import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{ki as t}from"./lucide-icons-BjbcRgLk.js";import{t as n}from"./jsx-runtime-By8HlURe.js";import{t as r}from"./useAppContext-ZpOJAKgd.js";import{t as i}from"./utils-BFSTDHdM.js";function a(e,t){return e.replace(/\{(\+?)([A-Za-z0-9_]+)\}/g,(e,n,r)=>{let i=t[r];return i===void 0?``:n?encodeURI(i):encodeURIComponent(i)})}function o(e){let t=new URL(e.url);return a(e.template,{url:t.href,href:t.href,origin:t.origin,protocol:t.protocol,username:t.username,password:t.password,host:t.host,hostname:t.hostname,port:t.port,pathname:t.pathname,hash:t.hash,search:t.search})}function s(e){return o(e)}var c=e(t(),1),l=n();function u({url:e,size:t=16,fallback:n,className:a=``}){let{config:o}=r(),u=(0,c.useMemo)(()=>{if(e)try{let t=new URL(e);return t.hostname=t.hostname.replace(/^(ai\.|api\.|enclave\.)/,``),s({template:o.faviconUrl,url:t})}catch{return}},[e,o.faviconUrl]);return u?(0,l.jsxs)(`span`,{className:i(`inline-flex items-center justify-center`,a),children:[(0,l.jsx)(`img`,{src:u,alt:``,className:`object-contain`,style:{width:t,height:t},onError:e=>{e.currentTarget.style.display=`none`;let t=e.currentTarget.nextElementSibling;t&&(t.style.display=`inline-block`)},decoding:`async`}),n&&(0,l.jsx)(`span`,{style:{display:`none`},children:n})]}):(0,l.jsx)(`span`,{className:i(`inline-flex items-center justify-center`,a),children:(0,l.jsx)(`span`,{children:n})})}export{o as n,u as t};