import{k as W,j as b,t as G,m as s,n as h,p as a,f as x,A as c,s as O,v,S as w,i as F,w as S,q as P,F as X}from"./web.Os7kOAdY.js";import{g as R,t as Y}from"./i18n-runtime._BAkvU05.js";var B=c("<button class=tool-btn>"),J=c('<div style=text-align:center;margin-bottom:16px><img style="max-width:300px;max-height:300px;border-radius:8px;border:1px solid var(--border)">'),K=c('<div style="display:grid;grid-template-columns:repeat(3,1fr);gap:4px;max-width:450px;margin:0 auto 16px">'),Q=c("<div style=text-align:center><button class=tool-btn>"),V=c("<div class=tool-container><div style=display:flex;flex-wrap:wrap;gap:12px;margin-bottom:16px><label class=tool-btn style=cursor:pointer><!$><!/><input type=file accept=image/* style=display:none></label><!$><!/></div><!$><!/><!$><!/>"),Z=c('<img style="width:100%;aspect-ratio:1;object-fit:cover;border-radius:4px;cursor:pointer;border:1px solid var(--border)">');function ne(){const[H,y]=b(R(),{equals:!1}),f=e=>Y(e,H());G(()=>{const e=t=>{const n=t.detail?.locale;n&&y(n)};window.addEventListener("taitan:locale-change",e),y(R()),O(()=>window.removeEventListener("taitan:locale-change",e))});const[d,I]=b(null),[g,E]=b([]);function M(e){const t=e.target.files?.[0];if(!t)return;const n=new FileReader;n.onload=()=>{I(n.result),E([])},n.readAsDataURL(t)}function N(){if(!d())return;const e=new Image;e.onload=()=>{const t=Math.min(e.naturalWidth,e.naturalHeight),n=(e.naturalWidth-t)/2,_=(e.naturalHeight-t)/2,l=t/3,m=[];for(let u=0;u<3;u++)for(let p=0;p<3;p++){const i=document.createElement("canvas");i.width=l,i.height=l,i.getContext("2d").drawImage(e,n+p*l,_+u*l,l,l,0,0,l,l),m.push(i.toDataURL("image/png"))}E(m)},e.src=d()}function C(e){const t=document.createElement("a");t.download=`grid-${e+1}.png`,t.href=g()[e],t.click()}function j(){g().forEach((e,t)=>{setTimeout(()=>C(t),t*200)})}return(()=>{var e=s(V),t=e.firstChild,n=t.firstChild,_=n.firstChild,[l,m]=h(_.nextSibling),u=l.nextSibling,p=n.nextSibling,[i,k]=h(p.nextSibling),q=t.nextSibling,[L,z]=h(q.nextSibling),D=L.nextSibling,[T,U]=h(D.nextSibling);return a(n,()=>f("上传图片"),l,m),u.addEventListener("change",M),a(t,x(w,{get when(){return d()},get children(){var r=s(B);return r.$$click=N,a(r,()=>f("切割为九宫格")),v(),r}}),i,k),a(e,x(w,{get when(){return P(()=>!!d())()&&g().length===0},get children(){var r=s(J),o=r.firstChild;return F(()=>S(o,"src",d())),r}}),L,z),a(e,x(w,{get when(){return g().length>0},get children(){return[(()=>{var r=s(K);return a(r,x(X,{get each(){return g()},children:(o,A)=>(()=>{var $=s(Z);return $.$$click=()=>C(A()),S($,"src",o),F(()=>S($,"title",`点击下载第 ${A()+1} 张`)),v(),$})()})),r})(),(()=>{var r=s(Q),o=r.firstChild;return o.$$click=j,a(o,()=>f("全部下载")),v(),r})()]}}),T,U),e})()}W(["click"]);export{ne as default};
