woodsportal-client-sdk 1.1.4-dev.52 → 1.1.4-dev.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3271 @@
1
+ import { __export, ensureValidRefresh, HUBSPOT_DATA, PORTAL_ID, DEV_PORTAL_ID, HUB_ID, setRefreshCallback, getAccessToken, setRefreshToken, setAccessToken, isAuthenticateApp, isExpiresAccessToken, isCookieExpired, getRefreshToken, DEV_API_URL, getCookie, setPortal, setSubscriptionType, setLoggedInDetails, clearAccessToken, removeAllCookie } from './chunk-24HIDVUO.js';
2
+ import axios from 'axios';
3
+ import pako from 'pako';
4
+ import { Base64 } from 'js-base64';
5
+
6
+ // src/client/index.ts
7
+ var client_exports = {};
8
+ __export(client_exports, {
9
+ Client: () => Client
10
+ });
11
+
12
+ // src/utils/localStoraget.ts
13
+ var memory = /* @__PURE__ */ new Map();
14
+ var memoryStore = {
15
+ getItem(key) {
16
+ return memory.has(key) ? memory.get(key) : null;
17
+ },
18
+ setItem(key, value) {
19
+ memory.set(key, value);
20
+ },
21
+ removeItem(key) {
22
+ memory.delete(key);
23
+ }
24
+ };
25
+ function resolveStore() {
26
+ if (typeof globalThis === "undefined") {
27
+ return memoryStore;
28
+ }
29
+ const ls = globalThis.localStorage;
30
+ if (!ls || typeof ls.getItem !== "function") {
31
+ return memoryStore;
32
+ }
33
+ try {
34
+ const probeKey = "__woodsportal_client_sdk_ls_probe__";
35
+ ls.setItem(probeKey, "1");
36
+ ls.removeItem(probeKey);
37
+ return ls;
38
+ } catch {
39
+ return memoryStore;
40
+ }
41
+ }
42
+ var storage = {
43
+ set: (key, value) => {
44
+ resolveStore().setItem(key, JSON.stringify(value));
45
+ },
46
+ get: (key) => {
47
+ const item = resolveStore().getItem(key);
48
+ return item ? JSON.parse(item) : null;
49
+ },
50
+ remove: (key) => {
51
+ resolveStore().removeItem(key);
52
+ }
53
+ };
54
+
55
+ // src/utils/config.ts
56
+ var config = {
57
+ get hubId() {
58
+ const hubSpotData = storage.get(HUBSPOT_DATA);
59
+ return hubSpotData?.[HUB_ID] || "";
60
+ },
61
+ get devPortalId() {
62
+ const hubSpotData = storage.get(HUBSPOT_DATA);
63
+ return hubSpotData?.[DEV_PORTAL_ID] || "";
64
+ },
65
+ get portalId() {
66
+ const hubSpotData = storage.get(HUBSPOT_DATA);
67
+ return hubSpotData?.[PORTAL_ID] || "";
68
+ },
69
+ get devApiUrl() {
70
+ const hubSpotData = storage.get(HUBSPOT_DATA);
71
+ return hubSpotData?.[DEV_API_URL] || "";
72
+ }
73
+ };
74
+ var setConfig = {
75
+ setDevPortalId(portalId) {
76
+ const existing = storage.get(HUBSPOT_DATA) || {};
77
+ storage.set(HUBSPOT_DATA, {
78
+ ...existing,
79
+ [PORTAL_ID]: portalId
80
+ });
81
+ }
82
+ };
83
+
84
+ // src/utils/generateApiUrl.ts
85
+ var generateApiUrl = ({
86
+ route,
87
+ params = {},
88
+ queryParams = ""
89
+ }) => {
90
+ const defaultParams = {
91
+ hubId: config.hubId,
92
+ portalId: config.portalId
93
+ };
94
+ params = { ...defaultParams, ...params };
95
+ const url2 = replaceParams(route, params);
96
+ let queryString = "";
97
+ if (queryParams && typeof queryParams === "object") {
98
+ const cleanedParams = Object.entries(queryParams).filter(([_, value]) => value !== null && value !== void 0).reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {});
99
+ queryString = new URLSearchParams(cleanedParams).toString();
100
+ }
101
+ return queryString ? `${url2}?${queryString}` : url2;
102
+ };
103
+ function replaceParams(template, values) {
104
+ return template.replace(
105
+ /\$\{(\w+)\}/g,
106
+ (_, key) => key in values ? String(values[key]) : `\${${key}}`
107
+ );
108
+ }
109
+
110
+ // src/client/api-endpoints.ts
111
+ var API_ENDPOINTS = {
112
+ // Auth
113
+ PRE_LOGIN: "/api/auth/pre-login",
114
+ LOGIN: "/api/auth/login",
115
+ AUTH_REFRESH: "/api/auth/refresh",
116
+ FORGET_PASSWORD: "/api/auth/forget-password",
117
+ RESET_PASSWORD_VERIFY_TOKEN: "/api/auth/token/validate",
118
+ RESET_PASSWORD: "/api/auth/reset-password",
119
+ VERIFY_EMAIL: "/api/auth/verify-email",
120
+ REGISTER_EXISTING_USER: "/api/auth/existing-user-register",
121
+ RESEND_EMAIL: "/api/auth/resend-email",
122
+ VERIFY_EMAIL_RESEND: "/api/auth/verify-email/resend",
123
+ LOGOUT: "/api/auth/logout",
124
+ // SSO
125
+ SSO_DETAILS: "/api/auth/sso/active",
126
+ SSO_URL: "/api/auth/sso/authorize",
127
+ SSO_CALLBACK: "/api/auth/sso/callback",
128
+ // User
129
+ ME: "/api/auth/me",
130
+ PROFILE: "/api/${hubId}/${portalId}/profiles",
131
+ CHANGE_PASSWORD: "/api/auth/change-password",
132
+ // Pipeline
133
+ PIPELINES: "/api/${hubId}/${portalId}/hubspot-object-pipelines/${hubspotObjectTypeId}",
134
+ // Stage
135
+ STAGES: "/api/${hubId}/${portalId}/hubspot-object-pipelines/${objectTypeId}/${pipelineId}/stages",
136
+ // Cache purge (replaces cache=false refresh; requires features.cache-purge-api-enabled on API)
137
+ CACHE_PURGE: "/api/${hubId}/${portalId}/cache-purge-jobs",
138
+ CACHE_PURGE_STATUS: "/api/${hubId}/${portalId}/cache-purge-jobs/${purgeJobId}",
139
+ /** @deprecated Use CACHE_PURGE */
140
+ CACHE_PURGE_LEGACY: "/api/${hubId}/${portalId}/cache/purge",
141
+ /** @deprecated Use CACHE_PURGE_STATUS */
142
+ CACHE_PURGE_STATUS_LEGACY: "/api/${hubId}/${portalId}/cache/purge/${purgeJobId}",
143
+ // Object (read on hubspot-object-data; form layout on hubspot-object-forms)
144
+ OBJECTS: "/api/${hubId}/${portalId}/hubspot-object-data/${hubspotObjectTypeId}/records",
145
+ OBJECTS_FORM: "/api/${hubId}/${portalId}/hubspot-object-forms/${hubspotObjectTypeId}/fields",
146
+ OBJECTS_FORM_OPTIONS: "/api/${hubId}/${portalId}/hubspot-object-forms/${formId}/${objectTypeId}",
147
+ RECORDS_CREATE: "/api/${hubId}/${portalId}/hubspot-object-data/${hubspotObjectTypeId}/records",
148
+ RECORDS_UPDATE: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}",
149
+ RECORDS_ASSOCIATE: "/api/${hubId}/${portalId}/hubspot-object-data/${fromObjectTypeId}/records/${fromRecordId}/associations/${toObjectTypeId}",
150
+ RECORDS_DISASSOCIATE: "/api/${hubId}/${portalId}/hubspot-object-data/${fromObjectTypeId}/records/${fromRecordId}/associations/${toObjectTypeId}",
151
+ /** @deprecated Use RECORDS_CREATE */
152
+ OBJECTS_CREATE: "/api/${hubId}/${portalId}/hubspot-object-forms/${hubspotObjectTypeId}/fields",
153
+ /** @deprecated Use RECORDS_ASSOCIATE */
154
+ OBJECTS_CREATE_EXISTING: "/api/${hubId}/${portalId}/hubspot-object-forms/:fromObjectTypeId/:fromRecordId/associations/:toObjectTypeId",
155
+ OBJECTS_DETAILS: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}",
156
+ /** @deprecated Use RECORDS_UPDATE */
157
+ OBJECTS_DETAILS_UPDATE: "/api/${hubId}/${portalId}/hubspot-object-forms/${objectId}/records/${id}",
158
+ OBJECTS_DETAILS_UPDATE_LEGACY: "/api/${hubId}/${portalId}/hubspot-object-forms/${objectId}/properties/${id}",
159
+ // Notes (nested under CRM record)
160
+ NOTES: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/notes",
161
+ NOTES_CREATE: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/notes",
162
+ NOTES_DETAILS_UPDATE: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/notes/${note_id}",
163
+ NOTES_IMAGE_UPLOAD: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/notes/images",
164
+ NOTES_ATTACHMENT_UPLOAD: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/notes/attachments",
165
+ NOTES_ATTACHMENT_UPDATE: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/notes/attachments/${note_id}",
166
+ // Email (nested under CRM record)
167
+ EMAILS: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/emails",
168
+ EMAILS_CREATE: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/emails",
169
+ EMAILS_DETAILS_UPDATE: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/emails/${email_id}",
170
+ EMAILS_IMAGE_UPLOAD: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/emails/images",
171
+ EMAILS_ATTACHMENT_UPLOAD: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/emails/attachments",
172
+ EMAILS_ATTACHMENT_UPDATE: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/emails/attachments/${email_id}",
173
+ // File manager (nested under CRM record)
174
+ FILES: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/files",
175
+ FILE: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/files/${rowId}",
176
+ FILE_DOWNLOAD: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/files/${rowId}/download",
177
+ FILES_CREATE_FOLDER: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/folders",
178
+ FILES_UPLOAD: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/files"
179
+ };
180
+
181
+ // src/client/config.ts
182
+ var config2 = {
183
+ baseURL: ""
184
+ };
185
+
186
+ // src/client/http-clint.ts
187
+ var axiosInstance = null;
188
+ var config3 = {};
189
+ function initializeHttpClient(clientConfig) {
190
+ config3 = clientConfig;
191
+ const baseURL = config?.devApiUrl || config3.baseURL;
192
+ if (!baseURL) {
193
+ throw new Error(
194
+ "WoodsPortal SDK HTTP client is not configured. Call initializeHttpClient({ baseURL }) at app startup."
195
+ );
196
+ }
197
+ const timeout = config3.timeout ?? 5e4;
198
+ axiosInstance = axios.create({
199
+ baseURL,
200
+ timeout,
201
+ headers: {
202
+ "Content-Type": "application/json",
203
+ ...config3.headers
204
+ }
205
+ });
206
+ setRefreshCallback(getAuthRefreshToken);
207
+ axiosInstance.interceptors.request.use((config4) => {
208
+ const token = getAccessToken();
209
+ if (token) {
210
+ config4.headers.set("Authorization", `Bearer ${token}`);
211
+ }
212
+ return config4;
213
+ });
214
+ axiosInstance.interceptors.response.use(
215
+ (response) => response,
216
+ (error) => {
217
+ if (error.response && error.response.status === 401) {
218
+ config3.skipCurrentPublicPath?.() ?? false;
219
+ }
220
+ return Promise.reject(error);
221
+ }
222
+ );
223
+ }
224
+ function getAxiosInstance() {
225
+ if (!axiosInstance) {
226
+ initializeHttpClient({
227
+ baseURL: config2.baseURL,
228
+ timeout: 5e4
229
+ });
230
+ }
231
+ return axiosInstance;
232
+ }
233
+ function formatBooleanSearchParam(key, value) {
234
+ return value ? `${key}:1` : `${key}:`;
235
+ }
236
+ var HttpClient = class {
237
+ static async get(url2, params) {
238
+ await ensureValidRefresh();
239
+ const response = await getAxiosInstance().get(url2, { params });
240
+ return response.data;
241
+ }
242
+ static async post(url2, data, options) {
243
+ await ensureValidRefresh();
244
+ const response = await getAxiosInstance().post(url2, data, options);
245
+ return response.data;
246
+ }
247
+ static async put(url2, data) {
248
+ await ensureValidRefresh();
249
+ const response = await getAxiosInstance().put(url2, data);
250
+ return response.data;
251
+ }
252
+ static async delete(url2, config4) {
253
+ await ensureValidRefresh();
254
+ const response = await getAxiosInstance().delete(url2, config4);
255
+ return response.data;
256
+ }
257
+ static formatSearchParams(params) {
258
+ return Object.entries(params).filter(([, value]) => Boolean(value)).map(
259
+ ([k, v]) => [
260
+ "type",
261
+ "categories",
262
+ "tags",
263
+ "author",
264
+ "manufacturer",
265
+ "shops",
266
+ "refund_reason"
267
+ ].includes(k) ? `${k}.slug:${v}` : ["is_approved"].includes(k) ? formatBooleanSearchParam(k, v) : `${k}:${v}`
268
+ ).join(";");
269
+ }
270
+ };
271
+ var AuthHttpClient = class {
272
+ static async get(url2, params) {
273
+ const response = await getAxiosInstance().get(url2, { params });
274
+ return response.data;
275
+ }
276
+ static async post(url2, data, options) {
277
+ const response = await getAxiosInstance().post(url2, data, options);
278
+ return response.data;
279
+ }
280
+ static async put(url2, data, options) {
281
+ const response = await getAxiosInstance().put(url2, data, options);
282
+ return response.data;
283
+ }
284
+ };
285
+ function getFormErrors(error) {
286
+ if (axios.isAxiosError(error)) {
287
+ return error.response?.data?.message ?? null;
288
+ }
289
+ return null;
290
+ }
291
+ function getFieldErrors(error) {
292
+ if (axios.isAxiosError(error)) {
293
+ return error.response?.data?.errors ?? null;
294
+ }
295
+ return null;
296
+ }
297
+ async function getAuthRefreshToken(refreshToken) {
298
+ if (refreshToken == null || refreshToken.trim() === "") {
299
+ return { token: null, success: false };
300
+ }
301
+ try {
302
+ const headers = {};
303
+ if (config.devPortalId) {
304
+ headers["X-Dev-Portal-Id"] = config.devPortalId;
305
+ }
306
+ const api_url = generateApiUrl({ route: API_ENDPOINTS.AUTH_REFRESH, queryParams: { hubId: config.hubId } });
307
+ const response = await getAxiosInstance().post(
308
+ api_url,
309
+ { refreshToken },
310
+ { headers }
311
+ );
312
+ const maybeData = response?.data?.data || response?.data;
313
+ const tokenData = maybeData?.tokenData || maybeData || {};
314
+ const newRefreshToken = tokenData?.refreshToken;
315
+ const token = tokenData?.token;
316
+ const expiresIn = tokenData?.expiresIn;
317
+ const rExpiresIn = tokenData?.refreshExpiresIn;
318
+ const rExpiresAt = tokenData?.refreshExpiresAt;
319
+ if (typeof newRefreshToken === "string") {
320
+ let rExpires = 0;
321
+ if (typeof rExpiresIn === "number") {
322
+ rExpires = Date.now() + rExpiresIn * 1e3;
323
+ } else if (typeof rExpiresAt === "number") {
324
+ rExpires = rExpiresAt * 1e3;
325
+ }
326
+ setRefreshToken(newRefreshToken, rExpires);
327
+ }
328
+ if (typeof token === "string") {
329
+ setAccessToken(token, typeof expiresIn === "number" ? expiresIn : void 0);
330
+ return { token, success: true };
331
+ }
332
+ return { token: null, success: false };
333
+ } catch {
334
+ return { token: null, success: false };
335
+ }
336
+ }
337
+
338
+ // src/data/user.ts
339
+ var PROFILE = null;
340
+ var setProfileData = (data) => {
341
+ PROFILE = data;
342
+ };
343
+ var getProfileData = () => {
344
+ return PROFILE;
345
+ };
346
+ function convertToBase64(obj) {
347
+ try {
348
+ if (!obj) return "";
349
+ const json = JSON.stringify(obj);
350
+ const compressed = pako.deflate(json);
351
+ const base64 = Base64.fromUint8Array(compressed, true);
352
+ return base64;
353
+ } catch (error) {
354
+ console.error("Failed to encode object:", error);
355
+ return "";
356
+ }
357
+ }
358
+ function decodeToBase64(encoded) {
359
+ try {
360
+ if (!encoded) return null;
361
+ const uint8Array = Base64.toUint8Array(encoded);
362
+ const decompressed = pako.inflate(uint8Array, { to: "string" });
363
+ return JSON.parse(decompressed);
364
+ } catch (error) {
365
+ console.error("Failed to decode object:", error);
366
+ return null;
367
+ }
368
+ }
369
+
370
+ // src/breadcrumb/url-utils.ts
371
+ function mapKeysDeep(obj, keyMap2) {
372
+ if (Array.isArray(obj)) {
373
+ return obj.map((item) => mapKeysDeep(item, keyMap2));
374
+ } else if (obj !== null && typeof obj === "object") {
375
+ return Object.entries(obj).reduce((acc, [key, value]) => {
376
+ const mappedKey = keyMap2[key] || key;
377
+ acc[mappedKey] = mapKeysDeep(value, keyMap2);
378
+ return acc;
379
+ }, {});
380
+ }
381
+ return obj;
382
+ }
383
+ function isMessingParent(breadcrumbs) {
384
+ let lastItem = breadcrumbs[breadcrumbs.length - 1];
385
+ let lastItem2 = breadcrumbs[breadcrumbs.length - 2];
386
+ let lastItem3 = breadcrumbs[breadcrumbs.length - 3];
387
+ return lastItem?.o_r_id && (!lastItem2?.o_r_id && lastItem2?.o_t_id) && lastItem3?.o_r_id ? true : false;
388
+ }
389
+ function isMessingParentLastItem(breadcrumbs) {
390
+ let lastItem = breadcrumbs[breadcrumbs.length - 1];
391
+ let lastItem2 = breadcrumbs[breadcrumbs.length - 2];
392
+ return !lastItem?.o_t_id && (lastItem2?.o_r_id && lastItem2?.o_t_id) ? false : true;
393
+ }
394
+ function breadcrumbStage(breadcrumbItems) {
395
+ let breadcrumbType = "child";
396
+ if (breadcrumbItems.length === 1) {
397
+ breadcrumbType = "root";
398
+ } else if (breadcrumbItems.length === 2) {
399
+ breadcrumbType = "root_details";
400
+ }
401
+ return breadcrumbType;
402
+ }
403
+ var generateUrl = (props, breadcrumbs) => {
404
+ const newBase64 = convertToBase64(breadcrumbs);
405
+ let url2 = "";
406
+ if (props?.objectTypeId && props?.recordId) {
407
+ url2 = `/${props?.recordId}/${props?.objectTypeId}/${props?.recordId}?b=${newBase64}`;
408
+ } else {
409
+ url2 = `/association/${props?.objectTypeId}?b=${newBase64}`;
410
+ }
411
+ return url2;
412
+ };
413
+ function getTotalParentLength(data) {
414
+ return data.filter(
415
+ (item) => (item.pt || item.o_t_id) && !item.o_r_id
416
+ ).length;
417
+ }
418
+ var generatePath = (breadcrumbs, breadcrumb, index) => {
419
+ const bc = convertToBase64(breadcrumbs.slice(0, index + 1));
420
+ if (index === 0) {
421
+ return {
422
+ name: breadcrumb?.n,
423
+ path: `/${breadcrumb?.pt || breadcrumb?.o_t_id}?b=${bc}`
424
+ };
425
+ } else if (index === 1) {
426
+ if (breadcrumb?.isHome) {
427
+ return {
428
+ name: breadcrumb?.n,
429
+ path: `/association/${breadcrumb?.o_t_id}?b=${bc}`
430
+ };
431
+ }
432
+ return {
433
+ name: breadcrumb?.n,
434
+ path: `/${breadcrumb?.o_r_id}/${breadcrumb?.o_t_id}/${breadcrumb?.o_r_id}?b=${bc}`
435
+ };
436
+ } else {
437
+ if (breadcrumb?.o_t_id && breadcrumb?.o_r_id && !breadcrumb?.isHome) {
438
+ return {
439
+ name: breadcrumb?.n,
440
+ path: `/${breadcrumb?.o_r_id}/${breadcrumb?.o_t_id}/${breadcrumb?.o_r_id}?b=${bc}`
441
+ };
442
+ } else {
443
+ return {
444
+ name: breadcrumb?.n,
445
+ path: `/association/${breadcrumb?.o_t_id}?b=${bc}`
446
+ };
447
+ }
448
+ }
449
+ };
450
+
451
+ // src/breadcrumb/key-map.ts
452
+ var keyMap = {
453
+ dp: "defPermissions",
454
+ n: "name",
455
+ sort: "sort",
456
+ o_t_id: "objectTypeId",
457
+ s: "search",
458
+ fPn: "filterPropertyName",
459
+ fO: "filterOperator",
460
+ fV: "filterValue",
461
+ c: "cache",
462
+ isPC: "isPrimaryCompany",
463
+ v: "view",
464
+ l: "limit",
465
+ pt: "path",
466
+ p: "page",
467
+ a: "after",
468
+ aPip: "activePipeline",
469
+ aT: "activeTab",
470
+ cT: "create",
471
+ dP: "display",
472
+ dL: "display_label",
473
+ pId: "pipeline_id"
474
+ };
475
+
476
+ // src/utils/url.ts
477
+ var ticketHubspotObjectTypeId = () => {
478
+ const { getParamDetails: getParamDetails2 } = routeParam;
479
+ const paramDetails = getParamDetails2();
480
+ if (
481
+ // this hubspotObjectTypeId only for main contact ticket object type
482
+ paramDetails?.breadcrumbs?.length === 2 && paramDetails?.breadcrumbs[0]?.pt === "/0-5"
483
+ ) {
484
+ return "0-1";
485
+ }
486
+ if (
487
+ // this hubspotObjectTypeId only for main company ticket object type
488
+ paramDetails?.breadcrumbs?.length === 2 && paramDetails?.breadcrumbs[0]?.pt === "/0-5-c"
489
+ ) {
490
+ return "0-2";
491
+ }
492
+ return "";
493
+ };
494
+
495
+ // src/utils/param.ts
496
+ function getParam(paramName) {
497
+ if (typeof globalThis === "undefined" || !globalThis.location) return null;
498
+ const hash = globalThis.location.hash || "";
499
+ if (!hash.startsWith("#/")) return null;
500
+ const hashWithoutHash = hash.startsWith("#") ? hash.substring(1) : hash;
501
+ const queryString = hashWithoutHash.split("?")[1];
502
+ if (!queryString) return null;
503
+ const params = new URLSearchParams(queryString);
504
+ return params.get(paramName);
505
+ }
506
+ function getPath() {
507
+ if (typeof globalThis === "undefined" || !globalThis.location) return null;
508
+ const hash = globalThis.location.hash || "";
509
+ if (!hash.startsWith("#/")) return null;
510
+ return hash.slice(1).split("?")[0];
511
+ }
512
+
513
+ // src/breadcrumb/param.ts
514
+ var getRouteMenu = (path) => {
515
+ const apiRoutes = globalThis?.apiRoutes || [];
516
+ return apiRoutes.find((menu) => menu?.path === path);
517
+ };
518
+ var getRouteDetails = () => {
519
+ const search = getParam("b");
520
+ const breadcrumbs = decodeToBase64(search) || [];
521
+ const lastItem = breadcrumbs[breadcrumbs.length - 1];
522
+ const mapped = lastItem ? mapKeysDeep(lastItem, keyMap) : null;
523
+ return { routeDetails: mapped };
524
+ };
525
+ var getParamDetails = (props, isDetailsPage = false) => {
526
+ const search = getParam("b");
527
+ let breadcrumbs = decodeToBase64(search) || [];
528
+ if (breadcrumbs.length > 0 && breadcrumbs?.[0]?.isHome) {
529
+ breadcrumbs = breadcrumbs.slice(1);
530
+ }
531
+ let mediatorObjectTypeId = "";
532
+ let mediatorObjectRecordId = "";
533
+ let parentObjectTypeId = "";
534
+ let parentObjectRecordId = "";
535
+ let lastItem = breadcrumbs[breadcrumbs.length - 1];
536
+ const lastItem2 = breadcrumbs[breadcrumbs.length - 2];
537
+ const lastItem3 = breadcrumbs[breadcrumbs.length - 3];
538
+ if (isDetailsPage === true && lastItem && "prm" in lastItem) {
539
+ delete lastItem.prm;
540
+ }
541
+ if (breadcrumbs.length > 1) {
542
+ if (props?.type === "ticket" || props?.type === "association") {
543
+ mediatorObjectTypeId = breadcrumbs[1]?.o_t_id || "";
544
+ mediatorObjectRecordId = breadcrumbs[1]?.o_r_id || "";
545
+ parentObjectTypeId = lastItem?.o_t_id || "";
546
+ parentObjectRecordId = lastItem?.o_r_id || "";
547
+ } else {
548
+ if (breadcrumbs.length > 2) {
549
+ mediatorObjectTypeId = breadcrumbs[1]?.o_t_id || "";
550
+ mediatorObjectRecordId = breadcrumbs[1]?.o_r_id || "";
551
+ }
552
+ if (!lastItem?.o_r_id && breadcrumbs.length > 2) {
553
+ parentObjectTypeId = lastItem2?.o_t_id || "";
554
+ parentObjectRecordId = lastItem2?.o_r_id || "";
555
+ }
556
+ if (lastItem?.o_r_id && breadcrumbs.length > 2) {
557
+ parentObjectTypeId = lastItem3?.o_t_id || "";
558
+ parentObjectRecordId = lastItem3?.o_r_id || "";
559
+ }
560
+ if (lastItem2?.o_t_id === "0-5" && !parentObjectTypeId && !parentObjectRecordId) {
561
+ parentObjectTypeId = lastItem2?.o_t_id || "";
562
+ parentObjectRecordId = lastItem2?.o_r_id || "";
563
+ }
564
+ }
565
+ }
566
+ let paramsObject = {};
567
+ if (breadcrumbs[0]?.prm?.isPC || breadcrumbs[1]?.prm?.isPC || lastItem?.prm?.isPC) {
568
+ paramsObject["isPrimaryCompany"] = true;
569
+ }
570
+ if (parentObjectTypeId && parentObjectRecordId) {
571
+ paramsObject["parentObjectTypeId"] = parentObjectTypeId;
572
+ paramsObject["parentObjectRecordId"] = parentObjectRecordId;
573
+ }
574
+ if (mediatorObjectTypeId && mediatorObjectRecordId) {
575
+ paramsObject["mediatorObjectTypeId"] = mediatorObjectTypeId;
576
+ paramsObject["mediatorObjectRecordId"] = mediatorObjectRecordId;
577
+ }
578
+ const mappedLastItemParam = Object.fromEntries(
579
+ Object.entries(lastItem?.prm || {}).map(([key, value]) => [
580
+ keyMap[key] || key,
581
+ // use mapped name if exists, else keep original
582
+ value
583
+ ])
584
+ );
585
+ let queryString = null;
586
+ if (props?.type === "association") {
587
+ queryString = new URLSearchParams({ ...paramsObject, ...{ cache: false } }).toString();
588
+ } else {
589
+ queryString = new URLSearchParams({ ...paramsObject, ...mappedLastItemParam }).toString();
590
+ }
591
+ let params = queryString ? `?${queryString}` : "";
592
+ const totalParentLength = getTotalParentLength(breadcrumbs);
593
+ let parentAccessLabel = false;
594
+ if (breadcrumbs[0]?.prm?.isPC && totalParentLength > 2 || // company object
595
+ !breadcrumbs[0]?.prm?.isPC && totalParentLength > 3 || // normal object
596
+ breadcrumbs[0]?.prm?.isPC && totalParentLength > 1 && props?.type === "ticket" || // company ticket
597
+ !breadcrumbs[0]?.prm?.isPC && totalParentLength > 2 && props?.type === "ticket") {
598
+ parentAccessLabel = true;
599
+ }
600
+ return {
601
+ breadcrumbs,
602
+ // paramsObject: Object.keys(mParamsObject).length === 0 ? null : mParamsObject,
603
+ paramsObject,
604
+ params,
605
+ parentAccessLabel
606
+ };
607
+ };
608
+
609
+ // src/breadcrumb/url.ts
610
+ var useUpdateLink = () => {
611
+ const updateLink = async (props, displayName = "prm") => {
612
+ const search = getParam("b");
613
+ const pathname = getPath();
614
+ let breadcrumbs = decodeToBase64(search) || [];
615
+ if (breadcrumbs.length < 1) {
616
+ const routeMenu = getRouteMenu(pathname);
617
+ breadcrumbs = [
618
+ {
619
+ n: routeMenu?.title,
620
+ pt: routeMenu?.path
621
+ }
622
+ ];
623
+ }
624
+ const lastBreadcrumb = breadcrumbs[breadcrumbs.length - 1];
625
+ if (displayName) {
626
+ const ex = await getDeep(lastBreadcrumb, displayName) || {};
627
+ await setDeep(lastBreadcrumb, displayName, {
628
+ ...ex,
629
+ ...props
630
+ });
631
+ } else {
632
+ await Object.assign(lastBreadcrumb, props);
633
+ }
634
+ const newBase64 = convertToBase64(breadcrumbs);
635
+ updateBParam(newBase64);
636
+ };
637
+ function setDeep(obj, path, value) {
638
+ const keys = path.split(".");
639
+ let curr = obj;
640
+ for (let i = 0; i < keys.length - 1; i++) {
641
+ if (!curr[keys[i]] || typeof curr[keys[i]] !== "object") {
642
+ curr[keys[i]] = {};
643
+ }
644
+ curr = curr[keys[i]];
645
+ }
646
+ curr[keys[keys.length - 1]] = value;
647
+ return curr;
648
+ }
649
+ function getDeep(obj, path) {
650
+ return path.split(".").reduce((acc, key) => acc?.[key], obj);
651
+ }
652
+ const getLinkParams = (displayName = "prm") => {
653
+ const search = getParam("b");
654
+ let breadcrumbs = decodeToBase64(search) || [];
655
+ if (breadcrumbs.length < 1) return null;
656
+ const lastItem = breadcrumbs[breadcrumbs.length - 1];
657
+ const getDeep2 = (obj, path) => {
658
+ return path.split(".").reduce((acc, key) => acc?.[key], obj);
659
+ };
660
+ const expandKeys = (obj) => {
661
+ return Object.fromEntries(
662
+ Object.entries(obj).map(([key, value]) => [
663
+ keyMap[key] || key,
664
+ // map if exists, else keep original
665
+ value
666
+ ])
667
+ );
668
+ };
669
+ const nestedValue = displayName ? getDeep2(lastItem, displayName) : null;
670
+ const output = nestedValue ? expandKeys(nestedValue) : null;
671
+ return output;
672
+ };
673
+ const filterParams = (displayName = "prm") => {
674
+ const search = getParam("b");
675
+ let breadcrumbs = decodeToBase64(search) || [];
676
+ if (breadcrumbs.length < 1) return null;
677
+ const lastItem = breadcrumbs[breadcrumbs.length - 1];
678
+ const getDeep2 = (obj, path) => {
679
+ return path.split(".").reduce((acc, key) => acc?.[key], obj);
680
+ };
681
+ const expandKeys = (obj) => {
682
+ return Object.fromEntries(
683
+ Object.entries(obj).map(([key, value]) => [
684
+ keyMap[key] || key,
685
+ // map if exists, else keep original
686
+ value
687
+ ])
688
+ );
689
+ };
690
+ const nestedValue = displayName ? getDeep2(lastItem, displayName) : null;
691
+ const output = nestedValue ? expandKeys(nestedValue) : expandKeys(lastItem);
692
+ return output;
693
+ };
694
+ return { updateLink, getLinkParams, filterParams };
695
+ };
696
+ var updateBParam = (newValue) => {
697
+ if (typeof globalThis === "undefined" || !globalThis.location) return;
698
+ const hash = globalThis.location.hash || "";
699
+ if (!hash.startsWith("#/")) return;
700
+ const withoutHash = hash.slice(2);
701
+ const [path, queryString] = withoutHash.split("?");
702
+ const params = new URLSearchParams(queryString || "");
703
+ params.set("b", newValue);
704
+ const newHash = `#/${path}?${params.toString()}`;
705
+ if (typeof globalThis !== "undefined" && globalThis.history && globalThis.history.replaceState) {
706
+ globalThis.history.replaceState(null, "", newHash);
707
+ }
708
+ };
709
+
710
+ // src/store/index.ts
711
+ function createStore(initializer) {
712
+ let state;
713
+ const listeners = /* @__PURE__ */ new Set();
714
+ const get = () => state;
715
+ const set = (partial) => {
716
+ const prevState = state;
717
+ const partialState = typeof partial === "function" ? partial(state) : partial;
718
+ state = {
719
+ ...state,
720
+ ...partialState
721
+ };
722
+ listeners.forEach(
723
+ (listener) => listener(state, prevState)
724
+ );
725
+ };
726
+ const subscribe = (listener) => {
727
+ listeners.add(listener);
728
+ return () => listeners.delete(listener);
729
+ };
730
+ state = initializer(set, get);
731
+ return {
732
+ getState: get,
733
+ setState: set,
734
+ subscribe
735
+ };
736
+ }
737
+
738
+ // src/utils/getCookieData.ts
739
+ var getAuthSubscriptionType = () => {
740
+ return getCookie("subscriptionType");
741
+ };
742
+
743
+ // src/store/use-table.ts
744
+ var pageLimit = 10;
745
+ var tableStore = createStore((set, get) => ({
746
+ // ==============================
747
+ // STATE
748
+ // ==============================
749
+ tableUniqueId: null,
750
+ gridData: [],
751
+ sort: "-hs_createdate",
752
+ limit: 10,
753
+ after: "",
754
+ page: 1,
755
+ nextPage: 1,
756
+ stageId: "",
757
+ totalItems: 1,
758
+ numOfPages: 1,
759
+ currentPage: 1,
760
+ search: "",
761
+ filterPropertyName: "hs_pipeline",
762
+ filterOperator: "eq",
763
+ filterValue: "",
764
+ isPrimaryCompany: null,
765
+ view: null,
766
+ selectedPipeline: "",
767
+ tableParam: {},
768
+ tableDefPermissions: {},
769
+ tableData: [],
770
+ tablePrependData: [],
771
+ // ==============================
772
+ // BASIC SETTERS
773
+ // ==============================
774
+ setTableUniqueId: (v) => set({ tableUniqueId: v }),
775
+ setSort: (v) => set({ sort: v }),
776
+ setLimit: (v) => set({ limit: v }),
777
+ setAfter: (v) => set({ after: v }),
778
+ setPage: (v) => set({ page: v }),
779
+ setNextPage: (v) => set({ nextPage: v }),
780
+ setStageId: (v) => set({ stageId: v }),
781
+ setTotalItems: (v) => set({ totalItems: v }),
782
+ setNumOfPages: (v) => set({ numOfPages: v }),
783
+ setCurrentPage: (v) => set({ currentPage: v }),
784
+ setSearch: (v) => set({ search: v }),
785
+ setFilterPropertyName: (v) => set({ filterPropertyName: v }),
786
+ setFilterOperator: (v) => set({ filterOperator: v }),
787
+ setFilterValue: (v) => set({ filterValue: v }),
788
+ setIsPrimaryCompany: (v) => set({ isPrimaryCompany: v }),
789
+ // ==============================
790
+ // VIEW
791
+ // ==============================
792
+ setView: (mView) => {
793
+ set({
794
+ page: getAuthSubscriptionType() === "FREE" ? "" : 1,
795
+ view: mView
796
+ });
797
+ },
798
+ // ==============================
799
+ // PIPELINE
800
+ // ==============================
801
+ changePipeline: (mView) => {
802
+ set({
803
+ page: getAuthSubscriptionType() === "FREE" ? "" : 1,
804
+ selectedPipeline: mView || ""
805
+ });
806
+ },
807
+ setSelectedPipeline: (pipelines, pipeLineId) => {
808
+ let filterValue = "";
809
+ if (pipeLineId) {
810
+ const pipelineSingle = pipelines.find(
811
+ (pipeline) => pipeline.pipelineId === pipeLineId
812
+ );
813
+ filterValue = pipelineSingle?.pipelineId || "";
814
+ }
815
+ set({
816
+ filterPropertyName: "hs_pipeline",
817
+ filterOperator: "eq",
818
+ filterValue,
819
+ selectedPipeline: filterValue
820
+ });
821
+ },
822
+ // ==============================
823
+ // RESET
824
+ // ==============================
825
+ resetTableParam: () => {
826
+ set({
827
+ sort: "-hs_createdate",
828
+ limit: pageLimit,
829
+ after: "",
830
+ page: getAuthSubscriptionType() === "FREE" ? "" : 1,
831
+ totalItems: 1,
832
+ numOfPages: 1,
833
+ currentPage: 1,
834
+ search: "",
835
+ filterPropertyName: "hs_pipeline",
836
+ filterOperator: "eq",
837
+ filterValue: "",
838
+ isPrimaryCompany: null,
839
+ selectedPipeline: ""
840
+ });
841
+ },
842
+ // ==============================
843
+ // PARAM BUILDER
844
+ // ==============================
845
+ getTableParam: (companyAsMediator, currentPageOverride) => {
846
+ const state = get();
847
+ const baseParams = {
848
+ sort: state.sort,
849
+ search: state.search,
850
+ filterPropertyName: state.filterPropertyName,
851
+ filterOperator: state.filterOperator,
852
+ filterValue: state.selectedPipeline,
853
+ cache: true,
854
+ isPrimaryCompany: companyAsMediator || false,
855
+ view: state.view
856
+ };
857
+ if (getAuthSubscriptionType() === "FREE") {
858
+ return {
859
+ ...baseParams,
860
+ after: state.page
861
+ };
862
+ }
863
+ return {
864
+ ...baseParams,
865
+ limit: state.limit,
866
+ page: currentPageOverride || state.page,
867
+ ...state.after && {
868
+ after: state.after
869
+ }
870
+ };
871
+ },
872
+ // ==============================
873
+ // GRID DATA
874
+ // ==============================
875
+ setGridData: async (type, deals) => {
876
+ if (type === "reset") {
877
+ await set({ gridData: [] });
878
+ return [];
879
+ }
880
+ if (type === "directly") {
881
+ await set({ gridData: deals });
882
+ return deals;
883
+ }
884
+ const finalData = await deals.map(
885
+ (deal) => {
886
+ const cards = deal?.data?.results?.rows?.map(
887
+ (row) => ({
888
+ id: row?.hs_object_id,
889
+ ...row,
890
+ hubspotObjectTypeId: type === "deals" ? "0-3" : "0-5"
891
+ })
892
+ ) || [];
893
+ return {
894
+ id: deal.id,
895
+ name: deal.label,
896
+ count: deal?.data?.total,
897
+ ...deal,
898
+ cards
899
+ };
900
+ }
901
+ );
902
+ await set({ gridData: finalData });
903
+ return finalData;
904
+ },
905
+ // ==============================
906
+ // DEFAULT PIPELINE
907
+ // ==============================
908
+ setDefaultPipeline(data, hubspotObjectTypeId) {
909
+ if (!data) {
910
+ set({ selectedPipeline: "" });
911
+ return "";
912
+ }
913
+ const { updateLink, filterParams } = useUpdateLink();
914
+ const params = filterParams();
915
+ const excludedIds = ["0-1", "0-2", "0-3", "0-4", "0-5", "home"];
916
+ const state = get();
917
+ const view = state.view;
918
+ const selectedPipeline = state.selectedPipeline;
919
+ let defaultPipelineId = "";
920
+ let mFilterValue = "";
921
+ const defaultPipeline = data?.data?.[0];
922
+ if (excludedIds.includes(hubspotObjectTypeId)) {
923
+ defaultPipelineId = defaultPipeline?.pipelineId || "";
924
+ }
925
+ if (params && params?.filterPropertyName === "hs_pipeline" && params?.filterValue) {
926
+ mFilterValue = params.filterValue;
927
+ } else {
928
+ if (view === "BOARD" && !selectedPipeline) {
929
+ mFilterValue = defaultPipelineId;
930
+ updateLink({
931
+ fV: defaultPipelineId
932
+ });
933
+ } else if (!excludedIds.includes(hubspotObjectTypeId)) {
934
+ mFilterValue = selectedPipeline || null;
935
+ } else {
936
+ mFilterValue = data.data.length === 1 ? defaultPipelineId : selectedPipeline;
937
+ }
938
+ }
939
+ set({ selectedPipeline: mFilterValue });
940
+ return mFilterValue;
941
+ },
942
+ setTableData: (response) => {
943
+ set({
944
+ tableData: response
945
+ });
946
+ },
947
+ setTablePrependData: async (response) => {
948
+ const state = get();
949
+ let rows = [];
950
+ if (response === "loading") {
951
+ const row = await state.tableData?.data?.results?.columns.reduce((acc, item) => {
952
+ if (!item.hidden) {
953
+ acc[item.key] = "loading";
954
+ }
955
+ return acc;
956
+ }, {});
957
+ rows = [row, ...state.tablePrependData];
958
+ } else {
959
+ const data = response?.data;
960
+ if (!data) {
961
+ set({
962
+ tablePrependData: []
963
+ });
964
+ }
965
+ const row = await Object.fromEntries(
966
+ Object.entries(data).map(([key, value]) => [
967
+ key,
968
+ value?.value ?? value
969
+ ])
970
+ );
971
+ rows = [...state.tablePrependData];
972
+ if (rows.length > 0) {
973
+ rows[0] = row;
974
+ } else {
975
+ rows.push(row);
976
+ }
977
+ }
978
+ set({
979
+ tablePrependData: rows
980
+ });
981
+ return rows;
982
+ }
983
+ }));
984
+ function useTable() {
985
+ const tableState = tableStore.getState();
986
+ return {
987
+ ...tableState,
988
+ ...{ listeners: { subscribe: tableStore.subscribe } }
989
+ };
990
+ }
991
+
992
+ // src/client/index.ts
993
+ var recordWriteContext = (paramsObject) => {
994
+ if (!paramsObject) {
995
+ return void 0;
996
+ }
997
+ const context = {};
998
+ const keys = [
999
+ "parentObjectTypeId",
1000
+ "parentObjectRecordId",
1001
+ "mediatorObjectTypeId",
1002
+ "mediatorObjectRecordId"
1003
+ ];
1004
+ keys.forEach((key) => {
1005
+ const value = paramsObject[key];
1006
+ if (value !== void 0 && value !== null && String(value).length > 0) {
1007
+ context[key] = String(value);
1008
+ }
1009
+ });
1010
+ return Object.keys(context).length > 0 ? context : void 0;
1011
+ };
1012
+ var mergeRecordWriteBody = (payload, paramsObject, options) => {
1013
+ const base = { ...payload || {} };
1014
+ const context = recordWriteContext(paramsObject);
1015
+ if (context) {
1016
+ base.context = context;
1017
+ }
1018
+ if (options && Object.keys(options).length > 0) {
1019
+ base.options = options;
1020
+ }
1021
+ return base;
1022
+ };
1023
+ var Client = {
1024
+ authentication: {
1025
+ preLogin: (data) => AuthHttpClient.post(API_ENDPOINTS.PRE_LOGIN, data),
1026
+ login: (data) => {
1027
+ const queryParams = config.hubId ? { hubId: config.hubId } : null;
1028
+ return AuthHttpClient.post(
1029
+ generateApiUrl({ route: API_ENDPOINTS.LOGIN, queryParams }),
1030
+ data,
1031
+ config?.devPortalId && {
1032
+ headers: {
1033
+ "X-Dev-Portal-Id": config.devPortalId
1034
+ }
1035
+ }
1036
+ );
1037
+ },
1038
+ verifyEmail: (data) => AuthHttpClient.post(API_ENDPOINTS.VERIFY_EMAIL, data),
1039
+ resetPasswordVerifyToken: (data) => AuthHttpClient.post(API_ENDPOINTS.RESET_PASSWORD_VERIFY_TOKEN, data),
1040
+ resetPassword: (data) => AuthHttpClient.post(API_ENDPOINTS.RESET_PASSWORD, data),
1041
+ forgetPassword: (data) => AuthHttpClient.post(API_ENDPOINTS.FORGET_PASSWORD, data),
1042
+ registerExistingUser: (data) => AuthHttpClient.post(API_ENDPOINTS.REGISTER_EXISTING_USER, data?.payload),
1043
+ verifyEmailResend: (data) => AuthHttpClient.post(API_ENDPOINTS.VERIFY_EMAIL_RESEND, data),
1044
+ resendEmail: (data) => AuthHttpClient.post(API_ENDPOINTS.RESEND_EMAIL, data),
1045
+ logout: () => HttpClient.post(API_ENDPOINTS.LOGOUT, null)
1046
+ },
1047
+ sso: {
1048
+ getSsoDetails: () => AuthHttpClient.get(API_ENDPOINTS.SSO_DETAILS),
1049
+ generateSsoUrl: (payload) => AuthHttpClient.get(generateApiUrl({ route: API_ENDPOINTS.SSO_URL, queryParams: payload?.queryParams })),
1050
+ ssoCallback: (payload) => AuthHttpClient.get(generateApiUrl({ route: API_ENDPOINTS.SSO_CALLBACK, queryParams: payload?.queryParams }))
1051
+ },
1052
+ user: {
1053
+ me: () => HttpClient.get(generateApiUrl({ route: API_ENDPOINTS.ME })),
1054
+ profile: (payload) => HttpClient.get(generateApiUrl({ route: API_ENDPOINTS.PROFILE, queryParams: payload })),
1055
+ changePassword: (data) => HttpClient.post(API_ENDPOINTS.CHANGE_PASSWORD, data)
1056
+ },
1057
+ pipeline: {
1058
+ list: (payload = null, param = null) => {
1059
+ const params = { hubspotObjectTypeId: payload?.hubspotObjectTypeId };
1060
+ const { getParamDetails: getParamDetails2 } = routeParam;
1061
+ const { paramsObject } = getParamDetails2({ type: payload?.componentName });
1062
+ const userData = getProfileData();
1063
+ const apiParams = {};
1064
+ if (paramsObject?.parentObjectTypeId) {
1065
+ apiParams.parentObjectTypeId = paramsObject?.parentObjectTypeId;
1066
+ } else if (payload?.isHome && userData?.data?.info?.objectTypeId && !param?.isPrimaryCompany) {
1067
+ apiParams.parentObjectTypeId = userData?.data?.info?.objectTypeId;
1068
+ } else if (payload?.isHome && userData?.data?.info?.objectTypeId && param?.isPrimaryCompany) {
1069
+ apiParams.parentObjectTypeId = "0-2";
1070
+ }
1071
+ apiParams.isPrimaryCompany = param?.isPrimaryCompany;
1072
+ apiParams.cache = payload?.cache;
1073
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.PIPELINES, params, queryParams: apiParams });
1074
+ return HttpClient.get(apiUrl);
1075
+ }
1076
+ },
1077
+ stage: {
1078
+ list: (props = null) => {
1079
+ const params = {
1080
+ // hubId: config.hubId,
1081
+ // portalId: portalId,
1082
+ objectTypeId: props?.params?.objectTypeId,
1083
+ pipelineId: props?.params?.pipelineId
1084
+ };
1085
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.STAGES, params });
1086
+ return HttpClient.get(apiUrl);
1087
+ }
1088
+ },
1089
+ object: {
1090
+ list: async (payload = null, param = null) => {
1091
+ param.cache = payload.cache;
1092
+ const params = { hubspotObjectTypeId: payload?.hubspotObjectTypeId };
1093
+ const { updateLink, getLinkParams } = useUpdateLink();
1094
+ const { getParamDetails: getParamDetails2 } = routeParam;
1095
+ const { paramsObject, parentAccessLabel } = getParamDetails2({ type: payload?.componentName });
1096
+ const userData = getProfileData();
1097
+ const pipeline = payload?.variables?.pipeline;
1098
+ const mPipelines = payload?.variables?.mPipelines;
1099
+ const mSelectedPipeline = pipeline !== void 0 ? pipeline : payload?.selectedPipeline;
1100
+ if (mSelectedPipeline) {
1101
+ param.filterValue = mSelectedPipeline;
1102
+ } else if (payload?.specPipeLine && payload?.pipeLineId) {
1103
+ param.filterValue = payload?.pipeLineId;
1104
+ } else if (payload?.hubspotObjectTypeId != "0-3" || payload?.hubspotObjectTypeId != "0-5") {
1105
+ param.filterValue = "";
1106
+ }
1107
+ const fParams = getLinkParams();
1108
+ param = { ...payload?.isFristTimeLoadData && fParams && !payload?.isHome ? fParams : param, ...paramsObject };
1109
+ if (!payload?.isFristTimeLoadData || !fParams) {
1110
+ await updateLink({
1111
+ "sort": param?.sort,
1112
+ "s": param?.search,
1113
+ "fPn": param?.filterPropertyName,
1114
+ "fO": param?.filterOperator,
1115
+ "fV": param?.filterValue,
1116
+ "c": param?.cache,
1117
+ "isPC": param?.isPrimaryCompany,
1118
+ "v": param?.view,
1119
+ "l": param?.limit,
1120
+ "p": param?.page,
1121
+ "a": param?.after
1122
+ });
1123
+ }
1124
+ if (mPipelines != void 0 && mPipelines?.length === 0 && !payload?.specPipeLine) {
1125
+ param.filterValue = "";
1126
+ await updateLink({
1127
+ "fV": param?.filterValue
1128
+ });
1129
+ }
1130
+ if (mPipelines != void 0 && mPipelines?.length === 1 && !payload?.specPipeLine && mSelectedPipeline != null) {
1131
+ param.filterValue = mPipelines[0].pipelineId;
1132
+ await updateLink({
1133
+ "fV": param?.filterValue
1134
+ });
1135
+ }
1136
+ if (payload?.isHome || payload?.hubspotObjectTypeId === "0-5" && payload?.componentName === "object") {
1137
+ let parentObjectTypeId = "";
1138
+ if (userData?.data?.info?.objectTypeId && !param?.isPrimaryCompany) {
1139
+ parentObjectTypeId = userData?.data?.info?.objectTypeId;
1140
+ } else if (userData?.data?.info?.objectTypeId && param?.isPrimaryCompany) {
1141
+ parentObjectTypeId = "0-2";
1142
+ }
1143
+ param.parentObjectTypeId = parentObjectTypeId;
1144
+ }
1145
+ param.parentAccessLabel = parentAccessLabel;
1146
+ const {
1147
+ stageId,
1148
+ nextPage
1149
+ } = useTable();
1150
+ if (stageId) {
1151
+ param.stageId = stageId;
1152
+ }
1153
+ if (param?.view === "BOARD") {
1154
+ param.page = nextPage;
1155
+ }
1156
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS, params, queryParams: param });
1157
+ return HttpClient.get(apiUrl);
1158
+ },
1159
+ sideBarList: async (payload = null) => {
1160
+ const hubspotObjectTypeId = payload?.hubspotObjectTypeId;
1161
+ const params = { hubspotObjectTypeId };
1162
+ const queryParams = payload.param;
1163
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS, params, queryParams });
1164
+ return HttpClient.get(apiUrl);
1165
+ },
1166
+ form: (payload = null) => {
1167
+ const params = { hubspotObjectTypeId: payload?.hubspotObjectTypeId };
1168
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS_FORM, params, queryParams: payload?.params });
1169
+ return HttpClient.get(apiUrl);
1170
+ },
1171
+ objectFormOptions: (payload = null) => {
1172
+ const params = {
1173
+ formId: payload?.formId,
1174
+ objectTypeId: payload?.objectTypeId ?? payload?.hubspotObjectTypeId
1175
+ };
1176
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS_FORM_OPTIONS, params, queryParams: payload?.params });
1177
+ return HttpClient.get(apiUrl);
1178
+ },
1179
+ create: (props = null) => {
1180
+ const { getParamDetails: getParamDetailsForCreate } = routeParam;
1181
+ const { paramsObject } = getParamDetailsForCreate({ type: props?.componentName });
1182
+ const cardParentMerge = props?.componentName === "association" ? true : false;
1183
+ const body = mergeRecordWriteBody(props?.payload, paramsObject, {
1184
+ cardParentMerge,
1185
+ addAnother: props?.params?.addAnother
1186
+ });
1187
+ const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId };
1188
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.RECORDS_CREATE, params, queryParams: props?.params });
1189
+ return HttpClient.post(apiUrl, body);
1190
+ },
1191
+ createExisting: (props = null) => {
1192
+ const { getLinkParams } = useUpdateLink();
1193
+ const fParams = getLinkParams();
1194
+ const queryParams = { ...fParams, ...props?.params };
1195
+ const params = {
1196
+ fromObjectTypeId: props?.fromObjectTypeId ?? props?.hubspotObjectTypeId,
1197
+ fromRecordId: props?.fromRecordId,
1198
+ toObjectTypeId: props?.toObjectTypeId
1199
+ };
1200
+ const payload = props.payload;
1201
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.RECORDS_ASSOCIATE, params, queryParams });
1202
+ return HttpClient.post(apiUrl, payload);
1203
+ },
1204
+ removeExisting: (props = null) => {
1205
+ const { getParamDetails: getParamDetailsForRemove } = routeParam;
1206
+ const { paramsObject } = getParamDetailsForRemove({ type: props?.componentName });
1207
+ const body = mergeRecordWriteBody(props?.payload, paramsObject, void 0);
1208
+ const params = {
1209
+ fromObjectTypeId: props?.fromObjectTypeId ?? props?.hubspotObjectTypeId,
1210
+ fromRecordId: props?.fromRecordId,
1211
+ toObjectTypeId: props?.toObjectTypeId
1212
+ };
1213
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.RECORDS_DISASSOCIATE, params });
1214
+ return HttpClient.delete(apiUrl, { data: body });
1215
+ },
1216
+ details: (props = null) => {
1217
+ const { paramsObject: urlParam, parentAccessLabel } = getParamDetails("", true);
1218
+ const hubspotObjectTypeId = ticketHubspotObjectTypeId();
1219
+ const params = {
1220
+ // hubId: config.hubId,
1221
+ // portalId: portalId,
1222
+ objectId: props?.params?.objectId,
1223
+ id: props?.params?.id
1224
+ };
1225
+ const queryParams = {
1226
+ parentAccessLabel,
1227
+ ...props?.queryParams,
1228
+ ...urlParam
1229
+ };
1230
+ if (hubspotObjectTypeId) queryParams.hubspotObjectTypeId = hubspotObjectTypeId;
1231
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS_DETAILS, params, queryParams });
1232
+ return HttpClient.get(apiUrl);
1233
+ },
1234
+ update: (props = null) => {
1235
+ const hubspotObjectTypeId = ticketHubspotObjectTypeId();
1236
+ const params = {
1237
+ objectId: props?.params?.objectId,
1238
+ id: props?.params?.id
1239
+ };
1240
+ const { getParamDetails: getParamDetailsForUpdate } = routeParam;
1241
+ const { paramsObject } = getParamDetailsForUpdate({ type: props?.componentName });
1242
+ const cardParentMerge = props?.componentName === "association" ? true : false;
1243
+ const rawPayload = props?.payload || {};
1244
+ const properties = rawPayload.properties ?? rawPayload.propertyPayload ?? rawPayload;
1245
+ const body = mergeRecordWriteBody(
1246
+ { properties },
1247
+ paramsObject,
1248
+ { cardParentMerge }
1249
+ );
1250
+ const queryParams = {};
1251
+ if (hubspotObjectTypeId) queryParams.hubspotObjectTypeId = hubspotObjectTypeId;
1252
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.RECORDS_UPDATE, params, queryParams });
1253
+ return HttpClient.put(apiUrl, body);
1254
+ }
1255
+ },
1256
+ note: {
1257
+ list: (props = null) => {
1258
+ const params = {
1259
+ // hubId: config.hubId,
1260
+ // portalId: portalId,
1261
+ objectId: props?.params?.objectId,
1262
+ id: props?.params?.id
1263
+ };
1264
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.NOTES, params, queryParams: props?.queryParams });
1265
+ return HttpClient.get(apiUrl);
1266
+ },
1267
+ create: (props = null) => {
1268
+ const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
1269
+ const queryParams = props.queryParams;
1270
+ const payload = props.payload;
1271
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.NOTES_CREATE, params, queryParams });
1272
+ return HttpClient.post(apiUrl, payload);
1273
+ },
1274
+ update: (props = null) => {
1275
+ const params = {
1276
+ // hubId: config.hubId,
1277
+ // portalId: portalId,
1278
+ objectId: props?.params?.objectId,
1279
+ id: props?.params?.id,
1280
+ note_id: props?.params?.note_id
1281
+ };
1282
+ const { paramsObject: queryParams } = getParamDetails();
1283
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.NOTES_DETAILS_UPDATE, params, queryParams });
1284
+ return HttpClient.put(apiUrl, props.payload);
1285
+ },
1286
+ image: (props = null) => {
1287
+ const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
1288
+ const queryParams = props.queryParams;
1289
+ const payload = props.payload;
1290
+ const axiosConfig = props.config || {};
1291
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.NOTES_IMAGE_UPLOAD, params, queryParams });
1292
+ return HttpClient.post(apiUrl, payload, {
1293
+ headers: {
1294
+ "Content-Type": "multipart/form-data"
1295
+ },
1296
+ ...axiosConfig
1297
+ });
1298
+ },
1299
+ attachment: (props = null) => {
1300
+ const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
1301
+ const queryParams = props.queryParams;
1302
+ const payload = props.payload;
1303
+ const axiosConfig = props.config || {};
1304
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.NOTES_ATTACHMENT_UPLOAD, params, queryParams });
1305
+ return HttpClient.post(apiUrl, payload, {
1306
+ headers: {
1307
+ "Content-Type": "multipart/form-data"
1308
+ },
1309
+ ...axiosConfig
1310
+ });
1311
+ }
1312
+ },
1313
+ email: {
1314
+ list: (props = null) => {
1315
+ const params = {
1316
+ // hubId: config.hubId,
1317
+ // portalId: portalId,
1318
+ objectId: props?.params?.objectId,
1319
+ id: props?.params?.id
1320
+ };
1321
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.EMAILS, params, queryParams: props?.queryParams });
1322
+ return HttpClient.get(apiUrl);
1323
+ },
1324
+ create: (props = null) => {
1325
+ const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
1326
+ const queryParams = props.queryParams;
1327
+ const payload = props.payload;
1328
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.EMAILS_CREATE, params, queryParams });
1329
+ return HttpClient.post(apiUrl, payload);
1330
+ },
1331
+ update: (props = null) => {
1332
+ const params = {
1333
+ // hubId: config.hubId,
1334
+ // portalId: portalId,
1335
+ objectId: props?.params?.objectId,
1336
+ id: props?.params?.id,
1337
+ email_id: props?.params?.email_id ?? props?.params?.note_id
1338
+ };
1339
+ const { paramsObject: queryParams } = getParamDetails();
1340
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.EMAILS_DETAILS_UPDATE, params, queryParams });
1341
+ return HttpClient.put(apiUrl, props.payload);
1342
+ },
1343
+ image: (props = null) => {
1344
+ const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
1345
+ const queryParams = props.queryParams;
1346
+ const payload = props.payload;
1347
+ const axiosConfig = props.config || {};
1348
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.EMAILS_IMAGE_UPLOAD, params, queryParams });
1349
+ return HttpClient.post(apiUrl, payload, {
1350
+ headers: {
1351
+ "Content-Type": "multipart/form-data"
1352
+ },
1353
+ ...axiosConfig
1354
+ });
1355
+ },
1356
+ attachment: (props = null) => {
1357
+ const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
1358
+ const queryParams = props.queryParams;
1359
+ const payload = props.payload;
1360
+ const axiosConfig = props.config || {};
1361
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.EMAILS_ATTACHMENT_UPLOAD, params, queryParams });
1362
+ return HttpClient.post(apiUrl, payload, {
1363
+ headers: {
1364
+ "Content-Type": "multipart/form-data"
1365
+ },
1366
+ ...axiosConfig
1367
+ });
1368
+ }
1369
+ },
1370
+ cache: {
1371
+ purge: (body, headers) => {
1372
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.CACHE_PURGE });
1373
+ return HttpClient.post(apiUrl, body, headers ? { headers } : void 0);
1374
+ },
1375
+ purgeStatus: (purgeJobId) => {
1376
+ const apiUrl = generateApiUrl({
1377
+ route: API_ENDPOINTS.CACHE_PURGE_STATUS,
1378
+ params: { purgeJobId }
1379
+ });
1380
+ return HttpClient.get(apiUrl);
1381
+ }
1382
+ },
1383
+ file: {
1384
+ list: (props = null) => {
1385
+ const params = {
1386
+ // hubId: config.hubId,
1387
+ // portalId: portalId,
1388
+ objectId: props?.params?.objectId,
1389
+ id: props?.params?.id
1390
+ };
1391
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.FILES, params, queryParams: props?.queryParams });
1392
+ return HttpClient.get(apiUrl);
1393
+ },
1394
+ details: (props = null) => {
1395
+ const params = {
1396
+ // hubId: config.hubId,
1397
+ // portalId: portalId,
1398
+ objectId: props?.params?.objectId,
1399
+ id: props?.params?.id,
1400
+ rowId: props?.params?.rowId
1401
+ };
1402
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.FILE, params, queryParams: props?.queryParams });
1403
+ return HttpClient.get(apiUrl);
1404
+ },
1405
+ download: (props = null) => {
1406
+ const params = {
1407
+ objectId: props?.params?.objectId,
1408
+ id: props?.params?.id,
1409
+ rowId: props?.params?.rowId
1410
+ };
1411
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.FILE_DOWNLOAD, params, queryParams: props?.queryParams });
1412
+ return HttpClient.post(apiUrl, {});
1413
+ },
1414
+ addFolder: (props = null) => {
1415
+ const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
1416
+ const queryParams = props.queryParams;
1417
+ const payload = props.payload;
1418
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.FILES_CREATE_FOLDER, params, queryParams });
1419
+ return HttpClient.post(apiUrl, payload);
1420
+ },
1421
+ addFile: (props = null) => {
1422
+ const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
1423
+ const queryParams = props.queryParams;
1424
+ const payload = props.payload;
1425
+ const axiosConfig = props.config || {};
1426
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.FILES_UPLOAD, params, queryParams });
1427
+ return HttpClient.post(apiUrl, payload, {
1428
+ headers: {
1429
+ "Content-Type": "multipart/form-data"
1430
+ },
1431
+ ...axiosConfig
1432
+ });
1433
+ }
1434
+ }
1435
+ };
1436
+
1437
+ // src/store2/store.ts
1438
+ function createStore2(initialState) {
1439
+ let state = initialState;
1440
+ const listeners = /* @__PURE__ */ new Set();
1441
+ return {
1442
+ getState() {
1443
+ return state;
1444
+ },
1445
+ setState(partial) {
1446
+ state = {
1447
+ ...state,
1448
+ ...partial
1449
+ };
1450
+ listeners.forEach(
1451
+ (listener) => listener(state)
1452
+ );
1453
+ },
1454
+ subscribe(listener) {
1455
+ listeners.add(listener);
1456
+ return () => listeners.delete(listener);
1457
+ }
1458
+ };
1459
+ }
1460
+
1461
+ // src/store2/use-form.ts
1462
+ var formStore = createStore2({
1463
+ form: null
1464
+ });
1465
+ var actions = {
1466
+ setFormData(response) {
1467
+ formStore.setState({
1468
+ form: response
1469
+ });
1470
+ }};
1471
+
1472
+ // src/store2/use-table.ts
1473
+ var tableStore2 = createStore2({
1474
+ objectsData: null,
1475
+ tableData: [],
1476
+ tablePrependData: [],
1477
+ hubspotObjectTypeId: "",
1478
+ selectedPipeline: "",
1479
+ viewType: ""
1480
+ });
1481
+ var actions2 = {
1482
+ async setObjectsData(response) {
1483
+ const state = tableStore2.getState();
1484
+ if (response?.info?.viewType == "LIST") {
1485
+ tableStore2.setState({
1486
+ objectsData: response
1487
+ });
1488
+ }
1489
+ if (response?.info?.viewType == "BOARD") {
1490
+ const {
1491
+ stageId
1492
+ } = useTable();
1493
+ if (stageId) {
1494
+ const boardData = { ...state.objectsData };
1495
+ const updatedBoardData = await {
1496
+ ...boardData,
1497
+ data: {
1498
+ ...boardData.data,
1499
+ results: boardData.data.results.map(
1500
+ (item) => String(item.id) === String(stageId) ? {
1501
+ ...item,
1502
+ data: {
1503
+ ...item.data,
1504
+ results: {
1505
+ ...item.data.results,
1506
+ rows: [
1507
+ ...item?.data?.results?.rows ?? [],
1508
+ // keep existing rows
1509
+ ...response?.data?.results?.rows ?? []
1510
+ // prepend new rows
1511
+ ]
1512
+ }
1513
+ }
1514
+ } : item
1515
+ )
1516
+ }
1517
+ };
1518
+ tableStore2.setState({
1519
+ objectsData: updatedBoardData
1520
+ });
1521
+ } else {
1522
+ tableStore2.setState({
1523
+ objectsData: response
1524
+ });
1525
+ }
1526
+ }
1527
+ },
1528
+ setTableData(response, payload) {
1529
+ const state = tableStore2.getState();
1530
+ const viewType = response?.info?.viewType;
1531
+ let newTablePrependData;
1532
+ if (viewType === "BOARD") {
1533
+ const stages = response?.data?.results ?? [];
1534
+ newTablePrependData = state.tablePrependData.map((prependStage) => {
1535
+ const matchingStage = stages.find(
1536
+ (stage) => String(stage.id) === String(prependStage.id)
1537
+ );
1538
+ const rows = matchingStage?.data?.results?.rows ?? [];
1539
+ const rowIds = new Set(
1540
+ rows.map((row) => row.id ?? row.hs_object_id).filter((id) => id != null && id !== "").map((id) => String(id))
1541
+ );
1542
+ const filteredRows = (prependStage?.data?.results?.rows ?? []).filter((item) => {
1543
+ const itemId = item.id ?? item.hs_object_id;
1544
+ if (itemId == null || itemId === "") return true;
1545
+ return !rowIds.has(String(itemId));
1546
+ });
1547
+ return {
1548
+ ...prependStage,
1549
+ data: {
1550
+ ...prependStage.data,
1551
+ results: {
1552
+ ...prependStage.data?.results,
1553
+ rows: filteredRows
1554
+ }
1555
+ }
1556
+ };
1557
+ });
1558
+ } else {
1559
+ const rows = response?.data?.results?.rows ?? [];
1560
+ const rowIds = new Set(
1561
+ rows.map((row) => row.id ?? row.hs_object_id).filter((id) => id != null && id !== "").map((id) => String(id))
1562
+ );
1563
+ newTablePrependData = state.tablePrependData.filter((item) => {
1564
+ const itemId = item.id ?? item.hs_object_id;
1565
+ if (itemId == null || itemId === "") return true;
1566
+ return !rowIds.has(String(itemId));
1567
+ });
1568
+ }
1569
+ const hubspotObjectTypeId = payload?.hubspotObjectTypeId;
1570
+ const selectedPipeline = payload?.selectedPipeline;
1571
+ if (response?.data?.total < 1 || payload?.componentName) {
1572
+ newTablePrependData = [];
1573
+ }
1574
+ if (state.viewType && state.viewType != viewType) {
1575
+ newTablePrependData = [];
1576
+ }
1577
+ if (state.hubspotObjectTypeId && state.hubspotObjectTypeId != hubspotObjectTypeId) {
1578
+ newTablePrependData = [];
1579
+ }
1580
+ if (state.selectedPipeline && state.selectedPipeline != selectedPipeline) {
1581
+ newTablePrependData = [];
1582
+ }
1583
+ if (payload.isFristTimeLoadData) {
1584
+ newTablePrependData = [];
1585
+ }
1586
+ tableStore2.setState({
1587
+ tableData: response,
1588
+ tablePrependData: newTablePrependData || [],
1589
+ hubspotObjectTypeId,
1590
+ viewType
1591
+ });
1592
+ },
1593
+ modifiedObjectsData(results) {
1594
+ const state = tableStore2.getState();
1595
+ const tablePrependData = state.tablePrependData;
1596
+ const modifiedData = results.map((result) => {
1597
+ const matchedPrepend = tablePrependData.find(
1598
+ (item) => String(item?.id) === String(result?.id)
1599
+ );
1600
+ if (!matchedPrepend) {
1601
+ return result;
1602
+ }
1603
+ const prependRows = matchedPrepend?.data?.results?.rows ?? [];
1604
+ const prependCards = prependRows.map((row) => ({
1605
+ id: row.hs_object_id,
1606
+ ...row
1607
+ }));
1608
+ return {
1609
+ ...result,
1610
+ // prepend in results.rows
1611
+ data: {
1612
+ ...result.data,
1613
+ results: {
1614
+ ...result.data.results,
1615
+ rows: [
1616
+ ...prependRows,
1617
+ ...result?.data?.results?.rows ?? []
1618
+ ]
1619
+ }
1620
+ },
1621
+ // prepend in cards
1622
+ cards: [
1623
+ ...prependCards,
1624
+ ...result?.cards ?? []
1625
+ ]
1626
+ };
1627
+ });
1628
+ tableStore2.setState({
1629
+ objectsData: modifiedData
1630
+ });
1631
+ },
1632
+ clearTablePrependData() {
1633
+ tableStore2.setState({
1634
+ tablePrependData: []
1635
+ });
1636
+ },
1637
+ async setTablePrependData(response, props) {
1638
+ const state = tableStore2.getState();
1639
+ const formState = formStore.getState();
1640
+ let rows = [];
1641
+ if (state.tableData?.info?.viewType == "BOARD") {
1642
+ if (response === "loading") {
1643
+ const responseData = state.tableData?.data?.results ?? [];
1644
+ const pipelineStage = props?.payload?.propertyPayload?.hs_pipeline_stage || props?.payload?.propertyPayload?.dealstage || formState?.form?.data?.pipelineDefaults?.defaultStage?.id;
1645
+ rows = responseData.map(
1646
+ ({ id, data }) => {
1647
+ const matchedPrepend = state.tablePrependData.find(
1648
+ (item) => String(item.id) === String(id)
1649
+ );
1650
+ const prependRows = matchedPrepend?.data?.results?.rows ?? [];
1651
+ const newRow = String(id) === String(pipelineStage) ? [
1652
+ (data?.results?.columns ?? []).reduce(
1653
+ (obj, column) => {
1654
+ obj[column.key] = "loading";
1655
+ return obj;
1656
+ },
1657
+ {}
1658
+ )
1659
+ ] : [];
1660
+ return {
1661
+ id,
1662
+ data: {
1663
+ results: {
1664
+ columns: data?.results?.columns ?? [],
1665
+ // prepend loading row + prepend rows
1666
+ rows: [
1667
+ ...newRow,
1668
+ ...prependRows
1669
+ ]
1670
+ }
1671
+ }
1672
+ };
1673
+ }
1674
+ );
1675
+ } else {
1676
+ const data = response?.data;
1677
+ const hs_pipeline_stage = data?.hs_pipeline_stage?.value?.value || data?.dealstage?.value?.value;
1678
+ if (!data) {
1679
+ tableStore2.setState({
1680
+ tablePrependData: []
1681
+ });
1682
+ }
1683
+ rows = state?.tablePrependData.map((row) => {
1684
+ const matchedPrepend = state.tablePrependData.find(
1685
+ (item) => String(item.id) === String(row.id)
1686
+ );
1687
+ const prependRows = matchedPrepend?.data?.results?.rows ?? [];
1688
+ if (String(row.id) === String(hs_pipeline_stage)) {
1689
+ const updatedRow = (row?.data?.results?.columns ?? []).reduce(
1690
+ (obj, column) => {
1691
+ const key = column.key;
1692
+ obj[key] = data?.[key]?.value ?? data?.[key] ?? "";
1693
+ return obj;
1694
+ },
1695
+ {}
1696
+ );
1697
+ prependRows[0] = updatedRow;
1698
+ return {
1699
+ ...row,
1700
+ data: {
1701
+ ...row.data,
1702
+ results: {
1703
+ ...row.data.results,
1704
+ rows: prependRows
1705
+ }
1706
+ }
1707
+ };
1708
+ }
1709
+ return row;
1710
+ });
1711
+ }
1712
+ } else if (state.tableData?.info?.viewType == "LIST") {
1713
+ if (response === "loading") {
1714
+ const row = await state.tableData?.data?.results?.columns.reduce((acc, item) => {
1715
+ if (!item.hidden) {
1716
+ acc[item.key] = "loading";
1717
+ }
1718
+ return acc;
1719
+ }, {});
1720
+ rows = [row, ...state.tablePrependData];
1721
+ } else if (response?.data) {
1722
+ const data = response?.data;
1723
+ if (!data) {
1724
+ tableStore2.setState({
1725
+ tablePrependData: []
1726
+ });
1727
+ }
1728
+ const row = await Object.fromEntries(
1729
+ Object.entries(data).map(([key, value]) => [
1730
+ key,
1731
+ value?.value ?? value
1732
+ ])
1733
+ );
1734
+ rows = [...state.tablePrependData];
1735
+ if (rows.length > 0) {
1736
+ rows[0] = row;
1737
+ } else {
1738
+ rows.push(row);
1739
+ }
1740
+ }
1741
+ }
1742
+ tableStore2.setState({
1743
+ tablePrependData: rows
1744
+ });
1745
+ }
1746
+ };
1747
+
1748
+ // src/store2/use-uploader.ts
1749
+ var uploaderStore = createStore2({
1750
+ attachments: []
1751
+ });
1752
+ function toAttachmentSummary(attachment) {
1753
+ return {
1754
+ createdAt: attachment.createdAt,
1755
+ id: attachment.id,
1756
+ name: attachment.name,
1757
+ size: attachment.size,
1758
+ type: attachment.type,
1759
+ updatedAt: attachment.updatedAt
1760
+ };
1761
+ }
1762
+ function resolveAttachmentsFromIds(attachmentIds, storedAttachments) {
1763
+ const raw = typeof attachmentIds === "object" && attachmentIds !== null && "value" in attachmentIds ? attachmentIds.value : attachmentIds;
1764
+ const ids = String(raw ?? "").split(";").map((id) => id.trim()).filter(Boolean);
1765
+ return ids.map((id) => storedAttachments.find((a) => String(a.id) === id)).filter((a) => a != null).map(toAttachmentSummary);
1766
+ }
1767
+ var actions3 = {
1768
+ setAttachment(response) {
1769
+ const data = response?.data;
1770
+ if (!data?.id) return;
1771
+ const state = uploaderStore.getState();
1772
+ const id = String(data.id);
1773
+ const existing = state.attachments;
1774
+ const index = existing.findIndex((item) => String(item.id) === id);
1775
+ const attachments = index >= 0 ? existing.map((item, i) => i === index ? data : item) : [...existing, data];
1776
+ uploaderStore.setState({ attachments });
1777
+ },
1778
+ clearAttachments() {
1779
+ uploaderStore.setState({ attachments: [] });
1780
+ }
1781
+ };
1782
+
1783
+ // src/store2/use-note.ts
1784
+ var noteStore = createStore2({
1785
+ notes: [],
1786
+ prependNotes: [],
1787
+ id: ""
1788
+ });
1789
+ var actions4 = {
1790
+ setNotes(response, payload) {
1791
+ const state = noteStore.getState();
1792
+ const rows = response?.data?.results?.rows ?? [];
1793
+ const rowIds = new Set(
1794
+ rows.map((row) => row.id ?? row.hs_object_id).filter((id2) => id2 != null && id2 !== "").map((id2) => String(id2))
1795
+ );
1796
+ let newPrependNotes = state.prependNotes.filter((item) => {
1797
+ const itemId = item.id ?? item.hs_object_id;
1798
+ if (itemId == null || itemId === "") return true;
1799
+ return !rowIds.has(String(itemId));
1800
+ });
1801
+ const id = payload?.params?.id;
1802
+ if (state.id && state.id != id) {
1803
+ newPrependNotes = [];
1804
+ }
1805
+ noteStore.setState({
1806
+ notes: response,
1807
+ prependNotes: newPrependNotes,
1808
+ id
1809
+ });
1810
+ },
1811
+ async setPrependNote(response) {
1812
+ const state = noteStore.getState();
1813
+ let rows = [];
1814
+ if (response === "loading") {
1815
+ const row = await state.notes?.data?.results?.columns.reduce((acc, item) => {
1816
+ if (!item.hidden) {
1817
+ acc[item.key] = "loading";
1818
+ }
1819
+ return acc;
1820
+ }, {});
1821
+ rows = [row, ...state.prependNotes];
1822
+ } else if (response?.data) {
1823
+ const data = response?.data;
1824
+ if (!data) {
1825
+ noteStore.setState({
1826
+ prependNotes: []
1827
+ });
1828
+ }
1829
+ const storedAttachments = uploaderStore.getState().attachments;
1830
+ const row = Object.fromEntries(
1831
+ Object.entries(data).map(([key, value]) => {
1832
+ if (key === "hs_attachment_ids") {
1833
+ return [
1834
+ key,
1835
+ resolveAttachmentsFromIds(value, storedAttachments)
1836
+ ];
1837
+ }
1838
+ return [key, value?.value ?? value];
1839
+ })
1840
+ );
1841
+ rows = [...state.prependNotes];
1842
+ if (rows.length > 0) {
1843
+ rows[0] = row;
1844
+ } else {
1845
+ rows.push(row);
1846
+ }
1847
+ }
1848
+ noteStore.setState({
1849
+ prependNotes: rows
1850
+ });
1851
+ },
1852
+ clearPrependNotes() {
1853
+ noteStore.setState({
1854
+ prependNotes: []
1855
+ });
1856
+ actions3.clearAttachments();
1857
+ },
1858
+ async updatePrependNote(response) {
1859
+ const responseData = { ...response };
1860
+ const state = noteStore.getState();
1861
+ const prependNotes = state.prependNotes || [];
1862
+ const note = response.data || null;
1863
+ const storedAttachments = uploaderStore.getState().attachments;
1864
+ const notes = prependNotes.map(
1865
+ (item) => item?.hs_object_id === note?.hs_object_id?.value ? {
1866
+ ...item,
1867
+ ...Object.fromEntries(
1868
+ Object.entries(note).map(([key, value]) => {
1869
+ if (key === "hs_attachment_ids") {
1870
+ return [
1871
+ key,
1872
+ resolveAttachmentsFromIds(value, storedAttachments)
1873
+ ];
1874
+ }
1875
+ return [key, value?.value ?? value];
1876
+ })
1877
+ )
1878
+ } : item
1879
+ );
1880
+ noteStore.setState({
1881
+ prependNotes: notes
1882
+ });
1883
+ if (responseData?.data?.hs_attachment_ids != null) {
1884
+ const noteObjectId = note?.hs_object_id?.value;
1885
+ const rows = state.notes?.data?.results?.rows ?? [];
1886
+ const matchingRow = rows.find(
1887
+ (row) => String(row.hs_object_id) === String(noteObjectId)
1888
+ );
1889
+ const originalPrependItem = prependNotes.find(
1890
+ (item) => String(item?.hs_object_id) === String(noteObjectId)
1891
+ );
1892
+ const existingAttachments = matchingRow?.hs_attachment_ids ?? originalPrependItem?.hs_attachment_ids ?? [];
1893
+ const newAttachments = resolveAttachmentsFromIds(
1894
+ responseData.data.hs_attachment_ids,
1895
+ storedAttachments
1896
+ );
1897
+ const mergedAttachments = [
1898
+ ...existingAttachments,
1899
+ ...newAttachments.filter(
1900
+ (attachment) => !existingAttachments.some(
1901
+ (existing) => String(existing.id) === String(attachment.id)
1902
+ )
1903
+ )
1904
+ ];
1905
+ const stateUpdates = {};
1906
+ if (matchingRow && state.notes?.data?.results) {
1907
+ stateUpdates.notes = {
1908
+ ...state.notes,
1909
+ data: {
1910
+ ...state.notes.data,
1911
+ results: {
1912
+ ...state.notes.data.results,
1913
+ rows: rows.map(
1914
+ (row) => String(row.hs_object_id) === String(noteObjectId) ? { ...row, hs_attachment_ids: mergedAttachments } : row
1915
+ )
1916
+ }
1917
+ }
1918
+ };
1919
+ }
1920
+ if (originalPrependItem) {
1921
+ stateUpdates.prependNotes = prependNotes.map(
1922
+ (item) => String(item?.hs_object_id) === String(noteObjectId) ? { ...item, hs_attachment_ids: mergedAttachments } : item
1923
+ );
1924
+ }
1925
+ if (Object.keys(stateUpdates).length > 0) {
1926
+ noteStore.setState(stateUpdates);
1927
+ }
1928
+ responseData.data.hs_attachment_ids = mergedAttachments;
1929
+ }
1930
+ return responseData;
1931
+ }
1932
+ };
1933
+
1934
+ // src/store2/use-email.ts
1935
+ var emailStore = createStore2({
1936
+ emails: [],
1937
+ prependEmails: [],
1938
+ id: ""
1939
+ });
1940
+ var actions5 = {
1941
+ setEmails(response, payload) {
1942
+ const state = emailStore.getState();
1943
+ const rows = response?.data?.results?.rows ?? [];
1944
+ const rowIds = new Set(
1945
+ rows.map((row) => row.id ?? row.hs_object_id).filter((id2) => id2 != null && id2 !== "").map((id2) => String(id2))
1946
+ );
1947
+ let newPrependEmails = state.prependEmails.filter((item) => {
1948
+ const itemId = item.id ?? item.hs_object_id;
1949
+ if (itemId == null || itemId === "") return true;
1950
+ return !rowIds.has(String(itemId));
1951
+ });
1952
+ const id = payload?.params?.id;
1953
+ if (state.id && state.id != id) {
1954
+ newPrependEmails = [];
1955
+ }
1956
+ emailStore.setState({
1957
+ emails: response,
1958
+ prependEmails: newPrependEmails,
1959
+ id
1960
+ });
1961
+ },
1962
+ async setPrependEmail(response) {
1963
+ const state = emailStore.getState();
1964
+ let rows = [];
1965
+ if (response === "loading") {
1966
+ const row = await state.emails?.data?.results?.columns.reduce((acc, item) => {
1967
+ if (!item.hidden) {
1968
+ acc[item.key] = "loading";
1969
+ }
1970
+ return acc;
1971
+ }, {});
1972
+ rows = [row, ...state.prependEmails];
1973
+ } else if (response?.data) {
1974
+ const data = response?.data;
1975
+ if (!data) {
1976
+ emailStore.setState({
1977
+ prependEmails: []
1978
+ });
1979
+ }
1980
+ const storedAttachments = uploaderStore.getState().attachments;
1981
+ const row = Object.fromEntries(
1982
+ Object.entries(data).map(([key, value]) => {
1983
+ if (key === "hs_attachment_ids") {
1984
+ return [
1985
+ key,
1986
+ resolveAttachmentsFromIds(value, storedAttachments)
1987
+ ];
1988
+ }
1989
+ return [key, value?.value ?? value];
1990
+ })
1991
+ );
1992
+ rows = [...state.prependEmails];
1993
+ if (rows.length > 0) {
1994
+ rows[0] = row;
1995
+ } else {
1996
+ rows.push(row);
1997
+ }
1998
+ }
1999
+ emailStore.setState({
2000
+ prependEmails: rows
2001
+ });
2002
+ },
2003
+ clearPrependEmails() {
2004
+ emailStore.setState({
2005
+ prependEmails: []
2006
+ });
2007
+ actions3.clearAttachments();
2008
+ },
2009
+ async updatePrependEmail(response) {
2010
+ const responseData = { ...response };
2011
+ const state = emailStore.getState();
2012
+ const prependEmails = state.prependEmails || [];
2013
+ const email = response.data || null;
2014
+ const storedAttachments = uploaderStore.getState().attachments;
2015
+ const emails = prependEmails.map(
2016
+ (item) => item?.hs_object_id === email?.hs_object_id?.value ? {
2017
+ ...item,
2018
+ ...Object.fromEntries(
2019
+ Object.entries(email).map(([key, value]) => {
2020
+ if (key === "hs_attachment_ids") {
2021
+ return [
2022
+ key,
2023
+ resolveAttachmentsFromIds(value, storedAttachments)
2024
+ ];
2025
+ }
2026
+ return [key, value?.value ?? value];
2027
+ })
2028
+ )
2029
+ } : item
2030
+ );
2031
+ emailStore.setState({
2032
+ prependEmails: emails
2033
+ });
2034
+ if (responseData?.data?.hs_attachment_ids != null) {
2035
+ const emailObjectId = email?.hs_object_id?.value;
2036
+ const rows = state.emails?.data?.results?.rows ?? [];
2037
+ const matchingRow = rows.find(
2038
+ (row) => String(row.hs_object_id) === String(emailObjectId)
2039
+ );
2040
+ const originalPrependItem = prependEmails.find(
2041
+ (item) => String(item?.hs_object_id) === String(emailObjectId)
2042
+ );
2043
+ const existingAttachments = matchingRow?.hs_attachment_ids ?? originalPrependItem?.hs_attachment_ids ?? [];
2044
+ const newAttachments = resolveAttachmentsFromIds(
2045
+ responseData.data.hs_attachment_ids,
2046
+ storedAttachments
2047
+ );
2048
+ const mergedAttachments = [
2049
+ ...existingAttachments,
2050
+ ...newAttachments.filter(
2051
+ (attachment) => !existingAttachments.some(
2052
+ (existing) => String(existing.id) === String(attachment.id)
2053
+ )
2054
+ )
2055
+ ];
2056
+ const stateUpdates = {};
2057
+ if (matchingRow && state.emails?.data?.results) {
2058
+ stateUpdates.emails = {
2059
+ ...state.emails,
2060
+ data: {
2061
+ ...state.emails.data,
2062
+ results: {
2063
+ ...state.emails.data.results,
2064
+ rows: rows.map(
2065
+ (row) => String(row.hs_object_id) === String(emailObjectId) ? { ...row, hs_attachment_ids: mergedAttachments } : row
2066
+ )
2067
+ }
2068
+ }
2069
+ };
2070
+ }
2071
+ if (originalPrependItem) {
2072
+ stateUpdates.prependEmails = prependEmails.map(
2073
+ (item) => String(item?.hs_object_id) === String(emailObjectId) ? { ...item, hs_attachment_ids: mergedAttachments } : item
2074
+ );
2075
+ }
2076
+ if (Object.keys(stateUpdates).length > 0) {
2077
+ emailStore.setState(stateUpdates);
2078
+ }
2079
+ responseData.data.hs_attachment_ids = mergedAttachments;
2080
+ }
2081
+ return responseData;
2082
+ }
2083
+ };
2084
+
2085
+ // src/store2/use-sync.ts
2086
+ var syncStore = createStore2({
2087
+ apiSync: false,
2088
+ sync: false,
2089
+ isSyncLoading: false,
2090
+ isSyncDisable: false
2091
+ });
2092
+ var actions6 = {
2093
+ setIsSyncLoading(status) {
2094
+ syncStore.setState({
2095
+ isSyncLoading: status,
2096
+ sync: status
2097
+ });
2098
+ },
2099
+ setSync(status) {
2100
+ resetAllStore();
2101
+ syncStore.setState({
2102
+ isSyncLoading: status,
2103
+ sync: status
2104
+ });
2105
+ },
2106
+ setApiSync(status) {
2107
+ syncStore.setState({
2108
+ isSyncLoading: status,
2109
+ apiSync: status
2110
+ });
2111
+ },
2112
+ setSyncDisable(status) {
2113
+ syncStore.setState({
2114
+ isSyncDisable: status
2115
+ });
2116
+ }
2117
+ };
2118
+ var resetAllStore = () => {
2119
+ actions2.clearTablePrependData();
2120
+ actions4.clearPrependNotes();
2121
+ actions5.clearPrependEmails();
2122
+ };
2123
+
2124
+ // src/utils/logError.ts
2125
+ function logError(context, error) {
2126
+ if (axios.isAxiosError(error)) {
2127
+ resetAllStore();
2128
+ console.error(context, {
2129
+ message: error.message,
2130
+ status: error.response?.status,
2131
+ statusText: error.response?.statusText,
2132
+ data: error.response?.data,
2133
+ url: error.config?.url,
2134
+ method: error.config?.method
2135
+ });
2136
+ return;
2137
+ }
2138
+ if (error instanceof Error) {
2139
+ console.error(context, error.message, error);
2140
+ return;
2141
+ }
2142
+ console.error(context, error);
2143
+ }
2144
+
2145
+ // src/mutation/createMutation.ts
2146
+ function createMutation(mutationFn, options) {
2147
+ let inFlight = 0;
2148
+ let lastReportedLoading = null;
2149
+ const syncLoading = () => {
2150
+ const active = inFlight > 0;
2151
+ if (lastReportedLoading === active) return;
2152
+ lastReportedLoading = active;
2153
+ options?.onLoadingChange?.(active);
2154
+ };
2155
+ const mutate = async (payload) => {
2156
+ inFlight += 1;
2157
+ syncLoading();
2158
+ try {
2159
+ const response = await mutationFn(payload);
2160
+ await options?.onSuccess?.(response, payload);
2161
+ return response;
2162
+ } catch (error) {
2163
+ options?.onError?.(error, payload);
2164
+ logError("[mutation]", error);
2165
+ throw error;
2166
+ } finally {
2167
+ inFlight -= 1;
2168
+ syncLoading();
2169
+ }
2170
+ };
2171
+ return {
2172
+ mutate,
2173
+ isLoading: () => inFlight > 0
2174
+ };
2175
+ }
2176
+
2177
+ // src/apis/authentication.ts
2178
+ function preLogin(options) {
2179
+ const { mutate, isLoading } = createMutation(
2180
+ async (payload) => {
2181
+ const response = await Client.authentication.preLogin(payload);
2182
+ return response;
2183
+ },
2184
+ options
2185
+ );
2186
+ return {
2187
+ mutate,
2188
+ login: mutate,
2189
+ isLoading
2190
+ };
2191
+ }
2192
+ function login(options) {
2193
+ const { mutate, isLoading } = createMutation(
2194
+ async (payload) => {
2195
+ const response = await Client.authentication.login(payload);
2196
+ const tokenData = response?.data?.tokenData || {};
2197
+ const loggedInDetails = response?.data?.loggedInDetails || {};
2198
+ const currentPortal = response?.data?.loggedInDetails?.currentPortal || {};
2199
+ const currentPortalId = currentPortal?.portalId || null;
2200
+ const SubscriptionType = loggedInDetails?.subscriptionType || "BASIC";
2201
+ const token = tokenData?.token;
2202
+ const refreshToken = tokenData?.refreshToken;
2203
+ const expiresIn = tokenData?.expiresIn;
2204
+ const rExpiresIn = tokenData?.refreshExpiresIn;
2205
+ setPortal(currentPortal);
2206
+ setSubscriptionType(SubscriptionType);
2207
+ await setAccessToken(token, expiresIn);
2208
+ await setRefreshToken(refreshToken, rExpiresIn);
2209
+ await setLoggedInDetails(response.data);
2210
+ setConfig.setDevPortalId(currentPortalId);
2211
+ return response;
2212
+ },
2213
+ options
2214
+ );
2215
+ return {
2216
+ mutate,
2217
+ login: mutate,
2218
+ isLoading
2219
+ };
2220
+ }
2221
+ function verifyEmail(options) {
2222
+ const { mutate, isLoading } = createMutation(
2223
+ async (payload) => {
2224
+ const verifyEmailPayload = payload || {};
2225
+ const token = getParam("token");
2226
+ if (!verifyEmailPayload?.token) verifyEmailPayload.token = token;
2227
+ const response = await Client.authentication.verifyEmail(verifyEmailPayload);
2228
+ return response;
2229
+ },
2230
+ options
2231
+ );
2232
+ return {
2233
+ mutate,
2234
+ verifyEmail: mutate,
2235
+ isLoading
2236
+ };
2237
+ }
2238
+ function resetPasswordVerifyToken(options) {
2239
+ const { mutate, isLoading } = createMutation(
2240
+ async (payload) => {
2241
+ const resetPasswordVerifyTokenPayload = payload || {};
2242
+ const token = getParam("token");
2243
+ if (!resetPasswordVerifyTokenPayload?.token) resetPasswordVerifyTokenPayload.token = token;
2244
+ const response = await Client.authentication.resetPasswordVerifyToken(resetPasswordVerifyTokenPayload);
2245
+ return response;
2246
+ },
2247
+ options
2248
+ );
2249
+ return {
2250
+ mutate,
2251
+ resetPasswordVerifyToken: mutate,
2252
+ isLoading
2253
+ };
2254
+ }
2255
+ function resetPassword(options) {
2256
+ const { mutate, isLoading } = createMutation(
2257
+ async (payload) => {
2258
+ const response = await Client.authentication.resetPassword(payload);
2259
+ return response;
2260
+ },
2261
+ options
2262
+ );
2263
+ return {
2264
+ mutate,
2265
+ resetPassword: mutate,
2266
+ isLoading
2267
+ };
2268
+ }
2269
+ function forgetPassword(options) {
2270
+ const { mutate, isLoading } = createMutation(
2271
+ async (payload) => {
2272
+ const response = await Client.authentication.forgetPassword(payload);
2273
+ return response;
2274
+ },
2275
+ options
2276
+ );
2277
+ return {
2278
+ mutate,
2279
+ forgetPassword: mutate,
2280
+ isLoading
2281
+ };
2282
+ }
2283
+ function logout(options) {
2284
+ const { mutate, isLoading } = createMutation(
2285
+ async () => {
2286
+ const response = await Client.authentication.logout();
2287
+ clearAccessToken();
2288
+ removeAllCookie();
2289
+ return response;
2290
+ },
2291
+ options
2292
+ );
2293
+ return {
2294
+ mutate,
2295
+ logout: mutate,
2296
+ isLoading
2297
+ };
2298
+ }
2299
+ function registerExistingUser(options) {
2300
+ const { mutate, isLoading } = createMutation(
2301
+ async (payload) => {
2302
+ const response = await Client.authentication.registerExistingUser(payload);
2303
+ return response;
2304
+ },
2305
+ options
2306
+ );
2307
+ return {
2308
+ mutate,
2309
+ registerExistingUser: mutate,
2310
+ isLoading
2311
+ };
2312
+ }
2313
+ function verifyEmailResend(options) {
2314
+ const { mutate, isLoading } = createMutation(
2315
+ async (payload) => {
2316
+ const response = await Client.authentication.verifyEmailResend(payload);
2317
+ return response;
2318
+ },
2319
+ options
2320
+ );
2321
+ return {
2322
+ mutate,
2323
+ verifyEmailResend: mutate,
2324
+ isLoading
2325
+ };
2326
+ }
2327
+ function resendEmail(options) {
2328
+ const { mutate, isLoading } = createMutation(
2329
+ async (payload) => {
2330
+ const response = await Client.authentication.resendEmail(payload);
2331
+ return response;
2332
+ },
2333
+ options
2334
+ );
2335
+ return {
2336
+ mutate,
2337
+ resendEmail: mutate,
2338
+ isLoading
2339
+ };
2340
+ }
2341
+
2342
+ // src/apis/sso.ts
2343
+ function getSsoDetails(options) {
2344
+ const { mutate, isLoading } = createMutation(
2345
+ async () => {
2346
+ const response = await Client.sso.getSsoDetails();
2347
+ return response;
2348
+ },
2349
+ options
2350
+ );
2351
+ return {
2352
+ mutate,
2353
+ getSsoDetails: mutate,
2354
+ isLoading
2355
+ };
2356
+ }
2357
+ function generateSsoUrl(options) {
2358
+ const { mutate, isLoading } = createMutation(
2359
+ async (payload) => {
2360
+ const response = await Client.sso.generateSsoUrl(payload);
2361
+ return response;
2362
+ },
2363
+ options
2364
+ );
2365
+ return {
2366
+ mutate,
2367
+ generateSsoUrl: mutate,
2368
+ isLoading
2369
+ };
2370
+ }
2371
+ function ssoCallback(options) {
2372
+ const { mutate, isLoading } = createMutation(
2373
+ async (payload) => {
2374
+ const response = await Client.sso.ssoCallback(payload);
2375
+ return response;
2376
+ },
2377
+ options
2378
+ );
2379
+ return {
2380
+ mutate,
2381
+ ssoCallback: mutate,
2382
+ isLoading
2383
+ };
2384
+ }
2385
+
2386
+ // src/apis/users.ts
2387
+ function me(options) {
2388
+ const { mutate, isLoading } = createMutation(
2389
+ async () => {
2390
+ const response = await Client.user.me();
2391
+ return response;
2392
+ },
2393
+ options
2394
+ );
2395
+ return {
2396
+ mutate,
2397
+ me: mutate,
2398
+ isLoading
2399
+ };
2400
+ }
2401
+ function profile(options) {
2402
+ const { mutate, isLoading } = createMutation(
2403
+ async (paylaod) => {
2404
+ const response = await Client.user.profile(paylaod);
2405
+ setProfileData(response);
2406
+ return response;
2407
+ },
2408
+ options
2409
+ );
2410
+ return {
2411
+ mutate,
2412
+ profile: mutate,
2413
+ isLoading
2414
+ };
2415
+ }
2416
+ function changePassword(options) {
2417
+ const { mutate, isLoading } = createMutation(
2418
+ async (payload) => {
2419
+ const response = await Client.user.changePassword(payload);
2420
+ return response;
2421
+ },
2422
+ options
2423
+ );
2424
+ return {
2425
+ mutate,
2426
+ changePassword: mutate,
2427
+ isLoading
2428
+ };
2429
+ }
2430
+
2431
+ // src/apis/pipeline.ts
2432
+ function list(options) {
2433
+ const {
2434
+ getTableParam
2435
+ } = useTable();
2436
+ const { mutate, isLoading } = createMutation(
2437
+ async (payload) => {
2438
+ const param = await getTableParam(payload?.companyAsMediator);
2439
+ const response = await Client.pipeline.list(payload, param);
2440
+ return response;
2441
+ },
2442
+ options
2443
+ );
2444
+ return {
2445
+ mutate,
2446
+ getPipelines: mutate,
2447
+ isLoading
2448
+ };
2449
+ }
2450
+
2451
+ // src/apis/stage.ts
2452
+ function list2(options) {
2453
+ const { mutate, isLoading } = createMutation(
2454
+ async (payload) => {
2455
+ const response = await Client.stage.list(payload);
2456
+ return response;
2457
+ },
2458
+ options
2459
+ );
2460
+ return {
2461
+ mutate,
2462
+ getStages: mutate,
2463
+ isLoading
2464
+ };
2465
+ }
2466
+
2467
+ // src/store2/use-multi-object.ts
2468
+ var multiObjectStore = createStore2({
2469
+ objects: {},
2470
+ objectsPrependData: {},
2471
+ meta: {}
2472
+ });
2473
+ function getObjectKey(payload) {
2474
+ return String(payload?.hubspotObjectTypeId ?? "");
2475
+ }
2476
+ var actions7 = {
2477
+ setMultiObjectData(response, payload) {
2478
+ const key = getObjectKey(payload);
2479
+ const state = multiObjectStore.getState();
2480
+ const rows = response?.data?.results?.rows ?? [];
2481
+ const rowIds = new Set(
2482
+ rows.map((row) => row.id ?? row.hs_object_id).filter((id) => id != null && id !== "").map((id) => String(id))
2483
+ );
2484
+ let newPrependForKey = (state.objectsPrependData[key] ?? []).filter((item) => {
2485
+ const itemId = item.id ?? item.hs_object_id;
2486
+ if (itemId == null || itemId === "") return true;
2487
+ return !rowIds.has(String(itemId));
2488
+ });
2489
+ const selectedPipeline = payload?.selectedPipeline ?? "";
2490
+ const viewType = response?.info?.viewType ?? "";
2491
+ const prevMeta = state.meta[key];
2492
+ if (response?.data?.total < 1 || payload?.componentName) {
2493
+ newPrependForKey = [];
2494
+ }
2495
+ if (prevMeta?.viewType && prevMeta.viewType !== viewType) {
2496
+ newPrependForKey = [];
2497
+ }
2498
+ if (prevMeta?.selectedPipeline && prevMeta.selectedPipeline !== selectedPipeline) {
2499
+ newPrependForKey = [];
2500
+ }
2501
+ multiObjectStore.setState({
2502
+ objects: { ...state.objects, [key]: response },
2503
+ objectsPrependData: { ...state.objectsPrependData, [key]: newPrependForKey },
2504
+ meta: {
2505
+ ...state.meta,
2506
+ [key]: { selectedPipeline, viewType }
2507
+ }
2508
+ });
2509
+ },
2510
+ clearMultiObjectPrependData(hubspotObjectTypeId) {
2511
+ const state = multiObjectStore.getState();
2512
+ if (!hubspotObjectTypeId) {
2513
+ multiObjectStore.setState({ objectsPrependData: {} });
2514
+ return;
2515
+ }
2516
+ const key = String(hubspotObjectTypeId);
2517
+ const { [key]: _, ...rest } = state.objectsPrependData;
2518
+ multiObjectStore.setState({ objectsPrependData: rest });
2519
+ },
2520
+ async setMultiObjectPrependData(response, props) {
2521
+ const key = getObjectKey(props);
2522
+ const state = multiObjectStore.getState();
2523
+ const tableResponse = state.objects[key];
2524
+ let rows = state.objectsPrependData[key] ?? [];
2525
+ if (tableResponse?.data?.total > 1) {
2526
+ if (response === "loading") {
2527
+ const row = tableResponse?.data?.results?.columns.reduce(
2528
+ (acc, item) => {
2529
+ if (!item.hidden) {
2530
+ acc[item.key] = "loading";
2531
+ }
2532
+ return acc;
2533
+ },
2534
+ {}
2535
+ );
2536
+ rows = [row, ...rows];
2537
+ } else if (response?.data) {
2538
+ const data = response?.data;
2539
+ if (!data) {
2540
+ multiObjectStore.setState({
2541
+ objectsPrependData: { ...state.objectsPrependData, [key]: [] }
2542
+ });
2543
+ return;
2544
+ }
2545
+ const row = Object.fromEntries(
2546
+ Object.entries(data).map(([k, value]) => [k, value?.value ?? value])
2547
+ );
2548
+ rows = [...rows];
2549
+ if (rows.length > 0) {
2550
+ rows[0] = row;
2551
+ } else {
2552
+ rows.push(row);
2553
+ }
2554
+ }
2555
+ }
2556
+ multiObjectStore.setState({
2557
+ objectsPrependData: { ...state.objectsPrependData, [key]: rows }
2558
+ });
2559
+ }
2560
+ };
2561
+
2562
+ // src/apis/object.ts
2563
+ function list3(options) {
2564
+ const { getTableParam } = useTable();
2565
+ const { setObjectsData, setTableData } = actions2;
2566
+ const { mutate, isLoading } = createMutation(
2567
+ async (payload) => {
2568
+ const param = await getTableParam(payload?.companyAsMediator);
2569
+ const response = await Client.object.list(payload, param);
2570
+ await setObjectsData(response);
2571
+ await setTableData(response, payload);
2572
+ return response;
2573
+ },
2574
+ options
2575
+ );
2576
+ return {
2577
+ mutate,
2578
+ getObjects: mutate,
2579
+ isLoading
2580
+ };
2581
+ }
2582
+ function sideBarList(options) {
2583
+ const { setMultiObjectData } = actions7;
2584
+ const { mutate, isLoading } = createMutation(
2585
+ async (payload) => {
2586
+ const response = await Client.object.sideBarList(payload);
2587
+ setMultiObjectData(response, payload);
2588
+ return response;
2589
+ },
2590
+ options
2591
+ );
2592
+ return {
2593
+ mutate,
2594
+ getSideBarObjects: mutate,
2595
+ isLoading
2596
+ };
2597
+ }
2598
+ function form(options) {
2599
+ const { setFormData } = actions;
2600
+ const { mutate, isLoading } = createMutation(
2601
+ async (payload) => {
2602
+ const response = await Client.object.form(payload);
2603
+ setFormData(response);
2604
+ return response;
2605
+ },
2606
+ options
2607
+ );
2608
+ return {
2609
+ mutate,
2610
+ getObjectsForm: mutate,
2611
+ isLoading
2612
+ };
2613
+ }
2614
+ function objectFormOptions(options) {
2615
+ const { mutate, isLoading } = createMutation(
2616
+ async (payload) => {
2617
+ const response = await Client.object.objectFormOptions(payload);
2618
+ return response;
2619
+ },
2620
+ options
2621
+ );
2622
+ return {
2623
+ mutate,
2624
+ objectFormOptions: mutate,
2625
+ isLoading
2626
+ };
2627
+ }
2628
+ function create(options) {
2629
+ const { setTablePrependData } = actions2;
2630
+ const { setMultiObjectPrependData } = actions7;
2631
+ const { mutate, isLoading } = createMutation(
2632
+ async (props) => {
2633
+ if (props?.componentName === "sidebarTable") await setMultiObjectPrependData("loading", props);
2634
+ if (props?.componentName != "association" && props?.componentName != "sidebarTable") await setTablePrependData("loading", props);
2635
+ const response = await Client.object.create(props);
2636
+ if (props?.componentName === "sidebarTable") await setMultiObjectPrependData(response, props);
2637
+ if (props?.componentName != "association" && props?.componentName != "sidebarTable") await setTablePrependData(response, props);
2638
+ return response;
2639
+ },
2640
+ options
2641
+ );
2642
+ return {
2643
+ mutate,
2644
+ createObject: mutate,
2645
+ isLoading
2646
+ };
2647
+ }
2648
+ function createExisting(options) {
2649
+ const { mutate, isLoading } = createMutation(
2650
+ async (props) => {
2651
+ const response = await Client.object.createExisting(props);
2652
+ return response;
2653
+ },
2654
+ options
2655
+ );
2656
+ return {
2657
+ mutate,
2658
+ createExistingObject: mutate,
2659
+ isLoading
2660
+ };
2661
+ }
2662
+ function removeExisting(options) {
2663
+ const { mutate, isLoading } = createMutation(
2664
+ async (props) => {
2665
+ const response = await Client.object.removeExisting(props);
2666
+ return response;
2667
+ },
2668
+ options
2669
+ );
2670
+ return {
2671
+ mutate,
2672
+ removeExisting: mutate,
2673
+ isLoading
2674
+ };
2675
+ }
2676
+ function details(options) {
2677
+ const { mutate, isLoading } = createMutation(
2678
+ async (payload) => {
2679
+ const response = await Client.object.details(payload);
2680
+ return response;
2681
+ },
2682
+ options
2683
+ );
2684
+ return {
2685
+ mutate,
2686
+ getObjectsDetails: mutate,
2687
+ isLoading
2688
+ };
2689
+ }
2690
+ function update(options) {
2691
+ const { mutate, isLoading } = createMutation(
2692
+ async (payload) => {
2693
+ const response = await Client.object.update(payload);
2694
+ return response;
2695
+ },
2696
+ options
2697
+ );
2698
+ return {
2699
+ mutate,
2700
+ updateObjectsDetails: mutate,
2701
+ isLoading
2702
+ };
2703
+ }
2704
+
2705
+ // src/apis/note.ts
2706
+ function list4(options) {
2707
+ const { setNotes } = actions4;
2708
+ const { mutate, isLoading } = createMutation(
2709
+ async (payload) => {
2710
+ const response = await Client.note.list(payload);
2711
+ setNotes(response, payload);
2712
+ return response;
2713
+ },
2714
+ options
2715
+ );
2716
+ return {
2717
+ mutate,
2718
+ getNotes: mutate,
2719
+ isLoading
2720
+ };
2721
+ }
2722
+ function create2(options) {
2723
+ const { setPrependNote } = actions4;
2724
+ const { mutate, isLoading } = createMutation(
2725
+ async (props) => {
2726
+ await setPrependNote("loading");
2727
+ const response = await Client.note.create(props);
2728
+ await setPrependNote(response);
2729
+ return response;
2730
+ },
2731
+ options
2732
+ );
2733
+ return {
2734
+ mutate,
2735
+ createNote: mutate,
2736
+ isLoading
2737
+ };
2738
+ }
2739
+ function update2(options) {
2740
+ const { updatePrependNote } = actions4;
2741
+ const { mutate, isLoading } = createMutation(
2742
+ async (payload) => {
2743
+ const response = await Client.note.update(payload);
2744
+ return updatePrependNote(response);
2745
+ },
2746
+ options
2747
+ );
2748
+ return {
2749
+ mutate,
2750
+ updateNote: mutate,
2751
+ isLoading
2752
+ };
2753
+ }
2754
+
2755
+ // src/apis/email.ts
2756
+ function list5(options) {
2757
+ const { setEmails } = actions5;
2758
+ const { mutate, isLoading } = createMutation(
2759
+ async (payload) => {
2760
+ const response = await Client.email.list(payload);
2761
+ setEmails(response, payload);
2762
+ return response;
2763
+ },
2764
+ options
2765
+ );
2766
+ return {
2767
+ mutate,
2768
+ getEmails: mutate,
2769
+ isLoading
2770
+ };
2771
+ }
2772
+ function create3(options) {
2773
+ const { setPrependEmail } = actions5;
2774
+ const { mutate, isLoading } = createMutation(
2775
+ async (props) => {
2776
+ await setPrependEmail("loading");
2777
+ const response = await Client.email.create(props);
2778
+ await setPrependEmail(response);
2779
+ return response;
2780
+ },
2781
+ options
2782
+ );
2783
+ return {
2784
+ mutate,
2785
+ createEmail: mutate,
2786
+ isLoading
2787
+ };
2788
+ }
2789
+ function update3(options) {
2790
+ const { updatePrependEmail } = actions5;
2791
+ const { mutate, isLoading } = createMutation(
2792
+ async (payload) => {
2793
+ const response = await Client.email.update(payload);
2794
+ return updatePrependEmail(response);
2795
+ },
2796
+ options
2797
+ );
2798
+ return {
2799
+ mutate,
2800
+ updateEmail: mutate,
2801
+ isLoading
2802
+ };
2803
+ }
2804
+
2805
+ // src/apis/uploader.ts
2806
+ function imageUpload(options) {
2807
+ const { mutate, isLoading } = createMutation(
2808
+ async (payload) => {
2809
+ const response = payload?.type === "email" ? await Client.email.image(payload) : await Client.note.image(payload);
2810
+ return response;
2811
+ },
2812
+ options
2813
+ );
2814
+ return {
2815
+ mutate,
2816
+ imageUpload: mutate,
2817
+ isLoading
2818
+ };
2819
+ }
2820
+ function attachmentUpload(options) {
2821
+ const { mutate, isLoading } = createMutation(
2822
+ async (payload) => {
2823
+ const response = payload?.type === "email" ? await Client.email.attachment(payload) : await Client.note.attachment(payload);
2824
+ actions3.setAttachment(response);
2825
+ return response;
2826
+ },
2827
+ options
2828
+ );
2829
+ return {
2830
+ mutate,
2831
+ attachmentUpload: mutate,
2832
+ isLoading
2833
+ };
2834
+ }
2835
+
2836
+ // src/apis/file.ts
2837
+ function list6(options) {
2838
+ const { mutate, isLoading } = createMutation(
2839
+ async (payload) => {
2840
+ const response = await Client.file.list(payload);
2841
+ return response;
2842
+ },
2843
+ options
2844
+ );
2845
+ return {
2846
+ mutate,
2847
+ getFiles: mutate,
2848
+ isLoading
2849
+ };
2850
+ }
2851
+ function details2(options) {
2852
+ const { mutate, isLoading } = createMutation(
2853
+ async (payload) => {
2854
+ const response = await Client.file.details(payload);
2855
+ return response;
2856
+ },
2857
+ options
2858
+ );
2859
+ return {
2860
+ mutate,
2861
+ getFile: mutate,
2862
+ isLoading
2863
+ };
2864
+ }
2865
+ function addFolder(options) {
2866
+ const { mutate, isLoading } = createMutation(
2867
+ async (props) => {
2868
+ const response = await Client.file.addFolder(props);
2869
+ return response;
2870
+ },
2871
+ options
2872
+ );
2873
+ return {
2874
+ mutate,
2875
+ addFolder: mutate,
2876
+ isLoading
2877
+ };
2878
+ }
2879
+ function addFile(options) {
2880
+ const { mutate, isLoading } = createMutation(
2881
+ async (props) => {
2882
+ const response = await Client.file.addFile(props);
2883
+ return response;
2884
+ },
2885
+ options
2886
+ );
2887
+ return {
2888
+ mutate,
2889
+ addFile: mutate,
2890
+ isLoading
2891
+ };
2892
+ }
2893
+ function download(options) {
2894
+ const { mutate, isLoading } = createMutation(
2895
+ async (payload) => {
2896
+ const response = await Client.file.download(payload);
2897
+ return response;
2898
+ },
2899
+ options
2900
+ );
2901
+ return {
2902
+ mutate,
2903
+ downloadFile: mutate,
2904
+ isLoading
2905
+ };
2906
+ }
2907
+
2908
+ // src/apis/cache.ts
2909
+ function purge(options) {
2910
+ const { mutate, isLoading } = createMutation(
2911
+ async (payload) => {
2912
+ const safePayload = payload ?? {};
2913
+ const idempotencyKey = typeof safePayload.idempotencyKey === "string" ? safePayload.idempotencyKey : void 0;
2914
+ const headers = idempotencyKey ? { "Idempotency-Key": idempotencyKey } : void 0;
2915
+ const { idempotencyKey: _ignored, ...body } = safePayload;
2916
+ return Client.cache.purge(body, headers);
2917
+ },
2918
+ options
2919
+ );
2920
+ return { mutate, purgeCache: mutate, isLoading };
2921
+ }
2922
+ function purgeStatus(purgeJobId, options) {
2923
+ const { mutate, isLoading } = createMutation(
2924
+ async (jobId) => Client.cache.purgeStatus(jobId ?? purgeJobId),
2925
+ options
2926
+ );
2927
+ return {
2928
+ mutate,
2929
+ getPurgeStatus: () => mutate(purgeJobId),
2930
+ isLoading
2931
+ };
2932
+ }
2933
+
2934
+ // src/breadcrumb/breadcrumbs.ts
2935
+ var getBreadcrumbs = () => {
2936
+ const search = getParam("b");
2937
+ let breadcrumbs = decodeToBase64(search) || [];
2938
+ if (!breadcrumbs && breadcrumbs.length < 1) return [];
2939
+ const updated = breadcrumbs.map((breadcrumb, index) => {
2940
+ return generatePath(breadcrumbs, breadcrumb, index);
2941
+ });
2942
+ if (updated.length < 1) {
2943
+ const pathname = getPath();
2944
+ const routeMenu = getRouteMenu(pathname);
2945
+ return [
2946
+ {
2947
+ name: routeMenu?.title,
2948
+ path: routeMenu?.path
2949
+ }
2950
+ ];
2951
+ }
2952
+ return updated;
2953
+ };
2954
+ var getTableTitle = (componentName, title, ticketTableTitle) => {
2955
+ const search = getParam("b");
2956
+ let breadcrumbs = decodeToBase64(search) || [];
2957
+ if (breadcrumbs.length < 1) {
2958
+ const pathname = getPath();
2959
+ const routeMenu = getRouteMenu(pathname);
2960
+ breadcrumbs = [
2961
+ {
2962
+ n: routeMenu?.title,
2963
+ pt: routeMenu?.path
2964
+ }
2965
+ ];
2966
+ }
2967
+ let associatedtableTitleSingular = "";
2968
+ let tableTitle = "";
2969
+ let singularTableTitle = "";
2970
+ if (breadcrumbs && breadcrumbs.length > 0) {
2971
+ const lastItem = breadcrumbs[breadcrumbs.length - 1];
2972
+ const last = lastItem ? generatePath(breadcrumbs, lastItem, breadcrumbs.length - 1) : null;
2973
+ const previousItem = breadcrumbs[breadcrumbs.length - 2];
2974
+ const previous = previousItem ? generatePath(breadcrumbs, previousItem, breadcrumbs.length - 2) : null;
2975
+ const singularLastName = last?.name;
2976
+ associatedtableTitleSingular = singularLastName;
2977
+ if (componentName != "ticket") {
2978
+ tableTitle = previous?.name ? { last, previous } : { last };
2979
+ singularTableTitle = previous?.name ? `${singularLastName} with ${previous?.name}` : singularLastName;
2980
+ } else {
2981
+ const ticketTableTitleSingular = ticketTableTitle.endsWith("s") ? ticketTableTitle.slice(0, -1) : ticketTableTitle;
2982
+ tableTitle = { last: { name: title } };
2983
+ singularTableTitle = previous?.name ? `${ticketTableTitleSingular} with ${singularLastName} ` : ticketTableTitleSingular;
2984
+ }
2985
+ }
2986
+ return { associatedtableTitleSingular, tableTitle, singularTableTitle };
2987
+ };
2988
+ var getFormTitle = (type, title, activeTab) => {
2989
+ const search = getParam("b");
2990
+ let breadcrumbs = decodeToBase64(search) || [];
2991
+ if (breadcrumbs.length < 1) {
2992
+ const pathname = getPath();
2993
+ const routeMenu = getRouteMenu(pathname);
2994
+ breadcrumbs = [
2995
+ {
2996
+ n: routeMenu?.title,
2997
+ pt: routeMenu?.path
2998
+ }
2999
+ ];
3000
+ }
3001
+ let objectName = "";
3002
+ let puralObjectName = "";
3003
+ let dialogTitle = "";
3004
+ if (breadcrumbs && breadcrumbs?.length > 0) {
3005
+ const last = breadcrumbs[breadcrumbs?.length - 1];
3006
+ const lastName = last?.n;
3007
+ const mTitle = title;
3008
+ if (type === "association" && breadcrumbs && breadcrumbs?.length > 0) {
3009
+ objectName = title;
3010
+ puralObjectName = title;
3011
+ dialogTitle = `${activeTab == "addNew" ? `Create a new ${mTitle} for ${nameTrancate(lastName)}` : `Associate an Existing ${mTitle} with ${nameTrancate(lastName)}`}`;
3012
+ } else {
3013
+ const singularLastName = typeof lastName === "string" && lastName?.endsWith("s") ? lastName.slice(0, -1) : lastName;
3014
+ objectName = singularLastName;
3015
+ puralObjectName = lastName;
3016
+ dialogTitle = `${activeTab == "addNew" ? `Create a new ${mTitle?.includes("with") ? nameTrancate(mTitle?.replace("with", "for")) : nameTrancate(mTitle)}` : `Associate an Existing ${nameTrancate(mTitle)}`}`;
3017
+ }
3018
+ }
3019
+ return { objectName, puralObjectName, dialogTitle };
3020
+ };
3021
+ var nameTrancate = (name) => {
3022
+ return name?.length > 30 ? `${name?.slice(0, 30) + "..."}` : name;
3023
+ };
3024
+
3025
+ // src/breadcrumb/generate-url.ts
3026
+ var useMakeLink = () => {
3027
+ const search = getParam("b");
3028
+ const makeLink = (props) => {
3029
+ if (!search || "isPC" in props) {
3030
+ return buildParentRoute(props);
3031
+ } else {
3032
+ const breadcrumbItems = decodeToBase64(search) || [];
3033
+ return buildChildRoute(props, breadcrumbItems);
3034
+ }
3035
+ };
3036
+ return { makeLink };
3037
+ };
3038
+ var buildParentRoute = (props) => {
3039
+ const pathname = getPath();
3040
+ const routeMenu = getRouteMenu(pathname);
3041
+ const breadcrumbItems = [
3042
+ {
3043
+ n: routeMenu?.title,
3044
+ o_t_id: routeMenu?.path,
3045
+ isHome: props?.isHome || false
3046
+ }
3047
+ ];
3048
+ return buildChildRoute(props, breadcrumbItems);
3049
+ };
3050
+ var buildChildRoute = (props, breadcrumbItems) => {
3051
+ let breadcrumbs = [...breadcrumbItems];
3052
+ let breadcrumbType = breadcrumbStage(breadcrumbItems);
3053
+ if (props?.isHome && isMessingParentLastItem(breadcrumbItems)) {
3054
+ const parent = {
3055
+ n: props?.title || "",
3056
+ o_t_id: props?.objectTypeId,
3057
+ "pt": `/association/${props?.objectTypeId}`,
3058
+ isHome: props?.isHome || false,
3059
+ "prm": {
3060
+ "sort": "-hs_createdate",
3061
+ "s": "",
3062
+ "fPn": "hs_pipeline",
3063
+ "fO": "eq",
3064
+ "fV": "",
3065
+ "c": true,
3066
+ "isPC": props?.isPC,
3067
+ "v": "LIST",
3068
+ "l": "10",
3069
+ "p": 1
3070
+ }
3071
+ };
3072
+ breadcrumbs.push(parent);
3073
+ const newCrumb = {
3074
+ n: props?.name,
3075
+ o_t_id: props?.objectTypeId,
3076
+ o_r_id: props?.recordId
3077
+ };
3078
+ breadcrumbs.push(newCrumb);
3079
+ } else if (breadcrumbType === "root") {
3080
+ const newCrumb = {
3081
+ n: props?.name,
3082
+ o_t_id: props?.objectTypeId,
3083
+ o_r_id: props?.recordId
3084
+ };
3085
+ if (props?.isPC) {
3086
+ newCrumb.prm = {
3087
+ isPC: props?.isPC
3088
+ };
3089
+ }
3090
+ breadcrumbs.push(newCrumb);
3091
+ } else {
3092
+ const lastItem = breadcrumbs[breadcrumbs.length - 1];
3093
+ if (props?.objectTypeId != "0-5" && breadcrumbs.length > 2 && // check for only association ticket object
3094
+ (!isMessingParent(breadcrumbItems) && lastItem?.o_t_id === props?.objectTypeId) && // check for all associated object and check isMessingParent for skip parent to child and child to parent association data
3095
+ (props?.isHome && !isMessingParentLastItem(breadcrumbItems))) {
3096
+ const newCrumb = {
3097
+ n: props?.name,
3098
+ o_t_id: props?.objectTypeId,
3099
+ o_r_id: props?.recordId
3100
+ };
3101
+ if (props?.isPC) {
3102
+ newCrumb.prm = {
3103
+ isPC: props?.isPC
3104
+ };
3105
+ }
3106
+ breadcrumbs.push(newCrumb);
3107
+ } else {
3108
+ const lastItem2 = breadcrumbs[breadcrumbs.length - 1];
3109
+ const parent = {
3110
+ n: props?.associationLabel || props?.name,
3111
+ o_t_id: props?.objectTypeId
3112
+ };
3113
+ if (props?.tableParam) {
3114
+ parent.prm = props?.tableParam;
3115
+ }
3116
+ if (props?.defPermissions) {
3117
+ parent.dp = props?.defPermissions;
3118
+ }
3119
+ if (lastItem2?.o_t_id && lastItem2?.o_r_id) {
3120
+ breadcrumbs.push(parent);
3121
+ }
3122
+ if (props?.recordId) {
3123
+ const newCrumb = {
3124
+ n: props?.name,
3125
+ o_t_id: props?.objectTypeId,
3126
+ o_r_id: props?.recordId
3127
+ };
3128
+ if (props?.isPC) {
3129
+ newCrumb.prm = {
3130
+ isPC: props?.isPC
3131
+ };
3132
+ }
3133
+ breadcrumbs.push(newCrumb);
3134
+ }
3135
+ }
3136
+ }
3137
+ return generateUrl(props, breadcrumbs);
3138
+ };
3139
+
3140
+ // src/utils/datetime.ts
3141
+ var DEFAULT_HUBSPOT_TIMEZONE = "Asia/Kolkata";
3142
+ function getCurrentTimeZone() {
3143
+ try {
3144
+ return Intl.DateTimeFormat().resolvedOptions().timeZone || DEFAULT_HUBSPOT_TIMEZONE;
3145
+ } catch {
3146
+ return DEFAULT_HUBSPOT_TIMEZONE;
3147
+ }
3148
+ }
3149
+ function normalizeToTimestamp(value) {
3150
+ if (value == null || value === "") return null;
3151
+ if (typeof value === "number") {
3152
+ return value > 1e11 ? value : null;
3153
+ }
3154
+ if (typeof value === "string" && /^\d+$/.test(value)) {
3155
+ const n = Number(value);
3156
+ return n > 1e11 ? n : null;
3157
+ }
3158
+ if (typeof value === "string" || value instanceof Date) {
3159
+ const date = new Date(value);
3160
+ return Number.isNaN(date.getTime()) ? null : date.getTime();
3161
+ }
3162
+ return null;
3163
+ }
3164
+ function formatGmtOffset(timeZone = getCurrentTimeZone(), date = /* @__PURE__ */ new Date()) {
3165
+ const raw = new Intl.DateTimeFormat("en-US", {
3166
+ timeZone,
3167
+ timeZoneName: "longOffset"
3168
+ }).formatToParts(date).find((part) => part.type === "timeZoneName")?.value;
3169
+ if (!raw) return "";
3170
+ return raw.replace(/GMT([+-])0(\d)(?=:)/, "GMT$1$2");
3171
+ }
3172
+ function formatHubSpotActivityDateTimeParts(timestamp, timeZone = getCurrentTimeZone()) {
3173
+ const ms = normalizeToTimestamp(timestamp);
3174
+ if (ms == null) return null;
3175
+ const date = new Date(ms);
3176
+ const datePart = new Intl.DateTimeFormat("en-US", {
3177
+ timeZone,
3178
+ month: "long",
3179
+ day: "numeric",
3180
+ year: "numeric"
3181
+ }).format(date);
3182
+ const timePart = new Intl.DateTimeFormat("en-US", {
3183
+ timeZone,
3184
+ hour: "numeric",
3185
+ minute: "2-digit",
3186
+ hour12: true
3187
+ }).format(date);
3188
+ const gmtOffset = formatGmtOffset(timeZone, date);
3189
+ return {
3190
+ date: datePart,
3191
+ time: timePart,
3192
+ gmtOffset,
3193
+ formatted: `${datePart} at ${timePart} ${gmtOffset}`.trim()
3194
+ };
3195
+ }
3196
+ function formatHubSpotActivityDateTime(timestamp, timeZone = getCurrentTimeZone()) {
3197
+ return formatHubSpotActivityDateTimeParts(timestamp, timeZone)?.formatted ?? "";
3198
+ }
3199
+
3200
+ // src/index.ts
3201
+ var api = {
3202
+ preLogin,
3203
+ login,
3204
+ verifyEmail,
3205
+ resetPasswordVerifyToken,
3206
+ resetPassword,
3207
+ registerExistingUser,
3208
+ verifyEmailResend,
3209
+ resendEmail,
3210
+ getSsoDetails,
3211
+ generateSsoUrl,
3212
+ ssoCallback,
3213
+ forgetPassword,
3214
+ logout,
3215
+ me,
3216
+ profile,
3217
+ changePassword,
3218
+ pipelines: list,
3219
+ stages: list2,
3220
+ objects: list3,
3221
+ sideBarObjects: sideBarList,
3222
+ objectsForm: form,
3223
+ createObject: create,
3224
+ createExistingObject: createExisting,
3225
+ removeExistingObject: removeExisting,
3226
+ objectsDetails: details,
3227
+ updateObjectsDetails: update,
3228
+ objectFormOptions,
3229
+ notes: list4,
3230
+ createNote: create2,
3231
+ updateNote: update2,
3232
+ emails: list5,
3233
+ createEmail: create3,
3234
+ updateEmail: update3,
3235
+ imageUpload,
3236
+ attachmentUpload,
3237
+ files: list6,
3238
+ file: details2,
3239
+ fileDownload: download,
3240
+ addFolder,
3241
+ addFile,
3242
+ purgeCache: purge,
3243
+ cachePurgeStatus: purgeStatus,
3244
+ getRefreshToken,
3245
+ getAuthRefreshToken,
3246
+ isCookieExpired,
3247
+ isExpiresAccessToken,
3248
+ isAuthenticateApp,
3249
+ getAccessToken
3250
+ };
3251
+ var store = {
3252
+ storage,
3253
+ useTable
3254
+ };
3255
+ var breadcrumbsDetails = {
3256
+ getBreadcrumbs,
3257
+ getTableTitle,
3258
+ getFormTitle
3259
+ };
3260
+ var url = {
3261
+ useMakeLink,
3262
+ useUpdateLink
3263
+ };
3264
+ var routeParam = {
3265
+ getRouteDetails,
3266
+ getParamDetails
3267
+ };
3268
+
3269
+ export { DEFAULT_HUBSPOT_TIMEZONE, actions2 as actions, actions3 as actions2, actions4 as actions3, actions5 as actions4, actions6 as actions5, actions7 as actions6, api, breadcrumbsDetails, client_exports, emailStore, formatGmtOffset, formatHubSpotActivityDateTime, formatHubSpotActivityDateTimeParts, getCurrentTimeZone, getFieldErrors, getFormErrors, initializeHttpClient, multiObjectStore, normalizeToTimestamp, noteStore, routeParam, store, syncStore, tableStore2 as tableStore, uploaderStore, url };
3270
+ //# sourceMappingURL=chunk-3WO26LA6.js.map
3271
+ //# sourceMappingURL=chunk-3WO26LA6.js.map