@fctc/edu-logic-lib 1.0.2 → 1.0.4

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