Files
op-packages/luci-app-honk/root/etc/honk/doona/assets/activity-SP7tP5Sc.js
T

3 lines
165 KiB
JavaScript

const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./AreaChart-CqTV2ZQk.js","./vendor-react-64fcanlc.js","./_commonjsHelpers-CXUWDbkB.js","./index-BpMcZry4.js","./index--6K0oddI.css","./AreaCurve-DQSHOSpG.js","./array-C0VuvQyb.js","./nodes-9cDj613b.js","./AppearanceControls-_LKvZPhT.js","./ItemText-CcW62_Lb.js","./logs-CSLBu0fr.js","./Select-DfNHOkHm.js","./Sparkline-CiSVZVwG.js","./Donut-B59wjqJE.js","./Editors-dKzIa8sH.js","./GridList-CZtL3cpM.js","./Checkbox-BiXT27lL.js","./Delete-Cfg0qtTJ.js","./Editors-rPgk_VZK.css","./index-BMEfMmeK.js","./geodata-X0pHz03D.js","./auth-CCQVpwEd.js","./auth-BJk40oQc.js"])))=>i.map(i=>d[i]);
import{r as e,a as t,j as n}from"./vendor-react-64fcanlc.js";import{d as s,h as a,n as r,o as i,w as o,s as l,R as c,S as d,a as u,b as m,I as h,L as p,u as f,_ as g,c as b,e as x,N as v,T as y,f as j,g as w,i as k,j as N,B as M,E as _,C as S,k as C,l as E,P as L,m as z,p as R,q as O,r as P,t as A,v as I,x as T,y as q,z as D,A as H,D as F,F as B,G as $,H as V,J as W,K as U,M as G,O as K,Q as J,U as X,V as Y,W as Q,X as Z,Y as ee,Z as te,$ as ne,a0 as se,a1 as ae,a2 as re,a3 as ie,a4 as oe,a5 as le,a6 as ce,a7 as de,a8 as ue,a9 as me,aa as he,ab as pe,ac as fe,ad as ge,ae as be,af as xe,ag as ve,ah as ye,ai as je,aj as we,ak as ke,al as Ne,am as Me,an as _e,ao as Se,ap as Ce,aq as Ee,ar as Le,as as ze,at as Re,au as Oe,av as Pe,aw as Ae,ax as Ie,ay as Te,az as qe,aA as De,aB as He,aC as Fe,aD as Be,aE as $e,aF as Ve,aG as We,aH as Ue,aI as Ge,aJ as Ke,aK as Je,aL as Xe,aM as Ye,aN as Qe,aO as Ze,aP as et,aQ as tt,aR as nt,aS as st,aT as at,aU as rt,aV as it,aW as ot,aX as lt,aY as ct,aZ as dt,a_ as ut,a$ as mt,b0 as ht,b1 as pt,b2 as ft,b3 as gt,b4 as bt,b5 as xt,b6 as vt,b7 as yt,b8 as jt,b9 as wt,ba as kt,bb as Nt,bc as Mt,bd as _t,be as St,bf as Ct,bg as Et,bh as Lt,bi as zt,bj as Rt,bk as Ot,bl as Pt,bm as At,bn as It,bo as Tt,bp as qt,bq as Dt,br as Ht,bs as Ft,bt as Bt,bu as $t,bv as Vt,bw as Wt,bx as Ut}from"./index-BpMcZry4.js";import{r as Gt,c as Kt,s as Jt,h as Xt,d as Yt,i as Qt,a as Zt,b as en,e as tn,f as nn,g as sn,j as an,n as rn,u as on,k as ln,l as cn,p as dn,m as un,o as mn,q as hn,t as pn,v as fn,w as gn,x as bn,y as xn,z as vn,A as yn,B as jn}from"./nodes-9cDj613b.js";import{L as wn,C as kn,u as Nn,a as Mn,P as _n,S as Sn,T as Cn,b as En,c as Ln}from"./AppearanceControls-_LKvZPhT.js";import{W as zn,S as Rn,u as On,a as Pn,b as An,c as In,e as Tn,d as qn,l as Dn,f as Hn,g as Fn,h as Bn,i as $n,V as Vn,C as Wn,r as Un,K as Gn,D as Kn,j as Jn,M as Xn,$ as Yn,k as Qn,m as Zn,n as es}from"./logs-CSLBu0fr.js";import{I as ts,C as ns}from"./ItemText-CcW62_Lb.js";const ss={"missing-offline-dependency":"config.diagnostic.offlineMissing","offline-dependency-denied":"config.diagnostic.offlineDenied","invalid-offline-dependency":"config.diagnostic.offlineInvalid","unreadable-offline-dependency":"config.diagnostic.offlineUnreadable"},as=e=>Object.hasOwn(ss,e);function rs(e,t,n){return as(e.code)?{summary:t("config.diagnostic.offline",{reason:t(ss[e.code]),which:n?t("config.diagnostic.offlineGeodata",{files:n}):t("config.diagnostic.offlineUsual")})}:s(e,t)}const is=e=>[...new Set(e.flatMap(({item:e,message:t})=>e.message&&!t.includes(e.message)?[e.message]:[]))];function os(e,t){const n=e.map(e=>e.id===t?.id?t.content:e.content).flatMap(e=>void 0===e?[]:Gt(e));return[...new Map(n.map(({name:e,written:t})=>[t,{name:e,written:t}])).values()]}const ls=e=>"<redacted>"===e.path||""===e.path,cs=e=>ls(e)?"main"===e.kind?"config.dae":`${e.kind}-${e.id.slice(0,8)}.dae`:e.path.split("/").pop()||"config.dae";function ds(e,t){const n=e.find(e=>"main"===e.kind);if(!n)return null;const s=[n,...e.filter(e=>"include"===e.kind&&!ls(e))];return t&&!s.some(e=>e.id===t.id)?null:s.map(e=>({id:e.id,...ls(e)?{}:{path:e.path},content:e.id===t?.id?t.content:e.content}))}const us=e=>e.filter(e=>"error"===e.level&&"restart-required"===e.code).map(e=>({key:/\b[a-z][a-z0-9_]*(?:\.[a-z0-9_]+)+\b/.exec(e.message)?.[0]??(e.message||null),sourceId:e.source_id,line:e.line})),ms=e=>us(e).length,hs={main:"config.kind.main",include:"config.kind.include",subscription:"nodes.kind.subscription",generated:"config.kind.generated"},ps=(e,t)=>`${e}:${t}`;function fs(e,t){const n=e.indexOf(":"),s=e.slice(0,n);return n>0&&t.includes(s)?{kind:s,value:e.slice(n+1)}:null}const gs=(e,t)=>t&&e?a("rules",{tab:"list",rule:e}):void 0,bs=(e,t,n=!1)=>a("nodes",{provider:r(e,t),q:e.name,node:n?e.id??null:null});function xs(e,t){const n=e?.find(e=>e.name===t)?.id;return n?o("",{group:n}):""}function vs(e,t,n){const s=t?.find(t=>t.name===e);return s?{label:s.name,href:a("policies",{group:s.id})}:{label:i(e,n),href:null}}const ys=["network","domain","dst_ip","dst_port","src_ip","src_port","pname"],js=e=>o("",{tab:"trace",...Object.fromEntries(ys.map(t=>[t,e[t]||null]))});function ws(e){const t=new URLSearchParams(e),n=e=>t.get(e)??"";return n("domain")||n("dst_ip")?{network:"udp"===n("network")?"udp":"tcp",domain:n("domain"),dst_ip:n("dst_ip"),dst_port:n("dst_port"),src_ip:n("src_ip"),src_port:n("src_port"),pname:n("pname")}:null}const ks=a("settings",{card:"runtime"});function Ns(e,t=Kt){return e?fs(e,t):null}function Ms(e,t){const n=e.filter(e=>"main"===e.kind||"include"===e.kind);for(const s of n){const e=Jt(s.content).blocks.find(e=>e.name===t);if(e)return a("config",{tab:"source",source:s.id,line:String(e.line+1)})}return a("config",{tab:"source",source:n.find(e=>"main"===e.kind)?.id??null})}const _s=a("activity",{card:"mode"}),Ss=a("overview",{card:"limits"}),Cs=e=>a("nodes",{nodes:JSON.stringify(e)});let Es=!1;const Ls=new Set,zs={snapshot:()=>Es,set(e){Es=e,Ls.forEach(e=>e())},subscribe:e=>(Ls.add(e),()=>{Ls.delete(e)})},Rs=[{id:"widgets:edit",titleKey:"widgets.edit",route:null,open:()=>zs.set(!0),aliases:["widget panel"]},{id:"dashboard:edit",titleKey:"dashboard.edit",parentKey:"nav.activity",route:"activity",aliases:["dashboard"]}],Os=e.createContext(null);function Ps({children:n}){const s=e.useContext(Os);return s?t.createPortal(n,s):null}const As=e=>e.dataset.height??"standard",Is='[data-pack="tile"]',Ts=e=>"short"!==As(e)&&("tall"===As(e)||"1"===getComputedStyle(e.querySelector(Is)).getPropertyValue("--rp-tile-stack").trim());const qs='[data-pack="line"]';function Ds(e,t,n=420){const s=e=>e.reduce((e,t)=>e+t,0),a=s(e.map(e=>e.width)),r=s(e.map(e=>e.natural)),i=(a+e.length*t)/n,o=e.map(e=>Math.ceil((e.natural+t)/i-1e-6));if(r>a||s(o)>n)return;const l=e.map(e=>(e.natural+(a-r)*e.width/a+t)/i),c=l.map((e,t)=>Math.max(o[t],Math.floor(e)));for(let d=n-s(c);0!==d;d+=d>0?-1:1){const e=c.map((e,t)=>t).filter(e=>d>0||c[e]>o[e]).reduce((e,t)=>(l[t]-c[t])*Math.sign(d)>(l[e]-c[e])*Math.sign(d)?t:e);c[e]+=Math.sign(d)}return c}function Hs(e){const t=()=>[...e.children].filter(e=>e instanceof HTMLElement&&e.classList.contains("rp-dashboard-cell")),n=new Set;let s=0;const a=(t,n)=>{e.dataset.measure="";const s=t.map(e=>Math.ceil(e.getBoundingClientRect().height));delete e.dataset.measure,t.forEach((e,t)=>e.style.setProperty("--rp-rows",String(s[t]+n))),e.dataset.packed="";const a=e.getBoundingClientRect(),r=t.map(e=>{const t=e.getBoundingClientRect();return{top:t.top-a.top,bottom:t.bottom-a.top,left:t.left,right:t.right,band:As(e)}});return{heights:s,boxes:r}},r=t=>{delete e.dataset.fit;for(const e of t)for(const t of["--rp-span","--rp-shift","--rp-trim"])e.style.removeProperty(t)},i=()=>{const s=t(),i=[...e.querySelectorAll(qs)],o=Number.parseFloat(getComputedStyle(e).getPropertyValue("--rp-dash-gap"))||0;if(i.length&&(e.dataset.controls="probe"),((t,n)=>{r(t);const s=e=>e.querySelector(qs),a=getComputedStyle(e);if(!t.some(s)||"none"===a.getPropertyValue("--rp-dash-snap").trim())return;const i=e.getBoundingClientRect().width+Math.min(0,Number.parseFloat(a.marginInlineStart)||0),o=t.map(e=>e.getBoundingClientRect()),l=new Map;o.forEach((e,t)=>{const n=Math.round(e.top);l.set(n,[...l.get(n)??[],t])});const c=[...l.values()].filter(e=>e.length>1&&e.every(e=>!t[e].dataset.width&&"wide"!==t[e].dataset.size&&s(t[e]))&&Math.abs(Math.max(...e.map(e=>o[e].right))-Math.min(...e.map(e=>o[e].left))-i)<=1);if(!c.length)return;const d=new Map(c.flat().map(e=>[e,o[e].width-s(t[e]).getBoundingClientRect().width]));e.dataset.lines="probe";const u=new Map(c.flat().map(e=>[e,Math.ceil(s(t[e]).getBoundingClientRect().width+d.get(e))+1]));delete e.dataset.lines;for(const r of c){const s=Ds(r.map(e=>({natural:u.get(e),width:o[e].width})),n);s&&(e.dataset.fit="",r.forEach((e,n)=>{t[e].style.setProperty("--rp-span",String(s[n])),t[e].style.setProperty("--rp-shift","0"),t[e].style.setProperty("--rp-trim","0")}))}})(s,o),i.length){const t=e=>e.map(e=>({natural:e.scrollWidth,width:e.clientWidth})).every(e=>e.natural<=e.width+.5)?"inline":"stacked";let n=t(i);"inline"===n&&(e.dataset.controls=n,n=t([...e.querySelectorAll(`${qs} [data-pack="label"]`)])),e.dataset.controls=n}else delete e.dataset.controls;const d=getComputedStyle(e),u=e.getBoundingClientRect().width+Math.min(0,Number.parseFloat(d.marginInlineStart)||0),m="none"!==d.getPropertyValue("--rp-dash-snap").trim();for(const e of s)e.toggleAttribute("data-wide",m&&e.getBoundingClientRect().width>7*u/12);const h=s.filter(e=>e.querySelector(Is)),p=h.map(Ts);h.forEach((e,t)=>e.dataset.tile=p[t]?"stacked":"inline");let{heights:f,boxes:g}=a(s,o);const b=(e=>{const t=e=>`${Math.round(e.top)} ${e.band}`,n=new Set(e.filter(e=>e.stacks).map(t));return e.map(e=>"short"!==e.band&&n.has(t(e))?"stacked":"inline")})(h.map((e,t)=>({top:g[s.indexOf(e)].top,stacks:p[t],band:As(e)})));h.some((e,t)=>e.dataset.tile!==b[t])&&(h.forEach((e,t)=>e.dataset.tile=b[t]),({heights:f,boxes:g}=a(s,o))),function(e,t){return e.map(n=>{const s=e.filter(e=>e!==n&&e.top>=n.bottom&&e.left<n.right-1&&e.right>n.left+1),a=Math.max(...e.filter(e=>e.band===n.band&&e.top<n.bottom-.5&&e.bottom>n.top+.5).map(e=>e.bottom)),r=s.length?Math.min(a,...s.map(e=>e.top-t)):a;return Math.max(0,Math.round(r-n.bottom))})}(g,o).forEach((e,t)=>{e&&s[t].style.setProperty("--rp-rows",String(f[t]+o+e))});const x=new Set(s.flatMap(e=>{const t=function(e){let t=e.querySelector(".rp-dashboard-body")??e.lastElementChild;for(;t&&"contents"===getComputedStyle(t).display;)t=t.lastElementChild;return t}(e);return t?[t,...t.children]:[]}));for(const e of n)x.has(e)||(l.unobserve(e),n.delete(e));for(const e of x)n.has(e)||(l.observe(e),n.add(e));c.disconnect();for(const e of i)c.observe(e,{subtree:!0,childList:!0,characterData:!0});e.dispatchEvent(new Event("rp-packed"))},o=()=>{s||=requestAnimationFrame(()=>{s=0,i()})},l=new ResizeObserver(()=>o()),c=new MutationObserver(()=>o());l.observe(e);const d=new MutationObserver(i);return d.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-size","data-width","data-height"]}),document.fonts?.addEventListener("loadingdone",i),i(),()=>{cancelAnimationFrame(s),document.fonts?.removeEventListener("loadingdone",i),l.disconnect(),d.disconnect(),c.disconnect(),delete e.dataset.packed,r(t())}}function Fs(t){e.useLayoutEffect(()=>{const e=t.current;return e?Hs(e):void 0},[t])}const Bs=({id:e,module:t,size:n,foot:s,width:a,height:r})=>({"data-instance":e,"data-module":t,"data-size":n,"data-foot":s,"data-width":a,"data-height":r}),$s=e=>e.some(e=>e.width)?"fraction":void 0,Vs=e.createContext(!1);function Ws(t=e=>e){const[n,s]=e.useState(!1);return[e.useCallback(e=>{const n=e&&t(e);if(!n)return;const a=()=>s(n.hasAttribute("data-wide"));a();const r=new MutationObserver(a);return r.observe(n,{attributes:!0,attributeFilter:["data-wide"]}),()=>r.disconnect()},[t]),n]}function Us({tile:t,visible:s,targetRef:a,children:r}){const[i,o]=Ws(),l=e.useCallback(e=>{const t=i(e);if("function"!=typeof a)return a&&(a.current=e),t;const n=a(e);return()=>{t?.(),"function"==typeof n&&n()}},[i,a]);return n.jsx("div",{ref:l,className:"rp-dashboard-cell","data-visible":s,...Bs(t),children:n.jsx(Vs,{value:o,children:r})})}const Gs=e=>e.closest(".rp-dashboard-cell");function Ks({children:e}){const[t,s]=Ws(Gs);return n.jsx("div",{ref:t,className:"rp-dashboard-body",inert:!0,children:n.jsx(Vs,{value:s,children:e})})}function Js({profile:t,grid:s,children:a}){const r=e.useRef(null);return Fs(r),n.jsx("div",{ref:r,className:"rp-dash-section","data-profile":t,"data-grid":s,children:a})}const Xs=[200,640],Ys=[200,960],Qs=[0,8192],Zs=(e,[t,n])=>Math.round(Math.min(n,Math.max(t,e))),ea=e=>({width:Zs(e.width,Xs),height:Zs(e.height,Ys)}),ta=({x:e,y:t,top:n})=>({x:Zs(e,Qs),y:Zs(t,Qs),...n&&{top:n}}),na=({x:e,y:t,top:n},s,a)=>({x:Math.max(0,Math.min(e,s.width-Math.min(a.width,s.width))),y:Math.max(0,Math.min(t,s.height-Math.min(a.height,s.height))),...n&&{top:n}});const sa={height:Ys[0]},aa=280,ra=480;function ia(e,t,n,s,a,r=Ys[1],i=Math.abs(s)){const o=(e,t,n,s,a,r,i)=>{if(!e)return[n,s];const o=Zs(n+("end"===e?a:-a),r);if(e!==t)return[Math.max(Math.min(n,r[0]),Math.min(o,i-s)),s];const l=Math.min(o,n+s);return[l,s-(l-n)]},[l,c]=o(t.inline,"end",e.size.width,e.offset.x,n,Xs,a?.width??1/0),[d,u]=o(t.block,e.offset.top?"start":"end",e.size.height,e.offset.y,s,[Ys[0],Math.max(Ys[0],Math.min(Ys[1],r))],a?.height??1/0);return{size:{width:l,height:!t.block||t.inline&&!i?Ys[1]:d},offset:{x:c,y:u,...e.offset.top&&{top:e.offset.top}}}}function oa(e,t,n,s){const a="left"===n||"right"===n,[r,i,o]=a?[e.top,e.height,t.height]:[e.left,e.width,t.width];return{at:Math.round(Math.max(0,Math.min(o-s,r+(i-s)/2))),shift:{right:{x:t.width-e.left,y:0},left:{x:-(e.left+e.width),y:0},bottom:{x:0,y:t.height-e.top},top:{x:0,y:-(e.top+e.height)}}[n]}}const la=(e,t=[1,3,8])=>t["small"===e?0:"medium"===e?1:2],ca=e.createContext("panel"),da=(e,t)=>({label:e,resource:t,forms:["area","sparkline","kv"],compact:["sparkline","kv"],sizes:["small","medium","large"],kvSizes:["small","medium"]}),ua=(e,t)=>({label:e,resource:t,forms:["kv"],compact:["kv"],sizes:["small","medium","large"]}),ma=(e,t)=>({...ua(e,t),forms:["donut","waffle","ranked","kv"],compact:["donut","ranked","kv"]}),ha=(e,t)=>({...ma(e,t),rows:!0}),pa=3,fa={speed:{...da("widgets.speed","runtime"),rate:!0},traffic:{...ua("widgets.traffic","runtime"),sizes:["medium"],widest:"1/2"},connections:{...da("act.active","runtime"),tile:!0,untitled:!0},memory:{...da("act.memory","runtime_memory"),tile:!0},cpu:{...da("act.cpu","runtime"),tile:!0,untitled:!0},ranking:{...ha("widgets.ranking","connections"),forms:["ranked","kv"],compact:["ranked","kv"]},outbounds:ha("widgets.outbounds","runtime_outbounds"),mode:{...ua("act.mode","config"),sizes:["medium"]},global:{...ua("act.global","config"),sizes:["medium"],untitled:!0},group:{...ua("widgets.group","groups"),sizes:["medium"],widest:"2/3"},status:{...ua("widgets.status","runtime"),sizes:["medium"],forms:["facts","kv"],compact:["kv"]},notices:ua("widgets.notices","events"),download:{...da("ui.download","runtime"),tile:!0,rate:!0},upload:{...da("ui.upload","runtime"),tile:!0,rate:!0},latency:{...ua("act.latency","nodes"),sizes:["medium"],tile:!0,groupChoice:"act.groupFollow"},history:{...da("act.traffic","runtime"),rate:!0},nodeLatency:{...ua("ui.nodeLatency","nodes"),forms:["dots","ranked"],compact:["dots","ranked"],rows:!0,narrowest:"1/2",groupChoice:"dashboard.allGroups"},sourceHealth:{...ua("dashboard.sourceHealth","providers"),sizes:["medium"],rows:!0},providerBudget:{...ua("dashboard.providerBudget","providers"),sizes:["medium"],rows:!0},connectionOutbounds:ha("dashboard.connectionOutbounds","connections"),connectionNetworks:{...ma("dashboard.connectionNetworks","connections"),sizes:["medium"],widest:"1/2"},dnsAnswers:{...ma("dashboard.dnsAnswers","dns_log"),widest:"1/2"},policyGroups:{...ua("dashboard.policyGroups","groups"),rows:!0,groupChoice:"dashboard.allGroups"},outboundErrors:{...ha("widgets.outboundErrors","runtime_outbounds"),forms:["ranked","kv"],compact:["ranked","kv"],sizes:["medium","large"]},nodeAvailability:{...ua("widgets.nodeAvailability","nodes"),sizes:["small","medium"],narrowest:"1/5",widest:"1/3"},dnsLatency:{...ua("widgets.dnsLatency","dns_log"),forms:["dots","kv"],compact:["dots","kv"],kvSizes:["small","medium"],widest:"2/3"},divider:{...ua("widgets.divider",null),sizes:["medium"],panelOnly:!0}},ga=["1/5","1/4","1/3","1/2","2/3","full"],ba=["short","standard","tall"],xa=[3,5,8],va=({tile:e,narrowest:t,widest:n})=>[ga.indexOf(e?"1/5":t??"1/3"),ga.indexOf(n??"full")],ya=e=>{const[t,n]=va(fa[e]);return ga.slice(t,n+1)},ja=(e,t)=>{const[n,s]=va(fa[e]);return ga[Math.min(Math.max(ga.indexOf(t),n),s)]},wa=e=>e.instance??e.id,ka=e=>t=>wa(t)===wa(e)?e:t,Na=(e,t)=>fa[e]["panel"===t?"compact":"forms"],Ma=e=>!0===fa[e].panelOnly,_a=(e,t,n)=>"panel"===n&&"kv"===t&&fa[e].kvSizes||fa[e].sizes,Sa=e=>fa[e].sizes.includes("small");function Ca(e,t){const n=Na(e.id,t);return"text"===e.form?n.includes("kv")?"kv":n.at(-1):"chart"===e.form?n[0]:n.includes(e.form)?e.form:n[0]}const Ea=e=>({id:e,form:Na(e,"panel")[0],size:"medium"}),La=()=>({version:4,items:[Ea("speed"),{id:"memory",form:"text",size:"medium"},Ea("mode")],collapsed:!1,pinned:!1,visible:!0}),za={size:void 0,offset:void 0,docked:void 0,dockHeight:void 0},Ra=e=>Object.keys(za).some(t=>void 0!==e[t]),Oa=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),Pa=e=>Object.hasOwn(fa,e);function Aa(e,t,n=!1){const s=new Set,a=new Map,r=[];for(const i of e){if(!Oa(i)||"string"!=typeof i.id||!Pa(i.id))continue;const e=i.id;if("dashboard"===t&&Ma(e))continue;if(void 0!==i.instance&&("string"!=typeof i.instance||!i.instance.length||i.instance.length>128))continue;const o=i.instance??e;if(s.has(o)||(a.get(e)??0)>=3)continue;if(void 0!==i.form&&"chart"!==i.form&&"text"!==i.form&&!Na(e,t).includes(i.form))continue;if(void 0!==i.group&&"string"!=typeof i.group)continue;if(void 0!==i.by&&"dev"!==i.by&&"domain"!==i.by)continue;const l=1===fa[e].sizes.length?"medium":"wide"===i.size&&"dashboard"===t?"wide":"large"===i.size?"large":"small"===i.size&&Sa(e)?"small":"medium",c={id:e,...o!==e?{instance:o}:{},size:l,form:i.form??Na(e,t)[0]};n&&"panel"===t&&(c.form="small"===l?"text":"large"===l?"chart":c.form),c.form=Ca(c,t),"panel"!==t||"large"!==c.size||_a(e,c.form,t).includes("large")||(c.size="medium"),void 0!==i.group&&(c.group=i.group),"ranking"===e&&(c.by="domain"===i.by?"domain":"dev"),"speed"===e&&!0===i.split&&(c.split=!0),"dashboard"===t&&(ga.includes(i.width)&&(c.width=ja(e,i.width)),ba.includes(i.height)&&(c.height=i.height),fa[e].rows&&xa.includes(i.rows)&&(c.rows=i.rows)),s.add(o),a.set(e,(a.get(e)??0)+1),r.push(c)}return r}const Ia=e=>"number"==typeof e&&Number.isFinite(e);function Ta(e){if(!Oa(e)||![1,2,3,4].includes(e.version)||!Array.isArray(e.items))return La();return{version:4,items:Aa(e.items.map(t=>Oa(t)?{...t,...1===e.version&&{size:"medium"},...!0===e.splitRates&&{split:!0}}:t),"panel",e.version<3),...Oa(e.size)&&Ia(e.size.width)&&Ia(e.size.height)?{size:ea({width:e.size.width,height:e.size.height})}:{},...Oa(e.offset)&&Ia(e.offset.x)&&Ia(e.offset.y)?{offset:ta({x:e.offset.x,y:e.offset.y,...!0===e.offset.top&&{top:!0}})}:{},collapsed:!0===e.collapsed,pinned:!0===e.pinned,...!0===e.titles?{titles:!0}:{},...!0===e.docked?{docked:!0}:{},...Ia(e.dockHeight)&&e.dockHeight>0?{dockHeight:Math.round(e.dockHeight)}:{},...!0===e.edge?{edge:!0}:{},visible:!1!==e.visible}}function qa(e,t){const n=fa[e].resource;return!n||!0===t?.resources[n]?.available}const Da=["quick","metrics","traffic","details","extensions"],Ha={quick:["mode","global","status"],metrics:["download","upload","connections","latency","cpu"],traffic:["history","outbounds"],details:["ranking","memory","notices"]},Fa={history:"area",memory:"area",status:"facts"},Ba={mode:"lead",latency:"tail",cpu:"end",notices:"end"},$a=e=>e.instance?void 0:Ba[e.id],Va=e=>({id:wa(e),module:e.id,size:e.size,foot:$a(e),width:e.width,height:e.height}),Wa=e=>({...Ea(e),...Fa[e]?{form:Fa[e]}:{}}),Ua=e=>Object.values(Ha).some(t=>t.includes(e.id))&&(e.form===Wa(e.id).form||!0===fa[e.id].tile&&"sparkline"===e.form),Ga=()=>Ja([...Object.entries(Ha).map(([e,t])=>[e,t.map(Wa)]),["extensions",[{...Ea("nodeLatency"),size:"wide"},Ea("connectionOutbounds"),Ea("dnsAnswers"),Ea("policyGroups")]]]),Ka=e=>e.sections.flatMap(e=>e.items);function Ja(e){const t=new Map;for(const[s,a]of e)for(const e of a)Oa(e)&&!t.has(String(e.instance??e.id))&&t.set(String(e.instance??e.id),s);const n=Aa(e.flatMap(([,e])=>e),"dashboard");return{version:3,sections:Da.map(e=>({id:e,items:n.filter(n=>t.get(wa(n))===e)}))}}function Xa(e,t){if(!t)return Ja([["extensions",e]]);return Ja(Da.map(t=>[t,e.filter(e=>(e=>Oa(e)&&void 0===e.instance?Object.entries(Ha).find(([,t])=>t.includes(e.id))?.[0]??"extensions":"extensions")(e)===t)]))}const Ya=(e,t)=>({...e,sections:e.sections.map(e=>({...e,items:e.items.flatMap(e=>t(e)??[])}))});function Qa(t,n,s,a){let r,i;const o=new Set;function l(){if(!r)try{i=localStorage.getItem(t),r=n(JSON.parse(i??"null")),a&&(r=a(r,null===i,c))}catch{r=s()}return r}function c(e){try{const n=JSON.stringify(e);return localStorage.setItem(t,n),i=n,!0}catch{return!1}}function d(e){o.add(e);const n=n=>{n.key!==t&&null!==n.key||(r=void 0,e())};return addEventListener("storage",n),()=>{o.delete(e),removeEventListener("storage",n)}}return{read:l,save:function(e){let s=l();if("function"==typeof e)try{const e=localStorage.getItem(t);void 0!==i&&e!==i&&(s=n(JSON.parse(e??"null"))),i=e}catch{}const a="function"==typeof e?e(s):e;r=a,c(a),o.forEach(e=>e())},useLayout:()=>e.useSyncExternalStore(d,l)}}const Za=Qa(l.dashboard,function(e){if(!Oa(e))return Ga();if(1===e.version&&Array.isArray(e.items))return Xa(e.items,!0===e.original);if(2!==e.version&&3!==e.version||!Array.isArray(e.sections))return Ga();const t=e.sections.filter(Oa);return Ja(Da.map(e=>[e,t.find(t=>t.id===e&&Array.isArray(t.items))?.items??[]]))},Ga,(e,t,n)=>{try{const s=localStorage.getItem(l.activityGroup);let a=null;try{a=JSON.parse(localStorage.getItem(l.widgets)??"null")}catch{}const r=Oa(a)&&!0===a.splitRates;if(!s&&!r)return e;const i=Ya(e,e=>s&&t&&"latency"===e.id&&!e.instance?{...e,group:s}:r&&"speed"===e.id?{...e,split:!0}:e);if(n(i))try{s&&localStorage.removeItem(l.activityGroup),r&&localStorage.setItem(l.widgets,JSON.stringify(Ta(a)))}catch{}return i}catch{return e}}),er=Za.save,tr=Za.useLayout;function nr({shape:t="rows",count:s=1,...a}){return e.useContext(c)?n.jsx("span",{"aria-hidden":"true",children:"—"}):n.jsx(d,{shape:t,count:s,...a})}function sr({parts:t}){return e.useContext(c)?n.jsx("span",{"aria-hidden":"true",children:"—"}):n.jsx(u,{children:t.map((e,t)=>"line"in e?n.jsx(m,{line:e.line},t):n.jsx(m,{height:e.height},t))})}function ar(e){return n.jsxs(h,{...e,children:[n.jsx("path",{fill:"currentColor",d:"M13.53 9.427c-.292-.292-.766-.294-1.06 0l-1.717 1.714V2.75c0-.414-.336-.75-.75-.75s-.75.336-.75.75v8.4L7.53 9.426c-.293-.293-.767-.293-1.06 0s-.293.767 0 1.06l2.998 2.998c.146.147.338.22.53.22.191 0 .384-.073.53-.22l3.002-2.998c.293-.292.293-.767 0-1.06"}),n.jsx("path",{fill:"currentColor",d:"M15.75 18H4.25C3.01 18 2 16.99 2 15.75v-2.021c0-.415.336-.75.75-.75s.75.335.75.75v2.021c0 .413.337.75.75.75h11.5c.413 0 .75-.337.75-.75v-2.021c0-.415.336-.75.75-.75s.75.335.75.75v2.021c0 1.24-1.01 2.25-2.25 2.25"})]})}function rr(e){return n.jsxs(h,{...e,children:[n.jsx("path",{fill:"currentColor",d:"m13.527 10.491-3.002-2.998c-.293-.293-.767-.293-1.06 0l-2.998 2.998c-.293.293-.293.768 0 1.06.147.147.339.22.53.22s.384-.073.53-.22L9.25 9.83v8.18c0 .414.336.75.75.75s.75-.336.75-.75V9.837l1.718 1.715c.293.293.767.293 1.06 0s.293-.769 0-1.06"}),n.jsx("path",{fill:"currentColor",d:"M15.75 17h-2.799c-.414 0-.75-.336-.75-.75s.336-.75.75-.75h2.799c.414 0 .75-.337.75-.75V4.25c0-.413-.336-.75-.75-.75H4.25c-.414 0-.75.337-.75.75v10.5c0 .413.336.75.75.75h2.726c.414 0 .75.336.75.75s-.336.75-.75.75H4.25C3.01 17 2 15.99 2 14.75V4.25C2 3.01 3.01 2 4.25 2h11.5C16.99 2 18 3.01 18 4.25v10.5c0 1.24-1.01 2.25-2.25 2.25"})]})}function ir(e){return n.jsx(h,{...e,children:n.jsx("path",{fill:"currentColor",fillRule:"evenodd",d:"M5.5 4h9A1.5 1.5 0 0 1 16 5.5v9a1.5 1.5 0 0 1-1.5 1.5h-9A1.5 1.5 0 0 1 4 14.5v-9A1.5 1.5 0 0 1 5.5 4m.25 1.5a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-8.5a.25.25 0 0 0-.25-.25zM7.5 7.5h5v5h-5zM6.25 1.5h1.5V4h-1.5zM6.25 16h1.5v2.5h-1.5zM1.5 6.25H4v1.5H1.5zM16 6.25h2.5v1.5H16zM9.25 1.5h1.5V4h-1.5zM9.25 16h1.5v2.5h-1.5zM1.5 9.25H4v1.5H1.5zM16 9.25h2.5v1.5H16zM12.25 1.5h1.5V4h-1.5zM12.25 16h1.5v2.5h-1.5zM1.5 12.25H4v1.5H1.5zM16 12.25h2.5v1.5H16z"})})}function or(e){return n.jsx(h,{...e,children:n.jsx("path",{fill:"currentColor",fillRule:"evenodd",d:"M3 5h14a1.5 1.5 0 0 1 1.5 1.5v6A1.5 1.5 0 0 1 17 14H3a1.5 1.5 0 0 1-1.5-1.5v-6A1.5 1.5 0 0 1 3 5m.25 1.5a.25.25 0 0 0-.25.25v5.5c0 .138.112.25.25.25h13.5a.25.25 0 0 0 .25-.25v-5.5a.25.25 0 0 0-.25-.25zM5 8h2.5v3H5zM8.75 8h2.5v3h-2.5zM12.5 8H15v3h-2.5zM4.25 14h1.5v2.5h-1.5zM7.25 14h1.5v2.5h-1.5zM11.25 14h1.5v2.5h-1.5zM14.25 14h1.5v2.5h-1.5z"})})}const lr=["base","surface","overlay","muted","subtle","text","on-text","love","gold","rose","pine","foam","iris","hl-low","hl-med","hl-high","accent","positive","negative","notice","info","line"];function cr(){const e=getComputedStyle(document.documentElement);return{...Object.fromEntries(lr.map(t=>[t,e.getPropertyValue("--rp-"+t).trim()])),cat:[1,2,3,4,5,6,7,8].map(t=>e.getPropertyValue("--rp-c"+t).trim())}}let dr;function ur(){const{family:e,flavour:t,scheme:n}=document.documentElement.dataset,s=`${e}/${t}/${n}`;return dr?.key!==s&&(dr={key:s,value:cr()}),dr.value}function mr(e){const t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:["data-family","data-flavour","data-scheme"]}),()=>t.disconnect()}function hr(){return e.useSyncExternalStore(mr,ur)}function pr({swatch:e,label:t,value:s,widest:a}){return n.jsxs("span",{className:"it",children:["string"==typeof e?n.jsx("i",{className:"sw",style:{background:e}}):e,t,void 0!==s&&n.jsxs(n.Fragment,{children:[" ",n.jsx("b",{"data-widest":a,children:s})]})]})}const fr=e.lazy(()=>g(()=>import("./AreaChart-CqTV2ZQk.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]),import.meta.url).then(e=>({default:e.AreaPlot}))),gr=e.lazy(()=>g(()=>import("./Sparkline-CiSVZVwG.js"),__vite__mapDeps([12,1,2,3,4,5,6,7,8,9,10,11]),import.meta.url).then(e=>({default:e.SparkPlot}))),br=e.lazy(()=>g(()=>import("./Donut-B59wjqJE.js"),__vite__mapDeps([13,1,2,3,4,6,7,8,9,10,11]),import.meta.url).then(e=>({default:e.DonutPlot})));function xr({series:e,fmt:t,widest:s}){return n.jsx("div",{className:"rp-legend",children:e.map(e=>n.jsx(pr,{swatch:e.color,label:e.label,value:t(e.values[e.values.length-1]),widest:s},e.label))})}const vr=e.memo(function(t){return n.jsx(p,{children:n.jsx(e.Suspense,{fallback:n.jsx("div",{style:t.fill?{minHeight:t.height??150,flex:"1 1 auto",width:"100%"}:{height:t.height??150,width:"100%"}}),children:n.jsx(fr,{...t})})})}),yr=e.memo(function(t){return n.jsx(p,{children:n.jsx(e.Suspense,{fallback:n.jsx("div",{style:{height:t.height??32,width:"100%"}}),children:n.jsx(gr,{...t})})})}),jr=e.memo(function({label:t,rows:s,total:a,legendLimit:r}){const i=f(),o=e.useMemo(()=>s.map(e=>({...e,percent:null===e.value?"—":i("ui.percent",{n:e.value})})),[s,i]);return n.jsxs("div",{className:"rp-donut",children:[n.jsxs("div",{className:"box",children:[n.jsx(p,{children:n.jsx(e.Suspense,{fallback:null,children:n.jsx(br,{label:t,rows:s})})}),n.jsx("div",{className:"center",children:a})]}),n.jsx("div",{className:"lst",children:o.slice(0,r).map(e=>n.jsxs("div",{className:"r",children:[n.jsx("i",{className:"dot",style:{background:e.color}}),n.jsx("span",{className:"n",children:e.href?n.jsx(wn,{appearance:"link",href:e.href,children:e.name}):e.name}),n.jsx("span",{children:e.text}),n.jsx("span",{className:"p",children:e.percent})]},e.name))})]})},(e,t)=>e.label===t.label&&e.total===t.total&&e.legendLimit===t.legendLimit&&(e.rows===t.rows||e.rows.length===t.rows.length&&e.rows.every((e,n)=>{const s=t.rows[n];return e.name===s.name&&e.value===s.value&&e.text===s.text&&e.color===s.color&&e.href===s.href})));function wr({facts:e,lead:t,loading:s}){const a=b();return e.length?n.jsxs("dl",{className:"rp-strip rp-facts"+(t?" rp-facts-lead":""),style:{"--facts":e.length,"--facts-rest":e.length-1},"data-wait":s?a:void 0,children:[s&&n.jsx(x,{}),e.map((e,a)=>n.jsxs("div",{className:"rp-card"+(e.tone?" "+e.tone:"")+("name"===e.valueRole?" rp-fact-name":""),children:[n.jsxs("dt",{className:"rp-tile-head"+(e.tint?" rp-tint-"+e.tint:""),children:[e.icon,e.label]}),n.jsxs("dd",{className:"rp-tile-body",children:[s?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"rp-big",inert:!0,"aria-hidden":"true",children:n.jsx("span",{className:"rp-skeleton-text"})}),e.caption&&n.jsx("span",{className:"rp-fact-caption",inert:!0,"aria-hidden":"true",children:n.jsx("span",{className:"rp-skeleton-text"})})]}):e.nodeName?n.jsx(v,{name:e.value,className:"rp-big",cut:"name"===e.valueRole?void 0:t&&0===a?"start":void 0}):"name"===e.valueRole?n.jsx("span",{className:"rp-big",children:e.value}):n.jsx(y,{className:"rp-big",cut:t&&0===a?"start":void 0,children:e.value}),!s&&e.caption&&n.jsx(y,{className:"rp-fact-caption",children:e.caption})]})]},e.label))]}):null}function kr(e,t,n){const s=t.getBoundingClientRect(),a=n&&"mouse"===e.pointerType?Math.floor(e.clientX):e.clientX,r=n&&"mouse"===e.pointerType?Math.floor(e.clientY):e.clientY,i=a-s.left,o=r-s.top;return n?{x:Math.round(i*n.width/s.width),y:Math.round(o*n.height/s.height),width:n.width}:{x:i,y:o,width:s.width}}function Nr(t,n,s){const[a,r]=e.useState(null),[i,o]=e.useState(!1),[l,c]=e.useState(!1),d=null!==a&&a<t?a:null;return{onFocus:()=>{o(!0),null===d&&t&&(r(0),c(!0),n(0))},onBlur:()=>{o(!1),c(!1),s()},onPointerLeave:()=>{i||s()},onKeyDown:e=>{if(!["ArrowRight","ArrowLeft","Enter","Escape"].includes(e.key))return;if(e.preventDefault(),"Escape"===e.key)return c(!1),void s();if("Enter"===e.key){if(null===d)return;return l?s():n(d),void c(!l)}const a=null===d?"ArrowRight"===e.key?0:t-1:d+("ArrowRight"===e.key?1:-1);a<0||a>=t||(r(a),c(!0),n(a))}}}function Mr(){let e=null;const t=new Set;return{get:()=>e,set(n){var s,a;(s=e)===(a=n)||s&&a&&s.x===a.x&&s.y===a.y&&s.width===a.width&&s.label===a.label&&s.nodeName===a.nodeName&&s.bounds?.x===a.bounds?.x&&s.bounds?.y===a.bounds?.y&&s.bounds?.height===a.bounds?.height&&s.bounds?.width===a.bounds?.width&&s.lines.length===a.lines.length&&s.lines.every((e,t)=>e===a.lines[t])||(e=n,t.forEach(e=>e()))},subscribe:e=>(t.add(e),()=>{t.delete(e)})}}function _r(e){let t=e.parentElement;for(;t&&"visible"===getComputedStyle(t).overflow;)t=t.parentElement;const n=e.getBoundingClientRect();if(!t)return{x:-n.left,y:-n.top,width:document.documentElement.clientWidth,height:document.documentElement.clientHeight};const s=t.getBoundingClientRect();return{x:s.left+t.clientLeft-n.left,y:s.top+t.clientTop-n.top,width:t.clientWidth,height:t.clientHeight}}function Sr(){const t=e.useRef(null),[n]=e.useState(Mr),s=e.useCallback((e,s,a)=>{t.current&&n.set({...kr(e,t.current),lines:s,nodeName:a})},[n]),a=e.useCallback(()=>n.set(null),[n]);return{ref:t,tip:n,show:s,showAt:n.set,hide:a}}function Cr({tip:t}){const s=e.useSyncExternalStore(t.subscribe,t.get);if(!s)return null;if(s.bounds)return n.jsx(Lr,{tip:s});const a=s.x>s.width-120?"end":s.x<120?"start":"middle";return n.jsx("div",{className:"rp-charttip "+a,style:{left:s.x,top:s.y},"aria-hidden":"true",children:s.lines.map((e,t)=>0===t?n.jsx("b",{children:s.nodeName?n.jsx(v,{name:e}):e},t):n.jsx("span",{children:e},t))})}const Er=e=>e;function Lr({tip:t}){const[s,a]=j(Er),[r,i]=e.useState(null);e.useEffect(()=>{const e=e=>{"Escape"===e.key&&i({x:t.x,y:t.y})};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[t.x,t.y]),!r||r.x===t.x&&r.y===t.y||i(null);const o=t.bounds,l=(e,t,n,s)=>{const a=e+10+t>n+s?e-t-10:e+10;return Math.max(n,Math.min(a,n+s-t))},c=l(t.x,a?.width??0,o.x,o.width),d=l(t.y,a?.height??0,o.y,o.height);return n.jsx("div",{ref:s,className:"rp-charttip-bounded",style:{visibility:!a||r?.x===t.x&&r?.y===t.y?"hidden":"visible",pointerEvents:"none",position:"absolute",top:0,left:0,transform:`translate(${c}px, ${d}px)`},children:n.jsxs("div",{role:"status","aria-live":"polite",className:"rp-boundedtip",style:{maxInlineSize:o.width},children:[n.jsx("p",{children:t.label}),n.jsx("ul",{children:t.lines.map((e,t)=>n.jsx("li",{children:e},t))})]})})}function zr(e,t){return e.length?e[Math.min(e.length-1,Math.max(0,Math.ceil(t/100*e.length)-1))]:null}function Rr(e,[t,n]){const s=Math.min(n,Math.max(t,e));return(Math.log10(s)-Math.log10(t))/(Math.log10(n)-Math.log10(t))}function Or(e){const t=e.reduce((e,t)=>e+t,0),n=e.some(e=>e/t*360<6)?Math.min(6,360/e.length):0;return e.map(s=>n+s/t*(360-e.length*n))}function Pr(e,t){return e<=0||t<=0?0:Math.max(1,Math.ceil(e/t*5))}const Ar=[10,30,60,120,300,600,900,1800,3600,7200,21600,43200,86400,172800,604800,2592e3].map(e=>1e3*e);function Ir(e,t,n=24){let s=Ar.find(s=>{return a=s,Math.floor(t/a)-Math.floor(e/a)+1<=n;var a});void 0===s&&(s=Math.ceil((t-e)/(n-1)/Ar[Ar.length-1])*Ar[Ar.length-1]);const a=[];for(let r=Math.floor(e/s)*s;r<=t;r+=s)a.push(r);return a}function Tr(e,t){return Math.log10(1+Math.max(0,Math.min(e,t)))/Math.log10(1+t)}function qr(e,t,n,s,a){const r=Math.max(0,Math.min(e,Math.floor(-t/n)-a)),i=Math.max(r,Math.min(e,Math.ceil((s-t)/n)+a));return r===i&&e?r?{start:e-1,end:e}:{start:0,end:1}:{start:r,end:i}}function Dr(e,[t,n],[s,a]){const r=n===t?.5:(e-t)/(n-t);return s*(1-r)+a*r}function Hr(e,t,n,s,a,r){if(!e.length)return[];const i=e.length>1&&e[1]<e[0]?-1:1;let o=n,l=s;const c=[],d=e.length-1,u=n=>{const s=t[n];if(!Number.isFinite(s)||!Number.isFinite(e[n]))return;let u=i*e[n];n===d?u=Math.min(u,l-s/2):0===n&&r&&(u=Math.max(u,o+s/2)),u-s/2<o||u+s/2>l||(c.push({index:n,position:i*u}),r&&n!==d?o=u+s/2+a:l=u-s/2-a)};if(i<0&&(o=-s,l=-n),u(d),r)for(let m=0;m<d;m++)u(m);else for(let m=d-1;m>=0;m--)u(m);return c.sort((e,t)=>e.index-t.index)}function Fr(e,t){let n=0;for(let s=1;s<e.length;s++)Math.abs(e[s]-t)<Math.abs(e[n]-t)&&(n=s);return n}const Br=12;function $r({label:t,points:s,marks:a=[],rows:r=[],fmt:i,maxHeight:o=160}){const l=f(),c=w(),[d,u]=k(),{ref:m,tip:h,show:p,hide:g}=Sr(),b=e.useMemo(()=>function(e){const t=e.map(e=>Math.max(e,1));if(!t.length)return[1,10];const n=10**Math.floor(Math.log10(Math.min(...t))),s=10**Math.ceil(Math.log10(Math.max(...t)));return[n,s>n?s:10*n]}(s.map(e=>e.value)),[s]),x=e.useMemo(()=>{const e=function([e,t],n=8){const s=[];for(let a=e;a<=t;a*=10)for(const e of[1,2,5])a*e<=t&&s.push(a*e);return s.length>n?s.filter(e=>Math.abs(Math.log10(e)-Math.round(Math.log10(e)))<1e-9):s}(b,u&&u<480?4:8);return null!==u&&u<360?e.filter((e,t)=>t%2==0):e},[b,u]),v=Math.max((u??0)-24,1),y=e=>Br+Rr(e,b)*v,j=s.length>400?2:s.length>120?3:4,{ys:N,hidden:M}=e.useMemo(()=>u?function(e,t,n){const s=e.map((e,t)=>({x:e,index:t})).sort((e,t)=>e.x-t.x),a=[],r=new Array(e.length).fill(0),i=[],o=2*t,l=n-t;for(const{x:c,index:d}of s){const e=[];for(let t=a.length-1;t>=0&&c-a[t].x<o;t--)e.push(a[t]);const n=t=>e.every(e=>(e.x-c)**2+(e.y-t)**2>=o*o-1e-6);let s=0;for(let a=0;!n(s);a++){const e=Math.ceil((a+1)/2)*(t/2);if(e>l){s=null;break}s=a%2?e:-e}if(r[d]=s,null===s){const e=i[i.length-1];e&&c-e.x<Math.max(o,24)?e.count++:i.push({x:c,count:1})}else a.push({x:c,y:s})}return{ys:r,hidden:i}}(s.map(e=>Br+Rr(e.value,b)*v),j,(o-36)/2):{ys:[],hidden:[]},[s,b,v,j,o,u]),_=Math.max(24,2*(Math.max(0,...N.map(e=>Math.abs(e??0)))+j+2)),S=_+36;return n.jsx("div",{className:"rp-swarm",ref:d,children:n.jsxs("div",{className:"rp-chart-hover",ref:m,onPointerLeave:g,children:[null!==u&&n.jsxs("svg",{width:u,height:S,role:"img","aria-label":t,"aria-describedby":c,children:[x.map(e=>{const t=y(e)>=u-Br-1;return n.jsxs("g",{children:[n.jsx("line",{className:"grid",x1:y(e),x2:y(e),y1:16,y2:S-18}),n.jsx("text",{className:"tick",x:t?u:y(e),y:S-4,textAnchor:t?"end":"middle",children:i(e)})]},e)}),s.map((e,t)=>null===N[t]||void 0===N[t]?null:n.jsx("circle",{cx:y(e.value),cy:16+_/2+N[t],r:j,fill:e.color,onPointerMove:t=>p(t,e.lines,e.nodeName)},e.id)),M.map(e=>n.jsxs("text",{className:"more",x:e.x,y:12,textAnchor:"middle",children:["+",e.count]},e.x)),a.map((e,t)=>{const s=y(e.value),a=s<96||t%2==1&&s<u-120;return n.jsxs("g",{className:"mark",children:[n.jsx("line",{x1:s,x2:s,y1:14,y2:S-18}),u>=360&&n.jsx("text",{x:s,y:10,textAnchor:a?"start":"end",dx:a?4:-4,children:e.label})]},e.label)})]}),null!==u&&r.length>0&&n.jsx("div",{className:"rp-strips",children:r.map(e=>n.jsxs("div",{className:"rp-strip-row",children:[n.jsxs("div",{className:"rp-row",children:[n.jsx("span",{className:"name",children:e.label}),n.jsx("span",{className:"rp-note",children:e.detail})]}),n.jsxs("svg",{width:u,height:20,role:"img","aria-label":l("ui.valuePair",{label:e.label,value:e.detail}),children:[n.jsx("line",{className:"grid",x1:Br,x2:Br+v,y1:10,y2:10}),e.points.map(e=>n.jsx("circle",{cx:y(e.value),cy:10,r:4,fill:e.color,onPointerMove:t=>p(t,e.lines,e.nodeName)},e.id)),void 0!==e.mark&&n.jsx("line",{className:"median",x1:y(e.mark),x2:y(e.mark),y1:-2,y2:22})]})]},e.id))}),n.jsx(Cr,{tip:h})]})})}function Vr({label:t,shares:s,legendLimit:a}){const r=f(),i=w(),{ref:o,tip:l,show:c,hide:d}=Sr(),u=e.useMemo(()=>{const e=function(e){const t=e.reduce((e,t)=>e+t,0);if(!t)return e.map(()=>0);const n=e.map(e=>e/t*100),s=n.map(Math.floor);let a=100-s.reduce((e,t)=>e+t,0);const r=n.map((e,t)=>({index:t,rest:e-s[t]})).sort((e,t)=>t.rest-e.rest||e.index-t.index);for(const{index:i}of r){if(!a)break;s[i]++,a--}for(let i=0;i<e.length;i++)if(e[i]>0&&0===s[i]){const e=s.indexOf(Math.max(...s));s[e]--,s[i]=1}return s}(s.map(e=>e.count));return s.flatMap((t,n)=>Array.from({length:e[n]},()=>t))},[s]);return n.jsxs("div",{className:"rp-waffle rp-chart-hover",ref:o,onPointerLeave:d,children:[n.jsxs("div",{className:"body",children:[n.jsx("div",{className:"grid",role:"img","aria-describedby":i,"aria-label":N(t,s,r),children:u.map((e,t)=>n.jsx("span",{style:{background:e.color},onPointerMove:t=>c(t,[e.label,e.text])},t))}),n.jsx("ul",{className:"legend",children:s.slice(0,a).map(e=>n.jsxs("li",{children:[n.jsx("i",{className:"sw",style:{background:e.color}}),n.jsx("span",{children:e.label}),n.jsx("b",{children:e.text})]},e.id))})]}),n.jsx(Cr,{tip:l})]})}function Wr({kind:e,tone:t}){return n.jsx("i",{className:"rp-marker "+e+(t?" "+t:""),"aria-hidden":"true"})}function Ur({rows:s,focused:a,render:r}){const i=e.useRef(null),o=e.useRef(()=>{}),[l,c]=e.useState({start:0,end:Math.min(s.length,40),height:0}),[d,u]=e.useState(!1);e.useLayoutEffect(()=>{let e=0;o.current=()=>{cancelAnimationFrame(e),e=0;const t=i.current;if(!t)return;const n=t.querySelector(":scope > .row")?.getBoundingClientRect().height;c(e=>{const a=n||e.height;if(!a)return e;const r={...qr(s.length,t.getBoundingClientRect().top,a,innerHeight,10),height:a};return e.start===r.start&&e.end===r.end&&e.height===r.height?e:r})};const n=()=>{e||(e=requestAnimationFrame(o.current))},a=()=>t.flushSync(()=>u(!0)),r=()=>u(!1);return o.current(),addEventListener("scroll",n,{capture:!0,passive:!0}),addEventListener("resize",n),addEventListener("beforeprint",a),addEventListener("afterprint",r),()=>{cancelAnimationFrame(e),removeEventListener("scroll",n,{capture:!0}),removeEventListener("resize",n),removeEventListener("beforeprint",a),removeEventListener("afterprint",r)}},[s.length]);const m=function(e,t){if(t<0||t>=e.start&&t<e.end)return[e];if(t===e.end)return[{start:e.start,end:t+1}];if(t===e.start-1)return[{start:t,end:e.end}];const n={start:t,end:t+1};return t<e.start?[n,e]:[e,n]}(d?{start:0,end:s.length}:{start:Math.min(l.start,s.length),end:Math.min(l.end,s.length)},s.findIndex(e=>e.id===a)),h=[];let p=0;const f=e=>e>p&&h.push(n.jsx("div",{style:{height:(e-p)*l.height},"aria-hidden":"true"},"gap-"+p));for(const e of m)f(e.start),h.push(...s.slice(e.start,e.end).map(r)),p=e.end;return f(s.length),n.jsx("div",{ref:i,onFocus:()=>o.current(),children:h})}function Gr({label:t,groups:s,legend:a,max:r,fmt:i,limit:o=10,showAll:l,summary:c}){const d=f(),u=w(),{ref:m,tip:h,show:p,hide:g}=Sr(),[b,x]=e.useState(new Set),[j,k]=e.useState(null),N=e.useRef(null);e.useLayoutEffect(()=>{const e=N.current;if(!e||document.activeElement===e.element||document.activeElement&&document.activeElement!==document.body)return;const t=m.current?.querySelector(`[data-row="${CSS.escape(e.id)}"] a`);t&&(N.current={id:e.id,element:t},t.focus({preventScroll:!0}))});const _=[0,r/4,r/2,3*r/4,r],S=e=>Math.min(100,e/r*100),C=e=>{const t=e.range&&function([e,t],n){const s=e=>Math.min(100,Math.max(0,e/n*100));return{start:s(e),width:s(t)-s(e)}}(e.range,r);return n.jsxs("div",{className:"row","data-row":e.id,onPointerMove:t=>p(t,[e.label,...e.details()],e.nodeName),children:[n.jsx("span",{className:"name",children:e.href?n.jsx(wn,{appearance:"link",href:e.href,children:e.nodeName?n.jsx(v,{name:e.label}):e.label}):e.nodeName?n.jsx(v,{name:e.label}):n.jsx(y,{children:e.label})}),n.jsxs("div",{className:"track",role:"img","aria-label":[e.label,...e.details()].join(d("ui.separator")),children:[_.map(e=>n.jsx("i",{className:"grid",style:{insetInlineStart:`${S(e)}%`}},e)),t&&t.width>0&&n.jsx("i",{className:"line",style:{insetInlineStart:`${t.start}%`,width:`${t.width}%`}}),null!==e.average&&n.jsx("span",{className:"at",style:{insetInlineStart:`${S(e.average)}%`},children:n.jsx(Wr,{kind:"ring"})}),n.jsx("span",{className:"at"+(e.value>r?" over":""),style:{insetInlineStart:`${S(e.value)}%`},children:n.jsx(Wr,{kind:"dot",tone:e.tone})})]}),n.jsx("span",{className:"value",children:e.text})]},e.id)};return n.jsxs("div",{className:"rp-markerplot rp-chart-hover",ref:m,onPointerLeave:g,onFocus:e=>{const t=e.target.closest("[data-row]")?.dataset.row;N.current=t?{id:t,element:e.target}:null,k(t??null)},onBlur:e=>{const t=e.target;queueMicrotask(()=>{N.current?.element===t&&document.activeElement!==t&&(N.current=null,k(null))})},role:"group","aria-label":t,"aria-describedby":u,children:[(c||a.length>0)&&n.jsxs("div",{className:"head",children:[c,a.length>0&&n.jsx("ul",{className:"legend",children:a.map(e=>n.jsxs("li",{children:[n.jsx(Wr,{kind:e.kind,tone:e.tone}),e.label]},e.label))})]}),n.jsxs("div",{className:"axis","aria-hidden":"true",children:[n.jsx("span",{}),n.jsx("div",{className:"scale",children:_.map(e=>n.jsx("span",{style:{insetInlineStart:`${S(e)}%`},children:i(e)},e))}),n.jsx("span",{})]}),s.map(e=>n.jsxs("section",{"aria-label":e.label,children:[s.length>1&&n.jsx("h4",{className:"rp-label",children:e.label}),b.has(e.id)?e.rows.length>40?n.jsx(Ur,{rows:e.rows,focused:j,render:C}):e.rows.map(C):e.rows.slice(0,o).map(C),!b.has(e.id)&&e.rows.length>o&&n.jsx("div",{className:"row more",children:n.jsx(M,{quiet:!0,small:!0,onPress:()=>x(t=>new Set([...t,e.id])),children:l(e.rows.length)})}),e.notes.map((e,t)=>n.jsx("p",{className:"rp-note note",children:e},t))]},e.id)),n.jsx(Cr,{tip:h})]})}function Kr({label:t,rows:s,columns:a}){const r=w(),{ref:i,tip:o,show:l,hide:c}=Sr(),d=e.useRef(null),[u,m]=e.useState(!1);return e.useLayoutEffect(()=>{const e=d.current;if(!e)return;const t=()=>{const[t,n,s]=[...e.children].map(e=>e.getBoundingClientRect());m(void 0!==s&&(n.left-t.right<16||s.left-n.right<16))};t();const n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[a]),n.jsxs("div",{className:"rp-heatmap rp-chart-hover",ref:i,onPointerLeave:c,role:"group","aria-label":t,"aria-describedby":r,style:{"--cols":a.length},children:[s.map(e=>{const t=Math.max(...e.counts);return n.jsxs("div",{className:"row",children:[n.jsx("div",{className:"head",children:e.label}),n.jsx("div",{className:"cells",children:e.counts.map((s,a)=>n.jsx("span",{className:"cell t"+Pr(s,t),style:{"--tone":e.color},onPointerMove:t=>l(t,[e.titles[a]]),role:"img","aria-label":e.titles[a]},a))})]},e.id)}),a.length>0&&n.jsxs("div",{className:"row times","aria-hidden":"true",children:[n.jsx("div",{className:"head"}),n.jsxs("div",{className:"ends",ref:d,children:[n.jsx("span",{children:a[0]}),a.length>2&&n.jsx("span",{className:u?"gone":void 0,children:a[Math.floor(a.length/2)]}),a.length>1&&n.jsx("span",{children:a[a.length-1]})]})]}),n.jsx(Cr,{tip:o})]})}const Jr=64;function Xr({label:e,series:t,fmt:s,onSelect:a,regions:r,height:i=260}){const o=w(),[l,c]=k(),{ref:d,tip:u,show:m,hide:h}=Sr(),p=Math.max(1,...t.flatMap(e=>e.points.flatMap(e=>[e.x,e.y]))),{end:f,ticks:g}=function(e){const t=Math.max(1e3,2*e),n=[0];for(let s=1e3;s<=t;s*=1e3)n.push(s);return{end:t,ticks:n}}(p),b=Math.max((c??0)-Jr-28,1),x=i-8-22,v=e=>Jr+Tr(e,f)*b,y=e=>8+(1-Tr(e,f))*x,j=new Map,N=t.flatMap(e=>e.points.map(t=>{const n=v(t.x),s=y(t.y),a=n+","+s,r=j.get(a)??0;return j.set(a,r+1),{point:t,color:e.color,cx:n,cy:s,nth:r,spot:a}})).map(e=>({...e,twins:j.get(e.spot)}));return n.jsx("div",{className:"rp-scatter",ref:l,children:n.jsxs("div",{className:"rp-chart-hover",ref:d,onPointerLeave:h,children:[null!==c&&n.jsxs("svg",{width:c,height:i,role:"img","aria-label":e,"aria-describedby":o,children:[g.map(e=>n.jsxs("g",{children:[n.jsx("line",{className:"grid",x1:v(e),x2:v(e),y1:8,y2:8+x}),n.jsx("line",{className:"grid",x1:Jr,x2:Jr+b,y1:y(e),y2:y(e)}),n.jsx("text",{className:"tick",x:v(e),y:i-6,textAnchor:"middle",children:s(e)}),n.jsx("text",{className:"tick",x:56,y:y(e)+4,textAnchor:"end",children:s(e)})]},e)),r&&n.jsxs("g",{className:"diagonal",children:[n.jsx("line",{x1:v(0),y1:y(0),x2:v(f),y2:y(f)}),n.jsx("text",{x:72,y:22,children:r.above}),n.jsx("text",{x:Jr+b-8,y:8+x-8,textAnchor:"end",children:r.below})]}),N.map(({point:e,color:t,cx:s,cy:r,nth:i,twins:o})=>{const l=2*Math.PI*i/o,c=o>1?6:0;return n.jsx("circle",{className:a?"pick":void 0,cx:s+c*Math.cos(l),cy:r+c*Math.sin(l),r:5,fill:t,onClick:a?()=>a(e.id):void 0,onPointerMove:t=>m(t,[e.name,e.detail])},e.id)})]}),n.jsx(Cr,{tip:u})]})})}function Yr({series:e}){return n.jsx("div",{className:"rp-legend",children:e.map(e=>n.jsx(pr,{swatch:e.color,label:e.label,value:String(e.points.length)},e.id))})}function Qr(e){return n.jsx(h,{...e,children:n.jsx("path",{fill:"currentColor",d:"M8.999 18.729c-.36 0-.717-.099-1.037-.293C7.359 18.07 7 17.43 7 16.726V10.49c0-.186-.068-.364-.192-.501l-4.18-4.644c-.538-.59-.674-1.416-.349-2.152S3.305 2 4.11 2h11.782c.804 0 1.505.457 1.83 1.193s.19 1.562-.353 2.156l-4.176 4.64c-.124.137-.192.315-.192.501v5.046c0 .843-.465 1.609-1.213 1.997l-1.865.968c-.292.152-.609.228-.923.228M4.109 3.5c-.295 0-.418.209-.458.298s-.11.322.088.54l4.184 4.647c.372.413.577.948.577 1.505v6.236c0 .254.168.383.24.427.073.045.266.133.49.017l1.866-.969c.25-.13.404-.384.404-.665V10.49c0-.557.205-1.092.577-1.505l4.18-4.644c.202-.22.132-.453.092-.543s-.163-.298-.458-.298z"})})}function Zr({model:e}){const t=f();return e.writable?n.jsx(M,{accent:!0,isDisabled:!e.dirty||e.incomplete,isPending:e.busy,onPress:e.apply,children:t("config.save")}):null}function ei({model:e,fill:t}){const s=f(),a=E();return n.jsxs("span",{className:"rp-cluster",children:[n.jsx(Rn,{label:s("act.mode"),value:e.mode,onChange:e.pick,isDisabled:e.busy||!e.writable,items:e.modes,fill:t}),e.writable?n.jsx(Zr,{model:e}):e.readOnly?n.jsx(L,{label:s("act.modeWhyReadOnly"),placement:"bottom end",trigger:n.jsx(M,{quiet:!0,label:s("act.modeWhyReadOnly"),children:e.status}),children:()=>n.jsxs(n.Fragment,{children:[n.jsx("p",{children:s("act.modeReadOnlyReason")}),n.jsx("p",{children:s("act.modeReadOnlyAction")}),n.jsx(wn,{external:!0,appearance:"link",href:z(a,"read-only"),children:s("act.readOnlyDocs")})]})}):n.jsx(R,{small:!0,tone:"muted",children:e.status})]})}function ti({model:e,part:t}){const s=f();return n.jsxs(n.Fragment,{children:["global"!==t&&e.error&&n.jsx(_,{error:e.error,onRetry:e.retry}),"global"!==t&&n.jsx(S,{title:s("act.mode"),"aria-label":s("act.mode"),tile:{icon:n.jsx(C,{}),tint:3,kind:"control"},reason:e.reasons.mode,aside:n.jsx(ei,{model:e})}),"mode"!==t&&n.jsx(S,{title:s("act.global"),tile:{icon:n.jsx(Qr,{}),tint:2,kind:"control"},reason:e.reasons.global,aside:n.jsxs("span",{className:"rp-cluster rp-global-controls",children:[n.jsx(kn,{quiet:!0,isDisabled:e.busy||!e.writable,label:s("act.global"),value:e.target,onChange:e.pickTarget,items:e.targets,searchLabel:s("ui.filterOutbounds"),children:n.jsx(zn,{labels:e.targets.map(e=>e.label),children:e.targetText})}),n.jsx(Zr,{model:e})]})})]})}const ni=(e,t)=>"invalid"===e.kind?{kind:"negative",text:t("ui.writeInvalid",{n:e.errors})}:"failed"===e.kind?I(e.error,t,t("ui.writeFailed")):null;function si(){const t=O().data?.resources,n=P(t,"config",{whileLoading:!1})&&!0===t?.config.writable,s=On(P(t,"config",{whileLoading:!1})),a=Pn(s.refetch,{rethrow:!0,shared:"main-source-edit"}),r=s.data?.sources.find(e=>"main"===e.kind&&e.writable)??null,i=An(r),o=i?r:null,l=!1===i,c=e.useMemo(()=>s.error??(l?new A("config.incomplete"):null),[s.error,l]),{apply:d}=a;return{main:o,checking:!!r&&null===i,writable:n,busy:null!==a.busy,error:c,retry:s.refetch,apply:e.useCallback(async(e,t=o??void 0)=>{if(!t)return{kind:"failed",error:c??new A("config.incomplete")};try{const n=await d(t,e);return n?n.diagnostics?{kind:"invalid",errors:n.diagnostics.filter(e=>"error"===e.level).length}:{kind:"ok"}:{kind:"cancelled"}}catch(n){return{kind:"failed",error:n}}},[o,d,c])}}const ai="# doona: outbound mode";function ri(e,t,n){return n.filter(n=>"comment"===n.kind&&e.slice(n.from,n.to).trim()===ai&&t.some(e=>"routing"===e.name&&n.from>e.open&&n.to<e.close&&1===n.depth)).flatMap(t=>{const s=e.lastIndexOf("\n",t.from-1)+1,a=n.filter(e=>e.from>=s&&e.to<=t.from);if(a.some(e=>1!==e.depth))return[];const r=a.findIndex(t=>0===t.parens&&"->"===e.slice(t.from,t.to)),i=-1===r||r===a.length-1?"":e.slice(a[r+1].from,t.from).trim();return[{from:s,to:t.to+("\n"===e[t.to]?1:0),target:i}]})}const ii=(e,t)=>e.mode===t.mode&&("global"!==e.mode||"global"!==t.mode||e.target===t.target);function oi(e){const t=Jt(e);return ri(e,t.blocks,t.tokens).map(t=>e.slice(0,t.from).split("\n").length)}const li={rule:"mode.rule",direct:"mode.direct",global:"mode.global"};function ci({writable:e,incomplete:t,status:n},s,a){return s?{mode:null,global:null}:e?{mode:t?a("act.globalMissing"):null,global:null}:{mode:null,global:n}}function di(){const t=f(),n=O().data?.resources,s=In(P(n,"groups",{whileLoading:!1})),a=On(P(n,"config",{whileLoading:!1})),{main:r,checking:i,writable:o,busy:l,error:c,retry:d,apply:u}=si(),m=T().data,h=Tn(m).daeText,p=h?(r??a.data?.sources.find(e=>"main"===e.kind))?.content:void 0,g=e.useMemo(()=>null==p?{mode:"rule"}:function(e){const{blocks:t,tokens:n}=Jt(e),s=ri(e,t,n).find(e=>e.target);return s?"direct"===s.target?{mode:"direct"}:{mode:"global",target:s.target}:{mode:"rule"}}(p),[p]),[b,x]=q(),v=D({shared:"mode-action"}),y=(h||!m)&&!!n?.config.available,j=function(e,t,n,s,a,r,i=!0){const o=s?t??e:e,l="global"===o.mode?o.target:("global"===e.mode?e.target:n[0]?.name)??"";return{mode:i?o.mode:"",target:i?l:"",targetText:i&&l||"—",writable:s,dirty:s&&null!==t&&!ii(t,e),incomplete:"global"===o.mode&&!l,status:r(a?"act.modeReadOnly":"act.modeUnavailable"),readOnly:a&&!s,modes:["rule","direct","global"].map(e=>[e,r(li[e])]),targets:n.map(e=>({id:e.name,label:e.name}))}}(g,b,s.data??[],h&&o&&(!!r||i),y,t,null!=p),w=()=>v.run("apply",async()=>{const e=b;if(!e||"global"===e.mode&&!e.target)return;const n=await u(t=>function(e,t){const n=Jt(e);for(const m of ri(e,n.blocks,n.tokens).reverse())e=e.slice(0,m.from)+e.slice(m.to);if("rule"===t.mode)return e;const{blocks:s,tokens:a}=Jt(e),r=s.find(e=>"routing"===e.name);if(!r)throw new A("act.modeNoRouting");const i=e.slice(r.open+1,r.close),o=i.match(/\n([ \t]+)\S/)?.[1]??" ";let l=r.open+1;"\n"===e[l]&&l++;let c=null;const d=t=>{const n=e.indexOf("\n",t);return e.slice(e.lastIndexOf("\n",t-1)+1,-1===n?void 0:n).trim()};for(let m=0;m<a.length;m++){const t=a[m];if(t.from<=r.open||t.to>r.close||1!==t.depth||0!==t.parens||"->"!==e.slice(t.from,t.to))continue;const n=a[m+1],s=a[m+2],i=a[m+3],o=a[m+4];if(!(n&&s&&i&&o&&"("===e.slice(s.from,s.to)&&"must"===e.slice(i.from,i.to)&&")"===e.slice(o.from,o.to))){c??=d(t.from);continue}if(null!==c)throw new A("act.modeInterleaved",c);const u=e.indexOf("\n",o.to);l=-1!==u&&u<r.close?u+1:o.to;const h=a[m+5];if(h&&h.from<l&&"comment"!==h.kind)throw new A("act.modeInterleaved",d(h.from))}const u="direct"===t.mode?"direct":t.target;return e.slice(0,l)+("\n"===e[l-1]?"":"\n")+`${o}l4proto(tcp, udp) -> ${u} ${ai}\n`+e.slice(l)}(t,e));if("ok"===n.kind&&(x(t=>t===e?null:t),H("positive",t("act.modeApplied",{mode:t(li[e.mode])}))),"failed"===n.kind&&n.error instanceof A&&"act.modeInterleaved"===n.error.key)return void H("negative",t(n.error.key),{detail:n.error.detail??void 0,error:n.error});const s=ni(n,t);s&&H(s.kind,s.text,{detail:s.detail,requestId:s.requestId,error:s.error})});return{...j,reasons:ci(j,l||!!v.busy,t),error:c,retry:d,busy:l||!!v.busy,pick:e=>{if("global"===e||"direct"===e||"rule"===e){const t="global"===e?{mode:e,target:j.target}:{mode:e};x(ii(t,g)?null:t)}},pickTarget:e=>{const t={mode:"global",target:e};x(ii(t,g)?null:t)},apply:()=>{w()}}}const ui=e=>{const t=Date.parse(e.observed_at);return Number.isFinite(t)?{time:t,value:e.process.cpu_percent}:void 0},mi=(e,t)=>({time:t,value:W(e.map(e=>e.value))});function hi(t,n=!0){const s=e.useContext(c);return F("cpu",s?void 0:t,ui,mi,n,s)}const pi=(e,t)=>({time:t,value:(e&&$(V(e)))??null});function fi(e,t,n){const s=function(e,t){if(e.length<=24)return e;const n=Math.ceil(e.length/24),s=[];let a=[];const r=()=>{for(let e=0;e<a.length;e+=n)s.push(t(a.slice(e,e+n),a[e].time));a=[]};for(const i of e)null!==i.value?a.push(i):(r(),null!==s.at(-1)?.value&&s.push(i));return r(),s}(B(e,[],t,n,void 0,1/0).samples,n);return{timestamps:s.map(e=>e.time),values:s.map(e=>e.value)}}function gi(e,t,n){return e.flatMap(({label:e,values:s})=>{const a=s.filter(e=>null!==e),[r,i]=a.length?[Math.max(...a),a.reduce((e,t)=>e+t,0)/a.length].map(t):["—","—"];return[{label:n("widgets.peak",{series:e}),value:r},{label:n("widgets.average",{series:e}),value:i}]})}function bi(e,t,n=5){const s=new Map;for(const i of U(e)){const e="dev"===t?G(i.src):i.domain||i.dst;e&&s.set(e,K(s.has(e)?s.get(e):0n,i.download_bytes))}const a=[...s].map(([e,t])=>({name:e,download:t})),r=K(...a.map(e=>e.download));return a.sort((e,t)=>e.download===t.download?0:null===e.download?1:null===t.download||e.download>t.download?-1:1),a.slice(0,n).map(e=>({...e,percent:J(e.download,r)}))}const xi=["ok","warn","err"];function vi(e,t,n,s){const r=Q(e),i=e?X(Y,e,s):n;return!e||"degraded"!==t&&"failed"!==t?{tone:r,text:i,href:null}:{tone:xi[Math.max(xi.indexOf(r),"failed"===t?2:1)],text:s("failed"===t?"ov.status.datapathFailed":"ov.status.datapathDegraded",{status:i}),href:a("overview",{card:"datapath"})}}const yi=e=>"operation.updated"===e.event&&"failed"===e.data.status?"err":"flow.gap"===e.event?"warn":"info";function ji(e,t){const n=oe(e,t),s=Object.fromEntries(Object.entries(n.params??{}).map(([e,t])=>[e,"string"==typeof t?le(t):t]));return"event.gapUnscopedNoCount"===n.key?String(s.reason):t("event.gapUnscoped"===n.key?"act.noticeGap":n.key,s)}function wi(e,t){const n=new Map;for(const s of e){const e=yi(s),a=t("ui.valuePair",{label:X(re,s.event,t),value:ji(s,t)}),r=`${e}|${s.event}|${a}`,i=n.get(r);i?i.count+=1:n.set(r,{row:{id:qn(s),tone:e,kindText:t("err"===e?"ui.error":"warn"===e?"ui.warning":"ui.notice"),summaryText:a},count:1})}return{rows:[...n.values()].slice(0,8).map(({row:e,count:n})=>n>1?{...e,summaryText:t("ui.aside",{text:e.summaryText,note:t("act.noticeRepeat",{n:n})})}:e),total:n.size}}function ki(e,t,n,s=!1){return e.down.some(e=>null!==e)||e.up.some(e=>null!==e)?"ready":!1===t?s?"loading":"unavailable":n?"empty":"loading"}function Ni(e,t,n){const s=e.find(e=>e.id===t)??e.find(e=>void 0!==$(V(e)))??e.find(e=>!ce(e.name))??e[0],a=s&&V(s),r=$(a),i="healthy"===a?.state,o="unavailable"===a?.state;return{id:s?.id??"",name:s?.name??"",latency:i&&void 0!==r?ue(r,n):"—",latencyClass:i&&void 0!==r?`rp-big ms ${Dn(r)}`:"rp-big",tone:i?"ok":o?"err":"muted",status:i?null:n(o?"ui.unavailable":"ui.unknown"),healthError:a?.error?de(a.error,n):void 0}}function Mi(e,t,n,s,a){const r=new Map(e.map(e=>[e.name,e])),i=new Map(e.map(e=>[e.id,e])),o=new Map(t.map(e=>[e.id,e])),l=e.map(e=>{const t=ie(e.name,e.selection.tcp_member_id?"tcp":"udp",r,i,o).node;return{id:e.id,label:e.name,node:t}}),c=new Map;for(const h of U(a))"active"===h.state&&h.outbound&&c.set(h.outbound,(c.get(h.outbound)??0)+1);let d;for(const h of l)(c.get(h.label)??0)>(c.get(d?.label??"")??0)&&(d=h);const u=l.find(e=>e.id===n),m=u??d??l.find(e=>e.node&&void 0!==$(V(e.node)))??l[0];return{...Ni(m?m.node?[m.node]:[]:t,"",s),options:l,chosen:u?.id??""}}const _i=(e,t,n)=>"builtin"===e.kind&&"block"===e.name?n.love:n.cat[t%n.cat.length];function Si(){const t=f(),n=me(),s=Hn(ge),r=O().data?.resources,i=Fn(P(r,"providers",{whileLoading:!1})),o=Bn(P(r,"nodes",{whileLoading:!1})),l=On(P(r,"config",{whileLoading:!1})),c=l.data?.sources.filter(e=>"main"===e.kind||"include"===e.kind),d=function({noNodeSources:e,noRouting:t},n){const s=(e,t,s)=>({id:e,tone:"info",kindText:n("ui.notice"),summaryText:n(t),action:s});return[...e?[s("setup:nodes","act.noSubscriptions",{label:n("nodes.addProvider"),href:a("nodes")})]:[],...t?[s("setup:routing","act.noRoutingMode",{label:n("act.chooseRoutingMode"),href:a("rules",{tab:"list",view:"simple"})})]:[]]}({noNodeSources:he(i.data?.providers,o.data),noRouting:!!c&&c.every(e=>void 0!==e.content)&&!Xt(c.map(e=>e.content))},t),u=e.useMemo(()=>wi(s.records,t),[s.records,t]);return{rows:[...d,...u.rows],total:d.length+u.total,error:s.error,retry:()=>{pe().then(()=>fe(n))},loading:!s.error&&null===s.available,empty:t(!1===s.available?"event.unavailable":"act.noIssues")}}function Ci({rows:e,total:t,error:s,retry:r,loading:i,empty:o}){const l=f();return n.jsxs(S,{"aria-label":l("act.issues"),children:[n.jsxs("div",{className:"rp-row nowrap",children:[n.jsxs("div",{className:"rp-cluster nowrap",children:[n.jsx("h2",{className:"rp-h3 rp-grow",children:n.jsx(y,{children:l("act.issues")})}),t>0&&n.jsx("span",{className:"rp-label",children:t})]}),n.jsx(wn,{appearance:"button",quiet:!0,small:!0,href:a("events"),children:l("act.viewAll")})]}),s&&n.jsx(_,{error:s,onRetry:r}),i?n.jsx(be,{children:n.jsx(nr,{count:4})}):0===e.length?n.jsx(be,{children:n.jsx(xe,{children:o})}):n.jsx(Ei,{rows:e,label:l("act.issues")})]})}function Ei({rows:e,label:t}){return n.jsx("div",{className:"rp-list rp-list-labeled rp-columns",role:"list","aria-label":t,style:ve(e.length),children:e.map(e=>n.jsxs("div",{role:"listitem",className:"rp-row",children:[n.jsx(R,{small:!0,tone:e.tone,children:e.kindText}),e.action?n.jsxs("span",{className:"rp-cluster nowrap",children:[n.jsx("span",{className:"rp-note rp-grow",children:e.summaryText}),n.jsx(wn,{appearance:"button",quiet:!0,small:!0,href:e.action.href,children:e.action.label})]}):n.jsx("span",{className:"rp-note rp-grow",children:e.summaryText})]},e.id))})}const Li=(e,t)=>({time:t,rss:W(e.map(e=>e.rss)),cgroup:W(e.map(e=>e.cgroup))});function zi(e){const t=Date.parse(e.observed_at);if(!Number.isFinite(t))return;const n=ye(e.process?.rss_bytes??null),s=ye(e.cgroup?.current_bytes??null);return{time:t,rss:null===n?null:Number(n),cgroup:null===s?null:Number(s)}}const Ri={live:{seconds:120,label:"act.live"},m10:{seconds:600,label:"act.m10"},h1:{seconds:3600,label:"act.h1"},h6:{seconds:21600,label:"act.h6"},h24:{seconds:86400,label:"act.h24"},d7:{seconds:604800,label:"act.d7"}},Oi=e=>{const t=ye(e??null);return null===t?null:Number(t)/1e3},Pi=(e,t)=>({time:t,up:W(e.map(e=>e.up)),down:W(e.map(e=>e.down)),connections:e.some(e=>null!==e.connections)?Math.max(...e.map(e=>e.connections??0)):null}),Ai=e=>"userspace"===e?.traffic.observed_by&&"ebpf"===e.datapath.kind;function Ii(e){const t=e.traffic,n=Date.parse(t.sampled_at??"");if(Number.isFinite(n))return{time:n,up:Oi(t.rates?.upload_bytes_per_second),down:Oi(t.rates?.download_bytes_per_second),connections:t.connections.total}}function Ti(e,t,n,s,a){const{samples:r,since:i,until:o}=B(e,t,n,Pi,s,a);return{timestamps:r.map(e=>e.time),down:r.map(e=>e.down),up:r.map(e=>e.up),connections:r.map(e=>e.connections),since:i,until:o}}function qi(t,n,s,{enabled:a=!0,anchored:r=!1}={}){const i=e.useContext(c),o=we(s,a?t:void 0),l=F("traffic",i||!a?void 0:n,Ii,Pi,a,i),d=e.useMemo(()=>o.data?function(e){return e.samples.map(e=>({time:Date.parse(e.sampled_at),up:Oi(e.upload_bytes_per_second),down:Oi(e.download_bytes_per_second),connections:e.connections}))}(o.data):[],[o.data]),u=e.useMemo(()=>Ti(l,d,s,r?d.at(-1)?.time:void 0),[l,d,s,r]);return{history:o,rings:l,samples:d,series:u}}function Di(t,n,{enabled:s=!0,windowSeconds:a,anchored:r=!1}={}){const i=e.useContext(c),o=je(s?t:void 0),l=F("memory",i?void 0:n,zi,Li,s,i),d=P(t?.resources,"memory_history",{whileLoading:!1}),u=a??(d?o.windowSeconds:600),m=e.useMemo(()=>o.data&&d?function(e){return e.samples.map(e=>{const t=ye(e.rss_bytes),n=ye(e.cgroup_current_bytes);return{time:Date.parse(e.sampled_at),rss:null===t?null:Number(t),cgroup:null===n?null:Number(n)}})}(o.data):[],[o.data,d]),h=e.useMemo(()=>function(e,t,n,s){const a=B(e,t,n,Li,s);return{...a,timestamps:a.samples.map(e=>e.time),rss:a.samples.map(e=>e.rss),cgroup:a.samples.map(e=>e.cgroup)}}(l,m,u,r?m.at(-1)?.time:void 0),[l,m,u,r]);return{...h,error:d?o.error:void 0,retry:o.refetch}}const Hi={connections:"nav.connections",flows:"flow.records",routing_trace:"ov.r.routingTrace",dns_query:"ov.r.dnsQuery",dns_cache:"ov.r.dnsCache",dns_log:"ov.r.dnsLog",events:"nav.events",probes:"ov.r.probes",traffic_history:"ov.r.trafficHistory",memory_history:"ov.r.memoryHistory",runtime_outbounds:"ov.r.outbounds",logs:"nav.logs",providers:"nodes.providers",rules:"rule.listTitle",config:"nav.config",config_validate:"ov.r.configValidate",runtime_settings:"settings.runtime",geodata:"settings.geodata"},Fi=["configNotLoaded","configReadOnly","mainReadOnly","recordOff","geodataUpdate","geodataUnreadable","notRunning","flowsIdle","notProvided"],Bi={"recorder-off":"recordOff","starting-or-stopping":"notRunning","geodata-mismatch":"geodataUnreadable"},$i={"config-unloaded":{text:"ov.lim.configMissing"},"writes-off":{text:"ov.lim.configWrite",docs:["read-only","ov.lim.docsReadOnly"]},"main-file-read-only":{text:"ov.lim.mainReadOnly",docs:["read-only","ov.lim.docsReadOnly"]},"recorder-off":{text:"ov.lim.recordOff"},"no-download-urls":{text:"ov.lim.geoNoStateDb",docs:["state-db","ov.lim.docsStateDb"]},"geodata-mismatch":{text:"ov.lim.geoUnreadable"},"starting-or-stopping":{text:"ov.lim.notRunningReason"}};function Vi(e,t,n,s,r){const i=e.resources,o=Tn(t),l=t=>o.reason(t,e,r),c=new Map,d=(e,t,s=Hi[t])=>{const a=c.get(e)??[];a.push({id:t,label:n(s)}),c.set(e,a)},u=(e,t)=>({href:z(s,e),text:n(t),external:!0}),m=(e,t)=>({label:n("ov.lim.why"),text:n(e),link:t}),h=e=>{const t=e.find(e=>void 0!==e),s=t&&$i[t.code];if(!s)return;const a=s.docs&&u(...s.docs),r=e.flatMap(e=>e&&"settings"in e?e.settings:[]);return r.length>0?{label:n("ov.lim.howTo"),text:n(s.text),snippet:o.snippet(r),link:a}:m(s.text,a)},p=i.config.available?!0!==i.config.writable?"configReadOnly":null:"configNotLoaded";p&&d(p,"config");const f=!i.config_validate.available&&"configNotLoaded"===p;f&&d("configNotLoaded","config_validate"),!1!==i.nodes.can_manage&&!1!==i.providers.can_manage||d(p??"mainReadOnly","manage","ov.lim.manage");const g=i.runtime_settings.available&&(i.runtime_settings.fields??[]).includes("record_flows");for(const a of Object.keys(Hi)){const e=i[a];if("config"===a||"config_validate"===a&&f)continue;const t="flows"===a&&e.available&&("off"===i.flows.recording||"auto"===i.flows.recording);if(("flows"===a||"logs"===a||"dns_log"===a)&&!1===r?.[a]?.allowed||t||!e.available){const e=l(a)?.code;d((e&&Bi[e])??(t?"flowsIdle":"notProvided"),a)}else"geodata"===a&&!0!==i.geodata.can_update&&d(p??"geodataUpdate",a),"providers"===a&&!1===i.providers.can_refresh&&d("notRunning","subscriptions","ov.lim.subscriptions"),"connections"===a&&!1===i.connections.can_close&&d("notProvided","close","ov.lim.close")}const b=()=>{const e=i.geodata;if(0===e.assets?.length)return m("ov.lim.geoNoAssets");const t=h([l("geodata")]);return t||(!0===e.configurable_sources?m("ov.lim.geoNoUrl",{href:a("settings",{card:"geodata"}),text:n("settings.geodata")}):void 0)};return Fi.flatMap(e=>{const t=c.get(e);if(!t)return[];const{named:r=[],...i}=((e,t)=>{const s=t.length,r=()=>t.map(e=>l(e.id));switch(e){case"configNotLoaded":return{headline:n("ov.lim.h.configNotLoaded"),named:["config"],help:h([l("config")])};case"configReadOnly":return{headline:n("ov.lim.h.configReadOnly"),named:["config"],help:h([l("config")])};case"mainReadOnly":return{headline:n("ov.lim.h.mainReadOnly"),named:["manage"],help:h([l("manage")])};case"recordOff":return{headline:n("ov.lim.h.recordOff",{n:s}),help:h(r())};case"geodataUpdate":return{headline:n("ov.lim.h.geodataUpdate"),named:["geodata"],help:b()};case"geodataUnreadable":return{headline:n("ov.lim.h.geodataUnreadable"),named:["geodata"],help:h(r())};case"notRunning":return{headline:s>1?n("ov.lim.h.notRunning",{n:s}):n("probes"===t[0].id?"ov.lim.h.probes":"ov.lim.h.subscriptions"),named:s>1?[]:[t[0].id],help:h(r())};case"flowsIdle":return{headline:n("recorded-on-demand"===l("flows")?.code?"ov.lim.h.flowsIdle":"ov.lim.h.flowsOff"),named:["flows"],link:g?{href:a("settings",{card:"runtime"}),text:n("settings.runtime")}:void 0};case"notProvided":{const e=r().some(e=>"build-lacks"===e?.code);return{headline:n(e?"ov.lim.h.notProvided":"ov.lim.h.notProvidedOther",{n:s}),link:e?u("honk-version","ov.lim.docsVersion"):void 0}}}})(e,t),o=t.filter(e=>!r.includes(e.id));return[{cause:e,...i,items:t,features:o.length>0?ke(s,t.map(e=>e.label)):void 0}]})}function Wi(t="history"){const n=f(),s=E(),a=Ne[s],r=hr(),i=O(),o=i.data?.resources,l=Me("memory"!==t&&P(o,"runtime",{whileLoading:!1})),c=_e("memory"===t&&P(o,"runtime_memory",{whileLoading:!1})),d=Se("status"===t&&P(o,"datapath",{whileLoading:!1})),[u,m]=e.useState("live"),h=Ri[u].seconds,p=Di(i.data,c.data,{enabled:"memory"===t}),{history:g,rings:b,samples:x,series:v}=qi(i.data,l.data,h,{enabled:["download","upload","connections","history"].includes(t)}),y=e.useMemo(()=>Ti(b,x,Ri.live.seconds,void 0,24),[b,x]),j=e.useContext(Ce)?.ap.sparklines??!0,w=hi(l.data,"cpu"===t&&j),k=e.useMemo(()=>fi(w,Ri.live.seconds,mi),[w]),N=e.useMemo(()=>[{label:n("ui.download"),color:r.cat[0],values:v.down},{label:n("ui.upload"),color:r.cat[3],values:v.up}],[n,r,v]),M=e.useMemo(()=>[{label:n("act.rss"),color:r.cat[0],values:p.rss},{label:n("act.cgroup"),color:r.cat[3],values:p.cgroup}],[n,r,p.rss,p.cgroup]),_=o?.runtime_memory?.metrics??[],S=_.includes("process.rss_bytes")||!_.includes("cgroup.current_bytes"),C=e.useMemo(()=>Object.keys(Ri).map(e=>[e,n(Ri[e].label)]),[n]),L=e.useCallback(e=>{(e=>Object.hasOwn(Ri,e))(e)&&m(e)},[]),z=e.useMemo(()=>({since:v.since,until:v.until}),[v.since,v.until]),R=e.useMemo(()=>({since:p.since,until:p.until}),[p.since,p.until]),A=e.useCallback(e=>te(null==e?null:1e3*e,a),[a]),I=e.useCallback(e=>ee(e,a),[a]),q=e.useCallback(e=>Z(e,n),[n]),D=e.useCallback(e=>se(e??null,a),[a]),H=e.useMemo(()=>function(e,t,n,s="en",a){const{tone:r,text:i}=vi(e?.lifecycle.state,a,t(!1===n?"act.modeUnavailable":"ui.loading"),t);return{status:{tone:r,text:i},download:te(e?.traffic.rates?.download_bytes_per_second??null,s),upload:te(e?.traffic.rates?.upload_bytes_per_second??null,s),connections:null==e?.traffic.connections.total?"—":ee(e.traffic.connections.total,s),cpu:Z(e?.process.cpu_percent,t),cpuHelp:{title:t("act.cpu"),text:t("act.cpuHelp")}}}(l.data,n,o?.runtime.available,a,d.data?.state),[l.data,n,o?.runtime.available,a,d.data?.state]),F=T("status"===t),{refetch:B}=l,{refetch:$}=d,V=e.useCallback(()=>{B(),$()},[B,$]),W=e.useMemo(()=>"status"===t&&i.data?Vi(i.data,F.data,n,s).reduce((e,t)=>e+t.items.length,0):0,[t,i.data,F.data,n,s]);return{...H,limited:W>0?n("act.limited",{n:W}):null,statusLoading:!l.data&&!l.error&&!1!==o?.runtime.available||!i.data,range:u,ranges:C,setRange:L,locale:a,p:r,spark:y,sparklines:j,cpuSpark:k,traffic:N,memorySeries:M,memoryLine:M[S?0:1],memoryValue:se((S?c.data?.process?.rss_bytes:c.data?.cgroup?.current_bytes)??null,a),chartRate:A,count:I,cpuText:q,memoryBytes:D,trafficBounds:z,memoryBounds:R,trafficTimestamps:v.timestamps,trafficUncounted:Ai(l.data),memoryTimestamps:p.timestamps,ready:!!i.data,discoveryFailed:!!i.error,error:l.error??d.error,stale:!!l.error&&!!l.data,retry:V,history:{error:g.error,retry:g.refetch,state:ki(v,o?.traffic_history.available,!!g.data,P(o,"runtime",{whileLoading:!1}))},memoryState:{error:c.error??p.error,retry:c.error?c.refetch:p.retry,state:p.samples.length>1?"ready":!1===o?.runtime_memory.available?"unavailable":"loading"}}}function Ui(e){return n.jsxs(h,{...e,children:[n.jsx("path",{fill:"currentColor",d:"M10 18.75c-4.825 0-8.75-3.925-8.75-8.75S5.175 1.25 10 1.25s8.75 3.925 8.75 8.75-3.925 8.75-8.75 8.75m0-16c-3.998 0-7.25 3.252-7.25 7.25s3.252 7.25 7.25 7.25 7.25-3.252 7.25-7.25S13.998 2.75 10 2.75"}),n.jsx("path",{fill:"currentColor",d:"M13.249 12.645c-.129 0-.26-.034-.379-.104l-3.22-1.895c-.23-.134-.37-.38-.37-.646V5c0-.414.335-.75.75-.75s.75.336.75.75v4.571l2.85 1.677c.357.21.476.67.266 1.026-.14.239-.39.37-.647.37"})]})}function Gi(t,n){const s=f(),a=O(),r=Bn(P(a.data?.resources,"nodes",{whileLoading:!1})),i=In(P(a.data?.resources,"groups",{whileLoading:!1})),[o,d]=e.useState(()=>{try{return localStorage.getItem(l.activityGroup)??""}catch{return""}}),u=n?.chosen??o,m=!i.data||i.loading||i.error||i.data.some(e=>e.id===u)?u:"",h=n?.setChosen??d,p=e.useContext(c);e.useEffect(()=>{!u||m||p||h("")},[u,m,h,p]),e.useEffect(()=>{if(!n)try{m?localStorage.setItem(l.activityGroup,m):localStorage.removeItem(l.activityGroup)}catch{}},[m,n]);const g=$n(void 0,!t&&!m&&!0===a.data?.resources.connections.available,!1,Ee.summary),b=t??g.data,x=e.useMemo(()=>Mi(i.data??[],r.data??[],m,s,b),[i.data,r.data,m,s,b]),v=r.data?.find(e=>e.id===x.id),y=Fn(!!v&&null==v.provider_id&&P(a.data?.resources,"providers",{whileLoading:!1})),j=v?bs(v,y.data?.providers??[]):void 0;return{...x,nodes:r.data,refetchNodes:r.refetch,href:j,setChosen:h,loading:a.loading||r.loading&&!r.data||i.loading&&!i.data,error:i.error??r.error,retry:()=>{i.refetch(),r.refetch()}}}const Ki=new Map,Ji=e=>{Ki.delete(e),Re(e)};function Xi({model:e,label:t}){const s=f();return n.jsx(kn,{appearance:"select",placement:"bottom start",label:t,triggerLabel:s("ui.valuePair",{label:t,value:e.name||"—"}),searchLabel:s("policy.pickGroups"),items:[{id:"",label:s("act.groupFollow")},...e.options.map(e=>({id:e.id,label:e.label}))],value:e.chosen,onChange:e.setChosen,onAction:e.setChosen,children:n.jsx(ts,{i:{id:e.chosen,label:e.name||"—",nodeName:!0}})})}function Yi({connections:t,selection:s,stats:a}){const r=f(),i=Gi(t,s),o=hr(),l=Ne[E()],d=e.useContext(Ce)?.ap.sparklines??!0,u=e.useCallback(e=>ue(e,r),[r]),m=function(t,n,s,a,r){const i=e.useContext(c),o=`latency-${encodeURIComponent(s)}`,l=a&&!i&&!!n,d=e.useRef(void 0);e.useEffect(()=>{i||(a?n&&(void 0!==d.current&&d.current!==o&&(Ji(d.current),Ji(o)),d.current=o):(Ji(o),d.current=void 0))},[o,n,a,i]);const u=e.useCallback(e=>{if(Ki.get(o)!==e)return Ki.set(o,e),pi(e.find(e=>e.id===n),Oe())},[o,n]),m=F(o,l?t:void 0,u,mi,a&&!!n,i),h=e.useMemo(()=>fi(m,Ri.m10.seconds,mi),[m]),p=h.values.filter(e=>null!==e).length<2,f=void 0!==t,g=e.useRef(void 0);return e.useEffect(()=>{if(!l||!f||!p||g.current===o)return;let e=!0;const t=setTimeout(()=>{g.current=o;const t=Ki.get(o);r()?.then(s=>{s.ok&&setTimeout(()=>{e&&t&&Ki.get(o)===t&&Le(o,pi(t.find(e=>e.id===n),Oe()),mi)},0)})},ze);return()=>{e=!1,clearTimeout(t)}},[l,f,p,o,n,r]),h}(i.nodes,i.id,JSON.stringify([i.chosen,i.id]),d,i.refetchNodes);return n.jsxs(S,{className:"rp-latency",title:r("act.latency"),tile:{icon:n.jsx(Ui,{}),tint:5,kind:"metric",layout:"responsive"},aside:n.jsx(Pe,{help:{title:r("act.latency"),text:r("act.groupPickHelp")},children:n.jsx(Xi,{label:r("policy.pickGroups"),model:i})}),children:[i.error&&n.jsx(_,{error:i.error,onRetry:i.retry}),n.jsx(Vn,{value:i.href?n.jsx(wn,{appearance:"link",href:i.href,label:r("ui.valuePair",{label:i.name,value:i.latency}),children:n.jsx("span",{className:i.latencyClass,children:i.latency})}):n.jsx("span",{className:i.latencyClass,children:i.latency}),status:i.status&&n.jsx(y,{text:i.healthError,children:n.jsx(R,{small:!0,tone:i.tone,children:i.status})}),spark:d&&n.jsx(yr,{values:m.values,timestamps:m.timestamps,color:o.cat[4],fmt:u,locale:l}),facts:a&&n.jsx(wr,{facts:gi([{label:r("act.latency"),values:m.values}],u,r)}),children:i.loading&&n.jsx(nr,{})})]})}function Qi(){const t=f(),n=Ne[E()],s=hr(),r=O().data?.resources.runtime_outbounds.available,o=Ae(!0===r),l=e.useMemo(()=>function(e,t,n,s){const r=ne(e);return{since:e?s("act.since",{time:ae(e.counter_since,t)}):"",total:se(r.total,t),rows:r.rows.map((e,r)=>({name:i(e.name,s),value:null===e.percent?null:Math.round(e.percent),text:se(e.bytes,t),href:a("connections",{out:e.name}),color:_i(e,r,n)}))}}(o.data,n,s,t),[o.data,n,s,t]);return{view:l,state:!1===r?"unavailable":o.data?l.rows.length?"ready":"empty":"loading",error:o.error,retry:o.refetch}}function Zi(){const e=f(),{view:t,state:s,error:a,retry:r}=Qi();return n.jsxs(S,{children:[n.jsx("div",{className:"rp-row",children:n.jsxs("div",{className:"rp-cluster",children:[n.jsx("h2",{className:"rp-h3",children:e("act.outUsage")}),t.since&&n.jsx("span",{className:"rp-label rp-counter-since",children:t.since})]})}),a&&n.jsx(_,{error:a,onRetry:r}),a&&"ready"!==s?null:"unavailable"===s?n.jsx(be,{holds:"tall",children:n.jsx(xe,{children:e("act.noOutbounds")})}):"loading"===s?n.jsx(sr,{parts:[{height:136}]}):"empty"===s?n.jsx(be,{holds:"tall",children:n.jsx(xe,{children:e("ui.empty")})}):n.jsx(jr,{label:e("act.outUsage"),rows:t.rows,total:t.total})]})}function eo({model:e}){const t=f(),{ref:s,by:a,setBy:r,rows:i,state:o,error:l,retry:c,truncated:d}=e;return n.jsxs(S,{ref:s,children:[n.jsxs("div",{className:"rp-row",children:[n.jsx(y,{text:t("act.rankingScope"),children:n.jsx("h2",{className:"rp-h3",children:t("act.topDevices")})}),n.jsx(Rn,{label:t("act.topDevices"),value:a,onChange:r,items:[["dev",t("act.devices")],["host",t("act.domains")]]})]}),l&&n.jsx(_,{error:l,onRetry:c}),d&&n.jsx(y,{text:t("act.rankingTruncated"),children:n.jsx(Ie,{tone:"warn",children:t("act.truncated")})}),"error"===o?null:"loading"===o?n.jsx(be,{holds:"bars",children:n.jsx(nr,{shape:"bars",count:4,columns:!0})}):"unavailable"===o?n.jsx(be,{holds:"bars",children:n.jsx(xe,{children:t("act.noConnections")})}):"empty"===o?n.jsx(be,{holds:"bars",children:n.jsx(xe,{children:t("act.rankingEmpty")})}):n.jsx("div",{className:"rp-list rp-columns",style:ve(i.length),children:i.map(e=>n.jsx(Te,{label:n.jsx(wn,{appearance:"link",href:e.href,children:e.name}),value:e.value,pct:e.pct,color:e.color},e.name))})]})}function to(t=!0,n,s=5){const r=f(),i=Ne[E()],o=hr(),[l,c]=e.useState("dev"),d=n?.by??l,u=n?.setBy??c,m=O().data?.resources.connections.available,[h,p]=qe(),[g,b]=e.useState(!1),x=$n(void 0,t&&!0===m,!p&&g,Ee.summary);x.data&&!g&&b(!0);const v=e.useMemo(()=>function(e,t,n,s,r,i=5){return bi(e,t,i).map((e,i)=>({name:e.name,value:null===e.percent?se(e.download,s):r("ui.share",{bytes:se(e.download,s),percent:e.percent}),pct:e.percent??0,color:n.cat[i%n.cat.length],href:a("connections","dev"===t?{src:e.name}:{q:e.name})}))}(x.data,d,o,i,r,s),[x.data,d,o,i,r,s]),y=x.data?v.length?"ready":"empty":x.error?"error":!0===m?"loading":"unavailable";return{ref:h,connections:x.data,by:d,setBy:u,rows:v,state:y,error:x.error??void 0,retry:x.refetch,truncated:!!x.data?.truncated}}function no({item:t,scale:s=1,selection:a,ranking:r}){const i=e.useContext(Vs),o=t.width?"2/3"===t.width||"full"===t.width:i;switch(t.id){case"mode":return n.jsx(so,{part:"mode"});case"global":return n.jsx(so,{part:"global"});case"latency":return n.jsx(Yi,{connections:void 0,selection:a,stats:o});case"ranking":return n.jsx(ao,{selection:r,limit:t.rows});case"notices":return n.jsx(ro,{});case"outbounds":return n.jsx(Zi,{});case"download":case"upload":case"connections":case"cpu":case"history":case"status":return n.jsx(oo,{kind:t.id,scale:s,stats:o});case"memory":return n.jsx(oo,{kind:"sparkline"===t.form?"memoryTile":"memory",scale:s,stats:o});default:return null}}function so({part:e}){return n.jsx(ti,{model:di(),part:e})}function ao({selection:e,limit:t}){return n.jsx(eo,{model:to(!0,e,t)})}function ro(){return n.jsx(Ci,{...Si()})}function io(){const e=Wi("status");return e.error?n.jsx(_,{error:e.error,onRetry:e.retry}):null}function oo({kind:e,scale:t,stats:s}){const r=f(),i=Wi("memoryTile"===e?"memory":e),{p:o,locale:l,range:c,ranges:d,setRange:h,traffic:p,spark:g,sparklines:b,cpuSpark:x,chartRate:v,count:y,cpuText:j,memorySeries:w,memoryBytes:k}=i,N=i.stale?"rp-big rp-muted":"rp-big",M="status"===e&&i.error&&n.jsx(_,{error:i.error,onRetry:i.retry}),C=(e,t,a)=>s&&n.jsx(wr,{facts:gi([{label:e,values:t}],a,r)});if(!i.ready)return M||(i.discoveryFailed?null:n.jsx(nr,{}));let E;switch(e){case"status":E=n.jsx(S,{className:"rp-control-card",children:n.jsx("div",{className:"rp-row","data-pack":"line",children:i.statusLoading?n.jsxs(u,{children:[n.jsx(m,{line:"body",width:88}),n.jsx("div",{className:"rp-control-tail",children:n.jsx(m,{line:"body",width:112})})]}):n.jsxs(n.Fragment,{children:[n.jsx(R,{tone:i.status.tone,children:i.status.text}),n.jsx("div",{className:"rp-control-tail",children:n.jsx(wn,{appearance:"button",quiet:!0,href:a("overview"),children:i.limited??r("act.viewDetails")})})]})})});break;case"download":E=n.jsx(Wn,{href:a("connections",{tab:"traffic"}),label:r("ui.download"),tile:{icon:n.jsx(ar,{}),tint:1},children:n.jsx(Vn,{value:n.jsx("span",{className:N,children:i.download}),spark:b&&n.jsx(yr,{values:g.down,timestamps:g.timestamps,color:o.cat[0],floor:100,fmt:v,locale:l}),facts:C(r("ui.download"),g.down,v)})});break;case"upload":E=n.jsx(Wn,{href:a("connections",{tab:"traffic"}),label:r("ui.upload"),tile:{icon:n.jsx(rr,{}),tint:4},children:n.jsx(Vn,{value:n.jsx("span",{className:N,children:i.upload}),spark:b&&n.jsx(yr,{values:g.up,timestamps:g.timestamps,color:o.cat[3],floor:100,fmt:v,locale:l}),facts:C(r("ui.upload"),g.up,v)})});break;case"connections":E=n.jsx(Wn,{href:a("connections",{tab:"list"}),label:r("act.active"),tile:{icon:n.jsx(He,{}),tint:3},children:n.jsx(Vn,{value:n.jsx("span",{className:N,children:i.connections}),spark:b&&n.jsx(yr,{values:g.connections,timestamps:g.timestamps,color:o.cat[2],fmt:y,locale:l}),facts:C(r("act.active"),g.connections,y)})});break;case"cpu":E=n.jsx(S,{title:r("act.cpu"),tile:{icon:n.jsx(ir,{}),tint:2,kind:"metric"},aside:n.jsx(De,{...i.cpuHelp}),children:n.jsx(Vn,{value:n.jsx(wn,{appearance:"link",href:a("overview"),label:r("ui.valuePair",{label:r("act.cpu"),value:i.cpu}),children:n.jsx("span",{className:N,children:i.cpu})}),spark:b&&n.jsx(yr,{values:x.values,timestamps:x.timestamps,color:o.cat[1],floor:100,fmt:j,locale:l}),facts:C(r("act.cpu"),x.values,j)})});break;case"history":E=n.jsx(S,{title:r("act.traffic"),help:i.trafficUncounted?{title:r("act.traffic"),text:r("ui.trafficUncounted")}:void 0,aside:n.jsx(Rn,{label:r("act.historyRange"),value:c,onChange:h,items:d}),children:i.history.error&&"ready"!==i.history.state?n.jsx(_,{error:i.history.error,onRetry:i.history.retry}):"unavailable"===i.history.state?n.jsx(be,{holds:"tall",children:n.jsx(xe,{children:r("act.noHistory")})}):"loading"===i.history.state?n.jsx(sr,{parts:[{line:"caption"},{height:120*t}]}):"empty"===i.history.state?n.jsx(be,{holds:"tall",children:n.jsx(xe,{children:r("act.emptyHistory")})}):n.jsxs("div",{className:"rp-chart-stats",children:[n.jsx(xr,{series:p,fmt:v}),n.jsx(vr,{label:r("act.traffic"),series:p,timestamps:i.trafficTimestamps,fmt:v,locale:l,height:120*t,fill:!0,window:i.trafficBounds}),s&&n.jsx(wr,{facts:gi(p,v,r)})]})});break;case"memoryTile":E=n.jsx(S,{title:r("act.memory"),tile:{icon:n.jsx(or,{}),tint:5,kind:"metric"},children:i.memoryState.error?n.jsx(_,{error:i.memoryState.error,onRetry:i.memoryState.retry}):n.jsx(Vn,{value:n.jsx(wn,{appearance:"link",href:a("overview"),label:r("ui.valuePair",{label:r("act.memory"),value:i.memoryValue}),children:n.jsx("span",{className:N,children:i.memoryValue})}),spark:b&&n.jsx(yr,{values:i.memoryLine.values,timestamps:i.memoryTimestamps,color:i.memoryLine.color,fmt:k,locale:l}),facts:C(i.memoryLine.label,i.memoryLine.values,k)})});break;case"memory":E=n.jsx(S,{title:r("act.memory"),aside:n.jsx(wn,{appearance:"button",quiet:!0,small:!0,href:a("overview"),children:r("act.viewDetails")}),children:i.memoryState.error?n.jsx(_,{error:i.memoryState.error,onRetry:i.memoryState.retry}):"ready"===i.memoryState.state?n.jsxs("div",{className:"rp-chart-stats",children:[n.jsx(xr,{series:w,fmt:k}),n.jsx(vr,{label:r("act.memory"),series:w,timestamps:i.memoryTimestamps,fmt:k,locale:l,height:150*t,fill:!0,baseline:"auto",window:i.memoryBounds}),s&&n.jsx(wr,{facts:gi(w,k,r)})]}):"unavailable"===i.memoryState.state?n.jsx(xe,{children:r("act.noHistory")}):n.jsx(be,{children:n.jsx(nr,{shape:"block",label:r("act.sampling")})})})}return n.jsxs(n.Fragment,{children:[M,E]})}const lo=[{id:"nodes",title:"act.setup.nodes",hint:"act.setup.nodesHint",action:"nodes.addProvider",href:a("nodes",{add:"subscription"})},{id:"rules",title:"act.setup.rules",hint:"act.setup.rulesHint",action:"act.setup.chooseRules",href:a("rules",{view:"simple"})},{id:"connection",title:"act.setup.connection",hint:"act.setup.connectionHint",action:"act.setup.checkConnection",href:a("policies")}];function co({model:e}){const t=f();return e.visible?n.jsx(S,{title:t("act.setup.title"),titleVariant:"caption",aside:n.jsx(M,{quiet:!0,small:!0,icon:!0,label:t("act.setup.dismiss"),onPress:e.dismiss,children:n.jsx($e,{})}),children:n.jsx("div",{className:"rp-setup",role:"list",children:lo.map(s=>n.jsxs("div",{role:"listitem",className:"rp-setup-step","data-complete":e.done[s.id],children:[n.jsxs("span",{className:"rp-setup-status",children:[e.done[s.id]?n.jsx(Fe,{}):n.jsx(Ui,{}),n.jsx(Be,{children:t(e.done[s.id]?"act.setup.complete":"act.setup.incomplete")})]}),n.jsxs("div",{className:"rp-setup-copy",children:[n.jsx("span",{children:t(s.title)}),n.jsx("span",{className:"rp-note",children:t(s.hint)})]}),!e.done[s.id]&&n.jsx(wn,{appearance:"button",small:!0,href:s.href,children:t(s.action)})]},s.id))})}):null}let uo=null;function mo(){if(uo)return uo;try{const e=localStorage.getItem(l.gettingStarted);return"complete"===e||"dismissed"===e?e:null}catch{return null}}function ho(e){uo=e;try{localStorage.getItem(l.gettingStarted)!==e&&localStorage.setItem(l.gettingStarted,e)}catch{}}function po(){const[t,n]=e.useState(mo),s=O().data?.resources,a=Bn(!t&&P(s,"nodes",{whileLoading:!1})),r=Fn(!t&&P(s,"providers",{whileLoading:!1})),i=On(!t&&P(s,"config",{whileLoading:!1})),o=In(!t&&P(s,"groups",{whileLoading:!1})),l=t?{nodes:!0,rules:!0,connection:!0}:function(e,t,n,s){const a=new Map(n.map(e=>[e.name,e])),r=new Map(n.map(e=>[e.id,e])),i=new Map(e.map(e=>[e.id,e])),o=t.filter(e=>"main"===e.kind||"include"===e.kind).map(e=>e.content??"").join("\n");return{nodes:!he(s,e),rules:null!==Yt(o)||!Qt(o),connection:n.some(e=>["tcp","udp"].some(t=>{const n=ie(e.name,t,a,r,i).node;return!!n&&"builtin"!==Ve(n)&&void 0!==$(V(n))}))}}(a.data??[],i.data?.sources??[],o.data??[],r.data?.providers??[]),c=!!(a.data&&r.data&&i.data&&o.data),d=["nodes","providers","config","groups"].every(e=>P(s,e,{whileLoading:!1})),u=!!(a.error||r.error||i.error||o.error),m=c&&Object.values(l).every(Boolean);return e.useEffect(()=>{if(t||!m)return;const e=requestAnimationFrame(()=>{ho("complete"),n("complete")});return()=>cancelAnimationFrame(e)},[t,m]),{done:l,pending:!t&&d&&!c&&!u,visible:!t&&c&&!m,settled:!!t,dismiss:()=>{ho("dismissed"),n("dismissed")}}}function fo({layout:t}){const s=Ka(t).some(e=>"mode"===e.id);return e.useEffect(()=>{const e=document.querySelector('main [data-module="mode"] .rp-card');e&&(e.tabIndex=-1,e.focus())},[]),s?null:n.jsx("div",{"data-module":"mode",children:n.jsx(no,{item:{id:"mode"}})})}const go={short:"dashboard.height.short",standard:"dashboard.height.standard",tall:"dashboard.height.tall"},bo={short:.75,standard:1,tall:2},xo=e=>"full"===e?1:Number(e[0])/Number(e[2]);function vo(e,t){return t&&fa[e.id].tile||"area"===e.form||"sparkline"===e.form||"dots"===e.form&&!fa[e.id].rows?"chart":fa[e.id].rows&&"donut"!==e.form&&"waffle"!==e.form?"rows":void 0}const yo=(e,t)=>({...e,width:t,...t&&"small"===e.size?{size:"medium"}:{}}),jo=e=>bo[e.height??"standard"];function wo(e,t,n){const s={label:n("dashboard.width"),value:e.width??"auto",options:[{value:"auto",label:n("dashboard.automaticWidth")},...ya(e.id).map(e=>({value:e,label:"full"===e?n("dashboard.wide"):e,fraction:xo(e)}))],set:t=>yo(e,"auto"===t?void 0:t)},a=vo(e,t);if("chart"===a)return{width:s,height:{label:n("dashboard.height"),value:e.height??"standard",options:ba.map(e=>({value:e,label:n(go[e])})),set:t=>({...e,height:t})}};if("rows"!==a)return{width:s};const r=function(e,t){return t?"ranking"===e.id?5:void 0:"sourceHealth"!==e.id&&"providerBudget"!==e.id?"nodeLatency"===e.id?la(e.size,[3,6,12]):"ranking"===e.id?Math.min(5,la(e.size)):la(e.size):void 0}(e,t),i=void 0===r||!xa.includes(r),o=xa.map(e=>({value:String(e),label:n("dashboard.rows",{n:e}),n:e}));i&&o.push({value:"auto",label:void 0===r?n("dashboard.allRows"):n("dashboard.rows",{n:r}),n:r??1/0});const l=e.rows??r;return{width:s,height:{label:n("dashboard.height"),value:void 0===e.rows&&i?"auto":String(l),options:o.sort((e,t)=>e.n-t.n).map(({value:e,label:t})=>({value:e,label:t})),set:t=>({...e,rows:"auto"===t?void 0:Number(t)})}}}const ko=(e,t)=>({...yo(e,t.width),...t.form?{form:t.form}:{},...t.height?{height:t.height}:{},...t.rows?{rows:t.rows}:{}});function No(e,t){const n=ya(e.id),s=n.find(e=>"1/5"!==e),a=fa[e.id].tile&&"sparkline"!==e.form,r=[...new Set([s,"1/2","full"])].filter(e=>n.includes(e)).map(e=>a&&xo(e)<1/3?{width:e,form:"sparkline"}:{width:e}),i=vo(e,t);return"chart"===i&&r.push({width:"1/2",height:"tall"}),"rows"===i&&r.push({width:"1/2",rows:xa.at(-1)}),r}const Mo=(e,t)=>{const n="full"===e.width?t("dashboard.wide"):e.width;return e.height?t("dashboard.preset",{width:n,height:t(go[e.height])}):e.rows?t("dashboard.preset",{width:n,height:t("dashboard.rows",{n:e.rows})}):n},_o=e.lazy(()=>g(()=>Promise.resolve().then(()=>nu),void 0,import.meta.url).then(e=>({default:e.WidgetContent})));function So({item:t,preview:s=!1,onChange:a=()=>{}}){const r=f();return Ua(t)?n.jsx(no,{item:t,scale:jo(t),ranking:{by:"domain"===t.by?"host":"dev",setBy:e=>a({...t,by:"host"===e?"domain":"dev"})},selection:{chosen:t.group??"",setChosen:e=>a({...t,group:e})}}):n.jsx(S,{title:r(fa[t.id].label),children:n.jsx(e.Suspense,{children:n.jsx(ca,{value:"dashboard",children:n.jsx(_o,{item:t,preview:s,onChange:a})})})})}const Co=e.lazy(()=>g(()=>import("./Editors-dKzIa8sH.js"),__vite__mapDeps([14,1,2,3,4,15,16,11,17,10,9,8,7,18]),import.meta.url).then(e=>({default:e.DashboardEditor}))),Eo=e.lazy(()=>g(()=>import("./Editors-dKzIa8sH.js"),__vite__mapDeps([14,1,2,3,4,15,16,11,17,10,9,8,7,18]),import.meta.url).then(e=>({default:e.DashboardActions})));function Lo({item:e,onChange:t}){const[s,a]=qe(void 0,0);return n.jsx(Us,{tile:Va(e),visible:a,targetRef:s,children:n.jsx(c,{value:!a,children:n.jsx(So,{item:e,onChange:t})})})}function zo(e){switch(e.id){case"mode":case"global":case"status":return 94;case"download":case"upload":case"connections":case"latency":case"cpu":return 110;case"history":return 106+120*jo(e);case"outbounds":return 226;case"memory":return"sparkline"===e.form?110:260;default:return 260}}const Ro=Object.freeze(Object.defineProperty({__proto__:null,Activity:function({query:t}){const s=f(),a=po(),r=tr(),[i,o]=e.useState(null),l=O(),d=null!==i;if(!l.data&&l.error)return null;if(!l.data&&!a.settled||a.pending)return n.jsx(We,{});if(!l.data)return n.jsx("div",{className:"rp-dashboard",children:n.jsx(u,{children:r.sections.filter(e=>e.items.length).map(e=>n.jsx(Js,{profile:e.id,grid:$s(e.items.map(Va)),children:e.items.map(e=>n.jsx(Us,{tile:Va(e),visible:!1,targetRef:null,children:n.jsx(Ue,{height:zo(e)})},wa(e)))},e.id))})});const m=e=>er(t=>Ya(t,ka(e)));return n.jsxs(n.Fragment,{children:[n.jsx(Ps,{children:d?n.jsx(e.Suspense,{children:n.jsx(Eo,{draft:i,saved:r,setDraft:o,onClose:()=>o(null)})}):n.jsx(M,{onPress:()=>o(r),children:s("dashboard.edit")})}),"mode"===new URLSearchParams(t).get("card")&&n.jsx(fo,{layout:r}),n.jsx(co,{model:a}),!Ka(r).some(e=>"status"===e.id)&&Ka(r).some(e=>"runtime"===fa[e.id].resource)&&n.jsx(io,{}),n.jsxs("div",{className:"rp-dashboard","data-editing":d||void 0,children:[d?n.jsx(e.Suspense,{children:n.jsx(c,{value:!0,children:n.jsx(Co,{draft:i,setDraft:o,render:e=>n.jsx(So,{item:e})})})}):r.sections.filter(e=>e.items.length).map(e=>n.jsx(Js,{profile:e.id,grid:$s(e.items.map(Va)),children:e.items.map(e=>n.jsx(Lo,{item:e,onChange:m},wa(e)))},e.id)),!Ka(i??r).length&&n.jsx(S,{children:n.jsx("span",{className:"rp-label",children:s("widgets.empty")})})]})]})}},Symbol.toStringTag,{value:"Module"}));function Oo(e,t,n,s){return Object.keys(Ge).filter(n=>e(n)||t===n).map(e=>({id:e,label:s(Ge[e]),isPending:t===e,isDisabled:!!t,onAction:()=>n(e)}))}function Po(e,t,n){const s=f(),a=Ke(e,t,n),r=e=>{a.run(e).then(t=>{t&&H("positive",s("ov.operationResult",{action:s(Ge[e]),status:s("ov.succeeded"),operationId:t.operation_id}))},e=>Je(e,s,s("ov.operationError")))};return{canRun:a.canRun,busy:a.busy,run:r,actions:Oo(a.canRun,a.busy,r,s)}}function Ao({isOpen:e,onCancel:t,onConfirm:s,isPending:a,isDisabled:r}){const i=f();return n.jsx(Xe,{title:i("shell.reloadTitle"),tone:"accent",isOpen:e,onCancel:t,confirmLabel:i("shell.reloadEngine"),isPending:a,isDisabled:r,onConfirm:s,children:n.jsx("p",{className:"rp-label",children:i("shell.reloadHelp")})})}function Io(e,t){const n=new Map;for(const a of e)n.set(a,(n.get(a)??0)+1);const s=[...n].map(([e,t])=>({key:e,count:t})).sort((e,t)=>t.count-e.count||((e,t)=>e===t?0:null===e?1:null===t||e<t?-1:1)(e.key,t.key));return{top:s.slice(0,t),rest:s.slice(t).reduce((e,t)=>e+t.count,0)}}function To(e,t,n){return e?.open?{label:n("rule.dns.positionNew",{name:t}),desc:n("rule.dns.positionNewHelp",{name:t})}:{label:n("rule.positionLast"),desc:void 0}}function qo(e,t,n){return{text:void 0===n?t(e):t(e,{n:n}),detail:t("rule.keepsRoute")}}function Do(e,t,n,s){if("routing"===n.list)return tn(t,n.before,s);if(n.before)return nn(t,n.before,n.list,s);const a=en(e,n.list);return a?.source.id===t.id?a.anchor:null}function Ho(e){const t=new Map;for(const n of e)t.set(n.sourceId,[...t.get(n.sourceId)??[],n]);return[...t.values()]}const Fo=e=>e instanceof Ye&&422===e.status?e.details??{}:null;function Bo(e,t,n,s){const a=t??Fo(e)?.diagnostics??null;if(!a){const t=I(e,s,s("ui.writeFailed"));return{text:Qe(t,s),lines:[],...t.requestId?{toastText:Qe(t,s,!1),requestId:t.requestId}:{},..."neutral"===t.kind?{neutral:!0}:{}}}const r=a.filter(e=>"error"===e.level).length,i=ms(a),o=a.map(e=>({item:e,message:Ze(rs(e,s),s)})),l=is(o);return{text:i?s("config.writeRestart",{n:i}):r?s("ui.writeInvalid",{n:r}):s("rule.refused"),lines:o.map(({item:e,message:t})=>{const a=n.find(t=>t.id===e.source_id);return null===e.line?t:s("config.atFile",{file:a?cs(a):e.source_id,line:e.line,message:t})}),...l.length?{backend:l}:{}}}function $o(e,t,n,s,a){const r=Ho(e).length,i=e.filter(e=>e.list===t),o=e.length-i.length;return i.length?{title:a("rule.pending",{n:i.length}),files:r>1?a("rule.pendingFiles",{files:r},"files"):null,elsewhere:o?a("rule.pendingElsewhere",{n:o}):null,failure:n,rows:i.map(e=>({id:e.id,line:Zt(e.condition,e.outbound,e.must),position:Vo(e,s,a)}))}:null}function Vo(e,t,n){return"routing"===e.list||e.before?e.before&&"fallback"!==e.before.kind?n("rule.positionBefore",{n:e.before.index+1}):n("rule.positionEnd"):To(en(t,e.list)?.anchor,e.list,n).label}function Wo(e,t,n,s){return t?{text:s("rule.partial",{n:t,held:n}),lines:[e.text,...e.lines],...e.backend?{backend:e.backend}:{},...e.requestId?{requestId:e.requestId}:{},...e.neutral&&!n?{neutral:!0}:{}}:e}const Uo=e=>[e.neutral?"neutral":"negative",e.toastText??e.text,{requestId:e.requestId}],Go=()=>{pe()};function Ko(){const t=f(),n=Pn(Go,{rethrow:!0,shared:"pending-apply"}),s=et().applying,a=e.useRef(null),r=async(e,s)=>{let a,r=[];try{if(r=(await Un(me(),s)).sources,s.aborted)return;const i=r.find(t=>t.id===e[0].sourceId),o=i&&await n.apply(i,()=>a=function(e,t,n){const s=t.content,a=Jt(s),r=n.map(n=>({rule:n,anchor:Do(e,t,n,a)}));if(r.some(e=>!e.anchor))return null;r.sort((e,t)=>e.anchor.from-t.anchor.from||e.rule.id-t.rule.id);let i="",o=0;for(let l=0;l<r.length;){const e=r[l].anchor.from,t=new Map;for(;l<r.length&&r[l].anchor.from===e;l++){const e=r[l].anchor.open??"";t.set(e,[...t.get(e)??[],r[l]])}i+=s.slice(o,e);for(const[n,s]of t)i+=n+s.map(({rule:e,anchor:t})=>t.indent+Zt(e.condition,e.outbound,e.must)+"\n").join("")+(s[0].anchor.close??"");o=e}return i+s.slice(o)}(r,i,e));if(!i||null===a)return Go(),{written:!1,failure:{text:t("rule.stale"),lines:[]}};if(!o)return;return o.diagnostics?{written:!1,failure:Bo(null,o.diagnostics,r,t)}:{written:!0,failure:null}}catch(i){if(s.aborted)return;return{written:i instanceof A&&["ui.writtenNotApplied","ui.operationUnknown","ui.activationDegradedSaved","ui.activationDegradedUnconfirmed","ui.activationUnknown"].includes(i.key)&&!1!==i.details?.written,failure:Bo(i,null,r,t)}}};return{apply:async e=>{if(!tt.begin())return;const n=new AbortController;a.current=n;try{return await(async(e,n)=>{let s=0;for(const a of Ho(e)){const i=await r(a,n);if(!i)return;i.written&&tt.remove(a.map(e=>e.id));const o=i.written?a.length:0;if(i.failure)return{written:s+o,failure:Wo(i.failure,s&&s+o,e.length-s-o,t)};s+=o}return{written:s,failure:null}})(e,n.signal)}finally{a.current===n&&(a.current=null),tt.end()}},busy:s,cancel:()=>{a.current&&(a.current.abort(),n.cancel())}}}function Jo(){const e=f(),{rules:t}=et(),{apply:n,busy:s}=Ko(),a=Ho(t).length,r=e("rule.applyPending",{n:t.length});return{count:t.length,label:a>1?e("rule.applyFiles",{rules:r,files:a},"files"):r,busy:s,apply:async()=>{const s=await n(t);if(!s)return;if(tt.fail(s.failure),s.failure)return void H(...Uo(s.failure));const a=qo("rule.applied",e,t.length);H("positive",a.text,{detail:a.detail})}}}const Xo="select";function Yo(e,t){const n=e??Xo,s=st(n);return s?X(at,s,t):n}function Qo(e,t){const n=e.native?Yo(e.native,t):X(at,e.kind,t),s=e.native||e.kind;return n===s?{label:n}:{label:n,id:s}}const Zo=e=>"selector"===(st(e??Xo)??"selector");function el(e,t){const n=nt.map(e=>({id:e.id,label:t(e.label),desc:t(e.description)}));return{selected:e??Xo,items:e&&!n.some(t=>t.id===e)?[{id:e,label:Yo(e,t)},...n]:n}}const tl={invalid:"group.badName",taken:"group.takenName"};function nl(e,t,n){const s=sn(e,t);return s?n(tl[s]):null}function sl(e,t,n){return e.every(e=>n?.filters.includes(e)||an(e))&&(t===(n?.policy??null)||an(t??""))}function al(e){return n.jsx(h,{...e,children:n.jsx("path",{fill:"currentColor",d:"M18.207 3.897c-.406-.094-.809.15-.906.554l-.38 1.575C15.523 3.594 12.919 2.02 10 2.02c-3.685 0-6.875 2.5-7.76 6.08-.099.403.147.81.55.909.4.1.808-.147.907-.55.718-2.907 3.31-4.939 6.303-4.939 2.517 0 4.735 1.447 5.809 3.633l-2.102-.508c-.404-.094-.808.15-.906.553s.15.808.553.905l3.245.785c.125.088.274.142.432.142q.09 0 .18-.021c.048-.012.086-.041.13-.061.069-.019.142-.02.205-.058.17-.104.29-.27.338-.464l.875-3.624c.097-.403-.15-.808-.552-.906M17.21 11.032c-.396-.096-.807.147-.907.55-.718 2.908-3.31 4.94-6.303 4.94-2.517 0-4.735-1.447-5.81-3.634l2.103.508c.403.092.809-.15.906-.553s-.15-.808-.553-.905l-3.255-.787c-.171-.118-.385-.171-.602-.119-.015.004-.026.015-.04.02-.104.013-.205.044-.295.1-.17.103-.29.27-.338.463l-.875 3.624c-.097.403.15.808.552.906q.09.02.177.02c.339 0 .646-.23.729-.574l.38-1.575c1.398 2.432 4.002 4.005 6.921 4.005 3.685 0 6.876-2.5 7.76-6.08.099-.403-.147-.81-.549-.909"})})}const rl=["cached","answered","nxdomain","failed"],il=e=>e.cached?"cached":"NOERROR"===e.status?"answered":"NXDOMAIN"===e.status?"nxdomain":"failed";function ol(e,t){const n={cached:0,answered:0,nxdomain:0,failed:0},s=[];for(const l of e){const e=il(l);n[e]++,l.cached||null===l.upstream||s.push({id:l.id,value:l.elapsed_ms,outcome:e,name:l.question.name,upstream:l.upstream})}const a=s.map(e=>e.value).sort((e,t)=>e-t),r=new Map;for(const l of s)r.set(l.upstream,[...r.get(l.upstream)??[],l]);const i=[...r].map(([e,t])=>({upstream:e,median:zr(t.map(e=>e.value).sort((e,t)=>e-t),50),samples:t}));i.sort((e,n)=>n.samples.length-e.samples.length||rt(t)(e.upstream,n.upstream));const o=e.length-n.cached;return{domains:Io(e.map(e=>e.question.name.replace(/\.$/,"")),8),devices:Io(e.map(e=>null===e.src?null:ll(e.src)),8),total:e.length,counts:n,uncached:o,samples:s,typical:zr(a,50),slowest:zr(a,95),failureRate:o?n.failed/o:null,cacheRate:e.length?n.cached/e.length:null,upstreams:i}}const ll=e=>e.replace(/:\d+$/,""),cl=(e,t)=>!!e?.next_cursor&&void 0!==t&&e.records.length<t,dl={default_member_id:"policy.cfg.defaultMember",final_outbound:"policy.cfg.finalOutbound",check_url:"policy.cfg.checkUrl",check_interval:"policy.cfg.checkInterval",tolerance:"policy.cfg.tolerance",idle_timeout:"policy.cfg.idleTimeout",interrupt_connections:"policy.cfg.interruptConnections"},ul=["default_member_id","final_outbound"],ml=(e,t)=>e?ul.filter(n=>e.capabilities.mutable_config.includes(n)&&("default_member_id"!==n||Zo(t))):[],hl=e=>null===e?"none":`=${e}`,pl=e=>e.startsWith("=")?e.slice(1):null,fl=e=>null===e?null:on(e),gl=(e,t)=>null===e||e===fl(t)||cn(e);function bl(e){const t=new Map;for(const[n,s]of e){if("ambiguous"===s)continue;const e=fl(s.entry.final);t.set(n,[...rn(s.entry),...e?[e]:[]])}return t}function xl(e,t){const n=new Map;for(const[r,i]of t)for(const e of i)n.set(e,[...n.get(e)??[],r]);const s=new Set([e]),a=[e];for(;a.length;)for(const e of n.get(a.pop())??[])s.has(e)||(s.add(e),a.push(e));return s}const vl=(e,t,n)=>({id:"none",items:[{id:hl(null),label:n("ui.none")},...[...new Set(t)].filter(t=>null!==t&&!e.some(e=>e.id===hl(t))).map(e=>({id:hl(e),label:e}))]});function yl(e,t,n=new Set){return e.filter(e=>{const s=t(e);return!n.has(s)&&(n.add(s),!0)})}const jl=e=>!1===e.alive?"err":void 0===e.tcp?void 0:Dn(e.tcp);function wl(e,t,n,s){const a=xl(e,t.links),r=new Set([...ot,...t.groups]),i=ot.map(e=>({id:hl(e),label:e})),o=t.groups.filter(e=>!a.has(e)).map(e=>({id:hl(e),label:e})),l=yl(t.nodes,e=>e.name,r).map(e=>({id:hl(e.name),label:e.name,nodeName:!0,desc:!1===e.alive?s("ui.unavailable"):void 0===e.tcp?"—":ue(e.tcp,s),tone:jl(e)})),c=[...i,...o,...l];return[vl(c,n,s),{id:"builtin",title:s("policy.pickBuiltin"),items:i},{id:"groups",title:s("policy.pickGroups"),items:o},{id:"nodes",title:s("policy.pickNodes"),items:l}].filter(e=>e.items.length)}function kl(e,t,n){const s=yl(e,e=>e.name).map(e=>({id:hl(e.name),label:e.name,nodeName:e.nodeName,desc:e.status.badge&&e.status.text?n("ui.valuePair",{label:e.status.badge,value:e.status.text}):e.status.text||e.status.badge,tone:e.status.tone}));return[vl(s,t,n),{id:"members",title:n("policy.pickMembers"),items:s}].filter(e=>e.items.length)}function Nl(e,t){const n=$(e);return void 0!==n?{text:ue(n,t),tone:Dn(n)}:"unavailable"===e?.state?{text:t("ui.unavailable"),tone:"err"}:{text:"—"}}function Ml(e,t,n){const s=ln(e);return[...rn({filters:e}).map(e=>({name:e,nodeName:!1,status:{text:"",badge:n("ui.group")}})),...t.filter(s).map(e=>({name:e.name,nodeName:!0,status:Nl(V(e),n)}))]}function _l(e){const t=new Map;for(const n of e)for(const e of Gt(n.content))t.set(e.name,t.has(e.name)?"ambiguous":{entry:e,origin:n});return t}function Sl(e,t,n){return t.error?it(t.error,n):t.loaded?e?"ambiguous"===e?n("policy.editAmbiguous"):e.origin.writable?void 0===t.complete?n("policy.editNoConfig"):t.complete?null:n("config.incomplete"):n("policy.editReadOnly",{file:e.origin.path}):n("policy.editNoEntry"):n("policy.editNoConfig")}function Cl(e,t,n,s,a,r){t!==n&&e(t).then(e=>{e&&void 0!==s&&H("positive",((e,t,n,s)=>s("override"===e.source?"policy.pinned":e.connections_interrupted?"policy.selectedInterrupted":"policy.selectedKept",{name:t,member:n}))(e,s,a(e.member_id),r))})}function El(e){return{measured:[...new Map(e.flatMap(e=>e.rows).map(e=>[e.id,e])).values()].sort((e,t)=>e.latest-t.latest),missing:[...new Map(e.flatMap(e=>e.missing).map(e=>[e.id,e])).values()],down:new Set(e.flatMap(e=>e.missing.filter(e=>"unavailable"===e.state).map(e=>e.id))).size}}function Ll(e,t,n){const s=function(e){const t=function(e){const t=[e.moving,e.avg10].filter(e=>null!==e);return t.length?[Math.min(...t),Math.max(...t)]:null}(e);return null!==t&&e.latest>t[1]*Rl.ratio&&e.latest-t[1]>=Rl.ms}(e);return{id:e.id,label:e.name,nodeName:!0,href:n,value:e.latest,average:Ol(e),range:Pl(e),text:ue(e.latest,t),tone:s?"notice":void 0,details:()=>[t("ui.valuePair",{label:t("nodes.latency.latest"),value:ue(e.latest,t)}),...null!==e.moving?[t("ui.valuePair",{label:t("nodes.latency.moving"),value:ue(e.moving,t)})]:[],...null!==e.avg10?[t("ui.valuePair",{label:t("nodes.latency.avg10"),value:ue(e.avg10,t)})]:[],...s?[t("nodes.latency.slower")]:[]]}}function zl(e,t,n,s){const a=rt(s),r=new Map((t??[]).map(e=>[e.id,e.name])),i=new Map,o=(e,t)=>{let n=i.get(e);return n||i.set(e,n={id:e,label:t,rows:[],missing:[]}),n};for(const c of e){const e=V(c),t="protocol"===n?[["protocol:"+(c.protocol??""),c.protocol??null]]:c.group_ids.length?c.group_ids.map(e=>["group:"+e,r.get(e)??e]):[["group:",null]];for(const[n,s]of t){const t=o(n,s);"healthy"===e?.state&&null!==e.latency_ms?t.rows.push({id:c.id,name:c.name,latest:e.latency_ms,moving:e.moving_avg_ms,avg10:e.avg10_ms}):t.missing.push({id:c.id,name:c.name,state:"unavailable"===e?.state?"unavailable":"unmeasured"})}}const l=[...i.values()];for(const c of l)c.rows.sort((e,t)=>e.latest-t.latest||a(e.name,t.name)),c.missing.sort((e,t)=>a(e.name,t.name));return l.sort((e,t)=>(null===e.label?1:0)-(null===t.label?1:0)||a(e.label??"",t.label??""))}const Rl={ratio:1.3,ms:20};function Ol(e){return e.avg10??e.moving}function Pl(e){if(null===e.moving&&null===e.avg10)return null;const t=[e.latest,e.moving,e.avg10].filter(e=>null!==e);return[Math.min(...t),Math.max(...t)]}function Al(e){const t=e.flatMap(e=>e.rows);return{moving:t.some(e=>null!==e.moving),avg10:t.some(e=>null!==e.avg10)}}function Il(e){const t=e.flatMap(e=>e.rows.flatMap(e=>[e.latest,e.moving??e.latest,e.avg10??e.latest])).sort((e,t)=>e-t),n=Math.max(10,1.25*(zr(t,90)??0)),s=n<=100?20:n<=500?100:n<=2e3?500:1e3;return Math.ceil(n/s)*s}const Tl=[3600,21600,43200,86400];function ql(e,t,n){return 0===e?n("nodes.manualOnly"):e%3600==0?n("nodes.everyHours",{n:e/3600}):n("nodes.everyDuration",{duration:lt(String(e),t)})}function Dl(e){const t=e.at(-1);return"m"===t||"h"===t?{count:e.slice(0,-1),unit:t}:null}function Hl(e){return Dl(e)??(/^\d+$/.test(e)?0===(t=Number(e))||Tl.includes(t)||t%60?null:t%3600?{count:String(t/60),unit:"m"}:{count:String(t/3600),unit:"h"}:null);var t}function Fl(e){const t=Number(e);return t>0&&t%3600==0?t/3600+"h":"h"}function Bl(e){if(""===e)return;const t=dn(e);return null!==t&&Number.isSafeInteger(t)?t:null}function $l(e){if(""===e||""===Dl(e)?.count)return null;const t=dn(e);return null===t?"nodes.intervalInvalid":Number.isSafeInteger(t)?null:"nodes.intervalTooLarge"}function Vl(e,t){const n=e+t;return 0===Bl(n)?"0":n}function Wl(e,t,n){return[...[0,...Tl,...null===e||e%60==0?[]:[e]].map(e=>({id:String(e),label:ql(e,t,n)})),{id:"typed",label:n("nodes.intervalCustom")}]}const Ul=new Map([["tcp","TCP"],["ws","WS"],["grpc","gRPC"],["xhttp","XHTTP"]]);function Gl(e,t,n,s){const a=Kl(V(e),s),r=function(e,t){const n=ft(e.health);return n.map(({kind:e,transport:s,observation:a})=>({label:n.some(t=>t.kind===e&&t.transport!==s)?t("ui.aside",{text:e,note:s.toUpperCase()}):e,...Kl(a,t,a.error?de(a.error,t):void 0)}))}(e,s),i=e.protocol??"—",o=e.stream_transport;return{id:e.id,name:e.name,protocol:o?s("ui.aside",{text:i,note:Ul.get(o)??o}):i,latency:a.value,latencyClass:a.tone,groups:e.group_ids.length?ke(n,e.group_ids.map(e=>t.get(e)??e)):"—",probeKinds:r,showProbeKinds:r.length>1,probeLabel:s("nodes.probe",{name:e.name}),removeLabel:s("nodes.remove",{name:e.name})}}function Kl(e,t,n){const s=$(e);return{value:void 0!==s?ue(s,t):"unavailable"===e?.state?n??t("ui.unavailable"):"—",tone:void 0!==s?`ms ${Dn(s)}`:"unavailable"===e?.state?"ms err":"ms"}}const Jl=e=>$(V(e)),Xl=(e,t,n,s)=>e&&t&&n.writable&&!0===s;function Yl(e,t,n){const s=Bl(e.interval);return{name:e.name.trim()!==t.tag,url:un(e.value)!==t.url,interval:""!==e.interval&&(null===s||s!==t.interval),agent:e.agent!==(t.ua??"")&&(e.agent.trim()||null)!==(t.ua??null),cache:null!==e.cache&&e.cache!==(t.cache??n),route:(e.route||"routing")!==(t.route||"routing")}}function Ql(e,t,n,s,a){return e&&t&&n&&s.writable&&void 0===a?null:e&&Xl(t,n,s,a)?"edit":"open"}function Zl(e,t,n){if(!e.length)return null;const s=e.length>1?e.filter(({entry:e})=>mn(e.url)===mn(t.url_redacted)):e;return{...1===s.length?s[0]:e[0],unique:1===e.length&&1===n.filter(e=>"subscription"===e.kind&&e.name===t.name).length}}function ec(e,t,n,s,a,r){const i=a.name.trim(),o=i!==n.name,l=o&&e.some(e=>e.id!==t.id&&pn(e.content,n.name)),c=o&&(s.some(e=>e.name===i)||e.some(e=>("main"===e.kind||"include"===e.kind)&&fn(e.content).some(e=>e.name===i))),d=i?c?r("nodes.nameTaken"):gn(i)?null:r("config.unquotable"):r("nodes.nameMissing"),u=hc(a.value,r)??(a.value.trim()?null:r("nodes.linkInvalid")),m=d??u??(l?r("nodes.renameElsewhere"):null);return{nameError:d,linkError:u,reason:m,valid:null===m&&(a.name!==n.name||a.value!==n.link)}}const tc=e=>e.some(({source:e})=>"main"!==e.kind);function nc(e,t,n){const s="subscription"===n?.kind;return{blockers:s?[...new Set((e??[]).flatMap(e=>hn(e.content,n.name)))]:[],checking:s&&t&&!e}}function sc(e,t,n){return{here:yn(t.content??"",n),elsewhere:e.filter(e=>e.id!==t.id&&yn(e.content??"",n).length>0||jn(e.content??"",n))}}function ac(e,t,n,s){const a=new Map;for(const f of t){if(!f.provider_id||!f.subscription_tag)continue;const e=a.get(f.provider_id)??new Set;e.add(f.subscription_tag),a.set(f.provider_id,e)}const r=e=>{const t=a.get(e);return 1===t?.size?[...t][0]:void 0},i=e=>{const t=mn(e.url_redacted),s=t?n.filter(e=>mn(e.url)===t):[];return 1===s.length?s[0].tag:void 0},o=new Map,l=e.filter(e=>"subscription"===e.kind);for(const f of l){const e=r(f.id)??i(f);e&&o.set(f.id,e)}const c=l.filter(e=>!o.has(e.id)),d=new Set(o.values()),u=n.filter(e=>!d.has(e.tag));1===c.length&&1===u.length&&o.set(c[0].id,u[0].tag);const m=e.map(e=>{const t=r(e.id);return{...e,displayName:o.get(e.id)??e.name,configTag:"subscription"===e.kind&&t&&1===n.filter(e=>e.tag===t).length?t:void 0,sourceTag:"subscription"===e.kind?e.name:void 0}}),h={builtin:0,unattributed:0};for(const f of t)null==f.provider_id&&h[Ve(f)]++;const p=[];for(const f of["builtin","unattributed"]){const t=h[f];t&&p.push({id:ct(f,e),name:s("builtin"===f?"nodes.kind.builtin":"nodes.kind.unattributed"),kind:f,url_redacted:null,node_count:t,updated_at:null,expires_at:null,traffic:null,status:"ok",last_error:null})}return{list:[...p,...m]}}function rc(e,t){return null!==t&&e.some(e=>e.id===t)?t:(e.find(e=>"builtin"!==e.kind&&"unattributed"!==e.kind)??e[0])?.id??null}function ic(e,t,n){return e.filter(e=>void 0===t||(null===t?null==e.provider_id&&"builtin"===Ve(e)==("builtin"===n):e.provider_id===t))}function oc(e,t){return n=>e.get(r(n,t))??"—"}function lc(e,t,n,s,a,r,i){const o=t.trim(),l=e.filter(e=>(!o||r(e.name,o))&&(!n||e.group_ids.includes(n))&&(!s||e.protocol===s)),c="ascending"===a.direction?1:-1,d=rt(i),u="latency"===a.column?new Map(l.map(e=>[e.id,Jl(e)])):new Map,m={name:(e,t)=>d(e.name,t.name),protocol:(e,t)=>d(e.protocol??"",t.protocol??""),latency:(e,t)=>pt(u.get(e.id),u.get(t.id))||d(e.name,t.name)};return l.sort((e,t)=>c*(m[a.column]??m.name)(e,t))}function cc(e,t){return e.filter(e=>!("ua"===e.name||"interval"===e.name||"cache"===e.name&&t.cache||("route"===e.name||"download_detour"===e.name)&&t.route))}function dc(e,t){const n={name:e.name.trim(),kind:"subscription",url:un(e.value)},s=Bl(e.interval);void 0!==t?.update_interval&&null!=s&&s!==t.update_interval&&(n.update_interval=s);const a=e.agent.trim();return void 0!==t?.user_agent&&a&&a!==t.user_agent&&(n.user_agent=a),void 0!==t?.cache&&null!==e.cache&&e.cache!==t.cache&&(n.cache=e.cache),n}function uc(e,t,n,s){const a="builtin"===e.kind||"unattributed"===e.kind,r="subscription"===e.kind&&"stale"===e.status&&null===e.updated_at&&null===e.last_error,i=e.traffic?K(e.traffic.upload_bytes,e.traffic.download_bytes):null,o=null!==i&&e.traffic?.total_bytes&&"0"!==e.traffic.total_bytes?J(i,e.traffic.total_bytes):null,l="subscription"===e.kind?t:void 0,c=e.displayName??e.name;return{id:e.id,name:c,url:e.url_redacted??void 0,kind:X({subscription:"nodes.kind.subscription",file:"nodes.kind.file",inline:"nodes.kind.inline",builtin:"nodes.kind.builtin",unattributed:"nodes.kind.unattributed"},e.kind,s),count:ee(e.node_count,n),usage:null===i?"—":e.traffic?.total_bytes?ht(i,e.traffic.total_bytes,n,s):se(i,n),updatedAt:a?null:e.updated_at,expires:e.expires_at?ae(e.expires_at,n):"—",expiresShort:e.expires_at?mt(e.expires_at,n):"—",quota:null===o?null:{pct:o,tone:ut(o)},interval:null==l?"—":ql(l,n,s),status:a?null:r?s("nodes.status.never"):X({ok:"nodes.status.ok",stale:"nodes.status.stale",error:"nodes.status.error"},e.status,s),tone:r?"neutral":{ok:"ok",stale:"warn",error:"err"}[e.status],error:e.last_error?Ze(dt(e.last_error.code,e.last_error.message,s),s):void 0,refreshLabel:s("nodes.refresh",{name:c}),removeLabel:s("nodes.remove",{name:c})}}function mc(e,t){const n=un(e);return n?bn(n)?gn(n)?null:t("config.unquotable"):t("nodes.urlInvalid"):null}function hc(e,t){const n=e.trim();return n?vn(n)?gn(n)?null:t("config.unquotable"):t("nodes.linkInvalid"):null}function pc(e,t,n,s){const a=t.trim();if("provider"!==e&&"node"!==e||!a&&!n.trim())return null;if(!a)return s("nodes.nameMissing");if("node"===e){const e=n.trim();return e?hc(n,s)??([...e].length>8192?s("nodes.linkTooLong",{n:8192}):null):s("nodes.linkInvalid")}return xn(a)?mc(n,s)??(n.trim()?null:s("nodes.urlInvalid")):s("nodes.nameInvalid")}function fc(e,t,n){return[..._l(e).values()].flatMap(e=>"ambiguous"!==e&&e.origin.writable&&!0===t(e.origin)&&!n(e.origin)?[e.entry]:[])}const gc=""+new URL("duck-night-CbKHyiul.webp",import.meta.url).href;function bc(e){return n.jsx(h,{...e,children:n.jsx("path",{fill:"currentColor",d:"M10 1.5a8.5 8.5 0 0 0-2.69 16.57c.43.08.58-.18.58-.41v-1.44c-2.36.51-2.86-1.14-2.86-1.14-.39-.98-.95-1.24-.95-1.24-.77-.53.06-.52.06-.52.85.06 1.3.88 1.3.88.76 1.3 1.99.92 2.47.71.08-.55.3-.93.54-1.14-1.89-.22-3.87-.95-3.87-4.2 0-.93.33-1.69.87-2.28-.09-.22-.38-1.08.08-2.25 0 0 .71-.23 2.34.87a8.1 8.1 0 0 1 4.26 0c1.62-1.1 2.33-.87 2.33-.87.47 1.17.18 2.03.09 2.25.54.59.87 1.35.87 2.28 0 3.26-1.99 3.98-3.88 4.19.31.26.58.78.58 1.58v2.34c0 .23.15.5.58.41A8.5 8.5 0 0 0 10 1.5"})})}function xc({trigger:e,isOpen:t,onOpenChange:s,onHonk:a}){const r=gt(a),i=bt(wt);return n.jsx(xt,{title:r.title,narrow:!0,scrollBody:i,trigger:e,isOpen:t,onOpenChange:s,footer:e=>n.jsx(M,{onPress:e,children:r.close}),children:n.jsxs("div",{className:yt("rp-about",r.honked&&"honked"),children:[n.jsxs(M,{appearance:"plain",className:yt("rp-about-duck",r.painted&&"painted"),onPress:r.tap,label:r.duck,children:[n.jsx("img",{src:vt,alt:"",className:yt(r.hop&&"hop")},r.taps),n.jsx("img",{src:r.taps>0?gc:void 0,alt:"",className:"night"}),r.honked&&n.jsx("span",{className:"rp-about-bubble",children:r.quack})]}),n.jsxs("div",{className:"rp-about-name",children:[n.jsxs("span",{className:"rp-brand-text",children:[n.jsx("span",{children:r.wordmark}),n.jsx("span",{className:"rp-brand-version",children:r.versionText})]}),n.jsx("span",{className:"rp-label",children:r.tagline})]}),n.jsx(Gn,{items:r.items}),n.jsx("p",{className:"rp-label",children:r.credits}),n.jsx("p",{className:"rp-label",children:r.privacy}),n.jsxs("div",{className:"rp-cluster rp-about-links",children:[n.jsxs(wn,{appearance:"link",href:r.guide.href,external:!0,children:[n.jsx(jt,{}),r.guide.label]}),r.repositories.map(e=>n.jsxs(wn,{appearance:"link",href:e.href,external:!0,children:[n.jsx(bc,{}),e.label]},e.href))]})]})})}const vc=new Set;function yc(){vc.forEach(e=>e())}function jc({go:t,openSearch:s,refresh:a,mac:r,entries:i,paths:o}){const l=f(),[c,d]=e.useState(!1);e.useEffect(()=>{return e=()=>d(!0),vc.add(e),()=>{vc.delete(e)};var e},[]),e.useEffect(()=>{let e=null;const n=()=>{e=null},r=r=>{const i=r.target;if("Control"!==r.key&&"Meta"!==r.key||kt(),r.defaultPrevented||r.repeat||r.isComposing||i instanceof HTMLElement&&(i.isContentEditable||i.closest('input, textarea, select, [role="textbox"], [role="dialog"], [role="alertdialog"], [role="menu"], [role="listbox"]')))return void n();if((r.ctrlKey||r.metaKey)&&!r.altKey&&"k"===r.key.toLowerCase())return r.preventDefault(),n(),void s();if(r.ctrlKey||r.metaKey||r.altKey)return void n();if("?"===r.key)return r.preventDefault(),n(),void d(!0);if("/"===r.key){n();const e=document.querySelector('.rp-content input[type="search"]');return void(e&&(r.preventDefault(),e.focus(),e.select()))}const l=e;if(n(),null!==l&&performance.now()-l<=800){const e=o[r.key];if(e&&Nt(e))return r.preventDefault(),void t(e)}if("r"===r.key)return r.preventDefault(),n(),void a();"g"===r.key&&(r.preventDefault(),e=performance.now())};return addEventListener("keydown",r),addEventListener("blur",n),addEventListener("focusin",n),()=>{removeEventListener("keydown",r),removeEventListener("blur",n),removeEventListener("focusin",n)}},[t,s,a,o]);const u=r?"⌘":`${l("shell.keyCtrl")} `;return n.jsx(xt,{title:l("shell.shortcuts"),isOpen:c,onOpenChange:d,footer:()=>n.jsx(M,{onPress:()=>d(!1),children:l("ui.close")}),children:n.jsxs("div",{className:"rp-shortcuts",children:[n.jsxs("div",{children:[n.jsxs("section",{children:[n.jsx("h3",{children:l("shell.shortcutGeneral")}),n.jsx(wc,{label:l("shell.shortcutSearch"),keys:[l(r?"shell.macShortcut":"shell.shortcut")]}),n.jsx(wc,{label:l("shell.shortcutHelp"),keys:["?"]}),n.jsx(wc,{label:l("shell.shortcutFilter"),keys:["/"]}),n.jsx(wc,{label:l("ui.refresh"),keys:["R"]})]}),n.jsxs("section",{children:[n.jsx("h3",{children:l("shell.shortcutTables")}),n.jsx(wc,{label:l("shell.shortcutMove"),keys:["↑","↓"]}),n.jsx(wc,{label:l("shell.shortcutSelect"),keys:[l("shell.keyEnter"),l("shell.keySpace")]}),n.jsx(wc,{label:l("shell.shortcutClose"),keys:[l("shell.keyEsc")]})]}),n.jsxs("section",{children:[n.jsx("h3",{children:l("shell.shortcutEditor")}),n.jsx(wc,{label:l("shell.shortcutApply"),keys:[`${u}S`]}),n.jsx(wc,{label:l("shell.shortcutSearch"),keys:[`${u}F`]}),n.jsx(wc,{label:l("shell.shortcutLine"),keys:[`${u}G`]}),n.jsx(wc,{label:l("shell.shortcutComment"),keys:[`${u}/`]})]})]}),n.jsxs("section",{children:[n.jsx("h3",{children:l("shell.shortcutGoTo")}),n.jsx("p",{className:"rp-label",children:l("shell.shortcutSequence")}),i.map(e=>n.jsx(wc,{label:e.label,keys:e.keys},e.id))]})]})})}function wc({label:e,keys:t}){return n.jsxs("div",{className:"rp-row",children:[n.jsx("span",{children:e}),n.jsx("span",{className:"keys",children:t.map((e,t)=>n.jsx("kbd",{className:"rp-kbd",children:e},t))})]})}function kc(e){return n.jsxs("svg",{className:"rp-icon",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",...e,children:[n.jsx("rect",{x:"3",y:"3",width:"6",height:"6",rx:"1"}),n.jsx("rect",{x:"12",y:"3",width:"5",height:"9",rx:"1"}),n.jsx("rect",{x:"3",y:"12",width:"6",height:"5",rx:"1"}),n.jsx("path",{d:"M12 15h5"})]})}function Nc({backend:e,close:t,openAbout:s}){return n.jsxs(n.Fragment,{children:[n.jsx(Gn,{row:!0,items:e.facts}),n.jsxs("div",{className:"rp-backend-actions",children:[n.jsx(M,{quiet:!0,onPress:()=>{t(),s()},children:e.about}),n.jsx(wn,{appearance:"button",href:e.edit.href,onPress:t,children:e.edit.label})]})]})}function Mc({backend:t,honk:s,popover:a}){const[r,i]=e.useState(!1);return n.jsxs(n.Fragment,{children:[n.jsx(L,{title:t.heading,subtitle:n.jsx(R,{tone:t.tone,small:!0,children:t.state}),...a,children:e=>n.jsx(Nc,{backend:t,close:e,openAbout:()=>i(!0)})}),n.jsx(xc,{isOpen:r,onOpenChange:i,onHonk:s})]})}function _c({backend:e,honk:t,panel:s=!1}){return n.jsx(Mc,{backend:e,honk:t,popover:{trigger:s?n.jsx(M,{quiet:!0,icon:!0,label:e.label,children:n.jsx(R,{tone:e.tone,small:!0})}):n.jsxs(M,{appearance:"plain",className:"rp-version",label:e.label,children:[n.jsx(R,{tone:e.tone,small:!0}),n.jsx("span",{className:"rp-version-text",children:e.text})]})}})}function Sc({backend:e,honk:t,anchor:s,isOpen:a,onOpenChange:r}){return n.jsx(Mc,{backend:e,honk:t,popover:{triggerRef:s,isOpen:a,onOpenChange:e=>{r(e),e||s.current?.querySelector("button")?.focus()}}})}const Cc=Qa(l.widgets,Ta,La),Ec=Cc.read,Lc=Cc.save,zc=Cc.useLayout,Rc=e=>Lc(t=>({...t,...e})),Oc=e.lazy(()=>g(()=>Promise.resolve().then(()=>hu),void 0,import.meta.url).then(e=>({default:e.PanelHost}))),Pc=e.lazy(()=>g(()=>Promise.resolve().then(()=>hu),void 0,import.meta.url).then(e=>({default:e.PhoneDrawer}))),Ac=e.lazy(()=>g(()=>import("./Editors-dKzIa8sH.js"),__vite__mapDeps([14,1,2,3,4,15,16,11,17,10,9,8,7,18]),import.meta.url).then(e=>({default:e.WidgetEditor}))),Ic=t=>n.jsx(p,{children:n.jsx(e.Suspense,{fallback:null,children:t})});function Tc({route:t,backend:s,honk:a}){const r=f(),i=bt(Mt),o=bt(wt),l=zc(),[c,d]=e.useState({text:"",serial:0}),u=!!O().data&&!o&&l.visible,m=i&&!!l.docked,h=n.jsx(_c,{backend:s,honk:a}),g=n.jsx(Oc,{route:t,backend:s,honk:a,dockable:i,onDock:e=>{Rc({docked:e||void 0}),d(t=>({text:r(e?"widgets.docked":"widgets.undocked"),serial:t.serial+1}))}});return n.jsxs(n.Fragment,{children:[u&&i&&!m&&n.jsx("div",{className:"rp-dock-slot","aria-hidden":"true",children:r("widgets.dropToDock")}),u&&m?n.jsx(p,{children:n.jsx(e.Suspense,{fallback:h,children:g})}):h,u&&!m&&Ic(g),u&&i&&n.jsx(Be,{children:n.jsx("span",{role:"status",children:n.jsx("span",{children:c.text},c.serial)})})]})}function qc({route:t,backend:s}){const a=!bt(wt),r=zc(),[i,o]=e.useState(!1),[l,c]=e.useState(!1),d=e.useSyncExternalStore(zs.subscribe,zs.snapshot),[u,m]=e.useState({route:t,floating:a});u.route===t&&u.floating===a||(m({route:t,floating:a}),o(!1)),i&&!l&&c(!0);const h=f(),p=a?r.visible:i;return n.jsxs(n.Fragment,{children:[n.jsx(M,{quiet:!0,icon:!0,isSelected:p,label:h(p?"widgets.hide":"widgets.show"),onPress:()=>a?Rc({visible:!r.visible}):o(!i),children:n.jsx(kc,{})}),!a&&l&&Ic(n.jsx(Pc,{open:i,onClose:()=>o(!1),backend:s})),d&&Ic(n.jsx(Ac,{backend:s,onClose:()=>zs.set(!1)}))]})}function Dc(){try{const e=JSON.parse(localStorage.getItem(l.navGroups)??"[]");return Array.isArray(e)?e.filter(e=>"string"==typeof e):[]}catch{return[]}}const Hc=e.memo(function({route:t,groups:s,busy:a,backend:r,honk:i,navRef:o,navStyle:c}){const[d,u]=e.useState(Dc);return _t(o),n.jsxs("nav",{className:"rp-side","aria-busy":a||void 0,children:[n.jsxs("div",{className:"rp-side-links rp-overlay-scroll",ref:o,children:[c&&n.jsx("span",{className:"rp-nav-slider",style:c}),s.map(e=>n.jsx("div",{"data-group":e.id,children:n.jsx(Kn,{variant:"nav",title:e.label,isExpanded:!d.includes(e.id),onExpandedChange:t=>{const n=t?d.filter(t=>t!==e.id):[...d,e.id];u(n),function(e){try{localStorage.setItem(l.navGroups,JSON.stringify(e))}catch{}}(n)},children:e.items.map(e=>n.jsxs(wn,{className:"rp-nav",href:e.href,"aria-current":e.current?"page":void 0,"data-unavailable":e.unavailable?"":void 0,"aria-description":e.description,onHoverStart:()=>St(e.id),onFocus:()=>St(e.id),children:[n.jsx(e.Icon,{}),e.label]},e.id))})},e.id))]}),n.jsx(Tc,{route:t,backend:r,honk:i})]})});function Fc({label:e,items:t}){return n.jsx("nav",{className:"rp-page-links","aria-label":e,children:t.map(e=>n.jsx(wn,{appearance:"button",href:e.href,"aria-current":e.current?"page":void 0,children:e.label},e.id))})}const Bc=l.hubPages;function $c(){try{return JSON.parse(sessionStorage.getItem(Bc)??"{}")??{}}catch{return{}}}function Vc({groups:t}){const s=f(),[a,r]=e.useState($c),i=t.flatMap(e=>e.items.filter(e=>e.current).map(t=>[e.id,t.path]))[0];return i&&a[i[0]]!==i[1]&&r({...a,[i[0]]:i[1]}),e.useEffect(()=>{try{sessionStorage.setItem(Bc,JSON.stringify(a))}catch{}},[a]),n.jsx("nav",{className:"rp-hubbar","aria-label":s("shell.hubs"),children:t.map(e=>{const t=e.items[0].Icon;return n.jsxs(wn,{href:(e.items.find(t=>t.path===a[e.id])??e.items[0]).href,"aria-current":i?.[0]===e.id?"page":void 0,children:[n.jsx("span",{className:"rp-hubbar-pill",children:n.jsx(t,{})}),e.label]},e.id)})})}function Wc({hub:e}){return n.jsx("div",{className:"rp-hubnav",children:n.jsx(Fc,{label:e.label,items:e.items})})}function Uc(e){return n.jsxs(h,{...e,children:[n.jsx("path",{fill:"currentColor",d:"M18.592 15.186c-.398-.13-.818.086-.946.479-.447 1.367-1.711 2.285-3.146 2.285-1.074 0-2.04-.52-2.648-1.342l.16.058c.323.118.683-.05.8-.376.117-.324-.051-.683-.376-.8l-1.819-.656c-.158-.057-.334-.048-.485.026-.152.074-.268.205-.32.367l-.63 1.907c-.107.327.07.68.399.789q.097.031.195.031c.263 0 .507-.166.594-.43l.091-.275c.866 1.344 2.366 2.201 4.039 2.201 2.086 0 3.923-1.334 4.571-3.318.13-.395-.086-.818-.48-.946M19.318 11.054c-.326-.11-.68.071-.789.398l-.064.197c-.882-1.281-2.357-2.1-3.965-2.1-2.104 0-3.945 1.35-4.583 3.356-.125.396.093.818.487.943.4.13.818-.094.943-.488.438-1.381 1.706-2.31 3.153-2.31 1.07 0 2.05.528 2.663 1.36l-.274-.1c-.32-.115-.683.052-.8.377s.05.682.376.8l1.818.656q.104.037.212.037.143 0 .274-.064c.152-.073.267-.206.32-.366l.628-1.907c.107-.328-.07-.68-.399-.79"}),n.jsx("path",{fill:"currentColor",d:"M8.18 10.927C5.01 10.662 3.567 9.807 3.5 9.5V6.224C5.03 7.067 7.524 7.5 10 7.5s4.97-.433 6.5-1.276v1.5c0 .414.336.75.75.75s.75-.336.75-.75V4.56c0-.041-.017-.076-.023-.115.008-.066.023-.129.023-.196C18 2.116 13.976 1 10 1S2 2.116 2 4.25c0 .067.015.13.023.196C2.017 4.485 2 4.52 2 4.56V14.5c0 1.776 2.928 2.491 4.673 2.759q.058.009.115.009c.364 0 .684-.266.74-.636.063-.41-.217-.793-.627-.856-2.464-.379-3.356-1.072-3.401-1.276v-3.144c1.484.738 3.659.99 4.555 1.065l.063.003c.386 0 .714-.296.746-.688.035-.413-.271-.775-.684-.81M10 2.5c4.288 0 6.5 1.227 6.5 1.75S14.288 6 10 6 3.5 4.773 3.5 4.25 5.712 2.5 10 2.5"})]})}const Gc=e.memo(function({route:t,lang:s,pickLang:r,ap:i,mac:o,openSearch:l,refresh:c,spinning:d,commands:u,apply:m,reload:h,honk:p,backend:g,wordmark:b,versionText:x,paletteSections:v,menu:y}){const j=f(),{palettes:w}=Nn({ap:i,paletteSections:v}),k=e.useRef(null),[N,_]=e.useState(!1),[S,C]=e.useState(!1),E=()=>C(!0),L={label:j("ui.appearanceSettings"),onAction:()=>location.assign(a("settings",{tab:"appearance"}))};return n.jsxs("header",{className:"rp-top",children:[n.jsx(xc,{onHonk:p,trigger:n.jsxs(M,{appearance:"plain",className:"rp-brand",tip:j("about.title"),children:[n.jsx("img",{src:vt,alt:""}),n.jsxs("span",{className:"rp-brand-text",children:[n.jsx("span",{children:b}),n.jsx("span",{className:"rp-brand-version",children:x})]})]})}),n.jsx("div",{className:"rp-search-wrap",onPointerEnter:kt,onFocus:kt,children:n.jsxs(M,{appearance:"plain",className:"rp-search",onPress:l,children:[n.jsx(Ct,{}),n.jsx("span",{className:"grow",children:j("shell.search")}),n.jsx("span",{className:"rp-kbd",children:j(o?"shell.macShortcut":"shell.shortcut")})]})}),n.jsxs("div",{className:"rp-actions",children:[n.jsx(qc,{route:t,backend:g}),n.jsx("span",{className:"rp-search-compact",onPointerEnter:kt,onFocus:kt,children:n.jsx(M,{quiet:!0,icon:!0,label:j("shell.search"),onPress:l,children:n.jsx(Ct,{})})}),n.jsx(M,{quiet:!0,icon:!0,label:j("ui.refresh"),isPending:d,onPress:c,children:n.jsx(Uc,{})}),u.apply&&n.jsxs(M,{quiet:!0,icon:!0,className:"rp-held",label:u.apply.label,isPending:u.apply.busy,isDisabled:u.apply.blocked,onPress:m,children:[n.jsx(ns,{}),n.jsx("span",{className:"rp-held-count",children:u.apply.count})]}),n.jsxs("span",{className:"rp-wide-only",children:[u.reload&&n.jsx(M,{quiet:!0,icon:!0,label:u.reload.label,isPending:u.reload.busy,isDisabled:u.reload.blocked,onPress:E,children:n.jsx(al,{className:"rp-spin-on-press"})}),n.jsx(Jn,{}),n.jsx(Mn,{lang:s,pickLang:r}),n.jsx(_n,{ap:i,paletteSections:v,more:L}),n.jsx(Sn,{dark:i.dark,label:y.themeLabel,toggle:i.toggle})]}),n.jsxs("span",{className:"rp-narrow-only",ref:k,children:[n.jsx(kn,{quiet:!0,chevron:!1,label:j("ui.moreOptions"),submenus:[{label:j("ui.lang"),icon:n.jsx(Cn,{}),sections:[{title:j("ui.lang"),items:Et,value:s,onChange:e=>r(e)}]},{label:j("ui.theme"),icon:n.jsx(En,{}),sections:[{title:j("ui.theme"),items:y.schemes,value:i.scheme,onChange:e=>i.pickScheme(e)}]},{label:j("ui.palette"),icon:n.jsx(Ln,{}),sections:w,actions:[L]}],actions:[...u.reload?[{label:u.reload.label,icon:n.jsx(al,{}),onAction:E}]:[],{label:g.title,icon:n.jsx(Lt,{}),onAction:()=>_(!0)}],children:n.jsx(Xn,{})}),n.jsx(Sc,{backend:g,honk:p,anchor:k,isOpen:N,onOpenChange:_})]})]}),n.jsx(Ao,{isOpen:S&&!!u.reload,onCancel:()=>C(!1),isPending:u.reload?.busy,isDisabled:u.reload?.blocked,onConfirm:()=>{C(!1),h()}})]})});function Kc(){const t=e.useSyncExternalStore(zt,Rt);return t&&n.jsx(Jc,{...t},t.until)}function Jc({status:t,until:s}){const a=f(),[r]=e.useState(Date.now),[i,o]=e.useState(r);e.useEffect(()=>{const e=setInterval(()=>o(Date.now()),1e3);return()=>clearInterval(e)},[]);const l=e=>a(429===t?"shell.rateLimited":"shell.backendBusy",{n:Math.max(1,Math.ceil((s-e)/1e3))});return n.jsxs(Ot,{tone:"informative",children:[n.jsx("span",{"aria-hidden":"true",children:l(i)}),n.jsx(Be,{children:l(r)})]})}const Xc=()=>{pe()};function Yc({lang:t,pickLang:s,ap:a,route:r,query:i,go:o,openSearch:l,mac:c,view:d}){const u=f(),{paletteSections:m,settingsValue:h,menu:g,navRef:b,navStyle:x}=At(t,s,a,r),{commands:v,apply:y,reload:j}=function(){const t=f(),n=O(),s=Jo(),a=Po(void 0,n.data,Xc),r=e.useRef({held:s,lifecycle:a});e.useLayoutEffect(()=>{r.current={held:s,lifecycle:a}});const i=e.useCallback(()=>{r.current.held.apply()},[]),o=e.useCallback(()=>{r.current.lifecycle.run("reload")},[]),l=a.canRun("reload"),c="reload"===a.busy;return{commands:e.useMemo(()=>Tt({count:s.count,label:s.label,busy:s.busy},l,c,t),[s.count,s.label,s.busy,l,c,t]),apply:i,reload:o}}(),[w,k]=e.useState(null),N=d.current.Page,S=d.groups.find(e=>e.items.some(e=>e.current));return n.jsxs("div",{className:"rp-shell",children:[n.jsx(Gc,{route:r,lang:t,pickLang:s,ap:a,mac:c,openSearch:l,refresh:d.refresh,spinning:d.spinning,commands:v,apply:y,reload:j,honk:d.honk,backend:d.backend,wordmark:d.wordmark,versionText:d.about.versionText,paletteSections:m,menu:g}),n.jsx(Hc,{route:r,groups:d.groups,busy:d.busy,backend:d.backend,honk:d.honk,navRef:b,navStyle:x}),n.jsx("main",{className:"rp-main",children:n.jsxs("div",{className:"rp-content",children:[n.jsxs("div",{className:"rp-head",children:[n.jsxs("div",{className:"rp-page-heading",children:[n.jsxs("div",{className:"rp-title",children:[n.jsx("h1",{className:"rp-h1",children:d.current.title}),d.current.hint&&n.jsx("span",{className:"rp-hint",children:d.current.hint})]}),n.jsx("div",{ref:k,className:"rp-page-actions"})]}),S&&n.jsx(Wc,{hub:S},S.id)]}),n.jsx(_,{error:d.error,onRetry:d.refresh}),n.jsx(Kc,{}),n.jsx(Os,{value:w,children:n.jsx(It,{value:d.current.skeleton,children:n.jsx(Ce.Provider,{value:h,children:"loading"===d.content.kind?n.jsx(We,{}):"unavailable"===d.content.kind?n.jsxs(xe,{children:[u("shell.notOffered"),n.jsx(M,{onPress:()=>o("activity"),children:u("shell.toActivity")})]}):n.jsx(p,{children:n.jsx(e.Suspense,{fallback:n.jsx(We,{}),children:n.jsx(N,{go:o,query:i})})},d.current.id)})})})]})}),n.jsx(Vc,{groups:d.groups})]})}const Qc=Object.freeze(Object.defineProperty({__proto__:null,Frame:function(e){const{view:t}=e;return n.jsxs(Pt.Provider,{value:t.about,children:[n.jsx(Yc,{...e}),n.jsx(jc,{go:e.go,openSearch:e.openSearch,refresh:t.refresh,mac:e.mac,entries:t.shortcuts,paths:t.shortcutPaths})]})}},Symbol.toStringTag,{value:"Module"})),Zc=16,ed={ArrowLeft:[-16,0],ArrowRight:[Zc,0],ArrowUp:[0,-16],ArrowDown:[0,Zc]},td=[{inline:"start",block:"start"},{inline:"end",block:"start"},{inline:"start",block:"end"},{inline:"end",block:"end"},{block:"start"},{block:"end"},{inline:"start"},{inline:"end"}];function nd(t,n,s){const[a,r]=e.useState(null),i=e.useRef(null),o=e=>{i.current=e,r(e),document.documentElement.toggleAttribute("data-panel-gesture",null!==e)};e.useEffect(()=>()=>document.documentElement.removeAttribute("data-panel-gesture"),[]);const{moveProps:l}=Yn({onMoveStart:()=>o(t()),onMove:({deltaX:e,deltaY:t})=>{i.current&&o(n(i.current,e,t))},onMoveEnd:()=>{i.current&&(s(i.current),o(null))}});return{live:a,props:{...l,onKeyDown:e=>{const a=ed[e.key];a&&(e.preventDefault(),s(n(t(),...a)))}}}}function sd({edge:e,label:t,grip:s,...a}){return n.jsx("button",{type:"button",...a,className:s?"rp-panel-resize rp-grip":"rp-panel-resize","data-inline":e.inline,"data-block":e.block,...t?{"aria-label":t}:{tabIndex:-1,"aria-hidden":!0}})}const ad=(e,{x:t,y:n})=>{const s=e?.getBoundingClientRect();return!!s&&t>=s.left&&t<=s.right&&n>=s.top&&n<=s.bottom},rd=e=>[...e?.querySelectorAll('[aria-expanded="true"][aria-controls]')??[]],id=(e,t)=>!!t&&(!!e?.contains(t)||rd(e).some(e=>{const n=document.getElementById(e.getAttribute("aria-controls")??"");return!!(n?.closest("[data-trigger]")??n)?.contains(t)})),od=`${Ht}, input:not([type="radio"], [type="checkbox"]), textarea, [role="menu"], [role="listbox"], [aria-expanded="true"]`;function ld(s,a,r,i,o){const l=!!s,c=e.useRef(null),[d,u]=e.useState(!1),[m,h]=e.useState(!1),[p,f]=e.useState(!1),[g,b]=e.useState(!1),[x,v]=e.useState(!1),[y,j]=e.useState(!1),{isFocusVisible:w}=Dt(),k=l&&!g&&(d||m&&w||p||x||!a||!!s?.keepOut),[N,M]=e.useState(k);N!==k&&(M(k),j(!k&&!g)),e.useEffect(()=>{if(!y)return;const e=setTimeout(()=>j(!1),400);return()=>clearTimeout(e)},[y]);const _=k||y&&!g,[S,C]=e.useState(null);e.useEffect(()=>{const e=o.current;if(!l||!e)return;const t=()=>v(rd(e).length>0),n=new MutationObserver(t);return n.observe(e,{subtree:!0,attributes:!0,attributeFilter:["aria-expanded"]}),t(),()=>n.disconnect()},[l,o]);const E=e.useRef(null),L=e.useRef(!1),z=e.useEffectEvent(()=>{const e=E.current,t=!!e&&(ad(o.current,e)||ad(c.current,e));t&&!L.current&&b(!1),L.current=t,u(t)});e.useLayoutEffect(()=>{const[e,t]=[o.current,c.current];if(!(l&&a&&e&&t))return;const n=()=>{const e=i();if(!e)return;const n={width:document.documentElement.clientWidth,height:document.documentElement.clientHeight},s=function(e,t){return[["right",t.width-e.left-e.width],["left",e.left],["bottom",t.height-e.top-e.height],["top",e.top]].reduce((e,t)=>t[1]<e[1]?t:e)[0]}(e,n),a={edge:s,...oa(e,n,s,"left"===s||"right"===s?t.offsetHeight:t.offsetWidth)};C(e=>JSON.stringify(e)===JSON.stringify(a)?e:a),z()};n();const s=new ResizeObserver(n);return s.observe(e),s.observe(t),()=>s.disconnect()},[l,a,r,i,o]),e.useLayoutEffect(()=>z(),[S]),e.useEffect(()=>{if(!l)return;const e=e=>{"touch"!==e.pointerType&&(E.current={x:e.clientX,y:e.clientY},z())},t=()=>{E.current=null,z()};return addEventListener("pointermove",e),document.documentElement.addEventListener("pointerleave",t),()=>{removeEventListener("pointermove",e),document.documentElement.removeEventListener("pointerleave",t)}},[l]),e.useEffect(()=>{if(!p)return;const e=e=>{const t=e.target;id(o.current,t)||c.current?.contains(t)||f(!1)};return addEventListener("pointerdown",e,!0),()=>removeEventListener("pointerdown",e,!0)},[p,o]);const R=e.useRef(""),O=e.useRef(!1);if(!s)return{handle:null,panelProps:{},frameProps:{}};const P=()=>{b(!1),f(!0)},A=()=>{t.flushSync(P),o.current?.querySelector(".rp-panel-move")?.focus()};return{handle:n.jsx("button",{ref:c,type:"button",className:"rp-edge-handle","data-edge":S?.edge,"data-out":_||void 0,"aria-label":s.label,style:S?{"--rp-edge-at":`${S.at}px`}:void 0,onFocus:e=>!O.current&&e.currentTarget.matches(":focus-visible")&&A(),onPointerDown:e=>R.current=e.pointerType,onClick:()=>{"touch"===R.current?P():A(),R.current=""},children:s.handle}),panelProps:{"data-edge":S?.edge,"data-tucked":_||!S?void 0:"",style:S&&{"--rp-edge-shift":`${S.shift.x}px ${S.shift.y}px`}},frameProps:{onFocus:()=>h(!0),onBlur:e=>{const t=e.relatedTarget;e.currentTarget.contains(t)||id(o.current,t)||(h(!1),b(!1),t&&f(!1))},onKeyDown:e=>{const n=e.target;var a;"Escape"!==e.key||!_||s.keepOut||n.closest(od)||(a=n,a.getAttribute("aria-describedby")?.split(" ").some(e=>"tooltip"===document.getElementById(e)?.getAttribute("role")))||(t.flushSync(()=>{b(!0),f(!1),u(!1)}),O.current=!0,c.current?.focus(),O.current=!1)}}}}function cd({label:t,resizeLabel:s,moveLabel:a,movedText:r,size:i,offset:o,onResize:l,onMove:c,header:d,collapsed:u=!1,locked:m=!1,children:h,dockTarget:p,onDock:f,edge:g}){const b="rtl"===qt().direction,x=e.useRef(null),v=e.useRef(null),[y,j]=e.useState(0),w=e=>b?e:-e,k=()=>x.current?.getBoundingClientRect()??{width:innerWidth-32,height:innerHeight,left:0,right:innerWidth,top:0,bottom:innerHeight},N=e.useCallback(()=>function(e,t){if(!e||!t)return null;const n=e.getBoundingClientRect(),[s,a,r,i]=[n.left+t.offsetLeft,n.top+t.offsetTop,t.offsetWidth,t.offsetHeight];return{left:s,top:a,width:r,height:i,right:s+r,bottom:a+i}}(x.current,v.current),[]),M=()=>N()??{width:i?.width??aa,height:sa.height,left:0,right:0,top:0,bottom:0},_=()=>{const[e,t]=[k(),M()],n=b?t.left-e.left:e.right-t.right;return o?.top?{x:n,y:t.top-e.top,top:!0}:{x:n,y:e.bottom-t.bottom}},S=e.useRef(td[0]),C=nd(()=>{const e=M(),t=v.current?.querySelector(".rp-widget-body"),n=e.height+(t?t.scrollHeight-t.clientHeight:0);return{size:{width:e.width,height:e.height},offset:_(),tallest:n,moved:0}},(e,t,n)=>{const s=e.moved+Math.abs(n);return{...ia(e,S.current,-w(t),n,k(),e.tallest,s),tallest:e.tallest,moved:s}},e=>l(e.size,e.offset)),E=e.useRef(null),L=(e=p?.())=>!!E.current&&ad(e??null,E.current),z=nd(_,(e,t,n)=>{E.current&&(E.current={x:E.current.x+t,y:E.current.y+n});const s=p?.();s?.toggleAttribute("data-dock-armed",!!E.current);const a=L(s);s?.toggleAttribute("data-dock-target",a),v.current?.toggleAttribute("data-docking",a);const r={...e,x:e.x+w(t),y:e.top?e.y+n:e.y-n};return na(r,k(),M())},e=>{const t=p?.(),n=L(t);if(t?.removeAttribute("data-dock-armed"),t?.removeAttribute("data-dock-target"),v.current?.removeAttribute("data-docking"),E.current=null,n&&f)return f();c(function({x:e,y:t,top:n},s,a){const r=n?t:s-a-t;return r+a/2<s/2?{x:e,y:Math.max(0,Math.round(r)),top:!0}:{x:e,y:Math.max(0,Math.round(s-a-r))}}(e,k().height,M().height)),j(e=>e+1)});!function(){const[,t]=e.useReducer(e=>e+1,0);e.useEffect(()=>(addEventListener("resize",t),()=>removeEventListener("resize",t)),[])}();const R=ld(g,!z.live&&!C.live,g?[o?.x,o?.y,o?.top,i?.width,i?.height,u,innerWidth,innerHeight].join():"",N,v),O=e=>{e.target.closest('button:not(.rp-panel-move), a, input, [role="button"]')||(E.current={x:e.clientX,y:e.clientY},z.props.onPointerDown?.(e))},P=C.live?.size??i,A=C.live?.offset??z.live??(o&&na(o,{width:innerWidth-32,height:innerHeight},{width:i?.width??aa,height:0}));return n.jsxs("div",{ref:x,className:"rp-floating-frame","data-anchor":A?.top?"top":void 0,style:A&&{"--rp-panel-x":`${A.x}px`,"--rp-panel-y":`${A.y}px`},...R.frameProps,children:[R.handle,n.jsxs("section",{ref:v,className:"rp-floating-panel","aria-label":t,"data-collapsed":u||void 0,...R.panelProps,style:{...R.panelProps.style,"--rp-panel-width":`${P?.width??aa}px`,...P&&!u&&{"--rp-panel-height":`${P.height}px`}},children:[!u&&!m&&td.map((e,t)=>n.jsx(sd,{edge:e,label:t?void 0:s,...C.props,onPointerDown:t=>{S.current=e,C.props.onPointerDown?.(t)},onKeyDown:t=>{S.current=e,C.props.onKeyDown(t)}},t)),n.jsxs("div",{className:"rp-panel-head",onPointerDown:m?void 0:O,children:[!m&&n.jsx("button",{type:"button",...z.props,onPointerDown:O,className:"rp-panel-move","aria-label":a}),d]}),h,n.jsx(Be,{children:n.jsx("span",{role:"status",children:y>0&&n.jsx("span",{children:r},y)})})]})]})}function dd({children:t,label:s,kind:a="panel"}){const r=e.useRef(null),[i,o]=e.useState(!1);return e.useLayoutEffect(()=>{const e=r.current;if(!e)return;const t=()=>{const t=e.offsetWidth-e.clientWidth+"px";e.style.getPropertyValue("--rp-scrollbar-gutter")!==t&&e.style.setProperty("--rp-scrollbar-gutter",t),o(e.scrollHeight>e.clientHeight+e.scrollTop+1||e.scrollWidth>e.clientWidth+Math.abs(e.scrollLeft)+1)};let n=0;const s=()=>{n||=requestAnimationFrame(()=>{n=0,t()})},i=new ResizeObserver(s);i.observe(e),e.firstElementChild&&i.observe(e.firstElementChild);const l=new MutationObserver(()=>{s();const t=e.querySelector(".rp-sortable-row[data-selected]");if("canvas"!==a||!t)return;const n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=Number.parseFloat(getComputedStyle(e).scrollPaddingBlockStart)||0;r.top<n.top+i?e.scrollTop+=r.top-n.top-i:r.bottom>n.bottom-i&&(e.scrollTop+=r.bottom-n.bottom+i)});return l.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-selected"]}),e.addEventListener("scroll",s),t(),()=>{cancelAnimationFrame(n),i.disconnect(),l.disconnect(),e.removeEventListener("scroll",s)}},[a]),n.jsx("section",{className:"rp-widget-panel","data-kind":a,"data-more":i||void 0,children:n.jsx("div",{ref:r,className:"rp-widget-body rp-overlay-scroll"+("gallery"===a?" rp-widget-gallery-list":""),tabIndex:0,role:"region","aria-label":s,children:n.jsx("div",{className:"rp-widget-body-content",children:t})})})}function ud({label:t,hideLabel:s,children:a}){const r=e.useContext(Ft);return n.jsxs("section",{className:"rp-widget","aria-label":t,children:[!s&&r&&n.jsx("h3",{className:"rp-widget-label rp-kv-label",children:t}),a]})}function md({label:e,children:t}){return n.jsxs("div",{className:"rp-widget-row",children:[n.jsx("span",{className:"rp-kv-label",children:e}),t]})}function hd({backend:e,actions:t,summary:s}){return n.jsxs("div",{className:"rp-widget-header",children:[e&&n.jsx("div",{className:"rp-widget-backend",children:e}),s,t&&n.jsx("div",{className:"rp-widget-actions",children:t})]})}function pd({rates:e,reserve:t}){return n.jsx("div",{className:"rp-widget-speed","data-reserve":t,children:e.map(e=>n.jsxs("span",{children:[n.jsx("span",{className:"rp-widget-speed-icon",style:{color:e.color},children:e.icon}),n.jsxs(Be,{children:[e.label," "]}),n.jsx("span",{className:"rp-widget-speed-value",children:e.value})]},e.label))})}function fd({panelWidth:t,onPanelWidth:s,resizeLabel:a,header:r,gallery:i,canvas:o,inspector:l,galleryLabel:c,canvasLabel:d,inspectorLabel:u}){const m=e.useRef(null),h=e.useRef(null),[p,f]=e.useState(1),[g,b]=e.useState(!1),x="rtl"===qt().direction,v=e=>ea({width:e,height:sa.height}).width,y=nd(()=>({width:t,scale:p}),(e,t)=>({...e,width:v(e.width+(x?-t:t)/e.scale)}),e=>s?.(e.width)),j=y.live?.width??t;return e.useLayoutEffect(()=>{const e=m.current,t=h.current;if(!e||!t)return;const n=()=>{const n=Number.parseFloat(getComputedStyle(e.firstElementChild).columnGap);b(e.clientWidth>=j+320+240+2*n);const s=getComputedStyle(t),a=t.clientWidth-Number.parseFloat(s.paddingLeft)-Number.parseFloat(s.paddingRight);f(Math.min(1,a/j))},s=new ResizeObserver(n);return s.observe(e),s.observe(t),n(),()=>s.disconnect()},[j]),n.jsx("div",{ref:m,className:"rp-widget-editor",style:{"--rp-panel-width":`${j}px`},children:n.jsxs("div",{className:"rp-widget-editor-grid","data-three-columns":g||void 0,children:[n.jsxs("section",{className:"rp-widget-gallery",children:[n.jsx("h3",{className:"rp-h3",children:c}),n.jsx(dd,{label:c,kind:"gallery",children:i})]}),n.jsxs("section",{className:"rp-widget-canvas",children:[n.jsx("h3",{className:"rp-h3",children:d}),n.jsx("div",{ref:h,className:"rp-widget-preview-space",children:n.jsxs("div",{className:"rp-floating-panel rp-widget-preview",style:{zoom:p,"--rp-preview-scale":p},children:[n.jsx("div",{className:"rp-panel-head",inert:!0,children:r}),n.jsx(dd,{label:d,kind:"canvas",children:o}),s&&n.jsx(sd,{edge:{inline:"end"},label:a,grip:!0,...y.props,onKeyDown:e=>{const n={ArrowLeft:-16,ArrowRight:Zc}[e.key];n&&(e.preventDefault(),s?.(v(t+(x?-n:n))))}})]})})]}),n.jsxs("section",{className:"rp-widget-inspector","aria-label":u,children:[n.jsx("h3",{className:"rp-h3",children:u}),l]})]})})}const gd=Date.now(),bd=[12,18,15,27,22,19,24].map((e,t)=>({time:gd-1e4*(6-t),value:e})),xd=[{id:"sample-ready",event:"stream.ready",data:{instance_id:"sample-engine",observed_at:new Date(gd).toISOString()}}];let vd;const yd=()=>vd??=async function(){const{createMockApi:e}=await g(async()=>{const{createMockApi:e}=await(import("./index-BMEfMmeK.js"));return{createMockApi:e}},__vite__mapDeps([19,3,1,2,4,7,20,21,22]),import.meta.url),t=e({isolated:!0}),[n,s,a,r,i,o,l,c,d,u,m,h,p]=await Promise.all([t.capabilities(),t.runtime(),t.runtimeMemory(),t.runtimeOutbounds(),t.datapath(),t.nodes({limit:8}),t.groups(),t.providers(),t.connections({detail:"full",limit:1e3}),t.dnsLog({limit:24}),t.config(),t.trafficHistory({window_seconds:120}),t.memoryHistory({window_seconds:120})]),f=await t.group(l[0].id);return{capabilities:n,runtime:s,runtimeMemory:a,runtimeOutbounds:r,datapath:i,nodes:o.nodes,groups:l,providers:c,connections:d,dnsLog:u,config:m,trafficHistory:h,memoryHistory:p,group:f,notices:xd}}();function jd(e){if(null==e)return!1;if(Array.isArray(e))return e.length>0;if("object"!=typeof e)return!0;const t=e;for(const n of["records","providers","samples","outbounds"])if(Array.isArray(t[n]))return t[n].length>0;return"tcp"in t&&"udp"in t?jd(t.tcp)||jd(t.udp):Object.keys(t).length>0}function wd(e,t,n){return!!jd(t)&&("capabilities"===e?qa(n,t):"connections"===e&&"ranking"===n?[...t.tcp,...t.udp].some(e=>e.src&&(ye(e.download_bytes)??0n)>0n):"runtimeOutbounds"===e?t.outbounds.some(e=>(ye("outboundErrors"===n?e.errors:e.download_bytes)??0n)>0n):"dnsLog"!==e||"dnsLatency"!==n||t.records.filter(e=>!e.cached&&null!==e.upstream).length>=5)}function kd({children:t,id:s}){const[a,r]=e.useState(),[i,o]=e.useState();e.useEffect(()=>{let e=!0;return yd().then(t=>{e&&r(t)},t=>{e&&o(t instanceof Error?t:new Error(String(t)))}),()=>{e=!1}},[]);const l=e.useMemo(()=>({get:(e,t)=>wd(e,t,s)?void 0:a?.[e]}),[s,a]);if(i)throw i;return n.jsx(Bt,{value:l,children:t})}function Nd(e){return n.jsx(h,{...e,children:n.jsx("path",{fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",d:"M10 3.5v13M4.75 11.5 10 16.75l5.25-5.25"})})}function Md(e){return n.jsx(h,{...e,children:n.jsx("path",{fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",d:"M10 16.5v-13M4.75 8.5 10 3.25l5.25 5.25"})})}const _d=e.createContext(2);function Sd({size:t,scale:s=1,combine:a=!1,widest:r,...i}){const o=f(),l=e.useContext(_d),c=n.jsx(xr,{series:i.series,fmt:e=>null==e?"—":i.fmt(e),widest:r});if("normal"===t)return n.jsxs(n.Fragment,{children:[c,n.jsx(vr,{...i,height:(i.height??150)*s})]});const d=("widget"===t?64:32)*s;if(a)return n.jsxs("figure",{className:"rp-compact-chart","aria-label":i.label,children:[c,n.jsx(vr,{...i,height:d,bare:!0,inset:l})]});const u=function(e,t=1e3){const n=[];for(let s=e.length-1;s>=0;s--)(!n.length||e[n.at(-1)]-e[s]>=t)&&n.push(s);return n.reverse()}(i.timestamps),m=e=>i.series.filter(t=>null!=t.values[u[e]]).sort((e,t)=>e.label<t.label?-1:e.label>t.label?1:0).map(t=>o("ui.valuePair",{label:t.label,value:i.fmt(t.values[u[e]])}));return n.jsxs("figure",{className:"rp-compact-chart","aria-label":i.label,children:[c,i.series.map(e=>n.jsx(yr,{values:u.map(t=>e.values[t]),timestamps:u.map(e=>i.timestamps[e]),color:e.color,inset:l,height:d,fmt:i.fmt,locale:i.locale,lines:m},e.label))]})}function Cd({state:e,rows:t=2,chart:s,children:a}){const r=f();return n.jsxs(n.Fragment,{children:[n.jsx(_,{error:e.error,onRetry:e.refetch}),e.error&&e.data&&n.jsx("span",{className:"rp-label",children:r("widgets.stale")}),e.loading&&!e.data?n.jsxs(u,{children:[Array.from({length:t},(e,t)=>n.jsx(m,{line:"body"},t)),s&&n.jsx(m,{height:s})]}):a]})}function Ed(t){const n=e.useContext(ca),s=e.useContext(Vs);return"dashboard"===n&&(t.width?"2/3"===t.width||"full"===t.width:s)}function Ld({item:e,form:t}){const s=f(),a=Ne[E()],r=Ed(e),i=Me(),o=i.data,l=o?.traffic.rates,c="kv"===t&&r&&"traffic"!==e.id,d=s=>"cpu"===e.id?n.jsx(Od,{scale:jo(e),wide:r,large:"large"===e.size||"wide"===e.size,form:t,runtime:o,statsOnly:s}):n.jsx(Rd,{scale:jo(e),wide:r,large:"large"===e.size||"wide"===e.size,form:t,runtime:o,connections:"connections"===e.id,direction:e.id,combine:"speed"===e.id&&!e.split,statsOnly:s}),u=!((e,t)=>!0===fa[e.id].rate&&"kv"!==t&&"small"!==e.size)(e,t)&&n.jsx(Gn,{compact:!0,row:"small"!==e.size,items:"traffic"===e.id?[[s("ui.download"),se(o?.traffic.bytes.download??null,a)],..."small"===e.size?[]:[[s("ui.upload"),se(o?.traffic.bytes.upload??null,a)]]]:fa[e.id].rate?[[s("upload"===e.id?"ui.upload":"ui.download"),te(("upload"===e.id?l?.upload_bytes_per_second:l?.download_bytes_per_second)??null,a)],..."small"===e.size||"download"===e.id||"upload"===e.id?[]:[[s("ui.upload"),te(l?.upload_bytes_per_second??null,a)]]]:[[s("cpu"===e.id?"act.cpu":"act.active"),"cpu"===e.id?Z(o?.process.cpu_percent,s):null==o?.traffic.connections.total?"—":ee(o.traffic.connections.total,a)]]});return n.jsxs(Cd,{state:i,rows:"small"===e.size?1:2,chart:"kv"!==t&&"small"!==e.size?48:void 0,children:[c?n.jsxs("div",{className:"rp-chart-stats",children:[u,d(!0)]}):u,"traffic"===e.id&&"small"!==e.size&&n.jsx("span",{className:"rp-label rp-counter-since",children:s("act.since",{time:ae(o?.traffic.counter_since??null,a)})}),"traffic"!==e.id&&"kv"!==t&&"small"!==e.size&&d(!1)]})}function zd({form:e,large:t,scale:s,wide:a,statsOnly:r,history:i,...o}){const l=f(),c=Ne[E()];return r?n.jsx(wr,{facts:gi(o.series,o.fmt,l)}):n.jsxs(n.Fragment,{children:[i&&n.jsx(_,{error:i.error,onRetry:i.refetch}),n.jsxs("div",{className:"rp-chart-stats",children:[n.jsx(Sd,{size:"sparkline"===e?t?"widget":"compact":"normal",scale:s,label:l("widgets.lastMinute"),locale:c,...o}),a&&n.jsx(wr,{facts:gi(o.series,o.fmt,l)})]})]})}function Rd({runtime:t,connections:s,direction:a,...r}){const i=f(),o=Ne[E()],l=hr(),{history:c,series:d}=qi(O().data,t,60,{anchored:!!e.useContext(Bt)});return n.jsx(zd,{...r,widest:s?void 0:te(888e6,o),history:c,timestamps:d.timestamps,fmt:e=>s?null==e?"—":ee(e,o):te(null==e?null:1e3*e,o),series:s?[{label:i("act.active"),color:l.cat[2],values:d.connections}]:[..."upload"===a?[]:[{label:i("ui.download"),color:l.cat[0],values:d.down}],..."download"===a?[]:[{label:i("ui.upload"),color:l.cat[3],values:d.up}]]})}function Od({runtime:t,...s}){const a=f(),r=hr(),i=e.useContext(Bt),o=hi(t),l=!!i&&!o.fine.length&&!o.coarse.length,c=e.useMemo(()=>B(o,l?bd:[],60,mi,i?l?bd.at(-1)?.time:o.fine.at(-1)?.time:void 0),[o,i,l]);return n.jsx(zd,{...s,timestamps:c.samples.map(e=>e.time),fmt:e=>Z(e,a),series:[{label:a("act.cpu"),color:r.cat[0],values:c.samples.map(e=>e.value)}]})}function Pd({item:t,form:s}){const a=f(),r=Ne[E()],i=e.useContext(ca),o=Ed(t),l=_e(),c=O().data?.resources.runtime_memory?.metrics??[],d=c.includes("process.rss_bytes"),u=c.includes("cgroup.current_bytes"),m="small"===t.size,h=l.data?.cgroup?.current_bytes??null,p=l.data?.cgroup?.limit_bytes??null,g=(ye(p)??0n)>0n,b="kv"===s&&!m&&g?J(h,p):null,x=m?null:ye(l.data?.cgroup?.events?.oom_kill??null),v="kv"!==s&&!m&&("dashboard"===i||"large"===t.size||"wide"===t.size),y=e=>se(e,r),j=c.includes("cgroup.limit_bytes")&&null===l.data?.cgroup?.limit_bytes,w=n.jsxs(n.Fragment,{children:[n.jsx(Gn,{compact:!0,row:!m,items:[...d?[[a("act.rss"),y(l.data?.process?.rss_bytes??null)]]:[],...!u||null!==b||m&&d?[]:[[a("act.cgroup"),!m&&g?ht(h,p,r,a):y(h)]],...!u||m||g?[]:[[a("ov.f.cgroupLimit"),a(j?"ov.noLimit":"widgets.notReported")]]]}),null!==b&&n.jsx($t,{label:a("act.cgroup"),value:b,valueLabel:ht(h,p,r,a),tone:ut(b)}),!!x&&n.jsx(Ie,{tone:"negative",children:a("ui.valuePair",{label:a("ov.f.oomKill"),value:ee(x,r)})}),!d&&!u&&n.jsx("span",{className:"rp-label",children:a("widgets.unavailable")})]}),k=e=>n.jsx(Ad,{scale:jo(t),wide:o,large:"large"===t.size||"wide"===t.size,form:s,memory:l.data,rss:d,cgroup:u,statsOnly:e});return n.jsxs(Cd,{state:l,chart:v?48:void 0,children:["kv"===s&&o?n.jsxs("div",{className:"rp-chart-stats",children:[n.jsx("div",{className:"rp-col",children:w}),k(!0)]}):w,v&&k(!1)]})}function Ad({memory:t,rss:s,cgroup:a,...r}){const i=f(),o=Ne[E()],l=hr(),c=Di(O().data,t,{windowSeconds:60,anchored:!!e.useContext(Bt)});return n.jsx(zd,{...r,history:{error:c.error,refetch:c.retry},timestamps:c.timestamps,fmt:e=>se(e??null,o),series:[...s?[{label:i("act.rss"),color:l.cat[0],values:c.rss}]:[],...a?[{label:i("act.cgroup"),color:l.cat[3],values:c.cgroup}]:[]]})}function Id({item:t,rows:s,bytes:a=!1,empty:r}){const i=f(),o=Ne[E()],l=hr(),c=e=>a?se(e,o):ee(e,o),{total:d,rows:u}=function(e,t){const n=(e=e.filter(e=>e.count>0)).reduce((e,t)=>e+t.count,0);return{total:n,rows:e.map((e,s)=>({...e,pct:e.percent??e.count/n*100,color:e.color??t[s%t.length]}))}}(s,l.cat),m=u.map(e=>({...e,text:c(e.count)})),h={legendLimit:t.rows??la(t.size),label:i(fa[t.id].label)},p="dashboard"===e.useContext(ca)&&!fa[t.id].rows;if(!d)return n.jsx(xe,{children:r});if("donut"===t.form)return n.jsx(jr,{...h,total:c(d),rows:m.map(e=>({...e,value:Math.round(e.pct)}))});if("waffle"===t.form)return n.jsx(Vr,{...h,shares:m.map(e=>({...e,id:e.name,label:e.name}))});const g=m.slice(0,p?void 0:t.rows??la(t.size));return n.jsx("div",{className:"rp-list rp-columns",style:ve(g.length),children:g.map(e=>"ranked"===t.form?n.jsx(Te,{label:e.name,value:e.text,pct:e.pct,color:e.color},e.name):n.jsx(Gn,{compact:!0,row:"small"!==t.size,items:[[e.name,e.text]]},e.name))})}function Td({item:t}){const s=f(),a=$n(void 0,!0,!1,Ee.summary),r=e.useMemo(()=>bi(a.data,t.by??"dev",t.rows??5).map(e=>({name:e.name,count:Number(e.download??0n),percent:e.percent??void 0})),[a.data,t.by,t.rows]);return n.jsxs(Cd,{state:a,children:[n.jsx(Id,{item:t,rows:r,bytes:!0,empty:s("ui.empty")}),a.data?.truncated&&n.jsx("span",{className:"rp-label",children:s("widgets.sampled")})]})}function qd({item:t}){const s=f(),a=Ne[E()],r=Ae(!0),i=hr(),o=e.useMemo(()=>ne(r.data),[r.data]),l="outboundErrors"===t.id,c=o.rows.map((e,t)=>({name:e.name,count:Number((l?e.errors:e.bytes)??0n),color:_i(e,t,i)}));return l&&c.sort((e,t)=>t.count-e.count),n.jsxs(Cd,{state:r,children:[n.jsx(Id,{item:t,rows:c,bytes:!l,empty:s(l?"widgets.noFailures":"ui.empty")}),"small"!==t.size&&n.jsx("span",{className:"rp-label rp-counter-since",children:s("act.since",{time:ae(r.data?.counter_since??null,a)})})]})}function Dd({item:t}){const s=f(),a=$n(void 0,!0,!1,Ee.summary),r=!0===O().data?.resources.runtime_outbounds.available,o=Ae("connectionOutbounds"===t.id&&r),l=hr(),c=e.useMemo(()=>{const e=new Map(ne(o.data).rows.map((e,t)=>[e.name,_i(e,t,l)])),n=Io(U(a.data).map(e=>"connectionOutbounds"===t.id?e.outbound:e.network),6);return[...n.top.map(n=>({name:"connectionOutbounds"===t.id?i(n.key,s):n.key??"—",count:n.count,color:"connectionOutbounds"===t.id?e.get(n.key??""):void 0})),...n.rest?[{name:s("dashboard.other"),count:n.rest}]:[]]},[a.data,o.data,l,t.id,s]);return n.jsxs(Cd,{state:a,children:[n.jsx(Id,{item:t,rows:c,empty:s("dashboard.noConnections")}),a.data?.truncated&&n.jsx("span",{className:"rp-label",children:s("widgets.sampled")})]})}function Hd({item:t}){const s=f(),a=Ne[E()],r=hr(),i=e.useContext(ca),o=Qn({}),l=e.useMemo(()=>ol(o.data?.records??[],a),[o.data,a]),c=[[s("dns.chart.median"),ue(l.typical,s)],[s("dns.chart.p95"),ue(l.slowest,s)]],d=e=>({id:e.id,value:e.value,color:r.cat[2],lines:[e.name,ue(e.value,s)]}),u="panel"===i?"large"===t.size:"tall"===t.height;return l.samples.length<5?n.jsx(Cd,{state:o,children:n.jsx("span",{className:"rp-label",children:s("dashboard.dnsSample",{n:l.total})})}):n.jsxs(Cd,{state:o,children:[n.jsx(Gn,{compact:!0,row:"small"!==t.size,items:c.slice(0,"small"===t.size?1:2)}),"dots"===t.form&&"small"!==t.size&&n.jsx($r,{label:s("widgets.dnsLatency"),points:l.samples.map(d),rows:u?l.upstreams.map(e=>({id:e.upstream,label:e.upstream,detail:s("dns.chart.upstream",{n:e.samples.length,median:ue(e.median,s)}),points:e.samples.map(d),mark:e.median})):[],fmt:e=>ue(e,s),maxHeight:"panel"===i?96:"short"===t.height?120:void 0})]})}function Fd({item:t}){const s=f(),a=Ne[E()],r=Qn({}),i=e.useMemo(()=>ol(r.data?.records??[],a),[r.data,a]);return n.jsxs(Cd,{state:r,children:[n.jsx(Id,{item:t,rows:rl.map(e=>({name:s(`dns.outcome.${e}`),count:i.counts[e]})),empty:s("dashboard.noQueries")}),i.total>0&&n.jsx("span",{className:"rp-label",children:s("dashboard.dnsSample",{n:i.total})})]})}function Bd({targetOnly:e,fill:t=!1}){const s=f(),a=di();return n.jsxs(n.Fragment,{children:[n.jsx(_,{error:a.error,onRetry:a.retry}),!e&&n.jsx(ei,{model:a,fill:t}),(e||"global"===a.mode)&&n.jsx(md,{label:s("act.global"),children:n.jsxs("span",{className:e?"rp-cluster rp-global-controls":"rp-cluster",children:[n.jsx(kn,{quiet:!0,label:s("act.global"),value:a.target,onChange:a.pickTarget,isDisabled:a.busy||!a.writable,items:a.targets,searchLabel:s("ui.filterOutbounds"),children:n.jsx(zn,{labels:a.targets.map(e=>e.label),children:a.targetText})}),e&&n.jsx(Zr,{model:a})]})}),a.incomplete&&n.jsx("span",{className:"rp-label",children:s("act.globalMissing")})]})}function $d({item:e,onChange:t}){const s=f(),r=In(),i=((e,t)=>e?.find(e=>e.id===t)??e?.find(e=>"selector"===e.policy.kind))(r.data,e.group);return n.jsx(Cd,{state:r,children:i?n.jsxs(n.Fragment,{children:[n.jsx(kn,{quiet:!0,label:s("ui.group"),value:i.id,items:(r.data??[]).map(e=>({id:e.id,label:e.name})),onChange:n=>t?.({...e,group:n}),searchLabel:s("ui.filterGroups"),children:i.name}),n.jsx(Vd,{id:i.id,refresh:r.refetch})]}):n.jsxs(xe,{children:[s("widgets.noManualGroup"),n.jsx(wn,{appearance:"button",small:!0,href:a("policies",{new:"1"}),children:s("group.newGroup")})]})})}function Vd({id:e,refresh:t}){const s=f(),a=Zn(e,t,()=>{}),r=a.data,i=a.network,o=r?.runtime.selection,l="both"===i?o?.tcp?.member_id===o?.udp?.member_id?o?.tcp?.member_id:"":o?.[i]?.member_id,c=!!r&&(r.capabilities.can_select||r.capabilities.can_override),d="both"===i?[o?.tcp,o?.udp].some(e=>"override"===e?.source):"override"===o?.[i]?.source,u=e=>r?.members.find(t=>t.id===e)?.name??"—";return n.jsxs(Cd,{state:a,children:[n.jsx(_,{error:a.actionError}),n.jsx(Rn,{label:s("widgets.network"),value:i,onChange:e=>a.setNetwork(e),isDisabled:!!a.busy,items:[["both",s("policy.both")],["tcp","TCP"],["udp","UDP"]]}),""===l&&n.jsx(Gn,{compact:!0,row:!0,items:[["TCP",u(o?.tcp?.member_id)],["UDP",u(o?.udp?.member_id)]]}),n.jsx(md,{label:s("widgets.member"),children:n.jsx(kn,{quiet:!0,searchLabel:s("ui.filterMembers"),label:s("widgets.member"),value:l??"",isDisabled:!!a.busy||!c,items:(r?.members??[]).map(e=>({id:e.id,label:e.name})),onChange:e=>Cl(a.select,e,l,r?.name,u,s),children:u(l)})}),r?.capabilities.can_override&&d&&n.jsx(M,{small:!0,isPending:"selection"===a.busy,onPress:()=>{a.clearOverride()},children:s("policy.releaseOverride")}),!c&&n.jsx("span",{className:"rp-label",children:s("widgets.readOnly")})]})}function Wd({item:e,onChange:t}){const s=f(),a=Gi(void 0,{chosen:e.group??"",setChosen:n=>t?.({...e,group:n})});return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"rp-cluster",children:[n.jsx(Xi,{label:s("policy.pickGroups"),model:a}),n.jsx(De,{title:s("act.latency"),text:s("act.groupPickHelp")})]}),n.jsx(_,{error:a.error,onRetry:a.retry}),n.jsx(Gn,{compact:!0,row:"small"!==e.size,items:[[a.name||"—",a.status??a.latency]]})]})}function Ud({item:t}){const s=f(),a=e.useContext(ca),r=Ne[E()],i=O().data?.resources,o=Bn(!0===i?.nodes.available),l=In(!0===i?.groups.available),c=e.useMemo(()=>zl(o.data??[],l.data,"group",r).filter(e=>!t.group||e.id===`group:${t.group}`),[o.data,l.data,t.group,r]),{measured:d,missing:u}=El(c),m=Al(c),h=e.useContext(Bt)&&"panel"===a?3:t.rows??la(t.size,[3,6,12]);return n.jsx(Cd,{state:{...o,error:o.error??l.error,refetch:()=>(o.refetch(),l.refetch())},rows:h,children:c.length?"dots"===t.form&&"small"!==t.size?n.jsx(Gr,{label:s("ui.nodeLatency"),summary:n.jsx(Gn,{compact:!0,row:!0,items:[[s("nodes.latency.lowest"),ue(d[0]?.latest??null,s)],[s("nodes.latency.highest"),ue(d.at(-1)?.latest??null,s)]]}),max:Il(c),fmt:e=>ue(e,s),limit:h,showAll:e=>s("nodes.latency.showAll",{n:e}),legend:m.moving||m.avg10?[{kind:"dot",label:s("nodes.latency.latest")},{kind:"ring",label:s("nodes.latency.average")},{kind:"line",label:s("nodes.latency.range")}]:[],groups:[{id:"nodes",label:t.group?c[0]?.label??s("nodes.latency.noGroup"):s("dashboard.allGroups"),rows:d.map(e=>Ll(e,s)),notes:u.map(e=>s("ui.valuePair",{label:e.name,value:s("unavailable"===e.state?"ui.unavailable":"ui.unknown")}))}]}):n.jsxs("div",{className:"rp-list",children:[d.slice(0,h).map(e=>n.jsx(Gn,{compact:!0,row:"small"!==t.size,items:[[e.name,ue(e.latest,s)]]},e.id)),u.slice(0,Math.max(0,h-d.length)).map(e=>n.jsx(Gn,{compact:!0,row:"small"!==t.size,items:[[e.name,s("unavailable"===e.state?"ui.unavailable":"ui.unknown")]]},e.id))]}):n.jsx(xe,{children:s("dashboard.noNodes")})})}function Gd({item:e}){const t=f(),s=Ne[E()],a=Bn(!0===O().data?.resources.nodes.available),{measured:r,missing:i,down:o}=El(zl(a.data??[],void 0,"protocol",s)),l=t("ui.fraction",{part:r.length,whole:r.length+i.length}),c=(e,t)=>n.jsx(R,{tone:e?t:"muted",children:ee(e,s)});return n.jsx(Cd,{state:a,children:a.data?.length?"small"===e.size?n.jsx(Gn,{compact:!0,items:[[t("ov.available"),l]]}):n.jsx(Gn,{compact:!0,row:!0,items:[[t("ov.available"),n.jsx(R,{tone:r.length?"ok":"muted",children:l})],[t("ui.unavailable"),c(o,"err")],[t("ui.unknown"),c(i.length-o,"neutral")]]}):n.jsx(xe,{children:t("dashboard.noNodes")})})}function Kd({item:e}){const t=f(),s=Ne[E()],a=Fn(),r="providerBudget"===e.id,i=(a.data?.providers??[]).filter(e=>!r||"subscription"===e.kind).slice(0,e.rows);return n.jsx(Cd,{state:a,children:i.length?n.jsx("div",{className:"rp-list rp-columns",style:ve(i.length),children:i.map(a=>{const i=uc(a,void 0,s,t),o=i.quota&&n.jsx($t,{label:r?i.name:t("nodes.usage"),value:i.quota.pct,valueLabel:i.usage,tone:i.quota.tone}),l=t=>n.jsx(Gn,{compact:!0,row:"small"!==e.size,items:[[i.name,t]]});return n.jsx("div",{className:"rp-entry",children:r?n.jsxs(n.Fragment,{children:[o??l(i.usage),a.expires_at&&n.jsx("span",{className:"rp-note",children:t("ui.valuePair",{label:t("nodes.expires"),value:i.expires})})]}):n.jsxs(n.Fragment,{children:[l(i.status??"—"),o]})},i.id)})}):n.jsx(xe,{children:t(r?"act.noSubscriptions":"dashboard.noSources")})})}function Jd({item:e}){const t=f(),s=O().data?.resources,a=In(!0===s?.groups.available),r=Bn(!0===s?.nodes.available),i=Mi(a.data??[],r.data??[],"",t).options.filter(t=>!e.group||t.id===e.group).slice(0,e.rows??la(e.size));return n.jsx(Cd,{state:{...a,error:a.error??r.error,refetch:()=>(a.refetch(),r.refetch())},children:i.length?n.jsx("div",{className:"rp-list rp-columns",style:ve(i.length),children:i.map(s=>{const a=Ni(s.node?[s.node]:[],"",t);return n.jsx(Gn,{compact:!0,row:"small"!==e.size,items:[[s.label,t("ui.valuePair",{label:s.node?.name??"—",value:a.status??a.latency})]]},s.id)})}):n.jsx(xe,{children:t("dashboard.noGroups")})})}function Xd({reserveWidth:e=!1}){const t=f(),s=Ne[E()],a=hr(),r=O(),i=Me(!0===r.data?.resources.runtime.available),o=i.data?.traffic.rates;return n.jsx(pd,{reserve:e?Vt(999.9,s,"unit.megabytePerSecond",1):void 0,rates:[{icon:n.jsx(Md,{}),label:t("ui.upload"),value:te(o?.upload_bytes_per_second??null,s),color:a.cat[3]},{icon:n.jsx(Nd,{}),label:t("ui.download"),value:te(o?.download_bytes_per_second??null,s),color:a.cat[0]}]})}function Yd({item:t,onChange:s}){const a=e.useContext(ca),r=Ca(t,a);switch((t={...t,form:r}).id){case"download":case"upload":case"history":case"speed":case"traffic":case"connections":case"cpu":return n.jsx(Ld,{item:t,form:r});case"memory":return n.jsx(Pd,{item:t,form:r});case"ranking":return n.jsx(Td,{item:t});case"outbounds":case"outboundErrors":return n.jsx(qd,{item:t});case"global":case"mode":return n.jsx(Bd,{targetOnly:"global"===t.id,fill:"panel"===a});case"latency":return n.jsx(Wd,{item:t,onChange:s});case"nodeLatency":return n.jsx(Ud,{item:t});case"nodeAvailability":return n.jsx(Gd,{item:t});case"sourceHealth":case"providerBudget":return n.jsx(Kd,{item:t});case"policyGroups":return n.jsx(Jd,{item:t});case"connectionOutbounds":case"connectionNetworks":return n.jsx(Dd,{item:t});case"dnsAnswers":return n.jsx(Fd,{item:t});case"dnsLatency":return n.jsx(Hd,{item:t});case"group":return n.jsx($d,{item:t,onChange:s});case"status":return n.jsx(Qd,{item:t});case"notices":return n.jsx(Zd,{item:t});case"divider":return n.jsx(Jn,{orientation:"horizontal"});default:return null}}function Qd({item:e}){const t=f(),s=Ne[E()],a=Me(),r=Se(!0===O().data?.resources.datapath?.available),i=vi(a.data?.lifecycle.state,r.data?.state,"—",t);return n.jsxs(Cd,{state:a,children:[n.jsx(_,{error:r.error,onRetry:r.refetch}),n.jsx(R,{tone:i.tone,children:i.text}),n.jsx(Gn,{compact:!0,row:"small"!==e.size,items:[[t("ov.uptime"),lt(a.data?.lifecycle.uptime_seconds??null,s)]]})]})}function Zd({item:e}){const t=me(),s=f(),r=Hn(ge),i=r.records,o=wi(i,s).rows.slice(0,la(e.size));return n.jsxs(n.Fragment,{children:[n.jsx(_,{error:r.error,onRetry:()=>fe(t)}),o.length?n.jsxs(n.Fragment,{children:[n.jsx(Ei,{rows:o,label:s("act.issues")}),n.jsx(wn,{appearance:"link",href:a("events"),children:s("widgets.noticeCount",{n:i.length})})]}):n.jsx("span",{className:"rp-label",children:s("widgets.noNotices")})]})}function eu({item:t,preview:s=!1,sample:a=!1,onChange:r}){const i=e.useContext(c),[o,l]=qe(void 0,0);return n.jsx("div",{ref:o,className:"rp-module-content","data-size":t.size,inert:s||i||a,children:n.jsx(c,{value:s||i||!l,children:a?n.jsx(kd,{id:t.id,children:n.jsx(tu,{item:t,sample:!0})}):n.jsx(tu,{item:t,onChange:r})})})}function tu({item:t,sample:s=!1,onChange:a}){const r=f(),i=e.useContext(ca),o=O().data,l=o?.resources.runtime_memory?.metrics??[],c="memory"===t.id&&1===l.filter(e=>"process.rss_bytes"===e||"cgroup.current_bytes"===e).length;return n.jsx(ud,{label:r(fa[t.id].label),hideLabel:"dashboard"===i||"small"===t.size||c||fa[t.id].untitled||"divider"===t.id&&!s,children:s||qa(t.id,o)?n.jsx(Yd,{item:t,onChange:a}):o?n.jsx("span",{className:"rp-label",children:r("widgets.unavailable")}):n.jsx(u,{children:Array.from({length:t.rows??2},(e,t)=>n.jsx(m,{line:"body"},t))})})}const nu=Object.freeze(Object.defineProperty({__proto__:null,WidgetContent:eu},Symbol.toStringTag,{value:"Module"})),su=e=>"wide"===e?"large":e;function au({children:e}){return n.jsx("div",{className:"rp-widget-grid",children:e})}function ru({size:e,id:t,module:s,children:a}){return n.jsx("div",{className:"rp-widget-cell","data-size":e,"data-widget-id":t,"data-module":s,children:a})}function iu(e){return n.jsxs("svg",{className:"rp-icon",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",...e,children:[n.jsx("path",{d:"M17.5 8V5.5A1.5 1.5 0 0 0 16 4H3.5A1.5 1.5 0 0 0 2 5.5v8A1.5 1.5 0 0 0 3.5 15H7"}),n.jsx("rect",{x:"10",y:"11",width:"8",height:"6",rx:"1.5"})]})}function ou(e){return n.jsx("svg",{className:"rp-icon",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",...e,children:n.jsx("path",{d:"m7 3 6 0-1 5 3 3v2H5v-2l3-3-1-5Zm3 10v5"})})}const lu=e=>document.querySelector(e?".rp-side-dock":".rp-floating-panel");let cu=null;const du=(e,t)=>[{id:"titles",label:t("widgets.showTitles"),checked:!!e.titles,onAction:()=>Rc({titles:!e.titles||void 0})}];function uu(){const e=zc(),t=f();return n.jsxs(dd,{label:t("widgets.title"),children:[n.jsx(Ft,{value:!!e.titles,children:n.jsx(au,{children:e.items.map(e=>n.jsx(ru,{id:wa(e),module:e.id,size:su(e.size),children:n.jsx(eu,{item:e,onChange:e=>Lc(t=>({...t,items:t.items.map(ka(e))}))})},wa(e)))})}),!e.items.length&&n.jsx("span",{className:"rp-label",children:t("widgets.empty")})]})}function mu({backend:e,honk:t,docked:s=!1,dockable:a=!1,onDock:r,preview:i=!1}){const o=f(),l=zc(),c=!i&&l.collapsed;return n.jsx(hd,{backend:s?void 0:t?n.jsx(_c,{backend:e,honk:t,panel:!0}):n.jsx(M,{quiet:!0,icon:!0,label:e.label,children:n.jsx(R,{tone:e.tone,small:!0})}),summary:c?n.jsx(Xd,{reserveWidth:!s}):void 0,actions:n.jsxs(n.Fragment,{children:[n.jsx(es,{quiet:!0,label:o("widgets.panelOptions"),actions:[{id:"edit",label:o("widgets.edit"),onAction:()=>zs.set(!0)},...a&&r&&!s?[{id:"dock",label:o("widgets.dock"),onAction:r}]:[],...s?[]:[{id:"edge",label:o("widgets.edgeHide"),checked:!!l.edge,onAction:()=>Rc({edge:!l.edge||void 0})}],...du(l,o),{id:"hide",label:o("widgets.hide"),onAction:()=>Rc({visible:!1})}]}),s?n.jsx(M,{quiet:!0,icon:!0,className:"rp-widget-undock",label:o("widgets.undock"),onPress:r,children:n.jsx(iu,{})}):n.jsx(M,{quiet:!0,icon:!0,isSelected:l.pinned,label:o(l.pinned?"widgets.unpin":"widgets.pin"),onPress:()=>Rc({pinned:!l.pinned}),children:n.jsx(ou,{})}),n.jsx(M,{quiet:!0,icon:!0,className:"rp-widget-collapse",expanded:!c,label:o(c?"widgets.expand":"widgets.collapse"),onPress:()=>Rc({collapsed:!c}),children:n.jsx(Wt,{})})]})})}const hu=Object.freeze(Object.defineProperty({__proto__:null,PanelHeader:mu,PanelHost:function({route:s,backend:a,honk:r,dockable:i,onDock:o}){const l=zc(),c=f(),d=l.collapsed,u=i&&!!l.docked,m=e.useSyncExternalStore(zs.subscribe,zs.snapshot);e.useLayoutEffect(()=>function(e){const t=cu;cu=null;const n=lu(e);if(!t||!n||performance.now()-t.at>1e3)return;const s=n.getBoundingClientRect();n.style.setProperty("--rp-dock-from",`${t.left-s.left}px ${t.top-s.top}px`),n.setAttribute("data-arriving",""),n.addEventListener("animationend",()=>{n.removeAttribute("data-arriving"),n.style.removeProperty("--rp-dock-from")},{once:!0})}(u),[u]);const h=e=>{(e=>{const t=lu(e)?.getBoundingClientRect();cu=t?{left:t.left,top:t.top,at:performance.now()}:null})(!e),o(e)},p=e.useRef(s);e.useEffect(()=>{p.current===s||l.pinned||u||Rc({collapsed:!0}),p.current=s},[s,l.pinned,u]);const g=e.useRef(null),b=nd(()=>{const e=g.current,t=e?.getBoundingClientRect().height??0,n=e?.querySelector(".rp-widget-body"),s=e?.querySelector(".rp-widget-body-content > * > *"),a=e?.parentElement,r=a?.querySelector(".rp-side-links"),i=t-(n?.clientHeight??0)+(s?.getBoundingClientRect().height??0),o=r?r.clientHeight-r.scrollHeight:0;return{height:t,min:i,max:Math.max(i,t+o,.45*(a?.clientHeight??0))}},(e,t,n)=>({...e,height:Math.min(e.max,Math.max(e.min,e.height-n))}),e=>Rc({dockHeight:Math.round(e.height)})),x=b.live?.height??l.dockHeight,v=n.jsx(mu,{backend:a,honk:r,docked:u,dockable:i,onDock:()=>h(!u)});return u?n.jsxs("section",{ref:g,className:"rp-side-dock","aria-label":c("widgets.title"),"data-sized":!(!x||d)||void 0,style:x?{"--rp-dock-height":`${x}px`}:void 0,children:[n.jsx("div",{className:"rp-dock-edge",children:!d&&n.jsx(sd,{edge:{block:"start"},label:c("widgets.resizePanel"),...b.props})}),v,!d&&n.jsx(_d.Provider,{value:0,children:n.jsx(uu,{})}),n.jsx(_c,{backend:a,honk:r})]}):t.createPortal(n.jsx(cd,{label:a.text,resizeLabel:c("widgets.resizePanel"),moveLabel:c("widgets.movePanel"),movedText:c("widgets.panelMoved"),size:l.size,offset:l.offset,onResize:(e,t)=>Rc({size:e,offset:t}),onMove:e=>Rc({offset:e}),header:v,collapsed:d,locked:l.pinned,dockTarget:()=>document.querySelector(".rp-dock-slot"),onDock:()=>h(!0),edge:l.edge&&!l.pinned?{handle:n.jsx(hd,{backend:n.jsx(R,{tone:a.tone,small:!0}),summary:n.jsx(Xd,{reserveWidth:!0})}),label:c("widgets.title"),keepOut:m}:void 0,children:!d&&n.jsx(uu,{})}),document.body)},PhoneDrawer:function({open:e,onClose:t,backend:s}){const a=f(),r=zc();return n.jsx(Ut,{open:e,title:s.text,icon:n.jsx(R,{tone:s.tone,small:!0}),fit:!0,onClose:t,actions:n.jsx(es,{quiet:!0,label:a("widgets.panelOptions"),actions:[{id:"edit",label:a("widgets.edit"),onAction:()=>zs.set(!0)},...du(r,a)]}),children:e&&n.jsx(uu,{})})}},Symbol.toStringTag,{value:"Module"}));export{To as $,Sl as A,$r as B,Ui as C,ar as D,Zo as E,wr as F,ml as G,Ml as H,xl as I,nl as J,kl as K,pr as L,wl as M,hl as N,sl as O,gl as P,ni as Q,Ao as R,Xr as S,pl as T,rr as U,si as V,Vr as W,_l as X,bl as Y,Cl as Z,ws as _,hr as a,Uo as a$,oi as a0,bs as a1,cs as a2,qo as a3,Ns as a4,Jo as a5,$o as a6,as as a7,os as a8,rs as a9,oc as aA,$l as aB,nc as aC,ec as aD,pc as aE,hc as aF,dc as aG,ds as aH,ms as aI,us as aJ,Ir as aK,Kr as aL,Ss as aM,xc as aN,yc as aO,Rs as aP,hs as aQ,ls as aR,Sr as aS,Dr as aT,_r as aU,Nr as aV,Hr as aW,Cr as aX,kr as aY,Fr as aZ,Ko as a_,Fo as aa,is as ab,_s as ac,zl as ad,Al as ae,El as af,Gr as ag,Ll as ah,Il as ai,Cs as aj,uc as ak,lc as al,Gl as am,mc as an,sc as ao,cc as ap,Bl as aq,Yl as ar,Zl as as,Ql as at,Xl as au,fc as av,tc as aw,ac as ax,rc as ay,ic as az,Vi as b,Or as b0,Fs as b1,Ks as b2,Bs as b3,su as b4,$s as b5,fa as b6,Ma as b7,Ka as b8,Ga as b9,za as bA,ka as bB,Hl as bC,Wl as bD,Vl as bE,Fl as bF,Ro as bG,Qc as bH,Ea as ba,kd as bb,eu as bc,No as bd,Ua as be,ko as bf,Mo as bg,So as bh,Va as bi,pa as bj,wo as bk,Na as bl,_a as bm,Ca as bn,wa as bo,xo as bp,er as bq,Ya as br,Ec as bs,aa as bt,Ra as bu,fd as bv,mu as bw,La as bx,Lc as by,ra as bz,Yr as c,gs as d,vi as e,ps as f,Io as g,fs as h,Qo as i,ks as j,Ai as k,cl as l,ol as m,rl as n,vs as o,zr as p,al as q,Hi as r,Ms as s,js as t,Po as u,Nl as v,dl as w,el as x,xs as y,fl as z};