onairos 3.1.10 → 3.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,270 @@
1
+ # New Onairos SDK Features
2
+
3
+ ## 🎯 Overview
4
+
5
+ We've added two major developer experience improvements to the Onairos SDK:
6
+
7
+ 1. **Programmatic Overlay Function** - Trigger the Onairos authentication and data request flow without the button component
8
+ 2. **Dictionary Response Format** - Get personality data as named objects instead of remembering array indices
9
+
10
+ ## 🚀 Feature 1: Programmatic Overlay Function
11
+
12
+ ### Problem Solved
13
+ Previously, developers could only trigger the Onairos flow by using the `OnairosButton` component. Now you can integrate Onairos into any UI element or trigger it programmatically.
14
+
15
+ ### New Exports Available
16
+
17
+ ```javascript
18
+ import {
19
+ openOnairosOverlay, // Function to open overlay programmatically
20
+ useOnairosOverlay, // React hook for overlay management
21
+ getOnairosData // Direct data access (placeholder for future)
22
+ } from 'onairos';
23
+ ```
24
+
25
+ ### Usage Examples
26
+
27
+ #### Basic Programmatic Usage
28
+ ```javascript
29
+ import { openOnairosOverlay } from 'onairos';
30
+
31
+ const handleCustomButton = async () => {
32
+ try {
33
+ const cleanup = await openOnairosOverlay({
34
+ webpageName: "My App",
35
+ requestData: ['basic', 'personality'],
36
+ autoFetch: true,
37
+ onComplete: (result) => {
38
+ console.log('User data received:', result);
39
+ // Handle the result
40
+ }
41
+ });
42
+
43
+ // Optional: Call cleanup() to close overlay programmatically
44
+ } catch (error) {
45
+ console.error('Failed to open overlay:', error);
46
+ }
47
+ };
48
+
49
+ // Attach to any element
50
+ <button onClick={handleCustomButton}>Get My Data</button>
51
+ ```
52
+
53
+ #### React Hook Usage
54
+ ```javascript
55
+ import { useOnairosOverlay } from 'onairos';
56
+
57
+ function MyComponent() {
58
+ const overlay = useOnairosOverlay({
59
+ webpageName: "My App",
60
+ requestData: ['personality'],
61
+ onComplete: (result) => {
62
+ // Handle result
63
+ }
64
+ });
65
+
66
+ return (
67
+ <button
68
+ onClick={() => overlay.open()}
69
+ disabled={overlay.isLoading}
70
+ >
71
+ {overlay.isLoading ? 'Loading...' : 'Discover Personality'}
72
+ </button>
73
+ );
74
+ }
75
+ ```
76
+
77
+ #### Vanilla JavaScript Integration
78
+ ```javascript
79
+ // Works without React
80
+ window.addEventListener('click', async (e) => {
81
+ if (e.target.id === 'my-onairos-btn') {
82
+ const cleanup = await window.Onairos.openOnairosOverlay({
83
+ webpageName: "Vanilla JS App",
84
+ requestData: ['basic', 'personality'],
85
+ onComplete: (result) => {
86
+ document.getElementById('results').innerHTML =
87
+ JSON.stringify(result.apiResponse, null, 2);
88
+ }
89
+ });
90
+ }
91
+ });
92
+ ```
93
+
94
+ ## 📊 Feature 2: Dictionary Response Format
95
+
96
+ ### Problem Solved
97
+ Previously, developers had to remember that personality scores came as an array where index 0 = Analyst, index 1 = Diplomat, etc. This was error-prone and hard to maintain.
98
+
99
+ ### Before (Array Format)
100
+ ```javascript
101
+ onComplete: (result) => {
102
+ const scores = result.apiResponse.InferenceResult.traits;
103
+
104
+ // Hard to remember what each index means!
105
+ const analystScore = scores[0]; // 😰 What was index 0 again?
106
+ const diplomatScore = scores[1]; // 😰 And index 1?
107
+ const sentinelScore = scores[2]; // 😰 This is confusing...
108
+ }
109
+ ```
110
+
111
+ ### After (Dictionary Format)
112
+ ```javascript
113
+ onComplete: (result) => {
114
+ const { traits, personalityDict } = result.apiResponse.InferenceResult;
115
+
116
+ // Much clearer and less error-prone! 🎉
117
+ const { Analyst, Diplomat, Sentinel, Explorer } = personalityDict;
118
+
119
+ // Or access directly
120
+ const analystScore = personalityDict.Analyst;
121
+ const commanderScore = personalityDict.Commander;
122
+ }
123
+ ```
124
+
125
+ ### All 16 Personality Types Available
126
+ ```javascript
127
+ const personalityTypes = [
128
+ 'Analyst', 'Diplomat', 'Sentinel', 'Explorer',
129
+ 'Architect', 'Logician', 'Commander', 'Debater',
130
+ 'Advocate', 'Mediator', 'Protagonist', 'Campaigner',
131
+ 'Logistician', 'Defender', 'Executive', 'Consul'
132
+ ];
133
+ ```
134
+
135
+ ### Backward Compatibility
136
+ The array format is still available! You get both formats by default:
137
+
138
+ ```javascript
139
+ onComplete: (result) => {
140
+ const inference = result.apiResponse.InferenceResult;
141
+
142
+ // Both formats available
143
+ const arrayFormat = inference.traits; // [0.8, 0.6, 0.4, ...]
144
+ const dictFormat = inference.personalityDict; // { Analyst: 0.8, Diplomat: 0.6, ... }
145
+
146
+ // Use whichever you prefer!
147
+ }
148
+ ```
149
+
150
+ ### Control Response Formatting
151
+
152
+ #### Enable/Disable Dictionary Format
153
+ ```javascript
154
+ <OnairosButton
155
+ webpageName="My App"
156
+ requestData={['personality']}
157
+ formatResponse={true} // Enable dictionary format (default: true)
158
+ responseFormat={{
159
+ includeDictionary: true, // Include personalityDict
160
+ includeArray: true // Keep original array format too
161
+ }}
162
+ onComplete={handleResult}
163
+ />
164
+ ```
165
+
166
+ #### Manual Formatting
167
+ ```javascript
168
+ import { formatPersonalityScores } from 'onairos';
169
+
170
+ // If you need to format manually
171
+ const personalityDict = formatPersonalityScores(scoresArray);
172
+ ```
173
+
174
+ ## 🔧 Configuration Options
175
+
176
+ ### openOnairosOverlay() Parameters
177
+ ```javascript
178
+ {
179
+ requestData: ['basic', 'personality', 'preferences'], // Data types to request
180
+ webpageName: 'My App', // Your app name
181
+ onComplete: (result) => {}, // Completion callback
182
+ autoFetch: true, // Auto-fetch data
183
+ testMode: false, // Use test endpoints
184
+ appIcon: 'https://myapp.com/icon.png', // Your app icon
185
+ formatResponse: true, // Enable dictionary format
186
+ responseFormat: { // Formatting options
187
+ includeDictionary: true,
188
+ includeArray: true
189
+ }
190
+ }
191
+ ```
192
+
193
+ ### OnairosButton New Props
194
+ ```javascript
195
+ <OnairosButton
196
+ // ... existing props ...
197
+ formatResponse={true} // Enable automatic formatting
198
+ responseFormat={{ // Formatting options
199
+ includeDictionary: true,
200
+ includeArray: true
201
+ }}
202
+ />
203
+ ```
204
+
205
+ ## 📁 File Structure
206
+ ```
207
+ src/
208
+ ├── utils/
209
+ │ ├── overlayHandler.js # New overlay functions
210
+ │ └── responseFormatter.js # New response formatting
211
+ ├── onairos.jsx # Updated main export
212
+ └── onairosButton.jsx # Updated with formatting
213
+ ```
214
+
215
+ ## 🔄 Migration Guide
216
+
217
+ ### For Existing Users
218
+ - **No breaking changes!** Your existing code continues to work exactly as before
219
+ - The array format is still available alongside the new dictionary format
220
+ - All existing props and functions work the same way
221
+
222
+ ### To Use New Features
223
+ 1. **Dictionary Format**: It's enabled by default! Just access `result.apiResponse.InferenceResult.personalityDict`
224
+ 2. **Programmatic Overlay**: Import `openOnairosOverlay` and use it with your custom UI elements
225
+
226
+ ### Example Migration
227
+ ```javascript
228
+ // Before
229
+ onComplete: (result) => {
230
+ const scores = result.apiResponse.InferenceResult.traits;
231
+ if (scores[0] > 0.7) { // Analyst
232
+ enableAnalyticsMode();
233
+ }
234
+ }
235
+
236
+ // After (both work!)
237
+ onComplete: (result) => {
238
+ const { traits, personalityDict } = result.apiResponse.InferenceResult;
239
+
240
+ // Old way still works
241
+ if (traits[0] > 0.7) {
242
+ enableAnalyticsMode();
243
+ }
244
+
245
+ // New way is clearer
246
+ if (personalityDict.Analyst > 0.7) {
247
+ enableAnalyticsMode();
248
+ }
249
+ }
250
+ ```
251
+
252
+ ## 🎉 Benefits Summary
253
+
254
+ ### For Developers
255
+ - ✅ **More flexible integration** - Use any UI element to trigger Onairos
256
+ - ✅ **Clearer code** - No more remembering array indices for personality types
257
+ - ✅ **Better maintainability** - Named properties are self-documenting
258
+ - ✅ **Backward compatible** - Existing code continues to work
259
+ - ✅ **Type safety ready** - Dictionary format works better with TypeScript
260
+
261
+ ### For End Users
262
+ - ✅ **Same great experience** - The Onairos flow UI remains unchanged
263
+ - ✅ **Works everywhere** - Can be triggered from any button or interaction
264
+
265
+ ## 📞 Support
266
+
267
+ If you have any questions about these new features:
268
+ - Check the updated examples in `example-usage-updated.js`
269
+ - Refer to existing documentation for the core Onairos functionality
270
+ - The new features are additive - your existing integration continues to work!
package/dist/845.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";(this.webpackChunkOnairosLaravel=this.webpackChunkOnairosLaravel||[]).push([[845,294],{845:(e,t,r)=>{r.d(t,{OnairosButton:()=>G});var n=r(294);const o=e=>{const t=(e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,((e,t,r)=>r?r.toUpperCase():t.toLowerCase())))(e);return t.charAt(0).toUpperCase()+t.slice(1)},a=(...e)=>e.filter(((e,t,r)=>Boolean(e)&&""!==e.trim()&&r.indexOf(e)===t)).join(" ").trim(),l=e=>{for(const t in e)if(t.startsWith("aria-")||"role"===t||"title"===t)return!0};var c={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const s=(0,n.forwardRef)((({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:o,className:s="",children:i,iconNode:u,...m},d)=>(0,n.createElement)("svg",{ref:d,...c,width:t,height:t,stroke:e,strokeWidth:o?24*Number(r)/Number(t):r,className:a("lucide",s),...!i&&!l(m)&&{"aria-hidden":"true"},...m},[...u.map((([e,t])=>(0,n.createElement)(e,t))),...Array.isArray(i)?i:[i]]))),i=(e,t)=>{const r=(0,n.forwardRef)((({className:r,...l},c)=>{return(0,n.createElement)(s,{ref:c,iconNode:t,className:a(`lucide-${i=o(e),i.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,`lucide-${e}`,r),...l});var i}));return r.displayName=o(e),r},u=i("mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]),m=i("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]),d=i("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);function p(e){let{onSuccess:t,testMode:r=!0}=e;const[o,a]=(0,n.useState)(""),[l,c]=(0,n.useState)(""),[s,i]=(0,n.useState)("email"),[p,f]=(0,n.useState)(!1),[b,g]=(0,n.useState)(""),y=async e=>{if(e.preventDefault(),g(""),(e=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e))(o)){f(!0);try{if(r)setTimeout((()=>{i("code"),f(!1)}),1e3);else{if(!(await fetch("https://api2.onairos.uk/email/verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:o})})).ok)throw new Error("Failed to send verification code");i("code"),f(!1)}}catch(e){g(e.message),f(!1)}}else g("Please enter a valid email address")},h=async e=>{if(e.preventDefault(),g(""),r&&"123456"===l)return i("success"),void setTimeout((()=>{t({email:o,verified:!0})}),1e3);if(r)g("Invalid code. Use 123456 for testing.");else{f(!0);try{const e=await fetch("https://api2.onairos.uk/email/verify/confirm",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:o,code:l})});if(!e.ok)throw new Error("Invalid verification code");const r=await e.json();i("success"),setTimeout((()=>{t({email:o,verified:!0,token:r.token})}),1e3)}catch(e){g(e.message),f(!1)}}};return n.createElement("div",{className:"flex flex-col items-center space-y-6 p-6 w-full"},"email"===s&&n.createElement("div",{className:"flex flex-col items-center space-y-6 w-full"},n.createElement("div",{className:"flex items-center justify-center w-16 h-16 bg-blue-100 rounded-full"},n.createElement(u,{className:"w-8 h-8 text-blue-600"})),n.createElement("div",{className:"text-center"},n.createElement("h2",{className:"text-xl font-semibold text-gray-900 mb-2"},"Sign in to Onairos"),n.createElement("p",{className:"text-gray-600"},"Enter your email address to continue"),r&&n.createElement("p",{className:"text-sm text-blue-600 mt-2"},"Test mode: Any valid email will work")),n.createElement("form",{onSubmit:y,className:"w-full max-w-md space-y-4"},n.createElement("div",null,n.createElement("label",{htmlFor:"email",className:"block text-sm font-medium text-gray-700 mb-1"},"Email address"),n.createElement("input",{type:"email",id:"email",value:o,onChange:e=>a(e.target.value),placeholder:"Enter your email",className:"w-full p-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none",required:!0})),b&&n.createElement("p",{className:"text-sm text-red-600"},b),n.createElement("button",{type:"submit",disabled:p,className:"w-full py-3 px-4 bg-blue-600 text-white rounded-lg font-semibold hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center"},p?n.createElement("div",{className:"animate-spin h-5 w-5 border-2 border-white rounded-full border-t-transparent"}):n.createElement(n.Fragment,null,"Continue",n.createElement(m,{className:"ml-2 w-4 h-4"}))))),"code"===s&&n.createElement("div",{className:"flex flex-col items-center space-y-6 w-full"},n.createElement("div",{className:"flex items-center justify-center w-16 h-16 bg-green-100 rounded-full"},n.createElement(u,{className:"w-8 h-8 text-green-600"})),n.createElement("div",{className:"text-center"},n.createElement("h2",{className:"text-xl font-semibold text-gray-900 mb-2"},"Check your email"),n.createElement("p",{className:"text-gray-600"},"We sent a verification code to"),n.createElement("p",{className:"text-gray-900 font-medium"},o),r&&n.createElement("p",{className:"text-sm text-blue-600 mt-2"},"Test mode: Use code 123456")),n.createElement("form",{onSubmit:h,className:"w-full max-w-md space-y-4"},n.createElement("div",null,n.createElement("label",{htmlFor:"code",className:"block text-sm font-medium text-gray-700 mb-1"},"Verification code"),n.createElement("input",{type:"text",id:"code",value:l,onChange:e=>c(e.target.value),placeholder:"Enter 6-digit code",className:"w-full p-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none text-center text-lg tracking-widest",maxLength:"6",required:!0})),b&&n.createElement("p",{className:"text-sm text-red-600"},b),n.createElement("button",{type:"submit",disabled:p,className:"w-full py-3 px-4 bg-blue-600 text-white rounded-lg font-semibold hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center"},p?n.createElement("div",{className:"animate-spin h-5 w-5 border-2 border-white rounded-full border-t-transparent"}):"Verify Code"),n.createElement("button",{type:"button",onClick:()=>i("email"),className:"w-full py-2 px-4 text-gray-600 hover:text-gray-800"},"Use a different email"))),"success"===s&&n.createElement("div",{className:"flex flex-col items-center space-y-6 w-full"},n.createElement("div",{className:"flex items-center justify-center w-16 h-16 bg-green-100 rounded-full"},n.createElement(d,{className:"w-8 h-8 text-green-600"})),n.createElement("div",{className:"text-center"},n.createElement("h2",{className:"text-xl font-semibold text-gray-900 mb-2"},"Email verified!"),n.createElement("p",{className:"text-gray-600"},"Setting up your account...")),n.createElement("div",{className:"w-8 h-8"},n.createElement("div",{className:"animate-spin h-8 w-8 border-2 border-blue-600 rounded-full border-t-transparent"}))))}function f(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function b(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?f(Object(r),!0).forEach((function(t){g(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):f(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function g(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const y=[{name:"YouTube",icon:"📺",color:"bg-red-500",connector:"youtube"},{name:"LinkedIn",icon:"💼",color:"bg-blue-700",connector:"linkedin"},{name:"Reddit",icon:"🔥",color:"bg-orange-500",connector:"reddit"},{name:"Pinterest",icon:"📌",color:"bg-red-600",connector:"pinterest"},{name:"Instagram",icon:"📷",color:"bg-pink-500",connector:"instagram"},{name:"GitHub",icon:"⚡",color:"bg-gray-800",connector:"github"},{name:"Facebook",icon:"👥",color:"bg-blue-600",connector:"facebook"},{name:"Gmail",icon:"✉️",color:"bg-red-400",connector:"gmail"}],h={apiKey:process.env.REACT_APP_ONAIROS_API_KEY||"onairos_web_sdk_live_key_2024",baseUrl:process.env.REACT_APP_ONAIROS_BASE_URL||"https://api2.onairos.uk",sdkType:"web",enableHealthMonitoring:!0,enableAutoRefresh:!0,enableConnectionValidation:!0};function v(e){let{onComplete:t,appIcon:r,appName:o="App"}=e;const[a,l]=(0,n.useState)({}),[c,s]=(0,n.useState)(!1),[i,u]=(0,n.useState)(null),[m,d]=(0,n.useState)({}),[p,f]=(0,n.useState)({}),[g,v]=(0,n.useState)(0);(0,n.useEffect)((()=>{(()=>{const e=localStorage.getItem("onairos_oauth_platform");e&&(console.log("📱 OAuth return detected for: ".concat(e)),localStorage.removeItem("onairos_oauth_platform"),localStorage.removeItem("onairos_oauth_return"),l((t=>b(b({},t),{},{[e]:!0}))),d((t=>b(b({},t),{},{[e]:null}))),console.log("✅ ".concat(e," marked as connected from OAuth return")))})()}),[]);const x=async e=>{console.log("🚀 connectToPlatform called for: ".concat(e));const t=y.find((t=>t.name===e));if(null==t||!t.connector)return console.error("❌ No connector found for platform: ".concat(e)),!1;try{var r;s(!0),u(e),d((t=>b(b({},t),{},{[e]:null}))),console.log("🔗 Starting OAuth connection for ".concat(e,"..."));const n=localStorage.getItem("username")||(null===(r=localStorage.getItem("onairosUser"))||void 0===r?void 0:r.email)||"user@example.com",o="".concat(h.baseUrl,"/").concat(t.connector,"/authorize"),a=await fetch(o,{method:"POST",headers:{"x-api-key":h.apiKey,"Content-Type":"application/json"},body:JSON.stringify({session:{username:n}})});if(!a.ok)throw new Error("HTTP ".concat(a.status,": ").concat(a.statusText));const c=await a.json();console.log("📋 ".concat(e," OAuth response:"),c);const i={youtube:["youtubeURL","youtubeUrl","youtube_url"],linkedin:["linkedinURL","linkedinUrl","linkedin_url"],reddit:["redditURL","redditUrl","reddit_url"],pinterest:["pinterestURL","pinterestUrl","pinterest_url"],instagram:["instagramURL","instagramUrl","instagram_url"],github:["githubURL","githubUrl","github_url"],facebook:["facebookURL","facebookUrl","facebook_url"],gmail:["gmailURL","gmailUrl","gmail_url"]}[t.connector]||["".concat(t.connector,"URL"),"".concat(t.connector,"Url"),"".concat(t.connector,"_url"),"platformURL","authUrl","url"];let m=null,p=null;for(const e of i)if(c[e]){m=c[e],p=e;break}if(!m)throw console.error("❌ No OAuth URL found for ".concat(e,":")),console.error("Expected one of:",i),console.error("Response keys:",Object.keys(c)),console.error("Full response:",c),new Error("No OAuth URL found. Backend should return one of: ".concat(i.join(", ")));if(console.log("✅ Found OAuth URL for ".concat(e," using key: ").concat(p)),/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)||window.innerWidth<=768)return localStorage.setItem("onairos_oauth_platform",e),localStorage.setItem("onairos_oauth_return",window.location.href),window.location.href=m,!0;{const r=window.open(m,"".concat(t.connector,"_oauth"),"width=500,height=600,scrollbars=yes,resizable=yes,status=no,location=no,toolbar=no,menubar=no");if(!r)throw new Error("Popup blocked. Please allow popups and try again.");let n=!1;const o=setInterval((()=>{try{if(r.location&&"onairos.uk"===r.location.hostname)return n=!0,console.log("🔄 ".concat(e," popup navigated to onairos.uk - treating as success")),void r.close()}catch(t){n||(n=!0,console.log("🔄 ".concat(e," popup navigated (cross-origin) - likely to onairos.uk")))}try{if(r.closed){clearInterval(o);const t=localStorage.getItem("onairos_".concat(e,"_success")),r=localStorage.getItem("onairos_".concat(e,"_error")),a=localStorage.getItem("onairos_".concat(e,"_timestamp")),c=a&&Date.now()-parseInt(a)<3e4;t&&c?(console.log("✅ ".concat(e," OAuth completed successfully (callback page)")),localStorage.removeItem("onairos_".concat(e,"_success")),localStorage.removeItem("onairos_".concat(e,"_timestamp")),l((t=>b(b({},t),{},{[e]:!0}))),d((t=>b(b({},t),{},{[e]:null})))):r&&c?(console.log("❌ ".concat(e," OAuth failed:"),r),localStorage.removeItem("onairos_".concat(e,"_error")),localStorage.removeItem("onairos_".concat(e,"_timestamp")),d((t=>b(b({},t),{},{[e]:r})))):n?(console.log("✅ ".concat(e," OAuth likely successful (navigated to onairos.uk)")),l((t=>b(b({},t),{},{[e]:!0}))),d((t=>b(b({},t),{},{[e]:null})))):(console.log("⚠️ ".concat(e," OAuth cancelled or no response")),d((t=>b(b({},t),{},{[e]:"Connection was cancelled"})))),s(!1),u(null)}}catch(e){}}),1e3);return setTimeout((()=>{try{!r.closed&&r.location&&"onairos.uk"===r.location.hostname&&(console.log("🚪 Auto-closing ".concat(e," popup showing onairos.uk (not found)")),r.close())}catch(t){!r.closed&&n&&(console.log("🚪 Auto-closing ".concat(e," popup (cross-origin, likely onairos.uk)")),r.close())}}),1e4),setTimeout((()=>{r.closed||(r.close(),clearInterval(o),d((t=>b(b({},t),{},{[e]:"Connection timeout"}))),s(!1),u(null))}),3e5),!0}}catch(t){return console.error("❌ Error connecting to ".concat(e,":"),t),d((r=>b(b({},r),{},{[e]:t.message}))),s(!1),u(null),!1}},E=Object.values(a).filter(Boolean).length;return n.createElement("div",{className:"max-w-sm mx-auto bg-white p-4 rounded-lg shadow-lg"},n.createElement("div",{className:"flex items-center justify-center mb-4"},n.createElement("div",{className:"flex items-center space-x-2"},n.createElement("img",{src:r||"https://onairos.sirv.com/Images/OnairosBlack.png",alt:o,className:"w-8 h-8 rounded-lg"}),n.createElement("div",{className:"flex items-center text-gray-400"},n.createElement("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},n.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 8l4 4m0 0l-4 4m4-4H3"}))),n.createElement("img",{src:"https://onairos.sirv.com/Images/OnairosBlack.png",alt:"Onairos",className:"w-8 h-8 rounded-lg"}))),n.createElement("div",{className:"text-center mb-4"},n.createElement("h2",{className:"text-lg font-bold text-gray-900 mb-1"},"Connect Data"),n.createElement("p",{className:"text-gray-600 text-sm"},"Connect data here to enhance your ",o," experience")),n.createElement("div",{className:"grid grid-cols-2 gap-3 mb-4"},y.map((e=>{const t=a[e.name]||!1,r=i===e.name,o=m[e.name],s=c&&!r;return n.createElement("div",{key:e.name,className:"relative p-3 border-2 rounded-lg transition-all duration-200 cursor-pointer ".concat(s?"opacity-50 cursor-not-allowed":"hover:shadow-md"," ").concat(t?"border-green-400 bg-green-50":o?"border-red-400 bg-red-50":r?"border-blue-400 bg-blue-50":"border-gray-200 bg-white hover:border-gray-300"),onClick:()=>!s&&(async e=>{if(console.log("🔥 TOGGLE CLICKED: ".concat(e)),c&&i!==e)return void console.log("⚠️ Already connecting to ".concat(i,", ignoring click on ").concat(e));a[e]?(console.log("🔌 Disconnecting from ".concat(e,"...")),l((t=>b(b({},t),{},{[e]:!1}))),d((t=>b(b({},t),{},{[e]:null})))):await x(e)})(e.name)},n.createElement("div",{className:"w-8 h-8 rounded-lg ".concat(e.color," flex items-center justify-center text-white text-lg mb-2 mx-auto relative")},r?n.createElement("div",{className:"animate-spin h-4 w-4 border-2 border-white rounded-full border-t-transparent"}):e.icon,t&&!r&&n.createElement("div",{className:"absolute -top-1 -right-1 w-4 h-4 bg-green-500 rounded-full flex items-center justify-center"},n.createElement("svg",{className:"w-2.5 h-2.5 text-white",fill:"currentColor",viewBox:"0 0 20 20"},n.createElement("path",{fillRule:"evenodd",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",clipRule:"evenodd"}))),o&&!r&&n.createElement("div",{className:"absolute -top-1 -right-1 w-4 h-4 bg-red-500 rounded-full flex items-center justify-center"},n.createElement("svg",{className:"w-2.5 h-2.5 text-white",fill:"currentColor",viewBox:"0 0 20 20"},n.createElement("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})))),n.createElement("div",{className:"text-center"},n.createElement("h3",{className:"font-medium text-gray-900 text-xs"},e.name),n.createElement("p",{className:"text-xs mt-1 ".concat(r?"text-blue-600":t?"text-green-600":o?"text-red-600":"text-gray-500")},r?"Connecting...":t?"Connected":o?"Failed":"Tap to connect"),o&&n.createElement("p",{className:"text-xs text-red-600 mt-1 break-words"},o)))}))),E>0&&n.createElement("div",{className:"mb-4 p-2 bg-green-50 border border-green-200 rounded-lg"},n.createElement("p",{className:"text-green-800 text-sm text-center"},"✅ ",E," connection",E>1?"s":""," active")),n.createElement("button",{onClick:()=>{const e=Object.entries(a).filter((e=>{let[t,r]=e;return r})).map((e=>{let[t]=e;return t}));t({connectedAccounts:e,totalConnections:e.length,healthScore:g,connectionHealth:p,sdkVersion:"2.1.7",enhancedFeatures:{healthMonitoring:h.enableHealthMonitoring,autoRefresh:h.enableAutoRefresh,connectionValidation:h.enableConnectionValidation}})},disabled:0===E,className:"w-full py-3 px-4 rounded-lg font-semibold transition-colors ".concat(E>0?"bg-blue-600 text-white hover:bg-blue-700":"bg-gray-300 text-gray-500 cursor-not-allowed")},E>0?"Continue with ".concat(E," connection").concat(E>1?"s":""):"Connect at least one platform"),n.createElement("button",{onClick:()=>t({connectedAccounts:[],totalConnections:0}),className:"w-full mt-2 py-2 text-gray-500 hover:text-gray-700 text-sm"},"Skip for now"))}function x(e){let{onComplete:t,userEmail:r}=e;const[o,a]=(0,n.useState)(""),[l,c]=(0,n.useState)({length:!1,number:!1,special:!1});(0,n.useEffect)((()=>{c({length:o.length>=8,number:/[0-9]/.test(o),special:/[!@#$%^&*(),.?":{}|<>]/.test(o)})}),[o]);const s=Object.values(l).every((e=>e))&&o.length>0;return n.createElement("div",{className:"max-w-md mx-auto bg-white p-6"},n.createElement("div",{className:"text-center mb-6"},n.createElement("div",{className:"w-16 h-16 bg-blue-100 rounded-full flex items-center justify-center mx-auto mb-4"},n.createElement("svg",{className:"w-8 h-8 text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},n.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m-6 4h12a2 2 0 002-2v-1a2 2 0 00-2-2H6a2 2 0 00-2 2v1a2 2 0 002 2zM12 7V3m0 4l3-3m-3 3L9 4"}))),n.createElement("h2",{className:"text-2xl font-bold text-gray-900 mb-2"},"Create Your Secure PIN"),n.createElement("p",{className:"text-gray-600"},"Your PIN will be used to securely access your data")),n.createElement("form",{onSubmit:e=>{e.preventDefault(),s&&t({pin:o,pinCreated:!0,timestamp:(new Date).toISOString()})},className:"space-y-4"},n.createElement("div",null,n.createElement("label",{htmlFor:"pin",className:"block text-sm font-medium text-gray-700 mb-2"},"Create PIN"),n.createElement("input",{type:"password",id:"pin",value:o,onChange:e=>a(e.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"Enter your secure PIN"})),n.createElement("div",{className:"bg-gray-50 p-4 rounded-lg"},n.createElement("h4",{className:"text-sm font-medium text-gray-700 mb-3"},"PIN Requirements:"),n.createElement("div",{className:"space-y-2"},Object.entries({length:"At least 8 characters",number:"One number (0-9)",special:"One special character (!@#$%^&*)"}).map((e=>{let[t,r]=e;return n.createElement("div",{key:t,className:"flex items-center"},n.createElement("div",{className:"w-4 h-4 rounded-full mr-2 flex items-center justify-center ".concat(l[t]?"bg-green-500":"bg-gray-300")},l[t]&&n.createElement("svg",{className:"w-3 h-3 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},n.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"}))),n.createElement("span",{className:"text-sm ".concat(l[t]?"text-green-600":"text-gray-600")},r))})))),n.createElement("button",{type:"submit",disabled:!s,className:"w-full py-3 px-4 rounded-lg font-semibold transition-colors ".concat(s?"bg-blue-600 text-white hover:bg-blue-700":"bg-gray-300 text-gray-500 cursor-not-allowed")},"Create PIN")),r&&n.createElement("p",{className:"text-center text-sm text-gray-500 mt-4"},"Securing account for: ",n.createElement("span",{className:"font-medium"},r)))}const E={btnGradStart:"#1A1A1A",btnGradEnd:"#000000",btnLabel:"#FFFFFF",btnBorder:"rgba(0, 0, 0, 0.2)",iconCircleGradientStart:"#333333",iconCircleGradientEnd:"#1A1A1A",background:"#FFFFFF",backgroundSecondary:"#F8F9FA",textPrimary:"#1A1A1A",textSecondary:"#6B7280",textMuted:"#9CA3AF",border:"#E5E7EB",borderLight:"#F3F4F6",success:"#10B981",error:"#EF4444",warning:"#F59E0B",info:"#3B82F6",hover:"rgba(0, 0, 0, 0.05)",pressed:"rgba(0, 0, 0, 0.1)",focus:"rgba(59, 130, 246, 0.1)"},w=["label","onClick","iconRight","loading","disabled","testId","className","style","textStyle"];function N(){return N=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},N.apply(null,arguments)}function O(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function k(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?O(Object(r),!0).forEach((function(t){S(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):O(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function S(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const C=e=>{let{size:t=40,children:r,className:o=""}=e;return n.createElement("div",{className:"relative flex items-center justify-center border border-black border-opacity-25 ".concat(o),style:{width:t,height:t,borderRadius:t/2,background:"linear-gradient(to bottom, ".concat(E.iconCircleGradientStart,", ").concat(E.iconCircleGradientEnd,")")}},r||n.createElement("span",{className:"font-semibold opacity-95",style:{fontSize:"20px",color:E.btnLabel,backgroundColor:"transparent"}},"→"))},j=e=>{let{label:t="Get Started",onClick:r,iconRight:o,loading:a=!1,disabled:l=!1,testId:c,className:s="",style:i={},textStyle:u={}}=e,m=function(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(-1!==t.indexOf(n))continue;r[n]=e[n]}return r}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],-1===t.indexOf(r)&&{}.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(e,w);const[d,p]=(0,n.useState)(!1),f=k({height:"48px",borderRadius:"100px",border:"1px solid ".concat(E.btnBorder),background:"linear-gradient(to bottom, ".concat(E.btnGradStart,", ").concat(E.btnGradEnd,")"),position:"relative",overflow:"hidden",width:"100%",cursor:l?"not-allowed":"pointer",opacity:l?.65:1,boxShadow:l?"none":"20px 30px 40px rgba(0,0,0,0.10)",transition:"all 0.2s ease"},i),b={position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0,0,0,0.1)",borderRadius:"100px",opacity:d?1:0,transition:"opacity 0.1s ease"},g=k({fontFamily:"Inter, system-ui, sans-serif",fontWeight:"600",fontSize:"16px",color:E.btnLabel,textAlign:"center",backgroundColor:"transparent"},u);return n.createElement("button",N({className:"relative ".concat(s),style:f,onClick:r,onMouseDown:()=>p(!0),onMouseUp:()=>p(!1),onMouseLeave:()=>p(!1),disabled:l||a,"data-testid":c,"aria-label":t},m),n.createElement("div",{style:b}),n.createElement("div",{style:{position:"absolute",left:0,right:0,top:0,bottom:0,display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"transparent"}},a?n.createElement("div",{className:"animate-spin rounded-full border-2 border-white border-t-transparent",style:{width:"20px",height:"20px"}}):n.createElement("span",{style:g},t)),n.createElement("div",{style:{position:"absolute",right:"4px",top:"4px",bottom:"4px",width:"40px",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"transparent"}},!a&&(o||n.createElement(C,null))))};function P(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?P(Object(r),!0).forEach((function(t){I(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):P(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function I(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const A=[{id:"basic",name:"Basic Info",description:"Essential profile information, account details, and basic demographics",icon:"👤",required:!0,tooltip:"Includes name, email, basic profile information. This data is essential for personalization and is always included.",privacyLink:"https://onairos.uk/privacy#basic-info"},{id:"personality",name:"Personality",description:"Personality traits, behavioral patterns and psychological insights",icon:"🧠",required:!1,tooltip:"AI-analyzed personality traits based on your social media activity and interactions. Used to improve content recommendations.",privacyLink:"https://onairos.uk/privacy#personality-data"},{id:"preferences",name:"Preferences",description:"User preferences, interests, settings and personal choices",icon:"⚙️",required:!1,tooltip:"Your stated preferences and interests from connected platforms. Helps customize your experience.",privacyLink:"https://onairos.uk/privacy#preferences-data"}],R=e=>{let{children:t,content:r,privacyLink:o}=e;const[a,l]=(0,n.useState)(!1);return n.createElement("div",{className:"relative inline-block"},n.createElement("span",{onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),className:"border-b border-dotted border-gray-400 cursor-help"},t),a&&n.createElement("div",{className:"absolute z-50 w-64 p-3 mt-2 text-sm bg-white border border-gray-200 rounded-lg shadow-lg left-0"},n.createElement("p",{className:"mb-2 text-gray-700"},r),n.createElement("a",{href:o,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:text-blue-800 text-xs font-medium"},"Learn more about privacy →")))};function L(e){let{onComplete:t,userEmail:r,appName:o="App",autoFetch:a=!1,testMode:l=!1,connectedAccounts:c={}}=e;const[s,i]=(0,n.useState)({basic:!0,personality:!1,preferences:!1}),[u,m]=(0,n.useState)(!1),[d,p]=(0,n.useState)(!1),[f,b]=(0,n.useState)(null),[g,y]=(0,n.useState)(null),h=e=>{const t=A.find((t=>t.id===e));null!=t&&t.required||i((t=>_(_({},t),{},{[e]:!t[e]})))},v=async()=>{p(!0),y(null);try{const e=(e=>{let t=0;const r=e+Date.now().toString();for(let e=0;e<r.length;e++)t=(t<<5)-t+r.charCodeAt(e),t&=t;return"user_".concat(Math.abs(t).toString(36))})(r),n=Object.entries(s).filter((e=>{let[t,r]=e;return r})).map((e=>{let[t]=e;return t})),c=e=>{const t=[],r=(new Date).toISOString(),n={basic:"Medium",personality:"Large",preferences:"Traits"};return e.forEach((e=>{n[e]&&t.push({data:n[e],date:r})})),t},i=l?"https://api2.onairos.uk/inferenceTest":"https://api2.onairos.uk/getAPIurlMobile",u={userHash:e,appName:o,approvedData:n,apiUrl:i,testMode:l,timestamp:(new Date).toISOString()};if(!a)return t(u),u;try{const e=c(n),a=l?{approvedData:n,userEmail:r,appName:o,testMode:l,timestamp:(new Date).toISOString()}:{Info:{storage:"local",appId:o,confirmations:e,EncryptedUserPin:"pending_pin_integration",account:r,proofMode:!1,Domain:window.location.hostname,web3Type:"standard",OthentSub:null}},s=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":"onairos_web_sdk_live_key_2024"},body:JSON.stringify(a)});if(!s.ok)throw new Error("API request failed: ".concat(s.status));const m=await s.json();b(m);const d=_(_({},u),{},{apiResponse:m,success:!0});return setTimeout((()=>{t(d)}),1500),d}catch(e){console.error("API request failed:",e),y("API request failed: ".concat(e.message));const r=_(_({},u),{},{error:e.message,success:!1});return setTimeout((()=>{t(r)}),2e3),r}}catch(e){throw console.error("Data processing failed:",e),y("Processing failed: ".concat(e.message)),e}finally{p(!1)}},x=async e=>{e.preventDefault(),m(!0);try{const e=await v();e&&t(e)}catch(e){y("Submission failed: ".concat(e.message))}finally{m(!1)}},w=Object.values(s).filter(Boolean).length;return n.createElement("div",{className:"w-full space-y-6"},n.createElement("div",{className:"p-3 rounded-lg border",style:{backgroundColor:"#EBF8FF",borderColor:"#BEE3F8",color:"#2B6CB0"}},n.createElement("p",{className:"text-sm"},"🔒 Your selected data will be securely processed and used only for the intended purpose.")),n.createElement("div",{className:"mb-6"},n.createElement("h3",{className:"text-md font-semibold text-gray-900 mb-3"},"Data Types"),n.createElement("div",{className:"space-y-2 sm:space-y-3"},A.map((e=>{const t=s[e.id]||!1,r=e.required;return n.createElement("div",{key:e.id,className:"flex items-center justify-between p-3 sm:p-4 border rounded-lg transition-colors ".concat(r?"bg-gray-100 border-gray-300 cursor-not-allowed":"hover:bg-gray-50 cursor-pointer border-gray-200"),onClick:()=>(e=>{const t=A.find((t=>t.id===e));null!=t&&t.required||h(e)})(e.id)},n.createElement("div",{className:"flex items-center space-x-3"},n.createElement("div",{className:"text-xl sm:text-2xl"},e.icon),n.createElement("div",null,n.createElement("h4",{className:"font-medium text-gray-900 text-sm sm:text-base"},n.createElement(R,{content:e.tooltip,privacyLink:e.privacyLink},e.name),r&&n.createElement("span",{className:"text-gray-500 ml-1 text-xs"},"(Required)")),n.createElement("p",{className:"text-xs sm:text-sm text-gray-500"},e.description))),r?n.createElement("div",{className:"px-2 py-1 bg-gray-400 text-white text-xs rounded-full"},"Required"):n.createElement("button",{onClick:t=>{t.stopPropagation(),h(e.id)},className:"relative inline-flex h-5 sm:h-6 w-9 sm:w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 ".concat(t?"bg-blue-600":"bg-gray-200")},n.createElement("span",{className:"inline-block h-3 sm:h-4 w-3 sm:w-4 transform rounded-full bg-white transition-transform ".concat(t?"translate-x-5 sm:translate-x-6":"translate-x-1")})))})))),n.createElement("div",{className:"mb-3 sm:mb-4 p-2 sm:p-3 bg-green-50 border border-green-200 rounded-lg"},n.createElement("p",{className:"text-green-800 text-xs sm:text-sm"},"✅ ",w," data type",w>1?"s":""," selected")),d&&n.createElement("div",{className:"mb-3 sm:mb-4 p-2 sm:p-3 bg-blue-50 border border-blue-200 rounded-lg"},n.createElement("p",{className:"text-blue-800 text-xs sm:text-sm"},"🔄 Processing your data request...")),g&&n.createElement("div",{className:"mb-3 sm:mb-4 p-2 sm:p-3 bg-red-50 border border-red-200 rounded-lg"},n.createElement("p",{className:"text-red-800 text-xs sm:text-sm"},"❌ ",g)),n.createElement("form",{onSubmit:x,className:"space-y-4"},n.createElement(j,{label:u?"Processing...":"Share Selected Data",onClick:x,disabled:u||0===w,loading:u,testId:"share-data-button"}),n.createElement("button",{type:"button",onClick:()=>t({selectedData:{},selectedConnectors:[],cancelled:!0}),className:"w-full py-2 font-medium transition-colors text-sm",style:{color:E.textSecondary}},"Cancel")))}function D(e){var t,r,o,a,l;let{onComplete:c,userEmail:s,appName:i="App"}=e;const[u,m]=(0,n.useState)(0),[d,p]=(0,n.useState)(0),[f,b]=(0,n.useState)(!1),g=[{title:"Setting up your personal AI",description:"Initializing your secure data model",icon:"🤖",duration:2e3},{title:"Processing your connections",description:"Analyzing your social media patterns",icon:"🔗",duration:2500},{title:"Training your model",description:"Building your personalized insights",icon:"🧠",duration:3e3},{title:"Finalizing setup",description:"Preparing your Onairos experience",icon:"✨",duration:2e3}];return(0,n.useEffect)((()=>{let e,t;if(u<g.length){const r=g[u].duration,n=100/g.length;e=setInterval((()=>{p((e=>{const t=e+n/(r/100);return Math.min(t,(u+1)*n)}))}),100),t=setTimeout((()=>{u<g.length-1?m((e=>e+1)):(b(!0),setTimeout((()=>{c({trainingComplete:!0,timestamp:(new Date).toISOString(),userEmail:s,appName:i})}),1e3))}),r)}return()=>{e&&clearInterval(e),t&&clearTimeout(t)}}),[u,c,s,i]),n.createElement("div",{className:"w-full flex flex-col items-center space-y-8"},n.createElement("div",{className:"text-center"},n.createElement("div",{className:"w-20 h-20 rounded-full flex items-center justify-center mx-auto mb-4",style:{background:"linear-gradient(135deg, ".concat(E.info,", #8B5CF6)")}},n.createElement("div",{className:"text-3xl"},f?"🎉":null===(t=g[u])||void 0===t?void 0:t.icon)),n.createElement("h2",{className:"text-2xl font-bold mb-2",style:{color:E.textPrimary}},f?"All set!":null===(r=g[u])||void 0===r?void 0:r.title),n.createElement("p",{style:{color:E.textSecondary}},f?"Your personal AI is ready to use":null===(o=g[u])||void 0===o?void 0:o.description)),n.createElement("div",{className:"w-full"},n.createElement("div",{className:"flex justify-between text-sm mb-2",style:{color:E.textSecondary}},n.createElement("span",null,"Progress"),n.createElement("span",null,Math.round(d),"%")),n.createElement("div",{className:"w-full rounded-full h-2",style:{backgroundColor:E.borderLight}},n.createElement("div",{className:"h-2 rounded-full transition-all duration-300 ease-out",style:{width:"".concat(d,"%"),background:"linear-gradient(90deg, ".concat(E.info,", #8B5CF6)")}}))),n.createElement("div",{className:"flex justify-center space-x-2"},g.map(((e,t)=>n.createElement("div",{key:t,className:"w-3 h-3 rounded-full transition-all duration-300",style:{backgroundColor:t<=u?E.info:E.border}})))),n.createElement("div",{className:"p-4 rounded-lg w-full",style:{backgroundColor:E.backgroundSecondary}},n.createElement("div",{className:"flex items-center space-x-3"},n.createElement("div",{className:"w-8 h-8 rounded-full flex items-center justify-center",style:{backgroundColor:"#DBEAFE"}},n.createElement("div",{className:"text-sm"},f?"✅":null===(a=g[u])||void 0===a?void 0:a.icon)),n.createElement("div",null,n.createElement("h3",{className:"font-medium",style:{color:E.textPrimary}},f?"Training Complete":"Step ".concat(u+1," of ").concat(g.length)),n.createElement("p",{className:"text-sm",style:{color:E.textSecondary}},f?"Your Onairos experience is ready":null===(l=g[u])||void 0===l?void 0:l.description)))),n.createElement("div",{className:"text-center"},n.createElement("p",{className:"text-sm",style:{color:E.textSecondary}},"Setting up for ",n.createElement("span",{className:"font-medium"},i)),s&&n.createElement("p",{className:"text-xs mt-1",style:{color:E.textMuted}},s)))}function T(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function U(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const F=["Analyst","Diplomat","Sentinel","Explorer","Architect","Logician","Commander","Debater","Advocate","Mediator","Protagonist","Campaigner","Logistician","Defender","Executive","Consul"],M=["Openness","Conscientiousness","Extraversion","Agreeableness","Neuroticism"];function B(e){var t;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{includeDictionary:n=!0,includeArray:o=!0}=r;if(!e)return e;const a=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?T(Object(r),!0).forEach((function(t){U(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):T(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({},e);if(null!==(t=e.InferenceResult)&&void 0!==t&&t.traits||e.traits||e.scores){var l;const t=(null===(l=e.InferenceResult)||void 0===l?void 0:l.traits)||e.traits||e.scores;if(Array.isArray(t)&&t.length>=16){if(n){const e={};F.forEach(((r,n)=>{e[r]=t[n]})),a.InferenceResult?a.InferenceResult.personalityDict=e:a.personalityDict=e}var c;if(!o)null!==(c=a.InferenceResult)&&void 0!==c&&c.traits&&delete a.InferenceResult.traits,a.traits&&delete a.traits,a.scores&&delete a.scores}}if(e.traitResult||e.traits){const t=e.traitResult||e.traits;if(Array.isArray(t)&&n){const e={};M.forEach(((r,n)=>{void 0!==t[n]&&(e[r]=t[n])})),a.traitDict=e}}return a}function q(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function $(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?q(Object(r),!0).forEach((function(t){z(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):q(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function z(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function G(e){let{requestData:t,webpageName:r,inferenceData:o=null,onComplete:a=null,autoFetch:l=!1,testMode:c=!1,proofMode:s=!1,textLayout:i="below",textColor:u="white",login:m=!1,buttonType:d="pill",loginReturn:f=null,loginType:b="signIn",visualType:g="full",appIcon:y=null,enableTraining:h=!0,formatResponse:E=!0,responseFormat:w={includeDictionary:!0,includeArray:!0}}=e;const[N,O]=(0,n.useState)(!1),[k,S]=(0,n.useState)("email"),[C,j]=(0,n.useState)(null),[P,_]=(0,n.useState)(null);(0,n.useEffect)((()=>{(()=>{const e=localStorage.getItem("onairosUser");if(e)try{const t=JSON.parse(e);j(t),t.onboardingComplete&&t.pinCreated?S("dataRequest"):t.verified&&!t.onboardingComplete?S("onboarding"):t.onboardingComplete&&!t.pinCreated&&S("pin")}catch(e){console.error("Error parsing saved user data:",e),localStorage.removeItem("onairosUser")}})()}),[]);const I=()=>{O(!1),_(null)},A=e=>{console.log("🔥 Email auth successful:",e),console.log("🔧 User State:",{isNewUser:e.isNewUser,userState:e.userState,flowType:e.flowType,existingUser:e.existingUser});const t=!0===e.isNewUser||"onboarding"===e.flowType||"new"===e.userState,r=$($({},e),{},{verified:!0,onboardingComplete:!t,pinCreated:!t});j(r),localStorage.setItem("onairosUser",JSON.stringify(r)),t?(console.log("🚀 New user detected → Starting onboarding flow (includes training)"),S("onboarding")):(console.log("👋 Existing user detected → Going directly to data request"),S("dataRequest"))},R=e=>{console.log("Onboarding completed:",e);const t=$($({},C),{},{onboardingComplete:!0,connectedAccounts:e.connectedAccounts||[]});j(t),localStorage.setItem("onairosUser",JSON.stringify(t)),S("pin")},T=e=>{console.log("PIN setup completed:",e);const t=$($($({},C),e),{},{pinCreated:!0});j(t),localStorage.setItem("onairosUser",JSON.stringify(t)),S("dataRequest")},U=e=>{console.log("🎓 Training completed:",e);const t=$($({},C),{},{trainingCompleted:!0},e);j(t),localStorage.setItem("onairosUser",JSON.stringify(t)),S("dataRequest")},F=e=>{console.log("🔥 OnairosButton: Data request completed:",e);const t=$($({},C),{},{lastDataRequest:e});j(t),localStorage.setItem("onairosUser",JSON.stringify(t)),O(!1);let r=e;if(E&&null!=e&&e.apiResponse)try{var n;r=$($({},e),{},{apiResponse:B(e.apiResponse,w)}),console.log("🔥 Response formatted with dictionary:",(null===(n=r.apiResponse)||void 0===n?void 0:n.personalityDict)||"No personality data")}catch(e){console.warn("🔥 Error formatting response:",e)}if(console.log("🔥 Calling onComplete callback with:",r),a)try{a(r),console.log("🔥 onComplete callback executed successfully")}catch(e){console.error("🔥 Error in onComplete callback:",e)}else console.log("🔥 No onComplete callback provided")},M="flex items-center justify-center font-bold rounded cursor-pointer ".concat("pill"===d?"px-4 py-2":"w-12 h-12"," bg-transparent OnairosConnect"),q={flexDirection:"below"===i?"column":"row",backgroundColor:"transparent",color:u,border:"1px solid transparent"},z={width:"20px",height:"20px",marginRight:"full"===g?"12px":"0"};return n.createElement(n.Fragment,null,n.createElement("button",{className:M,onClick:async()=>{try{console.log("🔥 openTerminal called"),O(!0)}catch(e){console.error("Error in openTerminal:",e)}},style:q},("full"===g||"icon"===g)&&n.createElement("img",{src:m?"https://onairos.sirv.com/Images/OnairosWhite.png":"https://onairos.sirv.com/Images/OnairosBlack.png",alt:"Onairos Logo",style:z}),"icon"!==g&&n.createElement("span",{className:"".concat("black"===u?"text-black":"text-white"," ").concat("icon"===g?"sr-only":""," ").concat("right"===i?"ml-2":"left"===i?"mr-2":"")},(()=>{switch(b){case"signUp":return"Sign Up with Onairos";case"signOut":return"Sign Out of Onairos";default:return"Sign In with Onairos"}})())),N&&n.createElement("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",onClick:e=>{e.target===e.currentTarget&&I()}},n.createElement("div",{className:"bg-white rounded-lg shadow-xl max-w-md w-full mx-4 max-h-[90vh] overflow-hidden relative",onClick:e=>e.stopPropagation()},n.createElement("button",{onClick:I,className:"absolute top-4 right-4 text-gray-400 hover:text-gray-600 z-10"},n.createElement("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},n.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"}))),n.createElement("div",{className:"overflow-y-auto max-h-[90vh]"},(()=>{switch(k){case"email":return n.createElement(p,{onSuccess:A,testMode:c});case"onboarding":return n.createElement(v,{onComplete:R,appIcon:y||"https://onairos.sirv.com/Images/OnairosBlack.png",appName:r,username:(null==C?void 0:C.email)||(null==C?void 0:C.username)});case"pin":return n.createElement(x,{onComplete:T,userEmail:null==C?void 0:C.email});case"training":return n.createElement(D,{onComplete:U,userEmail:null==C?void 0:C.email,appName:r,connectedAccounts:(null==C?void 0:C.connectedAccounts)||[]});case"dataRequest":return n.createElement(L,{onComplete:F,userEmail:null==C?void 0:C.email,requestData:t,appName:r,autoFetch:l,testMode:c,appIcon:y,connectedAccounts:(null==C?void 0:C.connectedAccounts)||{}});default:return n.createElement("div",{className:"flex flex-col items-center space-y-4 p-6"},n.createElement("div",{className:"animate-spin h-8 w-8 border-2 border-blue-600 rounded-full border-t-transparent"}),n.createElement("p",{className:"text-gray-600"},"Loading..."))}})()))))}},408:(e,t)=>{var r=Symbol.for("react.element"),n=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),s=Symbol.for("react.context"),i=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),p=Symbol.iterator;var f={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},b=Object.assign,g={};function y(e,t,r){this.props=e,this.context=t,this.refs=g,this.updater=r||f}function h(){}function v(e,t,r){this.props=e,this.context=t,this.refs=g,this.updater=r||f}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},h.prototype=y.prototype;var x=v.prototype=new h;x.constructor=v,b(x,y.prototype),x.isPureReactComponent=!0;var E=Array.isArray,w=Object.prototype.hasOwnProperty,N={current:null},O={key:!0,ref:!0,__self:!0,__source:!0};function k(e,t,n){var o,a={},l=null,c=null;if(null!=t)for(o in void 0!==t.ref&&(c=t.ref),void 0!==t.key&&(l=""+t.key),t)w.call(t,o)&&!O.hasOwnProperty(o)&&(a[o]=t[o]);var s=arguments.length-2;if(1===s)a.children=n;else if(1<s){for(var i=Array(s),u=0;u<s;u++)i[u]=arguments[u+2];a.children=i}if(e&&e.defaultProps)for(o in s=e.defaultProps)void 0===a[o]&&(a[o]=s[o]);return{$$typeof:r,type:e,key:l,ref:c,props:a,_owner:N.current}}function S(e){return"object"==typeof e&&null!==e&&e.$$typeof===r}var C=/\/+/g;function j(e,t){return"object"==typeof e&&null!==e&&null!=e.key?function(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,(function(e){return t[e]}))}(""+e.key):t.toString(36)}function P(e,t,o,a,l){var c=typeof e;"undefined"!==c&&"boolean"!==c||(e=null);var s=!1;if(null===e)s=!0;else switch(c){case"string":case"number":s=!0;break;case"object":switch(e.$$typeof){case r:case n:s=!0}}if(s)return l=l(s=e),e=""===a?"."+j(s,0):a,E(l)?(o="",null!=e&&(o=e.replace(C,"$&/")+"/"),P(l,t,o,"",(function(e){return e}))):null!=l&&(S(l)&&(l=function(e,t){return{$$typeof:r,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}(l,o+(!l.key||s&&s.key===l.key?"":(""+l.key).replace(C,"$&/")+"/")+e)),t.push(l)),1;if(s=0,a=""===a?".":a+":",E(e))for(var i=0;i<e.length;i++){var u=a+j(c=e[i],i);s+=P(c,t,o,u,l)}else if(u=function(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=p&&e[p]||e["@@iterator"])?e:null}(e),"function"==typeof u)for(e=u.call(e),i=0;!(c=e.next()).done;)s+=P(c=c.value,t,o,u=a+j(c,i++),l);else if("object"===c)throw t=String(e),Error("Objects are not valid as a React child (found: "+("[object Object]"===t?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return s}function _(e,t,r){if(null==e)return e;var n=[],o=0;return P(e,n,"","",(function(e){return t.call(r,e,o++)})),n}function I(e){if(-1===e._status){var t=e._result;(t=t()).then((function(t){0!==e._status&&-1!==e._status||(e._status=1,e._result=t)}),(function(t){0!==e._status&&-1!==e._status||(e._status=2,e._result=t)})),-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var A={current:null},R={transition:null},L={ReactCurrentDispatcher:A,ReactCurrentBatchConfig:R,ReactCurrentOwner:N};function D(){throw Error("act(...) is not supported in production builds of React.")}t.Children={map:_,forEach:function(e,t,r){_(e,(function(){t.apply(this,arguments)}),r)},count:function(e){var t=0;return _(e,(function(){t++})),t},toArray:function(e){return _(e,(function(e){return e}))||[]},only:function(e){if(!S(e))throw Error("React.Children.only expected to receive a single React element child.");return e}},t.Component=y,t.Fragment=o,t.Profiler=l,t.PureComponent=v,t.StrictMode=a,t.Suspense=u,t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=L,t.act=D,t.cloneElement=function(e,t,n){if(null==e)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var o=b({},e.props),a=e.key,l=e.ref,c=e._owner;if(null!=t){if(void 0!==t.ref&&(l=t.ref,c=N.current),void 0!==t.key&&(a=""+t.key),e.type&&e.type.defaultProps)var s=e.type.defaultProps;for(i in t)w.call(t,i)&&!O.hasOwnProperty(i)&&(o[i]=void 0===t[i]&&void 0!==s?s[i]:t[i])}var i=arguments.length-2;if(1===i)o.children=n;else if(1<i){s=Array(i);for(var u=0;u<i;u++)s[u]=arguments[u+2];o.children=s}return{$$typeof:r,type:e.type,key:a,ref:l,props:o,_owner:c}},t.createContext=function(e){return(e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null}).Provider={$$typeof:c,_context:e},e.Consumer=e},t.createElement=k,t.createFactory=function(e){var t=k.bind(null,e);return t.type=e,t},t.createRef=function(){return{current:null}},t.forwardRef=function(e){return{$$typeof:i,render:e}},t.isValidElement=S,t.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:I}},t.memo=function(e,t){return{$$typeof:m,type:e,compare:void 0===t?null:t}},t.startTransition=function(e){var t=R.transition;R.transition={};try{e()}finally{R.transition=t}},t.unstable_act=D,t.useCallback=function(e,t){return A.current.useCallback(e,t)},t.useContext=function(e){return A.current.useContext(e)},t.useDebugValue=function(){},t.useDeferredValue=function(e){return A.current.useDeferredValue(e)},t.useEffect=function(e,t){return A.current.useEffect(e,t)},t.useId=function(){return A.current.useId()},t.useImperativeHandle=function(e,t,r){return A.current.useImperativeHandle(e,t,r)},t.useInsertionEffect=function(e,t){return A.current.useInsertionEffect(e,t)},t.useLayoutEffect=function(e,t){return A.current.useLayoutEffect(e,t)},t.useMemo=function(e,t){return A.current.useMemo(e,t)},t.useReducer=function(e,t,r){return A.current.useReducer(e,t,r)},t.useRef=function(e){return A.current.useRef(e)},t.useState=function(e){return A.current.useState(e)},t.useSyncExternalStore=function(e,t,r){return A.current.useSyncExternalStore(e,t,r)},t.useTransition=function(){return A.current.useTransition()},t.version="18.3.1"},294:(e,t,r)=>{e.exports=r(408)}}]);
2
+ //# sourceMappingURL=845.js.map