@fctc/interface-logic 1.5.1 → 1.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4785 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __pow = Math.pow;
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 __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21
+ var __async = (__this, __arguments, generator) => {
22
+ return new Promise((resolve, reject) => {
23
+ var fulfilled = (value) => {
24
+ try {
25
+ step(generator.next(value));
26
+ } catch (e) {
27
+ reject(e);
28
+ }
29
+ };
30
+ var rejected = (value) => {
31
+ try {
32
+ step(generator.throw(value));
33
+ } catch (e) {
34
+ reject(e);
35
+ }
36
+ };
37
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
38
+ step((generator = generator.apply(__this, __arguments)).next());
39
+ });
40
+ };
41
+
42
+ // src/constants/api/uri-constant.ts
43
+ var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
44
+ UriConstants2["AUTH_TOKEN_PATH"] = "/authentication/oauth2/token";
45
+ UriConstants2["GENTOKEN_SOCIAL"] = "/token/generate";
46
+ UriConstants2["CALL_PATH"] = "/call";
47
+ UriConstants2["COMPANY_PATH"] = "/company";
48
+ UriConstants2["PROFILE_PATH"] = "/userinfo";
49
+ UriConstants2["RESET_PASSWORD_PATH"] = "/reset_password";
50
+ UriConstants2["CHANGE_PASSWORD_PATH"] = "/change_password";
51
+ UriConstants2["UPDATE_PASSWORD_PATH"] = "/change_password_parent";
52
+ UriConstants2["LOAD_ACTION"] = `/load_action`;
53
+ UriConstants2["REPORT_PATH"] = `/report`;
54
+ UriConstants2["RUN_ACTION_PATH"] = `/run_action`;
55
+ UriConstants2["UPLOAD_FILE_PATH"] = `/upload/file`;
56
+ UriConstants2["GET_MESSAGE"] = `/chatter/thread/messages`;
57
+ UriConstants2["SENT_MESSAGE"] = `/chatter/message/post`;
58
+ UriConstants2["UPLOAD_IMAGE"] = `/mail/attachment/upload`;
59
+ UriConstants2["DELETE_MESSAGE"] = `/chatter/message/update_content`;
60
+ UriConstants2["IMAGE_PATH"] = `/web/image`;
61
+ UriConstants2["LOAD_MESSAGE"] = `/load_message_failures`;
62
+ UriConstants2["TOKEN"] = `/check_token`;
63
+ UriConstants2["CREATE_UPDATE_PATH"] = `/create_update`;
64
+ UriConstants2["TWOFA_METHOD_PATH"] = `/id/api/v2/call`;
65
+ UriConstants2["SIGNIN_SSO"] = `/signin-sso/oauth`;
66
+ UriConstants2["GRANT_ACCESS"] = "/grant-access";
67
+ UriConstants2["TOKEN_BY_CODE"] = "/token";
68
+ UriConstants2["LOGOUT"] = "/logout";
69
+ return UriConstants2;
70
+ })(UriConstants || {});
71
+
72
+ // src/configs/axios-client.ts
73
+ import axios from "axios";
74
+
75
+ // src/utils/format.ts
76
+ import moment from "moment";
77
+
78
+ // src/utils/domain/py_tokenizer.ts
79
+ var TokenizerError = class extends Error {
80
+ };
81
+ var directMap = {
82
+ "\\": "\\",
83
+ '"': '"',
84
+ "'": "'",
85
+ a: "\x07",
86
+ b: "\b",
87
+ f: "\f",
88
+ n: "\n",
89
+ r: "\r",
90
+ t: " ",
91
+ v: "\v"
92
+ };
93
+ function decodeStringLiteral(str, unicode) {
94
+ const out = [];
95
+ let code;
96
+ for (let i = 0; i < str.length; ++i) {
97
+ if (str[i] !== "\\") {
98
+ out.push(str[i]);
99
+ continue;
100
+ }
101
+ const escape = str[i + 1];
102
+ if (escape in directMap) {
103
+ out.push(directMap[escape]);
104
+ ++i;
105
+ continue;
106
+ }
107
+ switch (escape) {
108
+ case "\n":
109
+ ++i;
110
+ continue;
111
+ case "N":
112
+ if (!unicode) {
113
+ break;
114
+ }
115
+ throw new TokenizerError("SyntaxError: \\N{} escape not implemented");
116
+ case "u":
117
+ if (!unicode) {
118
+ break;
119
+ }
120
+ const uni = str.slice(i + 2, i + 6);
121
+ if (!/[0-9a-f]{4}/i.test(uni)) {
122
+ throw new TokenizerError(
123
+ [
124
+ "SyntaxError: (unicode error) 'unicodeescape' codec",
125
+ " can't decode bytes in position ",
126
+ i,
127
+ "-",
128
+ i + 4,
129
+ ": truncated \\uXXXX escape"
130
+ ].join("")
131
+ );
132
+ }
133
+ code = parseInt(uni, 16);
134
+ out.push(String.fromCharCode(code));
135
+ i += 5;
136
+ continue;
137
+ case "U":
138
+ if (!unicode) {
139
+ break;
140
+ }
141
+ throw new TokenizerError("SyntaxError: \\U escape not implemented");
142
+ case "x":
143
+ const hex = str.slice(i + 2, i + 4);
144
+ if (!/[0-9a-f]{2}/i.test(hex)) {
145
+ if (!unicode) {
146
+ throw new TokenizerError("ValueError: invalid \\x escape");
147
+ }
148
+ throw new TokenizerError(
149
+ [
150
+ "SyntaxError: (unicode error) 'unicodeescape'",
151
+ " codec can't decode bytes in position ",
152
+ i,
153
+ "-",
154
+ i + 2,
155
+ ": truncated \\xXX escape"
156
+ ].join("")
157
+ );
158
+ }
159
+ code = parseInt(hex, 16);
160
+ out.push(String.fromCharCode(code));
161
+ i += 3;
162
+ continue;
163
+ default:
164
+ if (!/[0-8]/.test(escape)) {
165
+ break;
166
+ }
167
+ const r = /[0-8]{1,3}/g;
168
+ r.lastIndex = i + 1;
169
+ const m = r.exec(str);
170
+ if (!m) break;
171
+ const oct = m[0];
172
+ code = parseInt(oct, 8);
173
+ out.push(String.fromCharCode(code));
174
+ i += oct.length;
175
+ continue;
176
+ }
177
+ out.push("\\");
178
+ }
179
+ return out.join("");
180
+ }
181
+ var constants = /* @__PURE__ */ new Set(["None", "False", "True"]);
182
+ var comparators = [
183
+ "in",
184
+ "not",
185
+ "not in",
186
+ "is",
187
+ "is not",
188
+ "<",
189
+ "<=",
190
+ ">",
191
+ ">=",
192
+ "<>",
193
+ "!=",
194
+ "=="
195
+ ];
196
+ var binaryOperators = [
197
+ "or",
198
+ "and",
199
+ "|",
200
+ "^",
201
+ "&",
202
+ "<<",
203
+ ">>",
204
+ "+",
205
+ "-",
206
+ "*",
207
+ "/",
208
+ "//",
209
+ "%",
210
+ "~",
211
+ "**",
212
+ "."
213
+ ];
214
+ var unaryOperators = ["-"];
215
+ var symbols = /* @__PURE__ */ new Set([
216
+ ...["(", ")", "[", "]", "{", "}", ":", ","],
217
+ ...["if", "else", "lambda", "="],
218
+ ...comparators,
219
+ ...binaryOperators,
220
+ ...unaryOperators
221
+ ]);
222
+ function group(...args) {
223
+ return "(" + args.join("|") + ")";
224
+ }
225
+ var Name = "[a-zA-Z_]\\w*";
226
+ var Whitespace = "[ \\f\\t]*";
227
+ var DecNumber = "\\d+(L|l)?";
228
+ var IntNumber = DecNumber;
229
+ var Exponent = "[eE][+-]?\\d+";
230
+ var PointFloat = group(`\\d+\\.\\d*(${Exponent})?`, `\\.\\d+(${Exponent})?`);
231
+ var FloatNumber = group(PointFloat, `\\d+${Exponent}`);
232
+ var Number2 = group(FloatNumber, IntNumber);
233
+ var Operator = group(
234
+ "\\*\\*=?",
235
+ ">>=?",
236
+ "<<=?",
237
+ "<>",
238
+ "!=",
239
+ "//=?",
240
+ "[+\\-*/%&|^=<>]=?",
241
+ "~"
242
+ );
243
+ var Bracket = "[\\[\\]\\(\\)\\{\\}]";
244
+ var Special = "[:;.,`@]";
245
+ var Funny = group(Operator, Bracket, Special);
246
+ var ContStr = group(
247
+ "([uU])?'([^\\n'\\\\]*(?:\\\\.[^\\n'\\\\]*)*)'",
248
+ '([uU])?"([^\\n"\\\\]*(?:\\\\.[^\\n"\\\\]*)*)"'
249
+ );
250
+ var PseudoToken = Whitespace + group(Number2, Funny, ContStr, Name);
251
+ var NumberPattern = new RegExp("^" + Number2 + "$");
252
+ var StringPattern = new RegExp("^" + ContStr + "$");
253
+ var NamePattern = new RegExp("^" + Name + "$");
254
+ var strip = new RegExp("^" + Whitespace);
255
+ function tokenize(str) {
256
+ const tokens = [];
257
+ const max = str.length;
258
+ let start = 0;
259
+ let end = 0;
260
+ const pseudoprog = new RegExp(PseudoToken, "g");
261
+ while (pseudoprog.lastIndex < max) {
262
+ const pseudomatch = pseudoprog.exec(str);
263
+ if (!pseudomatch) {
264
+ if (/^\s+$/.test(str.slice(end))) {
265
+ break;
266
+ }
267
+ throw new TokenizerError(
268
+ "Failed to tokenize <<" + str + ">> at index " + (end || 0) + "; parsed so far: " + tokens
269
+ );
270
+ }
271
+ if (pseudomatch.index > end) {
272
+ if (str.slice(end, pseudomatch.index).trim()) {
273
+ throw new TokenizerError("Invalid expression");
274
+ }
275
+ }
276
+ start = pseudomatch.index;
277
+ end = pseudoprog.lastIndex;
278
+ let token = str.slice(start, end).replace(strip, "");
279
+ if (NumberPattern.test(token)) {
280
+ tokens.push({
281
+ type: 0,
282
+ value: parseFloat(token)
283
+ });
284
+ } else if (StringPattern.test(token)) {
285
+ const m = StringPattern.exec(token);
286
+ if (!m) throw new TokenizerError("Invalid string match");
287
+ tokens.push({
288
+ type: 1,
289
+ value: decodeStringLiteral(
290
+ m[3] !== void 0 ? m[3] : m[5],
291
+ !!(m[2] || m[4])
292
+ )
293
+ });
294
+ } else if (symbols.has(token)) {
295
+ if (token === "in" && tokens.length > 0 && tokens[tokens.length - 1].value === "not") {
296
+ token = "not in";
297
+ tokens.pop();
298
+ } else if (token === "not" && tokens.length > 0 && tokens[tokens.length - 1].value === "is") {
299
+ token = "is not";
300
+ tokens.pop();
301
+ }
302
+ tokens.push({
303
+ type: 2,
304
+ value: token
305
+ });
306
+ } else if (constants.has(token)) {
307
+ tokens.push({
308
+ type: 4,
309
+ value: token
310
+ });
311
+ } else if (NamePattern.test(token)) {
312
+ tokens.push({
313
+ type: 3,
314
+ value: token
315
+ });
316
+ } else {
317
+ throw new TokenizerError("Invalid expression");
318
+ }
319
+ }
320
+ return tokens;
321
+ }
322
+
323
+ // src/utils/domain/py_parser.ts
324
+ var ParserError = class extends Error {
325
+ };
326
+ var chainedOperators = new Set(comparators);
327
+ var infixOperators = /* @__PURE__ */ new Set([...binaryOperators, ...comparators]);
328
+ function bp(symbol) {
329
+ switch (symbol) {
330
+ case "=":
331
+ return 10;
332
+ case "if":
333
+ return 20;
334
+ case "in":
335
+ case "not in":
336
+ case "is":
337
+ case "is not":
338
+ case "<":
339
+ case "<=":
340
+ case ">":
341
+ case ">=":
342
+ case "<>":
343
+ case "==":
344
+ case "!=":
345
+ return 60;
346
+ case "or":
347
+ return 30;
348
+ case "and":
349
+ return 40;
350
+ case "not":
351
+ return 50;
352
+ case "|":
353
+ return 70;
354
+ case "^":
355
+ return 80;
356
+ case "&":
357
+ return 90;
358
+ case "<<":
359
+ case ">>":
360
+ return 100;
361
+ case "+":
362
+ case "-":
363
+ return 110;
364
+ case "*":
365
+ case "/":
366
+ case "//":
367
+ case "%":
368
+ return 120;
369
+ case "**":
370
+ return 140;
371
+ case ".":
372
+ case "(":
373
+ case "[":
374
+ return 150;
375
+ default:
376
+ return 0;
377
+ }
378
+ }
379
+ function bindingPower(token) {
380
+ return token.type === 2 ? bp(token.value) : 0;
381
+ }
382
+ function isSymbol(token, value) {
383
+ return token.type === 2 && token.value === value;
384
+ }
385
+ function parsePrefix(current, tokens) {
386
+ switch (current.type) {
387
+ case 0:
388
+ return { type: 0, value: current.value };
389
+ case 1:
390
+ return { type: 1, value: current.value };
391
+ case 4:
392
+ if (current.value === "None") {
393
+ return {
394
+ type: 3
395
+ /* None */
396
+ };
397
+ } else {
398
+ return { type: 2, value: current.value === "True" };
399
+ }
400
+ case 3:
401
+ return { type: 5, value: current.value };
402
+ case 2:
403
+ switch (current.value) {
404
+ case "-":
405
+ case "+":
406
+ case "~":
407
+ return {
408
+ type: 6,
409
+ op: current.value,
410
+ right: _parse(tokens, 130)
411
+ };
412
+ case "not":
413
+ return {
414
+ type: 6,
415
+ op: current.value,
416
+ right: _parse(tokens, 50)
417
+ };
418
+ case "(":
419
+ const content = [];
420
+ let isTuple = false;
421
+ while (tokens[0] && !isSymbol(tokens[0], ")")) {
422
+ content.push(_parse(tokens, 0));
423
+ if (tokens[0]) {
424
+ if (tokens[0] && isSymbol(tokens[0], ",")) {
425
+ isTuple = true;
426
+ tokens.shift();
427
+ } else if (!isSymbol(tokens[0], ")")) {
428
+ throw new ParserError("parsing error");
429
+ }
430
+ } else {
431
+ throw new ParserError("parsing error");
432
+ }
433
+ }
434
+ if (!tokens[0] || !isSymbol(tokens[0], ")")) {
435
+ throw new ParserError("parsing error");
436
+ }
437
+ tokens.shift();
438
+ isTuple = isTuple || content.length === 0;
439
+ return isTuple ? { type: 10, value: content } : content[0];
440
+ case "[":
441
+ const value = [];
442
+ while (tokens[0] && !isSymbol(tokens[0], "]")) {
443
+ value.push(_parse(tokens, 0));
444
+ if (tokens[0]) {
445
+ if (isSymbol(tokens[0], ",")) {
446
+ tokens.shift();
447
+ } else if (!isSymbol(tokens[0], "]")) {
448
+ throw new ParserError("parsing error");
449
+ }
450
+ }
451
+ }
452
+ if (!tokens[0] || !isSymbol(tokens[0], "]")) {
453
+ throw new ParserError("parsing error");
454
+ }
455
+ tokens.shift();
456
+ return { type: 4, value };
457
+ case "{":
458
+ const dict = {};
459
+ while (tokens[0] && !isSymbol(tokens[0], "}")) {
460
+ const key = _parse(tokens, 0);
461
+ if (key.type !== 1 && key.type !== 0 || !tokens[0] || !isSymbol(tokens[0], ":")) {
462
+ throw new ParserError("parsing error");
463
+ }
464
+ tokens.shift();
465
+ const val = _parse(tokens, 0);
466
+ dict[key.value] = val;
467
+ if (isSymbol(tokens[0], ",")) {
468
+ tokens.shift();
469
+ }
470
+ }
471
+ if (!tokens.shift()) {
472
+ throw new ParserError("parsing error");
473
+ }
474
+ return { type: 11, value: dict };
475
+ default:
476
+ throw new ParserError("Token cannot be parsed");
477
+ }
478
+ default:
479
+ throw new ParserError("Token cannot be parsed");
480
+ }
481
+ }
482
+ function parseInfix(left, current, tokens) {
483
+ switch (current.type) {
484
+ case 2:
485
+ if (infixOperators.has(current.value)) {
486
+ let right = _parse(tokens, bindingPower(current));
487
+ if (current.value === "and" || current.value === "or") {
488
+ return {
489
+ type: 14,
490
+ op: current.value,
491
+ left,
492
+ right
493
+ };
494
+ } else if (current.value === ".") {
495
+ if (right.type === 5) {
496
+ return {
497
+ type: 15,
498
+ obj: left,
499
+ key: right.value
500
+ };
501
+ } else {
502
+ throw new ParserError("invalid obj lookup");
503
+ }
504
+ }
505
+ let op = {
506
+ type: 7,
507
+ op: current.value,
508
+ left,
509
+ right
510
+ };
511
+ while (chainedOperators.has(current.value) && tokens[0] && tokens[0].type === 2 && chainedOperators.has(tokens[0].value)) {
512
+ const nextToken = tokens.shift();
513
+ op = {
514
+ type: 14,
515
+ op: "and",
516
+ left: op,
517
+ right: {
518
+ type: 7,
519
+ op: nextToken.value,
520
+ left: right,
521
+ right: _parse(tokens, bindingPower(nextToken))
522
+ }
523
+ };
524
+ right = op.right;
525
+ }
526
+ return op;
527
+ }
528
+ switch (current.value) {
529
+ case "(":
530
+ const args = [];
531
+ const kwargs = {};
532
+ while (tokens[0] && !isSymbol(tokens[0], ")")) {
533
+ const arg = _parse(tokens, 0);
534
+ if (arg.type === 9) {
535
+ kwargs[arg.name.value] = arg.value;
536
+ } else {
537
+ args.push(arg);
538
+ }
539
+ if (tokens[0] && isSymbol(tokens[0], ",")) {
540
+ tokens.shift();
541
+ }
542
+ }
543
+ if (!tokens[0] || !isSymbol(tokens[0], ")")) {
544
+ throw new ParserError("parsing error");
545
+ }
546
+ tokens.shift();
547
+ return { type: 8, fn: left, args, kwargs };
548
+ case "=":
549
+ if (left.type === 5) {
550
+ return {
551
+ type: 9,
552
+ name: left,
553
+ value: _parse(tokens, 10)
554
+ };
555
+ }
556
+ break;
557
+ case "[":
558
+ const key = _parse(tokens);
559
+ if (!tokens[0] || !isSymbol(tokens[0], "]")) {
560
+ throw new ParserError("parsing error");
561
+ }
562
+ tokens.shift();
563
+ return {
564
+ type: 12,
565
+ target: left,
566
+ key
567
+ };
568
+ case "if":
569
+ const condition = _parse(tokens);
570
+ if (!tokens[0] || !isSymbol(tokens[0], "else")) {
571
+ throw new ParserError("parsing error");
572
+ }
573
+ tokens.shift();
574
+ const ifFalse = _parse(tokens);
575
+ return {
576
+ type: 13,
577
+ condition,
578
+ ifTrue: left,
579
+ ifFalse
580
+ };
581
+ default:
582
+ break;
583
+ }
584
+ }
585
+ throw new ParserError("Token cannot be parsed");
586
+ }
587
+ function _parse(tokens, bp2 = 0) {
588
+ const token = tokens.shift();
589
+ if (!token) {
590
+ throw new ParserError("Unexpected end of input");
591
+ }
592
+ let expr = parsePrefix(token, tokens);
593
+ while (tokens[0] && bindingPower(tokens[0]) > bp2) {
594
+ expr = parseInfix(expr, tokens.shift(), tokens);
595
+ }
596
+ return expr;
597
+ }
598
+ function parse(tokens) {
599
+ if (tokens.length) {
600
+ return _parse(tokens, 0);
601
+ }
602
+ throw new ParserError("Missing token");
603
+ }
604
+ function parseArgs(args, spec) {
605
+ const last = args[args.length - 1];
606
+ const unnamedArgs = typeof last === "object" ? args.slice(0, -1) : args;
607
+ const kwargs = typeof last === "object" ? last : {};
608
+ for (const [index, val] of unnamedArgs.entries()) {
609
+ kwargs[spec[index]] = val;
610
+ }
611
+ return kwargs;
612
+ }
613
+
614
+ // src/utils/domain/py_date.ts
615
+ var AssertionError = class extends Error {
616
+ };
617
+ var ValueError = class extends Error {
618
+ };
619
+ var NotSupportedError = class extends Error {
620
+ };
621
+ function fmt2(n) {
622
+ return String(n).padStart(2, "0");
623
+ }
624
+ function fmt4(n) {
625
+ return String(n).padStart(4, "0");
626
+ }
627
+ function divmod(a, b, fn) {
628
+ let mod = a % b;
629
+ if (mod > 0 && b < 0 || mod < 0 && b > 0) {
630
+ mod += b;
631
+ }
632
+ return fn(Math.floor(a / b), mod);
633
+ }
634
+ function assert(bool, message = "AssertionError") {
635
+ if (!bool) {
636
+ throw new AssertionError(message);
637
+ }
638
+ }
639
+ var DAYS_IN_MONTH = [
640
+ null,
641
+ 31,
642
+ 28,
643
+ 31,
644
+ 30,
645
+ 31,
646
+ 30,
647
+ 31,
648
+ 31,
649
+ 30,
650
+ 31,
651
+ 30,
652
+ 31
653
+ ];
654
+ var DAYS_BEFORE_MONTH = [null];
655
+ for (let dbm = 0, i = 1; i < DAYS_IN_MONTH.length; ++i) {
656
+ DAYS_BEFORE_MONTH.push(dbm);
657
+ dbm += DAYS_IN_MONTH[i];
658
+ }
659
+ function daysInMonth(year, month) {
660
+ if (month === 2 && isLeap(year)) {
661
+ return 29;
662
+ }
663
+ return DAYS_IN_MONTH[month];
664
+ }
665
+ function isLeap(year) {
666
+ return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
667
+ }
668
+ function daysBeforeYear(year) {
669
+ const y = year - 1;
670
+ return y * 365 + Math.floor(y / 4) - Math.floor(y / 100) + Math.floor(y / 400);
671
+ }
672
+ function daysBeforeMonth(year, month) {
673
+ const postLeapFeb = month > 2 && isLeap(year);
674
+ return DAYS_BEFORE_MONTH[month] + (postLeapFeb ? 1 : 0);
675
+ }
676
+ function ymd2ord(year, month, day) {
677
+ const dim = daysInMonth(year, month);
678
+ if (!(1 <= day && day <= dim)) {
679
+ throw new ValueError(`day must be in 1..${dim}`);
680
+ }
681
+ return daysBeforeYear(year) + daysBeforeMonth(year, month) + day;
682
+ }
683
+ var DI400Y = daysBeforeYear(401);
684
+ var DI100Y = daysBeforeYear(101);
685
+ var DI4Y = daysBeforeYear(5);
686
+ function ord2ymd(n) {
687
+ --n;
688
+ let n400 = 0, n100 = 0, n4 = 0, n1 = 0, n0 = 0;
689
+ divmod(n, DI400Y, (_n400, n2) => {
690
+ n400 = _n400;
691
+ divmod(n2, DI100Y, (_n100, n3) => {
692
+ n100 = _n100;
693
+ divmod(n3, DI4Y, (_n4, n5) => {
694
+ n4 = _n4;
695
+ divmod(n5, 365, (_n1, n6) => {
696
+ n1 = _n1;
697
+ n0 = n6;
698
+ });
699
+ });
700
+ });
701
+ });
702
+ n = n0;
703
+ const year = n400 * 400 + 1 + n100 * 100 + n4 * 4 + n1;
704
+ if (n1 === 4 || n100 === 100) {
705
+ assert(n0 === 0);
706
+ return {
707
+ year: year - 1,
708
+ month: 12,
709
+ day: 31
710
+ };
711
+ }
712
+ const leapyear = n1 === 3 && (n4 !== 24 || n100 === 3);
713
+ assert(leapyear === isLeap(year));
714
+ let month = n + 50 >> 5;
715
+ let preceding = DAYS_BEFORE_MONTH[month] + (month > 2 && leapyear ? 1 : 0);
716
+ if (preceding > n) {
717
+ --month;
718
+ preceding -= DAYS_IN_MONTH[month] + (month === 2 && leapyear ? 1 : 0);
719
+ }
720
+ n -= preceding;
721
+ return {
722
+ year,
723
+ month,
724
+ day: n + 1
725
+ };
726
+ }
727
+ function tmxxx(year, month, day, hour, minute, second, microsecond) {
728
+ hour = hour || 0;
729
+ minute = minute || 0;
730
+ second = second || 0;
731
+ microsecond = microsecond || 0;
732
+ if (microsecond < 0 || microsecond > 999999) {
733
+ divmod(microsecond, 1e6, (carry, ms) => {
734
+ microsecond = ms;
735
+ second += carry;
736
+ });
737
+ }
738
+ if (second < 0 || second > 59) {
739
+ divmod(second, 60, (carry, s) => {
740
+ second = s;
741
+ minute += carry;
742
+ });
743
+ }
744
+ if (minute < 0 || minute > 59) {
745
+ divmod(minute, 60, (carry, m) => {
746
+ minute = m;
747
+ hour += carry;
748
+ });
749
+ }
750
+ if (hour < 0 || hour > 23) {
751
+ divmod(hour, 24, (carry, h) => {
752
+ hour = h;
753
+ day += carry;
754
+ });
755
+ }
756
+ if (month < 1 || month > 12) {
757
+ divmod(month - 1, 12, (carry, m) => {
758
+ month = m + 1;
759
+ year += carry;
760
+ });
761
+ }
762
+ const dim = daysInMonth(year, month);
763
+ if (day < 1 || day > dim) {
764
+ if (day === 0) {
765
+ --month;
766
+ if (month > 0) {
767
+ day = daysInMonth(year, month);
768
+ } else {
769
+ --year;
770
+ month = 12;
771
+ day = 31;
772
+ }
773
+ } else if (day === dim + 1) {
774
+ ++month;
775
+ day = 1;
776
+ if (month > 12) {
777
+ month = 1;
778
+ ++year;
779
+ }
780
+ } else {
781
+ const r = ord2ymd(ymd2ord(year, month, 1) + (day - 1));
782
+ year = r.year;
783
+ month = r.month;
784
+ day = r.day;
785
+ }
786
+ }
787
+ return {
788
+ year,
789
+ month,
790
+ day,
791
+ hour,
792
+ minute,
793
+ second,
794
+ microsecond
795
+ };
796
+ }
797
+ var PyDate = class _PyDate {
798
+ constructor(year, month, day) {
799
+ this.year = year;
800
+ this.month = month;
801
+ this.day = day;
802
+ }
803
+ static today() {
804
+ return this.convertDate(/* @__PURE__ */ new Date());
805
+ }
806
+ static convertDate(date) {
807
+ const year = date.getFullYear();
808
+ const month = date.getMonth() + 1;
809
+ const day = date.getDate();
810
+ return new _PyDate(year, month, day);
811
+ }
812
+ static create(...args) {
813
+ const { year, month, day } = parseArgs(args, ["year", "month", "day"]);
814
+ return new _PyDate(year, month, day);
815
+ }
816
+ add(timedelta) {
817
+ const s = tmxxx(this.year, this.month, this.day + timedelta.days, 0, 0, 0);
818
+ return new _PyDate(s.year, s.month, s.day);
819
+ }
820
+ isEqual(other) {
821
+ if (!(other instanceof _PyDate)) {
822
+ return false;
823
+ }
824
+ return this.year === other.year && this.month === other.month && this.day === other.day;
825
+ }
826
+ strftime(format) {
827
+ return format.replace(/%([A-Za-z])/g, (m, c) => {
828
+ switch (c) {
829
+ case "Y":
830
+ return fmt4(this.year);
831
+ case "m":
832
+ return fmt2(this.month);
833
+ case "d":
834
+ return fmt2(this.day);
835
+ default:
836
+ throw new ValueError(`No known conversion for ${m}`);
837
+ }
838
+ });
839
+ }
840
+ substract(other) {
841
+ if (other instanceof PyTimeDelta) {
842
+ return this.add(other.negate());
843
+ }
844
+ if (other instanceof _PyDate) {
845
+ return PyTimeDelta.create(this.toordinal() - other.toordinal());
846
+ }
847
+ throw new NotSupportedError();
848
+ }
849
+ toJSON() {
850
+ return this.strftime("%Y-%m-%d");
851
+ }
852
+ toordinal() {
853
+ return ymd2ord(this.year, this.month, this.day);
854
+ }
855
+ };
856
+ var PyDateTime = class _PyDateTime {
857
+ constructor(year, month, day, hour, minute, second, microsecond) {
858
+ this.year = year;
859
+ this.month = month;
860
+ this.day = day;
861
+ this.hour = hour;
862
+ this.minute = minute;
863
+ this.second = second;
864
+ this.microsecond = microsecond;
865
+ }
866
+ static now() {
867
+ return this.convertDate(/* @__PURE__ */ new Date());
868
+ }
869
+ static convertDate(date) {
870
+ const year = date.getFullYear();
871
+ const month = date.getMonth() + 1;
872
+ const day = date.getDate();
873
+ const hour = date.getHours();
874
+ const minute = date.getMinutes();
875
+ const second = date.getSeconds();
876
+ return new _PyDateTime(year, month, day, hour, minute, second, 0);
877
+ }
878
+ static create(...args) {
879
+ const namedArgs = parseArgs(args, [
880
+ "year",
881
+ "month",
882
+ "day",
883
+ "hour",
884
+ "minute",
885
+ "second",
886
+ "microsecond"
887
+ ]);
888
+ const year = namedArgs.year;
889
+ const month = namedArgs.month;
890
+ const day = namedArgs.day;
891
+ const hour = namedArgs.hour || 0;
892
+ const minute = namedArgs.minute || 0;
893
+ const second = namedArgs.second || 0;
894
+ const ms = namedArgs.microsecond / 1e3 || 0;
895
+ return new _PyDateTime(year, month, day, hour, minute, second, ms);
896
+ }
897
+ static combine(...args) {
898
+ const { date, time } = parseArgs(args, ["date", "time"]);
899
+ return _PyDateTime.create(
900
+ date.year,
901
+ date.month,
902
+ date.day,
903
+ time.hour,
904
+ time.minute,
905
+ time.second
906
+ );
907
+ }
908
+ add(timedelta) {
909
+ const s = tmxxx(
910
+ this.year,
911
+ this.month,
912
+ this.day + timedelta.days,
913
+ this.hour,
914
+ this.minute,
915
+ this.second + timedelta.seconds,
916
+ this.microsecond + timedelta.microseconds
917
+ );
918
+ return new _PyDateTime(
919
+ s.year,
920
+ s.month,
921
+ s.day,
922
+ s.hour,
923
+ s.minute,
924
+ s.second,
925
+ s.microsecond
926
+ );
927
+ }
928
+ isEqual(other) {
929
+ if (!(other instanceof _PyDateTime)) {
930
+ return false;
931
+ }
932
+ return this.year === other.year && this.month === other.month && this.day === other.day && this.hour === other.hour && this.minute === other.minute && this.second === other.second && this.microsecond === other.microsecond;
933
+ }
934
+ strftime(format) {
935
+ return format.replace(/%([A-Za-z])/g, (m, c) => {
936
+ switch (c) {
937
+ case "Y":
938
+ return fmt4(this.year);
939
+ case "m":
940
+ return fmt2(this.month);
941
+ case "d":
942
+ return fmt2(this.day);
943
+ case "H":
944
+ return fmt2(this.hour);
945
+ case "M":
946
+ return fmt2(this.minute);
947
+ case "S":
948
+ return fmt2(this.second);
949
+ default:
950
+ throw new ValueError(`No known conversion for ${m}`);
951
+ }
952
+ });
953
+ }
954
+ substract(timedelta) {
955
+ return this.add(timedelta.negate());
956
+ }
957
+ toJSON() {
958
+ return this.strftime("%Y-%m-%d %H:%M:%S");
959
+ }
960
+ to_utc() {
961
+ const d = new Date(
962
+ this.year,
963
+ this.month - 1,
964
+ this.day,
965
+ this.hour,
966
+ this.minute,
967
+ this.second
968
+ );
969
+ const timedelta = PyTimeDelta.create({ minutes: d.getTimezoneOffset() });
970
+ return this.add(timedelta);
971
+ }
972
+ };
973
+ var PyTime = class _PyTime extends PyDate {
974
+ constructor(hour, minute, second) {
975
+ const now = /* @__PURE__ */ new Date();
976
+ const year = now.getFullYear();
977
+ const month = now.getMonth() + 1;
978
+ const day = now.getDate();
979
+ super(year, month, day);
980
+ this.hour = hour;
981
+ this.minute = minute;
982
+ this.second = second;
983
+ this.hour = hour;
984
+ this.minute = minute;
985
+ this.second = second;
986
+ }
987
+ static create(...args) {
988
+ const namedArgs = parseArgs(args, ["hour", "minute", "second"]);
989
+ const hour = namedArgs.hour || 0;
990
+ const minute = namedArgs.minute || 0;
991
+ const second = namedArgs.second || 0;
992
+ return new _PyTime(hour, minute, second);
993
+ }
994
+ strftime(format) {
995
+ return format.replace(/%([A-Za-z])/g, (m, c) => {
996
+ switch (c) {
997
+ case "Y":
998
+ return fmt4(this.year);
999
+ case "m":
1000
+ return fmt2(this.month);
1001
+ case "d":
1002
+ return fmt2(this.day);
1003
+ case "H":
1004
+ return fmt2(this.hour);
1005
+ case "M":
1006
+ return fmt2(this.minute);
1007
+ case "S":
1008
+ return fmt2(this.second);
1009
+ default:
1010
+ throw new ValueError(`No known conversion for ${m}`);
1011
+ }
1012
+ });
1013
+ }
1014
+ toJSON() {
1015
+ return this.strftime("%H:%M:%S");
1016
+ }
1017
+ };
1018
+ var DAYS_IN_YEAR = [
1019
+ 31,
1020
+ 59,
1021
+ 90,
1022
+ 120,
1023
+ 151,
1024
+ 181,
1025
+ 212,
1026
+ 243,
1027
+ 273,
1028
+ 304,
1029
+ 334,
1030
+ 366
1031
+ ];
1032
+ var TIME_PERIODS = ["hour", "minute", "second"];
1033
+ var PERIODS = ["year", "month", "day", ...TIME_PERIODS];
1034
+ var RELATIVE_KEYS = "years months weeks days hours minutes seconds microseconds leapdays".split(
1035
+ " "
1036
+ );
1037
+ var ABSOLUTE_KEYS = "year month day hour minute second microsecond weekday nlyearday yearday".split(
1038
+ " "
1039
+ );
1040
+ var argsSpec = ["dt1", "dt2"];
1041
+ var PyRelativeDelta = class _PyRelativeDelta {
1042
+ static create(...args) {
1043
+ const params = parseArgs(args, argsSpec);
1044
+ if ("dt1" in params) {
1045
+ throw new Error("relativedelta(dt1, dt2) is not supported for now");
1046
+ }
1047
+ for (const period of PERIODS) {
1048
+ if (period in params) {
1049
+ const val = params[period];
1050
+ assert(val >= 0, `${period} ${val} is out of range`);
1051
+ }
1052
+ }
1053
+ for (const key of RELATIVE_KEYS) {
1054
+ params[key] = params[key] || 0;
1055
+ }
1056
+ for (const key of ABSOLUTE_KEYS) {
1057
+ params[key] = key in params ? params[key] : null;
1058
+ }
1059
+ params.days += 7 * params.weeks;
1060
+ let yearDay = 0;
1061
+ if (params.nlyearday) {
1062
+ yearDay = params.nlyearday;
1063
+ } else if (params.yearday) {
1064
+ yearDay = params.yearday;
1065
+ if (yearDay > 59) {
1066
+ params.leapDays = -1;
1067
+ }
1068
+ }
1069
+ if (yearDay) {
1070
+ for (let monthIndex = 0; monthIndex < DAYS_IN_YEAR.length; monthIndex++) {
1071
+ if (yearDay <= DAYS_IN_YEAR[monthIndex]) {
1072
+ params.month = monthIndex + 1;
1073
+ if (monthIndex === 0) {
1074
+ params.day = yearDay;
1075
+ } else {
1076
+ params.day = yearDay - DAYS_IN_YEAR[monthIndex - 1];
1077
+ }
1078
+ break;
1079
+ }
1080
+ }
1081
+ }
1082
+ return new _PyRelativeDelta(params);
1083
+ }
1084
+ static add(date, delta) {
1085
+ if (!(date instanceof PyDate || date instanceof PyDateTime)) {
1086
+ throw new NotSupportedError();
1087
+ }
1088
+ const s = tmxxx(
1089
+ (delta.year || date.year) + delta.years,
1090
+ (delta.month || date.month) + delta.months,
1091
+ delta.day || date.day,
1092
+ delta.hour || (date instanceof PyDateTime ? date.hour : 0),
1093
+ delta.minute || (date instanceof PyDateTime ? date.minute : 0),
1094
+ delta.second || (date instanceof PyDateTime ? date.second : 0),
1095
+ delta.microseconds || (date instanceof PyDateTime ? date.microsecond : 0)
1096
+ );
1097
+ const newDateTime = new PyDateTime(
1098
+ s.year,
1099
+ s.month,
1100
+ s.day,
1101
+ s.hour,
1102
+ s.minute,
1103
+ s.second,
1104
+ s.microsecond
1105
+ );
1106
+ let leapDays = 0;
1107
+ if (delta.leapDays && newDateTime.month > 2 && isLeap(newDateTime.year)) {
1108
+ leapDays = delta.leapDays;
1109
+ }
1110
+ const temp = newDateTime.add(
1111
+ PyTimeDelta.create({
1112
+ days: delta.days + leapDays,
1113
+ hours: delta.hours,
1114
+ minutes: delta.minutes,
1115
+ seconds: delta.seconds,
1116
+ microseconds: delta.microseconds
1117
+ })
1118
+ );
1119
+ const hasTime = Boolean(
1120
+ temp.hour || temp.minute || temp.second || temp.microsecond
1121
+ );
1122
+ const returnDate = !hasTime && date instanceof PyDate ? new PyDate(temp.year, temp.month, temp.day) : temp;
1123
+ if (delta.weekday !== null) {
1124
+ const wantedDow = delta.weekday + 1;
1125
+ const _date = new Date(
1126
+ returnDate.year,
1127
+ returnDate.month - 1,
1128
+ returnDate.day
1129
+ );
1130
+ const days = (7 - _date.getDay() + wantedDow) % 7;
1131
+ return returnDate.add(new PyTimeDelta(days, 0, 0));
1132
+ }
1133
+ return returnDate;
1134
+ }
1135
+ static substract(date, delta) {
1136
+ return _PyRelativeDelta.add(date, delta.negate());
1137
+ }
1138
+ constructor(params = {}, sign = 1) {
1139
+ this.years = sign * params.years;
1140
+ this.months = sign * params.months;
1141
+ this.days = sign * params.days;
1142
+ this.hours = sign * params.hours;
1143
+ this.minutes = sign * params.minutes;
1144
+ this.seconds = sign * params.seconds;
1145
+ this.microseconds = sign * params.microseconds;
1146
+ this.leapDays = params.leapDays;
1147
+ this.year = params.year;
1148
+ this.month = params.month;
1149
+ this.day = params.day;
1150
+ this.hour = params.hour;
1151
+ this.minute = params.minute;
1152
+ this.second = params.second;
1153
+ this.microsecond = params.microsecond;
1154
+ this.weekday = params.weekday;
1155
+ }
1156
+ negate() {
1157
+ return new _PyRelativeDelta(this, -1);
1158
+ }
1159
+ isEqual() {
1160
+ throw new NotSupportedError();
1161
+ }
1162
+ };
1163
+ var TIME_DELTA_KEYS = "weeks days hours minutes seconds milliseconds microseconds".split(" ");
1164
+ function modf(x) {
1165
+ const mod = x % 1;
1166
+ return [mod < 0 ? mod + 1 : mod, Math.floor(x)];
1167
+ }
1168
+ var PyTimeDelta = class _PyTimeDelta {
1169
+ constructor(days, seconds, microseconds) {
1170
+ this.days = days;
1171
+ this.seconds = seconds;
1172
+ this.microseconds = microseconds;
1173
+ }
1174
+ static create(...args) {
1175
+ const namedArgs = parseArgs(args, ["days", "seconds", "microseconds"]);
1176
+ for (const key of TIME_DELTA_KEYS) {
1177
+ namedArgs[key] = namedArgs[key] || 0;
1178
+ }
1179
+ let d = 0;
1180
+ let s = 0;
1181
+ let us = 0;
1182
+ const days = namedArgs.days + namedArgs.weeks * 7;
1183
+ let seconds = namedArgs.seconds + 60 * namedArgs.minutes + 3600 * namedArgs.hours;
1184
+ let microseconds = namedArgs.microseconds + 1e3 * namedArgs.milliseconds;
1185
+ const [dFrac, dInt] = modf(days);
1186
+ d = dInt;
1187
+ let daysecondsfrac = 0;
1188
+ if (dFrac) {
1189
+ const [dsFrac, dsInt] = modf(dFrac * 24 * 3600);
1190
+ s = dsInt;
1191
+ daysecondsfrac = dsFrac;
1192
+ }
1193
+ const [sFrac, sInt] = modf(seconds);
1194
+ seconds = sInt;
1195
+ const secondsfrac = sFrac + daysecondsfrac;
1196
+ divmod(seconds, 24 * 3600, (days2, seconds2) => {
1197
+ d += days2;
1198
+ s += seconds2;
1199
+ });
1200
+ microseconds += secondsfrac * 1e6;
1201
+ divmod(microseconds, 1e6, (seconds2, microseconds2) => {
1202
+ divmod(seconds2, 24 * 3600, (days2, seconds3) => {
1203
+ d += days2;
1204
+ s += seconds3;
1205
+ us += Math.round(microseconds2);
1206
+ });
1207
+ });
1208
+ return new _PyTimeDelta(d, s, us);
1209
+ }
1210
+ add(other) {
1211
+ return _PyTimeDelta.create({
1212
+ days: this.days + other.days,
1213
+ seconds: this.seconds + other.seconds,
1214
+ microseconds: this.microseconds + other.microseconds
1215
+ });
1216
+ }
1217
+ divide(n) {
1218
+ const us = (this.days * 24 * 3600 + this.seconds) * 1e6 + this.microseconds;
1219
+ return _PyTimeDelta.create({ microseconds: Math.floor(us / n) });
1220
+ }
1221
+ isEqual(other) {
1222
+ if (!(other instanceof _PyTimeDelta)) {
1223
+ return false;
1224
+ }
1225
+ return this.days === other.days && this.seconds === other.seconds && this.microseconds === other.microseconds;
1226
+ }
1227
+ isTrue() {
1228
+ return this.days !== 0 || this.seconds !== 0 || this.microseconds !== 0;
1229
+ }
1230
+ multiply(n) {
1231
+ return _PyTimeDelta.create({
1232
+ days: n * this.days,
1233
+ seconds: n * this.seconds,
1234
+ microseconds: n * this.microseconds
1235
+ });
1236
+ }
1237
+ negate() {
1238
+ return _PyTimeDelta.create({
1239
+ days: -this.days,
1240
+ seconds: -this.seconds,
1241
+ microseconds: -this.microseconds
1242
+ });
1243
+ }
1244
+ substract(other) {
1245
+ return _PyTimeDelta.create({
1246
+ days: this.days - other.days,
1247
+ seconds: this.seconds - other.seconds,
1248
+ microseconds: this.microseconds - other.microseconds
1249
+ });
1250
+ }
1251
+ total_seconds() {
1252
+ return this.days * 86400 + this.seconds + this.microseconds / 1e6;
1253
+ }
1254
+ };
1255
+
1256
+ // src/utils/domain/py_builtin.ts
1257
+ var EvaluationError = class extends Error {
1258
+ constructor(message) {
1259
+ super(message);
1260
+ this.name = "EvaluationError";
1261
+ }
1262
+ };
1263
+ function execOnIterable(iterable, func) {
1264
+ if (iterable === null) {
1265
+ throw new EvaluationError("value not iterable");
1266
+ }
1267
+ if (typeof iterable === "object" && !Array.isArray(iterable) && !(iterable instanceof Set)) {
1268
+ iterable = Object.keys(iterable);
1269
+ }
1270
+ if (typeof (iterable == null ? void 0 : iterable[Symbol.iterator]) !== "function") {
1271
+ throw new EvaluationError("value not iterable");
1272
+ }
1273
+ return func(iterable);
1274
+ }
1275
+ var BUILTINS = {
1276
+ /**
1277
+ * @param {any} value
1278
+ * @returns {boolean}
1279
+ */
1280
+ bool(value) {
1281
+ switch (typeof value) {
1282
+ case "number":
1283
+ return value !== 0;
1284
+ case "string":
1285
+ return value !== "";
1286
+ case "boolean":
1287
+ return value;
1288
+ case "object":
1289
+ if (value === null || value === void 0) {
1290
+ return false;
1291
+ }
1292
+ if ("isTrue" in value && typeof value.isTrue === "function") {
1293
+ return value.isTrue();
1294
+ }
1295
+ if (value instanceof Array) {
1296
+ return !!value.length;
1297
+ }
1298
+ if (value instanceof Set) {
1299
+ return !!value.size;
1300
+ }
1301
+ return Object.keys(value).length !== 0;
1302
+ default:
1303
+ return true;
1304
+ }
1305
+ },
1306
+ set(iterable) {
1307
+ if (arguments.length > 2) {
1308
+ throw new EvaluationError(
1309
+ `set expected at most 1 argument, got (${arguments.length - 1})`
1310
+ );
1311
+ }
1312
+ return execOnIterable(
1313
+ iterable,
1314
+ (iterable2) => new Set(iterable2)
1315
+ );
1316
+ },
1317
+ time: {
1318
+ strftime(format) {
1319
+ return PyDateTime.now().strftime(format);
1320
+ }
1321
+ },
1322
+ context_today() {
1323
+ return PyDate.today();
1324
+ },
1325
+ get current_date() {
1326
+ return this.today;
1327
+ },
1328
+ get today() {
1329
+ return PyDate.today().strftime("%Y-%m-%d");
1330
+ },
1331
+ get now() {
1332
+ return PyDateTime.now().strftime("%Y-%m-%d %H:%M:%S");
1333
+ },
1334
+ datetime: {
1335
+ time: PyTime,
1336
+ timedelta: PyTimeDelta,
1337
+ datetime: PyDateTime,
1338
+ date: PyDate
1339
+ },
1340
+ relativedelta: PyRelativeDelta,
1341
+ true: true,
1342
+ false: false
1343
+ };
1344
+
1345
+ // src/utils/domain/py_utils.ts
1346
+ function toPyValue(value) {
1347
+ switch (typeof value) {
1348
+ case "string":
1349
+ return { type: 1, value };
1350
+ case "number":
1351
+ return { type: 0, value };
1352
+ case "boolean":
1353
+ return { type: 2, value };
1354
+ case "object":
1355
+ if (Array.isArray(value)) {
1356
+ return { type: 4, value: value.map(toPyValue) };
1357
+ } else if (value === null) {
1358
+ return {
1359
+ type: 3
1360
+ /* None */
1361
+ };
1362
+ } else if (value instanceof Date) {
1363
+ return {
1364
+ type: 1,
1365
+ value: String(PyDateTime.convertDate(value))
1366
+ };
1367
+ } else if (value instanceof PyDate || value instanceof PyDateTime) {
1368
+ return { type: 1, value };
1369
+ } else {
1370
+ const content = {};
1371
+ for (const key in value) {
1372
+ content[key] = toPyValue(value[key]);
1373
+ }
1374
+ return { type: 11, value: content };
1375
+ }
1376
+ default:
1377
+ throw new Error("Invalid type");
1378
+ }
1379
+ }
1380
+ function formatAST(ast, lbp = 0) {
1381
+ switch (ast.type) {
1382
+ case 3:
1383
+ return "None";
1384
+ case 1:
1385
+ return JSON.stringify(ast.value);
1386
+ case 0:
1387
+ return String(ast.value);
1388
+ case 2:
1389
+ return ast.value ? "True" : "False";
1390
+ case 4:
1391
+ return `[${ast.value.map(formatAST).join(", ")}]`;
1392
+ case 6:
1393
+ if (ast.op === "not") {
1394
+ return `not ${formatAST(ast.right, 50)}`;
1395
+ }
1396
+ return `${ast.op}${formatAST(ast.right, 130)}`;
1397
+ case 7:
1398
+ const abp = bp(ast.op);
1399
+ const binaryStr = `${formatAST(ast.left, abp)} ${ast.op} ${formatAST(ast.right, abp)}`;
1400
+ return abp < lbp ? `(${binaryStr})` : binaryStr;
1401
+ case 11:
1402
+ const pairs = [];
1403
+ for (const k in ast.value) {
1404
+ pairs.push(`"${k}": ${formatAST(ast.value[k])}`);
1405
+ }
1406
+ return `{${pairs.join(", ")}}`;
1407
+ case 10:
1408
+ return `(${ast.value.map(formatAST).join(", ")})`;
1409
+ case 5:
1410
+ return ast.value;
1411
+ case 12:
1412
+ return `${formatAST(ast.target)}[${formatAST(ast.key)}]`;
1413
+ case 13:
1414
+ const { ifTrue, condition, ifFalse } = ast;
1415
+ return `${formatAST(ifTrue)} if ${formatAST(condition)} else ${formatAST(ifFalse)}`;
1416
+ case 14:
1417
+ const boolAbp = bp(ast.op);
1418
+ const boolStr = `${formatAST(ast.left, boolAbp)} ${ast.op} ${formatAST(ast.right, boolAbp)}`;
1419
+ return boolAbp < lbp ? `(${boolStr})` : boolStr;
1420
+ case 15:
1421
+ return `${formatAST(ast.obj, 150)}.${ast.key}`;
1422
+ case 8:
1423
+ const args = ast.args.map(formatAST);
1424
+ const kwargs = [];
1425
+ for (const kwarg in ast.kwargs) {
1426
+ kwargs.push(`${kwarg} = ${formatAST(ast.kwargs[kwarg])}`);
1427
+ }
1428
+ const argStr = args.concat(kwargs).join(", ");
1429
+ return `${formatAST(ast.fn)}(${argStr})`;
1430
+ default:
1431
+ throw new Error("invalid expression: " + JSON.stringify(ast));
1432
+ }
1433
+ }
1434
+ var PY_DICT = /* @__PURE__ */ Object.create(null);
1435
+ function toPyDict(obj) {
1436
+ return new Proxy(obj, {
1437
+ getPrototypeOf() {
1438
+ return PY_DICT;
1439
+ }
1440
+ });
1441
+ }
1442
+
1443
+ // src/utils/domain/py_interpreter.ts
1444
+ var isTrue = BUILTINS.bool;
1445
+ function applyUnaryOp(ast, context) {
1446
+ const value = evaluate(ast.right, context);
1447
+ switch (ast.op) {
1448
+ case "-":
1449
+ if (value instanceof Object && "negate" in value) {
1450
+ return value.negate();
1451
+ }
1452
+ return -value;
1453
+ case "+":
1454
+ return value;
1455
+ case "not":
1456
+ return !isTrue(value);
1457
+ default:
1458
+ throw new EvaluationError(`Unknown unary operator: ${ast.op}`);
1459
+ }
1460
+ }
1461
+ function pytypeIndex(val) {
1462
+ switch (typeof val) {
1463
+ case "object":
1464
+ return val === null ? 1 : Array.isArray(val) ? 5 : 3;
1465
+ case "number":
1466
+ return 2;
1467
+ case "string":
1468
+ return 4;
1469
+ default:
1470
+ throw new EvaluationError(`Unknown type: ${typeof val}`);
1471
+ }
1472
+ }
1473
+ function isLess(left, right) {
1474
+ if (typeof left === "number" && typeof right === "number") {
1475
+ return left < right;
1476
+ }
1477
+ if (typeof left === "boolean") {
1478
+ left = left ? 1 : 0;
1479
+ }
1480
+ if (typeof right === "boolean") {
1481
+ right = right ? 1 : 0;
1482
+ }
1483
+ const leftIndex = pytypeIndex(left);
1484
+ const rightIndex = pytypeIndex(right);
1485
+ if (leftIndex === rightIndex) {
1486
+ return left < right;
1487
+ }
1488
+ return leftIndex < rightIndex;
1489
+ }
1490
+ function isEqual(left, right) {
1491
+ if (typeof left !== typeof right) {
1492
+ if (typeof left === "boolean" && typeof right === "number") {
1493
+ return right === (left ? 1 : 0);
1494
+ }
1495
+ if (typeof left === "number" && typeof right === "boolean") {
1496
+ return left === (right ? 1 : 0);
1497
+ }
1498
+ return false;
1499
+ }
1500
+ if (left instanceof Object && "isEqual" in left) {
1501
+ return left.isEqual(right);
1502
+ }
1503
+ return left === right;
1504
+ }
1505
+ function isIn(left, right) {
1506
+ if (Array.isArray(right)) {
1507
+ return right.includes(left);
1508
+ }
1509
+ if (typeof right === "string" && typeof left === "string") {
1510
+ return right.includes(left);
1511
+ }
1512
+ if (typeof right === "object") {
1513
+ return left in right;
1514
+ }
1515
+ return false;
1516
+ }
1517
+ function applyBinaryOp(ast, context) {
1518
+ const left = evaluate(ast.left, context);
1519
+ const right = evaluate(ast.right, context);
1520
+ switch (ast.op) {
1521
+ case "+": {
1522
+ const relativeDeltaOnLeft = left instanceof PyRelativeDelta;
1523
+ const relativeDeltaOnRight = right instanceof PyRelativeDelta;
1524
+ if (relativeDeltaOnLeft || relativeDeltaOnRight) {
1525
+ const date = relativeDeltaOnLeft ? right : left;
1526
+ const delta = relativeDeltaOnLeft ? left : right;
1527
+ return PyRelativeDelta.add(date, delta);
1528
+ }
1529
+ const timeDeltaOnLeft = left instanceof PyTimeDelta;
1530
+ const timeDeltaOnRight = right instanceof PyTimeDelta;
1531
+ if (timeDeltaOnLeft && timeDeltaOnRight) {
1532
+ return left.add(right);
1533
+ }
1534
+ if (timeDeltaOnLeft) {
1535
+ if (right instanceof PyDate || right instanceof PyDateTime) {
1536
+ return right.add(left);
1537
+ } else {
1538
+ throw new NotSupportedError();
1539
+ }
1540
+ }
1541
+ if (timeDeltaOnRight) {
1542
+ if (left instanceof PyDate || left instanceof PyDateTime) {
1543
+ return left.add(right);
1544
+ } else {
1545
+ throw new NotSupportedError();
1546
+ }
1547
+ }
1548
+ if (left instanceof Array && right instanceof Array) {
1549
+ return [...left, ...right];
1550
+ }
1551
+ return left + right;
1552
+ }
1553
+ case "-": {
1554
+ const isRightDelta = right instanceof PyRelativeDelta;
1555
+ if (isRightDelta) {
1556
+ return PyRelativeDelta.substract(left, right);
1557
+ }
1558
+ const timeDeltaOnRight = right instanceof PyTimeDelta;
1559
+ if (timeDeltaOnRight) {
1560
+ if (left instanceof PyTimeDelta) {
1561
+ return left.substract(right);
1562
+ } else if (left instanceof PyDate || left instanceof PyDateTime) {
1563
+ return left.substract(right);
1564
+ } else {
1565
+ throw new NotSupportedError();
1566
+ }
1567
+ }
1568
+ if (left instanceof PyDate) {
1569
+ return left.substract(right);
1570
+ }
1571
+ return left - right;
1572
+ }
1573
+ case "*": {
1574
+ const timeDeltaOnLeft = left instanceof PyTimeDelta;
1575
+ const timeDeltaOnRight = right instanceof PyTimeDelta;
1576
+ if (timeDeltaOnLeft || timeDeltaOnRight) {
1577
+ const number = timeDeltaOnLeft ? right : left;
1578
+ const delta = timeDeltaOnLeft ? left : right;
1579
+ return delta.multiply(number);
1580
+ }
1581
+ return left * right;
1582
+ }
1583
+ case "/":
1584
+ return left / right;
1585
+ case "%":
1586
+ return left % right;
1587
+ case "//":
1588
+ if (left instanceof PyTimeDelta) {
1589
+ return left.divide(right);
1590
+ }
1591
+ return Math.floor(left / right);
1592
+ case "**":
1593
+ return __pow(left, right);
1594
+ case "==":
1595
+ return isEqual(left, right);
1596
+ case "<>":
1597
+ case "!=":
1598
+ return !isEqual(left, right);
1599
+ case "<":
1600
+ return isLess(left, right);
1601
+ case ">":
1602
+ return isLess(right, left);
1603
+ case ">=":
1604
+ return isEqual(left, right) || isLess(right, left);
1605
+ case "<=":
1606
+ return isEqual(left, right) || isLess(left, right);
1607
+ case "in":
1608
+ return isIn(left, right);
1609
+ case "not in":
1610
+ return !isIn(left, right);
1611
+ default:
1612
+ throw new EvaluationError(`Unknown binary operator: ${ast.op}`);
1613
+ }
1614
+ }
1615
+ var DICT = {
1616
+ get(...args) {
1617
+ const { key, defValue } = parseArgs(args, ["key", "defValue"]);
1618
+ const self = this;
1619
+ if (key in self) {
1620
+ return self[key];
1621
+ } else if (defValue !== void 0) {
1622
+ return defValue;
1623
+ }
1624
+ return null;
1625
+ }
1626
+ };
1627
+ var STRING = {
1628
+ lower() {
1629
+ return this.toLowerCase();
1630
+ },
1631
+ upper() {
1632
+ return this.toUpperCase();
1633
+ }
1634
+ };
1635
+ function applyFunc(key, func, set, ...args) {
1636
+ if (args.length === 1) {
1637
+ return new Set(set);
1638
+ }
1639
+ if (args.length > 2) {
1640
+ throw new EvaluationError(
1641
+ `${key}: py_js supports at most 1 argument, got (${args.length - 1})`
1642
+ );
1643
+ }
1644
+ return execOnIterable(args[0], func);
1645
+ }
1646
+ var SET = {
1647
+ intersection(...args) {
1648
+ return applyFunc(
1649
+ "intersection",
1650
+ (iterable) => {
1651
+ const intersection = /* @__PURE__ */ new Set();
1652
+ for (const i of iterable) {
1653
+ if (this.has(i)) {
1654
+ intersection.add(i);
1655
+ }
1656
+ }
1657
+ return intersection;
1658
+ },
1659
+ this,
1660
+ ...args
1661
+ );
1662
+ },
1663
+ difference(...args) {
1664
+ return applyFunc(
1665
+ "difference",
1666
+ (iterable) => {
1667
+ iterable = new Set(iterable);
1668
+ const difference = /* @__PURE__ */ new Set();
1669
+ for (const e of this) {
1670
+ if (!iterable.has(e)) {
1671
+ difference.add(e);
1672
+ }
1673
+ }
1674
+ return difference;
1675
+ },
1676
+ this,
1677
+ ...args
1678
+ );
1679
+ },
1680
+ union(...args) {
1681
+ return applyFunc(
1682
+ "union",
1683
+ (iterable) => {
1684
+ return /* @__PURE__ */ new Set([...this, ...iterable]);
1685
+ },
1686
+ this,
1687
+ ...args
1688
+ );
1689
+ }
1690
+ };
1691
+ function methods(_class) {
1692
+ return Object.getOwnPropertyNames(_class.prototype).map(
1693
+ (prop) => _class.prototype[prop]
1694
+ );
1695
+ }
1696
+ var allowedFns = /* @__PURE__ */ new Set([
1697
+ BUILTINS.time.strftime,
1698
+ BUILTINS.set,
1699
+ BUILTINS.bool,
1700
+ BUILTINS.context_today,
1701
+ BUILTINS.datetime.datetime.now,
1702
+ BUILTINS.datetime.datetime.combine,
1703
+ BUILTINS.datetime.date.today,
1704
+ ...methods(BUILTINS.relativedelta),
1705
+ ...Object.values(BUILTINS.datetime).flatMap((obj) => methods(obj)),
1706
+ ...Object.values(SET),
1707
+ ...Object.values(DICT),
1708
+ ...Object.values(STRING)
1709
+ ]);
1710
+ var unboundFn = Symbol("unbound function");
1711
+ function evaluate(ast, context = {}) {
1712
+ const dicts = /* @__PURE__ */ new Set();
1713
+ let pyContext;
1714
+ const evalContext = Object.create(context);
1715
+ if (!(evalContext == null ? void 0 : evalContext.context)) {
1716
+ Object.defineProperty(evalContext, "context", {
1717
+ get() {
1718
+ if (!pyContext) {
1719
+ pyContext = toPyDict(context);
1720
+ }
1721
+ return pyContext;
1722
+ }
1723
+ });
1724
+ }
1725
+ function _innerEvaluate(ast2) {
1726
+ var _a, _b, _c;
1727
+ switch (ast2 == null ? void 0 : ast2.type) {
1728
+ case 0:
1729
+ // Number
1730
+ case 1:
1731
+ return ast2.value;
1732
+ case 5:
1733
+ if (ast2.value in evalContext) {
1734
+ if (typeof evalContext[ast2.value] === "object" && ((_a = evalContext[ast2.value]) == null ? void 0 : _a.id)) {
1735
+ return (_b = evalContext[ast2.value]) == null ? void 0 : _b.id;
1736
+ }
1737
+ return (_c = evalContext[ast2.value]) != null ? _c : false;
1738
+ } else if (ast2.value in BUILTINS) {
1739
+ return BUILTINS[ast2.value];
1740
+ } else {
1741
+ return false;
1742
+ }
1743
+ case 3:
1744
+ return null;
1745
+ case 2:
1746
+ return ast2.value;
1747
+ case 6:
1748
+ return applyUnaryOp(ast2, evalContext);
1749
+ case 7:
1750
+ return applyBinaryOp(ast2, evalContext);
1751
+ case 14:
1752
+ const left = _evaluate(ast2.left);
1753
+ if (ast2.op === "and") {
1754
+ return isTrue(left) ? _evaluate(ast2.right) : left;
1755
+ } else {
1756
+ return isTrue(left) ? left : _evaluate(ast2.right);
1757
+ }
1758
+ case 4:
1759
+ // List
1760
+ case 10:
1761
+ return ast2.value.map(_evaluate);
1762
+ case 11:
1763
+ const dict = {};
1764
+ for (const key2 in ast2.value) {
1765
+ dict[key2] = _evaluate(ast2.value[key2]);
1766
+ }
1767
+ dicts.add(dict);
1768
+ return dict;
1769
+ case 8:
1770
+ const fnValue = _evaluate(ast2.fn);
1771
+ const args = ast2.args.map(_evaluate);
1772
+ const kwargs = {};
1773
+ for (const kwarg in ast2.kwargs) {
1774
+ kwargs[kwarg] = _evaluate(ast2 == null ? void 0 : ast2.kwargs[kwarg]);
1775
+ }
1776
+ if (fnValue === PyDate || fnValue === PyDateTime || fnValue === PyTime || fnValue === PyRelativeDelta || fnValue === PyTimeDelta) {
1777
+ return fnValue.create(...args, kwargs);
1778
+ }
1779
+ return fnValue(...args, kwargs);
1780
+ case 12:
1781
+ const dictVal = _evaluate(ast2.target);
1782
+ const key = _evaluate(ast2.key);
1783
+ return dictVal[key];
1784
+ case 13:
1785
+ if (isTrue(_evaluate(ast2.condition))) {
1786
+ return _evaluate(ast2.ifTrue);
1787
+ } else {
1788
+ return _evaluate(ast2.ifFalse);
1789
+ }
1790
+ case 15:
1791
+ let leftVal = _evaluate(ast2.obj);
1792
+ let result;
1793
+ if (dicts.has(leftVal) || Object.isPrototypeOf.call(PY_DICT, leftVal)) {
1794
+ result = DICT[ast2.key];
1795
+ } else if (typeof leftVal === "string") {
1796
+ result = STRING[ast2.key];
1797
+ } else if (leftVal instanceof Set) {
1798
+ result = SET[ast2.key];
1799
+ } else if (ast2.key === "get" && typeof leftVal === "object") {
1800
+ result = DICT[ast2.key];
1801
+ leftVal = toPyDict(leftVal);
1802
+ } else {
1803
+ result = leftVal[ast2.key];
1804
+ }
1805
+ if (typeof result === "function") {
1806
+ const bound = result.bind(leftVal);
1807
+ bound[unboundFn] = result;
1808
+ return bound;
1809
+ }
1810
+ return result;
1811
+ default:
1812
+ throw new EvaluationError(`AST of type ${ast2.type} cannot be evaluated`);
1813
+ }
1814
+ }
1815
+ function _evaluate(ast2) {
1816
+ const val = _innerEvaluate(ast2);
1817
+ if (typeof val === "function" && !allowedFns.has(val) && !allowedFns.has(val[unboundFn])) {
1818
+ throw new Error("Invalid Function Call");
1819
+ }
1820
+ return val;
1821
+ }
1822
+ return _evaluate(ast);
1823
+ }
1824
+
1825
+ // src/utils/domain/py.ts
1826
+ function parseExpr(expr) {
1827
+ const tokens = tokenize(expr);
1828
+ return parse(tokens);
1829
+ }
1830
+
1831
+ // src/utils/domain/objects.ts
1832
+ function shallowEqual(obj1, obj2, comparisonFn = (a, b) => a === b) {
1833
+ if (!obj1 || !obj2 || typeof obj1 !== "object" || typeof obj2 !== "object") {
1834
+ return obj1 === obj2;
1835
+ }
1836
+ const obj1Keys = Object.keys(obj1);
1837
+ return obj1Keys.length === Object.keys(obj2).length && obj1Keys.every((key) => comparisonFn(obj1[key], obj2[key]));
1838
+ }
1839
+
1840
+ // src/utils/domain/arrays.ts
1841
+ var shallowEqual2 = shallowEqual;
1842
+
1843
+ // src/utils/domain/strings.ts
1844
+ var escapeMethod = Symbol("html");
1845
+ function escapeRegExp(str) {
1846
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1847
+ }
1848
+
1849
+ // src/utils/domain/domain.ts
1850
+ var InvalidDomainError = class extends Error {
1851
+ };
1852
+ var Domain = class _Domain {
1853
+ constructor(descr = []) {
1854
+ this.ast = { type: -1, value: null };
1855
+ if (descr instanceof _Domain) {
1856
+ return new _Domain(descr.toString());
1857
+ } else {
1858
+ let rawAST;
1859
+ try {
1860
+ rawAST = typeof descr === "string" ? parseExpr(descr) : toAST(descr);
1861
+ } catch (error) {
1862
+ throw new InvalidDomainError(
1863
+ `Invalid domain representation: ${descr}`,
1864
+ {
1865
+ cause: error
1866
+ }
1867
+ );
1868
+ }
1869
+ this.ast = normalizeDomainAST(rawAST);
1870
+ }
1871
+ }
1872
+ static combine(domains, operator) {
1873
+ if (domains.length === 0) {
1874
+ return new _Domain([]);
1875
+ }
1876
+ const domain1 = domains[0] instanceof _Domain ? domains[0] : new _Domain(domains[0]);
1877
+ if (domains.length === 1) {
1878
+ return domain1;
1879
+ }
1880
+ const domain2 = _Domain.combine(domains.slice(1), operator);
1881
+ const result = new _Domain([]);
1882
+ const astValues1 = domain1.ast.value;
1883
+ const astValues2 = domain2.ast.value;
1884
+ const op = operator === "AND" ? "&" : "|";
1885
+ const combinedAST = {
1886
+ type: 4,
1887
+ value: astValues1.concat(astValues2)
1888
+ };
1889
+ result.ast = normalizeDomainAST(combinedAST, op);
1890
+ return result;
1891
+ }
1892
+ static and(domains) {
1893
+ return _Domain.combine(domains, "AND");
1894
+ }
1895
+ static or(domains) {
1896
+ return _Domain.combine(domains, "OR");
1897
+ }
1898
+ static not(domain) {
1899
+ const result = new _Domain(domain);
1900
+ result.ast.value.unshift({ type: 1, value: "!" });
1901
+ return result;
1902
+ }
1903
+ static removeDomainLeaves(domain, keysToRemove) {
1904
+ function processLeaf(elements, idx, operatorCtx, newDomain2) {
1905
+ const leaf = elements[idx];
1906
+ if (leaf.type === 10) {
1907
+ if (keysToRemove.includes(leaf.value[0].value)) {
1908
+ if (operatorCtx === "&") {
1909
+ newDomain2.ast.value.push(..._Domain.TRUE.ast.value);
1910
+ } else if (operatorCtx === "|") {
1911
+ newDomain2.ast.value.push(..._Domain.FALSE.ast.value);
1912
+ }
1913
+ } else {
1914
+ newDomain2.ast.value.push(leaf);
1915
+ }
1916
+ return 1;
1917
+ } else if (leaf.type === 1) {
1918
+ if (leaf.value === "|" && elements[idx + 1].type === 10 && elements[idx + 2].type === 10 && keysToRemove.includes(elements[idx + 1].value[0].value) && keysToRemove.includes(elements[idx + 2].value[0].value)) {
1919
+ newDomain2.ast.value.push(..._Domain.TRUE.ast.value);
1920
+ return 3;
1921
+ }
1922
+ newDomain2.ast.value.push(leaf);
1923
+ if (leaf.value === "!") {
1924
+ return 1 + processLeaf(elements, idx + 1, "&", newDomain2);
1925
+ }
1926
+ const firstLeafSkip = processLeaf(
1927
+ elements,
1928
+ idx + 1,
1929
+ leaf.value,
1930
+ newDomain2
1931
+ );
1932
+ const secondLeafSkip = processLeaf(
1933
+ elements,
1934
+ idx + 1 + firstLeafSkip,
1935
+ leaf.value,
1936
+ newDomain2
1937
+ );
1938
+ return 1 + firstLeafSkip + secondLeafSkip;
1939
+ }
1940
+ return 0;
1941
+ }
1942
+ const d = new _Domain(domain);
1943
+ if (d.ast.value.length === 0) {
1944
+ return d;
1945
+ }
1946
+ const newDomain = new _Domain([]);
1947
+ processLeaf(d.ast.value, 0, "&", newDomain);
1948
+ return newDomain;
1949
+ }
1950
+ contains(record) {
1951
+ const expr = evaluate(this.ast, record);
1952
+ return matchDomain(record, expr);
1953
+ }
1954
+ toString() {
1955
+ return formatAST(this.ast);
1956
+ }
1957
+ toList(context) {
1958
+ return evaluate(this.ast, context);
1959
+ }
1960
+ toJson() {
1961
+ try {
1962
+ const evaluatedAsList = this.toList({});
1963
+ const evaluatedDomain = new _Domain(evaluatedAsList);
1964
+ if (evaluatedDomain.toString() === this.toString()) {
1965
+ return evaluatedAsList;
1966
+ }
1967
+ return this.toString();
1968
+ } catch (e) {
1969
+ return this.toString();
1970
+ }
1971
+ }
1972
+ };
1973
+ var TRUE_LEAF = [1, "=", 1];
1974
+ var FALSE_LEAF = [0, "=", 1];
1975
+ var TRUE_DOMAIN = new Domain([TRUE_LEAF]);
1976
+ var FALSE_DOMAIN = new Domain([FALSE_LEAF]);
1977
+ Domain.TRUE = TRUE_DOMAIN;
1978
+ Domain.FALSE = FALSE_DOMAIN;
1979
+ function toAST(domain) {
1980
+ const elems = domain.map((elem) => {
1981
+ switch (elem) {
1982
+ case "!":
1983
+ case "&":
1984
+ case "|":
1985
+ return { type: 1, value: elem };
1986
+ default:
1987
+ return {
1988
+ type: 10,
1989
+ value: elem.map(toPyValue)
1990
+ };
1991
+ }
1992
+ });
1993
+ return { type: 4, value: elems };
1994
+ }
1995
+ function normalizeDomainAST(domain, op = "&") {
1996
+ if (domain.type !== 4) {
1997
+ if (domain.type === 10) {
1998
+ const value = domain.value;
1999
+ if (value.findIndex((e) => e.type === 10) === -1 || !value.every((e) => e.type === 10 || e.type === 1)) {
2000
+ throw new InvalidDomainError("Invalid domain AST");
2001
+ }
2002
+ } else {
2003
+ throw new InvalidDomainError("Invalid domain AST");
2004
+ }
2005
+ }
2006
+ if (domain.value.length === 0) {
2007
+ return domain;
2008
+ }
2009
+ let expected = 1;
2010
+ for (const child of domain.value) {
2011
+ switch (child.type) {
2012
+ case 1:
2013
+ if (child.value === "&" || child.value === "|") {
2014
+ expected++;
2015
+ } else if (child.value !== "!") {
2016
+ throw new InvalidDomainError("Invalid domain AST");
2017
+ }
2018
+ break;
2019
+ case 4:
2020
+ /* list */
2021
+ case 10:
2022
+ if (child.value.length === 3) {
2023
+ expected--;
2024
+ break;
2025
+ }
2026
+ throw new InvalidDomainError("Invalid domain AST");
2027
+ default:
2028
+ throw new InvalidDomainError("Invalid domain AST");
2029
+ }
2030
+ }
2031
+ const values = domain.value.slice();
2032
+ while (expected < 0) {
2033
+ expected++;
2034
+ values.unshift({ type: 1, value: op });
2035
+ }
2036
+ if (expected > 0) {
2037
+ throw new InvalidDomainError(
2038
+ `invalid domain ${formatAST(domain)} (missing ${expected} segment(s))`
2039
+ );
2040
+ }
2041
+ return { type: 4, value: values };
2042
+ }
2043
+ function matchCondition(record, condition) {
2044
+ if (typeof condition === "boolean") {
2045
+ return condition;
2046
+ }
2047
+ const [field, operator, value] = condition;
2048
+ if (typeof field === "string") {
2049
+ const names = field.split(".");
2050
+ if (names.length >= 2) {
2051
+ return matchCondition(record[names[0]], [
2052
+ names.slice(1).join("."),
2053
+ operator,
2054
+ value
2055
+ ]);
2056
+ }
2057
+ }
2058
+ let likeRegexp, ilikeRegexp;
2059
+ if (["like", "not like", "ilike", "not ilike"].includes(operator)) {
2060
+ likeRegexp = new RegExp(
2061
+ `(.*)${escapeRegExp(value).replaceAll("%", "(.*)")}(.*)`,
2062
+ "g"
2063
+ );
2064
+ ilikeRegexp = new RegExp(
2065
+ `(.*)${escapeRegExp(value).replaceAll("%", "(.*)")}(.*)`,
2066
+ "gi"
2067
+ );
2068
+ }
2069
+ const fieldValue = typeof field === "number" ? field : record[field];
2070
+ switch (operator) {
2071
+ case "=?":
2072
+ if ([false, null].includes(value)) {
2073
+ return true;
2074
+ }
2075
+ // eslint-disable-next-line no-fallthrough
2076
+ case "=":
2077
+ case "==":
2078
+ if (Array.isArray(fieldValue) && Array.isArray(value)) {
2079
+ return shallowEqual2(fieldValue, value);
2080
+ }
2081
+ return fieldValue === value;
2082
+ case "!=":
2083
+ case "<>":
2084
+ return !matchCondition(record, [field, "==", value]);
2085
+ case "<":
2086
+ return fieldValue < value;
2087
+ case "<=":
2088
+ return fieldValue <= value;
2089
+ case ">":
2090
+ return fieldValue > value;
2091
+ case ">=":
2092
+ return fieldValue >= value;
2093
+ case "in": {
2094
+ const val = Array.isArray(value) ? value : [value];
2095
+ const fieldVal = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
2096
+ return fieldVal.some((fv) => val.includes(fv));
2097
+ }
2098
+ case "not in": {
2099
+ const val = Array.isArray(value) ? value : [value];
2100
+ const fieldVal = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
2101
+ return !fieldVal.some((fv) => val.includes(fv));
2102
+ }
2103
+ case "like":
2104
+ if (fieldValue === false) {
2105
+ return false;
2106
+ }
2107
+ return Boolean(fieldValue.match(likeRegexp));
2108
+ case "not like":
2109
+ if (fieldValue === false) {
2110
+ return false;
2111
+ }
2112
+ return Boolean(!fieldValue.match(likeRegexp));
2113
+ case "=like":
2114
+ if (fieldValue === false) {
2115
+ return false;
2116
+ }
2117
+ return new RegExp(escapeRegExp(value).replace(/%/g, ".*")).test(
2118
+ fieldValue
2119
+ );
2120
+ case "ilike":
2121
+ if (fieldValue === false) {
2122
+ return false;
2123
+ }
2124
+ return Boolean(fieldValue.match(ilikeRegexp));
2125
+ case "not ilike":
2126
+ if (fieldValue === false) {
2127
+ return false;
2128
+ }
2129
+ return Boolean(!fieldValue.match(ilikeRegexp));
2130
+ case "=ilike":
2131
+ if (fieldValue === false) {
2132
+ return false;
2133
+ }
2134
+ return new RegExp(escapeRegExp(value).replace(/%/g, ".*"), "i").test(
2135
+ fieldValue
2136
+ );
2137
+ }
2138
+ throw new InvalidDomainError("could not match domain");
2139
+ }
2140
+ function makeOperators(record) {
2141
+ const match = matchCondition.bind(null, record);
2142
+ return {
2143
+ "!": (x) => !match(x),
2144
+ "&": (a, b) => match(a) && match(b),
2145
+ "|": (a, b) => match(a) || match(b)
2146
+ };
2147
+ }
2148
+ function matchDomain(record, domain) {
2149
+ if (domain.length === 0) {
2150
+ return true;
2151
+ }
2152
+ const operators = makeOperators(record);
2153
+ const reversedDomain = Array.from(domain).reverse();
2154
+ const condStack = [];
2155
+ for (const item of reversedDomain) {
2156
+ const operator = typeof item === "string" && operators[item];
2157
+ if (operator) {
2158
+ const operands = condStack.splice(-operator.length);
2159
+ condStack.push(operator(...operands));
2160
+ } else {
2161
+ condStack.push(item);
2162
+ }
2163
+ }
2164
+ return matchCondition(record, condStack.pop());
2165
+ }
2166
+
2167
+ // src/utils/function.ts
2168
+ import { useEffect, useState } from "react";
2169
+ var toQueryString = (params) => {
2170
+ return Object.keys(params).map(
2171
+ (key) => encodeURIComponent(key) + "=" + encodeURIComponent(params[key].toString())
2172
+ ).join("&");
2173
+ };
2174
+ var updateTokenParamInOriginalRequest = (originalRequest, newAccessToken) => {
2175
+ if (!originalRequest.data) return originalRequest.data;
2176
+ if (typeof originalRequest.data === "string") {
2177
+ try {
2178
+ const parsedData = JSON.parse(originalRequest.data);
2179
+ if (parsedData.with_context && typeof parsedData.with_context === "object") {
2180
+ parsedData.with_context.token = newAccessToken;
2181
+ }
2182
+ return JSON.stringify(parsedData);
2183
+ } catch (e) {
2184
+ console.warn("Failed to parse originalRequest.data", e);
2185
+ return originalRequest.data;
2186
+ }
2187
+ }
2188
+ if (typeof originalRequest.data === "object" && originalRequest.data.with_context) {
2189
+ originalRequest.data.with_context.token = newAccessToken;
2190
+ }
2191
+ return originalRequest.data;
2192
+ };
2193
+
2194
+ // src/utils/storage/local-storage.ts
2195
+ var localStorageUtils = () => {
2196
+ const setToken = (access_token) => __async(null, null, function* () {
2197
+ localStorage.setItem("accessToken", access_token);
2198
+ });
2199
+ const setRefreshToken = (refresh_token) => __async(null, null, function* () {
2200
+ localStorage.setItem("refreshToken", refresh_token);
2201
+ });
2202
+ const getAccessToken = () => __async(null, null, function* () {
2203
+ return localStorage.getItem("accessToken");
2204
+ });
2205
+ const getRefreshToken = () => __async(null, null, function* () {
2206
+ return localStorage.getItem("refreshToken");
2207
+ });
2208
+ const clearToken = () => __async(null, null, function* () {
2209
+ localStorage.removeItem("accessToken");
2210
+ localStorage.removeItem("refreshToken");
2211
+ });
2212
+ return {
2213
+ setToken,
2214
+ setRefreshToken,
2215
+ getAccessToken,
2216
+ getRefreshToken,
2217
+ clearToken
2218
+ };
2219
+ };
2220
+
2221
+ // src/utils/storage/session-storage.ts
2222
+ var sessionStorageUtils = () => {
2223
+ const getBrowserSession = () => __async(null, null, function* () {
2224
+ return sessionStorage.getItem("browserSession");
2225
+ });
2226
+ return {
2227
+ getBrowserSession
2228
+ };
2229
+ };
2230
+
2231
+ // src/configs/axios-client.ts
2232
+ var axiosClient = {
2233
+ init(config) {
2234
+ var _a, _b;
2235
+ const localStorage2 = (_a = config.localStorageUtils) != null ? _a : localStorageUtils();
2236
+ const sessionStorage2 = (_b = config.sessionStorageUtils) != null ? _b : sessionStorageUtils();
2237
+ const db = config.db;
2238
+ let isRefreshing = false;
2239
+ let failedQueue = [];
2240
+ const processQueue = (error, token = null) => {
2241
+ failedQueue == null ? void 0 : failedQueue.forEach((prom) => {
2242
+ if (error) {
2243
+ prom.reject(error);
2244
+ } else {
2245
+ prom.resolve(token);
2246
+ }
2247
+ });
2248
+ failedQueue = [];
2249
+ };
2250
+ const instance = axios.create({
2251
+ adapter: axios.defaults.adapter,
2252
+ baseURL: config.baseUrl,
2253
+ timeout: 5e4,
2254
+ paramsSerializer: (params) => new URLSearchParams(params).toString()
2255
+ });
2256
+ instance.interceptors.request.use(
2257
+ (config2) => __async(null, null, function* () {
2258
+ const useRefreshToken = config2.useRefreshToken;
2259
+ const token = useRefreshToken ? yield localStorage2.getRefreshToken() : yield localStorage2.getAccessToken();
2260
+ if (token) {
2261
+ config2.headers["Authorization"] = "Bearer " + token;
2262
+ }
2263
+ return config2;
2264
+ }),
2265
+ (error) => {
2266
+ Promise.reject(error);
2267
+ }
2268
+ );
2269
+ instance.interceptors.response.use(
2270
+ (response) => {
2271
+ return handleResponse(response);
2272
+ },
2273
+ (error) => __async(null, null, function* () {
2274
+ var _a2, _b2, _c;
2275
+ const handleError3 = (error2) => __async(null, null, function* () {
2276
+ var _a3;
2277
+ if (!error2.response) {
2278
+ return error2;
2279
+ }
2280
+ const { data } = error2.response;
2281
+ if (data && data.code === 400 && ["invalid_grant"].includes((_a3 = data.data) == null ? void 0 : _a3.error)) {
2282
+ yield clearAuthToken();
2283
+ }
2284
+ return data;
2285
+ });
2286
+ const originalRequest = error.config;
2287
+ if ((((_a2 = error.response) == null ? void 0 : _a2.status) === 403 || ((_b2 = error.response) == null ? void 0 : _b2.status) === 401 || ((_c = error.response) == null ? void 0 : _c.status) === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401, "ERR_2FA_006"].includes(
2288
+ error.response.data.code
2289
+ )) {
2290
+ if (isRefreshing) {
2291
+ return new Promise(function(resolve, reject) {
2292
+ failedQueue.push({ resolve, reject });
2293
+ }).then((token) => {
2294
+ originalRequest.headers["Authorization"] = "Bearer " + token;
2295
+ originalRequest.data = updateTokenParamInOriginalRequest(
2296
+ originalRequest,
2297
+ token
2298
+ );
2299
+ return instance.request(originalRequest);
2300
+ }).catch((err) => __async(null, null, function* () {
2301
+ var _a3, _b3;
2302
+ if ((((_a3 = err.response) == null ? void 0 : _a3.status) === 400 || ((_b3 = err.response) == null ? void 0 : _b3.status) === 401) && ["invalid_grant"].includes(err.response.data.error)) {
2303
+ yield clearAuthToken();
2304
+ }
2305
+ }));
2306
+ }
2307
+ const browserSession = yield sessionStorage2.getBrowserSession();
2308
+ const refreshToken = yield localStorage2.getRefreshToken();
2309
+ const accessTokenExp = yield localStorage2.getAccessToken();
2310
+ isRefreshing = true;
2311
+ if (!refreshToken && (!browserSession || browserSession == "unActive")) {
2312
+ yield clearAuthToken();
2313
+ } else {
2314
+ const payload = Object.fromEntries(
2315
+ Object.entries({
2316
+ refresh_token: refreshToken,
2317
+ grant_type: "refresh_token",
2318
+ client_id: config.config.clientId,
2319
+ client_secret: config.config.clientSecret
2320
+ }).filter(([_, value]) => !!value)
2321
+ );
2322
+ return new Promise(function(resolve) {
2323
+ var _a3;
2324
+ axios.post(
2325
+ `${config.baseUrl}${(_a3 = config.refreshTokenEndpoint) != null ? _a3 : "/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
2326
+ payload,
2327
+ {
2328
+ headers: {
2329
+ "Content-Type": config.refreshTokenEndpoint ? "application/x-www-form-urlencoded" : "multipart/form-data",
2330
+ Authorization: `Bearer ${accessTokenExp}`
2331
+ }
2332
+ }
2333
+ ).then((res) => __async(null, null, function* () {
2334
+ const data = res.data;
2335
+ yield localStorage2.setToken(data.access_token);
2336
+ yield localStorage2.setRefreshToken(data.refresh_token);
2337
+ axios.defaults.headers.common["Authorization"] = "Bearer " + data.access_token;
2338
+ originalRequest.headers["Authorization"] = "Bearer " + data.access_token;
2339
+ originalRequest.data = updateTokenParamInOriginalRequest(
2340
+ originalRequest,
2341
+ data.access_token
2342
+ );
2343
+ processQueue(null, data.access_token);
2344
+ resolve(instance.request(originalRequest));
2345
+ })).catch((err) => __async(null, null, function* () {
2346
+ var _a4;
2347
+ if (err && ((err == null ? void 0 : err.error_code) === "AUTHEN_FAIL" || (err == null ? void 0 : err.error_code) === "TOKEN_EXPIRED" || (err == null ? void 0 : err.error_code) === "TOKEN_INCORRECT" || (err == null ? void 0 : err.code) === "ERR_BAD_REQUEST") || (err == null ? void 0 : err.error_code) === "ERR_2FA_006") {
2348
+ yield clearAuthToken();
2349
+ }
2350
+ if (err && err.response) {
2351
+ const { error_code } = ((_a4 = err.response) == null ? void 0 : _a4.data) || {};
2352
+ if (error_code === "AUTHEN_FAIL") {
2353
+ yield clearAuthToken();
2354
+ }
2355
+ }
2356
+ processQueue(err, null);
2357
+ })).finally(() => {
2358
+ isRefreshing = false;
2359
+ });
2360
+ });
2361
+ }
2362
+ }
2363
+ return Promise.reject(yield handleError3(error));
2364
+ })
2365
+ );
2366
+ const handleResponse = (res) => {
2367
+ if (res && res.data) {
2368
+ return res.data;
2369
+ }
2370
+ return res;
2371
+ };
2372
+ const handleError2 = (error) => {
2373
+ var _a2, _b2, _c;
2374
+ if (error.isAxiosError && error.code === "ECONNABORTED") {
2375
+ console.error("Request Timeout Error:", error);
2376
+ return "Request Timeout Error";
2377
+ } else if (error.isAxiosError && !error.response) {
2378
+ console.error("Network Error:", error);
2379
+ return "Network Error";
2380
+ } else {
2381
+ console.error("Other Error:", error == null ? void 0 : error.response);
2382
+ const errorMessage = ((_b2 = (_a2 = error == null ? void 0 : error.response) == null ? void 0 : _a2.data) == null ? void 0 : _b2.message) || "An error occurred";
2383
+ return { message: errorMessage, status: (_c = error == null ? void 0 : error.response) == null ? void 0 : _c.status };
2384
+ }
2385
+ };
2386
+ const clearAuthToken = () => __async(null, null, function* () {
2387
+ yield localStorage2.clearToken();
2388
+ if (typeof window !== "undefined") {
2389
+ window.location.href = `/login`;
2390
+ }
2391
+ });
2392
+ function formatUrl(url, db2) {
2393
+ return url + (db2 ? "?db=" + db2 : "");
2394
+ }
2395
+ const responseBody = (response) => response;
2396
+ const requests = {
2397
+ get: (url, headers) => instance.get(formatUrl(url, db), headers).then(responseBody),
2398
+ post: (url, body, headers) => instance.post(formatUrl(url, db), body, headers).then(responseBody),
2399
+ post_excel: (url, body, headers) => instance.post(formatUrl(url, db), body, {
2400
+ responseType: "arraybuffer",
2401
+ headers: {
2402
+ "Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
2403
+ Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
2404
+ }
2405
+ }).then(responseBody),
2406
+ put: (url, body, headers) => instance.put(formatUrl(url, db), body, headers).then(responseBody),
2407
+ patch: (url, body) => instance.patch(formatUrl(url, db), body).then(responseBody),
2408
+ delete: (url, body) => instance.delete(formatUrl(url, db), body).then(responseBody)
2409
+ };
2410
+ return requests;
2411
+ }
2412
+ };
2413
+
2414
+ // src/store/index.ts
2415
+ import { useDispatch, useSelector } from "react-redux";
2416
+
2417
+ // src/store/reducers/breadcrums-slice/index.ts
2418
+ import { createSlice } from "@reduxjs/toolkit";
2419
+ var initialState = {
2420
+ breadCrumbs: []
2421
+ };
2422
+ var breadcrumbsSlice = createSlice({
2423
+ name: "breadcrumbs",
2424
+ initialState,
2425
+ reducers: {
2426
+ setBreadCrumbs: (state, action) => {
2427
+ state.breadCrumbs = [...state.breadCrumbs, action.payload];
2428
+ }
2429
+ }
2430
+ });
2431
+ var { setBreadCrumbs } = breadcrumbsSlice.actions;
2432
+ var breadcrums_slice_default = breadcrumbsSlice.reducer;
2433
+
2434
+ // src/store/reducers/env-slice/index.ts
2435
+ import { createSlice as createSlice2 } from "@reduxjs/toolkit";
2436
+ var initialState2 = {
2437
+ baseUrl: "",
2438
+ requests: null,
2439
+ companies: [],
2440
+ user: {},
2441
+ config: null,
2442
+ envFile: null,
2443
+ defaultCompany: {
2444
+ id: null,
2445
+ logo: "",
2446
+ secondary_color: "",
2447
+ primary_color: ""
2448
+ },
2449
+ context: {
2450
+ uid: null,
2451
+ allowed_company_ids: [],
2452
+ lang: "vi_VN",
2453
+ tz: "Asia/Saigon"
2454
+ }
2455
+ };
2456
+ var envSlice = createSlice2({
2457
+ name: "env",
2458
+ initialState: initialState2,
2459
+ reducers: {
2460
+ setEnv: (state, action) => {
2461
+ Object.assign(state, action.payload);
2462
+ },
2463
+ setUid: (state, action) => {
2464
+ state.context.uid = action.payload;
2465
+ },
2466
+ setAllowCompanies: (state, action) => {
2467
+ state.context.allowed_company_ids = action.payload;
2468
+ },
2469
+ setCompanies: (state, action) => {
2470
+ state.companies = action.payload;
2471
+ },
2472
+ setDefaultCompany: (state, action) => {
2473
+ state.defaultCompany = action.payload;
2474
+ },
2475
+ setLang: (state, action) => {
2476
+ state.context.lang = action.payload;
2477
+ },
2478
+ setUser: (state, action) => {
2479
+ state.user = action.payload;
2480
+ },
2481
+ setConfig: (state, action) => {
2482
+ state.config = action.payload;
2483
+ },
2484
+ setEnvFile: (state, action) => {
2485
+ state.envFile = action.payload;
2486
+ }
2487
+ }
2488
+ });
2489
+ var {
2490
+ setEnv,
2491
+ setUid,
2492
+ setLang,
2493
+ setAllowCompanies,
2494
+ setCompanies,
2495
+ setDefaultCompany,
2496
+ setUser,
2497
+ setConfig,
2498
+ setEnvFile
2499
+ } = envSlice.actions;
2500
+ var env_slice_default = envSlice.reducer;
2501
+
2502
+ // src/store/reducers/excel-slice/index.ts
2503
+ import { createSlice as createSlice3 } from "@reduxjs/toolkit";
2504
+ var initialState3 = {
2505
+ dataParse: null,
2506
+ idFile: null,
2507
+ isFileLoaded: false,
2508
+ loadingImport: false,
2509
+ selectedFile: null,
2510
+ errorData: null
2511
+ };
2512
+ var excelSlice = createSlice3({
2513
+ name: "excel",
2514
+ initialState: initialState3,
2515
+ reducers: {
2516
+ setDataParse: (state, action) => {
2517
+ state.dataParse = action.payload;
2518
+ },
2519
+ setIdFile: (state, action) => {
2520
+ state.idFile = action.payload;
2521
+ },
2522
+ setIsFileLoaded: (state, action) => {
2523
+ state.isFileLoaded = action.payload;
2524
+ },
2525
+ setLoadingImport: (state, action) => {
2526
+ state.loadingImport = action.payload;
2527
+ },
2528
+ setSelectedFile: (state, action) => {
2529
+ state.selectedFile = action.payload;
2530
+ },
2531
+ setErrorData: (state, action) => {
2532
+ state.errorData = action.payload;
2533
+ }
2534
+ }
2535
+ });
2536
+ var {
2537
+ setDataParse,
2538
+ setIdFile,
2539
+ setIsFileLoaded,
2540
+ setLoadingImport,
2541
+ setSelectedFile,
2542
+ setErrorData
2543
+ } = excelSlice.actions;
2544
+ var excel_slice_default = excelSlice.reducer;
2545
+
2546
+ // src/store/reducers/form-slice/index.ts
2547
+ import { createSlice as createSlice4 } from "@reduxjs/toolkit";
2548
+ var initialState4 = {
2549
+ viewDataStore: {},
2550
+ isShowingModalDetail: false,
2551
+ isShowModalTranslate: false,
2552
+ formSubmitComponent: {},
2553
+ fieldTranslation: null,
2554
+ listSubject: {},
2555
+ dataUser: {}
2556
+ };
2557
+ var formSlice = createSlice4({
2558
+ name: "form",
2559
+ initialState: initialState4,
2560
+ reducers: {
2561
+ setViewDataStore: (state, action) => {
2562
+ state.viewDataStore = action.payload;
2563
+ },
2564
+ setIsShowingModalDetail: (state, action) => {
2565
+ state.isShowingModalDetail = action.payload;
2566
+ },
2567
+ setIsShowModalTranslate: (state, action) => {
2568
+ state.isShowModalTranslate = action.payload;
2569
+ },
2570
+ setFormSubmitComponent: (state, action) => {
2571
+ state.formSubmitComponent[action.payload.key] = action.payload.component;
2572
+ },
2573
+ setFieldTranslate: (state, action) => {
2574
+ state.fieldTranslation = action.payload;
2575
+ },
2576
+ setListSubject: (state, action) => {
2577
+ state.listSubject = action.payload;
2578
+ },
2579
+ setDataUser: (state, action) => {
2580
+ state.dataUser = action.payload;
2581
+ }
2582
+ }
2583
+ });
2584
+ var {
2585
+ setViewDataStore,
2586
+ setIsShowingModalDetail,
2587
+ setIsShowModalTranslate,
2588
+ setFormSubmitComponent,
2589
+ setFieldTranslate,
2590
+ setListSubject,
2591
+ setDataUser
2592
+ } = formSlice.actions;
2593
+ var form_slice_default = formSlice.reducer;
2594
+
2595
+ // src/store/reducers/header-slice/index.ts
2596
+ import { createSlice as createSlice5 } from "@reduxjs/toolkit";
2597
+ var headerSlice = createSlice5({
2598
+ name: "header",
2599
+ initialState: {
2600
+ value: { allowedCompanyIds: [] }
2601
+ },
2602
+ reducers: {
2603
+ setHeader: (state, action) => {
2604
+ state.value = __spreadValues(__spreadValues({}, state.value), action.payload);
2605
+ },
2606
+ setAllowedCompanyIds: (state, action) => {
2607
+ state.value.allowedCompanyIds = action.payload;
2608
+ }
2609
+ }
2610
+ });
2611
+ var { setAllowedCompanyIds, setHeader } = headerSlice.actions;
2612
+ var header_slice_default = headerSlice.reducer;
2613
+
2614
+ // src/store/reducers/list-slice/index.ts
2615
+ import { createSlice as createSlice6 } from "@reduxjs/toolkit";
2616
+ var initialState5 = {
2617
+ pageLimit: 10,
2618
+ fields: {},
2619
+ order: "",
2620
+ selectedRowKeys: [],
2621
+ selectedRadioKey: 0,
2622
+ indexRowTableModal: -2,
2623
+ isUpdateTableModal: false,
2624
+ footerGroupTable: {},
2625
+ transferDetail: null,
2626
+ page: 0,
2627
+ domainTable: []
2628
+ };
2629
+ var listSlice = createSlice6({
2630
+ name: "list",
2631
+ initialState: initialState5,
2632
+ reducers: {
2633
+ setPageLimit: (state, action) => {
2634
+ state.pageLimit = action.payload;
2635
+ },
2636
+ setFields: (state, action) => {
2637
+ state.fields = action.payload;
2638
+ },
2639
+ setOrder: (state, action) => {
2640
+ state.order = action.payload;
2641
+ },
2642
+ setSelectedRowKeys: (state, action) => {
2643
+ state.selectedRowKeys = action.payload;
2644
+ },
2645
+ setSelectedRadioKey: (state, action) => {
2646
+ state.selectedRadioKey = action.payload;
2647
+ },
2648
+ setIndexRowTableModal: (state, action) => {
2649
+ state.indexRowTableModal = action.payload;
2650
+ },
2651
+ setTransferDetail: (state, action) => {
2652
+ state.transferDetail = action.payload;
2653
+ },
2654
+ setIsUpdateTableModal: (state, action) => {
2655
+ state.isUpdateTableModal = action.payload;
2656
+ },
2657
+ setPage: (state, action) => {
2658
+ state.page = action.payload;
2659
+ },
2660
+ setDomainTable: (state, action) => {
2661
+ state.domainTable = action.payload;
2662
+ }
2663
+ }
2664
+ });
2665
+ var {
2666
+ setPageLimit,
2667
+ setFields,
2668
+ setOrder,
2669
+ setSelectedRowKeys,
2670
+ setIndexRowTableModal,
2671
+ setIsUpdateTableModal,
2672
+ setPage,
2673
+ setSelectedRadioKey,
2674
+ setTransferDetail,
2675
+ setDomainTable
2676
+ } = listSlice.actions;
2677
+ var list_slice_default = listSlice.reducer;
2678
+
2679
+ // src/store/reducers/login-slice/index.ts
2680
+ import { createSlice as createSlice7 } from "@reduxjs/toolkit";
2681
+ var initialState6 = {
2682
+ db: "",
2683
+ redirectTo: "/",
2684
+ forgotPasswordUrl: "/"
2685
+ };
2686
+ var loginSlice = createSlice7({
2687
+ name: "login",
2688
+ initialState: initialState6,
2689
+ reducers: {
2690
+ setDb: (state, action) => {
2691
+ state.db = action.payload;
2692
+ },
2693
+ setRedirectTo: (state, action) => {
2694
+ state.redirectTo = action.payload;
2695
+ },
2696
+ setForgotPasswordUrl: (state, action) => {
2697
+ state.forgotPasswordUrl = action.payload;
2698
+ }
2699
+ }
2700
+ });
2701
+ var { setDb, setRedirectTo, setForgotPasswordUrl } = loginSlice.actions;
2702
+ var login_slice_default = loginSlice.reducer;
2703
+
2704
+ // src/store/reducers/navbar-slice/index.ts
2705
+ import { createSlice as createSlice8 } from "@reduxjs/toolkit";
2706
+ var initialState7 = {
2707
+ menuFocus: {},
2708
+ menuAction: {},
2709
+ navbarWidth: 250,
2710
+ menuList: []
2711
+ };
2712
+ var navbarSlice = createSlice8({
2713
+ name: "navbar",
2714
+ initialState: initialState7,
2715
+ reducers: {
2716
+ setMenuFocus: (state, action) => {
2717
+ state.menuFocus = action.payload;
2718
+ },
2719
+ setMenuFocusAction: (state, action) => {
2720
+ state.menuAction = action.payload;
2721
+ },
2722
+ setNavbarWidth: (state, action) => {
2723
+ state.navbarWidth = action.payload;
2724
+ },
2725
+ setMenuList: (state, action) => {
2726
+ state.menuList = action.payload;
2727
+ }
2728
+ }
2729
+ });
2730
+ var { setMenuFocus, setMenuFocusAction, setNavbarWidth, setMenuList } = navbarSlice.actions;
2731
+ var navbar_slice_default = navbarSlice.reducer;
2732
+
2733
+ // src/store/reducers/profile-slice/index.ts
2734
+ import { createSlice as createSlice9 } from "@reduxjs/toolkit";
2735
+ var initialState8 = {
2736
+ profile: {}
2737
+ };
2738
+ var profileSlice = createSlice9({
2739
+ name: "profile",
2740
+ initialState: initialState8,
2741
+ reducers: {
2742
+ setProfile: (state, action) => {
2743
+ state.profile = action.payload;
2744
+ }
2745
+ }
2746
+ });
2747
+ var { setProfile } = profileSlice.actions;
2748
+ var profile_slice_default = profileSlice.reducer;
2749
+
2750
+ // src/store/reducers/search-slice/index.ts
2751
+ import { createSlice as createSlice10 } from "@reduxjs/toolkit";
2752
+ var initialState9 = {
2753
+ groupByDomain: null,
2754
+ searchBy: [],
2755
+ searchString: "",
2756
+ hoveredIndexSearchList: null,
2757
+ selectedTags: [],
2758
+ firstDomain: null,
2759
+ searchMap: {},
2760
+ filterBy: [],
2761
+ groupBy: []
2762
+ };
2763
+ var searchSlice = createSlice10({
2764
+ name: "search",
2765
+ initialState: initialState9,
2766
+ reducers: {
2767
+ setGroupByDomain: (state, action) => {
2768
+ state.groupByDomain = action.payload;
2769
+ },
2770
+ setSearchBy: (state, action) => {
2771
+ state.searchBy = action.payload;
2772
+ },
2773
+ setSearchString: (state, action) => {
2774
+ state.searchString = action.payload;
2775
+ },
2776
+ setHoveredIndexSearchList: (state, action) => {
2777
+ state.hoveredIndexSearchList = action.payload;
2778
+ },
2779
+ setSelectedTags: (state, action) => {
2780
+ state.selectedTags = action.payload;
2781
+ },
2782
+ setFirstDomain: (state, action) => {
2783
+ state.firstDomain = action.payload;
2784
+ },
2785
+ setFilterBy: (state, action) => {
2786
+ state.filterBy = action.payload;
2787
+ },
2788
+ setGroupBy: (state, action) => {
2789
+ state.groupBy = action.payload;
2790
+ },
2791
+ setSearchMap: (state, action) => {
2792
+ state.searchMap = action.payload;
2793
+ },
2794
+ updateSearchMap: (state, action) => {
2795
+ if (!state.searchMap[action.payload.key]) {
2796
+ state.searchMap[action.payload.key] = [];
2797
+ }
2798
+ state.searchMap[action.payload.key].push(action.payload.value);
2799
+ },
2800
+ removeKeyFromSearchMap: (state, action) => {
2801
+ const { key, item } = action.payload;
2802
+ const values = state.searchMap[key];
2803
+ if (!values) return;
2804
+ if (item) {
2805
+ const filtered = values.filter((value) => value.name !== item.name);
2806
+ if (filtered.length > 0) {
2807
+ state.searchMap[key] = filtered;
2808
+ } else {
2809
+ delete state.searchMap[key];
2810
+ }
2811
+ } else {
2812
+ delete state.searchMap[key];
2813
+ }
2814
+ },
2815
+ clearSearchMap: (state) => {
2816
+ state.searchMap = {};
2817
+ }
2818
+ }
2819
+ });
2820
+ var {
2821
+ setGroupByDomain,
2822
+ setSelectedTags,
2823
+ setSearchString,
2824
+ setHoveredIndexSearchList,
2825
+ setFirstDomain,
2826
+ setSearchBy,
2827
+ setFilterBy,
2828
+ setSearchMap,
2829
+ updateSearchMap,
2830
+ removeKeyFromSearchMap,
2831
+ setGroupBy,
2832
+ clearSearchMap
2833
+ } = searchSlice.actions;
2834
+ var search_slice_default = searchSlice.reducer;
2835
+
2836
+ // src/store/store.ts
2837
+ import { configureStore } from "@reduxjs/toolkit";
2838
+
2839
+ // node_modules/redux/dist/redux.mjs
2840
+ function formatProdErrorMessage(code) {
2841
+ return `Minified Redux error #${code}; visit https://redux.js.org/Errors?code=${code} for the full message or use the non-minified dev environment for full errors. `;
2842
+ }
2843
+ var randomString = () => Math.random().toString(36).substring(7).split("").join(".");
2844
+ var ActionTypes = {
2845
+ INIT: `@@redux/INIT${/* @__PURE__ */ randomString()}`,
2846
+ REPLACE: `@@redux/REPLACE${/* @__PURE__ */ randomString()}`,
2847
+ PROBE_UNKNOWN_ACTION: () => `@@redux/PROBE_UNKNOWN_ACTION${randomString()}`
2848
+ };
2849
+ var actionTypes_default = ActionTypes;
2850
+ function isPlainObject(obj) {
2851
+ if (typeof obj !== "object" || obj === null)
2852
+ return false;
2853
+ let proto = obj;
2854
+ while (Object.getPrototypeOf(proto) !== null) {
2855
+ proto = Object.getPrototypeOf(proto);
2856
+ }
2857
+ return Object.getPrototypeOf(obj) === proto || Object.getPrototypeOf(obj) === null;
2858
+ }
2859
+ function miniKindOf(val) {
2860
+ if (val === void 0)
2861
+ return "undefined";
2862
+ if (val === null)
2863
+ return "null";
2864
+ const type = typeof val;
2865
+ switch (type) {
2866
+ case "boolean":
2867
+ case "string":
2868
+ case "number":
2869
+ case "symbol":
2870
+ case "function": {
2871
+ return type;
2872
+ }
2873
+ }
2874
+ if (Array.isArray(val))
2875
+ return "array";
2876
+ if (isDate(val))
2877
+ return "date";
2878
+ if (isError(val))
2879
+ return "error";
2880
+ const constructorName = ctorName(val);
2881
+ switch (constructorName) {
2882
+ case "Symbol":
2883
+ case "Promise":
2884
+ case "WeakMap":
2885
+ case "WeakSet":
2886
+ case "Map":
2887
+ case "Set":
2888
+ return constructorName;
2889
+ }
2890
+ return Object.prototype.toString.call(val).slice(8, -1).toLowerCase().replace(/\s/g, "");
2891
+ }
2892
+ function ctorName(val) {
2893
+ return typeof val.constructor === "function" ? val.constructor.name : null;
2894
+ }
2895
+ function isError(val) {
2896
+ return val instanceof Error || typeof val.message === "string" && val.constructor && typeof val.constructor.stackTraceLimit === "number";
2897
+ }
2898
+ function isDate(val) {
2899
+ if (val instanceof Date)
2900
+ return true;
2901
+ return typeof val.toDateString === "function" && typeof val.getDate === "function" && typeof val.setDate === "function";
2902
+ }
2903
+ function kindOf(val) {
2904
+ let typeOfVal = typeof val;
2905
+ if (process.env.NODE_ENV !== "production") {
2906
+ typeOfVal = miniKindOf(val);
2907
+ }
2908
+ return typeOfVal;
2909
+ }
2910
+ function warning(message) {
2911
+ if (typeof console !== "undefined" && typeof console.error === "function") {
2912
+ console.error(message);
2913
+ }
2914
+ try {
2915
+ throw new Error(message);
2916
+ } catch (e) {
2917
+ }
2918
+ }
2919
+ function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
2920
+ const reducerKeys = Object.keys(reducers);
2921
+ const argumentName = action && action.type === actionTypes_default.INIT ? "preloadedState argument passed to createStore" : "previous state received by the reducer";
2922
+ if (reducerKeys.length === 0) {
2923
+ return "Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";
2924
+ }
2925
+ if (!isPlainObject(inputState)) {
2926
+ return `The ${argumentName} has unexpected type of "${kindOf(inputState)}". Expected argument to be an object with the following keys: "${reducerKeys.join('", "')}"`;
2927
+ }
2928
+ const unexpectedKeys = Object.keys(inputState).filter((key) => !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key]);
2929
+ unexpectedKeys.forEach((key) => {
2930
+ unexpectedKeyCache[key] = true;
2931
+ });
2932
+ if (action && action.type === actionTypes_default.REPLACE)
2933
+ return;
2934
+ if (unexpectedKeys.length > 0) {
2935
+ return `Unexpected ${unexpectedKeys.length > 1 ? "keys" : "key"} "${unexpectedKeys.join('", "')}" found in ${argumentName}. Expected to find one of the known reducer keys instead: "${reducerKeys.join('", "')}". Unexpected keys will be ignored.`;
2936
+ }
2937
+ }
2938
+ function assertReducerShape(reducers) {
2939
+ Object.keys(reducers).forEach((key) => {
2940
+ const reducer = reducers[key];
2941
+ const initialState10 = reducer(void 0, {
2942
+ type: actionTypes_default.INIT
2943
+ });
2944
+ if (typeof initialState10 === "undefined") {
2945
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(12) : `The slice reducer for key "${key}" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);
2946
+ }
2947
+ if (typeof reducer(void 0, {
2948
+ type: actionTypes_default.PROBE_UNKNOWN_ACTION()
2949
+ }) === "undefined") {
2950
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(13) : `The slice reducer for key "${key}" returned undefined when probed with a random type. Don't try to handle '${actionTypes_default.INIT}' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.`);
2951
+ }
2952
+ });
2953
+ }
2954
+ function combineReducers(reducers) {
2955
+ const reducerKeys = Object.keys(reducers);
2956
+ const finalReducers = {};
2957
+ for (let i = 0; i < reducerKeys.length; i++) {
2958
+ const key = reducerKeys[i];
2959
+ if (process.env.NODE_ENV !== "production") {
2960
+ if (typeof reducers[key] === "undefined") {
2961
+ warning(`No reducer provided for key "${key}"`);
2962
+ }
2963
+ }
2964
+ if (typeof reducers[key] === "function") {
2965
+ finalReducers[key] = reducers[key];
2966
+ }
2967
+ }
2968
+ const finalReducerKeys = Object.keys(finalReducers);
2969
+ let unexpectedKeyCache;
2970
+ if (process.env.NODE_ENV !== "production") {
2971
+ unexpectedKeyCache = {};
2972
+ }
2973
+ let shapeAssertionError;
2974
+ try {
2975
+ assertReducerShape(finalReducers);
2976
+ } catch (e) {
2977
+ shapeAssertionError = e;
2978
+ }
2979
+ return function combination(state = {}, action) {
2980
+ if (shapeAssertionError) {
2981
+ throw shapeAssertionError;
2982
+ }
2983
+ if (process.env.NODE_ENV !== "production") {
2984
+ const warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
2985
+ if (warningMessage) {
2986
+ warning(warningMessage);
2987
+ }
2988
+ }
2989
+ let hasChanged = false;
2990
+ const nextState = {};
2991
+ for (let i = 0; i < finalReducerKeys.length; i++) {
2992
+ const key = finalReducerKeys[i];
2993
+ const reducer = finalReducers[key];
2994
+ const previousStateForKey = state[key];
2995
+ const nextStateForKey = reducer(previousStateForKey, action);
2996
+ if (typeof nextStateForKey === "undefined") {
2997
+ const actionType = action && action.type;
2998
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(14) : `When called with an action of type ${actionType ? `"${String(actionType)}"` : "(unknown type)"}, the slice reducer for key "${key}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`);
2999
+ }
3000
+ nextState[key] = nextStateForKey;
3001
+ hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
3002
+ }
3003
+ hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
3004
+ return hasChanged ? nextState : state;
3005
+ };
3006
+ }
3007
+
3008
+ // src/store/store.ts
3009
+ var rootReducer = combineReducers({
3010
+ env: env_slice_default,
3011
+ header: header_slice_default,
3012
+ navbar: navbar_slice_default,
3013
+ list: list_slice_default,
3014
+ search: search_slice_default,
3015
+ form: form_slice_default,
3016
+ breadcrumbs: breadcrums_slice_default,
3017
+ login: login_slice_default,
3018
+ excel: excel_slice_default,
3019
+ profile: profile_slice_default
3020
+ });
3021
+ var envStore = configureStore({
3022
+ reducer: rootReducer,
3023
+ middleware: (getDefaultMiddleware) => getDefaultMiddleware({
3024
+ serializableCheck: false
3025
+ })
3026
+ });
3027
+
3028
+ // src/environment/EnvStore.ts
3029
+ var EnvStore = class {
3030
+ constructor(envStore2, localStorageUtils2, sessionStorageUtils2) {
3031
+ this.envStore = envStore2;
3032
+ this.localStorageUtils = localStorageUtils2;
3033
+ this.sessionStorageUtils = sessionStorageUtils2;
3034
+ this.setup();
3035
+ }
3036
+ setup() {
3037
+ const env2 = this.envStore.getState().env;
3038
+ this.baseUrl = env2 == null ? void 0 : env2.baseUrl;
3039
+ this.requests = env2 == null ? void 0 : env2.requests;
3040
+ this.context = env2 == null ? void 0 : env2.context;
3041
+ this.defaultCompany = env2 == null ? void 0 : env2.defaultCompany;
3042
+ this.config = env2 == null ? void 0 : env2.config;
3043
+ this.companies = (env2 == null ? void 0 : env2.companies) || [];
3044
+ this.user = env2 == null ? void 0 : env2.user;
3045
+ this.db = env2 == null ? void 0 : env2.db;
3046
+ this.refreshTokenEndpoint = env2 == null ? void 0 : env2.refreshTokenEndpoint;
3047
+ }
3048
+ setupEnv(envConfig) {
3049
+ const dispatch = this.envStore.dispatch;
3050
+ const env2 = __spreadProps(__spreadValues({}, envConfig), {
3051
+ localStorageUtils: this.localStorageUtils,
3052
+ sessionStorageUtils: this.sessionStorageUtils
3053
+ });
3054
+ const requests = axiosClient.init(env2);
3055
+ dispatch(setEnv(__spreadProps(__spreadValues({}, env2), { requests })));
3056
+ this.setup();
3057
+ }
3058
+ setUid(uid) {
3059
+ const dispatch = this.envStore.dispatch;
3060
+ dispatch(setUid(uid));
3061
+ this.setup();
3062
+ }
3063
+ setLang(lang) {
3064
+ const dispatch = this.envStore.dispatch;
3065
+ dispatch(setLang(lang));
3066
+ this.setup();
3067
+ }
3068
+ setAllowCompanies(allowCompanies) {
3069
+ const dispatch = this.envStore.dispatch;
3070
+ dispatch(setAllowCompanies(allowCompanies));
3071
+ this.setup();
3072
+ }
3073
+ setCompanies(companies) {
3074
+ const dispatch = this.envStore.dispatch;
3075
+ dispatch(setCompanies(companies));
3076
+ this.setup();
3077
+ }
3078
+ setDefaultCompany(company) {
3079
+ const dispatch = this.envStore.dispatch;
3080
+ dispatch(setDefaultCompany(company));
3081
+ this.setup();
3082
+ }
3083
+ setUserInfo(userInfo) {
3084
+ const dispatch = this.envStore.dispatch;
3085
+ dispatch(setUser(userInfo));
3086
+ this.setup();
3087
+ }
3088
+ };
3089
+ var env = null;
3090
+ function getEnv() {
3091
+ if (!env)
3092
+ env = new EnvStore(envStore, localStorageUtils(), sessionStorageUtils());
3093
+ return env;
3094
+ }
3095
+
3096
+ // src/services/action-service/index.ts
3097
+ var ActionService = {
3098
+ // Load Action
3099
+ loadAction(_0) {
3100
+ return __async(this, arguments, function* ({
3101
+ idAction,
3102
+ context
3103
+ }) {
3104
+ const env2 = getEnv();
3105
+ const jsonData = {
3106
+ action_id: idAction,
3107
+ with_context: __spreadValues({}, context)
3108
+ };
3109
+ return env2.requests.post(`${"/load_action" /* LOAD_ACTION */}`, jsonData, {
3110
+ headers: {
3111
+ "Content-Type": "application/json"
3112
+ }
3113
+ });
3114
+ });
3115
+ },
3116
+ // Call Button
3117
+ callButton(_0) {
3118
+ return __async(this, arguments, function* ({
3119
+ model,
3120
+ ids = [],
3121
+ context,
3122
+ method
3123
+ }) {
3124
+ try {
3125
+ const env2 = getEnv();
3126
+ const jsonData = {
3127
+ model,
3128
+ method,
3129
+ ids,
3130
+ with_context: context
3131
+ };
3132
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3133
+ headers: {
3134
+ "Content-Type": "application/json"
3135
+ }
3136
+ });
3137
+ } catch (error) {
3138
+ console.error("Error when calling button action:", error);
3139
+ throw error;
3140
+ }
3141
+ });
3142
+ },
3143
+ // remove Row
3144
+ removeRows(_0) {
3145
+ return __async(this, arguments, function* ({
3146
+ model,
3147
+ ids,
3148
+ context
3149
+ }) {
3150
+ const env2 = getEnv();
3151
+ const jsonData = {
3152
+ model,
3153
+ method: "unlink",
3154
+ ids,
3155
+ with_context: context
3156
+ };
3157
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3158
+ headers: {
3159
+ "Content-Type": "application/json"
3160
+ }
3161
+ });
3162
+ });
3163
+ },
3164
+ // Duplicate Model
3165
+ duplicateRecord(_0) {
3166
+ return __async(this, arguments, function* ({
3167
+ model,
3168
+ id,
3169
+ context
3170
+ }) {
3171
+ const env2 = getEnv();
3172
+ const jsonData = {
3173
+ model,
3174
+ method: "copy",
3175
+ ids: id,
3176
+ with_context: context
3177
+ };
3178
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3179
+ headers: {
3180
+ "Content-Type": "application/json"
3181
+ }
3182
+ });
3183
+ });
3184
+ },
3185
+ // Get Print Report
3186
+ getPrintReportName(_0) {
3187
+ return __async(this, arguments, function* ({ id }) {
3188
+ const env2 = getEnv();
3189
+ const jsonData = {
3190
+ model: "ir.actions.report",
3191
+ method: "web_read",
3192
+ id,
3193
+ kwargs: {
3194
+ specification: {
3195
+ report_name: {}
3196
+ }
3197
+ }
3198
+ };
3199
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3200
+ headers: {
3201
+ "Content-Type": "application/json"
3202
+ }
3203
+ });
3204
+ });
3205
+ },
3206
+ //Save Print Invoice
3207
+ print(_0) {
3208
+ return __async(this, arguments, function* ({ id, report, db }) {
3209
+ const env2 = getEnv();
3210
+ const jsonData = {
3211
+ report,
3212
+ id,
3213
+ type: "pdf",
3214
+ file_response: true,
3215
+ db
3216
+ };
3217
+ const queryString = toQueryString(jsonData);
3218
+ const urlWithParams = `${"/report" /* REPORT_PATH */}?${queryString}`;
3219
+ return env2.requests.get(urlWithParams, {
3220
+ headers: {
3221
+ "Content-Type": "application/json"
3222
+ },
3223
+ responseType: "arraybuffer"
3224
+ });
3225
+ });
3226
+ },
3227
+ //Run Action
3228
+ runAction(_0) {
3229
+ return __async(this, arguments, function* ({
3230
+ idAction,
3231
+ context
3232
+ }) {
3233
+ const env2 = getEnv();
3234
+ const jsonData = {
3235
+ action_id: idAction,
3236
+ with_context: __spreadValues({}, context)
3237
+ // context: {
3238
+ // lang: 'en_US',
3239
+ // tz: 'Asia/Saigon',
3240
+ // uid: 2,
3241
+ // allowed_company_ids: [1],
3242
+ // active_id: Array.isArray(idDetail) ? idDetail[0] : idDetail,
3243
+ // active_ids: Array.isArray(idDetail) ? [...idDetail] : idDetail,
3244
+ // active_model: model,
3245
+ // },
3246
+ };
3247
+ return env2.requests.post(`${"/run_action" /* RUN_ACTION_PATH */}`, jsonData, {
3248
+ headers: {
3249
+ "Content-Type": "application/json"
3250
+ }
3251
+ });
3252
+ });
3253
+ }
3254
+ };
3255
+ var action_service_default = ActionService;
3256
+
3257
+ // src/services/auth-service/index.ts
3258
+ var AuthService = {
3259
+ login(body) {
3260
+ return __async(this, null, function* () {
3261
+ var _a, _b, _c, _d;
3262
+ const env2 = getEnv();
3263
+ const payload = Object.fromEntries(
3264
+ Object.entries({
3265
+ username: body.email,
3266
+ password: body.password,
3267
+ grant_type: ((_a = env2 == null ? void 0 : env2.config) == null ? void 0 : _a.grantType) || "",
3268
+ client_id: ((_b = env2 == null ? void 0 : env2.config) == null ? void 0 : _b.clientId) || "",
3269
+ client_secret: ((_c = env2 == null ? void 0 : env2.config) == null ? void 0 : _c.clientSecret) || ""
3270
+ }).filter(([_, value]) => !!value)
3271
+ );
3272
+ const encodedData = new URLSearchParams(payload).toString();
3273
+ return (_d = env2 == null ? void 0 : env2.requests) == null ? void 0 : _d.post(body.path, encodedData, {
3274
+ headers: {
3275
+ "Content-Type": "application/x-www-form-urlencoded"
3276
+ }
3277
+ });
3278
+ });
3279
+ },
3280
+ forgotPassword(email) {
3281
+ return __async(this, null, function* () {
3282
+ var _a;
3283
+ const env2 = getEnv();
3284
+ const bodyData = {
3285
+ login: email,
3286
+ url: `${window.location.origin}/reset-password`
3287
+ };
3288
+ return (_a = env2 == null ? void 0 : env2.requests) == null ? void 0 : _a.post("/reset_password" /* RESET_PASSWORD_PATH */, bodyData, {
3289
+ headers: {
3290
+ "Content-Type": "application/json"
3291
+ }
3292
+ });
3293
+ });
3294
+ },
3295
+ forgotPasswordSSO(_0) {
3296
+ return __async(this, arguments, function* ({
3297
+ email,
3298
+ with_context,
3299
+ method
3300
+ }) {
3301
+ var _a;
3302
+ const env2 = getEnv();
3303
+ const body = {
3304
+ method,
3305
+ kwargs: {
3306
+ vals: {
3307
+ email
3308
+ }
3309
+ },
3310
+ with_context
3311
+ };
3312
+ return (_a = env2 == null ? void 0 : env2.requests) == null ? void 0 : _a.post("/call" /* CALL_PATH */, body, {
3313
+ headers: {
3314
+ "Content-Type": "application/json"
3315
+ }
3316
+ });
3317
+ });
3318
+ },
3319
+ resetPassword(data, token) {
3320
+ return __async(this, null, function* () {
3321
+ var _a;
3322
+ const env2 = getEnv();
3323
+ const bodyData = {
3324
+ token,
3325
+ password: data.password,
3326
+ new_password: data.confirmPassword
3327
+ };
3328
+ return (_a = env2 == null ? void 0 : env2.requests) == null ? void 0 : _a.post("/change_password" /* CHANGE_PASSWORD_PATH */, bodyData, {
3329
+ headers: {
3330
+ "Content-Type": "application/json"
3331
+ }
3332
+ });
3333
+ });
3334
+ },
3335
+ resetPasswordSSO(_0) {
3336
+ return __async(this, arguments, function* ({
3337
+ method,
3338
+ password,
3339
+ with_context
3340
+ }) {
3341
+ var _a;
3342
+ const env2 = getEnv();
3343
+ const bodyData = {
3344
+ method,
3345
+ kwargs: {
3346
+ vals: {
3347
+ password
3348
+ }
3349
+ },
3350
+ with_context
3351
+ };
3352
+ return (_a = env2 == null ? void 0 : env2.requests) == null ? void 0 : _a.post("/call" /* CALL_PATH */, bodyData, {
3353
+ headers: {
3354
+ "Content-Type": "application/json"
3355
+ }
3356
+ });
3357
+ });
3358
+ },
3359
+ updatePassword(data, token) {
3360
+ return __async(this, null, function* () {
3361
+ var _a;
3362
+ const env2 = getEnv();
3363
+ const bodyData = {
3364
+ token,
3365
+ old_password: data.oldPassword,
3366
+ new_password: data.newPassword
3367
+ };
3368
+ return (_a = env2 == null ? void 0 : env2.requests) == null ? void 0 : _a.post("/change_password_parent" /* UPDATE_PASSWORD_PATH */, bodyData, {
3369
+ headers: {
3370
+ "Content-Type": "application/json"
3371
+ }
3372
+ });
3373
+ });
3374
+ },
3375
+ isValidToken(token) {
3376
+ return __async(this, null, function* () {
3377
+ var _a;
3378
+ const env2 = getEnv();
3379
+ const bodyData = {
3380
+ token
3381
+ };
3382
+ return (_a = env2 == null ? void 0 : env2.requests) == null ? void 0 : _a.post("/check_token" /* TOKEN */, bodyData, {
3383
+ headers: {
3384
+ "Content-Type": "application/json"
3385
+ }
3386
+ });
3387
+ });
3388
+ },
3389
+ loginSocial(_0) {
3390
+ return __async(this, arguments, function* ({
3391
+ db,
3392
+ state,
3393
+ access_token
3394
+ }) {
3395
+ var _a;
3396
+ const env2 = getEnv();
3397
+ return (_a = env2 == null ? void 0 : env2.requests) == null ? void 0 : _a.post(
3398
+ "/token/generate" /* GENTOKEN_SOCIAL */,
3399
+ { state, access_token },
3400
+ {
3401
+ headers: {
3402
+ "Content-Type": "application/json"
3403
+ }
3404
+ }
3405
+ );
3406
+ });
3407
+ },
3408
+ getProviders(db) {
3409
+ return __async(this, null, function* () {
3410
+ var _a;
3411
+ const env2 = getEnv();
3412
+ return (_a = env2 == null ? void 0 : env2.requests) == null ? void 0 : _a.get("/oauth/providers", { params: { db } });
3413
+ });
3414
+ },
3415
+ getAccessByCode(code) {
3416
+ return __async(this, null, function* () {
3417
+ var _a, _b, _c, _d;
3418
+ const env2 = getEnv();
3419
+ const data = new URLSearchParams();
3420
+ data.append("code", code);
3421
+ data.append("grant_type", "authorization_code");
3422
+ data.append("client_id", ((_a = env2 == null ? void 0 : env2.config) == null ? void 0 : _a.clientId) || "");
3423
+ data.append("redirect_uri", ((_b = env2 == null ? void 0 : env2.config) == null ? void 0 : _b.redirectUri) || "");
3424
+ return (_d = env2 == null ? void 0 : env2.requests) == null ? void 0 : _d.post(
3425
+ `${(_c = env2 == null ? void 0 : env2.baseUrl) == null ? void 0 : _c.replace("/mms/", "/id/")}/${"/token" /* TOKEN_BY_CODE */}`,
3426
+ data,
3427
+ {
3428
+ headers: {
3429
+ "Content-Type": "application/x-www-form-urlencoded"
3430
+ }
3431
+ }
3432
+ );
3433
+ });
3434
+ },
3435
+ logout(data) {
3436
+ return __async(this, null, function* () {
3437
+ var _a;
3438
+ const env2 = getEnv();
3439
+ console.log(data);
3440
+ return (_a = env2 == null ? void 0 : env2.requests) == null ? void 0 : _a.post(
3441
+ "/logout" /* LOGOUT */,
3442
+ {},
3443
+ {
3444
+ headers: {
3445
+ "Content-Type": "application/json"
3446
+ },
3447
+ withCredentials: true,
3448
+ useRefreshToken: true
3449
+ }
3450
+ );
3451
+ });
3452
+ }
3453
+ };
3454
+ var auth_service_default = AuthService;
3455
+
3456
+ // src/services/company-service/index.ts
3457
+ var CompanyService = {
3458
+ getCurrentCompany() {
3459
+ return __async(this, null, function* () {
3460
+ const env2 = getEnv();
3461
+ return yield env2.requests.get("/company" /* COMPANY_PATH */, {
3462
+ headers: {
3463
+ "Content-Type": "application/json"
3464
+ }
3465
+ });
3466
+ });
3467
+ },
3468
+ getInfoCompany(id) {
3469
+ return __async(this, null, function* () {
3470
+ var _a;
3471
+ const env2 = getEnv();
3472
+ const jsonData = {
3473
+ ids: [id],
3474
+ model: "res.company" /* COMPANY */,
3475
+ method: "web_read" /* WEB_READ */,
3476
+ kwargs: {
3477
+ specification: {
3478
+ primary_color: {},
3479
+ secondary_color: {},
3480
+ logo: {},
3481
+ display_name: {},
3482
+ secondary_logo: {}
3483
+ }
3484
+ }
3485
+ };
3486
+ return yield (_a = env2 == null ? void 0 : env2.requests) == null ? void 0 : _a.post("/call" /* CALL_PATH */, jsonData, {
3487
+ headers: {
3488
+ "Content-Type": "application/json"
3489
+ }
3490
+ });
3491
+ });
3492
+ }
3493
+ };
3494
+ var company_service_default = CompanyService;
3495
+
3496
+ // src/services/excel-service/index.ts
3497
+ var ExcelService = {
3498
+ uploadFile(_0) {
3499
+ return __async(this, arguments, function* ({ formData }) {
3500
+ const env2 = getEnv();
3501
+ return env2.requests.post(`${"/upload/file" /* UPLOAD_FILE_PATH */}`, formData, {
3502
+ headers: {
3503
+ "Content-Type": "multipart/form-data"
3504
+ }
3505
+ });
3506
+ });
3507
+ },
3508
+ uploadIdFile(_0) {
3509
+ return __async(this, arguments, function* ({ formData }) {
3510
+ const env2 = getEnv();
3511
+ return env2.requests.post(`${"/upload/file" /* UPLOAD_FILE_PATH */}`, formData, {
3512
+ headers: {
3513
+ "Content-Type": "multipart/form-data"
3514
+ }
3515
+ });
3516
+ });
3517
+ },
3518
+ parsePreview(_0) {
3519
+ return __async(this, arguments, function* ({
3520
+ id,
3521
+ selectedSheet,
3522
+ isHeader,
3523
+ context
3524
+ }) {
3525
+ const env2 = getEnv();
3526
+ const jsonData = {
3527
+ model: "base_import.import" /* BASE_IMPORT */,
3528
+ method: "parse_preview",
3529
+ ids: [id],
3530
+ kwargs: {
3531
+ options: {
3532
+ import_skip_records: [],
3533
+ import_set_empty_fields: [],
3534
+ fallback_values: {},
3535
+ name_create_enabled_fields: {},
3536
+ encoding: "",
3537
+ separator: "",
3538
+ quoting: '"',
3539
+ date_format: "",
3540
+ datetime_format: "",
3541
+ float_thousand_separator: ",",
3542
+ float_decimal_separator: ".",
3543
+ advanced: true,
3544
+ has_headers: isHeader,
3545
+ keep_matches: false,
3546
+ limit: 2e3,
3547
+ sheets: [],
3548
+ sheet: selectedSheet,
3549
+ skip: 0,
3550
+ tracking_disable: true
3551
+ }
3552
+ },
3553
+ with_context: context
3554
+ };
3555
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3556
+ headers: {
3557
+ "Content-Type": "multipart/form-data"
3558
+ }
3559
+ });
3560
+ });
3561
+ },
3562
+ executeImport(_0) {
3563
+ return __async(this, arguments, function* ({
3564
+ columns,
3565
+ fields,
3566
+ idFile,
3567
+ options,
3568
+ dryrun,
3569
+ context
3570
+ }) {
3571
+ const env2 = getEnv();
3572
+ const jsonData = {
3573
+ model: "base_import.import" /* BASE_IMPORT */,
3574
+ method: "execute_import",
3575
+ ids: [idFile],
3576
+ kwargs: {
3577
+ fields,
3578
+ columns,
3579
+ options,
3580
+ dryrun
3581
+ },
3582
+ with_context: context
3583
+ };
3584
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3585
+ headers: {
3586
+ "Content-Type": "multipart/form-data"
3587
+ }
3588
+ });
3589
+ });
3590
+ },
3591
+ getFileExcel(_0) {
3592
+ return __async(this, arguments, function* ({ model }) {
3593
+ const env2 = getEnv();
3594
+ const jsonData = {
3595
+ model,
3596
+ method: "get_import_templates" /* GET_IMPORT */,
3597
+ args: []
3598
+ };
3599
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData);
3600
+ });
3601
+ },
3602
+ getFieldExport(_0) {
3603
+ return __async(this, arguments, function* ({
3604
+ ids,
3605
+ model,
3606
+ isShow,
3607
+ parentField,
3608
+ fieldType,
3609
+ parentName,
3610
+ prefix,
3611
+ name,
3612
+ context,
3613
+ importCompat
3614
+ }) {
3615
+ const env2 = getEnv();
3616
+ const jsonData = {
3617
+ model,
3618
+ import_compat: importCompat,
3619
+ domain: [["id", "in", ids]],
3620
+ with_context: context
3621
+ };
3622
+ if (isShow) {
3623
+ jsonData.parent_field = parentField;
3624
+ jsonData.parent_field_type = fieldType;
3625
+ jsonData.parent_name = parentName;
3626
+ jsonData.name = name;
3627
+ jsonData.prefix = prefix;
3628
+ jsonData.exclude = [null];
3629
+ }
3630
+ return env2.requests.post("/export/get_fields", jsonData);
3631
+ });
3632
+ },
3633
+ exportExcel(_0) {
3634
+ return __async(this, arguments, function* ({
3635
+ model,
3636
+ domain,
3637
+ ids,
3638
+ fields,
3639
+ type,
3640
+ importCompat,
3641
+ context,
3642
+ groupby
3643
+ }) {
3644
+ const env2 = getEnv();
3645
+ const jsonData = {
3646
+ model,
3647
+ domain,
3648
+ ids,
3649
+ import_compat: importCompat,
3650
+ fields,
3651
+ with_context: context,
3652
+ groupby: groupby != null ? groupby : []
3653
+ };
3654
+ return env2.requests.post_excel(`/export/${type}`, jsonData);
3655
+ });
3656
+ }
3657
+ };
3658
+ var excel_service_default = ExcelService;
3659
+
3660
+ // src/services/form-service/index.ts
3661
+ var FormService = {
3662
+ getComment(_0) {
3663
+ return __async(this, arguments, function* ({ data }) {
3664
+ try {
3665
+ const env2 = getEnv();
3666
+ const jsonData = {
3667
+ thread_id: data.thread_id,
3668
+ thread_model: data.thread_model,
3669
+ limit: 100,
3670
+ with_context: {
3671
+ lang: data.lang
3672
+ }
3673
+ };
3674
+ return env2.requests.post("/chatter/thread/messages" /* GET_MESSAGE */, jsonData, {
3675
+ headers: {
3676
+ "Content-Type": "application/json"
3677
+ }
3678
+ });
3679
+ } catch (error) {
3680
+ console.error("Error when sending message:", error);
3681
+ throw error;
3682
+ }
3683
+ });
3684
+ },
3685
+ sentComment(_0) {
3686
+ return __async(this, arguments, function* ({ data }) {
3687
+ try {
3688
+ const env2 = getEnv();
3689
+ const jsonData = {
3690
+ context: {
3691
+ tz: "Asia/Saigon",
3692
+ uid: 2,
3693
+ allowed_company_ids: [1],
3694
+ mail_post_autofollow: false,
3695
+ temporary_id: 142183.01
3696
+ },
3697
+ post_data: {
3698
+ body: data.message,
3699
+ message_type: "comment",
3700
+ attachment_ids: data.attachment_ids,
3701
+ attachment_tokens: [],
3702
+ subtype_xmlid: data.subtype
3703
+ },
3704
+ thread_id: Number(data.thread_id),
3705
+ thread_model: data.thread_model
3706
+ };
3707
+ return env2.requests.post("/chatter/message/post" /* SENT_MESSAGE */, jsonData, {
3708
+ headers: {
3709
+ "Content-Type": "application/json"
3710
+ }
3711
+ });
3712
+ } catch (error) {
3713
+ console.error("Error when sent message:", error);
3714
+ throw error;
3715
+ }
3716
+ });
3717
+ },
3718
+ deleteComment(_0) {
3719
+ return __async(this, arguments, function* ({ data }) {
3720
+ try {
3721
+ const env2 = getEnv();
3722
+ const jsonData = {
3723
+ attachment_ids: [],
3724
+ attachment_tokens: [],
3725
+ body: "",
3726
+ message_id: data.message_id
3727
+ };
3728
+ return env2.requests.post("/chatter/message/update_content" /* DELETE_MESSAGE */, jsonData, {
3729
+ headers: {
3730
+ "Content-Type": "application/json"
3731
+ }
3732
+ });
3733
+ } catch (error) {
3734
+ console.error("Error when sent message:", error);
3735
+ throw error;
3736
+ }
3737
+ });
3738
+ },
3739
+ getImage(_0) {
3740
+ return __async(this, arguments, function* ({ data }) {
3741
+ try {
3742
+ const env2 = getEnv();
3743
+ return env2.requests.get(
3744
+ `${"/web/image" /* IMAGE_PATH */}?filename=${data.filename}&unique=${data.checksum}&width=1920&height=300`,
3745
+ {
3746
+ headers: {
3747
+ "Content-Type": "application/json"
3748
+ }
3749
+ }
3750
+ );
3751
+ } catch (error) {
3752
+ console.error("Error when sent message:", error);
3753
+ throw error;
3754
+ }
3755
+ });
3756
+ },
3757
+ uploadImage(_0) {
3758
+ return __async(this, arguments, function* ({ data }) {
3759
+ try {
3760
+ const env2 = getEnv();
3761
+ return env2.requests.post("/mail/attachment/upload" /* UPLOAD_IMAGE */, data, {
3762
+ headers: {
3763
+ "Content-Type": "multipart/form-data"
3764
+ }
3765
+ });
3766
+ } catch (error) {
3767
+ console.error("Error when sent message:", error);
3768
+ throw error;
3769
+ }
3770
+ });
3771
+ },
3772
+ getFormView(_0) {
3773
+ return __async(this, arguments, function* ({ data }) {
3774
+ try {
3775
+ const env2 = getEnv();
3776
+ const jsonData = {
3777
+ model: data.model,
3778
+ method: "get_formview_action",
3779
+ ids: data.id ? [data.id] : [],
3780
+ with_context: data.context
3781
+ };
3782
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3783
+ headers: {
3784
+ "Content-Type": "application/json"
3785
+ }
3786
+ });
3787
+ } catch (error) {
3788
+ console.error("Error when fetching form view:", error);
3789
+ throw error;
3790
+ }
3791
+ });
3792
+ },
3793
+ changeStatus(_0) {
3794
+ return __async(this, arguments, function* ({ data }) {
3795
+ const env2 = getEnv();
3796
+ const vals = {
3797
+ [data.name]: data.stage_id
3798
+ };
3799
+ const jsonData = {
3800
+ model: data.model,
3801
+ method: "web_save",
3802
+ with_context: {
3803
+ lang: data.lang,
3804
+ allowed_company_ids: [1],
3805
+ uid: 2,
3806
+ search_default_my_ticket: true,
3807
+ search_default_is_open: true
3808
+ },
3809
+ ids: [data.id],
3810
+ kwargs: {
3811
+ vals,
3812
+ specification: {}
3813
+ }
3814
+ };
3815
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3816
+ headers: {
3817
+ "Content-Type": "application/json"
3818
+ }
3819
+ });
3820
+ });
3821
+ }
3822
+ };
3823
+ var form_service_default = FormService;
3824
+
3825
+ // src/services/kanban-service/index.ts
3826
+ var KanbanServices = {
3827
+ getGroups(_0) {
3828
+ return __async(this, arguments, function* ({
3829
+ model,
3830
+ width_context
3831
+ }) {
3832
+ const env2 = getEnv();
3833
+ const jsonDataView = {
3834
+ model,
3835
+ method: "web_read_group",
3836
+ kwargs: {
3837
+ domain: [["stage_id.fold", "=", false]],
3838
+ fields: ["color:sum"],
3839
+ groupby: ["stage_id"]
3840
+ },
3841
+ width_context
3842
+ };
3843
+ return env2.requests.post("/call" /* CALL_PATH */, jsonDataView, {
3844
+ headers: {
3845
+ "Content-Type": "application/json"
3846
+ }
3847
+ });
3848
+ });
3849
+ },
3850
+ getProgressBar(_0) {
3851
+ return __async(this, arguments, function* ({
3852
+ field,
3853
+ color,
3854
+ model,
3855
+ width_context
3856
+ }) {
3857
+ const env2 = getEnv();
3858
+ const jsonDataView = {
3859
+ model,
3860
+ method: "read_progress_bar",
3861
+ kwargs: {
3862
+ domain: [],
3863
+ group_by: "stage_id",
3864
+ progress_bar: {
3865
+ colors: color,
3866
+ field
3867
+ }
3868
+ },
3869
+ width_context
3870
+ };
3871
+ return env2.requests.post("/call" /* CALL_PATH */, jsonDataView, {
3872
+ headers: {
3873
+ "Content-Type": "application/json"
3874
+ }
3875
+ });
3876
+ });
3877
+ }
3878
+ };
3879
+ var kanban_service_default = KanbanServices;
3880
+
3881
+ // src/services/model-service/index.ts
3882
+ var OBJECT_POSITION = 2;
3883
+ var ModelService = {
3884
+ getListMyBankAccount(_0) {
3885
+ return __async(this, arguments, function* ({
3886
+ domain,
3887
+ spectification,
3888
+ model
3889
+ }) {
3890
+ const env2 = getEnv();
3891
+ const jsonData = {
3892
+ model,
3893
+ method: "web_search_read",
3894
+ kwargs: {
3895
+ specification: spectification,
3896
+ domain,
3897
+ limit: 100,
3898
+ offset: 0
3899
+ }
3900
+ };
3901
+ return env2 == null ? void 0 : env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3902
+ headers: {
3903
+ "Content-Type": "application/json"
3904
+ }
3905
+ });
3906
+ });
3907
+ },
3908
+ getCurrency() {
3909
+ return __async(this, null, function* () {
3910
+ const env2 = getEnv();
3911
+ const jsonData = {
3912
+ model: "res.currency",
3913
+ method: "web_search_read",
3914
+ kwargs: {
3915
+ specification: {
3916
+ icon_url: {},
3917
+ name: {}
3918
+ },
3919
+ domain: [["active", "=", true]],
3920
+ limit: 100,
3921
+ offset: 0
3922
+ }
3923
+ };
3924
+ return env2 == null ? void 0 : env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3925
+ headers: {
3926
+ "Content-Type": "application/json"
3927
+ }
3928
+ });
3929
+ });
3930
+ },
3931
+ getConversionRate() {
3932
+ return __async(this, null, function* () {
3933
+ const env2 = getEnv();
3934
+ const jsonData = {
3935
+ model: "res.currency",
3936
+ method: "web_search_read",
3937
+ kwargs: {
3938
+ specification: {
3939
+ name: {},
3940
+ icon_url: {},
3941
+ rate_ids: {
3942
+ fields: {
3943
+ company_rate: {},
3944
+ sell: {}
3945
+ }
3946
+ }
3947
+ },
3948
+ domain: [["active", "=", true]],
3949
+ limit: 100,
3950
+ offset: 0
3951
+ }
3952
+ };
3953
+ return env2 == null ? void 0 : env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3954
+ headers: {
3955
+ "Content-Type": "application/json"
3956
+ }
3957
+ });
3958
+ });
3959
+ },
3960
+ getAll(_0) {
3961
+ return __async(this, arguments, function* ({ data }) {
3962
+ const env2 = getEnv();
3963
+ const jsonReadGroup = data.type == "calendar" ? { fields: data == null ? void 0 : data.fields } : data.fields && data.fields.length > 0 && data.groupby && data.groupby.length > 0 && data.groupby[0] ? {
3964
+ fields: data.fields,
3965
+ groupby: data.groupby
3966
+ } : {
3967
+ count_limit: 10001,
3968
+ order: data.sort,
3969
+ specification: data.specification
3970
+ };
3971
+ const jsonData = {
3972
+ model: String(data.model),
3973
+ method: data.type == "calendar" ? "search_read" : jsonReadGroup.fields && jsonReadGroup.groupby ? "web_read_group" : "web_search_read",
3974
+ ids: data.ids,
3975
+ with_context: data.context,
3976
+ kwargs: __spreadValues({
3977
+ domain: data.domain,
3978
+ limit: data.limit,
3979
+ offset: data.offset
3980
+ }, jsonReadGroup)
3981
+ };
3982
+ return env2 == null ? void 0 : env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3983
+ headers: {
3984
+ "Content-Type": "application/json"
3985
+ }
3986
+ });
3987
+ });
3988
+ },
3989
+ getListCalendar(_0) {
3990
+ return __async(this, arguments, function* ({ data }) {
3991
+ const env2 = getEnv();
3992
+ const jsonReadGroup = data.type == "calendar" ? data == null ? void 0 : data.fields : data.fields && data.fields.length > 0 && data.groupby && data.groupby.length > 0 && data.groupby[0] ? {
3993
+ fields: data.fields,
3994
+ groupby: data.groupby
3995
+ } : {
3996
+ count_limit: 10001,
3997
+ order: data.sort,
3998
+ specification: data.specification
3999
+ };
4000
+ const jsonData = {
4001
+ model: String(data.model),
4002
+ method: data.type == "calendar" ? "search_read" : jsonReadGroup.fields && jsonReadGroup.groupby ? "web_read_group" : "web_search_read",
4003
+ ids: data.ids,
4004
+ with_context: data.context,
4005
+ kwargs: __spreadValues({
4006
+ domain: data.domain,
4007
+ limit: data.limit,
4008
+ offset: data.offset,
4009
+ fields: data.fields
4010
+ }, jsonReadGroup)
4011
+ };
4012
+ return env2 == null ? void 0 : env2.requests.post("/call" /* CALL_PATH */, jsonData, {
4013
+ headers: {
4014
+ "Content-Type": "application/json"
4015
+ }
4016
+ });
4017
+ });
4018
+ },
4019
+ getList(_0) {
4020
+ return __async(this, arguments, function* ({
4021
+ model,
4022
+ ids = [],
4023
+ specification = {},
4024
+ domain = [],
4025
+ offset,
4026
+ order,
4027
+ context = {},
4028
+ limit = 10
4029
+ }) {
4030
+ var _a;
4031
+ const env2 = getEnv();
4032
+ const jsonData = {
4033
+ model,
4034
+ method: "web_search_read" /* WEB_SEARCH_READ */,
4035
+ ids,
4036
+ with_context: context,
4037
+ kwargs: {
4038
+ specification,
4039
+ domain,
4040
+ limit,
4041
+ offset,
4042
+ order
4043
+ }
4044
+ };
4045
+ return (_a = env2 == null ? void 0 : env2.requests) == null ? void 0 : _a.post("/call" /* CALL_PATH */, jsonData, {
4046
+ headers: {
4047
+ "Content-Type": "application/json"
4048
+ }
4049
+ });
4050
+ });
4051
+ },
4052
+ getDetail(_0) {
4053
+ return __async(this, arguments, function* ({
4054
+ ids = [],
4055
+ model,
4056
+ specification,
4057
+ context
4058
+ }) {
4059
+ var _a;
4060
+ const env2 = getEnv();
4061
+ const jsonData = {
4062
+ model,
4063
+ method: "web_read" /* WEB_READ */,
4064
+ ids,
4065
+ with_context: context,
4066
+ kwargs: {
4067
+ specification
4068
+ }
4069
+ };
4070
+ return (_a = env2 == null ? void 0 : env2.requests) == null ? void 0 : _a.post("/call" /* CALL_PATH */, jsonData, {
4071
+ headers: {
4072
+ "Content-Type": "application/json"
4073
+ }
4074
+ });
4075
+ });
4076
+ },
4077
+ save(_0) {
4078
+ return __async(this, arguments, function* ({
4079
+ model,
4080
+ ids = [],
4081
+ data = {},
4082
+ specification = {},
4083
+ context = {},
4084
+ path
4085
+ }) {
4086
+ var _a;
4087
+ const env2 = getEnv();
4088
+ const jsonData = {
4089
+ model,
4090
+ method: "web_save" /* WEB_SAVE */,
4091
+ with_context: context,
4092
+ ids,
4093
+ kwargs: {
4094
+ vals: data,
4095
+ specification
4096
+ }
4097
+ };
4098
+ return (_a = env2 == null ? void 0 : env2.requests) == null ? void 0 : _a.post(path != null ? path : "/call" /* CALL_PATH */, jsonData, {
4099
+ headers: {
4100
+ "Content-Type": "application/json"
4101
+ }
4102
+ });
4103
+ });
4104
+ },
4105
+ delete(_0) {
4106
+ return __async(this, arguments, function* ({ ids = [], model }) {
4107
+ var _a;
4108
+ const env2 = getEnv();
4109
+ const jsonData = {
4110
+ model,
4111
+ method: "unlink" /* UNLINK */,
4112
+ ids
4113
+ };
4114
+ return (_a = env2 == null ? void 0 : env2.requests) == null ? void 0 : _a.post("/call" /* CALL_PATH */, jsonData, {
4115
+ headers: {
4116
+ "Content-Type": "application/json"
4117
+ }
4118
+ });
4119
+ });
4120
+ },
4121
+ onChange(_0) {
4122
+ return __async(this, arguments, function* ({
4123
+ ids = [],
4124
+ model,
4125
+ object,
4126
+ specification,
4127
+ context,
4128
+ fieldChange
4129
+ }) {
4130
+ var _a;
4131
+ const env2 = getEnv();
4132
+ const jsonData = {
4133
+ model,
4134
+ method: "onchange" /* ONCHANGE */,
4135
+ ids,
4136
+ with_context: context,
4137
+ args: [
4138
+ object ? object : {},
4139
+ fieldChange ? fieldChange : [],
4140
+ specification
4141
+ ]
4142
+ };
4143
+ return (_a = env2 == null ? void 0 : env2.requests) == null ? void 0 : _a.post("/call" /* CALL_PATH */, jsonData, {
4144
+ headers: {
4145
+ "Content-Type": "application/json"
4146
+ }
4147
+ });
4148
+ });
4149
+ },
4150
+ getListFieldsOnchange(_0) {
4151
+ return __async(this, arguments, function* ({ model }) {
4152
+ var _a;
4153
+ const env2 = getEnv();
4154
+ const jsonData = {
4155
+ model,
4156
+ method: "get_fields_onchange" /* GET_ONCHANGE_FIELDS */
4157
+ };
4158
+ return (_a = env2 == null ? void 0 : env2.requests) == null ? void 0 : _a.post("/call" /* CALL_PATH */, jsonData, {
4159
+ headers: {
4160
+ "Content-Type": "application/json"
4161
+ }
4162
+ });
4163
+ });
4164
+ },
4165
+ parseORMOdoo(data) {
4166
+ for (const key in data) {
4167
+ if (key === "display_name") {
4168
+ delete data[key];
4169
+ }
4170
+ if (!data[key] && data[key] !== 0) {
4171
+ data[key] = false;
4172
+ } else if (data[key] === "Draft") {
4173
+ data[key] = "/";
4174
+ }
4175
+ }
4176
+ return __spreadValues({}, data);
4177
+ },
4178
+ toDataJS(data, viewData, model) {
4179
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
4180
+ for (const key in data) {
4181
+ if (data[key] === false) {
4182
+ if (viewData && model) {
4183
+ if (((_c = (_b = (_a = viewData == null ? void 0 : viewData.models) == null ? void 0 : _a[model]) == null ? void 0 : _b[key]) == null ? void 0 : _c.type) !== "boolean" /* BOOLEAN */) {
4184
+ data[key] = null;
4185
+ }
4186
+ } else {
4187
+ data[key] = null;
4188
+ }
4189
+ } else if (data[key] === "/") {
4190
+ data[key] = "Draft";
4191
+ } else if (data[key] !== false) {
4192
+ if (model !== void 0) {
4193
+ if (((_f = (_e = (_d = viewData == null ? void 0 : viewData.models) == null ? void 0 : _d[model]) == null ? void 0 : _e[key]) == null ? void 0 : _f.type) === "one2many" /* ONE2MANY */ || ((_i = (_h = (_g = viewData == null ? void 0 : viewData.models) == null ? void 0 : _g[model]) == null ? void 0 : _h[key]) == null ? void 0 : _i.type) === "many2many" /* MANY2MANY */) {
4194
+ data[key] = (_k = (_j = data[key]) != null ? _j : data[key] = []) == null ? void 0 : _k.map((item) => {
4195
+ var _a2, _b2, _c2, _d2;
4196
+ const relation = (_c2 = (_b2 = (_a2 = viewData == null ? void 0 : viewData.models) == null ? void 0 : _a2[model]) == null ? void 0 : _b2[key]) == null ? void 0 : _c2.relation;
4197
+ if (relation !== void 0) {
4198
+ if ((_d2 = viewData == null ? void 0 : viewData.models) == null ? void 0 : _d2[relation]) {
4199
+ if ((item == null ? void 0 : item.length) >= 3) {
4200
+ return ModelService.toDataJS(
4201
+ item[OBJECT_POSITION],
4202
+ viewData,
4203
+ relation
4204
+ );
4205
+ } else {
4206
+ return ModelService.toDataJS(item, viewData, relation);
4207
+ }
4208
+ } else {
4209
+ if ((item == null ? void 0 : item.length) >= 3) {
4210
+ return item[OBJECT_POSITION];
4211
+ } else {
4212
+ return item;
4213
+ }
4214
+ }
4215
+ }
4216
+ });
4217
+ }
4218
+ }
4219
+ }
4220
+ }
4221
+ return __spreadValues({}, data);
4222
+ }
4223
+ };
4224
+ var model_service_default = ModelService;
4225
+
4226
+ // src/services/user-service/index.ts
4227
+ var UserService = {
4228
+ getProfile(path) {
4229
+ return __async(this, null, function* () {
4230
+ const env2 = getEnv();
4231
+ return env2.requests.get(path != null ? path : "/userinfo" /* PROFILE_PATH */, {
4232
+ headers: {
4233
+ "Content-Type": "application/x-www-form-urlencoded"
4234
+ }
4235
+ });
4236
+ });
4237
+ },
4238
+ getUser(_0) {
4239
+ return __async(this, arguments, function* ({ context, id }) {
4240
+ const env2 = getEnv();
4241
+ const jsonData = {
4242
+ model: "res.users",
4243
+ method: "web_read",
4244
+ ids: [id],
4245
+ with_context: context,
4246
+ kwargs: {
4247
+ specification: {
4248
+ display_name: {},
4249
+ image_1920: {},
4250
+ name: {},
4251
+ login: {},
4252
+ email: {},
4253
+ password: {},
4254
+ visible_group_id: {
4255
+ fields: {
4256
+ id: {},
4257
+ display_name: {}
4258
+ }
4259
+ },
4260
+ company_id: {
4261
+ fields: {
4262
+ id: {},
4263
+ display_name: {}
4264
+ }
4265
+ }
4266
+ }
4267
+ }
4268
+ };
4269
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
4270
+ headers: {
4271
+ "Content-Type": "application/json"
4272
+ }
4273
+ });
4274
+ });
4275
+ },
4276
+ switchUserLocale: (_0) => __async(null, [_0], function* ({ id, values }) {
4277
+ var _a;
4278
+ const env2 = getEnv();
4279
+ const jsonData = {
4280
+ model: "res.users",
4281
+ domain: [["id", "=", id]],
4282
+ values
4283
+ };
4284
+ return env2 == null ? void 0 : env2.requests.post((_a = UriConstants) == null ? void 0 : _a.CREATE_UPDATE_PATH, jsonData, {
4285
+ headers: {
4286
+ "Content-Type": "application/json"
4287
+ }
4288
+ });
4289
+ })
4290
+ };
4291
+ var user_service_default = UserService;
4292
+
4293
+ // src/services/view-service/index.ts
4294
+ var ViewService = {
4295
+ getView(_0) {
4296
+ return __async(this, arguments, function* ({
4297
+ model,
4298
+ views,
4299
+ context = {},
4300
+ options = {},
4301
+ aid
4302
+ }) {
4303
+ var _a;
4304
+ const env2 = getEnv();
4305
+ const defaultOptions = {
4306
+ load_filters: true,
4307
+ toolbar: true,
4308
+ action_id: aid
4309
+ };
4310
+ const jsonDataView = {
4311
+ model,
4312
+ method: "get_fields_view_v2" /* GET_FIELD_VIEW */,
4313
+ kwargs: {
4314
+ views,
4315
+ options: __spreadValues(__spreadValues({}, options), defaultOptions)
4316
+ },
4317
+ with_context: context
4318
+ };
4319
+ return (_a = env2 == null ? void 0 : env2.requests) == null ? void 0 : _a.post("/call" /* CALL_PATH */, jsonDataView, {
4320
+ headers: {
4321
+ "Content-Type": "application/json"
4322
+ }
4323
+ });
4324
+ });
4325
+ },
4326
+ getMenu(context) {
4327
+ return __async(this, null, function* () {
4328
+ var _a;
4329
+ const env2 = getEnv();
4330
+ const jsonData = {
4331
+ model: "ir.ui.menu" /* MENU */,
4332
+ method: "web_search_read" /* WEB_SEARCH_READ */,
4333
+ ids: [],
4334
+ with_context: context,
4335
+ kwargs: {
4336
+ specification: {
4337
+ active: {},
4338
+ name: {},
4339
+ is_display: {},
4340
+ sequence: {},
4341
+ complete_name: {},
4342
+ action: {
4343
+ fields: {
4344
+ display_name: {},
4345
+ type: {},
4346
+ binding_view_types: {}
4347
+ // res_model: {},
4348
+ }
4349
+ },
4350
+ url_icon: {},
4351
+ web_icon: {},
4352
+ web_icon_data: {},
4353
+ groups_id: {
4354
+ fields: {
4355
+ full_name: {}
4356
+ },
4357
+ limit: 40,
4358
+ order: ""
4359
+ },
4360
+ display_name: {},
4361
+ child_id: {
4362
+ fields: {
4363
+ active: {},
4364
+ name: {},
4365
+ is_display: {},
4366
+ sequence: {},
4367
+ complete_name: {},
4368
+ action: {
4369
+ fields: {
4370
+ display_name: {},
4371
+ type: {},
4372
+ binding_view_types: {}
4373
+ // res_model: {},
4374
+ }
4375
+ },
4376
+ url_icon: {},
4377
+ web_icon: {},
4378
+ web_icon_data: {},
4379
+ groups_id: {
4380
+ fields: {
4381
+ full_name: {}
4382
+ },
4383
+ limit: 40,
4384
+ order: ""
4385
+ },
4386
+ display_name: {},
4387
+ child_id: {
4388
+ fields: {
4389
+ active: {},
4390
+ name: {},
4391
+ is_display: {},
4392
+ sequence: {},
4393
+ complete_name: {},
4394
+ action: {
4395
+ fields: {
4396
+ display_name: {},
4397
+ type: {},
4398
+ binding_view_types: {}
4399
+ // res_model: {},
4400
+ }
4401
+ },
4402
+ url_icon: {},
4403
+ web_icon: {},
4404
+ web_icon_data: {},
4405
+ groups_id: {
4406
+ fields: {
4407
+ full_name: {}
4408
+ },
4409
+ limit: 40,
4410
+ order: ""
4411
+ },
4412
+ display_name: {},
4413
+ child_id: {
4414
+ fields: {
4415
+ active: {},
4416
+ name: {},
4417
+ is_display: {},
4418
+ sequence: {},
4419
+ complete_name: {},
4420
+ action: {
4421
+ fields: {
4422
+ display_name: {},
4423
+ type: {},
4424
+ binding_view_types: {}
4425
+ // res_model: {},
4426
+ }
4427
+ },
4428
+ url_icon: {},
4429
+ web_icon: {},
4430
+ web_icon_data: {},
4431
+ groups_id: {
4432
+ fields: {
4433
+ full_name: {}
4434
+ },
4435
+ limit: 40,
4436
+ order: ""
4437
+ },
4438
+ display_name: {},
4439
+ child_id: {
4440
+ fields: {},
4441
+ limit: 40,
4442
+ order: ""
4443
+ }
4444
+ },
4445
+ limit: 40,
4446
+ order: ""
4447
+ }
4448
+ },
4449
+ limit: 40,
4450
+ order: ""
4451
+ }
4452
+ },
4453
+ limit: 40,
4454
+ order: ""
4455
+ }
4456
+ },
4457
+ domain: [
4458
+ "&",
4459
+ ["is_display", "=", true],
4460
+ "&",
4461
+ ["active", "=", true],
4462
+ ["parent_id", "=", false]
4463
+ ]
4464
+ }
4465
+ };
4466
+ return (_a = env2 == null ? void 0 : env2.requests) == null ? void 0 : _a.post("/call" /* CALL_PATH */, jsonData, {
4467
+ headers: {
4468
+ "Content-Type": "application/json"
4469
+ }
4470
+ });
4471
+ });
4472
+ },
4473
+ getActionDetail(aid, context) {
4474
+ return __async(this, null, function* () {
4475
+ var _a;
4476
+ const env2 = getEnv();
4477
+ const jsonData = {
4478
+ model: "ir.actions.act_window" /* WINDOW_ACTION */,
4479
+ method: "web_read" /* WEB_READ */,
4480
+ ids: [aid],
4481
+ with_context: context,
4482
+ kwargs: {
4483
+ specification: {
4484
+ id: {},
4485
+ name: {},
4486
+ res_model: {},
4487
+ views: {},
4488
+ view_mode: {},
4489
+ mobile_view_mode: {},
4490
+ domain: {},
4491
+ context: {},
4492
+ groups_id: {},
4493
+ search_view_id: {}
4494
+ }
4495
+ }
4496
+ };
4497
+ return (_a = env2 == null ? void 0 : env2.requests) == null ? void 0 : _a.post("/call" /* CALL_PATH */, jsonData, {
4498
+ headers: {
4499
+ "Content-Type": "application/json"
4500
+ }
4501
+ });
4502
+ });
4503
+ },
4504
+ getResequence(_0) {
4505
+ return __async(this, arguments, function* ({
4506
+ model,
4507
+ ids,
4508
+ context,
4509
+ offset
4510
+ }) {
4511
+ const env2 = getEnv();
4512
+ const jsonData = __spreadValues({
4513
+ model,
4514
+ with_context: context,
4515
+ ids,
4516
+ field: "sequence"
4517
+ }, offset > 0 ? { offset } : {});
4518
+ return env2 == null ? void 0 : env2.requests.post("/web/dataset/resequence", jsonData, {
4519
+ headers: {
4520
+ "Content-Type": "application/json"
4521
+ }
4522
+ });
4523
+ });
4524
+ },
4525
+ getSelectionItem(_0) {
4526
+ return __async(this, arguments, function* ({ data }) {
4527
+ var _a;
4528
+ const env2 = getEnv();
4529
+ const jsonData = {
4530
+ model: data.model,
4531
+ ids: [],
4532
+ method: "get_data_select",
4533
+ with_context: data.context,
4534
+ kwargs: {
4535
+ count_limit: 10001,
4536
+ domain: data.domain ? data.domain : [],
4537
+ offset: 0,
4538
+ order: "",
4539
+ specification: (_a = data == null ? void 0 : data.specification) != null ? _a : {
4540
+ id: {},
4541
+ name: {},
4542
+ display_name: {}
4543
+ }
4544
+ }
4545
+ };
4546
+ return env2 == null ? void 0 : env2.requests.post("/call" /* CALL_PATH */, jsonData, {
4547
+ headers: {
4548
+ "Content-Type": "application/json"
4549
+ }
4550
+ });
4551
+ });
4552
+ },
4553
+ loadMessages() {
4554
+ return __async(this, null, function* () {
4555
+ const env2 = getEnv();
4556
+ return env2.requests.post(
4557
+ "/load_message_failures" /* LOAD_MESSAGE */,
4558
+ {},
4559
+ {
4560
+ headers: {
4561
+ "Content-Type": "application/json"
4562
+ }
4563
+ }
4564
+ );
4565
+ });
4566
+ },
4567
+ getVersion() {
4568
+ return __async(this, null, function* () {
4569
+ var _a;
4570
+ const env2 = getEnv();
4571
+ console.log("env?.requests", env2, env2 == null ? void 0 : env2.requests);
4572
+ return (_a = env2 == null ? void 0 : env2.requests) == null ? void 0 : _a.get("", {
4573
+ headers: {
4574
+ "Content-Type": "application/json"
4575
+ }
4576
+ });
4577
+ });
4578
+ },
4579
+ get2FAMethods(_0) {
4580
+ return __async(this, arguments, function* ({
4581
+ method,
4582
+ with_context
4583
+ }) {
4584
+ const env2 = getEnv();
4585
+ const jsonData = {
4586
+ method,
4587
+ with_context
4588
+ };
4589
+ return env2 == null ? void 0 : env2.requests.post("/call" /* CALL_PATH */, jsonData, {
4590
+ headers: {
4591
+ "Content-Type": "application/json"
4592
+ }
4593
+ });
4594
+ });
4595
+ },
4596
+ verify2FA(_0) {
4597
+ return __async(this, arguments, function* ({
4598
+ method,
4599
+ with_context,
4600
+ code,
4601
+ device,
4602
+ location
4603
+ }) {
4604
+ const env2 = getEnv();
4605
+ const jsonData = {
4606
+ method,
4607
+ kwargs: {
4608
+ vals: {
4609
+ code,
4610
+ device,
4611
+ location
4612
+ }
4613
+ },
4614
+ with_context
4615
+ };
4616
+ return env2 == null ? void 0 : env2.requests.post("/call" /* CALL_PATH */, jsonData, {
4617
+ headers: {
4618
+ "Content-Type": "application/json"
4619
+ },
4620
+ withCredentials: true
4621
+ });
4622
+ });
4623
+ },
4624
+ signInSSO(_0) {
4625
+ return __async(this, arguments, function* ({
4626
+ redirect_uri,
4627
+ state,
4628
+ client_id,
4629
+ response_type,
4630
+ path
4631
+ }) {
4632
+ const env2 = getEnv();
4633
+ const params = new URLSearchParams({
4634
+ response_type,
4635
+ client_id,
4636
+ redirect_uri,
4637
+ state
4638
+ });
4639
+ const url = `${path}?${params.toString()}`;
4640
+ return env2 == null ? void 0 : env2.requests.get(url, {
4641
+ headers: {
4642
+ "Content-Type": "application/json"
4643
+ },
4644
+ withCredentials: true
4645
+ });
4646
+ });
4647
+ },
4648
+ grantAccess(_0) {
4649
+ return __async(this, arguments, function* ({
4650
+ redirect_uri,
4651
+ state,
4652
+ client_id,
4653
+ scopes
4654
+ }) {
4655
+ const env2 = getEnv();
4656
+ const jsonData = {
4657
+ redirect_uri,
4658
+ state,
4659
+ client_id,
4660
+ scopes
4661
+ };
4662
+ return env2 == null ? void 0 : env2.requests.post("/grant-access" /* GRANT_ACCESS */, jsonData, {
4663
+ headers: {
4664
+ "Content-Type": "application/json"
4665
+ },
4666
+ withCredentials: true
4667
+ });
4668
+ });
4669
+ },
4670
+ getFieldsViewSecurity(_0) {
4671
+ return __async(this, arguments, function* ({
4672
+ method,
4673
+ token,
4674
+ views
4675
+ }) {
4676
+ const env2 = getEnv();
4677
+ const jsonData = {
4678
+ method,
4679
+ kwargs: {
4680
+ views
4681
+ },
4682
+ with_context: {
4683
+ token
4684
+ }
4685
+ };
4686
+ return env2 == null ? void 0 : env2.requests.post("/call" /* CALL_PATH */, jsonData, {
4687
+ headers: {
4688
+ "Content-Type": "application/json"
4689
+ }
4690
+ });
4691
+ });
4692
+ },
4693
+ settingsWebRead2fa(_0) {
4694
+ return __async(this, arguments, function* ({
4695
+ method,
4696
+ model,
4697
+ kwargs,
4698
+ token
4699
+ }) {
4700
+ const env2 = getEnv();
4701
+ const jsonData = {
4702
+ method,
4703
+ model,
4704
+ kwargs,
4705
+ with_context: {
4706
+ token
4707
+ }
4708
+ };
4709
+ return env2 == null ? void 0 : env2.requests.post("/call" /* CALL_PATH */, jsonData, {
4710
+ headers: {
4711
+ "Content-Type": "application/json"
4712
+ }
4713
+ });
4714
+ });
4715
+ },
4716
+ requestSetupTotp(_0) {
4717
+ return __async(this, arguments, function* ({ method, token }) {
4718
+ const env2 = getEnv();
4719
+ const jsonData = {
4720
+ method,
4721
+ with_context: {
4722
+ token
4723
+ }
4724
+ };
4725
+ return env2 == null ? void 0 : env2.requests.post("/call" /* CALL_PATH */, jsonData, {
4726
+ headers: {
4727
+ "Content-Type": "application/json"
4728
+ }
4729
+ });
4730
+ });
4731
+ },
4732
+ verifyTotp(_0) {
4733
+ return __async(this, arguments, function* ({
4734
+ method,
4735
+ action_token,
4736
+ code
4737
+ }) {
4738
+ const env2 = getEnv();
4739
+ const jsonData = {
4740
+ method,
4741
+ kwargs: {
4742
+ vals: {
4743
+ code
4744
+ }
4745
+ },
4746
+ with_context: {
4747
+ action_token
4748
+ }
4749
+ };
4750
+ return env2 == null ? void 0 : env2.requests.post("/call" /* CALL_PATH */, jsonData, {
4751
+ headers: {
4752
+ "Content-Type": "application/json"
4753
+ }
4754
+ });
4755
+ });
4756
+ },
4757
+ removeTotpSetUp(_0) {
4758
+ return __async(this, arguments, function* ({ method, token }) {
4759
+ const env2 = getEnv();
4760
+ const jsonData = {
4761
+ method,
4762
+ with_context: {
4763
+ token
4764
+ }
4765
+ };
4766
+ return env2 == null ? void 0 : env2.requests.post("/call" /* CALL_PATH */, jsonData, {
4767
+ headers: {
4768
+ "Content-Type": "application/json"
4769
+ }
4770
+ });
4771
+ });
4772
+ }
4773
+ };
4774
+ var view_service_default = ViewService;
4775
+ export {
4776
+ action_service_default as ActionService,
4777
+ auth_service_default as AuthService,
4778
+ company_service_default as CompanyService,
4779
+ excel_service_default as ExcelService,
4780
+ form_service_default as FormService,
4781
+ kanban_service_default as KanbanService,
4782
+ model_service_default as ModelService,
4783
+ user_service_default as UserService,
4784
+ view_service_default as ViewService
4785
+ };