@onairosofficial/onairos-capacitor 0.1.0 → 0.1.1

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 (181) hide show
  1. package/LICENSE +194 -10
  2. package/README.md +182 -25
  3. package/dist/onairos.capacitor.esm.js +1 -0
  4. package/dist/onairos.capacitor.esm.turbopack.js +1 -0
  5. package/onairos.d.ts +656 -0
  6. package/package.json +186 -38
  7. package/src/OnairosReconnectButton.jsx +272 -0
  8. package/src/RSA.jsx +57 -0
  9. package/src/assets/NewLogo.png +0 -0
  10. package/src/assets/OnairosNewLogo.png +0 -0
  11. package/src/assets/chatgpt-icon.png +0 -0
  12. package/src/assets/fire-horse.png +0 -0
  13. package/src/assets/fire-horse.transparent.png +0 -0
  14. package/src/assets/latest-firehorse.png +0 -0
  15. package/src/assets/perplexity.png +0 -0
  16. package/src/assets/persona.png +0 -0
  17. package/src/assets/persona1.png +0 -0
  18. package/src/assets/persona2.png +0 -0
  19. package/src/assets/persona3.png +0 -0
  20. package/src/assets/persona4.png +0 -0
  21. package/src/assets/persona5.png +0 -0
  22. package/src/capacitorConnectorCatalog.js +38 -0
  23. package/src/capacitorOAuthConfig.js +52 -0
  24. package/src/chatgptHostedImport/index.js +303 -0
  25. package/src/components/AuthButtons.jsx +48 -0
  26. package/src/components/ConnectChatGPTModal.jsx +666 -0
  27. package/src/components/ConnectClaudeModal.jsx +610 -0
  28. package/src/components/ConnectGeminiModal.jsx +639 -0
  29. package/src/components/ConnectGrokModal.jsx +701 -0
  30. package/src/components/ConnectPerplexityModal.jsx +726 -0
  31. package/src/components/DataExplainerScreen.jsx +349 -0
  32. package/src/components/DataRequest.js +885 -0
  33. package/src/components/DataRequest.jsx +1055 -0
  34. package/src/components/EmailAuth.js +1871 -0
  35. package/src/components/EmailAuth.jsx +2062 -0
  36. package/src/components/ExtensionInstallPrompt.jsx +142 -0
  37. package/src/components/GoogleButton.js +133 -0
  38. package/src/components/LLMConnectorManager.jsx +201 -0
  39. package/src/components/LoadingPage.jsx +19 -0
  40. package/src/components/LoadingScreen.jsx +81 -0
  41. package/src/components/LunarBirthdate.jsx +96 -0
  42. package/src/components/LunarLoadingPage.jsx +251 -0
  43. package/src/components/Notification.jsx +21 -0
  44. package/src/components/OnairosAppButton.jsx +85 -0
  45. package/src/components/OnairosSSO.jsx +645 -0
  46. package/src/components/OnairosTrigger.jsx +61 -0
  47. package/src/components/PerplexityLogo.jsx +43 -0
  48. package/src/components/PinSetup.js +200 -0
  49. package/src/components/PinSetup.jsx +228 -0
  50. package/src/components/SDK_PIN_INTEGRATION_REQUIRED_CHANGES.md +526 -0
  51. package/src/components/SdkErrorBoundary.jsx +36 -0
  52. package/src/components/SecuritySetup.js +81 -0
  53. package/src/components/SessionUserBar.jsx +83 -0
  54. package/src/components/SignUp.js +123 -0
  55. package/src/components/TestTelegramButton.js +53 -0
  56. package/src/components/TrainingComponent.jsx +200 -0
  57. package/src/components/TrainingScreen.jsx +897 -0
  58. package/src/components/UniversalOnboarding.js +306 -0
  59. package/src/components/UniversalOnboarding.jsx +4837 -0
  60. package/src/components/ValentineLoadingPage.jsx +502 -0
  61. package/src/components/ValentineModeSelector.jsx +162 -0
  62. package/src/components/WelcomeScreen.jsx +435 -0
  63. package/src/components/WrappedLoadingPage.jsx +205 -0
  64. package/src/components/connectors/ChatGPTConnector.js +348 -0
  65. package/src/components/connectors/ChatGPTConnector.jsx +348 -0
  66. package/src/components/connectors/ClaudeConnector.js +44 -0
  67. package/src/components/connectors/ClaudeConnector.jsx +44 -0
  68. package/src/components/connectors/GeminiConnector.js +170 -0
  69. package/src/components/connectors/GeminiConnector.jsx +170 -0
  70. package/src/components/connectors/GmailConnector.js +148 -0
  71. package/src/components/connectors/GmailConnector.jsx +148 -0
  72. package/src/components/connectors/GrokConnector.js +16 -0
  73. package/src/components/connectors/GrokConnector.jsx +16 -0
  74. package/src/components/connectors/HingeConnector.js +419 -0
  75. package/src/components/connectors/HingeConnector.jsx +419 -0
  76. package/src/components/connectors/InstagramDataConnector.js +726 -0
  77. package/src/components/connectors/InstagramDataConnector.jsx +726 -0
  78. package/src/components/connectors/LinkedInConnector.js +4 -0
  79. package/src/components/connectors/LinkedInConnector.jsx +296 -0
  80. package/src/components/connectors/PerplexityConnector.jsx +16 -0
  81. package/src/components/connectors/PinterestConnector.js +208 -0
  82. package/src/components/connectors/PinterestConnector.jsx +208 -0
  83. package/src/components/connectors/README.md +292 -0
  84. package/src/components/connectors/RedditConnector.js +229 -0
  85. package/src/components/connectors/RedditConnector.jsx +229 -0
  86. package/src/components/connectors/SephoraConnector.js +482 -0
  87. package/src/components/connectors/SephoraConnector.jsx +482 -0
  88. package/src/components/connectors/TikTokConnector.jsx +430 -0
  89. package/src/components/connectors/YoutubeConnector.js +361 -0
  90. package/src/components/connectors/YoutubeConnector.jsx +361 -0
  91. package/src/components/connectors/index.js +50 -0
  92. package/src/components/icons.jsx +46 -0
  93. package/src/components/icons.tsx +21 -0
  94. package/src/components/ui/PageLayout.jsx +1255 -0
  95. package/src/components/ui/PrimaryButton.jsx +162 -0
  96. package/src/components/ui/button.jsx +49 -0
  97. package/src/components/ui/card.jsx +61 -0
  98. package/src/components/ui/checkbox.jsx +33 -0
  99. package/src/components/ui/label.jsx +29 -0
  100. package/src/components/utils/UpdateConnections.js +45 -0
  101. package/src/components/utils/oauthHelper.js +97 -0
  102. package/src/config/api-config.js +138 -0
  103. package/src/deepLink.jsx +38 -0
  104. package/src/getPin.js +26 -0
  105. package/src/icons/Avatar.png +0 -0
  106. package/src/icons/Sentiment.png +0 -0
  107. package/src/icons/Trait.png +0 -0
  108. package/src/iframe/DataRequestPage.jsx +285 -0
  109. package/src/iframe/OnairosButtonIntegration.md +148 -0
  110. package/src/iframe/components/Box.jsx +56 -0
  111. package/src/iframe/components/IndividualConnection.jsx +88 -0
  112. package/src/iframe/dataRequestHandler.js +714 -0
  113. package/src/iframe/data_request_iframe.html +27 -0
  114. package/src/iframe/data_request_page.js +47 -0
  115. package/src/iframe/icons/Avatar.png +1 -0
  116. package/src/iframe/icons/Avatar2.png +1 -0
  117. package/src/iframe/icons/Sentiment.png +1 -0
  118. package/src/iframe/icons/Trait.png +1 -0
  119. package/src/iframe/icons/onairos_logo.png +0 -0
  120. package/src/iframe/utils/api.js +57 -0
  121. package/src/index.js +274 -0
  122. package/src/laravel/OnairosVue.vue +410 -0
  123. package/src/laravel/blade-helpers.js +320 -0
  124. package/src/laravel/vite-plugin.js +179 -0
  125. package/src/mobile/MobileDataRequestPage.jsx +233 -0
  126. package/src/mobile/components/MobileBox.jsx +71 -0
  127. package/src/mobile/components/MobileIndividualConnection.jsx +51 -0
  128. package/src/mobile/shims/browser-apis.js +78 -0
  129. package/src/mobile/shims/lucide-shim.js +85 -0
  130. package/src/newUI/EMAIL_VERIFICATION_API_SCHEMA.md +268 -0
  131. package/src/newUI/PlatformConnectorsStep.tsx +435 -0
  132. package/src/newUI/PrimaryButton.tsx +213 -0
  133. package/src/newUI/SignInStep.tsx +194 -0
  134. package/src/newUI/VerificationStep.tsx +133 -0
  135. package/src/newUI/WelcomeScreen.tsx +311 -0
  136. package/src/newUI/services/connectedAccountsService.js +129 -0
  137. package/src/onairos.capacitor.jsx +16 -0
  138. package/src/onairos.core.jsx +133 -0
  139. package/src/onairos.jsx +14 -0
  140. package/src/onairos.native.jsx +15 -0
  141. package/src/onairosButton.jsx +9000 -0
  142. package/src/overlay/CheckBox.jsx +114 -0
  143. package/src/overlay/IndividualConnection copy.js +86 -0
  144. package/src/overlay/IndividualConnection.js +191 -0
  145. package/src/overlay/IndividualConnectionNew.jsx +157 -0
  146. package/src/overlay/box.js +84 -0
  147. package/src/overlay/overlay.js +437 -0
  148. package/src/styles/onairos-scoped-preflight.css +97 -0
  149. package/src/styles/sdkCssRegistry.js +20 -0
  150. package/src/styles/styleLoaderInsertShadow.js +69 -0
  151. package/src/styles/tailwind.capacitor.css +395 -0
  152. package/src/styles/tailwind.css +395 -0
  153. package/src/theme/colors.js +40 -0
  154. package/src/utils/apiKeyValidation.js +341 -0
  155. package/src/utils/apiResponseLogger.js +316 -0
  156. package/src/utils/authHeaders.js +275 -0
  157. package/src/utils/biometrics.js +26 -0
  158. package/src/utils/bookmarkletUtils.js +28 -0
  159. package/src/utils/capacitorDetection.js +278 -0
  160. package/src/utils/capacitorLLMHelper.js +352 -0
  161. package/src/utils/capacitorPlugins.js +366 -0
  162. package/src/utils/crossDomainSSO.js +587 -0
  163. package/src/utils/deepLinking.js +27 -0
  164. package/src/utils/devLogger.js +46 -0
  165. package/src/utils/extensionDetection.js +418 -0
  166. package/src/utils/extractMemory.js +277 -0
  167. package/src/utils/framerBrandingOverrides.js +40 -0
  168. package/src/utils/googleWebClientId.js +55 -0
  169. package/src/utils/overlayHandler.js +224 -0
  170. package/src/utils/platformDisconnect.js +309 -0
  171. package/src/utils/pollTrainingStatus.js +200 -0
  172. package/src/utils/rawMemoriesAccess.js +211 -0
  173. package/src/utils/resolveBackendAppId.js +47 -0
  174. package/src/utils/responseFormatter.js +140 -0
  175. package/src/utils/sdkDebugStorage.js +113 -0
  176. package/src/utils/sdkInitialization.js +645 -0
  177. package/src/utils/sessionManager.js +1258 -0
  178. package/src/utils/startBackgroundTraining.js +100 -0
  179. package/src/utils/userDataFormatter.js +222 -0
  180. package/index.d.ts +0 -1
  181. package/index.js +0 -1
@@ -0,0 +1,435 @@
1
+ import React, { useEffect, useState, useRef } from 'react';
2
+ import { COLORS } from '../theme/colors.js';
3
+ import { isMobileApp } from '../utils/capacitorDetection.js';
4
+ import { shouldHideOnairosLogoOnWelcomeAndEmail, getAiPlusPartnerWelcomeCopy } from '../utils/framerBrandingOverrides.js';
5
+ import OnairosWelcomeLogo from '../assets/NewLogo.png';
6
+
7
+ const normalizeAssetUrl = (asset) => {
8
+ if (typeof asset === 'string') return asset;
9
+ if (asset && typeof asset.default === 'string') return asset.default;
10
+ if (asset && typeof asset.src === 'string') return asset.src;
11
+ return '';
12
+ };
13
+
14
+ // Preload the logo image globally (runs once when module loads)
15
+ const LOGO_URL = normalizeAssetUrl(OnairosWelcomeLogo);
16
+ if (typeof window !== 'undefined') {
17
+ const preloadImg = new Image();
18
+ preloadImg.src = LOGO_URL;
19
+ }
20
+
21
+ export default function WelcomeScreen({
22
+ onContinue,
23
+ onContinueAsVerified,
24
+ onUseDifferentEmail,
25
+ preVerifiedEmail = null,
26
+ verifiedAppName = null,
27
+ continueLoading = false,
28
+ continueError = '',
29
+ onClose,
30
+ theme = 'default',
31
+ }) {
32
+ const isGlass = theme === 'glass';
33
+ const [imageLoaded, setImageLoaded] = useState(true);
34
+ const rootRef = useRef(null);
35
+ const [containerHeight, setContainerHeight] = useState(0);
36
+ const isTight = containerHeight > 0 && containerHeight <= 620;
37
+ const isVeryTight = containerHeight > 0 && containerHeight <= 540;
38
+ const hideOnairosLogo = shouldHideOnairosLogoOnWelcomeAndEmail();
39
+ const partnerWelcomeCopy = getAiPlusPartnerWelcomeCopy();
40
+ const usePartnerCopy = !!partnerWelcomeCopy;
41
+
42
+ const maskEmail = (emailStr) => {
43
+ try {
44
+ const v = String(emailStr || '').trim().toLowerCase();
45
+ if (!v || !v.includes('@')) return '';
46
+ const [local, domain] = v.split('@');
47
+ if (!local || !domain) return v;
48
+ return `${local.slice(0, 1)}*****@${domain}`;
49
+ } catch {
50
+ return '';
51
+ }
52
+ };
53
+
54
+ const hasPreVerifiedEmail = !!(preVerifiedEmail && String(preVerifiedEmail).includes('@'));
55
+ const appName = (() => {
56
+ const raw = (verifiedAppName || '').toString().trim();
57
+ return raw || 'this app';
58
+ })();
59
+
60
+ // Preload image and add preload link to head
61
+ useEffect(() => {
62
+ // In embedded environments (Capacitor/WKWebView), do NOT mutate document.head.
63
+ // Some third-party scripts (Sirv) inject global CSS resets into <head>, which "pollutes" host apps.
64
+ const isCapacitorNative = (() => {
65
+ try {
66
+ return isMobileApp() || !!window?.Capacitor?.isNativePlatform?.();
67
+ } catch {
68
+ return false;
69
+ }
70
+ })();
71
+
72
+ // Add preload link for the image
73
+ if (!isCapacitorNative) {
74
+ const existingPreload = document.querySelector(`link[href="${LOGO_URL}"]`);
75
+ if (!existingPreload) {
76
+ const preloadLink = document.createElement('link');
77
+ preloadLink.rel = 'preload';
78
+ preloadLink.as = 'image';
79
+ preloadLink.href = LOGO_URL;
80
+ document.head.appendChild(preloadLink);
81
+ }
82
+ }
83
+
84
+ // Preload via Image object for immediate cache
85
+ const img = new Image();
86
+ img.onload = () => setImageLoaded(true);
87
+ img.src = LOGO_URL;
88
+
89
+ // IMPORTANT:
90
+ // Do NOT load Sirv's JS anywhere inside the SDK.
91
+ // Sirv injects a global CSS reset into <head> (id="sirv-core-css-reset"), which can darken
92
+ // or otherwise change host-app typography (CSS pollution).
93
+ // The SDK uses plain <img> tags and does not require Sirv JS to function.
94
+ try {
95
+ const sirvReset = document.getElementById('sirv-core-css-reset');
96
+ if (sirvReset && sirvReset.parentNode) sirvReset.parentNode.removeChild(sirvReset);
97
+ } catch {}
98
+
99
+ return () => {
100
+ // Remove Sirv script (if present)
101
+ try {
102
+ const existingScript = document.querySelector('script[src="https://scripts.sirv.com/sirvjs/v3/sirv.js"]');
103
+ if (existingScript) document.head.removeChild(existingScript);
104
+ } catch {}
105
+
106
+ // Remove Sirv-injected CSS reset (if present)
107
+ try {
108
+ const sirvReset = document.getElementById('sirv-core-css-reset');
109
+ if (sirvReset && sirvReset.parentNode) sirvReset.parentNode.removeChild(sirvReset);
110
+ } catch {}
111
+ };
112
+ }, []);
113
+
114
+ // Tighten layout on short screens (e.g., iPhone SE / small landscape).
115
+ useEffect(() => {
116
+ if (!rootRef.current || typeof ResizeObserver === 'undefined') return;
117
+
118
+ const el = rootRef.current;
119
+ const ro = new ResizeObserver((entries) => {
120
+ const entry = entries && entries[0];
121
+ const h = entry?.contentRect?.height;
122
+ if (typeof h === 'number' && Number.isFinite(h)) setContainerHeight(Math.round(h));
123
+ });
124
+
125
+ ro.observe(el);
126
+ // initialize immediately
127
+ try {
128
+ setContainerHeight(Math.round(el.getBoundingClientRect().height || 0));
129
+ } catch {}
130
+
131
+ return () => ro.disconnect();
132
+ }, []);
133
+
134
+ return (
135
+ <div
136
+ ref={rootRef}
137
+ className="relative isolate w-full flex flex-col min-h-0"
138
+ style={{
139
+ height: '100%',
140
+ overflow: 'hidden',
141
+ backgroundColor: isGlass ? 'transparent' : '#ffffff',
142
+ }}
143
+ >
144
+ {/* Content - Flexible center area */}
145
+ <div
146
+ className={[
147
+ 'text-center flex-1 flex flex-col min-h-0',
148
+ // Avoid scrollbars on desktop unless absolutely necessary.
149
+ isVeryTight ? 'overflow-y-auto' : 'overflow-hidden md:overflow-visible',
150
+ ].join(' ')}
151
+ style={{
152
+ position: 'relative',
153
+ zIndex: 1,
154
+ // Bring the top stack (logo + headings) up slightly
155
+ paddingTop: isVeryTight ? 4 : (isTight ? 6 : 12),
156
+ paddingBottom: isVeryTight ? 8 : (isTight ? 10 : 14),
157
+ // Give short screens a bit more usable width to reduce wrapping (saves vertical space)
158
+ paddingLeft: isVeryTight ? 16 : 24,
159
+ paddingRight: isVeryTight ? 16 : 24,
160
+ }}
161
+ >
162
+ {/* Logo */}
163
+ {!hideOnairosLogo && (
164
+ <div
165
+ className="flex justify-center"
166
+ style={{
167
+ marginBottom: isVeryTight ? 4 : (isTight ? 6 : 8),
168
+ }}
169
+ >
170
+ <div
171
+ className="flex items-center justify-center"
172
+ style={{
173
+ width: isVeryTight ? 52 : (isTight ? 58 : 80),
174
+ height: isVeryTight ? 52 : (isTight ? 58 : 80),
175
+ borderRadius: '16px',
176
+ overflow: 'visible',
177
+ backgroundColor: 'transparent',
178
+ boxShadow: 'none',
179
+ }}
180
+ >
181
+ <img
182
+ className="w-full h-full object-contain"
183
+ src={LOGO_URL}
184
+ alt="Onairos Logo"
185
+ style={{
186
+ opacity: imageLoaded ? 1 : 0,
187
+ transition: 'opacity 0.2s ease-in',
188
+ borderRadius: 0,
189
+ }}
190
+ />
191
+ </div>
192
+ </div>
193
+ )}
194
+
195
+ {usePartnerCopy ? (
196
+ <h1
197
+ className={`font-bold text-balance ${isGlass ? 'text-white' : 'text-gray-900'}`}
198
+ style={{
199
+ fontFamily: 'IBM Plex Sans, system-ui, sans-serif',
200
+ fontSize: isVeryTight ? 22 : (isTight ? 24 : 28),
201
+ marginBottom: isVeryTight ? 10 : (isTight ? 12 : 14),
202
+ }}
203
+ >
204
+ {partnerWelcomeCopy}
205
+ </h1>
206
+ ) : (
207
+ <>
208
+ {/* Welcome Text */}
209
+ <p
210
+ className={`text-sm ${isGlass ? 'text-white/60' : 'text-gray-500'}`}
211
+ style={{
212
+ fontFamily: 'Inter, system-ui, sans-serif',
213
+ marginBottom: isVeryTight ? 2 : 6,
214
+ }}
215
+ >
216
+ Welcome to
217
+ </p>
218
+
219
+ {/* Main Title */}
220
+ <h1
221
+ className={`font-bold text-balance ${isGlass ? 'text-white' : 'text-gray-900'}`}
222
+ style={{
223
+ fontFamily: 'IBM Plex Sans, system-ui, sans-serif',
224
+ fontSize: isVeryTight ? 30 : (isTight ? 32 : 40),
225
+ marginBottom: isVeryTight ? 3 : (isTight ? 5 : 8),
226
+ }}
227
+ >
228
+ Onairos
229
+ </h1>
230
+
231
+ {/* Description */}
232
+ <p
233
+ className={`leading-relaxed text-pretty mx-auto w-full max-w-md ${isGlass ? 'text-white/70' : 'text-gray-600'}`}
234
+ style={{
235
+ fontFamily: 'Inter, system-ui, sans-serif',
236
+ // Slightly larger than before for readability
237
+ fontSize: isVeryTight ? 16 : (isTight ? 16 : 18),
238
+ marginBottom: isVeryTight ? 6 : (isTight ? 8 : 8),
239
+ }}
240
+ >
241
+ <span>This application uses Onairos to understand you.</span>
242
+ <a
243
+ href="https://onairos.io"
244
+ target="_blank"
245
+ rel="noopener noreferrer"
246
+ aria-label="Learn more about Onairos"
247
+ className={`inline-flex items-center justify-center align-middle ml-2 rounded-full border transition-colors ${isGlass ? 'border-white/30 text-white/60 hover:text-white hover:border-white/50' : 'border-gray-300 text-gray-500 hover:text-gray-700 hover:border-gray-400'}`}
248
+ style={{ width: 18, height: 18, lineHeight: 1, fontSize: 12, fontWeight: 700 }}
249
+ >
250
+ i
251
+ </a>
252
+ </p>
253
+ </>
254
+ )}
255
+
256
+ {/* Trust bullets (Plaid-style, but Onairos messaging) */}
257
+ <div
258
+ className="mx-auto w-full max-w-md text-left"
259
+ style={{ rowGap: isVeryTight ? 6 : (isTight ? 8 : 10), display: 'grid' }}
260
+ >
261
+ <div className="flex items-start gap-3">
262
+ <svg
263
+ aria-hidden="true"
264
+ width="18"
265
+ height="18"
266
+ viewBox="0 0 24 24"
267
+ fill="none"
268
+ style={{ marginTop: 2, flexShrink: 0 }}
269
+ >
270
+ <defs>
271
+ <linearGradient id="onairosCheckGrad1" x1="0" y1="0" x2="24" y2="24">
272
+ <stop offset="0%" stopColor="#60A5FA" />
273
+ <stop offset="55%" stopColor="#3B82F6" />
274
+ <stop offset="100%" stopColor="#1D4ED8" />
275
+ </linearGradient>
276
+ </defs>
277
+ <path
278
+ d="M20 6L9 17L4 12"
279
+ stroke="url(#onairosCheckGrad1)"
280
+ strokeWidth="3"
281
+ strokeLinecap="round"
282
+ strokeLinejoin="round"
283
+ />
284
+ </svg>
285
+ <div className="flex-1 min-w-0">
286
+ <div
287
+ className={`font-semibold leading-5 ${isGlass ? 'text-white' : 'text-gray-900'}`}
288
+ style={{
289
+ fontFamily: 'Inter, system-ui, sans-serif',
290
+ fontSize: isVeryTight ? 15 : 16,
291
+ }}
292
+ >
293
+ Secure
294
+ </div>
295
+ <div
296
+ className={`leading-5 ${isGlass ? 'text-white/60' : 'text-gray-600'}`}
297
+ style={{
298
+ fontFamily: 'Inter, system-ui, sans-serif',
299
+ fontSize: isVeryTight ? 13 : 14,
300
+ }}
301
+ >
302
+ End-to-end encrypted.
303
+ </div>
304
+ </div>
305
+ </div>
306
+
307
+ <div className="flex items-start gap-3">
308
+ <svg
309
+ aria-hidden="true"
310
+ width="18"
311
+ height="18"
312
+ viewBox="0 0 24 24"
313
+ fill="none"
314
+ style={{ marginTop: 2, flexShrink: 0 }}
315
+ >
316
+ <defs>
317
+ <linearGradient id="onairosCheckGrad2" x1="0" y1="0" x2="24" y2="24">
318
+ <stop offset="0%" stopColor="#60A5FA" />
319
+ <stop offset="55%" stopColor="#3B82F6" />
320
+ <stop offset="100%" stopColor="#1D4ED8" />
321
+ </linearGradient>
322
+ </defs>
323
+ <path
324
+ d="M20 6L9 17L4 12"
325
+ stroke="url(#onairosCheckGrad2)"
326
+ strokeWidth="3"
327
+ strokeLinecap="round"
328
+ strokeLinejoin="round"
329
+ />
330
+ </svg>
331
+ <div className="flex-1 min-w-0">
332
+ <div
333
+ className={`font-semibold leading-5 ${isGlass ? 'text-white' : 'text-gray-900'}`}
334
+ style={{
335
+ fontFamily: 'Inter, system-ui, sans-serif',
336
+ fontSize: isVeryTight ? 15 : 16,
337
+ }}
338
+ >
339
+ Private
340
+ </div>
341
+ <div
342
+ className={`leading-5 ${isGlass ? 'text-white/60' : 'text-gray-600'}`}
343
+ style={{
344
+ fontFamily: 'Inter, system-ui, sans-serif',
345
+ fontSize: isVeryTight ? 13 : 14,
346
+ }}
347
+ >
348
+ You control what you connect. We don't have access to your passwords.
349
+ </div>
350
+ </div>
351
+ </div>
352
+ </div>
353
+ </div>
354
+
355
+ {/* Get Started Button - Fixed at bottom */}
356
+ <div
357
+ className={`px-6 flex-shrink-0 backdrop-blur ${isGlass ? 'bg-transparent' : 'bg-white/80'}`}
358
+ style={{
359
+ position: 'relative',
360
+ zIndex: 1,
361
+ backgroundColor: isGlass ? 'transparent' : '#ffffff',
362
+ paddingTop: isVeryTight ? 8 : (isTight ? 9 : 12),
363
+ paddingBottom: `calc(${isVeryTight ? 12 : (isTight ? 14 : 20)}px + env(safe-area-inset-bottom))`,
364
+ }}
365
+ >
366
+ {continueError ? (
367
+ <p
368
+ className="text-center text-sm"
369
+ style={{
370
+ fontFamily: 'Inter, system-ui, sans-serif',
371
+ color: COLORS.error,
372
+ marginBottom: isTight ? 8 : 10,
373
+ }}
374
+ >
375
+ {continueError}
376
+ </p>
377
+ ) : null}
378
+ <button
379
+ className={`w-full rounded-full py-4 md:py-3 text-base font-medium flex items-center justify-center gap-2 transition-colors ${isGlass ? 'bg-white/15 hover:bg-white/25 text-white border border-white/20' : 'bg-gray-900 hover:bg-gray-800 text-white'}`}
380
+ style={{
381
+ fontFamily: 'Inter, system-ui, sans-serif',
382
+ // Defensive inline styles so host-app CSS/Tailwind differences cannot hide CTA in production.
383
+ display: 'flex',
384
+ width: '100%',
385
+ minHeight: 52,
386
+ borderRadius: 9999,
387
+ alignItems: 'center',
388
+ justifyContent: 'center',
389
+ gap: 8,
390
+ cursor: continueLoading ? 'not-allowed' : 'pointer',
391
+ background: isGlass ? 'rgba(255,255,255,0.15)' : '#111827',
392
+ color: isGlass ? '#ffffff' : '#ffffff',
393
+ border: isGlass ? '1px solid rgba(255,255,255,0.2)' : 'none',
394
+ opacity: continueLoading ? 0.75 : 1,
395
+ }}
396
+ onClick={hasPreVerifiedEmail ? onContinueAsVerified : onContinue}
397
+ disabled={continueLoading}
398
+ aria-label={hasPreVerifiedEmail ? 'Continue with verified email' : 'Get started with Onairos'}
399
+ >
400
+ {hasPreVerifiedEmail
401
+ ? (continueLoading ? 'Continuing…' : `Continue as ${maskEmail(preVerifiedEmail)}`)
402
+ : 'Get Started'}
403
+ <svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
404
+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 5l7 7-7 7" />
405
+ </svg>
406
+ </button>
407
+ {hasPreVerifiedEmail && (
408
+ <p
409
+ className="mt-2 w-full text-center"
410
+ style={{
411
+ fontFamily: 'Inter, system-ui, sans-serif',
412
+ fontSize: 12,
413
+ fontWeight: 400,
414
+ color: COLORS.textMuted,
415
+ }}
416
+ >
417
+ Verified by {appName}
418
+ </p>
419
+ )}
420
+ {hasPreVerifiedEmail && typeof onUseDifferentEmail === 'function' && (
421
+ <button
422
+ onClick={onUseDifferentEmail}
423
+ disabled={continueLoading}
424
+ className={`w-full text-center text-sm font-medium transition-colors ${isGlass ? 'text-white/50 hover:text-white/80' : 'text-gray-500 hover:text-gray-700'}`}
425
+ style={{ fontFamily: 'Inter, system-ui, sans-serif' }}
426
+ // tighten spacing on very small screens
427
+ {...(isVeryTight ? { } : {})}
428
+ >
429
+ Use a different email
430
+ </button>
431
+ )}
432
+ </div>
433
+ </div>
434
+ );
435
+ }
@@ -0,0 +1,205 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import Lottie from 'lottie-react';
3
+
4
+ export default function WrappedLoadingPage({ appName, isComplete = false, onTransitionComplete }) {
5
+ console.log('🎨 WrappedLoadingPage rendered with props:', { appName, isComplete });
6
+
7
+ // CRITICAL: Do not render anything for non-wrapped apps
8
+ // This component should NEVER be called for non-wrapped apps
9
+ const isWrappedApp = appName && appName.toLowerCase().includes('wrapped');
10
+
11
+ if (!isWrappedApp) {
12
+ console.warn('⚠️ WrappedLoadingPage should not be rendered for non-wrapped app:', appName);
13
+ return null;
14
+ }
15
+
16
+ const [animationData, setAnimationData] = useState(null);
17
+ const [progress, setProgress] = useState(0);
18
+ const [messageIndex, setMessageIndex] = useState(0);
19
+ const [isAnimatingToComplete, setIsAnimatingToComplete] = useState(false);
20
+
21
+ // Whimsical rotating messages
22
+ const messages = [
23
+ "Reading your mind...",
24
+ "Connecting the dots...",
25
+ "Brewing insights...",
26
+ "Decoding your vibe...",
27
+ "Piecing together your story...",
28
+ "Finding patterns in the chaos...",
29
+ "Translating data to wisdom...",
30
+ "Analyzing your digital footprint...",
31
+ "Your digital fingerprint is unique...",
32
+ "Generating personalized metrics...",
33
+ "Almost done thinking...",
34
+ "Polishing the final details...",
35
+ "Applying finishing touches...",
36
+ "Preparing your wrapped report..."
37
+ ];
38
+
39
+ useEffect(() => {
40
+ // Fetch the animation JSON from public folder
41
+ fetch('/rain-anim.json')
42
+ .then(res => res.json())
43
+ .then(data => setAnimationData(data))
44
+ .catch(err => {
45
+ console.error('Failed to load rain animation:', err);
46
+ // Fallback: try from the npm package public folder
47
+ fetch('https://onairos.sirv.com/rain-anim.json')
48
+ .then(res => res.json())
49
+ .then(data => setAnimationData(data))
50
+ .catch(err2 => console.error('Failed to load rain animation from fallback:', err2));
51
+ });
52
+ }, []);
53
+
54
+ // Animate progress bar over ~2 minutes (API can take 1-3 minutes)
55
+ useEffect(() => {
56
+ // Don't animate if we're already animating to complete
57
+ if (isAnimatingToComplete) return;
58
+
59
+ const duration = 120000; // 2 minutes in ms
60
+ const interval = 100; // Update every 100ms
61
+ const increment = (interval / duration) * 100;
62
+
63
+ const timer = setInterval(() => {
64
+ setProgress(prev => {
65
+ const next = prev + increment;
66
+ // Cap at 95% to avoid reaching 100% before API completes
67
+ return next >= 95 ? 95 : next;
68
+ });
69
+ }, interval);
70
+
71
+ return () => clearInterval(timer);
72
+ }, [isAnimatingToComplete]);
73
+
74
+ // When isComplete becomes true, animate progress to 100%
75
+ useEffect(() => {
76
+ if (!isComplete || isAnimatingToComplete) return;
77
+
78
+ console.log('🎁 Wrapped data ready - animating progress to 100%');
79
+ setIsAnimatingToComplete(true);
80
+
81
+ // Animate from current progress to 100% over 500ms
82
+ const startProgress = progress;
83
+ const duration = 500;
84
+ const startTime = Date.now();
85
+
86
+ const animateToComplete = () => {
87
+ const elapsed = Date.now() - startTime;
88
+ const t = Math.min(elapsed / duration, 1);
89
+
90
+ // Ease out animation
91
+ const eased = 1 - Math.pow(1 - t, 3);
92
+ const currentProgress = startProgress + (100 - startProgress) * eased;
93
+
94
+ setProgress(currentProgress);
95
+
96
+ if (t < 1) {
97
+ requestAnimationFrame(animateToComplete);
98
+ } else {
99
+ // Animation complete - wait a brief moment then notify parent
100
+ setTimeout(() => {
101
+ console.log('✅ Progress reached 100% - notifying parent');
102
+ if (onTransitionComplete) {
103
+ onTransitionComplete();
104
+ }
105
+ }, 200);
106
+ }
107
+ };
108
+
109
+ requestAnimationFrame(animateToComplete);
110
+ }, [isComplete, isAnimatingToComplete, progress, onTransitionComplete]);
111
+
112
+ // Rotate messages every 4 seconds
113
+ useEffect(() => {
114
+ const messageTimer = setInterval(() => {
115
+ setMessageIndex(prev => (prev + 1) % messages.length);
116
+ }, 4000);
117
+
118
+ return () => clearInterval(messageTimer);
119
+ }, []);
120
+
121
+ return (
122
+ <div className="flex flex-col items-center justify-center h-full px-4 py-4 md:px-6 overflow-hidden">
123
+ {/* Content is centered vertically inside the modal card */}
124
+ <div className="flex flex-col items-center justify-center w-full max-w-2xl space-y-2 md:space-y-4 h-full max-h-[600px]">
125
+ {/* Title */}
126
+ <div className="text-center flex-shrink-0 mt-0">
127
+ <h2 className="text-lg md:text-2xl font-semibold text-gray-900 mb-1">
128
+ {isWrappedApp ? 'Updating your digital brain for 2025...' : 'Processing your data...'}
129
+ </h2>
130
+ <p className="text-xs md:text-sm text-gray-600 px-4">
131
+ {isWrappedApp ? 'Crafting your personalized insights from your digital footprint' : 'This will just take a moment'}
132
+ </p>
133
+ </div>
134
+
135
+ {/* Lottie Animation */}
136
+ {animationData ? (
137
+ <div className="w-full max-w-[200px] md:max-w-[260px] mx-auto flex-shrink-1 min-h-0 aspect-square flex items-center justify-center">
138
+ <Lottie
139
+ animationData={animationData}
140
+ loop={true}
141
+ autoplay={true}
142
+ className="w-full h-full"
143
+ />
144
+ </div>
145
+ ) : (
146
+ <div className="w-full max-w-sm h-32 md:h-48 flex items-center justify-center flex-shrink-0">
147
+ <div className="animate-spin rounded-full h-10 w-10 md:h-12 md:w-12 border-b-2 border-gray-900"></div>
148
+ </div>
149
+ )}
150
+
151
+ {/* Black and White Loading Bar - Below Lottie */}
152
+ <div className="w-full max-w-md px-2 flex-shrink-0">
153
+ <div className="flex justify-between text-xs font-medium text-gray-600 mb-2 px-1">
154
+ <span>Analyzing data...</span>
155
+ <span>{Math.round(progress)}%</span>
156
+ </div>
157
+
158
+ <div className="relative w-full h-4 bg-gray-200 rounded-full overflow-hidden border border-gray-100 shadow-inner">
159
+ <div
160
+ className="absolute top-0 left-0 h-full bg-gray-900 rounded-full transition-all duration-300 ease-out flex items-center justify-end pr-2"
161
+ style={{
162
+ width: `${progress}%`
163
+ }}
164
+ >
165
+ {/* Optional: Add a subtle shine/pulse effect */}
166
+ <div className="w-full h-full absolute inset-0 bg-white/10 animate-pulse"></div>
167
+ </div>
168
+ </div>
169
+
170
+ {/* Rotating message with fade transition */}
171
+ <div className="h-8 mt-4 flex items-center justify-center">
172
+ <p
173
+ key={messageIndex}
174
+ className="text-center text-sm font-semibold text-gray-800 animate-fadeIn"
175
+ style={{
176
+ animation: 'fadeIn 0.5s ease-in-out'
177
+ }}
178
+ >
179
+ {messages[messageIndex]}
180
+ </p>
181
+ </div>
182
+
183
+ {/* Explicit wait message - Minimal Design */}
184
+ <div className="mt-5 flex flex-col items-center gap-1.5 max-w-sm mx-auto">
185
+ <div className="h-px w-12 bg-gradient-to-r from-transparent via-gray-300 to-transparent mb-1.5"></div>
186
+ <p className="text-xs text-gray-600 text-center leading-relaxed font-medium">
187
+ This runs a complex AI model and takes about 1-3 minutes.
188
+ </p>
189
+ <p className="text-xs text-gray-600 text-center font-medium">
190
+ Feel free to grab a coffee while we cook! ☕️
191
+ </p>
192
+ </div>
193
+ </div>
194
+
195
+ <style>{`
196
+ @keyframes fadeIn {
197
+ 0% { opacity: 0; transform: translateY(-4px); }
198
+ 100% { opacity: 1; transform: translateY(0); }
199
+ }
200
+ `}</style>
201
+ </div>
202
+ </div>
203
+ );
204
+ }
205
+