import{a as g,u as T,r as d,j as e,B as l,e as L,o as N,l as P,m as _,n as B}from"./index-Daq5M5bC.js";import{L as M,C as p,d as h,a as O,b as R,S as z,c as D}from"./logo-NAd285bv.js";import{u as q,b as G,T as V,B as y,c as $,P as F,A as H,a as W,C as u,S as Q,Z}from"./usage-format-CNuTCnK-.js";import{p as Y,s as o,q as J,r as K,m as X,o as ee,U as se,L as ae}from"./user-status-C4MB9Ruf.js";import{T as te}from"./index-CTnVPfHU.js";import"./index-B33Yn3RC.js";import{S as v}from"./settings-qFuUALDY.js";/**
 * @license lucide-react v0.511.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const re=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]],ne=g("book-open",re);/**
 * @license lucide-react v0.511.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ie=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],w=g("circle-alert",ie);/**
 * @license lucide-react v0.511.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ce=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],le=g("power",ce);function oe(){const{t:s}=T(),x=Y(o),{user:n}=x,{plan:t}=q(!!n,o),{usage:r}=G(!!n,o),[i,b]=d.useState(null),[m,k]=d.useState(!0),[C,j]=d.useState(!0);d.useEffect(()=>{(async()=>{try{const c=await L(),I=c.aiServers.some(U=>U.isDefault);b(I),j(c.extensionEnabled??!0)}catch(c){console.error("Failed to check AI configuration:",c),b(!1)}finally{k(!1)}})()},[]);const f=()=>{N.tabs.create({url:"/options.html"})},S=()=>{N.tabs.create({url:"/vocabulary.html"})},A=async()=>{try{const a=await o("ACQUIRE_LANGUAGE:AUTH_SIGN_OUT",{},"background");a!=null&&a.success||console.error((a==null?void 0:a.error)||"Sign out failed")}catch(a){console.error((a==null?void 0:a.message)||"Sign out failed")}finally{await x.refreshUser()}},E=async a=>{j(a);try{await P({extensionEnabled:a})}catch(c){console.error("Failed to save extension enabled setting:",c)}};return e.jsx(te,{children:e.jsxs("div",{className:"w-80 min-h-96 bg-gradient-to-b from-background to-muted/20 relative",children:[e.jsx("div",{className:"scanline absolute inset-0 pointer-events-none z-0"}),e.jsx("header",{className:"border-b bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60 relative z-10",children:e.jsxs("div",{className:"flex h-14 items-center justify-between px-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(M,{}),e.jsx("h1",{className:"text-lg font-bold tracking-tight gradient-text tech-glow",children:s("common.appName","DeepAcquire")})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(V,{})})]})}),e.jsxs("main",{className:"p-4 space-y-4 relative z-10",children:[e.jsx(p,{className:"card-glow gradient-border hover-lift",children:e.jsx(h,{className:"py-4",children:n?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3 justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-primary/10 flex items-center justify-center border border-primary/20",title:n.email||n.name||"User",children:e.jsx(J,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"flex flex-col truncate",children:[e.jsx("span",{className:"text-xs font-medium truncate max-w-[120px]",children:n.email||n.name||"User"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:s(`subscription.${t}`,t==="free"?"Member":t)})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(y,{variant:t==="free"?"secondary":"default",className:t==="premium"?"bg-amber-500 hover:bg-amber-600 text-white text-[10px] px-1.5 py-0":t==="pro"?"bg-blue-500 hover:bg-blue-600 text-white text-[10px] px-1.5 py-0":"text-[10px] px-1.5 py-0",children:s(`subscription.${t}`,t)}),e.jsx(l,{variant:"ghost",size:"icon",onClick:A,title:s("auth.signOut","Sign Out"),className:"h-7 w-7 flex-shrink-0 text-muted-foreground hover:text-destructive",children:e.jsx(K,{className:"h-3.5 w-3.5"})})]})]}),(r==null?void 0:r.shared)&&r.shared.limit>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-[10px] text-muted-foreground",children:[e.jsx("span",{children:s("subscription.aiUsage","AI Usage")}),e.jsx("span",{children:$(r.shared,"credits",s("subscription.unlimited","Unlimited"))})]}),r.shared.limit!==-1&&e.jsx(F,{value:Math.min(r.shared.used/r.shared.limit*100,100),className:"h-1.5"})]}),t==="free"&&e.jsxs(l,{size:"sm",className:"w-full h-7 text-xs",onClick:()=>{o("ACQUIRE_LANGUAGE:OPEN_WEBSITE",{returnTo:ee.pricing},"background").catch(()=>{})},children:[e.jsx(X,{className:"h-3 w-3 mr-1"}),s("subscription.upgradeToPro","Upgrade to Pro")]})]}):e.jsx(se,{auth:x,plan:t,showToast:!1})})}),!m&&!i&&e.jsxs(H,{className:"border-amber-200 bg-amber-50 dark:border-amber-800 dark:bg-amber-950",children:[e.jsx(w,{className:"h-4 w-4 text-amber-600 dark:text-amber-400"}),e.jsx(W,{className:"text-sm text-amber-800 dark:text-amber-200",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{children:s("popup.aiNeedsConfig","AI features require configuration to get contextual word analysis.")}),e.jsxs(l,{onClick:f,size:"sm",variant:"outline",className:"h-7 px-2 text-xs border-amber-300 hover:border-amber-400",children:[e.jsx(v,{className:"h-3 w-3 mr-3"}),s("popup.configureAI","Configure AI")]})]})})]}),e.jsxs(p,{className:"card-glow gradient-border hover-lift",children:[e.jsxs(O,{className:"pb-3",children:[e.jsxs(R,{className:"text-lg flex items-center gap-2 text-primary tech-glow",children:[e.jsx(z,{className:"h-5 w-5"}),i?s("popup.ready","Ready to Learn!"):s("popup.welcome","Welcome Learning!")]}),e.jsx(D,{children:i?s("popup.configuredDesc","Your AI is configured. Enjoy enhanced learning features!"):s("popup.learnDesc","Learn languages naturally by watching videos")})]}),!m&&e.jsx(h,{className:"pt-0",children:e.jsxs("div",{className:"text-xs text-muted-foreground space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(u,{className:"h-3 w-3 text-green-500"}),e.jsx("span",{children:s("popup.enhancedSubtitles","Enhanced subtitles")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(u,{className:"h-3 w-3 text-green-500"}),e.jsx("span",{children:s("popup.dictionaryLookup","Dictionary lookup")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[i?e.jsx(u,{className:"h-3 w-3 text-green-500"}):e.jsx(w,{className:"h-3 w-3 text-amber-500"}),e.jsx("span",{children:s("popup.aiContext","AI contextual analysis")}),!i&&e.jsx(y,{variant:"outline",className:"text-xs py-0 px-1",children:s("popup.setupRequired","Setup required")})]})]})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(p,{className:"card-glow gradient-border hover-lift",children:e.jsx(h,{className:"py-4",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(le,{className:"h-4 w-4 text-primary"}),e.jsx("div",{children:e.jsx(ae,{htmlFor:"ext-enabled",className:"text-sm font-medium",children:s("popup.enableExtension","Enable extension")})})]}),e.jsx(Q,{id:"ext-enabled",checked:C,onCheckedChange:E})]})})}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs(l,{onClick:S,variant:"outline",className:"h-11 hover-lift gradient-border",children:[e.jsx(ne,{className:"mr-3 h-4 w-4"}),s("popup.vocabulary","Vocabulary")]}),e.jsxs(l,{onClick:f,variant:"outline",className:"h-11 hover-lift gradient-border",children:[e.jsx(v,{className:"mr-3 h-4 w-4"}),s("popup.settings","Settings"),!m&&!i&&e.jsx(Z,{className:"ml-1 h-3 w-3 text-amber-500"})]})]})]}),e.jsx("div",{className:"pt-2 text-center",children:e.jsx("p",{className:"text-xs text-muted-foreground",children:s("popup.footer","Make language learning more natural")})})]})]})})}_().finally(()=>{B.createRoot(document.getElementById("root")).render(e.jsx(d.StrictMode,{children:e.jsx(oe,{})}))});
