import{k as pe,j as $,t as xe,m as v,p as o,f as C,i as u,v as E,A as P,e as $e,z as L,x as z,s as fe,n as J,F as M}from"./web.Os7kOAdY.js";import{g as K,t as ue}from"./i18n-runtime._BAkvU05.js";var ge=P('<div class=panel style=display:flex;flex-direction:column;gap:18px><section class=panel style=padding:14px><h3 style="margin:0 0 8px;font-size:14px;color:var(--muted)"></h3><div style=display:flex;flex-wrap:wrap;align-items:center;gap:8px><div class=tool-field style=flex:none><span class=tool-label></span><select class=tool-input style=width:70px></select></div><div class=tool-field style=flex:none><span class=tool-label></span><input type=color style=width:40px;height:32px;border:none;cursor:pointer></div><button></button><button class=tool-btn></button></div></section><section class=panel style=padding:14px><h3 style="margin:0 0 8px;font-size:14px;color:var(--muted)"></h3><div style=display:flex;flex-wrap:wrap;gap:4px></div></section><section class=panel style=padding:14px;overflow:auto><div></div></section><section class=panel style=padding:14px><h3 style="margin:0 0 8px;font-size:14px;color:var(--muted)"></h3><div class=tool-actions><button class="tool-btn is-primary"></button><button class=tool-btn>'),he=P("<option><!$><!/>×<!$><!/>"),O=P("<div>");const ve=[8,16,24,32],be=["#000000","#ffffff","#e74c3c","#e67e22","#f1c40f","#2ecc71","#3498db","#9b59b6","#1abc9c","#34495e","#ecf0f1","#95a5a6","#d35400","#c0392b","#8e44ad","#2980b9"];function ye(){const[Q,T]=$(K(),{equals:!1}),d=e=>ue(e,Q());xe(()=>{const e=t=>{const l=t.detail?.locale;l&&T(l)};window.addEventListener("taitan:locale-change",e),T(K()),fe(()=>window.removeEventListener("taitan:locale-change",e))});const[p,V]=$(16),[b,D]=$("#000000"),[f,m]=$(!1),[_,y]=$({}),[W,N]=$(!1),G=e=>{f()?y(t=>{const l={...t};return delete l[e],l}):y(t=>({...t,[e]:b()}))},X=e=>{N(!0),G(e)},Y=e=>{W()&&G(e)},w=()=>N(!1),I=()=>y({}),ee=()=>{const e=p(),t=16,l=document.createElement("canvas");l.width=e*t,l.height=e*t;const i=l.getContext("2d");for(let c=0;c<e;c++)for(let r=0;r<e;r++){const g=`${r},${c}`;i.fillStyle=_()[g]||"transparent",i.fillRect(r*t,c*t,t,t)}const a=document.createElement("a");a.download="pixel-art.png",a.href=l.toDataURL("image/png"),a.click()},te=()=>{const e=p(),t=[];for(let i=0;i<e;i++)for(let a=0;a<e;a++){const c=`${a},${i}`,r=_()[c];r&&t.push(`${a+1}px ${i+1}px 0 0 ${r}`)}const l=`.pixel-art {
  width: 1px;
  height: 1px;
  box-shadow:
    ${t.join(`,
    `)};
}`;navigator.clipboard.writeText(l).catch(()=>{}),alert("CSS box-shadow 已复制到剪贴板！")},ne=()=>{const e=[],t=p();for(let l=0;l<t;l++)for(let i=0;i<t;i++)e.push({key:`${i},${l}`,x:i,y:l});return e};return(()=>{var e=v(ge),t=e.firstChild,l=t.firstChild,i=l.nextSibling,a=i.firstChild,c=a.firstChild,r=c.nextSibling,g=a.nextSibling,R=g.firstChild,A=R.nextSibling,h=g.nextSibling,j=h.nextSibling,F=t.nextSibling,U=F.firstChild,le=U.nextSibling,q=F.nextSibling,S=q.firstChild,se=q.nextSibling,B=se.firstChild,ie=B.nextSibling,k=ie.firstChild,H=k.nextSibling;return e.addEventListener("mouseleave",w),e.$$mouseup=w,o(l,()=>d("工具栏")),o(c,()=>d("网格")),r.addEventListener("change",n=>{V(parseInt(n.currentTarget.value)),I()}),o(r,C(M,{each:ve,children:n=>(()=>{var s=v(he),x=s.firstChild,[Z,oe]=J(x.nextSibling),ae=Z.nextSibling,re=ae.nextSibling,[ce,de]=J(re.nextSibling);return z(s,"value",n),o(s,n,Z,oe),o(s,n,ce,de),s})()})),o(R,()=>d("颜色")),A.$$input=n=>{D(n.currentTarget.value),m(!1)},h.$$click=()=>m(!f()),o(h,()=>f()?"🧽 橡皮擦 (开)":"🧽 橡皮擦"),j.$$click=I,o(j,()=>d("清空画布")),o(U,()=>d("调色板")),o(le,C(M,{each:be,children:n=>(()=>{var s=v(O);return s.$$click=()=>{D(n),m(!1)},u(x=>L(s,`width:24px;height:24px;border-radius:3px;background:${n};cursor:pointer;border:2px solid ${b()===n&&!f()?"#333":"#ddd"};`,x)),E(),s})()})),S.addEventListener("mouseleave",w),o(S,C(M,{get each(){return ne()},children:n=>(()=>{var s=v(O);return s.addEventListener("mouseenter",()=>Y(n.key)),s.$$mousedown=()=>X(n.key),u(x=>L(s,`width:${Math.min(24,Math.floor(400/p()))}px;height:${Math.min(24,Math.floor(400/p()))}px;background:${_()[n.key]||"#fff"};cursor:crosshair;`,x)),E(),s})()})),o(B,()=>d("导出")),k.$$click=ee,o(k,()=>d("导出 PNG")),H.$$click=te,o(H,()=>d("复制 CSS box-shadow")),u(n=>{var s=`tool-btn ${f()?"is-primary":""}`,x=`display:grid;grid-template-columns:repeat(${p()},1fr);gap:1px;background:#ddd;border:1px solid #ddd;width:fit-content;margin:0 auto;user-select:none;`;return s!==n.e&&$e(h,n.e=s),n.t=L(S,x,n.t),n},{e:void 0,t:void 0}),u(()=>z(r,"value",p())),u(()=>z(A,"value",b())),E(),e})()}pe(["mouseup","input","click","mousedown"]);export{ye as default};
