Commit ·
7824c8c
1
Parent(s): c38314b
added thumbnail
Browse files- README.md +2 -0
- dist/assets/{index-Dq-reLEJ.js → index-MGlRZaEt.js} +1 -1
- dist/index.html +1 -1
README.md
CHANGED
|
@@ -9,6 +9,8 @@ license: apache-2.0
|
|
| 9 |
short_description: Private browser-based translator with 56 languages
|
| 10 |
app_file: dist/index.html
|
| 11 |
header: default
|
|
|
|
|
|
|
| 12 |
models:
|
| 13 |
- google/translategemma-4b-it
|
| 14 |
- onnx-community/translategemma-text-4b-it-ONNX
|
|
|
|
| 9 |
short_description: Private browser-based translator with 56 languages
|
| 10 |
app_file: dist/index.html
|
| 11 |
header: default
|
| 12 |
+
thumbnail: >-
|
| 13 |
+
https://uploads.nico.dev/translategemma-og.png
|
| 14 |
models:
|
| 15 |
- google/translategemma-4b-it
|
| 16 |
- onnx-community/translategemma-text-4b-it-ONNX
|
dist/assets/{index-Dq-reLEJ.js → index-MGlRZaEt.js}
RENAMED
|
@@ -126,7 +126,7 @@ Error generating stack: `+l.message+`
|
|
| 126 |
*
|
| 127 |
* This source code is licensed under the ISC license.
|
| 128 |
* See the LICENSE file in the root directory of this source tree.
|
| 129 |
-
*/const QE=[["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],WE=hi("trash",QE),pi=(...e)=>e.map(n=>typeof n=="string"?n:Object.entries(n||{}).filter(([,r])=>r).map(([r])=>r).join(" ")).filter(n=>n!=="").join(" ");function ug({variant:e="primary",icon:n,iconPosition:r="left",children:s,className:o="",...c}){const u="inline-flex items-center justify-center font-medium text-sm transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2",d={primary:"bg-primary text-primary-foreground hover:bg-primary-600 active:bg-primary-700 rounded-md shadow-sm hover:shadow focus:ring-primary/50",outlined:"bg-transparent text-primary hover:bg-muted active:bg-primary-50 border border-border rounded-[48px] focus:ring-primary/30",pill:"bg-transparent text-primary hover:bg-primary-50 active:bg-muted border border-border rounded-[48px] focus:ring-primary/30","pill-selected":"bg-primary-100 text-primary-800 hover:bg-primary-200 active:bg-primary-200 border border-primary-100 rounded-[48px] shadow-sm focus:ring-primary-800/30",text:"bg-transparent text-primary hover:bg-muted active:bg-primary-50 rounded-md focus:ring-primary/30",ghost:"bg-transparent text-muted-foreground hover:bg-muted hover:text-primary active:bg-primary-50 rounded-md focus:ring-primary/30"},h={primary:"[padding:0.625em_1.5em] [gap:0.5em]",outlined:"[padding:0.5em_0.75em] [gap:0.5em]",pill:"[padding:0.5em_0.75em] [gap:0.5em]","pill-selected":"[padding:0.5em_0.75em] [gap:0.5em]",text:"[padding:0.375em_0.5em] [gap:0.5em]",ghost:"[padding:0.5em_0.75em] [gap:0.5em]"};return he.jsxs("button",{className:pi("cursor-pointer",u,d[e],h[e],"disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-current disabled:hover:shadow-none",o),...c,children:[n&&r==="left"&&he.jsx(n,{className:"[width:1.25em] [height:1.25em]"}),s,n&&r==="right"&&he.jsx(n,{className:"[width:1.25em] [height:1.25em]"})]})}function Ob({variant:e="default",error:n=!1,className:r="",value:s,...o}){const c="w-full font-sans transition-all duration-200 resize-none focus:outline-none",u={default:"px-4 py-3 border border-border rounded-md bg-white hover:border-primary-300 focus:border-primary focus:ring-2 focus:ring-primary/20",minimal:"px-4 py-3 border-0 bg-transparent hover:bg-muted/30 focus:bg-white focus:shadow-sm rounded-md"},d=n?"border-destructive focus:border-destructive focus:ring-destructive/20":"",h="disabled:cursor-default",p=ct.useMemo(()=>{const g=typeof s=="string"?s.length:0;return console.log(g),g===0||g<50?"text-2xl":g<200?"text-xl":g<300?"text-lg":"text-base"},[s]);return he.jsx("textarea",{className:pi(c,u[e],d,h,p,r),value:s,...o})}function ZE({size:e=20,className:n=""}){return he.jsx(HE,{className:`animate-spin text-primary ${n}`,style:{width:e,height:e}})}function KE({className:e="",children:n,style:r}){return he.jsx("div",{className:pi("bg-white rounded-lg shadow-md p-8 border border-border",e),style:r,children:n})}const Cg=[{code:"ar_EG",name:"Arabic (Egypt)"},{code:"ar_SA",name:"Arabic (Saudi Arabia)"},{code:"bg_BG",name:"Bulgarian"},{code:"bn_IN",name:"Bengali"},{code:"ca_ES",name:"Catalan"},{code:"cs_CZ",name:"Czech"},{code:"da_DK",name:"Danish"},{code:"de_DE",name:"German"},{code:"el_GR",name:"Greek"},{code:"en",name:"English"},{code:"es_XX",name:"Spanish"},{code:"et_EE",name:"Estonian"},{code:"fa_IR",name:"Persian"},{code:"fi_FI",name:"Finnish"},{code:"fil_PH",name:"Filipino"},{code:"fr_CA",name:"French (Canada)"},{code:"fr_FR",name:"French"},{code:"gu_IN",name:"Gujarati"},{code:"he_IL",name:"Hebrew"},{code:"hi_IN",name:"Hindi"},{code:"hr_HR",name:"Croatian"},{code:"hu_HU",name:"Hungarian"},{code:"id_ID",name:"Indonesian"},{code:"is_IS",name:"Icelandic"},{code:"it_IT",name:"Italian"},{code:"ja_JP",name:"Japanese"},{code:"kn_IN",name:"Kannada"},{code:"ko_KR",name:"Korean"},{code:"lt_LT",name:"Lithuanian"},{code:"lv_LV",name:"Latvian"},{code:"ml_IN",name:"Malayalam"},{code:"mr_IN",name:"Marathi"},{code:"nl_NL",name:"Dutch"},{code:"no_NO",name:"Norwegian"},{code:"pa_IN",name:"Punjabi"},{code:"pl_PL",name:"Polish"},{code:"pt_BR",name:"Portuguese (Brazil)"},{code:"pt_PT",name:"Portuguese (Portugal)"},{code:"ro_RO",name:"Romanian"},{code:"ru_RU",name:"Russian"},{code:"sk_SK",name:"Slovak"},{code:"sl_SI",name:"Slovenian"},{code:"sr_RS",name:"Serbian"},{code:"sv_SE",name:"Swedish"},{code:"sw_KE",name:"Swahili"},{code:"sw_TZ",name:"Swahili (Tanzania)"},{code:"ta_IN",name:"Tamil"},{code:"te_IN",name:"Telugu"},{code:"th_TH",name:"Thai"},{code:"tr_TR",name:"Turkish"},{code:"uk_UA",name:"Ukrainian"},{code:"ur_PK",name:"Urdu"},{code:"vi_VN",name:"Vietnamese"},{code:"zh_CN",name:"Chinese (Simplified)"},{code:"zh_TW",name:"Chinese (Traditional)"},{code:"zu_ZA",name:"Zulu"}],JE=[{code:"auto",name:"Auto"},...Cg];function zb({value:e,onChange:n,includeAuto:r=!1}){const[s,o]=ct.useState(!1),[c,u]=ct.useState(""),d=ct.useRef(null),h=ct.useRef(null),p=r?JE:Cg,g=S=>{var E;return((E=p.find(O=>O.code===S))==null?void 0:E.name)||S},w=c?(S=>{const E=S.toLowerCase();return p.filter(O=>O.name.toLowerCase().includes(E)||O.code.toLowerCase().includes(E))})(c):p,b=S=>{n(S),o(!1),u("")};return ct.useEffect(()=>{const S=E=>{d.current&&!d.current.contains(E.target)&&(o(!1),u(""))};return s&&(document.addEventListener("mousedown",S),setTimeout(()=>{var E;return(E=h.current)==null?void 0:E.focus()},0)),()=>{document.removeEventListener("mousedown",S)}},[s]),he.jsxs("div",{className:"relative",ref:d,children:[he.jsxs("button",{onClick:()=>o(!s),className:"inline-flex items-center gap-2 px-3 py-2 text-sm font-medium text-primary hover:bg-muted rounded-md transition-colors",children:[he.jsx("span",{children:g(e)}),he.jsx(GE,{className:`w-4 h-4 transition-transform ${s?"rotate-180":""}`})]}),s&&he.jsxs("div",{className:"absolute top-full left-0 mt-2 w-64 bg-white border border-border rounded-md shadow-lg z-50",children:[he.jsx("div",{className:"p-2 border-b border-border",children:he.jsx("input",{ref:h,type:"text",placeholder:"Search languages...",value:c,onChange:S=>u(S.target.value),className:"w-full px-3 py-2 text-sm border border-border rounded-md focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary"})}),he.jsxs("div",{className:"max-h-60 overflow-auto",children:[w.map(S=>he.jsx("button",{onClick:()=>b(S.code),className:`w-full px-3 py-2 text-left text-sm hover:bg-muted transition-colors ${e===S.code?"bg-primary-50 text-primary-800":""}`,children:S.name},S.code)),w.length===0&&he.jsx("div",{className:"px-3 py-4 text-sm text-muted-foreground text-center",children:"No languages found"})]})]})]})}function eA(e,n=1){const s=["Bytes","KB","MB","GB","TB","PB"],o=Math.floor(Math.log(e)/Math.log(1024));return`${parseFloat((e/Math.pow(1024,o)).toFixed(n))}${s[o]}`}function tA(e){if(e<1e3)return`${Math.round(e)}ms`;const n=e/1e3;if(n<60)return`${n.toFixed(1)}s`;const r=Math.floor(n/60),s=Math.round(n%60);return`${r}m ${s}s`}function e_(e){return new Intl.NumberFormat("en-US").format(e)}function nA(e){return!e||e.trim().length===0?0:e.trim().split(/\s+/).filter(r=>r.length>0).length}const Lb=1e3;function aA({className:e="",translator:n}){const s=(()=>{const _e=window.location.hash.slice(1),me=new URLSearchParams(_e),ne=me.get("sl"),ee=me.get("tl"),Me=me.get("text"),V=W=>W?Cg.some(G=>G.code===W):!1;return{sourceLanguage:V(ne)?ne:"en",targetLanguage:V(ee)?ee:"de_DE",sourceText:Me?decodeURIComponent(Me):""}})(),[o,c]=ct.useState(s.sourceText),[u,d]=ct.useState(""),[h,p]=ct.useState(s.sourceLanguage),[g,y]=ct.useState(s.targetLanguage),[w,b]=ct.useState(!1),[S,E]=ct.useState(!1),[O,z]=ct.useState(!1),D=ct.useRef(null),[P,j]=ct.useState(0),[I,K]=ct.useState(0),k=()=>{p(g),y(h),c(u),d(o)},ce=async()=>{if(u)try{await navigator.clipboard.writeText(u),E(!0),setTimeout(()=>E(!1),2e3)}catch(_e){console.error("Failed to copy:",_e)}},oe=async()=>{try{const _e=window.location.href;await navigator.clipboard.writeText(_e),z(!0),setTimeout(()=>z(!1),2e3)}catch(_e){console.error("Failed to share:",_e)}},pe=async(_e,me,ne)=>{if(!_e.trim()){d(""),j(0),K(0);return}const ee=performance.now();D.current&&D.current.abort(),D.current=new AbortController;const Me=D.current;b(!0);try{const V=await n.translate(_e,me,ne);Me.signal.aborted||(d(V),j(Math.round(performance.now()-ee)),K(nA(_e)))}catch(V){Me.signal.aborted||console.error("Translation error:",V)}finally{Me.signal.aborted||b(!1)}};return ct.useEffect(()=>{const _e=new URLSearchParams;_e.set("sl",h),_e.set("tl",g),o&&_e.set("text",encodeURIComponent(o)),window.location.hash=`#${_e.toString()}`},[h,g,o]),ct.useEffect(()=>{const _e=setTimeout(()=>{pe(o,h,g)},500);return()=>{clearTimeout(_e)}},[o,h,g]),he.jsx("div",{className:pi("max-w-6xl mx-auto p-2 md:p-4 relative",e),children:he.jsxs("div",{className:"flex flex-col md:flex-row w-full gap-4 md:gap-8",children:[he.jsxs("div",{className:"flex flex-col gap-3 w-full md:w-1/2 relative",children:[he.jsx(zb,{value:h,onChange:p}),he.jsx(Ob,{value:o,onChange:_e=>c(_e.target.value),placeholder:"Enter text to translate...",className:"h-48 md:h-70 pb-10",variant:"default",maxLength:Lb}),he.jsxs("div",{className:"p-2 flex justify-between items-center -mt-4",children:[he.jsxs("p",{className:"text-xs text-muted-foreground opacity-70",children:[e_(o.length)," /"," ",e_(Lb)]}),he.jsxs("div",{className:"flex gap-2",children:[he.jsx("button",{onClick:oe,className:"p-2 text-muted-foreground hover:text-primary hover:bg-muted rounded-md transition-colors","aria-label":"Share translation",children:O?he.jsxs("span",{className:"flex text-xs gap-2",children:["link copied",he.jsx(kb,{className:"w-4 h-4 text-primary"})]}):he.jsx(XE,{className:"w-4 h-4"})}),he.jsx("button",{onClick:()=>c(""),className:"p-2 text-muted-foreground hover:text-primary hover:bg-muted rounded-md transition-colors","aria-label":"clear text",children:he.jsx(WE,{className:"w-4 h-4"})})]})]})]}),he.jsx("div",{className:"hidden md:block absolute left-1/2 top-5 -translate-x-1/2",children:he.jsx(ug,{variant:"ghost",icon:Cb,onClick:k,"aria-label":"Swap languages"})}),he.jsx("div",{className:"flex md:hidden justify-center -my-2",children:he.jsx(ug,{variant:"ghost",icon:Cb,onClick:k,"aria-label":"Swap languages",className:"rotate-90"})}),he.jsxs("div",{className:"flex flex-col gap-3 w-full md:w-1/2",children:[he.jsxs("div",{className:"flex items-center justify-between",children:[he.jsx(zb,{value:g,onChange:y}),w&&he.jsx(ZE,{size:20})]}),he.jsxs("div",{children:[he.jsx(Ob,{value:u,disabled:!0,placeholder:"Translation will appear here...",className:"h-48 md:h-70",variant:"default"}),he.jsxs("div",{className:"p-2 flex justify-between items-center -mt-4",children:[P>0?he.jsxs("p",{className:"text-xs text-muted-foreground opacity-70",children:["Translated ",he.jsxs("b",{children:[e_(I)," words"]})," in"," ",he.jsx("b",{children:tA(P)})]}):he.jsx("p",{}),he.jsx("div",{children:he.jsx("button",{onClick:ce,className:"p-2 text-muted-foreground hover:text-primary hover:bg-muted rounded-md transition-colors","aria-label":"Copy translation",children:S?he.jsxs("span",{className:"flex text-xs gap-2",children:["translation copied",he.jsx(kb,{className:"w-4 h-4 text-primary"})]}):he.jsx(jE,{className:"w-4 h-4"})})})]})]})]})]})})}/*!
|
| 130 |
* ONNX Runtime Web v1.25.0-dev.20260212-1a71a5f46e
|
| 131 |
* Copyright (c) Microsoft Corporation. All rights reserved.
|
| 132 |
* Licensed under the MIT License.
|
|
|
|
| 126 |
*
|
| 127 |
* This source code is licensed under the ISC license.
|
| 128 |
* See the LICENSE file in the root directory of this source tree.
|
| 129 |
+
*/const QE=[["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],WE=hi("trash",QE),pi=(...e)=>e.map(n=>typeof n=="string"?n:Object.entries(n||{}).filter(([,r])=>r).map(([r])=>r).join(" ")).filter(n=>n!=="").join(" ");function ug({variant:e="primary",icon:n,iconPosition:r="left",children:s,className:o="",...c}){const u="inline-flex items-center justify-center font-medium text-sm transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2",d={primary:"bg-primary text-primary-foreground hover:bg-primary-600 active:bg-primary-700 rounded-md shadow-sm hover:shadow focus:ring-primary/50",outlined:"bg-transparent text-primary hover:bg-muted active:bg-primary-50 border border-border rounded-[48px] focus:ring-primary/30",pill:"bg-transparent text-primary hover:bg-primary-50 active:bg-muted border border-border rounded-[48px] focus:ring-primary/30","pill-selected":"bg-primary-100 text-primary-800 hover:bg-primary-200 active:bg-primary-200 border border-primary-100 rounded-[48px] shadow-sm focus:ring-primary-800/30",text:"bg-transparent text-primary hover:bg-muted active:bg-primary-50 rounded-md focus:ring-primary/30",ghost:"bg-transparent text-muted-foreground hover:bg-muted hover:text-primary active:bg-primary-50 rounded-md focus:ring-primary/30"},h={primary:"[padding:0.625em_1.5em] [gap:0.5em]",outlined:"[padding:0.5em_0.75em] [gap:0.5em]",pill:"[padding:0.5em_0.75em] [gap:0.5em]","pill-selected":"[padding:0.5em_0.75em] [gap:0.5em]",text:"[padding:0.375em_0.5em] [gap:0.5em]",ghost:"[padding:0.5em_0.75em] [gap:0.5em]"};return he.jsxs("button",{className:pi("cursor-pointer",u,d[e],h[e],"disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-current disabled:hover:shadow-none",o),...c,children:[n&&r==="left"&&he.jsx(n,{className:"[width:1.25em] [height:1.25em]"}),s,n&&r==="right"&&he.jsx(n,{className:"[width:1.25em] [height:1.25em]"})]})}function Ob({variant:e="default",error:n=!1,className:r="",value:s,...o}){const c="w-full font-sans transition-all duration-200 resize-none focus:outline-none",u={default:"px-4 py-3 border border-border rounded-md bg-white hover:border-primary-300 focus:border-primary focus:ring-2 focus:ring-primary/20",minimal:"px-4 py-3 border-0 bg-transparent hover:bg-muted/30 focus:bg-white focus:shadow-sm rounded-md"},d=n?"border-destructive focus:border-destructive focus:ring-destructive/20":"",h="disabled:cursor-default",p=ct.useMemo(()=>{const g=typeof s=="string"?s.length:0;return console.log(g),g===0||g<50?"text-2xl":g<200?"text-xl":g<300?"text-lg":"text-base"},[s]);return he.jsx("textarea",{className:pi(c,u[e],d,h,p,r),value:s,...o})}function ZE({size:e=20,className:n=""}){return he.jsx(HE,{className:`animate-spin text-primary ${n}`,style:{width:e,height:e}})}function KE({className:e="",children:n,style:r}){return he.jsx("div",{className:pi("bg-white rounded-lg shadow-md p-8 border border-border",e),style:r,children:n})}const Cg=[{code:"ar_EG",name:"Arabic (Egypt)"},{code:"ar_SA",name:"Arabic (Saudi Arabia)"},{code:"bg_BG",name:"Bulgarian"},{code:"bn_IN",name:"Bengali"},{code:"ca_ES",name:"Catalan"},{code:"cs_CZ",name:"Czech"},{code:"da_DK",name:"Danish"},{code:"de_DE",name:"German"},{code:"el_GR",name:"Greek"},{code:"en",name:"English"},{code:"es_XX",name:"Spanish"},{code:"et_EE",name:"Estonian"},{code:"fa_IR",name:"Persian"},{code:"fi_FI",name:"Finnish"},{code:"fil_PH",name:"Filipino"},{code:"fr_CA",name:"French (Canada)"},{code:"fr_FR",name:"French"},{code:"gu_IN",name:"Gujarati"},{code:"he_IL",name:"Hebrew"},{code:"hi_IN",name:"Hindi"},{code:"hr_HR",name:"Croatian"},{code:"hu_HU",name:"Hungarian"},{code:"id_ID",name:"Indonesian"},{code:"is_IS",name:"Icelandic"},{code:"it_IT",name:"Italian"},{code:"ja_JP",name:"Japanese"},{code:"kn_IN",name:"Kannada"},{code:"ko_KR",name:"Korean"},{code:"lt_LT",name:"Lithuanian"},{code:"lv_LV",name:"Latvian"},{code:"ml_IN",name:"Malayalam"},{code:"mr_IN",name:"Marathi"},{code:"nl_NL",name:"Dutch"},{code:"no_NO",name:"Norwegian"},{code:"pa_IN",name:"Punjabi"},{code:"pl_PL",name:"Polish"},{code:"pt_BR",name:"Portuguese (Brazil)"},{code:"pt_PT",name:"Portuguese (Portugal)"},{code:"ro_RO",name:"Romanian"},{code:"ru_RU",name:"Russian"},{code:"sk_SK",name:"Slovak"},{code:"sl_SI",name:"Slovenian"},{code:"sr_RS",name:"Serbian"},{code:"sv_SE",name:"Swedish"},{code:"sw_KE",name:"Swahili"},{code:"sw_TZ",name:"Swahili (Tanzania)"},{code:"ta_IN",name:"Tamil"},{code:"te_IN",name:"Telugu"},{code:"th_TH",name:"Thai"},{code:"tr_TR",name:"Turkish"},{code:"uk_UA",name:"Ukrainian"},{code:"ur_PK",name:"Urdu"},{code:"vi_VN",name:"Vietnamese"},{code:"zh_TW",name:"Chinese (Traditional)"},{code:"zu_ZA",name:"Zulu"}],JE=[{code:"auto",name:"Auto"},...Cg];function zb({value:e,onChange:n,includeAuto:r=!1}){const[s,o]=ct.useState(!1),[c,u]=ct.useState(""),d=ct.useRef(null),h=ct.useRef(null),p=r?JE:Cg,g=S=>{var E;return((E=p.find(O=>O.code===S))==null?void 0:E.name)||S},w=c?(S=>{const E=S.toLowerCase();return p.filter(O=>O.name.toLowerCase().includes(E)||O.code.toLowerCase().includes(E))})(c):p,b=S=>{n(S),o(!1),u("")};return ct.useEffect(()=>{const S=E=>{d.current&&!d.current.contains(E.target)&&(o(!1),u(""))};return s&&(document.addEventListener("mousedown",S),setTimeout(()=>{var E;return(E=h.current)==null?void 0:E.focus()},0)),()=>{document.removeEventListener("mousedown",S)}},[s]),he.jsxs("div",{className:"relative",ref:d,children:[he.jsxs("button",{onClick:()=>o(!s),className:"inline-flex items-center gap-2 px-3 py-2 text-sm font-medium text-primary hover:bg-muted rounded-md transition-colors",children:[he.jsx("span",{children:g(e)}),he.jsx(GE,{className:`w-4 h-4 transition-transform ${s?"rotate-180":""}`})]}),s&&he.jsxs("div",{className:"absolute top-full left-0 mt-2 w-64 bg-white border border-border rounded-md shadow-lg z-50",children:[he.jsx("div",{className:"p-2 border-b border-border",children:he.jsx("input",{ref:h,type:"text",placeholder:"Search languages...",value:c,onChange:S=>u(S.target.value),className:"w-full px-3 py-2 text-sm border border-border rounded-md focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary"})}),he.jsxs("div",{className:"max-h-60 overflow-auto",children:[w.map(S=>he.jsx("button",{onClick:()=>b(S.code),className:`w-full px-3 py-2 text-left text-sm hover:bg-muted transition-colors ${e===S.code?"bg-primary-50 text-primary-800":""}`,children:S.name},S.code)),w.length===0&&he.jsx("div",{className:"px-3 py-4 text-sm text-muted-foreground text-center",children:"No languages found"})]})]})]})}function eA(e,n=1){const s=["Bytes","KB","MB","GB","TB","PB"],o=Math.floor(Math.log(e)/Math.log(1024));return`${parseFloat((e/Math.pow(1024,o)).toFixed(n))}${s[o]}`}function tA(e){if(e<1e3)return`${Math.round(e)}ms`;const n=e/1e3;if(n<60)return`${n.toFixed(1)}s`;const r=Math.floor(n/60),s=Math.round(n%60);return`${r}m ${s}s`}function e_(e){return new Intl.NumberFormat("en-US").format(e)}function nA(e){return!e||e.trim().length===0?0:e.trim().split(/\s+/).filter(r=>r.length>0).length}const Lb=1e3;function aA({className:e="",translator:n}){const s=(()=>{const _e=window.location.hash.slice(1),me=new URLSearchParams(_e),ne=me.get("sl"),ee=me.get("tl"),Me=me.get("text"),V=W=>W?Cg.some(G=>G.code===W):!1;return{sourceLanguage:V(ne)?ne:"en",targetLanguage:V(ee)?ee:"de_DE",sourceText:Me?decodeURIComponent(Me):""}})(),[o,c]=ct.useState(s.sourceText),[u,d]=ct.useState(""),[h,p]=ct.useState(s.sourceLanguage),[g,y]=ct.useState(s.targetLanguage),[w,b]=ct.useState(!1),[S,E]=ct.useState(!1),[O,z]=ct.useState(!1),D=ct.useRef(null),[P,j]=ct.useState(0),[I,K]=ct.useState(0),k=()=>{p(g),y(h),c(u),d(o)},ce=async()=>{if(u)try{await navigator.clipboard.writeText(u),E(!0),setTimeout(()=>E(!1),2e3)}catch(_e){console.error("Failed to copy:",_e)}},oe=async()=>{try{const _e=window.location.href;await navigator.clipboard.writeText(_e),z(!0),setTimeout(()=>z(!1),2e3)}catch(_e){console.error("Failed to share:",_e)}},pe=async(_e,me,ne)=>{if(!_e.trim()){d(""),j(0),K(0);return}const ee=performance.now();D.current&&D.current.abort(),D.current=new AbortController;const Me=D.current;b(!0);try{const V=await n.translate(_e,me,ne);Me.signal.aborted||(d(V),j(Math.round(performance.now()-ee)),K(nA(_e)))}catch(V){Me.signal.aborted||console.error("Translation error:",V)}finally{Me.signal.aborted||b(!1)}};return ct.useEffect(()=>{const _e=new URLSearchParams;_e.set("sl",h),_e.set("tl",g),o&&_e.set("text",encodeURIComponent(o)),window.location.hash=`#${_e.toString()}`},[h,g,o]),ct.useEffect(()=>{const _e=setTimeout(()=>{pe(o,h,g)},500);return()=>{clearTimeout(_e)}},[o,h,g]),he.jsx("div",{className:pi("max-w-6xl mx-auto p-2 md:p-4 relative",e),children:he.jsxs("div",{className:"flex flex-col md:flex-row w-full gap-4 md:gap-8",children:[he.jsxs("div",{className:"flex flex-col gap-3 w-full md:w-1/2 relative",children:[he.jsx(zb,{value:h,onChange:p}),he.jsx(Ob,{value:o,onChange:_e=>c(_e.target.value),placeholder:"Enter text to translate...",className:"h-48 md:h-70 pb-10",variant:"default",maxLength:Lb}),he.jsxs("div",{className:"p-2 flex justify-between items-center -mt-4",children:[he.jsxs("p",{className:"text-xs text-muted-foreground opacity-70",children:[e_(o.length)," /"," ",e_(Lb)]}),he.jsxs("div",{className:"flex gap-2",children:[he.jsx("button",{onClick:oe,className:"p-2 text-muted-foreground hover:text-primary hover:bg-muted rounded-md transition-colors","aria-label":"Share translation",children:O?he.jsxs("span",{className:"flex text-xs gap-2",children:["link copied",he.jsx(kb,{className:"w-4 h-4 text-primary"})]}):he.jsx(XE,{className:"w-4 h-4"})}),he.jsx("button",{onClick:()=>c(""),className:"p-2 text-muted-foreground hover:text-primary hover:bg-muted rounded-md transition-colors","aria-label":"clear text",children:he.jsx(WE,{className:"w-4 h-4"})})]})]})]}),he.jsx("div",{className:"hidden md:block absolute left-1/2 top-5 -translate-x-1/2",children:he.jsx(ug,{variant:"ghost",icon:Cb,onClick:k,"aria-label":"Swap languages"})}),he.jsx("div",{className:"flex md:hidden justify-center -my-2",children:he.jsx(ug,{variant:"ghost",icon:Cb,onClick:k,"aria-label":"Swap languages",className:"rotate-90"})}),he.jsxs("div",{className:"flex flex-col gap-3 w-full md:w-1/2",children:[he.jsxs("div",{className:"flex items-center justify-between",children:[he.jsx(zb,{value:g,onChange:y}),w&&he.jsx(ZE,{size:20})]}),he.jsxs("div",{children:[he.jsx(Ob,{value:u,disabled:!0,placeholder:"Translation will appear here...",className:"h-48 md:h-70",variant:"default"}),he.jsxs("div",{className:"p-2 flex justify-between items-center -mt-4",children:[P>0?he.jsxs("p",{className:"text-xs text-muted-foreground opacity-70",children:["Translated ",he.jsxs("b",{children:[e_(I)," words"]})," in"," ",he.jsx("b",{children:tA(P)})]}):he.jsx("p",{}),he.jsx("div",{children:he.jsx("button",{onClick:ce,className:"p-2 text-muted-foreground hover:text-primary hover:bg-muted rounded-md transition-colors","aria-label":"Copy translation",children:S?he.jsxs("span",{className:"flex text-xs gap-2",children:["translation copied",he.jsx(kb,{className:"w-4 h-4 text-primary"})]}):he.jsx(jE,{className:"w-4 h-4"})})})]})]})]})]})})}/*!
|
| 130 |
* ONNX Runtime Web v1.25.0-dev.20260212-1a71a5f46e
|
| 131 |
* Copyright (c) Microsoft Corporation. All rights reserved.
|
| 132 |
* Licensed under the MIT License.
|
dist/index.html
CHANGED
|
@@ -43,7 +43,7 @@
|
|
| 43 |
href="https://fonts.googleapis.com/css2?family=Google+Sans:wght@400;500;700&display=swap"
|
| 44 |
rel="stylesheet"
|
| 45 |
/>
|
| 46 |
-
<script type="module" crossorigin src="/assets/index-
|
| 47 |
<link rel="stylesheet" crossorigin href="/assets/index-DcjTpXS7.css">
|
| 48 |
</head>
|
| 49 |
<body>
|
|
|
|
| 43 |
href="https://fonts.googleapis.com/css2?family=Google+Sans:wght@400;500;700&display=swap"
|
| 44 |
rel="stylesheet"
|
| 45 |
/>
|
| 46 |
+
<script type="module" crossorigin src="/assets/index-MGlRZaEt.js"></script>
|
| 47 |
<link rel="stylesheet" crossorigin href="/assets/index-DcjTpXS7.css">
|
| 48 |
</head>
|
| 49 |
<body>
|