Files
wisp-open/frontend/dist/assets/index-BNpC-7X0.js
T

3 lines
8.0 KiB
JavaScript

(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e=!1;window.toggleApiKey=function(){let t=document.getElementById(`apiKey`),n=document.getElementById(`eyeBtn`);e=!e,t.type=e?`text`:`password`,n.textContent=e?`🙈`:`👁️`},window.recordShortcut=function(){let e=document.getElementById(`recordBtn`),t=document.getElementById(`shortcutInput`),n=e=>e.metaKey||e.key===`Meta`||e.key===`OS`||e.code===`MetaLeft`||e.code===`MetaRight`;e.textContent=`Recording...`,e.disabled=!0,t.value=``;let r=``,i=e=>{e.preventDefault(),e.stopPropagation();let i=[];e.ctrlKey&&i.push(`ctrl`),e.altKey&&i.push(`alt`),e.shiftKey&&i.push(`shift`),n(e)&&i.push(`win`);let a=e.key.toLowerCase();a===`control`&&(a=`ctrl`),a===`alt`&&(a=`alt`),a===`shift`&&(a=`shift`),(a===`meta`||a===`os`)&&(a=`win`),(e.code===`MetaLeft`||e.code===`MetaRight`)&&(a=`win`),a===` `&&(a=`space`);let s=new Set(i);s.add(a);let c=Array.from(s).filter(e=>e!==a);c.push(a),r=c.join(`+`),t.value=r,[`ctrl`,`alt`,`shift`,`win`].includes(a)||o()},a=e=>{e.preventDefault(),e.stopPropagation(),r&&(r.split(`+`).every(e=>[`ctrl`,`alt`,`shift`,`win`].includes(e))&&r.includes(`+`)?setTimeout(o,100):!e.ctrlKey&&!e.altKey&&!e.shiftKey&&!n(e)&&o())},o=()=>{if(!r){e.textContent=`Record`,e.disabled=!1,s();return}window.go.main.App.SaveSettings({shortcut:r}).then(t=>{t&&t.indexOf(`Invalid shortcut`)!==-1&&alert(t),e.textContent=`Record`,e.disabled=!1,s()})},s=()=>{window.removeEventListener(`keydown`,i,!0),window.removeEventListener(`keyup`,a,!0)};window.addEventListener(`keydown`,i,!0),window.addEventListener(`keyup`,a,!0)};function t(e){let t=document.getElementById(`historyList`);if(!e||e.length===0){t.innerHTML=`<div style="text-align: center; color: var(--text-muted); padding: 20px;">No history yet.</div>`;return}t.innerHTML=``,[...e].reverse().forEach(e=>{let n=document.createElement(`div`);n.className=`history-item`;let r=document.createElement(`span`);r.className=`history-time`,r.textContent=new Date(e.timestamp).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`});let i=document.createElement(`div`);i.textContent=e.text,n.appendChild(r),n.appendChild(i),t.appendChild(n)})}async function n(){try{t((await window.go.main.App.GetSettings()).history||[])}catch(e){console.error(`Failed to refresh history:`,e)}}async function r(){try{let 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;let n=e.app_version&&String(e.app_version).trim()||`dev`;document.getElementById(`appVersion`).textContent=n===`dev`?`dev`:`v`+n,t(e.history||[])}catch(e){console.error(`Failed to load settings:`,e)}}async function i(){try{let e=await window.go.main.App.GetMicrophones(),t=document.getElementById(`micDevice`);e.forEach(e=>{if(e.index!==-1){let n=document.createElement(`option`);n.value=e.index,n.textContent=e.name,t.appendChild(n)}})}catch(e){console.error(`Failed to load mics:`,e)}}window.saveApiKey=async function(){let e=document.getElementById(`apiKey`).value.trim();await window.go.main.App.SaveSettings({api_key:e}),a()};function a(e=`Settings Saved!`){let 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}),a()},window.saveAiModel=async function(){await window.go.main.App.SaveSettings({ai_model:document.getElementById(`aiModel`).value}),a()},window.saveLanguage=async function(){await window.go.main.App.SaveSettings({language:document.getElementById(`language`).value}),a(`Language Saved!`)},window.saveMicDevice=async function(){let e=document.getElementById(`micDevice`).value;await window.go.main.App.SaveSettings({microphone_device:e===`default`?null:parseInt(e)}),a()},window.savePrompt=async function(){await window.go.main.App.SaveSettings({ai_prompt:document.getElementById(`aiPrompt`).value.trim()}),a(`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(),t([]))};async function o(){try{let e=await window.go.main.App.CheckOnline(),t=document.getElementById(`connectionStatus`);if(e)t.innerHTML=`🟢 Online - Cloud transcription available`,t.style.background=`rgba(34, 197, 94, 0.1)`,t.style.color=`#22c55e`;else{t.innerHTML=`🔴 Offline - Install local Whisper for transcription`,t.style.background=`rgba(239, 68, 68, 0.1)`,t.style.color=`#ef4444`;let e=document.getElementById(`aiModel`);document.getElementById(`whisperModel`);for(let t of e.options)t.value!==`None`&&!t.value.startsWith(`local-`)&&(t.disabled=!0,t.text.includes(`(offline)`)||(t.text+=` (offline)`))}}catch(e){console.error(`Connection check failed:`,e)}}async function s(){try{let e=await window.go.main.App.GetWhisperInfo(),t=document.getElementById(`whisperModel`),n=t.querySelector(`option[value^="local-"]`);if(n&&n.remove(),e.installed){document.getElementById(`whisperNotInstalled`).style.display=`none`,document.getElementById(`whisperInstalled`).style.display=`block`,document.getElementById(`installedModel`).textContent=e.model+` model`;let n=document.createElement(`option`);n.value=`local-`+e.model,n.textContent=`🖥️ Local - `+e.model+` (offline)`,n.style.fontWeight=`bold`,t.insertBefore(n,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(){let e=document.getElementById(`whisperModelSelect`).value,t=document.getElementById(`installBtn`);t.disabled=!0,t.textContent=`Starting installation...`;try{let t=await window.go.main.App.InstallWhisper(e);alert(t+`
A terminal window will open showing the installation progress. This may take several minutes depending on your internet speed.`),setTimeout(s,5e3)}catch(e){alert(`Installation failed: `+e)}t.disabled=!1,t.textContent=`🚀 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{let e=await window.go.main.App.UninstallWhisper();alert(e),s()}catch(e){alert(`Uninstall failed: `+e)}};async function c(){try{if(navigator.userAgent.toLowerCase().includes(`linux`)){let e=document.getElementById(`offlineWhisperSection`);e&&(e.style.display=`none`);let t=document.getElementById(`startupLabel`);t&&(t.innerText=`Run on Linux OS Startup`)}}catch(e){console.error(`Failed to get environment:`,e)}if(await r(),await i(),await o(),await s(),window.runtime&&typeof window.runtime.EventsOn==`function`&&window.runtime.EventsOn(`history:updated`,function(){n()}),navigator.userAgent.toLowerCase().includes(`linux`)){let e=document.getElementById(`whisperModel`);e&&Array.from(e.options).forEach(e=>{e.value.startsWith(`local-`)&&e.remove()})}}c();