import"./_virtual_wxt-html-plugins-DPbbfBKe.js";import{j as e,r as i,d as B,l as C,a as W,f as E,b as r,B as w,t as T,R as U,h as R}from"./tailwind-BjeOSL3a.js";import{a as F,u as P,f as O}from"./useUpdateAvailable-Ffh8sE6h.js";function Y({updateState:p,actionLabel:c}){return e.jsxs("button",{onClick:o=>{o.stopPropagation(),F()},style:{display:"flex",alignItems:"center",justifyContent:"center",gap:6,width:"100%",padding:"7px 12px",background:"linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%)",borderBottom:"1px solid #fde68a",border:"none",borderBlockEnd:"1px solid #fde68a",fontSize:12,lineHeight:"16px",cursor:"pointer",transition:"background 150ms ease"},onMouseEnter:o=>{o.currentTarget.style.background="linear-gradient(135deg, #fef3c7 0%, #fde68a 100%)"},onMouseLeave:o=>{o.currentTarget.style.background="linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%)"},children:[e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"#b47818",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[e.jsx("path",{d:"m16 6-4-4-4 4"}),e.jsx("path",{d:"M12 2v8"}),e.jsx("rect",{x:"2",y:"14",width:"20",height:"8",rx:"2"})]}),e.jsx("span",{style:{color:"#92400e",fontWeight:600,fontSize:11,letterSpacing:"0.01em"},children:c}),e.jsxs("span",{style:{color:"#b47818",fontSize:10,fontWeight:500},children:["v",p.version]})]})}const $=`
.sl-popup {
  --ink: #1c1814;
  --ink-soft: #3d342c;
  --ink-muted: #6b5e54;
  --muted: #9a8d80;
  --paper: #f4eedf;
  --paper-card: #fefbf3;
  --line: #e6dcc4;
  --line-soft: #efe7d3;
  --accent: #b47818;
  --accent-bright: #d4950c;
  --accent-soft: #f6ecd2;
  --accent-deep: #8a5a0d;
  --rust: #a4421b;
  --moss: #5e6e3a;

  --font-display: 'Fraunces', 'Noto Serif SC', Georgia, serif;
  --font-italic: 'Instrument Serif', Georgia, serif;
  --font-sans: 'Geist', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  width: 304px;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--paper);
  background-image:
    radial-gradient(at 100% 0%, rgba(212, 149, 12, 0.08) 0%, transparent 55%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 220 220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/><feColorMatrix values='0 0 0 0 0.11  0 0 0 0 0.09  0 0 0 0 0.06  0 0 0 0.04 0'/></filter><rect width='220' height='220' filter='url(%23n)'/></svg>");
  background-size: auto, 220px 220px;
  position: relative;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'ss01', 'cv11';
}

.sl-popup *, .sl-popup *::before, .sl-popup *::after { box-sizing: border-box; }

.sl-popup-content {
  position: relative;
  z-index: 1;
  padding: 16px 18px 14px;
}

.sl-popup-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sl-popup-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.sl-popup-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
  transition: color 180ms ease, background 180ms ease, transform 240ms cubic-bezier(0.16, 0.84, 0.3, 1);
}
.sl-popup-icon:hover {
  color: var(--accent);
  background: var(--accent-soft);
}
.sl-popup-icon-gear:hover { transform: rotate(28deg); }
.sl-popup-icon-shot:hover { transform: translateY(-1px); }

.sl-popup-user,
.sl-popup-login {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  padding: 0;
  background: transparent;
  border: none;
  text-align: left;
}
.sl-popup-login { cursor: pointer; }

.sl-popup-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  color: var(--paper-card);
  background: linear-gradient(135deg, var(--accent-bright) 0%, var(--accent-deep) 100%);
  letter-spacing: 0.01em;
  text-transform: uppercase;
  overflow: hidden;
}
.sl-popup-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sl-popup-login-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--paper-card);
  border: 1px solid var(--line);
  color: var(--ink-muted);
  transition: color 180ms ease, border-color 180ms ease, background 180ms ease;
}
.sl-popup-login:hover .sl-popup-login-icon {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.sl-popup-user-info {
  min-width: 0;
  flex: 1;
}

.sl-popup-name-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.sl-popup-name {
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.005em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sl-popup-plan {
  font-family: var(--font-mono);
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  flex-shrink: 0;
  line-height: 1;
}
.sl-popup-plan-free { color: var(--muted); }
.sl-popup-plan-pro {
  color: var(--accent);
  background: linear-gradient(90deg, var(--accent-bright), var(--accent-deep));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sl-popup-email {
  margin-top: 1px;
  font-family: var(--font-italic);
  font-style: italic;
  font-size: 11.5px;
  color: var(--ink-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: 0.005em;
}

.sl-popup-login-title {
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.005em;
}
.sl-popup-login-desc {
  margin-top: 1px;
  font-family: var(--font-italic);
  font-style: italic;
  font-size: 11.5px;
  color: var(--ink-muted);
  letter-spacing: 0.005em;
}

.sl-popup-divider {
  height: 1px;
  margin: 14px 0 12px;
  background: linear-gradient(to right, transparent, var(--line), transparent);
}

.sl-popup-translate {
  position: relative;
  width: 100%;
  border: none;
  padding: 0;
  background: transparent;
  cursor: pointer;
  outline: none;
}
.sl-popup-translate:disabled { cursor: wait; }

.sl-popup-translate-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.005em;
  transition: background 220ms ease, transform 220ms cubic-bezier(0.16, 0.84, 0.3, 1);
}
.sl-popup-translate:hover:not(:disabled) .sl-popup-translate-inner {
  background: #2a221a;
  transform: translateY(-1px);
}
.sl-popup-translate:active:not(:disabled) .sl-popup-translate-inner {
  transform: translateY(0);
}

.sl-popup-translate-active .sl-popup-translate-inner {
  background: var(--rust);
  color: var(--paper);
}
.sl-popup-translate-active:hover:not(:disabled) .sl-popup-translate-inner {
  background: #b8451c;
}

.sl-popup-status {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--moss);
}

.sl-popup-status-engine {
  position: relative;
  padding-left: 9px;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--ink-muted);
  word-break: break-word;
}
.sl-popup-status-engine::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 8px;
  width: 1px;
  background: var(--line);
}

.sl-popup-status-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--moss);
  animation: sl-popup-pulse 1.6s ease-in-out infinite;
}
@keyframes sl-popup-pulse {
  0%, 100% { opacity: 0.5; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.15); }
}

.sl-popup-links {
  display: flex;
  align-items: stretch;
  gap: 0;
  border-top: 1px solid var(--line);
}

.sl-popup-link {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 4px 4px;
  color: var(--ink-soft);
  text-decoration: none;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: color 180ms ease;
}
.sl-popup-link + .sl-popup-link {
  margin-left: 16px;
  position: relative;
}
.sl-popup-link + .sl-popup-link::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 14px;
  bottom: 6px;
  width: 1px;
  background: var(--line);
}
.sl-popup-link svg {
  color: var(--muted);
  transition: color 180ms ease, transform 220ms cubic-bezier(0.16, 0.84, 0.3, 1);
}
.sl-popup-link:hover { color: var(--accent); }
.sl-popup-link:hover svg {
  color: var(--accent);
  transform: translate(2px, -2px);
}

.sl-popup-spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid rgba(244, 238, 223, 0.3);
  border-top-color: var(--paper);
  animation: sl-popup-spin 0.8s linear infinite;
}
@keyframes sl-popup-spin {
  to { transform: rotate(360deg); }
}
`;function q(){var b;const[p,c]=i.useState(!1),[o,g]=i.useState(null),[d,u]=i.useState(!0),[k,j]=i.useState(B.nativeLanguage),[t,h]=i.useState(null),x=P();i.useEffect(()=>(C().then(a=>{j(a.nativeLanguage)}),W().then(h),E(h)),[]),i.useEffect(()=>{r.tabs.query({active:!0,currentWindow:!0}).then(a=>{var l;(l=a[0])!=null&&l.id?r.tabs.sendMessage(a[0].id,{type:"get-translate-status"}).then(s=>{c((s==null?void 0:s.isTranslating)??!1),g((s==null?void 0:s.engine)??null),u(!1)}).catch(()=>{u(!1)}):u(!1)})},[]);const y=async()=>{var l;const a=await r.tabs.query({active:!0,currentWindow:!0});if((l=a[0])!=null&&l.id){const s=await r.tabs.sendMessage(a[0].id,{type:"toggle-page-translate"});c((s==null?void 0:s.isTranslating)??!1),g((s==null?void 0:s.engine)??null)}},N=()=>{r.tabs.create({url:r.runtime.getURL("/options.html")}),window.close()},L=()=>{r.runtime.sendMessage({type:"open-authorization-page"}),window.close()},M=async()=>{await r.runtime.sendMessage({type:"start-screenshot-ocr"}),window.close()},n=a=>T(a,k),f=t!=null&&t.image?t.image.startsWith("http")?t.image:`${w}${t.image}`:null,m=(t==null?void 0:t.name)||(t==null?void 0:t.email)||"",S=((b=m[0])==null?void 0:b.toUpperCase())||"?",v=(t==null?void 0:t.plan)==="pro",z=(t==null?void 0:t.extensionPlan)==="max"?"Max":v?"Pro":"Free";return e.jsxs("div",{className:"sl-popup",children:[e.jsx("style",{children:$}),x&&e.jsx("div",{style:{position:"relative",zIndex:2},children:e.jsx(Y,{updateState:x,actionLabel:n("update.action")})}),e.jsxs("div",{className:"sl-popup-content",children:[e.jsxs("div",{className:"sl-popup-head",children:[t!=null&&t.token?e.jsxs("div",{className:"sl-popup-user",children:[e.jsx("div",{className:"sl-popup-avatar",children:f?e.jsx("img",{src:f,alt:""}):S}),e.jsxs("div",{className:"sl-popup-user-info",children:[e.jsxs("div",{className:"sl-popup-name-row",children:[e.jsx("span",{className:"sl-popup-name",children:m}),e.jsx("span",{className:`sl-popup-plan ${v?"sl-popup-plan-pro":"sl-popup-plan-free"}`,children:z})]}),t.name&&t.email&&e.jsx("p",{className:"sl-popup-email",children:t.email})]})]}):e.jsxs("button",{type:"button",className:"sl-popup-login",onClick:L,children:[e.jsx("span",{className:"sl-popup-login-icon",children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"}),e.jsx("circle",{cx:"12",cy:"7",r:"4"})]})}),e.jsxs("div",{style:{minWidth:0,flex:1},children:[e.jsx("div",{className:"sl-popup-login-title",children:n("popup.login")}),e.jsx("div",{className:"sl-popup-login-desc",children:n("popup.loginDesc")})]})]}),e.jsxs("div",{className:"sl-popup-actions",children:[e.jsx("button",{type:"button",className:"sl-popup-icon sl-popup-icon-shot",onClick:M,title:n("popup.screenshot"),"aria-label":n("popup.screenshot"),children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3Z"}),e.jsx("circle",{cx:"12",cy:"13",r:"3"})]})}),e.jsx("button",{type:"button",className:"sl-popup-icon sl-popup-icon-gear",onClick:N,title:n("popup.settings"),"aria-label":n("popup.settings"),children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]})})]})]}),e.jsx("div",{className:"sl-popup-divider"}),e.jsx("button",{type:"button",onClick:y,disabled:d,className:`sl-popup-translate ${p?"sl-popup-translate-active":""}`,children:e.jsxs("div",{className:"sl-popup-translate-inner",children:[d?e.jsx("span",{className:"sl-popup-spinner","aria-hidden":!0}):p?e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1.5"})}):e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"m5 8 6 6"}),e.jsx("path",{d:"m4 14 6-6 2-3"}),e.jsx("path",{d:"M2 5h12"}),e.jsx("path",{d:"M7 2h1"}),e.jsx("path",{d:"m22 22-5-10-5 10"}),e.jsx("path",{d:"M14 18h6"})]}),e.jsx("span",{children:d?"":n(p?"popup.stopTranslate":"popup.translatePage")})]})}),p&&!d&&e.jsxs("div",{className:"sl-popup-status",children:[e.jsx("span",{className:"sl-popup-status-dot","aria-hidden":!0}),e.jsx("span",{children:n("popup.translationEnabled")}),o&&e.jsx("span",{className:"sl-popup-status-engine",children:O(o,n)})]}),e.jsx("div",{style:{height:16}}),e.jsxs("div",{className:"sl-popup-links",children:[e.jsxs("a",{href:"https://starrylingo.com/favorites",target:"_blank",rel:"noopener noreferrer",className:"sl-popup-link",children:[e.jsx("span",{children:n("popup.wordBook")}),e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M7 17 17 7"}),e.jsx("path",{d:"M7 7h10v10"})]})]}),e.jsxs("a",{href:w,target:"_blank",rel:"noopener noreferrer",className:"sl-popup-link",children:[e.jsx("span",{children:n("popup.visitWebsite")}),e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M7 17 17 7"}),e.jsx("path",{d:"M7 7h10v10"})]})]})]})]})]})}U.createRoot(document.getElementById("root")).render(e.jsx(R.StrictMode,{children:e.jsx(q,{})}));
