Files
op-packages/luci-app-honk/root/etc/honk/dashboard/assets/Dns-vjK8rYCH.js
T

4 lines
21 KiB
JavaScript

import{r as p,j as a}from"./vendor-react-Bf71BWbF.js";import{u as g,aM as we,c as Ne,a0 as Ce,aT as j,aq as Te,a1 as re,ak as _e,A as Se,au as De,bo as le,a5 as V,bc as F,bp as ie,X as Y,bf as Re,be as Le,a2 as $,a as I,bq as Z,U as qe,f as Ae,bi as Fe,br as Ee,bb as k,b as ee,a7 as Me,bs as Oe,aP as ke,af as C,j as oe,E as L,aB as Q,bt as Pe,bu as We,bv as Ue,bw as He,aG as R,aO as se,aI as ce,b1 as Be,bx as U,T as H,b2 as de,B as E,by as Ve,aH as ue,aD as z,bn as $e,aE as D,aC as ae,bm as Ie,aF as Qe,bz as ze,bl as Ke,bk as Ge}from"./index-CXHBmSa5.js";import{D as pe}from"./Table-D0NFHHNQ.js";import{T as B}from"./TimeCell-gSIuLEFc.js";import{A as Xe}from"./ActionGroup-90AzAQje.js";import{q as Je,u as he,a as Ye,s as Ze,b as es}from"./dns-DQrpG8y_.js";import{c as te,d as ss,e as as}from"./files-BxEOxSF8.js";import{d as ts}from"./nav-C2A1sZKm.js";import{F as ns}from"./FactStrip-BgQ_tYB6.js";import{r as ne,B as rs}from"./ranked-FVqORIQj.js";import{u as ls,w as is,C as os,p as P}from"./layout-BRLew_nj.js";import"./useGridSelectionCheckbox-BV96yL-N.js";import"./Virtualizer--Vfl8O3n.js";import"./ListLayout-CPapuywx.js";function cs({label:r,shares:t}){const e=g(),s=we(),{ref:l,tip:n,show:i,hide:o}=ls(),c=p.useMemo(()=>{const d=is(t.map(m=>m.count));return t.flatMap((m,f)=>Array.from({length:d[f]},()=>m))},[t]);return a.jsxs("div",{className:"rp-waffle rp-chart-hover",ref:l,onPointerLeave:o,children:[a.jsx("div",{className:"grid",role:"img","aria-describedby":s,"aria-label":e("ui.valuePair",{label:r,value:t.map(d=>`${d.label} ${d.text}`).join(e("ui.separator"))}),children:c.map((d,m)=>a.jsx("span",{style:{background:d.color},onPointerMove:f=>i(f,[d.label,d.text])},m))}),a.jsx("ul",{className:"legend",children:t.map(d=>a.jsxs("li",{children:[a.jsx("i",{className:"sw",style:{background:d.color}}),a.jsx("span",{children:d.label}),a.jsx("b",{children:d.text})]},d.id))}),a.jsx(os,{tip:n})]})}function ds({className:r,...t}){return a.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:20,viewBox:"0 0 20 20","aria-hidden":"true",focusable:"false",className:Ne("rp-icon",r),...t,children:[a.jsx("path",{fill:"currentColor",d:"M8.249 15.021c-.4 0-.733-.317-.748-.72l-.25-6.5c-.017-.414.307-.763.72-.779H8c.4 0 .733.317.748.72l.25 6.5c.017.414-.307.763-.72.778zM11.751 15.021h-.03c-.413-.016-.737-.365-.72-.779l.25-6.5c.015-.403.348-.72.748-.72h.03c.413.016.737.365.72.779l-.25 6.5c-.015.403-.348.72-.748.72"}),a.jsx("path",{fill:"currentColor",d:"M17 4h-3.5v-.75C13.5 2.01 12.49 1 11.25 1h-2.5C7.51 1 6.5 2.01 6.5 3.25V4H3c-.414 0-.75.336-.75.75s.336.75.75.75h.52l.422 10.342C3.99 17.052 4.98 18 6.19 18h7.62c1.211 0 2.2-.948 2.248-2.158L16.48 5.5H17c.414 0 .75-.336.75-.75S17.414 4 17 4m-9-.75c0-.413.337-.75.75-.75h2.5c.413 0 .75.337.75.75V4H8zm6.56 12.531c-.017.404-.346.719-.75.719H6.19c-.404 0-.733-.315-.75-.719L5.02 5.5h9.96z"})]})}const us={forced:"dns.route.forced","dns.routing":"dns.route.rules",default:"dns.route.default"};function me(r,t){return{fields:[[t("ui.state"),r.status],[t("ui.upstream"),r.upstream??"—"],[t("dns.routeSource"),Ce(us,r.route.source,t)],[t("dns.routeRule"),r.route.rule??"—"],[t("ui.elapsed"),j(r.elapsed_ms,t)]],answers:(r.answers??[]).map(e=>t("dns.answer",{name:e.name,type:e.type,ttl:e.ttl,data:e.data})),cacheText:t(r.cached?"dns.hit":"dns.miss"),cacheTone:r.cached?void 0:"warn"}}function ps(r,t,e,s,l,n){const i=t?.dns_query.record_types??[],o=e==="all"?i.length>0:i.includes(e);return{types:i,choices:[...i.map(c=>({id:c,label:c})),{id:"all",label:n("dns.allTypes")}],disabled:l||!t?.dns_query.available||!o||!s.trim(),reason:!t||l?null:t.dns_query.available?o?null:n(e==="all"?"dns.noTypes":"dns.typeUnsupported"):n("dns.queryUnavailable"),showCache:!!t?.dns_cache.available,cards:r?.results.map(c=>({id:c.type,title:`${r.domain} ${c.type}`,...me(c,n)}))??[],tabs:ts(t).map(c=>({id:c.id,label:n(c.titleKey)}))}}function hs(r,t,e,s,l,n){const i=e.toLowerCase(),o=t?.dns_cache,c=(r?.entries??[]).filter(d=>!i||d.domain.toLowerCase().includes(i));return{fields:[[n("dns.entries"),r?re(r.total,l):"—"]],coverage:r?["positive","negative","persistent"].filter(d=>!r.coverage[d]).map(d=>({id:d,text:n("ui.valuePair",{label:n({positive:"dns.positive",negative:"dns.negative",persistent:"dns.persistent"}[d]),value:n(d==="persistent"?"dns.chart.memoryOnly":"dns.notCovered")})})):[],filterText:i?n("dns.cacheFilter",{domain:e}):"",confirmationText:r?n("dns.flushConfirm",{n:r.total}):n("dns.flushConfirmAll"),flushDisabled:!!s||!t?.dns_cache.available||!t.dns_cache.flush,flushReason:o&&!s&&(!o.available||!o.flush)?n("dns.flushUnsupported"):null,deleteReason:o&&!s&&c.length>0&&(!o.available||!o.delete_entry)?n("dns.deleteUnsupported"):null,empty:n(t?.dns_cache.available&&t.dns_cache.read?"dns.empty":"dns.cacheUnavailable"),rows:c.map(d=>({id:d.entry_id,domain:d.domain,type:d.type,status:d.status,expiresAt:d.expires_at,staleUntil:d.stale_until,deleteLabel:n("dns.deleteEntry",{domain:d.domain,type:d.type}),pending:s===d.entry_id,disabled:!!s||!t?.dns_cache.available||!t.dns_cache.delete_entry}))}}function ms(r,t,e,s){const l=r?.records.find(i=>i.id===t);if(!l)return null;const n=me(l,s);return{id:l.id,title:l.question.name,answers:n.answers,fields:[[s("ui.type"),l.question.type],[s("ui.device"),l.src??"—"],n.fields[0],[s("ui.cache"),n.cacheText],...n.fields.slice(1),[s("ui.time"),Te(l.observed_at,e)]]}}function fs(r,t,e,s=[]){const l=r?.records??[];return{choices:[{id:"all",label:e("dns.allTypes")},...[...new Set([...s,...l.map(n=>n.question.type)])].map(n=>({id:n,label:n}))],total:r?e("dns.logTotal",{n:r.total}):"",totalHelp:r?{title:e("dns.logTotal",{n:r.total}),text:e("dns.logTotalHelp")}:null,loaded:r?.next_cursor?e("dns.logLoaded",{n:l.length}):"",empty:e(t===void 0?"ui.loading":t?"dns.logEmpty":"dns.logUnavailable"),rows:l.map(n=>({id:n.id,observedAt:n.observed_at,name:n.question.name,type:n.question.type,source:n.src??"—",resultError:n.status!=="NOERROR",result:n.status!=="NOERROR"?n.status:n.answers.map(i=>i.data).join(", ")||"—",cached:n.cached,upstream:n.cached?e("dns.hit"):n.upstream??"—",elapsed:j(n.elapsed_ms,e)}))}}function xs(r){return[te(["id","observed_at","src","name","type","status","cached","upstream","route_source","route_rule","elapsed_ms","answers"]),...r.map(t=>te([t.id,t.observed_at,t.src,t.question.name,t.question.type,t.status,t.cached?"true":"false",t.upstream,t.route.source,t.route.rule,t.elapsed_ms,t.answers.map(e=>e.data).join(" ")]))].join(`
`)+`
`}function gs(r,t){const e=new Set(r.records.map(s=>s.id));return{...r,records:[...r.records,...t.records.filter(s=>!e.has(s.id))],next_cursor:t.next_cursor}}function bs(r,t){const e=t&&new Set(t.records.map(s=>s.id));return{data:t??r,newerWaiting:!!e&&!!r?.records.some(s=>!e.has(s.id))}}function vs(r,t,e){if(!r)return null;const{usage:s,coverage:l}=r,n=o=>{const c=De(o);return c===null?"—":re(c,t)},i=s?_e(s.entries,s.entry_capacity):null;return{note:s?void 0:e("dns.chart.cacheNote",{n:r.total}),usage:s&&i!==null?{pct:i,value:i>0&&i<.5?"<"+e("ui.percent",{n:1}):e("ui.percent",{n:Math.round(i)}),facts:e("dns.chart.usageFacts",{entries:e("ui.fraction",{part:n(s.entries),whole:n(s.entry_capacity)})})}:null,coverage:e("dns.chart.coverage",{kinds:[l.positive&&e("dns.chart.positive"),l.negative&&e("dns.chart.negative")].filter(Boolean).join(e("ui.listSeparator")),persistent:e(l.persistent?"dns.chart.persistent":"dns.chart.memoryOnly")})}}function js(r,t,e){return r?e instanceof Se&&e.status===503?"unavailable":t?"ready":e?"error":"loading":"unlisted"}function ys({go:r,query:t}){const e=g(),s=le(),l=V(),n=p.useMemo(()=>new URLSearchParams(t),[t]),[i,o]=p.useState(n.get("domain")??""),[c,d]=p.useState(n.get("type")??"A");F(n.get("domain"),h=>o(h??"")),F(n.get("type"),h=>d(h??"A"));const[m,f]=p.useState(null),{busy:y,error:u,run:v}=ie({rethrow:!0}),x=l.data?.resources,w=p.useMemo(()=>ps(m,x,c,i,!!y,e),[m,x,c,i,y,e]),N=n.has("domain")&&w.tabs.some(h=>h.id==="log")?"log":w.tabs[0]?.id??"query",q=async()=>{try{await v("query",async h=>{const _=await Je(s.dnsQuery,i.trim(),c==="all"?w.types:[c],x?.dns_query.limits?.max_types_per_request??1,h);return h.aborted||f(_),_})}catch{}};return{...w,domain:i,setDomain:o,type:c,setType:d,pending:y==="query",queryError:u,submit:()=>void q(),setTab:h=>r("dns",Le(t,h,x&&!n.has("domain")?N:null)),tab:Re(t,w.tabs.map(h=>h.id),N),filterDomain:n.get("domain")??"",logEnabled:x?.dns_log.available,viewCache:()=>r("dns",Y(t,{tab:"cache",domain:m?.domain??""})),clearCacheFilter:()=>r("dns",Y(t,{tab:"cache",domain:null}))}}function ws(r){const t=g(),e=$[I()],s=Ye(!Ee()),l=p.useMemo(()=>hs(s.cache.data,s.capabilities.data?.resources,r,s.busy,e,t),[s.cache.data,s.capabilities.data,r,s.busy,e,t]),{remove:n}=s,i=p.useCallback(c=>void n(c).then(d=>d&&k("positive",t("dns.deleted",{n:d.deleted})),d=>k("negative",t("dns.deleteFailed"),{detail:ee(d,t)})),[n,t]),o=async()=>{try{const c=await s.flush();c&&k("positive",t("dns.flushed",{matched:c.matched,deleted:c.deleted}))}catch(c){return t("dns.flushFailed",{error:ee(c,t)})}};return{...l,error:s.cache.error,retry:s.cache.refetch,loading:(s.cache.loading||s.capabilities.loading)&&!s.cache.data,flushPending:s.busy==="flush",remove:i,flush:o,abortFlush:()=>{s.cancel(),s.cache.refetch()}}}function Ns(r){const t=he({},r===!0),e=V().data?.resources;return{log:t,cacheListed:Me(e,"dns_cache",{whileLoading:!1})&&e?.dns_cache.read===!0}}function Cs(r){const t=g(),e=$[I()],[s,l]=Oe(),[n,i]=p.useState(!1),o=es(r,!l&&n);o.data&&!n&&i(!0);const c=p.useMemo(()=>vs(o.data,e,t),[o.data,e,t]);return{ref:s,card:c,state:js(r,!!c,o.error),error:o.error,retry:o.refetch}}function Ts(r,t){const e=g(),s=$[I()],[l,n]=p.useState(t);F(t,n);const[i,o]=p.useState("all"),[c,d]=p.useState(""),m=le(),f=V(),y=Z(c),u=qe(y),v=y.trim()!==""&&!u,[x,w]=p.useState(u);!v&&u!==x&&w(u);const N={name:Z(l),type:i,src:v?x:u},q=JSON.stringify(N),h=he(N,r===!0),[_,A]=p.useState(null),[fe,K]=p.useState(!1),S=ie({scope:q});F(q,()=>A(null));const{data:b,newerWaiting:xe}=p.useMemo(()=>bs(h.data,_),[h.data,_]),G=()=>void S.run("older",async T=>{if(!b?.next_cursor)return;A(b);const{page:je}=await Ze(ye=>m.dnsLog(ye,T),{name:N.name.trim()||void 0,type:i==="all"?void 0:i,src:N.src,cursor:b.next_cursor,limit:h.limit},T);T.aborted||A(gs(b,je))}),X=()=>{S.cancel(),A(null);const T=h.refetch();T&&(K(!0),T.finally(()=>K(!1)))},[M,ge]=p.useState(null),be=Ae(Fe),J=f.data?.resources.dns_query.record_types,ve=p.useMemo(()=>fs(b,r,e,J),[b,r,e,J]),O=p.useMemo(()=>ms(b,M,s,e),[b,M,s,e]);return{...ve,detail:O,detailTitle:O?.title??"",name:l,newerWaiting:xe,setName:n,type:i,setType:o,src:c,setSrc:d,srcError:v?e("ui.invalidIp"):void 0,selected:O?M:null,setSelected:ge,wide:be,error:S.error??h.error,loading:h.loading&&!b,hasOlder:!!b?.next_cursor,loadingOlder:!!S.busy,loadOlder:G,refreshing:fe,refresh:X,retry:S.error?G:X,export:()=>ss(as("dns-log","csv"),xs(b?.records??[]),"text/csv;charset=utf-8")}}const _s=["cached","answered","nxdomain","failed"],Ss=r=>r.cached?"cached":r.status==="NOERROR"?"answered":r.status==="NXDOMAIN"?"nxdomain":"failed";function Ds(r){const t={cached:0,answered:0,nxdomain:0,failed:0},e=[];for(const o of r){const c=Ss(o);t[c]++,!o.cached&&o.upstream!==null&&e.push({id:o.id,value:o.elapsed_ms,outcome:c,name:o.question.name,upstream:o.upstream})}const s=e.map(o=>o.value).sort((o,c)=>o-c),l=new Map;for(const o of e)l.set(o.upstream,[...l.get(o.upstream)??[],o]);const n=[...l].map(([o,c])=>({upstream:o,median:P(c.map(d=>d.value).sort((d,m)=>d-m),50),samples:c}));n.sort((o,c)=>c.samples.length-o.samples.length||ke(o.upstream,c.upstream));const i=r.length-t.cached;return{domains:ne(r.map(o=>o.question.name.replace(/\.$/,"")),8),devices:ne(r.map(o=>o.src===null?null:Rs(o.src)),8),total:r.length,counts:t,uncached:i,samples:e,typical:P(s,50),slowest:P(s,95),failureRate:i?t.failed/i:null,cacheRate:r.length?t.cached/r.length:null,upstreams:n}}const Rs=r=>r.replace(/:\d+$/,""),Ls=(r,t)=>!!r?.next_cursor&&t!==void 0&&r.records.length<t,W={cached:"dns.outcome.cached",answered:"dns.outcome.answered",nxdomain:"dns.outcome.nxdomain",failed:"dns.outcome.failed"};function qs({enabled:r}){const t=g(),{log:e,cacheListed:s}=Ns(r);if(r===!1)return a.jsx(C,{children:t("dns.logUnavailable")});if(r===void 0)return null;const l=e.data?null:e.error,n=e.data?null:l?a.jsx(C,{children:t("dns.chart.noLog")}):a.jsx(oe,{}),i=l?a.jsx(L,{error:l,onRetry:e.refetch}):Ls(e.data,e.limit)?a.jsx("p",{className:"rp-note",children:t("dns.chart.shortPage",{n:e.data.records.length,limit:e.limit})}):null;return a.jsx(Fs,{records:e.data?.records??As,pending:n,notice:i,cacheListed:s})}const As=[];function Fs({records:r,pending:t,notice:e,cacheListed:s}){const l=g(),n=Q(),i=p.useMemo(()=>Ds(r),[r]),o={cached:n.positive,answered:n.cat[2],nxdomain:n.notice,failed:n.negative},c=u=>l("ui.percent",{n:u===null?0:Math.round(u*100)}),d=(u,v)=>{const x=v?u/v:0;return u>0&&x<.005?"<"+l("ui.percent",{n:1}):u<v&&x>.995?">"+l("ui.percent",{n:99}):c(x)},m=u=>({id:u.id,value:u.value,color:o[u.outcome],lines:[u.name,j(u.value,l),l(W[u.outcome])]}),f=t??(i.total<5?a.jsx(C,{children:l("dns.chart.tooFew")}):null),y=[{label:l("dns.chart.median"),value:j(i.typical,l),icon:a.jsx(Pe,{}),tint:"c1"},{label:l("dns.chart.p95"),value:j(i.slowest,l),icon:a.jsx(We,{}),tint:"c4"},{label:l("dns.chart.cacheRate"),value:c(i.cacheRate),icon:a.jsx(Ue,{}),tint:"c2"},{label:l("dns.chart.failureRate"),value:c(i.failureRate),icon:a.jsx(He,{}),tint:"c5",tone:i.counts.failed?"negative":void 0}];return a.jsxs("div",{className:"rp-chart-page",children:[e,!f&&a.jsx(ns,{facts:y}),a.jsxs("div",{className:"rp-g21",children:[a.jsx(R,{title:l("dns.chart.speed",{n:i.samples.length}),note:f?void 0:l("dns.chart.sample",{n:i.total,uncached:i.uncached,upstream:i.samples.length}),children:f??a.jsxs(a.Fragment,{children:[a.jsx(rs,{label:l("dns.chart.speed",{n:i.samples.length}),points:i.samples.map(m),marks:i.typical!==null&&i.slowest!==null?[{value:i.typical,label:l("dns.chart.typical",{value:j(i.typical,l)})},{value:i.slowest,label:l("dns.chart.slowest",{value:j(i.slowest,l)})}]:[],rows:i.upstreams.map(u=>({id:u.upstream,label:u.upstream,detail:l("dns.chart.upstream",{n:u.samples.length,median:j(u.median,l)}),points:u.samples.map(m),mark:u.median})),fmt:u=>j(u,l)}),a.jsxs("div",{className:"rp-legend",children:[["answered","nxdomain","failed"].map(u=>a.jsx(se,{swatch:o[u],label:l(W[u])},u)),a.jsx(se,{swatch:a.jsx("i",{className:"rp-median-key","aria-hidden":"true"}),label:l("dns.chart.medianKey")})]})]})}),a.jsx(R,{title:l("dns.chart.outcomes"),children:f??a.jsx(cs,{label:l("dns.chart.outcomes"),shares:_s.map(u=>({id:u,label:l(W[u]),count:i.counts[u],color:o[u],text:l("dns.chart.share",{n:i.counts[u],share:d(i.counts[u],i.total)})}))})})]}),a.jsxs("div",{className:"rp-g21",children:[a.jsx(Ms,{analysis:i,standIn:f}),a.jsx(Es,{listed:s})]})]})}function Es({listed:r}){const t=g(),e=Q(),{ref:s,...l}=Cs(r);return a.jsx(R,{ref:s,title:t("dns.chart.cache"),note:l.state==="ready"?l.card?.note:void 0,children:l.state==="unlisted"?a.jsx(C,{children:t("dns.cacheUnavailable")}):l.state==="unavailable"?a.jsx(C,{children:t("dns.cacheBusy")}):l.state==="error"?a.jsx(L,{error:l.error,onRetry:l.retry}):l.card?a.jsxs(a.Fragment,{children:[l.card.usage&&a.jsxs("div",{className:"rp-form",children:[a.jsx(ce,{label:t("dns.chart.usage"),value:l.card.usage.value,pct:l.card.usage.pct,color:e.accent}),a.jsx("span",{className:"rp-label",children:l.card.usage.facts})]}),a.jsx("p",{className:"rp-note",children:l.card.coverage})]}):a.jsx(oe,{})})}function Ms({analysis:r,standIn:t}){const e=g(),s=Q(),[l,n]=p.useState("device"),i=l==="device"?r.devices:r.domains,o=i.top[0]?.count??1;return a.jsx(R,{title:e("dns.chart.ranking"),aside:!t&&a.jsx(Be,{label:e("dns.chart.ranking"),value:l,onChange:n,items:[["device",e("dns.chart.byDevice")],["domain",e("dns.chart.byDomain")]]}),children:t??a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"rp-list",children:i.top.map(c=>a.jsx(ce,{label:c.key??e("dns.chart.resolver"),value:e("dns.chart.count",{n:c.count}),pct:c.count/o*100,color:l==="device"?s.cat[0]:s.cat[3]},c.key??""))}),i.rest>0&&a.jsx("p",{className:"rp-note",children:e("dns.chart.rest",{n:i.rest})})]})})}function Ys(r){const t=g(),e=ys(r),s=a.jsxs(a.Fragment,{children:[e.queryError&&a.jsx(L,{error:e.queryError,onRetry:e.submit,message:n=>t("dns.queryFailed",{error:n})}),a.jsx("form",{className:Ve(),onSubmit:n=>{n.preventDefault(),e.submit()},children:a.jsx(U,{reason:e.reason,children:a.jsxs("div",{className:"rp-toolbar",children:[a.jsx(H,{side:!0,label:t("ui.domain"),value:e.domain,onChange:e.setDomain,width:280,placeholder:"example.com"}),a.jsx(de,{label:t("ui.type"),side:!0,value:e.type,onChange:e.setType,items:e.choices}),a.jsx(E,{accent:!0,type:"submit",isPending:e.pending,isDisabled:e.disabled,children:t("dns.query")})]})})}),e.cards.length>0&&a.jsx("div",{className:"rp-col",children:e.cards.map(n=>a.jsxs(R,{className:"rp-col",children:[a.jsxs("div",{className:"rp-row",children:[a.jsxs("div",{className:"rp-cluster",children:[a.jsx("h3",{className:"rp-h3",children:n.title}),a.jsx(ue,{tone:n.cacheTone,children:n.cacheText})]}),e.showCache&&a.jsx(E,{quiet:!0,small:!0,onPress:e.viewCache,children:t("dns.viewCache")})]}),a.jsx(z,{inline:!0,items:n.fields}),n.answers.length?a.jsx("div",{className:"rp-list",children:n.answers.map((i,o)=>a.jsx("div",{className:"rp-code",children:i},o))}):a.jsx(C,{children:t("dns.noAnswers")})]},n.id))})]}),l={stats:a.jsx(qs,{enabled:e.logEnabled}),query:s,cache:a.jsx(Os,{domain:e.filterDomain,clearFilter:e.clearCacheFilter}),log:a.jsx(ks,{enabled:e.logEnabled,initialName:e.filterDomain})};return a.jsx("div",{className:"rp-page",children:a.jsx($e,{keepMounted:!0,label:t("nav.dns"),items:e.tabs.map(n=>({...n,content:l[n.id]})),value:e.tab,onChange:e.setTab})})}function Os({domain:r,clearFilter:t}){const e=g(),s=ws(r),{remove:l}=s,n=p.useMemo(()=>[{id:"q",label:e("ui.domain"),minWidth:192,isRowHeader:!0,render:i=>a.jsx(D,{className:"rp-code",text:i.id,children:i.domain})},{id:"t",label:e("ui.type"),minWidth:64,grow:0,drop:3,render:i=>i.type},{id:"s",label:e("ui.state"),minWidth:104,grow:0,render:i=>i.status},{id:"e",label:e("dns.expires"),minWidth:96,drop:2,render:i=>a.jsx(B,{at:i.expiresAt})},{id:"st",label:e("dns.staleUntil"),minWidth:104,drop:1,render:i=>a.jsx(B,{at:i.staleUntil})},{id:"a",label:e("ui.delete"),minWidth:80,grow:0,render:i=>a.jsx(E,{quiet:!0,icon:!0,small:!0,label:i.deleteLabel,isPending:i.pending,isDisabled:i.disabled,onPress:()=>l(i.id),children:a.jsx(ds,{})})}],[e,l]);return a.jsxs(a.Fragment,{children:[s.error&&a.jsx(L,{error:s.error,onRetry:s.retry}),a.jsx(U,{reason:s.flushReason,children:a.jsxs("div",{className:"rp-toolbar",children:[a.jsx(z,{row:!0,items:s.fields}),s.coverage.map(i=>a.jsx(ue,{tone:"warn",children:i.text},i.id)),s.filterText&&a.jsx(E,{small:!0,onPress:t,children:s.filterText}),a.jsx("span",{className:"rp-grow"}),a.jsx(Ge,{label:e("dns.flushAll"),confirmationText:s.confirmationText,isPending:s.flushPending,isDisabled:s.flushPending||s.flushDisabled,onConfirm:s.flush,onAbort:s.abortFlush})]})}),a.jsx(U,{reason:s.deleteReason,above:!0,children:a.jsx(pe,{label:e("ui.cache"),height:442,fit:!0,rows:s.rows,loading:s.loading,empty:s.empty,cols:n})})]})}function ks({enabled:r,initialName:t}){const e=g(),s=Ts(r,t),l=p.useMemo(()=>[{id:"t",label:e("ui.time"),minWidth:140,grow:0,render:n=>a.jsx(B,{at:n.observedAt})},{id:"q",label:e("ui.domain"),minWidth:200,grow:2,isRowHeader:!0,render:n=>a.jsx(D,{children:n.name})},{id:"ty",label:e("ui.type"),minWidth:64,grow:0,drop:3,render:n=>n.type},{id:"s",label:e("ui.device"),minWidth:128,drop:2,render:n=>a.jsx(D,{className:"rp-code",children:n.source})},{id:"r",label:e("dns.result"),minWidth:160,grow:2,render:n=>n.resultError?a.jsx(ae,{small:!0,tone:"err",children:n.result}):a.jsx(D,{className:"rp-code",children:n.result})},{id:"u",label:e("ui.upstream"),minWidth:128,drop:1,render:n=>n.cached?a.jsx(ae,{small:!0,tone:"ok",children:n.upstream}):a.jsx(D,{children:n.upstream})},{id:"e",label:e("ui.elapsed"),minWidth:72,grow:0,align:"end",drop:4,render:n=>n.elapsed}],[e]);return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"rp-toolbar",children:[a.jsx(H,{search:!0,label:e("ui.domain"),value:s.name,onChange:s.setName,placeholder:e("dns.logFilterHint"),width:240}),a.jsx(de,{label:e("ui.type"),side:!0,value:s.type,onChange:s.setType,items:s.choices}),a.jsx(H,{search:!0,label:e("ui.device"),value:s.src,onChange:s.setSrc,error:s.srcError,placeholder:"10.0.0.12",width:160}),s.total&&a.jsx(Ie,{help:s.totalHelp,children:a.jsx("span",{className:"rp-label",children:s.total})}),s.loaded&&a.jsx("span",{className:"rp-label",children:s.loaded}),a.jsx("span",{className:"rp-grow"}),a.jsx(Xe,{actions:[{id:"export",label:e("dns.exportLog"),icon:a.jsx(Qe,{}),isDisabled:!s.rows.length,onAction:s.export},{id:"refresh",label:e("refresh"),icon:a.jsx(ze,{className:"rp-spin-on-press"}),isPending:s.refreshing,onAction:s.refresh},...s.hasOlder?[{id:"older",label:e("dns.loadOlder"),isPending:s.loadingOlder,onAction:s.loadOlder}]:[]]})]}),s.error&&a.jsx(L,{error:s.error,onRetry:s.retry}),s.newerWaiting&&a.jsx("p",{className:"rp-note",children:e("dns.newerWaiting")}),a.jsxs("div",{className:"rp-with-panel","data-open":s.detail?"":void 0,children:[a.jsx(pe,{label:e("dns.log"),rowDetail:!0,height:520,rows:s.rows,selected:s.selected,onSelect:s.setSelected,selectOnFocus:s.wide,loading:s.loading,empty:s.empty,cols:l}),a.jsx(Ke,{open:!!s.detail,title:s.detailTitle,onClose:()=>s.setSelected(null),children:s.detail&&a.jsxs(a.Fragment,{children:[a.jsx(z,{inline:!0,items:s.detail.fields}),s.detail.answers.length?a.jsx("div",{className:"rp-list",children:s.detail.answers.map((n,i)=>a.jsx("div",{className:"rp-code",children:n},i))}):a.jsx(C,{children:e("dns.noAnswers")})]})})]})]})}export{Ys as Dns};