1import{r as l,j as e,u as p,_ as T,i as k,h as B,C as V,H as X,k as F,$,J as G,a0 as H,G as Q,t as C,c as A}from"../index.js";import{w as P}from"./Gauge-e6762f4d.js";function _({settings:t}){const[n,i]=l.useState(t==null?void 0:t.OpenAiKey),[o,r]=l.useState(t==null?void 0:t.OpenAiKey);return e.jsxs("div",{className:"flex gap-x-7 gap-[36px] mt-1.5",children:[e.jsxs("div",{className:"flex flex-col w-60",children:[e.jsx("label",{className:"text-white text-sm font-semibold block mb-3",children:"API Key"}),e.jsx("input",{type:"password",name:"OpenAiKey",className:"border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5",placeholder:"OpenAI API Key",defaultValue:t!=null&&t.OpenAiKey?"*".repeat(20):"",required:!0,autoComplete:"off",spellCheck:!1,onChange:d=>i(d.target.value),onBlur:()=>r(n)})]}),e.jsxs("div",{className:"flex flex-col w-60",children:[e.jsx("label",{className:"text-white text-sm font-semibold block mb-3",children:"Whisper Model"}),e.jsx("select",{disabled:!0,className:"border-none flex-shrink-0 bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5",children:e.jsx("option",{disabled:!0,selected:!0,children:"Whisper Large"})})]})]})}function q({settings:t}){const{t:n}=p(),[i,o]=l.useState(t==null?void 0:t.WhisperModelPref);return e.jsxs("div",{className:"w-full flex flex-col gap-y-4",children:[e.jsx(J,{model:i}),e.jsx("div",{className:"w-full flex items-center gap-4",children:e.jsxs("div",{className:"flex flex-col w-60",children:[e.jsx("label",{className:"text-white text-sm font-semibold block mb-3",children:n("common.selection")}),e.jsx("select",{name:"WhisperModelPref",defaultValue:i,onChange:r=>o(r.target.value),className:"border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5",children:["Xenova/whisper-small","Xenova/whisper-large"].map((r,d)=>e.jsx("option",{value:r,children:r},d))})]})})]})}function J({model:t}){switch(t){case"Xenova/whisper-small":return e.jsx(O,{});case"Xenova/whisper-large":return e.jsx(U,{});default:return e.jsx(O,{})}}function O(){const{t}=p();return e.jsx("div",{className:"flex flex-col md:flex-row md:items-center gap-x-2 text-white mb-4 bg-blue-800/30 w-fit rounded-lg px-4 py-2",children:e.jsxs("div",{className:"gap-x-2 flex items-center",children:[e.jsx(P,{size:25}),e.jsxs("p",{className:"text-sm",children:[t("transcription.warn-start"),e.jsx("br",{}),t("transcription.warn-recommend"),e.jsx("br",{}),e.jsx("br",{}),e.jsxs("i",{children:[t("transcription.warn-end")," (250mb)"]})]})]})})}function U(){const{t}=p();return e.jsx("div",{className:"flex flex-col md:flex-row md:items-center gap-x-2 text-white mb-4 bg-blue-800/30 w-fit rounded-lg px-4 py-2",children:e.jsxs("div",{className:"gap-x-2 flex items-center",children:[e.jsx(P,{size:25}),e.jsxs("p",{className:"text-sm",children:[t("transcription.warn-start"),e.jsx("br",{}),t("transcription.warn-recommend"),e.jsx("br",{}),e.jsx("br",{}),e.jsxs("i",{children:[t("transcription.warn-end")," (1.56GB)"]})]})]})})}const w=[{name:"OpenAI",value:"openai",logo:H,options:t=>e.jsx(_,{settings:t}),description:"Leverage the OpenAI Whisper-large model using your API key."},{name:"AnythingLLM Built-In",value:"local",logo:Q,options:t=>e.jsx(q,{settings:t}),description:"Run a built-in whisper model on this instance privately."}];function ee(){var N;const[t,n]=l.useState(!1),[i,o]=l.useState(!1),[r,d]=l.useState(null),[L,I]=l.useState(!0),[u,h]=l.useState(""),[z,M]=l.useState([]),[c,v]=l.useState(null),[f,x]=l.useState(!1),b=l.useRef(null),{t:g}=p(),y=async s=>{s.preventDefault();const a=s.target,S={WhisperProvider:c},D=new FormData(a);for(var[R,E]of D.entries())S[R]=E;const{error:j}=await C.updateSystem(S);n(!0),j?A(`Failed to save preferences: ${j}`,"error"):A("Transcription preferences saved successfully.","success"),n(!1),o(!!j)},W=s=>{h(""),v(s),x(!1),o(!0)},K=()=>{u.length>0?(h(""),b.current&&(b.current.value="")):x(!f)};l.useEffect(()=>{async function s(){const a=await C.keys();d(a),v((a==null?void 0:a.WhisperProvider)||"local"),I(!1)}s()},[]),l.useEffect(()=>{const s=w.filter(a=>a.name.toLowerCase().includes(u.toLowerCase()));M(s)},[u,c]);const m=w.find(s=>s.value===c);return e.jsxs("div",{className:"w-screen h-screen overflow-hidden bg-theme-bg
1-container flex",children:[e.jsx(T,{}),L?e.jsx("div",{style:{height:k?"100%":"calc(100% - 32px)"},className:"relative md:ml-[2px] md:mr-[16px] md:my-[16px] md:rounded-[16px] bg-theme-bg-secondary w-full h-full overflow-y-scroll p-4 md:p-0",children:e.jsx("div",{className:"w-full h-full flex justify-center items-center",children:e.jsx(B,{})})}):e.jsx("div",{style:{height:k?"100%":"calc(100% - 32px)"},className:"relative md:ml-[2px] md:mr-[16px] md:my-[16px] md:rounded-[16px] bg-theme-bg-secondary w-full h-full overflow-y-scroll p-4 md:p-0",children:e.jsx("form",{onSubmit:y,className:"flex w-full",children:e.jsxs("div",{className:"flex flex-col w-full px-1 md:pl-6 md:pr-[50px] py-16 md:py-6",children:[e.jsxs("div",{className:"w-full flex flex-col gap-y-1 pb-6 border-white light:border-theme-sidebar-border border-b-2 border-opacity-10",children:[e.jsx("div",{className:"flex gap-x-4 items-center",children:e.jsx("p",{className:"text-lg leading-6 font-bold text-white",children:g("transcription.title")})}),e.jsx("p",{className:"text-xs leading-[18px] font-base text-white text-opacity-60",children:g("transcription.description")})]}),e.jsx("div",{className:"w-full justify-end flex",children:i&&e.jsx(V,{onClick:()=>y(),className:"mt-3 mr-0 -mb-14 z-10",children:t?"Saving...":"Save changes"})}),e.jsx("div",{className:"text-base font-bold text-white mt-6 mb-4",children:g("transcription.provider")}),e.jsxs("div",{className:"relative",children:[f&&e.jsx("div",{className:"fixed top-0 left-0 w-full h-full bg-black bg-opacity-70 backdrop-blur-sm z-10",onClick:()=>x(!1)}),f?e.jsx("div",{className:"absolute top-0 left-0 w-full max-w-[640px] max-h-[310px] min-h-[64px] bg-theme-settings-input-bg rounded-lg flex flex-col justify-between cursor-pointer border-2 border-primary-button z-20",children:e.jsxs("div",{className:"w-full flex flex-col gap-y-1",children:[e.jsxs("div",{className:"flex items-center sticky top-0 z-10 border-b border-[#9CA3AF] mx-4 bg-theme-settings-input-bg",children:[e.jsx(X,{size:20,weight:"bold",className:"absolute left-4 z-30 text-theme-text-primary -ml-4 my-2"}),e.jsx("input",{type:"text",name:"provider-search",autoComplete:"off",placeholder:"Search audio transcription providers",className:"border-none -ml-4 my-2 bg-transparent z-20 pl-12 h-[38px] w-full px-4 py-1 text-sm outline-none focus:outline-primary-button active:outline-primary-button outline-none text-theme-text-primary placeholder:text-theme-text-primary placeholder:font-medium",onChange:s=>h(s.target.value),ref:b,onKeyDown:s=>{s.key==="Enter"&&s.preventDefault()}}),e.jsx(F,{size:20,weight:"bold",className:"cursor-pointer text-white hover:text-x-button",onClick:K})]}),e.jsx("div",{className:"flex-1 pl-4 pr-2 flex flex-col gap-y-1 overflow-y-auto white-scrollbar pb-4 max-h-[245px]",children:z.map(s=>e.jsx($,{name:s.name,value:s.value,image:s.logo,description:s.description,checked:c===s.value,onClick:()=>W(s.value)},s.name))})]})}):e.jsxs("button",{className:"w-full max-w-[640px] h-[64px] bg-theme-settings-input-bg rounded-lg flex items-center p-[14px] justify-between cursor-pointer border-2 border-transparent hover:border-primary-button transition-all duration-300",type:"button",onClick:()=>x(!0),children:[e.jsxs("div",{className:"flex gap-x-4 items-center",children:[e.jsx("img",{src:m.logo,alt:`${m.name} logo`,className:"w-10 h-10 rounded-md"}),e.jsxs("div",{className:"flex flex-col text-left",children:[e.jsx("div",{className:"text-sm font-semibold text-white",children:m.name}),e.jsx("div",{className:"mt-1 text-xs text-description",children:m.description})]})]}),e.jsx(G,{size:24,weight:"bold",className:"text-white"})]})]}),e.jsx("div",{onChange:()=>o(!0),className:"mt-4 flex flex-col gap-y-1",children:c&&((N=w.find(s=>s.value===c))==null?void 0:N.options(r))})]})})})]})}export{ee as default};
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.