import{Ir as e}from"./i18n-CsN8OUP9.js";var t=`CommandOrControl+Shift+Space`,n=e({enabled:!0,error:null,registered:null,shortcut:t});function r(e){e&&n.set({enabled:e.enabled===!0,error:e.error??null,registered:e.registered===!0,shortcut:typeof e.shortcut==`string`&&e.shortcut?e.shortcut:t})}function i(){return typeof window<`u`&&typeof window.hermesDesktop?.quickEntry?.getSettings==`function`}async function a(){if(i())try{r(await window.hermesDesktop.quickEntry.getSettings())}catch{}}async function o(e){if(!i())return;let t=n.get();n.set({...t,...e,registered:t.registered});try{r(await window.hermesDesktop.quickEntry.setSettings(e))}catch{n.set(t)}}var s=`current`,c={connected:!1,draft:``,sessions:[],submitting:!1,target:s,visible:!0};function l(e,t){switch(t.type){case`blur`:case`dismiss`:return{send:null,state:{...e,draft:``,submitting:!1,target:s,visible:!1}};case`edit`:return{send:null,state:{...e,draft:t.draft}};case`shown`:return{send:null,state:{...e,draft:``,submitting:!1,target:s,visible:!0}};case`state`:{let n=t.connected&&(e.target===`current`||e.target===`new`||t.sessions.some(t=>t.id===e.target));return{send:null,state:{...e,connected:t.connected,sessions:t.sessions,target:n?e.target:s}}}case`submit`:{let t=e.draft.trim();return!t||e.submitting||!e.connected?{send:null,state:e}:{send:{target:e.target,text:t},state:{...e,draft:``,submitting:!0,visible:!1}}}case`target`:return{send:null,state:{...e,target:t.target}};default:return{send:null,state:e}}}var u=null,d=null;function f(e){u=e}function p(e){if(typeof e==`string`)return e.trim()?{target:s,text:e}:null;if(!e||typeof e!=`object`)return null;let t=e,n=typeof t.text==`string`?t.text:``;return n.trim()?{target:typeof t.target==`string`&&t.target?t.target:s,text:n}:null}function m(){let e=typeof window>`u`?void 0:window.hermesDesktop?.quickEntry;return!e?.onSubmit||d?()=>{}:(d=e.onSubmit(e=>{let t=p(e);t&&u?.(t)}),()=>{d?.(),d=null})}export{m as a,l as c,i,o as l,t as n,c as o,s as r,a as s,n as t,f as u};