import{Ir as e,o as t}from"./i18n-CsN8OUP9.js";var n=0,r=new Map,i=e([]);function a(e){return e===`error`||e===`warning`?0:5e3}function o(e,t){return e===`error`||e===`warning`||t?`default`:`bottom-right`}function s(e){return e.replace(/^Error:\s*/,``).trim()}function c(e){return/no space left on device/i.test(e)||/not enough space/i.test(e)||/database or disk is full/i.test(e)||/\bENOSPC\b/i.test(e)||/disk full/i.test(e)||/full disk/i.test(e)}var l=[{test:c,summarize:()=>t(`notifications.errors.diskFull`)},{test:e=>/['"]code['"]\s*:\s*['"]gateway_auth_failed['"]/i.test(e),summarize:()=>t(`notifications.errors.gatewayAuthFailed`)},{test:e=>/incorrect api key provided/i.test(e)||/['"]code['"]\s*:\s*['"]invalid_api_key['"]/i.test(e),summarize:e=>{let n=e.match(/(?:error code|status(?:Code)?)[^\d]*(\d{3})/i)?.[1];return n?t(`notifications.errors.openaiRejectedApiKeyWithStatus`,n):t(`notifications.errors.openaiRejectedApiKey`)}},{test:e=>/neither voice_tools_openai_key nor openai_api_key is set/i.test(e),summarize:()=>t(`notifications.errors.openaiTtsNeedsKey`)},{test:e=>/ELEVENLABS_API_KEY not set/i.test(e)||/ElevenLabs STT API error \(HTTP 401\)/i.test(e),summarize:e=>/ELEVENLABS_API_KEY not set/i.test(e)?t(`notifications.errors.elevenLabsNeedsKey`):t(`notifications.errors.elevenLabsRejectedKey`)},{test:e=>/method not allowed/i.test(e),summarize:()=>t(`notifications.errors.methodNotAllowed`)},{test:e=>/microphone permission/i.test(e),summarize:()=>t(`notifications.errors.microphonePermission`)}];function u(e,t){let n=l.find(t=>t.test(e));return n?n.summarize(e):e.length>180?t:e||t}function d(e,t){let n=e instanceof Error?e.message:typeof e==`string`?e:t,r=s(n.match(/Error invoking remote method '[^']+': Error: (.+)$/)?.[1]??n),i=r.match(/"detail"\s*:\s*"([^"]+)"/)?.[1]??r,a=u(i,t);return{message:a,detail:i===a?void 0:i}}function f(e){let t=e.kind??`info`,s=e.id??`${Date.now()}-${n++}`,c={id:s,kind:t,icon:e.icon,accentColor:e.accentColor,meta:e.meta,title:e.title,message:e.message,detail:e.detail,action:e.action,onDismiss:e.onDismiss,createdAt:Date.now(),placement:e.placement??o(t,e.action)};window.clearTimeout(r.get(s)),r.delete(s),i.set([c,...i.get().filter(e=>e.id!==s)].slice(0,4));let l=e.durationMs??a(t);return l>0&&r.set(s,window.setTimeout(()=>m(s),l)),s}function p(e,t){let n=d(e,t);return f({kind:`error`,title:t,message:n.message,detail:n.detail})}function m(e){window.clearTimeout(r.get(e)),r.delete(e);let t=i.get().find(t=>t.id===e);i.set(i.get().filter(t=>t.id!==e)),t?.onDismiss?.()}function h(){for(let e of r.values())window.clearTimeout(e);r.clear();let e=i.get();i.set([]);for(let t of e)t.onDismiss?.()}export{f as a,c as i,h as n,p as o,m as r,d as s,i as t};