@dxtmisha/functional 1.3.0 → 1.4.2
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/dist/ScrollbarWidth-D6yhyHBp.js +2184 -0
- package/dist/classes/ref/DatetimeRef.d.ts +1 -3
- package/dist/classes/ref/EventRef.d.ts +1 -2
- package/dist/classes/ref/GeoFlagRef.d.ts +1 -2
- package/dist/classes/ref/GeoIntlRef.d.ts +1 -2
- package/dist/classes/ref/GeoRef.d.ts +1 -1
- package/dist/composables/ref/useApiRef.d.ts +1 -1
- package/dist/composables/ref/useCookieRef.d.ts +1 -1
- package/dist/composables/ref/useMeta.d.ts +1 -2
- package/dist/composables/ref/useTranslateRef.d.ts +1 -1
- package/dist/flags.js +1 -1
- package/dist/functions/basic.d.ts +1 -0
- package/dist/functions/computedByLanguage.d.ts +15 -0
- package/dist/functions/ref/getBindRef.d.ts +1 -1
- package/dist/functions/ref/render.d.ts +1 -1
- package/dist/functions/render/getBind.d.ts +2 -2
- package/dist/functions/render/getClassName.d.ts +1 -1
- package/dist/functions/render/getIndexForRender.d.ts +1 -1
- package/dist/functions/toBind.d.ts +1 -1
- package/dist/functions/toBinds.d.ts +1 -1
- package/dist/library.d.ts +2 -103
- package/dist/library.js +1338 -1846
- package/dist/types/constructorTypes.d.ts +1 -1
- package/dist/types/listTypes.d.ts +1 -1
- package/package.json +6 -5
- package/dist/Icons-BNmTjp32.js +0 -1301
- package/dist/classes/Api.d.ts +0 -305
- package/dist/classes/BroadcastMessage.d.ts +0 -36
- package/dist/classes/Cache.d.ts +0 -34
- package/dist/classes/CacheItem.d.ts +0 -55
- package/dist/classes/CacheStatic.d.ts +0 -17
- package/dist/classes/Cookie.d.ts +0 -58
- package/dist/classes/CookieBlock.d.ts +0 -22
- package/dist/classes/DataStorage.d.ts +0 -82
- package/dist/classes/Datetime.d.ts +0 -482
- package/dist/classes/EventItem.d.ts +0 -160
- package/dist/classes/Geo.d.ts +0 -168
- package/dist/classes/GeoFlag.d.ts +0 -79
- package/dist/classes/GeoIntl.d.ts +0 -262
- package/dist/classes/GeoPhone.d.ts +0 -107
- package/dist/classes/Global.d.ts +0 -21
- package/dist/classes/Hash.d.ts +0 -59
- package/dist/classes/Icons.d.ts +0 -90
- package/dist/classes/Loading.d.ts +0 -49
- package/dist/classes/Meta.d.ts +0 -168
- package/dist/classes/MetaManager.d.ts +0 -103
- package/dist/classes/MetaOg.d.ts +0 -101
- package/dist/classes/MetaTwitter.d.ts +0 -101
- package/dist/classes/ScrollbarWidth.d.ts +0 -33
- package/dist/classes/Translate.d.ts +0 -116
- package/dist/classes/__tests__/Meta.test.d.ts +0 -4
- package/dist/classes/__tests__/MetaManager.test.d.ts +0 -4
- package/dist/classes/__tests__/MetaOg.test.d.ts +0 -4
- package/dist/classes/__tests__/MetaTwitter.test.d.ts +0 -4
- package/dist/functions/anyToString.d.ts +0 -7
- package/dist/functions/applyTemplate.d.ts +0 -10
- package/dist/functions/arrFill.d.ts +0 -8
- package/dist/functions/copyObject.d.ts +0 -8
- package/dist/functions/createElement.d.ts +0 -13
- package/dist/functions/domQuerySelector.d.ts +0 -7
- package/dist/functions/domQuerySelectorAll.d.ts +0 -7
- package/dist/functions/encodeAttribute.d.ts +0 -7
- package/dist/functions/eventStopPropagation.d.ts +0 -7
- package/dist/functions/executeFunction.d.ts +0 -8
- package/dist/functions/executePromise.d.ts +0 -7
- package/dist/functions/forEach.d.ts +0 -11
- package/dist/functions/frame.d.ts +0 -16
- package/dist/functions/getAttributes.d.ts +0 -8
- package/dist/functions/getClipboardData.d.ts +0 -11
- package/dist/functions/getColumn.d.ts +0 -10
- package/dist/functions/getElement.d.ts +0 -8
- package/dist/functions/getElementId.d.ts +0 -9
- package/dist/functions/getElementItem.d.ts +0 -11
- package/dist/functions/getElementOrWindow.d.ts +0 -8
- package/dist/functions/getExp.d.ts +0 -13
- package/dist/functions/getItemByPath.d.ts +0 -8
- package/dist/functions/getKey.d.ts +0 -7
- package/dist/functions/getLengthOfAllArray.d.ts +0 -8
- package/dist/functions/getMaxLengthAllArray.d.ts +0 -8
- package/dist/functions/getMinLengthAllArray.d.ts +0 -8
- package/dist/functions/getMouseClient.d.ts +0 -8
- package/dist/functions/getMouseClientX.d.ts +0 -7
- package/dist/functions/getMouseClientY.d.ts +0 -7
- package/dist/functions/getObjectByKeys.d.ts +0 -8
- package/dist/functions/getObjectNoUndefined.d.ts +0 -8
- package/dist/functions/getObjectOrNone.d.ts +0 -7
- package/dist/functions/getRandomText.d.ts +0 -11
- package/dist/functions/getRequestString.d.ts +0 -9
- package/dist/functions/getStepPercent.d.ts +0 -8
- package/dist/functions/getStepValue.d.ts +0 -8
- package/dist/functions/goScroll.d.ts +0 -10
- package/dist/functions/inArray.d.ts +0 -8
- package/dist/functions/initScrollbarOffset.d.ts +0 -6
- package/dist/functions/intersectKey.d.ts +0 -8
- package/dist/functions/isArray.d.ts +0 -7
- package/dist/functions/isDifferent.d.ts +0 -9
- package/dist/functions/isDomRuntime.d.ts +0 -10
- package/dist/functions/isFilled.d.ts +0 -9
- package/dist/functions/isFloat.d.ts +0 -7
- package/dist/functions/isFunction.d.ts +0 -8
- package/dist/functions/isInDom.d.ts +0 -8
- package/dist/functions/isIntegerBetween.d.ts +0 -8
- package/dist/functions/isNull.d.ts +0 -8
- package/dist/functions/isNumber.d.ts +0 -7
- package/dist/functions/isObject.d.ts +0 -7
- package/dist/functions/isObjectNotArray.d.ts +0 -7
- package/dist/functions/isSelected.d.ts +0 -8
- package/dist/functions/isSelectedByList.d.ts +0 -8
- package/dist/functions/isString.d.ts +0 -7
- package/dist/functions/isWindow.d.ts +0 -7
- package/dist/functions/random.d.ts +0 -8
- package/dist/functions/replaceRecursive.d.ts +0 -10
- package/dist/functions/replaceTemplate.d.ts +0 -9
- package/dist/functions/secondToTime.d.ts +0 -7
- package/dist/functions/setElementItem.d.ts +0 -10
- package/dist/functions/setValues.d.ts +0 -17
- package/dist/functions/splice.d.ts +0 -12
- package/dist/functions/strFill.d.ts +0 -8
- package/dist/functions/toArray.d.ts +0 -17
- package/dist/functions/toCamelCase.d.ts +0 -7
- package/dist/functions/toCamelCaseFirst.d.ts +0 -7
- package/dist/functions/toDate.d.ts +0 -7
- package/dist/functions/toKebabCase.d.ts +0 -15
- package/dist/functions/toNumber.d.ts +0 -8
- package/dist/functions/toNumberByMax.d.ts +0 -9
- package/dist/functions/toPercent.d.ts +0 -8
- package/dist/functions/toPercentBy100.d.ts +0 -8
- package/dist/functions/transformation.d.ts +0 -21
- package/dist/functions/uniqueArray.d.ts +0 -7
- package/dist/functions/writeClipboardData.d.ts +0 -7
- package/dist/types/basicTypes.d.ts +0 -126
- package/dist/types/geoTypes.d.ts +0 -86
- package/dist/types/metaTypes.d.ts +0 -584
|
@@ -0,0 +1,2184 @@
|
|
|
1
|
+
var ct = Object.defineProperty;
|
|
2
|
+
var ut = (i, t, e) => t in i ? ct(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
|
|
3
|
+
var n = (i, t, e) => ut(i, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { geo as lt } from "@dxtmisha/media";
|
|
5
|
+
function O(i) {
|
|
6
|
+
return !!(i && typeof i == "object");
|
|
7
|
+
}
|
|
8
|
+
function b(i, t) {
|
|
9
|
+
if (O(i)) {
|
|
10
|
+
const e = [];
|
|
11
|
+
return i instanceof Map ? i.forEach((s, a) => e.push(t(s, a, i))) : Array.isArray(i) ? i.forEach((s, a) => e.push(t(s, a, i))) : Object.entries(i).forEach(
|
|
12
|
+
([s, a]) => e.push(t(a, s, i))
|
|
13
|
+
), e.filter((s) => s !== void 0);
|
|
14
|
+
}
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
17
|
+
function it(i, t = "=", e = "&") {
|
|
18
|
+
return b(
|
|
19
|
+
i,
|
|
20
|
+
(s, a) => `${a}${t}${encodeURIComponent(String(s).trim())}`
|
|
21
|
+
).sort().join(e);
|
|
22
|
+
}
|
|
23
|
+
function M(i) {
|
|
24
|
+
return i == null;
|
|
25
|
+
}
|
|
26
|
+
function L(i, t) {
|
|
27
|
+
if (i) {
|
|
28
|
+
if (t && i === "0")
|
|
29
|
+
return !0;
|
|
30
|
+
switch (typeof i) {
|
|
31
|
+
case "bigint":
|
|
32
|
+
case "number":
|
|
33
|
+
return i !== 0;
|
|
34
|
+
case "boolean":
|
|
35
|
+
return i;
|
|
36
|
+
case "function":
|
|
37
|
+
case "symbol":
|
|
38
|
+
return !0;
|
|
39
|
+
case "object":
|
|
40
|
+
return Array.isArray(i) ? i.length > 0 : Object.values(i).some((e) => !M(e));
|
|
41
|
+
case "string":
|
|
42
|
+
return !["", "undefined", "null", "0", "false", "[]"].includes(i);
|
|
43
|
+
case "undefined":
|
|
44
|
+
return !1;
|
|
45
|
+
default:
|
|
46
|
+
return !!i;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return !1;
|
|
50
|
+
}
|
|
51
|
+
function m(i) {
|
|
52
|
+
return O(i) && !Array.isArray(i);
|
|
53
|
+
}
|
|
54
|
+
function T(i) {
|
|
55
|
+
return typeof i == "string";
|
|
56
|
+
}
|
|
57
|
+
function gt(i) {
|
|
58
|
+
return JSON.parse(JSON.stringify(i));
|
|
59
|
+
}
|
|
60
|
+
function u() {
|
|
61
|
+
return typeof window != "undefined" && !!window.document;
|
|
62
|
+
}
|
|
63
|
+
function W(i) {
|
|
64
|
+
switch (typeof i) {
|
|
65
|
+
case "number":
|
|
66
|
+
return !0;
|
|
67
|
+
case "string":
|
|
68
|
+
return !!i.match(/^[0-9]+$/);
|
|
69
|
+
default:
|
|
70
|
+
return !1;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function P(i) {
|
|
74
|
+
if (typeof i == "number")
|
|
75
|
+
return i;
|
|
76
|
+
if (!i)
|
|
77
|
+
return 0;
|
|
78
|
+
let t = i.replace(/[^\d., ]+/ig, "");
|
|
79
|
+
return t.match(/( [0-9]{3}[ ,.]|[0-9] [0-9])/ig) ? t = t.replace(/ /ig, "").replace(/,/ig, ".") : t.match(/,[0-9]{3}[,.]/ig) ? t = t.replace(/,/ig, "") : t.match(/[.][0-9]{3}[,.]/ig) ? t = t.replace(/[.]/ig, "").replace(/,/ig, ".") : t = t.replace(/,/ig, "."), parseFloat(t);
|
|
80
|
+
}
|
|
81
|
+
function ft(i, t) {
|
|
82
|
+
return M(i) ? !1 : Array.isArray(t) ? t.includes(i) : W(i) && W(t) ? P(i) === P(t) : i === t;
|
|
83
|
+
}
|
|
84
|
+
function at(i) {
|
|
85
|
+
return i instanceof Function || typeof i == "function";
|
|
86
|
+
}
|
|
87
|
+
function y(i) {
|
|
88
|
+
return at(i) ? i() : i;
|
|
89
|
+
}
|
|
90
|
+
const N = {};
|
|
91
|
+
let J = "ui-storage";
|
|
92
|
+
class z {
|
|
93
|
+
/**
|
|
94
|
+
* Constructor
|
|
95
|
+
* @param name value name/ название значения
|
|
96
|
+
* @param isSession should we use a session/ использовать ли сессию
|
|
97
|
+
*/
|
|
98
|
+
constructor(t, e = !1) {
|
|
99
|
+
n(this, "value");
|
|
100
|
+
n(this, "age");
|
|
101
|
+
this.name = t, this.isSession = e;
|
|
102
|
+
const s = `${e ? "session" : "storage"}#${t}`;
|
|
103
|
+
if (s in N)
|
|
104
|
+
return N[s];
|
|
105
|
+
this.make(), N[s] = this;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Changing the prefix in key names. Should be called at the beginning of the code.
|
|
109
|
+
*
|
|
110
|
+
* Изменение префикса в названиях ключей. Вызывать нужно в начале кода.
|
|
111
|
+
* @param newPrefix new prefix/ новый префикс
|
|
112
|
+
*/
|
|
113
|
+
static setPrefix(t) {
|
|
114
|
+
J = t;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Getting data from local storage.
|
|
118
|
+
*
|
|
119
|
+
* Получение данных из локального хранилища.
|
|
120
|
+
* @param defaultValue default value/ значение по умолчанию
|
|
121
|
+
* @param cache cache time/ время кэширования
|
|
122
|
+
*/
|
|
123
|
+
get(t, e) {
|
|
124
|
+
if (this.value !== null && this.value !== void 0 && this.isCache(e))
|
|
125
|
+
return this.value;
|
|
126
|
+
if (t !== void 0)
|
|
127
|
+
return this.set(t);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Changing data in storage.
|
|
131
|
+
*
|
|
132
|
+
* Изменение данных в хранилище.
|
|
133
|
+
* @param value new values/ новые значения
|
|
134
|
+
*/
|
|
135
|
+
set(t) {
|
|
136
|
+
var e;
|
|
137
|
+
return this.value = y(t), this.age = (/* @__PURE__ */ new Date()).getTime(), this.value === void 0 ? this.remove() : (e = this.getMethod()) == null || e.setItem(this.getIndex(), JSON.stringify({
|
|
138
|
+
value: this.value,
|
|
139
|
+
age: this.age
|
|
140
|
+
})), this.value;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Removing data from storage.
|
|
144
|
+
*
|
|
145
|
+
* Удаление данных из хранилища.
|
|
146
|
+
*/
|
|
147
|
+
remove() {
|
|
148
|
+
var t;
|
|
149
|
+
return (t = this.getMethod()) == null || t.removeItem(this.getIndex()), this;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Clearing all data from storage.
|
|
153
|
+
*
|
|
154
|
+
* Очистка всех данных из хранилища.
|
|
155
|
+
*/
|
|
156
|
+
update() {
|
|
157
|
+
return this.make(), this;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Checks for storage time limit.
|
|
161
|
+
*
|
|
162
|
+
* Проверяет на лимит времени хранения.
|
|
163
|
+
* @param cache cache time/ время кэширования
|
|
164
|
+
*/
|
|
165
|
+
isCache(t) {
|
|
166
|
+
return M(t) || this.age && this.age + t * 1e3 >= (/* @__PURE__ */ new Date()).getTime();
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Returns an object for working with storage.
|
|
170
|
+
*
|
|
171
|
+
* Возвращает объект для работы с хранилищем.
|
|
172
|
+
*/
|
|
173
|
+
getMethod() {
|
|
174
|
+
if (u())
|
|
175
|
+
return this.isSession ? window == null ? void 0 : window.sessionStorage : window == null ? void 0 : window.localStorage;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Getting the storage key name.
|
|
179
|
+
*
|
|
180
|
+
* Получение имени ключа в хранилище.
|
|
181
|
+
*/
|
|
182
|
+
getIndex() {
|
|
183
|
+
return `${J}__${this.name}`;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Getting data from storage.
|
|
187
|
+
*
|
|
188
|
+
* Получение данных из хранилища.
|
|
189
|
+
*/
|
|
190
|
+
getValue() {
|
|
191
|
+
var e;
|
|
192
|
+
const t = (e = this.getMethod()) == null ? void 0 : e.getItem(this.getIndex());
|
|
193
|
+
if (t)
|
|
194
|
+
try {
|
|
195
|
+
return JSON.parse(t);
|
|
196
|
+
} catch (s) {
|
|
197
|
+
console.error("DataStorage", s);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Filling in the data from storage.
|
|
202
|
+
*
|
|
203
|
+
* Заполнение данными из хранилища.
|
|
204
|
+
*/
|
|
205
|
+
make() {
|
|
206
|
+
const t = this.getValue();
|
|
207
|
+
return t ? (this.value = t.value, this.age = t.age) : (this.value = void 0, this.age = void 0), this;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
const dt = "geo-code", o = class o {
|
|
211
|
+
/**
|
|
212
|
+
* Information about the current country.
|
|
213
|
+
*
|
|
214
|
+
* Информация об текущей стране.
|
|
215
|
+
*/
|
|
216
|
+
static get() {
|
|
217
|
+
return this.item;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Current country.
|
|
221
|
+
*
|
|
222
|
+
* Текущая страна.
|
|
223
|
+
*/
|
|
224
|
+
static getCountry() {
|
|
225
|
+
return this.item.country;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Current language.
|
|
229
|
+
*
|
|
230
|
+
* Текущий язык.
|
|
231
|
+
*/
|
|
232
|
+
static getLanguage() {
|
|
233
|
+
return this.language;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Full format according to the standard.
|
|
237
|
+
*
|
|
238
|
+
* Полный формат согласно стандарту.
|
|
239
|
+
*/
|
|
240
|
+
static getStandard() {
|
|
241
|
+
return this.item.standard;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Returns the first day of the week.
|
|
245
|
+
*
|
|
246
|
+
* Возвращает первый день недели.
|
|
247
|
+
*/
|
|
248
|
+
static getFirstDay() {
|
|
249
|
+
return this.item.firstDay;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Full format.
|
|
253
|
+
*
|
|
254
|
+
* Полный формат.
|
|
255
|
+
*/
|
|
256
|
+
static getLocation() {
|
|
257
|
+
return this.location;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Obtaining processed data.
|
|
261
|
+
*
|
|
262
|
+
* Получение обработанных данных.
|
|
263
|
+
*/
|
|
264
|
+
static getItem() {
|
|
265
|
+
return {
|
|
266
|
+
...this.item,
|
|
267
|
+
language: this.language
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Returns the full list of countries.
|
|
272
|
+
*
|
|
273
|
+
* Возвращает полный список стран.
|
|
274
|
+
*/
|
|
275
|
+
static getList() {
|
|
276
|
+
return lt;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Returns the data about the country by its full code.
|
|
280
|
+
*
|
|
281
|
+
* Возвращает данные о стране по ее полному коду.
|
|
282
|
+
* @param code country code, full form language-country or one of them/
|
|
283
|
+
* код страны, полный вид язык-страна или один из них
|
|
284
|
+
*/
|
|
285
|
+
static getByCode(t) {
|
|
286
|
+
let e;
|
|
287
|
+
return t && (t.match(/([A-Z]{2}-[a-z]{2})|([a-z]{2}-[A-Z]{2})/) && (e = this.getByCodeFull(t)), !e && t.match(/[A-Z]{2}/) && (e = this.getByCountry(this.toCountry(t))), !e && t.match(/[a-z]{2}/) && (e = this.getByLanguage(this.toLanguage(t)))), this.toFull(gt(e != null ? e : this.getList()[0]));
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Returns the full data by language and country.
|
|
291
|
+
*
|
|
292
|
+
* Возвращает полные данные по языку и стране.
|
|
293
|
+
* @param code string in the form of language-country/ строка в виде язык-страна
|
|
294
|
+
*/
|
|
295
|
+
static getByCodeFull(t) {
|
|
296
|
+
return this.getList().find(
|
|
297
|
+
(e) => ft(t, [
|
|
298
|
+
`${e.language}-${e.country}`,
|
|
299
|
+
`${e.country}-${e.language}`
|
|
300
|
+
])
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Returns the full data by country.
|
|
305
|
+
*
|
|
306
|
+
* Возвращает полные данные по стране.
|
|
307
|
+
* @param country country/ страна
|
|
308
|
+
*/
|
|
309
|
+
static getByCountry(t) {
|
|
310
|
+
return this.getList().find((e) => {
|
|
311
|
+
var s;
|
|
312
|
+
return e.country === t || ((s = e == null ? void 0 : e.countryAlternative) == null ? void 0 : s.find((a) => a === t));
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Returns the full data by language.
|
|
317
|
+
*
|
|
318
|
+
* Возвращает полные данные по языку.
|
|
319
|
+
* @param language language/ язык
|
|
320
|
+
*/
|
|
321
|
+
static getByLanguage(t) {
|
|
322
|
+
return this.getList().find((e) => {
|
|
323
|
+
var s;
|
|
324
|
+
return e.language === t || ((s = e == null ? void 0 : e.languageAlternative) == null ? void 0 : s.find((a) => a === t));
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Retrieving the default timezone.
|
|
329
|
+
*
|
|
330
|
+
* Получение временной зоны по умолчанию
|
|
331
|
+
*/
|
|
332
|
+
static getTimezone() {
|
|
333
|
+
return this.timezone;
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Retrieving the default timezone (formatted view).
|
|
337
|
+
*
|
|
338
|
+
* Получение временной зоны по умолчанию (отформатированный вид).
|
|
339
|
+
*/
|
|
340
|
+
static getTimezoneFormat() {
|
|
341
|
+
const t = Math.abs(Math.trunc(this.timezone / 60)).toString().padStart(2, "0"), e = Math.abs(this.timezone % 60).toString().padStart(2, "0");
|
|
342
|
+
return this.timezone >= 0 ? `-${t}:${e}` : `+${t}:${e}`;
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Determines the current country by its full name.
|
|
346
|
+
*
|
|
347
|
+
* Определяет текущую страну по ее полному названию.
|
|
348
|
+
* @param code country code, full form language-country or one of them/
|
|
349
|
+
* код страны, полный вид язык-страна или один из них
|
|
350
|
+
*/
|
|
351
|
+
static find(t) {
|
|
352
|
+
return this.getByCode(t);
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Returns a complete string with the country code and language.
|
|
356
|
+
*
|
|
357
|
+
* Возвращает полную строку с кодом страны и языка.
|
|
358
|
+
* @param item object with data about the current country/
|
|
359
|
+
* объект с данными об текущей стране
|
|
360
|
+
*/
|
|
361
|
+
static toStandard(t) {
|
|
362
|
+
return `${t.language}-${t.country}`;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Changes the data by the full code.
|
|
366
|
+
*
|
|
367
|
+
* Изменяет данные по полному коду.
|
|
368
|
+
* @param code country code, full form language-country or one of them/
|
|
369
|
+
* код страны, полный вид язык-страна или один из них
|
|
370
|
+
* @param save save the result/ сохранить результат
|
|
371
|
+
*/
|
|
372
|
+
static set(t, e) {
|
|
373
|
+
this.location = t, this.item = this.getByCode(this.location), this.language = this.findLanguage(this.location), e && this.storage.set(this.location);
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Changing the default timezone for transmitted dates.
|
|
377
|
+
*
|
|
378
|
+
* Изменение временной зоны по умолчанию для отправляемых дат
|
|
379
|
+
* @param timezone new time zone/ новая временная зона
|
|
380
|
+
*/
|
|
381
|
+
static setTimezone(t) {
|
|
382
|
+
this.timezone = t;
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Determines the current location.
|
|
386
|
+
*
|
|
387
|
+
* Определяет текущую локацию.
|
|
388
|
+
*/
|
|
389
|
+
static findLocation() {
|
|
390
|
+
var t;
|
|
391
|
+
return u() && (this.storage.get() || ((t = document.querySelector("html")) == null ? void 0 : t.lang) || navigator.language || navigator.languages[0] || "en-GB") || "en-GB";
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Determines the current language.
|
|
395
|
+
*
|
|
396
|
+
* Определяет текущий язык.
|
|
397
|
+
* @param code country code, full form language-country or one of them/
|
|
398
|
+
* код страны, полный вид язык-страна или один из них
|
|
399
|
+
*/
|
|
400
|
+
static findLanguage(t) {
|
|
401
|
+
return t && t.match(/[a-z]{2}/) ? this.toLanguage(t) : this.item.language;
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Returns the country code by its full language-country.
|
|
405
|
+
*
|
|
406
|
+
* Возвращает код страны по ее полному язык-страна.
|
|
407
|
+
* @param code country code/ код страна
|
|
408
|
+
*/
|
|
409
|
+
static toCountry(t) {
|
|
410
|
+
return t.replace(/[^A-Z]+/g, "");
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* Returns the language code by its full language-country.<br>
|
|
414
|
+
* Возвращает код языка по его полному язык-страна.
|
|
415
|
+
* @param code country code/ код страна
|
|
416
|
+
*/
|
|
417
|
+
static toLanguage(t) {
|
|
418
|
+
return t.replace(/[^a-z]+/g, "");
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Adding missing data.<br>
|
|
422
|
+
* Добавление недостающих данных.
|
|
423
|
+
* @param item object with data about the current country/
|
|
424
|
+
* объект с данными об текущей стране
|
|
425
|
+
*/
|
|
426
|
+
static toFull(t) {
|
|
427
|
+
return {
|
|
428
|
+
...t,
|
|
429
|
+
standard: this.toStandard(t),
|
|
430
|
+
firstDay: (t == null ? void 0 : t.firstDay) || "Mo"
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
n(o, "storage", new z(dt)), n(o, "location"), n(o, "item"), n(o, "language"), n(o, "timezone", (/* @__PURE__ */ new Date()).getTimezoneOffset()), o.location = o.findLocation(), o.language = o.findLanguage(o.location), o.item = o.getByCode(o.location);
|
|
435
|
+
let S = o;
|
|
436
|
+
function rt(i) {
|
|
437
|
+
return u() && i === window;
|
|
438
|
+
}
|
|
439
|
+
function p(i) {
|
|
440
|
+
var t;
|
|
441
|
+
if (u())
|
|
442
|
+
return rt(i) ? document.body : T(i) ? (t = document.querySelector(i)) != null ? t : void 0 : i;
|
|
443
|
+
}
|
|
444
|
+
function V(i) {
|
|
445
|
+
return rt(i) ? i : p(i);
|
|
446
|
+
}
|
|
447
|
+
function pt(i) {
|
|
448
|
+
var t;
|
|
449
|
+
return !!((t = p(i)) != null && t.closest("html"));
|
|
450
|
+
}
|
|
451
|
+
function A(i) {
|
|
452
|
+
return Array.isArray(i) ? i : [i];
|
|
453
|
+
}
|
|
454
|
+
class Z {
|
|
455
|
+
/**
|
|
456
|
+
* Classes Constructor
|
|
457
|
+
* @param elementSelector element/ элемент
|
|
458
|
+
* @param type type/ тип
|
|
459
|
+
* @param listener the object that receives a notification (an object that implements the
|
|
460
|
+
* Event interface) when an event of the specified type occurs/ объект, который принимает
|
|
461
|
+
* уведомление, когда событие указанного типа произошло
|
|
462
|
+
* @param options object that specifies characteristics/ объект options
|
|
463
|
+
* @param detail an event-dependent value associated with the event/ зависимое от события
|
|
464
|
+
* значение, связанное с событием
|
|
465
|
+
*/
|
|
466
|
+
constructor(t, e = ["click"], s, a, r) {
|
|
467
|
+
/**
|
|
468
|
+
* Element.
|
|
469
|
+
*
|
|
470
|
+
* Элемент.
|
|
471
|
+
*/
|
|
472
|
+
n(this, "element");
|
|
473
|
+
/**
|
|
474
|
+
* Element for checking. If the element is missing in the DOM, the event is turned off.
|
|
475
|
+
*
|
|
476
|
+
* Элемент для проверки. Если элемент отсутствует в DOM, событие выключается.
|
|
477
|
+
*/
|
|
478
|
+
n(this, "elementControl");
|
|
479
|
+
n(this, "elementControlEdit");
|
|
480
|
+
/**
|
|
481
|
+
* A case-sensitive string representing the event type to listen for.
|
|
482
|
+
*
|
|
483
|
+
* Чувствительная к регистру строка, представляющая тип обрабатываемого события.
|
|
484
|
+
*/
|
|
485
|
+
n(this, "type");
|
|
486
|
+
/**
|
|
487
|
+
* The object that receives a notification (an object that implements the Event interface)
|
|
488
|
+
* when an event of the specified type occurs. This must be null, an object with a
|
|
489
|
+
* handleEvent() method, or a JavaScript function.
|
|
490
|
+
*
|
|
491
|
+
* Объект, который принимает уведомление, когда событие указанного типа произошло.
|
|
492
|
+
* Это должен быть объект, реализующий интерфейс EventListener или просто функция JavaScript.
|
|
493
|
+
*/
|
|
494
|
+
n(this, "listenerRecent", (t) => {
|
|
495
|
+
var e, s;
|
|
496
|
+
pt(this.elementControl) ? ((e = this.listener) == null || e.call(this.element, t, this.detail), O(this.options) && ((s = this.options) != null && s.once) && this.stop()) : this.stop();
|
|
497
|
+
});
|
|
498
|
+
/**
|
|
499
|
+
* Event states.
|
|
500
|
+
*
|
|
501
|
+
* Состояния события.
|
|
502
|
+
*/
|
|
503
|
+
n(this, "activity", !1);
|
|
504
|
+
n(this, "activityItems", []);
|
|
505
|
+
this.listener = s, this.options = a, this.detail = r, this.element = V(t), this.elementControl = p(t), this.type = A(e);
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* Checks whether event listening is currently enabled.
|
|
509
|
+
*
|
|
510
|
+
* Проверяет, включено ли сейчас прослушивание события.
|
|
511
|
+
*/
|
|
512
|
+
isActive() {
|
|
513
|
+
return this.activity;
|
|
514
|
+
}
|
|
515
|
+
getElement() {
|
|
516
|
+
return this.element;
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
519
|
+
* Change of an element for tracking.
|
|
520
|
+
*
|
|
521
|
+
* Изменение элемента для прослеживания.
|
|
522
|
+
* @param elementSelector element/ элемент
|
|
523
|
+
*/
|
|
524
|
+
setElement(t) {
|
|
525
|
+
const e = V(t);
|
|
526
|
+
return this.elementControlEdit || (this.elementControl = p(t)), this.element = e, this.reset(), this;
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* Modifies the object that receives the notification.
|
|
530
|
+
*
|
|
531
|
+
* Модифицирует объект, который получает уведомление.
|
|
532
|
+
* @param elementSelector element/ элемент
|
|
533
|
+
*/
|
|
534
|
+
setElementControl(t) {
|
|
535
|
+
return this.elementControl = p(t), this.elementControlEdit = !M(this.elementControl), this.elementControlEdit || (this.elementControl = p(this.element)), this;
|
|
536
|
+
}
|
|
537
|
+
/**
|
|
538
|
+
* Changes the type of the handled event.
|
|
539
|
+
*
|
|
540
|
+
* Изменяет тип обрабатываемого события.
|
|
541
|
+
* @param type type/ тип
|
|
542
|
+
*/
|
|
543
|
+
setType(t) {
|
|
544
|
+
return this.type = A(t), this.reset(), this;
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* Modifies the object that receives the notification.
|
|
548
|
+
*
|
|
549
|
+
* Модифицирует объект, который получает уведомление.
|
|
550
|
+
* @param listener
|
|
551
|
+
*/
|
|
552
|
+
setListener(t) {
|
|
553
|
+
return this.listener = t, this;
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
556
|
+
* Modifying the options object that defines the characteristics of an object.
|
|
557
|
+
*
|
|
558
|
+
* Изменение объекта options, который определяет характеристики объекта.
|
|
559
|
+
* @param options
|
|
560
|
+
*/
|
|
561
|
+
setOptions(t) {
|
|
562
|
+
return this.options = t, this.reset(), this;
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* Modifying a dependent value for the dispatch method.
|
|
566
|
+
*
|
|
567
|
+
* Изменение зависимого значения для метода dispatch.
|
|
568
|
+
* @param detail
|
|
569
|
+
*/
|
|
570
|
+
setDetail(t) {
|
|
571
|
+
return this.detail = t, this;
|
|
572
|
+
}
|
|
573
|
+
/**
|
|
574
|
+
* The method of the EventTarget sends an Event to the object, (synchronously) invoking
|
|
575
|
+
* the affected EventListeners in the appropriate order.
|
|
576
|
+
*
|
|
577
|
+
* Отправляет событие в общую систему событий. Это событие подчиняется тем же правилам
|
|
578
|
+
* поведения "Захвата" и "Всплывания" как и непосредственно инициированные события.
|
|
579
|
+
* @param detail an event-dependent value associated with the event/ зависимое от события
|
|
580
|
+
* значение, связанное с событием
|
|
581
|
+
*/
|
|
582
|
+
dispatch(t = this.detail) {
|
|
583
|
+
return this.type.forEach(
|
|
584
|
+
(e) => {
|
|
585
|
+
var s;
|
|
586
|
+
return (s = this.element) == null ? void 0 : s.dispatchEvent(new CustomEvent(e, { detail: t }));
|
|
587
|
+
}
|
|
588
|
+
), this;
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* Starting event listening.
|
|
592
|
+
*
|
|
593
|
+
* Запуск прослушивания события.
|
|
594
|
+
*/
|
|
595
|
+
start() {
|
|
596
|
+
return this.activity || (this.activity = !0, this.activityItems = [], this.type.forEach((t) => {
|
|
597
|
+
this.element && !(t === "resize" && this.makeResize()) && !(t === "scroll-sync" && this.makeScroll()) && (this.element.addEventListener(t, this.listenerRecent, this.options), this.activityItems.push({
|
|
598
|
+
element: this.element,
|
|
599
|
+
type: t
|
|
600
|
+
}));
|
|
601
|
+
})), this;
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
604
|
+
* Stopping event listening.
|
|
605
|
+
*
|
|
606
|
+
* Остановка прослушивания события.
|
|
607
|
+
*/
|
|
608
|
+
stop() {
|
|
609
|
+
return this.activity && (this.activity = !1, this.activityItems.forEach(({
|
|
610
|
+
element: t,
|
|
611
|
+
type: e,
|
|
612
|
+
listener: s,
|
|
613
|
+
observer: a
|
|
614
|
+
}) => {
|
|
615
|
+
a ? a.disconnect() : s ? t == null || t.removeEventListener(e, s) : t == null || t.removeEventListener(e, this.listenerRecent);
|
|
616
|
+
})), this;
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* Toggling event handler state.
|
|
620
|
+
*
|
|
621
|
+
* Переключение состояния работы события.
|
|
622
|
+
* @param activity event activation/ активация события
|
|
623
|
+
*/
|
|
624
|
+
toggle(t) {
|
|
625
|
+
return t ? this.start() : this.stop();
|
|
626
|
+
}
|
|
627
|
+
/**
|
|
628
|
+
* Overloads the listening events.
|
|
629
|
+
*
|
|
630
|
+
* Перегружает события прослушивания.
|
|
631
|
+
*/
|
|
632
|
+
reset() {
|
|
633
|
+
return this.activity && (this.stop(), this.start()), this;
|
|
634
|
+
}
|
|
635
|
+
/**
|
|
636
|
+
* Checks if the ResizeObserver object exists.
|
|
637
|
+
*
|
|
638
|
+
* Проверяет, существует ли объект ResizeObserver.
|
|
639
|
+
*/
|
|
640
|
+
isObserver() {
|
|
641
|
+
return "ResizeObserver" in window;
|
|
642
|
+
}
|
|
643
|
+
/**
|
|
644
|
+
* The implementation of the resize event for an element.
|
|
645
|
+
*
|
|
646
|
+
* Реализация события изменения размера для элемента.
|
|
647
|
+
*/
|
|
648
|
+
makeResize() {
|
|
649
|
+
if (this.element && this.element instanceof HTMLElement && this.element !== document.body && this.isObserver()) {
|
|
650
|
+
const t = new ResizeObserver(
|
|
651
|
+
(e) => this.listenerRecent(e == null ? void 0 : e[0])
|
|
652
|
+
);
|
|
653
|
+
return t.observe(this.element), this.activityItems.push({
|
|
654
|
+
element: this.element,
|
|
655
|
+
type: "resize",
|
|
656
|
+
observer: t
|
|
657
|
+
}), !0;
|
|
658
|
+
}
|
|
659
|
+
return !1;
|
|
660
|
+
}
|
|
661
|
+
/**
|
|
662
|
+
* Implementation of the scroll event for an element.
|
|
663
|
+
*
|
|
664
|
+
* Реализация события изменения положения скролла для элемента.
|
|
665
|
+
*/
|
|
666
|
+
makeScroll() {
|
|
667
|
+
if (this.element) {
|
|
668
|
+
let t = !1;
|
|
669
|
+
const e = (s) => {
|
|
670
|
+
t || (t = !0, requestAnimationFrame(() => {
|
|
671
|
+
this.listenerRecent(s), t = !1;
|
|
672
|
+
}));
|
|
673
|
+
};
|
|
674
|
+
return this.element.addEventListener("scroll", e, this.options), this.element.addEventListener("resize", e, this.options), this.activityItems.push(
|
|
675
|
+
{
|
|
676
|
+
element: this.element,
|
|
677
|
+
type: "scroll",
|
|
678
|
+
listener: e
|
|
679
|
+
},
|
|
680
|
+
{
|
|
681
|
+
element: this.element,
|
|
682
|
+
type: "resize",
|
|
683
|
+
listener: e
|
|
684
|
+
}
|
|
685
|
+
), !0;
|
|
686
|
+
}
|
|
687
|
+
return !1;
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
const q = "ui-loading", D = class D {
|
|
691
|
+
/**
|
|
692
|
+
* Check if the loader is active now.
|
|
693
|
+
*
|
|
694
|
+
* Проверить, активен ли сейчас загрузчик.
|
|
695
|
+
*/
|
|
696
|
+
static is() {
|
|
697
|
+
return this.value > 0;
|
|
698
|
+
}
|
|
699
|
+
/**
|
|
700
|
+
* Shows the loader.
|
|
701
|
+
*
|
|
702
|
+
* Показывает загрузчик.
|
|
703
|
+
*/
|
|
704
|
+
static show() {
|
|
705
|
+
this.value++, this.dispatch();
|
|
706
|
+
}
|
|
707
|
+
/**
|
|
708
|
+
* Hides the loader.
|
|
709
|
+
*
|
|
710
|
+
* Скрывает загрузчик.
|
|
711
|
+
*/
|
|
712
|
+
static hide() {
|
|
713
|
+
this.is() && (this.value--, this.dispatch());
|
|
714
|
+
}
|
|
715
|
+
/**
|
|
716
|
+
* Event registration to listen for data changes.
|
|
717
|
+
*
|
|
718
|
+
* Регистрация события для прослушивания изменений данных.
|
|
719
|
+
* @param listener the object that receives a notification (an object that implements the
|
|
720
|
+
* Event interface) when an event of the specified type occurs/ объект, который принимает
|
|
721
|
+
* уведомление, когда событие указанного типа произошло
|
|
722
|
+
* @param element element/ элемент
|
|
723
|
+
*/
|
|
724
|
+
static registrationEvent(t, e) {
|
|
725
|
+
u() && new Z(window, q, t).setElementControl(e).start();
|
|
726
|
+
}
|
|
727
|
+
/**
|
|
728
|
+
* Calls the event listener.
|
|
729
|
+
*
|
|
730
|
+
* Вызывает слушателя событий.
|
|
731
|
+
*/
|
|
732
|
+
static dispatch() {
|
|
733
|
+
var t;
|
|
734
|
+
(t = this.event) == null || t.dispatch({ loading: this.is() });
|
|
735
|
+
}
|
|
736
|
+
};
|
|
737
|
+
n(D, "value", 0), n(D, "event"), u() && (D.event = new Z(window, q));
|
|
738
|
+
let E = D;
|
|
739
|
+
class yt {
|
|
740
|
+
constructor() {
|
|
741
|
+
/** Default headers/ Заголовки по умолчанию */
|
|
742
|
+
n(this, "headers", {});
|
|
743
|
+
}
|
|
744
|
+
/**
|
|
745
|
+
* Getting the header for the request.
|
|
746
|
+
*
|
|
747
|
+
* Получение заголовка для запроса.
|
|
748
|
+
* @param value list of headers/ список заголовков
|
|
749
|
+
* @param type type of request/ тип запроса
|
|
750
|
+
*/
|
|
751
|
+
get(t, e = "application/json;charset=UTF-8") {
|
|
752
|
+
if (t !== null) {
|
|
753
|
+
const s = {
|
|
754
|
+
...this.headers,
|
|
755
|
+
...t || {}
|
|
756
|
+
};
|
|
757
|
+
return L(e) && (s["Content-Type"] = e), s;
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
/**
|
|
761
|
+
* Modifies the default header data.
|
|
762
|
+
*
|
|
763
|
+
* Изменяет данные заголовка по умолчанию.
|
|
764
|
+
*/
|
|
765
|
+
set(t) {
|
|
766
|
+
return m(t) && (this.headers = t), this;
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
var l = /* @__PURE__ */ ((i) => (i.get = "GET", i.post = "POST", i.put = "PUT", i.delete = "DELETE", i))(l || {});
|
|
770
|
+
class mt {
|
|
771
|
+
constructor() {
|
|
772
|
+
/** Default request data/ Данные запроса по умолчанию */
|
|
773
|
+
n(this, "value");
|
|
774
|
+
}
|
|
775
|
+
/**
|
|
776
|
+
* Checks if default request data exists.
|
|
777
|
+
*
|
|
778
|
+
* Проверяет, существуют ли данные запроса по умолчанию.
|
|
779
|
+
*/
|
|
780
|
+
is() {
|
|
781
|
+
return !!this.value;
|
|
782
|
+
}
|
|
783
|
+
/**
|
|
784
|
+
* Gets the default request data.
|
|
785
|
+
*
|
|
786
|
+
* Получает данные запроса по умолчанию.
|
|
787
|
+
*/
|
|
788
|
+
get() {
|
|
789
|
+
return this.value;
|
|
790
|
+
}
|
|
791
|
+
/**
|
|
792
|
+
* Adds default data to the request.
|
|
793
|
+
*
|
|
794
|
+
* Добавляет данные по умолчанию к запросу.
|
|
795
|
+
* @param request request data/ данные запроса
|
|
796
|
+
*/
|
|
797
|
+
request(t) {
|
|
798
|
+
const e = this.get();
|
|
799
|
+
if (e) {
|
|
800
|
+
if (t instanceof FormData)
|
|
801
|
+
this.addByFormData(t, e);
|
|
802
|
+
else if (m(t))
|
|
803
|
+
return {
|
|
804
|
+
...e,
|
|
805
|
+
...t
|
|
806
|
+
};
|
|
807
|
+
}
|
|
808
|
+
return t;
|
|
809
|
+
}
|
|
810
|
+
/**
|
|
811
|
+
* Modifies the default request data.
|
|
812
|
+
*
|
|
813
|
+
* Изменяет данные запроса по умолчанию.
|
|
814
|
+
*/
|
|
815
|
+
set(t) {
|
|
816
|
+
this.value = t;
|
|
817
|
+
}
|
|
818
|
+
/**
|
|
819
|
+
* Adds default data to FormData request.
|
|
820
|
+
*
|
|
821
|
+
* Добавляет данные по умолчанию к запросу FormData.
|
|
822
|
+
* @param request FormData request/ запрос FormData
|
|
823
|
+
* @param value default values/ значения по умолчанию
|
|
824
|
+
*/
|
|
825
|
+
addByFormData(t, e) {
|
|
826
|
+
for (const s in e)
|
|
827
|
+
t.has(s) || t.set(s, e[s]);
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
class vt {
|
|
831
|
+
constructor() {
|
|
832
|
+
n(this, "value");
|
|
833
|
+
}
|
|
834
|
+
/**
|
|
835
|
+
* Last response data
|
|
836
|
+
*
|
|
837
|
+
* Данные последнего ответа
|
|
838
|
+
*/
|
|
839
|
+
get() {
|
|
840
|
+
return this.value;
|
|
841
|
+
}
|
|
842
|
+
/**
|
|
843
|
+
* Returns the execution status code.
|
|
844
|
+
*
|
|
845
|
+
* Возвращает код статуса выполнения.
|
|
846
|
+
*/
|
|
847
|
+
getStatus() {
|
|
848
|
+
var t;
|
|
849
|
+
return (t = this.get()) == null ? void 0 : t.status;
|
|
850
|
+
}
|
|
851
|
+
/**
|
|
852
|
+
* Returns the execution status text.
|
|
853
|
+
*
|
|
854
|
+
* Возвращает текст статуса выполнения.
|
|
855
|
+
*/
|
|
856
|
+
getStatusText() {
|
|
857
|
+
var t;
|
|
858
|
+
return (t = this.get()) == null ? void 0 : t.statusText;
|
|
859
|
+
}
|
|
860
|
+
/**
|
|
861
|
+
* Returns the script execution error.
|
|
862
|
+
*
|
|
863
|
+
* Возвращает ошибку выполнения скрипта.
|
|
864
|
+
*/
|
|
865
|
+
getError() {
|
|
866
|
+
var t;
|
|
867
|
+
return (t = this.get()) == null ? void 0 : t.error;
|
|
868
|
+
}
|
|
869
|
+
/**
|
|
870
|
+
* Returns the data of the last request.
|
|
871
|
+
*
|
|
872
|
+
* Возвращает данные последнего запроса.
|
|
873
|
+
*/
|
|
874
|
+
getResponse() {
|
|
875
|
+
var t;
|
|
876
|
+
return (t = this.get()) == null ? void 0 : t.lastResponse;
|
|
877
|
+
}
|
|
878
|
+
/**
|
|
879
|
+
* Returns messages from the last request.
|
|
880
|
+
*
|
|
881
|
+
* Возвращает сообщения от последнего запроса.
|
|
882
|
+
*/
|
|
883
|
+
getMessage() {
|
|
884
|
+
var t;
|
|
885
|
+
return ((t = this.get()) == null ? void 0 : t.lastMessage) || "";
|
|
886
|
+
}
|
|
887
|
+
/**
|
|
888
|
+
* Sets the status item data.
|
|
889
|
+
*
|
|
890
|
+
* Устанавливает данные элемента статуса.
|
|
891
|
+
* @param data status item data/ данные элемента статуса
|
|
892
|
+
*/
|
|
893
|
+
set(t) {
|
|
894
|
+
return "status" in t && this.setValue("status", t.status), "statusText" in t && this.setValue("statusText", t.statusText), "error" in t && this.setValue("error", t.error), "lastResponse" in t && this.setValue("lastResponse", t.lastResponse), "lastMessage" in t && this.setValue("lastMessage", t.lastMessage), this;
|
|
895
|
+
}
|
|
896
|
+
/**
|
|
897
|
+
* Sets the status code and optional status text.
|
|
898
|
+
*
|
|
899
|
+
* Устанавливает код статуса и необязательный текст статуса.
|
|
900
|
+
* @param status status code/ код статуса
|
|
901
|
+
* @param statusText optional status text/ необязательный текст статуса
|
|
902
|
+
*/
|
|
903
|
+
setStatus(t, e) {
|
|
904
|
+
return this.set({
|
|
905
|
+
status: t,
|
|
906
|
+
statusText: e
|
|
907
|
+
}), this;
|
|
908
|
+
}
|
|
909
|
+
/**
|
|
910
|
+
* Sets the error message.
|
|
911
|
+
*
|
|
912
|
+
* Устанавливает сообщение об ошибке.
|
|
913
|
+
* @param error error message/ сообщение об ошибке
|
|
914
|
+
*/
|
|
915
|
+
setError(t) {
|
|
916
|
+
return this.set({ error: t }), this;
|
|
917
|
+
}
|
|
918
|
+
/**
|
|
919
|
+
* Sets the data of the last response.
|
|
920
|
+
*
|
|
921
|
+
* Устанавливает данные последнего ответа.
|
|
922
|
+
* @param response response data/ данные ответа
|
|
923
|
+
*/
|
|
924
|
+
setLastResponse(t) {
|
|
925
|
+
return t && m(t) && "message" in t && this.setLastMessage(String(t.message)), this.set({ lastResponse: t }), this;
|
|
926
|
+
}
|
|
927
|
+
/**
|
|
928
|
+
* Sets messages from the last request.
|
|
929
|
+
*
|
|
930
|
+
* Устанавливает сообщения от последнего запроса.
|
|
931
|
+
* @param message message text/ текст сообщения
|
|
932
|
+
*/
|
|
933
|
+
setLastMessage(t) {
|
|
934
|
+
return this.set({ lastMessage: t }), this;
|
|
935
|
+
}
|
|
936
|
+
/**
|
|
937
|
+
* Sets a specific field in the status item.
|
|
938
|
+
*
|
|
939
|
+
* Устанавливает конкретное поле в элементе статуса.
|
|
940
|
+
* @param name field name/ название поля
|
|
941
|
+
* @param value field value/ значение поля
|
|
942
|
+
*/
|
|
943
|
+
setValue(t, e) {
|
|
944
|
+
this.value || (this.value = {}), this.value[t] = e;
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
async function wt(i) {
|
|
948
|
+
const t = y(i);
|
|
949
|
+
return t instanceof Promise ? await t : t;
|
|
950
|
+
}
|
|
951
|
+
function Et(i, t) {
|
|
952
|
+
return Math.floor(Math.random() * (t - i + 1) + i);
|
|
953
|
+
}
|
|
954
|
+
const K = "d-response-loading";
|
|
955
|
+
class bt {
|
|
956
|
+
/**
|
|
957
|
+
* Constructor
|
|
958
|
+
* @param requestDefault default request processor/ процессор запросов по умолчанию
|
|
959
|
+
*/
|
|
960
|
+
constructor(t) {
|
|
961
|
+
/** List of first-time API requests/ Список первичных API запросов */
|
|
962
|
+
n(this, "first", []);
|
|
963
|
+
/** Cached responses/ Кешированные ответы */
|
|
964
|
+
n(this, "response", []);
|
|
965
|
+
/** Loading instance/ Экземпляр загрузки */
|
|
966
|
+
n(this, "loading");
|
|
967
|
+
/** Developer mode flag/ Флаг режима разработчика */
|
|
968
|
+
n(this, "devMode", !1);
|
|
969
|
+
this.requestDefault = t;
|
|
970
|
+
}
|
|
971
|
+
/**
|
|
972
|
+
* Checks if there is a global cached request, if there is, returns it.
|
|
973
|
+
*
|
|
974
|
+
* Проверяет, есть ли глобальный кешированный запрос, если есть, возвращает его.
|
|
975
|
+
* @param path link to the request/ ссылка на запрос
|
|
976
|
+
* @param method request method/ метод запроса
|
|
977
|
+
* @param request data for the request/ данные для запроса
|
|
978
|
+
* @param devMode is it developer mode/ является ли режим разработчика
|
|
979
|
+
*/
|
|
980
|
+
get(t = "", e, s, a) {
|
|
981
|
+
return this.response.find((r) => !this.isDisable(r) && this.isPath(r, t) && e === r.method && this.isFirst(r, a) && this.isResponse(r, s) ? (this.isDevMode(a) && console.warn(`Response type: ${r.path}`), this.first.push(r), !0) : !1);
|
|
982
|
+
}
|
|
983
|
+
/**
|
|
984
|
+
* Returns a list of data about the emulator.
|
|
985
|
+
*
|
|
986
|
+
* Возвращает список данных об эмуляторе.
|
|
987
|
+
*/
|
|
988
|
+
getList() {
|
|
989
|
+
return this.response.filter((t) => t.isForGlobal !== !0);
|
|
990
|
+
}
|
|
991
|
+
/**
|
|
992
|
+
* Adding cached requests.
|
|
993
|
+
*
|
|
994
|
+
* Добавление кешированных запросов.
|
|
995
|
+
* @param response data for caching/ данные для кеширования
|
|
996
|
+
*/
|
|
997
|
+
add(t) {
|
|
998
|
+
return this.response.push(...A(t)), this;
|
|
999
|
+
}
|
|
1000
|
+
/**
|
|
1001
|
+
* Sets developer mode.
|
|
1002
|
+
*
|
|
1003
|
+
* Устанавливает режим разработчика.
|
|
1004
|
+
* @param devMode is it developer mode/ является ли режим разработчика
|
|
1005
|
+
*/
|
|
1006
|
+
setDevMode(t) {
|
|
1007
|
+
return this.devMode = t, this;
|
|
1008
|
+
}
|
|
1009
|
+
/**
|
|
1010
|
+
* Выполнение эмулятора, если доступно
|
|
1011
|
+
* @param apiFetch property of the request/ свойство запроса
|
|
1012
|
+
*/
|
|
1013
|
+
async emulator(t) {
|
|
1014
|
+
const {
|
|
1015
|
+
path: e = "",
|
|
1016
|
+
method: s = l.get,
|
|
1017
|
+
global: a = s === l.get,
|
|
1018
|
+
devMode: r = !1
|
|
1019
|
+
} = t;
|
|
1020
|
+
if (a || this.isDevMode(r)) {
|
|
1021
|
+
const h = this.requestDefault.request(t.request), g = this.get(e, s, h, r);
|
|
1022
|
+
if (g) {
|
|
1023
|
+
const f = await this.fetch(g, h);
|
|
1024
|
+
return this.isDevMode(r) && console.warn("Response data:", e, h, f), f;
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
/**
|
|
1029
|
+
* Checks if the cached item is disabled.
|
|
1030
|
+
*
|
|
1031
|
+
* Проверяет, отключен ли кешированный элемент.
|
|
1032
|
+
* @param item cached item/ кешированный элемент
|
|
1033
|
+
*/
|
|
1034
|
+
isDisable(t) {
|
|
1035
|
+
return !!y(t == null ? void 0 : t.disable);
|
|
1036
|
+
}
|
|
1037
|
+
/**
|
|
1038
|
+
* Checks if the path matches the cached one.
|
|
1039
|
+
*
|
|
1040
|
+
* Проверяет, совпадает ли путь с кешированным.
|
|
1041
|
+
* @param item cached item/ кешированный элемент
|
|
1042
|
+
* @param path request path/ путь запроса
|
|
1043
|
+
*/
|
|
1044
|
+
isPath(t, e) {
|
|
1045
|
+
return e === t.path || !!(t.path instanceof RegExp && e.match(t.path));
|
|
1046
|
+
}
|
|
1047
|
+
/**
|
|
1048
|
+
* Checks if it is developer mode.
|
|
1049
|
+
*
|
|
1050
|
+
* Проверяет, является ли режимом разработчика.
|
|
1051
|
+
* @param devMode is it developer mode/ является ли режим разработчика
|
|
1052
|
+
*/
|
|
1053
|
+
isDevMode(t) {
|
|
1054
|
+
return t || this.devMode;
|
|
1055
|
+
}
|
|
1056
|
+
/**
|
|
1057
|
+
* Checks if this is the first request.
|
|
1058
|
+
*
|
|
1059
|
+
* Проверяет, является ли это первым запросом.
|
|
1060
|
+
* @param item cached item/ кешированный элемент
|
|
1061
|
+
* @param devMode is it developer mode/ является ли режим разработчика
|
|
1062
|
+
*/
|
|
1063
|
+
isFirst(t, e) {
|
|
1064
|
+
return this.first.indexOf(t) === -1 || this.isDevMode(e);
|
|
1065
|
+
}
|
|
1066
|
+
/**
|
|
1067
|
+
* Checks if the request matches the cached one.
|
|
1068
|
+
*
|
|
1069
|
+
* Проверяет, совпадает ли запрос с кешированным.
|
|
1070
|
+
* @param item cached item/ кешированный элемент
|
|
1071
|
+
* @param request request data/ данные запроса
|
|
1072
|
+
*/
|
|
1073
|
+
isResponse(t, e) {
|
|
1074
|
+
const s = this.requestDefault.request(t == null ? void 0 : t.request);
|
|
1075
|
+
return e === s || s === "*any" || L(e) && L(s) && m(e) && m(s) && !(e instanceof FormData) && !(s instanceof FormData) && Object.values(e).length === Object.values(s).length && Object.entries(s).reduce(
|
|
1076
|
+
(a, [r, h]) => a && (h === (e == null ? void 0 : e[r]) || h === "*any"),
|
|
1077
|
+
!0
|
|
1078
|
+
);
|
|
1079
|
+
}
|
|
1080
|
+
/**
|
|
1081
|
+
* Emulates an execution request.
|
|
1082
|
+
*
|
|
1083
|
+
* Эмулирует запрос выполнения.
|
|
1084
|
+
* @param response Data for pre-request/ Данные для пред-запроса
|
|
1085
|
+
* @param request data for the request/ данные для запроса
|
|
1086
|
+
*/
|
|
1087
|
+
fetch(t, e) {
|
|
1088
|
+
return this.startResponseLoading(), new Promise((s) => {
|
|
1089
|
+
wt(
|
|
1090
|
+
at(t.response) ? t.response(e) : t.response
|
|
1091
|
+
).then((a) => {
|
|
1092
|
+
t != null && t.lag ? (E.show(), setTimeout(() => {
|
|
1093
|
+
this.stopResponseLoading(), s(a), E.hide();
|
|
1094
|
+
}, Et(0, 2e3))) : (this.stopResponseLoading(), s(a));
|
|
1095
|
+
});
|
|
1096
|
+
});
|
|
1097
|
+
}
|
|
1098
|
+
/**
|
|
1099
|
+
* Enable loading for request emulation.
|
|
1100
|
+
*
|
|
1101
|
+
* Включить загрузку для эмуляции запроса.
|
|
1102
|
+
*/
|
|
1103
|
+
startResponseLoading() {
|
|
1104
|
+
this.loading && clearTimeout(this.loading), u() && document.body.classList.add(K);
|
|
1105
|
+
}
|
|
1106
|
+
/**
|
|
1107
|
+
* Disable loading for request emulation.
|
|
1108
|
+
*
|
|
1109
|
+
* Отключить загрузку для эмуляции запроса.
|
|
1110
|
+
*/
|
|
1111
|
+
stopResponseLoading() {
|
|
1112
|
+
this.loading = setTimeout(() => {
|
|
1113
|
+
this.loading = void 0, u() && document.body.classList.remove(K);
|
|
1114
|
+
}, 1200);
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
class Lt {
|
|
1118
|
+
constructor() {
|
|
1119
|
+
/** Function for call before the request/ Функция для вызова перед запросом */
|
|
1120
|
+
n(this, "callback");
|
|
1121
|
+
/** Function for call after the request/ Функция для вызова после запроса */
|
|
1122
|
+
n(this, "callbackEnd");
|
|
1123
|
+
/** Is the preparation in progress/ Идет ли подготовка */
|
|
1124
|
+
n(this, "loading", !1);
|
|
1125
|
+
}
|
|
1126
|
+
/**
|
|
1127
|
+
* Preparation before executing the request.
|
|
1128
|
+
*
|
|
1129
|
+
* Подготовка перед выполнением запроса.
|
|
1130
|
+
* @param active is preparation active/ активна ли подготовка
|
|
1131
|
+
*/
|
|
1132
|
+
async make(t) {
|
|
1133
|
+
if (t && this.callback)
|
|
1134
|
+
return this.go();
|
|
1135
|
+
}
|
|
1136
|
+
/**
|
|
1137
|
+
* Analysis of the request after execution.
|
|
1138
|
+
*
|
|
1139
|
+
* Анализ запроса после выполнения.
|
|
1140
|
+
* @param active is preparation active/ активна ли подготовка
|
|
1141
|
+
* @param query data received in the request/ данные, полученные в запросе
|
|
1142
|
+
*/
|
|
1143
|
+
async makeEnd(t, e) {
|
|
1144
|
+
let s = {};
|
|
1145
|
+
return t && this.callbackEnd && (s = await this.callbackEnd(e)), s;
|
|
1146
|
+
}
|
|
1147
|
+
/**
|
|
1148
|
+
* The function is modified for a call before the request.
|
|
1149
|
+
*
|
|
1150
|
+
* Изменить функцию перед запросом.
|
|
1151
|
+
* @param callback function for call/ функция для вызова
|
|
1152
|
+
*/
|
|
1153
|
+
set(t) {
|
|
1154
|
+
return this.callback = t, this;
|
|
1155
|
+
}
|
|
1156
|
+
/**
|
|
1157
|
+
* Modify the function after the request.
|
|
1158
|
+
*
|
|
1159
|
+
* Изменить функцию после запроса.
|
|
1160
|
+
* @param callback function for call/ функция для вызова
|
|
1161
|
+
*/
|
|
1162
|
+
setEnd(t) {
|
|
1163
|
+
return this.callbackEnd = t, this;
|
|
1164
|
+
}
|
|
1165
|
+
/**
|
|
1166
|
+
* To execute preparation.
|
|
1167
|
+
*
|
|
1168
|
+
* Выполнить подготовку.
|
|
1169
|
+
*/
|
|
1170
|
+
async go() {
|
|
1171
|
+
return new Promise((t) => {
|
|
1172
|
+
this.loading ? setTimeout(() => this.go().then(t), 160) : this.callback ? (this.loading = !0, this.callback().then(() => {
|
|
1173
|
+
this.loading = !1, t();
|
|
1174
|
+
})) : t();
|
|
1175
|
+
});
|
|
1176
|
+
}
|
|
1177
|
+
/**
|
|
1178
|
+
* Analysis of the request after execution.
|
|
1179
|
+
*
|
|
1180
|
+
* Анализ запроса после выполнения.
|
|
1181
|
+
* @param query data received in the request/ данные, полученные в запросе
|
|
1182
|
+
*/
|
|
1183
|
+
async end(t) {
|
|
1184
|
+
let e = {};
|
|
1185
|
+
return this.callbackEnd && (e = await this.callbackEnd(t)), e;
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
const c = class c {
|
|
1189
|
+
/**
|
|
1190
|
+
* Is the server local.
|
|
1191
|
+
*
|
|
1192
|
+
* Является ли сервер локальный.
|
|
1193
|
+
*/
|
|
1194
|
+
static isLocalhost() {
|
|
1195
|
+
return typeof location == "undefined" || location.hostname === "localhost";
|
|
1196
|
+
}
|
|
1197
|
+
/**
|
|
1198
|
+
* Returns the status of the last request.
|
|
1199
|
+
*
|
|
1200
|
+
* Возвращает статус последнего запроса.
|
|
1201
|
+
*/
|
|
1202
|
+
static getStatus() {
|
|
1203
|
+
return this.status;
|
|
1204
|
+
}
|
|
1205
|
+
/**
|
|
1206
|
+
* Getting the response handler.
|
|
1207
|
+
*
|
|
1208
|
+
* Получение обработчика ответа.
|
|
1209
|
+
*/
|
|
1210
|
+
static getResponse() {
|
|
1211
|
+
return this.response;
|
|
1212
|
+
}
|
|
1213
|
+
/**
|
|
1214
|
+
* Getting the full path to the request script.
|
|
1215
|
+
*
|
|
1216
|
+
* Получение полного пути к скрипту запроса.
|
|
1217
|
+
* @param path path to the script/ путь к скрипту
|
|
1218
|
+
* @param api adding a path to the site’s API/ добавление пути к API сайта
|
|
1219
|
+
*/
|
|
1220
|
+
static getUrl(t, e = !0) {
|
|
1221
|
+
return `${e ? this.url : ""}${t}`.replace("{locale}", S.getLocation()).replace("{country}", S.getCountry()).replace("{language}", S.getLanguage());
|
|
1222
|
+
}
|
|
1223
|
+
/**
|
|
1224
|
+
* Getting data for the body.
|
|
1225
|
+
*
|
|
1226
|
+
* Получение данных для тела.
|
|
1227
|
+
* @param request this request/ данный запрос
|
|
1228
|
+
* @param method method for request/ метод запрос
|
|
1229
|
+
*/
|
|
1230
|
+
static getBody(t = {}, e = l.get) {
|
|
1231
|
+
if (t instanceof FormData)
|
|
1232
|
+
return t;
|
|
1233
|
+
if (e !== l.get && L(t))
|
|
1234
|
+
return T(t) ? t : JSON.stringify(t);
|
|
1235
|
+
}
|
|
1236
|
+
/**
|
|
1237
|
+
* Getting data for the body of the get method.
|
|
1238
|
+
*
|
|
1239
|
+
* Получение данных для тела метода get.
|
|
1240
|
+
* @param request this request/ данный запрос
|
|
1241
|
+
* @param path path to request/ путь к запрос
|
|
1242
|
+
* @param method method for request/ метод запрос
|
|
1243
|
+
*/
|
|
1244
|
+
static getBodyForGet(t, e = "", s = l.get) {
|
|
1245
|
+
if (s === l.get) {
|
|
1246
|
+
const a = e.match(/\?/) ? "&" : "?", r = typeof t == "object" ? it(t) : t;
|
|
1247
|
+
if (L(r))
|
|
1248
|
+
return `${a}${r}`;
|
|
1249
|
+
}
|
|
1250
|
+
return "";
|
|
1251
|
+
}
|
|
1252
|
+
/**
|
|
1253
|
+
* Modifies the default header data.
|
|
1254
|
+
*
|
|
1255
|
+
* Изменяет данные заголовка по умолчанию.
|
|
1256
|
+
*/
|
|
1257
|
+
static setHeaders(t) {
|
|
1258
|
+
return this.headers.set(t), c;
|
|
1259
|
+
}
|
|
1260
|
+
/**
|
|
1261
|
+
* Modifies the default request data.
|
|
1262
|
+
*
|
|
1263
|
+
* Изменяет данные запроса по умолчанию.
|
|
1264
|
+
*/
|
|
1265
|
+
static setRequestDefault(t) {
|
|
1266
|
+
return this.requestDefault.set(t), c;
|
|
1267
|
+
}
|
|
1268
|
+
/**
|
|
1269
|
+
* Change the base path to the script.
|
|
1270
|
+
*
|
|
1271
|
+
* Изменить базовый путь к скрипту.
|
|
1272
|
+
* @param url path to the script/ путь к скрипту
|
|
1273
|
+
*/
|
|
1274
|
+
static setUrl(t) {
|
|
1275
|
+
return this.url = t, c;
|
|
1276
|
+
}
|
|
1277
|
+
/**
|
|
1278
|
+
* The function is modified for a call before the request.
|
|
1279
|
+
*
|
|
1280
|
+
* Изменить функцию перед запросом.
|
|
1281
|
+
* @param callback function for call/ функция для вызова
|
|
1282
|
+
*/
|
|
1283
|
+
static setPreparation(t) {
|
|
1284
|
+
return this.preparation.set(t), c;
|
|
1285
|
+
}
|
|
1286
|
+
/**
|
|
1287
|
+
* Modify the function after the request.
|
|
1288
|
+
*
|
|
1289
|
+
* Изменить функцию после запроса.
|
|
1290
|
+
* @param callback function for call/ функция для вызова
|
|
1291
|
+
*/
|
|
1292
|
+
static setEnd(t) {
|
|
1293
|
+
return this.preparation.setEnd(t), c;
|
|
1294
|
+
}
|
|
1295
|
+
/**
|
|
1296
|
+
* To execute a request.
|
|
1297
|
+
*
|
|
1298
|
+
* Выполнить запрос.
|
|
1299
|
+
* @param pathRequest query string or list of parameters/ строка запроса или список параметров
|
|
1300
|
+
*/
|
|
1301
|
+
static async request(t) {
|
|
1302
|
+
return T(t) ? await this.fetch({
|
|
1303
|
+
path: t
|
|
1304
|
+
}) : await this.fetch(t);
|
|
1305
|
+
}
|
|
1306
|
+
/**
|
|
1307
|
+
* Sends a get method request.
|
|
1308
|
+
*
|
|
1309
|
+
* Отправляет запрос метода get.
|
|
1310
|
+
* @param request list of parameters/ список параметров
|
|
1311
|
+
*/
|
|
1312
|
+
static get(t) {
|
|
1313
|
+
return this.request({
|
|
1314
|
+
...t,
|
|
1315
|
+
method: l.get
|
|
1316
|
+
});
|
|
1317
|
+
}
|
|
1318
|
+
/**
|
|
1319
|
+
* Sends a post method request.
|
|
1320
|
+
*
|
|
1321
|
+
* Отправляет запрос метода post.
|
|
1322
|
+
* @param request list of parameters/ список параметров
|
|
1323
|
+
*/
|
|
1324
|
+
static post(t) {
|
|
1325
|
+
return this.request({
|
|
1326
|
+
...t,
|
|
1327
|
+
method: l.post
|
|
1328
|
+
});
|
|
1329
|
+
}
|
|
1330
|
+
/**
|
|
1331
|
+
* Sends a put method request.
|
|
1332
|
+
*
|
|
1333
|
+
* Отправляет запрос метода put.
|
|
1334
|
+
* @param request list of parameters/ список параметров
|
|
1335
|
+
*/
|
|
1336
|
+
static put(t) {
|
|
1337
|
+
return this.request({
|
|
1338
|
+
...t,
|
|
1339
|
+
method: l.put
|
|
1340
|
+
});
|
|
1341
|
+
}
|
|
1342
|
+
/**
|
|
1343
|
+
* Sends a delete method request.
|
|
1344
|
+
*
|
|
1345
|
+
* Отправляет запрос метода delete.
|
|
1346
|
+
* @param request list of parameters/ список параметров
|
|
1347
|
+
*/
|
|
1348
|
+
static delete(t) {
|
|
1349
|
+
return this.request({
|
|
1350
|
+
...t,
|
|
1351
|
+
method: l.delete
|
|
1352
|
+
});
|
|
1353
|
+
}
|
|
1354
|
+
/**
|
|
1355
|
+
* To execute a request.
|
|
1356
|
+
*
|
|
1357
|
+
* Выполнить запрос.
|
|
1358
|
+
* @param apiFetch property of the request/ свойство запроса
|
|
1359
|
+
*/
|
|
1360
|
+
static async fetch(t) {
|
|
1361
|
+
const {
|
|
1362
|
+
toData: e = !0,
|
|
1363
|
+
hideError: s = !1,
|
|
1364
|
+
queryReturn: a = void 0,
|
|
1365
|
+
globalPreparation: r = !0,
|
|
1366
|
+
globalEnd: h = !0
|
|
1367
|
+
} = t, g = await this.response.emulator(t);
|
|
1368
|
+
if (g)
|
|
1369
|
+
return g;
|
|
1370
|
+
let f = {};
|
|
1371
|
+
E.show();
|
|
1372
|
+
try {
|
|
1373
|
+
await this.preparation.make(r);
|
|
1374
|
+
const d = await this.makeQuery(t), v = await this.preparation.makeEnd(h, d);
|
|
1375
|
+
if (this.status.setStatus(
|
|
1376
|
+
d.status,
|
|
1377
|
+
d.statusText
|
|
1378
|
+
), v != null && v.reset)
|
|
1379
|
+
return E.hide(), await this.fetch(t);
|
|
1380
|
+
f = await this.readData(
|
|
1381
|
+
d,
|
|
1382
|
+
a,
|
|
1383
|
+
v
|
|
1384
|
+
);
|
|
1385
|
+
} catch (d) {
|
|
1386
|
+
s || console.error("Api: ", d), this.status.setError(String(d));
|
|
1387
|
+
}
|
|
1388
|
+
return E.hide(), this.makeData(f, e);
|
|
1389
|
+
}
|
|
1390
|
+
/**
|
|
1391
|
+
* Reading data from the response.
|
|
1392
|
+
*
|
|
1393
|
+
* Чтение данных из ответа.
|
|
1394
|
+
* @param query response from the server/ ответ от сервера
|
|
1395
|
+
* @param queryReturn custom function for reading data/ кастомная функция для чтения данных
|
|
1396
|
+
* @param end finalization data/ данные финализации
|
|
1397
|
+
*/
|
|
1398
|
+
static async readData(t, e, s) {
|
|
1399
|
+
var a;
|
|
1400
|
+
return e ? await e(t) : "data" in s ? s.data : ((a = t.headers.get("Content-Type")) != null ? a : "").match("application/json") ? await t.json() : { data: await t.text() };
|
|
1401
|
+
}
|
|
1402
|
+
/**
|
|
1403
|
+
* Executing the request.
|
|
1404
|
+
*
|
|
1405
|
+
* Выполнение запроса.
|
|
1406
|
+
* @param apiFetch property of the request/ свойство запроса
|
|
1407
|
+
*/
|
|
1408
|
+
static async makeQuery(t) {
|
|
1409
|
+
const e = this.requestDefault.request(t.request), {
|
|
1410
|
+
api: s = !0,
|
|
1411
|
+
path: a = "",
|
|
1412
|
+
pathFull: r = void 0,
|
|
1413
|
+
method: h = l.get,
|
|
1414
|
+
headers: g = {},
|
|
1415
|
+
type: f = "application/json;charset=UTF-8",
|
|
1416
|
+
init: d = {}
|
|
1417
|
+
} = t, v = r != null ? r : this.getUrl(a, s), ot = `${v}${this.getBodyForGet(e, v, h)}`, j = this.headers.get(g, f), U = {
|
|
1418
|
+
...d,
|
|
1419
|
+
method: h,
|
|
1420
|
+
body: this.getBody(e, h)
|
|
1421
|
+
};
|
|
1422
|
+
return j && (U.headers = j), await fetch(ot, U);
|
|
1423
|
+
}
|
|
1424
|
+
/**
|
|
1425
|
+
* Transforms data if needed.
|
|
1426
|
+
*
|
|
1427
|
+
* Преобразует данные, если нужно.
|
|
1428
|
+
* @param data data for transformation/ данные для преобразования
|
|
1429
|
+
* @param toData is it necessary to process the data/ нужно ли обрабатывать данные
|
|
1430
|
+
*/
|
|
1431
|
+
static makeData(t, e) {
|
|
1432
|
+
if (this.status.setLastResponse(t), t && e && m(t) && "data" in t) {
|
|
1433
|
+
if (m(t.data)) {
|
|
1434
|
+
const s = { ...t.data };
|
|
1435
|
+
return "success" in t && (s.success = t.success), s;
|
|
1436
|
+
}
|
|
1437
|
+
return t.data;
|
|
1438
|
+
}
|
|
1439
|
+
return t;
|
|
1440
|
+
}
|
|
1441
|
+
};
|
|
1442
|
+
n(c, "url", "/api/"), n(c, "headers", new yt()), n(c, "requestDefault", new mt()), n(c, "status", new vt()), n(c, "response", new bt(c.requestDefault)), n(c, "preparation", new Lt());
|
|
1443
|
+
let F = c;
|
|
1444
|
+
class Ct {
|
|
1445
|
+
/**
|
|
1446
|
+
* Constructor
|
|
1447
|
+
* @param callback function for the cache/ функция для кэша
|
|
1448
|
+
*/
|
|
1449
|
+
constructor(t) {
|
|
1450
|
+
n(this, "cache");
|
|
1451
|
+
n(this, "cacheOld");
|
|
1452
|
+
n(this, "comparisons", []);
|
|
1453
|
+
this.callback = t;
|
|
1454
|
+
}
|
|
1455
|
+
/**
|
|
1456
|
+
* Getting data for the cache, and if there is no cache, it performs a function to save the cache.
|
|
1457
|
+
*
|
|
1458
|
+
* Получение данных для кэша, и если нет кэша, выполняет функцию для сохранения кэша.
|
|
1459
|
+
* @param comparison additional data for comparison/ дополнительные данные для сравнения
|
|
1460
|
+
*/
|
|
1461
|
+
getCache(t) {
|
|
1462
|
+
return this.isUpdate(t) && (this.cacheOld = this.cache, this.setCache()), this.cache;
|
|
1463
|
+
}
|
|
1464
|
+
/**
|
|
1465
|
+
* Getting the previous value of the cache.
|
|
1466
|
+
*
|
|
1467
|
+
* Получение предыдущего значения кэша.
|
|
1468
|
+
*/
|
|
1469
|
+
getCacheOld() {
|
|
1470
|
+
return this.cacheOld;
|
|
1471
|
+
}
|
|
1472
|
+
/**
|
|
1473
|
+
* Getting data for the cache, and if there is no cache, it performs a function to save the cache (Async).
|
|
1474
|
+
*
|
|
1475
|
+
* Получение данных для кэша, и если нет кэша, выполняет функцию для сохранения кэша (Async).
|
|
1476
|
+
* @param comparison additional data for comparison/ дополнительные данные для сравнения
|
|
1477
|
+
*/
|
|
1478
|
+
async getCacheAsync(t) {
|
|
1479
|
+
return this.isUpdate(t) && (this.cacheOld = this.cache, await this.setCacheAsync()), this.cache;
|
|
1480
|
+
}
|
|
1481
|
+
/**
|
|
1482
|
+
* Overwrites or adds new values for the cache.
|
|
1483
|
+
*
|
|
1484
|
+
* Перезаписывает или добавляет новые значения для кэша.
|
|
1485
|
+
*/
|
|
1486
|
+
setCache() {
|
|
1487
|
+
this.cache = this.callback();
|
|
1488
|
+
}
|
|
1489
|
+
/**
|
|
1490
|
+
* Overwrites or adds new values for the cache (Async).
|
|
1491
|
+
*
|
|
1492
|
+
* Перезаписывает или добавляет новые значения для кэша (Async).
|
|
1493
|
+
*/
|
|
1494
|
+
async setCacheAsync() {
|
|
1495
|
+
this.cache = await this.callback();
|
|
1496
|
+
}
|
|
1497
|
+
/**
|
|
1498
|
+
* Checking additional data.
|
|
1499
|
+
*
|
|
1500
|
+
* Проверка дополнительных данных.
|
|
1501
|
+
* @param comparison additional data for comparison/ дополнительные данные для сравнения
|
|
1502
|
+
*/
|
|
1503
|
+
isUpdate(t) {
|
|
1504
|
+
return this.cache === void 0 || this.comparisons.length !== t.length || this.comparisons.findIndex((e, s) => e !== t[s]) >= 0 ? (this.comparisons = [...t], !0) : !1;
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
class St {
|
|
1508
|
+
constructor() {
|
|
1509
|
+
n(this, "cache", {});
|
|
1510
|
+
}
|
|
1511
|
+
/**
|
|
1512
|
+
* Getting data for the cache, and if there is no cache, it performs a function to save the cache.
|
|
1513
|
+
*
|
|
1514
|
+
* Получение данных для кэша, и если нет кэша, выполняет функцию для сохранения кэша.
|
|
1515
|
+
* @param name cache name/ название кэша
|
|
1516
|
+
* @param callback function for the cache/ функция для кэша
|
|
1517
|
+
* @param comparison additional data for comparison/ дополнительные данные для сравнения
|
|
1518
|
+
*/
|
|
1519
|
+
get(t, e, s) {
|
|
1520
|
+
return this.getCacheItem(t, e).getCache(s != null ? s : []);
|
|
1521
|
+
}
|
|
1522
|
+
/**
|
|
1523
|
+
* Getting data for the cache, and if there is no cache, it performs a function to save the cache (Async).
|
|
1524
|
+
*
|
|
1525
|
+
* Получение данных для кэша, и если нет кэша, выполняет функцию для сохранения кэша (Async).
|
|
1526
|
+
* @param name cache name/ название кэша
|
|
1527
|
+
* @param callback function for the cache/ функция для кэша
|
|
1528
|
+
* @param comparison additional data for comparison/ дополнительные данные для сравнения
|
|
1529
|
+
*/
|
|
1530
|
+
async getAsync(t, e, s) {
|
|
1531
|
+
return await this.getCacheItem(t, e).getCacheAsync(s != null ? s : []);
|
|
1532
|
+
}
|
|
1533
|
+
/**
|
|
1534
|
+
* Returns an instance of the object for working with the cache element.
|
|
1535
|
+
*
|
|
1536
|
+
* Возвращает экземпляр объекта для работы с элементом кэша.
|
|
1537
|
+
* @param name cache name/ название кэша
|
|
1538
|
+
* @param callback function for the cache/ функция для кэша
|
|
1539
|
+
*/
|
|
1540
|
+
getCacheItem(t, e) {
|
|
1541
|
+
return t in this.cache || (this.cache[t] = new Ct(e)), this.cache[t];
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
const R = class R {
|
|
1545
|
+
/**
|
|
1546
|
+
* Getting data for the cache, and if there is no cache, it performs a function to save the cache.
|
|
1547
|
+
*
|
|
1548
|
+
* Получение данных для кэша, и если нет кэша, выполняет функцию для сохранения кэша.
|
|
1549
|
+
* @param name cache name/ название кэша
|
|
1550
|
+
* @param callback function for the cache/ функция для кэша
|
|
1551
|
+
* @param comparison additional data for comparison/ дополнительные данные для сравнения
|
|
1552
|
+
*/
|
|
1553
|
+
static get(t, e, s) {
|
|
1554
|
+
return this.cache.get(t, e, s);
|
|
1555
|
+
}
|
|
1556
|
+
};
|
|
1557
|
+
n(R, "cache"), R.cache = new St();
|
|
1558
|
+
let Q = R;
|
|
1559
|
+
function nt(i, t = !1) {
|
|
1560
|
+
if (typeof i == "string") {
|
|
1561
|
+
const e = i.trim();
|
|
1562
|
+
switch (e) {
|
|
1563
|
+
case "undefined":
|
|
1564
|
+
return;
|
|
1565
|
+
case "null":
|
|
1566
|
+
return null;
|
|
1567
|
+
case "true":
|
|
1568
|
+
return !0;
|
|
1569
|
+
case "false":
|
|
1570
|
+
return !1;
|
|
1571
|
+
default:
|
|
1572
|
+
if (/^[{[]/.exec(e))
|
|
1573
|
+
try {
|
|
1574
|
+
return JSON.parse(e);
|
|
1575
|
+
} catch (s) {
|
|
1576
|
+
console.error("transformation: JSON error", s);
|
|
1577
|
+
}
|
|
1578
|
+
else {
|
|
1579
|
+
if (/^[0-9]+\.[0-9.]+$/.exec(e))
|
|
1580
|
+
return parseFloat(e);
|
|
1581
|
+
if (/^[0-9]+$/.exec(e))
|
|
1582
|
+
return parseInt(e, 10);
|
|
1583
|
+
if (t && u() && typeof (window == null ? void 0 : window[e]) == "function")
|
|
1584
|
+
return window[e];
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1588
|
+
return i;
|
|
1589
|
+
}
|
|
1590
|
+
const Dt = "cookie-block";
|
|
1591
|
+
class ht {
|
|
1592
|
+
/**
|
|
1593
|
+
* Obtaining status.
|
|
1594
|
+
*
|
|
1595
|
+
* Получение статуса.
|
|
1596
|
+
*/
|
|
1597
|
+
static get() {
|
|
1598
|
+
var t;
|
|
1599
|
+
return (t = this.storage.get()) != null ? t : !1;
|
|
1600
|
+
}
|
|
1601
|
+
/**
|
|
1602
|
+
* Changing status.
|
|
1603
|
+
*
|
|
1604
|
+
* Изменение статуса.
|
|
1605
|
+
* @param value value to be changed/ значение, на которое будет изменен
|
|
1606
|
+
*/
|
|
1607
|
+
static set(t) {
|
|
1608
|
+
this.storage.set(t);
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
n(ht, "storage", new z(Dt));
|
|
1612
|
+
const $ = {}, x = class x {
|
|
1613
|
+
constructor(t) {
|
|
1614
|
+
n(this, "value");
|
|
1615
|
+
n(this, "options", {});
|
|
1616
|
+
if (this.name = t, t in B)
|
|
1617
|
+
return B[t];
|
|
1618
|
+
this.value = $ == null ? void 0 : $[t], B[t] = this;
|
|
1619
|
+
}
|
|
1620
|
+
/**
|
|
1621
|
+
* Get data or update if none.
|
|
1622
|
+
*
|
|
1623
|
+
* Получает данные или обновляет, если их нет.
|
|
1624
|
+
* @param defaultValue value or function to change data/ значение или функция для изменения данных
|
|
1625
|
+
* @param options additional parameters/ дополнительные параметры
|
|
1626
|
+
*/
|
|
1627
|
+
get(t, e) {
|
|
1628
|
+
return this.value === void 0 && t && this.set(t, e), this.value;
|
|
1629
|
+
}
|
|
1630
|
+
/**
|
|
1631
|
+
* Updates cookie data.
|
|
1632
|
+
*
|
|
1633
|
+
* Обновляет данные cookie.
|
|
1634
|
+
* @param value value or function to change data/ значение или функция для изменения данных
|
|
1635
|
+
* @param options additional parameters/ дополнительные параметры
|
|
1636
|
+
*/
|
|
1637
|
+
set(t, e) {
|
|
1638
|
+
this.value = y(t), Object.assign(this.options, e), this.update();
|
|
1639
|
+
}
|
|
1640
|
+
/**
|
|
1641
|
+
* Delete cookie data.
|
|
1642
|
+
*
|
|
1643
|
+
* Удаление данных из cookie.
|
|
1644
|
+
*/
|
|
1645
|
+
remove() {
|
|
1646
|
+
this.set("");
|
|
1647
|
+
}
|
|
1648
|
+
/**
|
|
1649
|
+
* Returns cache time.
|
|
1650
|
+
*
|
|
1651
|
+
* Возвращает время кэширования.
|
|
1652
|
+
*/
|
|
1653
|
+
getAge() {
|
|
1654
|
+
var t, e;
|
|
1655
|
+
return (e = (t = this.options) == null ? void 0 : t.age) != null ? e : 10080 * 60;
|
|
1656
|
+
}
|
|
1657
|
+
/**
|
|
1658
|
+
* Update cookie data.
|
|
1659
|
+
*
|
|
1660
|
+
* Обновление данных cookie.
|
|
1661
|
+
*/
|
|
1662
|
+
update() {
|
|
1663
|
+
var t, e, s, a, r;
|
|
1664
|
+
if (u() && !ht.get()) {
|
|
1665
|
+
const h = String((t = this.value) != null ? t : "");
|
|
1666
|
+
document.cookie = [
|
|
1667
|
+
`${encodeURIComponent(this.name)}=${encodeURIComponent(h)}`,
|
|
1668
|
+
`max-age=${h === "" ? "-1" : this.getAge()}`,
|
|
1669
|
+
`SameSite=${(s = (e = this.options) == null ? void 0 : e.sameSite) != null ? s : "strict"}`,
|
|
1670
|
+
...(r = (a = this.options) == null ? void 0 : a.arguments) != null ? r : []
|
|
1671
|
+
].join("; ");
|
|
1672
|
+
}
|
|
1673
|
+
}
|
|
1674
|
+
/**
|
|
1675
|
+
* Update data from cookies.
|
|
1676
|
+
*
|
|
1677
|
+
* Обновляет данные из cookies.
|
|
1678
|
+
*/
|
|
1679
|
+
static updateData() {
|
|
1680
|
+
for (const t of document.cookie.split(";")) {
|
|
1681
|
+
const [e, s] = t.trim().split("=");
|
|
1682
|
+
e && L(s) && ($[e] = nt(s));
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
};
|
|
1686
|
+
u() && x.updateData();
|
|
1687
|
+
let Y = x;
|
|
1688
|
+
const B = {}, C = class C {
|
|
1689
|
+
/**
|
|
1690
|
+
* Getting an object with information about the phone code and country.
|
|
1691
|
+
*
|
|
1692
|
+
* Получение объекта с информацией о телефонном коде и стране.
|
|
1693
|
+
* @param code country and language code/ код страны и языка
|
|
1694
|
+
*/
|
|
1695
|
+
static get(t) {
|
|
1696
|
+
return this.list.find((e) => t === e.value);
|
|
1697
|
+
}
|
|
1698
|
+
/**
|
|
1699
|
+
* Getting information by phone.
|
|
1700
|
+
*
|
|
1701
|
+
* Получение информации по телефону.
|
|
1702
|
+
* @param phone phone number/ номер телефон
|
|
1703
|
+
*/
|
|
1704
|
+
static getByPhone(t) {
|
|
1705
|
+
let e = this.map, s, a = "";
|
|
1706
|
+
return this.toNumber(t).forEach((r) => {
|
|
1707
|
+
var h;
|
|
1708
|
+
a === "" && r in e ? (s = e[r], e = (h = s == null ? void 0 : s.next) != null ? h : {}) : a += r;
|
|
1709
|
+
}), {
|
|
1710
|
+
item: s,
|
|
1711
|
+
phone: a
|
|
1712
|
+
};
|
|
1713
|
+
}
|
|
1714
|
+
/**
|
|
1715
|
+
* Retrieves complete mask data by country code.
|
|
1716
|
+
*
|
|
1717
|
+
* Получает полные данные о маске по коду страны.
|
|
1718
|
+
* @param code country and language code/ код страны и языка
|
|
1719
|
+
*/
|
|
1720
|
+
static getByCode(t) {
|
|
1721
|
+
var s;
|
|
1722
|
+
const e = this.get(t);
|
|
1723
|
+
if (e)
|
|
1724
|
+
return (s = this.getByPhone(e.phone.toString())) == null ? void 0 : s.item;
|
|
1725
|
+
}
|
|
1726
|
+
/**
|
|
1727
|
+
* We get an array from a list of all phone numbers.
|
|
1728
|
+
*
|
|
1729
|
+
* Получаем массив из списка всех телефонных кодов.
|
|
1730
|
+
*/
|
|
1731
|
+
static getList() {
|
|
1732
|
+
return this.list;
|
|
1733
|
+
}
|
|
1734
|
+
/**
|
|
1735
|
+
* We get a map of a tree, sorted by its code.
|
|
1736
|
+
*
|
|
1737
|
+
* Получаем карту дерева, отсортированную по его коду.
|
|
1738
|
+
*/
|
|
1739
|
+
static getMap() {
|
|
1740
|
+
return this.map;
|
|
1741
|
+
}
|
|
1742
|
+
/**
|
|
1743
|
+
* Convert to phone mask.
|
|
1744
|
+
*
|
|
1745
|
+
* Преобразовать в маску телефона.
|
|
1746
|
+
* @param phone phone number/ номер телефон
|
|
1747
|
+
* @param masks a mask to transform a phone number/ маска для преобразования номер телефон
|
|
1748
|
+
*/
|
|
1749
|
+
static toMask(t, e) {
|
|
1750
|
+
if (L(t) && Array.isArray(e) && e.length > 0) {
|
|
1751
|
+
const s = this.removeZero(t), a = s.length;
|
|
1752
|
+
for (const r of e)
|
|
1753
|
+
if (this.getUnnecessaryLength(r) === a)
|
|
1754
|
+
return this.toStandard(s, r);
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
/**
|
|
1758
|
+
* Deletes the country code from the input number.
|
|
1759
|
+
*
|
|
1760
|
+
* Удаляет код страны по входному номеру.
|
|
1761
|
+
* @param phone phone number/ номер телефон
|
|
1762
|
+
*/
|
|
1763
|
+
static removeZero(t) {
|
|
1764
|
+
return t.match(/^0/) ? t.replace(/^0/, "") : t.match(/^89/) ? t.replace(/^8/, "") : t;
|
|
1765
|
+
}
|
|
1766
|
+
/**
|
|
1767
|
+
* Returns the symbol by the internal country code.
|
|
1768
|
+
*
|
|
1769
|
+
* Возвращает символ по коду внутри страны.
|
|
1770
|
+
* @param within internal country code/ код внутри страны
|
|
1771
|
+
*/
|
|
1772
|
+
static getWithinSymbol(t) {
|
|
1773
|
+
switch (t) {
|
|
1774
|
+
case 4:
|
|
1775
|
+
case "4":
|
|
1776
|
+
return "$";
|
|
1777
|
+
case 8:
|
|
1778
|
+
case "8":
|
|
1779
|
+
return "~";
|
|
1780
|
+
}
|
|
1781
|
+
return "=";
|
|
1782
|
+
}
|
|
1783
|
+
/**
|
|
1784
|
+
* Deletes all characters that do not belong to the mask.
|
|
1785
|
+
*
|
|
1786
|
+
* Удаляет все символы, не относящиеся к маске.
|
|
1787
|
+
* @param mask A mask to transform a phone number/ маска для преобразования номер телефон
|
|
1788
|
+
*/
|
|
1789
|
+
static getUnnecessaryLength(t) {
|
|
1790
|
+
return t.replace(/[^*]+/ig, "").length;
|
|
1791
|
+
}
|
|
1792
|
+
/**
|
|
1793
|
+
* Creating a list for the map.
|
|
1794
|
+
*
|
|
1795
|
+
* Формирование списка для карты.
|
|
1796
|
+
*/
|
|
1797
|
+
static makeList() {
|
|
1798
|
+
const t = b(S.getList(), (e) => {
|
|
1799
|
+
if (e != null && e.phoneMask)
|
|
1800
|
+
return {
|
|
1801
|
+
phone: (e == null ? void 0 : e.phoneCode) && Number(e.phoneCode.replace(/[^0-9]+/, "")) || void 0,
|
|
1802
|
+
within: (e == null ? void 0 : e.phoneWithin) || 0,
|
|
1803
|
+
mask: A(e.phoneMask),
|
|
1804
|
+
value: e.country
|
|
1805
|
+
};
|
|
1806
|
+
});
|
|
1807
|
+
this.list = t.sort((e, s) => e.phone - s.phone);
|
|
1808
|
+
}
|
|
1809
|
+
/**
|
|
1810
|
+
* Creating a map for search.
|
|
1811
|
+
*
|
|
1812
|
+
* Создание карты для поиска.
|
|
1813
|
+
*/
|
|
1814
|
+
static makeMap() {
|
|
1815
|
+
this.list.forEach((t) => {
|
|
1816
|
+
t.mask.forEach((e) => {
|
|
1817
|
+
let s = this.map, a;
|
|
1818
|
+
if (this.toNumber(e).forEach((r) => {
|
|
1819
|
+
var h;
|
|
1820
|
+
r in s || (s[r] = {
|
|
1821
|
+
items: [],
|
|
1822
|
+
info: void 0,
|
|
1823
|
+
value: void 0,
|
|
1824
|
+
mask: [],
|
|
1825
|
+
maskFull: [],
|
|
1826
|
+
next: {}
|
|
1827
|
+
}), a = s[r], s = (h = a == null ? void 0 : a.next) != null ? h : {};
|
|
1828
|
+
}), a) {
|
|
1829
|
+
a.value === void 0 && (a.info = t, a.value = t.value);
|
|
1830
|
+
const r = this.toWithin(e, t.within);
|
|
1831
|
+
a.mask.push(r), a.maskFull.push(r.replace(/\d/ig, "*")), a.items.push(t);
|
|
1832
|
+
}
|
|
1833
|
+
});
|
|
1834
|
+
});
|
|
1835
|
+
}
|
|
1836
|
+
/**
|
|
1837
|
+
* The method parses a string argument and returns a floating point number.
|
|
1838
|
+
*
|
|
1839
|
+
* Метод принимает строку в качестве аргумента и возвращает десятичное число.
|
|
1840
|
+
* @param value the value to parse/ текстовая строка
|
|
1841
|
+
*/
|
|
1842
|
+
static toNumber(t) {
|
|
1843
|
+
return t.replace(/\D+/ig, "").split("");
|
|
1844
|
+
}
|
|
1845
|
+
/**
|
|
1846
|
+
* Converts the phone to a standard.
|
|
1847
|
+
*
|
|
1848
|
+
* Преобразовывает телефон в стандарт.
|
|
1849
|
+
* @param phone phone number/ номер телефон
|
|
1850
|
+
* @param mask a mask to transform a phone number/ маска для преобразования номер телефон
|
|
1851
|
+
*/
|
|
1852
|
+
static toStandard(t, e) {
|
|
1853
|
+
let s = 0;
|
|
1854
|
+
return e.replace(/\*/ig, () => String(t[s++]));
|
|
1855
|
+
}
|
|
1856
|
+
/**
|
|
1857
|
+
* Replaces the first character with the internal country code
|
|
1858
|
+
*
|
|
1859
|
+
* Заменяет первый символ на код внутри страны.
|
|
1860
|
+
* @param mask a mask to transform a phone number/ маска для преобразования номер телефон
|
|
1861
|
+
* @param within internal country code/ код внутри страны
|
|
1862
|
+
*/
|
|
1863
|
+
static toWithin(t, e) {
|
|
1864
|
+
return t.replace(/\*/, this.getWithinSymbol(e));
|
|
1865
|
+
}
|
|
1866
|
+
};
|
|
1867
|
+
n(C, "list", []), n(C, "map", {}), C.makeList(), C.makeMap();
|
|
1868
|
+
let X = C;
|
|
1869
|
+
const w = class w {
|
|
1870
|
+
/**
|
|
1871
|
+
* Get data from hash.
|
|
1872
|
+
*
|
|
1873
|
+
* Получение данных из хэша.
|
|
1874
|
+
* @param name variable names/ названия переменных
|
|
1875
|
+
* @param defaultValue value or function to change data/ значение или функция для изменения данных
|
|
1876
|
+
*/
|
|
1877
|
+
static get(t, e) {
|
|
1878
|
+
return !(t in this.hash) && e && this.set(t, e), this.hash[t];
|
|
1879
|
+
}
|
|
1880
|
+
/**
|
|
1881
|
+
* Change data in hash.
|
|
1882
|
+
*
|
|
1883
|
+
* Изменение данных в хэше.
|
|
1884
|
+
* @param name variable names/ названия переменных
|
|
1885
|
+
* @param callback value or function to change data/ значение или функция для изменения данных
|
|
1886
|
+
*/
|
|
1887
|
+
static set(t, e) {
|
|
1888
|
+
var a;
|
|
1889
|
+
const s = y(e);
|
|
1890
|
+
s !== ((a = this.hash) == null ? void 0 : a[t]) && (this.hash[t] = s, this.update());
|
|
1891
|
+
}
|
|
1892
|
+
/**
|
|
1893
|
+
* Adding an event when data is changed.
|
|
1894
|
+
*
|
|
1895
|
+
* Добавление события при изменении данных.
|
|
1896
|
+
* @param name variable names/ названия переменных
|
|
1897
|
+
* @param callback the function is called when the data is changed/ функция вызывается при изменении данных
|
|
1898
|
+
*/
|
|
1899
|
+
static addWatch(t, e) {
|
|
1900
|
+
var s;
|
|
1901
|
+
t in this.watch ? (s = this.watch[t]) == null || s.push(e) : this.watch[t] = [e];
|
|
1902
|
+
}
|
|
1903
|
+
/**
|
|
1904
|
+
* Update hash variable from URL string.
|
|
1905
|
+
*
|
|
1906
|
+
* Обновление переменной хэша из строки URL.
|
|
1907
|
+
*/
|
|
1908
|
+
static reload() {
|
|
1909
|
+
if (!this.block) {
|
|
1910
|
+
const t = this.getLocation();
|
|
1911
|
+
this.makeWatch(t), this.hash = t;
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1914
|
+
/**
|
|
1915
|
+
* Obtaining data from the URL string.
|
|
1916
|
+
*
|
|
1917
|
+
* Получение данных из строки URL.
|
|
1918
|
+
*/
|
|
1919
|
+
static getLocation() {
|
|
1920
|
+
const t = {};
|
|
1921
|
+
return location.hash.replace(
|
|
1922
|
+
/([\w-]+)[:=]([^;]+)/ig,
|
|
1923
|
+
(...e) => (t[String(e[1])] = nt(e[2]), "")
|
|
1924
|
+
), t;
|
|
1925
|
+
}
|
|
1926
|
+
/**
|
|
1927
|
+
* Update hash string in URL.
|
|
1928
|
+
*
|
|
1929
|
+
* Обновление строки хэша в URL.
|
|
1930
|
+
*/
|
|
1931
|
+
static update() {
|
|
1932
|
+
this.block = !0, history.replaceState(null, "", `#${it(this.hash, "=", ";")}`), requestAnimationFrame(() => {
|
|
1933
|
+
this.block = !1;
|
|
1934
|
+
});
|
|
1935
|
+
}
|
|
1936
|
+
/**
|
|
1937
|
+
* Calling all functions whose data has changed.
|
|
1938
|
+
*
|
|
1939
|
+
* Вызов всех функций, у которых были изменены данные.
|
|
1940
|
+
* @param location fresh data/ свежий данные
|
|
1941
|
+
*/
|
|
1942
|
+
static makeWatch(t) {
|
|
1943
|
+
b(this.watch, (e, s) => {
|
|
1944
|
+
var a;
|
|
1945
|
+
((a = this.hash) == null ? void 0 : a[s]) !== (t == null ? void 0 : t[s]) && e.forEach((r) => r(t[s]));
|
|
1946
|
+
});
|
|
1947
|
+
}
|
|
1948
|
+
};
|
|
1949
|
+
n(w, "hash", {}), n(w, "watch", {}), n(w, "block", !1), u() && (w.reload(), addEventListener("hashchange", () => w.reload()));
|
|
1950
|
+
let H = w;
|
|
1951
|
+
const I = "__UI_ICON", G = 320, _ = "--LOAD--", k = class k {
|
|
1952
|
+
/**
|
|
1953
|
+
* Checks if the given icon is in the list of connected icons.
|
|
1954
|
+
*
|
|
1955
|
+
* Проверяет, есть ли данная иконка в списке подключенных иконок.
|
|
1956
|
+
* @param index icon name/ название иконки
|
|
1957
|
+
*/
|
|
1958
|
+
static is(t) {
|
|
1959
|
+
return t in this.icons || this.getName(t) in this.icons;
|
|
1960
|
+
}
|
|
1961
|
+
/**
|
|
1962
|
+
* Returns the icon by the name.
|
|
1963
|
+
*
|
|
1964
|
+
* Возвращает иконку по названию.
|
|
1965
|
+
* @param index icon name/ название иконки
|
|
1966
|
+
* @param url path to the storage location of the icon, if the icon does not exist/
|
|
1967
|
+
* путь к месту хранения иконки, если иконка не существует
|
|
1968
|
+
* @param wait waiting time for picture loading/
|
|
1969
|
+
* время ожидания загрузки картинки
|
|
1970
|
+
*/
|
|
1971
|
+
static async get(t, e = "", s = 1e3 * 60 * 3) {
|
|
1972
|
+
var r, h, g, f;
|
|
1973
|
+
const a = (f = (g = (r = this.icons) == null ? void 0 : r[this.getName(t)]) != null ? g : (h = this.icons) == null ? void 0 : h[t]) != null ? f : `${t.replace(/^@/, e != null ? e : this.url)}.svg`;
|
|
1974
|
+
return typeof a == "string" ? a === _ && s > 0 ? (await this.wait(), this.get(t, e, s - G)) : a : await a;
|
|
1975
|
+
}
|
|
1976
|
+
/**
|
|
1977
|
+
* Returns a list of names of all registered icons.
|
|
1978
|
+
*
|
|
1979
|
+
* Возвращает список названий всех зарегистрированных иконок.
|
|
1980
|
+
*/
|
|
1981
|
+
static getNameList() {
|
|
1982
|
+
return b(this.icons, (t, e) => e.replace(/^@/, ""));
|
|
1983
|
+
}
|
|
1984
|
+
/**
|
|
1985
|
+
* Returns a global link.
|
|
1986
|
+
*
|
|
1987
|
+
* Возвращает глобальную ссылку.
|
|
1988
|
+
*/
|
|
1989
|
+
static getUrlGlobal() {
|
|
1990
|
+
return `${F.isLocalhost(), ""}${this.url}`;
|
|
1991
|
+
}
|
|
1992
|
+
/**
|
|
1993
|
+
* Adding custom icons.
|
|
1994
|
+
*
|
|
1995
|
+
* Добавление пользовательских иконок.
|
|
1996
|
+
* @param index icon name/ название иконки
|
|
1997
|
+
* @param file path to the file/ путь к файлу
|
|
1998
|
+
*/
|
|
1999
|
+
static add(t, e) {
|
|
2000
|
+
this.icons[this.getName(t)] = e;
|
|
2001
|
+
}
|
|
2002
|
+
/**
|
|
2003
|
+
* Adding custom icons in loading mode.
|
|
2004
|
+
*
|
|
2005
|
+
* Добавление пользовательских иконок в режиме загрузки.
|
|
2006
|
+
* @param index icon name/ название иконки
|
|
2007
|
+
*/
|
|
2008
|
+
static addLoad(t) {
|
|
2009
|
+
this.icons[this.getName(t)] = _;
|
|
2010
|
+
}
|
|
2011
|
+
/**
|
|
2012
|
+
* Adding custom global icons.
|
|
2013
|
+
*
|
|
2014
|
+
* Добавление пользовательских глобальных иконок.
|
|
2015
|
+
* @param index icon name/ название иконки
|
|
2016
|
+
* @param file path to the file/ путь к файлу
|
|
2017
|
+
*/
|
|
2018
|
+
static addGlobal(t, e) {
|
|
2019
|
+
this.icons[this.getName(t)] = `${this.getUrlGlobal()}${e}`;
|
|
2020
|
+
}
|
|
2021
|
+
/**
|
|
2022
|
+
* Adding an icon by the list.
|
|
2023
|
+
*
|
|
2024
|
+
* Добавление иконки по списку.
|
|
2025
|
+
* @param list list of icons/ список иконки
|
|
2026
|
+
*/
|
|
2027
|
+
static addByList(t) {
|
|
2028
|
+
b(t, (e, s) => this.add(s, e));
|
|
2029
|
+
}
|
|
2030
|
+
/**
|
|
2031
|
+
* Changes the file path.
|
|
2032
|
+
*
|
|
2033
|
+
* Изменяет путь к файлу.
|
|
2034
|
+
* @param url new file path/ новый путь к файлу
|
|
2035
|
+
*/
|
|
2036
|
+
static setUrl(t) {
|
|
2037
|
+
this.url = t;
|
|
2038
|
+
}
|
|
2039
|
+
/**
|
|
2040
|
+
* Returns the icon name.
|
|
2041
|
+
*
|
|
2042
|
+
* Возвращает название иконки.
|
|
2043
|
+
* @param index icon name/ название иконки
|
|
2044
|
+
*/
|
|
2045
|
+
static getName(t) {
|
|
2046
|
+
return `@${t}`;
|
|
2047
|
+
}
|
|
2048
|
+
/**
|
|
2049
|
+
* Script execution delay.
|
|
2050
|
+
*
|
|
2051
|
+
* Задержка выполнения скрипта.
|
|
2052
|
+
*/
|
|
2053
|
+
static wait() {
|
|
2054
|
+
return new Promise((t) => setTimeout(() => t(), G));
|
|
2055
|
+
}
|
|
2056
|
+
};
|
|
2057
|
+
n(k, "icons", {}), n(k, "url", "/icons/"), u() && (I in window || (window[I] = {}), k.icons = window[I]);
|
|
2058
|
+
let tt = k;
|
|
2059
|
+
function kt(i, t, e) {
|
|
2060
|
+
var s, a;
|
|
2061
|
+
return (a = (s = p(i)) == null ? void 0 : s[t]) != null ? a : e;
|
|
2062
|
+
}
|
|
2063
|
+
function Ot(i, t, e) {
|
|
2064
|
+
const s = p(i);
|
|
2065
|
+
if (s) {
|
|
2066
|
+
const a = kt(s, t);
|
|
2067
|
+
if (O(a) && O(e))
|
|
2068
|
+
b(e, (r, h) => {
|
|
2069
|
+
a[h] = y(r);
|
|
2070
|
+
});
|
|
2071
|
+
else {
|
|
2072
|
+
const r = y(e);
|
|
2073
|
+
!(t in s) && typeof r == "string" ? s.setAttribute(t.toString(), r) : s[t] = y(e);
|
|
2074
|
+
}
|
|
2075
|
+
}
|
|
2076
|
+
return s;
|
|
2077
|
+
}
|
|
2078
|
+
function et(i, t = "div", e, s) {
|
|
2079
|
+
if (!u())
|
|
2080
|
+
return;
|
|
2081
|
+
const a = document.createElement(t);
|
|
2082
|
+
return typeof e == "function" ? e(a) : m(e) && b(e, (r, h) => {
|
|
2083
|
+
Ot(a, h, r);
|
|
2084
|
+
}), i == null || i.insertBefore(a, s != null ? s : null), a;
|
|
2085
|
+
}
|
|
2086
|
+
class st {
|
|
2087
|
+
/**
|
|
2088
|
+
* Checks whether to enable scroll hiding.
|
|
2089
|
+
*
|
|
2090
|
+
* Проверяет, надо ли включить скрытие скролла.
|
|
2091
|
+
*/
|
|
2092
|
+
static async is() {
|
|
2093
|
+
const t = await this.get();
|
|
2094
|
+
return t !== -1 && t <= 8;
|
|
2095
|
+
}
|
|
2096
|
+
/**
|
|
2097
|
+
* Returns the width of the scroll.
|
|
2098
|
+
*
|
|
2099
|
+
* Возвращает ширину скролла.
|
|
2100
|
+
*/
|
|
2101
|
+
static async get() {
|
|
2102
|
+
var e;
|
|
2103
|
+
const t = (e = this.storage.get()) != null ? e : -1;
|
|
2104
|
+
if (!this.calculate && t === -1) {
|
|
2105
|
+
const s = await this.init();
|
|
2106
|
+
return this.storage.set(s), s;
|
|
2107
|
+
}
|
|
2108
|
+
return t;
|
|
2109
|
+
}
|
|
2110
|
+
/**
|
|
2111
|
+
* Creates elements to check the width of the scroll.
|
|
2112
|
+
*
|
|
2113
|
+
* Создает элементы для проверки ширины скролла.
|
|
2114
|
+
*/
|
|
2115
|
+
static createElement() {
|
|
2116
|
+
return et(document.body, "div", (t) => {
|
|
2117
|
+
t.style.height = "24px", t.style.overflowY = "scroll", t.style.position = "fixed", t.style.width = "100%", et(t, "div", (e) => {
|
|
2118
|
+
e.style.height = "100px";
|
|
2119
|
+
});
|
|
2120
|
+
});
|
|
2121
|
+
}
|
|
2122
|
+
/**
|
|
2123
|
+
* Initialization of data to check the width of the scroll.
|
|
2124
|
+
*
|
|
2125
|
+
* Инициализация данных для проверки ширины скролла.
|
|
2126
|
+
*/
|
|
2127
|
+
static init() {
|
|
2128
|
+
return new Promise((t) => {
|
|
2129
|
+
this.calculate = !0;
|
|
2130
|
+
const e = this.createElement();
|
|
2131
|
+
e ? requestAnimationFrame(() => {
|
|
2132
|
+
t(e.offsetWidth - e.clientWidth), e.remove(), this.calculate = !1;
|
|
2133
|
+
}) : t(0);
|
|
2134
|
+
});
|
|
2135
|
+
}
|
|
2136
|
+
}
|
|
2137
|
+
n(st, "storage", new z("scrollbar", !0)), n(st, "calculate", !1);
|
|
2138
|
+
export {
|
|
2139
|
+
F as A,
|
|
2140
|
+
kt as B,
|
|
2141
|
+
Y as C,
|
|
2142
|
+
z as D,
|
|
2143
|
+
Z as E,
|
|
2144
|
+
V as F,
|
|
2145
|
+
S as G,
|
|
2146
|
+
H,
|
|
2147
|
+
tt as I,
|
|
2148
|
+
it as J,
|
|
2149
|
+
at as K,
|
|
2150
|
+
E as L,
|
|
2151
|
+
pt as M,
|
|
2152
|
+
W as N,
|
|
2153
|
+
rt as O,
|
|
2154
|
+
Ot as P,
|
|
2155
|
+
nt as Q,
|
|
2156
|
+
l as R,
|
|
2157
|
+
st as S,
|
|
2158
|
+
M as a,
|
|
2159
|
+
T as b,
|
|
2160
|
+
et as c,
|
|
2161
|
+
L as d,
|
|
2162
|
+
A as e,
|
|
2163
|
+
b as f,
|
|
2164
|
+
m as g,
|
|
2165
|
+
O as h,
|
|
2166
|
+
u as i,
|
|
2167
|
+
p as j,
|
|
2168
|
+
ft as k,
|
|
2169
|
+
gt as l,
|
|
2170
|
+
y as m,
|
|
2171
|
+
mt as n,
|
|
2172
|
+
yt as o,
|
|
2173
|
+
Lt as p,
|
|
2174
|
+
bt as q,
|
|
2175
|
+
Et as r,
|
|
2176
|
+
vt as s,
|
|
2177
|
+
P as t,
|
|
2178
|
+
St as u,
|
|
2179
|
+
Ct as v,
|
|
2180
|
+
Q as w,
|
|
2181
|
+
ht as x,
|
|
2182
|
+
X as y,
|
|
2183
|
+
wt as z
|
|
2184
|
+
};
|