import{k as Z,j as I,t as ee,h as N,m as r,n as j,w as z,p as e,q as x,v as H,i as Q,A as _,x as te,s as le}from"./web.Os7kOAdY.js";import{c as ne}from"./clipboard.BNxbz_oK.js";import{g as B,t as ae}from"./i18n-runtime._BAkvU05.js";var se=_("<div class=panel style=display:flex;flex-direction:column;gap:14px><div class=tool-field><span class=tool-label>URL</span><input class=tool-input autocomplete=off><!$><!/></div><!$><!/><p class=tool-hint>"),re=_("<span class=tool-error style=margin-top:6px>"),ie=_("<dl class=tool-kv><dt>scheme</dt><dd></dd><dt>username</dt><dd></dd><dt>password</dt><dd></dd><dt>host</dt><dd></dd><dt>port</dt><dd></dd><dt>pathname</dt><dd style=font-family:ui-monospace,monospace></dd><dt>search</dt><dd style=font-family:ui-monospace,monospace></dd><dt>hash</dt><dd style=font-family:ui-monospace,monospace></dd><dt>origin</dt><dd>"),oe=_('<div class=tool-actions><button class="tool-btn is-primary"></button><button class=tool-btn></button><button class=tool-btn></button><button class=tool-btn>'),v=_("<span class=tool-hint>"),de=_("<h3 style=margin:0;font-size:14px;color:var(--muted)>"),ce=_("<table class=tool-table><thead><tr><th></th><th></th><th></th></tr></thead><tbody>"),$e=_("<tr><td style=font-family:ui-monospace,monospace></td><td style=font-family:ui-monospace,monospace></td><td style=font-family:ui-monospace,monospace;color:var(--muted)>");function ue(w){try{return new URL(w)}catch{return null}}function he(){const[w,R]=I(B(),{equals:!1}),t=a=>ae(a,w());ee(()=>{const a=i=>{const d=i.detail?.locale;d&&R(d)};window.addEventListener("taitan:locale-change",a),R(B()),le(()=>window.removeEventListener("taitan:locale-change",a))});const[C,U]=I("https://user:pass@www.example.com:8443/api/v1/users?id=42&q=hello%20world&tags=a&tags=b#section-2"),l=N(()=>ue(C())),E=N(()=>{const a=l();if(!a)return[];const i=[];return a.searchParams.forEach((d,m)=>i.push({k:m,v:d})),i}),k=a=>{const i=l();if(!i)return;const d=new URL(i.href);a(d),U(d.href)};return(()=>{var a=r(se),i=a.firstChild,d=i.firstChild,m=d.nextSibling,D=m.nextSibling,[F,G]=j(D.nextSibling),J=i.nextSibling,[q,K]=j(J.nextSibling),O=q.nextSibling;return m.$$input=h=>U(h.currentTarget.value),z(m,"spellcheck",!1),e(i,(()=>{var h=x(()=>!!(!l()&&C().trim()));return()=>h()&&(()=>{var n=r(re);return e(n,()=>t("× 不是合法 URL")),n})()})(),F,G),e(a,(()=>{var h=x(()=>!!l());return()=>h()&&[(()=>{var n=r(ie),c=n.firstChild,$=c.nextSibling,u=$.nextSibling,p=u.nextSibling,o=p.nextSibling,S=o.nextSibling,g=S.nextSibling,b=g.nextSibling,y=b.nextSibling,f=y.nextSibling,L=f.nextSibling,P=L.nextSibling,V=P.nextSibling,M=V.nextSibling,W=M.nextSibling,T=W.nextSibling,X=T.nextSibling,Y=X.nextSibling;return e($,()=>l().protocol.replace(":","")),e(p,()=>l().username||(()=>{var s=r(v);return e(s,()=>t("(空)")),s})()),e(S,(()=>{var s=x(()=>!!l().password);return()=>s()?"•".repeat(l().password.length):(()=>{var A=r(v);return e(A,()=>t("(空)")),A})()})()),e(b,()=>l().hostname),e(f,()=>l().port||(()=>{var s=r(v);return e(s,()=>t("默认")),s})()),e(P,()=>l().pathname),e(M,()=>l().search||(()=>{var s=r(v);return e(s,()=>t("(空)")),s})()),e(T,()=>l().hash||(()=>{var s=r(v);return e(s,()=>t("(空)")),s})()),e(Y,()=>l().origin),n})(),x(()=>x(()=>E().length>0)()&&[(()=>{var n=r(de);return e(n,()=>t("Query 参数")),n})(),(()=>{var n=r(ce),c=n.firstChild,$=c.firstChild,u=$.firstChild,p=u.nextSibling,o=p.nextSibling,S=c.nextSibling;return e(u,()=>t("键")),e(p,()=>t("解码值")),e(o,()=>t("原始")),e(S,()=>E().map(g=>(()=>{var b=r($e),y=b.firstChild,f=y.nextSibling,L=f.nextSibling;return e(y,()=>g.k),e(f,()=>g.v),e(L,()=>encodeURIComponent(g.v)),b})())),n})()]),(()=>{var n=r(oe),c=n.firstChild,$=c.nextSibling,u=$.nextSibling,p=u.nextSibling;return c.$$click=()=>ne(l().href),e(c,()=>t("复制规范化")),$.$$click=()=>k(o=>{o.username="",o.password=""}),e($,()=>t("去掉 user:pass")),u.$$click=()=>k(o=>{o.search=""}),e(u,()=>t("去掉 query")),p.$$click=()=>k(o=>{o.hash=""}),e(p,()=>t("去掉 hash")),H(),n})()]})(),q,K),e(O,()=>t("使用浏览器原生 URL 解析器，与服务端可能有细微差异。")),Q(()=>z(m,"placeholder",t("粘贴一个 URL…"))),Q(()=>te(m,"value",C())),H(),a})()}Z(["input","click"]);export{he as default};
