import{M as H,d as te,u as se,c as oe,a5 as le,a6 as ae,a7 as ie,w as M,e as v,i as u,y as _,h as t,P as S,g as T,t as i,f as y,E as F,z as b,q as N,F as re,G as ne,r as h,k as p,x as ue,o as r,T as L,a8 as ce,a9 as de,aa as j,_ as ve}from"./index-D92x6h1h.js";import{S as pe}from"./SearchInput-DBHWpJgW.js";import{B as ge}from"./bug-CknZEDL-.js";import{C as fe}from"./circle-x-MT_qQnVa.js";/**
 * @license lucide-vue-next v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ye=H("ArrowDownToLineIcon",[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]]);/**
 * @license lucide-vue-next v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const _e=H("ClipboardCopyIcon",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]);async function be(s){try{if(typeof navigator<"u"&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(s),!0}catch{}if(typeof document>"u")return!1;try{const e=document.createElement("textarea");e.value=s,e.setAttribute("readonly",""),e.style.position="fixed",e.style.top="-9999px",e.style.left="-9999px",e.style.opacity="0",document.body.appendChild(e),e.select();const c=document.execCommand("copy");return e.remove(),c}catch{return!1}}function he(){return{copyText:be}}function me(s){return s.text.length>0||s.subsystems.size>0||s.severities.size>0}function we(s,e,c){if(e.length===0)return!0;if(c){const m=xe(e);return m!==null&&m.test(s)}return s.toLowerCase().includes(e.toLowerCase())}function ke(s,e){return e.subsystems.size>0&&!e.subsystems.has(s.subsys)||e.severities.size>0&&!e.severities.has(s.severity)?!1:we(s.body,e.text,e.textIsRegex)}function xe(s){try{return new RegExp(s,"i")}catch{return null}}const Ce={class:"log-view"},Se={class:"log-view__toolbar"},Te={class:"log-view__count","aria-live":"polite"},Le={class:"log-view__filter-row"},Ve=["aria-pressed"],Ee={key:0,class:"log-view__banner"},ze={class:"log-view__ts"},Be={class:"log-view__subsys"},Fe={class:"log-view__body-text"},Ie={key:1,class:"log-view__empty"},Ae={key:2,class:"log-view__empty"},De=te({__name:"LogView",setup(s){const{t:e}=se(),c=oe(),m=le(),{lines:d,bufferFull:$,debugEnabled:w}=ae(m),{clear:q,toggleDebug:U}=m,{copyText:Y}=he(),I=h(null),{isAtBottom:V,isAtTop:G,scrollToBottom:A}=ie(I),n=h(!0);M(()=>d.value.length,()=>{n.value&&V.value&&j(()=>A())}),M(V,l=>{l||(n.value=!1)});function K(){n.value?n.value=!1:(n.value=!0,j(()=>A()))}async function P(){const l=C.value;if(l.length===0){c.info(e("Log is empty — nothing to copy."));return}const o=l.map(a=>a.raw).join(`
`);await Y(o)?c.success(e("Copied {0} line(s) to clipboard.",String(l.length))):c.error(e("Could not write to clipboard."))}function W(){q()}async function X(){await U()||c.error(e("Could not toggle debug — the server returned an error. Check your admin permission."))}const J=p(()=>e("Buffer full at {0} lines — oldest lines dropped.","5000")),E=["error","warning","notice","info","debug","trace"],x=h(""),g=h(!1),k=h([]),z=h([...E]),O=p(()=>{const l=new Set;for(const o of d.value)o.subsys&&l.add(o.subsys);return Array.from(l).sort()}),D=p(()=>({text:x.value,textIsRegex:g.value,subsystems:k.value.length===0?new Set:new Set(k.value),severities:z.value.length===E.length?new Set:new Set(z.value)})),B=p(()=>me(D.value)),C=p(()=>B.value?d.value.filter(l=>ke(l,D.value)):d.value),Q=p(()=>C.value.length),R=p(()=>d.value.length),Z=p(()=>B.value?e("{0} / {1} line(s)",String(Q.value),String(R.value)):e("{0} line(s)",String(R.value)));function ee(){x.value="",g.value=!1,k.value=[],z.value=[...E]}return(l,o)=>{const f=ue("tooltip");return r(),v("section",Ce,[u("header",Se,[_((r(),S(t(L),{severity:t(w)?void 0:"secondary",outlined:!t(w),"aria-pressed":t(w),onClick:X},{default:T(()=>[y(t(ge),{size:16,"stroke-width":2}),b(" "+i(t(w)?t(e)("Disable debug"):t(e)("Enable debug")),1)]),_:1},8,["severity","outlined","aria-pressed"])),[[f,t(w)?t(e)("Disable debug-level log streaming for this session"):t(e)("Stream debug-level lines to this session only"),void 0,{bottom:!0}]]),_((r(),S(t(L),{severity:"secondary",outlined:"",onClick:P},{default:T(()=>[y(t(_e),{size:16,"stroke-width":2}),b(" "+i(t(e)("Copy log")),1)]),_:1})),[[f,t(e)("Copy the visible log to the clipboard"),void 0,{bottom:!0}]]),_((r(),S(t(L),{severity:"secondary",outlined:"",onClick:W},{default:T(()=>[y(t(ce),{size:16,"stroke-width":2}),b(" "+i(t(e)("Clear")),1)]),_:1})),[[f,t(e)("Clear the visible log (does not affect server)"),void 0,{bottom:!0}]]),_((r(),S(t(L),{severity:n.value?void 0:"secondary",outlined:!n.value,"aria-pressed":n.value,onClick:K},{default:T(()=>[y(t(ye),{size:16,"stroke-width":2}),b(" "+i(n.value?t(e)("Tail (on)"):t(e)("Tail (paused)")),1)]),_:1},8,["severity","outlined","aria-pressed"])),[[f,n.value?t(e)("Tail mode is on — new lines auto-scroll"):t(e)("Tail mode is paused — click to resume"),void 0,{bottom:!0}]]),o[3]||(o[3]=u("span",{class:"log-view__spacer","aria-hidden":"true"},null,-1)),u("span",Te,i(Z.value),1)]),u("div",Le,[y(pe,{modelValue:x.value,"onUpdate:modelValue":o[0]||(o[0]=a=>x.value=a),class:"log-view__text-search",placeholder:t(e)("Filter visible lines…"),"aria-label":t(e)("Filter visible lines")},null,8,["modelValue","placeholder","aria-label"]),_((r(),v("button",{type:"button",class:F(["log-view__regex-toggle",{"log-view__regex-toggle--on":g.value}]),"aria-pressed":g.value,onClick:o[1]||(o[1]=a=>g.value=!g.value)},[...o[4]||(o[4]=[b(" .* ",-1)])],10,Ve)),[[f,g.value?t(e)("Regex mode is on — disable to use plain substring"):t(e)("Click to match using a regular expression"),void 0,{bottom:!0}]]),y(t(de),{modelValue:k.value,"onUpdate:modelValue":o[2]||(o[2]=a=>k.value=a),options:O.value,placeholder:t(e)("All subsystems"),filter:!0,"show-toggle-all":!1,class:"log-view__subsys-picker","aria-label":t(e)("Subsystem filter")},null,8,["modelValue","options","placeholder","aria-label"]),B.value?_((r(),v("button",{key:0,type:"button",class:"log-view__clear-filters",onClick:ee},[y(t(fe),{size:14,"stroke-width":2}),b(" "+i(t(e)("Clear filters")),1)])),[[f,t(e)("Clear all filters"),void 0,{bottom:!0}]]):N("",!0)]),t($)?(r(),v("p",Ee,i(J.value),1)):N("",!0),u("div",{class:F(["log-view__body",{"log-view__body--has-top":!t(G)&&t(d).length>0,"log-view__body--has-bottom":!t(V)&&t(d).length>0}])},[u("div",{ref_key:"scrollEl",ref:I,class:"log-view__scroll"},[C.value.length>0?(r(!0),v(re,{key:0},ne(C.value,a=>(r(),v("div",{key:a.id,class:F(["log-view__line",`log-view__line--${a.severity}`])},[u("span",ze,i(a.ts),1),u("span",Be,i(a.subsys),1),u("span",Fe,i(a.body),1)],2))),128)):t(d).length===0?(r(),v("p",Ie,i(t(e)("Waiting for log lines…")),1)):(r(),v("p",Ae,i(t(e)("No lines match the active filter.")),1))],512)],2)])}}}),He=ve(De,[["__scopeId","data-v-1f8dd86f"]]);export{He as default};
