@capytale/iframe-react 1.2.0 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -1,10 +1,10 @@
1
- import { jsx as Q, jsxs as ft, Fragment as mt } from "react/jsx-runtime";
2
- import M, { useCallback as w, useEffect as A, useMemo as U } from "react";
3
- const et = Symbol("Comlink.proxy"), pt = Symbol("Comlink.endpoint"), Ct = Symbol("Comlink.releaseProxy"), q = Symbol("Comlink.finalizer"), I = Symbol("Comlink.thrown"), nt = (t) => typeof t == "object" && t !== null || typeof t == "function", vt = {
1
+ import { jsx as U, jsxs as ft, Fragment as mt } from "react/jsx-runtime";
2
+ import M, { useCallback as b, useEffect as A, useMemo as _ } from "react";
3
+ const et = /* @__PURE__ */ Symbol("Comlink.proxy"), pt = /* @__PURE__ */ Symbol("Comlink.endpoint"), vt = /* @__PURE__ */ Symbol("Comlink.releaseProxy"), q = /* @__PURE__ */ Symbol("Comlink.finalizer"), I = /* @__PURE__ */ Symbol("Comlink.thrown"), nt = (t) => typeof t == "object" && t !== null || typeof t == "function", Ct = {
4
4
  canHandle: (t) => nt(t) && t[et],
5
5
  serialize(t) {
6
6
  const { port1: e, port2: n } = new MessageChannel();
7
- return _(t, e), [n, [n]];
7
+ return Q(t, e), [n, [n]];
8
8
  },
9
9
  deserialize(t) {
10
10
  return t.start(), st(t);
@@ -26,7 +26,7 @@ const et = Symbol("Comlink.proxy"), pt = Symbol("Comlink.endpoint"), Ct = Symbol
26
26
  throw t.isError ? Object.assign(new Error(t.value.message), t.value) : t.value;
27
27
  }
28
28
  }, ot = /* @__PURE__ */ new Map([
29
- ["proxy", vt],
29
+ ["proxy", Ct],
30
30
  ["throw", yt]
31
31
  ]);
32
32
  function St(t, e) {
@@ -35,18 +35,18 @@ function St(t, e) {
35
35
  return !0;
36
36
  return !1;
37
37
  }
38
- function _(t, e = globalThis, n = ["*"]) {
39
- e.addEventListener("message", function s(o) {
38
+ function Q(t, e = globalThis, n = ["*"]) {
39
+ e.addEventListener("message", function i(o) {
40
40
  if (!o || !o.data)
41
41
  return;
42
42
  if (!St(n, o.origin)) {
43
43
  console.warn(`Invalid origin '${o.origin}' for comlink proxy`);
44
44
  return;
45
45
  }
46
- const { id: i, type: u, path: l } = Object.assign({ path: [] }, o.data), f = (o.data.argumentList || []).map(J);
46
+ const { id: s, type: u, path: l } = Object.assign({ path: [] }, o.data), f = (o.data.argumentList || []).map(J);
47
47
  let g;
48
48
  try {
49
- const d = l.slice(0, -1).reduce((C, y) => C[y], t), m = l.reduce((C, y) => C[y], t);
49
+ const d = l.slice(0, -1).reduce((v, y) => v[y], t), m = l.reduce((v, y) => v[y], t);
50
50
  switch (u) {
51
51
  case "GET":
52
52
  g = m;
@@ -59,14 +59,14 @@ function _(t, e = globalThis, n = ["*"]) {
59
59
  break;
60
60
  case "CONSTRUCT":
61
61
  {
62
- const C = new m(...f);
63
- g = lt(C);
62
+ const v = new m(...f);
63
+ g = lt(v);
64
64
  }
65
65
  break;
66
66
  case "ENDPOINT":
67
67
  {
68
- const { port1: C, port2: y } = new MessageChannel();
69
- _(t, y), g = Ft(C, [C]);
68
+ const { port1: v, port2: y } = new MessageChannel();
69
+ Q(t, y), g = Ft(v, [v]);
70
70
  }
71
71
  break;
72
72
  case "RELEASE":
@@ -79,14 +79,14 @@ function _(t, e = globalThis, n = ["*"]) {
79
79
  g = { value: d, [I]: 0 };
80
80
  }
81
81
  Promise.resolve(g).catch((d) => ({ value: d, [I]: 0 })).then((d) => {
82
- const [m, C] = O(d);
83
- e.postMessage(Object.assign(Object.assign({}, m), { id: i }), C), u === "RELEASE" && (e.removeEventListener("message", s), rt(e), q in t && typeof t[q] == "function" && t[q]());
82
+ const [m, v] = $(d);
83
+ e.postMessage(Object.assign(Object.assign({}, m), { id: s }), v), u === "RELEASE" && (e.removeEventListener("message", i), rt(e), q in t && typeof t[q] == "function" && t[q]());
84
84
  }).catch((d) => {
85
- const [m, C] = O({
85
+ const [m, v] = $({
86
86
  value: new TypeError("Unserializable return value"),
87
87
  [I]: 0
88
88
  });
89
- e.postMessage(Object.assign(Object.assign({}, m), { id: i }), C);
89
+ e.postMessage(Object.assign(Object.assign({}, m), { id: s }), v);
90
90
  });
91
91
  }), e.start && e.start();
92
92
  }
@@ -99,15 +99,15 @@ function rt(t) {
99
99
  function st(t, e) {
100
100
  const n = /* @__PURE__ */ new Map();
101
101
  return t.addEventListener("message", function(o) {
102
- const { data: i } = o;
103
- if (!i || !i.id)
102
+ const { data: s } = o;
103
+ if (!s || !s.id)
104
104
  return;
105
- const u = n.get(i.id);
105
+ const u = n.get(s.id);
106
106
  if (u)
107
107
  try {
108
- u(i);
108
+ u(s);
109
109
  } finally {
110
- n.delete(i.id);
110
+ n.delete(s.id);
111
111
  }
112
112
  }), z(t, n, [], e);
113
113
  }
@@ -122,29 +122,29 @@ function it(t) {
122
122
  rt(t);
123
123
  });
124
124
  }
125
- const j = /* @__PURE__ */ new WeakMap(), $ = "FinalizationRegistry" in globalThis && new FinalizationRegistry((t) => {
125
+ const j = /* @__PURE__ */ new WeakMap(), O = "FinalizationRegistry" in globalThis && new FinalizationRegistry((t) => {
126
126
  const e = (j.get(t) || 0) - 1;
127
127
  j.set(t, e), e === 0 && it(t);
128
128
  });
129
- function bt(t, e) {
129
+ function wt(t, e) {
130
130
  const n = (j.get(e) || 0) + 1;
131
- j.set(e, n), $ && $.register(t, e, t);
131
+ j.set(e, n), O && O.register(t, e, t);
132
132
  }
133
- function wt(t) {
134
- $ && $.unregister(t);
133
+ function bt(t) {
134
+ O && O.unregister(t);
135
135
  }
136
- function z(t, e, n = [], s = function() {
136
+ function z(t, e, n = [], i = function() {
137
137
  }) {
138
138
  let o = !1;
139
- const i = new Proxy(s, {
139
+ const s = new Proxy(i, {
140
140
  get(u, l) {
141
- if (G(o), l === Ct)
141
+ if (G(o), l === vt)
142
142
  return () => {
143
- wt(i), it(t), e.clear(), o = !0;
143
+ bt(s), it(t), e.clear(), o = !0;
144
144
  };
145
145
  if (l === "then") {
146
146
  if (n.length === 0)
147
- return { then: () => i };
147
+ return { then: () => s };
148
148
  const f = x(t, e, {
149
149
  type: "GET",
150
150
  path: n.map((g) => g.toString())
@@ -155,7 +155,7 @@ function z(t, e, n = [], s = function() {
155
155
  },
156
156
  set(u, l, f) {
157
157
  G(o);
158
- const [g, d] = O(f);
158
+ const [g, d] = $(f);
159
159
  return x(t, e, {
160
160
  type: "SET",
161
161
  path: [...n, l].map((m) => m.toString()),
@@ -174,7 +174,7 @@ function z(t, e, n = [], s = function() {
174
174
  const [d, m] = Y(f);
175
175
  return x(t, e, {
176
176
  type: "APPLY",
177
- path: n.map((C) => C.toString()),
177
+ path: n.map((v) => v.toString()),
178
178
  argumentList: d
179
179
  }, m).then(J);
180
180
  },
@@ -188,13 +188,13 @@ function z(t, e, n = [], s = function() {
188
188
  }, g).then(J);
189
189
  }
190
190
  });
191
- return bt(i, t), i;
191
+ return wt(s, t), s;
192
192
  }
193
193
  function ht(t) {
194
194
  return Array.prototype.concat.apply([], t);
195
195
  }
196
196
  function Y(t) {
197
- const e = t.map(O);
197
+ const e = t.map($);
198
198
  return [e.map((n) => n[0]), ht(e.map((n) => n[1]))];
199
199
  }
200
200
  const at = /* @__PURE__ */ new WeakMap();
@@ -204,22 +204,22 @@ function Ft(t, e) {
204
204
  function lt(t) {
205
205
  return Object.assign(t, { [et]: !0 });
206
206
  }
207
- function Rt(t, e = globalThis, n = "*") {
207
+ function Et(t, e = globalThis, n = "*") {
208
208
  return {
209
- postMessage: (s, o) => t.postMessage(s, n, o),
209
+ postMessage: (i, o) => t.postMessage(i, n, o),
210
210
  addEventListener: e.addEventListener.bind(e),
211
211
  removeEventListener: e.removeEventListener.bind(e)
212
212
  };
213
213
  }
214
- function O(t) {
214
+ function $(t) {
215
215
  for (const [e, n] of ot)
216
216
  if (n.canHandle(t)) {
217
- const [s, o] = n.serialize(t);
217
+ const [i, o] = n.serialize(t);
218
218
  return [
219
219
  {
220
220
  type: "HANDLER",
221
221
  name: e,
222
- value: s
222
+ value: i
223
223
  },
224
224
  o
225
225
  ];
@@ -240,20 +240,20 @@ function J(t) {
240
240
  return t.value;
241
241
  }
242
242
  }
243
- function x(t, e, n, s) {
243
+ function x(t, e, n, i) {
244
244
  return new Promise((o) => {
245
- const i = Et();
246
- e.set(i, o), t.start && t.start(), t.postMessage(Object.assign({ id: i }, n), s);
245
+ const s = Rt();
246
+ e.set(s, o), t.start && t.start(), t.postMessage(Object.assign({ id: s }, n), i);
247
247
  });
248
248
  }
249
- function Et() {
249
+ function Rt() {
250
250
  return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
251
251
  }
252
252
  function Jt(t, e) {
253
253
  return t.length === 0 ? e : `[${t}] ${e}`;
254
254
  }
255
255
  function Tt(t, e) {
256
- let n = !1, s, o, i;
256
+ let n = !1, i, o, s;
257
257
  function u(d) {
258
258
  return Jt(t, d);
259
259
  }
@@ -269,37 +269,37 @@ function Tt(t, e) {
269
269
  done() {
270
270
  return Promise.resolve();
271
271
  },
272
- provide(d, m, C) {
272
+ provide(d, m, v) {
273
273
  return Promise.resolve();
274
274
  }
275
275
  };
276
276
  else {
277
- const d = Rt(window.parent, void 0, e);
278
- _({
277
+ const d = Et(window.parent, void 0, e);
278
+ Q({
279
279
  declare(m) {
280
- if (s == null) throw new Error(u("No handler for declare"));
281
- s(m);
280
+ if (i == null) throw new Error(u("No handler for declare"));
281
+ i(m);
282
282
  },
283
283
  done() {
284
284
  if (o == null) throw new Error(u("No handler for done"));
285
285
  o();
286
286
  },
287
- provide(m, C, y) {
288
- if (i == null) throw new Error(u("No handler for provide"));
289
- i(m, C, y);
287
+ provide(m, v, y) {
288
+ if (s == null) throw new Error(u("No handler for provide"));
289
+ s(m, v, y);
290
290
  }
291
291
  }, d), l = st(d), f = !0;
292
292
  }
293
293
  const g = () => {
294
294
  if (!n) {
295
- if (s == null || o == null || i == null) return;
295
+ if (i == null || o == null || s == null) return;
296
296
  n = !0, l.ready();
297
297
  }
298
298
  };
299
299
  return {
300
300
  declare: (d) => l.declare(d),
301
301
  done: () => l.done(),
302
- provide: (d, m, C) => l.provide(d, m, lt(C)),
302
+ provide: (d, m, v) => l.provide(d, m, lt(v)),
303
303
  get name() {
304
304
  return t;
305
305
  },
@@ -307,30 +307,30 @@ function Tt(t, e) {
307
307
  return f;
308
308
  },
309
309
  set onDeclare(d) {
310
- s = d, g();
310
+ i = d, g();
311
311
  },
312
312
  set onDone(d) {
313
313
  o = d, g();
314
314
  },
315
315
  set onProvide(d) {
316
- i = d, g();
316
+ s = d, g();
317
317
  }
318
318
  };
319
319
  }
320
320
  function kt(t) {
321
321
  return function(e) {
322
- let n, s = !1, o = !1, i, u, l = !1, f = !1, g, d, m, C;
322
+ let n, i = !1, o = !1, s, u, l = !1, f = !1, g, d, m, v;
323
323
  function y() {
324
- if (i != null && i !== 0 && u != null)
324
+ if (s != null && s !== 0 && u != null)
325
325
  return u;
326
326
  }
327
- function R(a) {
328
- if (i != null && u != null && !(a > i))
327
+ function E(a) {
328
+ if (s != null && u != null && !(a > s))
329
329
  return u;
330
330
  }
331
331
  function h() {
332
332
  return m ?? (f ? m = Promise.resolve() : m = new Promise((a, c) => {
333
- C = a;
333
+ v = a;
334
334
  }));
335
335
  }
336
336
  function T() {
@@ -339,12 +339,12 @@ function kt(t) {
339
339
  return e;
340
340
  },
341
341
  get version() {
342
- return i;
342
+ return s;
343
343
  },
344
344
  get i() {
345
345
  return y();
346
346
  },
347
- v: (a) => R(a)
347
+ v: (a) => E(a)
348
348
  }), g;
349
349
  }
350
350
  function L() {
@@ -353,22 +353,22 @@ function kt(t) {
353
353
  return e;
354
354
  },
355
355
  get version() {
356
- return f ? i : void 0;
356
+ return f ? s : void 0;
357
357
  },
358
358
  get i() {
359
359
  return f ? y() : void 0;
360
360
  },
361
- v: (a) => f ? R(a) : void 0,
361
+ v: (a) => f ? E(a) : void 0,
362
362
  get promise() {
363
- return i === 0 ? Promise.reject(t("Remote interface not provided")) : h().then(() => {
364
- if (i === 0) throw new Error(t("Remote interface not provided"));
363
+ return s === 0 ? Promise.reject(t("Remote interface not provided")) : h().then(() => {
364
+ if (s === 0) throw new Error(t("Remote interface not provided"));
365
365
  return T();
366
366
  });
367
367
  }
368
368
  }), d;
369
369
  }
370
- function E() {
371
- C != null && (C(), C = void 0);
370
+ function R() {
371
+ v != null && (v(), v = void 0);
372
372
  }
373
373
  return {
374
374
  get name() {
@@ -383,11 +383,11 @@ function kt(t) {
383
383
  n = a;
384
384
  },
385
385
  get localVersionSent() {
386
- return s;
386
+ return i;
387
387
  },
388
388
  set localVersionSent(a) {
389
- if (!a && s) throw new Error(t("Local version already notified"));
390
- s = a, a && n === 0 && (o = !0);
389
+ if (!a && i) throw new Error(t("Local version already notified"));
390
+ i = a, a && n === 0 && (o = !0);
391
391
  },
392
392
  get localInterfaceSent() {
393
393
  return o;
@@ -398,19 +398,19 @@ function kt(t) {
398
398
  o = a;
399
399
  },
400
400
  get remoteVersion() {
401
- if (i != null)
402
- return i;
401
+ if (s != null)
402
+ return s;
403
403
  },
404
404
  set remoteVersion(a) {
405
- if (i != null && i !== a) throw new Error(t("A different remote version is already set for " + e + `(${i} -> ${a})`));
406
- i = a, a === 0 && (l = !0);
405
+ if (s != null && s !== a) throw new Error(t("A different remote version is already set for " + e + `(${s} -> ${a})`));
406
+ s = a, a === 0 && (l = !0);
407
407
  },
408
408
  get remoteVersionReceived() {
409
- return i != null;
409
+ return s != null;
410
410
  },
411
411
  setRemoteInterface: (a) => {
412
- if (i == null) throw new Error(t("Remote version not set"));
413
- if (i === 0) {
412
+ if (s == null) throw new Error(t("Remote version not set"));
413
+ if (s === 0) {
414
414
  console.warn(t("Remote version is 0, remote interface is ignored."));
415
415
  return;
416
416
  }
@@ -431,7 +431,7 @@ function kt(t) {
431
431
  if (!f) {
432
432
  if (!l) throw new Error(t("Remote interface not provided."));
433
433
  if (!o) throw new Error(t("Local interface not sent"));
434
- f = !0, E();
434
+ f = !0, R();
435
435
  }
436
436
  },
437
437
  getRemote: () => T(),
@@ -443,8 +443,8 @@ function kt(t) {
443
443
  };
444
444
  }
445
445
  function xt(t) {
446
- return function(e, n, s, o) {
447
- let i = s, u = !1, l = !1;
446
+ return function(e, n, i, o) {
447
+ let s = i, u = !1, l = !1;
448
448
  function f() {
449
449
  return e.every((g) => g.remoteVersionReceived && g.localVersionSent) && n.every((g) => g.remoteVersionReceived);
450
450
  }
@@ -475,24 +475,24 @@ function xt(t) {
475
475
  if (!f())
476
476
  throw new Error(t("Factory is not ready"));
477
477
  let g;
478
- o ? g = e.map((C) => C.getRemote()) : g = e[0].getRemote();
478
+ o ? g = e.map((v) => v.getRemote()) : g = e[0].getRemote();
479
479
  let d;
480
- const m = n.length > 0 ? n.map((C) => C.getRemote()) : null;
480
+ const m = n.length > 0 ? n.map((v) => v.getRemote()) : null;
481
481
  try {
482
- d = m == null ? i(g) : i(g, m);
483
- } catch (C) {
484
- throw new Error(t("error in factory:"), { cause: C });
482
+ d = m == null ? s(g) : s(g, m);
483
+ } catch (v) {
484
+ throw new Error(t("error in factory:"), { cause: v });
485
485
  }
486
486
  if (o || (d = [d]), d.length != e.length)
487
487
  throw new Error(t("Invalid factory result"));
488
- return u = !0, i = null, d;
488
+ return u = !0, s = null, d;
489
489
  }
490
490
  };
491
491
  };
492
492
  }
493
493
  function Lt(t) {
494
- return function(e, n, s, o) {
495
- let i = n, u = !1;
494
+ return function(e, n, i, o) {
495
+ let s = n, u = !1;
496
496
  function l() {
497
497
  return e.every((f) => f.isActivated);
498
498
  }
@@ -511,10 +511,10 @@ function Lt(t) {
511
511
  const d = new Error(t(u ? "callback already invoked" : "callback parameters are not ready"));
512
512
  throw o?.[1](d), d;
513
513
  }
514
- const f = s ? e.map((d) => d.getRemote()) : e[0].getRemote();
514
+ const f = i ? e.map((d) => d.getRemote()) : e[0].getRemote();
515
515
  let g;
516
516
  try {
517
- g = i(f);
517
+ g = s(f);
518
518
  } catch (d) {
519
519
  o == null ? console.error(t("error in callback:"), d) : o[1](d);
520
520
  } finally {
@@ -532,61 +532,61 @@ function Mt(t) {
532
532
  function e(a) {
533
533
  return ct(t.name, a);
534
534
  }
535
- const n = Lt(e), s = kt(e), o = xt(e), i = {}, u = [];
535
+ const n = Lt(e), i = kt(e), o = xt(e), s = {}, u = [];
536
536
  let l = [], f;
537
537
  const g = () => (f == null ? f = 0 : f++, f);
538
538
  function d(a) {
539
- let c = i[a];
540
- return c == null && (c = s(a), c.localVersion == null && (h && (c.localVersion = 0), T && (c.localVersionSent = !0)), c.remoteVersion == null && L && (c.remoteVersion = 0), i[a] = c), c;
539
+ let c = s[a];
540
+ return c == null && (c = i(a), c.localVersion == null && (h && (c.localVersion = 0), T && (c.localVersionSent = !0)), c.remoteVersion == null && L && (c.remoteVersion = 0), s[a] = c), c;
541
541
  }
542
542
  function m(a) {
543
543
  return a.map(d);
544
544
  }
545
- function C(...a) {
545
+ function v(...a) {
546
546
  const c = g(), p = Array(c).fill(!1);
547
- a.forEach((v) => {
548
- v.forEach((S) => {
547
+ a.forEach((C) => {
548
+ C.forEach((S) => {
549
549
  S.depGroup != null && (p[S.depGroup] = !0), S.depGroup = c;
550
550
  });
551
- }), Object.values(i).forEach((v) => {
552
- v.depGroup != null && v.depGroup !== c && p[v.depGroup] && (v.depGroup = c);
551
+ }), Object.values(s).forEach((C) => {
552
+ C.depGroup != null && C.depGroup !== c && p[C.depGroup] && (C.depGroup = c);
553
553
  });
554
554
  }
555
555
  t.onDeclare = (a) => {
556
556
  const c = m(a.map((p) => p.name));
557
557
  for (let p = 0; p < a.length; p++)
558
558
  a[p].version != null && (c[p].remoteVersion = a[p].version);
559
- C(c), E();
559
+ v(c), R();
560
560
  }, t.onDone = () => {
561
- L || (L = !0, Object.values(i).forEach((a) => {
561
+ L || (L = !0, Object.values(s).forEach((a) => {
562
562
  a.remoteVersion == null && (a.remoteVersion = 0);
563
- }), E());
563
+ }), R());
564
564
  }, t.onProvide = (a, c, p) => {
565
- let v = i[a];
566
- if (v == null)
565
+ let C = s[a];
566
+ if (C == null)
567
567
  throw new Error(e(`Contract not declared : ${a}`));
568
- if (v.remoteVersion != c)
569
- throw new Error(e(`Remote declared version ${v.remoteVersion} of contract "${a}" but provided version ${c}.`));
570
- if (v.remoteInterfaceReceived)
568
+ if (C.remoteVersion != c)
569
+ throw new Error(e(`Remote declared version ${C.remoteVersion} of contract "${a}" but provided version ${c}.`));
570
+ if (C.remoteInterfaceReceived)
571
571
  throw new Error(e(`Remote contract "${a}" is already provided.`));
572
- v.setRemoteInterface(p), E();
572
+ C.setRemoteInterface(p), R();
573
573
  };
574
- let y = !1, R = !1, h = !1, T = !1, L = !1;
575
- async function E() {
576
- if (R = !0, !y) {
577
- for (y = !0; R; ) {
578
- if (R = !1, t.isReady) {
574
+ let y = !1, E = !1, h = !1, T = !1, L = !1;
575
+ async function R() {
576
+ if (E = !0, !y) {
577
+ for (y = !0; E; ) {
578
+ if (E = !1, t.isReady) {
579
579
  const a = u.filter((c) => !c.isDeclared);
580
580
  if (a.length > 0)
581
581
  for (const c of a) {
582
582
  const p = Array(c.args.length + c.deps.length);
583
- c.args.forEach((v, S) => p[S] = v), c.deps.forEach((v, S) => p[S + c.args.length] = v), await t.declare(p.map((v) => ({ name: v.name, version: v.localVersion }))), p.forEach((v) => {
584
- v.localVersion != null && (v.localVersionSent = !0);
583
+ c.args.forEach((C, S) => p[S] = C), c.deps.forEach((C, S) => p[S + c.args.length] = C), await t.declare(p.map((C) => ({ name: C.name, version: C.localVersion }))), p.forEach((C) => {
584
+ C.localVersion != null && (C.localVersionSent = !0);
585
585
  }), c.isDeclared = !0;
586
586
  }
587
587
  }
588
588
  if (t.isReady && h && u.every((a) => a.isDeclared)) {
589
- const a = Object.values(i).filter((c) => !c.localVersionSent && c.localVersion != null);
589
+ const a = Object.values(s).filter((c) => !c.localVersionSent && c.localVersion != null);
590
590
  if (a.length > 0)
591
591
  for (const c of a)
592
592
  await t.declare([{ name: c.name, version: c.localVersion }]), c.localVersionSent = !0;
@@ -597,21 +597,21 @@ function Mt(t) {
597
597
  if (a.length > 0)
598
598
  for (const c of a) {
599
599
  const p = c.invoke();
600
- for (let v = 0; v < c.args.length; v++) {
601
- const S = c.args[v];
602
- await t.provide(S.name, S.localVersion, p[v]), S.localInterfaceSent = !0;
600
+ for (let C = 0; C < c.args.length; C++) {
601
+ const S = c.args[C];
602
+ await t.provide(S.name, S.localVersion, p[C]), S.localInterfaceSent = !0;
603
603
  }
604
604
  }
605
605
  }
606
606
  if (f != null) {
607
607
  const a = Array(f + 1).fill(null);
608
- for (const c in i) {
609
- const p = i[c];
608
+ for (const c in s) {
609
+ const p = s[c];
610
610
  p.depGroup != null && (p.isActivable ? a[p.depGroup] == null && !p.isActivated && (a[p.depGroup] = !0) : a[p.depGroup] = !1);
611
611
  }
612
612
  if (a.some((c) => c === !0))
613
- for (const c in i) {
614
- const p = i[c];
613
+ for (const c in s) {
614
+ const p = s[c];
615
615
  p.depGroup != null && a[p.depGroup] && p.activate();
616
616
  }
617
617
  }
@@ -631,7 +631,7 @@ function Mt(t) {
631
631
  get(a) {
632
632
  return d(a);
633
633
  },
634
- declareFactory: (a, c, p, v) => {
634
+ declareFactory: (a, c, p, C) => {
635
635
  if (h) throw new Error(e("Cannot declare a factory after done has been set to true."));
636
636
  const S = m(a.map((F) => F.name));
637
637
  {
@@ -642,13 +642,13 @@ function Mt(t) {
642
642
  for (let F = 0; F < a.length; F++)
643
643
  S[F].localVersion = a[F].version;
644
644
  const k = m(c);
645
- C(S, k);
646
- const gt = o(S, k, p, v);
647
- u.push(gt), E();
645
+ v(S, k);
646
+ const gt = o(S, k, p, C);
647
+ u.push(gt), R();
648
648
  },
649
- declareCallback(a, c, p, v) {
650
- const S = m(a), k = n(S, c, p, v);
651
- !y && l.length === 0 && k.isReady ? k.invoke() : (l.push(k), E());
649
+ declareCallback(a, c, p, C) {
650
+ const S = m(a), k = n(S, c, p, C);
651
+ !y && l.length === 0 && k.isReady ? k.invoke() : (l.push(k), R());
652
652
  },
653
653
  get done() {
654
654
  return h;
@@ -657,53 +657,53 @@ function Mt(t) {
657
657
  if (h) {
658
658
  if (!a) throw new Error(e("Cannot set done to false after it has been set to true."));
659
659
  } else
660
- a && (h = !0, Object.values(i).forEach((c) => {
660
+ a && (h = !0, Object.values(s).forEach((c) => {
661
661
  c.localVersion == null && (c.localVersion = 0);
662
- }), E());
662
+ }), R());
663
663
  }
664
664
  };
665
665
  }
666
666
  const Gt = /^\d+$/;
667
667
  function Dt(t) {
668
- const [e, n, s] = t.split(":", 3);
669
- if (n == null || s != null || !Gt.test(n)) return null;
668
+ const [e, n, i] = t.split(":", 3);
669
+ if (n == null || i != null || !Gt.test(n)) return null;
670
670
  const o = parseInt(n);
671
671
  return isNaN(o) || o === 0 ? null : { name: e, version: o };
672
672
  }
673
673
  function Pt(t) {
674
674
  const e = Mt(t);
675
- function n(s) {
676
- return ct(t.name, s);
675
+ function n(i) {
676
+ return ct(t.name, i);
677
677
  }
678
678
  return {
679
- plug(s, o, i = void 0) {
679
+ plug(i, o, s = void 0) {
680
680
  if (e.done) throw new Error(n("Cannot plug after plugsDone."));
681
- i == null && (i = o, o = []);
681
+ s == null && (s = o, o = []);
682
682
  let u = !0;
683
- Array.isArray(s) || (s = [s], u = !1);
684
- const l = s.map((f) => {
683
+ Array.isArray(i) || (i = [i], u = !1);
684
+ const l = i.map((f) => {
685
685
  const g = Dt(f);
686
686
  if (g == null)
687
687
  throw new Error(n("Invalid contract id : " + f));
688
688
  return g;
689
689
  });
690
- e.declareFactory(l, o, i, u);
690
+ e.declareFactory(l, o, s, u);
691
691
  },
692
692
  plugsDone() {
693
693
  e.done = !0;
694
694
  },
695
- use(s, o) {
696
- let i = !0;
697
- Array.isArray(s) || (s = [s], i = !1), e.declareCallback(s, o, i);
695
+ use(i, o) {
696
+ let s = !0;
697
+ Array.isArray(i) || (i = [i], s = !1), e.declareCallback(i, o, s);
698
698
  },
699
- exec(s, o) {
700
- let i = !0;
701
- return Array.isArray(s) || (s = [s], i = !1), new Promise((...u) => {
702
- e.declareCallback(s, o, i, u);
699
+ exec(i, o) {
700
+ let s = !0;
701
+ return Array.isArray(i) || (i = [i], s = !1), new Promise((...u) => {
702
+ e.declareCallback(i, o, s, u);
703
703
  });
704
704
  },
705
- get(s) {
706
- return s.map((o) => e.get(o).getLazyRemote());
705
+ get(i) {
706
+ return i.map((o) => e.get(o).getLazyRemote());
707
707
  }
708
708
  };
709
709
  }
@@ -715,16 +715,16 @@ function Vt(t) {
715
715
  console.log(`[${ut}@1.0.12] loaded`);
716
716
  const K = (t) => {
717
717
  let e;
718
- const n = /* @__PURE__ */ new Set(), s = (g, d) => {
718
+ const n = /* @__PURE__ */ new Set(), i = (g, d) => {
719
719
  const m = typeof g == "function" ? g(e) : g;
720
720
  if (!Object.is(m, e)) {
721
- const C = e;
722
- e = d ?? (typeof m != "object" || m === null) ? m : Object.assign({}, e, m), n.forEach((y) => y(e, C));
721
+ const v = e;
722
+ e = d ?? (typeof m != "object" || m === null) ? m : Object.assign({}, e, m), n.forEach((y) => y(e, v));
723
723
  }
724
- }, o = () => e, l = { setState: s, getState: o, getInitialState: () => f, subscribe: (g) => (n.add(g), () => n.delete(g)) }, f = e = t(s, o, l);
724
+ }, o = () => e, l = { setState: i, getState: o, getInitialState: () => f, subscribe: (g) => (n.add(g), () => n.delete(g)) }, f = e = t(i, o, l);
725
725
  return l;
726
- }, It = (t) => t ? K(t) : K, jt = (t) => t;
727
- function $t(t, e = jt) {
726
+ }, It = ((t) => t ? K(t) : K), jt = (t) => t;
727
+ function Ot(t, e = jt) {
728
728
  const n = M.useSyncExternalStore(
729
729
  t.subscribe,
730
730
  M.useCallback(() => e(t.getState()), [t, e]),
@@ -733,26 +733,26 @@ function $t(t, e = jt) {
733
733
  return M.useDebugValue(n), n;
734
734
  }
735
735
  const X = (t) => {
736
- const e = It(t), n = (s) => $t(e, s);
736
+ const e = It(t), n = (i) => Ot(e, i);
737
737
  return Object.assign(n, e), n;
738
- }, dt = (t) => t ? X(t) : X, Ot = (t) => (e, n, s) => {
739
- const o = s.subscribe;
740
- return s.subscribe = (u, l, f) => {
738
+ }, dt = ((t) => t ? X(t) : X), $t = (t) => (e, n, i) => {
739
+ const o = i.subscribe;
740
+ return i.subscribe = ((u, l, f) => {
741
741
  let g = u;
742
742
  if (l) {
743
743
  const d = f?.equalityFn || Object.is;
744
- let m = u(s.getState());
745
- g = (C) => {
746
- const y = u(C);
744
+ let m = u(i.getState());
745
+ g = (v) => {
746
+ const y = u(v);
747
747
  if (!d(m, y)) {
748
- const R = m;
749
- l(m = y, R);
748
+ const E = m;
749
+ l(m = y, E);
750
750
  }
751
751
  }, f?.fireImmediately && l(m, m);
752
752
  }
753
753
  return o(g);
754
- }, t(e, n, s);
755
- }, Nt = Ot, r = dt()(
754
+ }), t(e, n, i);
755
+ }, Nt = $t, r = dt()(
756
756
  Nt((t) => ({
757
757
  ready: !1,
758
758
  workflow: "current",
@@ -1068,17 +1068,17 @@ const qt = [
1068
1068
  activityContent: t,
1069
1069
  assignmentContent: e,
1070
1070
  activityBinaryData: n,
1071
- assignmentBinaryData: s
1071
+ assignmentBinaryData: i
1072
1072
  }) => {
1073
1073
  r.setState({
1074
1074
  loadedJsonActivityContent: t,
1075
1075
  loadedJsonAssignmentContent: e,
1076
1076
  loadedJsonActivityBinaryData: n,
1077
- loadedJsonAssignmentBinaryData: s
1077
+ loadedJsonAssignmentBinaryData: i
1078
1078
  });
1079
1079
  },
1080
- getActivityContentAndData: () => (console.log("[React bindings] Getting activity content and data"), r.getState().getJsonActivitySplitContentFunction()),
1081
- getAssignmentContentAndData: () => (console.log("[React bindings] Getting assignment content and data"), r.getState().getJsonAssignmentSplitContentFunction())
1080
+ getActivityContentAndData: () => r.getState().getJsonActivitySplitContentFunction(),
1081
+ getAssignmentContentAndData: () => r.getState().getJsonAssignmentSplitContentFunction()
1082
1082
  },
1083
1083
  "meta-player-anti-cheat:1": {
1084
1084
  lock: () => {
@@ -1088,7 +1088,7 @@ const qt = [
1088
1088
  },
1089
1089
  "meta-player-ui:1": {
1090
1090
  executeAction(t) {
1091
- if (console.log("[React bindings] Executing action:", t), t.startsWith("qa")) {
1091
+ if (t.startsWith("qa")) {
1092
1092
  const n = r.getState().quickActions[t];
1093
1093
  n ? n() : console.error(`[React bindings] Quick action not found: ${t}`);
1094
1094
  } else {
@@ -1098,11 +1098,11 @@ const qt = [
1098
1098
  },
1099
1099
  executeFileUpload(t, e) {
1100
1100
  if (t.startsWith("qa")) {
1101
- const s = r.getState().quickActions[t];
1102
- s ? s(e) : console.error(`[React bindings] Quick action not found: ${t}`);
1101
+ const i = r.getState().quickActions[t];
1102
+ i ? i(e) : console.error(`[React bindings] Quick action not found: ${t}`);
1103
1103
  } else {
1104
- const s = r.getState().sidebarActions[t];
1105
- s ? s(e) : console.error(`[React bindings] Sidebar action not found: ${t}`);
1104
+ const i = r.getState().sidebarActions[t];
1105
+ i ? i(e) : console.error(`[React bindings] Sidebar action not found: ${t}`);
1106
1106
  }
1107
1107
  },
1108
1108
  updateSettings(t) {
@@ -1144,61 +1144,46 @@ const qt = [
1144
1144
  return n(t, e);
1145
1145
  }
1146
1146
  }
1147
- }, b = Vt();
1147
+ }, w = Vt();
1148
1148
  function Wt(t) {
1149
- if (console.log("[React bindings] Contracts to plug:", t), Z) {
1150
- console.warn(
1151
- "[React bindings] Contracts have already been plugged. Skipping."
1152
- );
1153
- return;
1154
- }
1155
- Z = !0;
1156
- for (const e of t) {
1157
- if (!qt.includes(e)) {
1158
- console.warn(
1159
- `[React bindings] Contract ${e} is not implemented in Capytale. Skipping plug.`
1160
- );
1161
- continue;
1162
- }
1163
- if (!(e in tt)) {
1164
- console.warn(
1165
- `[React bindings] Contract handler for ${e} is not defined. Skipping plug.`
1166
- );
1167
- continue;
1168
- }
1169
- const n = tt[e];
1170
- console.log(`[React bindings] Plugging contract ${e}...`), b.plug([e], ([]) => (console.log(`[React bindings] Contract ${e} plugged.`), [n]));
1171
- }
1172
- b.plugsDone();
1173
- for (const e of [
1174
- "simple-content(text):1",
1175
- "simple-content(json):1",
1176
- "simple-binary-data(text):1",
1177
- "simple-content-eval(text):1",
1178
- "simple-content-eval(json):1",
1179
- "simple-content-eval(json):2",
1180
- "simple-content-eval(text):2",
1181
- "separate-contents(json):1",
1182
- "separate-dual-contents(json):1"
1183
- ])
1184
- if (console.log(
1185
- `[React bindings] Contract ${e} is being subscribed to content changes.`
1186
- ), t.includes(e)) {
1187
- console.log(
1188
- `[React bindings] Subscribing to content changes for contract ${e}`
1189
- );
1190
- const n = e.split(":")[0];
1191
- b.use([n], ([s]) => {
1192
- r.subscribe(
1193
- (o) => o.isDirtyCount,
1194
- () => {
1195
- s.i?.contentChanged(), console.log(
1196
- `[React bindings] Content changed for contract ${n}`
1197
- );
1198
- }
1149
+ if (!Z) {
1150
+ Z = !0;
1151
+ for (const e of t) {
1152
+ if (!qt.includes(e))
1153
+ continue;
1154
+ if (!(e in tt)) {
1155
+ console.warn(
1156
+ `[React bindings] Contract handler for ${e} is not defined. Skipping plug.`
1199
1157
  );
1200
- });
1158
+ continue;
1159
+ }
1160
+ const n = tt[e];
1161
+ w.plug([e], ([]) => [n]);
1201
1162
  }
1163
+ w.plugsDone();
1164
+ for (const e of [
1165
+ "simple-content(text):1",
1166
+ "simple-content(json):1",
1167
+ "simple-binary-data(text):1",
1168
+ "simple-content-eval(text):1",
1169
+ "simple-content-eval(json):1",
1170
+ "simple-content-eval(json):2",
1171
+ "simple-content-eval(text):2",
1172
+ "separate-contents(json):1",
1173
+ "separate-dual-contents(json):1"
1174
+ ])
1175
+ if (t.includes(e)) {
1176
+ const n = e.split(":")[0];
1177
+ w.use([n], ([i]) => {
1178
+ r.subscribe(
1179
+ (o) => o.isDirtyCount,
1180
+ () => {
1181
+ i.i?.contentChanged();
1182
+ }
1183
+ );
1184
+ });
1185
+ }
1186
+ }
1202
1187
  }
1203
1188
  const re = () => r((t) => {
1204
1189
  if (t.mode === null)
@@ -1214,26 +1199,26 @@ const re = () => r((t) => {
1214
1199
  if (t.theme === null)
1215
1200
  throw new Error("Theme is not set. Have you used contract 'theme'?");
1216
1201
  return t.theme;
1217
- }), ae = () => r((t) => t.incSaveCount), le = () => r((t) => t.incDirtyCount), ce = () => r((t) => t.loadedTextContent), ue = () => r((t) => t.loadedJsonContent), de = () => r((t) => t.loadedJsonActivityContent), ge = () => r((t) => t.loadedJsonAssignmentContent), fe = () => r((t) => t.loadedJsonActivityBinaryData), me = () => r((t) => t.loadedJsonAssignmentBinaryData), pe = () => w(() => r.getState().loadedTextContent, []), Ce = () => w(() => r.getState().loadedJsonContent, []), ve = () => w(() => r.getState().loadedJsonActivityContent, []), ye = () => w(() => r.getState().loadedJsonAssignmentContent, []), Se = () => w(
1202
+ }), ae = () => r((t) => t.incSaveCount), le = () => r((t) => t.incDirtyCount), ce = () => r((t) => t.loadedTextContent), ue = () => r((t) => t.loadedJsonContent), de = () => r((t) => t.loadedJsonActivityContent), ge = () => r((t) => t.loadedJsonAssignmentContent), fe = () => r((t) => t.loadedJsonActivityBinaryData), me = () => r((t) => t.loadedJsonAssignmentBinaryData), pe = () => b(() => r.getState().loadedTextContent, []), ve = () => b(() => r.getState().loadedJsonContent, []), Ce = () => b(() => r.getState().loadedJsonActivityContent, []), ye = () => b(() => r.getState().loadedJsonAssignmentContent, []), Se = () => b(
1218
1203
  () => ({
1219
1204
  content: r.getState().loadedJsonActivityContent,
1220
1205
  binaryData: r.getState().loadedJsonActivityBinaryData
1221
1206
  }),
1222
1207
  []
1223
- ), Ae = () => w(
1208
+ ), Ae = () => b(
1224
1209
  () => ({
1225
1210
  content: r.getState().loadedJsonAssignmentContent,
1226
1211
  binaryData: r.getState().loadedJsonAssignmentBinaryData
1227
1212
  }),
1228
1213
  []
1229
- ), be = (t) => {
1214
+ ), we = (t) => {
1230
1215
  const e = r(
1231
1216
  (n) => n.setGetTextContentFunction
1232
1217
  );
1233
1218
  A(() => {
1234
1219
  e(t);
1235
1220
  }, [t, e]);
1236
- }, we = (t) => {
1221
+ }, be = (t) => {
1237
1222
  const e = r(
1238
1223
  (n) => n.setGetJsonContentFunction
1239
1224
  );
@@ -1254,14 +1239,14 @@ const re = () => r((t) => {
1254
1239
  A(() => {
1255
1240
  e(t);
1256
1241
  }, [t, e]);
1257
- }, Re = (t) => {
1242
+ }, Ee = (t) => {
1258
1243
  const e = r(
1259
1244
  (n) => n.setGetJsonActivitySplitContentFunction
1260
1245
  );
1261
1246
  A(() => {
1262
1247
  e(t);
1263
1248
  }, [t, e]);
1264
- }, Ee = (t) => {
1249
+ }, Re = (t) => {
1265
1250
  const e = r(
1266
1251
  (n) => n.setGetJsonAssignmentSplitContentFunction
1267
1252
  );
@@ -1274,7 +1259,7 @@ const re = () => r((t) => {
1274
1259
  e > 0 && t();
1275
1260
  }, [e]);
1276
1261
  }, Te = () => (t, e) => {
1277
- b.use(["meta-player-ui"], ([n]) => {
1262
+ w.use(["meta-player-ui"], ([n]) => {
1278
1263
  if (n.version === 0) {
1279
1264
  console.error(
1280
1265
  "[React bindings] Le MétaPlayer ne supporte pas le contrat meta-player-ui"
@@ -1284,7 +1269,7 @@ const re = () => r((t) => {
1284
1269
  n.i?.previewTextFile(t, e);
1285
1270
  });
1286
1271
  }, ke = () => (t, e) => {
1287
- b.use(["meta-player-ui"], ([n]) => {
1272
+ w.use(["meta-player-ui"], ([n]) => {
1288
1273
  if (n.version === 0) {
1289
1274
  console.error(
1290
1275
  "[React bindings] Le MétaPlayer ne supporte pas le contrat meta-player-ui"
@@ -1296,13 +1281,13 @@ const re = () => r((t) => {
1296
1281
  };
1297
1282
  let D = 0, B = 0;
1298
1283
  const xe = (t, e) => {
1299
- const n = U(t, e), s = r((o) => o.setSidebarActions);
1284
+ const n = _(t, e), i = r((o) => o.setSidebarActions);
1300
1285
  A(() => (D++, D > 1 && console.error(
1301
1286
  "[React bindings] Capytale iframe React: Multiple sidebar actions registered: ",
1302
1287
  D
1303
1288
  ), () => {
1304
1289
  D--;
1305
- }), []), A(() => (b.use(["meta-player-ui"], ([o]) => {
1290
+ }), []), A(() => (w.use(["meta-player-ui"], ([o]) => {
1306
1291
  if (o.version === 0) {
1307
1292
  console.error(
1308
1293
  "[React bindings] Le MétaPlayer ne supporte pas le contrat meta-player-ui"
@@ -1310,7 +1295,7 @@ const xe = (t, e) => {
1310
1295
  return;
1311
1296
  }
1312
1297
  B++;
1313
- const i = n.map((l, f) => ({
1298
+ const s = n.map((l, f) => ({
1314
1299
  type: l.type,
1315
1300
  title: l.title,
1316
1301
  icon: l.icon,
@@ -1319,9 +1304,9 @@ const xe = (t, e) => {
1319
1304
  })), u = {};
1320
1305
  n.forEach((l, f) => {
1321
1306
  u[`sa-${B}-${f}`] = l.action;
1322
- }), o.i?.setSidebarActionButtons(i), s(u);
1307
+ }), o.i?.setSidebarActionButtons(s), i(u);
1323
1308
  }), () => {
1324
- s({}), b.use(["meta-player-ui"], ([o]) => {
1309
+ i({}), w.use(["meta-player-ui"], ([o]) => {
1325
1310
  if (o.version === 0) {
1326
1311
  console.error(
1327
1312
  "[React bindings] Le MétaPlayer ne supporte pas le contrat meta-player-ui"
@@ -1334,13 +1319,13 @@ const xe = (t, e) => {
1334
1319
  };
1335
1320
  let P = 0, H = 0;
1336
1321
  const Le = (t, e) => {
1337
- const n = U(t, e), s = r((o) => o.setQuickActions);
1322
+ const n = _(t, e), i = r((o) => o.setQuickActions);
1338
1323
  A(() => (P++, P > 1 && console.error(
1339
1324
  "[React bindings] Capytale iframe React: Multiple quick actions registered: ",
1340
1325
  P
1341
1326
  ), () => {
1342
1327
  P--;
1343
- }), []), A(() => (b.use(["meta-player-ui"], ([o]) => {
1328
+ }), []), A(() => (w.use(["meta-player-ui"], ([o]) => {
1344
1329
  if (o.version === 0) {
1345
1330
  console.error(
1346
1331
  "[React bindings] Le MétaPlayer ne supporte pas le contrat meta-player-ui"
@@ -1348,7 +1333,7 @@ const Le = (t, e) => {
1348
1333
  return;
1349
1334
  }
1350
1335
  H++;
1351
- const i = n.map((l, f) => ({
1336
+ const s = n.map((l, f) => ({
1352
1337
  type: l.type,
1353
1338
  title: l.title,
1354
1339
  icon: l.icon,
@@ -1357,9 +1342,9 @@ const Le = (t, e) => {
1357
1342
  })), u = {};
1358
1343
  n.forEach((l, f) => {
1359
1344
  u[`qa-${H}-${f}`] = l.action;
1360
- }), o.i?.setQuickActionButtons(i), s(u);
1345
+ }), o.i?.setQuickActionButtons(s), i(u);
1361
1346
  }), () => {
1362
- s({}), b.use(["meta-player-ui"], ([o]) => {
1347
+ i({}), w.use(["meta-player-ui"], ([o]) => {
1363
1348
  if (o.version === 0) {
1364
1349
  console.error(
1365
1350
  "[React bindings] Le MétaPlayer ne supporte pas le contrat meta-player-ui"
@@ -1372,31 +1357,28 @@ const Le = (t, e) => {
1372
1357
  };
1373
1358
  let V = 0;
1374
1359
  const Bt = (t, e, n) => {
1375
- const s = U(t, n), o = r(
1376
- (i) => i.setActivitySettingsCallback
1360
+ const i = _(t, n), o = r(
1361
+ (s) => s.setActivitySettingsCallback
1377
1362
  );
1378
- A(() => (console.log("[React bindings] Mounting useSettings"), V++, V > 1 && console.error(
1363
+ A(() => (V++, V > 1 && console.error(
1379
1364
  "[React bindings] Capytale iframe React: Multiple settings registered: ",
1380
1365
  V
1381
1366
  ), () => {
1382
- console.log("[React bindings] Unmounting useSettings"), V--;
1383
- }), []), A(() => (b.use(["meta-player-ui"], ([i]) => {
1384
- if (i.version === 0) {
1367
+ V--;
1368
+ }), []), A(() => (w.use(["meta-player-ui"], ([s]) => {
1369
+ if (s.version === 0) {
1385
1370
  console.error(
1386
1371
  "[React bindings] Le MétaPlayer ne supporte pas le contrat meta-player-ui"
1387
1372
  );
1388
1373
  return;
1389
1374
  }
1390
- console.log(
1391
- "[React bindings] Updating settings UI in MetaPlayer",
1392
- s
1393
- ), i.i?.setSettingsUI(s);
1375
+ s.i?.setSettingsUI(i);
1394
1376
  }), o(
1395
1377
  e
1396
1378
  ), () => {
1397
1379
  o(null);
1398
- }), [s]);
1399
- }, Ht = () => w((e) => b.exec(["meta-player-ui"], ([n]) => {
1380
+ }), [i]);
1381
+ }, Ht = () => b((e) => w.exec(["meta-player-ui"], ([n]) => {
1400
1382
  if (n.version === 0)
1401
1383
  throw console.error(
1402
1384
  "[React bindings] Le MétaPlayer ne supporte pas le contrat meta-player-ui"
@@ -1404,8 +1386,8 @@ const Bt = (t, e, n) => {
1404
1386
  "Le MétaPlayer ne supporte pas le contrat meta-player-ui"
1405
1387
  );
1406
1388
  return n.i?.showToast(e);
1407
- }), []), zt = () => w(
1408
- (e) => b.exec(["meta-player-ui"], ([n]) => {
1389
+ }), []), zt = () => b(
1390
+ (e) => w.exec(["meta-player-ui"], ([n]) => {
1409
1391
  if (n.version === 0)
1410
1392
  throw console.error(
1411
1393
  "[React bindings] Le MétaPlayer ne supporte pas le contrat meta-player-ui"
@@ -1415,8 +1397,8 @@ const Bt = (t, e, n) => {
1415
1397
  return n.i?.clearToast(e);
1416
1398
  }),
1417
1399
  []
1418
- ), Me = () => w(
1419
- () => b.exec(["meta-player-ui"], ([e]) => {
1400
+ ), Me = () => b(
1401
+ () => w.exec(["meta-player-ui"], ([e]) => {
1420
1402
  if (e.version === 0)
1421
1403
  throw console.error(
1422
1404
  "[React bindings] Le MétaPlayer ne supporte pas le contrat meta-player-ui"
@@ -1426,19 +1408,19 @@ const Bt = (t, e, n) => {
1426
1408
  return e.i?.clearToasts();
1427
1409
  }),
1428
1410
  []
1429
- ), Ut = (t, e) => {
1430
- const n = Ht(), s = zt();
1411
+ ), _t = (t, e) => {
1412
+ const n = Ht(), i = zt();
1431
1413
  return A(() => {
1432
1414
  if (t == null)
1433
1415
  return;
1434
1416
  const o = n(t);
1435
1417
  return () => {
1436
- o.then((i) => {
1437
- i != null && s(i);
1418
+ o.then((s) => {
1419
+ s != null && i(s);
1438
1420
  });
1439
1421
  };
1440
- }, [n, s, ...e]), null;
1441
- }, Ge = () => w(() => b.exec(["trigger-save"], ([e]) => {
1422
+ }, [n, i, ...e]), null;
1423
+ }, Ge = () => b(() => w.exec(["trigger-save"], ([e]) => {
1442
1424
  if (e.version === 0)
1443
1425
  throw console.error(
1444
1426
  "[React bindings] Le MétaPlayer ne supporte pas le contrat trigger-save"
@@ -1448,42 +1430,42 @@ const Bt = (t, e, n) => {
1448
1430
  return e.i?.triggerSave();
1449
1431
  }), []), De = () => r((t) => t.canSave), Pe = (t, e) => {
1450
1432
  const n = r(
1451
- (s) => s.setLlmGetFirstMessageContextFunction
1433
+ (i) => i.setLlmGetFirstMessageContextFunction
1452
1434
  );
1453
1435
  A(() => (n(t), () => {
1454
1436
  n(null);
1455
1437
  }), [e, n]);
1456
1438
  }, Ve = (t, e) => {
1457
1439
  const n = r(
1458
- (s) => s.setLlmGetAllMessagesContextFunction
1440
+ (i) => i.setLlmGetAllMessagesContextFunction
1459
1441
  );
1460
1442
  A(() => (n(t), () => {
1461
1443
  n(null);
1462
1444
  }), [e, n]);
1463
- }, Ie = (t, e, n, s) => {
1445
+ }, Ie = (t, e, n, i) => {
1464
1446
  const o = r(
1465
1447
  (l) => l.setLlmGetAvailableToolsFunction
1466
- ), i = r(
1448
+ ), s = r(
1467
1449
  (l) => l.setLlmCallToolFunction
1468
1450
  ), u = r(
1469
1451
  (l) => l.setLlmDescribeToolFunction
1470
1452
  );
1471
- A(() => (o(t), i(e), u(n), () => {
1472
- o(null), i(null), u(null);
1453
+ A(() => (o(t), s(e), u(n), () => {
1454
+ o(null), s(null), u(null);
1473
1455
  }), [
1474
- s,
1475
- o,
1476
1456
  i,
1457
+ o,
1458
+ s,
1477
1459
  u
1478
1460
  ]);
1479
1461
  };
1480
- function _t(t) {
1462
+ function Qt(t) {
1481
1463
  const e = {};
1482
1464
  for (const n of t.fields)
1483
1465
  e[n.name] = n.defaultValue;
1484
1466
  return e;
1485
1467
  }
1486
- function Qt(t) {
1468
+ function Ut(t) {
1487
1469
  return { [t.name]: t.defaultValues };
1488
1470
  }
1489
1471
  function Yt(t) {
@@ -1492,10 +1474,10 @@ function Yt(t) {
1492
1474
  function Kt(t) {
1493
1475
  switch (t.type) {
1494
1476
  case "form":
1495
- return _t(t);
1477
+ return Qt(t);
1496
1478
  case "checkboxes":
1497
1479
  case "switches":
1498
- return Qt(t);
1480
+ return Ut(t);
1499
1481
  case "radio":
1500
1482
  return Yt(t);
1501
1483
  default:
@@ -1509,7 +1491,7 @@ function Xt(t) {
1509
1491
  return e;
1510
1492
  }
1511
1493
  function je(t) {
1512
- const n = dt()((s) => ({
1494
+ const n = dt()((i) => ({
1513
1495
  ...Xt(t)
1514
1496
  }));
1515
1497
  return n.activitySettings = t, n;
@@ -1534,45 +1516,45 @@ const ee = [
1534
1516
  "mode:1",
1535
1517
  "workflow:1"
1536
1518
  ];
1537
- function $e({
1519
+ function Oe({
1538
1520
  children: t,
1539
1521
  contracts: e,
1540
1522
  loadOnlyWhenReady: n = !0,
1541
- activitySettingsStore: s
1523
+ activitySettingsStore: i
1542
1524
  }) {
1543
- const o = r((i) => i.ready);
1525
+ const o = r((s) => s.ready);
1544
1526
  return A(() => {
1545
- const i = [...e];
1527
+ const s = [...e];
1546
1528
  for (const u of ee)
1547
- i.includes(u) || i.push(u);
1548
- Wt(i);
1549
- }, []), n && !o ? /* @__PURE__ */ Q("div", { className: "capy-loading-container", children: "Chargement en cours..." }) : /* @__PURE__ */ ft(mt, { children: [
1550
- s && /* @__PURE__ */ Q(te, { store: s }),
1529
+ s.includes(u) || s.push(u);
1530
+ Wt(s);
1531
+ }, []), n && !o ? /* @__PURE__ */ U("div", { className: "capy-loading-container", children: "Chargement en cours..." }) : /* @__PURE__ */ ft(mt, { children: [
1532
+ i && /* @__PURE__ */ U(te, { store: i }),
1551
1533
  t
1552
1534
  ] });
1553
1535
  }
1554
- function Oe({ message: t }) {
1555
- return Ut(t, [t]), null;
1536
+ function $e({ message: t }) {
1537
+ return _t(t, [t]), null;
1556
1538
  }
1557
1539
  export {
1558
- $e as Capytale,
1559
- Oe as TemporaryToast,
1540
+ Oe as Capytale,
1541
+ $e as TemporaryToast,
1560
1542
  je as createActivitySettingsStore,
1561
1543
  Je as useAfterSaveAction,
1562
1544
  De as useCanSave,
1563
1545
  zt as useClearToast,
1564
1546
  Me as useClearToasts,
1565
- ve as useGetLoadedJsonActivityContent,
1547
+ Ce as useGetLoadedJsonActivityContent,
1566
1548
  Se as useGetLoadedJsonActivitySplitContent,
1567
1549
  ye as useGetLoadedJsonAssignmentContent,
1568
1550
  Ae as useGetLoadedJsonAssignmentSplitContent,
1569
- Ce as useGetLoadedJsonContent,
1551
+ ve as useGetLoadedJsonContent,
1570
1552
  pe as useGetLoadedTextContent,
1571
1553
  he as useJsonActivityContentSaveFunction,
1572
- Re as useJsonActivitySplitContentSaveFunction,
1554
+ Ee as useJsonActivitySplitContentSaveFunction,
1573
1555
  Fe as useJsonAssignmentContentSaveFunction,
1574
- Ee as useJsonAssignmentSplitContentSaveFunction,
1575
- we as useJsonContentSaveFunction,
1556
+ Re as useJsonAssignmentSplitContentSaveFunction,
1557
+ be as useJsonContentSaveFunction,
1576
1558
  Ve as useLLMAllMessagesContext,
1577
1559
  Pe as useLLMFirstMessageContext,
1578
1560
  Ie as useLLMTools,
@@ -1591,9 +1573,9 @@ export {
1591
1573
  Bt as useSettings,
1592
1574
  Ht as useShowToast,
1593
1575
  xe as useSidebarActions,
1594
- be as useTextContentSaveFunction,
1576
+ we as useTextContentSaveFunction,
1595
1577
  ie as useTheme,
1596
- Ut as useToast,
1578
+ _t as useToast,
1597
1579
  Ge as useTriggerSave,
1598
1580
  se as useWorkflow
1599
1581
  };