@weavix/sdk-react 0.0.10 → 0.0.12

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
@@ -1,891 +1,281 @@
1
- import Ye, { Component as Er, useState as A, useEffect as Y, createContext as Rr, useRef as xr, useMemo as Pr, useContext as Cr, useCallback as $e } from "react";
2
- import { on as q, hostApi as m, setHandler as Tr, uiApi as le, dispatchHostEvent as V, getLocalizedString as Or } from "@weavix/sdk-core";
3
- import { METHOD_NOT_SUPPORTED as Qr, MISSING_REQUIRED_SCOPE as Zr, PLUGIN_ID_IS_NOT_CORRECT as et, PLUGIN_ID_OR_SLOT_NOT_PROVIDED as rt, PluginActionError as tt, UNKNOWN_ERROR as nt, VALIDATION_ERROR as at, dispatchHostEvent as it, getField as ot, getLocalizedString as st, hostApi as ut, on as lt, uiApi as ct } from "@weavix/sdk-core";
4
- class wr extends Er {
5
- static getDerivedStateFromError(a) {
6
- return { hasError: !0, error: a };
7
- }
8
- constructor(a) {
9
- super(a), this.state = { hasError: !1, error: null };
10
- }
11
- componentDidCatch(a, c) {
12
- console.error("ErrorBoundary caught an error:", a, c);
13
- }
14
- render() {
15
- return this.state.hasError && this.state.error ? this.props.fallback(this.state.error) : this.props.children;
16
- }
1
+ import { Component as e, createContext as t, useCallback as n, useContext as r, useEffect as i, useMemo as a, useRef as o, useState as s } from "react";
2
+ import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
3
+ import { METHOD_NOT_SUPPORTED as d, MISSING_REQUIRED_SCOPE as f, PLUGIN_ID_IS_NOT_CORRECT as p, PLUGIN_ID_OR_SLOT_NOT_PROVIDED as m, PluginActionError as h, UNKNOWN_ERROR as g, VALIDATION_ERROR as _, dispatchHostEvent as v, dispatchHostEvent as y, getField as b, getLocalizedString as x, getLocalizedString as S, hostApi as C, hostApi as w, on as T, on as E, setHandler as D, uiApi as O, uiApi as k } from "@weavix/sdk-core";
4
+ //#region src/components/ErrorBoundary.tsx
5
+ var A = class extends e {
6
+ static getDerivedStateFromError(e) {
7
+ return {
8
+ hasError: !0,
9
+ error: e
10
+ };
11
+ }
12
+ constructor(e) {
13
+ super(e), this.state = {
14
+ hasError: !1,
15
+ error: null
16
+ };
17
+ }
18
+ componentDidCatch(e, t) {
19
+ console.error("ErrorBoundary caught an error:", e, t);
20
+ }
21
+ render() {
22
+ return this.state.hasError && this.state.error ? this.props.fallback(this.state.error) : this.props.children;
23
+ }
24
+ }, j = ({ error: e }) => /* @__PURE__ */ l("div", {
25
+ className: "plugin-error",
26
+ children: /* @__PURE__ */ u("div", {
27
+ className: "plugin-error__container",
28
+ children: [
29
+ /* @__PURE__ */ u("div", {
30
+ className: "plugin-error__header",
31
+ children: [/* @__PURE__ */ u("svg", {
32
+ className: "plugin-error__icon",
33
+ width: "24",
34
+ height: "24",
35
+ viewBox: "0 0 24 24",
36
+ fill: "none",
37
+ children: [/* @__PURE__ */ l("circle", {
38
+ cx: "12",
39
+ cy: "12",
40
+ r: "10",
41
+ fill: "#f44336"
42
+ }), /* @__PURE__ */ l("path", {
43
+ d: "M12 7v6m0 4h.01",
44
+ stroke: "white",
45
+ strokeWidth: "2",
46
+ strokeLinecap: "round"
47
+ })]
48
+ }), /* @__PURE__ */ l("h3", {
49
+ className: "plugin-error__title",
50
+ children: "Ошибка инициализации плагина"
51
+ })]
52
+ }),
53
+ /* @__PURE__ */ l("div", {
54
+ className: "plugin-error__message",
55
+ children: "Не удалось инициализировать плагин. Проверьте параметры запуска и попробуйте перезагрузить страницу."
56
+ }),
57
+ /* @__PURE__ */ u("details", {
58
+ className: "plugin-error__details",
59
+ children: [/* @__PURE__ */ l("summary", {
60
+ className: "plugin-error__summary",
61
+ children: "Детали ошибки"
62
+ }), /* @__PURE__ */ u("pre", {
63
+ className: "plugin-error__stack",
64
+ children: [e.message, e.stack && `\n\n${e.stack}`]
65
+ })]
66
+ })
67
+ ]
68
+ })
69
+ }), M = () => /* @__PURE__ */ l("div", {
70
+ className: "plugin-loader",
71
+ children: /* @__PURE__ */ u("div", {
72
+ className: "plugin-loader__content",
73
+ children: [/* @__PURE__ */ l("div", { className: "plugin-loader__spinner" }), /* @__PURE__ */ l("div", {
74
+ className: "plugin-loader__text",
75
+ children: "Загрузка плагина..."
76
+ })]
77
+ })
78
+ });
79
+ //#endregion
80
+ //#region src/hooks/useContext.ts
81
+ function N() {
82
+ let [e, t] = s(() => {
83
+ let e;
84
+ return E("context.changed", (t) => {
85
+ e = t;
86
+ })(), e;
87
+ });
88
+ return i(() => E("context.changed", (e) => {
89
+ t(e);
90
+ }), []), e;
17
91
  }
18
- var ee = { exports: {} }, H = {};
19
- var Le;
20
- function Sr() {
21
- if (Le) return H;
22
- Le = 1;
23
- var u = Ye, a = /* @__PURE__ */ Symbol.for("react.element"), c = /* @__PURE__ */ Symbol.for("react.fragment"), f = Object.prototype.hasOwnProperty, _ = u.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, j = { key: !0, ref: !0, __self: !0, __source: !0 };
24
- function I(P, v, k) {
25
- var b, O = {}, w = null, C = null;
26
- k !== void 0 && (w = "" + k), v.key !== void 0 && (w = "" + v.key), v.ref !== void 0 && (C = v.ref);
27
- for (b in v) f.call(v, b) && !j.hasOwnProperty(b) && (O[b] = v[b]);
28
- if (P && P.defaultProps) for (b in v = P.defaultProps, v) O[b] === void 0 && (O[b] = v[b]);
29
- return { $$typeof: a, type: P, key: w, ref: C, props: O, _owner: _.current };
30
- }
31
- return H.Fragment = c, H.jsx = I, H.jsxs = I, H;
92
+ //#endregion
93
+ //#region src/hooks/useIsYateam.ts
94
+ function P() {
95
+ let [e, t] = s(void 0);
96
+ return i(() => {
97
+ (async () => {
98
+ t(await w.getIsYateam());
99
+ })();
100
+ }, []), e;
32
101
  }
33
- var G = {};
34
- var Fe;
35
- function jr() {
36
- return Fe || (Fe = 1, process.env.NODE_ENV !== "production" && (function() {
37
- var u = Ye, a = /* @__PURE__ */ Symbol.for("react.element"), c = /* @__PURE__ */ Symbol.for("react.portal"), f = /* @__PURE__ */ Symbol.for("react.fragment"), _ = /* @__PURE__ */ Symbol.for("react.strict_mode"), j = /* @__PURE__ */ Symbol.for("react.profiler"), I = /* @__PURE__ */ Symbol.for("react.provider"), P = /* @__PURE__ */ Symbol.for("react.context"), v = /* @__PURE__ */ Symbol.for("react.forward_ref"), k = /* @__PURE__ */ Symbol.for("react.suspense"), b = /* @__PURE__ */ Symbol.for("react.suspense_list"), O = /* @__PURE__ */ Symbol.for("react.memo"), w = /* @__PURE__ */ Symbol.for("react.lazy"), C = /* @__PURE__ */ Symbol.for("react.offscreen"), x = Symbol.iterator, $ = "@@iterator";
38
- function S(e) {
39
- if (e === null || typeof e != "object")
40
- return null;
41
- var r = x && e[x] || e[$];
42
- return typeof r == "function" ? r : null;
43
- }
44
- var y = u.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
45
- function h(e) {
46
- {
47
- for (var r = arguments.length, t = new Array(r > 1 ? r - 1 : 0), n = 1; n < r; n++)
48
- t[n - 1] = arguments[n];
49
- L("error", e, t);
50
- }
51
- }
52
- function L(e, r, t) {
53
- {
54
- var n = y.ReactDebugCurrentFrame, s = n.getStackAddendum();
55
- s !== "" && (r += "%s", t = t.concat([s]));
56
- var l = t.map(function(o) {
57
- return String(o);
58
- });
59
- l.unshift("Warning: " + r), Function.prototype.apply.call(console[e], console, l);
60
- }
61
- }
62
- var F = !1, B = !1, Ve = !1, qe = !1, Be = !1, ce;
63
- ce = /* @__PURE__ */ Symbol.for("react.module.reference");
64
- function ze(e) {
65
- return !!(typeof e == "string" || typeof e == "function" || e === f || e === j || Be || e === _ || e === k || e === b || qe || e === C || F || B || Ve || typeof e == "object" && e !== null && (e.$$typeof === w || e.$$typeof === O || e.$$typeof === I || e.$$typeof === P || e.$$typeof === v || // This needs to include all possible module reference object
66
- // types supported by any Flight configuration anywhere since
67
- // we don't know which Flight build this will end up being used
68
- // with.
69
- e.$$typeof === ce || e.getModuleId !== void 0));
70
- }
71
- function Je(e, r, t) {
72
- var n = e.displayName;
73
- if (n)
74
- return n;
75
- var s = r.displayName || r.name || "";
76
- return s !== "" ? t + "(" + s + ")" : t;
77
- }
78
- function fe(e) {
79
- return e.displayName || "Context";
80
- }
81
- function D(e) {
82
- if (e == null)
83
- return null;
84
- if (typeof e.tag == "number" && h("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function")
85
- return e.displayName || e.name || null;
86
- if (typeof e == "string")
87
- return e;
88
- switch (e) {
89
- case f:
90
- return "Fragment";
91
- case c:
92
- return "Portal";
93
- case j:
94
- return "Profiler";
95
- case _:
96
- return "StrictMode";
97
- case k:
98
- return "Suspense";
99
- case b:
100
- return "SuspenseList";
101
- }
102
- if (typeof e == "object")
103
- switch (e.$$typeof) {
104
- case P:
105
- var r = e;
106
- return fe(r) + ".Consumer";
107
- case I:
108
- var t = e;
109
- return fe(t._context) + ".Provider";
110
- case v:
111
- return Je(e, e.render, "ForwardRef");
112
- case O:
113
- var n = e.displayName || null;
114
- return n !== null ? n : D(e.type) || "Memo";
115
- case w: {
116
- var s = e, l = s._payload, o = s._init;
117
- try {
118
- return D(o(l));
119
- } catch {
120
- return null;
121
- }
122
- }
123
- }
124
- return null;
125
- }
126
- var N = Object.assign, z = 0, de, ve, ge, he, pe, me, be;
127
- function _e() {
128
- }
129
- _e.__reactDisabledLog = !0;
130
- function He() {
131
- {
132
- if (z === 0) {
133
- de = console.log, ve = console.info, ge = console.warn, he = console.error, pe = console.group, me = console.groupCollapsed, be = console.groupEnd;
134
- var e = {
135
- configurable: !0,
136
- enumerable: !0,
137
- value: _e,
138
- writable: !0
139
- };
140
- Object.defineProperties(console, {
141
- info: e,
142
- log: e,
143
- warn: e,
144
- error: e,
145
- group: e,
146
- groupCollapsed: e,
147
- groupEnd: e
148
- });
149
- }
150
- z++;
151
- }
152
- }
153
- function Ge() {
154
- {
155
- if (z--, z === 0) {
156
- var e = {
157
- configurable: !0,
158
- enumerable: !0,
159
- writable: !0
160
- };
161
- Object.defineProperties(console, {
162
- log: N({}, e, {
163
- value: de
164
- }),
165
- info: N({}, e, {
166
- value: ve
167
- }),
168
- warn: N({}, e, {
169
- value: ge
170
- }),
171
- error: N({}, e, {
172
- value: he
173
- }),
174
- group: N({}, e, {
175
- value: pe
176
- }),
177
- groupCollapsed: N({}, e, {
178
- value: me
179
- }),
180
- groupEnd: N({}, e, {
181
- value: be
182
- })
183
- });
184
- }
185
- z < 0 && h("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
186
- }
187
- }
188
- var re = y.ReactCurrentDispatcher, te;
189
- function K(e, r, t) {
190
- {
191
- if (te === void 0)
192
- try {
193
- throw Error();
194
- } catch (s) {
195
- var n = s.stack.trim().match(/\n( *(at )?)/);
196
- te = n && n[1] || "";
197
- }
198
- return `
199
- ` + te + e;
200
- }
201
- }
202
- var ne = !1, X;
203
- {
204
- var Ke = typeof WeakMap == "function" ? WeakMap : Map;
205
- X = new Ke();
206
- }
207
- function ye(e, r) {
208
- if (!e || ne)
209
- return "";
210
- {
211
- var t = X.get(e);
212
- if (t !== void 0)
213
- return t;
214
- }
215
- var n;
216
- ne = !0;
217
- var s = Error.prepareStackTrace;
218
- Error.prepareStackTrace = void 0;
219
- var l;
220
- l = re.current, re.current = null, He();
221
- try {
222
- if (r) {
223
- var o = function() {
224
- throw Error();
225
- };
226
- if (Object.defineProperty(o.prototype, "props", {
227
- set: function() {
228
- throw Error();
229
- }
230
- }), typeof Reflect == "object" && Reflect.construct) {
231
- try {
232
- Reflect.construct(o, []);
233
- } catch (R) {
234
- n = R;
235
- }
236
- Reflect.construct(e, [], o);
237
- } else {
238
- try {
239
- o.call();
240
- } catch (R) {
241
- n = R;
242
- }
243
- e.call(o.prototype);
244
- }
245
- } else {
246
- try {
247
- throw Error();
248
- } catch (R) {
249
- n = R;
250
- }
251
- e();
252
- }
253
- } catch (R) {
254
- if (R && n && typeof R.stack == "string") {
255
- for (var i = R.stack.split(`
256
- `), E = n.stack.split(`
257
- `), g = i.length - 1, p = E.length - 1; g >= 1 && p >= 0 && i[g] !== E[p]; )
258
- p--;
259
- for (; g >= 1 && p >= 0; g--, p--)
260
- if (i[g] !== E[p]) {
261
- if (g !== 1 || p !== 1)
262
- do
263
- if (g--, p--, p < 0 || i[g] !== E[p]) {
264
- var T = `
265
- ` + i[g].replace(" at new ", " at ");
266
- return e.displayName && T.includes("<anonymous>") && (T = T.replace("<anonymous>", e.displayName)), typeof e == "function" && X.set(e, T), T;
267
- }
268
- while (g >= 1 && p >= 0);
269
- break;
270
- }
271
- }
272
- } finally {
273
- ne = !1, re.current = l, Ge(), Error.prepareStackTrace = s;
274
- }
275
- var W = e ? e.displayName || e.name : "", U = W ? K(W) : "";
276
- return typeof e == "function" && X.set(e, U), U;
277
- }
278
- function Xe(e, r, t) {
279
- return ye(e, !1);
280
- }
281
- function Qe(e) {
282
- var r = e.prototype;
283
- return !!(r && r.isReactComponent);
284
- }
285
- function Q(e, r, t) {
286
- if (e == null)
287
- return "";
288
- if (typeof e == "function")
289
- return ye(e, Qe(e));
290
- if (typeof e == "string")
291
- return K(e);
292
- switch (e) {
293
- case k:
294
- return K("Suspense");
295
- case b:
296
- return K("SuspenseList");
297
- }
298
- if (typeof e == "object")
299
- switch (e.$$typeof) {
300
- case v:
301
- return Xe(e.render);
302
- case O:
303
- return Q(e.type, r, t);
304
- case w: {
305
- var n = e, s = n._payload, l = n._init;
306
- try {
307
- return Q(l(s), r, t);
308
- } catch {
309
- }
310
- }
311
- }
312
- return "";
313
- }
314
- var J = Object.prototype.hasOwnProperty, Ee = {}, Re = y.ReactDebugCurrentFrame;
315
- function Z(e) {
316
- if (e) {
317
- var r = e._owner, t = Q(e.type, e._source, r ? r.type : null);
318
- Re.setExtraStackFrame(t);
319
- } else
320
- Re.setExtraStackFrame(null);
321
- }
322
- function Ze(e, r, t, n, s) {
323
- {
324
- var l = Function.call.bind(J);
325
- for (var o in e)
326
- if (l(e, o)) {
327
- var i = void 0;
328
- try {
329
- if (typeof e[o] != "function") {
330
- var E = Error((n || "React class") + ": " + t + " type `" + o + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[o] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
331
- throw E.name = "Invariant Violation", E;
332
- }
333
- i = e[o](r, o, n, t, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
334
- } catch (g) {
335
- i = g;
336
- }
337
- i && !(i instanceof Error) && (Z(s), h("%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).", n || "React class", t, o, typeof i), Z(null)), i instanceof Error && !(i.message in Ee) && (Ee[i.message] = !0, Z(s), h("Failed %s type: %s", t, i.message), Z(null));
338
- }
339
- }
340
- }
341
- var er = Array.isArray;
342
- function ae(e) {
343
- return er(e);
344
- }
345
- function rr(e) {
346
- {
347
- var r = typeof Symbol == "function" && Symbol.toStringTag, t = r && e[Symbol.toStringTag] || e.constructor.name || "Object";
348
- return t;
349
- }
350
- }
351
- function tr(e) {
352
- try {
353
- return xe(e), !1;
354
- } catch {
355
- return !0;
356
- }
357
- }
358
- function xe(e) {
359
- return "" + e;
360
- }
361
- function Pe(e) {
362
- if (tr(e))
363
- return h("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", rr(e)), xe(e);
364
- }
365
- var Ce = y.ReactCurrentOwner, nr = {
366
- key: !0,
367
- ref: !0,
368
- __self: !0,
369
- __source: !0
370
- }, Te, Oe;
371
- function ar(e) {
372
- if (J.call(e, "ref")) {
373
- var r = Object.getOwnPropertyDescriptor(e, "ref").get;
374
- if (r && r.isReactWarning)
375
- return !1;
376
- }
377
- return e.ref !== void 0;
378
- }
379
- function ir(e) {
380
- if (J.call(e, "key")) {
381
- var r = Object.getOwnPropertyDescriptor(e, "key").get;
382
- if (r && r.isReactWarning)
383
- return !1;
384
- }
385
- return e.key !== void 0;
386
- }
387
- function or(e, r) {
388
- typeof e.ref == "string" && Ce.current;
389
- }
390
- function sr(e, r) {
391
- {
392
- var t = function() {
393
- Te || (Te = !0, h("%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)", r));
394
- };
395
- t.isReactWarning = !0, Object.defineProperty(e, "key", {
396
- get: t,
397
- configurable: !0
398
- });
399
- }
400
- }
401
- function ur(e, r) {
402
- {
403
- var t = function() {
404
- Oe || (Oe = !0, h("%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)", r));
405
- };
406
- t.isReactWarning = !0, Object.defineProperty(e, "ref", {
407
- get: t,
408
- configurable: !0
409
- });
410
- }
411
- }
412
- var lr = function(e, r, t, n, s, l, o) {
413
- var i = {
414
- // This tag allows us to uniquely identify this as a React Element
415
- $$typeof: a,
416
- // Built-in properties that belong on the element
417
- type: e,
418
- key: r,
419
- ref: t,
420
- props: o,
421
- // Record the component responsible for creating this element.
422
- _owner: l
423
- };
424
- return i._store = {}, Object.defineProperty(i._store, "validated", {
425
- configurable: !1,
426
- enumerable: !1,
427
- writable: !0,
428
- value: !1
429
- }), Object.defineProperty(i, "_self", {
430
- configurable: !1,
431
- enumerable: !1,
432
- writable: !1,
433
- value: n
434
- }), Object.defineProperty(i, "_source", {
435
- configurable: !1,
436
- enumerable: !1,
437
- writable: !1,
438
- value: s
439
- }), Object.freeze && (Object.freeze(i.props), Object.freeze(i)), i;
440
- };
441
- function cr(e, r, t, n, s) {
442
- {
443
- var l, o = {}, i = null, E = null;
444
- t !== void 0 && (Pe(t), i = "" + t), ir(r) && (Pe(r.key), i = "" + r.key), ar(r) && (E = r.ref, or(r, s));
445
- for (l in r)
446
- J.call(r, l) && !nr.hasOwnProperty(l) && (o[l] = r[l]);
447
- if (e && e.defaultProps) {
448
- var g = e.defaultProps;
449
- for (l in g)
450
- o[l] === void 0 && (o[l] = g[l]);
451
- }
452
- if (i || E) {
453
- var p = typeof e == "function" ? e.displayName || e.name || "Unknown" : e;
454
- i && sr(o, p), E && ur(o, p);
455
- }
456
- return lr(e, i, E, s, n, Ce.current, o);
457
- }
458
- }
459
- var ie = y.ReactCurrentOwner, we = y.ReactDebugCurrentFrame;
460
- function M(e) {
461
- if (e) {
462
- var r = e._owner, t = Q(e.type, e._source, r ? r.type : null);
463
- we.setExtraStackFrame(t);
464
- } else
465
- we.setExtraStackFrame(null);
466
- }
467
- var oe;
468
- oe = !1;
469
- function se(e) {
470
- return typeof e == "object" && e !== null && e.$$typeof === a;
471
- }
472
- function Se() {
473
- {
474
- if (ie.current) {
475
- var e = D(ie.current.type);
476
- if (e)
477
- return `
478
-
479
- Check the render method of \`` + e + "`.";
480
- }
481
- return "";
482
- }
483
- }
484
- function fr(e) {
485
- return "";
486
- }
487
- var je = {};
488
- function dr(e) {
489
- {
490
- var r = Se();
491
- if (!r) {
492
- var t = typeof e == "string" ? e : e.displayName || e.name;
493
- t && (r = `
494
-
495
- Check the top-level render call using <` + t + ">.");
496
- }
497
- return r;
498
- }
499
- }
500
- function Ie(e, r) {
501
- {
502
- if (!e._store || e._store.validated || e.key != null)
503
- return;
504
- e._store.validated = !0;
505
- var t = dr(r);
506
- if (je[t])
507
- return;
508
- je[t] = !0;
509
- var n = "";
510
- e && e._owner && e._owner !== ie.current && (n = " It was passed a child from " + D(e._owner.type) + "."), M(e), h('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', t, n), M(null);
511
- }
512
- }
513
- function ke(e, r) {
514
- {
515
- if (typeof e != "object")
516
- return;
517
- if (ae(e))
518
- for (var t = 0; t < e.length; t++) {
519
- var n = e[t];
520
- se(n) && Ie(n, r);
521
- }
522
- else if (se(e))
523
- e._store && (e._store.validated = !0);
524
- else if (e) {
525
- var s = S(e);
526
- if (typeof s == "function" && s !== e.entries)
527
- for (var l = s.call(e), o; !(o = l.next()).done; )
528
- se(o.value) && Ie(o.value, r);
529
- }
530
- }
531
- }
532
- function vr(e) {
533
- {
534
- var r = e.type;
535
- if (r == null || typeof r == "string")
536
- return;
537
- var t;
538
- if (typeof r == "function")
539
- t = r.propTypes;
540
- else if (typeof r == "object" && (r.$$typeof === v || // Note: Memo only checks outer props here.
541
- // Inner props are checked in the reconciler.
542
- r.$$typeof === O))
543
- t = r.propTypes;
544
- else
545
- return;
546
- if (t) {
547
- var n = D(r);
548
- Ze(t, e.props, "prop", n, e);
549
- } else if (r.PropTypes !== void 0 && !oe) {
550
- oe = !0;
551
- var s = D(r);
552
- h("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", s || "Unknown");
553
- }
554
- typeof r.getDefaultProps == "function" && !r.getDefaultProps.isReactClassApproved && h("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
555
- }
556
- }
557
- function gr(e) {
558
- {
559
- for (var r = Object.keys(e.props), t = 0; t < r.length; t++) {
560
- var n = r[t];
561
- if (n !== "children" && n !== "key") {
562
- M(e), h("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", n), M(null);
563
- break;
564
- }
565
- }
566
- e.ref !== null && (M(e), h("Invalid attribute `ref` supplied to `React.Fragment`."), M(null));
567
- }
568
- }
569
- var De = {};
570
- function Ae(e, r, t, n, s, l) {
571
- {
572
- var o = ze(e);
573
- if (!o) {
574
- var i = "";
575
- (e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (i += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
576
- var E = fr();
577
- E ? i += E : i += Se();
578
- var g;
579
- e === null ? g = "null" : ae(e) ? g = "array" : e !== void 0 && e.$$typeof === a ? (g = "<" + (D(e.type) || "Unknown") + " />", i = " Did you accidentally export a JSX literal instead of a component?") : g = typeof e, h("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", g, i);
580
- }
581
- var p = cr(e, r, t, s, l);
582
- if (p == null)
583
- return p;
584
- if (o) {
585
- var T = r.children;
586
- if (T !== void 0)
587
- if (n)
588
- if (ae(T)) {
589
- for (var W = 0; W < T.length; W++)
590
- ke(T[W], e);
591
- Object.freeze && Object.freeze(T);
592
- } else
593
- h("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
594
- else
595
- ke(T, e);
596
- }
597
- if (J.call(r, "key")) {
598
- var U = D(e), R = Object.keys(r).filter(function(yr) {
599
- return yr !== "key";
600
- }), ue = R.length > 0 ? "{key: someKey, " + R.join(": ..., ") + ": ...}" : "{key: someKey}";
601
- if (!De[U + ue]) {
602
- var _r = R.length > 0 ? "{" + R.join(": ..., ") + ": ...}" : "{}";
603
- h(`A props object containing a "key" prop is being spread into JSX:
604
- let props = %s;
605
- <%s {...props} />
606
- React keys must be passed directly to JSX without using spread:
607
- let props = %s;
608
- <%s key={someKey} {...props} />`, ue, U, _r, U), De[U + ue] = !0;
609
- }
610
- }
611
- return e === f ? gr(p) : vr(p), p;
612
- }
613
- }
614
- function hr(e, r, t) {
615
- return Ae(e, r, t, !0);
616
- }
617
- function pr(e, r, t) {
618
- return Ae(e, r, t, !1);
619
- }
620
- var mr = pr, br = hr;
621
- G.Fragment = f, G.jsx = mr, G.jsxs = br;
622
- })()), G;
623
- }
624
- var Ne;
625
- function Ir() {
626
- return Ne || (Ne = 1, process.env.NODE_ENV === "production" ? ee.exports = Sr() : ee.exports = jr()), ee.exports;
627
- }
628
- var d = Ir();
629
- const kr = ({ error: u }) => /* @__PURE__ */ d.jsx("div", { className: "plugin-error", children: /* @__PURE__ */ d.jsxs("div", { className: "plugin-error__container", children: [
630
- /* @__PURE__ */ d.jsxs("div", { className: "plugin-error__header", children: [
631
- /* @__PURE__ */ d.jsxs(
632
- "svg",
633
- {
634
- className: "plugin-error__icon",
635
- width: "24",
636
- height: "24",
637
- viewBox: "0 0 24 24",
638
- fill: "none",
639
- children: [
640
- /* @__PURE__ */ d.jsx("circle", { cx: "12", cy: "12", r: "10", fill: "#f44336" }),
641
- /* @__PURE__ */ d.jsx(
642
- "path",
643
- {
644
- d: "M12 7v6m0 4h.01",
645
- stroke: "white",
646
- strokeWidth: "2",
647
- strokeLinecap: "round"
648
- }
649
- )
650
- ]
651
- }
652
- ),
653
- /* @__PURE__ */ d.jsx("h3", { className: "plugin-error__title", children: "Ошибка инициализации плагина" })
654
- ] }),
655
- /* @__PURE__ */ d.jsx("div", { className: "plugin-error__message", children: "Не удалось инициализировать плагин. Проверьте параметры запуска и попробуйте перезагрузить страницу." }),
656
- /* @__PURE__ */ d.jsxs("details", { className: "plugin-error__details", children: [
657
- /* @__PURE__ */ d.jsx("summary", { className: "plugin-error__summary", children: "Детали ошибки" }),
658
- /* @__PURE__ */ d.jsxs("pre", { className: "plugin-error__stack", children: [
659
- u.message,
660
- u.stack && `
661
-
662
- ${u.stack}`
663
- ] })
664
- ] })
665
- ] }) }), Ue = kr, Dr = () => /* @__PURE__ */ d.jsx("div", { className: "plugin-loader", children: /* @__PURE__ */ d.jsxs("div", { className: "plugin-loader__content", children: [
666
- /* @__PURE__ */ d.jsx("div", { className: "plugin-loader__spinner" }),
667
- /* @__PURE__ */ d.jsx("div", { className: "plugin-loader__text", children: "Загрузка плагина..." })
668
- ] }) }), qr = Dr;
669
- function Ar() {
670
- const [u, a] = A(() => {
671
- let c;
672
- return q("context.changed", (_) => {
673
- c = _;
674
- })(), c;
675
- });
676
- return Y(() => q("context.changed", (f) => {
677
- a(f);
678
- }), []), u;
102
+ //#endregion
103
+ //#region src/hooks/useLanguage.ts
104
+ function F() {
105
+ let [e, t] = s(() => {
106
+ let e;
107
+ return E("language.changed", (t) => {
108
+ e = t;
109
+ })(), e;
110
+ });
111
+ return i(() => E("language.changed", (e) => {
112
+ t(e);
113
+ }), []), e;
679
114
  }
680
- function Lr() {
681
- const [u, a] = A(void 0);
682
- return Y(() => {
683
- (async () => {
684
- const f = await m.getIsYateam();
685
- a(f);
686
- })();
687
- }, []), u;
115
+ //#endregion
116
+ //#region src/hooks/useTheme.ts
117
+ function I() {
118
+ let [e, t] = s(() => {
119
+ let e;
120
+ return E("theme.changed", (t) => {
121
+ e = t;
122
+ })(), e;
123
+ });
124
+ return i(() => E("theme.changed", (e) => {
125
+ t(e);
126
+ }), []), e;
688
127
  }
689
- function Me() {
690
- const [u, a] = A(() => {
691
- let c;
692
- return q("language.changed", (_) => {
693
- c = _;
694
- })(), c;
695
- });
696
- return Y(() => q("language.changed", (f) => {
697
- a(f);
698
- }), []), u;
128
+ //#endregion
129
+ //#region src/hooks/useUserId.ts
130
+ function L() {
131
+ let [e, t] = s(void 0);
132
+ return i(() => {
133
+ (async () => {
134
+ t(await w.getUserId());
135
+ })();
136
+ }, []), e;
699
137
  }
700
- function Fr() {
701
- const [u, a] = A(() => {
702
- let c;
703
- return q("theme.changed", (_) => {
704
- c = _;
705
- })(), c;
706
- });
707
- return Y(() => q("theme.changed", (f) => {
708
- a(f);
709
- }), []), u;
138
+ //#endregion
139
+ //#region src/components/PluginProvider.tsx
140
+ var R = t(null);
141
+ function z(e = "basic") {
142
+ let t = r(R);
143
+ if (!t) throw Error("usePluginContext must be used within PluginProvider");
144
+ if (e === "full" && t.contextLevel !== "full") throw Error("🛑 [Security] Code requests 'full' context, but manifest declares 'basic'. Change the contextLevel in your manifest to get full access.");
145
+ let n = I(), i = F(), a = P(), o = L(), s = N(), c = {
146
+ service: w.getService(),
147
+ origin: w.getOrigin(),
148
+ slot: t.slot,
149
+ innerUrl: t.innerUrl,
150
+ queryParams: t.queryParams,
151
+ registerHandler: t.registerHandler,
152
+ theme: n,
153
+ language: i,
154
+ isYateam: a,
155
+ userId: o
156
+ };
157
+ if (e === "basic") {
158
+ let e = t.entityId ? {
159
+ entityId: t.entityId,
160
+ ...t.entityMeta ? { entityMeta: t.entityMeta } : {}
161
+ } : void 0;
162
+ return {
163
+ ...c,
164
+ contextLevel: "basic",
165
+ slotContext: e
166
+ };
167
+ }
168
+ return {
169
+ ...c,
170
+ contextLevel: "full",
171
+ slotContext: s
172
+ };
710
173
  }
711
- function Nr() {
712
- const [u, a] = A(void 0);
713
- return Y(() => {
714
- (async () => {
715
- const f = await m.getUserId();
716
- a(f);
717
- })();
718
- }, []), u;
719
- }
720
- const We = Rr(null);
721
- function Br(u = "basic") {
722
- const a = Cr(We);
723
- if (!a)
724
- throw new Error("usePluginContext must be used within PluginProvider");
725
- if (u === "full" && a.contextLevel !== "full")
726
- throw new Error(
727
- "🛑 [Security] Code requests 'full' context, but manifest declares 'basic'. Change the contextLevel in your manifest to get full access."
728
- );
729
- const c = Fr(), f = Me(), _ = Lr(), j = Nr(), I = Ar(), P = {
730
- service: m.getService(),
731
- origin: m.getOrigin(),
732
- slot: a.slot,
733
- innerUrl: a.innerUrl,
734
- queryParams: a.queryParams,
735
- registerHandler: a.registerHandler,
736
- theme: c,
737
- language: f,
738
- isYateam: _,
739
- userId: j
740
- };
741
- if (u === "basic") {
742
- const v = a.entityId ? { entityId: a.entityId, ...a.entityMeta ? { entityMeta: a.entityMeta } : {} } : void 0;
743
- return {
744
- ...P,
745
- contextLevel: "basic",
746
- slotContext: v
747
- };
748
- }
749
- return {
750
- ...P,
751
- contextLevel: "full",
752
- slotContext: I
753
- };
754
- }
755
- const Ur = (u) => {
756
- try {
757
- return new URL(u, window.location.href).origin === window.location.origin;
758
- } catch {
759
- return !0;
760
- }
174
+ var B = (e) => {
175
+ try {
176
+ return new URL(e, window.location.href).origin === window.location.origin;
177
+ } catch {
178
+ return !0;
179
+ }
761
180
  };
762
- function zr({
763
- children: u,
764
- autoResize: a = !0,
765
- fallback: c,
766
- errorFallback: f,
767
- autoNotifyReady: _ = !0
768
- }) {
769
- const j = xr(!1), [I, P] = A(!1), [v, k] = A(null), [b, O] = A(null), w = Pr(() => (C, x) => Tr(C, x), []);
770
- return Y(() => {
771
- const C = (x) => {
772
- const S = x.target.closest("[href], [data-href]");
773
- if (!S) return;
774
- const y = S.getAttribute("href") || S.getAttribute("data-href");
775
- if (!y || Ur(y))
776
- return;
777
- x.preventDefault();
778
- const L = S.getAttribute("target") === "_blank";
779
- le.navigate({
780
- path: y,
781
- options: {
782
- newTab: L
783
- }
784
- }).then(() => {
785
- console.info(`Navigation: ${y}`);
786
- }).catch((F) => {
787
- console.error("Navigation error:", F);
788
- });
789
- };
790
- return document.addEventListener("click", C), () => {
791
- document.removeEventListener("click", C);
792
- };
793
- }, []), Y(() => {
794
- if (j.current)
795
- return;
796
- (async () => {
797
- try {
798
- m.init({ autoResize: a }), j.current = !0;
799
- const x = m.getContextLevel(), $ = m.getEntityId(), S = m.getEntityMeta();
800
- O({
801
- slot: m.getSlot(),
802
- innerUrl: m.getInnerUrl(),
803
- queryParams: m.getQueryParams(),
804
- contextLevel: x,
805
- entityId: $,
806
- entityMeta: S,
807
- registerHandler: w
808
- }), _ && await m.notifyReady();
809
- const [y, h, L, F, B] = await Promise.allSettled([
810
- m.getTheme(),
811
- m.getLanguage(),
812
- x === "full" ? m.getContext() : Promise.resolve(null),
813
- m.getIsYateam(),
814
- m.getUserId()
815
- ]);
816
- y.status === "fulfilled" && y.value && V({
817
- messageId: "",
818
- type: "event",
819
- method: "theme.changed",
820
- result: y.value
821
- }), h.status === "fulfilled" && h.value && V({
822
- messageId: "",
823
- type: "event",
824
- method: "language.changed",
825
- result: h.value
826
- }), F.status === "fulfilled" && F.value && V({
827
- messageId: "",
828
- type: "event",
829
- method: "isYateam.changed",
830
- result: F.value
831
- }), B.status === "fulfilled" && B.value && V({
832
- messageId: "",
833
- type: "event",
834
- method: "userId.changed",
835
- result: B.value
836
- }), x === "basic" ? $ && V({
837
- messageId: "",
838
- type: "event",
839
- method: "context.changed",
840
- result: { entityId: $, ...S ? { entityMeta: S } : {} }
841
- }) : L.status === "fulfilled" && L.value && V({
842
- messageId: "",
843
- type: "event",
844
- method: "context.changed",
845
- result: L.value
846
- }), P(!0);
847
- } catch (x) {
848
- k(x);
849
- }
850
- })();
851
- }, [a, w, _]), v ? f ? /* @__PURE__ */ d.jsx(d.Fragment, { children: f(v) }) : /* @__PURE__ */ d.jsx(Ue, { error: v }) : !I || !b ? /* @__PURE__ */ d.jsx(d.Fragment, { children: c }) : /* @__PURE__ */ d.jsx(
852
- wr,
853
- {
854
- fallback: f || ((C) => /* @__PURE__ */ d.jsx(Ue, { error: C })),
855
- children: /* @__PURE__ */ d.jsx(We.Provider, { value: b, children: u })
856
- }
857
- );
181
+ function V({ children: e, autoResize: t = !0, fallback: n, errorFallback: r, autoNotifyReady: u = !0 }) {
182
+ let d = o(!1), [f, p] = s(!1), [m, h] = s(null), [g, _] = s(null), v = a(() => (e, t) => D(e, t), []);
183
+ return i(() => {
184
+ let e = (e) => {
185
+ let t = e.target.closest("[href], [data-href]");
186
+ if (!t) return;
187
+ let n = t.getAttribute("href") || t.getAttribute("data-href");
188
+ if (!n || B(n)) return;
189
+ e.preventDefault();
190
+ let r = t.getAttribute("target") === "_blank";
191
+ k.navigate({
192
+ path: n,
193
+ options: { newTab: r }
194
+ }).then(() => {
195
+ console.info(`Navigation: ${n}`);
196
+ }).catch((e) => {
197
+ console.error("Navigation error:", e);
198
+ });
199
+ };
200
+ return document.addEventListener("click", e), () => {
201
+ document.removeEventListener("click", e);
202
+ };
203
+ }, []), i(() => {
204
+ d.current || (async () => {
205
+ try {
206
+ w.init({ autoResize: t }), d.current = !0;
207
+ let e = w.getContextLevel(), n = w.getEntityId(), r = w.getEntityMeta();
208
+ _({
209
+ slot: w.getSlot(),
210
+ innerUrl: w.getInnerUrl(),
211
+ queryParams: w.getQueryParams(),
212
+ contextLevel: e,
213
+ entityId: n,
214
+ entityMeta: r,
215
+ registerHandler: v
216
+ }), u && await w.notifyReady();
217
+ let [i, a, o, s, c] = await Promise.allSettled([
218
+ w.getTheme(),
219
+ w.getLanguage(),
220
+ e === "full" ? w.getContext() : Promise.resolve(null),
221
+ w.getIsYateam(),
222
+ w.getUserId()
223
+ ]);
224
+ i.status === "fulfilled" && i.value && y({
225
+ messageId: "",
226
+ type: "event",
227
+ method: "theme.changed",
228
+ result: i.value
229
+ }), a.status === "fulfilled" && a.value && y({
230
+ messageId: "",
231
+ type: "event",
232
+ method: "language.changed",
233
+ result: a.value
234
+ }), s.status === "fulfilled" && s.value && y({
235
+ messageId: "",
236
+ type: "event",
237
+ method: "isYateam.changed",
238
+ result: s.value
239
+ }), c.status === "fulfilled" && c.value && y({
240
+ messageId: "",
241
+ type: "event",
242
+ method: "userId.changed",
243
+ result: c.value
244
+ }), e === "basic" ? n && y({
245
+ messageId: "",
246
+ type: "event",
247
+ method: "context.changed",
248
+ result: {
249
+ entityId: n,
250
+ ...r ? { entityMeta: r } : {}
251
+ }
252
+ }) : o.status === "fulfilled" && o.value && y({
253
+ messageId: "",
254
+ type: "event",
255
+ method: "context.changed",
256
+ result: o.value
257
+ }), p(!0);
258
+ } catch (e) {
259
+ h(e);
260
+ }
261
+ })();
262
+ }, [
263
+ t,
264
+ v,
265
+ u
266
+ ]), m ? r ? /* @__PURE__ */ l(c, { children: r(m) }) : /* @__PURE__ */ l(j, { error: m }) : !f || !g ? /* @__PURE__ */ l(c, { children: n }) : /* @__PURE__ */ l(A, {
267
+ fallback: r || ((e) => /* @__PURE__ */ l(j, { error: e })),
268
+ children: /* @__PURE__ */ l(R.Provider, {
269
+ value: g,
270
+ children: e
271
+ })
272
+ });
858
273
  }
859
- const Yr = () => ({ show: $e((a) => le.confirm.show(a), []) }), Jr = Yr, $r = (u = "ru") => {
860
- const a = Me();
861
- return (c) => Or(c, a, u);
862
- }, Hr = $r, Mr = () => ({ add: $e((a) => le.toaster.add(a), []) }), Gr = Mr;
863
- export {
864
- wr as ErrorBoundary,
865
- Qr as METHOD_NOT_SUPPORTED,
866
- Zr as MISSING_REQUIRED_SCOPE,
867
- et as PLUGIN_ID_IS_NOT_CORRECT,
868
- rt as PLUGIN_ID_OR_SLOT_NOT_PROVIDED,
869
- tt as PluginActionError,
870
- Ue as PluginError,
871
- qr as PluginLoader,
872
- zr as PluginProvider,
873
- nt as UNKNOWN_ERROR,
874
- at as VALIDATION_ERROR,
875
- it as dispatchHostEvent,
876
- ot as getField,
877
- st as getLocalizedString,
878
- ut as hostApi,
879
- Ur as isInternalUrl,
880
- lt as on,
881
- ct as uiApi,
882
- Jr as useConfirm,
883
- Lr as useIsYateam,
884
- Me as useLanguage,
885
- Hr as useLocalizedString,
886
- Br as usePluginContext,
887
- Fr as useTheme,
888
- Gr as useToaster,
889
- Nr as useUserId
890
- };
891
- //# sourceMappingURL=index.mjs.map
274
+ var H = () => ({ show: n((e) => k.confirm.show(e), []) }), U = (e = "ru") => {
275
+ let t = F();
276
+ return (n) => S(n, t, e);
277
+ }, W = () => ({ add: n((e) => k.toaster.add(e), []) });
278
+ //#endregion
279
+ export { A as ErrorBoundary, d as METHOD_NOT_SUPPORTED, f as MISSING_REQUIRED_SCOPE, p as PLUGIN_ID_IS_NOT_CORRECT, m as PLUGIN_ID_OR_SLOT_NOT_PROVIDED, h as PluginActionError, j as PluginError, M as PluginLoader, V as PluginProvider, g as UNKNOWN_ERROR, _ as VALIDATION_ERROR, v as dispatchHostEvent, b as getField, x as getLocalizedString, C as hostApi, B as isInternalUrl, T as on, O as uiApi, H as useConfirm, P as useIsYateam, F as useLanguage, U as useLocalizedString, z as usePluginContext, I as useTheme, W as useToaster, L as useUserId };
280
+
281
+ //# sourceMappingURL=index.mjs.map