@yourgoods/ui-smart 0.24.0 → 0.25.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.
@@ -1,782 +0,0 @@
1
- import { defineComponent as te, ref as b, reactive as Q, watch as Y, computed as M, toRefs as re, createElementBlock as k, openBlock as E, createElementVNode as S, createCommentVNode as D, toDisplayString as X, createVNode as $, unref as u, isRef as Z, withCtx as G, createTextVNode as ae, Fragment as Oe, createBlock as H, resolveDynamicComponent as Ce, onMounted as Ue } from "vue";
2
- import { T as ue, c as Ve, u as Ae, a as Fe, P as ye, b as Re } from "./useRateLimitToast-BSzwSahA.js";
3
- import { C as A, _ as ze, B as We, p as W, g as He } from "./index-BMP0GdRz.js";
4
- import { PInput as J, IconMailMd as me, PButton as oe, IconEyeMd as ge, IconEyeClosedMd as he, PDialog as _e, PTopBar as qe, IconCrossMd as je } from "@profeat/ui-kit";
5
- const Ge = { class: "dialogDefaultContainerInsideContent" }, Ye = { class: "dialogDefaultContainerTextHint" }, Je = {
6
- key: 0,
7
- class: "input-wrapper"
8
- }, Ke = {
9
- key: 1,
10
- class: "input-wrapper"
11
- }, Qe = {
12
- key: 2,
13
- class: "input-wrapper"
14
- }, Xe = { key: 3 }, Ze = /* @__PURE__ */ te({
15
- __name: "AddNewEmailContent",
16
- props: {
17
- email: {},
18
- oldEmail: {},
19
- hintText: { default: "" },
20
- emailError: { default: "" },
21
- codeError: { default: "" },
22
- rateLimitText: { default: "" },
23
- showEmail: { type: Boolean, default: !0 },
24
- isFinalLimit: { type: Boolean },
25
- isNotMatchCode: { type: Boolean },
26
- loading: { type: Boolean }
27
- },
28
- emits: ["update:email", "update:code", "edit", "on-match-code", "on-match-code-error", "on-send-code", "on-send-code-again", "on-clear-code-error"],
29
- setup(_, { emit: F }) {
30
- const v = _, s = F, m = b(!1), e = b(""), i = Q({
31
- emailModel: v.email || "",
32
- codeModel: "",
33
- touched: { email: !1, code: !1 }
34
- });
35
- Y(
36
- () => i.emailModel,
37
- (p) => {
38
- s("update:email", p);
39
- }
40
- ), Y(
41
- () => i.codeModel,
42
- (p) => s("update:code", p)
43
- );
44
- const y = (p) => {
45
- i.touched[p] = !0;
46
- }, d = (p) => i.touched[p] = !1, r = () => {
47
- e.value = "", d("email");
48
- }, V = M(() => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.emailModel.trim())), N = M(() => !V.value || !!e.value), B = async () => {
49
- var n;
50
- if (y("email"), !V.value) {
51
- e.value = "Это не похоже на e-mail";
52
- return;
53
- }
54
- const {
55
- data: { data: p }
56
- } = await Ve(i.emailModel);
57
- if (!(((n = p == null ? void 0 : p[0]) == null ? void 0 : n.available) ?? !1)) {
58
- e.value = "Такой email уже используется";
59
- return;
60
- }
61
- e.value = "", s("on-send-code", {
62
- email: i.emailModel,
63
- prevEmail: v.oldEmail,
64
- offLoading: !0
65
- }), m.value = !0;
66
- };
67
- let O = "";
68
- const w = (p) => {
69
- s("on-clear-code-error");
70
- const l = p.target;
71
- let n = l.value.replace(/\D/g, "");
72
- n.length > 4 && (n = n.slice(0, 4)), l.value = n, i.codeModel = n, n.length === 4 && n !== O && (O = n, s("on-match-code", { email: i.emailModel, code: n }));
73
- }, c = () => {
74
- s("on-send-code-again", { email: i.emailModel });
75
- }, T = M(() => {
76
- if (e.value) return e.value;
77
- if (i.touched.email) {
78
- if (!i.emailModel.trim()) return "Введите e-mail";
79
- if (!V.value) return "Это не похоже на e-mail";
80
- }
81
- return v.emailError || "";
82
- }), g = M(() => v.isNotMatchCode ? "Неверный код" : i.touched.code ? U.value.trim() ? v.codeError ?? null : "Введите код" : ""), { emailModel: L, codeModel: U } = re(i);
83
- return (p, l) => {
84
- const n = ue;
85
- return E(), k("div", Ge, [
86
- S("div", Ye, X(m.value ? "Введите код подтверждения" : p.hintText), 1),
87
- p.showEmail ? (E(), k("div", Je, [
88
- $(u(J), {
89
- modelValue: u(L),
90
- "onUpdate:modelValue": l[0] || (l[0] = (C) => Z(L) ? L.value = C : null),
91
- size: "large",
92
- "text-size": "medium",
93
- label: "Почта",
94
- type: "email",
95
- error: T.value,
96
- onBlur: l[1] || (l[1] = (C) => y("email")),
97
- onInput: r
98
- }, null, 8, ["modelValue", "error"]),
99
- $(u(me), {
100
- class: "icon-locked",
101
- onClick: l[2] || (l[2] = (C) => p.$emit("edit", "email"))
102
- })
103
- ])) : D("", !0),
104
- m.value ? D("", !0) : (E(), k("div", Ke, [
105
- $(u(oe), {
106
- style: { width: "100%" },
107
- disabled: N.value,
108
- onClick: B
109
- }, {
110
- default: G(() => l[5] || (l[5] = [
111
- ae(" Отправить код ")
112
- ])),
113
- _: 1,
114
- __: [5]
115
- }, 8, ["disabled"])
116
- ])),
117
- m.value ? (E(), k("div", Qe, [
118
- $(u(J), {
119
- modelValue: u(U),
120
- "onUpdate:modelValue": l[3] || (l[3] = (C) => Z(U) ? U.value = C : null),
121
- size: "large",
122
- "text-size": "medium",
123
- label: "Код",
124
- type: "text",
125
- error: g.value,
126
- onInput: w,
127
- onBlur: l[4] || (l[4] = (C) => y("code"))
128
- }, null, 8, ["modelValue", "error"])
129
- ])) : D("", !0),
130
- !p.loading && m.value ? (E(), k("div", Xe, [
131
- $(n, {
132
- loading: p.loading,
133
- "rate-limit-text": p.rateLimitText,
134
- "is-final-limit": p.isFinalLimit,
135
- "on-send-again": c
136
- }, null, 8, ["loading", "rate-limit-text", "is-final-limit"])
137
- ])) : D("", !0)
138
- ]);
139
- };
140
- }
141
- }), et = { class: "dialogDefaultContainer" }, tt = { class: "dialogDefaultContainerInsideContent" }, lt = { class: "input-wrapper" }, at = { class: "input-wrapper" }, ot = { style: { width: "100%", display: "flex" } }, it = {
142
- key: 0,
143
- class: "dialogDefaultContainer"
144
- }, nt = { class: "dialogDefaultContainerInsideContent" }, st = { style: { "margin-top": "12px" } }, Te = 8, dt = /* @__PURE__ */ te({
145
- __name: "AddNewPasswordContent",
146
- props: {
147
- modelValue: { type: Boolean },
148
- title: { default: "Установка пароля" },
149
- hintText: { default: "" },
150
- emailSessionId: {}
151
- },
152
- emits: ["update:modelValue", "submit", "close", "update-user"],
153
- setup(_, { emit: F }) {
154
- const v = F, s = b(!1), m = b(""), e = b(""), i = Q({
155
- newPassword: !1,
156
- newPasswordConfirm: !1
157
- }), y = b(A.NEW), d = b(!1), r = b(!1), V = M(() => d.value ? "text" : "password"), N = M(() => r.value ? "text" : "password"), B = () => {
158
- d.value = !d.value;
159
- }, O = () => {
160
- r.value = !r.value;
161
- }, w = M(() => i.newPassword ? m.value.trim() ? m.value.trim().length < Te ? `Пароль слишком короткий. Введите хотя бы ${Te} символов` : "" : "Введите пароль" : ""), c = M(() => i.newPasswordConfirm ? e.value.trim() ? e.value !== m.value ? "Пароли не совпадают" : "" : "Повторите пароль" : ""), T = M(() => !!(w.value || c.value)), g = M(() => s.value || !m.value.trim() || !e.value.trim() ? !0 : T.value), L = () => {
162
- v("update:modelValue", !1), v("close");
163
- }, U = async () => {
164
- v("update-user", m.value);
165
- };
166
- return (p, l) => (E(), k(Oe, null, [
167
- S("div", et, [
168
- S("div", tt, [
169
- l[7] || (l[7] = S("div", { class: "dialogDefaultContainerTextHint" }, X("Установите новый пароль для защиты аккаунта. Пароль должен содержать не менее 8 символов."), -1)),
170
- S("div", lt, [
171
- $(u(J), {
172
- modelValue: m.value,
173
- "onUpdate:modelValue": l[0] || (l[0] = (n) => m.value = n),
174
- size: "large",
175
- "text-size": "medium",
176
- label: "Новый пароль",
177
- type: V.value,
178
- error: w.value,
179
- onBlur: l[1] || (l[1] = () => i.newPassword = !0),
180
- onInput: l[2] || (l[2] = () => i.newPassword = !0)
181
- }, null, 8, ["modelValue", "type", "error"]),
182
- (E(), H(Ce(d.value ? u(ge) : u(he)), {
183
- class: "icon-locked",
184
- onClick: B
185
- }))
186
- ]),
187
- S("div", at, [
188
- $(u(J), {
189
- modelValue: e.value,
190
- "onUpdate:modelValue": l[3] || (l[3] = (n) => e.value = n),
191
- size: "large",
192
- "text-size": "medium",
193
- label: "Повторите новый пароль",
194
- type: N.value,
195
- error: c.value,
196
- onBlur: l[4] || (l[4] = () => i.newPasswordConfirm = !0),
197
- onInput: l[5] || (l[5] = () => i.newPasswordConfirm = !0)
198
- }, null, 8, ["modelValue", "type", "error"]),
199
- (E(), H(Ce(r.value ? u(ge) : u(he)), {
200
- class: "icon-locked",
201
- onClick: O
202
- }))
203
- ]),
204
- S("div", ot, [
205
- $(u(oe), {
206
- style: { width: "100%" },
207
- disabled: g.value,
208
- onClick: U
209
- }, {
210
- default: G(() => l[6] || (l[6] = [
211
- ae(X("Сохранить"))
212
- ])),
213
- _: 1,
214
- __: [6]
215
- }, 8, ["disabled"])
216
- ])
217
- ])
218
- ]),
219
- y.value === u(A).COMPLETED ? (E(), k("div", it, [
220
- S("div", nt, [
221
- l[9] || (l[9] = S("p", null, "Пароль успешно установлен", -1)),
222
- S("div", st, [
223
- $(u(oe), {
224
- style: { width: "100%" },
225
- onClick: L
226
- }, {
227
- default: G(() => l[8] || (l[8] = [
228
- ae("Закрыть")
229
- ])),
230
- _: 1,
231
- __: [8]
232
- })
233
- ])
234
- ])
235
- ])) : D("", !0)
236
- ], 64));
237
- }
238
- }), rt = { class: "dialogDefaultContainerInsideContent" }, ut = { class: "dialogDefaultContainerTextHint" }, mt = {
239
- key: 0,
240
- class: "input-wrapper"
241
- }, ct = {
242
- key: 1,
243
- class: "input-wrapper"
244
- }, vt = /* @__PURE__ */ te({
245
- __name: "OldEmailContent",
246
- props: {
247
- email: {},
248
- code: {},
249
- hintText: { default: "" },
250
- emailError: { default: "" },
251
- codeError: { default: "" },
252
- rateLimitText: { default: "" },
253
- showEmail: { type: Boolean, default: !0 },
254
- showCode: { type: Boolean, default: !0 },
255
- isFinalLimit: { type: Boolean },
256
- isNotMatchCode: { type: Boolean, default: !1 },
257
- loading: { type: Boolean }
258
- },
259
- emits: ["update:email", "update:code", "edit", "on-match-code", "on-match-code-error", "on-send-code-again", "on-clear-code-error"],
260
- setup(_, { emit: F }) {
261
- const v = _, s = F, m = Q({
262
- touched: {
263
- email: !1,
264
- code: !1
265
- },
266
- emailModel: v.email,
267
- codeModel: v.code
268
- });
269
- Y(
270
- () => m.emailModel,
271
- (w) => s("update:email", w)
272
- ), Y(
273
- () => m.codeModel,
274
- (w) => s("update:code", w)
275
- );
276
- const e = (w) => {
277
- m.touched[w] = !0;
278
- }, i = b(""), y = (w) => {
279
- s("on-clear-code-error");
280
- const c = w.target;
281
- let T = ((c == null ? void 0 : c.value) ?? "").replace(/\D/g, "");
282
- T.length > 4 && (T = T.slice(0, 4)), V.value = T, c && c.value !== T && (c.value = T), T.length === 4 && T !== i.value && (i.value = T, s("on-match-code", { email: r.value, code: T }));
283
- }, d = () => {
284
- s("on-send-code-again", { email: r.value });
285
- }, { emailModel: r, codeModel: V, touched: N } = re(m), B = M(() => N.value.email && !r.value.trim() ? "Введите e-mail" : v.emailError), O = M(() => v.isNotMatchCode ? "Неверный код" : N.value.code ? V.value.trim() ? v.codeError ?? null : "Введите код" : "");
286
- return (w, c) => {
287
- const T = ue;
288
- return E(), k("div", rt, [
289
- S("div", ut, X(w.hintText), 1),
290
- w.showEmail ? (E(), k("div", mt, [
291
- $(u(J), {
292
- modelValue: u(r),
293
- "onUpdate:modelValue": c[0] || (c[0] = (g) => Z(r) ? r.value = g : null),
294
- size: "large",
295
- "text-size": "medium",
296
- label: "Почта",
297
- type: "email",
298
- error: B.value,
299
- disabled: !0,
300
- onBlur: c[1] || (c[1] = (g) => e("email")),
301
- onInput: c[2] || (c[2] = (g) => e("email"))
302
- }, null, 8, ["modelValue", "error"]),
303
- $(u(me), {
304
- class: "icon-locked",
305
- onClick: c[3] || (c[3] = (g) => w.$emit("edit", "email"))
306
- })
307
- ])) : D("", !0),
308
- w.showCode ? (E(), k("div", ct, [
309
- $(u(J), {
310
- modelValue: u(V),
311
- "onUpdate:modelValue": c[4] || (c[4] = (g) => Z(V) ? V.value = g : null),
312
- size: "large",
313
- "text-size": "medium",
314
- label: "Код",
315
- type: "text",
316
- error: O.value,
317
- onInput: y,
318
- onBlur: c[5] || (c[5] = (g) => e("code"))
319
- }, null, 8, ["modelValue", "error"])
320
- ])) : D("", !0),
321
- $(T, {
322
- loading: w.loading,
323
- "rate-limit-text": w.rateLimitText,
324
- "is-final-limit": w.isFinalLimit,
325
- "on-send-again": d
326
- }, null, 8, ["loading", "rate-limit-text", "is-final-limit"])
327
- ]);
328
- };
329
- }
330
- }), pt = /* @__PURE__ */ ze(vt, [["__scopeId", "data-v-5e561fbe"]]), ft = { class: "dialogDefaultContainerInsideContent" }, Et = { class: "dialogDefaultContainerTextHint" }, wt = {
331
- key: 0,
332
- class: "input-wrapper"
333
- }, Ct = {
334
- key: 1,
335
- class: "input-wrapper"
336
- }, yt = {
337
- key: 2,
338
- class: "input-wrapper"
339
- }, gt = { key: 3 }, ht = /* @__PURE__ */ te({
340
- __name: "NewEmailContent",
341
- props: {
342
- email: {},
343
- oldEmail: {},
344
- hintText: { default: "" },
345
- emailError: { default: "" },
346
- codeError: { default: "" },
347
- rateLimitText: { default: "" },
348
- showEmail: { type: Boolean, default: !0 },
349
- isFinalLimit: { type: Boolean, default: !1 },
350
- isNotMatchCode: { type: Boolean, default: !1 },
351
- loading: { type: Boolean }
352
- },
353
- emits: ["update:email", "update:code", "edit", "on-match-code", "on-match-code-error", "on-send-code", "on-send-code-again", "on-clear-code-error"],
354
- setup(_, { emit: F }) {
355
- const v = _, s = F, m = b(!1), e = b(""), i = Q({
356
- touched: { email: !1, code: !1 },
357
- emailModel: "",
358
- codeModel: ""
359
- });
360
- Y(
361
- () => i.emailModel,
362
- (l) => {
363
- s("update:email", l);
364
- }
365
- ), Y(
366
- () => i.codeModel,
367
- (l) => s("update:code", l)
368
- );
369
- const y = (l) => i.touched[l] = !0, d = (l) => i.touched[l] = !1, r = () => {
370
- e.value = "", d("email");
371
- }, V = M(() => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.emailModel.trim())), N = M(() => !V.value || !!e.value), B = async () => {
372
- var C;
373
- if (y("email"), !V.value) {
374
- e.value = "Это не похоже на e-mail";
375
- return;
376
- }
377
- const {
378
- data: { data: l }
379
- } = await Ve(i.emailModel);
380
- if (!(((C = l == null ? void 0 : l[0]) == null ? void 0 : C.available) ?? !1)) {
381
- e.value = "Такой email уже используется";
382
- return;
383
- }
384
- e.value = "", s("on-send-code", { email: i.emailModel, prevEmail: v.oldEmail, offLoading: !0 }), m.value = !0;
385
- };
386
- let O = "";
387
- const w = (l) => {
388
- s("on-clear-code-error");
389
- const n = l.target;
390
- let C = n.value.replace(/\D/g, "");
391
- C.length > 4 && (C = C.slice(0, 4), n.value = C), i.codeModel = C, C.length === 4 && C !== O && (O = C, s("on-match-code", { email: i.emailModel, code: C }));
392
- }, c = () => {
393
- s("on-send-code-again", { email: i.emailModel });
394
- }, { emailModel: T, codeModel: g, touched: L } = re(i), U = M(() => {
395
- if (e.value) return e.value;
396
- if (i.touched.email) {
397
- if (!i.emailModel.trim()) return "Введите e-mail";
398
- if (!V.value) return "Это не похоже на e-mail";
399
- }
400
- return v.emailError || "";
401
- }), p = M(() => v.isNotMatchCode ? "Неверный код" : L.value.code ? g.value.trim() ? v.codeError ?? null : "Введите код" : "");
402
- return (l, n) => {
403
- const C = ue;
404
- return E(), k("div", ft, [
405
- S("div", Et, X(m.value ? "Введите код подтверждения" : l.hintText), 1),
406
- l.showEmail ? (E(), k("div", wt, [
407
- $(u(J), {
408
- modelValue: u(T),
409
- "onUpdate:modelValue": n[0] || (n[0] = (R) => Z(T) ? T.value = R : null),
410
- size: "large",
411
- "text-size": "medium",
412
- label: "Почта",
413
- type: "email",
414
- error: U.value,
415
- onBlur: n[1] || (n[1] = (R) => y("email")),
416
- onInput: r
417
- }, null, 8, ["modelValue", "error"]),
418
- $(u(me), {
419
- class: "icon-locked",
420
- onClick: n[2] || (n[2] = (R) => l.$emit("edit", "email"))
421
- })
422
- ])) : D("", !0),
423
- m.value ? D("", !0) : (E(), k("div", Ct, [
424
- $(u(oe), {
425
- style: { width: "100%" },
426
- disabled: N.value,
427
- onClick: B
428
- }, {
429
- default: G(() => n[5] || (n[5] = [
430
- ae(" Отправить код ")
431
- ])),
432
- _: 1,
433
- __: [5]
434
- }, 8, ["disabled"])
435
- ])),
436
- m.value ? (E(), k("div", yt, [
437
- $(u(J), {
438
- modelValue: u(g),
439
- "onUpdate:modelValue": n[3] || (n[3] = (R) => Z(g) ? g.value = R : null),
440
- size: "large",
441
- "text-size": "medium",
442
- label: "Код",
443
- type: "text",
444
- error: p.value,
445
- onInput: w,
446
- onBlur: n[4] || (n[4] = (R) => y("code"))
447
- }, null, 8, ["modelValue", "error"])
448
- ])) : D("", !0),
449
- m.value ? (E(), k("div", gt, [
450
- $(C, {
451
- loading: l.loading,
452
- "rate-limit-text": l.rateLimitText,
453
- "is-final-limit": l.isFinalLimit,
454
- "on-send-again": c
455
- }, null, 8, ["loading", "rate-limit-text", "is-final-limit"])
456
- ])) : D("", !0)
457
- ]);
458
- };
459
- }
460
- }), Tt = { class: "text-center w-full" }, Mt = { class: "dialogTitle" }, Vt = {
461
- key: 0,
462
- class: "dialogDefaultContainer"
463
- }, bt = {
464
- key: 1,
465
- class: "dialogDefaultContainer"
466
- }, Me = 3, St = /* @__PURE__ */ te({
467
- __name: "ProfileEmailDialog",
468
- props: {
469
- modelValue: { type: Boolean },
470
- title: { default: "Смена почты" },
471
- hintText: { default: "Чтобы продолжить, введите код подтверждения" },
472
- initialEmail: { default: "" },
473
- throttler: {},
474
- provider: {},
475
- mode: {}
476
- },
477
- emits: ["update:modelValue", "submit-email", "edit", "close", "notify", "clean-input-errors", "on-update-jwt", "update-email-field", "on-password-error", "on-toast"],
478
- setup(_, { emit: F }) {
479
- const v = _, s = F, m = b(v.modelValue), e = Q({
480
- oldEmail: v.initialEmail,
481
- newEmail: "",
482
- code: "",
483
- addEmail: "",
484
- addCode: ""
485
- }), i = Q({ email: !1, code: !1 }), y = b(A.OLD), d = b(null), r = b(!1), V = b(!1), N = b(!1), B = b(We.VERIFY_EMAIL), O = M(() => B.value === "password-flow"), w = M(() => p.value ? v.title : O.value ? "Добавление пароля" : "Добавление почты"), { startTimer: c, remainingSeconds: T, isAvailableForSendAgain: g, totalRateAttempts: L, currentRateAttempt: U } = Fe(), { isEditFlow: p, getFlow: l } = Ae(b(v.mode ?? "edit")), { showRateLimitToast: n } = Re(s), C = M(() => i.email && !e.oldEmail.trim() ? "Введите e-mail" : ""), R = M(() => i.code && !e.code.trim() ? "Введите код" : ""), ie = M(() => g.value ? "Повторить" : `${T.value}`), q = b(Me), be = M(() => q.value === 0), $e = (a) => new Promise((t) => setTimeout(t, a));
486
- Y(
487
- () => v.modelValue,
488
- (a) => m.value = a
489
- ), Y(m, (a) => s("update:modelValue", a));
490
- const ne = () => {
491
- s("close"), m.value = !1;
492
- }, ce = (a) => s("edit", a);
493
- async function ve(a, t = !1) {
494
- var o;
495
- try {
496
- const h = (o = (await W("/users/profile/check-throttler", { method: "email", email: a, isInvite: t })).data) == null ? void 0 : o.data;
497
- return h ? (await $e(1e3), h.restTimeSec > 0 ? (c(h.restTimeSec), g.value = !1, L.value = h.attempts.total ?? L.value, U.value = (h.attempts.total ?? 0) - (h.attempts.available ?? 0), q.value = h.attempts.available ?? q.value) : g.value = !0, h) : null;
498
- } catch {
499
- return null;
500
- }
501
- }
502
- async function se(a = "email") {
503
- var o;
504
- return ((o = (await He("/users/profile/session/get-edit-session", { params: { field: a } })).data) == null ? void 0 : o.data) ?? null;
505
- }
506
- async function xe(a = "email") {
507
- try {
508
- const t = await se(a);
509
- d.value = (t == null ? void 0 : t.sessionId) ?? d.value, y.value = (t == null ? void 0 : t.step) ?? y.value, e.oldEmail = (t == null ? void 0 : t.oldValue) ?? e.oldEmail, t != null && t.sessionId || await pe(a);
510
- } catch {
511
- await pe(a);
512
- }
513
- }
514
- async function pe(a = "email") {
515
- var t;
516
- try {
517
- const o = await W("/users/profile/session/create-if-not-exists", { field: a, oldValue: v.initialEmail }), f = ((t = o.data) == null ? void 0 : t.data) ?? o.data;
518
- d.value = (f == null ? void 0 : f.sessionId) ?? d.value, y.value = (f == null ? void 0 : f.step) ?? y.value, e.oldEmail = (f == null ? void 0 : f.oldValue) ?? e.oldEmail, e.newEmail = (f == null ? void 0 : f.newValue) ?? e.newEmail;
519
- } catch {
520
- }
521
- }
522
- async function ee({ value: a, offLoading: t = !0 }) {
523
- var o;
524
- try {
525
- r.value = !0;
526
- const f = a ?? e.addEmail, h = await W(
527
- "/users/profile/email/contact/send-code",
528
- {
529
- sessionId: d.value,
530
- email: f,
531
- value: f,
532
- oldValue: e.oldEmail,
533
- provider: v.provider
534
- }
535
- // { headers: { 'x-only-sms': 'true' } }
536
- );
537
- if (h.status === 403 && ((o = h.data) != null && o.tooManyRequests)) {
538
- const I = h.data.tooManyRequests;
539
- return I.restTimeSec > 0 ? (c(I.restTimeSec), L.value = I.attempts.total ?? L.value, U.value = (I.attempts.total ?? 0) - (I.attempts.available ?? 0), q.value = I.attempts.available ?? q.value) : g.value = !0, h;
540
- }
541
- return await ve(a ?? e.oldEmail), h;
542
- } catch (f) {
543
- throw console.error(f), f;
544
- } finally {
545
- t && (r.value = !1);
546
- }
547
- }
548
- const fe = async (a, t) => {
549
- var o, f, h, I, x, j;
550
- if (!e.oldEmail && t === A.OLD) throw new Error("oldEmail пустой — модель потерялась");
551
- try {
552
- r.value = !0;
553
- const P = await se();
554
- if (d.value = (P == null ? void 0 : P.sessionId) ?? d.value, y.value = (P == null ? void 0 : P.step) ?? y.value, e.oldEmail = (P == null ? void 0 : P.oldValue) ?? e.oldEmail, e.newEmail = (P == null ? void 0 : P.newValue) ?? e.newEmail, !d.value) throw new Error("Нет sessionId для match");
555
- const z = await W("/users/profile/change/email/match-code", {
556
- email: t === A.NEW ? e.newEmail : e.oldEmail,
557
- sessionId: d.value,
558
- code: a,
559
- step: t
560
- }), le = ((o = z.data) == null ? void 0 : o.nextStep) ?? ((h = (f = z.data) == null ? void 0 : f.data) == null ? void 0 : h.nextStep) ?? null, De = ((x = (I = z.data) == null ? void 0 : I.data) == null ? void 0 : x.rateLimit) ?? ((j = z.data) == null ? void 0 : j.rateLimit) ?? null, Ne = z.data.data.success ?? z.data.success;
561
- if (n(De), !Ne) {
562
- V.value = !0;
563
- return;
564
- }
565
- if (le) {
566
- if (y.value = le, y.value === A.NEW) {
567
- const K = await se();
568
- e.oldEmail = (K == null ? void 0 : K.oldValue) ?? e.oldEmail, e.newEmail = (K == null ? void 0 : K.newValue) ?? e.newEmail, e.code = "";
569
- }
570
- y.value === A.COMPLETED && (e.code = "", s("submit-email", { email: e.addEmail, code: a }), s("on-toast", { color: "success", text: "E-mail изменён" }), s("on-update-jwt", "email", "edit", e.newEmail), d.value = null, s("close"));
571
- }
572
- return z;
573
- } finally {
574
- r.value = !1;
575
- }
576
- }, ke = async () => {
577
- try {
578
- const a = await W("/users/profile/bind/email/cancel", {
579
- sessionId: d.value
580
- });
581
- if ((a.data.data ?? a.data).success) {
582
- s("close");
583
- return;
584
- }
585
- } catch (a) {
586
- console.error(a);
587
- }
588
- };
589
- async function Ie({ code: a }) {
590
- await fe(a, A.OLD);
591
- }
592
- function Ee(a) {
593
- }
594
- async function Se({ code: a }) {
595
- await fe(a, A.NEW);
596
- }
597
- const we = async ({
598
- value: a,
599
- field: t = "email",
600
- offLoading: o = !0
601
- }) => {
602
- var f;
603
- try {
604
- if (r.value = !0, !d.value) throw new Error("Bind-сессия не найдена. Создайте её через createBindSession.");
605
- const h = a ?? e.addEmail, I = await W(`/users/profile/bind/contact/send-code/${t}`, {
606
- sessionId: d.value,
607
- email: h,
608
- provider: v.provider
609
- }), x = (f = I.data) == null ? void 0 : f.tooManyRequests;
610
- if (I.status === 403 && x) {
611
- x.restTimeSec > 0 ? (c(x.restTimeSec), L.value = x.attempts.total ?? L.value, U.value = (x.attempts.total ?? 0) - (x.attempts.available ?? 0), q.value = x.attempts.available ?? Me) : g.value = !0;
612
- return;
613
- }
614
- const j = await ve(h);
615
- return j && j.restTimeSec > 0 ? c(j.restTimeSec) : g.value = !0, I;
616
- } finally {
617
- o && (r.value = !1);
618
- }
619
- }, Be = async () => {
620
- var a, t, o, f, h, I;
621
- try {
622
- if (!d.value) {
623
- const le = await de();
624
- d.value = le.sessionId ?? d.value;
625
- }
626
- const x = await W("/users/profile/bind/email/match-code", {
627
- email: e.addEmail,
628
- sessionId: d.value,
629
- code: e.addCode
630
- }), j = ((a = x.data) == null ? void 0 : a.nextStep) ?? ((o = (t = x.data) == null ? void 0 : t.data) == null ? void 0 : o.nextStep);
631
- B.value = j ?? B.value;
632
- const P = ((h = (f = x.data) == null ? void 0 : f.data) == null ? void 0 : h.rateLimit) ?? ((I = x.data) == null ? void 0 : I.rateLimit) ?? null, z = x.data.data.success ?? x.data.success;
633
- if (n(P), !z) {
634
- N.value = !0;
635
- return;
636
- }
637
- } catch {
638
- }
639
- }, Le = async () => {
640
- }, Pe = async (a) => {
641
- if (!d.value) {
642
- const t = await de();
643
- d.value = t.sessionId ?? d.value;
644
- }
645
- r.value = !0;
646
- try {
647
- await W("/users/profile/bind/email/password/set", { sessionId: d.value, newPassword: a }), B.value = A.COMPLETED, s("on-toast", { color: "success", text: "E-mail успешно привязан к аккаунту" }), s("update-email-field", e.addEmail), s("submit-email", { email: e.addEmail, code: e.addCode }), s("on-update-jwt", "email", "bind", e.addEmail), s("close");
648
- } finally {
649
- r.value = !1;
650
- }
651
- }, de = async () => {
652
- r.value = !0;
653
- try {
654
- const a = await W("/users/profile/bind/email/init", { email: "" }), t = a.data.data ?? a.data;
655
- return B.value = t.step ?? B.value, d.value = t.sessionId ?? d.value, t;
656
- } finally {
657
- r.value = !1;
658
- }
659
- };
660
- return Ue(async () => {
661
- r.value = !0;
662
- const a = await l("email");
663
- if (v.mode === "bind" && a === "bind") {
664
- await de(), r.value = !1;
665
- return;
666
- }
667
- await xe(), e.oldEmail && await ee({ value: e.oldEmail }), r.value = !1;
668
- }), (a, t) => (E(), H(u(_e), {
669
- modelValue: m.value,
670
- "onUpdate:modelValue": [
671
- t[18] || (t[18] = (o) => m.value = o),
672
- ne
673
- ],
674
- width: "small",
675
- "auto-height": !0,
676
- "close-on-click-outside": !0,
677
- "onClick:outside": ne
678
- }, {
679
- header: G(() => [
680
- S("div", Tt, [
681
- $(u(qe), {
682
- "slot-left": !1,
683
- size: "small",
684
- borded: !0,
685
- "no-padding": !1
686
- }, {
687
- title: G(() => [
688
- S("span", Mt, X(w.value), 1)
689
- ]),
690
- "right-button": G(() => [
691
- $(u(je), {
692
- class: "cross",
693
- onClick: ne
694
- })
695
- ]),
696
- _: 1
697
- })
698
- ])
699
- ]),
700
- default: G(() => [
701
- S("div", null, [
702
- u(p) ? (E(), k("div", Vt, [
703
- r.value ? (E(), H(ye, { key: 0 })) : D("", !0),
704
- y.value === u(A).OLD ? (E(), H(pt, {
705
- key: 1,
706
- email: e.oldEmail,
707
- "onUpdate:email": t[0] || (t[0] = (o) => e.oldEmail = o),
708
- code: e.code,
709
- "onUpdate:code": t[1] || (t[1] = (o) => e.code = o),
710
- "hint-text": a.hintText,
711
- "email-error": C.value,
712
- "code-error": R.value,
713
- "rate-limit-text": ie.value,
714
- "is-final-limit": q.value === 0,
715
- "is-not-match-code": V.value,
716
- loading: r.value,
717
- onEdit: ce,
718
- onOnMatchCode: Ie,
719
- onOnMatchCodeError: Ee,
720
- onSendCode: t[2] || (t[2] = (o) => ee({ value: e.oldEmail })),
721
- onOnSendCodeAgain: t[3] || (t[3] = (o) => ee({ value: e.oldEmail })),
722
- onOnClearCodeError: t[4] || (t[4] = (o) => V.value = !1)
723
- }, null, 8, ["email", "code", "hint-text", "email-error", "code-error", "rate-limit-text", "is-final-limit", "is-not-match-code", "loading"])) : y.value === u(A).NEW ? (E(), H(ht, {
724
- key: 2,
725
- email: e.newEmail,
726
- "onUpdate:email": t[5] || (t[5] = (o) => e.newEmail = o),
727
- oldEmail: e.oldEmail,
728
- "onUpdate:oldEmail": t[6] || (t[6] = (o) => e.oldEmail = o),
729
- code: e.code,
730
- "onUpdate:code": t[7] || (t[7] = (o) => e.code = o),
731
- "hint-text": "Введите новый адрес вашей почты",
732
- "email-error": C.value,
733
- "code-error": R.value,
734
- "rate-limit-text": ie.value,
735
- "is-final-limit": q.value === 0,
736
- "is-not-match-code": V.value,
737
- loading: r.value,
738
- onEdit: ce,
739
- onOnMatchCode: Se,
740
- onOnMatchCodeError: Ee,
741
- onOnSendCode: t[8] || (t[8] = (o) => ee({ value: e.newEmail })),
742
- onOnSendCodeAgain: t[9] || (t[9] = (o) => ee({ value: e.newEmail })),
743
- onOnClearCodeError: t[10] || (t[10] = (o) => V.value = !1)
744
- }, null, 8, ["email", "oldEmail", "code", "email-error", "code-error", "rate-limit-text", "is-final-limit", "is-not-match-code", "loading"])) : D("", !0)
745
- ])) : (E(), k("div", bt, [
746
- r.value ? (E(), H(ye, { key: 0 })) : D("", !0),
747
- O.value ? (E(), H(dt, {
748
- key: 2,
749
- "model-value": m.value,
750
- "email-session-id": d.value,
751
- "onUpdate:modelValue": t[17] || (t[17] = (o) => s("update:modelValue", o)),
752
- onUpdateUser: Pe,
753
- onClose: ke
754
- }, null, 8, ["model-value", "email-session-id"])) : (E(), H(Ze, {
755
- key: 1,
756
- email: e.addEmail,
757
- "onUpdate:email": t[11] || (t[11] = (o) => e.addEmail = o),
758
- oldEmail: e.addEmail,
759
- "onUpdate:oldEmail": t[12] || (t[12] = (o) => e.addEmail = o),
760
- code: e.addCode,
761
- "onUpdate:code": t[13] || (t[13] = (o) => e.addCode = o),
762
- "hint-text": u(p) ? a.hintText : "Чтобы продолжить, введите новый адрес вашей почты",
763
- "rate-limit-text": ie.value,
764
- "is-final-limit": be.value,
765
- "is-not-match-code": N.value,
766
- loading: r.value,
767
- onOnSendCode: t[14] || (t[14] = (o) => we({ value: e.addEmail, field: "email" })),
768
- onOnSendCodeAgain: t[15] || (t[15] = (o) => we({ value: e.addEmail, field: "email" })),
769
- onOnMatchCode: Be,
770
- onOnMatchCodeError: Le,
771
- onOnClearCodeError: t[16] || (t[16] = (o) => N.value = !1)
772
- }, null, 8, ["email", "oldEmail", "code", "hint-text", "rate-limit-text", "is-final-limit", "is-not-match-code", "loading"]))
773
- ]))
774
- ])
775
- ]),
776
- _: 1
777
- }, 8, ["modelValue"]));
778
- }
779
- });
780
- export {
781
- St as default
782
- };