@seatmap-fyi/map-domain 0.1.0-alpha.50 → 0.1.0-alpha.51

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.
@@ -1,5 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { type PhysicalDocumentV1, type UUID } from "./physical-document.interface.js";
3
+ export declare const editorHistoryEntryLimit = 100;
4
+ export declare const editorUndoRevisionsSchema: z.ZodArray<z.ZodNumber>;
3
5
  export declare const mapEditorStateSchema: z.ZodObject<{
4
6
  version: z.ZodLiteral<1>;
5
7
  lockedIds: z.ZodArray<z.ZodString>;
@@ -4,6 +4,9 @@ import { documentCatalog } from "./catalog.js";
4
4
  import { worldMatrices } from "./geometry/geometry.js";
5
5
  import { uuidSchema } from "./schema.js";
6
6
  import { DecorationKind } from "./physical-document.interface.js";
7
+ // The editor bounds the combined Undo and Redo stacks to this many commands.
8
+ export const editorHistoryEntryLimit = 100;
9
+ export const editorUndoRevisionsSchema = z.array(z.number().int().positive()).max(editorHistoryEntryLimit);
7
10
  export const mapEditorStateSchema = z.strictObject({
8
11
  version: z.literal(1),
9
12
  lockedIds: z.array(uuidSchema).max(100_000),
@@ -1,4 +1,9 @@
1
- import { type Decoration } from "../physical-document.interface.js";
1
+ import { DecorationKind, type Decoration, type ReferencePlanCrop } from "../physical-document.interface.js";
2
2
  import { type Bounds, type Matrix } from "./geometry.js";
3
+ export declare const FullReferenceCrop: Readonly<ReferencePlanCrop>;
4
+ /** Both the render mask and hit bounds use the full image's original centre as their origin. */
5
+ export declare function imageLocalBounds(image: Extract<Decoration, {
6
+ kind: DecorationKind.Image;
7
+ }>): Bounds;
3
8
  /** World bounds of the physical artwork, independent of editor selection and section ownership. */
4
9
  export declare function decorationBounds(decoration: Decoration, matrix: Matrix): Bounds;
@@ -1,6 +1,18 @@
1
1
  import { polygonContour } from "./polygon-curves.js";
2
- import { DecorationKind, LabelAlignment } from "../physical-document.interface.js";
2
+ import { DecorationKind, LabelAlignment, } from "../physical-document.interface.js";
3
3
  import { pointsBounds, project } from "./geometry.js";
4
+ export const FullReferenceCrop = { left: 0, top: 0, width: 1, height: 1 };
5
+ /** Both the render mask and hit bounds use the full image's original centre as their origin. */
6
+ export function imageLocalBounds(image) {
7
+ const { width, height } = image.sizeM;
8
+ const crop = image.referenceCrop ?? FullReferenceCrop;
9
+ return {
10
+ minX: (crop.left - 0.5) * width,
11
+ minY: (crop.top - 0.5) * height,
12
+ maxX: (Math.min(1, crop.left + crop.width) - 0.5) * width,
13
+ maxY: (Math.min(1, crop.top + crop.height) - 0.5) * height,
14
+ };
15
+ }
4
16
  /** World bounds of the physical artwork, independent of editor selection and section ownership. */
5
17
  export function decorationBounds(decoration, matrix) {
6
18
  let points;
@@ -27,6 +39,16 @@ export function decorationBounds(decoration, matrix) {
27
39
  case DecorationKind.Circle:
28
40
  points = rectanglePoints(decoration.radiusM * 2, decoration.radiusM * 2);
29
41
  break;
42
+ case DecorationKind.Image: {
43
+ const { minX, minY, maxX, maxY } = imageLocalBounds(decoration);
44
+ points = [
45
+ { x: minX, y: minY },
46
+ { x: maxX, y: minY },
47
+ { x: maxX, y: maxY },
48
+ { x: minX, y: maxY },
49
+ ];
50
+ break;
51
+ }
30
52
  default:
31
53
  points = rectanglePoints(decoration.sizeM.width, decoration.sizeM.height);
32
54
  }
@@ -47,3 +47,4 @@ export declare function generateGroup(group: SeatingGroup): Generator<GeneratedS
47
47
  export declare function footprint(seat: GeneratedSeat, world?: Matrix): PointM[];
48
48
  export declare function footprintInside(points: PointM[], polygon: PolygonM): boolean;
49
49
  export declare function invalidPolygon(polygon: PolygonM): boolean;
50
+ export { arcThroughPoints } from "./three-point-arc.js";
@@ -252,3 +252,4 @@ function calculateInvalidPolygon(polygon) {
252
252
  return true;
253
253
  return false;
254
254
  }
255
+ export { arcThroughPoints } from "./three-point-arc.js";
@@ -0,0 +1,10 @@
1
+ import type { PointM } from "../physical-document.interface.js";
2
+ export declare function arcThroughPoints(first: PointM, middle: PointM, last: PointM): {
3
+ center: {
4
+ x: number;
5
+ y: number;
6
+ };
7
+ radius: number;
8
+ startRad: number;
9
+ sweepRad: number;
10
+ } | null;
@@ -0,0 +1,32 @@
1
+ function positiveAngle(angle) {
2
+ const turn = Math.PI * 2;
3
+ return ((angle % turn) + turn) % turn;
4
+ }
5
+ export function arcThroughPoints(first, middle, last) {
6
+ const x = last.x - first.x;
7
+ const y = last.y - first.y;
8
+ const chord = Math.hypot(x, y);
9
+ if (!chord)
10
+ return null;
11
+ const axis = { x: x / chord, y: y / chord };
12
+ const dx = middle.x - first.x;
13
+ const dy = middle.y - first.y;
14
+ const along = dx * axis.x + dy * axis.y;
15
+ const across = dy * axis.x - dx * axis.y;
16
+ if (Math.abs(across) <= Number.EPSILON * chord)
17
+ return null;
18
+ // In chord coordinates the centre lies halfway between the endpoints.
19
+ const offset = (along * (along - chord) + across * across) / (2 * across);
20
+ const center = {
21
+ x: first.x + x / 2 - offset * axis.y,
22
+ y: first.y + y / 2 + offset * axis.x,
23
+ };
24
+ const radius = Math.hypot(chord / 2, offset);
25
+ const startRad = Math.atan2(first.y - center.y, first.x - center.x);
26
+ const endRad = positiveAngle(Math.atan2(last.y - center.y, last.x - center.x) - startRad);
27
+ const middleRad = positiveAngle(Math.atan2(middle.y - center.y, middle.x - center.x) - startRad);
28
+ if (!Number.isFinite(radius) || !endRad || !middleRad || middleRad === endRad)
29
+ return null;
30
+ const sweepRad = middleRad < endRad ? endRad : endRad - Math.PI * 2;
31
+ return { center, radius, startRad, sweepRad };
32
+ }
package/dist/issues.d.ts CHANGED
@@ -24,6 +24,7 @@ export declare enum IssueCode {
24
24
  InvalidCompanion = "INVALID_COMPANION",
25
25
  InvalidLabel = "INVALID_LABEL",
26
26
  MissingLabel = "MISSING_LABEL",
27
+ ReferencePlanCoverage = "REFERENCE_PLAN_COVERAGE",
27
28
  MissingAsset = "MISSING_ASSET",
28
29
  CurveOverrun = "CURVE_OVERRUN",
29
30
  SeatOverlap = "SEAT_OVERLAP",
package/dist/issues.js CHANGED
@@ -24,6 +24,7 @@ export var IssueCode;
24
24
  IssueCode["InvalidCompanion"] = "INVALID_COMPANION";
25
25
  IssueCode["InvalidLabel"] = "INVALID_LABEL";
26
26
  IssueCode["MissingLabel"] = "MISSING_LABEL";
27
+ IssueCode["ReferencePlanCoverage"] = "REFERENCE_PLAN_COVERAGE";
27
28
  IssueCode["MissingAsset"] = "MISSING_ASSET";
28
29
  IssueCode["CurveOverrun"] = "CURVE_OVERRUN";
29
30
  IssueCode["SeatOverlap"] = "SEAT_OVERLAP";
package/dist/layers.js CHANGED
@@ -1,4 +1,5 @@
1
- import { SeatingKind } from "./physical-document.interface.js";
1
+ import { ReferencePlanLayer, SeatingKind, } from "./physical-document.interface.js";
2
+ import { isReferencePlan } from "./media.js";
2
3
  const catalogs = new WeakMap();
3
4
  /**
4
5
  * @method layerCatalog
@@ -52,6 +53,14 @@ export function layerCatalog(document) {
52
53
  for (const list of siblings.values()) {
53
54
  list.sort((a, b) => a.zIndex - b.zIndex || a.ownerId.localeCompare(b.ownerId) || a.rowIndex - b.rowIndex);
54
55
  }
56
+ // Reserve private plan paint positions around the chart without changing sibling stacking commands.
57
+ const referenceLayers = new Map(document.decorations
58
+ .filter(isReferencePlan)
59
+ .map((plan) => [plan.id, plan.referenceLayer ?? ReferencePlanLayer.BelowChart]));
60
+ let aboveReference = 0;
61
+ for (const list of siblings.values())
62
+ aboveReference += list.length;
63
+ let belowReference = -referenceLayers.size;
55
64
  const order = new Map();
56
65
  const runs = new Map();
57
66
  let previousOwner = null;
@@ -62,17 +71,24 @@ export function layerCatalog(document) {
62
71
  visit(entry.id);
63
72
  }
64
73
  else {
65
- order.set(entry.id, ordinal);
74
+ const referenceLayer = referenceLayers.get(entry.id);
75
+ if (referenceLayer) {
76
+ const position = referenceLayer === ReferencePlanLayer.AboveChart ? aboveReference++ : belowReference++;
77
+ order.set(entry.id, position);
78
+ runs.set(entry.ownerId, [{ ids: [entry.id], order: position }]);
79
+ continue;
80
+ }
81
+ const position = ordinal++;
82
+ order.set(entry.id, position);
66
83
  const ownerRuns = runs.get(entry.ownerId) ?? [];
67
84
  if (previousOwner === entry.ownerId) {
68
85
  ownerRuns[ownerRuns.length - 1].ids.push(entry.id);
69
86
  }
70
87
  else {
71
- ownerRuns.push({ ids: [entry.id], order: ordinal });
88
+ ownerRuns.push({ ids: [entry.id], order: position });
72
89
  }
73
90
  runs.set(entry.ownerId, ownerRuns);
74
91
  previousOwner = entry.ownerId;
75
- ordinal++;
76
92
  }
77
93
  }
78
94
  };
package/dist/media.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import type { BuyerPhoto, PhysicalDocumentV1, UUID } from "./physical-document.interface.js";
1
+ import { DecorationKind } from "./physical-document.interface.js";
2
+ import type { BuyerPhoto, Decoration, PhysicalDocumentV1, UUID, VenueBuyerPhoto } from "./physical-document.interface.js";
2
3
  import type { DocumentSeat } from "./catalog.js";
3
4
  export declare enum MediaScope {
4
5
  Artwork = "artwork",
@@ -16,12 +17,25 @@ export type MediaReference = Readonly<{
16
17
  }>;
17
18
  /** All live consumers share resource identity, including photos on gap slots. */
18
19
  export declare function mediaReferences(document: PhysicalDocumentV1): readonly MediaReference[];
20
+ type ReferencePlan = Extract<Decoration, {
21
+ kind: DecorationKind.Image;
22
+ }> & {
23
+ referencePlan: true;
24
+ };
25
+ export declare function isReferencePlan(decoration: Decoration): decoration is ReferencePlan;
26
+ /** Reference plans are for authoring. Keep only resources referenced by remaining buyer-visible content. */
27
+ export declare function withoutReferencePlans(document: PhysicalDocumentV1): PhysicalDocumentV1;
19
28
  export type ResolvedBuyerPhoto = {
20
29
  scope: MediaScope.Generated;
21
30
  } | {
22
- scope: Exclude<MediaScope, MediaScope.Generated | MediaScope.Artwork>;
31
+ scope: MediaScope.Venue;
32
+ ownerId: UUID;
33
+ photo: VenueBuyerPhoto;
34
+ } | {
35
+ scope: MediaScope.Seat | MediaScope.Row | MediaScope.Section;
23
36
  ownerId: UUID;
24
37
  photo: BuyerPhoto;
25
38
  };
26
39
  /** Resolve the primary inventory address; overlapping editing scopes do not change inheritance. */
27
40
  export declare function buyerPhotoForSeat(document: PhysicalDocumentV1, seat: DocumentSeat): ResolvedBuyerPhoto;
41
+ export {};
package/dist/media.js CHANGED
@@ -58,6 +58,25 @@ export function mediaReferences(document) {
58
58
  documentReferences.set(document, result);
59
59
  return result;
60
60
  }
61
+ export function isReferencePlan(decoration) {
62
+ return decoration.kind === DecorationKind.Image && decoration.referencePlan === true;
63
+ }
64
+ const buyerDocuments = new WeakMap();
65
+ /** Reference plans are for authoring. Keep only resources referenced by remaining buyer-visible content. */
66
+ export function withoutReferencePlans(document) {
67
+ const cached = buyerDocuments.get(document);
68
+ if (cached)
69
+ return cached;
70
+ const planAssets = new Set(document.decorations.filter(isReferencePlan).map((plan) => plan.assetId));
71
+ if (!planAssets.size)
72
+ return document;
73
+ const decorations = document.decorations.filter((decoration) => !isReferencePlan(decoration));
74
+ const publicAssetIds = new Set(mediaReferences({ ...document, decorations }).map((reference) => reference.assetId));
75
+ const assets = document.assets.filter((asset) => !planAssets.has(asset.id) || publicAssetIds.has(asset.id));
76
+ const visible = { ...document, decorations, assets };
77
+ buyerDocuments.set(document, visible);
78
+ return visible;
79
+ }
61
80
  /** Resolve the primary inventory address; overlapping editing scopes do not change inheritance. */
62
81
  export function buyerPhotoForSeat(document, seat) {
63
82
  if (seat.slot.buyerPhoto)
@@ -135,6 +135,21 @@ export type MapCategory = {
135
135
  export type BuyerPhoto = {
136
136
  assetId: UUID;
137
137
  };
138
+ export declare const VenuePhotoLimit: {
139
+ readonly BearingDeg: 360;
140
+ readonly PitchDeg: 35;
141
+ readonly SourceLabel: 100;
142
+ };
143
+ export type VenueBuyerPhoto = BuyerPhoto & {
144
+ initialBearingDeg?: number;
145
+ initialPitchDeg?: number;
146
+ capturedAt?: string;
147
+ sourceLabel?: string;
148
+ sourceDimensions?: {
149
+ width: number;
150
+ height: number;
151
+ };
152
+ };
138
153
  export type SeatSlot = {
139
154
  buyerPhoto?: BuyerPhoto;
140
155
  gap?: boolean;
@@ -407,6 +422,34 @@ export type DecorationStyle = {
407
422
  stroke?: Paint;
408
423
  strokeWidthM?: number;
409
424
  };
425
+ export type StageLabelStyle = {
426
+ color?: string;
427
+ fontFamily?: string;
428
+ underline?: boolean;
429
+ };
430
+ export declare enum ReferencePlanLayer {
431
+ BelowChart = "below-chart",
432
+ AboveChart = "above-chart"
433
+ }
434
+ /** The reference-plan picker accepts PDFs with up to 100 pages. */
435
+ export declare const ReferencePlanPageLimit = 100;
436
+ /** Authored source details for the private raster, which is the only stored artwork. */
437
+ export type ReferencePlanSource = {
438
+ fileName: string;
439
+ page?: number;
440
+ };
441
+ /** Fractions of the full image, with the origin at its upper-left corner. */
442
+ export type ReferencePlanCrop = {
443
+ left: number;
444
+ top: number;
445
+ width: number;
446
+ height: number;
447
+ };
448
+ export type ReferencePlanCalibration = {
449
+ firstPx: PointM;
450
+ secondPx: PointM;
451
+ distanceM: number;
452
+ };
410
453
  export type Decoration = DrawableBase & ({
411
454
  kind: DecorationKind.Text;
412
455
  text: string;
@@ -432,12 +475,20 @@ export type Decoration = DrawableBase & ({
432
475
  kind: DecorationKind.Polygon;
433
476
  boundary: PolygonM;
434
477
  gate?: GateDetails;
478
+ stage?: {
479
+ labelStyle?: StageLabelStyle;
480
+ };
435
481
  } | {
436
482
  kind: DecorationKind.Icon;
437
483
  iconId: VenueGlyph;
438
484
  sizeM: SizeM;
439
485
  } | {
440
486
  kind: DecorationKind.Image;
487
+ referencePlan?: true;
488
+ referenceSource?: ReferencePlanSource;
489
+ referenceLayer?: ReferencePlanLayer;
490
+ referenceCrop?: ReferencePlanCrop;
491
+ referenceCalibration?: ReferencePlanCalibration;
441
492
  assetId: UUID;
442
493
  sizeM: SizeM;
443
494
  opacity: number;
@@ -535,7 +586,7 @@ export type VenueZone = {
535
586
  focalPoint?: PointM;
536
587
  };
537
588
  export type PhysicalDocumentV1 = {
538
- buyerPhoto?: BuyerPhoto;
589
+ buyerPhoto?: VenueBuyerPhoto;
539
590
  schemaVersion: 1;
540
591
  mapId: UUID;
541
592
  name: string;
@@ -62,6 +62,12 @@ export var SeatShape;
62
62
  SeatShape["Stool"] = "stool";
63
63
  SeatShape["Bench"] = "bench";
64
64
  })(SeatShape || (SeatShape = {}));
65
+ // The hosted Whole-venue calibration clamps typed input to these limits.
66
+ export const VenuePhotoLimit = {
67
+ BearingDeg: 360,
68
+ PitchDeg: 35,
69
+ SourceLabel: 100,
70
+ };
65
71
  export var RowEnds;
66
72
  (function (RowEnds) {
67
73
  RowEnds["Start"] = "start";
@@ -114,6 +120,13 @@ export var TableChairDistribution;
114
120
  TableChairDistribution["Interior"] = "interior";
115
121
  TableChairDistribution["EqualSegments"] = "equalSegments";
116
122
  })(TableChairDistribution || (TableChairDistribution = {}));
123
+ export var ReferencePlanLayer;
124
+ (function (ReferencePlanLayer) {
125
+ ReferencePlanLayer["BelowChart"] = "below-chart";
126
+ ReferencePlanLayer["AboveChart"] = "above-chart";
127
+ })(ReferencePlanLayer || (ReferencePlanLayer = {}));
128
+ /** The reference-plan picker accepts PDFs with up to 100 pages. */
129
+ export const ReferencePlanPageLimit = 100;
117
130
  export var SectionOutlineRole;
118
131
  (function (SectionOutlineRole) {
119
132
  SectionOutlineRole["Boundary"] = "boundary";
package/dist/schema.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ArcFanFacing, ArcFanFit, ArcFanSectionOrigin } from "./arc-fan.interface.js";
2
2
  import { EntranceKind, GateUse, LineCap, LineJoin, LineEnding } from "./wayfinding.interface.js";
3
- import { TicketRestriction, TableBookingMode, TableChairDistribution, StandingBookingMode, SeatShape, type PhysicalDocumentV1, type SeatingGroup, type SeatSlot, type UUID, NumberingScheme, LabelDirection, TableChairNumberFormat, RowLabelPosition, AccessNeed, SeatingKind, CurveMode, DecorationKind, LabelAlignment, RowAlignment, RowStagger, RowEnds, RowJoin, SectionOutlineRole, SectionTier, AreaKind, ShapeKind, VenueGlyph } from "./physical-document.interface.js";
3
+ import { TicketRestriction, TableBookingMode, TableChairDistribution, StandingBookingMode, SeatShape, type PhysicalDocumentV1, type SeatingGroup, type SeatSlot, type UUID, NumberingScheme, LabelDirection, TableChairNumberFormat, RowLabelPosition, AccessNeed, SeatingKind, CurveMode, DecorationKind, ReferencePlanLayer, LabelAlignment, RowAlignment, RowStagger, RowEnds, RowJoin, SectionOutlineRole, SectionTier, AreaKind, ShapeKind, VenueGlyph } from "./physical-document.interface.js";
4
4
  import { z } from "zod";
5
5
  import { type DomainIssue } from "./issues.js";
6
6
  export declare const storedLabelSchema: z.ZodString;
@@ -8,6 +8,17 @@ export declare const hexColourSchema: z.ZodString;
8
8
  export declare const buyerPhotoSchema: z.ZodObject<{
9
9
  assetId: z.ZodString;
10
10
  }, z.core.$strict>;
11
+ export declare const venueBuyerPhotoSchema: z.ZodObject<{
12
+ assetId: z.ZodString;
13
+ initialBearingDeg: z.ZodOptional<z.ZodNumber>;
14
+ initialPitchDeg: z.ZodOptional<z.ZodNumber>;
15
+ capturedAt: z.ZodOptional<z.ZodISODate>;
16
+ sourceLabel: z.ZodOptional<z.ZodString>;
17
+ sourceDimensions: z.ZodOptional<z.ZodObject<{
18
+ width: z.ZodInt;
19
+ height: z.ZodInt;
20
+ }, z.core.$strict>>;
21
+ }, z.core.$strict>;
11
22
  export declare const seatPresentationSchema: z.ZodObject<{
12
23
  buyerPhoto: z.ZodOptional<z.ZodObject<{
13
24
  assetId: z.ZodString;
@@ -1038,6 +1049,11 @@ export declare const decorationStyleSchema: z.ZodObject<{
1038
1049
  }, z.core.$strict>>;
1039
1050
  strokeWidthM: z.ZodOptional<z.ZodNumber>;
1040
1051
  }, z.core.$strict>;
1052
+ export declare const stageLabelStyleSchema: z.ZodObject<{
1053
+ color: z.ZodOptional<z.ZodString>;
1054
+ fontFamily: z.ZodOptional<z.ZodString>;
1055
+ underline: z.ZodOptional<z.ZodBoolean>;
1056
+ }, z.core.$strict>;
1041
1057
  export declare const ticketOptionSchema: z.ZodObject<{
1042
1058
  id: z.ZodString;
1043
1059
  name: z.ZodString;
@@ -1078,6 +1094,14 @@ export declare const categoriesSchema: z.ZodArray<z.ZodObject<{
1078
1094
  export declare const documentSchema: z.ZodObject<{
1079
1095
  buyerPhoto: z.ZodOptional<z.ZodObject<{
1080
1096
  assetId: z.ZodString;
1097
+ initialBearingDeg: z.ZodOptional<z.ZodNumber>;
1098
+ initialPitchDeg: z.ZodOptional<z.ZodNumber>;
1099
+ capturedAt: z.ZodOptional<z.ZodISODate>;
1100
+ sourceLabel: z.ZodOptional<z.ZodString>;
1101
+ sourceDimensions: z.ZodOptional<z.ZodObject<{
1102
+ width: z.ZodInt;
1103
+ height: z.ZodInt;
1104
+ }, z.core.$strict>>;
1081
1105
  }, z.core.$strict>>;
1082
1106
  schemaVersion: z.ZodLiteral<1>;
1083
1107
  mapId: z.ZodString;
@@ -2445,6 +2469,13 @@ export declare const documentSchema: z.ZodObject<{
2445
2469
  opens: z.ZodOptional<z.ZodString>;
2446
2470
  showToBuyers: z.ZodOptional<z.ZodBoolean>;
2447
2471
  }, z.core.$strict>>;
2472
+ stage: z.ZodOptional<z.ZodObject<{
2473
+ labelStyle: z.ZodOptional<z.ZodObject<{
2474
+ color: z.ZodOptional<z.ZodString>;
2475
+ fontFamily: z.ZodOptional<z.ZodString>;
2476
+ underline: z.ZodOptional<z.ZodBoolean>;
2477
+ }, z.core.$strict>>;
2478
+ }, z.core.$strict>>;
2448
2479
  boundary: z.ZodObject<{
2449
2480
  outer: z.ZodArray<z.ZodObject<{
2450
2481
  x: z.ZodNumber;
@@ -2519,6 +2550,29 @@ export declare const documentSchema: z.ZodObject<{
2519
2550
  zIndex: z.ZodNumber;
2520
2551
  }, z.core.$strict>, z.ZodObject<{
2521
2552
  kind: z.ZodLiteral<DecorationKind.Image>;
2553
+ referencePlan: z.ZodOptional<z.ZodLiteral<true>>;
2554
+ referenceSource: z.ZodOptional<z.ZodObject<{
2555
+ fileName: z.ZodString;
2556
+ page: z.ZodOptional<z.ZodInt>;
2557
+ }, z.core.$strict>>;
2558
+ referenceLayer: z.ZodOptional<z.ZodEnum<typeof ReferencePlanLayer>>;
2559
+ referenceCrop: z.ZodOptional<z.ZodObject<{
2560
+ left: z.ZodNumber;
2561
+ top: z.ZodNumber;
2562
+ width: z.ZodNumber;
2563
+ height: z.ZodNumber;
2564
+ }, z.core.$strict>>;
2565
+ referenceCalibration: z.ZodOptional<z.ZodObject<{
2566
+ firstPx: z.ZodObject<{
2567
+ x: z.ZodNumber;
2568
+ y: z.ZodNumber;
2569
+ }, z.core.$strict>;
2570
+ secondPx: z.ZodObject<{
2571
+ x: z.ZodNumber;
2572
+ y: z.ZodNumber;
2573
+ }, z.core.$strict>;
2574
+ distanceM: z.ZodNumber;
2575
+ }, z.core.$strict>>;
2522
2576
  assetId: z.ZodString;
2523
2577
  sizeM: z.ZodObject<{
2524
2578
  width: z.ZodNumber;
@@ -2839,6 +2893,13 @@ export declare const decorationSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
2839
2893
  opens: z.ZodOptional<z.ZodString>;
2840
2894
  showToBuyers: z.ZodOptional<z.ZodBoolean>;
2841
2895
  }, z.core.$strict>>;
2896
+ stage: z.ZodOptional<z.ZodObject<{
2897
+ labelStyle: z.ZodOptional<z.ZodObject<{
2898
+ color: z.ZodOptional<z.ZodString>;
2899
+ fontFamily: z.ZodOptional<z.ZodString>;
2900
+ underline: z.ZodOptional<z.ZodBoolean>;
2901
+ }, z.core.$strict>>;
2902
+ }, z.core.$strict>>;
2842
2903
  boundary: z.ZodObject<{
2843
2904
  outer: z.ZodArray<z.ZodObject<{
2844
2905
  x: z.ZodNumber;
@@ -2913,6 +2974,29 @@ export declare const decorationSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
2913
2974
  zIndex: z.ZodNumber;
2914
2975
  }, z.core.$strict>, z.ZodObject<{
2915
2976
  kind: z.ZodLiteral<DecorationKind.Image>;
2977
+ referencePlan: z.ZodOptional<z.ZodLiteral<true>>;
2978
+ referenceSource: z.ZodOptional<z.ZodObject<{
2979
+ fileName: z.ZodString;
2980
+ page: z.ZodOptional<z.ZodInt>;
2981
+ }, z.core.$strict>>;
2982
+ referenceLayer: z.ZodOptional<z.ZodEnum<typeof ReferencePlanLayer>>;
2983
+ referenceCrop: z.ZodOptional<z.ZodObject<{
2984
+ left: z.ZodNumber;
2985
+ top: z.ZodNumber;
2986
+ width: z.ZodNumber;
2987
+ height: z.ZodNumber;
2988
+ }, z.core.$strict>>;
2989
+ referenceCalibration: z.ZodOptional<z.ZodObject<{
2990
+ firstPx: z.ZodObject<{
2991
+ x: z.ZodNumber;
2992
+ y: z.ZodNumber;
2993
+ }, z.core.$strict>;
2994
+ secondPx: z.ZodObject<{
2995
+ x: z.ZodNumber;
2996
+ y: z.ZodNumber;
2997
+ }, z.core.$strict>;
2998
+ distanceM: z.ZodNumber;
2999
+ }, z.core.$strict>>;
2916
3000
  assetId: z.ZodString;
2917
3001
  sizeM: z.ZodObject<{
2918
3002
  width: z.ZodNumber;
package/dist/schema.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ArcFanFacing, ArcFanFit, ArcFanMaximumRows, ArcFanMaximumPartsPerRow, ArcFanSectionOrigin, } from "./arc-fan.interface.js";
2
2
  import { EntranceKind, GateUse, LineCap, LineJoin, LineEnding } from "./wayfinding.interface.js";
3
3
  import { polygonContour, polygonContourVertexCount, PolygonVertexLimit, PolygonCornerRadiusMaxM, } from "./geometry/polygon-curves.js";
4
- import { DocumentLimits, TicketRestriction, TableBookingMode, TableChairDistribution, StandingBookingMode, SeatShape, TicketOptionLimit, NumberingScheme, LabelDirection, TableChairNumberFormat, RowLabelPosition, AccessNeed, SeatingKind, CurveMode, DecorationKind, LabelAlignment, RowAlignment, RowStagger, RowEnds, RowJoin, SectionOutlineRole, RowRefitStrength, SectionRotation, SectionScale, SectionTier, SectionRake, SectionFrontRowHeight, AreaKind, ShapeKind, VenueGlyph, } from "./physical-document.interface.js";
4
+ import { DocumentLimits, TicketRestriction, TableBookingMode, TableChairDistribution, StandingBookingMode, SeatShape, TicketOptionLimit, NumberingScheme, LabelDirection, TableChairNumberFormat, RowLabelPosition, AccessNeed, SeatingKind, CurveMode, DecorationKind, ReferencePlanLayer, ReferencePlanPageLimit, LabelAlignment, RowAlignment, RowStagger, RowEnds, RowJoin, SectionOutlineRole, RowRefitStrength, SectionRotation, SectionScale, SectionTier, SectionRake, SectionFrontRowHeight, AreaKind, ShapeKind, VenueGlyph, VenuePhotoLimit, } from "./physical-document.interface.js";
5
5
  import { z } from "zod";
6
6
  import { tableSellingValid, standingSellingValid } from "./selling.js";
7
7
  import { ticketOptionNameKey } from "./categories.js";
@@ -120,6 +120,15 @@ const rowLabelStyle = labelStyle.extend({
120
120
  rotationDeg: angle.optional(),
121
121
  });
122
122
  export const buyerPhotoSchema = z.strictObject({ assetId: uuid });
123
+ export const venueBuyerPhotoSchema = buyerPhotoSchema.extend({
124
+ initialBearingDeg: finite.min(-VenuePhotoLimit.BearingDeg).max(VenuePhotoLimit.BearingDeg).optional(),
125
+ initialPitchDeg: finite.min(-VenuePhotoLimit.PitchDeg).max(VenuePhotoLimit.PitchDeg).optional(),
126
+ capturedAt: z.iso.date().optional(),
127
+ sourceLabel: text(VenuePhotoLimit.SourceLabel)
128
+ .refine((value) => value === value.trim(), "Use a trimmed source label.")
129
+ .optional(),
130
+ sourceDimensions: z.strictObject({ width: z.int().positive(), height: z.int().positive() }).optional(),
131
+ });
123
132
  export const seatPresentationSchema = z.strictObject({
124
133
  buyerPhoto: buyerPhotoSchema.optional(),
125
134
  gap: z.boolean().optional(),
@@ -407,12 +416,36 @@ export const decorationStyleSchema = z.strictObject({
407
416
  stroke: paint.optional(),
408
417
  strokeWidthM: nonNegative.optional(),
409
418
  });
419
+ export const stageLabelStyleSchema = z.strictObject({
420
+ color: hexColourSchema.optional(),
421
+ fontFamily: storedLabelSchema.min(1).optional(),
422
+ underline: z.boolean().optional(),
423
+ });
410
424
  const decorationBase = {
411
425
  ...drawable,
412
426
  label: storedLabelSchema.optional(),
413
427
  heightM: nonNegative.optional(),
414
428
  style: decorationStyleSchema.optional(),
415
429
  };
430
+ const referenceSource = z.strictObject({
431
+ // 255 is the basename limit for common file systems. No path is stored.
432
+ fileName: z.string().min(1).max(255),
433
+ page: z.int().min(1).max(ReferencePlanPageLimit).optional(),
434
+ });
435
+ const imageFraction = finite.min(0).max(1);
436
+ const positiveImageFraction = imageFraction.positive();
437
+ const referenceCrop = z
438
+ .strictObject({
439
+ left: imageFraction,
440
+ top: imageFraction,
441
+ width: positiveImageFraction,
442
+ height: positiveImageFraction,
443
+ })
444
+ .refine(({ left, top, width, height }) => left + width <= 1 + Number.EPSILON && top + height <= 1 + Number.EPSILON, "Crop must fit inside the image.");
445
+ const imagePixel = z.strictObject({ x: finite.nonnegative(), y: finite.nonnegative() });
446
+ const referenceCalibration = z
447
+ .strictObject({ firstPx: imagePixel, secondPx: imagePixel, distanceM: finite.positive() })
448
+ .refine(({ firstPx, secondPx }) => firstPx.x !== secondPx.x || firstPx.y !== secondPx.y, "Mark two distinct points.");
416
449
  const decoration = z.discriminatedUnion("kind", [
417
450
  z.strictObject({
418
451
  ...decorationBase,
@@ -445,25 +478,36 @@ const decoration = z.discriminatedUnion("kind", [
445
478
  endEnding: z.enum(LineEnding).optional(),
446
479
  pointsM: z.array(point).min(2).max(10000),
447
480
  }),
448
- z.strictObject({
481
+ z
482
+ .strictObject({
449
483
  ...decorationBase,
450
484
  kind: z.literal(DecorationKind.Polygon),
451
485
  gate: gateDetails.optional(),
486
+ stage: z.strictObject({ labelStyle: stageLabelStyleSchema.optional() }).optional(),
452
487
  boundary: polygon,
453
- }),
488
+ })
489
+ .refine((value) => !value.gate || !value.stage, "A stage cannot also be a gate."),
454
490
  z.strictObject({
455
491
  ...decorationBase,
456
492
  kind: z.literal(DecorationKind.Icon),
457
493
  iconId: z.enum(VenueGlyph),
458
494
  sizeM: size,
459
495
  }),
460
- z.strictObject({
496
+ z
497
+ .strictObject({
461
498
  ...decorationBase,
462
499
  kind: z.literal(DecorationKind.Image),
500
+ referencePlan: z.literal(true).optional(),
501
+ referenceSource: referenceSource.optional(),
502
+ referenceLayer: z.enum(ReferencePlanLayer).optional(),
503
+ referenceCrop: referenceCrop.optional(),
504
+ referenceCalibration: referenceCalibration.optional(),
463
505
  assetId: uuid,
464
506
  sizeM: size,
465
507
  opacity: finite.min(0).max(1),
466
- }),
508
+ })
509
+ .refine((image) => image.referencePlan ||
510
+ (!image.referenceSource && !image.referenceLayer && !image.referenceCrop && !image.referenceCalibration), "Plan settings require a private reference image."),
467
511
  ]);
468
512
  const areaBase = {
469
513
  entrance: entranceSchema.optional(),
@@ -544,7 +588,7 @@ export const categoriesSchema = z
544
588
  }
545
589
  });
546
590
  export const documentSchema = z.strictObject({
547
- buyerPhoto: buyerPhotoSchema.optional(),
591
+ buyerPhoto: venueBuyerPhotoSchema.optional(),
548
592
  schemaVersion: z.literal(1),
549
593
  mapId: uuid,
550
594
  name,
@@ -23,6 +23,7 @@ export declare class ValidationIndex {
23
23
  private refreshLabels;
24
24
  private remove;
25
25
  private indexGroup;
26
+ private indexSections;
26
27
  rebuild(document: PhysicalDocumentV1): void;
27
28
  private refreshBaseIssues;
28
29
  update(document: PhysicalDocumentV1, changedGroupIds: ReadonlySet<UUID>, refreshMetadata?: boolean): void;
@@ -252,6 +252,17 @@ export class ValidationIndex {
252
252
  this.put(g.id, entries);
253
253
  this.groupIssues.set(g.id, local);
254
254
  }
255
+ indexSections(document) {
256
+ this.put(document.mapId, document.sections.map(({ id, label, floorId }) => ({
257
+ id,
258
+ ownerId: document.mapId,
259
+ label,
260
+ kind: LabelScope.Section,
261
+ // Section numbering restarts on each floor.
262
+ scope: floorId ? `sections:${floorId}` : "sections",
263
+ field: `${id}.label`,
264
+ })));
265
+ }
255
266
  rebuild(document) {
256
267
  this.document = document;
257
268
  this.buckets.clear();
@@ -262,14 +273,7 @@ export class ValidationIndex {
262
273
  this.seats.clear();
263
274
  this.companions.clear();
264
275
  this.baseIssues = [];
265
- this.put(document.mapId, document.sections.map((s) => ({
266
- id: s.id,
267
- ownerId: document.mapId,
268
- label: s.label,
269
- kind: LabelScope.Section,
270
- scope: "sections",
271
- field: `${s.id}.label`,
272
- })));
276
+ this.indexSections(document);
273
277
  for (const g of document.seatingGroups)
274
278
  this.indexGroup(g);
275
279
  for (const a of document.areas)
@@ -324,14 +328,7 @@ export class ValidationIndex {
324
328
  this.remove(document.mapId);
325
329
  for (const area of before.areas)
326
330
  this.remove(area.id);
327
- this.put(document.mapId, document.sections.map((section) => ({
328
- id: section.id,
329
- ownerId: document.mapId,
330
- label: section.label,
331
- kind: LabelScope.Section,
332
- scope: "sections",
333
- field: `${section.id}.label`,
334
- })));
331
+ this.indexSections(document);
335
332
  for (const area of document.areas)
336
333
  this.put(area.id, [
337
334
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seatmap-fyi/map-domain",
3
- "version": "0.1.0-alpha.50",
3
+ "version": "0.1.0-alpha.51",
4
4
  "license": "UNLICENSED",
5
5
  "type": "module",
6
6
  "sideEffects": false,