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