@placeos/ts-client 4.2.1 → 4.2.2

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.es.js CHANGED
@@ -41,15 +41,15 @@ function Wr(t, e, n, r) {
41
41
  function u(_) {
42
42
  try {
43
43
  l(r.next(_));
44
- } catch (b) {
45
- s(b);
44
+ } catch (v) {
45
+ s(v);
46
46
  }
47
47
  }
48
48
  function c(_) {
49
49
  try {
50
50
  l(r.throw(_));
51
- } catch (b) {
52
- s(b);
51
+ } catch (v) {
52
+ s(v);
53
53
  }
54
54
  }
55
55
  function l(_) {
@@ -161,7 +161,7 @@ function Hr(t, e, n) {
161
161
  }, i;
162
162
  function s(a) {
163
163
  return function(h) {
164
- return Promise.resolve(h).then(a, b);
164
+ return Promise.resolve(h).then(a, v);
165
165
  };
166
166
  }
167
167
  function u(a, h) {
@@ -179,12 +179,12 @@ function Hr(t, e, n) {
179
179
  }
180
180
  }
181
181
  function l(a) {
182
- a.value instanceof Ae ? Promise.resolve(a.value.v).then(_, b) : p(o[0][2], a);
182
+ a.value instanceof Ae ? Promise.resolve(a.value.v).then(_, v) : p(o[0][2], a);
183
183
  }
184
184
  function _(a) {
185
185
  c("next", a);
186
186
  }
187
- function b(a) {
187
+ function v(a) {
188
188
  c("throw", a);
189
189
  }
190
190
  function p(a, h) {
@@ -268,11 +268,11 @@ var ge = function() {
268
268
  } catch (f) {
269
269
  o = f instanceof Yt ? f.errors : [f];
270
270
  }
271
- var b = this._finalizers;
272
- if (b) {
271
+ var v = this._finalizers;
272
+ if (v) {
273
273
  this._finalizers = null;
274
274
  try {
275
- for (var p = Oe(b), a = p.next(); !a.done; a = p.next()) {
275
+ for (var p = Oe(v), a = p.next(); !a.done; a = p.next()) {
276
276
  var h = a.value;
277
277
  try {
278
278
  Sn(h);
@@ -1037,7 +1037,7 @@ function yi(t, e) {
1037
1037
  function gi(t, e) {
1038
1038
  return ie(t).pipe(ur(e), sr(e));
1039
1039
  }
1040
- function vi(t, e) {
1040
+ function bi(t, e) {
1041
1041
  return new q(function(n) {
1042
1042
  var r = 0;
1043
1043
  return e.schedule(function() {
@@ -1045,7 +1045,7 @@ function vi(t, e) {
1045
1045
  });
1046
1046
  });
1047
1047
  }
1048
- function bi(t, e) {
1048
+ function vi(t, e) {
1049
1049
  return new q(function(n) {
1050
1050
  var r;
1051
1051
  return _e(n, e, function() {
@@ -1086,13 +1086,13 @@ function ki(t, e) {
1086
1086
  if (Gn(t))
1087
1087
  return yi(t, e);
1088
1088
  if (Kn(t))
1089
- return vi(t, e);
1089
+ return bi(t, e);
1090
1090
  if (Zn(t))
1091
1091
  return gi(t, e);
1092
1092
  if (Xn(t))
1093
1093
  return cr(t, e);
1094
1094
  if (nr(t))
1095
- return bi(t, e);
1095
+ return vi(t, e);
1096
1096
  if (ir(t))
1097
1097
  return Si(t, e);
1098
1098
  }
@@ -1127,8 +1127,8 @@ function I(t, e) {
1127
1127
  });
1128
1128
  }
1129
1129
  function $i(t, e, n, r, i, o, s, u) {
1130
- var c = [], l = 0, _ = 0, b = !1, p = function() {
1131
- b && !c.length && !l && e.complete();
1130
+ var c = [], l = 0, _ = 0, v = !1, p = function() {
1131
+ v && !c.length && !l && e.complete();
1132
1132
  }, a = function(f) {
1133
1133
  return l < r ? h(f) : c.push(f);
1134
1134
  }, h = function(f) {
@@ -1154,7 +1154,7 @@ function $i(t, e, n, r, i, o, s, u) {
1154
1154
  }));
1155
1155
  };
1156
1156
  return t.subscribe(J(e, a, function() {
1157
- b = !0, p();
1157
+ v = !0, p();
1158
1158
  })), function() {
1159
1159
  };
1160
1160
  }
@@ -1246,8 +1246,8 @@ function En(t, e) {
1246
1246
  n.subscribe(J(r, function(c) {
1247
1247
  i?.unsubscribe();
1248
1248
  var l = 0, _ = o++;
1249
- ie(t(c, _)).subscribe(i = J(r, function(b) {
1250
- return r.next(e ? e(c, b, _, l++) : b);
1249
+ ie(t(c, _)).subscribe(i = J(r, function(v) {
1250
+ return r.next(e ? e(c, v, _, l++) : v);
1251
1251
  }, function() {
1252
1252
  i = null, u();
1253
1253
  }));
@@ -1272,14 +1272,14 @@ function cn(t, e) {
1272
1272
  return c.removeEventListener("abort", l);
1273
1273
  });
1274
1274
  }
1275
- var _ = ze(ze({}, r), { signal: s }), b = function(p) {
1275
+ var _ = ze(ze({}, r), { signal: s }), v = function(p) {
1276
1276
  u = !1, i.error(p);
1277
1277
  };
1278
1278
  return fetch(t, _).then(function(p) {
1279
1279
  n ? ie(n(p)).subscribe(J(i, void 0, function() {
1280
1280
  u = !1, i.complete();
1281
- }, b)) : (u = !1, i.next(p), i.complete());
1282
- }).catch(b), function() {
1281
+ }, v)) : (u = !1, i.next(p), i.complete());
1282
+ }).catch(v), function() {
1283
1283
  u && o.abort();
1284
1284
  };
1285
1285
  });
@@ -1704,7 +1704,7 @@ function qi() {
1704
1704
  return k.clean(), x.fill(0), S.fill(0), R;
1705
1705
  }
1706
1706
  e.hkdf = _;
1707
- function b(p, a, h, f) {
1707
+ function v(p, a, h, f) {
1708
1708
  for (var S = new o(p), y = S.digestLength, k = new Uint8Array(4), x = new Uint8Array(y), W = new Uint8Array(y), R = new Uint8Array(f), O = 0; O * y < f; O++) {
1709
1709
  var G = O + 1;
1710
1710
  k[0] = G >>> 24 & 255, k[1] = G >>> 16 & 255, k[2] = G >>> 8 & 255, k[3] = G >>> 0 & 255, S.reset(), S.update(a), S.update(k), S.finish(W);
@@ -1724,7 +1724,7 @@ function qi() {
1724
1724
  k[O] = 0;
1725
1725
  return S.clean(), R;
1726
1726
  }
1727
- e.pbkdf2 = b;
1727
+ e.pbkdf2 = v;
1728
1728
  });
1729
1729
  }(ft)), ft.exports;
1730
1730
  }
@@ -2044,7 +2044,7 @@ function z(t) {
2044
2044
  const me = {}, Fe = {}, ue = {};
2045
2045
  function Gi() {
2046
2046
  for (const t in me)
2047
- me.hasOwnProperty(t) && ve(t);
2047
+ me.hasOwnProperty(t) && be(t);
2048
2048
  for (const t in Fe)
2049
2049
  Fe.hasOwnProperty(t) && Xi(t);
2050
2050
  for (const t in ue)
@@ -2052,7 +2052,7 @@ function Gi() {
2052
2052
  }
2053
2053
  function ne(t, e, n = 300) {
2054
2054
  if (t && e && e instanceof Function)
2055
- ve(t), me[t] = setTimeout(() => {
2055
+ be(t), me[t] = setTimeout(() => {
2056
2056
  e(), delete me[t];
2057
2057
  }, n);
2058
2058
  else
@@ -2060,7 +2060,7 @@ function ne(t, e, n = 300) {
2060
2060
  t ? "Cannot create named timeout without a name" : "Cannot create a timeout without a callback"
2061
2061
  );
2062
2062
  }
2063
- function ve(t) {
2063
+ function be(t) {
2064
2064
  me[t] && (clearTimeout(me[t]), delete me[t]);
2065
2065
  }
2066
2066
  function Xi(t) {
@@ -2082,13 +2082,13 @@ const to = {
2082
2082
  version: "2.0.0"
2083
2083
  };
2084
2084
  let g = {}, A, F;
2085
- const v = {};
2085
+ const b = {};
2086
2086
  let w = "", ye = "";
2087
2087
  const Ee = new le(""), wt = new le("");
2088
2088
  let an = "/api/engine/v2";
2089
2089
  const ce = new le(!1), no = ce.asObservable();
2090
2090
  let gt = 0;
2091
- function be() {
2091
+ function ve() {
2092
2092
  return `${`${g.secure || window.location?.protocol.indexOf("https") >= 0 ? "https:" : "http:"}//${g.host || window.location?.host}`}${pr()}`;
2093
2093
  }
2094
2094
  function pr() {
@@ -2107,7 +2107,7 @@ function gs(t, e = !0) {
2107
2107
  A.setItem(`${w}_x-api-key`, `${t}`), A.setItem("trusted", `${e}`), oo("x-api-key", Wi(/* @__PURE__ */ new Date(), 5).valueOf());
2108
2108
  }
2109
2109
  function Ot() {
2110
- return bt("x-api-key", !1) || "";
2110
+ return vt("x-api-key", !1) || "";
2111
2111
  }
2112
2112
  function oo(t, e = zi(/* @__PURE__ */ new Date(), 2).valueOf()) {
2113
2113
  g.ignore_api_key && t === "x-api-key" || (A.setItem(`${w}_expires_at`, `${e}`), A.setItem(`${w}_access_token`, t));
@@ -2117,7 +2117,7 @@ function Y(t = !0) {
2117
2117
  if (!A) return "";
2118
2118
  if (Ot() && !g.ignore_api_key) return "x-api-key";
2119
2119
  const e = A.getItem(`${w}_expires_at`) || "", n = Ee.getValue();
2120
- return Hi(+e, /* @__PURE__ */ new Date()) && (d("Auth", "Token expired. Requesting new token..."), hn(), v.load_authority || (gt += 1, ne(
2120
+ return Hi(+e, /* @__PURE__ */ new Date()) && (d("Auth", "Token expired. Requesting new token..."), hn(), b.load_authority || (gt += 1, ne(
2121
2121
  "re-authorise",
2122
2122
  () => yr().catch(
2123
2123
  (r) => d("Auth", `Failed to get token: ${r}`)
@@ -2137,10 +2137,10 @@ function so() {
2137
2137
  function uo() {
2138
2138
  return Ee.pipe(I((t) => !!so()));
2139
2139
  }
2140
- function vt() {
2140
+ function bt() {
2141
2141
  return F;
2142
2142
  }
2143
- function vs() {
2143
+ function bs() {
2144
2144
  return ce.getValue();
2145
2145
  }
2146
2146
  function ln() {
@@ -2149,16 +2149,16 @@ function ln() {
2149
2149
  function co() {
2150
2150
  return !!g.secure;
2151
2151
  }
2152
- function bs() {
2152
+ function vs() {
2153
2153
  return no;
2154
2154
  }
2155
2155
  function fn() {
2156
- return bt("trust") === "true" || bt("trusted") === "true";
2156
+ return vt("trust") === "true" || vt("trusted") === "true";
2157
2157
  }
2158
2158
  function _r() {
2159
- return !!Ot() && !g.ignore_api_key || bt("fixed_device") === "true";
2159
+ return !!Ot() && !g.ignore_api_key || vt("fixed_device") === "true";
2160
2160
  }
2161
- function bt(t, e = !0) {
2161
+ function vt(t, e = !0) {
2162
2162
  let r = dr()[t];
2163
2163
  if (A) {
2164
2164
  const i = `${io()}_${t}`;
@@ -2171,8 +2171,8 @@ function Ss(t) {
2171
2171
  }
2172
2172
  function ks() {
2173
2173
  g = {}, F = void 0, Ee.next(""), wt.next(""), ce.next(!1), w = "", ye = "", an = "/api/engine/v2";
2174
- for (const t in v)
2175
- t in v && delete v[t];
2174
+ for (const t in b)
2175
+ t in b && delete b[t];
2176
2176
  Gi();
2177
2177
  }
2178
2178
  function mr() {
@@ -2182,20 +2182,20 @@ function hn() {
2182
2182
  d("Auth", "Invalidating tokens."), A.removeItem(`${w}_access_token`), A.removeItem(`${w}_expires_at`), Ee.getValue() && Ee.next("");
2183
2183
  }
2184
2184
  function yr(t, e = F) {
2185
- return v.authorise || (v.authorise = new Promise((n, r) => {
2185
+ return b.authorise || (b.authorise = new Promise((n, r) => {
2186
2186
  if (!e)
2187
- return delete v.authorise, r("Authority is not loaded");
2187
+ return delete b.authorise, r("Authority is not loaded");
2188
2188
  d("Auth", "Authorising user...");
2189
2189
  const i = () => {
2190
2190
  if (Y(!1))
2191
- d("Auth", "Valid token found."), delete v.authorise, n(Y());
2191
+ d("Auth", "Valid token found."), delete b.authorise, n(Y());
2192
2192
  else {
2193
2193
  const o = [
2194
2194
  () => {
2195
- d("Auth", "Successfully generated token."), n(Y()), delete v.authorise;
2195
+ d("Auth", "Successfully generated token."), n(Y()), delete b.authorise;
2196
2196
  },
2197
2197
  () => {
2198
- d("Auth", "Failed to generate token."), r("Failed to generate token"), setTimeout(() => delete v.authorise, 200);
2198
+ d("Auth", "Failed to generate token."), r("Failed to generate token"), setTimeout(() => delete b.authorise, 200);
2199
2199
  }
2200
2200
  ];
2201
2201
  g && g.auth_type === "password" ? (d("Auth", "Logging in with credentials."), go(g).then(
@@ -2203,14 +2203,14 @@ function yr(t, e = F) {
2203
2203
  ), gt = 0) : ye || nn() ? (d(
2204
2204
  "Auth",
2205
2205
  `Generating token with ${ye ? "code" : "refresh token"}`
2206
- ), vr().then(...o), gt = 0) : e.session ? (d(
2206
+ ), br().then(...o), gt = 0) : e.session ? (d(
2207
2207
  "Auth",
2208
2208
  "Users has session. Authorising application..."
2209
- ), ao(t).then(...o)) : (d("Auth", "No user session"), gr(e), r("No user session"), setTimeout(() => delete v.authorise, 200));
2209
+ ), ao(t).then(...o)) : (d("Auth", "No user session"), gr(e), r("No user session"), setTimeout(() => delete b.authorise, 200));
2210
2210
  }
2211
2211
  };
2212
2212
  fo().then(i, i);
2213
- })), v.authorise;
2213
+ })), b.authorise;
2214
2214
  }
2215
2215
  function xs() {
2216
2216
  const t = F ? F.logout_url : "/logout";
@@ -2230,7 +2230,7 @@ function xs() {
2230
2230
  });
2231
2231
  }
2232
2232
  function dn(t = 0) {
2233
- return v.load_authority || (v.load_authority = new Promise((e) => {
2233
+ return b.load_authority || (b.load_authority = new Promise((e) => {
2234
2234
  if (ce.next(!1), g.mock) {
2235
2235
  F = to, d("Auth", "System in mock mode"), ce.next(!0), e();
2236
2236
  return;
@@ -2240,7 +2240,7 @@ function dn(t = 0) {
2240
2240
  d("Auth", `Failed to load authority(${i})`), ce.next(!1), ne(
2241
2241
  "load_authority",
2242
2242
  () => {
2243
- delete v.load_authority, dn(t).then((o) => e());
2243
+ delete b.load_authority, dn(t).then((o) => e());
2244
2244
  },
2245
2245
  300 * Math.min(20, ++t)
2246
2246
  );
@@ -2262,9 +2262,9 @@ function dn(t = 0) {
2262
2262
  const o = () => {
2263
2263
  ce.next(!0), d("Auth", "Application set online."), e();
2264
2264
  };
2265
- delete v.load_authority, yr("").then(o, o);
2265
+ delete b.load_authority, yr("").then(o, o);
2266
2266
  }, r);
2267
- })), v.load_authority;
2267
+ })), b.load_authority;
2268
2268
  }
2269
2269
  async function ao(t) {
2270
2270
  const e = po(t);
@@ -2273,19 +2273,19 @@ async function ao(t) {
2273
2273
  window.location?.assign(e);
2274
2274
  }
2275
2275
  function lo(t) {
2276
- return v.iframe_auth || (v.iframe_auth = new Promise((e, n) => {
2276
+ return b.iframe_auth || (b.iframe_auth = new Promise((e, n) => {
2277
2277
  d("Auth", "Authorizing in an iFrame...");
2278
2278
  const r = document.createElement("iframe");
2279
2279
  r.style.position = "absolute", r.style.top = "0", r.style.left = "0", r.style.height = "1px", r.style.width = "1px", r.style.zIndex = "-1", r.id = "place-authorize", r.src = `${t}`;
2280
2280
  const i = (o) => {
2281
2281
  if (o.origin === window.location?.origin && o.data.type === "place-os") {
2282
2282
  const s = o.data;
2283
- if (d("Auth", "Received credentials from iFrame..."), document.body.removeChild(r), ve("iframe_auth"), window.removeEventListener("message", i), delete v.iframe_auth, s.token)
2283
+ if (d("Auth", "Received credentials from iFrame..."), document.body.removeChild(r), be("iframe_auth"), window.removeEventListener("message", i), delete b.iframe_auth, s.token)
2284
2284
  return e(), pn({
2285
2285
  access_token: s.token,
2286
2286
  ...s
2287
2287
  });
2288
- ye = s.code || "", vr().then(
2288
+ ye = s.code || "", br().then(
2289
2289
  (u) => e(u),
2290
2290
  (u) => n(u)
2291
2291
  );
@@ -2298,9 +2298,9 @@ function lo(t) {
2298
2298
  },
2299
2299
  15 * 1e3
2300
2300
  ), window.addEventListener("message", i), r.onerror = (o) => {
2301
- d("Auth", "iFrame error.", o), delete v.iframe_auth, n();
2301
+ d("Auth", "iFrame error.", o), delete b.iframe_auth, n();
2302
2302
  }, document.body.appendChild(r);
2303
- })), v.iframe_auth;
2303
+ })), b.iframe_auth;
2304
2304
  }
2305
2305
  let Dn = !1;
2306
2306
  function gr(t) {
@@ -2313,15 +2313,15 @@ function gr(t) {
2313
2313
  throw setTimeout(() => window.location?.assign(e), 300), Dn = !0, new Error("Redirecting to login page...");
2314
2314
  } else
2315
2315
  d("Auth", "Login being handled locally.");
2316
- delete v.authorise;
2316
+ delete b.authorise;
2317
2317
  }
2318
2318
  function fo() {
2319
- return v.check_token || (v.check_token = new Promise(async (t, e) => {
2320
- Y() ? (d("Auth", "Valid token found."), t(Y())) : (d("Auth", "No token. Checking URL for auth credentials..."), await ho() ? t(!0) : e()), delete v.check_token;
2321
- })), v.check_token;
2319
+ return b.check_token || (b.check_token = new Promise(async (t, e) => {
2320
+ Y() ? (d("Auth", "Valid token found."), t(Y())) : (d("Auth", "No token. Checking URL for auth credentials..."), await ho() ? t(!0) : e()), delete b.check_token;
2321
+ })), b.check_token;
2322
2322
  }
2323
2323
  function ho() {
2324
- return v.check_params || (v.check_params = new Promise((t) => {
2324
+ return b.check_params || (b.check_params = new Promise((t) => {
2325
2325
  d("Auth", "Checking for auth parameters...");
2326
2326
  let e = dr();
2327
2327
  if ((!e || Object.keys(e).length <= 0) && sessionStorage && (e = JSON.parse(
@@ -2339,13 +2339,13 @@ function ho() {
2339
2339
  t(!1);
2340
2340
  ne(
2341
2341
  "check_params_promise",
2342
- () => delete v.check_params,
2342
+ () => delete b.check_params,
2343
2343
  50
2344
2344
  );
2345
- })), v.check_params;
2345
+ })), b.check_params;
2346
2346
  }
2347
2347
  function po(t) {
2348
- const e = vo();
2348
+ const e = bo();
2349
2349
  t = t ? `${e};${t}` : e;
2350
2350
  const n = g ? (g.auth_uri || "").indexOf("?") >= 0 : !1, r = (g ? g.auth_uri : null) || "/auth/oauth/authorize", i = fn() || g.auth_type === "auth_code" ? "code" : "token";
2351
2351
  let o = `${r}${n ? "&" : "?"}response_type=${encodeURIComponent(i)}&client_id=${encodeURIComponent(w)}&state=${encodeURIComponent(t)}&redirect_uri=${encodeURIComponent(g.redirect_uri)}&scope=${encodeURIComponent(g.scope)}`;
@@ -2388,17 +2388,17 @@ function yo(t) {
2388
2388
  });
2389
2389
  return `${e}?${n}`;
2390
2390
  }
2391
- function vr() {
2392
- return br(...mo());
2391
+ function br() {
2392
+ return vr(...mo());
2393
2393
  }
2394
2394
  function go(t) {
2395
- return br(yo(t));
2395
+ return vr(yo(t));
2396
2396
  }
2397
- function br(t, e = "") {
2398
- return v.generate_tokens || (v.generate_tokens = new Promise((n, r) => {
2397
+ function vr(t, e = "") {
2398
+ return b.generate_tokens || (b.generate_tokens = new Promise((n, r) => {
2399
2399
  d("Auth", "Generating new token...");
2400
2400
  const i = (o) => {
2401
- d("Auth", "Error generating new tokens.", o), A.removeItem(`${w}_refresh_token`), wt.next(""), r(), delete v.generate_tokens;
2401
+ d("Auth", "Error generating new tokens.", o), A.removeItem(`${w}_refresh_token`), wt.next(""), r(), delete b.generate_tokens;
2402
2402
  };
2403
2403
  cn(t, {
2404
2404
  method: "POST",
@@ -2409,9 +2409,9 @@ function br(t, e = "") {
2409
2409
  }).subscribe(async (o) => {
2410
2410
  if (!o.ok) return i(o);
2411
2411
  const s = await o.json();
2412
- pn(s), n(), delete v.generate_tokens;
2412
+ pn(s), n(), delete b.generate_tokens;
2413
2413
  }, i);
2414
- })), v.generate_tokens;
2414
+ })), b.generate_tokens;
2415
2415
  }
2416
2416
  function pn(t) {
2417
2417
  const e = Li(
@@ -2426,13 +2426,13 @@ function pn(t) {
2426
2426
  t.refresh_token
2427
2427
  ), de("refresh_token"))), t.expires_in && (A.setItem(`${w}_expires_at`, `${e.valueOf()}`), de("expires_in")), ce.next(!0), Ee.next(t.access_token || ""), wt.next(t.refresh_token || "");
2428
2428
  }
2429
- function vo() {
2429
+ function bo() {
2430
2430
  const t = Bi();
2431
2431
  return A.setItem(`${w}_nonce`, t), t;
2432
2432
  }
2433
2433
  const Et = {};
2434
2434
  function $s(t, e = Et) {
2435
- bo(t.method, t.path, e);
2435
+ vo(t.method, t.path, e);
2436
2436
  const n = `${t.method}|${t.path}`, r = t.path.replace(/(http|https):\/\/[a-zA-Z0-9.]*:?([0-9]*)?/g, "").replace(/^\//, "").split("/"), i = {
2437
2437
  ...t,
2438
2438
  path_parts: r,
@@ -2442,7 +2442,7 @@ function $s(t, e = Et) {
2442
2442
  };
2443
2443
  e[n] = i, d("HTTP(M)", `+ ${t.method} ${t.path}`);
2444
2444
  }
2445
- function bo(t, e, n = Et) {
2445
+ function vo(t, e, n = Et) {
2446
2446
  const r = `${t}|${e}`;
2447
2447
  n[r] && (delete n[r], d("HTTP(M)", `- ${t} ${e}`));
2448
2448
  }
@@ -2547,7 +2547,7 @@ function Be(t, e, n, r = ln, i = So, o = wo) {
2547
2547
  En((s) => s.ok ? o(s, n.response_type) : On(s)),
2548
2548
  Mi(
2549
2549
  (s) => s.pipe(
2550
- un((u, c) => u.status === 511 ? (gr(vt()), wn(u)) : c + 1 > 4 || u.status !== 401 ? On(u || {}) : (d("HTTP", "Auth error", u), kr(), wn(u)))
2550
+ un((u, c) => u.status === 511 ? (gr(bt()), wn(u)) : c + 1 > 4 || u.status !== 401 ? On(u || {}) : (d("HTTP", "Auth error", u), kr(), wn(u)))
2551
2551
  )
2552
2552
  )
2553
2553
  );
@@ -2602,7 +2602,7 @@ function ws(t) {
2602
2602
  let xr = {}, $r = {}, Cn = "";
2603
2603
  const Pt = (t) => t;
2604
2604
  function E(t) {
2605
- const { query_params: e, fn: n, path: r, endpoint: i } = t, o = z(e), s = `${i || be()}${r ? "/" + r : ""}${o ? "?" + o : ""}`;
2605
+ const { query_params: e, fn: n, path: r, endpoint: i } = t, o = z(e), s = `${i || ve()}${r ? "/" + r : ""}${o ? "?" + o : ""}`;
2606
2606
  return ee(s).pipe(
2607
2607
  I((u) => {
2608
2608
  const c = Eo(s, o, r);
@@ -2620,37 +2620,37 @@ function E(t) {
2620
2620
  );
2621
2621
  }
2622
2622
  function $(t) {
2623
- const { query_params: e, id: n, path: r, fn: i, options: o } = t, s = z(e), u = `${be()}/${r}/${n}${s ? "?" + s : ""}`;
2623
+ const { query_params: e, id: n, path: r, fn: i, options: o } = t, s = z(e), u = `${ve()}/${r}/${n}${s ? "?" + s : ""}`;
2624
2624
  return ee(u, o).pipe(I((c) => (i || Pt)(c)));
2625
2625
  }
2626
2626
  function C(t) {
2627
- const { query_params: e, form_data: n, path: r, fn: i } = t, o = z(e), s = `${be()}/${r}${o ? "?" + o : ""}`;
2627
+ const { query_params: e, form_data: n, path: r, fn: i } = t, o = z(e), s = `${ve()}/${r}${o ? "?" + o : ""}`;
2628
2628
  return Ie(s, n).pipe(
2629
2629
  I((c) => (i || Pt)(c))
2630
2630
  );
2631
2631
  }
2632
2632
  function m(t) {
2633
- const { id: e, task_name: n, form_data: r, method: i, path: o, callback: s } = t, u = z(r), c = `${be()}/${o}/${e}/${n}`;
2633
+ const { id: e, task_name: n, form_data: r, method: i, path: o, callback: s } = t, u = z(r), c = `${ve()}/${o}/${e}/${n}`;
2634
2634
  return (i === "post" || i === "put" || !i ? (i === "put" ? We : Ie)(c, r) : (i === "del" ? He : ee)(
2635
2635
  `${c}${u ? "?" + u : ""}`,
2636
2636
  {
2637
2637
  response_type: "json"
2638
2638
  }
2639
2639
  )).pipe(
2640
- I((_) => (s || ((b) => b))(_))
2640
+ I((_) => (s || ((v) => v))(_))
2641
2641
  );
2642
2642
  }
2643
2643
  function N(t) {
2644
2644
  const { id: e, query_params: n, form_data: r, method: i, path: o, fn: s } = t, u = z({
2645
2645
  ...n,
2646
2646
  version: r.version || 0
2647
- }), c = `${be()}/${o}/${e}${u ? "?" + u : ""}`;
2647
+ }), c = `${ve()}/${o}/${e}${u ? "?" + u : ""}`;
2648
2648
  return (i === "put" ? We : It)(c, r).pipe(
2649
2649
  I((l) => (s || Pt)(l))
2650
2650
  );
2651
2651
  }
2652
2652
  function T(t) {
2653
- const { id: e, query_params: n, path: r } = t, i = z(n), o = `${be()}/${r}/${e}${i ? "?" + i : ""}`;
2653
+ const { id: e, query_params: n, path: r } = t, i = z(n), o = `${ve()}/${r}/${e}${i ? "?" + i : ""}`;
2654
2654
  return He(o);
2655
2655
  }
2656
2656
  function Eo(t, e, n) {
@@ -3450,7 +3450,7 @@ function yu(t = {}) {
3450
3450
  function gu(t, e = {}) {
3451
3451
  return $({ id: t, query_params: e, fn: Ct, path: K });
3452
3452
  }
3453
- function vu(t, e, n = "patch") {
3453
+ function bu(t, e, n = "patch") {
3454
3454
  return N({
3455
3455
  id: t,
3456
3456
  form_data: e,
@@ -3460,7 +3460,7 @@ function vu(t, e, n = "patch") {
3460
3460
  path: K
3461
3461
  });
3462
3462
  }
3463
- function bu(t) {
3463
+ function vu(t) {
3464
3464
  return C({ form_data: t, query_params: {}, fn: Ct, path: K });
3465
3465
  }
3466
3466
  function Su(t, e = {}) {
@@ -3877,7 +3877,7 @@ function gc(t, e, n = 1, r) {
3877
3877
  path: M
3878
3878
  });
3879
3879
  }
3880
- function vc(t, e, n = 1) {
3880
+ function bc(t, e, n = 1) {
3881
3881
  return m({
3882
3882
  id: t,
3883
3883
  task_name: `functions/${e}_${n}`,
@@ -3885,7 +3885,7 @@ function vc(t, e, n = 1) {
3885
3885
  path: M
3886
3886
  });
3887
3887
  }
3888
- function bc(t) {
3888
+ function vc(t) {
3889
3889
  return E({
3890
3890
  query_params: {},
3891
3891
  fn: (e) => new mn(e),
@@ -4401,13 +4401,13 @@ class Qt {
4401
4401
  }
4402
4402
  }
4403
4403
  const it = "/api/staff/v1/surveys";
4404
- function va(t = {}) {
4404
+ function ba(t = {}) {
4405
4405
  const e = z(t);
4406
4406
  return ee(`${it}${e ? "?" + e : ""}`).pipe(
4407
4407
  I((n) => n.map((r) => new Qt(r)))
4408
4408
  );
4409
4409
  }
4410
- function ba(t, e = {}) {
4410
+ function va(t, e = {}) {
4411
4411
  const n = z(e);
4412
4412
  return ee(`${it}/${t}${n ? "?" + n : ""}`).pipe(
4413
4413
  I((r) => new Qt(r))
@@ -4495,21 +4495,21 @@ var Yo = {
4495
4495
  var n = this, r = this._config, i = r.WebSocketCtor, o = r.protocol, s = r.url, u = r.binaryType, c = this._output, l = null;
4496
4496
  try {
4497
4497
  l = o ? new i(s, o) : new i(s), this._socket = l, u && (this._socket.binaryType = u);
4498
- } catch (b) {
4499
- c.error(b);
4498
+ } catch (v) {
4499
+ c.error(v);
4500
4500
  return;
4501
4501
  }
4502
4502
  var _ = new ge(function() {
4503
4503
  n._socket = null, l && l.readyState === 1 && l.close();
4504
4504
  });
4505
- l.onopen = function(b) {
4505
+ l.onopen = function(v) {
4506
4506
  var p = n._socket;
4507
4507
  if (!p) {
4508
4508
  l.close(), n._resetState();
4509
4509
  return;
4510
4510
  }
4511
4511
  var a = n._config.openObserver;
4512
- a && a.next(b);
4512
+ a && a.next(v);
4513
4513
  var h = n.destination;
4514
4514
  n.destination = At.create(function(f) {
4515
4515
  if (l.readyState === 1)
@@ -4526,16 +4526,16 @@ var Yo = {
4526
4526
  var f = n._config.closingObserver;
4527
4527
  f && f.next(void 0), l.close(), n._resetState();
4528
4528
  }), h && h instanceof Jt && _.add(h.subscribe(n.destination));
4529
- }, l.onerror = function(b) {
4530
- n._resetState(), c.error(b);
4531
- }, l.onclose = function(b) {
4529
+ }, l.onerror = function(v) {
4530
+ n._resetState(), c.error(v);
4531
+ }, l.onclose = function(v) {
4532
4532
  l === n._socket && n._resetState();
4533
4533
  var p = n._config.closeObserver;
4534
- p && p.next(b), b.wasClean ? c.complete() : c.error(b);
4535
- }, l.onmessage = function(b) {
4534
+ p && p.next(v), v.wasClean ? c.complete() : c.error(v);
4535
+ }, l.onmessage = function(v) {
4536
4536
  try {
4537
4537
  var p = n._config.deserializer;
4538
- c.next(p(b));
4538
+ c.next(p(v));
4539
4539
  } catch (a) {
4540
4540
  c.error(a);
4541
4541
  }
@@ -4634,11 +4634,11 @@ const L = {}, gn = {}, $e = {}, ts = {}, pe = new le(!1);
4634
4634
  $e._place_os_status = pe.asObservable();
4635
4635
  const Cr = new le([0, 0]);
4636
4636
  $e._place_os_sync = Cr.asObservable();
4637
- let Nr = Date.now(), we, xt = 0, se = null, ht, vn = 0;
4637
+ let Nr = Date.now(), we, xt = 0, se = null, ht, bn = 0;
4638
4638
  const st = 10 * 1e3, jr = new ae();
4639
4639
  $e._place_os_debug_events = jr.asObservable();
4640
4640
  function Kt() {
4641
- return be().indexOf("/control/") >= 0 ? "/control/websocket" : `${pr()}/systems/control`;
4641
+ return ve().indexOf("/control/") >= 0 ? "/control/websocket" : `${pr()}/systems/control`;
4642
4642
  }
4643
4643
  function Fr() {
4644
4644
  return pe.getValue();
@@ -4725,7 +4725,7 @@ function qe(t, e = st, n = 0) {
4725
4725
  },
4726
4726
  e
4727
4727
  );
4728
- } else se ? setTimeout(() => u(), 1e3) : bn().then(() => u());
4728
+ } else se ? setTimeout(() => u(), 1e3) : vn().then(() => u());
4729
4729
  }), L[r] = i;
4730
4730
  }
4731
4731
  return L[r].promise;
@@ -4752,8 +4752,8 @@ function zr(t) {
4752
4752
  time: Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3)
4753
4753
  });
4754
4754
  } else t.type === "error" ? cs(t) : t.cmd || d("WS", "Invalid websocket message", t, "error");
4755
- ve(`${t.id}`);
4756
- } else t === "pong" && (vn = Date.now(), d("WS", "Pong!"));
4755
+ be(`${t.id}`);
4756
+ } else t === "pong" && (bn = Date.now(), d("WS", "Pong!"));
4757
4757
  }
4758
4758
  function us(t) {
4759
4759
  const e = Object.keys(L).map((n) => L[n]).find((n) => n?.id === t.id);
@@ -4791,7 +4791,7 @@ function cs(t) {
4791
4791
  "error"
4792
4792
  );
4793
4793
  const n = Object.keys(L).map((r) => L[r]).filter((r) => r).find((r) => r.id === t.id);
4794
- n && n.reject && (n.reject(t), ve(`${n.key}`), delete L[n.key]);
4794
+ n && n.reject && (n.reject(t), be(`${n.key}`), delete L[n.key]);
4795
4795
  }
4796
4796
  function as(t, e, n = gn, r = $e) {
4797
4797
  const i = `${t.sys}|${t.mod}_${t.index}|${t.name}`;
@@ -4803,11 +4803,11 @@ function as(t, e, n = gn, r = $e) {
4803
4803
  e
4804
4804
  ]), n[i].next(e);
4805
4805
  }
4806
- function bn(t = 0) {
4806
+ function vn(t = 0) {
4807
4807
  return se == null && (se = new Promise((e) => {
4808
4808
  if (t > 40)
4809
4809
  return location.reload();
4810
- xt++, Nr = Date.now(), Q = ln() ? hs() : ls(), Q ? (d("WS(Debug)", "Authority:", [vt()]), d("WS", "Connecting to websocket..."), Q.subscribe(
4810
+ xt++, Nr = Date.now(), Q = ln() ? hs() : ls(), Q ? (d("WS(Debug)", "Authority:", [bt()]), d("WS", "Connecting to websocket..."), Q.subscribe(
4811
4811
  (n) => {
4812
4812
  pe.getValue() || (d("WS", "Connection established."), e()), pe.next(!0), xt = 0, Zt(), zr(n);
4813
4813
  },
@@ -4817,7 +4817,7 @@ function bn(t = 0) {
4817
4817
  () => {
4818
4818
  Q = void 0, se = null, Fn(), d("WS", "Connection closed by browser."), pe.next(!1), $t();
4819
4819
  }
4820
- ), we && clearInterval(we), vn = Date.now(), jn(), we = setInterval(
4820
+ ), we && clearInterval(we), bn = Date.now(), jn(), we = setInterval(
4821
4821
  () => jn(),
4822
4822
  Dr * 1e3
4823
4823
  ), Zt(), qr += 1, ht = setTimeout(() => {
@@ -4825,7 +4825,7 @@ function bn(t = 0) {
4825
4825
  }, 30 * 1e3)) : (Q ? d(
4826
4826
  "WS",
4827
4827
  `Waiting on auth(${t}). Retrying in ${1e3 * Math.min(10, t + 1)}ms...`,
4828
- [!!Y(), !!vt()],
4828
+ [!!Y(), !!bt()],
4829
4829
  "info"
4830
4830
  ) : d(
4831
4831
  "WS",
@@ -4834,14 +4834,14 @@ function bn(t = 0) {
4834
4834
  "error"
4835
4835
  ), setTimeout(
4836
4836
  () => {
4837
- se = null, bn(t).then((n) => e(n));
4837
+ se = null, vn(t).then((n) => e(n));
4838
4838
  },
4839
4839
  1e3 * Math.min(10, ++t)
4840
4840
  ));
4841
4841
  })), se;
4842
4842
  }
4843
4843
  function ls() {
4844
- if (!vt() || !Y()) return null;
4844
+ if (!bt() || !Y()) return null;
4845
4845
  const t = co() || location.protocol.indexOf("https") >= 0;
4846
4846
  let e = `ws${t ? "s" : ""}://${rn()}${Kt()}${_r() ? "?fixed_device=true" : ""}`;
4847
4847
  const n = Y();
@@ -4872,12 +4872,12 @@ function $t() {
4872
4872
  )}ms...`
4873
4873
  ), ne(
4874
4874
  "reconnect",
4875
- () => bn(),
4875
+ () => vn(),
4876
4876
  Math.min(5e3, (xt + 1) * 300 || 1e3)
4877
4877
  );
4878
4878
  }
4879
4879
  function jn() {
4880
- if (Date.now() - vn > 4 * Dr * 1e3)
4880
+ if (Date.now() - bn > 4 * Dr * 1e3)
4881
4881
  return $t();
4882
4882
  Q?.next("ping");
4883
4883
  }
@@ -4913,7 +4913,7 @@ function ds(t, e, n) {
4913
4913
  });
4914
4914
  break;
4915
4915
  case "unbind":
4916
- n[r] && (n[r].unsubscribe(), delete n[r], ve(`${r}`));
4916
+ n[r] && (n[r].unsubscribe(), delete n[r], be(`${r}`));
4917
4917
  break;
4918
4918
  }
4919
4919
  ne(
@@ -4946,7 +4946,7 @@ function Fn() {
4946
4946
  class zn {
4947
4947
  constructor(e, n) {
4948
4948
  this._module = e, this.name = n, ns().pipe(Pi()).subscribe((r) => {
4949
- r && (this._stale_bindings || this._pending === 1) ? (d("VAR", "Re-binding to status variable", this.binding()), this.rebind()) : r || (ve(
4949
+ r && (this._stale_bindings || this._pending === 1) ? (d("VAR", "Re-binding to status variable", this.binding()), this.rebind()) : r || (be(
4950
4950
  `rebind:${JSON.stringify(this.binding())}`
4951
4951
  ), d(
4952
4952
  "VAR",
@@ -4985,6 +4985,14 @@ class zn {
4985
4985
  subscribe(e) {
4986
4986
  return this.listen().subscribe(e);
4987
4987
  }
4988
+ bindThenSubscribe(e) {
4989
+ const n = this.bind();
4990
+ return this.listen().subscribe({
4991
+ next: e,
4992
+ complete: () => n(),
4993
+ error: () => n()
4994
+ });
4995
+ }
4988
4996
  /**
4989
4997
  * Bind to the status variable's value
4990
4998
  */
@@ -5169,7 +5177,7 @@ export {
5169
5177
  ha as addInvitation,
5170
5178
  cu as addLDAPSource,
5171
5179
  pu as addMetadata,
5172
- bu as addModule,
5180
+ vu as addModule,
5173
5181
  Mu as addOAuthSource,
5174
5182
  ma as addQuestion,
5175
5183
  Cu as addRepository,
@@ -5184,11 +5192,11 @@ export {
5184
5192
  Ec as addTrigger,
5185
5193
  Dc as addUser,
5186
5194
  zc as addZone,
5187
- be as apiEndpoint,
5195
+ ve as apiEndpoint,
5188
5196
  Ot as apiKey,
5189
5197
  oa as approveSignagePlaylist,
5190
5198
  yr as authorise,
5191
- vt as authority,
5199
+ bt as authority,
5192
5200
  Nn as bind,
5193
5201
  Qi as cleanObject,
5194
5202
  ks as cleanupAuth,
@@ -5201,12 +5209,12 @@ export {
5201
5209
  Oa as debug,
5202
5210
  jr as debug_events,
5203
5211
  He as del,
5204
- bo as deregisterMockEndpoint,
5212
+ vo as deregisterMockEndpoint,
5205
5213
  Aa as deregisterSystem,
5206
5214
  ss as execute,
5207
5215
  mc as executeOnSystem,
5208
5216
  Hc as executeOnZone,
5209
- vc as functionList,
5217
+ bc as functionList,
5210
5218
  Bi as generateNonce,
5211
5219
  ee as get,
5212
5220
  dr as getFragments,
@@ -5223,7 +5231,7 @@ export {
5223
5231
  Yi as isMobileSafari,
5224
5232
  ln as isMock,
5225
5233
  Ji as isNestedFrame,
5226
- vs as isOnline,
5234
+ bs as isOnline,
5227
5235
  co as isSecure,
5228
5236
  fn as isTrusted,
5229
5237
  Fr as is_connected,
@@ -5243,7 +5251,7 @@ export {
5243
5251
  ra as listSignagePlaylistMedia,
5244
5252
  ia as listSignagePlaylistMediaRevisions,
5245
5253
  Sc as listSystemTriggers,
5246
- bc as listSystemZones,
5254
+ vc as listSystemZones,
5247
5255
  Pc as listTriggerInstances,
5248
5256
  Nc as listZoneTags,
5249
5257
  Wc as listZoneTriggers,
@@ -5258,7 +5266,7 @@ export {
5258
5266
  Eu as moduleRuntimeError,
5259
5267
  Ou as moduleSettings,
5260
5268
  $u as moduleState,
5261
- bs as onlineState,
5269
+ vs as onlineState,
5262
5270
  Vi as parseLinkHeader,
5263
5271
  It as patch,
5264
5272
  Ie as post,
@@ -5283,7 +5291,7 @@ export {
5283
5291
  ec as querySettings,
5284
5292
  Qc as querySignageMedia,
5285
5293
  Gc as querySignagePlaylists,
5286
- va as querySurveys,
5294
+ ba as querySurveys,
5287
5295
  sc as querySystems,
5288
5296
  uc as querySystemsWithEmails,
5289
5297
  Ac as queryTriggers,
@@ -5347,7 +5355,7 @@ export {
5347
5355
  Yc as showSignageMedia,
5348
5356
  Vc as showSignageMetrics,
5349
5357
  Xc as showSignagePlaylist,
5350
- ba as showSurvey,
5358
+ va as showSurvey,
5351
5359
  cc as showSystem,
5352
5360
  wc as showTrigger,
5353
5361
  Mc as showUser,
@@ -5372,7 +5380,7 @@ export {
5372
5380
  fa as updateInvitation,
5373
5381
  uu as updateLDAPSource,
5374
5382
  du as updateMetadata,
5375
- vu as updateModule,
5383
+ bu as updateModule,
5376
5384
  Tu as updateOAuthSource,
5377
5385
  ya as updateQuestion,
5378
5386
  qu as updateRepository,