@seatmap-fyi/map-domain 0.1.0-alpha.2 → 0.1.0-alpha.29

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.
Files changed (62) hide show
  1. package/dist/catalog.d.ts +10 -3
  2. package/dist/catalog.js +66 -10
  3. package/dist/categories.d.ts +26 -0
  4. package/dist/categories.js +168 -0
  5. package/dist/editor-state.d.ts +49 -0
  6. package/dist/editor-state.js +266 -0
  7. package/dist/floors.d.ts +19 -0
  8. package/dist/floors.js +68 -0
  9. package/dist/geometry/boundary.d.ts +1 -1
  10. package/dist/geometry/boundary.js +10 -12
  11. package/dist/geometry/curve-warnings.d.ts +1 -1
  12. package/dist/geometry/curve-warnings.js +3 -5
  13. package/dist/geometry/decoration-bounds.d.ts +4 -0
  14. package/dist/geometry/decoration-bounds.js +42 -0
  15. package/dist/geometry/ellipse.js +4 -12
  16. package/dist/geometry/geometry.d.ts +12 -3
  17. package/dist/geometry/geometry.js +35 -26
  18. package/dist/geometry/polygon-curves.d.ts +12 -0
  19. package/dist/geometry/polygon-curves.js +132 -0
  20. package/dist/geometry/primitives.d.ts +1 -1
  21. package/dist/geometry/primitives.js +2 -3
  22. package/dist/geometry/seat-shape.d.ts +24 -0
  23. package/dist/geometry/seat-shape.js +101 -0
  24. package/dist/geometry/seating-layout.d.ts +14 -3
  25. package/dist/geometry/seating-layout.js +91 -19
  26. package/dist/geometry/units.d.ts +1 -0
  27. package/dist/geometry/units.js +2 -0
  28. package/dist/geometry/venue-outline.d.ts +2 -2
  29. package/dist/geometry/venue-outline.js +8 -21
  30. package/dist/identity.d.ts +4 -1
  31. package/dist/identity.js +36 -10
  32. package/dist/issues.d.ts +9 -2
  33. package/dist/issues.js +8 -6
  34. package/dist/labels.d.ts +12 -1
  35. package/dist/labels.js +76 -11
  36. package/dist/layers.d.ts +26 -0
  37. package/dist/layers.js +86 -0
  38. package/dist/media.d.ts +27 -0
  39. package/dist/media.js +89 -0
  40. package/dist/physical-document.interface.d.ts +518 -0
  41. package/dist/{types.js → physical-document.interface.js} +71 -0
  42. package/dist/preview.d.ts +1 -1
  43. package/dist/preview.js +65 -24
  44. package/dist/reference.js +1 -1
  45. package/dist/row-segments.d.ts +30 -0
  46. package/dist/row-segments.js +112 -0
  47. package/dist/schema.d.ts +1192 -68
  48. package/dist/schema.js +372 -96
  49. package/dist/seat-proximity.d.ts +4 -0
  50. package/dist/seat-proximity.js +119 -0
  51. package/dist/sections.d.ts +23 -0
  52. package/dist/sections.js +149 -0
  53. package/dist/selling.d.ts +34 -0
  54. package/dist/selling.js +148 -0
  55. package/dist/spacing-repairs.d.ts +31 -0
  56. package/dist/spacing-repairs.js +168 -0
  57. package/dist/table-layout.d.ts +29 -0
  58. package/dist/table-layout.js +134 -0
  59. package/dist/validation.d.ts +3 -1
  60. package/dist/validation.js +124 -74
  61. package/package.json +59 -3
  62. package/dist/types.d.ts +0 -313
@@ -0,0 +1,4 @@
1
+ import { type DomainIssue } from "./issues.js";
2
+ import { type PhysicalDocumentV1 } from "./physical-document.interface.js";
3
+ /** Marker contact is permitted; clearance advice never blocks publishing or marks inventory invalid. */
4
+ export declare function seatProximityIssues(document: PhysicalDocumentV1): readonly DomainIssue[];
@@ -0,0 +1,119 @@
1
+ import { documentGroupSeats } from "./catalog.js";
2
+ import { IssueCode, IssueSeverity, issue } from "./issues.js";
3
+ import { rowBookingLabel, inventoryName } from "./labels.js";
4
+ import { sectionCatalog } from "./sections.js";
5
+ import { SeatingKind } from "./physical-document.interface.js";
6
+ import { project, worldMatrices } from "./geometry/geometry.js";
7
+ import { LayoutUnitM } from "./geometry/units.js";
8
+ const seatClearanceM = 20.7 * LayoutUnitM;
9
+ const contactToleranceM = 1e-9;
10
+ const findings = new WeakMap();
11
+ /** Project physical parts once; names and review targets keep their booking identity. */
12
+ function inventorySeats(document) {
13
+ const result = [];
14
+ const sections = sectionCatalog(document);
15
+ const labels = new Map(document.sections.map((section) => [section.id, section.label]));
16
+ const matrices = worldMatrices(document);
17
+ let nextOwner = 0;
18
+ for (const group of document.seatingGroups) {
19
+ const owners = new Map();
20
+ const rows = group.kind === SeatingKind.Straight || group.kind === SeatingKind.Curved;
21
+ const ids = rows ? group.rows.map((row) => row.id) : [group.id];
22
+ for (const [index, id] of ids.entries()) {
23
+ const sectionId = sections.owners.get(id);
24
+ const label = rows ? rowBookingLabel(group, index) : inventoryName(group.labels);
25
+ owners.set(id, {
26
+ index: nextOwner++,
27
+ id,
28
+ name: `${rows ? "Row" : "Table"} “${label}”${sectionId ? ` in “${labels.get(sectionId)}”` : ""}`,
29
+ floorId: group.floorId ?? null,
30
+ });
31
+ }
32
+ const world = matrices.get(group.id);
33
+ for (const seat of documentGroupSeats(document, group)) {
34
+ if (seat.slot.gap)
35
+ continue;
36
+ result.push({
37
+ ...project(world, seat.position),
38
+ owner: owners.get(seat.rowId ?? group.id),
39
+ diameter: Math.min(seat.size.width, seat.size.height),
40
+ });
41
+ }
42
+ }
43
+ return result;
44
+ }
45
+ /** Adjacent cells bound regular layouts; each physical owner pair contributes one nearest finding. */
46
+ function nearbyPairs(seats) {
47
+ const cellSize = seats.reduce((size, seat) => Math.max(size, seat.diameter), seatClearanceM);
48
+ const cells = new Map();
49
+ const pairs = new Map();
50
+ const compare = (first, second) => {
51
+ const distance = Math.hypot(first.x - second.x, first.y - second.y);
52
+ const overlapDistance = (first.diameter + second.diameter) / 2;
53
+ const overlapping = distance < overlapDistance - contactToleranceM;
54
+ if (!overlapping && distance >= seatClearanceM)
55
+ return;
56
+ const later = first.owner.index >= second.owner.index ? first.owner : second.owner;
57
+ const earlier = first.owner.index >= second.owner.index ? second.owner : first.owner;
58
+ const key = `${later.index}:${earlier.index}`;
59
+ const previous = pairs.get(key);
60
+ if (previous &&
61
+ ((previous.overlapping && !overlapping) ||
62
+ (previous.overlapping === overlapping && previous.distance <= distance)))
63
+ return;
64
+ pairs.set(key, { first: later, second: earlier, distance, overlapDistance, overlapping });
65
+ };
66
+ for (const seat of seats) {
67
+ const x = Math.floor(seat.x / cellSize);
68
+ const y = Math.floor(seat.y / cellSize);
69
+ const floor = seat.owner.floorId ?? "";
70
+ for (let dy = -1; dy <= 1; dy++) {
71
+ for (let dx = -1; dx <= 1; dx++) {
72
+ for (const previous of cells.get(`${floor}:${x + dx}:${y + dy}`) ?? [])
73
+ compare(seat, previous);
74
+ }
75
+ }
76
+ const key = `${floor}:${x}:${y}`;
77
+ const cell = cells.get(key);
78
+ if (cell)
79
+ cell.push(seat);
80
+ else
81
+ cells.set(key, [seat]);
82
+ }
83
+ return [...pairs.values()].sort((a, b) => {
84
+ return a.first.index - b.first.index || a.second.index - b.second.index;
85
+ });
86
+ }
87
+ /** Marker contact is permitted; clearance advice never blocks publishing or marks inventory invalid. */
88
+ export function seatProximityIssues(document) {
89
+ const cached = findings.get(document);
90
+ if (cached)
91
+ return cached;
92
+ const result = nearbyPairs(inventorySeats(document)).map((pair) => {
93
+ const sameOwner = pair.first === pair.second;
94
+ let code;
95
+ let message;
96
+ if (pair.overlapping) {
97
+ code = IssueCode.SeatOverlap;
98
+ message = sameOwner
99
+ ? `${pair.first.name} has overlapping seats`
100
+ : `${pair.first.name} and ${pair.second.name} overlap`;
101
+ }
102
+ else {
103
+ code = IssueCode.SeatCramped;
104
+ message = sameOwner
105
+ ? `${pair.first.name} has seats too close together`
106
+ : `${pair.first.name} and ${pair.second.name} are too close together`;
107
+ }
108
+ return {
109
+ ...issue(code, message, sameOwner ? [pair.first.id] : [pair.first.id, pair.second.id]),
110
+ severity: IssueSeverity.Warning,
111
+ blocks: [],
112
+ description: pair.overlapping
113
+ ? `The closest seats are ${pair.distance.toFixed(2)} m apart, so their markers overlap on the buyer map; at least ${pair.overlapDistance.toFixed(2)} m keeps them apart.`
114
+ : `The closest seats are ${pair.distance.toFixed(2)} m apart; at least ${seatClearanceM.toFixed(2)} m is needed.`,
115
+ };
116
+ });
117
+ findings.set(document, result);
118
+ return result;
119
+ }
@@ -0,0 +1,23 @@
1
+ import { type PhysicalDocumentV1, type UUID } from "./physical-document.interface.js";
2
+ export type SectionEntry = {
3
+ /** Physical rows, tables, areas and artwork editable in this workspace. */
4
+ editableObjects: ReadonlySet<UUID>;
5
+ /** Also includes bank and collection ancestors needed to render those objects. */
6
+ renderMembers: ReadonlySet<UUID>;
7
+ /** Primary inventory only; overlapping workspaces do not count it twice. */
8
+ inventory: ReadonlySet<UUID>;
9
+ capacity: {
10
+ physicalSeats: number;
11
+ gaQuantity: number;
12
+ };
13
+ };
14
+ export type SectionCatalog = {
15
+ entries: ReadonlyMap<UUID, SectionEntry>;
16
+ /** Physical inventory owners; complete banks also expose their common owner. */
17
+ owners: ReadonlyMap<UUID, UUID>;
18
+ };
19
+ /**
20
+ * Spatial inventory boundaries own their first-contained anchors. Overview-only and
21
+ * outline-free sections retain their explicit inventory grouping, independently of artwork geometry.
22
+ */
23
+ export declare function sectionCatalog(document: PhysicalDocumentV1): SectionCatalog;
@@ -0,0 +1,149 @@
1
+ import { polygonContour } from "./geometry/polygon-curves.js";
2
+ import { BoundaryLocation, BoundaryToleranceM, classifyBoundary, prepareBoundary } from "./geometry/boundary.js";
3
+ import { decorationBounds } from "./geometry/decoration-bounds.js";
4
+ import { generatedSeats, emptyBounds, extend, pointsBounds, project, worldMatrices, } from "./geometry/geometry.js";
5
+ import { AreaKind, ShapeKind, SectionOutlineRole, DecorationKind, } from "./physical-document.interface.js";
6
+ const catalogs = new WeakMap();
7
+ /**
8
+ * Spatial inventory boundaries own their first-contained anchors. Overview-only and
9
+ * outline-free sections retain their explicit inventory grouping, independently of artwork geometry.
10
+ */
11
+ export function sectionCatalog(document) {
12
+ const cached = catalogs.get(document);
13
+ if (cached)
14
+ return cached;
15
+ const entries = new Map();
16
+ const owners = new Map();
17
+ const catalog = { entries, owners };
18
+ if (!document.sections.length) {
19
+ catalogs.set(document, catalog);
20
+ return catalog;
21
+ }
22
+ const matrices = worldMatrices(document);
23
+ const anchors = [];
24
+ for (const group of document.seatingGroups) {
25
+ const matrix = matrices.get(group.id);
26
+ const seats = generatedSeats(group);
27
+ if (!("rows" in group)) {
28
+ anchors.push({
29
+ id: group.id,
30
+ floorId: group.floorId ?? null,
31
+ point: project(matrix, { x: 0, y: 0 }),
32
+ parentId: group.parentId,
33
+ declaredSectionId: group.sectionId,
34
+ capacity: { physicalSeats: seats.filter((seat) => !seat.slot.gap).length, gaQuantity: 0 },
35
+ });
36
+ continue;
37
+ }
38
+ const rows = new Map();
39
+ for (const seat of seats) {
40
+ const rowId = seat.rowId;
41
+ const row = rows.get(rowId) ?? { bounds: emptyBounds(), seats: 0 };
42
+ extend(row.bounds, project(matrix, seat.position));
43
+ if (!seat.slot.gap)
44
+ row.seats++;
45
+ rows.set(rowId, row);
46
+ }
47
+ for (const row of group.rows) {
48
+ const geometry = rows.get(row.id);
49
+ anchors.push({
50
+ id: row.id,
51
+ floorId: group.floorId ?? null,
52
+ point: center(geometry.bounds),
53
+ groupId: group.id,
54
+ parentId: group.parentId,
55
+ declaredSectionId: group.sectionId,
56
+ capacity: { physicalSeats: geometry.seats, gaQuantity: 0 },
57
+ });
58
+ }
59
+ }
60
+ for (const area of document.areas) {
61
+ const matrix = matrices.get(area.id);
62
+ const point = area.shape.kind === ShapeKind.Polygon
63
+ ? center(pointsBounds(polygonContour(area.shape.boundary).outer.map((point) => project(matrix, point))))
64
+ : project(matrix, { x: 0, y: 0 });
65
+ anchors.push({
66
+ id: area.id,
67
+ floorId: area.floorId ?? null,
68
+ point,
69
+ parentId: area.parentId,
70
+ declaredSectionId: area.sectionId,
71
+ capacity: {
72
+ physicalSeats: area.kind === AreaKind.Booth ? 1 : 0,
73
+ gaQuantity: area.kind === AreaKind.GeneralAdmission ? area.capacity : 0,
74
+ },
75
+ });
76
+ }
77
+ for (const art of document.decorations) {
78
+ const matrix = matrices.get(art.id);
79
+ const point = art.kind === DecorationKind.Line
80
+ ? project(matrix, art.pointsM.reduce((sum, point) => ({
81
+ x: sum.x + point.x / art.pointsM.length,
82
+ y: sum.y + point.y / art.pointsM.length,
83
+ }), { x: 0, y: 0 }))
84
+ : center(decorationBounds(art, matrix));
85
+ anchors.push({
86
+ id: art.id,
87
+ floorId: art.floorId ?? null,
88
+ point,
89
+ parentId: art.parentId,
90
+ });
91
+ }
92
+ const collections = new Map(document.collections.map((collection) => [collection.id, collection]));
93
+ for (const section of document.sections) {
94
+ const editableObjects = new Set();
95
+ const renderMembers = new Set([section.id]);
96
+ const inventory = new Set();
97
+ const capacity = { physicalSeats: 0, gaQuantity: 0 };
98
+ entries.set(section.id, { editableObjects, renderMembers, inventory, capacity });
99
+ const spatial = section.outline && (section.outlineRole ?? SectionOutlineRole.Boundary) === SectionOutlineRole.Boundary;
100
+ const boundary = spatial ? prepareBoundary(section.outline) : null;
101
+ for (const anchor of anchors) {
102
+ if (anchor.floorId !== (section.floorId ?? null))
103
+ continue;
104
+ if (boundary) {
105
+ if (!withinBounds(boundary.bounds, anchor.point) ||
106
+ classifyBoundary(boundary, anchor.point) === BoundaryLocation.Outside)
107
+ continue;
108
+ }
109
+ else if (anchor.declaredSectionId !== section.id)
110
+ continue;
111
+ editableObjects.add(anchor.id);
112
+ renderMembers.add(anchor.id);
113
+ if (anchor.groupId)
114
+ renderMembers.add(anchor.groupId);
115
+ addCollectionAncestors(renderMembers, anchor.parentId, collections);
116
+ if (anchor.capacity && !owners.has(anchor.id)) {
117
+ owners.set(anchor.id, section.id);
118
+ inventory.add(anchor.id);
119
+ capacity.physicalSeats += anchor.capacity.physicalSeats;
120
+ capacity.gaQuantity += anchor.capacity.gaQuantity;
121
+ }
122
+ }
123
+ }
124
+ for (const group of document.seatingGroups) {
125
+ if (!("rows" in group))
126
+ continue;
127
+ const owner = owners.get(group.rows[0].id);
128
+ if (owner && group.rows.every((row) => owners.get(row.id) === owner))
129
+ owners.set(group.id, owner);
130
+ }
131
+ catalogs.set(document, catalog);
132
+ return catalog;
133
+ }
134
+ function center(bounds) {
135
+ return { x: (bounds.minX + bounds.maxX) / 2, y: (bounds.minY + bounds.maxY) / 2 };
136
+ }
137
+ function withinBounds(bounds, point) {
138
+ return (point.x >= bounds.minX - BoundaryToleranceM &&
139
+ point.x <= bounds.maxX + BoundaryToleranceM &&
140
+ point.y >= bounds.minY - BoundaryToleranceM &&
141
+ point.y <= bounds.maxY + BoundaryToleranceM);
142
+ }
143
+ function addCollectionAncestors(members, parentId, collections) {
144
+ let id = parentId;
145
+ while (id) {
146
+ members.add(id);
147
+ id = collections.get(id).parentId;
148
+ }
149
+ }
@@ -0,0 +1,34 @@
1
+ import { SeatingKind, TableBookingMode, StandingBookingMode, AreaKind, type SeatingGroup, type InventoryArea, type SeatSlot } from "./physical-document.interface.js";
2
+ export type TableInventory = Extract<SeatingGroup, {
3
+ kind: SeatingKind.Round | SeatingKind.Rectangular;
4
+ }>;
5
+ export type StandingInventory = Extract<InventoryArea, {
6
+ kind: AreaKind.GeneralAdmission;
7
+ }>;
8
+ export declare const StandingPartyLimit = 100;
9
+ export declare const StandingCapacityLimit = 100000;
10
+ /** An explicitly cleared tag still owns settings until Reset, as in the reference editor. */
11
+ export declare function seatHasOwnSettings(slot: SeatSlot): boolean;
12
+ export declare function tableSellingState(table: TableInventory): Readonly<{
13
+ mode: TableBookingMode;
14
+ chairCount: number;
15
+ hasPersonalSettings: boolean;
16
+ minGuests: number;
17
+ maxGuests: number;
18
+ }>;
19
+ export declare function tableSellingValid(table: TableInventory): boolean;
20
+ export declare function setTableBookingMode(table: TableInventory, mode: TableBookingMode): TableInventory;
21
+ export declare function resizeTableSelling(table: TableInventory): TableInventory;
22
+ export declare function setTablePartySize(table: TableInventory, field: "min" | "max", value: number): TableInventory;
23
+ export declare function tableAllowsChairEditing(group: SeatingGroup): boolean;
24
+ export declare function standingSellingState(area: StandingInventory): {
25
+ mode: StandingBookingMode;
26
+ wheelchairPlaces: number;
27
+ minGuests: number;
28
+ maxGuests: number;
29
+ };
30
+ export declare function standingSellingValid(area: StandingInventory): boolean;
31
+ export declare function setStandingBookingMode(area: StandingInventory, mode: StandingBookingMode): StandingInventory;
32
+ export declare function setStandingCapacity(area: StandingInventory, requested: number): StandingInventory;
33
+ export declare function setStandingPartySize(area: StandingInventory, field: "min" | "max", value: number): StandingInventory;
34
+ export declare function setStandingWheelchairPlaces(area: StandingInventory, requested: number): StandingInventory;
@@ -0,0 +1,148 @@
1
+ import { SeatingKind, TableBookingMode, StandingBookingMode, AreaKind, } from "./physical-document.interface.js";
2
+ export const StandingPartyLimit = 100;
3
+ export const StandingCapacityLimit = 100_000;
4
+ /** An explicitly cleared tag still owns settings until Reset, as in the reference editor. */
5
+ export function seatHasOwnSettings(slot) {
6
+ return Object.entries(slot).some(([key, value]) => key !== "id" && value !== undefined);
7
+ }
8
+ const tableStates = new WeakMap();
9
+ export function tableSellingState(table) {
10
+ const cached = tableStates.get(table);
11
+ if (cached)
12
+ return cached;
13
+ const sides = table.kind === SeatingKind.Round ? [table.chairs] : Object.values(table.chairsBySide);
14
+ let chairCount = 0, hasPersonalSettings = false;
15
+ for (const chairs of sides) {
16
+ chairCount += chairs.length;
17
+ if (!hasPersonalSettings)
18
+ hasPersonalSettings = chairs.some(seatHasOwnSettings);
19
+ }
20
+ const party = table.selling?.mode === TableBookingMode.Party ? table.selling : undefined;
21
+ const state = Object.freeze({
22
+ mode: table.selling?.mode ?? TableBookingMode.Individual,
23
+ chairCount,
24
+ hasPersonalSettings,
25
+ minGuests: party?.minGuests ?? 1,
26
+ maxGuests: party?.maxGuests ?? chairCount,
27
+ });
28
+ tableStates.set(table, state);
29
+ return state;
30
+ }
31
+ function resizedRange(range, capacity) {
32
+ const maxGuests = Math.min(capacity, range.maxGuests);
33
+ return { minGuests: Math.min(range.minGuests, maxGuests), maxGuests };
34
+ }
35
+ function editedRange(range, capacity, field, value) {
36
+ const current = resizedRange(range, capacity);
37
+ return field === "min"
38
+ ? {
39
+ ...current,
40
+ minGuests: Math.max(1, Math.min(current.maxGuests, Math.round(value))),
41
+ }
42
+ : {
43
+ ...current,
44
+ maxGuests: Math.max(current.minGuests, Math.min(capacity, Math.round(value))),
45
+ };
46
+ }
47
+ export function tableSellingValid(table) {
48
+ const state = tableSellingState(table);
49
+ if (state.mode !== TableBookingMode.Individual && state.hasPersonalSettings)
50
+ return false;
51
+ return state.minGuests >= 1 && state.minGuests <= state.maxGuests && state.maxGuests <= state.chairCount;
52
+ }
53
+ export function setTableBookingMode(table, mode) {
54
+ const state = tableSellingState(table);
55
+ if (state.mode === mode || (mode !== TableBookingMode.Individual && state.hasPersonalSettings))
56
+ return table;
57
+ const selling = mode === TableBookingMode.Individual
58
+ ? undefined
59
+ : mode === TableBookingMode.Party
60
+ ? { mode, minGuests: 1, maxGuests: state.chairCount }
61
+ : { mode };
62
+ return { ...table, selling };
63
+ }
64
+ export function resizeTableSelling(table) {
65
+ if (table.selling?.mode !== TableBookingMode.Party)
66
+ return table;
67
+ const range = resizedRange(table.selling, tableSellingState(table).chairCount);
68
+ if (range.minGuests === table.selling.minGuests && range.maxGuests === table.selling.maxGuests)
69
+ return table;
70
+ return { ...table, selling: { ...table.selling, ...range } };
71
+ }
72
+ export function setTablePartySize(table, field, value) {
73
+ if (table.selling?.mode !== TableBookingMode.Party)
74
+ return table;
75
+ const range = editedRange(table.selling, tableSellingState(table).chairCount, field, value);
76
+ if (range.minGuests === table.selling.minGuests && range.maxGuests === table.selling.maxGuests)
77
+ return table;
78
+ return { ...table, selling: { ...table.selling, ...range } };
79
+ }
80
+ export function tableAllowsChairEditing(group) {
81
+ return (group.kind === SeatingKind.Straight ||
82
+ group.kind === SeatingKind.Curved ||
83
+ tableSellingState(group).mode === TableBookingMode.Individual);
84
+ }
85
+ export function standingSellingState(area) {
86
+ const party = area.selling?.mode === StandingBookingMode.Party ? area.selling : undefined;
87
+ return {
88
+ mode: area.selling?.mode ?? StandingBookingMode.Standing,
89
+ wheelchairPlaces: area.selling?.wheelchairPlaces ?? 0,
90
+ minGuests: party?.minGuests ?? 1,
91
+ maxGuests: party?.maxGuests ?? area.capacity,
92
+ };
93
+ }
94
+ export function standingSellingValid(area) {
95
+ const state = standingSellingState(area);
96
+ return (state.wheelchairPlaces <= area.capacity &&
97
+ (state.mode === StandingBookingMode.Standing || area.capacity <= StandingPartyLimit) &&
98
+ state.minGuests >= 1 &&
99
+ state.minGuests <= state.maxGuests &&
100
+ state.maxGuests <= area.capacity);
101
+ }
102
+ function standingConfiguration(mode, wheelchairPlaces, range) {
103
+ if (mode === StandingBookingMode.Standing && wheelchairPlaces === 0)
104
+ return undefined;
105
+ return mode === StandingBookingMode.Party ? { mode, wheelchairPlaces, ...range } : { mode, wheelchairPlaces };
106
+ }
107
+ export function setStandingBookingMode(area, mode) {
108
+ const state = standingSellingState(area);
109
+ if (state.mode === mode || (mode !== StandingBookingMode.Standing && area.capacity > StandingPartyLimit))
110
+ return area;
111
+ return {
112
+ ...area,
113
+ selling: standingConfiguration(mode, state.wheelchairPlaces, {
114
+ minGuests: 1,
115
+ maxGuests: area.capacity,
116
+ }),
117
+ };
118
+ }
119
+ export function setStandingCapacity(area, requested) {
120
+ const state = standingSellingState(area);
121
+ const limit = state.mode === StandingBookingMode.Standing ? StandingCapacityLimit : StandingPartyLimit;
122
+ const capacity = Math.min(limit, Math.max(1, Math.round(requested)));
123
+ if (capacity === area.capacity)
124
+ return area;
125
+ return {
126
+ ...area,
127
+ capacity,
128
+ selling: standingConfiguration(state.mode, Math.min(capacity, state.wheelchairPlaces), resizedRange(state, capacity)),
129
+ };
130
+ }
131
+ export function setStandingPartySize(area, field, value) {
132
+ if (area.selling?.mode !== StandingBookingMode.Party)
133
+ return area;
134
+ const range = editedRange(area.selling, area.capacity, field, value);
135
+ if (range.minGuests === area.selling.minGuests && range.maxGuests === area.selling.maxGuests)
136
+ return area;
137
+ return { ...area, selling: { ...area.selling, ...range } };
138
+ }
139
+ export function setStandingWheelchairPlaces(area, requested) {
140
+ const state = standingSellingState(area);
141
+ const wheelchairPlaces = Math.max(0, Math.min(area.capacity, Math.round(requested)));
142
+ if (wheelchairPlaces === state.wheelchairPlaces)
143
+ return area;
144
+ return {
145
+ ...area,
146
+ selling: standingConfiguration(state.mode, wheelchairPlaces, state),
147
+ };
148
+ }
@@ -0,0 +1,31 @@
1
+ import { type PhysicalDocumentV1, type RectangularTableRecipe, type RoundTableRecipe, type RowLayout, type UUID } from "./physical-document.interface.js";
2
+ export declare enum SpacingRepairKind {
3
+ Row = "row",
4
+ LongTable = "longTable",
5
+ RoundTable = "roundTable"
6
+ }
7
+ export type SpacingRepair = {
8
+ groupId: UUID;
9
+ entityId: UUID;
10
+ description: string;
11
+ } & ({
12
+ kind: SpacingRepairKind.Row;
13
+ layout: RowLayout;
14
+ } | {
15
+ kind: SpacingRepairKind.LongTable;
16
+ recipe: RectangularTableRecipe;
17
+ } | {
18
+ kind: SpacingRepairKind.RoundTable;
19
+ recipe: RoundTableRecipe;
20
+ });
21
+ /** Spacing-only proposals retain inventory/metadata and the mean of remaining row seats. */
22
+ export declare function spacingRepairs(document: PhysicalDocumentV1): readonly SpacingRepair[];
23
+ export type SpacingRepairQuality = {
24
+ before: number;
25
+ after: number;
26
+ };
27
+ /** Preview only the reviewed proposals, with structural sharing and no editable/history state. */
28
+ export declare function spacingRepairReview(document: PhysicalDocumentV1, repairs: readonly SpacingRepair[]): {
29
+ quality: SpacingRepairQuality | null;
30
+ blocked: boolean;
31
+ };