@orbat-mapper/tactical-draw 0.34.0 → 0.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as PinPresentationCapability, A as PointSymbolConnector, B as isPointSymbol, C as makeFillPatternImage, D as PointSymbolAnchor, E as PointSymbol, F as PointSymbolRect, G as ResolvedEditModifiers, H as DEFAULT_EDIT_MODIFIERS, I as PointSymbolRender, J as PointerEventInfo, K as EditPointerDriver, L as PointSymbolSize, M as PointSymbolOffset, N as PointSymbolOffsetStyle, O as PointSymbolCapability, P as PointSymbolPlacement, Q as PinPresentation, R as PointSymbolStyle, S as isMinePattern, T as OffsetDragModifier, U as EditModifiers, V as resizePointSymbolSize, W as ModifierKey, X as PinFootprint, Y as DEFAULT_PIN_PRESENTATION, Z as PinOverridePatch, _ as HatchPattern, a as LayerId, at as PinRender, b as fillPatternImageDimension, c as MapEvent, ct as pinDistanceScale, d as PickHandler, et as PinPresentationPatch, f as PickOptions, g as HATCH_PATTERNS, h as TextStyleOptions, i as ImageOverlayResource, it as PinPresentationStore, j as PointSymbolGraphicModifiers, k as PointSymbolColors, l as MapEventHandler, lt as pinZoomScale, m as StyleOptions, n as HandleStyle, nt as PinPresentationStatus, o as MapAdapter, ot as combinePinScale, p as PixelCoordinate, q as PointerCallback, r as IconResource, rt as PinPresentationStatusEvent, s as MapCursor, st as isValidPinNumber, t as FeatureGroup, tt as PinPresentationState, u as PickEvent, ut as resolvePinPresentation, v as MINE_PATTERN_TILE_SIZE, w as parseColor, x as fillPatternImageId, y as Rgba, z as clonePointSymbol } from "./map-adapter-g2v5Ok3Y.mjs";
1
+ import { $ as CollocationLocate, $t as DEFAULT_PIN_PRESENTATION, A as PointSymbolColors, At as validateCollocation, B as clonePointSymbol, Bt as isMarker, C as isMinePattern, Ct as collocationOpacity, D as PointSymbol, Dt as resolveCollocationLocation, E as OffsetDragModifier, Et as patchCollocationOptions, F as PointSymbolPlacement, Ft as MarkerRender, G as Collocation, Gt as EditModifiers, H as resizePointSymbolSize, Ht as normalizeMarker, I as PointSymbolRect, It as MarkerSize, J as CollocationBracketShape, Jt as ResolvedEditModifiers, K as CollocationAreaStyle, Kt as ModifierKey, L as PointSymbolRender, Lt as MarkerStyle, M as PointSymbolGraphicModifiers, Mt as MarkerAnchor, N as PointSymbolOffset, Nt as MarkerCapability, O as PointSymbolAnchor, Ot as resolveCollocationSize, P as PointSymbolOffsetStyle, Pt as MarkerIcon, Q as CollocationHalo, Qt as PointerEventInfo, R as PointSymbolSize, Rt as cloneMarker, S as fillPatternImageId, St as collocationMemberPart, T as parseColor, Tt as normalizeCollocation, U as BuildCollocationRenderOptions, Ut as validateMarker, V as isPointSymbol, Vt as markerOpacity, W as COLLOCATION_SCREEN_RELATIVE_REACH, Wt as DEFAULT_EDIT_MODIFIERS, X as CollocationCommitChanges, Xt as EditPointerDriver, Y as CollocationBracketSide, Yt as readPickModifiers, Z as CollocationGround, Zt as PointerCallback, _ as HATCH_PATTERNS, _t as CollocationStroke, a as ImageOverlayResource, an as PinPresentationState, at as CollocationMemberOptionTypes, b as Rgba, bt as buildCollocationRender, c as MapCursor, cn as PinPresentationStore, ct as CollocationMemberRenderContext, d as PickEvent, dn as isValidPinNumber, dt as CollocationPart, en as PinFootprint, et as CollocationMarker, f as PickHandler, fn as pinDistanceScale, ft as CollocationPartDrag, g as TextStyleOptions, gt as CollocationRenderMember, h as StyleOptions, ht as CollocationRender, i as IconResource, in as PinPresentationPatch, it as CollocationMemberIcon, j as PointSymbolConnector, jt as Marker, k as PointSymbolCapability, kt as stableCollocation, l as MapEvent, ln as PinRender, lt as CollocationMemberSupport, m as PixelCoordinate, mn as resolvePinPresentation, mt as CollocationPointSymbol, n as HandleStyle, nn as PinPresentation, nt as CollocationMemberCapabilities, o as LayerId, on as PinPresentationStatus, ot as CollocationMemberOptions, p as PickOptions, pn as pinZoomScale, pt as CollocationPlate, q as CollocationBracketPlacement, qt as PickModifiers, r as IconHitLine, rn as PinPresentationCapability, rt as CollocationMemberGraphic, s as MapAdapter, sn as PinPresentationStatusEvent, st as CollocationMemberRender, t as FeatureGroup, tn as PinOverridePatch, tt as CollocationMember, u as MapEventHandler, un as combinePinScale, ut as CollocationOptions, v as HatchPattern, vt as CollocationStyle, w as makeFillPatternImage, wt as isCollocation, x as fillPatternImageDimension, xt as cloneCollocation, y as MINE_PATTERN_TILE_SIZE, yt as ResolvedCollocationMemberRender, z as PointSymbolStyle, zt as composeMarkerCapabilities } from "./map-adapter-CTbZTAL0.mjs";
2
2
  import { AmplifierPlacement, AmplifierPlacements, ControlMeasure, ControlMeasureKind, ControlMeasureRender, ControlMeasureStyle, HighlightAppearance, LabelFit, SymbolColors, TextAmplifiers } from "@orbat-mapper/control-measures";
3
3
  import { Feature, Position } from "geojson";
4
4
 
@@ -22,7 +22,14 @@ declare abstract class BaseMapAdapter<TLayerHandle, TEventToken, TViewToken> imp
22
22
  protected featureCache: Map<string, Feature<import("geojson").Geometry, import("geojson").GeoJsonProperties>[]>;
23
23
  protected featuresChangedListeners: Map<string, Set<(features: Feature[]) => void>>;
24
24
  protected iconResources: Map<string, IconResource>;
25
+ /** What each layer draws: its desired groups, or a group's previous version while held. */
25
26
  private featureGroupState;
27
+ /** The groups each layer was last given. */
28
+ private desiredFeatureGroups;
29
+ /** Held groups per layer, for layers drawing at least one group's earlier version. */
30
+ private heldLayers;
31
+ /** Per held layer, the timer that draws a group that waited too long. */
32
+ private holdTimers;
26
33
  private layerIconResourceIds;
27
34
  private layerCounter;
28
35
  private destroyed;
@@ -32,6 +39,35 @@ declare abstract class BaseMapAdapter<TLayerHandle, TEventToken, TViewToken> imp
32
39
  }): LayerId;
33
40
  removeLayer(layerId: LayerId): void;
34
41
  setLayerFeatureGroups(layerId: LayerId, groups: readonly FeatureGroup[]): void;
42
+ /**
43
+ * Hand a layer's desired groups to the engine. A group whose drawn icons
44
+ * (see `isIconResourceReady`) are not all drawable yet keeps drawing earlier
45
+ * content, so a replacement image that loads asynchronously never leaves a
46
+ * frame without the group's content; `iconResourceLoaded` commits it once
47
+ * they are. Updates that arrive faster than their icons load don't freeze
48
+ * the group: it draws the newest version whose icons have loaded, and one
49
+ * that drew nothing newer for a second draws its desired version anyway. A
50
+ * group with no previous version is drawn at once.
51
+ */
52
+ private commitFeatureGroups;
53
+ /**
54
+ * Whether the engine can draw icon resource `id` in the next frame. Engines
55
+ * that register icon images asynchronously override this together with
56
+ * calling `iconResourceLoaded`; a resource that failed to load counts as
57
+ * ready, so its group is not held forever.
58
+ */
59
+ protected isIconResourceReady(id: string): boolean;
60
+ /** Called by the engine once icon resource `id` became drawable: commits groups held for it. */
61
+ protected iconResourceLoaded(id: string): void;
62
+ /**
63
+ * Whether every icon `group` draws is drawable: the resources its features
64
+ * name through `iconId`, and its pin's. A listed resource nothing draws
65
+ * never holds the group.
66
+ */
67
+ private iconsReady;
68
+ /** Commit `layerId` again when its longest-waiting held group runs out of time. */
69
+ private scheduleHoldTimeout;
70
+ private clearHoldTimer;
35
71
  abstract onPick(layerId: LayerId, handler: PickHandler, opts?: PickOptions): () => void;
36
72
  abstract createEditPointerDriver(): EditPointerDriver;
37
73
  on(eventType: "click" | "pointermove" | "dblclick", handler: MapEventHandler): void;
@@ -91,6 +127,52 @@ declare function tryControlMeasureIdFromFeature(feature: Feature): string | null
91
127
  */
92
128
  declare function bindAbortable(signal: AbortSignal | undefined, attach: () => () => void): () => void;
93
129
  //#endregion
130
+ //#region src/feature-seam-fields.d.ts
131
+ /**
132
+ * Generic per-feature seam fields any `FeatureGroup` feature may carry
133
+ * (ADR-0063, "The MapAdapter seam"). Adapters read them through these helpers
134
+ * so every engine and the shared picker agree on defaults and validation.
135
+ */
136
+ /**
137
+ * Feature property: optional pixel offset `[x, y]` from an icon feature's
138
+ * point to its resource anchor, in the icon's own resource units (right/down
139
+ * positive). It scales with the icon's display size (`iconScale` or ground
140
+ * sizing) and turns with its rotation, so the resource anchor draws at
141
+ * `point + rotate(offset × scale)`. With a non-zero `iconRotation` that isn't
142
+ * bearing-safe on MapLibre, which holds `iconRotation` on screen
143
+ * (`icon-rotation-alignment: viewport`) where OpenLayers and the shared
144
+ * picker turn it with the map; use {@link ICON_SCREEN_ROTATION_PROPERTY} for
145
+ * an offset icon on a map that may turn.
146
+ */
147
+ declare const ICON_OFFSET_PROPERTY = "iconOffset";
148
+ /**
149
+ * Feature property: optional screen-space rotation of an icon feature, in
150
+ * radians clockwise on screen. When present it replaces `iconRotation` and the
151
+ * icon ignores the map bearing: it keeps this angle on screen however the map
152
+ * turns (OpenLayers `rotateWithView: false`, MapLibre viewport alignment).
153
+ * Collocation part and member images carry `0`, so they stay upright.
154
+ */
155
+ declare const ICON_SCREEN_ROTATION_PROPERTY = "iconScreenRotation";
156
+ /**
157
+ * Feature property: `false` marks a feature as not hit area. The shared
158
+ * screen-space picker and every adapter's candidate collection skip it, so a
159
+ * pick falls through to whatever lies beneath. Any other value (or none)
160
+ * keeps the feature pickable.
161
+ */
162
+ declare const HIT_AREA_PROPERTY = "hitArea";
163
+ /** The feature's icon pixel offset in resource units; `[0, 0]` when absent or invalid. */
164
+ declare function resolveIconOffset(properties: Feature["properties"] | undefined): [number, number];
165
+ /** The feature's screen-space icon rotation (radians), or `undefined` when it turns with the map. */
166
+ declare function resolveIconScreenRotation(properties: Feature["properties"] | undefined): number | undefined;
167
+ /**
168
+ * The icon resource anchor shifted by the feature's icon pixel offset: the
169
+ * resource coordinate that lands on the feature's point. Adapters whose engine
170
+ * takes an anchor (OpenLayers `anchor`, Leaflet `iconAnchor`) use it directly.
171
+ */
172
+ declare function resolveIconAnchor(anchor: readonly [number, number], properties: Feature["properties"] | undefined): [number, number];
173
+ /** Whether the feature takes the pointer (false only for `hitArea: false`). */
174
+ declare function isHitArea(feature: Pick<Feature, "properties">): boolean;
175
+ //#endregion
94
176
  //#region src/pick-candidates.d.ts
95
177
  interface ScreenBounds {
96
178
  minX: number;
@@ -496,75 +578,6 @@ declare function normalizeImageGraphic(image: ImageGraphic): ImageGraphic;
496
578
  declare function imageOpacity(image: ImageGraphic): number;
497
579
  declare function validateImageGraphic(image: ImageGraphic): void;
498
580
  //#endregion
499
- //#region src/marker.d.ts
500
- /** Displayed icon height; same pixel/meter contract as point-symbol sizes. */
501
- type MarkerSize = PointSymbolSize;
502
- interface MarkerStyle {
503
- /** Host-interpreted tint, handed to {@link MarkerCapability.render}. */
504
- color?: string;
505
- /** 0–1 display multiplier applied by TacticalDraw. */
506
- opacity?: number;
507
- }
508
- /**
509
- * Persisted generic marker (e.g. a pin) whose icon is supplied by the
510
- * host application. TacticalDraw treats `symbolId` as opaque (ADR-0059).
511
- */
512
- interface Marker {
513
- id: string;
514
- kind: "marker";
515
- /** Host-defined icon identifier resolved by the {@link MarkerCapability}. */
516
- symbolId: string;
517
- position: Position;
518
- /** Normalized radians clockwise from geographic north, around the icon anchor. */
519
- rotation: number;
520
- size: MarkerSize;
521
- /** Optional text; the capability decides whether and how to draw it. */
522
- label?: string;
523
- style?: MarkerStyle;
524
- properties?: Record<string, unknown>;
525
- schemaVersion: 1;
526
- }
527
- interface MarkerAnchor {
528
- x: number;
529
- y: number;
530
- }
531
- /** Host-prepared marker icon in canonical SVG units. */
532
- interface MarkerIcon {
533
- /**
534
- * Content-derived identity for adapter-wide icon reuse: equal ids must mean
535
- * identical SVG. Include anything that changes the drawing (symbol, color, label).
536
- */
537
- resourceId: string;
538
- /** Self-contained SVG markup. Producing safe content is the host's responsibility. */
539
- svg: string;
540
- width: number;
541
- height: number;
542
- /** Point placed at `Marker.position` (e.g. a pin's tip); rotation and scale pivot here. */
543
- anchor: MarkerAnchor;
544
- }
545
- interface MarkerRender extends MarkerIcon {
546
- /** False when the capability did not recognize `symbolId` and a placeholder is shown. */
547
- available: boolean;
548
- }
549
- interface MarkerCapability {
550
- /** Return `undefined` for an unknown `symbolId`; TacticalDraw renders a placeholder. */
551
- render(marker: Marker): MarkerIcon | undefined;
552
- /** Monotonic host-owned revision; bump it when icon resolution changes. */
553
- readonly generation?: number;
554
- }
555
- /**
556
- * One `MarkerCapability` from several, such as a badge catalog and the host's
557
- * own icons: each marker gets the icon of the first capability that recognises
558
- * its symbol id. `generation` is the sum of the parts' generations, so it still
559
- * increases when any part bumps its own.
560
- */
561
- declare function composeMarkerCapabilities(...capabilities: readonly MarkerCapability[]): MarkerCapability;
562
- declare function isMarker(graphic: unknown): graphic is Marker;
563
- declare function cloneMarker(marker: Marker): Marker;
564
- declare function markerOpacity(marker: Marker): number;
565
- declare function validateMarker(marker: Marker): void;
566
- declare function normalizeMarker(marker: Marker): Marker;
567
- //#endregion
568
581
  //#region src/note-graphic.d.ts
569
582
  /**
570
583
  * The Note graphic kind (ADR-0066): a framed box of Markdown content pinned to
@@ -752,11 +765,20 @@ declare function noteOpacity(note: NoteGraphic): number;
752
765
  declare function validateNoteGraphic(note: NoteGraphic): void;
753
766
  //#endregion
754
767
  //#region src/graphic.d.ts
755
- type Graphic = ControlMeasure | PointSymbol | ImageGraphic | Marker | NoteGraphic;
756
- type GraphicRender = ControlMeasureRender | PointSymbolRender | ImageRender | MarkerRender | NoteRender;
768
+ type Graphic = ControlMeasure | PointSymbol | ImageGraphic | Marker | NoteGraphic | Collocation;
769
+ type GraphicRender = ControlMeasureRender | PointSymbolRender | ImageRender | MarkerRender | NoteRender | CollocationRender;
757
770
  interface GraphicSnapshot<G extends Graphic = Graphic> {
758
771
  graphic: G;
759
- render: G extends PointSymbol ? PointSymbolRender : G extends ImageGraphic ? ImageRender : G extends Marker ? MarkerRender : G extends NoteGraphic ? NoteRender : ControlMeasureRender;
772
+ render: G extends PointSymbol ? PointSymbolRender : G extends ImageGraphic ? ImageRender : G extends Marker ? MarkerRender : G extends NoteGraphic ? NoteRender : G extends Collocation ? CollocationRender : ControlMeasureRender;
773
+ /**
774
+ * What a transform session's commit changed in a collocation since the
775
+ * session took it up (#764), in the shape a collocation edit step reports.
776
+ * Set only on a collocation's snapshot that a transform session commits
777
+ * (`onCommit`, `close()`, `setGraphics`' removed members, the `editMany`
778
+ * promise); absent everywhere else. Only the keys the transform changed are
779
+ * present, so a transform that changed nothing reports `{}`.
780
+ */
781
+ changes?: CollocationCommitChanges;
760
782
  }
761
783
  /**
762
784
  * A graphic whose identity is one geographic anchor + size + rotation,
@@ -765,10 +787,414 @@ interface GraphicSnapshot<G extends Graphic = Graphic> {
765
787
  */
766
788
  type AnchoredGraphic = PointSymbol | ImageGraphic | Marker | NoteGraphic;
767
789
  declare function isAnchoredGraphic(graphic: Graphic): graphic is AnchoredGraphic;
790
+ /**
791
+ * A graphic that is a control measure: neither an anchored graphic (point
792
+ * symbol, image, Marker) nor a collocation.
793
+ */
794
+ declare function isControlMeasureGraphic(graphic: Graphic): graphic is ControlMeasure;
768
795
  /** A graphic that can take view-owned pin presentation (ADR-0056): a point symbol or marker. */
769
796
  type PinnableGraphic = PointSymbol | Marker;
770
797
  declare function isPinnableGraphic(graphic: Graphic): graphic is PinnableGraphic;
771
798
  //#endregion
799
+ //#region src/collocation-transform.d.ts
800
+ /**
801
+ * A ground move handed to {@link ResolveCollocationTransform} (ADR-0063,
802
+ * "Gestures and pick result"). A location-handle drag passes `rotation: 0`
803
+ * and `scale: 1`; a group transform passes its box's rotation and scale.
804
+ */
805
+ interface CollocationTransform {
806
+ /** Where the move takes a lon/lat position. */
807
+ map(position: Position): Position;
808
+ /** Clockwise screen rotation in radians. */
809
+ rotation: number;
810
+ /** Uniform scale factor. */
811
+ scale: number;
812
+ /**
813
+ * The size the collocation's members were drawn at when the gesture began:
814
+ * its `size`, or the capability default when it has none
815
+ * (`resolveCollocationSize`). A scale applies to this.
816
+ */
817
+ size: PointSymbolSize;
818
+ /**
819
+ * Present for a partial collocation target: the ids of the collocation
820
+ * members the move applies to. Absent for the whole collocation.
821
+ */
822
+ members?: readonly string[];
823
+ }
824
+ /**
825
+ * The host's rule for what a ground move changes in a collocation: pure and
826
+ * synchronous. The engine calls it on every preview move and once at commit,
827
+ * always with the collocation as it stood when the gesture began.
828
+ */
829
+ type ResolveCollocationTransform = (collocation: Collocation, transform: CollocationTransform) => Collocation;
830
+ /**
831
+ * The default {@link ResolveCollocationTransform} (ADR-0063, #629 §7–8).
832
+ *
833
+ * For the whole collocation: `map` moves `position` if given, otherwise every
834
+ * positioned member; ground part placements are mapped, screen-relative ones
835
+ * rotated by `rotation` and multiplied by `scale`, a Bracket's `via` bend
836
+ * with them; a scale other than 1 sets
837
+ * `size` to `transform.size` times `scale`, with the point-symbol size floor.
838
+ * Members' set-aside `size`, `offset` and `rotation` are untouched and parts
839
+ * stay upright.
840
+ *
841
+ * For a partial target (`members` given): only the listed members that have a
842
+ * position move; `position`, `size` and part placements stay, so a derived
843
+ * location follows. Never modifies its input.
844
+ */
845
+ declare function transformCollocation(collocation: Collocation, transform: CollocationTransform): Collocation;
846
+ /**
847
+ * Some of a collocation's members taken into a group transform alongside
848
+ * other graphics (ADR-0063). Only those members' positions move;
849
+ * members without a position are dropped from the target.
850
+ */
851
+ interface PartialCollocationTarget {
852
+ graphic: Collocation;
853
+ /** Member ids, unique within the collocation. */
854
+ members: readonly string[];
855
+ }
856
+ /** What `editMany` and `TransformSession.setGraphics` accept for each member. */
857
+ type TransformTarget = Graphic | PartialCollocationTarget;
858
+ declare function isPartialCollocationTarget(target: unknown): target is PartialCollocationTarget;
859
+ //#endregion
860
+ //#region src/collocation-layout.d.ts
861
+ /** Staff–Bracket clearance, CSS px at collocation scale 1 (fixed, #634). */
862
+ declare const COLLOCATION_CLEARANCE = 12;
863
+ /**
864
+ * Default `bracket.padding` everywhere but the spine side, where it follows
865
+ * `bracket.cap`: CSS px at collocation scale 1. Also the Staff plate's padding.
866
+ */
867
+ declare const COLLOCATION_BRACKET_OVERHANG = 4;
868
+ /** How much wider than the line its halo is by default, CSS px at collocation scale 1. */
869
+ declare const COLLOCATION_HALO_EXTRA = 3;
870
+ type LocationMark = "ring" | "dot" | "cross";
871
+ type MemberMark = "dot" | "cross";
872
+ /** A part plate with its defaults filled in, shown or not. */
873
+ interface ResolvedCollocationPlate {
874
+ show: boolean;
875
+ fillColor: string;
876
+ fillOpacity: number;
877
+ /** `strokeWidth` in px at scale 1. */
878
+ border: {
879
+ show: boolean;
880
+ strokeColor: string;
881
+ strokeWidth: number;
882
+ };
883
+ }
884
+ /** A line's stroke with its defaults filled in; widths and dashes in px at scale 1. */
885
+ interface ResolvedCollocationStroke {
886
+ strokeColor: string;
887
+ strokeWidth: number;
888
+ strokeDash: number[];
889
+ }
890
+ /** {@link CollocationOptions} with every default filled in and out-of-range numbers replaced. */
891
+ interface ResolvedCollocationOptions {
892
+ parts: "role" | CollocationPart;
893
+ locate: "bounds-center" | "centroid" | "first";
894
+ gap: {
895
+ x: number;
896
+ y: number;
897
+ };
898
+ staff: {
899
+ tail: number; /** Px at scale 1, or `"frame"`: the lowest flag's frame stroke. */
900
+ strokeWidth: number | "frame"; /** A color, or `"frame"`: the lowest flag's frame color. */
901
+ strokeColor: string;
902
+ plate: ResolvedCollocationPlate;
903
+ };
904
+ bracket: {
905
+ defaultOffset: PixelCoordinate;
906
+ columns: number;
907
+ align: "left" | "center";
908
+ cap: number;
909
+ tick: number;
910
+ shape: CollocationBracketShape;
911
+ side: CollocationBracketSide;
912
+ attach: "middle" | "top";
913
+ plate: ResolvedCollocationPlate;
914
+ /**
915
+ * Each axis as set, or `null` unset: then the spine side follows `cap`
916
+ * and the other sides are {@link COLLOCATION_BRACKET_OVERHANG}.
917
+ */
918
+ padding: {
919
+ x: number | null;
920
+ y: number | null;
921
+ };
922
+ };
923
+ line: {
924
+ strokeColor: string;
925
+ strokeWidth: number; /** `strokeWidth`: px wider than each line it backs, at scale 1. */
926
+ halo: {
927
+ show: boolean;
928
+ strokeColor: string;
929
+ strokeWidth: number;
930
+ };
931
+ };
932
+ leader: ResolvedCollocationStroke & {
933
+ show: boolean;
934
+ };
935
+ ground: {
936
+ /** `"auto"`: none where a Staff foot or leader ends at the location, else a ring. */location: {
937
+ mark: LocationMark | "auto" | "none";
938
+ color: string;
939
+ size: number;
940
+ };
941
+ memberPositions: {
942
+ mark: MemberMark | "none";
943
+ color: string;
944
+ size: number;
945
+ }; /** The location and member position marks shrink with the collocation scale. */
946
+ scaleMarks: boolean;
947
+ ties: ResolvedCollocationStroke & {
948
+ show: boolean;
949
+ };
950
+ spread: {
951
+ shape: "none" | "hull" | "concave" | "circle" | "box";
952
+ padding: number;
953
+ style: CollocationSpreadStyle;
954
+ };
955
+ };
956
+ }
957
+ /** Resolved spread-area style; `fillOpacity` defaults to 0.1, whatever `fillColor` is. */
958
+ interface CollocationSpreadStyle extends CollocationAreaStyle {
959
+ strokeColor: string;
960
+ strokeWidth: number;
961
+ strokeDash: number[];
962
+ fillColor: string;
963
+ fillOpacity: number;
964
+ }
965
+ /** Fill every {@link CollocationOptions} default (ADR-0063, #634). */
966
+ declare function resolveCollocationOptions(options?: CollocationOptions): ResolvedCollocationOptions;
967
+ /**
968
+ * The collocation scale (#633): the share of full size of the collocation's
969
+ * size ({@link resolveCollocationSize}). 1 when it is screen-sized or has no
970
+ * `maxPixels`, else `max(value / resolution, minPixels) / maxPixels`, capped
971
+ * at 1. Every member is drawn at that size, so they all shrink alike.
972
+ */
973
+ /**
974
+ * A part's in-image strokes drawn in the leader style, as polylines in the
975
+ * layout's px. A leader that ends where the tick starts comes back joined to
976
+ * it as one polyline (location → tick root → spine), so the bend is a true
977
+ * join and its dashes run on through it. Without `withLeader` (a leader drawn
978
+ * elsewhere), only the tick.
979
+ */
980
+ declare function collocationLeaderStrokes(part: Pick<CollocationPartLayout, "tick" | "leader">, withLeader?: boolean): PixelCoordinate[][];
981
+ declare function collocationScale(size: PointSymbolSize, resolution: number | undefined): number;
982
+ /** One member placed in its part. Pixel geometry is CSS px relative to the part's anchor point, y down. */
983
+ interface CollocationMemberLayout {
984
+ memberId: string;
985
+ part: CollocationPart;
986
+ render: ResolvedCollocationMemberRender;
987
+ highlight: boolean;
988
+ /** Display px per canonical unit: the member's effective size over its size reference. */
989
+ iconScale: number;
990
+ /** Where the icon's top-left (canonical 0, 0) is drawn. */
991
+ topLeft: PixelCoordinate;
992
+ /**
993
+ * The seam's `iconOffset` (ADR-0063, #639) for a member icon resource
994
+ * anchored at its top-left [0, 0], placed at the part's anchor point. In
995
+ * canonical resource units; for a resource anchored at canonical (ax, ay),
996
+ * add (ax, ay).
997
+ */
998
+ iconOffset: [number, number];
999
+ box: PointSymbolRect;
1000
+ extent: PointSymbolRect;
1001
+ registration: PixelCoordinate;
1002
+ attachment: PixelCoordinate;
1003
+ /** Engine-drawn Highlight casing around the box, when the capability can't draw Highlight. */
1004
+ highlightCasing?: PointSymbolRect;
1005
+ }
1006
+ /** One part (Staff or Bracket) laid out for one resolution. */
1007
+ interface CollocationPartLayout {
1008
+ part: CollocationPart;
1009
+ /**
1010
+ * `"default"`: at its default spot. `"screen-relative"` / `"ground"`: from
1011
+ * its part placement.
1012
+ */
1013
+ mode: "default" | "screen-relative" | "ground";
1014
+ /** The ground point the part image and member icons are anchored at. */
1015
+ anchor: Position;
1016
+ /** CSS px from the anchor point to the part's registration (tick root or staff foot). */
1017
+ offset: PixelCoordinate;
1018
+ /**
1019
+ * CSS px from the anchor point to the point a screen-relative placement of
1020
+ * the part holds, which an editor turns into one: its registration, except
1021
+ * for an auto Bracket, where it is the members' middle (a ground placement
1022
+ * always holds the registration, {@link offset}). A screen-relative placement written from
1023
+ * it for an auto Bracket must record `side` (see
1024
+ * {@link CollocationBracketPlacement}), which marks it as holding that
1025
+ * middle; without `side` a placement holds the tick root.
1026
+ */
1027
+ placedAt: PixelCoordinate;
1028
+ /**
1029
+ * CSS px a screen-relative Bracket placement was moved sideways to keep the
1030
+ * Bracket clear of a Staff standing on the location, as its default spot
1031
+ * is. Absent when it wasn't moved. An editor adds it (over the collocation
1032
+ * scale) to the placement's offset, so what it stores is what is drawn.
1033
+ */
1034
+ staffClearance?: PixelCoordinate;
1035
+ /**
1036
+ * The side an auto Bracket stands on now (`bracket.side: "auto"` only).
1037
+ * Record it as the Bracket placement's `side`: the layout keeps a recorded
1038
+ * side, and a part drag turns it ({@link autoBracketSide}).
1039
+ */
1040
+ side?: "left" | "top" | "bottom";
1041
+ /** Part line work as polylines, CSS px relative to the anchor point. */
1042
+ lines: PixelCoordinate[][];
1043
+ /** Width of {@link lines}: scaled, floored at 1 px. */
1044
+ lineWidth: number;
1045
+ /**
1046
+ * Width of {@link lines} in px at collocation scale 1, before flooring:
1047
+ * `line.strokeWidth` for the Bracket; `staff.strokeWidth` for the Staff, resolved to the
1048
+ * lowest flag's frame stroke for `"frame"`.
1049
+ */
1050
+ baseLineWidth: number;
1051
+ /**
1052
+ * Color of {@link lines}: `line.strokeColor` for the Bracket; `staff.strokeColor` for
1053
+ * the Staff, resolved to the lowest flag's frame color for `"frame"`.
1054
+ */
1055
+ lineColor: string;
1056
+ /**
1057
+ * The Bracket's tick, registration → spine, CSS px relative to the anchor:
1058
+ * part of the part image like {@link lines}, but stroked in the leader style
1059
+ * ({@link leaderWidth}, {@link leaderDash}, `leader.strokeColor`) since it carries
1060
+ * the leader into the Bracket. Absent while leaders are hidden.
1061
+ */
1062
+ tick?: PixelCoordinate[];
1063
+ /**
1064
+ * Where a leader drawn as a separate line meets the tick: a ground
1065
+ * placement's tick root, CSS px relative to the anchor. The ground leader
1066
+ * and the in-image tick can't be one stroke, so the part image fills the
1067
+ * corner with a round joint, the leader's width across.
1068
+ */
1069
+ joint?: PixelCoordinate;
1070
+ /**
1071
+ * The part's plate (`staff.plate`, `bracket.plate`) while shown: closed
1072
+ * rings, CSS px relative to the anchor, filled beneath the line work, with
1073
+ * its border's width scaled and floored at 1 px. Never hit area.
1074
+ */
1075
+ plate?: {
1076
+ rings: PixelCoordinate[][];
1077
+ fillColor: string;
1078
+ fillOpacity: number;
1079
+ border?: {
1080
+ strokeColor: string;
1081
+ strokeWidth: number;
1082
+ };
1083
+ };
1084
+ /**
1085
+ * In-image leader, location → registration, CSS px: for a screen-relative
1086
+ * placement (through its `via` bend when it has one), and for a part at its
1087
+ * default spot off the location.
1088
+ */
1089
+ leader?: PixelCoordinate[];
1090
+ /** Width of the in-image leader and tick: `leader.strokeWidth` scaled, floored at 1 px. */
1091
+ leaderWidth: number;
1092
+ /** Dash pattern of the in-image leader and tick, scaled like its width; `[]` is solid. */
1093
+ leaderDash: number[];
1094
+ /**
1095
+ * With `line.halo` shown: px the halo is wider than each line it backs
1096
+ * (`line.halo.strokeWidth`, scaled), so a line's halo is `lineWidth +
1097
+ * haloExtra` and the leader's `leaderWidth + haloExtra`.
1098
+ */
1099
+ haloExtra?: number;
1100
+ /** With `line.halo` shown: its color. */
1101
+ haloColor?: string;
1102
+ /** Members in host order. */
1103
+ members: CollocationMemberLayout[];
1104
+ /** Bounds of the line work, tick and leader, stroke and halo included, CSS px relative to the anchor. */
1105
+ lineBounds?: PointSymbolRect;
1106
+ /** Pick shapes, CSS px relative to the anchor; ground marks are never hit area. */
1107
+ pick: {
1108
+ members: {
1109
+ memberId: string;
1110
+ rect: PointSymbolRect;
1111
+ }[]; /** Line work, tick and in-image leader; hit within the caller's tolerance plus half `lineWidth`. */
1112
+ lines: PixelCoordinate[][];
1113
+ };
1114
+ }
1115
+ interface CollocationGroundMark<M extends string> {
1116
+ position: Position;
1117
+ mark: M;
1118
+ color: string;
1119
+ /**
1120
+ * Diameter in CSS px, shrinking with the collocation scale unless
1121
+ * `ground.scaleMarks` is `false`.
1122
+ */
1123
+ size: number;
1124
+ /** Stroke width of rings and crosses: `line.strokeWidth`, scaled like {@link size}. */
1125
+ strokeWidth: number;
1126
+ /**
1127
+ * The mark's shape in CSS px around `position`, y down: for a ring (stroked,
1128
+ * white-filled) or a dot (filled) one closed circle whose first point is not
1129
+ * repeated, for a cross two strokes forming an upright `+`.
1130
+ */
1131
+ paths: PixelCoordinate[][];
1132
+ }
1133
+ /** Ground features, each in its fixed draw order bottom to top (spread, ties, marks, leaders, location). */
1134
+ interface CollocationGroundLayout {
1135
+ /** Closed lon/lat ring, or undefined when there is none. */
1136
+ spread?: {
1137
+ ring: Position[];
1138
+ style: CollocationSpreadStyle;
1139
+ };
1140
+ ties: {
1141
+ memberId: string;
1142
+ coordinates: [Position, Position];
1143
+ color: string;
1144
+ width: number;
1145
+ dash: number[]; /** Drawn because the member is highlighted; draw in the Highlight appearance. */
1146
+ highlight: boolean;
1147
+ }[];
1148
+ memberPositions: (CollocationGroundMark<MemberMark> & {
1149
+ memberId: string;
1150
+ highlight: boolean;
1151
+ })[];
1152
+ leaders: {
1153
+ part: CollocationPart; /** Location → registration, through a Bracket placement's `via` bend when it has one. */
1154
+ coordinates: Position[];
1155
+ color: string; /** Unscaled line width, CSS px. */
1156
+ width: number; /** Unscaled dash pattern, CSS px; `[]` is solid. */
1157
+ dash: number[];
1158
+ /**
1159
+ * With `line.halo` shown: px the halo is wider than the leader
1160
+ * (`line.halo.strokeWidth`, unscaled like the leader), so its halo is
1161
+ * `width + haloExtra`.
1162
+ */
1163
+ haloExtra?: number; /** With `line.halo` shown: its color. */
1164
+ haloColor?: string;
1165
+ }[];
1166
+ location?: CollocationGroundMark<LocationMark>;
1167
+ }
1168
+ /** The output of {@link layoutCollocation}. */
1169
+ interface CollocationLayout {
1170
+ /** Undefined when the collocation has no location: nothing is drawn or picked. */
1171
+ location?: Position;
1172
+ scale: number;
1173
+ options: ResolvedCollocationOptions;
1174
+ parts: {
1175
+ staff?: CollocationPartLayout;
1176
+ bracket?: CollocationPartLayout;
1177
+ };
1178
+ ground: CollocationGroundLayout;
1179
+ }
1180
+ /**
1181
+ * The shared collocation layout (ADR-0063, #641): turns a
1182
+ * {@link CollocationRender} into each part's pixel geometry, pick shapes and
1183
+ * member placement, plus the ground marks and spread area, for one
1184
+ * resolution (Web Mercator m/px, the same the members size with).
1185
+ *
1186
+ * Pure: rendering, CPU picking and the map sheet all call it, and adapters
1187
+ * never lay out. Parts are screen-upright; all pixel geometry is CSS px at
1188
+ * the part's `anchor` point, y down. Ground output is lon/lat.
1189
+ */
1190
+ declare function layoutCollocation(collocationRender: CollocationRender, resolution: number | undefined): CollocationLayout;
1191
+ /**
1192
+ * {@link layoutCollocation} of the collocation's {@link buildCollocationRender}
1193
+ * snapshot: the whole pipeline at one resolution, for callers that keep
1194
+ * neither.
1195
+ */
1196
+ declare function buildCollocationLayout(collocation: Collocation, capabilities: CollocationMemberCapabilities, resolution: number | undefined, options?: BuildCollocationRenderOptions): CollocationLayout;
1197
+ //#endregion
772
1198
  //#region src/tactical-draw/abort.d.ts
773
1199
  /**
774
1200
  * AbortPlumbing for the TacticalDraw façade.
@@ -818,57 +1244,53 @@ interface CombinedAbort {
818
1244
  */
819
1245
  declare function combineWithHostSignal(hostSignal?: AbortSignal): CombinedAbort;
820
1246
  //#endregion
821
- //#region src/tactical-draw/measure-options.d.ts
822
- declare const DEFAULT_LABEL_SIZE_PIXELS = 14;
823
- /**
824
- * Where a control measure's size is anchored (ADR-0020). `ground` (the
825
- * default) means a meter size fixed to the terrain — static, never re-rendered
826
- * on zoom. `screen` means a pixel size held constant on screen — re-rendered
827
- * against the live `metersPerPixel` on every view change. A draw/edit drawn in
828
- * pixels resolves (`bakes`) to a `ground` anchor on commit unless the caller
829
- * asks to stay `screen`. Edits of uniformly sized symbols retain their authored
830
- * unit by default (ADR-0052).
831
- */
832
- type SizeAnchor = "ground" | "screen";
833
- /**
834
- * Whether `kind` has at least one size that can be restored to its normal
835
- * pixel-authored appearance at the given resolution. Kept inside
836
- * tactical-draw using the core metadata catalog so hosts never need to
837
- * infer option names or special-case captured labels.
838
- *
839
- * `scale` only needs `getResolution()` (Web Mercator meters per CSS pixel), so
840
- * a host without a live map can pass a fixed one:
841
- * `canResetGroundSizes(measure, { getResolution: () => resolution })`.
842
- */
843
- declare function canResetGroundSizes(measure: Pick<ControlMeasure, "kind">, scale: Pick<MapAdapter, "getResolution">): boolean;
844
- /**
845
- * Return the complete option record produced by resetting every known size
846
- * pair to its default on-screen appearance at the given resolution. Pixel
847
- * keys are removed and meter keys are written, so the result remains
848
- * ground-anchored. A pair that inherits another pair's size is cleared so it
849
- * follows again. Unrelated options are preserved. This is the rule
850
- * `EditSession.resetGroundSizes()` applies; hosts resetting graphics outside
851
- * an edit session call it directly, passing a fixed resolution such as
852
- * `{ getResolution: () => resolution }`.
853
- *
854
- * A pair's default is its own `defaultValue` when its `defaultUnit` is `"px"`,
855
- * else the kind's default pixel option.
856
- *
857
- * Returns options for any kind with size pairs, even when nothing changes;
858
- * compare with the input (e.g. structurally) to detect a no-op. Returns
859
- * `undefined` when the kind has no resettable sizes or the resolution is not
860
- * usable.
861
- */
862
- declare function resetGroundSizeOptions(measure: Pick<ControlMeasure, "kind" | "options">, scale: Pick<MapAdapter, "getResolution">): ControlMeasure["options"] | undefined;
1247
+ //#region src/point-symbol-offset.d.ts
1248
+ /** Read-only layout needs forward projection only. Coordinates are CSS pixels. */
1249
+ type PointSymbolProjection = Pick<MapAdapter, "getPixelFromCoordinate" | "getBearing" | "getResolution">;
1250
+ /** Editing may also require inverse projection (notably ground placement). */
1251
+ type PointSymbolView = Pick<MapAdapter, "getPixelFromCoordinate" | "getCoordinateFromPixel" | "getBearing" | "getResolution">;
1252
+ interface PointSymbolOffsetLayout {
1253
+ /** Selected ordinary or detached body render, with canonical SVG dimensions. */
1254
+ render: PointSymbolRender;
1255
+ /** Selected body resource; dimensions and anchor remain in canonical SVG units. */
1256
+ resource: IconResource;
1257
+ /** Body opacity after applying the overall multiplier. */
1258
+ bodyOpacity: number;
1259
+ /** Clockwise radians in the projection plane. */
1260
+ rotation: number;
1261
+ actual: PixelCoordinate;
1262
+ /** Body registration, including natural HQ displacement in ordinary placement. */
1263
+ display: PixelCoordinate;
1264
+ /** Coordinate at which the chosen image's resource anchor is painted. */
1265
+ imageAnchor: PixelCoordinate;
1266
+ ordinaryDisplay: PixelCoordinate;
1267
+ attachment?: PixelCoordinate;
1268
+ junction?: PixelCoordinate;
1269
+ direction?: PixelCoordinate;
1270
+ path: PixelCoordinate[];
1271
+ kind: "ordinary" | "direct" | "indicator-only" | "with-extension";
1272
+ status: "ok" | "unsupported-presentation";
1273
+ scale: number;
1274
+ /** Resolved connector styling in CSS pixels. */
1275
+ connectorStyle: Required<PointSymbolOffsetStyle>;
1276
+ }
1277
+ /** Pure layout: projection input/output is in CSS pixels, including document contexts. */
1278
+ declare function resolvePointSymbolOffset(symbol: PointSymbol, render: PointSymbolRender, view: PointSymbolProjection): PointSymbolOffsetLayout | null;
1279
+ /** Set body placement without changing the authoritative coordinate. */
1280
+ declare function placePointSymbol(symbol: PointSymbol, render: PointSymbolRender, view: PointSymbolView, display: PixelCoordinate, mode?: PointSymbolPlacement["mode"]): PointSymbol;
1281
+ declare function convertPointSymbolPlacement(symbol: PointSymbol, render: PointSymbolRender, view: PointSymbolView, mode: PointSymbolPlacement["mode"]): PointSymbol;
1282
+ /** Explicit alignment, also used with hysteresis by pointer editing. */
1283
+ declare function alignPointSymbolIndicator(symbol: PointSymbol, render: PointSymbolRender, view: PointSymbolView): PointSymbol;
1284
+ declare function movePointSymbolLocation(symbol: PointSymbol, render: PointSymbolRender, view: PointSymbolView, position: Position): PointSymbol;
1285
+ /** Canonical resource metadata shared by native adapters and external exporters. */
1286
+ declare function pointSymbolResource(render: PointSymbolRender): IconResource;
863
1287
  /**
864
- * The [[SizeAnchor]] a measure currently encodes (ADR-0020): `screen` when it
865
- * carries its kind's pixel-denominated size option, `ground` otherwise. Keys off
866
- * the same metadata size pairs as the bake, so a consumer deciding how to
867
- * re-edit a graphic never has to re-derive the per-kind pixel-option knowledge
868
- * (e.g. via a fragile key-name heuristic). Accepts the minimal `{ kind, options }`
869
- * shape, mirroring [[measureUsesAdapterResolution]].
1288
+ * Convert a resolved CSS-pixel layout to output units (e.g. 25.4 / 96 for mm).
1289
+ * Scales positions, body scale, line width and dashes together, including the
1290
+ * already-resolved offset and padding. Canonical resources, direction, rotation
1291
+ * and opacity stay unchanged. Does not mutate the input or authored symbol.
870
1292
  */
871
- declare function getSizeAnchor(measure: Pick<ControlMeasure, "kind" | "options">): SizeAnchor;
1293
+ declare function scalePointSymbolLayout(layout: PointSymbolOffsetLayout, factor: number): PointSymbolOffsetLayout;
872
1294
  //#endregion
873
1295
  //#region src/tactical-draw/handles.d.ts
874
1296
  /**
@@ -915,10 +1337,17 @@ interface InteractionStyle {
915
1337
  rotateHandle?: HandleStyle;
916
1338
  /** A Note's left and right edge-midpoint grips that change its width (ADR-0066). */
917
1339
  widthHandle?: HandleStyle;
1340
+ /**
1341
+ * A hollow ring around a collocation's location mark while it is edited
1342
+ * (ADR-0063): the mark is the grip, so the ring shows it can be dragged
1343
+ * without covering it. `pointRadius` is a minimum; the ring grows to clear
1344
+ * a larger mark. Without a location mark, `vertexHandle` is drawn instead.
1345
+ */
1346
+ locationRingHandle?: HandleStyle;
918
1347
  boxOutline?: GuideStyle;
919
1348
  /**
920
1349
  * Line style for the passive, non-interactive selection highlight rendered
921
- * by {@link TacticalDraw.setHighlightedGraphics}. A dashed, muted variant of
1350
+ * by {@link TacticalDraw.setPassiveOutlines}. A dashed, muted variant of
922
1351
  * `boxOutline` so a locked/highlighted selection reads as visually distinct
923
1352
  * from an active edit's oriented transform box. Delivered per-feature via
924
1353
  * `properties.style` on the highlight outline `LineString`, resolved through
@@ -945,7 +1374,19 @@ interface InteractionStyle {
945
1374
  * remove) but no midpoints or box, and the edit controller deletes the tapped
946
1375
  * vertex instead of dragging it.
947
1376
  */
948
- type EditMode = "reshape" | "transform" | "labeldrag" | "delete" | "offset";
1377
+ type EditMode = "reshape" | "transform" | "labeldrag" | "delete" | "offset" /** Collocations only: the location handle (ADR-0063). */ | "location" /** Collocations only: part drags (ADR-0063). */ | "parts" /** Collocations only, opt-in: drag a positioned collocation member's ground position. */ | "member-positions" /** Collocations only, opt-in: a grip on the Bracket's far edge that sets `bracket.columns` (#758). */ | "columns" /** Collocations only, opt-in: a corner on the Bracket that sets the collocation's `size` (#758). */ | "size"
1378
+ /**
1379
+ * Collocations only, opt-in: a grip where the leader meets the Bracket's
1380
+ * tick that bends the leader along the tick's line, writing the Bracket
1381
+ * placement's `via`.
1382
+ */
1383
+ | "bend"
1384
+ /**
1385
+ * Collocations only, opt-in: drag a member's image to rearrange
1386
+ * the members or move it to the other part, or off the stack to hand its
1387
+ * removal to the host (#759).
1388
+ */
1389
+ | "rearrange";
949
1390
  //#endregion
950
1391
  //#region src/tactical-draw/session-events.d.ts
951
1392
  /** A gesture's phase within a stream of {@link TransientChangeEvent}s. */
@@ -987,7 +1428,13 @@ interface TransientChangeEvent {
987
1428
  type SettleReason = "close" | "error" | TacticalDrawAbortReason;
988
1429
  //#endregion
989
1430
  //#region src/tactical-draw/session-history.d.ts
990
- type SessionChangeSource = "gesture" | "undo" | "redo" | "programmatic";
1431
+ /**
1432
+ * Why a session's working graphic changed. A collocation edit reports its
1433
+ * gestures as `"part-drag"`, `"location-move"`, `"member-drag"`,
1434
+ * `"columns-drag"`, `"size-drag"`, `"bend-drag"` and `"reorder-drag"`
1435
+ * (ADR-0063) instead of `"gesture"`.
1436
+ */
1437
+ type SessionChangeSource = "gesture" | "undo" | "redo" | "programmatic" | "part-drag" | "location-move" | "member-drag" | "columns-drag" | "size-drag" | "bend-drag" | "reorder-drag";
991
1438
  interface SessionHistoryState {
992
1439
  readonly canUndo: boolean;
993
1440
  readonly canRedo: boolean;
@@ -1002,202 +1449,900 @@ interface SessionHistory {
1002
1449
  subscribe(listener: (state: SessionHistoryState) => void): () => void;
1003
1450
  }
1004
1451
  //#endregion
1005
- //#region src/tactical-draw/edit-session.d.ts
1006
- /**
1007
- * Surface delivered via `td.edit(measure, opts).onSession` and synchronously
1008
- * available from `td.activeSession` while the edit is live.
1009
- *
1010
- * `measure` is the immutable edit-start input. `controlPoints` is live working
1011
- * state. After the session settles (`close` / `abort`), every method is a
1012
- * silent no-op (except [[onSettled]] — late registration still delivers,
1013
- * asynchronously).
1014
- */
1015
- interface EditSession {
1016
- /** Undo/redo for completed mutations within this live session. */
1452
+ //#region src/tactical-draw/graphic-edit-session.d.ts
1453
+ interface PointSymbolOffsetControls {
1454
+ readonly layout: PointSymbolOffsetLayout | null;
1455
+ readonly connectors: readonly PointSymbolConnector[];
1456
+ setPlacement(mode: PointSymbolPlacement["mode"]): void;
1457
+ setConnector(connector: PointSymbolConnector): void;
1458
+ align(): void;
1459
+ reset(): void;
1460
+ }
1461
+ interface GraphicEditChangeEvent<G extends Graphic = Graphic> {
1462
+ readonly source: SessionChangeSource;
1463
+ readonly graphic: GraphicSnapshot<G>;
1464
+ readonly previous: GraphicSnapshot<G>;
1465
+ readonly session: GraphicEditSession<G>;
1466
+ reject(): void;
1467
+ close(): void;
1468
+ abort(): void;
1469
+ }
1470
+ /** Common selection/editing contract shared by control measures and point symbols. */
1471
+ interface GraphicEditSession<G extends Graphic = Graphic> {
1017
1472
  readonly history: SessionHistory;
1473
+ /** Present on point-symbol sessions; all commands participate in session history. */
1474
+ readonly offset?: PointSymbolOffsetControls;
1018
1475
  /** Immutable edit-start input. */
1019
- readonly graphic: ControlMeasure;
1020
- /**
1021
- * Live complete working graphic. Copy on read. `properties` (host-owned
1022
- * metadata, e.g. `standardIdentity`/`colorMode`) is session-owned like every
1023
- * other working field: it starts at the edit-start value, is replaced
1024
- * wholesale by [[updateGraphic]], survives every subsequent gesture/setter
1025
- * call and in-session undo/redo, and is rolled back by `event.reject()`
1026
- * (issue #354). Absent when the edit-start measure carried none and
1027
- * [[updateGraphic]] has not set any since.
1028
- */
1029
- readonly workingGraphic: ControlMeasure;
1030
- /** Live working state. Copy on read. */
1031
- readonly controlPoints: readonly Position[];
1032
- /** Live working options. Copy on read. */
1033
- readonly options: ControlMeasure["options"];
1034
- /** Live working style. Copy on read. */
1035
- readonly style: ControlMeasureStyle | undefined;
1036
- /**
1037
- * Live working text amplifiers (MIL-STD-2525E Appendix L Table L-II). Copy
1038
- * on read. `undefined` when the edit-start measure carried none and none
1039
- * have been set since. Keys are stored as given — canonicalisation to
1040
- * doctrinal field codes happens in the core render seam, not here.
1041
- */
1042
- readonly textAmplifiers: TextAmplifiers | undefined;
1043
- /** Live user-adjusted anchors for individually rendered text amplifiers. */
1044
- readonly amplifierPlacements: AmplifierPlacements | undefined;
1045
- /** `true` after the first working-copy mutation; back to `false` within tolerance. */
1476
+ readonly graphic: G;
1477
+ /** Live working graphic. Copy on read. */
1478
+ readonly workingGraphic: G;
1046
1479
  readonly dirty: boolean;
1047
1480
  readonly modes: readonly EditMode[];
1481
+ close(): GraphicSnapshot<G> | undefined;
1482
+ abort(): void;
1483
+ setModes(modes: readonly EditMode[]): void;
1484
+ /** Atomically replace any part of the live working graphic. */
1485
+ updateGraphic(updater: (graphic: G) => G): void;
1486
+ onChange(listener: (event: GraphicEditChangeEvent<G>) => void): () => void;
1487
+ onCommit(handler: (snapshot: GraphicSnapshot<G>) => void): () => void;
1488
+ onSettled(handler: (reason: SettleReason) => void): () => void;
1048
1489
  /**
1049
- * Whether reshape mode shows the measure's detail handles: fine-adjustment
1050
- * option handles such as the per-vertex width grips on arrow shafts.
1051
- * Initialised from `EditOptions.detailHandles` and mutated by
1052
- * [[setDetailHandles]].
1053
- */
1054
- readonly detailHandles: boolean;
1055
- /**
1056
- * The primary sub-selected part of a graphic whose definition divides it
1057
- * into parts (`ControlMeasureTopology.partOf`), e.g. the index of the Flow
1058
- * Arrow's selected flow (ADR-0065): the part most recently added to
1059
- * [[selectedParts]]. Hosts read it to edit the part's own settings. Starts
1060
- * at `0`; pressing a point or midpoint, or clicking the graphic's body,
1061
- * selects the part under the pointer alone, and an edit or undo that removes
1062
- * the selected part falls back to `0`. Dragging a point or midpoint of a part
1063
- * that is already selected keeps the selection; a click on it without a drag
1064
- * selects it alone. `undefined` for graphics without parts.
1490
+ * Present on point-symbol sessions: the continuous stream of a drag, for a
1491
+ * host that follows the symbol while it moves (a range ring, a viewshed).
1492
+ * `start` fires on the first move of a gesture, `move` on each one after,
1493
+ * and `end` exactly once per started gesture, before that gesture's
1494
+ * [[onChange]], or when the session settles mid-gesture. `points` holds the
1495
+ * one live position; `pointIndex` is `null`. A body, location or pin drag
1496
+ * moves it; a rotate or scale streams it unchanged. Returns an unsubscribe
1497
+ * function; registering after the session has settled returns a no-op.
1065
1498
  */
1066
- readonly selectedPart: number | undefined;
1499
+ onTransientChange?(listener: (event: TransientChangeEvent) => void): () => void;
1500
+ }
1501
+ //#endregion
1502
+ //#region src/tactical-draw/snapping.d.ts
1503
+ type SnapInteraction = "draw" | "reshape" | "translate" | "label-drag";
1504
+ interface SnapCandidateRequest {
1505
+ coordinate: Position;
1506
+ pixel: PixelCoordinate;
1507
+ interaction: SnapInteraction;
1508
+ graphicId?: string;
1067
1509
  /**
1068
- * Every sub-selected part, [[selectedPart]] included, ascending. Reshape
1069
- * mode shows the option grips of each. Never empty while the graphic has
1070
- * parts; empty for graphics without parts. An edit or undo drops parts the
1071
- * graphic no longer has (promoting the primary if it went), and when the
1072
- * part count changes the set collapses to its primary, since parts are
1073
- * indices and the ones after a removed part shift.
1510
+ * Every graphic a multi-selection moves together; candidates of any of them
1511
+ * are skipped, so the group never snaps onto itself. Set instead of `graphicId`.
1074
1512
  */
1075
- readonly selectedParts: readonly number[];
1513
+ graphicIds?: readonly string[];
1514
+ controlPointIndex?: number;
1515
+ originalEvent?: unknown;
1516
+ }
1517
+ interface SnapCandidate {
1518
+ id: string;
1519
+ coordinate: Position;
1520
+ kind: string;
1521
+ graphicId?: string;
1522
+ controlPointIndex?: number;
1523
+ priority?: number;
1524
+ }
1525
+ /**
1526
+ * Host snap candidates near `request`. A provider that leaves out the moving
1527
+ * graphic's own candidates should check `request.graphicIds` (a multi-selection)
1528
+ * as well as `request.graphicId`. A move or scale that tests several
1529
+ * points of a graphic (a control measure's control points, a Note's or an
1530
+ * Image's corners and centre) asks once per tested point on each pointer move,
1531
+ * so keep it cheap: return only candidates near `request.pixel`.
1532
+ */
1533
+ type SnapCandidateProvider = (request: SnapCandidateRequest) => readonly SnapCandidate[];
1534
+ /**
1535
+ * A snap the host answers later, such as one to terrain it has to sample
1536
+ * first. Asked on every reshape and translate move of a control-measure edit,
1537
+ * at the position the other sources snapped it to (for a translate, the moved
1538
+ * first control point). Return `null` to have no say in this move, and the
1539
+ * drag follows the pointer at once; otherwise the drag holds where it was
1540
+ * until the promise settles, then lands at the position it resolves to, or at
1541
+ * the pointer for `null`. An answer lands unless a later move's landed first,
1542
+ * so a drag keeps up while answers are slow. A release waits for the answer
1543
+ * to where it was let go before committing, so the gesture is still one
1544
+ * change. `signal` aborts once the drag is over or the edit settles.
1545
+ *
1546
+ * The host decides how far it reaches: neither `enabled` nor
1547
+ * `tolerancePixels` applies. `bypass` does.
1548
+ */
1549
+ type DeferredSnapProvider = (request: SnapCandidateRequest, signal: AbortSignal) => Promise<Position | null> | null;
1550
+ interface SnapResult {
1551
+ coordinate: Position;
1552
+ pixel: PixelCoordinate;
1553
+ candidate: SnapCandidate;
1554
+ distancePixels: number;
1555
+ }
1556
+ interface GraphicGeometrySnappingOptions {
1557
+ /** Snap to the nearest point along generated linework and polygon boundaries. Default `true`. */
1558
+ edges?: boolean;
1559
+ /** Snap to generated geometry vertices. Default `false`. */
1560
+ vertices?: boolean;
1561
+ }
1562
+ interface SnappingOptions {
1563
+ enabled?: boolean;
1564
+ tolerancePixels?: number;
1565
+ sources?: {
1566
+ graphics?: boolean;
1567
+ /**
1568
+ * Snap to generated control-measure geometry. `true` enables edges with
1569
+ * vertices disabled; pass an object to select either candidate type.
1570
+ * Text/label point features and the active graphic are excluded.
1571
+ */
1572
+ graphicGeometry?: boolean | GraphicGeometrySnappingOptions;
1573
+ external?: SnapCandidateProvider;
1574
+ deferred?: DeferredSnapProvider;
1575
+ };
1576
+ bypass?: (originalEvent: unknown) => boolean;
1577
+ /** Called for each resolution attempt; `null` clears a host-rendered indicator. */
1578
+ onSnap?: (result: SnapResult | null) => void;
1579
+ }
1580
+ /** The closest of several snap tests: the request that won, and its snap. */
1581
+ interface ClosestSnap {
1582
+ request: SnapCandidateRequest;
1583
+ result: SnapResult;
1584
+ }
1585
+ /** Internal controller seam supplied by the TacticalDraw façade. */
1586
+ interface SnapResolver {
1587
+ /** Snap one point, reporting the result through `onSnap`. */
1588
+ (request: SnapCandidateRequest): SnapResult | null;
1076
1589
  /**
1077
- * Live size anchor for the measure under edit (ADR-0020). `"ground"` bakes a
1078
- * pixel size to meters on commit; `"screen"` keeps it zoom-aware. Initialised
1079
- * from `EditOptions.sizeAnchor` and mutated by [[setSizeAnchor]].
1590
+ * Test several points of one graphic, such as a box's corners and centre,
1591
+ * and report only the closest snap through `onSnap`, so the host's
1592
+ * indicator shows the winner rather than whichever point was tested last.
1593
+ * With `cursor`, the snap whose target is nearest the cursor wins, so the
1594
+ * part of the graphic being dragged near snaps before a far one; without it,
1595
+ * the shortest snap does. Points snapping to the same target, equally near
1596
+ * the cursor, go to the shortest snap; other ties to the earlier request.
1080
1597
  */
1081
- readonly sizeAnchor: SizeAnchor;
1598
+ closest(requests: readonly SnapCandidateRequest[], cursor?: PixelCoordinate): ClosestSnap | null;
1599
+ }
1600
+ //#endregion
1601
+ //#region src/tactical-draw/collocation-edit-controller.d.ts
1602
+ /**
1603
+ * Part commands on a collocation edit session (ADR-0063), mirroring
1604
+ * `session.offset` on point symbols. Both take part in session history.
1605
+ */
1606
+ interface CollocationPartControls {
1607
+ /**
1608
+ * Hold `part` as a ground or screen-relative part placement without moving
1609
+ * it on screen. A no-op for a part with no members or a collocation with no
1610
+ * location.
1611
+ */
1612
+ setPlacement(part: CollocationPart, mode: PointSymbolPlacement["mode"]): void;
1613
+ /** Return `part` to its default spot. No collocation member moves. */
1614
+ reset(part: CollocationPart): void;
1615
+ }
1616
+ /**
1617
+ * One tick of a collocation location move (#755) or member drag. `points`
1618
+ * holds the live location and `pointIndex` is `null`, as for a point symbol;
1619
+ * `members` holds each positioned member's live position, so a host can keep
1620
+ * per-member analyses following the drag.
1621
+ */
1622
+ interface CollocationTransientChangeEvent extends TransientChangeEvent {
1623
+ readonly members: readonly {
1624
+ readonly memberId: string;
1625
+ readonly position: Position;
1626
+ }[];
1627
+ }
1628
+ /** A collocation edit step: the change source, its history label and what it changed. */
1629
+ interface CollocationCommit {
1630
+ source: SessionChangeSource;
1631
+ /** The step's history label, as `history.state.undoLabel` shows it. */
1632
+ label: string;
1633
+ changes: CollocationCommitChanges;
1634
+ }
1635
+ /**
1636
+ * A collocation edit's change event. `commit` says what the step changed
1637
+ * relative to `previous`; for an undo or redo, what that step changed back
1638
+ * or again, under the undone or redone step's label.
1639
+ */
1640
+ interface CollocationEditChangeEvent extends GraphicEditChangeEvent<Collocation> {
1641
+ readonly commit: CollocationCommit;
1642
+ readonly session: CollocationEditSession;
1643
+ }
1644
+ /** The session of a single collocation edit. */
1645
+ interface CollocationEditSession extends GraphicEditSession<Collocation> {
1646
+ readonly parts: CollocationPartControls;
1647
+ onChange(listener: (event: CollocationEditChangeEvent) => void): () => void;
1648
+ /**
1649
+ * The continuous stream of a location move or member drag: `start` on its
1650
+ * first move, `move` on each one after, and `end` exactly once per started
1651
+ * move, before its `onChange`, or when the session settles mid-move. Part
1652
+ * drags move no member and don't stream. Returns an unsubscribe function; registering
1653
+ * after the session has settled returns a no-op.
1654
+ */
1655
+ onTransientChange(listener: (event: CollocationTransientChangeEvent) => void): () => void;
1656
+ /** How a dragged part is stored: `EditOptions.partDrag`, or the last {@link setPartDrag}. */
1657
+ readonly partDrag: CollocationPartDrag;
1658
+ /** Change how parts dragged from now on are stored; a no-op once settled. */
1659
+ setPartDrag(partDrag: CollocationPartDrag): void;
1660
+ }
1661
+ interface CollocationEditControllerOptions {
1662
+ adapter: MapAdapter;
1663
+ capabilities: CollocationMemberCapabilities;
1664
+ collocation: Collocation;
1665
+ graphicsLayer: LayerId;
1666
+ previewLayer: LayerId;
1667
+ handlesLayer: LayerId;
1668
+ signal?: AbortSignal;
1669
+ closeOnClickAway?: boolean;
1670
+ modes?: readonly EditMode[];
1671
+ interactionStyle?: InteractionStyle;
1672
+ onSession?: (session: CollocationEditSession) => void;
1673
+ handleIdPrefix: string;
1674
+ settleToGraphics: (collocation?: Collocation) => void;
1675
+ publishWorkingGraphic: (group: FeatureGroup) => void;
1676
+ wasOnGraphicsLayer: boolean;
1677
+ onSettled?: () => void;
1678
+ onClickAwayGraphicsPick?: (event: PickEvent) => void;
1679
+ /** The façade's live Highlight appearance. */
1680
+ highlight: () => HighlightAppearance | undefined;
1681
+ /** The host's ground-move rule (`transformCollocation` by default). */
1682
+ resolveTransform: ResolveCollocationTransform;
1683
+ snap?: SnapResolver;
1684
+ deferredSnap?: DeferredSnapProvider;
1685
+ /** Called after every repaint of the working collocation, previews included. */
1686
+ onRepaint?: () => void;
1687
+ /**
1688
+ * The host's removal of a member a `"rearrange"` drag dropped well clear of
1689
+ * both parts (#759). Without it such a drop changes nothing.
1690
+ */
1691
+ onRemoveMember?: (memberId: string) => void;
1692
+ /** How a dragged part is stored; default `"keep"`. */
1693
+ partDrag?: CollocationPartDrag;
1694
+ /** `EditOptions.screenRelativeReach`; default {@link COLLOCATION_SCREEN_RELATIVE_REACH}. */
1695
+ screenRelativeReach?: number;
1696
+ }
1697
+ interface CollocationEditHandle {
1698
+ readonly promise: Promise<GraphicSnapshot<Collocation>>;
1699
+ readonly settled: boolean;
1700
+ readonly usesGraphicStack: boolean;
1701
+ readonly measureId: string;
1702
+ readonly graphicKind: "collocation";
1703
+ /** The live working collocation, previews included. Copy on read. */
1704
+ readonly workingGraphic: Collocation;
1705
+ refreshPresentation(): void;
1706
+ abort(reason: TacticalDrawAbortReason, cause?: unknown): void;
1707
+ syncHostMembership(present: boolean): void;
1082
1708
  /**
1083
- * Whether this ground-anchored measure has one or more sizes that can be
1084
- * restored at the adapter's current resolution.
1709
+ * Whether a pick on the edited collocation still reaches the host: a click
1710
+ * on a member or part (#629 §2), unless this pointer cycle was a drag.
1085
1711
  */
1086
- readonly canResetGroundSizes: boolean;
1712
+ passesPick(event: PickEvent): boolean;
1713
+ /** The layout of the last repaint, previews included; `null` before the first. */
1714
+ readonly layout: CollocationLayout | null;
1715
+ }
1716
+ /** Whether an active edit handle is a collocation edit. */
1717
+ declare function isCollocationEditHandle(handle: object | null): handle is CollocationEditHandle;
1718
+ /**
1719
+ * Default `["location", "parts"]`; `"member-positions"`, `"columns"`,
1720
+ * `"size"`, `"bend"` and `"rearrange"` are opt-in and `[]` locks everything.
1721
+ * Any other mode throws.
1722
+ */
1723
+ declare function normaliseCollocationModes(input?: readonly EditMode[]): readonly EditMode[];
1724
+ /**
1725
+ * A single collocation edit (ADR-0063, "Gestures and pick result"): part
1726
+ * drags (a plain drag on a member, a part's lines or its leader), a
1727
+ * location handle and, opt-in, a handle on each positioned member's ground
1728
+ * position. No transform box. A location move runs the host's
1729
+ * `resolveTransform` on every preview move and at commit, then rewrites each
1730
+ * part's placement so its registration keeps its screen position.
1731
+ */
1732
+ declare function runCollocationEdit(opts: CollocationEditControllerOptions): CollocationEditHandle;
1733
+ //#endregion
1734
+ //#region src/tactical-draw/transform-box.d.ts
1735
+ /**
1736
+ * The Excalidraw/Felt-style transform box: the oriented bounding box drawn
1737
+ * around a selection, with 4 corner scale handles, a rotate grip above the
1738
+ * top edge, and drag-anywhere-inside-the-box translate. This module is the
1739
+ * single source of truth for box *placement* (`fitTransformBox`,
1740
+ * `boxCorners`, `rotateGripPixel`) AND box *picking* (`pointInBox`,
1741
+ * `pickBoxHandle`) — mirroring the ADR-0016 discipline that keeps
1742
+ * `handles.ts` owning vertex/midpoint placement/pick. Everything here is pure
1743
+ * pixel-space math: no projection, no rendering, no session state.
1744
+ *
1745
+ * **Angle convention**: `angle` is in radians, measured in screen pixel space
1746
+ * (y grows downward). A positive angle rotates the box clockwise as drawn on
1747
+ * screen — the same convention `rotatePointsAround` (`handle-drag.ts`) uses,
1748
+ * so box rotation and control-point rotation stay in lockstep.
1749
+ *
1750
+ * **Corner ordering**: `boxCorners` always returns
1751
+ * `[topLeft, topRight, bottomRight, bottomLeft]` in the box's own (unrotated)
1752
+ * local frame, then rotated into place. "Top" means the smaller-y edge before
1753
+ * rotation — i.e. the edge the rotate grip floats above. The order is stable
1754
+ * across calls so a scale handle's `index` (0–3) always means the same
1755
+ * corner, and its opposite corner is always `(index + 2) % 4`.
1756
+ */
1757
+ interface TransformBox {
1758
+ /** Box center, pixel space. */
1759
+ center: PixelCoordinate;
1760
+ /** Half-width along the box's local x-axis (pre-rotation), in pixels. */
1761
+ halfWidth: number;
1762
+ /** Half-height along the box's local y-axis (pre-rotation), in pixels. */
1763
+ halfHeight: number;
1764
+ /** Radians, screen space, positive = clockwise on screen. */
1765
+ angle: number;
1766
+ }
1767
+ //#endregion
1768
+ //#region src/tactical-draw/collocation-rendering.d.ts
1769
+ interface CollocationGroupRender {
1770
+ features: Feature[];
1771
+ iconResources: IconResource[];
1772
+ /** The input snapshot the group was drawn from. */
1773
+ render: CollocationRender;
1774
+ layout: CollocationLayout;
1775
+ }
1776
+ /**
1777
+ * Draw a collocation as the contents of one atomic feature group (ADR-0063,
1778
+ * "The MapAdapter seam"), in canonical order: ground marks and ground leaders
1779
+ * (never hit area), one SVG line-work image per part, then each member as an
1780
+ * icon placed through the seam's icon pixel offset. Every pixel measure comes
1781
+ * from the shared layout; nothing here reads the camera beyond `resolution`.
1782
+ *
1783
+ * Zoom changes numbers, not images (ADR-0063 amendments): part line work is
1784
+ * drawn at collocation scale 1 and shown at the collocation scale through the
1785
+ * feature's `iconScale`, and member icons keep their resources, so a
1786
+ * resolution re-render of a ground-sized collocation mints no new image. When
1787
+ * its size has a `maxPixels` cap, every icon feature also carries the native
1788
+ * ground-size fields, so an engine that scales ground-sized point symbols
1789
+ * natively tracks zoom animations itself.
1790
+ */
1791
+ declare function renderCollocationGroup(collocation: Collocation, capabilities: CollocationMemberCapabilities, options: {
1792
+ resolution: number | undefined;
1793
+ highlight?: HighlightAppearance;
1794
+ /**
1795
+ * While a part or the location is dragged: draw screen-relative leaders as
1796
+ * ground lines through the current view instead of baking them into the
1797
+ * part image, so the images (and their resources) hold still mid-drag.
1798
+ */
1799
+ liveLeaders?: LiveLeaderView;
1800
+ /**
1801
+ * A member laid out but not drawn, image or Highlight casing: its slot
1802
+ * stays empty, as while it is dragged to rearrange the collocation (#759)
1803
+ * or several are dropped into it (#760). Its ground position mark and tie
1804
+ * still draw.
1805
+ */
1806
+ hiddenMembers?: readonly string[];
1807
+ }): CollocationGroupRender;
1808
+ /** The view a live leader is drawn through. */
1809
+ interface LiveLeaderView {
1810
+ toPixel(position: Position): PixelCoordinate | null;
1811
+ fromPixel(pixel: PixelCoordinate): Position | null;
1812
+ }
1813
+ /** The pick result a collocation feature reports, read from its properties. */
1814
+ declare function collocationPickTarget(feature: Feature): {
1815
+ part: CollocationPart;
1816
+ memberId?: string;
1817
+ } | undefined;
1818
+ /**
1819
+ * One collocation member's outline (ADR-0063): a screen-aligned box around
1820
+ * its extent in its part, padded by `padding`, and a ring at its ground
1821
+ * position, each a `LineString` in `style` with `properties` added. Drawn by
1822
+ * passive member outlines and by an edit's member link. `[]` while the member
1823
+ * isn't drawn or its box doesn't project; the ring is left out when the
1824
+ * member has no position or the ring doesn't project.
1825
+ */
1826
+ declare function collocationMemberOutlineFeatures(collocation: Collocation, layout: CollocationLayout, memberId: string, view: {
1827
+ toPixel: (position: Position) => PixelCoordinate | null;
1828
+ fromPixel: (pixel: PixelCoordinate) => Position | null | undefined;
1829
+ }, options: {
1830
+ featureId: string;
1831
+ padding: number;
1832
+ style?: GuideStyle;
1833
+ properties?: Record<string, unknown>;
1834
+ }): Feature[];
1835
+ /**
1836
+ * The screen pixels a laid-out collocation covers: each part's line work and
1837
+ * member extents, and its ground marks, ties, leaders and spread area. Fits
1838
+ * transform boxes and passive outlines around the whole collocation.
1839
+ */
1840
+ declare function collocationFootprintPixels(layout: CollocationLayout, toPixel: (position: Position) => PixelCoordinate | null): PixelCoordinate[];
1841
+ /** A screen rectangle of a collocation footprint: upright, so `box.angle` is 0. */
1842
+ interface CollocationFootprintRect {
1843
+ box: TransformBox;
1844
+ corners: PixelCoordinate[];
1845
+ }
1846
+ /**
1847
+ * Where a collocation is on screen (#755), in the box-and-corners shape of
1848
+ * `pointSymbolFootprint` and the other footprints. Parts stay upright, so
1849
+ * every box has `angle` 0.
1850
+ */
1851
+ interface CollocationFootprint extends CollocationFootprintRect {
1852
+ /** The location on screen. */
1853
+ location: PixelCoordinate;
1854
+ /** Each part's line work, leader and members. */
1855
+ parts: (CollocationFootprintRect & {
1856
+ part: CollocationPart;
1857
+ })[];
1858
+ /** Each drawn member's extent, labels included: the area a click picks it by. */
1859
+ members: (CollocationFootprintRect & {
1860
+ memberId: string;
1861
+ part: CollocationPart;
1862
+ })[];
1863
+ }
1864
+ /**
1865
+ * A collocation's screen footprint for host hit tests (marquee, lasso,
1866
+ * context menus, fit to selection): the location, a rectangle per part and
1867
+ * per drawn member, and the box around everything it draws, ground marks
1868
+ * included. Pass the capabilities TacticalDraw was given, so members lay out
1869
+ * as they are drawn. `null` when the collocation has no location or its
1870
+ * location doesn't project.
1871
+ */
1872
+ declare function collocationFootprint(collocation: Collocation, capabilities: CollocationMemberCapabilities, view: PointSymbolProjection, options?: BuildCollocationRenderOptions): CollocationFootprint | null;
1873
+ //#endregion
1874
+ //#region src/collocation-reorder.d.ts
1875
+ /**
1876
+ * Where a member dragged to rearrange the collocation (#759) lands: `index`
1877
+ * counts the other members of `part`, in host order, that it goes before.
1878
+ */
1879
+ interface CollocationDropSlot {
1880
+ part: CollocationPart;
1881
+ index: number;
1882
+ }
1883
+ /** A drop slot, or the removal cue of a member dragged well clear of both parts. */
1884
+ type CollocationDropTarget = CollocationDropSlot | {
1885
+ remove: true;
1886
+ };
1887
+ /**
1888
+ * CSS px a dragged member must be from every part's members before its drop
1889
+ * reads as a removal.
1890
+ */
1891
+ declare const COLLOCATION_REMOVE_DISTANCE = 48;
1892
+ interface CollocationDropTargetOptions {
1087
1893
  /**
1088
- * Commit: returns the `GraphicSnapshot<ControlMeasure>` of the current working state
1089
- * and resolves the outer `edit` promise with the same value (the same
1090
- * reference — no double-bake of ground-anchored sizes). Returns `undefined`
1091
- * after the session has settled (idempotent no-op).
1894
+ * Px from both parts at which a drop reads as a removal; default
1895
+ * {@link COLLOCATION_REMOVE_DISTANCE}. `Infinity` never removes: the nearest
1896
+ * slot is taken however far away the pointer is.
1092
1897
  */
1093
- close(): GraphicSnapshot<ControlMeasure> | undefined;
1094
- /** Reject the outer `edit` promise with reason `"session"`. */
1095
- abort(): void;
1898
+ removeDistance?: number;
1899
+ }
1900
+ /**
1901
+ * Where a member dragged to `pixel` lands (#759), read from `layout` as it
1902
+ * was drawn before the drag, so the answer never feeds back on itself.
1903
+ *
1904
+ * The nearest part's members (the Bracket's on a tie: it draws on top) take
1905
+ * it; within that part, it goes beside the member whose middle is nearest,
1906
+ * before or after it by the axis the members run along: across for a
1907
+ * Bracket grid of more than one column (filled in reading order whichever
1908
+ * side it stands on), else down. Farther than `removeDistance` from every
1909
+ * part, it is `{ remove: true }`.
1910
+ *
1911
+ * `memberId` need not be laid out: a symbol dropped into the collocation from
1912
+ * outside (#760) aims the same way, and its slot counts every member of the
1913
+ * part. Farther than `removeDistance` from every part, such a drop has no
1914
+ * target: `null`, as for a collocation with no member laid out.
1915
+ */
1916
+ declare function collocationDropTarget(layout: CollocationLayout, memberId: string, pixel: PixelCoordinate, toPixel: (position: Position) => PixelCoordinate | null, options?: CollocationDropTargetOptions): CollocationDropTarget | null;
1917
+ /**
1918
+ * `collocation` with `memberId` moved to `slot` (#759): the member goes
1919
+ * before the slot's member of that part in `members`, or right after the
1920
+ * part's last one (staying where it is when the part has no other member).
1921
+ * A member that changes part gets `part` set, or cleared when the new part is
1922
+ * the one it would get anyway (from its role and `options.parts`); one that
1923
+ * stays in its part keeps its `part` as it is.
1924
+ */
1925
+ declare function moveCollocationMember(collocation: Collocation, memberId: string, slot: CollocationDropSlot, capabilities?: CollocationMemberCapabilities): Collocation;
1926
+ /**
1927
+ * `collocation` with `members` joined at `slot` (#760), in the order given:
1928
+ * before the slot's member of that part in `members`, or right after the
1929
+ * part's last one (at the end when the part has none). Each joining member
1930
+ * gets `part` set when the slot's part isn't the one it would get anyway
1931
+ * (from its role and `options.parts`), and cleared when it is. A member whose
1932
+ * id is already in the collocation, or earlier in `members`, is left out.
1933
+ */
1934
+ declare function insertCollocationMembers(collocation: Collocation, members: readonly CollocationMember[], slot: CollocationDropSlot, capabilities?: CollocationMemberCapabilities): Collocation;
1935
+ //#endregion
1936
+ //#region src/tactical-draw/offset-drop.d.ts
1937
+ /** Where an offset drag released over a collocation drops its symbols (#760). */
1938
+ interface OffsetDrop {
1939
+ /** The collocation they join. */
1940
+ targetId: string;
1941
+ /** Where in it they go; see {@link insertCollocationMembers}. */
1942
+ slot: CollocationDropSlot;
1943
+ /** The dragged symbols' ids, in the order they join. */
1944
+ memberIds: string[];
1945
+ }
1946
+ /**
1947
+ * A host's drop of point symbols into a collocation with an offset drag
1948
+ * (#760), on a point-symbol edit or a group transform of point symbols and
1949
+ * Markers. While the pointer is over a collocation `targetAt` returns, the
1950
+ * drag previews the symbols joined at the slot under the pointer, in place of
1951
+ * that collocation; on release there, `commit` is called instead of the
1952
+ * offset change or `offsetDrag.commit`. The engine changes no membership and
1953
+ * records no step of the session's own: the host owns which symbols make up a
1954
+ * collocation. Away from every target the drag does what it does without it.
1955
+ */
1956
+ interface OffsetDropHandler {
1957
+ /**
1958
+ * The collocation a drop at `pixel` would join, or null. The host refuses
1959
+ * here what it won't join: another Layer, a locked collocation, one that
1960
+ * already holds a dragged symbol. Member ids are only unique within a
1961
+ * collocation, so the engine can't tell that last one by id: a dragged
1962
+ * symbol whose id a member already uses is previewed under another, and
1963
+ * the host's commit decides what id it joins with.
1964
+ *
1965
+ * The target is laid out once and reused while `targetAt` keeps returning
1966
+ * it: the same object, or an equal copy with the same id. Return a new
1967
+ * object for a changed collocation; one changed in place mid-drag keeps the
1968
+ * layout it had, as the render cache does.
1969
+ */
1970
+ targetAt(pixel: PixelCoordinate): Collocation | null;
1971
+ commit(drop: OffsetDrop): void;
1972
+ }
1973
+ /** One offset drag's aim at drop targets: the preview to draw, and the drop it would make. */
1974
+ interface OffsetDropAim {
1975
+ /** Aim at `pixel`: the drop a release there makes, or null away from every target. */
1976
+ aim(pixel: PixelCoordinate): OffsetDrop | null;
1977
+ /** The last aim's preview: the target joined, ghosts and ties; null without a target. */
1978
+ readonly group: FeatureGroup | null;
1979
+ /** Stop aiming: the hidden target draws again. Safe to call twice. */
1980
+ end(): void;
1981
+ /** Hand `drop` to the host; call after {@link end} and after the members draw again. */
1982
+ commit(drop: OffsetDrop): void;
1983
+ }
1984
+ /** What the façade binds once per session; the controller adds the dragged members. */
1985
+ interface OffsetDropContext {
1986
+ handler: OffsetDropHandler;
1987
+ capabilities: CollocationMemberCapabilities;
1988
+ highlight?: () => HighlightAppearance | undefined;
1989
+ /** Draw nothing in a host graphic's slot until {@link revealGraphic}. */
1990
+ hideGraphic(id: string): void;
1991
+ revealGraphic(id: string): void;
1992
+ /** Style of the tie from a ghost to its symbol's ground position. */
1993
+ tieStyle?: GuideStyle;
1994
+ }
1995
+ interface OffsetDropView {
1996
+ toPixel(position: Position): PixelCoordinate | null;
1997
+ fromPixel(pixel: PixelCoordinate): Position;
1998
+ /** The map's resolution, read on every aim: a zoom mid-drag lays the target out afresh. */
1999
+ readonly resolution: number | undefined;
2000
+ /** The preview group's id, held for the whole drag so the layer doesn't rebuild per frame. */
2001
+ groupId: string;
2002
+ }
2003
+ /**
2004
+ * Aim an offset drag of `members` at the host's drop targets (#760). The
2005
+ * target's slot is read from its layout as drawn when the pointer reached it,
2006
+ * so the preview never feeds back on the aim, as a reorder drag's (#759).
2007
+ */
2008
+ declare function beginOffsetDrop(context: OffsetDropContext, members: readonly CollocationMemberGraphic[], view: OffsetDropView): OffsetDropAim;
2009
+ //#endregion
2010
+ //#region src/tactical-draw/collocation-support.d.ts
2011
+ /** Options for {@link createCollocationSupport}. */
2012
+ interface CollocationSupportOptions {
1096
2013
  /**
1097
- * Switch the active edit-mode set. `"reshape"` produces vertex/midpoint
1098
- * handles; `"transform"` renders the oriented selection box (corner scale
1099
- * handles, rotate grip, body translate — ADR-0017); `"delete"` is exclusive
1100
- * (vertex-tap removal) and collapses the set to delete-only. An unknown mode
1101
- * is rejected with `TypeError`.
2014
+ * What a ground move of a collocation changes (ADR-0063): a location-handle
2015
+ * drag and every group transform that carries a collocation. Pure and
2016
+ * synchronous; called on every preview move and once at commit with the
2017
+ * collocation as it stood when the gesture began. Defaults to
2018
+ * `transformCollocation`.
1102
2019
  */
1103
- setModes(modes: readonly EditMode[]): void;
2020
+ resolveTransform?: ResolveCollocationTransform;
2021
+ }
2022
+ /**
2023
+ * The collocation layout, rendering and editing code `TacticalDraw` reaches
2024
+ * for, bundled so it is opt-in and tree-shakable (ADR-0063). Create one with
2025
+ * {@link createCollocationSupport} and pass it as `TacticalDrawOptions.collocations`;
2026
+ * a host never calls its members. Without it, `TacticalDraw` throws
2027
+ * `CollocationSupportRequiredError` on a Collocation.
2028
+ *
2029
+ * @internal Every member is an implementation detail shared with `TacticalDraw`
2030
+ * and its group-transform controller. It may change without a major release.
2031
+ */
2032
+ interface CollocationSupport {
2033
+ /** @internal Draw a collocation's features, icons and layout. */
2034
+ renderGroup: typeof renderCollocationGroup;
2035
+ /** @internal Warn once about duplicate member ids and capability fallbacks. */
2036
+ warn(collocation: Collocation, capabilities: CollocationMemberCapabilities): void;
2037
+ /** @internal The layout a collocation draws with. */
2038
+ layout: typeof buildCollocationLayout;
2039
+ /** @internal The screen pixels a laid-out collocation covers. */
2040
+ footprintPixels: typeof collocationFootprintPixels;
2041
+ /** @internal The passive outline of one member. */
2042
+ memberOutlineFeatures: typeof collocationMemberOutlineFeatures;
2043
+ /** @internal The part and member a picked collocation feature reports. */
2044
+ pickTarget: typeof collocationPickTarget;
2045
+ /** @internal What live view state a collocation's render reads. */
2046
+ viewDependence(collocation: Collocation, capabilities: CollocationMemberCapabilities): "none" | "resolution";
2047
+ /** @internal The size every member is drawn at. */
2048
+ resolveSize: typeof resolveCollocationSize;
2049
+ /** @internal A collocation's render description. */
2050
+ buildRender: typeof buildCollocationRender;
2051
+ /** @internal What a ground move of a collocation changes. */
2052
+ resolveTransform: ResolveCollocationTransform;
2053
+ /** @internal Run a single collocation edit. */
2054
+ runEdit: typeof runCollocationEdit;
2055
+ /** @internal Whether an active edit handle is a collocation edit. */
2056
+ isEditHandle: typeof isCollocationEditHandle;
2057
+ /** @internal Validate and default a collocation edit's modes. */
2058
+ normaliseModes: typeof normaliseCollocationModes;
2059
+ /** @internal Aim an offset drag at the host's drop targets (#760). */
2060
+ beginOffsetDrop: typeof beginOffsetDrop;
2061
+ }
2062
+ /**
2063
+ * Opt in to Collocations (ADR-0063) for a `TacticalDraw` instance:
2064
+ * `new TacticalDraw(adapter, { collocations: createCollocationSupport() })`.
2065
+ * Hosts that never draw a collocation leave it out and their bundle drops the
2066
+ * collocation layout, rendering and editing code.
2067
+ */
2068
+ declare function createCollocationSupport(options?: CollocationSupportOptions): CollocationSupport;
2069
+ //#endregion
2070
+ //#region src/tactical-draw/measure-options.d.ts
2071
+ declare const DEFAULT_LABEL_SIZE_PIXELS = 14;
2072
+ /**
2073
+ * Where a control measure's size is anchored (ADR-0020). `ground` (the
2074
+ * default) means a meter size fixed to the terrain — static, never re-rendered
2075
+ * on zoom. `screen` means a pixel size held constant on screen — re-rendered
2076
+ * against the live `metersPerPixel` on every view change. A draw/edit drawn in
2077
+ * pixels resolves (`bakes`) to a `ground` anchor on commit unless the caller
2078
+ * asks to stay `screen`. Edits of uniformly sized symbols retain their authored
2079
+ * unit by default (ADR-0052).
2080
+ */
2081
+ type SizeAnchor = "ground" | "screen";
2082
+ /**
2083
+ * Whether `kind` has at least one size that can be restored to its normal
2084
+ * pixel-authored appearance at the given resolution. Kept inside
2085
+ * tactical-draw using the core metadata catalog so hosts never need to
2086
+ * infer option names or special-case captured labels.
2087
+ *
2088
+ * `scale` only needs `getResolution()` (Web Mercator meters per CSS pixel), so
2089
+ * a host without a live map can pass a fixed one:
2090
+ * `canResetGroundSizes(measure, { getResolution: () => resolution })`.
2091
+ */
2092
+ declare function canResetGroundSizes(measure: Pick<ControlMeasure, "kind">, scale: Pick<MapAdapter, "getResolution">): boolean;
2093
+ /**
2094
+ * Return the complete option record produced by resetting every known size
2095
+ * pair to its default on-screen appearance at the given resolution. Pixel
2096
+ * keys are removed and meter keys are written, so the result remains
2097
+ * ground-anchored. A pair that inherits another pair's size is cleared so it
2098
+ * follows again. Unrelated options are preserved. This is the rule
2099
+ * `EditSession.resetGroundSizes()` applies; hosts resetting graphics outside
2100
+ * an edit session call it directly, passing a fixed resolution such as
2101
+ * `{ getResolution: () => resolution }`.
2102
+ *
2103
+ * A pair's default is its own `defaultValue` when its `defaultUnit` is `"px"`,
2104
+ * else the kind's default pixel option.
2105
+ *
2106
+ * Returns options for any kind with size pairs, even when nothing changes;
2107
+ * compare with the input (e.g. structurally) to detect a no-op. Returns
2108
+ * `undefined` when the kind has no resettable sizes or the resolution is not
2109
+ * usable.
2110
+ */
2111
+ declare function resetGroundSizeOptions(measure: Pick<ControlMeasure, "kind" | "options">, scale: Pick<MapAdapter, "getResolution">): ControlMeasure["options"] | undefined;
2112
+ /**
2113
+ * The [[SizeAnchor]] a measure currently encodes (ADR-0020): `screen` when it
2114
+ * carries its kind's pixel-denominated size option, `ground` otherwise. Keys off
2115
+ * the same metadata size pairs as the bake, so a consumer deciding how to
2116
+ * re-edit a graphic never has to re-derive the per-kind pixel-option knowledge
2117
+ * (e.g. via a fragile key-name heuristic). Accepts the minimal `{ kind, options }`
2118
+ * shape, mirroring [[measureUsesAdapterResolution]].
2119
+ */
2120
+ declare function getSizeAnchor(measure: Pick<ControlMeasure, "kind" | "options">): SizeAnchor;
2121
+ //#endregion
2122
+ //#region src/tactical-draw/note-rendering.d.ts
2123
+ /**
2124
+ * One Note's contribution to its atomic FeatureGroup (ADR-0066, ADR-0069):
2125
+ * the note raster as an image overlay, then a transparent pick polygon over the full box.
2126
+ * While pending, the polygon becomes a grey placeholder and there is no overlay.
2127
+ * A fully faded Note has neither, so it can't be seen or picked.
2128
+ */
2129
+ interface NoteRenderPlan {
2130
+ features: Feature[];
2131
+ overlay?: ImageOverlayResource;
2132
+ render: NoteRender;
2133
+ }
2134
+ interface NoteFootprint {
2135
+ box: TransformBox;
2136
+ corners: PixelCoordinate[];
2137
+ }
2138
+ /**
2139
+ * Memo shared by every render of one `TacticalDraw`, so zooming within a
2140
+ * density step reuses the resolved raster without calling the capability, and
2141
+ * the 2048 px cap is sized from a Note's last known height.
2142
+ */
2143
+ interface NoteResolveCache {
2144
+ /** Last ready box height in em per Note id. */
2145
+ readonly heights: Map<string, number>;
2146
+ /** Last ready raster per Note snapshot, with the density it was requested at. */
2147
+ readonly rasters: WeakMap<NoteGraphic, {
2148
+ pxPerEm: number;
2149
+ raster: NoteRaster;
2150
+ }>;
2151
+ }
2152
+ /** Screen-space box of a Note, for highlights, edit boxes and marquee hit tests. */
2153
+ declare function noteFootprint(note: NoteGraphic, render: NoteRender, adapter: Pick<MapAdapter, "getBearing" | "getPixelFromCoordinate" | "getResolution">): NoteFootprint | null;
2154
+ /**
2155
+ * Resolve and render one Note. Validates the Note and the resolved raster first,
2156
+ * so a malformed Note or raster throws before any caller state changes.
2157
+ *
2158
+ * The density requested from the capability follows the view (ADR-0069): the
2159
+ * on-screen pixels per em, times the capability's pixel ratio, rounded up to a
2160
+ * power of two and capped so the raster's longest side stays within
2161
+ * {@link NOTE_MAX_RASTER_PIXELS}. The overlay fades over one step once an em
2162
+ * is smaller on screen than the fade threshold, or once the cap stretches it.
2163
+ */
2164
+ declare function renderNoteForAdapter(adapter: Pick<MapAdapter, "getResolution" | "fromLonLat" | "toLonLat">, capability: NoteCapability, note: NoteGraphic, cache?: NoteResolveCache): NoteRenderPlan;
2165
+ //#endregion
2166
+ //#region src/tactical-draw/transform-session.d.ts
2167
+ /**
2168
+ * Surface delivered via `td.editMany(graphics, opts).onSession` and
2169
+ * synchronously available from `td.activeTransformSession` while the group
2170
+ * transform is live. The group sibling of `EditSession` (`edit-session.ts`):
2171
+ * no reshape, no per-measure `setOptions`/`setStyle` — only the shared
2172
+ * transform box's corner-scale / rotate / body-translate gestures, applied to
2173
+ * every member at once. See the Phase 3 ("Multi-select") slice of ADR-0017.
2174
+ *
2175
+ * Typed on `Graphic` (ADR-0032): a member is either a `ControlMeasure` or a
2176
+ * point symbol, and the two coexist in one session. Hosts narrow with
2177
+ * `isPointSymbol`. `controlPointsFor` is a control-measure accessor and returns
2178
+ * `undefined` for a point-symbol id.
2179
+ *
2180
+ * The member set is mutable via [[setGraphics]] (#187): members can join or
2181
+ * leave a live session without a session boundary — point symbols exactly like
2182
+ * measures. Because membership changes over the session's lifetime, snapshot
2183
+ * arrays are keyed by **graphic id**, not by index — a snapshot's identity is
2184
+ * `snapshot.graphic.id`. `graphics` is a live view of the current members'
2185
+ * join-time inputs; a `TransformChangeEvent`'s arrays are index-aligned with
2186
+ * `session.graphics` *as of that emission*. After the session settles (`close`
2187
+ * / `abort` / an emptying `setGraphics`), every method is a silent no-op
2188
+ * (except [[onSettled]] — late registration still delivers, asynchronously).
2189
+ */
2190
+ interface TransformSession {
2191
+ /** Undo/redo for completed gestures within the current membership baseline. */
2192
+ readonly history: SessionHistory;
1104
2193
  /**
1105
- * Show or hide the detail handles (see [[detailHandles]]). View state only:
1106
- * no change event, no history entry. A silent no-op after settlement.
2194
+ * Live view of the current members' join-time input graphics — a fresh array
2195
+ * on each read, in current membership order. Grows/shrinks as [[setGraphics]]
2196
+ * adds or removes members. Not stable across membership changes: key
2197
+ * snapshots by `snapshot.graphic.id` rather than relying on index alignment.
1107
2198
  */
1108
- setDetailHandles(visible: boolean): void;
2199
+ readonly graphics: readonly Graphic[];
1109
2200
  /**
1110
- * Select `part` alone (see [[selectedPart]]), or with `extend` toggle it in
1111
- * or out of [[selectedParts]]: a part toggled in becomes primary; toggling
1112
- * the primary out promotes the most recently added remaining part; toggling
1113
- * out the last part is a no-op. View state only: no change event, no
1114
- * history entry. A no-op for a part the working graphic doesn't have, for
1115
- * graphics without parts, and after settlement.
2201
+ * Live view of the current members' working graphics — a fresh array on each
2202
+ * read, in current membership order, reflecting every gesture applied so far.
2203
+ * Measures carry their working control points (and any transform-frozen
2204
+ * options); point symbols carry their working position, size value, and
2205
+ * rotation. Copy on read.
1116
2206
  */
1117
- selectPart(part: number, opts?: {
1118
- extend?: boolean;
1119
- }): void;
2207
+ readonly workingGraphics: readonly Graphic[];
1120
2208
  /**
1121
- * Replace [[selectedParts]] (e.g. "All flows"), ignoring parts the graphic
1122
- * doesn't have. `primary`, when it is among them, becomes [[selectedPart]];
1123
- * otherwise the last listed part does. View state only, like
1124
- * [[selectPart]]; a no-op without a valid part.
2209
+ * Live working control points for the control-measure member whose id is
2210
+ * `graphicId`, or `undefined` when no such member carries that id — including
2211
+ * when `graphicId` names a point symbol (which has no control points; read
2212
+ * its working `position` from [[workingGraphics]] instead). Copy on read.
1125
2213
  */
1126
- selectParts(parts: readonly number[], primary?: number): void;
2214
+ controlPointsFor(graphicId: string): readonly Position[] | undefined;
2215
+ /** `true` when any member's working state differs from its edit-start input beyond tolerance. */
2216
+ readonly dirty: boolean;
1127
2217
  /**
1128
- * Subscribe to part selection changes, from the pointer, [[selectPart]],
1129
- * [[selectParts]] or the reconcile after an edit or undo. Called once per
1130
- * effective change with the primary and the full set; a call that changes
1131
- * neither doesn't notify. Returns an unsubscribe function; registering
1132
- * after settlement is a no-op.
2218
+ * Live size anchor, applied group-wide to the **control-measure** members
2219
+ * only (ADR-0020). `"ground"` bakes each measure's pixel size to meters on
2220
+ * commit; `"screen"` keeps it zoom-aware. A point symbol's persisted
2221
+ * pixel/meter size is its own anchor and is never rewritten by this setting.
2222
+ * Initialised from `EditManyOptions.sizeAnchor` and mutated by [[setSizeAnchor]].
1133
2223
  */
1134
- onPartSelect(listener: (part: number | undefined, parts: readonly number[]) => void): () => void;
1135
- /** Atomically replace the live working graphic while preserving id and kind. */
1136
- updateGraphic(updater: (graphic: ControlMeasure) => ControlMeasure): void;
1137
- /** Shallow-merge per-measure generator options into the live working copy. */
1138
- setOptions(partial: ControlMeasure["options"]): void;
2224
+ readonly sizeAnchor: SizeAnchor;
1139
2225
  /**
1140
- * Flip the size anchor (ADR-0020). Takes effect on the next emitted snapshot
1141
- * and on `close()`. A no-op for measures with no pixel-denominated size. The
1142
- * in-flight preview is unaffected (it renders from the working options), so a
1143
- * screen-locked symbol stays screen-locked until commit.
1144
- *
1145
- * `options` shallow-merges a size-option patch in the *same* mutation, as
1146
- * [[setOptions]] would. Changing a measure's size mode means moving its value
1147
- * between the pixel and meter halves of a size pair *and* re-anchoring, and
1148
- * the halves are only meaningful together: options carrying a pixel size
1149
- * under a `"ground"` anchor bake that size away on commit, so a host that
1150
- * emitted the two as separate mutations would leave an undo step parked on a
1151
- * state whose committed size mode contradicts its own options. Passed here
1152
- * they are one change event and one history entry, which undo cannot land
1153
- * inside.
2226
+ * Switch the group's size anchor (ADR-0020) for its control-measure members.
2227
+ * Takes effect on the next emitted snapshot and on `close()`. Point-symbol
2228
+ * members are unaffected.
1154
2229
  */
1155
- setSizeAnchor(anchor: SizeAnchor, options?: ControlMeasure["options"]): void;
2230
+ setSizeAnchor(anchor: SizeAnchor): void;
1156
2231
  /**
1157
- * Reset every geometry and label size to its default on-screen appearance at
1158
- * the current map resolution, persisted in meters. The measure stays
1159
- * ground-anchored and the reset is one undoable programmatic mutation.
1160
- * No-op when [[canResetGroundSizes]] is false or after settlement.
2232
+ * Whether each member is outlined inside the group box. Initialised from
2233
+ * `EditManyOptions.memberOutlines` (default `true`) and mutated by
2234
+ * [[setMemberOutlines]].
1161
2235
  */
1162
- resetGroundSizes(): void;
1163
- /** Shallow-merge per-measure style into the live working copy. */
1164
- setStyle(partial: ControlMeasureStyle): void;
2236
+ readonly memberOutlines: boolean;
1165
2237
  /**
1166
- * Shallow-merge into the live working text amplifiers. A value of
1167
- * `undefined` or an empty/whitespace-only string deletes that key; the
1168
- * working record collapses back to `undefined` once it holds no keys. A
1169
- * silent no-op after the session has settled (like [[setOptions]]).
2238
+ * Show or hide the per-member outlines inside the group box, leaving the box
2239
+ * and its handles as they are. A host turns them off when the members read
2240
+ * as one object (a group selected whole) rather than as separate picks.
1170
2241
  */
1171
- setTextAmplifiers(partial: Record<string, string | undefined>): void;
2242
+ setMemberOutlines(visible: boolean): void;
1172
2243
  /**
1173
- * Merge field-keyed label overrides (position and/or rotation). The merge is
1174
- * **field-wise per key**: a bare `Position` value means `{ position }`;
1175
- * fields absent from the incoming value (e.g. `rotation` when only
1176
- * `position` is supplied) are preserved from the existing entry; an
1177
- * explicit `undefined` value deletes the key entirely — a full reset to the
1178
- * doctrinal placement (both position and rotation).
2244
+ * Whether a press at `pixel` would grab the group box's body, and so start
2245
+ * a move (or, with the offset-drag key, the host's offset drag), rather
2246
+ * than a handle or nothing. Lets a host route a modifier press that it
2247
+ * would otherwise take for a map gesture, such as a lasso.
1179
2248
  */
1180
- setAmplifierPlacements(partial: Record<string, AmplifierPlacement | undefined>): void;
2249
+ bodyAt(pixel: PixelCoordinate): boolean;
1181
2250
  /**
1182
- * Subscribe to working-copy changes. The listener receives an
1183
- * [[EditChangeEvent]] for each completed gesture (drag end, insert/delete
1184
- * via handle) — never on rubber-band ticks. All currently-registered
1185
- * listeners receive the same event instance in registration order.
2251
+ * Replace the member set in place — the primitive behind shift-click toggle,
2252
+ * marquee replace, and single-edit → group folding, without tearing the
2253
+ * session down (#187). Members (measures and point symbols alike) are matched
2254
+ * to the current set by graphic id:
2255
+ *
2256
+ * - **Retained** members (id in both the current and next sets) carry their
2257
+ * current working state forward; the passed graphic object is ignored for
2258
+ * them. Their `dirty` baseline stays their original join-time input, so a
2259
+ * session that has already moved things stays dirty across the call.
2260
+ * - **Removed** members (id in the current set, absent from the next) are
2261
+ * committed at their current working state.
2262
+ * - **Added** members (id only in the next set) join at their passed input
2263
+ * state and use their host-provided Graphic-stack slot when present.
2264
+ *
2265
+ * The transform box re-derives from the next member set at the session's
2266
+ * current box angle. Session-scoped state (`sizeAnchor`, box angle,
2267
+ * non-geometry dirty) is unchanged.
2268
+ *
2269
+ * Calling this establishes a new session-history baseline: both undo and
2270
+ * redo are cleared after retained members carry their working state
2271
+ * forward. Membership changes and already-emitted exit snapshots are not
2272
+ * undoable within the live session.
2273
+ *
2274
+ * **Return value** — the committed exit snapshots of the members removed *by
2275
+ * this call*, built exactly like [[close]]'s snapshots (a measure's pixel
2276
+ * size baked to ground unless `sizeAnchor` is `"screen"`, a point symbol's
2277
+ * size left untouched, then cloned and rendered); an empty array when nothing
2278
+ * was removed. The outer `editMany` promise resolves with the snapshots of
2279
+ * the members in the set **at close time only**. Removed members are NOT
2280
+ * retained in its Graphic-stack slot until the host acknowledges it by
2281
+ * folding the returned snapshot into its document and calling `td.render()`,
2282
+ * the same contract as [[close]]. A removed member's exit snapshot is also
2283
+ * delivered through [[onCommit]] — the recommended channel, since it covers
2284
+ * this return value and the close-time promise resolution through a single
2285
+ * subscription.
2286
+ * Returns `undefined` (a silent no-op) after the session has settled.
2287
+ *
2288
+ * `setGraphics([])` on a live session delegates to [[close]]: it commits every
2289
+ * current member, resolves the promise with their snapshots, and returns that
2290
+ * same array. Duplicate ids in `graphics` throw `TypeError` synchronously,
2291
+ * without mutating session state. A point-symbol member entering a session
2292
+ * whose controller was created without a point-symbol capability throws
2293
+ * `PointSymbolCapabilityRequiredError` synchronously, also without mutating
2294
+ * session state.
2295
+ *
2296
+ * A collocation may join whole or as a partial collocation target
2297
+ * (`{ graphic, members }`, ADR-0063); a retained collocation takes the
2298
+ * member scope of the passed target.
2299
+ */
2300
+ setGraphics(graphics: readonly TransformTarget[]): GraphicSnapshot[] | undefined;
2301
+ /**
2302
+ * Commit: returns the members' `GraphicSnapshot[]` (the members in the set at
2303
+ * close time) and resolves the outer `editMany` promise with the same value
2304
+ * (the same reference — no double-bake of ground-anchored measure sizes). A
2305
+ * member removed mid-session via [[setGraphics]] is not included here; its exit
2306
+ * snapshot was returned from that `setGraphics` call (and delivered to
2307
+ * [[onCommit]] at that time). Returns `undefined` after the session has
2308
+ * settled (idempotent no-op).
2309
+ */
2310
+ close(): GraphicSnapshot[] | undefined;
2311
+ /** Reject the outer `editMany` promise with reason `"session"`. */
2312
+ abort(): void;
2313
+ /**
2314
+ * Subscribe to working-copy changes. The listener receives a
2315
+ * [[TransformChangeEvent]] for each completed group gesture (corner scale,
2316
+ * rotate, or body-translate drag end) — never on rubber-band ticks. All
2317
+ * currently-registered listeners receive the same event instance, in
2318
+ * registration order.
1186
2319
  *
1187
2320
  * Listener exceptions are collected; after every listener has run, they are
1188
2321
  * rethrown (one if single, aggregated otherwise). `event.reject()` /
1189
2322
  * `event.close()` / `event.abort()` take effect only after all listeners
1190
- * have run.
1191
- */
1192
- onChange(listener: (event: EditChangeEvent) => void): () => void;
1193
- /**
1194
- * Subscribe to the committed snapshot — the single delivery channel for the
1195
- * `GraphicSnapshot<ControlMeasure>` this session ever commits (#197, mirroring
1196
- * `TransformSession.onCommit` #191). Fires exactly once, synchronously from
1197
- * within the [[close]] call that produced it (`session.close()`,
1198
- * `event.close()` from [[onChange]], a click-away close, or a click on
1199
- * another graphics-layer measure), with the same reference [[close]]
1200
- * returns and the outer `edit` promise resolves with. Never fires on abort.
2323
+ * have run — mirrors `EditSession.onChange` (issue #49).
2324
+ */
2325
+ onChange(listener: (event: TransformChangeEvent) => void): () => void;
2326
+ /**
2327
+ * Subscribe to committed exit-snapshot batches — the single delivery channel
2328
+ * for every `GraphicSnapshot[]` this session ever commits (#191). Fires
2329
+ * exactly once per batch:
2330
+ *
2331
+ * - The members [[setGraphics]] removes, but only when that call actually
2332
+ * removed at least one member.
2333
+ * - The close-time members on any commit path: [[close]], `setGraphics([])`,
2334
+ * a click-away close, or `TransformChangeEvent.close()`.
2335
+ *
2336
+ * Never fires on an abort/reject path — pair it with [[onSettled]] to also
2337
+ * observe abort settles. Fires synchronously from within the
2338
+ * `setGraphics`/`close` call that produced the batch, before that call
2339
+ * returns, and the array delivered here is the same reference that call
2340
+ * returns (and, for the close batch, the same reference the `editMany`
2341
+ * promise resolves with). This is the recommended single fold path for exit
2342
+ * state — subscribe once in `onSession` and every committed snapshot, from
2343
+ * either delivery site, arrives here exactly once; the `setGraphics` return
2344
+ * value and the promise resolution are unchanged and remain valid for
2345
+ * backward compatibility.
1201
2346
  *
1202
2347
  * Listener exceptions are collected; after every listener has run, they are
1203
2348
  * rethrown (one if single, `AggregateError` otherwise) — mirrors
@@ -1205,21 +2350,21 @@ interface EditSession {
1205
2350
  * session has settled returns a no-op unsubscribe and the listener never
1206
2351
  * fires.
1207
2352
  */
1208
- onCommit(handler: (snapshot: GraphicSnapshot<ControlMeasure>) => void): () => void;
2353
+ onCommit(handler: (snapshots: GraphicSnapshot[]) => void): () => void;
1209
2354
  /**
1210
2355
  * Subscribe to the session's settlement — the lifecycle complement of
1211
2356
  * [[onCommit]]: `onCommit` delivers *what* was committed, `onSettled` says
1212
- * the session is *over* and why (#197, mirroring
1213
- * `TransformSession.onSettled` #194). Fires exactly once, when the session
1214
- * settles by any path, commit or abort, with a `SettleReason`.
2357
+ * the session is *over* and why (#194). Fires exactly once, when the
2358
+ * session settles by any path, commit or abort, with a [[SettleReason]].
1215
2359
  *
1216
- * - On the commit path it fires **after** [[onCommit]]'s emission, so a
1217
- * listener that clears selection state observes a document that already
1218
- * contains the committed snapshot.
1219
- * - On every path it fires **after** the facade has already cleared
1220
- * `td.activeSession` — so fold-then-render works from inside the handler.
2360
+ * - On commit paths it fires **after** the close batch's `onCommit`
2361
+ * emission, so a listener that clears selection state observes a document
2362
+ * that already contains the exit snapshots.
2363
+ * - On every path it fires **after** the facade has already cleared its
2364
+ * slot — `td.activeTransformSession` is `null`, so fold-then-render works
2365
+ * from inside the handler.
1221
2366
  * - `reason` distinguishes commit from abort but is deliberately coarse —
1222
- * no payload; the snapshot was already delivered through [[onCommit]].
2367
+ * no payload; snapshots were already delivered through [[onCommit]].
1223
2368
  *
1224
2369
  * Registering after the session has already settled is **not** a no-op
1225
2370
  * (unlike [[onChange]] / [[onCommit]]): the handler is invoked
@@ -1231,50 +2376,32 @@ interface EditSession {
1231
2376
  * [[onChange]] / [[onCommit]]. Returns an unsubscribe function.
1232
2377
  */
1233
2378
  onSettled(handler: (reason: SettleReason) => void): () => void;
1234
- /**
1235
- * Subscribe to the continuous stream of in-flight geometry mutations —
1236
- * vertex/midpoint drags and box scale/rotate/translate gestures — fired
1237
- * throughout the gesture rather than once at its end (contrast
1238
- * [[onChange]]). `start` fires at gesture begin, `move` on every pointer
1239
- * tick, and `end` fires exactly once when the gesture finishes by any
1240
- * path: commit, a click-slop no-op (a box body click that never becomes a
1241
- * drag), or session abort/teardown mid-drag. `end` fires **before** the
1242
- * gesture's [[onChange]] emission (and, on the commit path, before
1243
- * [[onCommit]]/[[onSettled]] too), so a listener observing both channels
1244
- * sees the transient stream close first.
1245
- *
1246
- * Label-placement drags (`labeldrag` mode) do not fire this — they move
1247
- * amplifier placements, not control points.
1248
- *
1249
- * Listener exceptions are collected; after every listener has run, they
1250
- * are rethrown (one if single, `AggregateError` otherwise) — mirrors
1251
- * [[onChange]]. Returns an unsubscribe function; registering after the
1252
- * session has settled returns a no-op unsubscribe and the listener never
1253
- * fires.
1254
- */
1255
- onTransientChange(listener: (event: TransientChangeEvent) => void): () => void;
1256
2379
  }
1257
2380
  /**
1258
- * Delivered to `EditSession.onChange` listeners once per completed gesture.
1259
- *
1260
- * Listeners see the *same* event instance in registration order. Per-gesture
1261
- * effects (`reject`, `close`, `abort`) are recorded during emission and
1262
- * applied after every listener has run, so a downstream listener cannot
1263
- * observe partial state. See PRD #40 user-stories 23–24.
2381
+ * Delivered to `TransformSession.onChange` listeners once per completed group
2382
+ * gesture. Both `graphics` and `previous` are index-aligned with
2383
+ * `session.graphics` *as of this emission*. Key by `graphic.id` rather than
2384
+ * relying on index alignment across emissions. A `setGraphics` call from within
2385
+ * a listener takes effect immediately and supersedes this emission's
2386
+ * `reject()` (the rollback baseline no longer matches the member set);
2387
+ * `close()` and `abort()` still apply, against the new membership. See
2388
+ * `EditChangeEvent` for the identical emission contract this mirrors.
1264
2389
  */
1265
- interface EditChangeEvent {
2390
+ interface TransformChangeEvent {
1266
2391
  /** How this working-copy transition was initiated. */
1267
2392
  readonly source: SessionChangeSource;
1268
- /** Working state after the completed gesture. */
1269
- readonly graphic: GraphicSnapshot<ControlMeasure>;
1270
- /** State immediately before this gesture. */
1271
- readonly previous: GraphicSnapshot<ControlMeasure>;
2393
+ /** Working state after the completed gesture, index-aligned with `session.graphics` as of this emission. */
2394
+ readonly graphics: GraphicSnapshot[];
2395
+ /** State immediately before this gesture, index-aligned with `session.graphics` as of this emission. */
2396
+ readonly previous: GraphicSnapshot[];
1272
2397
  /** The session the event belongs to. */
1273
- readonly session: EditSession;
2398
+ readonly session: TransformSession;
1274
2399
  /**
1275
- * Roll the working preview back to `previous` after all listeners have run.
1276
- * Multiple calls collapse to a single rollback. Overridden by `close()` or
1277
- * `abort()` if either is also called during this emission.
2400
+ * Roll every member's working preview back to `previous` after all
2401
+ * listeners have run. Multiple calls collapse to a single rollback.
2402
+ * Overridden by `close()` or `abort()` if either is also called during this
2403
+ * emission, and dropped if a listener called `session.setGraphics` (the
2404
+ * rollback baseline no longer matches the member set).
1278
2405
  */
1279
2406
  reject(): void;
1280
2407
  /** Shortcut for `event.session.close()`, deferred until the emission ends. */
@@ -1283,273 +2410,221 @@ interface EditChangeEvent {
1283
2410
  abort(): void;
1284
2411
  }
1285
2412
  //#endregion
1286
- //#region src/point-symbol-offset.d.ts
1287
- /** Read-only layout needs forward projection only. Coordinates are CSS pixels. */
1288
- type PointSymbolProjection = Pick<MapAdapter, "getPixelFromCoordinate" | "getBearing" | "getResolution">;
1289
- /** Editing may also require inverse projection (notably ground placement). */
1290
- type PointSymbolView = Pick<MapAdapter, "getPixelFromCoordinate" | "getCoordinateFromPixel" | "getBearing" | "getResolution">;
1291
- interface PointSymbolOffsetLayout {
1292
- /** Selected ordinary or detached body render, with canonical SVG dimensions. */
1293
- render: PointSymbolRender;
1294
- /** Selected body resource; dimensions and anchor remain in canonical SVG units. */
1295
- resource: IconResource;
1296
- /** Body opacity after applying the overall multiplier. */
1297
- bodyOpacity: number;
1298
- /** Clockwise radians in the projection plane. */
1299
- rotation: number;
1300
- actual: PixelCoordinate;
1301
- /** Body registration, including natural HQ displacement in ordinary placement. */
1302
- display: PixelCoordinate;
1303
- /** Coordinate at which the chosen image's resource anchor is painted. */
1304
- imageAnchor: PixelCoordinate;
1305
- ordinaryDisplay: PixelCoordinate;
1306
- attachment?: PixelCoordinate;
1307
- junction?: PixelCoordinate;
1308
- direction?: PixelCoordinate;
1309
- path: PixelCoordinate[];
1310
- kind: "ordinary" | "direct" | "indicator-only" | "with-extension";
1311
- status: "ok" | "unsupported-presentation";
1312
- scale: number;
1313
- /** Resolved connector styling in CSS pixels. */
1314
- connectorStyle: Required<PointSymbolOffsetStyle>;
2413
+ //#region src/tactical-draw/transform-controller.d.ts
2414
+ /** Where a group offset drag started and where it is now, in lon/lat. */
2415
+ interface GroupOffsetDrag {
2416
+ from: Position;
2417
+ to: Position;
1315
2418
  }
1316
- /** Pure layout: projection input/output is in CSS pixels, including document contexts. */
1317
- declare function resolvePointSymbolOffset(symbol: PointSymbol, render: PointSymbolRender, view: PointSymbolProjection): PointSymbolOffsetLayout | null;
1318
- /** Set body placement without changing the authoritative coordinate. */
1319
- declare function placePointSymbol(symbol: PointSymbol, render: PointSymbolRender, view: PointSymbolView, display: PixelCoordinate, mode?: PointSymbolPlacement["mode"]): PointSymbol;
1320
- declare function convertPointSymbolPlacement(symbol: PointSymbol, render: PointSymbolRender, view: PointSymbolView, mode: PointSymbolPlacement["mode"]): PointSymbol;
1321
- /** Explicit alignment, also used with hysteresis by pointer editing. */
1322
- declare function alignPointSymbolIndicator(symbol: PointSymbol, render: PointSymbolRender, view: PointSymbolView): PointSymbol;
1323
- declare function movePointSymbolLocation(symbol: PointSymbol, render: PointSymbolRender, view: PointSymbolView, position: Position): PointSymbol;
1324
- /** Canonical resource metadata shared by native adapters and external exporters. */
1325
- declare function pointSymbolResource(render: PointSymbolRender): IconResource;
1326
2419
  /**
1327
- * Convert a resolved CSS-pixel layout to output units (e.g. 25.4 / 96 for mm).
1328
- * Scales positions, body scale, line width and dashes together, including the
1329
- * already-resolved offset and padding. Canonical resources, direction, rotation
1330
- * and opacity stay unchanged. Does not mutate the input or authored symbol.
2420
+ * A host's own gesture for a group body drag with the offset-drag key held,
2421
+ * as a point symbol's offset drag moves where it is drawn rather than where
2422
+ * it is: the members never move. `preview` is called for each painted frame
2423
+ * and returns a collocation to draw in place of the members, or null to draw
2424
+ * them as they are; `commit` is called once on release. The gesture records
2425
+ * no step of the session's own: what the host commits is its own change.
1331
2426
  */
1332
- declare function scalePointSymbolLayout(layout: PointSymbolOffsetLayout, factor: number): PointSymbolOffsetLayout;
1333
- //#endregion
1334
- //#region src/tactical-draw/graphic-edit-session.d.ts
1335
- interface PointSymbolOffsetControls {
1336
- readonly layout: PointSymbolOffsetLayout | null;
1337
- readonly connectors: readonly PointSymbolConnector[];
1338
- setPlacement(mode: PointSymbolPlacement["mode"]): void;
1339
- setConnector(connector: PointSymbolConnector): void;
1340
- align(): void;
1341
- reset(): void;
1342
- }
1343
- interface GraphicEditChangeEvent<G extends Graphic = Graphic> {
1344
- readonly source: SessionChangeSource;
1345
- readonly graphic: GraphicSnapshot<G>;
1346
- readonly previous: GraphicSnapshot<G>;
1347
- readonly session: GraphicEditSession<G>;
1348
- reject(): void;
1349
- close(): void;
1350
- abort(): void;
1351
- }
1352
- /** Common selection/editing contract shared by control measures and point symbols. */
1353
- interface GraphicEditSession<G extends Graphic = Graphic> {
1354
- readonly history: SessionHistory;
1355
- /** Present on point-symbol sessions; all commands participate in session history. */
1356
- readonly offset?: PointSymbolOffsetControls;
1357
- /** Immutable edit-start input. */
1358
- readonly graphic: G;
1359
- /** Live working graphic. Copy on read. */
1360
- readonly workingGraphic: G;
1361
- readonly dirty: boolean;
1362
- readonly modes: readonly EditMode[];
1363
- close(): GraphicSnapshot<G> | undefined;
1364
- abort(): void;
1365
- setModes(modes: readonly EditMode[]): void;
1366
- /** Atomically replace any part of the live working graphic. */
1367
- updateGraphic(updater: (graphic: G) => G): void;
1368
- onChange(listener: (event: GraphicEditChangeEvent<G>) => void): () => void;
1369
- onCommit(handler: (snapshot: GraphicSnapshot<G>) => void): () => void;
1370
- onSettled(handler: (reason: SettleReason) => void): () => void;
1371
- /**
1372
- * Present on point-symbol sessions: the continuous stream of a drag, for a
1373
- * host that follows the symbol while it moves (a range ring, a viewshed).
1374
- * `start` fires on the first move of a gesture, `move` on each one after,
1375
- * and `end` exactly once per started gesture, before that gesture's
1376
- * [[onChange]], or when the session settles mid-gesture. `points` holds the
1377
- * one live position; `pointIndex` is `null`. A body, location or pin drag
1378
- * moves it; a rotate or scale streams it unchanged. Returns an unsubscribe
1379
- * function; registering after the session has settled returns a no-op.
1380
- */
1381
- onTransientChange?(listener: (event: TransientChangeEvent) => void): () => void;
2427
+ interface GroupOffsetDragHandler {
2428
+ preview(drag: GroupOffsetDrag): Collocation | null;
2429
+ commit(drag: GroupOffsetDrag): void;
1382
2430
  }
1383
2431
  //#endregion
1384
- //#region src/tactical-draw/transform-session.d.ts
2432
+ //#region src/tactical-draw/edit-session.d.ts
1385
2433
  /**
1386
- * Surface delivered via `td.editMany(graphics, opts).onSession` and
1387
- * synchronously available from `td.activeTransformSession` while the group
1388
- * transform is live. The group sibling of `EditSession` (`edit-session.ts`):
1389
- * no reshape, no per-measure `setOptions`/`setStyle` — only the shared
1390
- * transform box's corner-scale / rotate / body-translate gestures, applied to
1391
- * every member at once. See the Phase 3 ("Multi-select") slice of ADR-0017.
1392
- *
1393
- * Typed on `Graphic` (ADR-0032): a member is either a `ControlMeasure` or a
1394
- * point symbol, and the two coexist in one session. Hosts narrow with
1395
- * `isPointSymbol`. `controlPointsFor` is a control-measure accessor and returns
1396
- * `undefined` for a point-symbol id.
2434
+ * Surface delivered via `td.edit(measure, opts).onSession` and synchronously
2435
+ * available from `td.activeSession` while the edit is live.
1397
2436
  *
1398
- * The member set is mutable via [[setGraphics]] (#187): members can join or
1399
- * leave a live session without a session boundary — point symbols exactly like
1400
- * measures. Because membership changes over the session's lifetime, snapshot
1401
- * arrays are keyed by **graphic id**, not by index — a snapshot's identity is
1402
- * `snapshot.graphic.id`. `graphics` is a live view of the current members'
1403
- * join-time inputs; a `TransformChangeEvent`'s arrays are index-aligned with
1404
- * `session.graphics` *as of that emission*. After the session settles (`close`
1405
- * / `abort` / an emptying `setGraphics`), every method is a silent no-op
1406
- * (except [[onSettled]] — late registration still delivers, asynchronously).
2437
+ * `measure` is the immutable edit-start input. `controlPoints` is live working
2438
+ * state. After the session settles (`close` / `abort`), every method is a
2439
+ * silent no-op (except [[onSettled]] — late registration still delivers,
2440
+ * asynchronously).
1407
2441
  */
1408
- interface TransformSession {
1409
- /** Undo/redo for completed gestures within the current membership baseline. */
2442
+ interface EditSession {
2443
+ /** Undo/redo for completed mutations within this live session. */
1410
2444
  readonly history: SessionHistory;
2445
+ /** Immutable edit-start input. */
2446
+ readonly graphic: ControlMeasure;
1411
2447
  /**
1412
- * Live view of the current members' join-time input graphics — a fresh array
1413
- * on each read, in current membership order. Grows/shrinks as [[setGraphics]]
1414
- * adds or removes members. Not stable across membership changes: key
1415
- * snapshots by `snapshot.graphic.id` rather than relying on index alignment.
2448
+ * Live complete working graphic. Copy on read. `properties` (host-owned
2449
+ * metadata, e.g. `standardIdentity`/`colorMode`) is session-owned like every
2450
+ * other working field: it starts at the edit-start value, is replaced
2451
+ * wholesale by [[updateGraphic]], survives every subsequent gesture/setter
2452
+ * call and in-session undo/redo, and is rolled back by `event.reject()`
2453
+ * (issue #354). Absent when the edit-start measure carried none and
2454
+ * [[updateGraphic]] has not set any since.
2455
+ */
2456
+ readonly workingGraphic: ControlMeasure;
2457
+ /** Live working state. Copy on read. */
2458
+ readonly controlPoints: readonly Position[];
2459
+ /** Live working options. Copy on read. */
2460
+ readonly options: ControlMeasure["options"];
2461
+ /** Live working style. Copy on read. */
2462
+ readonly style: ControlMeasureStyle | undefined;
2463
+ /**
2464
+ * Live working text amplifiers (MIL-STD-2525E Appendix L Table L-II). Copy
2465
+ * on read. `undefined` when the edit-start measure carried none and none
2466
+ * have been set since. Keys are stored as given — canonicalisation to
2467
+ * doctrinal field codes happens in the core render seam, not here.
2468
+ */
2469
+ readonly textAmplifiers: TextAmplifiers | undefined;
2470
+ /** Live user-adjusted anchors for individually rendered text amplifiers. */
2471
+ readonly amplifierPlacements: AmplifierPlacements | undefined;
2472
+ /** `true` after the first working-copy mutation; back to `false` within tolerance. */
2473
+ readonly dirty: boolean;
2474
+ readonly modes: readonly EditMode[];
2475
+ /**
2476
+ * Whether reshape mode shows the measure's detail handles: fine-adjustment
2477
+ * option handles such as the per-vertex width grips on arrow shafts.
2478
+ * Initialised from `EditOptions.detailHandles` and mutated by
2479
+ * [[setDetailHandles]].
1416
2480
  */
1417
- readonly graphics: readonly Graphic[];
2481
+ readonly detailHandles: boolean;
1418
2482
  /**
1419
- * Live view of the current members' working graphics — a fresh array on each
1420
- * read, in current membership order, reflecting every gesture applied so far.
1421
- * Measures carry their working control points (and any transform-frozen
1422
- * options); point symbols carry their working position, size value, and
1423
- * rotation. Copy on read.
2483
+ * The primary sub-selected part of a graphic whose definition divides it
2484
+ * into parts (`ControlMeasureTopology.partOf`), e.g. the index of the Flow
2485
+ * Arrow's selected flow (ADR-0065): the part most recently added to
2486
+ * [[selectedParts]]. Hosts read it to edit the part's own settings. Starts
2487
+ * at `0`; pressing a point or midpoint, or clicking the graphic's body,
2488
+ * selects the part under the pointer alone, and an edit or undo that removes
2489
+ * the selected part falls back to `0`. Dragging a point or midpoint of a part
2490
+ * that is already selected keeps the selection; a click on it without a drag
2491
+ * selects it alone. `undefined` for graphics without parts.
1424
2492
  */
1425
- readonly workingGraphics: readonly Graphic[];
2493
+ readonly selectedPart: number | undefined;
1426
2494
  /**
1427
- * Live working control points for the control-measure member whose id is
1428
- * `graphicId`, or `undefined` when no such member carries that id — including
1429
- * when `graphicId` names a point symbol (which has no control points; read
1430
- * its working `position` from [[workingGraphics]] instead). Copy on read.
2495
+ * Every sub-selected part, [[selectedPart]] included, ascending. Reshape
2496
+ * mode shows the option grips of each. Never empty while the graphic has
2497
+ * parts; empty for graphics without parts. An edit or undo drops parts the
2498
+ * graphic no longer has (promoting the primary if it went), and when the
2499
+ * part count changes the set collapses to its primary, since parts are
2500
+ * indices and the ones after a removed part shift.
1431
2501
  */
1432
- controlPointsFor(graphicId: string): readonly Position[] | undefined;
1433
- /** `true` when any member's working state differs from its edit-start input beyond tolerance. */
1434
- readonly dirty: boolean;
2502
+ readonly selectedParts: readonly number[];
1435
2503
  /**
1436
- * Live size anchor, applied group-wide to the **control-measure** members
1437
- * only (ADR-0020). `"ground"` bakes each measure's pixel size to meters on
1438
- * commit; `"screen"` keeps it zoom-aware. A point symbol's persisted
1439
- * pixel/meter size is its own anchor and is never rewritten by this setting.
1440
- * Initialised from `EditManyOptions.sizeAnchor` and mutated by [[setSizeAnchor]].
2504
+ * Live size anchor for the measure under edit (ADR-0020). `"ground"` bakes a
2505
+ * pixel size to meters on commit; `"screen"` keeps it zoom-aware. Initialised
2506
+ * from `EditOptions.sizeAnchor` and mutated by [[setSizeAnchor]].
1441
2507
  */
1442
2508
  readonly sizeAnchor: SizeAnchor;
1443
2509
  /**
1444
- * Switch the group's size anchor (ADR-0020) for its control-measure members.
1445
- * Takes effect on the next emitted snapshot and on `close()`. Point-symbol
1446
- * members are unaffected.
2510
+ * Whether this ground-anchored measure has one or more sizes that can be
2511
+ * restored at the adapter's current resolution.
1447
2512
  */
1448
- setSizeAnchor(anchor: SizeAnchor): void;
2513
+ readonly canResetGroundSizes: boolean;
1449
2514
  /**
1450
- * Whether each member is outlined inside the group box. Initialised from
1451
- * `EditManyOptions.memberOutlines` (default `true`) and mutated by
1452
- * [[setMemberOutlines]].
2515
+ * Commit: returns the `GraphicSnapshot<ControlMeasure>` of the current working state
2516
+ * and resolves the outer `edit` promise with the same value (the same
2517
+ * reference — no double-bake of ground-anchored sizes). Returns `undefined`
2518
+ * after the session has settled (idempotent no-op).
1453
2519
  */
1454
- readonly memberOutlines: boolean;
2520
+ close(): GraphicSnapshot<ControlMeasure> | undefined;
2521
+ /** Reject the outer `edit` promise with reason `"session"`. */
2522
+ abort(): void;
1455
2523
  /**
1456
- * Show or hide the per-member outlines inside the group box, leaving the box
1457
- * and its handles as they are. A host turns them off when the members read
1458
- * as one object (a group selected whole) rather than as separate picks.
2524
+ * Switch the active edit-mode set. `"reshape"` produces vertex/midpoint
2525
+ * handles; `"transform"` renders the oriented selection box (corner scale
2526
+ * handles, rotate grip, body translate — ADR-0017); `"delete"` is exclusive
2527
+ * (vertex-tap removal) and collapses the set to delete-only. An unknown mode
2528
+ * is rejected with `TypeError`.
1459
2529
  */
1460
- setMemberOutlines(visible: boolean): void;
2530
+ setModes(modes: readonly EditMode[]): void;
1461
2531
  /**
1462
- * Replace the member set in place — the primitive behind shift-click toggle,
1463
- * marquee replace, and single-edit → group folding, without tearing the
1464
- * session down (#187). Members (measures and point symbols alike) are matched
1465
- * to the current set by graphic id:
1466
- *
1467
- * - **Retained** members (id in both the current and next sets) carry their
1468
- * current working state forward; the passed graphic object is ignored for
1469
- * them. Their `dirty` baseline stays their original join-time input, so a
1470
- * session that has already moved things stays dirty across the call.
1471
- * - **Removed** members (id in the current set, absent from the next) are
1472
- * committed at their current working state.
1473
- * - **Added** members (id only in the next set) join at their passed input
1474
- * state and use their host-provided Graphic-stack slot when present.
1475
- *
1476
- * The transform box re-derives from the next member set at the session's
1477
- * current box angle. Session-scoped state (`sizeAnchor`, box angle,
1478
- * non-geometry dirty) is unchanged.
1479
- *
1480
- * Calling this establishes a new session-history baseline: both undo and
1481
- * redo are cleared after retained members carry their working state
1482
- * forward. Membership changes and already-emitted exit snapshots are not
1483
- * undoable within the live session.
1484
- *
1485
- * **Return value** — the committed exit snapshots of the members removed *by
1486
- * this call*, built exactly like [[close]]'s snapshots (a measure's pixel
1487
- * size baked to ground unless `sizeAnchor` is `"screen"`, a point symbol's
1488
- * size left untouched, then cloned and rendered); an empty array when nothing
1489
- * was removed. The outer `editMany` promise resolves with the snapshots of
1490
- * the members in the set **at close time only**. Removed members are NOT
1491
- * retained in its Graphic-stack slot until the host acknowledges it by
1492
- * folding the returned snapshot into its document and calling `td.render()`,
1493
- * the same contract as [[close]]. A removed member's exit snapshot is also
1494
- * delivered through [[onCommit]] — the recommended channel, since it covers
1495
- * this return value and the close-time promise resolution through a single
1496
- * subscription.
1497
- * Returns `undefined` (a silent no-op) after the session has settled.
2532
+ * Show or hide the detail handles (see [[detailHandles]]). View state only:
2533
+ * no change event, no history entry. A silent no-op after settlement.
2534
+ */
2535
+ setDetailHandles(visible: boolean): void;
2536
+ /**
2537
+ * Select `part` alone (see [[selectedPart]]), or with `extend` toggle it in
2538
+ * or out of [[selectedParts]]: a part toggled in becomes primary; toggling
2539
+ * the primary out promotes the most recently added remaining part; toggling
2540
+ * out the last part is a no-op. View state only: no change event, no
2541
+ * history entry. A no-op for a part the working graphic doesn't have, for
2542
+ * graphics without parts, and after settlement.
2543
+ */
2544
+ selectPart(part: number, opts?: {
2545
+ extend?: boolean;
2546
+ }): void;
2547
+ /**
2548
+ * Replace [[selectedParts]] (e.g. "All flows"), ignoring parts the graphic
2549
+ * doesn't have. `primary`, when it is among them, becomes [[selectedPart]];
2550
+ * otherwise the last listed part does. View state only, like
2551
+ * [[selectPart]]; a no-op without a valid part.
2552
+ */
2553
+ selectParts(parts: readonly number[], primary?: number): void;
2554
+ /**
2555
+ * Subscribe to part selection changes, from the pointer, [[selectPart]],
2556
+ * [[selectParts]] or the reconcile after an edit or undo. Called once per
2557
+ * effective change with the primary and the full set; a call that changes
2558
+ * neither doesn't notify. Returns an unsubscribe function; registering
2559
+ * after settlement is a no-op.
2560
+ */
2561
+ onPartSelect(listener: (part: number | undefined, parts: readonly number[]) => void): () => void;
2562
+ /** Atomically replace the live working graphic while preserving id and kind. */
2563
+ updateGraphic(updater: (graphic: ControlMeasure) => ControlMeasure): void;
2564
+ /** Shallow-merge per-measure generator options into the live working copy. */
2565
+ setOptions(partial: ControlMeasure["options"]): void;
2566
+ /**
2567
+ * Flip the size anchor (ADR-0020). Takes effect on the next emitted snapshot
2568
+ * and on `close()`. A no-op for measures with no pixel-denominated size. The
2569
+ * in-flight preview is unaffected (it renders from the working options), so a
2570
+ * screen-locked symbol stays screen-locked until commit.
1498
2571
  *
1499
- * `setGraphics([])` on a live session delegates to [[close]]: it commits every
1500
- * current member, resolves the promise with their snapshots, and returns that
1501
- * same array. Duplicate ids in `graphics` throw `TypeError` synchronously,
1502
- * without mutating session state. A point-symbol member entering a session
1503
- * whose controller was created without a point-symbol capability throws
1504
- * `PointSymbolCapabilityRequiredError` synchronously, also without mutating
1505
- * session state.
2572
+ * `options` shallow-merges a size-option patch in the *same* mutation, as
2573
+ * [[setOptions]] would. Changing a measure's size mode means moving its value
2574
+ * between the pixel and meter halves of a size pair *and* re-anchoring, and
2575
+ * the halves are only meaningful together: options carrying a pixel size
2576
+ * under a `"ground"` anchor bake that size away on commit, so a host that
2577
+ * emitted the two as separate mutations would leave an undo step parked on a
2578
+ * state whose committed size mode contradicts its own options. Passed here
2579
+ * they are one change event and one history entry, which undo cannot land
2580
+ * inside.
1506
2581
  */
1507
- setGraphics(graphics: readonly Graphic[]): GraphicSnapshot[] | undefined;
2582
+ setSizeAnchor(anchor: SizeAnchor, options?: ControlMeasure["options"]): void;
1508
2583
  /**
1509
- * Commit: returns the members' `GraphicSnapshot[]` (the members in the set at
1510
- * close time) and resolves the outer `editMany` promise with the same value
1511
- * (the same reference — no double-bake of ground-anchored measure sizes). A
1512
- * member removed mid-session via [[setGraphics]] is not included here; its exit
1513
- * snapshot was returned from that `setGraphics` call (and delivered to
1514
- * [[onCommit]] at that time). Returns `undefined` after the session has
1515
- * settled (idempotent no-op).
2584
+ * Reset every geometry and label size to its default on-screen appearance at
2585
+ * the current map resolution, persisted in meters. The measure stays
2586
+ * ground-anchored and the reset is one undoable programmatic mutation.
2587
+ * No-op when [[canResetGroundSizes]] is false or after settlement.
1516
2588
  */
1517
- close(): GraphicSnapshot[] | undefined;
1518
- /** Reject the outer `editMany` promise with reason `"session"`. */
1519
- abort(): void;
2589
+ resetGroundSizes(): void;
2590
+ /** Shallow-merge per-measure style into the live working copy. */
2591
+ setStyle(partial: ControlMeasureStyle): void;
1520
2592
  /**
1521
- * Subscribe to working-copy changes. The listener receives a
1522
- * [[TransformChangeEvent]] for each completed group gesture (corner scale,
1523
- * rotate, or body-translate drag end) — never on rubber-band ticks. All
1524
- * currently-registered listeners receive the same event instance, in
1525
- * registration order.
2593
+ * Shallow-merge into the live working text amplifiers. A value of
2594
+ * `undefined` or an empty/whitespace-only string deletes that key; the
2595
+ * working record collapses back to `undefined` once it holds no keys. A
2596
+ * silent no-op after the session has settled (like [[setOptions]]).
2597
+ */
2598
+ setTextAmplifiers(partial: Record<string, string | undefined>): void;
2599
+ /**
2600
+ * Merge field-keyed label overrides (position and/or rotation). The merge is
2601
+ * **field-wise per key**: a bare `Position` value means `{ position }`;
2602
+ * fields absent from the incoming value (e.g. `rotation` when only
2603
+ * `position` is supplied) are preserved from the existing entry; an
2604
+ * explicit `undefined` value deletes the key entirely — a full reset to the
2605
+ * doctrinal placement (both position and rotation).
2606
+ */
2607
+ setAmplifierPlacements(partial: Record<string, AmplifierPlacement | undefined>): void;
2608
+ /**
2609
+ * Subscribe to working-copy changes. The listener receives an
2610
+ * [[EditChangeEvent]] for each completed gesture (drag end, insert/delete
2611
+ * via handle) — never on rubber-band ticks. All currently-registered
2612
+ * listeners receive the same event instance in registration order.
1526
2613
  *
1527
2614
  * Listener exceptions are collected; after every listener has run, they are
1528
2615
  * rethrown (one if single, aggregated otherwise). `event.reject()` /
1529
2616
  * `event.close()` / `event.abort()` take effect only after all listeners
1530
- * have run — mirrors `EditSession.onChange` (issue #49).
2617
+ * have run.
1531
2618
  */
1532
- onChange(listener: (event: TransformChangeEvent) => void): () => void;
2619
+ onChange(listener: (event: EditChangeEvent) => void): () => void;
1533
2620
  /**
1534
- * Subscribe to committed exit-snapshot batches — the single delivery channel
1535
- * for every `GraphicSnapshot[]` this session ever commits (#191). Fires
1536
- * exactly once per batch:
1537
- *
1538
- * - The members [[setGraphics]] removes, but only when that call actually
1539
- * removed at least one member.
1540
- * - The close-time members on any commit path: [[close]], `setGraphics([])`,
1541
- * a click-away close, or `TransformChangeEvent.close()`.
1542
- *
1543
- * Never fires on an abort/reject path — pair it with [[onSettled]] to also
1544
- * observe abort settles. Fires synchronously from within the
1545
- * `setGraphics`/`close` call that produced the batch, before that call
1546
- * returns, and the array delivered here is the same reference that call
1547
- * returns (and, for the close batch, the same reference the `editMany`
1548
- * promise resolves with). This is the recommended single fold path for exit
1549
- * state — subscribe once in `onSession` and every committed snapshot, from
1550
- * either delivery site, arrives here exactly once; the `setGraphics` return
1551
- * value and the promise resolution are unchanged and remain valid for
1552
- * backward compatibility.
2621
+ * Subscribe to the committed snapshot — the single delivery channel for the
2622
+ * `GraphicSnapshot<ControlMeasure>` this session ever commits (#197, mirroring
2623
+ * `TransformSession.onCommit` #191). Fires exactly once, synchronously from
2624
+ * within the [[close]] call that produced it (`session.close()`,
2625
+ * `event.close()` from [[onChange]], a click-away close, or a click on
2626
+ * another graphics-layer measure), with the same reference [[close]]
2627
+ * returns and the outer `edit` promise resolves with. Never fires on abort.
1553
2628
  *
1554
2629
  * Listener exceptions are collected; after every listener has run, they are
1555
2630
  * rethrown (one if single, `AggregateError` otherwise) — mirrors
@@ -1557,21 +2632,21 @@ interface TransformSession {
1557
2632
  * session has settled returns a no-op unsubscribe and the listener never
1558
2633
  * fires.
1559
2634
  */
1560
- onCommit(handler: (snapshots: GraphicSnapshot[]) => void): () => void;
2635
+ onCommit(handler: (snapshot: GraphicSnapshot<ControlMeasure>) => void): () => void;
1561
2636
  /**
1562
2637
  * Subscribe to the session's settlement — the lifecycle complement of
1563
2638
  * [[onCommit]]: `onCommit` delivers *what* was committed, `onSettled` says
1564
- * the session is *over* and why (#194). Fires exactly once, when the
1565
- * session settles by any path, commit or abort, with a [[SettleReason]].
2639
+ * the session is *over* and why (#197, mirroring
2640
+ * `TransformSession.onSettled` #194). Fires exactly once, when the session
2641
+ * settles by any path, commit or abort, with a `SettleReason`.
1566
2642
  *
1567
- * - On commit paths it fires **after** the close batch's `onCommit`
1568
- * emission, so a listener that clears selection state observes a document
1569
- * that already contains the exit snapshots.
1570
- * - On every path it fires **after** the facade has already cleared its
1571
- * slot — `td.activeTransformSession` is `null`, so fold-then-render works
1572
- * from inside the handler.
2643
+ * - On the commit path it fires **after** [[onCommit]]'s emission, so a
2644
+ * listener that clears selection state observes a document that already
2645
+ * contains the committed snapshot.
2646
+ * - On every path it fires **after** the facade has already cleared
2647
+ * `td.activeSession` — so fold-then-render works from inside the handler.
1573
2648
  * - `reason` distinguishes commit from abort but is deliberately coarse —
1574
- * no payload; snapshots were already delivered through [[onCommit]].
2649
+ * no payload; the snapshot was already delivered through [[onCommit]].
1575
2650
  *
1576
2651
  * Registering after the session has already settled is **not** a no-op
1577
2652
  * (unlike [[onChange]] / [[onCommit]]): the handler is invoked
@@ -1583,32 +2658,50 @@ interface TransformSession {
1583
2658
  * [[onChange]] / [[onCommit]]. Returns an unsubscribe function.
1584
2659
  */
1585
2660
  onSettled(handler: (reason: SettleReason) => void): () => void;
2661
+ /**
2662
+ * Subscribe to the continuous stream of in-flight geometry mutations —
2663
+ * vertex/midpoint drags and box scale/rotate/translate gestures — fired
2664
+ * throughout the gesture rather than once at its end (contrast
2665
+ * [[onChange]]). `start` fires at gesture begin, `move` on every pointer
2666
+ * tick, and `end` fires exactly once when the gesture finishes by any
2667
+ * path: commit, a click-slop no-op (a box body click that never becomes a
2668
+ * drag), or session abort/teardown mid-drag. `end` fires **before** the
2669
+ * gesture's [[onChange]] emission (and, on the commit path, before
2670
+ * [[onCommit]]/[[onSettled]] too), so a listener observing both channels
2671
+ * sees the transient stream close first.
2672
+ *
2673
+ * Label-placement drags (`labeldrag` mode) do not fire this — they move
2674
+ * amplifier placements, not control points.
2675
+ *
2676
+ * Listener exceptions are collected; after every listener has run, they
2677
+ * are rethrown (one if single, `AggregateError` otherwise) — mirrors
2678
+ * [[onChange]]. Returns an unsubscribe function; registering after the
2679
+ * session has settled returns a no-op unsubscribe and the listener never
2680
+ * fires.
2681
+ */
2682
+ onTransientChange(listener: (event: TransientChangeEvent) => void): () => void;
1586
2683
  }
1587
2684
  /**
1588
- * Delivered to `TransformSession.onChange` listeners once per completed group
1589
- * gesture. Both `graphics` and `previous` are index-aligned with
1590
- * `session.graphics` *as of this emission*. Key by `graphic.id` rather than
1591
- * relying on index alignment across emissions. A `setGraphics` call from within
1592
- * a listener takes effect immediately and supersedes this emission's
1593
- * `reject()` (the rollback baseline no longer matches the member set);
1594
- * `close()` and `abort()` still apply, against the new membership. See
1595
- * `EditChangeEvent` for the identical emission contract this mirrors.
2685
+ * Delivered to `EditSession.onChange` listeners once per completed gesture.
2686
+ *
2687
+ * Listeners see the *same* event instance in registration order. Per-gesture
2688
+ * effects (`reject`, `close`, `abort`) are recorded during emission and
2689
+ * applied after every listener has run, so a downstream listener cannot
2690
+ * observe partial state. See PRD #40 user-stories 23–24.
1596
2691
  */
1597
- interface TransformChangeEvent {
2692
+ interface EditChangeEvent {
1598
2693
  /** How this working-copy transition was initiated. */
1599
2694
  readonly source: SessionChangeSource;
1600
- /** Working state after the completed gesture, index-aligned with `session.graphics` as of this emission. */
1601
- readonly graphics: GraphicSnapshot[];
1602
- /** State immediately before this gesture, index-aligned with `session.graphics` as of this emission. */
1603
- readonly previous: GraphicSnapshot[];
2695
+ /** Working state after the completed gesture. */
2696
+ readonly graphic: GraphicSnapshot<ControlMeasure>;
2697
+ /** State immediately before this gesture. */
2698
+ readonly previous: GraphicSnapshot<ControlMeasure>;
1604
2699
  /** The session the event belongs to. */
1605
- readonly session: TransformSession;
2700
+ readonly session: EditSession;
1606
2701
  /**
1607
- * Roll every member's working preview back to `previous` after all
1608
- * listeners have run. Multiple calls collapse to a single rollback.
1609
- * Overridden by `close()` or `abort()` if either is also called during this
1610
- * emission, and dropped if a listener called `session.setGraphics` (the
1611
- * rollback baseline no longer matches the member set).
2702
+ * Roll the working preview back to `previous` after all listeners have run.
2703
+ * Multiple calls collapse to a single rollback. Overridden by `close()` or
2704
+ * `abort()` if either is also called during this emission.
1612
2705
  */
1613
2706
  reject(): void;
1614
2707
  /** Shortcut for `event.session.close()`, deferred until the emission ends. */
@@ -1705,85 +2798,6 @@ interface DrawSession {
1705
2798
  onTransientChange(listener: (event: TransientChangeEvent) => void): () => void;
1706
2799
  }
1707
2800
  //#endregion
1708
- //#region src/tactical-draw/snapping.d.ts
1709
- type SnapInteraction = "draw" | "reshape" | "translate" | "label-drag";
1710
- interface SnapCandidateRequest {
1711
- coordinate: Position;
1712
- pixel: PixelCoordinate;
1713
- interaction: SnapInteraction;
1714
- graphicId?: string;
1715
- /**
1716
- * Every graphic a multi-selection moves together; candidates of any of them
1717
- * are skipped, so the group never snaps onto itself. Set instead of `graphicId`.
1718
- */
1719
- graphicIds?: readonly string[];
1720
- controlPointIndex?: number;
1721
- originalEvent?: unknown;
1722
- }
1723
- interface SnapCandidate {
1724
- id: string;
1725
- coordinate: Position;
1726
- kind: string;
1727
- graphicId?: string;
1728
- controlPointIndex?: number;
1729
- priority?: number;
1730
- }
1731
- /**
1732
- * Host snap candidates near `request`. A provider that leaves out the moving
1733
- * graphic's own candidates should check `request.graphicIds` (a multi-selection)
1734
- * as well as `request.graphicId`. A move or scale that tests several
1735
- * points of a graphic (a control measure's control points, a Note's or an
1736
- * Image's corners and centre) asks once per tested point on each pointer move,
1737
- * so keep it cheap: return only candidates near `request.pixel`.
1738
- */
1739
- type SnapCandidateProvider = (request: SnapCandidateRequest) => readonly SnapCandidate[];
1740
- /**
1741
- * A snap the host answers later, such as one to terrain it has to sample
1742
- * first. Asked on every reshape and translate move of a control-measure edit,
1743
- * at the position the other sources snapped it to (for a translate, the moved
1744
- * first control point). Return `null` to have no say in this move, and the
1745
- * drag follows the pointer at once; otherwise the drag holds where it was
1746
- * until the promise settles, then lands at the position it resolves to, or at
1747
- * the pointer for `null`. An answer lands unless a later move's landed first,
1748
- * so a drag keeps up while answers are slow. A release waits for the answer
1749
- * to where it was let go before committing, so the gesture is still one
1750
- * change. `signal` aborts once the drag is over or the edit settles.
1751
- *
1752
- * The host decides how far it reaches: neither `enabled` nor
1753
- * `tolerancePixels` applies. `bypass` does.
1754
- */
1755
- type DeferredSnapProvider = (request: SnapCandidateRequest, signal: AbortSignal) => Promise<Position | null> | null;
1756
- interface SnapResult {
1757
- coordinate: Position;
1758
- pixel: PixelCoordinate;
1759
- candidate: SnapCandidate;
1760
- distancePixels: number;
1761
- }
1762
- interface GraphicGeometrySnappingOptions {
1763
- /** Snap to the nearest point along generated linework and polygon boundaries. Default `true`. */
1764
- edges?: boolean;
1765
- /** Snap to generated geometry vertices. Default `false`. */
1766
- vertices?: boolean;
1767
- }
1768
- interface SnappingOptions {
1769
- enabled?: boolean;
1770
- tolerancePixels?: number;
1771
- sources?: {
1772
- graphics?: boolean;
1773
- /**
1774
- * Snap to generated control-measure geometry. `true` enables edges with
1775
- * vertices disabled; pass an object to select either candidate type.
1776
- * Text/label point features and the active graphic are excluded.
1777
- */
1778
- graphicGeometry?: boolean | GraphicGeometrySnappingOptions;
1779
- external?: SnapCandidateProvider;
1780
- deferred?: DeferredSnapProvider;
1781
- };
1782
- bypass?: (originalEvent: unknown) => boolean;
1783
- /** Called for each resolution attempt; `null` clears a host-rendered indicator. */
1784
- onSnap?: (result: SnapResult | null) => void;
1785
- }
1786
- //#endregion
1787
2801
  //#region src/tactical-draw/point-symbol-draw-controller.d.ts
1788
2802
  type DrawPointSymbolDraft = Pick<PointSymbol, "kind" | "sidc"> & Partial<Omit<PointSymbol, "kind" | "sidc">>;
1789
2803
  //#endregion
@@ -1811,7 +2825,7 @@ declare const DEFAULT_MARKER_SIZE: MarkerSize;
1811
2825
  interface TacticalDrawLayerOptions {
1812
2826
  graphics?: LayerId;
1813
2827
  /**
1814
- * Passive selection-highlight outlines ({@link TacticalDraw.setHighlightedGraphics}).
2828
+ * Passive selection-highlight outlines ({@link TacticalDraw.setPassiveOutlines}).
1815
2829
  * Resolved immediately above `graphics` so highlight boxes stack over base
1816
2830
  * graphics but below the preview / guide / handles interaction chrome.
1817
2831
  */
@@ -1832,6 +2846,25 @@ interface InteractionHit {
1832
2846
  /** Control-measure id when the hit feature belongs to one (graphics/preview parts). */
1833
2847
  measureId?: string;
1834
2848
  }
2849
+ /**
2850
+ * A passive outline target ({@link TacticalDraw.setPassiveOutlines}): a bare
2851
+ * graphic id outlines the whole graphic; `{ id, memberId }` outlines one
2852
+ * collocation member (ADR-0063).
2853
+ */
2854
+ type PassiveOutlineTarget = string | {
2855
+ id: string;
2856
+ memberId: string;
2857
+ };
2858
+ /**
2859
+ * A pick as `td.onPick` / `td.onGraphicPick` handlers receive it: the
2860
+ * adapter's {@link PickEvent} plus the modifier keys held, read the same way
2861
+ * in every engine (#754), so a handler can extend a selection on Shift or
2862
+ * Primary without guarding `originalEvent`.
2863
+ */
2864
+ interface TacticalDrawPickEvent extends PickEvent {
2865
+ modifiers: PickModifiers;
2866
+ }
2867
+ type TacticalDrawPickHandler = (event: TacticalDrawPickEvent) => void;
1835
2868
  interface TacticalDrawOptions {
1836
2869
  /** Optional point-symbol body-drag shortcut; disabled when omitted or false. */
1837
2870
  offsetDragModifier?: OffsetDragModifier | false;
@@ -1907,16 +2940,56 @@ interface TacticalDrawOptions {
1907
2940
  generateId?: () => string;
1908
2941
  /** Optional engine-level snapping for draw and edit interactions. */
1909
2942
  snapping?: SnappingOptions;
2943
+ /**
2944
+ * Opt-in Collocation support (ADR-0063), from `createCollocationSupport()`.
2945
+ * Without it, rendering, drawing or editing a Collocation throws
2946
+ * `CollocationSupportRequiredError`. What a ground move of a collocation
2947
+ * changes is set there too (`createCollocationSupport({ resolveTransform })`).
2948
+ */
2949
+ collocations?: CollocationSupport;
1910
2950
  }
1911
2951
  interface EditOptions {
1912
2952
  /** Override the point-symbol offset shortcut for this edit; false disables it. */
1913
2953
  offsetDragModifier?: OffsetDragModifier | false;
2954
+ /**
2955
+ * Point symbols only: the host's drop of the symbol into a collocation with
2956
+ * a body offset drag (#760); see {@link OffsetDropHandler}. Away from every
2957
+ * collocation `targetAt` names, the drag moves the offset as usual. Needs
2958
+ * `createCollocationSupport()`.
2959
+ */
2960
+ offsetDrop?: OffsetDropHandler;
2961
+ /**
2962
+ * Collocations only: the host's removal of a member that a `"rearrange"` drag
2963
+ * dropped well clear of both parts (#759). The host owns which graphics
2964
+ * make up a collocation, and what happens when fewer than two remain, so
2965
+ * the edit commits nothing for the drop. Without it no drop removes.
2966
+ */
2967
+ onRemoveMember?: (memberId: string) => void;
2968
+ /**
2969
+ * Collocations only: how a dragged part is stored. `"keep"` (default)
2970
+ * keeps a ground part on the ground and makes anything else
2971
+ * screen-relative; `"ground"` and `"screen-relative"` always store that
2972
+ * mode, e.g. `"ground"` for a host whose parts mark ground positions.
2973
+ */
2974
+ partDrag?: CollocationPartDrag;
2975
+ /**
2976
+ * Collocations only: under `partDrag: "keep"`, the farthest a dragged part
2977
+ * is stored screen-relative, in CSS px at collocation scale 1 from the
2978
+ * location to the part's registration (the Bracket's tick root, the
2979
+ * Staff's foot); further, it is stored on the ground. A location or
2980
+ * member move that keeps parts where they are on screen follows the same
2981
+ * rule. A long screen-relative leader is drawn into the part's image, so
2982
+ * its size grows with the leader's bounding box. Default
2983
+ * `COLLOCATION_SCREEN_RELATIVE_REACH` (200); `Infinity` keeps every
2984
+ * drag screen-relative.
2985
+ */
2986
+ screenRelativeReach?: number;
1914
2987
  signal?: AbortSignal;
1915
2988
  /**
1916
2989
  * Called synchronously once when the edit starts, before any pointer event
1917
2990
  * is processed. Lets a host wire commit / cancel buttons to the active edit.
1918
2991
  */
1919
- onSession?: (session: EditSession | GraphicEditSession<PointSymbol> | GraphicEditSession<ImageGraphic> | GraphicEditSession<NoteGraphic> | GraphicEditSession<Marker>) => void;
2992
+ onSession?: (session: EditSession | GraphicEditSession<PointSymbol> | GraphicEditSession<ImageGraphic> | GraphicEditSession<NoteGraphic> | GraphicEditSession<Marker> | CollocationEditSession) => void;
1920
2993
  /**
1921
2994
  * Default `true`. When `true`, a click on empty map (or on another graphics
1922
2995
  * layer measure) closes the active edit. Clicks on preview / handle
@@ -2000,6 +3073,23 @@ interface EditManyOptions {
2000
3073
  * session, where the other options are ignored.
2001
3074
  */
2002
3075
  memberOutlines?: boolean;
3076
+ /**
3077
+ * The host's own gesture for a body drag with the offset-drag key held
3078
+ * (see {@link GroupOffsetDragHandler}): a host collocates the set, say,
3079
+ * previewing the collocation as the pointer moves. Without it such a drag
3080
+ * moves the set as any body drag does. Needs `createCollocationSupport()`.
3081
+ */
3082
+ offsetDrag?: GroupOffsetDragHandler;
3083
+ /**
3084
+ * The host's drop of the set into a collocation with that drag (#760), when
3085
+ * every member is a point symbol or Marker; see {@link OffsetDropHandler}.
3086
+ * The members join in the order they are given. Over a collocation
3087
+ * `targetAt` names this wins; elsewhere `offsetDrag` runs. Needs
3088
+ * `createCollocationSupport()`.
3089
+ */
3090
+ offsetDrop?: OffsetDropHandler;
3091
+ /** Override the offset-drag key for this transform; `false` disables the gesture. */
3092
+ offsetDragModifier?: OffsetDragModifier | false;
2003
3093
  }
2004
3094
  /**
2005
3095
  * A host-defined set of graphics outlined together as one passive box
@@ -2100,6 +3190,9 @@ declare class TacticalDraw {
2100
3190
  private readonly images;
2101
3191
  private readonly notes;
2102
3192
  private readonly markers;
3193
+ /** The member kind → capability table collocations draw with, built once. */
3194
+ private readonly collocationMembers;
3195
+ private readonly collocations;
2103
3196
  private snappingOptions;
2104
3197
  private readonly resolveSnap;
2105
3198
  private readonly resolveDeferredSnap;
@@ -2183,12 +3276,12 @@ declare class TacticalDraw {
2183
3276
  private noteResolveCache;
2184
3277
  private lastSeenMarkerGeneration;
2185
3278
  /**
2186
- * Ids of graphics currently carrying a passive selection-highlight outline
2187
- * ({@link setHighlightedGraphics}). Declarative set-replace, no session —
2188
- * re-projected on every view change and re-evaluated at the end of every
2189
- * `render()` so outlines track geometry, style, and dropped graphics.
3279
+ * Current passive outline targets ({@link setPassiveOutlines}). Declarative
3280
+ * set-replace, no session — re-projected on every view change and
3281
+ * re-evaluated at the end of every `render()` so outlines track geometry,
3282
+ * style, and dropped graphics.
2190
3283
  */
2191
- private highlightedIds;
3284
+ private passiveOutlines;
2192
3285
  /** Graphic sets outlined as one box each ({@link setHighlightedGroups}). */
2193
3286
  private highlightedGroups;
2194
3287
  private pinBodies;
@@ -2204,7 +3297,7 @@ declare class TacticalDraw {
2204
3297
  */
2205
3298
  private hasHighlightOutlines;
2206
3299
  /**
2207
- * Coalesces bursts of {@link setHighlightedGraphics} (e.g. hover across a
3300
+ * Coalesces bursts of {@link setPassiveOutlines} (e.g. hover across a
2208
3301
  * list of rows) into at most one {@link renderHighlights} per animation
2209
3302
  * frame. Every other caller — `render()`, view-change, session start /
2210
3303
  * settle — needs highlight state updated synchronously and in step with
@@ -2289,6 +3382,20 @@ declare class TacticalDraw {
2289
3382
  * per-frame reconcile cost becomes O(selection) rather than O(document).
2290
3383
  */
2291
3384
  private renderGraphicGroup;
3385
+ /** The opted-in collocation support, or `CollocationSupportRequiredError`. */
3386
+ private requireCollocations;
3387
+ /**
3388
+ * Bind a session's offset drop (#760): the drag hides the target it aims
3389
+ * at in the graphics layer, and draws it joined on the preview layer.
3390
+ */
3391
+ private bindOffsetDrop;
3392
+ /** A collocation's group, stamped like {@link buildGraphicGroup}, with the layout it drew. */
3393
+ private buildCollocationGroup;
3394
+ /**
3395
+ * The current layout of a rendered collocation, from the graphics-stack
3396
+ * render cache (built once and cached on a miss).
3397
+ */
3398
+ private collocationLayout;
2292
3399
  /**
2293
3400
  * Render a Graphic group from scratch and stamp it with a fresh revision,
2294
3401
  * drawn from the module-scoped {@link nextGraphicGroupRevision} counter (see
@@ -2363,20 +3470,23 @@ declare class TacticalDraw {
2363
3470
  */
2364
3471
  render(measures: readonly Graphic[]): void;
2365
3472
  /**
2366
- * Replace the passive selection-highlight set with `ids`. Declarative and
2367
- * idempotent (mirrors {@link render}): a non-interactive outline box is drawn
2368
- * around each still-rendered graphic on the dedicated highlight layer — no
2369
- * draw / edit / transform session, no promise, no pick subscription. Passing
2370
- * `[]` clears every highlight. Unknown ids and ids currently active in an
2371
- * active edit / transform session are skipped (the live session's own visuals
2372
- * supersede the passive outline). Hosts use it for Excalidraw-style
2373
- * "locked selection" chrome.
3473
+ * Replace the passive outline set with `targets`. Declarative and
3474
+ * idempotent (mirrors {@link render}): a non-interactive dashed outline is
3475
+ * drawn on the dedicated highlight layer — no draw / edit / transform
3476
+ * session, no promise, no pick subscription. Passing `[]` clears every
3477
+ * outline. Hosts use it for "locked selection" chrome and for hover.
3478
+ *
3479
+ * A bare id outlines the whole graphic; unknown ids and ids active in an
3480
+ * edit / transform session are skipped (the live session's own visuals
3481
+ * supersede the outline). A `{ id, memberId }` target outlines one
3482
+ * collocation member's extent and rings its position (ADR-0063); it stays
3483
+ * drawn during that collocation's own edit, following the live preview.
2374
3484
  */
2375
- setHighlightedGraphics(ids: readonly string[]): void;
3485
+ setPassiveOutlines(targets: readonly PassiveOutlineTarget[]): void;
2376
3486
  /**
2377
3487
  * Replace the passive group outlines with `groups`: one outline box around
2378
3488
  * the joint bounds of each group's still-rendered graphics, drawn with the
2379
- * same style and on the same layer as {@link setHighlightedGraphics}, which
3489
+ * same style and on the same layer as {@link setPassiveOutlines}, which
2380
3490
  * it sits beside. Declarative like that set: `[]` clears every group
2381
3491
  * outline. A graphic in an active edit or transform session still counts
2382
3492
  * toward its group's bounds (at its last rendered geometry), so a host can
@@ -2384,16 +3494,23 @@ declare class TacticalDraw {
2384
3494
  * rendered graphic draws nothing.
2385
3495
  */
2386
3496
  setHighlightedGroups(groups: readonly HighlightedGroup[]): void;
3497
+ /**
3498
+ * @deprecated Use {@link setPassiveOutlines}; this alias forwards to it and
3499
+ * will be removed in a later major.
3500
+ */
3501
+ setHighlightedGraphics(ids: readonly string[]): void;
2387
3502
  /**
2388
3503
  * Cancel any pending coalesced highlight frame and re-project highlights
2389
- * immediately. Used by every caller other than `setHighlightedGraphics`
3504
+ * immediately. Used by every caller other than `setPassiveOutlines`
2390
3505
  * (`render()`, view-change, session start / settle) so their own
2391
3506
  * synchronous effects and the highlight layer update together, with no
2392
3507
  * frame of lag and no stale coalesced call left to fire afterwards.
2393
3508
  */
3509
+ /** Re-project passive outlines when one targets a member of collocation `id`. */
3510
+ private flushMemberOutlines;
2394
3511
  private flushHighlights;
2395
3512
  /**
2396
- * Project the current {@link highlightedIds} into one outline `LineString`
3513
+ * Project the current {@link passiveOutlines} into one outline `LineString`
2397
3514
  * per graphic and reconcile them onto the highlight layer. Idempotent and
2398
3515
  * grouped by graphic id, so desired-state replacement removes stale outlines
2399
3516
  * and an unchanged set is a cheap no-op write. Skips ids that are
@@ -2402,6 +3519,17 @@ declare class TacticalDraw {
2402
3519
  * (`getCoordinateFromPixel` is optional in the MapAdapter ABI).
2403
3520
  */
2404
3521
  private renderHighlights;
3522
+ /** The active edit when it is a single edit of collocation `id`. */
3523
+ private collocationEdit;
3524
+ /**
3525
+ * The collocation a member outline reads, with its layout: the working copy
3526
+ * and live layout while that collocation is edited on its own, else its last
3527
+ * render. `undefined` while a group transform holds it (the group box
3528
+ * supersedes the outline).
3529
+ */
3530
+ private outlinedCollocation;
3531
+ /** The passive outline of one collocation member: its extent, and a ring at its position. */
3532
+ private memberOutlineFeatures;
2405
3533
  /**
2406
3534
  * Fit the passive-highlight transform box for one graphic: the point-symbol
2407
3535
  * footprint for symbols, the snug text footprint for Text graphics, and the
@@ -2481,7 +3609,14 @@ declare class TacticalDraw {
2481
3609
  edit(graphic: ImageGraphic, options?: EditOptions): Promise<GraphicSnapshot<ImageGraphic>>;
2482
3610
  edit(graphic: NoteGraphic, options?: EditOptions): Promise<GraphicSnapshot<NoteGraphic>>;
2483
3611
  edit(graphic: Marker, options?: EditOptions): Promise<GraphicSnapshot<Marker>>;
3612
+ edit(graphic: Collocation, options?: EditOptions): Promise<GraphicSnapshot<Collocation>>;
2484
3613
  edit(measure: ControlMeasure, options?: EditOptions): Promise<GraphicSnapshot<ControlMeasure>>;
3614
+ /**
3615
+ * A single collocation edit (ADR-0063): part drags and a location handle,
3616
+ * no transform box. Clicks on a member or part still reach host pick
3617
+ * handlers (see {@link routePick}).
3618
+ */
3619
+ private editCollocation;
2485
3620
  /**
2486
3621
  * Start an interactive group transform (multi-select) over `measures`
2487
3622
  * (ADR-0017 "Multi-select" slice). Every host-provided member stays in its
@@ -2508,7 +3643,7 @@ declare class TacticalDraw {
2508
3643
  * session is over and why.
2509
3644
  */
2510
3645
  editMany(measures: ControlMeasure[], options?: EditManyOptions): Promise<GraphicSnapshot<ControlMeasure>[]>;
2511
- editMany(graphics: Graphic[], options?: EditManyOptions): Promise<GraphicSnapshot[]>;
3646
+ editMany(targets: TransformTarget[], options?: EditManyOptions): Promise<GraphicSnapshot[]>;
2512
3647
  /**
2513
3648
  * One-call selection-sync: mutate a live transform's member set in place, or
2514
3649
  * start a fresh `editMany` when none is live (#191). Any mix of control
@@ -2544,7 +3679,7 @@ declare class TacticalDraw {
2544
3679
  * either path. Starting a fresh transform preempts any other in-flight
2545
3680
  * draw/edit exactly like `editMany`.
2546
3681
  */
2547
- syncTransformGraphics(graphics: readonly Graphic[], options?: EditManyOptions): void;
3682
+ syncTransformGraphics(graphics: readonly TransformTarget[], options?: EditManyOptions): void;
2548
3683
  /**
2549
3684
  * Subscribe to picks on committed control measures.
2550
3685
  *
@@ -2556,7 +3691,7 @@ declare class TacticalDraw {
2556
3691
  * Returns an idempotent unsubscribe function. An optional `signal` removes
2557
3692
  * the handler when aborted.
2558
3693
  */
2559
- onGraphicPick(handler: PickHandler, opts?: PickOptions): () => void;
3694
+ onGraphicPick(handler: TacticalDrawPickHandler, opts?: PickOptions): () => void;
2560
3695
  /**
2561
3696
  * Subscribe to pick events on `layerId`. Routed through the façade so the
2562
3697
  * close-then-pick contract (issue #52) is observable: when an active edit
@@ -2567,7 +3702,7 @@ declare class TacticalDraw {
2567
3702
  *
2568
3703
  * Returns an unsubscribe function. Optional `signal` mirrors `adapter.onPick`.
2569
3704
  */
2570
- onPick(layerId: LayerId, handler: PickHandler, opts?: PickOptions): () => void;
3705
+ onPick(layerId: LayerId, handler: TacticalDrawPickHandler, opts?: PickOptions): () => void;
2571
3706
  /**
2572
3707
  * Stateless hit test answering "does TacticalDraw own the pixel at
2573
3708
  * `pixel`?" — for hosts composing their own click-away / deselection logic
@@ -2734,39 +3869,8 @@ declare class NoteCapabilityRequiredError extends Error {
2734
3869
  declare class MarkerCapabilityRequiredError extends Error {
2735
3870
  constructor();
2736
3871
  }
2737
- //#endregion
2738
- //#region src/tactical-draw/transform-box.d.ts
2739
- /**
2740
- * The Excalidraw/Felt-style transform box: the oriented bounding box drawn
2741
- * around a selection, with 4 corner scale handles, a rotate grip above the
2742
- * top edge, and drag-anywhere-inside-the-box translate. This module is the
2743
- * single source of truth for box *placement* (`fitTransformBox`,
2744
- * `boxCorners`, `rotateGripPixel`) AND box *picking* (`pointInBox`,
2745
- * `pickBoxHandle`) — mirroring the ADR-0016 discipline that keeps
2746
- * `handles.ts` owning vertex/midpoint placement/pick. Everything here is pure
2747
- * pixel-space math: no projection, no rendering, no session state.
2748
- *
2749
- * **Angle convention**: `angle` is in radians, measured in screen pixel space
2750
- * (y grows downward). A positive angle rotates the box clockwise as drawn on
2751
- * screen — the same convention `rotatePointsAround` (`handle-drag.ts`) uses,
2752
- * so box rotation and control-point rotation stay in lockstep.
2753
- *
2754
- * **Corner ordering**: `boxCorners` always returns
2755
- * `[topLeft, topRight, bottomRight, bottomLeft]` in the box's own (unrotated)
2756
- * local frame, then rotated into place. "Top" means the smaller-y edge before
2757
- * rotation — i.e. the edge the rotate grip floats above. The order is stable
2758
- * across calls so a scale handle's `index` (0–3) always means the same
2759
- * corner, and its opposite corner is always `(index + 2) % 4`.
2760
- */
2761
- interface TransformBox {
2762
- /** Box center, pixel space. */
2763
- center: PixelCoordinate;
2764
- /** Half-width along the box's local x-axis (pre-rotation), in pixels. */
2765
- halfWidth: number;
2766
- /** Half-height along the box's local y-axis (pre-rotation), in pixels. */
2767
- halfHeight: number;
2768
- /** Radians, screen space, positive = clockwise on screen. */
2769
- angle: number;
3872
+ declare class CollocationSupportRequiredError extends Error {
3873
+ constructor();
2770
3874
  }
2771
3875
  //#endregion
2772
3876
  //#region src/point-symbol-size.d.ts
@@ -2789,50 +3893,6 @@ interface ImageFootprint {
2789
3893
  }
2790
3894
  declare function imageFootprint(image: ImageGraphic, render: ImageRender, adapter: Pick<MapAdapter, "getBearing" | "getPixelFromCoordinate" | "getResolution">): ImageFootprint | null;
2791
3895
  //#endregion
2792
- //#region src/tactical-draw/note-rendering.d.ts
2793
- /**
2794
- * One Note's contribution to its atomic FeatureGroup (ADR-0066, ADR-0069):
2795
- * the note raster as an image overlay, then a transparent pick polygon over the full box.
2796
- * While pending, the polygon becomes a grey placeholder and there is no overlay.
2797
- * A fully faded Note has neither, so it can't be seen or picked.
2798
- */
2799
- interface NoteRenderPlan {
2800
- features: Feature[];
2801
- overlay?: ImageOverlayResource;
2802
- render: NoteRender;
2803
- }
2804
- interface NoteFootprint {
2805
- box: TransformBox;
2806
- corners: PixelCoordinate[];
2807
- }
2808
- /**
2809
- * Memo shared by every render of one `TacticalDraw`, so zooming within a
2810
- * density step reuses the resolved raster without calling the capability, and
2811
- * the 2048 px cap is sized from a Note's last known height.
2812
- */
2813
- interface NoteResolveCache {
2814
- /** Last ready box height in em per Note id. */
2815
- readonly heights: Map<string, number>;
2816
- /** Last ready raster per Note snapshot, with the density it was requested at. */
2817
- readonly rasters: WeakMap<NoteGraphic, {
2818
- pxPerEm: number;
2819
- raster: NoteRaster;
2820
- }>;
2821
- }
2822
- /** Screen-space box of a Note, for highlights, edit boxes and marquee hit tests. */
2823
- declare function noteFootprint(note: NoteGraphic, render: NoteRender, adapter: Pick<MapAdapter, "getBearing" | "getPixelFromCoordinate" | "getResolution">): NoteFootprint | null;
2824
- /**
2825
- * Resolve and render one Note. Validates the Note and the resolved raster first,
2826
- * so a malformed Note or raster throws before any caller state changes.
2827
- *
2828
- * The density requested from the capability follows the view (ADR-0069): the
2829
- * on-screen pixels per em, times the capability's pixel ratio, rounded up to a
2830
- * power of two and capped so the raster's longest side stays within
2831
- * {@link NOTE_MAX_RASTER_PIXELS}. The overlay fades over one step once an em
2832
- * is smaller on screen than the fade threshold, or once the cap stretches it.
2833
- */
2834
- declare function renderNoteForAdapter(adapter: Pick<MapAdapter, "getResolution" | "fromLonLat" | "toLonLat">, capability: NoteCapability, note: NoteGraphic, cache?: NoteResolveCache): NoteRenderPlan;
2835
- //#endregion
2836
3896
  //#region src/tactical-draw/marker-rendering.d.ts
2837
3897
  type MarkerFootprint = Omit<PointSymbolFootprint, "connector">;
2838
3898
  /** Resolve a marker's icon, substituting the built-in placeholder for unknown symbols. */
@@ -2840,6 +3900,14 @@ declare function resolveMarkerRender(capability: MarkerCapability, marker: Marke
2840
3900
  /** Complete rotated footprint for selection and transform chrome. */
2841
3901
  declare function markerFootprint(marker: Marker, render: MarkerRender, adapter: PointSymbolProjection): MarkerFootprint | null;
2842
3902
  //#endregion
3903
+ //#region src/hash.d.ts
3904
+ /**
3905
+ * A fast, stable 64-bit string hash for content-derived resource ids: two
3906
+ * independent 32-bit FNV-1a lanes (different offset bases and primes) over the
3907
+ * UTF-16 code units, as 14 base-36 digits. Not cryptographic.
3908
+ */
3909
+ declare function hashString(value: string): string;
3910
+ //#endregion
2843
3911
  //#region src/world-wrap.d.ts
2844
3912
  /**
2845
3913
  * Shift `lng` by whole world widths (360°) onto the copy nearest `refLng`.
@@ -2854,4 +3922,67 @@ declare function nearestWorldCopyLng(lng: number, refLng: number): number;
2854
3922
  /** `nearestWorldCopyLng` applied to a lon/lat position. */
2855
3923
  declare function nearestWorldCopyPosition(position: Position, refLng: number): Position;
2856
3924
  //#endregion
2857
- export { type AnchoredGraphic, BaseMapAdapter, type CombinedAbort, DEFAULT_EDIT_MODIFIERS, DEFAULT_LABEL_SIZE_PIXELS, DEFAULT_MARKER_SIZE, DEFAULT_PIN_PRESENTATION, DEFAULT_TEXT_SIZE_MAX_PIXELS, DEFAULT_TEXT_SIZE_MIN_PIXELS, type DeferredSnapProvider, type DrawImageDraft, type DrawMarkerDraft, type DrawMeasureDraft, type DrawNoteDraft, type DrawOptions, type DrawPointSymbolDraft, type DrawSession, type EditChangeEvent, type EditManyOptions, type EditMode, type EditModifiers, type EditOptions, type EditPointerDriver, type EditSession, type FeatureGroup, type FeatureHighlightBand, type Graphic, type GraphicEditChangeEvent, type GraphicEditSession, type GraphicGeometrySnappingOptions, type GraphicRender, type GraphicSnapshot, type GuideStyle, HATCH_PATTERNS, HIGHLIGHT_BAND_SLOTS, HIGHLIGHT_CASING_OUTSET_CSS_PIXELS, HIGHLIGHT_GLOW_BANDS, type HandleStyle, type HatchPattern, type HighlightBand, type HighlightBandSlot, type HighlightCasing, type HighlightedGroup, type IconResource, type ImageCapability, ImageCapabilityRequiredError, type ImageFootprint, type ImageGraphic, type ImageGraphicStyle, type ImageIntrinsicSize, type ImageOverlayResource, type ImageRender, type ImageResource, type ImageSize, type InteractionHit, type InteractionStyle, type LabelExtent, type LabelSizeBand, type LayerId, MINE_PATTERN_TILE_SIZE, type MapAdapter, type MapCursor, type MapEvent, type MapEventHandler, type Marker, type MarkerAnchor, type MarkerCapability, MarkerCapabilityRequiredError, type MarkerFootprint, type MarkerIcon, type MarkerRender, type MarkerSize, type MarkerStyle, type MergedPickFeature, type ModifierKey, NOTE_MAX_RASTER_PIXELS, NOTE_MAX_WIDTH, NOTE_MIN_WIDTH, type NativeEventEntry, type NoteBodyAlign, type NoteBodyStyle, type NoteCapability, NoteCapabilityRequiredError, type NoteEmSize, type NoteFadeThresholds, type NoteFontRoles, type NoteFootprint, type NoteFrame, type NoteFramePresetId, type NoteFrameTokenOverrides, type NoteGraphic, type NoteGraphicStyle, type NoteHeadingAlign, type NoteRaster, type NoteRender, type NoteStroke, type OffsetDragModifier, type PickCandidate, type PickCandidateHit, type PickCandidateHitKind, type PickCandidateInput, type PickEvaluationContext, type PickEvent, type PickHandler, type PickOptions, type PickPointerType, PinFootprint, PinOverridePatch, PinPresentation, PinPresentationCapability, PinPresentationPatch, PinPresentationState, PinPresentationStatus, PinPresentationStatusEvent, PinPresentationStore, PinRender, type PinnableGraphic, type PixelCoordinate, type PointSymbol, type PointSymbolAnchor, type PointSymbolCapability, PointSymbolCapabilityRequiredError, type PointSymbolColors, type PointSymbolConnector, type PointSymbolFootprint, type PointSymbolGraphicModifiers, type PointSymbolOffset, type PointSymbolOffsetControls, type PointSymbolOffsetLayout, type PointSymbolOffsetStyle, type PointSymbolPlacement, type PointSymbolProjection, type PointSymbolRect, type PointSymbolRender, type PointSymbolSize, type PointSymbolStyle, type PointSymbolView, type PointerCallback, PointerCallbackHub, type PointerEventInfo, type ResolvedEditModifiers, type ResolvedPickPresentation, type Rgba, type RotatedScreenBounds, type ScreenBounds, type SessionChangeSource, type SessionHistory, type SessionHistoryState, type SettleReason, type SizeAnchor, type SnapCandidate, type SnapCandidateProvider, type SnapCandidateRequest, type SnapInteraction, type SnapResult, type SnappingOptions, type StyleOptions, TEXT_FADE_END_RATIO, TEXT_HALO_BREAKPOINT_PIXELS, TEXT_HALO_COLOR, TOUCH_HIT_TOLERANCE_PX, TacticalDraw, TacticalDrawAbortError, type TacticalDrawAbortReason, TacticalDrawDestroyedError, type TacticalDrawLayerOptions, type TacticalDrawOptions, type TextAppearance, type TextSizeProps, type TextStyleOptions, type ToPixel, type TransformBox, type TransformChangeEvent, type TransformSession, type TransientChangeEvent, type TransientPhase, alignPointSymbolIndicator, bindAbortable, canResetGroundSizes, cloneImageGraphic, cloneMarker, cloneNoteGraphic, clonePointSymbol, coerceHandleStyle, combinePinScale, combineWithHostSignal, composeMarkerCapabilities, convertPointSymbolPlacement, effectivePointSymbolPixelSize, evaluatePickCandidates, fillPatternImageDimension, fillPatternImageId, getSizeAnchor, hasHighlightCasing, highlightBandsForStyle, highlightBandsInPaintOrder, highlightCasingWidth, hitTestFeature, hitTestIconFeature, ignoreAbort, imageFootprint, imageOpacity, isAnchoredGraphic, isImageGraphic, isMarker, isMinePattern, isNoteGraphic, isPinnableGraphic, isPointSymbol, isTacticalDrawAbortError, isValidPinNumber, makeFillPatternImage, markerFootprint, markerOpacity, mergeNativeAndCachedPickFeatures, movePointSymbolLocation, nearestWorldCopyLng, nearestWorldCopyPosition, normalizeImageGraphic, normalizeMarker, normalizeNoteGraphic, noteFootprint, noteOpacity, parseColor, pickHitTolerance, pickPointerType, pinDistanceScale, pinZoomScale, placePointSymbol, pointSymbolFootprint, pointSymbolResource, renderNoteForAdapter, renderOrderToVisualOrder, resetGroundSizeOptions, resizePointSymbolSize, resolveGroundTextSizePixels, resolveHighlightBands, resolveHighlightCasing, resolveMarkerRender, resolvePickPresentation, resolvePinPresentation, resolvePointSymbolOffset, resolveTextAppearance, resolveTextHaloWidth, resolveTextSizePixels, scalePointSymbolLayout, tryControlMeasureIdFromFeature, validateImageGraphic, validateMarker, validateNoteGraphic };
3925
+ //#region src/collocation-minimal-options.d.ts
3926
+ /** What {@link minimalCollocationOptions} compares against. */
3927
+ interface MinimalCollocationOptionsOptions {
3928
+ /**
3929
+ * The host's own defaults, for options it fills in differently from the
3930
+ * engine while they are unset, e.g. `{ line: { halo: { show: true } } }`. Laid over the engine's before resolving, so a value equal to
3931
+ * one of these goes and a value equal to the engine's own default stays.
3932
+ */
3933
+ defaults?: CollocationOptions;
3934
+ /**
3935
+ * Dotted paths, e.g. `"line.strokeColor"` or `"ground.ties"`, kept as given
3936
+ * whenever set, for host defaults that aren't fixed values (they follow the
3937
+ * map or the selection), so any value set there means something. A path
3938
+ * to an object keeps the whole object.
3939
+ */
3940
+ keep?: readonly string[];
3941
+ }
3942
+ /**
3943
+ * `options` without what makes no difference (#763), for a host that stores
3944
+ * collocation options: what it then stores stays small and picks up new
3945
+ * defaults. A value goes when {@link resolveCollocationOptions}, over the
3946
+ * host's `defaults` if given, resolves the same both with and without it, and
3947
+ * also resolves the same with only it set (its parents' other fields absent)
3948
+ * as without it. The second test keeps a value that only matches because of
3949
+ * another one, such as a `leader.strokeColor` equal to a non-default
3950
+ * `line.strokeColor`, so changing the other one later still leaves it set.
3951
+ * Object values are pruned key by key first and go, once emptied, only if
3952
+ * absent and empty resolve the same, as `gap: {}` and `bracket.plate: {}` do.
3953
+ * A hidden plate or tie keeps its style, since that resolves differently.
3954
+ *
3955
+ * Only values this engine reads as valid can go. Anything else is kept as
3956
+ * given, though it resolves to the default here: keys it doesn't know, enum
3957
+ * strings it doesn't know and values it can't read, any of which a newer
3958
+ * engine may have written, so an older one re-saving never loses them. So
3959
+ * are `memberOptions`, which the engine passes on unread, and the paths in
3960
+ * `keep`. A host reading a stored file drops malformed values first with
3961
+ * `sanitizeCollocationOptions`. `undefined` when nothing is left.
3962
+ * `options` itself is never changed.
3963
+ *
3964
+ * Collocation option defaults are frozen per `Collocation.schemaVersion`
3965
+ * (ADR-0063): what this function drops must mean the same to every engine
3966
+ * reading that version, so changing a default takes a `schemaVersion` bump
3967
+ * and a migration that writes the old default into stored options.
3968
+ */
3969
+ declare function minimalCollocationOptions(options: CollocationOptions | undefined, {
3970
+ defaults,
3971
+ keep
3972
+ }?: MinimalCollocationOptionsOptions): CollocationOptions | undefined;
3973
+ //#endregion
3974
+ //#region src/collocation-options-schema.d.ts
3975
+ /**
3976
+ * `options` read from a stored file, made safe to use: each malformed value
3977
+ * (a wrong type, `NaN`, a negative length where one can't be, an empty color)
3978
+ * is dropped on its own, its siblings kept, rather than throwing. Everything
3979
+ * well formed is kept as given, including keys and enum strings this engine
3980
+ * doesn't know, perhaps written by a newer one, so reading and re-saving a
3981
+ * file loses nothing. A bag emptied by dropping stays, as an empty bag
3982
+ * resolves like an absent one. `memberOptions` bags are kept whole; each
3983
+ * member kind's capability reads its own. `undefined` when `options` isn't an
3984
+ * object. Returns fresh objects; `options` itself is never changed.
3985
+ */
3986
+ declare function sanitizeCollocationOptions(options: unknown): CollocationOptions | undefined;
3987
+ //#endregion
3988
+ export { type AnchoredGraphic, BaseMapAdapter, type BuildCollocationRenderOptions, COLLOCATION_BRACKET_OVERHANG, COLLOCATION_CLEARANCE, COLLOCATION_HALO_EXTRA, COLLOCATION_REMOVE_DISTANCE, COLLOCATION_SCREEN_RELATIVE_REACH, type Collocation, type CollocationAreaStyle, type CollocationBracketPlacement, type CollocationBracketShape, type CollocationBracketSide, type CollocationCommit, type CollocationCommitChanges, type CollocationDropSlot, type CollocationDropTarget, type CollocationDropTargetOptions, type CollocationEditChangeEvent, type CollocationEditSession, type CollocationFootprint, type CollocationFootprintRect, type CollocationGround, type CollocationGroundLayout, type CollocationGroundMark, type CollocationHalo, type CollocationLayout, type CollocationLocate, type CollocationMarker, type CollocationMember, type CollocationMemberCapabilities, type CollocationMemberGraphic, type CollocationMemberIcon, type CollocationMemberLayout, type CollocationMemberOptionTypes, type CollocationMemberOptions, type CollocationMemberRender, type CollocationMemberRenderContext, type CollocationMemberSupport, type CollocationOptions, type CollocationPart, type CollocationPartControls, type CollocationPartDrag, type CollocationPartLayout, type CollocationPlate, type CollocationPointSymbol, type CollocationRender, type CollocationRenderMember, type CollocationSpreadStyle, type CollocationStroke, type CollocationStyle, type CollocationSupport, type CollocationSupportOptions, CollocationSupportRequiredError, type CollocationTransform, type CollocationTransientChangeEvent, type CombinedAbort, DEFAULT_EDIT_MODIFIERS, DEFAULT_LABEL_SIZE_PIXELS, DEFAULT_MARKER_SIZE, DEFAULT_PIN_PRESENTATION, DEFAULT_TEXT_SIZE_MAX_PIXELS, DEFAULT_TEXT_SIZE_MIN_PIXELS, type DeferredSnapProvider, type DrawImageDraft, type DrawMarkerDraft, type DrawMeasureDraft, type DrawNoteDraft, type DrawOptions, type DrawPointSymbolDraft, type DrawSession, type EditChangeEvent, type EditManyOptions, type EditMode, type EditModifiers, type EditOptions, type EditPointerDriver, type EditSession, type FeatureGroup, type FeatureHighlightBand, type Graphic, type GraphicEditChangeEvent, type GraphicEditSession, type GraphicGeometrySnappingOptions, type GraphicRender, type GraphicSnapshot, type GroupOffsetDrag, type GroupOffsetDragHandler, type GuideStyle, HATCH_PATTERNS, HIGHLIGHT_BAND_SLOTS, HIGHLIGHT_CASING_OUTSET_CSS_PIXELS, HIGHLIGHT_GLOW_BANDS, HIT_AREA_PROPERTY, type HandleStyle, type HatchPattern, type HighlightBand, type HighlightBandSlot, type HighlightCasing, type HighlightedGroup, ICON_OFFSET_PROPERTY, ICON_SCREEN_ROTATION_PROPERTY, type IconHitLine, type IconResource, type ImageCapability, ImageCapabilityRequiredError, type ImageFootprint, type ImageGraphic, type ImageGraphicStyle, type ImageIntrinsicSize, type ImageOverlayResource, type ImageRender, type ImageResource, type ImageSize, type InteractionHit, type InteractionStyle, type LabelExtent, type LabelSizeBand, type LayerId, MINE_PATTERN_TILE_SIZE, type MapAdapter, type MapCursor, type MapEvent, type MapEventHandler, type Marker, type MarkerAnchor, type MarkerCapability, MarkerCapabilityRequiredError, type MarkerFootprint, type MarkerIcon, type MarkerRender, type MarkerSize, type MarkerStyle, type MergedPickFeature, type MinimalCollocationOptionsOptions, type ModifierKey, NOTE_MAX_RASTER_PIXELS, NOTE_MAX_WIDTH, NOTE_MIN_WIDTH, type NativeEventEntry, type NoteBodyAlign, type NoteBodyStyle, type NoteCapability, NoteCapabilityRequiredError, type NoteEmSize, type NoteFadeThresholds, type NoteFontRoles, type NoteFootprint, type NoteFrame, type NoteFramePresetId, type NoteFrameTokenOverrides, type NoteGraphic, type NoteGraphicStyle, type NoteHeadingAlign, type NoteRaster, type NoteRender, type NoteStroke, type OffsetDragModifier, type OffsetDrop, type OffsetDropHandler, type PartialCollocationTarget, type PassiveOutlineTarget, type PickCandidate, type PickCandidateHit, type PickCandidateHitKind, type PickCandidateInput, type PickEvaluationContext, type PickEvent, type PickHandler, type PickModifiers, type PickOptions, type PickPointerType, PinFootprint, PinOverridePatch, PinPresentation, PinPresentationCapability, PinPresentationPatch, PinPresentationState, PinPresentationStatus, PinPresentationStatusEvent, PinPresentationStore, PinRender, type PinnableGraphic, type PixelCoordinate, type PointSymbol, type PointSymbolAnchor, type PointSymbolCapability, PointSymbolCapabilityRequiredError, type PointSymbolColors, type PointSymbolConnector, type PointSymbolFootprint, type PointSymbolGraphicModifiers, type PointSymbolOffset, type PointSymbolOffsetControls, type PointSymbolOffsetLayout, type PointSymbolOffsetStyle, type PointSymbolPlacement, type PointSymbolProjection, type PointSymbolRect, type PointSymbolRender, type PointSymbolSize, type PointSymbolStyle, type PointSymbolView, type PointerCallback, PointerCallbackHub, type PointerEventInfo, type ResolveCollocationTransform, type ResolvedCollocationMemberRender, type ResolvedCollocationOptions, type ResolvedCollocationPlate, type ResolvedCollocationStroke, type ResolvedEditModifiers, type ResolvedPickPresentation, type Rgba, type RotatedScreenBounds, type ScreenBounds, type SessionChangeSource, type SessionHistory, type SessionHistoryState, type SettleReason, type SizeAnchor, type SnapCandidate, type SnapCandidateProvider, type SnapCandidateRequest, type SnapInteraction, type SnapResult, type SnappingOptions, type StyleOptions, TEXT_FADE_END_RATIO, TEXT_HALO_BREAKPOINT_PIXELS, TEXT_HALO_COLOR, TOUCH_HIT_TOLERANCE_PX, TacticalDraw, TacticalDrawAbortError, type TacticalDrawAbortReason, TacticalDrawDestroyedError, type TacticalDrawLayerOptions, type TacticalDrawOptions, type TacticalDrawPickEvent, type TacticalDrawPickHandler, type TextAppearance, type TextSizeProps, type TextStyleOptions, type ToPixel, type TransformBox, type TransformChangeEvent, type TransformSession, type TransformTarget, type TransientChangeEvent, type TransientPhase, alignPointSymbolIndicator, bindAbortable, buildCollocationLayout, buildCollocationRender, canResetGroundSizes, cloneCollocation, cloneImageGraphic, cloneMarker, cloneNoteGraphic, clonePointSymbol, coerceHandleStyle, collocationDropTarget, collocationFootprint, collocationLeaderStrokes, collocationMemberPart, collocationOpacity, collocationScale, combinePinScale, combineWithHostSignal, composeMarkerCapabilities, convertPointSymbolPlacement, createCollocationSupport, effectivePointSymbolPixelSize, evaluatePickCandidates, fillPatternImageDimension, fillPatternImageId, getSizeAnchor, hasHighlightCasing, hashString, highlightBandsForStyle, highlightBandsInPaintOrder, highlightCasingWidth, hitTestFeature, hitTestIconFeature, ignoreAbort, imageFootprint, imageOpacity, insertCollocationMembers, isAnchoredGraphic, isCollocation, isControlMeasureGraphic, isHitArea, isImageGraphic, isMarker, isMinePattern, isNoteGraphic, isPartialCollocationTarget, isPinnableGraphic, isPointSymbol, isTacticalDrawAbortError, isValidPinNumber, layoutCollocation, makeFillPatternImage, markerFootprint, markerOpacity, mergeNativeAndCachedPickFeatures, minimalCollocationOptions, moveCollocationMember, movePointSymbolLocation, nearestWorldCopyLng, nearestWorldCopyPosition, normalizeCollocation, normalizeImageGraphic, normalizeMarker, normalizeNoteGraphic, noteFootprint, noteOpacity, parseColor, patchCollocationOptions, pickHitTolerance, pickPointerType, pinDistanceScale, pinZoomScale, placePointSymbol, pointSymbolFootprint, pointSymbolResource, readPickModifiers, renderNoteForAdapter, renderOrderToVisualOrder, resetGroundSizeOptions, resizePointSymbolSize, resolveCollocationLocation, resolveCollocationOptions, resolveCollocationSize, resolveGroundTextSizePixels, resolveHighlightBands, resolveHighlightCasing, resolveIconAnchor, resolveIconOffset, resolveIconScreenRotation, resolveMarkerRender, resolvePickPresentation, resolvePinPresentation, resolvePointSymbolOffset, resolveTextAppearance, resolveTextHaloWidth, resolveTextSizePixels, sanitizeCollocationOptions, scalePointSymbolLayout, stableCollocation, transformCollocation, tryControlMeasureIdFromFeature, validateCollocation, validateImageGraphic, validateMarker, validateNoteGraphic };