@capytale/iframe-react 1.0.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.
@@ -0,0 +1,1053 @@
1
+ import K, { useEffect as A, useMemo as se, useRef as Rt } from "react";
2
+ import { getSocket as _t } from "@capytale/app-agent";
3
+ var B = { exports: {} }, q = {};
4
+ /**
5
+ * @license React
6
+ * react-jsx-runtime.production.min.js
7
+ *
8
+ * Copyright (c) Facebook, Inc. and its affiliates.
9
+ *
10
+ * This source code is licensed under the MIT license found in the
11
+ * LICENSE file in the root directory of this source tree.
12
+ */
13
+ var Fe;
14
+ function Tt() {
15
+ if (Fe) return q;
16
+ Fe = 1;
17
+ var t = K, r = Symbol.for("react.element"), a = Symbol.for("react.fragment"), s = Object.prototype.hasOwnProperty, l = t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, h = { key: !0, ref: !0, __self: !0, __source: !0 };
18
+ function y(m, c, g) {
19
+ var E, S = {}, x = null, P = null;
20
+ g !== void 0 && (x = "" + g), c.key !== void 0 && (x = "" + c.key), c.ref !== void 0 && (P = c.ref);
21
+ for (E in c) s.call(c, E) && !h.hasOwnProperty(E) && (S[E] = c[E]);
22
+ if (m && m.defaultProps) for (E in c = m.defaultProps, c) S[E] === void 0 && (S[E] = c[E]);
23
+ return { $$typeof: r, type: m, key: x, ref: P, props: S, _owner: l.current };
24
+ }
25
+ return q.Fragment = a, q.jsx = y, q.jsxs = y, q;
26
+ }
27
+ var J = {};
28
+ /**
29
+ * @license React
30
+ * react-jsx-runtime.development.js
31
+ *
32
+ * Copyright (c) Facebook, Inc. and its affiliates.
33
+ *
34
+ * This source code is licensed under the MIT license found in the
35
+ * LICENSE file in the root directory of this source tree.
36
+ */
37
+ var De;
38
+ function wt() {
39
+ return De || (De = 1, process.env.NODE_ENV !== "production" && function() {
40
+ var t = K, r = Symbol.for("react.element"), a = Symbol.for("react.portal"), s = Symbol.for("react.fragment"), l = Symbol.for("react.strict_mode"), h = Symbol.for("react.profiler"), y = Symbol.for("react.provider"), m = Symbol.for("react.context"), c = Symbol.for("react.forward_ref"), g = Symbol.for("react.suspense"), E = Symbol.for("react.suspense_list"), S = Symbol.for("react.memo"), x = Symbol.for("react.lazy"), P = Symbol.for("react.offscreen"), L = Symbol.iterator, Je = "@@iterator";
41
+ function Le(e) {
42
+ if (e === null || typeof e != "object")
43
+ return null;
44
+ var n = L && e[L] || e[Je];
45
+ return typeof n == "function" ? n : null;
46
+ }
47
+ var D = t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
48
+ function R(e) {
49
+ {
50
+ for (var n = arguments.length, o = new Array(n > 1 ? n - 1 : 0), i = 1; i < n; i++)
51
+ o[i - 1] = arguments[i];
52
+ Ye("error", e, o);
53
+ }
54
+ }
55
+ function Ye(e, n, o) {
56
+ {
57
+ var i = D.ReactDebugCurrentFrame, v = i.getStackAddendum();
58
+ v !== "" && (n += "%s", o = o.concat([v]));
59
+ var p = o.map(function(d) {
60
+ return String(d);
61
+ });
62
+ p.unshift("Warning: " + n), Function.prototype.apply.call(console[e], console, p);
63
+ }
64
+ }
65
+ var Ue = !1, Ne = !1, Ve = !1, Be = !1, Ge = !1, ue;
66
+ ue = Symbol.for("react.module.reference");
67
+ function He(e) {
68
+ return !!(typeof e == "string" || typeof e == "function" || e === s || e === h || Ge || e === l || e === g || e === E || Be || e === P || Ue || Ne || Ve || typeof e == "object" && e !== null && (e.$$typeof === x || e.$$typeof === S || e.$$typeof === y || e.$$typeof === m || e.$$typeof === c || // This needs to include all possible module reference object
69
+ // types supported by any Flight configuration anywhere since
70
+ // we don't know which Flight build this will end up being used
71
+ // with.
72
+ e.$$typeof === ue || e.getModuleId !== void 0));
73
+ }
74
+ function Qe(e, n, o) {
75
+ var i = e.displayName;
76
+ if (i)
77
+ return i;
78
+ var v = n.displayName || n.name || "";
79
+ return v !== "" ? o + "(" + v + ")" : o;
80
+ }
81
+ function ce(e) {
82
+ return e.displayName || "Context";
83
+ }
84
+ function O(e) {
85
+ if (e == null)
86
+ return null;
87
+ if (typeof e.tag == "number" && R("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function")
88
+ return e.displayName || e.name || null;
89
+ if (typeof e == "string")
90
+ return e;
91
+ switch (e) {
92
+ case s:
93
+ return "Fragment";
94
+ case a:
95
+ return "Portal";
96
+ case h:
97
+ return "Profiler";
98
+ case l:
99
+ return "StrictMode";
100
+ case g:
101
+ return "Suspense";
102
+ case E:
103
+ return "SuspenseList";
104
+ }
105
+ if (typeof e == "object")
106
+ switch (e.$$typeof) {
107
+ case m:
108
+ var n = e;
109
+ return ce(n) + ".Consumer";
110
+ case y:
111
+ var o = e;
112
+ return ce(o._context) + ".Provider";
113
+ case c:
114
+ return Qe(e, e.render, "ForwardRef");
115
+ case S:
116
+ var i = e.displayName || null;
117
+ return i !== null ? i : O(e.type) || "Memo";
118
+ case x: {
119
+ var v = e, p = v._payload, d = v._init;
120
+ try {
121
+ return O(d(p));
122
+ } catch {
123
+ return null;
124
+ }
125
+ }
126
+ }
127
+ return null;
128
+ }
129
+ var j = Object.assign, M = 0, le, fe, de, ve, pe, ge, ye;
130
+ function me() {
131
+ }
132
+ me.__reactDisabledLog = !0;
133
+ function Ke() {
134
+ {
135
+ if (M === 0) {
136
+ le = console.log, fe = console.info, de = console.warn, ve = console.error, pe = console.group, ge = console.groupCollapsed, ye = console.groupEnd;
137
+ var e = {
138
+ configurable: !0,
139
+ enumerable: !0,
140
+ value: me,
141
+ writable: !0
142
+ };
143
+ Object.defineProperties(console, {
144
+ info: e,
145
+ log: e,
146
+ warn: e,
147
+ error: e,
148
+ group: e,
149
+ groupCollapsed: e,
150
+ groupEnd: e
151
+ });
152
+ }
153
+ M++;
154
+ }
155
+ }
156
+ function ze() {
157
+ {
158
+ if (M--, M === 0) {
159
+ var e = {
160
+ configurable: !0,
161
+ enumerable: !0,
162
+ writable: !0
163
+ };
164
+ Object.defineProperties(console, {
165
+ log: j({}, e, {
166
+ value: le
167
+ }),
168
+ info: j({}, e, {
169
+ value: fe
170
+ }),
171
+ warn: j({}, e, {
172
+ value: de
173
+ }),
174
+ error: j({}, e, {
175
+ value: ve
176
+ }),
177
+ group: j({}, e, {
178
+ value: pe
179
+ }),
180
+ groupCollapsed: j({}, e, {
181
+ value: ge
182
+ }),
183
+ groupEnd: j({}, e, {
184
+ value: ye
185
+ })
186
+ });
187
+ }
188
+ M < 0 && R("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
189
+ }
190
+ }
191
+ var z = D.ReactCurrentDispatcher, X;
192
+ function Y(e, n, o) {
193
+ {
194
+ if (X === void 0)
195
+ try {
196
+ throw Error();
197
+ } catch (v) {
198
+ var i = v.stack.trim().match(/\n( *(at )?)/);
199
+ X = i && i[1] || "";
200
+ }
201
+ return `
202
+ ` + X + e;
203
+ }
204
+ }
205
+ var Z = !1, U;
206
+ {
207
+ var Xe = typeof WeakMap == "function" ? WeakMap : Map;
208
+ U = new Xe();
209
+ }
210
+ function Se(e, n) {
211
+ if (!e || Z)
212
+ return "";
213
+ {
214
+ var o = U.get(e);
215
+ if (o !== void 0)
216
+ return o;
217
+ }
218
+ var i;
219
+ Z = !0;
220
+ var v = Error.prepareStackTrace;
221
+ Error.prepareStackTrace = void 0;
222
+ var p;
223
+ p = z.current, z.current = null, Ke();
224
+ try {
225
+ if (n) {
226
+ var d = function() {
227
+ throw Error();
228
+ };
229
+ if (Object.defineProperty(d.prototype, "props", {
230
+ set: function() {
231
+ throw Error();
232
+ }
233
+ }), typeof Reflect == "object" && Reflect.construct) {
234
+ try {
235
+ Reflect.construct(d, []);
236
+ } catch (T) {
237
+ i = T;
238
+ }
239
+ Reflect.construct(e, [], d);
240
+ } else {
241
+ try {
242
+ d.call();
243
+ } catch (T) {
244
+ i = T;
245
+ }
246
+ e.call(d.prototype);
247
+ }
248
+ } else {
249
+ try {
250
+ throw Error();
251
+ } catch (T) {
252
+ i = T;
253
+ }
254
+ e();
255
+ }
256
+ } catch (T) {
257
+ if (T && i && typeof T.stack == "string") {
258
+ for (var f = T.stack.split(`
259
+ `), _ = i.stack.split(`
260
+ `), b = f.length - 1, C = _.length - 1; b >= 1 && C >= 0 && f[b] !== _[C]; )
261
+ C--;
262
+ for (; b >= 1 && C >= 0; b--, C--)
263
+ if (f[b] !== _[C]) {
264
+ if (b !== 1 || C !== 1)
265
+ do
266
+ if (b--, C--, C < 0 || f[b] !== _[C]) {
267
+ var w = `
268
+ ` + f[b].replace(" at new ", " at ");
269
+ return e.displayName && w.includes("<anonymous>") && (w = w.replace("<anonymous>", e.displayName)), typeof e == "function" && U.set(e, w), w;
270
+ }
271
+ while (b >= 1 && C >= 0);
272
+ break;
273
+ }
274
+ }
275
+ } finally {
276
+ Z = !1, z.current = p, ze(), Error.prepareStackTrace = v;
277
+ }
278
+ var $ = e ? e.displayName || e.name : "", F = $ ? Y($) : "";
279
+ return typeof e == "function" && U.set(e, F), F;
280
+ }
281
+ function Ze(e, n, o) {
282
+ return Se(e, !1);
283
+ }
284
+ function et(e) {
285
+ var n = e.prototype;
286
+ return !!(n && n.isReactComponent);
287
+ }
288
+ function N(e, n, o) {
289
+ if (e == null)
290
+ return "";
291
+ if (typeof e == "function")
292
+ return Se(e, et(e));
293
+ if (typeof e == "string")
294
+ return Y(e);
295
+ switch (e) {
296
+ case g:
297
+ return Y("Suspense");
298
+ case E:
299
+ return Y("SuspenseList");
300
+ }
301
+ if (typeof e == "object")
302
+ switch (e.$$typeof) {
303
+ case c:
304
+ return Ze(e.render);
305
+ case S:
306
+ return N(e.type, n, o);
307
+ case x: {
308
+ var i = e, v = i._payload, p = i._init;
309
+ try {
310
+ return N(p(v), n, o);
311
+ } catch {
312
+ }
313
+ }
314
+ }
315
+ return "";
316
+ }
317
+ var W = Object.prototype.hasOwnProperty, be = {}, Ce = D.ReactDebugCurrentFrame;
318
+ function V(e) {
319
+ if (e) {
320
+ var n = e._owner, o = N(e.type, e._source, n ? n.type : null);
321
+ Ce.setExtraStackFrame(o);
322
+ } else
323
+ Ce.setExtraStackFrame(null);
324
+ }
325
+ function tt(e, n, o, i, v) {
326
+ {
327
+ var p = Function.call.bind(W);
328
+ for (var d in e)
329
+ if (p(e, d)) {
330
+ var f = void 0;
331
+ try {
332
+ if (typeof e[d] != "function") {
333
+ var _ = Error((i || "React class") + ": " + o + " type `" + d + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[d] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
334
+ throw _.name = "Invariant Violation", _;
335
+ }
336
+ f = e[d](n, d, i, o, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
337
+ } catch (b) {
338
+ f = b;
339
+ }
340
+ f && !(f instanceof Error) && (V(v), R("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", i || "React class", o, d, typeof f), V(null)), f instanceof Error && !(f.message in be) && (be[f.message] = !0, V(v), R("Failed %s type: %s", o, f.message), V(null));
341
+ }
342
+ }
343
+ }
344
+ var nt = Array.isArray;
345
+ function ee(e) {
346
+ return nt(e);
347
+ }
348
+ function rt(e) {
349
+ {
350
+ var n = typeof Symbol == "function" && Symbol.toStringTag, o = n && e[Symbol.toStringTag] || e.constructor.name || "Object";
351
+ return o;
352
+ }
353
+ }
354
+ function ot(e) {
355
+ try {
356
+ return he(e), !1;
357
+ } catch {
358
+ return !0;
359
+ }
360
+ }
361
+ function he(e) {
362
+ return "" + e;
363
+ }
364
+ function Ee(e) {
365
+ if (ot(e))
366
+ return R("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", rt(e)), he(e);
367
+ }
368
+ var Re = D.ReactCurrentOwner, at = {
369
+ key: !0,
370
+ ref: !0,
371
+ __self: !0,
372
+ __source: !0
373
+ }, _e, Te;
374
+ function it(e) {
375
+ if (W.call(e, "ref")) {
376
+ var n = Object.getOwnPropertyDescriptor(e, "ref").get;
377
+ if (n && n.isReactWarning)
378
+ return !1;
379
+ }
380
+ return e.ref !== void 0;
381
+ }
382
+ function st(e) {
383
+ if (W.call(e, "key")) {
384
+ var n = Object.getOwnPropertyDescriptor(e, "key").get;
385
+ if (n && n.isReactWarning)
386
+ return !1;
387
+ }
388
+ return e.key !== void 0;
389
+ }
390
+ function ut(e, n) {
391
+ typeof e.ref == "string" && Re.current;
392
+ }
393
+ function ct(e, n) {
394
+ {
395
+ var o = function() {
396
+ _e || (_e = !0, R("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", n));
397
+ };
398
+ o.isReactWarning = !0, Object.defineProperty(e, "key", {
399
+ get: o,
400
+ configurable: !0
401
+ });
402
+ }
403
+ }
404
+ function lt(e, n) {
405
+ {
406
+ var o = function() {
407
+ Te || (Te = !0, R("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", n));
408
+ };
409
+ o.isReactWarning = !0, Object.defineProperty(e, "ref", {
410
+ get: o,
411
+ configurable: !0
412
+ });
413
+ }
414
+ }
415
+ var ft = function(e, n, o, i, v, p, d) {
416
+ var f = {
417
+ // This tag allows us to uniquely identify this as a React Element
418
+ $$typeof: r,
419
+ // Built-in properties that belong on the element
420
+ type: e,
421
+ key: n,
422
+ ref: o,
423
+ props: d,
424
+ // Record the component responsible for creating this element.
425
+ _owner: p
426
+ };
427
+ return f._store = {}, Object.defineProperty(f._store, "validated", {
428
+ configurable: !1,
429
+ enumerable: !1,
430
+ writable: !0,
431
+ value: !1
432
+ }), Object.defineProperty(f, "_self", {
433
+ configurable: !1,
434
+ enumerable: !1,
435
+ writable: !1,
436
+ value: i
437
+ }), Object.defineProperty(f, "_source", {
438
+ configurable: !1,
439
+ enumerable: !1,
440
+ writable: !1,
441
+ value: v
442
+ }), Object.freeze && (Object.freeze(f.props), Object.freeze(f)), f;
443
+ };
444
+ function dt(e, n, o, i, v) {
445
+ {
446
+ var p, d = {}, f = null, _ = null;
447
+ o !== void 0 && (Ee(o), f = "" + o), st(n) && (Ee(n.key), f = "" + n.key), it(n) && (_ = n.ref, ut(n, v));
448
+ for (p in n)
449
+ W.call(n, p) && !at.hasOwnProperty(p) && (d[p] = n[p]);
450
+ if (e && e.defaultProps) {
451
+ var b = e.defaultProps;
452
+ for (p in b)
453
+ d[p] === void 0 && (d[p] = b[p]);
454
+ }
455
+ if (f || _) {
456
+ var C = typeof e == "function" ? e.displayName || e.name || "Unknown" : e;
457
+ f && ct(d, C), _ && lt(d, C);
458
+ }
459
+ return ft(e, f, _, v, i, Re.current, d);
460
+ }
461
+ }
462
+ var te = D.ReactCurrentOwner, we = D.ReactDebugCurrentFrame;
463
+ function I(e) {
464
+ if (e) {
465
+ var n = e._owner, o = N(e.type, e._source, n ? n.type : null);
466
+ we.setExtraStackFrame(o);
467
+ } else
468
+ we.setExtraStackFrame(null);
469
+ }
470
+ var ne;
471
+ ne = !1;
472
+ function re(e) {
473
+ return typeof e == "object" && e !== null && e.$$typeof === r;
474
+ }
475
+ function xe() {
476
+ {
477
+ if (te.current) {
478
+ var e = O(te.current.type);
479
+ if (e)
480
+ return `
481
+
482
+ Check the render method of \`` + e + "`.";
483
+ }
484
+ return "";
485
+ }
486
+ }
487
+ function vt(e) {
488
+ return "";
489
+ }
490
+ var ke = {};
491
+ function pt(e) {
492
+ {
493
+ var n = xe();
494
+ if (!n) {
495
+ var o = typeof e == "string" ? e : e.displayName || e.name;
496
+ o && (n = `
497
+
498
+ Check the top-level render call using <` + o + ">.");
499
+ }
500
+ return n;
501
+ }
502
+ }
503
+ function Ae(e, n) {
504
+ {
505
+ if (!e._store || e._store.validated || e.key != null)
506
+ return;
507
+ e._store.validated = !0;
508
+ var o = pt(n);
509
+ if (ke[o])
510
+ return;
511
+ ke[o] = !0;
512
+ var i = "";
513
+ e && e._owner && e._owner !== te.current && (i = " It was passed a child from " + O(e._owner.type) + "."), I(e), R('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', o, i), I(null);
514
+ }
515
+ }
516
+ function Pe(e, n) {
517
+ {
518
+ if (typeof e != "object")
519
+ return;
520
+ if (ee(e))
521
+ for (var o = 0; o < e.length; o++) {
522
+ var i = e[o];
523
+ re(i) && Ae(i, n);
524
+ }
525
+ else if (re(e))
526
+ e._store && (e._store.validated = !0);
527
+ else if (e) {
528
+ var v = Le(e);
529
+ if (typeof v == "function" && v !== e.entries)
530
+ for (var p = v.call(e), d; !(d = p.next()).done; )
531
+ re(d.value) && Ae(d.value, n);
532
+ }
533
+ }
534
+ }
535
+ function gt(e) {
536
+ {
537
+ var n = e.type;
538
+ if (n == null || typeof n == "string")
539
+ return;
540
+ var o;
541
+ if (typeof n == "function")
542
+ o = n.propTypes;
543
+ else if (typeof n == "object" && (n.$$typeof === c || // Note: Memo only checks outer props here.
544
+ // Inner props are checked in the reconciler.
545
+ n.$$typeof === S))
546
+ o = n.propTypes;
547
+ else
548
+ return;
549
+ if (o) {
550
+ var i = O(n);
551
+ tt(o, e.props, "prop", i, e);
552
+ } else if (n.PropTypes !== void 0 && !ne) {
553
+ ne = !0;
554
+ var v = O(n);
555
+ R("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", v || "Unknown");
556
+ }
557
+ typeof n.getDefaultProps == "function" && !n.getDefaultProps.isReactClassApproved && R("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
558
+ }
559
+ }
560
+ function yt(e) {
561
+ {
562
+ for (var n = Object.keys(e.props), o = 0; o < n.length; o++) {
563
+ var i = n[o];
564
+ if (i !== "children" && i !== "key") {
565
+ I(e), R("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", i), I(null);
566
+ break;
567
+ }
568
+ }
569
+ e.ref !== null && (I(e), R("Invalid attribute `ref` supplied to `React.Fragment`."), I(null));
570
+ }
571
+ }
572
+ var Oe = {};
573
+ function je(e, n, o, i, v, p) {
574
+ {
575
+ var d = He(e);
576
+ if (!d) {
577
+ var f = "";
578
+ (e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (f += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
579
+ var _ = vt();
580
+ _ ? f += _ : f += xe();
581
+ var b;
582
+ e === null ? b = "null" : ee(e) ? b = "array" : e !== void 0 && e.$$typeof === r ? (b = "<" + (O(e.type) || "Unknown") + " />", f = " Did you accidentally export a JSX literal instead of a component?") : b = typeof e, R("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", b, f);
583
+ }
584
+ var C = dt(e, n, o, v, p);
585
+ if (C == null)
586
+ return C;
587
+ if (d) {
588
+ var w = n.children;
589
+ if (w !== void 0)
590
+ if (i)
591
+ if (ee(w)) {
592
+ for (var $ = 0; $ < w.length; $++)
593
+ Pe(w[$], e);
594
+ Object.freeze && Object.freeze(w);
595
+ } else
596
+ R("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
597
+ else
598
+ Pe(w, e);
599
+ }
600
+ if (W.call(n, "key")) {
601
+ var F = O(e), T = Object.keys(n).filter(function(Et) {
602
+ return Et !== "key";
603
+ }), oe = T.length > 0 ? "{key: someKey, " + T.join(": ..., ") + ": ...}" : "{key: someKey}";
604
+ if (!Oe[F + oe]) {
605
+ var ht = T.length > 0 ? "{" + T.join(": ..., ") + ": ...}" : "{}";
606
+ R(`A props object containing a "key" prop is being spread into JSX:
607
+ let props = %s;
608
+ <%s {...props} />
609
+ React keys must be passed directly to JSX without using spread:
610
+ let props = %s;
611
+ <%s key={someKey} {...props} />`, oe, F, ht, F), Oe[F + oe] = !0;
612
+ }
613
+ }
614
+ return e === s ? yt(C) : gt(C), C;
615
+ }
616
+ }
617
+ function mt(e, n, o) {
618
+ return je(e, n, o, !0);
619
+ }
620
+ function St(e, n, o) {
621
+ return je(e, n, o, !1);
622
+ }
623
+ var bt = St, Ct = mt;
624
+ J.Fragment = s, J.jsx = bt, J.jsxs = Ct;
625
+ }()), J;
626
+ }
627
+ var Ie;
628
+ function xt() {
629
+ return Ie || (Ie = 1, process.env.NODE_ENV === "production" ? B.exports = Tt() : B.exports = wt()), B.exports;
630
+ }
631
+ var $e = xt();
632
+ const Me = (t) => {
633
+ let r;
634
+ const a = /* @__PURE__ */ new Set(), s = (g, E) => {
635
+ const S = typeof g == "function" ? g(r) : g;
636
+ if (!Object.is(S, r)) {
637
+ const x = r;
638
+ r = E ?? (typeof S != "object" || S === null) ? S : Object.assign({}, r, S), a.forEach((P) => P(r, x));
639
+ }
640
+ }, l = () => r, m = { setState: s, getState: l, getInitialState: () => c, subscribe: (g) => (a.add(g), () => a.delete(g)) }, c = r = t(s, l, m);
641
+ return m;
642
+ }, kt = (t) => t ? Me(t) : Me, At = (t) => t;
643
+ function Pt(t, r = At) {
644
+ const a = K.useSyncExternalStore(
645
+ t.subscribe,
646
+ () => r(t.getState()),
647
+ () => r(t.getInitialState())
648
+ );
649
+ return K.useDebugValue(a), a;
650
+ }
651
+ const We = (t) => {
652
+ const r = kt(t), a = (s) => Pt(r, s);
653
+ return Object.assign(a, r), a;
654
+ }, Ot = (t) => t ? We(t) : We, jt = (t) => (r, a, s) => {
655
+ const l = s.subscribe;
656
+ return s.subscribe = (y, m, c) => {
657
+ let g = y;
658
+ if (m) {
659
+ const E = (c == null ? void 0 : c.equalityFn) || Object.is;
660
+ let S = y(s.getState());
661
+ g = (x) => {
662
+ const P = y(x);
663
+ if (!E(S, P)) {
664
+ const L = S;
665
+ m(S = P, L);
666
+ }
667
+ }, c != null && c.fireImmediately && m(S, S);
668
+ }
669
+ return l(g);
670
+ }, t(r, a, s);
671
+ }, Ft = jt, u = Ot()(
672
+ Ft((t) => ({
673
+ ready: !1,
674
+ workflow: "current",
675
+ mode: "assignment",
676
+ theme: "light",
677
+ saveCount: 0,
678
+ afterSaveCount: 0,
679
+ isDirtyCount: 0,
680
+ loadedTextContent: null,
681
+ loadedJsonContent: null,
682
+ getTextContentFunction: () => (console.error("getTextContentFunction is not set"), null),
683
+ getJsonContentFunction: () => (console.error("getJsonContentFunction is not set"), null),
684
+ sidebarActions: {},
685
+ quickActions: {},
686
+ activitySettings: null,
687
+ setGetTextContentFunction: (r) => {
688
+ t({ getTextContentFunction: r });
689
+ },
690
+ setGetJsonContentFunction: (r) => {
691
+ t({ getJsonContentFunction: r });
692
+ },
693
+ setSidebarActions: (r) => {
694
+ t({ sidebarActions: r });
695
+ },
696
+ setQuickActions: (r) => {
697
+ t({ quickActions: r });
698
+ },
699
+ setActivitySettings: (r) => {
700
+ t({ activitySettings: r });
701
+ },
702
+ incSaveCount: () => t((r) => ({
703
+ saveCount: r.saveCount + 1
704
+ })),
705
+ incDirtyCount: () => t((r) => ({ isDirtyCount: r.isDirtyCount + 1 }))
706
+ }))
707
+ ), Dt = [
708
+ "meta-player-events:1",
709
+ "meta-player-ui:1",
710
+ "mode:1",
711
+ "reload:1",
712
+ "theme:1",
713
+ "workflow:1",
714
+ "simple-content(text):1",
715
+ "simple-content(json):1",
716
+ "simple-binary-data(text):1",
717
+ "simple-content-eval(text):1",
718
+ "simple-content-eval(json):1"
719
+ ], qe = {
720
+ "mode:1": {
721
+ setMode: (t) => {
722
+ u.setState({ mode: t });
723
+ }
724
+ },
725
+ "reload:1": {
726
+ reloaded: (t) => {
727
+ console.log("Reloaded with state:", t), console.error("Not implemented yet");
728
+ }
729
+ },
730
+ "theme:1": {
731
+ setTheme: (t) => {
732
+ if (t === null) {
733
+ u.setState({ theme: null });
734
+ return;
735
+ }
736
+ if (t !== "light" && t !== "dark") {
737
+ console.warn(
738
+ `Invalid theme: ${t}. Expected 'light' or 'dark'.`
739
+ ), u.setState({ theme: null });
740
+ return;
741
+ }
742
+ u.setState({ theme: t });
743
+ }
744
+ },
745
+ "workflow:1": {
746
+ setWorkflow: (t) => {
747
+ u.setState({ workflow: t });
748
+ }
749
+ },
750
+ "simple-content(text):1": {
751
+ contentSaved: () => {
752
+ u.setState((t) => ({
753
+ afterSaveCount: t.afterSaveCount + 1
754
+ }));
755
+ },
756
+ getContent: () => u.getState().getTextContentFunction(),
757
+ loadContent: (t) => {
758
+ u.setState({ loadedTextContent: t });
759
+ }
760
+ },
761
+ "simple-content(json):1": {
762
+ contentSaved: () => {
763
+ u.setState((t) => ({
764
+ afterSaveCount: t.afterSaveCount + 1
765
+ }));
766
+ },
767
+ getContent: () => u.getState().getJsonContentFunction(),
768
+ loadContent: (t) => {
769
+ u.setState({ loadedJsonContent: t });
770
+ }
771
+ },
772
+ "simple-binary-data(text):1": {
773
+ contentSaved: () => {
774
+ u.setState((t) => ({
775
+ afterSaveCount: t.afterSaveCount + 1
776
+ }));
777
+ },
778
+ getContent: () => u.getState().getTextContentFunction(),
779
+ loadContent: (t) => {
780
+ u.setState({ loadedTextContent: t });
781
+ }
782
+ },
783
+ "simple-content-eval(text):1": {
784
+ contentSaved: () => {
785
+ u.setState((t) => ({
786
+ afterSaveCount: t.afterSaveCount + 1
787
+ }));
788
+ },
789
+ getContent: () => u.getState().getTextContentFunction(),
790
+ loadContent: (t) => {
791
+ u.setState({ loadedTextContent: t });
792
+ },
793
+ getAssignmentContent: () => {
794
+ throw new Error(
795
+ "getAssignmentContent is not implemented for simple-content-eval(text)"
796
+ );
797
+ }
798
+ },
799
+ "simple-content-eval(json):1": {
800
+ contentSaved: () => {
801
+ u.setState((t) => ({
802
+ afterSaveCount: t.afterSaveCount + 1
803
+ }));
804
+ },
805
+ getContent: () => u.getState().getJsonContentFunction(),
806
+ loadContent: (t) => {
807
+ u.setState({ loadedJsonContent: t });
808
+ },
809
+ getAssignmentContent: () => {
810
+ throw new Error(
811
+ "getAssignmentContent is not implemented for simple-content-eval(json)"
812
+ );
813
+ }
814
+ },
815
+ "meta-player-ui:1": {
816
+ executeAction(t) {
817
+ if (t.startsWith("qa")) {
818
+ const a = u.getState().quickActions[t];
819
+ a ? a() : console.error(`Quick action not found: ${t}`);
820
+ } else {
821
+ const a = u.getState().sidebarActions[t];
822
+ a ? a() : console.error(`Sidebar action not found: ${t}`);
823
+ }
824
+ },
825
+ executeFileUpload(t, r) {
826
+ if (t.startsWith("qa")) {
827
+ const s = u.getState().quickActions[t];
828
+ s ? s(r) : console.error(`Quick action not found: ${t}`);
829
+ } else {
830
+ const s = u.getState().sidebarActions[t];
831
+ s ? s(r) : console.error(`Sidebar action not found: ${t}`);
832
+ }
833
+ },
834
+ updateSettings(t) {
835
+ u.setState({ activitySettings: t });
836
+ }
837
+ },
838
+ "meta-player-events:1": {
839
+ handleEvent(t) {
840
+ t === "all-loaded" && u.setState({ ready: !0 });
841
+ }
842
+ }
843
+ }, k = _t();
844
+ function It(t) {
845
+ for (const r of t) {
846
+ if (!Dt.includes(r)) {
847
+ console.warn(
848
+ `Contract ${r} is not implemented in Capytale. Skipping plug.`
849
+ );
850
+ continue;
851
+ }
852
+ if (!(r in qe)) {
853
+ console.warn(
854
+ `Contract handler for ${r} is not defined. Skipping plug.`
855
+ );
856
+ continue;
857
+ }
858
+ const a = qe[r];
859
+ k.plug([r], ([]) => [a]);
860
+ }
861
+ k.plugsDone();
862
+ for (const r of [
863
+ "simple-content(text):1",
864
+ "simple-content(json):1",
865
+ "simple-binary-data(text):1",
866
+ "simple-content-eval(text):1"
867
+ ])
868
+ if (console.log(`Contract ${r} is being subscribed to content changes.`), t.includes(r)) {
869
+ console.log(`Subscribing to content changes for contract ${r}`);
870
+ const a = r.split(":")[0];
871
+ k.use([a], ([s]) => {
872
+ u.subscribe((l) => l.isDirtyCount, () => {
873
+ var l;
874
+ (l = s.i) == null || l.contentChanged(), console.log(`Content changed for contract ${a}`);
875
+ });
876
+ });
877
+ }
878
+ }
879
+ function Wt({
880
+ children: t,
881
+ contracts: r,
882
+ loadOnlyWhenReady: a = !0
883
+ }) {
884
+ const s = u((l) => l.ready);
885
+ return A(() => {
886
+ const l = r.includes("meta-player-events:1") ? r : [...r, "meta-player-events:1"];
887
+ It(l);
888
+ }, []), a && !s ? /* @__PURE__ */ $e.jsx("div", { className: "container", children: "Chargement en cours..." }) : /* @__PURE__ */ $e.jsx("div", { className: "container", children: t });
889
+ }
890
+ const qt = () => u((t) => {
891
+ if (t.mode === null)
892
+ throw new Error("Mode is not set. Have you used contract 'mode'?");
893
+ return t.mode;
894
+ }), Jt = () => u((t) => {
895
+ if (t.workflow === null)
896
+ throw new Error("Workflow is not set. Have you used contract 'workflow'?");
897
+ return t.workflow;
898
+ }), Lt = () => u((t) => {
899
+ if (t.theme === null)
900
+ throw new Error("Theme is not set. Have you used contract 'theme'?");
901
+ return t.theme;
902
+ }), Yt = () => u((t) => t.incSaveCount), Ut = () => u((t) => t.incDirtyCount), Nt = () => u((t) => t.loadedTextContent), Vt = () => u((t) => t.loadedJsonContent), Bt = (t) => {
903
+ const r = u(
904
+ (a) => a.setGetTextContentFunction
905
+ );
906
+ A(() => {
907
+ r(t);
908
+ }, [t, r]);
909
+ }, Gt = (t) => {
910
+ const r = u(
911
+ (a) => a.setGetJsonContentFunction
912
+ );
913
+ A(() => {
914
+ r(t);
915
+ }, [t, r]);
916
+ }, Ht = (t) => {
917
+ const r = u((a) => a.afterSaveCount);
918
+ A(() => {
919
+ r > 0 && t();
920
+ }, [r]);
921
+ }, Qt = () => (t, r) => {
922
+ k.use(["meta-player-ui"], ([a]) => {
923
+ var s;
924
+ if (a.version === 0) {
925
+ console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");
926
+ return;
927
+ }
928
+ (s = a.i) == null || s.previewTextFile(t, r);
929
+ });
930
+ }, Kt = () => (t, r) => {
931
+ k.use(["meta-player-ui"], ([a]) => {
932
+ var s;
933
+ if (a.version === 0) {
934
+ console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");
935
+ return;
936
+ }
937
+ (s = a.i) == null || s.previewImageFile(t, r);
938
+ });
939
+ };
940
+ let G = 0, ae = 0;
941
+ const zt = (t, r) => {
942
+ const a = se(t, r), s = u((l) => l.setSidebarActions);
943
+ A(() => (G++, G > 1 && console.error("Capytale iframe React: Multiple sidebar actions registered: ", G), () => {
944
+ G--;
945
+ }), []), A(() => (k.use(["meta-player-ui"], ([l]) => {
946
+ var m;
947
+ if (l.version === 0) {
948
+ console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");
949
+ return;
950
+ }
951
+ ae++;
952
+ const h = a.map((c, g) => ({
953
+ type: c.type,
954
+ title: c.title,
955
+ icon: c.icon,
956
+ id: `sa-${ae}-${g}`,
957
+ ...c.type === "file-upload" ? { accept: c.accept } : {}
958
+ })), y = {};
959
+ a.forEach((c, g) => {
960
+ y[`sa-${ae}-${g}`] = c.action;
961
+ }), (m = l.i) == null || m.setSidebarActionButtons(h), s(y);
962
+ }), () => {
963
+ s({}), k.use(["meta-player-ui"], ([l]) => {
964
+ var h;
965
+ if (l.version === 0) {
966
+ console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");
967
+ return;
968
+ }
969
+ (h = l.i) == null || h.setSidebarActionButtons([]);
970
+ });
971
+ }), [a]);
972
+ };
973
+ let H = 0, ie = 0;
974
+ const Xt = (t, r) => {
975
+ const a = se(t, r), s = u((l) => l.setQuickActions);
976
+ A(() => (H++, H > 1 && console.error("Capytale iframe React: Multiple quick actions registered: ", H), () => {
977
+ H--;
978
+ }), []), A(() => (k.use(["meta-player-ui"], ([l]) => {
979
+ var m;
980
+ if (l.version === 0) {
981
+ console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");
982
+ return;
983
+ }
984
+ ie++;
985
+ const h = a.map((c, g) => ({
986
+ type: c.type,
987
+ title: c.title,
988
+ icon: c.icon,
989
+ id: `qa-${ie}-${g}`,
990
+ ...c.type === "file-upload" ? { accept: c.accept } : {}
991
+ })), y = {};
992
+ a.forEach((c, g) => {
993
+ y[`qa-${ie}-${g}`] = c.action;
994
+ }), (m = l.i) == null || m.setQuickActionButtons(h), s(y);
995
+ }), () => {
996
+ s({}), k.use(["meta-player-ui"], ([l]) => {
997
+ var h;
998
+ if (l.version === 0) {
999
+ console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");
1000
+ return;
1001
+ }
1002
+ (h = l.i) == null || h.setQuickActionButtons([]);
1003
+ });
1004
+ }), [a]);
1005
+ };
1006
+ let Q = 0;
1007
+ const Zt = (t, r) => {
1008
+ const a = se(t, r), s = u((y) => y.setActivitySettings), l = u((y) => y.activitySettings), h = Rt("");
1009
+ return A(() => (console.log("Mounting useSettings"), Q++, Q > 1 && console.error("Capytale iframe React: Multiple settings registered: ", Q), () => {
1010
+ Q--;
1011
+ }), []), A(() => {
1012
+ const y = JSON.stringify(a);
1013
+ if (y !== h.current)
1014
+ return h.current = y, k.use(["meta-player-ui"], ([m]) => {
1015
+ var c;
1016
+ if (m.version === 0) {
1017
+ console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");
1018
+ return;
1019
+ }
1020
+ console.log("Updating settings UI in MetaPlayer", a), (c = m.i) == null || c.setSettingsUI(a);
1021
+ }), () => {
1022
+ s(null);
1023
+ };
1024
+ }, [a]), l;
1025
+ }, en = () => (r) => {
1026
+ k.use(["meta-player-ui"], ([a]) => {
1027
+ var s;
1028
+ if (a.version === 0) {
1029
+ console.error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");
1030
+ return;
1031
+ }
1032
+ (s = a.i) == null || s.showToast(r);
1033
+ });
1034
+ };
1035
+ export {
1036
+ Wt as Capytale,
1037
+ Ht as useAfterSaveAction,
1038
+ Gt as useJsonContentSaveFunction,
1039
+ Vt as useLoadedJsonContent,
1040
+ Nt as useLoadedTextContent,
1041
+ qt as useMode,
1042
+ Ut as useNotifyIsDirty,
1043
+ Kt as usePreviewImageFile,
1044
+ Qt as usePreviewTextFile,
1045
+ Xt as useQuickActions,
1046
+ Yt as useRequestSave,
1047
+ Zt as useSettings,
1048
+ en as useShowToast,
1049
+ zt as useSidebarActions,
1050
+ Bt as useTextContentSaveFunction,
1051
+ Lt as useTheme,
1052
+ Jt as useWorkflow
1053
+ };