@cossistant/core 0.0.19 → 0.0.22

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.
@@ -15,8 +15,8 @@ declare const timelineItemSchema: ZodObject<{
15
15
  private: "private";
16
16
  }>;
17
17
  type: ZodEnum<{
18
- event: "event";
19
18
  message: "message";
19
+ event: "event";
20
20
  identification: "identification";
21
21
  }>;
22
22
  text: ZodNullable<ZodString>;
@@ -27,6 +27,7 @@ declare const timelineItemSchema: ZodObject<{
27
27
  }, $strip>, ZodObject<{
28
28
  type: ZodLiteral<"event">;
29
29
  eventType: ZodEnum<{
30
+ resolved: "resolved";
30
31
  assigned: "assigned";
31
32
  unassigned: "unassigned";
32
33
  participant_requested: "participant_requested";
@@ -36,7 +37,6 @@ declare const timelineItemSchema: ZodObject<{
36
37
  priority_changed: "priority_changed";
37
38
  tag_added: "tag_added";
38
39
  tag_removed: "tag_removed";
39
- resolved: "resolved";
40
40
  reopened: "reopened";
41
41
  visitor_blocked: "visitor_blocked";
42
42
  visitor_unblocked: "visitor_unblocked";
@@ -61,6 +61,13 @@ declare const timelineItemSchema: ZodObject<{
61
61
  mediaType: ZodString;
62
62
  fileName: ZodOptional<ZodString>;
63
63
  size: ZodOptional<ZodNumber>;
64
+ }, $strip>, ZodObject<{
65
+ type: ZodLiteral<"metadata">;
66
+ source: ZodEnum<{
67
+ email: "email";
68
+ widget: "widget";
69
+ api: "api";
70
+ }>;
64
71
  }, $strip>]>>;
65
72
  userId: ZodNullable<ZodString>;
66
73
  aiAgentId: ZodNullable<ZodString>;
@@ -85,8 +92,8 @@ declare const getConversationTimelineItemsResponseSchema: ZodObject<{
85
92
  private: "private";
86
93
  }>;
87
94
  type: ZodEnum<{
88
- event: "event";
89
95
  message: "message";
96
+ event: "event";
90
97
  identification: "identification";
91
98
  }>;
92
99
  text: ZodNullable<ZodString>;
@@ -97,6 +104,7 @@ declare const getConversationTimelineItemsResponseSchema: ZodObject<{
97
104
  }, $strip>, ZodObject<{
98
105
  type: ZodLiteral<"event">;
99
106
  eventType: ZodEnum<{
107
+ resolved: "resolved";
100
108
  assigned: "assigned";
101
109
  unassigned: "unassigned";
102
110
  participant_requested: "participant_requested";
@@ -106,7 +114,6 @@ declare const getConversationTimelineItemsResponseSchema: ZodObject<{
106
114
  priority_changed: "priority_changed";
107
115
  tag_added: "tag_added";
108
116
  tag_removed: "tag_removed";
109
- resolved: "resolved";
110
117
  reopened: "reopened";
111
118
  visitor_blocked: "visitor_blocked";
112
119
  visitor_unblocked: "visitor_unblocked";
@@ -131,6 +138,13 @@ declare const getConversationTimelineItemsResponseSchema: ZodObject<{
131
138
  mediaType: ZodString;
132
139
  fileName: ZodOptional<ZodString>;
133
140
  size: ZodOptional<ZodNumber>;
141
+ }, $strip>, ZodObject<{
142
+ type: ZodLiteral<"metadata">;
143
+ source: ZodEnum<{
144
+ email: "email";
145
+ widget: "widget";
146
+ api: "api";
147
+ }>;
134
148
  }, $strip>]>>;
135
149
  userId: ZodNullable<ZodString>;
136
150
  aiAgentId: ZodNullable<ZodString>;
@@ -147,8 +161,8 @@ declare const sendTimelineItemRequestSchema: ZodObject<{
147
161
  item: ZodObject<{
148
162
  id: ZodOptional<ZodString>;
149
163
  type: ZodDefault<ZodEnum<{
150
- event: "event";
151
164
  message: "message";
165
+ event: "event";
152
166
  }>>;
153
167
  text: ZodString;
154
168
  parts: ZodOptional<ZodArray<ZodUnion<readonly [ZodObject<{
@@ -157,6 +171,7 @@ declare const sendTimelineItemRequestSchema: ZodObject<{
157
171
  }, $strip>, ZodObject<{
158
172
  type: ZodLiteral<"event">;
159
173
  eventType: ZodEnum<{
174
+ resolved: "resolved";
160
175
  assigned: "assigned";
161
176
  unassigned: "unassigned";
162
177
  participant_requested: "participant_requested";
@@ -166,7 +181,6 @@ declare const sendTimelineItemRequestSchema: ZodObject<{
166
181
  priority_changed: "priority_changed";
167
182
  tag_added: "tag_added";
168
183
  tag_removed: "tag_removed";
169
- resolved: "resolved";
170
184
  reopened: "reopened";
171
185
  visitor_blocked: "visitor_blocked";
172
186
  visitor_unblocked: "visitor_unblocked";
@@ -191,6 +205,13 @@ declare const sendTimelineItemRequestSchema: ZodObject<{
191
205
  mediaType: ZodString;
192
206
  fileName: ZodOptional<ZodString>;
193
207
  size: ZodOptional<ZodNumber>;
208
+ }, $strip>, ZodObject<{
209
+ type: ZodLiteral<"metadata">;
210
+ source: ZodEnum<{
211
+ email: "email";
212
+ widget: "widget";
213
+ api: "api";
214
+ }>;
194
215
  }, $strip>]>>>;
195
216
  visibility: ZodDefault<ZodEnum<{
196
217
  public: "public";
@@ -214,8 +235,8 @@ declare const sendTimelineItemResponseSchema: ZodObject<{
214
235
  private: "private";
215
236
  }>;
216
237
  type: ZodEnum<{
217
- event: "event";
218
238
  message: "message";
239
+ event: "event";
219
240
  identification: "identification";
220
241
  }>;
221
242
  text: ZodNullable<ZodString>;
@@ -226,6 +247,7 @@ declare const sendTimelineItemResponseSchema: ZodObject<{
226
247
  }, $strip>, ZodObject<{
227
248
  type: ZodLiteral<"event">;
228
249
  eventType: ZodEnum<{
250
+ resolved: "resolved";
229
251
  assigned: "assigned";
230
252
  unassigned: "unassigned";
231
253
  participant_requested: "participant_requested";
@@ -235,7 +257,6 @@ declare const sendTimelineItemResponseSchema: ZodObject<{
235
257
  priority_changed: "priority_changed";
236
258
  tag_added: "tag_added";
237
259
  tag_removed: "tag_removed";
238
- resolved: "resolved";
239
260
  reopened: "reopened";
240
261
  visitor_blocked: "visitor_blocked";
241
262
  visitor_unblocked: "visitor_unblocked";
@@ -260,6 +281,13 @@ declare const sendTimelineItemResponseSchema: ZodObject<{
260
281
  mediaType: ZodString;
261
282
  fileName: ZodOptional<ZodString>;
262
283
  size: ZodOptional<ZodNumber>;
284
+ }, $strip>, ZodObject<{
285
+ type: ZodLiteral<"metadata">;
286
+ source: ZodEnum<{
287
+ email: "email";
288
+ widget: "widget";
289
+ api: "api";
290
+ }>;
263
291
  }, $strip>]>>;
264
292
  userId: ZodNullable<ZodString>;
265
293
  aiAgentId: ZodNullable<ZodString>;
@@ -1 +1 @@
1
- {"version":3,"file":"timeline-item.d.ts","names":[],"sources":["../../types/src/api/timeline-item.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAgMY,cA9EC,kBA8ED,EA9EmB,SA8EgB,CAAA;EAIlC,EAAA,aAAA,UAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA9BD,kBAAA,GAAqB,cAAe;KAEpC,YAAA,GAAe,cAAe;cAS7B,2CAAyC;;;;AAmBC,KAJ3C,mCAAA,GAAsC,MAIK,CAAA,OAH/C,yCAG+C,CAAA;AAAA,cAA1C,0CAA0C,EAAA,SAAA,CAAA;EAiB3C,KAAA,UAAA,UAAA,CAAA;IAKC,EAAA,aAAA,UAkDV,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAvDS,oCAAA,GAAuC,cAC3C;cAIK,+BAA6B;;;;;MAAA,KAAA,EAAA,OAAA;MAAA,OAAA,EAAA,SAAA;IAoD9B,CAAA,CAAA,CAAA;IAIC,IAAA,WAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAJD,uBAAA,GAA0B,cAC9B;cAGK,gCAA8B;;;;;;;;;;;;;;IAAA,IAAA,aAAA,UAAA,CAAA;IAAA,IAAA,aAAA,YAAA,UAAA,CAAA,CAAA;IAU/B,KAAA,UAAA,SAAwB,CAAA,SAC5B,UAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KADI,wBAAA,GAA2B,cAC/B"}
1
+ {"version":3,"file":"timeline-item.d.ts","names":[],"sources":["../../types/src/api/timeline-item.ts"],"sourcesContent":[],"mappings":";;;;;;;;cA4Ha,oBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmFwB,SAAA,WAAA;EAAA,SAAA,aAAA,YAAA,UAAA,CAAA,CAAA;AAiBvD,CAAA,QAAY,CAAA;AAKC,KArDD,kBAAA,GAAqB,MAuG9B,CAAA,OAvG6C,kBAuG7C,CAAA;KArGS,YAAA,GAAe,cAAe;cAU7B,2CAAyC;;;;KAe1C,mCAAA,GAAsC,cAC1C;cAGK,4CAA0C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAsBb,GAAA,EAAA,KAAA;MAAA,CAAA,CAAA;IAoD9B,CAAA,QAAA,CAAA,CAAA,CAAA,CAAA;IAIC,MAAA,aAAA,UAQV,CAAA;;;;;;;;;KArES,oCAAA,GAAuC,cAC3C;cAIK,+BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAwDC,MAAA,aAAA,YAAA,UAAA,CAAA,CAAA;IAAA,SAAA,aAAA,YAAA,UAAA,CAAA,CAAA;IAU/B,SAAA,aAAwB,YAC5B,UAAA,CAAA,CAAA;;;;KAfI,uBAAA,GAA0B,cAC9B;cAGK,gCAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAU/B,wBAAA,GAA2B,cAC/B"}
@@ -47,12 +47,12 @@ function getVisitorId(websiteId) {
47
47
  function setVisitorId(websiteId, visitorId) {
48
48
  if (!isLocalStorageAvailable()) return;
49
49
  try {
50
+ if (typeof window === "undefined") return;
50
51
  const data = {
51
52
  visitorId,
52
53
  timestamp: Date.now(),
53
54
  websiteId
54
55
  };
55
- if (typeof window === "undefined") return;
56
56
  const key = getStorageKey(websiteId);
57
57
  localStorage.setItem(key, JSON.stringify(data));
58
58
  } catch {}
@@ -1 +1 @@
1
- {"version":3,"file":"visitor-tracker.js","names":[],"sources":["../src/visitor-tracker.ts"],"sourcesContent":["/**\n * Visitor tracking utilities for managing visitor IDs in localStorage\n */\n\nimport { isValidULID } from \"./utils\";\n\nconst STORAGE_KEY_PREFIX = \"cossistant_visitor\";\n\n/**\n * Get the localStorage key for a specific website\n */\nfunction getStorageKey(websiteId: string): string {\n\treturn `${STORAGE_KEY_PREFIX}_${websiteId}`;\n}\n\n/**\n * Check if localStorage is available\n */\nfunction isLocalStorageAvailable(): boolean {\n\ttry {\n\t\tif (typeof window === \"undefined\" || !window.localStorage) {\n\t\t\treturn false;\n\t\t}\n\t\tconst testKey = \"__cossistant_test__\";\n\t\tlocalStorage.setItem(testKey, \"test\");\n\t\tlocalStorage.removeItem(testKey);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/**\n * Get visitor ID from localStorage for a specific website\n */\nexport function getVisitorId(websiteId: string): string | null {\n\tif (!isLocalStorageAvailable()) {\n\t\treturn null;\n\t}\n\n\ttry {\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn null;\n\t\t}\n\t\tconst data = localStorage.getItem(getStorageKey(websiteId));\n\t\tif (!data) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst parsed = JSON.parse(data);\n\t\t// Validate that the visitor ID is a valid ULID (26 characters)\n\t\tif (parsed.visitorId && isValidULID(parsed.visitorId)) {\n\t\t\treturn parsed.visitorId;\n\t\t}\n\t\treturn null;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n/**\n * Set visitor ID in localStorage for a specific website\n */\nexport function setVisitorId(websiteId: string, visitorId: string): void {\n\tif (!isLocalStorageAvailable()) {\n\t\treturn;\n\t}\n\n\ttry {\n\t\tconst data = {\n\t\t\tvisitorId,\n\t\t\ttimestamp: Date.now(),\n\t\t\twebsiteId,\n\t\t};\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn;\n\t\t}\n\t\tconst key = getStorageKey(websiteId);\n\t\tlocalStorage.setItem(key, JSON.stringify(data));\n\t} catch {\n\t\t// Silently fail - visitor tracking is not critical\n\t}\n}\n\n/**\n * Clear visitor ID for a specific website\n */\nexport function clearVisitorId(websiteId: string): void {\n\tif (!isLocalStorageAvailable()) {\n\t\treturn;\n\t}\n\n\ttry {\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn;\n\t\t}\n\t\tlocalStorage.removeItem(getStorageKey(websiteId));\n\t} catch {\n\t\t// Silently fail - visitor tracking is not critical\n\t}\n}\n\n/**\n * Clear all visitor IDs\n */\nexport function clearAllVisitorIds(): void {\n\tif (!isLocalStorageAvailable()) {\n\t\treturn;\n\t}\n\n\ttry {\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn;\n\t\t}\n\t\tconst keys = Object.keys(localStorage).filter((key) =>\n\t\t\tkey.startsWith(STORAGE_KEY_PREFIX)\n\t\t);\n\t\tfor (const key of keys) {\n\t\t\tlocalStorage.removeItem(key);\n\t\t}\n\t} catch {\n\t\t// Silently fail - visitor tracking is not critical\n\t}\n}\n\n/**\n * Get any existing visitor ID from localStorage by matching the public key\n * This is useful when we don't yet know the website ID but need to check for existing visitors\n */\nexport function getExistingVisitorId(\n\tpublicKey: string\n): { websiteId: string; visitorId: string } | null {\n\tif (!isLocalStorageAvailable()) {\n\t\treturn null;\n\t}\n\n\ttry {\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn null;\n\t\t}\n\t\t// Find all visitor keys in localStorage\n\t\tconst keys = Object.keys(localStorage).filter((key) =>\n\t\t\tkey.startsWith(STORAGE_KEY_PREFIX)\n\t\t);\n\n\t\t// Check each one to see if we have a valid visitor ID\n\t\tfor (const key of keys) {\n\t\t\tconst data =\n\t\t\t\ttypeof window !== \"undefined\" ? localStorage.getItem(key) : null;\n\t\t\tif (!data) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tconst parsed = JSON.parse(data);\n\t\t\t\t// Validate that the visitor ID is a valid ULID\n\t\t\t\tif (\n\t\t\t\t\tparsed.visitorId &&\n\t\t\t\t\tisValidULID(parsed.visitorId) &&\n\t\t\t\t\tparsed.websiteId\n\t\t\t\t) {\n\t\t\t\t\t// We found a valid visitor ID - return it\n\t\t\t\t\t// Note: In a multi-website scenario, you might want to match by public key\n\t\t\t\t\t// For now, we'll return the first valid one found\n\t\t\t\t\treturn {\n\t\t\t\t\t\twebsiteId: parsed.websiteId,\n\t\t\t\t\t\tvisitorId: parsed.visitorId,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t} catch {}\n\t\t}\n\n\t\treturn null;\n\t} catch {\n\t\treturn null;\n\t}\n}\n"],"mappings":";;;;;;AAMA,MAAM,qBAAqB;;;;AAK3B,SAAS,cAAc,WAA2B;AACjD,QAAO,GAAG,mBAAmB,GAAG;;;;;AAMjC,SAAS,0BAAmC;AAC3C,KAAI;AACH,MAAI,OAAO,WAAW,eAAe,CAAC,OAAO,aAC5C,QAAO;EAER,MAAM,UAAU;AAChB,eAAa,QAAQ,SAAS,OAAO;AACrC,eAAa,WAAW,QAAQ;AAChC,SAAO;SACA;AACP,SAAO;;;;;;AAOT,SAAgB,aAAa,WAAkC;AAC9D,KAAI,CAAC,yBAAyB,CAC7B,QAAO;AAGR,KAAI;AACH,MAAI,OAAO,WAAW,YACrB,QAAO;EAER,MAAM,OAAO,aAAa,QAAQ,cAAc,UAAU,CAAC;AAC3D,MAAI,CAAC,KACJ,QAAO;EAGR,MAAM,SAAS,KAAK,MAAM,KAAK;AAE/B,MAAI,OAAO,aAAa,YAAY,OAAO,UAAU,CACpD,QAAO,OAAO;AAEf,SAAO;SACA;AACP,SAAO;;;;;;AAOT,SAAgB,aAAa,WAAmB,WAAyB;AACxE,KAAI,CAAC,yBAAyB,CAC7B;AAGD,KAAI;EACH,MAAM,OAAO;GACZ;GACA,WAAW,KAAK,KAAK;GACrB;GACA;AACD,MAAI,OAAO,WAAW,YACrB;EAED,MAAM,MAAM,cAAc,UAAU;AACpC,eAAa,QAAQ,KAAK,KAAK,UAAU,KAAK,CAAC;SACxC;;;;;AAQT,SAAgB,eAAe,WAAyB;AACvD,KAAI,CAAC,yBAAyB,CAC7B;AAGD,KAAI;AACH,MAAI,OAAO,WAAW,YACrB;AAED,eAAa,WAAW,cAAc,UAAU,CAAC;SAC1C;;;;;AAQT,SAAgB,qBAA2B;AAC1C,KAAI,CAAC,yBAAyB,CAC7B;AAGD,KAAI;AACH,MAAI,OAAO,WAAW,YACrB;EAED,MAAM,OAAO,OAAO,KAAK,aAAa,CAAC,QAAQ,QAC9C,IAAI,WAAW,mBAAmB,CAClC;AACD,OAAK,MAAM,OAAO,KACjB,cAAa,WAAW,IAAI;SAEtB;;;;;;AAST,SAAgB,qBACf,WACkD;AAClD,KAAI,CAAC,yBAAyB,CAC7B,QAAO;AAGR,KAAI;AACH,MAAI,OAAO,WAAW,YACrB,QAAO;EAGR,MAAM,OAAO,OAAO,KAAK,aAAa,CAAC,QAAQ,QAC9C,IAAI,WAAW,mBAAmB,CAClC;AAGD,OAAK,MAAM,OAAO,MAAM;GACvB,MAAM,OACL,OAAO,WAAW,cAAc,aAAa,QAAQ,IAAI,GAAG;AAC7D,OAAI,CAAC,KACJ;AAGD,OAAI;IACH,MAAM,SAAS,KAAK,MAAM,KAAK;AAE/B,QACC,OAAO,aACP,YAAY,OAAO,UAAU,IAC7B,OAAO,UAKP,QAAO;KACN,WAAW,OAAO;KAClB,WAAW,OAAO;KAClB;WAEK;;AAGT,SAAO;SACA;AACP,SAAO"}
1
+ {"version":3,"file":"visitor-tracker.js","names":[],"sources":["../src/visitor-tracker.ts"],"sourcesContent":["/**\n * Visitor tracking utilities for managing visitor IDs in localStorage\n */\n\nimport { isValidULID } from \"./utils\";\n\nconst STORAGE_KEY_PREFIX = \"cossistant_visitor\";\n\n/**\n * Get the localStorage key for a specific website\n */\nfunction getStorageKey(websiteId: string): string {\n\treturn `${STORAGE_KEY_PREFIX}_${websiteId}`;\n}\n\n/**\n * Check if localStorage is available\n */\nfunction isLocalStorageAvailable(): boolean {\n\ttry {\n\t\tif (typeof window === \"undefined\" || !window.localStorage) {\n\t\t\treturn false;\n\t\t}\n\t\tconst testKey = \"__cossistant_test__\";\n\t\tlocalStorage.setItem(testKey, \"test\");\n\t\tlocalStorage.removeItem(testKey);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/**\n * Get visitor ID from localStorage for a specific website\n */\nexport function getVisitorId(websiteId: string): string | null {\n\tif (!isLocalStorageAvailable()) {\n\t\treturn null;\n\t}\n\n\ttry {\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn null;\n\t\t}\n\t\tconst data = localStorage.getItem(getStorageKey(websiteId));\n\t\tif (!data) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst parsed = JSON.parse(data);\n\t\t// Validate that the visitor ID is a valid ULID (26 characters)\n\t\tif (parsed.visitorId && isValidULID(parsed.visitorId)) {\n\t\t\treturn parsed.visitorId;\n\t\t}\n\t\treturn null;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n/**\n * Set visitor ID in localStorage for a specific website\n */\nexport function setVisitorId(websiteId: string, visitorId: string): void {\n\tif (!isLocalStorageAvailable()) {\n\t\treturn;\n\t}\n\n\ttry {\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn;\n\t\t}\n\t\tconst data = {\n\t\t\tvisitorId,\n\t\t\ttimestamp: Date.now(),\n\t\t\twebsiteId,\n\t\t};\n\t\tconst key = getStorageKey(websiteId);\n\t\tlocalStorage.setItem(key, JSON.stringify(data));\n\t} catch {\n\t\t// Silently fail - visitor tracking is not critical\n\t}\n}\n\n/**\n * Clear visitor ID for a specific website\n */\nexport function clearVisitorId(websiteId: string): void {\n\tif (!isLocalStorageAvailable()) {\n\t\treturn;\n\t}\n\n\ttry {\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn;\n\t\t}\n\t\tlocalStorage.removeItem(getStorageKey(websiteId));\n\t} catch {\n\t\t// Silently fail - visitor tracking is not critical\n\t}\n}\n\n/**\n * Clear all visitor IDs\n */\nexport function clearAllVisitorIds(): void {\n\tif (!isLocalStorageAvailable()) {\n\t\treturn;\n\t}\n\n\ttry {\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn;\n\t\t}\n\t\tconst keys = Object.keys(localStorage).filter((key) =>\n\t\t\tkey.startsWith(STORAGE_KEY_PREFIX)\n\t\t);\n\t\tfor (const key of keys) {\n\t\t\tlocalStorage.removeItem(key);\n\t\t}\n\t} catch {\n\t\t// Silently fail - visitor tracking is not critical\n\t}\n}\n\n/**\n * Get any existing visitor ID from localStorage by matching the public key\n * This is useful when we don't yet know the website ID but need to check for existing visitors\n */\nexport function getExistingVisitorId(\n\tpublicKey: string\n): { websiteId: string; visitorId: string } | null {\n\tif (!isLocalStorageAvailable()) {\n\t\treturn null;\n\t}\n\n\ttry {\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn null;\n\t\t}\n\t\t// Find all visitor keys in localStorage\n\t\tconst keys = Object.keys(localStorage).filter((key) =>\n\t\t\tkey.startsWith(STORAGE_KEY_PREFIX)\n\t\t);\n\n\t\t// Check each one to see if we have a valid visitor ID\n\t\tfor (const key of keys) {\n\t\t\tconst data =\n\t\t\t\ttypeof window !== \"undefined\" ? localStorage.getItem(key) : null;\n\t\t\tif (!data) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tconst parsed = JSON.parse(data);\n\t\t\t\t// Validate that the visitor ID is a valid ULID\n\t\t\t\tif (\n\t\t\t\t\tparsed.visitorId &&\n\t\t\t\t\tisValidULID(parsed.visitorId) &&\n\t\t\t\t\tparsed.websiteId\n\t\t\t\t) {\n\t\t\t\t\t// We found a valid visitor ID - return it\n\t\t\t\t\t// Note: In a multi-website scenario, you might want to match by public key\n\t\t\t\t\t// For now, we'll return the first valid one found\n\t\t\t\t\treturn {\n\t\t\t\t\t\twebsiteId: parsed.websiteId,\n\t\t\t\t\t\tvisitorId: parsed.visitorId,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t} catch {}\n\t\t}\n\n\t\tre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