@fctc/interface-logic 1.7.1 → 1.7.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.
package/dist/services.mjs CHANGED
@@ -28,619 +28,6 @@ var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
28
28
  return UriConstants2;
29
29
  })(UriConstants || {});
30
30
 
31
- // src/store/store.ts
32
- import { configureStore } from "@reduxjs/toolkit";
33
-
34
- // node_modules/redux/dist/redux.mjs
35
- function formatProdErrorMessage(code) {
36
- 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. `;
37
- }
38
- var randomString = () => Math.random().toString(36).substring(7).split("").join(".");
39
- var ActionTypes = {
40
- INIT: `@@redux/INIT${/* @__PURE__ */ randomString()}`,
41
- REPLACE: `@@redux/REPLACE${/* @__PURE__ */ randomString()}`,
42
- PROBE_UNKNOWN_ACTION: () => `@@redux/PROBE_UNKNOWN_ACTION${randomString()}`
43
- };
44
- var actionTypes_default = ActionTypes;
45
- function isPlainObject(obj) {
46
- if (typeof obj !== "object" || obj === null)
47
- return false;
48
- let proto = obj;
49
- while (Object.getPrototypeOf(proto) !== null) {
50
- proto = Object.getPrototypeOf(proto);
51
- }
52
- return Object.getPrototypeOf(obj) === proto || Object.getPrototypeOf(obj) === null;
53
- }
54
- function miniKindOf(val) {
55
- if (val === void 0)
56
- return "undefined";
57
- if (val === null)
58
- return "null";
59
- const type = typeof val;
60
- switch (type) {
61
- case "boolean":
62
- case "string":
63
- case "number":
64
- case "symbol":
65
- case "function": {
66
- return type;
67
- }
68
- }
69
- if (Array.isArray(val))
70
- return "array";
71
- if (isDate(val))
72
- return "date";
73
- if (isError(val))
74
- return "error";
75
- const constructorName = ctorName(val);
76
- switch (constructorName) {
77
- case "Symbol":
78
- case "Promise":
79
- case "WeakMap":
80
- case "WeakSet":
81
- case "Map":
82
- case "Set":
83
- return constructorName;
84
- }
85
- return Object.prototype.toString.call(val).slice(8, -1).toLowerCase().replace(/\s/g, "");
86
- }
87
- function ctorName(val) {
88
- return typeof val.constructor === "function" ? val.constructor.name : null;
89
- }
90
- function isError(val) {
91
- return val instanceof Error || typeof val.message === "string" && val.constructor && typeof val.constructor.stackTraceLimit === "number";
92
- }
93
- function isDate(val) {
94
- if (val instanceof Date)
95
- return true;
96
- return typeof val.toDateString === "function" && typeof val.getDate === "function" && typeof val.setDate === "function";
97
- }
98
- function kindOf(val) {
99
- let typeOfVal = typeof val;
100
- if (process.env.NODE_ENV !== "production") {
101
- typeOfVal = miniKindOf(val);
102
- }
103
- return typeOfVal;
104
- }
105
- function warning(message) {
106
- if (typeof console !== "undefined" && typeof console.error === "function") {
107
- console.error(message);
108
- }
109
- try {
110
- throw new Error(message);
111
- } catch (e) {
112
- }
113
- }
114
- function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
115
- const reducerKeys = Object.keys(reducers);
116
- const argumentName = action && action.type === actionTypes_default.INIT ? "preloadedState argument passed to createStore" : "previous state received by the reducer";
117
- if (reducerKeys.length === 0) {
118
- return "Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";
119
- }
120
- if (!isPlainObject(inputState)) {
121
- return `The ${argumentName} has unexpected type of "${kindOf(inputState)}". Expected argument to be an object with the following keys: "${reducerKeys.join('", "')}"`;
122
- }
123
- const unexpectedKeys = Object.keys(inputState).filter((key) => !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key]);
124
- unexpectedKeys.forEach((key) => {
125
- unexpectedKeyCache[key] = true;
126
- });
127
- if (action && action.type === actionTypes_default.REPLACE)
128
- return;
129
- if (unexpectedKeys.length > 0) {
130
- 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.`;
131
- }
132
- }
133
- function assertReducerShape(reducers) {
134
- Object.keys(reducers).forEach((key) => {
135
- const reducer = reducers[key];
136
- const initialState10 = reducer(void 0, {
137
- type: actionTypes_default.INIT
138
- });
139
- if (typeof initialState10 === "undefined") {
140
- 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.`);
141
- }
142
- if (typeof reducer(void 0, {
143
- type: actionTypes_default.PROBE_UNKNOWN_ACTION()
144
- }) === "undefined") {
145
- 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.`);
146
- }
147
- });
148
- }
149
- function combineReducers(reducers) {
150
- const reducerKeys = Object.keys(reducers);
151
- const finalReducers = {};
152
- for (let i = 0; i < reducerKeys.length; i++) {
153
- const key = reducerKeys[i];
154
- if (process.env.NODE_ENV !== "production") {
155
- if (typeof reducers[key] === "undefined") {
156
- warning(`No reducer provided for key "${key}"`);
157
- }
158
- }
159
- if (typeof reducers[key] === "function") {
160
- finalReducers[key] = reducers[key];
161
- }
162
- }
163
- const finalReducerKeys = Object.keys(finalReducers);
164
- let unexpectedKeyCache;
165
- if (process.env.NODE_ENV !== "production") {
166
- unexpectedKeyCache = {};
167
- }
168
- let shapeAssertionError;
169
- try {
170
- assertReducerShape(finalReducers);
171
- } catch (e) {
172
- shapeAssertionError = e;
173
- }
174
- return function combination(state = {}, action) {
175
- if (shapeAssertionError) {
176
- throw shapeAssertionError;
177
- }
178
- if (process.env.NODE_ENV !== "production") {
179
- const warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
180
- if (warningMessage) {
181
- warning(warningMessage);
182
- }
183
- }
184
- let hasChanged = false;
185
- const nextState = {};
186
- for (let i = 0; i < finalReducerKeys.length; i++) {
187
- const key = finalReducerKeys[i];
188
- const reducer = finalReducers[key];
189
- const previousStateForKey = state[key];
190
- const nextStateForKey = reducer(previousStateForKey, action);
191
- if (typeof nextStateForKey === "undefined") {
192
- const actionType = action && action.type;
193
- 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.`);
194
- }
195
- nextState[key] = nextStateForKey;
196
- hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
197
- }
198
- hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
199
- return hasChanged ? nextState : state;
200
- };
201
- }
202
-
203
- // src/store/reducers/breadcrums-slice/index.ts
204
- import { createSlice } from "@reduxjs/toolkit";
205
- var initialState = {
206
- breadCrumbs: []
207
- };
208
- var breadcrumbsSlice = createSlice({
209
- name: "breadcrumbs",
210
- initialState,
211
- reducers: {
212
- setBreadCrumbs: (state, action) => {
213
- state.breadCrumbs = [...state.breadCrumbs, action.payload];
214
- }
215
- }
216
- });
217
- var { setBreadCrumbs } = breadcrumbsSlice.actions;
218
- var breadcrums_slice_default = breadcrumbsSlice.reducer;
219
-
220
- // src/store/reducers/env-slice/index.ts
221
- import { createSlice as createSlice2 } from "@reduxjs/toolkit";
222
- var initialState2 = {
223
- baseUrl: "",
224
- companies: [],
225
- user: {},
226
- db: "",
227
- refreshTokenEndpoint: "",
228
- config: null,
229
- envFile: null,
230
- requests: null,
231
- defaultCompany: {
232
- id: null,
233
- logo: "",
234
- secondary_color: "",
235
- primary_color: ""
236
- },
237
- context: {
238
- uid: null,
239
- allowed_company_ids: [],
240
- lang: "vi_VN",
241
- tz: "Asia/Saigon"
242
- }
243
- };
244
- var envSlice = createSlice2({
245
- name: "env",
246
- initialState: initialState2,
247
- reducers: {
248
- setEnv: (state, action) => {
249
- Object.assign(state, action.payload);
250
- },
251
- setUid: (state, action) => {
252
- state.context.uid = action.payload;
253
- },
254
- setAllowCompanies: (state, action) => {
255
- state.context.allowed_company_ids = action.payload;
256
- },
257
- setCompanies: (state, action) => {
258
- state.companies = action.payload;
259
- },
260
- setDefaultCompany: (state, action) => {
261
- state.defaultCompany = action.payload;
262
- },
263
- setLang: (state, action) => {
264
- state.context.lang = action.payload;
265
- },
266
- setUser: (state, action) => {
267
- state.user = action.payload;
268
- },
269
- setConfig: (state, action) => {
270
- state.config = action.payload;
271
- },
272
- setEnvFile: (state, action) => {
273
- state.envFile = action.payload;
274
- }
275
- }
276
- });
277
- var {
278
- setEnv,
279
- setUid,
280
- setLang,
281
- setAllowCompanies,
282
- setCompanies,
283
- setDefaultCompany,
284
- setUser,
285
- setConfig,
286
- setEnvFile
287
- } = envSlice.actions;
288
- var env_slice_default = envSlice.reducer;
289
-
290
- // src/store/reducers/excel-slice/index.ts
291
- import { createSlice as createSlice3 } from "@reduxjs/toolkit";
292
- var initialState3 = {
293
- dataParse: null,
294
- idFile: null,
295
- isFileLoaded: false,
296
- loadingImport: false,
297
- selectedFile: null,
298
- errorData: null
299
- };
300
- var excelSlice = createSlice3({
301
- name: "excel",
302
- initialState: initialState3,
303
- reducers: {
304
- setDataParse: (state, action) => {
305
- state.dataParse = action.payload;
306
- },
307
- setIdFile: (state, action) => {
308
- state.idFile = action.payload;
309
- },
310
- setIsFileLoaded: (state, action) => {
311
- state.isFileLoaded = action.payload;
312
- },
313
- setLoadingImport: (state, action) => {
314
- state.loadingImport = action.payload;
315
- },
316
- setSelectedFile: (state, action) => {
317
- state.selectedFile = action.payload;
318
- },
319
- setErrorData: (state, action) => {
320
- state.errorData = action.payload;
321
- }
322
- }
323
- });
324
- var {
325
- setDataParse,
326
- setIdFile,
327
- setIsFileLoaded,
328
- setLoadingImport,
329
- setSelectedFile,
330
- setErrorData
331
- } = excelSlice.actions;
332
- var excel_slice_default = excelSlice.reducer;
333
-
334
- // src/store/reducers/form-slice/index.ts
335
- import { createSlice as createSlice4 } from "@reduxjs/toolkit";
336
- var initialState4 = {
337
- viewDataStore: {},
338
- isShowingModalDetail: false,
339
- isShowModalTranslate: false,
340
- formSubmitComponent: {},
341
- fieldTranslation: null,
342
- listSubject: {},
343
- dataUser: {}
344
- };
345
- var formSlice = createSlice4({
346
- name: "form",
347
- initialState: initialState4,
348
- reducers: {
349
- setViewDataStore: (state, action) => {
350
- state.viewDataStore = action.payload;
351
- },
352
- setIsShowingModalDetail: (state, action) => {
353
- state.isShowingModalDetail = action.payload;
354
- },
355
- setIsShowModalTranslate: (state, action) => {
356
- state.isShowModalTranslate = action.payload;
357
- },
358
- setFormSubmitComponent: (state, action) => {
359
- state.formSubmitComponent[action.payload.key] = action.payload.component;
360
- },
361
- setFieldTranslate: (state, action) => {
362
- state.fieldTranslation = action.payload;
363
- },
364
- setListSubject: (state, action) => {
365
- state.listSubject = action.payload;
366
- },
367
- setDataUser: (state, action) => {
368
- state.dataUser = action.payload;
369
- }
370
- }
371
- });
372
- var {
373
- setViewDataStore,
374
- setIsShowingModalDetail,
375
- setIsShowModalTranslate,
376
- setFormSubmitComponent,
377
- setFieldTranslate,
378
- setListSubject,
379
- setDataUser
380
- } = formSlice.actions;
381
- var form_slice_default = formSlice.reducer;
382
-
383
- // src/store/reducers/header-slice/index.ts
384
- import { createSlice as createSlice5 } from "@reduxjs/toolkit";
385
- var headerSlice = createSlice5({
386
- name: "header",
387
- initialState: {
388
- value: { allowedCompanyIds: [] }
389
- },
390
- reducers: {
391
- setHeader: (state, action) => {
392
- state.value = { ...state.value, ...action.payload };
393
- },
394
- setAllowedCompanyIds: (state, action) => {
395
- state.value.allowedCompanyIds = action.payload;
396
- }
397
- }
398
- });
399
- var { setAllowedCompanyIds, setHeader } = headerSlice.actions;
400
- var header_slice_default = headerSlice.reducer;
401
-
402
- // src/store/reducers/list-slice/index.ts
403
- import { createSlice as createSlice6 } from "@reduxjs/toolkit";
404
- var initialState5 = {
405
- pageLimit: 10,
406
- fields: {},
407
- order: "",
408
- selectedRowKeys: [],
409
- selectedRadioKey: 0,
410
- indexRowTableModal: -2,
411
- isUpdateTableModal: false,
412
- footerGroupTable: {},
413
- transferDetail: null,
414
- page: 0,
415
- domainTable: []
416
- };
417
- var listSlice = createSlice6({
418
- name: "list",
419
- initialState: initialState5,
420
- reducers: {
421
- setPageLimit: (state, action) => {
422
- state.pageLimit = action.payload;
423
- },
424
- setFields: (state, action) => {
425
- state.fields = action.payload;
426
- },
427
- setOrder: (state, action) => {
428
- state.order = action.payload;
429
- },
430
- setSelectedRowKeys: (state, action) => {
431
- state.selectedRowKeys = action.payload;
432
- },
433
- setSelectedRadioKey: (state, action) => {
434
- state.selectedRadioKey = action.payload;
435
- },
436
- setIndexRowTableModal: (state, action) => {
437
- state.indexRowTableModal = action.payload;
438
- },
439
- setTransferDetail: (state, action) => {
440
- state.transferDetail = action.payload;
441
- },
442
- setIsUpdateTableModal: (state, action) => {
443
- state.isUpdateTableModal = action.payload;
444
- },
445
- setPage: (state, action) => {
446
- state.page = action.payload;
447
- },
448
- setDomainTable: (state, action) => {
449
- state.domainTable = action.payload;
450
- }
451
- }
452
- });
453
- var {
454
- setPageLimit,
455
- setFields,
456
- setOrder,
457
- setSelectedRowKeys,
458
- setIndexRowTableModal,
459
- setIsUpdateTableModal,
460
- setPage,
461
- setSelectedRadioKey,
462
- setTransferDetail,
463
- setDomainTable
464
- } = listSlice.actions;
465
- var list_slice_default = listSlice.reducer;
466
-
467
- // src/store/reducers/login-slice/index.ts
468
- import { createSlice as createSlice7 } from "@reduxjs/toolkit";
469
- var initialState6 = {
470
- db: "",
471
- redirectTo: "/",
472
- forgotPasswordUrl: "/"
473
- };
474
- var loginSlice = createSlice7({
475
- name: "login",
476
- initialState: initialState6,
477
- reducers: {
478
- setDb: (state, action) => {
479
- state.db = action.payload;
480
- },
481
- setRedirectTo: (state, action) => {
482
- state.redirectTo = action.payload;
483
- },
484
- setForgotPasswordUrl: (state, action) => {
485
- state.forgotPasswordUrl = action.payload;
486
- }
487
- }
488
- });
489
- var { setDb, setRedirectTo, setForgotPasswordUrl } = loginSlice.actions;
490
- var login_slice_default = loginSlice.reducer;
491
-
492
- // src/store/reducers/navbar-slice/index.ts
493
- import { createSlice as createSlice8 } from "@reduxjs/toolkit";
494
- var initialState7 = {
495
- menuFocus: {},
496
- menuAction: {},
497
- navbarWidth: 250,
498
- menuList: []
499
- };
500
- var navbarSlice = createSlice8({
501
- name: "navbar",
502
- initialState: initialState7,
503
- reducers: {
504
- setMenuFocus: (state, action) => {
505
- state.menuFocus = action.payload;
506
- },
507
- setMenuFocusAction: (state, action) => {
508
- state.menuAction = action.payload;
509
- },
510
- setNavbarWidth: (state, action) => {
511
- state.navbarWidth = action.payload;
512
- },
513
- setMenuList: (state, action) => {
514
- state.menuList = action.payload;
515
- }
516
- }
517
- });
518
- var { setMenuFocus, setMenuFocusAction, setNavbarWidth, setMenuList } = navbarSlice.actions;
519
- var navbar_slice_default = navbarSlice.reducer;
520
-
521
- // src/store/reducers/profile-slice/index.ts
522
- import { createSlice as createSlice9 } from "@reduxjs/toolkit";
523
- var initialState8 = {
524
- profile: {}
525
- };
526
- var profileSlice = createSlice9({
527
- name: "profile",
528
- initialState: initialState8,
529
- reducers: {
530
- setProfile: (state, action) => {
531
- state.profile = action.payload;
532
- }
533
- }
534
- });
535
- var { setProfile } = profileSlice.actions;
536
- var profile_slice_default = profileSlice.reducer;
537
-
538
- // src/store/reducers/search-slice/index.ts
539
- import { createSlice as createSlice10 } from "@reduxjs/toolkit";
540
- var initialState9 = {
541
- groupByDomain: null,
542
- searchBy: [],
543
- searchString: "",
544
- hoveredIndexSearchList: null,
545
- selectedTags: [],
546
- firstDomain: null,
547
- searchMap: {},
548
- filterBy: [],
549
- groupBy: []
550
- };
551
- var searchSlice = createSlice10({
552
- name: "search",
553
- initialState: initialState9,
554
- reducers: {
555
- setGroupByDomain: (state, action) => {
556
- state.groupByDomain = action.payload;
557
- },
558
- setSearchBy: (state, action) => {
559
- state.searchBy = action.payload;
560
- },
561
- setSearchString: (state, action) => {
562
- state.searchString = action.payload;
563
- },
564
- setHoveredIndexSearchList: (state, action) => {
565
- state.hoveredIndexSearchList = action.payload;
566
- },
567
- setSelectedTags: (state, action) => {
568
- state.selectedTags = action.payload;
569
- },
570
- setFirstDomain: (state, action) => {
571
- state.firstDomain = action.payload;
572
- },
573
- setFilterBy: (state, action) => {
574
- state.filterBy = action.payload;
575
- },
576
- setGroupBy: (state, action) => {
577
- state.groupBy = action.payload;
578
- },
579
- setSearchMap: (state, action) => {
580
- state.searchMap = action.payload;
581
- },
582
- updateSearchMap: (state, action) => {
583
- if (!state.searchMap[action.payload.key]) {
584
- state.searchMap[action.payload.key] = [];
585
- }
586
- state.searchMap[action.payload.key].push(action.payload.value);
587
- },
588
- removeKeyFromSearchMap: (state, action) => {
589
- const { key, item } = action.payload;
590
- const values = state.searchMap[key];
591
- if (!values) return;
592
- if (item) {
593
- const filtered = values.filter((value) => value.name !== item.name);
594
- if (filtered.length > 0) {
595
- state.searchMap[key] = filtered;
596
- } else {
597
- delete state.searchMap[key];
598
- }
599
- } else {
600
- delete state.searchMap[key];
601
- }
602
- },
603
- clearSearchMap: (state) => {
604
- state.searchMap = {};
605
- }
606
- }
607
- });
608
- var {
609
- setGroupByDomain,
610
- setSelectedTags,
611
- setSearchString,
612
- setHoveredIndexSearchList,
613
- setFirstDomain,
614
- setSearchBy,
615
- setFilterBy,
616
- setSearchMap,
617
- updateSearchMap,
618
- removeKeyFromSearchMap,
619
- setGroupBy,
620
- clearSearchMap
621
- } = searchSlice.actions;
622
- var search_slice_default = searchSlice.reducer;
623
-
624
- // src/store/store.ts
625
- var rootReducer = combineReducers({
626
- env: env_slice_default,
627
- header: header_slice_default,
628
- navbar: navbar_slice_default,
629
- list: list_slice_default,
630
- search: search_slice_default,
631
- form: form_slice_default,
632
- breadcrumbs: breadcrums_slice_default,
633
- login: login_slice_default,
634
- excel: excel_slice_default,
635
- profile: profile_slice_default
636
- });
637
- var envStore = configureStore({
638
- reducer: rootReducer,
639
- middleware: (getDefaultMiddleware) => getDefaultMiddleware({
640
- serializableCheck: false
641
- })
642
- });
643
-
644
31
  // src/configs/axios-client.ts
645
32
  import axios from "axios";
646
33
 
@@ -2389,612 +1776,1228 @@ function evaluate(ast, context = {}) {
2389
1776
  } else {
2390
1777
  result = leftVal[ast2.key];
2391
1778
  }
2392
- if (typeof result === "function") {
2393
- const bound = result.bind(leftVal);
2394
- bound[unboundFn] = result;
2395
- return bound;
1779
+ if (typeof result === "function") {
1780
+ const bound = result.bind(leftVal);
1781
+ bound[unboundFn] = result;
1782
+ return bound;
1783
+ }
1784
+ return result;
1785
+ default:
1786
+ throw new EvaluationError(`AST of type ${ast2.type} cannot be evaluated`);
1787
+ }
1788
+ }
1789
+ function _evaluate(ast2) {
1790
+ const val = _innerEvaluate(ast2);
1791
+ if (typeof val === "function" && !allowedFns.has(val) && !allowedFns.has(val[unboundFn])) {
1792
+ throw new Error("Invalid Function Call");
1793
+ }
1794
+ return val;
1795
+ }
1796
+ return _evaluate(ast);
1797
+ }
1798
+
1799
+ // src/utils/domain/py.ts
1800
+ function parseExpr(expr) {
1801
+ const tokens = tokenize(expr);
1802
+ return parse(tokens);
1803
+ }
1804
+
1805
+ // src/utils/domain/objects.ts
1806
+ function shallowEqual(obj1, obj2, comparisonFn = (a, b) => a === b) {
1807
+ if (!obj1 || !obj2 || typeof obj1 !== "object" || typeof obj2 !== "object") {
1808
+ return obj1 === obj2;
1809
+ }
1810
+ const obj1Keys = Object.keys(obj1);
1811
+ return obj1Keys.length === Object.keys(obj2).length && obj1Keys.every((key) => comparisonFn(obj1[key], obj2[key]));
1812
+ }
1813
+
1814
+ // src/utils/domain/arrays.ts
1815
+ var shallowEqual2 = shallowEqual;
1816
+
1817
+ // src/utils/domain/strings.ts
1818
+ var escapeMethod = Symbol("html");
1819
+ function escapeRegExp(str) {
1820
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1821
+ }
1822
+
1823
+ // src/utils/domain/domain.ts
1824
+ var InvalidDomainError = class extends Error {
1825
+ };
1826
+ var Domain = class _Domain {
1827
+ ast = { type: -1, value: null };
1828
+ static TRUE;
1829
+ static FALSE;
1830
+ static combine(domains, operator) {
1831
+ if (domains.length === 0) {
1832
+ return new _Domain([]);
1833
+ }
1834
+ const domain1 = domains[0] instanceof _Domain ? domains[0] : new _Domain(domains[0]);
1835
+ if (domains.length === 1) {
1836
+ return domain1;
1837
+ }
1838
+ const domain2 = _Domain.combine(domains.slice(1), operator);
1839
+ const result = new _Domain([]);
1840
+ const astValues1 = domain1.ast.value;
1841
+ const astValues2 = domain2.ast.value;
1842
+ const op = operator === "AND" ? "&" : "|";
1843
+ const combinedAST = {
1844
+ type: 4,
1845
+ value: astValues1.concat(astValues2)
1846
+ };
1847
+ result.ast = normalizeDomainAST(combinedAST, op);
1848
+ return result;
1849
+ }
1850
+ static and(domains) {
1851
+ return _Domain.combine(domains, "AND");
1852
+ }
1853
+ static or(domains) {
1854
+ return _Domain.combine(domains, "OR");
1855
+ }
1856
+ static not(domain) {
1857
+ const result = new _Domain(domain);
1858
+ result.ast.value.unshift({ type: 1, value: "!" });
1859
+ return result;
1860
+ }
1861
+ static removeDomainLeaves(domain, keysToRemove) {
1862
+ function processLeaf(elements, idx, operatorCtx, newDomain2) {
1863
+ const leaf = elements[idx];
1864
+ if (leaf.type === 10) {
1865
+ if (keysToRemove.includes(leaf.value[0].value)) {
1866
+ if (operatorCtx === "&") {
1867
+ newDomain2.ast.value.push(..._Domain.TRUE.ast.value);
1868
+ } else if (operatorCtx === "|") {
1869
+ newDomain2.ast.value.push(..._Domain.FALSE.ast.value);
1870
+ }
1871
+ } else {
1872
+ newDomain2.ast.value.push(leaf);
1873
+ }
1874
+ return 1;
1875
+ } else if (leaf.type === 1) {
1876
+ 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)) {
1877
+ newDomain2.ast.value.push(..._Domain.TRUE.ast.value);
1878
+ return 3;
1879
+ }
1880
+ newDomain2.ast.value.push(leaf);
1881
+ if (leaf.value === "!") {
1882
+ return 1 + processLeaf(elements, idx + 1, "&", newDomain2);
1883
+ }
1884
+ const firstLeafSkip = processLeaf(
1885
+ elements,
1886
+ idx + 1,
1887
+ leaf.value,
1888
+ newDomain2
1889
+ );
1890
+ const secondLeafSkip = processLeaf(
1891
+ elements,
1892
+ idx + 1 + firstLeafSkip,
1893
+ leaf.value,
1894
+ newDomain2
1895
+ );
1896
+ return 1 + firstLeafSkip + secondLeafSkip;
1897
+ }
1898
+ return 0;
1899
+ }
1900
+ const d = new _Domain(domain);
1901
+ if (d.ast.value.length === 0) {
1902
+ return d;
1903
+ }
1904
+ const newDomain = new _Domain([]);
1905
+ processLeaf(d.ast.value, 0, "&", newDomain);
1906
+ return newDomain;
1907
+ }
1908
+ constructor(descr = []) {
1909
+ if (descr instanceof _Domain) {
1910
+ return new _Domain(descr.toString());
1911
+ } else {
1912
+ let rawAST;
1913
+ try {
1914
+ rawAST = typeof descr === "string" ? parseExpr(descr) : toAST(descr);
1915
+ } catch (error) {
1916
+ throw new InvalidDomainError(
1917
+ `Invalid domain representation: ${descr}`,
1918
+ {
1919
+ cause: error
1920
+ }
1921
+ );
1922
+ }
1923
+ this.ast = normalizeDomainAST(rawAST);
1924
+ }
1925
+ }
1926
+ contains(record) {
1927
+ const expr = evaluate(this.ast, record);
1928
+ return matchDomain(record, expr);
1929
+ }
1930
+ toString() {
1931
+ return formatAST(this.ast);
1932
+ }
1933
+ toList(context) {
1934
+ return evaluate(this.ast, context);
1935
+ }
1936
+ toJson() {
1937
+ try {
1938
+ const evaluatedAsList = this.toList({});
1939
+ const evaluatedDomain = new _Domain(evaluatedAsList);
1940
+ if (evaluatedDomain.toString() === this.toString()) {
1941
+ return evaluatedAsList;
1942
+ }
1943
+ return this.toString();
1944
+ } catch {
1945
+ return this.toString();
1946
+ }
1947
+ }
1948
+ };
1949
+ var TRUE_LEAF = [1, "=", 1];
1950
+ var FALSE_LEAF = [0, "=", 1];
1951
+ var TRUE_DOMAIN = new Domain([TRUE_LEAF]);
1952
+ var FALSE_DOMAIN = new Domain([FALSE_LEAF]);
1953
+ Domain.TRUE = TRUE_DOMAIN;
1954
+ Domain.FALSE = FALSE_DOMAIN;
1955
+ function toAST(domain) {
1956
+ const elems = domain.map((elem) => {
1957
+ switch (elem) {
1958
+ case "!":
1959
+ case "&":
1960
+ case "|":
1961
+ return { type: 1, value: elem };
1962
+ default:
1963
+ return {
1964
+ type: 10,
1965
+ value: elem.map(toPyValue)
1966
+ };
1967
+ }
1968
+ });
1969
+ return { type: 4, value: elems };
1970
+ }
1971
+ function normalizeDomainAST(domain, op = "&") {
1972
+ if (domain.type !== 4) {
1973
+ if (domain.type === 10) {
1974
+ const value = domain.value;
1975
+ if (value.findIndex((e) => e.type === 10) === -1 || !value.every((e) => e.type === 10 || e.type === 1)) {
1976
+ throw new InvalidDomainError("Invalid domain AST");
1977
+ }
1978
+ } else {
1979
+ throw new InvalidDomainError("Invalid domain AST");
1980
+ }
1981
+ }
1982
+ if (domain.value.length === 0) {
1983
+ return domain;
1984
+ }
1985
+ let expected = 1;
1986
+ for (const child of domain.value) {
1987
+ switch (child.type) {
1988
+ case 1:
1989
+ if (child.value === "&" || child.value === "|") {
1990
+ expected++;
1991
+ } else if (child.value !== "!") {
1992
+ throw new InvalidDomainError("Invalid domain AST");
1993
+ }
1994
+ break;
1995
+ case 4:
1996
+ /* list */
1997
+ case 10:
1998
+ if (child.value.length === 3) {
1999
+ expected--;
2000
+ break;
2396
2001
  }
2397
- return result;
2002
+ throw new InvalidDomainError("Invalid domain AST");
2398
2003
  default:
2399
- throw new EvaluationError(`AST of type ${ast2.type} cannot be evaluated`);
2004
+ throw new InvalidDomainError("Invalid domain AST");
2400
2005
  }
2401
2006
  }
2402
- function _evaluate(ast2) {
2403
- const val = _innerEvaluate(ast2);
2404
- if (typeof val === "function" && !allowedFns.has(val) && !allowedFns.has(val[unboundFn])) {
2405
- throw new Error("Invalid Function Call");
2007
+ const values = domain.value.slice();
2008
+ while (expected < 0) {
2009
+ expected++;
2010
+ values.unshift({ type: 1, value: op });
2011
+ }
2012
+ if (expected > 0) {
2013
+ throw new InvalidDomainError(
2014
+ `invalid domain ${formatAST(domain)} (missing ${expected} segment(s))`
2015
+ );
2016
+ }
2017
+ return { type: 4, value: values };
2018
+ }
2019
+ function matchCondition(record, condition) {
2020
+ if (typeof condition === "boolean") {
2021
+ return condition;
2022
+ }
2023
+ const [field, operator, value] = condition;
2024
+ if (typeof field === "string") {
2025
+ const names = field.split(".");
2026
+ if (names.length >= 2) {
2027
+ return matchCondition(record[names[0]], [
2028
+ names.slice(1).join("."),
2029
+ operator,
2030
+ value
2031
+ ]);
2406
2032
  }
2407
- return val;
2408
2033
  }
2409
- return _evaluate(ast);
2034
+ let likeRegexp, ilikeRegexp;
2035
+ if (["like", "not like", "ilike", "not ilike"].includes(operator)) {
2036
+ likeRegexp = new RegExp(
2037
+ `(.*)${escapeRegExp(value).replaceAll("%", "(.*)")}(.*)`,
2038
+ "g"
2039
+ );
2040
+ ilikeRegexp = new RegExp(
2041
+ `(.*)${escapeRegExp(value).replaceAll("%", "(.*)")}(.*)`,
2042
+ "gi"
2043
+ );
2044
+ }
2045
+ const fieldValue = typeof field === "number" ? field : record[field];
2046
+ switch (operator) {
2047
+ case "=?":
2048
+ if ([false, null].includes(value)) {
2049
+ return true;
2050
+ }
2051
+ // eslint-disable-next-line no-fallthrough
2052
+ case "=":
2053
+ case "==":
2054
+ if (Array.isArray(fieldValue) && Array.isArray(value)) {
2055
+ return shallowEqual2(fieldValue, value);
2056
+ }
2057
+ return fieldValue === value;
2058
+ case "!=":
2059
+ case "<>":
2060
+ return !matchCondition(record, [field, "==", value]);
2061
+ case "<":
2062
+ return fieldValue < value;
2063
+ case "<=":
2064
+ return fieldValue <= value;
2065
+ case ">":
2066
+ return fieldValue > value;
2067
+ case ">=":
2068
+ return fieldValue >= value;
2069
+ case "in": {
2070
+ const val = Array.isArray(value) ? value : [value];
2071
+ const fieldVal = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
2072
+ return fieldVal.some((fv) => val.includes(fv));
2073
+ }
2074
+ case "not in": {
2075
+ const val = Array.isArray(value) ? value : [value];
2076
+ const fieldVal = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
2077
+ return !fieldVal.some((fv) => val.includes(fv));
2078
+ }
2079
+ case "like":
2080
+ if (fieldValue === false) {
2081
+ return false;
2082
+ }
2083
+ return Boolean(fieldValue.match(likeRegexp));
2084
+ case "not like":
2085
+ if (fieldValue === false) {
2086
+ return false;
2087
+ }
2088
+ return Boolean(!fieldValue.match(likeRegexp));
2089
+ case "=like":
2090
+ if (fieldValue === false) {
2091
+ return false;
2092
+ }
2093
+ return new RegExp(escapeRegExp(value).replace(/%/g, ".*")).test(
2094
+ fieldValue
2095
+ );
2096
+ case "ilike":
2097
+ if (fieldValue === false) {
2098
+ return false;
2099
+ }
2100
+ return Boolean(fieldValue.match(ilikeRegexp));
2101
+ case "not ilike":
2102
+ if (fieldValue === false) {
2103
+ return false;
2104
+ }
2105
+ return Boolean(!fieldValue.match(ilikeRegexp));
2106
+ case "=ilike":
2107
+ if (fieldValue === false) {
2108
+ return false;
2109
+ }
2110
+ return new RegExp(escapeRegExp(value).replace(/%/g, ".*"), "i").test(
2111
+ fieldValue
2112
+ );
2113
+ }
2114
+ throw new InvalidDomainError("could not match domain");
2410
2115
  }
2411
-
2412
- // src/utils/domain/py.ts
2413
- function parseExpr(expr) {
2414
- const tokens = tokenize(expr);
2415
- return parse(tokens);
2116
+ function makeOperators(record) {
2117
+ const match = matchCondition.bind(null, record);
2118
+ return {
2119
+ "!": (x) => !match(x),
2120
+ "&": (a, b) => match(a) && match(b),
2121
+ "|": (a, b) => match(a) || match(b)
2122
+ };
2416
2123
  }
2417
-
2418
- // src/utils/domain/objects.ts
2419
- function shallowEqual(obj1, obj2, comparisonFn = (a, b) => a === b) {
2420
- if (!obj1 || !obj2 || typeof obj1 !== "object" || typeof obj2 !== "object") {
2421
- return obj1 === obj2;
2124
+ function matchDomain(record, domain) {
2125
+ if (domain.length === 0) {
2126
+ return true;
2422
2127
  }
2423
- const obj1Keys = Object.keys(obj1);
2424
- return obj1Keys.length === Object.keys(obj2).length && obj1Keys.every((key) => comparisonFn(obj1[key], obj2[key]));
2425
- }
2426
-
2427
- // src/utils/domain/arrays.ts
2428
- var shallowEqual2 = shallowEqual;
2429
-
2430
- // src/utils/domain/strings.ts
2431
- var escapeMethod = Symbol("html");
2432
- function escapeRegExp(str) {
2433
- return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2128
+ const operators = makeOperators(record);
2129
+ const reversedDomain = Array.from(domain).reverse();
2130
+ const condStack = [];
2131
+ for (const item of reversedDomain) {
2132
+ const operator = typeof item === "string" && operators[item];
2133
+ if (operator) {
2134
+ const operands = condStack.splice(-operator.length);
2135
+ condStack.push(operator(...operands));
2136
+ } else {
2137
+ condStack.push(item);
2138
+ }
2139
+ }
2140
+ return matchCondition(record, condStack.pop());
2434
2141
  }
2435
2142
 
2436
- // src/utils/domain/domain.ts
2437
- var InvalidDomainError = class extends Error {
2143
+ // src/utils/function.ts
2144
+ import { useEffect, useState } from "react";
2145
+ var toQueryString = (params) => {
2146
+ return Object.keys(params).map(
2147
+ (key) => encodeURIComponent(key) + "=" + encodeURIComponent(params[key].toString())
2148
+ ).join("&");
2438
2149
  };
2439
- var Domain = class _Domain {
2440
- ast = { type: -1, value: null };
2441
- static TRUE;
2442
- static FALSE;
2443
- static combine(domains, operator) {
2444
- if (domains.length === 0) {
2445
- return new _Domain([]);
2446
- }
2447
- const domain1 = domains[0] instanceof _Domain ? domains[0] : new _Domain(domains[0]);
2448
- if (domains.length === 1) {
2449
- return domain1;
2450
- }
2451
- const domain2 = _Domain.combine(domains.slice(1), operator);
2452
- const result = new _Domain([]);
2453
- const astValues1 = domain1.ast.value;
2454
- const astValues2 = domain2.ast.value;
2455
- const op = operator === "AND" ? "&" : "|";
2456
- const combinedAST = {
2457
- type: 4,
2458
- value: astValues1.concat(astValues2)
2459
- };
2460
- result.ast = normalizeDomainAST(combinedAST, op);
2461
- return result;
2462
- }
2463
- static and(domains) {
2464
- return _Domain.combine(domains, "AND");
2465
- }
2466
- static or(domains) {
2467
- return _Domain.combine(domains, "OR");
2150
+ var updateTokenParamInOriginalRequest = (originalRequest, newAccessToken) => {
2151
+ if (!originalRequest.data) return originalRequest.data;
2152
+ if (typeof originalRequest.data === "string") {
2153
+ try {
2154
+ const parsedData = JSON.parse(originalRequest.data);
2155
+ if (parsedData.with_context && typeof parsedData.with_context === "object") {
2156
+ parsedData.with_context.token = newAccessToken;
2157
+ }
2158
+ return JSON.stringify(parsedData);
2159
+ } catch (e) {
2160
+ console.warn("Failed to parse originalRequest.data", e);
2161
+ return originalRequest.data;
2162
+ }
2468
2163
  }
2469
- static not(domain) {
2470
- const result = new _Domain(domain);
2471
- result.ast.value.unshift({ type: 1, value: "!" });
2472
- return result;
2164
+ if (typeof originalRequest.data === "object" && originalRequest.data.with_context) {
2165
+ originalRequest.data.with_context.token = newAccessToken;
2473
2166
  }
2474
- static removeDomainLeaves(domain, keysToRemove) {
2475
- function processLeaf(elements, idx, operatorCtx, newDomain2) {
2476
- const leaf = elements[idx];
2477
- if (leaf.type === 10) {
2478
- if (keysToRemove.includes(leaf.value[0].value)) {
2479
- if (operatorCtx === "&") {
2480
- newDomain2.ast.value.push(..._Domain.TRUE.ast.value);
2481
- } else if (operatorCtx === "|") {
2482
- newDomain2.ast.value.push(..._Domain.FALSE.ast.value);
2483
- }
2167
+ return originalRequest.data;
2168
+ };
2169
+
2170
+ // src/utils/storage/local-storage.ts
2171
+ var localStorageUtils = () => {
2172
+ const setToken = async (access_token) => {
2173
+ localStorage.setItem("accessToken", access_token);
2174
+ };
2175
+ const setRefreshToken = async (refresh_token) => {
2176
+ localStorage.setItem("refreshToken", refresh_token);
2177
+ };
2178
+ const getAccessToken = async () => {
2179
+ return localStorage.getItem("accessToken");
2180
+ };
2181
+ const getRefreshToken = async () => {
2182
+ return localStorage.getItem("refreshToken");
2183
+ };
2184
+ const clearToken = async () => {
2185
+ localStorage.removeItem("accessToken");
2186
+ localStorage.removeItem("refreshToken");
2187
+ };
2188
+ return {
2189
+ setToken,
2190
+ setRefreshToken,
2191
+ getAccessToken,
2192
+ getRefreshToken,
2193
+ clearToken
2194
+ };
2195
+ };
2196
+
2197
+ // src/utils/storage/session-storage.ts
2198
+ var sessionStorageUtils = () => {
2199
+ const getBrowserSession = async () => {
2200
+ return sessionStorage.getItem("browserSession");
2201
+ };
2202
+ return {
2203
+ getBrowserSession
2204
+ };
2205
+ };
2206
+
2207
+ // src/configs/axios-client.ts
2208
+ var axiosClient = {
2209
+ init(config) {
2210
+ const localStorage2 = config.localStorageUtils ?? localStorageUtils();
2211
+ const sessionStorage2 = config.sessionStorageUtils ?? sessionStorageUtils();
2212
+ const db = config.db;
2213
+ let isRefreshing = false;
2214
+ let failedQueue = [];
2215
+ const processQueue = (error, token = null) => {
2216
+ failedQueue?.forEach((prom) => {
2217
+ if (error) {
2218
+ prom.reject(error);
2484
2219
  } else {
2485
- newDomain2.ast.value.push(leaf);
2486
- }
2487
- return 1;
2488
- } else if (leaf.type === 1) {
2489
- 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)) {
2490
- newDomain2.ast.value.push(..._Domain.TRUE.ast.value);
2491
- return 3;
2220
+ prom.resolve(token);
2492
2221
  }
2493
- newDomain2.ast.value.push(leaf);
2494
- if (leaf.value === "!") {
2495
- return 1 + processLeaf(elements, idx + 1, "&", newDomain2);
2222
+ });
2223
+ failedQueue = [];
2224
+ };
2225
+ const instance = axios.create({
2226
+ adapter: axios.defaults.adapter,
2227
+ baseURL: config.baseUrl,
2228
+ timeout: 5e4,
2229
+ paramsSerializer: (params) => new URLSearchParams(params).toString()
2230
+ });
2231
+ instance.interceptors.request.use(
2232
+ async (config2) => {
2233
+ const useRefreshToken = config2.useRefreshToken;
2234
+ const token = useRefreshToken ? await localStorage2.getRefreshToken() : await localStorage2.getAccessToken();
2235
+ if (token) {
2236
+ config2.headers["Authorization"] = "Bearer " + token;
2496
2237
  }
2497
- const firstLeafSkip = processLeaf(
2498
- elements,
2499
- idx + 1,
2500
- leaf.value,
2501
- newDomain2
2502
- );
2503
- const secondLeafSkip = processLeaf(
2504
- elements,
2505
- idx + 1 + firstLeafSkip,
2506
- leaf.value,
2507
- newDomain2
2508
- );
2509
- return 1 + firstLeafSkip + secondLeafSkip;
2238
+ return config2;
2239
+ },
2240
+ (error) => {
2241
+ Promise.reject(error);
2510
2242
  }
2511
- return 0;
2512
- }
2513
- const d = new _Domain(domain);
2514
- if (d.ast.value.length === 0) {
2515
- return d;
2516
- }
2517
- const newDomain = new _Domain([]);
2518
- processLeaf(d.ast.value, 0, "&", newDomain);
2519
- return newDomain;
2520
- }
2521
- constructor(descr = []) {
2522
- if (descr instanceof _Domain) {
2523
- return new _Domain(descr.toString());
2524
- } else {
2525
- let rawAST;
2526
- try {
2527
- rawAST = typeof descr === "string" ? parseExpr(descr) : toAST(descr);
2528
- } catch (error) {
2529
- throw new InvalidDomainError(
2530
- `Invalid domain representation: ${descr}`,
2531
- {
2532
- cause: error
2243
+ );
2244
+ instance.interceptors.response.use(
2245
+ (response) => {
2246
+ return handleResponse(response);
2247
+ },
2248
+ async (error) => {
2249
+ const handleError3 = async (error2) => {
2250
+ if (!error2.response) {
2251
+ return error2;
2533
2252
  }
2534
- );
2253
+ const { data } = error2.response;
2254
+ if (data && data.code === 400 && ["invalid_grant"].includes(data.data?.error)) {
2255
+ await clearAuthToken();
2256
+ }
2257
+ return data;
2258
+ };
2259
+ const originalRequest = error.config;
2260
+ if ((error.response?.status === 403 || error.response?.status === 401 || error.response?.status === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401, "ERR_2FA_006"].includes(
2261
+ error.response.data.code
2262
+ )) {
2263
+ if (isRefreshing) {
2264
+ return new Promise(function(resolve, reject) {
2265
+ failedQueue.push({ resolve, reject });
2266
+ }).then((token) => {
2267
+ originalRequest.headers["Authorization"] = "Bearer " + token;
2268
+ originalRequest.data = updateTokenParamInOriginalRequest(
2269
+ originalRequest,
2270
+ token
2271
+ );
2272
+ return instance.request(originalRequest);
2273
+ }).catch(async (err) => {
2274
+ if ((err.response?.status === 400 || err.response?.status === 401) && ["invalid_grant"].includes(err.response.data.error)) {
2275
+ await clearAuthToken();
2276
+ }
2277
+ });
2278
+ }
2279
+ const browserSession = await sessionStorage2.getBrowserSession();
2280
+ const refreshToken = await localStorage2.getRefreshToken();
2281
+ const accessTokenExp = await localStorage2.getAccessToken();
2282
+ isRefreshing = true;
2283
+ if (!refreshToken && (!browserSession || browserSession == "unActive")) {
2284
+ await clearAuthToken();
2285
+ } else {
2286
+ const payload = Object.fromEntries(
2287
+ Object.entries({
2288
+ refresh_token: refreshToken,
2289
+ grant_type: "refresh_token",
2290
+ client_id: config.config.clientId,
2291
+ client_secret: config.config.clientSecret
2292
+ }).filter(([_, value]) => !!value)
2293
+ );
2294
+ return new Promise(function(resolve) {
2295
+ axios.post(
2296
+ `${config.baseUrl}${config.refreshTokenEndpoint ?? "/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
2297
+ payload,
2298
+ {
2299
+ headers: {
2300
+ "Content-Type": config.refreshTokenEndpoint ? "application/x-www-form-urlencoded" : "multipart/form-data",
2301
+ Authorization: `Bearer ${accessTokenExp}`
2302
+ }
2303
+ }
2304
+ ).then(async (res) => {
2305
+ const data = res.data;
2306
+ await localStorage2.setToken(data.access_token);
2307
+ await localStorage2.setRefreshToken(data.refresh_token);
2308
+ axios.defaults.headers.common["Authorization"] = "Bearer " + data.access_token;
2309
+ originalRequest.headers["Authorization"] = "Bearer " + data.access_token;
2310
+ originalRequest.data = updateTokenParamInOriginalRequest(
2311
+ originalRequest,
2312
+ data.access_token
2313
+ );
2314
+ processQueue(null, data.access_token);
2315
+ resolve(instance.request(originalRequest));
2316
+ }).catch(async (err) => {
2317
+ if (err && (err?.error_code === "AUTHEN_FAIL" || err?.error_code === "TOKEN_EXPIRED" || err?.error_code === "TOKEN_INCORRECT" || err?.code === "ERR_BAD_REQUEST") || err?.error_code === "ERR_2FA_006") {
2318
+ await clearAuthToken();
2319
+ }
2320
+ if (err && err.response) {
2321
+ const { error_code } = err.response?.data || {};
2322
+ if (error_code === "AUTHEN_FAIL") {
2323
+ await clearAuthToken();
2324
+ }
2325
+ }
2326
+ processQueue(err, null);
2327
+ }).finally(() => {
2328
+ isRefreshing = false;
2329
+ });
2330
+ });
2331
+ }
2332
+ }
2333
+ return Promise.reject(await handleError3(error));
2535
2334
  }
2536
- this.ast = normalizeDomainAST(rawAST);
2537
- }
2538
- }
2539
- contains(record) {
2540
- const expr = evaluate(this.ast, record);
2541
- return matchDomain(record, expr);
2542
- }
2543
- toString() {
2544
- return formatAST(this.ast);
2545
- }
2546
- toList(context) {
2547
- return evaluate(this.ast, context);
2548
- }
2549
- toJson() {
2550
- try {
2551
- const evaluatedAsList = this.toList({});
2552
- const evaluatedDomain = new _Domain(evaluatedAsList);
2553
- if (evaluatedDomain.toString() === this.toString()) {
2554
- return evaluatedAsList;
2335
+ );
2336
+ const handleResponse = (res) => {
2337
+ if (res && res.data) {
2338
+ return res.data;
2339
+ }
2340
+ return res;
2341
+ };
2342
+ const handleError2 = (error) => {
2343
+ if (error.isAxiosError && error.code === "ECONNABORTED") {
2344
+ console.error("Request Timeout Error:", error);
2345
+ return "Request Timeout Error";
2346
+ } else if (error.isAxiosError && !error.response) {
2347
+ console.error("Network Error:", error);
2348
+ return "Network Error";
2349
+ } else {
2350
+ console.error("Other Error:", error?.response);
2351
+ const errorMessage = error?.response?.data?.message || "An error occurred";
2352
+ return { message: errorMessage, status: error?.response?.status };
2555
2353
  }
2556
- return this.toString();
2557
- } catch {
2558
- return this.toString();
2354
+ };
2355
+ const clearAuthToken = async () => {
2356
+ await localStorage2.clearToken();
2357
+ if (typeof window !== "undefined") {
2358
+ window.location.href = `/login`;
2359
+ }
2360
+ };
2361
+ function formatUrl(url, db2) {
2362
+ return url + (db2 ? "?db=" + db2 : "");
2559
2363
  }
2364
+ const responseBody = (response) => response;
2365
+ const requests = {
2366
+ get: (url, headers) => instance.get(formatUrl(url, db), headers).then(responseBody),
2367
+ post: (url, body, headers) => instance.post(formatUrl(url, db), body, headers).then(responseBody),
2368
+ post_excel: (url, body, headers) => instance.post(formatUrl(url, db), body, {
2369
+ responseType: "arraybuffer",
2370
+ headers: {
2371
+ "Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
2372
+ Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
2373
+ }
2374
+ }).then(responseBody),
2375
+ put: (url, body, headers) => instance.put(formatUrl(url, db), body, headers).then(responseBody),
2376
+ patch: (url, body) => instance.patch(formatUrl(url, db), body).then(responseBody),
2377
+ delete: (url, body) => instance.delete(formatUrl(url, db), body).then(responseBody)
2378
+ };
2379
+ return requests;
2560
2380
  }
2561
2381
  };
2562
- var TRUE_LEAF = [1, "=", 1];
2563
- var FALSE_LEAF = [0, "=", 1];
2564
- var TRUE_DOMAIN = new Domain([TRUE_LEAF]);
2565
- var FALSE_DOMAIN = new Domain([FALSE_LEAF]);
2566
- Domain.TRUE = TRUE_DOMAIN;
2567
- Domain.FALSE = FALSE_DOMAIN;
2568
- function toAST(domain) {
2569
- const elems = domain.map((elem) => {
2570
- switch (elem) {
2571
- case "!":
2572
- case "&":
2573
- case "|":
2574
- return { type: 1, value: elem };
2575
- default:
2576
- return {
2577
- type: 10,
2578
- value: elem.map(toPyValue)
2579
- };
2580
- }
2581
- });
2582
- return { type: 4, value: elems };
2583
- }
2584
- function normalizeDomainAST(domain, op = "&") {
2585
- if (domain.type !== 4) {
2586
- if (domain.type === 10) {
2587
- const value = domain.value;
2588
- if (value.findIndex((e) => e.type === 10) === -1 || !value.every((e) => e.type === 10 || e.type === 1)) {
2589
- throw new InvalidDomainError("Invalid domain AST");
2590
- }
2591
- } else {
2592
- throw new InvalidDomainError("Invalid domain AST");
2382
+
2383
+ // src/store/index.ts
2384
+ import { useDispatch, useSelector } from "react-redux";
2385
+
2386
+ // src/store/reducers/breadcrums-slice/index.ts
2387
+ import { createSlice } from "@reduxjs/toolkit";
2388
+ var initialState = {
2389
+ breadCrumbs: []
2390
+ };
2391
+ var breadcrumbsSlice = createSlice({
2392
+ name: "breadcrumbs",
2393
+ initialState,
2394
+ reducers: {
2395
+ setBreadCrumbs: (state, action) => {
2396
+ state.breadCrumbs = [...state.breadCrumbs, action.payload];
2593
2397
  }
2594
2398
  }
2595
- if (domain.value.length === 0) {
2596
- return domain;
2399
+ });
2400
+ var { setBreadCrumbs } = breadcrumbsSlice.actions;
2401
+ var breadcrums_slice_default = breadcrumbsSlice.reducer;
2402
+
2403
+ // src/store/reducers/env-slice/index.ts
2404
+ import { createSlice as createSlice2 } from "@reduxjs/toolkit";
2405
+ var initialState2 = {
2406
+ baseUrl: "",
2407
+ requests: null,
2408
+ companies: [],
2409
+ user: {},
2410
+ config: null,
2411
+ envFile: null,
2412
+ defaultCompany: {
2413
+ id: null,
2414
+ logo: "",
2415
+ secondary_color: "",
2416
+ primary_color: ""
2417
+ },
2418
+ context: {
2419
+ uid: null,
2420
+ allowed_company_ids: [],
2421
+ lang: "vi_VN",
2422
+ tz: "Asia/Saigon"
2597
2423
  }
2598
- let expected = 1;
2599
- for (const child of domain.value) {
2600
- switch (child.type) {
2601
- case 1:
2602
- if (child.value === "&" || child.value === "|") {
2603
- expected++;
2604
- } else if (child.value !== "!") {
2605
- throw new InvalidDomainError("Invalid domain AST");
2606
- }
2607
- break;
2608
- case 4:
2609
- /* list */
2610
- case 10:
2611
- if (child.value.length === 3) {
2612
- expected--;
2613
- break;
2614
- }
2615
- throw new InvalidDomainError("Invalid domain AST");
2616
- default:
2617
- throw new InvalidDomainError("Invalid domain AST");
2424
+ };
2425
+ var envSlice = createSlice2({
2426
+ name: "env",
2427
+ initialState: initialState2,
2428
+ reducers: {
2429
+ setEnv: (state, action) => {
2430
+ Object.assign(state, action.payload);
2431
+ },
2432
+ setUid: (state, action) => {
2433
+ state.context.uid = action.payload;
2434
+ },
2435
+ setAllowCompanies: (state, action) => {
2436
+ state.context.allowed_company_ids = action.payload;
2437
+ },
2438
+ setCompanies: (state, action) => {
2439
+ state.companies = action.payload;
2440
+ },
2441
+ setDefaultCompany: (state, action) => {
2442
+ state.defaultCompany = action.payload;
2443
+ },
2444
+ setLang: (state, action) => {
2445
+ state.context.lang = action.payload;
2446
+ },
2447
+ setUser: (state, action) => {
2448
+ state.user = action.payload;
2449
+ },
2450
+ setConfig: (state, action) => {
2451
+ state.config = action.payload;
2452
+ },
2453
+ setEnvFile: (state, action) => {
2454
+ state.envFile = action.payload;
2618
2455
  }
2619
2456
  }
2620
- const values = domain.value.slice();
2621
- while (expected < 0) {
2622
- expected++;
2623
- values.unshift({ type: 1, value: op });
2624
- }
2625
- if (expected > 0) {
2626
- throw new InvalidDomainError(
2627
- `invalid domain ${formatAST(domain)} (missing ${expected} segment(s))`
2628
- );
2629
- }
2630
- return { type: 4, value: values };
2631
- }
2632
- function matchCondition(record, condition) {
2633
- if (typeof condition === "boolean") {
2634
- return condition;
2457
+ });
2458
+ var {
2459
+ setEnv,
2460
+ setUid,
2461
+ setLang,
2462
+ setAllowCompanies,
2463
+ setCompanies,
2464
+ setDefaultCompany,
2465
+ setUser,
2466
+ setConfig,
2467
+ setEnvFile
2468
+ } = envSlice.actions;
2469
+ var env_slice_default = envSlice.reducer;
2470
+
2471
+ // src/store/reducers/excel-slice/index.ts
2472
+ import { createSlice as createSlice3 } from "@reduxjs/toolkit";
2473
+ var initialState3 = {
2474
+ dataParse: null,
2475
+ idFile: null,
2476
+ isFileLoaded: false,
2477
+ loadingImport: false,
2478
+ selectedFile: null,
2479
+ errorData: null
2480
+ };
2481
+ var excelSlice = createSlice3({
2482
+ name: "excel",
2483
+ initialState: initialState3,
2484
+ reducers: {
2485
+ setDataParse: (state, action) => {
2486
+ state.dataParse = action.payload;
2487
+ },
2488
+ setIdFile: (state, action) => {
2489
+ state.idFile = action.payload;
2490
+ },
2491
+ setIsFileLoaded: (state, action) => {
2492
+ state.isFileLoaded = action.payload;
2493
+ },
2494
+ setLoadingImport: (state, action) => {
2495
+ state.loadingImport = action.payload;
2496
+ },
2497
+ setSelectedFile: (state, action) => {
2498
+ state.selectedFile = action.payload;
2499
+ },
2500
+ setErrorData: (state, action) => {
2501
+ state.errorData = action.payload;
2502
+ }
2635
2503
  }
2636
- const [field, operator, value] = condition;
2637
- if (typeof field === "string") {
2638
- const names = field.split(".");
2639
- if (names.length >= 2) {
2640
- return matchCondition(record[names[0]], [
2641
- names.slice(1).join("."),
2642
- operator,
2643
- value
2644
- ]);
2504
+ });
2505
+ var {
2506
+ setDataParse,
2507
+ setIdFile,
2508
+ setIsFileLoaded,
2509
+ setLoadingImport,
2510
+ setSelectedFile,
2511
+ setErrorData
2512
+ } = excelSlice.actions;
2513
+ var excel_slice_default = excelSlice.reducer;
2514
+
2515
+ // src/store/reducers/form-slice/index.ts
2516
+ import { createSlice as createSlice4 } from "@reduxjs/toolkit";
2517
+ var initialState4 = {
2518
+ viewDataStore: {},
2519
+ isShowingModalDetail: false,
2520
+ isShowModalTranslate: false,
2521
+ formSubmitComponent: {},
2522
+ fieldTranslation: null,
2523
+ listSubject: {},
2524
+ dataUser: {}
2525
+ };
2526
+ var formSlice = createSlice4({
2527
+ name: "form",
2528
+ initialState: initialState4,
2529
+ reducers: {
2530
+ setViewDataStore: (state, action) => {
2531
+ state.viewDataStore = action.payload;
2532
+ },
2533
+ setIsShowingModalDetail: (state, action) => {
2534
+ state.isShowingModalDetail = action.payload;
2535
+ },
2536
+ setIsShowModalTranslate: (state, action) => {
2537
+ state.isShowModalTranslate = action.payload;
2538
+ },
2539
+ setFormSubmitComponent: (state, action) => {
2540
+ state.formSubmitComponent[action.payload.key] = action.payload.component;
2541
+ },
2542
+ setFieldTranslate: (state, action) => {
2543
+ state.fieldTranslation = action.payload;
2544
+ },
2545
+ setListSubject: (state, action) => {
2546
+ state.listSubject = action.payload;
2547
+ },
2548
+ setDataUser: (state, action) => {
2549
+ state.dataUser = action.payload;
2645
2550
  }
2646
2551
  }
2647
- let likeRegexp, ilikeRegexp;
2648
- if (["like", "not like", "ilike", "not ilike"].includes(operator)) {
2649
- likeRegexp = new RegExp(
2650
- `(.*)${escapeRegExp(value).replaceAll("%", "(.*)")}(.*)`,
2651
- "g"
2652
- );
2653
- ilikeRegexp = new RegExp(
2654
- `(.*)${escapeRegExp(value).replaceAll("%", "(.*)")}(.*)`,
2655
- "gi"
2656
- );
2657
- }
2658
- const fieldValue = typeof field === "number" ? field : record[field];
2659
- switch (operator) {
2660
- case "=?":
2661
- if ([false, null].includes(value)) {
2662
- return true;
2663
- }
2664
- // eslint-disable-next-line no-fallthrough
2665
- case "=":
2666
- case "==":
2667
- if (Array.isArray(fieldValue) && Array.isArray(value)) {
2668
- return shallowEqual2(fieldValue, value);
2669
- }
2670
- return fieldValue === value;
2671
- case "!=":
2672
- case "<>":
2673
- return !matchCondition(record, [field, "==", value]);
2674
- case "<":
2675
- return fieldValue < value;
2676
- case "<=":
2677
- return fieldValue <= value;
2678
- case ">":
2679
- return fieldValue > value;
2680
- case ">=":
2681
- return fieldValue >= value;
2682
- case "in": {
2683
- const val = Array.isArray(value) ? value : [value];
2684
- const fieldVal = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
2685
- return fieldVal.some((fv) => val.includes(fv));
2686
- }
2687
- case "not in": {
2688
- const val = Array.isArray(value) ? value : [value];
2689
- const fieldVal = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
2690
- return !fieldVal.some((fv) => val.includes(fv));
2552
+ });
2553
+ var {
2554
+ setViewDataStore,
2555
+ setIsShowingModalDetail,
2556
+ setIsShowModalTranslate,
2557
+ setFormSubmitComponent,
2558
+ setFieldTranslate,
2559
+ setListSubject,
2560
+ setDataUser
2561
+ } = formSlice.actions;
2562
+ var form_slice_default = formSlice.reducer;
2563
+
2564
+ // src/store/reducers/header-slice/index.ts
2565
+ import { createSlice as createSlice5 } from "@reduxjs/toolkit";
2566
+ var headerSlice = createSlice5({
2567
+ name: "header",
2568
+ initialState: {
2569
+ value: { allowedCompanyIds: [] }
2570
+ },
2571
+ reducers: {
2572
+ setHeader: (state, action) => {
2573
+ state.value = { ...state.value, ...action.payload };
2574
+ },
2575
+ setAllowedCompanyIds: (state, action) => {
2576
+ state.value.allowedCompanyIds = action.payload;
2691
2577
  }
2692
- case "like":
2693
- if (fieldValue === false) {
2694
- return false;
2695
- }
2696
- return Boolean(fieldValue.match(likeRegexp));
2697
- case "not like":
2698
- if (fieldValue === false) {
2699
- return false;
2700
- }
2701
- return Boolean(!fieldValue.match(likeRegexp));
2702
- case "=like":
2703
- if (fieldValue === false) {
2704
- return false;
2705
- }
2706
- return new RegExp(escapeRegExp(value).replace(/%/g, ".*")).test(
2707
- fieldValue
2708
- );
2709
- case "ilike":
2710
- if (fieldValue === false) {
2711
- return false;
2712
- }
2713
- return Boolean(fieldValue.match(ilikeRegexp));
2714
- case "not ilike":
2715
- if (fieldValue === false) {
2716
- return false;
2717
- }
2718
- return Boolean(!fieldValue.match(ilikeRegexp));
2719
- case "=ilike":
2720
- if (fieldValue === false) {
2721
- return false;
2722
- }
2723
- return new RegExp(escapeRegExp(value).replace(/%/g, ".*"), "i").test(
2724
- fieldValue
2725
- );
2726
2578
  }
2727
- throw new InvalidDomainError("could not match domain");
2728
- }
2729
- function makeOperators(record) {
2730
- const match = matchCondition.bind(null, record);
2731
- return {
2732
- "!": (x) => !match(x),
2733
- "&": (a, b) => match(a) && match(b),
2734
- "|": (a, b) => match(a) || match(b)
2735
- };
2736
- }
2737
- function matchDomain(record, domain) {
2738
- if (domain.length === 0) {
2739
- return true;
2579
+ });
2580
+ var { setAllowedCompanyIds, setHeader } = headerSlice.actions;
2581
+ var header_slice_default = headerSlice.reducer;
2582
+
2583
+ // src/store/reducers/list-slice/index.ts
2584
+ import { createSlice as createSlice6 } from "@reduxjs/toolkit";
2585
+ var initialState5 = {
2586
+ pageLimit: 10,
2587
+ fields: {},
2588
+ order: "",
2589
+ selectedRowKeys: [],
2590
+ selectedRadioKey: 0,
2591
+ indexRowTableModal: -2,
2592
+ isUpdateTableModal: false,
2593
+ footerGroupTable: {},
2594
+ transferDetail: null,
2595
+ page: 0,
2596
+ domainTable: []
2597
+ };
2598
+ var listSlice = createSlice6({
2599
+ name: "list",
2600
+ initialState: initialState5,
2601
+ reducers: {
2602
+ setPageLimit: (state, action) => {
2603
+ state.pageLimit = action.payload;
2604
+ },
2605
+ setFields: (state, action) => {
2606
+ state.fields = action.payload;
2607
+ },
2608
+ setOrder: (state, action) => {
2609
+ state.order = action.payload;
2610
+ },
2611
+ setSelectedRowKeys: (state, action) => {
2612
+ state.selectedRowKeys = action.payload;
2613
+ },
2614
+ setSelectedRadioKey: (state, action) => {
2615
+ state.selectedRadioKey = action.payload;
2616
+ },
2617
+ setIndexRowTableModal: (state, action) => {
2618
+ state.indexRowTableModal = action.payload;
2619
+ },
2620
+ setTransferDetail: (state, action) => {
2621
+ state.transferDetail = action.payload;
2622
+ },
2623
+ setIsUpdateTableModal: (state, action) => {
2624
+ state.isUpdateTableModal = action.payload;
2625
+ },
2626
+ setPage: (state, action) => {
2627
+ state.page = action.payload;
2628
+ },
2629
+ setDomainTable: (state, action) => {
2630
+ state.domainTable = action.payload;
2631
+ }
2740
2632
  }
2741
- const operators = makeOperators(record);
2742
- const reversedDomain = Array.from(domain).reverse();
2743
- const condStack = [];
2744
- for (const item of reversedDomain) {
2745
- const operator = typeof item === "string" && operators[item];
2746
- if (operator) {
2747
- const operands = condStack.splice(-operator.length);
2748
- condStack.push(operator(...operands));
2749
- } else {
2750
- condStack.push(item);
2633
+ });
2634
+ var {
2635
+ setPageLimit,
2636
+ setFields,
2637
+ setOrder,
2638
+ setSelectedRowKeys,
2639
+ setIndexRowTableModal,
2640
+ setIsUpdateTableModal,
2641
+ setPage,
2642
+ setSelectedRadioKey,
2643
+ setTransferDetail,
2644
+ setDomainTable
2645
+ } = listSlice.actions;
2646
+ var list_slice_default = listSlice.reducer;
2647
+
2648
+ // src/store/reducers/login-slice/index.ts
2649
+ import { createSlice as createSlice7 } from "@reduxjs/toolkit";
2650
+ var initialState6 = {
2651
+ db: "",
2652
+ redirectTo: "/",
2653
+ forgotPasswordUrl: "/"
2654
+ };
2655
+ var loginSlice = createSlice7({
2656
+ name: "login",
2657
+ initialState: initialState6,
2658
+ reducers: {
2659
+ setDb: (state, action) => {
2660
+ state.db = action.payload;
2661
+ },
2662
+ setRedirectTo: (state, action) => {
2663
+ state.redirectTo = action.payload;
2664
+ },
2665
+ setForgotPasswordUrl: (state, action) => {
2666
+ state.forgotPasswordUrl = action.payload;
2751
2667
  }
2752
2668
  }
2753
- return matchCondition(record, condStack.pop());
2754
- }
2669
+ });
2670
+ var { setDb, setRedirectTo, setForgotPasswordUrl } = loginSlice.actions;
2671
+ var login_slice_default = loginSlice.reducer;
2755
2672
 
2756
- // src/utils/function.ts
2757
- import { useEffect, useState } from "react";
2758
- var toQueryString = (params) => {
2759
- return Object.keys(params).map(
2760
- (key) => encodeURIComponent(key) + "=" + encodeURIComponent(params[key].toString())
2761
- ).join("&");
2673
+ // src/store/reducers/navbar-slice/index.ts
2674
+ import { createSlice as createSlice8 } from "@reduxjs/toolkit";
2675
+ var initialState7 = {
2676
+ menuFocus: {},
2677
+ menuAction: {},
2678
+ navbarWidth: 250,
2679
+ menuList: []
2762
2680
  };
2763
- var updateTokenParamInOriginalRequest = (originalRequest, newAccessToken) => {
2764
- if (!originalRequest.data) return originalRequest.data;
2765
- if (typeof originalRequest.data === "string") {
2766
- try {
2767
- const parsedData = JSON.parse(originalRequest.data);
2768
- if (parsedData.with_context && typeof parsedData.with_context === "object") {
2769
- parsedData.with_context.token = newAccessToken;
2770
- }
2771
- return JSON.stringify(parsedData);
2772
- } catch (e) {
2773
- console.warn("Failed to parse originalRequest.data", e);
2774
- return originalRequest.data;
2681
+ var navbarSlice = createSlice8({
2682
+ name: "navbar",
2683
+ initialState: initialState7,
2684
+ reducers: {
2685
+ setMenuFocus: (state, action) => {
2686
+ state.menuFocus = action.payload;
2687
+ },
2688
+ setMenuFocusAction: (state, action) => {
2689
+ state.menuAction = action.payload;
2690
+ },
2691
+ setNavbarWidth: (state, action) => {
2692
+ state.navbarWidth = action.payload;
2693
+ },
2694
+ setMenuList: (state, action) => {
2695
+ state.menuList = action.payload;
2775
2696
  }
2776
2697
  }
2777
- if (typeof originalRequest.data === "object" && originalRequest.data.with_context) {
2778
- originalRequest.data.with_context.token = newAccessToken;
2779
- }
2780
- return originalRequest.data;
2781
- };
2698
+ });
2699
+ var { setMenuFocus, setMenuFocusAction, setNavbarWidth, setMenuList } = navbarSlice.actions;
2700
+ var navbar_slice_default = navbarSlice.reducer;
2782
2701
 
2783
- // src/utils/storage/local-storage.ts
2784
- var localStorageUtils = () => {
2785
- const setToken = async (access_token) => {
2786
- localStorage.setItem("accessToken", access_token);
2787
- };
2788
- const setRefreshToken = async (refresh_token) => {
2789
- localStorage.setItem("refreshToken", refresh_token);
2790
- };
2791
- const getAccessToken = async () => {
2792
- return localStorage.getItem("accessToken");
2793
- };
2794
- const getRefreshToken = async () => {
2795
- return localStorage.getItem("refreshToken");
2796
- };
2797
- const clearToken = async () => {
2798
- localStorage.removeItem("accessToken");
2799
- localStorage.removeItem("refreshToken");
2800
- };
2801
- return {
2802
- setToken,
2803
- setRefreshToken,
2804
- getAccessToken,
2805
- getRefreshToken,
2806
- clearToken
2807
- };
2702
+ // src/store/reducers/profile-slice/index.ts
2703
+ import { createSlice as createSlice9 } from "@reduxjs/toolkit";
2704
+ var initialState8 = {
2705
+ profile: {}
2808
2706
  };
2707
+ var profileSlice = createSlice9({
2708
+ name: "profile",
2709
+ initialState: initialState8,
2710
+ reducers: {
2711
+ setProfile: (state, action) => {
2712
+ state.profile = action.payload;
2713
+ }
2714
+ }
2715
+ });
2716
+ var { setProfile } = profileSlice.actions;
2717
+ var profile_slice_default = profileSlice.reducer;
2809
2718
 
2810
- // src/utils/storage/session-storage.ts
2811
- var sessionStorageUtils = () => {
2812
- const getBrowserSession = async () => {
2813
- return sessionStorage.getItem("browserSession");
2814
- };
2815
- return {
2816
- getBrowserSession
2817
- };
2719
+ // src/store/reducers/search-slice/index.ts
2720
+ import { createSlice as createSlice10 } from "@reduxjs/toolkit";
2721
+ var initialState9 = {
2722
+ groupByDomain: null,
2723
+ searchBy: [],
2724
+ searchString: "",
2725
+ hoveredIndexSearchList: null,
2726
+ selectedTags: [],
2727
+ firstDomain: null,
2728
+ searchMap: {},
2729
+ filterBy: [],
2730
+ groupBy: []
2818
2731
  };
2819
-
2820
- // src/configs/axios-client.ts
2821
- var axiosClient = {
2822
- init(config) {
2823
- const localStorage2 = config.localStorageUtils ?? localStorageUtils();
2824
- const sessionStorage2 = config.sessionStorageUtils ?? sessionStorageUtils();
2825
- const db = config.db;
2826
- let isRefreshing = false;
2827
- let failedQueue = [];
2828
- const processQueue = (error, token = null) => {
2829
- failedQueue?.forEach((prom) => {
2830
- if (error) {
2831
- prom.reject(error);
2832
- } else {
2833
- prom.resolve(token);
2834
- }
2835
- });
2836
- failedQueue = [];
2837
- };
2838
- const instance = axios.create({
2839
- adapter: axios.defaults.adapter,
2840
- baseURL: config.baseUrl,
2841
- timeout: 5e4,
2842
- paramsSerializer: (params) => new URLSearchParams(params).toString()
2843
- });
2844
- instance.interceptors.request.use(async (config2) => {
2845
- const { useRefreshToken, useActionToken, actionToken } = config2;
2846
- if (useActionToken && actionToken) {
2847
- config2.headers["Action-Token"] = actionToken;
2848
- }
2849
- const getToken = useRefreshToken ? localStorage2.getRefreshToken : localStorage2.getAccessToken;
2850
- const token = await getToken?.();
2851
- if (token) config2.headers["Authorization"] = `Bearer ${token}`;
2852
- return config2;
2853
- }, Promise.reject);
2854
- instance.interceptors.response.use(
2855
- (response) => {
2856
- return handleResponse(response);
2857
- },
2858
- async (error) => {
2859
- const handleError3 = async (error2) => {
2860
- if (!error2.response) {
2861
- return error2;
2862
- }
2863
- const { data } = error2.response;
2864
- if (data && data.code === 400 && ["invalid_grant"].includes(data.data?.error)) {
2865
- await clearAuthToken();
2866
- }
2867
- return data;
2868
- };
2869
- const originalRequest = error.config;
2870
- if ((error.response?.status === 403 || error.response?.status === 401 || error.response?.status === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401, "ERR_2FA_006"].includes(
2871
- error.response.data.code
2872
- )) {
2873
- if (isRefreshing) {
2874
- return new Promise(function(resolve, reject) {
2875
- failedQueue.push({ resolve, reject });
2876
- }).then((token) => {
2877
- originalRequest.headers["Authorization"] = "Bearer " + token;
2878
- originalRequest.data = updateTokenParamInOriginalRequest(
2879
- originalRequest,
2880
- token
2881
- );
2882
- return instance.request(originalRequest);
2883
- }).catch(async (err) => {
2884
- if ((err.response?.status === 400 || err.response?.status === 401) && ["invalid_grant"].includes(err.response.data.error)) {
2885
- await clearAuthToken();
2886
- }
2887
- });
2888
- }
2889
- const browserSession = await sessionStorage2.getBrowserSession();
2890
- const refreshToken = await localStorage2.getRefreshToken();
2891
- const accessTokenExp = await localStorage2.getAccessToken();
2892
- isRefreshing = true;
2893
- if (!refreshToken && (!browserSession || browserSession == "unActive")) {
2894
- await clearAuthToken();
2895
- } else {
2896
- const payload = Object.fromEntries(
2897
- Object.entries({
2898
- refresh_token: refreshToken,
2899
- grant_type: "refresh_token",
2900
- client_id: config.config.clientId,
2901
- client_secret: config.config.clientSecret
2902
- }).filter(([_, value]) => !!value)
2903
- );
2904
- return new Promise(function(resolve) {
2905
- axios.post(
2906
- `${config.baseUrl}${config.refreshTokenEndpoint ?? "/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
2907
- payload,
2908
- {
2909
- headers: {
2910
- "Content-Type": config.refreshTokenEndpoint ? "application/x-www-form-urlencoded" : "multipart/form-data",
2911
- Authorization: `Bearer ${accessTokenExp}`
2912
- }
2913
- }
2914
- ).then(async (res) => {
2915
- const data = res.data;
2916
- await localStorage2.setToken(data.access_token);
2917
- await localStorage2.setRefreshToken(data.refresh_token);
2918
- axios.defaults.headers.common["Authorization"] = "Bearer " + data.access_token;
2919
- originalRequest.headers["Authorization"] = "Bearer " + data.access_token;
2920
- originalRequest.data = updateTokenParamInOriginalRequest(
2921
- originalRequest,
2922
- data.access_token
2923
- );
2924
- processQueue(null, data.access_token);
2925
- resolve(instance.request(originalRequest));
2926
- }).catch(async (err) => {
2927
- if (err && (err?.error_code === "AUTHEN_FAIL" || err?.error_code === "TOKEN_EXPIRED" || err?.error_code === "TOKEN_INCORRECT" || err?.code === "ERR_BAD_REQUEST") || err?.error_code === "ERR_2FA_006") {
2928
- await clearAuthToken();
2929
- }
2930
- if (err && err.response) {
2931
- const { error_code } = err.response?.data || {};
2932
- if (error_code === "AUTHEN_FAIL") {
2933
- await clearAuthToken();
2934
- }
2935
- }
2936
- processQueue(err, null);
2937
- }).finally(() => {
2938
- isRefreshing = false;
2939
- });
2940
- });
2941
- }
2942
- }
2943
- return Promise.reject(await handleError3(error));
2944
- }
2945
- );
2946
- const handleResponse = (res) => {
2947
- if (res && res.data) {
2948
- return res.data;
2732
+ var searchSlice = createSlice10({
2733
+ name: "search",
2734
+ initialState: initialState9,
2735
+ reducers: {
2736
+ setGroupByDomain: (state, action) => {
2737
+ state.groupByDomain = action.payload;
2738
+ },
2739
+ setSearchBy: (state, action) => {
2740
+ state.searchBy = action.payload;
2741
+ },
2742
+ setSearchString: (state, action) => {
2743
+ state.searchString = action.payload;
2744
+ },
2745
+ setHoveredIndexSearchList: (state, action) => {
2746
+ state.hoveredIndexSearchList = action.payload;
2747
+ },
2748
+ setSelectedTags: (state, action) => {
2749
+ state.selectedTags = action.payload;
2750
+ },
2751
+ setFirstDomain: (state, action) => {
2752
+ state.firstDomain = action.payload;
2753
+ },
2754
+ setFilterBy: (state, action) => {
2755
+ state.filterBy = action.payload;
2756
+ },
2757
+ setGroupBy: (state, action) => {
2758
+ state.groupBy = action.payload;
2759
+ },
2760
+ setSearchMap: (state, action) => {
2761
+ state.searchMap = action.payload;
2762
+ },
2763
+ updateSearchMap: (state, action) => {
2764
+ if (!state.searchMap[action.payload.key]) {
2765
+ state.searchMap[action.payload.key] = [];
2949
2766
  }
2950
- return res;
2951
- };
2952
- const handleError2 = (error) => {
2953
- if (error.isAxiosError && error.code === "ECONNABORTED") {
2954
- console.error("Request Timeout Error:", error);
2955
- return "Request Timeout Error";
2956
- } else if (error.isAxiosError && !error.response) {
2957
- console.error("Network Error:", error);
2958
- return "Network Error";
2767
+ state.searchMap[action.payload.key].push(action.payload.value);
2768
+ },
2769
+ removeKeyFromSearchMap: (state, action) => {
2770
+ const { key, item } = action.payload;
2771
+ const values = state.searchMap[key];
2772
+ if (!values) return;
2773
+ if (item) {
2774
+ const filtered = values.filter((value) => value.name !== item.name);
2775
+ if (filtered.length > 0) {
2776
+ state.searchMap[key] = filtered;
2777
+ } else {
2778
+ delete state.searchMap[key];
2779
+ }
2959
2780
  } else {
2960
- console.error("Other Error:", error?.response);
2961
- const errorMessage = error?.response?.data?.message || "An error occurred";
2962
- return { message: errorMessage, status: error?.response?.status };
2963
- }
2964
- };
2965
- const clearAuthToken = async () => {
2966
- await localStorage2.clearToken();
2967
- if (typeof window !== "undefined") {
2968
- window.location.href = `/login`;
2781
+ delete state.searchMap[key];
2969
2782
  }
2970
- };
2971
- function formatUrl(url, db2) {
2972
- return url + (db2 ? "?db=" + db2 : "");
2783
+ },
2784
+ clearSearchMap: (state) => {
2785
+ state.searchMap = {};
2973
2786
  }
2974
- const responseBody = (response) => response;
2975
- const requests = {
2976
- get: (url, headers) => instance.get(formatUrl(url, db), headers).then(responseBody),
2977
- post: (url, body, headers) => instance.post(formatUrl(url, db), body, headers).then(responseBody),
2978
- post_excel: (url, body, headers) => instance.post(formatUrl(url, db), body, {
2979
- responseType: "arraybuffer",
2980
- headers: {
2981
- "Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
2982
- Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
2983
- }
2984
- }).then(responseBody),
2985
- put: (url, body, headers) => instance.put(formatUrl(url, db), body, headers).then(responseBody),
2986
- patch: (url, body) => instance.patch(formatUrl(url, db), body).then(responseBody),
2987
- delete: (url, body) => instance.delete(formatUrl(url, db), body).then(responseBody)
2988
- };
2989
- return requests;
2990
2787
  }
2788
+ });
2789
+ var {
2790
+ setGroupByDomain,
2791
+ setSelectedTags,
2792
+ setSearchString,
2793
+ setHoveredIndexSearchList,
2794
+ setFirstDomain,
2795
+ setSearchBy,
2796
+ setFilterBy,
2797
+ setSearchMap,
2798
+ updateSearchMap,
2799
+ removeKeyFromSearchMap,
2800
+ setGroupBy,
2801
+ clearSearchMap
2802
+ } = searchSlice.actions;
2803
+ var search_slice_default = searchSlice.reducer;
2804
+
2805
+ // src/store/store.ts
2806
+ import { configureStore } from "@reduxjs/toolkit";
2807
+
2808
+ // node_modules/redux/dist/redux.mjs
2809
+ function formatProdErrorMessage(code) {
2810
+ 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. `;
2811
+ }
2812
+ var randomString = () => Math.random().toString(36).substring(7).split("").join(".");
2813
+ var ActionTypes = {
2814
+ INIT: `@@redux/INIT${/* @__PURE__ */ randomString()}`,
2815
+ REPLACE: `@@redux/REPLACE${/* @__PURE__ */ randomString()}`,
2816
+ PROBE_UNKNOWN_ACTION: () => `@@redux/PROBE_UNKNOWN_ACTION${randomString()}`
2991
2817
  };
2818
+ var actionTypes_default = ActionTypes;
2819
+ function isPlainObject(obj) {
2820
+ if (typeof obj !== "object" || obj === null)
2821
+ return false;
2822
+ let proto = obj;
2823
+ while (Object.getPrototypeOf(proto) !== null) {
2824
+ proto = Object.getPrototypeOf(proto);
2825
+ }
2826
+ return Object.getPrototypeOf(obj) === proto || Object.getPrototypeOf(obj) === null;
2827
+ }
2828
+ function miniKindOf(val) {
2829
+ if (val === void 0)
2830
+ return "undefined";
2831
+ if (val === null)
2832
+ return "null";
2833
+ const type = typeof val;
2834
+ switch (type) {
2835
+ case "boolean":
2836
+ case "string":
2837
+ case "number":
2838
+ case "symbol":
2839
+ case "function": {
2840
+ return type;
2841
+ }
2842
+ }
2843
+ if (Array.isArray(val))
2844
+ return "array";
2845
+ if (isDate(val))
2846
+ return "date";
2847
+ if (isError(val))
2848
+ return "error";
2849
+ const constructorName = ctorName(val);
2850
+ switch (constructorName) {
2851
+ case "Symbol":
2852
+ case "Promise":
2853
+ case "WeakMap":
2854
+ case "WeakSet":
2855
+ case "Map":
2856
+ case "Set":
2857
+ return constructorName;
2858
+ }
2859
+ return Object.prototype.toString.call(val).slice(8, -1).toLowerCase().replace(/\s/g, "");
2860
+ }
2861
+ function ctorName(val) {
2862
+ return typeof val.constructor === "function" ? val.constructor.name : null;
2863
+ }
2864
+ function isError(val) {
2865
+ return val instanceof Error || typeof val.message === "string" && val.constructor && typeof val.constructor.stackTraceLimit === "number";
2866
+ }
2867
+ function isDate(val) {
2868
+ if (val instanceof Date)
2869
+ return true;
2870
+ return typeof val.toDateString === "function" && typeof val.getDate === "function" && typeof val.setDate === "function";
2871
+ }
2872
+ function kindOf(val) {
2873
+ let typeOfVal = typeof val;
2874
+ if (process.env.NODE_ENV !== "production") {
2875
+ typeOfVal = miniKindOf(val);
2876
+ }
2877
+ return typeOfVal;
2878
+ }
2879
+ function warning(message) {
2880
+ if (typeof console !== "undefined" && typeof console.error === "function") {
2881
+ console.error(message);
2882
+ }
2883
+ try {
2884
+ throw new Error(message);
2885
+ } catch (e) {
2886
+ }
2887
+ }
2888
+ function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
2889
+ const reducerKeys = Object.keys(reducers);
2890
+ const argumentName = action && action.type === actionTypes_default.INIT ? "preloadedState argument passed to createStore" : "previous state received by the reducer";
2891
+ if (reducerKeys.length === 0) {
2892
+ return "Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";
2893
+ }
2894
+ if (!isPlainObject(inputState)) {
2895
+ return `The ${argumentName} has unexpected type of "${kindOf(inputState)}". Expected argument to be an object with the following keys: "${reducerKeys.join('", "')}"`;
2896
+ }
2897
+ const unexpectedKeys = Object.keys(inputState).filter((key) => !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key]);
2898
+ unexpectedKeys.forEach((key) => {
2899
+ unexpectedKeyCache[key] = true;
2900
+ });
2901
+ if (action && action.type === actionTypes_default.REPLACE)
2902
+ return;
2903
+ if (unexpectedKeys.length > 0) {
2904
+ 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.`;
2905
+ }
2906
+ }
2907
+ function assertReducerShape(reducers) {
2908
+ Object.keys(reducers).forEach((key) => {
2909
+ const reducer = reducers[key];
2910
+ const initialState10 = reducer(void 0, {
2911
+ type: actionTypes_default.INIT
2912
+ });
2913
+ if (typeof initialState10 === "undefined") {
2914
+ 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.`);
2915
+ }
2916
+ if (typeof reducer(void 0, {
2917
+ type: actionTypes_default.PROBE_UNKNOWN_ACTION()
2918
+ }) === "undefined") {
2919
+ 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.`);
2920
+ }
2921
+ });
2922
+ }
2923
+ function combineReducers(reducers) {
2924
+ const reducerKeys = Object.keys(reducers);
2925
+ const finalReducers = {};
2926
+ for (let i = 0; i < reducerKeys.length; i++) {
2927
+ const key = reducerKeys[i];
2928
+ if (process.env.NODE_ENV !== "production") {
2929
+ if (typeof reducers[key] === "undefined") {
2930
+ warning(`No reducer provided for key "${key}"`);
2931
+ }
2932
+ }
2933
+ if (typeof reducers[key] === "function") {
2934
+ finalReducers[key] = reducers[key];
2935
+ }
2936
+ }
2937
+ const finalReducerKeys = Object.keys(finalReducers);
2938
+ let unexpectedKeyCache;
2939
+ if (process.env.NODE_ENV !== "production") {
2940
+ unexpectedKeyCache = {};
2941
+ }
2942
+ let shapeAssertionError;
2943
+ try {
2944
+ assertReducerShape(finalReducers);
2945
+ } catch (e) {
2946
+ shapeAssertionError = e;
2947
+ }
2948
+ return function combination(state = {}, action) {
2949
+ if (shapeAssertionError) {
2950
+ throw shapeAssertionError;
2951
+ }
2952
+ if (process.env.NODE_ENV !== "production") {
2953
+ const warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
2954
+ if (warningMessage) {
2955
+ warning(warningMessage);
2956
+ }
2957
+ }
2958
+ let hasChanged = false;
2959
+ const nextState = {};
2960
+ for (let i = 0; i < finalReducerKeys.length; i++) {
2961
+ const key = finalReducerKeys[i];
2962
+ const reducer = finalReducers[key];
2963
+ const previousStateForKey = state[key];
2964
+ const nextStateForKey = reducer(previousStateForKey, action);
2965
+ if (typeof nextStateForKey === "undefined") {
2966
+ const actionType = action && action.type;
2967
+ 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.`);
2968
+ }
2969
+ nextState[key] = nextStateForKey;
2970
+ hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
2971
+ }
2972
+ hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
2973
+ return hasChanged ? nextState : state;
2974
+ };
2975
+ }
2992
2976
 
2993
- // src/store/index.ts
2994
- import { useDispatch, useSelector } from "react-redux";
2977
+ // src/store/store.ts
2978
+ var rootReducer = combineReducers({
2979
+ env: env_slice_default,
2980
+ header: header_slice_default,
2981
+ navbar: navbar_slice_default,
2982
+ list: list_slice_default,
2983
+ search: search_slice_default,
2984
+ form: form_slice_default,
2985
+ breadcrumbs: breadcrums_slice_default,
2986
+ login: login_slice_default,
2987
+ excel: excel_slice_default,
2988
+ profile: profile_slice_default
2989
+ });
2990
+ var envStore = configureStore({
2991
+ reducer: rootReducer,
2992
+ middleware: (getDefaultMiddleware) => getDefaultMiddleware({
2993
+ serializableCheck: false
2994
+ })
2995
+ });
2995
2996
 
2996
2997
  // src/environment/EnvStore.ts
2997
- var EnvStore = class {
2998
+ var EnvStore = class _EnvStore {
2999
+ static instance = null;
3000
+ envStore;
2998
3001
  baseUrl;
2999
3002
  requests;
3000
3003
  context;
@@ -3006,76 +3009,83 @@ var EnvStore = class {
3006
3009
  localStorageUtils;
3007
3010
  sessionStorageUtils;
3008
3011
  refreshTokenEndpoint;
3009
- constructor(localStorageUtils2, sessionStorageUtils2) {
3012
+ constructor(envStore2, localStorageUtils2, sessionStorageUtils2) {
3013
+ this.envStore = envStore2;
3010
3014
  this.localStorageUtils = localStorageUtils2;
3011
3015
  this.sessionStorageUtils = sessionStorageUtils2;
3012
3016
  this.setup();
3013
3017
  }
3018
+ static getInstance(envStore2, localStorageUtils2, sessionStorageUtils2) {
3019
+ if (!_EnvStore.instance) {
3020
+ _EnvStore.instance = new _EnvStore(
3021
+ envStore2,
3022
+ localStorageUtils2,
3023
+ sessionStorageUtils2
3024
+ );
3025
+ }
3026
+ return _EnvStore.instance;
3027
+ }
3014
3028
  setup() {
3015
- const env2 = envStore.getState().env;
3016
- this.baseUrl = env2?.baseUrl;
3017
- this.context = env2?.context;
3018
- this.defaultCompany = env2?.defaultCompany;
3019
- this.config = env2?.config;
3020
- this.companies = env2?.companies || [];
3021
- this.user = env2?.user;
3022
- this.db = env2?.db;
3023
- this.requests = env2?.requests;
3024
- this.refreshTokenEndpoint = env2?.refreshTokenEndpoint;
3029
+ const env = this.envStore.getState().env;
3030
+ this.baseUrl = env?.baseUrl;
3031
+ this.requests = env?.requests;
3032
+ this.context = env?.context;
3033
+ this.defaultCompany = env?.defaultCompany;
3034
+ this.config = env?.config;
3035
+ this.companies = env?.companies || [];
3036
+ this.user = env?.user;
3037
+ this.db = env?.db;
3038
+ this.refreshTokenEndpoint = env?.refreshTokenEndpoint;
3039
+ console.log("Env setup:", this);
3025
3040
  }
3026
3041
  setupEnv(envConfig) {
3027
- let env2 = {
3042
+ const dispatch = this.envStore.dispatch;
3043
+ const env = {
3028
3044
  ...envConfig,
3029
3045
  localStorageUtils: this.localStorageUtils,
3030
3046
  sessionStorageUtils: this.sessionStorageUtils
3031
3047
  };
3032
- const requests = axiosClient.init(env2);
3033
- this.requests = requests;
3034
- const dispatch = envStore.dispatch;
3035
- dispatch(
3036
- setEnv({
3037
- ...env2,
3038
- requests
3039
- })
3040
- );
3048
+ const requests = axiosClient.init(env);
3049
+ dispatch(setEnv({ ...env, requests }));
3041
3050
  this.setup();
3042
- return { ...env2, requests };
3043
3051
  }
3044
3052
  setUid(uid) {
3045
- const dispatch = envStore.dispatch;
3053
+ const dispatch = this.envStore.dispatch;
3046
3054
  dispatch(setUid(uid));
3047
3055
  this.setup();
3048
3056
  }
3049
3057
  setLang(lang) {
3050
- const dispatch = envStore.dispatch;
3058
+ const dispatch = this.envStore.dispatch;
3051
3059
  dispatch(setLang(lang));
3052
3060
  this.setup();
3053
3061
  }
3054
3062
  setAllowCompanies(allowCompanies) {
3055
- const dispatch = envStore.dispatch;
3063
+ const dispatch = this.envStore.dispatch;
3056
3064
  dispatch(setAllowCompanies(allowCompanies));
3057
3065
  this.setup();
3058
3066
  }
3059
3067
  setCompanies(companies) {
3060
- const dispatch = envStore.dispatch;
3068
+ const dispatch = this.envStore.dispatch;
3061
3069
  dispatch(setCompanies(companies));
3062
3070
  this.setup();
3063
3071
  }
3064
3072
  setDefaultCompany(company) {
3065
- const dispatch = envStore.dispatch;
3073
+ const dispatch = this.envStore.dispatch;
3066
3074
  dispatch(setDefaultCompany(company));
3067
3075
  this.setup();
3068
3076
  }
3069
3077
  setUserInfo(userInfo) {
3070
- const dispatch = envStore.dispatch;
3078
+ const dispatch = this.envStore.dispatch;
3071
3079
  dispatch(setUser(userInfo));
3072
3080
  this.setup();
3073
3081
  }
3074
3082
  };
3075
- var env = null;
3076
3083
  function getEnv() {
3077
- if (!env) env = new EnvStore(localStorageUtils(), sessionStorageUtils());
3078
- return env;
3084
+ const instance = EnvStore.getInstance(envStore);
3085
+ if (!instance) {
3086
+ throw new Error("EnvStore has not been initialized \u2014 call initEnv() first");
3087
+ }
3088
+ return instance;
3079
3089
  }
3080
3090
 
3081
3091
  // src/services/action-service/index.ts
@@ -3085,14 +3095,14 @@ var ActionService = {
3085
3095
  idAction,
3086
3096
  context
3087
3097
  }) {
3088
- const env2 = getEnv();
3098
+ const env = getEnv();
3089
3099
  const jsonData = {
3090
3100
  action_id: idAction,
3091
3101
  with_context: {
3092
3102
  ...context
3093
3103
  }
3094
3104
  };
3095
- return env2.requests.post(`${"/load_action" /* LOAD_ACTION */}`, jsonData, {
3105
+ return env.requests.post(`${"/load_action" /* LOAD_ACTION */}`, jsonData, {
3096
3106
  headers: {
3097
3107
  "Content-Type": "application/json"
3098
3108
  }
@@ -3106,14 +3116,14 @@ var ActionService = {
3106
3116
  method
3107
3117
  }) {
3108
3118
  try {
3109
- const env2 = getEnv();
3119
+ const env = getEnv();
3110
3120
  const jsonData = {
3111
3121
  model,
3112
3122
  method,
3113
3123
  ids,
3114
3124
  with_context: context
3115
3125
  };
3116
- return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3126
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3117
3127
  headers: {
3118
3128
  "Content-Type": "application/json"
3119
3129
  }
@@ -3129,14 +3139,14 @@ var ActionService = {
3129
3139
  ids,
3130
3140
  context
3131
3141
  }) {
3132
- const env2 = getEnv();
3142
+ const env = getEnv();
3133
3143
  const jsonData = {
3134
3144
  model,
3135
3145
  method: "unlink",
3136
3146
  ids,
3137
3147
  with_context: context
3138
3148
  };
3139
- return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3149
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3140
3150
  headers: {
3141
3151
  "Content-Type": "application/json"
3142
3152
  }
@@ -3148,14 +3158,14 @@ var ActionService = {
3148
3158
  id,
3149
3159
  context
3150
3160
  }) {
3151
- const env2 = getEnv();
3161
+ const env = getEnv();
3152
3162
  const jsonData = {
3153
3163
  model,
3154
3164
  method: "copy",
3155
3165
  ids: id,
3156
3166
  with_context: context
3157
3167
  };
3158
- return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3168
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3159
3169
  headers: {
3160
3170
  "Content-Type": "application/json"
3161
3171
  }
@@ -3163,7 +3173,7 @@ var ActionService = {
3163
3173
  },
3164
3174
  // Get Print Report
3165
3175
  async getPrintReportName({ id }) {
3166
- const env2 = getEnv();
3176
+ const env = getEnv();
3167
3177
  const jsonData = {
3168
3178
  model: "ir.actions.report",
3169
3179
  method: "web_read",
@@ -3174,7 +3184,7 @@ var ActionService = {
3174
3184
  }
3175
3185
  }
3176
3186
  };
3177
- return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3187
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3178
3188
  headers: {
3179
3189
  "Content-Type": "application/json"
3180
3190
  }
@@ -3182,7 +3192,7 @@ var ActionService = {
3182
3192
  },
3183
3193
  //Save Print Invoice
3184
3194
  async print({ id, report, db }) {
3185
- const env2 = getEnv();
3195
+ const env = getEnv();
3186
3196
  const jsonData = {
3187
3197
  report,
3188
3198
  id,
@@ -3192,7 +3202,7 @@ var ActionService = {
3192
3202
  };
3193
3203
  const queryString = toQueryString(jsonData);
3194
3204
  const urlWithParams = `${"/report" /* REPORT_PATH */}?${queryString}`;
3195
- return env2.requests.get(urlWithParams, {
3205
+ return env.requests.get(urlWithParams, {
3196
3206
  headers: {
3197
3207
  "Content-Type": "application/json"
3198
3208
  },
@@ -3204,7 +3214,7 @@ var ActionService = {
3204
3214
  idAction,
3205
3215
  context
3206
3216
  }) {
3207
- const env2 = getEnv();
3217
+ const env = getEnv();
3208
3218
  const jsonData = {
3209
3219
  action_id: idAction,
3210
3220
  with_context: {
@@ -3220,7 +3230,7 @@ var ActionService = {
3220
3230
  // active_model: model,
3221
3231
  // },
3222
3232
  };
3223
- return env2.requests.post(`${"/run_action" /* RUN_ACTION_PATH */}`, jsonData, {
3233
+ return env.requests.post(`${"/run_action" /* RUN_ACTION_PATH */}`, jsonData, {
3224
3234
  headers: {
3225
3235
  "Content-Type": "application/json"
3226
3236
  }
@@ -3232,30 +3242,30 @@ var action_service_default = ActionService;
3232
3242
  // src/services/auth-service/index.ts
3233
3243
  var AuthService = {
3234
3244
  async login(body) {
3235
- const env2 = getEnv();
3245
+ const env = getEnv();
3236
3246
  const payload = Object.fromEntries(
3237
3247
  Object.entries({
3238
3248
  username: body.email,
3239
3249
  password: body.password,
3240
- grant_type: env2?.config?.grantType || "",
3241
- client_id: env2?.config?.clientId || "",
3242
- client_secret: env2?.config?.clientSecret || ""
3250
+ grant_type: env?.config?.grantType || "",
3251
+ client_id: env?.config?.clientId || "",
3252
+ client_secret: env?.config?.clientSecret || ""
3243
3253
  }).filter(([_, value]) => !!value)
3244
3254
  );
3245
3255
  const encodedData = new URLSearchParams(payload).toString();
3246
- return env2?.requests?.post(body.path, encodedData, {
3256
+ return env?.requests?.post(body.path, encodedData, {
3247
3257
  headers: {
3248
3258
  "Content-Type": "application/x-www-form-urlencoded"
3249
3259
  }
3250
3260
  });
3251
3261
  },
3252
3262
  async forgotPassword(email) {
3253
- const env2 = getEnv();
3263
+ const env = getEnv();
3254
3264
  const bodyData = {
3255
3265
  login: email,
3256
3266
  url: `${window.location.origin}/reset-password`
3257
3267
  };
3258
- return env2?.requests?.post("/reset_password" /* RESET_PASSWORD_PATH */, bodyData, {
3268
+ return env?.requests?.post("/reset_password" /* RESET_PASSWORD_PATH */, bodyData, {
3259
3269
  headers: {
3260
3270
  "Content-Type": "application/json"
3261
3271
  }
@@ -3266,7 +3276,7 @@ var AuthService = {
3266
3276
  with_context,
3267
3277
  method
3268
3278
  }) {
3269
- const env2 = getEnv();
3279
+ const env = getEnv();
3270
3280
  const body = {
3271
3281
  method,
3272
3282
  kwargs: {
@@ -3276,20 +3286,20 @@ var AuthService = {
3276
3286
  },
3277
3287
  with_context
3278
3288
  };
3279
- return env2?.requests?.post("/call" /* CALL_PATH */, body, {
3289
+ return env?.requests?.post("/call" /* CALL_PATH */, body, {
3280
3290
  headers: {
3281
3291
  "Content-Type": "application/json"
3282
3292
  }
3283
3293
  });
3284
3294
  },
3285
3295
  async resetPassword(data, token) {
3286
- const env2 = getEnv();
3296
+ const env = getEnv();
3287
3297
  const bodyData = {
3288
3298
  token,
3289
3299
  password: data.password,
3290
3300
  new_password: data.confirmPassword
3291
3301
  };
3292
- return env2?.requests?.post("/change_password" /* CHANGE_PASSWORD_PATH */, bodyData, {
3302
+ return env?.requests?.post("/change_password" /* CHANGE_PASSWORD_PATH */, bodyData, {
3293
3303
  headers: {
3294
3304
  "Content-Type": "application/json"
3295
3305
  }
@@ -3300,7 +3310,7 @@ var AuthService = {
3300
3310
  password,
3301
3311
  with_context
3302
3312
  }) {
3303
- const env2 = getEnv();
3313
+ const env = getEnv();
3304
3314
  const bodyData = {
3305
3315
  method,
3306
3316
  kwargs: {
@@ -3310,57 +3320,43 @@ var AuthService = {
3310
3320
  },
3311
3321
  with_context
3312
3322
  };
3313
- return env2?.requests?.post("/call" /* CALL_PATH */, bodyData, {
3323
+ return env?.requests?.post("/call" /* CALL_PATH */, bodyData, {
3314
3324
  headers: {
3315
3325
  "Content-Type": "application/json"
3316
3326
  }
3317
3327
  });
3318
3328
  },
3319
3329
  async updatePassword(data, token) {
3320
- const env2 = getEnv();
3330
+ const env = getEnv();
3321
3331
  const bodyData = {
3322
3332
  token,
3323
3333
  old_password: data.oldPassword,
3324
3334
  new_password: data.newPassword
3325
3335
  };
3326
- return env2?.requests?.post("/change_password_parent" /* UPDATE_PASSWORD_PATH */, bodyData, {
3336
+ return env?.requests?.post("/change_password_parent" /* UPDATE_PASSWORD_PATH */, bodyData, {
3327
3337
  headers: {
3328
3338
  "Content-Type": "application/json"
3329
3339
  }
3330
3340
  });
3331
3341
  },
3332
3342
  async isValidToken(token) {
3333
- const env2 = getEnv();
3343
+ const env = getEnv();
3334
3344
  const bodyData = {
3335
3345
  token
3336
3346
  };
3337
- return env2?.requests?.post("/check_token" /* TOKEN */, bodyData, {
3347
+ return env?.requests?.post("/check_token" /* TOKEN */, bodyData, {
3338
3348
  headers: {
3339
3349
  "Content-Type": "application/json"
3340
3350
  }
3341
3351
  });
3342
3352
  },
3343
- async isValidActionToken(actionToken, path) {
3344
- const env2 = getEnv();
3345
- return env2?.requests?.post(
3346
- path,
3347
- {},
3348
- {
3349
- headers: {
3350
- "Content-Type": "application/json"
3351
- },
3352
- useActionToken: true,
3353
- actionToken
3354
- }
3355
- );
3356
- },
3357
3353
  async loginSocial({
3358
3354
  db,
3359
3355
  state,
3360
3356
  access_token
3361
3357
  }) {
3362
- const env2 = getEnv();
3363
- return env2?.requests?.post(
3358
+ const env = getEnv();
3359
+ return env?.requests?.post(
3364
3360
  "/token/generate" /* GENTOKEN_SOCIAL */,
3365
3361
  { state, access_token },
3366
3362
  {
@@ -3371,18 +3367,18 @@ var AuthService = {
3371
3367
  );
3372
3368
  },
3373
3369
  async getProviders(db) {
3374
- const env2 = getEnv();
3375
- return env2?.requests?.get("/oauth/providers", { params: { db } });
3370
+ const env = getEnv();
3371
+ return env?.requests?.get("/oauth/providers", { params: { db } });
3376
3372
  },
3377
3373
  async getAccessByCode(code) {
3378
- const env2 = getEnv();
3374
+ const env = getEnv();
3379
3375
  const data = new URLSearchParams();
3380
3376
  data.append("code", code);
3381
3377
  data.append("grant_type", "authorization_code");
3382
- data.append("client_id", env2?.config?.clientId || "");
3383
- data.append("redirect_uri", env2?.config?.redirectUri || "");
3384
- return env2?.requests?.post(
3385
- `${env2?.baseUrl?.replace("/mms/", "/id/")}/${"/token" /* TOKEN_BY_CODE */}`,
3378
+ data.append("client_id", env?.config?.clientId || "");
3379
+ data.append("redirect_uri", env?.config?.redirectUri || "");
3380
+ return env?.requests?.post(
3381
+ `${env?.baseUrl?.replace("/mms/", "/id/")}/${"/token" /* TOKEN_BY_CODE */}`,
3386
3382
  data,
3387
3383
  {
3388
3384
  headers: {
@@ -3392,9 +3388,9 @@ var AuthService = {
3392
3388
  );
3393
3389
  },
3394
3390
  async logout(data) {
3395
- const env2 = getEnv();
3391
+ const env = getEnv();
3396
3392
  console.log(data);
3397
- return env2?.requests?.post(
3393
+ return env?.requests?.post(
3398
3394
  "/logout" /* LOGOUT */,
3399
3395
  {},
3400
3396
  {
@@ -3412,15 +3408,15 @@ var auth_service_default = AuthService;
3412
3408
  // src/services/company-service/index.ts
3413
3409
  var CompanyService = {
3414
3410
  async getCurrentCompany() {
3415
- const env2 = getEnv();
3416
- return await env2.requests.get("/company" /* COMPANY_PATH */, {
3411
+ const env = getEnv();
3412
+ return await env.requests.get("/company" /* COMPANY_PATH */, {
3417
3413
  headers: {
3418
3414
  "Content-Type": "application/json"
3419
3415
  }
3420
3416
  });
3421
3417
  },
3422
3418
  async getInfoCompany(id) {
3423
- const env2 = getEnv();
3419
+ const env = getEnv();
3424
3420
  const jsonData = {
3425
3421
  ids: [id],
3426
3422
  model: "res.company" /* COMPANY */,
@@ -3435,7 +3431,7 @@ var CompanyService = {
3435
3431
  }
3436
3432
  }
3437
3433
  };
3438
- return await env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3434
+ return await env?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3439
3435
  headers: {
3440
3436
  "Content-Type": "application/json"
3441
3437
  }
@@ -3447,16 +3443,16 @@ var company_service_default = CompanyService;
3447
3443
  // src/services/excel-service/index.ts
3448
3444
  var ExcelService = {
3449
3445
  async uploadFile({ formData }) {
3450
- const env2 = getEnv();
3451
- return env2.requests.post(`${"/upload/file" /* UPLOAD_FILE_PATH */}`, formData, {
3446
+ const env = getEnv();
3447
+ return env.requests.post(`${"/upload/file" /* UPLOAD_FILE_PATH */}`, formData, {
3452
3448
  headers: {
3453
3449
  "Content-Type": "multipart/form-data"
3454
3450
  }
3455
3451
  });
3456
3452
  },
3457
3453
  async uploadIdFile({ formData }) {
3458
- const env2 = getEnv();
3459
- return env2.requests.post(`${"/upload/file" /* UPLOAD_FILE_PATH */}`, formData, {
3454
+ const env = getEnv();
3455
+ return env.requests.post(`${"/upload/file" /* UPLOAD_FILE_PATH */}`, formData, {
3460
3456
  headers: {
3461
3457
  "Content-Type": "multipart/form-data"
3462
3458
  }
@@ -3468,7 +3464,7 @@ var ExcelService = {
3468
3464
  isHeader,
3469
3465
  context
3470
3466
  }) {
3471
- const env2 = getEnv();
3467
+ const env = getEnv();
3472
3468
  const jsonData = {
3473
3469
  model: "base_import.import" /* BASE_IMPORT */,
3474
3470
  method: "parse_preview",
@@ -3498,7 +3494,7 @@ var ExcelService = {
3498
3494
  },
3499
3495
  with_context: context
3500
3496
  };
3501
- return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3497
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3502
3498
  headers: {
3503
3499
  "Content-Type": "multipart/form-data"
3504
3500
  }
@@ -3512,7 +3508,7 @@ var ExcelService = {
3512
3508
  dryrun,
3513
3509
  context
3514
3510
  }) {
3515
- const env2 = getEnv();
3511
+ const env = getEnv();
3516
3512
  const jsonData = {
3517
3513
  model: "base_import.import" /* BASE_IMPORT */,
3518
3514
  method: "execute_import",
@@ -3525,20 +3521,20 @@ var ExcelService = {
3525
3521
  },
3526
3522
  with_context: context
3527
3523
  };
3528
- return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3524
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3529
3525
  headers: {
3530
3526
  "Content-Type": "multipart/form-data"
3531
3527
  }
3532
3528
  });
3533
3529
  },
3534
3530
  async getFileExcel({ model }) {
3535
- const env2 = getEnv();
3531
+ const env = getEnv();
3536
3532
  const jsonData = {
3537
3533
  model,
3538
3534
  method: "get_import_templates" /* GET_IMPORT */,
3539
3535
  args: []
3540
3536
  };
3541
- return env2.requests.post("/call" /* CALL_PATH */, jsonData);
3537
+ return env.requests.post("/call" /* CALL_PATH */, jsonData);
3542
3538
  },
3543
3539
  async getFieldExport({
3544
3540
  ids,
@@ -3552,7 +3548,7 @@ var ExcelService = {
3552
3548
  context,
3553
3549
  importCompat
3554
3550
  }) {
3555
- const env2 = getEnv();
3551
+ const env = getEnv();
3556
3552
  const jsonData = {
3557
3553
  model,
3558
3554
  import_compat: importCompat,
@@ -3567,7 +3563,7 @@ var ExcelService = {
3567
3563
  jsonData.prefix = prefix;
3568
3564
  jsonData.exclude = [null];
3569
3565
  }
3570
- return env2.requests.post("/export/get_fields", jsonData);
3566
+ return env.requests.post("/export/get_fields", jsonData);
3571
3567
  },
3572
3568
  async exportExcel({
3573
3569
  model,
@@ -3579,7 +3575,7 @@ var ExcelService = {
3579
3575
  context,
3580
3576
  groupby
3581
3577
  }) {
3582
- const env2 = getEnv();
3578
+ const env = getEnv();
3583
3579
  const jsonData = {
3584
3580
  model,
3585
3581
  domain,
@@ -3589,7 +3585,7 @@ var ExcelService = {
3589
3585
  with_context: context,
3590
3586
  groupby: groupby ?? []
3591
3587
  };
3592
- return env2.requests.post_excel(`/export/${type}`, jsonData);
3588
+ return env.requests.post_excel(`/export/${type}`, jsonData);
3593
3589
  }
3594
3590
  };
3595
3591
  var excel_service_default = ExcelService;
@@ -3598,7 +3594,7 @@ var excel_service_default = ExcelService;
3598
3594
  var FormService = {
3599
3595
  async getComment({ data }) {
3600
3596
  try {
3601
- const env2 = getEnv();
3597
+ const env = getEnv();
3602
3598
  const jsonData = {
3603
3599
  thread_id: data.thread_id,
3604
3600
  thread_model: data.thread_model,
@@ -3607,7 +3603,7 @@ var FormService = {
3607
3603
  lang: data.lang
3608
3604
  }
3609
3605
  };
3610
- return env2.requests.post("/chatter/thread/messages" /* GET_MESSAGE */, jsonData, {
3606
+ return env.requests.post("/chatter/thread/messages" /* GET_MESSAGE */, jsonData, {
3611
3607
  headers: {
3612
3608
  "Content-Type": "application/json"
3613
3609
  }
@@ -3619,7 +3615,7 @@ var FormService = {
3619
3615
  },
3620
3616
  async sentComment({ data }) {
3621
3617
  try {
3622
- const env2 = getEnv();
3618
+ const env = getEnv();
3623
3619
  const jsonData = {
3624
3620
  context: {
3625
3621
  tz: "Asia/Saigon",
@@ -3638,7 +3634,7 @@ var FormService = {
3638
3634
  thread_id: Number(data.thread_id),
3639
3635
  thread_model: data.thread_model
3640
3636
  };
3641
- return env2.requests.post("/chatter/message/post" /* SENT_MESSAGE */, jsonData, {
3637
+ return env.requests.post("/chatter/message/post" /* SENT_MESSAGE */, jsonData, {
3642
3638
  headers: {
3643
3639
  "Content-Type": "application/json"
3644
3640
  }
@@ -3650,14 +3646,14 @@ var FormService = {
3650
3646
  },
3651
3647
  async deleteComment({ data }) {
3652
3648
  try {
3653
- const env2 = getEnv();
3649
+ const env = getEnv();
3654
3650
  const jsonData = {
3655
3651
  attachment_ids: [],
3656
3652
  attachment_tokens: [],
3657
3653
  body: "",
3658
3654
  message_id: data.message_id
3659
3655
  };
3660
- return env2.requests.post("/chatter/message/update_content" /* DELETE_MESSAGE */, jsonData, {
3656
+ return env.requests.post("/chatter/message/update_content" /* DELETE_MESSAGE */, jsonData, {
3661
3657
  headers: {
3662
3658
  "Content-Type": "application/json"
3663
3659
  }
@@ -3669,8 +3665,8 @@ var FormService = {
3669
3665
  },
3670
3666
  async getImage({ data }) {
3671
3667
  try {
3672
- const env2 = getEnv();
3673
- return env2.requests.get(
3668
+ const env = getEnv();
3669
+ return env.requests.get(
3674
3670
  `${"/web/image" /* IMAGE_PATH */}?filename=${data.filename}&unique=${data.checksum}&width=1920&height=300`,
3675
3671
  {
3676
3672
  headers: {
@@ -3685,8 +3681,8 @@ var FormService = {
3685
3681
  },
3686
3682
  async uploadImage({ data }) {
3687
3683
  try {
3688
- const env2 = getEnv();
3689
- return env2.requests.post("/mail/attachment/upload" /* UPLOAD_IMAGE */, data, {
3684
+ const env = getEnv();
3685
+ return env.requests.post("/mail/attachment/upload" /* UPLOAD_IMAGE */, data, {
3690
3686
  headers: {
3691
3687
  "Content-Type": "multipart/form-data"
3692
3688
  }
@@ -3698,14 +3694,14 @@ var FormService = {
3698
3694
  },
3699
3695
  async getFormView({ data }) {
3700
3696
  try {
3701
- const env2 = getEnv();
3697
+ const env = getEnv();
3702
3698
  const jsonData = {
3703
3699
  model: data.model,
3704
3700
  method: "get_formview_action",
3705
3701
  ids: data.id ? [data.id] : [],
3706
3702
  with_context: data.context
3707
3703
  };
3708
- return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3704
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3709
3705
  headers: {
3710
3706
  "Content-Type": "application/json"
3711
3707
  }
@@ -3716,7 +3712,7 @@ var FormService = {
3716
3712
  }
3717
3713
  },
3718
3714
  async changeStatus({ data }) {
3719
- const env2 = getEnv();
3715
+ const env = getEnv();
3720
3716
  const vals = {
3721
3717
  [data.name]: data.stage_id
3722
3718
  };
@@ -3736,7 +3732,7 @@ var FormService = {
3736
3732
  specification: {}
3737
3733
  }
3738
3734
  };
3739
- return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3735
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3740
3736
  headers: {
3741
3737
  "Content-Type": "application/json"
3742
3738
  }
@@ -3751,7 +3747,7 @@ var KanbanServices = {
3751
3747
  model,
3752
3748
  width_context
3753
3749
  }) {
3754
- const env2 = getEnv();
3750
+ const env = getEnv();
3755
3751
  const jsonDataView = {
3756
3752
  model,
3757
3753
  method: "web_read_group",
@@ -3762,7 +3758,7 @@ var KanbanServices = {
3762
3758
  },
3763
3759
  width_context
3764
3760
  };
3765
- return env2.requests.post("/call" /* CALL_PATH */, jsonDataView, {
3761
+ return env.requests.post("/call" /* CALL_PATH */, jsonDataView, {
3766
3762
  headers: {
3767
3763
  "Content-Type": "application/json"
3768
3764
  }
@@ -3774,7 +3770,7 @@ var KanbanServices = {
3774
3770
  model,
3775
3771
  width_context
3776
3772
  }) {
3777
- const env2 = getEnv();
3773
+ const env = getEnv();
3778
3774
  const jsonDataView = {
3779
3775
  model,
3780
3776
  method: "read_progress_bar",
@@ -3788,7 +3784,7 @@ var KanbanServices = {
3788
3784
  },
3789
3785
  width_context
3790
3786
  };
3791
- return env2.requests.post("/call" /* CALL_PATH */, jsonDataView, {
3787
+ return env.requests.post("/call" /* CALL_PATH */, jsonDataView, {
3792
3788
  headers: {
3793
3789
  "Content-Type": "application/json"
3794
3790
  }
@@ -3805,7 +3801,7 @@ var ModelService = {
3805
3801
  spectification,
3806
3802
  model
3807
3803
  }) {
3808
- const env2 = getEnv();
3804
+ const env = getEnv();
3809
3805
  const jsonData = {
3810
3806
  model,
3811
3807
  method: "web_search_read",
@@ -3816,14 +3812,14 @@ var ModelService = {
3816
3812
  offset: 0
3817
3813
  }
3818
3814
  };
3819
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3815
+ return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
3820
3816
  headers: {
3821
3817
  "Content-Type": "application/json"
3822
3818
  }
3823
3819
  });
3824
3820
  },
3825
3821
  async getCurrency() {
3826
- const env2 = getEnv();
3822
+ const env = getEnv();
3827
3823
  const jsonData = {
3828
3824
  model: "res.currency",
3829
3825
  method: "web_search_read",
@@ -3837,14 +3833,14 @@ var ModelService = {
3837
3833
  offset: 0
3838
3834
  }
3839
3835
  };
3840
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3836
+ return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
3841
3837
  headers: {
3842
3838
  "Content-Type": "application/json"
3843
3839
  }
3844
3840
  });
3845
3841
  },
3846
3842
  async getConversionRate() {
3847
- const env2 = getEnv();
3843
+ const env = getEnv();
3848
3844
  const jsonData = {
3849
3845
  model: "res.currency",
3850
3846
  method: "web_search_read",
@@ -3864,14 +3860,14 @@ var ModelService = {
3864
3860
  offset: 0
3865
3861
  }
3866
3862
  };
3867
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3863
+ return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
3868
3864
  headers: {
3869
3865
  "Content-Type": "application/json"
3870
3866
  }
3871
3867
  });
3872
3868
  },
3873
3869
  async getAll({ data }) {
3874
- const env2 = getEnv();
3870
+ const env = getEnv();
3875
3871
  const jsonReadGroup = data.type == "calendar" ? { fields: data?.fields } : data.fields && data.fields.length > 0 && data.groupby && data.groupby.length > 0 && data.groupby[0] ? {
3876
3872
  fields: data.fields,
3877
3873
  groupby: data.groupby
@@ -3892,14 +3888,14 @@ var ModelService = {
3892
3888
  ...jsonReadGroup
3893
3889
  }
3894
3890
  };
3895
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3891
+ return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
3896
3892
  headers: {
3897
3893
  "Content-Type": "application/json"
3898
3894
  }
3899
3895
  });
3900
3896
  },
3901
3897
  async getListCalendar({ data }) {
3902
- const env2 = getEnv();
3898
+ const env = getEnv();
3903
3899
  const jsonReadGroup = data.type == "calendar" ? data?.fields : data.fields && data.fields.length > 0 && data.groupby && data.groupby.length > 0 && data.groupby[0] ? {
3904
3900
  fields: data.fields,
3905
3901
  groupby: data.groupby
@@ -3921,7 +3917,7 @@ var ModelService = {
3921
3917
  ...jsonReadGroup
3922
3918
  }
3923
3919
  };
3924
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3920
+ return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
3925
3921
  headers: {
3926
3922
  "Content-Type": "application/json"
3927
3923
  }
@@ -3937,7 +3933,7 @@ var ModelService = {
3937
3933
  context = {},
3938
3934
  limit = 10
3939
3935
  }) {
3940
- const env2 = getEnv();
3936
+ const env = getEnv();
3941
3937
  const jsonData = {
3942
3938
  model,
3943
3939
  method: "web_search_read" /* WEB_SEARCH_READ */,
@@ -3951,7 +3947,7 @@ var ModelService = {
3951
3947
  order
3952
3948
  }
3953
3949
  };
3954
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3950
+ return env?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3955
3951
  headers: {
3956
3952
  "Content-Type": "application/json"
3957
3953
  }
@@ -3963,7 +3959,7 @@ var ModelService = {
3963
3959
  specification,
3964
3960
  context
3965
3961
  }) {
3966
- const env2 = getEnv();
3962
+ const env = getEnv();
3967
3963
  const jsonData = {
3968
3964
  model,
3969
3965
  method: "web_read" /* WEB_READ */,
@@ -3973,7 +3969,7 @@ var ModelService = {
3973
3969
  specification
3974
3970
  }
3975
3971
  };
3976
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3972
+ return env?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3977
3973
  headers: {
3978
3974
  "Content-Type": "application/json"
3979
3975
  }
@@ -3987,7 +3983,7 @@ var ModelService = {
3987
3983
  context = {},
3988
3984
  path
3989
3985
  }) {
3990
- const env2 = getEnv();
3986
+ const env = getEnv();
3991
3987
  const jsonData = {
3992
3988
  model,
3993
3989
  method: "web_save" /* WEB_SAVE */,
@@ -3998,20 +3994,20 @@ var ModelService = {
3998
3994
  specification
3999
3995
  }
4000
3996
  };
4001
- return env2?.requests?.post(path ?? "/call" /* CALL_PATH */, jsonData, {
3997
+ return env?.requests?.post(path ?? "/call" /* CALL_PATH */, jsonData, {
4002
3998
  headers: {
4003
3999
  "Content-Type": "application/json"
4004
4000
  }
4005
4001
  });
4006
4002
  },
4007
4003
  async delete({ ids = [], model }) {
4008
- const env2 = getEnv();
4004
+ const env = getEnv();
4009
4005
  const jsonData = {
4010
4006
  model,
4011
4007
  method: "unlink" /* UNLINK */,
4012
4008
  ids
4013
4009
  };
4014
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
4010
+ return env?.requests?.post("/call" /* CALL_PATH */, jsonData, {
4015
4011
  headers: {
4016
4012
  "Content-Type": "application/json"
4017
4013
  }
@@ -4025,7 +4021,7 @@ var ModelService = {
4025
4021
  context,
4026
4022
  fieldChange
4027
4023
  }) {
4028
- const env2 = getEnv();
4024
+ const env = getEnv();
4029
4025
  const jsonData = {
4030
4026
  model,
4031
4027
  method: "onchange" /* ONCHANGE */,
@@ -4037,19 +4033,19 @@ var ModelService = {
4037
4033
  specification
4038
4034
  ]
4039
4035
  };
4040
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
4036
+ return env?.requests?.post("/call" /* CALL_PATH */, jsonData, {
4041
4037
  headers: {
4042
4038
  "Content-Type": "application/json"
4043
4039
  }
4044
4040
  });
4045
4041
  },
4046
4042
  async getListFieldsOnchange({ model }) {
4047
- const env2 = getEnv();
4043
+ const env = getEnv();
4048
4044
  const jsonData = {
4049
4045
  model,
4050
4046
  method: "get_fields_onchange" /* GET_ONCHANGE_FIELDS */
4051
4047
  };
4052
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
4048
+ return env?.requests?.post("/call" /* CALL_PATH */, jsonData, {
4053
4049
  headers: {
4054
4050
  "Content-Type": "application/json"
4055
4051
  }
@@ -4117,15 +4113,15 @@ var model_service_default = ModelService;
4117
4113
  // src/services/user-service/index.ts
4118
4114
  var UserService = {
4119
4115
  async getProfile(path) {
4120
- const env2 = getEnv();
4121
- return env2?.requests?.get(path ?? "/userinfo" /* PROFILE_PATH */, {
4116
+ const env = getEnv();
4117
+ return env.requests.get(path ?? "/userinfo" /* PROFILE_PATH */, {
4122
4118
  headers: {
4123
4119
  "Content-Type": "application/x-www-form-urlencoded"
4124
4120
  }
4125
4121
  });
4126
4122
  },
4127
4123
  async getUser({ context, id }) {
4128
- const env2 = getEnv();
4124
+ const env = getEnv();
4129
4125
  const jsonData = {
4130
4126
  model: "res.users",
4131
4127
  method: "web_read",
@@ -4154,20 +4150,20 @@ var UserService = {
4154
4150
  }
4155
4151
  }
4156
4152
  };
4157
- return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
4153
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
4158
4154
  headers: {
4159
4155
  "Content-Type": "application/json"
4160
4156
  }
4161
4157
  });
4162
4158
  },
4163
4159
  switchUserLocale: async ({ id, values }) => {
4164
- const env2 = getEnv();
4160
+ const env = getEnv();
4165
4161
  const jsonData = {
4166
4162
  model: "res.users",
4167
4163
  domain: [["id", "=", id]],
4168
4164
  values
4169
4165
  };
4170
- return env2?.requests.post(UriConstants?.CREATE_UPDATE_PATH, jsonData, {
4166
+ return env?.requests.post(UriConstants?.CREATE_UPDATE_PATH, jsonData, {
4171
4167
  headers: {
4172
4168
  "Content-Type": "application/json"
4173
4169
  }
@@ -4185,7 +4181,7 @@ var ViewService = {
4185
4181
  options = {},
4186
4182
  aid
4187
4183
  }) {
4188
- const env2 = getEnv();
4184
+ const env = getEnv();
4189
4185
  const defaultOptions = {
4190
4186
  load_filters: true,
4191
4187
  toolbar: true,
@@ -4200,14 +4196,14 @@ var ViewService = {
4200
4196
  },
4201
4197
  with_context: context
4202
4198
  };
4203
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonDataView, {
4199
+ return env?.requests?.post("/call" /* CALL_PATH */, jsonDataView, {
4204
4200
  headers: {
4205
4201
  "Content-Type": "application/json"
4206
4202
  }
4207
4203
  });
4208
4204
  },
4209
4205
  async getMenu(context) {
4210
- const env2 = getEnv();
4206
+ const env = getEnv();
4211
4207
  const jsonData = {
4212
4208
  model: "ir.ui.menu" /* MENU */,
4213
4209
  method: "web_search_read" /* WEB_SEARCH_READ */,
@@ -4344,14 +4340,14 @@ var ViewService = {
4344
4340
  ]
4345
4341
  }
4346
4342
  };
4347
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
4343
+ return env?.requests?.post("/call" /* CALL_PATH */, jsonData, {
4348
4344
  headers: {
4349
4345
  "Content-Type": "application/json"
4350
4346
  }
4351
4347
  });
4352
4348
  },
4353
4349
  async getActionDetail(aid, context) {
4354
- const env2 = getEnv();
4350
+ const env = getEnv();
4355
4351
  const jsonData = {
4356
4352
  model: "ir.actions.act_window" /* WINDOW_ACTION */,
4357
4353
  method: "web_read" /* WEB_READ */,
@@ -4372,7 +4368,7 @@ var ViewService = {
4372
4368
  }
4373
4369
  }
4374
4370
  };
4375
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
4371
+ return env?.requests?.post("/call" /* CALL_PATH */, jsonData, {
4376
4372
  headers: {
4377
4373
  "Content-Type": "application/json"
4378
4374
  }
@@ -4384,7 +4380,7 @@ var ViewService = {
4384
4380
  context,
4385
4381
  offset
4386
4382
  }) {
4387
- const env2 = getEnv();
4383
+ const env = getEnv();
4388
4384
  const jsonData = {
4389
4385
  model,
4390
4386
  with_context: context,
@@ -4392,14 +4388,14 @@ var ViewService = {
4392
4388
  field: "sequence",
4393
4389
  ...offset > 0 ? { offset } : {}
4394
4390
  };
4395
- return env2?.requests.post("/web/dataset/resequence", jsonData, {
4391
+ return env?.requests.post("/web/dataset/resequence", jsonData, {
4396
4392
  headers: {
4397
4393
  "Content-Type": "application/json"
4398
4394
  }
4399
4395
  });
4400
4396
  },
4401
4397
  async getSelectionItem({ data }) {
4402
- const env2 = getEnv();
4398
+ const env = getEnv();
4403
4399
  const jsonData = {
4404
4400
  model: data.model,
4405
4401
  ids: [],
@@ -4417,15 +4413,15 @@ var ViewService = {
4417
4413
  }
4418
4414
  }
4419
4415
  };
4420
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4416
+ return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
4421
4417
  headers: {
4422
4418
  "Content-Type": "application/json"
4423
4419
  }
4424
4420
  });
4425
4421
  },
4426
4422
  async loadMessages() {
4427
- const env2 = getEnv();
4428
- return env2.requests.post(
4423
+ const env = getEnv();
4424
+ return env.requests.post(
4429
4425
  "/load_message_failures" /* LOAD_MESSAGE */,
4430
4426
  {},
4431
4427
  {
@@ -4436,8 +4432,9 @@ var ViewService = {
4436
4432
  );
4437
4433
  },
4438
4434
  async getVersion() {
4439
- const env2 = getEnv();
4440
- return env2?.requests.get("", {
4435
+ const env = getEnv();
4436
+ console.log("env?.requests", env, env?.requests);
4437
+ return env?.requests?.get("", {
4441
4438
  headers: {
4442
4439
  "Content-Type": "application/json"
4443
4440
  }
@@ -4447,12 +4444,12 @@ var ViewService = {
4447
4444
  method,
4448
4445
  with_context
4449
4446
  }) {
4450
- const env2 = getEnv();
4447
+ const env = getEnv();
4451
4448
  const jsonData = {
4452
4449
  method,
4453
4450
  with_context
4454
4451
  };
4455
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4452
+ return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
4456
4453
  headers: {
4457
4454
  "Content-Type": "application/json"
4458
4455
  }
@@ -4465,7 +4462,7 @@ var ViewService = {
4465
4462
  device,
4466
4463
  location
4467
4464
  }) {
4468
- const env2 = getEnv();
4465
+ const env = getEnv();
4469
4466
  const jsonData = {
4470
4467
  method,
4471
4468
  kwargs: {
@@ -4477,7 +4474,7 @@ var ViewService = {
4477
4474
  },
4478
4475
  with_context
4479
4476
  };
4480
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4477
+ return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
4481
4478
  headers: {
4482
4479
  "Content-Type": "application/json"
4483
4480
  },
@@ -4491,7 +4488,7 @@ var ViewService = {
4491
4488
  response_type,
4492
4489
  path
4493
4490
  }) {
4494
- const env2 = getEnv();
4491
+ const env = getEnv();
4495
4492
  const params = new URLSearchParams({
4496
4493
  response_type,
4497
4494
  client_id,
@@ -4499,7 +4496,7 @@ var ViewService = {
4499
4496
  state
4500
4497
  });
4501
4498
  const url = `${path}?${params.toString()}`;
4502
- return env2?.requests.get(url, {
4499
+ return env?.requests.get(url, {
4503
4500
  headers: {
4504
4501
  "Content-Type": "application/json"
4505
4502
  },
@@ -4512,14 +4509,14 @@ var ViewService = {
4512
4509
  client_id,
4513
4510
  scopes
4514
4511
  }) {
4515
- const env2 = getEnv();
4512
+ const env = getEnv();
4516
4513
  const jsonData = {
4517
4514
  redirect_uri,
4518
4515
  state,
4519
4516
  client_id,
4520
4517
  scopes
4521
4518
  };
4522
- return env2?.requests.post("/grant-access" /* GRANT_ACCESS */, jsonData, {
4519
+ return env?.requests.post("/grant-access" /* GRANT_ACCESS */, jsonData, {
4523
4520
  headers: {
4524
4521
  "Content-Type": "application/json"
4525
4522
  },
@@ -4531,7 +4528,7 @@ var ViewService = {
4531
4528
  token,
4532
4529
  views
4533
4530
  }) {
4534
- const env2 = getEnv();
4531
+ const env = getEnv();
4535
4532
  const jsonData = {
4536
4533
  method,
4537
4534
  kwargs: {
@@ -4541,7 +4538,7 @@ var ViewService = {
4541
4538
  token
4542
4539
  }
4543
4540
  };
4544
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4541
+ return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
4545
4542
  headers: {
4546
4543
  "Content-Type": "application/json"
4547
4544
  }
@@ -4553,7 +4550,7 @@ var ViewService = {
4553
4550
  kwargs,
4554
4551
  token
4555
4552
  }) {
4556
- const env2 = getEnv();
4553
+ const env = getEnv();
4557
4554
  const jsonData = {
4558
4555
  method,
4559
4556
  model,
@@ -4562,21 +4559,21 @@ var ViewService = {
4562
4559
  token
4563
4560
  }
4564
4561
  };
4565
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4562
+ return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
4566
4563
  headers: {
4567
4564
  "Content-Type": "application/json"
4568
4565
  }
4569
4566
  });
4570
4567
  },
4571
4568
  async requestSetupTotp({ method, token }) {
4572
- const env2 = getEnv();
4569
+ const env = getEnv();
4573
4570
  const jsonData = {
4574
4571
  method,
4575
4572
  with_context: {
4576
4573
  token
4577
4574
  }
4578
4575
  };
4579
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4576
+ return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
4580
4577
  headers: {
4581
4578
  "Content-Type": "application/json"
4582
4579
  }
@@ -4587,7 +4584,7 @@ var ViewService = {
4587
4584
  action_token,
4588
4585
  code
4589
4586
  }) {
4590
- const env2 = getEnv();
4587
+ const env = getEnv();
4591
4588
  const jsonData = {
4592
4589
  method,
4593
4590
  kwargs: {
@@ -4599,21 +4596,21 @@ var ViewService = {
4599
4596
  action_token
4600
4597
  }
4601
4598
  };
4602
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4599
+ return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
4603
4600
  headers: {
4604
4601
  "Content-Type": "application/json"
4605
4602
  }
4606
4603
  });
4607
4604
  },
4608
4605
  async removeTotpSetUp({ method, token }) {
4609
- const env2 = getEnv();
4606
+ const env = getEnv();
4610
4607
  const jsonData = {
4611
4608
  method,
4612
4609
  with_context: {
4613
4610
  token
4614
4611
  }
4615
4612
  };
4616
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4613
+ return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
4617
4614
  headers: {
4618
4615
  "Content-Type": "application/json"
4619
4616
  }