@uwdata/mosaic-plot 0.6.1 → 0.7.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.
@@ -12864,6 +12864,15 @@ var Query = class _Query {
12864
12864
  static except(...queries) {
12865
12865
  return new SetOperation("EXCEPT", queries.flat());
12866
12866
  }
12867
+ static describe(query) {
12868
+ const q = query.clone();
12869
+ const { clone, toString } = q;
12870
+ return Object.assign(q, {
12871
+ describe: true,
12872
+ clone: () => _Query.describe(clone.call(q)),
12873
+ toString: () => `DESCRIBE ${toString.call(q)}`
12874
+ });
12875
+ }
12867
12876
  constructor() {
12868
12877
  this.query = {
12869
12878
  with: [],
@@ -13098,6 +13107,7 @@ var Query = class _Query {
13098
13107
  }
13099
13108
  toString() {
13100
13109
  const {
13110
+ with: cte,
13101
13111
  select: select2,
13102
13112
  distinct: distinct2,
13103
13113
  from,
@@ -13109,8 +13119,7 @@ var Query = class _Query {
13109
13119
  qualify,
13110
13120
  orderby,
13111
13121
  limit,
13112
- offset: offset2,
13113
- with: cte
13122
+ offset: offset2
13114
13123
  } = this.query;
13115
13124
  const sql2 = [];
13116
13125
  if (cte.length) {
@@ -13232,6 +13241,9 @@ var SetOperation = class _SetOperation {
13232
13241
  function isQuery(value) {
13233
13242
  return value instanceof Query || value instanceof SetOperation;
13234
13243
  }
13244
+ function isDescribeQuery(value) {
13245
+ return isQuery(value) && value.describe;
13246
+ }
13235
13247
  function unquote(s2) {
13236
13248
  return isDoubleQuoted(s2) ? s2.slice(1, -1) : s2;
13237
13249
  }
@@ -13331,131 +13343,6 @@ function create(name, query, {
13331
13343
  return "CREATE" + (replace ? " OR REPLACE " : " ") + (temp ? "TEMP " : "") + (view ? "VIEW" : "TABLE") + (replace ? " " : " IF NOT EXISTS ") + name + " AS " + query;
13332
13344
  }
13333
13345
 
13334
- // ../core/src/util/js-type.js
13335
- function jsType(type2) {
13336
- switch (type2) {
13337
- case "BIGINT":
13338
- case "HUGEINT":
13339
- case "INTEGER":
13340
- case "SMALLINT":
13341
- case "TINYINT":
13342
- case "UBIGINT":
13343
- case "UINTEGER":
13344
- case "USMALLINT":
13345
- case "UTINYINT":
13346
- case "DOUBLE":
13347
- case "FLOAT":
13348
- case "REAL":
13349
- case "DECIMAL":
13350
- return "number";
13351
- case "DATE":
13352
- case "TIMESTAMP":
13353
- case "TIMESTAMPTZ":
13354
- case "TIMESTAMP WITH TIME ZONE":
13355
- case "TIME":
13356
- case "TIMESTAMP_NS":
13357
- return "date";
13358
- case "BOOLEAN":
13359
- return "boolean";
13360
- case "VARCHAR":
13361
- case "UUID":
13362
- return "string";
13363
- case "LIST":
13364
- return "array";
13365
- case "BLOB":
13366
- case "STRUCT":
13367
- case "MAP":
13368
- return "object";
13369
- default:
13370
- throw new Error(`Unsupported type: ${type2}`);
13371
- }
13372
- }
13373
-
13374
- // ../core/src/util/summarize.js
13375
- var Count = "count";
13376
- var Nulls = "nulls";
13377
- var Max = "max";
13378
- var Min = "min";
13379
- var Distinct = "distinct";
13380
- var statMap = {
13381
- [Count]: count,
13382
- [Distinct]: (column3) => count(column3).distinct(),
13383
- [Max]: max,
13384
- [Min]: min,
13385
- [Nulls]: (column3) => count().where(isNull(column3))
13386
- };
13387
- function summarize({ table, column: column3 }, stats) {
13388
- return Query.from(table).select(stats.map((s2) => [s2, statMap[s2](column3)]));
13389
- }
13390
-
13391
- // ../core/src/Catalog.js
13392
- var object = () => /* @__PURE__ */ Object.create(null);
13393
- var Catalog = class {
13394
- constructor(coordinator2) {
13395
- this.mc = coordinator2;
13396
- this.clear();
13397
- }
13398
- clear() {
13399
- this.tables = object();
13400
- }
13401
- tableInfo(table) {
13402
- const cache = this.tables;
13403
- if (cache[table]) {
13404
- return cache[table];
13405
- }
13406
- const infoPromise = getTableInfo(this.mc, table).catch((err) => {
13407
- cache[table] = null;
13408
- throw err;
13409
- });
13410
- return cache[table] = infoPromise;
13411
- }
13412
- async fieldInfo({ table, column: column3, stats }) {
13413
- const tableInfo = await this.tableInfo(table);
13414
- const colInfo = tableInfo[column3];
13415
- if (colInfo == null)
13416
- return;
13417
- if (!stats?.length)
13418
- return colInfo;
13419
- const result = await this.mc.query(
13420
- summarize(colInfo, stats),
13421
- { persist: true }
13422
- );
13423
- const info = { ...colInfo, ...Array.from(result)[0] };
13424
- for (const key in info) {
13425
- const value = info[key];
13426
- if (typeof value === "bigint") {
13427
- info[key] = Number(value);
13428
- }
13429
- }
13430
- return info;
13431
- }
13432
- async queryFields(fields) {
13433
- const list = await resolveFields(this, fields);
13434
- const data = await Promise.all(list.map((f) => this.fieldInfo(f)));
13435
- return data.filter((x3) => x3);
13436
- }
13437
- };
13438
- async function getTableInfo(mc, table) {
13439
- const result = await mc.query(
13440
- `DESCRIBE ${asRelation(table)}`,
13441
- { type: "json", cache: false }
13442
- );
13443
- const columns = object();
13444
- for (const entry of result) {
13445
- columns[entry.column_name] = {
13446
- table,
13447
- column: entry.column_name,
13448
- sqlType: entry.column_type,
13449
- type: jsType(entry.column_type),
13450
- nullable: entry.null === "YES"
13451
- };
13452
- }
13453
- return columns;
13454
- }
13455
- async function resolveFields(catalog, list) {
13456
- return list.length === 1 && list[0].column === "*" ? Object.values(await catalog.tableInfo(list[0].table)) : list;
13457
- }
13458
-
13459
13346
  // ../core/src/util/hash.js
13460
13347
  function fnv_hash(v2) {
13461
13348
  let a2 = 2166136261;
@@ -13815,7 +13702,7 @@ function consolidate(group3, enqueue, record) {
13815
13702
  type: "arrow",
13816
13703
  cache: false,
13817
13704
  record: false,
13818
- query: consolidatedQuery(group3, record)
13705
+ query: group3.query = consolidatedQuery(group3, record)
13819
13706
  },
13820
13707
  result: group3.result = queryResult()
13821
13708
  });
@@ -13863,7 +13750,7 @@ function consolidatedQuery(group3, record) {
13863
13750
  return query.$select(Array.from(fields.values()));
13864
13751
  }
13865
13752
  async function processResults(group3, cache) {
13866
- const { maps, result } = group3;
13753
+ const { maps, query, result } = group3;
13867
13754
  if (!maps)
13868
13755
  return;
13869
13756
  let data;
@@ -13875,25 +13762,33 @@ async function processResults(group3, cache) {
13875
13762
  }
13876
13763
  return;
13877
13764
  }
13765
+ const describe = isDescribeQuery(query);
13878
13766
  group3.forEach(({ entry }, index2) => {
13879
13767
  const { request, result: result2 } = entry;
13880
- const projected = projectResult(data, maps[index2]);
13768
+ const map4 = maps[index2];
13769
+ const extract = describe && map4 ? filterResult(data, map4) : map4 ? projectResult(data, map4) : data;
13881
13770
  if (request.cache) {
13882
- cache.set(String(request.query), projected);
13771
+ cache.set(String(request.query), extract);
13883
13772
  }
13884
- result2.fulfill(projected);
13773
+ result2.fulfill(extract);
13885
13774
  });
13886
13775
  }
13887
13776
  function projectResult(data, map4) {
13888
- if (map4) {
13889
- const cols = {};
13890
- for (const [name, as] of map4) {
13891
- cols[as] = data.getChild(name);
13777
+ const cols = {};
13778
+ for (const [name, as] of map4) {
13779
+ cols[as] = data.getChild(name);
13780
+ }
13781
+ return new data.constructor(cols);
13782
+ }
13783
+ function filterResult(data, map4) {
13784
+ const lookup = new Map(map4);
13785
+ const result = [];
13786
+ for (const d of data) {
13787
+ if (lookup.has(d.column_name)) {
13788
+ result.push({ ...d, column_name: lookup.get(d.column_name) });
13892
13789
  }
13893
- return new data.constructor(cols);
13894
- } else {
13895
- return data;
13896
13790
  }
13791
+ return result;
13897
13792
  }
13898
13793
 
13899
13794
  // ../core/src/util/cache.js
@@ -14140,6 +14035,197 @@ function QueryManager() {
14140
14035
  };
14141
14036
  }
14142
14037
 
14038
+ // ../core/src/util/js-type.js
14039
+ function jsType(type2) {
14040
+ switch (type2) {
14041
+ case "BIGINT":
14042
+ case "HUGEINT":
14043
+ case "INTEGER":
14044
+ case "SMALLINT":
14045
+ case "TINYINT":
14046
+ case "UBIGINT":
14047
+ case "UINTEGER":
14048
+ case "USMALLINT":
14049
+ case "UTINYINT":
14050
+ case "DOUBLE":
14051
+ case "FLOAT":
14052
+ case "REAL":
14053
+ return "number";
14054
+ case "DATE":
14055
+ case "TIMESTAMP":
14056
+ case "TIMESTAMPTZ":
14057
+ case "TIMESTAMP WITH TIME ZONE":
14058
+ case "TIME":
14059
+ case "TIMESTAMP_NS":
14060
+ return "date";
14061
+ case "BOOLEAN":
14062
+ return "boolean";
14063
+ case "VARCHAR":
14064
+ case "UUID":
14065
+ return "string";
14066
+ case "ARRAY":
14067
+ case "LIST":
14068
+ return "array";
14069
+ case "BLOB":
14070
+ case "STRUCT":
14071
+ case "MAP":
14072
+ case "GEOMETRY":
14073
+ return "object";
14074
+ default:
14075
+ if (type2.startsWith("DECIMAL")) {
14076
+ return "number";
14077
+ } else if (type2.startsWith("STRUCT") || type2.startsWith("MAP")) {
14078
+ return "object";
14079
+ } else if (type2.endsWith("]")) {
14080
+ return "array";
14081
+ }
14082
+ throw new Error(`Unsupported type: ${type2}`);
14083
+ }
14084
+ }
14085
+
14086
+ // ../core/src/util/convert-arrow.js
14087
+ var INTEGER = 2;
14088
+ var FLOAT = 3;
14089
+ var DECIMAL = 7;
14090
+ var TIMESTAMP = 10;
14091
+ function isArrowTable(values2) {
14092
+ return typeof values2?.getChild === "function";
14093
+ }
14094
+ function convertArrowArrayType(type2) {
14095
+ switch (type2.typeId) {
14096
+ case INTEGER:
14097
+ case FLOAT:
14098
+ case DECIMAL:
14099
+ return Float64Array;
14100
+ default:
14101
+ return Array;
14102
+ }
14103
+ }
14104
+ function convertArrowValue(type2) {
14105
+ const { typeId } = type2;
14106
+ if (typeId === TIMESTAMP) {
14107
+ return (v2) => v2 == null ? v2 : new Date(v2);
14108
+ }
14109
+ if (typeId === INTEGER && type2.bitWidth >= 64) {
14110
+ return (v2) => v2 == null ? v2 : Number(v2);
14111
+ }
14112
+ if (typeId === DECIMAL) {
14113
+ const scale3 = 1 / Math.pow(10, type2.scale);
14114
+ return (v2) => v2 == null ? v2 : decimalToNumber(v2, scale3);
14115
+ }
14116
+ return (v2) => v2;
14117
+ }
14118
+ function convertArrowColumn(column3) {
14119
+ const { type: type2 } = column3;
14120
+ const { typeId } = type2;
14121
+ if (typeId === TIMESTAMP) {
14122
+ const size = column3.length;
14123
+ const array3 = new Array(size);
14124
+ for (let row = 0; row < size; ++row) {
14125
+ const v2 = column3.get(row);
14126
+ array3[row] = v2 == null ? null : new Date(v2);
14127
+ }
14128
+ return array3;
14129
+ }
14130
+ if (typeId === INTEGER && type2.bitWidth >= 64) {
14131
+ const size = column3.length;
14132
+ const array3 = new Float64Array(size);
14133
+ for (let row = 0; row < size; ++row) {
14134
+ const v2 = column3.get(row);
14135
+ array3[row] = v2 == null ? NaN : Number(v2);
14136
+ }
14137
+ return array3;
14138
+ }
14139
+ if (typeId === DECIMAL) {
14140
+ const scale3 = 1 / Math.pow(10, type2.scale);
14141
+ const size = column3.length;
14142
+ const array3 = new Float64Array(size);
14143
+ for (let row = 0; row < size; ++row) {
14144
+ const v2 = column3.get(row);
14145
+ array3[row] = v2 == null ? NaN : decimalToNumber(v2, scale3);
14146
+ }
14147
+ return array3;
14148
+ }
14149
+ return column3.toArray();
14150
+ }
14151
+ var BASE32 = Array.from(
14152
+ { length: 8 },
14153
+ (_, i) => Math.pow(2, i * 32)
14154
+ );
14155
+ function decimalToNumber(v2, scale3) {
14156
+ const n = v2.length;
14157
+ let x3 = 0;
14158
+ if (v2.signed && (v2[n - 1] | 0) < 0) {
14159
+ for (let i = 0; i < n; ++i) {
14160
+ x3 += ~v2[i] * BASE32[i];
14161
+ }
14162
+ x3 = -(x3 + 1);
14163
+ } else {
14164
+ for (let i = 0; i < n; ++i) {
14165
+ x3 += v2[i] * BASE32[i];
14166
+ }
14167
+ }
14168
+ return x3 * scale3;
14169
+ }
14170
+
14171
+ // ../core/src/util/field-info.js
14172
+ var Count = "count";
14173
+ var Nulls = "nulls";
14174
+ var Max = "max";
14175
+ var Min = "min";
14176
+ var Distinct = "distinct";
14177
+ var statMap = {
14178
+ [Count]: count,
14179
+ [Distinct]: (column3) => count(column3).distinct(),
14180
+ [Max]: max,
14181
+ [Min]: min,
14182
+ [Nulls]: (column3) => count().where(isNull(column3))
14183
+ };
14184
+ function summarize(table, column3, stats) {
14185
+ return Query.from(table).select(Array.from(stats, (s2) => [s2, statMap[s2](column3)]));
14186
+ }
14187
+ async function queryFieldInfo(mc, fields) {
14188
+ if (fields.length === 1 && `${fields[0].column}` === "*") {
14189
+ return getTableInfo(mc, fields[0].table);
14190
+ } else {
14191
+ return (await Promise.all(fields.map((f) => getFieldInfo(mc, f)))).filter((x3) => x3);
14192
+ }
14193
+ }
14194
+ async function getFieldInfo(mc, { table, column: column3, stats }) {
14195
+ const q = Query.from({ source: table }).select({ column: column3 }).groupby(column3.aggregate ? sql`ALL` : []);
14196
+ const [desc2] = Array.from(await mc.query(Query.describe(q)));
14197
+ const info = {
14198
+ table,
14199
+ column: `${column3}`,
14200
+ sqlType: desc2.column_type,
14201
+ type: jsType(desc2.column_type),
14202
+ nullable: desc2.null === "YES"
14203
+ };
14204
+ if (!(stats?.length || stats?.size))
14205
+ return info;
14206
+ const result = await mc.query(
14207
+ summarize(table, column3, stats),
14208
+ { persist: true }
14209
+ );
14210
+ for (let i = 0; i < result.numCols; ++i) {
14211
+ const { name } = result.schema.fields[i];
14212
+ const child = result.getChildAt(i);
14213
+ const convert = convertArrowValue(child.type);
14214
+ info[name] = convert(child.get(0));
14215
+ }
14216
+ return info;
14217
+ }
14218
+ async function getTableInfo(mc, table) {
14219
+ const result = await mc.query(`DESCRIBE ${asRelation(table)}`);
14220
+ return Array.from(result).map((desc2) => ({
14221
+ table,
14222
+ column: desc2.column_name,
14223
+ sqlType: desc2.column_type,
14224
+ type: jsType(desc2.column_type),
14225
+ nullable: desc2.null === "YES"
14226
+ }));
14227
+ }
14228
+
14143
14229
  // ../core/src/util/void-logger.js
14144
14230
  function voidLogger() {
14145
14231
  return {
@@ -14172,7 +14258,6 @@ var Coordinator = class {
14172
14258
  logger = console,
14173
14259
  manager = QueryManager()
14174
14260
  } = options;
14175
- this.catalog = new Catalog(this);
14176
14261
  this.manager = manager;
14177
14262
  this.logger(logger);
14178
14263
  this.configure(options);
@@ -14191,7 +14276,7 @@ var Coordinator = class {
14191
14276
  this.manager.consolidate(consolidate2);
14192
14277
  this.indexes = indexes2;
14193
14278
  }
14194
- clear({ clients = true, cache = true, catalog = false } = {}) {
14279
+ clear({ clients = true, cache = true } = {}) {
14195
14280
  this.manager.clear();
14196
14281
  if (clients) {
14197
14282
  this.clients?.forEach((client) => this.disconnect(client));
@@ -14201,8 +14286,6 @@ var Coordinator = class {
14201
14286
  }
14202
14287
  if (cache)
14203
14288
  this.manager.cache().clear();
14204
- if (catalog)
14205
- this.catalog.clear();
14206
14289
  }
14207
14290
  databaseConnector(db) {
14208
14291
  return this.manager.connector(db);
@@ -14255,7 +14338,7 @@ var Coordinator = class {
14255
14338
  * @param {import('./MosaicClient.js').MosaicClient} client the client to disconnect
14256
14339
  */
14257
14340
  async connect(client) {
14258
- const { catalog, clients, filterGroups, indexes: indexes2 } = this;
14341
+ const { clients, filterGroups, indexes: indexes2 } = this;
14259
14342
  if (clients.has(client)) {
14260
14343
  throw new Error("Client already connected.");
14261
14344
  }
@@ -14263,7 +14346,7 @@ var Coordinator = class {
14263
14346
  client.coordinator = this;
14264
14347
  const fields = client.fields();
14265
14348
  if (fields?.length) {
14266
- client.fieldInfo(await catalog.queryFields(fields));
14349
+ client.fieldInfo(await queryFieldInfo(this, fields));
14267
14350
  }
14268
14351
  const filter3 = client.filterBy;
14269
14352
  if (filter3) {
@@ -21556,46 +21639,46 @@ function streamGeometry(geometry, stream) {
21556
21639
  }
21557
21640
  }
21558
21641
  var streamObjectType = {
21559
- Feature: function(object2, stream) {
21560
- streamGeometry(object2.geometry, stream);
21642
+ Feature: function(object, stream) {
21643
+ streamGeometry(object.geometry, stream);
21561
21644
  },
21562
- FeatureCollection: function(object2, stream) {
21563
- var features = object2.features, i = -1, n = features.length;
21645
+ FeatureCollection: function(object, stream) {
21646
+ var features = object.features, i = -1, n = features.length;
21564
21647
  while (++i < n)
21565
21648
  streamGeometry(features[i].geometry, stream);
21566
21649
  }
21567
21650
  };
21568
21651
  var streamGeometryType = {
21569
- Sphere: function(object2, stream) {
21652
+ Sphere: function(object, stream) {
21570
21653
  stream.sphere();
21571
21654
  },
21572
- Point: function(object2, stream) {
21573
- object2 = object2.coordinates;
21574
- stream.point(object2[0], object2[1], object2[2]);
21655
+ Point: function(object, stream) {
21656
+ object = object.coordinates;
21657
+ stream.point(object[0], object[1], object[2]);
21575
21658
  },
21576
- MultiPoint: function(object2, stream) {
21577
- var coordinates = object2.coordinates, i = -1, n = coordinates.length;
21659
+ MultiPoint: function(object, stream) {
21660
+ var coordinates = object.coordinates, i = -1, n = coordinates.length;
21578
21661
  while (++i < n)
21579
- object2 = coordinates[i], stream.point(object2[0], object2[1], object2[2]);
21662
+ object = coordinates[i], stream.point(object[0], object[1], object[2]);
21580
21663
  },
21581
- LineString: function(object2, stream) {
21582
- streamLine(object2.coordinates, stream, 0);
21664
+ LineString: function(object, stream) {
21665
+ streamLine(object.coordinates, stream, 0);
21583
21666
  },
21584
- MultiLineString: function(object2, stream) {
21585
- var coordinates = object2.coordinates, i = -1, n = coordinates.length;
21667
+ MultiLineString: function(object, stream) {
21668
+ var coordinates = object.coordinates, i = -1, n = coordinates.length;
21586
21669
  while (++i < n)
21587
21670
  streamLine(coordinates[i], stream, 0);
21588
21671
  },
21589
- Polygon: function(object2, stream) {
21590
- streamPolygon(object2.coordinates, stream);
21672
+ Polygon: function(object, stream) {
21673
+ streamPolygon(object.coordinates, stream);
21591
21674
  },
21592
- MultiPolygon: function(object2, stream) {
21593
- var coordinates = object2.coordinates, i = -1, n = coordinates.length;
21675
+ MultiPolygon: function(object, stream) {
21676
+ var coordinates = object.coordinates, i = -1, n = coordinates.length;
21594
21677
  while (++i < n)
21595
21678
  streamPolygon(coordinates[i], stream);
21596
21679
  },
21597
- GeometryCollection: function(object2, stream) {
21598
- var geometries = object2.geometries, i = -1, n = geometries.length;
21680
+ GeometryCollection: function(object, stream) {
21681
+ var geometries = object.geometries, i = -1, n = geometries.length;
21599
21682
  while (++i < n)
21600
21683
  streamGeometry(geometries[i], stream);
21601
21684
  }
@@ -21614,11 +21697,11 @@ function streamPolygon(coordinates, stream) {
21614
21697
  streamLine(coordinates[i], stream, 1);
21615
21698
  stream.polygonEnd();
21616
21699
  }
21617
- function stream_default(object2, stream) {
21618
- if (object2 && streamObjectType.hasOwnProperty(object2.type)) {
21619
- streamObjectType[object2.type](object2, stream);
21700
+ function stream_default(object, stream) {
21701
+ if (object && streamObjectType.hasOwnProperty(object.type)) {
21702
+ streamObjectType[object.type](object, stream);
21620
21703
  } else {
21621
- streamGeometry(object2, stream);
21704
+ streamGeometry(object, stream);
21622
21705
  }
21623
21706
  }
21624
21707
 
@@ -21742,12 +21825,12 @@ function centroidRingPoint(lambda, phi) {
21742
21825
  Z1 += w * (z0 + (z0 = z));
21743
21826
  centroidPointCartesian(x0, y0, z0);
21744
21827
  }
21745
- function centroid_default(object2) {
21828
+ function centroid_default(object) {
21746
21829
  W0 = W1 = X0 = Y0 = Z0 = X1 = Y1 = Z1 = 0;
21747
21830
  X2 = new Adder();
21748
21831
  Y2 = new Adder();
21749
21832
  Z2 = new Adder();
21750
- stream_default(object2, centroidStream);
21833
+ stream_default(object, centroidStream);
21751
21834
  var x3 = +X2, y3 = +Y2, z = +Z2, m = hypot(x3, y3, z);
21752
21835
  if (m < epsilon22) {
21753
21836
  x3 = X1, y3 = Y1, z = Z1;
@@ -22931,28 +23014,28 @@ function appendRound2(digits) {
22931
23014
  // ../../node_modules/d3-geo/src/path/index.js
22932
23015
  function path_default(projection3, context) {
22933
23016
  let digits = 3, pointRadius = 4.5, projectionStream, contextStream;
22934
- function path2(object2) {
22935
- if (object2) {
23017
+ function path2(object) {
23018
+ if (object) {
22936
23019
  if (typeof pointRadius === "function")
22937
23020
  contextStream.pointRadius(+pointRadius.apply(this, arguments));
22938
- stream_default(object2, projectionStream(contextStream));
23021
+ stream_default(object, projectionStream(contextStream));
22939
23022
  }
22940
23023
  return contextStream.result();
22941
23024
  }
22942
- path2.area = function(object2) {
22943
- stream_default(object2, projectionStream(area_default2));
23025
+ path2.area = function(object) {
23026
+ stream_default(object, projectionStream(area_default2));
22944
23027
  return area_default2.result();
22945
23028
  };
22946
- path2.measure = function(object2) {
22947
- stream_default(object2, projectionStream(measure_default));
23029
+ path2.measure = function(object) {
23030
+ stream_default(object, projectionStream(measure_default));
22948
23031
  return measure_default.result();
22949
23032
  };
22950
- path2.bounds = function(object2) {
22951
- stream_default(object2, projectionStream(bounds_default));
23033
+ path2.bounds = function(object) {
23034
+ stream_default(object, projectionStream(bounds_default));
22952
23035
  return bounds_default.result();
22953
23036
  };
22954
- path2.centroid = function(object2) {
22955
- stream_default(object2, projectionStream(centroid_default2));
23037
+ path2.centroid = function(object) {
23038
+ stream_default(object, projectionStream(centroid_default2));
22956
23039
  return centroid_default2.result();
22957
23040
  };
22958
23041
  path2.projection = function(_) {
@@ -23033,37 +23116,37 @@ TransformStream.prototype = {
23033
23116
  };
23034
23117
 
23035
23118
  // ../../node_modules/d3-geo/src/projection/fit.js
23036
- function fit(projection3, fitBounds, object2) {
23119
+ function fit(projection3, fitBounds, object) {
23037
23120
  var clip = projection3.clipExtent && projection3.clipExtent();
23038
23121
  projection3.scale(150).translate([0, 0]);
23039
23122
  if (clip != null)
23040
23123
  projection3.clipExtent(null);
23041
- stream_default(object2, projection3.stream(bounds_default));
23124
+ stream_default(object, projection3.stream(bounds_default));
23042
23125
  fitBounds(bounds_default.result());
23043
23126
  if (clip != null)
23044
23127
  projection3.clipExtent(clip);
23045
23128
  return projection3;
23046
23129
  }
23047
- function fitExtent(projection3, extent4, object2) {
23130
+ function fitExtent(projection3, extent4, object) {
23048
23131
  return fit(projection3, function(b) {
23049
23132
  var w = extent4[1][0] - extent4[0][0], h = extent4[1][1] - extent4[0][1], k2 = Math.min(w / (b[1][0] - b[0][0]), h / (b[1][1] - b[0][1])), x3 = +extent4[0][0] + (w - k2 * (b[1][0] + b[0][0])) / 2, y3 = +extent4[0][1] + (h - k2 * (b[1][1] + b[0][1])) / 2;
23050
23133
  projection3.scale(150 * k2).translate([x3, y3]);
23051
- }, object2);
23134
+ }, object);
23052
23135
  }
23053
- function fitSize(projection3, size, object2) {
23054
- return fitExtent(projection3, [[0, 0], size], object2);
23136
+ function fitSize(projection3, size, object) {
23137
+ return fitExtent(projection3, [[0, 0], size], object);
23055
23138
  }
23056
- function fitWidth(projection3, width, object2) {
23139
+ function fitWidth(projection3, width, object) {
23057
23140
  return fit(projection3, function(b) {
23058
23141
  var w = +width, k2 = w / (b[1][0] - b[0][0]), x3 = (w - k2 * (b[1][0] + b[0][0])) / 2, y3 = -k2 * b[0][1];
23059
23142
  projection3.scale(150 * k2).translate([x3, y3]);
23060
- }, object2);
23143
+ }, object);
23061
23144
  }
23062
- function fitHeight(projection3, height, object2) {
23145
+ function fitHeight(projection3, height, object) {
23063
23146
  return fit(projection3, function(b) {
23064
23147
  var h = +height, k2 = h / (b[1][1] - b[0][1]), x3 = -k2 * b[0][0], y3 = (h - k2 * (b[1][1] + b[0][1])) / 2;
23065
23148
  projection3.scale(150 * k2).translate([x3, y3]);
23066
- }, object2);
23149
+ }, object);
23067
23150
  }
23068
23151
 
23069
23152
  // ../../node_modules/d3-geo/src/projection/resample.js
@@ -23235,17 +23318,17 @@ function projectionMutator(projectAt) {
23235
23318
  projection3.precision = function(_) {
23236
23319
  return arguments.length ? (projectResample = resample_default(projectTransform, delta2 = _ * _), reset()) : sqrt(delta2);
23237
23320
  };
23238
- projection3.fitExtent = function(extent4, object2) {
23239
- return fitExtent(projection3, extent4, object2);
23321
+ projection3.fitExtent = function(extent4, object) {
23322
+ return fitExtent(projection3, extent4, object);
23240
23323
  };
23241
- projection3.fitSize = function(size, object2) {
23242
- return fitSize(projection3, size, object2);
23324
+ projection3.fitSize = function(size, object) {
23325
+ return fitSize(projection3, size, object);
23243
23326
  };
23244
- projection3.fitWidth = function(width, object2) {
23245
- return fitWidth(projection3, width, object2);
23327
+ projection3.fitWidth = function(width, object) {
23328
+ return fitWidth(projection3, width, object);
23246
23329
  };
23247
- projection3.fitHeight = function(height, object2) {
23248
- return fitHeight(projection3, height, object2);
23330
+ projection3.fitHeight = function(height, object) {
23331
+ return fitHeight(projection3, height, object);
23249
23332
  };
23250
23333
  function recenter() {
23251
23334
  var center2 = scaleTranslateRotate(k2, 0, 0, sx, sy, alpha).apply(null, project2(lambda, phi)), transform3 = scaleTranslateRotate(k2, x3 - center2[0], y3 - center2[1], sx, sy, alpha);
@@ -23386,17 +23469,17 @@ function albersUsa_default() {
23386
23469
  hawaiiPoint = hawaii.translate([x3 - 0.205 * k2, y3 + 0.212 * k2]).clipExtent([[x3 - 0.214 * k2 + epsilon6, y3 + 0.166 * k2 + epsilon6], [x3 - 0.115 * k2 - epsilon6, y3 + 0.234 * k2 - epsilon6]]).stream(pointStream);
23387
23470
  return reset();
23388
23471
  };
23389
- albersUsa.fitExtent = function(extent4, object2) {
23390
- return fitExtent(albersUsa, extent4, object2);
23472
+ albersUsa.fitExtent = function(extent4, object) {
23473
+ return fitExtent(albersUsa, extent4, object);
23391
23474
  };
23392
- albersUsa.fitSize = function(size, object2) {
23393
- return fitSize(albersUsa, size, object2);
23475
+ albersUsa.fitSize = function(size, object) {
23476
+ return fitSize(albersUsa, size, object);
23394
23477
  };
23395
- albersUsa.fitWidth = function(width, object2) {
23396
- return fitWidth(albersUsa, width, object2);
23478
+ albersUsa.fitWidth = function(width, object) {
23479
+ return fitWidth(albersUsa, width, object);
23397
23480
  };
23398
- albersUsa.fitHeight = function(height, object2) {
23399
- return fitHeight(albersUsa, height, object2);
23481
+ albersUsa.fitHeight = function(height, object) {
23482
+ return fitHeight(albersUsa, height, object);
23400
23483
  };
23401
23484
  function reset() {
23402
23485
  cache = cacheStream = null;
@@ -25871,6 +25954,9 @@ var Accent_default = colors_default("7fc97fbeaed4fdc086ffff99386cb0f0027fbf5b176
25871
25954
  // ../../node_modules/d3-scale-chromatic/src/categorical/Dark2.js
25872
25955
  var Dark2_default = colors_default("1b9e77d95f027570b3e7298a66a61ee6ab02a6761d666666");
25873
25956
 
25957
+ // ../../node_modules/d3-scale-chromatic/src/categorical/observable10.js
25958
+ var observable10_default = colors_default("4269d0efb118ff725c6cc5b03ca951ff8ab7a463f297bbf59c6b4e9498a0");
25959
+
25874
25960
  // ../../node_modules/d3-scale-chromatic/src/categorical/Paired.js
25875
25961
  var Paired_default = colors_default("a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928");
25876
25962
 
@@ -28081,6 +28167,15 @@ function parse(string2, fallback) {
28081
28167
  return new Date(string2);
28082
28168
  }
28083
28169
 
28170
+ // ../../node_modules/@observablehq/plot/src/order.js
28171
+ function orderof(values2) {
28172
+ if (values2 == null)
28173
+ return;
28174
+ const first3 = values2[0];
28175
+ const last2 = values2[values2.length - 1];
28176
+ return descending(first3, last2);
28177
+ }
28178
+
28084
28179
  // ../../node_modules/@observablehq/plot/src/time.js
28085
28180
  var durationSecond2 = 1e3;
28086
28181
  var durationMinute2 = durationSecond2 * 60;
@@ -28674,13 +28769,6 @@ function maybeAnchor(value, name) {
28674
28769
  function maybeFrameAnchor(value = "middle") {
28675
28770
  return maybeAnchor(value, "frameAnchor");
28676
28771
  }
28677
- function orderof(values2) {
28678
- if (values2 == null)
28679
- return;
28680
- const first3 = values2[0];
28681
- const last2 = values2[values2.length - 1];
28682
- return descending(first3, last2);
28683
- }
28684
28772
  function inherit2(options = {}, ...rest) {
28685
28773
  let o = options;
28686
28774
  for (const defaults23 of rest) {
@@ -28717,6 +28805,15 @@ function named2(things) {
28717
28805
  function maybeNamed(things) {
28718
28806
  return isIterable2(things) ? named2(things) : things;
28719
28807
  }
28808
+ function maybeClip(clip) {
28809
+ if (clip === true)
28810
+ clip = "frame";
28811
+ else if (clip === false)
28812
+ clip = null;
28813
+ else if (clip != null)
28814
+ clip = keyword(clip, "clip", ["frame", "sphere"]);
28815
+ return clip;
28816
+ }
28720
28817
 
28721
28818
  // ../../node_modules/@observablehq/plot/src/scales/index.js
28722
28819
  var position = Symbol("position");
@@ -29036,6 +29133,8 @@ function groupn(x3, y3, {
29036
29133
  extent4.x = x4;
29037
29134
  if (Y3)
29038
29135
  extent4.y = y4;
29136
+ if (G)
29137
+ extent4.z = f;
29039
29138
  if (filter3 && !filter3.reduce(g, extent4))
29040
29139
  continue;
29041
29140
  groupFacet.push(i++);
@@ -29134,10 +29233,7 @@ function maybeEvaluator(name, reduce, inputs, asReduce = maybeReduce) {
29134
29233
  };
29135
29234
  }
29136
29235
  function maybeGroup(I, X3) {
29137
- return X3 ? sort(
29138
- group(I, (i) => X3[i]),
29139
- first2
29140
- ) : [[, I]];
29236
+ return X3 ? group(I, (i) => X3[i]) : [[, I]];
29141
29237
  }
29142
29238
  function maybeReduce(reduce, value, fallback = invalidReduce) {
29143
29239
  if (reduce == null)
@@ -29209,6 +29305,8 @@ function maybeGroupReduceFallback(reduce) {
29209
29305
  return reduceX;
29210
29306
  case "y":
29211
29307
  return reduceY;
29308
+ case "z":
29309
+ return reduceZ;
29212
29310
  }
29213
29311
  throw new Error(`invalid group reduce: ${reduce}`);
29214
29312
  }
@@ -29319,6 +29417,11 @@ var reduceY = {
29319
29417
  return y3;
29320
29418
  }
29321
29419
  };
29420
+ var reduceZ = {
29421
+ reduceIndex(I, X3, { z }) {
29422
+ return z;
29423
+ }
29424
+ };
29322
29425
  function find2(test) {
29323
29426
  if (typeof test !== "function")
29324
29427
  throw new Error(`invalid test function: ${test}`);
@@ -29495,48 +29598,14 @@ function getSource(channels, key) {
29495
29598
  return channel.source === null ? null : channel;
29496
29599
  }
29497
29600
 
29498
- // ../../node_modules/@observablehq/plot/src/memoize.js
29499
- function memoize1(compute) {
29500
- let cacheValue, cacheKeys;
29501
- return (...keys) => {
29502
- if (cacheKeys?.length !== keys.length || cacheKeys.some((k2, i) => k2 !== keys[i])) {
29503
- cacheKeys = keys;
29504
- cacheValue = compute(...keys);
29505
- }
29506
- return cacheValue;
29507
- };
29508
- }
29509
-
29510
- // ../../node_modules/@observablehq/plot/src/format.js
29511
- var numberFormat = memoize1((locale3) => {
29512
- return new Intl.NumberFormat(locale3);
29513
- });
29514
- var monthFormat = memoize1((locale3, month) => {
29515
- return new Intl.DateTimeFormat(locale3, { timeZone: "UTC", ...month && { month } });
29516
- });
29517
- var weekdayFormat = memoize1((locale3, weekday) => {
29518
- return new Intl.DateTimeFormat(locale3, { timeZone: "UTC", ...weekday && { weekday } });
29519
- });
29520
- function formatNumber(locale3 = "en-US") {
29521
- const format3 = numberFormat(locale3);
29522
- return (i) => i != null && !isNaN(i) ? format3.format(i) : void 0;
29523
- }
29524
- function formatMonth(locale3 = "en-US", format3 = "short") {
29525
- const fmt = monthFormat(locale3, format3);
29526
- return (i) => i != null && !isNaN(i = +new Date(Date.UTC(2e3, +i))) ? fmt.format(i) : void 0;
29527
- }
29528
- function formatWeekday(locale3 = "en-US", format3 = "short") {
29529
- const fmt = weekdayFormat(locale3, format3);
29530
- return (i) => i != null && !isNaN(i = +new Date(Date.UTC(2001, 0, +i))) ? fmt.format(i) : void 0;
29531
- }
29532
- function formatIsoDate(date2) {
29533
- return format2(date2, "Invalid Date");
29601
+ // ../../node_modules/@observablehq/plot/src/context.js
29602
+ function createContext(options = {}) {
29603
+ const { document: document2 = typeof window !== "undefined" ? window.document : void 0, clip } = options;
29604
+ return { document: document2, clip: maybeClip(clip) };
29534
29605
  }
29535
- function formatAuto(locale3 = "en-US") {
29536
- const number7 = formatNumber(locale3);
29537
- return (v2) => (v2 instanceof Date ? formatIsoDate : typeof v2 === "number" ? number7 : string)(v2);
29606
+ function create3(name, { document: document2 }) {
29607
+ return select_default2(creator_default(name).call(document2.documentElement));
29538
29608
  }
29539
- var formatDefault = formatAuto();
29540
29609
 
29541
29610
  // ../../node_modules/@observablehq/plot/src/warnings.js
29542
29611
  var warnings = 0;
@@ -29555,1787 +29624,1800 @@ function warn(message) {
29555
29624
  ++warnings;
29556
29625
  }
29557
29626
 
29558
- // ../../node_modules/@observablehq/plot/src/style.js
29559
- var offset = (typeof window !== "undefined" ? window.devicePixelRatio > 1 : typeof it === "undefined") ? 0 : 0.5;
29560
- var nextClipId = 0;
29561
- function getClipId() {
29562
- return `plot-clip-${++nextClipId}`;
29563
- }
29564
- function styles(mark, {
29565
- title,
29566
- href,
29567
- ariaLabel: variaLabel,
29568
- ariaDescription,
29569
- ariaHidden,
29570
- target,
29571
- fill,
29572
- fillOpacity,
29573
- stroke,
29574
- strokeWidth,
29575
- strokeOpacity,
29576
- strokeLinejoin,
29577
- strokeLinecap,
29578
- strokeMiterlimit,
29579
- strokeDasharray,
29580
- strokeDashoffset,
29581
- opacity: opacity2,
29582
- mixBlendMode,
29583
- imageFilter,
29584
- paintOrder,
29585
- pointerEvents,
29586
- shapeRendering,
29587
- channels
29588
- }, {
29589
- ariaLabel: cariaLabel,
29590
- fill: defaultFill = "currentColor",
29591
- fillOpacity: defaultFillOpacity,
29592
- stroke: defaultStroke = "none",
29593
- strokeOpacity: defaultStrokeOpacity,
29594
- strokeWidth: defaultStrokeWidth,
29595
- strokeLinecap: defaultStrokeLinecap,
29596
- strokeLinejoin: defaultStrokeLinejoin,
29597
- strokeMiterlimit: defaultStrokeMiterlimit,
29598
- paintOrder: defaultPaintOrder
29599
- }) {
29600
- if (defaultFill === null) {
29601
- fill = null;
29602
- fillOpacity = null;
29603
- }
29604
- if (defaultStroke === null) {
29605
- stroke = null;
29606
- strokeOpacity = null;
29607
- }
29608
- if (isNoneish(defaultFill)) {
29609
- if (!isNoneish(defaultStroke) && (!isNoneish(fill) || channels?.fill))
29610
- defaultStroke = "none";
29611
- } else {
29612
- if (isNoneish(defaultStroke) && (!isNoneish(stroke) || channels?.stroke))
29613
- defaultFill = "none";
29627
+ // ../../node_modules/@observablehq/plot/src/projection.js
29628
+ var pi4 = Math.PI;
29629
+ var tau5 = 2 * pi4;
29630
+ var defaultAspectRatio = 0.618;
29631
+ function createProjection({
29632
+ projection: projection3,
29633
+ inset: globalInset = 0,
29634
+ insetTop = globalInset,
29635
+ insetRight = globalInset,
29636
+ insetBottom = globalInset,
29637
+ insetLeft = globalInset
29638
+ } = {}, dimensions) {
29639
+ if (projection3 == null)
29640
+ return;
29641
+ if (typeof projection3.stream === "function")
29642
+ return projection3;
29643
+ let options;
29644
+ let domain;
29645
+ let clip = "frame";
29646
+ if (isObject2(projection3)) {
29647
+ let inset;
29648
+ ({
29649
+ type: projection3,
29650
+ domain,
29651
+ inset,
29652
+ insetTop = inset !== void 0 ? inset : insetTop,
29653
+ insetRight = inset !== void 0 ? inset : insetRight,
29654
+ insetBottom = inset !== void 0 ? inset : insetBottom,
29655
+ insetLeft = inset !== void 0 ? inset : insetLeft,
29656
+ clip = clip,
29657
+ ...options
29658
+ } = projection3);
29659
+ if (projection3 == null)
29660
+ return;
29614
29661
  }
29615
- const [vfill, cfill] = maybeColorChannel(fill, defaultFill);
29616
- const [vfillOpacity, cfillOpacity] = maybeNumberChannel(fillOpacity, defaultFillOpacity);
29617
- const [vstroke, cstroke] = maybeColorChannel(stroke, defaultStroke);
29618
- const [vstrokeOpacity, cstrokeOpacity] = maybeNumberChannel(strokeOpacity, defaultStrokeOpacity);
29619
- const [vopacity, copacity] = maybeNumberChannel(opacity2);
29620
- if (!isNone(cstroke)) {
29621
- if (strokeWidth === void 0)
29622
- strokeWidth = defaultStrokeWidth;
29623
- if (strokeLinecap === void 0)
29624
- strokeLinecap = defaultStrokeLinecap;
29625
- if (strokeLinejoin === void 0)
29626
- strokeLinejoin = defaultStrokeLinejoin;
29627
- if (strokeMiterlimit === void 0 && !isRound(strokeLinejoin))
29628
- strokeMiterlimit = defaultStrokeMiterlimit;
29629
- if (!isNone(cfill) && paintOrder === void 0)
29630
- paintOrder = defaultPaintOrder;
29662
+ if (typeof projection3 !== "function")
29663
+ ({ type: projection3 } = namedProjection(projection3));
29664
+ const { width, height, marginLeft, marginRight, marginTop, marginBottom } = dimensions;
29665
+ const dx = width - marginLeft - marginRight - insetLeft - insetRight;
29666
+ const dy = height - marginTop - marginBottom - insetTop - insetBottom;
29667
+ projection3 = projection3?.({ width: dx, height: dy, clip, ...options });
29668
+ if (projection3 == null)
29669
+ return;
29670
+ clip = maybePostClip(clip, marginLeft, marginTop, width - marginRight, height - marginBottom);
29671
+ let tx = marginLeft + insetLeft;
29672
+ let ty = marginTop + insetTop;
29673
+ let transform3;
29674
+ if (domain != null) {
29675
+ const [[x06, y06], [x12, y12]] = path_default(projection3).bounds(domain);
29676
+ const k2 = Math.min(dx / (x12 - x06), dy / (y12 - y06));
29677
+ if (k2 > 0) {
29678
+ tx -= (k2 * (x06 + x12) - dx) / 2;
29679
+ ty -= (k2 * (y06 + y12) - dy) / 2;
29680
+ transform3 = transform_default({
29681
+ point(x3, y3) {
29682
+ this.stream.point(x3 * k2 + tx, y3 * k2 + ty);
29683
+ }
29684
+ });
29685
+ } else {
29686
+ warn(`Warning: the projection could not be fit to the specified domain; using the default scale.`);
29687
+ }
29631
29688
  }
29632
- const [vstrokeWidth, cstrokeWidth] = maybeNumberChannel(strokeWidth);
29633
- if (defaultFill !== null) {
29634
- mark.fill = impliedString(cfill, "currentColor");
29635
- mark.fillOpacity = impliedNumber(cfillOpacity, 1);
29689
+ transform3 ??= tx === 0 && ty === 0 ? identity8() : transform_default({
29690
+ point(x3, y3) {
29691
+ this.stream.point(x3 + tx, y3 + ty);
29692
+ }
29693
+ });
29694
+ return { stream: (s2) => projection3.stream(transform3.stream(clip(s2))) };
29695
+ }
29696
+ function namedProjection(projection3) {
29697
+ switch (`${projection3}`.toLowerCase()) {
29698
+ case "albers-usa":
29699
+ return scaleProjection(albersUsa_default, 0.7463, 0.4673);
29700
+ case "albers":
29701
+ return conicProjection2(albers_default, 0.7463, 0.4673);
29702
+ case "azimuthal-equal-area":
29703
+ return scaleProjection(azimuthalEqualArea_default, 4, 4);
29704
+ case "azimuthal-equidistant":
29705
+ return scaleProjection(azimuthalEquidistant_default, tau5, tau5);
29706
+ case "conic-conformal":
29707
+ return conicProjection2(conicConformal_default, tau5, tau5);
29708
+ case "conic-equal-area":
29709
+ return conicProjection2(conicEqualArea_default, 6.1702, 2.9781);
29710
+ case "conic-equidistant":
29711
+ return conicProjection2(conicEquidistant_default, 7.312, 3.6282);
29712
+ case "equal-earth":
29713
+ return scaleProjection(equalEarth_default, 5.4133, 2.6347);
29714
+ case "equirectangular":
29715
+ return scaleProjection(equirectangular_default, tau5, pi4);
29716
+ case "gnomonic":
29717
+ return scaleProjection(gnomonic_default, 3.4641, 3.4641);
29718
+ case "identity":
29719
+ return { type: identity8 };
29720
+ case "reflect-y":
29721
+ return { type: reflectY };
29722
+ case "mercator":
29723
+ return scaleProjection(mercator_default, tau5, tau5);
29724
+ case "orthographic":
29725
+ return scaleProjection(orthographic_default, 2, 2);
29726
+ case "stereographic":
29727
+ return scaleProjection(stereographic_default, 2, 2);
29728
+ case "transverse-mercator":
29729
+ return scaleProjection(transverseMercator_default, tau5, tau5);
29730
+ default:
29731
+ throw new Error(`unknown projection type: ${projection3}`);
29636
29732
  }
29637
- if (defaultStroke !== null) {
29638
- mark.stroke = impliedString(cstroke, "none");
29639
- mark.strokeWidth = impliedNumber(cstrokeWidth, 1);
29640
- mark.strokeOpacity = impliedNumber(cstrokeOpacity, 1);
29641
- mark.strokeLinejoin = impliedString(strokeLinejoin, "miter");
29642
- mark.strokeLinecap = impliedString(strokeLinecap, "butt");
29643
- mark.strokeMiterlimit = impliedNumber(strokeMiterlimit, 4);
29644
- mark.strokeDasharray = impliedString(strokeDasharray, "none");
29645
- mark.strokeDashoffset = impliedString(strokeDashoffset, "0");
29733
+ }
29734
+ function maybePostClip(clip, x12, y12, x22, y22) {
29735
+ if (clip === false || clip == null || typeof clip === "number")
29736
+ return (s2) => s2;
29737
+ if (clip === true)
29738
+ clip = "frame";
29739
+ switch (`${clip}`.toLowerCase()) {
29740
+ case "frame":
29741
+ return clipRectangle(x12, y12, x22, y22);
29742
+ default:
29743
+ throw new Error(`unknown projection clip type: ${clip}`);
29646
29744
  }
29647
- mark.target = string(target);
29648
- mark.ariaLabel = string(cariaLabel);
29649
- mark.ariaDescription = string(ariaDescription);
29650
- mark.ariaHidden = string(ariaHidden);
29651
- mark.opacity = impliedNumber(copacity, 1);
29652
- mark.mixBlendMode = impliedString(mixBlendMode, "normal");
29653
- mark.imageFilter = impliedString(imageFilter, "none");
29654
- mark.paintOrder = impliedString(paintOrder, "normal");
29655
- mark.pointerEvents = impliedString(pointerEvents, "auto");
29656
- mark.shapeRendering = impliedString(shapeRendering, "auto");
29657
- return {
29658
- title: { value: title, optional: true, filter: null },
29659
- href: { value: href, optional: true, filter: null },
29660
- ariaLabel: { value: variaLabel, optional: true, filter: null },
29661
- fill: { value: vfill, scale: "auto", optional: true },
29662
- fillOpacity: { value: vfillOpacity, scale: "auto", optional: true },
29663
- stroke: { value: vstroke, scale: "auto", optional: true },
29664
- strokeOpacity: { value: vstrokeOpacity, scale: "auto", optional: true },
29665
- strokeWidth: { value: vstrokeWidth, optional: true },
29666
- opacity: { value: vopacity, scale: "auto", optional: true }
29667
- };
29668
29745
  }
29669
- function applyTitle(selection2, L) {
29670
- if (L)
29671
- selection2.filter((i) => nonempty(L[i])).append("title").call(applyText, L);
29672
- }
29673
- function applyTitleGroup(selection2, L) {
29674
- if (L)
29675
- selection2.filter(([i]) => nonempty(L[i])).append("title").call(applyTextGroup, L);
29676
- }
29677
- function applyText(selection2, T) {
29678
- if (T)
29679
- selection2.text((i) => formatDefault(T[i]));
29680
- }
29681
- function applyTextGroup(selection2, T) {
29682
- if (T)
29683
- selection2.text(([i]) => formatDefault(T[i]));
29684
- }
29685
- function applyChannelStyles(selection2, { target, tip: tip2 }, {
29686
- ariaLabel: AL,
29687
- title: T,
29688
- fill: F,
29689
- fillOpacity: FO,
29690
- stroke: S,
29691
- strokeOpacity: SO,
29692
- strokeWidth: SW,
29693
- opacity: O,
29694
- href: H
29695
- }) {
29696
- if (AL)
29697
- applyAttr(selection2, "aria-label", (i) => AL[i]);
29698
- if (F)
29699
- applyAttr(selection2, "fill", (i) => F[i]);
29700
- if (FO)
29701
- applyAttr(selection2, "fill-opacity", (i) => FO[i]);
29702
- if (S)
29703
- applyAttr(selection2, "stroke", (i) => S[i]);
29704
- if (SO)
29705
- applyAttr(selection2, "stroke-opacity", (i) => SO[i]);
29706
- if (SW)
29707
- applyAttr(selection2, "stroke-width", (i) => SW[i]);
29708
- if (O)
29709
- applyAttr(selection2, "opacity", (i) => O[i]);
29710
- if (H)
29711
- applyHref(selection2, (i) => H[i], target);
29712
- if (!tip2)
29713
- applyTitle(selection2, T);
29714
- }
29715
- function applyGroupedChannelStyles(selection2, { target, tip: tip2 }, {
29716
- ariaLabel: AL,
29717
- title: T,
29718
- fill: F,
29719
- fillOpacity: FO,
29720
- stroke: S,
29721
- strokeOpacity: SO,
29722
- strokeWidth: SW,
29723
- opacity: O,
29724
- href: H
29725
- }) {
29726
- if (AL)
29727
- applyAttr(selection2, "aria-label", ([i]) => AL[i]);
29728
- if (F)
29729
- applyAttr(selection2, "fill", ([i]) => F[i]);
29730
- if (FO)
29731
- applyAttr(selection2, "fill-opacity", ([i]) => FO[i]);
29732
- if (S)
29733
- applyAttr(selection2, "stroke", ([i]) => S[i]);
29734
- if (SO)
29735
- applyAttr(selection2, "stroke-opacity", ([i]) => SO[i]);
29736
- if (SW)
29737
- applyAttr(selection2, "stroke-width", ([i]) => SW[i]);
29738
- if (O)
29739
- applyAttr(selection2, "opacity", ([i]) => O[i]);
29740
- if (H)
29741
- applyHref(selection2, ([i]) => H[i], target);
29742
- if (!tip2)
29743
- applyTitleGroup(selection2, T);
29744
- }
29745
- function groupAesthetics({
29746
- ariaLabel: AL,
29747
- title: T,
29748
- fill: F,
29749
- fillOpacity: FO,
29750
- stroke: S,
29751
- strokeOpacity: SO,
29752
- strokeWidth: SW,
29753
- opacity: O,
29754
- href: H
29755
- }, { tip: tip2 }) {
29756
- return [AL, tip2 ? void 0 : T, F, FO, S, SO, SW, O, H].filter((c4) => c4 !== void 0);
29757
- }
29758
- function groupZ2(I, Z, z) {
29759
- const G = group(I, (i) => Z[i]);
29760
- if (z === void 0 && G.size > 1 + I.length >> 1) {
29761
- warn(
29762
- `Warning: the implicit z channel has high cardinality. This may occur when the fill or stroke channel is associated with quantitative data rather than ordinal or categorical data. You can suppress this warning by setting the z option explicitly; if this data represents a single series, set z to null.`
29763
- );
29764
- }
29765
- return G.values();
29746
+ function scaleProjection(createProjection2, kx2, ky2) {
29747
+ return {
29748
+ type: ({ width, height, rotate, precision = 0.15, clip }) => {
29749
+ const projection3 = createProjection2();
29750
+ if (precision != null)
29751
+ projection3.precision?.(precision);
29752
+ if (rotate != null)
29753
+ projection3.rotate?.(rotate);
29754
+ if (typeof clip === "number")
29755
+ projection3.clipAngle?.(clip);
29756
+ projection3.scale(Math.min(width / kx2, height / ky2));
29757
+ projection3.translate([width / 2, height / 2]);
29758
+ return projection3;
29759
+ },
29760
+ aspectRatio: ky2 / kx2
29761
+ };
29766
29762
  }
29767
- function* groupIndex(I, position3, mark, channels) {
29768
- const { z } = mark;
29769
- const { z: Z } = channels;
29770
- const A5 = groupAesthetics(channels, mark);
29771
- const C3 = [...position3, ...A5];
29772
- for (const G of Z ? groupZ2(I, Z, z) : [I]) {
29773
- let Ag;
29774
- let Gg;
29775
- out:
29776
- for (const i of G) {
29777
- for (const c4 of C3) {
29778
- if (!defined(c4[i])) {
29779
- if (Gg)
29780
- Gg.push(-1);
29781
- continue out;
29782
- }
29783
- }
29784
- if (Ag === void 0) {
29785
- if (Gg)
29786
- yield Gg;
29787
- Ag = A5.map((c4) => keyof2(c4[i])), Gg = [i];
29788
- continue;
29789
- }
29790
- Gg.push(i);
29791
- for (let j = 0; j < A5.length; ++j) {
29792
- const k2 = keyof2(A5[j][i]);
29793
- if (k2 !== Ag[j]) {
29794
- yield Gg;
29795
- Ag = A5.map((c4) => keyof2(c4[i])), Gg = [i];
29796
- continue out;
29797
- }
29763
+ function conicProjection2(createProjection2, kx2, ky2) {
29764
+ const { type: type2, aspectRatio } = scaleProjection(createProjection2, kx2, ky2);
29765
+ return {
29766
+ type: (options) => {
29767
+ const { parallels, domain, width, height } = options;
29768
+ const projection3 = type2(options);
29769
+ if (parallels != null) {
29770
+ projection3.parallels(parallels);
29771
+ if (domain === void 0) {
29772
+ projection3.fitSize([width, height], { type: "Sphere" });
29798
29773
  }
29799
29774
  }
29800
- if (Gg)
29801
- yield Gg;
29802
- }
29803
- }
29804
- function maybeClip(clip) {
29805
- if (clip === true)
29806
- clip = "frame";
29807
- else if (clip === false)
29808
- clip = null;
29809
- else if (clip != null)
29810
- clip = keyword(clip, "clip", ["frame", "sphere"]);
29811
- return clip;
29775
+ return projection3;
29776
+ },
29777
+ aspectRatio
29778
+ };
29812
29779
  }
29813
- function applyClip(selection2, mark, dimensions, context) {
29814
- let clipUrl;
29815
- const { clip = context.clip } = mark;
29816
- switch (clip) {
29817
- case "frame": {
29818
- const { width, height, marginLeft, marginRight, marginTop, marginBottom } = dimensions;
29819
- const id2 = getClipId();
29820
- clipUrl = `url(#${id2})`;
29821
- selection2 = create3("svg:g", context).call(
29822
- (g) => g.append("svg:clipPath").attr("id", id2).append("rect").attr("x", marginLeft).attr("y", marginTop).attr("width", width - marginRight - marginLeft).attr("height", height - marginTop - marginBottom)
29823
- ).each(function() {
29824
- this.appendChild(selection2.node());
29825
- selection2.node = () => this;
29826
- });
29827
- break;
29780
+ var identity8 = constant({ stream: (stream) => stream });
29781
+ var reflectY = constant(
29782
+ transform_default({
29783
+ point(x3, y3) {
29784
+ this.stream.point(x3, -y3);
29828
29785
  }
29829
- case "sphere": {
29830
- const { projection: projection3 } = context;
29831
- if (!projection3)
29832
- throw new Error(`the "sphere" clip option requires a projection`);
29833
- const id2 = getClipId();
29834
- clipUrl = `url(#${id2})`;
29835
- selection2.append("clipPath").attr("id", id2).append("path").attr("d", path_default(projection3)({ type: "Sphere" }));
29836
- break;
29786
+ })
29787
+ );
29788
+ function project(cx, cy, values2, projection3) {
29789
+ const x3 = values2[cx];
29790
+ const y3 = values2[cy];
29791
+ const n = x3.length;
29792
+ const X3 = values2[cx] = new Float64Array(n).fill(NaN);
29793
+ const Y3 = values2[cy] = new Float64Array(n).fill(NaN);
29794
+ let i;
29795
+ const stream = projection3.stream({
29796
+ point(x4, y4) {
29797
+ X3[i] = x4;
29798
+ Y3[i] = y4;
29837
29799
  }
29800
+ });
29801
+ for (i = 0; i < n; ++i) {
29802
+ stream.point(x3[i], y3[i]);
29838
29803
  }
29839
- applyAttr(selection2, "aria-label", mark.ariaLabel);
29840
- applyAttr(selection2, "aria-description", mark.ariaDescription);
29841
- applyAttr(selection2, "aria-hidden", mark.ariaHidden);
29842
- applyAttr(selection2, "clip-path", clipUrl);
29843
29804
  }
29844
- function applyIndirectStyles(selection2, mark, dimensions, context) {
29845
- applyClip(selection2, mark, dimensions, context);
29846
- applyAttr(selection2, "fill", mark.fill);
29847
- applyAttr(selection2, "fill-opacity", mark.fillOpacity);
29848
- applyAttr(selection2, "stroke", mark.stroke);
29849
- applyAttr(selection2, "stroke-width", mark.strokeWidth);
29850
- applyAttr(selection2, "stroke-opacity", mark.strokeOpacity);
29851
- applyAttr(selection2, "stroke-linejoin", mark.strokeLinejoin);
29852
- applyAttr(selection2, "stroke-linecap", mark.strokeLinecap);
29853
- applyAttr(selection2, "stroke-miterlimit", mark.strokeMiterlimit);
29854
- applyAttr(selection2, "stroke-dasharray", mark.strokeDasharray);
29855
- applyAttr(selection2, "stroke-dashoffset", mark.strokeDashoffset);
29856
- applyAttr(selection2, "shape-rendering", mark.shapeRendering);
29857
- applyAttr(selection2, "filter", mark.imageFilter);
29858
- applyAttr(selection2, "paint-order", mark.paintOrder);
29859
- const { pointerEvents = context.pointerSticky === false ? "none" : void 0 } = mark;
29860
- applyAttr(selection2, "pointer-events", pointerEvents);
29805
+ function hasProjection({ projection: projection3 } = {}) {
29806
+ if (projection3 == null)
29807
+ return false;
29808
+ if (typeof projection3.stream === "function")
29809
+ return true;
29810
+ if (isObject2(projection3))
29811
+ projection3 = projection3.type;
29812
+ return projection3 != null;
29861
29813
  }
29862
- function applyDirectStyles(selection2, mark) {
29863
- applyStyle(selection2, "mix-blend-mode", mark.mixBlendMode);
29864
- applyAttr(selection2, "opacity", mark.opacity);
29814
+ function projectionAspectRatio(projection3) {
29815
+ if (typeof projection3?.stream === "function")
29816
+ return defaultAspectRatio;
29817
+ if (isObject2(projection3))
29818
+ projection3 = projection3.type;
29819
+ if (projection3 == null)
29820
+ return;
29821
+ if (typeof projection3 !== "function") {
29822
+ const { aspectRatio } = namedProjection(projection3);
29823
+ if (aspectRatio)
29824
+ return aspectRatio;
29825
+ }
29826
+ return defaultAspectRatio;
29865
29827
  }
29866
- function applyHref(selection2, href, target) {
29867
- selection2.each(function(i) {
29868
- const h = href(i);
29869
- if (h != null) {
29870
- const a2 = this.ownerDocument.createElementNS(namespaces_default.svg, "a");
29871
- a2.setAttribute("fill", "inherit");
29872
- a2.setAttributeNS(namespaces_default.xlink, "href", h);
29873
- if (target != null)
29874
- a2.setAttribute("target", target);
29875
- this.parentNode.insertBefore(a2, this).appendChild(this);
29876
- }
29877
- });
29878
- }
29879
- function applyAttr(selection2, name, value) {
29880
- if (value != null)
29881
- selection2.attr(name, value);
29828
+ function applyPosition(channels, scales2, { projection: projection3 }) {
29829
+ const { x: x3, y: y3 } = channels;
29830
+ let position3 = {};
29831
+ if (x3)
29832
+ position3.x = x3;
29833
+ if (y3)
29834
+ position3.y = y3;
29835
+ position3 = valueObject(position3, scales2);
29836
+ if (projection3 && x3?.scale === "x" && y3?.scale === "y")
29837
+ project("x", "y", position3, projection3);
29838
+ if (x3)
29839
+ position3.x = coerceNumbers(position3.x);
29840
+ if (y3)
29841
+ position3.y = coerceNumbers(position3.y);
29842
+ return position3;
29882
29843
  }
29883
- function applyStyle(selection2, name, value) {
29884
- if (value != null)
29885
- selection2.style(name, value);
29844
+ function getGeometryChannels(channel) {
29845
+ const X3 = [];
29846
+ const Y3 = [];
29847
+ const x3 = { scale: "x", value: X3 };
29848
+ const y3 = { scale: "y", value: Y3 };
29849
+ const sink = {
29850
+ point(x4, y4) {
29851
+ X3.push(x4);
29852
+ Y3.push(y4);
29853
+ },
29854
+ lineStart() {
29855
+ },
29856
+ lineEnd() {
29857
+ },
29858
+ polygonStart() {
29859
+ },
29860
+ polygonEnd() {
29861
+ },
29862
+ sphere() {
29863
+ }
29864
+ };
29865
+ for (const object of channel.value)
29866
+ stream_default(object, sink);
29867
+ return [x3, y3];
29886
29868
  }
29887
- function applyTransform(selection2, mark, { x: x3, y: y3 }, tx = offset, ty = offset) {
29888
- tx += mark.dx;
29889
- ty += mark.dy;
29890
- if (x3?.bandwidth)
29891
- tx += x3.bandwidth() / 2;
29892
- if (y3?.bandwidth)
29893
- ty += y3.bandwidth() / 2;
29894
- if (tx || ty)
29895
- selection2.attr("transform", `translate(${tx},${ty})`);
29869
+
29870
+ // ../../node_modules/@observablehq/plot/src/scales/schemes.js
29871
+ var categoricalSchemes = /* @__PURE__ */ new Map([
29872
+ ["accent", Accent_default],
29873
+ ["category10", category10_default],
29874
+ ["dark2", Dark2_default],
29875
+ ["observable10", observable10_default],
29876
+ ["paired", Paired_default],
29877
+ ["pastel1", Pastel1_default],
29878
+ ["pastel2", Pastel2_default],
29879
+ ["set1", Set1_default],
29880
+ ["set2", Set2_default],
29881
+ ["set3", Set3_default],
29882
+ ["tableau10", Tableau10_default]
29883
+ ]);
29884
+ function isCategoricalScheme(scheme28) {
29885
+ return scheme28 != null && categoricalSchemes.has(`${scheme28}`.toLowerCase());
29896
29886
  }
29897
- function impliedString(value, impliedValue) {
29898
- if ((value = string(value)) !== impliedValue)
29899
- return value;
29887
+ var ordinalSchemes = new Map([
29888
+ ...categoricalSchemes,
29889
+ // diverging
29890
+ ["brbg", scheme112(scheme, BrBG_default)],
29891
+ ["prgn", scheme112(scheme2, PRGn_default)],
29892
+ ["piyg", scheme112(scheme3, PiYG_default)],
29893
+ ["puor", scheme112(scheme4, PuOr_default)],
29894
+ ["rdbu", scheme112(scheme5, RdBu_default)],
29895
+ ["rdgy", scheme112(scheme6, RdGy_default)],
29896
+ ["rdylbu", scheme112(scheme7, RdYlBu_default)],
29897
+ ["rdylgn", scheme112(scheme8, RdYlGn_default)],
29898
+ ["spectral", scheme112(scheme9, Spectral_default)],
29899
+ // reversed diverging (for temperature data)
29900
+ ["burd", scheme11r(scheme5, RdBu_default)],
29901
+ ["buylrd", scheme11r(scheme7, RdYlBu_default)],
29902
+ // sequential (single-hue)
29903
+ ["blues", scheme92(scheme22, Blues_default)],
29904
+ ["greens", scheme92(scheme23, Greens_default)],
29905
+ ["greys", scheme92(scheme24, Greys_default)],
29906
+ ["oranges", scheme92(scheme27, Oranges_default)],
29907
+ ["purples", scheme92(scheme25, Purples_default)],
29908
+ ["reds", scheme92(scheme26, Reds_default)],
29909
+ // sequential (multi-hue)
29910
+ ["turbo", schemei(turbo_default)],
29911
+ ["viridis", schemei(viridis_default)],
29912
+ ["magma", schemei(magma)],
29913
+ ["inferno", schemei(inferno)],
29914
+ ["plasma", schemei(plasma)],
29915
+ ["cividis", schemei(cividis_default)],
29916
+ ["cubehelix", schemei(cubehelix_default2)],
29917
+ ["warm", schemei(warm)],
29918
+ ["cool", schemei(cool)],
29919
+ ["bugn", scheme92(scheme10, BuGn_default)],
29920
+ ["bupu", scheme92(scheme11, BuPu_default)],
29921
+ ["gnbu", scheme92(scheme12, GnBu_default)],
29922
+ ["orrd", scheme92(scheme13, OrRd_default)],
29923
+ ["pubu", scheme92(scheme15, PuBu_default)],
29924
+ ["pubugn", scheme92(scheme14, PuBuGn_default)],
29925
+ ["purd", scheme92(scheme16, PuRd_default)],
29926
+ ["rdpu", scheme92(scheme17, RdPu_default)],
29927
+ ["ylgn", scheme92(scheme19, YlGn_default)],
29928
+ ["ylgnbu", scheme92(scheme18, YlGnBu_default)],
29929
+ ["ylorbr", scheme92(scheme20, YlOrBr_default)],
29930
+ ["ylorrd", scheme92(scheme21, YlOrRd_default)],
29931
+ // cyclical
29932
+ ["rainbow", schemeicyclical(rainbow_default)],
29933
+ ["sinebow", schemeicyclical(sinebow_default)]
29934
+ ]);
29935
+ function scheme92(scheme28, interpolate) {
29936
+ return ({ length: n }) => {
29937
+ if (n === 1)
29938
+ return [scheme28[3][1]];
29939
+ if (n === 2)
29940
+ return [scheme28[3][1], scheme28[3][2]];
29941
+ n = Math.max(3, Math.floor(n));
29942
+ return n > 9 ? quantize_default(interpolate, n) : scheme28[n];
29943
+ };
29900
29944
  }
29901
- function impliedNumber(value, impliedValue) {
29902
- if ((value = number5(value)) !== impliedValue)
29903
- return value;
29945
+ function scheme112(scheme28, interpolate) {
29946
+ return ({ length: n }) => {
29947
+ if (n === 2)
29948
+ return [scheme28[3][0], scheme28[3][2]];
29949
+ n = Math.max(3, Math.floor(n));
29950
+ return n > 11 ? quantize_default(interpolate, n) : scheme28[n];
29951
+ };
29904
29952
  }
29905
- var validClassName = /^-?([_a-z]|[\240-\377]|\\[0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|\\[^\r\n\f0-9a-f])([_a-z0-9-]|[\240-\377]|\\[0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|\\[^\r\n\f0-9a-f])*$/i;
29906
- function maybeClassName(name) {
29907
- if (name === void 0)
29908
- return "plot-d6a7b5";
29909
- name = `${name}`;
29910
- if (!validClassName.test(name))
29911
- throw new Error(`invalid class name: ${name}`);
29912
- return name;
29953
+ function scheme11r(scheme28, interpolate) {
29954
+ return ({ length: n }) => {
29955
+ if (n === 2)
29956
+ return [scheme28[3][2], scheme28[3][0]];
29957
+ n = Math.max(3, Math.floor(n));
29958
+ return n > 11 ? quantize_default((t) => interpolate(1 - t), n) : scheme28[n].slice().reverse();
29959
+ };
29913
29960
  }
29914
- function applyInlineStyles(selection2, style) {
29915
- if (typeof style === "string") {
29916
- selection2.property("style", style);
29917
- } else if (style != null) {
29918
- for (const element of selection2) {
29919
- Object.assign(element.style, style);
29920
- }
29921
- }
29961
+ function schemei(interpolate) {
29962
+ return ({ length: n }) => quantize_default(interpolate, Math.max(2, Math.floor(n)));
29922
29963
  }
29923
- function applyFrameAnchor({ frameAnchor }, { width, height, marginTop, marginRight, marginBottom, marginLeft }) {
29924
- return [
29925
- /left$/.test(frameAnchor) ? marginLeft : /right$/.test(frameAnchor) ? width - marginRight : (marginLeft + width - marginRight) / 2,
29926
- /^top/.test(frameAnchor) ? marginTop : /^bottom/.test(frameAnchor) ? height - marginBottom : (marginTop + height - marginBottom) / 2
29927
- ];
29964
+ function schemeicyclical(interpolate) {
29965
+ return ({ length: n }) => quantize_default(interpolate, Math.floor(n) + 1).slice(0, -1);
29928
29966
  }
29929
-
29930
- // ../../node_modules/@observablehq/plot/src/context.js
29931
- function createContext(options = {}) {
29932
- const { document: document2 = typeof window !== "undefined" ? window.document : void 0, clip } = options;
29933
- return { document: document2, clip: maybeClip(clip) };
29967
+ function ordinalScheme(scheme28) {
29968
+ const s2 = `${scheme28}`.toLowerCase();
29969
+ if (!ordinalSchemes.has(s2))
29970
+ throw new Error(`unknown ordinal scheme: ${s2}`);
29971
+ return ordinalSchemes.get(s2);
29934
29972
  }
29935
- function create3(name, { document: document2 }) {
29936
- return select_default2(creator_default(name).call(document2.documentElement));
29973
+ function ordinalRange(scheme28, length4) {
29974
+ const s2 = ordinalScheme(scheme28);
29975
+ const r = typeof s2 === "function" ? s2({ length: length4 }) : s2;
29976
+ return r.length !== length4 ? r.slice(0, length4) : r;
29937
29977
  }
29938
-
29939
- // ../../node_modules/@observablehq/plot/src/projection.js
29940
- var pi4 = Math.PI;
29941
- var tau5 = 2 * pi4;
29942
- var defaultAspectRatio = 0.618;
29943
- function createProjection({
29944
- projection: projection3,
29945
- inset: globalInset = 0,
29946
- insetTop = globalInset,
29947
- insetRight = globalInset,
29948
- insetBottom = globalInset,
29949
- insetLeft = globalInset
29950
- } = {}, dimensions) {
29951
- if (projection3 == null)
29952
- return;
29953
- if (typeof projection3.stream === "function")
29954
- return projection3;
29955
- let options;
29956
- let domain;
29957
- let clip = "frame";
29958
- if (isObject2(projection3)) {
29959
- let inset;
29960
- ({
29961
- type: projection3,
29962
- domain,
29963
- inset,
29964
- insetTop = inset !== void 0 ? inset : insetTop,
29965
- insetRight = inset !== void 0 ? inset : insetRight,
29966
- insetBottom = inset !== void 0 ? inset : insetBottom,
29967
- insetLeft = inset !== void 0 ? inset : insetLeft,
29968
- clip = clip,
29969
- ...options
29970
- } = projection3);
29971
- if (projection3 == null)
29978
+ function maybeBooleanRange(domain, scheme28 = "greys") {
29979
+ const range3 = /* @__PURE__ */ new Set();
29980
+ const [f, t] = ordinalRange(scheme28, 2);
29981
+ for (const value of domain) {
29982
+ if (value == null)
29983
+ continue;
29984
+ if (value === true)
29985
+ range3.add(t);
29986
+ else if (value === false)
29987
+ range3.add(f);
29988
+ else
29972
29989
  return;
29973
29990
  }
29974
- if (typeof projection3 !== "function")
29975
- ({ type: projection3 } = namedProjection(projection3));
29976
- const { width, height, marginLeft, marginRight, marginTop, marginBottom } = dimensions;
29977
- const dx = width - marginLeft - marginRight - insetLeft - insetRight;
29978
- const dy = height - marginTop - marginBottom - insetTop - insetBottom;
29979
- projection3 = projection3?.({ width: dx, height: dy, clip, ...options });
29980
- if (projection3 == null)
29981
- return;
29982
- clip = maybePostClip(clip, marginLeft, marginTop, width - marginRight, height - marginBottom);
29983
- let tx = marginLeft + insetLeft;
29984
- let ty = marginTop + insetTop;
29985
- let transform3;
29986
- if (domain != null) {
29987
- const [[x06, y06], [x12, y12]] = path_default(projection3).bounds(domain);
29988
- const k2 = Math.min(dx / (x12 - x06), dy / (y12 - y06));
29989
- if (k2 > 0) {
29990
- tx -= (k2 * (x06 + x12) - dx) / 2;
29991
- ty -= (k2 * (y06 + y12) - dy) / 2;
29992
- transform3 = transform_default({
29993
- point(x3, y3) {
29994
- this.stream.point(x3 * k2 + tx, y3 * k2 + ty);
29995
- }
29996
- });
29997
- } else {
29998
- warn(`Warning: the projection could not be fit to the specified domain; using the default scale.`);
29991
+ return [...range3];
29992
+ }
29993
+ var quantitativeSchemes = /* @__PURE__ */ new Map([
29994
+ // diverging
29995
+ ["brbg", BrBG_default],
29996
+ ["prgn", PRGn_default],
29997
+ ["piyg", PiYG_default],
29998
+ ["puor", PuOr_default],
29999
+ ["rdbu", RdBu_default],
30000
+ ["rdgy", RdGy_default],
30001
+ ["rdylbu", RdYlBu_default],
30002
+ ["rdylgn", RdYlGn_default],
30003
+ ["spectral", Spectral_default],
30004
+ // reversed diverging (for temperature data)
30005
+ ["burd", (t) => RdBu_default(1 - t)],
30006
+ ["buylrd", (t) => RdYlBu_default(1 - t)],
30007
+ // sequential (single-hue)
30008
+ ["blues", Blues_default],
30009
+ ["greens", Greens_default],
30010
+ ["greys", Greys_default],
30011
+ ["purples", Purples_default],
30012
+ ["reds", Reds_default],
30013
+ ["oranges", Oranges_default],
30014
+ // sequential (multi-hue)
30015
+ ["turbo", turbo_default],
30016
+ ["viridis", viridis_default],
30017
+ ["magma", magma],
30018
+ ["inferno", inferno],
30019
+ ["plasma", plasma],
30020
+ ["cividis", cividis_default],
30021
+ ["cubehelix", cubehelix_default2],
30022
+ ["warm", warm],
30023
+ ["cool", cool],
30024
+ ["bugn", BuGn_default],
30025
+ ["bupu", BuPu_default],
30026
+ ["gnbu", GnBu_default],
30027
+ ["orrd", OrRd_default],
30028
+ ["pubugn", PuBuGn_default],
30029
+ ["pubu", PuBu_default],
30030
+ ["purd", PuRd_default],
30031
+ ["rdpu", RdPu_default],
30032
+ ["ylgnbu", YlGnBu_default],
30033
+ ["ylgn", YlGn_default],
30034
+ ["ylorbr", YlOrBr_default],
30035
+ ["ylorrd", YlOrRd_default],
30036
+ // cyclical
30037
+ ["rainbow", rainbow_default],
30038
+ ["sinebow", sinebow_default]
30039
+ ]);
30040
+ function quantitativeScheme(scheme28) {
30041
+ const s2 = `${scheme28}`.toLowerCase();
30042
+ if (!quantitativeSchemes.has(s2))
30043
+ throw new Error(`unknown quantitative scheme: ${s2}`);
30044
+ return quantitativeSchemes.get(s2);
30045
+ }
30046
+ var divergingSchemes = /* @__PURE__ */ new Set([
30047
+ "brbg",
30048
+ "prgn",
30049
+ "piyg",
30050
+ "puor",
30051
+ "rdbu",
30052
+ "rdgy",
30053
+ "rdylbu",
30054
+ "rdylgn",
30055
+ "spectral",
30056
+ "burd",
30057
+ "buylrd"
30058
+ ]);
30059
+ function isDivergingScheme(scheme28) {
30060
+ return scheme28 != null && divergingSchemes.has(`${scheme28}`.toLowerCase());
30061
+ }
30062
+
30063
+ // ../../node_modules/@observablehq/plot/src/scales/quantitative.js
30064
+ var flip = (i) => (t) => i(1 - t);
30065
+ var unit2 = [0, 1];
30066
+ var interpolators = /* @__PURE__ */ new Map([
30067
+ // numbers
30068
+ ["number", number_default],
30069
+ // color spaces
30070
+ ["rgb", rgb_default],
30071
+ ["hsl", hsl_default],
30072
+ ["hcl", hcl_default],
30073
+ ["lab", lab2]
30074
+ ]);
30075
+ function maybeInterpolator(interpolate) {
30076
+ const i = `${interpolate}`.toLowerCase();
30077
+ if (!interpolators.has(i))
30078
+ throw new Error(`unknown interpolator: ${i}`);
30079
+ return interpolators.get(i);
30080
+ }
30081
+ function createScaleQ(key, scale3, channels, {
30082
+ type: type2,
30083
+ nice: nice3,
30084
+ clamp,
30085
+ zero: zero3,
30086
+ domain = inferAutoDomain(key, channels),
30087
+ unknown,
30088
+ round: round2,
30089
+ scheme: scheme28,
30090
+ interval: interval2,
30091
+ range: range3 = registry.get(key) === radius ? inferRadialRange(channels, domain) : registry.get(key) === length3 ? inferLengthRange(channels, domain) : registry.get(key) === opacity ? unit2 : void 0,
30092
+ interpolate = registry.get(key) === color2 ? scheme28 == null && range3 !== void 0 ? rgb_default : quantitativeScheme(scheme28 !== void 0 ? scheme28 : type2 === "cyclical" ? "rainbow" : "turbo") : round2 ? round_default : number_default,
30093
+ reverse: reverse3
30094
+ }) {
30095
+ interval2 = maybeRangeInterval(interval2, type2);
30096
+ if (type2 === "cyclical" || type2 === "sequential")
30097
+ type2 = "linear";
30098
+ if (typeof interpolate !== "function")
30099
+ interpolate = maybeInterpolator(interpolate);
30100
+ reverse3 = !!reverse3;
30101
+ if (range3 !== void 0) {
30102
+ const n = (domain = arrayify2(domain)).length;
30103
+ const m = (range3 = arrayify2(range3)).length;
30104
+ if (n !== m) {
30105
+ if (interpolate.length === 1)
30106
+ throw new Error("invalid piecewise interpolator");
30107
+ interpolate = piecewise(interpolate, range3);
30108
+ range3 = void 0;
29999
30109
  }
30000
30110
  }
30001
- transform3 ??= tx === 0 && ty === 0 ? identity8() : transform_default({
30002
- point(x3, y3) {
30003
- this.stream.point(x3 + tx, y3 + ty);
30111
+ if (interpolate.length === 1) {
30112
+ if (reverse3) {
30113
+ interpolate = flip(interpolate);
30114
+ reverse3 = false;
30115
+ }
30116
+ if (range3 === void 0) {
30117
+ range3 = Float64Array.from(domain, (_, i) => i / (domain.length - 1));
30118
+ if (range3.length === 2)
30119
+ range3 = unit2;
30120
+ }
30121
+ scale3.interpolate((range3 === unit2 ? constant : interpolatePiecewise)(interpolate));
30122
+ } else {
30123
+ scale3.interpolate(interpolate);
30124
+ }
30125
+ if (zero3) {
30126
+ const [min5, max4] = extent(domain);
30127
+ if (min5 > 0 || max4 < 0) {
30128
+ domain = slice3(domain);
30129
+ if (orderof(domain) !== Math.sign(min5))
30130
+ domain[domain.length - 1] = 0;
30131
+ else
30132
+ domain[0] = 0;
30004
30133
  }
30005
- });
30006
- return { stream: (s2) => projection3.stream(transform3.stream(clip(s2))) };
30007
- }
30008
- function namedProjection(projection3) {
30009
- switch (`${projection3}`.toLowerCase()) {
30010
- case "albers-usa":
30011
- return scaleProjection(albersUsa_default, 0.7463, 0.4673);
30012
- case "albers":
30013
- return conicProjection2(albers_default, 0.7463, 0.4673);
30014
- case "azimuthal-equal-area":
30015
- return scaleProjection(azimuthalEqualArea_default, 4, 4);
30016
- case "azimuthal-equidistant":
30017
- return scaleProjection(azimuthalEquidistant_default, tau5, tau5);
30018
- case "conic-conformal":
30019
- return conicProjection2(conicConformal_default, tau5, tau5);
30020
- case "conic-equal-area":
30021
- return conicProjection2(conicEqualArea_default, 6.1702, 2.9781);
30022
- case "conic-equidistant":
30023
- return conicProjection2(conicEquidistant_default, 7.312, 3.6282);
30024
- case "equal-earth":
30025
- return scaleProjection(equalEarth_default, 5.4133, 2.6347);
30026
- case "equirectangular":
30027
- return scaleProjection(equirectangular_default, tau5, pi4);
30028
- case "gnomonic":
30029
- return scaleProjection(gnomonic_default, 3.4641, 3.4641);
30030
- case "identity":
30031
- return { type: identity8 };
30032
- case "reflect-y":
30033
- return { type: reflectY };
30034
- case "mercator":
30035
- return scaleProjection(mercator_default, tau5, tau5);
30036
- case "orthographic":
30037
- return scaleProjection(orthographic_default, 2, 2);
30038
- case "stereographic":
30039
- return scaleProjection(stereographic_default, 2, 2);
30040
- case "transverse-mercator":
30041
- return scaleProjection(transverseMercator_default, tau5, tau5);
30042
- default:
30043
- throw new Error(`unknown projection type: ${projection3}`);
30044
30134
  }
30135
+ if (reverse3)
30136
+ domain = reverse(domain);
30137
+ scale3.domain(domain).unknown(unknown);
30138
+ if (nice3)
30139
+ scale3.nice(maybeNice(nice3, type2)), domain = scale3.domain();
30140
+ if (range3 !== void 0)
30141
+ scale3.range(range3);
30142
+ if (clamp)
30143
+ scale3.clamp(clamp);
30144
+ return { type: type2, domain, range: range3, scale: scale3, interpolate, interval: interval2 };
30045
30145
  }
30046
- function maybePostClip(clip, x12, y12, x22, y22) {
30047
- if (clip === false || clip == null || typeof clip === "number")
30048
- return (s2) => s2;
30049
- if (clip === true)
30050
- clip = "frame";
30051
- switch (`${clip}`.toLowerCase()) {
30052
- case "frame":
30053
- return clipRectangle(x12, y12, x22, y22);
30054
- default:
30055
- throw new Error(`unknown projection clip type: ${clip}`);
30146
+ function maybeNice(nice3, type2) {
30147
+ return nice3 === true ? void 0 : typeof nice3 === "number" ? nice3 : maybeNiceInterval(nice3, type2);
30148
+ }
30149
+ function createScaleLinear(key, channels, options) {
30150
+ return createScaleQ(key, linear2(), channels, options);
30151
+ }
30152
+ function createScaleSqrt(key, channels, options) {
30153
+ return createScalePow(key, channels, { ...options, exponent: 0.5 });
30154
+ }
30155
+ function createScalePow(key, channels, { exponent = 1, ...options }) {
30156
+ return createScaleQ(key, pow3().exponent(exponent), channels, { ...options, type: "pow" });
30157
+ }
30158
+ function createScaleLog(key, channels, { base = 10, domain = inferLogDomain(channels), ...options }) {
30159
+ return createScaleQ(key, log2().base(base), channels, { ...options, domain });
30160
+ }
30161
+ function createScaleSymlog(key, channels, { constant: constant2 = 1, ...options }) {
30162
+ return createScaleQ(key, symlog().constant(constant2), channels, options);
30163
+ }
30164
+ function createScaleQuantile(key, channels, {
30165
+ range: range3,
30166
+ quantiles = range3 === void 0 ? 5 : (range3 = [...range3]).length,
30167
+ // deprecated; use n instead
30168
+ n = quantiles,
30169
+ scheme: scheme28 = "rdylbu",
30170
+ domain = inferQuantileDomain(channels),
30171
+ unknown,
30172
+ interpolate,
30173
+ reverse: reverse3
30174
+ }) {
30175
+ if (range3 === void 0) {
30176
+ range3 = interpolate !== void 0 ? quantize_default(interpolate, n) : registry.get(key) === color2 ? ordinalRange(scheme28, n) : void 0;
30177
+ }
30178
+ if (domain.length > 0) {
30179
+ domain = quantile3(domain, range3 === void 0 ? { length: n } : range3).quantiles();
30056
30180
  }
30181
+ return createScaleThreshold(key, channels, { domain, range: range3, reverse: reverse3, unknown });
30057
30182
  }
30058
- function scaleProjection(createProjection2, kx2, ky2) {
30059
- return {
30060
- type: ({ width, height, rotate, precision = 0.15, clip }) => {
30061
- const projection3 = createProjection2();
30062
- if (precision != null)
30063
- projection3.precision?.(precision);
30064
- if (rotate != null)
30065
- projection3.rotate?.(rotate);
30066
- if (typeof clip === "number")
30067
- projection3.clipAngle?.(clip);
30068
- projection3.scale(Math.min(width / kx2, height / ky2));
30069
- projection3.translate([width / 2, height / 2]);
30070
- return projection3;
30071
- },
30072
- aspectRatio: ky2 / kx2
30073
- };
30183
+ function createScaleQuantize(key, channels, {
30184
+ range: range3,
30185
+ n = range3 === void 0 ? 5 : (range3 = [...range3]).length,
30186
+ scheme: scheme28 = "rdylbu",
30187
+ domain = inferAutoDomain(key, channels),
30188
+ unknown,
30189
+ interpolate,
30190
+ reverse: reverse3
30191
+ }) {
30192
+ const [min5, max4] = extent(domain);
30193
+ let thresholds;
30194
+ if (range3 === void 0) {
30195
+ thresholds = ticks(min5, max4, n);
30196
+ if (thresholds[0] <= min5)
30197
+ thresholds.splice(0, 1);
30198
+ if (thresholds[thresholds.length - 1] >= max4)
30199
+ thresholds.pop();
30200
+ n = thresholds.length + 1;
30201
+ range3 = interpolate !== void 0 ? quantize_default(interpolate, n) : registry.get(key) === color2 ? ordinalRange(scheme28, n) : void 0;
30202
+ } else {
30203
+ thresholds = quantize_default(number_default(min5, max4), n + 1).slice(1, -1);
30204
+ if (min5 instanceof Date)
30205
+ thresholds = thresholds.map((x3) => new Date(x3));
30206
+ }
30207
+ if (orderof(arrayify2(domain)) < 0)
30208
+ thresholds.reverse();
30209
+ return createScaleThreshold(key, channels, { domain: thresholds, range: range3, reverse: reverse3, unknown });
30074
30210
  }
30075
- function conicProjection2(createProjection2, kx2, ky2) {
30076
- const { type: type2, aspectRatio } = scaleProjection(createProjection2, kx2, ky2);
30077
- return {
30078
- type: (options) => {
30079
- const { parallels, domain, width, height } = options;
30080
- const projection3 = type2(options);
30081
- if (parallels != null) {
30082
- projection3.parallels(parallels);
30083
- if (domain === void 0) {
30084
- projection3.fitSize([width, height], { type: "Sphere" });
30085
- }
30086
- }
30087
- return projection3;
30088
- },
30089
- aspectRatio
30211
+ function createScaleThreshold(key, channels, {
30212
+ domain = [0],
30213
+ // explicit thresholds in ascending order
30214
+ unknown,
30215
+ scheme: scheme28 = "rdylbu",
30216
+ interpolate,
30217
+ range: range3 = interpolate !== void 0 ? quantize_default(interpolate, domain.length + 1) : registry.get(key) === color2 ? ordinalRange(scheme28, domain.length + 1) : void 0,
30218
+ reverse: reverse3
30219
+ }) {
30220
+ domain = arrayify2(domain);
30221
+ const sign3 = orderof(domain);
30222
+ if (!isNaN(sign3) && !isOrdered(domain, sign3))
30223
+ throw new Error(`the ${key} scale has a non-monotonic domain`);
30224
+ if (reverse3)
30225
+ range3 = reverse(range3);
30226
+ return {
30227
+ type: "threshold",
30228
+ scale: threshold(sign3 < 0 ? reverse(domain) : domain, range3 === void 0 ? [] : range3).unknown(unknown),
30229
+ domain,
30230
+ range: range3
30090
30231
  };
30091
30232
  }
30092
- var identity8 = constant({ stream: (stream) => stream });
30093
- var reflectY = constant(
30094
- transform_default({
30095
- point(x3, y3) {
30096
- this.stream.point(x3, -y3);
30097
- }
30098
- })
30099
- );
30100
- function project(cx, cy, values2, projection3) {
30101
- const x3 = values2[cx];
30102
- const y3 = values2[cy];
30103
- const n = x3.length;
30104
- const X3 = values2[cx] = new Float64Array(n).fill(NaN);
30105
- const Y3 = values2[cy] = new Float64Array(n).fill(NaN);
30106
- let i;
30107
- const stream = projection3.stream({
30108
- point(x4, y4) {
30109
- X3[i] = x4;
30110
- Y3[i] = y4;
30111
- }
30112
- });
30113
- for (i = 0; i < n; ++i) {
30114
- stream.point(x3[i], y3[i]);
30233
+ function isOrdered(domain, sign3) {
30234
+ for (let i = 1, n = domain.length, d = domain[0]; i < n; ++i) {
30235
+ const s2 = descending(d, d = domain[i]);
30236
+ if (s2 !== 0 && s2 !== sign3)
30237
+ return false;
30115
30238
  }
30239
+ return true;
30116
30240
  }
30117
- function hasProjection({ projection: projection3 } = {}) {
30118
- if (projection3 == null)
30119
- return false;
30120
- if (typeof projection3.stream === "function")
30121
- return true;
30122
- if (isObject2(projection3))
30123
- projection3 = projection3.type;
30124
- return projection3 != null;
30241
+ function createScaleIdentity(key) {
30242
+ return { type: "identity", scale: hasNumericRange(registry.get(key)) ? identity5() : (d) => d };
30125
30243
  }
30126
- function projectionAspectRatio(projection3) {
30127
- if (typeof projection3?.stream === "function")
30128
- return defaultAspectRatio;
30129
- if (isObject2(projection3))
30130
- projection3 = projection3.type;
30131
- if (projection3 == null)
30132
- return;
30133
- if (typeof projection3 !== "function") {
30134
- const { aspectRatio } = namedProjection(projection3);
30135
- if (aspectRatio)
30136
- return aspectRatio;
30137
- }
30138
- return defaultAspectRatio;
30244
+ function inferDomain(channels, f = finite2) {
30245
+ return channels.length ? [
30246
+ min2(channels, ({ value }) => value === void 0 ? value : min2(value, f)),
30247
+ max2(channels, ({ value }) => value === void 0 ? value : max2(value, f))
30248
+ ] : [0, 1];
30139
30249
  }
30140
- function applyPosition(channels, scales2, { projection: projection3 }) {
30141
- const { x: x3, y: y3 } = channels;
30142
- let position3 = {};
30143
- if (x3)
30144
- position3.x = x3;
30145
- if (y3)
30146
- position3.y = y3;
30147
- position3 = valueObject(position3, scales2);
30148
- if (projection3 && x3?.scale === "x" && y3?.scale === "y")
30149
- project("x", "y", position3, projection3);
30150
- if (x3)
30151
- position3.x = coerceNumbers(position3.x);
30152
- if (y3)
30153
- position3.y = coerceNumbers(position3.y);
30154
- return position3;
30250
+ function inferAutoDomain(key, channels) {
30251
+ const type2 = registry.get(key);
30252
+ return (type2 === radius || type2 === opacity || type2 === length3 ? inferZeroDomain : inferDomain)(channels);
30155
30253
  }
30156
- function getGeometryChannels(channel) {
30157
- const X3 = [];
30158
- const Y3 = [];
30159
- const x3 = { scale: "x", value: X3 };
30160
- const y3 = { scale: "y", value: Y3 };
30161
- const sink = {
30162
- point(x4, y4) {
30163
- X3.push(x4);
30164
- Y3.push(y4);
30165
- },
30166
- lineStart() {
30167
- },
30168
- lineEnd() {
30169
- },
30170
- polygonStart() {
30171
- },
30172
- polygonEnd() {
30173
- },
30174
- sphere() {
30254
+ function inferZeroDomain(channels) {
30255
+ return [0, channels.length ? max2(channels, ({ value }) => value === void 0 ? value : max2(value, finite2)) : 1];
30256
+ }
30257
+ function inferRadialRange(channels, domain) {
30258
+ const hint = channels.find(({ radius: radius2 }) => radius2 !== void 0);
30259
+ if (hint !== void 0)
30260
+ return [0, hint.radius];
30261
+ const h25 = quantile2(channels, 0.5, ({ value }) => value === void 0 ? NaN : quantile2(value, 0.25, positive));
30262
+ const range3 = domain.map((d) => 3 * Math.sqrt(d / h25));
30263
+ const k2 = 30 / max2(range3);
30264
+ return k2 < 1 ? range3.map((r) => r * k2) : range3;
30265
+ }
30266
+ function inferLengthRange(channels, domain) {
30267
+ const h50 = median2(channels, ({ value }) => value === void 0 ? NaN : median2(value, Math.abs));
30268
+ const range3 = domain.map((d) => 12 * d / h50);
30269
+ const k2 = 60 / max2(range3);
30270
+ return k2 < 1 ? range3.map((r) => r * k2) : range3;
30271
+ }
30272
+ function inferLogDomain(channels) {
30273
+ for (const { value } of channels) {
30274
+ if (value !== void 0) {
30275
+ for (let v2 of value) {
30276
+ if (v2 > 0)
30277
+ return inferDomain(channels, positive);
30278
+ if (v2 < 0)
30279
+ return inferDomain(channels, negative);
30280
+ }
30175
30281
  }
30176
- };
30177
- for (const object2 of channel.value)
30178
- stream_default(object2, sink);
30179
- return [x3, y3];
30282
+ }
30283
+ return [1, 10];
30180
30284
  }
30181
-
30182
- // ../../node_modules/@observablehq/plot/src/scales/schemes.js
30183
- var schemeObservable10 = [
30184
- "#4269d0",
30185
- "#efb118",
30186
- "#ff725c",
30187
- "#6cc5b0",
30188
- "#3ca951",
30189
- "#ff8ab7",
30190
- "#a463f2",
30191
- "#97bbf5",
30192
- "#9c6b4e",
30193
- "#9498a0"
30194
- ];
30195
- var categoricalSchemes = /* @__PURE__ */ new Map([
30196
- ["accent", Accent_default],
30197
- ["category10", category10_default],
30198
- ["dark2", Dark2_default],
30199
- ["observable10", schemeObservable10],
30200
- ["paired", Paired_default],
30201
- ["pastel1", Pastel1_default],
30202
- ["pastel2", Pastel2_default],
30203
- ["set1", Set1_default],
30204
- ["set2", Set2_default],
30205
- ["set3", Set3_default],
30206
- ["tableau10", Tableau10_default]
30207
- ]);
30208
- function isCategoricalScheme(scheme28) {
30209
- return scheme28 != null && categoricalSchemes.has(`${scheme28}`.toLowerCase());
30285
+ function inferQuantileDomain(channels) {
30286
+ const domain = [];
30287
+ for (const { value } of channels) {
30288
+ if (value === void 0)
30289
+ continue;
30290
+ for (const v2 of value)
30291
+ domain.push(v2);
30292
+ }
30293
+ return domain;
30210
30294
  }
30211
- var ordinalSchemes = new Map([
30212
- ...categoricalSchemes,
30213
- // diverging
30214
- ["brbg", scheme112(scheme, BrBG_default)],
30215
- ["prgn", scheme112(scheme2, PRGn_default)],
30216
- ["piyg", scheme112(scheme3, PiYG_default)],
30217
- ["puor", scheme112(scheme4, PuOr_default)],
30218
- ["rdbu", scheme112(scheme5, RdBu_default)],
30219
- ["rdgy", scheme112(scheme6, RdGy_default)],
30220
- ["rdylbu", scheme112(scheme7, RdYlBu_default)],
30221
- ["rdylgn", scheme112(scheme8, RdYlGn_default)],
30222
- ["spectral", scheme112(scheme9, Spectral_default)],
30223
- // reversed diverging (for temperature data)
30224
- ["burd", scheme11r(scheme5, RdBu_default)],
30225
- ["buylrd", scheme11r(scheme7, RdYlBu_default)],
30226
- // sequential (single-hue)
30227
- ["blues", scheme92(scheme22, Blues_default)],
30228
- ["greens", scheme92(scheme23, Greens_default)],
30229
- ["greys", scheme92(scheme24, Greys_default)],
30230
- ["oranges", scheme92(scheme27, Oranges_default)],
30231
- ["purples", scheme92(scheme25, Purples_default)],
30232
- ["reds", scheme92(scheme26, Reds_default)],
30233
- // sequential (multi-hue)
30234
- ["turbo", schemei(turbo_default)],
30235
- ["viridis", schemei(viridis_default)],
30236
- ["magma", schemei(magma)],
30237
- ["inferno", schemei(inferno)],
30238
- ["plasma", schemei(plasma)],
30239
- ["cividis", schemei(cividis_default)],
30240
- ["cubehelix", schemei(cubehelix_default2)],
30241
- ["warm", schemei(warm)],
30242
- ["cool", schemei(cool)],
30243
- ["bugn", scheme92(scheme10, BuGn_default)],
30244
- ["bupu", scheme92(scheme11, BuPu_default)],
30245
- ["gnbu", scheme92(scheme12, GnBu_default)],
30246
- ["orrd", scheme92(scheme13, OrRd_default)],
30247
- ["pubu", scheme92(scheme15, PuBu_default)],
30248
- ["pubugn", scheme92(scheme14, PuBuGn_default)],
30249
- ["purd", scheme92(scheme16, PuRd_default)],
30250
- ["rdpu", scheme92(scheme17, RdPu_default)],
30251
- ["ylgn", scheme92(scheme19, YlGn_default)],
30252
- ["ylgnbu", scheme92(scheme18, YlGnBu_default)],
30253
- ["ylorbr", scheme92(scheme20, YlOrBr_default)],
30254
- ["ylorrd", scheme92(scheme21, YlOrRd_default)],
30255
- // cyclical
30256
- ["rainbow", schemeicyclical(rainbow_default)],
30257
- ["sinebow", schemeicyclical(sinebow_default)]
30258
- ]);
30259
- function scheme92(scheme28, interpolate) {
30260
- return ({ length: n }) => {
30261
- if (n === 1)
30262
- return [scheme28[3][1]];
30263
- if (n === 2)
30264
- return [scheme28[3][1], scheme28[3][2]];
30265
- n = Math.max(3, Math.floor(n));
30266
- return n > 9 ? quantize_default(interpolate, n) : scheme28[n];
30267
- };
30295
+ function interpolatePiecewise(interpolate) {
30296
+ return (i, j) => (t) => interpolate(i + t * (j - i));
30268
30297
  }
30269
- function scheme112(scheme28, interpolate) {
30270
- return ({ length: n }) => {
30271
- if (n === 2)
30272
- return [scheme28[3][0], scheme28[3][2]];
30273
- n = Math.max(3, Math.floor(n));
30274
- return n > 11 ? quantize_default(interpolate, n) : scheme28[n];
30275
- };
30298
+
30299
+ // ../../node_modules/@observablehq/plot/src/scales/diverging.js
30300
+ function createScaleD(key, scale3, transform3, channels, {
30301
+ type: type2,
30302
+ nice: nice3,
30303
+ clamp,
30304
+ domain = inferDomain(channels),
30305
+ unknown,
30306
+ pivot = 0,
30307
+ scheme: scheme28,
30308
+ range: range3,
30309
+ symmetric = true,
30310
+ interpolate = registry.get(key) === color2 ? scheme28 == null && range3 !== void 0 ? rgb_default : quantitativeScheme(scheme28 !== void 0 ? scheme28 : "rdbu") : number_default,
30311
+ reverse: reverse3
30312
+ }) {
30313
+ pivot = +pivot;
30314
+ domain = arrayify2(domain);
30315
+ let [min5, max4] = domain;
30316
+ if (domain.length > 2)
30317
+ warn(`Warning: the diverging ${key} scale domain contains extra elements.`);
30318
+ if (descending(min5, max4) < 0)
30319
+ [min5, max4] = [max4, min5], reverse3 = !reverse3;
30320
+ min5 = Math.min(min5, pivot);
30321
+ max4 = Math.max(max4, pivot);
30322
+ if (typeof interpolate !== "function") {
30323
+ interpolate = maybeInterpolator(interpolate);
30324
+ }
30325
+ if (range3 !== void 0) {
30326
+ interpolate = interpolate.length === 1 ? interpolatePiecewise(interpolate)(...range3) : piecewise(interpolate, range3);
30327
+ }
30328
+ if (reverse3)
30329
+ interpolate = flip(interpolate);
30330
+ if (symmetric) {
30331
+ const mid2 = transform3.apply(pivot);
30332
+ const mindelta = mid2 - transform3.apply(min5);
30333
+ const maxdelta = transform3.apply(max4) - mid2;
30334
+ if (mindelta < maxdelta)
30335
+ min5 = transform3.invert(mid2 - maxdelta);
30336
+ else if (mindelta > maxdelta)
30337
+ max4 = transform3.invert(mid2 + mindelta);
30338
+ }
30339
+ scale3.domain([min5, pivot, max4]).unknown(unknown).interpolator(interpolate);
30340
+ if (clamp)
30341
+ scale3.clamp(clamp);
30342
+ if (nice3)
30343
+ scale3.nice(nice3);
30344
+ return { type: type2, domain: [min5, max4], pivot, interpolate, scale: scale3 };
30276
30345
  }
30277
- function scheme11r(scheme28, interpolate) {
30278
- return ({ length: n }) => {
30279
- if (n === 2)
30280
- return [scheme28[3][2], scheme28[3][0]];
30281
- n = Math.max(3, Math.floor(n));
30282
- return n > 11 ? quantize_default((t) => interpolate(1 - t), n) : scheme28[n].slice().reverse();
30283
- };
30346
+ function createScaleDiverging(key, channels, options) {
30347
+ return createScaleD(key, diverging(), transformIdentity, channels, options);
30284
30348
  }
30285
- function schemei(interpolate) {
30286
- return ({ length: n }) => quantize_default(interpolate, Math.max(2, Math.floor(n)));
30349
+ function createScaleDivergingSqrt(key, channels, options) {
30350
+ return createScaleDivergingPow(key, channels, { ...options, exponent: 0.5 });
30287
30351
  }
30288
- function schemeicyclical(interpolate) {
30289
- return ({ length: n }) => quantize_default(interpolate, Math.floor(n) + 1).slice(0, -1);
30352
+ function createScaleDivergingPow(key, channels, { exponent = 1, ...options }) {
30353
+ return createScaleD(key, divergingPow().exponent(exponent = +exponent), transformPow2(exponent), channels, {
30354
+ ...options,
30355
+ type: "diverging-pow"
30356
+ });
30290
30357
  }
30291
- function ordinalScheme(scheme28) {
30292
- const s2 = `${scheme28}`.toLowerCase();
30293
- if (!ordinalSchemes.has(s2))
30294
- throw new Error(`unknown ordinal scheme: ${s2}`);
30295
- return ordinalSchemes.get(s2);
30358
+ function createScaleDivergingLog(key, channels, { base = 10, pivot = 1, domain = inferDomain(channels, pivot < 0 ? negative : positive), ...options }) {
30359
+ return createScaleD(key, divergingLog().base(base = +base), transformLog2, channels, {
30360
+ domain,
30361
+ pivot,
30362
+ ...options
30363
+ });
30296
30364
  }
30297
- function ordinalRange(scheme28, length4) {
30298
- const s2 = ordinalScheme(scheme28);
30299
- const r = typeof s2 === "function" ? s2({ length: length4 }) : s2;
30300
- return r.length !== length4 ? r.slice(0, length4) : r;
30365
+ function createScaleDivergingSymlog(key, channels, { constant: constant2 = 1, ...options }) {
30366
+ return createScaleD(
30367
+ key,
30368
+ divergingSymlog().constant(constant2 = +constant2),
30369
+ transformSymlog2(constant2),
30370
+ channels,
30371
+ options
30372
+ );
30301
30373
  }
30302
- function maybeBooleanRange(domain, scheme28 = "greys") {
30303
- const range3 = /* @__PURE__ */ new Set();
30304
- const [f, t] = ordinalRange(scheme28, 2);
30305
- for (const value of domain) {
30306
- if (value == null)
30307
- continue;
30308
- if (value === true)
30309
- range3.add(t);
30310
- else if (value === false)
30311
- range3.add(f);
30312
- else
30313
- return;
30374
+ var transformIdentity = {
30375
+ apply(x3) {
30376
+ return x3;
30377
+ },
30378
+ invert(x3) {
30379
+ return x3;
30314
30380
  }
30315
- return [...range3];
30316
- }
30317
- var quantitativeSchemes = /* @__PURE__ */ new Map([
30318
- // diverging
30319
- ["brbg", BrBG_default],
30320
- ["prgn", PRGn_default],
30321
- ["piyg", PiYG_default],
30322
- ["puor", PuOr_default],
30323
- ["rdbu", RdBu_default],
30324
- ["rdgy", RdGy_default],
30325
- ["rdylbu", RdYlBu_default],
30326
- ["rdylgn", RdYlGn_default],
30327
- ["spectral", Spectral_default],
30328
- // reversed diverging (for temperature data)
30329
- ["burd", (t) => RdBu_default(1 - t)],
30330
- ["buylrd", (t) => RdYlBu_default(1 - t)],
30331
- // sequential (single-hue)
30332
- ["blues", Blues_default],
30333
- ["greens", Greens_default],
30334
- ["greys", Greys_default],
30335
- ["purples", Purples_default],
30336
- ["reds", Reds_default],
30337
- ["oranges", Oranges_default],
30338
- // sequential (multi-hue)
30339
- ["turbo", turbo_default],
30340
- ["viridis", viridis_default],
30341
- ["magma", magma],
30342
- ["inferno", inferno],
30343
- ["plasma", plasma],
30344
- ["cividis", cividis_default],
30345
- ["cubehelix", cubehelix_default2],
30346
- ["warm", warm],
30347
- ["cool", cool],
30348
- ["bugn", BuGn_default],
30349
- ["bupu", BuPu_default],
30350
- ["gnbu", GnBu_default],
30351
- ["orrd", OrRd_default],
30352
- ["pubugn", PuBuGn_default],
30353
- ["pubu", PuBu_default],
30354
- ["purd", PuRd_default],
30355
- ["rdpu", RdPu_default],
30356
- ["ylgnbu", YlGnBu_default],
30357
- ["ylgn", YlGn_default],
30358
- ["ylorbr", YlOrBr_default],
30359
- ["ylorrd", YlOrRd_default],
30360
- // cyclical
30361
- ["rainbow", rainbow_default],
30362
- ["sinebow", sinebow_default]
30363
- ]);
30364
- function quantitativeScheme(scheme28) {
30365
- const s2 = `${scheme28}`.toLowerCase();
30366
- if (!quantitativeSchemes.has(s2))
30367
- throw new Error(`unknown quantitative scheme: ${s2}`);
30368
- return quantitativeSchemes.get(s2);
30381
+ };
30382
+ var transformLog2 = {
30383
+ apply: Math.log,
30384
+ invert: Math.exp
30385
+ };
30386
+ var transformSqrt2 = {
30387
+ apply(x3) {
30388
+ return Math.sign(x3) * Math.sqrt(Math.abs(x3));
30389
+ },
30390
+ invert(x3) {
30391
+ return Math.sign(x3) * (x3 * x3);
30392
+ }
30393
+ };
30394
+ function transformPow2(exponent) {
30395
+ return exponent === 0.5 ? transformSqrt2 : {
30396
+ apply(x3) {
30397
+ return Math.sign(x3) * Math.pow(Math.abs(x3), exponent);
30398
+ },
30399
+ invert(x3) {
30400
+ return Math.sign(x3) * Math.pow(Math.abs(x3), 1 / exponent);
30401
+ }
30402
+ };
30369
30403
  }
30370
- var divergingSchemes = /* @__PURE__ */ new Set([
30371
- "brbg",
30372
- "prgn",
30373
- "piyg",
30374
- "puor",
30375
- "rdbu",
30376
- "rdgy",
30377
- "rdylbu",
30378
- "rdylgn",
30379
- "spectral",
30380
- "burd",
30381
- "buylrd"
30382
- ]);
30383
- function isDivergingScheme(scheme28) {
30384
- return scheme28 != null && divergingSchemes.has(`${scheme28}`.toLowerCase());
30404
+ function transformSymlog2(constant2) {
30405
+ return {
30406
+ apply(x3) {
30407
+ return Math.sign(x3) * Math.log1p(Math.abs(x3 / constant2));
30408
+ },
30409
+ invert(x3) {
30410
+ return Math.sign(x3) * Math.expm1(Math.abs(x3)) * constant2;
30411
+ }
30412
+ };
30385
30413
  }
30386
30414
 
30387
- // ../../node_modules/@observablehq/plot/src/scales/quantitative.js
30388
- var flip = (i) => (t) => i(1 - t);
30389
- var unit2 = [0, 1];
30390
- var interpolators = /* @__PURE__ */ new Map([
30391
- // numbers
30392
- ["number", number_default],
30393
- // color spaces
30394
- ["rgb", rgb_default],
30395
- ["hsl", hsl_default],
30396
- ["hcl", hcl_default],
30397
- ["lab", lab2]
30398
- ]);
30399
- function maybeInterpolator(interpolate) {
30400
- const i = `${interpolate}`.toLowerCase();
30401
- if (!interpolators.has(i))
30402
- throw new Error(`unknown interpolator: ${i}`);
30403
- return interpolators.get(i);
30415
+ // ../../node_modules/@observablehq/plot/src/scales/temporal.js
30416
+ function createScaleT(key, scale3, channels, options) {
30417
+ return createScaleQ(key, scale3, channels, options);
30404
30418
  }
30405
- function createScaleQ(key, scale3, channels, {
30406
- type: type2,
30407
- nice: nice3,
30408
- clamp,
30409
- zero: zero3,
30410
- domain = inferAutoDomain(key, channels),
30411
- unknown,
30412
- round: round2,
30413
- scheme: scheme28,
30414
- interval: interval2,
30415
- range: range3 = registry.get(key) === radius ? inferRadialRange(channels, domain) : registry.get(key) === length3 ? inferLengthRange(channels, domain) : registry.get(key) === opacity ? unit2 : void 0,
30416
- interpolate = registry.get(key) === color2 ? scheme28 == null && range3 !== void 0 ? rgb_default : quantitativeScheme(scheme28 !== void 0 ? scheme28 : type2 === "cyclical" ? "rainbow" : "turbo") : round2 ? round_default : number_default,
30417
- reverse: reverse3
30418
- }) {
30419
+ function createScaleTime(key, channels, options) {
30420
+ return createScaleT(key, time(), channels, options);
30421
+ }
30422
+ function createScaleUtc(key, channels, options) {
30423
+ return createScaleT(key, utcTime(), channels, options);
30424
+ }
30425
+
30426
+ // ../../node_modules/@observablehq/plot/src/scales/ordinal.js
30427
+ var ordinalImplicit = Symbol("ordinal");
30428
+ function createScaleO(key, scale3, channels, { type: type2, interval: interval2, domain, range: range3, reverse: reverse3, hint }) {
30419
30429
  interval2 = maybeRangeInterval(interval2, type2);
30420
- if (type2 === "cyclical" || type2 === "sequential")
30421
- type2 = "linear";
30422
- if (typeof interpolate !== "function")
30423
- interpolate = maybeInterpolator(interpolate);
30424
- reverse3 = !!reverse3;
30430
+ if (domain === void 0)
30431
+ domain = inferDomain2(channels, interval2, key);
30432
+ if (type2 === "categorical" || type2 === ordinalImplicit)
30433
+ type2 = "ordinal";
30434
+ if (reverse3)
30435
+ domain = reverse(domain);
30436
+ domain = scale3.domain(domain).domain();
30425
30437
  if (range3 !== void 0) {
30426
- const n = (domain = arrayify2(domain)).length;
30427
- const m = (range3 = arrayify2(range3)).length;
30428
- if (n !== m) {
30429
- if (interpolate.length === 1)
30430
- throw new Error("invalid piecewise interpolator");
30431
- interpolate = piecewise(interpolate, range3);
30432
- range3 = void 0;
30438
+ if (typeof range3 === "function")
30439
+ range3 = range3(domain);
30440
+ scale3.range(range3);
30441
+ }
30442
+ return { type: type2, domain, range: range3, scale: scale3, hint, interval: interval2 };
30443
+ }
30444
+ function createScaleOrdinal(key, channels, { type: type2, interval: interval2, domain, range: range3, scheme: scheme28, unknown, ...options }) {
30445
+ interval2 = maybeRangeInterval(interval2, type2);
30446
+ if (domain === void 0)
30447
+ domain = inferDomain2(channels, interval2, key);
30448
+ let hint;
30449
+ if (registry.get(key) === symbol) {
30450
+ hint = inferSymbolHint(channels);
30451
+ range3 = range3 === void 0 ? inferSymbolRange(hint) : map2(range3, maybeSymbol);
30452
+ } else if (registry.get(key) === color2) {
30453
+ if (range3 === void 0 && (type2 === "ordinal" || type2 === ordinalImplicit)) {
30454
+ range3 = maybeBooleanRange(domain, scheme28);
30455
+ if (range3 !== void 0)
30456
+ scheme28 = void 0;
30433
30457
  }
30434
- }
30435
- if (interpolate.length === 1) {
30436
- if (reverse3) {
30437
- interpolate = flip(interpolate);
30438
- reverse3 = false;
30458
+ if (scheme28 === void 0 && range3 === void 0) {
30459
+ scheme28 = type2 === "ordinal" ? "turbo" : "observable10";
30439
30460
  }
30440
- if (range3 === void 0) {
30441
- range3 = Float64Array.from(domain, (_, i) => i / (domain.length - 1));
30442
- if (range3.length === 2)
30443
- range3 = unit2;
30461
+ if (scheme28 !== void 0) {
30462
+ if (range3 !== void 0) {
30463
+ const interpolate = quantitativeScheme(scheme28);
30464
+ const t03 = range3[0], d = range3[1] - range3[0];
30465
+ range3 = ({ length: n }) => quantize_default((t) => interpolate(t03 + d * t), n);
30466
+ } else {
30467
+ range3 = ordinalScheme(scheme28);
30468
+ }
30444
30469
  }
30445
- scale3.interpolate((range3 === unit2 ? constant : interpolatePiecewise)(interpolate));
30446
- } else {
30447
- scale3.interpolate(interpolate);
30448
30470
  }
30449
- if (zero3) {
30450
- const [min5, max4] = extent(domain);
30451
- if (min5 > 0 || max4 < 0) {
30452
- domain = slice3(domain);
30453
- if (orderof(domain) !== Math.sign(min5))
30454
- domain[domain.length - 1] = 0;
30455
- else
30456
- domain[0] = 0;
30457
- }
30471
+ if (unknown === implicit) {
30472
+ throw new Error(`implicit unknown on ${key} scale is not supported`);
30458
30473
  }
30459
- if (reverse3)
30460
- domain = reverse(domain);
30461
- scale3.domain(domain).unknown(unknown);
30462
- if (nice3)
30463
- scale3.nice(maybeNice(nice3, type2)), domain = scale3.domain();
30464
- if (range3 !== void 0)
30465
- scale3.range(range3);
30466
- if (clamp)
30467
- scale3.clamp(clamp);
30468
- return { type: type2, domain, range: range3, scale: scale3, interpolate, interval: interval2 };
30469
- }
30470
- function maybeNice(nice3, type2) {
30471
- return nice3 === true ? void 0 : typeof nice3 === "number" ? nice3 : maybeNiceInterval(nice3, type2);
30472
- }
30473
- function createScaleLinear(key, channels, options) {
30474
- return createScaleQ(key, linear2(), channels, options);
30475
- }
30476
- function createScaleSqrt(key, channels, options) {
30477
- return createScalePow(key, channels, { ...options, exponent: 0.5 });
30474
+ return createScaleO(key, ordinal().unknown(unknown), channels, { ...options, type: type2, domain, range: range3, hint });
30478
30475
  }
30479
- function createScalePow(key, channels, { exponent = 1, ...options }) {
30480
- return createScaleQ(key, pow3().exponent(exponent), channels, { ...options, type: "pow" });
30476
+ function createScalePoint(key, channels, { align = 0.5, padding = 0.5, ...options }) {
30477
+ return maybeRound(point().align(align).padding(padding), channels, options, key);
30481
30478
  }
30482
- function createScaleLog(key, channels, { base = 10, domain = inferLogDomain(channels), ...options }) {
30483
- return createScaleQ(key, log2().base(base), channels, { ...options, domain });
30479
+ function createScaleBand(key, channels, {
30480
+ align = 0.5,
30481
+ padding = 0.1,
30482
+ paddingInner = padding,
30483
+ paddingOuter = key === "fx" || key === "fy" ? 0 : padding,
30484
+ ...options
30485
+ }) {
30486
+ return maybeRound(
30487
+ band().align(align).paddingInner(paddingInner).paddingOuter(paddingOuter),
30488
+ channels,
30489
+ options,
30490
+ key
30491
+ );
30484
30492
  }
30485
- function createScaleSymlog(key, channels, { constant: constant2 = 1, ...options }) {
30486
- return createScaleQ(key, symlog().constant(constant2), channels, options);
30493
+ function maybeRound(scale3, channels, options, key) {
30494
+ let { round: round2 } = options;
30495
+ if (round2 !== void 0)
30496
+ scale3.round(round2 = !!round2);
30497
+ scale3 = createScaleO(key, scale3, channels, options);
30498
+ scale3.round = round2;
30499
+ return scale3;
30487
30500
  }
30488
- function createScaleQuantile(key, channels, {
30489
- range: range3,
30490
- quantiles = range3 === void 0 ? 5 : (range3 = [...range3]).length,
30491
- // deprecated; use n instead
30492
- n = quantiles,
30493
- scheme: scheme28 = "rdylbu",
30494
- domain = inferQuantileDomain(channels),
30495
- unknown,
30496
- interpolate,
30497
- reverse: reverse3
30498
- }) {
30499
- if (range3 === void 0) {
30500
- range3 = interpolate !== void 0 ? quantize_default(interpolate, n) : registry.get(key) === color2 ? ordinalRange(scheme28, n) : void 0;
30501
+ function inferDomain2(channels, interval2, key) {
30502
+ const values2 = new InternSet();
30503
+ for (const { value, domain } of channels) {
30504
+ if (domain !== void 0)
30505
+ return domain();
30506
+ if (value === void 0)
30507
+ continue;
30508
+ for (const v2 of value)
30509
+ values2.add(v2);
30501
30510
  }
30502
- if (domain.length > 0) {
30503
- domain = quantile3(domain, range3 === void 0 ? { length: n } : range3).quantiles();
30511
+ if (interval2 !== void 0) {
30512
+ const [min5, max4] = extent(values2).map(interval2.floor, interval2);
30513
+ return interval2.range(min5, interval2.offset(max4));
30504
30514
  }
30505
- return createScaleThreshold(key, channels, { domain, range: range3, reverse: reverse3, unknown });
30515
+ if (values2.size > 1e4 && registry.get(key) === position) {
30516
+ throw new Error(`implicit ordinal domain of ${key} scale has more than 10,000 values`);
30517
+ }
30518
+ return sort(values2, ascendingDefined2);
30506
30519
  }
30507
- function createScaleQuantize(key, channels, {
30508
- range: range3,
30509
- n = range3 === void 0 ? 5 : (range3 = [...range3]).length,
30510
- scheme: scheme28 = "rdylbu",
30511
- domain = inferAutoDomain(key, channels),
30512
- unknown,
30513
- interpolate,
30514
- reverse: reverse3
30515
- }) {
30516
- const [min5, max4] = extent(domain);
30517
- let thresholds;
30518
- if (range3 === void 0) {
30519
- thresholds = ticks(min5, max4, n);
30520
- if (thresholds[0] <= min5)
30521
- thresholds.splice(0, 1);
30522
- if (thresholds[thresholds.length - 1] >= max4)
30523
- thresholds.pop();
30524
- n = thresholds.length + 1;
30525
- range3 = interpolate !== void 0 ? quantize_default(interpolate, n) : registry.get(key) === color2 ? ordinalRange(scheme28, n) : void 0;
30526
- } else {
30527
- thresholds = quantize_default(number_default(min5, max4), n + 1).slice(1, -1);
30528
- if (min5 instanceof Date)
30529
- thresholds = thresholds.map((x3) => new Date(x3));
30520
+ function inferHint(channels, key) {
30521
+ let value;
30522
+ for (const { hint } of channels) {
30523
+ const candidate = hint?.[key];
30524
+ if (candidate === void 0)
30525
+ continue;
30526
+ if (value === void 0)
30527
+ value = candidate;
30528
+ else if (value !== candidate)
30529
+ return;
30530
30530
  }
30531
- if (orderof(arrayify2(domain)) < 0)
30532
- thresholds.reverse();
30533
- return createScaleThreshold(key, channels, { domain: thresholds, range: range3, reverse: reverse3, unknown });
30531
+ return value;
30534
30532
  }
30535
- function createScaleThreshold(key, channels, {
30536
- domain = [0],
30537
- // explicit thresholds in ascending order
30538
- unknown,
30539
- scheme: scheme28 = "rdylbu",
30540
- interpolate,
30541
- range: range3 = interpolate !== void 0 ? quantize_default(interpolate, domain.length + 1) : registry.get(key) === color2 ? ordinalRange(scheme28, domain.length + 1) : void 0,
30542
- reverse: reverse3
30543
- }) {
30544
- domain = arrayify2(domain);
30545
- const sign3 = orderof(domain);
30546
- if (!isNaN(sign3) && !isOrdered(domain, sign3))
30547
- throw new Error(`the ${key} scale has a non-monotonic domain`);
30548
- if (reverse3)
30549
- range3 = reverse(range3);
30533
+ function inferSymbolHint(channels) {
30550
30534
  return {
30551
- type: "threshold",
30552
- scale: threshold(sign3 < 0 ? reverse(domain) : domain, range3 === void 0 ? [] : range3).unknown(unknown),
30553
- domain,
30554
- range: range3
30535
+ fill: inferHint(channels, "fill"),
30536
+ stroke: inferHint(channels, "stroke")
30555
30537
  };
30556
30538
  }
30557
- function isOrdered(domain, sign3) {
30558
- for (let i = 1, n = domain.length, d = domain[0]; i < n; ++i) {
30559
- const s2 = descending(d, d = domain[i]);
30560
- if (s2 !== 0 && s2 !== sign3)
30561
- return false;
30562
- }
30563
- return true;
30564
- }
30565
- function createScaleIdentity(key) {
30566
- return { type: "identity", scale: hasNumericRange(registry.get(key)) ? identity5() : (d) => d };
30567
- }
30568
- function inferDomain(channels, f = finite2) {
30569
- return channels.length ? [
30570
- min2(channels, ({ value }) => value === void 0 ? value : min2(value, f)),
30571
- max2(channels, ({ value }) => value === void 0 ? value : max2(value, f))
30572
- ] : [0, 1];
30573
- }
30574
- function inferAutoDomain(key, channels) {
30575
- const type2 = registry.get(key);
30576
- return (type2 === radius || type2 === opacity || type2 === length3 ? inferZeroDomain : inferDomain)(channels);
30577
- }
30578
- function inferZeroDomain(channels) {
30579
- return [0, channels.length ? max2(channels, ({ value }) => value === void 0 ? value : max2(value, finite2)) : 1];
30580
- }
30581
- function inferRadialRange(channels, domain) {
30582
- const hint = channels.find(({ radius: radius2 }) => radius2 !== void 0);
30583
- if (hint !== void 0)
30584
- return [0, hint.radius];
30585
- const h25 = quantile2(channels, 0.5, ({ value }) => value === void 0 ? NaN : quantile2(value, 0.25, positive));
30586
- const range3 = domain.map((d) => 3 * Math.sqrt(d / h25));
30587
- const k2 = 30 / max2(range3);
30588
- return k2 < 1 ? range3.map((r) => r * k2) : range3;
30589
- }
30590
- function inferLengthRange(channels, domain) {
30591
- const h50 = median2(channels, ({ value }) => value === void 0 ? NaN : median2(value, Math.abs));
30592
- const range3 = domain.map((d) => 12 * d / h50);
30593
- const k2 = 60 / max2(range3);
30594
- return k2 < 1 ? range3.map((r) => r * k2) : range3;
30539
+ function inferSymbolRange(hint) {
30540
+ return isNoneish(hint.fill) ? symbolsStroke : symbolsFill;
30595
30541
  }
30596
- function inferLogDomain(channels) {
30597
- for (const { value } of channels) {
30598
- if (value !== void 0) {
30599
- for (let v2 of value) {
30600
- if (v2 > 0)
30601
- return inferDomain(channels, positive);
30602
- if (v2 < 0)
30603
- return inferDomain(channels, negative);
30542
+
30543
+ // ../../node_modules/@observablehq/plot/src/scales.js
30544
+ function createScales(channelsByScale, {
30545
+ label: globalLabel,
30546
+ inset: globalInset = 0,
30547
+ insetTop: globalInsetTop = globalInset,
30548
+ insetRight: globalInsetRight = globalInset,
30549
+ insetBottom: globalInsetBottom = globalInset,
30550
+ insetLeft: globalInsetLeft = globalInset,
30551
+ round: round2,
30552
+ nice: nice3,
30553
+ clamp,
30554
+ zero: zero3,
30555
+ align,
30556
+ padding,
30557
+ projection: projection3,
30558
+ facet: { label: facetLabel = globalLabel } = {},
30559
+ ...options
30560
+ } = {}) {
30561
+ const scales2 = {};
30562
+ for (const [key, channels] of channelsByScale) {
30563
+ const scaleOptions = options[key];
30564
+ const scale3 = createScale(key, channels, {
30565
+ round: registry.get(key) === position ? round2 : void 0,
30566
+ // only for position
30567
+ nice: nice3,
30568
+ clamp,
30569
+ zero: zero3,
30570
+ align,
30571
+ padding,
30572
+ projection: projection3,
30573
+ ...scaleOptions
30574
+ });
30575
+ if (scale3) {
30576
+ let {
30577
+ label = key === "fx" || key === "fy" ? facetLabel : globalLabel,
30578
+ percent,
30579
+ transform: transform3,
30580
+ inset,
30581
+ insetTop = inset !== void 0 ? inset : key === "y" ? globalInsetTop : 0,
30582
+ // not fy
30583
+ insetRight = inset !== void 0 ? inset : key === "x" ? globalInsetRight : 0,
30584
+ // not fx
30585
+ insetBottom = inset !== void 0 ? inset : key === "y" ? globalInsetBottom : 0,
30586
+ // not fy
30587
+ insetLeft = inset !== void 0 ? inset : key === "x" ? globalInsetLeft : 0
30588
+ // not fx
30589
+ } = scaleOptions || {};
30590
+ if (transform3 == null)
30591
+ transform3 = void 0;
30592
+ else if (typeof transform3 !== "function")
30593
+ throw new Error("invalid scale transform; not a function");
30594
+ scale3.percent = !!percent;
30595
+ scale3.label = label === void 0 ? inferScaleLabel(channels, scale3) : label;
30596
+ scale3.transform = transform3;
30597
+ if (key === "x" || key === "fx") {
30598
+ scale3.insetLeft = +insetLeft;
30599
+ scale3.insetRight = +insetRight;
30600
+ } else if (key === "y" || key === "fy") {
30601
+ scale3.insetTop = +insetTop;
30602
+ scale3.insetBottom = +insetBottom;
30604
30603
  }
30604
+ scales2[key] = scale3;
30605
30605
  }
30606
30606
  }
30607
- return [1, 10];
30607
+ return scales2;
30608
30608
  }
30609
- function inferQuantileDomain(channels) {
30610
- const domain = [];
30611
- for (const { value } of channels) {
30612
- if (value === void 0)
30613
- continue;
30614
- for (const v2 of value)
30615
- domain.push(v2);
30609
+ function createScaleFunctions(descriptors) {
30610
+ const scales2 = {};
30611
+ const scaleFunctions = { scales: scales2 };
30612
+ for (const [key, descriptor] of Object.entries(descriptors)) {
30613
+ const { scale: scale3, type: type2, interval: interval2, label } = descriptor;
30614
+ scales2[key] = exposeScale(descriptor);
30615
+ scaleFunctions[key] = scale3;
30616
+ scale3.type = type2;
30617
+ if (interval2 != null)
30618
+ scale3.interval = interval2;
30619
+ if (label != null)
30620
+ scale3.label = label;
30616
30621
  }
30617
- return domain;
30622
+ return scaleFunctions;
30618
30623
  }
30619
- function interpolatePiecewise(interpolate) {
30620
- return (i, j) => (t) => interpolate(i + t * (j - i));
30624
+ function autoScaleRange(scales2, dimensions) {
30625
+ const { x: x3, y: y3, fx, fy } = scales2;
30626
+ const superdimensions = fx || fy ? outerDimensions(dimensions) : dimensions;
30627
+ if (fx)
30628
+ autoScaleRangeX(fx, superdimensions);
30629
+ if (fy)
30630
+ autoScaleRangeY(fy, superdimensions);
30631
+ const subdimensions = fx || fy ? innerDimensions(scales2, dimensions) : dimensions;
30632
+ if (x3)
30633
+ autoScaleRangeX(x3, subdimensions);
30634
+ if (y3)
30635
+ autoScaleRangeY(y3, subdimensions);
30621
30636
  }
30622
-
30623
- // ../../node_modules/@observablehq/plot/src/scales/diverging.js
30624
- function createScaleD(key, scale3, transform3, channels, {
30625
- type: type2,
30626
- nice: nice3,
30627
- clamp,
30628
- domain = inferDomain(channels),
30629
- unknown,
30630
- pivot = 0,
30631
- scheme: scheme28,
30632
- range: range3,
30633
- symmetric = true,
30634
- interpolate = registry.get(key) === color2 ? scheme28 == null && range3 !== void 0 ? rgb_default : quantitativeScheme(scheme28 !== void 0 ? scheme28 : "rdbu") : number_default,
30635
- reverse: reverse3
30636
- }) {
30637
- pivot = +pivot;
30638
- domain = arrayify2(domain);
30639
- let [min5, max4] = domain;
30640
- if (domain.length > 2)
30641
- warn(`Warning: the diverging ${key} scale domain contains extra elements.`);
30642
- if (descending(min5, max4) < 0)
30643
- [min5, max4] = [max4, min5], reverse3 = !reverse3;
30644
- min5 = Math.min(min5, pivot);
30645
- max4 = Math.max(max4, pivot);
30646
- if (typeof interpolate !== "function") {
30647
- interpolate = maybeInterpolator(interpolate);
30648
- }
30649
- if (range3 !== void 0) {
30650
- interpolate = interpolate.length === 1 ? interpolatePiecewise(interpolate)(...range3) : piecewise(interpolate, range3);
30651
- }
30652
- if (reverse3)
30653
- interpolate = flip(interpolate);
30654
- if (symmetric) {
30655
- const mid2 = transform3.apply(pivot);
30656
- const mindelta = mid2 - transform3.apply(min5);
30657
- const maxdelta = transform3.apply(max4) - mid2;
30658
- if (mindelta < maxdelta)
30659
- min5 = transform3.invert(mid2 - maxdelta);
30660
- else if (mindelta > maxdelta)
30661
- max4 = transform3.invert(mid2 + mindelta);
30637
+ function inferScaleLabel(channels = [], scale3) {
30638
+ let label;
30639
+ for (const { label: l } of channels) {
30640
+ if (l === void 0)
30641
+ continue;
30642
+ if (label === void 0)
30643
+ label = l;
30644
+ else if (label !== l)
30645
+ return;
30662
30646
  }
30663
- scale3.domain([min5, pivot, max4]).unknown(unknown).interpolator(interpolate);
30664
- if (clamp)
30665
- scale3.clamp(clamp);
30666
- if (nice3)
30667
- scale3.nice(nice3);
30668
- return { type: type2, domain: [min5, max4], pivot, interpolate, scale: scale3 };
30669
- }
30670
- function createScaleDiverging(key, channels, options) {
30671
- return createScaleD(key, diverging(), transformIdentity, channels, options);
30672
- }
30673
- function createScaleDivergingSqrt(key, channels, options) {
30674
- return createScaleDivergingPow(key, channels, { ...options, exponent: 0.5 });
30675
- }
30676
- function createScaleDivergingPow(key, channels, { exponent = 1, ...options }) {
30677
- return createScaleD(key, divergingPow().exponent(exponent = +exponent), transformPow2(exponent), channels, {
30678
- ...options,
30679
- type: "diverging-pow"
30680
- });
30681
- }
30682
- function createScaleDivergingLog(key, channels, { base = 10, pivot = 1, domain = inferDomain(channels, pivot < 0 ? negative : positive), ...options }) {
30683
- return createScaleD(key, divergingLog().base(base = +base), transformLog2, channels, {
30684
- domain,
30685
- pivot,
30686
- ...options
30687
- });
30647
+ if (label === void 0)
30648
+ return;
30649
+ if (!isOrdinalScale(scale3) && scale3.percent)
30650
+ label = `${label} (%)`;
30651
+ return { inferred: true, toString: () => label };
30688
30652
  }
30689
- function createScaleDivergingSymlog(key, channels, { constant: constant2 = 1, ...options }) {
30690
- return createScaleD(
30691
- key,
30692
- divergingSymlog().constant(constant2 = +constant2),
30693
- transformSymlog2(constant2),
30694
- channels,
30695
- options
30696
- );
30653
+ function inferScaleOrder(scale3) {
30654
+ return Math.sign(orderof(scale3.domain())) * Math.sign(orderof(scale3.range()));
30697
30655
  }
30698
- var transformIdentity = {
30699
- apply(x3) {
30700
- return x3;
30701
- },
30702
- invert(x3) {
30703
- return x3;
30704
- }
30705
- };
30706
- var transformLog2 = {
30707
- apply: Math.log,
30708
- invert: Math.exp
30709
- };
30710
- var transformSqrt2 = {
30711
- apply(x3) {
30712
- return Math.sign(x3) * Math.sqrt(Math.abs(x3));
30713
- },
30714
- invert(x3) {
30715
- return Math.sign(x3) * (x3 * x3);
30716
- }
30717
- };
30718
- function transformPow2(exponent) {
30719
- return exponent === 0.5 ? transformSqrt2 : {
30720
- apply(x3) {
30721
- return Math.sign(x3) * Math.pow(Math.abs(x3), exponent);
30722
- },
30723
- invert(x3) {
30724
- return Math.sign(x3) * Math.pow(Math.abs(x3), 1 / exponent);
30656
+ function outerDimensions(dimensions) {
30657
+ const {
30658
+ marginTop,
30659
+ marginRight,
30660
+ marginBottom,
30661
+ marginLeft,
30662
+ width,
30663
+ height,
30664
+ facet: {
30665
+ marginTop: facetMarginTop,
30666
+ marginRight: facetMarginRight,
30667
+ marginBottom: facetMarginBottom,
30668
+ marginLeft: facetMarginLeft
30725
30669
  }
30670
+ } = dimensions;
30671
+ return {
30672
+ marginTop: Math.max(marginTop, facetMarginTop),
30673
+ marginRight: Math.max(marginRight, facetMarginRight),
30674
+ marginBottom: Math.max(marginBottom, facetMarginBottom),
30675
+ marginLeft: Math.max(marginLeft, facetMarginLeft),
30676
+ width,
30677
+ height
30726
30678
  };
30727
30679
  }
30728
- function transformSymlog2(constant2) {
30680
+ function innerDimensions({ fx, fy }, dimensions) {
30681
+ const { marginTop, marginRight, marginBottom, marginLeft, width, height } = outerDimensions(dimensions);
30729
30682
  return {
30730
- apply(x3) {
30731
- return Math.sign(x3) * Math.log1p(Math.abs(x3 / constant2));
30732
- },
30733
- invert(x3) {
30734
- return Math.sign(x3) * Math.expm1(Math.abs(x3)) * constant2;
30735
- }
30683
+ marginTop,
30684
+ marginRight,
30685
+ marginBottom,
30686
+ marginLeft,
30687
+ width: fx ? fx.scale.bandwidth() + marginLeft + marginRight : width,
30688
+ height: fy ? fy.scale.bandwidth() + marginTop + marginBottom : height,
30689
+ facet: { width, height }
30736
30690
  };
30737
30691
  }
30738
-
30739
- // ../../node_modules/@observablehq/plot/src/scales/temporal.js
30740
- function createScaleT(key, scale3, channels, options) {
30741
- return createScaleQ(key, scale3, channels, options);
30692
+ function autoScaleRangeX(scale3, dimensions) {
30693
+ if (scale3.range === void 0) {
30694
+ const { insetLeft, insetRight } = scale3;
30695
+ const { width, marginLeft = 0, marginRight = 0 } = dimensions;
30696
+ const left2 = marginLeft + insetLeft;
30697
+ const right2 = width - marginRight - insetRight;
30698
+ scale3.range = [left2, Math.max(left2, right2)];
30699
+ if (!isOrdinalScale(scale3))
30700
+ scale3.range = piecewiseRange(scale3);
30701
+ scale3.scale.range(scale3.range);
30702
+ }
30703
+ autoScaleRound(scale3);
30704
+ }
30705
+ function autoScaleRangeY(scale3, dimensions) {
30706
+ if (scale3.range === void 0) {
30707
+ const { insetTop, insetBottom } = scale3;
30708
+ const { height, marginTop = 0, marginBottom = 0 } = dimensions;
30709
+ const top2 = marginTop + insetTop;
30710
+ const bottom2 = height - marginBottom - insetBottom;
30711
+ scale3.range = [Math.max(top2, bottom2), top2];
30712
+ if (!isOrdinalScale(scale3))
30713
+ scale3.range = piecewiseRange(scale3);
30714
+ else
30715
+ scale3.range.reverse();
30716
+ scale3.scale.range(scale3.range);
30717
+ }
30718
+ autoScaleRound(scale3);
30719
+ }
30720
+ function autoScaleRound(scale3) {
30721
+ if (scale3.round === void 0 && isBandScale(scale3) && roundError(scale3) <= 30) {
30722
+ scale3.scale.round(true);
30723
+ }
30724
+ }
30725
+ function roundError({ scale: scale3 }) {
30726
+ const n = scale3.domain().length;
30727
+ const [start2, stop] = scale3.range();
30728
+ const paddingInner = scale3.paddingInner ? scale3.paddingInner() : 1;
30729
+ const paddingOuter = scale3.paddingOuter ? scale3.paddingOuter() : scale3.padding();
30730
+ const m = n - paddingInner;
30731
+ const step = Math.abs(stop - start2) / Math.max(1, m + paddingOuter * 2);
30732
+ return (step - Math.floor(step)) * m;
30742
30733
  }
30743
- function createScaleTime(key, channels, options) {
30744
- return createScaleT(key, time(), channels, options);
30734
+ function piecewiseRange(scale3) {
30735
+ const length4 = scale3.scale.domain().length + isThresholdScale(scale3);
30736
+ if (!(length4 > 2))
30737
+ return scale3.range;
30738
+ const [start2, end] = scale3.range;
30739
+ return Array.from({ length: length4 }, (_, i) => start2 + i / (length4 - 1) * (end - start2));
30745
30740
  }
30746
- function createScaleUtc(key, channels, options) {
30747
- return createScaleT(key, utcTime(), channels, options);
30741
+ function normalizeScale(key, scale3, hint) {
30742
+ return createScale(key, hint === void 0 ? void 0 : [{ hint }], { ...scale3 });
30748
30743
  }
30749
-
30750
- // ../../node_modules/@observablehq/plot/src/scales/ordinal.js
30751
- var ordinalImplicit = Symbol("ordinal");
30752
- function createScaleO(key, scale3, channels, { type: type2, interval: interval2, domain, range: range3, reverse: reverse3, hint }) {
30753
- interval2 = maybeRangeInterval(interval2, type2);
30754
- if (domain === void 0)
30755
- domain = inferDomain2(channels, interval2, key);
30756
- if (type2 === "categorical" || type2 === ordinalImplicit)
30757
- type2 = "ordinal";
30758
- if (reverse3)
30759
- domain = reverse(domain);
30760
- domain = scale3.domain(domain).domain();
30761
- if (range3 !== void 0) {
30762
- if (typeof range3 === "function")
30763
- range3 = range3(domain);
30764
- scale3.range(range3);
30744
+ function createScale(key, channels = [], options = {}) {
30745
+ const type2 = inferScaleType(key, channels, options);
30746
+ if (options.type === void 0 && options.domain === void 0 && options.range === void 0 && options.interval == null && key !== "fx" && key !== "fy" && isOrdinalScale({ type: type2 })) {
30747
+ const values2 = channels.map(({ value }) => value).filter((value) => value !== void 0);
30748
+ if (values2.some(isTemporal))
30749
+ warn(
30750
+ `Warning: some data associated with the ${key} scale are dates. Dates are typically associated with a "utc" or "time" scale rather than a "${formatScaleType(
30751
+ type2
30752
+ )}" scale. If you are using a bar mark, you probably want a rect mark with the interval option instead; if you are using a group transform, you probably want a bin transform instead. If you want to treat this data as ordinal, you can specify the interval of the ${key} scale (e.g., d3.utcDay), or you can suppress this warning by setting the type of the ${key} scale to "${formatScaleType(
30753
+ type2
30754
+ )}".`
30755
+ );
30756
+ else if (values2.some(isTemporalString))
30757
+ warn(
30758
+ `Warning: some data associated with the ${key} scale are strings that appear to be dates (e.g., YYYY-MM-DD). If these strings represent dates, you should parse them to Date objects. Dates are typically associated with a "utc" or "time" scale rather than a "${formatScaleType(
30759
+ type2
30760
+ )}" scale. If you are using a bar mark, you probably want a rect mark with the interval option instead; if you are using a group transform, you probably want a bin transform instead. If you want to treat this data as ordinal, you can suppress this warning by setting the type of the ${key} scale to "${formatScaleType(
30761
+ type2
30762
+ )}".`
30763
+ );
30764
+ else if (values2.some(isNumericString))
30765
+ warn(
30766
+ `Warning: some data associated with the ${key} scale are strings that appear to be numbers. If these strings represent numbers, you should parse or coerce them to numbers. Numbers are typically associated with a "linear" scale rather than a "${formatScaleType(
30767
+ type2
30768
+ )}" scale. If you want to treat this data as ordinal, you can specify the interval of the ${key} scale (e.g., 1 for integers), or you can suppress this warning by setting the type of the ${key} scale to "${formatScaleType(
30769
+ type2
30770
+ )}".`
30771
+ );
30765
30772
  }
30766
- return { type: type2, domain, range: range3, scale: scale3, hint, interval: interval2 };
30767
- }
30768
- function createScaleOrdinal(key, channels, { type: type2, interval: interval2, domain, range: range3, scheme: scheme28, unknown, ...options }) {
30769
- interval2 = maybeRangeInterval(interval2, type2);
30770
- if (domain === void 0)
30771
- domain = inferDomain2(channels, interval2, key);
30772
- let hint;
30773
- if (registry.get(key) === symbol) {
30774
- hint = inferSymbolHint(channels);
30775
- range3 = range3 === void 0 ? inferSymbolRange(hint) : map2(range3, maybeSymbol);
30776
- } else if (registry.get(key) === color2) {
30777
- if (range3 === void 0 && (type2 === "ordinal" || type2 === ordinalImplicit)) {
30778
- range3 = maybeBooleanRange(domain, scheme28);
30779
- if (range3 !== void 0)
30780
- scheme28 = void 0;
30781
- }
30782
- if (scheme28 === void 0 && range3 === void 0) {
30783
- scheme28 = type2 === "ordinal" ? "turbo" : "observable10";
30784
- }
30785
- if (scheme28 !== void 0) {
30786
- if (range3 !== void 0) {
30787
- const interpolate = quantitativeScheme(scheme28);
30788
- const t03 = range3[0], d = range3[1] - range3[0];
30789
- range3 = ({ length: n }) => quantize_default((t) => interpolate(t03 + d * t), n);
30790
- } else {
30791
- range3 = ordinalScheme(scheme28);
30773
+ options.type = type2;
30774
+ switch (type2) {
30775
+ case "diverging":
30776
+ case "diverging-sqrt":
30777
+ case "diverging-pow":
30778
+ case "diverging-log":
30779
+ case "diverging-symlog":
30780
+ case "cyclical":
30781
+ case "sequential":
30782
+ case "linear":
30783
+ case "sqrt":
30784
+ case "threshold":
30785
+ case "quantile":
30786
+ case "pow":
30787
+ case "log":
30788
+ case "symlog":
30789
+ options = coerceType(channels, options, coerceNumbers);
30790
+ break;
30791
+ case "identity":
30792
+ switch (registry.get(key)) {
30793
+ case position:
30794
+ options = coerceType(channels, options, coerceNumbers);
30795
+ break;
30796
+ case symbol:
30797
+ options = coerceType(channels, options, coerceSymbols);
30798
+ break;
30792
30799
  }
30793
- }
30800
+ break;
30801
+ case "utc":
30802
+ case "time":
30803
+ options = coerceType(channels, options, coerceDates);
30804
+ break;
30794
30805
  }
30795
- if (unknown === implicit) {
30796
- throw new Error(`implicit unknown on ${key} scale is not supported`);
30806
+ switch (type2) {
30807
+ case "diverging":
30808
+ return createScaleDiverging(key, channels, options);
30809
+ case "diverging-sqrt":
30810
+ return createScaleDivergingSqrt(key, channels, options);
30811
+ case "diverging-pow":
30812
+ return createScaleDivergingPow(key, channels, options);
30813
+ case "diverging-log":
30814
+ return createScaleDivergingLog(key, channels, options);
30815
+ case "diverging-symlog":
30816
+ return createScaleDivergingSymlog(key, channels, options);
30817
+ case "categorical":
30818
+ case "ordinal":
30819
+ case ordinalImplicit:
30820
+ return createScaleOrdinal(key, channels, options);
30821
+ case "cyclical":
30822
+ case "sequential":
30823
+ case "linear":
30824
+ return createScaleLinear(key, channels, options);
30825
+ case "sqrt":
30826
+ return createScaleSqrt(key, channels, options);
30827
+ case "threshold":
30828
+ return createScaleThreshold(key, channels, options);
30829
+ case "quantile":
30830
+ return createScaleQuantile(key, channels, options);
30831
+ case "quantize":
30832
+ return createScaleQuantize(key, channels, options);
30833
+ case "pow":
30834
+ return createScalePow(key, channels, options);
30835
+ case "log":
30836
+ return createScaleLog(key, channels, options);
30837
+ case "symlog":
30838
+ return createScaleSymlog(key, channels, options);
30839
+ case "utc":
30840
+ return createScaleUtc(key, channels, options);
30841
+ case "time":
30842
+ return createScaleTime(key, channels, options);
30843
+ case "point":
30844
+ return createScalePoint(key, channels, options);
30845
+ case "band":
30846
+ return createScaleBand(key, channels, options);
30847
+ case "identity":
30848
+ return createScaleIdentity(key);
30849
+ case void 0:
30850
+ return;
30851
+ default:
30852
+ throw new Error(`unknown scale type: ${type2}`);
30797
30853
  }
30798
- return createScaleO(key, ordinal().unknown(unknown), channels, { ...options, type: type2, domain, range: range3, hint });
30799
- }
30800
- function createScalePoint(key, channels, { align = 0.5, padding = 0.5, ...options }) {
30801
- return maybeRound(point().align(align).padding(padding), channels, options, key);
30802
30854
  }
30803
- function createScaleBand(key, channels, {
30804
- align = 0.5,
30805
- padding = 0.1,
30806
- paddingInner = padding,
30807
- paddingOuter = key === "fx" || key === "fy" ? 0 : padding,
30808
- ...options
30809
- }) {
30810
- return maybeRound(
30811
- band().align(align).paddingInner(paddingInner).paddingOuter(paddingOuter),
30812
- channels,
30813
- options,
30814
- key
30815
- );
30855
+ function formatScaleType(type2) {
30856
+ return typeof type2 === "symbol" ? type2.description : type2;
30816
30857
  }
30817
- function maybeRound(scale3, channels, options, key) {
30818
- let { round: round2 } = options;
30819
- if (round2 !== void 0)
30820
- scale3.round(round2 = !!round2);
30821
- scale3 = createScaleO(key, scale3, channels, options);
30822
- scale3.round = round2;
30823
- return scale3;
30858
+ function maybeScaleType(type2) {
30859
+ return typeof type2 === "string" ? `${type2}`.toLowerCase() : type2;
30824
30860
  }
30825
- function inferDomain2(channels, interval2, key) {
30826
- const values2 = new InternSet();
30827
- for (const { value, domain } of channels) {
30828
- if (domain !== void 0)
30829
- return domain();
30830
- if (value === void 0)
30861
+ var typeProjection = { toString: () => "projection" };
30862
+ function inferScaleType(key, channels, { type: type2, domain, range: range3, scheme: scheme28, pivot, projection: projection3 }) {
30863
+ type2 = maybeScaleType(type2);
30864
+ if (key === "fx" || key === "fy")
30865
+ return "band";
30866
+ if ((key === "x" || key === "y") && projection3 != null)
30867
+ type2 = typeProjection;
30868
+ for (const channel of channels) {
30869
+ const t = maybeScaleType(channel.type);
30870
+ if (t === void 0)
30831
30871
  continue;
30832
- for (const v2 of value)
30833
- values2.add(v2);
30872
+ else if (type2 === void 0)
30873
+ type2 = t;
30874
+ else if (type2 !== t)
30875
+ throw new Error(`scale incompatible with channel: ${type2} !== ${t}`);
30876
+ }
30877
+ if (type2 === typeProjection)
30878
+ return;
30879
+ if (type2 !== void 0)
30880
+ return type2;
30881
+ if (domain === void 0 && !channels.some(({ value }) => value !== void 0))
30882
+ return;
30883
+ const kind = registry.get(key);
30884
+ if (kind === radius)
30885
+ return "sqrt";
30886
+ if (kind === opacity || kind === length3)
30887
+ return "linear";
30888
+ if (kind === symbol)
30889
+ return "ordinal";
30890
+ if ((domain || range3 || []).length > 2)
30891
+ return asOrdinalType(kind);
30892
+ if (domain !== void 0) {
30893
+ if (isOrdinal(domain))
30894
+ return asOrdinalType(kind);
30895
+ if (isTemporal(domain))
30896
+ return "utc";
30897
+ } else {
30898
+ const values2 = channels.map(({ value }) => value).filter((value) => value !== void 0);
30899
+ if (values2.some(isOrdinal))
30900
+ return asOrdinalType(kind);
30901
+ if (values2.some(isTemporal))
30902
+ return "utc";
30903
+ }
30904
+ if (kind === color2) {
30905
+ if (pivot != null || isDivergingScheme(scheme28))
30906
+ return "diverging";
30907
+ if (isCategoricalScheme(scheme28))
30908
+ return "categorical";
30909
+ }
30910
+ return "linear";
30911
+ }
30912
+ function asOrdinalType(kind) {
30913
+ switch (kind) {
30914
+ case position:
30915
+ return "point";
30916
+ case color2:
30917
+ return ordinalImplicit;
30918
+ default:
30919
+ return "ordinal";
30834
30920
  }
30835
- if (interval2 !== void 0) {
30836
- const [min5, max4] = extent(values2).map(interval2.floor, interval2);
30837
- return interval2.range(min5, interval2.offset(max4));
30921
+ }
30922
+ function isOrdinalScale({ type: type2 }) {
30923
+ return type2 === "ordinal" || type2 === "point" || type2 === "band" || type2 === ordinalImplicit;
30924
+ }
30925
+ function isThresholdScale({ type: type2 }) {
30926
+ return type2 === "threshold";
30927
+ }
30928
+ function isBandScale({ type: type2 }) {
30929
+ return type2 === "point" || type2 === "band";
30930
+ }
30931
+ function isCollapsed(scale3) {
30932
+ if (scale3 === void 0)
30933
+ return true;
30934
+ const domain = scale3.domain();
30935
+ const value = scale3(domain[0]);
30936
+ for (let i = 1, n = domain.length; i < n; ++i) {
30937
+ if (scale3(domain[i]) - value) {
30938
+ return false;
30939
+ }
30838
30940
  }
30839
- if (values2.size > 1e4 && registry.get(key) === position) {
30840
- throw new Error(`implicit ordinal domain of ${key} scale has more than 10,000 values`);
30941
+ return true;
30942
+ }
30943
+ function coerceType(channels, { domain, ...options }, coerceValues) {
30944
+ for (const c4 of channels) {
30945
+ if (c4.value !== void 0) {
30946
+ if (domain === void 0)
30947
+ domain = c4.value?.domain;
30948
+ c4.value = coerceValues(c4.value);
30949
+ }
30841
30950
  }
30842
- return sort(values2, ascendingDefined2);
30951
+ return {
30952
+ domain: domain === void 0 ? domain : coerceValues(domain),
30953
+ ...options
30954
+ };
30843
30955
  }
30844
- function inferHint(channels, key) {
30845
- let value;
30846
- for (const { hint } of channels) {
30847
- const candidate = hint?.[key];
30848
- if (candidate === void 0)
30956
+ function coerceSymbols(values2) {
30957
+ return map2(values2, maybeSymbol);
30958
+ }
30959
+ function scale2(options = {}) {
30960
+ let scale3;
30961
+ for (const key in options) {
30962
+ if (!registry.has(key))
30849
30963
  continue;
30850
- if (value === void 0)
30851
- value = candidate;
30852
- else if (value !== candidate)
30853
- return;
30964
+ if (!isScaleOptions(options[key]))
30965
+ continue;
30966
+ if (scale3 !== void 0)
30967
+ throw new Error("ambiguous scale definition; multiple scales found");
30968
+ scale3 = exposeScale(normalizeScale(key, options[key]));
30854
30969
  }
30855
- return value;
30970
+ if (scale3 === void 0)
30971
+ throw new Error("invalid scale definition; no scale found");
30972
+ return scale3;
30856
30973
  }
30857
- function inferSymbolHint(channels) {
30858
- return {
30859
- fill: inferHint(channels, "fill"),
30860
- stroke: inferHint(channels, "stroke")
30974
+ function exposeScales(scales2) {
30975
+ return (key) => {
30976
+ if (!registry.has(key = `${key}`))
30977
+ throw new Error(`unknown scale: ${key}`);
30978
+ return scales2[key];
30861
30979
  };
30862
30980
  }
30863
- function inferSymbolRange(hint) {
30864
- return isNoneish(hint.fill) ? symbolsStroke : symbolsFill;
30981
+ function exposeScale({ scale: scale3, type: type2, domain, range: range3, interpolate, interval: interval2, transform: transform3, percent, pivot }) {
30982
+ if (type2 === "identity")
30983
+ return { type: "identity", apply: (d) => d, invert: (d) => d };
30984
+ const unknown = scale3.unknown ? scale3.unknown() : void 0;
30985
+ return {
30986
+ type: type2,
30987
+ domain: slice3(domain),
30988
+ // defensive copy
30989
+ ...range3 !== void 0 && { range: slice3(range3) },
30990
+ // defensive copy
30991
+ ...transform3 !== void 0 && { transform: transform3 },
30992
+ ...percent && { percent },
30993
+ // only exposed if truthy
30994
+ ...unknown !== void 0 && { unknown },
30995
+ ...interval2 !== void 0 && { interval: interval2 },
30996
+ // quantitative
30997
+ ...interpolate !== void 0 && { interpolate },
30998
+ ...scale3.clamp && { clamp: scale3.clamp() },
30999
+ // diverging (always asymmetric; we never want to apply the symmetric transform twice)
31000
+ ...pivot !== void 0 && { pivot, symmetric: false },
31001
+ // log, diverging-log
31002
+ ...scale3.base && { base: scale3.base() },
31003
+ // pow, diverging-pow
31004
+ ...scale3.exponent && { exponent: scale3.exponent() },
31005
+ // symlog, diverging-symlog
31006
+ ...scale3.constant && { constant: scale3.constant() },
31007
+ // band, point
31008
+ ...scale3.align && { align: scale3.align(), round: scale3.round() },
31009
+ ...scale3.padding && (scale3.paddingInner ? { paddingInner: scale3.paddingInner(), paddingOuter: scale3.paddingOuter() } : { padding: scale3.padding() }),
31010
+ ...scale3.bandwidth && { bandwidth: scale3.bandwidth(), step: scale3.step() },
31011
+ // utilities
31012
+ apply: (t) => scale3(t),
31013
+ ...scale3.invert && { invert: (t) => scale3.invert(t) }
31014
+ };
30865
31015
  }
30866
31016
 
30867
- // ../../node_modules/@observablehq/plot/src/scales.js
30868
- function createScales(channelsByScale, {
30869
- label: globalLabel,
30870
- inset: globalInset = 0,
30871
- insetTop: globalInsetTop = globalInset,
30872
- insetRight: globalInsetRight = globalInset,
30873
- insetBottom: globalInsetBottom = globalInset,
30874
- insetLeft: globalInsetLeft = globalInset,
30875
- round: round2,
30876
- nice: nice3,
30877
- clamp,
30878
- zero: zero3,
30879
- align,
30880
- padding,
30881
- projection: projection3,
30882
- facet: { label: facetLabel = globalLabel } = {},
30883
- ...options
30884
- } = {}) {
30885
- const scales2 = {};
30886
- for (const [key, channels] of channelsByScale) {
30887
- const scaleOptions = options[key];
30888
- const scale3 = createScale(key, channels, {
30889
- round: registry.get(key) === position ? round2 : void 0,
30890
- // only for position
30891
- nice: nice3,
30892
- clamp,
30893
- zero: zero3,
30894
- align,
30895
- padding,
30896
- projection: projection3,
30897
- ...scaleOptions
30898
- });
30899
- if (scale3) {
30900
- let {
30901
- label = key === "fx" || key === "fy" ? facetLabel : globalLabel,
30902
- percent,
30903
- transform: transform3,
30904
- inset,
30905
- insetTop = inset !== void 0 ? inset : key === "y" ? globalInsetTop : 0,
30906
- // not fy
30907
- insetRight = inset !== void 0 ? inset : key === "x" ? globalInsetRight : 0,
30908
- // not fx
30909
- insetBottom = inset !== void 0 ? inset : key === "y" ? globalInsetBottom : 0,
30910
- // not fy
30911
- insetLeft = inset !== void 0 ? inset : key === "x" ? globalInsetLeft : 0
30912
- // not fx
30913
- } = scaleOptions || {};
30914
- if (transform3 == null)
30915
- transform3 = void 0;
30916
- else if (typeof transform3 !== "function")
30917
- throw new Error("invalid scale transform; not a function");
30918
- scale3.percent = !!percent;
30919
- scale3.label = label === void 0 ? inferScaleLabel(channels, scale3) : label;
30920
- scale3.transform = transform3;
30921
- if (key === "x" || key === "fx") {
30922
- scale3.insetLeft = +insetLeft;
30923
- scale3.insetRight = +insetRight;
30924
- } else if (key === "y" || key === "fy") {
30925
- scale3.insetTop = +insetTop;
30926
- scale3.insetBottom = +insetBottom;
30927
- }
30928
- scales2[key] = scale3;
31017
+ // ../../node_modules/@observablehq/plot/src/memoize.js
31018
+ function memoize1(compute) {
31019
+ let cacheValue, cacheKeys;
31020
+ return (...keys) => {
31021
+ if (cacheKeys?.length !== keys.length || cacheKeys.some((k2, i) => k2 !== keys[i])) {
31022
+ cacheKeys = keys;
31023
+ cacheValue = compute(...keys);
30929
31024
  }
31025
+ return cacheValue;
31026
+ };
31027
+ }
31028
+
31029
+ // ../../node_modules/@observablehq/plot/src/format.js
31030
+ var numberFormat = memoize1((locale3) => {
31031
+ return new Intl.NumberFormat(locale3);
31032
+ });
31033
+ var monthFormat = memoize1((locale3, month) => {
31034
+ return new Intl.DateTimeFormat(locale3, { timeZone: "UTC", ...month && { month } });
31035
+ });
31036
+ var weekdayFormat = memoize1((locale3, weekday) => {
31037
+ return new Intl.DateTimeFormat(locale3, { timeZone: "UTC", ...weekday && { weekday } });
31038
+ });
31039
+ function formatNumber(locale3 = "en-US") {
31040
+ const format3 = numberFormat(locale3);
31041
+ return (i) => i != null && !isNaN(i) ? format3.format(i) : void 0;
31042
+ }
31043
+ function formatMonth(locale3 = "en-US", format3 = "short") {
31044
+ const fmt = monthFormat(locale3, format3);
31045
+ return (i) => i != null && !isNaN(i = +new Date(Date.UTC(2e3, +i))) ? fmt.format(i) : void 0;
31046
+ }
31047
+ function formatWeekday(locale3 = "en-US", format3 = "short") {
31048
+ const fmt = weekdayFormat(locale3, format3);
31049
+ return (i) => i != null && !isNaN(i = +new Date(Date.UTC(2001, 0, +i))) ? fmt.format(i) : void 0;
31050
+ }
31051
+ function formatIsoDate(date2) {
31052
+ return format2(date2, "Invalid Date");
31053
+ }
31054
+ function formatAuto(locale3 = "en-US") {
31055
+ const number7 = formatNumber(locale3);
31056
+ return (v2) => (v2 instanceof Date ? formatIsoDate : typeof v2 === "number" ? number7 : string)(v2);
31057
+ }
31058
+ var formatDefault = formatAuto();
31059
+
31060
+ // ../../node_modules/@observablehq/plot/src/style.js
31061
+ var offset = (typeof window !== "undefined" ? window.devicePixelRatio > 1 : typeof it === "undefined") ? 0 : 0.5;
31062
+ var nextClipId = 0;
31063
+ function getClipId() {
31064
+ return `plot-clip-${++nextClipId}`;
31065
+ }
31066
+ function styles(mark, {
31067
+ title,
31068
+ href,
31069
+ ariaLabel: variaLabel,
31070
+ ariaDescription,
31071
+ ariaHidden,
31072
+ target,
31073
+ fill,
31074
+ fillOpacity,
31075
+ stroke,
31076
+ strokeWidth,
31077
+ strokeOpacity,
31078
+ strokeLinejoin,
31079
+ strokeLinecap,
31080
+ strokeMiterlimit,
31081
+ strokeDasharray,
31082
+ strokeDashoffset,
31083
+ opacity: opacity2,
31084
+ mixBlendMode,
31085
+ imageFilter,
31086
+ paintOrder,
31087
+ pointerEvents,
31088
+ shapeRendering,
31089
+ channels
31090
+ }, {
31091
+ ariaLabel: cariaLabel,
31092
+ fill: defaultFill = "currentColor",
31093
+ fillOpacity: defaultFillOpacity,
31094
+ stroke: defaultStroke = "none",
31095
+ strokeOpacity: defaultStrokeOpacity,
31096
+ strokeWidth: defaultStrokeWidth,
31097
+ strokeLinecap: defaultStrokeLinecap,
31098
+ strokeLinejoin: defaultStrokeLinejoin,
31099
+ strokeMiterlimit: defaultStrokeMiterlimit,
31100
+ paintOrder: defaultPaintOrder
31101
+ }) {
31102
+ if (defaultFill === null) {
31103
+ fill = null;
31104
+ fillOpacity = null;
30930
31105
  }
30931
- return scales2;
30932
- }
30933
- function createScaleFunctions(descriptors) {
30934
- const scales2 = {};
30935
- const scaleFunctions = { scales: scales2 };
30936
- for (const [key, descriptor] of Object.entries(descriptors)) {
30937
- const { scale: scale3, type: type2, interval: interval2, label } = descriptor;
30938
- scales2[key] = exposeScale(descriptor);
30939
- scaleFunctions[key] = scale3;
30940
- scale3.type = type2;
30941
- if (interval2 != null)
30942
- scale3.interval = interval2;
30943
- if (label != null)
30944
- scale3.label = label;
31106
+ if (defaultStroke === null) {
31107
+ stroke = null;
31108
+ strokeOpacity = null;
30945
31109
  }
30946
- return scaleFunctions;
30947
- }
30948
- function autoScaleRange(scales2, dimensions) {
30949
- const { x: x3, y: y3, fx, fy } = scales2;
30950
- const superdimensions = fx || fy ? outerDimensions(dimensions) : dimensions;
30951
- if (fx)
30952
- autoScaleRangeX(fx, superdimensions);
30953
- if (fy)
30954
- autoScaleRangeY(fy, superdimensions);
30955
- const subdimensions = fx || fy ? innerDimensions(scales2, dimensions) : dimensions;
30956
- if (x3)
30957
- autoScaleRangeX(x3, subdimensions);
30958
- if (y3)
30959
- autoScaleRangeY(y3, subdimensions);
30960
- }
30961
- function inferScaleLabel(channels = [], scale3) {
30962
- let label;
30963
- for (const { label: l } of channels) {
30964
- if (l === void 0)
30965
- continue;
30966
- if (label === void 0)
30967
- label = l;
30968
- else if (label !== l)
30969
- return;
31110
+ if (isNoneish(defaultFill)) {
31111
+ if (!isNoneish(defaultStroke) && (!isNoneish(fill) || channels?.fill))
31112
+ defaultStroke = "none";
31113
+ } else {
31114
+ if (isNoneish(defaultStroke) && (!isNoneish(stroke) || channels?.stroke))
31115
+ defaultFill = "none";
30970
31116
  }
30971
- if (label === void 0)
30972
- return;
30973
- if (!isOrdinalScale(scale3) && scale3.percent)
30974
- label = `${label} (%)`;
30975
- return { inferred: true, toString: () => label };
30976
- }
30977
- function inferScaleOrder(scale3) {
30978
- return Math.sign(orderof(scale3.domain())) * Math.sign(orderof(scale3.range()));
30979
- }
30980
- function outerDimensions(dimensions) {
30981
- const {
30982
- marginTop,
30983
- marginRight,
30984
- marginBottom,
30985
- marginLeft,
30986
- width,
30987
- height,
30988
- facet: {
30989
- marginTop: facetMarginTop,
30990
- marginRight: facetMarginRight,
30991
- marginBottom: facetMarginBottom,
30992
- marginLeft: facetMarginLeft
30993
- }
30994
- } = dimensions;
31117
+ const [vfill, cfill] = maybeColorChannel(fill, defaultFill);
31118
+ const [vfillOpacity, cfillOpacity] = maybeNumberChannel(fillOpacity, defaultFillOpacity);
31119
+ const [vstroke, cstroke] = maybeColorChannel(stroke, defaultStroke);
31120
+ const [vstrokeOpacity, cstrokeOpacity] = maybeNumberChannel(strokeOpacity, defaultStrokeOpacity);
31121
+ const [vopacity, copacity] = maybeNumberChannel(opacity2);
31122
+ if (!isNone(cstroke)) {
31123
+ if (strokeWidth === void 0)
31124
+ strokeWidth = defaultStrokeWidth;
31125
+ if (strokeLinecap === void 0)
31126
+ strokeLinecap = defaultStrokeLinecap;
31127
+ if (strokeLinejoin === void 0)
31128
+ strokeLinejoin = defaultStrokeLinejoin;
31129
+ if (strokeMiterlimit === void 0 && !isRound(strokeLinejoin))
31130
+ strokeMiterlimit = defaultStrokeMiterlimit;
31131
+ if (!isNone(cfill) && paintOrder === void 0)
31132
+ paintOrder = defaultPaintOrder;
31133
+ }
31134
+ const [vstrokeWidth, cstrokeWidth] = maybeNumberChannel(strokeWidth);
31135
+ if (defaultFill !== null) {
31136
+ mark.fill = impliedString(cfill, "currentColor");
31137
+ mark.fillOpacity = impliedNumber(cfillOpacity, 1);
31138
+ }
31139
+ if (defaultStroke !== null) {
31140
+ mark.stroke = impliedString(cstroke, "none");
31141
+ mark.strokeWidth = impliedNumber(cstrokeWidth, 1);
31142
+ mark.strokeOpacity = impliedNumber(cstrokeOpacity, 1);
31143
+ mark.strokeLinejoin = impliedString(strokeLinejoin, "miter");
31144
+ mark.strokeLinecap = impliedString(strokeLinecap, "butt");
31145
+ mark.strokeMiterlimit = impliedNumber(strokeMiterlimit, 4);
31146
+ mark.strokeDasharray = impliedString(strokeDasharray, "none");
31147
+ mark.strokeDashoffset = impliedString(strokeDashoffset, "0");
31148
+ }
31149
+ mark.target = string(target);
31150
+ mark.ariaLabel = string(cariaLabel);
31151
+ mark.ariaDescription = string(ariaDescription);
31152
+ mark.ariaHidden = string(ariaHidden);
31153
+ mark.opacity = impliedNumber(copacity, 1);
31154
+ mark.mixBlendMode = impliedString(mixBlendMode, "normal");
31155
+ mark.imageFilter = impliedString(imageFilter, "none");
31156
+ mark.paintOrder = impliedString(paintOrder, "normal");
31157
+ mark.pointerEvents = impliedString(pointerEvents, "auto");
31158
+ mark.shapeRendering = impliedString(shapeRendering, "auto");
30995
31159
  return {
30996
- marginTop: Math.max(marginTop, facetMarginTop),
30997
- marginRight: Math.max(marginRight, facetMarginRight),
30998
- marginBottom: Math.max(marginBottom, facetMarginBottom),
30999
- marginLeft: Math.max(marginLeft, facetMarginLeft),
31000
- width,
31001
- height
31160
+ title: { value: title, optional: true, filter: null },
31161
+ href: { value: href, optional: true, filter: null },
31162
+ ariaLabel: { value: variaLabel, optional: true, filter: null },
31163
+ fill: { value: vfill, scale: "auto", optional: true },
31164
+ fillOpacity: { value: vfillOpacity, scale: "auto", optional: true },
31165
+ stroke: { value: vstroke, scale: "auto", optional: true },
31166
+ strokeOpacity: { value: vstrokeOpacity, scale: "auto", optional: true },
31167
+ strokeWidth: { value: vstrokeWidth, optional: true },
31168
+ opacity: { value: vopacity, scale: "auto", optional: true }
31002
31169
  };
31003
31170
  }
31004
- function innerDimensions({ fx, fy }, dimensions) {
31005
- const { marginTop, marginRight, marginBottom, marginLeft, width, height } = outerDimensions(dimensions);
31006
- return {
31007
- marginTop,
31008
- marginRight,
31009
- marginBottom,
31010
- marginLeft,
31011
- width: fx ? fx.scale.bandwidth() + marginLeft + marginRight : width,
31012
- height: fy ? fy.scale.bandwidth() + marginTop + marginBottom : height,
31013
- facet: { width, height }
31014
- };
31171
+ function applyTitle(selection2, L) {
31172
+ if (L)
31173
+ selection2.filter((i) => nonempty(L[i])).append("title").call(applyText, L);
31015
31174
  }
31016
- function autoScaleRangeX(scale3, dimensions) {
31017
- if (scale3.range === void 0) {
31018
- const { insetLeft, insetRight } = scale3;
31019
- const { width, marginLeft = 0, marginRight = 0 } = dimensions;
31020
- const left2 = marginLeft + insetLeft;
31021
- const right2 = width - marginRight - insetRight;
31022
- scale3.range = [left2, Math.max(left2, right2)];
31023
- if (!isOrdinalScale(scale3))
31024
- scale3.range = piecewiseRange(scale3);
31025
- scale3.scale.range(scale3.range);
31026
- }
31027
- autoScaleRound(scale3);
31175
+ function applyTitleGroup(selection2, L) {
31176
+ if (L)
31177
+ selection2.filter(([i]) => nonempty(L[i])).append("title").call(applyTextGroup, L);
31028
31178
  }
31029
- function autoScaleRangeY(scale3, dimensions) {
31030
- if (scale3.range === void 0) {
31031
- const { insetTop, insetBottom } = scale3;
31032
- const { height, marginTop = 0, marginBottom = 0 } = dimensions;
31033
- const top2 = marginTop + insetTop;
31034
- const bottom2 = height - marginBottom - insetBottom;
31035
- scale3.range = [Math.max(top2, bottom2), top2];
31036
- if (!isOrdinalScale(scale3))
31037
- scale3.range = piecewiseRange(scale3);
31038
- else
31039
- scale3.range.reverse();
31040
- scale3.scale.range(scale3.range);
31041
- }
31042
- autoScaleRound(scale3);
31179
+ function applyText(selection2, T) {
31180
+ if (T)
31181
+ selection2.text((i) => formatDefault(T[i]));
31043
31182
  }
31044
- function autoScaleRound(scale3) {
31045
- if (scale3.round === void 0 && isBandScale(scale3) && roundError(scale3) <= 30) {
31046
- scale3.scale.round(true);
31047
- }
31183
+ function applyTextGroup(selection2, T) {
31184
+ if (T)
31185
+ selection2.text(([i]) => formatDefault(T[i]));
31048
31186
  }
31049
- function roundError({ scale: scale3 }) {
31050
- const n = scale3.domain().length;
31051
- const [start2, stop] = scale3.range();
31052
- const paddingInner = scale3.paddingInner ? scale3.paddingInner() : 1;
31053
- const paddingOuter = scale3.paddingOuter ? scale3.paddingOuter() : scale3.padding();
31054
- const m = n - paddingInner;
31055
- const step = Math.abs(stop - start2) / Math.max(1, m + paddingOuter * 2);
31056
- return (step - Math.floor(step)) * m;
31187
+ function applyChannelStyles(selection2, { target, tip: tip2 }, {
31188
+ ariaLabel: AL,
31189
+ title: T,
31190
+ fill: F,
31191
+ fillOpacity: FO,
31192
+ stroke: S,
31193
+ strokeOpacity: SO,
31194
+ strokeWidth: SW,
31195
+ opacity: O,
31196
+ href: H
31197
+ }) {
31198
+ if (AL)
31199
+ applyAttr(selection2, "aria-label", (i) => AL[i]);
31200
+ if (F)
31201
+ applyAttr(selection2, "fill", (i) => F[i]);
31202
+ if (FO)
31203
+ applyAttr(selection2, "fill-opacity", (i) => FO[i]);
31204
+ if (S)
31205
+ applyAttr(selection2, "stroke", (i) => S[i]);
31206
+ if (SO)
31207
+ applyAttr(selection2, "stroke-opacity", (i) => SO[i]);
31208
+ if (SW)
31209
+ applyAttr(selection2, "stroke-width", (i) => SW[i]);
31210
+ if (O)
31211
+ applyAttr(selection2, "opacity", (i) => O[i]);
31212
+ if (H)
31213
+ applyHref(selection2, (i) => H[i], target);
31214
+ if (!tip2)
31215
+ applyTitle(selection2, T);
31057
31216
  }
31058
- function piecewiseRange(scale3) {
31059
- const length4 = scale3.scale.domain().length + isThresholdScale(scale3);
31060
- if (!(length4 > 2))
31061
- return scale3.range;
31062
- const [start2, end] = scale3.range;
31063
- return Array.from({ length: length4 }, (_, i) => start2 + i / (length4 - 1) * (end - start2));
31217
+ function applyGroupedChannelStyles(selection2, { target, tip: tip2 }, {
31218
+ ariaLabel: AL,
31219
+ title: T,
31220
+ fill: F,
31221
+ fillOpacity: FO,
31222
+ stroke: S,
31223
+ strokeOpacity: SO,
31224
+ strokeWidth: SW,
31225
+ opacity: O,
31226
+ href: H
31227
+ }) {
31228
+ if (AL)
31229
+ applyAttr(selection2, "aria-label", ([i]) => AL[i]);
31230
+ if (F)
31231
+ applyAttr(selection2, "fill", ([i]) => F[i]);
31232
+ if (FO)
31233
+ applyAttr(selection2, "fill-opacity", ([i]) => FO[i]);
31234
+ if (S)
31235
+ applyAttr(selection2, "stroke", ([i]) => S[i]);
31236
+ if (SO)
31237
+ applyAttr(selection2, "stroke-opacity", ([i]) => SO[i]);
31238
+ if (SW)
31239
+ applyAttr(selection2, "stroke-width", ([i]) => SW[i]);
31240
+ if (O)
31241
+ applyAttr(selection2, "opacity", ([i]) => O[i]);
31242
+ if (H)
31243
+ applyHref(selection2, ([i]) => H[i], target);
31244
+ if (!tip2)
31245
+ applyTitleGroup(selection2, T);
31064
31246
  }
31065
- function normalizeScale(key, scale3, hint) {
31066
- return createScale(key, hint === void 0 ? void 0 : [{ hint }], { ...scale3 });
31247
+ function groupAesthetics({
31248
+ ariaLabel: AL,
31249
+ title: T,
31250
+ fill: F,
31251
+ fillOpacity: FO,
31252
+ stroke: S,
31253
+ strokeOpacity: SO,
31254
+ strokeWidth: SW,
31255
+ opacity: O,
31256
+ href: H
31257
+ }, { tip: tip2 }) {
31258
+ return [AL, tip2 ? void 0 : T, F, FO, S, SO, SW, O, H].filter((c4) => c4 !== void 0);
31067
31259
  }
31068
- function createScale(key, channels = [], options = {}) {
31069
- const type2 = inferScaleType(key, channels, options);
31070
- if (options.type === void 0 && options.domain === void 0 && options.range === void 0 && options.interval == null && key !== "fx" && key !== "fy" && isOrdinalScale({ type: type2 })) {
31071
- const values2 = channels.map(({ value }) => value).filter((value) => value !== void 0);
31072
- if (values2.some(isTemporal))
31073
- warn(
31074
- `Warning: some data associated with the ${key} scale are dates. Dates are typically associated with a "utc" or "time" scale rather than a "${formatScaleType(
31075
- type2
31076
- )}" scale. If you are using a bar mark, you probably want a rect mark with the interval option instead; if you are using a group transform, you probably want a bin transform instead. If you want to treat this data as ordinal, you can specify the interval of the ${key} scale (e.g., d3.utcDay), or you can suppress this warning by setting the type of the ${key} scale to "${formatScaleType(
31077
- type2
31078
- )}".`
31079
- );
31080
- else if (values2.some(isTemporalString))
31081
- warn(
31082
- `Warning: some data associated with the ${key} scale are strings that appear to be dates (e.g., YYYY-MM-DD). If these strings represent dates, you should parse them to Date objects. Dates are typically associated with a "utc" or "time" scale rather than a "${formatScaleType(
31083
- type2
31084
- )}" scale. If you are using a bar mark, you probably want a rect mark with the interval option instead; if you are using a group transform, you probably want a bin transform instead. If you want to treat this data as ordinal, you can suppress this warning by setting the type of the ${key} scale to "${formatScaleType(
31085
- type2
31086
- )}".`
31087
- );
31088
- else if (values2.some(isNumericString))
31089
- warn(
31090
- `Warning: some data associated with the ${key} scale are strings that appear to be numbers. If these strings represent numbers, you should parse or coerce them to numbers. Numbers are typically associated with a "linear" scale rather than a "${formatScaleType(
31091
- type2
31092
- )}" scale. If you want to treat this data as ordinal, you can specify the interval of the ${key} scale (e.g., 1 for integers), or you can suppress this warning by setting the type of the ${key} scale to "${formatScaleType(
31093
- type2
31094
- )}".`
31095
- );
31260
+ function groupZ2(I, Z, z) {
31261
+ const G = group(I, (i) => Z[i]);
31262
+ if (z === void 0 && G.size > 1 + I.length >> 1) {
31263
+ warn(
31264
+ `Warning: the implicit z channel has high cardinality. This may occur when the fill or stroke channel is associated with quantitative data rather than ordinal or categorical data. You can suppress this warning by setting the z option explicitly; if this data represents a single series, set z to null.`
31265
+ );
31096
31266
  }
31097
- options.type = type2;
31098
- switch (type2) {
31099
- case "diverging":
31100
- case "diverging-sqrt":
31101
- case "diverging-pow":
31102
- case "diverging-log":
31103
- case "diverging-symlog":
31104
- case "cyclical":
31105
- case "sequential":
31106
- case "linear":
31107
- case "sqrt":
31108
- case "threshold":
31109
- case "quantile":
31110
- case "pow":
31111
- case "log":
31112
- case "symlog":
31113
- options = coerceType(channels, options, coerceNumbers);
31114
- break;
31115
- case "identity":
31116
- switch (registry.get(key)) {
31117
- case position:
31118
- options = coerceType(channels, options, coerceNumbers);
31119
- break;
31120
- case symbol:
31121
- options = coerceType(channels, options, coerceSymbols);
31122
- break;
31267
+ return G.values();
31268
+ }
31269
+ function* groupIndex(I, position3, mark, channels) {
31270
+ const { z } = mark;
31271
+ const { z: Z } = channels;
31272
+ const A5 = groupAesthetics(channels, mark);
31273
+ const C3 = [...position3, ...A5];
31274
+ for (const G of Z ? groupZ2(I, Z, z) : [I]) {
31275
+ let Ag;
31276
+ let Gg;
31277
+ out:
31278
+ for (const i of G) {
31279
+ for (const c4 of C3) {
31280
+ if (!defined(c4[i])) {
31281
+ if (Gg)
31282
+ Gg.push(-1);
31283
+ continue out;
31284
+ }
31285
+ }
31286
+ if (Ag === void 0) {
31287
+ if (Gg)
31288
+ yield Gg;
31289
+ Ag = A5.map((c4) => keyof2(c4[i])), Gg = [i];
31290
+ continue;
31291
+ }
31292
+ Gg.push(i);
31293
+ for (let j = 0; j < A5.length; ++j) {
31294
+ const k2 = keyof2(A5[j][i]);
31295
+ if (k2 !== Ag[j]) {
31296
+ yield Gg;
31297
+ Ag = A5.map((c4) => keyof2(c4[i])), Gg = [i];
31298
+ continue out;
31299
+ }
31300
+ }
31123
31301
  }
31302
+ if (Gg)
31303
+ yield Gg;
31304
+ }
31305
+ }
31306
+ function applyClip(selection2, mark, dimensions, context) {
31307
+ let clipUrl;
31308
+ const { clip = context.clip } = mark;
31309
+ switch (clip) {
31310
+ case "frame": {
31311
+ const { width, height, marginLeft, marginRight, marginTop, marginBottom } = dimensions;
31312
+ const id2 = getClipId();
31313
+ clipUrl = `url(#${id2})`;
31314
+ selection2 = create3("svg:g", context).call(
31315
+ (g) => g.append("svg:clipPath").attr("id", id2).append("rect").attr("x", marginLeft).attr("y", marginTop).attr("width", width - marginRight - marginLeft).attr("height", height - marginTop - marginBottom)
31316
+ ).each(function() {
31317
+ this.appendChild(selection2.node());
31318
+ selection2.node = () => this;
31319
+ });
31124
31320
  break;
31125
- case "utc":
31126
- case "time":
31127
- options = coerceType(channels, options, coerceDates);
31321
+ }
31322
+ case "sphere": {
31323
+ const { projection: projection3 } = context;
31324
+ if (!projection3)
31325
+ throw new Error(`the "sphere" clip option requires a projection`);
31326
+ const id2 = getClipId();
31327
+ clipUrl = `url(#${id2})`;
31328
+ selection2.append("clipPath").attr("id", id2).append("path").attr("d", path_default(projection3)({ type: "Sphere" }));
31128
31329
  break;
31330
+ }
31129
31331
  }
31130
- switch (type2) {
31131
- case "diverging":
31132
- return createScaleDiverging(key, channels, options);
31133
- case "diverging-sqrt":
31134
- return createScaleDivergingSqrt(key, channels, options);
31135
- case "diverging-pow":
31136
- return createScaleDivergingPow(key, channels, options);
31137
- case "diverging-log":
31138
- return createScaleDivergingLog(key, channels, options);
31139
- case "diverging-symlog":
31140
- return createScaleDivergingSymlog(key, channels, options);
31141
- case "categorical":
31142
- case "ordinal":
31143
- case ordinalImplicit:
31144
- return createScaleOrdinal(key, channels, options);
31145
- case "cyclical":
31146
- case "sequential":
31147
- case "linear":
31148
- return createScaleLinear(key, channels, options);
31149
- case "sqrt":
31150
- return createScaleSqrt(key, channels, options);
31151
- case "threshold":
31152
- return createScaleThreshold(key, channels, options);
31153
- case "quantile":
31154
- return createScaleQuantile(key, channels, options);
31155
- case "quantize":
31156
- return createScaleQuantize(key, channels, options);
31157
- case "pow":
31158
- return createScalePow(key, channels, options);
31159
- case "log":
31160
- return createScaleLog(key, channels, options);
31161
- case "symlog":
31162
- return createScaleSymlog(key, channels, options);
31163
- case "utc":
31164
- return createScaleUtc(key, channels, options);
31165
- case "time":
31166
- return createScaleTime(key, channels, options);
31167
- case "point":
31168
- return createScalePoint(key, channels, options);
31169
- case "band":
31170
- return createScaleBand(key, channels, options);
31171
- case "identity":
31172
- return createScaleIdentity(key);
31173
- case void 0:
31174
- return;
31175
- default:
31176
- throw new Error(`unknown scale type: ${type2}`);
31177
- }
31178
- }
31179
- function formatScaleType(type2) {
31180
- return typeof type2 === "symbol" ? type2.description : type2;
31181
- }
31182
- function maybeScaleType(type2) {
31183
- return typeof type2 === "string" ? `${type2}`.toLowerCase() : type2;
31332
+ applyAttr(selection2, "aria-label", mark.ariaLabel);
31333
+ applyAttr(selection2, "aria-description", mark.ariaDescription);
31334
+ applyAttr(selection2, "aria-hidden", mark.ariaHidden);
31335
+ applyAttr(selection2, "clip-path", clipUrl);
31184
31336
  }
31185
- var typeProjection = { toString: () => "projection" };
31186
- function inferScaleType(key, channels, { type: type2, domain, range: range3, scheme: scheme28, pivot, projection: projection3 }) {
31187
- type2 = maybeScaleType(type2);
31188
- if (key === "fx" || key === "fy")
31189
- return "band";
31190
- if ((key === "x" || key === "y") && projection3 != null)
31191
- type2 = typeProjection;
31192
- for (const channel of channels) {
31193
- const t = maybeScaleType(channel.type);
31194
- if (t === void 0)
31195
- continue;
31196
- else if (type2 === void 0)
31197
- type2 = t;
31198
- else if (type2 !== t)
31199
- throw new Error(`scale incompatible with channel: ${type2} !== ${t}`);
31200
- }
31201
- if (type2 === typeProjection)
31202
- return;
31203
- if (type2 !== void 0)
31204
- return type2;
31205
- if (domain === void 0 && !channels.some(({ value }) => value !== void 0))
31206
- return;
31207
- const kind = registry.get(key);
31208
- if (kind === radius)
31209
- return "sqrt";
31210
- if (kind === opacity || kind === length3)
31211
- return "linear";
31212
- if (kind === symbol)
31213
- return "ordinal";
31214
- if ((domain || range3 || []).length > 2)
31215
- return asOrdinalType(kind);
31216
- if (domain !== void 0) {
31217
- if (isOrdinal(domain))
31218
- return asOrdinalType(kind);
31219
- if (isTemporal(domain))
31220
- return "utc";
31221
- } else {
31222
- const values2 = channels.map(({ value }) => value).filter((value) => value !== void 0);
31223
- if (values2.some(isOrdinal))
31224
- return asOrdinalType(kind);
31225
- if (values2.some(isTemporal))
31226
- return "utc";
31227
- }
31228
- if (kind === color2) {
31229
- if (pivot != null || isDivergingScheme(scheme28))
31230
- return "diverging";
31231
- if (isCategoricalScheme(scheme28))
31232
- return "categorical";
31233
- }
31234
- return "linear";
31337
+ function applyIndirectStyles(selection2, mark, dimensions, context) {
31338
+ applyClip(selection2, mark, dimensions, context);
31339
+ applyAttr(selection2, "fill", mark.fill);
31340
+ applyAttr(selection2, "fill-opacity", mark.fillOpacity);
31341
+ applyAttr(selection2, "stroke", mark.stroke);
31342
+ applyAttr(selection2, "stroke-width", mark.strokeWidth);
31343
+ applyAttr(selection2, "stroke-opacity", mark.strokeOpacity);
31344
+ applyAttr(selection2, "stroke-linejoin", mark.strokeLinejoin);
31345
+ applyAttr(selection2, "stroke-linecap", mark.strokeLinecap);
31346
+ applyAttr(selection2, "stroke-miterlimit", mark.strokeMiterlimit);
31347
+ applyAttr(selection2, "stroke-dasharray", mark.strokeDasharray);
31348
+ applyAttr(selection2, "stroke-dashoffset", mark.strokeDashoffset);
31349
+ applyAttr(selection2, "shape-rendering", mark.shapeRendering);
31350
+ applyAttr(selection2, "filter", mark.imageFilter);
31351
+ applyAttr(selection2, "paint-order", mark.paintOrder);
31352
+ const { pointerEvents = context.pointerSticky === false ? "none" : void 0 } = mark;
31353
+ applyAttr(selection2, "pointer-events", pointerEvents);
31235
31354
  }
31236
- function asOrdinalType(kind) {
31237
- switch (kind) {
31238
- case position:
31239
- return "point";
31240
- case color2:
31241
- return ordinalImplicit;
31242
- default:
31243
- return "ordinal";
31244
- }
31355
+ function applyDirectStyles(selection2, mark) {
31356
+ applyStyle(selection2, "mix-blend-mode", mark.mixBlendMode);
31357
+ applyAttr(selection2, "opacity", mark.opacity);
31245
31358
  }
31246
- function isOrdinalScale({ type: type2 }) {
31247
- return type2 === "ordinal" || type2 === "point" || type2 === "band" || type2 === ordinalImplicit;
31359
+ function applyHref(selection2, href, target) {
31360
+ selection2.each(function(i) {
31361
+ const h = href(i);
31362
+ if (h != null) {
31363
+ const a2 = this.ownerDocument.createElementNS(namespaces_default.svg, "a");
31364
+ a2.setAttribute("fill", "inherit");
31365
+ a2.setAttributeNS(namespaces_default.xlink, "href", h);
31366
+ if (target != null)
31367
+ a2.setAttribute("target", target);
31368
+ this.parentNode.insertBefore(a2, this).appendChild(this);
31369
+ }
31370
+ });
31248
31371
  }
31249
- function isThresholdScale({ type: type2 }) {
31250
- return type2 === "threshold";
31372
+ function applyAttr(selection2, name, value) {
31373
+ if (value != null)
31374
+ selection2.attr(name, value);
31251
31375
  }
31252
- function isBandScale({ type: type2 }) {
31253
- return type2 === "point" || type2 === "band";
31376
+ function applyStyle(selection2, name, value) {
31377
+ if (value != null)
31378
+ selection2.style(name, value);
31254
31379
  }
31255
- function isCollapsed(scale3) {
31256
- if (scale3 === void 0)
31257
- return true;
31258
- const domain = scale3.domain();
31259
- const value = scale3(domain[0]);
31260
- for (let i = 1, n = domain.length; i < n; ++i) {
31261
- if (scale3(domain[i]) - value) {
31262
- return false;
31263
- }
31264
- }
31265
- return true;
31380
+ function applyTransform(selection2, mark, { x: x3, y: y3 }, tx = offset, ty = offset) {
31381
+ tx += mark.dx;
31382
+ ty += mark.dy;
31383
+ if (x3?.bandwidth)
31384
+ tx += x3.bandwidth() / 2;
31385
+ if (y3?.bandwidth)
31386
+ ty += y3.bandwidth() / 2;
31387
+ if (tx || ty)
31388
+ selection2.attr("transform", `translate(${tx},${ty})`);
31266
31389
  }
31267
- function coerceType(channels, { domain, ...options }, coerceValues) {
31268
- for (const c4 of channels) {
31269
- if (c4.value !== void 0) {
31270
- if (domain === void 0)
31271
- domain = c4.value?.domain;
31272
- c4.value = coerceValues(c4.value);
31273
- }
31274
- }
31275
- return {
31276
- domain: domain === void 0 ? domain : coerceValues(domain),
31277
- ...options
31278
- };
31390
+ function impliedString(value, impliedValue) {
31391
+ if ((value = string(value)) !== impliedValue)
31392
+ return value;
31279
31393
  }
31280
- function coerceSymbols(values2) {
31281
- return map2(values2, maybeSymbol);
31394
+ function impliedNumber(value, impliedValue) {
31395
+ if ((value = number5(value)) !== impliedValue)
31396
+ return value;
31282
31397
  }
31283
- function scale2(options = {}) {
31284
- let scale3;
31285
- for (const key in options) {
31286
- if (!registry.has(key))
31287
- continue;
31288
- if (!isScaleOptions(options[key]))
31289
- continue;
31290
- if (scale3 !== void 0)
31291
- throw new Error("ambiguous scale definition; multiple scales found");
31292
- scale3 = exposeScale(normalizeScale(key, options[key]));
31293
- }
31294
- if (scale3 === void 0)
31295
- throw new Error("invalid scale definition; no scale found");
31296
- return scale3;
31398
+ var validClassName = /^-?([_a-z]|[\240-\377]|\\[0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|\\[^\r\n\f0-9a-f])([_a-z0-9-]|[\240-\377]|\\[0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|\\[^\r\n\f0-9a-f])*$/i;
31399
+ function maybeClassName(name) {
31400
+ if (name === void 0)
31401
+ return "plot-d6a7b5";
31402
+ name = `${name}`;
31403
+ if (!validClassName.test(name))
31404
+ throw new Error(`invalid class name: ${name}`);
31405
+ return name;
31297
31406
  }
31298
- function exposeScales(scales2) {
31299
- return (key) => {
31300
- if (!registry.has(key = `${key}`))
31301
- throw new Error(`unknown scale: ${key}`);
31302
- return scales2[key];
31303
- };
31407
+ function applyInlineStyles(selection2, style) {
31408
+ if (typeof style === "string") {
31409
+ selection2.property("style", style);
31410
+ } else if (style != null) {
31411
+ for (const element of selection2) {
31412
+ Object.assign(element.style, style);
31413
+ }
31414
+ }
31304
31415
  }
31305
- function exposeScale({ scale: scale3, type: type2, domain, range: range3, interpolate, interval: interval2, transform: transform3, percent, pivot }) {
31306
- if (type2 === "identity")
31307
- return { type: "identity", apply: (d) => d, invert: (d) => d };
31308
- const unknown = scale3.unknown ? scale3.unknown() : void 0;
31309
- return {
31310
- type: type2,
31311
- domain: slice3(domain),
31312
- // defensive copy
31313
- ...range3 !== void 0 && { range: slice3(range3) },
31314
- // defensive copy
31315
- ...transform3 !== void 0 && { transform: transform3 },
31316
- ...percent && { percent },
31317
- // only exposed if truthy
31318
- ...unknown !== void 0 && { unknown },
31319
- ...interval2 !== void 0 && { interval: interval2 },
31320
- // quantitative
31321
- ...interpolate !== void 0 && { interpolate },
31322
- ...scale3.clamp && { clamp: scale3.clamp() },
31323
- // diverging (always asymmetric; we never want to apply the symmetric transform twice)
31324
- ...pivot !== void 0 && { pivot, symmetric: false },
31325
- // log, diverging-log
31326
- ...scale3.base && { base: scale3.base() },
31327
- // pow, diverging-pow
31328
- ...scale3.exponent && { exponent: scale3.exponent() },
31329
- // symlog, diverging-symlog
31330
- ...scale3.constant && { constant: scale3.constant() },
31331
- // band, point
31332
- ...scale3.align && { align: scale3.align(), round: scale3.round() },
31333
- ...scale3.padding && (scale3.paddingInner ? { paddingInner: scale3.paddingInner(), paddingOuter: scale3.paddingOuter() } : { padding: scale3.padding() }),
31334
- ...scale3.bandwidth && { bandwidth: scale3.bandwidth(), step: scale3.step() },
31335
- // utilities
31336
- apply: (t) => scale3(t),
31337
- ...scale3.invert && { invert: (t) => scale3.invert(t) }
31338
- };
31416
+ function applyFrameAnchor({ frameAnchor }, { width, height, marginTop, marginRight, marginBottom, marginLeft }) {
31417
+ return [
31418
+ /left$/.test(frameAnchor) ? marginLeft : /right$/.test(frameAnchor) ? width - marginRight : (marginLeft + width - marginRight) / 2,
31419
+ /^top/.test(frameAnchor) ? marginTop : /^bottom/.test(frameAnchor) ? height - marginBottom : (marginTop + height - marginBottom) / 2
31420
+ ];
31339
31421
  }
31340
31422
 
31341
31423
  // ../../node_modules/@observablehq/plot/src/dimensions.js
@@ -33081,19 +33163,28 @@ function axisTickKy(k2, anchor, data, {
33081
33163
  y: y3 = k2 === "y" ? void 0 : null,
33082
33164
  ...options
33083
33165
  }) {
33084
- return axisMark(vectorY, k2, anchor, `${k2}-axis tick`, data, {
33085
- strokeWidth,
33086
- strokeLinecap,
33087
- strokeLinejoin,
33088
- facetAnchor,
33089
- frameAnchor,
33090
- y: y3,
33091
- ...options,
33092
- dx: anchor === "left" ? +dx - offset + +insetLeft : +dx + offset - insetRight,
33093
- anchor: "start",
33094
- length: tickSize,
33095
- shape: anchor === "left" ? shapeTickLeft : shapeTickRight
33096
- });
33166
+ return axisMark(
33167
+ vectorY,
33168
+ k2,
33169
+ data,
33170
+ {
33171
+ ariaLabel: `${k2}-axis tick`,
33172
+ ariaHidden: true
33173
+ },
33174
+ {
33175
+ strokeWidth,
33176
+ strokeLinecap,
33177
+ strokeLinejoin,
33178
+ facetAnchor,
33179
+ frameAnchor,
33180
+ y: y3,
33181
+ ...options,
33182
+ dx: anchor === "left" ? +dx - offset + +insetLeft : +dx + offset - insetRight,
33183
+ anchor: "start",
33184
+ length: tickSize,
33185
+ shape: anchor === "left" ? shapeTickLeft : shapeTickRight
33186
+ }
33187
+ );
33097
33188
  }
33098
33189
  function axisTickKx(k2, anchor, data, {
33099
33190
  strokeWidth = 1,
@@ -33109,19 +33200,28 @@ function axisTickKx(k2, anchor, data, {
33109
33200
  x: x3 = k2 === "x" ? void 0 : null,
33110
33201
  ...options
33111
33202
  }) {
33112
- return axisMark(vectorX, k2, anchor, `${k2}-axis tick`, data, {
33113
- strokeWidth,
33114
- strokeLinejoin,
33115
- strokeLinecap,
33116
- facetAnchor,
33117
- frameAnchor,
33118
- x: x3,
33119
- ...options,
33120
- dy: anchor === "bottom" ? +dy - offset - insetBottom : +dy + offset + +insetTop,
33121
- anchor: "start",
33122
- length: tickSize,
33123
- shape: anchor === "bottom" ? shapeTickBottom : shapeTickTop
33124
- });
33203
+ return axisMark(
33204
+ vectorX,
33205
+ k2,
33206
+ data,
33207
+ {
33208
+ ariaLabel: `${k2}-axis tick`,
33209
+ ariaHidden: true
33210
+ },
33211
+ {
33212
+ strokeWidth,
33213
+ strokeLinejoin,
33214
+ strokeLinecap,
33215
+ facetAnchor,
33216
+ frameAnchor,
33217
+ x: x3,
33218
+ ...options,
33219
+ dy: anchor === "bottom" ? +dy - offset - insetBottom : +dy + offset + +insetTop,
33220
+ anchor: "start",
33221
+ length: tickSize,
33222
+ shape: anchor === "bottom" ? shapeTickBottom : shapeTickTop
33223
+ }
33224
+ );
33125
33225
  }
33126
33226
  function axisTextKy(k2, anchor, data, {
33127
33227
  facetAnchor = anchor + (k2 === "y" ? "-empty" : ""),
@@ -33143,9 +33243,8 @@ function axisTextKy(k2, anchor, data, {
33143
33243
  return axisMark(
33144
33244
  textY,
33145
33245
  k2,
33146
- anchor,
33147
- `${k2}-axis tick label`,
33148
33246
  data,
33247
+ { ariaLabel: `${k2}-axis tick label` },
33149
33248
  {
33150
33249
  facetAnchor,
33151
33250
  frameAnchor,
@@ -33186,9 +33285,8 @@ function axisTextKx(k2, anchor, data, {
33186
33285
  return axisMark(
33187
33286
  textX,
33188
33287
  k2,
33189
- anchor,
33190
- `${k2}-axis tick label`,
33191
33288
  data,
33289
+ { ariaLabel: `${k2}-axis tick label` },
33192
33290
  {
33193
33291
  facetAnchor,
33194
33292
  frameAnchor,
@@ -33232,7 +33330,7 @@ function gridKy(k2, anchor, data, {
33232
33330
  x2: x22 = anchor === "right" ? x3 : null,
33233
33331
  ...options
33234
33332
  }) {
33235
- return axisMark(ruleY, k2, anchor, `${k2}-grid`, data, { y: y3, x1: x12, x2: x22, ...gridDefaults(options) });
33333
+ return axisMark(ruleY, k2, data, { ariaLabel: `${k2}-grid`, ariaHidden: true }, { y: y3, x1: x12, x2: x22, ...gridDefaults(options) });
33236
33334
  }
33237
33335
  function gridKx(k2, anchor, data, {
33238
33336
  x: x3 = k2 === "x" ? void 0 : null,
@@ -33241,7 +33339,7 @@ function gridKx(k2, anchor, data, {
33241
33339
  y2: y22 = anchor === "bottom" ? y3 : null,
33242
33340
  ...options
33243
33341
  }) {
33244
- return axisMark(ruleX, k2, anchor, `${k2}-grid`, data, { x: x3, y1: y12, y2: y22, ...gridDefaults(options) });
33342
+ return axisMark(ruleX, k2, data, { ariaLabel: `${k2}-grid`, ariaHidden: true }, { x: x3, y1: y12, y2: y22, ...gridDefaults(options) });
33245
33343
  }
33246
33344
  function gridDefaults({
33247
33345
  color: color3 = "currentColor",
@@ -33286,7 +33384,7 @@ function labelOptions({
33286
33384
  initializer: initializer2
33287
33385
  };
33288
33386
  }
33289
- function axisMark(mark, k2, anchor, ariaLabel, data, options, initialize) {
33387
+ function axisMark(mark, k2, data, properties, options, initialize) {
33290
33388
  let channels;
33291
33389
  function axisInitializer(data2, facets, _channels, scales2, dimensions, context) {
33292
33390
  const initializeFacets = data2 == null && (k2 === "fx" || k2 === "fy");
@@ -33358,7 +33456,8 @@ function axisMark(mark, k2, anchor, ariaLabel, data, options, initialize) {
33358
33456
  } else {
33359
33457
  channels = {};
33360
33458
  }
33361
- m.ariaLabel = ariaLabel;
33459
+ if (properties !== void 0)
33460
+ Object.assign(m, properties);
33362
33461
  if (m.clip === void 0)
33363
33462
  m.clip = false;
33364
33463
  return m;
@@ -34787,6 +34886,8 @@ function binn(bx, by, gx, gy, {
34787
34886
  for (const [f, I] of maybeGroup(facet, G)) {
34788
34887
  for (const [k3, g] of maybeGroup(I, K2)) {
34789
34888
  for (const [b, extent4] of bin3(g)) {
34889
+ if (G)
34890
+ extent4.z = f;
34790
34891
  if (filter3 && !filter3.reduce(b, extent4))
34791
34892
  continue;
34792
34893
  groupFacet.push(i++);
@@ -34806,7 +34907,7 @@ function binn(bx, by, gx, gy, {
34806
34907
  for (const o of outputs)
34807
34908
  o.reduce(b, extent4);
34808
34909
  if (sort3)
34809
- sort3.reduce(b);
34910
+ sort3.reduce(b, extent4);
34810
34911
  }
34811
34912
  }
34812
34913
  }
@@ -34973,6 +35074,8 @@ function maybeBinReduceFallback(reduce) {
34973
35074
  return reduceY1;
34974
35075
  case "y2":
34975
35076
  return reduceY22;
35077
+ case "z":
35078
+ return reduceZ;
34976
35079
  }
34977
35080
  throw new Error(`invalid bin reduce: ${reduce}`);
34978
35081
  }
@@ -39643,13 +39746,13 @@ var attributeMap = /* @__PURE__ */ new Map([
39643
39746
  ["projectionInsetBottom", "projection.insetBottom"],
39644
39747
  ["projectionClip", "projection.clip"]
39645
39748
  ]);
39646
- function setProperty(object2, path2, value) {
39749
+ function setProperty(object, path2, value) {
39647
39750
  for (let i = 0; i < path2.length; ++i) {
39648
39751
  const key = path2[i];
39649
39752
  if (i === path2.length - 1) {
39650
- object2[key] = value;
39753
+ object[key] = value;
39651
39754
  } else {
39652
- object2 = object2[key] || (object2[key] = {});
39755
+ object = object[key] || (object[key] = {});
39653
39756
  }
39654
39757
  }
39655
39758
  }
@@ -39719,16 +39822,16 @@ function setSymbolAttributes(plot2, svg, attributes, symbols3) {
39719
39822
  }
39720
39823
  function inferLabels(spec, plot2) {
39721
39824
  const { marks: marks2 } = plot2;
39722
- inferLabel("x", spec, marks2, ["x", "x1", "x2"]);
39723
- inferLabel("y", spec, marks2, ["y", "y1", "y2"]);
39825
+ inferLabel("x", spec, marks2);
39826
+ inferLabel("y", spec, marks2);
39724
39827
  inferLabel("fx", spec, marks2);
39725
39828
  inferLabel("fy", spec, marks2);
39726
39829
  }
39727
- function inferLabel(key, spec, marks2, channels = [key]) {
39830
+ function inferLabel(key, spec, marks2) {
39728
39831
  const scale3 = spec[key] || {};
39729
39832
  if (scale3.axis === null || scale3.label !== void 0)
39730
39833
  return;
39731
- const fields = marks2.map((mark) => mark.channelField(channels)?.field);
39834
+ const fields = marks2.map((mark) => mark.channelField(key)?.field);
39732
39835
  if (fields.every((x3) => x3 == null))
39733
39836
  return;
39734
39837
  let candCol;
@@ -39741,7 +39844,7 @@ function inferLabel(key, spec, marks2, channels = [key]) {
39741
39844
  } else if (candCol === void 0 && candLabel === void 0) {
39742
39845
  candCol = column3;
39743
39846
  candLabel = label;
39744
- type2 = getType(marks2[i].data, channels) || "number";
39847
+ type2 = getType(marks2[i].data, key) || "number";
39745
39848
  } else if (candLabel !== label) {
39746
39849
  candLabel = void 0;
39747
39850
  } else if (candCol !== column3) {
@@ -39783,13 +39886,11 @@ function annotateMarks(svg, indices) {
39783
39886
  }
39784
39887
  }
39785
39888
  }
39786
- function getType(data, channels) {
39889
+ function getType(data, channel) {
39787
39890
  for (const row of data) {
39788
- for (let j = 0; j < channels.length; ++j) {
39789
- const v2 = row[channels[j]];
39790
- if (v2 != null) {
39791
- return v2 instanceof Date ? "date" : typeof v2;
39792
- }
39891
+ const v2 = row[channel] ?? row[channel + "1"] ?? row[channel + "2"];
39892
+ if (v2 != null) {
39893
+ return v2 instanceof Date ? "date" : typeof v2;
39793
39894
  }
39794
39895
  }
39795
39896
  }
@@ -39992,49 +40093,6 @@ function isSymbol2(value) {
39992
40093
  return symbols2.has(`${value}`.toLowerCase());
39993
40094
  }
39994
40095
 
39995
- // src/marks/util/arrow.js
39996
- var INTEGER = 2;
39997
- var FLOAT = 3;
39998
- var DECIMAL = 7;
39999
- var TIMESTAMP = 10;
40000
- function isArrowTable(values2) {
40001
- return typeof values2?.getChild === "function";
40002
- }
40003
- function convertArrowType(type2) {
40004
- switch (type2.typeId) {
40005
- case INTEGER:
40006
- case FLOAT:
40007
- case DECIMAL:
40008
- return Float64Array;
40009
- default:
40010
- return Array;
40011
- }
40012
- }
40013
- function convertArrow(type2) {
40014
- const { typeId } = type2;
40015
- if (typeId === TIMESTAMP) {
40016
- return (v2) => v2 == null ? v2 : new Date(v2);
40017
- }
40018
- if (typeId === INTEGER && type2.bitWidth >= 64) {
40019
- return (v2) => v2 == null ? v2 : Number(v2);
40020
- }
40021
- return (v2) => v2;
40022
- }
40023
- function convertArrowColumn(column3) {
40024
- const { type: type2 } = column3;
40025
- const { typeId } = type2;
40026
- if (typeId === INTEGER && type2.bitWidth >= 64) {
40027
- const size = column3.length;
40028
- const array3 = new Float64Array(size);
40029
- for (let row = 0; row < size; ++row) {
40030
- const v2 = column3.get(row);
40031
- array3[row] = v2 == null ? NaN : Number(v2);
40032
- }
40033
- return array3;
40034
- }
40035
- return column3.toArray();
40036
- }
40037
-
40038
40096
  // src/marks/util/to-data-array.js
40039
40097
  function toDataArray(data) {
40040
40098
  return isArrowTable(data) ? arrowToObjects(data) : data;
@@ -40050,7 +40108,7 @@ function arrowToObjects(data) {
40050
40108
  for (let j = 0; j < numCols; ++j) {
40051
40109
  const child = batch.getChildAt(j);
40052
40110
  const { name, type: type2 } = schema.fields[j];
40053
- const valueOf = convertArrow(type2);
40111
+ const valueOf = convertArrowValue(type2);
40054
40112
  for (let o = k2, i = 0; i < numRows; ++i, ++o) {
40055
40113
  objects[o][name] = valueOf(child.get(i));
40056
40114
  }
@@ -40135,17 +40193,15 @@ var Mark2 = class extends MosaicClient {
40135
40193
  hasOwnData() {
40136
40194
  return this.source == null || isDataArray(this.source);
40137
40195
  }
40196
+ hasFieldInfo() {
40197
+ return !!this._fieldInfo;
40198
+ }
40138
40199
  channel(channel) {
40139
40200
  return this.channels.find((c4) => c4.channel === channel);
40140
40201
  }
40141
- channelField(...channels) {
40142
- const list = channels.flat();
40143
- for (const channel of list) {
40144
- const c4 = this.channel(channel);
40145
- if (c4?.field)
40146
- return c4;
40147
- }
40148
- return null;
40202
+ channelField(channel, { exact } = {}) {
40203
+ const c4 = exact ? this.channel(channel) : this.channels.find((c5) => c5.channel.startsWith(channel));
40204
+ return c4?.field ? c4 : null;
40149
40205
  }
40150
40206
  fields() {
40151
40207
  if (this.hasOwnData())
@@ -40153,26 +40209,25 @@ var Mark2 = class extends MosaicClient {
40153
40209
  const { source: { table }, channels, reqs } = this;
40154
40210
  const fields = /* @__PURE__ */ new Map();
40155
40211
  for (const { channel, field: field2 } of channels) {
40156
- const column3 = field2?.column;
40157
- if (!column3) {
40212
+ if (!field2)
40158
40213
  continue;
40159
- } else if (field2.stats?.length || reqs[channel]) {
40160
- if (!fields.has(column3))
40161
- fields.set(column3, /* @__PURE__ */ new Set());
40162
- const entry = fields.get(column3);
40163
- reqs[channel]?.forEach((s2) => entry.add(s2));
40164
- field2.stats?.forEach((s2) => entry.add(s2));
40165
- }
40214
+ const stats = field2.stats?.stats || [];
40215
+ const key = field2.stats?.column ?? field2;
40216
+ const entry = fields.get(key) ?? fields.set(key, /* @__PURE__ */ new Set()).get(key);
40217
+ stats.forEach((s2) => entry.add(s2));
40218
+ reqs[channel]?.forEach((s2) => entry.add(s2));
40166
40219
  }
40167
- return Array.from(fields, ([column3, stats]) => {
40168
- return { table, column: column3, stats: Array.from(stats) };
40169
- });
40220
+ return Array.from(fields, ([c4, s2]) => ({ table, column: c4, stats: s2 }));
40170
40221
  }
40171
40222
  fieldInfo(info) {
40172
- this.stats = info.reduce(
40173
- (o, d) => (o[d.column] = d, o),
40174
- /* @__PURE__ */ Object.create(null)
40175
- );
40223
+ const lookup = Object.fromEntries(info.map((x3) => [x3.column, x3]));
40224
+ for (const entry of this.channels) {
40225
+ const { field: field2 } = entry;
40226
+ if (field2) {
40227
+ Object.assign(entry, lookup[field2.stats?.column ?? field2]);
40228
+ }
40229
+ }
40230
+ this._fieldInfo = true;
40176
40231
  return this;
40177
40232
  }
40178
40233
  query(filter3 = []) {
@@ -40240,8 +40295,7 @@ function channelScale(mark, channel) {
40240
40295
  const { plot: plot2 } = mark;
40241
40296
  let scaleType = plot2.getAttribute(`${channel}Scale`);
40242
40297
  if (!scaleType) {
40243
- const { field: field2 } = mark.channelField(channel, `${channel}1`, `${channel}2`);
40244
- const { type: type2 } = mark.stats[field2.column];
40298
+ const { type: type2 } = mark.channelField(channel);
40245
40299
  scaleType = type2 === "date" ? "time" : "linear";
40246
40300
  }
40247
40301
  const options = { type: scaleType };
@@ -40279,15 +40333,13 @@ var xext = { x: ["min", "max"] };
40279
40333
  var yext = { y: ["min", "max"] };
40280
40334
  var xyext = { ...xext, ...yext };
40281
40335
  function plotExtent(mark, filter3, channel, domainAttr, niceAttr) {
40282
- const { plot: plot2, stats } = mark;
40336
+ const { plot: plot2 } = mark;
40283
40337
  const domain = plot2.getAttribute(domainAttr);
40284
40338
  const nice3 = plot2.getAttribute(niceAttr);
40285
40339
  if (Array.isArray(domain) && !domain[Transient]) {
40286
40340
  return domain;
40287
40341
  } else {
40288
- const { field: field2 } = mark.channelField(channel);
40289
- const { column: column3 } = field2;
40290
- const { min: min5, max: max4 } = stats[column3];
40342
+ const { column: column3, min: min5, max: max4 } = mark.channelField(channel);
40291
40343
  const dom = filteredExtent(filter3, column3) || (nice3 ? linear2().domain([min5, max4]).nice().domain() : [min5, max4]);
40292
40344
  if (domain !== Fixed)
40293
40345
  dom[Transient] = true;
@@ -40307,7 +40359,7 @@ function filteredExtent(filter3, column3) {
40307
40359
  let lo;
40308
40360
  let hi;
40309
40361
  const visitor = (type2, clause) => {
40310
- if (type2 === "BETWEEN" && clause.field.column === column3) {
40362
+ if (type2 === "BETWEEN" && `${clause.field}` === column3) {
40311
40363
  const { range: range3 } = clause;
40312
40364
  if (range3 && (lo == null || range3[0] < lo))
40313
40365
  lo = range3[0];
@@ -40327,26 +40379,23 @@ function filteredExtent(filter3, column3) {
40327
40379
  var ConnectedMark = class extends Mark2 {
40328
40380
  constructor(type2, source, encodings) {
40329
40381
  const dim = type2.endsWith("X") ? "y" : type2.endsWith("Y") ? "x" : null;
40330
- const req = { [dim]: ["min", "max"] };
40382
+ const req = dim ? { [dim]: ["min", "max"] } : void 0;
40331
40383
  super(type2, source, encodings, req);
40332
40384
  this.dim = dim;
40333
40385
  }
40334
40386
  query(filter3 = []) {
40335
- const { plot: plot2, dim, source, stats } = this;
40387
+ const { plot: plot2, dim, source } = this;
40336
40388
  const { optimize = true } = source.options || {};
40337
40389
  const q = super.query(filter3);
40338
40390
  if (!dim)
40339
40391
  return q;
40340
40392
  const ortho = dim === "x" ? "y" : "x";
40341
- const value = this.channelField(ortho)?.as;
40342
- const { field: field2, as } = this.channelField(dim);
40343
- const { type: type2 } = stats[field2.column];
40393
+ const value = this.channelField(ortho, { exact: true })?.as;
40394
+ const { field: field2, as, type: type2, min: min5, max: max4 } = this.channelField(dim);
40344
40395
  const isContinuous = type2 === "date" || type2 === "number";
40345
40396
  if (optimize && isContinuous && value) {
40346
- const { column: column3 } = field2;
40347
- const { max: max4, min: min5 } = stats[column3];
40348
40397
  const size = dim === "x" ? plot2.innerWidth() : plot2.innerHeight();
40349
- const [lo, hi] = filteredExtent(filter3, column3) || [min5, max4];
40398
+ const [lo, hi] = filteredExtent(filter3, field2) || [min5, max4];
40350
40399
  const [expr] = binExpr(this, dim, size, [lo, hi], 1, as);
40351
40400
  const cols = q.select().map((c4) => c4.as).filter((c4) => c4 !== as && c4 !== value);
40352
40401
  return m4(q, expr, as, value, cols);
@@ -40368,17 +40417,10 @@ function m4(input, bin3, x3, y3, cols = []) {
40368
40417
 
40369
40418
  // src/marks/util/grid.js
40370
40419
  function arrayType(values2, name = "density") {
40371
- if (isArrowTable(values2)) {
40372
- return convertArrowType(values2.getChild(name).type);
40373
- } else {
40374
- return typeof values2[0][name] === "number" ? Float64Array : Array;
40375
- }
40376
- }
40377
- function grid1d(n, values2) {
40378
- const Type3 = arrayType(values2);
40379
- return valuesToGrid(new Type3(n), values2);
40420
+ return isArrowTable(values2) ? convertArrowArrayType(values2.getChild(name).type) : typeof values2[0]?.[name] === "number" ? Float64Array : Array;
40380
40421
  }
40381
- function valuesToGrid(grid, values2, name = "density") {
40422
+ function grid1d(n, values2, name = "density") {
40423
+ const grid = new (arrayType(values2))(n);
40382
40424
  if (isArrowTable(values2)) {
40383
40425
  const numRows = values2.numRows;
40384
40426
  if (numRows === 0)
@@ -40877,7 +40919,7 @@ var Grid2DMark = class extends Mark2 {
40877
40919
  }
40878
40920
  setPlot(plot2, index2) {
40879
40921
  const update2 = () => {
40880
- if (this.stats)
40922
+ if (this.hasFieldInfo())
40881
40923
  this.requestUpdate();
40882
40924
  };
40883
40925
  plot2.addAttributeListener("domainX", update2);
@@ -41222,7 +41264,7 @@ var RasterMark = class extends Grid2DMark {
41222
41264
  }
41223
41265
  setPlot(plot2, index2) {
41224
41266
  const update2 = () => {
41225
- if (this.stats)
41267
+ if (this.hasFieldInfo())
41226
41268
  this.rasterize();
41227
41269
  };
41228
41270
  plot2.addAttributeListener("schemeColor", update2);
@@ -41423,9 +41465,12 @@ var DenseLineMark = class extends RasterMark {
41423
41465
  function stripXY(mark, filter3) {
41424
41466
  if (Array.isArray(filter3) && !filter3.length)
41425
41467
  return filter3;
41426
- const xc = mark.channelField("x").field.column;
41427
- const yc = mark.channelField("y").field.column;
41428
- const test = (p) => p.op !== "BETWEEN" || p.field.column !== xc && p.field.column !== yc;
41468
+ const { column: xc } = mark.channelField("x");
41469
+ const { column: yc } = mark.channelField("y");
41470
+ const test = (p) => {
41471
+ const col = `${p.field}`;
41472
+ return p.op !== "BETWEEN" || col !== xc && col !== yc;
41473
+ };
41429
41474
  const filterAnd = (p) => p.op === "AND" ? and(p.children.filter((c4) => test(c4))) : p;
41430
41475
  return Array.isArray(filter3) ? filter3.filter((p) => test(p)).map((p) => filterAnd(p)) : filterAnd(filter3);
41431
41476
  }
@@ -41714,7 +41759,7 @@ var RasterTileMark = class extends Grid2DMark {
41714
41759
  }
41715
41760
  setPlot(plot2, index2) {
41716
41761
  const update2 = () => {
41717
- if (this.stats)
41762
+ if (this.hasFieldInfo())
41718
41763
  this.rasterize();
41719
41764
  };
41720
41765
  plot2.addAttributeListener("schemeColor", update2);
@@ -42263,8 +42308,8 @@ function closeTo(a2, b) {
42263
42308
  }
42264
42309
 
42265
42310
  // src/interactors/util/get-field.js
42266
- function getField(mark, channels) {
42267
- const field2 = mark.channelField(channels)?.field;
42311
+ function getField(mark, channel) {
42312
+ const field2 = mark.channelField(channel)?.field;
42268
42313
  return field2?.basis || field2;
42269
42314
  }
42270
42315
 
@@ -42298,7 +42343,7 @@ var Interval1D = class {
42298
42343
  this.pixelSize = pixelSize || 1;
42299
42344
  this.selection = selection2;
42300
42345
  this.peers = peers;
42301
- this.field = field2 || getField(mark, [channel, channel + "1", channel + "2"]);
42346
+ this.field = field2 || getField(mark, channel);
42302
42347
  this.style = style && sanitizeStyles(style);
42303
42348
  this.brush = channel === "y" ? brushY2() : brushX2();
42304
42349
  this.brush.on("brush end", ({ selection: selection3 }) => this.publish(selection3));
@@ -42366,8 +42411,8 @@ var Interval2D = class {
42366
42411
  this.pixelSize = pixelSize || 1;
42367
42412
  this.selection = selection2;
42368
42413
  this.peers = peers;
42369
- this.xfield = xfield || getField(mark, ["x", "x1", "x2"]);
42370
- this.yfield = yfield || getField(mark, ["y", "y1", "y2"]);
42414
+ this.xfield = xfield || getField(mark, "x");
42415
+ this.yfield = yfield || getField(mark, "y");
42371
42416
  this.style = style && sanitizeStyles(style);
42372
42417
  this.brush = brush2();
42373
42418
  this.brush.on("brush end", ({ selection: selection3 }) => this.publish(selection3));
@@ -42503,8 +42548,8 @@ var PanZoom = class {
42503
42548
  this.mark = mark;
42504
42549
  this.xsel = x3;
42505
42550
  this.ysel = y3;
42506
- this.xfield = xfield || getField(mark, ["x", "x1", "x2"]);
42507
- this.yfield = yfield || getField(mark, ["y", "y1", "y2"]);
42551
+ this.xfield = xfield || getField(mark, "x");
42552
+ this.yfield = yfield || getField(mark, "y");
42508
42553
  this.zoom = extent3(zoom, [0, Infinity], [1, 1]);
42509
42554
  this.panx = this.xsel && panx;
42510
42555
  this.pany = this.ysel && pany;
@@ -42733,8 +42778,10 @@ function findMark({ marks: marks2 }, channel) {
42733
42778
  if (channels == null)
42734
42779
  return null;
42735
42780
  for (let i = marks2.length - 1; i > -1; --i) {
42736
- if (marks2[i].channelField(channels)) {
42737
- return marks2[i];
42781
+ for (const channel2 of channels) {
42782
+ if (marks2[i].channelField(channel2, { exact: true })) {
42783
+ return marks2[i];
42784
+ }
42738
42785
  }
42739
42786
  }
42740
42787
  return null;
@@ -42763,7 +42810,7 @@ function binField(mark, channel, column3, options) {
42763
42810
  column: column3,
42764
42811
  label: column3,
42765
42812
  get stats() {
42766
- return ["min", "max"];
42813
+ return { column: column3, stats: ["min", "max"] };
42767
42814
  },
42768
42815
  get columns() {
42769
42816
  return [column3];
@@ -42773,7 +42820,7 @@ function binField(mark, channel, column3, options) {
42773
42820
  },
42774
42821
  toString() {
42775
42822
  const { apply: apply2, sqlApply, sqlInvert } = channelScale(mark, channel);
42776
- const { min: min5, max: max4 } = mark.stats[column3];
42823
+ const { min: min5, max: max4 } = mark.channelField(channel);
42777
42824
  const b = bins(apply2(min5), apply2(max4), options);
42778
42825
  const col = sqlApply(column3);
42779
42826
  const base = b.min === 0 ? col : `(${col} - ${b.min})`;