import{k as B,j as v,t as D,h as M,m as $,p as l,i as c,v as J,x as o,A as R,w as Q,s as V}from"./web.Os7kOAdY.js";import{g as P,t as W}from"./i18n-runtime._BAkvU05.js";var X=R("<div class=panel style=display:flex;flex-direction:column;gap:14px><div class=tool-field><span class=tool-label></span><select class=tool-input></select></div><div class=tool-grid-2><div class=tool-field><span class=tool-label></span><input class=tool-input type=number></div><div class=tool-field><span class=tool-label></span><select class=tool-input></select></div></div><div class=tool-field><span class=tool-label></span><select class=tool-input></select></div><div class=tool-field><span class=tool-label></span><input class=tool-input readonly></div><p class=tool-hint>"),C=R("<option>");const g={长度:{千米:1e3,米:1,厘米:.01,毫米:.001,英里:1609.344,码:.9144,英尺:.3048,英寸:.0254},重量:{吨:1e3,千克:1,克:.001,毫克:1e-6,磅:.453592,盎司:.0283495},温度:{摄氏度:1,华氏度:1,开尔文:1},面积:{平方千米:1e6,平方米:1,平方厘米:1e-4,公顷:1e4,亩:666.667,平方英里:259e4,平方英尺:.0929},体积:{升:1,毫升:.001,立方米:1e3,加仑:3.78541,品脱:.473176},速度:{"千米/时":1,"米/秒":3.6,"英里/时":1.60934,节:1.852}};function Y(u,d,a){let i=u;return d==="华氏度"?i=(u-32)*5/9:d==="开尔文"&&(i=u-273.15),a==="华氏度"?i*9/5+32:a==="开尔文"?i+273.15:i}function te(){const[u,d]=v(P(),{equals:!1}),a=t=>W(t,u());D(()=>{const t=s=>{const r=s.detail?.locale;r&&d(r)};window.addEventListener("taitan:locale-change",t),d(P()),V(()=>window.removeEventListener("taitan:locale-change",t))});const i=Object.keys(g),[f,q]=v(i[0]),p=M(()=>Object.keys(g[f()]||{})),[_,S]=v(p()[0]),[b,E]=v(p()[1]??p()[0]),[y,G]=v("1"),H=t=>{q(t);const s=Object.keys(g[t]||{});S(s[0]),E(s[1]??s[0])},K=M(()=>{const t=parseFloat(y());if(isNaN(t))return"";if(f()==="温度")return Y(t,_(),b()).toFixed(4).replace(/\.?0+$/,"");const s=g[f()]||{};return(t*(s[_()]||1)/(s[b()]||1)).toPrecision(8).replace(/\.?0+$/,"")});return(()=>{var t=$(X),s=t.firstChild,r=s.firstChild,m=r.nextSibling,T=s.nextSibling,L=T.firstChild,w=L.firstChild,j=w.nextSibling,U=L.nextSibling,k=U.firstChild,x=k.nextSibling,O=T.nextSibling,A=O.firstChild,h=A.nextSibling,F=O.nextSibling,N=F.firstChild,I=N.nextSibling,z=F.nextSibling;return l(r,()=>a("类别")),m.addEventListener("change",e=>H(e.currentTarget.value)),l(m,()=>i.map(e=>(()=>{var n=$(C);return o(n,"value",e),l(n,e),n})())),l(w,()=>a("数值")),j.$$input=e=>G(e.currentTarget.value),l(k,()=>a("从")),x.addEventListener("change",e=>S(e.currentTarget.value)),l(x,()=>p().map(e=>(()=>{var n=$(C);return o(n,"value",e),l(n,e),n})())),l(A,()=>a("到")),h.addEventListener("change",e=>E(e.currentTarget.value)),l(h,()=>p().map(e=>(()=>{var n=$(C);return o(n,"value",e),l(n,e),n})())),l(N,()=>a("结果")),l(z,()=>a("温度按 ℃ ↔ ℉ ↔ K 互转；其他类别经基准单位换算。")),c(()=>Q(I,"placeholder",a("自动计算"))),c(()=>o(m,"value",f())),c(()=>o(j,"value",y())),c(()=>o(x,"value",_())),c(()=>o(h,"value",b())),c(()=>o(I,"value",K())),J(),t})()}B(["input"]);export{te as default};
