@wireai/activation 0.13.2 → 0.13.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/AGENTS.md +4 -3
  2. package/CHANGELOG.md +228 -4
  3. package/README.md +16 -2
  4. package/dist/analytics/index.d.mts +4 -4
  5. package/dist/analytics/index.d.ts +4 -4
  6. package/dist/analytics/index.js +104 -470
  7. package/dist/analytics/index.js.map +1 -1
  8. package/dist/analytics/index.mjs +102 -468
  9. package/dist/analytics/index.mjs.map +1 -1
  10. package/dist/coachmarks/index.d.mts +14 -1
  11. package/dist/coachmarks/index.d.ts +14 -1
  12. package/dist/coachmarks/index.js +58 -14
  13. package/dist/coachmarks/index.js.map +1 -1
  14. package/dist/coachmarks/index.mjs +58 -14
  15. package/dist/coachmarks/index.mjs.map +1 -1
  16. package/dist/{currentSession-ClkLjcJ0.d.mts → currentSession-BoWtr3Jp.d.mts} +2 -2
  17. package/dist/{currentSession-DOVZEWJl.d.ts → currentSession-CCOMlaQ2.d.ts} +2 -2
  18. package/dist/{decision-Bl_M2y3r.d.mts → decision-Cjw0jbEj.d.mts} +1 -1
  19. package/dist/{decision-Cau5KmP6.d.ts → decision-GfpXAsk_.d.ts} +1 -1
  20. package/dist/index.d.mts +25 -2
  21. package/dist/index.d.ts +25 -2
  22. package/dist/index.js +220 -573
  23. package/dist/index.js.map +1 -1
  24. package/dist/index.mjs +217 -570
  25. package/dist/index.mjs.map +1 -1
  26. package/dist/questionnaire/index.d.mts +42 -10
  27. package/dist/questionnaire/index.d.ts +42 -10
  28. package/dist/questionnaire/index.js +45 -13
  29. package/dist/questionnaire/index.js.map +1 -1
  30. package/dist/questionnaire/index.mjs +45 -13
  31. package/dist/questionnaire/index.mjs.map +1 -1
  32. package/dist/reviews/index.d.mts +4 -4
  33. package/dist/reviews/index.d.ts +4 -4
  34. package/dist/reviews/index.js +27 -7
  35. package/dist/reviews/index.js.map +1 -1
  36. package/dist/reviews/index.mjs +27 -7
  37. package/dist/reviews/index.mjs.map +1 -1
  38. package/dist/showcase/index.js +7 -2
  39. package/dist/showcase/index.js.map +1 -1
  40. package/dist/showcase/index.mjs +7 -2
  41. package/dist/showcase/index.mjs.map +1 -1
  42. package/dist/{transport-DsRe4epC.d.ts → transport-CefdERPs.d.mts} +44 -5
  43. package/dist/{transport-CF_eHwzC.d.mts → transport-DFuPyCoJ.d.ts} +44 -5
  44. package/dist/{types-Buj9Lw9t.d.ts → types-UVYt9BJe.d.ts} +41 -1
  45. package/dist/{types-CNUqMK0D.d.mts → types-l2tfg23P.d.mts} +41 -1
  46. package/package.json +4 -1
  47. package/src/OnboardingFlow.tsx +44 -15
  48. package/src/WireOnboarding.tsx +7 -6
  49. package/src/activation/wireActivation.ts +3 -3
  50. package/src/analytics/analyticsFacade.ts +2 -2
  51. package/src/analytics/eventQueue.ts +83 -20
  52. package/src/cards/CardGridSelectCard.tsx +1 -1
  53. package/src/cards/ChipSelectCard.tsx +2 -2
  54. package/src/cards/SelectionCard.tsx +1 -1
  55. package/src/coachmarks/runtime.ts +62 -2
  56. package/src/coachmarks/useCoachmarkTour.ts +62 -14
  57. package/src/context/deviceId.ts +4 -4
  58. package/src/features/WireFeaturesProvider.tsx +4 -1
  59. package/src/identity/userIdentity.ts +1 -1
  60. package/src/questionnaire/QuestionnaireGate.tsx +90 -10
  61. package/src/questionnaire/index.ts +9 -1
  62. package/src/questionnaire/transport.ts +46 -11
  63. package/src/reviews/ReviewGate.tsx +61 -6
  64. package/src/reviews/index.ts +10 -1
  65. package/src/reviews/transport.ts +58 -12
  66. package/src/session-analytics/useLifecycleEvents.ts +1 -1
  67. package/src/theme/ThemeContext.tsx +42 -1
  68. package/src/types.ts +1 -1
  69. package/src/utils/submitResult.ts +39 -0
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var reactNative = require('react-native');
4
3
  var React19 = require('react');
5
4
  var wireaiRn = require('wireai-rn');
6
5
  var jsxRuntime = require('react/jsx-runtime');
6
+ var reactNative = require('react-native');
7
7
  var reactNativeSafeAreaContext = require('react-native-safe-area-context');
8
8
  var zod = require('zod');
9
9
 
@@ -12,401 +12,16 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
12
12
  var React19__default = /*#__PURE__*/_interopDefault(React19);
13
13
 
14
14
  var __defProp = Object.defineProperty;
15
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
16
- var __getOwnPropNames = Object.getOwnPropertyNames;
17
- var __hasOwnProp = Object.prototype.hasOwnProperty;
18
15
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
19
16
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
20
17
  }) : x)(function(x) {
21
18
  if (typeof require !== "undefined") return require.apply(this, arguments);
22
19
  throw Error('Dynamic require of "' + x + '" is not supported');
23
20
  });
24
- var __esm = (fn, res) => function __init() {
25
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
26
- };
27
21
  var __export = (target, all) => {
28
- for (var name2 in all)
29
- __defProp(target, name2, { get: all[name2], enumerable: true });
30
- };
31
- var __copyProps = (to, from, except, desc) => {
32
- if (from && typeof from === "object" || typeof from === "function") {
33
- for (let key of __getOwnPropNames(from))
34
- if (!__hasOwnProp.call(to, key) && key !== except)
35
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
36
- }
37
- return to;
22
+ for (var name in all)
23
+ __defProp(target, name, { get: all[name], enumerable: true });
38
24
  };
39
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
40
-
41
- // node_modules/expo-modules-core/src/errors/CodedError.ts
42
- var CodedError;
43
- var init_CodedError = __esm({
44
- "node_modules/expo-modules-core/src/errors/CodedError.ts"() {
45
- CodedError = class extends Error {
46
- constructor(code, message) {
47
- super(message);
48
- this.code = code;
49
- }
50
- };
51
- }
52
- });
53
-
54
- // node_modules/expo-modules-core/src/NativeModulesProxy.ts
55
- var NativeModulesProxy_default;
56
- var init_NativeModulesProxy = __esm({
57
- "node_modules/expo-modules-core/src/NativeModulesProxy.ts"() {
58
- NativeModulesProxy_default = {};
59
- }
60
- });
61
-
62
- // node_modules/expo-modules-core/src/TurboModuleToExpoModuleProxy.ts
63
- function createTurboModuleToExpoProxy(turboModule, name2) {
64
- return null;
65
- }
66
- var init_TurboModuleToExpoModuleProxy = __esm({
67
- "node_modules/expo-modules-core/src/TurboModuleToExpoModuleProxy.ts"() {
68
- }
69
- });
70
- var init_ensureNativeModulesAreInstalled = __esm({
71
- "node_modules/expo-modules-core/src/ensureNativeModulesAreInstalled.ts"() {
72
- }
73
- });
74
- function requireOptionalNativeModule(moduleName) {
75
- var _a2, _b, _c, _d, _e;
76
- try {
77
- return (_e = (_d = (_c = (_b = (_a2 = globalThis.expo) == null ? void 0 : _a2.modules) == null ? void 0 : _b[moduleName]) != null ? _c : NativeModulesProxy_default[moduleName]) != null ? _d : createTurboModuleToExpoProxy(reactNative.TurboModuleRegistry.get(moduleName), moduleName)) != null ? _e : null;
78
- } catch (e) {
79
- const error = e;
80
- console.warn(`An error occurred while requiring the '${moduleName}' module: ${error.message}`);
81
- return null;
82
- }
83
- }
84
- var init_requireNativeModule = __esm({
85
- "node_modules/expo-modules-core/src/requireNativeModule.ts"() {
86
- init_NativeModulesProxy();
87
- init_TurboModuleToExpoModuleProxy();
88
- init_ensureNativeModulesAreInstalled();
89
- }
90
- });
91
-
92
- // node_modules/expo-modules-core/src/sweet/setUpJsLogger.fx.ts
93
- var init_setUpJsLogger_fx = __esm({
94
- "node_modules/expo-modules-core/src/sweet/setUpJsLogger.fx.ts"() {
95
- init_CodedError();
96
- init_requireNativeModule();
97
- if (__DEV__ && typeof window !== "undefined" && (process.env.EXPO_OS === "android" || process.env.EXPO_OS === "ios")) {
98
- const NativeJSLogger = requireOptionalNativeModule("ExpoModulesCoreJSLogger");
99
- if (NativeJSLogger) {
100
- const onNewException = {
101
- eventName: "ExpoModulesCoreJSLogger.onNewError",
102
- action: console.error
103
- };
104
- const onNewWarning = {
105
- eventName: "ExpoModulesCoreJSLogger.onNewWarning",
106
- action: console.warn
107
- };
108
- const onNewDebug = {
109
- eventName: "ExpoModulesCoreJSLogger.onNewDebug",
110
- action: console.debug
111
- };
112
- const onNewInfo = {
113
- eventName: "ExpoModulesCoreJSLogger.onNewInfo",
114
- action: console.info
115
- };
116
- const onNewTrace = {
117
- eventName: "ExpoModulesCoreJSLogger.onNewTrace",
118
- action: console.trace
119
- };
120
- const listeners = [
121
- onNewException,
122
- onNewWarning,
123
- onNewDebug,
124
- onNewInfo,
125
- onNewTrace
126
- ];
127
- for (const listener of listeners) {
128
- NativeJSLogger.addListener(listener.eventName, ({ message }) => {
129
- listener.action(message);
130
- });
131
- }
132
- }
133
- }
134
- globalThis.ExpoModulesCore_CodedError = CodedError;
135
- }
136
- });
137
-
138
- // node_modules/expo-modules-core/src/registerWebModule.ts
139
- var init_registerWebModule = __esm({
140
- "node_modules/expo-modules-core/src/registerWebModule.ts"() {
141
- }
142
- });
143
-
144
- // node_modules/expo-modules-core/src/TypedArrays.types.ts
145
- var init_TypedArrays_types = __esm({
146
- "node_modules/expo-modules-core/src/TypedArrays.types.ts"() {
147
- }
148
- });
149
-
150
- // node_modules/expo-modules-core/src/PermissionsInterface.ts
151
- var init_PermissionsInterface = __esm({
152
- "node_modules/expo-modules-core/src/PermissionsInterface.ts"() {
153
- }
154
- });
155
- var init_PermissionsHook = __esm({
156
- "node_modules/expo-modules-core/src/PermissionsHook.ts"() {
157
- "use client";
158
- }
159
- });
160
- var init_Refs = __esm({
161
- "node_modules/expo-modules-core/src/Refs.ts"() {
162
- }
163
- });
164
- var init_useReleasingSharedObject = __esm({
165
- "node_modules/expo-modules-core/src/hooks/useReleasingSharedObject.ts"() {
166
- "use client";
167
- }
168
- });
169
-
170
- // node_modules/expo-modules-core/src/reload.ts
171
- var init_reload = __esm({
172
- "node_modules/expo-modules-core/src/reload.ts"() {
173
- }
174
- });
175
-
176
- // node_modules/expo-modules-core/src/index.ts
177
- var init_src = __esm({
178
- "node_modules/expo-modules-core/src/index.ts"() {
179
- init_setUpJsLogger_fx();
180
- init_requireNativeModule();
181
- init_registerWebModule();
182
- init_TypedArrays_types();
183
- init_PermissionsInterface();
184
- init_PermissionsHook();
185
- init_Refs();
186
- init_useReleasingSharedObject();
187
- init_reload();
188
- init_CodedError();
189
- }
190
- });
191
-
192
- // node_modules/expo-constants/build/Constants.types.js
193
- var AppOwnership, ExecutionEnvironment, UserInterfaceIdiom;
194
- var init_Constants_types = __esm({
195
- "node_modules/expo-constants/build/Constants.types.js"() {
196
- (function(AppOwnership2) {
197
- AppOwnership2["Expo"] = "expo";
198
- })(AppOwnership || (AppOwnership = {}));
199
- (function(ExecutionEnvironment2) {
200
- ExecutionEnvironment2["Bare"] = "bare";
201
- ExecutionEnvironment2["Standalone"] = "standalone";
202
- ExecutionEnvironment2["StoreClient"] = "storeClient";
203
- })(ExecutionEnvironment || (ExecutionEnvironment = {}));
204
- (function(UserInterfaceIdiom2) {
205
- UserInterfaceIdiom2["Handset"] = "handset";
206
- UserInterfaceIdiom2["Tablet"] = "tablet";
207
- UserInterfaceIdiom2["Desktop"] = "desktop";
208
- UserInterfaceIdiom2["TV"] = "tv";
209
- UserInterfaceIdiom2["Unsupported"] = "unsupported";
210
- })(UserInterfaceIdiom || (UserInterfaceIdiom = {}));
211
- }
212
- });
213
-
214
- // node_modules/expo-constants/build/ExponentConstants.js
215
- var ExponentConstants_default;
216
- var init_ExponentConstants = __esm({
217
- "node_modules/expo-constants/build/ExponentConstants.js"() {
218
- init_src();
219
- ExponentConstants_default = requireOptionalNativeModule("ExponentConstants");
220
- }
221
- });
222
-
223
- // node_modules/expo-constants/build/Constants.js
224
- var Constants_exports = {};
225
- __export(Constants_exports, {
226
- AppOwnership: () => AppOwnership,
227
- ExecutionEnvironment: () => ExecutionEnvironment,
228
- UserInterfaceIdiom: () => UserInterfaceIdiom,
229
- default: () => Constants_default
230
- });
231
- function isEmbeddedManifest(manifest) {
232
- return !isExpoUpdatesManifest(manifest);
233
- }
234
- function isExpoUpdatesManifest(manifest) {
235
- return "metadata" in manifest;
236
- }
237
- function getManifest(suppressWarning = false) {
238
- if (!rawManifest) {
239
- const invalidManifestType = rawManifest === null ? "null" : "undefined";
240
- if (nativeConstants.executionEnvironment === ExecutionEnvironment.Bare && reactNative.Platform.OS !== "web") {
241
- if (!suppressWarning) {
242
- console.warn(`Constants.manifest is ${invalidManifestType} because the embedded app.config could not be read. Ensure that you have installed the expo-constants build scripts if you need to read from Constants.manifest.`);
243
- }
244
- } else if (nativeConstants.executionEnvironment === ExecutionEnvironment.StoreClient || nativeConstants.executionEnvironment === ExecutionEnvironment.Standalone) {
245
- throw new CodedError("ERR_CONSTANTS_MANIFEST_UNAVAILABLE", `Constants.manifest is ${invalidManifestType}, must be an object.`);
246
- }
247
- }
248
- return rawManifest;
249
- }
250
- var ExpoUpdates, rawUpdatesManifest, rawDevLauncherManifest, rawAppConfig, _a, rawManifest, name, appOwnership, nativeConstants, constants, Constants_default;
251
- var init_Constants = __esm({
252
- "node_modules/expo-constants/build/Constants.js"() {
253
- init_src();
254
- init_Constants_types();
255
- init_ExponentConstants();
256
- init_Constants_types();
257
- if (!ExponentConstants_default) {
258
- console.warn("No native ExponentConstants module found, are you sure the expo-constants's module is linked properly?");
259
- }
260
- ExpoUpdates = requireOptionalNativeModule("ExpoUpdates");
261
- rawUpdatesManifest = null;
262
- if (ExpoUpdates) {
263
- let updatesManifest;
264
- if (ExpoUpdates.manifest) {
265
- updatesManifest = ExpoUpdates.manifest;
266
- } else if (ExpoUpdates.manifestString) {
267
- updatesManifest = JSON.parse(ExpoUpdates.manifestString);
268
- }
269
- if (updatesManifest && Object.keys(updatesManifest).length > 0) {
270
- rawUpdatesManifest = updatesManifest;
271
- }
272
- }
273
- rawDevLauncherManifest = null;
274
- if (reactNative.NativeModules.EXDevLauncher) {
275
- let devLauncherManifest;
276
- if (reactNative.NativeModules.EXDevLauncher.manifestString) {
277
- devLauncherManifest = JSON.parse(reactNative.NativeModules.EXDevLauncher.manifestString);
278
- }
279
- if (devLauncherManifest && Object.keys(devLauncherManifest).length > 0) {
280
- rawDevLauncherManifest = devLauncherManifest;
281
- }
282
- }
283
- rawAppConfig = null;
284
- if (ExponentConstants_default && ExponentConstants_default.manifest) {
285
- const appConfig = ExponentConstants_default.manifest;
286
- if (typeof appConfig === "string") {
287
- rawAppConfig = JSON.parse(appConfig);
288
- } else {
289
- rawAppConfig = appConfig;
290
- }
291
- }
292
- rawManifest = (_a = rawUpdatesManifest != null ? rawUpdatesManifest : rawDevLauncherManifest) != null ? _a : rawAppConfig;
293
- ({ name, appOwnership, ...nativeConstants } = ExponentConstants_default || {});
294
- constants = {
295
- ...nativeConstants,
296
- // Ensure this is null in bare workflow
297
- appOwnership: appOwnership != null ? appOwnership : null
298
- };
299
- Object.defineProperties(constants, {
300
- /**
301
- * Use `manifest` property by default.
302
- * This property is only used for internal purposes.
303
- * It behaves similarly to the original one, but suppresses warning upon no manifest available.
304
- * `expo-asset` uses it to prevent users from seeing mentioned warning.
305
- */
306
- __unsafeNoWarnManifest: {
307
- get() {
308
- const maybeManifest = getManifest(true);
309
- if (!maybeManifest || !isEmbeddedManifest(maybeManifest)) {
310
- return null;
311
- }
312
- return maybeManifest;
313
- },
314
- enumerable: false
315
- },
316
- __unsafeNoWarnManifest2: {
317
- get() {
318
- const maybeManifest = getManifest(true);
319
- if (!maybeManifest || !isExpoUpdatesManifest(maybeManifest)) {
320
- return null;
321
- }
322
- return maybeManifest;
323
- },
324
- enumerable: false
325
- },
326
- manifest: {
327
- get() {
328
- const maybeManifest = getManifest();
329
- if (!maybeManifest || !isEmbeddedManifest(maybeManifest)) {
330
- return null;
331
- }
332
- return maybeManifest;
333
- },
334
- enumerable: true
335
- },
336
- manifest2: {
337
- get() {
338
- const maybeManifest = getManifest();
339
- if (!maybeManifest || !isExpoUpdatesManifest(maybeManifest)) {
340
- return null;
341
- }
342
- return maybeManifest;
343
- },
344
- enumerable: true
345
- },
346
- expoConfig: {
347
- get() {
348
- var _a2, _b;
349
- const maybeManifest = getManifest(true);
350
- if (!maybeManifest) {
351
- return null;
352
- }
353
- if (ExpoUpdates && ExpoUpdates.isEmbeddedLaunch) {
354
- return rawAppConfig;
355
- }
356
- if (isExpoUpdatesManifest(maybeManifest)) {
357
- return (_b = (_a2 = maybeManifest.extra) == null ? void 0 : _a2.expoClient) != null ? _b : null;
358
- } else if (isEmbeddedManifest(maybeManifest)) {
359
- return maybeManifest;
360
- }
361
- return null;
362
- },
363
- enumerable: true
364
- },
365
- expoGoConfig: {
366
- get() {
367
- var _a2, _b;
368
- const maybeManifest = getManifest(true);
369
- if (!maybeManifest) {
370
- return null;
371
- }
372
- if (isExpoUpdatesManifest(maybeManifest)) {
373
- return (_b = (_a2 = maybeManifest.extra) == null ? void 0 : _a2.expoGo) != null ? _b : null;
374
- } else if (isEmbeddedManifest(maybeManifest)) {
375
- return maybeManifest;
376
- }
377
- return null;
378
- },
379
- enumerable: true
380
- },
381
- easConfig: {
382
- get() {
383
- var _a2, _b;
384
- const maybeManifest = getManifest(true);
385
- if (!maybeManifest) {
386
- return null;
387
- }
388
- if (isExpoUpdatesManifest(maybeManifest)) {
389
- return (_b = (_a2 = maybeManifest.extra) == null ? void 0 : _a2.eas) != null ? _b : null;
390
- } else if (isEmbeddedManifest(maybeManifest)) {
391
- return maybeManifest;
392
- }
393
- return null;
394
- },
395
- enumerable: true
396
- },
397
- __rawManifest_TEST: {
398
- get() {
399
- return rawManifest;
400
- },
401
- set(value) {
402
- rawManifest = value;
403
- },
404
- enumerable: false
405
- }
406
- });
407
- Constants_default = constants;
408
- }
409
- });
410
25
 
411
26
  // src/theme/defaultTheme.ts
412
27
  var defaultOnboardingTheme = {
@@ -464,7 +79,12 @@ var mergeTheme = (override) => {
464
79
  button: { ...defaultOnboardingTheme.button, ...override.button }
465
80
  };
466
81
  };
467
- var OnboardingThemeContext = React19.createContext(null);
82
+ var THEME_CONTEXT_SLOT = /* @__PURE__ */ Symbol.for("@wireai/activation:themeContext");
83
+ var themeGlobal = globalThis;
84
+ if (!themeGlobal[THEME_CONTEXT_SLOT]) {
85
+ themeGlobal[THEME_CONTEXT_SLOT] = React19.createContext(null);
86
+ }
87
+ var OnboardingThemeContext = themeGlobal[THEME_CONTEXT_SLOT];
468
88
  var OnboardingThemeProvider = ({
469
89
  theme,
470
90
  children
@@ -485,10 +105,10 @@ var IllustrationProvider = ({
485
105
  const value = React19.useMemo(() => registry != null ? registry : EMPTY_REGISTRY, [registry]);
486
106
  return /* @__PURE__ */ jsxRuntime.jsx(IllustrationContext.Provider, { value, children });
487
107
  };
488
- var useIllustration = (name2) => {
108
+ var useIllustration = (name) => {
489
109
  const registry = React19.useContext(IllustrationContext);
490
- if (!name2) return void 0;
491
- return registry[name2];
110
+ if (!name) return void 0;
111
+ return registry[name];
492
112
  };
493
113
  var Disc = ({ children }) => {
494
114
  const t = useOnboardingTheme();
@@ -587,11 +207,11 @@ var IconRegistryProvider = ({
587
207
  const value = React19.useMemo(() => registry != null ? registry : EMPTY_REGISTRY2, [registry]);
588
208
  return /* @__PURE__ */ jsxRuntime.jsx(IconContext.Provider, { value, children });
589
209
  };
590
- var useHostIcon = (name2) => {
210
+ var useHostIcon = (name) => {
591
211
  const registry = React19.useContext(IconContext);
592
- if (!name2) return void 0;
593
- if (!Object.prototype.hasOwnProperty.call(registry, name2)) return void 0;
594
- return registry[name2];
212
+ if (!name) return void 0;
213
+ if (!Object.prototype.hasOwnProperty.call(registry, name)) return void 0;
214
+ return registry[name];
595
215
  };
596
216
 
597
217
  // src/theme/typography.ts
@@ -607,9 +227,9 @@ var captionStyle = (f) => ({
607
227
  lineHeight: round(f.baseSize * 0.8125 * f.scale * 1.5)
608
228
  });
609
229
  var labelStyle = (f) => {
610
- var _a2;
230
+ var _a;
611
231
  return {
612
- fontFamily: (_a2 = f.medium) != null ? _a2 : f.bold,
232
+ fontFamily: (_a = f.medium) != null ? _a : f.bold,
613
233
  fontSize: round(f.baseSize * f.scale),
614
234
  lineHeight: round(f.baseSize * f.scale * 1.4),
615
235
  fontWeight: f.medium ? void 0 : "600"
@@ -622,9 +242,9 @@ var headingStyle = (f) => ({
622
242
  fontWeight: f.bold ? void 0 : "700"
623
243
  });
624
244
  var buttonLabelStyle = (f) => {
625
- var _a2;
245
+ var _a;
626
246
  return {
627
- fontFamily: (_a2 = f.bold) != null ? _a2 : f.medium,
247
+ fontFamily: (_a = f.bold) != null ? _a : f.medium,
628
248
  fontSize: round(f.baseSize * f.scale),
629
249
  fontWeight: f.bold ? void 0 : "600"
630
250
  };
@@ -1373,7 +993,7 @@ var _CardHandoff = ({
1373
993
  const running = React19.useRef({});
1374
994
  const mounted = React19.useRef(false);
1375
995
  React19.useEffect(() => {
1376
- var _a2, _b;
996
+ var _a, _b;
1377
997
  const last = prev.current;
1378
998
  prev.current = { key: transitionKey, node: children, variant };
1379
999
  if (!mounted.current) {
@@ -1382,7 +1002,7 @@ var _CardHandoff = ({
1382
1002
  return;
1383
1003
  }
1384
1004
  if (last.key === transitionKey) return;
1385
- (_a2 = running.current.enter) == null ? void 0 : _a2.stop();
1005
+ (_a = running.current.enter) == null ? void 0 : _a.stop();
1386
1006
  (_b = running.current.exit) == null ? void 0 : _b.stop();
1387
1007
  setLeaving(last);
1388
1008
  enterT.setValue(0);
@@ -1407,8 +1027,8 @@ var _CardHandoff = ({
1407
1027
  });
1408
1028
  React19.useEffect(
1409
1029
  () => () => {
1410
- var _a2, _b;
1411
- (_a2 = running.current.enter) == null ? void 0 : _a2.stop();
1030
+ var _a, _b;
1031
+ (_a = running.current.enter) == null ? void 0 : _a.stop();
1412
1032
  (_b = running.current.exit) == null ? void 0 : _b.stop();
1413
1033
  },
1414
1034
  []
@@ -1489,13 +1109,13 @@ var tryParse = (s) => {
1489
1109
  }
1490
1110
  };
1491
1111
  var deriveAnswers = (messages) => {
1492
- var _a2, _b, _c;
1112
+ var _a, _b, _c;
1493
1113
  const out = {};
1494
1114
  for (let i = 0; i < messages.length; i++) {
1495
1115
  const m = messages[i];
1496
1116
  const r = m == null ? void 0 : m.response;
1497
1117
  if (!m || m.role !== "assistant" || !r || r.action !== "render") continue;
1498
- const props = (_a2 = r.props) != null ? _a2 : {};
1118
+ const props = (_a = r.props) != null ? _a : {};
1499
1119
  const progress = props.progress;
1500
1120
  const questionText = (_c = (_b = props.title) != null ? _b : props.label) != null ? _c : props.question;
1501
1121
  const key = (progress == null ? void 0 : progress.slot_id) || (progress == null ? void 0 : progress.key) || questionText;
@@ -1509,9 +1129,9 @@ var deriveAnswers = (messages) => {
1509
1129
 
1510
1130
  // src/utils/readProgress.ts
1511
1131
  var readProgress = (response) => {
1512
- var _a2;
1132
+ var _a;
1513
1133
  if (!response || response.action !== "render") return {};
1514
- const props = (_a2 = response.props) != null ? _a2 : {};
1134
+ const props = (_a = response.props) != null ? _a : {};
1515
1135
  const raw = props.progress;
1516
1136
  if (!raw || typeof raw !== "object") return {};
1517
1137
  const p = raw;
@@ -1752,10 +1372,10 @@ var _PermissionCard = ({
1752
1372
  getStatusRef.current = getStatus;
1753
1373
  const shownRef = React19.useRef(false);
1754
1374
  React19.useEffect(() => {
1755
- var _a2;
1375
+ var _a;
1756
1376
  if (shownRef.current) return;
1757
1377
  shownRef.current = true;
1758
- (_a2 = onStageRef.current) == null ? void 0 : _a2.call(onStageRef, "shown");
1378
+ (_a = onStageRef.current) == null ? void 0 : _a.call(onStageRef, "shown");
1759
1379
  }, []);
1760
1380
  React19.useEffect(() => {
1761
1381
  const probe = getStatusRef.current;
@@ -1781,18 +1401,18 @@ var _PermissionCard = ({
1781
1401
  );
1782
1402
  }, [permission]);
1783
1403
  const settle = React19.useCallback((outcome) => {
1784
- var _a2;
1404
+ var _a;
1785
1405
  if (settledRef.current) return;
1786
1406
  settledRef.current = true;
1787
1407
  clearWatchdog();
1788
- (_a2 = onSettledRef.current) == null ? void 0 : _a2.call(onSettledRef, outcome);
1408
+ (_a = onSettledRef.current) == null ? void 0 : _a.call(onSettledRef, outcome);
1789
1409
  }, [clearWatchdog]);
1790
1410
  const primaryAction = status === "blocked" ? "settings" : status === "granted" || !request ? "continue" : "ask";
1791
1411
  const handlePrimary = React19.useCallback(() => {
1792
- var _a2, _b, _c, _d;
1412
+ var _a, _b, _c, _d;
1793
1413
  if (settledRef.current || busy) return;
1794
1414
  if (primaryAction === "settings") {
1795
- (_a2 = onStageRef.current) == null ? void 0 : _a2.call(onStageRef, "settings", "blocked");
1415
+ (_a = onStageRef.current) == null ? void 0 : _a.call(onStageRef, "settings", "blocked");
1796
1416
  try {
1797
1417
  void Promise.resolve(openSettings == null ? void 0 : openSettings()).catch(() => {
1798
1418
  });
@@ -1817,7 +1437,7 @@ var _PermissionCard = ({
1817
1437
  }
1818
1438
  setBusy(true);
1819
1439
  const finish = (value) => {
1820
- var _a3, _b2;
1440
+ var _a2, _b2;
1821
1441
  if (settledRef.current) return;
1822
1442
  clearWatchdog();
1823
1443
  const resolved = normalizePermissionStatus(value);
@@ -1825,7 +1445,7 @@ var _PermissionCard = ({
1825
1445
  setStatus(resolved);
1826
1446
  if (resolved === "granted") {
1827
1447
  playHaptic("success");
1828
- (_a3 = onStageRef.current) == null ? void 0 : _a3.call(onStageRef, "granted", "granted");
1448
+ (_a2 = onStageRef.current) == null ? void 0 : _a2.call(onStageRef, "granted", "granted");
1829
1449
  } else {
1830
1450
  (_b2 = onStageRef.current) == null ? void 0 : _b2.call(onStageRef, "denied", resolved);
1831
1451
  }
@@ -1847,9 +1467,9 @@ var _PermissionCard = ({
1847
1467
  }
1848
1468
  }, [busy, primaryAction, status, request, openSettings, settle, clearWatchdog, permission]);
1849
1469
  const handleSecondary = React19.useCallback(() => {
1850
- var _a2;
1470
+ var _a;
1851
1471
  if (settledRef.current || busy) return;
1852
- (_a2 = onStageRef.current) == null ? void 0 : _a2.call(onStageRef, "skipped");
1472
+ (_a = onStageRef.current) == null ? void 0 : _a.call(onStageRef, "skipped");
1853
1473
  settle("skipped");
1854
1474
  }, [busy, settle]);
1855
1475
  const popT = React19.useRef(new reactNative.Animated.Value(reduced ? 1 : 0)).current;
@@ -1955,18 +1575,18 @@ var isPermissionDue = (placement, position) => {
1955
1575
  return position.cardIndex >= target || position.isTerminal;
1956
1576
  };
1957
1577
  var permissionScreenId = (screen, index) => {
1958
- var _a2;
1959
- return (_a2 = screen.id) != null ? _a2 : `${screen.permission}:${index}`;
1578
+ var _a;
1579
+ return (_a = screen.id) != null ? _a : `${screen.permission}:${index}`;
1960
1580
  };
1961
1581
  var selectDuePermissionScreen = (screens, settled, position) => {
1962
- var _a2;
1582
+ var _a;
1963
1583
  if (!screens || screens.length === 0) return void 0;
1964
1584
  for (let index = 0; index < screens.length; index++) {
1965
1585
  const screen = screens[index];
1966
1586
  if (!screen) continue;
1967
1587
  const id = permissionScreenId(screen, index);
1968
1588
  if (settled.includes(id)) continue;
1969
- if (isPermissionDue((_a2 = screen.placement) != null ? _a2 : DEFAULT_PERMISSION_PLACEMENT, position)) {
1589
+ if (isPermissionDue((_a = screen.placement) != null ? _a : DEFAULT_PERMISSION_PLACEMENT, position)) {
1970
1590
  return { screen, id };
1971
1591
  }
1972
1592
  }
@@ -1998,8 +1618,8 @@ var DEFAULT_PERMISSION_COPY = {
1998
1618
  notifications: NOTIFICATIONS_PERMISSION_COPY
1999
1619
  };
2000
1620
  var resolvePermissionCopy = (permission, overrides) => {
2001
- var _a2;
2002
- const base = (_a2 = DEFAULT_PERMISSION_COPY[permission]) != null ? _a2 : GENERIC_PERMISSION_COPY;
1621
+ var _a;
1622
+ const base = (_a = DEFAULT_PERMISSION_COPY[permission]) != null ? _a : GENERIC_PERMISSION_COPY;
2003
1623
  if (!overrides) return base;
2004
1624
  const merged = { ...base };
2005
1625
  for (const key of Object.keys(overrides)) {
@@ -2042,7 +1662,7 @@ var OnboardingFlow = ({
2042
1662
  permissionsPending = false,
2043
1663
  onPermissionSettled
2044
1664
  }) => {
2045
- var _a2, _b, _c, _d, _e, _f;
1665
+ var _a, _b, _c, _d, _e, _f;
2046
1666
  const { messages, error, isLoading, sendMessage, reset } = wireaiRn.useWireAIThread();
2047
1667
  const makeActions = wireaiRn.useWireAIAction(sendMessage);
2048
1668
  const c = React19.useMemo(() => ({ ...DEFAULT_COPY, ...copy }), [copy]);
@@ -2062,7 +1682,8 @@ var OnboardingFlow = ({
2062
1682
  clientContextRef.current = clientContext;
2063
1683
  const lastScreenIndexRef = React19.useRef(-1);
2064
1684
  const previewTimer = React19.useRef(null);
2065
- const started = React19.useRef(false);
1685
+ const [runId, setRunId] = React19.useState(0);
1686
+ const startedRunRef = React19.useRef(-1);
2066
1687
  const finished = React19.useRef(false);
2067
1688
  const errored = React19.useRef(false);
2068
1689
  const attempts = React19.useRef(0);
@@ -2076,39 +1697,41 @@ var OnboardingFlow = ({
2076
1697
  onPermissionSettledRef.current = onPermissionSettled;
2077
1698
  const lastCard = React19.useMemo(
2078
1699
  () => [...messages].reverse().find((m) => {
2079
- var _a3;
2080
- return m.role === "assistant" && ((_a3 = m.response) == null ? void 0 : _a3.action) === "render";
1700
+ var _a2;
1701
+ return m.role === "assistant" && ((_a2 = m.response) == null ? void 0 : _a2.action) === "render";
2081
1702
  }),
2082
1703
  [messages]
2083
1704
  );
2084
1705
  const renderedCount = React19.useMemo(
2085
1706
  () => messages.filter((m) => {
2086
- var _a3;
2087
- return m.role === "assistant" && ((_a3 = m.response) == null ? void 0 : _a3.action) === "render";
1707
+ var _a2;
1708
+ return m.role === "assistant" && ((_a2 = m.response) == null ? void 0 : _a2.action) === "render";
2088
1709
  }).length,
2089
1710
  [messages]
2090
1711
  );
2091
1712
  const progress = React19.useMemo(() => readProgress(lastCard == null ? void 0 : lastCard.response), [lastCard]);
2092
1713
  React19.useEffect(() => {
2093
- var _a3;
2094
- if (started.current) return;
2095
- started.current = true;
2096
- sendMessage(resumed ? SKIP_ONE_SENTINEL : startMessage);
2097
- (_a3 = onEventRef.current) == null ? void 0 : _a3.call(
1714
+ var _a2;
1715
+ if (startedRunRef.current === runId) return;
1716
+ const isFirstRun = startedRunRef.current < 0;
1717
+ startedRunRef.current = runId;
1718
+ sendMessage(isFirstRun && !resumed ? startMessage : SKIP_ONE_SENTINEL);
1719
+ if (!isFirstRun) return;
1720
+ (_a2 = onEventRef.current) == null ? void 0 : _a2.call(
2098
1721
  onEventRef,
2099
1722
  resumed ? { type: "resumed", contextId: sessionId } : { type: "started", contextId: sessionId }
2100
1723
  );
2101
- }, [sendMessage, startMessage, resumed, sessionId]);
1724
+ }, [sendMessage, startMessage, resumed, sessionId, runId]);
2102
1725
  React19.useEffect(() => {
2103
1726
  if (lastCard) return;
2104
1727
  const timer = setTimeout(() => setTimedOut(true), startTimeoutMs);
2105
1728
  return () => clearTimeout(timer);
2106
- }, [lastCard, startTimeoutMs]);
1729
+ }, [lastCard, startTimeoutMs, runId]);
2107
1730
  React19.useEffect(() => {
2108
- var _a3, _b2, _c2, _d2;
1731
+ var _a2, _b2, _c2, _d2;
2109
1732
  setValidationError(void 0);
2110
1733
  if (!(lastCard == null ? void 0 : lastCard.id)) return;
2111
- const step2 = (_a3 = progress.step) != null ? _a3 : renderedCount;
1734
+ const step2 = (_a2 = progress.step) != null ? _a2 : renderedCount;
2112
1735
  lastScreenIndexRef.current = Math.max(0, step2 - 1);
2113
1736
  (_c2 = onEventRef.current) == null ? void 0 : _c2.call(onEventRef, {
2114
1737
  type: "turn",
@@ -2124,13 +1747,13 @@ var OnboardingFlow = ({
2124
1747
  }, [lastCard == null ? void 0 : lastCard.id]);
2125
1748
  React19.useEffect(() => {
2126
1749
  return () => {
2127
- var _a3, _b2, _c2;
1750
+ var _a2, _b2, _c2;
2128
1751
  if (finished.current || degradedRef.current) return;
2129
1752
  reportClientEvent(reportTargetRef.current, {
2130
1753
  event_type: "dropped",
2131
1754
  session_id: sessionIdRef.current,
2132
1755
  screen_index: lastScreenIndexRef.current >= 0 ? lastScreenIndexRef.current : void 0,
2133
- device: (_a3 = clientContextRef.current) == null ? void 0 : _a3.device,
1756
+ device: (_a2 = clientContextRef.current) == null ? void 0 : _a2.device,
2134
1757
  user_context: (_b2 = clientContextRef.current) == null ? void 0 : _b2.userContext,
2135
1758
  user_id: (_c2 = clientContextRef.current) == null ? void 0 : _c2.userId
2136
1759
  });
@@ -2138,17 +1761,17 @@ var OnboardingFlow = ({
2138
1761
  }, []);
2139
1762
  const restartThread = React19.useCallback(() => {
2140
1763
  setTimedOut(false);
2141
- started.current = false;
2142
1764
  errored.current = false;
1765
+ setRunId((n) => n + 1);
2143
1766
  reset();
2144
1767
  }, [reset]);
2145
1768
  React19.useEffect(() => {
2146
- var _a3, _b2, _c2, _d2, _e2, _f2, _g;
1769
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g;
2147
1770
  if (errored.current) return;
2148
1771
  if (!error && !timedOut) return;
2149
1772
  errored.current = true;
2150
1773
  const reason = error ? "backend" : "timeout";
2151
- (_a3 = onEventRef.current) == null ? void 0 : _a3.call(onEventRef, { type: "error", reason });
1774
+ (_a2 = onEventRef.current) == null ? void 0 : _a2.call(onEventRef, { type: "error", reason });
2152
1775
  attempts.current += 1;
2153
1776
  if (attempts.current <= maxRetries) {
2154
1777
  (_b2 = onEventRef.current) == null ? void 0 : _b2.call(onEventRef, { type: "retry", reason, attempt: attempts.current });
@@ -2186,8 +1809,8 @@ var OnboardingFlow = ({
2186
1809
  }, [isLoading, sendMessage]);
2187
1810
  const emitPermissionStage = React19.useCallback(
2188
1811
  (permission, stage, status) => {
2189
- var _a3, _b2, _c2, _d2;
2190
- (_a3 = onEventRef.current) == null ? void 0 : _a3.call(onEventRef, { type: "permission", permission, stage, status });
1812
+ var _a2, _b2, _c2, _d2;
1813
+ (_a2 = onEventRef.current) == null ? void 0 : _a2.call(onEventRef, { type: "permission", permission, stage, status });
2191
1814
  reportClientEvent(reportTargetRef.current, {
2192
1815
  event_type: "app_event",
2193
1816
  session_id: sessionIdRef.current,
@@ -2204,9 +1827,9 @@ var OnboardingFlow = ({
2204
1827
  );
2205
1828
  const settlePermission = React19.useCallback(
2206
1829
  (id, screen, outcome) => {
2207
- var _a3, _b2;
1830
+ var _a2, _b2;
2208
1831
  setLocallySettledPermissions((prev) => prev.includes(id) ? prev : [...prev, id]);
2209
- (_a3 = onPermissionSettledRef.current) == null ? void 0 : _a3.call(onPermissionSettledRef, id, outcome);
1832
+ (_a2 = onPermissionSettledRef.current) == null ? void 0 : _a2.call(onPermissionSettledRef, id, outcome);
2210
1833
  try {
2211
1834
  (_b2 = screen.onResult) == null ? void 0 : _b2.call(screen, screen.permission, outcome);
2212
1835
  } catch {
@@ -2231,26 +1854,26 @@ var OnboardingFlow = ({
2231
1854
  }, []);
2232
1855
  const wrappedActions = React19.useCallback(
2233
1856
  (messageId) => {
2234
- var _a3;
1857
+ var _a2;
2235
1858
  const base = makeActions(messageId);
2236
1859
  const validators2 = validatorsRef.current;
2237
- const validator = (_a3 = progress.slot_id ? validators2 == null ? void 0 : validators2[progress.slot_id] : void 0) != null ? _a3 : progress.key ? validators2 == null ? void 0 : validators2[progress.key] : void 0;
1860
+ const validator = (_a2 = progress.slot_id ? validators2 == null ? void 0 : validators2[progress.slot_id] : void 0) != null ? _a2 : progress.key ? validators2 == null ? void 0 : validators2[progress.key] : void 0;
2238
1861
  if (!validator) return base;
2239
1862
  const out = { ...base };
2240
- for (const name2 of ANSWER_CALLBACKS) {
2241
- const original = base[name2];
1863
+ for (const name of ANSWER_CALLBACKS) {
1864
+ const original = base[name];
2242
1865
  if (!original) continue;
2243
- out[name2] = (...args) => {
1866
+ out[name] = (...args) => {
2244
1867
  const value = args[0];
2245
1868
  if (typeof value !== "string") return original(...args);
2246
1869
  setValidating(true);
2247
1870
  validator(value).then((res) => {
2248
- var _a4;
1871
+ var _a3;
2249
1872
  if (res.ok) {
2250
1873
  setValidationError(void 0);
2251
1874
  original(...args);
2252
1875
  } else {
2253
- setValidationError((_a4 = res.error) != null ? _a4 : "That value isn't available.");
1876
+ setValidationError((_a3 = res.error) != null ? _a3 : "That value isn't available.");
2254
1877
  }
2255
1878
  }).catch(() => {
2256
1879
  original(...args);
@@ -2281,7 +1904,7 @@ var OnboardingFlow = ({
2281
1904
  if (!lastCard || !response) {
2282
1905
  return /* @__PURE__ */ jsxRuntime.jsx(LoadingScreen, { title: c.startingTitle, hint: c.startingHint });
2283
1906
  }
2284
- const step = (_a2 = progress.step) != null ? _a2 : renderedCount;
1907
+ const step = (_a = progress.step) != null ? _a : renderedCount;
2285
1908
  const total = (_b = progress.total) != null ? _b : approxScreens;
2286
1909
  const isTerminal = response.action === "render" && response.component === "StatusCard";
2287
1910
  const duePermission = permissionsPending ? void 0 : selectDuePermissionScreen(
@@ -2677,7 +2300,7 @@ var runtimeRequire = (moduleName) => {
2677
2300
  if (moduleName !== "@expo/vector-icons") return void 0;
2678
2301
  if (typeof __require !== "function") return void 0;
2679
2302
  try {
2680
- return __require("@expo/vector-icons");
2303
+ return require("@expo/vector-icons");
2681
2304
  } catch {
2682
2305
  return void 0;
2683
2306
  }
@@ -2806,13 +2429,13 @@ var WIRE_ICON_GLYPHS = {
2806
2429
  other: { family: "MaterialCommunityIcons", name: "dots-horizontal-circle" }
2807
2430
  };
2808
2431
  var WIRE_ICON_NAMES = Object.keys(WIRE_ICON_GLYPHS).sort();
2809
- var lookupIconGlyph = (name2) => {
2810
- if (!name2) return void 0;
2811
- if (!Object.prototype.hasOwnProperty.call(WIRE_ICON_GLYPHS, name2)) return void 0;
2812
- return WIRE_ICON_GLYPHS[name2];
2432
+ var lookupIconGlyph = (name) => {
2433
+ if (!name) return void 0;
2434
+ if (!Object.prototype.hasOwnProperty.call(WIRE_ICON_GLYPHS, name)) return void 0;
2435
+ return WIRE_ICON_GLYPHS[name];
2813
2436
  };
2814
- var _WireIcon = ({ name: name2, size = 20, color, requireModule }) => {
2815
- const hostIcon = useHostIcon(name2);
2437
+ var _WireIcon = ({ name, size = 20, color, requireModule }) => {
2438
+ const hostIcon = useHostIcon(name);
2816
2439
  if (hostIcon) {
2817
2440
  return /* @__PURE__ */ jsxRuntime.jsx(
2818
2441
  reactNative.View,
@@ -2824,7 +2447,7 @@ var _WireIcon = ({ name: name2, size = 20, color, requireModule }) => {
2824
2447
  }
2825
2448
  );
2826
2449
  }
2827
- const glyph = lookupIconGlyph(name2);
2450
+ const glyph = lookupIconGlyph(name);
2828
2451
  if (!glyph) return null;
2829
2452
  const Family = resolveIconFamily(glyph.family, requireModule);
2830
2453
  if (!Family) return null;
@@ -3237,7 +2860,7 @@ var STATUS_ICONS = {
3237
2860
  info: "\u2139"
3238
2861
  };
3239
2862
  var _StatusCard = ({ status, title, message, ctaLabel, onContinue, onPress, onSubmit }) => {
3240
- var _a2;
2863
+ var _a;
3241
2864
  const t = useOnboardingTheme();
3242
2865
  const reduced = useReducedMotion();
3243
2866
  const [submitted, setSubmitted] = React19.useState(false);
@@ -3303,7 +2926,7 @@ var _StatusCard = ({ status, title, message, ctaLabel, onContinue, onPress, onSu
3303
2926
  headingStyle(t.fonts),
3304
2927
  { color, opacity: popT, transform: [{ scale: popScale }] }
3305
2928
  ],
3306
- children: (_a2 = STATUS_ICONS[status]) != null ? _a2 : "\xB7"
2929
+ children: (_a = STATUS_ICONS[status]) != null ? _a : "\xB7"
3307
2930
  }
3308
2931
  ),
3309
2932
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -3646,9 +3269,9 @@ var runtimeRequire2 = (moduleName) => {
3646
3269
  try {
3647
3270
  switch (moduleName) {
3648
3271
  case "expo-constants":
3649
- return init_Constants(), __toCommonJS(Constants_exports);
3272
+ return require("expo-constants");
3650
3273
  case "expo-application":
3651
- return __require("expo-application");
3274
+ return require("expo-application");
3652
3275
  default:
3653
3276
  return void 0;
3654
3277
  }
@@ -3671,14 +3294,14 @@ var safeInterop = (requireModule, moduleName) => {
3671
3294
  };
3672
3295
  var detectAppVersion = (requireModule = runtimeRequire2) => {
3673
3296
  try {
3674
- const constants2 = safeInterop(requireModule, "expo-constants");
3675
- if (constants2) {
3676
- const expoConfig = constants2.expoConfig;
3297
+ const constants = safeInterop(requireModule, "expo-constants");
3298
+ if (constants) {
3299
+ const expoConfig = constants.expoConfig;
3677
3300
  if (expoConfig && typeof expoConfig === "object") {
3678
3301
  const fromExpoConfig = coerceVersion(expoConfig.version);
3679
3302
  if (fromExpoConfig) return fromExpoConfig;
3680
3303
  }
3681
- const fromNative = coerceVersion(constants2.nativeAppVersion);
3304
+ const fromNative = coerceVersion(constants.nativeAppVersion);
3682
3305
  if (fromNative) return fromNative;
3683
3306
  }
3684
3307
  const application = safeInterop(requireModule, "expo-application");
@@ -3701,7 +3324,7 @@ var runtimeRequire3 = (moduleName) => {
3701
3324
  if (moduleName !== "expo-device") return void 0;
3702
3325
  if (typeof __require !== "function") return void 0;
3703
3326
  try {
3704
- return __require("expo-device");
3327
+ return require("expo-device");
3705
3328
  } catch {
3706
3329
  return void 0;
3707
3330
  }
@@ -3743,7 +3366,7 @@ var deriveFormFactor = (iosIdiom, width, height) => {
3743
3366
  return void 0;
3744
3367
  };
3745
3368
  var collectDeviceContext = () => {
3746
- var _a2;
3369
+ var _a;
3747
3370
  const ctx = { platform: reactNative.Platform.OS };
3748
3371
  try {
3749
3372
  const version = reactNative.Platform.Version;
@@ -3752,26 +3375,26 @@ var collectDeviceContext = () => {
3752
3375
  }
3753
3376
  } catch {
3754
3377
  }
3755
- let constants2 = {};
3378
+ let constants = {};
3756
3379
  try {
3757
- constants2 = (_a2 = reactNative.Platform.constants) != null ? _a2 : {};
3380
+ constants = (_a = reactNative.Platform.constants) != null ? _a : {};
3758
3381
  } catch {
3759
- constants2 = {};
3382
+ constants = {};
3760
3383
  }
3761
3384
  let iosIdiom;
3762
3385
  try {
3763
3386
  if (reactNative.Platform.OS === "android") {
3764
- const brand = constants2.Brand;
3765
- const model = constants2.Model;
3766
- const release = constants2.Release;
3387
+ const brand = constants.Brand;
3388
+ const model = constants.Model;
3389
+ const release = constants.Release;
3767
3390
  if (typeof brand === "string" && brand) ctx.brand = brand;
3768
3391
  if (typeof model === "string" && model) ctx.model = model;
3769
3392
  if (release !== void 0 && release !== null && String(release)) {
3770
3393
  ctx.osVersion = String(release);
3771
3394
  }
3772
3395
  } else if (reactNative.Platform.OS === "ios") {
3773
- const osVersion = constants2.osVersion;
3774
- const idiom = constants2.interfaceIdiom;
3396
+ const osVersion = constants.osVersion;
3397
+ const idiom = constants.interfaceIdiom;
3775
3398
  if (osVersion !== void 0 && osVersion !== null && String(osVersion)) {
3776
3399
  ctx.osVersion = String(osVersion);
3777
3400
  }
@@ -3822,11 +3445,11 @@ var provenanceRegistry = () => {
3822
3445
  };
3823
3446
  var provenanceKey = (space, scope) => `${space}:${scope != null ? scope : "default"}`;
3824
3447
  var resolveIdentity = (input) => {
3825
- var _a2;
3448
+ var _a;
3826
3449
  if (typeof input.value !== "string") return void 0;
3827
3450
  const value = input.value.trim();
3828
3451
  if (!value) return void 0;
3829
- const durable = (_a2 = input.durable) != null ? _a2 : input.source === "host";
3452
+ const durable = (_a = input.durable) != null ? _a : input.source === "host";
3830
3453
  if (input.source === "host") {
3831
3454
  provenanceRegistry().host.set(provenanceKey(input.space, input.scope), value);
3832
3455
  }
@@ -3860,8 +3483,8 @@ var startHydration = (registry, appId, storage, minted) => {
3860
3483
  if (existing) return existing;
3861
3484
  const slot = deviceIdStorageKey(appId);
3862
3485
  const degraded = () => {
3863
- var _a2;
3864
- return { value: (_a2 = registry.keys.get(appId)) != null ? _a2 : minted, durable: false };
3486
+ var _a;
3487
+ return { value: (_a = registry.keys.get(appId)) != null ? _a : minted, durable: false };
3865
3488
  };
3866
3489
  const adopted = (value) => ({ value, durable: true });
3867
3490
  let run;
@@ -3874,8 +3497,8 @@ var startHydration = (registry, appId, storage, minted) => {
3874
3497
  }
3875
3498
  return Promise.resolve(storage.setItem(slot, minted)).then(
3876
3499
  () => {
3877
- var _a2;
3878
- return adopted((_a2 = registry.keys.get(appId)) != null ? _a2 : minted);
3500
+ var _a;
3501
+ return adopted((_a = registry.keys.get(appId)) != null ? _a : minted);
3879
3502
  },
3880
3503
  degraded
3881
3504
  );
@@ -3885,17 +3508,17 @@ var startHydration = (registry, appId, storage, minted) => {
3885
3508
  }
3886
3509
  registry.pending.set(appId, run);
3887
3510
  void run.then((outcome) => {
3888
- var _a2;
3511
+ var _a;
3889
3512
  if (outcome.durable) return;
3890
- (_a2 = registry.pending) == null ? void 0 : _a2.delete(appId);
3513
+ (_a = registry.pending) == null ? void 0 : _a.delete(appId);
3891
3514
  registry.hydrating.delete(appId);
3892
3515
  });
3893
3516
  return run;
3894
3517
  };
3895
3518
  var resolveAutoDeviceKey = (opts = {}) => {
3896
- var _a2, _b;
3519
+ var _a, _b;
3897
3520
  const registry = autoDeviceKeyRegistry();
3898
- const appId = (_a2 = opts.appId) != null ? _a2 : "default";
3521
+ const appId = (_a = opts.appId) != null ? _a : "default";
3899
3522
  let id = registry.keys.get(appId);
3900
3523
  if (!id) {
3901
3524
  id = mintDeviceId();
@@ -3909,13 +3532,13 @@ var resolveAutoDeviceKey = (opts = {}) => {
3909
3532
  return (_b = registry.keys.get(appId)) != null ? _b : id;
3910
3533
  };
3911
3534
  var hydrateAutoDeviceKey = async (opts = {}) => {
3912
- var _a2, _b;
3913
- return (_b = (_a2 = await hydrateDeviceIdentity(opts)) == null ? void 0 : _a2.value) != null ? _b : resolveAutoDeviceKey(opts);
3535
+ var _a, _b;
3536
+ return (_b = (_a = await hydrateDeviceIdentity(opts)) == null ? void 0 : _a.value) != null ? _b : resolveAutoDeviceKey(opts);
3914
3537
  };
3915
3538
  var hydrateDeviceIdentity = async (opts = {}) => {
3916
- var _a2, _b, _c;
3539
+ var _a, _b, _c;
3917
3540
  const id = resolveAutoDeviceKey(opts);
3918
- const appId = (_a2 = opts.appId) != null ? _a2 : "default";
3541
+ const appId = (_a = opts.appId) != null ? _a : "default";
3919
3542
  const record = (value, durable) => resolveIdentity({ value, space: "device", source: "auto", durable, scope: appId });
3920
3543
  if (!opts.storage) return record(id, false);
3921
3544
  const registry = autoDeviceKeyRegistry();
@@ -3925,11 +3548,11 @@ var hydrateDeviceIdentity = async (opts = {}) => {
3925
3548
  return record(outcome.value, outcome.durable);
3926
3549
  };
3927
3550
  var resetAutoDeviceKeys = () => {
3928
- var _a2;
3551
+ var _a;
3929
3552
  const registry = autoDeviceKeyRegistry();
3930
3553
  registry.keys.clear();
3931
3554
  registry.hydrating.clear();
3932
- (_a2 = registry.pending) == null ? void 0 : _a2.clear();
3555
+ (_a = registry.pending) == null ? void 0 : _a.clear();
3933
3556
  };
3934
3557
 
3935
3558
  // src/analytics/currentSession.ts
@@ -4031,9 +3654,9 @@ var sanitizeUserId = (raw) => {
4031
3654
  };
4032
3655
  var looksLikeEmail = (value) => typeof value === "string" && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value.trim());
4033
3656
  var identifyOnboarding = async (opts) => {
4034
- var _a2, _b, _c;
3657
+ var _a, _b, _c;
4035
3658
  const userId = sanitizeUserId(opts.userId);
4036
- if (!userId || !((_a2 = opts.config) == null ? void 0 : _a2.serverUrl)) return false;
3659
+ if (!userId || !((_a = opts.config) == null ? void 0 : _a.serverUrl)) return false;
4037
3660
  let contextId = ((_b = opts.contextId) == null ? void 0 : _b.trim()) || void 0;
4038
3661
  if (!contextId && opts.storage) {
4039
3662
  const key = (_c = opts.persistKey) != null ? _c : opts.appId ? sessionStorageKey(opts.appId) : void 0;
@@ -4104,11 +3727,11 @@ var clearUserContext = async (opts = {}) => {
4104
3727
  }
4105
3728
  };
4106
3729
  var activationJoinContext = (deviceKey) => {
4107
- var _a2;
4108
- return (_a2 = resolveUserContext({ deviceKey }).userContext) != null ? _a2 : {};
3730
+ var _a;
3731
+ return (_a = resolveUserContext({ deviceKey }).userContext) != null ? _a : {};
4109
3732
  };
4110
3733
  var resolveUserContext = (ctx = {}, opts = {}) => {
4111
- var _a2;
3734
+ var _a;
4112
3735
  const result = {};
4113
3736
  const bucket = {};
4114
3737
  const userId = sanitizeUserId(ctx.userId);
@@ -4118,7 +3741,7 @@ var resolveUserContext = (ctx = {}, opts = {}) => {
4118
3741
  result.deviceKey = deviceKey;
4119
3742
  bucket.device_key = deviceKey;
4120
3743
  }
4121
- const appVersion = (_a2 = cleanString(ctx.appVersion)) != null ? _a2 : cleanString(opts.autoAppVersion);
3744
+ const appVersion = (_a = cleanString(ctx.appVersion)) != null ? _a : cleanString(opts.autoAppVersion);
4122
3745
  if (appVersion) {
4123
3746
  result.appVersion = appVersion;
4124
3747
  bucket.app_version = appVersion;
@@ -4200,7 +3823,7 @@ var WireOnboarding = ({
4200
3823
  autoJoinKey = true,
4201
3824
  permissionScreens
4202
3825
  }) => {
4203
- var _a2, _b, _c, _d, _e, _f;
3826
+ var _a, _b, _c, _d, _e, _f;
4204
3827
  const boundUserId = React19.useMemo(() => sanitizeUserId(userId), [userId]);
4205
3828
  const device = React19.useMemo(() => {
4206
3829
  const collected = collectDeviceContext();
@@ -4242,7 +3865,7 @@ var WireOnboarding = ({
4242
3865
  clearTimeout(timer);
4243
3866
  };
4244
3867
  }, [wantsAutoJoin, autoJoinOutcome, config.appId, storage]);
4245
- const injectedJoinKey = wantsAutoJoin ? (_a2 = autoJoinOutcome == null ? void 0 : autoJoinOutcome.key) != null ? _a2 : void 0 : void 0;
3868
+ const injectedJoinKey = wantsAutoJoin ? (_a = autoJoinOutcome == null ? void 0 : autoJoinOutcome.key) != null ? _a : void 0 : void 0;
4246
3869
  const autoJoinPending = wantsAutoJoin && autoJoinOutcome === void 0;
4247
3870
  const effectiveUserContext = React19.useMemo(
4248
3871
  () => injectedJoinKey ? { ...userContextStable, ...activationJoinContext(injectedJoinKey) } : userContextStable,
@@ -4326,8 +3949,8 @@ var WireOnboarding = ({
4326
3949
  settledPermissionsRef.current = settledPermissions;
4327
3950
  const handlePermissionSettled = React19.useCallback(
4328
3951
  (id) => {
4329
- var _a3;
4330
- const current = (_a3 = settledPermissionsRef.current) != null ? _a3 : [];
3952
+ var _a2;
3953
+ const current = (_a2 = settledPermissionsRef.current) != null ? _a2 : [];
4331
3954
  if (current.includes(id)) return;
4332
3955
  const next = [...current, id];
4333
3956
  settledPermissionsRef.current = next;
@@ -4702,10 +4325,10 @@ var readEnabled = (raw) => {
4702
4325
  return { enabled: true };
4703
4326
  };
4704
4327
  var parseWireFeatures = (raw) => {
4705
- var _a2;
4328
+ var _a;
4706
4329
  if (!raw || typeof raw !== "object" || Array.isArray(raw)) return defaultWireFeatures;
4707
4330
  const src = raw;
4708
- const modeRaw = (_a2 = src.onboarding) == null ? void 0 : _a2.mode;
4331
+ const modeRaw = (_a = src.onboarding) == null ? void 0 : _a.mode;
4709
4332
  const mode = typeof modeRaw === "string" && VALID_MODES.includes(modeRaw) ? modeRaw : "ai";
4710
4333
  return {
4711
4334
  coachmarks: readEnabled(src.coachmarks),
@@ -4762,10 +4385,10 @@ var writeCachedFeatures = (storage, key, features) => {
4762
4385
  // src/features/fetchWireFeatures.ts
4763
4386
  var DEFAULT_TIMEOUT_MS = 4e3;
4764
4387
  var failOpen = async (storage, key) => {
4765
- var _a2;
4388
+ var _a;
4766
4389
  if (!storage) return defaultWireFeatures;
4767
4390
  const cached2 = await readCachedFeatures(storage, key);
4768
- return (_a2 = cached2 == null ? void 0 : cached2.features) != null ? _a2 : defaultWireFeatures;
4391
+ return (_a = cached2 == null ? void 0 : cached2.features) != null ? _a : defaultWireFeatures;
4769
4392
  };
4770
4393
  var fetchWithTimeout = async (url, apiKey, timeoutMs) => {
4771
4394
  const controller = typeof AbortController !== "undefined" ? new AbortController() : void 0;
@@ -4824,7 +4447,7 @@ var useWireFeatures = (config) => {
4824
4447
  return flags;
4825
4448
  };
4826
4449
  var CONTEXT_SYMBOL = /* @__PURE__ */ Symbol.for("wireai.features.context");
4827
- var globalObj = global;
4450
+ var globalObj = globalThis;
4828
4451
  if (!globalObj[CONTEXT_SYMBOL]) {
4829
4452
  globalObj[CONTEXT_SYMBOL] = React19.createContext(null);
4830
4453
  }
@@ -4842,11 +4465,11 @@ var WireFeaturesProvider = ({
4842
4465
  WireFeaturesProvider.displayName = "WireFeaturesProvider";
4843
4466
  var useWireFeaturesContext = () => React19.useContext(WireFeaturesContext);
4844
4467
  var useResolvedFeatures = (options) => {
4845
- var _a2, _b, _c;
4468
+ var _a, _b, _c;
4846
4469
  const ctx = useWireFeaturesContext();
4847
4470
  const shouldFetch = !(options == null ? void 0 : options.flags) && ctx == null;
4848
4471
  const fetched = useWireFeatures(shouldFetch ? options == null ? void 0 : options.config : void 0);
4849
- return (_c = (_b = (_a2 = options == null ? void 0 : options.flags) != null ? _a2 : ctx) != null ? _b : fetched) != null ? _c : defaultWireFeatures;
4472
+ return (_c = (_b = (_a = options == null ? void 0 : options.flags) != null ? _a : ctx) != null ? _b : fetched) != null ? _c : defaultWireFeatures;
4850
4473
  };
4851
4474
 
4852
4475
  // src/config/wireConfigFromEnv.ts
@@ -4856,8 +4479,8 @@ var WIRE_ENV_VARS = [
4856
4479
  "EXPO_PUBLIC_WIREAI_APP_ID"
4857
4480
  ];
4858
4481
  var wireConfigFromEnv = (overrides) => {
4859
- var _a2, _b, _c, _d, _e;
4860
- const apiKey = (_a2 = overrides == null ? void 0 : overrides.apiKey) != null ? _a2 : process.env.EXPO_PUBLIC_WIREAI_API_KEY;
4482
+ var _a, _b, _c, _d, _e;
4483
+ const apiKey = (_a = overrides == null ? void 0 : overrides.apiKey) != null ? _a : process.env.EXPO_PUBLIC_WIREAI_API_KEY;
4861
4484
  const serverUrl = (_b = overrides == null ? void 0 : overrides.serverUrl) != null ? _b : process.env.EXPO_PUBLIC_WIREAI_SERVER_URL;
4862
4485
  const appId = (_d = (_c = overrides == null ? void 0 : overrides.appId) != null ? _c : process.env.EXPO_PUBLIC_WIREAI_APP_ID) != null ? _d : "default";
4863
4486
  if (!apiKey || !serverUrl) {
@@ -4882,10 +4505,10 @@ var wireConfigFromEnv = (overrides) => {
4882
4505
 
4883
4506
  // src/config/onboardingFlag.ts
4884
4507
  var isOnboardingEnabled = (opts) => {
4885
- var _a2;
4508
+ var _a;
4886
4509
  const transportPresent = wireConfigFromEnv(opts == null ? void 0 : opts.config) !== null;
4887
4510
  if (!transportPresent) return false;
4888
- return (_a2 = opts == null ? void 0 : opts.remote) != null ? _a2 : true;
4511
+ return (_a = opts == null ? void 0 : opts.remote) != null ? _a : true;
4889
4512
  };
4890
4513
 
4891
4514
  // src/analytics/analyticsEvent.ts
@@ -4980,9 +4603,9 @@ var resetActivationRevalidation = () => {
4980
4603
  // src/activation/wireActivation.ts
4981
4604
  var clean = cleanString;
4982
4605
  var createWireActivation = (config) => {
4983
- var _a2, _b;
4606
+ var _a, _b;
4984
4607
  const target = { serverUrl: config.serverUrl, apiKey: config.apiKey };
4985
- const explicitDeviceKey = (_b = clean(config.deviceKey)) != null ? _b : clean((_a2 = config.userContext) == null ? void 0 : _a2.deviceKey);
4608
+ const explicitDeviceKey = (_b = clean(config.deviceKey)) != null ? _b : clean((_a = config.userContext) == null ? void 0 : _a.deviceKey);
4986
4609
  resolveIdentity({
4987
4610
  value: explicitDeviceKey,
4988
4611
  space: "device",
@@ -4997,11 +4620,11 @@ var createWireActivation = (config) => {
4997
4620
  if (!explicitDeviceKey) resolveAutoDeviceKey(autoDeviceKeyOptions);
4998
4621
  const detectedAppVersion = detectAppVersion();
4999
4622
  const applyContext = (event) => {
5000
- var _a3, _b2, _c;
4623
+ var _a2, _b2, _c;
5001
4624
  const resolved = resolveUserContext(
5002
4625
  // `??` is lazy on purpose: an explicit key must never even touch the auto registry.
5003
4626
  {
5004
- ...(_a3 = config.userContext) != null ? _a3 : {},
4627
+ ...(_a2 = config.userContext) != null ? _a2 : {},
5005
4628
  deviceKey: explicitDeviceKey != null ? explicitDeviceKey : resolveAutoDeviceKey(autoDeviceKeyOptions)
5006
4629
  },
5007
4630
  { autoAppVersion: (_b2 = config.appVersion) != null ? _b2 : detectedAppVersion }
@@ -5011,13 +4634,13 @@ var createWireActivation = (config) => {
5011
4634
  }
5012
4635
  if (resolved.userId && !event.user_id) event.user_id = resolved.userId;
5013
4636
  };
5014
- const track = async (name2, meta) => {
5015
- if (!clean(name2)) return false;
4637
+ const track = async (name, meta) => {
4638
+ if (!clean(name)) return false;
5016
4639
  const sessionId = ensureCurrentSessionId();
5017
4640
  const event = {
5018
4641
  event_type: "app_event",
5019
4642
  session_id: sessionId,
5020
- question_key: name2
4643
+ question_key: name
5021
4644
  };
5022
4645
  if (meta && Object.keys(meta).length > 0) event.meta = JSON.stringify(meta);
5023
4646
  applyContext(event);
@@ -5040,7 +4663,7 @@ var useActivationRevalidation = () => React19.useSyncExternalStore(
5040
4663
  getActivationRevalidationVersion
5041
4664
  );
5042
4665
  var useWireActivation = (config) => {
5043
- var _a2;
4666
+ var _a;
5044
4667
  const ref = React19.useRef(void 0);
5045
4668
  const prevKeys = React19.useRef("");
5046
4669
  const currentKeys = [
@@ -5048,7 +4671,7 @@ var useWireActivation = (config) => {
5048
4671
  config.apiKey,
5049
4672
  config.appId,
5050
4673
  config.deviceKey,
5051
- (_a2 = config.userContext) == null ? void 0 : _a2.deviceKey
4674
+ (_a = config.userContext) == null ? void 0 : _a.deviceKey
5052
4675
  ].join("|");
5053
4676
  if (!ref.current || prevKeys.current !== currentKeys) {
5054
4677
  prevKeys.current = currentKeys;
@@ -5074,8 +4697,8 @@ var WIRE_PURCHASE_EVENTS = {
5074
4697
  var PLAN_TIER_CONTEXT_KEY = "plan_tier";
5075
4698
  var asRecord = (value) => typeof value === "object" && value !== null ? value : void 0;
5076
4699
  var activeEntitlement = (info, entitlementId) => {
5077
- var _a2, _b;
5078
- const active = asRecord((_b = asRecord((_a2 = asRecord(info)) == null ? void 0 : _a2.entitlements)) == null ? void 0 : _b.active);
4700
+ var _a, _b;
4701
+ const active = asRecord((_b = asRecord((_a = asRecord(info)) == null ? void 0 : _a.entitlements)) == null ? void 0 : _b.active);
5079
4702
  const found = active == null ? void 0 : active[entitlementId];
5080
4703
  const entitlement = asRecord(found);
5081
4704
  if (!entitlement) return void 0;
@@ -5148,19 +4771,19 @@ var createRevenueCatBridge = (config) => {
5148
4771
  }
5149
4772
  };
5150
4773
  const syncPlanTier = (customerInfo) => {
5151
- var _a2;
4774
+ var _a;
5152
4775
  const tier = resolvePlanTier(customerInfo, entitlementId);
5153
4776
  if (!writeTier) return tier;
5154
4777
  try {
5155
- (_a2 = analytics.setUserContext) == null ? void 0 : _a2.call(analytics, { extra: { [PLAN_TIER_CONTEXT_KEY]: tier } });
4778
+ (_a = analytics.setUserContext) == null ? void 0 : _a.call(analytics, { extra: { [PLAN_TIER_CONTEXT_KEY]: tier } });
5156
4779
  } catch {
5157
4780
  }
5158
4781
  return tier;
5159
4782
  };
5160
4783
  const paywallShown = (offering, props) => {
5161
- var _a2, _b;
4784
+ var _a, _b;
5162
4785
  const shown = {
5163
- packages_count: (_b = (_a2 = offering == null ? void 0 : offering.availablePackages) == null ? void 0 : _a2.length) != null ? _b : 0
4786
+ packages_count: (_b = (_a = offering == null ? void 0 : offering.availablePackages) == null ? void 0 : _a.length) != null ? _b : 0
5164
4787
  };
5165
4788
  if (typeof (offering == null ? void 0 : offering.identifier) === "string") shown.offering_id = offering.identifier;
5166
4789
  emit(WIRE_PURCHASE_EVENTS.paywallShown, { ...shown, ...props });
@@ -5214,10 +4837,10 @@ var resetSessionStartGuard = () => {
5214
4837
  _emitted.clear();
5215
4838
  };
5216
4839
  var reportSessionStart = (opts) => {
5217
- var _a2;
4840
+ var _a;
5218
4841
  const target = opts.target;
5219
4842
  if (!opts.sink && !(target == null ? void 0 : target.serverUrl)) return;
5220
- const sessionId = (_a2 = opts.sessionId) != null ? _a2 : makeSessionId();
4843
+ const sessionId = (_a = opts.sessionId) != null ? _a : makeSessionId();
5221
4844
  setCurrentSessionId(sessionId);
5222
4845
  if (opts.once !== false) {
5223
4846
  if (_emitted.has(sessionId)) return;
@@ -5277,11 +4900,11 @@ var useSessionStart = (config, options = {}) => {
5277
4900
  return resolveAutoDeviceKey({ appId: cfg.appId, storage: cfg.storage });
5278
4901
  };
5279
4902
  const fire = () => {
5280
- var _a2, _b;
4903
+ var _a, _b;
5281
4904
  const { config: cfg, options: opts } = latest.current;
5282
4905
  if (!(cfg == null ? void 0 : cfg.serverUrl)) return;
5283
4906
  if (opts.enabled === false) return;
5284
- const target = { serverUrl: cfg.serverUrl, apiKey: (_a2 = cfg.apiKey) != null ? _a2 : "" };
4907
+ const target = { serverUrl: cfg.serverUrl, apiKey: (_a = cfg.apiKey) != null ? _a : "" };
5285
4908
  const device = collectDeviceContext();
5286
4909
  if (cfg.appVersion) device.appVersion = cfg.appVersion;
5287
4910
  reportSessionStart({
@@ -5332,7 +4955,7 @@ var resetFirstOpenLatch = () => {
5332
4955
  _firstOpenLatched.clear();
5333
4956
  };
5334
4957
  var buildLifecycleEvent = (questionKey, opts) => {
5335
- var _a2;
4958
+ var _a;
5336
4959
  const userContext = {};
5337
4960
  if (opts.deviceKey) userContext.device_key = opts.deviceKey;
5338
4961
  if (typeof opts.sessionCount === "number" && Number.isFinite(opts.sessionCount)) {
@@ -5344,7 +4967,7 @@ var buildLifecycleEvent = (questionKey, opts) => {
5344
4967
  const event = {
5345
4968
  event_type: "app_event",
5346
4969
  question_key: questionKey,
5347
- session_id: (_a2 = opts.sessionId) != null ? _a2 : makeSessionId()
4970
+ session_id: (_a = opts.sessionId) != null ? _a : makeSessionId()
5348
4971
  };
5349
4972
  const userId = sanitizeUserId(opts.userId);
5350
4973
  if (userId) event.user_id = userId;
@@ -5370,8 +4993,8 @@ var emitFirstOpen = (opts) => {
5370
4993
  routeLifecycleEvent(buildLifecycleEvent(FIRST_OPEN_EVENT, opts), opts);
5371
4994
  };
5372
4995
  var reportFirstOpen = (opts) => {
5373
- var _a2;
5374
- const appId = (_a2 = opts.appId) != null ? _a2 : "default";
4996
+ var _a;
4997
+ const appId = (_a = opts.appId) != null ? _a : "default";
5375
4998
  if (_firstOpenLatched.has(appId)) return;
5376
4999
  _firstOpenLatched.add(appId);
5377
5000
  const storage = opts.storage;
@@ -5396,8 +5019,8 @@ var reportFirstOpen = (opts) => {
5396
5019
  })();
5397
5020
  };
5398
5021
  var wireLifecycleEvents = (opts) => {
5399
- var _a2;
5400
- const sessionId = (_a2 = opts.sessionId) != null ? _a2 : makeSessionId();
5022
+ var _a;
5023
+ const sessionId = (_a = opts.sessionId) != null ? _a : makeSessionId();
5401
5024
  reportFirstOpen({ ...opts, sessionId });
5402
5025
  reportSessionStart({
5403
5026
  target: opts.target,
@@ -5446,10 +5069,11 @@ var claimQueueKey = (preferred, explicit) => {
5446
5069
  );
5447
5070
  return key;
5448
5071
  };
5072
+ var READ_TIMED_OUT = /* @__PURE__ */ Symbol("wireai:storage-read-timeout");
5449
5073
  var withTimeout4 = (p, ms) => {
5450
5074
  let timer;
5451
5075
  const timeout = new Promise((resolve) => {
5452
- timer = setTimeout(() => resolve(void 0), ms);
5076
+ timer = setTimeout(() => resolve(READ_TIMED_OUT), ms);
5453
5077
  });
5454
5078
  return Promise.race([p, timeout]).finally(() => clearTimeout(timer));
5455
5079
  };
@@ -5474,10 +5098,10 @@ var parsePersisted2 = (raw) => {
5474
5098
  }
5475
5099
  };
5476
5100
  var createEventQueue = (options) => {
5477
- var _a2, _b, _c, _d, _e, _f, _g;
5101
+ var _a, _b, _c, _d, _e, _f, _g;
5478
5102
  const target = options.target;
5479
5103
  const storage = options.storage;
5480
- const defaultKey = (_b = options.storageKey) != null ? _b : `wireai:evtq:${(_a2 = options.appId) != null ? _a2 : "default"}`;
5104
+ const defaultKey = (_b = options.storageKey) != null ? _b : `wireai:evtq:${(_a = options.appId) != null ? _a : "default"}`;
5481
5105
  const key = storage ? claimQueueKey(defaultKey, options.storageKey !== void 0) : defaultKey;
5482
5106
  const maxSize = (_c = options.maxSize) != null ? _c : DEFAULTS.maxSize;
5483
5107
  const batchSize = (_d = options.batchSize) != null ? _d : DEFAULTS.batchSize;
@@ -5489,6 +5113,7 @@ var createEventQueue = (options) => {
5489
5113
  let flushing = false;
5490
5114
  let attempt = 0;
5491
5115
  let retryTimer;
5116
+ let backlogUnread = false;
5492
5117
  const resolveEnvelope = () => {
5493
5118
  try {
5494
5119
  return typeof options.envelope === "function" ? options.envelope() : options.envelope;
@@ -5497,14 +5122,14 @@ var createEventQueue = (options) => {
5497
5122
  }
5498
5123
  };
5499
5124
  const stamp = (event) => {
5500
- var _a3;
5125
+ var _a2;
5501
5126
  const env = resolveEnvelope();
5502
5127
  const stamped = { ...event };
5503
5128
  if (stamped.ts === void 0) stamped.ts = Date.now();
5504
5129
  if (!env) return stamped;
5505
5130
  if (!stamped.device && env.device) stamped.device = env.device;
5506
5131
  if (!stamped.session_id && env.sessionId) stamped.session_id = env.sessionId;
5507
- const uc = { ...(_a3 = stamped.user_context) != null ? _a3 : {} };
5132
+ const uc = { ...(_a2 = stamped.user_context) != null ? _a2 : {} };
5508
5133
  if (env.appVersion && uc.app_version === void 0) uc.app_version = env.appVersion;
5509
5134
  if (env.appBuild && uc.app_build === void 0) uc.app_build = env.appBuild;
5510
5135
  if (env.networkType && uc.network_type === void 0) uc.network_type = env.networkType;
@@ -5513,6 +5138,7 @@ var createEventQueue = (options) => {
5513
5138
  };
5514
5139
  const persist = () => {
5515
5140
  if (!storage) return;
5141
+ if (backlogUnread) return;
5516
5142
  try {
5517
5143
  if (pending.length === 0) {
5518
5144
  void storage.removeItem(key).catch(() => {
@@ -5535,23 +5161,44 @@ var createEventQueue = (options) => {
5535
5161
  return `__nosig_${nextId}_${Math.random()}`;
5536
5162
  }
5537
5163
  };
5164
+ const mergePersisted = (persistedItems) => {
5165
+ if (persistedItems.length === 0) return;
5166
+ const seen = new Set(pending.map((item) => item.sig));
5167
+ const restored = [];
5168
+ for (const persisted of persistedItems) {
5169
+ const sig = safeSig(persisted.event);
5170
+ if (seen.has(sig)) continue;
5171
+ seen.add(sig);
5172
+ restored.push({ id: nextId++, event: persisted.event, sig });
5173
+ }
5174
+ if (restored.length === 0) return;
5175
+ pending = [...restored, ...pending];
5176
+ enforceSizeCap();
5177
+ persist();
5178
+ };
5538
5179
  const loadPromise = (async () => {
5539
5180
  if (!storage) return;
5540
5181
  try {
5541
- const persistedItems = parsePersisted2(await withTimeout4(storage.getItem(key), READ_TIMEOUT_MS4));
5542
- if (persistedItems.length === 0) return;
5543
- const events = [...persistedItems.map((p) => p.event), ...pending.map((p) => p.event)];
5544
- pending = [];
5545
- nextId = 0;
5546
- const seen = /* @__PURE__ */ new Set();
5547
- for (const event of events) {
5548
- const sig = safeSig(event);
5549
- if (seen.has(sig)) continue;
5550
- seen.add(sig);
5551
- pending.push({ id: nextId++, event, sig });
5182
+ const read = Promise.resolve(storage.getItem(key));
5183
+ read.catch(() => {
5184
+ });
5185
+ const raced = await withTimeout4(read, READ_TIMEOUT_MS4);
5186
+ if (raced === READ_TIMED_OUT) {
5187
+ backlogUnread = true;
5188
+ warnInDev(
5189
+ `[wireai] the persisted analytics backlog at "${key}" took longer than ${READ_TIMEOUT_MS4}ms to read, so the queue started without it. The stored events are NOT discarded: writes are held back until the read lands, and the backlog is merged in then. If you see this on every cold start, your storage adapter is too slow to be on the launch path.`
5190
+ );
5191
+ void read.then((late) => {
5192
+ backlogUnread = false;
5193
+ mergePersisted(parsePersisted2(late));
5194
+ flush();
5195
+ }).catch(() => {
5196
+ backlogUnread = false;
5197
+ persist();
5198
+ });
5199
+ return;
5552
5200
  }
5553
- enforceSizeCap();
5554
- persist();
5201
+ mergePersisted(parsePersisted2(raced));
5555
5202
  } catch {
5556
5203
  }
5557
5204
  })();
@@ -5648,13 +5295,13 @@ var useLifecycleEvents = (config, options = {}) => {
5648
5295
  const queueRef = React19.useRef(void 0);
5649
5296
  React19.useEffect(() => {
5650
5297
  const resolveSink = () => {
5651
- var _a2, _b;
5298
+ var _a, _b;
5652
5299
  const { config: cfg, options: opts } = latest.current;
5653
5300
  if (opts.sink) return opts.sink;
5654
5301
  if (!(cfg == null ? void 0 : cfg.serverUrl)) return void 0;
5655
5302
  if (!queueRef.current) {
5656
5303
  queueRef.current = createEventQueue({
5657
- target: { serverUrl: cfg.serverUrl, apiKey: (_a2 = cfg.apiKey) != null ? _a2 : "" },
5304
+ target: { serverUrl: cfg.serverUrl, apiKey: (_a = cfg.apiKey) != null ? _a : "" },
5658
5305
  storage: cfg.storage,
5659
5306
  // Dedicated key so the hook's internal queue never collides with a host's main queue.
5660
5307
  storageKey: `wireai:evtq:lifecycle:${(_b = cfg.appId) != null ? _b : "default"}`,
@@ -5664,24 +5311,24 @@ var useLifecycleEvents = (config, options = {}) => {
5664
5311
  return queueRef.current.enqueue;
5665
5312
  };
5666
5313
  const targetOf = (cfg) => {
5667
- var _a2;
5668
- return (cfg == null ? void 0 : cfg.serverUrl) ? { serverUrl: cfg.serverUrl, apiKey: (_a2 = cfg.apiKey) != null ? _a2 : "" } : void 0;
5314
+ var _a;
5315
+ return (cfg == null ? void 0 : cfg.serverUrl) ? { serverUrl: cfg.serverUrl, apiKey: (_a = cfg.apiKey) != null ? _a : "" } : void 0;
5669
5316
  };
5670
5317
  const resolveDeviceKey = (cfg, opts) => {
5671
- var _a2;
5672
- const host = (_a2 = resolveIdentity({
5318
+ var _a;
5319
+ const host = (_a = resolveIdentity({
5673
5320
  value: opts.deviceKey,
5674
5321
  space: "device",
5675
5322
  source: "host",
5676
5323
  scope: cfg == null ? void 0 : cfg.appId
5677
- })) == null ? void 0 : _a2.value;
5324
+ })) == null ? void 0 : _a.value;
5678
5325
  if (host) return host;
5679
5326
  if (!(cfg == null ? void 0 : cfg.storage)) return void 0;
5680
5327
  return resolveAutoDeviceKey({ appId: cfg.appId, storage: cfg.storage });
5681
5328
  };
5682
5329
  const mountOpenSessionId = makeSessionId();
5683
5330
  const fireSession = (sessionId) => {
5684
- var _a2;
5331
+ var _a;
5685
5332
  const { config: cfg, options: opts } = latest.current;
5686
5333
  if (opts.enabled === false) return;
5687
5334
  if (!(cfg == null ? void 0 : cfg.serverUrl) && !opts.sink) return;
@@ -5694,14 +5341,14 @@ var useLifecycleEvents = (config, options = {}) => {
5694
5341
  userId: opts.userId,
5695
5342
  deviceKey: resolveDeviceKey(cfg, opts),
5696
5343
  sessionCount: opts.sessionCount,
5697
- appVersion: (_a2 = cfg == null ? void 0 : cfg.appVersion) != null ? _a2 : device.appVersion,
5344
+ appVersion: (_a = cfg == null ? void 0 : cfg.appVersion) != null ? _a : device.appVersion,
5698
5345
  platform: reactNative.Platform.OS,
5699
5346
  device,
5700
5347
  meta: opts.meta
5701
5348
  });
5702
5349
  };
5703
5350
  const fireMountOpen = () => {
5704
- var _a2;
5351
+ var _a;
5705
5352
  fireSession(mountOpenSessionId);
5706
5353
  const { config: cfg, options: opts } = latest.current;
5707
5354
  if (opts.enabled === false) return;
@@ -5716,7 +5363,7 @@ var useLifecycleEvents = (config, options = {}) => {
5716
5363
  userId: opts.userId,
5717
5364
  deviceKey: resolveDeviceKey(cfg, opts),
5718
5365
  sessionCount: opts.sessionCount,
5719
- appVersion: (_a2 = cfg == null ? void 0 : cfg.appVersion) != null ? _a2 : device.appVersion,
5366
+ appVersion: (_a = cfg == null ? void 0 : cfg.appVersion) != null ? _a : device.appVersion,
5720
5367
  platform: reactNative.Platform.OS,
5721
5368
  device,
5722
5369
  meta: opts.meta