@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.
@@ -31,625 +31,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  var environment_exports = {};
32
32
  __export(environment_exports, {
33
33
  EnvStore: () => EnvStore,
34
- env: () => env,
35
34
  getEnv: () => getEnv,
36
35
  initEnv: () => initEnv
37
36
  });
38
37
  module.exports = __toCommonJS(environment_exports);
39
38
 
40
- // src/store/store.ts
41
- var import_toolkit11 = require("@reduxjs/toolkit");
42
-
43
- // node_modules/redux/dist/redux.mjs
44
- function formatProdErrorMessage(code) {
45
- 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. `;
46
- }
47
- var randomString = () => Math.random().toString(36).substring(7).split("").join(".");
48
- var ActionTypes = {
49
- INIT: `@@redux/INIT${/* @__PURE__ */ randomString()}`,
50
- REPLACE: `@@redux/REPLACE${/* @__PURE__ */ randomString()}`,
51
- PROBE_UNKNOWN_ACTION: () => `@@redux/PROBE_UNKNOWN_ACTION${randomString()}`
52
- };
53
- var actionTypes_default = ActionTypes;
54
- function isPlainObject(obj) {
55
- if (typeof obj !== "object" || obj === null)
56
- return false;
57
- let proto = obj;
58
- while (Object.getPrototypeOf(proto) !== null) {
59
- proto = Object.getPrototypeOf(proto);
60
- }
61
- return Object.getPrototypeOf(obj) === proto || Object.getPrototypeOf(obj) === null;
62
- }
63
- function miniKindOf(val) {
64
- if (val === void 0)
65
- return "undefined";
66
- if (val === null)
67
- return "null";
68
- const type = typeof val;
69
- switch (type) {
70
- case "boolean":
71
- case "string":
72
- case "number":
73
- case "symbol":
74
- case "function": {
75
- return type;
76
- }
77
- }
78
- if (Array.isArray(val))
79
- return "array";
80
- if (isDate(val))
81
- return "date";
82
- if (isError(val))
83
- return "error";
84
- const constructorName = ctorName(val);
85
- switch (constructorName) {
86
- case "Symbol":
87
- case "Promise":
88
- case "WeakMap":
89
- case "WeakSet":
90
- case "Map":
91
- case "Set":
92
- return constructorName;
93
- }
94
- return Object.prototype.toString.call(val).slice(8, -1).toLowerCase().replace(/\s/g, "");
95
- }
96
- function ctorName(val) {
97
- return typeof val.constructor === "function" ? val.constructor.name : null;
98
- }
99
- function isError(val) {
100
- return val instanceof Error || typeof val.message === "string" && val.constructor && typeof val.constructor.stackTraceLimit === "number";
101
- }
102
- function isDate(val) {
103
- if (val instanceof Date)
104
- return true;
105
- return typeof val.toDateString === "function" && typeof val.getDate === "function" && typeof val.setDate === "function";
106
- }
107
- function kindOf(val) {
108
- let typeOfVal = typeof val;
109
- if (process.env.NODE_ENV !== "production") {
110
- typeOfVal = miniKindOf(val);
111
- }
112
- return typeOfVal;
113
- }
114
- function warning(message) {
115
- if (typeof console !== "undefined" && typeof console.error === "function") {
116
- console.error(message);
117
- }
118
- try {
119
- throw new Error(message);
120
- } catch (e) {
121
- }
122
- }
123
- function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
124
- const reducerKeys = Object.keys(reducers);
125
- const argumentName = action && action.type === actionTypes_default.INIT ? "preloadedState argument passed to createStore" : "previous state received by the reducer";
126
- if (reducerKeys.length === 0) {
127
- return "Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";
128
- }
129
- if (!isPlainObject(inputState)) {
130
- return `The ${argumentName} has unexpected type of "${kindOf(inputState)}". Expected argument to be an object with the following keys: "${reducerKeys.join('", "')}"`;
131
- }
132
- const unexpectedKeys = Object.keys(inputState).filter((key) => !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key]);
133
- unexpectedKeys.forEach((key) => {
134
- unexpectedKeyCache[key] = true;
135
- });
136
- if (action && action.type === actionTypes_default.REPLACE)
137
- return;
138
- if (unexpectedKeys.length > 0) {
139
- 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.`;
140
- }
141
- }
142
- function assertReducerShape(reducers) {
143
- Object.keys(reducers).forEach((key) => {
144
- const reducer = reducers[key];
145
- const initialState10 = reducer(void 0, {
146
- type: actionTypes_default.INIT
147
- });
148
- if (typeof initialState10 === "undefined") {
149
- 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.`);
150
- }
151
- if (typeof reducer(void 0, {
152
- type: actionTypes_default.PROBE_UNKNOWN_ACTION()
153
- }) === "undefined") {
154
- 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.`);
155
- }
156
- });
157
- }
158
- function combineReducers(reducers) {
159
- const reducerKeys = Object.keys(reducers);
160
- const finalReducers = {};
161
- for (let i = 0; i < reducerKeys.length; i++) {
162
- const key = reducerKeys[i];
163
- if (process.env.NODE_ENV !== "production") {
164
- if (typeof reducers[key] === "undefined") {
165
- warning(`No reducer provided for key "${key}"`);
166
- }
167
- }
168
- if (typeof reducers[key] === "function") {
169
- finalReducers[key] = reducers[key];
170
- }
171
- }
172
- const finalReducerKeys = Object.keys(finalReducers);
173
- let unexpectedKeyCache;
174
- if (process.env.NODE_ENV !== "production") {
175
- unexpectedKeyCache = {};
176
- }
177
- let shapeAssertionError;
178
- try {
179
- assertReducerShape(finalReducers);
180
- } catch (e) {
181
- shapeAssertionError = e;
182
- }
183
- return function combination(state = {}, action) {
184
- if (shapeAssertionError) {
185
- throw shapeAssertionError;
186
- }
187
- if (process.env.NODE_ENV !== "production") {
188
- const warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
189
- if (warningMessage) {
190
- warning(warningMessage);
191
- }
192
- }
193
- let hasChanged = false;
194
- const nextState = {};
195
- for (let i = 0; i < finalReducerKeys.length; i++) {
196
- const key = finalReducerKeys[i];
197
- const reducer = finalReducers[key];
198
- const previousStateForKey = state[key];
199
- const nextStateForKey = reducer(previousStateForKey, action);
200
- if (typeof nextStateForKey === "undefined") {
201
- const actionType = action && action.type;
202
- 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.`);
203
- }
204
- nextState[key] = nextStateForKey;
205
- hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
206
- }
207
- hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
208
- return hasChanged ? nextState : state;
209
- };
210
- }
211
-
212
- // src/store/reducers/breadcrums-slice/index.ts
213
- var import_toolkit = require("@reduxjs/toolkit");
214
- var initialState = {
215
- breadCrumbs: []
216
- };
217
- var breadcrumbsSlice = (0, import_toolkit.createSlice)({
218
- name: "breadcrumbs",
219
- initialState,
220
- reducers: {
221
- setBreadCrumbs: (state, action) => {
222
- state.breadCrumbs = [...state.breadCrumbs, action.payload];
223
- }
224
- }
225
- });
226
- var { setBreadCrumbs } = breadcrumbsSlice.actions;
227
- var breadcrums_slice_default = breadcrumbsSlice.reducer;
228
-
229
- // src/store/reducers/env-slice/index.ts
230
- var import_toolkit2 = require("@reduxjs/toolkit");
231
- var initialState2 = {
232
- baseUrl: "",
233
- companies: [],
234
- user: {},
235
- db: "",
236
- refreshTokenEndpoint: "",
237
- config: null,
238
- envFile: null,
239
- requests: null,
240
- defaultCompany: {
241
- id: null,
242
- logo: "",
243
- secondary_color: "",
244
- primary_color: ""
245
- },
246
- context: {
247
- uid: null,
248
- allowed_company_ids: [],
249
- lang: "vi_VN",
250
- tz: "Asia/Saigon"
251
- }
252
- };
253
- var envSlice = (0, import_toolkit2.createSlice)({
254
- name: "env",
255
- initialState: initialState2,
256
- reducers: {
257
- setEnv: (state, action) => {
258
- Object.assign(state, action.payload);
259
- },
260
- setUid: (state, action) => {
261
- state.context.uid = action.payload;
262
- },
263
- setAllowCompanies: (state, action) => {
264
- state.context.allowed_company_ids = action.payload;
265
- },
266
- setCompanies: (state, action) => {
267
- state.companies = action.payload;
268
- },
269
- setDefaultCompany: (state, action) => {
270
- state.defaultCompany = action.payload;
271
- },
272
- setLang: (state, action) => {
273
- state.context.lang = action.payload;
274
- },
275
- setUser: (state, action) => {
276
- state.user = action.payload;
277
- },
278
- setConfig: (state, action) => {
279
- state.config = action.payload;
280
- },
281
- setEnvFile: (state, action) => {
282
- state.envFile = action.payload;
283
- }
284
- }
285
- });
286
- var {
287
- setEnv,
288
- setUid,
289
- setLang,
290
- setAllowCompanies,
291
- setCompanies,
292
- setDefaultCompany,
293
- setUser,
294
- setConfig,
295
- setEnvFile
296
- } = envSlice.actions;
297
- var env_slice_default = envSlice.reducer;
298
-
299
- // src/store/reducers/excel-slice/index.ts
300
- var import_toolkit3 = require("@reduxjs/toolkit");
301
- var initialState3 = {
302
- dataParse: null,
303
- idFile: null,
304
- isFileLoaded: false,
305
- loadingImport: false,
306
- selectedFile: null,
307
- errorData: null
308
- };
309
- var excelSlice = (0, import_toolkit3.createSlice)({
310
- name: "excel",
311
- initialState: initialState3,
312
- reducers: {
313
- setDataParse: (state, action) => {
314
- state.dataParse = action.payload;
315
- },
316
- setIdFile: (state, action) => {
317
- state.idFile = action.payload;
318
- },
319
- setIsFileLoaded: (state, action) => {
320
- state.isFileLoaded = action.payload;
321
- },
322
- setLoadingImport: (state, action) => {
323
- state.loadingImport = action.payload;
324
- },
325
- setSelectedFile: (state, action) => {
326
- state.selectedFile = action.payload;
327
- },
328
- setErrorData: (state, action) => {
329
- state.errorData = action.payload;
330
- }
331
- }
332
- });
333
- var {
334
- setDataParse,
335
- setIdFile,
336
- setIsFileLoaded,
337
- setLoadingImport,
338
- setSelectedFile,
339
- setErrorData
340
- } = excelSlice.actions;
341
- var excel_slice_default = excelSlice.reducer;
342
-
343
- // src/store/reducers/form-slice/index.ts
344
- var import_toolkit4 = require("@reduxjs/toolkit");
345
- var initialState4 = {
346
- viewDataStore: {},
347
- isShowingModalDetail: false,
348
- isShowModalTranslate: false,
349
- formSubmitComponent: {},
350
- fieldTranslation: null,
351
- listSubject: {},
352
- dataUser: {}
353
- };
354
- var formSlice = (0, import_toolkit4.createSlice)({
355
- name: "form",
356
- initialState: initialState4,
357
- reducers: {
358
- setViewDataStore: (state, action) => {
359
- state.viewDataStore = action.payload;
360
- },
361
- setIsShowingModalDetail: (state, action) => {
362
- state.isShowingModalDetail = action.payload;
363
- },
364
- setIsShowModalTranslate: (state, action) => {
365
- state.isShowModalTranslate = action.payload;
366
- },
367
- setFormSubmitComponent: (state, action) => {
368
- state.formSubmitComponent[action.payload.key] = action.payload.component;
369
- },
370
- setFieldTranslate: (state, action) => {
371
- state.fieldTranslation = action.payload;
372
- },
373
- setListSubject: (state, action) => {
374
- state.listSubject = action.payload;
375
- },
376
- setDataUser: (state, action) => {
377
- state.dataUser = action.payload;
378
- }
379
- }
380
- });
381
- var {
382
- setViewDataStore,
383
- setIsShowingModalDetail,
384
- setIsShowModalTranslate,
385
- setFormSubmitComponent,
386
- setFieldTranslate,
387
- setListSubject,
388
- setDataUser
389
- } = formSlice.actions;
390
- var form_slice_default = formSlice.reducer;
391
-
392
- // src/store/reducers/header-slice/index.ts
393
- var import_toolkit5 = require("@reduxjs/toolkit");
394
- var headerSlice = (0, import_toolkit5.createSlice)({
395
- name: "header",
396
- initialState: {
397
- value: { allowedCompanyIds: [] }
398
- },
399
- reducers: {
400
- setHeader: (state, action) => {
401
- state.value = { ...state.value, ...action.payload };
402
- },
403
- setAllowedCompanyIds: (state, action) => {
404
- state.value.allowedCompanyIds = action.payload;
405
- }
406
- }
407
- });
408
- var { setAllowedCompanyIds, setHeader } = headerSlice.actions;
409
- var header_slice_default = headerSlice.reducer;
410
-
411
- // src/store/reducers/list-slice/index.ts
412
- var import_toolkit6 = require("@reduxjs/toolkit");
413
- var initialState5 = {
414
- pageLimit: 10,
415
- fields: {},
416
- order: "",
417
- selectedRowKeys: [],
418
- selectedRadioKey: 0,
419
- indexRowTableModal: -2,
420
- isUpdateTableModal: false,
421
- footerGroupTable: {},
422
- transferDetail: null,
423
- page: 0,
424
- domainTable: []
425
- };
426
- var listSlice = (0, import_toolkit6.createSlice)({
427
- name: "list",
428
- initialState: initialState5,
429
- reducers: {
430
- setPageLimit: (state, action) => {
431
- state.pageLimit = action.payload;
432
- },
433
- setFields: (state, action) => {
434
- state.fields = action.payload;
435
- },
436
- setOrder: (state, action) => {
437
- state.order = action.payload;
438
- },
439
- setSelectedRowKeys: (state, action) => {
440
- state.selectedRowKeys = action.payload;
441
- },
442
- setSelectedRadioKey: (state, action) => {
443
- state.selectedRadioKey = action.payload;
444
- },
445
- setIndexRowTableModal: (state, action) => {
446
- state.indexRowTableModal = action.payload;
447
- },
448
- setTransferDetail: (state, action) => {
449
- state.transferDetail = action.payload;
450
- },
451
- setIsUpdateTableModal: (state, action) => {
452
- state.isUpdateTableModal = action.payload;
453
- },
454
- setPage: (state, action) => {
455
- state.page = action.payload;
456
- },
457
- setDomainTable: (state, action) => {
458
- state.domainTable = action.payload;
459
- }
460
- }
461
- });
462
- var {
463
- setPageLimit,
464
- setFields,
465
- setOrder,
466
- setSelectedRowKeys,
467
- setIndexRowTableModal,
468
- setIsUpdateTableModal,
469
- setPage,
470
- setSelectedRadioKey,
471
- setTransferDetail,
472
- setDomainTable
473
- } = listSlice.actions;
474
- var list_slice_default = listSlice.reducer;
475
-
476
- // src/store/reducers/login-slice/index.ts
477
- var import_toolkit7 = require("@reduxjs/toolkit");
478
- var initialState6 = {
479
- db: "",
480
- redirectTo: "/",
481
- forgotPasswordUrl: "/"
482
- };
483
- var loginSlice = (0, import_toolkit7.createSlice)({
484
- name: "login",
485
- initialState: initialState6,
486
- reducers: {
487
- setDb: (state, action) => {
488
- state.db = action.payload;
489
- },
490
- setRedirectTo: (state, action) => {
491
- state.redirectTo = action.payload;
492
- },
493
- setForgotPasswordUrl: (state, action) => {
494
- state.forgotPasswordUrl = action.payload;
495
- }
496
- }
497
- });
498
- var { setDb, setRedirectTo, setForgotPasswordUrl } = loginSlice.actions;
499
- var login_slice_default = loginSlice.reducer;
500
-
501
- // src/store/reducers/navbar-slice/index.ts
502
- var import_toolkit8 = require("@reduxjs/toolkit");
503
- var initialState7 = {
504
- menuFocus: {},
505
- menuAction: {},
506
- navbarWidth: 250,
507
- menuList: []
508
- };
509
- var navbarSlice = (0, import_toolkit8.createSlice)({
510
- name: "navbar",
511
- initialState: initialState7,
512
- reducers: {
513
- setMenuFocus: (state, action) => {
514
- state.menuFocus = action.payload;
515
- },
516
- setMenuFocusAction: (state, action) => {
517
- state.menuAction = action.payload;
518
- },
519
- setNavbarWidth: (state, action) => {
520
- state.navbarWidth = action.payload;
521
- },
522
- setMenuList: (state, action) => {
523
- state.menuList = action.payload;
524
- }
525
- }
526
- });
527
- var { setMenuFocus, setMenuFocusAction, setNavbarWidth, setMenuList } = navbarSlice.actions;
528
- var navbar_slice_default = navbarSlice.reducer;
529
-
530
- // src/store/reducers/profile-slice/index.ts
531
- var import_toolkit9 = require("@reduxjs/toolkit");
532
- var initialState8 = {
533
- profile: {}
534
- };
535
- var profileSlice = (0, import_toolkit9.createSlice)({
536
- name: "profile",
537
- initialState: initialState8,
538
- reducers: {
539
- setProfile: (state, action) => {
540
- state.profile = action.payload;
541
- }
542
- }
543
- });
544
- var { setProfile } = profileSlice.actions;
545
- var profile_slice_default = profileSlice.reducer;
546
-
547
- // src/store/reducers/search-slice/index.ts
548
- var import_toolkit10 = require("@reduxjs/toolkit");
549
- var initialState9 = {
550
- groupByDomain: null,
551
- searchBy: [],
552
- searchString: "",
553
- hoveredIndexSearchList: null,
554
- selectedTags: [],
555
- firstDomain: null,
556
- searchMap: {},
557
- filterBy: [],
558
- groupBy: []
559
- };
560
- var searchSlice = (0, import_toolkit10.createSlice)({
561
- name: "search",
562
- initialState: initialState9,
563
- reducers: {
564
- setGroupByDomain: (state, action) => {
565
- state.groupByDomain = action.payload;
566
- },
567
- setSearchBy: (state, action) => {
568
- state.searchBy = action.payload;
569
- },
570
- setSearchString: (state, action) => {
571
- state.searchString = action.payload;
572
- },
573
- setHoveredIndexSearchList: (state, action) => {
574
- state.hoveredIndexSearchList = action.payload;
575
- },
576
- setSelectedTags: (state, action) => {
577
- state.selectedTags = action.payload;
578
- },
579
- setFirstDomain: (state, action) => {
580
- state.firstDomain = action.payload;
581
- },
582
- setFilterBy: (state, action) => {
583
- state.filterBy = action.payload;
584
- },
585
- setGroupBy: (state, action) => {
586
- state.groupBy = action.payload;
587
- },
588
- setSearchMap: (state, action) => {
589
- state.searchMap = action.payload;
590
- },
591
- updateSearchMap: (state, action) => {
592
- if (!state.searchMap[action.payload.key]) {
593
- state.searchMap[action.payload.key] = [];
594
- }
595
- state.searchMap[action.payload.key].push(action.payload.value);
596
- },
597
- removeKeyFromSearchMap: (state, action) => {
598
- const { key, item } = action.payload;
599
- const values = state.searchMap[key];
600
- if (!values) return;
601
- if (item) {
602
- const filtered = values.filter((value) => value.name !== item.name);
603
- if (filtered.length > 0) {
604
- state.searchMap[key] = filtered;
605
- } else {
606
- delete state.searchMap[key];
607
- }
608
- } else {
609
- delete state.searchMap[key];
610
- }
611
- },
612
- clearSearchMap: (state) => {
613
- state.searchMap = {};
614
- }
615
- }
616
- });
617
- var {
618
- setGroupByDomain,
619
- setSelectedTags,
620
- setSearchString,
621
- setHoveredIndexSearchList,
622
- setFirstDomain,
623
- setSearchBy,
624
- setFilterBy,
625
- setSearchMap,
626
- updateSearchMap,
627
- removeKeyFromSearchMap,
628
- setGroupBy,
629
- clearSearchMap
630
- } = searchSlice.actions;
631
- var search_slice_default = searchSlice.reducer;
632
-
633
- // src/store/store.ts
634
- var rootReducer = combineReducers({
635
- env: env_slice_default,
636
- header: header_slice_default,
637
- navbar: navbar_slice_default,
638
- list: list_slice_default,
639
- search: search_slice_default,
640
- form: form_slice_default,
641
- breadcrumbs: breadcrums_slice_default,
642
- login: login_slice_default,
643
- excel: excel_slice_default,
644
- profile: profile_slice_default
645
- });
646
- var envStore = (0, import_toolkit11.configureStore)({
647
- reducer: rootReducer,
648
- middleware: (getDefaultMiddleware) => getDefaultMiddleware({
649
- serializableCheck: false
650
- })
651
- });
652
-
653
39
  // src/configs/axios-client.ts
654
40
  var import_axios = __toESM(require("axios"));
655
41
 
@@ -2352,653 +1738,1269 @@ function evaluate(ast, context = {}) {
2352
1738
  return isTrue(left) ? left : _evaluate(ast2.right);
2353
1739
  }
2354
1740
  case 4:
2355
- // List
1741
+ // List
1742
+ case 10:
1743
+ return ast2.value.map(_evaluate);
1744
+ case 11:
1745
+ const dict = {};
1746
+ for (const key2 in ast2.value) {
1747
+ dict[key2] = _evaluate(ast2.value[key2]);
1748
+ }
1749
+ dicts.add(dict);
1750
+ return dict;
1751
+ case 8:
1752
+ const fnValue = _evaluate(ast2.fn);
1753
+ const args = ast2.args.map(_evaluate);
1754
+ const kwargs = {};
1755
+ for (const kwarg in ast2.kwargs) {
1756
+ kwargs[kwarg] = _evaluate(ast2?.kwargs[kwarg]);
1757
+ }
1758
+ if (fnValue === PyDate || fnValue === PyDateTime || fnValue === PyTime || fnValue === PyRelativeDelta || fnValue === PyTimeDelta) {
1759
+ return fnValue.create(...args, kwargs);
1760
+ }
1761
+ return fnValue(...args, kwargs);
1762
+ case 12:
1763
+ const dictVal = _evaluate(ast2.target);
1764
+ const key = _evaluate(ast2.key);
1765
+ return dictVal[key];
1766
+ case 13:
1767
+ if (isTrue(_evaluate(ast2.condition))) {
1768
+ return _evaluate(ast2.ifTrue);
1769
+ } else {
1770
+ return _evaluate(ast2.ifFalse);
1771
+ }
1772
+ case 15:
1773
+ let leftVal = _evaluate(ast2.obj);
1774
+ let result;
1775
+ if (dicts.has(leftVal) || Object.isPrototypeOf.call(PY_DICT, leftVal)) {
1776
+ result = DICT[ast2.key];
1777
+ } else if (typeof leftVal === "string") {
1778
+ result = STRING[ast2.key];
1779
+ } else if (leftVal instanceof Set) {
1780
+ result = SET[ast2.key];
1781
+ } else if (ast2.key === "get" && typeof leftVal === "object") {
1782
+ result = DICT[ast2.key];
1783
+ leftVal = toPyDict(leftVal);
1784
+ } else {
1785
+ result = leftVal[ast2.key];
1786
+ }
1787
+ if (typeof result === "function") {
1788
+ const bound = result.bind(leftVal);
1789
+ bound[unboundFn] = result;
1790
+ return bound;
1791
+ }
1792
+ return result;
1793
+ default:
1794
+ throw new EvaluationError(`AST of type ${ast2.type} cannot be evaluated`);
1795
+ }
1796
+ }
1797
+ function _evaluate(ast2) {
1798
+ const val = _innerEvaluate(ast2);
1799
+ if (typeof val === "function" && !allowedFns.has(val) && !allowedFns.has(val[unboundFn])) {
1800
+ throw new Error("Invalid Function Call");
1801
+ }
1802
+ return val;
1803
+ }
1804
+ return _evaluate(ast);
1805
+ }
1806
+
1807
+ // src/utils/domain/py.ts
1808
+ function parseExpr(expr) {
1809
+ const tokens = tokenize(expr);
1810
+ return parse(tokens);
1811
+ }
1812
+
1813
+ // src/utils/domain/objects.ts
1814
+ function shallowEqual(obj1, obj2, comparisonFn = (a, b) => a === b) {
1815
+ if (!obj1 || !obj2 || typeof obj1 !== "object" || typeof obj2 !== "object") {
1816
+ return obj1 === obj2;
1817
+ }
1818
+ const obj1Keys = Object.keys(obj1);
1819
+ return obj1Keys.length === Object.keys(obj2).length && obj1Keys.every((key) => comparisonFn(obj1[key], obj2[key]));
1820
+ }
1821
+
1822
+ // src/utils/domain/arrays.ts
1823
+ var shallowEqual2 = shallowEqual;
1824
+
1825
+ // src/utils/domain/strings.ts
1826
+ var escapeMethod = Symbol("html");
1827
+ function escapeRegExp(str) {
1828
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1829
+ }
1830
+
1831
+ // src/utils/domain/domain.ts
1832
+ var InvalidDomainError = class extends Error {
1833
+ };
1834
+ var Domain = class _Domain {
1835
+ ast = { type: -1, value: null };
1836
+ static TRUE;
1837
+ static FALSE;
1838
+ static combine(domains, operator) {
1839
+ if (domains.length === 0) {
1840
+ return new _Domain([]);
1841
+ }
1842
+ const domain1 = domains[0] instanceof _Domain ? domains[0] : new _Domain(domains[0]);
1843
+ if (domains.length === 1) {
1844
+ return domain1;
1845
+ }
1846
+ const domain2 = _Domain.combine(domains.slice(1), operator);
1847
+ const result = new _Domain([]);
1848
+ const astValues1 = domain1.ast.value;
1849
+ const astValues2 = domain2.ast.value;
1850
+ const op = operator === "AND" ? "&" : "|";
1851
+ const combinedAST = {
1852
+ type: 4,
1853
+ value: astValues1.concat(astValues2)
1854
+ };
1855
+ result.ast = normalizeDomainAST(combinedAST, op);
1856
+ return result;
1857
+ }
1858
+ static and(domains) {
1859
+ return _Domain.combine(domains, "AND");
1860
+ }
1861
+ static or(domains) {
1862
+ return _Domain.combine(domains, "OR");
1863
+ }
1864
+ static not(domain) {
1865
+ const result = new _Domain(domain);
1866
+ result.ast.value.unshift({ type: 1, value: "!" });
1867
+ return result;
1868
+ }
1869
+ static removeDomainLeaves(domain, keysToRemove) {
1870
+ function processLeaf(elements, idx, operatorCtx, newDomain2) {
1871
+ const leaf = elements[idx];
1872
+ if (leaf.type === 10) {
1873
+ if (keysToRemove.includes(leaf.value[0].value)) {
1874
+ if (operatorCtx === "&") {
1875
+ newDomain2.ast.value.push(..._Domain.TRUE.ast.value);
1876
+ } else if (operatorCtx === "|") {
1877
+ newDomain2.ast.value.push(..._Domain.FALSE.ast.value);
1878
+ }
1879
+ } else {
1880
+ newDomain2.ast.value.push(leaf);
1881
+ }
1882
+ return 1;
1883
+ } else if (leaf.type === 1) {
1884
+ 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)) {
1885
+ newDomain2.ast.value.push(..._Domain.TRUE.ast.value);
1886
+ return 3;
1887
+ }
1888
+ newDomain2.ast.value.push(leaf);
1889
+ if (leaf.value === "!") {
1890
+ return 1 + processLeaf(elements, idx + 1, "&", newDomain2);
1891
+ }
1892
+ const firstLeafSkip = processLeaf(
1893
+ elements,
1894
+ idx + 1,
1895
+ leaf.value,
1896
+ newDomain2
1897
+ );
1898
+ const secondLeafSkip = processLeaf(
1899
+ elements,
1900
+ idx + 1 + firstLeafSkip,
1901
+ leaf.value,
1902
+ newDomain2
1903
+ );
1904
+ return 1 + firstLeafSkip + secondLeafSkip;
1905
+ }
1906
+ return 0;
1907
+ }
1908
+ const d = new _Domain(domain);
1909
+ if (d.ast.value.length === 0) {
1910
+ return d;
1911
+ }
1912
+ const newDomain = new _Domain([]);
1913
+ processLeaf(d.ast.value, 0, "&", newDomain);
1914
+ return newDomain;
1915
+ }
1916
+ constructor(descr = []) {
1917
+ if (descr instanceof _Domain) {
1918
+ return new _Domain(descr.toString());
1919
+ } else {
1920
+ let rawAST;
1921
+ try {
1922
+ rawAST = typeof descr === "string" ? parseExpr(descr) : toAST(descr);
1923
+ } catch (error) {
1924
+ throw new InvalidDomainError(
1925
+ `Invalid domain representation: ${descr}`,
1926
+ {
1927
+ cause: error
1928
+ }
1929
+ );
1930
+ }
1931
+ this.ast = normalizeDomainAST(rawAST);
1932
+ }
1933
+ }
1934
+ contains(record) {
1935
+ const expr = evaluate(this.ast, record);
1936
+ return matchDomain(record, expr);
1937
+ }
1938
+ toString() {
1939
+ return formatAST(this.ast);
1940
+ }
1941
+ toList(context) {
1942
+ return evaluate(this.ast, context);
1943
+ }
1944
+ toJson() {
1945
+ try {
1946
+ const evaluatedAsList = this.toList({});
1947
+ const evaluatedDomain = new _Domain(evaluatedAsList);
1948
+ if (evaluatedDomain.toString() === this.toString()) {
1949
+ return evaluatedAsList;
1950
+ }
1951
+ return this.toString();
1952
+ } catch {
1953
+ return this.toString();
1954
+ }
1955
+ }
1956
+ };
1957
+ var TRUE_LEAF = [1, "=", 1];
1958
+ var FALSE_LEAF = [0, "=", 1];
1959
+ var TRUE_DOMAIN = new Domain([TRUE_LEAF]);
1960
+ var FALSE_DOMAIN = new Domain([FALSE_LEAF]);
1961
+ Domain.TRUE = TRUE_DOMAIN;
1962
+ Domain.FALSE = FALSE_DOMAIN;
1963
+ function toAST(domain) {
1964
+ const elems = domain.map((elem) => {
1965
+ switch (elem) {
1966
+ case "!":
1967
+ case "&":
1968
+ case "|":
1969
+ return { type: 1, value: elem };
1970
+ default:
1971
+ return {
1972
+ type: 10,
1973
+ value: elem.map(toPyValue)
1974
+ };
1975
+ }
1976
+ });
1977
+ return { type: 4, value: elems };
1978
+ }
1979
+ function normalizeDomainAST(domain, op = "&") {
1980
+ if (domain.type !== 4) {
1981
+ if (domain.type === 10) {
1982
+ const value = domain.value;
1983
+ if (value.findIndex((e) => e.type === 10) === -1 || !value.every((e) => e.type === 10 || e.type === 1)) {
1984
+ throw new InvalidDomainError("Invalid domain AST");
1985
+ }
1986
+ } else {
1987
+ throw new InvalidDomainError("Invalid domain AST");
1988
+ }
1989
+ }
1990
+ if (domain.value.length === 0) {
1991
+ return domain;
1992
+ }
1993
+ let expected = 1;
1994
+ for (const child of domain.value) {
1995
+ switch (child.type) {
1996
+ case 1:
1997
+ if (child.value === "&" || child.value === "|") {
1998
+ expected++;
1999
+ } else if (child.value !== "!") {
2000
+ throw new InvalidDomainError("Invalid domain AST");
2001
+ }
2002
+ break;
2003
+ case 4:
2004
+ /* list */
2356
2005
  case 10:
2357
- return ast2.value.map(_evaluate);
2358
- case 11:
2359
- const dict = {};
2360
- for (const key2 in ast2.value) {
2361
- dict[key2] = _evaluate(ast2.value[key2]);
2362
- }
2363
- dicts.add(dict);
2364
- return dict;
2365
- case 8:
2366
- const fnValue = _evaluate(ast2.fn);
2367
- const args = ast2.args.map(_evaluate);
2368
- const kwargs = {};
2369
- for (const kwarg in ast2.kwargs) {
2370
- kwargs[kwarg] = _evaluate(ast2?.kwargs[kwarg]);
2371
- }
2372
- if (fnValue === PyDate || fnValue === PyDateTime || fnValue === PyTime || fnValue === PyRelativeDelta || fnValue === PyTimeDelta) {
2373
- return fnValue.create(...args, kwargs);
2374
- }
2375
- return fnValue(...args, kwargs);
2376
- case 12:
2377
- const dictVal = _evaluate(ast2.target);
2378
- const key = _evaluate(ast2.key);
2379
- return dictVal[key];
2380
- case 13:
2381
- if (isTrue(_evaluate(ast2.condition))) {
2382
- return _evaluate(ast2.ifTrue);
2383
- } else {
2384
- return _evaluate(ast2.ifFalse);
2385
- }
2386
- case 15:
2387
- let leftVal = _evaluate(ast2.obj);
2388
- let result;
2389
- if (dicts.has(leftVal) || Object.isPrototypeOf.call(PY_DICT, leftVal)) {
2390
- result = DICT[ast2.key];
2391
- } else if (typeof leftVal === "string") {
2392
- result = STRING[ast2.key];
2393
- } else if (leftVal instanceof Set) {
2394
- result = SET[ast2.key];
2395
- } else if (ast2.key === "get" && typeof leftVal === "object") {
2396
- result = DICT[ast2.key];
2397
- leftVal = toPyDict(leftVal);
2398
- } else {
2399
- result = leftVal[ast2.key];
2400
- }
2401
- if (typeof result === "function") {
2402
- const bound = result.bind(leftVal);
2403
- bound[unboundFn] = result;
2404
- return bound;
2006
+ if (child.value.length === 3) {
2007
+ expected--;
2008
+ break;
2405
2009
  }
2406
- return result;
2010
+ throw new InvalidDomainError("Invalid domain AST");
2407
2011
  default:
2408
- throw new EvaluationError(`AST of type ${ast2.type} cannot be evaluated`);
2012
+ throw new InvalidDomainError("Invalid domain AST");
2409
2013
  }
2410
2014
  }
2411
- function _evaluate(ast2) {
2412
- const val = _innerEvaluate(ast2);
2413
- if (typeof val === "function" && !allowedFns.has(val) && !allowedFns.has(val[unboundFn])) {
2414
- throw new Error("Invalid Function Call");
2415
- }
2416
- return val;
2015
+ const values = domain.value.slice();
2016
+ while (expected < 0) {
2017
+ expected++;
2018
+ values.unshift({ type: 1, value: op });
2417
2019
  }
2418
- return _evaluate(ast);
2419
- }
2420
-
2421
- // src/utils/domain/py.ts
2422
- function parseExpr(expr) {
2423
- const tokens = tokenize(expr);
2424
- return parse(tokens);
2425
- }
2426
-
2427
- // src/utils/domain/objects.ts
2428
- function shallowEqual(obj1, obj2, comparisonFn = (a, b) => a === b) {
2429
- if (!obj1 || !obj2 || typeof obj1 !== "object" || typeof obj2 !== "object") {
2430
- return obj1 === obj2;
2020
+ if (expected > 0) {
2021
+ throw new InvalidDomainError(
2022
+ `invalid domain ${formatAST(domain)} (missing ${expected} segment(s))`
2023
+ );
2431
2024
  }
2432
- const obj1Keys = Object.keys(obj1);
2433
- return obj1Keys.length === Object.keys(obj2).length && obj1Keys.every((key) => comparisonFn(obj1[key], obj2[key]));
2434
- }
2435
-
2436
- // src/utils/domain/arrays.ts
2437
- var shallowEqual2 = shallowEqual;
2438
-
2439
- // src/utils/domain/strings.ts
2440
- var escapeMethod = Symbol("html");
2441
- function escapeRegExp(str) {
2442
- return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2025
+ return { type: 4, value: values };
2443
2026
  }
2444
-
2445
- // src/utils/domain/domain.ts
2446
- var InvalidDomainError = class extends Error {
2447
- };
2448
- var Domain = class _Domain {
2449
- ast = { type: -1, value: null };
2450
- static TRUE;
2451
- static FALSE;
2452
- static combine(domains, operator) {
2453
- if (domains.length === 0) {
2454
- return new _Domain([]);
2027
+ function matchCondition(record, condition) {
2028
+ if (typeof condition === "boolean") {
2029
+ return condition;
2030
+ }
2031
+ const [field, operator, value] = condition;
2032
+ if (typeof field === "string") {
2033
+ const names = field.split(".");
2034
+ if (names.length >= 2) {
2035
+ return matchCondition(record[names[0]], [
2036
+ names.slice(1).join("."),
2037
+ operator,
2038
+ value
2039
+ ]);
2455
2040
  }
2456
- const domain1 = domains[0] instanceof _Domain ? domains[0] : new _Domain(domains[0]);
2457
- if (domains.length === 1) {
2458
- return domain1;
2041
+ }
2042
+ let likeRegexp, ilikeRegexp;
2043
+ if (["like", "not like", "ilike", "not ilike"].includes(operator)) {
2044
+ likeRegexp = new RegExp(
2045
+ `(.*)${escapeRegExp(value).replaceAll("%", "(.*)")}(.*)`,
2046
+ "g"
2047
+ );
2048
+ ilikeRegexp = new RegExp(
2049
+ `(.*)${escapeRegExp(value).replaceAll("%", "(.*)")}(.*)`,
2050
+ "gi"
2051
+ );
2052
+ }
2053
+ const fieldValue = typeof field === "number" ? field : record[field];
2054
+ switch (operator) {
2055
+ case "=?":
2056
+ if ([false, null].includes(value)) {
2057
+ return true;
2058
+ }
2059
+ // eslint-disable-next-line no-fallthrough
2060
+ case "=":
2061
+ case "==":
2062
+ if (Array.isArray(fieldValue) && Array.isArray(value)) {
2063
+ return shallowEqual2(fieldValue, value);
2064
+ }
2065
+ return fieldValue === value;
2066
+ case "!=":
2067
+ case "<>":
2068
+ return !matchCondition(record, [field, "==", value]);
2069
+ case "<":
2070
+ return fieldValue < value;
2071
+ case "<=":
2072
+ return fieldValue <= value;
2073
+ case ">":
2074
+ return fieldValue > value;
2075
+ case ">=":
2076
+ return fieldValue >= value;
2077
+ case "in": {
2078
+ const val = Array.isArray(value) ? value : [value];
2079
+ const fieldVal = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
2080
+ return fieldVal.some((fv) => val.includes(fv));
2459
2081
  }
2460
- const domain2 = _Domain.combine(domains.slice(1), operator);
2461
- const result = new _Domain([]);
2462
- const astValues1 = domain1.ast.value;
2463
- const astValues2 = domain2.ast.value;
2464
- const op = operator === "AND" ? "&" : "|";
2465
- const combinedAST = {
2466
- type: 4,
2467
- value: astValues1.concat(astValues2)
2468
- };
2469
- result.ast = normalizeDomainAST(combinedAST, op);
2470
- return result;
2082
+ case "not in": {
2083
+ const val = Array.isArray(value) ? value : [value];
2084
+ const fieldVal = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
2085
+ return !fieldVal.some((fv) => val.includes(fv));
2086
+ }
2087
+ case "like":
2088
+ if (fieldValue === false) {
2089
+ return false;
2090
+ }
2091
+ return Boolean(fieldValue.match(likeRegexp));
2092
+ case "not like":
2093
+ if (fieldValue === false) {
2094
+ return false;
2095
+ }
2096
+ return Boolean(!fieldValue.match(likeRegexp));
2097
+ case "=like":
2098
+ if (fieldValue === false) {
2099
+ return false;
2100
+ }
2101
+ return new RegExp(escapeRegExp(value).replace(/%/g, ".*")).test(
2102
+ fieldValue
2103
+ );
2104
+ case "ilike":
2105
+ if (fieldValue === false) {
2106
+ return false;
2107
+ }
2108
+ return Boolean(fieldValue.match(ilikeRegexp));
2109
+ case "not ilike":
2110
+ if (fieldValue === false) {
2111
+ return false;
2112
+ }
2113
+ return Boolean(!fieldValue.match(ilikeRegexp));
2114
+ case "=ilike":
2115
+ if (fieldValue === false) {
2116
+ return false;
2117
+ }
2118
+ return new RegExp(escapeRegExp(value).replace(/%/g, ".*"), "i").test(
2119
+ fieldValue
2120
+ );
2471
2121
  }
2472
- static and(domains) {
2473
- return _Domain.combine(domains, "AND");
2122
+ throw new InvalidDomainError("could not match domain");
2123
+ }
2124
+ function makeOperators(record) {
2125
+ const match = matchCondition.bind(null, record);
2126
+ return {
2127
+ "!": (x) => !match(x),
2128
+ "&": (a, b) => match(a) && match(b),
2129
+ "|": (a, b) => match(a) || match(b)
2130
+ };
2131
+ }
2132
+ function matchDomain(record, domain) {
2133
+ if (domain.length === 0) {
2134
+ return true;
2474
2135
  }
2475
- static or(domains) {
2476
- return _Domain.combine(domains, "OR");
2136
+ const operators = makeOperators(record);
2137
+ const reversedDomain = Array.from(domain).reverse();
2138
+ const condStack = [];
2139
+ for (const item of reversedDomain) {
2140
+ const operator = typeof item === "string" && operators[item];
2141
+ if (operator) {
2142
+ const operands = condStack.splice(-operator.length);
2143
+ condStack.push(operator(...operands));
2144
+ } else {
2145
+ condStack.push(item);
2146
+ }
2147
+ }
2148
+ return matchCondition(record, condStack.pop());
2149
+ }
2150
+
2151
+ // src/utils/function.ts
2152
+ var import_react = require("react");
2153
+ var updateTokenParamInOriginalRequest = (originalRequest, newAccessToken) => {
2154
+ if (!originalRequest.data) return originalRequest.data;
2155
+ if (typeof originalRequest.data === "string") {
2156
+ try {
2157
+ const parsedData = JSON.parse(originalRequest.data);
2158
+ if (parsedData.with_context && typeof parsedData.with_context === "object") {
2159
+ parsedData.with_context.token = newAccessToken;
2160
+ }
2161
+ return JSON.stringify(parsedData);
2162
+ } catch (e) {
2163
+ console.warn("Failed to parse originalRequest.data", e);
2164
+ return originalRequest.data;
2165
+ }
2477
2166
  }
2478
- static not(domain) {
2479
- const result = new _Domain(domain);
2480
- result.ast.value.unshift({ type: 1, value: "!" });
2481
- return result;
2167
+ if (typeof originalRequest.data === "object" && originalRequest.data.with_context) {
2168
+ originalRequest.data.with_context.token = newAccessToken;
2482
2169
  }
2483
- static removeDomainLeaves(domain, keysToRemove) {
2484
- function processLeaf(elements, idx, operatorCtx, newDomain2) {
2485
- const leaf = elements[idx];
2486
- if (leaf.type === 10) {
2487
- if (keysToRemove.includes(leaf.value[0].value)) {
2488
- if (operatorCtx === "&") {
2489
- newDomain2.ast.value.push(..._Domain.TRUE.ast.value);
2490
- } else if (operatorCtx === "|") {
2491
- newDomain2.ast.value.push(..._Domain.FALSE.ast.value);
2492
- }
2170
+ return originalRequest.data;
2171
+ };
2172
+
2173
+ // src/utils/storage/local-storage.ts
2174
+ var localStorageUtils = () => {
2175
+ const setToken = async (access_token) => {
2176
+ localStorage.setItem("accessToken", access_token);
2177
+ };
2178
+ const setRefreshToken = async (refresh_token) => {
2179
+ localStorage.setItem("refreshToken", refresh_token);
2180
+ };
2181
+ const getAccessToken = async () => {
2182
+ return localStorage.getItem("accessToken");
2183
+ };
2184
+ const getRefreshToken = async () => {
2185
+ return localStorage.getItem("refreshToken");
2186
+ };
2187
+ const clearToken = async () => {
2188
+ localStorage.removeItem("accessToken");
2189
+ localStorage.removeItem("refreshToken");
2190
+ };
2191
+ return {
2192
+ setToken,
2193
+ setRefreshToken,
2194
+ getAccessToken,
2195
+ getRefreshToken,
2196
+ clearToken
2197
+ };
2198
+ };
2199
+
2200
+ // src/utils/storage/session-storage.ts
2201
+ var sessionStorageUtils = () => {
2202
+ const getBrowserSession = async () => {
2203
+ return sessionStorage.getItem("browserSession");
2204
+ };
2205
+ return {
2206
+ getBrowserSession
2207
+ };
2208
+ };
2209
+
2210
+ // src/configs/axios-client.ts
2211
+ var axiosClient = {
2212
+ init(config) {
2213
+ const localStorage2 = config.localStorageUtils ?? localStorageUtils();
2214
+ const sessionStorage2 = config.sessionStorageUtils ?? sessionStorageUtils();
2215
+ const db = config.db;
2216
+ let isRefreshing = false;
2217
+ let failedQueue = [];
2218
+ const processQueue = (error, token = null) => {
2219
+ failedQueue?.forEach((prom) => {
2220
+ if (error) {
2221
+ prom.reject(error);
2493
2222
  } else {
2494
- newDomain2.ast.value.push(leaf);
2495
- }
2496
- return 1;
2497
- } else if (leaf.type === 1) {
2498
- 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)) {
2499
- newDomain2.ast.value.push(..._Domain.TRUE.ast.value);
2500
- return 3;
2223
+ prom.resolve(token);
2501
2224
  }
2502
- newDomain2.ast.value.push(leaf);
2503
- if (leaf.value === "!") {
2504
- return 1 + processLeaf(elements, idx + 1, "&", newDomain2);
2225
+ });
2226
+ failedQueue = [];
2227
+ };
2228
+ const instance = import_axios.default.create({
2229
+ adapter: import_axios.default.defaults.adapter,
2230
+ baseURL: config.baseUrl,
2231
+ timeout: 5e4,
2232
+ paramsSerializer: (params) => new URLSearchParams(params).toString()
2233
+ });
2234
+ instance.interceptors.request.use(
2235
+ async (config2) => {
2236
+ const useRefreshToken = config2.useRefreshToken;
2237
+ const token = useRefreshToken ? await localStorage2.getRefreshToken() : await localStorage2.getAccessToken();
2238
+ if (token) {
2239
+ config2.headers["Authorization"] = "Bearer " + token;
2505
2240
  }
2506
- const firstLeafSkip = processLeaf(
2507
- elements,
2508
- idx + 1,
2509
- leaf.value,
2510
- newDomain2
2511
- );
2512
- const secondLeafSkip = processLeaf(
2513
- elements,
2514
- idx + 1 + firstLeafSkip,
2515
- leaf.value,
2516
- newDomain2
2517
- );
2518
- return 1 + firstLeafSkip + secondLeafSkip;
2241
+ return config2;
2242
+ },
2243
+ (error) => {
2244
+ Promise.reject(error);
2519
2245
  }
2520
- return 0;
2521
- }
2522
- const d = new _Domain(domain);
2523
- if (d.ast.value.length === 0) {
2524
- return d;
2525
- }
2526
- const newDomain = new _Domain([]);
2527
- processLeaf(d.ast.value, 0, "&", newDomain);
2528
- return newDomain;
2529
- }
2530
- constructor(descr = []) {
2531
- if (descr instanceof _Domain) {
2532
- return new _Domain(descr.toString());
2533
- } else {
2534
- let rawAST;
2535
- try {
2536
- rawAST = typeof descr === "string" ? parseExpr(descr) : toAST(descr);
2537
- } catch (error) {
2538
- throw new InvalidDomainError(
2539
- `Invalid domain representation: ${descr}`,
2540
- {
2541
- cause: error
2246
+ );
2247
+ instance.interceptors.response.use(
2248
+ (response) => {
2249
+ return handleResponse(response);
2250
+ },
2251
+ async (error) => {
2252
+ const handleError3 = async (error2) => {
2253
+ if (!error2.response) {
2254
+ return error2;
2542
2255
  }
2543
- );
2256
+ const { data } = error2.response;
2257
+ if (data && data.code === 400 && ["invalid_grant"].includes(data.data?.error)) {
2258
+ await clearAuthToken();
2259
+ }
2260
+ return data;
2261
+ };
2262
+ const originalRequest = error.config;
2263
+ if ((error.response?.status === 403 || error.response?.status === 401 || error.response?.status === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401, "ERR_2FA_006"].includes(
2264
+ error.response.data.code
2265
+ )) {
2266
+ if (isRefreshing) {
2267
+ return new Promise(function(resolve, reject) {
2268
+ failedQueue.push({ resolve, reject });
2269
+ }).then((token) => {
2270
+ originalRequest.headers["Authorization"] = "Bearer " + token;
2271
+ originalRequest.data = updateTokenParamInOriginalRequest(
2272
+ originalRequest,
2273
+ token
2274
+ );
2275
+ return instance.request(originalRequest);
2276
+ }).catch(async (err) => {
2277
+ if ((err.response?.status === 400 || err.response?.status === 401) && ["invalid_grant"].includes(err.response.data.error)) {
2278
+ await clearAuthToken();
2279
+ }
2280
+ });
2281
+ }
2282
+ const browserSession = await sessionStorage2.getBrowserSession();
2283
+ const refreshToken = await localStorage2.getRefreshToken();
2284
+ const accessTokenExp = await localStorage2.getAccessToken();
2285
+ isRefreshing = true;
2286
+ if (!refreshToken && (!browserSession || browserSession == "unActive")) {
2287
+ await clearAuthToken();
2288
+ } else {
2289
+ const payload = Object.fromEntries(
2290
+ Object.entries({
2291
+ refresh_token: refreshToken,
2292
+ grant_type: "refresh_token",
2293
+ client_id: config.config.clientId,
2294
+ client_secret: config.config.clientSecret
2295
+ }).filter(([_, value]) => !!value)
2296
+ );
2297
+ return new Promise(function(resolve) {
2298
+ import_axios.default.post(
2299
+ `${config.baseUrl}${config.refreshTokenEndpoint ?? "/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
2300
+ payload,
2301
+ {
2302
+ headers: {
2303
+ "Content-Type": config.refreshTokenEndpoint ? "application/x-www-form-urlencoded" : "multipart/form-data",
2304
+ Authorization: `Bearer ${accessTokenExp}`
2305
+ }
2306
+ }
2307
+ ).then(async (res) => {
2308
+ const data = res.data;
2309
+ await localStorage2.setToken(data.access_token);
2310
+ await localStorage2.setRefreshToken(data.refresh_token);
2311
+ import_axios.default.defaults.headers.common["Authorization"] = "Bearer " + data.access_token;
2312
+ originalRequest.headers["Authorization"] = "Bearer " + data.access_token;
2313
+ originalRequest.data = updateTokenParamInOriginalRequest(
2314
+ originalRequest,
2315
+ data.access_token
2316
+ );
2317
+ processQueue(null, data.access_token);
2318
+ resolve(instance.request(originalRequest));
2319
+ }).catch(async (err) => {
2320
+ 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") {
2321
+ await clearAuthToken();
2322
+ }
2323
+ if (err && err.response) {
2324
+ const { error_code } = err.response?.data || {};
2325
+ if (error_code === "AUTHEN_FAIL") {
2326
+ await clearAuthToken();
2327
+ }
2328
+ }
2329
+ processQueue(err, null);
2330
+ }).finally(() => {
2331
+ isRefreshing = false;
2332
+ });
2333
+ });
2334
+ }
2335
+ }
2336
+ return Promise.reject(await handleError3(error));
2544
2337
  }
2545
- this.ast = normalizeDomainAST(rawAST);
2546
- }
2547
- }
2548
- contains(record) {
2549
- const expr = evaluate(this.ast, record);
2550
- return matchDomain(record, expr);
2551
- }
2552
- toString() {
2553
- return formatAST(this.ast);
2554
- }
2555
- toList(context) {
2556
- return evaluate(this.ast, context);
2557
- }
2558
- toJson() {
2559
- try {
2560
- const evaluatedAsList = this.toList({});
2561
- const evaluatedDomain = new _Domain(evaluatedAsList);
2562
- if (evaluatedDomain.toString() === this.toString()) {
2563
- return evaluatedAsList;
2338
+ );
2339
+ const handleResponse = (res) => {
2340
+ if (res && res.data) {
2341
+ return res.data;
2342
+ }
2343
+ return res;
2344
+ };
2345
+ const handleError2 = (error) => {
2346
+ if (error.isAxiosError && error.code === "ECONNABORTED") {
2347
+ console.error("Request Timeout Error:", error);
2348
+ return "Request Timeout Error";
2349
+ } else if (error.isAxiosError && !error.response) {
2350
+ console.error("Network Error:", error);
2351
+ return "Network Error";
2352
+ } else {
2353
+ console.error("Other Error:", error?.response);
2354
+ const errorMessage = error?.response?.data?.message || "An error occurred";
2355
+ return { message: errorMessage, status: error?.response?.status };
2564
2356
  }
2565
- return this.toString();
2566
- } catch {
2567
- return this.toString();
2357
+ };
2358
+ const clearAuthToken = async () => {
2359
+ await localStorage2.clearToken();
2360
+ if (typeof window !== "undefined") {
2361
+ window.location.href = `/login`;
2362
+ }
2363
+ };
2364
+ function formatUrl(url, db2) {
2365
+ return url + (db2 ? "?db=" + db2 : "");
2568
2366
  }
2367
+ const responseBody = (response) => response;
2368
+ const requests = {
2369
+ get: (url, headers) => instance.get(formatUrl(url, db), headers).then(responseBody),
2370
+ post: (url, body, headers) => instance.post(formatUrl(url, db), body, headers).then(responseBody),
2371
+ post_excel: (url, body, headers) => instance.post(formatUrl(url, db), body, {
2372
+ responseType: "arraybuffer",
2373
+ headers: {
2374
+ "Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
2375
+ Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
2376
+ }
2377
+ }).then(responseBody),
2378
+ put: (url, body, headers) => instance.put(formatUrl(url, db), body, headers).then(responseBody),
2379
+ patch: (url, body) => instance.patch(formatUrl(url, db), body).then(responseBody),
2380
+ delete: (url, body) => instance.delete(formatUrl(url, db), body).then(responseBody)
2381
+ };
2382
+ return requests;
2569
2383
  }
2570
2384
  };
2571
- var TRUE_LEAF = [1, "=", 1];
2572
- var FALSE_LEAF = [0, "=", 1];
2573
- var TRUE_DOMAIN = new Domain([TRUE_LEAF]);
2574
- var FALSE_DOMAIN = new Domain([FALSE_LEAF]);
2575
- Domain.TRUE = TRUE_DOMAIN;
2576
- Domain.FALSE = FALSE_DOMAIN;
2577
- function toAST(domain) {
2578
- const elems = domain.map((elem) => {
2579
- switch (elem) {
2580
- case "!":
2581
- case "&":
2582
- case "|":
2583
- return { type: 1, value: elem };
2584
- default:
2585
- return {
2586
- type: 10,
2587
- value: elem.map(toPyValue)
2588
- };
2589
- }
2590
- });
2591
- return { type: 4, value: elems };
2592
- }
2593
- function normalizeDomainAST(domain, op = "&") {
2594
- if (domain.type !== 4) {
2595
- if (domain.type === 10) {
2596
- const value = domain.value;
2597
- if (value.findIndex((e) => e.type === 10) === -1 || !value.every((e) => e.type === 10 || e.type === 1)) {
2598
- throw new InvalidDomainError("Invalid domain AST");
2599
- }
2600
- } else {
2601
- throw new InvalidDomainError("Invalid domain AST");
2385
+
2386
+ // src/store/index.ts
2387
+ var import_react_redux = require("react-redux");
2388
+
2389
+ // src/store/reducers/breadcrums-slice/index.ts
2390
+ var import_toolkit = require("@reduxjs/toolkit");
2391
+ var initialState = {
2392
+ breadCrumbs: []
2393
+ };
2394
+ var breadcrumbsSlice = (0, import_toolkit.createSlice)({
2395
+ name: "breadcrumbs",
2396
+ initialState,
2397
+ reducers: {
2398
+ setBreadCrumbs: (state, action) => {
2399
+ state.breadCrumbs = [...state.breadCrumbs, action.payload];
2602
2400
  }
2603
2401
  }
2604
- if (domain.value.length === 0) {
2605
- return domain;
2402
+ });
2403
+ var { setBreadCrumbs } = breadcrumbsSlice.actions;
2404
+ var breadcrums_slice_default = breadcrumbsSlice.reducer;
2405
+
2406
+ // src/store/reducers/env-slice/index.ts
2407
+ var import_toolkit2 = require("@reduxjs/toolkit");
2408
+ var initialState2 = {
2409
+ baseUrl: "",
2410
+ requests: null,
2411
+ companies: [],
2412
+ user: {},
2413
+ config: null,
2414
+ envFile: null,
2415
+ defaultCompany: {
2416
+ id: null,
2417
+ logo: "",
2418
+ secondary_color: "",
2419
+ primary_color: ""
2420
+ },
2421
+ context: {
2422
+ uid: null,
2423
+ allowed_company_ids: [],
2424
+ lang: "vi_VN",
2425
+ tz: "Asia/Saigon"
2606
2426
  }
2607
- let expected = 1;
2608
- for (const child of domain.value) {
2609
- switch (child.type) {
2610
- case 1:
2611
- if (child.value === "&" || child.value === "|") {
2612
- expected++;
2613
- } else if (child.value !== "!") {
2614
- throw new InvalidDomainError("Invalid domain AST");
2615
- }
2616
- break;
2617
- case 4:
2618
- /* list */
2619
- case 10:
2620
- if (child.value.length === 3) {
2621
- expected--;
2622
- break;
2623
- }
2624
- throw new InvalidDomainError("Invalid domain AST");
2625
- default:
2626
- throw new InvalidDomainError("Invalid domain AST");
2427
+ };
2428
+ var envSlice = (0, import_toolkit2.createSlice)({
2429
+ name: "env",
2430
+ initialState: initialState2,
2431
+ reducers: {
2432
+ setEnv: (state, action) => {
2433
+ Object.assign(state, action.payload);
2434
+ },
2435
+ setUid: (state, action) => {
2436
+ state.context.uid = action.payload;
2437
+ },
2438
+ setAllowCompanies: (state, action) => {
2439
+ state.context.allowed_company_ids = action.payload;
2440
+ },
2441
+ setCompanies: (state, action) => {
2442
+ state.companies = action.payload;
2443
+ },
2444
+ setDefaultCompany: (state, action) => {
2445
+ state.defaultCompany = action.payload;
2446
+ },
2447
+ setLang: (state, action) => {
2448
+ state.context.lang = action.payload;
2449
+ },
2450
+ setUser: (state, action) => {
2451
+ state.user = action.payload;
2452
+ },
2453
+ setConfig: (state, action) => {
2454
+ state.config = action.payload;
2455
+ },
2456
+ setEnvFile: (state, action) => {
2457
+ state.envFile = action.payload;
2627
2458
  }
2628
2459
  }
2629
- const values = domain.value.slice();
2630
- while (expected < 0) {
2631
- expected++;
2632
- values.unshift({ type: 1, value: op });
2633
- }
2634
- if (expected > 0) {
2635
- throw new InvalidDomainError(
2636
- `invalid domain ${formatAST(domain)} (missing ${expected} segment(s))`
2637
- );
2638
- }
2639
- return { type: 4, value: values };
2640
- }
2641
- function matchCondition(record, condition) {
2642
- if (typeof condition === "boolean") {
2643
- return condition;
2460
+ });
2461
+ var {
2462
+ setEnv,
2463
+ setUid,
2464
+ setLang,
2465
+ setAllowCompanies,
2466
+ setCompanies,
2467
+ setDefaultCompany,
2468
+ setUser,
2469
+ setConfig,
2470
+ setEnvFile
2471
+ } = envSlice.actions;
2472
+ var env_slice_default = envSlice.reducer;
2473
+
2474
+ // src/store/reducers/excel-slice/index.ts
2475
+ var import_toolkit3 = require("@reduxjs/toolkit");
2476
+ var initialState3 = {
2477
+ dataParse: null,
2478
+ idFile: null,
2479
+ isFileLoaded: false,
2480
+ loadingImport: false,
2481
+ selectedFile: null,
2482
+ errorData: null
2483
+ };
2484
+ var excelSlice = (0, import_toolkit3.createSlice)({
2485
+ name: "excel",
2486
+ initialState: initialState3,
2487
+ reducers: {
2488
+ setDataParse: (state, action) => {
2489
+ state.dataParse = action.payload;
2490
+ },
2491
+ setIdFile: (state, action) => {
2492
+ state.idFile = action.payload;
2493
+ },
2494
+ setIsFileLoaded: (state, action) => {
2495
+ state.isFileLoaded = action.payload;
2496
+ },
2497
+ setLoadingImport: (state, action) => {
2498
+ state.loadingImport = action.payload;
2499
+ },
2500
+ setSelectedFile: (state, action) => {
2501
+ state.selectedFile = action.payload;
2502
+ },
2503
+ setErrorData: (state, action) => {
2504
+ state.errorData = action.payload;
2505
+ }
2644
2506
  }
2645
- const [field, operator, value] = condition;
2646
- if (typeof field === "string") {
2647
- const names = field.split(".");
2648
- if (names.length >= 2) {
2649
- return matchCondition(record[names[0]], [
2650
- names.slice(1).join("."),
2651
- operator,
2652
- value
2653
- ]);
2507
+ });
2508
+ var {
2509
+ setDataParse,
2510
+ setIdFile,
2511
+ setIsFileLoaded,
2512
+ setLoadingImport,
2513
+ setSelectedFile,
2514
+ setErrorData
2515
+ } = excelSlice.actions;
2516
+ var excel_slice_default = excelSlice.reducer;
2517
+
2518
+ // src/store/reducers/form-slice/index.ts
2519
+ var import_toolkit4 = require("@reduxjs/toolkit");
2520
+ var initialState4 = {
2521
+ viewDataStore: {},
2522
+ isShowingModalDetail: false,
2523
+ isShowModalTranslate: false,
2524
+ formSubmitComponent: {},
2525
+ fieldTranslation: null,
2526
+ listSubject: {},
2527
+ dataUser: {}
2528
+ };
2529
+ var formSlice = (0, import_toolkit4.createSlice)({
2530
+ name: "form",
2531
+ initialState: initialState4,
2532
+ reducers: {
2533
+ setViewDataStore: (state, action) => {
2534
+ state.viewDataStore = action.payload;
2535
+ },
2536
+ setIsShowingModalDetail: (state, action) => {
2537
+ state.isShowingModalDetail = action.payload;
2538
+ },
2539
+ setIsShowModalTranslate: (state, action) => {
2540
+ state.isShowModalTranslate = action.payload;
2541
+ },
2542
+ setFormSubmitComponent: (state, action) => {
2543
+ state.formSubmitComponent[action.payload.key] = action.payload.component;
2544
+ },
2545
+ setFieldTranslate: (state, action) => {
2546
+ state.fieldTranslation = action.payload;
2547
+ },
2548
+ setListSubject: (state, action) => {
2549
+ state.listSubject = action.payload;
2550
+ },
2551
+ setDataUser: (state, action) => {
2552
+ state.dataUser = action.payload;
2654
2553
  }
2655
2554
  }
2656
- let likeRegexp, ilikeRegexp;
2657
- if (["like", "not like", "ilike", "not ilike"].includes(operator)) {
2658
- likeRegexp = new RegExp(
2659
- `(.*)${escapeRegExp(value).replaceAll("%", "(.*)")}(.*)`,
2660
- "g"
2661
- );
2662
- ilikeRegexp = new RegExp(
2663
- `(.*)${escapeRegExp(value).replaceAll("%", "(.*)")}(.*)`,
2664
- "gi"
2665
- );
2666
- }
2667
- const fieldValue = typeof field === "number" ? field : record[field];
2668
- switch (operator) {
2669
- case "=?":
2670
- if ([false, null].includes(value)) {
2671
- return true;
2672
- }
2673
- // eslint-disable-next-line no-fallthrough
2674
- case "=":
2675
- case "==":
2676
- if (Array.isArray(fieldValue) && Array.isArray(value)) {
2677
- return shallowEqual2(fieldValue, value);
2678
- }
2679
- return fieldValue === value;
2680
- case "!=":
2681
- case "<>":
2682
- return !matchCondition(record, [field, "==", value]);
2683
- case "<":
2684
- return fieldValue < value;
2685
- case "<=":
2686
- return fieldValue <= value;
2687
- case ">":
2688
- return fieldValue > value;
2689
- case ">=":
2690
- return fieldValue >= value;
2691
- case "in": {
2692
- const val = Array.isArray(value) ? value : [value];
2693
- const fieldVal = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
2694
- return fieldVal.some((fv) => val.includes(fv));
2555
+ });
2556
+ var {
2557
+ setViewDataStore,
2558
+ setIsShowingModalDetail,
2559
+ setIsShowModalTranslate,
2560
+ setFormSubmitComponent,
2561
+ setFieldTranslate,
2562
+ setListSubject,
2563
+ setDataUser
2564
+ } = formSlice.actions;
2565
+ var form_slice_default = formSlice.reducer;
2566
+
2567
+ // src/store/reducers/header-slice/index.ts
2568
+ var import_toolkit5 = require("@reduxjs/toolkit");
2569
+ var headerSlice = (0, import_toolkit5.createSlice)({
2570
+ name: "header",
2571
+ initialState: {
2572
+ value: { allowedCompanyIds: [] }
2573
+ },
2574
+ reducers: {
2575
+ setHeader: (state, action) => {
2576
+ state.value = { ...state.value, ...action.payload };
2577
+ },
2578
+ setAllowedCompanyIds: (state, action) => {
2579
+ state.value.allowedCompanyIds = action.payload;
2695
2580
  }
2696
- case "not in": {
2697
- const val = Array.isArray(value) ? value : [value];
2698
- const fieldVal = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
2699
- return !fieldVal.some((fv) => val.includes(fv));
2581
+ }
2582
+ });
2583
+ var { setAllowedCompanyIds, setHeader } = headerSlice.actions;
2584
+ var header_slice_default = headerSlice.reducer;
2585
+
2586
+ // src/store/reducers/list-slice/index.ts
2587
+ var import_toolkit6 = require("@reduxjs/toolkit");
2588
+ var initialState5 = {
2589
+ pageLimit: 10,
2590
+ fields: {},
2591
+ order: "",
2592
+ selectedRowKeys: [],
2593
+ selectedRadioKey: 0,
2594
+ indexRowTableModal: -2,
2595
+ isUpdateTableModal: false,
2596
+ footerGroupTable: {},
2597
+ transferDetail: null,
2598
+ page: 0,
2599
+ domainTable: []
2600
+ };
2601
+ var listSlice = (0, import_toolkit6.createSlice)({
2602
+ name: "list",
2603
+ initialState: initialState5,
2604
+ reducers: {
2605
+ setPageLimit: (state, action) => {
2606
+ state.pageLimit = action.payload;
2607
+ },
2608
+ setFields: (state, action) => {
2609
+ state.fields = action.payload;
2610
+ },
2611
+ setOrder: (state, action) => {
2612
+ state.order = action.payload;
2613
+ },
2614
+ setSelectedRowKeys: (state, action) => {
2615
+ state.selectedRowKeys = action.payload;
2616
+ },
2617
+ setSelectedRadioKey: (state, action) => {
2618
+ state.selectedRadioKey = action.payload;
2619
+ },
2620
+ setIndexRowTableModal: (state, action) => {
2621
+ state.indexRowTableModal = action.payload;
2622
+ },
2623
+ setTransferDetail: (state, action) => {
2624
+ state.transferDetail = action.payload;
2625
+ },
2626
+ setIsUpdateTableModal: (state, action) => {
2627
+ state.isUpdateTableModal = action.payload;
2628
+ },
2629
+ setPage: (state, action) => {
2630
+ state.page = action.payload;
2631
+ },
2632
+ setDomainTable: (state, action) => {
2633
+ state.domainTable = action.payload;
2700
2634
  }
2701
- case "like":
2702
- if (fieldValue === false) {
2703
- return false;
2704
- }
2705
- return Boolean(fieldValue.match(likeRegexp));
2706
- case "not like":
2707
- if (fieldValue === false) {
2708
- return false;
2709
- }
2710
- return Boolean(!fieldValue.match(likeRegexp));
2711
- case "=like":
2712
- if (fieldValue === false) {
2713
- return false;
2714
- }
2715
- return new RegExp(escapeRegExp(value).replace(/%/g, ".*")).test(
2716
- fieldValue
2717
- );
2718
- case "ilike":
2719
- if (fieldValue === false) {
2720
- return false;
2721
- }
2722
- return Boolean(fieldValue.match(ilikeRegexp));
2723
- case "not ilike":
2724
- if (fieldValue === false) {
2725
- return false;
2726
- }
2727
- return Boolean(!fieldValue.match(ilikeRegexp));
2728
- case "=ilike":
2729
- if (fieldValue === false) {
2730
- return false;
2731
- }
2732
- return new RegExp(escapeRegExp(value).replace(/%/g, ".*"), "i").test(
2733
- fieldValue
2734
- );
2735
2635
  }
2736
- throw new InvalidDomainError("could not match domain");
2737
- }
2738
- function makeOperators(record) {
2739
- const match = matchCondition.bind(null, record);
2740
- return {
2741
- "!": (x) => !match(x),
2742
- "&": (a, b) => match(a) && match(b),
2743
- "|": (a, b) => match(a) || match(b)
2744
- };
2745
- }
2746
- function matchDomain(record, domain) {
2747
- if (domain.length === 0) {
2748
- return true;
2636
+ });
2637
+ var {
2638
+ setPageLimit,
2639
+ setFields,
2640
+ setOrder,
2641
+ setSelectedRowKeys,
2642
+ setIndexRowTableModal,
2643
+ setIsUpdateTableModal,
2644
+ setPage,
2645
+ setSelectedRadioKey,
2646
+ setTransferDetail,
2647
+ setDomainTable
2648
+ } = listSlice.actions;
2649
+ var list_slice_default = listSlice.reducer;
2650
+
2651
+ // src/store/reducers/login-slice/index.ts
2652
+ var import_toolkit7 = require("@reduxjs/toolkit");
2653
+ var initialState6 = {
2654
+ db: "",
2655
+ redirectTo: "/",
2656
+ forgotPasswordUrl: "/"
2657
+ };
2658
+ var loginSlice = (0, import_toolkit7.createSlice)({
2659
+ name: "login",
2660
+ initialState: initialState6,
2661
+ reducers: {
2662
+ setDb: (state, action) => {
2663
+ state.db = action.payload;
2664
+ },
2665
+ setRedirectTo: (state, action) => {
2666
+ state.redirectTo = action.payload;
2667
+ },
2668
+ setForgotPasswordUrl: (state, action) => {
2669
+ state.forgotPasswordUrl = action.payload;
2670
+ }
2749
2671
  }
2750
- const operators = makeOperators(record);
2751
- const reversedDomain = Array.from(domain).reverse();
2752
- const condStack = [];
2753
- for (const item of reversedDomain) {
2754
- const operator = typeof item === "string" && operators[item];
2755
- if (operator) {
2756
- const operands = condStack.splice(-operator.length);
2757
- condStack.push(operator(...operands));
2758
- } else {
2759
- condStack.push(item);
2672
+ });
2673
+ var { setDb, setRedirectTo, setForgotPasswordUrl } = loginSlice.actions;
2674
+ var login_slice_default = loginSlice.reducer;
2675
+
2676
+ // src/store/reducers/navbar-slice/index.ts
2677
+ var import_toolkit8 = require("@reduxjs/toolkit");
2678
+ var initialState7 = {
2679
+ menuFocus: {},
2680
+ menuAction: {},
2681
+ navbarWidth: 250,
2682
+ menuList: []
2683
+ };
2684
+ var navbarSlice = (0, import_toolkit8.createSlice)({
2685
+ name: "navbar",
2686
+ initialState: initialState7,
2687
+ reducers: {
2688
+ setMenuFocus: (state, action) => {
2689
+ state.menuFocus = action.payload;
2690
+ },
2691
+ setMenuFocusAction: (state, action) => {
2692
+ state.menuAction = action.payload;
2693
+ },
2694
+ setNavbarWidth: (state, action) => {
2695
+ state.navbarWidth = action.payload;
2696
+ },
2697
+ setMenuList: (state, action) => {
2698
+ state.menuList = action.payload;
2760
2699
  }
2761
2700
  }
2762
- return matchCondition(record, condStack.pop());
2763
- }
2701
+ });
2702
+ var { setMenuFocus, setMenuFocusAction, setNavbarWidth, setMenuList } = navbarSlice.actions;
2703
+ var navbar_slice_default = navbarSlice.reducer;
2764
2704
 
2765
- // src/utils/function.ts
2766
- var import_react = require("react");
2767
- var updateTokenParamInOriginalRequest = (originalRequest, newAccessToken) => {
2768
- if (!originalRequest.data) return originalRequest.data;
2769
- if (typeof originalRequest.data === "string") {
2770
- try {
2771
- const parsedData = JSON.parse(originalRequest.data);
2772
- if (parsedData.with_context && typeof parsedData.with_context === "object") {
2773
- parsedData.with_context.token = newAccessToken;
2774
- }
2775
- return JSON.stringify(parsedData);
2776
- } catch (e) {
2777
- console.warn("Failed to parse originalRequest.data", e);
2778
- return originalRequest.data;
2705
+ // src/store/reducers/profile-slice/index.ts
2706
+ var import_toolkit9 = require("@reduxjs/toolkit");
2707
+ var initialState8 = {
2708
+ profile: {}
2709
+ };
2710
+ var profileSlice = (0, import_toolkit9.createSlice)({
2711
+ name: "profile",
2712
+ initialState: initialState8,
2713
+ reducers: {
2714
+ setProfile: (state, action) => {
2715
+ state.profile = action.payload;
2779
2716
  }
2780
2717
  }
2781
- if (typeof originalRequest.data === "object" && originalRequest.data.with_context) {
2782
- originalRequest.data.with_context.token = newAccessToken;
2783
- }
2784
- return originalRequest.data;
2785
- };
2786
-
2787
- // src/utils/storage/local-storage.ts
2788
- var localStorageUtils = () => {
2789
- const setToken = async (access_token) => {
2790
- localStorage.setItem("accessToken", access_token);
2791
- };
2792
- const setRefreshToken = async (refresh_token) => {
2793
- localStorage.setItem("refreshToken", refresh_token);
2794
- };
2795
- const getAccessToken = async () => {
2796
- return localStorage.getItem("accessToken");
2797
- };
2798
- const getRefreshToken = async () => {
2799
- return localStorage.getItem("refreshToken");
2800
- };
2801
- const clearToken = async () => {
2802
- localStorage.removeItem("accessToken");
2803
- localStorage.removeItem("refreshToken");
2804
- };
2805
- return {
2806
- setToken,
2807
- setRefreshToken,
2808
- getAccessToken,
2809
- getRefreshToken,
2810
- clearToken
2811
- };
2812
- };
2718
+ });
2719
+ var { setProfile } = profileSlice.actions;
2720
+ var profile_slice_default = profileSlice.reducer;
2813
2721
 
2814
- // src/utils/storage/session-storage.ts
2815
- var sessionStorageUtils = () => {
2816
- const getBrowserSession = async () => {
2817
- return sessionStorage.getItem("browserSession");
2818
- };
2819
- return {
2820
- getBrowserSession
2821
- };
2722
+ // src/store/reducers/search-slice/index.ts
2723
+ var import_toolkit10 = require("@reduxjs/toolkit");
2724
+ var initialState9 = {
2725
+ groupByDomain: null,
2726
+ searchBy: [],
2727
+ searchString: "",
2728
+ hoveredIndexSearchList: null,
2729
+ selectedTags: [],
2730
+ firstDomain: null,
2731
+ searchMap: {},
2732
+ filterBy: [],
2733
+ groupBy: []
2822
2734
  };
2823
-
2824
- // src/configs/axios-client.ts
2825
- var axiosClient = {
2826
- init(config) {
2827
- const localStorage2 = config.localStorageUtils ?? localStorageUtils();
2828
- const sessionStorage2 = config.sessionStorageUtils ?? sessionStorageUtils();
2829
- const db = config.db;
2830
- let isRefreshing = false;
2831
- let failedQueue = [];
2832
- const processQueue = (error, token = null) => {
2833
- failedQueue?.forEach((prom) => {
2834
- if (error) {
2835
- prom.reject(error);
2836
- } else {
2837
- prom.resolve(token);
2838
- }
2839
- });
2840
- failedQueue = [];
2841
- };
2842
- const instance = import_axios.default.create({
2843
- adapter: import_axios.default.defaults.adapter,
2844
- baseURL: config.baseUrl,
2845
- timeout: 5e4,
2846
- paramsSerializer: (params) => new URLSearchParams(params).toString()
2847
- });
2848
- instance.interceptors.request.use(async (config2) => {
2849
- const { useRefreshToken, useActionToken, actionToken } = config2;
2850
- if (useActionToken && actionToken) {
2851
- config2.headers["Action-Token"] = actionToken;
2852
- }
2853
- const getToken = useRefreshToken ? localStorage2.getRefreshToken : localStorage2.getAccessToken;
2854
- const token = await getToken?.();
2855
- if (token) config2.headers["Authorization"] = `Bearer ${token}`;
2856
- return config2;
2857
- }, Promise.reject);
2858
- instance.interceptors.response.use(
2859
- (response) => {
2860
- return handleResponse(response);
2861
- },
2862
- async (error) => {
2863
- const handleError3 = async (error2) => {
2864
- if (!error2.response) {
2865
- return error2;
2866
- }
2867
- const { data } = error2.response;
2868
- if (data && data.code === 400 && ["invalid_grant"].includes(data.data?.error)) {
2869
- await clearAuthToken();
2870
- }
2871
- return data;
2872
- };
2873
- const originalRequest = error.config;
2874
- if ((error.response?.status === 403 || error.response?.status === 401 || error.response?.status === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401, "ERR_2FA_006"].includes(
2875
- error.response.data.code
2876
- )) {
2877
- if (isRefreshing) {
2878
- return new Promise(function(resolve, reject) {
2879
- failedQueue.push({ resolve, reject });
2880
- }).then((token) => {
2881
- originalRequest.headers["Authorization"] = "Bearer " + token;
2882
- originalRequest.data = updateTokenParamInOriginalRequest(
2883
- originalRequest,
2884
- token
2885
- );
2886
- return instance.request(originalRequest);
2887
- }).catch(async (err) => {
2888
- if ((err.response?.status === 400 || err.response?.status === 401) && ["invalid_grant"].includes(err.response.data.error)) {
2889
- await clearAuthToken();
2890
- }
2891
- });
2892
- }
2893
- const browserSession = await sessionStorage2.getBrowserSession();
2894
- const refreshToken = await localStorage2.getRefreshToken();
2895
- const accessTokenExp = await localStorage2.getAccessToken();
2896
- isRefreshing = true;
2897
- if (!refreshToken && (!browserSession || browserSession == "unActive")) {
2898
- await clearAuthToken();
2899
- } else {
2900
- const payload = Object.fromEntries(
2901
- Object.entries({
2902
- refresh_token: refreshToken,
2903
- grant_type: "refresh_token",
2904
- client_id: config.config.clientId,
2905
- client_secret: config.config.clientSecret
2906
- }).filter(([_, value]) => !!value)
2907
- );
2908
- return new Promise(function(resolve) {
2909
- import_axios.default.post(
2910
- `${config.baseUrl}${config.refreshTokenEndpoint ?? "/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
2911
- payload,
2912
- {
2913
- headers: {
2914
- "Content-Type": config.refreshTokenEndpoint ? "application/x-www-form-urlencoded" : "multipart/form-data",
2915
- Authorization: `Bearer ${accessTokenExp}`
2916
- }
2917
- }
2918
- ).then(async (res) => {
2919
- const data = res.data;
2920
- await localStorage2.setToken(data.access_token);
2921
- await localStorage2.setRefreshToken(data.refresh_token);
2922
- import_axios.default.defaults.headers.common["Authorization"] = "Bearer " + data.access_token;
2923
- originalRequest.headers["Authorization"] = "Bearer " + data.access_token;
2924
- originalRequest.data = updateTokenParamInOriginalRequest(
2925
- originalRequest,
2926
- data.access_token
2927
- );
2928
- processQueue(null, data.access_token);
2929
- resolve(instance.request(originalRequest));
2930
- }).catch(async (err) => {
2931
- 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") {
2932
- await clearAuthToken();
2933
- }
2934
- if (err && err.response) {
2935
- const { error_code } = err.response?.data || {};
2936
- if (error_code === "AUTHEN_FAIL") {
2937
- await clearAuthToken();
2938
- }
2939
- }
2940
- processQueue(err, null);
2941
- }).finally(() => {
2942
- isRefreshing = false;
2943
- });
2944
- });
2945
- }
2946
- }
2947
- return Promise.reject(await handleError3(error));
2948
- }
2949
- );
2950
- const handleResponse = (res) => {
2951
- if (res && res.data) {
2952
- return res.data;
2953
- }
2954
- return res;
2955
- };
2956
- const handleError2 = (error) => {
2957
- if (error.isAxiosError && error.code === "ECONNABORTED") {
2958
- console.error("Request Timeout Error:", error);
2959
- return "Request Timeout Error";
2960
- } else if (error.isAxiosError && !error.response) {
2961
- console.error("Network Error:", error);
2962
- return "Network Error";
2963
- } else {
2964
- console.error("Other Error:", error?.response);
2965
- const errorMessage = error?.response?.data?.message || "An error occurred";
2966
- return { message: errorMessage, status: error?.response?.status };
2735
+ var searchSlice = (0, import_toolkit10.createSlice)({
2736
+ name: "search",
2737
+ initialState: initialState9,
2738
+ reducers: {
2739
+ setGroupByDomain: (state, action) => {
2740
+ state.groupByDomain = action.payload;
2741
+ },
2742
+ setSearchBy: (state, action) => {
2743
+ state.searchBy = action.payload;
2744
+ },
2745
+ setSearchString: (state, action) => {
2746
+ state.searchString = action.payload;
2747
+ },
2748
+ setHoveredIndexSearchList: (state, action) => {
2749
+ state.hoveredIndexSearchList = action.payload;
2750
+ },
2751
+ setSelectedTags: (state, action) => {
2752
+ state.selectedTags = action.payload;
2753
+ },
2754
+ setFirstDomain: (state, action) => {
2755
+ state.firstDomain = action.payload;
2756
+ },
2757
+ setFilterBy: (state, action) => {
2758
+ state.filterBy = action.payload;
2759
+ },
2760
+ setGroupBy: (state, action) => {
2761
+ state.groupBy = action.payload;
2762
+ },
2763
+ setSearchMap: (state, action) => {
2764
+ state.searchMap = action.payload;
2765
+ },
2766
+ updateSearchMap: (state, action) => {
2767
+ if (!state.searchMap[action.payload.key]) {
2768
+ state.searchMap[action.payload.key] = [];
2967
2769
  }
2968
- };
2969
- const clearAuthToken = async () => {
2970
- await localStorage2.clearToken();
2971
- if (typeof window !== "undefined") {
2972
- window.location.href = `/login`;
2770
+ state.searchMap[action.payload.key].push(action.payload.value);
2771
+ },
2772
+ removeKeyFromSearchMap: (state, action) => {
2773
+ const { key, item } = action.payload;
2774
+ const values = state.searchMap[key];
2775
+ if (!values) return;
2776
+ if (item) {
2777
+ const filtered = values.filter((value) => value.name !== item.name);
2778
+ if (filtered.length > 0) {
2779
+ state.searchMap[key] = filtered;
2780
+ } else {
2781
+ delete state.searchMap[key];
2782
+ }
2783
+ } else {
2784
+ delete state.searchMap[key];
2973
2785
  }
2974
- };
2975
- function formatUrl(url, db2) {
2976
- return url + (db2 ? "?db=" + db2 : "");
2786
+ },
2787
+ clearSearchMap: (state) => {
2788
+ state.searchMap = {};
2977
2789
  }
2978
- const responseBody = (response) => response;
2979
- const requests = {
2980
- get: (url, headers) => instance.get(formatUrl(url, db), headers).then(responseBody),
2981
- post: (url, body, headers) => instance.post(formatUrl(url, db), body, headers).then(responseBody),
2982
- post_excel: (url, body, headers) => instance.post(formatUrl(url, db), body, {
2983
- responseType: "arraybuffer",
2984
- headers: {
2985
- "Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
2986
- Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
2987
- }
2988
- }).then(responseBody),
2989
- put: (url, body, headers) => instance.put(formatUrl(url, db), body, headers).then(responseBody),
2990
- patch: (url, body) => instance.patch(formatUrl(url, db), body).then(responseBody),
2991
- delete: (url, body) => instance.delete(formatUrl(url, db), body).then(responseBody)
2992
- };
2993
- return requests;
2994
2790
  }
2791
+ });
2792
+ var {
2793
+ setGroupByDomain,
2794
+ setSelectedTags,
2795
+ setSearchString,
2796
+ setHoveredIndexSearchList,
2797
+ setFirstDomain,
2798
+ setSearchBy,
2799
+ setFilterBy,
2800
+ setSearchMap,
2801
+ updateSearchMap,
2802
+ removeKeyFromSearchMap,
2803
+ setGroupBy,
2804
+ clearSearchMap
2805
+ } = searchSlice.actions;
2806
+ var search_slice_default = searchSlice.reducer;
2807
+
2808
+ // src/store/store.ts
2809
+ var import_toolkit11 = require("@reduxjs/toolkit");
2810
+
2811
+ // node_modules/redux/dist/redux.mjs
2812
+ function formatProdErrorMessage(code) {
2813
+ 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. `;
2814
+ }
2815
+ var randomString = () => Math.random().toString(36).substring(7).split("").join(".");
2816
+ var ActionTypes = {
2817
+ INIT: `@@redux/INIT${/* @__PURE__ */ randomString()}`,
2818
+ REPLACE: `@@redux/REPLACE${/* @__PURE__ */ randomString()}`,
2819
+ PROBE_UNKNOWN_ACTION: () => `@@redux/PROBE_UNKNOWN_ACTION${randomString()}`
2995
2820
  };
2821
+ var actionTypes_default = ActionTypes;
2822
+ function isPlainObject(obj) {
2823
+ if (typeof obj !== "object" || obj === null)
2824
+ return false;
2825
+ let proto = obj;
2826
+ while (Object.getPrototypeOf(proto) !== null) {
2827
+ proto = Object.getPrototypeOf(proto);
2828
+ }
2829
+ return Object.getPrototypeOf(obj) === proto || Object.getPrototypeOf(obj) === null;
2830
+ }
2831
+ function miniKindOf(val) {
2832
+ if (val === void 0)
2833
+ return "undefined";
2834
+ if (val === null)
2835
+ return "null";
2836
+ const type = typeof val;
2837
+ switch (type) {
2838
+ case "boolean":
2839
+ case "string":
2840
+ case "number":
2841
+ case "symbol":
2842
+ case "function": {
2843
+ return type;
2844
+ }
2845
+ }
2846
+ if (Array.isArray(val))
2847
+ return "array";
2848
+ if (isDate(val))
2849
+ return "date";
2850
+ if (isError(val))
2851
+ return "error";
2852
+ const constructorName = ctorName(val);
2853
+ switch (constructorName) {
2854
+ case "Symbol":
2855
+ case "Promise":
2856
+ case "WeakMap":
2857
+ case "WeakSet":
2858
+ case "Map":
2859
+ case "Set":
2860
+ return constructorName;
2861
+ }
2862
+ return Object.prototype.toString.call(val).slice(8, -1).toLowerCase().replace(/\s/g, "");
2863
+ }
2864
+ function ctorName(val) {
2865
+ return typeof val.constructor === "function" ? val.constructor.name : null;
2866
+ }
2867
+ function isError(val) {
2868
+ return val instanceof Error || typeof val.message === "string" && val.constructor && typeof val.constructor.stackTraceLimit === "number";
2869
+ }
2870
+ function isDate(val) {
2871
+ if (val instanceof Date)
2872
+ return true;
2873
+ return typeof val.toDateString === "function" && typeof val.getDate === "function" && typeof val.setDate === "function";
2874
+ }
2875
+ function kindOf(val) {
2876
+ let typeOfVal = typeof val;
2877
+ if (process.env.NODE_ENV !== "production") {
2878
+ typeOfVal = miniKindOf(val);
2879
+ }
2880
+ return typeOfVal;
2881
+ }
2882
+ function warning(message) {
2883
+ if (typeof console !== "undefined" && typeof console.error === "function") {
2884
+ console.error(message);
2885
+ }
2886
+ try {
2887
+ throw new Error(message);
2888
+ } catch (e) {
2889
+ }
2890
+ }
2891
+ function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
2892
+ const reducerKeys = Object.keys(reducers);
2893
+ const argumentName = action && action.type === actionTypes_default.INIT ? "preloadedState argument passed to createStore" : "previous state received by the reducer";
2894
+ if (reducerKeys.length === 0) {
2895
+ return "Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";
2896
+ }
2897
+ if (!isPlainObject(inputState)) {
2898
+ return `The ${argumentName} has unexpected type of "${kindOf(inputState)}". Expected argument to be an object with the following keys: "${reducerKeys.join('", "')}"`;
2899
+ }
2900
+ const unexpectedKeys = Object.keys(inputState).filter((key) => !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key]);
2901
+ unexpectedKeys.forEach((key) => {
2902
+ unexpectedKeyCache[key] = true;
2903
+ });
2904
+ if (action && action.type === actionTypes_default.REPLACE)
2905
+ return;
2906
+ if (unexpectedKeys.length > 0) {
2907
+ 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.`;
2908
+ }
2909
+ }
2910
+ function assertReducerShape(reducers) {
2911
+ Object.keys(reducers).forEach((key) => {
2912
+ const reducer = reducers[key];
2913
+ const initialState10 = reducer(void 0, {
2914
+ type: actionTypes_default.INIT
2915
+ });
2916
+ if (typeof initialState10 === "undefined") {
2917
+ 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.`);
2918
+ }
2919
+ if (typeof reducer(void 0, {
2920
+ type: actionTypes_default.PROBE_UNKNOWN_ACTION()
2921
+ }) === "undefined") {
2922
+ 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.`);
2923
+ }
2924
+ });
2925
+ }
2926
+ function combineReducers(reducers) {
2927
+ const reducerKeys = Object.keys(reducers);
2928
+ const finalReducers = {};
2929
+ for (let i = 0; i < reducerKeys.length; i++) {
2930
+ const key = reducerKeys[i];
2931
+ if (process.env.NODE_ENV !== "production") {
2932
+ if (typeof reducers[key] === "undefined") {
2933
+ warning(`No reducer provided for key "${key}"`);
2934
+ }
2935
+ }
2936
+ if (typeof reducers[key] === "function") {
2937
+ finalReducers[key] = reducers[key];
2938
+ }
2939
+ }
2940
+ const finalReducerKeys = Object.keys(finalReducers);
2941
+ let unexpectedKeyCache;
2942
+ if (process.env.NODE_ENV !== "production") {
2943
+ unexpectedKeyCache = {};
2944
+ }
2945
+ let shapeAssertionError;
2946
+ try {
2947
+ assertReducerShape(finalReducers);
2948
+ } catch (e) {
2949
+ shapeAssertionError = e;
2950
+ }
2951
+ return function combination(state = {}, action) {
2952
+ if (shapeAssertionError) {
2953
+ throw shapeAssertionError;
2954
+ }
2955
+ if (process.env.NODE_ENV !== "production") {
2956
+ const warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
2957
+ if (warningMessage) {
2958
+ warning(warningMessage);
2959
+ }
2960
+ }
2961
+ let hasChanged = false;
2962
+ const nextState = {};
2963
+ for (let i = 0; i < finalReducerKeys.length; i++) {
2964
+ const key = finalReducerKeys[i];
2965
+ const reducer = finalReducers[key];
2966
+ const previousStateForKey = state[key];
2967
+ const nextStateForKey = reducer(previousStateForKey, action);
2968
+ if (typeof nextStateForKey === "undefined") {
2969
+ const actionType = action && action.type;
2970
+ 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.`);
2971
+ }
2972
+ nextState[key] = nextStateForKey;
2973
+ hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
2974
+ }
2975
+ hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
2976
+ return hasChanged ? nextState : state;
2977
+ };
2978
+ }
2996
2979
 
2997
- // src/store/index.ts
2998
- var import_react_redux = require("react-redux");
2980
+ // src/store/store.ts
2981
+ var rootReducer = combineReducers({
2982
+ env: env_slice_default,
2983
+ header: header_slice_default,
2984
+ navbar: navbar_slice_default,
2985
+ list: list_slice_default,
2986
+ search: search_slice_default,
2987
+ form: form_slice_default,
2988
+ breadcrumbs: breadcrums_slice_default,
2989
+ login: login_slice_default,
2990
+ excel: excel_slice_default,
2991
+ profile: profile_slice_default
2992
+ });
2993
+ var envStore = (0, import_toolkit11.configureStore)({
2994
+ reducer: rootReducer,
2995
+ middleware: (getDefaultMiddleware) => getDefaultMiddleware({
2996
+ serializableCheck: false
2997
+ })
2998
+ });
2999
2999
 
3000
3000
  // src/environment/EnvStore.ts
3001
- var EnvStore = class {
3001
+ var EnvStore = class _EnvStore {
3002
+ static instance = null;
3003
+ envStore;
3002
3004
  baseUrl;
3003
3005
  requests;
3004
3006
  context;
@@ -3010,88 +3012,93 @@ var EnvStore = class {
3010
3012
  localStorageUtils;
3011
3013
  sessionStorageUtils;
3012
3014
  refreshTokenEndpoint;
3013
- constructor(localStorageUtils2, sessionStorageUtils2) {
3015
+ constructor(envStore2, localStorageUtils2, sessionStorageUtils2) {
3016
+ this.envStore = envStore2;
3014
3017
  this.localStorageUtils = localStorageUtils2;
3015
3018
  this.sessionStorageUtils = sessionStorageUtils2;
3016
3019
  this.setup();
3017
3020
  }
3021
+ static getInstance(envStore2, localStorageUtils2, sessionStorageUtils2) {
3022
+ if (!_EnvStore.instance) {
3023
+ _EnvStore.instance = new _EnvStore(
3024
+ envStore2,
3025
+ localStorageUtils2,
3026
+ sessionStorageUtils2
3027
+ );
3028
+ }
3029
+ return _EnvStore.instance;
3030
+ }
3018
3031
  setup() {
3019
- const env2 = envStore.getState().env;
3020
- this.baseUrl = env2?.baseUrl;
3021
- this.context = env2?.context;
3022
- this.defaultCompany = env2?.defaultCompany;
3023
- this.config = env2?.config;
3024
- this.companies = env2?.companies || [];
3025
- this.user = env2?.user;
3026
- this.db = env2?.db;
3027
- this.requests = env2?.requests;
3028
- this.refreshTokenEndpoint = env2?.refreshTokenEndpoint;
3032
+ const env = this.envStore.getState().env;
3033
+ this.baseUrl = env?.baseUrl;
3034
+ this.requests = env?.requests;
3035
+ this.context = env?.context;
3036
+ this.defaultCompany = env?.defaultCompany;
3037
+ this.config = env?.config;
3038
+ this.companies = env?.companies || [];
3039
+ this.user = env?.user;
3040
+ this.db = env?.db;
3041
+ this.refreshTokenEndpoint = env?.refreshTokenEndpoint;
3042
+ console.log("Env setup:", this);
3029
3043
  }
3030
3044
  setupEnv(envConfig) {
3031
- let env2 = {
3045
+ const dispatch = this.envStore.dispatch;
3046
+ const env = {
3032
3047
  ...envConfig,
3033
3048
  localStorageUtils: this.localStorageUtils,
3034
3049
  sessionStorageUtils: this.sessionStorageUtils
3035
3050
  };
3036
- const requests = axiosClient.init(env2);
3037
- this.requests = requests;
3038
- const dispatch = envStore.dispatch;
3039
- dispatch(
3040
- setEnv({
3041
- ...env2,
3042
- requests
3043
- })
3044
- );
3051
+ const requests = axiosClient.init(env);
3052
+ dispatch(setEnv({ ...env, requests }));
3045
3053
  this.setup();
3046
- return { ...env2, requests };
3047
3054
  }
3048
3055
  setUid(uid) {
3049
- const dispatch = envStore.dispatch;
3056
+ const dispatch = this.envStore.dispatch;
3050
3057
  dispatch(setUid(uid));
3051
3058
  this.setup();
3052
3059
  }
3053
3060
  setLang(lang) {
3054
- const dispatch = envStore.dispatch;
3061
+ const dispatch = this.envStore.dispatch;
3055
3062
  dispatch(setLang(lang));
3056
3063
  this.setup();
3057
3064
  }
3058
3065
  setAllowCompanies(allowCompanies) {
3059
- const dispatch = envStore.dispatch;
3066
+ const dispatch = this.envStore.dispatch;
3060
3067
  dispatch(setAllowCompanies(allowCompanies));
3061
3068
  this.setup();
3062
3069
  }
3063
3070
  setCompanies(companies) {
3064
- const dispatch = envStore.dispatch;
3071
+ const dispatch = this.envStore.dispatch;
3065
3072
  dispatch(setCompanies(companies));
3066
3073
  this.setup();
3067
3074
  }
3068
3075
  setDefaultCompany(company) {
3069
- const dispatch = envStore.dispatch;
3076
+ const dispatch = this.envStore.dispatch;
3070
3077
  dispatch(setDefaultCompany(company));
3071
3078
  this.setup();
3072
3079
  }
3073
3080
  setUserInfo(userInfo) {
3074
- const dispatch = envStore.dispatch;
3081
+ const dispatch = this.envStore.dispatch;
3075
3082
  dispatch(setUser(userInfo));
3076
3083
  this.setup();
3077
3084
  }
3078
3085
  };
3079
- var env = null;
3080
3086
  function initEnv({
3081
3087
  localStorageUtils: localStorageUtils2,
3082
3088
  sessionStorageUtils: sessionStorageUtils2
3083
3089
  }) {
3084
- env = new EnvStore(localStorageUtils2, sessionStorageUtils2);
3085
- return env;
3090
+ return EnvStore.getInstance(envStore, localStorageUtils2, sessionStorageUtils2);
3086
3091
  }
3087
3092
  function getEnv() {
3088
- if (!env) env = new EnvStore(localStorageUtils(), sessionStorageUtils());
3089
- return env;
3093
+ const instance = EnvStore.getInstance(envStore);
3094
+ if (!instance) {
3095
+ throw new Error("EnvStore has not been initialized \u2014 call initEnv() first");
3096
+ }
3097
+ return instance;
3090
3098
  }
3091
3099
  // Annotate the CommonJS export names for ESM import in node:
3092
3100
  0 && (module.exports = {
3093
3101
  EnvStore,
3094
- env,
3095
3102
  getEnv,
3096
3103
  initEnv
3097
3104
  });