@chrtco/sdk 0.9.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -549,6 +549,11 @@ interface StyleUrlOptions {
549
549
  * default — for keys with a bound CHRTstyle custom style, that's the
550
550
  * style's default palette. */
551
551
  theme?: ChrtStyleTheme;
552
+ /** Symbol artwork family: "s52" (default) or "s101" (official S-101
553
+ * Portrayal Catalogue symbols). Load the matching images client-side
554
+ * via `loadS101SymbolImages` / `loadChrtSymbolImages` from
555
+ * `@chrtco/sdk/atlas/browser`. */
556
+ symbols?: "s52" | "s101" | "chrt";
552
557
  }
553
558
  interface FetchStyleOptions extends StyleUrlOptions {
554
559
  signal?: AbortSignal;
@@ -1031,6 +1036,11 @@ interface InteractMapLike {
1031
1036
  x: number;
1032
1037
  y: number;
1033
1038
  };
1039
+ /** Present on real GL JS maps; lets `inspectAll()` accept screen points. */
1040
+ unproject?(point: [number, number]): {
1041
+ lng: number;
1042
+ lat: number;
1043
+ };
1034
1044
  }
1035
1045
  /** The subset of a GL JS MapMouseEvent that attach() consumes. */
1036
1046
  interface InteractMapMouseEvent {
@@ -1043,6 +1053,20 @@ interface InteractMapMouseEvent {
1043
1053
  lat: number;
1044
1054
  };
1045
1055
  }
1056
+ /**
1057
+ * A click location for candidate decoding: screen pixels always, geographic
1058
+ * coordinates when resolvable. `InteractMapMouseEvent` is assignable.
1059
+ */
1060
+ interface ClickAnchor {
1061
+ point: {
1062
+ x: number;
1063
+ y: number;
1064
+ };
1065
+ lngLat: {
1066
+ lng: number;
1067
+ lat: number;
1068
+ } | null;
1069
+ }
1046
1070
  /** Context passed to `onInspect` alongside the result. */
1047
1071
  interface InspectEventContext {
1048
1072
  /** Click location. */
@@ -1058,12 +1082,123 @@ interface InspectEventContext {
1058
1082
  /** The rendered feature the result was decoded from. */
1059
1083
  feature: InspectableFeature;
1060
1084
  }
1061
- interface AttachOptions {
1085
+ /**
1086
+ * What kind of click target a candidate is. Drives the primary priority
1087
+ * band (point > line > area) — distinct from `kind`, which describes the
1088
+ * decode shape (a WRECKS point is `kind: "area"` decode-wise but a "point"
1089
+ * click target).
1090
+ */
1091
+ type InspectTargetClass = "point" | "line" | "area";
1092
+ /**
1093
+ * One deduplicated feature under a click, ready for a disambiguation list.
1094
+ * Plain serializable data — resolve the full {@link InspectResult} (with
1095
+ * the v1 co-located merge and optional enrichment) by selecting it via
1096
+ * `attach()`'s candidate flow or `inspectAll().select()`.
1097
+ */
1098
+ interface InspectCandidate {
1099
+ /** Raw S-57 object class, e.g. "BOYLAT". */
1100
+ layer: string;
1101
+ /** Style-layer id the feature was rendered by, e.g. "enc-BOYLAT". */
1102
+ layerId: string;
1103
+ /** Decode shape this candidate resolves to on selection. */
1104
+ kind: "navaid" | "bridge" | "area";
1105
+ /** Click-target class driving the priority band. */
1106
+ targetClass: InspectTargetClass;
1107
+ /**
1108
+ * Priority rank (lower = higher priority): `band * 1000 + classRank`,
1109
+ * band 0/1/2 for point/line/area targets.
1110
+ */
1111
+ rank: number;
1112
+ /** Display title (same derivation as the selected InspectResult's). */
1113
+ title: string;
1114
+ /** Human-readable object class, e.g. "Lateral Buoy". */
1115
+ objectClass: string;
1116
+ /** [lng, lat] when the feature carries Point geometry. */
1117
+ coordinates: [number, number] | null;
1118
+ /**
1119
+ * Source-cell-scoped S-57 identity the dedupe folded on
1120
+ * (`{cell}|{LNAM}`), or null when the tiles carry no identity attrs
1121
+ * (such features are never folded).
1122
+ */
1123
+ identity: string | null;
1124
+ /**
1125
+ * Raw S-57 classes of co-located child objects collapsed into this
1126
+ * candidate (e.g. ["LIGHTS", "TOPMAR"] on a lit buoy). Selecting the
1127
+ * candidate merges their attributes via the v1 pipeline.
1128
+ */
1129
+ collapsedChildren: string[];
1130
+ /** The underlying rendered feature (pass to `inspect()` for headless decode). */
1131
+ feature: InspectableFeature;
1132
+ /** Non-SOLAS disclaimer + attribution + data currency. Always present. */
1133
+ notice: InspectNotice;
1134
+ }
1135
+ /** Options shared by every candidate-collecting entry point. */
1136
+ interface CandidateQueryOptions {
1137
+ /**
1138
+ * Pixel radius around the click for point/line targets (a finger- and
1139
+ * line-width-friendly hit box). Area (polygon) candidates always require
1140
+ * the exact click point to fall inside them. Default: 8. Pass 0 to query
1141
+ * the exact point only.
1142
+ */
1143
+ tolerance?: number;
1144
+ /**
1145
+ * Fold co-located S-57 child objects (LIGHTS, TOPMAR, FOGSIG, RTPBCN,
1146
+ * DAYMAR) into their parent buoy/beacon candidate. Default: true.
1147
+ */
1148
+ collapseChildren?: boolean;
1149
+ /** Override the queried nav-aid style-layer ids. */
1150
+ navAidLayers?: string[];
1151
+ /** Override the queried bridge style-layer ids. */
1152
+ bridgeLayers?: string[];
1153
+ /** Override the queried area style-layer ids. */
1154
+ areaLayers?: string[];
1155
+ }
1156
+ /** Context passed to `onCandidates` when a click hits several features. */
1157
+ interface CandidatesEventContext {
1158
+ /** Click location. */
1159
+ lngLat: {
1160
+ lng: number;
1161
+ lat: number;
1162
+ };
1163
+ /** Click location in screen pixels. */
1164
+ point: {
1165
+ x: number;
1166
+ y: number;
1167
+ };
1168
+ /**
1169
+ * Resolve one candidate to its full InspectResult (v1 co-located merge +
1170
+ * the attach-level `enrich` setting). Also drives the built-in popup and
1171
+ * `onInspect`, so custom candidate UIs stay one line.
1172
+ */
1173
+ select: (candidate: InspectCandidate) => Promise<InspectResult>;
1174
+ }
1175
+ /** Return shape of `chrt.interact.inspectAll()`. */
1176
+ interface InspectCandidateSet {
1177
+ /** Deduplicated candidates under the point, highest priority first. */
1178
+ candidates: InspectCandidate[];
1179
+ /**
1180
+ * Resolve one candidate to its full InspectResult (v1 co-located
1181
+ * attribute merge; `enrich: true` adds source-cell provenance — metered).
1182
+ */
1183
+ select(candidate: InspectCandidate, opts?: {
1184
+ enrich?: boolean;
1185
+ signal?: AbortSignal;
1186
+ }): Promise<InspectResult>;
1187
+ }
1188
+ interface AttachOptions extends CandidateQueryOptions {
1062
1189
  /**
1063
1190
  * Receive every InspectResult (headless mode). Fires whether or not the
1064
1191
  * built-in popup is enabled.
1065
1192
  */
1066
1193
  onInspect?: (result: InspectResult, ctx: InspectEventContext) => void;
1194
+ /**
1195
+ * Called when a click hits SEVERAL features (after dedupe/collapse),
1196
+ * with the priority-ordered candidates — render your own disambiguation
1197
+ * UI and resolve a choice via `ctx.select(candidate)`. When provided,
1198
+ * multi-hit clicks fire this instead of auto-inspecting the top
1199
+ * candidate. Single hits skip straight to `onInspect` / the popup.
1200
+ */
1201
+ onCandidates?: (candidates: InspectCandidate[], ctx: CandidatesEventContext) => void;
1067
1202
  /** Called when a click hits no inspectable feature. */
1068
1203
  onMiss?: (ctx: {
1069
1204
  lngLat: {
@@ -1072,21 +1207,17 @@ interface AttachOptions {
1072
1207
  };
1073
1208
  }) => void;
1074
1209
  /**
1075
- * Show the built-in minimal popup (plain DOM, no framework). Default: true
1076
- * when `onInspect` is not provided, false otherwise.
1210
+ * Show the built-in minimal popup (plain DOM, no framework) — the result
1211
+ * card, and a candidate list when a click hits several features.
1212
+ * Default: true when neither `onInspect` nor `onCandidates` is provided,
1213
+ * false otherwise.
1077
1214
  */
1078
1215
  popup?: boolean;
1079
1216
  /**
1080
- * Auto-enrich every click through the features API (metered — counts
1081
- * against the key's `featureCalls` quota). Default: false.
1217
+ * Auto-enrich every inspected result through the features API (metered —
1218
+ * counts against the key's `featureCalls` quota). Default: false.
1082
1219
  */
1083
1220
  enrich?: boolean;
1084
- /** Override the queried nav-aid style-layer ids. */
1085
- navAidLayers?: string[];
1086
- /** Override the queried bridge style-layer ids. */
1087
- bridgeLayers?: string[];
1088
- /** Override the queried area style-layer ids. */
1089
- areaLayers?: string[];
1090
1221
  }
1091
1222
  /** Handle returned by `attach()`. */
1092
1223
  interface InteractHandle {
@@ -1125,6 +1256,154 @@ declare class InteractError extends Error {
1125
1256
  });
1126
1257
  }
1127
1258
 
1259
+ /**
1260
+ * Multi-feature candidate collection for CHRTinteract (interact v1.1).
1261
+ *
1262
+ * A chart click rarely hits exactly one feature: a buoy sits on a channel
1263
+ * over a depth area, dense harbors stack nav aids over regulated areas over
1264
+ * DEPARE. This module turns "everything under (or near) the click" into a
1265
+ * deduplicated, priority-ordered candidate list:
1266
+ *
1267
+ * 1. COLLECT — queryRenderedFeatures over the interact layer sets with a
1268
+ * pixel tolerance box for point/line targets; polygon (area) targets
1269
+ * are kept only when they contain the exact click point.
1270
+ * 2. DEDUPE — the same S-57 object comes back once per tile it was split
1271
+ * into and once per style layer that rendered it. Features are folded
1272
+ * by source-cell-scoped S-57 identity: LNAM (the AGEN+FIDN+FIDS long
1273
+ * name — verified present on 100% of features in served CHRT tiles),
1274
+ * falling back to the AGEN/FIDN/FIDS composite.
1275
+ * 3. COLLAPSE — S-57 child objects (LIGHTS, TOPMAR, FOGSIG, RTPBCN,
1276
+ * DAYMAR) co-located with a parent buoy/beacon in the same hit set are
1277
+ * folded into the parent candidate; selecting the parent runs the v1
1278
+ * co-located merge so the light/topmark attributes surface there. A
1279
+ * mariner reads a lit buoy as ONE aid, not three S-57 objects.
1280
+ * 4. RANK — class priority: point targets > line targets > area targets,
1281
+ * with a within-band ladder kept value-coherent with the atlas label
1282
+ * ladder (`LABEL_PRIORITY` in atlas/labels.ts — the P4 collision
1283
+ * model). Area features NEVER preempt the buoy above them, but they
1284
+ * always remain in the list, so open water resolves to its DEPARE.
1285
+ *
1286
+ * Everything here is pure and map-optional: `collectCandidates()` works on
1287
+ * any InspectableFeature[]; `collectClickCandidates()` adds the
1288
+ * queryRenderedFeatures wiring. Entitlement enforcement stays in
1289
+ * `InteractClient` — these are building blocks, useless without CHRT tiles.
1290
+ */
1291
+
1292
+ /**
1293
+ * Within-band class ladder — lower = higher priority. Value-coherent with
1294
+ * the atlas label-collision ladder (`LABEL_PRIORITY`, atlas/labels.ts):
1295
+ * classes present in both carry the SAME value, so "what places first on
1296
+ * the chart" and "what lists first under a click" never invert. Documented
1297
+ * exceptions live in {@link INSPECT_RANK_DEVIATIONS}; the coherence unit
1298
+ * test (candidates.test.ts) enforces equal-unless-deviating.
1299
+ *
1300
+ * Rungs (mirroring the label ladder's tiers, extended for area classes the
1301
+ * label ladder never ranks):
1302
+ *
1303
+ * 100 — safety-critical: lights, hazards (rocks, obstructions, wrecks),
1304
+ * overhead clearances
1305
+ * 200 — nav-aid primaries: buoys, beacons, light vessels/floats
1306
+ * 250 — nav-aid auxiliaries: fog signals, radar beacons, daymarks,
1307
+ * topmarks, radio stations
1308
+ * 260 — bridges (interact-specific: preempt the water/contours below)
1309
+ * 300 — depth field: contours
1310
+ * 350 — caution / regulated / traffic areas
1311
+ * 400 — structures: landmarks, moorings, shoreline constructions
1312
+ * 410 — subsea infrastructure lines: cables, pipelines
1313
+ * 420 — channel & berthing infrastructure
1314
+ * 500 — ambient annotation: seabed, kelp, magnetic variation
1315
+ * 610 — DEPARE: the canonical "what water is this" answer
1316
+ * 640 — hydrographic context: rivers, canals, lakes, coastline
1317
+ * 700 — land / ambient areas
1318
+ */
1319
+ declare const INSPECT_CLASS_RANK: Record<string, number>;
1320
+ /** Rank for queried classes not in the ladder (mirrors DEFAULT_LABEL_PRIORITY). */
1321
+ declare const DEFAULT_INSPECT_CLASS_RANK = 450;
1322
+ /**
1323
+ * Classes whose interact rank deliberately differs from the atlas
1324
+ * LABEL_PRIORITY value, with why. The coherence test allows exactly these.
1325
+ */
1326
+ declare const INSPECT_RANK_DEVIATIONS: Record<string, string>;
1327
+ /** Compose the candidate rank: primary target band, then class ladder. */
1328
+ declare function candidateRank(targetClass: InspectTargetClass, rawLayer: string): number;
1329
+ /**
1330
+ * Source-cell-scoped S-57 identity for a rendered feature.
1331
+ *
1332
+ * CHRT tiles carry the GDAL S-57 feature-identity attributes end-to-end
1333
+ * (verified against served prod tiles: LNAM/FIDN/FIDS/AGEN present on
1334
+ * 100% of features): LNAM is the AGEN+FIDN+FIDS "long name" — the stable
1335
+ * object identity that survives a feature being split across tile
1336
+ * boundaries or rendered by several style layers. Scoped by `_cell_id`
1337
+ * because the same real-world object legitimately appears in multiple
1338
+ * source cells (band overlap) with distinct provenance.
1339
+ *
1340
+ * Returns null when the attributes are absent (never dedupe blind).
1341
+ */
1342
+ declare function featureIdentity(feature: InspectableFeature): string | null;
1343
+ /**
1344
+ * Resolve a candidate's click-target class: rendered geometry first (the
1345
+ * truth for classes with point/line/area variants), style-layer suffix
1346
+ * next, class default last (nav aids → point, everything else → area).
1347
+ */
1348
+ declare function resolveTargetClass(layerId: string, feature: InspectableFeature): InspectTargetClass;
1349
+ /**
1350
+ * Turn raw rendered features into the deduplicated, priority-ordered
1351
+ * candidate list. Pure — usable on any queryRenderedFeatures result (or
1352
+ * plain `{ layer, properties }` objects) without a map.
1353
+ *
1354
+ * Order in = render order (queryRenderedFeatures returns topmost first);
1355
+ * the sort is stable, so equal-rank candidates keep that visual order.
1356
+ */
1357
+ declare function collectCandidates(features: InspectableFeature[], opts?: Pick<CandidateQueryOptions, "collapseChildren">): InspectCandidate[];
1358
+ /** Default pixel tolerance around the click for point/line targets. */
1359
+ declare const DEFAULT_CLICK_TOLERANCE = 8;
1360
+ /**
1361
+ * Collect every inspectable candidate under (or within `tolerance` px of)
1362
+ * a click point: one tolerance-box query over the interact layer sets,
1363
+ * plus an exact-point query that gates polygon candidates — an area
1364
+ * feature is only offered when the click actually falls inside it, while
1365
+ * points and lines get the forgiving hit box.
1366
+ */
1367
+ declare function collectClickCandidates(map: InteractMapLike, point: {
1368
+ x: number;
1369
+ y: number;
1370
+ }, opts?: CandidateQueryOptions): InspectCandidate[];
1371
+
1372
+ /**
1373
+ * Map wiring for CHRTinteract — click → candidates → inspect().
1374
+ *
1375
+ * v1 was a faithful port of the first-party `/map` click pipeline
1376
+ * (`src/hooks/use-map-renderer.tsx` in the platform repo): nav-aid point
1377
+ * features → bridges → area features, taking the topmost hit. v1.1 keeps
1378
+ * that decode intact but routes every click through the candidate
1379
+ * collector (candidates.ts): all features under the click are deduped by
1380
+ * S-57 identity and priority-ordered, `decodeClick` resolves the TOP
1381
+ * candidate, and the attach handler in index.ts surfaces the rest for
1382
+ * disambiguation.
1383
+ *
1384
+ * Attribute merging (S-57 encodes lights/fog/topmarks as separate child
1385
+ * objects co-located with their parent buoy/beacon) — unchanged from v1:
1386
+ * - OBJNAM / COLOUR inherited from a co-located parent buoy/beacon
1387
+ * - CATFOG from a co-located FOGSIG
1388
+ * - RETRFL presence from a co-located RTPBCN
1389
+ * - TOPSHP from a co-located TOPMAR
1390
+ * - LITCHR / SIGPER / SIGGRP / LIGHT_COLOUR / CATLIT from the primary
1391
+ * co-located LIGHTS (preferring a non-sector light)
1392
+ * - all co-located LIGHTS combined into the sector list
1393
+ *
1394
+ * MapLibre / Mapbox GL is NOT imported — the map is consumed through the
1395
+ * structural `InteractMapLike` interface, so `maplibre-gl` remains an
1396
+ * optional peer dependency.
1397
+ */
1398
+
1399
+ /**
1400
+ * Resolve ONE candidate to its full InspectResult at a click location:
1401
+ * nav-aid classes run the co-located child-object merge, everything else
1402
+ * decodes directly (bridges/areas anchor to the click point when the
1403
+ * feature carries no Point geometry). Exported for tests.
1404
+ */
1405
+ declare function decodeCandidate(map: InteractMapLike, candidate: InspectCandidate, at: ClickAnchor, opts?: AttachOptions): InspectResult;
1406
+
1128
1407
  /**
1129
1408
  * CHRTinteract — productized click-to-inspect for CHRT charts.
1130
1409
  *
@@ -1162,6 +1441,29 @@ declare class InteractClient {
1162
1441
  * if (result.kind === "navaid") console.log(result.characteristic); // "Fl R 4s"
1163
1442
  */
1164
1443
  inspect(feature: InspectableFeature, opts?: InspectOptions): Promise<InspectResult>;
1444
+ /**
1445
+ * Collect EVERY inspectable feature under a point on a CHRT map —
1446
+ * deduplicated across tile boundaries by S-57 identity (`LNAM`) and
1447
+ * ordered by class priority (point targets > lines > areas, safety
1448
+ * classes first within each band). Area features never preempt the buoy
1449
+ * on top of them but always stay selectable: a click on open water
1450
+ * resolves to its DEPARE.
1451
+ *
1452
+ * `point` is a screen pixel point (`e.point` from a map click) or
1453
+ * `[lng, lat]`. Point/line targets are picked up within
1454
+ * `opts.tolerance` px (default 8); polygon candidates require the exact
1455
+ * point to fall inside them.
1456
+ *
1457
+ * The first call performs the server-side entitlement check.
1458
+ *
1459
+ * @example
1460
+ * const { candidates, select } = await chrt.interact.inspectAll(map, e.point);
1461
+ * const result = await select(candidates[0]); // full decode (+ merge)
1462
+ */
1463
+ inspectAll(map: InteractMapLike, point: {
1464
+ x: number;
1465
+ y: number;
1466
+ } | [number, number], opts?: CandidateQueryOptions): Promise<InspectCandidateSet>;
1165
1467
  /**
1166
1468
  * Attach click-to-inspect to a MapLibre / Mapbox GL map rendering CHRT
1167
1469
  * tiles. Resolves once the server-side entitlement check passes; rejects
@@ -1169,10 +1471,20 @@ declare class InteractClient {
1169
1471
  * no listeners are wired on denial.
1170
1472
  *
1171
1473
  * Headless-first: pass `onInspect` to receive every decoded
1172
- * {@link InspectResult} and render your own UI. Without `onInspect`, the
1474
+ * {@link InspectResult} and render your own UI. Without callbacks, the
1173
1475
  * built-in minimal popup is shown (opt back in explicitly with
1174
1476
  * `popup: true` to have both).
1175
1477
  *
1478
+ * A click that hits SEVERAL features (deduplicated by S-57 identity)
1479
+ * disambiguates instead of silently taking the topmost:
1480
+ * - `onCandidates` provided → it receives the priority-ordered list;
1481
+ * resolve a choice with `ctx.select(candidate)`.
1482
+ * - built-in popup → shows a candidate list; picking a row opens the
1483
+ * result card.
1484
+ * - `onInspect` only → the top candidate is inspected immediately, and
1485
+ * clicking the SAME spot again cycles to the next candidate — so an
1486
+ * area feature under a buoy is reachable with a second click.
1487
+ *
1176
1488
  * @example
1177
1489
  * const handle = await chrt.interact.attach(map, {
1178
1490
  * onInspect: (result) => console.log(result.title, result.characteristic),
@@ -1701,59 +2013,6 @@ declare const S101_SYMBOL_GROUPS: {
1701
2013
 
1702
2014
  declare const S101_NEW_SYMBOLS: NauticalSymbol[];
1703
2015
 
1704
- /**
1705
- * S-52 SVG Loader — pure (DOM-free) string operations over the inlined S-52
1706
- * SVG catalogue in `s52-svgs-generated.ts`. SVG files use S-52 color token
1707
- * names (e.g., CHBLK, LITRD) as fill/stroke values; `applyColorTheme` swaps
1708
- * those tokens for hex from the active palette.
1709
- *
1710
- * Browser-only image loaders live in `./s52-svg-loader-browser.ts` (sub-export
1711
- * `@chrtco/sdk/atlas/browser`) — they use `new Image()` and require a DOM.
1712
- */
1713
-
1714
- /**
1715
- * Get raw SVG string for an S-52 symbol by name (e.g., "BOYCAN01").
1716
- * Returns null if the symbol is not found.
1717
- */
1718
- declare function getS52SvgString(symbolName: string): string | null;
1719
- /**
1720
- * Get an S-52 SVG string with color tokens resolved to hex values
1721
- * from the specified color table.
1722
- */
1723
- declare function getThemedS52Svg(symbolName: string, colorTable?: ColorTableName): string | null;
1724
- /**
1725
- * Replace S-52 color token names in an SVG string with hex colors
1726
- * from the active color table.
1727
- *
1728
- * Matches tokens in fill="TOKEN" and stroke="TOKEN" attribute values.
1729
- */
1730
- declare function applyColorTheme(svgString: string, colorTable?: ColorTableName): string;
1731
- /** Get a list of all available S-52 point symbol names. */
1732
- declare function getAvailablePointSymbols(): string[];
1733
- /** Get a list of all available S-52 pattern names. */
1734
- declare function getAvailablePatterns(): string[];
1735
- /** Get a list of all available S-52 line symbol names. */
1736
- declare function getAvailableLineSymbols(): string[];
1737
- /** Stats for debugging */
1738
- declare function getS52SymbolStats(): {
1739
- pointCount: number;
1740
- patternCount: number;
1741
- lineCount: number;
1742
- totalCount: number;
1743
- };
1744
-
1745
- /**
1746
- * Zoom range of CHRT tile builds — kept in lockstep with the baremetal
1747
- * tippecanoe invocation (tools/chrt-baremetal/server/src/tilebuild/per-layer-zoom.ts).
1748
- *
1749
- * Per-S-57-class minzoom/maxzoom narrowing is handled inside the MVT at
1750
- * tile-build time via per-feature `tippecanoe.minzoom/maxzoom`; these two
1751
- * constants are the outer envelope the MapLibre source declares, so the
1752
- * client doesn't request tiles outside what the pmtiles can actually serve.
1753
- */
1754
- declare const BUILD_MINZOOM = 0;
1755
- declare const BUILD_MAXZOOM = 14;
1756
-
1757
2016
  /**
1758
2017
  * Post-consolidation (2026-04): one consolidated PMTiles per region, all
1759
2018
  * S-57 classes as distinct MVT layers inside. The MapLibre style emits one
@@ -2045,6 +2304,15 @@ interface StyleGeneratorOptions extends BuildSourcesOptions {
2045
2304
  * round so the rendered numbers match. Default "meters".
2046
2305
  */
2047
2306
  depthUnits?: "meters" | "feet";
2307
+ /**
2308
+ * Which symbol artwork the style references. "s52" (default) uses the
2309
+ * PresLib-derived S-52 set; "s101" rewrites icon references to the
2310
+ * official S-101 Portrayal Catalogue symbols (s101: image namespace)
2311
+ * where a counterpart exists — see s101-style.ts. "chrt" applies the
2312
+ * CHRT house ATON/LIGHTS glyphs with colour-true tinting — see
2313
+ * chrt-style.ts. Selection logic differences are documented per module.
2314
+ */
2315
+ symbolSet?: "s52" | "s101" | "chrt";
2048
2316
  /**
2049
2317
  * S-52 §SOUNDG02 — soundings shoaler than this depth (metres) render in
2050
2318
  * the high-contrast color; deeper soundings render in the muted color.
@@ -2074,6 +2342,150 @@ declare function getStyleStats(style: MapboxStyle): {
2074
2342
  objectClasses: Set<string>;
2075
2343
  };
2076
2344
 
2345
+ declare const S101_SOURCE_COMMIT = "05063500e898544c90078ab78a61efc72b7e62f3";
2346
+
2347
+ /**
2348
+ * S-101 symbol-set support (portrayal-excellence 7c, first slice).
2349
+ *
2350
+ * The vendored official S-101 Portrayal Catalogue symbols (see
2351
+ * `assets/s101/PROVENANCE.md`) are registered on the map under the
2352
+ * `s101:` image namespace so they can coexist with the S-52 set. A style
2353
+ * document is switched to the S-101 symbol set by rewriting every
2354
+ * icon-image reference whose symbol has an official S-101 counterpart —
2355
+ * selection logic (the S-52 lookup expressions) is unchanged, only the
2356
+ * artwork swaps. That is deliberate and documented: the S-101 rule engine
2357
+ * (Lua rules in the PC's `Rules/`) is the later 7c phase; the official
2358
+ * SVGs themselves are exact today.
2359
+ *
2360
+ * Colour theming resolves through the OFFICIAL S-101 day/dusk/night
2361
+ * profiles (from the PC's {day,dusk,night}SvgStyle.css), not CHRT's S-52
2362
+ * tables — the S-101 style is spec-true end to end at the symbol level.
2363
+ */
2364
+
2365
+ /** MapLibre image-id namespace for the S-101 symbol set. */
2366
+ declare const S101_ICON_PREFIX = "s101:";
2367
+ /** All vendored S-101 symbol names (unprefixed). */
2368
+ declare const S101_SYMBOL_NAMES: ReadonlySet<string>;
2369
+ /** Resolve an S-101 colour token via the official profile for `table`. */
2370
+ declare function resolveS101Color(token: string, table?: ColorTableName): string;
2371
+ /**
2372
+ * Get an S-101 symbol SVG with its colour tokens resolved through the
2373
+ * official S-101 profile. Returns null for unknown symbols.
2374
+ */
2375
+ declare function getThemedS101Svg(symbolName: string, table?: ColorTableName): string | null;
2376
+ /**
2377
+ * Switch a generated style document to the S-101 symbol set. Symbol names
2378
+ * without an official S-101 counterpart keep their S-52 image (both sets
2379
+ * are loaded by `loadChartSymbolImages`), so coverage can only grow as the
2380
+ * PC adds symbols. Returns the same style object (mutated), for chaining.
2381
+ */
2382
+ declare function applyS101SymbolSet(style: MapboxStyle): MapboxStyle;
2383
+
2384
+ /**
2385
+ * CHRT house ATON/LIGHTS symbol set (portrayal-excellence 7d, ATON slice).
2386
+ *
2387
+ * Design intent (Anthony's brief): clear, simplified silhouettes;
2388
+ * colour-true marks — a green buoy IS green, a red buoy IS red, exactly
2389
+ * as encoded in the feature's COLOUR attribute; sound-capable aids show a
2390
+ * sound badge, radar-capable aids show a radar badge.
2391
+ *
2392
+ * Mechanics:
2393
+ * - Tintable bodies (lateral/special buoys, beacons, daymarks, the light
2394
+ * flare) ship as single-colour SDF glyphs; a layer-level `icon-color`
2395
+ * expression tints them from the FIRST listed COLOUR code (the dominant
2396
+ * band per S-57 encoding). Region conventions fall out of the data —
2397
+ * nothing here hardcodes IALA A/B.
2398
+ * - Identity-coloured marks (cardinals, isolated danger, safe water) are
2399
+ * fixed-palette glyphs: their colour scheme is invariant under IALA and
2400
+ * single-tint would destroy the meaning. MapLibre ignores `icon-color`
2401
+ * for non-SDF images, so both kinds coexist in one layer.
2402
+ * - Capability badges ride the existing child-symbol mechanics: FOGSIG
2403
+ * features render the sound badge, RTPBCN/RDOSTA the radar badge, at
2404
+ * their S-52 child offsets beside the parent aid.
2405
+ *
2406
+ * The house palette below is a v1 placeholder tuned for legibility against
2407
+ * CHRT's water fills — the 7d design pass (Anthony + design) owns the
2408
+ * final values. Naming/pricing of the house style is an OPEN decision
2409
+ * (see .chrt/plans/chrt-portrayal-excellence.md P7d); nothing here touches
2410
+ * pricing or entitlements.
2411
+ */
2412
+
2413
+ declare const CHRT_ICON_PREFIX = "chrt:";
2414
+ /** Glyphs registered as SDF (tintable via icon-color). */
2415
+ declare const CHRT_SDF_GLYPHS: ReadonlySet<string>;
2416
+ /** All house glyph names. */
2417
+ declare const CHRT_GLYPH_NAMES: ReadonlySet<string>;
2418
+ /**
2419
+ * House ATON palette — S-57 COLOUR code → hex. v1 placeholder values
2420
+ * (see module header); chosen for contrast on the CHRT day water ramp.
2421
+ */
2422
+ declare const CHRT_ATON_COLORS: Record<string, string>;
2423
+ /** First-listed-colour-wins tint expression for SDF bodies. */
2424
+ declare function chrtAtonTintExpression(): unknown[];
2425
+ /** Lights tint: exact colour (incl. blue/orange — the house style renders
2426
+ * the encoded colour, unlike the S-52 three-bucket flares); colourless
2427
+ * lights read as white with the dark halo carrying contrast. */
2428
+ declare function chrtLightTintExpression(): unknown[];
2429
+ /**
2430
+ * Switch a generated style document to the CHRT house symbol set: rewrite
2431
+ * the ATON/LIGHTS icon expressions and inject the colour-true tint on
2432
+ * tintable layers. Returns the same style object (mutated).
2433
+ */
2434
+ declare function applyChrtSymbolSet(style: MapboxStyle): MapboxStyle;
2435
+
2436
+ /**
2437
+ * S-52 SVG Loader — pure (DOM-free) string operations over the inlined S-52
2438
+ * SVG catalogue in `s52-svgs-generated.ts`. SVG files use S-52 color token
2439
+ * names (e.g., CHBLK, LITRD) as fill/stroke values; `applyColorTheme` swaps
2440
+ * those tokens for hex from the active palette.
2441
+ *
2442
+ * Browser-only image loaders live in `./s52-svg-loader-browser.ts` (sub-export
2443
+ * `@chrtco/sdk/atlas/browser`) — they use `new Image()` and require a DOM.
2444
+ */
2445
+
2446
+ /**
2447
+ * Get raw SVG string for an S-52 symbol by name (e.g., "BOYCAN01").
2448
+ * Returns null if the symbol is not found.
2449
+ */
2450
+ declare function getS52SvgString(symbolName: string): string | null;
2451
+ /**
2452
+ * Get an S-52 SVG string with color tokens resolved to hex values
2453
+ * from the specified color table.
2454
+ */
2455
+ declare function getThemedS52Svg(symbolName: string, colorTable?: ColorTableName): string | null;
2456
+ /**
2457
+ * Replace S-52 color token names in an SVG string with hex colors
2458
+ * from the active color table.
2459
+ *
2460
+ * Matches tokens in fill="TOKEN" and stroke="TOKEN" attribute values.
2461
+ */
2462
+ declare function applyColorTheme(svgString: string, colorTable?: ColorTableName): string;
2463
+ /** Get a list of all available S-52 point symbol names. */
2464
+ declare function getAvailablePointSymbols(): string[];
2465
+ /** Get a list of all available S-52 pattern names. */
2466
+ declare function getAvailablePatterns(): string[];
2467
+ /** Get a list of all available S-52 line symbol names. */
2468
+ declare function getAvailableLineSymbols(): string[];
2469
+ /** Stats for debugging */
2470
+ declare function getS52SymbolStats(): {
2471
+ pointCount: number;
2472
+ patternCount: number;
2473
+ lineCount: number;
2474
+ totalCount: number;
2475
+ };
2476
+
2477
+ /**
2478
+ * Zoom range of CHRT tile builds — kept in lockstep with the baremetal
2479
+ * tippecanoe invocation (tools/chrt-baremetal/server/src/tilebuild/per-layer-zoom.ts).
2480
+ *
2481
+ * Per-S-57-class minzoom/maxzoom narrowing is handled inside the MVT at
2482
+ * tile-build time via per-feature `tippecanoe.minzoom/maxzoom`; these two
2483
+ * constants are the outer envelope the MapLibre source declares, so the
2484
+ * client doesn't request tiles outside what the pmtiles can actually serve.
2485
+ */
2486
+ declare const BUILD_MINZOOM = 0;
2487
+ declare const BUILD_MAXZOOM = 14;
2488
+
2077
2489
  /**
2078
2490
  * CHRTstyle custom styles — the customer-facing map_styles config applied
2079
2491
  * on top of the generated S-52 style.
@@ -2448,10 +2860,11 @@ declare class Chrt {
2448
2860
  * transformRequest: chrt.transformRequest(),
2449
2861
  * });
2450
2862
  *
2451
- * @remarks S-101 portrayal is on the roadmap; today `style()` emits S-52.
2452
- * Generated locally, so it never applies a key-bound CHRTstyle custom
2453
- * style — use {@link styleUrl} / {@link fetchStyle} (the served Style API)
2454
- * for that.
2863
+ * @remarks Pass `symbolSet: "s101"` for the official S-101 Portrayal
2864
+ * Catalogue symbol artwork (load images via `loadS101SymbolImages` from
2865
+ * `@chrtco/sdk/atlas/browser`); default is the S-52 set. Generated
2866
+ * locally, so it never applies a key-bound CHRTstyle custom style — use
2867
+ * {@link styleUrl} / {@link fetchStyle} (the served Style API) for that.
2455
2868
  */
2456
2869
  style(opts?: ChrtStyleOptions): MapboxStyle;
2457
2870
  /**
@@ -2503,4 +2916,4 @@ declare class Chrt {
2503
2916
  warmTiles(region?: string): Promise<void>;
2504
2917
  }
2505
2918
 
2506
- export { ALL_NAV_AID_LAYERS, ALL_WATER_BODY_LAYERS, AREA_QUERY_LAYERS, type AreaInspectResult, type AtlasStyle, type AttachOptions, BAND_DRAW_ORDER, BAND_PRIORITY_RANGES, type BBox, BRIDGE_QUERY_LAYERS, BUILD_MAXZOOM, BUILD_MINZOOM, type BandCode, type BandPriorityRange, type BridgeInspectResult, type BuildOfflineStyleOptions, type BuildSourcesOptions, CHART_BAND_CODES, CHART_CASCADE_CODES, CHART_SECTIONS, type CellDeletedEvent, type CellDetail, type CellEventData, type CellNewEvent, type CellUpdatedData, type CellUpdatedEvent, type CellsOptions, type CellsResponse, type ChartSection, Chrt, type ChrtConfig, ChrtError, type ChrtStyleOptions, type ChrtStyleTheme, ColorTableName, type CoverageOptions, type CoverageResponse, type CoverageSource, type CustomStyleConfig, DEFAULT_CUSTOM_STYLE_CONFIG, DEFAULT_LABEL_SETTINGS, DEFAULT_NAV_AID_SETTINGS, DEFAULT_REGION, DEFAULT_SOUNDING_SETTINGS, DEFAULT_TILE_BASE_URL, DEFAULT_TILE_REGION, DEFAULT_WATER_BODY_SETTINGS, type DecodedAreaFeature, type DecodedBridge, type DecodedNavAid, type DecodedProperty, type DisplayCategory, type DisplayMode, type FeatureCollection, type FeaturesOptions, type FetchStyleOptions, FileSystemAdapter, type FlashPattern, type FlashPhase, type GenerateCustomStyleOptions, type GeneratedCustomStyle, type GeoJsonFeature, type GeoJsonGeometry, type GeomType, type InspectEnrichment, type InspectEventContext, type InspectNotice, type InspectOptions, type InspectResult, type InspectableFeature, InteractClient, type InteractEntitlement, InteractError, type InteractErrorCode, type InteractHandle, type InteractMapLike, type InteractMapMouseEvent, LABELED_LAYERS, LABEL_BEHAVIOR, LABEL_LAYER_GROUPS, LABEL_PRIORITY, type LabelBehavior, type LabelConfigOptions, type LabelLayerConfig, type LabelSettings, type LookupEntry, type MapLibreStyle, type MapboxStyle, type MapboxVectorSource, NAUTICAL_SYMBOLS, NAV_AID_LAYER_GROUPS, NAV_AID_QUERY_LAYERS, NON_SOLAS_DISCLAIMER, NON_SOLAS_DISCLAIMER_SHORT, type NauticalCategory, type NauticalSymbol, type NavAidInspectResult, type NavAidSettings, type OfflineBundleResponse, type OfflineDownloadOptions, type OfflineDownloadProgress, type OfflineDownloadResult, OfflineError, type OfflineErrorCode, type OfflineFetchStyleOptions, type OfflineHeartbeatOptions, type OfflineRegionSummary, type OfflineRemoveOptions, OfflineStyleError, type OfflineStylePlatform, type OfflineStyleResponse, type PmtilesVectorSource, type QueryOptions, type ResolvedStyle, type ResolvedTheme, type RouteFeatureQueryOptions, type RouteFeatureQueryResponse, type RouteQueryOptions, type RouteQueryResponse, type S101Feature, S101_CHART_SECTIONS, S101_FEATURES, S101_NEW_SYMBOLS, S101_SYMBOL_GROUPS, S52_DRAW_ORDER, S52_LOOKUP, SOUNDING_LAYERS, SYMBOL_GROUPS, SYMBOL_MAP, type ScaleBand, type SectorArcFeature, type SectorArcFeatureCollection, type SectorInfo, type SoundingSettings, type SourceMode, type StyleGeneratorOptions, type StyleLayer, type StyleUrlOptions, type SymbolGroup, TileAuth, type TileGroup, type TileGroupsResponse, TileTokenError, type TileTokenErrorCode, type TileTokenResponse, type TransformRequest, type TransformedRequest, type VectorSourceSpec, WATER_BODY_LAYER_GROUPS, type WaterBodySettings, type WebhookEvent, type WebhookEventType, type WebhookPayload, applyColorTheme, applyCustomStyleSettings, bandFilterExpression, buildFlashPattern, buildLabelLayer, buildLayersForClass, buildOfflineStyle, buildSectorArcGeoJSON, buildSectorArcsFC, buildSectorsFromFeatures, buildSources, combineWithBandFilter, daymarkColor, decimateFeatures, decodeAreaFeatureProps, decodeBridgeProps, decodeNavAidProps, depareColor, depareFillExpression, deriveMarinerName, extractNavAidDesignation, generateCustomStyle, generateSpriteManifest, generateSpriteSheet, generateStyle, generateStyleJSON, getAvailableLineSymbols, getAvailablePatterns, getAvailablePointSymbols, getCollisionSettings, getDrawPriority, getGridSizeForZoom, getIconExpression, getLabelBehavior, getLabelConfig, getLabelPriority, getLookupEntry, getMaxCellsForZoom, getOrderedClasses, getS52SvgString, getS52SymbolStats, getStyleStats, getSymbolSvgString, getThemedS52Svg, getTopmarkMeaning, hazardColor, hazardFillExpression, isLabelLayerVisible, isNavAidLayer, isNavAidLayerVisible, isSoundingLayerVisible, isVisibleInMode, isWaterBodyLayerVisible, labelSortKey, lateralColor, lateralFillExpression, lightColor, lightFillExpression, normalizeTheme, paginate, parseListCodes, parseWebhook, preprocessLights, preprocessNavAids, preprocessSoundings, preprocessWaterBodies, resolveCustomTheme, resolveStyle, sanitizeCustomStyleConfig, scaleSizeValue, scaminToMinZoom, withinBboxFilter, worldMinusBboxPolygon };
2919
+ export { ALL_NAV_AID_LAYERS, ALL_WATER_BODY_LAYERS, AREA_QUERY_LAYERS, type AreaInspectResult, type AtlasStyle, type AttachOptions, BAND_DRAW_ORDER, BAND_PRIORITY_RANGES, type BBox, BRIDGE_QUERY_LAYERS, BUILD_MAXZOOM, BUILD_MINZOOM, type BandCode, type BandPriorityRange, type BridgeInspectResult, type BuildOfflineStyleOptions, type BuildSourcesOptions, CHART_BAND_CODES, CHART_CASCADE_CODES, CHART_SECTIONS, CHRT_ATON_COLORS, CHRT_GLYPH_NAMES, CHRT_ICON_PREFIX, CHRT_SDF_GLYPHS, type CandidateQueryOptions, type CandidatesEventContext, type CellDeletedEvent, type CellDetail, type CellEventData, type CellNewEvent, type CellUpdatedData, type CellUpdatedEvent, type CellsOptions, type CellsResponse, type ChartSection, Chrt, type ChrtConfig, ChrtError, type ChrtStyleOptions, type ChrtStyleTheme, type ClickAnchor, ColorTableName, type CoverageOptions, type CoverageResponse, type CoverageSource, type CustomStyleConfig, DEFAULT_CLICK_TOLERANCE, DEFAULT_CUSTOM_STYLE_CONFIG, DEFAULT_INSPECT_CLASS_RANK, DEFAULT_LABEL_SETTINGS, DEFAULT_NAV_AID_SETTINGS, DEFAULT_REGION, DEFAULT_SOUNDING_SETTINGS, DEFAULT_TILE_BASE_URL, DEFAULT_TILE_REGION, DEFAULT_WATER_BODY_SETTINGS, type DecodedAreaFeature, type DecodedBridge, type DecodedNavAid, type DecodedProperty, type DisplayCategory, type DisplayMode, type FeatureCollection, type FeaturesOptions, type FetchStyleOptions, FileSystemAdapter, type FlashPattern, type FlashPhase, type GenerateCustomStyleOptions, type GeneratedCustomStyle, type GeoJsonFeature, type GeoJsonGeometry, type GeomType, INSPECT_CLASS_RANK, INSPECT_RANK_DEVIATIONS, type InspectCandidate, type InspectCandidateSet, type InspectEnrichment, type InspectEventContext, type InspectNotice, type InspectOptions, type InspectResult, type InspectTargetClass, type InspectableFeature, InteractClient, type InteractEntitlement, InteractError, type InteractErrorCode, type InteractHandle, type InteractMapLike, type InteractMapMouseEvent, LABELED_LAYERS, LABEL_BEHAVIOR, LABEL_LAYER_GROUPS, LABEL_PRIORITY, type LabelBehavior, type LabelConfigOptions, type LabelLayerConfig, type LabelSettings, type LookupEntry, type MapLibreStyle, type MapboxStyle, type MapboxVectorSource, NAUTICAL_SYMBOLS, NAV_AID_LAYER_GROUPS, NAV_AID_QUERY_LAYERS, NON_SOLAS_DISCLAIMER, NON_SOLAS_DISCLAIMER_SHORT, type NauticalCategory, type NauticalSymbol, type NavAidInspectResult, type NavAidSettings, type OfflineBundleResponse, type OfflineDownloadOptions, type OfflineDownloadProgress, type OfflineDownloadResult, OfflineError, type OfflineErrorCode, type OfflineFetchStyleOptions, type OfflineHeartbeatOptions, type OfflineRegionSummary, type OfflineRemoveOptions, OfflineStyleError, type OfflineStylePlatform, type OfflineStyleResponse, type PmtilesVectorSource, type QueryOptions, type ResolvedStyle, type ResolvedTheme, type RouteFeatureQueryOptions, type RouteFeatureQueryResponse, type RouteQueryOptions, type RouteQueryResponse, type S101Feature, S101_CHART_SECTIONS, S101_FEATURES, S101_ICON_PREFIX, S101_NEW_SYMBOLS, S101_SOURCE_COMMIT, S101_SYMBOL_GROUPS, S101_SYMBOL_NAMES, S52_DRAW_ORDER, S52_LOOKUP, SOUNDING_LAYERS, SYMBOL_GROUPS, SYMBOL_MAP, type ScaleBand, type SectorArcFeature, type SectorArcFeatureCollection, type SectorInfo, type SoundingSettings, type SourceMode, type StyleGeneratorOptions, type StyleLayer, type StyleUrlOptions, type SymbolGroup, TileAuth, type TileGroup, type TileGroupsResponse, TileTokenError, type TileTokenErrorCode, type TileTokenResponse, type TransformRequest, type TransformedRequest, type VectorSourceSpec, WATER_BODY_LAYER_GROUPS, type WaterBodySettings, type WebhookEvent, type WebhookEventType, type WebhookPayload, applyChrtSymbolSet, applyColorTheme, applyCustomStyleSettings, applyS101SymbolSet, bandFilterExpression, buildFlashPattern, buildLabelLayer, buildLayersForClass, buildOfflineStyle, buildSectorArcGeoJSON, buildSectorArcsFC, buildSectorsFromFeatures, buildSources, candidateRank, chrtAtonTintExpression, chrtLightTintExpression, collectCandidates, collectClickCandidates, combineWithBandFilter, daymarkColor, decimateFeatures, decodeAreaFeatureProps, decodeBridgeProps, decodeCandidate, decodeNavAidProps, depareColor, depareFillExpression, deriveMarinerName, extractNavAidDesignation, featureIdentity, generateCustomStyle, generateSpriteManifest, generateSpriteSheet, generateStyle, generateStyleJSON, getAvailableLineSymbols, getAvailablePatterns, getAvailablePointSymbols, getCollisionSettings, getDrawPriority, getGridSizeForZoom, getIconExpression, getLabelBehavior, getLabelConfig, getLabelPriority, getLookupEntry, getMaxCellsForZoom, getOrderedClasses, getS52SvgString, getS52SymbolStats, getStyleStats, getSymbolSvgString, getThemedS101Svg, getThemedS52Svg, getTopmarkMeaning, hazardColor, hazardFillExpression, isLabelLayerVisible, isNavAidLayer, isNavAidLayerVisible, isSoundingLayerVisible, isVisibleInMode, isWaterBodyLayerVisible, labelSortKey, lateralColor, lateralFillExpression, lightColor, lightFillExpression, normalizeTheme, paginate, parseListCodes, parseWebhook, preprocessLights, preprocessNavAids, preprocessSoundings, preprocessWaterBodies, resolveCustomTheme, resolveS101Color, resolveStyle, resolveTargetClass, sanitizeCustomStyleConfig, scaleSizeValue, scaminToMinZoom, withinBboxFilter, worldMinusBboxPolygon };