@seatlayer/js 0.48.2 → 0.49.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.
@@ -1,1602 +0,0 @@
1
- import { ChartDoc, AvailabilityRule, ChartTheme, ExpandedSeat } from '@seatlayer/core';
2
-
3
- /**
4
- * Sales-channel planning — the pure, DOM-free half of Channels mode.
5
- *
6
- * Everything here is deterministic and testable without a canvas: the marker
7
- * palette, the mixed-source selection summary, the LOCAL staged preview of an
8
- * assignment, and the bucket rows the Review sheet renders.
9
- *
10
- * The local preview deliberately produces the SAME `AssignmentBuckets` shape the
11
- * server returns from `POST /channels/assignments`. There is no dry-run endpoint,
12
- * so the review sheet is drawn from this local computation and then REDRAWN from
13
- * the authoritative server response after Apply. One renderer, two sources —
14
- * which is why the shapes must match exactly.
15
- *
16
- * Spec: sales-channels-product-ux-spec §8.4–8.5.
17
- */
18
- /**
19
- * Public sale is a built-in pseudo-channel. The server's sentinel for it is the
20
- * literal string `'public'` — it is what `GET /channels` returns as
21
- * `publicSale.id`, what `GET /channels/allocation` reports for an unallocated
22
- * unit, and what `POST /channels/assignments` accepts (alongside `null`) as the
23
- * target meaning "send these back to public sale".
24
- *
25
- * This constant was `''` until 2026-08-02, which silently made every public unit
26
- * look like an unknown PRIVATE channel to `planAssignment` and `markerOf` — the
27
- * cause of the Review sheet's phantom "moved out of another channel" line and
28
- * the rail's "?" marker. Keep it byte-identical to the server's
29
- * `eventChannels.PUBLIC_CHANNEL_ID`.
30
- */
31
- declare const PUBLIC_CHANNEL_ID = "public";
32
- declare const PUBLIC_CHANNEL_NAME = "Public sale";
33
- /** True for every spelling of "public sale" a worker may hand us. */
34
- declare function isPublicChannelId(id: string | null | undefined): boolean;
35
- type ChannelState = 'active' | 'paused' | 'archived';
36
- /** Physical inventory status, as the manage surface speaks it. */
37
- type ChannelSeatStatus = 'free' | 'held' | 'booked' | 'blocked';
38
- interface ChannelCounts {
39
- allocated: number;
40
- free: number;
41
- held: number;
42
- booked: number;
43
- blocked: number;
44
- units: number;
45
- }
46
- /** Buyer-access intents the server stores per channel. */
47
- type ChannelAccessIntent = 'none' | 'internal' | 'server' | 'hosted_link';
48
- /**
49
- * Buyer-access summary on a channel row. Shipped by the access hardening branch
50
- * (merged to app main). Still optional in this type: a worker that predates the
51
- * merge simply omits it and the rail reads "—" rather than inventing a state.
52
- */
53
- interface ChannelAccessSummary {
54
- intent?: ChannelAccessIntent | string;
55
- hasActiveGrants?: boolean;
56
- lastMintAt?: number | null;
57
- /** Free-text detail (partner host, who paused it) when the server offers one. */
58
- detail?: string | null;
59
- }
60
- interface ChannelRecord {
61
- id: string;
62
- name: string;
63
- color: string | null;
64
- marker: string | null;
65
- externalRef: string | null;
66
- state: ChannelState;
67
- archiveDestination: string | null;
68
- createdAt: number;
69
- updatedAt: number;
70
- archivedAt: number | null;
71
- counts: ChannelCounts;
72
- access?: ChannelAccessSummary | null;
73
- }
74
- interface PublicSaleChannel {
75
- /** `'public'` on every shipped worker; typed loosely so an older build that
76
- * still answers `''` is normalised rather than rejected. */
77
- id: string;
78
- name: string;
79
- state: 'active';
80
- counts: ChannelCounts;
81
- access?: ChannelAccessSummary | null;
82
- }
83
- interface ChannelListResult {
84
- assignmentVersion: number;
85
- publicSale: PublicSaleChannel;
86
- channels: ChannelRecord[];
87
- }
88
- interface AssignmentBucketCount {
89
- count: number;
90
- }
91
- interface AssignmentSkippedBucket extends AssignmentBucketCount {
92
- labels: string[];
93
- truncated: boolean;
94
- }
95
- interface AssignmentBuckets {
96
- changedFromPublic: AssignmentBucketCount;
97
- movedFromOtherChannel: AssignmentBucketCount & {
98
- channels: Array<{
99
- channelId: string;
100
- name: string | null;
101
- count: number;
102
- }>;
103
- };
104
- alreadyInTarget: AssignmentBucketCount;
105
- skippedHeld: AssignmentSkippedBucket;
106
- skippedBooked: AssignmentSkippedBucket;
107
- /** Requested labels that are not inventory in this event. */
108
- notFound: AssignmentSkippedBucket;
109
- }
110
- interface AssignmentResult {
111
- ok: true;
112
- targetChannelId: string;
113
- assignmentVersion: number;
114
- requested: number;
115
- applied: number;
116
- buckets: AssignmentBuckets;
117
- }
118
- interface ArchiveBlockedDetails {
119
- activeHolds?: number;
120
- heldUnits?: number;
121
- latestHoldExpiresAt?: number | null;
122
- retryAfterMs?: number;
123
- }
124
- /**
125
- * Clamp any marker text down to the ONE uppercase character every surface draws.
126
- *
127
- * The server stores `marker` as free text (it only length-caps it), so a channel
128
- * created outside this widget can carry "star" or "VIP". The comp's marker chip
129
- * is a single glyph: taking two characters ("ST") overflows the 22px chip and
130
- * stops reading as a letter. Non-letter leading characters (an emoji, a digit,
131
- * punctuation) are skipped in favour of the first real letter.
132
- */
133
- declare function markerLetter(raw: string | null | undefined, fallback: string): string;
134
- /**
135
- * Suggest a marker for a new channel: the first letter of its name when that
136
- * letter is still free, otherwise the next unused letter. Deterministic so the
137
- * Create dialog's preview matches what actually gets stored.
138
- */
139
- declare function suggestMarker(name: string, taken: Iterable<string>): {
140
- letter: string;
141
- color: string;
142
- };
143
- /** The letter + color a channel actually renders with (server value wins). */
144
- declare function markerOf(channel: {
145
- id: string;
146
- name: string;
147
- marker?: string | null;
148
- color?: string | null;
149
- }, index?: number): {
150
- letter: string;
151
- color: string;
152
- };
153
- /** One line of the rail's mixed-source selection summary (§8.4). */
154
- interface SelectionSourceRow {
155
- channelId: string;
156
- name: string;
157
- count: number;
158
- }
159
- /**
160
- * Group the current selection by the channel each unit is allocated to today.
161
- * Public sale is listed first; the rest follow in list order so the rail's
162
- * ordering never jitters as the selection changes.
163
- */
164
- declare function selectionSources(labels: string[], allocation: Map<string, string>, list: ChannelListResult | null): SelectionSourceRow[];
165
- /**
166
- * The LOCAL staged preview of "move these labels to this channel".
167
- *
168
- * Mirrors the DO's rules exactly (eventChannels.applyAssignment):
169
- * - a unit already in the target is `alreadyInTarget`, whatever its status;
170
- * - otherwise held and booked units are skipped and never rewritten;
171
- * - otherwise a public unit is `changedFromPublic`, a private one is
172
- * `movedFromOtherChannel` (itemised per source);
173
- * - a label that is not inventory in this event is `notFound`.
174
- *
175
- * Every requested label lands in exactly one bucket — the property the Review
176
- * sheet's "every selected seat is in exactly one line" promise depends on.
177
- */
178
- declare function planAssignment(input: {
179
- labels: string[];
180
- targetChannelId: string;
181
- allocation: Map<string, string>;
182
- statusOf: (label: string) => ChannelSeatStatus | undefined;
183
- nameOf: (channelId: string) => string | null;
184
- }): AssignmentBuckets;
185
- /** Units this plan will actually mutate — what the Apply button counts. */
186
- declare function mutationCount(buckets: AssignmentBuckets): number;
187
- /** True when moving inventory out of another PRIVATE channel — §8.5 requires an
188
- * explicit confirmation line for exactly this case. */
189
- declare function needsMoveConfirmation(buckets: AssignmentBuckets): boolean;
190
- interface BucketRow {
191
- kind: 'add' | 'move' | 'same' | 'skip';
192
- icon: string;
193
- count: number;
194
- text: string;
195
- why?: string;
196
- /** Sampled seat labels for a skipped bucket, when the server sent any. */
197
- peek?: string;
198
- }
199
- /**
200
- * Render-ready rows for the Review sheet. The comp shows five lines; the server
201
- * carries a sixth bucket (`notFound`) which is emitted only when it is non-zero,
202
- * so a normal review still reads exactly like the approved design.
203
- *
204
- * Empty buckets are dropped — a zero line is noise, not honesty.
205
- */
206
- declare function bucketRows(buckets: AssignmentBuckets, targetName: string): BucketRow[];
207
- /**
208
- * "try again in ~N minutes" for the archive-blocked-by-holds 409 (§8.8).
209
- * Rounds up so the organizer never comes back one tick early.
210
- */
211
- declare function retryAfterCopy(details: ArchiveBlockedDetails | null | undefined): string;
212
- /** The access line under a channel row. Falls back to "—" before the hardening
213
- * branch lands the `access` field, never to a guess. */
214
- declare function accessLine(access: ChannelAccessSummary | null | undefined): string;
215
- /**
216
- * The name of each sale route, WORD FOR WORD as the server says it.
217
- *
218
- * `eventChannels.ts` builds its refusal sentences from an `INTENT_LABEL` map
219
- * with exactly these four strings. Diverging here would mean the picker calls a
220
- * route one thing and the refusal it produces calls it another, so these are
221
- * copied deliberately rather than paraphrased.
222
- */
223
- declare function accessIntentLabel(intent: ChannelAccessIntent): string;
224
- /**
225
- * What choosing this route actually DOES, now that the server enforces it.
226
- *
227
- * Written against the enforcement matrix, not against intent: each route opens
228
- * exactly one way to reach a buyer and refuses the other three, so each sentence
229
- * says both halves. The old copy for these values promised nothing and delivered
230
- * nothing; it was deleted in 0.42.0 and is not coming back.
231
- */
232
- declare function accessIntentDescription(intent: ChannelAccessIntent): string;
233
- /** `channel_access_intent_forbids` (409) — the route this channel declares is
234
- * not the one the action needed. */
235
- interface AccessIntentForbidsDetails {
236
- channelId?: string;
237
- accessIntent?: ChannelAccessIntent | string;
238
- /** The route the refused action arrived on: `hosted_link` | `server` | `staff` | `public`. */
239
- route?: string;
240
- }
241
- /**
242
- * The refusal, said as a decision the organizer can act on.
243
- *
244
- * The server's own sentence stops at "…so it cannot be sold through a buyer
245
- * link" — true, but it leaves the reader to work out what to do. This adds the
246
- * second half: which route to switch to. The code itself is never shown.
247
- */
248
- declare function intentForbidsCopy(details: AccessIntentForbidsDetails | null | undefined): string;
249
- /** `channel_intent_switch_blocked` (409) — buyers are inside the current route. */
250
- interface IntentSwitchBlockedDetails {
251
- channelId?: string;
252
- from?: ChannelAccessIntent | string;
253
- to?: ChannelAccessIntent | string;
254
- liveAccessLinks?: number;
255
- activeSessions?: number;
256
- acknowledgeWith?: {
257
- acknowledgeLiveAccess?: boolean;
258
- };
259
- }
260
- /**
261
- * What is live right now, and what acknowledging would do to it.
262
- *
263
- * Both halves are checked against the server rather than guessed: an
264
- * acknowledged switch REVOKES the channel's hosted links (redemption refuses
265
- * from that moment, so a link left listed as active would be a door the
266
- * management surface advertises and the buyer path denies), and deliberately
267
- * LEAVES buyer sessions and their holds alone — nobody is thrown out of a
268
- * checkout. Sessions cap at 12 hours (30 minutes by default) and no new ones can
269
- * be minted, so the old route drains on its own.
270
- */
271
- declare function intentSwitchBlockedCopy(details: IntentSwitchBlockedDetails | null | undefined): {
272
- headline: string;
273
- consequences: string[];
274
- };
275
- /** Lifecycle the server stores. `rotated` means a newer link replaced this one. */
276
- type AccessLinkState = 'active' | 'revoked' | 'rotated';
277
- /** What the organizer surface renders: `state`, unless an active link has run
278
- * out of time or out of redemptions. Never a capability, never a hash. */
279
- type AccessLinkStatus = AccessLinkState | 'expired' | 'exhausted';
280
- /**
281
- * One hosted link, exactly as `GET …/access-links` projects it.
282
- *
283
- * There is deliberately NO `url` and NO `capability` field here — the listing
284
- * route does not return them, no other route returns them, and this type must
285
- * not tempt a caller into believing otherwise. The secret exists in exactly one
286
- * place for exactly one moment: the create/rotate response (`AccessLinkReveal`).
287
- */
288
- interface AccessLinkRecord {
289
- id: string;
290
- channelId: string;
291
- label: string | null;
292
- includePublic: boolean;
293
- expiresAt: number;
294
- maxRedemptions: number;
295
- redemptions: number;
296
- /** Guest-weighted per-buyer ceiling handed to every session this link mints. */
297
- maxQuantity: number;
298
- sessionTtlSeconds: number;
299
- state: AccessLinkState;
300
- status: AccessLinkStatus;
301
- createdAt: number;
302
- createdBy: string | null;
303
- revokedAt: number | null;
304
- lastRedeemedAt: number | null;
305
- /** Rotation lineage: the link this replaced, and the one that replaced it. */
306
- rotatedFrom: string | null;
307
- rotatedTo: string | null;
308
- }
309
- /** A listed link, with the live session count the rotate dialog needs to state
310
- * "N buyers got in with this link and still have access". */
311
- interface AccessLinkStatusRecord extends AccessLinkRecord {
312
- activeSessions?: number;
313
- }
314
- /**
315
- * The ONE-TIME reveal. `url` and `capability` are on the wire exactly once, in
316
- * the create/rotate response, and are unrecoverable afterwards: SeatLayer stores
317
- * only a hash. Nothing may persist this — see `ChannelsMode.revealLink`.
318
- */
319
- interface AccessLinkReveal {
320
- link: AccessLinkRecord;
321
- url: string;
322
- capability: string;
323
- revealedOnce: true;
324
- /** Rotation only: the link that just stopped working, and how many live buyer
325
- * sessions from it were ended (0 when the organizer let them finish). */
326
- previous?: AccessLinkRecord;
327
- endedSessions?: number;
328
- }
329
- /**
330
- * Owner-set defaults for a new link. Expiry is NOT here: "when the event starts"
331
- * is the server's own default (it knows `starts_at`; the cockpit does not), so
332
- * the create form expresses that choice by omitting `expiresAt` entirely rather
333
- * than by guessing a timestamp the server would then have to correct.
334
- */
335
- declare const ACCESS_LINK_DEFAULTS: {
336
- readonly maxRedemptions: 100;
337
- readonly maxQuantity: 4;
338
- };
339
- /** Plain-language state badge for a hosted link (§9: no internal vocabulary). */
340
- declare function accessLinkBadge(link: Pick<AccessLinkRecord, 'status' | 'state'>): {
341
- text: string;
342
- kind: 'active' | 'paused' | 'archived';
343
- };
344
- /** Only an `active` link can be rotated or revoked; the server agrees (409
345
- * `access_link_not_active`), so the buttons are absent rather than failing. */
346
- declare function accessLinkIsLive(link: Pick<AccessLinkRecord, 'status' | 'state'>): boolean;
347
- /**
348
- * The policy an organizer is agreeing to, in one list. Used by BOTH the reveal
349
- * (what you just created) and the status card (what is live), so the two can
350
- * never drift into describing the same link differently.
351
- */
352
- declare function accessLinkPolicyLines(link: AccessLinkRecord): Array<{
353
- k: string;
354
- v: string;
355
- }>;
356
- /**
357
- * Plain language for a refused hosted-link call.
358
- *
359
- * The PLATFORM BOUNDS live on the server (60s–180d expiry, 1–10 000 redemptions,
360
- * 1–100 seats per buyer, 20 live links per channel) and the server states them
361
- * in `message`. We surface that sentence rather than re-encoding the numbers
362
- * here, so the client can never disagree with the rule it is reporting.
363
- */
364
- declare function accessLinkErrorCopy(err: {
365
- code?: string;
366
- serverMessage?: string;
367
- status?: number;
368
- details?: Record<string, unknown>;
369
- } | null | undefined): string;
370
- /**
371
- * The chart-update refusal `channel_assignment_would_drop` (409) deliberately
372
- * mirrors the Apply skipped buckets, so ONE review component renders both.
373
- * This adapts it into the same `BucketRow[]` the Review sheet already draws.
374
- */
375
- interface AssignmentDropDetails {
376
- droppedUnits?: number;
377
- channels?: Array<{
378
- channelId: string;
379
- name: string | null;
380
- count: number;
381
- labels?: string[];
382
- truncated?: boolean;
383
- }>;
384
- acknowledgeWith?: string;
385
- }
386
- declare function dropReviewRows(details: AssignmentDropDetails | null | undefined): BucketRow[];
387
- /** Plain-language state badge text (§9: no internal vocabulary on user surfaces). */
388
- declare function stateBadge(state: ChannelState | 'builtin'): string;
389
-
390
- /**
391
- * Organizer manage-surface client for workers/api (the `/v1/events/:key/*`
392
- * inventory routes + the public realtime channel). Companion to api.ts (the
393
- * buyer `/pub/*` client) — kept separate because the manage surface is
394
- * token-authed (Bearer) and cross-origin from the CMS:
395
- *
396
- * - Writes + reports send `Authorization: Bearer <token>` where the token is
397
- * a short-lived, event-scoped organizer manage token (`mse_…`, minted by
398
- * NestJS) OR a tenant secret key (`sk_…`). Both are accepted by the worker's
399
- * `eitherAuth` on block / unblock / unblock-all / unbook / hold-ttl / report
400
- * / log. The Authorization header also exempts the call from the worker's
401
- * cookie-CSRF gate, so no extra client header is needed.
402
- * - `credentials: 'omit'` — there is no session cookie; the CMS runs
403
- * cross-origin. The worker's credentialed CORS still echoes the CMS origin.
404
- * - chart geometry and authored media use authenticated organizer Event
405
- * routes. A manage bearer is not buyer authority and is never sent to
406
- * `/pub`. The seat STATE reads are private too. `/pub/.../objects` and an unticketed
407
- * `/pub/.../subscribe` both answer with the BUYER projection, which shows
408
- * inventory the caller may not buy as a neutral `blocked` — so an organizer
409
- * reading them sees its own channel allocations as blocked seats. Both now
410
- * go through the token: `/v1/events/:key/objects` for the snapshot, and a
411
- * `/v1/events/:key/subscribe-tickets` mint for the socket's scope.
412
- *
413
- * `box-book` is intentionally omitted for M1 (box office ships in M2, and the
414
- * route is still session-only server-side).
415
- */
416
-
417
- /** One page of the organizer-only label → channel projection. */
418
- interface ChannelAllocationPage {
419
- assignmentVersion: number;
420
- allocations: Array<{
421
- label: string;
422
- channelId: string;
423
- }>;
424
- nextAfterLabel: string | null;
425
- }
426
- interface ChannelAuditEntry {
427
- id: number;
428
- at: number;
429
- actor: string | null;
430
- action: string;
431
- channelId: string | null;
432
- assignmentVersion: number;
433
- before: unknown;
434
- after: unknown;
435
- reason: string | null;
436
- }
437
- interface ChannelAuditPage {
438
- entries: ChannelAuditEntry[];
439
- nextBefore: number | null;
440
- }
441
- /**
442
- * Buyer projection for a preview audience — the same scoped server view the
443
- * buyer SDK receives. When an audience cannot be previewed (a paused or
444
- * archived channel), the server answers `{available:false, unavailable:[…]}`
445
- * and the UI shows the real paused/unavailable landing state instead of
446
- * rendering those seats as eligible.
447
- *
448
- * Fields stay optional: a worker that predates the hardening merge 404s here,
449
- * and Channels mode says the preview needs a newer server rather than faking a
450
- * projection client-side.
451
- */
452
- interface ChannelPreviewProjection {
453
- available?: boolean;
454
- unavailable?: Array<{
455
- channelId: string;
456
- state: 'paused' | 'archived' | string;
457
- }>;
458
- channelIds?: string[];
459
- includePublic?: boolean;
460
- /** Labels this audience may buy. Everything else renders as ONE neutral
461
- * unavailable state so preview never leaks which channel holds a seat. */
462
- eligible?: string[];
463
- counts?: {
464
- eligible?: number;
465
- free?: number;
466
- held?: number;
467
- booked?: number;
468
- };
469
- }
470
- declare class ManageApiError extends Error {
471
- status: number;
472
- code?: string;
473
- /** Present when a block/unbook 409s because seats were just taken. */
474
- conflicts?: {
475
- label: string;
476
- reason?: string;
477
- }[];
478
- /**
479
- * Structured refusal detail. The channel routes use it for the two 409s a UI
480
- * must render rather than merely report: `channel_archive_blocked_by_holds`
481
- * carries {activeHolds, heldUnits, latestHoldExpiresAt, retryAfterMs}, and
482
- * `channel_assignment_conflict` carries the current assignmentVersion.
483
- */
484
- details?: Record<string, unknown>;
485
- /**
486
- * The server's own human sentence, when it sent one. `message` is the machine
487
- * code (that is what `error` carries), so a UI that wants to state a PLATFORM
488
- * RULE — "redemptions must be between 1 and 10 000" — reads this instead of
489
- * re-encoding the bound locally and risking disagreement with the server.
490
- */
491
- serverMessage?: string;
492
- constructor(status: number, message: string, code?: string, conflicts?: {
493
- label: string;
494
- reason?: string;
495
- }[], details?: Record<string, unknown>, serverMessage?: string);
496
- }
497
- interface ReportByStatus {
498
- free: number;
499
- held: number;
500
- booked: number;
501
- not_for_sale: number;
502
- }
503
- interface ReportCategoryRow {
504
- category: string;
505
- total: number;
506
- free: number;
507
- held: number;
508
- booked: number;
509
- not_for_sale: number;
510
- /** Configured-price snapshots for booked inventory; not proof of payment. */
511
- bookedValue: number;
512
- /** @deprecated Use `bookedValue`. */
513
- bookedRevenue: number;
514
- }
515
- interface ReportCategoryMeta {
516
- key: string;
517
- label: string;
518
- color: string;
519
- price: number;
520
- }
521
- interface ReportResult {
522
- report: {
523
- byStatus: ReportByStatus;
524
- byCategory: ReportCategoryRow[];
525
- bySection?: ControlRoomSectionMetric[];
526
- };
527
- event: {
528
- key: string;
529
- name: string;
530
- seatTotal: number;
531
- currency?: string;
532
- };
533
- categories: ReportCategoryMeta[];
534
- }
535
- interface ControlRoomSectionMetric {
536
- sectionId: string;
537
- sectionLabel: string;
538
- zoneId: string | null;
539
- total: number;
540
- free: number;
541
- held: number;
542
- booked: number;
543
- not_for_sale: number;
544
- bookedValue: number;
545
- /** @deprecated Use `bookedValue`. */
546
- bookedRevenue: number;
547
- }
548
- /** Recent seat-state change safe for an event:view control-room grant. Full
549
- * audit references remain available only through the event:reports log API. */
550
- interface ControlRoomActivityEntry {
551
- id: number;
552
- at: number;
553
- action: string;
554
- labels: string[];
555
- }
556
- interface ControlRoomSnapshot {
557
- version: number;
558
- currency: string;
559
- totals: {
560
- free: number;
561
- held: number;
562
- booked: number;
563
- blocked: number;
564
- };
565
- /** Configured value attached to booked inventory, never payment revenue. */
566
- bookedValue: {
567
- gross: number;
568
- bySection: ControlRoomSectionMetric[];
569
- };
570
- /** @deprecated Use `bookedValue`. */
571
- revenue: {
572
- gross: number;
573
- bySection: ControlRoomSectionMetric[];
574
- };
575
- velocity: {
576
- windowMinutes: number;
577
- bySection: Array<{
578
- sectionId: string;
579
- netBooked: number;
580
- bookedValue: number;
581
- /** @deprecated Use `bookedValue`. */
582
- grossRevenue: number;
583
- previousNetBooked: number;
584
- trend: 'rising' | 'steady' | 'cooling';
585
- }>;
586
- };
587
- presence: {
588
- shoppingSessions: number;
589
- activeHolds: number;
590
- };
591
- /** Present on workers that support reload-safe activity hydration. */
592
- activity?: ControlRoomActivityEntry[];
593
- event: {
594
- key: string;
595
- name: string;
596
- seatTotal: number;
597
- currency?: string;
598
- };
599
- }
600
- interface LogEntry {
601
- id: number;
602
- at: number;
603
- action: string;
604
- labels: string[];
605
- ref: string | null;
606
- }
607
- interface LogPage {
608
- entries: LogEntry[];
609
- nextBefore: number | null;
610
- }
611
- /** Platform/SDK inventory history — deliberately unrelated to commerce Orders. */
612
- type InventoryBookingState = 'booked' | 'partially_cancelled' | 'cancelled';
613
- interface InventoryBookingObject {
614
- label: string;
615
- objectId: string;
616
- objectType: 'seat' | 'booth' | 'ga' | 'table';
617
- categoryKey: string;
618
- sectionId: string | null;
619
- sectionLabel: string | null;
620
- zoneId: string | null;
621
- tierId: string | null;
622
- releaseId: string | null;
623
- bookingMode: 'individual' | 'whole' | 'variable';
624
- quantity: number;
625
- /** Event-configured price snapshot; not proof of what a buyer paid. */
626
- unitPrice: number;
627
- configuredValue: number;
628
- currency: string;
629
- channelId: string | null;
630
- channelExternalRef: string | null;
631
- source: string;
632
- state: 'booked' | 'cancelled';
633
- bookedAt: number;
634
- cancelledAt: number | null;
635
- }
636
- interface InventoryBooking {
637
- eventKey: string;
638
- eventMode: 'live' | 'test';
639
- bookingRef: string;
640
- state: InventoryBookingState;
641
- bookedAt: number;
642
- updatedAt: number;
643
- cancelledAt: number | null;
644
- source: string;
645
- bookedBy: string | null;
646
- lastActor: string | null;
647
- lastSource: string;
648
- labels: string[];
649
- objects: InventoryBookingObject[];
650
- quantity: number;
651
- activeQuantity: number;
652
- configuredValue: number;
653
- activeConfiguredValue: number;
654
- currency: string | null;
655
- }
656
- interface InventoryBookingsQuery {
657
- q?: string;
658
- state?: InventoryBookingState | null;
659
- cursor?: string | null;
660
- limit?: number;
661
- }
662
- interface InventoryBookingsPage {
663
- bookings: InventoryBooking[];
664
- nextCursor: string | null;
665
- }
666
- interface InventoryBookingActivity {
667
- id: number;
668
- action: 'book' | 'replay' | 'partial_cancel' | 'cancel' | 'reconcile';
669
- at: number;
670
- labels: string[];
671
- actor: string | null;
672
- source: string;
673
- }
674
- interface InventoryBookingDetail {
675
- booking: InventoryBooking;
676
- activity: InventoryBookingActivity[];
677
- activityTruncated: boolean;
678
- }
679
- /** Booking-time facts attached to the channel that produced the inventory move. */
680
- interface ChannelAttribution {
681
- sold: number;
682
- units: number;
683
- bookedValue: number | null;
684
- /** @deprecated Use `bookedValue`. */
685
- revenue: number | null;
686
- }
687
- interface ChannelReportRow {
688
- channelId: string;
689
- name: string;
690
- externalRef: string | null;
691
- state: ChannelState;
692
- allocation: ChannelCounts;
693
- attribution: ChannelAttribution;
694
- sellThrough: number | null;
695
- }
696
- interface ChannelReport {
697
- assignmentVersion: number;
698
- includesBookedValue: boolean;
699
- /** @deprecated Use `includesBookedValue`. */
700
- includesRevenue: boolean;
701
- methodology: {
702
- allocation: string;
703
- attribution: string;
704
- sellThrough: string;
705
- };
706
- rows: ChannelReportRow[];
707
- totals: {
708
- allocated: number;
709
- free: number;
710
- held: number;
711
- booked: number;
712
- blocked: number;
713
- sold: number;
714
- bookedValue: number | null;
715
- /** @deprecated Use `bookedValue`. */
716
- revenue: number | null;
717
- };
718
- }
719
- interface ChannelReportResult {
720
- report: ChannelReport;
721
- event: {
722
- key: string;
723
- name: string;
724
- seatTotal?: number;
725
- currency?: string;
726
- };
727
- }
728
- interface ChannelReportLinkRecord {
729
- id: string;
730
- channelId: string;
731
- label: string | null;
732
- includesBookedValue: boolean;
733
- /** @deprecated Use `includesBookedValue`. */
734
- includesRevenue: boolean;
735
- expiresAt: number;
736
- state: 'active' | 'revoked';
737
- status: 'active' | 'revoked' | 'expired';
738
- views: number;
739
- lastViewedAt: number | null;
740
- createdAt: number;
741
- createdBy: string | null;
742
- revokedAt: number | null;
743
- }
744
- interface ChannelReportLinkReveal {
745
- link: ChannelReportLinkRecord;
746
- url: string;
747
- capability: string;
748
- revealedOnce: true;
749
- }
750
- /**
751
- * A one-use WebSocket subscribe ticket. `protocols` is exactly what to hand
752
- * `new WebSocket(url, protocols)` — the ticket rides in `Sec-WebSocket-Protocol`
753
- * because a browser socket cannot carry an Authorization header and a bearer
754
- * must never travel in a URL.
755
- */
756
- interface SubscribeTicket {
757
- ticket: string;
758
- expiresAt: number;
759
- protocol: string;
760
- protocols: string[];
761
- }
762
- interface PubObjectsResult {
763
- /** Every non-free seat's status keyed by label (free seats omitted). */
764
- seats: Record<string, string>;
765
- hidden?: string[];
766
- closed?: string[];
767
- updatedAt: number;
768
- }
769
- interface PubChartResult {
770
- event: {
771
- key: string;
772
- name: string;
773
- status?: string;
774
- venue?: string | null;
775
- startsAt?: number | null;
776
- currency?: string;
777
- mode?: string;
778
- };
779
- doc: ChartDoc;
780
- }
781
- /**
782
- * Bound to one apiBase + one event-scoped token. Rebuild (or `setToken`) when a
783
- * token is re-minted on 401.
784
- */
785
- declare class ManageApi {
786
- private base;
787
- private token;
788
- constructor(apiBase: string, token: string);
789
- /** Swap the Bearer token in place (SeatManager re-mints on 401). */
790
- setToken(token: string): void;
791
- private auth;
792
- private authBlob;
793
- /** Event-pinned organizer geometry. A manage token is never sent to `/pub`. */
794
- chart(key: string): Promise<PubChartResult>;
795
- /** Authenticated bytes for an Event-scoped organizer chart asset. */
796
- asset(key: string, asset: string): Promise<Blob>;
797
- /**
798
- * The ORGANIZER's seat map: physical state, token-authed.
799
- *
800
- * This used to read `/pub/events/:key/objects` with no credential, which
801
- * answers with the BUYER projection — every unit the caller may not buy
802
- * collapses to a neutral `blocked`. An anonymous caller may buy only Public
803
- * sale inventory, so the cockpit rendered every channel-allocated seat as
804
- * blocked and then computed its KPIs, sell-through and (worse) its
805
- * block/unblock target sets from that. `/v1/events/:key/objects` returns the
806
- * unprojected snapshot the control-room read model already trusts.
807
- */
808
- objects(key: string): Promise<PubObjectsResult>;
809
- /**
810
- * Exchange the manage token for a one-use organizer socket ticket.
811
- *
812
- * A browser `WebSocket` cannot send an Authorization header, so the socket's
813
- * scope is established here, over ordinary HTTPS. Without it the DO treats a
814
- * manager socket as an anonymous public buyer and projects its deltas — so a
815
- * hold inside a private allocation is structurally suppressed and the map
816
- * drifts away from the truth `objects()` just established.
817
- *
818
- * Tickets are single-redemption and expire in ~30s: mint one per connect.
819
- */
820
- subscribeTicket(key: string): Promise<SubscribeTicket>;
821
- socketUrl(key: string): string;
822
- /** Take FREE seats off sale in one batched call. Optional `releaseAt` (epoch
823
- * ms, future) auto-returns them to sale; `reason` tags the block (M3 uses it).
824
- * Throws ManageApiError 409 (conflicts) if any seat was just taken. */
825
- block(key: string, labels: string[], opts?: {
826
- releaseAt?: number;
827
- reason?: string;
828
- }): Promise<{
829
- ok: true;
830
- blocked: string[];
831
- }>;
832
- /** Return specific blocked seats to sale (one batched call). */
833
- unblock(key: string, labels: string[]): Promise<{
834
- ok: true;
835
- unblocked: string[];
836
- }>;
837
- /** Return every blocked seat to sale; resolves with the freed count. */
838
- unblockAll(key: string): Promise<{
839
- ok: true;
840
- freed: number;
841
- }>;
842
- /** Cancel bookings — return BOOKED seats to free (credit not refunded).
843
- * Guarded by the original booking reference. */
844
- unbook(key: string, labels: string[], bookingRef: string): Promise<{
845
- ok: true;
846
- unbooked: string[];
847
- }>;
848
- /** Set (ms, clamped 1–60 min server-side) or clear (null) the hold TTL. */
849
- setHoldTtl(key: string, holdTtlMs: number | null): Promise<{
850
- ok: true;
851
- holdTtlMs: number | null;
852
- }>;
853
- /** Inventory lifecycle by stable integrator bookingRef. Absent on Managed. */
854
- bookings(key: string, query?: InventoryBookingsQuery): Promise<InventoryBookingsPage>;
855
- /** Exact configured-value snapshot plus book/replay/cancellation audit. */
856
- booking(key: string, bookingRef: string): Promise<InventoryBookingDetail>;
857
- /** Alias matching the server SDK vocabulary. */
858
- listBookings(key: string, query?: InventoryBookingsQuery): Promise<InventoryBookingsPage>;
859
- /** Alias matching the server SDK vocabulary. */
860
- retrieveBooking(key: string, bookingRef: string): Promise<InventoryBookingDetail>;
861
- /** The organizer's current per section/zone availability windows (needs
862
- * `event:view`). Ids absent from `rules` are open / on sale. */
863
- availability(key: string): Promise<{
864
- rules: Record<string, AvailabilityRule>;
865
- }>;
866
- /** Replace the availability windows for a set of section/zone ids (needs
867
- * `event:block`). Ids absent from `rules` become open / on sale; a zone rule
868
- * cascades to its sections. The worker derives each id's seat labels, so
869
- * `labels` on the sent rules is best-effort. Resolves with the authoritative
870
- * effective `hidden` set (a due rule may fire at once) and the server-cleaned
871
- * `rules` map (fired timed/threshold windows dropped). */
872
- setAvailability(key: string, rules: Record<string, AvailabilityRule>): Promise<{
873
- ok: true;
874
- hidden: string[];
875
- rules: Record<string, AvailabilityRule>;
876
- }>;
877
- /** Allocation list with exact per-channel counts. `includeArchived` adds the
878
- * read-only archived rows behind the rail's "Show archived" control. */
879
- channels(key: string, opts?: {
880
- includeArchived?: boolean;
881
- }): Promise<ChannelListResult>;
882
- /** One page of the label → channel map that paints the allocation overlay.
883
- * Paged by label; follow `nextAfterLabel` until it is null. */
884
- channelAllocation(key: string, opts?: {
885
- afterLabel?: string;
886
- limit?: number;
887
- }): Promise<ChannelAllocationPage>;
888
- channelAudit(key: string, opts?: {
889
- limit?: number;
890
- before?: number;
891
- }): Promise<ChannelAuditPage>;
892
- createChannel(key: string, input: {
893
- name: string;
894
- color?: string | null;
895
- marker?: string | null;
896
- externalRef?: string | null;
897
- }): Promise<{
898
- ok: true;
899
- channel: ChannelRecord;
900
- }>;
901
- renameChannel(key: string, channelId: string, name: string): Promise<{
902
- ok: true;
903
- channel: ChannelRecord;
904
- }>;
905
- setChannelPaused(key: string, channelId: string, paused: boolean): Promise<{
906
- ok: true;
907
- channel: ChannelRecord;
908
- }>;
909
- /** Archive with a mandatory destination for the remaining allocation.
910
- * Throws ManageApiError 409 `channel_archive_blocked_by_holds` while any hold
911
- * is live; `err.details` carries the exact counts + retry window. */
912
- archiveChannel(key: string, channelId: string, destination: string | null): Promise<{
913
- ok: true;
914
- channel: ChannelRecord;
915
- assignmentVersion: number;
916
- moved: number;
917
- }>;
918
- /**
919
- * Versioned Apply. A stale `assignmentVersion` mutates NOTHING and throws
920
- * ManageApiError 409 `channel_assignment_conflict` — the caller keeps its
921
- * selection and offers "Refresh and review". There is no dry-run: the review
922
- * sheet previews locally, this call returns the authoritative buckets.
923
- */
924
- applyChannelAssignment(key: string, input: {
925
- targetChannelId: string | null;
926
- labels: string[];
927
- assignmentVersion: number;
928
- }): Promise<AssignmentResult>;
929
- /**
930
- * Read-only buyer projection for an audience (§8.6) — the SAME scoped server
931
- * view the buyer SDK receives, never a local approximation.
932
- *
933
- * Ships on the access-hardening branch. Older workers 404/405 here; callers
934
- * MUST feature-detect and quietly say the preview needs a newer server rather
935
- * than faking a projection client-side.
936
- */
937
- channelPreview(key: string, channelIds: string[], opts?: {
938
- includePublic?: boolean;
939
- }): Promise<ChannelPreviewProjection>;
940
- /**
941
- * Choose which sale route this channel opens.
942
- *
943
- * Since the server's 2026-08-06 change this is AUTHORIZATION, not a label:
944
- * exactly one of the four routes may mint buyer access for the channel and the
945
- * other three refuse with 409 `channel_access_intent_forbids`. The default is
946
- * `none`, which refuses all four — so a route has to be declared before any
947
- * buyer-facing action on the channel can succeed.
948
- *
949
- * Switching the route while buyers are already inside the current one is
950
- * refused with 409 `channel_intent_switch_blocked`, whose `details` name what
951
- * is live (`liveAccessLinks`, `activeSessions`). Retry with
952
- * `acknowledgeLiveAccess: true`: hosted links on the channel are revoked,
953
- * while sessions already minted keep their holds and drain on their own.
954
- * `intentSwitch` is present on the response ONLY when the switch disturbed
955
- * something, so the ordinary case stays the two-key body it has always been.
956
- */
957
- setChannelAccessIntent(key: string, channelId: string, accessIntent: ChannelAccessIntent, opts?: {
958
- acknowledgeLiveAccess?: boolean;
959
- reason?: string;
960
- }): Promise<{
961
- ok: true;
962
- channel: ChannelRecord;
963
- intentSwitch?: {
964
- closedLinks: number;
965
- keptSessions: number;
966
- };
967
- }>;
968
- /**
969
- * Mint a hosted access link. The 201 is the ONE and ONLY time `url` and
970
- * `capability` exist outside the buyer's browser — SeatLayer keeps a hash, so
971
- * there is no route, cache, or support escalation that can produce this string
972
- * again. Callers must reveal it immediately and then let it go.
973
- *
974
- * Every omitted field takes the server's default: expiry = when the event
975
- * starts, 100 redemptions, 4 seats per buyer, this channel's allocation only.
976
- * Platform bounds are enforced server-side and reported as 422 with the rule
977
- * spelled out in `ManageApiError.serverMessage`.
978
- *
979
- * NOT a side effect any more. This used to SET the channel's access intent to
980
- * `hosted_link`; since 2026-08-06 it REQUIRES it, and a channel declaring any
981
- * other route refuses with 409 `channel_access_intent_forbids`. Callers must
982
- * declare the route first — `ChannelsMode` does exactly that before it
983
- * creates, so a first buyer link on a fresh channel is still one gesture.
984
- */
985
- createAccessLink(key: string, channelId: string, input?: {
986
- label?: string | null;
987
- /** Absolute epoch ms. Omit for "when the event starts". */
988
- expiresAt?: number;
989
- maxRedemptions?: number;
990
- maxQuantity?: number;
991
- includePublic?: boolean;
992
- }): Promise<AccessLinkReveal>;
993
- /** Status only — label, expiry, redemptions, per-buyer cap, lineage, and the
994
- * live session count. Never the url, never the capability. Needs `:view`. */
995
- accessLinks(key: string, channelId: string): Promise<{
996
- links: AccessLinkStatusRecord[];
997
- }>;
998
- /**
999
- * Rotate — the ONLY recovery for a link nobody kept. The old URL stops opening
1000
- * immediately and the response is a fresh one-time reveal.
1001
- *
1002
- * `endActiveSessions` is REQUIRED, not defaulted: the organizer must say
1003
- * whether buyers already inside finish their checkout or lose access now. The
1004
- * server answers 422 `end_active_sessions_required` if it is omitted, and that
1005
- * refusal is correct — a UI must not pick either branch on their behalf.
1006
- */
1007
- rotateAccessLink(key: string, channelId: string, linkId: string, endActiveSessions: boolean): Promise<AccessLinkReveal & {
1008
- previous: AccessLinkRecord;
1009
- endedSessions: number;
1010
- }>;
1011
- /** Revoke. The link stops opening immediately; `endActiveSessions` decides
1012
- * whether the buyers already inside keep their sessions. */
1013
- revokeAccessLink(key: string, channelId: string, linkId: string, endActiveSessions?: boolean): Promise<{
1014
- ok: true;
1015
- link: AccessLinkRecord;
1016
- endedSessions: number;
1017
- }>;
1018
- report(key: string): Promise<ReportResult>;
1019
- controlRoom(key: string, windowMinutes?: number): Promise<ControlRoomSnapshot>;
1020
- /** Allocation beside immutable booking-time channel attribution. */
1021
- channelReport(key: string): Promise<ChannelReportResult>;
1022
- createChannelReportLink(key: string, channelId: string, input?: {
1023
- label?: string;
1024
- includesBookedValue?: boolean;
1025
- /** @deprecated Use `includesBookedValue`. */
1026
- includesRevenue?: boolean;
1027
- expiresAt?: number;
1028
- }): Promise<ChannelReportLinkReveal>;
1029
- channelReportLinks(key: string, channelId: string): Promise<{
1030
- links: ChannelReportLinkRecord[];
1031
- }>;
1032
- revokeChannelReportLink(key: string, channelId: string, linkId: string): Promise<{
1033
- ok: true;
1034
- link: ChannelReportLinkRecord;
1035
- }>;
1036
- log(key: string, opts?: {
1037
- limit?: number;
1038
- before?: number;
1039
- }): Promise<LogPage>;
1040
- /** CSV report as a Blob (Bearer auth can't ride a plain <a href>). Host builds
1041
- * an object URL for download. */
1042
- reportCsv(key: string): Promise<Blob>;
1043
- }
1044
-
1045
- /**
1046
- * SeatManager — the organizer manage surface, packaged for the SDK.
1047
- *
1048
- * Productizes the SeatLayer dashboard's ManageEventPage into a framework-
1049
- * agnostic class (mirrors how SeatPicker productized the buyer flow). It mounts
1050
- * the shared engine in `manageMode`, subscribes to the event's realtime channel
1051
- * and drives three control-room tools on one persistent canvas:
1052
- *
1053
- * - **view** — a live board: realtime seat repaint (flash on hold/book),
1054
- * live KPI tallies + configured booked value, and a streaming activity
1055
- * feed derived from the delta stream + audit log. Read-only.
1056
- * - **inspect** — select one seat to read its live inventory context.
1057
- * - **block** — bulk-first block/unblock: marquee-drag, ⌘A select-all,
1058
- * whole-category / whole-section select, single-seat fallback →
1059
- * one batched block/unblock (optimistic, reconciled by the WS),
1060
- * and timed auto-release.
1061
- *
1062
- * Auth: organizer chart/media, inventory, realtime and reports all carry a
1063
- * Bearer event-scoped manage token (`mse_…`) or tenant secret key (`sk_…`) via
1064
- * {@link ManageApi}. Organizer authority is never downgraded to buyer `/pub`.
1065
- */
1066
-
1067
- type SeatManagerMode = 'view' | 'inspect' | 'block' | 'sections' | 'channels';
1068
- /**
1069
- * Capabilities the cockpit's token was minted with. Channels mode is gated on
1070
- * these and fails CLOSED: no `event:channels:view` ⇒ no Channels pill at all;
1071
- * view without `event:channels:manage` ⇒ read-only inspection with every
1072
- * mutation control absent, not merely disabled.
1073
- */
1074
- type SeatManagerCapability = 'event:view' | 'event:block' | 'event:cancel' | 'event:reports' | 'event:channels:view' | 'event:channels:manage';
1075
- /** DO seat status — 'blocked' has no engine analogue (→ 'not_for_sale'). */
1076
- type DoStatus = 'free' | 'held' | 'booked' | 'blocked';
1077
- /** Live KPI snapshot pushed to `onTallies` on every state change. */
1078
- interface SeatManagerTallies {
1079
- free: number;
1080
- held: number;
1081
- booked: number;
1082
- blocked: number;
1083
- /** Total seats on the chart. */
1084
- total: number;
1085
- /** booked / total, 0–100. */
1086
- capacityPct: number;
1087
- /** booked / (total − blocked), 0–100 — sell-through of sellable inventory. */
1088
- sellThroughPct: number;
1089
- /** Exact Σ booked unit_price snapshots from the authenticated report. */
1090
- bookedValue: number;
1091
- /** @deprecated Use `bookedValue`. */
1092
- grossRevenue: number;
1093
- /** Booked value is never reconstructed from the chart's current list price. */
1094
- bookedValueStatus: 'loading' | 'current' | 'stale';
1095
- /** @deprecated Use `bookedValueStatus`. */
1096
- revenueStatus: 'loading' | 'current' | 'stale';
1097
- /** ISO-4217 currency for `bookedValue`. */
1098
- currency: string;
1099
- }
1100
- /** One streamed activity line for the live feed. */
1101
- interface SeatManagerActivity {
1102
- id: string;
1103
- at: number;
1104
- label: string;
1105
- /** Full labels affected by this one backend/realtime operation. */
1106
- labels: string[];
1107
- count: number;
1108
- /** Human verb: held / booked / released / blocked / unblocked. */
1109
- verb: string;
1110
- status: DoStatus;
1111
- /** Spatial context for grouped activity when the chart defines sections. */
1112
- sectionIds?: string[];
1113
- sectionLabels?: string[];
1114
- }
1115
- /** Fired after a successful organizer action, for host toasts/telemetry. */
1116
- interface SeatManagerActionResult {
1117
- action: 'block' | 'unblock' | 'unblockAll' | 'cancelBooking' | 'setHoldTtl';
1118
- labels: string[];
1119
- count: number;
1120
- }
1121
- interface SeatManagerOptions {
1122
- /** CSS selector or element to mount into. */
1123
- container: string | HTMLElement;
1124
- /** API origin. Defaults to https://api.seatlayer.io. */
1125
- apiBase?: string;
1126
- /** Event key (e.g. `ev_xxx` / `west-end-p3`). */
1127
- eventKey: string;
1128
- /** Bearer manage token — event-scoped `mse_…` or a tenant secret `sk_…`. */
1129
- token: string;
1130
- /** Absolute token expiry (epoch ms). Enables proactive in-place rotation. */
1131
- tokenExpiresAt?: number;
1132
- /** Initial mode. Default 'view'. */
1133
- mode?: SeatManagerMode;
1134
- /**
1135
- * The capability set this token was minted with. Supply it whenever you mint
1136
- * an `mse_…` grant — it is the only way the widget can know a delegated token
1137
- * carries `event:channels:manage`, and without it Channels mode stays
1138
- * read-only (fail-closed). A tenant secret (`sk_…`) is org authority and is
1139
- * never narrowed server-side, so it is treated as fully capable.
1140
- */
1141
- capabilities?: SeatManagerCapability[] | string[];
1142
- /** ISO-4217 fallback currency for configured booked value (chart/event wins). */
1143
- currency?: string;
1144
- /** Chart theme override for the chrome (rails/bar). Chart colors come from the doc. */
1145
- theme?: ChartTheme;
1146
- /**
1147
- * Keep the canvas painting even when the tab is hidden/backgrounded (a war-room
1148
- * board on a second monitor). Calls `forceDraw()` after each delta so Chrome's
1149
- * rAF throttling on occluded tabs never leaves the board stale. Default true.
1150
- */
1151
- keepLiveWhileHidden?: boolean;
1152
- /**
1153
- * Opt in to camera-following for new buyer holds/bookings. Off by default so
1154
- * a live event never steals an operator's current map context.
1155
- */
1156
- followLive?: boolean;
1157
- /** Chart + first snapshot are loaded and the board is live. */
1158
- onReady?: () => void;
1159
- /** Live KPI tallies changed. */
1160
- onTallies?: (tallies: SeatManagerTallies) => void;
1161
- /** A grouped live/audit activity item arrived. */
1162
- onActivity?: (activity: SeatManagerActivity) => void;
1163
- /** Exact private control-room projection changed. */
1164
- onControlRoom?: (snapshot: ControlRoomSnapshot) => void;
1165
- /** Called before token expiry. The manager swaps the result without remounting. */
1166
- onTokenRefresh?: () => Promise<{
1167
- token: string;
1168
- expiresAt: number;
1169
- }>;
1170
- /** Tool/mode changed from inside the shared cockpit. */
1171
- onModeChange?: (mode: SeatManagerMode) => void;
1172
- /** Follow-live preference changed from inside the cockpit. */
1173
- onFollowLiveChange?: (enabled: boolean) => void;
1174
- /** Block-mode selection changed (marquee / ⌘A / category / section / tap). */
1175
- onSelectionChange?: (seats: ExpandedSeat[]) => void;
1176
- /** A block/unblock/cancel action completed successfully. */
1177
- onActionComplete?: (result: SeatManagerActionResult) => void;
1178
- /**
1179
- * The realtime link connected or dropped, with the moment the numbers on
1180
- * screen were last known good.
1181
- *
1182
- * A host embedding this cockpit renders its own chrome around it, and until
1183
- * now had no way to know the board had gone stale: the manager tracked the
1184
- * drop internally (its own LIVE/RECONNECTING pill) and told nobody. A host
1185
- * that polls on a timer and pauses while the tab is hidden therefore showed
1186
- * arbitrarily old numbers that looked exactly like fresh ones.
1187
- */
1188
- onConnectionChange?: (state: SeatManagerConnection) => void;
1189
- onError?: (err: unknown) => void;
1190
- }
1191
- /** Realtime link state, as reported to the embedding host. */
1192
- interface SeatManagerConnection {
1193
- /** `live` while the socket is open; `reconnecting` from drop until reopen. */
1194
- status: 'live' | 'reconnecting';
1195
- /**
1196
- * `Date.now()` of the last snapshot or delta accepted from the server, or
1197
- * null before the first one. This is the honest "as of" for whatever the host
1198
- * is displaying — NOT the time the connection dropped, which is later and
1199
- * would overstate freshness.
1200
- */
1201
- lastMessageAt: number | null;
1202
- }
1203
- declare class SeatManager {
1204
- private readonly opts;
1205
- private readonly api;
1206
- private readonly key;
1207
- private readonly keepLive;
1208
- private host;
1209
- private root;
1210
- private mapHost;
1211
- private els;
1212
- private renderer;
1213
- private doc;
1214
- private mode;
1215
- private labelToId;
1216
- private labelToSeat;
1217
- private allIds;
1218
- /**
1219
- * GA inventory units — real sellable labels the server counts, with NO seat
1220
- * geometry and therefore no renderer binding. They live here rather than in
1221
- * `labelToId`/`allIds` so every paint path keeps addressing paintable nodes
1222
- * only, while the tally denominator finally covers the same universe the
1223
- * numerator does. Without them a GA sale hit `booked` but not `total`:
1224
- * Free under-reported by GA capacity and SOLD% could exceed 100%.
1225
- */
1226
- private gaUnitLabelSet;
1227
- private status;
1228
- /** Live non-free counters, moved by each delta rather than re-walked. */
1229
- private counts;
1230
- /** Bumped whenever the seat model is replaced wholesale (a full snapshot). */
1231
- private modelVersion;
1232
- private currency;
1233
- private authoritativeGrossRevenue;
1234
- private revenueStatus;
1235
- private revenueRequest;
1236
- private controlRoomSnapshot;
1237
- /** Bearer-fetched organizer chart media, revoked with this manager. */
1238
- private readonly organizerAssetUrls;
1239
- /**
1240
- * The server's own totals, pinned to the client model they were read against.
1241
- * Display = server baseline + (client now − client then), so the authoritative
1242
- * numbers land exactly on arrival and deltas still move them between reads.
1243
- * A wholesale model replacement invalidates the pairing (`model`), and the
1244
- * client tallies — themselves a fresh authenticated read — take over.
1245
- */
1246
- private serverBaseline;
1247
- /** Latest presence frame, held whether or not a snapshot has landed yet. */
1248
- private livePresence;
1249
- /** Latest cumulative booked gross pushed on a delta frame. */
1250
- private liveGross;
1251
- /** Coalesces a burst of deltas into one KPI/rail repaint. */
1252
- private paintHandle;
1253
- private trendWindowMinutes;
1254
- private heatEnabled;
1255
- private followLive;
1256
- private lastKpiValues;
1257
- private activeKpiDeltas;
1258
- private ws;
1259
- private reconnectTimer;
1260
- private attempt;
1261
- private closed;
1262
- /** Mirrors the `live` root class, so the getter never has to read the DOM. */
1263
- private connectionStatus;
1264
- /** When the server last told us something. Stamped on accepted traffic only —
1265
- * a socket that opens and says nothing has not refreshed anything. */
1266
- private lastMessageAt;
1267
- private ready;
1268
- private feed;
1269
- private feedTimer;
1270
- private toastTimer;
1271
- private liveEventTimer;
1272
- private kpiCleanupTimer;
1273
- private followLiveTimer;
1274
- private followSeatTimer;
1275
- private releaseAt;
1276
- private layoutObserver;
1277
- private tokenExpiresAt;
1278
- private tokenRefreshTimer;
1279
- private tokenRefreshInFlight;
1280
- private sectionByObject;
1281
- private sectionLabelById;
1282
- private sectionsBase;
1283
- private availabilityRules;
1284
- private effectiveHidden;
1285
- private effectiveClosed;
1286
- private availabilitySaving;
1287
- private lastSyncedAt;
1288
- private blockedQuery;
1289
- private blockedSection;
1290
- private blockedResultLimit;
1291
- private unblockAllConfirmTimer;
1292
- /**
1293
- * Sales channels (M6b).
1294
- *
1295
- * Two fields, and the split between them is the whole point. `channelCaps` is
1296
- * AUTHORITY and is known early — it is read from the token's declared
1297
- * capabilities before the first rail paint, so the Channels pill either
1298
- * exists from the start or never appears. `channels` is the loaded sub-app,
1299
- * and it now arrives late: its module is fetched on first entry into Channels
1300
- * mode (`ensureChannels`), not at mount.
1301
- *
1302
- * So every gate that used to ask `!!this.channels` — the pill, the mode
1303
- * whitelist, the `c` shortcut — asks `channelCaps.view` instead. Asking the
1304
- * instance would make a permission the member genuinely has look like one
1305
- * they do not for as long as a network fetch takes.
1306
- */
1307
- private channels;
1308
- private channelCaps;
1309
- /** In-flight `import('./channelsMode')`, so concurrent entries load once. */
1310
- private channelsLoading;
1311
- private readonly onFullscreenChange;
1312
- private readonly onKeyDown;
1313
- private readonly onRailClick;
1314
- constructor(options: SeatManagerOptions);
1315
- /** Build the DOM, load the chart, subscribe to realtime, mount the board. */
1316
- render(): Promise<this>;
1317
- setMode(mode: SeatManagerMode): void;
1318
- /**
1319
- * Decide what this token may do with sales channels.
1320
- *
1321
- * Declared capabilities win — a host that mints an `mse_…` grant knows exactly
1322
- * what it asked for. Otherwise a tenant secret (`sk_…`) is org authority the
1323
- * worker never narrows, so it is fully capable; and a delegated token with no
1324
- * declaration is probed for read access and then treated as READ-ONLY, because
1325
- * "we could not tell" must never render mutation controls.
1326
- */
1327
- private resolveChannelCapabilities;
1328
- /**
1329
- * Load Channels mode, once, on first entry.
1330
- *
1331
- * Everything about this method is shaped by one rule: the cockpit must stay
1332
- * usable and honest while the module is in the air.
1333
- *
1334
- * - The promise is memoized, so a member who taps the pill twice, or a host
1335
- * whose deep link and initial `mode` prop both ask for Channels, loads one
1336
- * module and builds one instance.
1337
- * - Authority is re-checked on arrival. A token rotation can revoke
1338
- * `event:channels:view` between the tap and the load, and building the
1339
- * sub-app for a token that no longer carries the capability would put
1340
- * mutation controls on screen that every server call then refuses.
1341
- * - The mode is re-checked too. Someone who taps Channels and then Monitor
1342
- * before the chunk lands must not be yanked into Channels when it does; the
1343
- * instance is kept (it is paid for) but only entered if we are still there.
1344
- * - A failed load is stated in the rail rather than swallowed. Channels is a
1345
- * whole surface — silently showing an empty one would read as "this event
1346
- * has no channels", which is a lie about inventory.
1347
- */
1348
- private ensureChannels;
1349
- /** The adapter between the cockpit's internals and Channels mode. */
1350
- private buildChannelsHost;
1351
- /** Actual on-screen seat diameter, for the channel overlay's marks. The
1352
- * renderer's base seat radius is 9 chart units; retaining the camera scale
1353
- * (rather than capping it) keeps every preview paint aligned with the real
1354
- * chart geometry at deep zoom. */
1355
- private seatPixelSize;
1356
- /** Toggle the normalized sales-velocity outline overlay without changing seat colors. */
1357
- setHeatOverlay(enabled: boolean): void;
1358
- /** Toggle opt-in camera following for new buyer hold/book events. */
1359
- setFollowLive(enabled: boolean): void;
1360
- /** Change the current-vs-previous sales window and refresh the private projection. */
1361
- setTrendWindow(windowMinutes: number): Promise<ControlRoomSnapshot>;
1362
- enterFullscreen(): Promise<void>;
1363
- exitFullscreen(): Promise<void>;
1364
- isFullscreen(): boolean;
1365
- private toggleFullscreen;
1366
- /** Rotate the delegated credential without rebuilding DOM, canvas or socket. */
1367
- setToken(token: string, expiresAt?: number): void;
1368
- private scheduleTokenRefresh;
1369
- private rotateToken;
1370
- /** Bulk block the given labels (or the current selection when omitted). */
1371
- block(labels?: string[], opts?: {
1372
- releaseAt?: number;
1373
- reason?: string;
1374
- }): Promise<void>;
1375
- unblock(labels?: string[]): Promise<void>;
1376
- unblockAll(): Promise<void>;
1377
- /** Cancel bookings (BOOKED → free), guarded by the original booking ref. */
1378
- cancelBooking(labels: string[], bookingRef: string): Promise<void>;
1379
- selectAll(): ExpandedSeat[];
1380
- selectSection(sectionId: string): ExpandedSeat[];
1381
- selectByLabels(labels: string[]): ExpandedSeat[];
1382
- clearSelection(): void;
1383
- getSelection(): ExpandedSeat[];
1384
- getReport(): Promise<ReportResult>;
1385
- getControlRoomSnapshot(windowMinutes?: number): Promise<ControlRoomSnapshot>;
1386
- /**
1387
- * The realtime link's current state and the "as of" behind it.
1388
- *
1389
- * Pair with `onConnectionChange` for the edges: a host that mounts after a
1390
- * drop, or re-reads on tab focus, needs to be able to ASK rather than wait
1391
- * for the next transition that may never come.
1392
- */
1393
- getConnection(): SeatManagerConnection;
1394
- getLog(opts?: {
1395
- limit?: number;
1396
- before?: number;
1397
- }): Promise<{
1398
- entries: LogEntry[];
1399
- nextBefore: number | null;
1400
- }>;
1401
- setHoldTtl(ms: number | null): Promise<void>;
1402
- /** M2 — box-office booking from free seats. Stubbed (route is session-only today). */
1403
- boxBook(_labels: string[], _bookingRef: string): Promise<void>;
1404
- zoomToFit(): void;
1405
- destroy(): void;
1406
- private buildRenderer;
1407
- /** Block always uses a marquee. Channels only enables its marquee after the
1408
- * organizer deliberately chooses Assign seats; Pan map keeps desktop drag
1409
- * available for large charts. */
1410
- private isBulkSelectMode;
1411
- /**
1412
- * Block never touches held or booked inventory, so it cannot select it.
1413
- * Channels must be able to select it — the Review sheet's honesty depends on
1414
- * counting the held and sold units inside a marquee and saying they will not
1415
- * move, rather than silently omitting them from the selection.
1416
- */
1417
- private selectableStatuses;
1418
- private updateRendererInteraction;
1419
- private handleSeatSelect;
1420
- /**
1421
- * Build the client's inventory universe from the chart.
1422
- *
1423
- * `expandChart` yields SEATS — it has no output for a GA area, whose capacity
1424
- * is sold as N synthetic unit labels. The server's seat map keys, its deltas
1425
- * and its `totals` all speak those labels, so a client that only knows seats
1426
- * counts GA sales in the numerator (every key of the snapshot is written into
1427
- * `status`) while leaving them out of the denominator. Registering the GA
1428
- * units here — labels only, never a render binding — is what makes the two
1429
- * agree.
1430
- */
1431
- private buildUnitUniverse;
1432
- /** Every sellable unit the client knows: seats + GA capacity. */
1433
- private unitTotal;
1434
- /** Every label the client models, whether or not it can be painted. */
1435
- private knownLabels;
1436
- private repaintAll;
1437
- /**
1438
- * Open the cockpit's realtime socket AS THE ORGANIZER.
1439
- *
1440
- * The scope has to be established before the upgrade, because a browser
1441
- * `WebSocket` cannot send an Authorization header: the manage token is traded
1442
- * over HTTPS for a one-use ticket which rides in `Sec-WebSocket-Protocol`.
1443
- * Without it the server treats this socket as an anonymous public buyer and
1444
- * projects its deltas, so any change inside a private channel allocation is
1445
- * structurally suppressed and the map silently drifts.
1446
- *
1447
- * If the mint fails, remain reconnecting. An unticketed socket is a buyer
1448
- * projection, so applying it to organizer state would be worse than staying
1449
- * visibly offline while the host refreshes authority or upgrades the API.
1450
- */
1451
- private connect;
1452
- private scheduleReconnect;
1453
- private onMessage;
1454
- /**
1455
- * Adopt the cumulative booked gross a delta frame carried.
1456
- *
1457
- * Stashed with its arrival time so an in-flight control-room read can decide
1458
- * whether it is holding the newer number: a frame that landed after the
1459
- * request started is newer than the response, one that landed before is not.
1460
- */
1461
- private applyLiveGross;
1462
- /** The single writer for a label's status, so the counters never drift. */
1463
- private setStatusLabel;
1464
- private resnapshot;
1465
- /**
1466
- * Replace the whole seat model.
1467
- *
1468
- * `fallback` is the compact frame's modal status: those snapshots list only
1469
- * the seats that DIFFER from it, so every other known label takes it. Without
1470
- * this the omitted majority would silently fall back to `free` — fine when
1471
- * the mode really is free, wrong the moment it is not.
1472
- */
1473
- private applySnapshot;
1474
- /** The one O(n) walk left: a wholesale model replacement re-bases the counters. */
1475
- private recountAll;
1476
- /** Optimistic local write shared by organizer actions. Paint and tally once,
1477
- * even when an arena-sized operation changes hundreds of seats. */
1478
- private setSeatsLocal;
1479
- /** Keep the canvas painting on hidden/occluded tabs (war-room second monitor). */
1480
- private afterPaint;
1481
- private activityColor;
1482
- private sectionsForLabels;
1483
- private pulseSeatLabels;
1484
- /** Render one grouped realtime operation at the right semantic zoom level. */
1485
- private paintSpatialActivity;
1486
- private locateSection;
1487
- private locateActivity;
1488
- private showLiveEvent;
1489
- private applyReportRevenue;
1490
- /**
1491
- * Read the server's own control-room projection.
1492
- *
1493
- * Called on mount, on every socket (re)connect and after an organizer action —
1494
- * never on a timer and never per delta frame. Presence and gross that arrived
1495
- * on the socket AFTER this request started are newer than the response, so
1496
- * they survive it; anything older defers to the read.
1497
- */
1498
- private refreshControlRoom;
1499
- /** Pin the server's totals to the client model they were read against. */
1500
- private rebaseServerTotals;
1501
- /** What the client's own model says — GA units included since `render()`. */
1502
- private clientTallies;
1503
- /**
1504
- * The numbers the KPI bar and rail render.
1505
- *
1506
- * The server is the authority: its totals land exactly as read, and the
1507
- * delta-driven client model carries them forward until the next read. Before
1508
- * the first snapshot — and after a wholesale model replacement invalidates the
1509
- * pairing — the client model stands alone.
1510
- */
1511
- private buildTallies;
1512
- /**
1513
- * Queue one KPI/rail repaint for this burst of changes.
1514
- *
1515
- * A delta frame can carry hundreds of seats and `paintKpis` rebuilds eight
1516
- * nodes from scratch, so painting per change is what made an arena-sized
1517
- * frame expensive. Coalescing on a frame keeps the burst to a single rebuild;
1518
- * without `requestAnimationFrame` (SSR, an older test env) it paints inline
1519
- * rather than dropping the update.
1520
- */
1521
- private recomputeTallies;
1522
- private flushTallies;
1523
- private verbFor;
1524
- private pushActivity;
1525
- private seedFeed;
1526
- private startFeedClock;
1527
- private selectionLabels;
1528
- private syncSelection;
1529
- private buildChrome;
1530
- private updateContainerLayout;
1531
- private sectionOptions;
1532
- private buildSectionOptions;
1533
- private paintModeTabs;
1534
- private paintFollowLiveButton;
1535
- private paintHeatButton;
1536
- private paintMomentumHelp;
1537
- private paintFullscreenButton;
1538
- private paintTrendWindow;
1539
- private setLive;
1540
- private updateZoomHint;
1541
- private formatKpiDelta;
1542
- private paintKpis;
1543
- private paintRail;
1544
- private renderViewRail;
1545
- /** Live presence wins over the snapshot's copy — it is the fresher channel,
1546
- * and it exists from the first frame rather than the first fetch. */
1547
- private presenceCounts;
1548
- private paintMonitorInsights;
1549
- private applyHeatOverlay;
1550
- private renderInspectRail;
1551
- /** Pull the organizer's availability rules (event:view). Called on load and on
1552
- * every WS (re)connect, mirroring how the other panels re-hydrate. `closed` is
1553
- * deterministic from the rules; `hidden` (which folds in already-due timed /
1554
- * threshold windows) comes from the snapshot + WS effective set. */
1555
- private refreshAvailability;
1556
- /** Run a token-authed op; on a 401 re-mint via onTokenRefresh and retry once. */
1557
- private withAuthRetry;
1558
- private closedIdsFromRules;
1559
- /** Adopt a new effective hidden/closed set (from a snapshot or WS broadcast) and
1560
- * repaint the rail + canvas when it actually moves. */
1561
- private updateEffectiveAvailability;
1562
- /** Canvas read of the availability state: dim hidden sections to a whisper,
1563
- * half-light closed sections, leave open sections normal. Only in Sections mode;
1564
- * cleared in every other tool. */
1565
- private applySectionCanvasTreatment;
1566
- /** Zone-grouped render tree: each zone header then its sections (which follow the
1567
- * zone window), then loose sections + the ungrouped bucket. Effective hidden /
1568
- * closed come from the live sets, rules from the organizer map. */
1569
- private buildSectionRows;
1570
- private renderSectionsRail;
1571
- private sectionRowHtml;
1572
- private wireSectionRail;
1573
- /** Change one row's availability mode. A zone rule subsumes its child section
1574
- * rules, so those are dropped from the map (the zone window is the truth). */
1575
- private setSectionMode;
1576
- /** Edit a timed reveal time / threshold percent on an existing row rule. */
1577
- private setSectionRulePatch;
1578
- /** Optimistically adopt the new rules, then reconcile with the server-cleaned
1579
- * map + effective hidden/closed sets. Rolls back the rules on failure. */
1580
- private persistAvailability;
1581
- private paintLegend;
1582
- private paintFeed;
1583
- private renderBlockRail;
1584
- private toggleCategory;
1585
- /** A category/filter is a real toggle: add the missing seats, or remove the
1586
- * whole group when every eligible seat in it is already selected. */
1587
- private toggleLabels;
1588
- private isBlockSelectable;
1589
- private paintSelBar;
1590
- private paintCategoryControls;
1591
- private filteredBlockedSeats;
1592
- private paintBlockedInventory;
1593
- private confirmUnblockAll;
1594
- private resetUnblockAllConfirm;
1595
- private done;
1596
- private toastOk;
1597
- private toastErr;
1598
- private toast;
1599
- private fail;
1600
- }
1601
-
1602
- export { type SeatManagerCapability as $, type AssignmentResult as A, type BucketRow as B, type ChannelListResult as C, type ControlRoomActivityEntry as D, type ControlRoomSectionMetric as E, type ControlRoomSnapshot as F, type InventoryBooking as G, type InventoryBookingActivity as H, type IntentSwitchBlockedDetails as I, type InventoryBookingDetail as J, type InventoryBookingObject as K, type InventoryBookingState as L, type InventoryBookingsPage as M, type InventoryBookingsQuery as N, type LogEntry as O, type LogPage as P, ManageApi as Q, ManageApiError as R, PUBLIC_CHANNEL_ID as S, PUBLIC_CHANNEL_NAME as T, type ReportByStatus as U, type ReportCategoryMeta as V, type ReportCategoryRow as W, type ReportResult as X, SeatManager as Y, type SeatManagerActionResult as Z, type SeatManagerActivity as _, type ChannelAllocationPage as a, type SeatManagerConnection as a0, type SeatManagerMode as a1, type SeatManagerOptions as a2, type SeatManagerTallies as a3, type SelectionSourceRow as a4, accessIntentDescription as a5, accessIntentLabel as a6, accessLine as a7, accessLinkBadge as a8, accessLinkErrorCopy as a9, accessLinkIsLive as aa, accessLinkPolicyLines as ab, bucketRows as ac, dropReviewRows as ad, intentForbidsCopy as ae, intentSwitchBlockedCopy as af, isPublicChannelId as ag, markerLetter as ah, markerOf as ai, mutationCount as aj, needsMoveConfirmation as ak, planAssignment as al, retryAfterCopy as am, selectionSources as an, stateBadge as ao, suggestMarker as ap, type ChannelRecord as b, type ChannelPreviewProjection as c, type ChannelAccessIntent as d, type AccessLinkReveal as e, type AccessLinkStatusRecord as f, type ChannelSeatStatus as g, ACCESS_LINK_DEFAULTS as h, type AccessIntentForbidsDetails as i, type AccessLinkRecord as j, type AccessLinkState as k, type AccessLinkStatus as l, type ArchiveBlockedDetails as m, type AssignmentBuckets as n, type AssignmentDropDetails as o, type ChannelAccessSummary as p, type ChannelAttribution as q, type ChannelAuditEntry as r, type ChannelAuditPage as s, type ChannelCounts as t, type ChannelReport as u, type ChannelReportLinkRecord as v, type ChannelReportLinkReveal as w, type ChannelReportResult as x, type ChannelReportRow as y, type ChannelState as z };