import{k as dt,j as r,t as ut,m as pt,p as l,i as h,v as gt,s as U,A as ft,w as W,x as m}from"./web.Os7kOAdY.js";import{g as j,t as vt}from"./i18n-runtime._BAkvU05.js";var xt=ft('<div class=panel style=display:flex;flex-direction:column;gap:18px><section class=panel style=padding:14px;text-align:center><h3 style="margin:0 0 10px;font-size:14px;color:var(--muted)"></h3><div style="position:relative;width:200px;height:200px;margin:0 auto"><svg viewBox="0 0 100 100"style=width:100%;height:100%;transform:rotate(-90deg)><circle cx=50 cy=50 r=45 fill=none stroke=#eee stroke-width=6></circle><circle cx=50 cy=50 r=45 fill=none stroke-width=6 stroke-linecap=round></circle></svg><div style=position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-size:36px;font-family:ui-monospace,monospace;font-weight:bold></div></div></section><section class=panel style=padding:14px><div class=tool-grid-2><div class=tool-field><span class=tool-label></span><input class=tool-input type=number min=1 max=120></div><div class=tool-field><span class=tool-label></span><input class=tool-input type=number min=1 max=60></div></div><div class=tool-actions style=margin-top:12px><button class="tool-btn is-primary"></button><button class=tool-btn></button><button class=tool-btn></button><button class=tool-btn></button></div></section><section class=panel style=padding:14px;text-align:center><h3 style="margin:0 0 6px;font-size:14px;color:var(--muted)"></h3><div style=font-size:48px;font-weight:bold;color:#e74c3c></div><p style="margin:4px 0 0;font-size:12px;color:var(--muted)">');const G=25,mt=5;function kt(){const[H,k]=r(j(),{equals:!1}),o=t=>vt(t,H());ut(()=>{const t=i=>{const n=i.detail?.locale;n&&k(n)};window.addEventListener("taitan:locale-change",t),k(j()),U(()=>window.removeEventListener("taitan:locale-change",t))});const[c,N]=r(G),[u,V]=r(mt),[b,s]=r(G*60),[p,y]=r(!1),[a,g]=r("work"),[w,_]=r(0);let d=null;const S=()=>`pomodoro_${new Date().toISOString().slice(0,10)}`;_((()=>{try{return parseInt(localStorage.getItem(S())||"0")||0}catch{return 0}})());const J=t=>{try{localStorage.setItem(S(),String(t))}catch{}},Q=()=>{try{const t=new AudioContext,i=t.createOscillator(),n=t.createGain();i.connect(n),n.connect(t.destination),i.frequency.value=800,n.gain.value=.3,i.start(),n.gain.exponentialRampToValueAtTime(.001,t.currentTime+.8),i.stop(t.currentTime+.8),setTimeout(()=>t.close(),1e3)}catch{}},f=()=>{d&&(clearInterval(d),d=null),y(!1)},X=()=>{if(s(t=>t-1),b()<=0)if(f(),Q(),a()==="work"){const t=w()+1;_(t),J(t),g("break"),s(u()*60)}else g("work"),s(c()*60)},Y=()=>{p()||(y(!0),d=setInterval(X,1e3))},Z=()=>{f(),g("work"),s(c()*60)},tt=()=>{f(),a()==="work"?(g("break"),s(u()*60)):(g("work"),s(c()*60))};U(()=>{d&&clearInterval(d)});const et=t=>{const i=Math.floor(t/60),n=t%60;return`${String(i).padStart(2,"0")}:${String(n).padStart(2,"0")}`},nt=()=>{const t=a()==="work"?c()*60:u()*60;return t>0?(t-b())/t*100:0};return(()=>{var t=pt(xt),i=t.firstChild,n=i.firstChild,it=n.nextSibling,C=it.firstChild,lt=C.firstChild,T=lt.nextSibling,ot=C.nextSibling,E=i.nextSibling,I=E.firstChild,A=I.firstChild,L=A.firstChild,M=L.nextSibling,st=A.nextSibling,R=st.firstChild,z=R.nextSibling,at=I.nextSibling,v=at.firstChild,x=v.nextSibling,$=x.nextSibling,D=$.nextSibling,rt=E.nextSibling,B=rt.firstChild,K=B.nextSibling,ct=K.nextSibling;return l(n,()=>a()==="work"?"🍅 专注时间":"☕ 休息时间"),l(ot,()=>et(b())),l(L,()=>o("专注(分钟)")),M.$$input=e=>{N(parseInt(e.currentTarget.value)||25),!p()&&a()==="work"&&s(c()*60)},l(R,()=>o("休息(分钟)")),z.$$input=e=>{V(parseInt(e.currentTarget.value)||5),!p()&&a()==="break"&&s(u()*60)},v.$$click=Y,l(v,()=>o("开始")),x.$$click=f,l(x,()=>o("暂停")),$.$$click=Z,l($,()=>o("重置")),D.$$click=tt,l(D,()=>o("跳过")),l(B,()=>o("今日完成")),l(K,w),l(ct,()=>o("个番茄钟")),h(e=>{var O=a()==="work"?"#e74c3c":"#27ae60",P=`${nt()*2.83} 283`,q=p(),F=!p();return O!==e.e&&W(T,"stroke",e.e=O),P!==e.t&&W(T,"stroke-dasharray",e.t=P),q!==e.a&&m(v,"disabled",e.a=q),F!==e.o&&m(x,"disabled",e.o=F),e},{e:void 0,t:void 0,a:void 0,o:void 0}),h(()=>m(M,"value",c())),h(()=>m(z,"value",u())),gt(),t})()}dt(["input","click"]);export{kt as default};
