import{k as G,j as h,t as J,h as I,m as K,p as a,i as C,v as Q,A as W,e as L,z as R,x as g,w as Y,s as Z}from"./web.Os7kOAdY.js";import{c as E}from"./clipboard.BNxbz_oK.js";import{g as A,t as tt}from"./i18n-runtime._BAkvU05.js";var et=W("<div class=panel style=display:flex;flex-direction:column;gap:14px><div class=tool-grid-2><div class=tool-field><span class=tool-label></span><input class=tool-input type=number min=1 max=3999><span>→ <strong style=font-family:ui-monospace,monospace;font-size:16px></strong></span><div class=tool-actions><button class=tool-btn></button></div></div><div class=tool-field><span class=tool-label></span><input class=tool-input type=text><span>→ <strong style=font-family:ui-monospace,monospace;font-size:16px></strong></span><div class=tool-actions><button class=tool-btn></button></div></div></div><p class=tool-hint>");const ot=[[1e3,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]];function V(s){if(!Number.isInteger(s)||s<1||s>3999)throw new Error("范围 1..3999");let o="",e=s;for(const[n,i]of ot)for(;e>=n;)o+=i,e-=n;return o}const D={I:1,V:5,X:10,L:50,C:100,D:500,M:1e3};function nt(s){const o=s.trim().toUpperCase();if(!/^[IVXLCDM]+$/.test(o))throw new Error("只能包含 I V X L C D M");let e=0;for(let n=0;n<o.length;n++){const i=D[o[n]],r=D[o[n+1]];r&&i<r?(e+=r-i,n++):e+=i}if(V(e)!==o)throw new Error("不是合法的罗马数字");return e}function at(){const[s,o]=h(A(),{equals:!1}),e=l=>tt(l,s());J(()=>{const l=f=>{const d=f.detail?.locale;d&&o(d)};window.addEventListener("taitan:locale-change",l),o(A()),Z(()=>window.removeEventListener("taitan:locale-change",l))});const[n,i]=h("1989"),[r,N]=h("MCMLXXXIX"),c=I(()=>{try{return{ok:!0,out:V(parseInt(n(),10))}}catch(l){return{ok:!1,out:l.message}}}),u=I(()=>{try{return{ok:!0,out:String(nt(r()))}}catch(l){return{ok:!1,out:l.message}}});return(()=>{var l=K(et),f=l.firstChild,d=f.firstChild,X=d.firstChild,x=X.nextSibling,v=x.nextSibling,T=v.firstChild,z=T.nextSibling,P=v.nextSibling,b=P.firstChild,O=d.nextSibling,y=O.firstChild,m=y.nextSibling,p=m.nextSibling,j=p.firstChild,q=j.nextSibling,H=p.nextSibling,$=H.firstChild,U=f.nextSibling;return a(X,()=>e("阿拉伯数字 (1..3999)")),x.$$input=t=>i(t.currentTarget.value),a(z,()=>c().out||"-"),b.$$click=()=>E(c().out),a(b,()=>e("复制")),a(y,()=>e("罗马数字")),m.$$input=t=>N(t.currentTarget.value),a(q,()=>u().out||"-"),$.$$click=()=>E(u().out),a($,()=>e("复制")),a(U,()=>e("罗马数字标准范围 1..3999；M=1000、D=500、C=100、L=50、X=10、V=5、I=1。")),C(t=>{var M=`tool-hint ${c().ok?"":"tool-error"}`,B=c().ok?"":"padding:6px 10px;",_=!c().ok,k=e("如 MCMLXXXIX"),S=`tool-hint ${u().ok?"":"tool-error"}`,F=u().ok?"":"padding:6px 10px;",w=!u().ok;return M!==t.e&&L(v,t.e=M),t.t=R(v,B,t.t),_!==t.a&&g(b,"disabled",t.a=_),k!==t.o&&Y(m,"placeholder",t.o=k),S!==t.i&&L(p,t.i=S),t.n=R(p,F,t.n),w!==t.s&&g($,"disabled",t.s=w),t},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0}),C(()=>g(x,"value",n())),C(()=>g(m,"value",r())),Q(),l})()}G(["input","click"]);export{at as default};
