1import{j as e,r as l}from"./vendor-react-4XT1lARu.js";import{_ as Ms,a7 as Le,at as V,au as z,aB as Ie,av as G,aG as B,aw as $,n as ge,e as f,bq as _s,br as Ws,bs as Vs,bt as $s,bu as zs,cA as Gs,af as fe,cj as Ks,ey as ws,aC as S,aO as ze,as as le,c8 as At,u as Dt,a5 as Et,aZ as It,bw as Lt,a_ as Ft,ez as Ot,aJ as ct,co as Rt,ar as Mt,a6 as qt,cL as Ut,f as Bs,bd as Hs,aa as _t,ab as us,ac as ps,ad as hs,ae as xs,ag as gs,w as Ns,B as Wt,ay as Qs,an as Ys,cz as Vt,eA as Js,aA as Ds,eB as $t,eC as Zs,eD as zt,a$ as fs,ah as js,ai as ys,aj as vs,ak as bs,al as as,F as Ss,v as Xs,S as Gt,bo as Cs,b7 as Es,b8 as Kt,ba as Bt,bb as Ht,am as Os,bm as Rs,ca as lt,N as dt,aW as Is,cp as Qt,cq as Yt,cr as Jt,cs as et,ct as Zt,ao as Xt,ej as Ge,cZ as Ke,ea as Be,ap as cs,aq as st,cX as tt,O as ea,cV as sa,bx as ta,eE as aa,P as na,bh as ia,bi as ra,bj as oa,bk as ca,az as la,eF as da,eG as ma,eH as ua,eI as pa,eJ as ha,eK as xa,cQ as ga}from"./index-BVK4sMpl.js";import{g as fa}from"./voice-accent-labels-z7lpiBAi.js";import{S as ee}from"./switch-KIf71EN3.js";import{P as mt,a as ut,b as pt}from"./popover-Do544U9E.js";import{T as ja,a as ya,b as ss,c as ts}from"./tabs-CAN9dd7h.js";import{u as Fe,f as ht,i as we,b as je,d as ie,e as R,q as oe,p as xt,y as va,w as ba,g as ns,R as wa,z as Na,k as Ls,X as Ca}from"./i18n-D2s5SYoo.js";import{C as at,a as nt,b as it}from"./collapsible-BI8UCu39.js";import{A as Sa,a as ka,b as Ta,c as Pa,d as Aa,e as Da,f as Ea,g as Ia,h as La}from"./alert-dialog-CkA66PPA.js";import{Q as rt}from"./qr-code-DntWswEE.js";import{U as Fa}from"./user-Tyncs4EV.js";import{U as Oa}from"./upload-DKNmofxg.js";import{S as Ra}from"./scale-DOWMCxxf.js";import{E as ls}from"./eye-off-ts5o47YC.js";import{E as ds}from"./eye-CR6l8q_5.js";import{T as ot}from"./trash-2-BJuB1KE5.js";import{S as Ma,a as qa,R as Ua}from"./sunset-CbaCyD3I.js";import{C as _a}from"./calendar-days-DbZdHarG.js";import{P as Wa}from"./plus-BPUL2Yay.js";import"./vendor-radix-Dw269-bE.js";/** 2 * @license lucide-react v0.453.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const Va=Ms("Chrome",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["line",{x1:"21.17",x2:"12",y1:"8",y2:"8",key:"a0cw5f"}],["line",{x1:"3.95",x2:"8.54",y1:"6.06",y2:"14",key:"1kftof"}],["line",{x1:"10.88",x2:"15.46",y1:"21.94",y2:"14",key:"1ymyh8"}]]);/** 7 * @license lucide-react v0.453.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const ms=Ms("Key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]);/** 12 * @license lucide-react v0.453.0 - ISC 13 * 14 * This source code is licensed under the ISC license. 15 * See the LICENSE file in the root directory of this source tree. 16 */const $a=Ms("SlidersVertical",[["line",{x1:"4",x2:"4",y1:"21",y2:"14",key:"1p332r"}],["line",{x1:"4",x2:"4",y1:"10",y2:"3",key:"gb41h5"}],["line",{x1:"12",x2:"12",y1:"21",y2:"12",key:"hf2csr"}],["line",{x1:"12",x2:"12",y1:"8",y2:"3",key:"1kfi7u"}],["line",{x1:"20",x2:"20",y1:"21",y2:"16",key:"1lhrwl"}],["line",{x1:"20",x2:"20",y1:"12",y2:"3",key:"16vvfq"}],["line",{x1:"2",x2:"6",y1:"14",y2:"14",key:"1uebub"}],["line",{x1:"10",x2:"14",y1:"8",y2:"8",key:"1yglbp"}],["line",{x1:"18",x2:"22",y1:"16",y2:"16",key:"1jxqpz"}]]);function za({compact:i=!1}){const n=i?"space-y-4":"space-y-8",t=i?"text-lg font-semibold mb-2":"text-2xl font-semibold mb-4",r=i?"text-base font-semibold mb-2 mt-4":"text-xl font-semibold mb-3 mt-6";return e.jsxs("div",{className:`prose prose-slate dark:prose-invert max-w-none ${n}`,children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Last updated: April 19, 2026"}),e.jsxs("section",{children:[e.jsx("h2",{className:t,children:"1. Introduction"}),e.jsx("p",{className:"text-sm",children:'Welcome to WireLingo ("we," "our," or "us"). We are committed to protecting your personal information and your right to privacy in accordance with the UK General Data Protection Regulation (UK GDPR) and the Privacy and Electronic Communications Regulations (PECR). This Privacy Policy explains how we
16collect, use, disclose, and safeguard your information when you use our language learning platform, including our website and iOS and Android mobile applications.'}),e.jsxs("p",{className:"mt-2 text-sm",children:[e.jsx("strong",{children:"Data Controller:"})," WireLingo is the data controller responsible for your personal data. If you have any questions about this Privacy Policy or our data practices, please contact us at ",e.jsx("a",{href:"mailto:[email protected]",className:"text-primary hover:underline",children:"[email protected]"}),"."]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:t,children:"2. Information We Collect"}),e.jsx("h3",{className:r,children:"2.1 Information You Provide"}),e.jsxs("ul",{className:"list-disc pl-6 space-y-1 text-sm",children:[e.jsxs("li",{children:[e.jsx("strong",{children:"Account Information:"})," Username, email address, and password (stored in encrypted form)"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Profile Data:"})," First name, last name, profile picture, language preferences, and proficiency level"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Learning Preferences:"})," Selected languages, difficulty levels, topic preferences, display settings (font size, Pinyin/Furigana toggles, accent preferences), and subscription settings"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Search and Dictionary History:"})," Words and phrases you look up in the in-app dictionary, and searches you perform within the platform, stored and linked to your account to personalise your learning experience"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Customer Support Content:"})," Messages, descriptions, and any other content you submit when contacting us via support tickets or feedback forms"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"AI Interaction Data:"})," When you use our AI-powered features, your voice audio and text are transmitted to OpenAI, Google Gemini, or ElevenLabs for processing. For Sage Voice sessions, we store a conversation transcript and a session summary on our servers to support your learning history. We do not store raw voice recordings"]})]}),e.jsx("h3",{className:r,children:"2.2 Information Automatically Collected"}),e.jsxs("ul",{className:"list-disc pl-6 space-y-1 text-sm",children:[e.jsxs("li",{children:[e.jsx("strong",{children:"Usage Data:"})," Articles viewed, reading time, completion status, vocabulary saved, quiz attempts and responses, audio playbacks, dictionary lookups, and other in-app interactions"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Session Data:"})," Session start and end times, device type, browser type, operating system, screen dimensions, and platform (web or mobile)"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Device Information:"})," IP address, browser or app version, operating system, and a device identifier we generate to protect against trial abuse and maintain platform security"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Device Fingerprint for Security:"})," On mobile devices, we record a device identifier and an installation identifier to detect multi-account abuse (for example, creating multiple free-trial accounts from the same device). These identifiers are used solely for platform integrity purposes and are not shared with third parties for advertising. If our system detects that the same device has been used to create multiple accounts in a manner that violates our Terms of Service, an account may be restricted and an administrator notified"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Location Data:"})," Approximate location (country and city) derived from your IP address at the time of account creation, used to set your default timezone and content preferences"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Push Notification Data:"})," If you enable push notifications, we store your device's notification endpoint or Expo push token, platform, and device name"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Marketing Attribution:"})," If you arrive via a marketing link, we may record the source, medium, campaign, landing page, and referrer to understand which channels bring users to WireLingo"]})]}),e.jsx("h3",{className:r,children:"2.3 Purchase and Subscription Information"}),e.jsxs("ul",{className:"list-disc pl-6 space-y-1 text-sm",children:[e.jsxs("li",{children:[e.jsx("strong",{children:"Stripe (web subscriptions):"}
16)," Payment is processed securely by Stripe. We store your Stripe customer ID and subscription ID but do not store full card details"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Apple In-App Purchases (iOS):"})," Subscriptions purchased through the iOS app are processed entirely by Apple. We store your Apple original transaction ID, subscription tier, plan, and expiry date to manage your access. We do not have access to your payment card details"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Purchase History:"})," Your subscription tier, plan duration, and subscription status are stored and linked to your account"]})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:t,children:"3. Legal Basis for Processing"}),e.jsx("p",{className:"mb-2 text-sm",children:"Under UK GDPR, we process your personal data based on the following lawful bases:"}),e.jsxs("ul",{className:"list-disc pl-6 space-y-1 text-sm",children:[e.jsxs("li",{children:[e.jsx("strong",{children:"Contract Performance:"})," To provide our language learning services, manage your subscription, and maintain your account"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Legitimate Interests:"})," To improve our platform, analyse usage patterns, prevent abuse, and ensure security"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Consent:"})," For marketing communications, non-essential cookies, and analytics tracking"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Legal Obligation:"})," To comply with applicable laws and regulations"]})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:t,children:"4. How We Use Your Information"}),e.jsxs("ul",{className:"list-disc pl-6 space-y-1 text-sm",children:[e.jsx("li",{children:"Provide, maintain, and improve our language learning platform"}),e.jsx("li",{children:"Personalise your learning experience based on your preferences, progress, and search history"}),e.jsx("li",{children:"Manage your subscription and process payments via Stripe or Apple"}),e.jsx("li",{children:"Send you transactional emails (account confirmation, subscription receipts, renewal reminders) and, where you have consented, marketing or onboarding emails"}),e.jsx("li",{children:"Send push notifications for new content or reminders (only if you have enabled them)"}),e.jsx("li",{children:"Respond to your enquiries and provide customer support"}),e.jsx("li",{children:"Analyse usage patterns to improve our content and features"}),e.jsx("li",{children:"Detect and prevent fraudulent activity, trial abuse, and security threats"}),e.jsx("li",{children:"Measure the effectiveness of our marketing campaigns"})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:t,children:"5. AI-Powered Features and Data Processing"}),e.jsx("p",{className:"mb-2 text-sm",children:"WireLingo uses artificial intelligence to enhance your language learning experience."}
16),e.jsx("h3",{className:r,children:"5.1 Talk with Sage (Voice Conversations)"}),e.jsxs("ul",{className:"list-disc pl-6 space-y-1 text-sm",children:[e.jsxs("li",{children:[e.jsx("strong",{children:"Data Transmitted:"})," Your voice audio is streamed in real-time to OpenAI's, Google Gemini's, or ElevenLabs' servers for speech recognition, AI response generation, and voice synthesis"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Data Stored by WireLingo:"})," After each session, we store a conversation transcript and a session summary on our servers. These are linked to your account and used to support your learning history. We do not store raw voice recordings"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Retention:"})," Session transcripts and summaries are retained for the duration of your account. You may request deletion by contacting us"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Processing Location:"})," Voice data is processed in the United States by OpenAI, Google, and ElevenLabs"]})]}),e.jsx("h3",{className:r,children:"5.2 Sage Assist (Text Translation and Chat)"}),e.jsxs("ul",{className:"list-disc pl-6 space-y-1 text-sm",children:[e.jsxs("li",{children:[e.jsx("strong",{children:"Data Transmitted:"})," The selected sentence, article context, your proficiency level, and your question are sent to OpenAI or Google Gemini for processing"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Data Stored by WireLingo:"})," We store a usage counter (number of Sage Assist interactions) linked to your account to enforce subscription limits. We do not store the sentence text, your questions, or AI responses"]})]}),e.jsx("h3",{className:r,children:"5.3 Text-to-Speech"}),e.jsx("ul",{className:"list-disc pl-6 space-y-1 text-sm",children:e.jsxs("li",{children:[e.jsx("strong",{children:"Provider:"})," Audio narration is generated by ElevenLabs or OpenAI TTS. Your text input (article content) is sent to these services for audio generation. We do not record your voice"]})}),e.jsx("h3",{className:r,children:"5.4 Third-Party AI Provider Policies"}),e.jsxs("ul",{className:"list-disc pl-6 space-y-1 text-sm",children:[e.jsxs("li",{children:[e.jsx("strong",{children:"OpenAI Zero Data Retention:"})," We use OpenAI's API with zero data retention enabled. Your data is NOT used to train AI models."]}),e.jsxs("li",{children:[e.jsx("strong",{children:"ElevenLabs:"})," ElevenLabs processes voice audio solely to generate synthesised speech responses. Audio is not retained after processing and is not used to train AI models."]}),e.jsxs("li",{children:[e.jsx("strong",{children:"UK GDPR Equivalence:"})," OpenAI and ElevenLabs are both subject to contractual data protection obligations and maintain data protection standards equivalent to UK GDPR requirements, including Standard Contractual Clauses (SCCs) or equivalent safeguards for international data transfers."]})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:t,children:"6. Information Sharing and Third-Party Services"}),e.jsx("p",{className:"mb-2 text-sm",children:"We do not sell your personal information. We share data only with the following categories of third parties as necessary to operate our platform:"}),e.jsx("h3",{className:r,children:"6.1 Service Providers"}),e.jsxs("ul",{className:"list-disc pl-6 space-y-1 text-sm",children:[e.jsxs("li",{children:[e.jsx("strong",{children:"Stripe:"})," Payment processing for web subscriptions"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Apple:"})," In-app purchase processing for iOS subscriptions"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"SendGrid:"})," Transactional and marketing email delivery"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"OpenAI / Google Gemini:"})," AI conversation and translation features"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"ElevenLabs:"})," Text-to-speech audio generation"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Google Analytics (GA4):"})," Anonymised usage analytics to understand platform performance"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Expo:"})," Mobile push notification delivery for iOS and Android"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Cloudflare:"})," Bot protection, CAPTCHA verification, and CDN services; may process your IP address"]})]}),e.jsx("h3",{className:r,children:"6.2 Other Disclosures"}),e.jsxs("ul",{className:"list-disc pl-6 space-y-1 text-sm",children:[e.jsxs("li",{children:[e.jsx("strong",{children:"Legal Requirements:"})," When required by law, court order, or government regulation"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Business Transfers:"})," In connection with a merger, acquisition, or sale of assets"]})]}),e.jsx("p",{className:"mt-2 text-sm",children:"All third-party service providers are contractually obligated to handle your data securely and only for the purposes we specify."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:t,children:"7. Data Security"}),e.jsx("p",{className:"text-sm",children:"We implement industry-standard security measures including encrypted password storage (bcrypt), secure HTTPS connections, session-based authentication, tw
16o-factor authentication (TOTP), account lockout after repeated failed login attempts, and regular security reviews."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:t,children:"8. Your Privacy Rights"}),e.jsx("p",{className:"mb-2 text-sm",children:"Under UK GDPR, you have the following rights:"}),e.jsxs("ul",{className:"list-disc pl-6 space-y-1 text-sm",children:[e.jsxs("li",{children:[e.jsx("strong",{children:"Right of Access:"})," Request a copy of your personal information"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Right to Rectification:"})," Update or correct inaccurate information"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Right to Erasure:"})," Request deletion of your personal information"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Right to Restrict Processing:"})," Limit how we use your data"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Right to Object:"})," Object to processing for direct marketing"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Right to Data Portability:"})," Request your data in a machine-readable format"]})]}),e.jsxs("p",{className:"mt-2 text-sm",children:["To exercise these rights, contact us at ",e.jsx("a",{href:"mailto:[email protected]",className:"text-primary hover:underline",children:"[email protected]"}),". We will respond within 30 days."]}),e.jsxs("p",{className:"mt-2 text-sm",children:["If you are an iOS user and purchased a subscription through the App Store, you can manage or cancel your subscription directly through your Ap
16ple ID settings. Apple's handling of your payment data is governed by ",e.jsx("a",{href:"https://www.apple.com/legal/privacy/",className:"text-primary hover:underline",target:"_blank",rel:"noopener noreferrer",children:"Apple's Privacy Policy"}),"."]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:t,children:"9. Data Retention"}),e.jsxs("ul",{className:"list-disc pl-6 space-y-1 text-sm",children:[e.jsxs("li",{children:[e.jsx("strong",{children:"Account Data:"})," Retained while your account is active and for up to 2 years after deletion, after which it is permanently removed"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Learning Progress and Search History:"})," Retained while your account is active"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Support Tickets:"})," Retained for up to 3 years for customer service and legal purposes"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Analytics Data:"})," 14 months (Google Analytics GA4), 26 months (first-party session analytics)"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Marketing Attribution:"})," Retained for up to 26 months"]})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:t,children:"10. Cookies and Tracking"}),e.jsxs("p",{className:"text-sm",children:["We use cookies and similar technologies to maintain your session, remember your preferences, and analyse platform usage. For full details, please see our ",e.jsx("a",{href:"/cookies",className:"text-primary hover:underline",children:"Cookie Policy"}),"."]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:t,children:"11. Minimum Age and Children's Privacy"}),e.jsxs("p",{className:"text-sm mb-2",children:["WireLingo is intended for users aged ",e.jsx("strong",{children:"16 and over"}),". Our platform includes AI-powered features â such as real-time conversation practice and AI-assisted translation â and is not directed at children or teenagers under the age of 16."]}),e.jsx("p",{className:"text-sm mb-2",children:"We do not knowingly collect personal information from anyone under 16. By creating an account, users confirm they meet this minimum age requirement, as set out in our Terms of Service. We do not implement automated age verification; this requirement is enforced through the contractual agreement made at account creation and, for iOS users, through the App Store age rating."}),e.jsxs("p",{className:"text-sm",children:["If we become aware that we have inadvertently collected data from a user under 16, we will suspend the account and delete all associated personal data promptly. To report this, contact us at ",e.jsx("a",{href:"mailto:[email protected]",className:"text-primary hover:underline",children:"[email protected]"}),"."]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:t,children:"12. Changes to This Policy"}),e.jsx("p",{className:"text-sm",children:"We may update this Privacy Policy from time to time. We will notify you of material changes by email or via an in-app notice. Your continued use of WireLingo after the effective date of any changes constitutes your acceptance of the updated policy."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:t,children:"13. Contact Us"}),e.jsxs("div",{className:"bg-muted p-4 rounded-lg",children:[e.jsxs("p",{className:"flex items-center gap-2 font-semibold text-sm",children:[e.jsx(Le,{className:"w-4 h-4"}),"Email: ",e.jsx("a",{href:"mailto:[email protected]",className:"text-primary hover:underline",children:"[email protected]"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"WireLingo Language Learning Platform"})]})]})]})}function Ga({compact:i=!1}){const n=i?"space-y-4":"space-y-8",t=i?"text-lg font-semibold mb-2":"text-2xl font-semibold mb-4",r=i?"text-base font-semibold mb-2 mt-4":"text-xl font-semibold mb-3 mt-6";return e.jsxs("div",{className:`prose prose-slate dark:prose-invert max-w-none ${n}`,children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Last updated: January 26, 2026"}),e.jsxs("section",{children:[e.jsx("h2",{className:t,children:"1. Agreement to Terms"}),e.jsx("p",{className:"text-sm",children:'By accessing or using WireLingo ("Platform," "Service," "we," "us," or "our"), you agree to be bound by these Terms of Service. If you do not agree to these terms, please do not use our platform.'})]}),e.jsxs("section",{children:[e.jsx("h2",{className:t,children:"2. Age Requirements"}),e.jsxs("p",{className:"text-sm",children:["You must be at least ",e.jsx("strong",{children:"16 years old"})," to create an account and use WireLingo. By creating an account, you confirm that you meet this age requirement."]}),e.jsx("p",{className:"mt-2 text-sm",children:"If you are under 18 years old, you should review these Terms with a parent or guardian to ensure they understand and agree to them on your behalf."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:t,children:"3. Description of Service"}),e.jsx("p",{className:"text-sm",children:"WireLingo is a language learning platform that provides access to news articles in multiple languages (Mandarin Chinese, Spanish, German, French, Japanese, and English) with varying difficulty levels. Our service includes:"}),e.jsxs("ul",{className:"list-disc pl-6 space-y-1 text-sm mt-2",children:[e.jsx("li",{children:"Curated news articles across 17+ topics and 5 difficulty levels"}),e.jsx("li",{children:"AI-powered article grading and vocabulary extraction"}),e.jsx("li",{children:"Progress tracking and learning analytics"}),e.jsx("li",{children:"Audio playback for improved pronunciation practice"}),e.jsx("li",{children:"Grammar explanations and vocabulary lists"})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:t,children:"4. User Accounts"}),e.jsx("h3",{className:r,children:"4.1 Account Creation"}),e.jsx("p",{className:"text-sm",children:"To access certain features, you may
16need to create an account. You agree to:"}),e.jsxs("ul",{className:"list-disc pl-6 space-y-1 text-sm mt-2",children:[e.jsx("li",{children:"Provide accurate, current, and complete information"}),e.jsx("li",{children:"Maintain the security of your password"}),e.jsx("li",{children:"Notify us immediately of any unauthorised account access"}),e.jsx("li",{children:"Be responsible for all activities under your account"})]}),e.jsx("h3",{className:r,children:"4.2 Account Termination"}),e.jsx("p",{className:"text-sm",children:"We reserve the right to suspend or terminate your account if you violate these Terms or engage in activities that harm our platform or other users."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:t,children:"5. Acceptable Use"}),e.jsx("p",{className:"mb-2 text-sm",children:"You agree NOT to:"}),e.jsxs("ul",{className:"list-disc pl-6 space-y-1 text-sm",children:[e.jsx("li",{children:"Violate any applicable laws or regulations"}),e.jsx("li",{children:"Infringe on intellectual property rights"}),e.jsx("li",{children:"Upload malicious code, viruses, or harmful software"}),e.jsx("li",{children:"Attempt to gain unauthorised access to our systems"}),e.jsx("li",{children:"Scrape, harvest, or collect user data without permission"}),e.jsx("li",{children:"Use automated tools (bots, scrapers) to access our content"}),e.jsx("li",{children:"Impersonate another user or entity"})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:t,children:"6. Content and Intellectual Property"}),e.jsx("h3",{className:r,children:"6.1 Our Content"}),e.jsx("p",{className:"text-sm",children:"All content on WireLingo, including articles, images, audio files, grammar explanations, and vocabulary lists, is protected by copyright and other intellectual property laws."}),e.jsx("h3",{className:r,children:"6.2 Your Use of Content"}),e.jsx("p",{className:"text-sm",children:"You may access and use our content for personal, non-commercial language learning purposes only. You may not reproduce, distribute, or republish our content without permission."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:t,children:"7. Disclaimers"}),e.jsx("p",{className:"text-sm",children:'We provide our platform "as is" and "as available" without warranties of any kind. We do not guarantee uninterrupted, error-free, or secure access to our service. Our platform is designed for language learning and educational purposes. We make no guarantees about language proficiency outcomes.'})]}),e.jsxs("section",{children:[e.jsx("h2",{className:t,children:"8. Limitation of Liability"}),e.jsx("p",{className:"text-sm",children:"To the maximum extent permitted by law, WireLingo and its affiliates shall not be liable for any indirect, incidental, special, consequential, or punitive damages arising from your use of our platform."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:t,children:"9. Modifications to Terms"}),e.jsx("p",{className:"text-sm",children:"We may update these Terms of Service from time to time. Material changes will be communicated via email or prominent notice on our platform. Your continued use after changes constitutes acceptance of the updated terms."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:t,children:"10. Termination"}),e.jsx("p",{className:"text-sm",children:"We reserve the right to suspend or terminate your access to our platform at any time, for any reason, including violation of these Terms. Upon termination, your right to use our service will immediately cease."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:t,children:"11. Governing Law"}),e.jsx("p",{className:"text-sm",children:"These Terms shall be governed by and construed in accordance with applicable laws, without regard to conflict of law principles."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:t,children:"12. Contact Information"}),e.jsxs("div",{className:"bg-muted p-4 rounded-lg",children:[e.jsxs("p",{className:"flex items-center gap-2 font-semibold text-sm",children:[e.jsx(Le,{className:"w-4 h-4"}),"Email: ",e.jsx("a",{href:"mailto:[email protected]",className:"text-primary hover:underline",children:"[email protected]"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"WireLingo Language Learning Platform"})]})]})]})}function Ka(){const[i,n]=l.useState(!1);return l.useEffect(()=>{const t=()=>{const r=navigator.userAgent||navigator.vendor||window.opera,u=/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i,s="ontouchstart"in window||navigator.maxTouchPoints>0,g=window.innerWidth<768;n(u.test(r.toLowerCase())||s&&g)};return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]),i}function Ba(){const{toast:i}
16=Fe(),{user:n}=ht(),{account:t,common:r}=we(),u=(n==null?void 0:n.role)==="admin"||(n==null?void 0:n.role)==="super-admin",s=Ka(),[g,j]=l.useState(!1),[v,p]=l.useState(!1),[h,I]=l.useState(""),[k,Z]=l.useState(""),[O,_]=l.useState(""),[x,D]=l.useState([]),[H,L]=l.useState(""),[P,W]=l.useState(""),[se,N]=l.useState(null),[X,re]=l.useState(!1),[A,te]=l.useState("choose"),{data:C}=je({queryKey:["/api/2fa/status"]}),de=ie({mutationFn:async()=>await(await R("POST","/api/2fa/setup")).json(),onSuccess:m=>{sessionStorage.setItem("2fa-setup-state",JSON.stringify({step:"choose",qrCode:m.qrCode,secret:m.secret,otpauthUrl:m.otpauthUrl||"",backupCodes:m.backupCodes})),I(m.qrCode),Z(m.secret),_(m.otpauthUrl||""),D(m.backupCodes),te("choose"),j(!0)},onError:m=>{le(i,u,{adminTitle:"Failed to setup 2FA",adminDescription:m.message,userTitle:t.twoFactorSetupFailedTitle,userDescription:r.pleaseTryAgainMoment})}}),M=ie({mutationFn:async m=>await(await R("POST","/api/2fa/enable",{code:m})).json(),onSuccess:m=>{sessionStorage.removeItem("2fa-setup-state"),oe.invalidateQueries({queryKey:["/api/2fa/status"]}),i({title:r.success,description:t.twoFactorEnabledToast}),L(""),te("success"),m.backupCodes&&D(m.backupCodes)},onError:m=>{le(i,u,{adminTitle:"Failed to enable 2FA",adminDescription:m.message,userTitle:t.twoFactorInvalidCodeTitle,userDescription:t.twoFactorCheckCodeDesc})}}),ae=ie({mutationFn:async m=>await(await R("POST","/api/2fa/disable",{code:m})).json(),onSuccess:()=>{oe.invalidateQueries({queryKey:["/api/2fa/status"]}),i({title:r.success,description:t.twoFactorDisabledToast}),p(!1),W("")},onError:m=>{le(i,u,{adminTitle:"Failed to disable 2FA",adminDescription:m.message,userTitle:t.twoFactorDisableFailedTitle,userDescription:t.twoFactorCheckCodeDesc})}}),qe=m=>{m.preventDefault(),H.length===6&&M.mutate(H)},Oe=m=>{m.preventDefault(),P&&ae.mutate(P)},me=(m,w)=>{navigator.clipboard.writeText(m),w!==void 0&&(N(w),setTimeout(()=>N(null),2e3))},Ne=()=>{navigator.clipboard.writeText(k),re(!0),setTimeout(()=>re(!1),2e3)},ue=m=>{h&&k&&sessionStorage.setItem("2fa-setup-state",JSON.stringify({step:m,qrCode:h,secret:k,otpauthUrl:O,backupCodes:x}))},Y=m=>{te(m),ue(m)},ye=()=>{O&&(Y("verify"),window.location.href=O)};l.useEffect(()=>{const m=sessionStorage.getItem("2fa-setup-state");if(m)try{const w=JSON.parse(m);if(w.qrCode&&w.secret){I(w.qrCode),Z(w.secret),w.otpauthUrl&&_(w.otpauthUrl),w.backupCodes&&D(w.backupCodes);const be=["choose","qr","manual","verify"].includes(w.step)?w.step:"choose";te(be),j(!0)}}catch{sessionStorage.removeItem("2fa-setup-state")}},[]),l.useEffect(()=>{C!=null&&C.enabled&&(sessionStorage.removeItem("2fa-setup-state"),g&&A!=="success"&&te("success"))},[C==null?void 0:C.enabled,g,A]);const T=()=>{j(!1),L(""),I(""),Z(""),_(""),D([]),te("choose"),re(!1),sessionStorage.removeItem("2fa-setup-state")},Re=()=>e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground text-center",children:t.twoFactorChooseMethodIntro}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs(f,{variant:"outline",className:"w-full h-auto py-4 flex flex-col gap-2",onClick:ye,disabled:!O,"data-testid":"button-open-authenticator",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ks,{className:"h-5 w-5"}),e.jsx("span",{className:"font-semibold",children:t.twoFactorOpenInAuthApp})]}),e.jsx("span",{className:"text-xs opacity-80",children:t.twoFactorOpenInAuthAppDesc})]}),e.jsxs(f,{variant:"default",className:"w-full h-auto py-4 flex flex-col gap-2",onClick:()=>Y("qr"),"data-testid":"button-scan-qr",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(rt,{className:"h-5 w-5"}),e.jsx("span",{className:"font-semibold",children:t.twoFactorScanQrCode})]}),e.jsx("span",{className:"text-xs opacity-80",children:t.twoFactorScanQrCodeDesc})]}),e.jsxs(f,{variant:"outline",className:"w-full h-auto py-4 flex flex-col gap-2",onClick:()=>Y("manual"),"data-testid":"button-manual-entry",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ms,{className:"h-5 w-5"}),e.jsx("span",{className:"font-semibold",children:t.twoFactorEnterKeyManually})]}),e.jsx("span",{className:"text-xs opacity-80",children:t.twoFactorEnterKeyManuallyDesc})]})]}),s&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4 text-sm text-muted-foreground",children:[e.jsxs("p",{className:"font-medium mb-2 flex items-center gap-2",children:[e.jsx(ws,{className:"h-4 w-4"}),t.twoFactorOnMobile]}),e.jsx("p",{className:"text-xs",children:t.twoFactorOnMobileTip})]})]}),ce=()=>e.jsxs("div",{className:"space-y-4",children:[h&&e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx("div",{className:"bg-white p-3 rounded-lg",children:e.jsx("img",{src:h,alt:t.twoFactorQrAlt,className:"w-48 h-48","data-testid":"img-qr-code"})}),e.jsx("p",{className:"text-sm text-muted-foreground text-center",children:t.twoFactorScanThisCode})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(S,{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(ms,{className:"h-4 w-4"}),t.twoFactorCantScan]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(fe,{value:k,readOnly:!0,className:"font-mono text-xs","data-testid":"input-secret-key"}),e.jsx(f,{type:"button",variant:"outline",onClick:Ne,className:"shrink-0","data-testid":"button-copy-secret",children:X?e.jsx(ge,{className:"h-4 w-4 text-emerald-600"}):e.jsx(ze,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"flex gap-2 pt-4 border-t",children:[e.jsx(f,{variant:"ghost",onClick:()=>Y("choose"),"data-testid":"button-back-to-methods",children:r.back}),e.jsx(f,{className:"flex-1",onClick:()=>Y("verify"),"data-testid":"button-continue-verify",children:t.twoFactorAddedContinue})]})]}),Ae=()=>e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-center mb-4",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-full bg-primary/10 mb-3",children:e.jsx(ms,{className:"h-6 w-6 text-primary"})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t.twoFactorCopySecretIntro})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{children:t.twoFactorSecretKey}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(fe,{value:k,readOnly:!0,className:"font-mono text-sm","data-testid":"input-secret-key-manual"}),e.jsx(f,{type:"button",variant:"outline",onClick:Ne,className:"shrink-0","data-testid":"button-copy-secret-manual",children:X?e.jsx(ge,{className:"h-4 w-4 text-emerald-600"}):e.jsx(ze,{className:"h-4 w-4"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t.twoFactorManualEntryHint})]}),e.jsxs(f,{variant:"outline",className:"w-full",onClick:ye,disabled:!O,"data-testid":"button-open-authenticator-alt",children:[e.jsx(Ks,{className:"h-4 w-4 mr-2"}),t.twoFactorOrOpenInAuthApp]}),e.jsxs("div",{className:"flex gap-2 pt-4 border-t",children:[e.jsx(f,{variant:"ghost",onClick:()=>Y("choose"),"data-testid":"button-back-to-methods-manual",children:r.back}),e.jsx(f,{className:"flex-1",onClick:()=>Y("verify"),"data-testid":"button-continue-verify-manual",children:t.twoFactorAddedContinue})]})]}),Ce=()=>e.jsxs("form",{onSubmit:qe,className:"space-y-4",children:[e.jsxs("div",{className:"text-center mb-4",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-full bg-primary/10 mb-3",children:e.jsx(Ie,{className:"h-6 w-6 text-primary"})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t.twoFactorEnterCodeIntro})]}),e.jsxs("div",{children:[e.jsx(S,{htmlFor:"verification-code",children:t.twoFactorVerificationCode}),e.jsx(fe,{id:"verification-code",type:"text",inputMode:"numeric",pattern:"[0-9]*",maxLength:6,value:H,onChange:m=>L(m.target.value.replace(/\D/g,"")),onPaste:m=>{m.preventDefault();const w=m.clipboardData.getData("text").replace(/\D/g,"").slice(0,6);L(w)},placeholder:"000000",className:"text-center text-2xl tracking-[0.5em] font-mono mt-2",autoComplete:"one-time-code",autoCapitalize:"off",autoCorrect:"off","data-testid":"input-2fa-verification-code"})]}),e.jsx(f,{type:"submit",className:"w-full",disabled:H.length!==6||M.isPending,"data-testid":"button-verify-2fa-code",children:M.isPending?t.twoFactorVerifying:t.twoFactorVerifyAndEnable}),e.jsx(f,{type:"button",variant:"ghost",className:"w-full",onClick:()=>Y("choose"),"data-testid":"button-back-to-setup",children:t.twoFactorBackToSetupOptions})]}),He=()=>e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-center mb-4",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-emerald-100 dark:bg-emerald-950/30 mb-3",children:e.jsx(ge,{className:"h-8 w-8 text-emerald-600"})}),e.jsx("h3",{className:"text-lg font-semibold text-emerald-900 dark:text-emerald-100",children:t.twoFactorEnabledSuccess}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:t.twoFactorAccountProtected})]}),x.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-yellow-50 dark:bg-yellow-950/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-4",children:[e.jsx("p",{className:"text-sm font-medium text-yellow-900 dark:text-yellow-100",children:t.twoFactorImportantSaveBackupCodes}),e.jsx("p",{className:"text-xs text-yellow-700 dark:text-yellow-300 mt-1",children:t.twoFactorBackupCodesOnce})]}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:x.map((m,w)=>e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("code",{className:"flex-1 px-3 py-2 bg-muted rounded text-sm font-mono",children:m}),e.jsx(f,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>me(m,w),"data-testid":`button-copy-backup-success-${w}`,children:se===w?e.jsx(ge,{className:"h-3 w-3 text-emerald-600"}):e.jsx(ze,{className:"h-3 w-3"})})]},w))}),e.jsxs(f,{variant:"outline",className:"w-full",onClick:()=>me(x.join(` 17`)),"data-testid":"button-copy-all-backup-success",children:[e.jsx(ze,{className:"h-4 w-4 mr-2"}),t.twoFactorCopyAllCodes]})]})]}),ve=()=>e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-yellow-50 dark:bg-yellow-950/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-4",children:[e.jsx("p",{className:"text-sm font-medium text-yellow-900 dark:text-yellow-100",children:t.twoFactorSaveTheseBackupCodes}),e.jsx("p",{className:"text-xs text-yellow-700 dark:text-yellow-300 mt-1",children:t.twoFactorBackupCodesOnce})]}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:x.map((m,w)=>e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("code",{className:"flex-1 px-3 py-2 bg-muted rounded text-sm font-mono",children:m}),e.jsx(f,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>me(m,w),"data-testid":`button-copy-backup-${w}`,children:se===w?e.jsx(ge,{className:"h-3 w-3 text-emerald-600"}):e.jsx(ze,{className:"h-3 w-3"})})]},w))}),e.jsxs(f,{variant:"outline",className:"w-full",onClick:()=>me(x.join(` 18`)),"data-testid":"button-copy-all-backup",children:[e.jsx(ze,{className:"h-4 w-4 mr-2"}),t.twoFactorCopyAllCodes]})]}),pe=()=>{if(A==="success")return e.jsxs(e.Fragment,{children:[e.jsx(ge,{className:"h-5 w-5 text-emerald-600"}),t.twoFactorEnabledSuccess]});if(C!=null&&C.enabled)return e.jsxs(e.Fragment,{children:[e.jsx(ge,{className:"h-5 w-5 text-emerald-600"}),t.twoFactorEnabledSaveBackupCodes]});switch(A){case"choose":return e.jsxs(e.Fragment,{children:[e.jsx(Ie,{className:"h-5 w-5 text-primary"}),t.twoFactorSetupTitle]});case"qr":return e.jsxs(e.Fragment,{children:[e.jsx(rt,{className:"h-5 w-5 text-primary"}),t.twoFactorScanQrCode]});case"manual":return e.jsxs(e.Fragment,{children:[e.jsx(ms,{className:"h-5 w-5 text-primary"}),t.twoFactorEnterKeyManually]});case"verify":return e.jsxs(e.Fragment,{children:[e.jsx(Ie,{className:"h-5 w-5 text-primary"}),t.twoFactorVerifySetup]});default:return e.jsxs(e.Fragment,{children:[e.jsx(Ie,{className:"h-5 w-5 text-primary"}),t.twoFactorSetupShort]})}},De=()=>{if(A==="success")return t.twoFactorSaveBackupCodesSafe;if(C!=null&&C.enabled)return t.twoFactorStoreCodesSafely;switch(A){case"choose":return t.twoFactorChooseSetupMethod;case"qr":return t.twoFactorScanQrDesc;case"manual":return t.twoFactorCopySecretDesc;case"verify":return t.twoFactorEnterCodeDesc;default:return""}};return e.jsxs(e.Fragment,{children:[e.jsxs(V,{children:[e.jsx(z,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ie,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{children:[e.jsx(G,{children:t.twoFactorAuth}),e.jsx(B,{children:t.twoFactorCardDesc})]})]})}),e.jsx($,{className:"space-y-4",children:C!=null&&C.enabled?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg bg-emerald-50 dark:bg-emerald-950/20 border-emerald-200 dark:border-emerald-800",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-emerald-900 dark:text-emerald-100",children:t.twoFactorIsEnabled}),e.jsx("p",{className:"text-sm text-emerald-700 dark:text-emerald-300",children:t.twoFactorAccountProtected}),(C==null?void 0:C.backupCodesRemaining)!==void 0&&e.jsx("p",{className:"text-sm text-emerald-600 dark:text-emerald-400 mt-1",children:t.backupCodesRemaining(C.backupCodesRemaining)})]}),e.jsx(ge,{className:"h-6 w-6 text-emerald-600"})]}),e.jsx(f,{variant:"destructive",onClick:()=>p(!0),"data-testid":"button-disable-2fa",children:t.disable2fa})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:t.twoFactorExplanation}),e.jsx(f,{onClick:()=>de.mutate(),disabled:de.isPending,"data-testid":"button-enable-2fa",children:de.isPending?t.twoFactorSettingUp:t.enable2fa})]})})]}),e.jsx(_s,{open:g,onOpenChange:m=>!m&&T(),children:e.jsxs(Ws,{className:"max-w-md max-h-[90vh] overflow-y-auto",children:[e.jsxs(Vs,{children:[e.jsx($s,{className:"flex items-center gap-2",children:pe()}),e.jsx(zs,{children:De()})]}),A==="success"?He():C!=null&&C.enabled?x.length>0?ve():null:e.jsxs(e.Fragment,{children:[A==="choose"&&Re(),A==="qr"&&ce(),A==="manual"&&Ae(),A==="verify"&&Ce()]}),e.jsx(Gs,{children:e.jsx(f,{variant:A==="success"||C!=null&&C.enabled?"default":"outline",onClick:T,"data-testid":"button-close-2fa-dialog",children:A==="success"||C!=null&&C.enabled?r.done:r.cancel})})]})}),e.jsx(_s,{open:v,onOpenChange:p,children:e.jsxs(Ws,{className:"max-w-sm",children:[e.jsxs(Vs,{children:[e.jsx($s,{children:t.disable2fa}),e.jsx(zs,{children:t.twoFactorDisableDesc})]}),e.jsxs("form",{onSubmit:Oe,className:"space-y-4",children:[e.jsx(fe,{type:"text",inputMode:"numeric",pattern:"[0-9]*",maxLength:6,value:P,onChange:m=>W(m.target.value.replace(/\D/g,"")),placeholder:"000000",className:"text-center text-2xl tracking-[0.5em] font-mono",autoComplete:"one-time-code","data-testid":"input-disable-2fa-code"}),e.jsxs(Gs,{children:[e.jsx(f,{type:"button",variant:"outline",onClick:()=>p(!1),"data-testid":"button-cancel-disable-2fa",children:r.cancel}),e.jsx(f,{type:"submit",variant:"destructive",disabled:P.length<6||ae.isPending,"data-testid":"button-confirm-disable-2fa",children:ae.isPending?t.twoFactorDisabling:t.disable2fa})]})]})]})})]})}function Ha(){const i=new Date;let n;try{n=Intl.supportedValuesOf("timeZone")}catch{n=["Pacific/Auckland","Australia/Sydney","Australia/Perth","Asia/Tokyo","Asia/Shanghai","Asia/Hong_Kong","Asia/Singapore","Asia/Bangkok","Asia/Kolkata","Asia/Dubai","Europe/Moscow","Europe/Istanbul","Europe/Athens","Europe/Helsinki","Europe/Berlin","Europe/Paris","Europe/Amsterdam","Europe/London","Atlantic/Reykjavik","America/Sao_Paulo","America/Ne
18w_York","America/Chicago","America/Denver","America/Los_Angeles","America/Anchorage","Pacific/Honolulu","UTC"]}return n.map(t=>{var h;let r=0;try{const I=new Intl.DateTimeFormat("en-US",{timeZone:t,hour:"numeric",minute:"numeric",hour12:!1,year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(i),k=D=>{var H;return Number(((H=I.find(L=>L.type===D))==null?void 0:H.value)??0)},Z=Date.UTC(k("year"),k("month")-1,k("day"),k("hour"),k("minute")),O=new Intl.DateTimeFormat("en-US",{timeZone:"UTC",hour:"numeric",minute:"numeric",hour12:!1,year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(i),_=D=>{var H;return Number(((H=O.find(L=>L.type===D))==null?void 0:H.value)??0)},x=Date.UTC(_("year"),_("month")-1,_("day"),_("hour"),_("minute"));r=(Z-x)/6e4}catch{}const u=r>=0?"+":"-",s=Math.abs(r),g=String(Math.floor(s/60)).padStart(2,"0"),j=String(s%60).padStart(2,"0"),v=`UTC${u}${g}:${j}`,p=((h=t.split("/").pop())==null?void 0:h.replace(/_/g," "))??t;return{value:t,label:`(${v}) ${p} â ${t}`,offsetMinutes:r}}).sort((t,r)=>t.offsetMinutes-r.offsetMinutes)}let Fs=null;function Qa(){return Fs||(Fs=Ha()),Fs}async function Ya(i,n=1024,t=800){return new Promise((r,u)=>{const s=new Image;s.onload=()=>{let{width:g,height:j}=s;(g>t||j>t)&&(g>j?(j=Math.round(j*t/g),g=t):(g=Math.round(g*t/j),j=t));const v=document.createElement("canvas");v.width=g,v.height=j;const p=v.getContext("2d");if(!p){u(new Error("Could not get canvas context"));return}p.drawImage(s,0,0,g,j);const h=I=>{v.toBlob(k=>{if(!k){u(new Error("Failed to compress image"));return}if(k.size>n*1024&&I>.1)h(I-.1);else{const Z=new File([k],i.name,{type:"image/jpeg",lastModified:Date.now()});r(Z)}},"image/jpeg",I)};h(.9)},s.onerror=()=>u(new Error("Failed to load image")),s.src=URL.createObjectURL(i)})}const Ja=i=>Xt({firstName:Ge(n=>{if(typeof n=="string"){const t=n.trim();return t===""?null:t}return n},Ke([Be(),cs().max(100,i.account.firstNameTooLong)]).optional()),lastName:Ge(n=>{if(typeof n=="string"){const t=n.trim();return t===""?null:t}return n},Ke([Be(),cs().max(100,i.account.lastNameTooLong)]).optional()),email:Ge(n=>{if(typeof n=="string"){const t=n.trim();return t===""?null:t}return n},Ke([Be(),cs().email(i.featureRequest.emailInvalid)]).optional()),subscriptionEnabled:st().optional(),marketingOptIn:st().optional(),timezone:Ge(n=>{if(typeof n=="string"){const t=n.trim();return t===""?null:t}return n},Ke([Be(),cs().max(50)]).optional()),subscriptionLanguage:Ge(n=>{if(typeof n=="string"){const t=n.trim();return t===""?null:t}return n},Ke([Be(),tt(["mandarin","spanish","german","french","japanese","english"])]).optional()),subscriptionLevel:Ge(n=>{if(typeof n=="string"){const t=n.trim();return t===""?null:t}return n},Ke([Be(),tt(["beginner","lower-intermediate","intermediate","upper-intermediate","advanced"])]).optional())});function Za({user:i}){const{account:n,common:t}=we(),{toast:r}=Fe(),u=(i==null?void 0:i.role)==="admin"||(i==null?void 0:i.role)==="super-admin",s=ns(),g=(i==null?void 0:i.marketingOptIn)&&!(i!=null&&i.unsubscribedFromMarketing),j=ie({mutationFn:async v=>await R("POST","/api/user/marketing-subscription",{subscribed:v}),onSuccess:(v,p)=>{s.invalidateQueries({queryKey:["/api/user"]}),r({title:p?t.subscribed:t.unsubscribed,description:p?n.marketingEmailsDescription:n.unsubscribedMarketingDescription})},onError:v=>{le(r,u,{adminTitle:"Failed to update marketing preference",adminDescription:v.message,userTitle:"Couldn't save preference",userDescription:"Please try again in a moment."})}});return e.jsxs(V,{children:[e.jsxs(z,{children:[e.jsxs(G,{className:"flex items-center gap-2",children:[e.jsx(Le,{className:"h-5 w-5"}),n.emailPreferences]}),e.jsx(B,{children:n.manageEmailPreferences})]}),e.jsxs($,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between space-x-2",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(S,{htmlFor:"marketing-emails",className:"cursor-pointer",children:n.marketingEmails}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n.marketingEmailsDescription})]}),e.jsx(ee,{id:"marketing-emails",checked:g,onCheckedChange:v=>j.mutate(v),disabled:j.isPending,"data-testid":"switch-marketing-emails"})]}),(i==null?void 0:i.unsubscribedFromMarketing)&&e.jsx("p",{className:"text-sm text-amber-600 dar
18k:text-amber-400",children:n.resubscribeDescription})]})]})}function Xa(i){const n="=".repeat((4-i.length%4)%4),t=(i+n).replace(/-/g,"+").replace(/_/g,"/"),r=window.atob(t),u=new Uint8Array(r.length);for(let s=0;s<r.length;++s)u[s]=r.charCodeAt(s);return u}function en(){var Xe;const{account:i,common:n,marketing:t}=we(),r=[{key:"morning",label:i.morning,sub:i.morningTime,Icon:Ma},{key:"afternoon",label:i.afternoon,sub:i.afternoonTime,Icon:lt},{key:"evening",label:i.evening,sub:i.eveningTime,Icon:qa},{key:"night",label:i.night,sub:i.nightTime,Icon:ea}],u=new Set(r.map(o=>o.key)),s=[{key:"daily",label:i.everyDay,Icon:_a},{key:"few_times_weekly",label:i.fewTimesWeek,Icon:Ua},{key:"weekends",label:i.weekendsOnly,Icon:dt}],{toast:g}=Fe(),{user:j}=ht(),v=(j==null?void 0:j.role)==="admin"||(j==null?void 0:j.role)==="super-admin",p=ns(),{isNativeApp:h,isIOSNativeApp:I,isAndroidNativeApp:k}=ct(),O=typeof window<"u"&&(window.navigator.standalone===!0||window.matchMedia("(display-mode: standalone)").matches)&&!h,[_,x]=l.useState(null),[D,H]=l.useState(!1),[L,P]=l.useState(!1);l.useEffect(()=>{if(!O){H(!0);return}async function o(){if("serviceWorker"in navigator&&"PushManager"in window)try{const q=await(await navigator.serviceWorker.ready).pushManager.getSubscription();x((q==null?void 0:q.endpoint)||"")}catch{x("")}else x("");H(!0)}o()},[O]);const{data:W,refetch:se}=je({queryKey:["/api/push/status","user",_],queryFn:async()=>{const o=_?`/api/push/status?scope=user&endpoint=${encodeURIComponent(_)}`:"/api/push/status?scope=user&endpoint=",y=await fetch(o,{credentials:"include"});if(!y.ok)throw new Error("Failed to fetch push status");return y.json()},enabled:D&&O}),N=(W==null?void 0:W.subscribed)&&((Xe=W==null?void 0:W.notificationTypes)==null?void 0:Xe.includes("study_reminder")),X=async()=>{var o;if(!("serviceWorker"in navigator)||!("PushManager"in window)){g({title:n.notSupported,description:t.notifNotSupportedBrowser,variant:"destructive"});return}P(!0);try{if(await Notification.requestPermission()!=="granted"){g({title:n.permissionDenied,description:n.enableNotificationsInSettings,variant:"destructive"});return}const q=await fetch("/api/push/vapid-public-key");if(!q.ok)throw new Error("Push notifications not configured on server");const{vapidPublicKey:Q}=await q.json(),U=await navigator.serviceWorker.ready,We=await U.pushManager.getSubscription();let xe=We;if(!xe)try{xe=await U.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:Xa(Q)})}catch(Ee){const $e=navigator.userAgent;throw(/iPad|iPhone|iPod/.test($e)||/Macintosh/.test($e)&&navigator.maxTouchPoints>1)&&Ee.name==="NotAllowedError"?new Error("Push notifications may not be available on this iOS version. Try updating to iOS 16.4 or later."):Ee.name==="NotAllowedError"||(o=Ee.message)!=null&&o.includes("permission")?new Error("Push notifications are blocked. Please enable them in your device settings."):new Error(Ee.message||"Failed to subscribe to push notifications")}const Ve=xe.endpoint,Te=Ls();We?await fetch("/api/push/add-notification-type",{method:"POST",headers:{"Content-Type":"application/json",...Te?{"x-csrf-token":Te}:{}},credentials:"include",body:JSON.stringify({endpoint:Ve,type:"study_reminder"})}):await fetch("/api/push/subscribe",{method:"POST",headers:{"Content-Type":"application/json",...Te?{"x-csrf-token":Te}:{}},credentials:"include",body:JSON.stringify({subscription:xe.toJSON(),notificationTypes:["study_reminder"],scope:"user"})}),x(Ve),await se(),g({title:n.pushEnabled,description:i.studyReminderPushActive})}catch(y){le(g,v,{adminTitle:"Failed to enable push",adminDescription:y.message,userTitle:n.error,userDescription:n.tryAgain})}finally{P(!1)}},re=async()=>{P(!0);try{const y=await(await navigator.serviceWorker.ready).pushManager.getSubscription();if(!y){await se();return}const q=Ls();await fetch("/api/push/remove-notification-type",{method:"DELETE",headers:{"Content-Type":"application/json",...q?{"x-csrf-token":q}:{}},credentials:"include",body:JSON.stringify({endpoint:y.endpoint,type:"study_reminder"})}),await se(),g({title:n.pushDisabled,description:i.studyReminderDisabled})}catch(o){le(g,v,{adminTitle:"Failed to disable push",adminDescription:o.message,userTitle:n.error,userDescription:n.tryAgain})}finally{P(!1)}},{data:A,isLoading:te}=je({queryKey:["/api/auth/study-reminder/preferences"]}),[C,de]=l.useState("morning"),[M,ae]=l.useState(null),[qe,Oe]=l.useState("daily"),[me,Ne]=l.useState(!1),[ue,Y]=l.useState(!1),ye=C?!u.has(C):!1,[T,Re]=l.useState("08:00"),ce=M?!u.has(M):!1,[Ae,Ce]=l.useState("18:00"),[He,ve]=l.useState(h?null:!1),[pe,De]=l.useState(h?null:"granted"),[m,w]=l.useState(null),[Se,be]=l.useState(!h),[ks,Ue]=l.useState(!1),Me=I?"ios":k?"android":null;l.useEffect(()=>{if(!h)return;const o=window.ReactNativeWebView;if(!(o!=null&&o.postMessage)){ve(!1),be(!0);return}const y=Q=>{let U;
18try{U=typeof Q.data=="string"?JSON.parse(Q.data):Q.data}catch{return}(U==null?void 0:U.action)==="push-token-status"?(ve(U.permissionStatus==="granted"&&!!U.token),De(U.permissionStatus||null),w(U.token||null),be(!0)):(U==null?void 0:U.action)==="push-enabled"&&(ve(!0),De("granted"),U.token&&(w(U.token),be(!0)))};window.addEventListener("message",y),o.postMessage(JSON.stringify({action:"get-push-token"}));const q=setTimeout(()=>{ve(Q=>Q===null?!1:Q),be(!0)},3e3);return()=>{clearTimeout(q),window.removeEventListener("message",y)}},[h]),l.useEffect(()=>{if(!A)return;const o=A.studyReminderTime??"morning",y=A.studyReminderTime2??null;Ne(A.studyReminderEnabled??!1),de(o),ae(y),Oe(A.studyReminderFrequency??"daily"),Y(A.studyReminderEmailEnabled??!1),o&&!u.has(o)&&Re(o),y&&!u.has(y)&&Ce(y)},[A]);const he=ie({mutationFn:async o=>R("PATCH","/api/auth/study-reminder/preferences",o),onSuccess:()=>{p.invalidateQueries({queryKey:["/api/auth/study-reminder/preferences"]})},onError:()=>g({title:n.failedToSave,variant:"warning"})}),is=pe==="granted"&&m?encodeURIComponent(m):"none",{data:E,refetch:_e}=je({queryKey:["/api/mobile/push-status",Me,m,pe,"study_reminder"],queryFn:async()=>{let o="/api/mobile/push-status?type=study_reminder";Me&&(o+=`&platform=${Me}¤tToken=${is}`,pe&&(o+=`&osPermission=${encodeURIComponent(pe)}`));const y=await fetch(o,{credentials:"include"});if(!y.ok)throw new Error("Failed to fetch SR mobile push status");return y.json()},enabled:h&&Se});l.useEffect(()=>{if(!h||!Se||!(m!=null&&m.startsWith("ExponentPushToken["))||!E||E.hasTokens)return;const o=/Android/.test(navigator.userAgent)?"android":"ios",y=Ls();console.log("[SR MobilePush] Onboarding race condition detected â auto-registering token"),fetch("/api/mobile/register-push-token",{method:"POST",headers:{"Content-Type":"application/json",...y?{"x-csrf-token":y}:{}},credentials:"include",body:JSON.stringify({pushToken:m,platform:o})}).then(()=>{p.invalidateQueries({queryKey:["/api/mobile/push-status"]})}).catch(console.error)},[h,Se,m,E==null?void 0:E.hasTokens]);const Qe=l.useRef(!1);l.useEffect(()=>{!Qe.current||!m||pe!=="granted"||(Qe.current=!1,(async()=>{try{await R("PATCH","/api/mobile/toggle-notification-type",{currentToken:m,type:"study_reminder",enabled:!0}),await _e(),g({title:i.studyReminderPushActive})}catch{g({title:n.failedToEnablePush,variant:"destructive"})}})())},[m,pe]);const Ye=async()=>{Ue(!0);try{if(pe==="granted"&&m)await R("PATCH","/api/mobile/toggle-notification-type",{currentToken:m,type:"study_reminder",enabled:!0}),await _e(),g({title:i.studyReminderPushActive});else{const o=window.ReactNativeWebView;o!=null&&o.postMessage&&(Qe.current=!0,o.postMessage(JSON.stringify({action:"enable-push"}))),g({title:n.enablePush,description:n.allowNotificationsDescription})}}catch{g({title:n.failedToEnablePush,variant:"destructive"})}finally{Ue(!1)}},Ts=async()=>{if(m){Ue(!0);try{await R("PATCH","/api/mobile/toggle-notification-type",{currentToken:m,type:"study_reminder",enabled:!1}),await _e(),g({title:i.studyReminderDisabled})}catch{g({title:n.failedToDisablePush,variant:"destructive"})}finally{Ue(!1)}}},Ps=o=>{Ne(o);const y=!h&&!O&&o,q=y?{studyReminderEmailEnabled:!0}:{};y&&Y(!0),he.mutate({studyReminderEnabled:o,...q})},Je=o=>{de(o),he.mutate({studyReminderTime:o})},c=o=>{ae(o),o===null&&!u.has(Ae)&&Ce("18:00"),he.mutate({studyReminderTime2:o})},ke=o=>{Oe(o),he.mutate({studyReminderFrequency:o})},Ze=o=>{Y(o),he.mutate({studyReminderEmailEnabled:o})};if(te)return null;const rs=h?E!=null&&E.enabled?ue?`${n.pushNotification} + ${n.email}`:n.pushNotification:ue?n.email:n.notYetConfigured:O?N?ue?`${n.pushNotification} + ${n.email}`:n.pushNotification:ue?n.email:n.notYetConfigured:n.email;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-base font-semibold leading-none",children:i.studyReminders}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:me?i.studyRemindersActiveDescription(rs):i.studyRemindersOnboardingDescription})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(ee,{checked:me,onCheckedChange:Ps,disabled:he.isPending,"data-testid":"toggle-study-reminders"})})]}),me&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{className:"text-sm font-medium",children:i.remindMeAt}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[r.map(({key:o,label:y,sub:q,Icon:Q})=>{const U=C===o;return e.jsxs("button",{"data-testid":`button-settings-time-${o}`,onClick:()=>Je(o),className:`rounded-lg p-3 flex flex-col items-start gap-1 text-left border transition-all ${U?"bg-primary/10 border-primary text-primary":"bg-muted/40 border-border text-muted-foreground hover-elevate"}`,children:[e.jsx(Q,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm font-medium",children:y}),e.jsx("span",{className:"text-xs opacity-70",children:q})]},o)}),e.jsxs("button",{"data-testid":"button-settings-time-exact",onClick:()=>{ye||Je(T||"08:00")},className:`col-span-2 rounded-lg p-3 flex items-center justify-between gap-2 border transition-all ${ye?"bg-primary/10 border-primary text-primary":"bg-muted/40 border-border text-muted-foreground hover-elevate"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ns,{className:"w-4 h-4"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium block",children:n.specificTime}),ye&&e.jsx("span",{className:"text-xs opacity-70",children:n.exactTimeNote})]})]}),ye?e.jsx("input",{type:"time",step:"300",value:T,"data-testid":"input-sett
18ings-time-exact",onClick:o=>o.stopPropagation(),onChange:o=>Re(o.target.value),onBlur:o=>{o.target.value&&Je(o.target.value)},className:"bg-transparent border-none text-sm font-medium text-primary focus:outline-none cursor-pointer"}):e.jsx("span",{className:"text-xs opacity-70",children:n.chooseTime})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs(S,{className:"text-sm font-medium",children:[i.addSecondReminder," ",e.jsxs("span",{className:"text-muted-foreground font-normal",children:["(",n.optional,")"]})]}),M?e.jsx("button",{onClick:()=>c(null),className:"text-xs text-muted-foreground hover:text-foreground transition-colors","data-testid":"button-remove-second-reminder",children:n.remove}):null]}),M?e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[r.map(({key:o,label:y,sub:q,Icon:Q})=>{const U=M===o;return e.jsxs("button",{"data-testid":`button-settings-time2-${o}`,onClick:()=>c(o),className:`rounded-lg p-3 flex flex-col items-start gap-1 text-left border transition-all ${U?"bg-primary/10 border-primary text-primary":"bg-muted/40 border-border text-muted-foreground hover-elevate"}`,children:[e.jsx(Q,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm font-medium",children:y}),e.jsx("span",{className:"text-xs opacity-70",children:q})]},o)}),e.jsxs("button",{"data-testid":"button-settings-time2-exact",onClick:()=>{ce||c(Ae||"18:00")},className:`col-span-2 rounded-lg p-3 flex items-center justify-between gap-2 border transition-all ${ce?"bg-primary/10 border-primary text-primary":"bg-muted/40 border-border text-muted-foreground hover-elevate"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ns,{className:"w-4 h-4"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium block",children:n.specificTime}),ce&&e.jsx("span",{className:"text-xs opacity-70",children:n.exactTimeNote})]})]}),ce?e.jsx("input",{type:"time",step:"300",value:Ae,"data-testid":"input-sett
18ings-time2-exact",onClick:o=>o.stopPropagation(),onChange:o=>Ce(o.target.value),onBlur:o=>{o.target.value&&c(o.target.value)},className:"bg-transparent border-none text-sm font-medium text-primary focus:outline-none cursor-pointer"}):e.jsx("span",{className:"text-xs opacity-70",children:n.chooseTime})]})]}):e.jsxs("button",{"data-testid":"button-add-second-reminder",onClick:()=>c("evening"),className:"w-full rounded-lg p-3 flex items-center gap-2 border border-dashed border-border text-muted-foreground hover-elevate text-sm transition-all",children:[e.jsx(Wa,{className:"w-4 h-4"}),e.jsx("span",{children:i.addSecondReminder})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{className:"text-sm font-medium",children:i.frequency}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:s.map(({key:o,label:y,Icon:q})=>{const Q=qe===o;return e.jsxs("button",{"data-testid":`button-settings-freq-${o}`,onClick:()=>ke(o),className:`flex items-center gap-1.5 rounded-full px-3 py-1.5 text-sm border transition-all ${Q?"bg-primary/10 border-primary text-primary":"bg-muted/40 border-border text-muted-foreground hover-elevate"}`,children:[e.jsx(q,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:y})]},o)})})]}),e.jsxs("div",{className:"space-y-3 pt-1 border-t border-border",children:[e.jsx(S,{className:"text-sm font-medium",children:n.delivery}),h?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ws,{className:"w-4 h-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:i.pushNotification}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Se?E!=null&&E.thisPlatformEnabled?E.deviceCount&&E.deviceCount>1?i.activeOnNDevices(E.deviceCount):i.activeOnThisDevice:E!=null&&E.enabled&&!(E!=null&&E.thisPlatformEnabled)?(E.deviceCount||1)>1?i.activeOnNOtherDevices(E.deviceCount||1):i.activeOnOtherDevice:He===!1?n.tapToEnableInSettings(I?"iOS":"Android"):n.tapToEnable:`${n.checking}â¦`})]})]}),e.jsx(ee,{checked:!!(E!=null&&E.thisPlatformEnabled),disabled:!Se||ks,onCheckedChange:o=>{o?Ye():Ts()},"data-testid":"toggle-reminder-push"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Le,{className:"w-4 h-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:i.alsoSendEmail}),e.jsx("p",{className:"text-xs text-muted-foreground",children:i.optionalBackupReminder})]})]}),e.jsx(ee,{checked:ue,onCheckedChange:Ze,disabled:he.isPending,"data-testid":"toggle-reminder-email"})]})]}):O?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(sa,{className:"w-4 h-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:i.pushNotification}),e.jsx("p",{className:"text-xs text-muted-foreground",children:D?N?i.activeOnThisDevice:n.tapToEnable:`${n.checking}â¦`})]})]}),e.jsx(ee,{checked:!!N,disabled:L||!D,onCheckedChange:o=>{o?X():re()},"data-testid":"toggle-reminder-pwa-push"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Le,{className:"w-4 h-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:i.alsoSendEmail}),e.jsx("p",{className:"text-xs text-muted-foreground",children:i.optionalBackupReminder})]})]}),e.jsx(ee,{checked:ue,onCheckedChange:Ze,disabled:he.isPending,"data-testid":"toggle-reminder-email"})]})]}):e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Le,{className:"w-4 h-4 shrink-0"}),e.jsx("span",{children:i.emailOnlyReminder})]})]})]})]})}function An(){return e.jsx(V,{children:e.jsx($,{className:"pt-6",children:e.jsx(en,{})})})}function sn({selectedLanguage:i}){const{toast:n}=Fe(),t=ns(),{account:r,common:u,header:s}=we(),g=wa();s.langMandarin,s.langSpanish,s.langGerman,s.langFrench,s.langJapanese,s.langEnglish;const j={Male:r.voiceGenderMale,Female:r.voiceGenderFemale},[v,p]=l.useState(null),h=l.useRef(null),I=async N=>{if(v===N){h.current&&(h.current.pause(),h.current=null),p(null);return}h.current&&(h.current.pause(),h.current=null);try{p(N);const X=await R("POST","/api/elevenlabs-live/voice-preview",{voiceId:N,language:i});if(!X.ok)throw new Error("Preview failed");const re=await X.blob(),A=URL.createObjectURL(re),te=new Audio(A);h.current=te,te.onended=()=>{p(null),URL.revokeObjectURL(A)},te.onerror=()=>{p(null),n({title:u.previewFailed,description:u.couldNotPlayPreview,variant:"warning"})},await te.play()}catch{p(null),n({title:u.previewFailed,description:u.couldNotGeneratePreview,variant:"warning"})}},{data:k}=je({queryKey:["/api/auth/me"]}),Z=(k==null?void 0:k.role)==="admin"||(k==null?void 0:k.role)==="super-admin",{data:O}=je({queryKey:["/api/settings/discuss-with-sage"],staleTime:30*1e3}),{data:_}=je({queryKey:["/api/admin/sage-provider"],enabled:Z}),D=(Z?_==null?void 0:_.effectiveProvider:O==null?void 0:O.provider)==="elevenlabs",{data:H={}}=je({queryKey:["/api/elevenlabs-live/user-voice-preferences"],enabled:D}),{data:L=[],isLoading:P}=je({queryKey:["/api/elevenlabs-live/voices",i],queryFn:async()=>i?(await R("GET",`/api/elevenlabs-live/voices/${i}`)).json():[],enabled:!!i&&D}),W=ie({mutationFn:async({language:N,voiceId:X})=>(await R("PUT","/api/elevenlabs-live/user-voice-preferences",{language:N,voiceId:X})).json(),onSuccess:()=>{t.invalidateQueries({queryKey:["/api/elevenlabs-live/user-voice-preferences"]}),n({title:u.settingsSaved,description:u.voiceUpdated})},onError:N=>{le(n,Z,{adminTitle:"Unable to save voice preference",adminDescription:N.message,userTitle:u.error,userDescription:u.tryAgain})}}),se=i?H[i]:null;return L.find(N=>N.voiceId===se),D?e.jsxs(V,{children:[e.jsx(z,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ta,{state:"idle",size:"sm"}),e.jsxs("div",{children:[e.jsx(G,{children:r.sageSettingsTitle}),e.jsx(B,{children:r.sageSettingsDescription})]})]})}),e.jsx($,{className:"space-y-4",children:i?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ss,{language:i,className:"w-4 h-4"}),e.jsx(S,{className:"text-sm font-medium text-muted-foreground",children:{mandarin:r.voicesLabelMandarin,spanish:r.voicesLabelSpanish,german:r.voicesLabelGerman,french:r.voicesLabelFrench,japanese:r.voicesLabelJapanese,english:r.voicesLabelEnglish}[i]??r.voicesLabelEnglish})]}),P?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(fs,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{className:"text-sm",children:r.loadingVoices})]}):L.length===0?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Cs,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:r.noVoicesAvailable})]}):e.jsx("div",{className:"divide-y divide-border rounded-xl border overflow-hidden",children:L.map(N=>{const X=se===N.voiceId,re=v===N.voiceId;return e.jsxs("div",{className:`flex items-center justify-between px-3 py-2.5 transition-colors cursor-pointer ${X?"bg-primary/5":"hover-elevate"}`,onClick:()=>{i&&!W.isPending&&W.mutate({language:i,voiceId:N.voiceId})},"data-testid":`voice-option-${N.voiceId}`,children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx("div",{className:`w-4 h-4 rounded-full border-2 flex items-center justify-center flex-shrink-0 ${X?"border-primary bg-primary":"border-muted-foreground
18/30"}`,children:X&&e.jsx(ge,{className:"h-2.5 w-2.5 text-primary-foreground"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:N.displayName}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[fa(r,N.accent,N.accentTranslations,g)," ⢠",j[N.gender]??N.gender]})]})]}),e.jsx(f,{variant:"ghost",size:"icon",className:"h-8 w-8 flex-shrink-0",onClick:A=>{A.stopPropagation(),I(N.voiceId)},"data-testid":`button-preview-voice-${N.voiceId}`,children:re?e.jsx(aa,{className:"h-3.5 w-3.5 fill-current"}):e.jsx(na,{className:"h-3.5 w-3.5"})})]},N.voiceId)})})]}):e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Cs,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:r.selectLanguageForVoice})]})})]}):null}function tn({user:i}){const{toast:n}=Fe(),t=ns(),{account:r,common:u}=we(),[s,g]=l.useState((i==null?void 0:i.showStreakCelebration)??!0),[j,v]=l.useState((i==null?void 0:i.showStreakProgress)??!0);l.useEffect(()=>{i&&(g(i.showStreakCelebration??!0),v(i.showStreakProgress??!0))},[i==null?void 0:i.showStreakCelebration,i==null?void 0:i.showStreakProgress]);const p=async(h,I)=>{try{await R("PATCH","/api/user/profile",{[h]:I}),t.invalidateQueries({queryKey:["/api/auth/me"]}),t.invalidateQueries({queryKey:["/api/user/daily-reading-progress"]})}catch{n({title:u.failedToUpdateSetting,variant:"warning"})}};return e.jsxs(V,{children:[e.jsxs(z,{children:[e.jsxs(G,{className:"flex items-center gap-2",children:[e.jsx(Ns,{className:"h-5 w-5"}),r.streakVisibilityTitle]}),e.jsx(B,{children:r.streakVisibilityDescription})]}),e.jsx($,{children:e.jsxs("div",{className:"rounded-xl border overflow-hidden divide-y",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 px-4 py-3.5",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(S,{htmlFor:"show-celebration",className:"cursor-pointer text-sm font-medium",children:r.streakCelebration}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r.streakCelebrationDescription})]}),e.jsx(ee,{id:"show-celebration",checked:s,onCheckedChange:h=>{g(h),p("showStreakCelebration",h)},"data-testid":"switch-show-streak-celebration"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4 px-4 py-3.5",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(S,{htmlFor:"show-progress",className:"cursor-pointer text-sm font-medium",children:r.streakProgressIndicators}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r.streakProgressDescription})]}),e.jsx(ee,{id:"show-progress",checked:j,onCheckedChange:h=>{v(h),p("showStreakProgress",h)},"data-testid":"switch-show-streak-progress"})]})]})})]})}function an(){const{showTraditional:i,setShowTraditional:n}=ia(),{account:t}=we();return e.jsxs("div",{className:"flex items-center justify-between gap-4 pt-2",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(S,{className:"text-sm font-medium cursor-pointer",children:t.traditionalCharacters}),e.jsx("p",{className:"text-xs text-muted-foreground",children:i?t.traditionalCharactersDescription:t.simplifiedCharactersDescription})]}),e.jsx(ee,{checked:i,onCheckedChange:n,"data-testid":"switch-traditional-chinese-settings"})]})}const nn=["mandarin","spanish","german","french","japanese","english"];function rn({user:i}){const{toast:n}=Fe(),t=ns(),[r,u]=l.useState(!1),{account:s,common:g,dictionary:j}=we(),v=async p=>{try{await R("PATCH","/api/user/profile",{nativeLanguage:p}),t.invalidateQueries({queryKey:["/api/auth/me"]}),t.invalidateQueries({queryKey:["/api/user"]}),n({title:s.translationLanguageUpdated,description:s.translationLanguageUpdatedDescription})}catch{n({title:s.failedToUpdateTranslationLanguage,variant:"destructive"})}};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(S,{className:"text-sm font-medium",children:s.translationLanguageLabel}),e.jsxs(ra,{open:r,onOpenChange:u,children:[e.jsx(oa,{asChild:!0,children:e.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground transition-colors",onClick:()=>u(p=>!p),children:e.jsx(Cs,{className:"w-4 h-4"})})}),e.jsx(ca,{side:"bottom",align:"start",className:"max-w-[min(20rem,calc(100vw-2rem))]",children:s.translationLanguageTooltip})]})]}),e.jsxs(js,{value:(i==null?void 0:i.nativeLanguage)??"english",onValueChange:v,children:[e.jsx(ys,{"data-testid":"select-native-language",className:"w-full",children:e.jsx(vs,{placeholder:s.selectTranslationLanguage})}),e.jsx(bs,{className:"max-h-[400px]",children:la.map(p=>e.jsx(as,{value:p.value,"data-testid":`option-native-language-${p.value}`,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ss,{language:p.value,size:"sm"}),e.jsx("span",{className:"text-sm",children:Na(p.value,j,p.nativeScript)})]})},p.value))})]}),e.jsx("p",{className:"text-xs text-muted-foreground leading-snug",children:s.aiGeneratedWarning})]})}function on({user:i,isAdmin:n=!1}){var L;const{toast:t}=Fe(),[r,u]=l.useState((i==null?void 0:i.secondaryLanguages)||[]),[s,g]=l.useState(!1),j=((L=i==null?void 0:i.preferredLanguage)==null?void 0:L.toLowerCase())||null,v=l.useRef(null),p=l.useRef(r),h=l.useRef(!1),I=l.useRef(!1),{account:k,common:Z,dictionary:O}=we(),_=xt(O);l.useEffect(()=>{v.current||h.current||I.current||(u((i==null?void 0:i.secondaryLanguages)||[]),p.current=(i==null?void 0:i.secondaryLanguages)||[])},[i==null?void 0:i.secondaryLanguages]);const x=nn.filter(P=>P!==j),D=l.useCallback(async()=>
18{if(h.current){I.current=!0;return}h.current=!0,g(!0);const P=[...p.current];try{await R("PATCH","/api/user/profile",{secondaryLanguages:P}),oe.invalidateQueries({queryKey:["/api/auth/me"]})}catch{u((i==null?void 0:i.secondaryLanguages)||[]),p.current=(i==null?void 0:i.secondaryLanguages)||[],t({title:k.failedToUpdate,variant:"warning"})}finally{h.current=!1,I.current?(I.current=!1,D()):g(!1)}},[i==null?void 0:i.secondaryLanguages,t,k.failedToUpdate]),H=l.useCallback(P=>{u(W=>{const se=new Set(W);se.has(P)?se.delete(P):se.add(P);const N=Array.from(se);return p.current=N,v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{D()},800),N})},[D]);return l.useEffect(()=>()=>{v.current&&clearTimeout(v.current)},[]),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(S,{className:"text-sm font-medium",children:k.quickSwitchLanguages}),s&&e.jsxs("span",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(Os,{className:"h-3 w-3 animate-spin"}),Z.saving]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:k.quickSwitchDescription})]}),e.jsx("div",{className:"rounded-xl border overflow-hidden divide-y",children:x.map(P=>{const W=r.includes(P);return e.jsxs("button",{type:"button",className:`flex items-center gap-3 w-full text-left px-4 py-3 transition-colors cursor-pointer ${W?"bg-primary/5 hover:bg-primary/8":"bg-background hover:bg-muted/40"}`,onClick:()=>H(P),"data-testid":`button-secondary-lang-${P}`,children:[e.jsx("div",{className:`flex items-center justify-center w-5 h-5 rounded-full border-2 shrink-0 transition-colors ${W?"bg-primary border-primary":"border-muted-foreground/30"}`,children:W&&e.jsx(ge,{className:"w-3 h-3 text-primary-foreground"})}),e.jsx(Ss,{language:P,size:"sm"}),e.jsx("span",{className:`text-sm transition-colors ${W?"font-semibold":"font-medium text-muted-foreground"}`,children:_[P]})]},P)})})]})}function cn({control:i}){const[n,t]=l.useState(!1),r=Qa(),u=l.useRef(null),{account:s}=we();l.useEffect(()=>{n&&u.current&&setTimeout(()=>{var j;(j=u.current)==null||j.scrollIntoView({block:"center"})},50)},[n]);const g=r.findIndex(j=>j.offsetMinutes>=0);return e.jsx(us,{control:i,name:"timezone",render:({field:j})=>{const v=r.find(p=>p.value===j.value);return e.jsxs(ps,{className:"flex flex-col",children:[e.jsx(hs,{children:s.timezone}),e.jsxs(mt,{open:n,onOpenChange:t,children:[e.jsx(ut,{asChild:!0,children:e.jsx(xs,{children:e.jsxs(f,{variant:"outline",role:"combobox","aria-expanded":n,className:"justify-between font-normal","data-testid":"select-timezone",children:[e.jsx("span",{className:"truncate",children:v?v.label:s.selectTimezone}),e.jsx(Rs,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})})}),e.jsx(pt,{className:"w-[400px] p-0",align:"start",children:e.jsxs(da,{children:[e.jsx(ma,{placeholder:s.searchTimezone,"data-testid":"input-timezone-search"}),e.jsxs(ua,{children:[e.jsx(pa,{children:s.noTimezoneFound}),e.jsx(ha,{children:r.map((p,h)=>e.jsxs(xa,{ref:h===g?u:void 0,value:p.label,keywords:[p.value,p.value.replace(/_/g," ")],onSelect:()=>{j.onChange(p.value),t(!1)},"data-testid":`timezone-option-${p.value}`,children:[e.jsx(ge,{className:`mr-2 h-4 w-4 ${j.value===p.value?"opacity-100":"opacity-0"}`}),p.label]},p.value))})]})]})})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s.timezoneDescription}),e.jsx(gs,{})]})}})}function Dn(){const i=we(),{account:n,common:t,header:r,dictionary:u}=i,s=n,{theme:g,toggleTheme:j}=At(),v=xt(u),p={beginner:r.levelBeginner,"lower-intermediate":r.levelLowerIntermediate,intermediate:r.levelIntermediate,"upper-intermediate":r.levelUpperIntermediate,advanced:r.levelAdvanced},h={beginner:r.levelBeginnerDesc,"lower-intermediate":r.levelLowerIntermediateDesc,intermediate:r.levelIntermediateDesc,"upper-intermediate":r.levelUpperIntermediateDesc,advanced:r.levelAdvancedDesc},[,I]=Dt(),k=Et(),Z=new URLSearchParams(k).get("tab")||"profile",{data:O}=je({queryKey:["/api/settings/public"],staleTime:5*60*1e3}),_=(O==null?void 0:O.levelAutoAdvanceEnabled)??!0,{toast:x}=Fe(),{selectedLanguage:D,abilityLevel:H,selectedLevels:L,showAllLevels:P,setSelectedLanguage:W,setAbilityLevel:se,toggleLevel:N,setShowAllLevels:X}=It(),{consentGiven:re,consentRequired:A,revokeConsent:te,grantConsent:C,isPending:de}=Lt(),{settings:M,updateSettings:ae}=Ft(),qe=l.useRef(null),[Oe,me]=l.useState(null),[Ne,ue]=l.useState(!1),[Y,ye]=l.useState(""),[T,Re]=l.useState(""),[ce,Ae]=l.useState(""),[Ce,He]=l.useState(!1),[ve,pe]=l.useState(!1),[De,m]=l.useState(!1),[w,Se]=l.useState(""),[be,ks]=l.useState(!1),[Ue,Me]=l.useState(!1),{isInstalled:he,isInstallable:is,promptInstall:E}=Ot(),{isNativeApp:_e,isIOSNativeApp:Qe}=ct(),[Ye,Ts]=l.useState(!1),[Ps,Je]=l.useState(!1);l.useEffect(()=>{if(typeof window<"u"){const a=navigator.userAgent,d=/iPad|iPhone|iPod/.test(a)&&!window.MSStream,b=/Macintosh/.test(a)&&navigator.maxTouchPoints>1;Ts(d||b),Je(/Android/.test(a))}},[]),l.useEffect(()=>{const a=window.location.hash;if(!a)return;const d=setTimeout(()=>{const b=document.querySelector(a);b&&b.scrollIntoView({behavior:"smooth",block:"center"})},400);return()=>clearTimeout(d)},[]);const{data:c}=je({queryKey:["/api/auth/me"]}),ke=(c==null?void 0:c.role)==="admin"||(c==null?void 0:c.role)==="super-admin",Ze=
18Rt(c==null?void 0:c.nativeLanguage),rs=l.useRef(!1),Xe=l.useRef(!1);l.useEffect(()=>{async function a(){if(Xe.current)return;const d=new URLSearchParams(window.location.search),b=d.get("subscription"),F=d.get("portal"),Pe=d.get("upgrade");if((b==="success"||b==="cancelled"||F==="return"||Pe==="success")&&window.ReactNativeWebView&&(localStorage.removeItem("stripe_session_pending"),window.ReactNativeWebView.postMessage(JSON.stringify({action:"leaving-stripe"}))),b==="success"){Xe.current=!0,console.log("[AccountSettings] Checkout success detected, syncing subscription...");const es=d.get("stripe_session_id");let K=null;if(es)try{const ne=await fetch(`/api/admin/subscription/checkout-session-details?sessionId=${encodeURIComponent(es)}`,{credentials:"include"});ne.ok&&(K=await ne.json(),console.log("[GTM] Retrieved checkout details from server:",K))}catch(ne){console.warn("[GTM] Server session lookup failed, falling back to localStorage:",ne)}if(!K){const ne=localStorage.getItem("pendingCheckout");if(ne)try{const J=JSON.parse(ne);Date.now()-J.timestamp<60*60*1e3&&(K={transactionId:es??`wl_${Date.now()}_${J.planId}`,planId:J.planId,planType:J.planType,currency:J.currency,priceInCents:J.priceInCents},console.log("[GTM] Using localStorage fallback for checkout details"))}catch(J){console.error("[GTM] Error parsing localStorage pendingCheckout:",J)}}localStorage.removeItem("pendingCheckout"),K?(Ds.purchase(K.transactionId,K.planId,K.planType,K.currency,K.priceInCents),console.log("[GTM] Purchase event fired:",{transactionId:K.transactionId,planId:K.planId,planType:K.planType,currency:K.currency,value:K.priceInCents/100}),window.ReactNativeWebView&&ga("purchase",{tier:K.planType,price:K.priceInCents/100,currency:K.currency,receipt_id:K.transactionId,platform:"android"})):console.warn("[GTM] Could not determine checkout details â purchase event not fired"),d.delete("subscription");const qs=d.toString(),Ct=qs?`${window.location.pathname}?${qs}`:window.location.pathname;window.history.replaceState({},"",Ct);const St=[0,2e3,5e3,1e4],kt=1e4,Tt=new Set(["active","trialing","trial","cancelling"]),Pt=()=>{const ne=oe.getQueryData(["/api/auth/me"]);return!!(ne!=null&&ne.stripeSubscriptionId&&Tt.has(ne.subscriptionStatus??""))};let Us=!1;for(const ne of St){ne&&await new Promise(J=>window.setTimeout(J,ne));try{const J=await R("POST","/api/admin/subscription/sync",void 0,{timeoutMs:kt});J.ok||console.warn("[AccountSettings] Post-checkout sync returned",J.status)}catch(J){console.warn("[AccountSettings] Post-checkout sync attempt failed:",J)}try{await oe.refetchQueries({queryKey:["/api/auth/me"]})}catch(J){console.warn("[AccountSettings] Account refresh after sync failed:",J)}if(Pt()){Us=!0;break}}Us?(console.log("[AccountSettings] Post-checkout subscription visible on the account"),x({title:n.subscriptionActivated,description:n.subscriptionActivatedDescription})):console.error("[AccountSettings] Post-checkout plan not visible yet; relying on webhook activation")}else if(b==="cancelled"){localStorage.removeItem("pendingCheckout"),d.delete("subscription");const es=d.toString()?`${window.location.pathname}?${d.toString()}`:window.location.pathname;window.history.replaceState({},"",es)}}a()},[x]),l.useEffect(()=>{async function a(){if(rs.current||!c)return;if(c.stripeSubscriptionId&&(c.subscriptionStatus==="active"||c.subscriptionStatus==="cancelling"||c.subscriptionStatus==="trial"||c.subscriptionStatus==="trialing"))try{console.log("[AccountSettings] Syncing subscription from Stripe..."),(await R("POST","/api/admin/subscription/sync")).ok&&(console.log("[AccountSettings] Subscription synced successfully"),rs.current=!0,oe.invalidateQueries({queryKey:["/api/auth/me"]}))}catch(b){console.error("[AccountSettings] Failed to sync subscription:",b)}}a()},[c]);const o=l.useMemo(()=>Mt(Ja(i)),[i]),y=qt({resolver:o,defaultValues:{firstName:"",lastName:"",email:"",subscriptionEnabled:!1,subscriptionLanguage:null,subscriptionLevel:null,marketingOptIn:!1,timezone:""}});l.useEffect(()=>{c&&(console.log("[AccountSettings] User data:",{profileImageUrl:c.profileImageUrl,username:c.username,subscriptionEnabled:c.subscriptionEnabled}),y.reset({firstName:c.firstName??"",lastName:c.lastName??"",email:c.email??"",subscriptionEnabled:c.subscriptionEnabled??!1,subscriptionLanguage:c.subscriptionLanguage??"",subscriptionLevel:c.subscriptionLevel??"",marketingOptIn:c.marketingOptIn??!1,timezone:c.timezone??""}),me(c.profileImageUrl??null),console.log("[AccountSettings] Form reset with subscriptionEnabled:",c.subscriptionEnabled??!1))},[c]);const q=ie({mutationFn:async a=>{const d=new FormData;return d.append("profilePicture",a),(await Ca("POST","/api/user/profile-picture",d)).json()},onSuccess:()=>{oe.invalidateQueries({queryKey:["/api/auth/me"]}),x({title:t.success,description:n.profilePictureUploaded})},onError:a=>{const d=a.message||"";let b=n.imageProcessingError;d.toLowerCase().includes("size")||d.toLowerCase().includes("large")?b=n.imageTooLargeError:(d.toLowerCase().includes("format")||d.toLowerCase().includes("type"))&&(b=n.invalidImageFormatError),le(x,ke,{adminTitle:"Unable to upload picture",adminDescription:d||"Failed to upload profile picture",userTitle:n.unableToUploadPicture,userDescription:b})}}),Q=ie({mutationFn:async a=>await R("PUT","/api/user/profile",a),onSuccess:()=>{oe.invalidateQueries({queryKey:["/api/auth/me"]})},onError:()=>{x({title:n.failedToUpdateProfile,variant:"warning"})}}),[U,We]=l.useState(!1),xe=ie({mutationFn:async()=>await R("POST","/api/auth/resend-verification"),onSuccess:()=>{x({title:n.verificationEmailSent,description:n.verificationEmailSentDescription})},onError:a=>{le(x,ke,{adminTitle:"Failed to send verification email",adminDescription:a.message,userTitle:n.couldntSendEmail,userDescription:t.tryAgain})}}),Ve=ie({mutationFn:async a=>{const d=await R("PUT","/api/user/password",a);if(!d.ok){const F=(await d.json()).error||"Failed to change password";throw F.toLowerCase().includes("incorrect")||F.toLowerCase().includes("invalid")?new Error("Your current password is incorrect. Please try again."):F.toLowerCase().includes("weak")||F.toLowerCase().includes("requirements")?new Error("Your new password doesn't meet the requirements. Please use at least 8 characters with upper, lower, number, and special character."):new Error(F)}return d.json()},onSuccess:()=>{x({title:n.passwordChanged,description:n.passwordChangedDescription}),ye(""),Re(""),Ae("")},onError:a=>{le(x,ke,{adminTitle:"Unable to change password",adminDescription:a.message,userTitle:n.couldntChangePassword,userDescription:n.checkPasswordError})}}),Te=ie({mutationFn:async a=>{const d=await R("DELETE","/api/user/account",{password:a});if(!d.ok){const F=(await d.json()).error||"Failed to schedule account deleti
18on";throw F.toLowerCase().includes("incorrect password")||F.toLowerCase().includes("invalid password")?new Error("The password you entered is incorrect. Please try again."):F.toLowerCase().includes("locked")?new Error("Your account is temporarily locked. Please try again later."):new Error(F)}return d.json()},onSuccess:a=>{x({title:n.deletionScheduledTitle,description:n.deletionScheduledDescription}),Se(""),Me(!1),oe.invalidateQueries({queryKey:["/api/auth/me"]})},onError:a=>{le(x,ke,{adminTitle:"Unable to schedule deletion",adminDescription:a.message,userTitle:n.couldntScheduleDeletion,userDescription:n.checkPasswordError}),Me(!1)}}),Ee=ie({mutationFn:async()=>{const a=await R("POST","/api/user/account/cancel-deletion");if(!a.ok){const d=await a.json();throw new Error(d.error||"Failed to cancel deletion")}return a.json()},onSuccess:()=>{x({title:n.deletionCancelled,description:n.deletionCancelledDescription}),oe.invalidateQueries({queryKey:["/api/auth/me"]})},onError:a=>{le(x,ke,{adminTitle:"Unable to cancel deletion",adminDescription:a.message,userTitle:n.couldntCancelDeletion,userDescription:t.tryAgain})}}),$e=ie({mutationFn:async()=>{const a=await R("PATCH","/api/auth/users/me/onboarding-reset");if(!a.ok)throw new Error("Failed to reset tour");return a.json()},onSuccess:()=>{oe.invalidateQueries({queryKey:["/api/auth/me"]}),I("/platform")},onError:()=>{x({title:n.couldNotResetTour,variant:"destructive"})}}),os=ie({mutationFn:async()=>{const a=await R("PATCH","/api/auth/users/me/article-tour-reset");if(!a.ok)throw new Error("Failed to reset article tour");return a.json()},onSuccess:()=>{oe.invalidateQueries({queryKey:["/api/auth/me"]}),x({title:n.articleTourResetSuccess})},onError:()=>{x({title:n.couldNotResetArticleTour,variant:"destructive"})}}),gt=a=>{if(a==null||a.preventDefault(),!Y){x({title:n.currentPasswordRequired,description:n.enterCurrentPasswordError,variant:"destructive"});return}if(T.length<8){x({title:n.passwordTooShort,description:n.passwordMinLengthError,variant:"destructive"});return}if(!/[A-Z]/.test(T)){x({title:n.missingUppercase,description:n.missingUppercaseError,variant:"destructive"});return}if(!/[a-z]/.test(T)){x({title:n.missingLowercase,description:n.missingLowercaseError,variant:"destructive"});return}if(!/[0-9]/.test(T)){x({title:n.missingNumber,description:n.missingNumberError,variant:"destructive"});return}if(!/[^A-Za-z0-9]/.test(T)){x({title:n.missingSpecialCharacter,description:n.missingSpecialCharacterError,variant:"destructive"});return}if(T!==ce){x({title:n.passwordsDoNotMatch,description:n.passwordsMatchError,variant:"destructive"});return}Ve.mutate({currentPassword:Y,newPassword:T})},ft=()=>{if(!w){x({title:n.passwordRequired,description:n.deleteAccountPasswordError,variant:"destructive"});return}Te.mutate(w)},jt=async a=>{var b;const d=(b=a.target.files)==null?void 0:b[0];if(a.target.value="",!!d){if(!d.type.startsWith("image/")){x({title:t.error,description:n.onlyImagesAllowed,variant:"destructive"});return}try{let F=d;d.size>1024*1024&&(We(!0),F=await Ya(d),We(!1));const Pe=new FileReader;Pe.onloadend=()=>{me(Pe.result)},Pe.readAsDataURL(F),q.mutate(F)}catch{We(!1),x({title:t.error,description:n.imageProcessingError,variant:"destructive"})}}},yt=async()=>{var b;const a=navigator.userAgent;if(/iPad|iPhone|iPod|Android/.test(a)||navigator.maxTouchPoints>1)try{(await navigator.permissions.query({name:"camera"})).state==="denied"&&x({title:t.cameraBlockedTitle,description:t.cameraBlockedDescription,variant:"warning"})}catch{}(b=qe.current)==null||b.click()},vt=a=>{const d={},b=y.formState.dirtyFields;console.log("[AccountSettings] Form submit - dirtyFields:",b),console.log("[AccountSettings] Form submit - data:",a);const F=Pe=>{if(typeof Pe=="string"){const As=Pe.trim();return As===""?null:As}return Pe};b.firstName&&(d.firstName=F(a.firstName)),b.lastName&&(d.lastName=F(a.lastName)),b.email&&(d.email=F(a.email)),"subscriptionEnabled"in b&&(d.subscriptionEnabled=a.subscriptionEnabled,console.log("[AccountSettings] subscriptionEnabled is dirty, value:",a.subscriptionEnabled)),"marketingOptIn"in b&&(d.marketingOptIn=a.marketingOptIn),b.timezone&&(d.timezone=F(a.timezone)),b.subscriptionLanguage&&(d.subscriptionLanguage=F(a.subscriptionLanguage)),b.subscriptionLevel&&(d.subscriptionLevel=F(a.subscriptionLevel)),console.log("[AccountSettings] Upd
18ates to send:",d),Object.keys(d).length!==0&&Q.mutate(d)},bt=a=>{W(a)},wt=()=>{I("/platform")},Nt=async()=>{ue(!0);try{if("caches"in window){const a=await caches.keys();await Promise.all(a.map(d=>caches.delete(d))),console.log("[UpdateApp] Cleared all caches:",a)}if("serviceWorker"in navigator){const a=await navigator.serviceWorker.getRegistrations();for(const d of a)await d.unregister(),console.log("[UpdateApp] Unregistered service worker")}localStorage.removeItem("wirelingo_last_version_check"),localStorage.removeItem("wirelingo_update_available"),setTimeout(()=>{window.location.reload()},1e3)}catch(a){console.error("[UpdateApp] Error updating app:",a),ue(!1),x({title:s.updateFailedTitle,description:s.updateFailedDesc,variant:"destructive"})}};return e.jsx("div",{className:"min-h-screen bg-background",children:e.jsxs("div",{className:"max-w-2xl mx-auto p-4 sm:p-6 space-y-4 sm:space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(f,{variant:"ghost",size:"icon",onClick:wt,"data-testid":"button-back",children:e.jsx(Ut,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:s.accountSettings}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s.manageAccountDescription})]})]}),e.jsxs(ja,{defaultValue:Z,className:"w-full",children:[e.jsxs(ya,{className:"w-full grid grid-cols-5 h-auto p-1","data-testid":"settings-tabs",children:[e.jsxs(ss,{value:"profile",className:"gap-1.5 px-2 py-2 text-xs sm:text-sm","data-testid":"tab-profile",children:[e.jsx(Fa,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"hidden sm:inline",children:s.profileTab})]}),e.jsxs(ss,{value:"learning",className:"gap-1.5 px-2 py-2 text-xs sm:text-sm","data-testid":"tab-learning",children:[e.jsx(Bs,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"hidden sm:inline",children:s.learningTab})]}),e.jsxs(ss,{value:"experience",className:"gap-1.5 px-2 py-2 text-xs sm:text-sm","data-testid":"tab-experience",children:[e.jsx($a,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"hidden sm:inline",children:s.experienceTab})]}),e.jsxs(ss,{value:"privacy",className:"gap-1.5 px-2 py-2 text-xs sm:text-sm","data-testid":"tab-privacy",children:[e.jsx(Ie,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"hidden sm:inline",children:s.privacyTab})]}),e.jsxs(ss,{value:"security",className:"gap-1.5 px-2 py-2 text-xs sm:text-sm","data-testid":"tab-security",children:[e.jsx(Hs,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"hidden sm:inline",children:s.securityTab})]})]}),e.jsxs(ts,{value:"profile",className:"space-y-4 sm:space-y-6 mt-4 sm:mt-6",children:[e.jsxs(V,{children:[e.jsxs(z,{children:[e.jsx(G,{children:s.profileSettings}),e.jsx(B,{children:s.profileDescription})]}),e.jsx($,{children:e.jsx(_t,{...y,children:e.jsxs("form",{onSubmit:y.handleSubmit(vt),className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4 sm:gap-6",children:[Oe?e.jsx("img",{src:Oe,alt:s.profilePicture,className:"h-16 w-16 sm:h-20 sm:w-20 rounded-full object-cover border shrink-0"}):(()=>{const a=va((c==null?void 0:c.email)||(c==null?void 0:c.username)||""),d=ba(c==null?void 0:c.firstName,c==null?void 0:c.lastName,c==null?void 0:c.username);return e.jsx("div",{className:`h-16 w-16 sm:h-20 sm:w-20 rounded-full flex items-center justify-center text-xl sm:text-2xl font-semibold shrink-0 ${a.bg} ${a.text}`,children:d})})(),e.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[e.jsx(S,{children:s.profilePicture}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{ref:qe,type:"file",accept:"image/*",onChange:jt,className:"hidden","data-testid":"input-profile-picture"}),e.jsxs(f,{type:"button",variant:"outline",onClick:yt,disabled:q.isPending||U,"data-testid":"button-upload-profile-picture",children:[e.jsx(Oa,{className:"h-4 w-4 mr-2"}),U?t.optimising:q.isPending?t.uploading:s.uploadImage]})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s.imageOptimiseHint})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(us,{control:y.control,name:"firstName",render:({field:a})=>e.jsxs(ps,{children:[e.jsx(hs,{children:s.firstName}),e.jsx(xs,{children:e.jsx(fe,{placeholder:s.firstNamePlaceholder,...a,value:a.value??"","data-testid":"input-first-name"})}),e.jsx(gs,{})]})}),e.jsx(us,{control:y.control,name:"lastName",render:({field:a})=>e.jsxs(ps,{children:[e.jsx(hs,{children:s.lastName}),e.jsx(xs,{children:e.jsx(fe,{placeholder:s.lastNamePlaceholder,...a,value:a.value??"","data-testid":"input-last-name"})}),e.jsx(gs,{})]})})]}),e.jsx(us,{control:y.control,name:"email",render:({field:a})=>e.jsxs(ps,{children:[e.jsx(hs,{children:s.emailLabel}),e.jsx(xs,{children:e.jsx(fe,{type:"email",placeholder:s.emailPlaceholder,autoCapitalize:"none",autoCorrect:"off",autoComplete:"email",...a,value:a.value??"","data-testid":"input-email"})}),e.jsx(gs,{})]})}),e.jsx(cn,{control:y.control}),e.jsx(f,{type:"submit",disabled:Q.isPending,"data-testid":"button-save-profile",children:Q.isPending?t.saving:s.saveProfile})]})})})]}),ke&&e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(f,{variant:"outline",size:"sm",onClick:()=>os.mutate(),disabled:os.isPending,"data-testid":"button-test-article-tour",children:os.isPending?t.resetting:s.testArticleTour}),e.jsx(f,{variant:"outline",size:"sm",onClick:()=>$e.mutate(),disabled:$e.isPending,"data-testid":"button-test-header-tour",children:$e.isPending?t.resetting:s.testHeaderTour})]}),c&&!c.emailVerified&&c.subscriptionStatus==="trial_ineligible"&&!c.trialBlocked&&e.jsxs(V,{className:"border-orange-500/30 bg-
18orange-50/50 dark:bg-orange-950/20",children:[e.jsxs(z,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(Ns,{className:"h-5 w-5 text-orange-600"}),e.jsx(G,{className:"text-base",children:s.trialPaused}),e.jsx(Wt,{variant:"outline",className:"text-orange-600 border-orange-600/50 text-xs",children:s.actionRequired})]}),e.jsx(B,{children:s.trialPausedDescription})]}),e.jsxs($,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s.trialPausedActionHint}),e.jsxs(f,{onClick:()=>xe.mutate(),disabled:xe.isPending,"data-testid":"button-resend-verification-trial-paused",children:[e.jsx(Le,{className:"h-4 w-4 mr-2"}),xe.isPending?t.sending:s.resendVerification]})]})]}),c&&!c.emailVerified&&c.subscriptionStatus!=="trial_ineligible"&&e.jsxs(V,{className:"border-amber-500/20",children:[e.jsxs(z,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Qs,{className:"h-5 w-5 text-amber-500"}),e.jsx(G,{className:"text-base",children:s.emailVerification})]}),e.jsx(B,{children:s.emailNotVerified})]}),e.jsxs($,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s.emailVerificationActionHint}),e.jsxs(f,{variant:"outline",onClick:()=>xe.mutate(),disabled:xe.isPending,"data-testid":"button-resend-verification-settings",children:[e.jsx(Le,{className:"h-4 w-4 mr-2"}),xe.isPending?t.sending:s.resendVerification]})]})]}),c&&c.emailVerified&&e.jsxs(V,{children:[e.jsx(z,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ys,{className:"h-5 w-5 text-green-500"}),e.jsx(G,{className:"text-base",children:s.emailVerified})]})}),e.jsx($,{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:s.emailVerifiedSuccess})})]}),!_e&&e.jsxs(V,{children:[e.jsxs(z,{children:[e.jsxs(G,{className:"flex items-center gap-2",children:[e.jsx(ws,{className:"h-5 w-5"}),s.installApp]}),e.jsx(B,{children:s.installAppDescription})]}),e.jsx($,{className:"space-y-4",children:he?e.jsxs("div",{className:"flex items-center gap-2 text-green-600 dark:text-green-400",children:[e.jsx(Ys,{className:"h-5 w-5"}),e.jsx("span",{children:s.appInstalled})]}):e.jsxs(e.Fragment,{children:[is&&!Ye&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Va,{className:"h-5 w-5 text-blue-500"}),e.jsx("span",{className:"font-medium",children:s.installOnChrome})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s.installOnChromeHint}),e.jsxs(f,{onClick:E,className:"gap-2","data-testid":"button-install-chrome",children:[e.jsx(Vt,{className:"h-4 w-4"}),s.installWireLingo]})]}),Ye&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Js,{className:"h-5 w-5 text-foreground/70 dark:text-muted-foreground/50"}),e.jsx("span",{className:"font-medium",children:s.getOnIos})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s.getOnIOSHint}),e.jsxs(f,{onClick:()=>{Ds.appStoreClick("apple","account_settings"),window.open($t,"_blank","noopener,noreferrer")},className:"gap-2","data-testid":"button-install-ios",children:[e.jsx(Js,{className:"h-4 w-4"}),s.downloadOnAppStore]})]}),Ps&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Zs,{className:"h-5 w-5 text-green-600"}),e.jsx("span",{className:"font-medium",children:s.getOnAndroid})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s.getOnAndroidHint}),e.jsxs(f,{onClick:()=>{Ds.appStoreClick("google","account_settings"),window.open(zt,"_blank","noopener,noreferrer")},className:"gap-2","data-testid":"button-install-android",children:[e.jsx(Zs,{className:"h-4 w-4"}),s.getOnGooglePlay]})]}),!is&&!Ye&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[s.howToInstallApp,":"]}),e.jsxs("ul",{className:"text-sm text-muted-foreground space-y-2 list-disc list-inside",children:[e.jsxs("li",{children:[e.jsxs("strong",{children:[s.chrome,":"]})," ",s.chromeInstallHint]}),e.jsxs("li",{children:[e.jsxs("strong",{children:[s.safari,":"]})," ",s.safariInstallHint]}),e.jsxs("li",{children:[e.jsxs("strong",{children:[s.edge,":"]}
18)," ",s.edgeInstallHint]})]})]})]})})]}),!_e&&he&&e.jsxs(V,{children:[e.jsxs(z,{children:[e.jsxs(G,{className:"flex items-center gap-2",children:[e.jsx(fs,{className:"h-5 w-5"}),s.updateApp]}),e.jsx(B,{children:s.updateAppDescription})]}),e.jsxs($,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s.updateAppHint}),e.jsxs(f,{onClick:Nt,disabled:Ne,className:"gap-2","data-testid":"button-update-app",children:[e.jsx(fs,{className:`h-4 w-4 ${Ne?"animate-spin":""}`}),Ne?t.updating:s.updateApp]})]})]})]}),e.jsxs(ts,{value:"learning",className:"space-y-4 sm:space-y-6 mt-4 sm:mt-6",children:[e.jsxs(V,{children:[e.jsxs(z,{children:[e.jsx(G,{children:s.primaryLearningLanguage}),e.jsx(B,{children:s.primaryLearningLanguageDesc})]}),e.jsxs($,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{htmlFor:"language-select",children:s.language}),e.jsxs(js,{value:D||void 0,onValueChange:bt,children:[e.jsx(ys,{id:"language-select","data-testid":"select-language",children:e.jsx(vs,{placeholder:s.chooseLanguage})}),e.jsx(bs,{children:Object.entries(v).map(([a,d])=>e.jsx(as,{value:a,"data-testid":`option-language-${a}`,children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Ss,{language:a,size:"sm"}),d]})},a))})]})]}),e.jsx(rn,{user:c}),e.jsx(on,{user:c,isAdmin:ke}),((D==null?void 0:D.toLowerCase())==="mandarin"||((c==null?void 0:c.secondaryLanguages)||[]).includes("mandarin"))&&e.jsx(an,{})]})]}),e.jsxs(V,{id:"reading-level",children:[e.jsxs(z,{children:[e.jsx(G,{children:s.readingLevel}),e.jsx(B,{children:s.readingLevelDescription})]}),e.jsxs($,{className:"space-y-4",children:[e.jsx("div",{className:"rounded-lg bg-muted/50 p-3.5 space-y-2.5",children:[{Icon:Bs,text:s.readingLevelTip1},..._?[{Icon:Xs,text:s.readingLevelTip2Auto}]:[{Icon:Xs,text:s.readingLevelTip2}],{Icon:fs,text:s.readingLevelTip3},{Icon:Gt,text:s.readingLevelTip4}].map(({Icon:a,text:d},b)=>e.jsxs("div",{className:"flex gap-2.5 text-xs text-muted-foreground leading-relaxed",children:[e.jsx(a,{className:"w-3.5 h-3.5 shrink-0 mt-px"}),e.jsx("span",{children:d})]},b))}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(S,{children:s.selectLevels}),e.jsxs(mt,{children:[e.jsx(ut,{asChild:!0,children:e.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground transition-colors","data-testid":"button-level-info",children:e.jsx(Cs,{className:"w-4 h-4"})})}),e.jsxs(pt,{className:"w-80 p-0",align:"start",children:[e.jsxs("div",{className:"p-4 border-b",children:[e.jsx("h4",{className:"font-semibold text-sm",children:s.proficiencyLevels}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:s.whatLevelsMean})]}),e.jsx("div",{className:"max-h-80 overflow-y-auto",children:Es.map((a,d)=>e.jsxs("div",{className:`p-3 ${d!==Es.length-1?"border-b":""}`,children:[e.jsx("div",{className:"font-medium text-sm",children:p[a.id]??a.label}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1 leading-relaxed",children:h[a.id]??a.description})]},a.id))})]})]})]}),e.jsx("div",{className:"rounded-xl border overflow-hidden divide-y",children:Es.map(a=>{const d=L.includes(a.id);return e.jsxs("button",{type:"button",className:`flex items-center gap-3 w-full text-left px-4 py-3.5 transition-colors cursor-pointer ${d?"bg-primary/5 hover:bg-primary/8":"bg-background hover:bg-muted/40"}`,onClick:()=>N(a.id),"data-testid":`button-level-${a.id}`,children:[e.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center shrink-0 transition-colors p-1",style:{background:d?Kt[a.id]??"hsl(var(--primary))":"rgba(0,0,0,0.06)"},children:e.jsx(Bt,{filled:Ht[a.id],levelId:a.id,active:d,variant:"light"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:`block text-sm transition-colors ${d?"font-semibold":"font-medium text-muted-foreground"}`,children:p[a.id]??a.label}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 leading-relaxed",children:h[a.id]??a.description})]}),d&&e.jsx("div",{className:"shrink-0 w-1.5 h-1.5 rounded-full bg-primary"})]},a.id)})}),L.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground italic",children:s.noLevelsSelected}),L.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:L.length===1?s.showingLevelLessons(p[L[0]]):s.showingMultipleLevelsLessons(L.length)}),L.length>1&&e.jsx("p",{className:"text-xs text-muted-foreground",children:s.highestLevelDefault})]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4 pt-4 border-t",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(S,{htmlFor:"show-all-levels",className:"cursor-pointer text-sm font-medium",children:s.showAllLevels}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.showAllLevelsDescription})]}),e.jsx(ee,{id:"show-all-levels",checked:P,onCheckedChange:X,"data-testid":"switch-show-all-levels"})]})]})]}),e.jsx(tn,{user:c}),e.jsx(sn,{selectedLanguage:D}),D&&e.jsx(f,{className:"w-full",onClick:()=>I("/platform"),"data-testid":"button-continue",children:s.continueToLessons})]}
18),e.jsxs(ts,{value:"privacy",className:"space-y-4 sm:space-y-6 mt-4 sm:mt-6",children:[e.jsx(Za,{user:c}),!Qe&&e.jsxs(V,{children:[e.jsxs(z,{children:[e.jsxs(G,{className:"flex items-center gap-2",children:[e.jsx(Ie,{className:"h-5 w-5"}),s.cookiePreferences]}),e.jsx(B,{children:s.cookiePreferencesDescription})]}),e.jsxs($,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s.managePrivacyDescription}),e.jsx(f,{variant:"outline",onClick:()=>{typeof window.__ucCmp<"u"?window.__ucCmp.showSecondLayer():console.warn("Privacy settings not available - UserCentrics not loaded")},className:"gap-2","data-testid":"button-manage-privacy",children:s.managePrivacySettings})]})]}),A&&e.jsxs(V,{children:[e.jsxs(z,{children:[e.jsxs(G,{className:"flex items-center gap-2",children:[e.jsx(Ie,{className:"h-5 w-5"}),s.aiConsentTitle]}),e.jsx(B,{children:s.aiConsentDesc})]}),e.jsxs($,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s.aiConsentBody}),e.jsxs("div",{className:"flex items-center justify-between gap-4 p-4 rounded-xl bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:s.aiConsentLabel}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:re?s.aiConsentGiven:s.aiConsentNotGiven})]}),re?e.jsx(f,{variant:"outline",size:"sm",onClick:()=>te(),disabled:de,"data-testid":"button-revoke-ai-consent",children:de?e.jsx(Os,{className:"h-3.5 w-3.5 animate-spin"}):s.revokeConsent}):e.jsx(f,{size:"sm",onClick:()=>C(),disabled:de,"data-testid":"button-grant-ai-consent",children:de?e.jsx(Os,{className:"h-3.5 w-3.5 animate-spin"}):s.giveConsent})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.revokeConsentNote})]})]}),e.jsxs(V,{children:[e.jsxs(z,{children:[e.jsxs(G,{className:"flex items-center gap-2",children:[e.jsx(Ra,{className:"h-5 w-5"}),s.legal]}),e.jsx(B,{children:s.legalDesc})]}),e.jsxs($,{className:"space-y-4",children:[e.jsxs(at,{children:[e.jsx(nt,{asChild:!0,children:e.jsxs(f,{variant:"outline",className:"w-full justify-between","data-testid":"button-expand-privacy-policy",children:[s.privacyPolicy,e.jsx(Rs,{className:"h-4 w-4 transition-transform duration-200 group-data-[state=open]:rotate-180"})]})}),e.jsx(it,{className:"pt-4",children:e.jsx("div",{className:"border rounded-lg p-4 max-h-[400px] overflow-y-auto bg-muted/30",children:e.jsx(za,{compact:!0})})})]}),e.jsxs(at,{children:[e.jsx(nt,{asChild:!0,children:e.jsxs(f,{variant:"outline",className:"w-full justify-between","data-testid":"button-expand-terms",children:[s.termsOfService,e.jsx(Rs,{className:"h-4 w-4 transition-transform duration-200 group-data-[state=open]:rotate-180"})]})}),e.jsx(it,{className:"pt-4",children:e.jsx("div",{className:"border rounded-lg p-4 max-h-[400px] overflow-y-auto bg-muted/30",children:e.jsx(Ga,{compact:!0})})})]})]})]})]}),e.jsxs(ts,{value:"security",className:"space-y-4 sm:space-y-6 mt-4 sm:mt-6",children:[e.jsxs(V,{children:[e.jsxs(z,{children:[e.jsxs(G,{className:"flex items-center gap-2",children:[e.jsx(Hs,{className:"h-5 w-5"}),s.changePassword]}),e.jsx(B,{children:s.changePasswordDesc})]}),e.jsx($,{className:"space-y-4",children:e.jsxs("form",{onSubmit:gt,className:"space-y-4",children:[e.jsx("input",{type:"hidden",autoComplete:"username",value:(c==null?void 0:c.email)??"",readOnly:!0}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{htmlFor:"current-password",children:s.currentPassword}),e.jsxs("div",{className:"relative",children:[e.jsx(fe,{id:"current-password",name:"current-password",type:Ce?"text":"password",autoComplete:"current-password",value:Y,onChange:a=>ye(a.target.value),placeholder:s.enterCurrentPassword,className:"pr-10","data-testid":"input-current-password"}),e.jsx("button",{type:"button",className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",onClick:a=>{a.preventDefault(),a.stopPropagation(),He(d=>!d)},tabIndex:-1,"aria-label":Ce?t.hidePassword:t.showPassword,"data-testid":"button-toggle-current-password",children:Ce?e.jsx(ls,{className:"h-4 w-4"}):e.jsx(ds,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{htmlFor:"new-password",children:s.newPassword}),e.jsxs("div",{className:"relative",children:[e.jsx(fe,{id:"new-password",name:"new-password",type:ve?"text":"password",autoComplete:"new-password",value:T,onChange:a=>Re(a.target.value),placeholder:s.passwordNewPlaceholder,className:"pr-10","data-testid":"input-new-password"}),e.jsx("button",{type:"button",className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",onClick:a=>{a.preventDefault(),a.stopPropagation(),pe(d=>!d)},tabIndex:-1,"aria-label":ve?t.hidePassword:t.showPassword,"data-testid":"button-toggle-new-password",children:ve?e.jsx(ls,{className:"h-4 w-4"}):e.jsx(ds,{className:"h-4 w-4"})})]}),T&&(T.length<8||!/[A-Z]/.test(T)||!/[a-z]/.test(T)||!/[0-9]/.test(T)||!/[^A-Za-z0-9]/.test(T))&&e.jsx("p",{className:"text-sm text-destructive",children:T.length<8?s.passwordMinLength:/[A-Z]/.test(T)?/[a-z]/.test(T)?/[0-9]/.test(T)?s.passwordNeedsSpecial:s.passwordNeedsNumber:s.passwordNeedsLower:s.passwordNeedsUpper})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{htmlFor:"confirm-password",children:s.confirmNewPassword}),e.jsxs("div",{className:"relative",children:[e.jsx(fe,{id:"confirm-password",name:"confirm-password",type:De?"text":"password",autoComplete:"new-password",value:ce,onChange:a=>Ae(a.target.value),placeholder:s.confirmPasswordPlaceholder,className:"pr-10","data-testid":"input-confirm-password"}),e.jsx("button",{type:"button",className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",onClick:a=>{a.preventDefault(),a.stopPropagation(),m(d=>!d)},tabIndex:-1,"aria-label":De?t.hidePassword:t.showPassword,"data-testid":"button-toggle-confirm-password",children:De?e.jsx(ls,{className:"h-4 w-4"}):e.jsx(ds,{className:"h-4 w-4"})})]}),ce&&T!==ce&&e.jsx("p",{className:"text-sm text-destructive",children:s.passwordsDoNotMatch})]})]}),e.jsx(f,{type:"submit",disabled:Ve.isPending||!Y||T.length<8||!/[A-Z]/.test(T)||!/[a-z]/.test(T)||!/[0-9]/.test(T)||!/[^A-Za-z0-9]/.test(T)||T!==ce,"data-testid":"button-change-password",children:Ve.isPending?s.changingPassword:s.changePassword})]})})]}),e.jsx(Ba,{}),e.jsxs(V,{className:"border-destructive/50",children:[e.jsxs(z,{children:[e.jsxs(G,{className:"flex items-center gap-2 text-destructive",children:[e.jsx(ot,{className:"h-5 w-5"}),s.deleteAccount]}
18),e.jsx(B,{children:c!=null&&c.deletionScheduledFor?s.deleteAccountScheduled:s.deleteAccountPermanent})]}),e.jsx($,{className:"space-y-4",children:c!=null&&c.deletionScheduledFor?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"rounded-lg bg-amber-500/10 border border-amber-500/30 p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Qs,{className:"h-5 w-5 text-amber-500"}),e.jsx("p",{className:"text-sm font-medium text-amber-600 dark:text-amber-400",children:s.deletionScheduledTitle})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[s.deletionScheduledOn," ",e.jsx("strong",{className:"text-foreground",children:new Date(c.deletionScheduledFor).toLocaleDateString(Ze,{day:"numeric",month:"long",year:"numeric"})})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s.deletionScheduledNote})]}),e.jsx(f,{onClick:()=>Ee.mutate(),disabled:Ee.isPending,"data-testid":"button-cancel-deletion",children:Ee.isPending?s.cancellingDeletion:s.cancelDeletion})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"rounded-lg bg-destructive/10 border border-destructive/20 p-4 space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-destructive",children:s.gracePeriod}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s.gracePeriodNote}),e.jsxs("ul",{className:"text-sm text-muted-foreground list-disc list-inside space-y-1",children:[e.jsx("li",{children:s.deleteDataItem1}),e.jsx("li",{children:s.deleteDataItem2}),e.jsx("li",{children:s.deleteDataItem3}),e.jsx("li",{children:s.deleteDataItem4}),e.jsx("li",{children:s.deleteDataItem5})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{htmlFor:"delete-password",children:s.enterPasswordToConfirm}),e.jsxs("div",{className:"relative",children:[e.jsx(fe,{id:"delete-password",type:be?"text":"password",value:w,onChange:a=>Se(a.target.value),placeholder:s.enterYourPassword,className:"pr-10","data-testid":"input-delete-password"}),e.jsx("button",{type:"button",className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",onClick:()=>ks(!be),"data-testid":"button-toggle-delete-password",children:be?e.jsx(ls,{className:"h-4 w-4"}):e.jsx(ds,{className:"h-4 w-4"})})]})]}),e.jsxs(Sa,{open:Ue,onOpenChange:Me,children:[e.jsx(ka,{asChild:!0,children:e.jsxs(f,{variant:"destructive",disabled:!w||Te.isPending,"data-testid":"button-delete-account",children:[e.jsx(ot,{className:"h-4 w-4 mr-2"}),s.scheduleAccountDeletion]})}),e.jsxs(Ta,{children:[e.jsxs(Pa,{children:[e.jsx(Aa,{children:s.scheduleAccountDeletionTitle}),e.jsx(Da,{children:s.scheduleAccountDeletionDesc})]}),e.jsxs(Ea,{children:[e.jsx(Ia,{"data-testid":"button-cancel-delete",children:t.cancel}),e.jsx(La,{onClick:ft,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",disabled:Te.isPending,"data-testid":"button-confirm-delete",children:Te.isPending?s.schedulingDeletion:s.yesScheduleDeletion})]})]})]})]})})]})]}),e.jsxs(ts,{value:"experience",className:"space-y-4 sm:space-y-6 mt-4 sm:mt-6",children:[e.jsxs(V,{"data-testid":"card-appearance",children:[e.jsxs(z,{children:[e.jsxs(G,{className:"flex items-center gap-2",children:[e.jsx(lt,{className:"h-5 w-5"}),s.appearanceCard]}),e.jsx(B,{children:s.appearanceCardDesc})]}),e.jsx($,{children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(S,{className:"text-sm font-medium",children:r.darkMode}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.darkModeDesc})]}),e.jsx(ee,{checked:g==="dark",onCheckedChange:()=>j(),"data-testid":"switch-dark-mode"})]})})]}),e.jsxs(V,{"data-testid":"card-display-preferences",children:[e.jsxs(z,{children:[e.jsxs(G,{className:"flex items-center gap-2",children:[e.jsx(dt,{className:"h-5 w-5"}),s.cardDisplayPreferences]}),e.jsx(B,{children:s.cardDisplayPreferencesDesc})]}),e.jsxs($,{className:"space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{className:"text-sm font-medium",children:s.cardLayout}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.cardLayoutDesc}),e.jsx("div",{className:"flex gap-1",children:["extended","compact"].map(a=>e.jsx(f,{size:"sm",variant:M.cardLayout===a?"default":"outline",className:"flex-1",onClick:()=>ae({cardLayout:a}),"data-testid":`button-layout-${a}`,children:a==="extended"?s.layoutExtended:s.layoutCompact},a))})]}),e.jsx(Is,{}),M.cardLayout!=="compact"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{className:"text-sm font-medium",children:s.cardExcerpt}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.cardExcerptDesc}),e.jsx("div",{className:"flex gap-1",children:["none","partial","full"].map(a=>e.jsx(f,{size:"sm",variant:M.cardExcerpt===a?"default":"outline",className:"flex-1",onClick:()=>ae({cardExcerpt:a}),"data-testid":`button-excerpt-${a}`,children:a==="none"?s.excerptNone:a==="partial"?s.excerptParti
18al:s.excerptFull},a))})]}),e.jsx(Is,{}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(S,{htmlFor:"dp-reading-time",className:"text-sm font-medium cursor-pointer",children:s.readingTime}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.readingTimeDesc})]}),e.jsx(ee,{id:"dp-reading-time",checked:M.showReadingTime,onCheckedChange:a=>ae({showReadingTime:a}),"data-testid":"switch-dp-reading-time"})]})]}),(u.langEnglish,u.langBritishEnglish,u.langFrench,u.langSpanish,u.langGerman,u.langArabic,u.langGreek,u.langHindi,u.langIndonesian,u.langItalian,u.langJapanese,u.langKorean,u.langMalay,u.langMandarin,u.langPolish,u.langPortuguese,u.langRussian,u.langTagalog,u.langThai,u.langTurkish,u.langVietnamese,e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(S,{htmlFor:"dp-english-title",className:"text-sm font-medium cursor-pointer",children:s.nativeTitle}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.nativeTitleDescription})]}),e.jsx(ee,{id:"dp-english-title",checked:M.showEnglishTitle,onCheckedChange:a=>ae(a?{showEnglishTitle:!0}:{showEnglishTitle:!1,englishTitleFirst:!1}),"data-testid":"switch-dp-english-title"})]}),M.showEnglishTitle&&e.jsxs("div",{className:"flex items-center justify-between gap-4 pl-4 border-l-2 border-border",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(S,{htmlFor:"dp-english-title-first",className:"text-sm font-medium cursor-pointer",children:s.nativeTitleFirst}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.nativeTitleFirstDescription})]}),e.jsx(ee,{id:"dp-english-title-first",checked:M.englishTitleFirst,onCheckedChange:a=>ae({englishTitleFirst:a}),"data-testid":"switch-dp-english-title-first"})]})]})),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(S,{htmlFor:"dp-card-date",className:"text-sm font-medium cursor-pointer",children:s.publishedDate}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.publishedDateDesc})]}),e.jsx(ee,{id:"dp-card-date",checked:M.showCardDate,onCheckedChange:a=>ae({showCardDate:a}),"data-testid":"switch-dp-card-date"})]}),e.jsx(Is,{}),e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 space-y-0.5",children:[e.jsx(S,{htmlFor:"dp-date-format",className:"text-sm font-medium",children:s.dateFormatLabel}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.dateFormatDesc})]}),e.jsxs(js,{value:M.dateFormat,onValueChange:a=>ae({dateFormat:a}),children:[e.jsx(ys,{id:"dp-date-format",className:"w-40 shrink-0","data-testid":"select-date-format",children:e.jsx(vs,{})}),e.jsx(bs,{children:Qt.map(a=>e.jsxs(as,{value:a.value,"data-testid":`option-date-format-${a.value}`,children:[e.jsx("span",{children:Yt(a.value,s)}),e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:Jt(a.value,Ze)})]},a.value))})]})]}),e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 space-y-0.5",children:[e.jsx(S,{htmlFor:"dp-timezone",className:"text-sm font-medium",children:s.timezone}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.timezoneDesc})]}),e.jsxs(js,{value:M.timezone,onValueChange:a=>ae({timezone:a}),children:[e.jsx(ys,{id:"dp-timezone",className:"w-40 shrink-0","data-testid":"select-timezone",children:e.jsx(vs,{})}),e.jsxs(bs,{children:[!et.find(a=>a.value===M.timezone)&&e.jsx(as,{value:M.timezone,children:M.timezone}),et.map(a=>e.jsx(as,{value:a.value,"data-testid":`option-timezone-${a.value}`,children:Zt(a.value,s)},a.value))]})]})]})]})]}),e.jsxs(V,{"data-testid":"card-haptics-settings",children:[e.jsxs(z,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ws,{className:"h-5 w-5"}),e.jsx(G,{children:s.hapticFeedback})]}),e.jsx(B,{children:s.hapticFeedbackDesc})]}),e.jsx($,{children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(S,{htmlFor:"haptics-enabled",className:"text-sm font-medium",children:s.enableHapticFeedback}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s.hapticFeedbackNote})]}),e.jsx(ee,{id:"haptics-enabled",checked:(c==null?void 0:c.hapticsEnabled)??!1,onCheckedChange:a=>{R("PATCH","/api/user/profile",{hapticsEnabled:a}).then(()=>oe.invalidateQueries({queryKey:["/api/auth/me"]})).catch(()=>x({title:t.failedToSave,variant:"destructive"}))},"data-testid":"switch-haptics-enabled"})]})})]})]})]})]})})}export{An as StudyReminderCard,en as StudyReminderContent,Dn as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.