import{a as v,w as $,o as B,b as F,f as d,t as n,x as u,y as V,g as e,i as c,F as y,z as T,A as U,B as i,C as k,D as O,K as j,G as p,J as S,e as R}from"./vue-core-Ewsep5yp.js";import{h as E,a as I,r as N}from"./inertia-Ckpa2qIg.js";import{A as z}from"./AdminLayout-j5U7h0Jh.js";import{a as M,Y as P,a1 as Y,c as q,n as G,ap as H,s as J}from"./heroicons-BDwnQUYs.js";import"./PwaInstallPrompt-DoLwZwXF.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";import"./LocaleSwitcher-9HahHW1U.js";import"./app-oHOEXACs.js";import"./monaco-JW8DSIgC.js";import"./ConfirmDialog-CAAUJZjl.js";import"./OnoxLogo-CeDonOUJ.js";import"./useConfirm-BuAOQkqU.js";const K={class:"mb-4 grid grid-cols-2 gap-2 sm:grid-cols-4 lg:grid-cols-6"},Q=["onClick"],W={class:"text-xs font-medium"},X=["title"],Z={class:"mb-3 flex flex-wrap items-center gap-3 rounded-xl border border-slate-200 bg-white p-3 shadow-sm"},ee={class:"relative flex-1 min-w-[200px]"},te=["value"],se=["value"],le=["value"],oe=["value"],re={class:"flex items-center gap-1.5 text-xs"},ae={class:"flex items-center gap-1.5 text-xs"},ne={class:"flex items-center gap-1"},ie={key:0,class:"mb-3 rounded-lg border border-red-200 bg-red-50 p-3 text-sm text-red-800 flex items-start gap-2"},de={class:"font-mono text-xs"},ue={class:"rounded-xl border border-slate-700 bg-slate-900 shadow-lg overflow-hidden"},ce={class:"border-b border-slate-700 px-4 py-2 flex items-center justify-between"},pe={class:"flex items-center gap-2 text-xs"},ve={class:"font-mono text-slate-300"},xe={class:"flex items-center gap-3 text-xs"},ge={key:0,class:"text-emerald-400 flex items-center gap-1"},me={class:"text-slate-500"},fe={class:"max-h-[600px] overflow-y-auto font-mono text-xs"},be={key:0,class:"px-4 py-12 text-center text-slate-500"},he={class:"text-slate-500 flex-shrink-0"},we={class:"text-slate-200 break-all"},Be={__name:"Logs",props:{sources:Object,current_source:String,logs:Array,filters:Object,error:{type:String,default:null}},setup(r){const o=r,m=v(o.logs||[]),x=v(o.error),f=v(""),_=v(!0),h=v(!1),w=v(null),g=(l={})=>{N.get(route("admin.logs.index"),{source:l.source??o.current_source,level:l.level??o.filters.level,lines:l.lines??o.filters.lines,filter:l.filter??o.filters.filter,since:l.since??o.filters.since},{preserveState:!0,replace:!0})},C=async()=>{try{const{data:l}=await I.get(route("admin.logs.refresh"),{params:{source:o.current_source,lines:o.filters.lines,filter:o.filters.filter,since:o.filters.since,level:o.filters.level}});m.value=l.logs??[],x.value=l.error??null,w.value=l.fetched_at??null}catch(l){x.value=l?.response?.data?.message||l.message||"refresh_failed"}};$(()=>o.logs,l=>{m.value=l||[]}),$(()=>o.error,l=>{x.value=l});const b=R(()=>{if(!f.value)return m.value;const l=f.value.toLowerCase();return m.value.filter(t=>(t.message||"").toLowerCase().includes(l))}),A=l=>({info:"text-slate-400",notice:"text-blue-400",warn:"text-amber-400",warning:"text-amber-400",error:"text-red-400",crit:"text-red-500 font-bold",debug:"text-slate-500"})[l]||"text-slate-300",D=()=>{const l=b.value.map(a=>`[${a.time}] ${(a.level||"info").toUpperCase()}: ${a.message}`).join(`
`),t=new Blob([l],{type:"text/plain"}),s=document.createElement("a");s.href=URL.createObjectURL(t),s.download=`${o.current_source}-${new Date().toISOString().slice(0,10)}.log`,s.click()};let L;return B(()=>{L=setInterval(()=>{h.value&&C()},1e4)}),F(()=>clearInterval(L)),(l,t)=>(c(),d(y,null,[n(u(E),{title:"Sistem Logları"}),n(z,null,{header:V(()=>[...t[7]||(t[7]=[p("Sistem Logları",-1)])]),default:V(()=>[e("div",K,[(c(!0),d(y,null,T(r.sources,(s,a)=>(c(),d("button",{key:a,onClick:ye=>g({source:a}),class:U(["rounded-lg border p-3 text-left transition",r.current_source===a?"border-indigo-400 bg-indigo-50 ring-1 ring-indigo-300":"border-slate-200 bg-white hover:bg-slate-50"])},[e("div",W,i(s.name),1),e("div",{class:"font-mono text-[10px] text-slate-400 truncate",title:s.path},i(s.path),9,X)],10,Q))),128))]),e("div",Z,[e("div",ee,[n(u(M),{class:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400"}),k(e("input",{"onUpdate:modelValue":t[0]||(t[0]=s=>f.value=s),type:"text",placeholder:"Yerel arama (anlık)...",class:"w-full rounded-lg border border-slate-300 bg-white py-1.5 pl-9 pr-3 text-sm"},null,512),[[O,f.value]])]),e("input",{value:r.filters.filter||"",onChange:t[1]||(t[1]=s=>g({filter:s.target.value})),placeholder:"grep -F (sunucu tarafı)",type:"text",class:"w-44 rounded-lg border border-slate-300 bg-white py-1.5 px-3 text-sm font-mono"},null,40,te),e("select",{value:r.filters.level||"",onChange:t[2]||(t[2]=s=>g({level:s.target.value})),class:"rounded-lg border border-slate-300 bg-white px-3 py-1.5 text-sm"},[...t[8]||(t[8]=[e("option",{value:""},"Tüm seviyeler",-1),e("option",{value:"info"},"info",-1),e("option",{value:"notice"},"notice",-1),e("option",{value:"warn"},"warn",-1),e("option",{value:"error"},"error",-1),e("option",{value:"crit"},"crit",-1)])],40,se),e("select",{value:r.filters.since||"",onChange:t[3]||(t[3]=s=>g({since:s.target.value})),class:"rounded-lg border border-slate-300 bg-white px-3 py-1.5 text-sm"},[...t[9]||(t[9]=[e("option",{value:""},"Tüm zaman",-1),e("option",{value:"5m"},"Son 5 dakika",-1),e("option",{value:"15m"},"Son 15 dakika",-1),e("option",{value:"1h"},"Son 1 saat",-1),e("option",{value:"1d"},"Son 24 saat",-1)])],40,le),e("select",{value:r.filters.lines,onChange:t[4]||(t[4]=s=>g({lines:parseInt(s.target.value)})),class:"rounded-lg border border-slate-300 bg-white px-3 py-1.5 text-sm"},[...t[10]||(t[10]=[e("option",{value:100},"Son 100",-1),e("option",{value:200},"Son 200",-1),e("option",{value:500},"Son 500",-1),e("option",{value:1e3},"Son 1000",-1),e("option",{value:5e3},"Son 5000",-1)])],40,oe),e("label",re,[k(e("input",{"onUpdate:modelValue":t[5]||(t[5]=s=>_.value=s),type:"checkbox"},null,512),[[j,_.value]]),t[11]||(t[11]=e("span",null,"Aşağı kaydır",-1))]),e("label",ae,[k(e("input",{"onUpdate:modelValue":t[6]||(t[6]=s=>h.value=s),type:"checkbox"},null,512),[[j,h.value]]),e("span",ne,[n(u(P),{class:"h-3.5 w-3.5"}),t[12]||(t[12]=p(" Oto-yenile (10sn)",-1))])]),e("button",{onClick:C,class:"inline-flex items-center gap-1 rounded-lg border border-slate-300 bg-white px-3 py-1.5 text-sm hover:bg-slate-50"},[n(u(Y),{class:"h-4 w-4"}),t[13]||(t[13]=p(" Yenile ",-1))]),e("button",{onClick:D,class:"inline-flex items-center gap-1 rounded-lg border border-slate-300 bg-white px-3 py-1.5 text-sm hover:bg-slate-50"},[n(u(q),{class:"h-4 w-4"}),t[14]||(t[14]=p(" İndir (.log) ",-1))])]),x.value?(c(),d("div",ie,[n(u(G),{class:"h-4 w-4 flex-shrink-0 mt-0.5"}),e("div",null,[t[15]||(t[15]=e("strong",null,"Log okunamadı:",-1)),e("span",de,i(x.value),1)])])):S("",!0),e("div",ue,[e("div",ce,[e("div",pe,[n(u(H),{class:"h-4 w-4 text-slate-400"}),e("span",ve,i(r.sources[r.current_source]?.path),1)]),e("div",xe,[w.value?(c(),d("span",ge,[n(u(J),{class:"h-3.5 w-3.5"}),p(" Son: "+i(new Date(w.value).toLocaleTimeString("tr-TR")),1)])):S("",!0),e("span",me,i(b.value.length)+" satır",1)])]),e("div",fe,[b.value.length===0?(c(),d("div",be," Eşleşen log yok. ")):S("",!0),(c(!0),d(y,null,T(b.value,(s,a)=>(c(),d("div",{key:a,class:"px-4 py-1 hover:bg-slate-800/50 flex gap-3"},[e("span",he,i(s.time),1),e("span",{class:U(["uppercase font-bold flex-shrink-0 w-12",A(s.level)])},i(s.level),3),e("span",we,i(s.message),1)]))),128))])]),t[16]||(t[16]=e("p",{class:"mt-3 text-xs text-slate-500"},[p(" Veri kaynağı: sysapi "),e("code",{class:"font-mono"},"log-tail"),p(" · Path whitelist defense-in-depth (PHP + bash) · grep -F literal arama (regex DoS engellendi). ")],-1))]),_:1})],64))}};export{Be as default};
