@fctc/edu-logic-lib 1.0.8 → 1.0.10

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