import{M as h,r,p as w}from"./index-CPuF8FlG.js";const y=h("config",()=>{const t=r(null),o=r([]),c=r([]),n=r(!1),e=r(null),i=w(()=>{var a;return((a=t.value)==null?void 0:a.config_exists)??!1});async function l(){n.value=!0,e.value=null;try{const s=await(await fetch("/api/config")).json();s.success?t.value=s.data:e.value=s.error}catch(a){e.value=String(a)}finally{n.value=!1}}async function f(){n.value=!0,e.value=null;try{const s=await(await fetch("/api/config/processes")).json();s.success?o.value=s.data.processes:e.value=s.error}catch(a){e.value=String(a)}finally{n.value=!1}}async function g(a=50){var s;n.value=!0,e.value=null;try{const u=await(await fetch(`/api/config/changelog?tail=${a}&format=raw`)).json();if(u.success){const d=Array.isArray((s=u.data)==null?void 0:s.entries)?u.data.entries:[];c.value=d.filter(v=>v!=null)}else e.value=u.error}catch(m){e.value=String(m)}finally{n.value=!1}}async function p(){n.value=!0,e.value=null;try{const s=await(await fetch("/api/config/reload",{method:"POST"})).json();return s.success&&await l(),s}catch(a){return e.value=String(a),{success:!1,error:String(a)}}finally{n.value=!1}}return{info:t,processes:o,changelog:c,loading:n,error:e,isConfigured:i,fetchInfo:l,fetchProcesses:f,fetchChangelog:g,reloadConfig:p}}),$=/\]\s+(\w+)/;function S(t){const o=t.match($);return(o==null?void 0:o[1])??""}function _(t){return typeof t=="string"?S(t).toUpperCase():(t.action??"").toUpperCase()}function A(t){if(typeof t=="string")return t;const o=t.details&&Object.keys(t.details).length>0?JSON.stringify(t.details):"{}";return`[${t.timestamp}] ${t.action} ${t.entity_type}:${t.entity_name} ${o}`}function T(t){if(typeof t=="string"){const i=t.match(/\[([^\]]+)\]\s+(\w+)\s+(.+)/);if(i){const l=new Date(i[1]),f=i[2].toLowerCase(),g=i[3];return`${l.toLocaleTimeString()} - ${f} ${g.split("{")[0].trim()}`}return t}const o=new Date(t.timestamp),c=Number.isNaN(o.getTime())?t.timestamp:o.toLocaleTimeString(),n=t.action?t.action.toLowerCase():"update",e=t.entity_type&&t.entity_name?`${t.entity_type}:${t.entity_name}`:"";return e?`${c} - ${n} ${e}`:`${c} - ${n}`}export{A as a,T as f,_ as g,y as u};
