@fragiola/flow-vue 0.0.0-stage → 0.0.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["EdgePath","EdgePath","Viewport","parts"],"sources":["../src/composables/create-flow-ref.ts","../src/composables/use-connection.ts","../src/composables/use-edge.ts","../src/composables/use-edges.ts","../src/composables/use-flow.ts","../src/composables/use-flow-ref.ts","../src/composables/use-flow-store.ts","../src/composables/use-handle.ts","../src/composables/use-internal-node.ts","../src/composables/use-key-press.ts","../src/composables/use-node.ts","../src/composables/use-node-connections.ts","../src/composables/use-node-id.ts","../src/composables/use-nodes.ts","../src/composables/use-nodes-data.ts","../src/composables/use-on-viewport-change.ts","../src/composables/use-selection.ts","../src/composables/use-viewport.ts","../src/components/background.ts","../src/components/connection-line.ts","../src/components/controls.ts","../src/components/edge-path.ts","../src/components/edge.ts","../src/components/edge-label.ts","../src/components/edge-toolbar.ts","../src/components/edges.ts","../src/composables/use-control-button.ts","../src/components/fit-view.ts","../src/components/handle.ts","../src/components/node.ts","../src/components/node-toolbar.ts","../src/components/nodes.ts","../src/components/nodes-selection.ts","../src/components/reconnect-anchor.ts","../src/utils/engine-facade.ts","../src/utils/flow-store.ts","../src/components/root.ts","../src/components/selection-box.ts","../src/components/toggle-interactive.ts","../src/components/viewport.ts","../src/components/zoom-in.ts","../src/components/zoom-out.ts","../src/parts.ts","../src/typed.ts"],"sourcesContent":["// From Tree (fragiola/tree, packages/vue/src/composables/create-tree-ref.ts), same author and\n// licence.\nimport type {\n AnyTypes,\n FlowEngine,\n FlowFeatures,\n FlowModel,\n FlowTypes,\n} from \"@fragiola/flow\";\nimport { markRaw, type ShallowRef, shallowRef, toRaw } from \"vue\";\n\n/** What a flow ref gives once its `Flow.Root` is mounted: the root's model and engine. */\nexport interface FlowRefValue<\n T extends FlowTypes = AnyTypes,\n F extends FlowFeatures = readonly [],\n> {\n readonly model: FlowModel<T, F>;\n readonly engine: FlowEngine<T, F>;\n}\n\ndeclare const flowRefBrand: unique symbol;\n\n/**\n * Access to a `Flow.Root` from outside it (a toolbar, a menu, a test): pass it as the root's\n * `flow-ref`; `value` is the root's model and engine while it is mounted, `null` otherwise.\n * `value` is reactive, so a render that reads it re-renders when the root mounts or unmounts.\n *\n * It is not a Vue ref: a template does not unwrap it, so `:flow-ref=\"flow\"` passes the flow ref\n * itself, and the template reads `flow.value`, as a script does.\n */\nexport interface FlowRef<\n T extends FlowTypes = AnyTypes,\n F extends FlowFeatures = readonly [],\n> {\n /** the root's model and engine while it is mounted, `null` otherwise */\n readonly value: FlowRefValue<T, F> | null;\n /** only `createFlowRef` and `useFlowRef` make a flow ref */\n readonly [flowRefBrand]: true;\n}\n\n/** the reactive value behind each flow ref, which only `Flow.Root` sets */\nconst values = new WeakMap<object, ShallowRef<FlowRefValue | null>>();\n\n/**\n * Creates a flow ref anywhere (a module, a test, `setup`, where `useFlowRef` says the same).\n *\n * ```ts\n * const flow = createFlowRef<Types, typeof features>();\n * // <Flow.Root :flow-ref=\"flow\" :features=\"features\" :default-nodes=\"nodes\">…</Flow.Root>\n * flow.value?.engine.run(\"fit-view\");\n * ```\n */\nexport function createFlowRef<\n T extends FlowTypes = AnyTypes,\n F extends FlowFeatures = readonly [],\n>(): FlowRef<T, F> {\n const value = shallowRef<FlowRefValue | null>(null);\n // a plain object, never made reactive: a template neither unwraps it nor wraps it in a proxy\n const flow = markRaw({\n get value() {\n return value.value;\n },\n });\n values.set(flow, value);\n return flow as unknown as FlowRef<T, F>;\n}\n\n/** @internal what `Flow.Root` calls: attaches (or, with `null`, detaches) its model and engine */\nexport function setFlowRef(\n flow: FlowRef<FlowTypes, FlowFeatures>,\n next: FlowRefValue<FlowTypes, FlowFeatures> | null,\n): void {\n const current = values.get(toRaw(flow));\n if (!current) {\n throw new TypeError(\n \"Flow.Root: `flow-ref` takes a flow ref from useFlowRef or createFlowRef\",\n );\n }\n current.value = next as unknown as FlowRefValue | null;\n}\n","import type { Connection } from \"@fragiola/flow\";\nimport type { ComputedRef } from \"vue\";\nimport { useFlowContext } from \"../context\";\nimport { useFlowValue } from \"./internal\";\n\n/**\n * The connection being drawn from a handle (`connection()`), or null, as a computed ref that\n * changes with it: where it starts and ends, the handle it would end at and whether the drop would\n * be accepted (`status`).\n */\nexport function useConnection(): ComputedRef<Connection | null> {\n const context = useFlowContext(\"useConnection\");\n return useFlowValue(\n context,\n () => context.engine.value?.get(\"connection\") ?? null,\n (a, b) =>\n a === b ||\n (a !== null &&\n b !== null &&\n a.path === b.path &&\n a.status === b.status &&\n a.to === b.to &&\n a.from === b.from &&\n a.toSide === b.toSide),\n );\n}\n","import {\n type AnyTypes,\n type EdgePath,\n type FlowEdge,\n type FlowTypes,\n flag,\n type PartAttributes,\n partAttributes,\n} from \"@fragiola/flow\";\nimport {\n type ComputedRef,\n computed,\n type MaybeRefOrGetter,\n toValue,\n} from \"vue\";\nimport { type FlowContextValue, useFlowContext } from \"../context\";\nimport { shallowEqual } from \"../utils/shallow-equal\";\nimport { useFlowValue } from \"./internal\";\n\n/** What an edge shows: its state on screen. */\nexport interface EdgeState<T extends FlowTypes = AnyTypes> {\n readonly edgeId: string;\n /** the edge, as the model holds it */\n readonly edge: FlowEdge<T>;\n /**\n * its path, label point and ends (`edge-path-by`), once both its nodes have a size; an app\n * type gets the bezier path, and its ends to draw its own\n */\n readonly path: EdgePath | undefined;\n /** `data-selected` (`selection()`) */\n readonly selected: boolean;\n /** one of its ends is being moved (`reconnection()`) */\n readonly reconnecting: boolean;\n /** it takes DOM focus (`keyboard()`): `tabindex=\"0\"` */\n readonly focusable: boolean;\n readonly attributes: PartAttributes;\n}\n\n/** What goes on an edge's element (an SVG group). */\nexport type EdgeElementProps = {\n tabindex: number | undefined;\n} & Readonly<Record<`data-${string}`, string | undefined>>;\n\nexport interface UseEdgeResult<T extends FlowTypes = AnyTypes> {\n state: ComputedRef<EdgeState<T>>;\n /** what goes on the edge's element (`v-bind`): its attributes and `tabindex` */\n props: ComputedRef<EdgeElementProps>;\n}\n\n/** Two edge paths that draw the same (`edge-path-by` builds a new one at every read). */\nexport function sameEdgePath(\n a: EdgePath | undefined,\n b: EdgePath | undefined,\n): boolean {\n if (a === b) return true;\n if (!a || !b) return false;\n return (\n a.path === b.path &&\n a.sourceSide === b.sourceSide &&\n a.targetSide === b.targetSide &&\n a.label.x === b.label.x &&\n a.label.y === b.label.y &&\n a.source.x === b.source.x &&\n a.source.y === b.source.y &&\n a.target.x === b.target.x &&\n a.target.y === b.target.y\n );\n}\n\ninterface EdgeView {\n attributes: PartAttributes;\n path: EdgePath | undefined;\n reconnecting: boolean;\n focusable: boolean;\n}\n\n/** An edge's state and the props of its element, for an edge drawn by hand (`Flow.Edge` uses it). */\nexport function useEdge<T extends FlowTypes = AnyTypes>(\n edge: MaybeRefOrGetter<FlowEdge<T>>,\n): UseEdgeResult<T> {\n const context = useFlowContext(\"useEdge\");\n const current = () => toValue(edge);\n const view = useFlowValue<EdgeView>(\n context,\n () => {\n const edgeId = current().id;\n const engine = context.engine.value;\n return engine\n ? {\n attributes: engine.adapter.attributes(\"edge\", { edgeId }),\n path: engine.get(\"edge-path-by\", { edgeId }),\n reconnecting: engine.is(\"edge-reconnecting\", { edgeId }),\n focusable: engine.is(\"edge-focusable\", { edgeId }),\n }\n : {\n attributes: edgeAttributes(context, \"edge\", edgeId),\n path: staticEdgePath(context, edgeId),\n reconnecting: false,\n focusable: false,\n };\n },\n (a, b) =>\n a.reconnecting === b.reconnecting &&\n a.focusable === b.focusable &&\n sameEdgePath(a.path, b.path) &&\n shallowEqual(a.attributes, b.attributes),\n \"entity\",\n () => ({ kind: \"edge\", id: current().id }),\n );\n const state = computed<EdgeState<T>>(() => {\n const { attributes, path, reconnecting, focusable } = view.value;\n const value = current();\n return {\n edgeId: value.id,\n edge: value,\n path,\n selected: attributes[\"data-selected\"] !== undefined,\n reconnecting,\n focusable,\n attributes,\n };\n });\n const props = computed<EdgeElementProps>(() => ({\n ...view.value.attributes,\n tabindex: view.value.focusable ? 0 : undefined,\n }));\n return { state, props };\n}\n\n/** @internal an edge's path, triggering its readers when it changes (`Flow.EdgePath`, …) */\nexport function useEdgePath(\n context: FlowContextValue,\n edgeId: () => string,\n): ComputedRef<EdgePath | undefined> {\n return useFlowValue(\n context,\n () => {\n const engine = context.engine.value;\n return engine\n ? engine.get(\"edge-path-by\", { edgeId: edgeId() })\n : staticEdgePath(context, edgeId());\n },\n sameEdgePath,\n \"entity\",\n () => ({ kind: \"edge\", id: edgeId() }),\n );\n}\n\n/** An edge's path before the engine exists: the static geometry's (absent until both sizes are known). */\nfunction staticEdgePath(\n context: FlowContextValue,\n edgeId: string,\n): EdgePath | undefined {\n return context.geometry.value?.edgePaths[edgeId];\n}\n\n/**\n * @internal the attributes of an edge's part (`edge`, `edge-path`, `edge-label`): the engine's, or\n * before it exists the same from the model (its id, `data-selected`, `data-animated`)\n */\nexport function edgeAttributes(\n context: FlowContextValue,\n part: \"edge\" | \"edge-path\" | \"edge-label\",\n edgeId: string,\n): PartAttributes {\n const engine = context.engine.value;\n if (engine) return engine.adapter.attributes(part, { edgeId });\n const edge = context.model.get(\"edge-by\", { id: edgeId });\n return {\n ...partAttributes(part, edgeId),\n \"data-selected\": flag(edge?.selected === true),\n \"data-animated\": flag(edge?.animated === true),\n };\n}\n","import type { AnyTypes, FlowEdge, FlowTypes } from \"@fragiola/flow\";\nimport type { ComputedRef } from \"vue\";\nimport { useFlowContext } from \"../context\";\nimport { useFlowValue } from \"./internal\";\n\n/**\n * Every edge of the enclosing `Flow.Root`, in drawing order, as a computed ref that changes on\n * every change of one (the model's frozen list, never made reactive).\n */\nexport function useEdges<T extends FlowTypes = AnyTypes>(): ComputedRef<\n readonly FlowEdge<T>[]\n> {\n const context = useFlowContext(\"useEdges\");\n return useFlowValue(\n context,\n () => context.model.get(\"all-edges\") as readonly FlowEdge<T>[],\n Object.is,\n );\n}\n","import type {\n AnyTypes,\n FlowEngine,\n FlowFeatures,\n FlowModel,\n FlowTypes,\n} from \"@fragiola/flow\";\nimport { typedEngine, typedModel, useFlowContext } from \"../context\";\n\nexport interface UseFlowResult<\n T extends FlowTypes = AnyTypes,\n F extends FlowFeatures = readonly [],\n> {\n /**\n * the model of the enclosing `Flow.Root`: the flow's document and its rules. Change it with\n * `model.run(\"node.move\", { nodeId, position })`, read it with `model.get` / `model.is`\n */\n model: FlowModel<T, F>;\n /**\n * the engine of the flow on screen: screen actions (`engine.run(\"fit-view\")`), screen facts\n * (`engine.get(\"viewport\")`) and its events (`engine.subscribe`). It is there from `setup`;\n * before the root is mounted (and on the server) an action is refused and a read is empty\n */\n engine: FlowEngine<T, F>;\n}\n\n/**\n * The model and the engine of the enclosing `Flow.Root`. Pass the registry and the features as the\n * type arguments (`useFlow<Types, typeof features>()`): a child cannot infer them through\n * injection. Call it in `setup`: another model remounts the root, so the values never change for\n * a component.\n */\nexport function useFlow<\n T extends FlowTypes = AnyTypes,\n F extends FlowFeatures = readonly [],\n>(): UseFlowResult<T, F> {\n const context = useFlowContext(\"useFlow\");\n return {\n model: typedModel<T, F>(context.model),\n engine: typedEngine<T, F>(context.publicEngine),\n };\n}\n","// From Tree (fragiola/tree, packages/vue/src/composables/use-tree-ref.ts), same author and licence.\nimport type { AnyTypes, FlowFeatures, FlowTypes } from \"@fragiola/flow\";\nimport { createFlowRef, type FlowRef } from \"./create-flow-ref\";\n\n/**\n * A flow ref for this component: pass it as a `Flow.Root`'s `flow-ref`, and read `flow.value` in\n * the template (a toolbar next to the flow, which re-renders when the root mounts) or in handlers.\n * A template does not unwrap a flow ref: it reads `flow.value`, as a script does.\n *\n * ```vue\n * <script setup lang=\"ts\">\n * const flow = useFlowRef<Types>();\n * </script>\n * <template>\n * <button type=\"button\" :disabled=\"!flow.value\" @click=\"flow.value?.engine.run('fit-view')\">\n * Fit\n * </button>\n * <Flow.Root :flow-ref=\"flow\" :default-nodes=\"nodes\">…</Flow.Root>\n * </template>\n * ```\n */\nexport function useFlowRef<\n T extends FlowTypes = AnyTypes,\n F extends FlowFeatures = readonly [],\n>(): FlowRef<T, F> {\n return createFlowRef<T, F>();\n}\n","import type { AnyTypes, FlowFeatures, FlowTypes } from \"@fragiola/flow\";\nimport type { ComputedRef } from \"vue\";\nimport { typedEngine, typedModel, useFlowContext } from \"../context\";\nimport { useFlowValue } from \"./internal\";\nimport type { UseFlowResult } from \"./use-flow\";\n\n/**\n * A value selected from the model and the engine of the enclosing `Flow.Root`, as a computed ref\n * that triggers its readers only when it changes (`equal`, default `Object.is`): `selector` runs\n * again on every change of the model and every view change of the engine (a measurement, the\n * viewport, a gesture), and when a reactive value it reads changes. Pass the registry and the\n * features as the type arguments after the selected value's (`useFlowStore<number, Types, typeof\n * features>(…)`). Keep a selector that builds an object or an array with an `equal` that compares\n * it (`sameFlowValue`), or it changes on every change.\n */\nexport function useFlowStore<\n S,\n T extends FlowTypes = AnyTypes,\n F extends FlowFeatures = readonly [],\n>(\n selector: (flow: UseFlowResult<T, F>) => S,\n equal: (a: S, b: S) => boolean = Object.is,\n): ComputedRef<S> {\n const context = useFlowContext(\"useFlowStore\");\n const flow: UseFlowResult<T, F> = {\n model: typedModel<T, F>(context.model),\n engine: typedEngine<T, F>(context.publicEngine),\n };\n return useFlowValue(context, () => selector(flow), equal);\n}\n","import {\n type HandleRegistration,\n type HandleSide,\n type HandleType,\n type PartAttributes,\n partAttributes,\n} from \"@fragiola/flow\";\nimport {\n type ComputedRef,\n computed,\n type MaybeRefOrGetter,\n toValue,\n} from \"vue\";\nimport { useFlowContext, usePartNodeId } from \"../context\";\nimport { type ElementRef, elementRef } from \"../utils/render\";\nimport { sameValue, useFlowValue } from \"./internal\";\n\nexport interface UseHandleOptions {\n /** whether edges start (`source`) or end (`target`) here */\n type: HandleType;\n /** the side of the node it sits on: the direction its edges leave or enter by */\n side: HandleSide;\n /** its id among the node's handles of its type (none: the node's default handle) */\n handleId?: string | undefined;\n /** whether a connection may start or end here; default true */\n connectable?: boolean | undefined;\n /** whether a connection may start here (a drag, a tap, a key); default true */\n connectableStart?: boolean | undefined;\n /** whether a connection may end here (be its target); default true */\n connectableEnd?: boolean | undefined;\n /** its node; default the enclosing `Flow.Node`'s */\n nodeId?: string | undefined;\n}\n\n/** What a handle shows. */\nexport interface HandleState {\n readonly nodeId: string;\n readonly handleId: string | undefined;\n readonly type: HandleType;\n readonly side: HandleSide;\n /** a connection may start or end here (its flag and its node's): `data-connectable` */\n readonly connectable: boolean;\n /** a connection may start here: `data-connectable-start` */\n readonly connectableStart: boolean;\n /** a connection may end here: `data-connectable-end` */\n readonly connectableEnd: boolean;\n /** the connection under way starts here (`connection()`): `data-connecting` */\n readonly connecting: boolean;\n /** the connection under way would end here and be accepted: `data-valid` */\n readonly valid: boolean;\n /** the connection under way would end here and be refused: `data-invalid` */\n readonly invalid: boolean;\n readonly attributes: PartAttributes;\n}\n\n/** What goes on a handle's element. */\nexport type HandleElementProps = {\n /** the template ref that registers the element with the engine (D8) */\n ref: ElementRef;\n} & Readonly<Record<`data-${string}`, string | undefined>>;\n\nexport interface UseHandleResult {\n state: ComputedRef<HandleState>;\n /** what goes on the handle's element (`v-bind`): its attributes and its template ref */\n props: ComputedRef<HandleElementProps>;\n}\n\n/** A registration's identity: a change registers the handle again. */\nfunction registrationKey(registration: HandleRegistration): string {\n return JSON.stringify([\n registration.nodeId,\n registration.handleId ?? null,\n registration.type,\n registration.side,\n registration.connectable ?? null,\n registration.connectableStart ?? null,\n registration.connectableEnd ?? null,\n ]);\n}\n\n/**\n * A handle's state and the props of its element, for a handle rendered by hand (`Flow.Handle`\n * uses it): registered with the engine, which measures its centre relative to its node.\n */\nexport function useHandle(\n options: MaybeRefOrGetter<UseHandleOptions>,\n): UseHandleResult {\n const context = useFlowContext(\"useHandle\");\n const nodeIdOf = usePartNodeId(\"Handle\", () => toValue(options).nodeId);\n // the last object while its fields stay: a new one registers the handle again\n const registration = computed<HandleRegistration>((previous) => {\n const {\n type,\n side,\n handleId,\n connectable,\n connectableStart,\n connectableEnd,\n } = toValue(options);\n const next = {\n nodeId: nodeIdOf(),\n handleId,\n type,\n side,\n connectable,\n connectableStart,\n connectableEnd,\n };\n return previous !== undefined &&\n registrationKey(previous) === registrationKey(next)\n ? previous\n : next;\n });\n const attributes = useFlowValue(\n context,\n () => {\n const value = registration.value;\n const engine = context.engine.value;\n return engine\n ? engine.adapter.attributes(\"handle\", value)\n : {\n ...partAttributes(\"handle\", value.handleId),\n \"data-handle-type\": value.type,\n \"data-side\": value.side,\n };\n },\n sameValue,\n \"entity\",\n );\n const ref = elementRef(\n (element) => {\n const engine = context.engine.value;\n if (!engine) return undefined;\n const value = registration.value;\n engine.adapter.registerHandle(value, element);\n return () => engine.adapter.registerHandle(value, null);\n },\n () => [context.engine.value, registrationKey(registration.value)],\n );\n const state = computed<HandleState>(() => {\n const value = registration.value;\n const current = attributes.value;\n return {\n nodeId: value.nodeId,\n handleId: value.handleId,\n type: value.type,\n side: value.side,\n connectable: current[\"data-connectable\"] !== undefined,\n connectableStart: current[\"data-connectable-start\"] !== undefined,\n connectableEnd: current[\"data-connectable-end\"] !== undefined,\n connecting: current[\"data-connecting\"] !== undefined,\n valid: current[\"data-valid\"] !== undefined,\n invalid: current[\"data-invalid\"] !== undefined,\n attributes: current,\n };\n });\n const props = computed<HandleElementProps>(() => {\n context.engine.value;\n return { ...attributes.value, ref };\n });\n return { state, props };\n}\n","import {\n type AnyTypes,\n type FlowTypes,\n type InternalNode,\n sameFlowValue,\n} from \"@fragiola/flow\";\nimport type { ComputedRef, MaybeRefOrGetter } from \"vue\";\nimport { toValue } from \"vue\";\nimport { useFlowContext } from \"../context\";\nimport { useFlowValue } from \"./internal\";\n\n/**\n * A node as the engine knows it on screen (`internal-node-by`), as a computed ref: the document's\n * node, its absolute position and box (`nodeOrigin` applied), whether its size is known, its\n * z-index and its handles with their centres; undefined while it does not exist or before the root\n * is mounted. It changes only when one of them changes (compared by value): a pan does not. The\n * id may be a ref or a getter.\n */\nexport function useInternalNode<T extends FlowTypes = AnyTypes>(\n nodeId: MaybeRefOrGetter<string>,\n): ComputedRef<InternalNode<T> | undefined> {\n const context = useFlowContext(\"useInternalNode\");\n return useFlowValue(\n context,\n () =>\n context.engine.value?.get(\"internal-node-by\", {\n nodeId: toValue(nodeId),\n }) as InternalNode<T> | undefined,\n sameFlowValue,\n );\n}\n","import {\n type KeyPressKeys,\n type KeyPressTarget,\n watchKeyPress,\n} from \"@fragiola/flow\";\nimport {\n inject,\n type MaybeRefOrGetter,\n type Ref,\n readonly,\n shallowRef,\n toValue,\n watchEffect,\n} from \"vue\";\nimport { FlowKey } from \"../context\";\n\nexport interface UseKeyPressOptions {\n /** where the keys are read: a window, a document or an element; default the root's window */\n target?: KeyPressTarget | null | undefined;\n}\n\n/**\n * Whether a key, or a combo of keys, is held, as a ref that changes with it. `keys` is a combo or\n * several (any of them): key names joined by `+`, held at once (`\"Shift\"`, `\"Meta+s\"`,\n * `[\"Meta+z\", \"Control+z\"]`); a name is a `KeyboardEvent.key` or `.code`, without case\n * (`watchKeyPress`). The keys are read on `target`, by default the window of the enclosing\n * `Flow.Root`'s element (never the global one): false before the root is mounted, or outside a\n * root without a `target`. The keys and the options may be refs or getters.\n */\nexport function useKeyPress(\n keys: MaybeRefOrGetter<KeyPressKeys>,\n options: MaybeRefOrGetter<UseKeyPressOptions> = {},\n): Readonly<Ref<boolean>> {\n const rootElement = inject(FlowKey, null)?.rootElement;\n const pressed = shallowRef(false);\n watchEffect((onCleanup) => {\n const given = toValue(options).target;\n const target =\n given === undefined\n ? (rootElement?.value?.ownerDocument.defaultView ?? null)\n : given;\n if (!target) return;\n const value = toValue(keys);\n const stop = watchKeyPress(\n target,\n typeof value === \"string\" ? [value] : [...value],\n (held) => {\n pressed.value = held;\n },\n );\n onCleanup(() => {\n stop();\n pressed.value = false;\n });\n });\n return readonly(pressed);\n}\n","import {\n type AnyTypes,\n type FlowNode,\n type FlowTypes,\n flag,\n type PartAttributes,\n partAttributes,\n} from \"@fragiola/flow\";\nimport {\n type ComponentInternalInstance,\n type ComputedRef,\n computed,\n ErrorCodes,\n getCurrentInstance,\n handleError,\n type MaybeRefOrGetter,\n queuePostFlushCb,\n toValue,\n} from \"vue\";\nimport { useFlowContext } from \"../context\";\nimport { type ElementRef, elementRef, px } from \"../utils/render\";\nimport { sameValue, useFlowValue } from \"./internal\";\n\n/** What a node shows: its state on screen. */\nexport interface NodeState<T extends FlowTypes = AnyTypes> {\n readonly nodeId: string;\n /** the node, as the model holds it */\n readonly node: FlowNode<T>;\n /** its top-left corner in absolute flow coordinates (its parents' positions added) */\n readonly x: number;\n readonly y: number;\n /** `data-selected` (`selection()`) */\n readonly selected: boolean;\n /** `data-dragging` (`drag()`) */\n readonly dragging: boolean;\n /** `data-resizing` (`resize()`) */\n readonly resizing: boolean;\n /** its size is known (measured or given): `data-measured` */\n readonly measured: boolean;\n /** it takes DOM focus (`keyboard()`): `tabindex=\"0\"` */\n readonly focusable: boolean;\n /** the attributes its element carries (`data-flow-part`, `data-flow-id`, the state) */\n readonly attributes: PartAttributes;\n}\n\n/** What goes on a node's element. */\nexport type NodeElementProps = {\n /** the template ref that registers the element with the engine (measured) */\n ref: ElementRef;\n tabindex: number | undefined;\n /** absolute, at its position, with the document's size when given */\n style: Record<string, string>;\n} & Readonly<Record<`data-${string}`, string | undefined>>;\n\nexport interface UseNodeResult<T extends FlowTypes = AnyTypes> {\n state: ComputedRef<NodeState<T>>;\n /**\n * what goes on the node's element (`v-bind`): its attributes, `tabindex`, its structural style\n * and the template ref that registers it with the engine\n */\n props: ComputedRef<NodeElementProps>;\n}\n\ninterface NodeView {\n attributes: PartAttributes;\n x: number;\n y: number;\n /** its structural `z-index` (`node-z-index-by`, or the static geometry's before the engine) */\n zIndex: number | undefined;\n focusable: boolean;\n}\n\n/** a node registration of the current patch, and the component whose element it is */\ninterface PendingRegistration {\n readonly register: () => void;\n readonly instance: ComponentInternalInstance | null;\n}\n\n/** the node registrations of the current patch, made once it is done (`registerLater`) */\nlet pending = new Set<PendingRegistration>();\nlet scheduled = false;\n\n/** Makes the patch's pending registrations; one that throws goes to Vue's error handling. */\nfunction registerPending(): void {\n scheduled = false;\n const batch = pending;\n pending = new Set();\n const failures: [unknown, PendingRegistration][] = [];\n for (const entry of batch) {\n try {\n entry.register();\n } catch (error) {\n failures.push([error, entry]);\n }\n }\n for (const [error, entry] of failures) {\n handleError(error, entry.instance, ErrorCodes.FUNCTION_REF);\n }\n}\n\n/**\n * Registers a node's element once Vue's patch is done, all the patch's nodes at once. Vue calls an\n * element's function ref as soon as the element is inserted, and the engine measures a node when\n * it is registered (`offsetWidth`): registered there, each node mounted in a patch (hundreds, on a\n * zoom out) would force a layout of its own between the insertions, where React's refs (and these)\n * come after every insertion, so the first measurement lays the page out once. The batch is a\n * post-flush job with Vue's template-ref id (-1): it runs after the patch, before the mounted\n * hooks and `flush: \"post\"` watchers, and before the patch's `nextTick` resolves, as a ref set\n * during the patch would. Returns whether it was still pending (then it is cancelled).\n */\nfunction registerLater(\n register: () => void,\n instance: ComponentInternalInstance | null,\n): () => boolean {\n const entry: PendingRegistration = { register, instance };\n pending.add(entry);\n if (!scheduled) {\n scheduled = true;\n queuePostFlushCb(Object.assign(() => registerPending(), { id: -1 }));\n }\n return () => pending.delete(entry);\n}\n\n/**\n * A node's state and the props of its element, for a node rendered by hand (`Flow.Node` uses it).\n * Bind `props` on the element (the engine resolves presses from its attributes), in a render that\n * reads `props.value`.\n */\nexport function useNode<T extends FlowTypes = AnyTypes>(\n node: MaybeRefOrGetter<FlowNode<T>>,\n): UseNodeResult<T> {\n const context = useFlowContext(\"useNode\");\n const { model } = context;\n const instance = getCurrentInstance();\n const current = () => toValue(node);\n const view = useFlowValue<NodeView>(\n context,\n () => {\n const value = current();\n const nodeId = value.id;\n const engine = context.engine.value;\n if (!engine) {\n // the static geometry (a server render, the first client render): its box with the\n // node origin applied and its z-index, as the engine gives them before measuring\n const geometry = context.geometry.value;\n const rect = geometry?.nodeRects[nodeId];\n const at = rect\n ? undefined\n : model.get(\"absolute-position-by\", { nodeId });\n return {\n attributes: {\n ...partAttributes(\"node\", nodeId),\n \"data-selected\": flag(value.selected === true),\n },\n x: rect?.x ?? at?.x ?? value.position.x,\n y: rect?.y ?? at?.y ?? value.position.y,\n zIndex: geometry?.nodeZIndexes[nodeId],\n focusable: false,\n };\n }\n const rect = engine.get(\"node-rect-by\", { nodeId });\n return {\n attributes: engine.adapter.attributes(\"node\", { nodeId }),\n x: rect?.x ?? value.position.x,\n y: rect?.y ?? value.position.y,\n zIndex: engine.get(\"node-z-index-by\", { nodeId }),\n focusable: engine.is(\"node-focusable\", { nodeId }),\n };\n },\n sameValue,\n \"entity\",\n () => ({ kind: \"node\", id: current().id }),\n );\n const ref = elementRef(\n (element) => {\n const engine = context.engine.value;\n if (!engine) return undefined;\n const nodeId = current().id;\n const cancel = registerLater(\n () =>\n engine.adapter.registerNode(nodeId, element as HTMLElement),\n instance,\n );\n return () => {\n if (!cancel()) engine.adapter.registerNode(nodeId, null);\n };\n },\n () => [context.engine.value, current().id],\n );\n const state = computed<NodeState<T>>(() => {\n const { attributes, x, y, focusable } = view.value;\n const value = current();\n return {\n nodeId: value.id,\n node: value,\n x,\n y,\n selected: attributes[\"data-selected\"] !== undefined,\n dragging: attributes[\"data-dragging\"] !== undefined,\n resizing: attributes[\"data-resizing\"] !== undefined,\n measured: attributes[\"data-measured\"] !== undefined,\n focusable,\n attributes,\n };\n });\n const props = computed<NodeElementProps>(() => {\n const { attributes, x, y, zIndex, focusable } = view.value;\n // the engine, read here: once it is there, the element patches and its ref registers it\n context.engine.value;\n const value = current();\n return {\n ...attributes,\n ref,\n tabindex: focusable ? 0 : undefined,\n style: {\n position: \"absolute\",\n top: \"0\",\n left: \"0\",\n transform: `translate(${px(x)}, ${px(y)})`,\n ...(zIndex === undefined ? {} : { zIndex: String(zIndex) }),\n ...(value.width === undefined\n ? {}\n : { width: px(value.width) }),\n ...(value.height === undefined\n ? {}\n : { height: px(value.height) }),\n },\n };\n });\n return { state, props };\n}\n","import {\n type HandleType,\n type NodeConnection,\n sameFlowValue,\n} from \"@fragiola/flow\";\nimport { type ComputedRef, inject, type MaybeRefOrGetter, toValue } from \"vue\";\nimport { NodeKey, useFlowContext } from \"../context\";\nimport { useFlowValue } from \"./internal\";\n\nexport interface UseNodeConnectionsOptions {\n /** the node; default the enclosing `Flow.Node`'s */\n id?: string | undefined;\n /** only the connections at this handle of it */\n handleId?: string | undefined;\n /** only those that start (`\"source\"`) or end (`\"target\"`) at it */\n type?: HandleType | undefined;\n}\n\n/**\n * The connections at a node (`node-connections-by`), as a computed ref: each edge that starts or\n * ends at it, as its `edgeId`, `source`, `sourceHandle`, `target` and `targetHandle`, in the\n * document's order. It changes only when they change (an edge added, removed or reconnected\n * there), not when a node moves or an edge's data changes. The options may be a ref or a getter;\n * outside a `Flow.Node`, give an `id`.\n */\nexport function useNodeConnections(\n options: MaybeRefOrGetter<UseNodeConnectionsOptions> = {},\n): ComputedRef<readonly NodeConnection[]> {\n const context = useFlowContext(\"useNodeConnections\");\n const node = inject(NodeKey, null);\n const nodeIdOf = () => {\n const id = toValue(options).id ?? node?.nodeId();\n if (id === undefined) {\n throw new Error(\n \"useNodeConnections must be called inside Flow.Node (or be given an id)\",\n );\n }\n return id;\n };\n // thrown in `setup`, as React's, rather than at the first read\n nodeIdOf();\n return useFlowValue(\n context,\n () => {\n const { handleId, type } = toValue(options);\n return context.model.get(\"node-connections-by\", {\n nodeId: nodeIdOf(),\n handleId,\n handleType: type,\n });\n },\n sameFlowValue,\n );\n}\n","import { type ComputedRef, computed, inject } from \"vue\";\nimport { NodeKey } from \"../context\";\n\n/**\n * The id of the node the component renders inside (`Flow.Node`), as a computed ref, or null\n * outside one: a custom node's piece reads its own node without being given its id.\n */\nexport function useNodeId(): ComputedRef<string | null> {\n const context = inject(NodeKey, null);\n return computed(() => context?.nodeId() ?? null);\n}\n","import type { AnyTypes, FlowNode, FlowTypes } from \"@fragiola/flow\";\nimport type { ComputedRef } from \"vue\";\nimport { useFlowContext } from \"../context\";\nimport { useFlowValue } from \"./internal\";\n\n/**\n * Every node of the enclosing `Flow.Root`, in drawing order, as a computed ref that changes on\n * every change of one (the model's frozen list, never made reactive).\n */\nexport function useNodes<T extends FlowTypes = AnyTypes>(): ComputedRef<\n readonly FlowNode<T>[]\n> {\n const context = useFlowContext(\"useNodes\");\n return useFlowValue(\n context,\n () => context.model.get(\"all-nodes\") as readonly FlowNode<T>[],\n Object.is,\n );\n}\n","import {\n type AnyTypes,\n type FlowTypes,\n type NodeData,\n sameFlowValue,\n} from \"@fragiola/flow\";\nimport {\n type ComputedRef,\n computed,\n type MaybeRefOrGetter,\n toValue,\n} from \"vue\";\nimport { useFlowContext } from \"../context\";\nimport { useFlowValue } from \"./internal\";\n\n/**\n * A node's id, type and data (`nodes-data-by`), as a computed ref, or null while it does not\n * exist; given several ids, each existing one's in the order given. It changes only when one of\n * them changes (its type or its data, compared by value), not when a node moves or another\n * changes. The ids may be a ref or a getter.\n */\nexport function useNodesData<T extends FlowTypes = AnyTypes>(\n nodeId: MaybeRefOrGetter<string>,\n): ComputedRef<NodeData<T> | null>;\nexport function useNodesData<T extends FlowTypes = AnyTypes>(\n nodeIds: MaybeRefOrGetter<readonly string[]>,\n): ComputedRef<readonly NodeData<T>[]>;\nexport function useNodesData<T extends FlowTypes = AnyTypes>(\n ids: MaybeRefOrGetter<string | readonly string[]>,\n): ComputedRef<NodeData<T> | null | readonly NodeData<T>[]> {\n const context = useFlowContext(\"useNodesData\");\n const list = useFlowValue(\n context,\n () => {\n const value = toValue(ids);\n return context.model.get(\"nodes-data-by\", {\n nodeIds: typeof value === \"string\" ? [value] : [...value],\n }) as readonly NodeData<T>[];\n },\n sameFlowValue,\n );\n // one id: its entry (the list keeps its object while equal, so does the entry)\n return computed(() =>\n typeof toValue(ids) === \"string\" ? (list.value[0] ?? null) : list.value,\n );\n}\n","import type { Viewport } from \"@fragiola/flow\";\nimport { type MaybeRefOrGetter, toValue, watchEffect } from \"vue\";\nimport { useFlowContext } from \"../context\";\n\nexport interface UseOnViewportChangeOptions {\n /** the viewport starts changing (`viewport-change-start`): a pan, a zoom, an animation */\n onStart?: ((viewport: Viewport, gesture: boolean) => void) | undefined;\n /** each change of the viewport (`viewport-change`) */\n onChange?: ((viewport: Viewport, gesture: boolean) => void) | undefined;\n /** the viewport stopped changing (`viewport-change-end`) */\n onEnd?: ((viewport: Viewport, gesture: boolean) => void) | undefined;\n}\n\n/**\n * Calls back on the viewport's changes of the enclosing `Flow.Root` (the engine's events), without\n * rendering anything: `gesture` is true for a pan, the wheel, a pinch or auto-pan, false for an\n * action. `options` is a value, a ref or a getter, and its callbacks are read at each event (a\n * reactive object's, a ref's or a getter's latest).\n */\nexport function useOnViewportChange(\n options: MaybeRefOrGetter<UseOnViewportChangeOptions>,\n): void {\n const context = useFlowContext(\"useOnViewportChange\");\n watchEffect((onCleanup) => {\n const engine = context.engine.value;\n if (!engine) return;\n const stop = engine.subscribe((event) => {\n // read at each event, never tracked by this effect\n const now = toValue(options);\n if (event.type === \"viewport-change-start\") {\n now.onStart?.(event.viewport, event.gesture);\n } else if (event.type === \"viewport-change\") {\n now.onChange?.(event.viewport, event.gesture);\n } else if (event.type === \"viewport-change-end\") {\n now.onEnd?.(event.viewport, event.gesture);\n }\n });\n onCleanup(stop);\n });\n}\n","import type { AnyTypes, FlowEdge, FlowNode, FlowTypes } from \"@fragiola/flow\";\nimport type { ComputedRef } from \"vue\";\nimport { useFlowContext } from \"../context\";\nimport { useFlowValue } from \"./internal\";\n\n/** What is selected. */\nexport interface FlowSelection<T extends FlowTypes = AnyTypes> {\n readonly nodes: readonly FlowNode<T>[];\n readonly edges: readonly FlowEdge<T>[];\n}\n\nconst NONE: readonly never[] = Object.freeze([]);\n\n/**\n * The selected nodes and edges of the enclosing `Flow.Root` (`selection()`; none without it), as a\n * computed ref that changes with them: a panel showing the selection, a Delete button.\n */\nexport function useSelection<T extends FlowTypes = AnyTypes>(): ComputedRef<\n FlowSelection<T>\n> {\n const context = useFlowContext(\"useSelection\");\n const { model } = context;\n return useFlowValue(\n context,\n () => ({\n nodes: (model.get(\"selected-nodes\") ??\n NONE) as readonly FlowNode<T>[],\n edges: (model.get(\"selected-edges\") ??\n NONE) as readonly FlowEdge<T>[],\n }),\n (a, b) =>\n a.nodes.length === b.nodes.length &&\n a.edges.length === b.edges.length &&\n a.nodes.every((node, i) => node === b.nodes[i]) &&\n a.edges.every((edge, i) => edge === b.edges[i]),\n );\n}\n","import type { Viewport } from \"@fragiola/flow\";\nimport type { ComputedRef } from \"vue\";\nimport { useFlowContext } from \"../context\";\nimport { useFlowValue } from \"./internal\";\n\n/**\n * The viewport of the enclosing `Flow.Root` (`{ x, y, zoom }`), as a computed ref that changes\n * with it: a zoom level readout, a control's state. Change it with `engine.run(\"set-viewport\")`.\n */\nexport function useViewport(): ComputedRef<Viewport> {\n const context = useFlowContext(\"useViewport\");\n return useFlowValue(context, () => context.publicEngine.get(\"viewport\"));\n}\n","import {\n type BackgroundPattern,\n type BackgroundVariant,\n partAttributes,\n} from \"@fragiola/flow\";\nimport { h, useId } from \"vue\";\nimport { useFlowValue } from \"../composables/internal\";\nimport { useFlowContext } from \"../context\";\nimport {\n definePrimitive,\n type FlowComponent,\n type PrimitiveProps,\n} from \"../utils/primitive\";\nimport { type RenderSlot, renderElement } from \"../utils/render\";\n\nexport interface BackgroundState {\n /** the pattern's tile on the screen, at the current viewport */\n readonly pattern: BackgroundPattern;\n}\n\nexport interface BackgroundProps extends PrimitiveProps {\n /** the marks: `dots` (default), `lines` or `cross` */\n variant?: BackgroundVariant | undefined;\n /** the distance between two marks, in flow units; default 20 (`[x, y]` for two) */\n gap?: number | readonly [number, number] | undefined;\n /** dots: a dot's diameter (flow units); lines: the stroke width (screen pixels); cross: a bar's length */\n size?: number | undefined;\n /** the pattern's shift from the flow's origin, in flow units */\n offset?: number | readonly [number, number] | undefined;\n}\n\nexport interface BackgroundSlots extends RenderSlot<BackgroundState> {}\n\nconst BACKGROUND_STYLE = {\n position: \"absolute\",\n top: \"0\",\n left: \"0\",\n width: \"100%\",\n height: \"100%\",\n pointerEvents: \"none\",\n};\n\nconst EMPTY_PATTERN: BackgroundPattern = Object.freeze({\n variant: \"dots\",\n x: 0,\n y: 0,\n width: 0,\n height: 0,\n dot: undefined,\n path: undefined,\n strokeWidth: 0,\n});\n\n/** A pair given as a reactive array, as the engine takes it (a plain one). */\nfunction plainPair(\n value: number | readonly [number, number] | undefined,\n): number | readonly [number, number] | undefined {\n return Array.isArray(value)\n ? ([value[0], value[1]] as readonly [number, number])\n : value;\n}\n\n/**\n * The flow's background (`data-flow-part=\"background\"`): an SVG pattern of dots, lines or crosses\n * that pans and zooms with the viewport (`background-pattern`), inside `Flow.Root` before\n * `Flow.Viewport`. The marks are drawn in `currentColor`: set the `color` (and the background\n * itself) in your style.\n */\nexport const Background: FlowComponent<BackgroundProps, BackgroundSlots> =\n definePrimitive<BackgroundProps, BackgroundSlots>(\n \"Background\",\n [\"variant\", \"gap\", \"size\", \"offset\", \"as\"],\n (props, { attrs, slots }) => {\n const context = useFlowContext(\"Background\");\n const pattern = useFlowValue(context, () =>\n context.engine.value?.get(\"background-pattern\", {\n variant: props.variant,\n gap: plainPair(props.gap),\n size: props.size,\n offset: plainPair(props.offset),\n }),\n );\n const id = `flow-background-${(useId() ?? \"\").replace(/[^a-zA-Z0-9_-]/g, \"\")}`;\n return () => {\n // drawn once the engine is there (a server render has the bare element)\n const tile = pattern.value;\n return renderElement({\n tag: \"svg\",\n as: props.as,\n attrs,\n render: slots.render,\n state: { pattern: tile ?? EMPTY_PATTERN },\n props: { ...partAttributes(\"background\") },\n style: BACKGROUND_STYLE,\n children: tile\n ? () => [\n h(\n \"pattern\",\n {\n \"data-flow-part\": \"background-pattern\",\n id,\n patternUnits: \"userSpaceOnUse\",\n x: tile.x,\n y: tile.y,\n width: tile.width,\n height: tile.height,\n },\n [\n tile.dot\n ? h(\"circle\", {\n \"data-flow-part\":\n \"background-mark\",\n cx: tile.dot.cx,\n cy: tile.dot.cy,\n r: tile.dot.r,\n fill: \"currentColor\",\n })\n : h(\"path\", {\n \"data-flow-part\":\n \"background-mark\",\n d: tile.path,\n fill: \"none\",\n stroke: \"currentColor\",\n \"stroke-width\":\n tile.strokeWidth,\n }),\n ],\n ),\n h(\"rect\", {\n \"data-flow-part\": \"background-fill\",\n width: \"100%\",\n height: \"100%\",\n fill: `url(#${id})`,\n }),\n ]\n : undefined,\n });\n };\n },\n );\n","import type { Connection } from \"@fragiola/flow\";\nimport { h } from \"vue\";\nimport { useFlowValue } from \"../composables/internal\";\nimport { useConnection } from \"../composables/use-connection\";\nimport { useFlowContext } from \"../context\";\nimport {\n definePrimitive,\n type FlowComponent,\n type PrimitiveProps,\n type SlotFunction,\n} from \"../utils/primitive\";\nimport { type RenderSlot, renderElement } from \"../utils/render\";\n\nexport interface ConnectionLineState {\n /** the connection being drawn */\n readonly connection: Connection;\n /** the drop would add the edge: `data-valid` */\n readonly valid: boolean;\n /** the drop would be refused (`model.can(\"edge.add\")`, a middleware's veto): `data-invalid` */\n readonly invalid: boolean;\n}\n\nexport interface ConnectionLineProps extends PrimitiveProps {}\n\nexport interface ConnectionLineSlots extends RenderSlot<ConnectionLineState> {\n /**\n * draws the line, in flow coordinates (`v-slot=\"{ connection }\"`); default an unfilled\n * `<path>` of the connection's path (`data-flow-part=\"connection-path\"`)\n */\n default?: SlotFunction<{ connection: Connection }>;\n}\n\nconst LINE_STYLE = {\n position: \"absolute\",\n top: \"0\",\n left: \"0\",\n width: \"100%\",\n height: \"100%\",\n overflow: \"visible\",\n pointerEvents: \"none\",\n};\n\n/**\n * The connection being drawn (`data-flow-part=\"connection-line\"`, `data-valid` / `data-invalid`,\n * `connection()`): an SVG inside `Flow.Viewport`, rendered only while a connection is under way.\n */\nexport const ConnectionLine: FlowComponent<\n ConnectionLineProps,\n ConnectionLineSlots\n> = definePrimitive<ConnectionLineProps, ConnectionLineSlots>(\n \"ConnectionLine\",\n [\"as\"],\n (props, { attrs, slots }) => {\n const context = useFlowContext(\"ConnectionLine\");\n const connection = useConnection();\n const attributes = useFlowValue(\n context,\n () =>\n context.engine.value?.adapter.attributes(\"connection-line\") ??\n {},\n );\n return () => {\n const current = connection.value;\n if (!current) return null;\n const own = attributes.value;\n const state: ConnectionLineState = {\n connection: current,\n valid: own[\"data-valid\"] !== undefined,\n invalid: own[\"data-invalid\"] !== undefined,\n };\n return renderElement({\n tag: \"svg\",\n as: props.as,\n attrs,\n render: slots.render,\n state,\n props: { ...own, \"data-flow-part\": \"connection-line\" },\n style: LINE_STYLE,\n children: () =>\n slots.default\n ? slots.default({ connection: current })\n : h(\"path\", {\n \"data-flow-part\": \"connection-path\",\n d: current.path,\n fill: \"none\",\n }),\n });\n };\n },\n);\n","import { partAttributes } from \"@fragiola/flow\";\nimport {\n definePrimitive,\n type FlowComponent,\n type PrimitiveProps,\n type SlotFunction,\n} from \"../utils/primitive\";\nimport { type RenderSlot, renderElement } from \"../utils/render\";\n\n/** The state of `Flow.Controls` (none: its buttons have their own). */\nexport type ControlsState = Record<never, never>;\n\nexport interface ControlsProps extends PrimitiveProps {}\n\nexport interface ControlsSlots extends RenderSlot<ControlsState> {\n /** its buttons: `Flow.ZoomIn`, `Flow.ZoomOut`, `Flow.FitView`, `Flow.ToggleInteractive`, … */\n default?: SlotFunction<Record<never, never>>;\n}\n\n/**\n * A group of the viewport's buttons (`data-flow-part=\"controls\"`): `Flow.ZoomIn`, `Flow.ZoomOut`,\n * `Flow.FitView`, `Flow.ToggleInteractive`, or your own. Inside `Flow.Root`, outside\n * `Flow.Viewport`; presses and the wheel over it are left to it. Place it with your style.\n */\nexport const Controls: FlowComponent<ControlsProps, ControlsSlots> =\n definePrimitive<ControlsProps, ControlsSlots>(\n \"Controls\",\n [\"as\"],\n (props, { attrs, slots }) =>\n () =>\n renderElement({\n tag: \"div\",\n as: props.as,\n attrs,\n render: slots.render,\n state: {},\n props: { ...partAttributes(\"controls\") },\n children: () => slots.default?.({}),\n }),\n );\n","import type { EdgePath as EdgePathValue } from \"@fragiola/flow\";\nimport { sameValue, useFlowValue } from \"../composables/internal\";\nimport { edgeAttributes, useEdgePath } from \"../composables/use-edge\";\nimport { useEdgeId, useFlowContext } from \"../context\";\nimport {\n definePrimitive,\n type FlowComponent,\n type PrimitiveProps,\n type SlotFunction,\n} from \"../utils/primitive\";\nimport { type RenderSlot, renderElement } from \"../utils/render\";\n\nexport interface EdgePathState {\n readonly edgeId: string;\n /** the edge's path, label point and ends */\n readonly path: EdgePathValue;\n /** `data-selected` (`selection()`) */\n readonly selected: boolean;\n}\n\nexport interface EdgePathProps extends PrimitiveProps {\n /** the edge; default the enclosing `Flow.Edge`'s */\n edgeId?: string | undefined;\n}\n\nexport interface EdgePathSlots extends RenderSlot<EdgePathState> {\n /** the path's SVG content (an `<animate>`, a `<title>`), as React's children */\n default?: SlotFunction<{ state: EdgePathState }>;\n}\n\n/**\n * An edge's path (`data-flow-part=\"edge-path\"`): an SVG `<path>` whose `d` is the engine's\n * (`edge-path-by`, D9; before the engine exists, the static geometry's), unfilled. A `d` of your own draws an app type (from `state.path`'s ends).\n * Several may share an edge: a wide transparent one is a bigger press target. Its default slot\n * renders inside the `<path>` (an `<animate>`, a `<title>`), as React's children.\n */\nexport const EdgePath: FlowComponent<EdgePathProps, EdgePathSlots> =\n definePrimitive<EdgePathProps, EdgePathSlots>(\n \"EdgePath\",\n [\"edgeId\", \"as\"],\n (props, { attrs, slots }) => {\n const context = useFlowContext(\"EdgePath\");\n const edgeId = useEdgeId(\"EdgePath\", () => props.edgeId);\n const path = useEdgePath(context, edgeId);\n const attributes = useFlowValue(\n context,\n () => edgeAttributes(context, \"edge-path\", edgeId()),\n sameValue,\n \"entity\",\n () => ({ kind: \"edge\", id: edgeId() }),\n );\n return () => {\n const current = path.value;\n const own = attributes.value;\n if (!current || !own) return null;\n const state: EdgePathState = {\n edgeId: edgeId(),\n path: current,\n selected: own[\"data-selected\"] !== undefined,\n };\n return renderElement({\n tag: \"path\",\n as: props.as,\n attrs,\n render: slots.render,\n state,\n props: { ...own, d: current.path, fill: \"none\" },\n children: slots.default\n ? () => slots.default?.({ state })\n : undefined,\n });\n };\n },\n );\n","import type { AnyTypes, FlowEdge, FlowTypes } from \"@fragiola/flow\";\nimport { h, nextTick, provide } from \"vue\";\nimport { type EdgeState, useEdge } from \"../composables/use-edge\";\nimport { EdgeKey, useFlowContext } from \"../context\";\nimport {\n definePrimitive,\n type FlowComponent,\n type PrimitiveProps,\n type SlotFunction,\n} from \"../utils/primitive\";\nimport { elementRef, type RenderSlot, renderElement } from \"../utils/render\";\nimport { EdgePath } from \"./edge-path\";\n\nexport interface EdgeProps<T extends FlowTypes = AnyTypes>\n extends PrimitiveProps {\n /** the edge it draws: the one `Flow.Edges` gives its slot */\n edge: FlowEdge<T>;\n}\n\nexport interface EdgeSlots<T extends FlowTypes = AnyTypes>\n extends RenderSlot<EdgeState<T>> {\n /** its parts: default a `Flow.EdgePath` */\n default?: SlotFunction<{ state: EdgeState<T> }>;\n}\n\nconst EDGE_STYLE = { pointerEvents: \"visibleStroke\" };\n\n/**\n * One edge (`data-flow-part=\"edge\"`, `data-flow-id`): an SVG group inside `Flow.Edges`, drawn once\n * both its nodes have a size (before the engine, the sizes its document gives: a server render\n * draws it). Mounted again in another render level's layer, it takes back the focus it had. It renders its default slot (`Flow.EdgePath` by default,\n * `Flow.EdgeLabel`, `Flow.ReconnectAnchor`); a press on its stroke selects it (`selection()`).\n */\nexport const Edge: FlowComponent<EdgeProps, EdgeSlots> = definePrimitive<\n EdgeProps,\n EdgeSlots\n>(\"Edge\", [\"edge\", \"as\"], (props, { attrs, slots }) => {\n const context = useFlowContext(\"Edge\");\n const { state, props: own } = useEdge(() => props.edge);\n provide(EdgeKey, { edgeId: () => props.edge.id });\n // a mounted edge that had focus takes it back (an edge moving to another render level's layer\n // mounts again there), once its new layer is in the document: Vue calls the ref before it\n // inserts a new parent\n const ref = elementRef(\n (element) => {\n const engine = context.engine.value;\n if (engine) {\n void nextTick(() => engine.adapter.refocus(element));\n }\n return undefined;\n },\n () => [context.engine.value],\n );\n return () => {\n const current = state.value;\n // the engine, read here: once it is there, the element patches and its ref sees it\n context.engine.value;\n if (!current.path) return null;\n return renderElement({\n tag: \"g\",\n as: props.as,\n attrs,\n render: slots.render,\n state: current,\n ref,\n props: { ...own.value },\n style: EDGE_STYLE,\n children: () =>\n slots.default ? slots.default({ state: current }) : h(EdgePath),\n });\n };\n});\n","import type { EdgePath } from \"@fragiola/flow\";\nimport { inject, onScopeDispose, shallowRef } from \"vue\";\nimport { sameValue, useFlowValue } from \"../composables/internal\";\nimport { edgeAttributes, useEdgePath } from \"../composables/use-edge\";\nimport { EdgeLabelLayerKey, useEdgeId, useFlowContext } from \"../context\";\nimport {\n definePrimitive,\n type FlowComponent,\n type PrimitiveProps,\n type SlotFunction,\n} from \"../utils/primitive\";\nimport { onClient, px, type RenderSlot, renderElement } from \"../utils/render\";\n\nexport interface EdgeLabelState {\n readonly edgeId: string;\n /** the edge's path, label point and ends */\n readonly path: EdgePath;\n /** `data-selected` (`selection()`) */\n readonly selected: boolean;\n}\n\nexport interface EdgeLabelProps extends PrimitiveProps {\n /** the edge; default the enclosing `Flow.Edge`'s */\n edgeId?: string | undefined;\n}\n\nexport interface EdgeLabelSlots extends RenderSlot<EdgeLabelState> {\n default?: SlotFunction<{ state: EdgeLabelState }>;\n}\n\nlet nextLabelKey = 0;\n\n/**\n * An edge's label (`data-flow-part=\"edge-label\"`): HTML, centred on the path's label point in\n * flow coordinates, in the HTML layer of `Flow.Edges` (SVG holds no HTML: it renders there, not\n * where it is written). It renders only its default slot; a press on it selects its edge.\n */\nexport const EdgeLabel: FlowComponent<EdgeLabelProps, EdgeLabelSlots> =\n definePrimitive<EdgeLabelProps, EdgeLabelSlots>(\n \"EdgeLabel\",\n [\"edgeId\", \"as\"],\n (props, { attrs, slots }) => {\n const context = useFlowContext(\"EdgeLabel\");\n const edgeId = useEdgeId(\"EdgeLabel\", () => props.edgeId);\n const layer = inject(EdgeLabelLayerKey, null);\n const path = useEdgePath(context, edgeId);\n const attributes = useFlowValue(\n context,\n () => edgeAttributes(context, \"edge-label\", edgeId()),\n sameValue,\n \"entity\",\n () => ({ kind: \"edge\", id: edgeId() }),\n );\n const version = shallowRef(0);\n // the label's element, rendered by the layer\n const render = () => {\n const current = path.value;\n const own = attributes.value;\n if (!current || !own) return null;\n const state: EdgeLabelState = {\n edgeId: edgeId(),\n path: current,\n selected: own[\"data-selected\"] !== undefined,\n };\n const { x, y } = current.label;\n return renderElement({\n tag: \"div\",\n as: props.as,\n attrs,\n render: slots.render,\n state,\n props: { ...own },\n style: {\n position: \"absolute\",\n top: \"0\",\n left: \"0\",\n transform: `translate(${px(x)}, ${px(y)}) translate(-50%, -50%)`,\n pointerEvents: \"all\",\n },\n children: () => slots.default?.({ state }),\n });\n };\n onClient(() => {\n if (!layer) return;\n const remove = layer.add({\n key: nextLabelKey++,\n edgeId,\n render,\n version,\n });\n onScopeDispose(remove);\n });\n // its attributes and slots are not reactive: a change renders the label again (written,\n // never read here, so this render does not depend on it)\n let renders = 0;\n return () => {\n version.value = ++renders;\n return null;\n };\n },\n );\n","import type { EdgeToolbarPosition, PartAttributes, XY } from \"@fragiola/flow\";\nimport { h, inject, onScopeDispose, shallowRef, Teleport } from \"vue\";\nimport { useFlowValue } from \"../composables/internal\";\nimport { EdgeLabelLayerKey, useEdgeId, useFlowContext } from \"../context\";\nimport {\n definePrimitive,\n type FlowComponent,\n type PrimitiveProps,\n type SlotFunction,\n} from \"../utils/primitive\";\nimport { onClient, px, type RenderSlot, renderElement } from \"../utils/render\";\n\nexport interface EdgeToolbarState {\n readonly edgeId: string;\n /** the point of the edge it stands at */\n readonly position: \"label\" | \"source\" | \"target\";\n /** where it is anchored (its `alignX` / `alignY` point), in pixels relative to the root */\n readonly anchor: EdgeToolbarPosition;\n}\n\nexport interface EdgeToolbarProps extends PrimitiveProps {\n /** its edge; default the enclosing `Flow.Edge`'s */\n edgeId?: string | undefined;\n /** the point of the edge it stands at: its label point, its source or its target end; default `\"label\"` */\n position?: \"label\" | \"source\" | \"target\" | undefined;\n /** a flow point it stands at instead (absolute flow coordinates); wins over `position` */\n point?: XY | undefined;\n /** a screen offset from that point, in pixels; default `{ x: 0, y: 0 }` */\n offset?: XY | undefined;\n /** which of its edges goes at the point across: its left (`\"start\"`), centre (default) or right */\n alignX?: \"start\" | \"center\" | \"end\" | undefined;\n /** which of its edges goes at the point down: its top (`\"start\"`), centre (default) or bottom */\n alignY?: \"start\" | \"center\" | \"end\" | undefined;\n /** whether it is shown; default while its edge is selected (`selection()`) */\n open?: boolean | undefined;\n}\n\nexport interface EdgeToolbarSlots extends RenderSlot<EdgeToolbarState> {\n /** your buttons */\n default?: SlotFunction<{ state: EdgeToolbarState }>;\n}\n\ninterface ToolbarView {\n anchor: EdgeToolbarPosition;\n attributes: PartAttributes;\n}\n\nlet nextToolbarKey = 0;\n\n/**\n * A toolbar on an edge (`data-flow-part=\"toolbar\"`, `data-flow-id` its edge's id), outside the\n * zoom: rendered in `Flow.Root` (a `Teleport`), centred at the point `edge-toolbar-by` gives (the\n * edge's label point or one of its ends), so it keeps its size at any zoom. Inside `Flow.Edges`\n * (SVG) it renders from the edges' HTML layer, whose `Teleport` creates HTML. Presses and the\n * wheel over it are left to it. It renders only its default slot (your buttons).\n */\nexport const EdgeToolbar: FlowComponent<EdgeToolbarProps, EdgeToolbarSlots> =\n definePrimitive<EdgeToolbarProps, EdgeToolbarSlots>(\n \"EdgeToolbar\",\n [\n \"edgeId\",\n \"position\",\n \"point\",\n \"offset\",\n \"alignX\",\n \"alignY\",\n \"open\",\n \"as\",\n ],\n (props, { attrs, slots }) => {\n const context = useFlowContext(\"EdgeToolbar\");\n const { model } = context;\n const edgeId = useEdgeId(\"EdgeToolbar\", () => props.edgeId);\n const layer = inject(EdgeLabelLayerKey, null);\n // hidden, it reads nothing of the view: a pan or a zoom gives the same value (nothing\n // renders again); shown, an equal anchor keeps the last value\n const view = useFlowValue<ToolbarView | undefined>(context, () => {\n const engine = context.engine.value;\n if (!engine) return undefined;\n const id = edgeId();\n if (!(props.open ?? model.is(\"edge-selected\", { edgeId: id })))\n return undefined;\n const anchor = engine.get(\"edge-toolbar-by\", {\n edgeId: id,\n position: props.position ?? \"label\",\n point: props.point,\n offset: props.offset,\n alignX: props.alignX,\n alignY: props.alignY,\n });\n return anchor\n ? {\n anchor,\n attributes: engine.adapter.attributes(\"toolbar\", {\n edgeId: id,\n }),\n }\n : undefined;\n });\n // the toolbar, teleported into the root\n const render = () => {\n const current = view.value;\n const root = context.rootElement.value;\n if (!current || !root) return null;\n const state: EdgeToolbarState = {\n edgeId: edgeId(),\n position: props.position ?? \"label\",\n anchor: current.anchor,\n };\n const { x, y, anchorX, anchorY } = current.anchor;\n return h(Teleport, { to: root }, [\n renderElement({\n tag: \"div\",\n as: props.as,\n attrs,\n render: slots.render,\n state,\n props: { ...current.attributes },\n style: {\n position: \"absolute\",\n top: \"0\",\n left: \"0\",\n transform: `translate(${px(x)}, ${px(y)}) translate(${-anchorX * 100}%, ${-anchorY * 100}%)`,\n },\n children: () => slots.default?.({ state }),\n }),\n ]);\n };\n if (!layer) return render;\n // inside the edges' SVG, a `Teleport` would keep creating SVG elements: the HTML layer\n // renders it (its attributes and slots are not reactive: a change renders it again)\n const version = shallowRef(0);\n onClient(() => {\n const remove = layer.add({\n key: `toolbar-${nextToolbarKey++}`,\n edgeId,\n render,\n version,\n });\n onScopeDispose(remove);\n });\n let renders = 0;\n return () => {\n version.value = ++renders;\n return null;\n };\n },\n { booleans: [\"open\"] },\n );\n","import {\n type AnyTypes,\n edgesLayerAttributes,\n type FlowEdge,\n type FlowTypes,\n partAttributes,\n} from \"@fragiola/flow\";\nimport {\n defineComponent,\n h,\n type PropType,\n provide,\n type Slot,\n shallowRef,\n} from \"vue\";\nimport { type DrawnLayer, useDrawnLayers } from \"../composables/internal\";\nimport {\n EdgeKey,\n type EdgeLabelEntry,\n type EdgeLabelLayer,\n EdgeLabelLayerKey,\n useFlowContext,\n} from \"../context\";\nimport {\n definePrimitive,\n type FlowComponent,\n type PrimitiveProps,\n type SlotFunction,\n} from \"../utils/primitive\";\nimport { type RenderSlot, renderElement } from \"../utils/render\";\n\nexport interface EdgesState {\n /** how many edges are drawn */\n count: number;\n}\n\nexport interface EdgesProps extends PrimitiveProps {}\n\nexport interface EdgesSlots<T extends FlowTypes = AnyTypes>\n extends RenderSlot<EdgesState> {\n /**\n * draws one edge (`v-slot=\"{ edge }\"`): usually a `Flow.Edge` (an SVG group) with its path and\n * label. Each edge's slot renders again when its edge changes, or a reactive value it reads\n * does\n */\n default?: SlotFunction<{ edge: FlowEdge<T> }>;\n}\n\nconst LAYER_STYLE = {\n position: \"absolute\",\n top: \"0\",\n left: \"0\",\n width: \"100%\",\n height: \"100%\",\n overflow: \"visible\",\n pointerEvents: \"none\",\n};\n\n/**\n * One edge's drawing, again only when its edge changes, a reactive value its slot reads does, or\n * the slot is a new one; its path renders again by itself (`Flow.EdgePath` follows `edge-path-by`).\n */\nconst EdgeSlot = defineComponent({\n name: \"FlowEdgeSlot\",\n props: {\n edge: { type: Object as PropType<FlowEdge>, required: true },\n // the slot itself: a new one (a render function's, or a slot that reads an outer slot's\n // scope) renders every entity again, a compiled template's stays the same\n slot: { type: Function as PropType<Slot>, required: false },\n },\n setup(props) {\n return () => props.slot?.({ edge: props.edge });\n },\n});\n\n/** A label in the HTML layer: its edge provided again, so its content sits in its edge. */\nconst EdgeLabelOutlet = defineComponent({\n name: \"FlowEdgeLabelOutlet\",\n props: {\n entry: { type: Object as PropType<EdgeLabelEntry>, required: true },\n },\n setup(props) {\n provide(EdgeKey, { edgeId: () => props.entry.edgeId() });\n return () => {\n props.entry.version.value;\n return props.entry.render();\n };\n },\n});\n\n/**\n * The layer of the edges (`data-flow-part=\"edges\"`), inside `Flow.Viewport`, before `Flow.Nodes`:\n * an SVG (`data-flow-part=\"edges\"` too) where the default slot draws each edge, once both its\n * nodes have a size (before the engine exists, from the document's sizes: a server render draws\n * them; with `onlyRenderVisible`, none: the view is not known yet), in the engine's drawing order (`drawn-edges`: by stack value), and the HTML layer edge\n * labels render in. When some edges stand above nodes (`render-layers`, `zIndexMode`), each level\n * gets its own layer (`data-flow-part=\"edges-layer\"`, `data-level`, at the level's `z-index`) with\n * its SVG and its labels, between the nodes below and above it. It lets presses through to the\n * pane; the edges' own parts take them.\n *\n * ```vue\n * <Flow.Edges v-slot=\"{ edge }\"><Flow.Edge :edge=\"edge\" /></Flow.Edges>\n * ```\n */\nexport const Edges: FlowComponent<EdgesProps, EdgesSlots> = definePrimitive<\n EdgesProps,\n EdgesSlots\n>(\"Edges\", [\"as\"], (props, { attrs, slots }) => {\n const context = useFlowContext(\"Edges\");\n // the levels and their edges: shown, measured, in view with `onlyRenderVisible`, by z-order\n const layers = useDrawnLayers(context);\n // the labels of the edges, rendered in the HTML layer (SVG holds no HTML)\n const labels = shallowRef<readonly EdgeLabelEntry[]>([]);\n const layer: EdgeLabelLayer = {\n add(entry) {\n labels.value = [...labels.value, entry];\n return () => {\n labels.value = labels.value.filter((other) => other !== entry);\n };\n },\n };\n provide(EdgeLabelLayerKey, layer);\n const svg = (edges: readonly FlowEdge[]) =>\n h(\n \"svg\",\n { ...partAttributes(\"edges\"), style: LAYER_STYLE },\n edges.map((edge) =>\n h(EdgeSlot, {\n key: edge.id,\n edge,\n slot: slots.default as Slot | undefined,\n }),\n ),\n );\n const outlets = (entries: readonly EdgeLabelEntry[]) =>\n entries.map((entry) => h(EdgeLabelOutlet, { key: entry.key, entry }));\n // several levels: each one's SVG and labels in its own layer (an edge's label in its edge's)\n const levels = (drawn: readonly DrawnLayer[]) => {\n const levelOf = new Map<string, number>();\n for (const [index, { edges }] of drawn.entries()) {\n for (const edge of edges) levelOf.set(edge.id, index);\n }\n const byLevel = drawn.map((): EdgeLabelEntry[] => []);\n for (const entry of labels.value) {\n byLevel[levelOf.get(entry.edgeId()) ?? 0]?.push(entry);\n }\n const engine = context.engine.value;\n return drawn.map(({ level, zIndex, edges }, index) =>\n h(\n \"div\",\n {\n key: level,\n ...(engine\n ? engine.adapter.attributes(\"edges-layer\", { level })\n : edgesLayerAttributes(level)),\n style: {\n ...LAYER_STYLE,\n ...(zIndex === undefined\n ? {}\n : { zIndex: String(zIndex) }),\n },\n },\n [svg(edges), ...outlets(byLevel[index] ?? [])],\n ),\n );\n };\n return () => {\n const drawn = layers.value;\n const count = drawn.reduce((sum, { edges }) => sum + edges.length, 0);\n return renderElement({\n tag: \"div\",\n as: props.as,\n attrs,\n render: slots.render,\n state: { count },\n props: { ...partAttributes(\"edges\") },\n style: LAYER_STYLE,\n children: () =>\n drawn.length > 1\n ? levels(drawn)\n : [svg(drawn[0]?.edges ?? []), ...outlets(labels.value)],\n });\n };\n});\n","// The buttons of `Flow.Controls`: each runs one engine action, and is disabled while the engine\n// refuses it (`engine.can`), re-rendering when the view changes.\nimport type { EngineActionKey } from \"@fragiola/flow\";\nimport type { ComputedRef } from \"vue\";\nimport { useFlowContext } from \"../context\";\nimport { useFlowValue } from \"./internal\";\n\n/** What a control button shows. */\nexport interface ControlButtonState {\n /** the engine refuses its action now (a zoom at its limit, `fit-view` before a size) */\n readonly disabled: boolean;\n}\n\n/** @internal a control button's state and own props: it runs `action` when clicked */\nexport function useControlButton(\n part: string,\n action: EngineActionKey,\n disabledProp: () => boolean | undefined,\n fields: () => object = () => ({}),\n): {\n state: ComputedRef<ControlButtonState>;\n props: () => Record<string, unknown>;\n} {\n const context = useFlowContext(part);\n // the fields its props give (an absent one is the engine's default)\n const payload = () => givenPayload(fields());\n const allowed = useFlowValue(context, () => {\n const engine = context.engine.value;\n return engine ? engine.can(action, payload() as never) : false;\n });\n const state = useFlowValue(context, () => ({\n disabled: disabledProp() === true || !allowed.value,\n }));\n const onClick = () => {\n context.engine.value?.run(action, payload() as never);\n };\n return {\n state,\n props: () => {\n const { disabled } = state.value;\n return {\n type: \"button\",\n \"data-flow-part\": partName(part),\n \"data-disabled\": disabled ? \"\" : undefined,\n disabled,\n onClick,\n };\n },\n };\n}\n\n/** @internal a control's payload: the fields its props give (an absent one is the engine's default) */\nexport function givenPayload<P extends object>(fields: P): Partial<P> {\n return Object.fromEntries(\n Object.entries(fields).filter(([, value]) => value !== undefined),\n ) as Partial<P>;\n}\n\n/** `ZoomIn` → `zoom-in`. */\nfunction partName(part: string): string {\n return part.replace(\n /[A-Z]/g,\n (letter, at: number) => `${at === 0 ? \"\" : \"-\"}${letter.toLowerCase()}`,\n );\n}\n","import type { FitPadding } from \"@fragiola/flow\";\nimport {\n type ControlButtonState,\n useControlButton,\n} from \"../composables/use-control-button\";\nimport {\n definePrimitive,\n type FlowComponent,\n NUMBER_PROP,\n numberProp,\n type PrimitiveProps,\n type SlotFunction,\n} from \"../utils/primitive\";\nimport { type RenderSlot, renderElement } from \"../utils/render\";\n\nexport interface FitViewProps extends PrimitiveProps {\n /** disabled even when the engine would run its action */\n disabled?: boolean | undefined;\n /**\n * how long its viewport change animates, in milliseconds (the root's `easing`); default 0: at\n * once. The attribute's text is its number (`duration=\"300\"`)\n */\n duration?: number | `${number}` | undefined;\n /**\n * the room kept free on every side: a share of the root's size, `\"<n>px\"`, or each side's\n * (`{ top, right, bottom, left }`); default the engine's 0.1\n */\n padding?: FitPadding | undefined;\n /** only these nodes; default every node that is not hidden */\n nodeIds?: string[] | undefined;\n /** without `nodeIds`, the hidden nodes of known size too; default false */\n includeHidden?: boolean | undefined;\n /** the least zoom it may pick (within the root's limits); default the root's `minZoom` */\n minZoom?: number | `${number}` | undefined;\n /** the greatest zoom it may pick (within the root's limits); default the root's `maxZoom` */\n maxZoom?: number | `${number}` | undefined;\n}\n\nexport interface FitViewSlots extends RenderSlot<ControlButtonState> {\n /** its content (an icon, a label) */\n default?: SlotFunction<{ state: ControlButtonState }>;\n}\n\n/**\n * A button (`data-flow-part=\"fit-view\"`): Fits every node in the root, or its `nodeIds` (`fit-view`, with its props as the payload), disabled before a node is measured. It renders only its default slot (an icon,\n * a label).\n */\nexport const FitView: FlowComponent<FitViewProps, FitViewSlots> =\n definePrimitive<FitViewProps, FitViewSlots>(\n \"FitView\",\n [\n \"disabled\",\n \"duration\",\n \"padding\",\n \"nodeIds\",\n \"includeHidden\",\n \"minZoom\",\n \"maxZoom\",\n \"as\",\n ],\n (props, { attrs, slots }) => {\n const { state, props: own } = useControlButton(\n \"FitView\",\n \"fit-view\",\n () => props.disabled,\n // `nodeIds` spread: a reactive array reaches the engine as a copy\n () => ({\n duration: numberProp(props.duration),\n padding: props.padding,\n nodeIds: props.nodeIds ? [...props.nodeIds] : undefined,\n includeHidden: props.includeHidden,\n minZoom: numberProp(props.minZoom),\n maxZoom: numberProp(props.maxZoom),\n }),\n );\n return () => {\n const current = state.value;\n return renderElement({\n tag: \"button\",\n as: props.as,\n attrs,\n render: slots.render,\n state: current,\n props: own(),\n children: () => slots.default?.({ state: current }),\n });\n };\n },\n {\n booleans: [\"disabled\", \"includeHidden\"],\n // `duration=\"300\"` is its number (`min-zoom`, `max-zoom` too)\n types: {\n duration: NUMBER_PROP,\n minZoom: NUMBER_PROP,\n maxZoom: NUMBER_PROP,\n },\n },\n );\n","import type { HandleSide } from \"@fragiola/flow\";\nimport {\n type HandleState,\n type UseHandleOptions,\n useHandle,\n} from \"../composables/use-handle\";\nimport {\n definePrimitive,\n type FlowComponent,\n type PrimitiveProps,\n type SlotFunction,\n} from \"../utils/primitive\";\nimport { type RenderSlot, renderElement } from \"../utils/render\";\n\nexport interface HandleProps extends PrimitiveProps, UseHandleOptions {}\n\nexport interface HandleSlots extends RenderSlot<HandleState> {\n default?: SlotFunction<{ state: HandleState }>;\n}\n\n/** Where a handle sits by default: centred on its side of the node (a style may move it). */\nconst SIDE_STYLE: Record<HandleSide, Record<string, string>> = {\n top: { top: \"0\", left: \"50%\", transform: \"translate(-50%, -50%)\" },\n right: { top: \"50%\", left: \"100%\", transform: \"translate(-50%, -50%)\" },\n bottom: { top: \"100%\", left: \"50%\", transform: \"translate(-50%, -50%)\" },\n left: { top: \"50%\", left: \"0\", transform: \"translate(-50%, -50%)\" },\n};\n\nconst HANDLE_STYLE = { position: \"absolute\" };\n\n/**\n * A node's connection point (`data-flow-part=\"handle\"`, `data-handle-type`, `data-side`), inside\n * `Flow.Node`: registered with the engine (D8), which measures its centre; with `connection()`, a\n * press on it draws a connection. Absolutely positioned at the middle of its `side` by default;\n * your `style` may place it elsewhere on the node. Give it its size and look.\n */\nexport const Handle: FlowComponent<HandleProps, HandleSlots> = definePrimitive<\n HandleProps,\n HandleSlots\n>(\n \"Handle\",\n [\n \"type\",\n \"side\",\n \"handleId\",\n \"connectable\",\n \"connectableStart\",\n \"connectableEnd\",\n \"nodeId\",\n \"as\",\n ],\n (props, { attrs, slots }) => {\n const { state, props: own } = useHandle(() => ({\n type: props.type,\n side: props.side,\n handleId: props.handleId,\n connectable: props.connectable,\n connectableStart: props.connectableStart,\n connectableEnd: props.connectableEnd,\n nodeId: props.nodeId,\n }));\n return () => {\n const current = state.value;\n const { ref, ...attributes } = own.value;\n return renderElement({\n tag: \"div\",\n as: props.as,\n attrs,\n render: slots.render,\n state: current,\n ref,\n props: attributes,\n style: HANDLE_STYLE,\n baseStyle: SIDE_STYLE[props.side],\n children: () => slots.default?.({ state: current }),\n });\n };\n },\n { booleans: [\"connectable\", \"connectableStart\", \"connectableEnd\"] },\n);\n","import type { AnyTypes, FlowNode, FlowTypes } from \"@fragiola/flow\";\nimport { provide } from \"vue\";\nimport { type NodeState, useNode } from \"../composables/use-node\";\nimport { NodeKey } from \"../context\";\nimport {\n definePrimitive,\n type FlowComponent,\n type PrimitiveProps,\n type SlotFunction,\n} from \"../utils/primitive\";\nimport { type RenderSlot, renderElement } from \"../utils/render\";\n\nexport interface NodeProps<T extends FlowTypes = AnyTypes>\n extends PrimitiveProps {\n /** the node it renders: the one `Flow.Nodes` gives its slot */\n node: FlowNode<T>;\n}\n\nexport interface NodeSlots<T extends FlowTypes = AnyTypes>\n extends RenderSlot<NodeState<T>> {\n /** the node's content: `Flow.Handle`s, a resizer, a toolbar */\n default?: SlotFunction<{ state: NodeState<T> }>;\n}\n\n/**\n * One node (`data-flow-part=\"node\"`, `data-flow-id`), absolutely positioned at its place in the\n * viewport (a structural `transform`), registered with the engine, which measures it and resolves\n * presses on it (drag, select, connect from its handles). It renders only its default slot: the\n * content, `Flow.Handle`s, a resizer, a toolbar.\n */\nexport const Node: FlowComponent<NodeProps, NodeSlots> = definePrimitive<\n NodeProps,\n NodeSlots\n>(\"Node\", [\"node\", \"as\"], (props, { attrs, slots }) => {\n const { state, props: own } = useNode(() => props.node);\n provide(NodeKey, { nodeId: () => props.node.id });\n return () => {\n const current = state.value;\n const { ref, style, ...attributes } = own.value;\n return renderElement({\n tag: \"div\",\n as: props.as,\n attrs,\n render: slots.render,\n state: current,\n ref,\n props: attributes,\n style,\n children: () => slots.default?.({ state: current }),\n });\n };\n});\n","import type {\n HandleSide,\n NodeToolbarPosition,\n PartAttributes,\n} from \"@fragiola/flow\";\nimport { h, inject, Teleport } from \"vue\";\nimport { useFlowValue } from \"../composables/internal\";\nimport { NodeKey, useFlowContext } from \"../context\";\nimport {\n definePrimitive,\n type FlowComponent,\n type PrimitiveProps,\n type SlotFunction,\n} from \"../utils/primitive\";\nimport { type RenderSlot, renderElement } from \"../utils/render\";\n\nexport interface NodeToolbarState {\n /** its node (undefined for several nodes' toolbar) */\n readonly nodeId: string | undefined;\n /** the nodes it stands beside: `nodeIds`, or its one node */\n readonly nodeIds: readonly string[];\n /** where it is anchored, in pixels relative to the root */\n readonly position: NodeToolbarPosition;\n readonly side: HandleSide;\n}\n\nexport interface NodeToolbarProps extends PrimitiveProps {\n /** its node; default the enclosing `Flow.Node`'s */\n nodeId?: string | undefined;\n /**\n * several nodes it stands beside (their bounds), instead of one; when not empty it wins over\n * `nodeId`, and the toolbar is shown by default while every one of them is selected\n */\n nodeIds?: readonly string[] | undefined;\n /** the node's side it stands on; default `\"top\"` */\n side?: HandleSide | undefined;\n /** where along that side; default `\"center\"` */\n align?: \"start\" | \"center\" | \"end\" | undefined;\n /** the gap between the node and the toolbar, in pixels; default 10 */\n offset?: number | undefined;\n /** whether it is shown; default while its node (every node of `nodeIds`) is selected (`selection()`) */\n open?: boolean | undefined;\n}\n\nexport interface NodeToolbarSlots extends RenderSlot<NodeToolbarState> {\n /** your buttons */\n default?: SlotFunction<{ state: NodeToolbarState }>;\n}\n\ninterface ToolbarView {\n position: NodeToolbarPosition;\n nodeIds: readonly string[];\n attributes: PartAttributes;\n}\n\n/**\n * A toolbar next to a node, or beside several nodes' bounds (`nodeIds`; `data-flow-part=\"toolbar\"`),\n * outside the zoom: rendered in\n * `Flow.Root` (a `Teleport`), at the anchor `node-toolbar-by` gives, so it keeps its size at any\n * zoom. Presses and the wheel over it are left to it. It renders only its default slot (your\n * buttons).\n */\nexport const NodeToolbar: FlowComponent<NodeToolbarProps, NodeToolbarSlots> =\n definePrimitive<NodeToolbarProps, NodeToolbarSlots>(\n \"NodeToolbar\",\n [\"nodeId\", \"nodeIds\", \"side\", \"align\", \"offset\", \"open\", \"as\"],\n (props, { attrs, slots }) => {\n const context = useFlowContext(\"NodeToolbar\");\n const { model } = context;\n const around = inject(NodeKey, null);\n // several nodes (`nodeIds` not empty), or one: the given one or the enclosing node's\n const many = () =>\n props.nodeIds !== undefined && props.nodeIds.length > 0;\n const nodeId = (): string | undefined => {\n if (many()) return undefined;\n const id = props.nodeId ?? around?.nodeId();\n if (id === undefined) {\n throw new Error(\n \"Flow.NodeToolbar must be rendered inside Flow.Node (or be given a nodeId or nodeIds)\",\n );\n }\n return id;\n };\n // hidden, it reads nothing of the view: a pan or a zoom gives the same value (nothing\n // renders again); shown, an equal anchor keeps the last value\n const view = useFlowValue<ToolbarView | undefined>(context, () => {\n const engine = context.engine.value;\n if (!engine) return undefined;\n const id = nodeId();\n const nodeIds =\n id === undefined ? [...(props.nodeIds ?? [])] : [id];\n const shown =\n props.open ??\n nodeIds.every((node) =>\n model.is(\"node-selected\", { nodeId: node }),\n );\n if (!shown) return undefined;\n const position = engine.get(\"node-toolbar-by\", {\n ...(id === undefined ? { nodeIds } : { nodeId: id }),\n side: props.side ?? \"top\",\n align: props.align,\n offset: props.offset,\n });\n return position\n ? {\n position,\n nodeIds,\n attributes: engine.adapter.attributes(\n \"toolbar\",\n id === undefined ? {} : { nodeId: id },\n ),\n }\n : undefined;\n });\n return () => {\n const current = view.value;\n const root = context.rootElement.value;\n if (!current || !root) return null;\n const state: NodeToolbarState = {\n nodeId: nodeId(),\n nodeIds: current.nodeIds,\n position: current.position,\n side: props.side ?? \"top\",\n };\n const { x, y, anchorX, anchorY } = current.position;\n return h(Teleport, { to: root }, [\n renderElement({\n tag: \"div\",\n as: props.as,\n attrs,\n render: slots.render,\n state,\n props: { ...current.attributes },\n style: {\n position: \"absolute\",\n top: \"0\",\n left: \"0\",\n transform: `translate(${x}px, ${y}px) translate(${-anchorX * 100}%, ${-anchorY * 100}%)`,\n },\n children: () => slots.default?.({ state }),\n }),\n ]);\n };\n },\n { booleans: [\"open\"] },\n );\n","import {\n type AnyTypes,\n type FlowNode,\n type FlowTypes,\n partAttributes,\n} from \"@fragiola/flow\";\nimport { defineComponent, h, type PropType, type Slot } from \"vue\";\nimport { useDrawnLayers, useFlowValue } from \"../composables/internal\";\nimport { useFlowContext } from \"../context\";\nimport {\n definePrimitive,\n type FlowComponent,\n type PrimitiveProps,\n type SlotFunction,\n} from \"../utils/primitive\";\nimport { type RenderSlot, renderElement } from \"../utils/render\";\n\nexport interface NodesState {\n /** how many nodes are rendered */\n count: number;\n}\n\nexport interface NodesProps extends PrimitiveProps {}\n\nexport interface NodesSlots<T extends FlowTypes = AnyTypes>\n extends RenderSlot<NodesState> {\n /**\n * renders one node (`v-slot=\"{ node }\"`): usually a `Flow.Node` with its content and handles.\n * Each node's slot renders again when its node changes, or a reactive value it reads does\n */\n default?: SlotFunction<{ node: FlowNode<T> }>;\n}\n\n// one render level: its own stacking context, the nodes' z-index (a selected one raised) orders\n// them among themselves, never above what follows the layer (the connection line)\nconst NODES_STYLE = {\n position: \"absolute\",\n top: \"0\",\n left: \"0\",\n isolation: \"isolate\",\n};\n\n// several levels: no stacking context of its own, so the nodes' (negative) z-indexes interleave\n// with the edges' layers (`render-layers`), still below what follows\nconst LAYERED_NODES_STYLE = { position: \"absolute\", top: \"0\", left: \"0\" };\n\n/**\n * One node's rendering, again only when its node changes (the model shares the nodes a command\n * did not change: a drag step renders the moved nodes only), when a reactive value its slot reads\n * does, or when the slot is a new one.\n */\nconst NodeSlot = defineComponent({\n name: \"FlowNodeSlot\",\n props: {\n node: { type: Object as PropType<FlowNode>, required: true },\n // the slot itself: a new one (a render function's, or a slot that reads an outer slot's\n // scope) renders every entity again, a compiled template's stays the same\n slot: { type: Function as PropType<Slot>, required: false },\n },\n setup(props) {\n return () => props.slot?.({ node: props.node });\n },\n});\n\nconst NO_NODES: readonly FlowNode[] = Object.freeze([]);\n\nfunction shownNodes(nodes: readonly FlowNode[]): readonly FlowNode[] {\n return nodes.filter((node) => node.hidden !== true);\n}\n\n/**\n * The layer of the nodes (`data-flow-part=\"nodes\"`), inside `Flow.Viewport`: renders its default\n * slot for each node that is not hidden (with `onlyRenderVisible`, each one in view,\n * `visible-nodes`; with it, none before the engine knows the view: the server render and the\n * first client render), in drawing order, keyed by its id (a node keeps its element when it moves).\n * You render each node. It is its own stacking context (`isolation`), but while some edges stand\n * above nodes (several `render-layers`), when the nodes' z-indexes interleave with the edges'\n * layers.\n *\n * ```vue\n * <Flow.Nodes v-slot=\"{ node }\"><Flow.Node :node=\"node\">…</Flow.Node></Flow.Nodes>\n * ```\n */\nexport const Nodes: FlowComponent<NodesProps, NodesSlots> = definePrimitive<\n NodesProps,\n NodesSlots\n>(\"Nodes\", [\"as\"], (props, { attrs, slots }) => {\n const context = useFlowContext(\"Nodes\");\n const { model } = context;\n const list = useFlowValue(context, () => {\n const engine = context.engine.value;\n if (!engine) {\n // before the engine, a culled flow renders none: the view is not known yet\n return context.onlyRenderVisible.value\n ? NO_NODES\n : shownNodes(model.get(\"all-nodes\"));\n }\n return engine.adapter.settings.onlyRenderVisible\n ? engine.get(\"visible-nodes\")\n : shownNodes(model.get(\"all-nodes\"));\n });\n const layers = useDrawnLayers(context);\n return () => {\n const nodes = list.value;\n const layered = layers.value.length > 1;\n return renderElement({\n tag: \"div\",\n as: props.as,\n attrs,\n render: slots.render,\n state: { count: nodes.length },\n props: { ...partAttributes(\"nodes\") },\n style: layered ? LAYERED_NODES_STYLE : NODES_STYLE,\n children: () =>\n nodes.map((node) =>\n h(NodeSlot, {\n key: node.id,\n node,\n slot: slots.default as Slot | undefined,\n }),\n ),\n });\n };\n});\n","import type { Rect } from \"@fragiola/flow\";\nimport { useFlowValue } from \"../composables/internal\";\nimport { useFlowContext } from \"../context\";\nimport {\n definePrimitive,\n type FlowComponent,\n type PrimitiveProps,\n type SlotFunction,\n} from \"../utils/primitive\";\nimport { px, type RenderSlot, renderElement } from \"../utils/render\";\n\nexport interface NodesSelectionState {\n /** the rectangle around the selected nodes, in flow coordinates */\n readonly rect: Rect;\n /** the selection is being dragged by it: `data-dragging` */\n readonly dragging: boolean;\n}\n\nexport interface NodesSelectionProps extends PrimitiveProps {}\n\nexport interface NodesSelectionSlots extends RenderSlot<NodesSelectionState> {\n default?: SlotFunction<{ state: NodesSelectionState }>;\n}\n\n/**\n * The rectangle around the selected nodes (`data-flow-part=\"nodes-selection\"`, `selection()`),\n * inside `Flow.Viewport` next to `Flow.Nodes` (it is in flow coordinates): rendered at\n * `selection-rect`, while two or more nodes are selected by a box (or always, with\n * `selection({ rect: \"always\" })`). A press on it drags the selection (`drag()`), its context\n * menu is the selection's. With `keyboard()` it takes focus (`tabindex`), and its keys are a\n * focused selected node's: the arrows move the selection, the delete keys remove it, Escape clears\n * it. Give it its look.\n */\nexport const NodesSelection: FlowComponent<\n NodesSelectionProps,\n NodesSelectionSlots\n> = definePrimitive<NodesSelectionProps, NodesSelectionSlots>(\n \"NodesSelection\",\n [\"as\"],\n (props, { attrs, slots }) => {\n const context = useFlowContext(\"NodesSelection\");\n const rect = useFlowValue(\n context,\n () => context.engine.value?.get(\"selection-rect\") ?? null,\n );\n // read only while the rectangle is shown\n const attributes = useFlowValue(\n context,\n () =>\n context.engine.value?.adapter.attributes(\"nodes-selection\") ??\n {},\n );\n return () => {\n const current = rect.value;\n if (!current) return null;\n const own = attributes.value;\n const state: NodesSelectionState = {\n rect: current,\n dragging: own[\"data-dragging\"] !== undefined,\n };\n return renderElement({\n tag: \"div\",\n as: props.as,\n attrs,\n render: slots.render,\n state,\n props: { ...own, \"data-flow-part\": \"nodes-selection\" },\n style: {\n position: \"absolute\",\n top: \"0\",\n left: \"0\",\n transform: `translate(${px(current.x)}, ${px(current.y)})`,\n width: px(current.width),\n height: px(current.height),\n },\n children: () => slots.default?.({ state }),\n });\n };\n },\n);\n","import type { EdgePath } from \"@fragiola/flow\";\nimport { sameValue, useFlowValue } from \"../composables/internal\";\nimport { useEdgePath } from \"../composables/use-edge\";\nimport { useEdgeId, useFlowContext } from \"../context\";\nimport {\n definePrimitive,\n type FlowComponent,\n type PrimitiveProps,\n} from \"../utils/primitive\";\nimport { type RenderSlot, renderElement } from \"../utils/render\";\n\nexport interface ReconnectAnchorState {\n readonly edgeId: string;\n /** which end of the edge it moves */\n readonly end: \"source\" | \"target\";\n /** the edge's path and ends */\n readonly path: EdgePath;\n /** this edge's end is being moved */\n readonly reconnecting: boolean;\n}\n\nexport interface ReconnectAnchorProps extends PrimitiveProps {\n /** which end of the edge it moves */\n end: \"source\" | \"target\";\n /** the edge; default the enclosing `Flow.Edge`'s */\n edgeId?: string | undefined;\n}\n\nexport interface ReconnectAnchorSlots\n extends RenderSlot<ReconnectAnchorState> {}\n\n/**\n * An edge end's grab area (`data-flow-part=\"reconnect-anchor\"`, `data-end`): an SVG circle at the\n * end, inside `Flow.Edge`. With `reconnection()`, a press on it moves that end to another handle;\n * an end its edge's `reconnectable` keeps fixed (`false`, or the other end's name) draws none.\n * Transparent by default; give it its radius (`r`, default 10) and look.\n */\nexport const ReconnectAnchor: FlowComponent<\n ReconnectAnchorProps,\n ReconnectAnchorSlots\n> = definePrimitive<ReconnectAnchorProps, ReconnectAnchorSlots>(\n \"ReconnectAnchor\",\n [\"end\", \"edgeId\", \"as\"],\n (props, { attrs, slots }) => {\n const context = useFlowContext(\"ReconnectAnchor\");\n const edgeId = useEdgeId(\"ReconnectAnchor\", () => props.edgeId);\n const path = useEdgePath(context, edgeId);\n const view = useFlowValue(\n context,\n () => {\n const engine = context.engine.value;\n const id = edgeId();\n // `reconnectable: \"source\"` (or `\"target\"`, or false): no anchor at the other end\n if (\n !context.model.is(\"edge-reconnectable\", {\n edgeId: id,\n end: props.end,\n })\n ) {\n return undefined;\n }\n return engine\n ? {\n attributes: engine.adapter.attributes(\n \"reconnect-anchor\",\n {\n edgeId: id,\n end: props.end,\n },\n ),\n reconnecting: engine.is(\"edge-reconnecting\", {\n edgeId: id,\n }),\n }\n : undefined;\n },\n sameValue,\n \"entity\",\n () => ({ kind: \"edge\", id: edgeId() }),\n );\n return () => {\n const current = path.value;\n const own = view.value;\n if (!current || !own) return null;\n const point = current[props.end];\n return renderElement({\n tag: \"circle\",\n as: props.as,\n attrs,\n render: slots.render,\n state: {\n edgeId: edgeId(),\n end: props.end,\n path: current,\n reconnecting: own.reconnecting,\n },\n props: {\n ...own.attributes,\n cx: point.x,\n cy: point.y,\n r: 10,\n fill: \"transparent\",\n },\n style: { pointerEvents: \"all\" },\n });\n };\n },\n);\n","// The engine an app sees through `useFlow()` and a flow ref: always there, even before the root\n// mounted (`setup`, the server). It forwards every verb to the root's current engine; with none,\n// an action is refused and a read gives the empty answer. The React adapter's\n// (packages/react/src/utils/engine-facade.ts, itself from Tree), framework-free.\nimport type {\n CommandResult,\n FlowEngine,\n FlowEngineAdapter,\n FlowEngineEvent,\n Viewport,\n} from \"@fragiola/flow\";\n\n/** The facade, and how the root points it at its current engine. */\nexport interface EngineFacade {\n readonly engine: FlowEngine;\n /** the root's current engine (null: not mounted) */\n readonly current: FlowEngine | null;\n /** points the facade at `engine` (null: the root unmounted) */\n set(engine: FlowEngine | null): void;\n}\n\nconst NOT_MOUNTED: CommandResult<never> = Object.freeze({\n ok: false,\n error: Object.freeze({\n code: \"refused\",\n message: \"the flow is not mounted\",\n }),\n});\n\ntype Verb = (key: string, payload?: unknown) => unknown;\n\n/** A facade whose reads before the mount answer `viewport` with `initial`. */\nexport function createEngineFacade(initial: Viewport): EngineFacade {\n let current: FlowEngine | null = null;\n const listeners = new Set<(event: FlowEngineEvent) => void>();\n let unsubscribe: () => void = () => {};\n const empty: Readonly<Record<string, unknown>> = {\n viewport: Object.freeze({ ...initial }),\n \"root-size\": Object.freeze({ width: 0, height: 0 }),\n \"handles-by\": Object.freeze([]),\n \"dragging-node-ids\": Object.freeze([]),\n \"selection-box\": null,\n connection: null,\n };\n const forward =\n (verb: \"run\" | \"can\" | \"check\" | \"get\" | \"is\", fallback: Verb) =>\n (key: string, payload?: unknown) =>\n current\n ? (current[verb] as unknown as Verb)(key, payload)\n : fallback(key, payload);\n const engine = Object.freeze({\n run: forward(\"run\", () => NOT_MOUNTED),\n can: forward(\"can\", () => false),\n check: forward(\"check\", () => NOT_MOUNTED),\n get: forward(\"get\", (key) =>\n Object.hasOwn(empty, key) ? empty[key] : undefined,\n ),\n is: forward(\"is\", () => false),\n // listens across engines: a listener added before the mount hears the mounted engine\n subscribe(listener: (event: FlowEngineEvent) => void) {\n const wrapper = (event: FlowEngineEvent) => listener(event);\n listeners.add(wrapper);\n return () => {\n listeners.delete(wrapper);\n };\n },\n // the root owns its engine and destroys it when it unmounts\n destroy() {},\n get adapter(): FlowEngineAdapter {\n if (!current) throw new Error(\"the flow is not mounted\");\n return current.adapter;\n },\n }) as unknown as FlowEngine;\n return {\n engine,\n get current() {\n return current;\n },\n set(next) {\n if (next === current) return;\n unsubscribe();\n current = next;\n unsubscribe = next\n ? next.subscribe((event) => {\n for (const listener of [...listeners]) listener(event);\n })\n : () => {};\n },\n };\n}\n","// What a root's readers hear (React's `utils/flow-store.ts` in Vue's reactive way): counters that\n// the root bumps on each change of the model and of the engine, told only to the readers it may\n// concern. A computed of `useFlowValue` reads the counter of its scope (and of its node or edge),\n// so a viewport step reads no node or edge again, and a measurement only those it changed.\nimport type { ViewChange } from \"@fragiola/flow\";\nimport { type ShallowRef, shallowRef } from \"vue\";\nimport type { AnyFlowEngine, AnyFlowModel } from \"../context\";\n\n/**\n * @internal what a reader depends on:\n * - `view`: anything, the viewport included (the layers' lists, the background, toolbars);\n * - `entity`: one node's or edge's own view (its place, path, attributes, `z-index`), which a\n * viewport step leaves alone, so a pan or a zoom never reads it again. A viewport step does\n * change the nodes' `z-index` while there are several render levels (`node-z-index-by`, the\n * levels follow the drawn edges): then it counts as an entity change too.\n */\nexport type FlowValueScope = \"view\" | \"entity\";\n\n/**\n * @internal the node or the edge an `entity` reader shows: a change that is only a measurement\n * (nodes mounted, a node resized) tells it only when the measurement changed it (its node's box or\n * measured state, its edge's path), not every node and edge on screen\n */\nexport interface FlowEntity {\n readonly kind: \"node\" | \"edge\";\n readonly id: string;\n}\n\n/** One node's or edge's readers, and what a measurement may change of it. */\ninterface EntityRecord {\n readonly entity: FlowEntity;\n /** bumped when a measurement changed it */\n readonly counter: ShallowRef<number>;\n /** its readers (`acquire`): dropped at none */\n readers: number;\n /**\n * its node's box and measured state, or its edge's path (frozen, the same until changed), as\n * of the last measurement; none after any other change (read again at the next measurement,\n * which then tells it)\n */\n token: readonly unknown[] | undefined;\n}\n\n/** @internal the counters of one root, read by its `useFlowValue` computeds */\nexport interface FlowStore {\n /** every change: a commit of the model, every engine notification (the root's `revision`) */\n readonly view: Readonly<ShallowRef<number>>;\n /**\n * a change of every node and edge: a commit that changed the lists, a gesture, a notification\n * while there are (or were) several render levels, a measurement with a viewport change\n */\n readonly entity: Readonly<ShallowRef<number>>;\n /** a notification that was only a measurement: what an `entity` reader without one hears */\n readonly measure: Readonly<ShallowRef<number>>;\n /**\n * the counter of a node's or an edge's measurements while it has a reader (`acquire`), else\n * `measure` (every measurement)\n */\n counterOf(entity: FlowEntity): Readonly<ShallowRef<number>>;\n /** a reader of a node or an edge: its record is kept until released */\n acquire(entity: FlowEntity): () => void;\n /** a commit of the model */\n commit(): void;\n /** the engine, once created: its notifications are told from then on; returns the remover */\n attach(engine: AnyFlowEngine): () => void;\n}\n\nconst keyOf = (entity: FlowEntity) => `${entity.kind}\\u0000${entity.id}`;\n\n/** @internal the store of a root's model (and its engine, once attached) */\nexport function createFlowStore(model: AnyFlowModel): FlowStore {\n const view = shallowRef(0);\n const entity = shallowRef(0);\n const measure = shallowRef(0);\n const records = new Map<string, EntityRecord>();\n let engine: AnyFlowEngine | null = null;\n\n const tokenOf = ({ kind, id }: FlowEntity): readonly unknown[] =>\n !engine\n ? []\n : kind === \"node\"\n ? [\n engine.get(\"node-rect-by\", { nodeId: id }),\n engine.is(\"node-measured\", { nodeId: id }),\n ]\n : [engine.get(\"edge-path-by\", { edgeId: id })];\n\n const recordOf = (of: FlowEntity): EntityRecord => {\n const key = keyOf(of);\n let record = records.get(key);\n if (!record) {\n record = {\n entity: { kind: of.kind, id: of.id },\n counter: shallowRef(0),\n readers: 0,\n token: tokenOf(of),\n };\n records.set(key, record);\n }\n return record;\n };\n\n /** A change: of the view only, only a measurement, or of everything. */\n const tell = (kind: \"view\" | \"measured\" | \"entity\") => {\n view.value++;\n if (kind === \"view\") return;\n if (kind === \"entity\") {\n for (const record of records.values()) record.token = undefined;\n entity.value++;\n return;\n }\n measure.value++;\n for (const record of records.values()) {\n const token = tokenOf(record.entity);\n const was = record.token;\n const same =\n was !== undefined &&\n token.length === was.length &&\n token.every((value, i) => Object.is(value, was[i]));\n if (same) continue;\n record.token = token;\n record.counter.value++;\n }\n };\n\n // a commit that keeps both lists changes no node's or edge's own view\n let nodes = model.get(\"all-nodes\");\n let edges = model.get(\"all-edges\");\n\n return {\n view,\n entity,\n measure,\n counterOf: (of) => records.get(keyOf(of))?.counter ?? measure,\n acquire(of) {\n const key = keyOf(of);\n const record = recordOf(of);\n record.readers += 1;\n let released = false;\n return () => {\n if (released) return;\n released = true;\n record.readers -= 1;\n if (record.readers <= 0 && records.get(key) === record) {\n records.delete(key);\n }\n };\n },\n commit() {\n const nextNodes = model.get(\"all-nodes\");\n const nextEdges = model.get(\"all-edges\");\n const changed = nextNodes !== nodes || nextEdges !== edges;\n nodes = nextNodes;\n edges = nextEdges;\n tell(changed ? \"entity\" : \"view\");\n },\n attach(created) {\n engine = created;\n // the measurements before the engine counted nothing: read again at the next one\n for (const record of records.values()) record.token = undefined;\n // several render levels give the nodes ranks that follow the drawn edges, so the view\n const layered = () => created.get(\"render-layers\").length > 1;\n let wasLayered = layered();\n const stop = created.adapter.subscribe((change: ViewChange) => {\n const isLayered = layered();\n const levels = isLayered || wasLayered;\n wasLayered = isLayered;\n if (change.gesture || levels) tell(\"entity\");\n else if (change.measured)\n tell(change.viewport ? \"entity\" : \"measured\");\n else tell(\"view\");\n });\n return () => {\n stop();\n if (engine === created) engine = null;\n };\n },\n };\n}\n","import {\n type AnyTypes,\n type CommandEvent,\n type CreateId,\n createFlowEngine,\n createFlowModel,\n type DefaultEdgeOptions,\n ENGINE_EVENT_CALLBACKS,\n type FitViewPayload,\n type FlowEdge,\n type FlowEdgeInput,\n type FlowEngine,\n type FlowEngineEventOf,\n type FlowEngineOptions,\n type FlowFeatures,\n type FlowModel,\n type FlowNode,\n type FlowNodeInput,\n type FlowTypes,\n partAttributes,\n type StaticGeometry,\n staticGeometry,\n type Viewport,\n} from \"@fragiola/flow\";\nimport {\n computed,\n defineComponent,\n h,\n onBeforeUnmount,\n onMounted,\n onScopeDispose,\n onUnmounted,\n type PropType,\n provide,\n shallowRef,\n toRaw,\n watch,\n} from \"vue\";\nimport {\n type FlowRef,\n type FlowRefValue,\n setFlowRef,\n} from \"../composables/create-flow-ref\";\nimport { useFlowValue } from \"../composables/internal\";\nimport {\n type AnyFlowEngine,\n eraseModel,\n type FlowContextValue,\n FlowKey,\n} from \"../context\";\nimport { createEngineFacade } from \"../utils/engine-facade\";\nimport { createFlowStore } from \"../utils/flow-store\";\nimport {\n definePrimitive,\n type FlowComponent,\n NUMBER_PROP,\n numberProp,\n type PrimitiveProps,\n type SlotFunction,\n} from \"../utils/primitive\";\nimport {\n elementRef,\n onClient,\n type RenderSlot,\n renderElement,\n} from \"../utils/render\";\n\nexport interface RootState {\n /** the gestures and keys may change the flow (`set-interactive`, `data-interactive`) */\n interactive: boolean;\n /** the viewport is being panned (`data-panning`) */\n panning: boolean;\n /** nodes are being dragged (`drag()`, `data-dragging`) */\n dragging: boolean;\n /** a connection is being drawn (`connection()`, `data-connecting`) */\n connecting: boolean;\n /** a box selection is being drawn (`selection()`, `data-selecting`) */\n selecting: boolean;\n}\n\n/** The engine's options a root takes as props: each one that changes applies at once. */\nexport type RootEngineProps = Omit<\n Pick<\n FlowEngineOptions,\n | \"minZoom\"\n | \"maxZoom\"\n | \"translateExtent\"\n | \"panOnDrag\"\n | \"panOnScroll\"\n | \"zoomOnScroll\"\n | \"zoomOnPinch\"\n | \"zoomOnDoubleClick\"\n | \"zoomStep\"\n | \"interactive\"\n | \"onlyRenderVisible\"\n | \"pathOptions\"\n | \"autoPan\"\n | \"panActivationKey\"\n | \"panOnScrollMode\"\n | \"panOnScrollSpeed\"\n | \"zoomActivationKey\"\n | \"easing\"\n | \"nodeOrigin\"\n | \"nodeExtent\"\n | \"elevateNodesOnSelect\"\n | \"elevateEdgesOnSelect\"\n | \"paneClickDistance\"\n | \"nodeClickDistance\"\n | \"preventScrolling\"\n | \"nodesFocusable\"\n | \"edgesFocusable\"\n | \"zIndexMode\"\n >,\n \"panOnScrollSpeed\" | \"paneClickDistance\" | \"nodeClickDistance\"\n> & {\n /** the factor of the wheel's pixels when it pans; the attribute's text is its number */\n panOnScrollSpeed?: number | `${number}` | undefined;\n /**\n * how far (px) a press on the pane may move and still be a click; the attribute's text is its\n * number\n */\n paneClickDistance?: number | `${number}` | undefined;\n /**\n * how far (px) a press on a node may move and still be a click; the attribute's text is its\n * number\n */\n nodeClickDistance?: number | `${number}` | undefined;\n};\n\nexport interface RootProps<\n T extends FlowTypes = AnyTypes,\n F extends FlowFeatures = readonly [],\n> extends PrimitiveProps,\n RootEngineProps {\n /**\n * the flow model. Its middleware (`model.use`) sees every command the flow runs, and its\n * listeners (`model.subscribe`) every change. Give it, or let the root create one from\n * `nodes` / `defaultNodes` and `edges` / `defaultEdges`. Another model remounts the flow\n */\n model?: FlowModel<T, F> | undefined;\n /** the nodes of the model the root creates (read once, at mount) */\n defaultNodes?: readonly FlowNodeInput<T>[] | undefined;\n /** the edges of the model the root creates (read once, at mount) */\n defaultEdges?: readonly FlowEdgeInput<T>[] | undefined;\n /**\n * controlled nodes (`v-model:nodes`): a new list brings the model to it with the commands a\n * user would run (`model.get(\"commands-to\")`, one `batch`); every change of the model's nodes\n * emits `update:nodes`. Give every node its id\n */\n nodes?: readonly FlowNode<T>[] | undefined;\n /** controlled edges (`v-model:edges`), as `nodes` */\n edges?: readonly FlowEdge<T>[] | undefined;\n /**\n * the opt-in features of the model the root creates (read once, at mount):\n * `[selection(), drag(), connection()]`, each from its entry (`@fragiola/flow-vue/drag`). A\n * `model` has its own\n */\n features?: F | undefined;\n /** the id generator of the model the root creates (read once, at mount) */\n createId?: CreateId | undefined;\n /**\n * the fields every `edge.add` of the model the root creates fills in where it leaves them out\n * (read once, at mount: the model option `defaultEdgeOptions`)\n */\n defaultEdgeOptions?: DefaultEdgeOptions<T> | undefined;\n /** controlled viewport (`v-model:viewport`): a new value is set on the engine (`set-viewport`) */\n viewport?: Viewport | undefined;\n /** the viewport the flow starts at (read once, at mount); default `{ x: 0, y: 0, zoom: 1 }` */\n defaultViewport?: Viewport | undefined;\n /** fits the nodes once their sizes are known, again once measured (read once, at mount) */\n fitView?: boolean | FitViewPayload | undefined;\n /** access to the model and the engine from outside the root (`useFlowRef`, `createFlowRef`) */\n flowRef?: FlowRef<T, F> | undefined;\n}\n\nexport interface RootSlots extends RenderSlot<RootState> {\n /** the flow: `Flow.Background`, `Flow.Viewport`, `Flow.Controls`, `MiniMap`, … */\n default?: SlotFunction<{ state: RootState }>;\n}\n\ntype Callbacks = typeof ENGINE_EVENT_CALLBACKS;\n\n/**\n * The root's engine events, one per entry of `ENGINE_EVENT_CALLBACKS`, named by the callback with\n * its first letter lowercased (`nodeClick`, `moveStart`, `init`, `connectCancel`, …), each emitted\n * with the event: `@node-click` in a template, `onNodeClick` in `h()` or TSX.\n */\nexport type RootEventEmits = {\n [K in keyof Callbacks as Uncapitalize<Callbacks[K]>]: (\n event: FlowEngineEventOf<K>,\n ) => void;\n};\n\n/**\n * The events of `Flow.Root`: the controlled values, for `v-model` (or `@update:…`), and one per\n * engine event (`RootEventEmits`).\n */\nexport type RootEmits<T extends FlowTypes = AnyTypes> = {\n /** the model's nodes, after every command that changes them (a drag step too) */\n \"update:nodes\": (nodes: readonly FlowNode<T>[]) => void;\n /** the model's edges, after every command that changes them */\n \"update:edges\": (edges: readonly FlowEdge<T>[]) => void;\n /** every viewport change, by a gesture (`gesture: true`) or an action */\n \"update:viewport\": (viewport: Viewport, gesture: boolean) => void;\n} & RootEventEmits;\n\n/** Each engine event's Vue event, from the core's table (`node-click` → `nodeClick`, `ready` → `init`). */\nconst EVENT_EMITS: ReadonlyMap<string, keyof RootEventEmits> = new Map(\n Object.entries(ENGINE_EVENT_CALLBACKS).map(\n ([type, name]) =>\n [\n type,\n `${name[0]?.toLowerCase()}${name.slice(1)}` as keyof RootEventEmits,\n ] as const,\n ),\n);\n\nconst ENGINE_PROPS = [\n \"minZoom\",\n \"maxZoom\",\n \"translateExtent\",\n \"panOnDrag\",\n \"panOnScroll\",\n \"zoomOnScroll\",\n \"zoomOnPinch\",\n \"zoomOnDoubleClick\",\n \"zoomStep\",\n \"interactive\",\n \"onlyRenderVisible\",\n \"pathOptions\",\n \"autoPan\",\n \"panActivationKey\",\n \"panOnScrollMode\",\n \"panOnScrollSpeed\",\n \"zoomActivationKey\",\n \"easing\",\n \"nodeOrigin\",\n \"nodeExtent\",\n \"elevateNodesOnSelect\",\n \"elevateEdgesOnSelect\",\n \"paneClickDistance\",\n \"nodeClickDistance\",\n \"preventScrolling\",\n \"nodesFocusable\",\n \"edgesFocusable\",\n \"zIndexMode\",\n] as const satisfies readonly (keyof RootEngineProps)[];\n\n/** The engine props whose attribute's text is its number (`pane-click-distance=\"5\"`). */\nconst NUMBER_PROPS: ReadonlySet<string> = new Set([\n \"panOnScrollSpeed\",\n \"paneClickDistance\",\n \"nodeClickDistance\",\n]);\n\nconst ROOT_PROPS = [\n \"model\",\n \"defaultNodes\",\n \"defaultEdges\",\n \"nodes\",\n \"edges\",\n \"features\",\n \"createId\",\n \"defaultEdgeOptions\",\n \"viewport\",\n \"defaultViewport\",\n \"fitView\",\n \"flowRef\",\n ...ENGINE_PROPS,\n \"as\",\n] as const satisfies readonly (keyof RootProps)[];\n\n/** The props a bare attribute turns on (`<Flow.Root pan-on-scroll>`). */\nconst ROOT_BOOLEANS = [\n \"panOnDrag\",\n \"panOnScroll\",\n \"zoomOnScroll\",\n \"zoomOnPinch\",\n \"zoomOnDoubleClick\",\n \"interactive\",\n \"onlyRenderVisible\",\n \"autoPan\",\n \"elevateNodesOnSelect\",\n \"elevateEdgesOnSelect\",\n \"preventScrolling\",\n \"nodesFocusable\",\n \"edgesFocusable\",\n] as const satisfies readonly (keyof RootProps)[];\n\nconst ROOT_EMITS: readonly (keyof RootEmits)[] = [\n \"update:nodes\",\n \"update:edges\",\n \"update:viewport\",\n ...EVENT_EMITS.values(),\n];\n\n/** The root's props as its implementation reads them: any registry, any features. */\ntype AnyRootProps = RootProps<AnyTypes, FlowFeatures>;\n\n/** The `meta` of the commands that bring the model to the controlled props. */\nconst CONTROLLED_META = Object.freeze({ source: \"controlled\" });\n\nconst DEFAULT_VIEWPORT: Viewport = Object.freeze({ x: 0, y: 0, zoom: 1 });\n\nconst ROOT_STYLE = { position: \"relative\", overflow: \"hidden\" };\n\n/** A list of features by their names, in order: an equal new list is the same. */\nfunction featureNames(features: FlowFeatures | undefined): string {\n return (features ?? []).map((feature) => feature.name).join(\",\");\n}\n\n/** Warns once per message and root: misuse that the root ignores. */\nfunction warnOnce(): (message: string) => void {\n const warned = new Set<string>();\n return (message) => {\n if (warned.has(message)) return;\n warned.add(message);\n console.warn(`[@fragiola/flow-vue] ${message}`);\n };\n}\n\n/**\n * Each engine option's value as a key: a new equal object (`pathOptions`) is the same, a function\n * (`easing`) is itself, and `null` (`:pan-activation-key=\"null\"`: none) is not `undefined` (the\n * default).\n */\nfunction optionKeys(\n options: Partial<FlowEngineOptions>,\n): Record<string, unknown> {\n return Object.fromEntries(\n Object.entries(options).map(([key, value]) => [\n key,\n typeof value === \"function\" || value === undefined\n ? value\n : JSON.stringify(value),\n ]),\n );\n}\n\n/** A key that changes when an engine option's value does (but a function's: `easing` is watched). */\nfunction optionsKey(options: Partial<FlowEngineOptions>): string {\n return JSON.stringify(optionKeys(options), (_key, value) =>\n value === undefined ? \"undefined\" : value,\n );\n}\n\n/**\n * A list the app owns, as the model takes it: the plain list, never a reactive proxy (a frozen\n * list, the model's own given back by `update:nodes`, is taken as it is).\n */\nfunction plainList<E extends object>(\n list: readonly E[] | undefined,\n): readonly E[] | undefined {\n if (list === undefined) return undefined;\n const raw = toRaw(list);\n return Object.isFrozen(raw) ? raw : raw.map((entry) => toRaw(entry));\n}\n\n/** A value the app owns, without its reactive proxy. */\nfunction plain<V>(value: V): V {\n return value !== null && typeof value === \"object\" ? toRaw(value) : value;\n}\n\n/** a key per object: another model remounts the flow (`-1` for none) */\nconst modelKeys = new WeakMap<object, number>();\nlet nextModelKey = 0;\nfunction keyOfModel(model: object | undefined): number {\n if (model === undefined) return -1;\n const raw = toRaw(model);\n let key = modelKeys.get(raw);\n if (key === undefined) {\n key = nextModelKey++;\n modelKeys.set(raw, key);\n }\n return key;\n}\n\n/** The flow of one model: it owns the engine, so it lives as long as the model does. */\nconst RootFlow = definePrimitive<AnyRootProps, RootSlots, RootEmits<AnyTypes>>(\n \"RootFlow\",\n ROOT_PROPS,\n (props, { attrs, slots, emit }) => {\n const given = props.model ? toRaw(props.model) : undefined;\n const ownModel = given\n ? null\n : createFlowModel<AnyTypes, FlowFeatures>(\n {\n version: 1,\n nodes: [\n ...(plainList(props.nodes ?? props.defaultNodes) ??\n []),\n ],\n edges: [\n ...(plainList(props.edges ?? props.defaultEdges) ??\n []),\n ],\n } as never,\n {\n features: plain(props.features),\n createId: props.createId,\n defaultEdgeOptions: plain(props.defaultEdgeOptions),\n },\n );\n const typed = (given ?? ownModel) as FlowModel<AnyTypes, FlowFeatures>;\n const model = eraseModel(typed);\n\n // the features are the model's, fixed when it is created: a later change is ignored\n const warn = warnOnce();\n const firstFeatures = featureNames(props.features);\n watch(\n () => featureNames(props.features),\n (next) => {\n if (!props.model && next !== firstFeatures) {\n warn(\n \"the features prop changed after the root created its model: the change is ignored (the features are fixed when the model is created)\",\n );\n }\n },\n );\n\n const engineProps = (): Partial<FlowEngineOptions> =>\n Object.fromEntries(\n ENGINE_PROPS.map((name) => [\n name,\n NUMBER_PROPS.has(name)\n ? numberProp(props[name])\n : plain(props[name]),\n ]),\n ) as Partial<FlowEngineOptions>;\n const start = plain(\n props.viewport ?? props.defaultViewport ?? DEFAULT_VIEWPORT,\n );\n const facade = createEngineFacade(start);\n const engine = shallowRef<AnyFlowEngine | null>(null);\n const store = createFlowStore(model);\n const revision = store.view;\n const rootElement = shallowRef<HTMLElement | null>(null);\n\n // the engine options last sent, by key: a change sends only the keys that changed (an\n // `interactive` that stays must not undo the lock of `Flow.ToggleInteractive`)\n let sentOptions: Record<string, unknown> = {};\n const stops: (() => void)[] = [];\n // the engine is created once mounted, so that no server render attaches or observes\n // anything; the parts that attach to it read `engine` in their render, and patch then\n onMounted(() => {\n const options = engineProps();\n const created = createFlowEngine(model, {\n ...options,\n defaultViewport: { x: start.x, y: start.y, zoom: start.zoom },\n fitView: plain(props.fitView),\n }) as unknown as AnyFlowEngine;\n sentOptions = optionKeys(options);\n stops.push(\n store.attach(created),\n created.subscribe((event) => {\n if (event.type === \"viewport-change\") {\n emit(\"update:viewport\", event.viewport, event.gesture);\n return;\n }\n // the event's own (`nodeClick`, `moveStart`, …): Vue calls the listener given now\n const name = EVENT_EMITS.get(event.type);\n if (name) emit(name, event);\n }),\n );\n facade.set(created as unknown as FlowEngine);\n engine.value = created;\n holdFlowRef(props.flowRef);\n });\n // destroyed once its parts are gone: they let go of their elements first\n onUnmounted(() => {\n for (const stop of stops.splice(0)) stop();\n const current = engine.value;\n facade.set(null);\n engine.value = null;\n current?.destroy();\n });\n\n // the flow ref: the model and the facade (the same object across engines)\n const handle = {\n model: typed,\n engine: facade.engine,\n } as unknown as FlowRefValue<FlowTypes, FlowFeatures>;\n let heldRef: FlowRef<FlowTypes, FlowFeatures> | undefined;\n const holdFlowRef = (\n next: FlowRef<AnyTypes, FlowFeatures> | undefined,\n ) => {\n const ref = next\n ? (toRaw(next) as unknown as FlowRef<FlowTypes, FlowFeatures>)\n : undefined;\n if (ref === heldRef) return;\n if (heldRef) setFlowRef(heldRef, null);\n heldRef = ref;\n if (ref) setFlowRef(ref, handle);\n };\n watch(\n () => props.flowRef,\n (next) => {\n if (engine.value) holdFlowRef(next);\n },\n );\n onBeforeUnmount(() => holdFlowRef(undefined));\n\n // the engine options that changed since they were sent\n watch([() => optionsKey(engineProps()), () => props.easing], () => {\n const live = engine.value;\n if (!live) return;\n const options = engineProps() as Record<string, unknown>;\n const next = optionKeys(options);\n const changed = Object.keys(next).filter(\n (key) => next[key] !== sentOptions[key],\n );\n sentOptions = next;\n if (changed.length === 0) return;\n live.adapter.setOptions(\n Object.fromEntries(changed.map((key) => [key, options[key]])),\n );\n });\n\n // a controlled viewport that differs from the engine's is set on it\n watch(\n () => [\n engine.value,\n props.viewport?.x,\n props.viewport?.y,\n props.viewport?.zoom,\n ],\n () => {\n const live = engine.value;\n const viewport = props.viewport;\n if (!live || !viewport) return;\n const current = live.get(\"viewport\");\n if (\n current.x !== viewport.x ||\n current.y !== viewport.y ||\n current.zoom !== viewport.zoom\n ) {\n live.run(\"set-viewport\", {\n x: viewport.x,\n y: viewport.y,\n zoom: viewport.zoom,\n });\n }\n },\n );\n\n // the controlled lists the model was last brought to (a model the root created starts at\n // them)\n let sent: { nodes: unknown; edges: unknown } = ownModel\n ? { nodes: props.nodes, edges: props.edges }\n : { nodes: undefined, edges: undefined };\n const syncControlled = () => {\n const { nodes, edges } = props;\n // only a list that changed is diffed (an edge list that stays is not walked on each\n // step)\n const target = {\n nodes: (nodes === sent.nodes ? undefined : plainList(nodes)) as\n | readonly FlowNode[]\n | undefined,\n edges: (edges === sent.edges ? undefined : plainList(edges)) as\n | readonly FlowEdge[]\n | undefined,\n };\n sent = { nodes, edges };\n if (target.nodes === undefined && target.edges === undefined) {\n return;\n }\n const commands = model.get(\"commands-to\", target);\n if (commands.length === 0) return;\n const options = { meta: CONTROLLED_META };\n if (!model.run(\"batch\", { commands: [...commands] }, options).ok) {\n // refused as a whole (a middleware's veto): each change that may be made is, and\n // the app hears what the model holds instead\n const refused: string[] = [];\n for (const entry of commands) {\n const result = model.run(\n \"batch\",\n { commands: [entry] },\n options,\n );\n if (!result.ok) {\n refused.push(\n `${entry.command}: ${result.error.message}`,\n );\n }\n }\n warn(\n `the controlled nodes / edges were not all applied (the model's are reported back):\\n${refused.join(\"\\n\")}`,\n );\n }\n // what the model holds when it differs from the props (a veto, a rule that kept a\n // node in its parent, a middleware that rewrote a payload): the app's state follows\n // the model\n if (\n target.nodes !== undefined &&\n model.get(\"commands-to\", { nodes: target.nodes }).length > 0\n ) {\n emit(\"update:nodes\", model.get(\"all-nodes\"));\n }\n if (\n target.edges !== undefined &&\n model.get(\"commands-to\", { edges: target.edges }).length > 0\n ) {\n emit(\"update:edges\", model.get(\"all-edges\"));\n }\n };\n watch([() => props.nodes, () => props.edges], syncControlled);\n\n // on the client only: a server render neither changes a model that may be shared by other\n // requests, nor subscribes to it\n onClient(() => {\n syncControlled();\n onScopeDispose(\n model.subscribe((event: CommandEvent) => {\n store.commit();\n if (event.meta?.source === CONTROLLED_META.source) return;\n if (event.before.nodes !== event.after.nodes) {\n emit(\"update:nodes\", event.after.nodes);\n }\n if (event.before.edges !== event.after.edges) {\n emit(\"update:edges\", event.after.edges);\n }\n }),\n );\n });\n\n // the geometry the parts draw from while there is no engine (the server, the first client\n // render): once per document and options, shared by every part\n let lastGeometry:\n | {\n nodes: readonly FlowNode[];\n edges: readonly FlowEdge[];\n key: string;\n value: StaticGeometry;\n }\n | undefined;\n const geometry = computed<StaticGeometry | null>(() => {\n // the lists: a commit that keeps them keeps the geometry\n store.entity.value;\n if (engine.value) {\n lastGeometry = undefined;\n return null;\n }\n const options = {\n nodeOrigin: plain(props.nodeOrigin),\n pathOptions: plain(props.pathOptions),\n zIndexMode: props.zIndexMode,\n elevateNodesOnSelect: props.elevateNodesOnSelect,\n elevateEdgesOnSelect: props.elevateEdgesOnSelect,\n };\n const nodes = model.get(\"all-nodes\");\n const edges = model.get(\"all-edges\");\n const key = optionsKey(options);\n if (\n lastGeometry &&\n lastGeometry.nodes === nodes &&\n lastGeometry.edges === edges &&\n lastGeometry.key === key\n ) {\n return lastGeometry.value;\n }\n const value = staticGeometry({ nodes, edges }, options);\n lastGeometry = { nodes, edges, key, value };\n return value;\n });\n\n const context: FlowContextValue = {\n model,\n engine,\n publicEngine: facade.engine as unknown as AnyFlowEngine,\n rootElement,\n revision,\n store,\n onlyRenderVisible: computed(() => props.onlyRenderVisible === true),\n geometry,\n };\n provide(FlowKey, context);\n\n const rootRef = elementRef(\n (element) => {\n rootElement.value = element as HTMLElement;\n const live = engine.value;\n if (live) live.adapter.attachRoot(element as HTMLElement);\n return () => {\n if (live) live.adapter.detachRoot();\n rootElement.value = null;\n };\n },\n () => [engine.value],\n );\n const attributes = useFlowValue(context, () => {\n const live = engine.value;\n return live\n ? live.adapter.attributes(\"root\")\n : partAttributes(\"root\");\n });\n\n return () => {\n const live = engine.value;\n const current = attributes.value;\n const state: RootState = {\n interactive: live\n ? current[\"data-interactive\"] !== undefined\n : true,\n panning: current[\"data-panning\"] !== undefined,\n dragging: current[\"data-dragging\"] !== undefined,\n connecting: current[\"data-connecting\"] !== undefined,\n selecting: current[\"data-selecting\"] !== undefined,\n };\n return renderElement({\n tag: \"div\",\n as: props.as,\n attrs,\n render: slots.render,\n state,\n ref: rootRef,\n props: { ...current },\n style: ROOT_STYLE,\n children: () => slots.default?.({ state }),\n });\n };\n },\n {\n booleans: ROOT_BOOLEANS,\n types: {\n fitView: [Boolean, Object] as PropType<unknown>,\n // a bare attribute is `true`, mouse buttons (`:pan-on-drag=\"[1, 2]\"`) stay a list\n panOnDrag: [Boolean, Array] as PropType<unknown>,\n autoPan: [Boolean, Object] as PropType<unknown>,\n // `pan-on-scroll-speed=\"2\"` is its number\n panOnScrollSpeed: NUMBER_PROP,\n paneClickDistance: NUMBER_PROP,\n nodeClickDistance: NUMBER_PROP,\n },\n emits: ROOT_EMITS,\n },\n);\n\n/**\n * The flow (`data-flow-part=\"root\"`): owns the model (unless given) and the engine, attaches the\n * engine to its element (the engine listens to it: pointer, wheel, keys, focus) and re-renders\n * when the flow changes. It renders only its default slot; no provider is needed above it. Give\n * it a size (the flow fills it). Another `model` remounts the flow. It takes any features; give\n * it your registry and features with `typedFlow<Types, typeof features>().Root`.\n */\nexport const Root: FlowComponent<\n RootProps<AnyTypes, FlowFeatures>,\n RootSlots,\n RootEmits\n> = defineComponent({\n name: \"FlowRoot\",\n inheritAttrs: false,\n // a bare boolean attribute reaches RootFlow as it came, which casts it\n props: [...ROOT_PROPS],\n emits: [...ROOT_EMITS],\n setup(props, { attrs, slots, emit }) {\n const forward = Object.fromEntries(\n ROOT_EMITS.map((event) => [\n `on${event[0]?.toUpperCase()}${event.slice(1)}`,\n (...args: unknown[]) =>\n (emit as (name: string, ...rest: unknown[]) => void)(\n event,\n ...args,\n ),\n ]),\n );\n return () =>\n h(\n RootFlow,\n {\n ...attrs,\n ...props,\n ...forward,\n key: keyOfModel(\n (props as { model?: object | undefined }).model,\n ),\n } as never,\n slots,\n );\n },\n}) as unknown as FlowComponent<\n RootProps<AnyTypes, FlowFeatures>,\n RootSlots,\n RootEmits\n>;\n","import type { Rect } from \"@fragiola/flow\";\nimport { useFlowValue } from \"../composables/internal\";\nimport { useFlowContext } from \"../context\";\nimport {\n definePrimitive,\n type FlowComponent,\n type PrimitiveProps,\n type SlotFunction,\n} from \"../utils/primitive\";\nimport { px, type RenderSlot, renderElement } from \"../utils/render\";\n\nexport interface SelectionBoxState {\n /** the box, in pixels relative to the root */\n readonly box: Rect;\n}\n\nexport interface SelectionBoxProps extends PrimitiveProps {}\n\nexport interface SelectionBoxSlots extends RenderSlot<SelectionBoxState> {\n default?: SlotFunction<{ state: SelectionBoxState }>;\n}\n\n/**\n * The box selection being drawn (`data-flow-part=\"selection-box\"`, `selection()`): absolutely\n * positioned in `Flow.Root` (outside `Flow.Viewport`: it is in screen pixels), rendered only\n * while a box is drawn. Give it its look.\n */\nexport const SelectionBox: FlowComponent<SelectionBoxProps, SelectionBoxSlots> =\n definePrimitive<SelectionBoxProps, SelectionBoxSlots>(\n \"SelectionBox\",\n [\"as\"],\n (props, { attrs, slots }) => {\n const context = useFlowContext(\"SelectionBox\");\n const box = useFlowValue(\n context,\n () => context.engine.value?.get(\"selection-box\") ?? null,\n );\n const attributes = useFlowValue(\n context,\n () =>\n context.engine.value?.adapter.attributes(\"selection-box\") ??\n {},\n );\n return () => {\n const current = box.value;\n if (!current) return null;\n const state: SelectionBoxState = { box: current };\n return renderElement({\n tag: \"div\",\n as: props.as,\n attrs,\n render: slots.render,\n state,\n props: {\n ...attributes.value,\n \"data-flow-part\": \"selection-box\",\n },\n style: {\n position: \"absolute\",\n left: px(current.x),\n top: px(current.y),\n width: px(current.width),\n height: px(current.height),\n pointerEvents: \"none\",\n },\n children: () => slots.default?.({ state }),\n });\n };\n },\n );\n","import { useFlowValue } from \"../composables/internal\";\nimport { useFlowContext } from \"../context\";\nimport {\n definePrimitive,\n type FlowComponent,\n type PrimitiveProps,\n type SlotFunction,\n} from \"../utils/primitive\";\nimport { type RenderSlot, renderElement } from \"../utils/render\";\n\n/** The switches the lock turns off and on (React Flow's: dragging, connecting, selecting). */\nconst LOCKED_KINDS = [\"drag\", \"connect\", \"select\"] as const;\n\nexport interface ToggleInteractiveState {\n /**\n * the flow is not locked: it is interactive and one of dragging, connecting and selecting at\n * least is on (`interactive-by`)\n */\n readonly interactive: boolean;\n}\n\nexport interface ToggleInteractiveProps extends PrimitiveProps {}\n\nexport interface ToggleInteractiveSlots\n extends RenderSlot<ToggleInteractiveState> {\n /** its content (an icon, a label) */\n default?: SlotFunction<{ state: ToggleInteractiveState }>;\n}\n\n/**\n * A toggle button (`data-flow-part=\"toggle-interactive\"`, `aria-pressed` while the flow is locked,\n * `data-interactive`): locks and unlocks the flow, React Flow's interactive button: locking turns\n * dragging, connecting and selecting off (`set-interactive { drag, connect, select }`), unlocking\n * turns them and `interactive` on; pan and zoom stay. It renders only its default slot.\n */\nexport const ToggleInteractive: FlowComponent<\n ToggleInteractiveProps,\n ToggleInteractiveSlots\n> = definePrimitive<ToggleInteractiveProps, ToggleInteractiveSlots>(\n \"ToggleInteractive\",\n [\"as\"],\n (props, { attrs, slots }) => {\n const context = useFlowContext(\"ToggleInteractive\");\n const interactive = useFlowValue(context, () => {\n const engine = context.engine.value;\n return engine\n ? LOCKED_KINDS.some((kind) =>\n engine.is(\"interactive-by\", { kind }),\n )\n : true;\n });\n const onClick = () => {\n context.engine.value?.run(\n \"set-interactive\",\n interactive.value\n ? { drag: false, connect: false, select: false }\n : {\n interactive: true,\n drag: true,\n connect: true,\n select: true,\n },\n );\n };\n return () => {\n const state: ToggleInteractiveState = {\n interactive: interactive.value,\n };\n return renderElement({\n tag: \"button\",\n as: props.as,\n attrs,\n render: slots.render,\n state,\n props: {\n type: \"button\",\n \"data-flow-part\": \"toggle-interactive\",\n \"data-interactive\": state.interactive ? \"\" : undefined,\n \"aria-pressed\": String(!state.interactive),\n disabled: context.engine.value === null,\n onClick,\n },\n children: () => slots.default?.({ state }),\n });\n };\n },\n);\n","import { partAttributes, type Viewport as ViewportValue } from \"@fragiola/flow\";\nimport { useViewport } from \"../composables/use-viewport\";\nimport { useFlowContext } from \"../context\";\nimport {\n definePrimitive,\n type FlowComponent,\n type PrimitiveProps,\n type SlotFunction,\n} from \"../utils/primitive\";\nimport { elementRef, type RenderSlot, renderElement } from \"../utils/render\";\n\nexport interface ViewportState {\n /** the viewport: the pan (`x`, `y`, pixels) and the zoom */\n viewport: ViewportValue;\n}\n\nexport interface ViewportProps extends PrimitiveProps {}\n\nexport interface ViewportSlots extends RenderSlot<ViewportState> {\n /** what is in flow coordinates: `Flow.Edges`, `Flow.Nodes`, `Flow.ConnectionLine` */\n default?: SlotFunction<{ state: ViewportState }>;\n}\n\nconst VIEWPORT_STYLE = {\n position: \"absolute\",\n top: \"0\",\n left: \"0\",\n width: \"100%\",\n height: \"100%\",\n // a stacking context of its own before the engine writes its transform (the server's HTML):\n // with several render levels the nodes and edge layers have negative z-indexes\n isolation: \"isolate\",\n};\n\n/**\n * The pannable, zoomable layer (`data-flow-part=\"viewport\"`): what is inside is in flow\n * coordinates (`Flow.Edges`, `Flow.Nodes`, `Flow.ConnectionLine`). The engine writes its\n * `transform` itself (D4), never Vue: a pan or a zoom re-renders nothing inside it, nor the\n * viewport itself unless its state is read (its `render` slot, a `class` or `style` function).\n */\nexport const Viewport: FlowComponent<ViewportProps, ViewportSlots> =\n definePrimitive<ViewportProps, ViewportSlots>(\n \"Viewport\",\n [\"as\"],\n (props, { attrs, slots }) => {\n const context = useFlowContext(\"Viewport\");\n const viewport = useViewport();\n const ref = elementRef(\n (element) => {\n const engine = context.engine.value;\n if (!engine) return undefined;\n engine.adapter.attachViewport(element as HTMLElement);\n return () => engine.adapter.attachViewport(null);\n },\n () => [context.engine.value],\n );\n // read when used (a `render` slot, a `class` function): a pan re-renders the viewport\n // only for a consumer that shows it\n const state: ViewportState = {\n get viewport() {\n return viewport.value;\n },\n };\n return () => {\n context.engine.value;\n return renderElement({\n tag: \"div\",\n as: props.as,\n attrs,\n render: slots.render,\n state,\n ref,\n props: { ...partAttributes(\"viewport\") },\n style: VIEWPORT_STYLE,\n children: () => slots.default?.({ state }),\n });\n };\n },\n );\n","import {\n type ControlButtonState,\n useControlButton,\n} from \"../composables/use-control-button\";\nimport {\n definePrimitive,\n type FlowComponent,\n NUMBER_PROP,\n numberProp,\n type PrimitiveProps,\n type SlotFunction,\n} from \"../utils/primitive\";\nimport { type RenderSlot, renderElement } from \"../utils/render\";\n\nexport interface ZoomInProps extends PrimitiveProps {\n /** disabled even when the engine would run its action */\n disabled?: boolean | undefined;\n /**\n * how long its viewport change animates, in milliseconds (the root's `easing`); default 0: at\n * once. The attribute's text is its number (`duration=\"300\"`)\n */\n duration?: number | `${number}` | undefined;\n}\n\nexport interface ZoomInSlots extends RenderSlot<ControlButtonState> {\n /** its content (an icon, a label) */\n default?: SlotFunction<{ state: ControlButtonState }>;\n}\n\n/**\n * A button (`data-flow-part=\"zoom-in\"`): Zooms in by a step around the root's centre (`zoom-in`), disabled at the greatest zoom. It renders only its default slot (an icon,\n * a label).\n */\nexport const ZoomIn: FlowComponent<ZoomInProps, ZoomInSlots> = definePrimitive<\n ZoomInProps,\n ZoomInSlots\n>(\n \"ZoomIn\",\n [\"disabled\", \"duration\", \"as\"],\n (props, { attrs, slots }) => {\n const { state, props: own } = useControlButton(\n \"ZoomIn\",\n \"zoom-in\",\n () => props.disabled,\n () => ({ duration: numberProp(props.duration) }),\n );\n return () => {\n const current = state.value;\n return renderElement({\n tag: \"button\",\n as: props.as,\n attrs,\n render: slots.render,\n state: current,\n props: own(),\n children: () => slots.default?.({ state: current }),\n });\n };\n },\n {\n booleans: [\"disabled\"],\n // `duration=\"300\"` is its number\n types: { duration: NUMBER_PROP },\n },\n);\n","import {\n type ControlButtonState,\n useControlButton,\n} from \"../composables/use-control-button\";\nimport {\n definePrimitive,\n type FlowComponent,\n NUMBER_PROP,\n numberProp,\n type PrimitiveProps,\n type SlotFunction,\n} from \"../utils/primitive\";\nimport { type RenderSlot, renderElement } from \"../utils/render\";\n\nexport interface ZoomOutProps extends PrimitiveProps {\n /** disabled even when the engine would run its action */\n disabled?: boolean | undefined;\n /**\n * how long its viewport change animates, in milliseconds (the root's `easing`); default 0: at\n * once. The attribute's text is its number (`duration=\"300\"`)\n */\n duration?: number | `${number}` | undefined;\n}\n\nexport interface ZoomOutSlots extends RenderSlot<ControlButtonState> {\n /** its content (an icon, a label) */\n default?: SlotFunction<{ state: ControlButtonState }>;\n}\n\n/**\n * A button (`data-flow-part=\"zoom-out\"`): Zooms out by a step around the root's centre (`zoom-out`), disabled at the least zoom. It renders only its default slot (an icon,\n * a label).\n */\nexport const ZoomOut: FlowComponent<ZoomOutProps, ZoomOutSlots> =\n definePrimitive<ZoomOutProps, ZoomOutSlots>(\n \"ZoomOut\",\n [\"disabled\", \"duration\", \"as\"],\n (props, { attrs, slots }) => {\n const { state, props: own } = useControlButton(\n \"ZoomOut\",\n \"zoom-out\",\n () => props.disabled,\n () => ({ duration: numberProp(props.duration) }),\n );\n return () => {\n const current = state.value;\n return renderElement({\n tag: \"button\",\n as: props.as,\n attrs,\n render: slots.render,\n state: current,\n props: own(),\n children: () => slots.default?.({ state: current }),\n });\n };\n },\n {\n booleans: [\"disabled\"],\n // `duration=\"300\"` is its number\n types: { duration: NUMBER_PROP },\n },\n );\n","// The `Flow` namespace: `import { Flow } from \"@fragiola/flow-vue\"`, then `<Flow.Root>`,\n// `<Flow.Node>`, … The features' primitives are on their entries (`MiniMap` on\n// `@fragiola/flow-vue/minimap`, `NodeResizer` on `/resize`), so this one never imports them.\nexport { Background } from \"./components/background\";\nexport { ConnectionLine } from \"./components/connection-line\";\nexport { Controls } from \"./components/controls\";\nexport { Edge } from \"./components/edge\";\nexport { EdgeLabel } from \"./components/edge-label\";\nexport { EdgePath } from \"./components/edge-path\";\nexport { EdgeToolbar } from \"./components/edge-toolbar\";\nexport { Edges } from \"./components/edges\";\nexport { FitView } from \"./components/fit-view\";\nexport { Handle } from \"./components/handle\";\nexport { Node } from \"./components/node\";\nexport { NodeToolbar } from \"./components/node-toolbar\";\nexport { Nodes } from \"./components/nodes\";\nexport { NodesSelection } from \"./components/nodes-selection\";\nexport { ReconnectAnchor } from \"./components/reconnect-anchor\";\nexport { Root } from \"./components/root\";\nexport { SelectionBox } from \"./components/selection-box\";\nexport { ToggleInteractive } from \"./components/toggle-interactive\";\nexport { Viewport } from \"./components/viewport\";\nexport { ZoomIn } from \"./components/zoom-in\";\nexport { ZoomOut } from \"./components/zoom-out\";\n","// From Splitter (fragiola/splitter, packages/vue/src/typed.ts), same author and licence.\nimport type { AnyTypes, FlowFeatures, FlowTypes } from \"@fragiola/flow\";\nimport type { EdgeProps, EdgeSlots } from \"./components/edge\";\nimport type { EdgesProps, EdgesSlots } from \"./components/edges\";\nimport type { NodeProps, NodeSlots } from \"./components/node\";\nimport type { NodesProps, NodesSlots } from \"./components/nodes\";\nimport type { RootEmits, RootProps, RootSlots } from \"./components/root\";\nimport * as parts from \"./parts\";\nimport type { FlowComponent } from \"./utils/primitive\";\n\n/**\n * The `Flow` primitives typed by the registry `T` and the features `F`: the root's model, lists\n * and features, and the nodes and edges the slots give and the parts take. The others are the\n * same as `Flow`'s.\n */\nexport type TypedFlow<\n T extends FlowTypes = AnyTypes,\n F extends FlowFeatures = readonly [],\n> = Omit<typeof parts, \"Root\" | \"Nodes\" | \"Node\" | \"Edges\" | \"Edge\"> & {\n Root: FlowComponent<RootProps<T, F>, RootSlots, RootEmits<T>>;\n Nodes: FlowComponent<NodesProps, NodesSlots<T>>;\n Node: FlowComponent<NodeProps<T>, NodeSlots<T>>;\n Edges: FlowComponent<EdgesProps, EdgesSlots<T>>;\n Edge: FlowComponent<EdgeProps<T>, EdgeSlots<T>>;\n};\n\n/**\n * The `Flow` primitives typed by your registry and features: what React writes as type arguments\n * (`<Flow.Nodes<Types>>`), which a Vue template cannot pass. The same components, typed:\n *\n * ```ts\n * const Flow = typedFlow<Types, typeof features>();\n * // <Flow.Nodes v-slot=\"{ node }\">: `node.data` is the registry's\n * ```\n */\nexport function typedFlow<\n T extends FlowTypes = AnyTypes,\n F extends FlowFeatures = readonly [],\n>(): TypedFlow<T, F> {\n return parts as unknown as TypedFlow<T, F>;\n}\n"],"mappings":";;;;;;;AAyCA,MAAM,yBAAS,IAAI,QAAiD;;;;;;;;;;AAWpE,SAAgB,gBAGG;CACf,MAAM,QAAQ,WAAgC,IAAI;CAElD,MAAM,OAAO,QAAQ,EACjB,IAAI,QAAQ;EACR,OAAO,MAAM;CACjB,EACJ,CAAC;CACD,OAAO,IAAI,MAAM,KAAK;CACtB,OAAO;AACX;;AAGA,SAAgB,WACZ,MACA,MACI;CACJ,MAAM,UAAU,OAAO,IAAI,MAAM,IAAI,CAAC;CACtC,IAAI,CAAC,SACD,MAAM,IAAI,UACN,yEACJ;CAEJ,QAAQ,QAAQ;AACpB;;;;;;;ACrEA,SAAgB,gBAAgD;CAC5D,MAAM,UAAU,eAAe,eAAe;CAC9C,OAAO,aACH,eACM,QAAQ,OAAO,OAAO,IAAI,YAAY,KAAK,OAChD,GAAG,MACA,MAAM,KACL,MAAM,QACH,MAAM,QACN,EAAE,SAAS,EAAE,QACb,EAAE,WAAW,EAAE,UACf,EAAE,OAAO,EAAE,MACX,EAAE,SAAS,EAAE,QACb,EAAE,WAAW,EAAE,MAC3B;AACJ;;;ACyBA,SAAgB,aACZ,GACA,GACO;CACP,IAAI,MAAM,GAAG,OAAO;CACpB,IAAI,CAAC,KAAK,CAAC,GAAG,OAAO;CACrB,OACI,EAAE,SAAS,EAAE,QACb,EAAE,eAAe,EAAE,cACnB,EAAE,eAAe,EAAE,cACnB,EAAE,MAAM,MAAM,EAAE,MAAM,KACtB,EAAE,MAAM,MAAM,EAAE,MAAM,KACtB,E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;AACnC,CACJ;;;;;;AC/BA,MAAa,UACT,gBACI,WACA;CAAC;CAAY;CAAY;AAAI,IAC5B,OAAO,EAAE,OAAO,YAAY;CACzB,MAAM,EAAE,OAAO,OAAO,QAAQ,iBAC1B,WACA,kBACM,MAAM,iBACL,EAAE,UAAU,WAAW,MAAM,QAAQ,EAAE,EAClD;CACA,aAAa;EACT,MAAM,UAAU,MAAM;EACtB,OAAO,cAAc;GACjB,KAAK;GACL,IAAI,MAAM;GACV;GACA,QAAQ,MAAM;GACd,OAAO;GACP,OAAO,IAAI;GACX,gBAAgB,MAAM,UAAU,EAAE,OAAO,QAAQ,CAAC;EACtD,CAAC;CACL;AACJ,GACA;CACI,UAAU,CAAC,UAAU;CAErB,OAAO,EAAE,UAAU,YAAY;AACnC,CACJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AE3BJ,SAAgB,YAGK;CACjB,OAAOC;AACX"}
@@ -0,0 +1 @@
1
+ export * from "@fragiola/flow/keyboard";
@@ -0,0 +1 @@
1
+ export * from "@fragiola/flow/keyboard";
@@ -0,0 +1,80 @@
1
+ import { n as PrimitiveProps, o as RenderSlot, r as SlotFunction, t as FlowComponent } from "./primitive-ryVigrQO.js";
2
+ import { MinimapView, XY } from "@fragiola/flow";
3
+ export * from "@fragiola/flow/minimap";
4
+ interface MiniMapState {
5
+ /** what it draws: the nodes, the view and the mask, in flow coordinates */
6
+ readonly view: MinimapView;
7
+ }
8
+ interface MiniMapProps extends PrimitiveProps {
9
+ /** its width, in pixels; default 200 */
10
+ width?: number | undefined;
11
+ /** its height, in pixels; default 150 */
12
+ height?: number | undefined;
13
+ /**
14
+ * a drag on it moves the view the other way (as grabbing the flow), and a press does not
15
+ * centre the view; default `minimap()`'s `inversePan`
16
+ */
17
+ inversePan?: boolean | undefined;
18
+ /**
19
+ * how fast its wheel zooms: 10 is the flow's own wheel, 20 twice as fast; default
20
+ * `minimap()`'s `zoomStep`. The attribute's text is its number (`zoom-step="20"`)
21
+ */
22
+ zoomStep?: number | `${number}` | undefined;
23
+ }
24
+ type MiniMapEmits = {
25
+ /**
26
+ * a tap on it (`minimap-click`), with the flow point under the pointer on the minimap: center
27
+ * the view there, add a node there (`@click`; the root captures the pointer, so a DOM click
28
+ * never reaches the minimap)
29
+ */
30
+ click: (event: MouseEvent, point: XY) => void;
31
+ };
32
+ interface MiniMapSlots extends RenderSlot<MiniMapState> {
33
+ /**
34
+ * what it draws, in flow coordinates (`v-slot="{ view }"`); default a `MiniMapNode` per node,
35
+ * then the `MiniMapMask`
36
+ */
37
+ default?: SlotFunction<{
38
+ view: MinimapView;
39
+ }>;
40
+ }
41
+ /**
42
+ * A small map of the flow (`data-flow-part="minimap"`, `minimap()`): an SVG of `width` × `height`
43
+ * pixels showing every node and what the root shows. With `minimap()`'s options, a drag on it pans
44
+ * and its wheel zooms the flow. Inside `Flow.Root`, outside `Flow.Viewport`; place it with your
45
+ * style.
46
+ */
47
+ export declare const MiniMap: FlowComponent<MiniMapProps, MiniMapSlots, MiniMapEmits>;
48
+ /** The state of `MiniMapMask`: the root's view, in flow coordinates. */
49
+ interface MiniMapMaskState {
50
+ readonly view: {
51
+ x: number;
52
+ y: number;
53
+ width: number;
54
+ height: number;
55
+ };
56
+ }
57
+ interface MiniMapMaskProps extends PrimitiveProps {}
58
+ interface MiniMapMaskSlots extends RenderSlot<MiniMapMaskState> {}
59
+ /**
60
+ * The `MiniMap`'s mask (`data-flow-part="minimap-mask"`): an SVG path covering the map but what the
61
+ * root shows (`fill-rule="evenodd"`). Give it its fill.
62
+ */
63
+ export declare const MiniMapMask: FlowComponent<MiniMapMaskProps, MiniMapMaskSlots>;
64
+ interface MiniMapNodeState {
65
+ readonly nodeId: string;
66
+ /** `data-selected` (`selection()`) */
67
+ readonly selected: boolean;
68
+ }
69
+ interface MiniMapNodeProps extends PrimitiveProps {
70
+ /** the node it stands for */
71
+ nodeId: string;
72
+ }
73
+ interface MiniMapNodeSlots extends RenderSlot<MiniMapNodeState> {}
74
+ /**
75
+ * A node in the `MiniMap` (`data-flow-part="minimap-node"`, `data-flow-id`): an SVG rectangle of
76
+ * the node's box, in flow coordinates. Nothing when the node is not shown.
77
+ */
78
+ export declare const MiniMapNode: FlowComponent<MiniMapNodeProps, MiniMapNodeSlots>;
79
+ export type { MiniMapEmits, MiniMapMaskProps, MiniMapMaskSlots, MiniMapMaskState, MiniMapNodeProps, MiniMapNodeSlots, MiniMapNodeState, MiniMapProps, MiniMapSlots, MiniMapState };
80
+ //# sourceMappingURL=minimap.d.ts.map