PageSourceSearch

https://aimangatranslator.app/assets/tools-panel-DB_L7N-H.js

js aimangatranslator.app collected 2026-10-05 06:05:11 UTC 32,402 bytes, 2 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/pdf-to-images-5eGVeyWx.js","assets/index-B4-xBY2L.js","assets/rolldown-runtime-QTnfLwEv.js","assets/framework-DJH1pfSr.js","assets/url-utils-BQKFb685.js"])))=>i.map(i=>d[i]);
2import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,n,r}from"./framework-DJH1pfSr.js";import{t as i}from"./index-B4-xBY2L.js";import{t as a}from"./react-client-CAjdHkmk.js";import{c as o}from"./client-CmOHgZho.js";import{t as s}from"./navigation-DK41M7fL.js";import{t as c}from"./utils-DXalBF5w.js";import{i as l,n as u,t as d,u as f}from"./dropdown-menu-CAJmqdJi.js";import{t as p}from"./createLucideIcon-BRWvWrMn.js";import{t as m}from"./check-CX-FwU1S.js";import{t as h}from"./chevron-down-B1vai0Li.js";import{t as g}from"./external-link-Dl8IwxXX.js";import{t as ee}from"./eye-T6E8AKtT.js";import{t as _}from"./loader-circle-Cxy4jRlv.js";import{t as v}from"./sparkles-DoLysNxV.js";import{t as y}from"./x-ChR1JV_j.js";import{t as te}from"./switch-DdlfWtIJ.js";import{v as b}from"./promo-D7H9JO13.js";import{t as ne}from"./use-promo-countdown-Jjc7A-Gz.js";import{a as x,i as re}from"./track-BUg7VPxk.js";import{n as ie}from"./auth-modal-provider-DuyXTIp9.js";import{n as S,r as ae,t as C}from"./pricing-Bj9eNs_o.js";var w=p(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),T=e(t(),1),oe=e(n(),1),E=r(),se=[`basic_monthly`,`pro_monthly`,`basic_credits`,`pro_credits`];function D({open:e,onClose:t,title:n,subtitle:r,offerIds:i=se,ctaLabel:s,signInLabel:l,loadingLabel:u=`…`,note:d}){let f=(0,T.useId)(),p=a(`landing.promo`),{data:m}=o(),{openAuth:h}=ie(),[g,ee]=(0,T.useState)(!1),[te,b]=(0,T.useState)(null),[w,D]=(0,T.useState)(null),O=ne(e);if((0,T.useEffect)(()=>ee(!0),[]),(0,T.useEffect)(()=>{if(!e)return;x(`pricing_view`,{source:`paywall`});let n=e=>{e.key===`Escape`&&t()};window.addEventListener(`keydown`,n);let r=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{window.removeEventListener(`keydown`,n),document.body.style.overflow=r}},[e,t]),!g||!e)return null;let ce=i.map(e=>C(e)).filter(e=>!!e),le=ce.length>0?ce:S().filter(e=>[`basic_monthly`,`pro_monthly`,`basic_credits`].includes(e.productId));async function ue(e){if(D(null),x(`plan_select`,{plan:e,source:`paywall`}),!m?.user){x(`feature_gate_hit`,{feature:`checkout`,source:`paywall`}),t(),h({mode:`sign-in`,callbackUrl:`/#tools`,source:`paywall`});return}b(e);try{let t=C(e),n=typeof t?.priceInCents==`number`?t.priceInCents/100:void 0,r=(t?.currency||`usd`).toUpperCase(),i=await(await fetch(`/api/payment/checkout`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({product_id:e,payment_provider:`stripe`,redirect:`/?success=1#tools`})})).json();if(i.code===0&&i.data?.checkout_url){re({plan:e,payment_provider:`stripe`,source:`paywall`,revenue:n,currency:r}),x(`begin_checkout`,{plan:e,payment_provider:`stripe`,source:`paywall`,...typeof n==`
2number`?{revenue:n,currency:r}:{}}),window.location.href=i.data.checkout_url;return}D(i.message||`Checkout failed`)}catch(e){D(e?.message||`Checkout failed`)}finally{b(null)}}return(0,oe.createPortal)((0,E.jsxs)(`div`,{className:`fixed inset-0 z-[1200] flex items-end justify-center p-0 sm:items-center sm:p-4`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":f,children:[(0,E.jsx)(`button`,{type:`button`,className:`absolute inset-0 bg-[var(--amt-ink)]/50`,"aria-label":`Close`,onClick:t}),(0,E.jsxs)(`div`,{className:`relative z-10 w-full max-w-lg overflow-hidden border-[4px] border-[var(--amt-ink)] bg-[var(--amt-paper)] shadow-[8px_8px_0_0_var(--amt-ink)]`,children:[(0,E.jsxs)(`div`,{className:`relative border-b-[3px] border-[var(--amt-ink)] bg-[var(--amt-bg-elevated)] px-5 pt-5 pb-4 sm:px-6`,children:[(0,E.jsx)(`button`,{type:`button`,onClick:t,className:`absolute top-3 right-3 border-[2px] border-[var(--amt-ink)] bg-white p-1.5 text-[var(--amt-ink)] hover:bg-[var(--amt-paper)]`,"aria-label":`Close`,children:(0,E.jsx)(y,{className:`size-4`})}),(0,E.jsxs)(`p`,{className:`inline-flex items-center border-2 border-[var(--amt-accent)] bg-white px-2.5 py-0.5 text-[10px] font-bold tracking-[0.14em] text-[var(--amt-accent)] uppercase`,children:[p(`banner_badge`),` · `,p(`banner_limited`)]}),(0,E.jsx)(`h2`,{id:f,className:`amt-heading mt-2 max-w-[20rem] text-[20px] text-[var(--amt-ink)] uppercase sm:text-[22px]`,children:n}),(0,E.jsx)(`p`,{className:`mt-1.5 text-[13px] text-[var(--amt-text-muted)]`,children:r}),(0,E.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,E.jsx)(`span`,{className:`text-[10px] font-semibold tracking-wide text-[var(--amt-text-muted)] uppercase`,children:p(`popup_timer_label`)}),(0,E.jsx)(`div`,{className:`flex items-center gap-0.5`,children:[O.minutes,O.seconds,O.ms].map((e,t)=>(0,E.jsxs)(`span`,{className:`flex items-center gap-0.5`,children:[t>0&&(0,E.jsx)(`span`,{className:`text-xs font-bold text-[var(--amt-accent)]/70`,children:`:`}),(0,E.jsx)(`span`,{className:`inline-flex min-w-[28px] items-center justify-center border-2 border-[var(--amt-ink)] bg-[var(--amt-ink)] px-1.5 py-0.5 text-center text-xs font-bold text-white tabular-nums`,children:e})]},t))})]})]}),(0,E.jsxs)(`div`,{className:`flex flex-col gap-3 p-5`,children:[le.map((e,t)=>{let n=Math.floor(e.credits/10),r=`$${(e.priceInCents/100).toFixed(e.priceInCents%100==0?0:2)}`,i=e.type===ae.SUBSCRIPTION,a=e.plan?.interval===`year`?`/year`:e.plan?.interval===`month`?`/month`:``,o=te===e.productId,s=e.planName===`Pro`||!i&&t===0;return(0,E.jsxs)(`button`,{type:`button`,disabled:!!te,onClick:()=>void ue(e.productId),className:c(`relative flex w-full items-center justify-between gap-3 border-[3px] border-[var(--amt-ink)] bg-[var(--amt-bg-elevated)] px-4 py-3 text-left transition-transform`,`hover:-translate-y-0.5 hover:bg-white`,`disabled:cursor-wait disabled:opacity-70`,s&&`ring-2 ring-[var(--amt-accent)] ring-offset-1`),children:[s?(0,E.jsxs)(`span`,{className:`absolute -top-2.5 left-3 inline-flex items-center gap-1 border-2 border-[var(--amt-ink)] bg-[var(--amt-accent)] px-2 py-0.5 text-[9px] font-bold text-white uppercase`,children:[(0,E.jsx)(v,{className:`size-3`}),p(`banner_badge`)]}):null,(0,E.jsxs)(`div`,{className:`min-w-0`,children:[(0,E.jsxs)(`p`,{className:`amt-heading text-[15px] text-[var(--amt-ink)] uppercase`,children:[e.productName,i?` · ${a}`:` · pack`]}),(0,E.jsxs)(`p`,{className:`mt-0.5 text-[12px] text-[var(--amt-text-muted)]`,children:[n,` pages · `,e.credits,` credits`]})]}),(0,E.jsxs)(`span`,{className:`amt-btn-primary inline-flex h-9 shrink-0 items-center gap-1.5 px-3 text-[12px]`,children:[o?(0,E.jsx)(_,{className:`size-3.5 animate-spin`}):null,o?u:`${r}${a||``}`]})]},e.productId)}),w?(0,E.jsx)(`p`,{className:`text-[13px] text-[var(--mt-danger)]`,children:w}):null,m?.user?null:(0,E.jsx)(`button`,{type:`button`,onClick:()=>{t(),h({mode:`sign-in`,callbackUrl:`/`})},className:`amt-label text-center text-[12px] text-[var(--amt-accent)] underline`,children:l}),d?(0,E.jsx)(`p`,{className:`text-center text-[11px] text-[var(--amt-text-muted)]`,children:d}):null,(0,E.jsx)(`p`,{className:`sr-only`,children:s})]})]})]}),document.body)}var O=`application/pdf`,ce=3e3;function le(e){switch(e){case`uploading`:return 1;case`submitting`:return 2;case`processing`:return 3;case`success`:case`failed`:return 4}}function ue(e,t){switch(e){case`uploading`:return t.statusUploading;
2case`submitting`:return t.statusSubmitting;case`processing`:return t.statusProcessing;case`success`:return t.statusSuccess;case`failed`:return t.statusFailed}}function k({heading:e,fields:t,targetSlugs:n,credits:r,autoStartLabel:a,dropzone:p,action:v}){let{data:y,isPending:ne}=o(),{openAuth:re}=ie(),[S,ae]=(0,T.useState)(()=>Object.fromEntries(t.map(e=>[e.id,e.options[0]??``]))),[C,oe]=(0,T.useState)(!1),[se,k]=(0,T.useState)(!1),[A,j]=(0,T.useState)(null),[M,N]=(0,T.useState)(`idle`),[P,F]=(0,T.useState)(null),[I,L]=(0,T.useState)([]),[de,R]=(0,T.useState)(null),[fe,z]=(0,T.useState)([]),[pe,me]=(0,T.useState)(!1),[he,B]=(0,T.useState)(!1),[V,H]=(0,T.useState)(null),U=(0,T.useRef)(null),W=(0,T.useRef)(null),G=(0,T.useRef)(null),K=!ne&&!!y?.user,q=M===`preparing`||M===`running`,J=I.find(e=>e.localId===de)??I[I.length-1]??null,Y=J?le(J.phase):M===`done`?4:1,ge=fe.filter(e=>e.status===`success`&&e.resultImage||e.status===`processing`||e.status===`pending`||e.status===`failed`).slice(0,30),_e=ge.some(e=>e.status===`processing`||e.status===`pending`);function X(e,t){L(n=>n.map(n=>n.localId===e?{...n,...t}:n))}function Z(){W.current&&=(clearInterval(W.current),null)}async function Q(){if(!y?.user){z([]);return}me(!0);try{let e=await fetch(`/api/tasks`,{cache:`no-store`}),t=await e.json();if(e.status===401){z([]);return}if(t?.code!==0)return;z(t.data?.tasks||[])}catch{}finally{me(!1)}}async function $(){if(!y?.user)return H(null),0;try{let e=await(await fetch(`/api/credits`,{cache:`no-store`})).json();if(e?.code===0){let t=Number(e.data?.balance??0);return H(t),t}}catch{}return 0}async function ve(e=1){return y?.user?await $()<10*Math.max(1,e)?(x(`feature_gate_hit`,{feature:`credits`,source:`tools`}),B(!0),F(v.needCredits),!1):!0:(x(`feature_gate_hit`,{feature:`translate`,source:`tools`}),re({mode:`sign-in`,callbackUrl:`/#tools`,source:`tools`}),!1)}function ye(e){let t=`history-${e.id}`,n=e.status===`success`?`success`:e.status===`failed`?`failed`:(e.status===`pending`||e.status,`processing`);L([{localId:t,pageIndex:1,pageTotal:1,fileName:e.id.slice(0,8),targetLanguage:e.targetLanguage||`—`,targetSlug:e.targetLanguage||``,phase:n,taskId:e.id,sourceImage:e.sourceImage||void 0,resultImage:e.resultImage||void 0,credits:10}]),R(t),N(n===`success`?`done`:n===`failed`?`failed`:`running`),j(null),F(null),n===`processing`&&be([e.id]),document.getElementById(`tools`)?.scrollIntoView({behavior:`smooth`,block:`start`})}(0,T.useEffect)(()=>()=>Z(),[]),(0,T.useEffect)(()=>{K?(Q(),$()):(z([]),H(null))},[K]),(0,T.useEffect)(()=>{if(K&&!(!_e&&M!==`running`))return G.current=setInterval(()=>{Q()},4e3),()=>{G.current&&=(clearInterval(G.current),null)}},[K,_e,M]);function be(e){if(Z(),e.length===0)return;let t=async()=>{try{let e=await(await fetch(`/api/tasks`,{cache:`no-store`})).json();if(e?.code!==0)return;let t=e.data?.tasks||[],n=new Map(t.map(e=>[e.id,e]));L(e=>{let t=e.map(e=>{if(!e.taskId||e.phase===`success`||e.phase===`failed`)return e;let t=n.get(e.taskId);return t?t.status===`success`?(x(`translation_completed`,{pages:1}),{...e,phase:`success`,resultImage:t.resultImage||e.resultImage,sourceImage:t.sourceImage||e.sourceImage}):t.status===`failed`?(x(`translation_failed`,{error_code:`task_failed`}),{...e,phase:`failed`,error:v.failed}):{...e,phase:`processing`,sourceImage:t.sourceImage||e.sourceImage}:e});if(t.every(e=>!e.taskId||e.phase===`success`||e.phase===`failed`)){Z();let e=t.some(e=>e.phase===`failed`),n=t.some(e=>e.phase===`success`);N(e&&!n?`failed`:`done`),Q(),$(),n&&window.setTimeout(()=>b(`after_generate`),800)}return t})}catch{}};t(),W.current=setInterval(()=>void t(),ce)}async function xe(e,t,n,r,i){let a=`${Date.now()}-${n}-${Math.random().toString(36).slice(2,8)}`,o={localId:a,pageIndex:n,pageTotal:r,fileName:e.name,targetLanguage:i,targetSlug:t,phase:`uploading`,credits:10};L(e=>[...e,o]),R(a);let s=new FormData;s.append(`files`,e);let c=await fetch(`/api/storage/upload-image`,{method:`POST`,body:s});if(c.status===413){let e={...o,phase:`failed`,error:`Image is too large to upload (server limit). Try a smaller PNG/JPG under ~10MB.`};return X(a,e),e}let l=null;try{l=await c.json()}catch{let e={...o,phase:`failed`,error:c.ok?v.failed:`Upload failed (HTTP ${c.status}). Check storage config.`};return X(a,e),e}let u=l?.data?.urls?.[0];if(l?.code!==0||!u){let e={...o,phase:`failed`,error:l?.message||(c.ok?v.failed:`Upload failed (HTTP ${c.status})`)};return X(a,e),e}if(u.startsWith(`data:`)){let e={...o,phase:`failed`,error:`Storage (R2) is not configured — WaveSpeed needs a public image URL.`};return X(a,e),e}X(a,{phase:`submitting`,sourceImage:u}),x(`translation_started`,{page_index:n,page_total:r});let d=await(await fetch(`/api/translate`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({imageUrl:u,targetLanguage:t})})).json();if(d?.code!==0||!d?.data?.taskId){let e=String(d?.message||v.failed);/insufficient/i.test(e)?(x(`translation_failed`,{error_code:`insufficient`}),B(!0),F(v.needCredits)):x(`translation_failed`,{error_code:`submit_failed`});let t={...o,phase:`failed`,sourceImage:u,error:/insufficient/i.test(e)?v.needCredits:e||v.failed};return X(a,t),t}let f={...o,phase:`processing`,taskId:d.data.taskId,sourceImage:u};return X(a,f),f}async function Se(e){F(null),L([]),R(null),Z();let t=n[S.target];
2if(!t){F(v.unsupported);return}try{let n;if(e.type===O){N(`preparing`);let{pdfToImages:t}=await i(async()=>{let{pdfToImages:e}=await import(`./pdf-to-images-5eGVeyWx.js`);return{pdfToImages:e}},__vite__mapDeps([0,1,2,3,4]));if(n=await t(e),n.length===0){F(v.failed),N(`ready`);return}}else n=[e];if(!await ve(n.length)){N(`ready`);return}N(`running`);let r=[];for(let e=0;e<n.length;e++){e>0&&await new Promise(e=>setTimeout(e,1100));let i=await xe(n[e],t,e+1,n.length,S.target);if(r.push(i),i.phase===`failed`&&n.length===1){N(`failed`),F(i.error||v.failed);return}}let a=r.map(e=>e.taskId).filter(e=>!!e);if(a.length===0){N(`failed`),F(v.failed);return}be(a),Q()}catch{F(v.failed),N(`ready`)}}async function Ce(e){if(!e)return;let t=e.type.startsWith(`image/`),n=e.type===O;!t&&!n||(x(`image_uploaded`,{kind:n?`pdf`:`image`}),Z(),j(e),F(null),L([]),R(null),N(`ready`),await ve(1)&&C&&Se(e))}function we(){Z(),j(null),N(`idle`),F(null),L([]),R(null),U.current&&(U.current.value=``)}let Te=[{step:1,label:v.stepUpload,hint:v.stepUploadHint},{step:2,label:v.stepSubmit,hint:v.stepSubmitHint},{step:3,label:v.stepTranslate,hint:v.stepTranslateHint},{step:4,label:v.stepDone,hint:v.stepDoneHint}],Ee=M===`preparing`||M===`running`||M===`done`||M===`failed`||I.length>0;return(0,E.jsxs)(`section`,{id:`tools`,className:`relative w-full max-w-full scroll-mt-[calc(var(--amt-header-h)+16px)] overflow-hidden`,children:[(0,E.jsx)(`div`,{"aria-hidden":!0,className:`amt-grid-paper absolute inset-0 z-0`}),(0,E.jsx)(`div`,{"aria-hidden":!0,className:`amt-screentone absolute inset-0 z-0 opacity-20`}),(0,E.jsxs)(`div`,{className:`relative z-10 mx-auto max-w-[1200px] px-5 py-12 md:px-8 md:py-16`,children:[(0,E.jsx)(`div`,{className:`mb-[-2px] ml-2 self-start md:ml-4`,children:(0,E.jsx)(`span`,{className:`amt-ribbon`,children:e})}),(0,E.jsxs)(`div`,{className:`amt-ink-shadow border-8 border-dashed border-[var(--amt-ink)] bg-[var(--amt-paper)] p-6 md:p-8`,children:[(0,E.jsx)(`div`,{className:`mx-auto grid w-full max-w-[1136px] grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4`,children:t.map(e=>{let t=S[e.id]??e.options[0]??``;return(0,E.jsxs)(`div`,{className:`w-full`,children:[(0,E.jsx)(`span`,{id:`tools-${e.id}-label`,className:`amt-label mb-2 block text-[11px] text-[var(--amt-text-muted)]`,children:e.label}),(0,E.jsxs)(d,{children:[(0,E.jsxs)(f,{id:`tools-${e.id}`,"aria-labelledby":`tools-${e.id}-label`,disabled:q,className:c(`flex h-10 w-full items-center justify-between gap-2 border-[3px] border-[var(--amt-ink)] bg-[var(--amt-bg-elevated)] px-2 text-left text-[15px] text-[var(--amt-text)] outline-none`,`hover:bg-white focus-visible:bg-white data-popup-open:bg-white`,q&&`cursor-not-allowed opacity-60`),children:[(0,E.jsx)(`span`,{className:`min-w-0 truncate`,children:t}),(0,E.jsx)(h,{className:`size-4 shrink-0 text-[var(--amt-text-muted)]`,"aria-hidden":!0})]}),(0,E.jsx)(u,{align:`start`,sideOffset:4,className:`z-[1100] max-h-72 w-(--anchor-width) min-w-[var(--anchor-width)] rounded-none border-[3px] border-[var(--amt-ink)] bg-[var(--amt-paper)] p-1 shadow-[4px_4px_0_0_var(--amt-ink)]`,children:e.options.map(n=>{let r=n===t;return(0,E.jsxs)(l,{onClick:()=>ae(t=>({...t,[e.id]:n})),className:c(`amt-label flex cursor-pointer items-center justify-between gap-3 rounded-none px-3 py-2 text-[12px] text-[var(--amt-ink)]`,`focus:bg-[var(--amt-accent)] focus:text-white data-highlighted:bg-[var(--amt-accent)] data-highlighted:text-white`,r&&`bg-[var(--amt-bg-soft)] font-medium data-highlighted:bg-[var(--amt-accent)]`),children:[(0,E.jsx)(`span`,{className:`min-w-0 truncate`,children:n}),r?(0,E.jsx)(m,{className:`size-3.5 shrink-0`,"aria-hidden":!0}):null]},n)})})]})]},e.id)})}),(0,E.jsxs)(`div`,{className:`mx-auto mt-6 flex w-full max-w-[1136px] flex-col gap-3`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between gap-4 max-[374px]:flex-col max-[374px]:items-start max-[374px]:gap-2`,children:[(0,E.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1`,children:[(0,E.jsxs)(`div`,{className:`flex items-baseline gap-1.5`,children:[(0,E.jsx)(`span`,{className:`amt-label text-[10px] text-[var(--amt-text-muted)]`,children:v.availableLabel}),(0,E.jsx)(`span`,{className:`amt-heading text-[18px] text-[var(--amt-ink)]`,children:K&&V!==null?String(V):r.count}),(0,E.jsx)(`span`,{className:`text-[11px] text-[var(--amt-text-muted)]`,children:r.label.split(`/`)[0]?.trim()||r.label})]}),(0,E.jsx)(`div`,{className:`hidden h-4 w-px bg-[var(--amt-ink)]/20 sm:block`}),(0,E.jsxs)(`div`,{className:`flex items-baseline gap-1.5`,children:[(0,E.jsx)(`span`,{className:`amt-label text-[10px] text-[var(--amt-text-muted)]`,children:v.costLabel}),(0,E.jsx)(`span`,{className:`amt-heading text-[18px] text-[var(--amt-accent)]`,children:10}),(0,E.jsx)(`span`,{className:`text-[11px] text-[var(--amt-text-muted)]`,children:r.label})]}),K?null:(0,E.jsx)(`span`,{className:`text-[11px] text-[var(--amt-accent)]`,children:v.freeStartNote})]}),(0,E.jsxs)(`label`,{htmlFor:`tools-auto-start`,className:`flex cursor-pointer items-center gap-2 text-[13px] text-[var(--amt-text-muted)]`,children:[(0,E.jsx)(te,{id:`tools-auto-start`,checked:C,onCheckedChange:oe,size:`sm`,disabled:q}),a]})]}),(0,E.jsx)(`input`,{ref:U,type:`file`,accept:`image/*,application/pdf`,className:`hidden`,onChange:e=>Ce(e.target.files?.[0])}),Ee?(0,E.jsxs)(`div`,{className:`flex flex-col gap-4 border-[4px] border-[var(--amt-ink)] bg-[var(--amt-bg-elevated)] p-4 md:p-6`,children:[(0,E.jsx)(`ol`,{className:`grid grid-cols-2 gap-2 md:grid-cols-4 md:gap-3`,children:Te.map(e=>{let t=Y>e.step,n=Y===e.step&&M!==`done`,r=M===`failed`&&e.step===4&&Y===4;return(0,E.jsxs)(`li`,{className:c(`flex flex-col gap-1 border-[3px] border-[var(--amt-ink)] px-3 py-2`,t&&!r&&`bg-[var(--amt-accent)] text-white`,n&&`bg-[var(--amt-paper)] shadow-[3px_3px_0_0_var(--amt-ink)]`,!t&&!n&&`bg-[var(--amt-bg-soft)] opacity-70`,r&&`bg-[var(--mt-danger)]/10`),children:[(0,E.jsxs)(`span`,{className:`amt-label flex items-center gap-1.5 text-[11px] tracking-wide uppercase`,children:[t&&!r?(0,E.jsx)(m,{className:`size-3.5 shrink-0`,"aria-hidden":!0}):n&&M===`running`?(0,E.jsx)(_,{className:`size-3.5 shrink-0 animate-spin`,"aria-hidden":!0}):null,e.label]}),(0,E.jsx)(`span`,{className:c(`text-[11px] leading-snug`,t&&!r?`text-white/85`:`text-[var(--amt-text-muted)]`),children:e.hint})]},e.step)})}),(0,E.jsx)(`p`,{className:`amt-label text-[11px] text-[var(--amt-text-muted)]`,children:v.asyncNote}),M===`preparing`?(0,E.jsxs)(`div`,{className:`flex items-center gap-2 text-[14px] text-[var(--amt-ink)]`,children:[(0,E.jsx)(_,{className:`size-4 animate-spin`,"aria-hidden":!0}),v.preparing]}
2):null,(M===`running`||J?.phase===`processing`||J?.phase===`submitting`)&&M!==`done`&&M!==`failed`?(0,E.jsxs)(`div`,{className:`border-[3px] border-[var(--amt-ink)] bg-[var(--amt-bg-soft)] px-3 py-3 sm:px-4`,children:[(0,E.jsx)(`p`,{className:`amt-heading text-[13px] text-[var(--amt-ink)] uppercase`,children:v.waitUpsellTitle}),(0,E.jsx)(`p`,{className:`mt-1 text-[12px] leading-snug text-[var(--amt-text-muted)]`,children:v.waitUpsellBody}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>B(!0),className:`mt-2.5 inline-flex h-8 items-center border-2 border-[var(--amt-ink)] bg-[var(--amt-accent)] px-3 text-[11px] font-bold text-white uppercase shadow-[2px_2px_0_0_var(--amt-ink)] hover:brightness-110`,children:v.waitUpsellCta})]}):null,K&&V!==null&&V<10&&(M===`done`||M===`failed`||M===`ready`)?(0,E.jsxs)(`div`,{className:`border-[3px] border-[var(--amt-accent)] bg-[var(--amt-bg-elevated)] px-3 py-3`,children:[(0,E.jsx)(`p`,{className:`text-sm font-bold text-[var(--amt-ink)]`,children:v.continueBarTitle}),(0,E.jsxs)(`div`,{className:`mt-2.5 flex flex-wrap gap-2`,children:[(0,E.jsx)(`button`,{type:`button`,onClick:()=>B(!0),className:`flex-1 border-2 border-[var(--amt-ink)] bg-[var(--amt-accent)] px-3 py-2 text-xs font-bold text-white shadow-[2px_2px_0_0_var(--amt-ink)] hover:brightness-110`,children:v.continueBarBuy}),(0,E.jsx)(s,{href:`/pricing`,className:`border-2 border-[var(--amt-ink)] bg-white px-3 py-2 text-xs font-semibold text-[var(--amt-ink)] shadow-[2px_2px_0_0_var(--amt-ink)]`,children:v.continueBarPlans})]})]}):null,(0,E.jsxs)(`div`,{className:`border-[3px] border-[var(--amt-ink)] bg-[var(--amt-paper)]`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b-[3px] border-[var(--amt-ink)] px-3 py-2`,children:[(0,E.jsx)(`span`,{className:`amt-heading text-[14px] text-[var(--amt-ink)] uppercase`,children:v.taskDetail
2s}),I.length>1?(0,E.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:I.map(e=>(0,E.jsxs)(`button`,{type:`button`,onClick:()=>R(e.localId),className:c(`amt-label border-2 border-[var(--amt-ink)] px-2 py-0.5 text-[10px]`,e.localId===J?.localId?`bg-[var(--amt-accent)] text-white`:`bg-[var(--amt-bg-elevated)] text-[var(--amt-ink)]`),children:[v.taskPage,` `,e.pageIndex]},e.localId))}):null]}),J?(0,E.jsxs)(`div`,{className:`grid gap-4 p-3 md:grid-cols-2`,children:[(0,E.jsxs)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-2 text-[13px]`,children:[(0,E.jsx)(`dt`,{className:`amt-label text-[11px] text-[var(--amt-text-muted)]`,children:v.taskStatus}),(0,E.jsx)(`dd`,{className:`font-medium text-[var(--amt-ink)]`,children:ue(J.phase,v)}),(0,E.jsx)(`dt`,{className:`amt-label text-[11px] text-[var(--amt-text-muted)]`,children:v.taskId}),(0,E.jsx)(`dd`,{className:`truncate font-mono text-[12px] text-[var(--amt-ink)]`,children:J.taskId||`—`}),(0,E.jsx)(`dt`,{className:`amt-label text-[11px] text-[var(--amt-text-muted)]`,children:v.taskLanguage}),(0,E.jsx)(`dd`,{className:`text-[var(--amt-ink)]`,children:J.targetLanguage}),(0,E.jsx)(`dt`,{className:`amt-label text-[11px] text-[var(--amt-text-muted)]`,children:v.taskCredits}),(0,E.jsx)(`dd`,{className:`text-[var(--amt-ink)]`,children:J.credits}),J.pageTotal>1?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`dt`,{className:`amt-label text-[11px] text-[var(--amt-text-muted)]`,children:v.taskPage}),(0,E.jsxs)(`dd`,{className:`text-[var(--amt-ink)]`,children:[J.pageIndex,` / `,J.pageTotal]})]}):null,(0,E.jsx)(`dt`,{className:`amt-label text-[11px] text-[var(--amt-text-muted)]`,children:`File`}),(0,E.jsx)(`dd`,{className:`truncate text-[var(--amt-ink)]`,children:J.fileName}),J.error?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`dt`,{className:`amt-label text-[11px] text-[var(--mt-danger)]`,children:`Error`}),(0,E.jsx)(`dd`,{className:`text-[13px] text-[var(--mt-danger)]`,children:J.error})]}):null,J.phase===`failed`?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`dt`,{className:`amt-label text-[11px] text-[var(--amt-text-muted)]`,children:`Note`}),(0,E.jsx)(`dd`,{className:`text-[12px] text-[var(--amt-text-muted)]`,children:/network|timeout|interrupt/i.test(J.error||``)?v.networkHint:v.refundNote})]}):null]}),(0,E.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,E.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,E.jsx)(`span`,{className:`amt-label text-[10px] text-[var(--amt-text-muted)]`,children:v.sourceLabel}),(0,E.jsx)(`div`,{className:`flex min-h-[120px] items-center justify-center border-[2px] border-[var(--amt-ink)] bg-[var(--amt-bg-soft)]`,children:J.sourceImage?(0,E.jsx)(`img`,{src:J.sourceImage,alt:``,className:`max-h-48 w-full object-contain`}):(0,E.jsx)(_,{className:`size-5 animate-spin text-[var(--amt-text-muted)]`,"aria-hidden":!0})})]}),(0,E.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,E.jsx)(`span`,{className:`amt-label text-[10px] text-[var(--amt-text-muted)]`,children:v.resultLabel}),(0,E.jsx)(`div`,{className:`flex min-h-[120px] items-center justify-center border-[2px] border-[var(--amt-ink)] bg-[var(--amt-bg-soft)]`,children:J.resultImage?(0,E.jsx)(`img`,{src:J.resultImage,alt:``,className:`max-h-48 w-full object-contain`}):J.phase===`failed`?(0,E.jsx)(`span`,{className:`px-2 text-center text-[11px] text-[var(--mt-danger)]`,children:v.statusFailed}):(0,E.jsxs)(`span`,{className:`flex items-center gap-1.5 px-2 text-center text-[11px] text-[var(--amt-text-muted)]`,children:[(0,E.jsx)(_,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),v.waitingResult]})})]})]})]}):(0,E.jsxs)(`div`,{className:`flex items-center gap-2 p-4 text-[13px] text-[var(--amt-text-muted)]`,children:[(0,E.jsx)(_,{className:`size-4 animate-spin`,"aria-hidden":!0}),v.translating]})]}),P?(0,E.jsxs)(`div`,{className:`space-y-1`,children:[(0,E.jsx)(`p`,{className:`text-[13px] text-[var(--mt-danger)]`,children:P}),M===`failed`||I.some(e=>e.phase===`failed`)?(0,E.jsx)(`p`,{className:`text-[12px] text-[var(--amt-text-muted)]`,children:/insufficient|credit/i.test(P)?v.needCredits:v.refundNote}):null]}):null,(0,E.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[J?.resultImage?(0,E.jsxs)(`a`,{href:J.resultImage,target:`_blank`,rel:`noreferrer`,className:`amt-btn-primary inline-flex h-10 items-center gap-1.5 text-[13px]`,children:[v.downloadResult,(0,E.jsx)(g,{className:`size-3.5`,"aria-hidden":!0})]}):null,M===`failed`||J?.phase===`failed`?(0,E.jsx)(`button`,{type:`button`,onClick:()=>B(!0),className:`inline-flex h-10 items-center border-[3px] border-[var(--amt-ink)] bg-[var(--amt-accent)] px-4 text-[13px] font-semibold text-white shadow-[3px_3px_0_0_var(--amt-ink)]`,children:v.continueBarBuy}):null,(0,E.jsx)(s,{href:`/dashboard`,className:`inline-flex h-10 items-center border-[3px] border-[var(--amt-ink)] bg-[var(--amt-paper)] px-4 text-[13px] font-semibold text-[var(--amt-ink)] shadow-[3px_3px_0_0_var(--amt-ink)]`,children:v.viewTasks}),(M===`done`||M===`failed`)&&(0,E.jsx)(`button`,{type:`button`,onClick:we,className:`amt-label text-[12px] text-[var(--amt-text-muted)] underline`,children:v.change})]}),M===`done`?(0,E.jsx)(`p`,{className:`amt-heading text-[16px] text-[var(--amt-ink)] uppercase`,children:I.filter(e=>e.phase===`success`).length>1?v.doneMulti.replace(`{count}`,String(I.filter(e=>e.phase===`success`).length)):v.done}):null]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:()=>!q&&U.current?.click(),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&!q&&(e.preventDefault(),U.current?.click())},onDragOver:e=>{e.preventDefault(),k(!0)},onDragLeave:()=>k(!1),onDrop:e=>{e.preventDefault(),k(!1),q||Ce(e.dataTransfer.files?.[0])},className:`relative flex min-h-[200px] flex-1 cursor-pointer flex-col items-center justify-center gap-3 overflow-hidden border-8 border-dashed border-[var(--amt-ink)] px-6 py-10 text-center transition-colors outline-none ${se?`bg-[var(--amt-bg-soft)]`:`bg-[var(--amt-paper)] hover:bg-[var(--amt-bg-elevated)]`}
2`,children:[(0,E.jsx)(`div`,{"aria-hidden":!0,className:`absolute top-0 right-0 size-16 translate-x-8 -translate-y-8 rotate-45 border-2 border-[var(--amt-ink)] bg-[var(--amt-bg-soft)]`}),A?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`span`,{className:`amt-heading text-[20px] text-[var(--amt-ink)] uppercase`,children:A.name}),(0,E.jsx)(`span`,{className:`amt-label text-[12px] text-[var(--amt-text-muted)]`,children:v.ready})]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`span`,{className:`amt-heading text-[22px] text-[var(--amt-ink)] uppercase md:text-[28px]`,children:p.primary}),(0,E.jsx)(`span`,{className:`amt-label text-[12px] text-[var(--amt-text-muted)]`,children:p.secondary})]})]}),P?(0,E.jsx)(`p`,{className:`text-[13px] text-[var(--mt-danger)]`,children:P}):null,A&&M===`ready`?(0,E.jsx)(`button`,{type:`button`,onClick:()=>{if(K&&V!==null&&V<10){B(!0),F(v.needCredits);return}Se(A)},className:`amt-btn-primary w-fit text-[14px]`,children:K?V!==null&&V<10?v.continueBarBuy:v.translate:v.signIn}):null]})]})]}),K&&ge.length>0?(0,E.jsxs)(`div`,{id:`recent-translations`,className:`amt-ink-shadow mx-auto mt-6 max-w-[1200px] overflow-hidden border-[4px] border-[var(--amt-ink)] bg-[var(--amt-paper)]`,children:[(0,E.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border-b-[3px] border-[var(--amt-ink)] bg-[var(--amt-bg-elevated)] px-4 py-3 sm:px-5`,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(w,{className:`size-4 text-[var(--amt-accent)]`,"aria-hidden":!0}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`p`,{className:`amt-heading text-[14px] text-[var(--amt-ink)] uppercase`,children:v.historyTitle}),(0,E.jsx)(`p`,{className:`text-[11px] text-[var(--amt-text-muted)]`,children:v.historySubtitle})]})]}),(0,E.jsxs)(`button`,{type:`button`,onClick:()=>void Q(),disabled:pe,className:`inline-flex items-center gap-1.5 border-[2px] border-[var(--amt-ink)] bg-[var(--amt-paper)] px-2.5 py-1 text-[11px] font-semibold text-[var(--amt-ink)] shadow-[2px_2px_0_0_var(--amt-ink)] hover:-translate-y-px disabled:opacity-50`,children:[pe?(0,E.jsx)(_,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,E.jsx)(w,{className:`size-3.5`,"aria-hidden":!0}),v.historyRefresh]})]}),(0,E.jsx)(`div`,{className:`h-[20rem] overflow-y-auto overscroll-contain p-4 [scrollbar-gutter:stable] sm:p-5`,children:(0,E.jsx)(`ul`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:ge.map(e=>{let t=e.resultImage||e.sourceImage,n=e.status===`processing`||e.status===`pending`,r=e.status===`failed`,i=e.status===`success`&&!!e.resultImage,a=e.createdAt?new Date(e.createdAt).toLocaleString():``,o=i?v.historyDone:n?e.status===`pending`?v.historyPending:v.historyProcessing:v.historyFailed;return(0,E.jsxs)(`li`,{className:`flex h-[8.5rem] overflow-hidden border-[3px] border-[var(--amt-ink)] bg-[var(--amt-bg-elevated)] shadow-[3px_3px_0_0_var(--amt-ink)]`,children:[(0,E.jsxs)(`button`,{type:`button`,onClick:()=>ye(e),className:`relative h-full w-24 shrink-0 bg-[var(--amt-bg-soft)] sm:w-28`,title:v.historyView,children:[t?(0,E.jsx)(`img`,{src:t,alt:``,className:`h-full w-full object-cover`,loading:`lazy`}):(0,E.jsx)(`span`,{className:`flex h-full items-center justify-center text-[10px] text-[var(--amt-text-muted)]`,children:`—`}),n?(0,E.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center bg-black/35`,children:(0,E.jsx)(_,{className:`size-6 animate-spin text-white`,"aria-hidden":!0})}):null]}),(0,E.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col justify-between p-2.5 sm:p-3`,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`p`,{className:c(`text-[11px] font-bold`,i&&`text-emerald-700`,n&&`text-[var(--amt-accent)]`,r&&`text-[var(--mt-danger)]`),children:o}),(0,E.jsx)(`p`,{className:`mt-0.5 truncate text-[10px] text-[var(--amt-text-muted)]`,children:a}),e.targetLanguage?(0,E.jsxs)(`p`,{className:`mt-0.5 truncate text-[10px] text-[var(--amt-ink)]`,children:[`→ `,e.targetLanguage]}):null]}),(0,E.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[(0,E.jsxs)(`button`,{type:`button`,onClick:()=>ye(e),className:`inline-flex items-center gap-1 border-[2px] border-[var(--amt-ink)] bg-[var(--amt-paper)] px-2 py-1 text-[10px] font-semibold text-[var(--amt-ink)] hover:bg-white`,children:[(0,E.jsx)(ee,{className:`size-3`,"aria-hidden":!0}),v.historyView]}),i&&e.resultImage?(0,E.jsxs)(`a`,{href:e.resultImage,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 border-[2px] border-[var(--amt-ink)] bg-[var(--amt-accent)] px-2 py-1 text-[10px] font-semibold text-white`,children:[(0,E.jsx)(g,{className:`size-3`,"aria-hidden":!0}),v.historyDownload]}):null]})]})]},e.id)})})})]}):null]}),(0,E.jsx)(D,{open:he,onClose:()=>B(!1),title:v.paywallTitle,subtitle:v.paywallSubtitle,note:v.paywallNote,ctaLabel:v.paywallCta,signInLabel:v.paywallSignIn})]})}export{k as ToolsPanel};

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.