@foxford/sdk 6.1.2 → 6.2.1

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.
package/antibot.cjs ADDED
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
8
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
+ var __spreadValues = (a, b) => {
10
+ for (var prop in b || (b = {}))
11
+ if (__hasOwnProp.call(b, prop))
12
+ __defNormalProp(a, prop, b[prop]);
13
+ if (__getOwnPropSymbols)
14
+ for (var prop of __getOwnPropSymbols(b)) {
15
+ if (__propIsEnum.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ }
18
+ return a;
19
+ };
20
+ var __export = (target, all) => {
21
+ for (var name in all)
22
+ __defProp(target, name, { get: all[name], enumerable: true });
23
+ };
24
+ var __copyProps = (to, from, except, desc) => {
25
+ if (from && typeof from === "object" || typeof from === "function") {
26
+ for (let key of __getOwnPropNames(from))
27
+ if (!__hasOwnProp.call(to, key) && key !== except)
28
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
29
+ }
30
+ return to;
31
+ };
32
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
33
+
34
+ // src/antibot/index.ts
35
+ var antibot_exports = {};
36
+ __export(antibot_exports, {
37
+ FoxfordAntibot: () => FoxfordAntibot
38
+ });
39
+ module.exports = __toCommonJS(antibot_exports);
40
+ var _FoxfordAntibot = class _FoxfordAntibot {
41
+ constructor(config = _FoxfordAntibot.DEFAULT_CONFIG) {
42
+ this.createAntibotFrame = (params) => {
43
+ if (window.location.hostname.endsWith("foxford.ru") || window.location.hostname.endsWith("netology-group.services") || window.location.hostname.endsWith("foxford-school.com") || window.location.hostname.endsWith("foxford-home-school.ru") || window.location.hostname.endsWith("smartlearning.ru") || this.config.debug) {
44
+ const frame = _FoxfordAntibot.createFrame(params.src, params == null ? void 0 : params.onload, params == null ? void 0 : params.onerror);
45
+ document.body.appendChild(frame);
46
+ window.antibotInitialized = true;
47
+ }
48
+ };
49
+ this.config = __spreadValues(__spreadValues({}, _FoxfordAntibot.DEFAULT_CONFIG), config);
50
+ if (window.antibotInitialized === void 0) window.antibotInitialized = false;
51
+ if (!document.body) throw new Error("Body element not found");
52
+ if (window.onCaptureReady !== void 0) {
53
+ console.debug("Seo4Ajax crawler injects own callback. FoxfordAntibot initialization will be ignored.");
54
+ return;
55
+ }
56
+ if (_FoxfordAntibot.antibotIsInitialized()) {
57
+ console.debug("FoxfordAntibot is already mounted");
58
+ return;
59
+ }
60
+ if (process.env.NODE_ENV === "production") {
61
+ this.createAntibotFrame({
62
+ onerror: this.config.antibotOnerror,
63
+ onload: this.config.antibotOnload,
64
+ src: this.config.antibotFrameSrc
65
+ });
66
+ }
67
+ }
68
+ static antibotIsInitialized() {
69
+ if (window.antibotInitialized || document.querySelectorAll(`iframe.${_FoxfordAntibot.FRAME_CLASSNAME}`).length > 0) {
70
+ return true;
71
+ }
72
+ try {
73
+ return window.top ? window.self !== window.top && Boolean(window.top.antibotInitialized) : false;
74
+ } catch (e) {
75
+ return false;
76
+ }
77
+ }
78
+ };
79
+ _FoxfordAntibot.FOXFORD_ANTIBOT_URL = "https://foxford.ru/antibot/ping";
80
+ _FoxfordAntibot.DEFAULT_CONFIG = {
81
+ antibotFrameSrc: _FoxfordAntibot.FOXFORD_ANTIBOT_URL
82
+ };
83
+ _FoxfordAntibot.FRAME_CLASSNAME = "antibot";
84
+ _FoxfordAntibot.createFrame = (src, onload, onerror) => {
85
+ const frame = document.createElement("iframe");
86
+ frame.classList.add(_FoxfordAntibot.FRAME_CLASSNAME);
87
+ frame.style.width = "1px";
88
+ frame.style.height = "1px";
89
+ frame.style.position = "fixed";
90
+ frame.style.zIndex = "-1";
91
+ frame.style.top = "0";
92
+ frame.style.left = "0";
93
+ frame.style.border = "0";
94
+ frame.referrerPolicy = "origin";
95
+ frame.src = src;
96
+ frame.onload = (e) => {
97
+ if (typeof onload === "function") onload(e);
98
+ };
99
+ frame.onerror = () => {
100
+ if (typeof onerror === "function") onerror();
101
+ };
102
+ return frame;
103
+ };
104
+ var FoxfordAntibot = _FoxfordAntibot;
105
+ // Annotate the CommonJS export names for ESM import in node:
106
+ 0 && (module.exports = {
107
+ FoxfordAntibot
108
+ });
package/antibot.d.cts ADDED
@@ -0,0 +1,24 @@
1
+ interface FoxfordAntibotConfig {
2
+ antibotFrameSrc?: string;
3
+ antibotOnload?: (e: Event) => void;
4
+ antibotOnerror?: () => void;
5
+ debug?: boolean;
6
+ }
7
+ declare class FoxfordAntibot {
8
+ private config;
9
+ static FOXFORD_ANTIBOT_URL: string;
10
+ static DEFAULT_CONFIG: {
11
+ antibotFrameSrc: string;
12
+ };
13
+ static FRAME_CLASSNAME: string;
14
+ constructor(config?: FoxfordAntibotConfig);
15
+ private static antibotIsInitialized;
16
+ private static createFrame;
17
+ createAntibotFrame: (params: {
18
+ src: string;
19
+ onload?: (_e: Event) => void;
20
+ onerror?: () => void;
21
+ }) => void;
22
+ }
23
+
24
+ export { FoxfordAntibot, type FoxfordAntibotConfig };
package/antibot.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ interface FoxfordAntibotConfig {
2
+ antibotFrameSrc?: string;
3
+ antibotOnload?: (e: Event) => void;
4
+ antibotOnerror?: () => void;
5
+ debug?: boolean;
6
+ }
7
+ declare class FoxfordAntibot {
8
+ private config;
9
+ static FOXFORD_ANTIBOT_URL: string;
10
+ static DEFAULT_CONFIG: {
11
+ antibotFrameSrc: string;
12
+ };
13
+ static FRAME_CLASSNAME: string;
14
+ constructor(config?: FoxfordAntibotConfig);
15
+ private static antibotIsInitialized;
16
+ private static createFrame;
17
+ createAntibotFrame: (params: {
18
+ src: string;
19
+ onload?: (_e: Event) => void;
20
+ onerror?: () => void;
21
+ }) => void;
22
+ }
23
+
24
+ export { FoxfordAntibot, type FoxfordAntibotConfig };
package/antibot.js ADDED
@@ -0,0 +1,86 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+
18
+ // src/antibot/index.ts
19
+ var _FoxfordAntibot = class _FoxfordAntibot {
20
+ constructor(config = _FoxfordAntibot.DEFAULT_CONFIG) {
21
+ this.createAntibotFrame = (params) => {
22
+ if (window.location.hostname.endsWith("foxford.ru") || window.location.hostname.endsWith("netology-group.services") || window.location.hostname.endsWith("foxford-school.com") || window.location.hostname.endsWith("foxford-home-school.ru") || window.location.hostname.endsWith("smartlearning.ru") || this.config.debug) {
23
+ const frame = _FoxfordAntibot.createFrame(params.src, params == null ? void 0 : params.onload, params == null ? void 0 : params.onerror);
24
+ document.body.appendChild(frame);
25
+ window.antibotInitialized = true;
26
+ }
27
+ };
28
+ this.config = __spreadValues(__spreadValues({}, _FoxfordAntibot.DEFAULT_CONFIG), config);
29
+ if (window.antibotInitialized === void 0) window.antibotInitialized = false;
30
+ if (!document.body) throw new Error("Body element not found");
31
+ if (window.onCaptureReady !== void 0) {
32
+ console.debug("Seo4Ajax crawler injects own callback. FoxfordAntibot initialization will be ignored.");
33
+ return;
34
+ }
35
+ if (_FoxfordAntibot.antibotIsInitialized()) {
36
+ console.debug("FoxfordAntibot is already mounted");
37
+ return;
38
+ }
39
+ if (process.env.NODE_ENV === "production") {
40
+ this.createAntibotFrame({
41
+ onerror: this.config.antibotOnerror,
42
+ onload: this.config.antibotOnload,
43
+ src: this.config.antibotFrameSrc
44
+ });
45
+ }
46
+ }
47
+ static antibotIsInitialized() {
48
+ if (window.antibotInitialized || document.querySelectorAll(`iframe.${_FoxfordAntibot.FRAME_CLASSNAME}`).length > 0) {
49
+ return true;
50
+ }
51
+ try {
52
+ return window.top ? window.self !== window.top && Boolean(window.top.antibotInitialized) : false;
53
+ } catch (e) {
54
+ return false;
55
+ }
56
+ }
57
+ };
58
+ _FoxfordAntibot.FOXFORD_ANTIBOT_URL = "https://foxford.ru/antibot/ping";
59
+ _FoxfordAntibot.DEFAULT_CONFIG = {
60
+ antibotFrameSrc: _FoxfordAntibot.FOXFORD_ANTIBOT_URL
61
+ };
62
+ _FoxfordAntibot.FRAME_CLASSNAME = "antibot";
63
+ _FoxfordAntibot.createFrame = (src, onload, onerror) => {
64
+ const frame = document.createElement("iframe");
65
+ frame.classList.add(_FoxfordAntibot.FRAME_CLASSNAME);
66
+ frame.style.width = "1px";
67
+ frame.style.height = "1px";
68
+ frame.style.position = "fixed";
69
+ frame.style.zIndex = "-1";
70
+ frame.style.top = "0";
71
+ frame.style.left = "0";
72
+ frame.style.border = "0";
73
+ frame.referrerPolicy = "origin";
74
+ frame.src = src;
75
+ frame.onload = (e) => {
76
+ if (typeof onload === "function") onload(e);
77
+ };
78
+ frame.onerror = () => {
79
+ if (typeof onerror === "function") onerror();
80
+ };
81
+ return frame;
82
+ };
83
+ var FoxfordAntibot = _FoxfordAntibot;
84
+ export {
85
+ FoxfordAntibot
86
+ };
@@ -0,0 +1,24 @@
1
+ // @flow
2
+ declare interface FoxfordAntibotConfig {
3
+ antibotFrameSrc?: string;
4
+ antibotOnload?: (e: Event) => void;
5
+ antibotOnerror?: () => void;
6
+ debug?: boolean;
7
+ }
8
+ declare class FoxfordAntibot {
9
+ static FOXFORD_ANTIBOT_URL: string;
10
+ static DEFAULT_CONFIG: {
11
+ antibotFrameSrc: string,
12
+ ...
13
+ };
14
+ static FRAME_CLASSNAME: string;
15
+ constructor(config?: FoxfordAntibotConfig): this;
16
+ createAntibotFrame: (params: {
17
+ src: string,
18
+ onload?: (_e: Event) => void,
19
+ onerror?: () => void,
20
+ ...
21
+ }) => void;
22
+ }
23
+ export type { FoxfordAntibotConfig };
24
+ declare export { FoxfordAntibot };
package/entities.cjs ADDED
@@ -0,0 +1,443 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
10
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
+ var __spreadValues = (a, b) => {
12
+ for (var prop in b || (b = {}))
13
+ if (__hasOwnProp.call(b, prop))
14
+ __defNormalProp(a, prop, b[prop]);
15
+ if (__getOwnPropSymbols)
16
+ for (var prop of __getOwnPropSymbols(b)) {
17
+ if (__propIsEnum.call(b, prop))
18
+ __defNormalProp(a, prop, b[prop]);
19
+ }
20
+ return a;
21
+ };
22
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
23
+ var __export = (target, all) => {
24
+ for (var name in all)
25
+ __defProp(target, name, { get: all[name], enumerable: true });
26
+ };
27
+ var __copyProps = (to, from, except, desc) => {
28
+ if (from && typeof from === "object" || typeof from === "function") {
29
+ for (let key of __getOwnPropNames(from))
30
+ if (!__hasOwnProp.call(to, key) && key !== except)
31
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
32
+ }
33
+ return to;
34
+ };
35
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
36
+
37
+ // src/entities/index.ts
38
+ var entities_exports = {};
39
+ __export(entities_exports, {
40
+ User: () => User
41
+ });
42
+ module.exports = __toCommonJS(entities_exports);
43
+
44
+ // src/entities/user/constants.ts
45
+ var GRADE_MAP = {
46
+ 1: "1 \u043A\u043B\u0430\u0441\u0441",
47
+ 2: "2 \u043A\u043B\u0430\u0441\u0441",
48
+ 3: "3 \u043A\u043B\u0430\u0441\u0441",
49
+ 4: "4 \u043A\u043B\u0430\u0441\u0441",
50
+ 5: "5 \u043A\u043B\u0430\u0441\u0441",
51
+ 6: "6 \u043A\u043B\u0430\u0441\u0441",
52
+ 7: "7 \u043A\u043B\u0430\u0441\u0441",
53
+ 8: "8 \u043A\u043B\u0430\u0441\u0441",
54
+ 9: "9 \u043A\u043B\u0430\u0441\u0441",
55
+ 10: "10 \u043A\u043B\u0430\u0441\u0441",
56
+ 11: "11 \u043A\u043B\u0430\u0441\u0441"
57
+ };
58
+ var DEFAULT_USER = {
59
+ address: {
60
+ building: null,
61
+ cityId: null,
62
+ cityName: null,
63
+ countryId: null,
64
+ countryName: null,
65
+ house: null,
66
+ index: null,
67
+ regionId: null,
68
+ regionName: null,
69
+ room: null,
70
+ street: null
71
+ },
72
+ avatarUrl: "",
73
+ bonus: {
74
+ giftAmount: 0,
75
+ realMoneyAmount: 0
76
+ },
77
+ bonusAmount: 0,
78
+ cartItemsCount: 0,
79
+ cartTemplateId: null,
80
+ createdAt: null,
81
+ disciplineIds: [],
82
+ email: "",
83
+ emailConfirmed: false,
84
+ externshipUser: false,
85
+ fakeEmail: false,
86
+ fakeUser: false,
87
+ firstName: "",
88
+ freeAccessFinishesAt: null,
89
+ fullName: "",
90
+ grade: {
91
+ id: null,
92
+ index: null,
93
+ name: "",
94
+ translit: ""
95
+ },
96
+ gradeChecked: false,
97
+ hasAccessToAttestationSheets: false,
98
+ hasAccessToMultiDaysStreaks: false,
99
+ hasActivePurchases: false,
100
+ hasAttemptsSolveExamRehearsals: false,
101
+ hasBookmarks: false,
102
+ hasExternshipAttestationAccess: false,
103
+ hasPurchasedExternshipContracts: false,
104
+ id: null,
105
+ isAgent: false,
106
+ isCoach: false,
107
+ isCustomer: null,
108
+ isElementaryPupil: false,
109
+ isExternshipCoach: false,
110
+ isGraduated: false,
111
+ isMiniGroupTeacher: false,
112
+ isParent: false,
113
+ lastName: "",
114
+ locale: null,
115
+ methodist: false,
116
+ middleName: "",
117
+ onboardingFinished: false,
118
+ onboardingFinishedAt: null,
119
+ parentPhone: null,
120
+ parentPhoneConfirmed: false,
121
+ phone: null,
122
+ phoneConfirmed: false,
123
+ privacy: {
124
+ publicProfile: false
125
+ },
126
+ profileEnriched: false,
127
+ purchaseAnyExternshipContracts: false,
128
+ recapUuid: null,
129
+ shortName: "",
130
+ skype: null,
131
+ socialNets: [],
132
+ socializationProfile: null,
133
+ tags: null,
134
+ timezone: null,
135
+ type: null,
136
+ webSocketNotificationsJwt: null
137
+ };
138
+
139
+ // src/entities/user/index.ts
140
+ var _User = class _User {
141
+ constructor(props, isDefault = false) {
142
+ this.props = props;
143
+ this.isDefault = isDefault;
144
+ /**
145
+ * Возвращает роль пользователя
146
+ * @returns {UserRole} роль как строка
147
+ */
148
+ this.getRole = () => {
149
+ if (this.isCoach) return "\u0420\u0435\u043F\u0435\u0442\u0438\u0442\u043E\u0440";
150
+ if (this.isAgent) return "\u0423\u0447\u0438\u0442\u0435\u043B\u044C";
151
+ if (this.isParent) return "\u0420\u043E\u0434\u0438\u0442\u0435\u043B\u044C";
152
+ switch (this.type) {
153
+ case "pupil":
154
+ return this.getPupilRole();
155
+ case "agent":
156
+ return "\u0423\u0447\u0438\u0442\u0435\u043B\u044C";
157
+ default:
158
+ return "\u0423\u0447\u0435\u043D\u0438\u043A";
159
+ }
160
+ };
161
+ /**
162
+ * Возвращает фамилию и инициалы юзера
163
+ * @param {User} user
164
+ * @return {string} 'Пупкин В.'
165
+ */
166
+ this.getInitials = () => {
167
+ var _a, _b;
168
+ return `${this.lastName}${this.firstName ? ` ${(_a = this.firstName[0]) == null ? void 0 : _a.toUpperCase()}.` : ""}${this.middleName !== "" && this.middleName !== null ? ` ${(_b = this.middleName[0]) == null ? void 0 : _b.toUpperCase()}.` : ""}`;
169
+ };
170
+ }
171
+ get id() {
172
+ return this.props.id;
173
+ }
174
+ get email() {
175
+ return this.props.email;
176
+ }
177
+ get firstName() {
178
+ return this.props.firstName;
179
+ }
180
+ get middleName() {
181
+ return this.props.middleName;
182
+ }
183
+ get lastName() {
184
+ return this.props.lastName;
185
+ }
186
+ get fullName() {
187
+ return this.props.fullName;
188
+ }
189
+ get shortName() {
190
+ return this.props.shortName;
191
+ }
192
+ get createdAt() {
193
+ return this.props.createdAt;
194
+ }
195
+ get timezone() {
196
+ return this.props.timezone;
197
+ }
198
+ get locale() {
199
+ return this.props.locale;
200
+ }
201
+ get grade() {
202
+ return this.props.grade;
203
+ }
204
+ get phone() {
205
+ return this.props.phone;
206
+ }
207
+ get avatarUrl() {
208
+ return this.props.avatarUrl;
209
+ }
210
+ get isParent() {
211
+ return this.props.isParent;
212
+ }
213
+ get isGraduated() {
214
+ return this.props.isGraduated;
215
+ }
216
+ get gradeChecked() {
217
+ return this.props.gradeChecked;
218
+ }
219
+ get type() {
220
+ return this.props.type;
221
+ }
222
+ get isCoach() {
223
+ return this.props.isCoach;
224
+ }
225
+ get isMiniGroupTeacher() {
226
+ return this.props.isMiniGroupTeacher;
227
+ }
228
+ get isExternshipCoach() {
229
+ return this.props.isExternshipCoach;
230
+ }
231
+ get isAgent() {
232
+ return this.props.isAgent;
233
+ }
234
+ get methodist() {
235
+ return this.props.methodist;
236
+ }
237
+ get address() {
238
+ return this.props.address;
239
+ }
240
+ get socialNets() {
241
+ return this.props.socialNets;
242
+ }
243
+ get skype() {
244
+ return this.props.skype;
245
+ }
246
+ get settings() {
247
+ return this.props.settings;
248
+ }
249
+ get bonus() {
250
+ return this.props.bonus;
251
+ }
252
+ get bonusAmount() {
253
+ return this.props.bonusAmount;
254
+ }
255
+ get hasActivePurchases() {
256
+ return this.props.hasActivePurchases;
257
+ }
258
+ get hasAttemptsSolveExamRehearsals() {
259
+ return this.props.hasAttemptsSolveExamRehearsals;
260
+ }
261
+ get hasBookmarks() {
262
+ return this.props.hasBookmarks;
263
+ }
264
+ get tags() {
265
+ return this.props.tags;
266
+ }
267
+ get cartTemplateId() {
268
+ return this.props.cartTemplateId;
269
+ }
270
+ get cartItemsCount() {
271
+ return this.props.cartItemsCount;
272
+ }
273
+ get onboardingFinished() {
274
+ return this.props.onboardingFinished;
275
+ }
276
+ get onboardingFinishedAt() {
277
+ return this.props.onboardingFinishedAt;
278
+ }
279
+ get emailConfirmed() {
280
+ return this.props.emailConfirmed;
281
+ }
282
+ get phoneConfirmed() {
283
+ return this.props.phoneConfirmed;
284
+ }
285
+ get fakeEmail() {
286
+ return this.props.fakeEmail;
287
+ }
288
+ get fakeUser() {
289
+ return this.props.fakeUser;
290
+ }
291
+ get profileEnriched() {
292
+ return this.props.profileEnriched;
293
+ }
294
+ get recapUuid() {
295
+ return this.props.recapUuid;
296
+ }
297
+ get disciplineIds() {
298
+ return this.props.disciplineIds;
299
+ }
300
+ get privacy() {
301
+ return this.props.privacy;
302
+ }
303
+ get parentPhone() {
304
+ return this.props.parentPhone;
305
+ }
306
+ get parentPhoneConfirmed() {
307
+ return this.props.parentPhoneConfirmed;
308
+ }
309
+ get isCustomer() {
310
+ return this.props.isCustomer;
311
+ }
312
+ get hasAccessToMultiDaysStreaks() {
313
+ return this.props.hasAccessToMultiDaysStreaks;
314
+ }
315
+ get isElementaryPupil() {
316
+ return this.props.isElementaryPupil;
317
+ }
318
+ get webSocketNotificationsJwt() {
319
+ return this.props.webSocketNotificationsJwt;
320
+ }
321
+ get hasAccessToAttestationSheets() {
322
+ return this.props.hasAccessToAttestationSheets;
323
+ }
324
+ get externshipUser() {
325
+ return this.props.externshipUser;
326
+ }
327
+ get hasPurchasedExternshipContracts() {
328
+ return this.props.hasPurchasedExternshipContracts;
329
+ }
330
+ get hasExternshipAttestationAccess() {
331
+ return this.props.hasExternshipAttestationAccess;
332
+ }
333
+ get socializationProfile() {
334
+ return this.props.socializationProfile;
335
+ }
336
+ get freeAccessFinishesAt() {
337
+ return this.props.freeAccessFinishesAt;
338
+ }
339
+ get hasUnseenRoomFeatures() {
340
+ return this.props.hasUnseenRoomFeatures;
341
+ }
342
+ get purchaseAnyExternshipContracts() {
343
+ return this.props.purchaseAnyExternshipContracts;
344
+ }
345
+ /**
346
+ * Глубокое клонирование объекта с защитой от циклических ссылок
347
+ * @private
348
+ * @param obj - объект для клонирования
349
+ * @param hash - WeakMap для отслеживания уже клонированных объектов
350
+ * @returns клонированный объект
351
+ */
352
+ static deepClone(obj, hash = /* @__PURE__ */ new WeakMap()) {
353
+ if (obj === null || typeof obj !== "object") {
354
+ return obj;
355
+ }
356
+ if (hash.has(obj)) {
357
+ return hash.get(obj);
358
+ }
359
+ if (obj instanceof Date) {
360
+ return new Date(obj.getTime());
361
+ }
362
+ if (obj instanceof RegExp) {
363
+ return new RegExp(obj.source, obj.flags);
364
+ }
365
+ if (Array.isArray(obj)) {
366
+ const clonedArr = [];
367
+ hash.set(obj, clonedArr);
368
+ obj.forEach((item, index) => {
369
+ clonedArr[index] = this.deepClone(item, hash);
370
+ });
371
+ return clonedArr;
372
+ }
373
+ const clonedObj = Object.create(Object.getPrototypeOf(obj));
374
+ hash.set(obj, clonedObj);
375
+ Object.keys(obj).forEach((key) => {
376
+ clonedObj[key] = this.deepClone(obj[key], hash);
377
+ });
378
+ return clonedObj;
379
+ }
380
+ static createDefault() {
381
+ return new _User(this.deepClone(DEFAULT_USER), true);
382
+ }
383
+ /**
384
+ * Санитизирует строку: удаляет null-байты и обрезает пробелы
385
+ * @private
386
+ * @param str - исходная строка
387
+ * @returns санитизированная строка
388
+ */
389
+ static sanitizeString(str) {
390
+ if (typeof str !== "string") {
391
+ console.warn("[User] Invalid string type:", typeof str);
392
+ return String(str);
393
+ }
394
+ return str.replace(/\x00/g, "").trim();
395
+ }
396
+ static fromApi(input) {
397
+ const sanitizedData = this.sanitizeUserData(this.deepClone(input));
398
+ return new _User(sanitizedData);
399
+ }
400
+ /**
401
+ * Санитизирует данные пользователя
402
+ * @private
403
+ * @param data - исходные данные
404
+ * @returns санитизированные данные
405
+ */
406
+ static sanitizeUserData(data) {
407
+ return __spreadProps(__spreadValues({}, data), {
408
+ email: this.sanitizeString(data.email),
409
+ firstName: this.sanitizeString(data.firstName),
410
+ fullName: this.sanitizeString(data.fullName),
411
+ lastName: this.sanitizeString(data.lastName),
412
+ middleName: data.middleName ? this.sanitizeString(data.middleName) : data.middleName,
413
+ shortName: this.sanitizeString(data.shortName)
414
+ });
415
+ }
416
+ isDefaultUser() {
417
+ return this.isDefault;
418
+ }
419
+ isLoggedIn() {
420
+ return this.id && this.id > 0 ? true : false;
421
+ }
422
+ /**
423
+ * Возвращает тектовое представление роли / класса пользователя
424
+ *
425
+ * @returns {UserRole}
426
+ */
427
+ getPupilRole() {
428
+ if (this.grade.index === 0) {
429
+ return "\u0414\u043E\u0448\u043A\u043E\u043B\u044C\u043D\u0438\u043A";
430
+ }
431
+ if (this.grade.index == null) return "\u0412\u044B\u043F\u0443\u0441\u043A\u043D\u0438\u043A";
432
+ return _User.getGradeString(this.grade.index);
433
+ }
434
+ toJson() {
435
+ return JSON.stringify(this.props);
436
+ }
437
+ };
438
+ _User.getGradeString = (index) => GRADE_MAP[index] || GRADE_MAP[1];
439
+ var User = _User;
440
+ // Annotate the CommonJS export names for ESM import in node:
441
+ 0 && (module.exports = {
442
+ User
443
+ });