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