PageSourceSearch

https://kairobot.ai/assets/kairo-translator-iv1YW1si.js

js kairobot.ai collected 2026-10-05 14:32:59 UTC 8,228 bytes, 1 lines download raw bytes

1import{a as n,j as e}from"./vendor-react-5BUW_FQY.js";import{m as L}from"./vendor-motion-BMdIFYxW.js";import{bM as P,a as E,X as $,L as G,C as z,aQ as B}from"./vendor-icons-C_vOXKuu.js";const x=[{code:"en",label:"English",flag:"🇺🇸"},{code:"es",label:"Spanish",flag:"🇪🇸"},{code:"fr",label:"French",flag:"🇫🇷"},{code:"pt",label:"Portuguese",flag:"🇧🇷"},{code:"de",label:"German",flag:"🇩🇪"},{code:"it",label:"Italian",flag:"🇮🇹"},{code:"nl",label:"Dutch",flag:"🇳🇱"},{code:"ru",label:"Russian",flag:"🇷🇺"},{code:"zh",label:"Chinese",flag:"🇨🇳"},{code:"ja",label:"Japanese",flag:"🇯🇵"},{code:"ko",label:"Korean",flag:"🇰🇷"},{code:"ar",label:"Arabic",flag:"🇸🇦"},{code:"hi",label:"Hindi",flag:"🇮🇳"},{code:"tr",label:"Turkish",flag:"🇹🇷"},{code:"pl",label:"Polish",flag:"🇵🇱"},{code:"vi",label:"Vietnamese",flag:"🇻🇳"},{code:"th",label:"Thai",flag:"🇹🇭"},{code:"sv",label:"Swedish",flag:"🇸🇪"},{code:"uk",label:"Ukrainian",flag:"🇺🇦"},{code:"id",label:"Indonesian",flag:"🇮🇩"},{code:"el",label:"Greek",flag:"🇬🇷"},{code:"cs",label:"Czech",flag:"🇨🇿"},{code:"ro",label:"Romanian",flag:"🇷🇴"},{code:"hu",label:"Hungarian",flag:"🇭🇺"},{code:"he",label:"Hebrew",flag:"🇮🇱"},{code:"fa",label:"Persian",flag:"🇮🇷"},{code:"ms",label:"Malay",flag:"🇲🇾"},{code:"tl",label:"Filipino",flag:"🇵🇭"},{code:"sw",label:"Swahili",flag:"🇰🇪"},{code:"bn",label:"Bengali",flag:"🇧🇩"}],R="kairo-trans-lang";function K(){try{return sessionStorage.getItem(R)??"es"}catch{return"es"}}function j(r){try{sessionStorage.setItem(R,r)}catch{}}function U(r){const a=r.toLowerCase();return/\b(spanish|español)\b/.test(a)?"es":/\b(french|français)\b/.test(a)?"fr":/\b(german|deutsch)\b/.test(a)?"de":/\b(italian|italiano)\b/.test(a)?"it":/\b(portuguese|português)\b/.test(a)?"pt":/\b(chinese|mandarin|中文)\b/.test(a)?"zh":/\b(japanese|日本語)\b/.test(a)?"ja":/\b(korean|한국어)\b/.test(a)?"ko":/\b(arabic|عربي)\b/.test(a)?"ar":/\b(hindi|हिंदी)\b/.test(a)?"hi":/\b(russian|русский)\b/.test(a)?"ru":/\b(turkish|türkçe)\b/.test(a)?"tr":null}function D(r){const a=/translate\s+["']?(.+?)["']?\s+(?:to|into)\s+\w+/i.exec(r);if(a)return a[1].trim();const o=/how\s+(?:do\s+you\s+say|to\s+say)\s+["']?(.+?)["']?\s+in\s+\w+/i.exec(r);return o?o[1].trim():""}async function M(r,a,o){if(!r.trim())return"";const t=`${a}|${o}`,u=`https://api.mymemory.translated.net/get?q=${encodeURIComponent(r)}&langpair=${t}`,l=await fetch(u);if(!l.ok)throw new Error("Translation API error");const i=await l.json();if(i.responseStatus!==200)throw new Error(i.responseDetails||"Translation failed");return i.responseData.translatedText||""}function I({value:r,onChange:a,exclude:o}){return e.jsx("select",{value:r,onChange:t=>a(t.target.value),className:"flex-1 rounded-xl px-3 py-2 text-sm font-semibold outline-none appearance-none cursor-pointer",style:{background:"rgba(255,255,255,0.06)",border:"1px solid rgba(255,255,255,0.1)",color:"rgba(255,255,255,0.85)"},children:x.filter(t=>t.code!==o).map(t=>e.jsxs("option",{value:t.code,style:{background:"#111"},children:[t.flag," ",t.label]},t.code))})}function X({query:r}){const[a,o]=n.useState("en"),[t,u]=n.useState(()=>{const s=U(r||"");return s?(j(s),s):K()}),[l,i]=n.useState(()=>D(r||"")),[c,g]=n.useState(""),[w,N]=n.useState(!1),[v,f]=n.useState(""),[A,k]=n.useState(!1),b=n.useRef(null),p=500,m=n.useCallback(async(s,d,h)=>{if(!s.trim()){g(""),f("");return}N(!0),f("");try{const S=await M(s,d,h);g(S)}catch{f("Translation failed — check your connection"),g("")}finally{N(!1)}},[]);n.useEffect(()=>(b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{m(l,a,t)},600),()=>{b.current&&clearTimeout(b.current)}),[l,a,t,m]),n.useEffect(()=>{l&&m(l,a,t)},[]);const F=()=>{const s=t,d=a;o(s),u(d),j(d),i(c),g(l)},T=(s,d)=>{if(!s||!("speechSynthesis"in window))return;const h=new SpeechSynthesisUtterance(s);h.lang=d,window.speechSynthesis.speak(h)},H=()=>{c&&(navigator.clipboard.writeText(c).catch(()=>{}),k(!0),setTimeout(()=>k(!1),1800))},y=x.find(s=>s.code===a),C=x.find(s=>s.code===t);return e.jsxs(L.div,{initial:{opacity:0,y:6}
1,animate:{opacity:1,y:0},className:"rounded-2xl overflow-hidden w-full",style:{background:"rgba(15,17,26,0.95)",border:"1px solid rgba(255,255,255,0.1)"},children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3",style:{borderBottom:"1px solid rgba(255,255,255,0.07)"},children:[e.jsx("span",{className:"text-xs font-bold uppercase tracking-widest",style:{color:"rgba(56,189,248,0.8)"},children:"🌐 Kairo Translator"}),e.jsxs("span",{className:"text-[10px]",style:{color:"rgba(255,255,255,0.25)"},children:[x.length," languages"]})]}),e.jsxs("div",{className:"flex items-center gap-2 px-4 pt-4 pb-3",children:[e.jsx(I,{value:a,onChange:o,exclude:t}),e.jsx(L.button,{whileTap:{rotate:180,scale:.9},onClick:F,className:"shrink-0 p-2 rounded-xl hover:bg-white/5 transition-colors",style:{border:"1px solid rgba(255,255,255,0.1)"},children:e.jsx(P,{className:"w-4 h-4 text-sky-400"})}),e.jsx(I,{value:t,onChange:s=>{u(s),j(s)},exclude:a})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-0",style:{borderTop:"1px solid rgba(255,255,255,0.06)"},children:[e.jsxs("div",{className:"relative",style:{borderRight:"1px solid rgba(255,255,255,0.06)"},children:[e.jsxs("div",{className:"px-3 py-2 flex items-center gap-1.5",style:{borderBottom:"1px solid rgba(255,255,255,0.05)"},children:[e.jsxs("span",{className:"text-xs font-semibold",style:{color:"rgba(255,255,255,0.35)"},children:[y?.flag," ",y?.label]}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{onClick:()=>T(l,a),className:"p-1 rounded hover:bg-white/5 transition-colors",children:e.jsx(E,{className:"w-3 h-3 text-gray-600"})}),l&&e.jsx("button",{onClick:()=>{i(""),g("")},className:"p-1 rounded hover:bg-white/5 transition-colors",children:e.jsx($,{className:"w-3 h-3 text-gray-600"})})]}),e.jsx("textarea",{value:l,onChange:s=>{s.target.value.length<=p&&i(s.target.value)},placeholder:`Type in ${y?.label}...`,className:"w-full resize-none text-sm text-white placeholder-gray-600 outline-none p-3 min-h-[120px]",style:{background:"transparent"}}),e.jsx("div",{className:"px-3 pb-2 text-right",children:e.jsxs("span",{className:"text-[10px]",style:{color:l.length>p*.9?"rgba(251,146,60,0.7)":"rgba(255,255,255,0.2)"},children:[l.length,"/",p]})})]}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"px-3 py-2 flex items-center gap-1.5",style:{borderBottom:"1px solid rgba(255,255,255,0.05)"},children:[e.jsxs("span",{className:"text-xs font-semibold",style:{color:"rgba(255,255,255,0.35)"},children:[C?.flag," ",C?.label]}),e.jsx("div",{className:"flex-1"}),w&&e.jsx(G,{className:"w-3 h-3 text-sky-400 animate-spin"}),e.jsx("button",{onClick:()=>T(c,t),className:"p-1 rounded hover:bg-white/5 transition-colors",disabled:!c,children:e.jsx(E,{className:"w-3 h-3 text-gray-600"})}),e.jsx("button",{onClick:H,className:"p-1 rounded hover:bg-white/5 transition-colors",disabled:!c,children:A?e.jsx(z,{className:"w-3 h-3 text-green-400"}):e.jsx(B,{className:"w-3 h-3 text-gray-600"})})]}),e.jsx("div",{className:"p-3 min-h-[120px]",children:v?e.jsx("p",{className:"text-xs text-red-400/70",children:v}):c?e.jsx("p",{className:"text-sm leading-relaxed",style:{color:"rgba(255,255,255,0.85)",fontFamily:"inherit"},children:c}):w?e.jsx("div",{className:"space-y-2 pt-1",children:[70,90,55].map((s,d)=>e.jsx("div",{className:"h-2 rounded animate-pulse",style:{background:"rgba(255,255,255,0.06)",width:`${s}%`}},d))}):e.jsx("p",{className:"text-sm",style:{color:"rgba(255,255,255,0.2)"},children:"Translation appears here"})})]})]}),e.jsx("div",{className:"px-4 py-3 flex flex-wrap gap-2",style:{borderTop:"1px solid rgba(255,255,255,0.06)"},children:["Hello","Thank you","How much?","Where is...?","I need help"].map(s=>e.jsx("button",{onClick:()=>i(s),className:"text-xs px-2.5 py-1 rounded-lg transition-all hover:brightness-125",style:{background:"rgba(56,189,248,0.08)",border:"1px solid rgba(56,189,248,0.15)",color:"rgba(56,189,248,0.7)"},children:s},s))})]})}export{X as KairoTranslator};

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.