PageSourceSearch

https://static.alugha.com/assets/LanguageSelection-index-Dn3Syu0G.js

js alugha.com collected 2026-10-02 11:20:47 UTC 3,684 bytes, 1 lines download raw bytes

1import{H as q,z as O,r as o,f0 as B,ai as T,p as D,o as Q,f1 as V,aC as Y,j as h,dY as G,S as J}from"./index-B-8CDiEL.js";import{T as K}from"./Tag-index-DuZlojVC.js";import{u as X}from"./useDebounce-index-Dv7f12rR.js";const Z=q.div.withConfig({componentId:"sc-65dbf598-0"})(["display:flex;flex-direction:column;",";",";flex:",";"],e=>e.reverse&&"flex-direction: column-reverse",e=>e.reverseRow&&O(["flex-direction:row-reverse;align-items:center;"]),e=>e.stretch?"1 1 auto":"0 0 auto"),_=q.div.withConfig({componentId:"sc-65dbf598-1"})(["display:flex;flex-wrap:wrap;flex:1 1 auto;padding:",";margin:",";",""],e=>e.noPadding?"0":"0.25rem 0",e=>e.reverseRow&&"0 1rem",e=>e.maxContentTags&&O(["width:max-content;max-width:95vw;"])),L=(e,u,r)=>{const i=e.indexOf(u);return i<0?0:(e.length-i)/e.length*r},ee=e=>{const u=X(e?.query||"",{wait:500}),r=o.useContext(B),i=o.useMemo(()=>e?.whitelistCodes?.length?r.filter(n=>e?.whitelistCodes?.includes(n.code)):[],[r,e?.whitelistCodes]),m=o.useMemo(()=>e?.whitelistCodes?i:r,[r,e?.whitelistCodes,i]),f=o.useMemo(()=>{const n=e?.blacklistCodes||[],p=m.filter(t=>e?.whitelistCodes?.includes(t.code));if(!u)return e?.whitelistCodes?p:m.filter(t=>!n.includes(t.code));const M=u.toLocaleLowerCase().split(" "),w=[],x=e?.whitelistCodes?p:m;for(const t of x){let s=0;for(const l of M)t.formattedName&&(s+=L(t.formattedName.toLocaleLowerCase(),l,20)),t.nativeName&&(s+=L(t.nativeName.toLocaleLowerCase(),l,10)),s+=L(t.name.toLocaleLowerCase(),l,5),s+=L(t.code.toLocaleLowerCase(),l,3);s&&w.push({score:s,language:t})}return w.filter(t=>n.length===0||!n.includes(t.language.code)).sort((t,s)=>s.score-t.score).slice(0,50).map(({language:t})=>t)},[m,e?.whitelistCodes,e?.blacklistCodes,u]),C=o.useMemo(()=>f.map(n=>({value:n,label:`${n.formattedName||n.nativeName||n.name} (${n.code.toUpperCase()})`})),[f]);return{languages:T,formattedLanguages:r,filteredLanguages:f,languagesAsOptions:C}},v=Q({custom:{id:"app.LanguageSelection.custom",defaultMessage:"Custom"},label:{id:"app.LanguageSelection.label",defaultMessage:"Language"}}),oe=({blacklistCodes:e,whitelistCodes:u,dark:r,label:i,onFocusSearch:m,onRemove:f,onSelect:C=V,noPadding:n,withTags:p,maxContentTags:M,reverse:w,blackListSelectedLangs:x=!1,showSelectedLangs:t=!1,selectedLangs:s,showCustomLanguage:l,stretch:$,disableDelete:k,buttonProps:I,borderColorLight:R,...U})=>{const{formatMessage:d}=D(),[z,b]=o.useState(""),N=o.useMemo(()=>({label:d(v.custom)+" (C-)",value:"c-"}),[d]),y=o.useMemo(()=>x?[...e||[],...s?.map(a=>a.code)||[]]:e,[x,e,s]),{languagesAsOptions:j,formattedLanguages:S}=ee({query:z,whitelistCodes:u}),A=o.useMemo(()=>{const a=j.filter(c=>!y?.includes(c.value.code));return l&&a.unshift(N),a},[N,j,l,y]),E=o.useCallback(({value:a})=>{if(a==="c-")C({code:"c-",name:d(v.custom),nativeName:d(v.custom),fallbacks:[]});else{const c=Y[a.code];c&&C(c)}},[d,C]),F=o.useCallback(a=>
1{if(!T||!s)return;const c=s.find(W=>W.name===a);f?.(c)},[f,s]),H=o.useCallback(a=>{b(a.trim())},[b]),g=o.useMemo(()=>s?.map(a=>S.find(c=>a.code===c.code)||a),[S,s]),P=o.useMemo(()=>i||(t&&g&&g.length>0?g.map(a=>`${a.formattedName||a.nativeName||a.name} (${a.code.toUpperCase()})`).join(", "):d(v.label)),[d,g,i,t]);return h.jsx("div",{id:"language",children:h.jsxs(Z,{reverse:w,stretch:$,children:[p&&h.jsx(_,{noPadding:n,maxContentTags:M,...G("language-tags"),children:g&&g.map(a=>h.jsx(K,{handleRemoveTag:F,tagValue:a.name,disabled:k,children:`${a.formattedName||a.nativeName||a.name} (${a.code.toUpperCase()})`},a.code))}),h.jsx(J,{...U,dark:r,borderColorLight:R,label:P,onSelect:E,searchMode:"inline",onSearchChange:H,options:A,onFocusSearch:m,buttonProps:I})]})})};export{oe as L,v as m,ee as u};

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.