@qaecy/cue-sdk 0.0.17 → 0.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,12 @@
1
- import { getApps as ge, initializeApp as ue } from "firebase/app";
2
- import { ref as _, getDownloadURL as F, getMetadata as M, getBlob as Xt, updateMetadata as me, uploadBytesResumable as mt, uploadBytes as rt, StringFormat as we, uploadString as fe, listAll as z, getStorage as T, connectStorageEmulator as K } from "firebase/storage";
3
- import { Writer as ye, DataFactory as j } from "n3";
4
- import { getFirestore as be, connectFirestoreEmulator as ve, collection as wt, getDocs as _e, query as ke, where as Ee, limit as xe, doc as ft, getDoc as Ce, setDoc as Ie, serverTimestamp as Te, increment as Se } from "firebase/firestore";
5
- import { getAuth as Ae, connectAuthEmulator as Re, onIdTokenChanged as Pe, getIdTokenResult as st, signInWithEmailAndPassword as Oe, GoogleAuthProvider as at, OAuthProvider as it, signInWithPopup as De, signInWithRedirect as Le, getRedirectResult as qe, signInWithCustomToken as je, signOut as Ue, onAuthStateChanged as Me, fetchSignInMethodsForEmail as ze, linkWithPopup as Ne, unlink as $e, reauthenticateWithCredential as yt, EmailAuthProvider as Q, updatePassword as Fe, linkWithCredential as Be, verifyBeforeUpdateEmail as Ge, sendEmailVerification as He } from "firebase/auth";
6
- import { v5 as We } from "uuid";
1
+ import { getApps as fe, initializeApp as ye } from "firebase/app";
2
+ import { ref as _, getDownloadURL as V, getMetadata as M, getBlob as ee, updateMetadata as be, uploadBytesResumable as wt, uploadBytes as rt, StringFormat as ve, uploadString as _e, listAll as z, getStorage as T, connectStorageEmulator as K } from "firebase/storage";
3
+ import { Writer as ke, DataFactory as j } from "n3";
4
+ import { getFirestore as Ee, connectFirestoreEmulator as xe, collection as ft, getDocs as Ie, query as Ce, where as Te, limit as Se, doc as yt, getDoc as Re, setDoc as Ae, serverTimestamp as Pe, increment as Oe } from "firebase/firestore";
5
+ import { getAuth as De, connectAuthEmulator as Le, onIdTokenChanged as qe, getIdTokenResult as st, signInWithEmailAndPassword as je, GoogleAuthProvider as at, OAuthProvider as it, signInWithPopup as Ue, signInWithRedirect as Me, getRedirectResult as ze, signInWithCustomToken as Ne, signOut as $e, onAuthStateChanged as Fe, fetchSignInMethodsForEmail as Be, linkWithPopup as Ge, unlink as He, reauthenticateWithCredential as bt, EmailAuthProvider as Q, updatePassword as We, linkWithCredential as Ve, verifyBeforeUpdateEmail as Ke, sendEmailVerification as Qe } from "firebase/auth";
6
+ import { v5 as Xe } from "uuid";
7
7
  import "spark-md5";
8
- import { getFunctions as Yt, connectFunctionsEmulator as Zt, httpsCallable as B } from "firebase/functions";
9
- class pt {
8
+ import { getFunctions as oe, connectFunctionsEmulator as re, httpsCallable as F } from "firebase/functions";
9
+ class lt {
10
10
  queryEndpoint;
11
11
  updateEndpoint;
12
12
  baseHeaders;
@@ -18,7 +18,7 @@ class pt {
18
18
  constructor(t) {
19
19
  this.queryEndpoint = t.queryEndpoint, this.updateEndpoint = t.updateEndpoint, this.baseHeaders = Object.fromEntries(
20
20
  Object.entries(t.originalHeaders || {}).filter(
21
- ([e]) => pt.RELEVANT_HEADER_KEYS.includes(e)
21
+ ([e]) => lt.RELEVANT_HEADER_KEYS.includes(e)
22
22
  )
23
23
  ), t.authHeader !== void 0 && (this.baseHeaders.Authorization = t.authHeader);
24
24
  }
@@ -86,7 +86,7 @@ class X extends Error {
86
86
  super(`QLever is locked (rebuild in progress): ${t}`), this.name = "QLeverLockedError";
87
87
  }
88
88
  }
89
- class A {
89
+ class R {
90
90
  queryEndpoint;
91
91
  updateEndpoint;
92
92
  dataEndpoint;
@@ -113,7 +113,7 @@ class A {
113
113
  * 423 means qlever accessor has an ongoing rebuild; we should wait and retry.
114
114
  */
115
115
  static async _retryOnLocked(t) {
116
- const e = A.LOCKED_MAX_RETRIES, o = A.LOCKED_BASE_DELAY_MS;
116
+ const e = R.LOCKED_MAX_RETRIES, o = R.LOCKED_BASE_DELAY_MS;
117
117
  let r;
118
118
  for (let s = 0; s <= e; s++)
119
119
  try {
@@ -131,7 +131,7 @@ class A {
131
131
  constructor(t) {
132
132
  this.queryEndpoint = t.queryEndpoint, this.updateEndpoint = t.updateEndpoint, this.dataEndpoint = this.updateEndpoint.replace(/\/update$/, "/data"), this.baseHeaders = Object.fromEntries(
133
133
  Object.entries(t.originalHeaders || {}).filter(
134
- ([e]) => A.RELEVANT_HEADER_KEYS.includes(e)
134
+ ([e]) => R.RELEVANT_HEADER_KEYS.includes(e)
135
135
  )
136
136
  ), this.baseHeaders["x-user-roles"] = "admin";
137
137
  }
@@ -173,7 +173,7 @@ class A {
173
173
  })).text();
174
174
  }
175
175
  async update(t) {
176
- return A._retryOnLocked(async () => {
176
+ return R._retryOnLocked(async () => {
177
177
  const e = await fetch(this.updateEndpoint, {
178
178
  headers: {
179
179
  ...this.baseHeaders,
@@ -204,8 +204,8 @@ class A {
204
204
  await this._postToDataEndpoint(t, `${this.dataEndpoint}/delete`);
205
205
  }
206
206
  async _postToDataEndpoint(t, e) {
207
- const o = await this._quadsToNQuads(t), r = await Ve(Buffer.from(o, "utf-8"));
208
- await A._retryOnLocked(async () => {
207
+ const o = await this._quadsToNQuads(t), r = await Ye(Buffer.from(o, "utf-8"));
208
+ await R._retryOnLocked(async () => {
209
209
  const s = await fetch(e, {
210
210
  method: "POST",
211
211
  headers: {
@@ -223,12 +223,12 @@ class A {
223
223
  }
224
224
  _quadsToNQuads(t) {
225
225
  return new Promise((e, o) => {
226
- const r = new ye({ format: "application/n-quads" });
226
+ const r = new ke({ format: "application/n-quads" });
227
227
  r.addQuads(t), r.end((s, a) => s ? o(s) : e(a));
228
228
  });
229
229
  }
230
230
  }
231
- async function Ve(i) {
231
+ async function Ye(i) {
232
232
  const t = new CompressionStream("gzip"), e = t.writable.getWriter();
233
233
  e.write(new Uint8Array(i)), e.close();
234
234
  const o = [], r = t.readable.getReader();
@@ -243,14 +243,14 @@ async function Ve(i) {
243
243
  a.set(p, n), n += p.byteLength;
244
244
  return a.buffer;
245
245
  }
246
- class Ke {
246
+ class Ze {
247
247
  constructor(t) {
248
248
  switch (this.options = t, this.options.graphType) {
249
249
  case "qlever":
250
- this._db = new A(this.options);
250
+ this._db = new R(this.options);
251
251
  break;
252
252
  case "fuseki":
253
- this._db = new pt(this.options);
253
+ this._db = new lt(this.options);
254
254
  break;
255
255
  default:
256
256
  throw new Error(`Unsupported graph type: ${this.options.graphType}`);
@@ -298,7 +298,7 @@ class Ke {
298
298
  return this.options.graphType === "qlever" ? this._db.deleteData(t) : Promise.reject(new Error("deleteData not supported for Fuseki — use update() with SPARQL DELETE DATA"));
299
299
  }
300
300
  }
301
- class Qe {
301
+ class vt {
302
302
  constructor(t) {
303
303
  this.options = t;
304
304
  }
@@ -327,7 +327,7 @@ class Qe {
327
327
  async getDownloadURL(t, e) {
328
328
  const o = _(this._bucket(t), e);
329
329
  try {
330
- return await F(o);
330
+ return await V(o);
331
331
  } catch (r) {
332
332
  if (r?.code === "storage/object-not-found") return;
333
333
  throw r;
@@ -343,7 +343,7 @@ class Qe {
343
343
  const r = _(this._bucket(t), e);
344
344
  try {
345
345
  const s = await M(r);
346
- return `${await F(r)}&t=${encodeURIComponent(s.updated)}`;
346
+ return `${await V(r)}&t=${encodeURIComponent(s.updated)}`;
347
347
  } catch (s) {
348
348
  if (s?.code === "storage/object-not-found" || s?.status === 404) {
349
349
  this._knownMissing.add(o), console.debug(`[CueBlobStorage] ${e} not found (404 OK — optional cache file)`);
@@ -356,7 +356,7 @@ class Qe {
356
356
  async getFile(t, e) {
357
357
  const o = _(this._bucket(t), e);
358
358
  try {
359
- return await Xt(o);
359
+ return await ee(o);
360
360
  } catch (r) {
361
361
  if (r?.code === "storage/object-not-found") return;
362
362
  throw r;
@@ -382,7 +382,7 @@ class Qe {
382
382
  ]);
383
383
  try {
384
384
  const [a, n] = await Promise.all([
385
- s(F(e)),
385
+ s(V(e)),
386
386
  s(M(e))
387
387
  ]), p = `${a}&t=${encodeURIComponent(n.updated)}`, c = await fetch(p, { signal: o.signal });
388
388
  if (!c.ok) throw new Error(`HTTP ${c.status}`);
@@ -414,7 +414,7 @@ class Qe {
414
414
  /** Update custom metadata on an existing file. */
415
415
  async setMetadata(t, e, o) {
416
416
  const r = _(this._bucket(t), e);
417
- await me(r, { customMetadata: o });
417
+ await be(r, { customMetadata: o });
418
418
  }
419
419
  // ─── Uploads ──────────────────────────────────────────────────────────────
420
420
  /**
@@ -423,7 +423,7 @@ class Qe {
423
423
  * upload progress needs to be surfaced in the UI.
424
424
  */
425
425
  uploadResumable(t, e, o, r) {
426
- const s = _(this._bucket(t), e), a = mt(s, o, r ? { customMetadata: r } : void 0);
426
+ const s = _(this._bucket(t), e), a = wt(s, o, r ? { customMetadata: r } : void 0);
427
427
  return {
428
428
  complete: () => new Promise((n, p) => a.then(() => n(), p)),
429
429
  pause: () => a.pause(),
@@ -446,9 +446,9 @@ class Qe {
446
446
  await rt(s, o, r ? { customMetadata: r } : void 0);
447
447
  }
448
448
  /** Upload a string or base64-encoded value. */
449
- async uploadString(t, e, o, r = we.RAW, s) {
449
+ async uploadString(t, e, o, r = ve.RAW, s) {
450
450
  const a = _(this._bucket(t), e);
451
- await fe(a, o, r, s ? { customMetadata: s } : void 0);
451
+ await _e(a, o, r, s ? { customMetadata: s } : void 0);
452
452
  }
453
453
  // ─── Listing ──────────────────────────────────────────────────────────────
454
454
  /** List all item names directly under `prefix` in the given bucket. */
@@ -499,7 +499,7 @@ class Qe {
499
499
  d(new DOMException("Upload cancelled", "AbortError"));
500
500
  return;
501
501
  }
502
- const g = mt(n, e, { customMetadata: o }), w = () => {
502
+ const g = wt(n, e, { customMetadata: o }), w = () => {
503
503
  g.cancel(), d(new DOMException("Upload cancelled", "AbortError"));
504
504
  };
505
505
  s?.addEventListener("abort", w, { once: !0 }), g.on(
@@ -540,7 +540,7 @@ class Qe {
540
540
  return (await z(e)).items.map((r) => r.name);
541
541
  }
542
542
  }
543
- const bt = {
543
+ const _t = {
544
544
  ä: "ae",
545
545
  ä: "ae",
546
546
  Ä: "AE",
@@ -576,15 +576,15 @@ const bt = {
576
576
  };
577
577
  function D(i, t = !1) {
578
578
  const e = "daca0510-72b5-48ba-9091-b918ca18136b";
579
- return i = Xe(i, t), We(i, e);
579
+ return i = Je(i, t), Xe(i, e);
580
580
  }
581
- function Xe(i, t = !1) {
581
+ function Je(i, t = !1) {
582
582
  let e = i;
583
- for (const o in bt)
584
- e = e.replace(new RegExp(o, "g"), bt[o]);
583
+ for (const o in _t)
584
+ e = e.replace(new RegExp(o, "g"), _t[o]);
585
585
  return t && e !== i && console.info(`${i} -> ${e}`), e;
586
586
  }
587
- function Ye(i, t = "") {
587
+ function to(i, t = "") {
588
588
  return D(`${t}${i}`);
589
589
  }
590
590
  class x {
@@ -608,7 +608,7 @@ class x {
608
608
  return this;
609
609
  }
610
610
  }
611
- function lt(i, t) {
611
+ function ct(i, t) {
612
612
  const e = /* @__PURE__ */ new Set();
613
613
  let o = t(), r = !1;
614
614
  const s = [], a = () => {
@@ -630,7 +630,7 @@ function lt(i, t) {
630
630
  }
631
631
  };
632
632
  }
633
- async function ct(i, t, e, o) {
633
+ async function ht(i, t, e, o) {
634
634
  const r = D(i);
635
635
  let s;
636
636
  if (o) {
@@ -646,8 +646,8 @@ const Y = {
646
646
  apiKey: "AIzaSyAiW42QBx9HS4Khu88pCW7MV66IhBAQul0",
647
647
  appId: "1:151132927589:web:d2ffdb377dfadfd23ab88c",
648
648
  measurementId: "G-YT4PK6HGZD"
649
- }, vt = "qaecy-mvp-406413", Ze = "734737865998", Jt = "europe-west6", _t = "projects", Je = "spaces_chats_eu_west6", kt = "spaces_raw_eu_west6", Et = "spaces_processed_eu_west6", to = "spaces_logs_eu_west6", eo = "cue_public_eu_west6", xt = "db_persistence_eu_west6", oo = "/data-views/admin/consumption", ro = "/data-views/admin/profile/organizations", Ct = "/data-views/admin/profile/api-keys", It = "/commands/admin/profile/api-keys", so = "/commands/admin/profile/terms", ao = (i) => `/data-views/admin/organizations/${i}/members`, io = "/commands/admin/project", no = "/assistant/search", te = "/triplestore/query", po = "/triplestore/update", lo = "/triplestore/shacl", ee = "/qlever-server/qlever/query", co = "/qlever-server/qlever/update", ho = "/qlever-server/qlever/shacl", Tt = "/commands/file-system-structure/batch", St = "microsoft.com", At = "superadmin", ht = "https://cue.qaecy.com/r/";
650
- class Rt {
649
+ }, kt = "qaecy-mvp-406413", eo = "734737865998", se = "europe-west6", Et = "projects", xt = "spaces_chats_eu_west6", It = "spaces_raw_eu_west6", Ct = "spaces_processed_eu_west6", Tt = "spaces_logs_eu_west6", St = "cue_public_eu_west6", Rt = "db_persistence_eu_west6", oo = "/data-views/admin/consumption", ro = "/data-views/admin/profile/organizations", At = "/data-views/admin/profile/api-keys", Pt = "/commands/admin/profile/api-keys", so = "/commands/admin/profile/terms", ao = (i) => `/data-views/admin/organizations/${i}/members`, io = "/commands/admin/project", no = "/assistant/search", ae = "/triplestore/query", po = "/triplestore/update", lo = "/triplestore/shacl", ie = "/qlever-server/qlever/query", co = "/qlever-server/qlever/update", ho = "/qlever-server/qlever/shacl", Ot = "/commands/file-system-structure/batch", Dt = "microsoft.com", Lt = "superadmin", dt = "https://cue.qaecy.com/r/";
650
+ class qt {
651
651
  _auth;
652
652
  _endpoints;
653
653
  _userSignal = new x(null);
@@ -664,19 +664,19 @@ class Rt {
664
664
  /** All unique UIDs for the current user (Firebase UID + linked provider UIDs). */
665
665
  userIds;
666
666
  constructor(t, e = !1, o) {
667
- this._auth = Ae(t), this._endpoints = o, e && Re(this._auth, o.authEmulatorUrl, {
667
+ this._auth = De(t), this._endpoints = o, e && Le(this._auth, o.authEmulatorUrl, {
668
668
  disableWarnings: !0
669
- }), this.user = this._userSignal.asReadonly(), this.token = this._tokenSignal.asReadonly(), this.isSuperAdmin = this._isSuperAdminSignal.asReadonly(), this._userIdsSignal = lt([this._userSignal], () => {
669
+ }), this.user = this._userSignal.asReadonly(), this.token = this._tokenSignal.asReadonly(), this.isSuperAdmin = this._isSuperAdminSignal.asReadonly(), this._userIdsSignal = ct([this._userSignal], () => {
670
670
  const r = this._userSignal.get();
671
671
  if (!r) return [];
672
672
  const s = /* @__PURE__ */ new Set([r.uid]);
673
673
  return r.providerData.forEach((a) => s.add(a.uid)), Array.from(s);
674
- }), this.userIds = this._userIdsSignal, this._stopTokenListener = Pe(this._auth, async (r) => {
674
+ }), this.userIds = this._userIdsSignal, this._stopTokenListener = qe(this._auth, async (r) => {
675
675
  if (this._userSignal.set(r), r) {
676
676
  const s = await r.getIdToken();
677
677
  this._tokenSignal.set(s);
678
678
  const a = await st(r);
679
- this._isSuperAdminSignal.set(a.claims.role === At);
679
+ this._isSuperAdminSignal.set(a.claims.role === Lt);
680
680
  } else
681
681
  this._tokenSignal.set(null), this._isSuperAdminSignal.set(!1);
682
682
  });
@@ -689,14 +689,14 @@ class Rt {
689
689
  if (t === "password") {
690
690
  if (!e)
691
691
  throw new Error("credentials are required for password sign-in");
692
- return (await Oe(
692
+ return (await je(
693
693
  this._auth,
694
694
  e.email,
695
695
  e.password
696
696
  )).user;
697
697
  }
698
- const o = t === "google" ? new at() : new it(St);
699
- return (await De(this._auth, o)).user;
698
+ const o = t === "google" ? new at() : new it(Dt);
699
+ return (await Ue(this._auth, o)).user;
700
700
  }
701
701
  /**
702
702
  * Initiate a redirect-based sign-in (mobile / iframe contexts where popups
@@ -704,8 +704,8 @@ class Rt {
704
704
  * retrieve the result.
705
705
  */
706
706
  async signInWithRedirect(t) {
707
- const e = t === "google" ? new at() : new it(St);
708
- await Le(this._auth, e);
707
+ const e = t === "google" ? new at() : new it(Dt);
708
+ await Me(this._auth, e);
709
709
  }
710
710
  /**
711
711
  * Retrieve the result of a redirect sign-in. Returns the signed-in `User`
@@ -713,7 +713,7 @@ class Rt {
713
713
  * Call this once on app startup before showing a sign-in UI.
714
714
  */
715
715
  async checkRedirectResult() {
716
- return (await qe(this._auth))?.user ?? null;
716
+ return (await ze(this._auth))?.user ?? null;
717
717
  }
718
718
  /**
719
719
  * One-shot async check — returns `true` if the current user has the
@@ -722,7 +722,7 @@ class Rt {
722
722
  */
723
723
  async checkSuperAdmin() {
724
724
  const t = this._auth.currentUser;
725
- return t ? (await st(t)).claims.role === At : !1;
725
+ return t ? (await st(t)).claims.role === Lt : !1;
726
726
  }
727
727
  /** Sign in with a Cue API key. `projectId` is optional — omit it when no project context is available (e.g. admin flows). */
728
728
  async signInWithApiKey(t, e) {
@@ -735,11 +735,11 @@ class Rt {
735
735
  if (!r.ok)
736
736
  throw new Error(`Failed to fetch custom token: ${r.statusText}`);
737
737
  const { token: s } = await r.json();
738
- return (await je(this._auth, s)).user;
738
+ return (await Ne(this._auth, s)).user;
739
739
  }
740
740
  /** Sign out the current user */
741
741
  async signOut() {
742
- await Ue(this._auth);
742
+ await $e(this._auth);
743
743
  }
744
744
  /**
745
745
  * Register a new user by name and email.
@@ -769,7 +769,7 @@ class Rt {
769
769
  }
770
770
  /** Subscribe to authentication state changes. Returns an unsubscribe function. */
771
771
  onAuthStateChanged(t) {
772
- return Me(this._auth, t);
772
+ return Fe(this._auth, t);
773
773
  }
774
774
  /** Get the Firebase ID token for the current user, or null if not authenticated */
775
775
  async getToken(t = !1) {
@@ -801,12 +801,11 @@ class Rt {
801
801
  return this._auth;
802
802
  }
803
803
  }
804
- class Pt {
805
- constructor(t, e) {
806
- this._storageRaw = t, this._storageProcessed = e;
804
+ class jt {
805
+ constructor(t) {
806
+ this._blob = t;
807
807
  }
808
- _storageRaw;
809
- _storageProcessed;
808
+ _blob;
810
809
  /**
811
810
  * Returns a Firebase authenticated download URL for a document stored in Cue.
812
811
  *
@@ -818,8 +817,24 @@ class Pt {
818
817
  * @param bucket - `'raw'` (default, original uploads) or `'processed'` (derived artefacts).
819
818
  */
820
819
  async getDownloadUrl(t, e, o, r = "raw") {
821
- const s = r === "processed" ? this._storageProcessed : this._storageRaw, a = _(s, `${t}/${e}${o}`);
822
- return F(a);
820
+ const s = `${t}/${e}${o}`, a = await this._blob.getDownloadURL(r, s);
821
+ if (!a) throw new Error(`File not found in storage: ${s} (bucket: ${r})`);
822
+ return a;
823
+ }
824
+ /**
825
+ * Returns a Firebase authenticated download URL for an alternative representation
826
+ * using its full `qcy:remoteRelativePath` stored in the processed bucket.
827
+ *
828
+ * Use this instead of `getDownloadUrl` when the document info was obtained via
829
+ * `fetchAlternativeRepresentations` and carries a `remoteRelativePath`.
830
+ *
831
+ * @param remoteRelativePath - The full path in the processed bucket,
832
+ * e.g. `{projectId}/fragments/{uuid}.fragments`.
833
+ */
834
+ async getAltRepDownloadUrl(t) {
835
+ const e = await this._blob.getDownloadURL("processed", t);
836
+ if (!e) throw new Error(`Alternative representation not found in storage: ${t}`);
837
+ return e;
823
838
  }
824
839
  }
825
840
  const go = "/data-views/tables", uo = "/commands/tables";
@@ -861,7 +876,7 @@ class mo {
861
876
  throw new Error(`Failed to save tables: ${o.status} ${o.statusText}`);
862
877
  }
863
878
  }
864
- class Ot {
879
+ class Ut {
865
880
  constructor(t, e, o, r) {
866
881
  this._auth = t, this._gatewayUrl = e, this.projects = o, this.sync = r, this.tables = new mo(t, e);
867
882
  }
@@ -918,7 +933,7 @@ class Ot {
918
933
  */
919
934
  async sparql(t, e, o) {
920
935
  o || (o = (await this.projects.getProject(e))?.projectSettings?.graph?.type ?? "qlever");
921
- const r = o === "fuseki" ? te : ee;
936
+ const r = o === "fuseki" ? ae : ie;
922
937
  console.log(`Executing SPARQL query against ${r} for project ${e} with graph type ${o}`);
923
938
  const s = new URLSearchParams();
924
939
  s.append("query", t);
@@ -1018,7 +1033,7 @@ const nt = [
1018
1033
  "railway",
1019
1034
  "natural",
1020
1035
  "manmade"
1021
- ], oe = [
1036
+ ], ne = [
1022
1037
  "address",
1023
1038
  "poi",
1024
1039
  "railway",
@@ -1132,13 +1147,13 @@ const yo = "https://nominatim.openstreetmap.org", bo = "cue-gis/0.0.1", vo = {
1132
1147
  paved: "road",
1133
1148
  zone: "boundary"
1134
1149
  }, L = "nominatim";
1135
- function G(i) {
1150
+ function B(i) {
1136
1151
  return `${L}:${i}`;
1137
1152
  }
1138
1153
  function _o(i) {
1139
1154
  const t = S(i);
1140
1155
  return {
1141
- id: G(i),
1156
+ id: B(i),
1142
1157
  sourceId: L,
1143
1158
  sourceLayerId: i,
1144
1159
  category: i,
@@ -1160,7 +1175,7 @@ class ko {
1160
1175
  }
1161
1176
  async listFeatureCategoryDescriptors(t) {
1162
1177
  return (await Promise.allSettled(
1163
- oe.map(async (o) => {
1178
+ ne.map(async (o) => {
1164
1179
  const r = await this.search(t, o);
1165
1180
  return { category: o, hasResults: r.length > 0 };
1166
1181
  })
@@ -1172,14 +1187,14 @@ class ko {
1172
1187
  return (await this.listFeatureCategoryDescriptors(t)).map((o) => _o(o.category));
1173
1188
  }
1174
1189
  async getFeaturesForLayer(t, e) {
1175
- const o = nt.find((r) => G(r) === e);
1190
+ const o = nt.find((r) => B(r) === e);
1176
1191
  return o ? this.search(t, o) : [];
1177
1192
  }
1178
1193
  async listFeatureCategories(t) {
1179
1194
  return (await this.listFeatureCategoryDescriptors(t)).map((o) => o.category);
1180
1195
  }
1181
1196
  async getFeaturesOfCategory(t, e) {
1182
- return this.getFeaturesForLayer(t, G(e));
1197
+ return this.getFeaturesForLayer(t, B(e));
1183
1198
  }
1184
1199
  /**
1185
1200
  * Low-level search against the Nominatim API. Uses a per-layer probe query
@@ -1215,7 +1230,7 @@ class ko {
1215
1230
  id: `${t.osm_type}/${t.osm_id}`,
1216
1231
  sourceId: L,
1217
1232
  sourceFeatureId: `${t.osm_type}/${t.osm_id}`,
1218
- layerId: G(n),
1233
+ layerId: B(n),
1219
1234
  name: t.name ?? t.display_name.split(",")[0].trim(),
1220
1235
  category: n,
1221
1236
  preferredColor: p.preferredColor,
@@ -1229,7 +1244,7 @@ class ko {
1229
1244
  };
1230
1245
  }
1231
1246
  }
1232
- const Dt = {
1247
+ const Mt = {
1233
1248
  // 100s – Residential
1234
1249
  110: "residential",
1235
1250
  120: "residential",
@@ -1308,7 +1323,7 @@ const Dt = {
1308
1323
  960: "agricultural",
1309
1324
  970: "agricultural",
1310
1325
  990: "other"
1311
- }, Lt = {
1326
+ }, zt = {
1312
1327
  1010: "residential",
1313
1328
  1020: "mixed",
1314
1329
  1030: "residential",
@@ -1417,16 +1432,16 @@ function O(i) {
1417
1432
  for (const [t, e] of xo)
1418
1433
  if (t.test(i)) return e;
1419
1434
  }
1420
- function Co(i, t) {
1435
+ function Io(i, t) {
1421
1436
  if (i == null) return;
1422
1437
  const e = String(i).trim();
1423
- return t === "swiss-gwr" ? Eo[e] ?? O(e) : t === "danish-matrikel" ? Dt[e] ?? O(e) : t === "zurich-wfs" || t === "swiss-av-wfs" ? Lt[e] ?? O(e) : Lt[e] ?? Dt[e] ?? O(e);
1438
+ return t === "swiss-gwr" ? Eo[e] ?? O(e) : t === "danish-matrikel" ? Mt[e] ?? O(e) : t === "zurich-wfs" || t === "swiss-av-wfs" ? zt[e] ?? O(e) : zt[e] ?? Mt[e] ?? O(e);
1424
1439
  }
1425
- function Io(i, t) {
1440
+ function Co(i, t) {
1426
1441
  if (i != null)
1427
1442
  return O(String(i).trim());
1428
1443
  }
1429
- function re(i) {
1444
+ function pe(i) {
1430
1445
  return i.trim().toLowerCase().replace(/[\s_\-]/g, "");
1431
1446
  }
1432
1447
  const To = {
@@ -1448,11 +1463,11 @@ const To = {
1448
1463
  forslag: "proposed",
1449
1464
  aflyst: "repealed"
1450
1465
  };
1451
- function se(i) {
1466
+ function le(i) {
1452
1467
  if (i)
1453
- return To[re(i)];
1468
+ return To[pe(i)];
1454
1469
  }
1455
- const qt = {
1470
+ const Nt = {
1456
1471
  // Swiss Nutzungsplanung (typ_gde_bezeichnung and common variants)
1457
1472
  grundnutzungszonenplan: "land-use-plan",
1458
1473
  nutzungszonenplan: "land-use-plan",
@@ -1546,17 +1561,17 @@ const qt = {
1546
1561
  // Catch-all: any remaining Xzone / Xareal designation from the Grundnutzungszonenplan
1547
1562
  [/zone$|areal$/i, "land-use-plan"]
1548
1563
  ];
1549
- function ae(i) {
1564
+ function ce(i) {
1550
1565
  if (!i) return;
1551
- const t = re(i);
1552
- if (t in qt) return qt[t];
1566
+ const t = pe(i);
1567
+ if (t in Nt) return Nt[t];
1553
1568
  for (const [e, o] of So)
1554
1569
  if (e.test(i)) return o;
1555
1570
  console.warn(
1556
1571
  `[cue-gis] Unknown zone plan type — add "${i}" to classifyZonePlanType: no ZonePlanType mapping found.`
1557
1572
  );
1558
1573
  }
1559
- const Ao = "https://maps.zh.ch/wfs/OGDZHWFS", Ro = "zurich-wfs", Po = [8.35, 47.15, 8.95, 47.7], Oo = [5.9, 45.7, 10.55, 47.85];
1574
+ const Ro = "https://maps.zh.ch/wfs/OGDZHWFS", Ao = "zurich-wfs", Po = [8.35, 47.15, 8.95, 47.7], Oo = [5.9, 45.7, 10.55, 47.85];
1560
1575
  function Z(i) {
1561
1576
  return typeof i == "string" ? i : i.typeName;
1562
1577
  }
@@ -1613,7 +1628,7 @@ function Uo(i, t) {
1613
1628
  featureType: "building",
1614
1629
  areaM2: typeof e == "number" ? e : void 0,
1615
1630
  buildingUse: r ? String(r) : void 0,
1616
- buildingUseGeneric: Co(r, t),
1631
+ buildingUseGeneric: Io(r, t),
1617
1632
  floors: typeof o == "number" ? o : void 0,
1618
1633
  yearBuilt: typeof s == "number" ? s : void 0,
1619
1634
  registryId: a
@@ -1626,7 +1641,7 @@ function Mo(i, t) {
1626
1641
  featureType: "plot",
1627
1642
  areaM2: typeof a == "number" ? a : void 0,
1628
1643
  plotUse: n ? String(n) : void 0,
1629
- plotUseGeneric: Io(n),
1644
+ plotUseGeneric: Co(n),
1630
1645
  plotId: s,
1631
1646
  registryId: e
1632
1647
  };
@@ -1651,7 +1666,7 @@ function No(i) {
1651
1666
  }
1652
1667
  function $o(i) {
1653
1668
  if (!i) return { featureType: "zone" };
1654
- const t = i.plannavn ?? i.bezeichnung ?? i.typ_bezeichnung ?? i.art ?? void 0, e = i.planid ?? i.plannummer ?? void 0, o = i.artcode ?? i.typ_code ?? i.abkuerzung ?? e ?? void 0, r = i.rechtsstatus ?? i.status ?? void 0, s = se(r), a = i.typ_gde_bezeichnung ?? void 0, n = ae(a), p = i.dagsordenpunkt_url ?? i.dokument_url ?? i.link ?? void 0, c = i.auflagedatum ?? void 0, h = i.festsetzungsdatum ?? void 0, d = i.genehmigungsdatum ?? void 0, g = i.inkraftsetzungsdatum ?? void 0, w = i.flaeche ?? i.flaeche_m2 ?? void 0;
1669
+ const t = i.plannavn ?? i.bezeichnung ?? i.typ_bezeichnung ?? i.art ?? void 0, e = i.planid ?? i.plannummer ?? void 0, o = i.artcode ?? i.typ_code ?? i.abkuerzung ?? e ?? void 0, r = i.rechtsstatus ?? i.status ?? void 0, s = le(r), a = i.typ_gde_bezeichnung ?? void 0, n = ce(a), p = i.dagsordenpunkt_url ?? i.dokument_url ?? i.link ?? void 0, c = i.auflagedatum ?? void 0, h = i.festsetzungsdatum ?? void 0, d = i.genehmigungsdatum ?? void 0, g = i.inkraftsetzungsdatum ?? void 0, w = i.flaeche ?? i.flaeche_m2 ?? void 0;
1655
1670
  return {
1656
1671
  featureType: "zone",
1657
1672
  zoneType: t ? String(t) : void 0,
@@ -1688,7 +1703,7 @@ class et {
1688
1703
  sourceId;
1689
1704
  outputFormat;
1690
1705
  constructor(t) {
1691
- this.categoryMap = t.categoryMap, this.baseUrl = t.baseUrl ?? Ao, this.sourceId = t.sourceId ?? Ro, this.outputFormat = t.outputFormat ?? "application/json; subtype=geojson";
1706
+ this.categoryMap = t.categoryMap, this.baseUrl = t.baseUrl ?? Ro, this.sourceId = t.sourceId ?? Ao, this.outputFormat = t.outputFormat ?? "application/json; subtype=geojson";
1692
1707
  }
1693
1708
  async listFeatureCategoryDescriptors(t) {
1694
1709
  const e = await this.listAvailableLayers(t);
@@ -1785,7 +1800,7 @@ class et {
1785
1800
  return e.category === "building" ? Uo(t.properties, this.sourceId) : e.category === "greenspace" ? zo(t.properties) : e.category === "paved" ? No(t.properties) : e.category === "zone" ? $o(t.properties) : Mo(t.properties, this.sourceId);
1786
1801
  }
1787
1802
  }
1788
- const ie = [8, 54.5, 15.2, 57.8], ne = {
1803
+ const he = [8, 54.5, 15.2, 57.8], de = {
1789
1804
  building: [
1790
1805
  { source: "danish-matrikel", typename: "bbr_v001:bygning_current" }
1791
1806
  ],
@@ -1864,8 +1879,8 @@ function Vo(i, t) {
1864
1879
  featureType: "zone",
1865
1880
  zoneType: a ?? void 0,
1866
1881
  zoneCode: p ?? void 0,
1867
- legalStatus: se(c),
1868
- planType: ae(i?.typ_gde_bezeichnung),
1882
+ legalStatus: le(c),
1883
+ planType: ce(i?.typ_gde_bezeichnung),
1869
1884
  planId: n ?? void 0,
1870
1885
  planDocumentLink: h ?? void 0,
1871
1886
  publicationDate: i?.auflagedatum ?? void 0,
@@ -1889,7 +1904,7 @@ class Ko {
1889
1904
  getHeaders;
1890
1905
  sourceId;
1891
1906
  constructor(t) {
1892
- this.dataViewsBaseUrl = t.dataViewsBaseUrl.replace(/\/$/, ""), this.getHeaders = t.getHeaders, this.categoryMap = t.categoryMap ?? ne, this.sourceId = t.sourceId ?? "cue-sdk-gis";
1907
+ this.dataViewsBaseUrl = t.dataViewsBaseUrl.replace(/\/$/, ""), this.getHeaders = t.getHeaders, this.categoryMap = t.categoryMap ?? de, this.sourceId = t.sourceId ?? "cue-sdk-gis";
1893
1908
  }
1894
1909
  async listFeatureCategoryDescriptors(t) {
1895
1910
  const e = await this.listAvailableLayers(t);
@@ -2021,7 +2036,7 @@ const Qo = {
2021
2036
  // ÖREB Überlagernde Festlegungen (Flächen) – overlaying planning constraints
2022
2037
  "ms:ogd-0155_arv_basis_np_ul_flaeche_f"
2023
2038
  ]
2024
- }, pe = [
2039
+ }, ge = [
2025
2040
  {
2026
2041
  name: "Canton of Zürich",
2027
2042
  coverageBBox: Po,
@@ -2061,7 +2076,7 @@ const Qo = {
2061
2076
  * - `pdk:kommuneplanramme_vedtaget` – adopted municipal plan frameworks
2062
2077
  */
2063
2078
  name: "Denmark (Plandata.dk – planning zones)",
2064
- coverageBBox: ie,
2079
+ coverageBBox: he,
2065
2080
  supportedCategories: ["zone"],
2066
2081
  priority: 10,
2067
2082
  adapter: new et({
@@ -2079,7 +2094,7 @@ const Qo = {
2079
2094
  })
2080
2095
  }
2081
2096
  ];
2082
- function jt(i) {
2097
+ function $t(i) {
2083
2098
  return [...i].sort(
2084
2099
  (t, e) => nt.indexOf(t.category) - nt.indexOf(e.category)
2085
2100
  );
@@ -2100,7 +2115,7 @@ class Xo {
2100
2115
  ...s
2101
2116
  } = t;
2102
2117
  this.nominatim = new ko(s);
2103
- const a = o ? pe : [];
2118
+ const a = o ? ge : [];
2104
2119
  this.regions = e ?? a, this.zonePlanTypeColors = { ...fo, ...r };
2105
2120
  }
2106
2121
  /**
@@ -2120,12 +2135,12 @@ class Xo {
2120
2135
  for (const a of e)
2121
2136
  for (const n of a.supportedCategories ?? [])
2122
2137
  r.has(n) || (r.add(n), s.push(S(n)));
2123
- for (const a of oe)
2138
+ for (const a of ne)
2124
2139
  r.has(a) || s.push(S(a));
2125
- return jt(s);
2140
+ return $t(s);
2126
2141
  }
2127
2142
  const o = await this._adapterFor(t).listFeatureCategoryDescriptors(t);
2128
- return jt(o);
2143
+ return $t(o);
2129
2144
  }
2130
2145
  /**
2131
2146
  * Return the feature categories that have at least one result within the
@@ -2198,7 +2213,7 @@ class Xo {
2198
2213
  const { features: n, idx: p } = await Promise.race(a.values());
2199
2214
  a.delete(p);
2200
2215
  for (const c of n) {
2201
- const h = Ut(c), d = V(c), g = s.get(h);
2216
+ const h = Ft(c), d = W(c), g = s.get(h);
2202
2217
  (g === void 0 || d > g) && (s.set(h, d), yield c);
2203
2218
  }
2204
2219
  }
@@ -2234,7 +2249,7 @@ class Xo {
2234
2249
  d.status === "fulfilled" && (d.value.isNominatim ? n.push(...d.value.features) : a.push(...d.value.features));
2235
2250
  const p = Jo(a, n), c = /* @__PURE__ */ new Map(), h = [];
2236
2251
  for (const d of p) {
2237
- const g = Ut(d), w = V(d), u = c.get(g);
2252
+ const g = Ft(d), w = W(d), u = c.get(g);
2238
2253
  (u === void 0 || w > u) && (c.set(g, w), h.push(d));
2239
2254
  }
2240
2255
  return h;
@@ -2248,11 +2263,11 @@ class Xo {
2248
2263
  return this.regions.filter((o) => N(o.coverageBBox, t)).sort((o, r) => (r.priority ?? 0) - (o.priority ?? 0))[0]?.adapter ?? this.nominatim;
2249
2264
  }
2250
2265
  }
2251
- function V(i) {
2266
+ function W(i) {
2252
2267
  const t = i.geometry?.type;
2253
2268
  return t === "Polygon" || t === "MultiPolygon" ? 3 : t === "LineString" || t === "MultiLineString" ? 2 : 1;
2254
2269
  }
2255
- function Ut(i) {
2270
+ function Ft(i) {
2256
2271
  const t = Math.round(i.lat * 1e3) / 1e3, e = Math.round(i.lon * 1e3) / 1e3;
2257
2272
  return `${(i.name ?? i.id ?? "").toLowerCase().trim()}|${t}|${e}`;
2258
2273
  }
@@ -2263,7 +2278,7 @@ function Zo(i, t) {
2263
2278
  }
2264
2279
  function Jo(i, t) {
2265
2280
  if (t.length === 0) return i;
2266
- const e = i.filter((a) => V(a) === 3), o = i.filter((a) => V(a) !== 3), r = e.map((a) => ({ feature: { ...a, originalData: { ...a.originalData } }, matched: !1 })), s = [];
2281
+ const e = i.filter((a) => W(a) === 3), o = i.filter((a) => W(a) !== 3), r = e.map((a) => ({ feature: { ...a, originalData: { ...a.originalData } }, matched: !1 })), s = [];
2267
2282
  for (const a of t) {
2268
2283
  let n = -1, p = Yo;
2269
2284
  for (let c = 0; c < r.length; c++) {
@@ -2370,11 +2385,11 @@ class or {
2370
2385
  _getGateway() {
2371
2386
  if (this._gatewayCache !== null && this._gatewayProjectId === this._projectId)
2372
2387
  return this._gatewayCache;
2373
- const t = this._projectId, e = [...pe];
2388
+ const t = this._projectId, e = [...ge];
2374
2389
  return t && e.unshift({
2375
2390
  name: "Cue SDK (authenticated)",
2376
- coverageBBox: ie,
2377
- supportedCategories: Object.keys(ne),
2391
+ coverageBBox: he,
2392
+ supportedCategories: Object.keys(de),
2378
2393
  priority: 10,
2379
2394
  adapter: new Ko({
2380
2395
  dataViewsBaseUrl: `${this._gatewayUrl}${tr}`,
@@ -2427,11 +2442,11 @@ class or {
2427
2442
  this._loadListeners.forEach((e) => e(t));
2428
2443
  }
2429
2444
  }
2430
- class Mt {
2445
+ class Bt {
2431
2446
  constructor(t, e, o = !1, r) {
2432
- if (this._auth = t, this._db = be(e), this._functions = Yt(e, Jt), this._gatewayUrl = r?.gatewayUrl ?? "", o) {
2447
+ if (this._auth = t, this._db = Ee(e), this._functions = oe(e, se), this._gatewayUrl = r?.gatewayUrl ?? "", o) {
2433
2448
  const s = r?.firestoreEmulatorHost ?? "localhost", a = r?.firestoreEmulatorPort ?? 8080;
2434
- ve(this._db, s, a), Zt(this._functions, "localhost", 5001);
2449
+ xe(this._db, s, a), re(this._functions, "localhost", 5001);
2435
2450
  }
2436
2451
  }
2437
2452
  _auth;
@@ -2464,12 +2479,12 @@ class Mt {
2464
2479
  * Access is gated by Firestore rules which check membership.
2465
2480
  */
2466
2481
  async listProjects() {
2467
- const t = this._requireUser(), e = wt(this._db, _t);
2468
- return (await _e(ke(e, Ee("members", "array-contains", t), xe(100)))).docs.map((r) => r.data());
2482
+ const t = this._requireUser(), e = ft(this._db, Et);
2483
+ return (await Ie(Ce(e, Te("members", "array-contains", t), Se(100)))).docs.map((r) => r.data());
2469
2484
  }
2470
2485
  /** Fetch a single project by ID. Returns null if not found. */
2471
2486
  async getProject(t) {
2472
- const e = ft(wt(this._db, _t), t), o = await Ce(e);
2487
+ const e = yt(ft(this._db, Et), t), o = await Re(e);
2473
2488
  return o.exists() ? o.data() : null;
2474
2489
  }
2475
2490
  /**
@@ -2478,10 +2493,10 @@ class Mt {
2478
2493
  */
2479
2494
  async incrementUnitsConsumed(t, e, o) {
2480
2495
  if (e <= 0) return;
2481
- const r = ft(this._db, "clientSync", t);
2482
- await Ie(r, {
2483
- unitsConsumed: Se(e),
2484
- lastUpdated: Te(),
2496
+ const r = yt(this._db, "clientSync", t);
2497
+ await Ae(r, {
2498
+ unitsConsumed: Oe(e),
2499
+ lastUpdated: Pe(),
2485
2500
  lastUserId: o
2486
2501
  }, { merge: !0 });
2487
2502
  }
@@ -2489,20 +2504,20 @@ class Mt {
2489
2504
  * Invite a user to a project by email. Returns the invited user's uid and display name.
2490
2505
  */
2491
2506
  async inviteUserToProject(t, e, o) {
2492
- return (await B(this._functions, "inviteUserToProject")({ email: t, spaceId: e, role: o })).data;
2507
+ return (await F(this._functions, "inviteUserToProject")({ email: t, spaceId: e, role: o })).data;
2493
2508
  }
2494
2509
  /** Change an existing member's role on a project. */
2495
2510
  async changeUserRoleOnProject(t, e, o) {
2496
- await B(this._functions, "changeUserRoleOnProject")({ uid: t, spaceId: e, role: o });
2511
+ await F(this._functions, "changeUserRoleOnProject")({ uid: t, spaceId: e, role: o });
2497
2512
  }
2498
2513
  /** Remove a member from a project. */
2499
2514
  async removeUserFromProject(t, e) {
2500
- await B(this._functions, "removeUserFromProject")({ uid: t, spaceId: e });
2515
+ await F(this._functions, "removeUserFromProject")({ uid: t, spaceId: e });
2501
2516
  }
2502
2517
  }
2503
- class zt {
2518
+ class Gt {
2504
2519
  constructor(t, e, o, r) {
2505
- this._auth = t, this._gatewayUrl = r, this._functions = Yt(e, Jt), o && Zt(this._functions, "localhost", 5001);
2520
+ this._auth = t, this._gatewayUrl = r, this._functions = oe(e, se), o && re(this._functions, "localhost", 5001);
2506
2521
  }
2507
2522
  _auth;
2508
2523
  _gatewayUrl;
@@ -2519,13 +2534,13 @@ class zt {
2519
2534
  }
2520
2535
  /** Whether the current user has an active API key. */
2521
2536
  async hasAPIKey() {
2522
- return await this._fetch(Ct) !== null;
2537
+ return await this._fetch(At) !== null;
2523
2538
  }
2524
2539
  /** Returns the sign-in methods registered for the current user's email. */
2525
2540
  async getSignInMethods() {
2526
2541
  const t = this._auth.currentUser;
2527
2542
  if (!t?.email) throw new Error("User has no e-mail");
2528
- return ze(this._auth.firebaseAuth, t.email);
2543
+ return Be(this._auth.firebaseAuth, t.email);
2529
2544
  }
2530
2545
  /** Builds a human-readable label from a Firebase UserInfo provider entry. */
2531
2546
  buildProviderLabel(t) {
@@ -2538,42 +2553,42 @@ class zt {
2538
2553
  }
2539
2554
  /** Links a Google or Microsoft provider to the current account via popup. Returns the new provider label. */
2540
2555
  async linkProvider(t) {
2541
- const e = this._requireUser(), o = t === "google.com" ? new at() : new it(t), s = (await Ne(e, o)).user.providerData.find(
2556
+ const e = this._requireUser(), o = t === "google.com" ? new at() : new it(t), s = (await Ge(e, o)).user.providerData.find(
2542
2557
  (a) => a.providerId === t
2543
2558
  );
2544
2559
  return s ? this.buildProviderLabel(s) : "-";
2545
2560
  }
2546
2561
  /** Unlinks a provider from the current account. */
2547
2562
  async unlinkProvider(t) {
2548
- await $e(this._requireUser(), t);
2563
+ await He(this._requireUser(), t);
2549
2564
  }
2550
2565
  /** Changes the password. Reauthenticates first. */
2551
2566
  async updatePassword(t, e) {
2552
2567
  const o = this._requireUser();
2553
2568
  if (!o.email) throw new Error("User has no e-mail");
2554
- await yt(
2569
+ await bt(
2555
2570
  o,
2556
2571
  Q.credential(o.email, t)
2557
- ), await Fe(o, e);
2572
+ ), await We(o, e);
2558
2573
  }
2559
2574
  /** Adds (sets) a password for an account that currently only uses SSO. */
2560
2575
  async addPassword(t) {
2561
2576
  const e = this._requireUser();
2562
2577
  if (!e.email) throw new Error("User has no e-mail");
2563
- await Be(e, Q.credential(e.email, t));
2578
+ await Ve(e, Q.credential(e.email, t));
2564
2579
  }
2565
2580
  /** Requests an e-mail change. Sends a verification e-mail to the new address. */
2566
2581
  async updateEmail(t, e) {
2567
2582
  const o = this._requireUser();
2568
2583
  if (!o.email) throw new Error("User e-mail not available");
2569
- await yt(
2584
+ await bt(
2570
2585
  o,
2571
2586
  Q.credential(o.email, e)
2572
- ), await Ge(o, t), await He(o);
2587
+ ), await Ke(o, t), await Qe(o);
2573
2588
  }
2574
2589
  /** Creates a new API key for the current user. */
2575
2590
  async createAPIKey(t) {
2576
- return this._fetch(It, {
2591
+ return this._fetch(Pt, {
2577
2592
  method: "POST",
2578
2593
  headers: { "Content-Type": "application/json" },
2579
2594
  body: JSON.stringify({ expiration: t })
@@ -2582,7 +2597,7 @@ class zt {
2582
2597
  /** Revokes the current user's API key. */
2583
2598
  async revokeAPIKey() {
2584
2599
  const t = await this._auth.authenticatedFetch(
2585
- this._url(It),
2600
+ this._url(Pt),
2586
2601
  { method: "DELETE" }
2587
2602
  );
2588
2603
  if (!t.ok)
@@ -2590,7 +2605,7 @@ class zt {
2590
2605
  }
2591
2606
  /** Fetches the current user's existing API key. */
2592
2607
  async requestAPIKey() {
2593
- const t = await this._fetch(Ct);
2608
+ const t = await this._fetch(At);
2594
2609
  if (!t) throw new Error("No API key found");
2595
2610
  return t;
2596
2611
  }
@@ -2612,7 +2627,7 @@ class zt {
2612
2627
  * Uses the `getUserInfo` Firebase callable function.
2613
2628
  */
2614
2629
  async getUserInfo(t) {
2615
- return (await B(this._functions, "getUserInfo")({ uids: t })).data;
2630
+ return (await F(this._functions, "getUserInfo")({ uids: t })).data;
2616
2631
  }
2617
2632
  /** Record that the current user has accepted the terms of service. Sets a `terms` custom claim on the token. */
2618
2633
  async acceptTerms(t) {
@@ -2633,7 +2648,7 @@ class zt {
2633
2648
  return t ? (await st(t)).claims.terms ?? null : null;
2634
2649
  }
2635
2650
  }
2636
- const Nt = ["superadmin", "admin", "syncer", "member"], $t = {
2651
+ const Ht = ["superadmin", "admin", "syncer", "member"], Wt = {
2637
2652
  createEntities: "admin",
2638
2653
  createProvider: "superadmin",
2639
2654
  changeContentCategories: "syncer",
@@ -2665,9 +2680,9 @@ function rr() {
2665
2680
  viewEntities: !1
2666
2681
  };
2667
2682
  }
2668
- class Ft {
2683
+ class Vt {
2669
2684
  constructor(t) {
2670
- this._isSuperAdmin = t, this._projectRoles = new x([]), this.privileges = lt(
2685
+ this._isSuperAdmin = t, this._projectRoles = new x([]), this.privileges = ct(
2671
2686
  [this._projectRoles, t],
2672
2687
  () => this._compute()
2673
2688
  );
@@ -2694,17 +2709,17 @@ class Ft {
2694
2709
  _expand(t) {
2695
2710
  if (this._isSuperAdmin.get())
2696
2711
  return ["superadmin", "admin", "syncer", "member"];
2697
- const e = Nt.findIndex((o) => t.includes(o));
2698
- return e === -1 ? [] : Array.from(Nt.slice(e));
2712
+ const e = Ht.findIndex((o) => t.includes(o));
2713
+ return e === -1 ? [] : Array.from(Ht.slice(e));
2699
2714
  }
2700
2715
  _compute() {
2701
2716
  const t = this._projectRoles.get(), e = rr();
2702
- for (const o of Object.keys($t))
2703
- e[o] = t.includes($t[o]);
2717
+ for (const o of Object.keys(Wt))
2718
+ e[o] = t.includes(Wt[o]);
2704
2719
  return e;
2705
2720
  }
2706
2721
  }
2707
- class Bt {
2722
+ class Kt {
2708
2723
  constructor(t) {
2709
2724
  this._storage = t;
2710
2725
  }
@@ -2737,7 +2752,7 @@ class Bt {
2737
2752
  // ── Internal helpers ───────────────────────────────────────────────────────
2738
2753
  async _get(t, e) {
2739
2754
  try {
2740
- const r = await (await Xt(_(this._storage, `${t}/${e}.json.gz`))).arrayBuffer(), s = new DecompressionStream("gzip"), a = s.writable.getWriter(), n = s.readable.getReader();
2755
+ const r = await (await ee(_(this._storage, `${t}/${e}.json.gz`))).arrayBuffer(), s = new DecompressionStream("gzip"), a = s.writable.getWriter(), n = s.readable.getReader();
2741
2756
  a.write(new Uint8Array(r)), a.close();
2742
2757
  const p = [];
2743
2758
  let c = await n.read();
@@ -2794,7 +2809,7 @@ const b = {
2794
2809
  dicu: "https://w3id.org/digitalconstruction/0.5/Units#",
2795
2810
  diclvl: "https://w3id.org/digitalconstruction/0.5/Levels#",
2796
2811
  dicstg: "https://w3id.org/digitalconstruction/0.5/Stages#"
2797
- }, R = {
2812
+ }, A = {
2798
2813
  madsrdf: "http://www.loc.gov/mads/rdf/v1#",
2799
2814
  bflc: "http://id.loc.gov/ontologies/bflc/",
2800
2815
  foaf: "http://xmlns.com/foaf/0.1/",
@@ -6022,12 +6037,12 @@ const b = {
6022
6037
  fbsp: "http://purl.obolibrary.org/obo/FBSP_",
6023
6038
  rex: "http://purl.obolibrary.org/obo/REX_"
6024
6039
  };
6025
- class dt {
6040
+ class gt {
6026
6041
  static _instance;
6027
6042
  // Opposite map is built once
6028
6043
  _nsMap;
6029
6044
  static getInstance() {
6030
- return this._instance ? this._instance : (this._instance = new dt(), this._instance);
6045
+ return this._instance ? this._instance : (this._instance = new gt(), this._instance);
6031
6046
  }
6032
6047
  compactIRI(t) {
6033
6048
  let e = this._nsMap;
@@ -6043,12 +6058,12 @@ class dt {
6043
6058
  return r === void 0 ? t : t.replace(o, `${r}:`);
6044
6059
  }
6045
6060
  expandIRI(t) {
6046
- const e = t.split(":")[0], o = R[e] ?? b[e];
6061
+ const e = t.split(":")[0], o = A[e] ?? b[e];
6047
6062
  return t.replace(`${e}:`, o);
6048
6063
  }
6049
6064
  _buildNSMap() {
6050
6065
  const t = {};
6051
- return Object.keys(R).forEach((e) => t[R[e]] = e), Object.keys(b).forEach(
6066
+ return Object.keys(A).forEach((e) => t[A[e]] = e), Object.keys(b).forEach(
6052
6067
  (e) => t[b[e]] = e
6053
6068
  ), this._nsMap = t, t;
6054
6069
  }
@@ -6109,7 +6124,7 @@ class ar {
6109
6124
  return;
6110
6125
  }
6111
6126
  const o = this._buildCategoriesQuery(t, "ContentCategory"), r = this._buildCategoriesQuery(t, "EntityCategory"), s = this._buildRelationshipsQuery(t);
6112
- await ct(
6127
+ await ht(
6113
6128
  o + r + s,
6114
6129
  async () => {
6115
6130
  const [a, n, p] = await Promise.all([
@@ -6133,7 +6148,7 @@ class ar {
6133
6148
  }
6134
6149
  _buildCategoriesQuery(t, e) {
6135
6150
  return `PREFIX qcy: <${b.qcy}>
6136
- PREFIX skos: <${R.skos}>
6151
+ PREFIX skos: <${A.skos}>
6137
6152
  SELECT ?iri ?parent (SAMPLE(?l) AS ?label)
6138
6153
  WHERE {
6139
6154
  ?iri a qcy:${e} .
@@ -6159,7 +6174,7 @@ GROUP BY ?iri ?parent`;
6159
6174
  }
6160
6175
  _buildRelationshipsQuery(t) {
6161
6176
  return `PREFIX qcy: <${b.qcy}>
6162
- PREFIX rdfs: <${R.rdfs}>
6177
+ PREFIX rdfs: <${A.rdfs}>
6163
6178
  SELECT ?iri ?parent (SAMPLE(?l) AS ?label)
6164
6179
  WHERE {
6165
6180
  ?x qcy:relatedEntity ?y ;
@@ -6183,8 +6198,8 @@ GROUP BY ?iri ?parent`;
6183
6198
  }
6184
6199
  }
6185
6200
  const ir = "https://qlever.dev/api/osm-planet";
6186
- class le {
6187
- constructor(t, e, o = ht, r, s) {
6201
+ class ue {
6202
+ constructor(t, e, o = dt, r, s) {
6188
6203
  this._api = t, this._projectId = e, this._queryCache = r, this._graphType = s, this.baseURL = `${o}${e}/`, this.entityInfoMap = this._entityInfoMapComputed, this.entityGraph = this._entityGraph.asReadonly(), this._entityOSMMap.subscribe(() => this._checkPendingOSMFetches()), this._fetchEntityGraph().catch(
6189
6204
  (a) => console.error("[CueProjectEntities] Entity graph fetch failed:", a)
6190
6205
  );
@@ -6206,7 +6221,7 @@ class le {
6206
6221
  _fetchingOSMIds = /* @__PURE__ */ new Set();
6207
6222
  _entityGraph = new x(void 0);
6208
6223
  // ── Derived signals ────────────────────────────────────────────────────────
6209
- _entityInfoMapComputed = lt(
6224
+ _entityInfoMapComputed = ct(
6210
6225
  [
6211
6226
  this._entityDetails,
6212
6227
  this._entityDocuments,
@@ -6388,7 +6403,7 @@ WHERE {
6388
6403
  */
6389
6404
  async contentCategoriesInProject(t = !0) {
6390
6405
  const e = this._api.language, o = `PREFIX qcy: <${b.qcy}>
6391
- PREFIX skos: <${R.skos}>
6406
+ PREFIX skos: <${A.skos}>
6392
6407
  SELECT ?iri (SAMPLE(?l) AS ?label) ?count
6393
6408
  WHERE {
6394
6409
  ?iri a qcy:EntityCategory .
@@ -6447,7 +6462,7 @@ ORDER BY DESC(?weight)`, o = await this._api.sparql(
6447
6462
  };
6448
6463
  }
6449
6464
  if (t === "md") {
6450
- const s = dt.getInstance(), a = r.map((h) => ({
6465
+ const s = gt.getInstance(), a = r.map((h) => ({
6451
6466
  src: s.compactIRI(h.sourceCat.value),
6452
6467
  pred: s.compactIRI(h.predicate.value),
6453
6468
  tgt: s.compactIRI(h.targetCat.value),
@@ -6483,9 +6498,9 @@ ORDER BY DESC(?weight)`, o = await this._api.sparql(
6483
6498
  for (const { osm: f, viaRels: k, entityUUID: m } of h.indirect) {
6484
6499
  const E = s[f];
6485
6500
  if (E)
6486
- for (const C of k) {
6487
- const v = `${C}:${m}`, y = u.get(v) ?? { geometries: [], entityUUID: m };
6488
- y.geometries.some((I) => I.osmIRI === f) || (y.geometries.push({ osmIRI: f, wkt: E }), u.set(v, y));
6501
+ for (const I of k) {
6502
+ const v = `${I}:${m}`, y = u.get(v) ?? { geometries: [], entityUUID: m };
6503
+ y.geometries.some((C) => C.osmIRI === f) || (y.geometries.push({ osmIRI: f, wkt: E }), u.set(v, y));
6489
6504
  }
6490
6505
  }
6491
6506
  u.size > 0 && (g = Array.from(u.entries()).map(
@@ -6582,7 +6597,7 @@ WHERE {
6582
6597
  ?e2 qcy:hasEntityCategory ?e2Cat
6583
6598
  }
6584
6599
  GROUP BY ?e1Cat ?e2Cat`;
6585
- await ct(
6600
+ await ht(
6586
6601
  t,
6587
6602
  async () => {
6588
6603
  const e = await this._api.sparql(
@@ -6619,7 +6634,7 @@ GROUP BY ?e1Cat ?e2Cat`;
6619
6634
  async _fetchOSMLocations(t) {
6620
6635
  const e = t.filter((n) => !n.includes("/relation/"));
6621
6636
  if (e.length === 0) return;
6622
- const o = e.map((n) => `<${n}>`).join(" "), r = `PREFIX geo: <${R.geo}>
6637
+ const o = e.map((n) => `<${n}>`).join(" "), r = `PREFIX geo: <${A.geo}>
6623
6638
  SELECT * WHERE {
6624
6639
  VALUES ?s { ${o} }
6625
6640
  SERVICE <${ir}> {
@@ -6635,8 +6650,8 @@ SELECT * WHERE {
6635
6650
  }), this._osmWKTMap.set(a);
6636
6651
  }
6637
6652
  }
6638
- class ce {
6639
- constructor(t, e, o, r = ht, s, a) {
6653
+ class pt {
6654
+ constructor(t, e, o, r = dt, s, a) {
6640
6655
  this._api = t, this._projectId = e, this._queryCache = s, this._graphType = a, this.baseURL = `${r}${e}/`, this._currentLang = o ?? this._api.language, this.documentInfoMap = this._documentInfoMap.asReadonly(), this.projectDocumentsData = this._projectDocumentsData.asReadonly();
6641
6656
  }
6642
6657
  _api;
@@ -6690,7 +6705,7 @@ class ce {
6690
6705
  documentsByContentCategory: {}
6691
6706
  });
6692
6707
  const t = this._buildDocumentsBySuffixQuery(), e = this._buildDocumentsByContentCategoryQuery(), o = this._buildDuplicateCountQuery();
6693
- await ct(
6708
+ await ht(
6694
6709
  t + e + o,
6695
6710
  async () => {
6696
6711
  const [r, s, a] = await Promise.all([
@@ -6739,6 +6754,23 @@ class ce {
6739
6754
  t.filter((s) => r[s] !== void 0).map((s) => [s, r[s]])
6740
6755
  );
6741
6756
  }
6757
+ /**
6758
+ * Fetches a lightweight document metadata shape (id/path/suffix/size) for
6759
+ * the given UUIDs and merges the results into `documentInfoMap`.
6760
+ *
6761
+ * This is useful for list/table contexts that do not need language-tagged
6762
+ * fields (`subject`, `summary`) or category/tag enrichment.
6763
+ *
6764
+ * UUIDs already present in `documentInfoMap` are skipped.
6765
+ */
6766
+ async fetchDocumentDataSimple(t) {
6767
+ const e = this._documentInfoMap.get(), o = t.filter((s) => e[s] === void 0);
6768
+ o.length > 0 && await this._fetchSimpleDocumentInfoBatch(o);
6769
+ const r = this._documentInfoMap.get();
6770
+ return Object.fromEntries(
6771
+ t.filter((s) => r[s] !== void 0).map((s) => [s, r[s]])
6772
+ );
6773
+ }
6742
6774
  /**
6743
6775
  * Returns the alternative representations of the given document UUID.
6744
6776
  *
@@ -6758,14 +6790,28 @@ class ce {
6758
6790
  async fetchAlternativeRepresentations(t) {
6759
6791
  const e = `PREFIX qcy: <${b.qcy}>
6760
6792
  PREFIX r: <${this.baseURL}>
6761
- SELECT ?altId
6793
+ SELECT ?altId ?contentIRI ?suffix ?rrp
6762
6794
  WHERE {
6763
- r:${t} qcy:alternativeRepresentation ?alt .
6764
- BIND(REPLACE(STR(?alt), "^.*/([^/]*)$", "$1") AS ?altId)
6765
- }`, r = (await this._api.sparql(e, this._projectId, this._graphType)).results.bindings.map((a) => a.altId?.value).filter((a) => !!a);
6766
- if (r.length === 0) return [];
6767
- const s = await this.fetchDocumentData(r);
6768
- return r.map((a) => s[a]).filter((a) => a !== void 0);
6795
+ r:${t} qcy:alternativeRepresentation ?contentIRI .
6796
+ BIND(REPLACE(STR(?contentIRI), "^.*/([^/]*)$", "$1") AS ?altId)
6797
+ ?contentIRI qcy:hasFileLocation ?loc .
6798
+ ?loc qcy:suffix ?suffix .
6799
+ OPTIONAL { ?loc qcy:remoteRelativePath ?rrp }
6800
+ }`, o = await this._api.sparql(e, this._projectId, this._graphType), r = { ...this._documentInfoMap.get() }, s = [];
6801
+ return o.results.bindings.forEach((a) => {
6802
+ if (!a.altId || !a.contentIRI) return;
6803
+ const n = a.altId.value, p = {
6804
+ id: n,
6805
+ contentIRI: a.contentIRI.value,
6806
+ path: "",
6807
+ suffix: a.suffix?.value ?? "",
6808
+ size: 0,
6809
+ tags: [],
6810
+ categories: [],
6811
+ remoteRelativePath: a.rrp?.value
6812
+ };
6813
+ r[n] = p, s.push(p);
6814
+ }), this._documentInfoMap.set(r), s;
6769
6815
  }
6770
6816
  /**
6771
6817
  * Returns a single arbitrary file path from the project's triplestore.
@@ -6829,6 +6875,38 @@ GROUP BY ?id ?contentIRI ?suffix ?size ?subject ?summary`, s = await this._api.s
6829
6875
  a[c] = h, n[c] = h;
6830
6876
  }), this._documentInfoMap.set(a), n;
6831
6877
  }
6878
+ /** Executes a reduced document-info query (id/path/suffix/size only), merges
6879
+ * into `documentInfoMap`, and returns newly fetched entries. */
6880
+ async _fetchSimpleDocumentInfoBatch(t) {
6881
+ const e = t.map((n) => `r:${n}`).join(" "), o = `PREFIX qcy: <${b.qcy}>
6882
+ PREFIX r: <${this.baseURL}>
6883
+ SELECT ?id ?contentIRI ?suffix ?size (SAMPLE(?fp) AS ?path)
6884
+ WHERE {
6885
+ VALUES ?contentIRI { ${e} }
6886
+ ?contentIRI qcy:sizeBytes ?size ;
6887
+ qcy:hasFileLocation ?loc .
6888
+ ?loc qcy:filePath ?fp ;
6889
+ qcy:suffix ?suffix .
6890
+ BIND(REPLACE(STR(?contentIRI), "^.*/([^/]*)$", "$1") AS ?id)
6891
+ }
6892
+ GROUP BY ?id ?contentIRI ?suffix ?size`, r = await this._api.sparql(o, this._projectId, this._graphType), s = { ...this._documentInfoMap.get() }, a = {};
6893
+ return r.results.bindings.forEach((n) => {
6894
+ if (!n.id) return;
6895
+ const p = n.id.value, c = s[p], h = {
6896
+ id: p,
6897
+ contentIRI: n.contentIRI?.value ?? c?.contentIRI ?? p,
6898
+ path: n.path?.value ?? c?.path ?? p,
6899
+ suffix: n.suffix?.value ?? c?.suffix ?? "",
6900
+ size: n.size ? parseInt(n.size.value, 10) : c?.size ?? 0,
6901
+ tags: c?.tags ?? [],
6902
+ categories: c?.categories ?? [],
6903
+ subject: c?.subject,
6904
+ summary: c?.summary,
6905
+ providerId: c?.providerId
6906
+ };
6907
+ s[p] = h, a[p] = h;
6908
+ }), this._documentInfoMap.set(s), a;
6909
+ }
6832
6910
  async _fetchDocumentsBySuffix() {
6833
6911
  return this._runDocumentsBySuffixQuery(this._buildDocumentsBySuffixQuery());
6834
6912
  }
@@ -6910,8 +6988,8 @@ WHERE {
6910
6988
  }
6911
6989
  }
6912
6990
  class nr {
6913
- constructor(t, e, { language: o, queryCache: r, rdfBase: s = ht, graphType: a }) {
6914
- this._api = t, this._projectId = e, this.schema = new ar(t, e, o, r, a), this.entities = new le(t, e, s, r, a), this.documents = new ce(t, e, o, s, r, a), this.availableContentCategories = this.schema.availableContentCategories, this.availableEntityCategories = this.schema.availableEntityCategories, this.availableEntityRelationships = this.schema.availableEntityRelationships, this.schemaReady = this.schema.ready, this.entityInfoMap = this.entities.entityInfoMap, this.entityGraph = this.entities.entityGraph, this.documentInfoMap = this.documents.documentInfoMap, this.projectDocumentsData = this.documents.projectDocumentsData, this.searchResults = this._searchResults.asReadonly(), this.documents.fetchOverview().catch((n) => console.error("[CueProjectView] fetchOverview failed:", n));
6991
+ constructor(t, e, { language: o, queryCache: r, rdfBase: s = dt, graphType: a }) {
6992
+ this._api = t, this._projectId = e, this.schema = new ar(t, e, o, r, a), this.entities = new ue(t, e, s, r, a), this.documents = new pt(t, e, o, s, r, a), this.availableContentCategories = this.schema.availableContentCategories, this.availableEntityCategories = this.schema.availableEntityCategories, this.availableEntityRelationships = this.schema.availableEntityRelationships, this.schemaReady = this.schema.ready, this.entityInfoMap = this.entities.entityInfoMap, this.entityGraph = this.entities.entityGraph, this.documentInfoMap = this.documents.documentInfoMap, this.projectDocumentsData = this.documents.projectDocumentsData, this.searchResults = this._searchResults.asReadonly(), this.documents.fetchOverview().catch((n) => console.error("[CueProjectView] fetchOverview failed:", n));
6915
6993
  }
6916
6994
  _api;
6917
6995
  _projectId;
@@ -7029,7 +7107,7 @@ class nr {
7029
7107
  this._destroyed = !0, this._searchResults.set(void 0);
7030
7108
  }
7031
7109
  }
7032
- function Gt(i, t) {
7110
+ function Qt(i, t) {
7033
7111
  return new Promise((e) => {
7034
7112
  const o = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
7035
7113
  for (const m of i)
@@ -7926,7 +8004,7 @@ const pr = {
7926
8004
  }
7927
8005
  };
7928
8006
  l.AUDIO + "", l.VIDEO + "", l.IMAGE + "", l.TEXT + "", l.MARKUP + "", l.SCRIPT + "", l.DATA + "", l.ARCHIVE + "", l.INSTALLER + "", l.BINARY + "", l.BACKUP + "", l.AUTOMATION + "", l.PRESENTATION + "", l.SPREADSHEET + "", l.FONT + "", l.GEOSPATIAL + "", l.THREE_D + "", l.CAD + "", l.BIM + "", l.PLANNING + "", l.EMAIL + "", l.MULTIMEDIA + "", l.UNKNOWN + "";
7929
- const { namedNode: lr, literal: Ir } = j;
8007
+ const { namedNode: lr, literal: Cr } = j;
7930
8008
  lr("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
7931
8009
  const { namedNode: Tr } = j, { namedNode: cr, literal: Sr } = j;
7932
8010
  cr("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
@@ -7934,14 +8012,14 @@ function hr(i) {
7934
8012
  const t = i.split(".");
7935
8013
  return t.length > 1 ? "." + t.pop()?.toLowerCase() : "";
7936
8014
  }
7937
- const { namedNode: dr, literal: Ar } = j;
8015
+ const { namedNode: dr, literal: Rr } = j;
7938
8016
  dr("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
7939
- const { namedNode: gr, literal: Rr } = j;
8017
+ const { namedNode: gr, literal: Ar } = j;
7940
8018
  gr("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
7941
- function Ht(i, t, e, o, r, s, a, n = !1, p = !1) {
8019
+ function Xt(i, t, e, o, r, s, a, n = !1, p = !1) {
7942
8020
  const c = hr(i), h = D(o), d = `${t}/${h}${c}`;
7943
8021
  a === void 0 && (a = pr[c]?.mime ?? "application/octet-stream");
7944
- const g = Ye(i, r);
8022
+ const g = to(i, r);
7945
8023
  return {
7946
8024
  name: i,
7947
8025
  blob_name: d,
@@ -7967,7 +8045,7 @@ async function U() {
7967
8045
  "fs/promises"
7968
8046
  );
7969
8047
  }
7970
- async function Wt(i) {
8048
+ async function Yt(i) {
7971
8049
  if (typeof window < "u")
7972
8050
  throw new Error(
7973
8051
  `Cannot read file from path "${i}" in a browser environment. Provide file.data (Uint8Array) instead.`
@@ -7975,20 +8053,20 @@ async function Wt(i) {
7975
8053
  const { readFile: t } = await U();
7976
8054
  return t(i);
7977
8055
  }
7978
- let q = null, H = null, W = null;
8056
+ let q = null, G = null, H = null;
7979
8057
  function Pr(i) {
7980
- W = i, H = null, q = null;
8058
+ H = i, G = null, q = null;
7981
8059
  }
7982
8060
  async function ur() {
7983
8061
  if (typeof window < "u") {
7984
- if (!W)
8062
+ if (!H)
7985
8063
  throw new Error(
7986
8064
  "WASM scanner is not configured for browser use. Call configureScanWasm(baseUrl) during app initialisation."
7987
8065
  );
7988
- const i = await fetch(`${W}/dir_scanner_wasm_bg.wasm`);
8066
+ const i = await fetch(`${H}/dir_scanner_wasm_bg.wasm`);
7989
8067
  if (!i.ok)
7990
8068
  throw new Error(`Failed to fetch WASM binary: ${i.status} ${i.statusText}`);
7991
- const t = new Uint8Array(await i.arrayBuffer()), o = await import(`${W}/dir_scanner_wasm.mjs`);
8069
+ const t = new Uint8Array(await i.arrayBuffer()), o = await import(`${H}/dir_scanner_wasm.mjs`);
7992
8070
  await o.default({ module_or_path: t }), q = o.scan;
7993
8071
  } else {
7994
8072
  const { readFile: i } = await U(), { join: t } = await import(
@@ -8001,8 +8079,8 @@ async function ur() {
8001
8079
  await a.default({ module_or_path: r }), q = a.scan;
8002
8080
  }
8003
8081
  }
8004
- const mr = "qlever", $ = 1e3, gt = "cue:pending:";
8005
- async function ut(i) {
8082
+ const mr = "qlever", $ = 1e3, ut = "cue:pending:";
8083
+ async function mt(i) {
8006
8084
  const { tmpdir: t } = await import(
8007
8085
  /* webpackIgnore: true */
8008
8086
  "os"
@@ -8012,33 +8090,33 @@ async function ut(i) {
8012
8090
  );
8013
8091
  return e(t(), `cue-sync-pending-${i}.json`);
8014
8092
  }
8015
- async function Vt(i) {
8093
+ async function Zt(i) {
8016
8094
  if (typeof window < "u") {
8017
- const t = window.localStorage.getItem(`${gt}${i}`);
8095
+ const t = window.localStorage.getItem(`${ut}${i}`);
8018
8096
  return t ? JSON.parse(t) : null;
8019
8097
  }
8020
8098
  try {
8021
- const t = await (await U()).readFile(await ut(i), "utf-8");
8099
+ const t = await (await U()).readFile(await mt(i), "utf-8");
8022
8100
  return JSON.parse(t);
8023
8101
  } catch {
8024
8102
  return null;
8025
8103
  }
8026
8104
  }
8027
- async function Kt(i) {
8105
+ async function Jt(i) {
8028
8106
  const t = JSON.stringify(i);
8029
8107
  if (typeof window < "u") {
8030
- window.localStorage.setItem(`${gt}${i.spaceId}`, t);
8108
+ window.localStorage.setItem(`${ut}${i.spaceId}`, t);
8031
8109
  return;
8032
8110
  }
8033
- await (await U()).writeFile(await ut(i.spaceId), t, "utf-8");
8111
+ await (await U()).writeFile(await mt(i.spaceId), t, "utf-8");
8034
8112
  }
8035
8113
  async function wr(i) {
8036
8114
  if (typeof window < "u") {
8037
- window.localStorage.removeItem(`${gt}${i}`);
8115
+ window.localStorage.removeItem(`${ut}${i}`);
8038
8116
  return;
8039
8117
  }
8040
8118
  try {
8041
- await (await U()).unlink(await ut(i));
8119
+ await (await U()).unlink(await mt(i));
8042
8120
  } catch {
8043
8121
  }
8044
8122
  }
@@ -8098,7 +8176,7 @@ class fr {
8098
8176
  */
8099
8177
  async flushPendingMetadata(t, e, o) {
8100
8178
  this._legacy = o ?? !1;
8101
- const r = await Vt(t);
8179
+ const r = await Zt(t);
8102
8180
  if (!(!r || r.items.length === 0)) {
8103
8181
  console.info(`Trying to upload metadata (${r.items.length} item(s))...`), e && console.info(`Flushing ${r.items.length} pending file location(s) from previous sync ⏳`);
8104
8182
  try {
@@ -8121,20 +8199,20 @@ class fr {
8121
8199
  this._api?.getConsumption(o) ?? Promise.reject(new Error("CueSyncApi is not bound to a CueApi instance")),
8122
8200
  this._fetchUnitCreditMap(s),
8123
8201
  this._fetchTierNames()
8124
- ]), f = (await Gt(t, h)).localNotOnRemote ?? [], k = f.length > 0 ? await this.scanCost(f) : [];
8202
+ ]), f = (await Qt(t, h)).localNotOnRemote ?? [], k = f.length > 0 ? await this.scanCost(f) : [];
8125
8203
  let m = 0, E = 0;
8126
8204
  for (const v of k) {
8127
8205
  m += v.units;
8128
- const y = g[c], I = y?.[v.ext] ?? 1;
8206
+ const y = g[c], C = y?.[v.ext] ?? 1;
8129
8207
  s && y && !(v.ext in y) && console.info(` Unknown format: .${v.ext} (using default rate of 1 credit/unit)`);
8130
- const P = v.units * I;
8208
+ const P = v.units * C;
8131
8209
  E += P, v.credits = Math.round(P);
8132
8210
  }
8133
- const C = w[c] ?? c;
8211
+ const I = w[c] ?? c;
8134
8212
  return {
8135
8213
  costRecords: k,
8136
8214
  tier: c,
8137
- tierName: C,
8215
+ tierName: I,
8138
8216
  unitsToConsume: m,
8139
8217
  creditsToConsume: Math.round(E),
8140
8218
  creditsAvailable: d.creditsAvailable,
@@ -8153,35 +8231,35 @@ class fr {
8153
8231
  const [d, g] = await Promise.all([
8154
8232
  this._listRemoteFiles(h, o, r, a),
8155
8233
  this._api?.getConsumption(o) ?? Promise.reject(new Error("CueSyncApi is not bound to a CueApi instance"))
8156
- ]), { unitsAvailable: w } = g, u = await Gt(t, d);
8234
+ ]), { unitsAvailable: w } = g, u = await Qt(t, d);
8157
8235
  a && (console.info(`Total local files: ${t.length}`), console.info(`Total remote files: ${d.length}`), console.info(
8158
8236
  `Total files to sync: ${(u.localNotOnRemote?.length ?? 0) + u.localNotOnRemotePathOnly.length}`
8159
8237
  ));
8160
8238
  let f = u.syncCount, k = u.syncSize, m = 0, E = !1;
8161
- const C = u.localNotOnRemote ?? [];
8162
- if (C.length > 0) {
8163
- const I = (await this.scanCost(C)).reduce((P, de) => P + de.units, 0);
8164
- if (I > w)
8239
+ const I = u.localNotOnRemote ?? [];
8240
+ if (I.length > 0) {
8241
+ const C = (await this.scanCost(I)).reduce((P, we) => P + we.units, 0);
8242
+ if (C > w)
8165
8243
  throw new Error(
8166
- `Insufficient units: ${I} units required but only ${w} available.`
8244
+ `Insufficient units: ${C} units required but only ${w} available.`
8167
8245
  );
8168
8246
  }
8169
- await this._initPendingBatch(o, a), a && C.length && console.info("Syncing missing files ⏳");
8170
- for (const y of C)
8247
+ await this._initPendingBatch(o, a), a && I.length && console.info("Syncing missing files ⏳");
8248
+ for (const y of I)
8171
8249
  try {
8172
- const I = Ht(
8250
+ const C = Xt(
8173
8251
  y.relativePath,
8174
8252
  o,
8175
8253
  s,
8176
8254
  y.md5,
8177
8255
  r
8178
8256
  );
8179
- if (!I.blob_name) throw new Error(`blob_name missing for ${y.relativePath}`);
8180
- const P = y.data ?? new Uint8Array(await Wt(y.fullPath));
8257
+ if (!C.blob_name) throw new Error(`blob_name missing for ${y.relativePath}`);
8258
+ const P = y.data ?? new Uint8Array(await Yt(y.fullPath));
8181
8259
  await this._blob.uploadRaw(
8182
- I.blob_name,
8260
+ C.blob_name,
8183
8261
  P,
8184
- I
8262
+ C
8185
8263
  ), await this._queueFileLocation({
8186
8264
  relativePath: y.relativePath,
8187
8265
  md5: y.md5,
@@ -8189,8 +8267,8 @@ class fr {
8189
8267
  providerId: r,
8190
8268
  fileContentExists: !1
8191
8269
  }), E = !0, f += 1, k += y.size || 0, this._logProgress(f, u.totalCount, k, u.totalSize, n);
8192
- } catch (I) {
8193
- m += 1, console.error(`[CueSyncApi] Failed to upload file: ${y.fullPath}`), a && console.error("[CueSyncApi] Upload error details:", I);
8270
+ } catch (C) {
8271
+ m += 1, console.error(`[CueSyncApi] Failed to upload file: ${y.fullPath}`), a && console.error("[CueSyncApi] Upload error details:", C);
8194
8272
  }
8195
8273
  a && u.localNotOnRemotePathOnly.length && console.info(`Syncing missing file locations (on provider "${r}") ⏳`);
8196
8274
  for (const y of u.localNotOnRemotePathOnly)
@@ -8216,7 +8294,7 @@ class fr {
8216
8294
  async _getOrCreateGraph(t, e) {
8217
8295
  const o = this._graphMap.get(t);
8218
8296
  if (o) return o;
8219
- const s = (await this._projects.getProject(t))?.projectSettings?.graph?.type ?? mr, a = s === "qlever" ? `${this._gatewayUrl}${ee}` : `${this._gatewayUrl}${te}`, n = s === "qlever" ? `${this._gatewayUrl}${co}` : `${this._gatewayUrl}${po}`, p = new Ke({
8297
+ const s = (await this._projects.getProject(t))?.projectSettings?.graph?.type ?? mr, a = s === "qlever" ? `${this._gatewayUrl}${ie}` : `${this._gatewayUrl}${ae}`, n = s === "qlever" ? `${this._gatewayUrl}${co}` : `${this._gatewayUrl}${po}`, p = new Ze({
8220
8298
  graphType: s,
8221
8299
  queryEndpoint: a,
8222
8300
  updateEndpoint: n,
@@ -8282,7 +8360,7 @@ WHERE {
8282
8360
  }
8283
8361
  async _initPendingBatch(t, e) {
8284
8362
  this._flushTimer !== null && (clearInterval(this._flushTimer), this._flushTimer = null), this._pendingSpaceId = t, this._pendingItems = [];
8285
- const o = await Vt(t);
8363
+ const o = await Zt(t);
8286
8364
  if (o && o.items.length > 0) {
8287
8365
  console.info(`Trying to upload metadata from interrupted sync (${o.items.length} item(s))...`), e && console.info(`Flushing ${o.items.length} pending file location(s) from previous sync ⏳`);
8288
8366
  try {
@@ -8303,7 +8381,7 @@ WHERE {
8303
8381
  typeof r == "object" && typeof r.unref == "function" && r.unref(), this._flushTimer = r;
8304
8382
  }
8305
8383
  async _queueFileLocation(t) {
8306
- this._pendingItems.push(t), this._pendingSpaceId && await Kt({ spaceId: this._pendingSpaceId, items: this._pendingItems });
8384
+ this._pendingItems.push(t), this._pendingSpaceId && await Jt({ spaceId: this._pendingSpaceId, items: this._pendingItems });
8307
8385
  }
8308
8386
  /**
8309
8387
  * Flush all queued file-location items to the commands API in a single batch.
@@ -8325,11 +8403,11 @@ WHERE {
8325
8403
  o && console.info(`Wrote ${r.length} file location(s) to commands API ✅`);
8326
8404
  } catch (s) {
8327
8405
  const a = [...r, ...this._pendingItems];
8328
- throw this._pendingItems = a, await Kt({ spaceId: e, items: a }), s;
8406
+ throw this._pendingItems = a, await Jt({ spaceId: e, items: a }), s;
8329
8407
  }
8330
8408
  }
8331
8409
  async _postFssBatch(t, e) {
8332
- const o = this._legacy ? `${this._gatewayUrl}${Tt}?blob=true` : `${this._gatewayUrl}${Tt}`;
8410
+ const o = this._legacy ? `${this._gatewayUrl}${Ot}?blob=true` : `${this._gatewayUrl}${Ot}`;
8333
8411
  let r;
8334
8412
  try {
8335
8413
  r = await this._auth.authenticatedFetch(o, {
@@ -8359,14 +8437,14 @@ WHERE {
8359
8437
  * shown to the user before or after calling {@link sync}.
8360
8438
  */
8361
8439
  async scanCost(t) {
8362
- if (H || (H = ur()), await H, !q) throw new Error("WASM scan function not initialised");
8440
+ if (G || (G = ur()), await G, !q) throw new Error("WASM scan function not initialised");
8363
8441
  const e = 200, o = /* @__PURE__ */ new Map();
8364
8442
  for (let r = 0; r < t.length; r += e) {
8365
8443
  const s = t.slice(r, r + e), a = await Promise.all(
8366
8444
  s.map(async (p) => ({
8367
8445
  originalPath: p.relativePath,
8368
8446
  // Use pre-loaded data if available (browser), otherwise read from disk (Node.js).
8369
- data: p.data ?? new Uint8Array(await Wt(p.fullPath))
8447
+ data: p.data ?? new Uint8Array(await Yt(p.fullPath))
8370
8448
  }))
8371
8449
  ), n = q(a);
8372
8450
  for (const p of n) {
@@ -8426,7 +8504,7 @@ WHERE {
8426
8504
  const { spaceId: o, providerId: r, userId: s, signal: a, onProgress: n } = e;
8427
8505
  if (!t.data)
8428
8506
  throw new Error("syncBrowserFile requires file.data (Uint8Array). Read the file with File.arrayBuffer() first.");
8429
- const p = Ht(t.relativePath, o, s, t.md5, r);
8507
+ const p = Xt(t.relativePath, o, s, t.md5, r);
8430
8508
  if (!p.blob_name) throw new Error(`blob_name missing for ${t.relativePath}`);
8431
8509
  await this._blob.uploadRaw(
8432
8510
  p.blob_name,
@@ -8470,7 +8548,7 @@ WHERE {
8470
8548
  s({ percent: a, syncCount: t, totalCount: e, syncSize: o, totalSize: r });
8471
8549
  }
8472
8550
  }
8473
- const Qt = {
8551
+ const te = {
8474
8552
  production: {
8475
8553
  gatewayUrl: "https://accessors-api-gateway-ueyeemwf2a-oa.a.run.app",
8476
8554
  tokenUrl: "https://accessors-api-gateway-ueyeemwf2a-oa.a.run.app/token",
@@ -8490,7 +8568,7 @@ const Qt = {
8490
8568
  firestoreEmulatorPort: 8080
8491
8569
  }
8492
8570
  };
8493
- class he {
8571
+ class me {
8494
8572
  auth;
8495
8573
  api;
8496
8574
  projects;
@@ -8504,6 +8582,7 @@ class he {
8504
8582
  _storageRaw;
8505
8583
  _storageProcessed;
8506
8584
  _gis = null;
8585
+ _projectDocuments = /* @__PURE__ */ new Map();
8507
8586
  /**
8508
8587
  * Reactive GIS service. Lazily constructed on first access.
8509
8588
  *
@@ -8526,21 +8605,30 @@ class he {
8526
8605
  "Using default SDK app settings. Contact QAECY for your own configuration for any production code."
8527
8606
  );
8528
8607
  const o = t.apiKey ?? Y.apiKey, r = t.appId ?? Y.appId, s = t.measurementId ?? Y.measurementId, a = t.environment ?? "production";
8529
- this._endpoints = { ...Qt[a], ...t.endpoints }, this._isEmulator = a === "emulator", this._app = ge().find((p) => p.name === "[DEFAULT]") ?? ue({
8608
+ this._endpoints = { ...te[a], ...t.endpoints }, this._isEmulator = a === "emulator", this._app = fe().find((g) => g.name === "[DEFAULT]") ?? ye({
8530
8609
  apiKey: o,
8531
8610
  appId: r,
8532
8611
  measurementId: s,
8533
- authDomain: `${vt}.firebaseapp.com`,
8534
- projectId: vt,
8535
- messagingSenderId: Ze
8536
- }), this.auth = new Rt(this._app, this._isEmulator, this._endpoints), this.projects = new Mt(this.auth, this._app, this._isEmulator, this._endpoints), this._storageRaw = T(this._app, kt), this._storageProcessed = T(this._app, Et), this._isEmulator && (K(this._storageRaw, this._endpoints.storageEmulatorHost, this._endpoints.storageEmulatorPort), K(this._storageProcessed, this._endpoints.storageEmulatorHost, this._endpoints.storageEmulatorPort)), this.api = this._buildApi(this.projects), this.storage = new Pt(this._storageRaw, this._storageProcessed), this.profile = new zt(
8612
+ authDomain: `${kt}.firebaseapp.com`,
8613
+ projectId: kt,
8614
+ messagingSenderId: eo
8615
+ }), this.auth = new qt(this._app, this._isEmulator, this._endpoints), this.projects = new Bt(this.auth, this._app, this._isEmulator, this._endpoints), this._storageRaw = T(this._app, It), this._storageProcessed = T(this._app, Ct);
8616
+ const n = T(this._app, St), p = T(this._app, Tt), c = T(this._app, xt), h = T(this._app, Rt);
8617
+ this._isEmulator && (K(this._storageRaw, this._endpoints.storageEmulatorHost, this._endpoints.storageEmulatorPort), K(this._storageProcessed, this._endpoints.storageEmulatorHost, this._endpoints.storageEmulatorPort)), this.api = this._buildApi(this.projects);
8618
+ const d = new vt({
8619
+ storageRaw: this._storageRaw,
8620
+ storageProcessed: this._storageProcessed,
8621
+ storagePublic: n,
8622
+ storageLogs: p,
8623
+ storageChatSessions: c,
8624
+ storagePersistence: h
8625
+ });
8626
+ this.storage = new jt(d), this.profile = new Gt(
8537
8627
  this.auth,
8538
8628
  this._app,
8539
8629
  this._isEmulator,
8540
8630
  this._endpoints.gatewayUrl
8541
- ), this.privileges = new Ft(this.auth.isSuperAdmin);
8542
- const n = T(this._app, xt);
8543
- this._isEmulator && K(n, this._endpoints.storageEmulatorHost, this._endpoints.storageEmulatorPort), this.cache = new Bt(n);
8631
+ ), this.privileges = new Vt(this.auth.isSuperAdmin), this._isEmulator && K(h, this._endpoints.storageEmulatorHost, this._endpoints.storageEmulatorPort), this.cache = new Kt(h);
8544
8632
  }
8545
8633
  /**
8546
8634
  * Create a `Cue` instance from an already-initialized Firebase app.
@@ -8559,16 +8647,16 @@ class he {
8559
8647
  * });
8560
8648
  */
8561
8649
  static fromApp(t, e = {}) {
8562
- const o = e.environment ?? "production", r = { ...Qt[o], ...e.endpoints }, s = new Rt(t, !1, r), a = new Mt(s, t, !1, r), n = T(t, kt), p = T(t, Et), c = T(t, eo), h = T(t, to), d = T(t, Je), g = T(t, xt), w = new Qe({
8650
+ const o = e.environment ?? "production", r = { ...te[o], ...e.endpoints }, s = new qt(t, !1, r), a = new Bt(s, t, !1, r), n = T(t, It), p = T(t, Ct), c = T(t, St), h = T(t, Tt), d = T(t, xt), g = T(t, Rt), w = new vt({
8563
8651
  storageRaw: n,
8564
8652
  storageProcessed: p,
8565
8653
  storagePublic: c,
8566
8654
  storageLogs: h,
8567
8655
  storageChatSessions: d,
8568
8656
  storagePersistence: g
8569
- }), u = new fr(s, a, w, r.gatewayUrl), f = new Ot(s, r.gatewayUrl, a, u);
8657
+ }), u = new fr(s, a, w, r.gatewayUrl), f = new Ut(s, r.gatewayUrl, a, u);
8570
8658
  u._bindApi(f);
8571
- const k = new zt(s, t, !1, r.gatewayUrl), m = Object.create(he.prototype), E = new Ft(s.isSuperAdmin), C = new Bt(g), v = new Pt(n, p);
8659
+ const k = new Gt(s, t, !1, r.gatewayUrl), m = Object.create(me.prototype), E = new Vt(s.isSuperAdmin), I = new Kt(g), v = new jt(w);
8572
8660
  return Object.assign(m, {
8573
8661
  _app: t,
8574
8662
  _endpoints: r,
@@ -8580,13 +8668,13 @@ class he {
8580
8668
  projects: a,
8581
8669
  profile: k,
8582
8670
  privileges: E,
8583
- cache: C,
8671
+ cache: I,
8584
8672
  storage: v
8585
8673
  }), m;
8586
8674
  }
8587
8675
  /** Override in subclasses to provide a custom CueApi (e.g. with sync). */
8588
8676
  _buildApi(t) {
8589
- return new Ot(this.auth, this._endpoints.gatewayUrl, t);
8677
+ return new Ut(this.auth, this._endpoints.gatewayUrl, t);
8590
8678
  }
8591
8679
  /** Convenience: get the current user's Firebase ID token */
8592
8680
  getToken(t = !1) {
@@ -8635,7 +8723,7 @@ class he {
8635
8723
  get: (r) => this.cache.getQueryCache(t, r).then((s) => s?.results),
8636
8724
  set: (r, s) => this.cache.setQueryCache(t, r, { query: r, results: s })
8637
8725
  };
8638
- return new le(
8726
+ return new ue(
8639
8727
  this.api,
8640
8728
  t,
8641
8729
  e?.rdfBase,
@@ -8658,44 +8746,61 @@ class he {
8658
8746
  * ```
8659
8747
  */
8660
8748
  createProjectDocuments(t, e) {
8661
- const o = e?.queryCache ?? {
8662
- get: (r) => this.cache.getQueryCache(t, r).then((s) => s?.results),
8663
- set: (r, s) => this.cache.setQueryCache(t, r, { query: r, results: s })
8749
+ if (!(e?.language !== void 0 || e?.rdfBase !== void 0 || e?.graphType !== void 0 || e?.queryCache !== void 0)) {
8750
+ const s = this._projectDocuments.get(t);
8751
+ if (s)
8752
+ return s.setLanguage(this.api.language), s;
8753
+ const a = {
8754
+ get: (p) => this.cache.getQueryCache(t, p).then((c) => c?.results),
8755
+ set: (p, c) => this.cache.setQueryCache(t, p, { query: p, results: c })
8756
+ }, n = new pt(
8757
+ this.api,
8758
+ t,
8759
+ this.api.language,
8760
+ void 0,
8761
+ a,
8762
+ void 0
8763
+ );
8764
+ return this._projectDocuments.set(t, n), n;
8765
+ }
8766
+ const r = e?.queryCache ?? {
8767
+ get: (s) => this.cache.getQueryCache(t, s).then((a) => a?.results),
8768
+ set: (s, a) => this.cache.setQueryCache(t, s, { query: s, results: a })
8664
8769
  };
8665
- return new ce(
8770
+ return new pt(
8666
8771
  this.api,
8667
8772
  t,
8668
- e?.language,
8773
+ e?.language ?? this.api.language,
8669
8774
  e?.rdfBase,
8670
- o,
8775
+ r,
8671
8776
  e?.graphType
8672
8777
  );
8673
8778
  }
8674
8779
  }
8675
8780
  export {
8676
- Je as B,
8677
- he as C,
8678
- $t as R,
8679
- Ot as a,
8680
- Rt as b,
8681
- Bt as c,
8781
+ xt as B,
8782
+ me as C,
8783
+ Wt as R,
8784
+ Ut as a,
8785
+ qt as b,
8786
+ Kt as c,
8682
8787
  or as d,
8683
- Ft as e,
8684
- zt as f,
8685
- ce as g,
8686
- le as h,
8788
+ Vt as e,
8789
+ Gt as f,
8790
+ pt as g,
8791
+ ue as h,
8687
8792
  ar as i,
8688
8793
  nr as j,
8689
- Mt as k,
8794
+ Bt as k,
8690
8795
  x as l,
8691
- Pt as m,
8796
+ jt as m,
8692
8797
  fr as n,
8693
8798
  mo as o,
8694
8799
  Pr as p,
8695
- lt as q,
8696
- to as r,
8697
- ct as s,
8698
- xt as t,
8699
- eo as u,
8700
- Qe as v
8800
+ ct as q,
8801
+ Tt as r,
8802
+ ht as s,
8803
+ Rt as t,
8804
+ St as u,
8805
+ vt as v
8701
8806
  };