Files
wisp-open/frontend/dist/assets/index.c6252eaf.js
T
2026-04-09 22:57:06 -07:00

4 lines
7.5 KiB
JavaScript

(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))a(n);new MutationObserver(n=>{for(const i of n)if(i.type==="childList")for(const r of i.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&a(r)}).observe(document,{childList:!0,subtree:!0});function o(n){const i={};return n.integrity&&(i.integrity=n.integrity),n.referrerpolicy&&(i.referrerPolicy=n.referrerpolicy),n.crossorigin==="use-credentials"?i.credentials="include":n.crossorigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function a(n){if(n.ep)return;n.ep=!0;const i=o(n);fetch(n.href,i)}})();let u=!1;window.toggleApiKey=function(){const e=document.getElementById("apiKey"),t=document.getElementById("eyeBtn");u=!u,e.type=u?"text":"password",t.textContent=u?"\u{1F648}":"\u{1F441}\uFE0F"};window.recordShortcut=function(){const e=document.getElementById("recordBtn"),t=document.getElementById("shortcutInput");e.textContent="Recording...",e.disabled=!0,t.value="";let o="";const a=s=>{s.preventDefault(),s.stopPropagation();const c=[];s.ctrlKey&&c.push("ctrl"),s.altKey&&c.push("alt"),s.shiftKey&&c.push("shift"),(s.metaKey||s.key==="Meta"||s.key==="OS")&&c.push("win");let l=s.key.toLowerCase();l==="control"&&(l="ctrl"),l==="alt"&&(l="alt"),l==="shift"&&(l="shift"),(l==="meta"||l==="os")&&(l="win"),l===" "&&(l="space");const p=new Set(c);p.add(l);const y=Array.from(p).filter(f=>f!==l);y.push(l),o=y.join("+"),t.value=o,["ctrl","alt","shift","win"].includes(l)||i()},n=s=>{s.preventDefault(),s.stopPropagation(),o&&(o.split("+").every(l=>["ctrl","alt","shift","win"].includes(l))&&o.includes("+")?setTimeout(i,100):!s.ctrlKey&&!s.altKey&&!s.shiftKey&&!s.metaKey&&i())},i=()=>{if(!o){e.textContent="Record",e.disabled=!1,r();return}window.go.main.App.SaveSettings({shortcut:o}).then(()=>{e.textContent="Record",e.disabled=!1,r()})},r=()=>{window.removeEventListener("keydown",a,!0),window.removeEventListener("keyup",n,!0)};window.addEventListener("keydown",a,!0),window.addEventListener("keyup",n,!0)};async function w(){try{const e=await window.go.main.App.GetSettings();document.getElementById("apiKey").value=e.api_key||"",document.getElementById("shortcutInput").value=e.shortcut||"alt+z",document.getElementById("whisperModel").value=e.whisper_model||"whisper-large-v3-turbo",document.getElementById("aiModel").value=e.ai_model||"llama-3.3-70b-versatile",document.getElementById("aiPrompt").value=e.ai_prompt||"",document.getElementById("language").value=e.language||"en",document.getElementById("startupToggle").checked=e.startup||!1;const t=e.history||[],o=document.getElementById("historyList");t.length>0&&(o.innerHTML="",[...t].reverse().forEach(a=>{const n=document.createElement("div");n.className="history-item";const i=document.createElement("span");i.className="history-time",i.textContent=new Date(a.timestamp).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});const r=document.createElement("div");r.textContent=a.text,n.appendChild(i),n.appendChild(r),o.appendChild(n)}))}catch(e){console.error("Failed to load settings:",e)}}async function g(){try{const e=await window.go.main.App.GetMicrophones(),t=document.getElementById("micDevice");e.forEach(o=>{if(o.index!==-1){const a=document.createElement("option");a.value=o.index,a.textContent=o.name,t.appendChild(a)}})}catch(e){console.error("Failed to load mics:",e)}}window.saveApiKey=async function(){const e=document.getElementById("apiKey").value.trim();await window.go.main.App.SaveSettings({api_key:e}),d()};function d(e="Settings Saved!"){const t=document.getElementById("saveStatus");t.textContent=e,t.classList.add("show"),setTimeout(()=>t.classList.remove("show"),2e3)}window.saveWhisperModel=async function(){await window.go.main.App.SaveSettings({whisper_model:document.getElementById("whisperModel").value}),d()};window.saveAiModel=async function(){await window.go.main.App.SaveSettings({ai_model:document.getElementById("aiModel").value}),d()};window.saveLanguage=async function(){await window.go.main.App.SaveSettings({language:document.getElementById("language").value}),d("Language Saved!")};window.saveMicDevice=async function(){const e=document.getElementById("micDevice").value;await window.go.main.App.SaveSettings({microphone_device:e==="default"?null:parseInt(e)}),d()};window.savePrompt=async function(){await window.go.main.App.SaveSettings({ai_prompt:document.getElementById("aiPrompt").value.trim()}),d("Prompt Saved!")};window.toggleStartup=async function(){await window.go.main.App.ToggleStartup(document.getElementById("startupToggle").checked)};window.clearHistory=async function(){confirm("Clear all history?")&&(await window.go.main.App.ClearHistory(),document.getElementById("historyList").innerHTML='<div style="text-align: center; color: var(--text-muted); padding: 20px;">No history yet.</div>')};async function h(){try{const e=await window.go.main.App.CheckOnline(),t=document.getElementById("connectionStatus");if(e)t.innerHTML="\u{1F7E2} Online - Cloud transcription available",t.style.background="rgba(34, 197, 94, 0.1)",t.style.color="#22c55e";else{t.innerHTML="\u{1F534} Offline - Install local Whisper for transcription",t.style.background="rgba(239, 68, 68, 0.1)",t.style.color="#ef4444";const o=document.getElementById("aiModel"),a=document.getElementById("whisperModel");for(let n of o.options)n.value!=="None"&&!n.value.startsWith("local-")&&(n.disabled=!0,n.text.includes("(offline)")||(n.text+=" (offline)"))}}catch(e){console.error("Connection check failed:",e)}}async function m(){try{const e=await window.go.main.App.GetWhisperInfo(),t=document.getElementById("whisperModel"),o=t.querySelector('option[value^="local-"]');if(o&&o.remove(),e.installed){document.getElementById("whisperNotInstalled").style.display="none",document.getElementById("whisperInstalled").style.display="block",document.getElementById("installedModel").textContent=e.model+" model";const a=document.createElement("option");a.value="local-"+e.model,a.textContent="\u{1F5A5}\uFE0F Local - "+e.model+" (offline)",a.style.fontWeight="bold",t.insertBefore(a,t.firstChild)}else document.getElementById("whisperNotInstalled").style.display="block",document.getElementById("whisperInstalled").style.display="none"}catch(e){console.error("Whisper status check failed:",e)}}window.installWhisper=async function(){const e=document.getElementById("whisperModelSelect").value,t=document.getElementById("installBtn");t.disabled=!0,t.textContent="Starting installation...";try{const o=await window.go.main.App.InstallWhisper(e);alert(o+`
A terminal window will open showing the installation progress. This may take several minutes depending on your internet speed.`),setTimeout(m,5e3)}catch(o){alert("Installation failed: "+o)}t.disabled=!1,t.textContent="\u{1F680} Install Offline Whisper"};window.uninstallWhisper=async function(){if(!!confirm("Are you sure you want to uninstall offline Whisper? This will delete the downloaded model."))try{const e=await window.go.main.App.UninstallWhisper();alert(e),m()}catch(e){alert("Uninstall failed: "+e)}};async function v(){try{if(navigator.userAgent.toLowerCase().includes("linux")){const t=document.getElementById("offlineWhisperSection");t&&(t.style.display="none");const o=document.getElementById("startupLabel");o&&(o.innerText="Run on Linux OS Startup")}}catch(e){console.error("Failed to get environment:",e)}if(await w(),await g(),await h(),await m(),navigator.userAgent.toLowerCase().includes("linux")){const e=document.getElementById("whisperModel");e&&Array.from(e.options).forEach(t=>{t.value.startsWith("local-")&&t.remove()})}}v();