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