import{k as ne,j as u,t as le,m as ie,n as y,p as s,i as $,v as oe,B as ae,A as se,w as re,x as m,s as ce}from"./web.Os7kOAdY.js";import{g as N,t as de}from"./i18n-runtime._BAkvU05.js";var pe=se('<div class=tool-container><div style=margin-bottom:16px><label style=font-size:13px;display:block;margin-bottom:6px></label><textarea class=tool-input rows=3 style=width:100%;resize:vertical></textarea></div><div style=display:flex;flex-wrap:wrap;gap:12px;margin-bottom:16px;align-items:center><select class=tool-select><option value=tian></option><option value=mi></option><option value=hui></option></select><label style=font-size:13px><!$><!/><input type=range min=40 max=120><!$><!/>px</label><label style=font-size:13px><!$><!/><input type=number min=2 max=16 class=tool-input style=width:50px></label><label style=font-size:13px;display:flex;align-items:center;gap:4px><input type=checkbox><!$><!/></label><button class=tool-btn></button></div><div style="overflow:auto;margin-bottom:16px;border:1px solid var(--border);border-radius:8px;background:#fafafa;padding:8px"><canvas style="display:block;margin:0 auto"></canvas></div><button class=tool-btn>');function ue(){const[W,C]=u(N(),{equals:!1}),o=n=>de(n,W());le(()=>{const n=t=>{const a=t.detail?.locale;a&&C(a)};window.addEventListener("taitan:locale-change",n),C(N()),ce(()=>window.removeEventListener("taitan:locale-change",n))});const[E,j]=u("永字八法"),[v,q]=u("tian"),[S,F]=u(80),[L,H]=u(8),[z,K]=u(!0),[U]=u("楷体, KaiTi, serif");let d;function J(){if(!d)return;const n=E().replace(/\s/g,"");if(!n)return;const t=S(),a=L(),f=Math.ceil(n.length/a),g=20,x=a*t+g*2,h=f*t+g*2;d.width=x,d.height=h;const e=d.getContext("2d");e.fillStyle="#fff",e.fillRect(0,0,x,h);for(let b=0;b<f;b++)for(let r=0;r<a;r++){const i=g+r*t,l=g+b*t;if(e.strokeStyle="#d44",e.lineWidth=1.5,e.strokeRect(i,l,t,t),z()){if(e.strokeStyle="#fcc",e.lineWidth=.8,e.setLineDash([4,3]),(v()==="tian"||v()==="mi")&&(e.beginPath(),e.moveTo(i,l+t/2),e.lineTo(i+t,l+t/2),e.stroke(),e.beginPath(),e.moveTo(i+t/2,l),e.lineTo(i+t/2,l+t),e.stroke()),v()==="mi"&&(e.beginPath(),e.moveTo(i,l),e.lineTo(i+t,l+t),e.stroke(),e.beginPath(),e.moveTo(i+t,l),e.lineTo(i,l+t),e.stroke()),v()==="hui"){const p=t*.25;e.strokeRect(i+p,l+p,t-p*2,t-p*2)}e.setLineDash([])}const _=b*a+r;_<n.length&&(e.fillStyle="#ccc",e.font=`${t*.7}px ${U()}`,e.textAlign="center",e.textBaseline="middle",e.fillText(n[_],i+t/2,l+t/2+t*.03))}}function O(){if(!d)return;const n=document.createElement("a");n.download="copybook.png",n.href=d.toDataURL("image/png"),n.click()}return(()=>{var n=ie(pe),t=n.firstChild,a=t.firstChild,f=a.nextSibling,g=t.nextSibling,x=g.firstChild,h=x.firstChild,e=h.nextSibling,b=e.nextSibling,r=x.nextSibling,i=r.firstChild,[l,_]=y(i.nextSibling),p=l.nextSibling,Q=p.nextSibling,[R,V]=y(Q.nextSibling);R.nextSibling;var k=r.nextSibling,X=k.firstChild,[P,Y]=y(X.nextSibling),A=P.nextSibling,w=k.nextSibling,T=w.firstChild,Z=T.nextSibling,[ee,te]=y(Z.nextSibling),D=w.nextSibling,G=g.nextSibling,M=G.firstChild,B=G.nextSibling;s(a,()=>o("输入练字内容:")),f.$$input=c=>j(c.currentTarget.value),x.addEventListener("change",c=>q(c.currentTarget.value)),s(h,()=>o("田字格")),s(e,()=>o("米字格")),s(b,()=>o("回字格")),s(r,()=>o("格子大小:"),l,_),p.$$input=c=>F(parseInt(c.currentTarget.value)),s(r,S,R,V),s(k,()=>o("每行:"),P,Y),A.$$input=c=>H(parseInt(c.currentTarget.value)||8),T.addEventListener("change",c=>K(c.currentTarget.checked)),s(w,()=>o("显示辅助线"),ee,te),D.$$click=J,s(D,()=>o("生成字帖"));var I=d;return typeof I=="function"?ae(I,M):d=M,B.$$click=O,s(B,()=>o("下载字帖")),$(()=>re(f,"placeholder",o("输入汉字，如：永字八法横竖撇捺"))),$(()=>m(f,"value",E())),$(()=>m(x,"value",v())),$(()=>m(p,"value",S())),$(()=>m(A,"value",L())),$(()=>m(T,"checked",z())),oe(),n})()}ne(["input","click"]);export{ue as default};
