@uwrl/qc-utils 0.0.22 → 0.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- var W = /* @__PURE__ */ ((e) => (e.SECOND = "s", e.MINUTE = "m", e.HOUR = "h", e.DAY = "D", e.WEEK = "W", e.MONTH = "M", e.YEAR = "Y", e))(W || {}), v = /* @__PURE__ */ ((e) => (e.ADD_POINTS = "ADD_POINTS", e.CHANGE_VALUES = "CHANGE_VALUES", e.ASSIGN_VALUES_BULK = "ASSIGN_VALUES_BULK", e.DELETE_POINTS = "DELETE_POINTS", e.DRIFT_CORRECTION = "DRIFT_CORRECTION", e.INTERPOLATE = "INTERPOLATE", e.SHIFT_DATETIMES = "SHIFT_DATETIMES", e.ASSIGN_DATETIMES_BULK = "ASSIGN_DATETIMES_BULK", e.FILL_GAPS = "FILL_GAPS", e))(v || {}), T = /* @__PURE__ */ ((e) => (e.FIND_GAPS = "FIND_GAPS", e.PERSISTENCE = "PERSISTENCE", e.CHANGE = "CHANGE", e.RATE_OF_CHANGE = "RATE_OF_CHANGE", e.VALUE_THRESHOLD = "VALUE_THRESHOLD", e.DATETIME_RANGE = "DATETIME_RANGE", e.SELECTION = "SELECTION", e))(T || {}), K = /* @__PURE__ */ ((e) => (e.LT = "Less than", e.LTE = "Less than or equal to", e.GT = "Greater than", e.GTE = "Greater than or equal to", e.E = "Equal", e))(K || {}), Gt = /* @__PURE__ */ ((e) => (e.ADD = "ADD", e.SUB = "SUB", e.MULT = "MULT", e.DIV = "DIV", e.ASSIGN = "ASSIGN", e))(Gt || {}), Ht = /* @__PURE__ */ ((e) => (e.LT = "Less than", e.LTE = "Less than or equal to", e.GT = "Greater than", e.GTE = "Greater than or equal to", e.E = "Equal", e))(Ht || {});
2
- class zt {
1
+ var W = /* @__PURE__ */ ((e) => (e.SECOND = "s", e.MINUTE = "m", e.HOUR = "h", e.DAY = "D", e.WEEK = "W", e.MONTH = "M", e.YEAR = "Y", e))(W || {}), v = /* @__PURE__ */ ((e) => (e.ADD_POINTS = "ADD_POINTS", e.CHANGE_VALUES = "CHANGE_VALUES", e.ASSIGN_VALUES_BULK = "ASSIGN_VALUES_BULK", e.DELETE_POINTS = "DELETE_POINTS", e.DRIFT_CORRECTION = "DRIFT_CORRECTION", e.INTERPOLATE = "INTERPOLATE", e.SHIFT_DATETIMES = "SHIFT_DATETIMES", e.ASSIGN_DATETIMES_BULK = "ASSIGN_DATETIMES_BULK", e.FILL_GAPS = "FILL_GAPS", e))(v || {}), T = /* @__PURE__ */ ((e) => (e.FIND_GAPS = "FIND_GAPS", e.PERSISTENCE = "PERSISTENCE", e.CHANGE = "CHANGE", e.RATE_OF_CHANGE = "RATE_OF_CHANGE", e.VALUE_THRESHOLD = "VALUE_THRESHOLD", e.DATETIME_RANGE = "DATETIME_RANGE", e.SELECTION = "SELECTION", e))(T || {}), K = /* @__PURE__ */ ((e) => (e.LT = "Less than", e.LTE = "Less than or equal to", e.GT = "Greater than", e.GTE = "Greater than or equal to", e.E = "Equal", e))(K || {}), Gt = /* @__PURE__ */ ((e) => (e.ADD = "ADD", e.SUB = "SUB", e.MULT = "MULT", e.DIV = "DIV", e.ASSIGN = "ASSIGN", e))(Gt || {}), zt = /* @__PURE__ */ ((e) => (e.LT = "Less than", e.LTE = "Less than or equal to", e.GT = "Greater than", e.GTE = "Greater than or equal to", e.E = "Equal", e))(zt || {});
2
+ class Ht {
3
3
  id;
4
4
  thingId;
5
5
  link;
@@ -11,7 +11,7 @@ class zt {
11
11
  this.id = "", this.thingId = "", this.link = "", this.frequency = null, this.path = "HydroShare", this.datastreamIds = [], this.publicResource = !1;
12
12
  }
13
13
  }
14
- class ts extends zt {
14
+ class Zr extends Ht {
15
15
  resourceTitle;
16
16
  resourceAbstract;
17
17
  resourceKeywords;
@@ -31,7 +31,7 @@ class Xt {
31
31
  this.elevationDatum = "WGS84", this.state = "", this.county = "", this.country = "";
32
32
  }
33
33
  }
34
- class rs {
34
+ class es {
35
35
  id;
36
36
  workspaceId;
37
37
  name;
@@ -48,7 +48,7 @@ class rs {
48
48
  this.id = "", this.workspaceId = "", this.name = "", this.tags = [], this.siteType = "", this.samplingFeatureCode = "", this.isPrivate = !1, this.description = "", this.samplingFeatureType = "Site", this.dataDisclaimer = "";
49
49
  }
50
50
  }
51
- class ss {
51
+ class ts {
52
52
  id;
53
53
  workspaceId;
54
54
  name;
@@ -78,7 +78,7 @@ class ss {
78
78
  this.id = "", this.workspaceId = "", this.name = "", this.description = "", this.thingId = t || "", this.observationType = "OM_Measurement", this.resultType = "Time Series Coverage", this.sampledMedium = "", this.noDataValue = -9999, this.aggregationStatistic = "", this.unitId = "", this.observedPropertyId = "", this.sensorId = "", this.processingLevelId = "", this.timeAggregationInterval = null, this.timeAggregationIntervalUnit = "seconds", this.isPrivate = !0, this.isVisible = !0, this.valueCount = 0;
79
79
  }
80
80
  }
81
- class ns {
81
+ class rs {
82
82
  id;
83
83
  workspaceId;
84
84
  name;
@@ -89,7 +89,7 @@ class ns {
89
89
  this.id = "", this.workspaceId = "", this.name = "", this.symbol = "", this.definition = "", this.type = "";
90
90
  }
91
91
  }
92
- class os {
92
+ class ss {
93
93
  id;
94
94
  workspaceId;
95
95
  name;
@@ -105,7 +105,7 @@ class os {
105
105
  this.id = "", this.workspaceId = "", this.name = "", this.description = "", this.manufacturer = "", this.model = "", this.methodType = "Instrument Deployment", this.methodCode = "", this.methodLink = "", this.encodingType = "application/json", this.modelLink = "";
106
106
  }
107
107
  }
108
- class as {
108
+ class ns {
109
109
  id;
110
110
  workspaceId;
111
111
  name;
@@ -117,7 +117,7 @@ class as {
117
117
  this.id = "", this.workspaceId = "", this.name = "", this.definition = "", this.description = "", this.type = "Hydrology", this.code = "";
118
118
  }
119
119
  }
120
- class is {
120
+ class os {
121
121
  id;
122
122
  workspaceId;
123
123
  code;
@@ -127,7 +127,7 @@ class is {
127
127
  this.id = "", this.workspaceId = "", this.code = "", this.definition = "", this.explanation = "";
128
128
  }
129
129
  }
130
- class cs {
130
+ class as {
131
131
  id;
132
132
  workspaceId;
133
133
  code;
@@ -136,7 +136,7 @@ class cs {
136
136
  this.id = "", this.workspaceId = "", this.code = "", this.description = "";
137
137
  }
138
138
  }
139
- class ls {
139
+ class is {
140
140
  name;
141
141
  code;
142
142
  type;
@@ -145,7 +145,7 @@ class ls {
145
145
  constructor() {
146
146
  }
147
147
  }
148
- class us {
148
+ class cs {
149
149
  id;
150
150
  email;
151
151
  password;
@@ -163,7 +163,7 @@ class us {
163
163
  this.id = "", this.email = "", this.password = "", this.firstName = "", this.middleName = "", this.lastName = "", this.phone = "", this.address = "", this.type = "", this.link = "", this.accountType = "standard", this.hydroShareConnected = !1;
164
164
  }
165
165
  }
166
- class hs {
166
+ class ls {
167
167
  id;
168
168
  name;
169
169
  iconLink;
@@ -174,7 +174,7 @@ class hs {
174
174
  }
175
175
  }
176
176
  var Vt = /* @__PURE__ */ ((e) => (e.Global = "*", e.View = "view", e.Create = "create", e.Edit = "edit", e.Delete = "delete", e))(Vt || {}), qt = /* @__PURE__ */ ((e) => (e.Global = "*", e.Workspace = "Workspace", e.Collaborator = "Collaborator", e.Thing = "Thing", e.Datastream = "Datastream", e.Sensor = "Sensor", e.Unit = "Unit", e.ObservedProperty = "ObservedProperty", e.ProcessingLevel = "ProcessingLevel", e.Observation = "Observation", e))(qt || {});
177
- class fs {
177
+ class us {
178
178
  id = "";
179
179
  key = "";
180
180
  name = "";
@@ -189,7 +189,7 @@ class fs {
189
189
  Object.assign(this, t);
190
190
  }
191
191
  }
192
- class ds {
192
+ class hs {
193
193
  id;
194
194
  name;
195
195
  isPrivate;
@@ -200,7 +200,7 @@ class ds {
200
200
  this.id = "", this.name = "", this.isPrivate = !1, this.owner = null, this.collaboratorRole = null, this.pendingTransferTo = null;
201
201
  }
202
202
  }
203
- class ps {
203
+ class fs {
204
204
  user;
205
205
  role;
206
206
  constructor() {
@@ -561,7 +561,7 @@ function or(e) {
561
561
  }, r);
562
562
  };
563
563
  }
564
- var He = (function() {
564
+ var ze = (function() {
565
565
  function e(t) {
566
566
  t && (this._subscribe = t);
567
567
  }
@@ -582,7 +582,7 @@ var He = (function() {
582
582
  }
583
583
  }, e.prototype.forEach = function(t, r) {
584
584
  var s = this;
585
- return r = ze(r), new r(function(n, a) {
585
+ return r = He(r), new r(function(n, a) {
586
586
  var o = new Oe({
587
587
  next: function(i) {
588
588
  try {
@@ -607,7 +607,7 @@ var He = (function() {
607
607
  return or(t)(this);
608
608
  }, e.prototype.toPromise = function(t) {
609
609
  var r = this;
610
- return t = ze(t), new t(function(s, n) {
610
+ return t = He(t), new t(function(s, n) {
611
611
  var a;
612
612
  r.subscribe(function(o) {
613
613
  return a = o;
@@ -621,7 +621,7 @@ var He = (function() {
621
621
  return new e(t);
622
622
  }, e;
623
623
  })();
624
- function ze(e) {
624
+ function He(e) {
625
625
  var t;
626
626
  return (t = e ?? Qt.Promise) !== null && t !== void 0 ? t : Promise;
627
627
  }
@@ -709,12 +709,12 @@ var cr = wt(function(e) {
709
709
  var s = this, n = s.hasError, a = s.thrownError, o = s.isStopped;
710
710
  n ? r.error(a) : o && r.complete();
711
711
  }, t.prototype.asObservable = function() {
712
- var r = new He();
712
+ var r = new ze();
713
713
  return r.source = this, r;
714
714
  }, t.create = function(r, s) {
715
715
  return new Xe(r, s);
716
716
  }, t;
717
- })(He), Xe = (function(e) {
717
+ })(ze), Xe = (function(e) {
718
718
  de(t, e);
719
719
  function t(r, s) {
720
720
  var n = e.call(this) || this;
@@ -886,7 +886,7 @@ function pr() {
886
886
  }, Se;
887
887
  }
888
888
  var yr = pr();
889
- const gr = /* @__PURE__ */ fr(yr), z = gr(10), mr = 1e3;
889
+ const gr = /* @__PURE__ */ fr(yr), H = gr(10), mr = 1e3;
890
890
  async function q(e, t) {
891
891
  const r = gt(t);
892
892
  try {
@@ -898,25 +898,25 @@ async function q(e, t) {
898
898
  }
899
899
  const c = {
900
900
  async fetch(e, t = {}) {
901
- return t.method = "GET", await z(() => q(e, t));
901
+ return t.method = "GET", await H(() => q(e, t));
902
902
  },
903
903
  async patch(e, t, r = null, s = {}) {
904
904
  if (s.method = "PATCH", s.body = r ? Lt(r, t) : t, Object.keys(s.body).length !== 0)
905
- return await z(() => q(e, s));
905
+ return await H(() => q(e, s));
906
906
  },
907
907
  async post(e, t = void 0, r = {}) {
908
- return r.method = "POST", r.body = t, await z(() => q(e, r));
908
+ return r.method = "POST", r.body = t, await H(() => q(e, r));
909
909
  },
910
910
  async put(e, t = void 0, r = {}) {
911
- return r.method = "PUT", r.body = t, await z(() => q(e, r));
911
+ return r.method = "PUT", r.body = t, await H(() => q(e, r));
912
912
  },
913
913
  async delete(e, t = void 0, r = {}) {
914
- return r.method = "DELETE", r.body = t, await z(() => q(e, r));
914
+ return r.method = "DELETE", r.body = t, await H(() => q(e, r));
915
915
  },
916
916
  async paginatedFetch(e, t) {
917
- const r = t ?? mr, s = e.includes("?") ? "&" : "?", n = `${e}${s}page_size=${r}&page=1`, a = gt({ method: "GET" }), o = await z(() => fetch(n, a)), i = Number(o.headers.get("x-total-pages")) || 1, d = [...await mt(o)];
917
+ const r = t ?? mr, s = e.includes("?") ? "&" : "?", n = `${e}${s}page_size=${r}&page=1`, a = gt({ method: "GET" }), o = await H(() => fetch(n, a)), i = Number(o.headers.get("x-total-pages")) || 1, d = [...await mt(o)];
918
918
  for (let u = 2; u <= i; u++) {
919
- const y = `${e}${s}page_size=${r}&page=${u}`, g = await z(() => q(y, { method: "GET" }));
919
+ const y = `${e}${s}page_size=${r}&page=${u}`, g = await H(() => q(y, { method: "GET" }));
920
920
  d.push(...g);
921
921
  }
922
922
  return d;
@@ -960,7 +960,7 @@ const c = {
960
960
  type: "HydroServer"
961
961
  }
962
962
  };
963
- class ys {
963
+ class ds {
964
964
  name = "";
965
965
  settings = {
966
966
  type: "SDL",
@@ -1010,7 +1010,7 @@ function Ze(e) {
1010
1010
  status: e.status
1011
1011
  };
1012
1012
  }
1013
- const C = "https://lro.hydroserver.org/api", De = `${C}/auth`, N = `${De}/browser/account`, Ee = `${De}/browser/session`, le = `${De}/browser/provider`, R = `${C}/data/workspaces`, ve = `${C}/data/roles`, O = `${C}/data/datastreams`, H = `${C}/data/sensors`, A = `${C}/data/things`, et = `${A}/tags`, J = `${C}/data/orchestration-systems`, Y = `${C}/data/data-sources`, X = `${C}/data/observed-properties`, Q = `${C}/data/processing-levels`, ee = `${C}/data/result-qualifiers`, V = `${C}/data/units`, gs = (e, t, r, s, n) => {
1013
+ const C = "https://lro.hydroserver.org/api", De = `${C}/auth`, N = `${De}/browser/account`, Ee = `${De}/browser/session`, le = `${De}/browser/provider`, R = `${C}/data/workspaces`, ve = `${C}/data/roles`, O = `${C}/data/datastreams`, z = `${C}/data/sensors`, A = `${C}/data/things`, et = `${A}/tags`, J = `${C}/data/orchestration-systems`, Y = `${C}/data/data-sources`, X = `${C}/data/observed-properties`, Q = `${C}/data/processing-levels`, ee = `${C}/data/result-qualifiers`, V = `${C}/data/units`, ps = (e, t, r, s, n) => {
1014
1014
  let a = `${O}/${e}/observations?format=column`;
1015
1015
  return a += `&order_by=phenomenonTime&page_size=${t}`, a += `&phenomenon_time_min=${encodeURIComponent(r)}`, s && (a += `&phenomenon_time_max=${encodeURIComponent(s)}`), n && (a += `&page=${n}`), a;
1016
1016
  }, wr = (e, t, r) => {
@@ -1028,7 +1028,7 @@ const C = "https://lro.hydroserver.org/api", De = `${C}/auth`, N = `${De}/browse
1028
1028
  i.type = "hidden", i.name = o, i.value = s[o] || "", a.appendChild(i);
1029
1029
  }
1030
1030
  document.body.appendChild(a), a.submit();
1031
- }, ms = {
1031
+ }, ys = {
1032
1032
  fetchSession: async () => c.fetch(`${Ee}`),
1033
1033
  login: async (e, t) => c.post(`${Ee}`, { email: e, password: t }),
1034
1034
  logout: async () => c.delete(`${Ee}`),
@@ -1194,12 +1194,12 @@ const C = "https://lro.hydroserver.org/api", De = `${C}/auth`, N = `${De}/browse
1194
1194
  fetchWorkspaceProcessingLevels: async (e) => c.paginatedFetch(`${Q}?workspace_id=${e}`),
1195
1195
  updateProcessingLevel: async (e, t = null) => c.patch(`${Q}/${e.id}`, e, t),
1196
1196
  deleteProcessingLevel: async (e) => c.delete(`${Q}/${e}`),
1197
- createSensor: async (e) => c.post(H, e),
1198
- fetchSensors: async () => c.paginatedFetch(`${H}`),
1199
- fetchSensor: async (e) => c.fetch(`${H}/${e}`),
1200
- fetchWorkspaceSensors: async (e) => c.paginatedFetch(`${H}?workspace_id=${e}`),
1201
- updateSensor: async (e, t = null) => c.patch(`${H}/${e.id}`, e, t),
1202
- deleteSensor: async (e) => c.delete(`${H}/${e}`),
1197
+ createSensor: async (e) => c.post(z, e),
1198
+ fetchSensors: async () => c.paginatedFetch(`${z}`),
1199
+ fetchSensor: async (e) => c.fetch(`${z}/${e}`),
1200
+ fetchWorkspaceSensors: async (e) => c.paginatedFetch(`${z}?workspace_id=${e}`),
1201
+ updateSensor: async (e, t = null) => c.patch(`${z}/${e.id}`, e, t),
1202
+ deleteSensor: async (e) => c.delete(`${z}/${e}`),
1203
1203
  createResultQualifier: async (e) => c.post(ee, e),
1204
1204
  fetchResultQualifiers: async () => c.paginatedFetch(`${ee}`),
1205
1205
  fetchWorkspaceResultQualifiers: async (e) => c.paginatedFetch(`${ee}?workspace_id=${e}`),
@@ -1248,15 +1248,15 @@ const C = "https://lro.hydroserver.org/api", De = `${C}/auth`, N = `${De}/browse
1248
1248
  fetchOrganizationTypes: async () => c.fetch(`${N}/organization-types`),
1249
1249
  fetchSiteTypes: async () => c.fetch(`${A}/site-types`),
1250
1250
  fetchSamplingFeatureTypes: async () => c.paginatedFetch(`${A}/sampling-feature-types`),
1251
- fetchSensorEncodingTypes: async () => c.paginatedFetch(`${H}/encoding-types`),
1252
- fetchMethodTypes: async () => c.paginatedFetch(`${H}/method-types`),
1251
+ fetchSensorEncodingTypes: async () => c.paginatedFetch(`${z}/encoding-types`),
1252
+ fetchMethodTypes: async () => c.paginatedFetch(`${z}/method-types`),
1253
1253
  fetchVariableTypes: async () => c.paginatedFetch(`${X}/variable-types`),
1254
1254
  fetchUnitTypes: async () => c.paginatedFetch(`${V}/types`),
1255
1255
  fetchDatastreamStatuses: async () => c.paginatedFetch(`${O}/statuses`),
1256
1256
  fetchDatastreamAggregations: async () => c.paginatedFetch(`${O}/aggregation-statistics`),
1257
1257
  fetchSampledMediums: async () => c.paginatedFetch(`${O}/sampled-mediums`)
1258
1258
  };
1259
- class ws {
1259
+ class gs {
1260
1260
  name = "";
1261
1261
  mappings = [];
1262
1262
  extractorVariables = {};
@@ -1272,7 +1272,7 @@ const $t = 1, he = $t * 60, Ce = he * 60, xe = Ce * 24, br = xe * 7, Sr = Ce * 3
1272
1272
  [W.WEEK]: br,
1273
1273
  [W.MONTH]: Sr,
1274
1274
  [W.YEAR]: Er
1275
- }, bs = (e) => e.toLocaleString(void 0, {
1275
+ }, ms = (e) => e.toLocaleString(void 0, {
1276
1276
  year: "numeric",
1277
1277
  month: "short",
1278
1278
  day: "2-digit",
@@ -1280,7 +1280,7 @@ const $t = 1, he = $t * 60, Ce = he * 60, xe = Ce * 24, br = xe * 7, Sr = Ce * 3
1280
1280
  hour12: !1,
1281
1281
  minute: "2-digit",
1282
1282
  second: "2-digit"
1283
- }), Ss = (e) => {
1283
+ }), ws = (e) => {
1284
1284
  let t, r;
1285
1285
  e >= he * 1e3 ? (t = e / (he * 1e3), r = "m") : e >= 1e3 ? (t = e / 1e3, r = "s") : (t = e, r = "ms");
1286
1286
  let s;
@@ -1290,7 +1290,7 @@ const $t = 1, he = $t * 60, Ce = he * 60, xe = Ce * 24, br = xe * 7, Sr = Ce * 3
1290
1290
  const r = performance.now(), s = await e(), a = +(performance.now() - r);
1291
1291
  return { response: s, duration: a };
1292
1292
  };
1293
- function Es(e, t) {
1293
+ function bs(e, t) {
1294
1294
  const r = new Date(e);
1295
1295
  return r.setHours(r.getHours() - t), r.toISOString();
1296
1296
  }
@@ -1875,7 +1875,7 @@ function D(e, t) {
1875
1875
  predictedWorkerMs: 0,
1876
1876
  reason: r.rationale
1877
1877
  };
1878
- const s = Hr(e, t);
1878
+ const s = zr(e, t);
1879
1879
  if (s <= 0)
1880
1880
  return {
1881
1881
  useWorker: !1,
@@ -1897,7 +1897,7 @@ function D(e, t) {
1897
1897
  reason: i ? `worker faster (${o.toFixed(1)} vs ${a.toFixed(1)} ms)` : `inline faster (${a.toFixed(1)} vs ${o.toFixed(1)} ms)`
1898
1898
  };
1899
1899
  }
1900
- function Hr(e, t) {
1900
+ function zr(e, t) {
1901
1901
  switch (e) {
1902
1902
  case v.CHANGE_VALUES:
1903
1903
  case v.INTERPOLATE:
@@ -1914,30 +1914,30 @@ function Hr(e, t) {
1914
1914
  return t.datasetSize;
1915
1915
  }
1916
1916
  }
1917
- function vs(e) {
1917
+ function Ss(e) {
1918
1918
  return Ue.add(e), () => Ue.delete(e);
1919
1919
  }
1920
- function ks() {
1920
+ function Es() {
1921
1921
  return M;
1922
1922
  }
1923
- function _s() {
1923
+ function vs() {
1924
1924
  return Ne;
1925
1925
  }
1926
- function As() {
1926
+ function ks() {
1927
1927
  return Object.keys(Fe).map((e) => ({ op: e, ...Fe[e] }));
1928
1928
  }
1929
- function Ts() {
1929
+ function _s() {
1930
1930
  M = fe, Ne = null;
1931
1931
  try {
1932
1932
  localStorage.removeItem(Pe);
1933
1933
  } catch {
1934
1934
  }
1935
1935
  }
1936
- async function Ls(e = {}) {
1936
+ async function As(e = {}) {
1937
1937
  if (typeof window > "u" || !(e.force || M.measuredAt === 0 || Date.now() - M.measuredAt > Gr)) return M;
1938
1938
  if (te) await te;
1939
1939
  else {
1940
- te = zr().finally(() => {
1940
+ te = Hr().finally(() => {
1941
1941
  te = null;
1942
1942
  });
1943
1943
  const r = await te;
@@ -1946,7 +1946,7 @@ async function Ls(e = {}) {
1946
1946
  }
1947
1947
  return M;
1948
1948
  }
1949
- async function zr() {
1949
+ async function Hr() {
1950
1950
  if (!(typeof SharedArrayBuffer < "u"))
1951
1951
  return {
1952
1952
  ...fe,
@@ -2046,21 +2046,21 @@ function Vr(e) {
2046
2046
  } catch {
2047
2047
  }
2048
2048
  }
2049
- const re = 20 * 1e3, qr = 1024, Jr = ["date", "value", "qualifier"], Qr = typeof SharedArrayBuffer < "u";
2049
+ const re = 20 * 1e3, qr = typeof SharedArrayBuffer < "u";
2050
2050
  function U(e, t) {
2051
- return Qr ? t !== void 0 ? new SharedArrayBuffer(e, { maxByteLength: t }) : new SharedArrayBuffer(e) : t !== void 0 ? new ArrayBuffer(e, { maxByteLength: t }) : new ArrayBuffer(e);
2051
+ return qr ? t !== void 0 ? new SharedArrayBuffer(e, { maxByteLength: t }) : new SharedArrayBuffer(e) : t !== void 0 ? new ArrayBuffer(e, { maxByteLength: t }) : new ArrayBuffer(e);
2052
2052
  }
2053
2053
  function pt(e, t) {
2054
2054
  const r = e;
2055
2055
  typeof r.grow == "function" ? r.grow(t) : typeof r.resize == "function" && r.resize(t);
2056
2056
  }
2057
- function Kr(e, t) {
2057
+ function Jr(e, t) {
2058
2058
  if (e.length !== t.length) return !1;
2059
2059
  for (let r = 0; r < e.length; r++)
2060
2060
  if (e[r] !== t[r]) return !1;
2061
2061
  return !0;
2062
2062
  }
2063
- function Zr(e, t) {
2063
+ function Qr(e, t) {
2064
2064
  switch (e) {
2065
2065
  case v.ADD_POINTS:
2066
2066
  case v.FILL_GAPS:
@@ -2069,10 +2069,9 @@ function Zr(e, t) {
2069
2069
  return !0;
2070
2070
  }
2071
2071
  }
2072
- class $s {
2072
+ class Ts {
2073
2073
  /** The generated dataset to be used for plotting */
2074
2074
  dataset = {
2075
- dimensions: Jr,
2076
2075
  source: {
2077
2076
  x: new Float64Array(
2078
2077
  U(
@@ -2174,17 +2173,16 @@ class $s {
2174
2173
  this.loadingTime = null, this.isLoading = !0, this.history.length = 0, await this.loadData(this.rawData);
2175
2174
  }
2176
2175
  /**
2177
- * @param index
2178
- * @returns
2176
+ * Truncate history at `index` (inclusive), reload from raw, and
2177
+ * replay the surviving entries. Used by the "Reload from this step"
2178
+ * button in EditHistory.
2179
2179
  */
2180
2180
  async reloadHistory(t) {
2181
2181
  const r = this.history.slice(0, t + 1);
2182
2182
  return this.redoStack.length = 0, await this.reload(), await this.dispatch(r.map((s) => [s.method, ...s.args || []]));
2183
2183
  }
2184
- /**
2185
- * Remove a history item
2186
- * @param index
2187
- */
2184
+ /** Splice the history entry at `index`, reload from raw, and replay
2185
+ * the survivors. */
2188
2186
  async removeHistoryItem(t) {
2189
2187
  const r = [...this.history];
2190
2188
  return r.splice(t, 1), this.redoStack.length = 0, await this.reload(), await this.dispatch(r.map((s) => [s.method, ...s.args || []]));
@@ -2257,7 +2255,7 @@ class $s {
2257
2255
  method: t,
2258
2256
  args: r,
2259
2257
  isLoading: !0
2260
- }, this.history.push(a), Zr(t, r) || this.history[this.history.length - 2]?.method === T.SELECTION && this.history.splice(this.history.length - 2, 1), this._pendingExecutionMode = "inline";
2258
+ }, this.history.push(a), Qr(t, r) || this.history[this.history.length - 2]?.method === T.SELECTION && this.history.splice(this.history.length - 2, 1), this._pendingExecutionMode = "inline";
2261
2259
  const o = await ke(async () => await s[t].apply(this, r));
2262
2260
  n = o.response;
2263
2261
  const i = this.history.indexOf(a), l = i >= 0 ? this.history[i] : void 0;
@@ -2319,12 +2317,6 @@ class $s {
2319
2317
  }
2320
2318
  return n;
2321
2319
  }
2322
- /**
2323
- * @param index An array containing the list of index of values to perform the operations on.
2324
- * @param operator The operator that will be applied
2325
- * @param value The value to use in the operation
2326
- * @returns an array of index values to keep selected in the plot
2327
- */
2328
2320
  /**
2329
2321
  * Multi-threaded apply of an arithmetic operator to Y at the previously-filtered selection.
2330
2322
  * 1. Selection is read from the previous history entry (the last entry is this operation itself).
@@ -2338,7 +2330,7 @@ class $s {
2338
2330
  if (!D(v.CHANGE_VALUES, {
2339
2331
  datasetSize: this.dataset.source.y.length,
2340
2332
  selectionSize: n
2341
- }).useWorker || n < qr)
2333
+ }).useWorker)
2342
2334
  return dt(this.dataY, s, t, r), [];
2343
2335
  this._pendingExecutionMode = "worker";
2344
2336
  const o = Math.min(navigator.hardwareConcurrency || 1, n), i = Math.ceil(n / o), l = [], d = [];
@@ -2530,13 +2522,15 @@ class $s {
2530
2522
  return await this._deleteDataPoints(t), await this._addDataPoints(w) ?? [];
2531
2523
  }
2532
2524
  /**
2533
- * Multi-threaded version of {@link _fillGaps}.
2525
+ * Detect gaps in the configured window and insert fill points using
2526
+ * either linear interpolation or a sentinel `fillValue`. Inline path:
2527
+ * single copy-with-fills sweep into freshly-allocated x/y buffers.
2528
+ * Worker path:
2534
2529
  * 1. The main thread scans once for gaps and computes the number of fill points per gap.
2535
2530
  * 2. The original array is split into equal segments; each gap is assigned to the segment containing its left index.
2536
2531
  * 3. Cumulative fill counts before each segment give each worker's output startTarget, ensuring no overlap.
2537
2532
  * 4. Each worker copies its segment to the output buffer and inserts its gap fills inline.
2538
- */
2539
- /**
2533
+ *
2540
2534
  * @param range Optional `[startTs, endTs]` window in epoch
2541
2535
  * milliseconds. Both bounds inclusive; snapped to the nearest
2542
2536
  * enclosed point via binary search. Datetime-addressed (not
@@ -2642,12 +2636,12 @@ class $s {
2642
2636
  return this._deleteDataPoints(t);
2643
2637
  }
2644
2638
  /**
2645
- Deletes data points from a large array using worker threads.
2646
- 1. The main thread divides the original array into equal parts to distribute work among workers.
2647
- 2. For each segment, binary search locates the indexes to delete (deleteSegment), ensuring efficient lookups.
2648
- 3. The cumulative deletions before each segment help compute the starting index (startTarget) for each worker's output, ensuring no overlap.
2649
- 4. Each worker processes its segment linearly, skipping deletions and copying kept elements to their computed positions.
2650
- * @param deleteIndices
2639
+ * Delete points by ascending `deleteIndices` from x/y. Inline path
2640
+ * runs a single skip-on-delete copy on the main thread; worker path:
2641
+ * 1. Main thread splits the original array into equal segments.
2642
+ * 2. Per-segment binary search locates the indexes to delete (deleteSegment) for efficient lookups.
2643
+ * 3. Cumulative deletions before each segment give each worker's output startTarget so segments don't overlap.
2644
+ * 4. Each worker walks its segment linearly, skipping deletions and copying kept elements into place.
2651
2645
  */
2652
2646
  async _deleteDataPoints(t) {
2653
2647
  const r = this.dataX.length, s = r - t.length;
@@ -2730,12 +2724,6 @@ class $s {
2730
2724
  if (n.length !== 0)
2731
2725
  return this._driftCorrection(n);
2732
2726
  }
2733
- /**
2734
- *
2735
- * @param start The start index
2736
- * @param end The end index
2737
- * @param value The drift amount
2738
- */
2739
2727
  /**
2740
2728
  * Multi-threaded drift correction over one or more [start, end, value] ranges.
2741
2729
  * 1. Main thread reads each range's anchors (startDatetime, extent) once and chunks the range.
@@ -2877,11 +2865,6 @@ class $s {
2877
2865
  // =======================
2878
2866
  // FILTER OPERATIONS
2879
2867
  // =======================
2880
- /**
2881
- * Filter by applying a set of logical operations
2882
- * @param appliedFilters
2883
- * @returns an array of index values to select in the plot
2884
- */
2885
2868
  /**
2886
2869
  * Filter by applying a set of logical operations, using worker threads.
2887
2870
  * 1. Main thread encodes filters as numeric opcodes + thresholds (cheaper than string compares in the hot loop).
@@ -2941,12 +2924,6 @@ class $s {
2941
2924
  }
2942
2925
  return p;
2943
2926
  }
2944
- /**
2945
- *
2946
- * @param comparator
2947
- * @param value
2948
- * @returns
2949
- */
2950
2927
  /**
2951
2928
  * Find points where the relative rate `(curr - prev) / |prev|` satisfies the comparator, using worker threads.
2952
2929
  * 1. Main thread partitions scan range [1, dataY.length) into chunks; `Y[i-1]` is safely read from the shared buffer across chunk boundaries.
@@ -3038,14 +3015,8 @@ class $s {
3038
3015
  */
3039
3016
  async _selection(t) {
3040
3017
  const r = this.history[this.history.length - 2], s = !!r && r.method !== T.SELECTION && !!T[r.method], n = s && Array.isArray(r.selected) ? r.selected : void 0;
3041
- return !t || !t.length ? (this.history.pop(), n && n.length > 0 && this.history.pop(), t) : (n && Kr(n, t) ? this.history.pop() : s && this.history.splice(this.history.length - 2, 1), t);
3018
+ return !t || !t.length ? (this.history.pop(), n && n.length > 0 && this.history.pop(), t) : (n && Jr(n, t) ? this.history.pop() : s && this.history.splice(this.history.length - 2, 1), t);
3042
3019
  }
3043
- /**
3044
- *
3045
- * @param comparator
3046
- * @param value
3047
- * @returns
3048
- */
3049
3020
  /**
3050
3021
  * Find points where the change from the previous value satisfies the comparator, using worker threads.
3051
3022
  * 1. Main thread partitions scan range [1, dataY.length) into chunks (each chunk's first index safely reads Y[i-1] from the shared buffer).
@@ -3227,11 +3198,11 @@ class $s {
3227
3198
  return w;
3228
3199
  }
3229
3200
  }
3230
- const ue = "1", es = /* @__PURE__ */ new Set([
3201
+ const ue = "1", Kr = /* @__PURE__ */ new Set([
3231
3202
  ...Object.values(v),
3232
3203
  ...Object.values(T)
3233
3204
  ]);
3234
- function Rs(e, t) {
3205
+ function Ls(e, t) {
3235
3206
  const r = e.history.map((s) => {
3236
3207
  const n = {
3237
3208
  method: s.method,
@@ -3249,7 +3220,7 @@ function Rs(e, t) {
3249
3220
  operations: r
3250
3221
  };
3251
3222
  }
3252
- function Is(e) {
3223
+ function $s(e) {
3253
3224
  if (!e || typeof e != "object")
3254
3225
  throw new Error("QC script must be a JSON object.");
3255
3226
  const t = e;
@@ -3272,7 +3243,7 @@ function Is(e) {
3272
3243
  const o = n;
3273
3244
  if (typeof o.method != "string")
3274
3245
  throw new Error(`Operation ${a} missing string \`method\`.`);
3275
- if (!es.has(o.method))
3246
+ if (!Kr.has(o.method))
3276
3247
  throw new Error(`Operation ${a} has unknown method: "${o.method}".`);
3277
3248
  if (!Array.isArray(o.args))
3278
3249
  throw new Error(`Operation ${a} \`args\` must be an array.`);
@@ -3292,7 +3263,7 @@ function Is(e) {
3292
3263
  operations: s
3293
3264
  };
3294
3265
  }
3295
- async function Os(e, t) {
3266
+ async function Rs(e, t) {
3296
3267
  e.history.length = 0, e.redoStack.length = 0, await e.reload();
3297
3268
  const r = { applied: 0, failed: [] };
3298
3269
  for (let s = 0; s < t.operations.length; s++) {
@@ -3316,35 +3287,35 @@ async function Os(e, t) {
3316
3287
  export {
3317
3288
  N as ACCOUNT_BASE,
3318
3289
  De as AUTH_BASE,
3319
- fs as ApiKey,
3290
+ us as ApiKey,
3320
3291
  C as BASE_URL,
3321
- ps as Collaborator,
3292
+ fs as Collaborator,
3322
3293
  kt as DEFAULT_SNACK_DURATION,
3323
- ys as DataSource,
3324
- ss as Datastream,
3294
+ ds as DataSource,
3295
+ ts as Datastream,
3325
3296
  v as EnumEditOperations,
3326
3297
  T as EnumFilterOperations,
3327
3298
  K as FilterOperation,
3328
- zt as HydroShareArchive,
3299
+ Ht as HydroShareArchive,
3329
3300
  re as INCREASE_AMOUNT,
3330
3301
  Xt as Location,
3331
- Ht as LogicalOperation,
3332
- hs as OAuthProvider,
3333
- $s as ObservationRecord,
3334
- as as ObservedProperty,
3302
+ zt as LogicalOperation,
3303
+ ls as OAuthProvider,
3304
+ Ts as ObservationRecord,
3305
+ ns as ObservedProperty,
3335
3306
  Gt as Operator,
3336
- ls as Organization,
3307
+ is as Organization,
3337
3308
  le as PROVIDER_BASE,
3338
- ws as Payload,
3309
+ gs as Payload,
3339
3310
  Vt as PermissionAction,
3340
3311
  qt as PermissionResource,
3341
3312
  lr as Position,
3342
- ts as PostHydroShareArchive,
3343
- is as ProcessingLevel,
3313
+ Zr as PostHydroShareArchive,
3314
+ os as ProcessingLevel,
3344
3315
  ue as QC_SCRIPT_VERSION,
3345
- cs as ResultQualifier,
3316
+ as as ResultQualifier,
3346
3317
  Ee as SESSION_BASE,
3347
- os as Sensor,
3318
+ ss as Sensor,
3348
3319
  ur as Snack,
3349
3320
  _t as SnackColor,
3350
3321
  At as SnackIcon,
@@ -3352,35 +3323,35 @@ export {
3352
3323
  hr as Snackbar,
3353
3324
  et as TAG_BASE,
3354
3325
  A as THINGS_BASE,
3355
- rs as Thing,
3326
+ es as Thing,
3356
3327
  W as TimeUnit,
3357
- ns as Unit,
3358
- us as User,
3359
- ds as Workspace,
3360
- ms as api,
3328
+ rs as Unit,
3329
+ cs as User,
3330
+ hs as Workspace,
3331
+ ys as api,
3361
3332
  c as apiMethods,
3362
- Os as applyScript,
3363
- Ts as clearCalibration,
3333
+ Rs as applyScript,
3334
+ _s as clearCalibration,
3364
3335
  Lt as createPatchObject,
3365
- Ls as ensureCalibration,
3336
+ As as ensureCalibration,
3366
3337
  Jt as extractErrorMessage,
3367
3338
  B as findFirstGreaterOrEqual,
3368
3339
  j as findLastLessOrEqual,
3369
- bs as formatDate,
3370
- Ss as formatDuration,
3340
+ ms as formatDate,
3341
+ ws as formatDuration,
3371
3342
  yt as getCSRFToken,
3372
- ks as getCalibration,
3373
- _s as getLastBenchmarkDetail,
3374
- gs as getObservationsEndpoint,
3375
- As as getOperationTable,
3343
+ Es as getCalibration,
3344
+ vs as getLastBenchmarkDetail,
3345
+ ps as getObservationsEndpoint,
3346
+ ks as getOperationTable,
3376
3347
  ke as measureEllapsedTime,
3377
- vs as onCalibrationChange,
3378
- Is as parseScript,
3348
+ Ss as onCalibrationChange,
3349
+ $s as parseScript,
3379
3350
  gt as requestInterceptor,
3380
3351
  mt as responseInterceptor,
3381
- zr as runBenchmarks,
3382
- Rs as serializeHistory,
3352
+ Hr as runBenchmarks,
3353
+ Ls as serializeHistory,
3383
3354
  D as shouldUseWorker,
3384
- Es as subtractHours,
3355
+ bs as subtractHours,
3385
3356
  oe as timeUnitMultipliers
3386
3357
  };
@@ -1,15 +1,15 @@
1
1
  (function(w,M){typeof exports=="object"&&typeof module<"u"?M(exports):typeof define=="function"&&define.amd?define(["exports"],M):(w=typeof globalThis<"u"?globalThis:w||self,M(w["@uwrl/qc-utils"]={}))})(this,(function(w){"use strict";var M=(e=>(e.SECOND="s",e.MINUTE="m",e.HOUR="h",e.DAY="D",e.WEEK="W",e.MONTH="M",e.YEAR="Y",e))(M||{}),k=(e=>(e.ADD_POINTS="ADD_POINTS",e.CHANGE_VALUES="CHANGE_VALUES",e.ASSIGN_VALUES_BULK="ASSIGN_VALUES_BULK",e.DELETE_POINTS="DELETE_POINTS",e.DRIFT_CORRECTION="DRIFT_CORRECTION",e.INTERPOLATE="INTERPOLATE",e.SHIFT_DATETIMES="SHIFT_DATETIMES",e.ASSIGN_DATETIMES_BULK="ASSIGN_DATETIMES_BULK",e.FILL_GAPS="FILL_GAPS",e))(k||{}),L=(e=>(e.FIND_GAPS="FIND_GAPS",e.PERSISTENCE="PERSISTENCE",e.CHANGE="CHANGE",e.RATE_OF_CHANGE="RATE_OF_CHANGE",e.VALUE_THRESHOLD="VALUE_THRESHOLD",e.DATETIME_RANGE="DATETIME_RANGE",e.SELECTION="SELECTION",e))(L||{}),X=(e=>(e.LT="Less than",e.LTE="Less than or equal to",e.GT="Greater than",e.GTE="Greater than or equal to",e.E="Equal",e))(X||{}),Je=(e=>(e.ADD="ADD",e.SUB="SUB",e.MULT="MULT",e.DIV="DIV",e.ASSIGN="ASSIGN",e))(Je||{}),Qe=(e=>(e.LT="Less than",e.LTE="Less than or equal to",e.GT="Greater than",e.GTE="Greater than or equal to",e.E="Equal",e))(Qe||{});class Ke{id;thingId;link;frequency;path;datastreamIds;publicResource;constructor(){this.id="",this.thingId="",this.link="",this.frequency=null,this.path="HydroShare",this.datastreamIds=[],this.publicResource=!1}}class er extends Ke{resourceTitle;resourceAbstract;resourceKeywords;constructor(){super(),this.resourceTitle=void 0,this.resourceAbstract=void 0,this.resourceKeywords=void 0}}class Ze{latitude;longitude;elevation_m;elevationDatum;state;county;country;constructor(){this.elevationDatum="WGS84",this.state="",this.county="",this.country=""}}class tr{id;workspaceId;name;location=new Ze;tags;hydroShareArchive;siteType;samplingFeatureCode;isPrivate;description;samplingFeatureType;dataDisclaimer;constructor(){this.id="",this.workspaceId="",this.name="",this.tags=[],this.siteType="",this.samplingFeatureCode="",this.isPrivate=!1,this.description="",this.samplingFeatureType="Site",this.dataDisclaimer=""}}class rr{id;workspaceId;name;description;thingId;observationType;resultType;status;sampledMedium;noDataValue;aggregationStatistic;unitId;observedPropertyId;sensorId;processingLevelId;isPrivate;isVisible;phenomenonBeginTime;phenomenonEndTime;intendedTimeSpacing;intendedTimeSpacingUnit;timeAggregationInterval;timeAggregationIntervalUnit;dataSourceId;valueCount;constructor(t){this.id="",this.workspaceId="",this.name="",this.description="",this.thingId=t||"",this.observationType="OM_Measurement",this.resultType="Time Series Coverage",this.sampledMedium="",this.noDataValue=-9999,this.aggregationStatistic="",this.unitId="",this.observedPropertyId="",this.sensorId="",this.processingLevelId="",this.timeAggregationInterval=null,this.timeAggregationIntervalUnit="seconds",this.isPrivate=!0,this.isVisible=!0,this.valueCount=0}}class nr{id;workspaceId;name;symbol;definition;type;constructor(){this.id="",this.workspaceId="",this.name="",this.symbol="",this.definition="",this.type=""}}class sr{id;workspaceId;name;description;manufacturer;model;methodType;methodCode;methodLink;encodingType;modelLink;constructor(){this.id="",this.workspaceId="",this.name="",this.description="",this.manufacturer="",this.model="",this.methodType="Instrument Deployment",this.methodCode="",this.methodLink="",this.encodingType="application/json",this.modelLink=""}}class or{id;workspaceId;name;definition;description;type;code;constructor(){this.id="",this.workspaceId="",this.name="",this.definition="",this.description="",this.type="Hydrology",this.code=""}}class ar{id;workspaceId;code;definition;explanation;constructor(){this.id="",this.workspaceId="",this.code="",this.definition="",this.explanation=""}}class ir{id;workspaceId;code;description;constructor(){this.id="",this.workspaceId="",this.code="",this.description=""}}class cr{name;code;type;description;link;constructor(){}}class lr{id;email;password;firstName;middleName;lastName;phone;address;organization;type;link;accountType;hydroShareConnected;constructor(){this.id="",this.email="",this.password="",this.firstName="",this.middleName="",this.lastName="",this.phone="",this.address="",this.type="",this.link="",this.accountType="standard",this.hydroShareConnected=!1}}class ur{id;name;iconLink;signupEnabled;connectEnabled;constructor(){this.id="",this.name="",this.iconLink="",this.signupEnabled=!0,this.connectEnabled=!0}}var et=(e=>(e.Global="*",e.View="view",e.Create="create",e.Edit="edit",e.Delete="delete",e))(et||{}),tt=(e=>(e.Global="*",e.Workspace="Workspace",e.Collaborator="Collaborator",e.Thing="Thing",e.Datastream="Datastream",e.Sensor="Sensor",e.Unit="Unit",e.ObservedProperty="ObservedProperty",e.ProcessingLevel="ProcessingLevel",e.Observation="Observation",e))(tt||{});class hr{id="";key="";name="";description="";isActive=!0;expiresAt="";createdAt="";lastUsed="";workspaceId="";role=null;constructor(t){Object.assign(this,t)}}class fr{id;name;isPrivate;owner;collaboratorRole;pendingTransferTo;constructor(){this.id="",this.name="",this.isPrivate=!1,this.owner=null,this.collaboratorRole=null,this.pendingTransferTo=null}}class dr{user;role;constructor(){this.user={phone:"",address:"",link:"",type:"",name:"",email:"",organizationName:""},this.role={name:"",description:"",id:"",isApikeyRole:!1,isUserRole:!1,workspaceId:"",permissions:[]}}}function be(){const e="csrftoken=",r=decodeURIComponent(document.cookie).split(";");for(const n of r){const s=n.trim();if(s.startsWith(e))return s.substring(e.length)}return null}function Se(e){let t=e.headers?{...e.headers}:{},r;return e.body!==void 0&&(r=typeof e.body=="string"||e.body instanceof FormData?e.body:JSON.stringify(e.body)),t["X-CSRFToken"]=be()||"",{...e,headers:t,body:r,credentials:"omit"}}function rt(e){if(Array.isArray(e?.errors)&&e.errors.length&&(e=e.errors[0]),typeof e!="object"||e===null)return"An unknown error occurred.";const t=["message","detail","error"];for(const r of t)if(e[r])return e[r];return"An unknown error occurred."}async function Ee(e){if(e.headers.get("Content-Length")==="0"||e.statusText==="No Content")return null;const t=e.headers.get("content-type")||"";let r=null;if(t.includes("application/json"))try{r=await e.json()}catch(s){console.error("Failed to parse error JSON:",s)}else if(t.includes("text/csv"))try{r=await e.blob()}catch(s){console.error("Failed to parse error JSON:",s)}if(e.ok||e.status===401)return r;const n={status:e.status,message:rt(r)};throw console.error("API response not OK:",n.message),n}var ve=function(e,t){return ve=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(r[s]=n[s])},ve(e,t)};function ie(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");ve(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}function ke(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function _e(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),s,a=[],o;try{for(;(t===void 0||t-- >0)&&!(s=n.next()).done;)a.push(s.value)}catch(i){o={error:i}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return a}function Ae(e,t,r){if(r||arguments.length===2)for(var n=0,s=t.length,a;n<s;n++)(a||!(n in t))&&(a||(a=Array.prototype.slice.call(t,0,n)),a[n]=t[n]);return e.concat(a||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;function Y(e){return typeof e=="function"}function nt(e){var t=function(n){Error.call(n),n.stack=new Error().stack},r=e(t);return r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r}var Te=nt(function(e){return function(r){e(this),this.message=r?r.length+` errors occurred during unsubscription:
2
2
  `+r.map(function(n,s){return s+1+") "+n.toString()}).join(`
3
- `):"",this.name="UnsubscriptionError",this.errors=r}});function Le(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var ce=(function(){function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var t,r,n,s,a;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var i=ke(o),l=i.next();!l.done;l=i.next()){var d=l.value;d.remove(this)}}catch(h){t={error:h}}finally{try{l&&!l.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}else o.remove(this);var u=this.initialTeardown;if(Y(u))try{u()}catch(h){a=h instanceof Te?h.errors:[h]}var y=this._finalizers;if(y){this._finalizers=null;try{for(var g=ke(y),m=g.next();!m.done;m=g.next()){var S=m.value;try{at(S)}catch(h){a=a??[],h instanceof Te?a=Ae(Ae([],_e(a)),_e(h.errors)):a.push(h)}}}catch(h){n={error:h}}finally{try{m&&!m.done&&(s=g.return)&&s.call(g)}finally{if(n)throw n.error}}}if(a)throw new Te(a)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)at(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(r=this._finalizers)!==null&&r!==void 0?r:[]).push(t)}},e.prototype._hasParent=function(t){var r=this._parentage;return r===t||Array.isArray(r)&&r.includes(t)},e.prototype._addParent=function(t){var r=this._parentage;this._parentage=Array.isArray(r)?(r.push(t),r):r?[r,t]:t},e.prototype._removeParent=function(t){var r=this._parentage;r===t?this._parentage=null:Array.isArray(r)&&Le(r,t)},e.prototype.remove=function(t){var r=this._finalizers;r&&Le(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=(function(){var t=new e;return t.closed=!0,t})(),e})(),st=ce.EMPTY;function ot(e){return e instanceof ce||e&&"closed"in e&&Y(e.remove)&&Y(e.add)&&Y(e.unsubscribe)}function at(e){Y(e)?e():e.unsubscribe()}var pr={Promise:void 0},yr={setTimeout:function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setTimeout.apply(void 0,Ae([e,t],_e(r)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function gr(e){yr.setTimeout(function(){throw e})}function it(){}function le(e){e()}var ct=(function(e){ie(t,e);function t(r){var n=e.call(this)||this;return n.isStopped=!1,r?(n.destination=r,ot(r)&&r.add(n)):n.destination=br,n}return t.create=function(r,n,s){return new $e(r,n,s)},t.prototype.next=function(r){this.isStopped||this._next(r)},t.prototype.error=function(r){this.isStopped||(this.isStopped=!0,this._error(r))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(r){this.destination.next(r)},t.prototype._error=function(r){try{this.destination.error(r)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t})(ce),mr=(function(){function e(t){this.partialObserver=t}return e.prototype.next=function(t){var r=this.partialObserver;if(r.next)try{r.next(t)}catch(n){ue(n)}},e.prototype.error=function(t){var r=this.partialObserver;if(r.error)try{r.error(t)}catch(n){ue(n)}else ue(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(r){ue(r)}},e})(),$e=(function(e){ie(t,e);function t(r,n,s){var a=e.call(this)||this,o;return Y(r)||!r?o={next:r??void 0,error:n??void 0,complete:s??void 0}:o=r,a.destination=new mr(o),a}return t})(ct);function ue(e){gr(e)}function wr(e){throw e}var br={closed:!0,next:it,error:wr,complete:it},Sr=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function Er(e){return e}function vr(e){return e.length===0?Er:e.length===1?e[0]:function(r){return e.reduce(function(n,s){return s(n)},r)}}var lt=(function(){function e(t){t&&(this._subscribe=t)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(t,r,n){var s=this,a=_r(t)?t:new $e(t,r,n);return le(function(){var o=s,i=o.operator,l=o.source;a.add(i?i.call(a,l):l?s._subscribe(a):s._trySubscribe(a))}),a},e.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(r){t.error(r)}},e.prototype.forEach=function(t,r){var n=this;return r=ut(r),new r(function(s,a){var o=new $e({next:function(i){try{t(i)}catch(l){a(l),o.unsubscribe()}},error:a,complete:s});n.subscribe(o)})},e.prototype._subscribe=function(t){var r;return(r=this.source)===null||r===void 0?void 0:r.subscribe(t)},e.prototype[Sr]=function(){return this},e.prototype.pipe=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return vr(t)(this)},e.prototype.toPromise=function(t){var r=this;return t=ut(t),new t(function(n,s){var a;r.subscribe(function(o){return a=o},function(o){return s(o)},function(){return n(a)})})},e.create=function(t){return new e(t)},e})();function ut(e){var t;return(t=e??pr.Promise)!==null&&t!==void 0?t:Promise}function kr(e){return e&&Y(e.next)&&Y(e.error)&&Y(e.complete)}function _r(e){return e&&e instanceof ct||kr(e)&&ot(e)}var Ar=nt(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),ht=(function(e){ie(t,e);function t(){var r=e.call(this)||this;return r.closed=!1,r.currentObservers=null,r.observers=[],r.isStopped=!1,r.hasError=!1,r.thrownError=null,r}return t.prototype.lift=function(r){var n=new ft(this,this);return n.operator=r,n},t.prototype._throwIfClosed=function(){if(this.closed)throw new Ar},t.prototype.next=function(r){var n=this;le(function(){var s,a;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var o=ke(n.currentObservers),i=o.next();!i.done;i=o.next()){var l=i.value;l.next(r)}}catch(d){s={error:d}}finally{try{i&&!i.done&&(a=o.return)&&a.call(o)}finally{if(s)throw s.error}}}})},t.prototype.error=function(r){var n=this;le(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=r;for(var s=n.observers;s.length;)s.shift().error(r)}})},t.prototype.complete=function(){var r=this;le(function(){if(r._throwIfClosed(),!r.isStopped){r.isStopped=!0;for(var n=r.observers;n.length;)n.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var r;return((r=this.observers)===null||r===void 0?void 0:r.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(r){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,r)},t.prototype._subscribe=function(r){return this._throwIfClosed(),this._checkFinalizedStatuses(r),this._innerSubscribe(r)},t.prototype._innerSubscribe=function(r){var n=this,s=this,a=s.hasError,o=s.isStopped,i=s.observers;return a||o?st:(this.currentObservers=null,i.push(r),new ce(function(){n.currentObservers=null,Le(i,r)}))},t.prototype._checkFinalizedStatuses=function(r){var n=this,s=n.hasError,a=n.thrownError,o=n.isStopped;s?r.error(a):o&&r.complete()},t.prototype.asObservable=function(){var r=new lt;return r.source=this,r},t.create=function(r,n){return new ft(r,n)},t})(lt),ft=(function(e){ie(t,e);function t(r,n){var s=e.call(this)||this;return s.destination=r,s.source=n,s}return t.prototype.next=function(r){var n,s;(s=(n=this.destination)===null||n===void 0?void 0:n.next)===null||s===void 0||s.call(n,r)},t.prototype.error=function(r){var n,s;(s=(n=this.destination)===null||n===void 0?void 0:n.error)===null||s===void 0||s.call(n,r)},t.prototype.complete=function(){var r,n;(n=(r=this.destination)===null||r===void 0?void 0:r.complete)===null||n===void 0||n.call(r)},t.prototype._subscribe=function(r){var n,s;return(s=(n=this.source)===null||n===void 0?void 0:n.subscribe(r))!==null&&s!==void 0?s:st},t})(ht);const Re=3e3;var Ie=(e=>(e.Warning="warning",e.Success="success",e.Error="error",e.Info="info",e))(Ie||{}),Oe=(e=>(e.Success="mdi-checkbox-marked-circle",e.Warning="mdi-alert",e.Error="mdi-alert-circle",e.Info="mdi-information",e.None="none",e))(Oe||{}),Ue=(e=>(e.Warning="Warning",e.Success="Success",e.Error="Error",e.Info="Info",e))(Ue||{}),dt=(e=>(e.Center="center",e.Left="left",e.Right="right",e.Bottom="bottom",e.Top="top",e))(dt||{});class pt{constructor(t="",r="info",n="none",s="Info",a=Re,o="center",i=!1){this.message=t,this.color=r,this.icon=n,this.title=s,this.timeout=a,this.position=o,this.visible=i}}class yt{static subject=new ht;static get snack$(){return this.subject.asObservable()}static createSnackbar(t,r){this.subject.next(new pt(t,Ie[r],Oe[r],Ue[r],Re,"bottom",!0))}static success(t){this.createSnackbar(t,"Success")}static warn(t){this.createSnackbar(t,"Warning")}static error(t){this.createSnackbar(t,"Error")}static info(t){this.createSnackbar(t,"Info")}}function Me(e,t){const r={};for(let n in t)if(Array.isArray(t[n]))JSON.stringify(e[n])!==JSON.stringify(t[n])&&(r[n]=t[n]);else if(e[n]&&typeof e[n]=="object"&&t[n]&&typeof t[n]=="object"){const s=Me(e[n],t[n]);Object.keys(s).length>0&&(r[n]=s)}else JSON.stringify(e[n])!==JSON.stringify(t[n])&&(r[n]=t[n]);return r}function Tr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ce,gt;function Lr(){if(gt)return Ce;gt=1;class e{constructor(n){this.value=n,this.next=void 0}}class t{constructor(){this.clear()}enqueue(n){const s=new e(n);this._head?(this._tail.next=s,this._tail=s):(this._head=s,this._tail=s),this._size++}dequeue(){const n=this._head;if(n)return this._head=this._head.next,this._size--,n.value}clear(){this._head=void 0,this._tail=void 0,this._size=0}get size(){return this._size}*[Symbol.iterator](){let n=this._head;for(;n;)yield n.value,n=n.next}}return Ce=t,Ce}var De,mt;function $r(){if(mt)return De;mt=1;const e=Lr();return De=r=>{if(!((Number.isInteger(r)||r===1/0)&&r>0))throw new TypeError("Expected `concurrency` to be a number from 1 and up");const n=new e;let s=0;const a=()=>{s--,n.size>0&&n.dequeue()()},o=async(d,u,...y)=>{s++;const g=(async()=>d(...y))();u(g);try{await g}catch{}a()},i=(d,u,...y)=>{n.enqueue(o.bind(null,d,u,...y)),(async()=>(await Promise.resolve(),s<r&&n.size>0&&n.dequeue()()))()},l=(d,...u)=>new Promise(y=>{i(d,y,...u)});return Object.defineProperties(l,{activeCount:{get:()=>s},pendingCount:{get:()=>n.size},clearQueue:{value:()=>{n.clear()}}}),l},De}var Rr=$r();const V=Tr(Rr)(10),Ir=1e3;async function Q(e,t){const r=Se(t);try{const n=await fetch(e,r);return await Ee(n)}catch(n){throw n instanceof TypeError&&yt.error("Network error. Please check your connection."),n}}const c={async fetch(e,t={}){return t.method="GET",await V(()=>Q(e,t))},async patch(e,t,r=null,n={}){if(n.method="PATCH",n.body=r?Me(r,t):t,Object.keys(n.body).length!==0)return await V(()=>Q(e,n))},async post(e,t=void 0,r={}){return r.method="POST",r.body=t,await V(()=>Q(e,r))},async put(e,t=void 0,r={}){return r.method="PUT",r.body=t,await V(()=>Q(e,r))},async delete(e,t=void 0,r={}){return r.method="DELETE",r.body=t,await V(()=>Q(e,r))},async paginatedFetch(e,t){const r=t??Ir,n=e.includes("?")?"&":"?",s=`${e}${n}page_size=${r}&page=1`,a=Se({method:"GET"}),o=await V(()=>fetch(s,a)),i=Number(o.headers.get("x-total-pages"))||1,d=[...await Ee(o)];for(let u=2;u<=i;u++){const y=`${e}${n}page_size=${r}&page=${u}`,g=await V(()=>Q(y,{method:"GET"}));d.push(...g)}return d}},wt={HTTP:{type:"HTTP",sourceUri:"",placeholderVariables:[]},local:{type:"local",sourceUri:"",placeholderVariables:[]}},bt={JSON:{type:"JSON",timestamp:{key:"",format:"ISO8601",timezoneMode:"embeddedOffset"},JMESPath:""},CSV:{type:"CSV",timestamp:{key:"",format:"ISO8601",timezoneMode:"embeddedOffset"},headerRow:1,dataStartRow:2,delimiter:",",identifierType:"name"}},St={HydroServer:{type:"HydroServer"}};class Or{name="";settings={type:"SDL",extractor:JSON.parse(JSON.stringify(wt.local)),transformer:JSON.parse(JSON.stringify(bt.CSV)),loader:JSON.parse(JSON.stringify(St.HydroServer)),payloads:[]};id="";workspaceId="";orchestrationSystem={id:"",name:"",workspaceId:"",type:""};schedule={interval:15,intervalUnits:"minutes"};status={paused:!0};datastreams=[];constructor(t){Object.assign(this,t)}switchExtractor(t){this.settings.extractor=JSON.parse(JSON.stringify(wt[t]))}switchTransformer(t){this.settings.transformer=JSON.parse(JSON.stringify(bt[t]))}switchLoader(t){this.settings.loader=JSON.parse(JSON.stringify(St[t]))}}function Et(e){return{name:e.name,settings:e.settings,workspaceId:e.workspaceId,orchestrationSystemId:e.orchestrationSystem.id,schedule:e.schedule,status:e.status}}const F="https://lro.hydroserver.org/api",he=`${F}/auth`,B=`${he}/browser/account`,fe=`${he}/browser/session`,te=`${he}/browser/provider`,I=`${F}/data/workspaces`,Fe=`${F}/data/roles`,U=`${F}/data/datastreams`,z=`${F}/data/sensors`,T=`${F}/data/things`,Pe=`${T}/tags`,K=`${F}/data/orchestration-systems`,H=`${F}/data/data-sources`,q=`${F}/data/observed-properties`,Z=`${F}/data/processing-levels`,re=`${F}/data/result-qualifiers`,J=`${F}/data/units`,Ur=(e,t,r,n,s)=>{let a=`${U}/${e}/observations?format=column`;return a+=`&order_by=phenomenonTime&page_size=${t}`,a+=`&phenomenon_time_min=${encodeURIComponent(r)}`,n&&(a+=`&phenomenon_time_max=${encodeURIComponent(n)}`),s&&(a+=`&page=${s}`),a},Mr={fetchSession:async()=>c.fetch(`${fe}`),login:async(e,t)=>c.post(`${fe}`,{email:e,password:t}),logout:async()=>c.delete(`${fe}`),fetchUser:async()=>c.fetch(`${B}`),signup:async e=>c.post(`${B}`,e),updateUser:async(e,t)=>c.patch(`${B}`,e,t),deleteUser:async()=>c.delete(`${B}`),sendVerificationEmail:async e=>c.put(`${B}/email/verify`,{email:e}),verifyEmailWithCode:async e=>c.post(`${B}/email/verify`,{key:e}),requestPasswordReset:async e=>c.post(`${B}/password/request`,{email:e}),resetPassword:async(e,t)=>c.post(`${B}/password/reset`,{key:e,password:t}),fetchWorkspaces:async()=>c.paginatedFetch(`${I}`),fetchAssociatedWorkspaces:async()=>c.paginatedFetch(`${I}?is_associated=true`),fetchWorkspace:async e=>c.fetch(`${I}/${e}`),createWorkspace:async e=>c.post(I,e),updateWorkspace:async(e,t=null)=>c.patch(`${I}/${e.id}`,e,t),deleteWorkspace:async e=>c.delete(`${I}/${e}`),transferWorkspace:async(e,t)=>c.post(`${I}/${e}/transfer`,{newOwner:t}),acceptWorkspaceTransfer:async e=>c.put(`${I}/${e}/transfer`),rejectWorkspaceTransfer:async e=>c.delete(`${I}/${e}/transfer`),getCollaboratorRoles:async e=>c.paginatedFetch(`${Fe}?is_user_role=true`),getAPIKeyRoles:async e=>c.paginatedFetch(`${Fe}?is_apikey_role=true`),getRole:async e=>c.fetch(`${Fe}/${e}`),getCollaborators:async e=>c.paginatedFetch(`${I}/${e}/collaborators`),addCollaborator:async(e,t,r)=>c.post(`${I}/${e}/collaborators`,{email:t,roleId:r}),updateCollaboratorRole:async(e,t,r)=>c.put(`${I}/${e}/collaborators`,{email:t,roleId:r}),removeCollaborator:async(e,t)=>c.delete(`${I}/${e}/collaborators`,{email:t}),fetchApiKeys:async e=>c.paginatedFetch(`${I}/${e}/api-keys?expand_related=true`),fetchApiKey:async(e,t)=>c.fetch(`${I}/${e}/api-keys/${t}?expand_related=true`),createApiKey:async e=>c.post(`${I}/${e.workspaceId}/api-keys?expand_related=true`,{name:e.name,description:e.description,isActive:!0,roleId:e.role.id}),updateApiKey:async(e,t)=>c.patch(`${I}/${e.workspaceId}/api-keys/${e.id}?expand_related=true`,{name:e.name,description:e.description,isActive:!0,roleId:e.role.id},t&&{name:t.name,description:t.description,isActive:!0,roleId:t.role.id}),regenerateApiKey:async(e,t)=>c.put(`${I}/${e}/api-keys/${t}/regenerate?expand_related=true`),deleteApiKey:async(e,t)=>c.delete(`${I}/${e}/api-keys/${t}`),fetchConnectedProviders:async()=>c.fetch(`${te}/connections`),providerRedirect:(e,t,r)=>{const n={provider:e,callback_url:t,process:r},s=be(),a=document.createElement("form");if(a.method="POST",a.action=`${te}/redirect`,s){const o=document.createElement("input");o.type="hidden",o.name="csrfmiddlewaretoken",o.value=s,a.appendChild(o)}for(const o in n){const i=document.createElement("input");i.type="hidden",i.name=o,i.value=n[o]||"",a.appendChild(i)}document.body.appendChild(a),a.submit()},providerSignup:async e=>c.post(`${te}/signup`,e),deleteProvider:async(e,t)=>c.delete(`${te}/connections`,{provider:e,account:t}),createUnit:async e=>c.post(J,e),fetchUnits:async()=>c.paginatedFetch(`${J}`),fetchWorkspaceUnits:async e=>c.paginatedFetch(`${J}?workspace_id=${e}`),updateUnit:async(e,t=null)=>c.patch(`${J}/${e.id}`,e,t),deleteUnit:async e=>c.delete(`${J}/${e}`),getUnit:async e=>c.fetch(`${J}/${e}`),removeThingOwner:async(e,t)=>c.patch(`${T}/${e}/ownership`,{email:t,removeOwner:!0}),addSecondaryOwner:async(e,t)=>c.patch(`${T}/${e}/ownership`,{email:t,makeOwner:!0}),transferPrimaryOwnership:async(e,t)=>c.patch(`${T}/${e}/ownership`,{email:t,transferPrimary:!0}),createThing:async e=>c.post(T,e),fetchThings:async()=>c.paginatedFetch(`${T}`),fetchThingsForWorkspace:async e=>c.paginatedFetch(`${T}?workspace_id=${e}`),fetchOwnedThings:async()=>c.paginatedFetch(`${T}?owned_only=true`),fetchThing:async e=>c.fetch(`${T}/${e}`),updateThing:async e=>c.patch(`${T}/${e.id}`,e),updateThingPrivacy:async(e,t)=>c.patch(`${T}/${e}`,{isPrivate:t}),deleteThing:async e=>c.delete(`${T}/${e}`),fetchMetadataForThingOwner:async e=>c.paginatedFetch(`${T}/${e}/metadata?include_assignable_metadata=true`),fetchMetadataForThing:async e=>c.fetch(`${T}/${e}/metadata`),uploadSitePhotos:async(e,t)=>c.post(`${T}/${e}/photos`,t),fetchSitePhotos:async e=>c.paginatedFetch(`${T}/${e}/photos`),deleteSitePhoto:async(e,t)=>c.delete(`${T}/${e}/photos`,{name:t}),createSiteTag:async(e,t)=>c.post(`${T}/${e}/tags`,t),editSiteTag:async(e,t)=>c.put(`${T}/${e}/tags`,t),fetchSiteTags:async e=>c.fetch(`${T}/${e}/tags`),fetchUsersSiteTags:async()=>c.fetch(`${Pe}`),deleteSiteTag:async(e,t)=>c.delete(`${T}/${e}/tags`,t),fetchWorkspaceTags:async e=>c.fetch(`${Pe}/keys?workspace_id=${e}`),createHydroShareArchive:async e=>c.post(`${T}/${e.thingId}/archive`,e),updateHydroShareArchive:async(e,t)=>c.patch(`${T}/${e.thingId}/archive`,e,t),fetchHydroShareArchive:async e=>c.fetch(`${T}/${e}/archive`),deleteHydroShareArchive:async e=>c.delete(`${T}/${e}/archive`),archiveToHydroShare:async e=>c.post(`${T}/${e}/archive/trigger`),createDatastream:async e=>c.post(U,e),fetchDatastreams:async e=>{const t=[];if(e)for(const[n,s]of Object.entries(e))t.push(`${encodeURIComponent(n)}=${encodeURIComponent(s)}`);const r=t.length?`?${t.join("&")}`:"";return c.paginatedFetch(`${U}${r}`)},fetchDatastreamsForThing:async e=>c.paginatedFetch(`${U}?thing_id=${e}`),fetchExpandedDatastreamsForThing:async e=>c.paginatedFetch(`${U}?thing_id=${e}&expand_related=true`),fetchDatastreamsForDataSource:async e=>c.paginatedFetch(`${U}?data_source_id=${e}`),fetchDatastream:async e=>c.fetch(`${U}/${e}`),fetchDatastreamExpanded:async e=>c.fetch(`${U}/${e}?expand_related=true`),fetchUsersDatastreams:async()=>c.paginatedFetch(`${U}?exclude_unowned=true`),updateDatastream:async(e,t=null)=>c.patch(`${U}/${e.id}`,e,t),deleteDatastream:async e=>c.delete(`${U}/${e}`),downloadDatastreamCSV:async e=>c.fetch(`${U}/${e}/csv`),createObservedProperty:async e=>c.post(q,e),fetchObservedProperty:async e=>c.fetch(`${q}/${e}`),fetchObservedProperties:async()=>c.paginatedFetch(`${q}`),fetchWorkspaceObservedProperties:async e=>c.paginatedFetch(`${q}?workspace_id=${e}`),updateObservedProperty:async(e,t=null)=>c.patch(`${q}/${e.id}`,e,t),deleteObservedProperty:async e=>c.delete(`${q}/${e}`),createProcessingLevel:async e=>c.post(Z,e),fetchProcessingLevels:async()=>c.paginatedFetch(`${Z}`),fetchProcessingLevel:async e=>c.fetch(`${Z}/${e}`),fetchWorkspaceProcessingLevels:async e=>c.paginatedFetch(`${Z}?workspace_id=${e}`),updateProcessingLevel:async(e,t=null)=>c.patch(`${Z}/${e.id}`,e,t),deleteProcessingLevel:async e=>c.delete(`${Z}/${e}`),createSensor:async e=>c.post(z,e),fetchSensors:async()=>c.paginatedFetch(`${z}`),fetchSensor:async e=>c.fetch(`${z}/${e}`),fetchWorkspaceSensors:async e=>c.paginatedFetch(`${z}?workspace_id=${e}`),updateSensor:async(e,t=null)=>c.patch(`${z}/${e.id}`,e,t),deleteSensor:async e=>c.delete(`${z}/${e}`),createResultQualifier:async e=>c.post(re,e),fetchResultQualifiers:async()=>c.paginatedFetch(`${re}`),fetchWorkspaceResultQualifiers:async e=>c.paginatedFetch(`${re}?workspace_id=${e}`),updateResultQualifier:async(e,t=null)=>c.patch(`${re}/${e.id}`,e,t),deleteResultQualifier:async e=>c.delete(`${re}/${e}`),createOrchestrationSystem:async e=>c.post(K,e),fetchOrchestrationSystems:async()=>c.paginatedFetch(K),fetchWorkspaceOrchestrationSystems:async e=>c.paginatedFetch(`${K}?workspace_id=${e}`),fetchOrchestrationSystem:async e=>c.fetch(`${K}/${e}`),updateOrchestrationSystem:async(e,t)=>c.patch(`${K}/${e}`,t),deleteOrchestrationSystem:async e=>c.delete(`${K}/${e}`),createDataSource:async e=>c.post(`${H}?expand_related=true`,Et(e)),fetchDataSources:async()=>c.paginatedFetch(`${H}?expand_related=true`),fetchWorkspaceDataSources:async e=>c.paginatedFetch(`${H}?workspace_id=${e}&expand_related=true`),fetchDataSource:async e=>c.fetch(`${H}/${e}?expand_related=true`),updateDataSource:async e=>c.patch(`${H}/${e.id}?expand_related=true`,Et(e)),updateDataSourcePartial:async e=>c.patch(`${H}/${e.id}?expand_related=true`,e),deleteDataSource:async e=>c.delete(`${H}/${e}`),linkDatastreamToDataSource:async(e,t)=>c.post(`${H}/${e}/datastreams/${t}`),unlinkDatastreamFromDataSource:async(e,t)=>c.delete(`${H}/${e}/datastreams/${t}`),fetchObservations:async e=>c.fetch(e),deleteObservationsForDatastream:async e=>c.post(`${U}/${e}/observations/bulk-delete`,{phenomenonTimeStart:null,phenomenonTimeEnd:null}),fetchUserTypes:async()=>c.fetch(`${B}/user-types`),fetchOrganizationTypes:async()=>c.fetch(`${B}/organization-types`),fetchSiteTypes:async()=>c.fetch(`${T}/site-types`),fetchSamplingFeatureTypes:async()=>c.paginatedFetch(`${T}/sampling-feature-types`),fetchSensorEncodingTypes:async()=>c.paginatedFetch(`${z}/encoding-types`),fetchMethodTypes:async()=>c.paginatedFetch(`${z}/method-types`),fetchVariableTypes:async()=>c.paginatedFetch(`${q}/variable-types`),fetchUnitTypes:async()=>c.paginatedFetch(`${J}/types`),fetchDatastreamStatuses:async()=>c.paginatedFetch(`${U}/statuses`),fetchDatastreamAggregations:async()=>c.paginatedFetch(`${U}/aggregation-statistics`),fetchSampledMediums:async()=>c.paginatedFetch(`${U}/sampled-mediums`)};class Cr{name="";mappings=[];extractorVariables={};constructor(t){Object.assign(this,t)}}const vt=1,de=vt*60,Ne=de*60,Be=Ne*24,Dr=Be*7,Fr=Ne*30,Pr=Be*365,ne={[M.SECOND]:vt,[M.MINUTE]:de,[M.HOUR]:Ne,[M.DAY]:Be,[M.WEEK]:Dr,[M.MONTH]:Fr,[M.YEAR]:Pr},Nr=e=>e.toLocaleString(void 0,{year:"numeric",month:"short",day:"2-digit",hour:"2-digit",hour12:!1,minute:"2-digit",second:"2-digit"}),Br=e=>{let t,r;e>=de*1e3?(t=e/(de*1e3),r="m"):e>=1e3?(t=e/1e3,r="s"):(t=e,r="ms");let n;return r==="ms"?n=Math.round(t).toString():n=t.toFixed(2),`${n} ${r}`},pe=async(e,t)=>{t&&console.info(t);const r=performance.now(),n=await e(),a=+(performance.now()-r);return{response:n,duration:a}};function jr(e,t){const r=new Date(e);return r.setHours(r.getHours()-t),r.toISOString()}const j=(e,t)=>{let r=0,n=e.length;for(;r<n;){const s=r+n>>1;e[s]<t?r=s+1:n=s}return r},W=(e,t)=>{let r=0,n=e.length;for(;r<n;){const s=r+n>>1;e[s]>t?n=s:r=s+1}return r-1},kt=`(function(){"use strict";function c(n,s,a,u,f,l,y,o){let r=0,e=o;for(let t=l;t<=y;t++)r<a.length&&t===a[r]?r++:(u[e]=n[t],f[e]=s[t],e++);return e-o}self.onmessage=n=>{const{bufferX:s,bufferY:a,outputBufferX:u,outputBufferY:f,start:l,end:y,deleteSegment:o,startTarget:r}=n.data,e=new Float64Array(s),t=new Float32Array(a),A=new Float64Array(u),g=new Float32Array(f);c(e,t,o,A,g,l,y,r),self.postMessage("Done")}})();
3
+ `):"",this.name="UnsubscriptionError",this.errors=r}});function Le(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var ce=(function(){function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var t,r,n,s,a;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var i=ke(o),l=i.next();!l.done;l=i.next()){var d=l.value;d.remove(this)}}catch(h){t={error:h}}finally{try{l&&!l.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}else o.remove(this);var u=this.initialTeardown;if(Y(u))try{u()}catch(h){a=h instanceof Te?h.errors:[h]}var y=this._finalizers;if(y){this._finalizers=null;try{for(var g=ke(y),m=g.next();!m.done;m=g.next()){var S=m.value;try{at(S)}catch(h){a=a??[],h instanceof Te?a=Ae(Ae([],_e(a)),_e(h.errors)):a.push(h)}}}catch(h){n={error:h}}finally{try{m&&!m.done&&(s=g.return)&&s.call(g)}finally{if(n)throw n.error}}}if(a)throw new Te(a)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)at(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(r=this._finalizers)!==null&&r!==void 0?r:[]).push(t)}},e.prototype._hasParent=function(t){var r=this._parentage;return r===t||Array.isArray(r)&&r.includes(t)},e.prototype._addParent=function(t){var r=this._parentage;this._parentage=Array.isArray(r)?(r.push(t),r):r?[r,t]:t},e.prototype._removeParent=function(t){var r=this._parentage;r===t?this._parentage=null:Array.isArray(r)&&Le(r,t)},e.prototype.remove=function(t){var r=this._finalizers;r&&Le(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=(function(){var t=new e;return t.closed=!0,t})(),e})(),st=ce.EMPTY;function ot(e){return e instanceof ce||e&&"closed"in e&&Y(e.remove)&&Y(e.add)&&Y(e.unsubscribe)}function at(e){Y(e)?e():e.unsubscribe()}var pr={Promise:void 0},yr={setTimeout:function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setTimeout.apply(void 0,Ae([e,t],_e(r)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function gr(e){yr.setTimeout(function(){throw e})}function it(){}function le(e){e()}var ct=(function(e){ie(t,e);function t(r){var n=e.call(this)||this;return n.isStopped=!1,r?(n.destination=r,ot(r)&&r.add(n)):n.destination=br,n}return t.create=function(r,n,s){return new $e(r,n,s)},t.prototype.next=function(r){this.isStopped||this._next(r)},t.prototype.error=function(r){this.isStopped||(this.isStopped=!0,this._error(r))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(r){this.destination.next(r)},t.prototype._error=function(r){try{this.destination.error(r)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t})(ce),mr=(function(){function e(t){this.partialObserver=t}return e.prototype.next=function(t){var r=this.partialObserver;if(r.next)try{r.next(t)}catch(n){ue(n)}},e.prototype.error=function(t){var r=this.partialObserver;if(r.error)try{r.error(t)}catch(n){ue(n)}else ue(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(r){ue(r)}},e})(),$e=(function(e){ie(t,e);function t(r,n,s){var a=e.call(this)||this,o;return Y(r)||!r?o={next:r??void 0,error:n??void 0,complete:s??void 0}:o=r,a.destination=new mr(o),a}return t})(ct);function ue(e){gr(e)}function wr(e){throw e}var br={closed:!0,next:it,error:wr,complete:it},Sr=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function Er(e){return e}function vr(e){return e.length===0?Er:e.length===1?e[0]:function(r){return e.reduce(function(n,s){return s(n)},r)}}var lt=(function(){function e(t){t&&(this._subscribe=t)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(t,r,n){var s=this,a=_r(t)?t:new $e(t,r,n);return le(function(){var o=s,i=o.operator,l=o.source;a.add(i?i.call(a,l):l?s._subscribe(a):s._trySubscribe(a))}),a},e.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(r){t.error(r)}},e.prototype.forEach=function(t,r){var n=this;return r=ut(r),new r(function(s,a){var o=new $e({next:function(i){try{t(i)}catch(l){a(l),o.unsubscribe()}},error:a,complete:s});n.subscribe(o)})},e.prototype._subscribe=function(t){var r;return(r=this.source)===null||r===void 0?void 0:r.subscribe(t)},e.prototype[Sr]=function(){return this},e.prototype.pipe=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return vr(t)(this)},e.prototype.toPromise=function(t){var r=this;return t=ut(t),new t(function(n,s){var a;r.subscribe(function(o){return a=o},function(o){return s(o)},function(){return n(a)})})},e.create=function(t){return new e(t)},e})();function ut(e){var t;return(t=e??pr.Promise)!==null&&t!==void 0?t:Promise}function kr(e){return e&&Y(e.next)&&Y(e.error)&&Y(e.complete)}function _r(e){return e&&e instanceof ct||kr(e)&&ot(e)}var Ar=nt(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),ht=(function(e){ie(t,e);function t(){var r=e.call(this)||this;return r.closed=!1,r.currentObservers=null,r.observers=[],r.isStopped=!1,r.hasError=!1,r.thrownError=null,r}return t.prototype.lift=function(r){var n=new ft(this,this);return n.operator=r,n},t.prototype._throwIfClosed=function(){if(this.closed)throw new Ar},t.prototype.next=function(r){var n=this;le(function(){var s,a;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var o=ke(n.currentObservers),i=o.next();!i.done;i=o.next()){var l=i.value;l.next(r)}}catch(d){s={error:d}}finally{try{i&&!i.done&&(a=o.return)&&a.call(o)}finally{if(s)throw s.error}}}})},t.prototype.error=function(r){var n=this;le(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=r;for(var s=n.observers;s.length;)s.shift().error(r)}})},t.prototype.complete=function(){var r=this;le(function(){if(r._throwIfClosed(),!r.isStopped){r.isStopped=!0;for(var n=r.observers;n.length;)n.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var r;return((r=this.observers)===null||r===void 0?void 0:r.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(r){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,r)},t.prototype._subscribe=function(r){return this._throwIfClosed(),this._checkFinalizedStatuses(r),this._innerSubscribe(r)},t.prototype._innerSubscribe=function(r){var n=this,s=this,a=s.hasError,o=s.isStopped,i=s.observers;return a||o?st:(this.currentObservers=null,i.push(r),new ce(function(){n.currentObservers=null,Le(i,r)}))},t.prototype._checkFinalizedStatuses=function(r){var n=this,s=n.hasError,a=n.thrownError,o=n.isStopped;s?r.error(a):o&&r.complete()},t.prototype.asObservable=function(){var r=new lt;return r.source=this,r},t.create=function(r,n){return new ft(r,n)},t})(lt),ft=(function(e){ie(t,e);function t(r,n){var s=e.call(this)||this;return s.destination=r,s.source=n,s}return t.prototype.next=function(r){var n,s;(s=(n=this.destination)===null||n===void 0?void 0:n.next)===null||s===void 0||s.call(n,r)},t.prototype.error=function(r){var n,s;(s=(n=this.destination)===null||n===void 0?void 0:n.error)===null||s===void 0||s.call(n,r)},t.prototype.complete=function(){var r,n;(n=(r=this.destination)===null||r===void 0?void 0:r.complete)===null||n===void 0||n.call(r)},t.prototype._subscribe=function(r){var n,s;return(s=(n=this.source)===null||n===void 0?void 0:n.subscribe(r))!==null&&s!==void 0?s:st},t})(ht);const Re=3e3;var Ie=(e=>(e.Warning="warning",e.Success="success",e.Error="error",e.Info="info",e))(Ie||{}),Oe=(e=>(e.Success="mdi-checkbox-marked-circle",e.Warning="mdi-alert",e.Error="mdi-alert-circle",e.Info="mdi-information",e.None="none",e))(Oe||{}),Ue=(e=>(e.Warning="Warning",e.Success="Success",e.Error="Error",e.Info="Info",e))(Ue||{}),dt=(e=>(e.Center="center",e.Left="left",e.Right="right",e.Bottom="bottom",e.Top="top",e))(dt||{});class pt{constructor(t="",r="info",n="none",s="Info",a=Re,o="center",i=!1){this.message=t,this.color=r,this.icon=n,this.title=s,this.timeout=a,this.position=o,this.visible=i}}class yt{static subject=new ht;static get snack$(){return this.subject.asObservable()}static createSnackbar(t,r){this.subject.next(new pt(t,Ie[r],Oe[r],Ue[r],Re,"bottom",!0))}static success(t){this.createSnackbar(t,"Success")}static warn(t){this.createSnackbar(t,"Warning")}static error(t){this.createSnackbar(t,"Error")}static info(t){this.createSnackbar(t,"Info")}}function Me(e,t){const r={};for(let n in t)if(Array.isArray(t[n]))JSON.stringify(e[n])!==JSON.stringify(t[n])&&(r[n]=t[n]);else if(e[n]&&typeof e[n]=="object"&&t[n]&&typeof t[n]=="object"){const s=Me(e[n],t[n]);Object.keys(s).length>0&&(r[n]=s)}else JSON.stringify(e[n])!==JSON.stringify(t[n])&&(r[n]=t[n]);return r}function Tr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ce,gt;function Lr(){if(gt)return Ce;gt=1;class e{constructor(n){this.value=n,this.next=void 0}}class t{constructor(){this.clear()}enqueue(n){const s=new e(n);this._head?(this._tail.next=s,this._tail=s):(this._head=s,this._tail=s),this._size++}dequeue(){const n=this._head;if(n)return this._head=this._head.next,this._size--,n.value}clear(){this._head=void 0,this._tail=void 0,this._size=0}get size(){return this._size}*[Symbol.iterator](){let n=this._head;for(;n;)yield n.value,n=n.next}}return Ce=t,Ce}var Fe,mt;function $r(){if(mt)return Fe;mt=1;const e=Lr();return Fe=r=>{if(!((Number.isInteger(r)||r===1/0)&&r>0))throw new TypeError("Expected `concurrency` to be a number from 1 and up");const n=new e;let s=0;const a=()=>{s--,n.size>0&&n.dequeue()()},o=async(d,u,...y)=>{s++;const g=(async()=>d(...y))();u(g);try{await g}catch{}a()},i=(d,u,...y)=>{n.enqueue(o.bind(null,d,u,...y)),(async()=>(await Promise.resolve(),s<r&&n.size>0&&n.dequeue()()))()},l=(d,...u)=>new Promise(y=>{i(d,y,...u)});return Object.defineProperties(l,{activeCount:{get:()=>s},pendingCount:{get:()=>n.size},clearQueue:{value:()=>{n.clear()}}}),l},Fe}var Rr=$r();const V=Tr(Rr)(10),Ir=1e3;async function Q(e,t){const r=Se(t);try{const n=await fetch(e,r);return await Ee(n)}catch(n){throw n instanceof TypeError&&yt.error("Network error. Please check your connection."),n}}const c={async fetch(e,t={}){return t.method="GET",await V(()=>Q(e,t))},async patch(e,t,r=null,n={}){if(n.method="PATCH",n.body=r?Me(r,t):t,Object.keys(n.body).length!==0)return await V(()=>Q(e,n))},async post(e,t=void 0,r={}){return r.method="POST",r.body=t,await V(()=>Q(e,r))},async put(e,t=void 0,r={}){return r.method="PUT",r.body=t,await V(()=>Q(e,r))},async delete(e,t=void 0,r={}){return r.method="DELETE",r.body=t,await V(()=>Q(e,r))},async paginatedFetch(e,t){const r=t??Ir,n=e.includes("?")?"&":"?",s=`${e}${n}page_size=${r}&page=1`,a=Se({method:"GET"}),o=await V(()=>fetch(s,a)),i=Number(o.headers.get("x-total-pages"))||1,d=[...await Ee(o)];for(let u=2;u<=i;u++){const y=`${e}${n}page_size=${r}&page=${u}`,g=await V(()=>Q(y,{method:"GET"}));d.push(...g)}return d}},wt={HTTP:{type:"HTTP",sourceUri:"",placeholderVariables:[]},local:{type:"local",sourceUri:"",placeholderVariables:[]}},bt={JSON:{type:"JSON",timestamp:{key:"",format:"ISO8601",timezoneMode:"embeddedOffset"},JMESPath:""},CSV:{type:"CSV",timestamp:{key:"",format:"ISO8601",timezoneMode:"embeddedOffset"},headerRow:1,dataStartRow:2,delimiter:",",identifierType:"name"}},St={HydroServer:{type:"HydroServer"}};class Or{name="";settings={type:"SDL",extractor:JSON.parse(JSON.stringify(wt.local)),transformer:JSON.parse(JSON.stringify(bt.CSV)),loader:JSON.parse(JSON.stringify(St.HydroServer)),payloads:[]};id="";workspaceId="";orchestrationSystem={id:"",name:"",workspaceId:"",type:""};schedule={interval:15,intervalUnits:"minutes"};status={paused:!0};datastreams=[];constructor(t){Object.assign(this,t)}switchExtractor(t){this.settings.extractor=JSON.parse(JSON.stringify(wt[t]))}switchTransformer(t){this.settings.transformer=JSON.parse(JSON.stringify(bt[t]))}switchLoader(t){this.settings.loader=JSON.parse(JSON.stringify(St[t]))}}function Et(e){return{name:e.name,settings:e.settings,workspaceId:e.workspaceId,orchestrationSystemId:e.orchestrationSystem.id,schedule:e.schedule,status:e.status}}const D="https://lro.hydroserver.org/api",he=`${D}/auth`,B=`${he}/browser/account`,fe=`${he}/browser/session`,te=`${he}/browser/provider`,I=`${D}/data/workspaces`,De=`${D}/data/roles`,U=`${D}/data/datastreams`,z=`${D}/data/sensors`,T=`${D}/data/things`,Pe=`${T}/tags`,K=`${D}/data/orchestration-systems`,H=`${D}/data/data-sources`,q=`${D}/data/observed-properties`,Z=`${D}/data/processing-levels`,re=`${D}/data/result-qualifiers`,J=`${D}/data/units`,Ur=(e,t,r,n,s)=>{let a=`${U}/${e}/observations?format=column`;return a+=`&order_by=phenomenonTime&page_size=${t}`,a+=`&phenomenon_time_min=${encodeURIComponent(r)}`,n&&(a+=`&phenomenon_time_max=${encodeURIComponent(n)}`),s&&(a+=`&page=${s}`),a},Mr={fetchSession:async()=>c.fetch(`${fe}`),login:async(e,t)=>c.post(`${fe}`,{email:e,password:t}),logout:async()=>c.delete(`${fe}`),fetchUser:async()=>c.fetch(`${B}`),signup:async e=>c.post(`${B}`,e),updateUser:async(e,t)=>c.patch(`${B}`,e,t),deleteUser:async()=>c.delete(`${B}`),sendVerificationEmail:async e=>c.put(`${B}/email/verify`,{email:e}),verifyEmailWithCode:async e=>c.post(`${B}/email/verify`,{key:e}),requestPasswordReset:async e=>c.post(`${B}/password/request`,{email:e}),resetPassword:async(e,t)=>c.post(`${B}/password/reset`,{key:e,password:t}),fetchWorkspaces:async()=>c.paginatedFetch(`${I}`),fetchAssociatedWorkspaces:async()=>c.paginatedFetch(`${I}?is_associated=true`),fetchWorkspace:async e=>c.fetch(`${I}/${e}`),createWorkspace:async e=>c.post(I,e),updateWorkspace:async(e,t=null)=>c.patch(`${I}/${e.id}`,e,t),deleteWorkspace:async e=>c.delete(`${I}/${e}`),transferWorkspace:async(e,t)=>c.post(`${I}/${e}/transfer`,{newOwner:t}),acceptWorkspaceTransfer:async e=>c.put(`${I}/${e}/transfer`),rejectWorkspaceTransfer:async e=>c.delete(`${I}/${e}/transfer`),getCollaboratorRoles:async e=>c.paginatedFetch(`${De}?is_user_role=true`),getAPIKeyRoles:async e=>c.paginatedFetch(`${De}?is_apikey_role=true`),getRole:async e=>c.fetch(`${De}/${e}`),getCollaborators:async e=>c.paginatedFetch(`${I}/${e}/collaborators`),addCollaborator:async(e,t,r)=>c.post(`${I}/${e}/collaborators`,{email:t,roleId:r}),updateCollaboratorRole:async(e,t,r)=>c.put(`${I}/${e}/collaborators`,{email:t,roleId:r}),removeCollaborator:async(e,t)=>c.delete(`${I}/${e}/collaborators`,{email:t}),fetchApiKeys:async e=>c.paginatedFetch(`${I}/${e}/api-keys?expand_related=true`),fetchApiKey:async(e,t)=>c.fetch(`${I}/${e}/api-keys/${t}?expand_related=true`),createApiKey:async e=>c.post(`${I}/${e.workspaceId}/api-keys?expand_related=true`,{name:e.name,description:e.description,isActive:!0,roleId:e.role.id}),updateApiKey:async(e,t)=>c.patch(`${I}/${e.workspaceId}/api-keys/${e.id}?expand_related=true`,{name:e.name,description:e.description,isActive:!0,roleId:e.role.id},t&&{name:t.name,description:t.description,isActive:!0,roleId:t.role.id}),regenerateApiKey:async(e,t)=>c.put(`${I}/${e}/api-keys/${t}/regenerate?expand_related=true`),deleteApiKey:async(e,t)=>c.delete(`${I}/${e}/api-keys/${t}`),fetchConnectedProviders:async()=>c.fetch(`${te}/connections`),providerRedirect:(e,t,r)=>{const n={provider:e,callback_url:t,process:r},s=be(),a=document.createElement("form");if(a.method="POST",a.action=`${te}/redirect`,s){const o=document.createElement("input");o.type="hidden",o.name="csrfmiddlewaretoken",o.value=s,a.appendChild(o)}for(const o in n){const i=document.createElement("input");i.type="hidden",i.name=o,i.value=n[o]||"",a.appendChild(i)}document.body.appendChild(a),a.submit()},providerSignup:async e=>c.post(`${te}/signup`,e),deleteProvider:async(e,t)=>c.delete(`${te}/connections`,{provider:e,account:t}),createUnit:async e=>c.post(J,e),fetchUnits:async()=>c.paginatedFetch(`${J}`),fetchWorkspaceUnits:async e=>c.paginatedFetch(`${J}?workspace_id=${e}`),updateUnit:async(e,t=null)=>c.patch(`${J}/${e.id}`,e,t),deleteUnit:async e=>c.delete(`${J}/${e}`),getUnit:async e=>c.fetch(`${J}/${e}`),removeThingOwner:async(e,t)=>c.patch(`${T}/${e}/ownership`,{email:t,removeOwner:!0}),addSecondaryOwner:async(e,t)=>c.patch(`${T}/${e}/ownership`,{email:t,makeOwner:!0}),transferPrimaryOwnership:async(e,t)=>c.patch(`${T}/${e}/ownership`,{email:t,transferPrimary:!0}),createThing:async e=>c.post(T,e),fetchThings:async()=>c.paginatedFetch(`${T}`),fetchThingsForWorkspace:async e=>c.paginatedFetch(`${T}?workspace_id=${e}`),fetchOwnedThings:async()=>c.paginatedFetch(`${T}?owned_only=true`),fetchThing:async e=>c.fetch(`${T}/${e}`),updateThing:async e=>c.patch(`${T}/${e.id}`,e),updateThingPrivacy:async(e,t)=>c.patch(`${T}/${e}`,{isPrivate:t}),deleteThing:async e=>c.delete(`${T}/${e}`),fetchMetadataForThingOwner:async e=>c.paginatedFetch(`${T}/${e}/metadata?include_assignable_metadata=true`),fetchMetadataForThing:async e=>c.fetch(`${T}/${e}/metadata`),uploadSitePhotos:async(e,t)=>c.post(`${T}/${e}/photos`,t),fetchSitePhotos:async e=>c.paginatedFetch(`${T}/${e}/photos`),deleteSitePhoto:async(e,t)=>c.delete(`${T}/${e}/photos`,{name:t}),createSiteTag:async(e,t)=>c.post(`${T}/${e}/tags`,t),editSiteTag:async(e,t)=>c.put(`${T}/${e}/tags`,t),fetchSiteTags:async e=>c.fetch(`${T}/${e}/tags`),fetchUsersSiteTags:async()=>c.fetch(`${Pe}`),deleteSiteTag:async(e,t)=>c.delete(`${T}/${e}/tags`,t),fetchWorkspaceTags:async e=>c.fetch(`${Pe}/keys?workspace_id=${e}`),createHydroShareArchive:async e=>c.post(`${T}/${e.thingId}/archive`,e),updateHydroShareArchive:async(e,t)=>c.patch(`${T}/${e.thingId}/archive`,e,t),fetchHydroShareArchive:async e=>c.fetch(`${T}/${e}/archive`),deleteHydroShareArchive:async e=>c.delete(`${T}/${e}/archive`),archiveToHydroShare:async e=>c.post(`${T}/${e}/archive/trigger`),createDatastream:async e=>c.post(U,e),fetchDatastreams:async e=>{const t=[];if(e)for(const[n,s]of Object.entries(e))t.push(`${encodeURIComponent(n)}=${encodeURIComponent(s)}`);const r=t.length?`?${t.join("&")}`:"";return c.paginatedFetch(`${U}${r}`)},fetchDatastreamsForThing:async e=>c.paginatedFetch(`${U}?thing_id=${e}`),fetchExpandedDatastreamsForThing:async e=>c.paginatedFetch(`${U}?thing_id=${e}&expand_related=true`),fetchDatastreamsForDataSource:async e=>c.paginatedFetch(`${U}?data_source_id=${e}`),fetchDatastream:async e=>c.fetch(`${U}/${e}`),fetchDatastreamExpanded:async e=>c.fetch(`${U}/${e}?expand_related=true`),fetchUsersDatastreams:async()=>c.paginatedFetch(`${U}?exclude_unowned=true`),updateDatastream:async(e,t=null)=>c.patch(`${U}/${e.id}`,e,t),deleteDatastream:async e=>c.delete(`${U}/${e}`),downloadDatastreamCSV:async e=>c.fetch(`${U}/${e}/csv`),createObservedProperty:async e=>c.post(q,e),fetchObservedProperty:async e=>c.fetch(`${q}/${e}`),fetchObservedProperties:async()=>c.paginatedFetch(`${q}`),fetchWorkspaceObservedProperties:async e=>c.paginatedFetch(`${q}?workspace_id=${e}`),updateObservedProperty:async(e,t=null)=>c.patch(`${q}/${e.id}`,e,t),deleteObservedProperty:async e=>c.delete(`${q}/${e}`),createProcessingLevel:async e=>c.post(Z,e),fetchProcessingLevels:async()=>c.paginatedFetch(`${Z}`),fetchProcessingLevel:async e=>c.fetch(`${Z}/${e}`),fetchWorkspaceProcessingLevels:async e=>c.paginatedFetch(`${Z}?workspace_id=${e}`),updateProcessingLevel:async(e,t=null)=>c.patch(`${Z}/${e.id}`,e,t),deleteProcessingLevel:async e=>c.delete(`${Z}/${e}`),createSensor:async e=>c.post(z,e),fetchSensors:async()=>c.paginatedFetch(`${z}`),fetchSensor:async e=>c.fetch(`${z}/${e}`),fetchWorkspaceSensors:async e=>c.paginatedFetch(`${z}?workspace_id=${e}`),updateSensor:async(e,t=null)=>c.patch(`${z}/${e.id}`,e,t),deleteSensor:async e=>c.delete(`${z}/${e}`),createResultQualifier:async e=>c.post(re,e),fetchResultQualifiers:async()=>c.paginatedFetch(`${re}`),fetchWorkspaceResultQualifiers:async e=>c.paginatedFetch(`${re}?workspace_id=${e}`),updateResultQualifier:async(e,t=null)=>c.patch(`${re}/${e.id}`,e,t),deleteResultQualifier:async e=>c.delete(`${re}/${e}`),createOrchestrationSystem:async e=>c.post(K,e),fetchOrchestrationSystems:async()=>c.paginatedFetch(K),fetchWorkspaceOrchestrationSystems:async e=>c.paginatedFetch(`${K}?workspace_id=${e}`),fetchOrchestrationSystem:async e=>c.fetch(`${K}/${e}`),updateOrchestrationSystem:async(e,t)=>c.patch(`${K}/${e}`,t),deleteOrchestrationSystem:async e=>c.delete(`${K}/${e}`),createDataSource:async e=>c.post(`${H}?expand_related=true`,Et(e)),fetchDataSources:async()=>c.paginatedFetch(`${H}?expand_related=true`),fetchWorkspaceDataSources:async e=>c.paginatedFetch(`${H}?workspace_id=${e}&expand_related=true`),fetchDataSource:async e=>c.fetch(`${H}/${e}?expand_related=true`),updateDataSource:async e=>c.patch(`${H}/${e.id}?expand_related=true`,Et(e)),updateDataSourcePartial:async e=>c.patch(`${H}/${e.id}?expand_related=true`,e),deleteDataSource:async e=>c.delete(`${H}/${e}`),linkDatastreamToDataSource:async(e,t)=>c.post(`${H}/${e}/datastreams/${t}`),unlinkDatastreamFromDataSource:async(e,t)=>c.delete(`${H}/${e}/datastreams/${t}`),fetchObservations:async e=>c.fetch(e),deleteObservationsForDatastream:async e=>c.post(`${U}/${e}/observations/bulk-delete`,{phenomenonTimeStart:null,phenomenonTimeEnd:null}),fetchUserTypes:async()=>c.fetch(`${B}/user-types`),fetchOrganizationTypes:async()=>c.fetch(`${B}/organization-types`),fetchSiteTypes:async()=>c.fetch(`${T}/site-types`),fetchSamplingFeatureTypes:async()=>c.paginatedFetch(`${T}/sampling-feature-types`),fetchSensorEncodingTypes:async()=>c.paginatedFetch(`${z}/encoding-types`),fetchMethodTypes:async()=>c.paginatedFetch(`${z}/method-types`),fetchVariableTypes:async()=>c.paginatedFetch(`${q}/variable-types`),fetchUnitTypes:async()=>c.paginatedFetch(`${J}/types`),fetchDatastreamStatuses:async()=>c.paginatedFetch(`${U}/statuses`),fetchDatastreamAggregations:async()=>c.paginatedFetch(`${U}/aggregation-statistics`),fetchSampledMediums:async()=>c.paginatedFetch(`${U}/sampled-mediums`)};class Cr{name="";mappings=[];extractorVariables={};constructor(t){Object.assign(this,t)}}const vt=1,de=vt*60,Ne=de*60,Be=Ne*24,Fr=Be*7,Dr=Ne*30,Pr=Be*365,ne={[M.SECOND]:vt,[M.MINUTE]:de,[M.HOUR]:Ne,[M.DAY]:Be,[M.WEEK]:Fr,[M.MONTH]:Dr,[M.YEAR]:Pr},Nr=e=>e.toLocaleString(void 0,{year:"numeric",month:"short",day:"2-digit",hour:"2-digit",hour12:!1,minute:"2-digit",second:"2-digit"}),Br=e=>{let t,r;e>=de*1e3?(t=e/(de*1e3),r="m"):e>=1e3?(t=e/1e3,r="s"):(t=e,r="ms");let n;return r==="ms"?n=Math.round(t).toString():n=t.toFixed(2),`${n} ${r}`},pe=async(e,t)=>{t&&console.info(t);const r=performance.now(),n=await e(),a=+(performance.now()-r);return{response:n,duration:a}};function jr(e,t){const r=new Date(e);return r.setHours(r.getHours()-t),r.toISOString()}const j=(e,t)=>{let r=0,n=e.length;for(;r<n;){const s=r+n>>1;e[s]<t?r=s+1:n=s}return r},W=(e,t)=>{let r=0,n=e.length;for(;r<n;){const s=r+n>>1;e[s]>t?n=s:r=s+1}return r-1},kt=`(function(){"use strict";function c(n,s,a,u,f,l,y,o){let r=0,e=o;for(let t=l;t<=y;t++)r<a.length&&t===a[r]?r++:(u[e]=n[t],f[e]=s[t],e++);return e-o}self.onmessage=n=>{const{bufferX:s,bufferY:a,outputBufferX:u,outputBufferY:f,start:l,end:y,deleteSegment:o,startTarget:r}=n.data,e=new Float64Array(s),t=new Float32Array(a),A=new Float64Array(u),g=new Float32Array(f);c(e,t,o,A,g,l,y,r),self.postMessage("Done")}})();
4
4
  `,_t=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",kt],{type:"text/javascript;charset=utf-8"});function Wr(e){let t;try{if(t=_t&&(self.URL||self.webkitURL).createObjectURL(_t),!t)throw"";const r=new Worker(t,{name:e?.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(kt),{name:e?.name})}}const At=`(function(){"use strict";function F(n,l,a,o,s,y,g,f,i,w,A){let e=0,t=f;for(let r=y;r<=g;r++)if(o[t]=n[r],s[t]=l[r],t++,e<a.length&&r===a[e][0]){const u=a[e][0],c=a[e][1],d=n[u],h=n[c],m=l[u],D=l[c],x=h-d,P=D-m;let p=d+i;for(;p<h;)o[t]=p,s[t]=w?m+(p-d)*P/x:A,t++,p+=i;e++}return t-f}self.onmessage=n=>{const{bufferX:l,bufferY:a,outputBufferX:o,outputBufferY:s,start:y,end:g,gapsSegment:f,startTarget:i,fillDelta:w,interpolate:A,fillValue:e}=n.data,t=new Float64Array(l),r=new Float32Array(a),u=new Float64Array(o),c=new Float32Array(s);F(t,r,f,u,c,y,g,i,w,A,e),self.postMessage("Done")}})();
5
5
  `,Tt=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",At],{type:"text/javascript;charset=utf-8"});function xr(e){let t;try{if(t=Tt&&(self.URL||self.webkitURL).createObjectURL(Tt),!t)throw"";const r=new Worker(t,{name:e?.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(At),{name:e?.name})}}const Lt=`(function(){"use strict";function g(o,n,c){for(let s=0;s<c.length;s++){const{indexes:t,lowerIdx:l,upperIdx:r}=c[s],i=o[l],f=n[l],a=o[r],d=n[r],p=a-i,w=d-f;if(p===0){for(let e=0;e<t.length;e++)n[t[e]]=f;continue}for(let e=0;e<t.length;e++){const u=t[e];n[u]=f+(o[u]-i)*w/p}}}self.onmessage=o=>{const{bufferX:n,bufferY:c,groups:s}=o.data,t=new Float64Array(n),l=new Float32Array(c);g(t,l,s),self.postMessage("Done")}})();
6
6
  `,$t=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Lt],{type:"text/javascript;charset=utf-8"});function Gr(e){let t;try{if(t=$t&&(self.URL||self.webkitURL).createObjectURL($t),!t)throw"";const r=new Worker(t,{name:e?.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Lt),{name:e?.name})}}const Rt=`(function(){"use strict";self.onmessage=r=>{const{bufferX:s,bufferY:o,jobs:a}=r.data,f=new Float64Array(s),n=new Float32Array(o);for(let e=0;e<a.length;e++){const{chunkStart:c,chunkEnd:l,startDatetime:u,value:i,extent:y}=a[e];for(let t=c;t<l;t++)n[t]=n[t]+i*((f[t]-u)/y)}self.postMessage("Done")}})();
7
7
  `,It=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Rt],{type:"text/javascript;charset=utf-8"});function Yr(e){let t;try{if(t=It&&(self.URL||self.webkitURL).createObjectURL(It),!t)throw"";const r=new Worker(t,{name:e?.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Rt),{name:e?.name})}}const Ot=`(function(){"use strict";function u(f,o,a,n,l,c,s,i){let r=c,e=0,t=i;const w=a.length;for(;r<s&&e<w;){const y=a[e][0];f[r]<=y?(n[t]=f[r],l[t]=o[r],r++):(n[t]=y,l[t]=a[e][1],e++),t++}for(;r<s;)n[t]=f[r],l[t]=o[r],r++,t++;for(;e<w;)n[t]=a[e][0],l[t]=a[e][1],e++,t++;return t-i}self.onmessage=f=>{const{bufferX:o,bufferY:a,outputBufferX:n,outputBufferY:l,origStart:c,origEnd:s,insertions:i,outStart:r}=f.data,e=new Float64Array(o),t=new Float32Array(a),w=new Float64Array(n),y=new Float32Array(l);u(e,t,i,w,y,c,s,r),self.postMessage("Done")}})();
8
8
  `,Ut=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Ot],{type:"text/javascript;charset=utf-8"});function Hr(e){let t;try{if(t=Ut&&(self.URL||self.webkitURL).createObjectURL(Ut),!t)throw"";const r=new Worker(t,{name:e?.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Ot),{name:e?.name})}}const Mt=`(function(){"use strict";self.onmessage=i=>{const{bufferX:c,bufferY:g,outputBufferX:d,outputBufferY:y,indexes:n,outStart:r,amount:f,isMonth:Y,isYear:h,deltaMs:w}=i.data,s=new Float64Array(c),a=new Float32Array(g),l=new Float64Array(d),u=new Float32Array(y);if(Y)for(let t=0;t<n.length;t++){const e=n[t],o=new Date(s[e]);o.setMonth(o.getMonth()+f),l[r+t]=o.getTime(),u[r+t]=a[e]}else if(h)for(let t=0;t<n.length;t++){const e=n[t],o=new Date(s[e]);o.setFullYear(o.getFullYear()+f),l[r+t]=o.getTime(),u[r+t]=a[e]}else for(let t=0;t<n.length;t++){const e=n[t];l[r+t]=s[e]+w,u[r+t]=a[e]}self.postMessage("Done")}})();
9
- `,Ct=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Mt],{type:"text/javascript;charset=utf-8"});function zr(e){let t;try{if(t=Ct&&(self.URL||self.webkitURL).createObjectURL(Ct),!t)throw"";const r=new Worker(t,{name:e?.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Mt),{name:e?.name})}}const Dt=`(function(){"use strict";function a(e,t,o,c){const n=[];let r=e[t];for(let s=t+1;s<=o;s++){const f=e[s];f-r>c&&n.push(s-1,s),r=f}return n}self.onmessage=e=>{const{bufferX:t,start:o,endInclusive:c,threshold:n}=e.data,r=new Float64Array(t);self.postMessage(a(r,o,c,n))}})();
10
- `,Ft=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Dt],{type:"text/javascript;charset=utf-8"});function Xr(e){let t;try{if(t=Ft&&(self.URL||self.webkitURL).createObjectURL(Ft),!t)throw"";const r=new Worker(t,{name:e?.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Dt),{name:e?.name})}}const Pt=`(function(){"use strict";function c(u,s,t){const n=[];if(s>=t)return n;let e=s,o=u[s];for(let r=s+1;r<t;r++){const f=u[r];f!==o&&(n.push(e,r-e,o),e=r,o=f)}return n.push(e,t-e,o),n}self.onmessage=u=>{const{bufferY:s,start:t,end:n}=u.data,e=new Float32Array(s);self.postMessage(c(e,t,n))}})();
9
+ `,Ct=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Mt],{type:"text/javascript;charset=utf-8"});function zr(e){let t;try{if(t=Ct&&(self.URL||self.webkitURL).createObjectURL(Ct),!t)throw"";const r=new Worker(t,{name:e?.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Mt),{name:e?.name})}}const Ft=`(function(){"use strict";function a(e,t,o,c){const n=[];let r=e[t];for(let s=t+1;s<=o;s++){const f=e[s];f-r>c&&n.push(s-1,s),r=f}return n}self.onmessage=e=>{const{bufferX:t,start:o,endInclusive:c,threshold:n}=e.data,r=new Float64Array(t);self.postMessage(a(r,o,c,n))}})();
10
+ `,Dt=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Ft],{type:"text/javascript;charset=utf-8"});function Xr(e){let t;try{if(t=Dt&&(self.URL||self.webkitURL).createObjectURL(Dt),!t)throw"";const r=new Worker(t,{name:e?.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Ft),{name:e?.name})}}const Pt=`(function(){"use strict";function c(u,s,t){const n=[];if(s>=t)return n;let e=s,o=u[s];for(let r=s+1;r<t;r++){const f=u[r];f!==o&&(n.push(e,r-e,o),e=r,o=f)}return n.push(e,t-e,o),n}self.onmessage=u=>{const{bufferY:s,start:t,end:n}=u.data,e=new Float32Array(s);self.postMessage(c(e,t,n))}})();
11
11
  `,Nt=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Pt],{type:"text/javascript;charset=utf-8"});function Vr(e){let t;try{if(t=Nt&&(self.URL||self.webkitURL).createObjectURL(Nt),!t)throw"";const r=new Worker(t,{name:e?.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Pt),{name:e?.name})}}const Bt=`(function(){"use strict";function o(s,i,t,n,l){const f=[];if(n==="Less than")for(let e=i;e<t;e++)s[e]-s[e-1]<l&&f.push(e);else if(n==="Less than or equal to")for(let e=i;e<t;e++)s[e]-s[e-1]<=l&&f.push(e);else if(n==="Greater than")for(let e=i;e<t;e++)s[e]-s[e-1]>l&&f.push(e);else if(n==="Greater than or equal to")for(let e=i;e<t;e++)s[e]-s[e-1]>=l&&f.push(e);else if(n==="Equal")for(let e=i;e<t;e++)s[e]-s[e-1]==l&&f.push(e);return f}self.onmessage=s=>{const{bufferY:i,start:t,end:n,comparator:l,value:f}=s.data,e=new Float32Array(i);self.postMessage(o(e,t,n,l,f))}})();
12
12
  `,jt=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Bt],{type:"text/javascript;charset=utf-8"});function qr(e){let t;try{if(t=jt&&(self.URL||self.webkitURL).createObjectURL(jt),!t)throw"";const r=new Worker(t,{name:e?.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Bt),{name:e?.name})}}const Wt=`(function(){"use strict";function l(t,i,n,o,h){const f=[];if(o==="Less than")for(let e=i;e<n;e++){const s=t[e-1];(t[e]-s)/Math.abs(s)<h&&f.push(e)}else if(o==="Less than or equal to")for(let e=i;e<n;e++){const s=t[e-1];(t[e]-s)/Math.abs(s)<=h&&f.push(e)}else if(o==="Greater than")for(let e=i;e<n;e++){const s=t[e-1];(t[e]-s)/Math.abs(s)>h&&f.push(e)}else if(o==="Greater than or equal to")for(let e=i;e<n;e++){const s=t[e-1];(t[e]-s)/Math.abs(s)>=h&&f.push(e)}else if(o==="Equal")for(let e=i;e<n;e++){const s=t[e-1];(t[e]-s)/Math.abs(s)==h&&f.push(e)}return f}self.onmessage=t=>{const{bufferY:i,start:n,end:o,comparator:h,value:f}=t.data,e=new Float32Array(i);self.postMessage(l(e,n,o,h,f))}})();
13
13
  `,xt=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Wt],{type:"text/javascript;charset=utf-8"});function Jr(e){let t;try{if(t=xt&&(self.URL||self.webkitURL).createObjectURL(xt),!t)throw"";const r=new Worker(t,{name:e?.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Wt),{name:e?.name})}}const Gt=`(function(){"use strict";function k(i,l,u,r,c){const f=[],b=r.length;for(let a=l;a<u;a++){const t=i[a];let e=!1;for(let n=0;n<b;n++){const o=r[n],s=c[n];if(o===0){if(t<s){e=!0;break}}else if(o===1){if(t<=s){e=!0;break}}else if(o===2){if(t>s){e=!0;break}}else if(o===3){if(t>=s){e=!0;break}}else if(t==s){e=!0;break}}e&&f.push(a)}return f}self.onmessage=i=>{const{bufferY:l,start:u,end:r,ops:c,values:f}=i.data,b=new Float32Array(l);self.postMessage(k(b,u,r,c,f))}})();
14
14
  `,Yt=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Gt],{type:"text/javascript;charset=utf-8"});function je(e){let t;try{if(t=Yt&&(self.URL||self.webkitURL).createObjectURL(Yt),!t)throw"";const r=new Worker(t,{name:e?.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Gt),{name:e?.name})}}const Ht=`(function(){"use strict";function e(l,t,o,s){const c=t.length;if(o==="ADD")for(let f=0;f<c;f++)l[t[f]]=l[t[f]]+s;else if(o==="SUB")for(let f=0;f<c;f++)l[t[f]]=l[t[f]]-s;else if(o==="MULT")for(let f=0;f<c;f++)l[t[f]]=l[t[f]]*s;else if(o==="DIV")for(let f=0;f<c;f++)l[t[f]]=l[t[f]]/s;else if(o==="ASSIGN")for(let f=0;f<c;f++)l[t[f]]=s}self.onmessage=l=>{const{bufferY:t,indexes:o,operator:s,value:c}=l.data,f=new Float32Array(t);e(f,o,s,c),self.postMessage("Done")}})();
15
- `,zt=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Ht],{type:"text/javascript;charset=utf-8"});function Qr(e){let t;try{if(t=zt&&(self.URL||self.webkitURL).createObjectURL(zt),!t)throw"";const r=new Worker(t,{name:e?.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Ht),{name:e?.name})}}function Xt(e,t,r,n,s){const a=[],o=n.length;for(let i=t;i<r;i++){const l=e[i];let d=!1;for(let u=0;u<o;u++){const y=n[u],g=s[u];if(y===0){if(l<g){d=!0;break}}else if(y===1){if(l<=g){d=!0;break}}else if(y===2){if(l>g){d=!0;break}}else if(y===3){if(l>=g){d=!0;break}}else if(l==g){d=!0;break}}d&&a.push(i)}return a}function Kr(e,t,r,n,s){const a=[];if(n==="Less than")for(let o=t;o<r;o++)e[o]-e[o-1]<s&&a.push(o);else if(n==="Less than or equal to")for(let o=t;o<r;o++)e[o]-e[o-1]<=s&&a.push(o);else if(n==="Greater than")for(let o=t;o<r;o++)e[o]-e[o-1]>s&&a.push(o);else if(n==="Greater than or equal to")for(let o=t;o<r;o++)e[o]-e[o-1]>=s&&a.push(o);else if(n==="Equal")for(let o=t;o<r;o++)e[o]-e[o-1]==s&&a.push(o);return a}function Zr(e,t,r,n,s){const a=[];if(n==="Less than")for(let o=t;o<r;o++){const i=e[o-1];(e[o]-i)/Math.abs(i)<s&&a.push(o)}else if(n==="Less than or equal to")for(let o=t;o<r;o++){const i=e[o-1];(e[o]-i)/Math.abs(i)<=s&&a.push(o)}else if(n==="Greater than")for(let o=t;o<r;o++){const i=e[o-1];(e[o]-i)/Math.abs(i)>s&&a.push(o)}else if(n==="Greater than or equal to")for(let o=t;o<r;o++){const i=e[o-1];(e[o]-i)/Math.abs(i)>=s&&a.push(o)}else if(n==="Equal")for(let o=t;o<r;o++){const i=e[o-1];(e[o]-i)/Math.abs(i)==s&&a.push(o)}return a}function en(e,t,r,n){const s=[];let a=e[t];for(let o=t+1;o<=r;o++){const i=e[o];i-a>n&&s.push(o-1,o),a=i}return s}function tn(e,t,r){const n=[];if(t>=r)return n;let s=t,a=e[t];for(let o=t+1;o<r;o++){const i=e[o];i!==a&&(n.push(s,o-s,a),s=o,a=i)}return n.push(s,r-s,a),n}function rn(e,t,r,n,s,a,o,i,l,d,u){let y=0,g=i;for(let m=a;m<=o;m++)if(n[g]=e[m],s[g]=t[m],g++,y<r.length&&m===r[y][0]){const S=r[y][0],h=r[y][1],f=e[S],b=e[h],p=t[S],E=t[h],v=b-f,A=E-p;let $=f+l;for(;$<b;)n[g]=$,s[g]=d?p+($-f)*A/v:u,g++,$+=l;y++}return g-i}function nn(e,t,r,n,s,a,o,i){let l=a,d=0,u=i;const y=r.length;for(;l<o&&d<y;){const g=r[d][0];e[l]<=g?(n[u]=e[l],s[u]=t[l],l++):(n[u]=g,s[u]=r[d][1],d++),u++}for(;l<o;)n[u]=e[l],s[u]=t[l],l++,u++;for(;d<y;)n[u]=r[d][0],s[u]=r[d][1],d++,u++;return u-i}function sn(e,t,r,n,s,a,o,i){let l=0,d=i;for(let u=a;u<=o;u++)l<r.length&&u===r[l]?l++:(n[d]=e[u],s[d]=t[u],d++);return d-i}function on(e,t,r,n){const s=r.length,a=new Array(s);if(n.isMonth)for(let o=0;o<s;o++){const i=r[o],l=new Date(e[i]);l.setMonth(l.getMonth()+n.amount),a[o]=[l.getTime(),t[i]]}else if(n.isYear)for(let o=0;o<s;o++){const i=r[o],l=new Date(e[i]);l.setFullYear(l.getFullYear()+n.amount),a[o]=[l.getTime(),t[i]]}else for(let o=0;o<s;o++){const i=r[o];a[o]=[e[i]+n.deltaMs,t[i]]}return a}function an(e,t,r){for(let n=0;n<r.length;n++){const{indexes:s,lowerIdx:a,upperIdx:o}=r[n],i=e[a],l=t[a],d=e[o],u=t[o],y=d-i,g=u-l;if(y===0){for(let m=0;m<s.length;m++)t[s[m]]=l;continue}for(let m=0;m<s.length;m++){const S=s[m];t[S]=l+(e[S]-i)*g/y}}}function cn(e,t,r){for(let n=0;n<r.length;n++){const s=r[n][0],a=r[n][1],o=r[n][2];if(a<=s)continue;const i=e[s],l=e[a]-i;if(l!==0)for(let d=s;d<a;d++)t[d]=t[d]+o*((e[d]-i)/l)}}function Vt(e,t,r,n){const s=t.length;if(r==="ADD")for(let a=0;a<s;a++)e[t[a]]=e[t[a]]+n;else if(r==="SUB")for(let a=0;a<s;a++)e[t[a]]=e[t[a]]-n;else if(r==="MULT")for(let a=0;a<s;a++)e[t[a]]=e[t[a]]*n;else if(r==="DIV")for(let a=0;a<s;a++)e[t[a]]=e[t[a]]/n;else if(r==="ASSIGN")for(let a=0;a<s;a++)e[t[a]]=n}const We="qc-utils:calibration:v1",ln=720*60*60*1e3,ye=5e4,ge=2e5,me={spawnOverheadMs:50,inlineThroughput:5e4,workerThroughput:8e4,hwConcurrency:4,measuredAt:0,userAgent:"default"};let C=mn()??me,xe=null,se=null;const Ge=new Set,Ye={[L.VALUE_THRESHOLD]:{mode:"calibrated",weight:1,rationale:"O(n) single-pass scan; baseline reference"},[L.CHANGE]:{mode:"calibrated",weight:1.1,rationale:"O(n) with one subtraction per step"},[L.RATE_OF_CHANGE]:{mode:"calibrated",weight:1.4,rationale:"O(n) with division + abs per step"},[L.FIND_GAPS]:{mode:"calibrated",weight:.9,rationale:"O(n) on X only, mostly empty output"},[L.PERSISTENCE]:{mode:"calibrated",weight:1.3,rationale:"O(n) + chunk-boundary stitch"},[L.DATETIME_RANGE]:{mode:"always-inline",weight:0,rationale:"O(log n) binary search; never worth the worker hop"},[L.SELECTION]:{mode:"always-inline",weight:0,rationale:"Pure history bookkeeping"},[k.CHANGE_VALUES]:{mode:"calibrated",weight:.7,rationale:"O(k) in-place arithmetic on selection"},[k.ASSIGN_VALUES_BULK]:{mode:"always-inline",weight:0,rationale:"Single tight loop, already inline"},[k.ASSIGN_DATETIMES_BULK]:{mode:"always-inline",weight:0,rationale:"Composes delete+add which handle their own dispatch"},[k.INTERPOLATE]:{mode:"calibrated",weight:1.5,rationale:"Linear interp per consecutive group; in-place writes"},[k.DRIFT_CORRECTION]:{mode:"calibrated",weight:1.2,rationale:"O(range total) in-place math; one pass per range"},[k.SHIFT_DATETIMES]:{mode:"calibrated",weight:1.1,rationale:"O(k) per-point shift math; inline skips SAB allocation"},[k.ADD_POINTS]:{mode:"calibrated",weight:1.8,rationale:"Single merge pass over Y/X + insertions; fresh SAB per call"},[k.DELETE_POINTS]:{mode:"calibrated",weight:1.4,rationale:"Single skip-on-delete pass over Y/X; fresh SAB per call"},[k.FILL_GAPS]:{mode:"calibrated",weight:1.3,rationale:"Single copy-with-fills pass; fresh SAB sized to newLength"}};function P(e,t){const r=Ye[e];if(!r)return{useWorker:!0,predictedInlineMs:1/0,predictedWorkerMs:0,reason:"unknown op; keeping default worker path"};if(r.mode==="always-inline")return{useWorker:!1,predictedInlineMs:0,predictedWorkerMs:0,reason:r.rationale};if(typeof SharedArrayBuffer>"u")return{useWorker:!1,predictedInlineMs:0,predictedWorkerMs:1/0,reason:"SharedArrayBuffer unavailable; forced inline"};if(r.mode==="always-worker")return{useWorker:!0,predictedInlineMs:1/0,predictedWorkerMs:0,reason:r.rationale};const n=un(e,t);if(n<=0)return{useWorker:!1,predictedInlineMs:0,predictedWorkerMs:C.spawnOverheadMs,reason:"zero work units"};const s=Math.max(1,Math.min(t.parallelism??C.hwConcurrency,C.hwConcurrency)),a=r.weight*n/C.inlineThroughput,o=C.spawnOverheadMs+r.weight*n/(C.workerThroughput*s),i=a>o;return{useWorker:i,predictedInlineMs:a,predictedWorkerMs:o,reason:i?`worker faster (${o.toFixed(1)} vs ${a.toFixed(1)} ms)`:`inline faster (${a.toFixed(1)} vs ${o.toFixed(1)} ms)`}}function un(e,t){switch(e){case k.CHANGE_VALUES:case k.INTERPOLATE:case k.SHIFT_DATETIMES:case k.DRIFT_CORRECTION:return t.selectionSize??0;case k.DELETE_POINTS:return(t.selectionSize??0)+t.datasetSize*.25;case k.ADD_POINTS:{const r=Math.max(1,Math.log2(Math.max(t.datasetSize,2)));return t.datasetSize+(t.selectionSize??0)*r}default:return t.datasetSize}}function hn(e){return Ge.add(e),()=>Ge.delete(e)}function fn(){return C}function dn(){return xe}function pn(){return Object.keys(Ye).map(e=>({op:e,...Ye[e]}))}function yn(){C=me,xe=null;try{localStorage.removeItem(We)}catch{}}async function gn(e={}){if(typeof window>"u"||!(e.force||C.measuredAt===0||Date.now()-C.measuredAt>ln))return C;if(se)await se;else{se=qt().finally(()=>{se=null});const r=await se;C=r,wn(r),xe=r;for(const n of Ge)n(C)}return C}async function qt(){if(!(typeof SharedArrayBuffer<"u"))return{...me,measuredAt:Date.now(),userAgent:navigator.userAgent,hwConcurrency:navigator.hardwareConcurrency||me.hwConcurrency,sharedArrayBufferAvailable:!1,samples:{spawnRoundtripMs:[],inlineScanMs:[],workerScanMs:[]}};const t=navigator.hardwareConcurrency||4,r=new Float32Array(ye);for(let h=0;h<ye;h++)r[h]=Math.sin(h);const n=await He(3,()=>{const h=performance.now();return Xt(r,0,ye,[2],[.5]),performance.now()-h}),s=ze(n),a=ye/Math.max(s,.001),o=new SharedArrayBuffer(256*Float32Array.BYTES_PER_ELEMENT),i=await He(3,async()=>{const h=performance.now();return await new Promise(f=>{const b=new je;b.onmessage=()=>{b.terminate(),f()},b.postMessage({bufferY:o,start:0,end:256,ops:[2],values:[.5]})}),performance.now()-h}),l=ze(i),d=new SharedArrayBuffer(ge*Float32Array.BYTES_PER_ELEMENT),u=new Float32Array(d);for(let h=0;h<ge;h++)u[h]=Math.sin(h);const y=await He(3,async()=>{const h=performance.now();return await new Promise(f=>{const b=new je;b.onmessage=()=>{b.terminate(),f()},b.postMessage({bufferY:d,start:0,end:ge,ops:[2],values:[.5]})}),performance.now()-h}),g=Math.max(ze(y)-l,.1),m=ge/g;return{spawnOverheadMs:l,inlineThroughput:a,workerThroughput:m,hwConcurrency:t,measuredAt:Date.now(),userAgent:navigator.userAgent,sharedArrayBufferAvailable:!0,samples:{spawnRoundtripMs:i,inlineScanMs:n,workerScanMs:y}}}async function He(e,t){const r=[];for(let n=0;n<e;n++)await new Promise(s=>setTimeout(s,0)),r.push(await t());return r}function ze(e){if(!e.length)return 0;const t=[...e].sort((n,s)=>n-s),r=Math.floor(t.length/2);return t.length%2?t[r]:(t[r-1]+t[r])/2}function mn(){if(typeof localStorage>"u")return null;try{const e=localStorage.getItem(We);if(!e)return null;const t=JSON.parse(e);return!t||typeof t.spawnOverheadMs!="number"?null:t}catch{return null}}function wn(e){if(!(typeof localStorage>"u"))try{const t={spawnOverheadMs:e.spawnOverheadMs,inlineThroughput:e.inlineThroughput,workerThroughput:e.workerThroughput,hwConcurrency:e.hwConcurrency,measuredAt:e.measuredAt,userAgent:e.userAgent};localStorage.setItem(We,JSON.stringify(t))}catch{}}const ee=20*1e3,bn=1024,Sn=["date","value","qualifier"],En=typeof SharedArrayBuffer<"u";function D(e,t){return En?t!==void 0?new SharedArrayBuffer(e,{maxByteLength:t}):new SharedArrayBuffer(e):t!==void 0?new ArrayBuffer(e,{maxByteLength:t}):new ArrayBuffer(e)}function Jt(e,t){const r=e;typeof r.grow=="function"?r.grow(t):typeof r.resize=="function"&&r.resize(t)}function vn(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}function kn(e,t){switch(e){case k.ADD_POINTS:case k.FILL_GAPS:return!1;default:return!0}}class _n{dataset={dimensions:Sn,source:{x:new Float64Array(D(ee*Float64Array.BYTES_PER_ELEMENT,ee*Float64Array.BYTES_PER_ELEMENT)),y:new Float32Array(D(ee*Float32Array.BYTES_PER_ELEMENT,ee*Float32Array.BYTES_PER_ELEMENT))}};history=[];redoStack=[];_isReplaying=!1;_pendingExecutionMode="inline";loadingTime=null;isLoading=!0;rawData;constructor(t){this.history=[],this.rawData=t,this.loadData(this.rawData)}async loadData(t){if(!t)return;this.isLoading=!0;const r=await pe(()=>{this._growBuffer(t.datetimes.length),this._resizeTo(t.datetimes.length),this.dataX.set(t.datetimes),this.dataY.set(t.dataValues)});this.loadingTime=r.duration,this.history.length=0,this.isLoading=!1}get dataX(){return this.dataset.source.x}get dataY(){return this.dataset.source.y}_resizeTo(t){this.dataset.source.x=new Float64Array(this.dataset.source.x.buffer).subarray(0,t),this.dataset.source.y=new Float32Array(this.dataset.source.y.buffer).subarray(0,t)}_growBuffer(t){const r=t*Float64Array.BYTES_PER_ELEMENT;let n=this.dataX.buffer.byteLength;for(;r>n;)n+=ee*Float64Array.BYTES_PER_ELEMENT;if(n*Float64Array.BYTES_PER_ELEMENT>this.dataX.buffer.maxByteLength){const s=D(this.dataX.buffer.byteLength,n*Float64Array.BYTES_PER_ELEMENT),a=D(this.dataY.buffer.byteLength,n*Float32Array.BYTES_PER_ELEMENT),o=new Float64Array(s),i=new Float32Array(a);o.set(this.dataX),i.set(this.dataY),this.dataset.source.x=o,this.dataset.source.y=i}this.dataX.buffer.byteLength<t*Float64Array.BYTES_PER_ELEMENT&&(Jt(this.dataX.buffer,t*Float64Array.BYTES_PER_ELEMENT),Jt(this.dataY.buffer,t*Float32Array.BYTES_PER_ELEMENT))}async reload(){this.loadingTime=null,this.isLoading=!0,this.history.length=0,await this.loadData(this.rawData)}async reloadHistory(t){const r=this.history.slice(0,t+1);return this.redoStack.length=0,await this.reload(),await this.dispatch(r.map(n=>[n.method,...n.args||[]]))}async removeHistoryItem(t){const r=[...this.history];return r.splice(t,1),this.redoStack.length=0,await this.reload(),await this.dispatch(r.map(n=>[n.method,...n.args||[]]))}async undo(){if(!this.history.length)return[];const t=this.history[this.history.length-1],r=this.history.slice(0,-1);await this.reload(),this.redoStack.push(t),this._isReplaying=!0;try{return await this.dispatch(r.map(n=>[n.method,...n.args||[]]))}finally{this._isReplaying=!1}}async redo(){if(!this.redoStack.length)return[];const t=this.redoStack.pop();this._isReplaying=!0;try{return await this.dispatch([[t.method,...t.args||[]]])}finally{this._isReplaying=!1}}get beginTime(){return this.dataset.source.x.length?new Date(this.dataset.source.x[0]):null}get endTime(){return this.dataset.source.x.length?new Date(this.dataset.source.x[this.dataset.source.x.length-1]):null}async dispatchAction(t,...r){const n={[k.ADD_POINTS]:this._addDataPoints,[k.CHANGE_VALUES]:this._changeValues,[k.ASSIGN_VALUES_BULK]:this._assignValuesBulk,[k.DELETE_POINTS]:this._deleteDataPointsFromSelection,[k.DRIFT_CORRECTION]:this._driftCorrectionFromSelection,[k.INTERPOLATE]:this._interpolateFromSelection,[k.SHIFT_DATETIMES]:this._shiftFromSelection,[k.ASSIGN_DATETIMES_BULK]:this._assignDatetimesBulk,[k.FILL_GAPS]:this._fillGaps};let s=[],a=null;try{this._isReplaying||(this.redoStack.length=0),a={method:t,args:r,isLoading:!0},this.history.push(a),kn(t,r)||this.history[this.history.length-2]?.method===L.SELECTION&&this.history.splice(this.history.length-2,1),this._pendingExecutionMode="inline";const o=await pe(async()=>await n[t].apply(this,r));s=o.response;const i=this.history.indexOf(a),l=i>=0?this.history[i]:void 0;l&&(l.duration=o.duration,l.executionMode=this._pendingExecutionMode,l.status="success",l.isLoading=!1)}catch{if(a){const i=this.history.indexOf(a),l=i>=0?this.history[i]:void 0;l&&(l.status="failed",l.isLoading=!1)}}return s}async dispatch(t,...r){const n=async(s,a)=>L[s]?await this.dispatchFilter(s,...a):await this.dispatchAction(s,...a);if(Array.isArray(t)){let s=[];for(let a=0;a<t.length;a++){const o=t[a][0],i=t[a].slice(1,t[a].length);s=await n(o,i)}return s}else return await n(t,r)}async dispatchFilter(t,...r){const n={[L.FIND_GAPS]:this._findGaps,[L.VALUE_THRESHOLD]:this._valueThreshold,[L.DATETIME_RANGE]:this._datetimeRange,[L.PERSISTENCE]:this._persistence,[L.CHANGE]:this._change,[L.RATE_OF_CHANGE]:this._rateOfChange,[L.SELECTION]:this._selection};let s=[],a=null;try{const o=t===L.SELECTION,i=o&&(!r[0]||Array.isArray(r[0])&&r[0].length===0);!this._isReplaying&&!i&&(this.redoStack.length=0),a={method:t,args:r,isLoading:!0};const l=this.history[this.history.length-1],d=!!L[l?.method],u=l?.method===t||d&&!o;let y;u?(y=this.history.length-1,this.history[y]=a):(this.history.push(a),y=this.history.length-1),this._pendingExecutionMode="inline";const g=await pe(async()=>await n[t].apply(this,r));s=g.response;const m=this.history.indexOf(a),S=m>=0?this.history[m]:void 0;S&&(S.duration=g.duration,S.executionMode=this._pendingExecutionMode,S.selected=g.response,S.status="success",S.isLoading=!1)}catch(o){if(console.log(`Failed to execute filter operation: ${t} with arguments: `,r),console.log(o),a){const i=this.history.indexOf(a),l=i>=0?this.history[i]:void 0;l&&(l.status="failed",l.isLoading=!1)}}return s}async _changeValues(t,r){const n=this.history[this.history.length-2]?.selected;if(!n||n.length===0)return[];const s=n.length;if(!P(k.CHANGE_VALUES,{datasetSize:this.dataset.source.y.length,selectionSize:s}).useWorker||s<bn)return Vt(this.dataY,n,t,r),[];this._pendingExecutionMode="worker";const o=Math.min(navigator.hardwareConcurrency||1,s),i=Math.ceil(s/o),l=[],d=[];for(let u=0;u<o;u++){const y=u*i,g=Math.min((u+1)*i,s);if(y>=g)break;const m=n.slice(y,g);d.push(new Promise(S=>{const h=new Qr;l.push(h),h.postMessage({bufferY:this.dataY.buffer,indexes:m,operator:t,value:r}),h.onmessage=f=>{S(f.data)}}))}return await Promise.all(d),l.forEach(u=>u.terminate()),[]}_applyOperatorInPlace(t,r,n){Vt(this.dataY,t,r,n)}async _assignValuesBulk(t){const r=this.history[this.history.length-2]?.selected;if(!r||!r.length||!t?.length)return[];const n=Math.min(r.length,t.length),s=this.dataY;for(let a=0;a<n;a++)s[r[a]]=t[a];return[]}async _assignDatetimesBulk(t){const r=this.history[this.history.length-2]?.selected;if(!r||!r.length||!t?.length)return[];const n=Math.min(r.length,t.length),s=new Array(n),a=new Array(n);for(let o=0;o<n;o++)s[o]=[t[o],this.dataY[r[o]]],a[o]=r[o];return a.sort((o,i)=>o-i),await this._deleteDataPoints(a),await this._addDataPoints(s),[]}async _interpolateFromSelection(){const t=this.history[this.history.length-2]?.selected;if(!(!t||t.length===0))return this._interpolate(t)}async _interpolate(t){const r=this._getConsecutiveGroups(t);if(r.length===0||r[0].length===0)return;const n=this.dataset.source.y.length,s=r.map(u=>({indexes:u,lowerIdx:Math.max(0,u[0]-1),upperIdx:Math.min(n-1,u[u.length-1]+1)}));if(!P(k.INTERPOLATE,{datasetSize:n,selectionSize:t.length}).useWorker){an(this.dataX,this.dataY,s);return}this._pendingExecutionMode="worker";const o=Math.min(navigator.hardwareConcurrency||1,s.length),i=Math.ceil(s.length/o),l=[],d=[];for(let u=0;u<o;u++){const y=s.slice(u*i,(u+1)*i);if(y.length===0)break;d.push(new Promise(g=>{const m=new Gr;l.push(m),m.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,groups:y}),m.onmessage=S=>{g(S.data)}}))}await Promise.all(d),l.forEach(u=>u.terminate())}async _shiftFromSelection(t,r){const n=this.history[this.history.length-2]?.selected;return!n||n.length===0?[]:await this._shift(n,t,r)??[]}async _shift(t,r,n){if(t.length===0)return[];const s=n===M.MONTH,a=n===M.YEAR,o=!s&&!a?r*ne[n]*1e3:0,i=t.length;if(!P(k.SHIFT_DATETIMES,{datasetSize:this.dataset.source.x.length,selectionSize:i}).useWorker){const p=on(this.dataX,this.dataY,t,{amount:r,isMonth:s,isYear:a,deltaMs:o});return await this._deleteDataPoints(t),await this._addDataPoints(p)??[]}this._pendingExecutionMode="worker";const d=D(i*Float64Array.BYTES_PER_ELEMENT),u=D(i*Float32Array.BYTES_PER_ELEMENT),y=Math.min(navigator.hardwareConcurrency||1,i),g=Math.ceil(i/y),m=[],S=[];for(let p=0;p<y;p++){const E=p*g,v=Math.min((p+1)*g,i);if(E>=v)break;const A=t.slice(E,v);S.push(new Promise($=>{const R=new zr;m.push(R),R.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,outputBufferX:d,outputBufferY:u,indexes:A,outStart:E,amount:r,isMonth:s,isYear:a,deltaMs:o}),R.onmessage=O=>{$(O.data)}}))}await Promise.all(S),m.forEach(p=>p.terminate());const h=new Float64Array(d),f=new Float32Array(u),b=new Array(i);for(let p=0;p<i;p++)b[p]=[h[p],f[p]];return await this._deleteDataPoints(t),await this._addDataPoints(b)??[]}async _fillGaps(t,r,n,s,a){const o=this.dataX.length;if(o===0)return[];const i=t[0]*ne[t[1]]*1e3,l=r[0]*ne[r[1]]*1e3,d=this.dataX,u=a?.[0]!=null&&Number.isFinite(a[0])?j(d,a[0]):0,y=a?.[1]!=null&&Number.isFinite(a[1])?W(d,a[1]):o-1,g=[],m=[];let S=0;for(let _=u+1;_<=y;_++)if(d[_]-d[_-1]>i){let N=0,x=d[_-1]+l;for(;x<d[_];)N++,x+=l;N>0&&(g.push([_-1,_]),m.push(N),S+=N)}if(S===0)return[];const h=new Array(S);let f=0,b=0;for(let _=0;_<g.length;_++){const G=g[_][0],N=m[_];for(let x=1;x<=N;x++)h[b++]=G+f+x;f+=N}const p=o+S,E=p*Float64Array.BYTES_PER_ELEMENT,v=p*Float32Array.BYTES_PER_ELEMENT,A=D(E,Math.max(this.dataX.buffer.maxByteLength,E)),$=D(v,Math.max(this.dataY.buffer.maxByteLength,v));if(!P(k.FILL_GAPS,{datasetSize:o,selectionSize:S}).useWorker){const _=new Float64Array(A),G=new Float32Array($);return rn(this.dataX,this.dataY,g,_,G,0,o-1,0,l,n,s),this.dataset.source.x=_,this.dataset.source.y=G,this._resizeTo(p),h}this._pendingExecutionMode="worker";const O=navigator.hardwareConcurrency||1,Qt=Math.ceil(o/O),Xe=[];let ae=0;for(let _=0;_<O;_++){const G=_*Qt,N=Math.min((_+1)*Qt-1,o-1),x=[];let we=0;for(;ae<g.length&&g[ae][0]<=N;)x.push(g[ae]),we+=m[ae],ae++;Xe.push({start:G,end:N,gapsSegment:x,fillsInSegment:we})}const Ve=new Array(O).fill(0);for(let _=1;_<O;_++)Ve[_]=Ve[_-1]+Xe[_-1].fillsInSegment;const Kt=[],Zt=[];for(let _=0;_<O;_++){const{start:G,end:N,gapsSegment:x}=Xe[_],we=G+Ve[_];Zt.push(new Promise(Rn=>{const qe=new xr;Kt.push(qe),qe.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,outputBufferX:A,outputBufferY:$,start:G,end:N,gapsSegment:x,startTarget:we,fillDelta:l,interpolate:n,fillValue:s}),qe.onmessage=In=>{Rn(In.data)}}))}return await Promise.all(Zt),Kt.forEach(_=>_.terminate()),this.dataset.source.x=new Float64Array(A),this.dataset.source.y=new Float32Array($),this._resizeTo(p),h}async _deleteDataPointsFromSelection(){const t=this.history[this.history.length-2]?.selected;if(!(!t||t.length===0))return this._deleteDataPoints(t)}async _deleteDataPoints(t){const r=this.dataX.length,n=r-t.length;if(!P(k.DELETE_POINTS,{datasetSize:r,selectionSize:t.length}).useWorker){const m=D(this.dataX.buffer.byteLength,this.dataX.buffer.maxByteLength),S=D(this.dataY.buffer.byteLength,this.dataY.buffer.maxByteLength),h=new Float64Array(m),f=new Float32Array(S);sn(this.dataX,this.dataY,t,h,f,0,r-1,0),this.dataset.source.x=h,this.dataset.source.y=f,this._resizeTo(n);return}this._pendingExecutionMode="worker";const a=navigator.hardwareConcurrency||1,o=Math.ceil(this.dataX.length/a),i=[],l=[];for(let m=0;m<a;m++){const S=m*o,h=Math.min((m+1)*o-1,this.dataX.length-1),f=j(t,S),b=W(t,h),p=t.slice(f,b+1);l.push({start:S,end:h,deleteSegment:p})}const d=new Array(a).fill(0);for(let m=1;m<a;m++)d[m]=d[m-1]+l[m-1].deleteSegment.length;const u=[],y=D(this.dataX.buffer.byteLength,this.dataX.buffer.maxByteLength),g=D(this.dataY.buffer.byteLength,this.dataY.buffer.maxByteLength);for(let m=0;m<a;m++){const{start:S,end:h,deleteSegment:f}=l[m],b=S-d[m];u.push(new Promise(p=>{const E=new Wr;i.push(E),E.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,outputBufferX:y,outputBufferY:g,start:S,end:h,deleteSegment:f,startTarget:b}),E.onmessage=v=>{p(v.data)}}))}await Promise.all(u),i.forEach(m=>m.terminate()),this.dataset.source.x=new Float64Array(y),this.dataset.source.y=new Float32Array(g),this._resizeTo(n)}async _driftCorrectionFromSelection(t){const r=this.history[this.history.length-2]?.selected;if(!r||r.length===0)return;const n=this._getConsecutiveGroups(r),s=[];for(const a of n)a.length!==0&&s.push([a[0],a[a.length-1],t]);if(s.length!==0)return this._driftCorrection(s)}async _driftCorrection(t){if(!t||t.length===0)return;const r=this.dataset.source.x,n=navigator.hardwareConcurrency||1;let s=0;for(const[y,g]of t)g>y&&(s+=g-y);if(!P(k.DRIFT_CORRECTION,{datasetSize:r.length,selectionSize:s}).useWorker){cn(r,this.dataY,t);return}this._pendingExecutionMode="worker";const o=[];for(const[y,g,m]of t){if(g<=y)continue;const S=r[y],h=r[g]-S;if(h===0)continue;const f=g-y,b=Math.max(1,Math.ceil(f/n));for(let p=y;p<g;p+=b)o.push({chunkStart:p,chunkEnd:Math.min(p+b,g),startDatetime:S,value:m,extent:h})}if(o.length===0)return;const i=Math.min(n,o.length),l=Array.from({length:i},()=>[]);o.forEach((y,g)=>l[g%i].push(y));const d=[],u=[];for(const y of l)y.length!==0&&u.push(new Promise(g=>{const m=new Yr;d.push(m),m.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,jobs:y}),m.onmessage=S=>{g(S.data)}}));await Promise.all(u),d.forEach(y=>y.terminate())}_getConsecutiveGroups(t){const r=[[]];return t.reduce((n,s)=>{const a=n[n.length-1];return!a.length||s==a[a.length-1]+1?a.push(s):n.push([s]),n},r),r}async _addDataPoints(t){if(t.length===0)return[];const r=this.dataX.length,n=r+t.length;t.sort((h,f)=>h[0]-f[0]);const s=new Array(t.length);for(let h=0;h<t.length;h++){const f=t[h][0],b=W(this.dataX,f)+1;s[h]=b+h}const a=n*Float64Array.BYTES_PER_ELEMENT,o=n*Float32Array.BYTES_PER_ELEMENT,i=D(a,Math.max(this.dataX.buffer.maxByteLength,a)),l=D(o,Math.max(this.dataY.buffer.maxByteLength,o));if(!P(k.ADD_POINTS,{datasetSize:r,selectionSize:t.length}).useWorker){const h=new Float64Array(i),f=new Float32Array(l);return nn(this.dataX,this.dataY,t,h,f,0,r,0),this.dataset.source.x=h,this.dataset.source.y=f,this._resizeTo(n),s}this._pendingExecutionMode="worker";const u=t.map(h=>W(this.dataX,h[0])+1),y=Math.max(1,Math.min(navigator.hardwareConcurrency||1,Math.max(r,1))),g=Math.ceil(Math.max(r,1)/y),m=[],S=[];for(let h=0;h<y;h++){const f=h*g,b=Math.min((h+1)*g,r),p=j(u,f),E=h===y-1?t.length:j(u,b),v=t.slice(p,E),A=f+p;f>=b&&v.length===0||S.push(new Promise($=>{const R=new Hr;m.push(R),R.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,outputBufferX:i,outputBufferY:l,origStart:f,origEnd:b,insertions:v,outStart:A}),R.onmessage=O=>{$(O.data)}}))}return await Promise.all(S),m.forEach(h=>h.terminate()),this.dataset.source.x=new Float64Array(i),this.dataset.source.y=new Float32Array(l),this._resizeTo(n),s}async _valueThreshold(t,r){const n=Object.keys(t);if(n.length===0)return[];const s={[X.LT]:0,[X.LTE]:1,[X.GT]:2,[X.GTE]:3,[X.E]:4},a=n.map(E=>s[E]??4),o=n.map(E=>t[E]),i=this.dataset.source.y,l=this.dataset.source.x;let d=0,u=i.length;if(u===0)return[];if(r!=null){const[E,v]=r;E!=null&&Number.isFinite(E)&&(d=j(l,E)),v!=null&&Number.isFinite(v)&&(u=W(l,v)+1)}if(u<=d)return[];const y=u-d;if(!P(L.VALUE_THRESHOLD,{datasetSize:y}).useWorker)return Xt(i,d,u,a,o);this._pendingExecutionMode="worker";const m=Math.min(navigator.hardwareConcurrency||1,y),S=Math.ceil(y/m),h=[],f=[];for(let E=0;E<m;E++){const v=d+E*S,A=Math.min(d+(E+1)*S,u);if(v>=A)break;f.push(new Promise($=>{const R=new je;h.push(R),R.postMessage({bufferY:this.dataY.buffer,start:v,end:A,ops:a,values:o}),R.onmessage=O=>{$(O.data)}}))}const b=await Promise.all(f);h.forEach(E=>E.terminate());const p=[];for(let E=0;E<b.length;E++){const v=b[E];for(let A=0;A<v.length;A++)p.push(v[A])}return p}async _rateOfChange(t,r,n){const s=this.dataset.source.y,a=this.dataset.source.x;if(s.length<2)return[];let o=1,i=s.length;if(n!=null){const[f,b]=n;f!=null&&Number.isFinite(f)&&(o=Math.max(1,j(a,f))),b!=null&&Number.isFinite(b)&&(i=W(a,b)+1)}if(i<=o)return[];const l=i-o;if(!P(L.RATE_OF_CHANGE,{datasetSize:s.length}).useWorker)return Zr(s,o,i,t,r);this._pendingExecutionMode="worker";const u=Math.min(navigator.hardwareConcurrency||1,l),y=Math.ceil(l/u),g=[],m=[];for(let f=0;f<u;f++){const b=o+f*y,p=Math.min(o+(f+1)*y,i);if(b>=p)break;m.push(new Promise(E=>{const v=new Jr;g.push(v),v.postMessage({bufferY:this.dataY.buffer,start:b,end:p,comparator:t,value:r}),v.onmessage=A=>{E(A.data)}}))}const S=await Promise.all(m);g.forEach(f=>f.terminate());const h=[];for(let f=0;f<S.length;f++){const b=S[f];for(let p=0;p<b.length;p++)h.push(b[p])}return h}async _datetimeRange(t,r){const n=this.dataset.source.x,s=n.length;if(s===0)return[];const a=t==null?0:j(n,t),o=r==null?s-1:W(n,r);if(a>o)return[];const i=new Array(o-a+1);for(let l=a;l<=o;l++)i[l-a]=l;return i}async _selection(t){const r=this.history[this.history.length-2],n=!!r&&r.method!==L.SELECTION&&!!L[r.method],s=n&&Array.isArray(r.selected)?r.selected:void 0;return!t||!t.length?(this.history.pop(),s&&s.length>0&&this.history.pop(),t):(s&&vn(s,t)?this.history.pop():n&&this.history.splice(this.history.length-2,1),t)}async _change(t,r,n){const s=this.dataset.source.y,a=this.dataset.source.x;if(s.length<2)return[];let o=1,i=s.length;if(n!=null){const[f,b]=n;f!=null&&Number.isFinite(f)&&(o=Math.max(1,j(a,f))),b!=null&&Number.isFinite(b)&&(i=W(a,b)+1)}if(i<=o)return[];const l=i-o;if(!P(L.CHANGE,{datasetSize:s.length}).useWorker)return Kr(s,o,i,t,r);this._pendingExecutionMode="worker";const u=Math.min(navigator.hardwareConcurrency||1,l),y=Math.ceil(l/u),g=[],m=[];for(let f=0;f<u;f++){const b=o+f*y,p=Math.min(o+(f+1)*y,i);if(b>=p)break;m.push(new Promise(E=>{const v=new qr;g.push(v),v.postMessage({bufferY:this.dataY.buffer,start:b,end:p,comparator:t,value:r}),v.onmessage=A=>{E(A.data)}}))}const S=await Promise.all(m);g.forEach(f=>f.terminate());const h=[];for(let f=0;f<S.length;f++){const b=S[f];for(let p=0;p<b.length;p++)h.push(b[p])}return h}async _findGaps(t,r,n){const s=this.dataset.source.x;let a=0,o=s.length;if(n!=null){const[f,b]=n;f!=null&&Number.isFinite(f)&&(a=j(s,f)),b!=null&&Number.isFinite(b)&&(o=W(s,b)+1)}if(o<=a)return[];const i=t*ne[r]*1e3;if(!P(L.FIND_GAPS,{datasetSize:o-a}).useWorker){const f=en(s,a,o-1,i),b=new Set;for(let p=0;p<f.length;p++)b.add(f[p]);return[...b]}this._pendingExecutionMode="worker";const d=o-a,u=Math.min(navigator.hardwareConcurrency||1,d),y=Math.ceil(d/u),g=[],m=[];for(let f=0;f<u;f++){const b=a+f*y,p=Math.min(a+(f+1)*y,o);if(b>=p)break;m.push(new Promise(E=>{const v=new Xr;g.push(v),v.postMessage({bufferX:this.dataX.buffer,start:b,endInclusive:p,threshold:i}),v.onmessage=A=>{E(A.data)}}))}const S=await Promise.all(m);g.forEach(f=>f.terminate());const h=new Set;for(let f=0;f<S.length;f++){const b=S[f];for(let p=0;p<b.length;p++)h.add(b[p])}return[...h]}async _persistence(t,r){const n=this.dataset.source.x,s=this.dataset.source.y;let a=0,o=s.length;if(r!=null){const[p,E]=r;p!=null&&Number.isFinite(p)&&(a=j(n,p)),E!=null&&Number.isFinite(E)&&(o=W(n,E)+1)}if(o<=a)return[];const i=o-a;if(!P(L.PERSISTENCE,{datasetSize:i}).useWorker){const p=tn(s,a,o),E=[];for(let v=0;v<p.length;v+=3){const A=p[v],$=p[v+1];if($>=t)for(let R=0;R<$;R++)E.push(A+R)}return E}this._pendingExecutionMode="worker";const d=Math.min(navigator.hardwareConcurrency||1,i),u=Math.ceil(i/d),y=[],g=[];for(let p=0;p<d;p++){const E=a+p*u,v=Math.min(a+(p+1)*u,o);if(E>=v)break;g.push(new Promise(A=>{const $=new Vr;y.push($),$.postMessage({bufferY:this.dataY.buffer,start:E,end:v}),$.onmessage=R=>{A(R.data)}}))}const m=await Promise.all(g);y.forEach(p=>p.terminate());const S=[],h=[],f=[];for(let p=0;p<m.length;p++){const E=m[p];for(let v=0;v<E.length;v+=3){const A=E[v],$=E[v+1],R=E[v+2],O=S.length-1;O>=0&&f[O]===R&&S[O]+h[O]===A?h[O]+=$:(S.push(A),h.push($),f.push(R))}}const b=[];for(let p=0;p<S.length;p++){const E=h[p];if(E>=t){const v=S[p];for(let A=0;A<E;A++)b.push(v+A)}}return b}}const oe="1",An=new Set([...Object.values(k),...Object.values(L)]);function Tn(e,t){const r=e.history.map(n=>{const s={method:n.method,args:n.args?[...n.args]:[]};return n.status==="failed"&&(s.status="failed"),s});return{version:oe,createdAt:new Date().toISOString(),window:{startDate:t.startDate,endDate:t.endDate},operations:r}}function Ln(e){if(!e||typeof e!="object")throw new Error("QC script must be a JSON object.");const t=e;if(t.version!==oe)throw new Error(`Unsupported QC script version: ${String(t.version)}. This loader understands version "${oe}".`);if(typeof t.createdAt!="string")throw new Error("QC script is missing `createdAt` (ISO-8601 string).");const r=t.window;if(!r||typeof r!="object")throw new Error("QC script is missing `window`.");if(typeof r.startDate!="string"||typeof r.endDate!="string")throw new Error("`window.startDate` and `window.endDate` must be ISO-8601 strings.");if(!Array.isArray(t.operations))throw new Error("QC script `operations` must be an array.");const n=t.operations.map((s,a)=>{if(!s||typeof s!="object")throw new Error(`Operation ${a} must be an object.`);const o=s;if(typeof o.method!="string")throw new Error(`Operation ${a} missing string \`method\`.`);if(!An.has(o.method))throw new Error(`Operation ${a} has unknown method: "${o.method}".`);if(!Array.isArray(o.args))throw new Error(`Operation ${a} \`args\` must be an array.`);const i={method:o.method,args:[...o.args]};return o.status==="failed"&&(i.status="failed"),i});return{version:oe,createdAt:t.createdAt,window:{startDate:r.startDate,endDate:r.endDate},operations:n}}async function $n(e,t){e.history.length=0,e.redoStack.length=0,await e.reload();const r={applied:0,failed:[]};for(let n=0;n<t.operations.length;n++){const s=t.operations[n];try{await e.dispatch(s.method,...s.args),e.history[e.history.length-1]?.status==="failed"?r.failed.push({index:n,method:s.method,error:"Operation handler reported failure (see console)."}):r.applied++}catch(a){r.failed.push({index:n,method:s.method,error:a instanceof Error?a.message:String(a)})}}return r}w.ACCOUNT_BASE=B,w.AUTH_BASE=he,w.ApiKey=hr,w.BASE_URL=F,w.Collaborator=dr,w.DEFAULT_SNACK_DURATION=Re,w.DataSource=Or,w.Datastream=rr,w.EnumEditOperations=k,w.EnumFilterOperations=L,w.FilterOperation=X,w.HydroShareArchive=Ke,w.INCREASE_AMOUNT=ee,w.Location=Ze,w.LogicalOperation=Qe,w.OAuthProvider=ur,w.ObservationRecord=_n,w.ObservedProperty=or,w.Operator=Je,w.Organization=cr,w.PROVIDER_BASE=te,w.Payload=Cr,w.PermissionAction=et,w.PermissionResource=tt,w.Position=dt,w.PostHydroShareArchive=er,w.ProcessingLevel=ar,w.QC_SCRIPT_VERSION=oe,w.ResultQualifier=ir,w.SESSION_BASE=fe,w.Sensor=sr,w.Snack=pt,w.SnackColor=Ie,w.SnackIcon=Oe,w.SnackTitle=Ue,w.Snackbar=yt,w.TAG_BASE=Pe,w.THINGS_BASE=T,w.Thing=tr,w.TimeUnit=M,w.Unit=nr,w.User=lr,w.Workspace=fr,w.api=Mr,w.apiMethods=c,w.applyScript=$n,w.clearCalibration=yn,w.createPatchObject=Me,w.ensureCalibration=gn,w.extractErrorMessage=rt,w.findFirstGreaterOrEqual=j,w.findLastLessOrEqual=W,w.formatDate=Nr,w.formatDuration=Br,w.getCSRFToken=be,w.getCalibration=fn,w.getLastBenchmarkDetail=dn,w.getObservationsEndpoint=Ur,w.getOperationTable=pn,w.measureEllapsedTime=pe,w.onCalibrationChange=hn,w.parseScript=Ln,w.requestInterceptor=Se,w.responseInterceptor=Ee,w.runBenchmarks=qt,w.serializeHistory=Tn,w.shouldUseWorker=P,w.subtractHours=jr,w.timeUnitMultipliers=ne,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})}));
15
+ `,zt=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Ht],{type:"text/javascript;charset=utf-8"});function Qr(e){let t;try{if(t=zt&&(self.URL||self.webkitURL).createObjectURL(zt),!t)throw"";const r=new Worker(t,{name:e?.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Ht),{name:e?.name})}}function Xt(e,t,r,n,s){const a=[],o=n.length;for(let i=t;i<r;i++){const l=e[i];let d=!1;for(let u=0;u<o;u++){const y=n[u],g=s[u];if(y===0){if(l<g){d=!0;break}}else if(y===1){if(l<=g){d=!0;break}}else if(y===2){if(l>g){d=!0;break}}else if(y===3){if(l>=g){d=!0;break}}else if(l==g){d=!0;break}}d&&a.push(i)}return a}function Kr(e,t,r,n,s){const a=[];if(n==="Less than")for(let o=t;o<r;o++)e[o]-e[o-1]<s&&a.push(o);else if(n==="Less than or equal to")for(let o=t;o<r;o++)e[o]-e[o-1]<=s&&a.push(o);else if(n==="Greater than")for(let o=t;o<r;o++)e[o]-e[o-1]>s&&a.push(o);else if(n==="Greater than or equal to")for(let o=t;o<r;o++)e[o]-e[o-1]>=s&&a.push(o);else if(n==="Equal")for(let o=t;o<r;o++)e[o]-e[o-1]==s&&a.push(o);return a}function Zr(e,t,r,n,s){const a=[];if(n==="Less than")for(let o=t;o<r;o++){const i=e[o-1];(e[o]-i)/Math.abs(i)<s&&a.push(o)}else if(n==="Less than or equal to")for(let o=t;o<r;o++){const i=e[o-1];(e[o]-i)/Math.abs(i)<=s&&a.push(o)}else if(n==="Greater than")for(let o=t;o<r;o++){const i=e[o-1];(e[o]-i)/Math.abs(i)>s&&a.push(o)}else if(n==="Greater than or equal to")for(let o=t;o<r;o++){const i=e[o-1];(e[o]-i)/Math.abs(i)>=s&&a.push(o)}else if(n==="Equal")for(let o=t;o<r;o++){const i=e[o-1];(e[o]-i)/Math.abs(i)==s&&a.push(o)}return a}function en(e,t,r,n){const s=[];let a=e[t];for(let o=t+1;o<=r;o++){const i=e[o];i-a>n&&s.push(o-1,o),a=i}return s}function tn(e,t,r){const n=[];if(t>=r)return n;let s=t,a=e[t];for(let o=t+1;o<r;o++){const i=e[o];i!==a&&(n.push(s,o-s,a),s=o,a=i)}return n.push(s,r-s,a),n}function rn(e,t,r,n,s,a,o,i,l,d,u){let y=0,g=i;for(let m=a;m<=o;m++)if(n[g]=e[m],s[g]=t[m],g++,y<r.length&&m===r[y][0]){const S=r[y][0],h=r[y][1],f=e[S],b=e[h],p=t[S],E=t[h],v=b-f,A=E-p;let $=f+l;for(;$<b;)n[g]=$,s[g]=d?p+($-f)*A/v:u,g++,$+=l;y++}return g-i}function nn(e,t,r,n,s,a,o,i){let l=a,d=0,u=i;const y=r.length;for(;l<o&&d<y;){const g=r[d][0];e[l]<=g?(n[u]=e[l],s[u]=t[l],l++):(n[u]=g,s[u]=r[d][1],d++),u++}for(;l<o;)n[u]=e[l],s[u]=t[l],l++,u++;for(;d<y;)n[u]=r[d][0],s[u]=r[d][1],d++,u++;return u-i}function sn(e,t,r,n,s,a,o,i){let l=0,d=i;for(let u=a;u<=o;u++)l<r.length&&u===r[l]?l++:(n[d]=e[u],s[d]=t[u],d++);return d-i}function on(e,t,r,n){const s=r.length,a=new Array(s);if(n.isMonth)for(let o=0;o<s;o++){const i=r[o],l=new Date(e[i]);l.setMonth(l.getMonth()+n.amount),a[o]=[l.getTime(),t[i]]}else if(n.isYear)for(let o=0;o<s;o++){const i=r[o],l=new Date(e[i]);l.setFullYear(l.getFullYear()+n.amount),a[o]=[l.getTime(),t[i]]}else for(let o=0;o<s;o++){const i=r[o];a[o]=[e[i]+n.deltaMs,t[i]]}return a}function an(e,t,r){for(let n=0;n<r.length;n++){const{indexes:s,lowerIdx:a,upperIdx:o}=r[n],i=e[a],l=t[a],d=e[o],u=t[o],y=d-i,g=u-l;if(y===0){for(let m=0;m<s.length;m++)t[s[m]]=l;continue}for(let m=0;m<s.length;m++){const S=s[m];t[S]=l+(e[S]-i)*g/y}}}function cn(e,t,r){for(let n=0;n<r.length;n++){const s=r[n][0],a=r[n][1],o=r[n][2];if(a<=s)continue;const i=e[s],l=e[a]-i;if(l!==0)for(let d=s;d<a;d++)t[d]=t[d]+o*((e[d]-i)/l)}}function Vt(e,t,r,n){const s=t.length;if(r==="ADD")for(let a=0;a<s;a++)e[t[a]]=e[t[a]]+n;else if(r==="SUB")for(let a=0;a<s;a++)e[t[a]]=e[t[a]]-n;else if(r==="MULT")for(let a=0;a<s;a++)e[t[a]]=e[t[a]]*n;else if(r==="DIV")for(let a=0;a<s;a++)e[t[a]]=e[t[a]]/n;else if(r==="ASSIGN")for(let a=0;a<s;a++)e[t[a]]=n}const We="qc-utils:calibration:v1",ln=720*60*60*1e3,ye=5e4,ge=2e5,me={spawnOverheadMs:50,inlineThroughput:5e4,workerThroughput:8e4,hwConcurrency:4,measuredAt:0,userAgent:"default"};let C=mn()??me,xe=null,se=null;const Ge=new Set,Ye={[L.VALUE_THRESHOLD]:{mode:"calibrated",weight:1,rationale:"O(n) single-pass scan; baseline reference"},[L.CHANGE]:{mode:"calibrated",weight:1.1,rationale:"O(n) with one subtraction per step"},[L.RATE_OF_CHANGE]:{mode:"calibrated",weight:1.4,rationale:"O(n) with division + abs per step"},[L.FIND_GAPS]:{mode:"calibrated",weight:.9,rationale:"O(n) on X only, mostly empty output"},[L.PERSISTENCE]:{mode:"calibrated",weight:1.3,rationale:"O(n) + chunk-boundary stitch"},[L.DATETIME_RANGE]:{mode:"always-inline",weight:0,rationale:"O(log n) binary search; never worth the worker hop"},[L.SELECTION]:{mode:"always-inline",weight:0,rationale:"Pure history bookkeeping"},[k.CHANGE_VALUES]:{mode:"calibrated",weight:.7,rationale:"O(k) in-place arithmetic on selection"},[k.ASSIGN_VALUES_BULK]:{mode:"always-inline",weight:0,rationale:"Single tight loop, already inline"},[k.ASSIGN_DATETIMES_BULK]:{mode:"always-inline",weight:0,rationale:"Composes delete+add which handle their own dispatch"},[k.INTERPOLATE]:{mode:"calibrated",weight:1.5,rationale:"Linear interp per consecutive group; in-place writes"},[k.DRIFT_CORRECTION]:{mode:"calibrated",weight:1.2,rationale:"O(range total) in-place math; one pass per range"},[k.SHIFT_DATETIMES]:{mode:"calibrated",weight:1.1,rationale:"O(k) per-point shift math; inline skips SAB allocation"},[k.ADD_POINTS]:{mode:"calibrated",weight:1.8,rationale:"Single merge pass over Y/X + insertions; fresh SAB per call"},[k.DELETE_POINTS]:{mode:"calibrated",weight:1.4,rationale:"Single skip-on-delete pass over Y/X; fresh SAB per call"},[k.FILL_GAPS]:{mode:"calibrated",weight:1.3,rationale:"Single copy-with-fills pass; fresh SAB sized to newLength"}};function P(e,t){const r=Ye[e];if(!r)return{useWorker:!0,predictedInlineMs:1/0,predictedWorkerMs:0,reason:"unknown op; keeping default worker path"};if(r.mode==="always-inline")return{useWorker:!1,predictedInlineMs:0,predictedWorkerMs:0,reason:r.rationale};if(typeof SharedArrayBuffer>"u")return{useWorker:!1,predictedInlineMs:0,predictedWorkerMs:1/0,reason:"SharedArrayBuffer unavailable; forced inline"};if(r.mode==="always-worker")return{useWorker:!0,predictedInlineMs:1/0,predictedWorkerMs:0,reason:r.rationale};const n=un(e,t);if(n<=0)return{useWorker:!1,predictedInlineMs:0,predictedWorkerMs:C.spawnOverheadMs,reason:"zero work units"};const s=Math.max(1,Math.min(t.parallelism??C.hwConcurrency,C.hwConcurrency)),a=r.weight*n/C.inlineThroughput,o=C.spawnOverheadMs+r.weight*n/(C.workerThroughput*s),i=a>o;return{useWorker:i,predictedInlineMs:a,predictedWorkerMs:o,reason:i?`worker faster (${o.toFixed(1)} vs ${a.toFixed(1)} ms)`:`inline faster (${a.toFixed(1)} vs ${o.toFixed(1)} ms)`}}function un(e,t){switch(e){case k.CHANGE_VALUES:case k.INTERPOLATE:case k.SHIFT_DATETIMES:case k.DRIFT_CORRECTION:return t.selectionSize??0;case k.DELETE_POINTS:return(t.selectionSize??0)+t.datasetSize*.25;case k.ADD_POINTS:{const r=Math.max(1,Math.log2(Math.max(t.datasetSize,2)));return t.datasetSize+(t.selectionSize??0)*r}default:return t.datasetSize}}function hn(e){return Ge.add(e),()=>Ge.delete(e)}function fn(){return C}function dn(){return xe}function pn(){return Object.keys(Ye).map(e=>({op:e,...Ye[e]}))}function yn(){C=me,xe=null;try{localStorage.removeItem(We)}catch{}}async function gn(e={}){if(typeof window>"u"||!(e.force||C.measuredAt===0||Date.now()-C.measuredAt>ln))return C;if(se)await se;else{se=qt().finally(()=>{se=null});const r=await se;C=r,wn(r),xe=r;for(const n of Ge)n(C)}return C}async function qt(){if(!(typeof SharedArrayBuffer<"u"))return{...me,measuredAt:Date.now(),userAgent:navigator.userAgent,hwConcurrency:navigator.hardwareConcurrency||me.hwConcurrency,sharedArrayBufferAvailable:!1,samples:{spawnRoundtripMs:[],inlineScanMs:[],workerScanMs:[]}};const t=navigator.hardwareConcurrency||4,r=new Float32Array(ye);for(let h=0;h<ye;h++)r[h]=Math.sin(h);const n=await He(3,()=>{const h=performance.now();return Xt(r,0,ye,[2],[.5]),performance.now()-h}),s=ze(n),a=ye/Math.max(s,.001),o=new SharedArrayBuffer(256*Float32Array.BYTES_PER_ELEMENT),i=await He(3,async()=>{const h=performance.now();return await new Promise(f=>{const b=new je;b.onmessage=()=>{b.terminate(),f()},b.postMessage({bufferY:o,start:0,end:256,ops:[2],values:[.5]})}),performance.now()-h}),l=ze(i),d=new SharedArrayBuffer(ge*Float32Array.BYTES_PER_ELEMENT),u=new Float32Array(d);for(let h=0;h<ge;h++)u[h]=Math.sin(h);const y=await He(3,async()=>{const h=performance.now();return await new Promise(f=>{const b=new je;b.onmessage=()=>{b.terminate(),f()},b.postMessage({bufferY:d,start:0,end:ge,ops:[2],values:[.5]})}),performance.now()-h}),g=Math.max(ze(y)-l,.1),m=ge/g;return{spawnOverheadMs:l,inlineThroughput:a,workerThroughput:m,hwConcurrency:t,measuredAt:Date.now(),userAgent:navigator.userAgent,sharedArrayBufferAvailable:!0,samples:{spawnRoundtripMs:i,inlineScanMs:n,workerScanMs:y}}}async function He(e,t){const r=[];for(let n=0;n<e;n++)await new Promise(s=>setTimeout(s,0)),r.push(await t());return r}function ze(e){if(!e.length)return 0;const t=[...e].sort((n,s)=>n-s),r=Math.floor(t.length/2);return t.length%2?t[r]:(t[r-1]+t[r])/2}function mn(){if(typeof localStorage>"u")return null;try{const e=localStorage.getItem(We);if(!e)return null;const t=JSON.parse(e);return!t||typeof t.spawnOverheadMs!="number"?null:t}catch{return null}}function wn(e){if(!(typeof localStorage>"u"))try{const t={spawnOverheadMs:e.spawnOverheadMs,inlineThroughput:e.inlineThroughput,workerThroughput:e.workerThroughput,hwConcurrency:e.hwConcurrency,measuredAt:e.measuredAt,userAgent:e.userAgent};localStorage.setItem(We,JSON.stringify(t))}catch{}}const ee=20*1e3,bn=typeof SharedArrayBuffer<"u";function F(e,t){return bn?t!==void 0?new SharedArrayBuffer(e,{maxByteLength:t}):new SharedArrayBuffer(e):t!==void 0?new ArrayBuffer(e,{maxByteLength:t}):new ArrayBuffer(e)}function Jt(e,t){const r=e;typeof r.grow=="function"?r.grow(t):typeof r.resize=="function"&&r.resize(t)}function Sn(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}function En(e,t){switch(e){case k.ADD_POINTS:case k.FILL_GAPS:return!1;default:return!0}}class vn{dataset={source:{x:new Float64Array(F(ee*Float64Array.BYTES_PER_ELEMENT,ee*Float64Array.BYTES_PER_ELEMENT)),y:new Float32Array(F(ee*Float32Array.BYTES_PER_ELEMENT,ee*Float32Array.BYTES_PER_ELEMENT))}};history=[];redoStack=[];_isReplaying=!1;_pendingExecutionMode="inline";loadingTime=null;isLoading=!0;rawData;constructor(t){this.history=[],this.rawData=t,this.loadData(this.rawData)}async loadData(t){if(!t)return;this.isLoading=!0;const r=await pe(()=>{this._growBuffer(t.datetimes.length),this._resizeTo(t.datetimes.length),this.dataX.set(t.datetimes),this.dataY.set(t.dataValues)});this.loadingTime=r.duration,this.history.length=0,this.isLoading=!1}get dataX(){return this.dataset.source.x}get dataY(){return this.dataset.source.y}_resizeTo(t){this.dataset.source.x=new Float64Array(this.dataset.source.x.buffer).subarray(0,t),this.dataset.source.y=new Float32Array(this.dataset.source.y.buffer).subarray(0,t)}_growBuffer(t){const r=t*Float64Array.BYTES_PER_ELEMENT;let n=this.dataX.buffer.byteLength;for(;r>n;)n+=ee*Float64Array.BYTES_PER_ELEMENT;if(n*Float64Array.BYTES_PER_ELEMENT>this.dataX.buffer.maxByteLength){const s=F(this.dataX.buffer.byteLength,n*Float64Array.BYTES_PER_ELEMENT),a=F(this.dataY.buffer.byteLength,n*Float32Array.BYTES_PER_ELEMENT),o=new Float64Array(s),i=new Float32Array(a);o.set(this.dataX),i.set(this.dataY),this.dataset.source.x=o,this.dataset.source.y=i}this.dataX.buffer.byteLength<t*Float64Array.BYTES_PER_ELEMENT&&(Jt(this.dataX.buffer,t*Float64Array.BYTES_PER_ELEMENT),Jt(this.dataY.buffer,t*Float32Array.BYTES_PER_ELEMENT))}async reload(){this.loadingTime=null,this.isLoading=!0,this.history.length=0,await this.loadData(this.rawData)}async reloadHistory(t){const r=this.history.slice(0,t+1);return this.redoStack.length=0,await this.reload(),await this.dispatch(r.map(n=>[n.method,...n.args||[]]))}async removeHistoryItem(t){const r=[...this.history];return r.splice(t,1),this.redoStack.length=0,await this.reload(),await this.dispatch(r.map(n=>[n.method,...n.args||[]]))}async undo(){if(!this.history.length)return[];const t=this.history[this.history.length-1],r=this.history.slice(0,-1);await this.reload(),this.redoStack.push(t),this._isReplaying=!0;try{return await this.dispatch(r.map(n=>[n.method,...n.args||[]]))}finally{this._isReplaying=!1}}async redo(){if(!this.redoStack.length)return[];const t=this.redoStack.pop();this._isReplaying=!0;try{return await this.dispatch([[t.method,...t.args||[]]])}finally{this._isReplaying=!1}}get beginTime(){return this.dataset.source.x.length?new Date(this.dataset.source.x[0]):null}get endTime(){return this.dataset.source.x.length?new Date(this.dataset.source.x[this.dataset.source.x.length-1]):null}async dispatchAction(t,...r){const n={[k.ADD_POINTS]:this._addDataPoints,[k.CHANGE_VALUES]:this._changeValues,[k.ASSIGN_VALUES_BULK]:this._assignValuesBulk,[k.DELETE_POINTS]:this._deleteDataPointsFromSelection,[k.DRIFT_CORRECTION]:this._driftCorrectionFromSelection,[k.INTERPOLATE]:this._interpolateFromSelection,[k.SHIFT_DATETIMES]:this._shiftFromSelection,[k.ASSIGN_DATETIMES_BULK]:this._assignDatetimesBulk,[k.FILL_GAPS]:this._fillGaps};let s=[],a=null;try{this._isReplaying||(this.redoStack.length=0),a={method:t,args:r,isLoading:!0},this.history.push(a),En(t,r)||this.history[this.history.length-2]?.method===L.SELECTION&&this.history.splice(this.history.length-2,1),this._pendingExecutionMode="inline";const o=await pe(async()=>await n[t].apply(this,r));s=o.response;const i=this.history.indexOf(a),l=i>=0?this.history[i]:void 0;l&&(l.duration=o.duration,l.executionMode=this._pendingExecutionMode,l.status="success",l.isLoading=!1)}catch{if(a){const i=this.history.indexOf(a),l=i>=0?this.history[i]:void 0;l&&(l.status="failed",l.isLoading=!1)}}return s}async dispatch(t,...r){const n=async(s,a)=>L[s]?await this.dispatchFilter(s,...a):await this.dispatchAction(s,...a);if(Array.isArray(t)){let s=[];for(let a=0;a<t.length;a++){const o=t[a][0],i=t[a].slice(1,t[a].length);s=await n(o,i)}return s}else return await n(t,r)}async dispatchFilter(t,...r){const n={[L.FIND_GAPS]:this._findGaps,[L.VALUE_THRESHOLD]:this._valueThreshold,[L.DATETIME_RANGE]:this._datetimeRange,[L.PERSISTENCE]:this._persistence,[L.CHANGE]:this._change,[L.RATE_OF_CHANGE]:this._rateOfChange,[L.SELECTION]:this._selection};let s=[],a=null;try{const o=t===L.SELECTION,i=o&&(!r[0]||Array.isArray(r[0])&&r[0].length===0);!this._isReplaying&&!i&&(this.redoStack.length=0),a={method:t,args:r,isLoading:!0};const l=this.history[this.history.length-1],d=!!L[l?.method],u=l?.method===t||d&&!o;let y;u?(y=this.history.length-1,this.history[y]=a):(this.history.push(a),y=this.history.length-1),this._pendingExecutionMode="inline";const g=await pe(async()=>await n[t].apply(this,r));s=g.response;const m=this.history.indexOf(a),S=m>=0?this.history[m]:void 0;S&&(S.duration=g.duration,S.executionMode=this._pendingExecutionMode,S.selected=g.response,S.status="success",S.isLoading=!1)}catch(o){if(console.log(`Failed to execute filter operation: ${t} with arguments: `,r),console.log(o),a){const i=this.history.indexOf(a),l=i>=0?this.history[i]:void 0;l&&(l.status="failed",l.isLoading=!1)}}return s}async _changeValues(t,r){const n=this.history[this.history.length-2]?.selected;if(!n||n.length===0)return[];const s=n.length;if(!P(k.CHANGE_VALUES,{datasetSize:this.dataset.source.y.length,selectionSize:s}).useWorker)return Vt(this.dataY,n,t,r),[];this._pendingExecutionMode="worker";const o=Math.min(navigator.hardwareConcurrency||1,s),i=Math.ceil(s/o),l=[],d=[];for(let u=0;u<o;u++){const y=u*i,g=Math.min((u+1)*i,s);if(y>=g)break;const m=n.slice(y,g);d.push(new Promise(S=>{const h=new Qr;l.push(h),h.postMessage({bufferY:this.dataY.buffer,indexes:m,operator:t,value:r}),h.onmessage=f=>{S(f.data)}}))}return await Promise.all(d),l.forEach(u=>u.terminate()),[]}_applyOperatorInPlace(t,r,n){Vt(this.dataY,t,r,n)}async _assignValuesBulk(t){const r=this.history[this.history.length-2]?.selected;if(!r||!r.length||!t?.length)return[];const n=Math.min(r.length,t.length),s=this.dataY;for(let a=0;a<n;a++)s[r[a]]=t[a];return[]}async _assignDatetimesBulk(t){const r=this.history[this.history.length-2]?.selected;if(!r||!r.length||!t?.length)return[];const n=Math.min(r.length,t.length),s=new Array(n),a=new Array(n);for(let o=0;o<n;o++)s[o]=[t[o],this.dataY[r[o]]],a[o]=r[o];return a.sort((o,i)=>o-i),await this._deleteDataPoints(a),await this._addDataPoints(s),[]}async _interpolateFromSelection(){const t=this.history[this.history.length-2]?.selected;if(!(!t||t.length===0))return this._interpolate(t)}async _interpolate(t){const r=this._getConsecutiveGroups(t);if(r.length===0||r[0].length===0)return;const n=this.dataset.source.y.length,s=r.map(u=>({indexes:u,lowerIdx:Math.max(0,u[0]-1),upperIdx:Math.min(n-1,u[u.length-1]+1)}));if(!P(k.INTERPOLATE,{datasetSize:n,selectionSize:t.length}).useWorker){an(this.dataX,this.dataY,s);return}this._pendingExecutionMode="worker";const o=Math.min(navigator.hardwareConcurrency||1,s.length),i=Math.ceil(s.length/o),l=[],d=[];for(let u=0;u<o;u++){const y=s.slice(u*i,(u+1)*i);if(y.length===0)break;d.push(new Promise(g=>{const m=new Gr;l.push(m),m.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,groups:y}),m.onmessage=S=>{g(S.data)}}))}await Promise.all(d),l.forEach(u=>u.terminate())}async _shiftFromSelection(t,r){const n=this.history[this.history.length-2]?.selected;return!n||n.length===0?[]:await this._shift(n,t,r)??[]}async _shift(t,r,n){if(t.length===0)return[];const s=n===M.MONTH,a=n===M.YEAR,o=!s&&!a?r*ne[n]*1e3:0,i=t.length;if(!P(k.SHIFT_DATETIMES,{datasetSize:this.dataset.source.x.length,selectionSize:i}).useWorker){const p=on(this.dataX,this.dataY,t,{amount:r,isMonth:s,isYear:a,deltaMs:o});return await this._deleteDataPoints(t),await this._addDataPoints(p)??[]}this._pendingExecutionMode="worker";const d=F(i*Float64Array.BYTES_PER_ELEMENT),u=F(i*Float32Array.BYTES_PER_ELEMENT),y=Math.min(navigator.hardwareConcurrency||1,i),g=Math.ceil(i/y),m=[],S=[];for(let p=0;p<y;p++){const E=p*g,v=Math.min((p+1)*g,i);if(E>=v)break;const A=t.slice(E,v);S.push(new Promise($=>{const R=new zr;m.push(R),R.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,outputBufferX:d,outputBufferY:u,indexes:A,outStart:E,amount:r,isMonth:s,isYear:a,deltaMs:o}),R.onmessage=O=>{$(O.data)}}))}await Promise.all(S),m.forEach(p=>p.terminate());const h=new Float64Array(d),f=new Float32Array(u),b=new Array(i);for(let p=0;p<i;p++)b[p]=[h[p],f[p]];return await this._deleteDataPoints(t),await this._addDataPoints(b)??[]}async _fillGaps(t,r,n,s,a){const o=this.dataX.length;if(o===0)return[];const i=t[0]*ne[t[1]]*1e3,l=r[0]*ne[r[1]]*1e3,d=this.dataX,u=a?.[0]!=null&&Number.isFinite(a[0])?j(d,a[0]):0,y=a?.[1]!=null&&Number.isFinite(a[1])?W(d,a[1]):o-1,g=[],m=[];let S=0;for(let _=u+1;_<=y;_++)if(d[_]-d[_-1]>i){let N=0,x=d[_-1]+l;for(;x<d[_];)N++,x+=l;N>0&&(g.push([_-1,_]),m.push(N),S+=N)}if(S===0)return[];const h=new Array(S);let f=0,b=0;for(let _=0;_<g.length;_++){const G=g[_][0],N=m[_];for(let x=1;x<=N;x++)h[b++]=G+f+x;f+=N}const p=o+S,E=p*Float64Array.BYTES_PER_ELEMENT,v=p*Float32Array.BYTES_PER_ELEMENT,A=F(E,Math.max(this.dataX.buffer.maxByteLength,E)),$=F(v,Math.max(this.dataY.buffer.maxByteLength,v));if(!P(k.FILL_GAPS,{datasetSize:o,selectionSize:S}).useWorker){const _=new Float64Array(A),G=new Float32Array($);return rn(this.dataX,this.dataY,g,_,G,0,o-1,0,l,n,s),this.dataset.source.x=_,this.dataset.source.y=G,this._resizeTo(p),h}this._pendingExecutionMode="worker";const O=navigator.hardwareConcurrency||1,Qt=Math.ceil(o/O),Xe=[];let ae=0;for(let _=0;_<O;_++){const G=_*Qt,N=Math.min((_+1)*Qt-1,o-1),x=[];let we=0;for(;ae<g.length&&g[ae][0]<=N;)x.push(g[ae]),we+=m[ae],ae++;Xe.push({start:G,end:N,gapsSegment:x,fillsInSegment:we})}const Ve=new Array(O).fill(0);for(let _=1;_<O;_++)Ve[_]=Ve[_-1]+Xe[_-1].fillsInSegment;const Kt=[],Zt=[];for(let _=0;_<O;_++){const{start:G,end:N,gapsSegment:x}=Xe[_],we=G+Ve[_];Zt.push(new Promise(Ln=>{const qe=new xr;Kt.push(qe),qe.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,outputBufferX:A,outputBufferY:$,start:G,end:N,gapsSegment:x,startTarget:we,fillDelta:l,interpolate:n,fillValue:s}),qe.onmessage=$n=>{Ln($n.data)}}))}return await Promise.all(Zt),Kt.forEach(_=>_.terminate()),this.dataset.source.x=new Float64Array(A),this.dataset.source.y=new Float32Array($),this._resizeTo(p),h}async _deleteDataPointsFromSelection(){const t=this.history[this.history.length-2]?.selected;if(!(!t||t.length===0))return this._deleteDataPoints(t)}async _deleteDataPoints(t){const r=this.dataX.length,n=r-t.length;if(!P(k.DELETE_POINTS,{datasetSize:r,selectionSize:t.length}).useWorker){const m=F(this.dataX.buffer.byteLength,this.dataX.buffer.maxByteLength),S=F(this.dataY.buffer.byteLength,this.dataY.buffer.maxByteLength),h=new Float64Array(m),f=new Float32Array(S);sn(this.dataX,this.dataY,t,h,f,0,r-1,0),this.dataset.source.x=h,this.dataset.source.y=f,this._resizeTo(n);return}this._pendingExecutionMode="worker";const a=navigator.hardwareConcurrency||1,o=Math.ceil(this.dataX.length/a),i=[],l=[];for(let m=0;m<a;m++){const S=m*o,h=Math.min((m+1)*o-1,this.dataX.length-1),f=j(t,S),b=W(t,h),p=t.slice(f,b+1);l.push({start:S,end:h,deleteSegment:p})}const d=new Array(a).fill(0);for(let m=1;m<a;m++)d[m]=d[m-1]+l[m-1].deleteSegment.length;const u=[],y=F(this.dataX.buffer.byteLength,this.dataX.buffer.maxByteLength),g=F(this.dataY.buffer.byteLength,this.dataY.buffer.maxByteLength);for(let m=0;m<a;m++){const{start:S,end:h,deleteSegment:f}=l[m],b=S-d[m];u.push(new Promise(p=>{const E=new Wr;i.push(E),E.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,outputBufferX:y,outputBufferY:g,start:S,end:h,deleteSegment:f,startTarget:b}),E.onmessage=v=>{p(v.data)}}))}await Promise.all(u),i.forEach(m=>m.terminate()),this.dataset.source.x=new Float64Array(y),this.dataset.source.y=new Float32Array(g),this._resizeTo(n)}async _driftCorrectionFromSelection(t){const r=this.history[this.history.length-2]?.selected;if(!r||r.length===0)return;const n=this._getConsecutiveGroups(r),s=[];for(const a of n)a.length!==0&&s.push([a[0],a[a.length-1],t]);if(s.length!==0)return this._driftCorrection(s)}async _driftCorrection(t){if(!t||t.length===0)return;const r=this.dataset.source.x,n=navigator.hardwareConcurrency||1;let s=0;for(const[y,g]of t)g>y&&(s+=g-y);if(!P(k.DRIFT_CORRECTION,{datasetSize:r.length,selectionSize:s}).useWorker){cn(r,this.dataY,t);return}this._pendingExecutionMode="worker";const o=[];for(const[y,g,m]of t){if(g<=y)continue;const S=r[y],h=r[g]-S;if(h===0)continue;const f=g-y,b=Math.max(1,Math.ceil(f/n));for(let p=y;p<g;p+=b)o.push({chunkStart:p,chunkEnd:Math.min(p+b,g),startDatetime:S,value:m,extent:h})}if(o.length===0)return;const i=Math.min(n,o.length),l=Array.from({length:i},()=>[]);o.forEach((y,g)=>l[g%i].push(y));const d=[],u=[];for(const y of l)y.length!==0&&u.push(new Promise(g=>{const m=new Yr;d.push(m),m.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,jobs:y}),m.onmessage=S=>{g(S.data)}}));await Promise.all(u),d.forEach(y=>y.terminate())}_getConsecutiveGroups(t){const r=[[]];return t.reduce((n,s)=>{const a=n[n.length-1];return!a.length||s==a[a.length-1]+1?a.push(s):n.push([s]),n},r),r}async _addDataPoints(t){if(t.length===0)return[];const r=this.dataX.length,n=r+t.length;t.sort((h,f)=>h[0]-f[0]);const s=new Array(t.length);for(let h=0;h<t.length;h++){const f=t[h][0],b=W(this.dataX,f)+1;s[h]=b+h}const a=n*Float64Array.BYTES_PER_ELEMENT,o=n*Float32Array.BYTES_PER_ELEMENT,i=F(a,Math.max(this.dataX.buffer.maxByteLength,a)),l=F(o,Math.max(this.dataY.buffer.maxByteLength,o));if(!P(k.ADD_POINTS,{datasetSize:r,selectionSize:t.length}).useWorker){const h=new Float64Array(i),f=new Float32Array(l);return nn(this.dataX,this.dataY,t,h,f,0,r,0),this.dataset.source.x=h,this.dataset.source.y=f,this._resizeTo(n),s}this._pendingExecutionMode="worker";const u=t.map(h=>W(this.dataX,h[0])+1),y=Math.max(1,Math.min(navigator.hardwareConcurrency||1,Math.max(r,1))),g=Math.ceil(Math.max(r,1)/y),m=[],S=[];for(let h=0;h<y;h++){const f=h*g,b=Math.min((h+1)*g,r),p=j(u,f),E=h===y-1?t.length:j(u,b),v=t.slice(p,E),A=f+p;f>=b&&v.length===0||S.push(new Promise($=>{const R=new Hr;m.push(R),R.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,outputBufferX:i,outputBufferY:l,origStart:f,origEnd:b,insertions:v,outStart:A}),R.onmessage=O=>{$(O.data)}}))}return await Promise.all(S),m.forEach(h=>h.terminate()),this.dataset.source.x=new Float64Array(i),this.dataset.source.y=new Float32Array(l),this._resizeTo(n),s}async _valueThreshold(t,r){const n=Object.keys(t);if(n.length===0)return[];const s={[X.LT]:0,[X.LTE]:1,[X.GT]:2,[X.GTE]:3,[X.E]:4},a=n.map(E=>s[E]??4),o=n.map(E=>t[E]),i=this.dataset.source.y,l=this.dataset.source.x;let d=0,u=i.length;if(u===0)return[];if(r!=null){const[E,v]=r;E!=null&&Number.isFinite(E)&&(d=j(l,E)),v!=null&&Number.isFinite(v)&&(u=W(l,v)+1)}if(u<=d)return[];const y=u-d;if(!P(L.VALUE_THRESHOLD,{datasetSize:y}).useWorker)return Xt(i,d,u,a,o);this._pendingExecutionMode="worker";const m=Math.min(navigator.hardwareConcurrency||1,y),S=Math.ceil(y/m),h=[],f=[];for(let E=0;E<m;E++){const v=d+E*S,A=Math.min(d+(E+1)*S,u);if(v>=A)break;f.push(new Promise($=>{const R=new je;h.push(R),R.postMessage({bufferY:this.dataY.buffer,start:v,end:A,ops:a,values:o}),R.onmessage=O=>{$(O.data)}}))}const b=await Promise.all(f);h.forEach(E=>E.terminate());const p=[];for(let E=0;E<b.length;E++){const v=b[E];for(let A=0;A<v.length;A++)p.push(v[A])}return p}async _rateOfChange(t,r,n){const s=this.dataset.source.y,a=this.dataset.source.x;if(s.length<2)return[];let o=1,i=s.length;if(n!=null){const[f,b]=n;f!=null&&Number.isFinite(f)&&(o=Math.max(1,j(a,f))),b!=null&&Number.isFinite(b)&&(i=W(a,b)+1)}if(i<=o)return[];const l=i-o;if(!P(L.RATE_OF_CHANGE,{datasetSize:s.length}).useWorker)return Zr(s,o,i,t,r);this._pendingExecutionMode="worker";const u=Math.min(navigator.hardwareConcurrency||1,l),y=Math.ceil(l/u),g=[],m=[];for(let f=0;f<u;f++){const b=o+f*y,p=Math.min(o+(f+1)*y,i);if(b>=p)break;m.push(new Promise(E=>{const v=new Jr;g.push(v),v.postMessage({bufferY:this.dataY.buffer,start:b,end:p,comparator:t,value:r}),v.onmessage=A=>{E(A.data)}}))}const S=await Promise.all(m);g.forEach(f=>f.terminate());const h=[];for(let f=0;f<S.length;f++){const b=S[f];for(let p=0;p<b.length;p++)h.push(b[p])}return h}async _datetimeRange(t,r){const n=this.dataset.source.x,s=n.length;if(s===0)return[];const a=t==null?0:j(n,t),o=r==null?s-1:W(n,r);if(a>o)return[];const i=new Array(o-a+1);for(let l=a;l<=o;l++)i[l-a]=l;return i}async _selection(t){const r=this.history[this.history.length-2],n=!!r&&r.method!==L.SELECTION&&!!L[r.method],s=n&&Array.isArray(r.selected)?r.selected:void 0;return!t||!t.length?(this.history.pop(),s&&s.length>0&&this.history.pop(),t):(s&&Sn(s,t)?this.history.pop():n&&this.history.splice(this.history.length-2,1),t)}async _change(t,r,n){const s=this.dataset.source.y,a=this.dataset.source.x;if(s.length<2)return[];let o=1,i=s.length;if(n!=null){const[f,b]=n;f!=null&&Number.isFinite(f)&&(o=Math.max(1,j(a,f))),b!=null&&Number.isFinite(b)&&(i=W(a,b)+1)}if(i<=o)return[];const l=i-o;if(!P(L.CHANGE,{datasetSize:s.length}).useWorker)return Kr(s,o,i,t,r);this._pendingExecutionMode="worker";const u=Math.min(navigator.hardwareConcurrency||1,l),y=Math.ceil(l/u),g=[],m=[];for(let f=0;f<u;f++){const b=o+f*y,p=Math.min(o+(f+1)*y,i);if(b>=p)break;m.push(new Promise(E=>{const v=new qr;g.push(v),v.postMessage({bufferY:this.dataY.buffer,start:b,end:p,comparator:t,value:r}),v.onmessage=A=>{E(A.data)}}))}const S=await Promise.all(m);g.forEach(f=>f.terminate());const h=[];for(let f=0;f<S.length;f++){const b=S[f];for(let p=0;p<b.length;p++)h.push(b[p])}return h}async _findGaps(t,r,n){const s=this.dataset.source.x;let a=0,o=s.length;if(n!=null){const[f,b]=n;f!=null&&Number.isFinite(f)&&(a=j(s,f)),b!=null&&Number.isFinite(b)&&(o=W(s,b)+1)}if(o<=a)return[];const i=t*ne[r]*1e3;if(!P(L.FIND_GAPS,{datasetSize:o-a}).useWorker){const f=en(s,a,o-1,i),b=new Set;for(let p=0;p<f.length;p++)b.add(f[p]);return[...b]}this._pendingExecutionMode="worker";const d=o-a,u=Math.min(navigator.hardwareConcurrency||1,d),y=Math.ceil(d/u),g=[],m=[];for(let f=0;f<u;f++){const b=a+f*y,p=Math.min(a+(f+1)*y,o);if(b>=p)break;m.push(new Promise(E=>{const v=new Xr;g.push(v),v.postMessage({bufferX:this.dataX.buffer,start:b,endInclusive:p,threshold:i}),v.onmessage=A=>{E(A.data)}}))}const S=await Promise.all(m);g.forEach(f=>f.terminate());const h=new Set;for(let f=0;f<S.length;f++){const b=S[f];for(let p=0;p<b.length;p++)h.add(b[p])}return[...h]}async _persistence(t,r){const n=this.dataset.source.x,s=this.dataset.source.y;let a=0,o=s.length;if(r!=null){const[p,E]=r;p!=null&&Number.isFinite(p)&&(a=j(n,p)),E!=null&&Number.isFinite(E)&&(o=W(n,E)+1)}if(o<=a)return[];const i=o-a;if(!P(L.PERSISTENCE,{datasetSize:i}).useWorker){const p=tn(s,a,o),E=[];for(let v=0;v<p.length;v+=3){const A=p[v],$=p[v+1];if($>=t)for(let R=0;R<$;R++)E.push(A+R)}return E}this._pendingExecutionMode="worker";const d=Math.min(navigator.hardwareConcurrency||1,i),u=Math.ceil(i/d),y=[],g=[];for(let p=0;p<d;p++){const E=a+p*u,v=Math.min(a+(p+1)*u,o);if(E>=v)break;g.push(new Promise(A=>{const $=new Vr;y.push($),$.postMessage({bufferY:this.dataY.buffer,start:E,end:v}),$.onmessage=R=>{A(R.data)}}))}const m=await Promise.all(g);y.forEach(p=>p.terminate());const S=[],h=[],f=[];for(let p=0;p<m.length;p++){const E=m[p];for(let v=0;v<E.length;v+=3){const A=E[v],$=E[v+1],R=E[v+2],O=S.length-1;O>=0&&f[O]===R&&S[O]+h[O]===A?h[O]+=$:(S.push(A),h.push($),f.push(R))}}const b=[];for(let p=0;p<S.length;p++){const E=h[p];if(E>=t){const v=S[p];for(let A=0;A<E;A++)b.push(v+A)}}return b}}const oe="1",kn=new Set([...Object.values(k),...Object.values(L)]);function _n(e,t){const r=e.history.map(n=>{const s={method:n.method,args:n.args?[...n.args]:[]};return n.status==="failed"&&(s.status="failed"),s});return{version:oe,createdAt:new Date().toISOString(),window:{startDate:t.startDate,endDate:t.endDate},operations:r}}function An(e){if(!e||typeof e!="object")throw new Error("QC script must be a JSON object.");const t=e;if(t.version!==oe)throw new Error(`Unsupported QC script version: ${String(t.version)}. This loader understands version "${oe}".`);if(typeof t.createdAt!="string")throw new Error("QC script is missing `createdAt` (ISO-8601 string).");const r=t.window;if(!r||typeof r!="object")throw new Error("QC script is missing `window`.");if(typeof r.startDate!="string"||typeof r.endDate!="string")throw new Error("`window.startDate` and `window.endDate` must be ISO-8601 strings.");if(!Array.isArray(t.operations))throw new Error("QC script `operations` must be an array.");const n=t.operations.map((s,a)=>{if(!s||typeof s!="object")throw new Error(`Operation ${a} must be an object.`);const o=s;if(typeof o.method!="string")throw new Error(`Operation ${a} missing string \`method\`.`);if(!kn.has(o.method))throw new Error(`Operation ${a} has unknown method: "${o.method}".`);if(!Array.isArray(o.args))throw new Error(`Operation ${a} \`args\` must be an array.`);const i={method:o.method,args:[...o.args]};return o.status==="failed"&&(i.status="failed"),i});return{version:oe,createdAt:t.createdAt,window:{startDate:r.startDate,endDate:r.endDate},operations:n}}async function Tn(e,t){e.history.length=0,e.redoStack.length=0,await e.reload();const r={applied:0,failed:[]};for(let n=0;n<t.operations.length;n++){const s=t.operations[n];try{await e.dispatch(s.method,...s.args),e.history[e.history.length-1]?.status==="failed"?r.failed.push({index:n,method:s.method,error:"Operation handler reported failure (see console)."}):r.applied++}catch(a){r.failed.push({index:n,method:s.method,error:a instanceof Error?a.message:String(a)})}}return r}w.ACCOUNT_BASE=B,w.AUTH_BASE=he,w.ApiKey=hr,w.BASE_URL=D,w.Collaborator=dr,w.DEFAULT_SNACK_DURATION=Re,w.DataSource=Or,w.Datastream=rr,w.EnumEditOperations=k,w.EnumFilterOperations=L,w.FilterOperation=X,w.HydroShareArchive=Ke,w.INCREASE_AMOUNT=ee,w.Location=Ze,w.LogicalOperation=Qe,w.OAuthProvider=ur,w.ObservationRecord=vn,w.ObservedProperty=or,w.Operator=Je,w.Organization=cr,w.PROVIDER_BASE=te,w.Payload=Cr,w.PermissionAction=et,w.PermissionResource=tt,w.Position=dt,w.PostHydroShareArchive=er,w.ProcessingLevel=ar,w.QC_SCRIPT_VERSION=oe,w.ResultQualifier=ir,w.SESSION_BASE=fe,w.Sensor=sr,w.Snack=pt,w.SnackColor=Ie,w.SnackIcon=Oe,w.SnackTitle=Ue,w.Snackbar=yt,w.TAG_BASE=Pe,w.THINGS_BASE=T,w.Thing=tr,w.TimeUnit=M,w.Unit=nr,w.User=lr,w.Workspace=fr,w.api=Mr,w.apiMethods=c,w.applyScript=Tn,w.clearCalibration=yn,w.createPatchObject=Me,w.ensureCalibration=gn,w.extractErrorMessage=rt,w.findFirstGreaterOrEqual=j,w.findLastLessOrEqual=W,w.formatDate=Nr,w.formatDuration=Br,w.getCSRFToken=be,w.getCalibration=fn,w.getLastBenchmarkDetail=dn,w.getObservationsEndpoint=Ur,w.getOperationTable=pn,w.measureEllapsedTime=pe,w.onCalibrationChange=hn,w.parseScript=An,w.requestInterceptor=Se,w.responseInterceptor=Ee,w.runBenchmarks=qt,w.serializeHistory=_n,w.shouldUseWorker=P,w.subtractHours=jr,w.timeUnitMultipliers=ne,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})}));
@@ -9,7 +9,6 @@ export declare const INCREASE_AMOUNT: number;
9
9
  export declare class ObservationRecord {
10
10
  /** The generated dataset to be used for plotting */
11
11
  dataset: {
12
- dimensions: string[];
13
12
  source: {
14
13
  x: Float64Array<ArrayBufferLike>;
15
14
  y: Float32Array<ArrayBufferLike>;
@@ -72,14 +71,13 @@ export declare class ObservationRecord {
72
71
  */
73
72
  reload(): Promise<void>;
74
73
  /**
75
- * @param index
76
- * @returns
74
+ * Truncate history at `index` (inclusive), reload from raw, and
75
+ * replay the surviving entries. Used by the "Reload from this step"
76
+ * button in EditHistory.
77
77
  */
78
78
  reloadHistory(index: number): Promise<number[]>;
79
- /**
80
- * Remove a history item
81
- * @param index
82
- */
79
+ /** Splice the history entry at `index`, reload from raw, and replay
80
+ * the survivors. */
83
81
  removeHistoryItem(index: number): Promise<number[]>;
84
82
  /**
85
83
  * Undo the most recent history entry. Pushes it onto `redoStack` so a
@@ -113,12 +111,6 @@ export declare class ObservationRecord {
113
111
  dispatch(actions: EnumEditOperations | EnumFilterOperations | [EnumEditOperations | EnumFilterOperations, ...any][], ...args: any): Promise<number[]>;
114
112
  /** Filter operations do not transform the data and return a selection */
115
113
  dispatchFilter(action: EnumFilterOperations, ...args: any): Promise<number[]>;
116
- /**
117
- * @param index An array containing the list of index of values to perform the operations on.
118
- * @param operator The operator that will be applied
119
- * @param value The value to use in the operation
120
- * @returns an array of index values to keep selected in the plot
121
- */
122
114
  /**
123
115
  * Multi-threaded apply of an arithmetic operator to Y at the previously-filtered selection.
124
116
  * 1. Selection is read from the previous history entry (the last entry is this operation itself).
@@ -186,13 +178,15 @@ export declare class ObservationRecord {
186
178
  */
187
179
  private _shift;
188
180
  /**
189
- * Multi-threaded version of {@link _fillGaps}.
181
+ * Detect gaps in the configured window and insert fill points using
182
+ * either linear interpolation or a sentinel `fillValue`. Inline path:
183
+ * single copy-with-fills sweep into freshly-allocated x/y buffers.
184
+ * Worker path:
190
185
  * 1. The main thread scans once for gaps and computes the number of fill points per gap.
191
186
  * 2. The original array is split into equal segments; each gap is assigned to the segment containing its left index.
192
187
  * 3. Cumulative fill counts before each segment give each worker's output startTarget, ensuring no overlap.
193
188
  * 4. Each worker copies its segment to the output buffer and inserts its gap fills inline.
194
- */
195
- /**
189
+ *
196
190
  * @param range Optional `[startTs, endTs]` window in epoch
197
191
  * milliseconds. Both bounds inclusive; snapped to the nearest
198
192
  * enclosed point via binary search. Datetime-addressed (not
@@ -209,12 +203,12 @@ export declare class ObservationRecord {
209
203
  */
210
204
  private _deleteDataPointsFromSelection;
211
205
  /**
212
- Deletes data points from a large array using worker threads.
213
- 1. The main thread divides the original array into equal parts to distribute work among workers.
214
- 2. For each segment, binary search locates the indexes to delete (deleteSegment), ensuring efficient lookups.
215
- 3. The cumulative deletions before each segment help compute the starting index (startTarget) for each worker's output, ensuring no overlap.
216
- 4. Each worker processes its segment linearly, skipping deletions and copying kept elements to their computed positions.
217
- * @param deleteIndices
206
+ * Delete points by ascending `deleteIndices` from x/y. Inline path
207
+ * runs a single skip-on-delete copy on the main thread; worker path:
208
+ * 1. Main thread splits the original array into equal segments.
209
+ * 2. Per-segment binary search locates the indexes to delete (deleteSegment) for efficient lookups.
210
+ * 3. Cumulative deletions before each segment give each worker's output startTarget so segments don't overlap.
211
+ * 4. Each worker walks its segment linearly, skipping deletions and copying kept elements into place.
218
212
  */
219
213
  private _deleteDataPoints;
220
214
  /**
@@ -227,12 +221,6 @@ export declare class ObservationRecord {
227
221
  * can still use it directly.
228
222
  */
229
223
  private _driftCorrectionFromSelection;
230
- /**
231
- *
232
- * @param start The start index
233
- * @param end The end index
234
- * @param value The drift amount
235
- */
236
224
  /**
237
225
  * Multi-threaded drift correction over one or more [start, end, value] ranges.
238
226
  * 1. Main thread reads each range's anchors (startDatetime, extent) once and chunks the range.
@@ -255,11 +243,6 @@ export declare class ObservationRecord {
255
243
  * 4. Each worker linearly merges its original slice with its insertion slice (both already sorted by datetime) into the output buffer. Originals win on datetime ties, matching the original `findLastLessOrEqual` semantics.
256
244
  */
257
245
  private _addDataPoints;
258
- /**
259
- * Filter by applying a set of logical operations
260
- * @param appliedFilters
261
- * @returns an array of index values to select in the plot
262
- */
263
246
  /**
264
247
  * Filter by applying a set of logical operations, using worker threads.
265
248
  * 1. Main thread encodes filters as numeric opcodes + thresholds (cheaper than string compares in the hot loop).
@@ -269,12 +252,6 @@ export declare class ObservationRecord {
269
252
  * Opcodes: 0=LT, 1=LTE, 2=GT, 3=GTE, 4=E.
270
253
  */
271
254
  private _valueThreshold;
272
- /**
273
- *
274
- * @param comparator
275
- * @param value
276
- * @returns
277
- */
278
255
  /**
279
256
  * Find points where the relative rate `(curr - prev) / |prev|` satisfies the comparator, using worker threads.
280
257
  * 1. Main thread partitions scan range [1, dataY.length) into chunks; `Y[i-1]` is safely read from the shared buffer across chunk boundaries.
@@ -315,12 +292,6 @@ export declare class ObservationRecord {
315
292
  * the script would grow a phantom SELECTION after every real filter.
316
293
  */
317
294
  private _selection;
318
- /**
319
- *
320
- * @param comparator
321
- * @param value
322
- * @returns
323
- */
324
295
  /**
325
296
  * Find points where the change from the previous value satisfies the comparator, using worker threads.
326
297
  * 1. Main thread partitions scan range [1, dataY.length) into chunks (each chunk's first index safely reads Y[i-1] from the shared buffer).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uwrl/qc-utils",
3
- "version": "0.0.22",
3
+ "version": "0.0.23",
4
4
  "description": "Quality Control Utilities",
5
5
  "homepage": "https://github.com/hydroserver2/qc-utils#readme",
6
6
  "bugs": {