@octostar/map-component 0.9.1 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/README.md +37 -43
  2. package/dist/de-baB1tmXy.js +587 -0
  3. package/dist/de-baB1tmXy.js.map +1 -0
  4. package/dist/es-BOFeFpOn.js +587 -0
  5. package/dist/es-BOFeFpOn.js.map +1 -0
  6. package/dist/fr-CaNTJBXD.js +587 -0
  7. package/dist/fr-CaNTJBXD.js.map +1 -0
  8. package/dist/index.mjs +1767 -1303
  9. package/dist/index.mjs.map +1 -1
  10. package/dist/it-D8wMaegA.js +587 -0
  11. package/dist/it-D8wMaegA.js.map +1 -0
  12. package/dist/pt-BR-DU8z2z6T.js +587 -0
  13. package/dist/pt-BR-DU8z2z6T.js.map +1 -0
  14. package/dist/pt-PT-ByMcI3iF.js +587 -0
  15. package/dist/pt-PT-ByMcI3iF.js.map +1 -0
  16. package/dist/styles.css +5 -1
  17. package/dist/types/components/cluster-pie-chart.d.ts.map +1 -1
  18. package/dist/types/components/layers-panel.d.ts +4 -1
  19. package/dist/types/components/layers-panel.d.ts.map +1 -1
  20. package/dist/types/components/map-editor-canvas.d.ts.map +1 -1
  21. package/dist/types/components/properties-panel.d.ts.map +1 -1
  22. package/dist/types/components/timebar.d.ts +1 -2
  23. package/dist/types/components/timebar.d.ts.map +1 -1
  24. package/dist/types/components/value-legend.d.ts +29 -0
  25. package/dist/types/components/value-legend.d.ts.map +1 -0
  26. package/dist/types/i18n/icuContext.d.ts +10 -0
  27. package/dist/types/i18n/icuContext.d.ts.map +1 -0
  28. package/dist/types/i18n/index.d.ts +17 -0
  29. package/dist/types/i18n/index.d.ts.map +1 -0
  30. package/dist/types/i18n/locale.d.ts +12 -0
  31. package/dist/types/i18n/locale.d.ts.map +1 -0
  32. package/dist/types/index.d.ts +1 -3
  33. package/dist/types/index.d.ts.map +1 -1
  34. package/dist/types/lib/feature-cap.d.ts +3 -24
  35. package/dist/types/lib/feature-cap.d.ts.map +1 -1
  36. package/dist/types/lib/field-values.d.ts +13 -0
  37. package/dist/types/lib/field-values.d.ts.map +1 -1
  38. package/dist/types/lib/ingest-pipeline.d.ts.map +1 -1
  39. package/dist/types/lib/labels/icon-labels.d.ts +33 -0
  40. package/dist/types/lib/labels/icon-labels.d.ts.map +1 -0
  41. package/dist/types/lib/labels/message-labels.d.ts +112 -0
  42. package/dist/types/lib/labels/message-labels.d.ts.map +1 -0
  43. package/dist/types/lib/labels/panel-labels.d.ts +331 -0
  44. package/dist/types/lib/labels/panel-labels.d.ts.map +1 -0
  45. package/dist/types/lib/map-editor-api.d.ts +6 -8
  46. package/dist/types/lib/map-editor-api.d.ts.map +1 -1
  47. package/dist/types/lib/map-labels.d.ts +608 -609
  48. package/dist/types/lib/map-labels.d.ts.map +1 -1
  49. package/package.json +15 -1
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
- import { useContext, createContext, useRef, useLayoutEffect, useState, useEffect, useSyncExternalStore, useCallback, useMemo, forwardRef, useImperativeHandle } from "react";
2
+ import { useSyncExternalStore, useEffect, useContext, createContext, useRef, useLayoutEffect, useState, useCallback, useMemo, forwardRef, useImperativeHandle } from "react";
3
3
  import * as maplibregl from "maplibre-gl";
4
4
  import { getWorkerUrl, getVersion, setWorkerUrl } from "maplibre-gl";
5
5
  import MapboxDraw from "@mapbox/mapbox-gl-draw";
@@ -7,6 +7,8 @@ import * as turf from "@turf/turf";
7
7
  import { distance as distance$1, point } from "@turf/turf";
8
8
  import * as THREE from "three";
9
9
  import proj4 from "proj4";
10
+ import i18next from "i18next";
11
+ import ICU from "i18next-icu";
10
12
  import { Button, Modal, Input, App, message, ConfigProvider, Tooltip, Dropdown, Divider, Popover, Slider, Switch, Segmented, Select, Tag, DatePicker, Collapse, ColorPicker, Tabs, Card, Table } from "antd";
11
13
  import { clsx } from "clsx";
12
14
  import { twMerge } from "tailwind-merge";
@@ -144,7 +146,7 @@ async function featureCollectionBlobPartsAsync(collection, options) {
144
146
  (_c = options == null ? void 0 : options.onProgress) == null ? void 0 : _c.call(options, total, total);
145
147
  return coalescer.finish();
146
148
  }
147
- const ingestWorkerSource = '"use strict";(()=>{function b(e,t){let n=e.length,r=Math.max(0,t.max-(t.existing??0));return n<=r?{features:e,dropped:0,sourceCount:n}:{features:e.slice(0,r),dropped:n-r,sourceCount:n}}function S(e){let t=e.crs?.properties?.name,n=null;if(t){let r=t.match(/EPSG::?(\\d+)/i);r&&(n=`EPSG:${r[1]}`)}if(!n&&e.features.length>0){let r=E(e.features[0].geometry);if(r){let[s,a]=r;if(Math.abs(s)<=180&&Math.abs(a)<=90)return{sourceCRS:"EPSG:4326",needsReprojection:!1}}return{sourceCRS:null,needsReprojection:!1}}return{sourceCRS:n,needsReprojection:n!==null&&n!=="EPSG:4326"}}function E(e){if(!e)return null;switch(e.type){case"Point":return e.coordinates;case"MultiPoint":case"LineString":return e.coordinates[0];case"MultiLineString":case"Polygon":return e.coordinates[0]?.[0];case"MultiPolygon":return e.coordinates[0]?.[0]?.[0];default:return null}}function I(e){return e.geometry?.type==="LineString"?e.geometry.coordinates.some(n=>n.length>=3&&n[2]!==0):e.geometry?.type==="MultiLineString"?e.geometry.coordinates.some(n=>n.some(r=>r.length>=3&&r[2]!==0)):!1}function d(e){if(!e)return null;if(e instanceof Date)return e;if(typeof e=="string"||typeof e=="number"){let t=new Date(e);return isNaN(t.getTime())?null:t}return null}function h(e){return!!(e.startDate||e.startdate||e.start_date||e.start_time||e.date||e.timestamp||e.flightDate||e.time||e.datetime||e.endDate||e.enddate||e.end_date||e.end_time)}function F(e){let t=d(e.startDate)||d(e.startdate)||d(e.start_date)||d(e.start_time)||d(e.date)||d(e.timestamp)||d(e.flightDate)||d(e.time)||d(e.datetime),n=d(e.endDate)||d(e.enddate)||d(e.end_date)||d(e.end_time);return t&&n&&n<t&&([t,n]=[n,t]),{startDate:t,endDate:n}}function x(e){return"kind"in e&&e.kind==="ack"}function w(){let e=globalThis.crypto?.randomUUID?.bind(globalThis.crypto);return e?e():`f-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function _(e,t,n){switch(n.idStrategy){case"preserve":return e.id;case"layer-index":return e.id!==void 0&&e.id!==null?String(e.id):`${n.layerId}-f${t}`;case"uuid-fallback":return e.id?String(e.id):w()}}function C(e,t){if(Array.isArray(e)){if(typeof e[0]=="number"){let n=e[0],r=e[1];t[0]=Math.min(t[0],n),t[1]=Math.min(t[1],r),t[2]=Math.max(t[2],n),t[3]=Math.max(t[3],r);return}for(let n of e)C(n,t)}}function R(e,t){if(e){if(e.type==="GeometryCollection"){for(let n of e.geometries)R(n,t);return}C(e.coordinates,t)}}function G(e){let t=[1/0,1/0,-1/0,-1/0];for(let n of e)R(n.geometry,t);return t.every(n=>isFinite(n))?t:null}function A(e,t){let n;if(e.type==="text")try{n=JSON.parse(e.text)}catch(c){return{kind:"error",code:"parse-error",message:c instanceof Error?c.message:"Invalid file"}}else n=e.data;if(n&&n.type==="Feature"&&(n={type:"FeatureCollection",features:[n]}),!n||n.type!=="FeatureCollection"||!Array.isArray(n.features))return{kind:"error",code:"invalid-format",message:"Invalid GeoJSON format"};if(t.emptyIsError&&n.features.length===0)return{kind:"error",code:"empty",message:"The file contains no features"};if(n["octostar:map"])return{kind:"enriched",data:n};let{sourceCRS:r,needsReprojection:s}=S(n),a=b(n.features,{max:t.maxFeatures??1/0}),o=!1,u=!1,i=[];a.features.forEach((c,D)=>{let p=_(c,D,t);!u&&I(c)&&(u=!0);let g=c.properties||{};if(!h(g)){i.push(t.idStrategy==="preserve"?c:{...c,id:p});return}let{startDate:y,endDate:k}=F(g);(y||k)&&(o=!0),i.push({...c,...p!==void 0&&{id:p},properties:{...g,startDate:y?.toISOString()||null,endDate:k?.toISOString()||null}})});let m=n.properties?.layerMetadata;return{kind:"features",features:i,featureCount:i.length,bbox:G(i),hasTemporal:o,hasAltitude:u,reprojected:!1,sourceCRS:r,...s&&{needsReprojection:s},...m&&{layerMetadata:m},...a.dropped>0&&{truncated:{droppedCount:a.dropped,sourceFeatureCount:a.sourceCount,maxFeatures:t.maxFeatures}}}}var N=5e3;function P(e,t){let n=Number.isNaN(t)?N:Math.max(1,Math.floor(t)),r=[];for(let s=0;s<e.length;s+=n)r.push(e.slice(s,s+n));return r}function f(e){if(e===void 0)return!1;if(typeof e=="number")return Number.isFinite(e)&&!Object.is(e,-0);if(e===null||typeof e!="object")return!0;if(Array.isArray(e)){for(let t=0;t<e.length;t++)if(!f(e[t]))return!1;return!0}for(let t in e)if(!f(e[t]))return!1;return!0}function J(e){for(let t=0;t<e.length;t++)if(!f(e[t]))return e;try{return JSON.stringify(e)}catch{return e}}function M(e){let{kind:t,features:n,...r}=e;return r}async function T(e,t,n,r){let s;try{s=A(t,n)}catch(a){r.post({kind:"result",id:e,ok:!1,error:a instanceof Error?a.message:String(a)});return}if(s.kind!=="features"){r.post({kind:"result",id:e,ok:!0,result:s});return}try{let a=r.encode??J,o=P(s.features,r.chunkSize??N);r.post({kind:"head",id:e,summary:M(s)});let u=o.length>0?a(o[0]):null;for(let i=0;i<o.length;i++){let m=r.waitAck(i);r.post({kind:"chunk",id:e,seq:i,payload:u}),u=i+1<o.length?a(o[i+1]):null,await m}r.post({kind:"done",id:e,chunkCount:o.length})}catch(a){r.post({kind:"error",id:e,message:a instanceof Error?a.message:String(a)})}}var O=e=>self.postMessage(e),l=new Map;self.onmessage=async e=>{let t=e.data;if(x(t)){let o=`${t.id}:${t.seq}`,u=l.get(o);l.delete(o),u?.();return}let{id:n,source:r,options:s,tuning:a}=t;try{let o=r.type==="blob"?{type:"text",text:await r.blob.text()}:r;await T(n,o,s,{post:O,waitAck:u=>new Promise(i=>{l.set(`${n}:${u}`,i)}),...a?.chunkSize!==void 0&&{chunkSize:a.chunkSize},...a?.featureArrayChunks&&{encode:u=>u}})}catch(o){O({kind:"result",id:n,ok:!1,error:o instanceof Error?o.message:String(o)})}finally{l.forEach((o,u)=>{u.startsWith(`${n}:`)&&l.delete(u)})}};})();\n';
149
+ const ingestWorkerSource = '"use strict";(()=>{function b(e,t){let n=e.length,r=Math.max(0,t.max-(t.existing??0));return n<=r?{features:e,dropped:0,sourceCount:n}:{features:e.slice(0,r),dropped:n-r,sourceCount:n}}function S(e){let t=e.crs?.properties?.name,n=null;if(t){let r=t.match(/EPSG::?(\\d+)/i);r&&(n=`EPSG:${r[1]}`)}if(!n&&e.features.length>0){let r=E(e.features[0].geometry);if(r){let[s,a]=r;if(Math.abs(s)<=180&&Math.abs(a)<=90)return{sourceCRS:"EPSG:4326",needsReprojection:!1}}return{sourceCRS:null,needsReprojection:!1}}return{sourceCRS:n,needsReprojection:n!==null&&n!=="EPSG:4326"}}function E(e){if(!e)return null;switch(e.type){case"Point":return e.coordinates;case"MultiPoint":case"LineString":return e.coordinates[0];case"MultiLineString":case"Polygon":return e.coordinates[0]?.[0];case"MultiPolygon":return e.coordinates[0]?.[0]?.[0];default:return null}}function I(e){return e.geometry?.type==="LineString"?e.geometry.coordinates.some(n=>n.length>=3&&n[2]!==0):e.geometry?.type==="MultiLineString"?e.geometry.coordinates.some(n=>n.some(r=>r.length>=3&&r[2]!==0)):!1}function d(e){if(!e)return null;if(e instanceof Date)return e;if(typeof e=="string"||typeof e=="number"){let t=new Date(e);return isNaN(t.getTime())?null:t}return null}function h(e){return!!(e.startDate||e.startdate||e.start_date||e.start_time||e.date||e.timestamp||e.flightDate||e.time||e.datetime||e.endDate||e.enddate||e.end_date||e.end_time)}function x(e){let t=d(e.startDate)||d(e.startdate)||d(e.start_date)||d(e.start_time)||d(e.date)||d(e.timestamp)||d(e.flightDate)||d(e.time)||d(e.datetime),n=d(e.endDate)||d(e.enddate)||d(e.end_date)||d(e.end_time);return t&&n&&n<t&&([t,n]=[n,t]),{startDate:t,endDate:n}}function F(e){return"kind"in e&&e.kind==="ack"}function w(){let e=globalThis.crypto?.randomUUID?.bind(globalThis.crypto);return e?e():`f-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function G(e,t,n){switch(n.idStrategy){case"preserve":return e.id;case"layer-index":return e.id!==void 0&&e.id!==null?String(e.id):`${n.layerId}-f${t}`;case"uuid-fallback":return e.id?String(e.id):w()}}function C(e,t){if(Array.isArray(e)){if(typeof e[0]=="number"){let n=e[0],r=e[1];t[0]=Math.min(t[0],n),t[1]=Math.min(t[1],r),t[2]=Math.max(t[2],n),t[3]=Math.max(t[3],r);return}for(let n of e)C(n,t)}}function R(e,t){if(e){if(e.type==="GeometryCollection"){for(let n of e.geometries)R(n,t);return}C(e.coordinates,t)}}function M(e){let t=[1/0,1/0,-1/0,-1/0];for(let n of e)R(n.geometry,t);return t.every(n=>isFinite(n))?t:null}function N(e,t){let n;if(e.type==="text")try{n=JSON.parse(e.text)}catch(c){return{kind:"error",code:"parse-error",message:c instanceof Error?c.message:"Invalid file"}}else n=e.data;if(n&&n.type==="Feature"&&(n={type:"FeatureCollection",features:[n]}),!n||n.type!=="FeatureCollection"||!Array.isArray(n.features))return{kind:"error",code:"invalid-format",message:"Invalid GeoJSON format"};if(t.emptyIsError&&n.features.length===0)return{kind:"error",code:"empty",message:"The file contains no features"};if(n["octostar:map"])return{kind:"enriched",data:n};let{sourceCRS:r,needsReprojection:s}=S(n),a=b(n.features,{max:t.maxFeatures??1/0}),o=!1,u=!1,i=[];a.features.forEach((c,A)=>{let p=G(c,A,t);!u&&I(c)&&(u=!0);let g=c.properties||{};if(!h(g)){i.push(t.idStrategy==="preserve"?c:{...c,id:p});return}let{startDate:y,endDate:k}=x(g);(y||k)&&(o=!0),i.push({...c,...p!==void 0&&{id:p},properties:{...g,startDate:y?.toISOString()||null,endDate:k?.toISOString()||null}})});let m=n.properties?.layerMetadata;return{kind:"features",features:i,featureCount:i.length,bbox:M(i),hasTemporal:o,hasAltitude:u,reprojected:!1,sourceCRS:r,...s&&{needsReprojection:s},...m&&{layerMetadata:m},...a.dropped>0&&{truncated:{droppedCount:a.dropped,sourceFeatureCount:a.sourceCount,maxFeatures:t.maxFeatures}}}}var O=5e3;function _(e,t){let n=Number.isNaN(t)?O:Math.max(1,Math.floor(t)),r=[];for(let s=0;s<e.length;s+=n)r.push(e.slice(s,s+n));return r}function f(e){if(e===void 0)return!1;if(typeof e=="number")return Number.isFinite(e)&&!Object.is(e,-0);if(e===null||typeof e!="object")return!0;if(Array.isArray(e)){for(let t=0;t<e.length;t++)if(!f(e[t]))return!1;return!0}for(let t in e)if(!f(e[t]))return!1;return!0}function J(e){for(let t=0;t<e.length;t++)if(!f(e[t]))return e;try{return JSON.stringify(e)}catch{return e}}function P(e){let{kind:t,features:n,...r}=e;return r}async function T(e,t,n,r){let s;try{s=N(t,n)}catch(a){r.post({kind:"result",id:e,ok:!1,error:a instanceof Error?a.message:String(a)});return}if(s.kind!=="features"){r.post({kind:"result",id:e,ok:!0,result:s});return}try{let a=r.encode??J,o=_(s.features,r.chunkSize??O);r.post({kind:"head",id:e,summary:P(s)});let u=o.length>0?a(o[0]):null;for(let i=0;i<o.length;i++){let m=r.waitAck(i);r.post({kind:"chunk",id:e,seq:i,payload:u}),u=i+1<o.length?a(o[i+1]):null,await m}r.post({kind:"done",id:e,chunkCount:o.length})}catch(a){r.post({kind:"error",id:e,message:a instanceof Error?a.message:String(a)})}}var D=e=>self.postMessage(e),l=new Map;self.onmessage=async e=>{let t=e.data;if(F(t)){let o=`${t.id}:${t.seq}`,u=l.get(o);l.delete(o),u?.();return}let{id:n,source:r,options:s,tuning:a}=t;try{let o=r.type==="blob"?{type:"text",text:await r.blob.text()}:r;await T(n,o,s,{post:D,waitAck:u=>new Promise(i=>{l.set(`${n}:${u}`,i)}),...a?.chunkSize!==void 0&&{chunkSize:a.chunkSize},...a?.featureArrayChunks&&{encode:u=>u}})}catch(o){D({kind:"result",id:n,ok:!1,error:o instanceof Error?o.message:String(o)})}finally{l.forEach((o,u)=>{u.startsWith(`${n}:`)&&l.delete(u)})}};})();\n';
148
150
  proj4.defs("EPSG:27700", "+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 +units=m +no_defs");
149
151
  proj4.defs("EPSG:3857", "+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs");
150
152
  proj4.defs("EPSG:32630", "+proj=utm +zone=30 +datum=WGS84 +units=m +no_defs");
@@ -217,17 +219,7 @@ function truncationToCapInfo(truncation, rest) {
217
219
  max: truncation.maxFeatures
218
220
  };
219
221
  }
220
- function formatCount(value) {
221
- return value.toLocaleString("en-US");
222
- }
223
- const DEFAULT_FEATURE_CAP_LABELS = {
224
- title: "Feature limit reached",
225
- layersOverLimit: ({ layerCount, max, dropped }) => `${formatCount(layerCount)} layers were larger than the ${formatCount(max)}-feature limit; ${formatCount(dropped)} features in total were not loaded.`,
226
- layerAlreadyHeld: ({ layerName, existing, max, kept, dropped }) => `"${layerName}" already held ${formatCount(existing)} of its ${formatCount(max)}-feature limit, so only ${formatCount(kept)} more were added; ${formatCount(dropped)} were skipped.`,
227
- firstFeaturesAdded: ({ kept, sourceCount, layerName, dropped }) => `Only the first ${formatCount(kept)} of ${formatCount(sourceCount)} features were added to "${layerName}"; ${formatCount(dropped)} were skipped (per-layer limit).`,
228
- restoreNote: "Re-saving this map will persist only the loaded features."
229
- };
230
- function formatFeatureCapToast(info, labels = DEFAULT_FEATURE_CAP_LABELS) {
222
+ function formatFeatureCapToast(info, labels) {
231
223
  const isRestore = info.source === "restore";
232
224
  const variant = isRestore ? "destructive" : "default";
233
225
  const withNote = (text) => isRestore ? `${text} ${labels.restoreNote}` : text;
@@ -352,6 +344,7 @@ function runIngestPipeline(source, options) {
352
344
  return {
353
345
  kind: "error",
354
346
  code: "parse-error",
347
+ // eslint-disable-next-line i18next/no-literal-string -- the code picks the user's text (labels.ingest); this is for logs
355
348
  message: err instanceof Error ? err.message : "Invalid file"
356
349
  };
357
350
  }
@@ -743,13 +736,13 @@ function getSharedIngestClient() {
743
736
  }
744
737
  function createIngestProgressStore() {
745
738
  const entries = /* @__PURE__ */ new Map();
746
- const listeners = /* @__PURE__ */ new Set();
739
+ const listeners2 = /* @__PURE__ */ new Set();
747
740
  let nextId = 0;
748
741
  let snapshot = [];
749
742
  let dirty = false;
750
743
  const notify = () => {
751
744
  dirty = true;
752
- listeners.forEach((listener) => listener());
745
+ listeners2.forEach((listener) => listener());
753
746
  };
754
747
  return {
755
748
  begin(label, options) {
@@ -775,8 +768,8 @@ function createIngestProgressStore() {
775
768
  };
776
769
  },
777
770
  subscribe(listener) {
778
- listeners.add(listener);
779
- return () => listeners.delete(listener);
771
+ listeners2.add(listener);
772
+ return () => listeners2.delete(listener);
780
773
  },
781
774
  getSnapshot() {
782
775
  if (dirty) {
@@ -800,6 +793,797 @@ function installInlinedMaplibreWorker() {
800
793
  }
801
794
  setWorkerUrl(URL.createObjectURL(new Blob([maplibreWorkerSource], { type: "text/javascript" })));
802
795
  }
796
+ const CONTEXT_SEPARATOR = "_";
797
+ const parentParse = ICU.prototype.parse;
798
+ const contextSuffix = (options) => typeof (options == null ? void 0 : options.context) === "string" && options.context !== "" ? `${CONTEXT_SEPARATOR}${options.context}` : "";
799
+ class ICUWithContext extends ICU {
800
+ // Upstream returns finalKeys untouched, so there is nothing to delegate to.
801
+ // i18next pops finalKeys, so the appended (more specific) key wins and the
802
+ // base key remains the fallback.
803
+ addLookupKeys(finalKeys, key, _code, _ns, options) {
804
+ const suffix = contextSuffix(options);
805
+ if (suffix) finalKeys.push(`${key}${suffix}`);
806
+ return finalKeys;
807
+ }
808
+ // `key` only feeds the memo key upstream, so qualifying it keeps the
809
+ // contextual and plain messages in separate cache slots.
810
+ parse(res, options, lng, ns, key, info) {
811
+ return parentParse.call(this, res, options, lng, ns, `${key}${contextSuffix(options)}`, info);
812
+ }
813
+ }
814
+ const SUPPORTED_LANGUAGES = ["en", "it", "fr", "de", "es", "pt-BR", "pt-PT"];
815
+ const DEFAULT_LANGUAGE = "en";
816
+ const DEFAULT_VARIANTS = /* @__PURE__ */ new Map([["pt", "pt-BR"]]);
817
+ function languageOf(locale) {
818
+ var _a;
819
+ let parsed;
820
+ try {
821
+ parsed = new Intl.Locale(locale.trim().replace(/_/g, "-"));
822
+ } catch {
823
+ return null;
824
+ }
825
+ const base = parsed.language.toLowerCase();
826
+ const region = (_a = parsed.region) == null ? void 0 : _a.toLowerCase();
827
+ const shipped = (code) => SUPPORTED_LANGUAGES.find((language) => language.toLowerCase() === code);
828
+ return (region ? shipped(`${base}-${region}`) : void 0) ?? DEFAULT_VARIANTS.get(base) ?? shipped(base) ?? null;
829
+ }
830
+ function canonicalTag(tag) {
831
+ try {
832
+ return Intl.getCanonicalLocales(tag.trim().replace(/_/g, "-"))[0] ?? null;
833
+ } catch {
834
+ return null;
835
+ }
836
+ }
837
+ function resolveMapLocale(language) {
838
+ const pageTag = typeof document === "undefined" ? "" : document.documentElement.lang;
839
+ for (const tag of [language, pageTag]) {
840
+ const canonical = tag ? canonicalTag(tag) : null;
841
+ if (canonical && languageOf(canonical)) return canonical;
842
+ }
843
+ return DEFAULT_LANGUAGE;
844
+ }
845
+ const instance = i18next.createInstance();
846
+ void instance.use(ICUWithContext).init({
847
+ lng: DEFAULT_LANGUAGE,
848
+ fallbackLng: (code) => [languageOf(code) ?? DEFAULT_LANGUAGE, DEFAULT_LANGUAGE],
849
+ resources: { en: { translation: {} } },
850
+ partialBundledLanguages: true,
851
+ nsSeparator: false,
852
+ keySeparator: false,
853
+ returnNull: false,
854
+ initAsync: false,
855
+ // English is a missing-key fallthrough: without this ICU re-parses the
856
+ // message on every call of a plural label (counts in the status bar).
857
+ i18nFormat: { memoizeFallback: true },
858
+ interpolation: { escapeValue: false }
859
+ });
860
+ const CATALOGS = {
861
+ it: () => import("./it-D8wMaegA.js"),
862
+ fr: () => import("./fr-CaNTJBXD.js"),
863
+ de: () => import("./de-baB1tmXy.js"),
864
+ es: () => import("./es-BOFeFpOn.js"),
865
+ "pt-BR": () => import("./pt-BR-DU8z2z6T.js"),
866
+ "pt-PT": () => import("./pt-PT-ByMcI3iF.js")
867
+ };
868
+ const loaded = /* @__PURE__ */ new Set([DEFAULT_LANGUAGE]);
869
+ const loading = /* @__PURE__ */ new Map();
870
+ const listeners = /* @__PURE__ */ new Set();
871
+ const isMapLocaleReady = (locale) => loaded.has(languageOf(locale) ?? DEFAULT_LANGUAGE);
872
+ function loadMapLanguage(language) {
873
+ if (language === "en" || loaded.has(language)) return Promise.resolve();
874
+ const inFlight = loading.get(language);
875
+ if (inFlight) return inFlight;
876
+ const load = CATALOGS[language]().then((catalog) => {
877
+ instance.addResourceBundle(language, "translation", catalog.default, true, true);
878
+ loaded.add(language);
879
+ listeners.forEach((notify) => notify());
880
+ }).catch((error) => {
881
+ console.warn(`[map] the ${language} catalog did not load; showing English`, error);
882
+ }).finally(() => loading.delete(language));
883
+ loading.set(language, load);
884
+ return load;
885
+ }
886
+ const subscribe = (notify) => {
887
+ listeners.add(notify);
888
+ return () => listeners.delete(notify);
889
+ };
890
+ function useMapLocale(language) {
891
+ const wanted = resolveMapLocale(language);
892
+ const ready = useSyncExternalStore(subscribe, () => isMapLocaleReady(wanted), () => languageOf(wanted) === "en");
893
+ useEffect(() => {
894
+ if (!ready) void loadMapLanguage(languageOf(wanted) ?? DEFAULT_LANGUAGE);
895
+ }, [wanted, ready]);
896
+ return ready ? wanted : DEFAULT_LANGUAGE;
897
+ }
898
+ const translators = /* @__PURE__ */ new Map();
899
+ function translatorFor(locale) {
900
+ let translate = translators.get(locale);
901
+ if (!translate) {
902
+ const fixed = instance.getFixedT(locale);
903
+ translate = (key, options) => String(fixed(key, options));
904
+ translators.set(locale, translate);
905
+ }
906
+ return translate;
907
+ }
908
+ if (typeof document !== "undefined") void loadMapLanguage(languageOf(resolveMapLocale()) ?? DEFAULT_LANGUAGE);
909
+ const iconPickerLabels = (t) => ({
910
+ title: t("Select Icon"),
911
+ searchPlaceholder: t("Search icons..."),
912
+ allCategories: (count) => t("All ({count})", { count }),
913
+ categoryWithCount: ({ category, count }) => `${category} (${count})`,
914
+ noIconsFound: (query) => t('No icons found for "{query}"', { query }),
915
+ noIconSelected: t("No icon selected"),
916
+ clearIcon: t("Clear", { context: "remove the selected icon" }),
917
+ cancel: t("Cancel"),
918
+ emptyTrigger: t("icon", { context: "empty icon picker button" }),
919
+ anyEmojiHint: t("Any other emoji works too: type or paste it in the search"),
920
+ useEmoji: (emoji) => t("Use {emoji}", { emoji }),
921
+ emojiNotEverywhere: t("This emoji may not show on every computer: pick another"),
922
+ customEmoji: t("Emoji", { context: "icon picker, an icon outside the catalog" }),
923
+ emojiGroups: {
924
+ smileys: t("Smileys", { context: "emoji tab" }),
925
+ people: t("People", { context: "emoji tab" }),
926
+ nature: t("Animals & nature", { context: "emoji tab" }),
927
+ food: t("Food & drink", { context: "emoji tab" }),
928
+ travel: t("Travel & places", { context: "emoji tab" }),
929
+ activities: t("Activities", { context: "emoji tab" }),
930
+ objects: t("Objects", { context: "emoji tab" }),
931
+ symbols: t("Symbols", { context: "emoji tab" })
932
+ }
933
+ });
934
+ const iconCategoryLabels = (t) => ({
935
+ places: t("Places", { context: "icon type" }),
936
+ transport: t("Transport", { context: "icon type" }),
937
+ food: t("Food", { context: "icon type" }),
938
+ nature: t("Nature", { context: "icon type" }),
939
+ symbols: t("Symbols", { context: "icon type" }),
940
+ activities: t("Activities", { context: "icon type" }),
941
+ work: t("Work", { context: "icon type" }),
942
+ shopping: t("Shopping", { context: "icon type" }),
943
+ communication: t("Communication", { context: "icon type" }),
944
+ people: t("People", { context: "icon type" }),
945
+ maritime: t("Maritime", { context: "icon type" }),
946
+ security: t("Security", { context: "icon type" }),
947
+ time: t("Time", { context: "icon type" }),
948
+ shapes: t("Shapes", { context: "icon type" }),
949
+ arrows: t("Arrows", { context: "icon type" })
950
+ });
951
+ const placeIconNames = (t) => ({
952
+ "map-pin": t("Map Pin", { context: "map icon" }),
953
+ home: t("Home", { context: "map icon" }),
954
+ building: t("Building", { context: "map icon" }),
955
+ store: t("Store", { context: "map icon" }),
956
+ factory: t("Factory", { context: "map icon" }),
957
+ construction: t("Construction", { context: "map icon" }),
958
+ church: t("Church", { context: "map icon" }),
959
+ hospital: t("Hospital", { context: "map icon" }),
960
+ school: t("School", { context: "map icon" }),
961
+ graduation: t("University", { context: "map icon" }),
962
+ library: t("Library", { context: "map icon" }),
963
+ landmark: t("Landmark", { context: "map icon" }),
964
+ castle: t("Castle", { context: "map icon" }),
965
+ mosque: t("Mosque", { context: "map icon" }),
966
+ stadium: t("Stadium", { context: "map icon" }),
967
+ tent: t("Camping", { context: "map icon" }),
968
+ car: t("Car", { context: "map icon" }),
969
+ bus: t("Bus", { context: "map icon" }),
970
+ train: t("Train", { context: "map icon" }),
971
+ plane: t("Plane", { context: "map icon" }),
972
+ ship: t("Ship", { context: "map icon" }),
973
+ bike: t("Bike", { context: "map icon" }),
974
+ fuel: t("Gas Station", { context: "map icon" }),
975
+ helicopter: t("Helicopter", { context: "map icon" }),
976
+ rocket: t("Rocket", { context: "map icon" }),
977
+ motorcycle: t("Motorcycle", { context: "map icon" }),
978
+ taxi: t("Taxi", { context: "map icon" }),
979
+ truck: t("Truck", { context: "map icon" }),
980
+ utensils: t("Restaurant", { context: "map icon" }),
981
+ coffee: t("Coffee", { context: "map icon" }),
982
+ beer: t("Bar", { context: "map icon" }),
983
+ wine: t("Wine", { context: "map icon" }),
984
+ pizza: t("Pizza", { context: "map icon" }),
985
+ "ice-cream": t("Ice Cream", { context: "map icon" }),
986
+ apple: t("Apple", { context: "map icon" }),
987
+ cake: t("Cake", { context: "map icon" }),
988
+ hamburger: t("Burger", { context: "map icon" })
989
+ });
990
+ const natureIconNames = (t) => ({
991
+ trees: t("Forest", { context: "map icon" }),
992
+ mountain: t("Mountain", { context: "map icon" }),
993
+ waves: t("Water", { context: "map icon" }),
994
+ sun: t("Sun", { context: "map icon" }),
995
+ cloud: t("Cloud", { context: "map icon" }),
996
+ umbrella: t("Umbrella", { context: "map icon" }),
997
+ flower: t("Flower", { context: "map icon" }),
998
+ leaf: t("Leaf", { context: "map icon" }),
999
+ rainbow: t("Rainbow", { context: "map icon" }),
1000
+ snowflake: t("Snow", { context: "map icon" }),
1001
+ fire: t("Fire", { context: "map icon" }),
1002
+ volcano: t("Volcano", { context: "map icon" }),
1003
+ heart: t("Heart", { context: "map icon" }),
1004
+ star: t("Star", { context: "map icon" }),
1005
+ flag: t("Flag", { context: "map icon" }),
1006
+ alert: t("Warning", { context: "map icon" }),
1007
+ info: t("Info", { context: "map icon" }),
1008
+ check: t("Check", { context: "map icon" }),
1009
+ "x-mark": t("X", { context: "map icon" }),
1010
+ zap: t("Zap", { context: "map icon" }),
1011
+ bell: t("Bell", { context: "map icon" }),
1012
+ peace: t("Peace", { context: "map icon" }),
1013
+ recycle: t("Recycle", { context: "map icon" }),
1014
+ radioactive: t("Radioactive", { context: "map icon" }),
1015
+ biohazard: t("Biohazard", { context: "map icon" }),
1016
+ camera: t("Camera", { context: "map icon" }),
1017
+ music: t("Music", { context: "map icon" }),
1018
+ film: t("Cinema", { context: "map icon" }),
1019
+ gamepad: t("Gaming", { context: "map icon" }),
1020
+ trophy: t("Trophy", { context: "map icon" }),
1021
+ medal: t("Medal", { context: "map icon" }),
1022
+ sports: t("Sports", { context: "map icon" }),
1023
+ basketball: t("Basketball", { context: "map icon" }),
1024
+ fishing: t("Fishing", { context: "map icon" }),
1025
+ art: t("Art", { context: "map icon" })
1026
+ });
1027
+ const everydayIconNames = (t) => ({
1028
+ briefcase: t("Office", { context: "map icon" }),
1029
+ wrench: t("Repair", { context: "map icon" }),
1030
+ hammer: t("Construction", { context: "map icon" }),
1031
+ gear: t("Settings", { context: "map icon" }),
1032
+ microscope: t("Science", { context: "map icon" }),
1033
+ "test-tube": t("Lab", { context: "map icon" }),
1034
+ computer: t("Computer", { context: "map icon" }),
1035
+ cart: t("Shopping", { context: "map icon" }),
1036
+ gift: t("Gift", { context: "map icon" }),
1037
+ package: t("Package", { context: "map icon" }),
1038
+ money: t("Money", { context: "map icon" }),
1039
+ "credit-card": t("Payment", { context: "map icon" }),
1040
+ phone: t("Phone", { context: "map icon" }),
1041
+ mail: t("Mail", { context: "map icon" }),
1042
+ globe: t("Web", { context: "map icon" }),
1043
+ satellite: t("Satellite", { context: "map icon" }),
1044
+ radio: t("Radio", { context: "map icon" }),
1045
+ tv: t("TV", { context: "map icon" }),
1046
+ user: t("Person", { context: "map icon" }),
1047
+ users: t("Group", { context: "map icon" }),
1048
+ baby: t("Baby", { context: "map icon" }),
1049
+ dog: t("Dog", { context: "map icon" }),
1050
+ cat: t("Cat", { context: "map icon" }),
1051
+ bird: t("Bird", { context: "map icon" }),
1052
+ horse: t("Horse", { context: "map icon" }),
1053
+ fish: t("Fish", { context: "map icon" }),
1054
+ anchor: t("Anchor", { context: "map icon" }),
1055
+ compass: t("Compass", { context: "map icon" }),
1056
+ lighthouse: t("Lighthouse", { context: "map icon" }),
1057
+ sailboat: t("Sailboat", { context: "map icon" }),
1058
+ lock: t("Lock", { context: "map icon" }),
1059
+ key: t("Key", { context: "map icon" }),
1060
+ shield: t("Shield", { context: "map icon" }),
1061
+ eye: t("Eye", { context: "map icon" }),
1062
+ search: t("Search", { context: "map icon" }),
1063
+ police: t("Police", { context: "map icon" }),
1064
+ siren: t("Siren", { context: "map icon" })
1065
+ });
1066
+ const markerIconNames = (t) => ({
1067
+ clock: t("Clock", { context: "map icon" }),
1068
+ calendar: t("Calendar", { context: "map icon" }),
1069
+ bookmark: t("Bookmark", { context: "map icon" }),
1070
+ tag: t("Tag", { context: "map icon" }),
1071
+ pushpin: t("Pin", { context: "map icon" }),
1072
+ "red-circle": t("Red Circle", { context: "map icon" }),
1073
+ "blue-circle": t("Blue Circle", { context: "map icon" }),
1074
+ "green-circle": t("Green Circle", { context: "map icon" }),
1075
+ "yellow-circle": t("Yellow Circle", { context: "map icon" }),
1076
+ "orange-circle": t("Orange Circle", { context: "map icon" }),
1077
+ "purple-circle": t("Purple Circle", { context: "map icon" }),
1078
+ "white-circle": t("White Circle", { context: "map icon" }),
1079
+ "black-circle": t("Black Circle", { context: "map icon" }),
1080
+ "red-square": t("Red Square", { context: "map icon" }),
1081
+ "blue-square": t("Blue Square", { context: "map icon" }),
1082
+ diamond: t("Diamond", { context: "map icon" }),
1083
+ "arrow-up": t("Arrow Up", { context: "map icon" }),
1084
+ "arrow-down": t("Arrow Down", { context: "map icon" }),
1085
+ "arrow-left": t("Arrow Left", { context: "map icon" }),
1086
+ "arrow-right": t("Arrow Right", { context: "map icon" }),
1087
+ target: t("Target", { context: "map icon" })
1088
+ });
1089
+ const iconNameLabels = (t) => ({
1090
+ ...placeIconNames(t),
1091
+ ...natureIconNames(t),
1092
+ ...everydayIconNames(t),
1093
+ ...markerIconNames(t)
1094
+ });
1095
+ const noticeToastLabels = (t) => ({
1096
+ screenshotFailed: t("Screenshot failed"),
1097
+ screenshotMapNotReady: t("Map is not ready yet."),
1098
+ screenshotNotRendered: t("The map did not render in time. Please try again."),
1099
+ noVisibleLayers: t("No visible layers"),
1100
+ noVisibleLayersDescription: t("Show at least one layer to draw features"),
1101
+ noLayerSelected: t("No layer selected"),
1102
+ noLayerSelectedDescription: t("Select an editable layer to clear features"),
1103
+ cannotClearHpLayer: t("Cannot clear high-performance layer"),
1104
+ cannotClearHpLayerDescription: t("Clear is not supported for HP layers. Delete individual features instead."),
1105
+ layerEmpty: t("Layer is empty"),
1106
+ layerEmptyDescription: t("No features to clear"),
1107
+ layerCleared: t("Layer cleared"),
1108
+ layerClearedDescription: (layerName) => t('Removed all features from "{layerName}"', { layerName }),
1109
+ terrainUnavailable: t("3D Terrain Unavailable"),
1110
+ terrainUnavailableDescription: t("Terrain features are disabled for this configuration."),
1111
+ terrainEnabled: t("3D Terrain Enabled"),
1112
+ terrainEnabledDescription: t("Tilt the map (right-click + drag or Ctrl + drag) to see the 3D effect."),
1113
+ exportFailed: t("Export failed"),
1114
+ exportFailedDescription: t("Could not prepare the download"),
1115
+ featuresAdded: t("Features added"),
1116
+ featuresAddedDescription: ({ count, layerName }) => t('{count, plural, one {Added # feature to "{layerName}"} other {Added # features to "{layerName}"}}', {
1117
+ count,
1118
+ layerName
1119
+ }),
1120
+ layerCreated: t("Layer created"),
1121
+ searchFailed: t("Search failed"),
1122
+ searchFailedDescription: t("Failed to search data source")
1123
+ });
1124
+ const fileToastLabels = (t) => ({
1125
+ mapRestored: t("Map restored"),
1126
+ mapRestoredDescription: ({ layerCount, featureCount }) => t(
1127
+ "{layerCount, plural, one {Restored # layer with {featureCount, plural, one {# feature} other {# features}}} other {Restored # layers with {featureCount, plural, one {# feature} other {# features}}}}",
1128
+ { layerCount, featureCount }
1129
+ ),
1130
+ featuresLoaded: t("Features loaded"),
1131
+ featuresLoadedDescription: (count) => t("{count, plural, one {Created layer with # feature} other {Created layer with # features}}", { count }),
1132
+ loadFailed: t("Load failed"),
1133
+ loadFailedDescription: t("Failed to load from workspace"),
1134
+ saved: t("Saved"),
1135
+ savedDescription: t("Saved entire map to workspace"),
1136
+ saveFailed: t("Save failed"),
1137
+ saveFailedDescription: t("Failed to save to workspace"),
1138
+ noFeatures: t("No features"),
1139
+ noFeaturesDescription: t("There are no features to fit to"),
1140
+ geojsonLoadFailed: t("Failed to load GeoJSON"),
1141
+ invalidFile: t("Invalid file"),
1142
+ emptyGeojson: t("Empty GeoJSON"),
1143
+ hpLayerCreatedDescription: ({ layerName, count, reprojectedFrom }) => reprojectedFrom === null ? t(
1144
+ '{count, plural, one {Created "{layerName}" with # feature (high-performance mode)} other {Created "{layerName}" with # features (high-performance mode)}}',
1145
+ { layerName, count }
1146
+ ) : t(
1147
+ '{count, plural, one {Created "{layerName}" with # feature (reprojected from {crs}) (high-performance mode)} other {Created "{layerName}" with # features (reprojected from {crs}) (high-performance mode)}}',
1148
+ { layerName, count, crs: reprojectedFrom }
1149
+ ),
1150
+ dataViewingLayer: t("Can't load into a data-viewing layer"),
1151
+ dataViewingLayerDescription: t(
1152
+ "Its features are fetched from data and aren't saved with the map. Load the file into another layer."
1153
+ ),
1154
+ hostOwnedLayer: t("Can't load into this layer"),
1155
+ hostOwnedLayerDescription: t("Another view owns its features. Load the file into another layer."),
1156
+ noLayerToLoadInto: t("No layer to load into"),
1157
+ noLayerToLoadIntoDescription: t("Create a layer first, then load the file again."),
1158
+ geojsonLoaded: t("GeoJSON loaded"),
1159
+ geojsonLoadedDescription: ({ count, reprojectedFrom, layerHidden }) => geojsonLoadedSentence(t, count, reprojectedFrom, layerHidden),
1160
+ layerAdded: t("Layer added"),
1161
+ layerAddedDescription: ({ layerName, count, reprojectedFrom }) => reprojectedFrom === null ? t(
1162
+ '{count, plural, one {Created "{layerName}" with # feature (high-performance)} other {Created "{layerName}" with # features (high-performance)}}',
1163
+ { layerName, count }
1164
+ ) : t(
1165
+ '{count, plural, one {Created "{layerName}" with # feature (reprojected from {crs}) (high-performance)} other {Created "{layerName}" with # features (reprojected from {crs}) (high-performance)}}',
1166
+ { layerName, count, crs: reprojectedFrom }
1167
+ )
1168
+ });
1169
+ function geojsonLoadedSentence(t, count, reprojectedFrom, layerHidden) {
1170
+ if (reprojectedFrom === null) {
1171
+ return layerHidden ? t("{count, plural, one {Added # feature (layer hidden)} other {Added # features (layer hidden)}}", { count }) : t("{count, plural, one {Added # feature} other {Added # features}}", { count });
1172
+ }
1173
+ return layerHidden ? t(
1174
+ "{count, plural, one {Added # feature (reprojected from {crs}) (layer hidden)} other {Added # features (reprojected from {crs}) (layer hidden)}}",
1175
+ { count, crs: reprojectedFrom }
1176
+ ) : t(
1177
+ "{count, plural, one {Added # feature (reprojected from {crs})} other {Added # features (reprojected from {crs})}}",
1178
+ { count, crs: reprojectedFrom }
1179
+ );
1180
+ }
1181
+ const toastLabels = (t) => ({ ...noticeToastLabels(t), ...fileToastLabels(t) });
1182
+ const featureCapLabels = (t) => ({
1183
+ title: t("Feature limit reached"),
1184
+ layersOverLimit: ({ layerCount, max, dropped }) => t(
1185
+ "{layerCount, plural, one {# layer was larger than the {max, number}-feature limit; {dropped, plural, one {# feature in total was not loaded.} other {# features in total were not loaded.}}} other {# layers were larger than the {max, number}-feature limit; {dropped, plural, one {# feature in total was not loaded.} other {# features in total were not loaded.}}}}",
1186
+ { layerCount, max, dropped }
1187
+ ),
1188
+ layerAlreadyHeld: ({ layerName, existing, max, kept, dropped }) => t(
1189
+ '"{layerName}" already held {existing, number} of its {max, number}-feature limit, so only {kept, number} more were added; {dropped, number} were skipped.',
1190
+ { layerName, existing, max, kept, dropped }
1191
+ ),
1192
+ firstFeaturesAdded: ({ kept, sourceCount, layerName, dropped }) => t(
1193
+ 'Only the first {kept, number} of {sourceCount, number} features were added to "{layerName}"; {dropped, number} were skipped (per-layer limit).',
1194
+ { kept, sourceCount, layerName, dropped }
1195
+ ),
1196
+ restoreNote: t("Re-saving this map will persist only the loaded features.")
1197
+ });
1198
+ const ingestAndDropLabels = (t) => ({
1199
+ ingest: {
1200
+ importing: (name) => t("Importing {name}…", { name }),
1201
+ rendering: (name) => t("Rendering {name}…", { name }),
1202
+ preparingDownload: (name) => t("Preparing download {name}…", { name }),
1203
+ progress: ({ received, total }) => t("{received, number} / {total, plural, one {# feature} other {# features}}", { received, total }),
1204
+ invalidFormat: t("Invalid GeoJSON format"),
1205
+ noFeatures: t("The file contains no features"),
1206
+ workerUnresponsive: t("Ingest worker unresponsive — the file could not be parsed"),
1207
+ workerCrashed: t("Ingest worker crashed")
1208
+ },
1209
+ dropZone: {
1210
+ title: t("Drop GeoJSON here"),
1211
+ subtitle: t("Add as new layer")
1212
+ }
1213
+ });
1214
+ const canvasLabels = (t) => ({
1215
+ defaultLayerName: t("Default Layer"),
1216
+ newTextLabel: t("New Label"),
1217
+ clusterOther: t("Other"),
1218
+ mapInitFailedTitle: t("Map Initialization Failed"),
1219
+ mapInitFailedSubtitle: t("Unable to load the interactive map"),
1220
+ mapInitFailedFallback: t("Failed to initialize map"),
1221
+ refreshPage: t("Refresh Page"),
1222
+ measureDistance: t("Distance:"),
1223
+ measureArea: t("Area:"),
1224
+ measureDistanceHint: t("Click points to measure"),
1225
+ measureAreaHint: t("Click 3+ points"),
1226
+ measureClearHint: t("(double-click to clear)"),
1227
+ timelineToggle: t("Timeline", { context: "map timebar toggle" }),
1228
+ layersToggle: t("Layers"),
1229
+ layersToggleAriaLabel: t("Toggle layers panel"),
1230
+ unsavedCount: (count) => t("{count, plural, one {# unsaved} other {# unsaved}}", { count }),
1231
+ createPointFeature: t("Create new point feature"),
1232
+ noEditableLayer: t("No editable layer"),
1233
+ tooltipId: t("ID:"),
1234
+ morePointsHint: t("More points overlap here: zoom in to reach them"),
1235
+ traceDuration: t("Duration:"),
1236
+ traceDistance: t("Distance:"),
1237
+ traceAvgSpeed: t("Avg Speed:"),
1238
+ traceGroup: (group) => t("Group: {group}", { group }),
1239
+ statusFeatureCount: (count) => t("{count, plural, one {# feature} other {# features}}", { count }),
1240
+ statusSelectedCount: (count) => t("{count, plural, one {# selected} other {# selected}}", { count })
1241
+ });
1242
+ const mapOptionLabels = (t) => ({
1243
+ title: t("Map Options"),
1244
+ load: t("Load"),
1245
+ uploadMap: t("Upload Map"),
1246
+ loadFromWorkspace: t("Load Map from workspace"),
1247
+ save: t("Save"),
1248
+ downloadMap: t("Download Map"),
1249
+ saveToWorkspace: t("Save Map to workspace"),
1250
+ autoShowLabels: t("Auto-show labels"),
1251
+ autoLabelThreshold: t("When features on screen"),
1252
+ visibleFeatures: t("Visible:", { context: "features on screen" }),
1253
+ labelsShown: t("(shown)", { context: "map labels" }),
1254
+ labelsHidden: t("(hidden)", { context: "map labels" }),
1255
+ fitToAllFeatures: t("Fit Map to All Features"),
1256
+ terrain3d: t("3D", { context: "terrain toggle" }),
1257
+ basemapStreets: t("Streets"),
1258
+ basemapSatellite: t("Satellite", { context: "basemap" }),
1259
+ basemapDark: t("Dark")
1260
+ });
1261
+ const layersPanelLabels = (t) => ({
1262
+ title: t("Layers"),
1263
+ createLayer: t("Create new layer"),
1264
+ loadAsNewLayer: t("Load GeoJSON from desktop as new layer"),
1265
+ searchAndAdd: t("Search and add..."),
1266
+ groupLayerCount: (count) => t("{count, plural, one {# layer} other {# layers}}", { count }),
1267
+ unsavedCount: (count) => t("{count, plural, one {# unsaved} other {# unsaved}}", { count }),
1268
+ hpLayerTitle: t("High-Performance Layer"),
1269
+ hpLayerDescription: t("Optimized for large datasets. Geometry cannot be moved or reshaped."),
1270
+ editingThisLayer: t("This is the layer being edited"),
1271
+ clickToEditLayer: t("Click to edit this layer"),
1272
+ loadGeojson: t("Load GeoJSON from desktop"),
1273
+ saveGeojson: t("Save GeoJSON to desktop"),
1274
+ neverHideLabels: t("Never hide labels"),
1275
+ labelsOffForLayer: t("Labels are turned off for this layer"),
1276
+ neverHideLabelsHint: t("Show every label even when the map is crowded"),
1277
+ fitMapToLayer: t("Fit Map to Layer"),
1278
+ deleteLayer: t("Delete Layer"),
1279
+ deleteLayerConfirmTitle: (layerName) => t('Delete layer "{layerName}"?', { layerName }),
1280
+ deleteLayerConfirmContent: t("This will delete the layer and all its features."),
1281
+ deleteLayerConfirmOk: t("Delete"),
1282
+ deleteLayerConfirmCancel: t("Cancel"),
1283
+ moveSelectedHere: (count) => t("{count, plural, one {Move # selected here} other {Move # selected here}}", { count })
1284
+ });
1285
+ const pointLayerSettingLabels = (t) => ({
1286
+ pointFeatures: t("Point Features"),
1287
+ traceLines: t("Trace Lines"),
1288
+ connectAllPoints: t("Connect all points"),
1289
+ groupBy: (field) => t("Group by {field}", { field }),
1290
+ heatmap: t("Heatmap"),
1291
+ intensity: t("Intensity"),
1292
+ radius: t("Radius"),
1293
+ clustering: t("Clustering"),
1294
+ simpleCount: t("Simple count"),
1295
+ pieBy: (field) => t("Pie by {field}", { field }),
1296
+ showPointDots: t("Show point dots"),
1297
+ countByField: t("Count by field"),
1298
+ selectNumericField: t("Select numeric field..."),
1299
+ colorBubblesByValue: t("Color bubbles by value"),
1300
+ altitudeDisplay: t("Altitude Display"),
1301
+ altitude3d: t("3D (show altitude)"),
1302
+ altitudeFlat: t("Flat (ignore altitude)"),
1303
+ altitudeBoth: t("Both (3D + flat shadow)"),
1304
+ pointIcon: t("Point Icon")
1305
+ });
1306
+ const visualLayerSettingLabels = (t) => ({
1307
+ visualSettings: t("Visual Settings"),
1308
+ labels: t("Labels", { context: "map labels" }),
1309
+ labelFromName: t("Use name property"),
1310
+ labelFromField: t("Use field..."),
1311
+ labelFixedText: t("Fixed text..."),
1312
+ selectField: t("Select field..."),
1313
+ enterLabelText: t("Enter label text..."),
1314
+ size: t("Size", { context: "map symbol size" }),
1315
+ defaultSize: t("Default size"),
1316
+ sizeByField: t("Size by field..."),
1317
+ overrideSize: t("Override size..."),
1318
+ color: t("Color", { context: "map symbol color" }),
1319
+ useFeatureColor: t("Use feature color"),
1320
+ colorByField: t("Color by field..."),
1321
+ fixedColor: t("Fixed color..."),
1322
+ categories: t("Categories"),
1323
+ gradient: t("Gradient"),
1324
+ legend: t("Legend"),
1325
+ legendTop: (count) => t("Legend (top {count})", { count }),
1326
+ legendSampled: t("Legend (sampled)"),
1327
+ filterValues: t("Filter values…"),
1328
+ noMatches: t("No matches"),
1329
+ showLess: t("Show less"),
1330
+ showAll: (count) => t("Show all ({count})", { count }),
1331
+ legendCount: (count) => t("{count, number}", { count }),
1332
+ legendRowTitle: (value, count) => t("{value} ({count, number})", { value, count }),
1333
+ legendRowShare: (value, count, share) => t("{value} ({count, number}, {share, number, percent})", { value, count, share })
1334
+ });
1335
+ const pointIconLabels = (t) => ({
1336
+ iconSameForAll: t("Same for all", { context: "map point icon" }),
1337
+ iconByFieldValue: t("By field value", { context: "map point icon" }),
1338
+ icons: t("Icons"),
1339
+ iconsAssigning: t("Assigning icons…"),
1340
+ iconsAssignedByAi: t("Icons assigned by AI"),
1341
+ iconsAssignedByKeywords: t("Icons assigned by keyword match"),
1342
+ reassignIcons: t("Reassign", { context: "map point icons" }),
1343
+ reassignIconsWithAi: t("Let the AI assign every icon again"),
1344
+ reassignIconsByKeywords: t("Assign every icon again by keyword match (no AI connected)"),
1345
+ iconAiUnavailable: (error) => t("AI unavailable, used keyword match ({error})", { error }),
1346
+ iconAiNoUsableIcon: t("The AI suggested no icon the map can draw, used keyword match"),
1347
+ assignNewIcons: (count) => t("{count, plural, one {Assign # new value} other {Assign # new values}}", { count }),
1348
+ iconOtherValues: t("All other values", { context: "map point icon" }),
1349
+ iconEmptyOrUnassigned: t("Empty or unassigned", { context: "map point icon" })
1350
+ });
1351
+ const layerSettingLabels = (t) => ({
1352
+ ...pointLayerSettingLabels(t),
1353
+ ...visualLayerSettingLabels(t),
1354
+ ...pointIconLabels(t)
1355
+ });
1356
+ const drawingToolbarLabels = (t) => ({
1357
+ drawingTools: t("Drawing tools"),
1358
+ clickSelect: t("Click Select"),
1359
+ rectangleSelect: t("Rectangle Select"),
1360
+ polygonSelect: t("Polygon Select"),
1361
+ circleSelect: t("Circle Select"),
1362
+ selectTool: t("Select Tool"),
1363
+ switchSelectionMode: t("Switch selection mode"),
1364
+ filterArea: t("Filter Area"),
1365
+ clearFilter: t("Clear Filter"),
1366
+ measureDistance: t("Measure Distance"),
1367
+ measureArea: t("Measure Area"),
1368
+ switchMeasureMode: t("Switch measure mode"),
1369
+ searchAndNavigate: t("Search & Navigate"),
1370
+ fitToData: t("Fit to Data"),
1371
+ noEditableLayer: t("No editable layer"),
1372
+ noEditableLayerHint: t("Select an editable layer with the pencil icon to enable editing"),
1373
+ editMode: t("Edit Mode"),
1374
+ searchAndAdd: t("Search and Add"),
1375
+ dropPoint: t("Drop Point"),
1376
+ drawLine: t("Draw Line"),
1377
+ drawPolygon: t("Draw Polygon"),
1378
+ drawRectangle: t("Draw Rectangle"),
1379
+ drawPolygonOrRectangle: t("Draw Polygon/Rectangle"),
1380
+ drawPolygonOrRectangleAriaLabel: t("Draw Polygon or Rectangle"),
1381
+ addText: t("Add Text"),
1382
+ drawArrow: t("Draw Arrow"),
1383
+ drawCircle: t("Draw Circle"),
1384
+ undo: t("Undo"),
1385
+ redo: t("Redo"),
1386
+ deleteSelected: (count) => t("Delete selected ({count})", { count }),
1387
+ deleteSelectedAriaLabel: t("Delete selected features"),
1388
+ deleteKey: t("Del", { context: "keyboard key" }),
1389
+ undoShortcut: t("Ctrl+Z", { context: "keyboard shortcut" }),
1390
+ redoShortcut: t("Ctrl+Y", { context: "keyboard shortcut" }),
1391
+ clearAll: (count) => t("Clear all ({count})", { count }),
1392
+ moreTools: t("More tools"),
1393
+ clearAllConfirmTitle: t("Clear all features?"),
1394
+ clearAllConfirmContent: (count) => t(
1395
+ "{count, plural, one {This will remove all # feature from the map. This action cannot be undone.} other {This will remove all # features from the map. This action cannot be undone.}}",
1396
+ { count }
1397
+ ),
1398
+ clearAllConfirmOk: t("Clear all", { context: "remove every map feature" }),
1399
+ clearAllConfirmCancel: t("Cancel")
1400
+ });
1401
+ const navigationLabels = (t) => ({
1402
+ navigate: {
1403
+ title: t("Navigate To"),
1404
+ addressPlaceholder: t("Search address..."),
1405
+ searchAddress: t("Go", { context: "search the address" }),
1406
+ orCoordinates: t("or coordinates"),
1407
+ latitude: t("Lat"),
1408
+ longitude: t("Lng"),
1409
+ latitudePlaceholder: t("-90 to 90"),
1410
+ longitudePlaceholder: t("-180 to 180"),
1411
+ dropPoint: t("Drop", { context: "place a point on the map" }),
1412
+ goToCoordinates: t("Go", { context: "fly to the coordinates" }),
1413
+ locationNotFound: t("Location not found"),
1414
+ locationNotFoundDescription: t("Try a different search term"),
1415
+ searchError: t("Search error"),
1416
+ searchErrorDescription: t("Could not search for location. Check your connection.")
1417
+ },
1418
+ coordinates: {
1419
+ invalidCoordinates: t("Invalid coordinates"),
1420
+ invalidCoordinatesDescription: t("Please enter valid latitude and longitude values"),
1421
+ invalidLatitude: t("Invalid latitude"),
1422
+ invalidLongitude: t("Invalid longitude"),
1423
+ latitudeOutOfRange: t("Latitude must be between -90 and 90"),
1424
+ longitudeOutOfRange: t("Longitude must be between -180 and 180"),
1425
+ notANumber: t("Please enter a valid number")
1426
+ },
1427
+ featureSearch: {
1428
+ title: t("Search Features"),
1429
+ placeholder: t("Search features..."),
1430
+ titlesMode: t("Titles", { context: "search feature names" }),
1431
+ fullJsonMode: t("Full JSON"),
1432
+ /** `more` is true when the result list stopped at its cap. */
1433
+ resultCount: ({ count, more }) => more ? t("{count, number}+ found", { count }) : t("{count, number} found", { count }),
1434
+ totalCount: (count) => t("{count, number} total", { count }),
1435
+ noResults: t("No features found"),
1436
+ typeToSearch: (count) => t("{count, plural, one {Type to search across # feature} other {Type to search across # features}}", {
1437
+ count
1438
+ }),
1439
+ untitledFeature: t("Feature", { context: "untitled map feature" }),
1440
+ unknownGeometry: t("Unknown")
1441
+ }
1442
+ });
1443
+ const propertiesPanelLabels = (t) => ({
1444
+ showingFirstSelected: ({ shown, total }) => t("Showing the first {shown, number} of {total, number} selected features", { shown, total }),
1445
+ previousOverlappingPoint: t("Previous overlapping point"),
1446
+ nextOverlappingPoint: t("Next overlapping point"),
1447
+ selectedFeatures: (count) => t("{count, plural, one {# selected feature} other {# selected features}}", { count }),
1448
+ untitledFeature: t("Feature", { context: "untitled map feature" }),
1449
+ hpLayerHint: t("High Performance Layer — does not allow moving / geometrical editing of features"),
1450
+ hpBadge: t("HP", { context: "high-performance layer" }),
1451
+ viewBadge: t("View", { context: "read-only mode" }),
1452
+ openInNewTab: t("Open in new tab"),
1453
+ actions: t("Actions"),
1454
+ copyToLayer: t("Copy to layer"),
1455
+ moveToLayer: t("Move to layer"),
1456
+ untitledLayer: t("Untitled", { context: "map layer" }),
1457
+ newLayer: t("New layer…"),
1458
+ newLayerPrompt: t("New layer name"),
1459
+ changeIcon: t("Change icon"),
1460
+ setIcon: t("Set icon"),
1461
+ deleteFeatures: (count) => t("{count, plural, one {Delete # feature} other {Delete # features}}", { count }),
1462
+ deleteFeature: t("Delete feature"),
1463
+ entityCards: t("Entity Cards"),
1464
+ entityCardsCount: (count) => t("Entity Cards ({count})", { count }),
1465
+ properties: t("Properties"),
1466
+ noEntityCardProvider: t("No entity card provider registered"),
1467
+ selectSingleToSeeProperties: t("Select a single feature to see/set properties"),
1468
+ selectSingleToEdit: t("Select a single feature to edit properties."),
1469
+ pointDetail: t("Point Detail"),
1470
+ layer: t("Layer:"),
1471
+ octostarRecord: t("Octostar record"),
1472
+ localMapFeature: t("Local map feature"),
1473
+ unsaved: t("Unsaved", { context: "map feature" }),
1474
+ createEntity: t("Create entity"),
1475
+ untitledRecord: t("Untitled", { context: "record" }),
1476
+ refreshFromRecord: t("Refresh from record"),
1477
+ recordFields: t("Record Fields"),
1478
+ id: t("ID:"),
1479
+ featureSaved: t("Feature saved"),
1480
+ savedTo: (workspace) => t("Saved to {workspace}", { workspace }),
1481
+ saveFailed: t("Save failed"),
1482
+ saveFeatureFailed: t("Failed to save feature"),
1483
+ refreshed: t("Refreshed", { context: "record" }),
1484
+ refreshedDescription: t("Properties updated from record"),
1485
+ refreshFailed: t("Refresh failed")
1486
+ });
1487
+ const featureFieldLabels = (t) => ({
1488
+ label: t("Label", { context: "map text" }),
1489
+ name: t("Name", { context: "map feature" }),
1490
+ enterLabel: t("Enter label..."),
1491
+ featureName: t("Feature name"),
1492
+ noName: t("No name"),
1493
+ icon: t("Icon", { context: "map point" }),
1494
+ type: t("Type", { context: "entity type" }),
1495
+ noType: t("No type"),
1496
+ latLng: t("Lat / Lng"),
1497
+ centroidHint: t("Lat and Lng refer to the centroid of this feature"),
1498
+ latitude: t("Latitude"),
1499
+ longitude: t("Longitude"),
1500
+ temporal: t("Temporal", { context: "feature dates" }),
1501
+ dateCount: (count) => t("{count, plural, one {# date} other {# dates}}", { count }),
1502
+ start: t("Start", { context: "feature start date" }),
1503
+ end: t("End", { context: "feature end date" }),
1504
+ style: t("Style"),
1505
+ fontSize: t("Font Size"),
1506
+ fontColor: t("Font Color"),
1507
+ fontWeight: t("Font Weight"),
1508
+ fontWeightNormal: t("Normal", { context: "font weight" }),
1509
+ fontWeightBold: t("Bold", { context: "font weight" }),
1510
+ arrowSize: t("Arrow Size"),
1511
+ stroke: t("Stroke", { context: "map outline" }),
1512
+ strokeColor: t("Stroke Color"),
1513
+ strokeWidth: t("Stroke Width"),
1514
+ strokeOpacity: t("Stroke Opacity"),
1515
+ fill: t("Fill", { context: "map area" }),
1516
+ fillColor: t("Fill Color"),
1517
+ fillOpacity: t("Fill Opacity"),
1518
+ resetFillToStroke: t("Reset fill to the stroke colour"),
1519
+ iconSize: t("Size", { context: "map symbol size" }),
1520
+ propertyKey: t("Key"),
1521
+ propertyValue: t("Value"),
1522
+ newProperty: t("New property…")
1523
+ });
1524
+ const timebarLabels = (t) => ({
1525
+ play: t("Play"),
1526
+ pause: t("Pause"),
1527
+ reset: t("Reset timeline"),
1528
+ cumulative: t("Cumulative: what has appeared stays"),
1529
+ toggle: t("Toggle timeline"),
1530
+ featureCount: (count) => t("{count, plural, one {# feature} other {# features}}", { count }),
1531
+ selectedCount: ({ selected, total }) => t("{selected, number} of {total, number} selected", { selected, total }),
1532
+ binEvents: (count) => t("{count, plural, one {# event} other {# events}}", { count }),
1533
+ binEventsWithSelection: ({ count, selected }) => t("{count, plural, one {# event ({selected, number} selected)} other {# events ({selected, number} selected)}}", {
1534
+ count,
1535
+ selected
1536
+ })
1537
+ });
1538
+ const actionPanelLabels = (t) => ({
1539
+ groupLabel: t("File actions"),
1540
+ saveTooltip: t("Download features as GeoJSON"),
1541
+ saveAriaLabel: t("Save as GeoJSON"),
1542
+ save: t("Save GeoJSON"),
1543
+ loadTooltip: t("Import features from GeoJSON file"),
1544
+ loadAriaLabel: t("Load GeoJSON file"),
1545
+ load: t("Load GeoJSON")
1546
+ });
1547
+ const DEFAULT_LAYER_ID = "default";
1548
+ const DEFAULT_LAYER_NAME = "Default Layer";
1549
+ const buildMapLabels = (t) => ({
1550
+ canvas: canvasLabels(t),
1551
+ toasts: toastLabels(t),
1552
+ featureCap: featureCapLabels(t),
1553
+ ...ingestAndDropLabels(t),
1554
+ mapOptions: mapOptionLabels(t),
1555
+ layersPanel: layersPanelLabels(t),
1556
+ layerSettings: layerSettingLabels(t),
1557
+ drawingToolbar: drawingToolbarLabels(t),
1558
+ ...navigationLabels(t),
1559
+ propertiesPanel: propertiesPanelLabels(t),
1560
+ featureFields: featureFieldLabels(t),
1561
+ iconPicker: iconPickerLabels(t),
1562
+ iconCategories: iconCategoryLabels(t),
1563
+ iconNames: iconNameLabels(t),
1564
+ timebar: timebarLabels(t),
1565
+ actionPanel: actionPanelLabels(t)
1566
+ });
1567
+ const labelsByLocale = /* @__PURE__ */ new Map();
1568
+ function mapLabelsFor(locale) {
1569
+ const shown = isMapLocaleReady(locale) ? locale : "en";
1570
+ let labels = labelsByLocale.get(shown);
1571
+ if (!labels) {
1572
+ labels = buildMapLabels(translatorFor(shown));
1573
+ labelsByLocale.set(shown, labels);
1574
+ }
1575
+ return labels;
1576
+ }
1577
+ const DEFAULT_MAP_LABELS = mapLabelsFor("en");
1578
+ const MapLabelsContext = createContext(null);
1579
+ function shownLayerName(layer, labels) {
1580
+ return layer.name === DEFAULT_LAYER_NAME ? labels.defaultLayerName : layer.name;
1581
+ }
1582
+ function useMapLabels() {
1583
+ const provided = useContext(MapLabelsContext);
1584
+ const locale = useMapLocale();
1585
+ return provided ?? mapLabelsFor(locale);
1586
+ }
803
1587
  const HOST_ICON_FULL_ZOOM_PROP = "iconFullZoom";
804
1588
  const HOST_ICON_MIN_ZOOM_PROP = "iconMinZoom";
805
1589
  const HOST_ICON_MIN_SCALE_PROP = "iconMinScale";
@@ -821,588 +1605,6 @@ function hostIconSizeMultiplier(size, fieldPosition) {
821
1605
  if ((size == null ? void 0 : size.mode) === "field" && fieldPosition !== null) return 0.6 + fieldPosition * 0.9;
822
1606
  return 1;
823
1607
  }
824
- const ICON_LIST = [
825
- // Location & Places
826
- { id: "map-pin", emoji: "📍", name: "Map Pin", category: "places" },
827
- { id: "home", emoji: "🏠", name: "Home", category: "places" },
828
- { id: "building", emoji: "🏢", name: "Building", category: "places" },
829
- { id: "store", emoji: "🏪", name: "Store", category: "places" },
830
- { id: "factory", emoji: "🏭", name: "Factory", category: "places" },
831
- { id: "construction", emoji: "🏗️", name: "Construction", category: "places" },
832
- { id: "church", emoji: "⛪", name: "Church", category: "places" },
833
- { id: "hospital", emoji: "🏥", name: "Hospital", category: "places" },
834
- { id: "school", emoji: "🏫", name: "School", category: "places" },
835
- { id: "graduation", emoji: "🎓", name: "University", category: "places" },
836
- { id: "library", emoji: "📚", name: "Library", category: "places" },
837
- { id: "landmark", emoji: "🏛️", name: "Landmark", category: "places" },
838
- { id: "castle", emoji: "🏰", name: "Castle", category: "places" },
839
- { id: "mosque", emoji: "🕌", name: "Mosque", category: "places" },
840
- { id: "stadium", emoji: "🏟️", name: "Stadium", category: "places" },
841
- { id: "tent", emoji: "⛺", name: "Camping", category: "places" },
842
- // Transport
843
- { id: "car", emoji: "🚗", name: "Car", category: "transport" },
844
- { id: "bus", emoji: "🚌", name: "Bus", category: "transport" },
845
- { id: "train", emoji: "🚂", name: "Train", category: "transport" },
846
- { id: "plane", emoji: "✈️", name: "Plane", category: "transport" },
847
- { id: "ship", emoji: "🚢", name: "Ship", category: "transport" },
848
- { id: "bike", emoji: "🚲", name: "Bike", category: "transport" },
849
- { id: "fuel", emoji: "⛽", name: "Gas Station", category: "transport" },
850
- { id: "helicopter", emoji: "🚁", name: "Helicopter", category: "transport" },
851
- { id: "rocket", emoji: "🚀", name: "Rocket", category: "transport" },
852
- { id: "motorcycle", emoji: "🏍️", name: "Motorcycle", category: "transport" },
853
- { id: "taxi", emoji: "🚕", name: "Taxi", category: "transport" },
854
- { id: "truck", emoji: "🚛", name: "Truck", category: "transport" },
855
- // Food & Drink
856
- { id: "utensils", emoji: "🍴", name: "Restaurant", category: "food" },
857
- { id: "coffee", emoji: "☕", name: "Coffee", category: "food" },
858
- { id: "beer", emoji: "🍺", name: "Bar", category: "food" },
859
- { id: "wine", emoji: "🍷", name: "Wine", category: "food" },
860
- { id: "pizza", emoji: "🍕", name: "Pizza", category: "food" },
861
- { id: "ice-cream", emoji: "🍦", name: "Ice Cream", category: "food" },
862
- { id: "apple", emoji: "🍎", name: "Apple", category: "food" },
863
- { id: "cake", emoji: "🎂", name: "Cake", category: "food" },
864
- { id: "hamburger", emoji: "🍔", name: "Burger", category: "food" },
865
- // Nature
866
- { id: "trees", emoji: "🌲", name: "Forest", category: "nature" },
867
- { id: "mountain", emoji: "⛰️", name: "Mountain", category: "nature" },
868
- { id: "waves", emoji: "🌊", name: "Water", category: "nature" },
869
- { id: "sun", emoji: "☀️", name: "Sun", category: "nature" },
870
- { id: "cloud", emoji: "☁️", name: "Cloud", category: "nature" },
871
- { id: "umbrella", emoji: "🌂", name: "Umbrella", category: "nature" },
872
- { id: "flower", emoji: "🌸", name: "Flower", category: "nature" },
873
- { id: "leaf", emoji: "🍃", name: "Leaf", category: "nature" },
874
- { id: "rainbow", emoji: "🌈", name: "Rainbow", category: "nature" },
875
- { id: "snowflake", emoji: "❄️", name: "Snow", category: "nature" },
876
- { id: "fire", emoji: "🔥", name: "Fire", category: "nature" },
877
- { id: "volcano", emoji: "🌋", name: "Volcano", category: "nature" },
878
- // Symbols & Markers
879
- { id: "heart", emoji: "❤️", name: "Heart", category: "symbols" },
880
- { id: "star", emoji: "⭐", name: "Star", category: "symbols" },
881
- { id: "flag", emoji: "🚩", name: "Flag", category: "symbols" },
882
- { id: "alert", emoji: "⚠️", name: "Warning", category: "symbols" },
883
- { id: "info", emoji: "ℹ️", name: "Info", category: "symbols" },
884
- { id: "check", emoji: "✅", name: "Check", category: "symbols" },
885
- { id: "x-mark", emoji: "❌", name: "X", category: "symbols" },
886
- { id: "zap", emoji: "⚡", name: "Zap", category: "symbols" },
887
- { id: "bell", emoji: "🔔", name: "Bell", category: "symbols" },
888
- { id: "peace", emoji: "☮️", name: "Peace", category: "symbols" },
889
- { id: "recycle", emoji: "♻️", name: "Recycle", category: "symbols" },
890
- { id: "radioactive", emoji: "☢️", name: "Radioactive", category: "symbols" },
891
- { id: "biohazard", emoji: "☣️", name: "Biohazard", category: "symbols" },
892
- // Activities
893
- { id: "camera", emoji: "📷", name: "Camera", category: "activities" },
894
- { id: "music", emoji: "🎵", name: "Music", category: "activities" },
895
- { id: "film", emoji: "🎬", name: "Cinema", category: "activities" },
896
- { id: "gamepad", emoji: "🎮", name: "Gaming", category: "activities" },
897
- { id: "trophy", emoji: "🏆", name: "Trophy", category: "activities" },
898
- { id: "medal", emoji: "🎖️", name: "Medal", category: "activities" },
899
- { id: "sports", emoji: "⚽", name: "Sports", category: "activities" },
900
- { id: "basketball", emoji: "🏀", name: "Basketball", category: "activities" },
901
- { id: "fishing", emoji: "🎣", name: "Fishing", category: "activities" },
902
- { id: "art", emoji: "🎨", name: "Art", category: "activities" },
903
- // Work & Tools
904
- { id: "briefcase", emoji: "💼", name: "Office", category: "work" },
905
- { id: "wrench", emoji: "🔧", name: "Repair", category: "work" },
906
- { id: "hammer", emoji: "🔨", name: "Construction", category: "work" },
907
- { id: "gear", emoji: "⚙️", name: "Settings", category: "work" },
908
- { id: "microscope", emoji: "🔬", name: "Science", category: "work" },
909
- { id: "test-tube", emoji: "🧪", name: "Lab", category: "work" },
910
- { id: "computer", emoji: "💻", name: "Computer", category: "work" },
911
- // Shopping
912
- { id: "cart", emoji: "🛒", name: "Shopping", category: "shopping" },
913
- { id: "gift", emoji: "🎁", name: "Gift", category: "shopping" },
914
- { id: "package", emoji: "📦", name: "Package", category: "shopping" },
915
- { id: "money", emoji: "💰", name: "Money", category: "shopping" },
916
- { id: "credit-card", emoji: "💳", name: "Payment", category: "shopping" },
917
- // Communication
918
- { id: "phone", emoji: "📱", name: "Phone", category: "communication" },
919
- { id: "mail", emoji: "📧", name: "Mail", category: "communication" },
920
- { id: "globe", emoji: "🌐", name: "Web", category: "communication" },
921
- { id: "satellite", emoji: "📡", name: "Satellite", category: "communication" },
922
- { id: "radio", emoji: "📻", name: "Radio", category: "communication" },
923
- { id: "tv", emoji: "📺", name: "TV", category: "communication" },
924
- // People & Animals
925
- { id: "user", emoji: "👤", name: "Person", category: "people" },
926
- { id: "users", emoji: "👥", name: "Group", category: "people" },
927
- { id: "baby", emoji: "👶", name: "Baby", category: "people" },
928
- { id: "dog", emoji: "🐕", name: "Dog", category: "people" },
929
- { id: "cat", emoji: "🐈", name: "Cat", category: "people" },
930
- { id: "bird", emoji: "🐦", name: "Bird", category: "people" },
931
- { id: "horse", emoji: "🐴", name: "Horse", category: "people" },
932
- { id: "fish", emoji: "🐟", name: "Fish", category: "people" },
933
- // Maritime & Navigation
934
- { id: "anchor", emoji: "⚓", name: "Anchor", category: "maritime" },
935
- { id: "compass", emoji: "🧭", name: "Compass", category: "maritime" },
936
- { id: "lighthouse", emoji: "🗼", name: "Lighthouse", category: "maritime" },
937
- { id: "sailboat", emoji: "⛵", name: "Sailboat", category: "maritime" },
938
- // Security
939
- { id: "lock", emoji: "🔒", name: "Lock", category: "security" },
940
- { id: "key", emoji: "🔑", name: "Key", category: "security" },
941
- { id: "shield", emoji: "🛡️", name: "Shield", category: "security" },
942
- { id: "eye", emoji: "👁️", name: "Eye", category: "security" },
943
- { id: "search", emoji: "🔍", name: "Search", category: "security" },
944
- { id: "police", emoji: "🚔", name: "Police", category: "security" },
945
- { id: "siren", emoji: "🚨", name: "Siren", category: "security" },
946
- // Time & Organization
947
- { id: "clock", emoji: "🕐", name: "Clock", category: "time" },
948
- { id: "calendar", emoji: "📅", name: "Calendar", category: "time" },
949
- { id: "bookmark", emoji: "🔖", name: "Bookmark", category: "time" },
950
- { id: "tag", emoji: "🏷️", name: "Tag", category: "time" },
951
- { id: "pushpin", emoji: "📌", name: "Pin", category: "time" },
952
- // Shapes & Geometric
953
- { id: "red-circle", emoji: "🔴", name: "Red Circle", category: "shapes" },
954
- { id: "blue-circle", emoji: "🔵", name: "Blue Circle", category: "shapes" },
955
- { id: "green-circle", emoji: "🟢", name: "Green Circle", category: "shapes" },
956
- { id: "yellow-circle", emoji: "🟡", name: "Yellow Circle", category: "shapes" },
957
- { id: "orange-circle", emoji: "🟠", name: "Orange Circle", category: "shapes" },
958
- { id: "purple-circle", emoji: "🟣", name: "Purple Circle", category: "shapes" },
959
- { id: "white-circle", emoji: "⚪", name: "White Circle", category: "shapes" },
960
- { id: "black-circle", emoji: "⚫", name: "Black Circle", category: "shapes" },
961
- { id: "red-square", emoji: "🟥", name: "Red Square", category: "shapes" },
962
- { id: "blue-square", emoji: "🟦", name: "Blue Square", category: "shapes" },
963
- { id: "diamond", emoji: "💎", name: "Diamond", category: "shapes" },
964
- // Arrows
965
- { id: "arrow-up", emoji: "⬆️", name: "Arrow Up", category: "arrows" },
966
- { id: "arrow-down", emoji: "⬇️", name: "Arrow Down", category: "arrows" },
967
- { id: "arrow-left", emoji: "⬅️", name: "Arrow Left", category: "arrows" },
968
- { id: "arrow-right", emoji: "➡️", name: "Arrow Right", category: "arrows" },
969
- { id: "target", emoji: "🎯", name: "Target", category: "arrows" }
970
- ];
971
- const ICONS = [...ICON_LIST];
972
- const EMOJI_BY_ID = new Map(ICONS.map((i) => [i.id, i.emoji]));
973
- const plural = (count, word) => `${word}${count !== 1 ? "s" : ""}`;
974
- const DEFAULT_LAYER_ID = "default";
975
- const DEFAULT_LAYER_NAME = "Default Layer";
976
- const iconNames = Object.fromEntries(ICONS.map((icon) => [icon.id, icon.name]));
977
- const iconCategories = {
978
- places: "Places",
979
- transport: "Transport",
980
- food: "Food",
981
- nature: "Nature",
982
- symbols: "Symbols",
983
- activities: "Activities",
984
- work: "Work",
985
- shopping: "Shopping",
986
- communication: "Communication",
987
- people: "People",
988
- maritime: "Maritime",
989
- security: "Security",
990
- time: "Time",
991
- shapes: "Shapes",
992
- arrows: "Arrows"
993
- };
994
- const DEFAULT_MAP_LABELS = {
995
- canvas: {
996
- defaultLayerName: DEFAULT_LAYER_NAME,
997
- newTextLabel: "New Label",
998
- clusterOther: "Other",
999
- mapInitFailedTitle: "Map Initialization Failed",
1000
- mapInitFailedSubtitle: "Unable to load the interactive map",
1001
- mapInitFailedFallback: "Failed to initialize map",
1002
- refreshPage: "Refresh Page",
1003
- measureDistance: "Distance:",
1004
- measureArea: "Area:",
1005
- measureDistanceHint: "Click points to measure",
1006
- measureAreaHint: "Click 3+ points",
1007
- measureClearHint: "(double-click to clear)",
1008
- timelineToggle: "Timeline",
1009
- layersToggle: "Layers",
1010
- layersToggleAriaLabel: "Toggle layers panel",
1011
- unsavedCount: (count) => `${count} unsaved`,
1012
- createPointFeature: "Create new point feature",
1013
- noEditableLayer: "No editable layer",
1014
- tooltipId: "ID:",
1015
- morePointsHint: "More points overlap here: zoom in to reach them",
1016
- traceDuration: "Duration:",
1017
- traceDistance: "Distance:",
1018
- traceAvgSpeed: "Avg Speed:",
1019
- traceGroup: (group) => `Group: ${group}`,
1020
- statusFeatureCount: (count) => `${count} ${plural(count, "feature")}`,
1021
- statusSelectedCount: (count) => `${count} selected`
1022
- },
1023
- toasts: {
1024
- screenshotFailed: "Screenshot failed",
1025
- screenshotMapNotReady: "Map is not ready yet.",
1026
- screenshotNotRendered: "The map did not render in time. Please try again.",
1027
- noVisibleLayers: "No visible layers",
1028
- noVisibleLayersDescription: "Show at least one layer to draw features",
1029
- noLayerSelected: "No layer selected",
1030
- noLayerSelectedDescription: "Select an editable layer to clear features",
1031
- cannotClearHpLayer: "Cannot clear high-performance layer",
1032
- cannotClearHpLayerDescription: "Clear is not supported for HP layers. Delete individual features instead.",
1033
- layerEmpty: "Layer is empty",
1034
- layerEmptyDescription: "No features to clear",
1035
- layerCleared: "Layer cleared",
1036
- layerClearedDescription: (layerName) => `Removed all features from "${layerName}"`,
1037
- terrainUnavailable: "3D Terrain Unavailable",
1038
- terrainUnavailableDescription: "Terrain features are disabled for this configuration.",
1039
- terrainEnabled: "3D Terrain Enabled",
1040
- terrainEnabledDescription: "Tilt the map (right-click + drag or Ctrl + drag) to see the 3D effect.",
1041
- exportFailed: "Export failed",
1042
- exportFailedDescription: "Could not prepare the download",
1043
- featuresAdded: "Features added",
1044
- featuresAddedDescription: ({ count, layerName }) => `Added ${count} features to "${layerName}"`,
1045
- layerCreated: "Layer created",
1046
- searchFailed: "Search failed",
1047
- searchFailedDescription: "Failed to search data source",
1048
- mapRestored: "Map restored",
1049
- mapRestoredDescription: ({ layerCount, featureCount }) => `Restored ${layerCount} layers with ${featureCount} features`,
1050
- featuresLoaded: "Features loaded",
1051
- featuresLoadedDescription: (count) => `Created layer with ${count} features`,
1052
- loadFailed: "Load failed",
1053
- loadFailedDescription: "Failed to load from workspace",
1054
- saved: "Saved",
1055
- savedDescription: "Saved entire map to workspace",
1056
- saveFailed: "Save failed",
1057
- saveFailedDescription: "Failed to save to workspace",
1058
- noFeatures: "No features",
1059
- noFeaturesDescription: "There are no features to fit to",
1060
- geojsonLoadFailed: "Failed to load GeoJSON",
1061
- invalidFile: "Invalid file",
1062
- emptyGeojson: "Empty GeoJSON",
1063
- /** `reprojectedFrom` is the source CRS when the file was reprojected, otherwise null. */
1064
- hpLayerCreatedDescription: ({ layerName, count, reprojectedFrom }) => `Created "${layerName}" with ${count} features${reprojectedFrom !== null ? ` (reprojected from ${reprojectedFrom})` : ""} (high-performance mode)`,
1065
- dataViewingLayer: "Can't load into a data-viewing layer",
1066
- dataViewingLayerDescription: "Its features are fetched from data and aren't saved with the map. Load the file into another layer.",
1067
- hostOwnedLayer: "Can't load into this layer",
1068
- hostOwnedLayerDescription: "Another view owns its features. Load the file into another layer.",
1069
- noLayerToLoadInto: "No layer to load into",
1070
- noLayerToLoadIntoDescription: "Create a layer first, then load the file again.",
1071
- geojsonLoaded: "GeoJSON loaded",
1072
- geojsonLoadedDescription: ({ count, reprojectedFrom, layerHidden }) => `Added ${count} features${reprojectedFrom !== null ? ` (reprojected from ${reprojectedFrom})` : ""}${layerHidden ? " (layer hidden)" : ""}`,
1073
- layerAdded: "Layer added",
1074
- layerAddedDescription: ({ layerName, count, reprojectedFrom }) => `Created "${layerName}" with ${count} features${reprojectedFrom !== null ? ` (reprojected from ${reprojectedFrom})` : ""} (high-performance)`
1075
- },
1076
- featureCap: DEFAULT_FEATURE_CAP_LABELS,
1077
- ingest: {
1078
- importing: (name) => `Importing ${name}…`,
1079
- rendering: (name) => `Rendering ${name}…`,
1080
- preparingDownload: (name) => `Preparing download ${name}…`,
1081
- progress: ({ received, total }) => `${received.toLocaleString()} / ${total.toLocaleString()} features`,
1082
- invalidFormat: "Invalid GeoJSON format",
1083
- noFeatures: "The file contains no features",
1084
- workerUnresponsive: "Ingest worker unresponsive — the file could not be parsed",
1085
- workerCrashed: "Ingest worker crashed"
1086
- },
1087
- dropZone: {
1088
- title: "Drop GeoJSON here",
1089
- subtitle: "Add as new layer"
1090
- },
1091
- mapOptions: {
1092
- title: "Map Options",
1093
- load: "Load",
1094
- uploadMap: "Upload Map",
1095
- loadFromWorkspace: "Load Map from workspace",
1096
- save: "Save",
1097
- downloadMap: "Download Map",
1098
- saveToWorkspace: "Save Map to workspace",
1099
- autoShowLabels: "Auto-show labels",
1100
- autoLabelThreshold: "When features on screen",
1101
- visibleFeatures: "Visible:",
1102
- labelsShown: "(shown)",
1103
- labelsHidden: "(hidden)",
1104
- fitToAllFeatures: "Fit Map to All Features",
1105
- terrain3d: "3D",
1106
- basemapStreets: "Streets",
1107
- basemapSatellite: "Satellite",
1108
- basemapDark: "Dark"
1109
- },
1110
- layersPanel: {
1111
- title: "Layers",
1112
- createLayer: "Create new layer",
1113
- loadAsNewLayer: "Load GeoJSON from desktop as new layer",
1114
- searchAndAdd: "Search and add...",
1115
- groupLayerCount: (count) => `${count} layers`,
1116
- unsavedCount: (count) => `${count} unsaved`,
1117
- hpLayerTitle: "High-Performance Layer",
1118
- hpLayerDescription: "Optimized for large datasets. Geometry cannot be moved or reshaped.",
1119
- editingThisLayer: "This is the layer being edited",
1120
- clickToEditLayer: "Click to edit this layer",
1121
- loadGeojson: "Load GeoJSON from desktop",
1122
- saveGeojson: "Save GeoJSON to desktop",
1123
- neverHideLabels: "Never hide labels",
1124
- labelsOffForLayer: "Labels are turned off for this layer",
1125
- neverHideLabelsHint: "Show every label even when the map is crowded",
1126
- fitMapToLayer: "Fit Map to Layer",
1127
- deleteLayer: "Delete Layer",
1128
- deleteLayerConfirmTitle: (layerName) => `Delete layer "${layerName}"?`,
1129
- deleteLayerConfirmContent: "This will delete the layer and all its features.",
1130
- deleteLayerConfirmOk: "Delete",
1131
- deleteLayerConfirmCancel: "Cancel",
1132
- moveSelectedHere: (count) => `Move ${count} selected here`
1133
- },
1134
- layerSettings: {
1135
- pointFeatures: "Point Features",
1136
- traceLines: "Trace Lines",
1137
- connectAllPoints: "Connect all points",
1138
- groupBy: (field) => `Group by ${field}`,
1139
- heatmap: "Heatmap",
1140
- intensity: "Intensity",
1141
- radius: "Radius",
1142
- clustering: "Clustering",
1143
- simpleCount: "Simple count",
1144
- pieBy: (field) => `Pie by ${field}`,
1145
- showPointDots: "Show point dots",
1146
- countByField: "Count by field",
1147
- selectNumericField: "Select numeric field...",
1148
- colorBubblesByValue: "Color bubbles by value",
1149
- altitudeDisplay: "Altitude Display",
1150
- altitude3d: "3D (show altitude)",
1151
- altitudeFlat: "Flat (ignore altitude)",
1152
- altitudeBoth: "Both (3D + flat shadow)",
1153
- visualSettings: "Visual Settings",
1154
- labels: "Labels",
1155
- labelFromName: "Use name property",
1156
- labelFromField: "Use field...",
1157
- labelFixedText: "Fixed text...",
1158
- selectField: "Select field...",
1159
- enterLabelText: "Enter label text...",
1160
- size: "Size",
1161
- defaultSize: "Default size",
1162
- sizeByField: "Size by field...",
1163
- overrideSize: "Override size...",
1164
- color: "Color",
1165
- useFeatureColor: "Use feature color",
1166
- colorByField: "Color by field...",
1167
- fixedColor: "Fixed color...",
1168
- categories: "Categories",
1169
- gradient: "Gradient",
1170
- pointIcon: "Point Icon",
1171
- iconSameForAll: "Same for all",
1172
- iconByFieldValue: "By field value",
1173
- icons: "Icons",
1174
- iconsAssigning: "Assigning icons…",
1175
- iconsAssignedByAi: "Icons assigned by AI",
1176
- iconsAssignedByKeywords: "Icons assigned by keyword match",
1177
- reassignIcons: "Reassign",
1178
- reassignIconsWithAi: "Let the AI assign every icon again",
1179
- reassignIconsByKeywords: "Assign every icon again by keyword match (no AI connected)",
1180
- iconAiUnavailable: (error) => `AI unavailable, used keyword match (${error})`,
1181
- iconAiNoUsableIcon: "The AI suggested no icon the map can draw, used keyword match",
1182
- assignNewIcons: (count) => `Assign ${count} new ${plural(count, "value")}`,
1183
- iconOtherValues: "All other values",
1184
- iconEmptyOrUnassigned: "Empty or unassigned",
1185
- legend: "Legend",
1186
- legendTop: (count) => `Legend (top ${count})`,
1187
- legendSampled: "Legend (sampled)",
1188
- filterValues: "Filter values…",
1189
- noMatches: "No matches",
1190
- showLess: "Show less",
1191
- showAll: (count) => `Show all (${count})`
1192
- },
1193
- drawingToolbar: {
1194
- drawingTools: "Drawing tools",
1195
- clickSelect: "Click Select",
1196
- rectangleSelect: "Rectangle Select",
1197
- polygonSelect: "Polygon Select",
1198
- circleSelect: "Circle Select",
1199
- selectTool: "Select Tool",
1200
- switchSelectionMode: "Switch selection mode",
1201
- filterArea: "Filter Area",
1202
- clearFilter: "Clear Filter",
1203
- measureDistance: "Measure Distance",
1204
- measureArea: "Measure Area",
1205
- switchMeasureMode: "Switch measure mode",
1206
- searchAndNavigate: "Search & Navigate",
1207
- fitToData: "Fit to Data",
1208
- noEditableLayer: "No editable layer",
1209
- noEditableLayerHint: "Select an editable layer with the pencil icon to enable editing",
1210
- editMode: "Edit Mode",
1211
- searchAndAdd: "Search and Add",
1212
- dropPoint: "Drop Point",
1213
- drawLine: "Draw Line",
1214
- drawPolygon: "Draw Polygon",
1215
- drawRectangle: "Draw Rectangle",
1216
- drawPolygonOrRectangle: "Draw Polygon/Rectangle",
1217
- drawPolygonOrRectangleAriaLabel: "Draw Polygon or Rectangle",
1218
- addText: "Add Text",
1219
- drawArrow: "Draw Arrow",
1220
- drawCircle: "Draw Circle",
1221
- undo: "Undo",
1222
- redo: "Redo",
1223
- deleteSelected: (count) => `Delete selected (${count})`,
1224
- deleteSelectedAriaLabel: "Delete selected features",
1225
- clearAll: (count) => `Clear all (${count})`,
1226
- moreTools: "More tools",
1227
- clearAllConfirmTitle: "Clear all features?",
1228
- clearAllConfirmContent: (count) => `This will remove all ${count} ${plural(count, "feature")} from the map. This action cannot be undone.`,
1229
- clearAllConfirmOk: "Clear all",
1230
- clearAllConfirmCancel: "Cancel"
1231
- },
1232
- navigate: {
1233
- title: "Navigate To",
1234
- addressPlaceholder: "Search address...",
1235
- searchAddress: "Go",
1236
- orCoordinates: "or coordinates",
1237
- latitude: "Lat",
1238
- longitude: "Lng",
1239
- latitudePlaceholder: "-90 to 90",
1240
- longitudePlaceholder: "-180 to 180",
1241
- dropPoint: "Drop",
1242
- goToCoordinates: "Go",
1243
- locationNotFound: "Location not found",
1244
- locationNotFoundDescription: "Try a different search term",
1245
- searchError: "Search error",
1246
- searchErrorDescription: "Could not search for location. Check your connection."
1247
- },
1248
- coordinates: {
1249
- invalidCoordinates: "Invalid coordinates",
1250
- invalidCoordinatesDescription: "Please enter valid latitude and longitude values",
1251
- invalidLatitude: "Invalid latitude",
1252
- invalidLongitude: "Invalid longitude",
1253
- latitudeOutOfRange: "Latitude must be between -90 and 90",
1254
- longitudeOutOfRange: "Longitude must be between -180 and 180",
1255
- notANumber: "Please enter a valid number"
1256
- },
1257
- featureSearch: {
1258
- title: "Search Features",
1259
- placeholder: "Search features...",
1260
- titlesMode: "Titles",
1261
- fullJsonMode: "Full JSON",
1262
- /** `more` is true when the result list stopped at its cap. */
1263
- resultCount: ({ count, more }) => `${count}${more ? "+" : ""} found`,
1264
- totalCount: (count) => `${count} total`,
1265
- noResults: "No features found",
1266
- typeToSearch: (count) => `Type to search across ${count} features`,
1267
- untitledFeature: "Feature",
1268
- unknownGeometry: "Unknown"
1269
- },
1270
- propertiesPanel: {
1271
- showingFirstSelected: ({ shown, total }) => `Showing the first ${shown} of ${total.toLocaleString()} selected features`,
1272
- previousOverlappingPoint: "Previous overlapping point",
1273
- nextOverlappingPoint: "Next overlapping point",
1274
- selectedFeatures: (count) => `${count} selected ${count === 1 ? "feature" : "features"}`,
1275
- untitledFeature: "Feature",
1276
- hpLayerHint: "High Performance Layer — does not allow moving / geometrical editing of features",
1277
- hpBadge: "HP",
1278
- viewBadge: "View",
1279
- openInNewTab: "Open in new tab",
1280
- actions: "Actions",
1281
- copyToLayer: "Copy to layer",
1282
- moveToLayer: "Move to layer",
1283
- untitledLayer: "Untitled",
1284
- newLayer: "New layer…",
1285
- newLayerPrompt: "New layer name",
1286
- changeIcon: "Change icon",
1287
- setIcon: "Set icon",
1288
- deleteFeatures: (count) => `Delete ${count} feature${count > 1 ? "s" : ""}`,
1289
- deleteFeature: "Delete feature",
1290
- entityCards: "Entity Cards",
1291
- entityCardsCount: (count) => `Entity Cards (${count})`,
1292
- properties: "Properties",
1293
- noEntityCardProvider: "No entity card provider registered",
1294
- selectSingleToSeeProperties: "Select a single feature to see/set properties",
1295
- selectSingleToEdit: "Select a single feature to edit properties.",
1296
- pointDetail: "Point Detail",
1297
- layer: "Layer:",
1298
- octostarRecord: "Octostar record",
1299
- localMapFeature: "Local map feature",
1300
- unsaved: "Unsaved",
1301
- createEntity: "Create entity",
1302
- untitledRecord: "Untitled",
1303
- refreshFromRecord: "Refresh from record",
1304
- recordFields: "Record Fields",
1305
- id: "ID:",
1306
- featureSaved: "Feature saved",
1307
- savedTo: (workspace) => `Saved to ${workspace}`,
1308
- saveFailed: "Save failed",
1309
- saveFeatureFailed: "Failed to save feature",
1310
- refreshed: "Refreshed",
1311
- refreshedDescription: "Properties updated from record",
1312
- refreshFailed: "Refresh failed"
1313
- },
1314
- featureFields: {
1315
- label: "Label",
1316
- name: "Name",
1317
- enterLabel: "Enter label...",
1318
- featureName: "Feature name",
1319
- noName: "No name",
1320
- icon: "Icon",
1321
- type: "Type",
1322
- noType: "No type",
1323
- latLng: "Lat / Lng",
1324
- centroidHint: "Lat and Lng refer to the centroid of this feature",
1325
- latitude: "Latitude",
1326
- longitude: "Longitude",
1327
- temporal: "Temporal",
1328
- dateCount: (count) => `${count} ${plural(count, "date")}`,
1329
- start: "Start",
1330
- end: "End",
1331
- style: "Style",
1332
- fontSize: "Font Size",
1333
- fontColor: "Font Color",
1334
- fontWeight: "Font Weight",
1335
- fontWeightNormal: "Normal",
1336
- fontWeightBold: "Bold",
1337
- arrowSize: "Arrow Size",
1338
- stroke: "Stroke",
1339
- strokeColor: "Stroke Color",
1340
- strokeWidth: "Stroke Width",
1341
- strokeOpacity: "Stroke Opacity",
1342
- fill: "Fill",
1343
- fillColor: "Fill Color",
1344
- fillOpacity: "Fill Opacity",
1345
- resetFillToStroke: "Reset fill to the stroke colour",
1346
- iconSize: "Size",
1347
- propertyKey: "Key",
1348
- propertyValue: "Value",
1349
- newProperty: "New property…"
1350
- },
1351
- iconPicker: {
1352
- title: "Select Icon",
1353
- searchPlaceholder: "Search icons...",
1354
- allCategories: (count) => `All (${count})`,
1355
- categoryWithCount: ({ category, count }) => `${category} (${count})`,
1356
- noIconsFound: (query) => `No icons found for "${query}"`,
1357
- noIconSelected: "No icon selected",
1358
- clearIcon: "Clear",
1359
- cancel: "Cancel",
1360
- emptyTrigger: "icon",
1361
- anyEmojiHint: "Any other emoji works too: type or paste it in the search",
1362
- useEmoji: (emoji) => `Use ${emoji}`,
1363
- emojiNotEverywhere: "This emoji may not show on every computer: pick another",
1364
- customEmoji: "Emoji",
1365
- emojiGroups: {
1366
- smileys: "Smileys",
1367
- people: "People",
1368
- nature: "Animals & nature",
1369
- food: "Food & drink",
1370
- travel: "Travel & places",
1371
- activities: "Activities",
1372
- objects: "Objects",
1373
- symbols: "Symbols"
1374
- }
1375
- },
1376
- iconCategories,
1377
- iconNames,
1378
- timebar: {
1379
- play: "Play",
1380
- pause: "Pause",
1381
- reset: "Reset timeline",
1382
- cumulative: "Cumulative: keep what has appeared",
1383
- toggle: "Toggle timeline",
1384
- featureCount: (count) => `${count} ${plural(count, "feature")}`,
1385
- selectedCount: ({ selected, total }) => `${selected} of ${total} selected`,
1386
- binEvents: (count) => `${count} ${plural(count, "event")}`,
1387
- binEventsWithSelection: ({ count, selected }) => `${count} ${plural(count, "event")} (${selected} selected)`
1388
- },
1389
- actionPanel: {
1390
- groupLabel: "File actions",
1391
- saveTooltip: "Download features as GeoJSON",
1392
- saveAriaLabel: "Save as GeoJSON",
1393
- save: "Save GeoJSON",
1394
- loadTooltip: "Import features from GeoJSON file",
1395
- loadAriaLabel: "Load GeoJSON file",
1396
- load: "Load GeoJSON"
1397
- }
1398
- };
1399
- const MapLabelsContext = createContext(DEFAULT_MAP_LABELS);
1400
- function shownLayerName(layer, labels) {
1401
- return layer.name === DEFAULT_LAYER_NAME ? labels.defaultLayerName : layer.name;
1402
- }
1403
- function useMapLabels() {
1404
- return useContext(MapLabelsContext);
1405
- }
1406
1608
  const SELECTED_STATE_KEY = "selected";
1407
1609
  const SELECTED = ["boolean", ["feature-state", SELECTED_STATE_KEY], false];
1408
1610
  const SELECTED_STATE = Object.freeze({ [SELECTED_STATE_KEY]: true });
@@ -2428,8 +2630,157 @@ function resolveMissingImage(id, provider) {
2428
2630
  if (image == null ? void 0 : image.data) return { kind: "host", image };
2429
2631
  return id.startsWith(HOST_IMAGE_PREFIX) ? { kind: "none" } : { kind: "emoji" };
2430
2632
  }
2431
- function windowFromRange(start, end) {
2432
- if (!start || !end) return null;
2633
+ const ICON_LIST = [
2634
+ // Location & Places
2635
+ { id: "map-pin", emoji: "📍", name: "Map Pin", category: "places" },
2636
+ { id: "home", emoji: "🏠", name: "Home", category: "places" },
2637
+ { id: "building", emoji: "🏢", name: "Building", category: "places" },
2638
+ { id: "store", emoji: "🏪", name: "Store", category: "places" },
2639
+ { id: "factory", emoji: "🏭", name: "Factory", category: "places" },
2640
+ { id: "construction", emoji: "🏗️", name: "Construction", category: "places" },
2641
+ { id: "church", emoji: "⛪", name: "Church", category: "places" },
2642
+ { id: "hospital", emoji: "🏥", name: "Hospital", category: "places" },
2643
+ { id: "school", emoji: "🏫", name: "School", category: "places" },
2644
+ { id: "graduation", emoji: "🎓", name: "University", category: "places" },
2645
+ { id: "library", emoji: "📚", name: "Library", category: "places" },
2646
+ { id: "landmark", emoji: "🏛️", name: "Landmark", category: "places" },
2647
+ { id: "castle", emoji: "🏰", name: "Castle", category: "places" },
2648
+ { id: "mosque", emoji: "🕌", name: "Mosque", category: "places" },
2649
+ { id: "stadium", emoji: "🏟️", name: "Stadium", category: "places" },
2650
+ { id: "tent", emoji: "⛺", name: "Camping", category: "places" },
2651
+ // Transport
2652
+ { id: "car", emoji: "🚗", name: "Car", category: "transport" },
2653
+ { id: "bus", emoji: "🚌", name: "Bus", category: "transport" },
2654
+ { id: "train", emoji: "🚂", name: "Train", category: "transport" },
2655
+ { id: "plane", emoji: "✈️", name: "Plane", category: "transport" },
2656
+ { id: "ship", emoji: "🚢", name: "Ship", category: "transport" },
2657
+ { id: "bike", emoji: "🚲", name: "Bike", category: "transport" },
2658
+ { id: "fuel", emoji: "⛽", name: "Gas Station", category: "transport" },
2659
+ { id: "helicopter", emoji: "🚁", name: "Helicopter", category: "transport" },
2660
+ { id: "rocket", emoji: "🚀", name: "Rocket", category: "transport" },
2661
+ { id: "motorcycle", emoji: "🏍️", name: "Motorcycle", category: "transport" },
2662
+ { id: "taxi", emoji: "🚕", name: "Taxi", category: "transport" },
2663
+ { id: "truck", emoji: "🚛", name: "Truck", category: "transport" },
2664
+ // Food & Drink
2665
+ { id: "utensils", emoji: "🍴", name: "Restaurant", category: "food" },
2666
+ { id: "coffee", emoji: "☕", name: "Coffee", category: "food" },
2667
+ { id: "beer", emoji: "🍺", name: "Bar", category: "food" },
2668
+ { id: "wine", emoji: "🍷", name: "Wine", category: "food" },
2669
+ { id: "pizza", emoji: "🍕", name: "Pizza", category: "food" },
2670
+ { id: "ice-cream", emoji: "🍦", name: "Ice Cream", category: "food" },
2671
+ { id: "apple", emoji: "🍎", name: "Apple", category: "food" },
2672
+ { id: "cake", emoji: "🎂", name: "Cake", category: "food" },
2673
+ { id: "hamburger", emoji: "🍔", name: "Burger", category: "food" },
2674
+ // Nature
2675
+ { id: "trees", emoji: "🌲", name: "Forest", category: "nature" },
2676
+ { id: "mountain", emoji: "⛰️", name: "Mountain", category: "nature" },
2677
+ { id: "waves", emoji: "🌊", name: "Water", category: "nature" },
2678
+ { id: "sun", emoji: "☀️", name: "Sun", category: "nature" },
2679
+ { id: "cloud", emoji: "☁️", name: "Cloud", category: "nature" },
2680
+ { id: "umbrella", emoji: "🌂", name: "Umbrella", category: "nature" },
2681
+ { id: "flower", emoji: "🌸", name: "Flower", category: "nature" },
2682
+ { id: "leaf", emoji: "🍃", name: "Leaf", category: "nature" },
2683
+ { id: "rainbow", emoji: "🌈", name: "Rainbow", category: "nature" },
2684
+ { id: "snowflake", emoji: "❄️", name: "Snow", category: "nature" },
2685
+ { id: "fire", emoji: "🔥", name: "Fire", category: "nature" },
2686
+ { id: "volcano", emoji: "🌋", name: "Volcano", category: "nature" },
2687
+ // Symbols & Markers
2688
+ { id: "heart", emoji: "❤️", name: "Heart", category: "symbols" },
2689
+ { id: "star", emoji: "⭐", name: "Star", category: "symbols" },
2690
+ { id: "flag", emoji: "🚩", name: "Flag", category: "symbols" },
2691
+ { id: "alert", emoji: "⚠️", name: "Warning", category: "symbols" },
2692
+ { id: "info", emoji: "ℹ️", name: "Info", category: "symbols" },
2693
+ { id: "check", emoji: "✅", name: "Check", category: "symbols" },
2694
+ { id: "x-mark", emoji: "❌", name: "X", category: "symbols" },
2695
+ { id: "zap", emoji: "⚡", name: "Zap", category: "symbols" },
2696
+ { id: "bell", emoji: "🔔", name: "Bell", category: "symbols" },
2697
+ { id: "peace", emoji: "☮️", name: "Peace", category: "symbols" },
2698
+ { id: "recycle", emoji: "♻️", name: "Recycle", category: "symbols" },
2699
+ { id: "radioactive", emoji: "☢️", name: "Radioactive", category: "symbols" },
2700
+ { id: "biohazard", emoji: "☣️", name: "Biohazard", category: "symbols" },
2701
+ // Activities
2702
+ { id: "camera", emoji: "📷", name: "Camera", category: "activities" },
2703
+ { id: "music", emoji: "🎵", name: "Music", category: "activities" },
2704
+ { id: "film", emoji: "🎬", name: "Cinema", category: "activities" },
2705
+ { id: "gamepad", emoji: "🎮", name: "Gaming", category: "activities" },
2706
+ { id: "trophy", emoji: "🏆", name: "Trophy", category: "activities" },
2707
+ { id: "medal", emoji: "🎖️", name: "Medal", category: "activities" },
2708
+ { id: "sports", emoji: "⚽", name: "Sports", category: "activities" },
2709
+ { id: "basketball", emoji: "🏀", name: "Basketball", category: "activities" },
2710
+ { id: "fishing", emoji: "🎣", name: "Fishing", category: "activities" },
2711
+ { id: "art", emoji: "🎨", name: "Art", category: "activities" },
2712
+ // Work & Tools
2713
+ { id: "briefcase", emoji: "💼", name: "Office", category: "work" },
2714
+ { id: "wrench", emoji: "🔧", name: "Repair", category: "work" },
2715
+ { id: "hammer", emoji: "🔨", name: "Construction", category: "work" },
2716
+ { id: "gear", emoji: "⚙️", name: "Settings", category: "work" },
2717
+ { id: "microscope", emoji: "🔬", name: "Science", category: "work" },
2718
+ { id: "test-tube", emoji: "🧪", name: "Lab", category: "work" },
2719
+ { id: "computer", emoji: "💻", name: "Computer", category: "work" },
2720
+ // Shopping
2721
+ { id: "cart", emoji: "🛒", name: "Shopping", category: "shopping" },
2722
+ { id: "gift", emoji: "🎁", name: "Gift", category: "shopping" },
2723
+ { id: "package", emoji: "📦", name: "Package", category: "shopping" },
2724
+ { id: "money", emoji: "💰", name: "Money", category: "shopping" },
2725
+ { id: "credit-card", emoji: "💳", name: "Payment", category: "shopping" },
2726
+ // Communication
2727
+ { id: "phone", emoji: "📱", name: "Phone", category: "communication" },
2728
+ { id: "mail", emoji: "📧", name: "Mail", category: "communication" },
2729
+ { id: "globe", emoji: "🌐", name: "Web", category: "communication" },
2730
+ { id: "satellite", emoji: "📡", name: "Satellite", category: "communication" },
2731
+ { id: "radio", emoji: "📻", name: "Radio", category: "communication" },
2732
+ { id: "tv", emoji: "📺", name: "TV", category: "communication" },
2733
+ // People & Animals
2734
+ { id: "user", emoji: "👤", name: "Person", category: "people" },
2735
+ { id: "users", emoji: "👥", name: "Group", category: "people" },
2736
+ { id: "baby", emoji: "👶", name: "Baby", category: "people" },
2737
+ { id: "dog", emoji: "🐕", name: "Dog", category: "people" },
2738
+ { id: "cat", emoji: "🐈", name: "Cat", category: "people" },
2739
+ { id: "bird", emoji: "🐦", name: "Bird", category: "people" },
2740
+ { id: "horse", emoji: "🐴", name: "Horse", category: "people" },
2741
+ { id: "fish", emoji: "🐟", name: "Fish", category: "people" },
2742
+ // Maritime & Navigation
2743
+ { id: "anchor", emoji: "⚓", name: "Anchor", category: "maritime" },
2744
+ { id: "compass", emoji: "🧭", name: "Compass", category: "maritime" },
2745
+ { id: "lighthouse", emoji: "🗼", name: "Lighthouse", category: "maritime" },
2746
+ { id: "sailboat", emoji: "⛵", name: "Sailboat", category: "maritime" },
2747
+ // Security
2748
+ { id: "lock", emoji: "🔒", name: "Lock", category: "security" },
2749
+ { id: "key", emoji: "🔑", name: "Key", category: "security" },
2750
+ { id: "shield", emoji: "🛡️", name: "Shield", category: "security" },
2751
+ { id: "eye", emoji: "👁️", name: "Eye", category: "security" },
2752
+ { id: "search", emoji: "🔍", name: "Search", category: "security" },
2753
+ { id: "police", emoji: "🚔", name: "Police", category: "security" },
2754
+ { id: "siren", emoji: "🚨", name: "Siren", category: "security" },
2755
+ // Time & Organization
2756
+ { id: "clock", emoji: "🕐", name: "Clock", category: "time" },
2757
+ { id: "calendar", emoji: "📅", name: "Calendar", category: "time" },
2758
+ { id: "bookmark", emoji: "🔖", name: "Bookmark", category: "time" },
2759
+ { id: "tag", emoji: "🏷️", name: "Tag", category: "time" },
2760
+ { id: "pushpin", emoji: "📌", name: "Pin", category: "time" },
2761
+ // Shapes & Geometric
2762
+ { id: "red-circle", emoji: "🔴", name: "Red Circle", category: "shapes" },
2763
+ { id: "blue-circle", emoji: "🔵", name: "Blue Circle", category: "shapes" },
2764
+ { id: "green-circle", emoji: "🟢", name: "Green Circle", category: "shapes" },
2765
+ { id: "yellow-circle", emoji: "🟡", name: "Yellow Circle", category: "shapes" },
2766
+ { id: "orange-circle", emoji: "🟠", name: "Orange Circle", category: "shapes" },
2767
+ { id: "purple-circle", emoji: "🟣", name: "Purple Circle", category: "shapes" },
2768
+ { id: "white-circle", emoji: "⚪", name: "White Circle", category: "shapes" },
2769
+ { id: "black-circle", emoji: "⚫", name: "Black Circle", category: "shapes" },
2770
+ { id: "red-square", emoji: "🟥", name: "Red Square", category: "shapes" },
2771
+ { id: "blue-square", emoji: "🟦", name: "Blue Square", category: "shapes" },
2772
+ { id: "diamond", emoji: "💎", name: "Diamond", category: "shapes" },
2773
+ // Arrows
2774
+ { id: "arrow-up", emoji: "⬆️", name: "Arrow Up", category: "arrows" },
2775
+ { id: "arrow-down", emoji: "⬇️", name: "Arrow Down", category: "arrows" },
2776
+ { id: "arrow-left", emoji: "⬅️", name: "Arrow Left", category: "arrows" },
2777
+ { id: "arrow-right", emoji: "➡️", name: "Arrow Right", category: "arrows" },
2778
+ { id: "target", emoji: "🎯", name: "Target", category: "arrows" }
2779
+ ];
2780
+ const ICONS = [...ICON_LIST];
2781
+ const EMOJI_BY_ID = new Map(ICONS.map((i) => [i.id, i.emoji]));
2782
+ function windowFromRange(start, end) {
2783
+ if (!start || !end) return null;
2433
2784
  const t0 = start.getTime();
2434
2785
  const t1 = end.getTime();
2435
2786
  return Number.isFinite(t0) && Number.isFinite(t1) ? { t0, t1 } : null;
@@ -4909,8 +5260,8 @@ const CATEGORIES = [
4909
5260
  "arrows"
4910
5261
  ];
4911
5262
  function IconPicker({ value, onChange, disabled = false, renderTrigger, open: controlledOpen, onOpenChange }) {
4912
- const { iconPicker: labels, iconNames: iconNames2, iconCategories: iconCategories2 } = useMapLabels();
4913
- const iconName = useCallback((icon) => iconNames2[icon.id] ?? icon.name, [iconNames2]);
5263
+ const { iconPicker: labels, iconNames, iconCategories } = useMapLabels();
5264
+ const iconName = useCallback((icon) => iconNames[icon.id] ?? icon.name, [iconNames]);
4914
5265
  const [internalOpen, setInternalOpen] = useState(false);
4915
5266
  const open = controlledOpen ?? internalOpen;
4916
5267
  const setOpen = useCallback((v) => {
@@ -4929,11 +5280,11 @@ function IconPicker({ value, onChange, disabled = false, renderTrigger, open: co
4929
5280
  if (search.trim()) {
4930
5281
  const searchLower = search.toLowerCase().trim();
4931
5282
  result = result.filter(
4932
- (i) => iconName(i).toLowerCase().includes(searchLower) || i.name.toLowerCase().includes(searchLower) || i.id.toLowerCase().includes(searchLower) || i.category.toLowerCase().includes(searchLower) || (iconCategories2[i.category] ?? "").toLowerCase().includes(searchLower)
5283
+ (i) => iconName(i).toLowerCase().includes(searchLower) || i.name.toLowerCase().includes(searchLower) || i.id.toLowerCase().includes(searchLower) || i.category.toLowerCase().includes(searchLower) || (iconCategories[i.category] ?? "").toLowerCase().includes(searchLower)
4933
5284
  );
4934
5285
  }
4935
5286
  return result;
4936
- }, [activeCategory, activeEmojiGroup, search, iconName, iconCategories2]);
5287
+ }, [activeCategory, activeEmojiGroup, search, iconName, iconCategories]);
4937
5288
  const emojiShown = useMemo(() => {
4938
5289
  if (activeEmojiGroup) return EMOJI_LIST[activeEmojiGroup];
4939
5290
  const query = search.toLowerCase().trim();
@@ -5020,7 +5371,7 @@ function IconPicker({ value, onChange, disabled = false, renderTrigger, open: co
5020
5371
  setSearch("");
5021
5372
  },
5022
5373
  "data-testid": `button-category-${cat}`,
5023
- children: labels.categoryWithCount({ category: iconCategories2[cat], count })
5374
+ children: labels.categoryWithCount({ category: iconCategories[cat], count })
5024
5375
  },
5025
5376
  cat
5026
5377
  );
@@ -5738,7 +6089,7 @@ function DrawingToolbar({
5738
6089
  /* @__PURE__ */ jsx(Undo2, { className: "w-4 h-4" }),
5739
6090
  labels.undo
5740
6091
  ] }),
5741
- showShortcutHints && /* @__PURE__ */ jsx("kbd", { className: "px-1.5 py-0.5 text-xs font-mono bg-black/10 dark:bg-white/10 rounded", children: "Ctrl+Z" })
6092
+ showShortcutHints && /* @__PURE__ */ jsx("kbd", { className: "px-1.5 py-0.5 text-xs font-mono bg-black/10 dark:bg-white/10 rounded", children: labels.undoShortcut })
5742
6093
  ] }),
5743
6094
  disabled: disabled || !canUndo,
5744
6095
  onClick: onUndo
@@ -5750,7 +6101,7 @@ function DrawingToolbar({
5750
6101
  /* @__PURE__ */ jsx(Redo2, { className: "w-4 h-4" }),
5751
6102
  labels.redo
5752
6103
  ] }),
5753
- showShortcutHints && /* @__PURE__ */ jsx("kbd", { className: "px-1.5 py-0.5 text-xs font-mono bg-black/10 dark:bg-white/10 rounded", children: "Ctrl+Y" })
6104
+ showShortcutHints && /* @__PURE__ */ jsx("kbd", { className: "px-1.5 py-0.5 text-xs font-mono bg-black/10 dark:bg-white/10 rounded", children: labels.redoShortcut })
5754
6105
  ] }),
5755
6106
  disabled: disabled || !canRedo,
5756
6107
  onClick: onRedo
@@ -5764,7 +6115,7 @@ function DrawingToolbar({
5764
6115
  /* @__PURE__ */ jsx(X, { className: "w-4 h-4" }),
5765
6116
  labels.deleteSelected(selectedCount)
5766
6117
  ] }),
5767
- showShortcutHints && /* @__PURE__ */ jsx("kbd", { className: "px-1.5 py-0.5 text-xs font-mono bg-black/10 dark:bg-white/10 rounded", children: "Del" })
6118
+ showShortcutHints && /* @__PURE__ */ jsx("kbd", { className: "px-1.5 py-0.5 text-xs font-mono bg-black/10 dark:bg-white/10 rounded", children: labels.deleteKey })
5768
6119
  ] }),
5769
6120
  disabled: disabled || selectedCount === 0,
5770
6121
  onClick: onDeleteSelected
@@ -6200,7 +6551,7 @@ function DrawingToolbar({
6200
6551
  {
6201
6552
  title: showShortcutHints ? /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
6202
6553
  labels.undo,
6203
- /* @__PURE__ */ jsx("kbd", { className: "px-1.5 py-0.5 text-xs font-mono bg-black/20 rounded", children: "Ctrl+Z" })
6554
+ /* @__PURE__ */ jsx("kbd", { className: "px-1.5 py-0.5 text-xs font-mono bg-black/20 rounded", children: labels.undoShortcut })
6204
6555
  ] }) : labels.undo,
6205
6556
  placement: "right",
6206
6557
  children: /* @__PURE__ */ jsx(
@@ -6222,7 +6573,7 @@ function DrawingToolbar({
6222
6573
  {
6223
6574
  title: showShortcutHints ? /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
6224
6575
  labels.redo,
6225
- /* @__PURE__ */ jsx("kbd", { className: "px-1.5 py-0.5 text-xs font-mono bg-black/20 rounded", children: "Ctrl+Y" })
6576
+ /* @__PURE__ */ jsx("kbd", { className: "px-1.5 py-0.5 text-xs font-mono bg-black/20 rounded", children: labels.redoShortcut })
6226
6577
  ] }) : labels.redo,
6227
6578
  placement: "right",
6228
6579
  children: /* @__PURE__ */ jsx(
@@ -6248,7 +6599,7 @@ function DrawingToolbar({
6248
6599
  {
6249
6600
  title: showShortcutHints ? /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
6250
6601
  labels.deleteSelected(selectedCount),
6251
- /* @__PURE__ */ jsx("kbd", { className: "px-1.5 py-0.5 text-xs font-mono bg-black/20 rounded", children: "Del" })
6602
+ /* @__PURE__ */ jsx("kbd", { className: "px-1.5 py-0.5 text-xs font-mono bg-black/20 rounded", children: labels.deleteKey })
6252
6603
  ] }) : labels.deleteSelected(selectedCount),
6253
6604
  placement: "right",
6254
6605
  children: /* @__PURE__ */ jsx(
@@ -7223,137 +7574,522 @@ function PointIconSettings({
7223
7574
  ] })
7224
7575
  ] });
7225
7576
  }
7226
- const MAP_STYLES = [
7227
- { id: "streets", name: "Streets", icon: Map$1 },
7228
- { id: "satellite", name: "Satellite", icon: Satellite },
7229
- { id: "dark", name: "Dark", icon: Map$1 }
7230
- ];
7231
- function builtInBasemapName(id, labels) {
7232
- switch (id) {
7233
- case "streets":
7234
- return labels.basemapStreets;
7235
- case "satellite":
7236
- return labels.basemapSatellite;
7237
- case "dark":
7238
- return labels.basemapDark;
7239
- default:
7240
- return void 0;
7241
- }
7242
- }
7243
- const LEGEND_MAX_VALUES = 50;
7244
- const LEGEND_INITIAL_VISIBLE = 8;
7245
- function ColorByFieldLegend({
7246
- layerId,
7247
- fieldName,
7248
- getFieldValueDistribution
7249
- }) {
7250
- const { layerSettings: labels } = useMapLabels();
7251
- const [expanded, setExpanded] = useState(false);
7252
- const [filter, setFilter] = useState("");
7253
- useEffect(() => {
7254
- setFilter("");
7255
- setExpanded(false);
7256
- }, [layerId, fieldName]);
7257
- const distribution = useMemo(
7258
- () => getFieldValueDistribution(layerId, fieldName, LEGEND_MAX_VALUES),
7259
- [getFieldValueDistribution, layerId, fieldName]
7260
- );
7261
- const filtered = useMemo(() => {
7262
- const q = filter.trim().toLowerCase();
7263
- if (!q) return distribution;
7264
- return distribution.filter((d) => d.value.toLowerCase().includes(q));
7265
- }, [distribution, filter]);
7266
- if (distribution.length === 0) return null;
7267
- const visible = expanded ? filtered : filtered.slice(0, LEGEND_INITIAL_VISIBLE);
7268
- const hiddenCount = filtered.length - visible.length;
7269
- return /* @__PURE__ */ jsxs(
7270
- "div",
7271
- {
7272
- className: "mt-1 rounded border border-border/50 bg-background/40 p-1.5",
7273
- "data-testid": `legend-color-by-${layerId}`,
7274
- children: [
7275
- /* @__PURE__ */ jsx("div", { className: "text-[10px] uppercase tracking-wide text-muted-foreground mb-1", children: distribution.length >= LEGEND_MAX_VALUES ? labels.legendTop(LEGEND_MAX_VALUES) : labels.legend }),
7276
- (distribution.length > LEGEND_INITIAL_VISIBLE || expanded) && /* @__PURE__ */ jsx(
7277
- Input,
7278
- {
7279
- size: "small",
7280
- allowClear: true,
7281
- placeholder: labels.filterValues,
7282
- value: filter,
7283
- onChange: (e) => setFilter(e.target.value),
7284
- className: "mb-1 !text-[11px]",
7285
- "data-testid": `legend-filter-${layerId}`
7286
- }
7287
- ),
7288
- /* @__PURE__ */ jsxs("div", { className: "space-y-0.5 max-h-40 overflow-y-auto", children: [
7289
- visible.map(({ value, count }) => /* @__PURE__ */ jsxs(
7290
- "div",
7291
- {
7292
- className: "flex items-center gap-1.5 text-[11px]",
7293
- title: `${value} (${count})`,
7294
- children: [
7295
- /* @__PURE__ */ jsx(
7296
- "span",
7297
- {
7298
- className: "inline-block w-2.5 h-2.5 rounded-sm shrink-0 border border-black/10",
7299
- style: { backgroundColor: hashStringToColor(value) }
7300
- }
7301
- ),
7302
- /* @__PURE__ */ jsx("span", { className: "truncate flex-1 text-foreground", children: value }),
7303
- /* @__PURE__ */ jsx("span", { className: "text-muted-foreground tabular-nums", children: count })
7304
- ]
7305
- },
7306
- value
7307
- )),
7308
- visible.length === 0 && /* @__PURE__ */ jsx("div", { className: "text-[11px] text-muted-foreground italic", children: labels.noMatches })
7309
- ] }),
7310
- (hiddenCount > 0 || expanded && filtered.length > LEGEND_INITIAL_VISIBLE) && /* @__PURE__ */ jsx(
7311
- "button",
7312
- {
7313
- type: "button",
7314
- className: "mt-1 text-[11px] text-primary hover:underline",
7315
- onClick: () => setExpanded((e) => !e),
7316
- "data-testid": `legend-toggle-${layerId}`,
7317
- children: expanded ? labels.showLess : labels.showAll(filtered.length)
7318
- }
7319
- )
7320
- ]
7321
- }
7322
- );
7323
- }
7324
- function ColorGradientLegend({
7325
- layerId,
7326
- min,
7327
- max,
7328
- sampled
7329
- }) {
7330
- const { layerSettings: labels } = useMapLabels();
7331
- const degenerate = min === max;
7332
- return /* @__PURE__ */ jsxs(
7333
- "div",
7334
- {
7335
- className: "mt-1 rounded border border-border/50 bg-background/40 p-1.5",
7336
- "data-testid": `legend-gradient-${layerId}`,
7337
- children: [
7338
- /* @__PURE__ */ jsx("div", { className: "text-[10px] uppercase tracking-wide text-muted-foreground mb-1", children: sampled ? labels.legendSampled : labels.legend }),
7339
- /* @__PURE__ */ jsx(
7340
- "div",
7341
- {
7342
- className: "h-2.5 rounded-sm border border-black/10",
7343
- style: { background: degenerate ? gradientColor(0.5) : `linear-gradient(to right, ${GRADIENT_RAMP.join(", ")})` }
7344
- }
7345
- ),
7346
- /* @__PURE__ */ jsx("div", { className: "flex justify-between text-[11px] text-muted-foreground tabular-nums mt-0.5", children: degenerate ? /* @__PURE__ */ jsx("span", { className: "mx-auto", children: formatGradientStop(min) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
7347
- /* @__PURE__ */ jsx("span", { children: formatGradientStop(min) }),
7348
- /* @__PURE__ */ jsx("span", { children: formatGradientStop(max) })
7349
- ] }) })
7350
- ]
7351
- }
7352
- );
7577
+ const OTHER_BUCKET_KEY = "__other__";
7578
+ const OTHER_BUCKET_COLOR = "#9ca3af";
7579
+ function toDisplayName(name, otherLabel) {
7580
+ return name === OTHER_BUCKET_KEY ? otherLabel : name;
7353
7581
  }
7354
- function LayersPanel({
7355
- layers,
7356
- onAddLayer,
7582
+ function createPieSVG(categories, total, otherLabel, size = 44, onSliceHover, badgeValue) {
7583
+ const container = document.createElement("div");
7584
+ container.style.width = `${size}px`;
7585
+ container.style.height = `${size}px`;
7586
+ container.style.cursor = "pointer";
7587
+ const radius = size / 2;
7588
+ const innerRadius = radius * 0.5;
7589
+ const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
7590
+ svg.setAttribute("width", String(size));
7591
+ svg.setAttribute("height", String(size));
7592
+ svg.setAttribute("viewBox", `0 0 ${size} ${size}`);
7593
+ svg.style.display = "block";
7594
+ const bgCircle = document.createElementNS("http://www.w3.org/2000/svg", "circle");
7595
+ bgCircle.setAttribute("cx", String(radius));
7596
+ bgCircle.setAttribute("cy", String(radius));
7597
+ bgCircle.setAttribute("r", String(radius));
7598
+ bgCircle.setAttribute("fill", "white");
7599
+ svg.appendChild(bgCircle);
7600
+ const slicesSum = categories.reduce((s, c) => s + c.count, 0);
7601
+ const remainder = Math.max(0, total - slicesSum);
7602
+ const renderList = remainder > 0 ? [...categories, { name: "__remainder__", displayName: otherLabel, count: remainder, color: OTHER_BUCKET_COLOR }] : categories;
7603
+ const nonZeroSlices = renderList.filter((c) => c.count > 0);
7604
+ const isSingleFullSlice = nonZeroSlices.length === 1 && nonZeroSlices[0].count >= total;
7605
+ if (isSingleFullSlice) {
7606
+ const cat = nonZeroSlices[0];
7607
+ const ring = document.createElementNS("http://www.w3.org/2000/svg", "path");
7608
+ const d = [
7609
+ `M 0 ${radius}`,
7610
+ `a ${radius} ${radius} 0 1 0 ${radius * 2} 0`,
7611
+ `a ${radius} ${radius} 0 1 0 ${-radius * 2} 0`,
7612
+ `M ${radius - innerRadius} ${radius}`,
7613
+ `a ${innerRadius} ${innerRadius} 0 1 1 ${innerRadius * 2} 0`,
7614
+ `a ${innerRadius} ${innerRadius} 0 1 1 ${-innerRadius * 2} 0`,
7615
+ "Z"
7616
+ ].join(" ");
7617
+ ring.setAttribute("d", d);
7618
+ ring.setAttribute("fill-rule", "evenodd");
7619
+ ring.setAttribute("fill", cat.color);
7620
+ ring.setAttribute("stroke", "white");
7621
+ ring.setAttribute("stroke-width", "1");
7622
+ ring.style.transition = "opacity 0.15s";
7623
+ ring.addEventListener("mouseenter", (e) => {
7624
+ ring.style.opacity = "0.8";
7625
+ if (onSliceHover) onSliceHover(cat, e);
7626
+ });
7627
+ ring.addEventListener("mouseleave", (e) => {
7628
+ ring.style.opacity = "1";
7629
+ if (onSliceHover) onSliceHover(null, e);
7630
+ });
7631
+ svg.appendChild(ring);
7632
+ }
7633
+ let currentAngle = -90;
7634
+ (isSingleFullSlice ? [] : renderList).forEach((cat) => {
7635
+ if (cat.count === 0) return;
7636
+ const sliceAngle = cat.count / total * 360;
7637
+ const startAngle = currentAngle;
7638
+ const endAngle = currentAngle + sliceAngle;
7639
+ const startRad = startAngle * Math.PI / 180;
7640
+ const endRad = endAngle * Math.PI / 180;
7641
+ const x1 = radius + radius * Math.cos(startRad);
7642
+ const y1 = radius + radius * Math.sin(startRad);
7643
+ const x2 = radius + radius * Math.cos(endRad);
7644
+ const y2 = radius + radius * Math.sin(endRad);
7645
+ const x3 = radius + innerRadius * Math.cos(endRad);
7646
+ const y3 = radius + innerRadius * Math.sin(endRad);
7647
+ const x4 = radius + innerRadius * Math.cos(startRad);
7648
+ const y4 = radius + innerRadius * Math.sin(startRad);
7649
+ const largeArc = sliceAngle > 180 ? 1 : 0;
7650
+ const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
7651
+ const d = [
7652
+ `M ${x1} ${y1}`,
7653
+ `A ${radius} ${radius} 0 ${largeArc} 1 ${x2} ${y2}`,
7654
+ `L ${x3} ${y3}`,
7655
+ `A ${innerRadius} ${innerRadius} 0 ${largeArc} 0 ${x4} ${y4}`,
7656
+ "Z"
7657
+ ].join(" ");
7658
+ path.setAttribute("d", d);
7659
+ path.setAttribute("fill", cat.color);
7660
+ path.setAttribute("stroke", "white");
7661
+ path.setAttribute("stroke-width", "1");
7662
+ path.style.transition = "opacity 0.15s";
7663
+ path.addEventListener("mouseenter", (e) => {
7664
+ path.style.opacity = "0.8";
7665
+ if (onSliceHover) onSliceHover(cat, e);
7666
+ });
7667
+ path.addEventListener("mouseleave", (e) => {
7668
+ path.style.opacity = "1";
7669
+ if (onSliceHover) onSliceHover(null, e);
7670
+ });
7671
+ svg.appendChild(path);
7672
+ currentAngle = endAngle;
7673
+ });
7674
+ const centerCircle = document.createElementNS("http://www.w3.org/2000/svg", "circle");
7675
+ centerCircle.setAttribute("cx", String(radius));
7676
+ centerCircle.setAttribute("cy", String(radius));
7677
+ centerCircle.setAttribute("r", String(innerRadius - 2));
7678
+ centerCircle.setAttribute("fill", "#1f2937");
7679
+ svg.appendChild(centerCircle);
7680
+ const badgeText = formatClusterBadge(badgeValue ?? total);
7681
+ const text = document.createElementNS("http://www.w3.org/2000/svg", "text");
7682
+ text.setAttribute("x", String(radius));
7683
+ text.setAttribute("y", String(radius));
7684
+ text.setAttribute("text-anchor", "middle");
7685
+ text.setAttribute("dominant-baseline", "central");
7686
+ text.setAttribute("fill", "white");
7687
+ text.setAttribute("font-size", badgeText.length >= 6 ? "8" : badgeText.length >= 4 ? "9" : badgeText.length >= 3 ? "10" : "11");
7688
+ text.setAttribute("font-weight", "bold");
7689
+ text.setAttribute("font-family", "system-ui, sans-serif");
7690
+ text.textContent = badgeText;
7691
+ svg.appendChild(text);
7692
+ container.appendChild(svg);
7693
+ return container;
7694
+ }
7695
+ let tooltipEl = null;
7696
+ function showTooltip(cat, x, y) {
7697
+ if (!tooltipEl) {
7698
+ tooltipEl = document.createElement("div");
7699
+ tooltipEl.style.cssText = `
7700
+ position: fixed;
7701
+ background: rgba(0,0,0,0.85);
7702
+ color: white;
7703
+ padding: 6px 10px;
7704
+ border-radius: 4px;
7705
+ font-size: 12px;
7706
+ font-family: system-ui, sans-serif;
7707
+ pointer-events: none;
7708
+ z-index: 10000;
7709
+ white-space: nowrap;
7710
+ box-shadow: 0 2px 8px rgba(0,0,0,0.3);
7711
+ `;
7712
+ document.body.appendChild(tooltipEl);
7713
+ }
7714
+ while (tooltipEl.firstChild) tooltipEl.removeChild(tooltipEl.firstChild);
7715
+ const row = document.createElement("div");
7716
+ row.style.cssText = "display: flex; align-items: center; gap: 6px;";
7717
+ const swatch = document.createElement("span");
7718
+ swatch.style.cssText = "width: 10px; height: 10px; border-radius: 2px;";
7719
+ swatch.style.backgroundColor = cat.color;
7720
+ row.appendChild(swatch);
7721
+ const label = document.createElement("span");
7722
+ const name = document.createElement("strong");
7723
+ name.textContent = cat.displayName;
7724
+ label.appendChild(name);
7725
+ label.appendChild(document.createTextNode(`: ${cat.count}`));
7726
+ row.appendChild(label);
7727
+ tooltipEl.appendChild(row);
7728
+ tooltipEl.style.left = `${x + 12}px`;
7729
+ tooltipEl.style.top = `${y - 10}px`;
7730
+ tooltipEl.style.display = "block";
7731
+ }
7732
+ function hideTooltip() {
7733
+ if (tooltipEl) {
7734
+ tooltipEl.style.display = "none";
7735
+ }
7736
+ }
7737
+ function fingerprintCluster(pointCount, counts2, size, badgeValue) {
7738
+ return `${size}|${pointCount}|${badgeValue ?? ""}|${counts2.join(",")}`;
7739
+ }
7740
+ function buildPieElement(categories, pointCount, otherLabel, size, source, clusterId, map, coords, badgeValue) {
7741
+ const el = createPieSVG(categories, pointCount, otherLabel, size, (cat, event) => {
7742
+ if (cat) {
7743
+ showTooltip(cat, event.clientX, event.clientY);
7744
+ } else {
7745
+ hideTooltip();
7746
+ }
7747
+ }, badgeValue);
7748
+ el.addEventListener("click", () => {
7749
+ source.getClusterExpansionZoom(clusterId).then((zoom) => {
7750
+ if (typeof zoom === "number") {
7751
+ map.easeTo({ center: coords, zoom: zoom + 0.5 });
7752
+ }
7753
+ }).catch(() => {
7754
+ });
7755
+ });
7756
+ return el;
7757
+ }
7758
+ function renderClusterPies(map, sourceId, categoryValues, categoryColorMap, markers, otherLabel) {
7759
+ const source = map.getSource(sourceId);
7760
+ if (!source) return;
7761
+ const clusters = map.querySourceFeatures(sourceId, {
7762
+ filter: ["has", "point_count"]
7763
+ });
7764
+ const visibleClusterIds = /* @__PURE__ */ new Set();
7765
+ clusters.forEach((feature) => {
7766
+ var _a, _b, _c;
7767
+ const clusterId = (_a = feature.properties) == null ? void 0 : _a.cluster_id;
7768
+ if (clusterId === void 0) return;
7769
+ const clusterKey = `${clusterId}`;
7770
+ visibleClusterIds.add(clusterKey);
7771
+ const coords = feature.geometry.coordinates;
7772
+ const pointCount = ((_b = feature.properties) == null ? void 0 : _b.point_count) || 0;
7773
+ const sumRaw = (_c = feature.properties) == null ? void 0 : _c[CLUSTER_SUM_PROP];
7774
+ const sumNum = typeof sumRaw === "number" ? sumRaw : sumRaw != null ? Number(sumRaw) : NaN;
7775
+ const badgeValue = Number.isFinite(sumNum) ? sumNum : void 0;
7776
+ const allCounts = categoryValues.map((_, i) => {
7777
+ var _a2;
7778
+ return Number(((_a2 = feature.properties) == null ? void 0 : _a2[`cat_${i}`]) || 0);
7779
+ });
7780
+ const categories = categoryValues.map((cat, i) => ({
7781
+ name: cat,
7782
+ displayName: toDisplayName(cat, otherLabel),
7783
+ count: allCounts[i],
7784
+ color: categoryColorMap[cat] || "#3b82f6"
7785
+ })).filter((c) => c.count > 0);
7786
+ const size = pointCount < 100 ? 40 : pointCount < 750 ? 50 : 60;
7787
+ const fingerprint = fingerprintCluster(pointCount, allCounts, size, badgeValue);
7788
+ const existing = markers.get(clusterKey);
7789
+ if (existing && existing.fingerprint === fingerprint) {
7790
+ existing.marker.setLngLat(coords);
7791
+ return;
7792
+ }
7793
+ const el = buildPieElement(categories, pointCount, otherLabel, size, source, clusterId, map, coords, badgeValue);
7794
+ if (existing) {
7795
+ existing.marker.remove();
7796
+ }
7797
+ const marker = new maplibregl.Marker({ element: el }).setLngLat(coords).addTo(map);
7798
+ markers.set(clusterKey, { marker, fingerprint });
7799
+ });
7800
+ markers.forEach((entry, key) => {
7801
+ if (!visibleClusterIds.has(key)) {
7802
+ entry.marker.remove();
7803
+ markers.delete(key);
7804
+ }
7805
+ });
7806
+ }
7807
+ function createClusterPieManager(map, sourceId, categoryValues, categoryColorMap, otherLabel = DEFAULT_MAP_LABELS.canvas.clusterOther) {
7808
+ const markers = /* @__PURE__ */ new Map();
7809
+ let updateScheduled = false;
7810
+ function scheduleUpdate() {
7811
+ if (updateScheduled) return;
7812
+ updateScheduled = true;
7813
+ requestAnimationFrame(() => {
7814
+ updateScheduled = false;
7815
+ renderClusterPies(map, sourceId, categoryValues, categoryColorMap, markers, otherLabel);
7816
+ });
7817
+ }
7818
+ function onData(e) {
7819
+ if (e.dataType === "source" && e.sourceId === sourceId) {
7820
+ scheduleUpdate();
7821
+ }
7822
+ }
7823
+ map.on("moveend", scheduleUpdate);
7824
+ map.on("data", onData);
7825
+ scheduleUpdate();
7826
+ return {
7827
+ update: scheduleUpdate,
7828
+ destroy: () => {
7829
+ map.off("moveend", scheduleUpdate);
7830
+ map.off("data", onData);
7831
+ markers.forEach((entry) => entry.marker.remove());
7832
+ markers.clear();
7833
+ hideTooltip();
7834
+ }
7835
+ };
7836
+ }
7837
+ function ClusterPieManager(props) {
7838
+ const { map, sourceId, categoryValues, categoryColorMap, visible } = props;
7839
+ const otherLabel = useMapLabels().canvas.clusterOther;
7840
+ const markersRef = useRef(/* @__PURE__ */ new Map());
7841
+ const updateScheduled = useRef(false);
7842
+ const updateMarkers = useCallback(() => {
7843
+ if (!map || !visible) {
7844
+ markersRef.current.forEach((entry) => entry.marker.remove());
7845
+ markersRef.current.clear();
7846
+ return;
7847
+ }
7848
+ renderClusterPies(map, sourceId, categoryValues, categoryColorMap, markersRef.current, otherLabel);
7849
+ }, [map, sourceId, categoryValues, categoryColorMap, visible, otherLabel]);
7850
+ useEffect(() => {
7851
+ if (!map) return;
7852
+ const scheduleUpdate = () => {
7853
+ if (updateScheduled.current) return;
7854
+ updateScheduled.current = true;
7855
+ requestAnimationFrame(() => {
7856
+ updateScheduled.current = false;
7857
+ updateMarkers();
7858
+ });
7859
+ };
7860
+ const onData = (e) => {
7861
+ if (e.dataType === "source" && e.sourceId === sourceId) {
7862
+ scheduleUpdate();
7863
+ }
7864
+ };
7865
+ scheduleUpdate();
7866
+ map.on("moveend", scheduleUpdate);
7867
+ map.on("data", onData);
7868
+ return () => {
7869
+ map.off("moveend", scheduleUpdate);
7870
+ map.off("data", onData);
7871
+ markersRef.current.forEach((entry) => entry.marker.remove());
7872
+ markersRef.current.clear();
7873
+ hideTooltip();
7874
+ };
7875
+ }, [map, sourceId, updateMarkers]);
7876
+ useEffect(() => {
7877
+ if (!visible) {
7878
+ markersRef.current.forEach((entry) => entry.marker.remove());
7879
+ markersRef.current.clear();
7880
+ hideTooltip();
7881
+ } else {
7882
+ updateMarkers();
7883
+ }
7884
+ }, [visible, updateMarkers]);
7885
+ return null;
7886
+ }
7887
+ const LEGEND_MAX_VALUES = 50;
7888
+ const LEGEND_INITIAL_VISIBLE = 8;
7889
+ function LegendTitle({ children }) {
7890
+ return /* @__PURE__ */ jsx("div", { className: "text-[10px] font-semibold uppercase tracking-wide text-foreground mb-1.5", children });
7891
+ }
7892
+ function LegendRowView({
7893
+ row,
7894
+ maxCount,
7895
+ total,
7896
+ bucket = false
7897
+ }) {
7898
+ const { layerSettings: labels } = useMapLabels();
7899
+ return /* @__PURE__ */ jsxs(
7900
+ "div",
7901
+ {
7902
+ className: "relative flex items-center gap-2 px-1 py-0.5 text-[11px]",
7903
+ title: total ? labels.legendRowShare(row.value, row.count, row.count / total) : labels.legendRowTitle(row.value, row.count),
7904
+ "data-testid": "legend-row",
7905
+ children: [
7906
+ /* @__PURE__ */ jsx(
7907
+ "span",
7908
+ {
7909
+ "aria-hidden": true,
7910
+ className: "absolute inset-y-0 left-0 rounded-sm bg-muted/60",
7911
+ style: { width: `${row.count / maxCount * 100}%` }
7912
+ }
7913
+ ),
7914
+ /* @__PURE__ */ jsx(
7915
+ "span",
7916
+ {
7917
+ className: "relative inline-block w-3 h-3 rounded-full shrink-0 ring-1 ring-inset ring-black/15",
7918
+ style: { backgroundColor: row.color },
7919
+ "data-testid": "legend-swatch"
7920
+ }
7921
+ ),
7922
+ /* @__PURE__ */ jsx(
7923
+ "span",
7924
+ {
7925
+ className: `relative truncate flex-1 ${bucket ? "italic text-muted-foreground" : "text-foreground"}`,
7926
+ "data-testid": "legend-value",
7927
+ children: row.value
7928
+ }
7929
+ ),
7930
+ /* @__PURE__ */ jsx("span", { className: "relative text-muted-foreground tabular-nums", "data-testid": "legend-count", children: labels.legendCount(row.count) })
7931
+ ]
7932
+ }
7933
+ );
7934
+ }
7935
+ function ValueLegend({
7936
+ testId,
7937
+ title,
7938
+ rows,
7939
+ pinned,
7940
+ total,
7941
+ layerId,
7942
+ fieldName
7943
+ }) {
7944
+ const { layerSettings: labels } = useMapLabels();
7945
+ const [expanded, setExpanded] = useState(false);
7946
+ const [filter, setFilter] = useState("");
7947
+ useEffect(() => {
7948
+ setFilter("");
7949
+ setExpanded(false);
7950
+ }, [layerId, fieldName]);
7951
+ const filtered = useMemo(() => {
7952
+ const q = filter.trim().toLowerCase();
7953
+ if (!q) return rows;
7954
+ return rows.filter((r) => r.value.toLowerCase().includes(q));
7955
+ }, [rows, filter]);
7956
+ if (rows.length === 0 && !pinned) return null;
7957
+ const visible = expanded ? filtered : filtered.slice(0, LEGEND_INITIAL_VISIBLE);
7958
+ const hiddenCount = filtered.length - visible.length;
7959
+ const maxCount = Math.max(1, ...rows.map((r) => r.count), (pinned == null ? void 0 : pinned.count) ?? 0);
7960
+ return /* @__PURE__ */ jsxs("div", { className: "mt-1 rounded border border-border/50 bg-background/40 p-1.5", "data-testid": testId, children: [
7961
+ /* @__PURE__ */ jsx(LegendTitle, { children: title }),
7962
+ (rows.length > LEGEND_INITIAL_VISIBLE || expanded) && /* @__PURE__ */ jsx(
7963
+ Input,
7964
+ {
7965
+ size: "small",
7966
+ allowClear: true,
7967
+ placeholder: labels.filterValues,
7968
+ value: filter,
7969
+ onChange: (e) => setFilter(e.target.value),
7970
+ className: "mb-1 !text-[11px]",
7971
+ "data-testid": `${testId}-filter`
7972
+ }
7973
+ ),
7974
+ /* @__PURE__ */ jsxs("div", { className: "space-y-0.5 max-h-48 overflow-y-auto", "data-testid": `${testId}-rows`, children: [
7975
+ visible.map((row) => /* @__PURE__ */ jsx(LegendRowView, { row, maxCount, total }, row.value)),
7976
+ visible.length === 0 && rows.length > 0 && /* @__PURE__ */ jsx("div", { className: "text-[11px] text-muted-foreground italic", children: labels.noMatches })
7977
+ ] }),
7978
+ pinned && /* @__PURE__ */ jsx("div", { className: "mt-0.5 pt-0.5 border-t border-border/50", "data-testid": `${testId}-pinned`, children: /* @__PURE__ */ jsx(LegendRowView, { row: pinned, maxCount, total, bucket: true }) }),
7979
+ (hiddenCount > 0 || expanded && filtered.length > LEGEND_INITIAL_VISIBLE) && /* @__PURE__ */ jsx(
7980
+ "button",
7981
+ {
7982
+ type: "button",
7983
+ className: "mt-1 text-[11px] text-primary hover:underline",
7984
+ onClick: () => setExpanded((e) => !e),
7985
+ "data-testid": `${testId}-toggle`,
7986
+ children: expanded ? labels.showLess : labels.showAll(filtered.length)
7987
+ }
7988
+ )
7989
+ ] });
7990
+ }
7991
+ function ColorByFieldLegend({
7992
+ layerId,
7993
+ fieldName,
7994
+ getFieldValueDistribution
7995
+ }) {
7996
+ const { layerSettings: labels } = useMapLabels();
7997
+ const distribution = useMemo(
7998
+ () => getFieldValueDistribution(layerId, fieldName, LEGEND_MAX_VALUES),
7999
+ [getFieldValueDistribution, layerId, fieldName]
8000
+ );
8001
+ const rows = useMemo(() => distribution.map((d) => ({ ...d, color: hashStringToColor(d.value) })), [distribution]);
8002
+ return /* @__PURE__ */ jsx(
8003
+ ValueLegend,
8004
+ {
8005
+ testId: `legend-color-by-${layerId}`,
8006
+ title: distribution.length >= LEGEND_MAX_VALUES ? labels.legendTop(LEGEND_MAX_VALUES) : labels.legend,
8007
+ rows,
8008
+ layerId,
8009
+ fieldName
8010
+ }
8011
+ );
8012
+ }
8013
+ function ClusterPieLegend({
8014
+ layerId,
8015
+ fieldName,
8016
+ getClusterPieCategories
8017
+ }) {
8018
+ const { layerSettings: labels, canvas } = useMapLabels();
8019
+ const categories = useMemo(
8020
+ () => getClusterPieCategories(layerId, fieldName),
8021
+ [getClusterPieCategories, layerId, fieldName]
8022
+ );
8023
+ const rows = useMemo(
8024
+ () => ((categories == null ? void 0 : categories.values) ?? []).map((v) => ({ ...v, color: hashStringToColor(v.value) })),
8025
+ [categories]
8026
+ );
8027
+ if (!categories) return null;
8028
+ const { otherCount } = categories;
8029
+ const total = rows.reduce((sum, r) => sum + r.count, otherCount);
8030
+ return /* @__PURE__ */ jsx(
8031
+ ValueLegend,
8032
+ {
8033
+ testId: `legend-cluster-pie-${layerId}`,
8034
+ title: labels.legend,
8035
+ rows,
8036
+ pinned: otherCount > 0 ? { value: canvas.clusterOther, count: otherCount, color: OTHER_BUCKET_COLOR } : void 0,
8037
+ total,
8038
+ layerId,
8039
+ fieldName
8040
+ }
8041
+ );
8042
+ }
8043
+ const MAP_STYLES = [
8044
+ { id: "streets", name: "Streets", icon: Map$1 },
8045
+ { id: "satellite", name: "Satellite", icon: Satellite },
8046
+ { id: "dark", name: "Dark", icon: Map$1 }
8047
+ ];
8048
+ function builtInBasemapName(id, labels) {
8049
+ switch (id) {
8050
+ case "streets":
8051
+ return labels.basemapStreets;
8052
+ case "satellite":
8053
+ return labels.basemapSatellite;
8054
+ case "dark":
8055
+ return labels.basemapDark;
8056
+ default:
8057
+ return void 0;
8058
+ }
8059
+ }
8060
+ function ColorGradientLegend({
8061
+ layerId,
8062
+ min,
8063
+ max,
8064
+ sampled
8065
+ }) {
8066
+ const { layerSettings: labels } = useMapLabels();
8067
+ const degenerate = min === max;
8068
+ return /* @__PURE__ */ jsxs(
8069
+ "div",
8070
+ {
8071
+ className: "mt-1 rounded border border-border/50 bg-background/40 p-1.5",
8072
+ "data-testid": `legend-gradient-${layerId}`,
8073
+ children: [
8074
+ /* @__PURE__ */ jsx(LegendTitle, { children: sampled ? labels.legendSampled : labels.legend }),
8075
+ /* @__PURE__ */ jsx(
8076
+ "div",
8077
+ {
8078
+ className: "h-2.5 rounded-sm border border-black/10",
8079
+ style: { background: degenerate ? gradientColor(0.5) : `linear-gradient(to right, ${GRADIENT_RAMP.join(", ")})` }
8080
+ }
8081
+ ),
8082
+ /* @__PURE__ */ jsx("div", { className: "flex justify-between text-[11px] text-muted-foreground tabular-nums mt-0.5", children: degenerate ? /* @__PURE__ */ jsx("span", { className: "mx-auto", children: formatGradientStop(min) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
8083
+ /* @__PURE__ */ jsx("span", { children: formatGradientStop(min) }),
8084
+ /* @__PURE__ */ jsx("span", { children: formatGradientStop(max) })
8085
+ ] }) })
8086
+ ]
8087
+ }
8088
+ );
8089
+ }
8090
+ function LayersPanel({
8091
+ layers,
8092
+ onAddLayer,
7357
8093
  onRemoveLayer,
7358
8094
  onRenameLayer,
7359
8095
  onToggleLayerVisibility,
@@ -7380,6 +8116,7 @@ function LayersPanel({
7380
8116
  getSuggestedTraceField,
7381
8117
  getLayerFields,
7382
8118
  getFieldValueDistribution,
8119
+ getClusterPieCategories,
7383
8120
  onUpdateHeatmapConfig,
7384
8121
  onUpdateClusterConfig,
7385
8122
  onUpdateVisualConfig,
@@ -7404,12 +8141,12 @@ function LayersPanel({
7404
8141
  iconSuggestionProvider
7405
8142
  }) {
7406
8143
  const {
7407
- canvas: canvasLabels,
8144
+ canvas: canvasLabels2,
7408
8145
  layersPanel: labels,
7409
8146
  layerSettings: settingsLabels,
7410
8147
  mapOptions: optionsLabels
7411
8148
  } = useMapLabels();
7412
- const shownName = useCallback((layer) => shownLayerName(layer, canvasLabels), [canvasLabels]);
8149
+ const shownName = useCallback((layer) => shownLayerName(layer, canvasLabels2), [canvasLabels2]);
7413
8150
  const confirm = useConfirm();
7414
8151
  const [editingLayerId, setEditingLayerId] = useState(null);
7415
8152
  const [editingName, setEditingName] = useState("");
@@ -7904,7 +8641,15 @@ function LayersPanel({
7904
8641
  }
7905
8642
  ),
7906
8643
  /* @__PURE__ */ jsx("span", { className: "text-[10px]", children: settingsLabels.colorBubblesByValue })
7907
- ] })
8644
+ ] }),
8645
+ layer.clusterConfig.groupByField && getClusterPieCategories && /* @__PURE__ */ jsx(
8646
+ ClusterPieLegend,
8647
+ {
8648
+ layerId: layer.id,
8649
+ fieldName: layer.clusterConfig.groupByField,
8650
+ getClusterPieCategories
8651
+ }
8652
+ )
7908
8653
  ] })
7909
8654
  ] })
7910
8655
  ] }),
@@ -8659,7 +9404,7 @@ function EntityCardsList({
8659
9404
  ] });
8660
9405
  }
8661
9406
  function StackPager({ stack }) {
8662
- const { propertiesPanel: labels, canvas: canvasLabels } = useMapLabels();
9407
+ const { propertiesPanel: labels, canvas: canvasLabels2 } = useMapLabels();
8663
9408
  return /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-3 py-1 border-b border-border shrink-0 text-xs text-muted-foreground", children: [
8664
9409
  /* @__PURE__ */ jsx(Tooltip, { title: labels.previousOverlappingPoint, children: /* @__PURE__ */ jsx(
8665
9410
  Button,
@@ -8673,7 +9418,7 @@ function StackPager({ stack }) {
8673
9418
  "data-testid": "button-stack-prev"
8674
9419
  }
8675
9420
  ) }),
8676
- /* @__PURE__ */ jsx(Tooltip, { title: stack.more ? canvasLabels.morePointsHint : void 0, children: /* @__PURE__ */ jsxs("span", { "data-testid": "panel-stack-position", children: [
9421
+ /* @__PURE__ */ jsx(Tooltip, { title: stack.more ? canvasLabels2.morePointsHint : void 0, children: /* @__PURE__ */ jsxs("span", { "data-testid": "panel-stack-position", children: [
8677
9422
  stack.position + 1,
8678
9423
  " / ",
8679
9424
  stack.count,
@@ -8923,10 +9668,10 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
8923
9668
  propertiesPanel: labels,
8924
9669
  featureFields: fieldLabels,
8925
9670
  coordinates: coordinateLabels,
8926
- canvas: canvasLabels
9671
+ canvas: canvasLabels2
8927
9672
  } = useMapLabels();
8928
9673
  const inlineEntityCardLabel = inlineEntityCardLabelProp ?? labels.pointDetail;
8929
- const shownName = layerName !== void 0 && layerId !== void 0 ? shownLayerName({ name: layerName }, canvasLabels) : layerName;
9674
+ const shownName = layerName !== void 0 && layerId !== void 0 ? shownLayerName({ name: layerName }, canvasLabels2) : layerName;
8930
9675
  const { toast } = useToast();
8931
9676
  const hasMultipleSelection = selectedFeatures.length > 1;
8932
9677
  const [isSaving, setIsSaving] = useState(false);
@@ -8990,7 +9735,7 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
8990
9735
  targetLayers.forEach((l) => {
8991
9736
  items.push({
8992
9737
  key: l.id,
8993
- label: shownLayerName(l, canvasLabels) || labels.untitledLayer,
9738
+ label: shownLayerName(l, canvasLabels2) || labels.untitledLayer,
8994
9739
  onClick: () => {
8995
9740
  if (action === "copy") {
8996
9741
  onCopyFeaturesToLayer == null ? void 0 : onCopyFeaturesToLayer(featureIds, l.id);
@@ -9014,7 +9759,7 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
9014
9759
  });
9015
9760
  }
9016
9761
  return items;
9017
- }, [targetLayers, featureIds, onCopyFeaturesToLayer, onMoveFeaturesToLayer, onCreateLayerAndCopyFeatures, onCreateLayerAndMoveFeatures, labels, canvasLabels]);
9762
+ }, [targetLayers, featureIds, onCopyFeaturesToLayer, onMoveFeaturesToLayer, onCreateLayerAndCopyFeatures, onCreateLayerAndMoveFeatures, labels, canvasLabels2]);
9018
9763
  const [name, setName] = useState("");
9019
9764
  const [description, setDescription] = useState("");
9020
9765
  const [startDate, setStartDate] = useState("");
@@ -9027,7 +9772,7 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
9027
9772
  const [strokeOpacity, setStrokeOpacity] = useState(1);
9028
9773
  const [fillColor, setFillColor] = useState("#3b82f6");
9029
9774
  const [fillOpacity, setFillOpacity] = useState(0.2);
9030
- const [labelText, setLabelText] = useState(canvasLabels.newTextLabel);
9775
+ const [labelText, setLabelText] = useState(canvasLabels2.newTextLabel);
9031
9776
  const [fontSize, setFontSize] = useState(14);
9032
9777
  const [fontColor, setFontColor] = useState("#000000");
9033
9778
  const [fontWeight, setFontWeight] = useState("normal");
@@ -9043,7 +9788,7 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
9043
9788
  useEffect(() => {
9044
9789
  if (feature) {
9045
9790
  if (feature.properties.kind === "text") {
9046
- const textLabel = feature.properties.label || feature.properties.text || canvasLabels.newTextLabel;
9791
+ const textLabel = feature.properties.label || feature.properties.text || canvasLabels2.newTextLabel;
9047
9792
  setName(textLabel);
9048
9793
  setLabelText(textLabel);
9049
9794
  } else {
@@ -10761,10 +11506,9 @@ function Timebar({
10761
11506
  className,
10762
11507
  timebarExtra,
10763
11508
  keepExtraWhenEmpty = false,
10764
- formatCount: formatCount2,
10765
- labels: labelOverrides
11509
+ formatCount
10766
11510
  }) {
10767
- const labels = { ...useMapLabels().timebar, ...labelOverrides };
11511
+ const labels = useMapLabels().timebar;
10768
11512
  const {
10769
11513
  isEnabled,
10770
11514
  hasTemporalData,
@@ -11034,7 +11778,7 @@ function Timebar({
11034
11778
  {
11035
11779
  className: "text-xs text-muted-foreground ml-1",
11036
11780
  "data-testid": "text-timeline-feature-count",
11037
- children: formatCount2 ? formatCount2({
11781
+ children: formatCount ? formatCount({
11038
11782
  total: temporalFeatures.length,
11039
11783
  selected: hasSelection ? selectedTemporalFeatures.length : null
11040
11784
  }) : hasSelection ? labels.selectedCount({ selected: selectedTemporalFeatures.length, total: temporalFeatures.length }) : labels.featureCount(temporalFeatures.length)
@@ -12036,6 +12780,29 @@ function fieldValueDistribution(features, fieldName, maxValues, scanLimit = feat
12036
12780
  }
12037
12781
  return Array.from(counts2.entries()).sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0])).slice(0, maxValues).map(([value, count]) => ({ value, count }));
12038
12782
  }
12783
+ const CLUSTER_PIE_MAX_CATEGORIES = 15;
12784
+ function clusterPieKey(raw) {
12785
+ return raw !== null && typeof raw === "object" ? JSON.stringify(raw) : categoricalKey(raw);
12786
+ }
12787
+ const ranksAbove = (value, count, other) => count > other.count || count === other.count && value < other.value;
12788
+ function clusterPieCategories(points, fieldName) {
12789
+ var _a;
12790
+ const counts2 = /* @__PURE__ */ new Map();
12791
+ for (const point2 of points) {
12792
+ const key = clusterPieKey((_a = point2.properties) == null ? void 0 : _a[fieldName]);
12793
+ if (key !== null) counts2.set(key, (counts2.get(key) ?? 0) + 1);
12794
+ }
12795
+ const values = [];
12796
+ counts2.forEach((count, value) => {
12797
+ let at = values.length;
12798
+ while (at > 0 && ranksAbove(value, count, values[at - 1])) at--;
12799
+ if (at >= CLUSTER_PIE_MAX_CATEGORIES) return;
12800
+ values.splice(at, 0, { value, count });
12801
+ if (values.length > CLUSTER_PIE_MAX_CATEGORIES) values.pop();
12802
+ });
12803
+ const inSlices = values.reduce((sum, v) => sum + v.count, 0);
12804
+ return { values, otherCount: points.length - inSlices };
12805
+ }
12039
12806
  const SELECTION_OVERLAY_SOURCE_ID = "selection-overlay";
12040
12807
  const SELECTION_OVERLAY_LAYER_IDS = {
12041
12808
  iconRing: "selection-overlay-icon-ring",
@@ -12104,530 +12871,220 @@ function buildSelectionOverlayStack(newTextLabel) {
12104
12871
  filter: NOT_HOST_FILTER,
12105
12872
  layout: {
12106
12873
  ...buildCustomLabelLayout(newTextLabel),
12107
- // Never hidden by the auto-label density cap, which only flips the
12108
- // unpinned base layer: with base labels off, the selected ones stay.
12109
- visibility: "visible",
12110
- // Full collision; topmost, so placed first (see the module comment):
12111
- // selected labels thin among themselves and win against every other.
12112
- "text-allow-overlap": false,
12113
- "text-ignore-placement": false,
12114
- "text-optional": true,
12115
- // Same ranking as the base layers, so which selected label wins a
12116
- // crowded spot is stable across repaints.
12117
- "symbol-sort-key": ["coalesce", ["get", "_labelPriority"], 100]
12118
- },
12119
- paint: buildCustomLabelPaint()
12120
- }
12121
- ];
12122
- }
12123
- function buildSelectionOverlayData(ids, styleFor) {
12124
- const features = [];
12125
- ids.forEach((id) => {
12126
- styleFor(id).forEach((feature) => features.push(feature));
12127
- });
12128
- return { type: "FeatureCollection", features };
12129
- }
12130
- function renderedFeatureId(f) {
12131
- var _a;
12132
- const fromProps = (_a = f.properties) == null ? void 0 : _a.id;
12133
- if (fromProps !== void 0 && fromProps !== null && fromProps !== "") return String(fromProps);
12134
- if (f.id !== void 0 && f.id !== null && f.id !== "") return String(f.id);
12135
- return null;
12136
- }
12137
- function resolveTooltipFeature(rendered, lookup) {
12138
- const id = renderedFeatureId(rendered);
12139
- const stored = id === null ? null : lookup(id);
12140
- if (stored) {
12141
- return deepClone({
12142
- type: "Feature",
12143
- geometry: stored.geometry,
12144
- properties: stored.properties ?? {},
12145
- id: stored.id
12146
- });
12147
- }
12148
- return {
12149
- type: "Feature",
12150
- geometry: rendered.geometry,
12151
- properties: { ...rendered.properties ?? {} },
12152
- id: rendered.id
12153
- };
12154
- }
12155
- const DEFAULT_POINT_RADIUS = 5;
12156
- const DEFAULT_ICON_SIZE = 24;
12157
- const MAX_POINT_RADIUS = 24;
12158
- const SAME_SPOT_PX = 1;
12159
- const CROWD = 16;
12160
- const SCAN_LIMIT = 256;
12161
- const isDot = (m) => m.center !== null;
12162
- const distance = (a, b) => Math.hypot(a.x - b.x, a.y - b.y);
12163
- function paintedRadius(f) {
12164
- var _a, _b;
12165
- const p = f.properties ?? {};
12166
- const hidden = ((_a = f.state) == null ? void 0 : _a[TIMELINE_HIDDEN_KEY]) === true || p.isHiddenByCluster === 1 || p.isHiddenByHeatmap === 1;
12167
- if (hidden) return 0;
12168
- if (typeof p.icon === "string" && p.icon !== "") {
12169
- return typeof p.iconSize === "number" && Number.isFinite(p.iconSize) ? p.iconSize / 2 : DEFAULT_ICON_SIZE / 2;
12170
- }
12171
- const r = ((_b = f.state) == null ? void 0 : _b[TRACE_ENDPOINT_KEY]) === true ? p._endpointRadius : p.pointRadius;
12172
- return typeof r === "number" && Number.isFinite(r) ? r : DEFAULT_POINT_RADIUS;
12173
- }
12174
- function labelPriority(f) {
12175
- var _a;
12176
- const v = (_a = f.properties) == null ? void 0 : _a._labelPriority;
12177
- return typeof v === "number" && Number.isFinite(v) ? v : DEFAULT_LABEL_PRIORITY;
12178
- }
12179
- function members(features, project, maxDots = Infinity) {
12180
- const seen = /* @__PURE__ */ new Set();
12181
- const out = [];
12182
- let dots = 0;
12183
- for (const feature of features) {
12184
- const id = renderedFeatureId(feature);
12185
- if (id === null || seen.has(id)) continue;
12186
- if (seen.size === SCAN_LIMIT || dots === maxDots) return { members: out, cut: true };
12187
- seen.add(id);
12188
- if (feature.geometry.type !== "Point") {
12189
- out.push({ id, feature, center: null, radius: 0 });
12190
- continue;
12191
- }
12192
- const radius = paintedRadius(feature);
12193
- if (radius <= 0) continue;
12194
- out.push({ id, feature, center: project(feature.geometry.coordinates), radius });
12195
- dots++;
12196
- }
12197
- return { members: out, cut: false };
12198
- }
12199
- function searchBox(dot) {
12200
- const reach = dot.radius + MAX_POINT_RADIUS;
12201
- return [[dot.center.x - reach, dot.center.y - reach], [dot.center.x + reach, dot.center.y + reach]];
12202
- }
12203
- function featureStackAt(point2, hits, queryBox, project) {
12204
- const hit = members(hits, project, CROWD + 1).members;
12205
- const under = hit.filter(isDot);
12206
- if (under.length === 0) return { features: hit.length > 0 ? [hit[0].feature] : [], more: false };
12207
- const fromCursor = (d) => distance(d.center, point2);
12208
- const byCursor = (a, b) => fromCursor(a) - fromCursor(b);
12209
- let dots;
12210
- let more;
12211
- if (under.length > CROWD) {
12212
- dots = under.sort(byCursor).slice(0, CROWD);
12213
- more = true;
12214
- } else {
12215
- const nearest = under.reduce((a, b) => fromCursor(b) < fromCursor(a) ? b : a);
12216
- const taken = new Set(under.map((d) => d.id));
12217
- const box = members(queryBox(searchBox(nearest)), project);
12218
- const neighbours = box.members.filter(isDot).filter((m) => !taken.has(m.id) && distance(m.center, nearest.center) <= m.radius + nearest.radius);
12219
- dots = [...under, ...neighbours].sort(byCursor);
12220
- more = box.cut;
12221
- }
12222
- const spot = dots[0].center;
12223
- const onSpot = dots.filter((d) => distance(d.center, spot) < SAME_SPOT_PX).sort((a, b) => labelPriority(a.feature) - labelPriority(b.feature));
12224
- const rest = dots.filter((d) => distance(d.center, spot) >= SAME_SPOT_PX);
12225
- return { features: [...onSpot, ...rest].map((d) => d.feature), more };
12226
- }
12227
- function computeBubbleDomain(values) {
12228
- let min = Infinity;
12229
- let max = -Infinity;
12230
- for (const v of values) {
12231
- if (!Number.isFinite(v)) continue;
12232
- if (v < min) min = v;
12233
- if (v > max) max = v;
12234
- }
12235
- return isFinite(min) ? { min, max } : null;
12236
- }
12237
- function bubbleGradientColorExpression(prop, min, max) {
12238
- if (!(max > min)) return gradientColor(0.5);
12239
- const expr = ["interpolate", ["linear"], ["get", prop]];
12240
- const span = max - min;
12241
- GRADIENT_RAMP.forEach((color, i) => {
12242
- expr.push(min + span * i / (GRADIENT_RAMP.length - 1), color);
12243
- });
12244
- return expr;
12245
- }
12246
- function createClusterGradientManager(map, sourceId, options) {
12247
- const clusterProp = options.valueProp ?? "point_count";
12248
- let scheduled = false;
12249
- let lastDomainKey = "";
12250
- let reportedFailure = false;
12251
- function reportFailure(stage, error) {
12252
- if (reportedFailure) return;
12253
- reportedFailure = true;
12254
- console.error(`[map-component] cluster gradient ${stage} failed; bubbles keep their current colors:`, error);
12255
- }
12256
- function apply() {
12257
- scheduled = false;
12258
- let values;
12259
- try {
12260
- if (!map.getSource(sourceId)) return;
12261
- values = map.querySourceFeatures(sourceId, { filter: ["has", "point_count"] }).map((f) => {
12262
- var _a;
12263
- return Number((_a = f.properties) == null ? void 0 : _a[clusterProp]);
12264
- });
12265
- if (options.singleLayerId) {
12266
- const singles = map.querySourceFeatures(sourceId, {
12267
- filter: ["all", ["!", ["has", "point_count"]], [">", ["get", CLUSTER_COUNT_VALUE_PROP], 1]]
12268
- });
12269
- values.push(...singles.map((f) => {
12270
- var _a;
12271
- return Number((_a = f.properties) == null ? void 0 : _a[CLUSTER_COUNT_VALUE_PROP]);
12272
- }));
12273
- }
12274
- } catch (error) {
12275
- reportFailure("domain query", error);
12276
- return;
12277
- }
12278
- const domain = computeBubbleDomain(values);
12279
- if (!domain) return;
12280
- const key = `${domain.min}|${domain.max}`;
12281
- if (key === lastDomainKey) return;
12282
- lastDomainKey = key;
12283
- try {
12284
- if (map.getLayer(options.clustersLayerId)) {
12285
- map.setPaintProperty(
12286
- options.clustersLayerId,
12287
- "circle-color",
12288
- bubbleGradientColorExpression(clusterProp, domain.min, domain.max)
12289
- );
12290
- }
12291
- if (options.singleLayerId && map.getLayer(options.singleLayerId)) {
12292
- map.setPaintProperty(
12293
- options.singleLayerId,
12294
- "circle-color",
12295
- bubbleGradientColorExpression(CLUSTER_COUNT_VALUE_PROP, domain.min, domain.max)
12296
- );
12297
- }
12298
- } catch (error) {
12299
- reportFailure("paint update", error);
12300
- lastDomainKey = "";
12301
- }
12302
- }
12303
- function schedule() {
12304
- if (scheduled) return;
12305
- scheduled = true;
12306
- requestAnimationFrame(apply);
12307
- }
12308
- function onData(e) {
12309
- if (e.dataType === "source" && e.sourceId === sourceId) schedule();
12310
- }
12311
- map.on("moveend", schedule);
12312
- map.on("data", onData);
12313
- schedule();
12314
- return {
12315
- destroy: () => {
12316
- map.off("moveend", schedule);
12317
- map.off("data", onData);
12874
+ // Never hidden by the auto-label density cap, which only flips the
12875
+ // unpinned base layer: with base labels off, the selected ones stay.
12876
+ visibility: "visible",
12877
+ // Full collision; topmost, so placed first (see the module comment):
12878
+ // selected labels thin among themselves and win against every other.
12879
+ "text-allow-overlap": false,
12880
+ "text-ignore-placement": false,
12881
+ "text-optional": true,
12882
+ // Same ranking as the base layers, so which selected label wins a
12883
+ // crowded spot is stable across repaints.
12884
+ "symbol-sort-key": ["coalesce", ["get", "_labelPriority"], 100]
12885
+ },
12886
+ paint: buildCustomLabelPaint()
12318
12887
  }
12319
- };
12888
+ ];
12320
12889
  }
12321
- const OTHER_BUCKET_KEY = "__other__";
12322
- const OTHER_BUCKET_COLOR = "#9ca3af";
12323
- function toDisplayName(name, otherLabel) {
12324
- return name === OTHER_BUCKET_KEY ? otherLabel : name;
12890
+ function buildSelectionOverlayData(ids, styleFor) {
12891
+ const features = [];
12892
+ ids.forEach((id) => {
12893
+ styleFor(id).forEach((feature) => features.push(feature));
12894
+ });
12895
+ return { type: "FeatureCollection", features };
12325
12896
  }
12326
- function createPieSVG(categories, total, otherLabel, size = 44, onSliceHover, badgeValue) {
12327
- const container = document.createElement("div");
12328
- container.style.width = `${size}px`;
12329
- container.style.height = `${size}px`;
12330
- container.style.cursor = "pointer";
12331
- const radius = size / 2;
12332
- const innerRadius = radius * 0.5;
12333
- const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
12334
- svg.setAttribute("width", String(size));
12335
- svg.setAttribute("height", String(size));
12336
- svg.setAttribute("viewBox", `0 0 ${size} ${size}`);
12337
- svg.style.display = "block";
12338
- const bgCircle = document.createElementNS("http://www.w3.org/2000/svg", "circle");
12339
- bgCircle.setAttribute("cx", String(radius));
12340
- bgCircle.setAttribute("cy", String(radius));
12341
- bgCircle.setAttribute("r", String(radius));
12342
- bgCircle.setAttribute("fill", "white");
12343
- svg.appendChild(bgCircle);
12344
- const slicesSum = categories.reduce((s, c) => s + c.count, 0);
12345
- const remainder = Math.max(0, total - slicesSum);
12346
- const renderList = remainder > 0 ? [...categories, { name: "__remainder__", displayName: otherLabel, count: remainder, color: OTHER_BUCKET_COLOR }] : categories;
12347
- const nonZeroSlices = renderList.filter((c) => c.count > 0);
12348
- const isSingleFullSlice = nonZeroSlices.length === 1 && nonZeroSlices[0].count >= total;
12349
- if (isSingleFullSlice) {
12350
- const cat = nonZeroSlices[0];
12351
- const ring = document.createElementNS("http://www.w3.org/2000/svg", "path");
12352
- const d = [
12353
- `M 0 ${radius}`,
12354
- `a ${radius} ${radius} 0 1 0 ${radius * 2} 0`,
12355
- `a ${radius} ${radius} 0 1 0 ${-radius * 2} 0`,
12356
- `M ${radius - innerRadius} ${radius}`,
12357
- `a ${innerRadius} ${innerRadius} 0 1 1 ${innerRadius * 2} 0`,
12358
- `a ${innerRadius} ${innerRadius} 0 1 1 ${-innerRadius * 2} 0`,
12359
- "Z"
12360
- ].join(" ");
12361
- ring.setAttribute("d", d);
12362
- ring.setAttribute("fill-rule", "evenodd");
12363
- ring.setAttribute("fill", cat.color);
12364
- ring.setAttribute("stroke", "white");
12365
- ring.setAttribute("stroke-width", "1");
12366
- ring.style.transition = "opacity 0.15s";
12367
- ring.addEventListener("mouseenter", (e) => {
12368
- ring.style.opacity = "0.8";
12369
- if (onSliceHover) onSliceHover(cat, e);
12370
- });
12371
- ring.addEventListener("mouseleave", (e) => {
12372
- ring.style.opacity = "1";
12373
- if (onSliceHover) onSliceHover(null, e);
12897
+ function renderedFeatureId(f) {
12898
+ var _a;
12899
+ const fromProps = (_a = f.properties) == null ? void 0 : _a.id;
12900
+ if (fromProps !== void 0 && fromProps !== null && fromProps !== "") return String(fromProps);
12901
+ if (f.id !== void 0 && f.id !== null && f.id !== "") return String(f.id);
12902
+ return null;
12903
+ }
12904
+ function resolveTooltipFeature(rendered, lookup) {
12905
+ const id = renderedFeatureId(rendered);
12906
+ const stored = id === null ? null : lookup(id);
12907
+ if (stored) {
12908
+ return deepClone({
12909
+ type: "Feature",
12910
+ geometry: stored.geometry,
12911
+ properties: stored.properties ?? {},
12912
+ id: stored.id
12374
12913
  });
12375
- svg.appendChild(ring);
12376
12914
  }
12377
- let currentAngle = -90;
12378
- (isSingleFullSlice ? [] : renderList).forEach((cat) => {
12379
- if (cat.count === 0) return;
12380
- const sliceAngle = cat.count / total * 360;
12381
- const startAngle = currentAngle;
12382
- const endAngle = currentAngle + sliceAngle;
12383
- const startRad = startAngle * Math.PI / 180;
12384
- const endRad = endAngle * Math.PI / 180;
12385
- const x1 = radius + radius * Math.cos(startRad);
12386
- const y1 = radius + radius * Math.sin(startRad);
12387
- const x2 = radius + radius * Math.cos(endRad);
12388
- const y2 = radius + radius * Math.sin(endRad);
12389
- const x3 = radius + innerRadius * Math.cos(endRad);
12390
- const y3 = radius + innerRadius * Math.sin(endRad);
12391
- const x4 = radius + innerRadius * Math.cos(startRad);
12392
- const y4 = radius + innerRadius * Math.sin(startRad);
12393
- const largeArc = sliceAngle > 180 ? 1 : 0;
12394
- const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
12395
- const d = [
12396
- `M ${x1} ${y1}`,
12397
- `A ${radius} ${radius} 0 ${largeArc} 1 ${x2} ${y2}`,
12398
- `L ${x3} ${y3}`,
12399
- `A ${innerRadius} ${innerRadius} 0 ${largeArc} 0 ${x4} ${y4}`,
12400
- "Z"
12401
- ].join(" ");
12402
- path.setAttribute("d", d);
12403
- path.setAttribute("fill", cat.color);
12404
- path.setAttribute("stroke", "white");
12405
- path.setAttribute("stroke-width", "1");
12406
- path.style.transition = "opacity 0.15s";
12407
- path.addEventListener("mouseenter", (e) => {
12408
- path.style.opacity = "0.8";
12409
- if (onSliceHover) onSliceHover(cat, e);
12410
- });
12411
- path.addEventListener("mouseleave", (e) => {
12412
- path.style.opacity = "1";
12413
- if (onSliceHover) onSliceHover(null, e);
12414
- });
12415
- svg.appendChild(path);
12416
- currentAngle = endAngle;
12417
- });
12418
- const centerCircle = document.createElementNS("http://www.w3.org/2000/svg", "circle");
12419
- centerCircle.setAttribute("cx", String(radius));
12420
- centerCircle.setAttribute("cy", String(radius));
12421
- centerCircle.setAttribute("r", String(innerRadius - 2));
12422
- centerCircle.setAttribute("fill", "#1f2937");
12423
- svg.appendChild(centerCircle);
12424
- const badgeText = formatClusterBadge(badgeValue ?? total);
12425
- const text = document.createElementNS("http://www.w3.org/2000/svg", "text");
12426
- text.setAttribute("x", String(radius));
12427
- text.setAttribute("y", String(radius));
12428
- text.setAttribute("text-anchor", "middle");
12429
- text.setAttribute("dominant-baseline", "central");
12430
- text.setAttribute("fill", "white");
12431
- text.setAttribute("font-size", badgeText.length >= 6 ? "8" : badgeText.length >= 4 ? "9" : badgeText.length >= 3 ? "10" : "11");
12432
- text.setAttribute("font-weight", "bold");
12433
- text.setAttribute("font-family", "system-ui, sans-serif");
12434
- text.textContent = badgeText;
12435
- svg.appendChild(text);
12436
- container.appendChild(svg);
12437
- return container;
12915
+ return {
12916
+ type: "Feature",
12917
+ geometry: rendered.geometry,
12918
+ properties: { ...rendered.properties ?? {} },
12919
+ id: rendered.id
12920
+ };
12438
12921
  }
12439
- let tooltipEl = null;
12440
- function showTooltip(cat, x, y) {
12441
- if (!tooltipEl) {
12442
- tooltipEl = document.createElement("div");
12443
- tooltipEl.style.cssText = `
12444
- position: fixed;
12445
- background: rgba(0,0,0,0.85);
12446
- color: white;
12447
- padding: 6px 10px;
12448
- border-radius: 4px;
12449
- font-size: 12px;
12450
- font-family: system-ui, sans-serif;
12451
- pointer-events: none;
12452
- z-index: 10000;
12453
- white-space: nowrap;
12454
- box-shadow: 0 2px 8px rgba(0,0,0,0.3);
12455
- `;
12456
- document.body.appendChild(tooltipEl);
12922
+ const DEFAULT_POINT_RADIUS = 5;
12923
+ const DEFAULT_ICON_SIZE = 24;
12924
+ const MAX_POINT_RADIUS = 24;
12925
+ const SAME_SPOT_PX = 1;
12926
+ const CROWD = 16;
12927
+ const SCAN_LIMIT = 256;
12928
+ const isDot = (m) => m.center !== null;
12929
+ const distance = (a, b) => Math.hypot(a.x - b.x, a.y - b.y);
12930
+ function paintedRadius(f) {
12931
+ var _a, _b;
12932
+ const p = f.properties ?? {};
12933
+ const hidden = ((_a = f.state) == null ? void 0 : _a[TIMELINE_HIDDEN_KEY]) === true || p.isHiddenByCluster === 1 || p.isHiddenByHeatmap === 1;
12934
+ if (hidden) return 0;
12935
+ if (typeof p.icon === "string" && p.icon !== "") {
12936
+ return typeof p.iconSize === "number" && Number.isFinite(p.iconSize) ? p.iconSize / 2 : DEFAULT_ICON_SIZE / 2;
12457
12937
  }
12458
- while (tooltipEl.firstChild) tooltipEl.removeChild(tooltipEl.firstChild);
12459
- const row = document.createElement("div");
12460
- row.style.cssText = "display: flex; align-items: center; gap: 6px;";
12461
- const swatch = document.createElement("span");
12462
- swatch.style.cssText = "width: 10px; height: 10px; border-radius: 2px;";
12463
- swatch.style.backgroundColor = cat.color;
12464
- row.appendChild(swatch);
12465
- const label = document.createElement("span");
12466
- const name = document.createElement("strong");
12467
- name.textContent = cat.displayName;
12468
- label.appendChild(name);
12469
- label.appendChild(document.createTextNode(`: ${cat.count}`));
12470
- row.appendChild(label);
12471
- tooltipEl.appendChild(row);
12472
- tooltipEl.style.left = `${x + 12}px`;
12473
- tooltipEl.style.top = `${y - 10}px`;
12474
- tooltipEl.style.display = "block";
12938
+ const r = ((_b = f.state) == null ? void 0 : _b[TRACE_ENDPOINT_KEY]) === true ? p._endpointRadius : p.pointRadius;
12939
+ return typeof r === "number" && Number.isFinite(r) ? r : DEFAULT_POINT_RADIUS;
12475
12940
  }
12476
- function hideTooltip() {
12477
- if (tooltipEl) {
12478
- tooltipEl.style.display = "none";
12941
+ function labelPriority(f) {
12942
+ var _a;
12943
+ const v = (_a = f.properties) == null ? void 0 : _a._labelPriority;
12944
+ return typeof v === "number" && Number.isFinite(v) ? v : DEFAULT_LABEL_PRIORITY;
12945
+ }
12946
+ function members(features, project, maxDots = Infinity) {
12947
+ const seen = /* @__PURE__ */ new Set();
12948
+ const out = [];
12949
+ let dots = 0;
12950
+ for (const feature of features) {
12951
+ const id = renderedFeatureId(feature);
12952
+ if (id === null || seen.has(id)) continue;
12953
+ if (seen.size === SCAN_LIMIT || dots === maxDots) return { members: out, cut: true };
12954
+ seen.add(id);
12955
+ if (feature.geometry.type !== "Point") {
12956
+ out.push({ id, feature, center: null, radius: 0 });
12957
+ continue;
12958
+ }
12959
+ const radius = paintedRadius(feature);
12960
+ if (radius <= 0) continue;
12961
+ out.push({ id, feature, center: project(feature.geometry.coordinates), radius });
12962
+ dots++;
12963
+ }
12964
+ return { members: out, cut: false };
12965
+ }
12966
+ function searchBox(dot) {
12967
+ const reach = dot.radius + MAX_POINT_RADIUS;
12968
+ return [[dot.center.x - reach, dot.center.y - reach], [dot.center.x + reach, dot.center.y + reach]];
12969
+ }
12970
+ function featureStackAt(point2, hits, queryBox, project) {
12971
+ const hit = members(hits, project, CROWD + 1).members;
12972
+ const under = hit.filter(isDot);
12973
+ if (under.length === 0) return { features: hit.length > 0 ? [hit[0].feature] : [], more: false };
12974
+ const fromCursor = (d) => distance(d.center, point2);
12975
+ const byCursor = (a, b) => fromCursor(a) - fromCursor(b);
12976
+ let dots;
12977
+ let more;
12978
+ if (under.length > CROWD) {
12979
+ dots = under.sort(byCursor).slice(0, CROWD);
12980
+ more = true;
12981
+ } else {
12982
+ const nearest = under.reduce((a, b) => fromCursor(b) < fromCursor(a) ? b : a);
12983
+ const taken = new Set(under.map((d) => d.id));
12984
+ const box = members(queryBox(searchBox(nearest)), project);
12985
+ const neighbours = box.members.filter(isDot).filter((m) => !taken.has(m.id) && distance(m.center, nearest.center) <= m.radius + nearest.radius);
12986
+ dots = [...under, ...neighbours].sort(byCursor);
12987
+ more = box.cut;
12479
12988
  }
12989
+ const spot = dots[0].center;
12990
+ const onSpot = dots.filter((d) => distance(d.center, spot) < SAME_SPOT_PX).sort((a, b) => labelPriority(a.feature) - labelPriority(b.feature));
12991
+ const rest = dots.filter((d) => distance(d.center, spot) >= SAME_SPOT_PX);
12992
+ return { features: [...onSpot, ...rest].map((d) => d.feature), more };
12480
12993
  }
12481
- function fingerprintCluster(pointCount, counts2, size, badgeValue) {
12482
- return `${size}|${pointCount}|${badgeValue ?? ""}|${counts2.join(",")}`;
12994
+ function computeBubbleDomain(values) {
12995
+ let min = Infinity;
12996
+ let max = -Infinity;
12997
+ for (const v of values) {
12998
+ if (!Number.isFinite(v)) continue;
12999
+ if (v < min) min = v;
13000
+ if (v > max) max = v;
13001
+ }
13002
+ return isFinite(min) ? { min, max } : null;
12483
13003
  }
12484
- function buildPieElement(categories, pointCount, otherLabel, size, source, clusterId, map, coords, badgeValue) {
12485
- const el = createPieSVG(categories, pointCount, otherLabel, size, (cat, event) => {
12486
- if (cat) {
12487
- showTooltip(cat, event.clientX, event.clientY);
12488
- } else {
12489
- hideTooltip();
12490
- }
12491
- }, badgeValue);
12492
- el.addEventListener("click", () => {
12493
- source.getClusterExpansionZoom(clusterId).then((zoom) => {
12494
- if (typeof zoom === "number") {
12495
- map.easeTo({ center: coords, zoom: zoom + 0.5 });
12496
- }
12497
- }).catch(() => {
12498
- });
13004
+ function bubbleGradientColorExpression(prop, min, max) {
13005
+ if (!(max > min)) return gradientColor(0.5);
13006
+ const expr = ["interpolate", ["linear"], ["get", prop]];
13007
+ const span = max - min;
13008
+ GRADIENT_RAMP.forEach((color, i) => {
13009
+ expr.push(min + span * i / (GRADIENT_RAMP.length - 1), color);
12499
13010
  });
12500
- return el;
13011
+ return expr;
12501
13012
  }
12502
- function renderClusterPies(map, sourceId, categoryValues, categoryColorMap, markers, otherLabel) {
12503
- const source = map.getSource(sourceId);
12504
- if (!source) return;
12505
- const clusters = map.querySourceFeatures(sourceId, {
12506
- filter: ["has", "point_count"]
12507
- });
12508
- const visibleClusterIds = /* @__PURE__ */ new Set();
12509
- clusters.forEach((feature) => {
12510
- var _a, _b, _c;
12511
- const clusterId = (_a = feature.properties) == null ? void 0 : _a.cluster_id;
12512
- if (clusterId === void 0) return;
12513
- const clusterKey = `${clusterId}`;
12514
- visibleClusterIds.add(clusterKey);
12515
- const coords = feature.geometry.coordinates;
12516
- const pointCount = ((_b = feature.properties) == null ? void 0 : _b.point_count) || 0;
12517
- const sumRaw = (_c = feature.properties) == null ? void 0 : _c[CLUSTER_SUM_PROP];
12518
- const sumNum = typeof sumRaw === "number" ? sumRaw : sumRaw != null ? Number(sumRaw) : NaN;
12519
- const badgeValue = Number.isFinite(sumNum) ? sumNum : void 0;
12520
- const allCounts = categoryValues.map((_, i) => {
12521
- var _a2;
12522
- return Number(((_a2 = feature.properties) == null ? void 0 : _a2[`cat_${i}`]) || 0);
12523
- });
12524
- const categories = categoryValues.map((cat, i) => ({
12525
- name: cat,
12526
- displayName: toDisplayName(cat, otherLabel),
12527
- count: allCounts[i],
12528
- color: categoryColorMap[cat] || "#3b82f6"
12529
- })).filter((c) => c.count > 0);
12530
- const size = pointCount < 100 ? 40 : pointCount < 750 ? 50 : 60;
12531
- const fingerprint = fingerprintCluster(pointCount, allCounts, size, badgeValue);
12532
- const existing = markers.get(clusterKey);
12533
- if (existing && existing.fingerprint === fingerprint) {
12534
- existing.marker.setLngLat(coords);
13013
+ function createClusterGradientManager(map, sourceId, options) {
13014
+ const clusterProp = options.valueProp ?? "point_count";
13015
+ let scheduled = false;
13016
+ let lastDomainKey = "";
13017
+ let reportedFailure = false;
13018
+ function reportFailure(stage, error) {
13019
+ if (reportedFailure) return;
13020
+ reportedFailure = true;
13021
+ console.error(`[map-component] cluster gradient ${stage} failed; bubbles keep their current colors:`, error);
13022
+ }
13023
+ function apply() {
13024
+ scheduled = false;
13025
+ let values;
13026
+ try {
13027
+ if (!map.getSource(sourceId)) return;
13028
+ values = map.querySourceFeatures(sourceId, { filter: ["has", "point_count"] }).map((f) => {
13029
+ var _a;
13030
+ return Number((_a = f.properties) == null ? void 0 : _a[clusterProp]);
13031
+ });
13032
+ if (options.singleLayerId) {
13033
+ const singles = map.querySourceFeatures(sourceId, {
13034
+ filter: ["all", ["!", ["has", "point_count"]], [">", ["get", CLUSTER_COUNT_VALUE_PROP], 1]]
13035
+ });
13036
+ values.push(...singles.map((f) => {
13037
+ var _a;
13038
+ return Number((_a = f.properties) == null ? void 0 : _a[CLUSTER_COUNT_VALUE_PROP]);
13039
+ }));
13040
+ }
13041
+ } catch (error) {
13042
+ reportFailure("domain query", error);
12535
13043
  return;
12536
13044
  }
12537
- const el = buildPieElement(categories, pointCount, otherLabel, size, source, clusterId, map, coords, badgeValue);
12538
- if (existing) {
12539
- existing.marker.remove();
12540
- }
12541
- const marker = new maplibregl.Marker({ element: el }).setLngLat(coords).addTo(map);
12542
- markers.set(clusterKey, { marker, fingerprint });
12543
- });
12544
- markers.forEach((entry, key) => {
12545
- if (!visibleClusterIds.has(key)) {
12546
- entry.marker.remove();
12547
- markers.delete(key);
13045
+ const domain = computeBubbleDomain(values);
13046
+ if (!domain) return;
13047
+ const key = `${domain.min}|${domain.max}`;
13048
+ if (key === lastDomainKey) return;
13049
+ lastDomainKey = key;
13050
+ try {
13051
+ if (map.getLayer(options.clustersLayerId)) {
13052
+ map.setPaintProperty(
13053
+ options.clustersLayerId,
13054
+ "circle-color",
13055
+ bubbleGradientColorExpression(clusterProp, domain.min, domain.max)
13056
+ );
13057
+ }
13058
+ if (options.singleLayerId && map.getLayer(options.singleLayerId)) {
13059
+ map.setPaintProperty(
13060
+ options.singleLayerId,
13061
+ "circle-color",
13062
+ bubbleGradientColorExpression(CLUSTER_COUNT_VALUE_PROP, domain.min, domain.max)
13063
+ );
13064
+ }
13065
+ } catch (error) {
13066
+ reportFailure("paint update", error);
13067
+ lastDomainKey = "";
12548
13068
  }
12549
- });
12550
- }
12551
- function createClusterPieManager(map, sourceId, categoryValues, categoryColorMap, otherLabel = DEFAULT_MAP_LABELS.canvas.clusterOther) {
12552
- const markers = /* @__PURE__ */ new Map();
12553
- let updateScheduled = false;
12554
- function scheduleUpdate() {
12555
- if (updateScheduled) return;
12556
- updateScheduled = true;
12557
- requestAnimationFrame(() => {
12558
- updateScheduled = false;
12559
- renderClusterPies(map, sourceId, categoryValues, categoryColorMap, markers, otherLabel);
12560
- });
13069
+ }
13070
+ function schedule() {
13071
+ if (scheduled) return;
13072
+ scheduled = true;
13073
+ requestAnimationFrame(apply);
12561
13074
  }
12562
13075
  function onData(e) {
12563
- if (e.dataType === "source" && e.sourceId === sourceId) {
12564
- scheduleUpdate();
12565
- }
13076
+ if (e.dataType === "source" && e.sourceId === sourceId) schedule();
12566
13077
  }
12567
- map.on("moveend", scheduleUpdate);
13078
+ map.on("moveend", schedule);
12568
13079
  map.on("data", onData);
12569
- scheduleUpdate();
13080
+ schedule();
12570
13081
  return {
12571
- update: scheduleUpdate,
12572
13082
  destroy: () => {
12573
- map.off("moveend", scheduleUpdate);
13083
+ map.off("moveend", schedule);
12574
13084
  map.off("data", onData);
12575
- markers.forEach((entry) => entry.marker.remove());
12576
- markers.clear();
12577
- hideTooltip();
12578
13085
  }
12579
13086
  };
12580
13087
  }
12581
- function ClusterPieManager(props) {
12582
- const { map, sourceId, categoryValues, categoryColorMap, visible } = props;
12583
- const otherLabel = useMapLabels().canvas.clusterOther;
12584
- const markersRef = useRef(/* @__PURE__ */ new Map());
12585
- const updateScheduled = useRef(false);
12586
- const updateMarkers = useCallback(() => {
12587
- if (!map || !visible) {
12588
- markersRef.current.forEach((entry) => entry.marker.remove());
12589
- markersRef.current.clear();
12590
- return;
12591
- }
12592
- renderClusterPies(map, sourceId, categoryValues, categoryColorMap, markersRef.current, otherLabel);
12593
- }, [map, sourceId, categoryValues, categoryColorMap, visible, otherLabel]);
12594
- useEffect(() => {
12595
- if (!map) return;
12596
- const scheduleUpdate = () => {
12597
- if (updateScheduled.current) return;
12598
- updateScheduled.current = true;
12599
- requestAnimationFrame(() => {
12600
- updateScheduled.current = false;
12601
- updateMarkers();
12602
- });
12603
- };
12604
- const onData = (e) => {
12605
- if (e.dataType === "source" && e.sourceId === sourceId) {
12606
- scheduleUpdate();
12607
- }
12608
- };
12609
- scheduleUpdate();
12610
- map.on("moveend", scheduleUpdate);
12611
- map.on("data", onData);
12612
- return () => {
12613
- map.off("moveend", scheduleUpdate);
12614
- map.off("data", onData);
12615
- markersRef.current.forEach((entry) => entry.marker.remove());
12616
- markersRef.current.clear();
12617
- hideTooltip();
12618
- };
12619
- }, [map, sourceId, updateMarkers]);
12620
- useEffect(() => {
12621
- if (!visible) {
12622
- markersRef.current.forEach((entry) => entry.marker.remove());
12623
- markersRef.current.clear();
12624
- hideTooltip();
12625
- } else {
12626
- updateMarkers();
12627
- }
12628
- }, [visible, updateMarkers]);
12629
- return null;
12630
- }
12631
13088
  const EMPTY_ID_SET = /* @__PURE__ */ new Set();
12632
13089
  const EMPTY_SOURCES = [];
12633
13090
  const EMPTY_LABEL_MAP = /* @__PURE__ */ new Map();
@@ -12858,6 +13315,15 @@ function basemapInsertAnchor(map) {
12858
13315
  if (map.getLayer("custom-polygon-fill")) return "custom-polygon-fill";
12859
13316
  return void 0;
12860
13317
  }
13318
+ function layerPointFeatures(layer, stores) {
13319
+ const isPoint = (f) => {
13320
+ var _a;
13321
+ return ((_a = f == null ? void 0 : f.geometry) == null ? void 0 : _a.type) === "Point";
13322
+ };
13323
+ if (layer.readOnly) return (stores.readOnly.get(layer.id) ?? []).filter(isPoint);
13324
+ if (layer.visible) return layer.featureIds.map((id) => stores.draw.get(id)).filter(isPoint);
13325
+ return (stores.hidden.get(layer.id) ?? []).filter(isPoint);
13326
+ }
12861
13327
  function featureStateHostFor(m) {
12862
13328
  return {
12863
13329
  setFeatureState: (source, id, state) => m.setFeatureState({ source, id }, state),
@@ -12946,9 +13412,10 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
12946
13412
  keepTimebarExtra = false,
12947
13413
  onOpenInNewTab,
12948
13414
  onEntityContextMenu,
12949
- labels: labelsProp
13415
+ language
12950
13416
  }, ref) {
12951
- const labels = labelsProp ?? DEFAULT_MAP_LABELS;
13417
+ const shownLocale = useMapLocale(language);
13418
+ const labels = mapLabelsFor(shownLocale);
12952
13419
  const labelsRef = useRef(labels);
12953
13420
  labelsRef.current = labels;
12954
13421
  const mapContainer = useRef(null);
@@ -14389,6 +14856,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
14389
14856
  preDragRef.current = null;
14390
14857
  if (!pre || isApiAddingRef.current || pendingCaptureRef.current) return;
14391
14858
  pendingCaptureRef.current = {
14859
+ // eslint-disable-next-line i18next/no-literal-string -- undo labels only reach debug logs
14392
14860
  label: "move feature",
14393
14861
  before: pre.features,
14394
14862
  beforeLayers: pre.layers,
@@ -16404,27 +16872,27 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
16404
16872
  const handleClear = useCallback(() => {
16405
16873
  if (!draw.current) return;
16406
16874
  const activeLayer = layersRef.current.find((l) => l.id === activeEditingLayerId);
16407
- const toastLabels = labelsRef.current.toasts;
16875
+ const toastLabels2 = labelsRef.current.toasts;
16408
16876
  if (!activeLayer) {
16409
16877
  toast({
16410
- title: toastLabels.noLayerSelected,
16411
- description: toastLabels.noLayerSelectedDescription,
16878
+ title: toastLabels2.noLayerSelected,
16879
+ description: toastLabels2.noLayerSelectedDescription,
16412
16880
  variant: "destructive"
16413
16881
  });
16414
16882
  return;
16415
16883
  }
16416
16884
  if (activeLayer.readOnly) {
16417
16885
  toast({
16418
- title: toastLabels.cannotClearHpLayer,
16419
- description: toastLabels.cannotClearHpLayerDescription,
16886
+ title: toastLabels2.cannotClearHpLayer,
16887
+ description: toastLabels2.cannotClearHpLayerDescription,
16420
16888
  variant: "destructive"
16421
16889
  });
16422
16890
  return;
16423
16891
  }
16424
16892
  if (activeLayer.featureIds.length === 0) {
16425
16893
  toast({
16426
- title: toastLabels.layerEmpty,
16427
- description: toastLabels.layerEmptyDescription
16894
+ title: toastLabels2.layerEmpty,
16895
+ description: toastLabels2.layerEmptyDescription
16428
16896
  });
16429
16897
  return;
16430
16898
  }
@@ -16445,8 +16913,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
16445
16913
  scheduleTimelineUpdate();
16446
16914
  scheduleSync();
16447
16915
  toast({
16448
- title: toastLabels.layerCleared,
16449
- description: toastLabels.layerClearedDescription(shownLayerName(activeLayer, labelsRef.current.canvas))
16916
+ title: toastLabels2.layerCleared,
16917
+ description: toastLabels2.layerClearedDescription(shownLayerName(activeLayer, labelsRef.current.canvas))
16450
16918
  });
16451
16919
  }, [activeEditingLayerId, saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate, scheduleSync, toast]);
16452
16920
  const handleDeleteSelected = useCallback(() => {
@@ -17678,6 +18146,20 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
17678
18146
  },
17679
18147
  [layers]
17680
18148
  );
18149
+ const getClusterPieCategories = useCallback(
18150
+ (layerId, fieldName) => {
18151
+ const layer = layers.find((l) => l.id === layerId);
18152
+ if (!layer || !draw.current) return null;
18153
+ const points = layerPointFeatures(layer, {
18154
+ readOnly: readOnlyFeatures.current,
18155
+ hidden: hiddenFeatures.current,
18156
+ draw: draw.current
18157
+ });
18158
+ return clusterPieCategories(points, fieldName);
18159
+ },
18160
+ // Property edits change the pie counts without a new `layers`, as in the cluster effect.
18161
+ [layers, clusterDataVersion]
18162
+ );
17681
18163
  const handleFitToLayerFeatures = useCallback((layerId) => {
17682
18164
  if (!map.current) return;
17683
18165
  const customBounds = fitBoundsProvider == null ? void 0 : fitBoundsProvider(layerId);
@@ -19644,6 +20126,16 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
19644
20126
  }
19645
20127
  };
19646
20128
  }, [isMapLoaded, layers, currentMapStyle]);
20129
+ const newTextLabel = labels.canvas.newTextLabel;
20130
+ useEffect(() => {
20131
+ var _a;
20132
+ const m = map.current;
20133
+ if (!m || !isMapLoaded) return;
20134
+ const hostLabels = customLayerId("host-labels", SHARED_SOURCE_ID);
20135
+ const textField = buildCustomLabelLayout(newTextLabel)["text-field"];
20136
+ [...((_a = shardRegistryRef.current) == null ? void 0 : _a.labelLayerIds("all")) ?? [], SELECTION_OVERLAY_LAYER_IDS.label].filter((id) => id !== hostLabels && m.getLayer(id)).forEach((id) => m.setLayoutProperty(id, "text-field", textField));
20137
+ }, [isMapLoaded, newTextLabel]);
20138
+ const clusterOtherLabel = labels.canvas.clusterOther;
19647
20139
  useEffect(() => {
19648
20140
  if (!map.current || !draw.current || !isMapLoaded) return;
19649
20141
  const mapInstance = map.current;
@@ -19711,36 +20203,16 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
19711
20203
  const unclusteredLayerId = `unclustered-point-${layer.id}`;
19712
20204
  const singleValueLayerId = `cluster-single-${layer.id}`;
19713
20205
  const singleValueCountLayerId = `cluster-single-count-${layer.id}`;
19714
- let pointFeatures = [];
19715
- if (layer.visible) {
19716
- if (layer.readOnly) {
19717
- const roFeatures = readOnlyFeatures.current.get(layer.id) || [];
19718
- pointFeatures = roFeatures.filter((f) => {
19719
- var _a2;
19720
- return ((_a2 = f.geometry) == null ? void 0 : _a2.type) === "Point";
19721
- });
19722
- } else {
19723
- layer.featureIds.forEach((id) => {
19724
- var _a2;
19725
- const f = drawInstance.get(id);
19726
- if (f && ((_a2 = f.geometry) == null ? void 0 : _a2.type) === "Point") {
19727
- pointFeatures.push(f);
19728
- }
19729
- });
19730
- }
19731
- } else {
19732
- const hidden = hiddenFeatures.current.get(layer.id) || [];
19733
- pointFeatures = hidden.filter((f) => {
19734
- var _a2;
19735
- return ((_a2 = f.geometry) == null ? void 0 : _a2.type) === "Point";
19736
- });
19737
- }
20206
+ const pointFeatures = layerPointFeatures(layer, {
20207
+ readOnly: readOnlyFeatures.current,
20208
+ hidden: hiddenFeatures.current,
20209
+ draw: drawInstance
20210
+ });
19738
20211
  if (pointFeatures.length === 0) return;
19739
20212
  const groupByField = (_b = layer.clusterConfig) == null ? void 0 : _b.groupByField;
19740
20213
  const countByField = ((_c = layer.clusterConfig) == null ? void 0 : _c.countByFieldEnabled) && ((_d = layer.clusterConfig) == null ? void 0 : _d.countByField) || null;
19741
20214
  const bubbleGradient = !!((_e = layer.clusterConfig) == null ? void 0 : _e.bubbleGradient) && !groupByField;
19742
20215
  const OTHER_COLOR = OTHER_BUCKET_COLOR;
19743
- const MAX_CATEGORIES = 15;
19744
20216
  try {
19745
20217
  const layerColor = ((_g = (_f = layer.visualConfig) == null ? void 0 : _f.color) == null ? void 0 : _g.fixedColor) || "#3b82f6";
19746
20218
  let clusterProperties = {};
@@ -19748,15 +20220,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
19748
20220
  let categoryColorMap = {};
19749
20221
  let hasOtherBucket = false;
19750
20222
  if (groupByField) {
19751
- const counts2 = /* @__PURE__ */ new Map();
19752
- pointFeatures.forEach((f) => {
19753
- var _a2;
19754
- const key = categoricalKey((_a2 = f.properties) == null ? void 0 : _a2[groupByField]);
19755
- if (key === null) return;
19756
- counts2.set(key, (counts2.get(key) ?? 0) + 1);
19757
- });
19758
- const sorted = Array.from(counts2.entries()).sort((a, b) => b[1] - a[1]);
19759
- const topKeys = sorted.slice(0, MAX_CATEGORIES).map(([k]) => k);
20223
+ const topKeys = clusterPieCategories(pointFeatures, groupByField).values.map((v) => v.value);
19760
20224
  categoryValues = [...topKeys];
19761
20225
  hasOtherBucket = true;
19762
20226
  const fieldAsString = ["to-string", ["coalesce", ["get", groupByField], ""]];
@@ -19796,7 +20260,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
19796
20260
  sourceId,
19797
20261
  categoryValues,
19798
20262
  categoryColorMap,
19799
- labelsRef.current.canvas.clusterOther
20263
+ clusterOtherLabel
19800
20264
  );
19801
20265
  clusterPieManagers.current.set(layer.id, pieManager);
19802
20266
  } else {
@@ -19966,7 +20430,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
19966
20430
  } catch {
19967
20431
  }
19968
20432
  };
19969
- }, [isMapLoaded, layers, currentMapStyle, hashStringToColor$1, clusterDataVersion]);
20433
+ }, [isMapLoaded, layers, currentMapStyle, hashStringToColor$1, clusterDataVersion, clusterOtherLabel]);
19970
20434
  if (mapError) {
19971
20435
  return /* @__PURE__ */ jsx("div", { className: `flex items-center justify-center h-full bg-muted/30 ${className || ""}`, "data-testid": "map-error", children: /* @__PURE__ */ jsxs(Card, { className: "max-w-md", children: [
19972
20436
  /* @__PURE__ */ jsx("div", { className: "p-4 border-b border-border", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
@@ -20348,6 +20812,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
20348
20812
  getAvailableTraceFields,
20349
20813
  getSuggestedTraceField,
20350
20814
  getFieldValueDistribution,
20815
+ getClusterPieCategories,
20351
20816
  iconSuggestionProvider,
20352
20817
  onUpdateHeatmapConfig: handleUpdateHeatmapConfig,
20353
20818
  onUpdateClusterConfig: handleUpdateClusterConfig,
@@ -21490,7 +21955,6 @@ export {
21490
21955
  ActionPanel,
21491
21956
  ClusterPieManager,
21492
21957
  ColorPickerPopover,
21493
- DEFAULT_MAP_LABELS,
21494
21958
  DEFAULT_MAX_FEATURES_PER_LAYER,
21495
21959
  DebugSidebar,
21496
21960
  DrawingToolbar,