@onairosofficial/onairos-capacitor 0.1.3 → 0.1.5
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.
- package/OnairosofficialOnairosCapacitor.podspec +1 -1
- package/README.md +1 -1
- package/dist/onairos.capacitor.esm.js +509 -1
- package/dist/onairos.capacitor.esm.turbopack.js +509 -1
- package/ios/Sources/OnairosNativeConnectorsPlugin/OnairosChatGPTNativePlugin.swift +187 -945
- package/ios/Sources/OnairosNativeConnectorsPlugin/OnairosRNScrapers.swift +1800 -0
- package/ios/Sources/OnairosNativeConnectorsPlugin/OnairosSpotifyNativePlugin.swift +180 -629
- package/onairos.d.ts +24 -0
- package/package.json +5 -2
- package/src/assets/connectors/Linkedinicon.png +0 -0
- package/src/assets/connectors/Redditicon.png +0 -0
- package/src/assets/connectors/YouTubeicon2.png +0 -0
- package/src/assets/connectors/chatgpt.png +0 -0
- package/src/assets/connectors/claude.png +0 -0
- package/src/assets/connectors/instagram.png +0 -0
- package/src/assets/connectors/netflix.png +0 -0
- package/src/assets/connectors/pinterest.png +0 -0
- package/src/assets/connectors/sephora.png +0 -0
- package/src/assets/connectors/spotify.png +0 -0
- package/src/assets/connectors/tiktok.png +0 -0
- package/src/assets/permissions/onairos.png +0 -0
- package/src/assets/permissions/personalization.png +0 -0
- package/src/assets/permissions/public-profile-person.png +0 -0
- package/src/assets/permissions/raw-memories.png +0 -0
- package/src/capacitorConnectorCatalog.js +2 -6
- package/src/components/DataRequest.jsx +96 -532
- package/src/components/EmailAuth.jsx +4 -116
- package/src/components/PinSetup.jsx +39 -226
- package/src/components/SDKDesignPreview.jsx +33 -0
- package/src/components/SessionUserBar.jsx +2 -1
- package/src/components/TrainingScreen.jsx +18 -12
- package/src/components/UniversalOnboarding.jsx +191 -424
- package/src/components/WelcomeScreen.jsx +19 -12
- package/src/components/parity/NativeConnections.jsx +136 -0
- package/src/components/parity/NativeScreens.jsx +48 -0
- package/src/components/ui/PageLayout.jsx +7 -3
- package/src/nativeImport/ConnectorLoading.jsx +13 -0
- package/src/nativeImport/CustomImportSession.js +115 -0
- package/src/nativeImport/ImportIcon.jsx +29 -0
- package/src/nativeImport/ImportProgress.jsx +24 -0
- package/src/nativeImport/ImportStatus.jsx +9 -0
- package/src/nativeImport/NativeChatImport.jsx +28 -0
- package/src/nativeImport/NativeImportSession.js +123 -0
- package/src/nativeImport/NativeScraperImport.jsx +57 -0
- package/src/nativeImport/SmartFilter.jsx +28 -0
- package/src/nativeImport/customPayload.js +37 -0
- package/src/nativeImport/netflixExport.js +30 -0
- package/src/nativeImport/netflixHistory.js +28 -0
- package/src/nativeImport/netflixSession.js +59 -0
- package/src/nativeImport/rawHandoff.js +7 -0
- package/src/nativeImport/rn/config/api.js +5 -0
- package/src/nativeImport/rn/services/apiKeyService.js +2 -0
- package/src/nativeImport/rn/services/hingePayload.js +37 -0
- package/src/nativeImport/rn/services/nativeConversationImport.js +138 -0
- package/src/nativeImport/rn/services/nativeFileTransfer.js +127 -0
- package/src/nativeImport/rn/services/nativeRawRedaction.js +136 -0
- package/src/nativeImport/rn/services/netflixPayload.js +70 -0
- package/src/nativeImport/rn/services/rawMemoryPolicy.js +38 -0
- package/src/nativeImport/rn/services/sephoraPayload.js +166 -0
- package/src/nativeImport/rn/services/spotifyPayload.js +99 -0
- package/src/nativeImport/rn/source-manifest.json +45 -0
- package/src/nativeImport/rn/utils/importedFiles.js +74 -0
- package/src/nativeImport/rn/utils/nativeImportDates.js +45 -0
- package/src/nativeImport/rn/utils/nativeImportFileReceiver.js +51 -0
- package/src/nativeImport/rn/utils/nativeImportMetadata.js +74 -0
- package/src/nativeImport/rn/utils/nativeImportTopics.js +56 -0
- package/src/nativeImport/rn/utils/rawExportDelivery.js +12 -0
- package/src/nativeImport/rn/utils/webviewScripts/chatgptDiscovery.js +99 -0
- package/src/nativeImport/rn/utils/webviewScripts/claude.js +349 -0
- package/src/nativeImport/rn/utils/webviewScripts/gemini.js +356 -0
- package/src/nativeImport/rn/utils/webviewScripts/hinge.js +375 -0
- package/src/nativeImport/rn/utils/webviewScripts/instagram.js +152 -0
- package/src/nativeImport/rn/utils/webviewScripts/linkedin.js +825 -0
- package/src/nativeImport/rn/utils/webviewScripts/nativeChatGPTImport.js +202 -0
- package/src/nativeImport/rn/utils/webviewScripts/nativeChatGPTSession.js +63 -0
- package/src/nativeImport/rn/utils/webviewScripts/nativeImportFiles.js +132 -0
- package/src/nativeImport/rn/utils/webviewScripts/nativeImportProviders.js +80 -0
- package/src/nativeImport/rn/utils/webviewScripts/nativeLoginViewport.js +28 -0
- package/src/nativeImport/rn/utils/webviewScripts/netflix.js +257 -0
- package/src/nativeImport/rn/utils/webviewScripts/sephora.js +862 -0
- package/src/nativeImport/rn/utils/webviewScripts/sephoraSession.js +160 -0
- package/src/nativeImport/rn/utils/webviewScripts/spotify.js +1868 -0
- package/src/nativeImport/rn/utils/webviewScripts/telegram.js +630 -0
- package/src/nativeImport/rn/utils/webviewScripts/tiktok.js +2920 -0
- package/src/onairos.capacitor.jsx +14 -2
- package/src/onairos.core.jsx +3 -0
- package/src/onairosButton.jsx +23 -17
- package/src/styles/onairos-fonts.css +20 -0
- package/src/styles/onairos-native.css +709 -0
- package/src/styles/onairos-rn-parity.css +175 -0
- package/src/styles/sdkCssRegistry.js +83 -1
- package/src/styles/tailwind.capacitor.css +6 -0
- package/src/utils/capacitorPlugins.js +20 -12
- package/src/utils/nativeConnectorSession.js +18 -0
- package/src/utils/parityPolicy.js +41 -0
|
@@ -1,150 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {NativeConsent} from './parity/NativeScreens.jsx';
|
|
2
|
+
import {approvedScopes, requestedScopes, platformKey} from '../utils/parityPolicy.js';
|
|
3
|
+
import React, { useState, useEffect, useCallback, useMemo, useRef } from "react";
|
|
2
4
|
import { API_CONFIG } from '../config/api-config';
|
|
3
5
|
import SessionUserBar from './SessionUserBar.jsx';
|
|
4
6
|
import { PERPLEXITY_LOGO_DATA_URI } from './PerplexityLogo.jsx';
|
|
5
|
-
import OnairosLogo from '../assets/NewLogo.png';
|
|
6
|
-
// import personaImg from "../assets/persona.png";
|
|
7
|
-
// Use remote URL to avoid 403 Forbidden on local asset during dev/prod mismatch
|
|
8
|
-
const personaImg = "https://anushkasirv.sirv.com/persona.jpg";
|
|
9
7
|
|
|
10
8
|
/* -------------------------
|
|
11
9
|
ICON COMPONENTS
|
|
12
10
|
-------------------------- */
|
|
13
|
-
const Icon = ({ type, isGlass }) => {
|
|
14
|
-
const base = `w-4 h-4 ${isGlass ? 'text-white/70' : 'text-gray-700'}`;
|
|
15
|
-
|
|
16
|
-
switch (type) {
|
|
17
|
-
case "User":
|
|
18
|
-
return (
|
|
19
|
-
<svg className={base} viewBox="0 0 24 24" fill="currentColor">
|
|
20
|
-
<path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/>
|
|
21
|
-
</svg>
|
|
22
|
-
);
|
|
23
|
-
case "Memory":
|
|
24
|
-
return (
|
|
25
|
-
<svg className={base} viewBox="0 0 24 24" fill="currentColor">
|
|
26
|
-
<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"/>
|
|
27
|
-
</svg>
|
|
28
|
-
);
|
|
29
|
-
case "Grid3X3":
|
|
30
|
-
return (
|
|
31
|
-
<svg className={base} viewBox="0 0 24 24" fill="currentColor">
|
|
32
|
-
<path d="M3 13h8V3H3v10zm0 8h8v-6H3v6zm10 0h8V11h-8v10zm0-18v6h8V3h-8z"/>
|
|
33
|
-
</svg>
|
|
34
|
-
);
|
|
35
|
-
case "Brain":
|
|
36
|
-
return (
|
|
37
|
-
<svg className={base} viewBox="0 0 24 24" fill="currentColor">
|
|
38
|
-
<path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm3.5-9c.83 0 1.5-.67 1.5-1.5S16.33 8 15.5 8 14 8.67 14 9.5s.67 1.5 1.5 1.5zm-7 0c.83 0 1.5-.67 1.5-1.5S9.33 8 8.5 8 7 8.67 7 9.5 7.67 11 8.5 11zm3.5 6.5c2.33 0 4.31-1.46 5.11-3.5H6.89c.8 2.04 2.78 3.5 5.11 3.5z"/>
|
|
39
|
-
</svg>
|
|
40
|
-
);
|
|
41
|
-
default:
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
/* -------------------------
|
|
47
|
-
TOGGLE (soft apple style)
|
|
48
|
-
-------------------------- */
|
|
49
|
-
const DataTypeToggle = React.memo(({ dataType, enabled, onToggle, isNative, isGlass }) => {
|
|
50
|
-
const isDisabled = dataType.required || dataType.disabled;
|
|
51
|
-
|
|
52
|
-
const handle = useCallback(() => {
|
|
53
|
-
if (isDisabled) return;
|
|
54
|
-
onToggle(dataType.id, !enabled);
|
|
55
|
-
}, [dataType.id, enabled, isDisabled, onToggle]);
|
|
56
|
-
|
|
57
|
-
const title = useMemo(() => {
|
|
58
|
-
if (dataType.required) return 'Required - cannot be disabled';
|
|
59
|
-
if (dataType.disabled && dataType.disabledReason) return dataType.disabledReason;
|
|
60
|
-
return '';
|
|
61
|
-
}, [dataType.disabled, dataType.disabledReason, dataType.required]);
|
|
62
|
-
|
|
63
|
-
const checkboxVisualStyle = useMemo(() => ({
|
|
64
|
-
width: 20,
|
|
65
|
-
height: 20,
|
|
66
|
-
borderRadius: 6,
|
|
67
|
-
borderWidth: 2,
|
|
68
|
-
borderStyle: 'solid',
|
|
69
|
-
borderColor: dataType.disabled
|
|
70
|
-
? (isGlass ? 'rgba(255,255,255,0.28)' : '#D1D5DB')
|
|
71
|
-
: enabled
|
|
72
|
-
? (isGlass ? 'rgba(255,255,255,0.55)' : '#111827')
|
|
73
|
-
: (isGlass ? 'rgba(255,255,255,0.75)' : '#4B5563'),
|
|
74
|
-
backgroundColor: dataType.disabled
|
|
75
|
-
? (isGlass ? 'rgba(255,255,255,0.06)' : '#F3F4F6')
|
|
76
|
-
: enabled
|
|
77
|
-
? (isGlass ? 'rgba(255,255,255,0.22)' : '#111827')
|
|
78
|
-
: '#FFFFFF',
|
|
79
|
-
boxShadow: enabled || dataType.disabled
|
|
80
|
-
? '0 1px 2px rgba(17,24,39,0.12)'
|
|
81
|
-
: `0 0 0 1px ${isGlass ? 'rgba(255,255,255,0.28)' : 'rgba(17,24,39,0.16)'}, inset 0 0 0 1px rgba(255,255,255,0.85)`,
|
|
82
|
-
outline: 'none',
|
|
83
|
-
opacity: 1,
|
|
84
|
-
WebkitAppearance: 'none',
|
|
85
|
-
appearance: 'none',
|
|
86
|
-
WebkitTextFillColor: 'currentColor',
|
|
87
|
-
}), [dataType.disabled, enabled, isGlass]);
|
|
88
|
-
|
|
89
|
-
return (
|
|
90
|
-
<button
|
|
91
|
-
onClick={handle}
|
|
92
|
-
className={`
|
|
93
|
-
w-full flex items-center justify-between
|
|
94
|
-
py-2.5 px-3
|
|
95
|
-
${isGlass ? 'bg-white/10' : 'bg-white/40 backdrop-blur-sm'}
|
|
96
|
-
${isDisabled ? 'cursor-not-allowed opacity-50' : isGlass ? 'hover:bg-white/20 cursor-pointer' : 'hover:bg-white/70 cursor-pointer'}
|
|
97
|
-
transition rounded-xl shadow-sm
|
|
98
|
-
`}
|
|
99
|
-
style={{ maxWidth: '100%', minWidth: 0, boxSizing: 'border-box' }}
|
|
100
|
-
title={title}
|
|
101
|
-
disabled={dataType.disabled}
|
|
102
|
-
>
|
|
103
|
-
<div className="flex items-center gap-2.5 flex-1 min-w-0">
|
|
104
|
-
<div className={`w-7 h-7 flex items-center justify-center rounded-full flex-shrink-0 ${dataType.disabled ? (isGlass ? 'bg-white/5' : 'bg-gray-200') : (isGlass ? 'bg-white/10' : 'bg-gray-100')}`}>
|
|
105
|
-
<Icon type={dataType.icon} isGlass={isGlass} />
|
|
106
|
-
</div>
|
|
107
|
-
<div className="flex flex-col items-start min-w-0">
|
|
108
|
-
<span className={`${isNative ? 'text-[14px]' : 'text-[13px]'} font-medium ${dataType.disabled ? (isGlass ? 'text-white/40' : 'text-gray-400') : (isGlass ? 'text-white' : 'text-gray-900')}`} style={{ fontFamily: 'Inter, system-ui, sans-serif' }}>
|
|
109
|
-
{dataType.name}
|
|
110
|
-
{dataType.required && <span className={`ml-1.5 text-[11px] ${isGlass ? 'text-white/50' : 'text-gray-500'}`}>(Required)</span>}
|
|
111
|
-
</span>
|
|
112
|
-
{dataType.description && (
|
|
113
|
-
<span className={`text-[11px] leading-tight ${dataType.disabled ? (isGlass ? 'text-white/30' : 'text-gray-400') : (isGlass ? 'text-white/50' : 'text-gray-500')}`} style={{ fontFamily: 'Inter, system-ui, sans-serif' }}>
|
|
114
|
-
{dataType.description}
|
|
115
|
-
</span>
|
|
116
|
-
)}
|
|
117
|
-
</div>
|
|
118
|
-
</div>
|
|
119
|
-
|
|
120
|
-
<div
|
|
121
|
-
className={`w-5 h-5 rounded-md border-2 flex items-center justify-center shadow-sm flex-shrink-0 ml-2
|
|
122
|
-
transition
|
|
123
|
-
${dataType.disabled
|
|
124
|
-
? isGlass ? "bg-white/5 border-white/20" : "bg-gray-100 border-gray-300"
|
|
125
|
-
: enabled
|
|
126
|
-
? isGlass ? "bg-white/20 border-white/30" : "bg-gray-900 border-gray-900"
|
|
127
|
-
: isGlass ? "bg-transparent border-white/60" : "bg-white border-gray-500"
|
|
128
|
-
}`}
|
|
129
|
-
style={checkboxVisualStyle}
|
|
130
|
-
>
|
|
131
|
-
{enabled && !dataType.disabled && (
|
|
132
|
-
<svg className="w-3 h-3 text-white" style={{ color: '#FFFFFF', WebkitTextFillColor: '#FFFFFF' }} viewBox="0 0 20 20" fill="currentColor">
|
|
133
|
-
<path d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z"/>
|
|
134
|
-
</svg>
|
|
135
|
-
)}
|
|
136
|
-
</div>
|
|
137
|
-
</button>
|
|
138
|
-
);
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
DataTypeToggle.displayName = 'DataTypeToggle';
|
|
142
|
-
|
|
143
|
-
/* -------------------------
|
|
144
|
-
MAIN COMPONENT
|
|
145
|
-
-------------------------- */
|
|
146
11
|
|
|
147
|
-
/** Sources that can back “Raw Memories” (LLMs + retail/media raw pipelines). */
|
|
148
12
|
const RAW_MEMORY_SOURCE_KEYS = new Set([
|
|
149
13
|
'chatgpt',
|
|
150
14
|
'claude',
|
|
@@ -156,13 +20,7 @@ const RAW_MEMORY_SOURCE_KEYS = new Set([
|
|
|
156
20
|
'sephora',
|
|
157
21
|
]);
|
|
158
22
|
|
|
159
|
-
|
|
160
|
-
'chatgpt',
|
|
161
|
-
'claude',
|
|
162
|
-
'gemini',
|
|
163
|
-
'grok',
|
|
164
|
-
'perplexity',
|
|
165
|
-
]);
|
|
23
|
+
|
|
166
24
|
|
|
167
25
|
const X_LOGO_SVG =
|
|
168
26
|
'data:image/svg+xml,%3Csvg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"%3E%3Cpath fill="%23000000" d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"/%3E%3C/svg%3E';
|
|
@@ -220,8 +78,8 @@ const getOptions = (appName, hasRawMemorySources) => [
|
|
|
220
78
|
},
|
|
221
79
|
];
|
|
222
80
|
|
|
223
|
-
const DataRequest = ({ appName = "My App", onComplete, onConnectMoreApps, connectedPlatforms =
|
|
224
|
-
|
|
81
|
+
const DataRequest = ({ appName = "My App", onComplete, onDecline, onConnectMoreApps, connectedPlatforms = null, showTime = false, userEmail = null, onLogout = null, appIcon = null, customTitle = null, theme = 'default', rawMemoriesOnly = false, rawMemoriesConfig = null, requestData = null, allowedPlatforms = null, rawMemoriesOffered = null, privacyPolicyUrl = 'https://privacy.onairos.io', allowContinueWithoutConnections = false, demoMode = false }) => {
|
|
82
|
+
|
|
225
83
|
// One-checkbox model: basic is required, personalization is the single opt-out choice
|
|
226
84
|
// (pre-selected for lower friction), raw memories is an opt-in second choice when available.
|
|
227
85
|
const [selected, setSelected] = useState({
|
|
@@ -229,9 +87,9 @@ const DataRequest = ({ appName = "My App", onComplete, onConnectMoreApps, connec
|
|
|
229
87
|
personalization: true,
|
|
230
88
|
rawMemories: false,
|
|
231
89
|
});
|
|
232
|
-
|
|
90
|
+
|
|
233
91
|
const normalizedRequestData = useMemo(
|
|
234
|
-
() => (
|
|
92
|
+
() => requestedScopes(requestData)?.map(scope => scope.toLowerCase()) ?? null,
|
|
235
93
|
[requestData]
|
|
236
94
|
);
|
|
237
95
|
|
|
@@ -239,34 +97,10 @@ const DataRequest = ({ appName = "My App", onComplete, onConnectMoreApps, connec
|
|
|
239
97
|
const [platformIconFailed, setPlatformIconFailed] = useState({});
|
|
240
98
|
const [platforms, setPlatforms] = useState(() => getConnected());
|
|
241
99
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
100
|
+
const submittingRef = useRef(false);
|
|
101
|
+
const [submitError, setSubmitError] = useState('');
|
|
102
|
+
|
|
242
103
|
|
|
243
|
-
const isWrappedApp = typeof appName === 'string' && appName.toLowerCase().includes('wrapped');
|
|
244
|
-
|
|
245
|
-
// Debug: Log props on mount
|
|
246
|
-
useEffect(() => {
|
|
247
|
-
console.log('🔍 [DATAREQUEST-MOUNT] Props received:', {
|
|
248
|
-
userEmail,
|
|
249
|
-
connectedPlatforms,
|
|
250
|
-
appName,
|
|
251
|
-
hasUserEmail: !!userEmail,
|
|
252
|
-
connectedPlatformsType: typeof connectedPlatforms,
|
|
253
|
-
connectedPlatformsIsArray: Array.isArray(connectedPlatforms),
|
|
254
|
-
connectedPlatformsLength: Array.isArray(connectedPlatforms) ? connectedPlatforms.length : 'N/A'
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
// Also check localStorage
|
|
258
|
-
try {
|
|
259
|
-
const u = JSON.parse(localStorage.getItem("onairosUser") || "{}");
|
|
260
|
-
console.log('🔍 [DATAREQUEST-MOUNT] localStorage onairosUser:', {
|
|
261
|
-
email: u.email,
|
|
262
|
-
connectedAccounts: u.connectedAccounts,
|
|
263
|
-
hasConnectedAccounts: !!u.connectedAccounts,
|
|
264
|
-
connectedAccountsLength: Array.isArray(u.connectedAccounts) ? u.connectedAccounts.length : 'N/A'
|
|
265
|
-
});
|
|
266
|
-
} catch (e) {
|
|
267
|
-
console.error('❌ Failed to read localStorage:', e);
|
|
268
|
-
}
|
|
269
|
-
}, []); // Run only once on mount
|
|
270
104
|
|
|
271
105
|
// Normalize platform ids/names coming from different sources (SDK, backend, localStorage)
|
|
272
106
|
// so logos always render (e.g. "linkedin" -> "LinkedIn").
|
|
@@ -274,7 +108,7 @@ const DataRequest = ({ appName = "My App", onComplete, onConnectMoreApps, connec
|
|
|
274
108
|
const key = String(p || '').trim();
|
|
275
109
|
// Reject pure-numeric strings (leaked array indices)
|
|
276
110
|
if (/^\d+$/.test(key)) return '';
|
|
277
|
-
const lower = key
|
|
111
|
+
const lower = platformKey(key);
|
|
278
112
|
const map = {
|
|
279
113
|
instagram: 'Instagram',
|
|
280
114
|
youtube: 'YouTube',
|
|
@@ -300,22 +134,16 @@ const DataRequest = ({ appName = "My App", onComplete, onConnectMoreApps, connec
|
|
|
300
134
|
}
|
|
301
135
|
|
|
302
136
|
function platformKeyForFilter(displayName) {
|
|
303
|
-
return
|
|
137
|
+
return platformKey(displayName);
|
|
304
138
|
}
|
|
305
139
|
|
|
306
140
|
/** When `allowedPlatforms` is set, at least one must be a raw-memory pipeline (LLM / Netflix / Spotify / Sephora). */
|
|
307
|
-
|
|
308
|
-
if (!allowedSet || allowedSet.size === 0) return true;
|
|
309
|
-
for (const k of allowedSet) {
|
|
310
|
-
if (RAW_MEMORY_SOURCE_KEYS.has(k)) return true;
|
|
311
|
-
}
|
|
312
|
-
return false;
|
|
313
|
-
}
|
|
141
|
+
|
|
314
142
|
|
|
315
143
|
/** User has a connected raw-capable account; if allowlist is set, that connection must be on it. */
|
|
316
144
|
function userHasConnectedRawSourceInAllowlist(connectedList, allowedSet) {
|
|
317
145
|
const list = Array.isArray(connectedList) ? connectedList : [];
|
|
318
|
-
if (!allowedSet
|
|
146
|
+
if (!allowedSet) {
|
|
319
147
|
return list.some((p) => RAW_MEMORY_SOURCE_KEYS.has(platformKeyForFilter(p)));
|
|
320
148
|
}
|
|
321
149
|
return list.some((p) => {
|
|
@@ -324,23 +152,13 @@ const DataRequest = ({ appName = "My App", onComplete, onConnectMoreApps, connec
|
|
|
324
152
|
});
|
|
325
153
|
}
|
|
326
154
|
|
|
327
|
-
|
|
328
|
-
const list = Array.isArray(connectedList) ? connectedList : [];
|
|
329
|
-
if (!allowedSet || allowedSet.size === 0) {
|
|
330
|
-
return list.some((p) => LLM_RAW_MEMORY_SOURCE_KEYS.has(platformKeyForFilter(p)));
|
|
331
|
-
}
|
|
332
|
-
return list.some((p) => {
|
|
333
|
-
const k = platformKeyForFilter(p);
|
|
334
|
-
return LLM_RAW_MEMORY_SOURCE_KEYS.has(k) && allowedSet.has(k);
|
|
335
|
-
});
|
|
336
|
-
}
|
|
155
|
+
|
|
337
156
|
|
|
338
157
|
/** Raw row only if export is offered for this app and developer opted in explicitly. */
|
|
339
158
|
function developerExplicitlyWantsRawMemoriesInUI() {
|
|
340
159
|
if (rawMemoriesOffered === false) return false;
|
|
341
160
|
if (rawMemoriesOnly || rawMemoriesConfig != null) return true;
|
|
342
161
|
if (requestData == null) return false;
|
|
343
|
-
if (!Array.isArray(requestData) || requestData.length === 0) return false;
|
|
344
162
|
return !!(normalizedRequestData && normalizedRequestData.includes('rawmemories'));
|
|
345
163
|
}
|
|
346
164
|
|
|
@@ -488,26 +306,23 @@ const DataRequest = ({ appName = "My App", onComplete, onConnectMoreApps, connec
|
|
|
488
306
|
|
|
489
307
|
return { hasField: sawField, platforms: [] };
|
|
490
308
|
} catch (e) {
|
|
491
|
-
console.error('
|
|
309
|
+
console.error('[Onairos] Request failed.');
|
|
492
310
|
return { hasField: false, platforms: [] };
|
|
493
311
|
}
|
|
494
312
|
}
|
|
495
313
|
|
|
496
|
-
|
|
314
|
+
|
|
497
315
|
|
|
498
316
|
// Ensure we actually show connected platforms even if prop isn't passed
|
|
499
317
|
function getConnected() {
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
type: typeof connectedPlatforms
|
|
504
|
-
});
|
|
505
|
-
|
|
318
|
+
if (Array.isArray(connectedPlatforms)) return normalizePlatformList(connectedPlatforms);
|
|
319
|
+
|
|
320
|
+
|
|
506
321
|
// Prefer non-empty localStorage snapshots: UniversalOnboarding updates them on OAuth return.
|
|
507
322
|
// If localStorage only has an empty/stale field, keep falling through to props/backend.
|
|
508
323
|
const localSnapshot = readLocalConnectedSnapshot();
|
|
509
324
|
if (localSnapshot.platforms.length > 0) {
|
|
510
|
-
|
|
325
|
+
|
|
511
326
|
return localSnapshot.platforms;
|
|
512
327
|
}
|
|
513
328
|
|
|
@@ -515,22 +330,22 @@ const DataRequest = ({ appName = "My App", onComplete, onConnectMoreApps, connec
|
|
|
515
330
|
// If array provided, use it
|
|
516
331
|
if (Array.isArray(connectedPlatforms) && connectedPlatforms.length > 0) {
|
|
517
332
|
const unique = normalizePlatformList(connectedPlatforms);
|
|
518
|
-
|
|
333
|
+
|
|
519
334
|
return unique;
|
|
520
335
|
}
|
|
521
|
-
|
|
336
|
+
|
|
522
337
|
// If object provided, map truthy keys
|
|
523
338
|
if (connectedPlatforms && typeof connectedPlatforms === "object" && !Array.isArray(connectedPlatforms)) {
|
|
524
339
|
for (const candidate of [connectedPlatforms, ...extractPlatformCandidates(connectedPlatforms)]) {
|
|
525
340
|
const unique = normalizePlatformCandidate(candidate);
|
|
526
341
|
if (unique.length > 0) {
|
|
527
|
-
|
|
342
|
+
|
|
528
343
|
return unique;
|
|
529
344
|
}
|
|
530
345
|
}
|
|
531
346
|
}
|
|
532
|
-
|
|
533
|
-
|
|
347
|
+
|
|
348
|
+
|
|
534
349
|
return [];
|
|
535
350
|
}
|
|
536
351
|
|
|
@@ -538,7 +353,7 @@ const DataRequest = ({ appName = "My App", onComplete, onConnectMoreApps, connec
|
|
|
538
353
|
useEffect(() => {
|
|
539
354
|
const refreshPlatforms = () => {
|
|
540
355
|
const newPlatforms = getConnected();
|
|
541
|
-
|
|
356
|
+
|
|
542
357
|
setPlatforms(newPlatforms);
|
|
543
358
|
};
|
|
544
359
|
|
|
@@ -570,57 +385,57 @@ const DataRequest = ({ appName = "My App", onComplete, onConnectMoreApps, connec
|
|
|
570
385
|
|
|
571
386
|
const fetchFromBackendIfNeeded = async () => {
|
|
572
387
|
const currentPlatforms = getConnected();
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
if (userEmail) {
|
|
578
|
-
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
if (userEmail && connectedPlatforms == null && !demoMode) {
|
|
393
|
+
|
|
579
394
|
try {
|
|
580
395
|
const baseUrl = API_CONFIG.getBaseUrl();
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
|
|
585
400
|
const resp = await fetch(`${baseUrl}/getAccountInfo/email`, {
|
|
586
401
|
method: 'POST',
|
|
587
402
|
headers: { 'Content-Type': 'application/json' },
|
|
588
403
|
body: JSON.stringify({ Info: { identifier: userEmail } })
|
|
589
404
|
});
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
|
|
594
409
|
if (resp.ok) {
|
|
595
410
|
const data = await resp.json();
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
|
|
600
415
|
const connectedRaw = extractPlatformCandidates(data).find((candidate) => {
|
|
601
416
|
return normalizePlatformCandidate(candidate).length > 0;
|
|
602
417
|
}) || [];
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
|
|
606
421
|
{
|
|
607
422
|
const unique = normalizePlatformCandidate(connectedRaw);
|
|
608
423
|
if (unique.length === 0) {
|
|
609
|
-
|
|
424
|
+
|
|
610
425
|
return;
|
|
611
426
|
}
|
|
612
|
-
|
|
613
|
-
|
|
427
|
+
|
|
428
|
+
|
|
614
429
|
// Save to localStorage so it persists
|
|
615
430
|
try {
|
|
616
431
|
const u = JSON.parse(localStorage.getItem("onairosUser") || "{}");
|
|
617
432
|
u.connectedAccounts = unique;
|
|
618
433
|
localStorage.setItem("onairosUser", JSON.stringify(u));
|
|
619
|
-
|
|
434
|
+
|
|
620
435
|
} catch (e) {
|
|
621
|
-
console.error('
|
|
436
|
+
console.error('[Onairos] Request failed.');
|
|
622
437
|
}
|
|
623
|
-
|
|
438
|
+
|
|
624
439
|
// Update platforms display. Backend truth wins over stale localStorage.
|
|
625
440
|
if (cancelled) return;
|
|
626
441
|
setPlatforms((prev) => {
|
|
@@ -638,14 +453,14 @@ const DataRequest = ({ appName = "My App", onComplete, onConnectMoreApps, connec
|
|
|
638
453
|
}
|
|
639
454
|
} else {
|
|
640
455
|
const errorText = await resp.text();
|
|
641
|
-
console.error('
|
|
456
|
+
console.error('[Onairos] Request failed.');
|
|
642
457
|
}
|
|
643
458
|
} catch (error) {
|
|
644
|
-
console.error('
|
|
459
|
+
console.error('[Onairos] Request failed.');
|
|
645
460
|
}
|
|
646
461
|
}
|
|
647
462
|
};
|
|
648
|
-
|
|
463
|
+
|
|
649
464
|
const initialPlatforms = getConnected();
|
|
650
465
|
// If we already have platforms from storage/props, keep the first interaction responsive
|
|
651
466
|
// and refresh backend truth after the consent sheet has settled.
|
|
@@ -653,18 +468,18 @@ const DataRequest = ({ appName = "My App", onComplete, onConnectMoreApps, connec
|
|
|
653
468
|
|
|
654
469
|
// Listen for custom event from UniversalOnboarding
|
|
655
470
|
const handleConnectedAccountsUpdate = () => {
|
|
656
|
-
|
|
471
|
+
|
|
657
472
|
refreshPlatforms();
|
|
658
473
|
};
|
|
659
|
-
|
|
474
|
+
|
|
660
475
|
// Listen for storage events (cross-tab/window updates)
|
|
661
476
|
const handleStorageChange = (e) => {
|
|
662
477
|
if (e.key === 'onairosUser') {
|
|
663
|
-
|
|
478
|
+
|
|
664
479
|
refreshPlatforms();
|
|
665
480
|
}
|
|
666
481
|
};
|
|
667
|
-
|
|
482
|
+
|
|
668
483
|
window.addEventListener('onairos-connected-accounts-update', handleConnectedAccountsUpdate);
|
|
669
484
|
window.addEventListener('storage', handleStorageChange);
|
|
670
485
|
|
|
@@ -685,45 +500,45 @@ const DataRequest = ({ appName = "My App", onComplete, onConnectMoreApps, connec
|
|
|
685
500
|
}, [connectedPlatforms, userEmail]); // Re-run if connectedPlatforms prop or userEmail changes
|
|
686
501
|
|
|
687
502
|
useEffect(() => {
|
|
688
|
-
|
|
503
|
+
|
|
689
504
|
}, [platforms]);
|
|
690
505
|
|
|
691
506
|
// SDK parity: Capacitor should look like mobile web.
|
|
692
507
|
// Avoid “native-only” sizing differences here.
|
|
693
508
|
|
|
694
509
|
const allowedNormalizedSet = useMemo(() => {
|
|
695
|
-
if (!Array.isArray(allowedPlatforms)
|
|
510
|
+
if (!Array.isArray(allowedPlatforms)) return null;
|
|
696
511
|
return new Set(allowedPlatforms.map((p) => platformKeyForFilter(p)).filter(Boolean));
|
|
697
512
|
}, [allowedPlatforms]);
|
|
698
513
|
|
|
699
514
|
const visibleConnectedPlatforms = useMemo(() => {
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
515
|
+
const current = Array.isArray(connectedPlatforms) ? normalizePlatformList(connectedPlatforms) : platforms;
|
|
516
|
+
if (!allowedNormalizedSet) return current;
|
|
517
|
+
return current.filter((p) => allowedNormalizedSet.has(platformKeyForFilter(p)));
|
|
518
|
+
}, [platforms, allowedNormalizedSet, connectedPlatforms]);
|
|
703
519
|
const hasVisibleConnectedPlatforms = visibleConnectedPlatforms.length > 0;
|
|
704
520
|
|
|
705
|
-
const hasRawMemorySources = userHasConnectedRawSourceInAllowlist(platforms, allowedNormalizedSet);
|
|
706
|
-
|
|
521
|
+
const hasRawMemorySources = userHasConnectedRawSourceInAllowlist(Array.isArray(connectedPlatforms) ? normalizePlatformList(connectedPlatforms) : platforms, allowedNormalizedSet);
|
|
522
|
+
|
|
707
523
|
const showRawMemoriesOption =
|
|
708
524
|
rawMemoriesOffered !== false &&
|
|
709
|
-
|
|
710
|
-
hasRawMemorySources &&
|
|
711
|
-
allowlistIncludesAnyRawSource(allowedNormalizedSet);
|
|
525
|
+
developerExplicitlyWantsRawMemoriesInUI();
|
|
712
526
|
|
|
713
527
|
// Options follow requestData; rawMemories only when developer wants it AND user has a raw-capable source.
|
|
714
528
|
// A combined option (e.g. personalization → preferences + personality) shows if ANY of its scopes
|
|
715
529
|
// are requested, so collapsing toggles never hides a scope the developer asked for.
|
|
716
530
|
const availableOptions = useMemo(() => getOptions(appName, hasRawMemorySources).filter((opt) => {
|
|
531
|
+
if (rawMemoriesOnly) return opt.id === 'rawMemories' && showRawMemoriesOption;
|
|
717
532
|
if (opt.required) return true;
|
|
718
533
|
if (opt.id === 'rawMemories') return showRawMemoriesOption;
|
|
719
|
-
if (!normalizedRequestData
|
|
534
|
+
if (!normalizedRequestData) return true;
|
|
720
535
|
const optScopes = (opt.scopes && opt.scopes.length ? opt.scopes : [opt.id]).map((s) => s.toLowerCase());
|
|
721
536
|
return optScopes.some((s) => normalizedRequestData.includes(s));
|
|
722
|
-
}), [appName, hasRawMemorySources, normalizedRequestData, showRawMemoriesOption]);
|
|
537
|
+
}), [appName, hasRawMemorySources, normalizedRequestData, showRawMemoriesOption, rawMemoriesOnly]);
|
|
723
538
|
|
|
724
539
|
// Split required (shown as an "included" line) from the user's actual checkboxes.
|
|
725
|
-
|
|
726
|
-
|
|
540
|
+
|
|
541
|
+
|
|
727
542
|
|
|
728
543
|
const toggle = useCallback((id, val) => {
|
|
729
544
|
// Ensure "basic" is always true (required) and disabled options can't be toggled
|
|
@@ -734,9 +549,9 @@ const DataRequest = ({ appName = "My App", onComplete, onConnectMoreApps, connec
|
|
|
734
549
|
setSelected((p) => (p[id] === val ? p : { ...p, [id]: val }));
|
|
735
550
|
}, [availableOptions]);
|
|
736
551
|
|
|
737
|
-
const freqToPercent = (f) => (f === "once" ? 0 : f === "weekly" ? 50 : 100);
|
|
738
552
|
|
|
739
|
-
|
|
553
|
+
|
|
554
|
+
|
|
740
555
|
|
|
741
556
|
const renderConnectPlatformChip = (platform, index) => {
|
|
742
557
|
const src = DATA_REQUEST_PLATFORM_LOGOS[platform] || '';
|
|
@@ -771,285 +586,34 @@ const DataRequest = ({ appName = "My App", onComplete, onConnectMoreApps, connec
|
|
|
771
586
|
);
|
|
772
587
|
};
|
|
773
588
|
|
|
774
|
-
|
|
775
|
-
const rect = e.currentTarget.getBoundingClientRect();
|
|
776
|
-
const x = Math.max(0, Math.min(rect.width, e.clientX - rect.left));
|
|
777
|
-
const ratio = x / rect.width;
|
|
778
|
-
if (ratio < 1 / 3) setFreq("once");
|
|
779
|
-
else if (ratio < 2 / 3) setFreq("weekly");
|
|
780
|
-
else setFreq("daily");
|
|
781
|
-
};
|
|
589
|
+
|
|
782
590
|
|
|
783
591
|
// Expand each enabled option into its backend scopes. Combined toggles (personalization)
|
|
784
592
|
// emit multiple scopes so downstream `approved.includes('preferences'|'personality')` still works.
|
|
785
|
-
const buildApprovedScopes =
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
optScopes.forEach((s) => scopes.push(s));
|
|
791
|
-
});
|
|
792
|
-
return [...new Set(scopes)];
|
|
793
|
-
}, [availableOptions, selected]);
|
|
794
|
-
|
|
795
|
-
const canSubmit = selectedCount > 0 && !isSubmitting && (hasVisibleConnectedPlatforms || allowContinueWithoutConnections);
|
|
796
|
-
|
|
593
|
+
const buildApprovedScopes = () => approvedScopes(selected,
|
|
594
|
+
rawMemoriesConfig != null && !normalizedRequestData?.includes('rawmemories')
|
|
595
|
+
? [...(requestedScopes(requestData) || ['preferences','personality']), 'rawMemories'] : requestData,
|
|
596
|
+
{rawOnly: rawMemoriesOnly, hasRawSource: hasRawMemorySources, rawOffered: rawMemoriesOffered !== false});
|
|
597
|
+
const canSubmit = buildApprovedScopes().length > 0 && !isSubmitting && (hasVisibleConnectedPlatforms || allowContinueWithoutConnections);
|
|
797
598
|
const handleAcceptContinue = async () => {
|
|
798
|
-
if (!canSubmit) return;
|
|
599
|
+
if (!canSubmit || submittingRef.current) return;
|
|
600
|
+
submittingRef.current = true;
|
|
799
601
|
setIsSubmitting(true);
|
|
602
|
+
setSubmitError('');
|
|
800
603
|
try {
|
|
801
|
-
await
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
freq,
|
|
805
|
-
demoMode: !!demoMode,
|
|
806
|
-
});
|
|
604
|
+
await onComplete?.({approved: buildApprovedScopes(), freq, demoMode: !!demoMode});
|
|
605
|
+
} catch (_) {
|
|
606
|
+
setSubmitError('Your response wasn’t saved. Please try again.');
|
|
807
607
|
} finally {
|
|
608
|
+
submittingRef.current = false;
|
|
808
609
|
setIsSubmitting(false);
|
|
809
610
|
}
|
|
810
611
|
};
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
<SessionUserBar userEmail={userEmail} onLogout={onLogout} theme={theme} />
|
|
817
|
-
)}
|
|
818
|
-
|
|
819
|
-
{/* CONTENT */}
|
|
820
|
-
<div className={`flex-1 overflow-y-auto px-6 pb-2 ${demoMode ? 'pt-3 md:pt-4' : 'pt-3 md:pt-6'}`}>
|
|
821
|
-
|
|
822
|
-
{/* ICONS */}
|
|
823
|
-
<div className="flex justify-center items-center gap-3 mb-3 md:mb-4">
|
|
824
|
-
{/* Wrapped: Onairos -> Persona. Non-wrapped: Onairos -> app placeholder */}
|
|
825
|
-
<div className={`w-10 h-10 rounded-2xl shadow flex items-center justify-center overflow-hidden ${isGlass ? 'bg-white/10' : 'bg-white'}`}>
|
|
826
|
-
<img
|
|
827
|
-
src={OnairosLogo}
|
|
828
|
-
alt="Onairos"
|
|
829
|
-
className="w-full h-full object-contain p-1"
|
|
830
|
-
/>
|
|
831
|
-
</div>
|
|
832
|
-
<svg className={`w-5 h-5 ${isGlass ? 'text-white/40' : 'text-gray-400'}`} fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
833
|
-
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M14 5l7 7m0 0l-7 7m7-7H3" />
|
|
834
|
-
</svg>
|
|
835
|
-
<div className={`w-10 h-10 rounded-2xl shadow flex items-center justify-center overflow-hidden ${isGlass ? 'bg-white/10' : 'bg-white'}`}>
|
|
836
|
-
{appIcon ? (
|
|
837
|
-
<img
|
|
838
|
-
src={appIcon}
|
|
839
|
-
alt={appName}
|
|
840
|
-
className="w-full h-full object-cover"
|
|
841
|
-
onError={(e) => {
|
|
842
|
-
e.currentTarget.style.display = 'none';
|
|
843
|
-
e.currentTarget.parentElement.innerHTML = `<span class="text-lg font-serif font-bold" style="font-family: IBM Plex Sans, system-ui, sans-serif">${(appName || 'A').charAt(0).toUpperCase()}</span>`;
|
|
844
|
-
}}
|
|
845
|
-
/>
|
|
846
|
-
) : isWrappedApp ? (
|
|
847
|
-
<img
|
|
848
|
-
src={personaImg}
|
|
849
|
-
alt="Persona"
|
|
850
|
-
className="w-6 h-6 object-contain rounded-xl"
|
|
851
|
-
onError={(e) => {
|
|
852
|
-
e.currentTarget.style.display = 'none';
|
|
853
|
-
e.currentTarget.parentElement.innerHTML = '<span class="text-xl">🎁</span>';
|
|
854
|
-
}}
|
|
855
|
-
/>
|
|
856
|
-
) : (
|
|
857
|
-
<span className="text-lg font-serif font-bold" style={{ fontFamily: 'IBM Plex Sans, system-ui, sans-serif' }}>{(appName || 'A').charAt(0).toUpperCase()}</span>
|
|
858
|
-
)}
|
|
859
|
-
</div>
|
|
860
|
-
</div>
|
|
861
|
-
|
|
862
|
-
{/* TITLE */}
|
|
863
|
-
<div className={`text-center ${demoMode ? 'mb-3 md:mb-3' : 'mb-4 md:mb-5'}`}>
|
|
864
|
-
<h1 className={`text-[20px] md:text-[22px] font-semibold leading-tight tracking-tight ${isGlass ? 'text-white' : 'text-gray-900'}`} style={{ fontFamily: 'IBM Plex Sans, system-ui, sans-serif' }}>
|
|
865
|
-
{customTitle || `${appName} wants to personalize your experience`}
|
|
866
|
-
</h1>
|
|
867
|
-
<div className="mt-1 flex items-center justify-center gap-2">
|
|
868
|
-
<p className={`text-[12px] ${isGlass ? 'text-white/50' : 'text-gray-500'}`} style={{ fontFamily: 'Inter, system-ui, sans-serif' }}>
|
|
869
|
-
choose what to share
|
|
870
|
-
</p>
|
|
871
|
-
{privacyPolicyUrl && (
|
|
872
|
-
<a
|
|
873
|
-
href={privacyPolicyUrl}
|
|
874
|
-
target="_blank"
|
|
875
|
-
rel="noopener noreferrer"
|
|
876
|
-
aria-label="How your data is used"
|
|
877
|
-
title="How your data is used"
|
|
878
|
-
className={`inline-flex items-center justify-center w-5 h-5 rounded-full border transition flex-shrink-0 ${isGlass ? 'border-white/40 text-white/80 hover:text-white hover:border-white/70' : 'border-gray-400 text-gray-500 hover:text-gray-800 hover:border-gray-600'}`}
|
|
879
|
-
>
|
|
880
|
-
<span className="text-[12px] font-semibold leading-none" style={{ fontFamily: 'Georgia, serif' }}>i</span>
|
|
881
|
-
</a>
|
|
882
|
-
)}
|
|
883
|
-
</div>
|
|
884
|
-
{demoMode && (
|
|
885
|
-
<p className={`mx-auto mt-1.5 max-w-[300px] text-[11px] leading-snug ${isGlass ? 'text-white/55' : 'text-gray-500'}`} style={{ fontFamily: 'Inter, system-ui, sans-serif' }}>
|
|
886
|
-
Demo mode — consent flow only. No account data is fetched or processed.
|
|
887
|
-
</p>
|
|
888
|
-
)}
|
|
889
|
-
</div>
|
|
890
|
-
|
|
891
|
-
{/* CONSENT - one checkbox (two when Raw Memories is available) */}
|
|
892
|
-
<div className={`flex flex-col gap-2 ${demoMode ? 'mb-3 md:mb-4' : 'mb-4 md:mb-6'}`}>
|
|
893
|
-
{choiceOptions.map((opt) => (
|
|
894
|
-
<DataTypeToggle
|
|
895
|
-
key={opt.id}
|
|
896
|
-
dataType={opt}
|
|
897
|
-
enabled={selected[opt.id]}
|
|
898
|
-
onToggle={toggle}
|
|
899
|
-
isNative={false}
|
|
900
|
-
isGlass={isGlass}
|
|
901
|
-
/>
|
|
902
|
-
))}
|
|
903
|
-
|
|
904
|
-
{/* Always-included items shown as a quiet line rather than a checkbox.
|
|
905
|
-
Left structure mirrors DataTypeToggle (px-3 + w-7 icon slot + gap-2.5) so text aligns. */}
|
|
906
|
-
{requiredOptions.map((opt) => (
|
|
907
|
-
<div key={opt.id} className={`flex items-start gap-2.5 px-3 pt-0.5 ${isGlass ? 'text-white/55' : 'text-gray-500'}`} style={{ fontFamily: 'Inter, system-ui, sans-serif' }}>
|
|
908
|
-
<div className="w-7 flex-shrink-0 flex items-center justify-center mt-0.5">
|
|
909
|
-
<svg className={`w-3.5 h-3.5 ${isGlass ? 'text-white/55' : 'text-gray-400'}`} viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
|
|
910
|
-
<path d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" />
|
|
911
|
-
</svg>
|
|
912
|
-
</div>
|
|
913
|
-
<span className="text-[11px] leading-snug min-w-0">
|
|
914
|
-
<span className="font-medium">{opt.name}</span>
|
|
915
|
-
<span className={isGlass ? 'text-white/40' : 'text-gray-400'}> · always included</span>
|
|
916
|
-
{opt.description && (
|
|
917
|
-
<span className={`block ${isGlass ? 'text-white/40' : 'text-gray-400'}`}>{opt.description}</span>
|
|
918
|
-
)}
|
|
919
|
-
</span>
|
|
920
|
-
</div>
|
|
921
|
-
))}
|
|
922
|
-
</div>
|
|
923
|
-
|
|
924
|
-
{/* FREQUENCY PANEL - Only shown if showTime is true */}
|
|
925
|
-
{showTime && (
|
|
926
|
-
<div className="p-5 rounded-3xl bg-white/50 backdrop-blur-md border border-black/5 shadow-sm">
|
|
927
|
-
<div className="flex justify-between items-center mb-3">
|
|
928
|
-
<span className="text-sm font-medium text-gray-900" style={{ fontFamily: 'Inter, system-ui, sans-serif' }}>
|
|
929
|
-
How often can {appName} receive updates?
|
|
930
|
-
</span>
|
|
931
|
-
<span className="text-[11px] text-gray-500" style={{ fontFamily: 'Inter, system-ui, sans-serif' }}>
|
|
932
|
-
{freq === "once"
|
|
933
|
-
? "one-time only"
|
|
934
|
-
: freq === "weekly"
|
|
935
|
-
? "once per week"
|
|
936
|
-
: "once per day"}
|
|
937
|
-
</span>
|
|
938
|
-
</div>
|
|
939
|
-
|
|
940
|
-
{/* SLIDER: subtle rail, monochrome progress, click-to-set */}
|
|
941
|
-
<div
|
|
942
|
-
className="relative h-2.5 rounded-full bg-gray-200/90 overflow-hidden mb-4 border border-black/5 shadow-inner cursor-pointer"
|
|
943
|
-
onClick={handleRailClick}
|
|
944
|
-
>
|
|
945
|
-
<div
|
|
946
|
-
className="absolute h-full transition-all rounded-full"
|
|
947
|
-
style={{
|
|
948
|
-
width: `${freqToPercent(freq)}%`,
|
|
949
|
-
background: "linear-gradient(90deg, rgba(31,41,55,0.95) 0%, rgba(107,114,128,0.9) 60%, rgba(209,213,219,0.85) 100%)",
|
|
950
|
-
}}
|
|
951
|
-
/>
|
|
952
|
-
{/* Tick marks for 3 stops */}
|
|
953
|
-
<span className="absolute left-0 top-1/2 -translate-y-1/2 w-[2px] h-3 bg-black/10" />
|
|
954
|
-
<span className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 w-[2px] h-3 bg-black/10" />
|
|
955
|
-
<span className="absolute right-0 top-1/2 -translate-y-1/2 w-[2px] h-3 bg-black/10" />
|
|
956
|
-
{/* Thumb indicator (sleek) */}
|
|
957
|
-
<span
|
|
958
|
-
className="absolute top-1/2 -translate-y-1/2 -translate-x-1/2 w-4.5 h-4.5 rounded-full bg-white border border-black/20 shadow-md"
|
|
959
|
-
style={{
|
|
960
|
-
left: `${freqToPercent(freq)}%`,
|
|
961
|
-
}}
|
|
962
|
-
/>
|
|
963
|
-
</div>
|
|
964
|
-
|
|
965
|
-
<div className="grid grid-cols-3 text-center text-[12px] font-medium" style={{ fontFamily: 'Inter, system-ui, sans-serif' }}>
|
|
966
|
-
<button onClick={() => setFreq("once")} className="text-gray-700">1× only</button>
|
|
967
|
-
<button onClick={() => setFreq("weekly")} className="text-gray-900 font-semibold">1× weekly</button>
|
|
968
|
-
<button onClick={() => setFreq("daily")} className="text-gray-700">1× daily</button>
|
|
969
|
-
</div>
|
|
970
|
-
|
|
971
|
-
<p className="text-[11px] text-gray-500 mt-3 leading-snug" style={{ fontFamily: 'Inter, system-ui, sans-serif' }}>
|
|
972
|
-
This only controls update frequency; It does not grant more access.
|
|
973
|
-
</p>
|
|
974
|
-
</div>
|
|
975
|
-
)}
|
|
976
|
-
|
|
977
|
-
</div>
|
|
978
|
-
|
|
979
|
-
{/* FOOTER */}
|
|
980
|
-
<div
|
|
981
|
-
className={`px-6 pt-3 md:pt-4 border-t flex-shrink-0 ${isGlass ? 'bg-transparent border-white/10' : 'bg-white/80 backdrop-blur border-black/5'}`}
|
|
982
|
-
style={{ paddingBottom: 'calc(12px + env(safe-area-inset-bottom))' }}
|
|
983
|
-
>
|
|
984
|
-
{/* Connected sources only. */}
|
|
985
|
-
{showConnectPlatformsCard && (
|
|
986
|
-
<div className={`mb-3 rounded-2xl backdrop-blur border px-3 py-2.5 ${isGlass ? 'bg-white/5 border-white/10' : 'bg-white/60 border-black/5'}`}>
|
|
987
|
-
<div className="text-center mb-1">
|
|
988
|
-
<div className={`text-[13px] font-semibold ${isGlass ? 'text-white' : 'text-gray-900'}`} style={{ fontFamily: 'IBM Plex Sans, system-ui, sans-serif' }}>Connect Platforms</div>
|
|
989
|
-
<div className={`text-[11px] ${isGlass ? 'text-white/50' : 'text-gray-500'}`} style={{ fontFamily: 'Inter, system-ui, sans-serif' }}>more connections, smarter personalization</div>
|
|
990
|
-
</div>
|
|
991
|
-
<div className="flex items-center justify-center gap-2 overflow-x-auto whitespace-nowrap pb-1" style={{ WebkitOverflowScrolling: 'touch' }}>
|
|
992
|
-
{visibleConnectedPlatforms.map((platform, index) => renderConnectPlatformChip(platform, index))}
|
|
993
|
-
</div>
|
|
994
|
-
{typeof onConnectMoreApps === 'function' && (
|
|
995
|
-
<div className="mt-1 flex justify-center">
|
|
996
|
-
<button
|
|
997
|
-
type="button"
|
|
998
|
-
onClick={onConnectMoreApps}
|
|
999
|
-
className={`text-[11px] font-medium inline-flex items-center gap-1.5 ${isGlass ? 'text-white/60 hover:text-white/90' : 'text-gray-700 hover:text-gray-900'}`}
|
|
1000
|
-
style={{ WebkitTextFillColor: isGlass ? undefined : '#111827', fontFamily: 'Inter, system-ui, sans-serif' }}
|
|
1001
|
-
>
|
|
1002
|
-
<span style={{ fontFamily: 'Inter, system-ui, sans-serif' }}>Connect more</span>
|
|
1003
|
-
<span
|
|
1004
|
-
aria-hidden="true"
|
|
1005
|
-
className={`inline-flex items-center justify-center w-4 h-4 rounded-full border leading-none ${isGlass ? 'border-white/30 text-white/60' : 'border-gray-400 text-gray-800'}`}
|
|
1006
|
-
style={{ WebkitTextFillColor: isGlass ? undefined : '#111827' }}
|
|
1007
|
-
>
|
|
1008
|
-
+
|
|
1009
|
-
</span>
|
|
1010
|
-
</button>
|
|
1011
|
-
</div>
|
|
1012
|
-
)}
|
|
1013
|
-
</div>
|
|
1014
|
-
)}
|
|
1015
|
-
|
|
1016
|
-
{/* If no platforms are connected yet, explain the preloaded/background flow or allow connecting apps. */}
|
|
1017
|
-
{(!platforms || platforms.length === 0) &&
|
|
1018
|
-
visibleConnectedPlatforms.length === 0 &&
|
|
1019
|
-
typeof onConnectMoreApps === 'function' && (
|
|
1020
|
-
<div className={`mb-3 rounded-2xl backdrop-blur border px-3 py-2 text-center ${isGlass ? 'bg-white/5 border-white/10' : 'bg-white/60 border-black/5'}`}>
|
|
1021
|
-
<div className={`text-[11px] mb-1 ${isGlass ? 'text-white/50' : 'text-gray-500'}`} style={{ fontFamily: 'Inter, system-ui, sans-serif' }}>
|
|
1022
|
-
{allowContinueWithoutConnections ? 'Personalization is preparing in the background' : 'No apps connected yet'}
|
|
1023
|
-
</div>
|
|
1024
|
-
{!allowContinueWithoutConnections && (
|
|
1025
|
-
<button
|
|
1026
|
-
type="button"
|
|
1027
|
-
onClick={onConnectMoreApps}
|
|
1028
|
-
className="text-[12px] font-medium underline underline-offset-2 text-gray-700 hover:text-gray-900"
|
|
1029
|
-
style={{ WebkitTextFillColor: '#111827', fontFamily: 'Inter, system-ui, sans-serif' }}
|
|
1030
|
-
>
|
|
1031
|
-
Connect apps?
|
|
1032
|
-
</button>
|
|
1033
|
-
)}
|
|
1034
|
-
</div>
|
|
1035
|
-
)}
|
|
1036
|
-
<button
|
|
1037
|
-
className={`w-full rounded-full py-3 text-sm font-medium shadow-sm flex items-center justify-center gap-2 transition ${!canSubmit ? 'cursor-not-allowed opacity-70' : 'cursor-pointer'} ${isGlass ? 'bg-white/15 border border-white/20' : 'bg-gray-900'}`}
|
|
1038
|
-
style={{ color: '#ffffff', fontFamily: 'Inter, system-ui, sans-serif' }}
|
|
1039
|
-
disabled={!canSubmit}
|
|
1040
|
-
onClick={handleAcceptContinue}
|
|
1041
|
-
>
|
|
1042
|
-
{isSubmitting ? (
|
|
1043
|
-
<svg className="w-4 h-4 animate-spin" viewBox="0 0 24 24" fill="none" aria-hidden="true">
|
|
1044
|
-
<circle className="opacity-25" cx="12" cy="12" r="9" stroke="currentColor" strokeWidth="3" />
|
|
1045
|
-
<path className="opacity-90" d="M21 12a9 9 0 0 0-9-9" stroke="currentColor" strokeWidth="3" strokeLinecap="round" />
|
|
1046
|
-
</svg>
|
|
1047
|
-
) : null}
|
|
1048
|
-
{hasVisibleConnectedPlatforms || allowContinueWithoutConnections ? 'Accept & Continue' : 'Connect apps to continue'}
|
|
1049
|
-
</button>
|
|
1050
|
-
</div>
|
|
1051
|
-
</div>
|
|
1052
|
-
);
|
|
612
|
+
return <div style={{display:'flex', flexDirection:'column', flex:1, minHeight:0, height:'100%'}}>{userEmail && <SessionUserBar userEmail={userEmail} onLogout={onLogout} theme={theme}/>}<NativeConsent customTitle={customTitle} appName={appName} rawOnly={rawMemoriesOnly} options={availableOptions}
|
|
613
|
+
selected={selected} onToggle={toggle} connections={visibleConnectedPlatforms} renderPlatform={renderConnectPlatformChip}
|
|
614
|
+
onConnectMore={onConnectMoreApps} onAccept={handleAcceptContinue} onDecline={onDecline}
|
|
615
|
+
canSubmit={canSubmit} submitting={isSubmitting} error={submitError} privacyPolicyUrl={privacyPolicyUrl}
|
|
616
|
+
showTime={showTime} freq={freq} setFreq={setFreq}/></div>;
|
|
1053
617
|
};
|
|
1054
618
|
|
|
1055
619
|
export default DataRequest;
|