onairos
Version:
The Onairos Library is a collection of functions that enable Applications to connect and communicate data with Onairos Identities via User Authorization. Integration for developers is seamless, simple and effective for all applications. LLM SDK capabiliti
1 lines • 51.9 kB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define("Onairos",["React"],t):"object"==typeof exports?exports.Onairos=t(require("react")):e.Onairos=t(e.React)}(this,(e=>(()=>{"use strict";var t={639:t=>{t.exports=e}},n={};function s(e){var o=n[e];if(void 0!==o)return o.exports;var a=n[e]={exports:{}};return t[e](a,a.exports,s),a.exports}s.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},s.d=(e,t)=>{for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{s.r(o),s.d(o,{Onairos:()=>B,default:()=>q});var e=s(639),t=s.n(e);const n=e=>{const t=(e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,((e,t,n)=>n?n.toUpperCase():t.toLowerCase())))(e);return t.charAt(0).toUpperCase()+t.slice(1)},a=(...e)=>e.filter(((e,t,n)=>Boolean(e)&&""!==e.trim()&&n.indexOf(e)===t)).join(" ").trim(),r=e=>{for(const t in e)if(t.startsWith("aria-")||"role"===t||"title"===t)return!0};var l={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 i=(0,e.forwardRef)((({color:t="currentColor",size:n=24,strokeWidth:s=2,absoluteStrokeWidth:o,className:i="",children:c,iconNode:m,...d},u)=>(0,e.createElement)("svg",{ref:u,...l,width:n,height:n,stroke:t,strokeWidth:o?24*Number(s)/Number(n):s,className:a("lucide",i),...!c&&!r(d)&&{"aria-hidden":"true"},...d},[...m.map((([t,n])=>(0,e.createElement)(t,n))),...Array.isArray(c)?c:[c]]))),c=(t,s)=>{const o=(0,e.forwardRef)((({className:o,...r},l)=>{return(0,e.createElement)(i,{ref:l,iconNode:s,className:a(`lucide-${c=n(t),c.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,`lucide-${t}`,o),...r});var c}));return o.displayName=n(t),o},m=c("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"}]]),d=c("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]),u=c("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);function p(n){let{onSuccess:s,testMode:o=!0}=n;const[a,r]=(0,e.useState)(""),[l,i]=(0,e.useState)(""),[c,p]=(0,e.useState)("email"),[h,g]=(0,e.useState)(!1),[b,y]=(0,e.useState)(""),f=async e=>{if(e.preventDefault(),y(""),(e=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e))(a)){g(!0);try{if(o)setTimeout((()=>{p("code"),g(!1)}),1e3);else{if(!(await fetch("https://api2.onairos.uk/auth/send-code",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:a})})).ok)throw new Error("Failed to send verification code");p("code"),g(!1)}}catch(e){y(e.message),g(!1)}}else y("Please enter a valid email address")},x=async e=>{if(e.preventDefault(),y(""),o&&"123456"===l)return p("success"),void setTimeout((()=>{s({email:a,verified:!0})}),1e3);if(o)y("Invalid code. Use 123456 for testing.");else{g(!0);try{const e=await fetch("https://api2.onairos.uk/auth/verify-code",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:a,code:l})});if(!e.ok)throw new Error("Invalid verification code");const t=await e.json();p("success"),setTimeout((()=>{s({email:a,verified:!0,token:t.token})}),1e3)}catch(e){y(e.message),g(!1)}}};return t().createElement("div",{className:"flex flex-col items-center space-y-6 p-6 w-full"},"email"===c&&t().createElement("div",{className:"flex flex-col items-center space-y-6 w-full"},t().createElement("div",{className:"flex items-center justify-center w-16 h-16 bg-blue-100 rounded-full"},t().createElement(m,{className:"w-8 h-8 text-blue-600"})),t().createElement("div",{className:"text-center"},t().createElement("h2",{className:"text-xl font-semibold text-gray-900 mb-2"},"Sign in to Onairos"),t().createElement("p",{className:"text-gray-600"},"Enter your email address to continue"),o&&t().createElement("p",{className:"text-sm text-blue-600 mt-2"},"Test mode: Any valid email will work")),t().createElement("form",{onSubmit:f,className:"w-full max-w-md space-y-4"},t().createElement("div",null,t().createElement("label",{htmlFor:"email",className:"block text-sm font-medium text-gray-700 mb-1"},"Email address"),t().createElement("input",{type:"email",id:"email",value:a,onChange:e=>r(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&&t().createElement("p",{className:"text-sm text-red-600"},b),t().createElement("button",{type:"submit",disabled:h,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"},h?t().createElement("div",{className:"animate-spin h-5 w-5 border-2 border-white rounded-full border-t-transparent"}):t().createElement(t().Fragment,null,"Continue",t().createElement(d,{className:"ml-2 w-4 h-4"}))))),"code"===c&&t().createElement("div",{className:"flex flex-col items-center space-y-6 w-full"},t().createElement("div",{className:"flex items-center justify-center w-16 h-16 bg-green-100 rounded-full"},t().createElement(m,{className:"w-8 h-8 text-green-600"})),t().createElement("div",{className:"text-center"},t().createElement("h2",{className:"text-xl font-semibold text-gray-900 mb-2"},"Check your email"),t().createElement("p",{className:"text-gray-600"},"We sent a verification code to"),t().createElement("p",{className:"text-gray-900 font-medium"},a),o&&t().createElement("p",{className:"text-sm text-blue-600 mt-2"},"Test mode: Use code 123456")),t().createElement("form",{onSubmit:x,className:"w-full max-w-md space-y-4"},t().createElement("div",null,t().createElement("label",{htmlFor:"code",className:"block text-sm font-medium text-gray-700 mb-1"},"Verification code"),t().createElement("input",{type:"text",id:"code",value:l,onChange:e=>i(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&&t().createElement("p",{className:"text-sm text-red-600"},b),t().createElement("button",{type:"submit",disabled:h,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"},h?t().createElement("div",{className:"animate-spin h-5 w-5 border-2 border-white rounded-full border-t-transparent"}):"Verify Code"),t().createElement("button",{type:"button",onClick:()=>p("email"),className:"w-full py-2 px-4 text-gray-600 hover:text-gray-800"},"Use a different email"))),"success"===c&&t().createElement("div",{className:"flex flex-col items-center space-y-6 w-full"},t().createElement("div",{className:"flex items-center justify-center w-16 h-16 bg-green-100 rounded-full"},t().createElement(u,{className:"w-8 h-8 text-green-600"})),t().createElement("div",{className:"text-center"},t().createElement("h2",{className:"text-xl font-semibold text-gray-900 mb-2"},"Email verified!"),t().createElement("p",{className:"text-gray-600"},"Setting up your account...")),t().createElement("div",{className:"w-8 h-8"},t().createElement("div",{className:"animate-spin h-8 w-8 border-2 border-blue-600 rounded-full border-t-transparent"}))))}class h extends e.Component{constructor(e){super(e),this.state={connected:!1,open:!1,isConnecting:!1},this.handleClose=this.handleClose.bind(this),this.handleOpen=this.handleOpen.bind(this),this.youtubeConnect=this.youtubeConnect.bind(this),this.setConnected=this.setConnected.bind(this),this.setDisconnected=this.setDisconnected.bind(this)}setConnected(){this.setState({connected:!0}),this.props.onConnectionChange&&this.props.onConnectionChange("YouTube",!0),this.handleClose()}setDisconnected(){this.updateConnections("Remove","Youtube").then((()=>{this.setState({connected:!1}),this.props.onConnectionChange&&this.props.onConnectionChange("YouTube",!1),this.handleClose()})).catch((e=>{console.error("Error removing YouTube connection:",e)}))}async updateConnections(e,t){const n={session:{username:localStorage.getItem("username")||this.props.username},updateType:e,newConnection:t};try{const e=await fetch("https://api2.onairos.uk/connections/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});return await e.json()}catch(e){throw console.error("UpdateConnections error:",e),e}}handleOpen(){this.setState({open:!0})}handleClose(){this.setState({open:!1}),this.props.onClose&&this.props.onClose()}async youtubeConnect(){this.setState({isConnecting:!0});const e={session:{username:localStorage.getItem("username")||this.props.username}};try{const t=await fetch("https://api2.onairos.uk/youtube/authorize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await t.json();n.youtubeURL?window.location.href=n.youtubeURL:(console.error("No YouTube URL received"),this.setState({isConnecting:!1}))}catch(e){console.error("YouTube connection error:",e),this.setState({isConnecting:!1})}}render(){const{open:e=this.props.open||this.state.open}=this.props;return e?t().createElement("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50"},t().createElement("div",{className:"bg-white rounded-lg shadow-xl max-w-md w-full mx-4 max-h-[90vh] overflow-hidden"},t().createElement("div",{className:"p-6"},t().createElement("h2",{className:"text-xl font-bold text-gray-900 mb-4"},"Grant Onairos Access to your YouTube Account?"),t().createElement("div",{className:"space-y-4 text-gray-700"},t().createElement("p",null,"Grant Permission to your YouTube Account, so we can build your Data Models."),t().createElement("div",null,t().createElement("p",{className:"font-medium mb-2"},"We will access your YouTube:"),t().createElement("ul",{className:"list-disc ml-6 space-y-1"},t().createElement("li",null,"Basic Account Info"),t().createElement("li",null,"Liked and Watched Videos"),t().createElement("li",null,"Subscribed Channels and Playlist Videos"))),t().createElement("p",null,"We will delete all the data used once your Model is Created"),t().createElement("p",{className:"text-sm"},t().createElement("a",{href:"https://onairos.uk/compliance-google-policy",className:"text-blue-600 hover:underline"},"Onairos")," ","complies with"," ",t().createElement("a",{href:"https://policies.google.com/privacy",className:"text-blue-600 hover:underline"},"Google API Services User Data Policy"))),t().createElement("div",{className:"flex space-x-3 mt-6"},t().createElement("button",{onClick:this.handleClose,disabled:this.state.isConnecting,className:"flex-1 px-4 py-2 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50 disabled:opacity-50"},"Disagree"),t().createElement("button",{onClick:this.youtubeConnect,disabled:this.state.isConnecting,className:"flex-1 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50"},this.state.isConnecting?"Connecting...":"Agree"))))):null}}const g=h;class b extends e.Component{constructor(e){super(e),this.state={connected:!1,open:!1,isConnecting:!1},this.handleClose=this.handleClose.bind(this),this.handleOpen=this.handleOpen.bind(this),this.linkedinConnect=this.linkedinConnect.bind(this),this.setConnected=this.setConnected.bind(this),this.setDisconnected=this.setDisconnected.bind(this)}setConnected(){this.setState({connected:!0}),this.props.onConnectionChange&&this.props.onConnectionChange("LinkedIn",!0),this.handleClose()}setDisconnected(){this.updateConnections("Remove","LinkedIn").then((()=>{this.setState({connected:!1}),this.props.onConnectionChange&&this.props.onConnectionChange("LinkedIn",!1),this.handleClose()})).catch((e=>{console.error("Error removing LinkedIn connection:",e)}))}async updateConnections(e,t){const n={session:{username:localStorage.getItem("username")||this.props.username},updateType:e,newConnection:t};try{const e=await fetch("https://api2.onairos.uk/connections/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});return await e.json()}catch(e){throw console.error("UpdateConnections error:",e),e}}handleOpen(){this.setState({open:!0})}handleClose(){this.setState({open:!1}),this.props.onClose&&this.props.onClose()}async linkedinConnect(){this.setState({isConnecting:!0});const e={session:{username:localStorage.getItem("username")||this.props.username}};try{const t=await fetch("https://api2.onairos.uk/linkedin/authorize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await t.json();n.linkedinURL?window.location.href=n.linkedinURL:(console.error("No LinkedIn URL received"),this.setState({isConnecting:!1}))}catch(e){console.error("LinkedIn connection error:",e),this.setState({isConnecting:!1})}}render(){const{open:e=this.props.open||this.state.open}=this.props;return e?t().createElement("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50"},t().createElement("div",{className:"bg-white rounded-lg shadow-xl max-w-md w-full mx-4 max-h-[90vh] overflow-hidden"},t().createElement("div",{className:"p-6"},t().createElement("h2",{className:"text-xl font-bold text-gray-900 mb-4"},"Grant Onairos Access to your LinkedIn Account?"),t().createElement("div",{className:"space-y-4 text-gray-700"},t().createElement("p",null,"Grant Permission to your LinkedIn Account, so we can build your Data Models."),t().createElement("div",null,t().createElement("p",{className:"font-medium mb-2"},"We will access your LinkedIn:"),t().createElement("ul",{className:"list-disc ml-6 space-y-1"},t().createElement("li",null,"Basic Profile Information"),t().createElement("li",null,"Professional Experience"),t().createElement("li",null,"Network Connections"),t().createElement("li",null,"Posts and Activity"))),t().createElement("p",null,"We will delete all the data used once your Model is Created"),t().createElement("p",{className:"text-sm"},t().createElement("a",{href:"https://onairos.uk/privacy-policy",className:"text-blue-600 hover:underline"},"Onairos Privacy Policy")," ","- Your professional data is handled with the highest security standards.")),t().createElement("div",{className:"flex space-x-3 mt-6"},t().createElement("button",{onClick:this.handleClose,disabled:this.state.isConnecting,className:"flex-1 px-4 py-2 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50 disabled:opacity-50"},"Disagree"),t().createElement("button",{onClick:this.linkedinConnect,disabled:this.state.isConnecting,className:"flex-1 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50"},this.state.isConnecting?"Connecting...":"Agree"))))):null}}const y=b;class f extends e.Component{constructor(e){super(e),this.state={connected:!1,open:!1,isConnecting:!1},this.handleClose=this.handleClose.bind(this),this.handleOpen=this.handleOpen.bind(this),this.instagramConnect=this.instagramConnect.bind(this),this.setConnected=this.setConnected.bind(this),this.setDisconnected=this.setDisconnected.bind(this)}setConnected(){this.setState({connected:!0}),this.props.onConnectionChange&&this.props.onConnectionChange("Instagram",!0),this.handleClose()}setDisconnected(){this.updateConnections("Remove","Instagram").then((()=>{this.setState({connected:!1}),this.props.onConnectionChange&&this.props.onConnectionChange("Instagram",!1),this.handleClose()})).catch((e=>{console.error("Error removing Instagram connection:",e)}))}async updateConnections(e,t){const n={session:{username:localStorage.getItem("username")||this.props.username},updateType:e,newConnection:t};try{const e=await fetch("https://api2.onairos.uk/connections/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});return await e.json()}catch(e){throw console.error("UpdateConnections error:",e),e}}handleOpen(){this.setState({open:!0})}handleClose(){this.setState({open:!1}),this.props.onClose&&this.props.onClose()}async instagramConnect(){this.setState({isConnecting:!0});const e={session:{username:localStorage.getItem("username")||this.props.username}};try{const t=await fetch("https://api2.onairos.uk/instagram/authorize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await t.json();n.instagramURL?window.location.href=n.instagramURL:(console.error("No Instagram URL received"),this.setState({isConnecting:!1}))}catch(e){console.error("Instagram connection error:",e),this.setState({isConnecting:!1})}}render(){const{open:e=this.props.open||this.state.open}=this.props;return e?t().createElement("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50"},t().createElement("div",{className:"bg-white rounded-lg shadow-xl max-w-md w-full mx-4 max-h-[90vh] overflow-hidden"},t().createElement("div",{className:"p-6"},t().createElement("h2",{className:"text-xl font-bold text-gray-900 mb-4"},"Grant Onairos Access to your Instagram Account?"),t().createElement("div",{className:"space-y-4 text-gray-700"},t().createElement("p",null,"Grant Permission to your Instagram Account, so we can build your Data Models."),t().createElement("div",null,t().createElement("p",{className:"font-medium mb-2"},"We will access your Instagram:"),t().createElement("ul",{className:"list-disc ml-6 space-y-1"},t().createElement("li",null,"Basic Profile Information"),t().createElement("li",null,"Posts and Stories"),t().createElement("li",null,"Liked Content"),t().createElement("li",null,"Following and Followers"))),t().createElement("p",null,"We will delete all the data used once your Model is Created"),t().createElement("p",{className:"text-sm"},t().createElement("a",{href:"https://onairos.uk/compliance-meta-policy",className:"text-blue-600 hover:underline"},"Onairos")," ","complies with"," ",t().createElement("a",{href:"https://developers.facebook.com/policy",className:"text-blue-600 hover:underline"},"Meta Platform Policy"))),t().createElement("div",{className:"flex space-x-3 mt-6"},t().createElement("button",{onClick:this.handleClose,disabled:this.state.isConnecting,className:"flex-1 px-4 py-2 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50 disabled:opacity-50"},"Disagree"),t().createElement("button",{onClick:this.instagramConnect,disabled:this.state.isConnecting,className:"flex-1 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50"},this.state.isConnecting?"Connecting...":"Agree"))))):null}}const x=f;class C extends e.Component{constructor(e){super(e),this.state={connected:!1,open:!1,isConnecting:!1},this.handleClose=this.handleClose.bind(this),this.handleOpen=this.handleOpen.bind(this),this.pinterestConnect=this.pinterestConnect.bind(this),this.setConnected=this.setConnected.bind(this),this.setDisconnected=this.setDisconnected.bind(this)}setConnected(){this.setState({connected:!0}),this.props.onConnectionChange&&this.props.onConnectionChange("Pinterest",!0),this.handleClose()}setDisconnected(){this.updateConnections("Remove","Pinterest").then((()=>{this.setState({connected:!1}),this.props.onConnectionChange&&this.props.onConnectionChange("Pinterest",!1),this.handleClose()})).catch((e=>{console.error("Error removing Pinterest connection:",e)}))}async updateConnections(e,t){const n={session:{username:localStorage.getItem("username")||this.props.username},updateType:e,newConnection:t};try{const e=await fetch("https://api2.onairos.uk/connections/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});return await e.json()}catch(e){throw console.error("UpdateConnections error:",e),e}}handleOpen(){this.setState({open:!0})}handleClose(){this.setState({open:!1}),this.props.onClose&&this.props.onClose()}async pinterestConnect(){this.setState({isConnecting:!0});const e={session:{username:localStorage.getItem("username")||this.props.username}};try{const t=await fetch("https://api2.onairos.uk/pinterest/authorize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await t.json();n.pinterestURL?window.location.href=n.pinterestURL:(console.error("No Pinterest URL received"),this.setState({isConnecting:!1}))}catch(e){console.error("Pinterest connection error:",e),this.setState({isConnecting:!1})}}render(){const{open:e=this.props.open||this.state.open}=this.props;return e?t().createElement("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50"},t().createElement("div",{className:"bg-white rounded-lg shadow-xl max-w-md w-full mx-4 max-h-[90vh] overflow-hidden"},t().createElement("div",{className:"p-6"},t().createElement("h2",{className:"text-xl font-bold text-gray-900 mb-4"},"Grant Onairos Access to your Pinterest Account?"),t().createElement("div",{className:"space-y-4 text-gray-700"},t().createElement("p",null,"Grant Permission to your Pinterest Account, so we can build your Data Models."),t().createElement("div",null,t().createElement("p",{className:"font-medium mb-2"},"We will access your Pinterest:"),t().createElement("ul",{className:"list-disc ml-6 space-y-1"},t().createElement("li",null,"Basic Profile Information"),t().createElement("li",null,"Boards and Pins"),t().createElement("li",null,"Saved and Liked Pins"),t().createElement("li",null,"Following and Followers"))),t().createElement("p",null,"We will delete all the data used once your Model is Created"),t().createElement("p",{className:"text-sm"},t().createElement("a",{href:"https://onairos.uk/privacy-policy",className:"text-blue-600 hover:underline"},"Onairos Privacy Policy")," ","- Your creative interests and preferences are securely processed.")),t().createElement("div",{className:"flex space-x-3 mt-6"},t().createElement("button",{onClick:this.handleClose,disabled:this.state.isConnecting,className:"flex-1 px-4 py-2 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50 disabled:opacity-50"},"Disagree"),t().createElement("button",{onClick:this.pinterestConnect,disabled:this.state.isConnecting,className:"flex-1 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50"},this.state.isConnecting?"Connecting...":"Agree"))))):null}}const E=C;class v extends e.Component{constructor(e){super(e),this.state={connected:!1,open:!1,isConnecting:!1},this.handleClose=this.handleClose.bind(this),this.handleOpen=this.handleOpen.bind(this),this.redditConnect=this.redditConnect.bind(this),this.setConnected=this.setConnected.bind(this),this.setDisconnected=this.setDisconnected.bind(this)}setConnected(){this.setState({connected:!0}),this.props.onConnectionChange&&this.props.onConnectionChange("Reddit",!0),this.handleClose()}setDisconnected(){this.updateConnections("Remove","Reddit").then((()=>{this.setState({connected:!1}),this.props.onConnectionChange&&this.props.onConnectionChange("Reddit",!1),this.handleClose()})).catch((e=>{console.error("Error removing Reddit connection:",e)}))}async updateConnections(e,t){const n={session:{username:localStorage.getItem("username")||this.props.username},updateType:e,newConnection:t};try{const e=await fetch("https://api2.onairos.uk/connections/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});return await e.json()}catch(e){throw console.error("UpdateConnections error:",e),e}}handleOpen(){this.setState({open:!0})}handleClose(){this.setState({open:!1}),this.props.onClose&&this.props.onClose()}async redditConnect(){this.setState({isConnecting:!0});const e={session:{username:localStorage.getItem("username")||this.props.username}};try{const t=await fetch("https://api2.onairos.uk/reddit/authorize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await t.json();n.redditURL?window.location.href=n.redditURL:(console.error("No Reddit URL received"),this.setState({isConnecting:!1}))}catch(e){console.error("Reddit connection error:",e),this.setState({isConnecting:!1})}}render(){const{open:e=this.props.open||this.state.open}=this.props;return e?t().createElement("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50"},t().createElement("div",{className:"bg-white rounded-lg shadow-xl max-w-md w-full mx-4 max-h-[90vh] overflow-hidden"},t().createElement("div",{className:"p-6"},t().createElement("h2",{className:"text-xl font-bold text-gray-900 mb-4"},"Grant Onairos Access to your Reddit Account?"),t().createElement("div",{className:"space-y-4 text-gray-700"},t().createElement("p",null,"Grant Permission to your Reddit Account, so we can build your Data Models."),t().createElement("div",null,t().createElement("p",{className:"font-medium mb-2"},"We will access your Reddit:"),t().createElement("ul",{className:"list-disc ml-6 space-y-1"},t().createElement("li",null,"Basic Profile Information"),t().createElement("li",null,"Posts and Comments"),t().createElement("li",null,"Upvoted and Saved Content"),t().createElement("li",null,"Subscribed Subreddits"))),t().createElement("p",null,"We will delete all the data used once your Model is Created"),t().createElement("p",{className:"text-sm"},t().createElement("a",{href:"https://onairos.uk/privacy-policy",className:"text-blue-600 hover:underline"},"Onairos Privacy Policy")," ","- Your Reddit activity helps us understand your interests and preferences.")),t().createElement("div",{className:"flex space-x-3 mt-6"},t().createElement("button",{onClick:this.handleClose,disabled:this.state.isConnecting,className:"flex-1 px-4 py-2 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50 disabled:opacity-50"},"Disagree"),t().createElement("button",{onClick:this.redditConnect,disabled:this.state.isConnecting,className:"flex-1 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50"},this.state.isConnecting?"Connecting...":"Agree"))))):null}}const w=v;class N extends e.Component{constructor(e){super(e),this.state={connected:!1,open:!1,isConnecting:!1},this.handleClose=this.handleClose.bind(this),this.handleOpen=this.handleOpen.bind(this),this.gmailConnect=this.gmailConnect.bind(this),this.setConnected=this.setConnected.bind(this),this.setDisconnected=this.setDisconnected.bind(this)}setConnected(){this.setState({connected:!0}),this.props.onConnectionChange&&this.props.onConnectionChange("Gmail",!0),this.handleClose()}setDisconnected(){this.updateConnections("Remove","Gmail").then((()=>{this.setState({connected:!1}),this.props.onConnectionChange&&this.props.onConnectionChange("Gmail",!1),this.handleClose()})).catch((e=>{console.error("Error removing Gmail connection:",e)}))}async updateConnections(e,t){const n={session:{username:localStorage.getItem("username")||this.props.username},updateType:e,newConnection:t};try{const e=await fetch("https://api2.onairos.uk/connections/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});return await e.json()}catch(e){throw console.error("UpdateConnections error:",e),e}}handleOpen(){this.setState({open:!0})}handleClose(){this.setState({open:!1}),this.props.onClose&&this.props.onClose()}async gmailConnect(){this.setState({isConnecting:!0});const e={session:{username:localStorage.getItem("username")||this.props.username}};try{const t=await fetch("https://api2.onairos.uk/gmail/authorize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await t.json();n.gmailURL?window.location.href=n.gmailURL:(console.error("No Gmail URL received"),this.setState({isConnecting:!1}))}catch(e){console.error("Gmail connection error:",e),this.setState({isConnecting:!1})}}render(){const{open:e=this.props.open||this.state.open}=this.props;return e?t().createElement("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50"},t().createElement("div",{className:"bg-white rounded-lg shadow-xl max-w-md w-full mx-4 max-h-[90vh] overflow-hidden"},t().createElement("div",{className:"p-6"},t().createElement("h2",{className:"text-xl font-bold text-gray-900 mb-4"},"Grant Onairos Access to your Gmail Account?"),t().createElement("div",{className:"space-y-4 text-gray-700"},t().createElement("p",null,"Grant Permission to your Gmail Account, so we can build your Data Models."),t().createElement("div",null,t().createElement("p",{className:"font-medium mb-2"},"We will access your Gmail:"),t().createElement("ul",{className:"list-disc ml-6 space-y-1"},t().createElement("li",null,"Basic Account Information"),t().createElement("li",null,"Email Metadata (subjects, dates, senders)"),t().createElement("li",null,"Email Categories and Labels"),t().createElement("li",null,"Communication Patterns"))),t().createElement("div",{className:"bg-yellow-50 border border-yellow-200 rounded-lg p-3"},t().createElement("p",{className:"text-yellow-800 text-sm font-medium"},t().createElement("strong",null,"Note:")," We do NOT read the content of your emails. Only metadata is processed.")),t().createElement("p",null,"We will delete all the data used once your Model is Created"),t().createElement("p",{className:"text-sm"},t().createElement("a",{href:"https://onairos.uk/compliance-google-policy",className:"text-blue-600 hover:underline"},"Onairos")," ","complies with"," ",t().createElement("a",{href:"https://policies.google.com/privacy",className:"text-blue-600 hover:underline"},"Google API Services User Data Policy"))),t().createElement("div",{className:"flex space-x-3 mt-6"},t().createElement("button",{onClick:this.handleClose,disabled:this.state.isConnecting,className:"flex-1 px-4 py-2 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50 disabled:opacity-50"},"Disagree"),t().createElement("button",{onClick:this.gmailConnect,disabled:this.state.isConnecting,className:"flex-1 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50"},this.state.isConnecting?"Connecting...":"Agree"))))):null}}const S=N;function O(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,s)}return n}function k(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?O(Object(n),!0).forEach((function(t){P(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):O(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function P(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;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:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const j=[{name:"YouTube",icon:"📺",color:"bg-red-500",connector:"youtube"},{name:"Reddit",icon:"🔥",color:"bg-orange-500",connector:"reddit"},{name:"Instagram",icon:"📷",color:"bg-pink-500",connector:"instagram"},{name:"Pinterest",icon:"📌",color:"bg-red-600",connector:"pinterest"},{name:"LinkedIn",icon:"💼",color:"bg-blue-700",connector:"linkedin"},{name:"Gmail",icon:"📧",color:"bg-red-500",connector:"gmail"}];function I(n){let{onComplete:s,appIcon:o,appName:a="App",username:r}=n;const[l,i]=(0,e.useState)({}),[c,m]=(0,e.useState)(!1),[d,u]=(0,e.useState)(null),p=(e,t)=>{i((n=>k(k({},n),{},{[e]:t}))),u(null)},h=Object.values(l).filter(Boolean).length;return t().createElement("div",{className:"w-full max-w-md mx-auto bg-white rounded-lg shadow-xl overflow-hidden",style:{maxHeight:"90vh",height:"auto"}},t().createElement("div",{className:"p-4 sm:p-6 overflow-y-auto",style:{maxHeight:"calc(90vh - 4rem)"}},t().createElement("div",{className:"flex items-center justify-center mb-4 sm:mb-6"},t().createElement("div",{className:"flex items-center space-x-3"},t().createElement("img",{src:o||"https://onairos.sirv.com/Images/OnairosBlack.png",alt:a,className:"w-8 h-8 sm:w-10 sm:h-10 rounded-lg"}),t().createElement("div",{className:"flex items-center text-gray-400"},t().createElement("svg",{className:"w-5 h-5 sm:w-6 sm:h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},t().createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 8l4 4m0 0l-4 4m4-4H3"}))),t().createElement("img",{src:"https://onairos.sirv.com/Images/OnairosBlack.png",alt:"Onairos",className:"w-8 h-8 sm:w-10 sm:h-10 rounded-lg"}))),t().createElement("div",{className:"text-center mb-4 sm:mb-6"},t().createElement("h2",{className:"text-lg sm:text-xl font-bold text-gray-900 mb-2"},"Connect Your Accounts"),t().createElement("p",{className:"text-gray-600 text-xs sm:text-sm"},"Choose which accounts to connect for a personalized experience")),t().createElement("div",{className:"mb-4 sm:mb-6 p-2 sm:p-3 bg-blue-50 border border-blue-200 rounded-lg"},t().createElement("p",{className:"text-blue-800 text-xs sm:text-sm"},"🔒 Your data is never shared with anyone. It's only used to train your personal model and is stored securely.")),t().createElement("div",{className:"space-y-2 sm:space-y-3 mb-4 sm:mb-6"},j.map((e=>{const n=l[e.name]||!1;return t().createElement("div",{key:e.name,className:"flex items-center justify-between p-3 sm:p-4 border rounded-lg hover:bg-gray-50 transition-colors"},t().createElement("div",{className:"flex items-center space-x-3"},t().createElement("div",{className:"w-8 h-8 sm:w-10 sm:h-10 rounded-lg ".concat(e.color," flex items-center justify-center text-white text-base sm:text-lg")},e.icon),t().createElement("div",null,t().createElement("h3",{className:"font-medium text-gray-900 text-sm sm:text-base"},e.name),t().createElement("p",{className:"text-xs sm:text-sm text-gray-500"},n?"Connected":"Not connected"))),t().createElement("button",{onClick:()=>(async(e,t)=>{if(c)return;l[e]?i((t=>k(k({},t),{},{[e]:!1}))):u(t)})(e.name,e.connector),disabled:c,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(n?"bg-blue-600":"bg-gray-200"," ").concat(c?"opacity-50 cursor-not-allowed":"cursor-pointer")},t().createElement("span",{className:"inline-block h-3 sm:h-4 w-3 sm:w-4 transform rounded-full bg-white transition-transform ".concat(n?"translate-x-5 sm:translate-x-6":"translate-x-1")})))}))),h>0&&t().createElement("div",{className:"mb-3 sm:mb-4 p-2 sm:p-3 bg-green-50 border border-green-200 rounded-lg"},t().createElement("p",{className:"text-green-800 text-xs sm:text-sm"},"✅ ",h," account",h>1?"s":""," connected")),t().createElement("button",{onClick:()=>{const e=Object.entries(l).filter((e=>{let[t,n]=e;return n})).map((e=>{let[t]=e;return t}));s({connectedAccounts:e,totalConnections:e.length})},disabled:0===h,className:"w-full py-2 sm:py-3 px-4 rounded-lg font-semibold transition-colors text-sm sm:text-base ".concat(h>0?"bg-blue-600 text-white hover:bg-blue-700":"bg-gray-300 text-gray-500 cursor-not-allowed")},"Continue ",h>0?"with ".concat(h," account").concat(h>1?"s":""):""),t().createElement("button",{onClick:()=>s({connectedAccounts:[],totalConnections:0}),className:"w-full mt-2 py-2 text-gray-500 hover:text-gray-700 text-xs sm:text-sm"},"Skip for now")),t().createElement(g,{open:"youtube"===d,onClose:()=>u(null),onConnectionChange:p,username:r}),t().createElement(y,{open:"linkedin"===d,onClose:()=>u(null),onConnectionChange:p,username:r}),t().createElement(x,{open:"instagram"===d,onClose:()=>u(null),onConnectionChange:p,username:r}),t().createElement(E,{open:"pinterest"===d,onClose:()=>u(null),onConnectionChange:p,username:r}),t().createElement(w,{open:"reddit"===d,onClose:()=>u(null),onConnectionChange:p,username:r}),t().createElement(S,{open:"gmail"===d,onClose:()=>u(null),onConnectionChange:p,username:r}))}function T(n){let{onComplete:s,userEmail:o}=n;const[a,r]=(0,e.useState)(""),[l,i]=(0,e.useState)(""),[c,m]=(0,e.useState)({length:!1,uppercase:!1,lowercase:!1,number:!1,special:!1});(0,e.useEffect)((()=>{m({length:a.length>=6,uppercase:/[A-Z]/.test(a),lowercase:/[a-z]/.test(a),number:/[0-9]/.test(a),special:/[!@#$%^&*(),.?":{}|<>]/.test(a)})}),[a]);const d=Object.values(c).every((e=>e)),u=a===l&&a.length>0,p=d&&u;return t().createElement("div",{className:"max-w-md mx-auto bg-white p-6"},t().createElement("div",{className:"text-center mb-6"},t().createElement("div",{className:"w-16 h-16 bg-blue-100 rounded-full flex items-center justify-center mx-auto mb-4"},t().createElement("svg",{className:"w-8 h-8 text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},t().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"}))),t().createElement("h2",{className:"text-2xl font-bold text-gray-900 mb-2"},"Create Your Secure PIN"),t().createElement("p",{className:"text-gray-600"},"Your PIN will be used to securely access your data")),t().createElement("form",{onSubmit:e=>{e.preventDefault(),p&&s({pin:a,pinCreated:!0,timestamp:(new Date).toISOString()})},className:"space-y-4"},t().createElement("div",null,t().createElement("label",{htmlFor:"pin",className:"block text-sm font-medium text-gray-700 mb-2"},"Enter PIN"),t().createElement("input",{type:"password",id:"pin",value:a,onChange:e=>r(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"})),t().createElement("div",null,t().createElement("label",{htmlFor:"confirmPin",className:"block text-sm font-medium text-gray-700 mb-2"},"Confirm PIN"),t().createElement("input",{type:"password",id:"confirmPin",value:l,onChange:e=>i(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:"Confirm your PIN"}),l&&!u&&t().createElement("p",{className:"text-red-500 text-sm mt-1"},"PINs do not match"),l&&u&&t().createElement("p",{className:"text-green-500 text-sm mt-1"},"✅ PINs match")),t().createElement("div",{className:"bg-gray-50 p-4 rounded-lg"},t().createElement("h4",{className:"text-sm font-medium text-gray-700 mb-3"},"PIN Requirements:"),t().createElement("div",{className:"space-y-2"},Object.entries({length:"At least 6 characters",uppercase:"One uppercase letter (A-Z)",lowercase:"One lowercase letter (a-z)",number:"One number (0-9)",special:"One special character (!@#$%^&*)"}).map((e=>{let[n,s]=e;return t().createElement("div",{key:n,className:"flex items-center"},t().createElement("div",{className:"w-4 h-4 rounded-full mr-2 flex items-center justify-center ".concat(c[n]?"bg-green-500":"bg-gray-300")},c[n]&&t().createElement("svg",{className:"w-3 h-3 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},t().createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"}))),t().createElement("span",{className:"text-sm ".concat(c[n]?"text-green-600":"text-gray-600")},s))})))),t().createElement("button",{type:"submit",disabled:!p,className:"w-full py-3 px-4 rounded-lg font-semibold transition-colors ".concat(p?"bg-blue-600 text-white hover:bg-blue-700":"bg-gray-300 text-gray-500 cursor-not-allowed")},"Create PIN")),o&&t().createElement("p",{className:"text-center text-sm text-gray-500 mt-4"},"Securing account for: ",t().createElement("span",{className:"font-medium"},o)))}function D(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,s)}return n}function L(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?D(Object(n),!0).forEach((function(t){A(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):D(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function A(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;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:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const R=[{id:"basic",name:"Basic Information",description:"Name, email, and essential account details",icon:"👤",required:!0},{id:"memories",name:"Memories",description:"Preferences and interests",icon:"🧠",required:!1}];function U(n){let{onComplete:s,userEmail:o,appName:a="App",autoFetch:r=!0}=n;const[l,i]=(0,e.useState)({basic:!0,memories:!1}),[c,m]=(0,e.useState)(!1),[d,u]=(0,e.useState)(!1),[p,h]=(0,e.useState)(null),[g,b]=(0,e.useState)(null),y=e=>{let t=0;const n=e+Date.now().toString();for(let e=0;e<n.length;e++){t=(t<<5)-t+n.charCodeAt(e),t&=t}return"user_".concat(Math.abs(t).toString(36))},f=Object.values(l).filter(Boolean).length;return t().createElement("div",{className:"w-full max-w-md mx-auto bg-white rounded-lg shadow-xl overflow-hidden",style:{maxHeight:"90vh",height:"auto"}},t().createElement("div",{className:"p-4 sm:p-6 overflow-y-auto",style:{maxHeight:"calc(90vh - 4rem)"}},t().createElement("div",{className:"text-center mb-4 sm:mb-6"},t().createElement("div",{className:"w-12 h-12 sm:w-16 sm:h-16 bg-blue-100 rounded-full flex items-center justify-center mx-auto mb-3 sm:mb-4"},t().createElement("svg",{className:"w-6 h-6 sm:w-8 sm:h-8 text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},t().createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"}))),t().createElement("h2",{className:"text-lg sm:text-xl font-semibold text-gray-900 mb-2"},"Data Access Request"),t().createElement("p",{className:"text-gray-600 text-xs sm:text-sm"},t().createElement("span",{className:"font-medium"},a)," would like to access some of your data.")),t().createElement("div",{className:"space-y-2 sm:space-y-3 mb-4 sm:mb-6"},R.map((e=>{const n=l[e.id]||!1,s=e.required;return t().createElement("div",{key:e.id,className:"flex items-center justify-between p-3 sm:p-4 border rounded-lg transition-colors ".concat(s?"bg-blue-50 border-blue-200":"hover:bg-gray-50")},t().createElement("div",{className:"flex items-center space-x-3"},t().createElement("div",{className:"text-xl sm:text-2xl"},e.icon),t().createElement("div",null,t().createElement("h3",{className:"font-medium text-gray-900 text-sm sm:text-base"},e.name,s&&t().createElement("span",{className:"text-blue-600 ml-1"},"*")),t().createElement("p",{className:"text-xs sm:text-sm text-gray-500"},e.description))),s?t().createElement("div",{className:"px-2 py-1 bg-blue-600 text-white text-xs rounded-full"},"Required"):t().createElement("button",{onClick:()=>{var t;"basic"!==(t=e.id)&&i((e=>L(L({},e),{},{[t]:!e[t]})))},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(n?"bg-blue-600":"bg-gray-200")},t().createElement("span",{className:"inline-block h-3 sm:h-4 w-3 sm:w-4 transform rounded-full bg-white transition-transform ".concat(n?"translate-x-5 sm:translate-x-6":"translate-x-1")})))}))),t().createElement("div",{className:"mb-3 sm:mb-4 p-2 sm:p-3 bg-green-50 border border-green-200 rounded-lg"},t().createElement("p",{className:"text-green-800 text-xs sm:text-sm"},"✅ ",f," data type",f>1?"s":""," selected for sharing")),d&&t().createElement("div",{className:"mb-3 sm:mb-4 p-2 sm:p-3 bg-blue-50 border border-blue-200 rounded-lg"},t().createElement("p",{className:"text-blue-800 text-xs sm:text-sm"},"🔄 Processing your data request...")),g&&t().createElement("div",{className:"mb-3 sm:mb-4 p-2 sm:p-3 bg-red-50 border border-red-200 rounded-lg"},t().createElement("p",{className:"text-red-800 text-xs sm:text-sm"},"❌ ",g)),t().createElement("div",{className:"flex space-x-3"},t().createElement("button",{onClick:()=>{s({approved:!1,dataTypes:[],timestamp:(new Date).toISOString(),userEmail:o,userHash:y(o),appName:a})},disabled:c,className:"flex-1 py-2 sm:py-3 px-4 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50 transition-colors disabled:opacity-50 text-sm sm:text-base"},"Deny"),t().createElement("button",{onClick:async()=>{if(!c){m(!0);try{const e=Object.entries(l).filter((e=>{let[t,n]=e;return n})).map((e=>{let[t]=e;return t})),t=y(o),n={approved:!0,dataTypes:e,timestamp:(new Date).toISOString(),userEmail:o,userHash:t,appName:a};let i=n;if(r)try{const t=await(async e=>{try{u(!0),b(null);const t=y(o),n=await fetch("https://api2.onairos.uk/inferenceTest",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({approvedData:e,userEmail:o,userHash:t,appName:a,timestamp:(new Date).toISOString()})});if(!n.ok)throw new Error("API call failed with status: ".concat(n.status));const s=L(L({},await n.json()),{},{userHash:t});return h(s),s}catch(e){throw console.error("API call error:",e),b(e.message),e}finally{u(!1)}})(e);i=L(L({},n),{},{apiResponse:t,apiUrl:"https://api2.onairos.uk/inferenceTest"})}catch(e){i=L(L({},n),{},{apiError:e.message,apiUrl:"https://api2.onairos.uk/inferenceTest"})}await new Promise((e=>setTimeout(e,500))),s(i)}catch(e){console.error("Error in handleApprove:",e),b("Failed to process request")}finally{m(!1)}}},disabled:c,className:"flex-1 py-2 sm:py-3 px-4 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors disabled:opacity-50 text-sm sm:text-base"},c?"Processing...":"Approve"))))}function M(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,s)}return n}function W(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?M(Object(n),!0).forEach((function(t){G(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):M(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function G(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;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:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function z(n){let{requestData:s,webpageName:o,inferenceData:a=null,onComplete:r=null,autoFetch:l=!0,proofMode:i=!1,textLayout:c="below",textColor:m="white",login:d=!1,buttonType:u="pill",loginReturn:h=null,loginType:g="signIn",visualType:b="full",appIcon:y=null}=n;const[f,x]=(0,e.useState)(!1),[C,E]=(0,e.useState)("email"),[v,w]=(0,e.useState)(null),[N,S]=(0,e.useState)(null);(0,e.useEffect)((()=>{(()=>{const e=localStorage.getItem("onairosUser");if(e)try{const t=JSON.parse(e);w(t),t.onboardingComplete&&t.pinCreated?E("dataRequest"):t.verified&&!t.onboardingComplete?E("onboarding"):t.onboardingComplete&&!t.pinCreated&&E("pin")}catch(e){console.error("Error parsing saved user data:",e),localStorage.removeItem("onairosUser")}})()}),[]);const O=()=>{x(!1),S(null)},k=e=>{console.log("Email auth successful:",e);const t=W(W({},e),{},{verified:!0,onboardingComplete:!1,pinCreated:!1});w(t),localStorage.setItem("onairosUser",JSON.stringify(t)),E("onboarding")},P=e=>{console.log("Onboarding completed:",e);const t=W(W({},v),{},{onboardingComplete:!0,connectedAccounts:e.connectedAccounts||[]});w(t),localStorage.setItem("onairosUser",JSON.stringify(t)),E("pin")},j=e=>{console.log("PIN setup completed:",e);const t=W(W(W({},v),e),{},{pinCreated:!0});w(t),localStorage.setItem("onairosUser",JSON.stringify(t)),E("dataRequest")},D=e=>{console.log("🔥 OnairosButton: Data request completed:",e);const t=W(W({},v),{},{lastDataRequest:e});if(w(t),localStorage.setItem("onairosUser",JSON.stringify(t)),x(!1),console.log("🔥 Calling onComplete callback with:",e),r)try{r(e),console.log("🔥 onComplete callback executed successfully")}catch(e){console.error("🔥 Error in onComplete callback:",e)}else console.log("🔥 No onComplete callback provided")},L="flex items-center justify-center font-bold rounded cursor-pointer ".concat("pill"===u?"px-4 py-2":"w-12 h-12"," bg-transparent OnairosConnect"),A={flexDirection:"below"===c?"column":"row",backgroundColor:"transparent",color:m,border:"1px solid transparent"},R={width:"20px",height:"20px",marginRight:"full"===b?"12px":"0"};return t().createElement(t().Fragment,null,t().createElement("button",{className:L,onClick:async()=>{try{console.log("🔥 openTerminal called"),x(!0)}catch(e){console.error("Error in openTerminal:",e)}},style:A},("full"===b||"icon"===b)&&t().createElement("img",{src:d?"https://onairos.sirv.com/Images/OnairosWhite.png":"https://onairos.sirv.com/Images/OnairosBlack.png",alt:"Onairos Logo",style:R}),"icon"!==b&&t().createElement("span",{className:"".concat("black"===m?"tex