import"./modulepreload-polyfill-B5Qt9EMX.js";import{F as x,l as b,d as L,e as k,P as I,B as z,h as R,i as B,W as P,j as S,k as m,n as $}from"./WorkLayer-5uUyxw6h.js";document.body.onload=function(){function o(c){const t=/\/share\/([\w-]+)/,i=c.match(t);return i?i[1]:null}let a=window.location.href;console.log("current url:",a);let n=a.substring(0,a.indexOf("/share")),e=o(a);console.log("host:",n),console.log("id:",e);const l=new URLSearchParams(window.location.search);let r=l.get("u")||l.get("uuid");e||(e="test");let s=`${n}/proxy/zips/v2/number_mini/1501/${e}.zip`;n.includes("art.pcoloring.com")&&(s=`https://pcoloring.com/zips/v2/number_mini/1501/${e}.zip`),v(e,r,s)};async function v(o,a,n){console.log(o,a,n);let e=[];a&&(e=await F(o,a));let l=document.querySelector("#play-button"),r=document.querySelector("#canvas"),s=r.getContext("webgl2",{premultipliedAlpha:!1}),c=window.devicePixelRatio;r.width=r.clientWidth*c,r.height=r.clientHeight*c;let t=new x(s,c),i;if(o=="test"?i=await j():i=await b(n),!e||e.length<=0){e=[];for(let y of i.config)for(let w of y.areas)e.push(w.id)}l.style.zIndex="200";let f={hintStyle:"default",sound:!0,vibrate:!0,autoNext:!0,...JSON.parse(localStorage.getItem("settings")||"{}")},d=new L(new k(f),i,s,e);t.fillerData=d,console.log("resource",i),t.setContentPadding(new I(0,0,0,0));let u=d.width,p=d.height;t.setContentSize(u,p),i.bg&&t.addLayer(new z(t,i.bg,t.width,t.height,R.Repeat)),t.addLayer(new B(t,0,0,u,p));let g=new P(t,d);t.addLayer(g),t.addLayer(new S(t,i.page,u,p)),g.initTask(),l.addEventListener("click",()=>h(g)),h(g)}async function F(o,a){let n=null;const e=`/api/tasks?uuid=${a}&art=${o}`;try{const l=await fetch(e,{method:"GET",headers:{"Content-Type":"application/json"}});return l.ok?(console.log("获取task数据成功:"),n=await l.json()):console.error("未获取到task数据"),n}catch(l){console.error("网络请求或服务器错误:",l)}}async function j(){let o="/assets/unzipped/friend",a=[fetch(`${o}/config.json`).then(t=>t.json()),m(`${o}/page.png`),m(`${o}/map.png`),m("/assets/fonts/numbers_roboto_500.png")],[n,e,l,r,s,c]=await Promise.all(a);return new $(n,e,l,r,[],c,s)}async function h(o){let a=document.getElementById("poster-img");a.style.zIndex="0";let n=document.getElementById("play-button");n.style.zIndex="0",await o.replay(),n.style.zIndex="200"}