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