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