@thestatic-tv/dcl-sdk 2.8.1 → 2.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -17,7 +17,7 @@ async function request(url, options = {}) {
17
17
  }
18
18
 
19
19
  // src/StaticTVClient.ts
20
- import { signedFetch as signedFetch3 } from "~system/SignedFetch";
20
+ import { signedFetch as signedFetch4 } from "~system/SignedFetch";
21
21
 
22
22
  // src/modules/guide.ts
23
23
  var GuideModule = class {
@@ -209,7 +209,83 @@ function dclClearTimeout(timeoutId) {
209
209
  // src/utils/bounds.ts
210
210
  import { engine as engine2, Transform } from "@dcl/sdk/ecs";
211
211
  import { getSceneInformation } from "~system/Runtime";
212
+
213
+ // src/utils/walls.ts
212
214
  var PARCEL_SIZE = 16;
215
+ var EDGE_STRIP = 1;
216
+ var WALL_TOP_MAX = 32;
217
+ function heightLimit(parcels) {
218
+ return Math.log2(parcels + 1) * 20;
219
+ }
220
+ function wallTop(parcels) {
221
+ return Math.min(WALL_TOP_MAX, heightLimit(parcels) - 4);
222
+ }
223
+ function parcelRects(parcels, base) {
224
+ const parse = (p) => {
225
+ const parts = String(p).split(",");
226
+ if (parts.length !== 2) return null;
227
+ const [x, z] = parts.map((n) => parseInt(n, 10));
228
+ return Number.isFinite(x) && Number.isFinite(z) ? { x, z } : null;
229
+ };
230
+ const coords = parcels.map(parse).filter((c) => c !== null);
231
+ const origin = base && parse(base) || coords[0];
232
+ if (!origin) return [];
233
+ return coords.map((c) => {
234
+ const minX = (c.x - origin.x) * PARCEL_SIZE;
235
+ const minZ = (c.z - origin.z) * PARCEL_SIZE;
236
+ return { minX, maxX: minX + PARCEL_SIZE, minZ, maxZ: minZ + PARCEL_SIZE };
237
+ });
238
+ }
239
+ function outerSides(rect, rects) {
240
+ const at = (minX, minZ) => rects.some((r) => r.minX === minX && r.minZ === minZ);
241
+ const sides = [];
242
+ if (!at(rect.minX - PARCEL_SIZE, rect.minZ)) sides.push("west");
243
+ if (!at(rect.minX + PARCEL_SIZE, rect.minZ)) sides.push("east");
244
+ if (!at(rect.minX, rect.minZ - PARCEL_SIZE)) sides.push("south");
245
+ if (!at(rect.minX, rect.minZ + PARCEL_SIZE)) sides.push("north");
246
+ return sides;
247
+ }
248
+ function wallBoxes(rects, strip = EDGE_STRIP, top = wallTop(rects.length)) {
249
+ return rects.map((r) => {
250
+ const outer = outerSides(r, rects);
251
+ return {
252
+ minX: r.minX + (outer.includes("west") ? strip : 0),
253
+ maxX: r.maxX - (outer.includes("east") ? strip : 0),
254
+ minZ: r.minZ + (outer.includes("south") ? strip : 0),
255
+ maxZ: r.maxZ - (outer.includes("north") ? strip : 0),
256
+ top
257
+ };
258
+ });
259
+ }
260
+ function inParcels(p, rects) {
261
+ return rects.some((r) => p.x >= r.minX && p.x <= r.maxX && p.z >= r.minZ && p.z <= r.maxZ);
262
+ }
263
+ function insideWalls(p, boxes) {
264
+ return boxes.some((b) => p.x >= b.minX && p.x <= b.maxX && p.z >= b.minZ && p.z <= b.maxZ && p.y < b.top);
265
+ }
266
+ var clamp = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
267
+ function ejectPoint(boxes, rects, from) {
268
+ const IN = 0.5;
269
+ const p = from || { x: 0, y: 0, z: 0 };
270
+ let best = null;
271
+ let bestDistance = Infinity;
272
+ rects.forEach((rect, i) => {
273
+ const b = boxes[i];
274
+ if (!b) return;
275
+ const along = (lo, hi, v) => clamp(v, lo + IN, hi - IN);
276
+ for (const side of outerSides(rect, rects)) {
277
+ const point = side === "west" ? { x: b.minX + IN, z: along(b.minZ, b.maxZ, p.z) } : side === "east" ? { x: b.maxX - IN, z: along(b.minZ, b.maxZ, p.z) } : side === "south" ? { x: along(b.minX, b.maxX, p.x), z: b.minZ + IN } : { x: along(b.minX, b.maxX, p.x), z: b.maxZ - IN };
278
+ const distance = Math.hypot(point.x - p.x, point.z - p.z);
279
+ if (distance < bestDistance) {
280
+ bestDistance = distance;
281
+ best = { x: point.x, y: b.top + 1, z: point.z };
282
+ }
283
+ }
284
+ });
285
+ return best;
286
+ }
287
+
288
+ // src/utils/bounds.ts
213
289
  var cachedBounds = null;
214
290
  var cachedParcelRects = [];
215
291
  var boundsInitialized = false;
@@ -252,11 +328,7 @@ async function getSceneBounds() {
252
328
  boundsError = true;
253
329
  return null;
254
330
  }
255
- cachedParcelRects = coords.map((c) => {
256
- const minX = (c.x - base.x) * PARCEL_SIZE;
257
- const minZ = (c.z - base.z) * PARCEL_SIZE;
258
- return { minX, maxX: minX + PARCEL_SIZE, minZ, maxZ: minZ + PARCEL_SIZE };
259
- });
331
+ cachedParcelRects = parcelRects(parcels, baseParcel);
260
332
  const worldMinX = Math.min(...coords.map((c) => c.x));
261
333
  const worldMaxX = Math.max(...coords.map((c) => c.x));
262
334
  const worldMinZ = Math.min(...coords.map((c) => c.z));
@@ -292,6 +364,9 @@ function isPlayerInBounds(_bounds) {
292
364
  return false;
293
365
  }
294
366
  }
367
+ function getParcelRects() {
368
+ return cachedParcelRects.map((r) => ({ ...r }));
369
+ }
295
370
  function getPlayerPosition() {
296
371
  try {
297
372
  const transform = Transform.getOrNull(engine2.PlayerEntity);
@@ -434,7 +509,7 @@ var SessionModule = class {
434
509
  this._tier = normalizeTier(response.sdkType);
435
510
  this.startHeartbeat();
436
511
  this.client.log(`Session started: ${this.sessionId}, tier: ${this._tier}`);
437
- this.client._enableFeaturesForTier(this._tier, this._keyId);
512
+ this.client._enableFeaturesForTier(this._tier, this._keyId, this._tier === "pro" && response.venue === true);
438
513
  return this.sessionId;
439
514
  }
440
515
  this.client._settleFeaturesAsFree();
@@ -693,10 +768,280 @@ var InteractionsModule = class {
693
768
  }
694
769
  };
695
770
 
771
+ // src/modules/frames.ts
772
+ import { signedFetch } from "~system/SignedFetch";
773
+ import { openExternalUrl } from "~system/RestrictedActions";
774
+ var FRAMES_MAX = 64;
775
+ var REFRESH_JITTER_MS = 3e3;
776
+ var DEFAULT_VERSION = "default";
777
+ var IMAGE_MAX = 1e3;
778
+ var TEXT_MAX = 120;
779
+ var LINK_MAX = 1e3;
780
+ var VERSION_MAX = 40;
781
+ var HTTPS = /^https:/i;
782
+ function isSceneFrame(value) {
783
+ if (!value || typeof value !== "object") return false;
784
+ const f = value;
785
+ if (typeof f.id !== "string" || typeof f.label !== "string" || typeof f.onContent !== "function") return false;
786
+ const d = f.default;
787
+ if (d === void 0 || d === null) return true;
788
+ if (typeof d !== "object") return false;
789
+ const { image, text, link } = d;
790
+ return typeof image === "string" && (text === void 0 || typeof text === "string") && (link === void 0 || typeof link === "string");
791
+ }
792
+ function defaultContent(frame) {
793
+ const d = frame.default;
794
+ if (!d) return null;
795
+ return { image: d.image, text: d.text || "", link: d.link || "", version: DEFAULT_VERSION };
796
+ }
797
+ function savedContent(value) {
798
+ if (!value || typeof value !== "object" || Array.isArray(value)) return null;
799
+ const v = value;
800
+ const image = v.image;
801
+ const text = v.text === void 0 || v.text === null ? "" : v.text;
802
+ const link = v.link === void 0 || v.link === null ? "" : v.link;
803
+ const version = v.version;
804
+ if (typeof image !== "string" || image.length > IMAGE_MAX || !HTTPS.test(image)) return null;
805
+ if (typeof text !== "string" || text.length > TEXT_MAX) return null;
806
+ if (typeof link !== "string" || link.length > LINK_MAX || link !== "" && !HTTPS.test(link)) return null;
807
+ if (typeof version !== "string" || version === "" || version.length > VERSION_MAX) return null;
808
+ return { image, text, link, version };
809
+ }
810
+ function sameContent(a, b) {
811
+ return b !== null && a.image === b.image && a.text === b.text && a.link === b.link && a.version === b.version;
812
+ }
813
+ function errorOf(body) {
814
+ try {
815
+ const data = body ? JSON.parse(body) : null;
816
+ return data && typeof data.error === "string" ? data.error : "";
817
+ } catch {
818
+ return "";
819
+ }
820
+ }
821
+ var FramesModule = class {
822
+ constructor(host) {
823
+ this.entries = /* @__PURE__ */ new Map();
824
+ /** Venue is known: the reads, the upload and the clicks may go */
825
+ this.enabled = false;
826
+ /** This copy's admin check succeeded: the declaration may be uploaded */
827
+ this.adminOk = false;
828
+ this.uploaded = false;
829
+ this.loadReadStarted = false;
830
+ /** The last good read's `frames` object (saved content by frame id), or null until a read succeeds */
831
+ this.answer = null;
832
+ /** Reads are numbered as they start; an answer older than the one shown is dropped */
833
+ this.readSeq = 0;
834
+ this.shownSeq = 0;
835
+ /** A framesRefresh is waiting out its jitter: another inside the wait shares its read */
836
+ this.refreshWaiting = false;
837
+ this.host = host;
838
+ }
839
+ /** The declared frames' ids, in the order they were first registered */
840
+ get ids() {
841
+ return [...this.entries.keys()];
842
+ }
843
+ /** True once Venue is known for this scene */
844
+ get isEnabled() {
845
+ return this.enabled;
846
+ }
847
+ /**
848
+ * Declare frames: kept until Venue is known; after, a frame registered now gets what the last read gave at once,
849
+ * and the load read and the upload that waited on frames go now (each still once a load)
850
+ */
851
+ register(frames) {
852
+ if (!Array.isArray(frames)) {
853
+ this.host.log("registerFrames skipped - not a list of frames");
854
+ return;
855
+ }
856
+ for (const frame of frames) {
857
+ if (!isSceneFrame(frame)) {
858
+ this.host.log("Frame skipped - not a SceneFrame:", frame);
859
+ continue;
860
+ }
861
+ if (!this.entries.has(frame.id) && this.entries.size >= FRAMES_MAX) {
862
+ this.host.warn(`Frame ${frame.id} skipped - at most ${FRAMES_MAX} frames a scene`);
863
+ continue;
864
+ }
865
+ this.entries.set(frame.id, { frame, shown: null });
866
+ }
867
+ this.host.log("Registered frames:", this.ids);
868
+ if (!this.enabled) return;
869
+ this.apply();
870
+ this.loadRead();
871
+ this.upload().catch(() => {
872
+ });
873
+ }
874
+ /** Venue is known (the client calls this once the session confirms it): the load read, and the upload if it waited */
875
+ enable() {
876
+ if (this.enabled) return;
877
+ this.enabled = true;
878
+ this.loadRead();
879
+ this.upload().catch(() => {
880
+ });
881
+ }
882
+ /** This copy's admin check succeeded (the admin panel calls this): the declaration goes up once Venue is known */
883
+ adminCheckSucceeded() {
884
+ this.adminOk = true;
885
+ this.upload().catch(() => {
886
+ });
887
+ }
888
+ /**
889
+ * A queued framesRefresh (the scene's page saved or reset a frame): read again after a random wait of up to
890
+ * REFRESH_JITTER_MS. Refreshes that arrive inside the wait share its read.
891
+ */
892
+ refresh() {
893
+ if (!this.enabled || this.entries.size === 0 || this.refreshWaiting) return;
894
+ this.refreshWaiting = true;
895
+ const wait = Math.floor(Math.random() * REFRESH_JITTER_MS);
896
+ this.host.log(`Frames refresh in ${wait} ms`);
897
+ dclSetTimeout(() => {
898
+ this.refreshWaiting = false;
899
+ this.loadReadStarted = true;
900
+ this.read().catch(() => {
901
+ });
902
+ }, wait);
903
+ }
904
+ /**
905
+ * A visitor clicked a frame. The link opens when it is an https: one: the shown content's, else the frame's default's
906
+ * - so a scene without Venue (or before its read lands), which shows its own defaults, has no dead frames. The click is
907
+ * posted signed under the shown version (fire and forget; a failure is logged, never shown) only with Venue and
908
+ * something shown. An id not declared opens nothing and posts nothing.
909
+ */
910
+ open(id) {
911
+ const entry = typeof id === "string" ? this.entries.get(id) : void 0;
912
+ if (!entry) {
913
+ this.host.log("openFrame: no frame declared with this id:", id);
914
+ return;
915
+ }
916
+ const shown = entry.shown;
917
+ if (this.enabled && shown) this.postClick(entry.frame.id, shown.version).catch(() => {
918
+ });
919
+ else this.host.log("openFrame: no click counted - no Venue, or the frame shows nothing yet:", id);
920
+ const link = shown ? shown.link : entry.frame.default?.link || "";
921
+ if (link !== "" && HTTPS.test(link)) {
922
+ try {
923
+ Promise.resolve(openExternalUrl({ url: link })).catch((err) => this.host.log("Frame link not opened:", err));
924
+ } catch (err) {
925
+ this.host.log("Frame link not opened:", err);
926
+ }
927
+ }
928
+ }
929
+ /** The routes' base for this scene: the scene id encoded, as any value in a url path is */
930
+ sceneUrl() {
931
+ const sceneId = this.host.getSceneId();
932
+ if (!sceneId) return null;
933
+ return `${this.host.getBaseUrl()}/scene/${encodeURIComponent(sceneId)}`;
934
+ }
935
+ /** The read at load: once, when Venue is known and a frame is declared */
936
+ loadRead() {
937
+ if (this.loadReadStarted || !this.enabled || this.entries.size === 0) return;
938
+ this.loadReadStarted = true;
939
+ this.read().catch(() => {
940
+ });
941
+ }
942
+ /** Read the saved content and show it; a failed read keeps what was shown */
943
+ async read() {
944
+ const base = this.sceneUrl();
945
+ if (!base) {
946
+ this.host.log("Frames: no scene id - nothing read");
947
+ return;
948
+ }
949
+ const seq = ++this.readSeq;
950
+ let frames;
951
+ try {
952
+ const res = await fetch(`${base}/frames`);
953
+ if (!res.ok) {
954
+ this.host.log("Frames read refused:", res.status);
955
+ return;
956
+ }
957
+ const data = await res.json();
958
+ const raw = data && typeof data === "object" ? data.frames : void 0;
959
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
960
+ this.host.log("Frames read: the answer holds no frames");
961
+ return;
962
+ }
963
+ frames = raw;
964
+ } catch (err) {
965
+ this.host.log("Frames read error:", err);
966
+ return;
967
+ }
968
+ if (seq < this.shownSeq) return;
969
+ this.shownSeq = seq;
970
+ this.answer = frames;
971
+ this.apply();
972
+ }
973
+ /** A frame's content from the last good read: its saved content when usable, else its default, else null */
974
+ contentFor(frame) {
975
+ const answer = this.answer;
976
+ if (answer && Object.prototype.hasOwnProperty.call(answer, frame.id)) {
977
+ const saved = savedContent(answer[frame.id]);
978
+ if (saved) return saved;
979
+ this.host.log("Frames: saved content not usable, ignored:", frame.id);
980
+ }
981
+ return defaultContent(frame);
982
+ }
983
+ /** Each declared frame's content handed to its onContent when it differs from what the frame shows */
984
+ apply() {
985
+ if (!this.enabled || this.answer === null) return;
986
+ for (const entry of [...this.entries.values()]) {
987
+ const content = this.contentFor(entry.frame);
988
+ if (!content || sameContent(content, entry.shown)) continue;
989
+ try {
990
+ entry.frame.onContent({ ...content });
991
+ entry.shown = content;
992
+ } catch (err) {
993
+ this.host.error(`Frame ${entry.frame.id}: onContent failed`, err);
994
+ }
995
+ }
996
+ }
997
+ /** The declaration - ids, labels, defaults, never the handlers - once a load, in its own request to the config route */
998
+ async upload() {
999
+ if (this.uploaded || !this.enabled || !this.adminOk || this.entries.size === 0) return;
1000
+ const base = this.sceneUrl();
1001
+ if (!base) return;
1002
+ this.uploaded = true;
1003
+ const frames = [...this.entries.values()].map(({ frame }) => {
1004
+ const d = frame.default;
1005
+ return {
1006
+ id: frame.id,
1007
+ label: frame.label,
1008
+ ...d ? { default: { image: d.image, text: d.text || "", link: d.link || "" } } : {}
1009
+ };
1010
+ });
1011
+ try {
1012
+ const res = await signedFetch({
1013
+ url: `${base}/config`,
1014
+ init: { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ frames }) }
1015
+ });
1016
+ if (res.ok) {
1017
+ this.host.log("Frames declared:", frames.map((f) => f.id));
1018
+ return;
1019
+ }
1020
+ this.host.log("Frames declaration refused:", res.status, errorOf(res.body));
1021
+ } catch (err) {
1022
+ this.host.log("Frames declaration error:", err);
1023
+ }
1024
+ }
1025
+ /** The click, signed: thestatic.tv counts it under the frame's shown version (one a wallet a frame a 10 s) */
1026
+ async postClick(id, version) {
1027
+ const base = this.sceneUrl();
1028
+ if (!base) return;
1029
+ try {
1030
+ const res = await signedFetch({
1031
+ url: `${base}/frames/click`,
1032
+ init: { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ frame: id, version }) }
1033
+ });
1034
+ if (!res.ok) this.host.log("Frame click refused:", id, res.status, errorOf(res.body));
1035
+ } catch (err) {
1036
+ this.host.log("Frame click error:", id, err);
1037
+ }
1038
+ }
1039
+ };
1040
+
696
1041
  // src/ui/guide-ui.tsx
697
1042
  import ReactEcs2, { UiEntity as UiEntity2, Input as Input2, Label as Label2 } from "@dcl/sdk/react-ecs";
698
1043
  import { Color4 as Color43 } from "@dcl/sdk/math";
699
- import { openExternalUrl } from "~system/RestrictedActions";
1044
+ import { openExternalUrl as openExternalUrl2 } from "~system/RestrictedActions";
700
1045
 
701
1046
  // src/ui/theme.ts
702
1047
  import { Color4 } from "@dcl/sdk/math";
@@ -965,6 +1310,7 @@ var GuideUIModule = class {
965
1310
  * Always renders toggle button, plus panel when visible
966
1311
  */
967
1312
  this.getComponent = () => {
1313
+ if (this.client.isVisitorBlocked) return null;
968
1314
  const windowW = UI_DIMENSIONS.guide.width;
969
1315
  const windowH = UI_DIMENSIONS.guide.height;
970
1316
  return ReactEcs2.createElement(UiEntity2, {
@@ -1186,7 +1532,7 @@ var GuideUIModule = class {
1186
1532
  handleChannelClick(video) {
1187
1533
  const baseUrl = this.getBaseUrl();
1188
1534
  const channelUrl = `${baseUrl}/${video.channelId || video.id}`;
1189
- openExternalUrl({ url: channelUrl });
1535
+ openExternalUrl2({ url: channelUrl });
1190
1536
  }
1191
1537
  renderLeftPanel() {
1192
1538
  const sidebarW = this.s(UI_DIMENSIONS.guide.sidebar.width);
@@ -1728,12 +2074,13 @@ var GuideUIModule = class {
1728
2074
  // src/ui/chat-ui.tsx
1729
2075
  import ReactEcs3, { UiEntity as UiEntity3, Label as Label3, Input as Input3, Button as Button2 } from "@dcl/sdk/react-ecs";
1730
2076
  import { Color4 as Color44 } from "@dcl/sdk/math";
1731
- import { signedFetch } from "~system/SignedFetch";
2077
+ import { signedFetch as signedFetch2 } from "~system/SignedFetch";
1732
2078
  import { getPlayer } from "@dcl/sdk/players";
1733
- import { openExternalUrl as openExternalUrl2 } from "~system/RestrictedActions";
2079
+ import { openExternalUrl as openExternalUrl3 } from "~system/RestrictedActions";
1734
2080
  var POLL_INTERVAL_ACTIVE = 5e3;
1735
2081
  var POLL_INTERVAL_PASSIVE = 3e4;
1736
2082
  var MESSAGE_TEXT_INSET = 2 * 2 + 28 + 12 + 8 + 8 + 3 + 12;
2083
+ var HISTORY_ERROR_ID = "sys-history-error";
1737
2084
  var ChatUIModule = class {
1738
2085
  constructor(client, config = {}) {
1739
2086
  // Visibility state
@@ -1757,6 +2104,8 @@ var ChatUIModule = class {
1757
2104
  this.systemMessages = [];
1758
2105
  this.inputText = "";
1759
2106
  this.chatScrollOffset = 0;
2107
+ // The last history read's failure, shown as the messages' last line until a read succeeds (2026-11-17)
2108
+ this.historyError = "";
1760
2109
  // UI preferences
1761
2110
  this.position = "right";
1762
2111
  // Timers
@@ -1771,6 +2120,7 @@ var ChatUIModule = class {
1771
2120
  * Always renders toggle button, plus panel when visible
1772
2121
  */
1773
2122
  this.getComponent = () => {
2123
+ if (this.client.isVisitorBlocked) return null;
1774
2124
  const scaledTheme = scaleChatTheme(DEFAULT_CHAT_THEME, this.client.uiScale);
1775
2125
  const positionStyle = this.getPositionStyle();
1776
2126
  return ReactEcs3.createElement(UiEntity3, {
@@ -1911,7 +2261,7 @@ var ChatUIModule = class {
1911
2261
  this.isSigningIn = true;
1912
2262
  try {
1913
2263
  const baseUrl = this.getBaseUrl();
1914
- const response = await signedFetch({
2264
+ const response = await signedFetch2({
1915
2265
  url: `${baseUrl}/api/auth/dcl`,
1916
2266
  init: {
1917
2267
  method: "POST",
@@ -1963,8 +2313,13 @@ var ChatUIModule = class {
1963
2313
  async fetchMessages() {
1964
2314
  try {
1965
2315
  const baseUrl = this.getBaseUrl();
1966
- const response = await fetch(`${baseUrl}/api/chat/history?channelId=${this.currentChannelId}`);
2316
+ const response = await fetch(`${baseUrl}/api/chat/history?channelId=${encodeURIComponent(this.currentChannelId)}`);
2317
+ if (!response.ok) {
2318
+ this.historyError = `CHAT HISTORY UNAVAILABLE (${response.status})`;
2319
+ return;
2320
+ }
1967
2321
  const data = await response.json();
2322
+ this.historyError = "";
1968
2323
  if (data.messages) {
1969
2324
  const twentyFourHoursAgo = Date.now() - 24 * 60 * 60 * 1e3;
1970
2325
  const recentMsgs = data.messages.filter(
@@ -1992,6 +2347,7 @@ var ChatUIModule = class {
1992
2347
  this.realMessages = sortedMsgs;
1993
2348
  }
1994
2349
  } catch (e) {
2350
+ this.historyError = "CHAT HISTORY UNAVAILABLE";
1995
2351
  }
1996
2352
  }
1997
2353
  async handleSend() {
@@ -2007,7 +2363,7 @@ var ChatUIModule = class {
2007
2363
  this.inputText = "";
2008
2364
  try {
2009
2365
  const baseUrl = this.getBaseUrl();
2010
- const response = await signedFetch({
2366
+ const response = await signedFetch2({
2011
2367
  url: `${baseUrl}/api/chat/send`,
2012
2368
  init: {
2013
2369
  method: "POST",
@@ -2050,6 +2406,7 @@ var ChatUIModule = class {
2050
2406
  switchChannel(channelId) {
2051
2407
  this.currentChannelId = channelId;
2052
2408
  this.realMessages = [];
2409
+ this.historyError = "";
2053
2410
  this.showChannelDropdown = false;
2054
2411
  this.chatScrollOffset = 0;
2055
2412
  this.channelPage = 0;
@@ -2164,6 +2521,16 @@ var ChatUIModule = class {
2164
2521
  }
2165
2522
  renderMessagesArea(theme) {
2166
2523
  const allMessages = [...this.systemMessages, ...this.realMessages];
2524
+ if (this.historyError) {
2525
+ allMessages.push({
2526
+ id: HISTORY_ERROR_ID,
2527
+ username: "SYSTEM",
2528
+ text: this.historyError,
2529
+ uid: "system",
2530
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
2531
+ isSystem: true
2532
+ });
2533
+ }
2167
2534
  const totalMessages = allMessages.length;
2168
2535
  const maxOffset = Math.max(0, totalMessages - UI_DIMENSIONS.chat.messagesPerPage);
2169
2536
  if (this.chatScrollOffset > maxOffset) this.chatScrollOffset = maxOffset;
@@ -2250,7 +2617,12 @@ var ChatUIModule = class {
2250
2617
  return ReactEcs3.createElement(UiEntity3, {
2251
2618
  key: msg.id,
2252
2619
  uiTransform: { width: "100%", height: 24, marginBottom: 4, flexShrink: 0 },
2253
- uiText: { value: msg.text, fontSize: theme.systemMessage, color: THEME.colors.green, textAlign: "middle-left" }
2620
+ uiText: {
2621
+ value: msg.text,
2622
+ fontSize: theme.systemMessage,
2623
+ color: msg.id === HISTORY_ERROR_ID ? THEME.colors.yellow : THEME.colors.green,
2624
+ textAlign: "middle-left"
2625
+ }
2254
2626
  });
2255
2627
  }
2256
2628
  renderChatMessage(msg, theme) {
@@ -2365,7 +2737,7 @@ var ChatUIModule = class {
2365
2737
  uiBackground: { color: THEME.colors.cyan },
2366
2738
  color: Color44.Black(),
2367
2739
  onMouseDown: () => {
2368
- openExternalUrl2({ url: `${baseUrl}/apply` });
2740
+ openExternalUrl3({ url: `${baseUrl}/login` });
2369
2741
  }
2370
2742
  })
2371
2743
  ]
@@ -2537,11 +2909,11 @@ var ChatUIModule = class {
2537
2909
  };
2538
2910
 
2539
2911
  // src/ui/admin-panel-ui.tsx
2540
- import ReactEcs5, { UiEntity as UiEntity5, Button as Button3, Label as Label5, Input as Input4 } from "@dcl/sdk/react-ecs";
2541
- import { Color4 as Color45, Vector3 } from "@dcl/sdk/math";
2912
+ import ReactEcs6, { UiEntity as UiEntity6, Button as Button4, Label as Label6, Input as Input4 } from "@dcl/sdk/react-ecs";
2913
+ import { Color4 as Color46 } from "@dcl/sdk/math";
2542
2914
  import { getPlayer as getPlayer2 } from "@dcl/sdk/players";
2543
- import { movePlayerTo, openExternalUrl as openExternalUrl3 } from "~system/RestrictedActions";
2544
- import { signedFetch as signedFetch2 } from "~system/SignedFetch";
2915
+ import { openExternalUrl as openExternalUrl5 } from "~system/RestrictedActions";
2916
+ import { signedFetch as signedFetch3 } from "~system/SignedFetch";
2545
2917
 
2546
2918
  // src/ui/ui-renderer.tsx
2547
2919
  import ReactEcs4, { ReactEcsRenderer, UiEntity as UiEntity4, Label as Label4 } from "@dcl/sdk/react-ecs";
@@ -2649,6 +3021,7 @@ function createStaticUI(client) {
2649
3021
  initNotificationSystem();
2650
3022
  return function StaticUI() {
2651
3023
  const currentScale = client.uiScale;
3024
+ const blocked = client.isVisitorBlocked;
2652
3025
  const guideComponent = client.guideUI?.getComponent() ?? null;
2653
3026
  const chatComponent = client.chatUI?.getComponent() ?? null;
2654
3027
  const adminComponent = client.adminPanel?.getComponent() ?? null;
@@ -2664,7 +3037,7 @@ function createStaticUI(client) {
2664
3037
  alignItems: "center"
2665
3038
  }
2666
3039
  },
2667
- /* @__PURE__ */ ReactEcs4.createElement(NotificationBanner, null),
3040
+ blocked ? null : /* @__PURE__ */ ReactEcs4.createElement(NotificationBanner, null),
2668
3041
  guideComponent,
2669
3042
  chatComponent,
2670
3043
  adminComponent
@@ -2676,24 +3049,436 @@ function setupStaticUI(client) {
2676
3049
  ReactEcsRenderer.setUiRenderer(StaticUI);
2677
3050
  }
2678
3051
 
3052
+ // src/ui/blocked-notice.tsx
3053
+ import ReactEcs5, { UiEntity as UiEntity5, Label as Label5, Button as Button3 } from "@dcl/sdk/react-ecs";
3054
+ import { Color4 as Color45 } from "@dcl/sdk/math";
3055
+ import { openExternalUrl as openExternalUrl4 } from "~system/RestrictedActions";
3056
+ var DEFAULT_SITE_URL = "https://thestatic.tv";
3057
+ function blockedNoticeLines(standing, kickLeftMs) {
3058
+ if (standing === "banned") {
3059
+ return ["BANNED FROM THIS SCENE", "The scene's moderators banned", "this wallet."];
3060
+ }
3061
+ if (standing === "kicked") {
3062
+ const minutes = Math.max(1, Math.ceil(kickLeftMs / 6e4));
3063
+ return ["REMOVED FROM THIS SCENE", "A moderator cleared the scene.", `You can come back in ${minutes} min.`];
3064
+ }
3065
+ if (standing === "private") {
3066
+ return ["PRIVATE EVENT", "Open to TheStatic.tv citizens right now."];
3067
+ }
3068
+ return [];
3069
+ }
3070
+ function blockedNoticeAction(standing, siteUrl = DEFAULT_SITE_URL) {
3071
+ if (standing === "private") return { label: "BECOME A CITIZEN", url: `${siteUrl}/login` };
3072
+ return null;
3073
+ }
3074
+ function BlockedNotice(props) {
3075
+ const lines = blockedNoticeLines(props.standing, props.kickLeftMs);
3076
+ if (lines.length === 0) return null;
3077
+ const s = (v) => Math.round(v * props.scale);
3078
+ const [title, ...body] = lines;
3079
+ const action = blockedNoticeAction(props.standing, props.siteUrl || DEFAULT_SITE_URL);
3080
+ return /* @__PURE__ */ ReactEcs5.createElement(
3081
+ UiEntity5,
3082
+ {
3083
+ uiTransform: {
3084
+ width: "100%",
3085
+ height: "100%",
3086
+ positionType: "absolute",
3087
+ justifyContent: "center",
3088
+ alignItems: "center"
3089
+ }
3090
+ },
3091
+ /* @__PURE__ */ ReactEcs5.createElement(
3092
+ UiEntity5,
3093
+ {
3094
+ uiTransform: { width: s(460), flexDirection: "column", alignItems: "center", padding: s(20) },
3095
+ uiBackground: { color: Color45.create(0.05, 0.05, 0.08, 0.95) }
3096
+ },
3097
+ /* @__PURE__ */ ReactEcs5.createElement(Label5, { value: title, fontSize: s(22), color: Color45.create(0.9, 0.2, 0.2, 1), uiTransform: { height: s(34) } }),
3098
+ body.map((line, i) => /* @__PURE__ */ ReactEcs5.createElement(Label5, { key: `blocked-line-${i}`, value: line, fontSize: s(16), color: Color45.White(), uiTransform: { height: s(26) } })),
3099
+ action && /* @__PURE__ */ ReactEcs5.createElement(
3100
+ Button3,
3101
+ {
3102
+ uiTransform: { width: s(220), height: s(36), margin: { top: s(12) } },
3103
+ uiBackground: { color: Color45.create(0, 0.8, 0.8, 1) },
3104
+ value: action.label,
3105
+ fontSize: s(16),
3106
+ color: Color45.Black(),
3107
+ onMouseDown: () => {
3108
+ openExternalUrl4({ url: action.url });
3109
+ }
3110
+ }
3111
+ )
3112
+ )
3113
+ );
3114
+ }
3115
+
3116
+ // src/utils/player-wait.ts
3117
+ var PLAYER_WAIT_STEP_MS = 1e3;
3118
+ var PLAYER_WAIT_MAX_MS = 30 * 1e3;
3119
+ var isGuest = (player) => player.isGuest === true;
3120
+ var PlayerWait = class {
3121
+ constructor(deps) {
3122
+ this.timerId = null;
3123
+ this.reads = 0;
3124
+ /** This wait has checked a guest reading already */
3125
+ this.guestChecked = false;
3126
+ this.deps = deps;
3127
+ }
3128
+ get stepMs() {
3129
+ return this.deps.stepMs ?? PLAYER_WAIT_STEP_MS;
3130
+ }
3131
+ get maxMs() {
3132
+ return this.deps.maxMs ?? PLAYER_WAIT_MAX_MS;
3133
+ }
3134
+ /** True while a wait is reading the player */
3135
+ get waiting() {
3136
+ return this.timerId !== null;
3137
+ }
3138
+ /**
3139
+ * The check with the player now, or - with no player yet - a wait that runs it once one appears. A guest reading is
3140
+ * checked now and the wait goes on for a non-guest one. Resolves when the check is done, or at once when there is
3141
+ * none to run.
3142
+ */
3143
+ async run() {
3144
+ const player = this.read();
3145
+ if (player && !isGuest(player)) {
3146
+ this.stop();
3147
+ await this.deps.check(player);
3148
+ return;
3149
+ }
3150
+ if (player) {
3151
+ this.start("A guest reading - checked now; waiting for a non-guest one");
3152
+ this.guestChecked = true;
3153
+ await this.deps.check(player);
3154
+ return;
3155
+ }
3156
+ this.start("No player data yet - waiting for one");
3157
+ }
3158
+ /** A wait, unless one is running (one at a time) */
3159
+ start(msg) {
3160
+ if (this.timerId !== null) return;
3161
+ this.reads = 0;
3162
+ this.guestChecked = false;
3163
+ this.deps.log?.(msg);
3164
+ this.timerId = this.deps.setInterval(() => this.tick(), this.stepMs);
3165
+ }
3166
+ tick() {
3167
+ this.reads++;
3168
+ const player = this.read();
3169
+ if (player && !isGuest(player)) {
3170
+ this.stop();
3171
+ this.deps.log?.(`Player resolved after ${this.reads} read(s)`);
3172
+ this.deps.check(player).catch(() => {
3173
+ });
3174
+ return;
3175
+ }
3176
+ if (player && !this.guestChecked) {
3177
+ this.guestChecked = true;
3178
+ this.deps.log?.(`A guest reading after ${this.reads} read(s) - checked now; still waiting for a non-guest one`);
3179
+ this.deps.check(player).catch(() => {
3180
+ });
3181
+ }
3182
+ if (this.reads * this.stepMs >= this.maxMs) {
3183
+ this.stop();
3184
+ this.deps.log?.(`No non-guest player after ${this.maxMs / 1e3} s - no further check`);
3185
+ }
3186
+ }
3187
+ stop() {
3188
+ if (this.timerId === null) return;
3189
+ this.deps.clearInterval(this.timerId);
3190
+ this.timerId = null;
3191
+ }
3192
+ read() {
3193
+ try {
3194
+ const player = this.deps.getPlayer();
3195
+ return player && player.userId ? player : null;
3196
+ } catch {
3197
+ return null;
3198
+ }
3199
+ }
3200
+ };
3201
+
3202
+ // src/modules/moderation.ts
3203
+ import { engine as engine4, Transform as Transform2, MeshCollider, ColliderLayer } from "@dcl/sdk/ecs";
3204
+ import { Vector3 } from "@dcl/sdk/math";
3205
+ import { movePlayerTo } from "~system/RestrictedActions";
3206
+ var KICK_MS = 2 * 60 * 1e3;
3207
+ var REREAD_MS = 60 * 1e3;
3208
+ var READ_GAP_MS = 5e3;
3209
+ var HINT_SPREAD_MS = 3e3;
3210
+ var CITIZEN_WAIT_MS = 1e4;
3211
+ var CHECK_EVERY_S = 1;
3212
+ function namesMe(wallet, mine) {
3213
+ if (typeof wallet !== "string" || wallet === "") return false;
3214
+ if (typeof mine !== "string" || mine === "") return false;
3215
+ return wallet.toLowerCase() === mine.toLowerCase();
3216
+ }
3217
+ var ModerationModule = class {
3218
+ constructor(deps) {
3219
+ this.banned = false;
3220
+ this.kickedUntil = 0;
3221
+ this.canModerate = false;
3222
+ // Private mode (2026-11-19): the last answer's word on this visitor, its isCitizen and when it came, a hint's read
3223
+ // waiting its random spread, and the callers of checkCitizen() waiting on the next read
3224
+ this.privateBlocked = false;
3225
+ this.citizen = false;
3226
+ this.citizenAnsweredAt = null;
3227
+ this.hintDueAt = null;
3228
+ this.readWaiters = [];
3229
+ this.rects = [];
3230
+ this.boxes = [];
3231
+ this.wallEntities = [];
3232
+ this.lastBlocked = false;
3233
+ this.lastStanding = "clear";
3234
+ this.lastReadAt = Number.NEGATIVE_INFINITY;
3235
+ this.readInFlight = false;
3236
+ this.readPending = false;
3237
+ this.wasInScene = null;
3238
+ this.sinceCheck = 0;
3239
+ this.started = false;
3240
+ /** Every CHECK_EVERY_S: a lapsed kick, the re-reads, and a blocked visitor inside a wall moved above it */
3241
+ this.system = (dt) => {
3242
+ if (this.hintDueAt !== null && this.now() >= this.hintDueAt) {
3243
+ this.hintDueAt = null;
3244
+ this.requestRead();
3245
+ }
3246
+ if (this.readWaiters.length > 0) {
3247
+ const t = this.now();
3248
+ const expired = this.readWaiters.filter((w) => t >= w.deadline);
3249
+ if (expired.length > 0) {
3250
+ this.readWaiters = this.readWaiters.filter((w) => t < w.deadline);
3251
+ for (const w of expired) w.resolve();
3252
+ }
3253
+ }
3254
+ this.sinceCheck += dt;
3255
+ if (this.sinceCheck < CHECK_EVERY_S) return;
3256
+ this.sinceCheck = 0;
3257
+ const now = this.now();
3258
+ if (this.kickedUntil > 0 && now >= this.kickedUntil) {
3259
+ this.kickedUntil = 0;
3260
+ this.sync();
3261
+ }
3262
+ const me = getPlayerPosition();
3263
+ const inScene = me !== null && this.rects.length > 0 && inParcels(me, this.rects);
3264
+ if (inScene && this.wasInScene === false) this.readPending = true;
3265
+ if (inScene && now - this.lastReadAt >= REREAD_MS) this.readPending = true;
3266
+ this.wasInScene = inScene;
3267
+ this.tryRead();
3268
+ if (me && this.blocked && insideWalls(me, this.boxes)) {
3269
+ const to = ejectPoint(this.boxes, this.rects, me);
3270
+ if (to) {
3271
+ this.log("Blocked and inside the walls - moving above them", to);
3272
+ Promise.resolve(movePlayerTo({ newRelativePosition: Vector3.create(to.x, to.y, to.z) })).catch(() => {
3273
+ });
3274
+ }
3275
+ }
3276
+ };
3277
+ this.deps = deps;
3278
+ }
3279
+ now() {
3280
+ return this.deps.now ? this.deps.now() : Date.now();
3281
+ }
3282
+ log(msg, ...args) {
3283
+ this.deps.log?.(msg, ...args);
3284
+ }
3285
+ /** Reads the scene's parcels and starts the checks (once) */
3286
+ async start() {
3287
+ if (this.started) return;
3288
+ this.started = true;
3289
+ engine4.addSystem(this.system);
3290
+ try {
3291
+ await getSceneBounds();
3292
+ this.rects = getParcelRects();
3293
+ this.boxes = wallBoxes(this.rects);
3294
+ } catch {
3295
+ }
3296
+ this.sync();
3297
+ }
3298
+ /** banned, kicked (KICK ALL, until it lapses), private (the scene's private mode) or clear - in that precedence */
3299
+ get standing() {
3300
+ if (this.banned) return "banned";
3301
+ if (this.kickedUntil > 0 && this.now() < this.kickedUntil) return "kicked";
3302
+ if (this.privateBlocked) return "private";
3303
+ return "clear";
3304
+ }
3305
+ /** The last answer's isCitizen (2026-11-19): false before one, and from a server that does not answer it */
3306
+ get isCitizen() {
3307
+ return this.citizen;
3308
+ }
3309
+ /**
3310
+ * Whether this visitor is a TheStatic.tv citizen (2026-11-19): the last answer when it is under READ_GAP_MS old, else
3311
+ * the answer of the next read - started now, or the one in flight - through the same gate as every other read. A
3312
+ * read that fails answers what the last one said (false before any), and so does one that has not settled within
3313
+ * CITIZEN_WAIT_MS (the module's system ends that wait).
3314
+ */
3315
+ async checkCitizen() {
3316
+ if (this.citizenAnsweredAt !== null && this.now() - this.citizenAnsweredAt < READ_GAP_MS) return this.citizen;
3317
+ await new Promise((resolve) => {
3318
+ this.readWaiters.push({ resolve, deadline: this.now() + CITIZEN_WAIT_MS });
3319
+ if (!this.readInFlight) this.requestRead();
3320
+ });
3321
+ return this.citizen;
3322
+ }
3323
+ get blocked() {
3324
+ return this.standing !== "clear";
3325
+ }
3326
+ /** How long a kick has left, in ms (0 when not kicked) */
3327
+ get kickLeftMs() {
3328
+ return this.standing === "kicked" ? Math.max(0, this.kickedUntil - this.now()) : 0;
3329
+ }
3330
+ /**
3331
+ * admin-check's answer: the ban list's word on this visitor, whether they moderate the scene, and (2026-11-19) the
3332
+ * private mode's word and whether they are a citizen. Only the boolean true counts, so an answer without the new
3333
+ * fields reads as open and not a citizen. One who can moderate is never walled by private mode here, whatever the
3334
+ * answer says (the server admits them; this keeps a wrong answer from locking an admin out).
3335
+ */
3336
+ applyStanding(answer) {
3337
+ this.banned = answer.isBanned === true;
3338
+ this.canModerate = answer.canModerate === true;
3339
+ this.privateBlocked = answer.privateBlocked === true && !this.canModerate;
3340
+ this.citizen = answer.isCitizen === true;
3341
+ this.citizenAnsweredAt = this.now();
3342
+ this.lastReadAt = Math.max(this.lastReadAt, this.now());
3343
+ this.sync();
3344
+ }
3345
+ /**
3346
+ * A command from the scene's queue (the poll every visitor runs). Returns true for the three this module takes.
3347
+ * kickBanned names a wallet: the named visitor re-reads their standing, every other visitor does nothing.
3348
+ * privateMode (2026-11-19) is a hint for every visitor: its payload is not read - a re-read after a random wait of up
3349
+ * to HINT_SPREAD_MS, joined by any hint that comes while it waits, and still gated by one read in flight and
3350
+ * READ_GAP_MS, so no number of hints makes this copy read faster than that.
3351
+ */
3352
+ handleCommand(type, payload) {
3353
+ if (type === "privateMode") {
3354
+ if (this.hintDueAt === null) {
3355
+ const r = this.deps.random ? this.deps.random() : Math.random();
3356
+ const wait = Number.isFinite(r) ? Math.min(Math.max(r, 0), 1) * HINT_SPREAD_MS : 0;
3357
+ this.hintDueAt = this.now() + wait;
3358
+ this.log(`Private mode changed - reading my standing in ${Math.round(wait)} ms`);
3359
+ }
3360
+ return true;
3361
+ }
3362
+ if (type === "kickBanned") {
3363
+ if (namesMe(payload?.wallet, this.deps.myWallet())) {
3364
+ this.log("A kick names me - reading my standing");
3365
+ this.requestRead();
3366
+ }
3367
+ return true;
3368
+ }
3369
+ if (type === "kickAll") {
3370
+ if (!this.canModerate) {
3371
+ this.kickedUntil = this.now() + KICK_MS;
3372
+ this.sync();
3373
+ }
3374
+ return true;
3375
+ }
3376
+ return false;
3377
+ }
3378
+ /** Ask for a fresh standing read: at once when the gate allows, else as soon as it does */
3379
+ requestRead() {
3380
+ this.readPending = true;
3381
+ this.tryRead();
3382
+ }
3383
+ tryRead() {
3384
+ if (!this.readPending || this.readInFlight) return;
3385
+ const now = this.now();
3386
+ if (now - this.lastReadAt < READ_GAP_MS) return;
3387
+ this.readPending = false;
3388
+ this.readInFlight = true;
3389
+ this.lastReadAt = now;
3390
+ this.deps.reread().catch(() => {
3391
+ }).finally(() => {
3392
+ this.readInFlight = false;
3393
+ const waiters = this.readWaiters;
3394
+ this.readWaiters = [];
3395
+ for (const w of waiters) w.resolve();
3396
+ });
3397
+ }
3398
+ /** The walls follow blocked; the scene hears of a change */
3399
+ sync() {
3400
+ const standing = this.standing;
3401
+ const blocked = standing !== "clear";
3402
+ if (blocked && this.wallEntities.length === 0) this.raiseWalls();
3403
+ if (!blocked && this.wallEntities.length > 0) this.lowerWalls();
3404
+ if (blocked !== this.lastBlocked || standing !== this.lastStanding) {
3405
+ this.lastBlocked = blocked;
3406
+ this.lastStanding = standing;
3407
+ this.log(`Standing: ${standing}`);
3408
+ this.deps.onChange?.(blocked, standing);
3409
+ }
3410
+ }
3411
+ raiseWalls() {
3412
+ for (const b of this.boxes) {
3413
+ const wall = engine4.addEntity();
3414
+ Transform2.create(wall, {
3415
+ position: Vector3.create((b.minX + b.maxX) / 2, b.top / 2, (b.minZ + b.maxZ) / 2),
3416
+ scale: Vector3.create(b.maxX - b.minX, b.top, b.maxZ - b.minZ)
3417
+ });
3418
+ MeshCollider.setBox(wall, ColliderLayer.CL_PHYSICS);
3419
+ this.wallEntities.push(wall);
3420
+ }
3421
+ }
3422
+ lowerWalls() {
3423
+ for (const wall of this.wallEntities) engine4.removeEntity(wall);
3424
+ this.wallEntities = [];
3425
+ }
3426
+ /** The walls this copy has up (one per parcel while blocked) */
3427
+ get wallCount() {
3428
+ return this.wallEntities.length;
3429
+ }
3430
+ };
3431
+
2679
3432
  // src/ui/admin-panel-ui.tsx
2680
- var BAN_KICK_POSITION = Vector3.create(16, -50, 16);
3433
+ var FIGURE_NAMES = ["recordings", "vaulted", "slugKeyedLeft", "pendingReports"];
3434
+ function figuresOf(value) {
3435
+ const figures = value?.figures;
3436
+ if (!figures || typeof figures !== "object") return null;
3437
+ if (!FIGURE_NAMES.every((name) => Number.isInteger(figures[name]))) return null;
3438
+ const basis = value.basis;
3439
+ return {
3440
+ recordings: figures.recordings,
3441
+ vaulted: figures.vaulted,
3442
+ slugKeyedLeft: figures.slugKeyedLeft,
3443
+ pendingReports: figures.pendingReports,
3444
+ ...typeof basis === "string" ? { basis } : {}
3445
+ };
3446
+ }
3447
+ function channelDeleteLines(look, changed) {
3448
+ const lines = [];
3449
+ if (changed) lines.push("WHAT IT HOLDS CHANGED - READ AGAIN");
3450
+ if (look.unlinkOnly) {
3451
+ lines.push("This only unlinks the channel.", "Nothing is deleted.");
3452
+ return lines;
3453
+ }
3454
+ const { recordings, vaulted, slugKeyedLeft } = look.figures;
3455
+ if (recordings > 0) {
3456
+ lines.push(`Deletes ${recordings} recording${recordings === 1 ? "" : "s"} for good`);
3457
+ if (vaulted > 0) lines.push(`${vaulted} of them in the Vault`);
3458
+ } else {
3459
+ lines.push("It holds no recordings");
3460
+ }
3461
+ if (slugKeyedLeft > 0) lines.push(`${slugKeyedLeft} record${slugKeyedLeft === 1 ? "" : "s"} under its name stay${slugKeyedLeft === 1 ? "s" : ""}`);
3462
+ lines.push("Stream history is kept");
3463
+ return lines;
3464
+ }
3465
+ var SEEN_COMMAND_IDS_MAX = 200;
2681
3466
  var C2 = {
2682
- bg: Color45.create(0.08, 0.08, 0.12, 0.98),
2683
- header: Color45.create(0.9, 0.15, 0.15, 1),
2684
- tabActive: Color45.create(0, 0.7, 0.7, 1),
2685
- tabInactive: Color45.create(0.15, 0.15, 0.2, 1),
2686
- section: Color45.create(0.12, 0.12, 0.18, 1),
2687
- btn: Color45.create(0.2, 0.2, 0.28, 1),
2688
- cyan: Color45.create(0, 0.8, 0.8, 1),
2689
- magenta: Color45.create(0.85, 0.2, 0.55, 1),
2690
- yellow: Color45.create(0.95, 0.75, 0.1, 1),
2691
- green: Color45.create(0.2, 0.75, 0.3, 1),
2692
- red: Color45.create(0.85, 0.2, 0.2, 1),
2693
- purple: Color45.create(0.6, 0.3, 0.85, 1),
2694
- orange: Color45.create(0.95, 0.5, 0.15, 1),
2695
- text: Color45.White(),
2696
- textDim: Color45.create(0.6, 0.6, 0.7, 1)
3467
+ bg: Color46.create(0.08, 0.08, 0.12, 0.98),
3468
+ header: Color46.create(0.9, 0.15, 0.15, 1),
3469
+ tabActive: Color46.create(0, 0.7, 0.7, 1),
3470
+ tabInactive: Color46.create(0.15, 0.15, 0.2, 1),
3471
+ section: Color46.create(0.12, 0.12, 0.18, 1),
3472
+ btn: Color46.create(0.2, 0.2, 0.28, 1),
3473
+ cyan: Color46.create(0, 0.8, 0.8, 1),
3474
+ magenta: Color46.create(0.85, 0.2, 0.55, 1),
3475
+ yellow: Color46.create(0.95, 0.75, 0.1, 1),
3476
+ green: Color46.create(0.2, 0.75, 0.3, 1),
3477
+ red: Color46.create(0.85, 0.2, 0.2, 1),
3478
+ purple: Color46.create(0.6, 0.3, 0.85, 1),
3479
+ orange: Color46.create(0.95, 0.5, 0.15, 1),
3480
+ text: Color46.White(),
3481
+ textDim: Color46.create(0.6, 0.6, 0.7, 1)
2697
3482
  };
2698
3483
  var AdminPanelUIModule = class {
2699
3484
  // UI scaling - uses shared client.uiScale
@@ -2714,6 +3499,10 @@ var AdminPanelUIModule = class {
2714
3499
  this.channelCreateError = "";
2715
3500
  this.channelDeleting = false;
2716
3501
  this.channelDeleteError = "";
3502
+ // The delete's confirm step (thestatic.tv 2026-11-13): what the server's look answered the channel holds - shown in
3503
+ // the panel and sent back as the acknowledgement - or null while no confirm is open
3504
+ this.channelDeleteLook = null;
3505
+ this.channelDeleteChanged = false;
2717
3506
  this.keyRotating = false;
2718
3507
  this.keyRotateStatus = "";
2719
3508
  this.streamControlling = false;
@@ -2731,34 +3520,90 @@ var AdminPanelUIModule = class {
2731
3520
  this.broadcastText = "";
2732
3521
  this.modStatus = "";
2733
3522
  this.modsFetched = false;
3523
+ // What the last kick sent from the Mod tab came to (2026-11-17): KICK ALL and the ban's kick are queued on
3524
+ // thestatic.tv, where every visitor's copy reads them
3525
+ this.kickStatus = "";
3526
+ // The Video and Broadcast buttons go through the same queue since 2026-11-18 (until then they reached the presser's
3527
+ // copy alone): what the last send from each came to, one line a section
3528
+ this.videoStatus = "";
3529
+ this.broadcastStatus = "";
3530
+ /** The url the screen last played - the scene's current one from the video state at load, or the last play here - which PLAYBACK Play sends */
3531
+ this.currentVideoUrl = null;
3532
+ // Scene controls (2026-11-18): the scene's own declaration, each control's current option on this copy, the tab's
3533
+ // status line, and the once-a-load gates for the declaration's upload and the saved state's read
3534
+ this.controls = [];
3535
+ this.currentOption = {};
3536
+ this.controlStatus = "";
3537
+ this.controlsUploaded = false;
3538
+ this.stateRead = false;
3539
+ /** init has read the video state: the saved control state may be read now (a persist control registered later reads then) */
3540
+ this.loadReadsDone = false;
3541
+ // The command poll (2026-11-18): the server's cursor, sent back as since once known, and the ids seen - the last
3542
+ // SEEN_COMMAND_IDS_MAX, this copy's own sends among them - so no command runs twice here
3543
+ this.commandCursor = null;
3544
+ this.seenCommandIds = /* @__PURE__ */ new Set();
3545
+ this.seenCommandOrder = [];
3546
+ this.controlLine = { sent: "Sent to everyone", notSent: "Not sent", show: (line) => {
3547
+ this.controlStatus = line;
3548
+ } };
3549
+ this.videoLine = { sent: "Sent to everyone", notSent: "Not sent", show: (line) => {
3550
+ this.videoStatus = line;
3551
+ } };
3552
+ this.broadcastLine = { sent: "Sent to everyone", notSent: "Not sent", show: (line) => {
3553
+ this.broadcastStatus = line;
3554
+ } };
3555
+ // Private mode (2026-11-19, Venue): the switch's state from the last read (null until an answer carries it), and the
3556
+ // MOD tab's line for the switch
3557
+ this.privateModeOn = null;
3558
+ this.privateStatus = "";
3559
+ this.privateLine = { sent: "Sent to everyone", notSent: "Not sent", show: (line) => {
3560
+ this.privateStatus = line;
3561
+ } };
2734
3562
  // --- UI Components ---
2735
- this.SectionHead = ({ label, color }) => /* @__PURE__ */ ReactEcs5.createElement(
2736
- UiEntity5,
3563
+ this.SectionHead = ({ label, color }) => /* @__PURE__ */ ReactEcs6.createElement(
3564
+ UiEntity6,
2737
3565
  {
2738
3566
  uiTransform: { width: "100%", height: this.s(UI_DIMENSIONS.admin.sectionHeadHeight), margin: { bottom: 8 }, padding: { left: 10 }, alignItems: "center" },
2739
- uiBackground: { color: Color45.create(color.r * 0.3, color.g * 0.3, color.b * 0.3, 0.5) }
3567
+ uiBackground: { color: Color46.create(color.r * 0.3, color.g * 0.3, color.b * 0.3, 0.5) }
2740
3568
  },
2741
- /* @__PURE__ */ ReactEcs5.createElement(Label5, { value: label, fontSize: this.theme.sectionHead, color })
3569
+ /* @__PURE__ */ ReactEcs6.createElement(Label6, { value: label, fontSize: this.theme.sectionHead, color })
2742
3570
  );
2743
- this.TabBtn = ({ label, tab }) => /* @__PURE__ */ ReactEcs5.createElement(
2744
- Button3,
3571
+ this.TabBtn = ({ label, tab }) => /* @__PURE__ */ ReactEcs6.createElement(
3572
+ Button4,
2745
3573
  {
2746
3574
  uiTransform: { flexGrow: 1, height: this.s(UI_DIMENSIONS.admin.tabHeight), justifyContent: "center", alignItems: "center" },
2747
3575
  uiBackground: { color: this.activeTab === tab ? C2.tabActive : C2.tabInactive },
2748
3576
  value: label,
2749
3577
  fontSize: this.theme.tabButton,
2750
- color: this.activeTab === tab ? Color45.Black() : C2.text,
3578
+ color: this.activeTab === tab ? Color46.Black() : C2.text,
2751
3579
  textAlign: "middle-center",
2752
3580
  onMouseDown: () => this.setActiveTab(tab)
2753
3581
  }
2754
3582
  );
3583
+ /**
3584
+ * The CONTROLS tab (2026-11-18): a section per registered control, a button per option, OFF when the control has one,
3585
+ * the current option highlighted, and one status line for the last press. Listed first in the tab bar, only when
3586
+ * controls are registered, for the same admins the VIDEO tab is.
3587
+ */
3588
+ this.ControlsTab = () => {
3589
+ const t = this.theme;
3590
+ return /* @__PURE__ */ ReactEcs6.createElement(UiEntity6, { uiTransform: { flexDirection: "column", width: "100%", padding: 10 } }, this.controls.map((control) => /* @__PURE__ */ ReactEcs6.createElement(UiEntity6, { key: `control-${control.id}`, uiTransform: { flexDirection: "column", margin: { bottom: 14 } } }, /* @__PURE__ */ ReactEcs6.createElement(this.SectionHead, { label: control.label, color: C2.cyan }), /* @__PURE__ */ ReactEcs6.createElement(UiEntity6, { uiTransform: { flexDirection: "row", flexWrap: "wrap" } }, control.options.map((option) => this.controlButton(control, option.id, option.label)), control.off === true && this.controlButton(control, "off", "OFF")))), this.controlStatus && /* @__PURE__ */ ReactEcs6.createElement(
3591
+ Label6,
3592
+ {
3593
+ value: this.controlStatus,
3594
+ fontSize: t.status,
3595
+ color: this.controlStatus.startsWith("Not sent") ? C2.red : C2.green,
3596
+ uiTransform: { height: this.s(18) }
3597
+ }
3598
+ ));
3599
+ };
2755
3600
  this.VideoTab = () => {
2756
3601
  if (!this.streamFetched) {
2757
3602
  this.fetchStreamData();
2758
3603
  }
2759
3604
  const t = this.theme;
2760
- return /* @__PURE__ */ ReactEcs5.createElement(UiEntity5, { uiTransform: { flexDirection: "column", width: "100%", padding: 10 } }, !this.streamData?.hasChannel && /* @__PURE__ */ ReactEcs5.createElement(UiEntity5, { uiTransform: { flexDirection: "column", margin: { bottom: 14 } } }, /* @__PURE__ */ ReactEcs5.createElement(this.SectionHead, { label: "LIVE STREAM", color: C2.btn }), /* @__PURE__ */ ReactEcs5.createElement(Label5, { value: "No streaming channel linked", fontSize: t.labelSmall, color: C2.textDim, uiTransform: { margin: { bottom: 8 } } }), this.isOwner && /* @__PURE__ */ ReactEcs5.createElement(UiEntity5, { uiTransform: { flexDirection: "column" } }, this.streamData?.trialAvailable && /* @__PURE__ */ ReactEcs5.createElement(UiEntity5, { uiTransform: { flexDirection: "column", margin: { bottom: 10 } } }, /* @__PURE__ */ ReactEcs5.createElement(
2761
- Button3,
3605
+ return /* @__PURE__ */ ReactEcs6.createElement(UiEntity6, { uiTransform: { flexDirection: "column", width: "100%", padding: 10 } }, !this.streamData?.hasChannel && /* @__PURE__ */ ReactEcs6.createElement(UiEntity6, { uiTransform: { flexDirection: "column", margin: { bottom: 14 } } }, /* @__PURE__ */ ReactEcs6.createElement(this.SectionHead, { label: "LIVE STREAM", color: C2.btn }), /* @__PURE__ */ ReactEcs6.createElement(Label6, { value: "No streaming channel linked", fontSize: t.labelSmall, color: C2.textDim, uiTransform: { margin: { bottom: 8 } } }), this.isOwner && /* @__PURE__ */ ReactEcs6.createElement(UiEntity6, { uiTransform: { flexDirection: "column" } }, this.streamData?.trialAvailable && /* @__PURE__ */ ReactEcs6.createElement(UiEntity6, { uiTransform: { flexDirection: "column", margin: { bottom: 10 } } }, /* @__PURE__ */ ReactEcs6.createElement(
3606
+ Button4,
2762
3607
  {
2763
3608
  uiTransform: { width: this.s(200), height: this.s(UI_DIMENSIONS.admin.buttonHeight), margin: { bottom: 6 } },
2764
3609
  uiBackground: { color: this.trialClaiming ? C2.btn : C2.green },
@@ -2767,8 +3612,8 @@ var AdminPanelUIModule = class {
2767
3612
  color: C2.text,
2768
3613
  onMouseDown: () => this.claimTrial()
2769
3614
  }
2770
- ), this.trialClaimError && /* @__PURE__ */ ReactEcs5.createElement(Label5, { value: this.trialClaimError, fontSize: t.status, color: C2.red }), /* @__PURE__ */ ReactEcs5.createElement(Label5, { value: "One-time trial \u2022 4 hours of streaming", fontSize: t.labelSmall, color: C2.textDim, uiTransform: { margin: { top: 4 } } })), !this.streamData?.trialAvailable && /* @__PURE__ */ ReactEcs5.createElement(UiEntity5, { uiTransform: { flexDirection: "column" } }, /* @__PURE__ */ ReactEcs5.createElement(
2771
- Button3,
3615
+ ), this.trialClaimError && /* @__PURE__ */ ReactEcs6.createElement(Label6, { value: this.trialClaimError, fontSize: t.status, color: C2.red }), /* @__PURE__ */ ReactEcs6.createElement(Label6, { value: "One-time trial \u2022 4 hours of streaming", fontSize: t.labelSmall, color: C2.textDim, uiTransform: { margin: { top: 4 } } })), !this.streamData?.trialAvailable && /* @__PURE__ */ ReactEcs6.createElement(UiEntity6, { uiTransform: { flexDirection: "column" } }, /* @__PURE__ */ ReactEcs6.createElement(
3616
+ Button4,
2772
3617
  {
2773
3618
  uiTransform: { width: this.s(170), height: this.s(UI_DIMENSIONS.admin.buttonHeight), margin: { bottom: 6 } },
2774
3619
  uiBackground: { color: this.channelCreating ? C2.btn : C2.cyan },
@@ -2777,47 +3622,47 @@ var AdminPanelUIModule = class {
2777
3622
  color: C2.text,
2778
3623
  onMouseDown: () => this.createChannel()
2779
3624
  }
2780
- ), this.channelCreateError && /* @__PURE__ */ ReactEcs5.createElement(Label5, { value: this.channelCreateError, fontSize: t.status, color: C2.red }), /* @__PURE__ */ ReactEcs5.createElement(Label5, { value: "Relay tier \u2022 $25/mo \u2022 8 hours streaming", fontSize: t.labelSmall, color: C2.textDim, uiTransform: { margin: { top: 4 } } })))), this.streamData?.hasChannel && this.isOwner && /* @__PURE__ */ ReactEcs5.createElement(UiEntity5, { uiTransform: { flexDirection: "column", margin: { bottom: 14 } } }, /* @__PURE__ */ ReactEcs5.createElement(this.SectionHead, { label: this.streamData.isLive ? "LIVE STREAM" : "STREAM SETTINGS", color: this.streamData.isLive ? C2.red : C2.yellow }), /* @__PURE__ */ ReactEcs5.createElement(UiEntity5, { uiTransform: { flexDirection: "row", alignItems: "center", margin: { bottom: 8 } } }, /* @__PURE__ */ ReactEcs5.createElement(
2781
- Label5,
3625
+ ), this.channelCreateError && /* @__PURE__ */ ReactEcs6.createElement(Label6, { value: this.channelCreateError, fontSize: t.status, color: C2.red }), /* @__PURE__ */ ReactEcs6.createElement(Label6, { value: "Relay tier \u2022 $25/mo \u2022 8 hours streaming", fontSize: t.labelSmall, color: C2.textDim, uiTransform: { margin: { top: 4 } } })))), this.streamData?.hasChannel && this.isOwner && /* @__PURE__ */ ReactEcs6.createElement(UiEntity6, { uiTransform: { flexDirection: "column", margin: { bottom: 14 } } }, /* @__PURE__ */ ReactEcs6.createElement(this.SectionHead, { label: this.streamData.isLive ? "LIVE STREAM" : "STREAM SETTINGS", color: this.streamData.isLive ? C2.red : C2.yellow }), /* @__PURE__ */ ReactEcs6.createElement(UiEntity6, { uiTransform: { flexDirection: "row", alignItems: "center", margin: { bottom: 8 } } }, /* @__PURE__ */ ReactEcs6.createElement(
3626
+ Label6,
2782
3627
  {
2783
3628
  value: this.streamData.isLive ? `LIVE \u2022 ${this.streamData.currentViewers || 0} viewers` : "OFFLINE",
2784
3629
  fontSize: t.label,
2785
3630
  color: this.streamData.isLive ? C2.red : C2.textDim
2786
3631
  }
2787
- ), /* @__PURE__ */ ReactEcs5.createElement(Label5, { value: ` \u2022 ${this.streamData.tier?.toUpperCase() || "RELAY"}`, fontSize: t.labelSmall, color: C2.cyan }), /* @__PURE__ */ ReactEcs5.createElement(Label5, { value: ` \u2022 ${this.streamData.sparksBalance || 0} Sparks`, fontSize: t.labelSmall, color: C2.textDim })), /* @__PURE__ */ ReactEcs5.createElement(
2788
- Label5,
3632
+ ), /* @__PURE__ */ ReactEcs6.createElement(Label6, { value: ` \u2022 ${this.streamData.tier?.toUpperCase() || "RELAY"}`, fontSize: t.labelSmall, color: C2.cyan }), /* @__PURE__ */ ReactEcs6.createElement(Label6, { value: ` \u2022 ${this.streamData.sparksBalance || 0} Sparks`, fontSize: t.labelSmall, color: C2.textDim })), /* @__PURE__ */ ReactEcs6.createElement(
3633
+ Label6,
2789
3634
  {
2790
3635
  value: `Channel: ${this.streamData.channelName || this.streamData.channelId}`,
2791
3636
  fontSize: t.labelSmall,
2792
3637
  color: C2.textDim,
2793
3638
  uiTransform: { margin: { bottom: 10 } }
2794
3639
  }
2795
- ), /* @__PURE__ */ ReactEcs5.createElement(UiEntity5, { uiTransform: { flexDirection: "column", margin: { bottom: 6 } } }, /* @__PURE__ */ ReactEcs5.createElement(Label5, { value: "RTMP Server:", fontSize: t.labelSmall, color: C2.textDim }), /* @__PURE__ */ ReactEcs5.createElement(
2796
- Label5,
3640
+ ), /* @__PURE__ */ ReactEcs6.createElement(UiEntity6, { uiTransform: { flexDirection: "column", margin: { bottom: 6 } } }, /* @__PURE__ */ ReactEcs6.createElement(Label6, { value: "RTMP Server:", fontSize: t.labelSmall, color: C2.textDim }), /* @__PURE__ */ ReactEcs6.createElement(
3641
+ Label6,
2797
3642
  {
2798
3643
  value: this.streamData.rtmpUrl || "Loading...",
2799
3644
  fontSize: t.label,
2800
3645
  color: this.streamData.rtmpUrl ? C2.text : C2.textDim,
2801
3646
  uiTransform: { margin: { left: 6 } }
2802
3647
  }
2803
- )), /* @__PURE__ */ ReactEcs5.createElement(UiEntity5, { uiTransform: { flexDirection: "column", margin: { bottom: 6 } } }, /* @__PURE__ */ ReactEcs5.createElement(Label5, { value: "Stream Key:", fontSize: t.labelSmall, color: C2.textDim }), /* @__PURE__ */ ReactEcs5.createElement(
2804
- Label5,
3648
+ )), /* @__PURE__ */ ReactEcs6.createElement(UiEntity6, { uiTransform: { flexDirection: "column", margin: { bottom: 6 } } }, /* @__PURE__ */ ReactEcs6.createElement(Label6, { value: "Stream Key:", fontSize: t.labelSmall, color: C2.textDim }), /* @__PURE__ */ ReactEcs6.createElement(
3649
+ Label6,
2805
3650
  {
2806
3651
  value: this.streamData.streamKey || "Loading...",
2807
3652
  fontSize: t.label,
2808
3653
  color: this.streamData.streamKey ? C2.cyan : C2.textDim,
2809
3654
  uiTransform: { margin: { left: 6 } }
2810
3655
  }
2811
- )), /* @__PURE__ */ ReactEcs5.createElement(UiEntity5, { uiTransform: { flexDirection: "column", margin: { bottom: 10 } } }, /* @__PURE__ */ ReactEcs5.createElement(Label5, { value: "HLS Playback:", fontSize: t.labelSmall, color: C2.textDim }), /* @__PURE__ */ ReactEcs5.createElement(
2812
- Label5,
3656
+ )), /* @__PURE__ */ ReactEcs6.createElement(UiEntity6, { uiTransform: { flexDirection: "column", margin: { bottom: 10 } } }, /* @__PURE__ */ ReactEcs6.createElement(Label6, { value: "HLS Playback:", fontSize: t.labelSmall, color: C2.textDim }), /* @__PURE__ */ ReactEcs6.createElement(
3657
+ Label6,
2813
3658
  {
2814
3659
  value: this.streamData.hlsUrl || "Not available",
2815
3660
  fontSize: t.label,
2816
3661
  color: this.streamData.hlsUrl ? C2.green : C2.textDim,
2817
3662
  uiTransform: { margin: { left: 6 } }
2818
3663
  }
2819
- )), /* @__PURE__ */ ReactEcs5.createElement(UiEntity5, { uiTransform: { flexDirection: "row", flexWrap: "wrap", margin: { bottom: 6 } } }, !this.streamData.isLive && /* @__PURE__ */ ReactEcs5.createElement(
2820
- Button3,
3664
+ )), /* @__PURE__ */ ReactEcs6.createElement(UiEntity6, { uiTransform: { flexDirection: "row", flexWrap: "wrap", margin: { bottom: 6 } } }, !this.streamData.isLive && /* @__PURE__ */ ReactEcs6.createElement(
3665
+ Button4,
2821
3666
  {
2822
3667
  uiTransform: { width: this.s(110), height: this.s(UI_DIMENSIONS.admin.buttonHeightSmall), margin: 4 },
2823
3668
  uiBackground: { color: this.streamControlling ? C2.btn : C2.green },
@@ -2826,8 +3671,8 @@ var AdminPanelUIModule = class {
2826
3671
  color: C2.text,
2827
3672
  onMouseDown: () => this.startStream()
2828
3673
  }
2829
- ), this.streamData.isLive && /* @__PURE__ */ ReactEcs5.createElement(
2830
- Button3,
3674
+ ), this.streamData.isLive && /* @__PURE__ */ ReactEcs6.createElement(
3675
+ Button4,
2831
3676
  {
2832
3677
  uiTransform: { width: this.s(110), height: this.s(UI_DIMENSIONS.admin.buttonHeightSmall), margin: 4 },
2833
3678
  uiBackground: { color: this.streamControlling ? C2.btn : C2.red },
@@ -2836,18 +3681,18 @@ var AdminPanelUIModule = class {
2836
3681
  color: C2.text,
2837
3682
  onMouseDown: () => this.stopStream()
2838
3683
  }
2839
- ), this.streamData.isLive && this.streamData.hlsUrl && /* @__PURE__ */ ReactEcs5.createElement(
2840
- Button3,
3684
+ ), this.streamData.isLive && this.streamData.hlsUrl && /* @__PURE__ */ ReactEcs6.createElement(
3685
+ Button4,
2841
3686
  {
2842
3687
  uiTransform: { width: this.s(100), height: this.s(UI_DIMENSIONS.admin.buttonHeightSmall), margin: 4 },
2843
3688
  uiBackground: { color: C2.cyan },
2844
3689
  value: "Play on Screen",
2845
3690
  fontSize: t.buttonSmall,
2846
3691
  color: C2.text,
2847
- onMouseDown: () => this.config.onVideoPlay?.(this.streamData.hlsUrl)
3692
+ onMouseDown: () => this.playStreamOnScreen(this.streamData.hlsUrl)
2848
3693
  }
2849
- )), /* @__PURE__ */ ReactEcs5.createElement(UiEntity5, { uiTransform: { flexDirection: "row", flexWrap: "wrap", margin: { bottom: 6 } } }, /* @__PURE__ */ ReactEcs5.createElement(
2850
- Button3,
3694
+ )), /* @__PURE__ */ ReactEcs6.createElement(UiEntity6, { uiTransform: { flexDirection: "row", flexWrap: "wrap", margin: { bottom: 6 } } }, /* @__PURE__ */ ReactEcs6.createElement(
3695
+ Button4,
2851
3696
  {
2852
3697
  uiTransform: { width: this.s(80), height: this.s(UI_DIMENSIONS.admin.buttonHeightSmall), margin: 4 },
2853
3698
  uiBackground: { color: C2.btn },
@@ -2856,8 +3701,8 @@ var AdminPanelUIModule = class {
2856
3701
  color: C2.text,
2857
3702
  onMouseDown: () => this.refreshStreamStatus()
2858
3703
  }
2859
- ), /* @__PURE__ */ ReactEcs5.createElement(
2860
- Button3,
3704
+ ), /* @__PURE__ */ ReactEcs6.createElement(
3705
+ Button4,
2861
3706
  {
2862
3707
  uiTransform: { width: this.s(95), height: this.s(UI_DIMENSIONS.admin.buttonHeightSmall), margin: 4 },
2863
3708
  uiBackground: { color: this.keyRotating ? C2.btn : C2.yellow },
@@ -2866,8 +3711,8 @@ var AdminPanelUIModule = class {
2866
3711
  color: C2.text,
2867
3712
  onMouseDown: () => this.rotateStreamKey()
2868
3713
  }
2869
- ), !this.streamData.isLive && /* @__PURE__ */ ReactEcs5.createElement(
2870
- Button3,
3714
+ ), !this.streamData.isLive && !this.channelDeleteLook && /* @__PURE__ */ ReactEcs6.createElement(
3715
+ Button4,
2871
3716
  {
2872
3717
  uiTransform: { width: this.s(70), height: this.s(UI_DIMENSIONS.admin.buttonHeightSmall), margin: 4 },
2873
3718
  uiBackground: { color: this.channelDeleting ? C2.btn : C2.red },
@@ -2876,11 +3721,31 @@ var AdminPanelUIModule = class {
2876
3721
  color: C2.text,
2877
3722
  onMouseDown: () => this.deleteChannel()
2878
3723
  }
2879
- )), this.streamControlStatus === "started" && /* @__PURE__ */ ReactEcs5.createElement(Label5, { value: "Stream started - begin broadcasting in OBS", fontSize: t.status, color: C2.green }), this.streamControlStatus === "stopped" && /* @__PURE__ */ ReactEcs5.createElement(Label5, { value: "Stream stopped", fontSize: t.status, color: C2.textDim }), this.keyRotateStatus === "success" && /* @__PURE__ */ ReactEcs5.createElement(Label5, { value: "Key rotated! Update OBS", fontSize: t.status, color: C2.green }), this.keyRotateStatus === "error" && /* @__PURE__ */ ReactEcs5.createElement(Label5, { value: "Failed to rotate key", fontSize: t.status, color: C2.red }), this.channelDeleteError && /* @__PURE__ */ ReactEcs5.createElement(Label5, { value: this.channelDeleteError, fontSize: t.status, color: C2.red }), this.streamControlStatus === "error" && /* @__PURE__ */ ReactEcs5.createElement(Label5, { value: "Stream control failed", fontSize: t.status, color: C2.red })), /* @__PURE__ */ ReactEcs5.createElement(this.SectionHead, { label: "PLAY NOW", color: C2.orange }), /* @__PURE__ */ ReactEcs5.createElement(UiEntity5, { uiTransform: { flexDirection: "row", alignItems: "center", margin: { bottom: 14 } } }, /* @__PURE__ */ ReactEcs5.createElement(
3724
+ )), !this.streamData.isLive && this.channelDeleteLook && /* @__PURE__ */ ReactEcs6.createElement(UiEntity6, { uiTransform: { flexDirection: "column", margin: { bottom: 6 }, padding: 6 }, uiBackground: { color: C2.section } }, /* @__PURE__ */ ReactEcs6.createElement(Label6, { value: "DELETE THIS CHANNEL?", fontSize: t.labelSmall, color: C2.red, uiTransform: { height: this.s(18) } }), channelDeleteLines(this.channelDeleteLook, this.channelDeleteChanged).map((line, i) => /* @__PURE__ */ ReactEcs6.createElement(Label6, { key: `delete-line-${i}`, value: line, fontSize: t.status, color: line.startsWith("WHAT") ? C2.yellow : C2.text, uiTransform: { height: this.s(18) } })), /* @__PURE__ */ ReactEcs6.createElement(UiEntity6, { uiTransform: { flexDirection: "row", margin: { top: 4 } } }, /* @__PURE__ */ ReactEcs6.createElement(
3725
+ Button4,
3726
+ {
3727
+ uiTransform: { width: this.s(120), height: this.s(UI_DIMENSIONS.admin.buttonHeightSmall), margin: 4 },
3728
+ uiBackground: { color: this.channelDeleting ? C2.btn : C2.red },
3729
+ value: this.channelDeleting ? "..." : "Confirm Delete",
3730
+ fontSize: t.buttonSmall,
3731
+ color: C2.text,
3732
+ onMouseDown: () => this.confirmDeleteChannel()
3733
+ }
3734
+ ), /* @__PURE__ */ ReactEcs6.createElement(
3735
+ Button4,
3736
+ {
3737
+ uiTransform: { width: this.s(70), height: this.s(UI_DIMENSIONS.admin.buttonHeightSmall), margin: 4 },
3738
+ uiBackground: { color: C2.btn },
3739
+ value: "Cancel",
3740
+ fontSize: t.buttonSmall,
3741
+ color: C2.text,
3742
+ onMouseDown: () => this.cancelDeleteChannel()
3743
+ }
3744
+ ))), this.streamControlStatus === "started" && /* @__PURE__ */ ReactEcs6.createElement(Label6, { value: "Stream started - begin broadcasting in OBS", fontSize: t.status, color: C2.green }), this.streamControlStatus === "stopped" && /* @__PURE__ */ ReactEcs6.createElement(Label6, { value: "Stream stopped", fontSize: t.status, color: C2.textDim }), this.keyRotateStatus === "success" && /* @__PURE__ */ ReactEcs6.createElement(Label6, { value: "Key rotated! Update OBS", fontSize: t.status, color: C2.green }), this.keyRotateStatus === "error" && /* @__PURE__ */ ReactEcs6.createElement(Label6, { value: "Failed to rotate key", fontSize: t.status, color: C2.red }), this.channelDeleteError && /* @__PURE__ */ ReactEcs6.createElement(Label6, { value: this.channelDeleteError, fontSize: t.status, color: C2.red }), this.streamControlStatus === "error" && /* @__PURE__ */ ReactEcs6.createElement(Label6, { value: "Stream control failed", fontSize: t.status, color: C2.red })), /* @__PURE__ */ ReactEcs6.createElement(this.SectionHead, { label: "PLAY NOW", color: C2.orange }), /* @__PURE__ */ ReactEcs6.createElement(UiEntity6, { uiTransform: { flexDirection: "row", alignItems: "center", margin: { bottom: 14 } } }, /* @__PURE__ */ ReactEcs6.createElement(
2880
3745
  Input4,
2881
3746
  {
2882
3747
  uiTransform: { width: this.s(230), height: this.s(UI_DIMENSIONS.admin.inputHeight) },
2883
- uiBackground: { color: Color45.create(0.15, 0.15, 0.2, 1) },
3748
+ uiBackground: { color: Color46.create(0.15, 0.15, 0.2, 1) },
2884
3749
  placeholder: "Video URL...",
2885
3750
  placeholderColor: C2.textDim,
2886
3751
  color: C2.text,
@@ -2890,20 +3755,18 @@ var AdminPanelUIModule = class {
2890
3755
  this.customVideoUrl = val;
2891
3756
  }
2892
3757
  }
2893
- ), /* @__PURE__ */ ReactEcs5.createElement(
2894
- Button3,
3758
+ ), /* @__PURE__ */ ReactEcs6.createElement(
3759
+ Button4,
2895
3760
  {
2896
3761
  uiTransform: { width: this.s(75), height: this.s(UI_DIMENSIONS.admin.inputHeight), margin: { left: 8 } },
2897
3762
  uiBackground: { color: C2.green },
2898
3763
  value: "Play",
2899
3764
  fontSize: t.button,
2900
3765
  color: C2.text,
2901
- onMouseDown: () => {
2902
- if (this.customVideoUrl) this.config.onVideoPlay?.(this.customVideoUrl);
2903
- }
3766
+ onMouseDown: () => this.playNow()
2904
3767
  }
2905
- ), /* @__PURE__ */ ReactEcs5.createElement(
2906
- Button3,
3768
+ ), /* @__PURE__ */ ReactEcs6.createElement(
3769
+ Button4,
2907
3770
  {
2908
3771
  uiTransform: { width: this.s(65), height: this.s(UI_DIMENSIONS.admin.inputHeight), margin: { left: 6 } },
2909
3772
  uiBackground: { color: C2.btn },
@@ -2914,55 +3777,82 @@ var AdminPanelUIModule = class {
2914
3777
  this.customVideoUrl = "";
2915
3778
  }
2916
3779
  }
2917
- )), /* @__PURE__ */ ReactEcs5.createElement(this.SectionHead, { label: "PLAYBACK", color: C2.green }), /* @__PURE__ */ ReactEcs5.createElement(UiEntity5, { uiTransform: { flexDirection: "row", flexWrap: "wrap", margin: { bottom: 14 } } }, /* @__PURE__ */ ReactEcs5.createElement(
2918
- Button3,
3780
+ )), this.videoStatus && /* @__PURE__ */ ReactEcs6.createElement(
3781
+ Label6,
3782
+ {
3783
+ value: this.videoStatus,
3784
+ fontSize: t.status,
3785
+ color: this.videoStatus.startsWith("Not sent") ? C2.red : C2.green,
3786
+ uiTransform: { height: this.s(18), margin: { bottom: 6 } }
3787
+ }
3788
+ ), /* @__PURE__ */ ReactEcs6.createElement(this.SectionHead, { label: "PLAYBACK", color: C2.green }), /* @__PURE__ */ ReactEcs6.createElement(UiEntity6, { uiTransform: { flexDirection: "row", flexWrap: "wrap", margin: { bottom: 14 } } }, /* @__PURE__ */ ReactEcs6.createElement(
3789
+ Button4,
2919
3790
  {
2920
3791
  uiTransform: { width: this.s(75), height: this.s(UI_DIMENSIONS.admin.buttonHeightSmall), margin: 4 },
2921
3792
  uiBackground: { color: C2.green },
2922
3793
  value: "Play",
2923
3794
  fontSize: t.button,
2924
3795
  color: C2.text,
2925
- onMouseDown: () => this.config.onCommand?.("videoPlay", { playing: true })
3796
+ onMouseDown: () => this.playbackPlay()
2926
3797
  }
2927
- ), /* @__PURE__ */ ReactEcs5.createElement(
2928
- Button3,
3798
+ ), /* @__PURE__ */ ReactEcs6.createElement(
3799
+ Button4,
2929
3800
  {
2930
3801
  uiTransform: { width: this.s(75), height: this.s(UI_DIMENSIONS.admin.buttonHeightSmall), margin: 4 },
2931
3802
  uiBackground: { color: C2.red },
2932
3803
  value: "Stop",
2933
3804
  fontSize: t.button,
2934
3805
  color: C2.text,
2935
- onMouseDown: () => this.config.onVideoStop?.()
3806
+ onMouseDown: () => this.playbackStop()
2936
3807
  }
2937
- ), /* @__PURE__ */ ReactEcs5.createElement(
2938
- Button3,
3808
+ ), /* @__PURE__ */ ReactEcs6.createElement(
3809
+ Button4,
2939
3810
  {
2940
3811
  uiTransform: { width: this.s(100), height: this.s(UI_DIMENSIONS.admin.buttonHeightSmall), margin: 4 },
2941
3812
  uiBackground: { color: C2.btn },
2942
3813
  value: "Reset Default",
2943
3814
  fontSize: t.buttonSmall,
2944
3815
  color: C2.text,
2945
- onMouseDown: () => this.config.onCommand?.("videoClear", {})
3816
+ onMouseDown: () => this.resetDefault()
2946
3817
  }
2947
- )), /* @__PURE__ */ ReactEcs5.createElement(this.SectionHead, { label: "VIDEO SLOTS", color: C2.cyan }), /* @__PURE__ */ ReactEcs5.createElement(UiEntity5, { uiTransform: { flexDirection: "row", flexWrap: "wrap", margin: { bottom: 10 } } }, /* @__PURE__ */ ReactEcs5.createElement(Button3, { uiTransform: { width: this.s(70), height: this.s(UI_DIMENSIONS.admin.buttonHeightSmall), margin: 4 }, uiBackground: { color: C2.cyan }, value: "Play 1", fontSize: t.button, color: C2.text, onMouseDown: () => this.playSlot("slot1") }), /* @__PURE__ */ ReactEcs5.createElement(Button3, { uiTransform: { width: this.s(70), height: this.s(UI_DIMENSIONS.admin.buttonHeightSmall), margin: 4 }, uiBackground: { color: C2.cyan }, value: "Play 2", fontSize: t.button, color: C2.text, onMouseDown: () => this.playSlot("slot2") }), /* @__PURE__ */ ReactEcs5.createElement(Button3, { uiTransform: { width: this.s(70), height: this.s(UI_DIMENSIONS.admin.buttonHeightSmall), margin: 4 }, uiBackground: { color: C2.cyan }, value: "Play 3", fontSize: t.button, color: C2.text, onMouseDown: () => this.playSlot("slot3") }), /* @__PURE__ */ ReactEcs5.createElement(Button3, { uiTransform: { width: this.s(70), height: this.s(UI_DIMENSIONS.admin.buttonHeightSmall), margin: 4 }, uiBackground: { color: C2.cyan }, value: "Play 4", fontSize: t.button, color: C2.text, onMouseDown: () => this.playSlot("slot4") }), /* @__PURE__ */ ReactEcs5.createElement(Button3, { uiTransform: { width: this.s(70), height: this.s(UI_DIMENSIONS.admin.buttonHeightSmall), margin: 4 }, uiBackground: { color: C2.cyan }, value: "Play 5", fontSize: t.button, color: C2.text, onMouseDown: () => this.playSlot("slot5") })), /* @__PURE__ */ ReactEcs5.createElement(
2948
- Button3,
3818
+ )), /* @__PURE__ */ ReactEcs6.createElement(this.SectionHead, { label: "VIDEO SLOTS", color: C2.cyan }), /* @__PURE__ */ ReactEcs6.createElement(UiEntity6, { uiTransform: { flexDirection: "row", flexWrap: "wrap", margin: { bottom: 10 } } }, ["slot1", "slot2", "slot3", "slot4", "slot5"].map((slot, i) => /* @__PURE__ */ ReactEcs6.createElement(
3819
+ Button4,
3820
+ {
3821
+ key: `play-${slot}`,
3822
+ uiTransform: { width: this.s(70), height: this.s(UI_DIMENSIONS.admin.buttonHeightSmall), margin: 4 },
3823
+ uiBackground: { color: C2.cyan },
3824
+ value: `Play ${i + 1}`,
3825
+ fontSize: t.button,
3826
+ color: C2.text,
3827
+ onMouseDown: () => this.pressSlot(slot)
3828
+ }
3829
+ ))), /* @__PURE__ */ ReactEcs6.createElement(
3830
+ Button4,
2949
3831
  {
2950
3832
  uiTransform: { height: this.s(24) },
2951
- uiBackground: { color: Color45.create(0, 0, 0, 0) },
3833
+ uiBackground: { color: Color46.create(0, 0, 0, 0) },
2952
3834
  value: "Edit slots at thestatic.tv",
2953
3835
  fontSize: t.labelSmall,
2954
3836
  color: C2.cyan,
2955
- onMouseDown: () => openExternalUrl3({ url: this.config.footerLink || `https://thestatic.tv/scene/${this.config.sceneId}` })
3837
+ onMouseDown: () => openExternalUrl5({ url: this.config.footerLink || `https://thestatic.tv/scene/${this.config.sceneId}` })
2956
3838
  }
2957
3839
  ));
2958
3840
  };
2959
3841
  this.ModTab = () => {
2960
3842
  const t = this.theme;
2961
- return /* @__PURE__ */ ReactEcs5.createElement(UiEntity5, { uiTransform: { flexDirection: "column", width: "100%", padding: 10 } }, this.modStatus === "loading" && /* @__PURE__ */ ReactEcs5.createElement(Label5, { value: "Loading...", fontSize: t.status, color: C2.yellow }), this.modStatus === "saved" && /* @__PURE__ */ ReactEcs5.createElement(Label5, { value: "Saved!", fontSize: t.status, color: C2.green }), this.modStatus === "error" && /* @__PURE__ */ ReactEcs5.createElement(Label5, { value: "Error - check input", fontSize: t.status, color: C2.red }), /* @__PURE__ */ ReactEcs5.createElement(this.SectionHead, { label: "BROADCAST", color: C2.orange }), /* @__PURE__ */ ReactEcs5.createElement(UiEntity5, { uiTransform: { flexDirection: "row", alignItems: "center", margin: { bottom: 14 } } }, /* @__PURE__ */ ReactEcs5.createElement(
3843
+ return /* @__PURE__ */ ReactEcs6.createElement(UiEntity6, { uiTransform: { flexDirection: "column", width: "100%", padding: 10 } }, this.modStatus === "loading" && /* @__PURE__ */ ReactEcs6.createElement(Label6, { value: "Loading...", fontSize: t.status, color: C2.yellow }), this.modStatus === "saved" && /* @__PURE__ */ ReactEcs6.createElement(Label6, { value: "Saved!", fontSize: t.status, color: C2.green }), this.modStatus === "error" && /* @__PURE__ */ ReactEcs6.createElement(Label6, { value: "Error - check input", fontSize: t.status, color: C2.red }), this.kickStatus && /* @__PURE__ */ ReactEcs6.createElement(
3844
+ Label6,
3845
+ {
3846
+ value: this.kickStatus,
3847
+ fontSize: t.status,
3848
+ color: this.kickStatus.startsWith("Kick not sent") ? C2.red : C2.green,
3849
+ uiTransform: { height: this.s(18) }
3850
+ }
3851
+ ), /* @__PURE__ */ ReactEcs6.createElement(this.SectionHead, { label: "BROADCAST", color: C2.orange }), /* @__PURE__ */ ReactEcs6.createElement(UiEntity6, { uiTransform: { flexDirection: "row", alignItems: "center", margin: { bottom: 14 } } }, /* @__PURE__ */ ReactEcs6.createElement(
2962
3852
  Input4,
2963
3853
  {
2964
3854
  uiTransform: { width: this.s(230), height: this.s(UI_DIMENSIONS.admin.inputHeight) },
2965
- uiBackground: { color: Color45.create(0.15, 0.15, 0.2, 1) },
3855
+ uiBackground: { color: Color46.create(0.15, 0.15, 0.2, 1) },
2966
3856
  placeholder: "Message to all players...",
2967
3857
  placeholderColor: C2.textDim,
2968
3858
  color: C2.text,
@@ -2972,8 +3862,8 @@ var AdminPanelUIModule = class {
2972
3862
  this.broadcastText = val;
2973
3863
  }
2974
3864
  }
2975
- ), /* @__PURE__ */ ReactEcs5.createElement(
2976
- Button3,
3865
+ ), /* @__PURE__ */ ReactEcs6.createElement(
3866
+ Button4,
2977
3867
  {
2978
3868
  uiTransform: { width: this.s(65), height: this.s(UI_DIMENSIONS.admin.inputHeight), margin: { left: 8 } },
2979
3869
  uiBackground: { color: C2.orange },
@@ -2982,27 +3872,51 @@ var AdminPanelUIModule = class {
2982
3872
  color: C2.text,
2983
3873
  onMouseDown: () => this.sendBroadcast()
2984
3874
  }
2985
- )), /* @__PURE__ */ ReactEcs5.createElement(this.SectionHead, { label: "CHAOS MODE", color: C2.red }), /* @__PURE__ */ ReactEcs5.createElement(UiEntity5, { uiTransform: { flexDirection: "row", flexWrap: "wrap", margin: { bottom: 14 } } }, /* @__PURE__ */ ReactEcs5.createElement(
2986
- Button3,
3875
+ )), this.broadcastStatus && /* @__PURE__ */ ReactEcs6.createElement(
3876
+ Label6,
3877
+ {
3878
+ value: this.broadcastStatus,
3879
+ fontSize: t.status,
3880
+ color: this.broadcastStatus.startsWith("Not sent") ? C2.red : C2.green,
3881
+ uiTransform: { height: this.s(18), margin: { bottom: 6 } }
3882
+ }
3883
+ ), /* @__PURE__ */ ReactEcs6.createElement(this.SectionHead, { label: "CHAOS MODE", color: C2.red }), /* @__PURE__ */ ReactEcs6.createElement(UiEntity6, { uiTransform: { flexDirection: "row", flexWrap: "wrap", margin: { bottom: 14 } } }, /* @__PURE__ */ ReactEcs6.createElement(
3884
+ Button4,
2987
3885
  {
2988
3886
  uiTransform: { width: this.s(130), height: this.s(UI_DIMENSIONS.admin.buttonHeight), margin: 4 },
2989
3887
  uiBackground: { color: C2.red },
2990
3888
  value: "KICK ALL",
2991
3889
  fontSize: t.button,
2992
3890
  color: C2.text,
2993
- onMouseDown: () => {
2994
- this.log("KICK ALL clicked");
2995
- this.config.onCommand?.("kickAll", {});
2996
- }
3891
+ onMouseDown: () => this.kickAll()
3892
+ }
3893
+ )), this.venue && /* @__PURE__ */ ReactEcs6.createElement(UiEntity6, { uiTransform: { flexDirection: "column", margin: { bottom: 14 } } }, /* @__PURE__ */ ReactEcs6.createElement(this.SectionHead, { label: "PRIVATE MODE", color: C2.yellow }), /* @__PURE__ */ ReactEcs6.createElement(Label6, { value: "While ON, only citizens get in", fontSize: t.labelSmall, color: C2.textDim, uiTransform: { height: this.s(18), margin: { bottom: 4 } } }), /* @__PURE__ */ ReactEcs6.createElement(UiEntity6, { uiTransform: { flexDirection: "row", flexWrap: "wrap" } }, [true, false].map((on) => /* @__PURE__ */ ReactEcs6.createElement(
3894
+ Button4,
3895
+ {
3896
+ key: `private-${on ? "on" : "off"}`,
3897
+ uiTransform: { width: this.s(70), height: this.s(UI_DIMENSIONS.admin.buttonHeightSmall), margin: 4 },
3898
+ uiBackground: { color: this.privateModeOn === on ? C2.yellow : C2.btn },
3899
+ value: on ? "ON" : "OFF",
3900
+ fontSize: t.buttonSmall,
3901
+ color: this.privateModeOn === on ? Color46.Black() : C2.text,
3902
+ onMouseDown: () => this.setPrivateMode(on)
2997
3903
  }
2998
- )), /* @__PURE__ */ ReactEcs5.createElement(this.SectionHead, { label: "SCENE ADMINS", color: C2.purple }), /* @__PURE__ */ ReactEcs5.createElement(UiEntity5, { uiTransform: { flexDirection: "column", margin: { bottom: 6 } } }, this.sceneAdmins.length === 0 && this.modStatus !== "loading" && /* @__PURE__ */ ReactEcs5.createElement(Label5, { value: "No scene admins", fontSize: t.labelSmall, color: C2.textDim }), this.sceneAdmins.map((wallet, i) => /* @__PURE__ */ ReactEcs5.createElement(
2999
- UiEntity5,
3904
+ ))), this.privateStatus && /* @__PURE__ */ ReactEcs6.createElement(
3905
+ Label6,
3906
+ {
3907
+ value: this.privateStatus,
3908
+ fontSize: t.status,
3909
+ color: this.privateStatus.startsWith("Not sent") ? C2.red : C2.green,
3910
+ uiTransform: { height: this.s(18) }
3911
+ }
3912
+ )), /* @__PURE__ */ ReactEcs6.createElement(this.SectionHead, { label: "SCENE ADMINS", color: C2.purple }), /* @__PURE__ */ ReactEcs6.createElement(UiEntity6, { uiTransform: { flexDirection: "column", margin: { bottom: 6 } } }, this.sceneAdmins.length === 0 && this.modStatus !== "loading" && /* @__PURE__ */ ReactEcs6.createElement(Label6, { value: "No scene admins", fontSize: t.labelSmall, color: C2.textDim }), this.sceneAdmins.map((wallet, i) => /* @__PURE__ */ ReactEcs6.createElement(
3913
+ UiEntity6,
3000
3914
  {
3001
3915
  key: `admin-${i}`,
3002
3916
  uiTransform: { flexDirection: "row", alignItems: "center", margin: { bottom: 5 }, width: "100%" }
3003
3917
  },
3004
- /* @__PURE__ */ ReactEcs5.createElement(
3005
- Label5,
3918
+ /* @__PURE__ */ ReactEcs6.createElement(
3919
+ Label6,
3006
3920
  {
3007
3921
  value: `${wallet.slice(0, 6)}...${wallet.slice(-4)}`,
3008
3922
  fontSize: t.label,
@@ -3010,8 +3924,8 @@ var AdminPanelUIModule = class {
3010
3924
  uiTransform: { width: this.s(130) }
3011
3925
  }
3012
3926
  ),
3013
- /* @__PURE__ */ ReactEcs5.createElement(
3014
- Button3,
3927
+ /* @__PURE__ */ ReactEcs6.createElement(
3928
+ Button4,
3015
3929
  {
3016
3930
  uiTransform: { width: this.s(70), height: this.s(28), margin: { left: 8 } },
3017
3931
  uiBackground: { color: C2.btn },
@@ -3021,11 +3935,11 @@ var AdminPanelUIModule = class {
3021
3935
  onMouseDown: () => this.removeSceneAdmin(wallet)
3022
3936
  }
3023
3937
  )
3024
- ))), /* @__PURE__ */ ReactEcs5.createElement(UiEntity5, { uiTransform: { flexDirection: "row", alignItems: "center", margin: { bottom: 14 } } }, /* @__PURE__ */ ReactEcs5.createElement(
3938
+ ))), /* @__PURE__ */ ReactEcs6.createElement(UiEntity6, { uiTransform: { flexDirection: "row", alignItems: "center", margin: { bottom: 14 } } }, /* @__PURE__ */ ReactEcs6.createElement(
3025
3939
  Input4,
3026
3940
  {
3027
3941
  uiTransform: { width: this.s(230), height: this.s(UI_DIMENSIONS.admin.inputHeight) },
3028
- uiBackground: { color: Color45.create(0.15, 0.15, 0.2, 1) },
3942
+ uiBackground: { color: Color46.create(0.15, 0.15, 0.2, 1) },
3029
3943
  placeholder: "0x... add admin",
3030
3944
  placeholderColor: C2.textDim,
3031
3945
  color: C2.text,
@@ -3035,8 +3949,8 @@ var AdminPanelUIModule = class {
3035
3949
  this.newAdminWallet = val;
3036
3950
  }
3037
3951
  }
3038
- ), /* @__PURE__ */ ReactEcs5.createElement(
3039
- Button3,
3952
+ ), /* @__PURE__ */ ReactEcs6.createElement(
3953
+ Button4,
3040
3954
  {
3041
3955
  uiTransform: { width: this.s(60), height: this.s(UI_DIMENSIONS.admin.inputHeight), margin: { left: 8 } },
3042
3956
  uiBackground: { color: C2.purple },
@@ -3047,14 +3961,14 @@ var AdminPanelUIModule = class {
3047
3961
  if (this.newAdminWallet) this.addSceneAdmin(this.newAdminWallet);
3048
3962
  }
3049
3963
  }
3050
- )), /* @__PURE__ */ ReactEcs5.createElement(this.SectionHead, { label: "BANNED WALLETS", color: C2.red }), /* @__PURE__ */ ReactEcs5.createElement(UiEntity5, { uiTransform: { flexDirection: "column", margin: { bottom: 6 } } }, this.bannedWallets.length === 0 && this.modStatus !== "loading" && /* @__PURE__ */ ReactEcs5.createElement(Label5, { value: "No banned wallets", fontSize: t.labelSmall, color: C2.textDim }), this.bannedWallets.map((wallet, i) => /* @__PURE__ */ ReactEcs5.createElement(
3051
- UiEntity5,
3964
+ )), /* @__PURE__ */ ReactEcs6.createElement(this.SectionHead, { label: "BANNED WALLETS", color: C2.red }), /* @__PURE__ */ ReactEcs6.createElement(UiEntity6, { uiTransform: { flexDirection: "column", margin: { bottom: 6 } } }, this.bannedWallets.length === 0 && this.modStatus !== "loading" && /* @__PURE__ */ ReactEcs6.createElement(Label6, { value: "No banned wallets", fontSize: t.labelSmall, color: C2.textDim }), this.bannedWallets.map((wallet, i) => /* @__PURE__ */ ReactEcs6.createElement(
3965
+ UiEntity6,
3052
3966
  {
3053
3967
  key: `ban-${i}`,
3054
3968
  uiTransform: { flexDirection: "row", alignItems: "center", margin: { bottom: 5 }, width: "100%" }
3055
3969
  },
3056
- /* @__PURE__ */ ReactEcs5.createElement(
3057
- Label5,
3970
+ /* @__PURE__ */ ReactEcs6.createElement(
3971
+ Label6,
3058
3972
  {
3059
3973
  value: `${wallet.slice(0, 6)}...${wallet.slice(-4)}`,
3060
3974
  fontSize: t.label,
@@ -3062,8 +3976,8 @@ var AdminPanelUIModule = class {
3062
3976
  uiTransform: { width: this.s(130) }
3063
3977
  }
3064
3978
  ),
3065
- /* @__PURE__ */ ReactEcs5.createElement(
3066
- Button3,
3979
+ /* @__PURE__ */ ReactEcs6.createElement(
3980
+ Button4,
3067
3981
  {
3068
3982
  uiTransform: { width: this.s(70), height: this.s(28), margin: { left: 8 } },
3069
3983
  uiBackground: { color: C2.green },
@@ -3073,11 +3987,11 @@ var AdminPanelUIModule = class {
3073
3987
  onMouseDown: () => this.unbanWallet(wallet)
3074
3988
  }
3075
3989
  )
3076
- ))), /* @__PURE__ */ ReactEcs5.createElement(UiEntity5, { uiTransform: { flexDirection: "row", alignItems: "center", margin: { bottom: 10 } } }, /* @__PURE__ */ ReactEcs5.createElement(
3990
+ ))), /* @__PURE__ */ ReactEcs6.createElement(UiEntity6, { uiTransform: { flexDirection: "row", alignItems: "center", margin: { bottom: 10 } } }, /* @__PURE__ */ ReactEcs6.createElement(
3077
3991
  Input4,
3078
3992
  {
3079
3993
  uiTransform: { width: this.s(230), height: this.s(UI_DIMENSIONS.admin.inputHeight) },
3080
- uiBackground: { color: Color45.create(0.15, 0.15, 0.2, 1) },
3994
+ uiBackground: { color: Color46.create(0.15, 0.15, 0.2, 1) },
3081
3995
  placeholder: "0x... ban wallet",
3082
3996
  placeholderColor: C2.textDim,
3083
3997
  color: C2.text,
@@ -3087,8 +4001,8 @@ var AdminPanelUIModule = class {
3087
4001
  this.newBanWallet = val;
3088
4002
  }
3089
4003
  }
3090
- ), /* @__PURE__ */ ReactEcs5.createElement(
3091
- Button3,
4004
+ ), /* @__PURE__ */ ReactEcs6.createElement(
4005
+ Button4,
3092
4006
  {
3093
4007
  uiTransform: { width: this.s(60), height: this.s(UI_DIMENSIONS.admin.inputHeight), margin: { left: 8 } },
3094
4008
  uiBackground: { color: C2.red },
@@ -3099,15 +4013,15 @@ var AdminPanelUIModule = class {
3099
4013
  if (this.newBanWallet) this.banWallet(this.newBanWallet);
3100
4014
  }
3101
4015
  }
3102
- )), /* @__PURE__ */ ReactEcs5.createElement(
3103
- Button3,
4016
+ )), /* @__PURE__ */ ReactEcs6.createElement(
4017
+ Button4,
3104
4018
  {
3105
4019
  uiTransform: { height: this.s(24) },
3106
- uiBackground: { color: Color45.create(0, 0, 0, 0) },
4020
+ uiBackground: { color: Color46.create(0, 0, 0, 0) },
3107
4021
  value: "Manage at thestatic.tv",
3108
4022
  fontSize: t.labelSmall,
3109
4023
  color: C2.cyan,
3110
- onMouseDown: () => openExternalUrl3({ url: this.config.footerLink || `https://thestatic.tv/scene/${this.config.sceneId}` })
4024
+ onMouseDown: () => openExternalUrl5({ url: this.config.footerLink || `https://thestatic.tv/scene/${this.config.sceneId}` })
3111
4025
  }
3112
4026
  ));
3113
4027
  };
@@ -3116,11 +4030,24 @@ var AdminPanelUIModule = class {
3116
4030
  * Always renders notification (scaled), admin panel only for admins
3117
4031
  */
3118
4032
  this.getComponent = () => {
4033
+ if (this.moderation.blocked) {
4034
+ return BlockedNotice({
4035
+ standing: this.moderation.standing,
4036
+ kickLeftMs: this.moderation.kickLeftMs,
4037
+ scale: this.client.uiScale,
4038
+ // thestatic.tv's own origin, for a private event's BECOME A CITIZEN (2026-11-19): the API base less its path, as
4039
+ // the chat's REGISTER IDENTITY derives its /login
4040
+ siteUrl: this.baseUrl.replace("/api/v1/dcl", "")
4041
+ });
4042
+ }
3119
4043
  if (!this.isAdmin) {
3120
4044
  return this.renderScaledNotification();
3121
4045
  }
3122
4046
  const t = this.theme;
3123
4047
  const tabs = [];
4048
+ if (this.venue && this.controls.length > 0) {
4049
+ tabs.push({ label: "CONTROLS", id: "controls" });
4050
+ }
3124
4051
  if (this.config.sceneTabs && this.config.sceneTabs.length > 0) {
3125
4052
  this.config.sceneTabs.forEach((tab) => tabs.push({ label: tab.label, id: tab.id }));
3126
4053
  }
@@ -3133,8 +4060,8 @@ var AdminPanelUIModule = class {
3133
4060
  if (!tabs.find((tab) => tab.id === this.activeTab) && tabs.length > 0) {
3134
4061
  this.activeTab = tabs[0].id;
3135
4062
  }
3136
- return /* @__PURE__ */ ReactEcs5.createElement(
3137
- UiEntity5,
4063
+ return /* @__PURE__ */ ReactEcs6.createElement(
4064
+ UiEntity6,
3138
4065
  {
3139
4066
  uiTransform: {
3140
4067
  width: "100%",
@@ -3143,16 +4070,16 @@ var AdminPanelUIModule = class {
3143
4070
  }
3144
4071
  },
3145
4072
  this.renderScaledNotification(),
3146
- /* @__PURE__ */ ReactEcs5.createElement(
3147
- UiEntity5,
4073
+ /* @__PURE__ */ ReactEcs6.createElement(
4074
+ UiEntity6,
3148
4075
  {
3149
4076
  uiTransform: {
3150
4077
  position: { right: 20 + this.s(100) + 10 + this.s(100) + 10, bottom: 10 },
3151
4078
  positionType: "absolute"
3152
4079
  }
3153
4080
  },
3154
- /* @__PURE__ */ ReactEcs5.createElement(
3155
- Button3,
4081
+ /* @__PURE__ */ ReactEcs6.createElement(
4082
+ Button4,
3156
4083
  {
3157
4084
  uiTransform: { width: this.s(100), height: this.s(45) },
3158
4085
  uiBackground: { color: this.panelOpen ? C2.btn : C2.header },
@@ -3163,8 +4090,8 @@ var AdminPanelUIModule = class {
3163
4090
  }
3164
4091
  )
3165
4092
  ),
3166
- this.panelOpen && /* @__PURE__ */ ReactEcs5.createElement(
3167
- UiEntity5,
4093
+ this.panelOpen && /* @__PURE__ */ ReactEcs6.createElement(
4094
+ UiEntity6,
3168
4095
  {
3169
4096
  key: `admin-panel-${this.client.uiScale}`,
3170
4097
  uiTransform: {
@@ -3177,8 +4104,8 @@ var AdminPanelUIModule = class {
3177
4104
  },
3178
4105
  uiBackground: { color: C2.bg }
3179
4106
  },
3180
- /* @__PURE__ */ ReactEcs5.createElement(
3181
- UiEntity5,
4107
+ /* @__PURE__ */ ReactEcs6.createElement(
4108
+ UiEntity6,
3182
4109
  {
3183
4110
  uiTransform: {
3184
4111
  width: "100%",
@@ -3190,12 +4117,12 @@ var AdminPanelUIModule = class {
3190
4117
  },
3191
4118
  uiBackground: { color: C2.header }
3192
4119
  },
3193
- /* @__PURE__ */ ReactEcs5.createElement(Label5, { value: this.config.title || "ADMIN PANEL", fontSize: t.header, color: C2.text }),
3194
- /* @__PURE__ */ ReactEcs5.createElement(
3195
- Button3,
4120
+ /* @__PURE__ */ ReactEcs6.createElement(Label6, { value: this.config.title || "ADMIN PANEL", fontSize: t.header, color: C2.text }),
4121
+ /* @__PURE__ */ ReactEcs6.createElement(
4122
+ Button4,
3196
4123
  {
3197
4124
  uiTransform: { width: this.s(28), height: this.s(28) },
3198
- uiBackground: { color: Color45.create(0, 0, 0, 0.3) },
4125
+ uiBackground: { color: Color46.create(0, 0, 0, 0.3) },
3199
4126
  value: "X",
3200
4127
  fontSize: t.header,
3201
4128
  color: THEME.colors.red,
@@ -3203,9 +4130,9 @@ var AdminPanelUIModule = class {
3203
4130
  }
3204
4131
  )
3205
4132
  ),
3206
- /* @__PURE__ */ ReactEcs5.createElement(UiEntity5, { uiTransform: { width: "100%", height: this.s(UI_DIMENSIONS.admin.tabHeight), flexDirection: "row" } }, tabs.map((tab) => /* @__PURE__ */ ReactEcs5.createElement(this.TabBtn, { label: tab.label, tab: tab.id }))),
3207
- /* @__PURE__ */ ReactEcs5.createElement(
3208
- UiEntity5,
4133
+ /* @__PURE__ */ ReactEcs6.createElement(UiEntity6, { uiTransform: { width: "100%", height: this.s(UI_DIMENSIONS.admin.tabHeight), flexDirection: "row" } }, tabs.map((tab) => /* @__PURE__ */ ReactEcs6.createElement(this.TabBtn, { label: tab.label, tab: tab.id }))),
4134
+ /* @__PURE__ */ ReactEcs6.createElement(
4135
+ UiEntity6,
3209
4136
  {
3210
4137
  uiTransform: {
3211
4138
  width: "100%",
@@ -3214,12 +4141,13 @@ var AdminPanelUIModule = class {
3214
4141
  flexDirection: "column"
3215
4142
  }
3216
4143
  },
3217
- this.activeTab === "video" && /* @__PURE__ */ ReactEcs5.createElement(this.VideoTab, null),
3218
- this.activeTab === "mod" && this.isOwner && /* @__PURE__ */ ReactEcs5.createElement(this.ModTab, null),
4144
+ this.activeTab === "controls" && this.venue && this.controls.length > 0 && /* @__PURE__ */ ReactEcs6.createElement(this.ControlsTab, null),
4145
+ this.activeTab === "video" && /* @__PURE__ */ ReactEcs6.createElement(this.VideoTab, null),
4146
+ this.activeTab === "mod" && this.isOwner && /* @__PURE__ */ ReactEcs6.createElement(this.ModTab, null),
3219
4147
  this.config.sceneTabs?.map((tab) => this.activeTab === tab.id && tab.render())
3220
4148
  ),
3221
- /* @__PURE__ */ ReactEcs5.createElement(
3222
- UiEntity5,
4149
+ /* @__PURE__ */ ReactEcs6.createElement(
4150
+ UiEntity6,
3223
4151
  {
3224
4152
  uiTransform: {
3225
4153
  width: "100%",
@@ -3229,15 +4157,15 @@ var AdminPanelUIModule = class {
3229
4157
  },
3230
4158
  uiBackground: { color: C2.section }
3231
4159
  },
3232
- /* @__PURE__ */ ReactEcs5.createElement(
3233
- Button3,
4160
+ /* @__PURE__ */ ReactEcs6.createElement(
4161
+ Button4,
3234
4162
  {
3235
4163
  uiTransform: { height: this.s(24) },
3236
- uiBackground: { color: Color45.create(0, 0, 0, 0) },
4164
+ uiBackground: { color: Color46.create(0, 0, 0, 0) },
3237
4165
  value: `thestatic.tv/scene/${this.config.sceneId}`,
3238
4166
  fontSize: t.labelSmall,
3239
4167
  color: C2.cyan,
3240
- onMouseDown: () => openExternalUrl3({ url: this.config.footerLink || `https://thestatic.tv/scene/${this.config.sceneId}` })
4168
+ onMouseDown: () => openExternalUrl5({ url: this.config.footerLink || `https://thestatic.tv/scene/${this.config.sceneId}` })
3241
4169
  }
3242
4170
  )
3243
4171
  )
@@ -3258,14 +4186,41 @@ var AdminPanelUIModule = class {
3258
4186
  // Ensure sceneId is set
3259
4187
  };
3260
4188
  this.baseUrl = client.getBaseUrl();
4189
+ this.moderation = new ModerationModule({
4190
+ reread: () => this.checkAdminStatus(),
4191
+ myWallet: () => this.myWallet(),
4192
+ onChange: (blocked, standing) => this.onStandingChange(blocked, standing),
4193
+ log: (msg, ...args) => this.log(msg, ...args)
4194
+ });
4195
+ this.adminWait = new PlayerWait({
4196
+ getPlayer: () => getPlayer2(),
4197
+ setInterval: dclSetInterval,
4198
+ clearInterval: dclClearInterval,
4199
+ check: (player) => this.checkAdminFor(player),
4200
+ log: (msg) => this.log(msg)
4201
+ });
3261
4202
  if (config.headerColor) {
3262
- C2.header = Color45.create(
4203
+ C2.header = Color46.create(
3263
4204
  config.headerColor.r,
3264
4205
  config.headerColor.g,
3265
4206
  config.headerColor.b,
3266
4207
  config.headerColor.a
3267
4208
  );
3268
4209
  }
4210
+ if (config.controls && config.controls.length > 0) this.registerControls(config.controls);
4211
+ }
4212
+ kickLine(sent) {
4213
+ return { sent, notSent: "Kick not sent", show: (line) => {
4214
+ this.kickStatus = line;
4215
+ } };
4216
+ }
4217
+ /**
4218
+ * The Venue tier (2026-11-19): scene controls and private mode are Venue's, so the CONTROLS tab, the declaration's
4219
+ * upload, a press, the saved state's read, a queued control's run and the private-mode switch all need it. The
4220
+ * client knows it from the session start, before this panel exists.
4221
+ */
4222
+ get venue() {
4223
+ return this.client.hasVenueFeatures === true;
3269
4224
  }
3270
4225
  log(msg, ...args) {
3271
4226
  if (this.config.debug) {
@@ -3284,26 +4239,36 @@ var AdminPanelUIModule = class {
3284
4239
  * Initialize the admin panel - checks admin status and fetches video state
3285
4240
  */
3286
4241
  async init() {
4242
+ this.moderation.start().catch(() => {
4243
+ });
3287
4244
  await this.checkAdminStatus();
3288
4245
  await this.fetchVideoState();
3289
4246
  this.autoPlayDefault();
4247
+ this.loadReadsDone = true;
4248
+ await this.readSavedState();
3290
4249
  this.startCommandPolling();
3291
4250
  this.log("Initialized");
3292
4251
  }
3293
4252
  /**
3294
- * Check if current player is an admin for this scene
4253
+ * Check if current player is an admin for this scene. With no player yet it waits for one on the SDK's timer and
4254
+ * checks then (utils/player-wait.ts): one wait at a time, ended quietly after 30 s with no wallet. A guest reading
4255
+ * (isGuest true) is checked at once and the wait goes on for a non-guest reading, checked once more if one comes
4256
+ * within the 30 s. Resolves when the check is done, or at once when there is none to run.
3295
4257
  */
3296
4258
  async checkAdminStatus() {
3297
- const player = getPlayer2();
3298
- if (!player?.userId) {
3299
- this.log("No player data yet");
3300
- return;
3301
- }
4259
+ await this.adminWait.run();
4260
+ }
4261
+ /** The admin check proper, for a player the explorer has resolved */
4262
+ async checkAdminFor(player) {
3302
4263
  this.playerWallet = player.userId;
3303
4264
  if (this.config.forceAdmin) {
3304
4265
  this.isAdmin = true;
3305
4266
  this.isOwner = true;
4267
+ this.moderation.applyStanding({ isBanned: false, canModerate: true });
3306
4268
  this.log("Admin status FORCED (forceAdmin: true)");
4269
+ this.uploadControls().catch(() => {
4270
+ });
4271
+ this.client.frames?.adminCheckSucceeded();
3307
4272
  return;
3308
4273
  }
3309
4274
  try {
@@ -3314,17 +4279,54 @@ var AdminPanelUIModule = class {
3314
4279
  const data = await res.json();
3315
4280
  this.isAdmin = data.showButton ?? data.hasAccess;
3316
4281
  this.isOwner = data.isOwner || data.isSceneAdmin;
3317
- if (data.isBanned) {
4282
+ const wasBanned = this.moderation.standing === "banned";
4283
+ if (typeof data.privateMode?.on === "boolean") this.privateModeOn = data.privateMode.on;
4284
+ this.moderation.applyStanding({
4285
+ isBanned: data.isBanned === true,
4286
+ canModerate: data.showButton === true || data.hasAccess === true,
4287
+ privateBlocked: data.privateBlocked === true,
4288
+ isCitizen: data.isCitizen === true
4289
+ });
4290
+ if (data.isBanned === true && !wasBanned) {
3318
4291
  this.config.onBroadcast?.("You have been banned from this scene.");
3319
- this.banKickPlayer();
3320
- this.log("Player is banned - kicking");
4292
+ this.log("Player is banned - blocked");
3321
4293
  }
3322
4294
  this.log("Admin status:", this.isAdmin, "Owner:", this.isOwner);
4295
+ if (this.isAdmin) this.uploadControls().catch(() => {
4296
+ });
4297
+ if (this.isAdmin) this.client.frames?.adminCheckSucceeded();
3323
4298
  }
3324
4299
  } catch (err) {
3325
4300
  this.log("Admin check error:", err);
3326
4301
  }
3327
4302
  }
4303
+ /** My wallet, lowercased: admin-check's player, else the explorer's */
4304
+ myWallet() {
4305
+ let wallet = this.playerWallet;
4306
+ if (!wallet) {
4307
+ try {
4308
+ wallet = getPlayer2()?.userId || "";
4309
+ } catch {
4310
+ wallet = "";
4311
+ }
4312
+ }
4313
+ return wallet ? wallet.toLowerCase() : null;
4314
+ }
4315
+ /** Blocked turned on or off: the panel closes, and the client stops what it plays and tells the scene */
4316
+ onStandingChange(blocked, standing) {
4317
+ if (blocked) this.hide();
4318
+ this.client._onBlockedChange?.(blocked, standing);
4319
+ }
4320
+ /** True while this visitor is banned or kicked (2026-11-17) */
4321
+ get isVisitorBlocked() {
4322
+ return this.moderation.blocked;
4323
+ }
4324
+ /** A url the scene's queue or the slots would play - nothing while this visitor is blocked */
4325
+ playUrl(url) {
4326
+ if (this.moderation.blocked) return;
4327
+ this.currentVideoUrl = url;
4328
+ this.config.onVideoPlay?.(url);
4329
+ }
3328
4330
  /**
3329
4331
  * Toggle the admin panel open/closed
3330
4332
  */
@@ -3376,6 +4378,128 @@ var AdminPanelUIModule = class {
3376
4378
  this.config.sceneTabs.push(tab);
3377
4379
  this.log("Registered scene tab:", tab.label);
3378
4380
  }
4381
+ // --- Scene controls (2026-11-18; Venue since 2026-11-19, Pro until then) ---
4382
+ /**
4383
+ * Register scene controls: the CONTROLS tab draws them, a press reaches every visitor's copy through the scene's
4384
+ * queue, and the declaration goes to the scene's record once an admin's check has succeeded. The same as the config's
4385
+ * `controls`; a control registered again by id replaces the earlier one. Only the shape is checked here - thestatic.tv
4386
+ * checks the ids, labels and bounds when the declaration is uploaded, and every press against it.
4387
+ */
4388
+ registerControls(controls) {
4389
+ for (const control of controls) {
4390
+ if (!control || typeof control.id !== "string" || !Array.isArray(control.options) || typeof control.onChange !== "function") {
4391
+ this.log("Scene control skipped - not a SceneControl:", control);
4392
+ continue;
4393
+ }
4394
+ const at = this.controls.findIndex((c) => c.id === control.id);
4395
+ if (at >= 0) this.controls[at] = control;
4396
+ else this.controls.push(control);
4397
+ }
4398
+ this.log("Registered scene controls:", this.controls.map((c) => c.id));
4399
+ this.readSavedState().catch(() => {
4400
+ });
4401
+ this.uploadControls().catch(() => {
4402
+ });
4403
+ }
4404
+ /** True when `option` is one of the control's, or 'off' on a control that has OFF */
4405
+ isControlOption(control, option) {
4406
+ if (option === "off") return control.off === true;
4407
+ return control.options.some((o) => o.id === option);
4408
+ }
4409
+ /** A queued sceneControl's registered control and valid option, or null for anything else */
4410
+ controlCommand(payload) {
4411
+ const p = payload;
4412
+ if (!p || typeof p.control !== "string" || typeof p.option !== "string") return null;
4413
+ const control = this.controls.find((c) => c.id === p.control);
4414
+ if (!control || !this.isControlOption(control, p.option)) return null;
4415
+ return { control, option: p.option };
4416
+ }
4417
+ /** Run a control's option on this copy and mark it current; a handler that throws is logged and breaks nothing else */
4418
+ applyControl(control, option) {
4419
+ this.currentOption[control.id] = option;
4420
+ try {
4421
+ control.onChange(option);
4422
+ } catch (err) {
4423
+ this.log("Control handler failed:", control.id, option, err);
4424
+ }
4425
+ }
4426
+ /** A press in the CONTROLS tab: this copy runs it at once, then everyone's through the queue (Venue, 2026-11-19) */
4427
+ async pressControl(control, option) {
4428
+ if (!this.venue) return;
4429
+ this.applyControl(control, option);
4430
+ await this.sendSceneCommand("sceneControl", { control: control.id, option }, this.controlLine);
4431
+ }
4432
+ /**
4433
+ * The saved option of every persist control, read once a load from the scene's public state route - after the admin
4434
+ * check and the video state, before the poll starts - and run on this copy, so a late arrival sees what the last
4435
+ * press set. A saved option that is not one of the control's is ignored, as is a failed read; a control with no saved
4436
+ * option keeps the scene's own default.
4437
+ */
4438
+ async readSavedState() {
4439
+ if (this.stateRead || !this.loadReadsDone || !this.venue) return;
4440
+ const persisted = this.controls.filter((c) => c.persist === true);
4441
+ if (persisted.length === 0) return;
4442
+ this.stateRead = true;
4443
+ try {
4444
+ const res = await fetch(`${this.baseUrl}/scene/${this.config.sceneId}/state`);
4445
+ if (!res.ok) {
4446
+ this.log("Scene state read refused:", res.status);
4447
+ return;
4448
+ }
4449
+ const data = await res.json();
4450
+ const state = data && typeof data.state === "object" && data.state !== null ? data.state : {};
4451
+ for (const control of persisted) {
4452
+ const saved = state[control.id];
4453
+ if (typeof saved === "string" && this.isControlOption(control, saved)) {
4454
+ this.log("Saved control option:", control.id, saved);
4455
+ this.applyControl(control, saved);
4456
+ }
4457
+ }
4458
+ } catch (err) {
4459
+ this.log("Scene state read error:", err);
4460
+ }
4461
+ }
4462
+ /**
4463
+ * The declaration - each control's id, label, options, off and persist, never its handler - posted once a load to the
4464
+ * scene's record on thestatic.tv, from a copy whose admin check succeeded, so the scene's page draws the same buttons.
4465
+ * thestatic.tv checks the shape and bounds and writes only a declaration that differs. A refusal is logged, never
4466
+ * shown to the visitor, and not retried in this load.
4467
+ */
4468
+ async uploadControls() {
4469
+ if (this.controlsUploaded || !this.isAdmin || !this.venue || this.controls.length === 0) return;
4470
+ this.controlsUploaded = true;
4471
+ const controls = this.controls.map((c) => ({
4472
+ id: c.id,
4473
+ label: c.label,
4474
+ options: c.options.map((o) => ({ id: o.id, label: o.label })),
4475
+ off: c.off === true,
4476
+ persist: c.persist === true
4477
+ }));
4478
+ try {
4479
+ const res = await this.signedRequest(`${this.baseUrl}/scene/${this.config.sceneId}/config`, {
4480
+ method: "POST",
4481
+ headers: { "Content-Type": "application/json" },
4482
+ body: JSON.stringify({ controls })
4483
+ });
4484
+ if (res.ok) {
4485
+ this.log("Scene controls declared:", controls.map((c) => c.id));
4486
+ return;
4487
+ }
4488
+ const data = await res.json().catch(() => ({}));
4489
+ this.log("Scene controls declaration refused:", res.status, data.error);
4490
+ } catch (err) {
4491
+ this.log("Scene controls declaration error:", err);
4492
+ }
4493
+ }
4494
+ /** Remember a command id the poll has run or this copy has sent, forgetting the oldest past SEEN_COMMAND_IDS_MAX */
4495
+ markCommandSeen(id) {
4496
+ if (this.seenCommandIds.has(id)) return;
4497
+ this.seenCommandIds.add(id);
4498
+ this.seenCommandOrder.push(id);
4499
+ while (this.seenCommandOrder.length > SEEN_COMMAND_IDS_MAX) {
4500
+ this.seenCommandIds.delete(this.seenCommandOrder.shift());
4501
+ }
4502
+ }
3379
4503
  // --- Stream Polling ---
3380
4504
  startStreamPolling() {
3381
4505
  if (this.pollIntervalId !== null) return;
@@ -3416,52 +4540,91 @@ var AdminPanelUIModule = class {
3416
4540
  * body proved nothing and is no longer sent. Returns a fetch-like shape for the call sites.
3417
4541
  */
3418
4542
  async signedRequest(url, init = {}) {
3419
- const res = await signedFetch2({ url, init: { method: init.method || "GET", headers: init.headers || {}, body: init.body } });
4543
+ const res = await signedFetch3({ url, init: { method: init.method || "GET", headers: init.headers || {}, body: init.body } });
3420
4544
  return {
3421
4545
  ok: res.ok,
3422
4546
  status: res.status,
3423
4547
  json: async () => res.body ? JSON.parse(res.body) : {}
3424
4548
  };
3425
4549
  }
4550
+ /**
4551
+ * Every visitor's copy reads the scene's queue (a public GET, every 5 s). Since 2026-11-18 the poll sends the server's
4552
+ * cursor back as `since` once it has one - the first poll has none, so the 30-second replay on load stays, which the
4553
+ * kicks rely on - and tells commands apart by id: a bounded set of the last SEEN_COMMAND_IDS_MAX, this copy's own
4554
+ * sends among them (a press is not run twice here), so two commands in one millisecond both run. A command with no id
4555
+ * falls back to the timestamp rule every command used until then, and a server that answers no cursor (production
4556
+ * before 2026-11-18) gets no since and is read as before.
4557
+ */
3426
4558
  async pollCommands() {
3427
4559
  try {
3428
- const res = await fetch(`${this.baseUrl}/scene/${this.config.sceneId}/commands`);
4560
+ const since = this.commandCursor !== null ? `?since=${this.commandCursor}` : "";
4561
+ const res = await fetch(`${this.baseUrl}/scene/${this.config.sceneId}/commands${since}`);
3429
4562
  if (!res.ok) return;
3430
4563
  const data = await res.json();
3431
4564
  const commands = data.commands || [];
4565
+ if (typeof data.cursor === "number") this.commandCursor = data.cursor;
3432
4566
  for (const cmd of commands) {
3433
- if (cmd.timestamp <= this.lastCommandTimestamp) continue;
3434
- this.lastCommandTimestamp = cmd.timestamp;
3435
- if (cmd.type === "broadcast" && cmd.payload?.text) {
3436
- const msg = cmd.payload.from ? `${cmd.payload.from}: ${cmd.payload.text}` : cmd.payload.text;
3437
- this.log("Received broadcast:", msg);
3438
- this.config.onBroadcast?.(msg);
3439
- } else if (cmd.type === "clearBroadcast") {
3440
- this.log("Received clearBroadcast");
3441
- hideNotification();
3442
- } else if ((cmd.type === "videoPlay" || cmd.type === "videoSetUrl") && cmd.payload?.url) {
3443
- this.log("Received video play:", cmd.type, cmd.payload.url);
3444
- this.config.onVideoPlay?.(cmd.payload.url);
3445
- } else if (cmd.type === "videoStop" || cmd.type === "videoClear") {
3446
- this.log("Received video stop/clear:", cmd.type);
3447
- this.config.onVideoStop?.();
3448
- } else if (cmd.type === "videoPlaySlot" && cmd.payload?.slot) {
3449
- const slotId = cmd.payload.slot;
3450
- if (cmd.payload.url) {
3451
- this.log("Received videoPlaySlot with URL:", slotId, cmd.payload.url);
3452
- this.config.onVideoPlay?.(cmd.payload.url);
3453
- } else {
3454
- this.log("Received videoPlaySlot:", slotId);
3455
- this.playSlot(slotId);
3456
- }
3457
- } else if (this.config.onCommand) {
3458
- this.log("Received command:", cmd.type, cmd.payload);
3459
- this.config.onCommand(cmd.type, cmd.payload);
4567
+ if (typeof cmd.id === "string" && cmd.id !== "") {
4568
+ if (this.seenCommandIds.has(cmd.id)) continue;
4569
+ this.markCommandSeen(cmd.id);
4570
+ if (typeof cmd.timestamp === "number" && cmd.timestamp > this.lastCommandTimestamp) this.lastCommandTimestamp = cmd.timestamp;
4571
+ } else {
4572
+ if (cmd.timestamp <= this.lastCommandTimestamp) continue;
4573
+ this.lastCommandTimestamp = cmd.timestamp;
4574
+ }
4575
+ try {
4576
+ this.runCommand(cmd);
4577
+ } catch (err) {
4578
+ this.log("Command handler failed:", cmd.type, err);
3460
4579
  }
3461
4580
  }
3462
4581
  } catch (err) {
3463
4582
  }
3464
4583
  }
4584
+ /** One queued command on this copy: the SDK's own types here, a registered control's option, else the scene's onCommand */
4585
+ runCommand(cmd) {
4586
+ const control = cmd.type === "sceneControl" && this.venue ? this.controlCommand(cmd.payload) : null;
4587
+ if (cmd.type === "broadcast" && cmd.payload?.text) {
4588
+ const msg = cmd.payload.from ? `${cmd.payload.from}: ${cmd.payload.text}` : cmd.payload.text;
4589
+ this.log("Received broadcast:", msg);
4590
+ this.config.onBroadcast?.(msg);
4591
+ } else if (cmd.type === "clearBroadcast") {
4592
+ this.log("Received clearBroadcast");
4593
+ hideNotification();
4594
+ } else if (cmd.type === "kickBanned" || cmd.type === "kickAll") {
4595
+ this.log("Received kick:", cmd.type, cmd.payload);
4596
+ this.moderation.handleCommand(cmd.type, cmd.payload);
4597
+ this.config.onCommand?.(cmd.type, cmd.payload);
4598
+ } else if (cmd.type === "privateMode" && this.venue) {
4599
+ this.log("Received privateMode - re-reading my standing");
4600
+ this.moderation.handleCommand(cmd.type, cmd.payload);
4601
+ } else if ((cmd.type === "videoPlay" || cmd.type === "videoSetUrl") && cmd.payload?.url) {
4602
+ this.log("Received video play:", cmd.type, cmd.payload.url);
4603
+ this.playUrl(cmd.payload.url);
4604
+ } else if (cmd.type === "videoStop" || cmd.type === "videoClear") {
4605
+ this.log("Received video stop/clear:", cmd.type);
4606
+ if (cmd.type === "videoClear") this.currentVideoUrl = null;
4607
+ this.config.onVideoStop?.();
4608
+ } else if (cmd.type === "videoPlaySlot" && cmd.payload?.slot) {
4609
+ const slotId = cmd.payload.slot;
4610
+ if (cmd.payload.url) {
4611
+ this.log("Received videoPlaySlot with URL:", slotId, cmd.payload.url);
4612
+ this.playUrl(cmd.payload.url);
4613
+ } else {
4614
+ this.log("Received videoPlaySlot:", slotId);
4615
+ this.playSlot(slotId);
4616
+ }
4617
+ } else if (cmd.type === "framesRefresh") {
4618
+ this.log("Received framesRefresh");
4619
+ this.client.frames?.refresh();
4620
+ } else if (control) {
4621
+ this.log("Received scene control:", control.control.id, control.option);
4622
+ this.applyControl(control.control, control.option);
4623
+ } else if (this.config.onCommand) {
4624
+ this.log("Received command:", cmd.type, cmd.payload);
4625
+ this.config.onCommand(cmd.type, cmd.payload);
4626
+ }
4627
+ }
3465
4628
  // --- Stream API Calls ---
3466
4629
  async fetchStreamData() {
3467
4630
  if (this.streamFetched || !this.playerWallet) return;
@@ -3503,6 +4666,7 @@ var AdminPanelUIModule = class {
3503
4666
  defaultSlot: data.defaultSlot || null,
3504
4667
  videoSlots: data.videoSlots || {}
3505
4668
  };
4669
+ if (typeof data.currentVideoUrl === "string" && data.currentVideoUrl !== "") this.currentVideoUrl = data.currentVideoUrl;
3506
4670
  this.videoStateFetched = true;
3507
4671
  this.log("Video state fetched:", this.videoState.defaultSlot || "no default");
3508
4672
  }
@@ -3517,7 +4681,7 @@ var AdminPanelUIModule = class {
3517
4681
  const slot = this.videoState?.videoSlots?.[slotId];
3518
4682
  if (slot?.url) {
3519
4683
  this.log("Playing slot:", slotId, slot.url);
3520
- this.config.onVideoPlay?.(slot.url);
4684
+ this.playUrl(slot.url);
3521
4685
  } else {
3522
4686
  this.log("Slot has no URL:", slotId);
3523
4687
  this.config.onVideoSlotPlay?.(slotId);
@@ -3532,7 +4696,7 @@ var AdminPanelUIModule = class {
3532
4696
  const slot = this.videoState.videoSlots?.[defaultSlot];
3533
4697
  if (slot?.url) {
3534
4698
  this.log("Auto-playing default slot:", defaultSlot);
3535
- this.config.onVideoPlay?.(slot.url);
4699
+ this.playUrl(slot.url);
3536
4700
  }
3537
4701
  }
3538
4702
  async createChannel() {
@@ -3595,36 +4759,89 @@ var AdminPanelUIModule = class {
3595
4759
  }
3596
4760
  this.trialClaiming = false;
3597
4761
  }
4762
+ /**
4763
+ * Delete, step one (thestatic.tv 2026-11-13): the delete takes the channel's recordings since that day, and only
4764
+ * once the caller has acknowledged how many. So Delete asks first - a signed GET to the same route, which deletes
4765
+ * nothing - and opens the confirm with what it answered. It posted the delete at once with an empty body, which the
4766
+ * server now refuses for a channel that holds a recording. The look is a GET and never a flag in a delete's body:
4767
+ * a server from before that day answers a GET 405 (said below, nothing deleted), where it would read a body flag as
4768
+ * nothing and delete.
4769
+ */
3598
4770
  async deleteChannel() {
3599
4771
  if (!this.playerWallet || this.channelDeleting || !this.streamData?.hasChannel) return;
3600
4772
  this.channelDeleting = true;
3601
4773
  this.channelDeleteError = "";
4774
+ this.channelDeleteLook = null;
4775
+ this.channelDeleteChanged = false;
4776
+ try {
4777
+ this.log("Reading what a channel delete would take...");
4778
+ const res = await this.signedRequest(`${this.baseUrl}/scene/${this.config.sceneId}/stream/delete`);
4779
+ const data = await res.json().catch(() => ({}));
4780
+ const figures = figuresOf(data);
4781
+ if (res.ok && figures) {
4782
+ this.channelDeleteLook = { figures, unlinkOnly: data.unlinkOnly === true };
4783
+ } else if (res.status === 405) {
4784
+ this.channelDeleteError = "The server cannot show what a delete takes - nothing was deleted";
4785
+ } else if (res.ok) {
4786
+ this.channelDeleteError = "The server showed no figures - nothing was deleted";
4787
+ } else {
4788
+ this.channelDeleteError = data.error || "Could not read the channel - nothing was deleted";
4789
+ this.log("Channel delete look refused:", data.error);
4790
+ }
4791
+ } catch (err) {
4792
+ this.channelDeleteError = "Network error - nothing was deleted";
4793
+ this.log("Channel delete look error:", err);
4794
+ }
4795
+ this.channelDeleting = false;
4796
+ }
4797
+ /**
4798
+ * Delete, step two: the delete, with the figures the confirm showed sent back as `acknowledge`. A count that moved
4799
+ * since the look (the server's 409 with the figures as they are now) re-opens the confirm with them, marked changed -
4800
+ * never sent on. Anything else refused is said, the confirm closed.
4801
+ */
4802
+ async confirmDeleteChannel() {
4803
+ const look = this.channelDeleteLook;
4804
+ if (!this.playerWallet || this.channelDeleting || !look) return;
4805
+ this.channelDeleting = true;
4806
+ this.channelDeleteError = "";
3602
4807
  try {
3603
- this.log("Deleting channel for scene...");
4808
+ this.log("Deleting channel for scene...", look.figures);
3604
4809
  const res = await this.signedRequest(
3605
4810
  `${this.baseUrl}/scene/${this.config.sceneId}/stream/delete`,
3606
4811
  {
3607
4812
  method: "POST",
3608
4813
  headers: { "Content-Type": "application/json" },
3609
- body: JSON.stringify({})
4814
+ body: JSON.stringify({ acknowledge: look.figures })
3610
4815
  }
3611
4816
  );
3612
- const data = await res.json();
4817
+ const data = await res.json().catch(() => ({}));
4818
+ const moved = res.status === 409 && data.confirmRequired === true ? figuresOf(data) : null;
3613
4819
  if (res.ok) {
3614
4820
  this.log("Channel deleted:", data);
4821
+ this.channelDeleteLook = null;
3615
4822
  this.streamData = null;
3616
4823
  this.streamFetched = false;
3617
- this.config.onBroadcast?.("Channel deleted successfully");
4824
+ const gone = typeof data.recordingsDeleted === "number" && data.recordingsDeleted > 0 ? ` with ${data.recordingsDeleted} recording${data.recordingsDeleted === 1 ? "" : "s"}` : "";
4825
+ this.config.onBroadcast?.(`Channel deleted${gone}`);
4826
+ } else if (moved) {
4827
+ this.channelDeleteLook = { figures: moved, unlinkOnly: false };
4828
+ this.channelDeleteChanged = true;
3618
4829
  } else {
4830
+ this.channelDeleteLook = null;
3619
4831
  this.channelDeleteError = data.error || "Failed to delete channel";
3620
4832
  this.log("Channel deletion failed:", data.error);
3621
4833
  }
3622
4834
  } catch (err) {
4835
+ this.channelDeleteLook = null;
3623
4836
  this.channelDeleteError = "Network error deleting channel";
3624
4837
  this.log("Channel deletion error:", err);
3625
4838
  }
3626
4839
  this.channelDeleting = false;
3627
4840
  }
4841
+ cancelDeleteChannel() {
4842
+ this.channelDeleteLook = null;
4843
+ this.channelDeleteChanged = false;
4844
+ }
3628
4845
  async startStream() {
3629
4846
  if (!this.playerWallet || this.streamControlling || !this.streamData?.hasChannel || this.streamData.isLive) return;
3630
4847
  if ((this.streamData.sparksBalance || 0) <= 0) {
@@ -3831,6 +5048,7 @@ var AdminPanelUIModule = class {
3831
5048
  this.modStatus = "saved";
3832
5049
  this.log("Banned wallet:", normalized);
3833
5050
  this.config.onCommand?.("kickBanned", { wallet: normalized });
5051
+ await this.sendSceneCommand("kickBanned", { wallet: normalized }, this.kickLine("Banned and kicked"));
3834
5052
  } else {
3835
5053
  this.modStatus = "error";
3836
5054
  }
@@ -3865,15 +5083,142 @@ var AdminPanelUIModule = class {
3865
5083
  this.log("Unban error:", err);
3866
5084
  }
3867
5085
  }
3868
- banKickPlayer() {
3869
- movePlayerTo({ newRelativePosition: BAN_KICK_POSITION });
3870
- this.log("Player ban-kicked");
5086
+ /**
5087
+ * Queue a command on thestatic.tv for every visitor's copy of the scene (2026-11-17): a signed POST to the scene's
5088
+ * commands route, which takes it from the scene's owner, an admin or an authorized user at the scene's registered
5089
+ * location, and which every copy's poll reads within its 30-second window. The one sender for the kicks, the scene
5090
+ * controls and, since 2026-11-18, the Video and Broadcast buttons; each shows what it came to on its section's own
5091
+ * line. The command id the server answers goes into the seen set, so this copy's poll does not run its own press a
5092
+ * second time. Returns that id (empty when the answer carries none), or null when the command was not sent.
5093
+ */
5094
+ async sendSceneCommand(type, payload, line) {
5095
+ const data = await this.sendSigned("commands", { type, payload }, line);
5096
+ if (data === null) return null;
5097
+ const id = typeof data.commandId === "string" ? data.commandId : "";
5098
+ if (id !== "") this.markCommandSeen(id);
5099
+ return id;
5100
+ }
5101
+ /**
5102
+ * The one signed sender's POST (2026-11-18; since 2026-11-19 private mode's switch goes through it too, to its own
5103
+ * route): signed as the presser to one of the scene's routes on thestatic.tv, which decides whether the presser may;
5104
+ * what it came to shown on the section's line in a control's four words. Returns the answer, or null when not sent.
5105
+ */
5106
+ async sendSigned(route, body, line) {
5107
+ try {
5108
+ const res = await this.signedRequest(`${this.baseUrl}/scene/${this.config.sceneId}/${route}`, {
5109
+ method: "POST",
5110
+ headers: { "Content-Type": "application/json" },
5111
+ body: JSON.stringify(body)
5112
+ });
5113
+ const parsed = await res.json().catch(() => ({}));
5114
+ const data = parsed && typeof parsed === "object" ? parsed : {};
5115
+ if (res.ok) {
5116
+ line.show(line.sent);
5117
+ return data;
5118
+ }
5119
+ line.show(res.status === 401 || res.status === 403 ? `${line.notSent}: no access` : `${line.notSent}: HTTP ${res.status}`);
5120
+ this.log("Refused:", route, body.type ?? "", res.status, data.error);
5121
+ } catch (err) {
5122
+ line.show(`${line.notSent}: network error`);
5123
+ this.log("Send error:", route, err);
5124
+ }
5125
+ return null;
5126
+ }
5127
+ /**
5128
+ * PRIVATE MODE ON / OFF (2026-11-19, Venue; thestatic-hq docs/MERGE-CONTRACT-2026-11-19.md section 2): `{ on }` to
5129
+ * the scene's private route through the one signed sender. thestatic.tv decides who may switch it (its scene access
5130
+ * check) and queues `privateMode` for every copy, this one included, which re-reads its standing on it. The state
5131
+ * shown follows the server's answer, never the press.
5132
+ */
5133
+ async setPrivateMode(on) {
5134
+ if (!this.venue) return;
5135
+ const data = await this.sendSigned("private", { on }, this.privateLine);
5136
+ if (typeof data?.privateMode?.on === "boolean") this.privateModeOn = data.privateMode.on;
5137
+ }
5138
+ /** KICK ALL: every visitor who cannot moderate the scene is moved out and kept out for a while (2026-11-17) */
5139
+ async kickAll() {
5140
+ this.log("KICK ALL clicked");
5141
+ this.config.onCommand?.("kickAll", {});
5142
+ await this.sendSceneCommand("kickAll", {}, this.kickLine("KICK ALL sent"));
3871
5143
  }
5144
+ /**
5145
+ * BROADCAST (2026-11-18): queued for every visitor, as the scene's page on thestatic.tv sends it - `from` the presser's
5146
+ * display name, ADMIN when the explorer has none (the page's own default) - and shown here at once as everyone sees
5147
+ * it, `from: text`. Until then the in-world Send reached the presser's copy alone.
5148
+ */
3872
5149
  sendBroadcast() {
3873
- if (!this.broadcastText.trim()) return;
3874
- this.config.onBroadcast?.(this.broadcastText.trim());
5150
+ const text = this.broadcastText.trim();
5151
+ if (!text) return;
5152
+ const from = this.myName();
5153
+ this.config.onBroadcast?.(`${from}: ${text}`);
3875
5154
  this.broadcastText = "";
3876
5155
  this.log("Broadcast sent");
5156
+ this.sendSceneCommand("broadcast", { text, from }, this.broadcastLine).catch(() => {
5157
+ });
5158
+ }
5159
+ /** The presser's display name for a broadcast's from, ADMIN when the explorer has none; within the route's 100 */
5160
+ myName() {
5161
+ try {
5162
+ const name = getPlayer2()?.name;
5163
+ if (typeof name === "string" && name.trim() !== "") return name.trim().slice(0, 100);
5164
+ } catch {
5165
+ }
5166
+ return "ADMIN";
5167
+ }
5168
+ // --- The Video tab's buttons (2026-11-18): each does here at once what it did, then queues the same for everyone ---
5169
+ /** PLAY NOW: the typed url plays here and is queued as videoSetUrl, which thestatic.tv keeps for later arrivals */
5170
+ playNow() {
5171
+ const url = this.customVideoUrl.trim();
5172
+ if (!url) return;
5173
+ this.playUrl(url);
5174
+ this.sendSceneCommand("videoSetUrl", { url }, this.videoLine).catch(() => {
5175
+ });
5176
+ }
5177
+ /** Play on Screen: the scene's own live stream, as PLAY NOW with its HLS url (what the scene's page sends for it) */
5178
+ playStreamOnScreen(url) {
5179
+ this.playUrl(url);
5180
+ this.sendSceneCommand("videoSetUrl", { url }, this.videoLine).catch(() => {
5181
+ });
5182
+ }
5183
+ /** Play 1-5: the slot plays here (its url from the video state) and is queued as videoPlaySlot; the server resolves its url for everyone */
5184
+ pressSlot(slotId) {
5185
+ this.playSlot(slotId);
5186
+ this.sendSceneCommand("videoPlaySlot", { slot: slotId }, this.videoLine).catch(() => {
5187
+ });
5188
+ }
5189
+ /**
5190
+ * PLAYBACK Play: the current video - the one the screen last played here, or the scene's current url from the video
5191
+ * state at load - plays again here and is queued as videoPlay with its url; with none known nothing is sent and the
5192
+ * line says so. onCommand gets ('videoPlay', { playing: true }) as it did before, for a scene that reads it.
5193
+ */
5194
+ playbackPlay() {
5195
+ this.config.onCommand?.("videoPlay", { playing: true });
5196
+ const url = this.currentVideoUrl;
5197
+ if (!url) {
5198
+ this.videoStatus = "Not sent: no video";
5199
+ return;
5200
+ }
5201
+ this.playUrl(url);
5202
+ this.sendSceneCommand("videoPlay", { url }, this.videoLine).catch(() => {
5203
+ });
5204
+ }
5205
+ /** Stop: the screen stops here and videoStop is queued for everyone */
5206
+ playbackStop() {
5207
+ this.config.onVideoStop?.();
5208
+ this.sendSceneCommand("videoStop", {}, this.videoLine).catch(() => {
5209
+ });
5210
+ }
5211
+ /**
5212
+ * Reset Default: the screen goes back to its default here - what every copy does on a queued videoClear - and
5213
+ * videoClear is queued, which also clears the scene's kept url on thestatic.tv. onCommand gets ('videoClear', {}) as
5214
+ * it did before.
5215
+ */
5216
+ resetDefault() {
5217
+ this.config.onCommand?.("videoClear", {});
5218
+ this.currentVideoUrl = null;
5219
+ this.config.onVideoStop?.();
5220
+ this.sendSceneCommand("videoClear", {}, this.videoLine).catch(() => {
5221
+ });
3877
5222
  }
3878
5223
  setActiveTab(tab) {
3879
5224
  const previousTab = this.activeTab;
@@ -3887,6 +5232,22 @@ var AdminPanelUIModule = class {
3887
5232
  this.stopStreamPolling();
3888
5233
  }
3889
5234
  }
5235
+ /** A control's button (2026-11-18): the option's label, highlighted while that option is current on this copy */
5236
+ controlButton(control, option, label) {
5237
+ const current = this.currentOption[control.id] === option;
5238
+ return /* @__PURE__ */ ReactEcs6.createElement(
5239
+ Button4,
5240
+ {
5241
+ key: `control-${control.id}-${option}`,
5242
+ uiTransform: { minWidth: this.s(70), height: this.s(UI_DIMENSIONS.admin.buttonHeightSmall), margin: 4, padding: { left: 10, right: 10 } },
5243
+ uiBackground: { color: current ? C2.cyan : C2.btn },
5244
+ value: label,
5245
+ fontSize: this.theme.buttonSmall,
5246
+ color: current ? Color46.Black() : C2.text,
5247
+ onMouseDown: () => this.pressControl(control, option)
5248
+ }
5249
+ );
5250
+ }
3890
5251
  /**
3891
5252
  * Render a scaled notification banner
3892
5253
  * Uses same layout as NotificationBanner but with scaled font size
@@ -3897,8 +5258,8 @@ var AdminPanelUIModule = class {
3897
5258
  if (!state.visible) return null;
3898
5259
  const N2 = UI_DIMENSIONS.notification;
3899
5260
  const colors = THEME.colors;
3900
- return /* @__PURE__ */ ReactEcs5.createElement(
3901
- UiEntity5,
5261
+ return /* @__PURE__ */ ReactEcs6.createElement(
5262
+ UiEntity6,
3902
5263
  {
3903
5264
  uiTransform: {
3904
5265
  positionType: "absolute",
@@ -3908,8 +5269,8 @@ var AdminPanelUIModule = class {
3908
5269
  alignItems: "center"
3909
5270
  }
3910
5271
  },
3911
- /* @__PURE__ */ ReactEcs5.createElement(
3912
- UiEntity5,
5272
+ /* @__PURE__ */ ReactEcs6.createElement(
5273
+ UiEntity6,
3913
5274
  {
3914
5275
  uiTransform: {
3915
5276
  minWidth: this.s(200),
@@ -3921,15 +5282,15 @@ var AdminPanelUIModule = class {
3921
5282
  },
3922
5283
  uiBackground: { color: colors.panel }
3923
5284
  },
3924
- /* @__PURE__ */ ReactEcs5.createElement(
3925
- UiEntity5,
5285
+ /* @__PURE__ */ ReactEcs6.createElement(
5286
+ UiEntity6,
3926
5287
  {
3927
5288
  uiTransform: { width: N2.borderWidth, height: "100%" },
3928
5289
  uiBackground: { color: colors.cyan }
3929
5290
  }
3930
5291
  ),
3931
- /* @__PURE__ */ ReactEcs5.createElement(
3932
- UiEntity5,
5292
+ /* @__PURE__ */ ReactEcs6.createElement(
5293
+ UiEntity6,
3933
5294
  {
3934
5295
  uiTransform: {
3935
5296
  flexGrow: 1,
@@ -3939,8 +5300,8 @@ var AdminPanelUIModule = class {
3939
5300
  alignItems: "center"
3940
5301
  }
3941
5302
  },
3942
- /* @__PURE__ */ ReactEcs5.createElement(
3943
- Label5,
5303
+ /* @__PURE__ */ ReactEcs6.createElement(
5304
+ Label6,
3944
5305
  {
3945
5306
  value: state.text,
3946
5307
  fontSize: this.s(N2.fontSize),
@@ -3949,8 +5310,8 @@ var AdminPanelUIModule = class {
3949
5310
  }
3950
5311
  )
3951
5312
  ),
3952
- /* @__PURE__ */ ReactEcs5.createElement(
3953
- UiEntity5,
5313
+ /* @__PURE__ */ ReactEcs6.createElement(
5314
+ UiEntity6,
3954
5315
  {
3955
5316
  uiTransform: { width: 5, height: 5, margin: { right: 10 } },
3956
5317
  uiBackground: { color: colors.cyan }
@@ -4004,9 +5365,13 @@ var StaticTVClient = class {
4004
5365
  this._keyId = null;
4005
5366
  this._disabled = false;
4006
5367
  this._tier = "free";
5368
+ /** Venue (2026-11-19): the server's flag beside a Pro tier; the event features need it */
5369
+ this._venue = false;
4007
5370
  this._standardFeaturesEnabled = false;
4008
5371
  this._proFeaturesEnabled = false;
4009
5372
  this._pendingProConfig = null;
5373
+ /** Controls registered before the admin panel exists (the tier not yet confirmed) - handed to it at init (2026-11-18) */
5374
+ this._pendingControls = [];
4010
5375
  this._featuresResolved = false;
4011
5376
  /** Guide module - fetch channel lineup (standard/pro tier) */
4012
5377
  this.guide = null;
@@ -4050,6 +5415,8 @@ var StaticTVClient = class {
4050
5415
  };
4051
5416
  this.baseUrl = config.baseUrl || DEFAULT_BASE_URL;
4052
5417
  this.apiUrl = config.apiUrl || DEFAULT_BASE_URL;
5418
+ this.frames = new FramesModule(this);
5419
+ if (config.frames) this.frames.register(config.frames);
4053
5420
  if (!config.apiKey) {
4054
5421
  this._disabled = true;
4055
5422
  this._keyType = null;
@@ -4180,7 +5547,7 @@ var StaticTVClient = class {
4180
5547
  * @internal
4181
5548
  */
4182
5549
  async signedRequest(endpoint, init = {}) {
4183
- const response = await signedFetch3({
5550
+ const response = await signedFetch4({
4184
5551
  url: `${this.apiUrl}${endpoint}`,
4185
5552
  init: {
4186
5553
  method: init.method || "POST",
@@ -4240,6 +5607,7 @@ var StaticTVClient = class {
4240
5607
  * @param url Video URL to play
4241
5608
  */
4242
5609
  playVideo(url) {
5610
+ if (this.isVisitorBlocked) return;
4243
5611
  const screen = this.config.videoScreen;
4244
5612
  if (screen !== void 0) {
4245
5613
  this.log(`Playing video: ${url}`);
@@ -4297,6 +5665,7 @@ var StaticTVClient = class {
4297
5665
  _playVideoInternal(url, isFallback = false, isLiveStream = false) {
4298
5666
  const screen = this.config.videoScreen;
4299
5667
  if (screen === void 0) return;
5668
+ if (this.isVisitorBlocked) return;
4300
5669
  this._clearVerificationTimeout();
4301
5670
  this._streamVerified = false;
4302
5671
  if (VideoPlayer.has(screen)) {
@@ -4420,6 +5789,7 @@ var StaticTVClient = class {
4420
5789
  */
4421
5790
  _handleGuideVideoSelect(video) {
4422
5791
  if (!video.src) return;
5792
+ if (this.isVisitorBlocked) return;
4423
5793
  this._pendingVideoData = video;
4424
5794
  const isLiveStream = video.channelId !== void 0 || video.src.includes(".m3u8") || video.src.includes("media.thestatic.tv");
4425
5795
  this._playVideoWithVerification(video, isLiveStream);
@@ -4496,6 +5866,74 @@ var StaticTVClient = class {
4496
5866
  this.log(`Stream confirmed playing: ${this._pendingVideoData.name}`);
4497
5867
  }
4498
5868
  }
5869
+ /**
5870
+ * True while this visitor is banned from the scene or kicked out of it (Pro tier, 2026-11-17), or kept out by its
5871
+ * private mode (Venue, 2026-11-19): the SDK keeps them out of the scene's parcels, shows them only the notice and
5872
+ * plays them no video. A scene with its own media (a radio, its own screen) checks this, or passes
5873
+ * `onBlockedChange`, and stops it.
5874
+ */
5875
+ get isVisitorBlocked() {
5876
+ return this.adminPanel?.isVisitorBlocked ?? false;
5877
+ }
5878
+ /**
5879
+ * This visitor's standing: 'banned', 'kicked', 'private' (2026-11-19) or 'clear', in that precedence (always 'clear'
5880
+ * without the Pro tier's admin panel)
5881
+ */
5882
+ get visitorStanding() {
5883
+ return this.adminPanel?.moderation.standing ?? "clear";
5884
+ }
5885
+ /**
5886
+ * True when the last standing read said this visitor is a TheStatic.tv citizen - their wallet linked to an account
5887
+ * (2026-11-19). False before a read, from a server that does not answer it, and without the Pro tier's admin panel.
5888
+ * For a fresh answer, `checkCitizen()`.
5889
+ */
5890
+ get visitorIsCitizen() {
5891
+ return this.adminPanel?.moderation.isCitizen ?? false;
5892
+ }
5893
+ /**
5894
+ * Whether this visitor is a TheStatic.tv citizen, fresh (2026-11-19): a read of the scene's admin-check through the
5895
+ * moderation module - the last answer when it is under 5 s old, else the next read, gated as every standing read
5896
+ * is. False without the Pro tier's admin panel, and when no read has answered. A scene's citizens-only door asks
5897
+ * this instead of calling a route of its own; thestatic.tv answers it from the signed request, so a scene cannot
5898
+ * claim a citizen.
5899
+ */
5900
+ async checkCitizen() {
5901
+ if (!this.adminPanel) return false;
5902
+ try {
5903
+ return await this.adminPanel.moderation.checkCitizen();
5904
+ } catch {
5905
+ return false;
5906
+ }
5907
+ }
5908
+ /**
5909
+ * The admin panel's moderation reports blocked on or off (2026-11-17): the panels close, the SDK's own video
5910
+ * stops (and its fallback loop comes back once clear), the watch heartbeat stops, and the scene hears of it.
5911
+ * @internal
5912
+ */
5913
+ _onBlockedChange(blocked, standing) {
5914
+ const screen = this.config.videoScreen;
5915
+ if (blocked) {
5916
+ this.guideUI?.hide();
5917
+ this.chatUI?.hide();
5918
+ this.heartbeat?.stopWatching();
5919
+ this._pendingVideoData = null;
5920
+ this._clearVerificationTimeout();
5921
+ if (screen !== void 0 && VideoPlayer.has(screen)) {
5922
+ VideoPlayer.getMutable(screen).playing = false;
5923
+ }
5924
+ this._currentVideoUrl = "";
5925
+ } else if (screen !== void 0) {
5926
+ const fallbackUrl = this.config.fallbackVideoUrl !== void 0 ? this.config.fallbackVideoUrl : DEFAULT_FALLBACK_VIDEO;
5927
+ if (fallbackUrl !== "") this._playVideoInternal(fallbackUrl, true);
5928
+ }
5929
+ if (this.config.onBlockedChange) {
5930
+ try {
5931
+ this.config.onBlockedChange(blocked, standing);
5932
+ } catch (err) {
5933
+ this.error("onBlockedChange failed", err);
5934
+ }
5935
+ }
5936
+ }
4499
5937
  /**
4500
5938
  * Internal handler for broadcast messages
4501
5939
  * @internal
@@ -4554,8 +5992,15 @@ var StaticTVClient = class {
4554
5992
  onBroadcast: (text) => this._handleBroadcast(text),
4555
5993
  onCommand: this.config.onCommand || this._pendingProConfig?.onCommand,
4556
5994
  // Merge other settings from enableProFeatures if provided
4557
- ...this._pendingProConfig
5995
+ ...this._pendingProConfig,
5996
+ // The scene's controls (2026-11-18): the constructor's, enableProFeatures()'s, and any registered before now
5997
+ controls: [
5998
+ ...this.config.controls || [],
5999
+ ...this._pendingProConfig?.controls || [],
6000
+ ...this._pendingControls
6001
+ ]
4558
6002
  };
6003
+ this._pendingControls = [];
4559
6004
  this.adminPanel = new AdminPanelUIModule(this, adminConfig);
4560
6005
  this._proFeaturesEnabled = true;
4561
6006
  this.adminPanel.init().catch((err) => {
@@ -4599,8 +6044,9 @@ var StaticTVClient = class {
4599
6044
  getSceneId() {
4600
6045
  return this._pendingProConfig?.sceneId || this.config.sceneId || this._keyId || void 0;
4601
6046
  }
4602
- _enableFeaturesForTier(tier, keyId) {
6047
+ _enableFeaturesForTier(tier, keyId, venue = false) {
4603
6048
  this._tier = tier;
6049
+ this._venue = tier === "pro" && venue === true;
4604
6050
  if (keyId) {
4605
6051
  this._keyId = keyId;
4606
6052
  }
@@ -4615,6 +6061,7 @@ var StaticTVClient = class {
4615
6061
  this.log("Pro tier detected but no video config - call enableProFeatures() or set videoScreen to enable admin panel");
4616
6062
  }
4617
6063
  }
6064
+ if (this._venue) this.frames.enable();
4618
6065
  this._resolveFeaturesReady(tier);
4619
6066
  }
4620
6067
  /**
@@ -4642,6 +6089,13 @@ var StaticTVClient = class {
4642
6089
  get hasProFeatures() {
4643
6090
  return this._proFeaturesEnabled;
4644
6091
  }
6092
+ /**
6093
+ * True when the server confirmed the Venue tier (2026-11-19): Pro plus the event features - scene
6094
+ * controls, frames, private mode. `tier` stays 'pro' for a Venue scene, so a scene's own Pro checks hold.
6095
+ */
6096
+ get hasVenueFeatures() {
6097
+ return this._venue;
6098
+ }
4645
6099
  /**
4646
6100
  * @deprecated Use `tier` instead
4647
6101
  */
@@ -4711,6 +6165,57 @@ var StaticTVClient = class {
4711
6165
  }
4712
6166
  this.adminPanel.registerSceneTab(tab);
4713
6167
  }
6168
+ /**
6169
+ * Register scene controls for the Admin Panel's CONTROLS tab and the scene's page on thestatic.tv (2026-11-18;
6170
+ * the Venue tier since 2026-11-19, Pro until then) - the same as passing `controls` in the config. Before the panel
6171
+ * exists (the tier not yet confirmed) they are kept and handed to it at init; after, they join the tab at once. On a
6172
+ * Pro scene without Venue they are kept and never drawn, uploaded or run. See `SceneControl`.
6173
+ *
6174
+ * @example
6175
+ * ```typescript
6176
+ * staticTV.registerControls([{
6177
+ * id: 'digifog', label: 'DigiFog', off: true, persist: true,
6178
+ * options: [{ id: 'stars', label: 'Stars' }, { id: 'pulse', label: 'Pulse' }],
6179
+ * onChange: (option) => fog.play(option)
6180
+ * }])
6181
+ * ```
6182
+ */
6183
+ registerControls(controls) {
6184
+ if (!this.adminPanel) {
6185
+ this._pendingControls.push(...controls);
6186
+ this.log(`Scene controls registered (${controls.length}) - the admin panel takes them when the Pro tier is confirmed`);
6187
+ return;
6188
+ }
6189
+ this.adminPanel.registerControls(controls);
6190
+ }
6191
+ /**
6192
+ * Register picture frames (Venue tier, 2026-11-19) - the same as passing `frames` in the config. Kept whatever the
6193
+ * tier (without Venue `openFrame` still opens a default's link); once Venue is known, a frame registered now gets the
6194
+ * content the last read gave at once. A frame registered again by id
6195
+ * replaces the earlier one; at most 64. Only the shape is checked here - thestatic.tv checks the ids, labels and URLs
6196
+ * when the declaration is uploaded. See `SceneFrame`.
6197
+ *
6198
+ * @example
6199
+ * ```typescript
6200
+ * staticTV.registerFrames([{
6201
+ * id: 'f00', label: 'Ground floor, west wall',
6202
+ * default: { image: 'https://example.com/poster.png' },
6203
+ * onContent: (c) => showPicture(frameEntity, c.image, c.text)
6204
+ * }])
6205
+ * ```
6206
+ */
6207
+ registerFrames(frames) {
6208
+ this.frames.register(frames);
6209
+ }
6210
+ /**
6211
+ * A visitor clicked a frame (2026-11-19): the link opens when it is an https: one - the content's, else the frame's
6212
+ * default's, so a frame works before Venue is on - and, with Venue, the click is counted on thestatic.tv under the
6213
+ * picture the frame shows (signed, fire and forget). Call it from the frame's own pointer handler. Nothing happens
6214
+ * for an id the scene did not declare.
6215
+ */
6216
+ openFrame(id) {
6217
+ this.frames.open(id);
6218
+ }
4714
6219
  /**
4715
6220
  * Close Admin/Guide panels (they share the same screen space)
4716
6221
  * Chat is independent and stays open.
@@ -4782,16 +6287,19 @@ var StaticTVClient = class {
4782
6287
  export {
4783
6288
  AdminPanelUIModule,
4784
6289
  ChatUIModule,
6290
+ FramesModule,
4785
6291
  GuideModule,
4786
6292
  GuideUIModule,
4787
6293
  HeartbeatModule,
4788
6294
  InteractionsModule,
4789
6295
  KEY_TYPE_CHANNEL,
4790
6296
  KEY_TYPE_SCENE,
6297
+ ModerationModule,
4791
6298
  NotificationBanner,
4792
6299
  SessionModule,
4793
6300
  StaticTVClient,
4794
6301
  fetchUserData,
6302
+ getParcelRects,
4795
6303
  getPlayerDisplayName,
4796
6304
  getPlayerPosition,
4797
6305
  getPlayerWallet,