import{d as $,Y as q,v as E,x as F,y as p,o as f,R as O,c as w,S as x,b as m,Z as y,w as I,a as L,h as N,$ as S,a0 as z,B as t,C as A,D as J,E as g,F as P,G as V,H as D,I as G,J as H,A as K,K as R,M as T,a1 as U,a2 as W,N as Y,L as Z,O as Q}from"./index-CWMhB7z4.js";const ee=$({name:"ShwfedBlockCardBadge",inheritAttrs:!1,__name:"badge",props:{badge:{}},setup(n){const a=n,{locale:C}=q(),k=T(),o=K(void 0);function i(){return R(k)}const b=t(()=>o.value===void 0?Z():Q(o.value)),c=t(()=>U(a.badge.content,C.value)||""),j=t(()=>c.value?W(c.value,g,{...i(),json:b.value}):""),B=t(()=>{const e=a.badge.show;if(!e)return!0;try{return Y(g(e,{...i(),json:b.value}))}catch(r){return console.warn("[shwfed-card-badge] show evaluation failed",r),!0}});async function s(){const e=a.badge.request;if(!e)return;const r=i(),_=A(function*(){const v=yield*J(yield*g(e,r));return P(v)});try{o.value=await V(D(_,G))}catch(v){console.warn("[shwfed-card-badge] fetch failed",v)}}const l=t(()=>!!a.badge.request&&(a.badge.interval??0)>0),M=t(()=>Math.max(1,a.badge.interval??1)*1e3),u=H(),{pause:h,resume:d}=E(()=>{s()},M,{immediate:!1});return F(()=>{s(),l.value&&u.value&&d()}),p(u,e=>{l.value&&(e?(s(),d()):h())}),p(()=>[a.badge.request??"",a.badge.interval??0].join("|"),()=>{s(),l.value&&u.value?d():h()}),(e,r)=>c.value&&B.value?(f(),O(S,{key:0},[n.badge.dot?(f(),w(m(y),x({key:0,variant:n.badge.variant??"default",class:"size-2.5 min-w-0 rounded-full p-0"},e.$attrs),null,16,["variant"])):(f(),w(m(y),x({key:1,variant:n.badge.variant??"default"},e.$attrs),{default:I(()=>[L(m(N),{source:j.value,class:"max-w-none text-inherit [&_*]:text-inherit [&_p]:m-0"},null,8,["source"])]),_:1},16,["variant"]))],64)):z("",!0)}});export{ee as default};
