import"./DsnmJJEf.js";import{o as T}from"./vrwecVo1.js";import{p as q,u as D,e as b,f as p,a as m,b as F,d as w,g as o,s as G,r as E,t as I,k as x,c as k}from"./Dyk1ealw.js";import{d as H,a as J,s as K}from"./DEEYSJdk.js";import{i as h}from"./cYAxD0tk.js";import{e as N,s as O}from"./CDBVw774.js";import{c as Q}from"./Brlxm5ml.js";import{s as V}from"./BGzpdNMV.js";import{a as g,c as W}from"./CVq-Ik9t.js";import{c as r}from"./CtD3ap6u.js";import{i as X}from"./DmLHkASY.js";var Y=k('<span class="absolute -right-1.5 -top-1.5 flex h-4 min-w-4 items-center justify-center rounded-full bg-red-500 px-1 text-[0.625rem] font-bold leading-none text-white"> </span>'),Z=k("<button><!> <!></button>");function ue(U,e){q(e,!0);function P(n){const t=n.replace(/(^|-)([a-z])/g,(c,d,a)=>a.toUpperCase());return X[t]}async function i(){const n=r.forContext(e.context);for(const t of n)if(t.badgeEndpoint)try{const c=t.badgeEndpoint.includes("?")?"&":"?",d=`${t.badgeEndpoint}${c}route=${encodeURIComponent(e.route)}&lang=${encodeURIComponent(e.lang)}&type=${encodeURIComponent(e.context)}`,a=await W.get(d);r.setBadge(t.id,a.count)}catch{}}D(()=>{r.loaded&&e.route&&e.context&&(e.lang,i())}),T(()=>{const n=[g.subscribe("pages:update",()=>i()),g.subscribe("config:update",()=>i()),g.subscribe("plugins:update",()=>i()),g.subscribe("themes:update",()=>i())],t=()=>i();return window.addEventListener("grav:revisions:changed",t),()=>{n.forEach(c=>c()),window.removeEventListener("grav:revisions:changed",t)}});var _=b(),R=p(_);{var j=n=>{var t=b(),c=p(t);N(c,17,()=>r.forContext(e.context),d=>d.id,(d,a)=>{const y=x(()=>P(o(a).icon)),l=x(()=>r.badges[o(a).id]),z=x(()=>r.activePanel===o(a).id);var u=Z(),C=w(u);{var B=s=>{var f=b(),v=p(f);Q(v,()=>o(y),(M,S)=>{S(M,{size:14})}),m(s,f)};h(C,s=>{o(y)&&s(B)})}var L=G(C,2);{var A=s=>{var f=Y(),v=w(f,!0);E(f),I(()=>K(v,o(l)>99?"99+":o(l))),m(s,f)};h(L,s=>{o(l)&&o(l)>0&&s(A)})}E(u),I(()=>{V(u,1,`relative inline-flex h-8 w-8 items-center justify-center rounded-md border transition-colors
				${o(z)?"border-primary bg-primary/10 text-primary":"border-border text-muted-foreground hover:bg-accent hover:text-foreground"}`),O(u,"title",o(a).label)}),J("click",u,()=>r.toggle(o(a).id,{route:e.route,lang:e.lang,type:e.context})),m(d,u)}),m(n,t)};h(R,n=>{r.loaded&&n(j)})}m(U,_),F()}H(["click"]);export{ue as C};
