webwallgl 1.1.0 → 1.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +164 -4
- package/README.md +164 -4
- package/package.json +1 -1
- package/types.d.ts +166 -17
- package/webwallgl.d.ts +35 -15
- package/webwallgl.global.js +706 -88
- package/webwallgl.global.js.map +1 -1
- package/webwallgl.global.min.js +37 -37
- package/webwallgl.global.min.js.map +1 -1
- package/webwallgl.min.mjs +37 -37
- package/webwallgl.min.mjs.map +1 -1
- package/webwallgl.mjs +707 -89
- package/webwallgl.mjs.map +1 -1
package/webwallgl.min.mjs
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
function nr(e,n){const t=n?.renderDpr??e.cfg?.renderDpr??1;return Math.min(window.devicePixelRatio||1,t)}function hn(e){return e==="fit"?"contain":e==="fill"?"cover":e==="contain"||e==="stretch"?e:"cover"}function yo(e){const n=hn(e);return n==="contain"?{objectFit:"contain",background:"rgba(10,12,16,0.85)"}:n==="stretch"?{objectFit:"fill",background:"transparent"}:{objectFit:"cover",background:"transparent"}}function gs(e){return{cfg:{type:"canvas"},coverAlign:{x:.5,y:.5,tx:.5,ty:.5},frameMeter:{stamps:[],last:0,fps:0},disposers:[]}}(()=>{const e=n=>n.preventDefault();window.addEventListener("contextmenu",e,!0),document.addEventListener("contextmenu",e,!0),window.__blockContextMenu=n=>n.addEventListener("contextmenu",e,!0)})();function nn(e){if(e.iframe)try{e.iframe.contentWindow?.location.replace("about:blank")}catch{}if(e.wrap)e.wrap.innerHTML="";else if(e.iframe?.isConnected)try{e.iframe.remove()}catch{}e.raf!==void 0&&cancelAnimationFrame(e.raf),e.raf=void 0;for(const n of e.videoPairs??[])n.destroy();e.videoPairs=void 0,e.sceneCleanup&&e.sceneCleanup(),e.sceneCleanup=void 0,e.sceneCtl=void 0,e.pointerCtl=void 0,e.renderer&&(e.renderer.dispose?.(),e.renderer=void 0);for(const n of e.videoTextures??[])n.pause(),n.removeAttribute("src"),n.load(),n.remove();e.videoTextures=void 0;for(const n of e.objectUrls??[])try{URL.revokeObjectURL(n)}catch{}if(e.objectUrls=void 0,e.sceneAudio){for(const n of e.sceneAudio.audios)n.pause(),n.removeAttribute("src"),n.load();e.sceneAudio=void 0}if(e.video){e.video.pause(),e.video.removeAttribute("src");try{e.video.load()}catch{}e.video.remove()}e.video=void 0,e.img=void 0,e.iframe=void 0,e.canvas=void 0,e.ctx=void 0,e.info=void 0,xo(e)}function bs(e){nn(e);for(const n of e.disposers.splice(0))try{n()}catch{}e.wrap?.remove(),e.wrap=void 0}const ys=new TextDecoder,mt=e=>ys.decode(e).replace(/^\uFEFF/,""),vo=500;function rr(e,n){const t=e.frameMeter.stamps;t.push(n),e.frameMeter.last=n;const r=n-vo;for(;t.length&&t[0]<r;)t.shift();const o=t.length>=2?t[t.length-1]-t[0]:0;e.frameMeter.fps=o>0?(t.length-1)*1e3/o:0}function xo(e){e.frameMeter.stamps.length=0,e.frameMeter.last=0,e.frameMeter.fps=0}function vs(e){return!e.frameMeter.last||e.paused?{fps:0,running:!1}:performance.now()-e.frameMeter.last>Math.max(vo,400)?{fps:0,running:!1}:{fps:e.frameMeter.fps,running:!0}}function se(e,n,t){try{e.onDiagnostic?.(t,/fail|error|失败|ERROR/.test(t)?"error":"info")}catch{}try{const r=n.mediaBase?new URL(n.mediaBase,window.location.href).origin:"";if(r){const o=new Image;o.src=`${r}/diag?msg=${encodeURIComponent(`scene ${n.src??"?"}: ${t.slice(0,500)}`)}`}}catch{}}function Rr(e){e.coverAlign.x=e.coverAlign.y=e.coverAlign.tx=e.coverAlign.ty=.5,xs(e)}function xs(e){const n=`${(e.coverAlign.x*100).toFixed(2)}% ${(e.coverAlign.y*100).toFixed(2)}%`,t=e.video??e.img;t&&t.isConnected&&(t.style.objectPosition=n)}function wo(e,n,t){const r=nr(e,t),o=Math.max(1,Math.round((n.clientWidth||window.innerWidth||1)*r)),i=Math.max(1,Math.round((n.clientHeight||window.innerHeight||1)*r));return n.width===o&&n.height===i?!1:(n.width=o,n.height=i,!0)}function ws(e){const n=new DataView(e.buffer,e.byteOffset,e.byteLength);if(e.length<16)throw new Error("\u6587\u4EF6\u592A\u5C0F\uFF0C\u4E0D\u662F scene.pkg");const t=n.getUint32(0,!0);if(t<4||t>16)throw new Error("\u9B54\u6570\u957F\u5EA6\u5F02\u5E38: "+t);const r=Mo(e,4,t);if(!r.startsWith("PKGV"))throw new Error("\u4E0D\u662F scene.pkg\uFF0C\u9B54\u6570: "+r);const o=n.getUint32(4+t,!0);let i=4+t+4;const s=[];for(let c=0;c<o;c++){if(i+8>e.length)throw new Error("\u5165\u53E3\u8868\u8D8A\u754C @"+c);const u=n.getUint32(i,!0);if(i+=4,i+u+8>e.length)throw new Error("\u5165\u53E3 "+c+" \u8D8A\u754C");const l=_s(e,i,u);i+=u;const p=n.getUint32(i,!0);i+=4;const f=n.getUint32(i,!0);i+=4,s.push({name:l,offset:p,size:f})}const a=i;return{magic:r,version:r.slice(4),count:o,entries:s,dataStart:a,fileSize:e.length,buf:e}}function Fr(e,n){const t=e.entries.find(i=>i.name===n);if(t===void 0)return null;const r=e.dataStart+t.offset,o=r+t.size;if(r<0||o>e.fileSize)throw new Error("\u5165\u53E3 "+n+" \u8D8A\u754C");return e.buf.subarray(r,o)}function Ms(e){let n=0;for(const t of e.entries)n=Math.max(n,t.offset+t.size);return{dataEnd:e.dataStart+n,fileSize:e.fileSize,ok:e.dataStart+n<=e.fileSize}}function Mo(e,n,t){let r="";for(let o=n;o<n+t;o++)r+=String.fromCharCode(e[o]);return r}function _s(e,n,t){try{return new TextDecoder("utf-8",{fatal:!0}).decode(e.subarray(n,n+t))}catch{return Mo(e,n,t)}}const As=Object.freeze(Object.defineProperty({__proto__:null,getEntry:Fr,parsePkg:ws,verifyLayout:Ms},Symbol.toStringTag,{value:"Module"})),kr={0:"ARGB8888",1:"RGB888",2:"RGB565",4:"DXT5",6:"DXT3",7:"DXT1",8:"RG88",9:"R8",10:"RG1616f",11:"R16f",12:"BC7",13:"RGBa1010102",14:"RGBA16161616f",15:"RGB161616f"},jt={UNKNOWN:-1,JPEG:2,PNG:13,GIF:25,WEBP:35,MP4:35};function Ts(e){const n=e.images[0];if(!n||n.length===0)throw new Error("\u65E0\u56FE\u50CF\u6570\u636E");const t=n[0];if(e.isVideo)return{width:t.width,height:t.height,video:t.data};if(e.freeImageFormat===jt.PNG)return{width:t.width,height:t.height,png:t.data};if(e.freeImageFormat!==jt.UNKNOWN)return{width:t.width,height:t.height,image:t.data,fif:e.freeImageFormat};const r=Nr(e.format,t.data,t.width,t.height);return!e.frames?.list?.length&&(t.width!==e.width||t.height!==e.height)?{width:e.width,height:e.height,rgba:_o(r,t.width,t.height,e.width,e.height)}:{width:t.width,height:t.height,rgba:r}}function Ss(e){const n=e.images[0];if(!n||n.length===0)throw new Error("\u65E0\u56FE\u50CF\u6570\u636E");const t=[];for(const r of n){if(e.freeImageFormat!==jt.UNKNOWN){t.push({width:r.width,height:r.height,image:r.data,fif:e.freeImageFormat});continue}const o=Nr(e.format,r.data,r.width,r.height);t.push({width:r.width,height:r.height,rgba:o})}return!e.frames?.list?.length&&t.length>0&&(t[0].width!==e.width||t[0].height!==e.height)&&t[0].rgba&&(t[0]={width:e.width,height:e.height,rgba:_o(t[0].rgba,t[0].width,t[0].height,e.width,e.height)}),t}function _o(e,n,t,r,o){const i=new Uint8Array(r*o*4);for(let s=0;s<o;s++)i.set(e.subarray(s*n*4,s*n*4+r*4),s*r*4);return i}function Nr(e,n,t,r){switch(e){case 0:return Es(n,t,r);case 1:return Ps(n,t,r);case 2:return Cs(n,t,r);case 4:return Ns(n,t,r);case 6:return ks(n,t,r);case 7:return Fs(n,t,r);case 8:return Ls(n,t,r);case 9:return Rs(n,t,r);case 12:throw new Error("BC7 \u89E3\u7801\u6682\u672A\u5B9E\u73B0\uFF08format=12\uFF09");default:throw new Error("\u672A\u652F\u6301\u7684\u7EB9\u7406\u683C\u5F0F: "+(kr[e]||e))}}function Es(e,n,t){return new Uint8Array(e.buffer,e.byteOffset,n*t*4).slice()}function Ps(e,n,t){const r=new Uint8Array(n*t*4);for(let o=0;o<n*t;o++)r[o*4]=e[o*3],r[o*4+1]=e[o*3+1],r[o*4+2]=e[o*3+2],r[o*4+3]=255;return r}function Cs(e,n,t){const r=new Uint8Array(n*t*4);for(let o=0;o<n*t;o++){const i=e[o*2]|e[o*2+1]<<8,s=i>>11&31,a=i>>5&63,c=i&31;r[o*4]=s<<3|s>>2,r[o*4+1]=a<<2|a>>4,r[o*4+2]=c<<3|c>>2,r[o*4+3]=255}return r}function Ls(e,n,t){const r=new Uint8Array(n*t*4);for(let o=0;o<n*t;o++)r[o*4]=e[o*2+1],r[o*4+1]=e[o*2+1],r[o*4+2]=e[o*2+1],r[o*4+3]=e[o*2];return r}function Rs(e,n,t){const r=new Uint8Array(n*t*4);for(let o=0;o<n*t;o++)r[o*4]=e[o],r[o*4+1]=e[o],r[o*4+2]=e[o],r[o*4+3]=255;return r}function Fs(e,n,t){return Ur(e,n,t,!0,0)}function ks(e,n,t){return Ur(e,n,t,!1,3)}function Ns(e,n,t){return Ur(e,n,t,!1,5)}function Ur(e,n,t,r,o){const i=new Uint8Array(n*t*4),s=r?8:16,a=new Uint8Array(16);let c=0;for(let u=0;u<t;u+=4)for(let l=0;l<n;l+=4){if(c+s>e.length)return i;a.set(e.subarray(c,c+s)),c+=s;const p=Us(a,r),f=Ds(a,r),d=o===3?Bs(a):o===5?Is(a):null;for(let w=0;w<4;w++)for(let M=0;M<4;M++){const m=l+M,A=u+w;if(m>=n||A>=t)continue;const h=w*4+M,b=(A*n+m)*4;i[b]=p[f[h]*4],i[b+1]=p[f[h]*4+1],i[b+2]=p[f[h]*4+2],i[b+3]=d!==null?d[h]:p[f[h]*4+3]}}return i}function Ao(e,n){const t=e[n]|e[n+1]<<8,r=t>>11&31,o=t>>5&63,i=t&31;return[t,r<<3|r>>2,o<<2|o>>4,i<<3|i>>2]}function Us(e,n){const t=n?0:8,r=Ao(e,t),o=Ao(e,t+2),i=new Uint8Array(16);return i[0]=r[1],i[1]=r[2],i[2]=r[3],i[3]=255,i[4]=o[1],i[5]=o[2],i[6]=o[3],i[7]=255,n&&r[0]<=o[0]?(i[8]=r[1]+o[1]>>1,i[9]=r[2]+o[2]>>1,i[10]=r[3]+o[3]>>1,i[11]=255,i[12]=0,i[13]=0,i[14]=0,i[15]=0):(i[8]=Math.floor((2*r[1]+o[1])/3),i[9]=Math.floor((2*r[2]+o[2])/3),i[10]=Math.floor((2*r[3]+o[3])/3),i[11]=255,i[12]=Math.floor((r[1]+2*o[1])/3),i[13]=Math.floor((r[2]+2*o[2])/3),i[14]=Math.floor((r[3]+2*o[3])/3),i[15]=255),i}function Ds(e,n){const t=n?4:12,r=new Uint8Array(16);for(let o=0;o<4;o++){const i=e[t+o];r[o*4]=i&3,r[o*4+1]=i>>2&3,r[o*4+2]=i>>4&3,r[o*4+3]=i>>6&3}return r}function Bs(e){const n=new Uint8Array(16);for(let t=0;t<8;t++){const r=e[t],o=r&15,i=r&240;n[2*t]=o|o<<4,n[2*t+1]=i|i>>4}return n}function Is(e){const n=e[0],t=e[1],r=new Uint8Array(8);if(r[0]=n,r[1]=t,n<=t){for(let a=1;a<5;a++)r[1+a]=Math.floor(((5-a)*n+a*t)/5);r[6]=0,r[7]=255}else for(let a=1;a<7;a++)r[a+1]=Math.floor(((7-a)*n+a*t)/7);const o=new Uint8Array(16);let i=0;for(let a=0;a<2;a++){let c=0;for(let u=0;u<3;u++)c|=e[2+a*3+u]<<8*u;for(let u=0;u<8;u++)o[i++]=c>>3*u&7}const s=new Uint8Array(16);for(let a=0;a<16;a++)s[a]=r[o[a]];return s}function To(e,n){const t=new Uint8Array(n);let r=0,o=0;for(;r<e.length;){const i=e[r++];let s=i>>4;if(s===15){let l;do l=e[r++],s+=l;while(l===255)}for(let l=0;l<s;l++)t[o++]=e[r++];if(r>=e.length)break;const a=e[r]|e[r+1]<<8;r+=2;let c=4+(i&15);if((i&15)===15){let l;do l=e[r++],c+=l;while(l===255)}const u=o-a;for(let l=0;l<c;l++)t[o++]=t[u+l]}return t}function $e(e,n){return(e[n]|e[n+1]<<8|e[n+2]<<16|e[n+3]<<24)>>>0}function So(e,n){return $e(e,n)|0}const Pn=new DataView(new ArrayBuffer(4));function zt(e,n){return Pn.setUint8(0,e[n]),Pn.setUint8(1,e[n+1]),Pn.setUint8(2,e[n+2]),Pn.setUint8(3,e[n+3]),Pn.getFloat32(0,!0)}function Os(e){let n=0;const t=or(e,n,9);if(n+=9,t!=="TEXV0005\0")throw new Error("\u4E0D\u662F .tex \u6587\u4EF6: "+t);const r=or(e,n,9);if(n+=9,r!=="TEXI0001\0")throw new Error("\u672A\u77E5 TEXI \u5B50\u5BB9\u5668: "+r);const o=$e(e,n);n+=4;const i=$e(e,n);n+=4;const s=$e(e,n);n+=4;const a=$e(e,n);n+=4;const c=$e(e,n);n+=4;const u=$e(e,n);n+=4,n+=4;const l=or(e,n,9);n+=9;const p=$e(e,n);n+=4;let f=jt.UNKNOWN,d=0;if(l==="TEXB0004\0"){f=$e(e,n)|0,n+=4;const v=$e(e,n);n+=4,f===jt.UNKNOWN&&v===1&&(f=jt.MP4),d=v===1?4:3}else if(l==="TEXB0003\0")f=$e(e,n)|0,n+=4,d=3;else if(l==="TEXB0002\0")d=2;else if(l==="TEXB0001\0")d=1;else throw new Error("\u672A\u77E5 TEXB \u5BB9\u5668: "+l);const w=(i&32)!==0||f===jt.MP4,M=[];for(let v=0;v<p;v++){const T=$e(e,n);n+=4;const _=[];for(let F=0;F<T;F++){if(d===4){for(n+=8;n<e.length&&e[n]!==0;)n++;n+=1,n+=4}const R=$e(e,n);n+=4;const k=$e(e,n);n+=4;let U=0,V=0;d>=2&&(U=$e(e,n),n+=4,V=So(e,n),n+=4);const q=So(e,n);if(n+=4,w){_.push({width:R,height:k,compression:0,data:e.subarray(n)}),n=e.length;continue}U===0&&(V=q);const W=e.subarray(n,n+q);n+=q;let Z=W;U===1&&(Z=To(W,V)),_.push({width:R,height:k,compression:U,data:Z})}M.push(_)}const m=M[0]&&M[0][0],A=m?m.width:s,h=m?m.height:a;let b=null;if(n+13<=e.length){const v=or(e,n,9);if(v.indexOf("TEXS")===0){let T=n+9;const _=$e(e,T);T+=4;let F=0,R=0;v==="TEXS0003\0"&&(F=$e(e,T),T+=4,R=$e(e,T),T+=4);const k=e.length-T,U=_>0&&k>0&&k%_===0?k/_:0;if(_>0&&_<=4096&&U>=32){const V=[];for(let W=0;W<_;W++){const Z=T+W*U;if(Z+32>e.length)break;const K=zt(e,Z+8),re=zt(e,Z+12),te=zt(e,Z+16),X=zt(e,Z+20),J=zt(e,Z+24),de=zt(e,Z+28);V.push({imageId:zt(e,Z)|0,duration:zt(e,Z+4),x:K,y:re,width:Math.hypot(te,X)||F,height:Math.hypot(J,de)||R,uDir:[te,X],vDir:[J,de],rotated:Math.abs(X)>.5||Math.abs(J)>.5})}V.length===_&&V.every(W=>{if(!(W.width>0&&W.height>0))return!1;const Z=[W.x,W.x+W.uDir[0],W.x+W.vDir[0],W.x+W.uDir[0]+W.vDir[0]],K=[W.y,W.y+W.uDir[1],W.y+W.vDir[1],W.y+W.uDir[1]+W.vDir[1]];return Math.min(...Z)>=-1&&Math.max(...Z)<=A+1&&Math.min(...K)>=-1&&Math.max(...K)<=h+1})&&(b={magic:v,frameWidth:F,frameHeight:R,atlasWidth:A,atlasHeight:h,list:V})}}}return{format:o,formatName:kr[o]||String(o),flags:i,textureWidth:s,textureHeight:a,width:c,height:u,freeImageFormat:f,containerMagic:l,containerVersion:d,isVideo:w,images:M,frames:b}}function or(e,n,t){let r="";for(let o=n;o<n+t;o++)r+=String.fromCharCode(e[o]);return r}const $s=Object.freeze(Object.defineProperty({__proto__:null,FIF:jt,TEXTURE_FORMATS:kr,decodeMip0:Ts,decodeMips:Ss,decodePixels:Nr,lz4Decompress:To,parseTex:Os},Symbol.toStringTag,{value:"Module"}));function Eo(e,n){if(!e||typeof n!="string")return null;const t=e[n];return t&&typeof t=="object"?t:null}function Dr(e){return typeof e=="string"?e:e&&typeof e=="object"&&typeof e.name=="string"?e.name:null}function js(e,n){return ir(e)&&ir(n)?Number(e)===Number(n):String(e)===String(n)}function Br(e){if(typeof e=="boolean")return"bool";if(typeof e=="number")return Number.isFinite(e)?"num":"other";if(typeof e=="string"){const n=e.trim().split(/\s+/);return n.length>0&&n[0]!==""&&n.every(t=>Number.isFinite(Number(t)))?"num":"text"}return"other"}function zs(e){switch(e.type){case"bool":return"bool";case"slider":return"num";case"color":return"num";case"textinput":return"text";default:return Br(e.value)}}function Po(e,n){if(e===null||typeof e!="object")return e;if(e.user&&typeof e.user=="object"&&typeof e.user.name=="string"){const r=Eo(n,e.user.name);if(!r||r.value===void 0||r.value===null)return e.value;const o=r.type==="combo"?Ir(r.value,r.options):r.value;return js(o,e.user.condition)}if(typeof e.user!="string")return e;const t=Eo(n,e.user);if(!t||t.value===void 0||t.value===null)return e.value;if(t.userOverridden)return t.value;if(e.value!==null&&typeof e.value=="object")return e.value;if(e.value===void 0)return t.value;if(Br(e.value)==="bool"&&t.type==="slider"){const r=Number(t.value);return Number.isFinite(r)?r!==0:e.value}return Br(e.value)===zs(t)?t.value:e.value}function mn(e,n,t){if(t>32||e===null||typeof e!="object")return e;if(Array.isArray(e)){for(let r=0;r<e.length;r++)e[r]=mn(e[r],n,t+1);return e}if(Dr(e.user)){let r=Po(e,n);for(let o=0;o<8&&r!==null&&typeof r=="object"&&Dr(r.user);o++)r=Po(r,n);return e.value=mn(r,n,t+1),e}for(const r of Object.keys(e))e[r]=mn(e[r],n,t+1);return e}function Vs(e){return e?Array.isArray(e)?e.map(n=>n&&typeof n=="object"&&"value"in n?n.value:n):typeof e=="object"?Object.values(e):[]:[]}function ir(e){return typeof e=="number"?Number.isInteger(e):typeof e=="string"&&/^-?\d+$/.test(e.trim())}function Ir(e,n){const t=Vs(n);return!(t.length>0?t.every(ir):ir(e))||typeof e=="number"&&Number.isFinite(e)?e:typeof e=="string"&&/^-?\d+$/.test(e.trim())?Number(e):e}function Ws(e){const n={};if(!e||typeof e!="object")return n;for(const[t,r]of Object.entries(e))!r||typeof r!="object"||!("value"in r)||(n[t]=r.type==="combo"?Ir(r.value,r.options):r.value);return n}function wt(e){return e&&typeof e=="object"?Dr(e.user):null}function Hs(e,n,t){const r={};if(!t||typeof t!="object")return r;const o=e&&typeof e=="object"?e:{},i=n&&typeof n=="object"?n:{};for(const[s,a]of Object.entries(t)){const c=a&&typeof a=="object"&&"value"in a?a.value:a,u=o[s];if(u&&typeof u=="object"){u.value=c,u.userOverridden=!0;const l=u.type==="combo"?Ir(u.value,u.options):u.value;i[s]=l,r[s]=l}else i[s]=c,r[s]=c}return r}function gn(e){typeof e=="object"&&e!==null&&(e=e.value);const n=String(e??"").trim().split(/\s+/).map(Number);return n.length===1?[n[0]||0,n[0]||0,n[0]||0]:[n[0]||0,n[1]||0,n[2]||0]}function Cn(e){typeof e=="object"&&e!==null&&(e=e.value);const n=String(e??"").trim().split(/\s+/).map(Number);return n.length===1?[n[0]||0,n[0]||0]:[n[0]||0,n[1]||0]}function sr(e){return e==null?[1,1,1]:typeof e=="string"?gn(e):typeof e=="object"&&e!==null?gn(e.value):[1,1,1]}function it(e,n=!1){if(e==null)return n;if(typeof e=="boolean")return e;if(typeof e=="number")return e!==0;if(typeof e=="object"&&e!==null){const t=e.value;return typeof t=="number"?t!==0:!!t}return n}function ut(e,n){if(typeof e=="number")return e;if(e!==null&&typeof e=="object"){const t=Number(e.value);return Number.isFinite(t)?t:n}return n}function Or(e){return e?!e.image&&!e.model&&!e.particle&&e.text==null&&!e.size:!1}function $r(e,n,t){const r=t?e.scale:[1,1,1],o=(e.angles[2]||0)*Math.PI/180,i=Math.cos(o),s=Math.sin(o),a=n.origin[0]*r[0],c=n.origin[1]*r[1];return{origin:[e.origin[0]+a*i-c*s,e.origin[1]+a*s+c*i,e.origin[2]+(n.origin[2]||0)],scale:[r[0]*n.scale[0],r[1]*n.scale[1],r[2]*n.scale[2]],angles:[n.angles[0],n.angles[1],(e.angles[2]||0)+n.angles[2]]}}function Xs(e,n){const t=n&&n.general&&n.general.properties||{},r=e.objects||[];mn(r,t,0),mn(e.general||{},t,0);const o=new Map;for(const m of r)m.id!==void 0&&o.set(m.id,m);const i=r.map(m=>({id:m.id,parent:m.parent,origin:gn(m.origin||"0 0 0"),scale:gn(m.scale||"1 1 1"),angles:gn(m.angles||"0 0 0")})),s=i.map(m=>({origin:m.origin.slice(),scale:m.scale.slice(),angles:m.angles.slice()}));for(let m=0;m<8;m++){let A=!1;for(const h of i){if(h.parent===void 0||h.parent===null||!o.get(h.parent))continue;const v=i.findIndex(V=>V.id===h.parent);if(v<0)continue;const T=i[v];if(T.parent!==void 0&&T.parent!==null)continue;const _=r[v],F=_.scale,k=!(F!==null&&typeof F=="object"&&(typeof F.script=="string"||F.user!==void 0)&&Or(_)),U=$r(T,h,k);h.origin=U.origin,h.scale=U.scale,h.angles=U.angles,h.parent=null,A=!0}if(!A)break}const a=r.map(m=>it(m.visible,!0)),c=new Map;r.forEach((m,A)=>{m.id!==void 0&&c.set(m.id,A)});const u=new Map,l=new Map;for(const m of r)if(m.parent!==void 0&&m.parent!==null){u.set(m.parent,(u.get(m.parent)||0)+1);const A=m.id!==void 0?m.id:null;if(A!==null){const h=l.get(m.parent);h?h.push(A):l.set(m.parent,[A])}}const p=r.map(()=>!0);for(let m=0;m<r.length;m++){let A=a[m],h=r[m].parent;for(let b=0;A&&h!==void 0&&h!==null&&b<64;b++){const v=c.get(h);if(v===void 0)break;a[v]||(A=!1),h=r[v].parent}p[m]=A}const f=r.map((m,A)=>{const h=i[A],b=typeof m.image=="string"&&(m.image.indexOf("models/util/projectlayer")===0||m.image.indexOf("models/util/fullscreenlayer")===0);let v=Cn(m.size||"0 0"),T=h.origin;if(b){const _=(e.general||{}).orthogonalprojection,F=_&&Number(_.width),R=_&&Number(_.height);F>0&&R>0&&(v=[F,R],T=[F/2,R/2,h.origin[2]||0])}return{id:m.id!==void 0?m.id:A,name:m.name||"",visible:p[A],visibleSelf:a[A],srcObject:m,image:typeof m.image=="string"?m.image:null,model:typeof m.model=="string"?m.model:null,isSkybox:typeof m.name=="string"&&m.name.indexOf("\u5929\u7A7A\u76D2")>=0,particle:typeof m.particle=="string"?m.particle:null,instanceoverride:m.instanceoverride||null,sound:Array.isArray(m.sound)?m.sound.filter(_=>typeof _=="string"):[],soundprops:{volume:ut(m.volume,1),playbackmode:m.playbackmode||"single",startsilent:it(m.startsilent,!1),maxtime:ut(m.maxtime,0),mintime:ut(m.mintime,0),spatialization:it(m.spatialization,!1),muteineditor:it(m.muteineditor,!1)},text:typeof m.text=="string"?m.text:m.text&&typeof m.text=="object"?m.text.value:null,textScript:m.text&&typeof m.text=="object"&&m.text.script||null,textScriptProps:m.text&&typeof m.text=="object"&&m.text.scriptproperties||null,component:typeof m.component=="string"?m.component:null,isText:m.text!==void 0&&m.text!==null,textFont:typeof m.font=="string"?m.font:null,textPointsize:ut(m.pointsize,24)||24,textColor:sr(m.color),textAnchor:typeof m.anchor=="string"&&m.anchor!=="none"?m.anchor:"center",textMaxwidth:ut(m.maxwidth,0),textMaxrows:ut(m.maxrows,0),textLimitwidth:it(m.limitwidth,!1),textLimitrows:it(m.limitrows,!1),textLimituseellipsis:it(m.limituseellipsis,!1),textHAlign:m.horizontalalign||"center",textVAlign:m.verticalalign||"center",textSpacing:m.spacing?Cn(m.spacing):[0,0],textPadding:(()=>{const _=m.padding;if(typeof _=="number")return _;const F=String(_??"").trim().split(/\s+/).map(Number).filter(R=>Number.isFinite(R));return F.length?F.reduce((R,k)=>R+k,0)/F.length:0})(),textOpaquebackground:it(m.opaquebackground,!1),textBackgroundcolor:sr(m.backgroundcolor),textBackgroundbrightness:ut(m.backgroundbrightness,1),textCastshadow:it(m.castshadow,!1),isSound:!!(m.sound&&m.sound.length),isComponent:!!m.component,objectScripts:(()=>{const _={};for(const F of["scale","origin","color","alpha","brightness","angles","visible"]){const R=m[F];R&&typeof R=="object"&&typeof R.script=="string"&&R.script&&(_[F]={script:R.script,scriptproperties:R.scriptproperties||null,value:R.value})}return Object.keys(_).length?_:null})(),objectAnimations:(()=>{const _={};for(const F of["scale","origin","color","alpha","brightness","angles","visible","volume","maxwidth","zoom"]){const R=m[F];R&&typeof R=="object"&&R.animation&&typeof R.animation=="object"&&R.animation.options&&(_[F]={animation:R.animation,value:R.value})}return Object.keys(_).length?_:null})(),animationLayers:(m.animationlayers||[]).filter(_=>_&&typeof _.animation=="number").map(_=>({animation:_.animation,visible:it(_.visible,!0),additive:it(_.additive,!1),blend:ut(_.blend,1),rate:ut(_.rate,1)})),solid:(()=>{if(typeof m.particle=="string")return!1;const _=typeof m.image=="string"?m.image:"";return _.indexOf("models/util/composelayer")===0?!1:_.indexOf("models/util/solidlayer")===0?!0:m.solid?!_||_.indexOf("models/util/")===0:!1})(),isContainer:typeof m.image=="string"&&m.image.indexOf("models/util/composelayer")===0,hasChildren:(u.get(m.id!==void 0?m.id:A)||0)>0,childIds:l.get(m.id!==void 0?m.id:A)||null,parentId:m.parent!==void 0&&m.parent!==null?m.parent:null,attachment:typeof m.attachment=="string"&&m.attachment!==""?m.attachment:null,passthrough:!!(m.config&&m.config.passthrough===!0),isPostProcess:b,origin:T,scale:h.scale,angles:h.angles,localOrigin:s[A].origin,localScale:s[A].scale,localAngles:s[A].angles,renderInert:Or(m),scaleRuntimeBound:m.scale!==null&&typeof m.scale=="object"&&(typeof m.scale.script=="string"||m.scale.user!==void 0),size:v,alignment:m.alignment||"center",color:sr(m.color),alpha:ut(m.alpha,1),brightness:ut(m.brightness,1),copybackground:!!m.copybackground,colorBlendMode:m.colorBlendMode||0,parallaxDepth:m.parallaxDepth!==void 0?Cn(m.parallaxDepth):null,effects:(m.effects||[]).map(_=>({file:_.file||"",name:typeof _.name=="string"?_.name:"",visible:it(_.visible,!0),visibleScript:_.visible&&typeof _.visible=="object"&&typeof _.visible.script=="string"&&_.visible.script?{script:_.visible.script,scriptproperties:_.visible.scriptproperties||null,value:!!_.visible.value}:null,passes:(_.passes||[]).map(F=>({combos:F.combos||{},constantshadervalues:F.constantshadervalues||{},textures:F.textures||[]}))}))}}),d=e.general||{},w=(()=>{const m={};for(const[A,h]of Object.entries(d))h&&typeof h=="object"&&typeof h.script=="string"&&h.script&&(m[A]={script:h.script,scriptproperties:h.scriptproperties||null,value:h.value});return Object.keys(m).length?m:null})(),M=(()=>{const m={};for(const[A,h]of Object.entries(d))h&&typeof h=="object"&&h.animation&&typeof h.animation=="object"&&h.animation.options&&(m[A]={animation:h.animation,value:h.value});return Object.keys(m).length?m:null})();{const m=new Map;for(const A of f)A.id!==void 0&&m.set(A.id,A);for(let A=0;A<8;A++){let h=!1;for(const b of f){if(b.parallaxDepth||b.parentId==null)continue;const v=m.get(b.parentId);!v||!v.parallaxDepth||v.image||v.particle||v.model||(b.parallaxDepth=v.parallaxDepth.slice(),h=!0)}if(!h)break}}return{camera:e.camera||null,general:d,generalScripts:w,generalAnimations:M,layers:f,properties:t}}function Gs(e){if(!Array.isArray(e))return;const n=new Map;for(const t of e)t&&t.id!==void 0&&t.id!==null&&n.set(t.id,t);for(const t of e){if(!t)continue;if(t.destroyed){t.visible=!1;continue}let r=t.visibleSelf!==!1,o=t.parentId;for(let i=0;r&&o!=null&&i<64;i++){const s=n.get(o);if(!s)break;(s.visibleSelf===!1||s.destroyed)&&(r=!1),o=s.parentId}t.visible=r}}function qs(e,n){!e||!n||typeof n!="object"||e.isContainer||n.solidlayer===!0&&(e.solid=!0)}function Ys(e){return!e||typeof e.material!="string"?null:{materialPath:e.material,autosize:!!e.autosize,cropoffset:e.cropoffset?Cn(e.cropoffset):null}}function Zs(e,n){if(!e||e.length===0)return;const t=new Map;for(const i of e)i&&i.id!==void 0&&i.id!==null&&t.set(i.id,i);const r=i=>{let s=0,a=i.parentId;for(let c=0;a!=null&&c<64;c++){const u=t.get(a);if(!u)break;s++,a=u.parentId}return s},o=[];for(const i of e)!i||!i.localOrigin||i.isPostProcess||n&&!n.has(i.id)||o.push(i);o.sort((i,s)=>r(i)-r(s));for(const i of o){const s=i.parentId!==void 0&&i.parentId!==null?t.get(i.parentId):null;let a;if(!s)a={origin:i.localOrigin.slice(),scale:i.localScale.slice(),angles:i.localAngles.slice()};else{const u=!(s.scaleRuntimeBound&&s.renderInert);a=$r({origin:s.origin,scale:s.scale,angles:s.angles},{origin:i.localOrigin,scale:i.localScale,angles:i.localAngles},u)}const c=i.attachBindDelta;c&&(a.origin[0]+=c[0],a.origin[1]+=c[1]),i.origin[0]=a.origin[0],i.origin[1]=a.origin[1],i.origin[2]=a.origin[2],i.scale[0]=a.scale[0],i.scale[1]=a.scale[1],i.scale[2]=a.scale[2],i.angles[0]=a.angles[0],i.angles[1]=a.angles[1],i.angles[2]=a.angles[2],i.attachBase&&(i.attachBase[0]=a.origin[0],i.attachBase[1]=a.origin[1])}}function Ks(e,n){const t=new Set;if(!e||e.length===0)return t;const r=new Map;for(const a of e){if(!a||a.parentId===void 0||a.parentId===null)continue;const c=r.get(a.parentId);c?c.push(a):r.set(a.parentId,[a])}const o=["origin","scale","angles"],i=[];for(const a of e){if(!a||a.id===void 0||a.id===null)continue;const c=a.objectScripts||null,u=a.objectAnimations||null;o.some(p=>c&&c[p]||u&&u[p])&&i.push(a)}if(n)for(const a of n)a&&a.id!==void 0&&a.id!==null&&i.push(a);const s=i.slice();for(let a=0;s.length>0&&a<1e5;a++){const c=s.pop();if(!c||c.id===void 0||c.id===null||t.has(c.id))continue;t.add(c.id);const u=r.get(c.id);if(u)for(const l of u)s.push(l)}return t}const Qs=Object.freeze(Object.defineProperty({__proto__:null,applySolidFromModel:qs,collectTransformDirty:Ks,composeChildTransform:$r,isRenderInert:Or,parseBool:it,parseColor:sr,parseNum:ut,parseScene:Xs,parseVec2:Cn,parseVec3:gn,recomposeWorld:Zs,recomputeLayerVisibility:Gs,resolveMaterial:Ys},Symbol.toStringTag,{value:"Module"}));function Js(e,n,t){const r=Fr(e,n.file);if(r===null)return;let o;try{o=JSON.parse(t(r))}catch{return}n.fbos=o.fbos||[],n.materialPasses=(o.passes||[]).map(i=>{if(!i.material)return{shader:null,copyCommand:!0,target:i.target||null,source:i.source||null,binds:i.bind||[],blending:"normal",textures:[],combos:{},constants:{}};const s=Fr(e,i.material);if(s===null)return{shader:null,copyCommand:!1,target:i.target||null,binds:i.bind||[],blending:"normal",textures:[],combos:{},constants:{}};const a=JSON.parse(t(s)),c=a.passes&&a.passes[0]||{};return{shader:c.shader||null,copyCommand:!1,target:i.target||null,binds:i.bind||[],blending:c.blending||"normal",textures:c.textures||[],combos:c.combos||{},constants:c.constantshadervalues||{}}})}const ea={"models/util/solidlayer.json":{material:"materials/util/solidlayer.json"},"models/util/composelayer.json":{material:"materials/util/solidlayer.json"},"models/util/fullscreenlayer.json":{material:"materials/util/solidlayer.json"},"models/util/projectlayer.json":{material:"materials/util/solidlayer.json"}};function Co(e){if(!e||typeof e!="string")return!0;const n=e.toLowerCase();return n==="generic"||n==="sprite"||n==="flat"||n.startsWith("genericimage")}function ta(e,n){return!e||!n||!n.shader||Co(n.shader)||(e.effects=e.effects||[],e.effects.some(t=>t.layerMaterial))?!1:(e.effects.unshift({file:"",name:"_layerMaterial",visible:!0,layerMaterial:!0,passes:[{combos:n.combos||{},constantshadervalues:n.constantshadervalues||{},textures:n.textures||[]}],materialPasses:[{shader:n.shader,copyCommand:!1,target:null,binds:[],blending:n.blending||"normal",textures:n.textures||[],combos:n.combos||{},constants:n.constantshadervalues||{}}],fbos:[]}),!0)}const na={"materials/util/solidlayer.json":{passes:[{shader:"flat",blending:"translucent",cullmode:"nocull",depthtest:"disabled",depthwrite:"disabled",textures:[],combos:{}}]}},ra=Object.freeze(Object.defineProperty({__proto__:null,BUILTIN_MATERIALS:na,BUILTIN_MODELS:ea,attachLayerMaterialEffect:ta,isBuiltinAlbedoShader:Co,resolveEffectChain:Js},Symbol.toStringTag,{value:"Module"}));function bn(){return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function Mt(e,n){const t=new Float32Array(16);for(let r=0;r<4;r++)for(let o=0;o<4;o++){let i=0;for(let s=0;s<4;s++)i+=e[s*4+o]*n[r*4+s];t[r*4+o]=i}return t}function yn(e,n,t,r,o,i){const s=bn();return s[0]=2/(n-e),s[5]=2/(r-t),s[10]=-2/(i-o),s[12]=-(n+e)/(n-e),s[13]=-(r+t)/(r-t),s[14]=-0/(i-o),s}function vn(e,n,t,r){return Mt(e,new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,n,t,r,1]))}function Lo(e){const n=new Float32Array(16);for(let t=0;t<4;t++)for(let r=0;r<4;r++)n[r*4+t]=e[t*4+r];return n}function Ln(e,n,t,r){return Mt(e,new Float32Array([n,0,0,0,0,t,0,0,0,0,r,0,0,0,0,1]))}function Ro(e,n){const t=Math.cos(n),r=Math.sin(n);return Mt(e,new Float32Array([t,r,0,0,-r,t,0,0,0,0,1,0,0,0,0,1]))}function oa(e,n){const t=Math.cos(n),r=Math.sin(n);return Mt(e,new Float32Array([1,0,0,0,0,t,r,0,0,-r,t,0,0,0,0,1]))}function ia(e,n){const t=Math.cos(n),r=Math.sin(n);return Mt(e,new Float32Array([t,0,-r,0,0,1,0,0,r,0,t,0,0,0,0,1]))}function sa(e,n,t,r){const o=1/Math.tan(e*Math.PI/180/2),i=new Float32Array(16);return i[0]=o/(n||1),i[5]=o,i[10]=(r+t)/(t-r),i[11]=-1,i[14]=2*r*t/(t-r),i}function ar(e,n){const t=e&&typeof e=="object"?e.value:e;return typeof t=="number"&&Number.isFinite(t)?t:n}function aa(e){const n=e&&e.general;return!n||n.orthogonalprojection?!1:ar(n.fov,0)>0}function ca(e,n){return n&&n.perspective&&e&&e.isSkybox&&n.eye?n.eye:e.origin}function la(e,n,t){const r=ko([e[0]-n[0],e[1]-n[1],e[2]-n[2]]),o=ko(No(t,r)),i=No(r,o),s=new Float32Array([o[0],i[0],r[0],0,o[1],i[1],r[1],0,o[2],i[2],r[2],0,0,0,0,1]);return s[12]=-(o[0]*e[0]+o[1]*e[1]+o[2]*e[2]),s[13]=-(i[0]*e[0]+i[1]*e[1]+i[2]*e[2]),s[14]=-(r[0]*e[0]+r[1]*e[1]+r[2]*e[2]),s}function ua(e,n,t,r){const o=e[3]*n+e[7]*t+e[11]*r+e[15];return[(e[0]*n+e[4]*t+e[8]*r+e[12])/o,(e[1]*n+e[5]*t+e[9]*r+e[13])/o,(e[2]*n+e[6]*t+e[10]*r+e[14])/o]}const fa=[[16,9],[16,10],[21,9],[32,9]];function da(e,n,t,r,o){const i=e/n;if(!Number.isFinite(i)||i<=0||!(t>0)||!(r>0))return null;const s=.02,a=t/r;if(Math.abs(i-a)<=s*a)return{viewW:t,viewH:r};for(const[c,u]of fa){const l=c/u;if(Math.abs(i-l)>s*l)continue;const p=r,f=r*l;return f>t+1e-6?{viewW:t,viewH:t/l}:{viewW:f,viewH:p}}return null}function jr(e,n,t,r,o,i,s){const a=Fo(i),c=Fo(s);if(e==="cover"){const u=da(r,o,n,t);if(u)return{offX:(n-u.viewW)*a,offY:(t-u.viewH)*c,viewW:u.viewW,viewH:u.viewH};const l=Math.max(r/n,o/t),p=r/l,f=o/l;return{offX:(n-p)*a,offY:(t-f)*c,viewW:p,viewH:f}}if(e==="contain"){const u=r/o;if(n/t>u){const d=n,w=n/u;return{offX:0,offY:(t-w)/2,viewW:d,viewH:w}}const p=t,f=t*u;return{offY:0,offX:(n-f)/2,viewW:f,viewH:p}}return{offX:0,offY:0,viewW:n,viewH:t}}function pa(e,n,t,r,o,i){const s=e.general,a=e.camera,c=a&&a.eye?zr(a.eye):[0,0,0],u=a&&a.center?zr(a.center):[0,0,-1],l=a&&a.up?zr(a.up):[0,1,0];if(aa(e)){const b=t>0?n/t:1.7777777777777777,v=ar(s.fov,50),T=Math.max(ar(s.nearz,.01),1e-4),_=Math.max(ar(s.farz,1e4),T+1),F=la(c,u,l),R=sa(v,b,T,_);return{view:F,projection:R,eye:c,center:u,projW:b,projH:1,offX:0,offY:0,viewW:b,viewH:1,perspective:!0}}const p=bn(),f=s&&s.orthogonalprojection&&s.orthogonalprojection.width||n,d=s&&s.orthogonalprojection&&s.orthogonalprojection.height||t,w=jr(r,f,d,n,t,o,i),M=e&&e.cameraTransforms?e.cameraTransforms.zoom:s&&s.zoom,m=M&&typeof M=="object"?M.value:M,A=Number(m);if(Number.isFinite(A)&&A>0&&Math.abs(A-1)>1e-6){const b=w.offX+w.viewW/2,v=w.offY+w.viewH/2,T=w.viewW/A,_=w.viewH/A;w.offX=b-T/2,w.offY=v-_/2,w.viewW=T,w.viewH=_}const h=yn(w.offX,w.offX+w.viewW,w.offY+w.viewH,w.offY,-1e4,1e4);return{view:p,projection:h,eye:c,projW:f,projH:d,offX:w.offX,offY:w.offY,viewW:w.viewW,viewH:w.viewH,perspective:!1}}function Fo(e){const n=Number(e);return Number.isFinite(n)?n<0?0:n>1?1:n:.5}function zr(e){return String(e).trim().split(/\s+/).map(Number)}function ko(e){const n=Math.hypot(e[0],e[1],e[2])||1;return[e[0]/n,e[1]/n,e[2]/n]}function No(e,n){return[e[1]*n[2]-e[2]*n[1],e[2]*n[0]-e[0]*n[2],e[0]*n[1]-e[1]*n[0]]}function xn(e){const n=Number(e);return Number.isFinite(n)?n*.5:0}function ha(e){const n=new Map,t=new Map,r=/^[ \t]*#define[ \t]+([A-Za-z_][A-Za-z0-9_]*)(?:\(([^)]*)\))?[ \t]*(.*)$/gm;let o;for(;(o=r.exec(e))!==null;){const i=s=>s.replace(/\/\/.*$/,"").replace(/\/\*[\s\S]*?\*\//g,"").trim();o[2]!==void 0?t.set(o[1],{args:o[2].split(",").map(s=>s.trim()).filter(Boolean),body:i(o[3])}):n.set(o[1],i(o[3]))}return{defs:n,fns:t}}function ma(e,n,t,r){const o=[];let i=0;for(;i<e.length;){const s=e.indexOf(n,i);if(s===-1){o.push(e.slice(i));break}o.push(e.slice(i,s));let c=s+n.length;for(;c<e.length&&/\s/.test(e[c]);)c++;if(e[c]!=="("){o.push(e.slice(s,c)),i=c;continue}let u=0,l=c;for(;l<e.length;l++)if(e[l]==="(")u++;else if(e[l]===")"&&(u--,u===0))break;if(l>=e.length){o.push(e.slice(s));break}const p=e.slice(c+1,l),f=Rt(p);let d=t.body;t.args.forEach((w,M)=>{const m=f[M]!==void 0?f[M].trim():"";d=Rn(d,w,m)}),r>0&&(d=Uo(d,r-1)),o.push("("+d+")"),i=l+1}return o.join("")}function Rn(e,n,t){return e.replace(new RegExp("\\b"+n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+"\\b","g"),t)}function Rt(e){const n=[];let t=0,r="";for(let o=0;o<e.length;o++){const i=e[o];i==="("?t++:i===")"&&t--,i===","&&t===0?(n.push(r),r=""):r+=i}return r.trim()!==""&&n.push(r),n}function Uo(e,n){for(let t=0;t<12;t++){const{defs:r,fns:o}=ha(e);if(r.size===0&&o.size===0)break;const i=e.split(`
|
|
2
|
-
`),s=new Map;for(let u=0;u<i.length;u++){const l=/^[ \t]*#define[ \t]+([A-Za-z_][A-Za-z0-9_]*)/.exec(i[u]);l&&!s.has(l[1])&&s.set(l[1],u)}const a=new Map;{const u="(?:float|int|bool|vec[234]|ivec[234]|bvec[234]|mat[234])";for(const l of r.keys()){const
|
|
3
|
-
`),!c)break}return e}function
|
|
1
|
+
function rr(e,n){const t=n?.renderDpr??e.cfg?.renderDpr??1;return Math.min(window.devicePixelRatio||1,t)}function pn(e){return e==="fit"?"contain":e==="fill"?"cover":e==="contain"||e==="stretch"?e:"cover"}function _o(e){const n=pn(e);return n==="contain"?{objectFit:"contain",background:"rgba(10,12,16,0.85)"}:n==="stretch"?{objectFit:"fill",background:"transparent"}:{objectFit:"cover",background:"transparent"}}function Es(e){return{cfg:{type:"canvas"},coverAlign:{x:.5,y:.5,tx:.5,ty:.5},frameMeter:{stamps:[],last:0,fps:0},disposers:[]}}(()=>{const e=n=>n.preventDefault();window.addEventListener("contextmenu",e,!0),document.addEventListener("contextmenu",e,!0),window.__blockContextMenu=n=>n.addEventListener("contextmenu",e,!0)})();function on(e){if(e.iframe)try{e.iframe.contentWindow?.location.replace("about:blank")}catch{}if(e.wrap)e.wrap.innerHTML="";else if(e.iframe?.isConnected)try{e.iframe.remove()}catch{}e.raf!==void 0&&cancelAnimationFrame(e.raf),e.raf=void 0;for(const t of e.videoPairs??[])t.destroy();if(e.videoPairs=void 0,e.sceneCleanup)try{e.sceneCleanup()}catch{}e.sceneCleanup=void 0,e.sceneCtl=void 0,e.pointerCtl=void 0,e.mediaCtl=void 0;const n=e.wallpaperDisposers??[];e.wallpaperDisposers=[];for(const t of n)try{t()}catch{}e.renderer&&(e.renderer.dispose?.(),e.renderer=void 0);for(const t of e.videoTextures??[])t.pause(),t.removeAttribute("src"),t.load(),t.remove();e.videoTextures=void 0;for(const t of e.objectUrls??[])try{URL.revokeObjectURL(t)}catch{}if(e.objectUrls=void 0,e.sceneAudio){for(const t of e.sceneAudio.audios)t.pause(),t.removeAttribute("src"),t.load();e.sceneAudio=void 0}if(e.video){e.video.pause(),e.video.removeAttribute("src");try{e.video.load()}catch{}e.video.remove()}e.video=void 0,e.img=void 0,e.iframe=void 0,e.canvas=void 0,e.ctx=void 0,e.info=void 0,Fs(),To(e)}function Ps(e){try{on(e)}catch{}e.peekRaf!==void 0&&(cancelAnimationFrame(e.peekRaf),e.peekRaf=void 0);for(const n of e.disposers.splice(0))try{n()}catch{}e.wrap?.remove(),e.wrap=void 0}const Cs=new TextDecoder,xt=e=>Cs.decode(e).replace(/^\uFEFF/,""),Ao=500;function Fn(e,n){const t=e.frameMeter.stamps;t.push(n),e.frameMeter.last=n;const r=n-Ao;for(;t.length&&t[0]<r;)t.shift();const o=t.length>=2?t[t.length-1]-t[0]:0;e.frameMeter.fps=o>0?(t.length-1)*1e3/o:0}function To(e){e.frameMeter.stamps.length=0,e.frameMeter.last=0,e.frameMeter.fps=0}function Ls(e){return!e.frameMeter.last||e.paused?{fps:0,running:!1}:performance.now()-e.frameMeter.last>Math.max(Ao,400)?{fps:0,running:!1}:{fps:e.frameMeter.fps,running:!0}}function se(e,n,t){try{e.onDiagnostic?.(t,/fail|error|失败|ERROR/.test(t)?"error":"info")}catch{}try{const r=n.mediaBase?new URL(n.mediaBase,window.location.href).origin:"";if(r){const o=new Image;o.src=`${r}/diag?msg=${encodeURIComponent(`scene ${n.src??"?"}: ${t.slice(0,500)}`)}`}}catch{}}function Fr(e){e.coverAlign.x=e.coverAlign.y=e.coverAlign.tx=e.coverAlign.ty=.5,Rs(e)}function Rs(e){const n=`${(e.coverAlign.x*100).toFixed(2)}% ${(e.coverAlign.y*100).toFixed(2)}%`,t=e.video??e.img;t&&t.isConnected&&(t.style.objectPosition=n)}const ks=["__scene","__sceneLayers","__textures","__objScripts","__textWidgets","__mediaHooks","__mediaControl","__mediaStats","__mediaSet","__system","__liveSystem","__audioStats","__audioMute","__particleStats","__particleToggle","__pointerStats","__compositeStats","__compositeEnable"];function Fs(){const e=window;for(const n of ks)n in e&&delete e[n]}function So(e,n,t){const r=rr(e,t),o=Math.max(1,Math.round((n.clientWidth||window.innerWidth||1)*r)),i=Math.max(1,Math.round((n.clientHeight||window.innerHeight||1)*r));return n.width===o&&n.height===i?!1:(n.width=o,n.height=i,!0)}function Ns(e){const n=new DataView(e.buffer,e.byteOffset,e.byteLength);if(e.length<16)throw new Error("\u6587\u4EF6\u592A\u5C0F\uFF0C\u4E0D\u662F scene.pkg");const t=n.getUint32(0,!0);if(t<4||t>16)throw new Error("\u9B54\u6570\u957F\u5EA6\u5F02\u5E38: "+t);const r=Eo(e,4,t);if(!r.startsWith("PKGV"))throw new Error("\u4E0D\u662F scene.pkg\uFF0C\u9B54\u6570: "+r);const o=n.getUint32(4+t,!0);let i=4+t+4;const s=[];for(let c=0;c<o;c++){if(i+8>e.length)throw new Error("\u5165\u53E3\u8868\u8D8A\u754C @"+c);const u=n.getUint32(i,!0);if(i+=4,i+u+8>e.length)throw new Error("\u5165\u53E3 "+c+" \u8D8A\u754C");const l=Ds(e,i,u);i+=u;const f=n.getUint32(i,!0);i+=4;const p=n.getUint32(i,!0);i+=4,s.push({name:l,offset:f,size:p})}const a=i;return{magic:r,version:r.slice(4),count:o,entries:s,dataStart:a,fileSize:e.length,buf:e}}function Nr(e,n){const t=e.entries.find(i=>i.name===n);if(t===void 0)return null;const r=e.dataStart+t.offset,o=r+t.size;if(r<0||o>e.fileSize)throw new Error("\u5165\u53E3 "+n+" \u8D8A\u754C");return e.buf.subarray(r,o)}function Us(e){let n=0;for(const t of e.entries)n=Math.max(n,t.offset+t.size);return{dataEnd:e.dataStart+n,fileSize:e.fileSize,ok:e.dataStart+n<=e.fileSize}}function Eo(e,n,t){let r="";for(let o=n;o<n+t;o++)r+=String.fromCharCode(e[o]);return r}function Ds(e,n,t){try{return new TextDecoder("utf-8",{fatal:!0}).decode(e.subarray(n,n+t))}catch{return Eo(e,n,t)}}const Bs=Object.freeze(Object.defineProperty({__proto__:null,getEntry:Nr,parsePkg:Ns,verifyLayout:Us},Symbol.toStringTag,{value:"Module"})),Ur={0:"ARGB8888",1:"RGB888",2:"RGB565",4:"DXT5",6:"DXT3",7:"DXT1",8:"RG88",9:"R8",10:"RG1616f",11:"R16f",12:"BC7",13:"RGBa1010102",14:"RGBA16161616f",15:"RGB161616f"},Yt={UNKNOWN:-1,JPEG:2,PNG:13,GIF:25,WEBP:35,MP4:35};function Is(e){const n=e.images[0];if(!n||n.length===0)throw new Error("\u65E0\u56FE\u50CF\u6570\u636E");const t=n[0];if(e.isVideo)return{width:t.width,height:t.height,video:t.data};if(e.freeImageFormat===Yt.PNG)return{width:t.width,height:t.height,png:t.data};if(e.freeImageFormat!==Yt.UNKNOWN)return{width:t.width,height:t.height,image:t.data,fif:e.freeImageFormat};const r=Dr(e.format,t.data,t.width,t.height);return!e.frames?.list?.length&&(t.width!==e.width||t.height!==e.height)?{width:e.width,height:e.height,rgba:Po(r,t.width,t.height,e.width,e.height)}:{width:t.width,height:t.height,rgba:r}}function Os(e){const n=e.images[0];if(!n||n.length===0)throw new Error("\u65E0\u56FE\u50CF\u6570\u636E");const t=[];for(const r of n){if(e.freeImageFormat!==Yt.UNKNOWN){t.push({width:r.width,height:r.height,image:r.data,fif:e.freeImageFormat});continue}const o=Dr(e.format,r.data,r.width,r.height);t.push({width:r.width,height:r.height,rgba:o})}return!e.frames?.list?.length&&t.length>0&&(t[0].width!==e.width||t[0].height!==e.height)&&t[0].rgba&&(t[0]={width:e.width,height:e.height,rgba:Po(t[0].rgba,t[0].width,t[0].height,e.width,e.height)}),t}function Po(e,n,t,r,o){const i=new Uint8Array(r*o*4);for(let s=0;s<o;s++)i.set(e.subarray(s*n*4,s*n*4+r*4),s*r*4);return i}function Dr(e,n,t,r){switch(e){case 0:return $s(n,t,r);case 1:return js(n,t,r);case 2:return zs(n,t,r);case 4:return Gs(n,t,r);case 6:return Xs(n,t,r);case 7:return Hs(n,t,r);case 8:return Vs(n,t,r);case 9:return Ws(n,t,r);case 12:throw new Error("BC7 \u89E3\u7801\u6682\u672A\u5B9E\u73B0\uFF08format=12\uFF09");default:throw new Error("\u672A\u652F\u6301\u7684\u7EB9\u7406\u683C\u5F0F: "+(Ur[e]||e))}}function $s(e,n,t){return new Uint8Array(e.buffer,e.byteOffset,n*t*4).slice()}function js(e,n,t){const r=new Uint8Array(n*t*4);for(let o=0;o<n*t;o++)r[o*4]=e[o*3],r[o*4+1]=e[o*3+1],r[o*4+2]=e[o*3+2],r[o*4+3]=255;return r}function zs(e,n,t){const r=new Uint8Array(n*t*4);for(let o=0;o<n*t;o++){const i=e[o*2]|e[o*2+1]<<8,s=i>>11&31,a=i>>5&63,c=i&31;r[o*4]=s<<3|s>>2,r[o*4+1]=a<<2|a>>4,r[o*4+2]=c<<3|c>>2,r[o*4+3]=255}return r}function Vs(e,n,t){const r=new Uint8Array(n*t*4);for(let o=0;o<n*t;o++)r[o*4]=e[o*2+1],r[o*4+1]=e[o*2+1],r[o*4+2]=e[o*2+1],r[o*4+3]=e[o*2];return r}function Ws(e,n,t){const r=new Uint8Array(n*t*4);for(let o=0;o<n*t;o++)r[o*4]=e[o],r[o*4+1]=e[o],r[o*4+2]=e[o],r[o*4+3]=255;return r}function Hs(e,n,t){return Br(e,n,t,!0,0)}function Xs(e,n,t){return Br(e,n,t,!1,3)}function Gs(e,n,t){return Br(e,n,t,!1,5)}function Br(e,n,t,r,o){const i=new Uint8Array(n*t*4),s=r?8:16,a=new Uint8Array(16);let c=0;for(let u=0;u<t;u+=4)for(let l=0;l<n;l+=4){if(c+s>e.length)return i;a.set(e.subarray(c,c+s)),c+=s;const f=Ys(a,r),p=qs(a,r),d=o===3?Zs(a):o===5?Ks(a):null;for(let y=0;y<4;y++)for(let x=0;x<4;x++){const m=l+x,M=u+y;if(m>=n||M>=t)continue;const h=y*4+x,g=(M*n+m)*4;i[g]=f[p[h]*4],i[g+1]=f[p[h]*4+1],i[g+2]=f[p[h]*4+2],i[g+3]=d!==null?d[h]:f[p[h]*4+3]}}return i}function Co(e,n){const t=e[n]|e[n+1]<<8,r=t>>11&31,o=t>>5&63,i=t&31;return[t,r<<3|r>>2,o<<2|o>>4,i<<3|i>>2]}function Ys(e,n){const t=n?0:8,r=Co(e,t),o=Co(e,t+2),i=new Uint8Array(16);return i[0]=r[1],i[1]=r[2],i[2]=r[3],i[3]=255,i[4]=o[1],i[5]=o[2],i[6]=o[3],i[7]=255,n&&r[0]<=o[0]?(i[8]=r[1]+o[1]>>1,i[9]=r[2]+o[2]>>1,i[10]=r[3]+o[3]>>1,i[11]=255,i[12]=0,i[13]=0,i[14]=0,i[15]=0):(i[8]=Math.floor((2*r[1]+o[1])/3),i[9]=Math.floor((2*r[2]+o[2])/3),i[10]=Math.floor((2*r[3]+o[3])/3),i[11]=255,i[12]=Math.floor((r[1]+2*o[1])/3),i[13]=Math.floor((r[2]+2*o[2])/3),i[14]=Math.floor((r[3]+2*o[3])/3),i[15]=255),i}function qs(e,n){const t=n?4:12,r=new Uint8Array(16);for(let o=0;o<4;o++){const i=e[t+o];r[o*4]=i&3,r[o*4+1]=i>>2&3,r[o*4+2]=i>>4&3,r[o*4+3]=i>>6&3}return r}function Zs(e){const n=new Uint8Array(16);for(let t=0;t<8;t++){const r=e[t],o=r&15,i=r&240;n[2*t]=o|o<<4,n[2*t+1]=i|i>>4}return n}function Ks(e){const n=e[0],t=e[1],r=new Uint8Array(8);if(r[0]=n,r[1]=t,n<=t){for(let a=1;a<5;a++)r[1+a]=Math.floor(((5-a)*n+a*t)/5);r[6]=0,r[7]=255}else for(let a=1;a<7;a++)r[a+1]=Math.floor(((7-a)*n+a*t)/7);const o=new Uint8Array(16);let i=0;for(let a=0;a<2;a++){let c=0;for(let u=0;u<3;u++)c|=e[2+a*3+u]<<8*u;for(let u=0;u<8;u++)o[i++]=c>>3*u&7}const s=new Uint8Array(16);for(let a=0;a<16;a++)s[a]=r[o[a]];return s}function Lo(e,n){const t=new Uint8Array(n);let r=0,o=0;for(;r<e.length;){const i=e[r++];let s=i>>4;if(s===15){let l;do l=e[r++],s+=l;while(l===255)}for(let l=0;l<s;l++)t[o++]=e[r++];if(r>=e.length)break;const a=e[r]|e[r+1]<<8;r+=2;let c=4+(i&15);if((i&15)===15){let l;do l=e[r++],c+=l;while(l===255)}const u=o-a;for(let l=0;l<c;l++)t[o++]=t[u+l]}return t}function Oe(e,n){return(e[n]|e[n+1]<<8|e[n+2]<<16|e[n+3]<<24)>>>0}function Ro(e,n){return Oe(e,n)|0}const Nn=new DataView(new ArrayBuffer(4));function qt(e,n){return Nn.setUint8(0,e[n]),Nn.setUint8(1,e[n+1]),Nn.setUint8(2,e[n+2]),Nn.setUint8(3,e[n+3]),Nn.getFloat32(0,!0)}function Qs(e){let n=0;const t=or(e,n,9);if(n+=9,t!=="TEXV0005\0")throw new Error("\u4E0D\u662F .tex \u6587\u4EF6: "+t);const r=or(e,n,9);if(n+=9,r!=="TEXI0001\0")throw new Error("\u672A\u77E5 TEXI \u5B50\u5BB9\u5668: "+r);const o=Oe(e,n);n+=4;const i=Oe(e,n);n+=4;const s=Oe(e,n);n+=4;const a=Oe(e,n);n+=4;const c=Oe(e,n);n+=4;const u=Oe(e,n);n+=4,n+=4;const l=or(e,n,9);n+=9;const f=Oe(e,n);n+=4;let p=Yt.UNKNOWN,d=0;if(l==="TEXB0004\0"){p=Oe(e,n)|0,n+=4;const v=Oe(e,n);n+=4,p===Yt.UNKNOWN&&v===1&&(p=Yt.MP4),d=v===1?4:3}else if(l==="TEXB0003\0")p=Oe(e,n)|0,n+=4,d=3;else if(l==="TEXB0002\0")d=2;else if(l==="TEXB0001\0")d=1;else throw new Error("\u672A\u77E5 TEXB \u5BB9\u5668: "+l);const y=(i&32)!==0||p===Yt.MP4,x=[];for(let v=0;v<f;v++){const A=Oe(e,n);n+=4;const _=[];for(let R=0;R<A;R++){if(d===4){for(n+=8;n<e.length&&e[n]!==0;)n++;n+=1,n+=4}const L=Oe(e,n);n+=4;const N=Oe(e,n);n+=4;let j=0,H=0;d>=2&&(j=Oe(e,n),n+=4,H=Ro(e,n),n+=4);const K=Ro(e,n);if(n+=4,y){_.push({width:L,height:N,compression:0,data:e.subarray(n)}),n=e.length;continue}j===0&&(H=K);const O=e.subarray(n,n+K);n+=K;let W=O;j===1&&(W=Lo(O,H)),_.push({width:L,height:N,compression:j,data:W})}x.push(_)}const m=x[0]&&x[0][0],M=m?m.width:s,h=m?m.height:a;let g=null;if(n+13<=e.length){const v=or(e,n,9);if(v.indexOf("TEXS")===0){let A=n+9;const _=Oe(e,A);A+=4;let R=0,L=0;v==="TEXS0003\0"&&(R=Oe(e,A),A+=4,L=Oe(e,A),A+=4);const N=e.length-A,j=_>0&&N>0&&N%_===0?N/_:0;if(_>0&&_<=4096&&j>=32){const H=[];for(let O=0;O<_;O++){const W=A+O*j;if(W+32>e.length)break;const X=qt(e,W+8),ie=qt(e,W+12),J=qt(e,W+16),Z=qt(e,W+20),te=qt(e,W+24),le=qt(e,W+28);H.push({imageId:qt(e,W)|0,duration:qt(e,W+4),x:X,y:ie,width:Math.hypot(J,Z)||R,height:Math.hypot(te,le)||L,uDir:[J,Z],vDir:[te,le],rotated:Math.abs(Z)>.5||Math.abs(te)>.5})}H.length===_&&H.every(O=>{if(!(O.width>0&&O.height>0))return!1;const W=[O.x,O.x+O.uDir[0],O.x+O.vDir[0],O.x+O.uDir[0]+O.vDir[0]],X=[O.y,O.y+O.uDir[1],O.y+O.vDir[1],O.y+O.uDir[1]+O.vDir[1]];return Math.min(...W)>=-1&&Math.max(...W)<=M+1&&Math.min(...X)>=-1&&Math.max(...X)<=h+1})&&(g={magic:v,frameWidth:R,frameHeight:L,atlasWidth:M,atlasHeight:h,list:H})}}}return{format:o,formatName:Ur[o]||String(o),flags:i,textureWidth:s,textureHeight:a,width:c,height:u,freeImageFormat:p,containerMagic:l,containerVersion:d,isVideo:y,images:x,frames:g}}function or(e,n,t){let r="";for(let o=n;o<n+t;o++)r+=String.fromCharCode(e[o]);return r}const Js=Object.freeze(Object.defineProperty({__proto__:null,FIF:Yt,TEXTURE_FORMATS:Ur,decodeMip0:Is,decodeMips:Os,decodePixels:Dr,lz4Decompress:Lo,parseTex:Qs},Symbol.toStringTag,{value:"Module"}));function ko(e,n){if(!e||typeof n!="string")return null;const t=e[n];return t&&typeof t=="object"?t:null}function Ir(e){return typeof e=="string"?e:e&&typeof e=="object"&&typeof e.name=="string"?e.name:null}function ea(e,n){return ir(e)&&ir(n)?Number(e)===Number(n):String(e)===String(n)}function Or(e){if(typeof e=="boolean")return"bool";if(typeof e=="number")return Number.isFinite(e)?"num":"other";if(typeof e=="string"){const n=e.trim().split(/\s+/);return n.length>0&&n[0]!==""&&n.every(t=>Number.isFinite(Number(t)))?"num":"text"}return"other"}function ta(e){switch(e.type){case"bool":return"bool";case"slider":return"num";case"color":return"num";case"textinput":return"text";default:return Or(e.value)}}function Fo(e,n){if(e===null||typeof e!="object")return e;if(e.user&&typeof e.user=="object"&&typeof e.user.name=="string"){const r=ko(n,e.user.name);if(!r||r.value===void 0||r.value===null)return e.value;const o=r.type==="combo"?$r(r.value,r.options):r.value;return ea(o,e.user.condition)}if(typeof e.user!="string")return e;const t=ko(n,e.user);if(!t||t.value===void 0||t.value===null)return e.value;if(t.userOverridden)return t.value;if(e.value!==null&&typeof e.value=="object")return e.value;if(e.value===void 0)return t.value;if(Or(e.value)==="bool"&&t.type==="slider"){const r=Number(t.value);return Number.isFinite(r)?r!==0:e.value}return Or(e.value)===ta(t)?t.value:e.value}function hn(e,n,t){if(t>32||e===null||typeof e!="object")return e;if(Array.isArray(e)){for(let r=0;r<e.length;r++)e[r]=hn(e[r],n,t+1);return e}if(Ir(e.user)){let r=Fo(e,n);for(let o=0;o<8&&r!==null&&typeof r=="object"&&Ir(r.user);o++)r=Fo(r,n);return e.value=hn(r,n,t+1),e}for(const r of Object.keys(e))e[r]=hn(e[r],n,t+1);return e}function na(e){return e?Array.isArray(e)?e.map(n=>n&&typeof n=="object"&&"value"in n?n.value:n):typeof e=="object"?Object.values(e):[]:[]}function ir(e){return typeof e=="number"?Number.isInteger(e):typeof e=="string"&&/^-?\d+$/.test(e.trim())}function $r(e,n){const t=na(n);return!(t.length>0?t.every(ir):ir(e))||typeof e=="number"&&Number.isFinite(e)?e:typeof e=="string"&&/^-?\d+$/.test(e.trim())?Number(e):e}function ra(e){const n={};if(!e||typeof e!="object")return n;for(const[t,r]of Object.entries(e))!r||typeof r!="object"||!("value"in r)||(n[t]=r.type==="combo"?$r(r.value,r.options):r.value);return n}function Ct(e){return e&&typeof e=="object"?Ir(e.user):null}function oa(e,n,t){const r={};if(!t||typeof t!="object")return r;const o=e&&typeof e=="object"?e:{},i=n&&typeof n=="object"?n:{};for(const[s,a]of Object.entries(t)){const c=a&&typeof a=="object"&&"value"in a?a.value:a,u=o[s];if(u&&typeof u=="object"){u.value=c,u.userOverridden=!0;const l=u.type==="combo"?$r(u.value,u.options):u.value;i[s]=l,r[s]=l}else i[s]=c,r[s]=c}return r}function mn(e){typeof e=="object"&&e!==null&&(e=e.value);const n=String(e??"").trim().split(/\s+/).map(Number);return n.length===1?[n[0]||0,n[0]||0,n[0]||0]:[n[0]||0,n[1]||0,n[2]||0]}function Un(e){typeof e=="object"&&e!==null&&(e=e.value);const n=String(e??"").trim().split(/\s+/).map(Number);return n.length===1?[n[0]||0,n[0]||0]:[n[0]||0,n[1]||0]}function sr(e){return e==null?[1,1,1]:typeof e=="string"?mn(e):typeof e=="object"&&e!==null?mn(e.value):[1,1,1]}function lt(e,n=!1){if(e==null)return n;if(typeof e=="boolean")return e;if(typeof e=="number")return e!==0;if(typeof e=="object"&&e!==null){const t=e.value;return typeof t=="number"?t!==0:!!t}return n}function ft(e,n){if(typeof e=="number")return e;if(e!==null&&typeof e=="object"){const t=Number(e.value);return Number.isFinite(t)?t:n}return n}function jr(e){return e?!e.image&&!e.model&&!e.particle&&e.text==null&&!e.size:!1}function zr(e,n,t){const r=t?e.scale:[1,1,1],o=(e.angles[2]||0)*Math.PI/180,i=Math.cos(o),s=Math.sin(o),a=n.origin[0]*r[0],c=n.origin[1]*r[1];return{origin:[e.origin[0]+a*i-c*s,e.origin[1]+a*s+c*i,e.origin[2]+(n.origin[2]||0)],scale:[r[0]*n.scale[0],r[1]*n.scale[1],r[2]*n.scale[2]],angles:[n.angles[0],n.angles[1],(e.angles[2]||0)+n.angles[2]]}}function ia(e,n){const t=n&&n.general&&n.general.properties||{},r=e.objects||[];hn(r,t,0),hn(e.general||{},t,0);const o=new Map;for(const m of r)m.id!==void 0&&o.set(m.id,m);const i=r.map(m=>({id:m.id,parent:m.parent,origin:mn(m.origin||"0 0 0"),scale:mn(m.scale||"1 1 1"),angles:mn(m.angles||"0 0 0")})),s=i.map(m=>({origin:m.origin.slice(),scale:m.scale.slice(),angles:m.angles.slice()}));for(let m=0;m<8;m++){let M=!1;for(const h of i){if(h.parent===void 0||h.parent===null||!o.get(h.parent))continue;const v=i.findIndex(H=>H.id===h.parent);if(v<0)continue;const A=i[v];if(A.parent!==void 0&&A.parent!==null)continue;const _=r[v],R=_.scale,N=!(R!==null&&typeof R=="object"&&(typeof R.script=="string"||R.user!==void 0)&&jr(_)),j=zr(A,h,N);h.origin=j.origin,h.scale=j.scale,h.angles=j.angles,h.parent=null,M=!0}if(!M)break}const a=r.map(m=>lt(m.visible,!0)),c=new Map;r.forEach((m,M)=>{m.id!==void 0&&c.set(m.id,M)});const u=new Map,l=new Map;for(const m of r)if(m.parent!==void 0&&m.parent!==null){u.set(m.parent,(u.get(m.parent)||0)+1);const M=m.id!==void 0?m.id:null;if(M!==null){const h=l.get(m.parent);h?h.push(M):l.set(m.parent,[M])}}const f=r.map(()=>!0);for(let m=0;m<r.length;m++){let M=a[m],h=r[m].parent;for(let g=0;M&&h!==void 0&&h!==null&&g<64;g++){const v=c.get(h);if(v===void 0)break;a[v]||(M=!1),h=r[v].parent}f[m]=M}const p=r.map((m,M)=>{const h=i[M],g=typeof m.image=="string"&&(m.image.indexOf("models/util/projectlayer")===0||m.image.indexOf("models/util/fullscreenlayer")===0);let v=Un(m.size||"0 0"),A=h.origin;if(g){const _=(e.general||{}).orthogonalprojection,R=_&&Number(_.width),L=_&&Number(_.height);R>0&&L>0&&(v=[R,L],A=[R/2,L/2,h.origin[2]||0])}return{id:m.id!==void 0?m.id:M,name:m.name||"",visible:f[M],visibleSelf:a[M],srcObject:m,image:typeof m.image=="string"?m.image:null,model:typeof m.model=="string"?m.model:null,isSkybox:typeof m.name=="string"&&m.name.indexOf("\u5929\u7A7A\u76D2")>=0,particle:typeof m.particle=="string"?m.particle:null,instanceoverride:m.instanceoverride||null,sound:Array.isArray(m.sound)?m.sound.filter(_=>typeof _=="string"):[],soundprops:{volume:ft(m.volume,1),playbackmode:m.playbackmode||"single",startsilent:lt(m.startsilent,!1),maxtime:ft(m.maxtime,0),mintime:ft(m.mintime,0),spatialization:lt(m.spatialization,!1),muteineditor:lt(m.muteineditor,!1)},text:typeof m.text=="string"?m.text:m.text&&typeof m.text=="object"?m.text.value:null,textScript:m.text&&typeof m.text=="object"&&m.text.script||null,textScriptProps:m.text&&typeof m.text=="object"&&m.text.scriptproperties||null,component:typeof m.component=="string"?m.component:null,isText:m.text!==void 0&&m.text!==null,textFont:typeof m.font=="string"?m.font:null,textPointsize:ft(m.pointsize,24)||24,textColor:sr(m.color),textAnchor:typeof m.anchor=="string"&&m.anchor!=="none"?m.anchor:"center",textMaxwidth:ft(m.maxwidth,0),textMaxrows:ft(m.maxrows,0),textLimitwidth:lt(m.limitwidth,!1),textLimitrows:lt(m.limitrows,!1),textLimituseellipsis:lt(m.limituseellipsis,!1),textHAlign:m.horizontalalign||"center",textVAlign:m.verticalalign||"center",textSpacing:m.spacing?Un(m.spacing):[0,0],textPadding:(()=>{const _=m.padding;if(typeof _=="number")return _;const R=String(_??"").trim().split(/\s+/).map(Number).filter(L=>Number.isFinite(L));return R.length?R.reduce((L,N)=>L+N,0)/R.length:0})(),textOpaquebackground:lt(m.opaquebackground,!1),textBackgroundcolor:sr(m.backgroundcolor),textBackgroundbrightness:ft(m.backgroundbrightness,1),textCastshadow:lt(m.castshadow,!1),isSound:!!(m.sound&&m.sound.length),isComponent:!!m.component,objectScripts:(()=>{const _={};for(const R of["scale","origin","color","alpha","brightness","angles","visible"]){const L=m[R];L&&typeof L=="object"&&typeof L.script=="string"&&L.script&&(_[R]={script:L.script,scriptproperties:L.scriptproperties||null,value:L.value})}return Object.keys(_).length?_:null})(),objectAnimations:(()=>{const _={};for(const R of["scale","origin","color","alpha","brightness","angles","visible","volume","maxwidth","zoom"]){const L=m[R];L&&typeof L=="object"&&L.animation&&typeof L.animation=="object"&&L.animation.options&&(_[R]={animation:L.animation,value:L.value})}return Object.keys(_).length?_:null})(),animationLayers:(m.animationlayers||[]).filter(_=>_&&typeof _.animation=="number").map(_=>({animation:_.animation,visible:lt(_.visible,!0),additive:lt(_.additive,!1),blend:ft(_.blend,1),rate:ft(_.rate,1)})),solid:(()=>{if(typeof m.particle=="string")return!1;const _=typeof m.image=="string"?m.image:"";return _.indexOf("models/util/composelayer")===0?!1:_.indexOf("models/util/solidlayer")===0?!0:m.solid?!_||_.indexOf("models/util/")===0:!1})(),isContainer:typeof m.image=="string"&&m.image.indexOf("models/util/composelayer")===0,hasChildren:(u.get(m.id!==void 0?m.id:M)||0)>0,childIds:l.get(m.id!==void 0?m.id:M)||null,parentId:m.parent!==void 0&&m.parent!==null?m.parent:null,attachment:typeof m.attachment=="string"&&m.attachment!==""?m.attachment:null,passthrough:!!(m.config&&m.config.passthrough===!0),isPostProcess:g,origin:A,scale:h.scale,angles:h.angles,localOrigin:s[M].origin,localScale:s[M].scale,localAngles:s[M].angles,renderInert:jr(m),scaleRuntimeBound:m.scale!==null&&typeof m.scale=="object"&&(typeof m.scale.script=="string"||m.scale.user!==void 0),size:v,alignment:m.alignment||"center",color:sr(m.color),alpha:ft(m.alpha,1),brightness:ft(m.brightness,1),copybackground:!!m.copybackground,colorBlendMode:m.colorBlendMode||0,parallaxDepth:m.parallaxDepth!==void 0?Un(m.parallaxDepth):null,effects:(m.effects||[]).map(_=>({file:_.file||"",name:typeof _.name=="string"?_.name:"",visible:lt(_.visible,!0),visibleScript:_.visible&&typeof _.visible=="object"&&typeof _.visible.script=="string"&&_.visible.script?{script:_.visible.script,scriptproperties:_.visible.scriptproperties||null,value:!!_.visible.value}:null,passes:(_.passes||[]).map(R=>({combos:R.combos||{},constantshadervalues:R.constantshadervalues||{},textures:R.textures||[]}))}))}}),d=e.general||{},y=(()=>{const m={};for(const[M,h]of Object.entries(d))h&&typeof h=="object"&&typeof h.script=="string"&&h.script&&(m[M]={script:h.script,scriptproperties:h.scriptproperties||null,value:h.value});return Object.keys(m).length?m:null})(),x=(()=>{const m={};for(const[M,h]of Object.entries(d))h&&typeof h=="object"&&h.animation&&typeof h.animation=="object"&&h.animation.options&&(m[M]={animation:h.animation,value:h.value});return Object.keys(m).length?m:null})();{const m=new Map;for(const M of p)M.id!==void 0&&m.set(M.id,M);for(let M=0;M<8;M++){let h=!1;for(const g of p){if(g.parallaxDepth||g.parentId==null)continue;const v=m.get(g.parentId);!v||!v.parallaxDepth||v.image||v.particle||v.model||(g.parallaxDepth=v.parallaxDepth.slice(),h=!0)}if(!h)break}}return{camera:e.camera||null,general:d,generalScripts:y,generalAnimations:x,layers:p,properties:t}}function sa(e){if(!Array.isArray(e))return;const n=new Map;for(const t of e)t&&t.id!==void 0&&t.id!==null&&n.set(t.id,t);for(const t of e){if(!t)continue;if(t.destroyed){t.visible=!1;continue}let r=t.visibleSelf!==!1,o=t.parentId;for(let i=0;r&&o!=null&&i<64;i++){const s=n.get(o);if(!s)break;(s.visibleSelf===!1||s.destroyed)&&(r=!1),o=s.parentId}t.visible=r}}function aa(e,n){!e||!n||typeof n!="object"||e.isContainer||n.solidlayer===!0&&(e.solid=!0)}function ca(e){return!e||typeof e.material!="string"?null:{materialPath:e.material,autosize:!!e.autosize,cropoffset:e.cropoffset?Un(e.cropoffset):null}}function la(e,n){if(!e||e.length===0)return;const t=new Map;for(const i of e)i&&i.id!==void 0&&i.id!==null&&t.set(i.id,i);const r=i=>{let s=0,a=i.parentId;for(let c=0;a!=null&&c<64;c++){const u=t.get(a);if(!u)break;s++,a=u.parentId}return s},o=[];for(const i of e)!i||!i.localOrigin||i.isPostProcess||n&&!n.has(i.id)||o.push(i);o.sort((i,s)=>r(i)-r(s));for(const i of o){const s=i.parentId!==void 0&&i.parentId!==null?t.get(i.parentId):null;let a;if(!s)a={origin:i.localOrigin.slice(),scale:i.localScale.slice(),angles:i.localAngles.slice()};else{const u=!(s.scaleRuntimeBound&&s.renderInert);a=zr({origin:s.origin,scale:s.scale,angles:s.angles},{origin:i.localOrigin,scale:i.localScale,angles:i.localAngles},u)}const c=i.attachBindDelta;c&&(a.origin[0]+=c[0],a.origin[1]+=c[1]),i.origin[0]=a.origin[0],i.origin[1]=a.origin[1],i.origin[2]=a.origin[2],i.scale[0]=a.scale[0],i.scale[1]=a.scale[1],i.scale[2]=a.scale[2],i.angles[0]=a.angles[0],i.angles[1]=a.angles[1],i.angles[2]=a.angles[2],i.attachBase&&(i.attachBase[0]=a.origin[0],i.attachBase[1]=a.origin[1])}}function ua(e,n){const t=new Set;if(!e||e.length===0)return t;const r=new Map;for(const a of e){if(!a||a.parentId===void 0||a.parentId===null)continue;const c=r.get(a.parentId);c?c.push(a):r.set(a.parentId,[a])}const o=["origin","scale","angles"],i=[];for(const a of e){if(!a||a.id===void 0||a.id===null)continue;const c=a.objectScripts||null,u=a.objectAnimations||null;o.some(f=>c&&c[f]||u&&u[f])&&i.push(a)}if(n)for(const a of n)a&&a.id!==void 0&&a.id!==null&&i.push(a);const s=i.slice();for(let a=0;s.length>0&&a<1e5;a++){const c=s.pop();if(!c||c.id===void 0||c.id===null||t.has(c.id))continue;t.add(c.id);const u=r.get(c.id);if(u)for(const l of u)s.push(l)}return t}const fa=Object.freeze(Object.defineProperty({__proto__:null,applySolidFromModel:aa,collectTransformDirty:ua,composeChildTransform:zr,isRenderInert:jr,parseBool:lt,parseColor:sr,parseNum:ft,parseScene:ia,parseVec2:Un,parseVec3:mn,recomposeWorld:la,recomputeLayerVisibility:sa,resolveMaterial:ca},Symbol.toStringTag,{value:"Module"}));function da(e,n,t){const r=Nr(e,n.file);if(r===null)return;let o;try{o=JSON.parse(t(r))}catch{return}n.fbos=o.fbos||[],n.materialPasses=(o.passes||[]).map(i=>{if(!i.material)return{shader:null,copyCommand:!0,target:i.target||null,source:i.source||null,binds:i.bind||[],blending:"normal",textures:[],combos:{},constants:{}};const s=Nr(e,i.material);if(s===null)return{shader:null,copyCommand:!1,target:i.target||null,binds:i.bind||[],blending:"normal",textures:[],combos:{},constants:{}};const a=JSON.parse(t(s)),c=a.passes&&a.passes[0]||{};return{shader:c.shader||null,copyCommand:!1,target:i.target||null,binds:i.bind||[],blending:c.blending||"normal",textures:c.textures||[],combos:c.combos||{},constants:c.constantshadervalues||{}}})}const pa={"models/util/solidlayer.json":{material:"materials/util/solidlayer.json"},"models/util/composelayer.json":{material:"materials/util/solidlayer.json"},"models/util/fullscreenlayer.json":{material:"materials/util/solidlayer.json"},"models/util/projectlayer.json":{material:"materials/util/solidlayer.json"}};function No(e){if(!e||typeof e!="string")return!0;const n=e.toLowerCase();return n==="generic"||n==="sprite"||n==="flat"||n.startsWith("genericimage")}function ha(e,n){return!e||!n||!n.shader||No(n.shader)||(e.effects=e.effects||[],e.effects.some(t=>t.layerMaterial))?!1:(e.effects.unshift({file:"",name:"_layerMaterial",visible:!0,layerMaterial:!0,passes:[{combos:n.combos||{},constantshadervalues:n.constantshadervalues||{},textures:n.textures||[]}],materialPasses:[{shader:n.shader,copyCommand:!1,target:null,binds:[],blending:n.blending||"normal",textures:n.textures||[],combos:n.combos||{},constants:n.constantshadervalues||{}}],fbos:[]}),!0)}const ma={"materials/util/solidlayer.json":{passes:[{shader:"flat",blending:"translucent",cullmode:"nocull",depthtest:"disabled",depthwrite:"disabled",textures:[],combos:{}}]}},ga=Object.freeze(Object.defineProperty({__proto__:null,BUILTIN_MATERIALS:ma,BUILTIN_MODELS:pa,attachLayerMaterialEffect:ha,isBuiltinAlbedoShader:No,resolveEffectChain:da},Symbol.toStringTag,{value:"Module"}));function gn(){return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function Lt(e,n){const t=new Float32Array(16);for(let r=0;r<4;r++)for(let o=0;o<4;o++){let i=0;for(let s=0;s<4;s++)i+=e[s*4+o]*n[r*4+s];t[r*4+o]=i}return t}function bn(e,n,t,r,o,i){const s=gn();return s[0]=2/(n-e),s[5]=2/(r-t),s[10]=-2/(i-o),s[12]=-(n+e)/(n-e),s[13]=-(r+t)/(r-t),s[14]=-0/(i-o),s}function yn(e,n,t,r){return Lt(e,new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,n,t,r,1]))}function Uo(e){const n=new Float32Array(16);for(let t=0;t<4;t++)for(let r=0;r<4;r++)n[r*4+t]=e[t*4+r];return n}function Dn(e,n,t,r){return Lt(e,new Float32Array([n,0,0,0,0,t,0,0,0,0,r,0,0,0,0,1]))}function Do(e,n){const t=Math.cos(n),r=Math.sin(n);return Lt(e,new Float32Array([t,r,0,0,-r,t,0,0,0,0,1,0,0,0,0,1]))}function ba(e,n){const t=Math.cos(n),r=Math.sin(n);return Lt(e,new Float32Array([1,0,0,0,0,t,r,0,0,-r,t,0,0,0,0,1]))}function ya(e,n){const t=Math.cos(n),r=Math.sin(n);return Lt(e,new Float32Array([t,0,-r,0,0,1,0,0,r,0,t,0,0,0,0,1]))}function va(e,n,t,r){const o=1/Math.tan(e*Math.PI/180/2),i=new Float32Array(16);return i[0]=o/(n||1),i[5]=o,i[10]=(r+t)/(t-r),i[11]=-1,i[14]=2*r*t/(t-r),i}function ar(e,n){const t=e&&typeof e=="object"?e.value:e;return typeof t=="number"&&Number.isFinite(t)?t:n}function xa(e){const n=e&&e.general;return!n||n.orthogonalprojection?!1:ar(n.fov,0)>0}function wa(e,n){return n&&n.perspective&&e&&e.isSkybox&&n.eye?n.eye:e.origin}function Ma(e,n,t){const r=Io([e[0]-n[0],e[1]-n[1],e[2]-n[2]]),o=Io(Oo(t,r)),i=Oo(r,o),s=new Float32Array([o[0],i[0],r[0],0,o[1],i[1],r[1],0,o[2],i[2],r[2],0,0,0,0,1]);return s[12]=-(o[0]*e[0]+o[1]*e[1]+o[2]*e[2]),s[13]=-(i[0]*e[0]+i[1]*e[1]+i[2]*e[2]),s[14]=-(r[0]*e[0]+r[1]*e[1]+r[2]*e[2]),s}function _a(e,n,t,r){const o=e[3]*n+e[7]*t+e[11]*r+e[15];return[(e[0]*n+e[4]*t+e[8]*r+e[12])/o,(e[1]*n+e[5]*t+e[9]*r+e[13])/o,(e[2]*n+e[6]*t+e[10]*r+e[14])/o]}const Aa=[[16,9],[16,10],[21,9],[32,9]];function Ta(e,n,t,r,o){const i=e/n;if(!Number.isFinite(i)||i<=0||!(t>0)||!(r>0))return null;const s=.02,a=t/r;if(Math.abs(i-a)<=s*a)return{viewW:t,viewH:r};for(const[c,u]of Aa){const l=c/u;if(Math.abs(i-l)>s*l)continue;const f=r,p=r*l;return p>t+1e-6?{viewW:t,viewH:t/l}:{viewW:p,viewH:f}}return null}function Vr(e,n,t,r,o,i,s){const a=Bo(i),c=Bo(s);if(e==="cover"){const u=Ta(r,o,n,t);if(u)return{offX:(n-u.viewW)*a,offY:(t-u.viewH)*c,viewW:u.viewW,viewH:u.viewH};const l=Math.max(r/n,o/t),f=r/l,p=o/l;return{offX:(n-f)*a,offY:(t-p)*c,viewW:f,viewH:p}}if(e==="contain"){const u=r/o;if(n/t>u){const d=n,y=n/u;return{offX:0,offY:(t-y)/2,viewW:d,viewH:y}}const f=t,p=t*u;return{offY:0,offX:(n-p)/2,viewW:p,viewH:f}}return{offX:0,offY:0,viewW:n,viewH:t}}function Sa(e,n,t,r,o,i){const s=e.general,a=e.camera,c=a&&a.eye?Wr(a.eye):[0,0,0],u=a&&a.center?Wr(a.center):[0,0,-1],l=a&&a.up?Wr(a.up):[0,1,0];if(xa(e)){const g=t>0?n/t:1.7777777777777777,v=ar(s.fov,50),A=Math.max(ar(s.nearz,.01),1e-4),_=Math.max(ar(s.farz,1e4),A+1),R=Ma(c,u,l),L=va(v,g,A,_);return{view:R,projection:L,eye:c,center:u,projW:g,projH:1,offX:0,offY:0,viewW:g,viewH:1,perspective:!0}}const f=gn(),p=s&&s.orthogonalprojection&&s.orthogonalprojection.width||n,d=s&&s.orthogonalprojection&&s.orthogonalprojection.height||t,y=Vr(r,p,d,n,t,o,i),x=e&&e.cameraTransforms?e.cameraTransforms.zoom:s&&s.zoom,m=x&&typeof x=="object"?x.value:x,M=Number(m);if(Number.isFinite(M)&&M>0&&Math.abs(M-1)>1e-6){const g=y.offX+y.viewW/2,v=y.offY+y.viewH/2,A=y.viewW/M,_=y.viewH/M;y.offX=g-A/2,y.offY=v-_/2,y.viewW=A,y.viewH=_}const h=bn(y.offX,y.offX+y.viewW,y.offY+y.viewH,y.offY,-1e4,1e4);return{view:f,projection:h,eye:c,projW:p,projH:d,offX:y.offX,offY:y.offY,viewW:y.viewW,viewH:y.viewH,perspective:!1}}function Bo(e){const n=Number(e);return Number.isFinite(n)?n<0?0:n>1?1:n:.5}function Wr(e){return String(e).trim().split(/\s+/).map(Number)}function Io(e){const n=Math.hypot(e[0],e[1],e[2])||1;return[e[0]/n,e[1]/n,e[2]/n]}function Oo(e,n){return[e[1]*n[2]-e[2]*n[1],e[2]*n[0]-e[0]*n[2],e[0]*n[1]-e[1]*n[0]]}function vn(e){const n=Number(e);return Number.isFinite(n)?n*.5:0}function Ea(e){const n=new Map,t=new Map,r=/^[ \t]*#define[ \t]+([A-Za-z_][A-Za-z0-9_]*)(?:\(([^)]*)\))?[ \t]*(.*)$/gm;let o;for(;(o=r.exec(e))!==null;){const i=s=>s.replace(/\/\/.*$/,"").replace(/\/\*[\s\S]*?\*\//g,"").trim();o[2]!==void 0?t.set(o[1],{args:o[2].split(",").map(s=>s.trim()).filter(Boolean),body:i(o[3])}):n.set(o[1],i(o[3]))}return{defs:n,fns:t}}function Pa(e,n,t,r){const o=[];let i=0;for(;i<e.length;){const s=e.indexOf(n,i);if(s===-1){o.push(e.slice(i));break}o.push(e.slice(i,s));let c=s+n.length;for(;c<e.length&&/\s/.test(e[c]);)c++;if(e[c]!=="("){o.push(e.slice(s,c)),i=c;continue}let u=0,l=c;for(;l<e.length;l++)if(e[l]==="(")u++;else if(e[l]===")"&&(u--,u===0))break;if(l>=e.length){o.push(e.slice(s));break}const f=e.slice(c+1,l),p=It(f);let d=t.body;t.args.forEach((y,x)=>{const m=p[x]!==void 0?p[x].trim():"";d=Bn(d,y,m)}),r>0&&(d=$o(d,r-1)),o.push("("+d+")"),i=l+1}return o.join("")}function Bn(e,n,t){return e.replace(new RegExp("\\b"+n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+"\\b","g"),t)}function It(e){const n=[];let t=0,r="";for(let o=0;o<e.length;o++){const i=e[o];i==="("?t++:i===")"&&t--,i===","&&t===0?(n.push(r),r=""):r+=i}return r.trim()!==""&&n.push(r),n}function $o(e,n){for(let t=0;t<12;t++){const{defs:r,fns:o}=Ea(e);if(r.size===0&&o.size===0)break;const i=e.split(`
|
|
2
|
+
`),s=new Map;for(let u=0;u<i.length;u++){const l=/^[ \t]*#define[ \t]+([A-Za-z_][A-Za-z0-9_]*)/.exec(i[u]);l&&!s.has(l[1])&&s.set(l[1],u)}const a=new Map;{const u="(?:float|int|bool|vec[234]|ivec[234]|bvec[234]|mat[234])";for(const l of r.keys()){const f=l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),p=new RegExp("^\\s*(?:const\\s+|uniform\\s+|varying\\s+|in\\s+|out\\s+|attribute\\s+)*"+u+"\\s+"+f+"\\s*[=;]");for(let d=0;d<i.length;d++)if(p.test(i[d])){a.set(l,d);break}}}let c=!1;for(let u=0;u<i.length;u++){const l=i[u];if(/^[ \t]*#/.test(l))continue;let f=l;for(const[p,d]of r){const y=s.get(p);if(y!==void 0&&u<y||a.get(p)===u)continue;new RegExp("\\b"+p.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+"\\b").test(f)&&(f=Bn(f,p,d),c=!0)}for(const[p,d]of o){const y=s.get(p);y!==void 0&&u<y||f.includes(p)&&(f=Pa(f,p,d,n),c=!0)}i[u]=f}if(e=i.join(`
|
|
3
|
+
`),!c)break}return e}function jo(e,n,t){const r=d=>n[d]!==void 0?String(n[d]):t.has(d)?"("+t.get(d)+")":"0";let o=e.replace(/\b[A-Za-z_][A-Za-z0-9_]*\b/g,d=>r(d)),i=0;function s(){for(;i<o.length&&/\s/.test(o[i]);)i++}function a(){let d=c();for(s();o.startsWith("||",i);){i+=2;const y=c();d=d||y,s()}return d}function c(){let d=u();for(s();o.startsWith("&&",i);){i+=2;const y=u();d=d&&y,s()}return d}function u(){let d=l();for(s();o.startsWith("==",i)||o.startsWith("!=",i);){const y=o[i]==="="?"==":"!=";i+=2;const x=l();d=y==="=="?d===x:d!==x,s()}return d}function l(){let d=f();for(s();/^[<>]/.test(o[i]||"");){let y=o[i];o[i+1]==="="&&(y+="=",i++),i++;const x=f();y==="<"?d=d<x:y===">"?d=d>x:y==="<="?d=d<=x:d=d>=x,s()}return d}function f(){return s(),o[i]==="!"?(i++,!f()):p()}function p(){if(s(),o[i]==="("){i++;const y=a();return s(),i++,y}const d=/^-?\d+(\.\d+)?/.exec(o.slice(i));return d?(i+=d[0].length,Number(d[0])):!1}return a()}function zo(e){let n="",t=0;const r=e.length;for(;t<r;){const o=e[t],i=e[t+1];if(o==="/"&&i==="*"){for(t+=2;t<r&&!(e[t]==="*"&&e[t+1]==="/");)e[t]===`
|
|
4
4
|
`&&(n+=`
|
|
5
5
|
`),t++;t+=2;continue}if(o==="/"&&i==="/"){for(;t<r&&e[t]!==`
|
|
6
|
-
`;)t++;continue}n+=o,t++}return n}function
|
|
7
|
-
`),i=[],s=[],a=new Map;for(let c=0;c<o.length;c++){const u=o[c],l=u.trim();if(l.startsWith("#include")){if(
|
|
8
|
-
`)}function
|
|
9
|
-
`))break}for(;
|
|
10
|
-
`||Z===")")break}const W=U.slice(k,q);return/\d\.\d/.test(W)?`${T}${_}.0 ${F} ${R}`:v});{const v=new Set,T=/\b(?:uniform\s+)?(?:highp|mediump|lowp\s+)?(?:float|vec2|vec3|vec4|mat2|mat3|mat4)\s+([A-Za-z_][A-Za-z0-9_]*)/g;let _;for(;(_=T.exec(l))!==null;)v.add(_[1]);if(v.size>0){const F=Array.from(v).sort((R,k)=>k.length-R.length).join("|");l=l.replace(new RegExp("(^|[^\\w.])(\\d+)\\s*([+-])\\s*("+F+")(?![A-Za-z0-9_])","g"),"$1$2.0 $3 $4"),l=l.replace(new RegExp("\\b("+F+")\\s*([+-])\\s*(\\d+)(?![\\d.])","g"),"$1 $2 $3.0")}}if(l===b)break}{const h=["smoothstep","step","mix","clamp","max","min","pow","mod","atan","sqrt","inversesqrt","exp","log","exp2","log2","abs","sign","floor","ceil","fract","length","distance","dot","reflect","refract","faceforward","normalize","cross"],b=/\b(ApplyBlending|ApplyComposite|BlendTransparency)\s*\(/;for(const v of h)l=ze(l,v,T=>{const F=Rt(T).map(R=>{if(b.test(R))return R;const k=[];let U=R.replace(/\[[^\]]*\]/g,V=>(k.push(V),"\0"+(k.length-1)+"\0")).replace(/\b(?:ivec[234]|uvec[234]|int|uint)\s*\([^()]*\)/g,V=>(k.push(V),"\0"+(k.length-1)+"\0"));return U=U.replace(/(?<![A-Za-z0-9_.\u0000])(\d+)(?![.\d])(?![A-Za-z_])/g,"$1.0"),U.replace(/\u0000(\d+)\u0000/g,(V,q)=>k[Number(q)])});return v+"("+F.join(",")+")"});l=ze(l,"pow",v=>{const T=Rt(v);if(T.length!==2)return"pow("+v+")";const _=T[0].trim(),F=T[1].trim(),R=/\.(xyzw|rgba|xyz|rgb|xy|rg|zw)\s*$/.exec(_),U=R?{xyzw:4,rgba:4,xyz:3,rgb:3,xy:2,rg:2,zw:2}[R[1]]:0,V=/\bvec[234]\s*\(/.test(F)||/\.(xyzw|rgba|xyz|rgb|xy|rg|zw)\b/.test(F);return U>=2&&!V?"pow("+_+", vec"+U+"("+F+"))":"pow("+_+", "+F+")"})}l=l.replace(/([)\]])\s*([*/])\s*(\d+)(?![\d.])/g,"$1 $2 $3.0"),l=l.replace(/\)\s*([+-])\s*(\d+)(?![\d.])/g,") $1 $2.0"),l=l.replace(/(^|[^\w.])(\d+)(?![.\d])\s*([+-])\s*((?:step|smoothstep|mix|mod|fract|abs|sin|cos|tan|atan|sqrt|pow|inversesqrt|floor|ceil|sign|length|normalize|distance|dot|cross|exp|log|exp2|log2|clamp|min|max)\s*\()/g,"$1$2.0 $3 $4");{const h=new Set,b=/\b(?:vec[234])\s+([A-Za-z_][A-Za-z0-9_]*)/g;let v;for(;(v=b.exec(l))!==null;)h.add(v[1]);if(h.size>0){const T=Array.from(h).sort((_,F)=>F.length-_.length).join("|");l=l.replace(new RegExp("\\b("+T+")\\s*([+-])\\s*(\\d+)(?![\\d.])","g"),"$1 $2 $3.0")}}{const h=new Set,b=/\b(?:int|uint)\s+([A-Za-z_][A-Za-z0-9_]*)/g;let v;for(;(v=b.exec(l))!==null;)h.add(v[1]);l=l.replace(/\buint\b/g,"int"),l=l.replace(/\b([A-Za-z_][A-Za-z0-9_]*)\s*%\s*(\d+)(?![\d.])/g,(T,_,F)=>h.has(_)?T:"mod("+_+", "+F+".0)"),l=l.replace(/\bint\s+([A-Za-z_][A-Za-z0-9_]*)\s*=\s*mod\(([^;]*)\);/g,"int $1 = int(mod($2));")}l=l.replace(/\b(vec[234])\s+([A-Za-z_][A-Za-z0-9_]*)\s*=\s*([^;()\n,]+);/g,(h,b,v,T)=>{const _=T.trim();return/^(vec[234]|mat[234]|int\b|float\b)/.test(_)?h:b+" "+v+" = "+b+"("+_+");"});for(const h of["mix","clamp","step","smoothstep","min","max","mod","pow"])l=ze(l,h,b=>h+"("+b.replace(/(?<![A-Za-z0-9_.])(\d+)(?![.\d])/g,"$1.0")+")");l=ze(l,"clamp",h=>{const b=Rt(h);if(b.length!==3)return"clamp("+h+")";const v=b[0].trim(),T=b[1].trim(),_=F=>/^-?\d+\.?\d*$/.test(F);return _(v)&&_(T)&&Number(v)===0&&Number(T)===1?"clamp("+b[2].trim()+", "+v+", "+T+")":"clamp("+h+")"}),l=l.replace(/(\.\d+)\s*([+-])\s*(\d+)(?![\d.])/g,"$1 $2 $3.0"),l=l.replace(/([)\]])\s*([+-])\s*(\d+)(?![\d.])/g,"$1 $2 $3.0"),l=ze(l,"smoothstep",h=>{const b=Rt(h);return b.length===3&&b[1].trim()==="0.0"&&b[0].trim()!=="0.0"?"(1.0 - smoothstep(0.0, "+b[0].trim()+", "+b[2].trim()+"))":"smoothstep("+h+")"});{const h=new Map,b=/\b(?:uniform|varying|attribute|in|out)?\s*\b(vec([234]))\s+([A-Za-z_]\w*)/g;let v;for(;(v=b.exec(l))!==null;)h.set(v[3],Number(v[2]));if(h.size>0){const T={2:"xy",3:"xyz",4:"xyzw"};l=l.replace(/(^|[;{}\n]\s*)([A-Za-z_]\w*)\s*=\s*([A-Za-z_]\w*)\s*;/g,(_,F,R,k)=>{const U=h.get(R),V=h.get(k);return!U||!V||U>=V?_:F+R+" = "+k+"."+T[U]+";"})}{const T=new Set;{const R=/\b(?:uniform|varying|attribute|in|out|const)?\s*\bfloat\s+([A-Za-z_]\w*)/g;let k;for(;(k=R.exec(l))!==null;)T.add(k[1])}const _=R=>{const k=R.trim();{const q=/^vec([234])\s*\(/.exec(k);if(q){let W=0;for(let Z=k.indexOf("(");Z<k.length;Z++)if(k[Z]==="(")W++;else if(k[Z]===")"&&(W--,W===0))return Z===k.length-1?Number(q[1]):0;return 0}}if(/^texture(?:Lod)?\s*\(/.test(k)){let q=0;for(let W=k.indexOf("(");W<k.length;W++)if(k[W]==="(")q++;else if(k[W]===")"&&(q--,q===0))return W===k.length-1?4:0;return 0}const U=/^([A-Za-z_]\w*)(?:\.([xyzwrgba]{2,4}))?\s*[*/]\s*([^*/]+)$/.exec(k);if(!U)return 0;const V=U[3];return/\bvec[234]\s*\(|\.[xyzwrgba]{2,4}\b/.test(V)?0:U[2]?U[2].length:T.has(U[1])?0:h.get(U[1])||0};l=l.replace(/(^|[;{}\n]\s*)float\s+([A-Za-z_]\w*)\s*=\s*([^;]+);/g,(R,k,U,V)=>_(V)<2?R:`${k}float ${U} = (${V.trim()}).x;`);const F={2:"xy",3:"xyz"};l=l.replace(/(^|[;{}\n]\s*)vec([23])\s+([A-Za-z_]\w*)\s*=\s*([^;]+);/g,(R,k,U,V,q)=>{const W=Number(U);return _(q)<=W?R:`${k}vec${U} ${V} = (${q.trim()}).${F[W]};`})}if(h.size>0){const T=new Set,_=/\b(?:uniform|varying|attribute|in|out)?\s*\bfloat\s+([A-Za-z_]\w*)/g;let F;for(;(F=_.exec(l))!==null;)T.add(F[1]);const R="pow|saturate|clamp|smoothstep|step|abs|floor|ceil|fract|frac|sin|cos|tan|asin|acos|atan|sqrt|length|distance|dot|exp|log|sign|fmod|mod|min|max|mix|lerp",k=/^(?:length|distance|dot)$/,U=q=>{const W=q.match(new RegExp("^(?:"+R+")\\s*\\("));if(!W)return!1;let Z=0;const K=W[0].length-1;let re=-1;for(let J=K;J<q.length;J++)if(q[J]==="(")Z++;else if(q[J]===")"&&(Z--,Z===0)){re=J;break}if(re!==q.length-1)return!1;const te=W[0].replace(/\s*\($/,"");if(k.test(te))return!0;const X=q.slice(K+1,re);if(/\bvec[234]\s*\(/.test(X)||/\.[xyzwrgba]{2,4}\b/.test(X))return!1;for(const J of h.keys()){const de=J.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp("(?<!\\.)\\b"+de+"\\b(?!\\s*\\.[xyzwrgba]\\b)").test(X))return!1}return!0},V=new Set;if(l=l.replace(/(^|[;{}\n]\s*)([A-Za-z_]\w*)\s*=\s*([^;]+);/g,(q,W,Z,K)=>{const re=h.get(Z);if(!re||T.has(Z))return q;const te=K.trim();if(new RegExp("^vec"+re+"\\s*\\(").test(te)||h.has(te))return q;const X=/^-?\d+(?:\.\d+)?(?:e[-+]?\d+)?$/i.test(te),J=T.has(te);return!X&&!J&&!U(te)?q:(V.add(Z),W+Z+" = vec"+re+"("+te+");")}),V.size>0){const q=[...V].sort((W,Z)=>Z.length-W.length).join("|");l=l.replace(new RegExp(`\\b([A-Za-z_]\\w*)\\s*([*/])\\s*(${q})\\b`,"g"),(W,Z,K,re)=>h.has(Z)?W:`${Z} ${K} ${re}.x`),l=l.replace(new RegExp(`\\b(${q})\\s*([*/])\\s*([A-Za-z_]\\w*)\\b`,"g"),(W,Z,K,re)=>h.has(re)?W:`${Z}.x ${K} ${re}`)}}}l=l.replace(/(\.[xyzwrgba]{1,4}\s*=\s*)(-?\d+)\s*;/g,"$1$2.0;"),l=l.replace(/\b(float|vec2|vec3|vec4)\s+([A-Za-z_]\w*)\s*=\s*(-?\d+)\s*;/g,(h,b,v,T)=>b==="float"?`${b} ${v} = ${T}.0;`:`${b} ${v} = ${b}(${T}.0);`);{const h=new Set,b=/\b(?:uniform|varying|attribute|in|out)?\s*\bfloat\s+([A-Za-z_]\w*)/g;let v;for(;(v=b.exec(l))!==null;)h.add(v[1]);if(h.size>0){const T=[...h].sort((_,F)=>F.length-_.length).join("|");l=l.replace(new RegExp(`\\b(${T})\\s*=\\s*(-?\\d+)\\s*;`,"g"),"$1 = $2.0;"),l=l.replace(new RegExp(`\\b(${T})\\s*([-+*/]=)\\s*(-?\\d+)\\s*;`,"g"),"$1 $2 $3.0;")}}l=l.replace(/(\.[xyzwrgba]{1,4}\s*[-+*/]=\s*)(-?\d+)\s*;/g,"$1$2.0;");const d="step|smoothstep|saturate|clamp|mix|lerp|frac|fract|abs|floor|ceil|min|max|pow|sqrt|length|dot|distance";l=l.replace(new RegExp(`\\bint\\s+([A-Za-z_]\\w*)\\s*=\\s*((?:${d})\\s*\\()`,"g"),"float $1 = $2"),l=l.replace(/\bfloat\s+([A-Za-z_]\w*)\s*=\s*(int\s*\([^;]*\))\s*;/g,"float $1 = float($2);");{const h=$o(l);h.size>0&&(l=l.replace(/\b(const\s+)?float\s+([A-Za-z_]\w*)\s*=\s*([^;{}]+);/g,(b,v,T,_)=>{const F=_.trim();if(/\./.test(F)||/[A-Za-z_]\w*\s*\(/.test(F))return b;const R=F.match(/[A-Za-z_]\w*/g);return!R||!R.length||!R.every(k=>h.has(k))?b:`${v||""}float ${T} = float(${F});`}))}{const h=$o(l),b=new Set;let v;const T=/\b(?:const\s+|uniform\s+|varying\s+|in\s+|out\s+)*float\s+([A-Za-z_]\w*)/g;for(;(v=T.exec(l))!==null;)b.add(v[1]);for(const _ of[...h])b.has(_)&&(h.delete(_),b.delete(_));if(h.size>0&&b.size>0){const _=[...h].sort((R,k)=>k.length-R.length).join("|"),F=[...b].sort((R,k)=>k.length-R.length).join("|");l=l.replace(new RegExp(`\\b(${_})\\s*([*/+-])\\s*(${F})\\b`,"g"),(R,k,U,V)=>`float(${k}) ${U} ${V}`),l=l.replace(new RegExp(`\\b(${F})\\s*([*/+-])\\s*(${_})\\b`,"g"),(R,k,U,V)=>`${k} ${U} float(${V})`)}}{const h=new Set,b=/\bbool\s+([A-Za-z_]\w*)\s*=/g;let v;for(;(v=b.exec(l))!==null;)h.add(v[1]);if(h.size>0){const T=[...h].join("|");l=l.replace(new RegExp(`([-+*/]=\\s*)(${T})\\b`,"g"),(_,F,R)=>`${F}float(${R})`)}}{const h=/\(\s*([^()&|]+?)\s*(<=|>=|<|>|==|!=)\s*([^()&|]+?)\s*\)/g;l=l.replace(new RegExp(h.source+"\\s*([*/])","g"),(b,v,T,_,F)=>`float(${v.trim()} ${T} ${_.trim()}) ${F}`),l=l.replace(new RegExp("([-+*/]=\\s*)"+h.source,"g"),(b,v,T,_,F)=>`${v}float(${T.trim()} ${_} ${F.trim()})`)}{const h=new Set;for(const b of l.matchAll(/\b(?:uniform\s+)?(?:highp|mediump|lowp\s+)?float\s+([A-Za-z_]\w*)\s*\[/g))h.add(b[1]);if(h.size){const b=[...h].sort((R,k)=>k.length-R.length).join("|"),v=new RegExp("\\b("+b+")\\s*\\[","g");let T="",_=0,F;for(;F=v.exec(l);){const R=F.index+F[0].length-1,k=cr(l,R,"[","]");if(k<0)break;let U=k+1;for(;U<l.length&&/[ \t]/.test(l[U]);)U++;if(l[U]!=="["){const K=l.slice(R+1,k).trim(),re=/\d\.\d/.test(K)||/^[A-Za-z_]\w*$/.test(K)&&new RegExp("\\bfloat\\s+"+K.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+"\\b").test(l),te=/^\s*int\s*\(/.test(K)||/^-?\d+$/.test(K);if(re&&!te){T+=l.slice(_,F.index),T+=F[1]+"[int("+K+")]",_=k+1,v.lastIndex=_;continue}v.lastIndex=k+1;continue}const V=cr(l,U,"[","]");if(V<0)break;const q=l.slice(R+1,k),W=l.slice(U+1,V);T+=l.slice(_,F.index),T+=F[1]+"[int(("+q+")) * 4 + int(("+W+"))]",_=V+1,v.lastIndex=_}l=T+l.slice(_)}}l=ze(l,"mix",(h,b)=>{const v=Rt(h);if(v.length!==3)return"mix("+h+")";const T=U=>{const V=U.trim(),q=/\.([xyzwrgba]{1,4})\s*$/.exec(V);if(q)return q[1].length;const W=/^vec([234])\s*\(/.exec(V);if(W)return Number(W[1]);if(!/^[A-Za-z_]\w*$/.test(V))return 0;const Z=new RegExp("\\b(vec([234])|float)\\s+"+V+"\\b","g");let K=0,re;for(;(re=Z.exec(l))!==null&&re.index<b;)K=re[1].startsWith("vec")?Number(re[2]):1;return K},_=v[0].trim(),F=v[1].trim(),R=T(_),k=T(F);if(R>=2&&k>=2&&R!==k){const U=Math.min(R,k),V=U===2?".xy":U===3?".xyz":"";return V?"mix("+(R>U?_+V:_)+", "+(k>U?F+V:F)+", "+v[2].trim()+")":"mix("+h+")"}return"mix("+h+")"});{const h=/\b(vec([234]))\s+([A-Za-z_]\w*)\s*\(/g;let b="",v=0,T;for(;T=h.exec(l);){const _=Oo(l,T.index+T[0].length-1);if(_<0)break;let F=_+1;for(;F<l.length&&/\s/.test(l[F]);)F++;if(l[F]!=="{")continue;const R=cr(l,F,"{","}");if(R<0)break;const k=Number(T[2]);if(k>=4){h.lastIndex=R;continue}let U=l.slice(F+1,R);const V=new Map;for(const W of l.slice(0,T.index).matchAll(/\buniform\s+(?:highp|mediump|lowp\s+)?(vec([234]))\s+([A-Za-z_]\w*)/g))V.set(W[3],Number(W[2]));for(const W of U.matchAll(/\b(vec([234]))\s+([A-Za-z_]\w*)/g))V.set(W[3],Number(W[2]));const q=k===2?"xy":"xyz";U=U.replace(/\breturn\s+([A-Za-z_]\w*)\s*;/g,(W,Z)=>{const K=V.get(Z);return K&&K>k?"return "+Z+"."+q+";":W}),b+=l.slice(v,F+1)+U,v=R,h.lastIndex=R}l=b+l.slice(v)}const w=new Set,M=/\b(?:uniform\s+)?(?:mat4|mat3|mat2|float4x4)\s+([A-Za-z_][A-Za-z0-9_]*)/g;let m;for(;(m=M.exec(l))!==null;)w.add(m[1]);if(l=ze(l,"mul",h=>{const b=Rt(h);if(b.length!==2)return"mul("+h+")";const v=b[0].trim(),T=b[1].trim(),_=F=>w.has(F.split(/[\[.\s]/)[0])||/^mat[234]\(/.test(F);return _(v)&&_(T)?"(transpose("+T+") * transpose("+v+"))":_(T)?"(transpose("+T+") * "+v+")":"("+v+" * "+T+")"}),l=l.replace(/\blerp\b/g,"mix").replace(/\bfrac\b/g,"fract"),l=ze(l,"atan2",h=>"atan("+h+")"),l=ze(l,"fmod",h=>{const b=Rt(h);if(b.length!==2)return"mod("+h+")";const v=b[0].trim(),T=b[1].trim();return"(("+v+") - ("+T+") * trunc(("+v+") / ("+T+")))"}),l=ze(l,"ddx",h=>"dFdx("+h+")"),l=ze(l,"ddy",h=>"dFdy("+h+")"),l=ze(l,"CAST3X3",h=>"mat3("+h+")"),n==="vert")l=l.replace(/\battribute\b/g,"in").replace(/\bvarying\b/g,"out");else{if(l=l.replace(/\bvarying\b/g,"in").replace(/\battribute\b/g,"in"),typeof o=="string"&&o){const v=new Map,T=/^\s*(?:varying|out)\s+(?:highp|mediump|lowp\s+)?(vec[234]|float)\s+([A-Za-z_]\w*)\s*;/gm;let _;for(;(_=T.exec(o))!==null;)v.set(_[2],_[1]);const F={float:1,vec2:2,vec3:3,vec4:4},R=new Map;if(l=l.replace(/^(\s*in\s+(?:highp|mediump|lowp\s+)?)(vec[234]|float)(\s+)([A-Za-z_]\w*)(\s*;)/gm,(k,U,V,q,W,Z)=>{const K=v.get(W);return!K||F[K]<=F[V]?k:(R.set(W,F[V]),U+K+q+W+Z)}),R.size>0){const k={1:"x",2:"xy",3:"xyz"};for(const[U,V]of R){const q=k[V];q&&(l=l.split(`
|
|
11
|
-
`).map(
|
|
12
|
-
`))}}l=l.replace(/^(\s*in\s+(?:highp|mediump|lowp\s+)?)(vec[234]|float)(\s+)([A-Za-z_]\w*)(\s*;)/gm,(
|
|
13
|
-
`).map(
|
|
14
|
-
`))}const h=new Set,
|
|
15
|
-
`+
|
|
6
|
+
`;)t++;continue}n+=o,t++}return n}function Vo(e,n,t,r){const o=e.split(`
|
|
7
|
+
`),i=[],s=[],a=new Map;for(let c=0;c<o.length;c++){const u=o[c],l=u.trim();if(l.startsWith("#include")){if(In(s)){const f=/^#include[ \t]+"([^"]+)"|^#include[ \t]+<([^>]+)>/.exec(l),p=f&&(f[1]||f[2]),d=p&&t?t(p):null;d!=null?i.push(Vo(zo(d),n,t)):i.push("// [include \u7F3A\u5931: "+p+"]")}continue}if(l.startsWith("#define")){if(In(s)){i.push(u);const f=/^#define[ \t]+([A-Za-z_][A-Za-z0-9_]*)(?:\([^)]*\))?[ \t]*(.*)$/.exec(l);f&&a.set(f[1],f[2].trim())}continue}if(l.startsWith("#undef")){In(s)&&i.push(u);continue}if(l.startsWith("#ifdef")||l.startsWith("#ifndef")||l.startsWith("#if")){const f=In(s);let p=!1;if(l.startsWith("#ifdef")){const d=l.slice(6).trim().split(/\s+/)[0];p=n[d]!==void 0||a.has(d)}else if(l.startsWith("#ifndef")){const d=l.slice(7).trim().split(/\s+/)[0];p=!(n[d]!==void 0||a.has(d))}else try{p=!!jo(l.slice(3).trim(),n,a)}catch{p=!1}s.push({parent:f,hit:p,done:p});continue}if(l.startsWith("#else")){if(s.length>0){const f=s[s.length-1];f.hit=!f.done,f.done=!0}continue}if(l.startsWith("#elif")){if(s.length>0){const f=s[s.length-1];if(f.done)f.hit=!1;else{let p=!1;try{p=!!jo(l.slice(5).trim(),n,a)}catch{p=!1}f.hit=p,f.done=p}}continue}if(l.startsWith("#endif")){s.length>0&&s.pop();continue}l.startsWith("#")||In(s)&&i.push(u)}return i.join(`
|
|
8
|
+
`)}function In(e){return e.every(n=>n.parent&&n.hit)}function cr(e,n,t,r){let o=0;for(let i=n;i<e.length;i++)if(e[i]===t)o++;else if(e[i]===r&&(o--,o===0))return i;return-1}function Wo(e,n){return cr(e,n,"(",")")}const Ca=new Set(["void","bool","int","uint","float","double","vec2","vec3","vec4","bvec2","bvec3","bvec4","ivec2","ivec3","ivec4","uvec2","uvec3","uvec4","mat2","mat3","mat4","mat2x2","mat2x3","mat2x4","mat3x2","mat3x3","mat3x4","mat4x2","mat4x3","mat4x4"]);function La(e,n){let t=n-1;for(;t>=0&&/[ \t]/.test(e[t]);)t--;if(t<0||t===n-1)return!1;let r=t+1;for(;t>=0&&/[A-Za-z0-9_]/.test(e[t]);)t--;const o=e.slice(t+1,r);return Ca.has(o)}function Ho(e){const n=new Set;let t;const r=/\b(?:const\s+)?int\s+([A-Za-z_]\w*)\s*[=;)\u0003]/g;for(;(t=r.exec(e))!==null;)n.add(t[1]);return n}function ze(e,n,t){let r="",o=0;for(;o<e.length;){const i=e.indexOf(n,o);if(i===-1){r+=e.slice(o);break}if(i>0&&/[A-Za-z0-9_]/.test(e[i-1])){r+=e.slice(o,i+1),o=i+1;continue}const s=i+n.length;if(s<e.length&&/[A-Za-z0-9_]/.test(e[s])){r+=e.slice(o,s),o=s;continue}if(La(e,i)){r+=e.slice(o,s),o=s;continue}r+=e.slice(o,i);let a=i+n.length;for(;a<e.length&&/\s/.test(e[a]);)a++;if(e[a]!=="("){r+=e.slice(i,a),o=a;continue}const c=Wo(e,a);if(c===-1){r+=e.slice(i);break}const u=e.slice(a+1,c);r+=t(u,i),o=c+1}return r}function Xo(e,n,t,r,o){const i=e;e=zo(e);const s={},a=/\[COMBO\][^\n]*?"combo"\s*:\s*"([^"]+)"[^\n]*?"default"\s*:\s*(-?\d+)/g;let c;if(typeof o=="string"&&o){const h=new RegExp(a.source,"g");let g;for(;(g=h.exec(o))!==null;)s[g[1]]=Number(g[2])}for(;(c=a.exec(i))!==null;)s[c[1]]=Number(c[2]);const u={GLSL:1,...s,...t||{}};let l=Vo(e,u,r);l=$o(l,20),l=l.replace(/^[ \t]*#define[^\n]*\n?/gm,"");{const h=new Set,g=/\[COMBO\][^\n]*"combo"\s*:\s*"([^"]+)"/g;let v;for(;(v=g.exec(i))!==null;)h.add(v[1]);for(const A of Object.keys(u))h.add(A);h.delete("GLSL");for(const A of h){const _=u[A]!==void 0?u[A]:0;l=Bn(l,A,String(_))}}l=Bn(l,"sample","smp"),l=l.replace(/(\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)[fh]\b/g,"$1"),l=l.replace(/\bfloat4x4\b/g,"mat4").replace(/\bfloat3x3\b/g,"mat3").replace(/\bfloat2x2\b/g,"mat2").replace(/\bfloat4\b/g,"vec4").replace(/\bfloat3\b/g,"vec3").replace(/\bfloat2\b/g,"vec2").replace(/\bhalf4\b/g,"vec4").replace(/\bhalf3\b/g,"vec3").replace(/\bhalf2\b/g,"vec2").replace(/\bhalf\b/g,"float"),l=l.replace(/\btexSample2DLod\b/g,"textureLod").replace(/\btexSample2D\b/g,"texture"),l=ze(l,"saturate",h=>"clamp("+h+", 0.0, 1.0)"),l=ze(l,"CAST4",h=>"vec4("+h+")"),l=ze(l,"CAST3",h=>"vec3("+h+")"),l=ze(l,"CAST2",h=>"vec2("+h+")"),l=l.replace(/\b(max|min)\(\s*(-?\d+(?:\.\d+)?)\s*,\s*([A-Za-z_]\w*\.(rgb|xyz|rg|xy|r|x))\s*\)/g,(h,g,v,A,_)=>{const R=_.length;return g+"(vec"+R+"("+v+"), "+A+")"}),l=l.replace(/(\.([xyzwrgba]{2,4})\s*=\s*)(max|min)\(\s*(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)\s*,\s*([^;]+?)\s*\)\s*;/g,(h,g,v,A,_,R)=>/\.[xyzwrgba]{2,4}\b|\bvec[234]\s*\(/.test(R)?`${g}${A}(vec${v.length}(${_}), ${R});`:h),l=l.replace(/(^|[^\w)\]])([+-])([+-])(?=[\d.])/g,(h,g,v,A)=>g+(v===A?"+":"-"));const f=[];l=l.replace(/\b\d+(?:\.\d+)?[eE][+-]?\d+\b/g,h=>(f.push(h),""+"".repeat(f.length)+""));const p=[];l=l.replace(/\bfor\s*\(\s*int\s+([A-Za-z_]\w*)([^)]*)\)/g,(h,g,v)=>(p.push(v+")"),`for (int ${g}${"".repeat(p.length)}`));for(let h=0;h<8;h++){const g=l;l=l.replace(/(^|[^\w.])(\d+)\s*([*/])\s*([A-Za-z_][A-Za-z0-9_]*)/g,"$1$2.0 $3 $4"),l=l.replace(/\b([A-Za-z_][A-Za-z0-9_]*)\s*([*/])\s*(\d+)(?![\d.])/g,"$1 $2 $3.0"),l=l.replace(/(\d+\.\d+)\s*([*/])\s*(\d+)(?![\d.])/g,"$1 $2 $3.0"),l=l.replace(/(^|[^\w.])(\d+)\s*([*/])\s*(\d+\.\d+)/g,"$1$2.0 $3 $4"),l=l.replace(/(\.\d+)\s*([+-])\s*(\d+)(?![\d.])/g,"$1 $2 $3.0"),l=l.replace(/([A-Za-z_]\w*\.(?:xyzw|xyz|xy|zw|rgba|rgb|rg|x|y|z|w|r|g|b|a))\s*([+-])\s*(\d+)(?![\d.])/g,"$1 $2 $3.0"),l=l.replace(/(^|[^\w.])(\d+)\s*([+-])\s*(\d+\.\d+)/g,"$1$2.0 $3 $4"),l=l.replace(/(^|[^\w.])(\d+)\s*([+-])\s*([A-Za-z_]\w*\.(?:xyzw|xyz|xy|zw|rgba|rgb|rg|x|y|z|w|r|g|b|a))/g,"$1$2.0 $3 $4"),l=l.replace(/(^|[^\w.])(\d+)\s*([*/+-])\s*(\()/g,(v,A,_,R,L,N,j)=>{let H=0,K=N+v.length-1;for(;K<j.length;K++){const W=j[K];if(W==="(")H++;else if(W===")"){if(H--,H===0){K++;break}}else if(H===0&&(W===";"||W===","||W===`
|
|
9
|
+
`))break}for(;K<j.length;K++){const W=j[K];if(W===";"||W===","||W===`
|
|
10
|
+
`||W===")")break}const O=j.slice(N,K);return/\d\.\d/.test(O)?`${A}${_}.0 ${R} ${L}`:v});{const v=new Set,A=/\b(?:uniform\s+)?(?:highp|mediump|lowp\s+)?(?:float|vec2|vec3|vec4|mat2|mat3|mat4)\s+([A-Za-z_][A-Za-z0-9_]*)/g;let _;for(;(_=A.exec(l))!==null;)v.add(_[1]);if(v.size>0){const R=Array.from(v).sort((L,N)=>N.length-L.length).join("|");l=l.replace(new RegExp("(^|[^\\w.])(\\d+)\\s*([+-])\\s*("+R+")(?![A-Za-z0-9_])","g"),"$1$2.0 $3 $4"),l=l.replace(new RegExp("\\b("+R+")\\s*([+-])\\s*(\\d+)(?![\\d.])","g"),"$1 $2 $3.0")}}if(l===g)break}{const h=["smoothstep","step","mix","clamp","max","min","pow","mod","atan","sqrt","inversesqrt","exp","log","exp2","log2","abs","sign","floor","ceil","fract","length","distance","dot","reflect","refract","faceforward","normalize","cross"],g=/\b(ApplyBlending|ApplyComposite|BlendTransparency)\s*\(/;for(const v of h)l=ze(l,v,A=>{const R=It(A).map(L=>{if(g.test(L))return L;const N=[];let j=L.replace(/\[[^\]]*\]/g,H=>(N.push(H),"\0"+(N.length-1)+"\0")).replace(/\b(?:ivec[234]|uvec[234]|int|uint)\s*\([^()]*\)/g,H=>(N.push(H),"\0"+(N.length-1)+"\0"));return j=j.replace(/(?<![A-Za-z0-9_.\u0000])(\d+)(?![.\d])(?![A-Za-z_])/g,"$1.0"),j.replace(/\u0000(\d+)\u0000/g,(H,K)=>N[Number(K)])});return v+"("+R.join(",")+")"});l=ze(l,"pow",v=>{const A=It(v);if(A.length!==2)return"pow("+v+")";const _=A[0].trim(),R=A[1].trim(),L=/\.(xyzw|rgba|xyz|rgb|xy|rg|zw)\s*$/.exec(_),j=L?{xyzw:4,rgba:4,xyz:3,rgb:3,xy:2,rg:2,zw:2}[L[1]]:0,H=/\bvec[234]\s*\(/.test(R)||/\.(xyzw|rgba|xyz|rgb|xy|rg|zw)\b/.test(R);return j>=2&&!H?"pow("+_+", vec"+j+"("+R+"))":"pow("+_+", "+R+")"})}l=l.replace(/([)\]])\s*([*/])\s*(\d+)(?![\d.])/g,"$1 $2 $3.0"),l=l.replace(/\)\s*([+-])\s*(\d+)(?![\d.])/g,") $1 $2.0"),l=l.replace(/(^|[^\w.])(\d+)(?![.\d])\s*([+-])\s*((?:step|smoothstep|mix|mod|fract|abs|sin|cos|tan|atan|sqrt|pow|inversesqrt|floor|ceil|sign|length|normalize|distance|dot|cross|exp|log|exp2|log2|clamp|min|max)\s*\()/g,"$1$2.0 $3 $4");{const h=new Set,g=/\b(?:vec[234])\s+([A-Za-z_][A-Za-z0-9_]*)/g;let v;for(;(v=g.exec(l))!==null;)h.add(v[1]);if(h.size>0){const A=Array.from(h).sort((_,R)=>R.length-_.length).join("|");l=l.replace(new RegExp("\\b("+A+")\\s*([+-])\\s*(\\d+)(?![\\d.])","g"),"$1 $2 $3.0")}}{const h=new Set,g=/\b(?:int|uint)\s+([A-Za-z_][A-Za-z0-9_]*)/g;let v;for(;(v=g.exec(l))!==null;)h.add(v[1]);l=l.replace(/\buint\b/g,"int"),l=l.replace(/\b([A-Za-z_][A-Za-z0-9_]*)\s*%\s*(\d+)(?![\d.])/g,(A,_,R)=>h.has(_)?A:"mod("+_+", "+R+".0)"),l=l.replace(/\bint\s+([A-Za-z_][A-Za-z0-9_]*)\s*=\s*mod\(([^;]*)\);/g,"int $1 = int(mod($2));")}l=l.replace(/\b(vec[234])\s+([A-Za-z_][A-Za-z0-9_]*)\s*=\s*([^;()\n,]+);/g,(h,g,v,A)=>{const _=A.trim();return/^(vec[234]|mat[234]|int\b|float\b)/.test(_)?h:g+" "+v+" = "+g+"("+_+");"});for(const h of["mix","clamp","step","smoothstep","min","max","mod","pow"])l=ze(l,h,g=>h+"("+g.replace(/(?<![A-Za-z0-9_.])(\d+)(?![.\d])/g,"$1.0")+")");l=ze(l,"clamp",h=>{const g=It(h);if(g.length!==3)return"clamp("+h+")";const v=g[0].trim(),A=g[1].trim(),_=R=>/^-?\d+\.?\d*$/.test(R);return _(v)&&_(A)&&Number(v)===0&&Number(A)===1?"clamp("+g[2].trim()+", "+v+", "+A+")":"clamp("+h+")"}),l=l.replace(/(\.\d+)\s*([+-])\s*(\d+)(?![\d.])/g,"$1 $2 $3.0"),l=l.replace(/([)\]])\s*([+-])\s*(\d+)(?![\d.])/g,"$1 $2 $3.0"),l=ze(l,"smoothstep",h=>{const g=It(h);return g.length===3&&g[1].trim()==="0.0"&&g[0].trim()!=="0.0"?"(1.0 - smoothstep(0.0, "+g[0].trim()+", "+g[2].trim()+"))":"smoothstep("+h+")"});{const h=new Map,g=/\b(?:uniform|varying|attribute|in|out)?\s*\b(vec([234]))\s+([A-Za-z_]\w*)/g;let v;for(;(v=g.exec(l))!==null;)h.set(v[3],Number(v[2]));if(h.size>0){const A={2:"xy",3:"xyz",4:"xyzw"};l=l.replace(/(^|[;{}\n]\s*)([A-Za-z_]\w*)\s*=\s*([A-Za-z_]\w*)\s*;/g,(_,R,L,N)=>{const j=h.get(L),H=h.get(N);return!j||!H||j>=H?_:R+L+" = "+N+"."+A[j]+";"})}{const A=new Set;{const L=/\b(?:uniform|varying|attribute|in|out|const)?\s*\bfloat\s+([A-Za-z_]\w*)/g;let N;for(;(N=L.exec(l))!==null;)A.add(N[1])}const _=L=>{const N=L.trim();{const K=/^vec([234])\s*\(/.exec(N);if(K){let O=0;for(let W=N.indexOf("(");W<N.length;W++)if(N[W]==="(")O++;else if(N[W]===")"&&(O--,O===0))return W===N.length-1?Number(K[1]):0;return 0}}if(/^texture(?:Lod)?\s*\(/.test(N)){let K=0;for(let O=N.indexOf("(");O<N.length;O++)if(N[O]==="(")K++;else if(N[O]===")"&&(K--,K===0))return O===N.length-1?4:0;return 0}const j=/^([A-Za-z_]\w*)(?:\.([xyzwrgba]{2,4}))?\s*[*/]\s*([^*/]+)$/.exec(N);if(!j)return 0;const H=j[3];return/\bvec[234]\s*\(|\.[xyzwrgba]{2,4}\b/.test(H)?0:j[2]?j[2].length:A.has(j[1])?0:h.get(j[1])||0};l=l.replace(/(^|[;{}\n]\s*)float\s+([A-Za-z_]\w*)\s*=\s*([^;]+);/g,(L,N,j,H)=>_(H)<2?L:`${N}float ${j} = (${H.trim()}).x;`);const R={2:"xy",3:"xyz"};l=l.replace(/(^|[;{}\n]\s*)vec([23])\s+([A-Za-z_]\w*)\s*=\s*([^;]+);/g,(L,N,j,H,K)=>{const O=Number(j);return _(K)<=O?L:`${N}vec${j} ${H} = (${K.trim()}).${R[O]};`})}if(h.size>0){const A=new Set,_=/\b(?:uniform|varying|attribute|in|out)?\s*\bfloat\s+([A-Za-z_]\w*)/g;let R;for(;(R=_.exec(l))!==null;)A.add(R[1]);const L="pow|saturate|clamp|smoothstep|step|abs|floor|ceil|fract|frac|sin|cos|tan|asin|acos|atan|sqrt|length|distance|dot|exp|log|sign|fmod|mod|min|max|mix|lerp",N=/^(?:length|distance|dot)$/,j=K=>{const O=K.match(new RegExp("^(?:"+L+")\\s*\\("));if(!O)return!1;let W=0;const X=O[0].length-1;let ie=-1;for(let te=X;te<K.length;te++)if(K[te]==="(")W++;else if(K[te]===")"&&(W--,W===0)){ie=te;break}if(ie!==K.length-1)return!1;const J=O[0].replace(/\s*\($/,"");if(N.test(J))return!0;const Z=K.slice(X+1,ie);if(/\bvec[234]\s*\(/.test(Z)||/\.[xyzwrgba]{2,4}\b/.test(Z))return!1;for(const te of h.keys()){const le=te.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp("(?<!\\.)\\b"+le+"\\b(?!\\s*\\.[xyzwrgba]\\b)").test(Z))return!1}return!0},H=new Set;if(l=l.replace(/(^|[;{}\n]\s*)([A-Za-z_]\w*)\s*=\s*([^;]+);/g,(K,O,W,X)=>{const ie=h.get(W);if(!ie||A.has(W))return K;const J=X.trim();if(new RegExp("^vec"+ie+"\\s*\\(").test(J)||h.has(J))return K;const Z=/^-?\d+(?:\.\d+)?(?:e[-+]?\d+)?$/i.test(J),te=A.has(J);return!Z&&!te&&!j(J)?K:(H.add(W),O+W+" = vec"+ie+"("+J+");")}),H.size>0){const K=[...H].sort((O,W)=>W.length-O.length).join("|");l=l.replace(new RegExp(`\\b([A-Za-z_]\\w*)\\s*([*/])\\s*(${K})\\b`,"g"),(O,W,X,ie)=>h.has(W)?O:`${W} ${X} ${ie}.x`),l=l.replace(new RegExp(`\\b(${K})\\s*([*/])\\s*([A-Za-z_]\\w*)\\b`,"g"),(O,W,X,ie)=>h.has(ie)?O:`${W}.x ${X} ${ie}`)}}}l=l.replace(/(\.[xyzwrgba]{1,4}\s*=\s*)(-?\d+)\s*;/g,"$1$2.0;"),l=l.replace(/\b(float|vec2|vec3|vec4)\s+([A-Za-z_]\w*)\s*=\s*(-?\d+)\s*;/g,(h,g,v,A)=>g==="float"?`${g} ${v} = ${A}.0;`:`${g} ${v} = ${g}(${A}.0);`);{const h=new Set,g=/\b(?:uniform|varying|attribute|in|out)?\s*\bfloat\s+([A-Za-z_]\w*)/g;let v;for(;(v=g.exec(l))!==null;)h.add(v[1]);if(h.size>0){const A=[...h].sort((_,R)=>R.length-_.length).join("|");l=l.replace(new RegExp(`\\b(${A})\\s*=\\s*(-?\\d+)\\s*;`,"g"),"$1 = $2.0;"),l=l.replace(new RegExp(`\\b(${A})\\s*([-+*/]=)\\s*(-?\\d+)\\s*;`,"g"),"$1 $2 $3.0;")}}l=l.replace(/(\.[xyzwrgba]{1,4}\s*[-+*/]=\s*)(-?\d+)\s*;/g,"$1$2.0;");const d="step|smoothstep|saturate|clamp|mix|lerp|frac|fract|abs|floor|ceil|min|max|pow|sqrt|length|dot|distance";l=l.replace(new RegExp(`\\bint\\s+([A-Za-z_]\\w*)\\s*=\\s*((?:${d})\\s*\\()`,"g"),"float $1 = $2"),l=l.replace(/\bfloat\s+([A-Za-z_]\w*)\s*=\s*(int\s*\([^;]*\))\s*;/g,"float $1 = float($2);");{const h=Ho(l);h.size>0&&(l=l.replace(/\b(const\s+)?float\s+([A-Za-z_]\w*)\s*=\s*([^;{}]+);/g,(g,v,A,_)=>{const R=_.trim();if(/\./.test(R)||/[A-Za-z_]\w*\s*\(/.test(R))return g;const L=R.match(/[A-Za-z_]\w*/g);return!L||!L.length||!L.every(N=>h.has(N))?g:`${v||""}float ${A} = float(${R});`}))}{const h=Ho(l),g=new Set;let v;const A=/\b(?:const\s+|uniform\s+|varying\s+|in\s+|out\s+)*float\s+([A-Za-z_]\w*)/g;for(;(v=A.exec(l))!==null;)g.add(v[1]);for(const _ of[...h])g.has(_)&&(h.delete(_),g.delete(_));if(h.size>0&&g.size>0){const _=[...h].sort((L,N)=>N.length-L.length).join("|"),R=[...g].sort((L,N)=>N.length-L.length).join("|");l=l.replace(new RegExp(`\\b(${_})\\s*([*/+-])\\s*(${R})\\b`,"g"),(L,N,j,H)=>`float(${N}) ${j} ${H}`),l=l.replace(new RegExp(`\\b(${R})\\s*([*/+-])\\s*(${_})\\b`,"g"),(L,N,j,H)=>`${N} ${j} float(${H})`)}}{const h=new Set,g=/\bbool\s+([A-Za-z_]\w*)\s*=/g;let v;for(;(v=g.exec(l))!==null;)h.add(v[1]);if(h.size>0){const A=[...h].join("|");l=l.replace(new RegExp(`([-+*/]=\\s*)(${A})\\b`,"g"),(_,R,L)=>`${R}float(${L})`)}}{const h=/\(\s*([^()&|]+?)\s*(<=|>=|<|>|==|!=)\s*([^()&|]+?)\s*\)/g;l=l.replace(new RegExp(h.source+"\\s*([*/])","g"),(g,v,A,_,R)=>`float(${v.trim()} ${A} ${_.trim()}) ${R}`),l=l.replace(new RegExp("([-+*/]=\\s*)"+h.source,"g"),(g,v,A,_,R)=>`${v}float(${A.trim()} ${_} ${R.trim()})`)}{const h=new Set;for(const g of l.matchAll(/\b(?:uniform\s+)?(?:highp|mediump|lowp\s+)?float\s+([A-Za-z_]\w*)\s*\[/g))h.add(g[1]);if(h.size){const g=[...h].sort((L,N)=>N.length-L.length).join("|"),v=new RegExp("\\b("+g+")\\s*\\[","g");let A="",_=0,R;for(;R=v.exec(l);){const L=R.index+R[0].length-1,N=cr(l,L,"[","]");if(N<0)break;let j=N+1;for(;j<l.length&&/[ \t]/.test(l[j]);)j++;if(l[j]!=="["){const X=l.slice(L+1,N).trim(),ie=/\d\.\d/.test(X)||/^[A-Za-z_]\w*$/.test(X)&&new RegExp("\\bfloat\\s+"+X.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+"\\b").test(l),J=/^\s*int\s*\(/.test(X)||/^-?\d+$/.test(X);if(ie&&!J){A+=l.slice(_,R.index),A+=R[1]+"[int("+X+")]",_=N+1,v.lastIndex=_;continue}v.lastIndex=N+1;continue}const H=cr(l,j,"[","]");if(H<0)break;const K=l.slice(L+1,N),O=l.slice(j+1,H);A+=l.slice(_,R.index),A+=R[1]+"[int(("+K+")) * 4 + int(("+O+"))]",_=H+1,v.lastIndex=_}l=A+l.slice(_)}}l=ze(l,"mix",(h,g)=>{const v=It(h);if(v.length!==3)return"mix("+h+")";const A=j=>{const H=j.trim(),K=/\.([xyzwrgba]{1,4})\s*$/.exec(H);if(K)return K[1].length;const O=/^vec([234])\s*\(/.exec(H);if(O)return Number(O[1]);if(!/^[A-Za-z_]\w*$/.test(H))return 0;const W=new RegExp("\\b(vec([234])|float)\\s+"+H+"\\b","g");let X=0,ie;for(;(ie=W.exec(l))!==null&&ie.index<g;)X=ie[1].startsWith("vec")?Number(ie[2]):1;return X},_=v[0].trim(),R=v[1].trim(),L=A(_),N=A(R);if(L>=2&&N>=2&&L!==N){const j=Math.min(L,N),H=j===2?".xy":j===3?".xyz":"";return H?"mix("+(L>j?_+H:_)+", "+(N>j?R+H:R)+", "+v[2].trim()+")":"mix("+h+")"}return"mix("+h+")"});{const h=/\b(vec([234]))\s+([A-Za-z_]\w*)\s*\(/g;let g="",v=0,A;for(;A=h.exec(l);){const _=Wo(l,A.index+A[0].length-1);if(_<0)break;let R=_+1;for(;R<l.length&&/\s/.test(l[R]);)R++;if(l[R]!=="{")continue;const L=cr(l,R,"{","}");if(L<0)break;const N=Number(A[2]);if(N>=4){h.lastIndex=L;continue}let j=l.slice(R+1,L);const H=new Map;for(const O of l.slice(0,A.index).matchAll(/\buniform\s+(?:highp|mediump|lowp\s+)?(vec([234]))\s+([A-Za-z_]\w*)/g))H.set(O[3],Number(O[2]));for(const O of j.matchAll(/\b(vec([234]))\s+([A-Za-z_]\w*)/g))H.set(O[3],Number(O[2]));const K=N===2?"xy":"xyz";j=j.replace(/\breturn\s+([A-Za-z_]\w*)\s*;/g,(O,W)=>{const X=H.get(W);return X&&X>N?"return "+W+"."+K+";":O}),g+=l.slice(v,R+1)+j,v=L,h.lastIndex=L}l=g+l.slice(v)}const y=new Set,x=/\b(?:uniform\s+)?(?:mat4|mat3|mat2|float4x4)\s+([A-Za-z_][A-Za-z0-9_]*)/g;let m;for(;(m=x.exec(l))!==null;)y.add(m[1]);if(l=ze(l,"mul",h=>{const g=It(h);if(g.length!==2)return"mul("+h+")";const v=g[0].trim(),A=g[1].trim(),_=R=>y.has(R.split(/[\[.\s]/)[0])||/^mat[234]\(/.test(R);return _(v)&&_(A)?"(transpose("+A+") * transpose("+v+"))":_(A)?"(transpose("+A+") * "+v+")":"("+v+" * "+A+")"}),l=l.replace(/\blerp\b/g,"mix").replace(/\bfrac\b/g,"fract"),l=ze(l,"atan2",h=>"atan("+h+")"),l=ze(l,"fmod",h=>{const g=It(h);if(g.length!==2)return"mod("+h+")";const v=g[0].trim(),A=g[1].trim();return"(("+v+") - ("+A+") * trunc(("+v+") / ("+A+")))"}),l=ze(l,"ddx",h=>"dFdx("+h+")"),l=ze(l,"ddy",h=>"dFdy("+h+")"),l=ze(l,"CAST3X3",h=>"mat3("+h+")"),n==="vert")l=l.replace(/\battribute\b/g,"in").replace(/\bvarying\b/g,"out");else{if(l=l.replace(/\bvarying\b/g,"in").replace(/\battribute\b/g,"in"),typeof o=="string"&&o){const v=new Map,A=/^\s*(?:varying|out)\s+(?:highp|mediump|lowp\s+)?(vec[234]|float)\s+([A-Za-z_]\w*)\s*;/gm;let _;for(;(_=A.exec(o))!==null;)v.set(_[2],_[1]);const R={float:1,vec2:2,vec3:3,vec4:4},L=new Map;if(l=l.replace(/^(\s*in\s+(?:highp|mediump|lowp\s+)?)(vec[234]|float)(\s+)([A-Za-z_]\w*)(\s*;)/gm,(N,j,H,K,O,W)=>{const X=v.get(O);return!X||R[X]<=R[H]?N:(L.set(O,R[H]),j+X+K+O+W)}),L.size>0){const N={1:"x",2:"xy",3:"xyz"};for(const[j,H]of L){const K=N[H];K&&(l=l.split(`
|
|
11
|
+
`).map(O=>/^\s*in\s/.test(O)?O:O.replace(new RegExp("\\b"+j+"\\b(?!\\s*[.\\w])","g"),j+"."+K)).join(`
|
|
12
|
+
`))}}l=l.replace(/^(\s*in\s+(?:highp|mediump|lowp\s+)?)(vec[234]|float)(\s+)([A-Za-z_]\w*)(\s*;)/gm,(N,j,H,K,O,W)=>{const X=v.get(O);if(!X||R[X]>=R[H])return N;const ie="xyzw",J="rgba";return new RegExp("\\b"+O+"\\s*\\.\\s*["+ie+J+"]*["+ie.slice(R[X])+J.slice(R[X])+"]").test(l)?N:j+X+K+O+W})}{const v=new Map,A=/^\s*in\s+(?:highp|mediump|lowp\s+)?(vec[34])\s+([A-Za-z_]\w*)\s*;/gm;let _;for(;(_=A.exec(l))!==null;)v.set(_[2],Number(_[1].slice(3)));const R=new Map(v),L=/\b(vec[34])\s+([A-Za-z_]\w*)\s*[=;]/g;for(;(_=L.exec(l))!==null;)R.has(_[2])||R.set(_[2],Number(_[1].slice(3)));if(R.size>0){const N=j=>{const H=j.trim();if(!H)return j;const K=/^([A-Za-z_]\w*)$/.exec(H);if(K&&R.has(K[1]))return K[1]+".xy";const O=/^([A-Za-z_]\w*)(\s*[+\-].+)$/.exec(H);return O&&R.has(O[1])?"("+O[1]+".xy"+O[2]+")":j};for(const j of["textureLod","texture"])l=ze(l,j,H=>{const K=It(H);return K.length>=2&&(K[1]=N(K[1])),j+"("+K.join(", ")+")"})}v.size>0&&(l=l.split(`
|
|
13
|
+
`).map(N=>{if(!/\bvec2\s+[A-Za-z_]\w*\s*=/.test(N))return N;let j=N;for(const H of v.keys())j=j.replace(new RegExp("\\b"+H+"\\b(?!\\s*[.\\w])","g"),H+".xy");return j}).join(`
|
|
14
|
+
`))}const h=new Set,g=new Set;{const v=/^\s*in\s+(?:highp|mediump|lowp\s+)?(vec[234]|float)\s+([A-Za-z_]\w*)\s*;/gm;let A;for(;(A=v.exec(l))!==null;)g.add(A[2])}for(const v of g)new RegExp("\\b"+v+"\\b\\s*(?:\\.[xyzwrgba]{1,4})?\\s*(?:[-+*/]?=(?!=)|\\+\\+|--)").test(l)&&h.add(v);if(h.size>0){const v=l.search(/\bvoid\s+main\s*\([^)]*\)\s*\{/);if(v!==-1){const A=l.indexOf("{",v),_=l.slice(0,A+1);let R=l.slice(A+1);const L=[];for(const N of h){if(new RegExp("(?:^|[;{}\\n])\\s*(?:highp|mediump|lowp\\s+)?(?:vec[234]|float|int|bool)\\s+"+N+"\\s*[=;]").test(R))continue;const H=new RegExp("^\\s*in\\s+(?:highp|mediump|lowp\\s+)?(vec[234]|float)\\s+"+N+"\\s*;","m").exec(l),K=H?H[1]:"vec4";L.push(" "+K+" "+N+"_rw = "+N+";"),R=Bn(R,N,N+"_rw")}L.length>0&&(R=`
|
|
15
|
+
`+L.map(N=>N.replace(/= (\w+)_rw;/,"= $1;")).join(`
|
|
16
16
|
`)+`
|
|
17
|
-
`+
|
|
18
|
-
`).map(
|
|
19
|
-
`)}
|
|
20
|
-
`;return n==="vert"&&(
|
|
21
|
-
`),n==="frag"&&(
|
|
22
|
-
`,/\bgl_FragColor\b/.test(l)&&(
|
|
23
|
-
`,l=l.replace(/\bgl_FragColor\b/g,"fragColor"))),
|
|
17
|
+
`+R),l=_+R}}}l=l.replace(/\[(?:unroll|loop|branch|flatten)\]\s*/g,""),l=l.replace(/\bstatic\s+/g,""),p.length>0&&(l=l.replace(/\u0003(\u0004+)\u0003/g,(h,g)=>p[g.length-1]));{const h=new Set;for(const g of l.matchAll(/\b(?:uniform[ \t]+)?(?:highp|mediump|lowp)?[ \t]*float[ \t]+([A-Za-z_]\w*)[ \t]*[;=]/g))h.add(g[1]);if(h.size){const g=v=>{const A=v.trim().startsWith("-"),_=v.replace(/^-\s*/,"").trim();return h.has(_)?(A?"-":"")+"int("+_+")":v};l=l.replace(/(for\s*\(\s*(?:int|uint)\s+(\w+)\s*=\s*)(-?\s*[A-Za-z_]\w*|-?\s*\d+)(\s*;\s*\2\s*[<>]=?\s*)(-?\s*[A-Za-z_]\w*|-?\s*\d+)(\s*;)/g,(v,A,_,R,L,N,j)=>A+g(R)+L+g(N)+j)}}{const h=new Set;l=l.split(`
|
|
18
|
+
`).map(g=>{const v=/^[ \t]*uniform[ \t]+(?:highp|mediump|lowp[ \t]+)?[A-Za-z0-9_]+[ \t]+([A-Za-z_][A-Za-z0-9_]*)/.exec(g);if(!v)return g;const A=v[1];return h.has(A)?"":(h.add(A),g)}).join(`
|
|
19
|
+
`)}f.length>0&&(l=l.replace(/\u0001(\u0002+)\u0001/g,(h,g)=>f[g.length-1]));let M=`#version 300 es
|
|
20
|
+
`;return n==="vert"&&(M+=`precision highp float;
|
|
21
|
+
`),n==="frag"&&(M+=`precision highp float;
|
|
22
|
+
`,/\bgl_FragColor\b/.test(l)&&(M+=`out vec4 fragColor;
|
|
23
|
+
`,l=l.replace(/\bgl_FragColor\b/g,"fragColor"))),M+l}const Go={center:[.5,.5],centre:[.5,.5],left:[0,.5],right:[1,.5],top:[.5,0],bottom:[.5,1],topleft:[0,0],topright:[1,0],bottomleft:[0,1],bottomright:[1,1]},Ra={2:"multiply",6:"additive",7:"screen",9:"additive",31:"additive"},ka={screen:1,multiply:2},Hr=`#version 300 es
|
|
24
24
|
in vec3 a_Position;
|
|
25
25
|
in vec2 a_TexCoord;
|
|
26
26
|
uniform mat4 u_MVP;
|
|
@@ -28,7 +28,7 @@ out vec2 v_UV;
|
|
|
28
28
|
void main() {
|
|
29
29
|
gl_Position = u_MVP * vec4(a_Position, 1.0);
|
|
30
30
|
v_UV = a_TexCoord;
|
|
31
|
-
}`,
|
|
31
|
+
}`,Fa=`#version 300 es
|
|
32
32
|
precision mediump float;
|
|
33
33
|
in vec2 v_UV;
|
|
34
34
|
uniform sampler2D u_Tex;
|
|
@@ -44,7 +44,7 @@ void main() {
|
|
|
44
44
|
if (u_BlendPrep == 1) c.rgb *= c.a;
|
|
45
45
|
else if (u_BlendPrep == 2) c.rgb = mix(vec3(1.0), c.rgb, c.a);
|
|
46
46
|
fragColor = c;
|
|
47
|
-
}`,
|
|
47
|
+
}`,Na=`#version 300 es
|
|
48
48
|
precision mediump float;
|
|
49
49
|
in vec2 v_UV;
|
|
50
50
|
uniform sampler2D u_Tex;
|
|
@@ -55,15 +55,15 @@ void main() {
|
|
|
55
55
|
if (u_BlendPrep == 1) c.rgb *= c.a;
|
|
56
56
|
else if (u_BlendPrep == 2) c.rgb = mix(vec3(1.0), c.rgb, c.a);
|
|
57
57
|
fragColor = c;
|
|
58
|
-
}`,
|
|
58
|
+
}`,Ua=`#version 300 es
|
|
59
59
|
precision mediump float;
|
|
60
60
|
in vec2 v_UV;
|
|
61
61
|
uniform sampler2D u_Tex;
|
|
62
62
|
out vec4 fragColor;
|
|
63
63
|
void main() {
|
|
64
64
|
fragColor = vec4(texture(u_Tex, v_UV).rgb, 1.0);
|
|
65
|
-
}`;function
|
|
66
|
-
void main(`));const o=n?/unprojectedUVs\s*\*=\s*v_PointerScale\s*\*/:/unprojectedUVs\s*\*=\s*g_PointerScale\s*\*/;return r.replace(o,"unprojectedUVs *= "+Na+" *")}function Ua(e,n={}){const t=e.getContext("webgl2",{premultipliedAlpha:!1,antialias:!1,alpha:!1,preserveDrawingBuffer:!0});if(!t)throw new Error("\u5F53\u524D\u6D4F\u89C8\u5668\u4E0D\u652F\u6301 WebGL2");const r=n.shaderResolver||(async()=>null),o=n.diag||(()=>{}),i=typeof document<"u"?document.createElement("canvas"):null;i&&(i.style.cssText="position:fixed;left:-9999px;top:-9999px;width:2px;height:2px;opacity:0");let s=!1,a=n.fboCapFactor===void 0?0:n.fboCapFactor,c=null,u=null,l=null;const p=[["g_AudioSpectrum16Left","left16"],["g_AudioSpectrum16Right","right16"],["g_AudioSpectrum32Left","left32"],["g_AudioSpectrum32Right","right32"],["g_AudioSpectrum64Left","left64"],["g_AudioSpectrum64Right","right64"]];function f(x){l=x||null}let d=null,w=null,M=null,m=null,A=null,h=null,b=null;const v=new Map,T=new Map,_={total:0,ok:0,failed:0};function F(x,D){d=typeof x=="function"?x:null,w=D&&D.userProperties||null,M=D&&D.audioViews||null,m=D&&D.shared||null,A=D&&D.inputView||null,h=D&&D.timers||null,b=D&&typeof D.onSandbox=="function"?D.onSandbox:null,v.clear(),T.clear()}let R=!1;const k=lr(t,Vr,xa),U=lr(t,Vr,wa),V=lr(t,Vr,Ma),q=t.createVertexArray();t.bindVertexArray(q);const W=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,W),t.enableVertexAttribArray(0),t.vertexAttribPointer(0,3,t.FLOAT,!1,20,0),t.enableVertexAttribArray(1),t.vertexAttribPointer(1,2,t.FLOAT,!1,20,12),t.bindVertexArray(null);const Z=new Map;let K=1;function re(x,D,H){const z=(H||"")+"|"+x+"x"+D;if(Z.has(z)){const L=Z.get(z);return L.stamp=K,L}const G=t.createFramebuffer(),g=t.createTexture();t.bindTexture(t.TEXTURE_2D,g),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,x,D,0,t.RGBA,t.UNSIGNED_BYTE,null),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.bindFramebuffer(t.FRAMEBUFFER,G),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,g,0),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.bindFramebuffer(t.FRAMEBUFFER,null);const S={fbo:G,tex:g,width:x,height:D,stamp:K};return Z.set(z,S),S}function te(){for(const[x,D]of Z)D.stamp!==K&&(D.fbo&&t.deleteFramebuffer(D.fbo),D.tex&&t.deleteTexture(D.tex),Z.delete(x))}const X=new Map,J=new Map,de=new Map;function Se(x){const D={},H=/uniform\s+[A-Za-z0-9_]+\s+([A-Za-z_][A-Za-z0-9_]*)[^;]*;\s*\/\/([^\n]*)/g;let z;for(;(z=H.exec(x))!==null;){const G=z[1],g=z[2],S=/"material"\s*:\s*"([^"]+)"/.exec(g);if(!S)continue;const L=/"default"\s*:\s*("(?:[^"]*)"|-?\d+(?:\.\d+)?)/.exec(g);D[S[1]]={uniform:G,default:L?Qe(L[1]):void 0}}return D}function Ae(x){const D=new Map,H=/uniform\s+sampler2D\s+g_Texture(\d+)\s*;\s*\/\/([^\n]*)/g;let z;for(;(z=H.exec(x))!==null;){const G=Number(z[1]),g=/"default"\s*:\s*"([^"]+)"/.exec(z[2]);g&&g[1]&&D.set(G,g[1])}return D}function De(x){const D=[],H=/uniform\s+sampler2D\s+(g_Texture(\d+))[^;]*;\s*\/\/([^\n]*)/g;let z;for(;(z=H.exec(x))!==null;){const G=/"combo"\s*:\s*"([^"]+)"/.exec(z[3]);G&&D.push({slot:Number(z[2]),name:z[1],combo:G[1]})}return D}function Qe(x){if(x.startsWith('"'))return x.slice(1,-1);const D=Number(x);return Number.isFinite(D)?D:void 0}async function Ve(x,D,H){let z=de.get(x);if(z===void 0){const S=await r("shaders/"+x+".frag")||"",L=await r("shaders/"+x+".vert")||"";z={frag:S,vert:L,texCombos:De(S)},de.set(x,z)}const G={...D};for(const S of z.texCombos)H&&H[S.slot]&&G[S.combo]===void 0&&(G[S.combo]=1);const g=x+"|"+JSON.stringify(G);if(X.has(g)){const S=X.get(g);if(S===null)throw new Error("shader="+x+" \u7F16\u8BD1\u5931\u8D25\uFF08\u5DF2\u7F13\u5B58\uFF09");return S}for(let S=0;S<4;S++){const L=new Set,E=I=>J.has(I)?J.get(I):(L.add(I),null),N=Zo(jo(z.frag,"frag",G,E,z.vert)),j=jo(z.vert,"vert",G,E,z.frag);if(L.size===0){let I;try{I=lr(t,j,N)}catch(C){throw X.set(g,null),new Error("shader="+x+" "+(C&&C.message))}const B=new Map,O=t.getProgramParameter(I,t.ACTIVE_UNIFORMS);for(let C=0;C<O;C++){const Q=t.getActiveUniform(I,C),ee=Q.name.replace(/\[0\]$/,"");B.set(ee,{loc:t.getUniformLocation(I,Q.name),type:Sa[Q.type]||"unknown",size:Q.size})}const Y={...Se(z.vert),...Se(z.frag)},$=/gl_Position\s*=\s*vec4\s*\(\s*a_Position/.test(z.vert)&&!/[aA]_Position[\s\S]{0,40}mul\s*\(/.test(z.vert),P=new Map([...Ae(z.vert),...Ae(z.frag)]),y={prog:I,uni:B,matMeta:Y,samplerDefaults:P,fragGlsl:N,vertGlsl:j,ndcDirect:$};return X.set(g,y),y}await Promise.all(Array.from(L).map(async I=>{J.set(I,await r("shaders/"+I)||"")}))}throw new Error("include \u89E3\u6790\u5931\u8D25: "+x)}const Ee=Wr(t,new Uint8Array([255,255,255,255]),1,1),Re=Wr(t,new Uint8Array([0,0,0,0]),1,1);let le=null;function Pe(x){le=x||null}function Be(){if(!le)return null;const x=typeof le=="function"?le():le;return x&&x.state?x.state:x}const Me={x:0,y:0,sx:0,sy:0};let _e=0,Ie=0,We=0,ft=1/60,me=-1;const Tt=typeof n.fadeDuration=="number"&&n.fadeDuration>=0?n.fadeDuration:1,Xn=(x,D)=>{const H=x!==null&&typeof x=="object"?x.value:x;return H===!0||H===1?!0:H===!1||H===0?!1:D},yt=(x,D)=>{const H=x!==null&&typeof x=="object"?x.value:x;return typeof H=="number"&&Number.isFinite(H)?H:D},Gn=x=>n.fade!==!1&&Xn(x.camerafade,!1);function Er(x,D){if(!Xn(x.camerashake,!1))return null;const H=yt(x.camerashakeamplitude,0);if(H===0)return null;const z=Math.max(0,Math.min(1,yt(x.camerashakeroughness,0))),G=yt(x.camerashakespeed,1),g=D*G,S=Math.sin(g*2.1)*Math.cos(g*.7),L=Math.cos(g*1.7)*Math.sin(g*.9),E=Math.sin(g*11.3)*Math.cos(g*7.1),N=Math.cos(g*9.7)*Math.sin(g*13.1);return{x:(S*(1-z)+E*z)*H,y:(L*(1-z)+N*z)*H}}function qn(){const x=new Date;return(x.getHours()*3600+x.getMinutes()*60+x.getSeconds())/86400}function ye(x,D,H){const z=x.get(D);z&&z.loc!==null&&H(z.loc,z.type,z.size)}function He(x){if(typeof x=="number")return[x,x,x,x];const D=String(x).trim().split(/[\s,]+/).map(Number);return[D[0]||0,D[1]||0,D[2]||0,D[3]||0]}function cn(x,D,H){const z=x.get(D);if(!z||z.loc===null)return;const G=H&&H.value!==void 0?H.value:H,g=He(G);switch(z.type){case"float":t.uniform1f(z.loc,g[0]);break;case"int":case"bool":t.uniform1i(z.loc,G===!0||G===1?1:Math.round(g[0]));break;case"vec2":t.uniform2f(z.loc,g[0],g[1]);break;case"vec3":t.uniform3f(z.loc,g[0],g[1],g[2]);break;case"vec4":t.uniform4f(z.loc,g[0],g[1],g[2],g[3]);break;case"mat4":t.uniformMatrix4fv(z.loc,!1,dt);break;case"mat3":t.uniformMatrix3fv(z.loc,!1,Zt);break}}const Nt=()=>new Float32Array([1,0,0,0,1,0,0,0,1]);function Yn(x,D,H,z,G,g,S,L,E,N,j){if(ye(x,"g_Time",y=>t.uniform1f(y,H)),ye(x,"g_Daytime",y=>t.uniform1f(y,qn())),ye(x,"g_ModelViewProjectionMatrix",y=>t.uniformMatrix4fv(y,!1,g)),ye(x,"g_ModelMatrix",y=>t.uniformMatrix4fv(y,!1,S)),ye(x,"g_ViewProjectionMatrix",y=>t.uniformMatrix4fv(y,!1,L)),x.get("g_ModelViewProjectionMatrixInverse")){let y=null;for(const[Q,ee]of E)Q===0&&(y=ee);const C=y&&y[0]>0&&y[1]>0?Lo(Ln(bn(),y[0]/2,y[1]/2,1)):dt;ye(x,"g_ModelViewProjectionMatrixInverse",Q=>t.uniformMatrix4fv(Q,!1,C))}ye(x,"g_Brightness",y=>t.uniform1f(y,D.brightness)),ye(x,"g_UserAlpha",y=>t.uniform1f(y,D.alpha)),ye(x,"g_Alpha",y=>t.uniform1f(y,D.alpha)),ye(x,"g_Color",y=>t.uniform3f(y,D.color[0],D.color[1],D.color[2])),ye(x,"g_Color4",y=>t.uniform4f(y,D.color[0],D.color[1],D.color[2],1)),ye(x,"g_CompositeColor",y=>t.uniform3f(y,D.color[0],D.color[1],D.color[2])),ye(x,"g_TexelSize",y=>t.uniform2f(y,1/z,1/G)),ye(x,"g_TexelSizeHalf",y=>t.uniform2f(y,.5/z,.5/G)),ye(x,"g_TextureReductionScale",y=>t.uniform1f(y,1));const I=Be(),B=Gr(!!(I&&I.has),!!x.get("g_PointerScale"));let O=B?kn:I?I.u:.5,Y=B?kn:I?I.v:.5,$=B?kn:I?I.lastU:.5,P=B?kn:I?I.lastV:.5;if(j&&D&&D.size&&D.size[0]>0&&D.size[1]>0){const y=Math.abs(D.size[0]*D.scale[0]),C=Math.abs(D.size[1]*D.scale[1]);if(y>0&&C>0){const Q=D.origin[0]-y/2,ee=j.projH-D.origin[1]-C/2,ie=fe=>(j.offX+fe*j.viewW-Q)/y,oe=fe=>(j.offY+fe*j.viewH-ee)/C;O=ie(O),Y=oe(Y),$=ie($),P=oe(P)}}ye(x,"g_PointerPosition",y=>t.uniform2f(y,O,Y)),ye(x,"g_PointerPositionLast",y=>t.uniform2f(y,$,P)),ye(x,"g_PointerState",y=>t.uniform4f(y,O,Y,I&&I.leftDown?1:0,0)),ye(x,"g_ParallaxPosition",y=>t.uniform2f(y,Me.sx*.5+.5,Me.sy*.5+.5)),ye(x,"g_Frametime",y=>t.uniform1f(y,ft)),x.get("g_EffectTextureProjectionMatrixInverse")&&ye(x,"g_EffectTextureProjectionMatrixInverse",y=>t.uniformMatrix4fv(y,!1,dt));for(let y=0;y<8;y++)ye(x,"g_Texture"+y,C=>t.uniform1i(C,y));for(const[y,C]of E)ye(x,"g_Texture"+y+"Resolution",Q=>t.uniform4f(Q,C[0],C[1],C[2],C[3]));if(l){const y=typeof l=="function"?l():l;if(y)for(const[C,Q]of p){const ee=y[Q];ee&&ye(x,C,ie=>t.uniform1fv(ie,ee))}}}function Zn(x,D,H){for(const[z,G]of Object.entries(D||{})){const g=H&&H[z];g&&cn(x,g.uniform,G)}for(const[z,G]of Object.entries(H||{}))(!D||!(z in D))&&G.default!==void 0&&cn(x,G.uniform,G.default)}function Pr(x){const D=Be();Gr(!!(D&&D.has),!!x.get("g_PointerScale"))&&ye(x,"g_PointerScale",H=>t.uniform1f(H,0))}function Kn(x,D,H,z){if(!x)return x;let G=!1;for(const S of Object.values(x))if(S!==null&&typeof S=="object"&&typeof S.script=="string"){G=!0;break}if(!G||!d)return x;const g={...x};for(const[S,L]of Object.entries(x)){if(L===null||typeof L!="object"||typeof L.script!="string")continue;const E=D+"|"+S;let N=v.get(E);if(N===void 0){_.total++;try{N=d(L.script,L.scriptproperties||L.scriptProperties||null,{userProperties:w||{},audioViews:M||void 0,layer:z||null,shared:m||{},inputView:A||void 0,setTimeout:h?h.setTimeout:void 0,clearTimeout:h?h.clearTimeout:void 0,setInterval:h?h.setInterval:void 0,clearInterval:h?h.clearInterval:void 0})}catch{N=null}if(N?_.ok++:_.failed++,v.set(E,N),N){const $=L.value!==void 0?L.value:L,P=He($),C=typeof $=="number"?P[0]:{x:P[0],y:P[1],z:P[2]};N.init&&N.init(C)}if(N&&typeof N.applyUserProperties=="function")try{N.applyUserProperties(w||{})}catch{}if(N&&N.hasMediaHook&&b)try{b(N)}catch{}}if(!N||N.disabled||!N.hasUpdate)continue;if(N.engine){N.engine.runtime=H,N.engine.frametime=ft,N.engine.timeOfDay=qn();const $=Be();$&&$.screenW&&$.screenH&&(N.engine.screenResolution={x:$.screenW,y:$.screenH})}const j=He(L.value!==void 0?L.value:L),B=typeof(L.value!==void 0?L.value:L)=="number"?j[0]:{x:j[0],y:j[1],z:j[2]};let O;try{O=N.callUpdate(B)}catch{O=void 0}const Y=O??B;if(typeof Y=="number"&&Number.isFinite(Y))g[S]=Y;else if(Y&&typeof Y=="object"){const $=Number(Y.x),P=Number(Y.y),y=Number(Y.z);Number.isFinite($)&&Number.isFinite(P)&&(g[S]=Number.isFinite(y)?`${$} ${P} ${y}`:`${$} ${P} 0`)}}return g}function ln(x,D,H){if(!x)return x;let z=!1;for(const g of Object.values(x))if(g&&typeof g=="object"&&g.animation&&g.animation.options){z=!0;break}if(!z)return x;const G={...x};for(const[g,S]of Object.entries(x)){if(!S||typeof S!="object"||!S.animation||!S.animation.options)continue;const L=D+"|anim|"+g;let E=T.get(L);if(!E){const N=Xo(S.animation),j=S.value!==void 0?S.value:0;N.baseNumeric=Array.isArray(j)?j.slice():j,E={ctrl:N},T.set(L,E)}E.ctrl.playing&&E.ctrl.setFrame(H*E.ctrl.fps*E.ctrl.rate),G[g]=E.ctrl.applyTo(E.ctrl.baseNumeric)}return G}function Cr(x,D,H,z){return x==null||x===""?null:x.startsWith("_rt_")?x.startsWith("_rt_imageLayerComposite")?It&&St.has(x)?St.get(x):D:H.has(x)?H.get(x):null:H.has(x)?H.get(x):z.get(x)||null}const qt=Aa(),_n=Ta(),vt=new Map;function Yt(x,D){const H=x+"x"+D;let z=vt.get(H);return z===void 0&&(z=_a(x,D),vt.set(H,z)),z}let Ut=null;function st(x,D){Ut!==x&&(t.bindBuffer(t.ARRAY_BUFFER,W),t.bufferData(t.ARRAY_BUFFER,D,t.DYNAMIC_DRAW),Ut=x)}const we={mvp:t.getUniformLocation(k,"u_MVP"),tex:t.getUniformLocation(k,"u_Tex"),color:t.getUniformLocation(k,"u_Color4"),frameOrigin:t.getUniformLocation(k,"u_FrameOrigin"),frameU:t.getUniformLocation(k,"u_FrameU"),frameV:t.getUniformLocation(k,"u_FrameV"),blendPrep:t.getUniformLocation(k,"u_BlendPrep")},at={mvp:t.getUniformLocation(U,"u_MVP"),tex:t.getUniformLocation(U,"u_Tex"),blendPrep:t.getUniformLocation(U,"u_BlendPrep")},ct={mvp:t.getUniformLocation(V,"u_MVP"),tex:t.getUniformLocation(V,"u_Tex")},dt=bn(),Zt=Nt();function Ye(x){x==="translucent"?(t.enable(t.BLEND),t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA)):x==="additive"?(t.enable(t.BLEND),t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE)):t.disable(t.BLEND)}let Kt=0;function Qn(x){const{mode:D,prep:H}=Xr(x);Kt=H,D==="additive"?(t.enable(t.BLEND),t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE)):D==="multiply"?(t.enable(t.BLEND),t.blendFuncSeparate(t.DST_COLOR,t.ZERO,t.ONE,t.ONE_MINUS_SRC_ALPHA)):D==="screen"?(t.enable(t.BLEND),t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_COLOR,t.ONE,t.ONE_MINUS_SRC_ALPHA)):Ye("translucent")}function Qt(x,D){if(D&&D.perspective)return!1;const H=x.size[0]*x.scale[0],z=x.size[1]*x.scale[1];if(H===0||z===0)return!1;let G=Math.abs(H)/2,g=Math.abs(z)/2;const S=x.angles[2];if(S!==0){const O=Math.abs(Math.cos(S)),Y=Math.abs(Math.sin(S)),$=G*O+g*Y,P=G*Y+g*O;G=$,g=P}const L=x.origin[0],E=D.projH-x.origin[1];let N=64;x.parallaxDepth&&(N+=Math.abs(xn(x.parallaxDepth[0])*Ie),N+=Math.abs(xn(x.parallaxDepth[1])*We));const j=Go(x),I=N+j[0],B=N+j[1];return L+G+I<D.offX||L-G-I>D.offX+D.viewW||E+g+B<D.offY||E-g-B>D.offY+D.viewH}function An(x,D,H){if(!x.spriteSheet)return null;const z=D&&D.frames,G=Array.isArray(z)?z:z&&z.list;if(!G||G.length===0)return null;const g=z&&z.atlasWidth||D.width||0,S=z&&z.atlasHeight||D.height||0;if(g<=0||S<=0)return null;x.spriteFrameCount=G.length;let L=0;const E=x.textureAnimation;if(E&&E.frame!==null&&E.frame!==void 0)L=Math.floor(Number(E.frame))||0,L>=0||(L=0),L>=G.length&&(L=G.length-1);else if(G.length>1){const Y=E&&E.playing===!1;let $=0;for(const P of G)$+=P.duration>0?P.duration:1/30;if(!Y&&$>0){let P=H%$;P<0&&(P+=$);for(let y=0;y<G.length;y++){const C=G[y].duration>0?G[y].duration:.03333333333333333;if(P<C){L=y;break}P-=C,L=y}}}const N=G[L],j=N.uDir?N.uDir[0]:N.width,I=N.uDir?N.uDir[1]:0,B=N.vDir?N.vDir[0]:0,O=N.vDir?N.vDir[1]:N.height;return[N.x/g,N.y/S,j/g,I/S,B/g,O/S]}function Dt(x,D){const H=x.size[0]*x.scale[0],z=x.size[1]*x.scale[1];let G=bn();if(D&&D.perspective){const S=ca(x,D);G=vn(G,S[0],S[1],S[2]);const L=x.angles[0]||0,E=x.angles[1]||0;E&&(G=ia(G,E)),L&&(G=oa(G,L)),G=Ro(G,-x.angles[2])}else{if(G=vn(G,x.origin[0],D.projH-x.origin[1],x.origin[2]),x.parallaxDepth&&(Ie!==0||We!==0)){const S=xn(x.parallaxDepth[0]),L=xn(x.parallaxDepth[1]);G=vn(G,S*Ie,L*We,0)}G=Ro(G,-x.angles[2])}const g=zo[x.alignment]||[.5,.5];return(g[0]!==.5||g[1]!==.5)&&(G=vn(G,(.5-g[0])*H,(.5-g[1])*z,0)),{m:G,w:H,h:z}}function un(x,D,H,z,G,g,S,L,E=!1,N=null,j=null){const I=Dt(z,G);let B=I.m;if(j){const $=(j[0]+j[2]/2)*z.scale[0],P=(j[1]+j[3]/2)*z.scale[1];B=vn(B,$,-P,0),B=Ln(B,j[2]*z.scale[0],j[3]*z.scale[1],1)}else B=Ln(B,I.w,I.h,1);const O=Mt(g,B),Y=x===U?at:we;t.useProgram(x),E?(Kt=0,t.enable(t.BLEND),z.containerAlphaMeaningful?t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA):t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA)):Qn(z.colorBlendMode),Y.blendPrep!==null&&Y.blendPrep!==void 0&&t.uniform1i(Y.blendPrep,Kt),Fe?(t.bindFramebuffer(t.FRAMEBUFFER,Fe.fbo.fbo),t.viewport(0,0,Fe.w,Fe.h)):(t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,S,L)),t.bindVertexArray(q),st("local",_n),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,D),t.uniform1i(Y.tex,0),t.uniformMatrix4fv(Y.mvp,!1,O),Y.color!==null&&Y.color!==void 0&&t.uniform4f(Y.color,H[0],H[1],H[2],H[3]),Jt(Y,N),t.drawArrays(t.TRIANGLES,0,6)}function Jt(x,D){!x||x.frameOrigin===null||x.frameOrigin===void 0||(D?(t.uniform2f(x.frameOrigin,D[0],D[1]),t.uniform2f(x.frameU,D[2],D[3]),t.uniform2f(x.frameV,D[4],D[5])):(t.uniform2f(x.frameOrigin,0,0),t.uniform2f(x.frameU,1,0),t.uniform2f(x.frameV,0,1)))}let Bt=null,Fe=null;const St=new Map,Et=new Map;let It=!0;function Ot(x,D){const H=Dt(x,D),z=D&&D.perspective?x.scale[1]:-x.scale[1],G=D&&D.perspective&&x.scale[2]||1;return Ln(H.m,x.scale[0],z,G)}function fn(x,D,H,z,G,g,S){Fe?(t.bindFramebuffer(t.FRAMEBUFFER,Fe.fbo.fbo),t.viewport(0,0,Fe.w,Fe.h)):(t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,z,G));const L=Mt(H,Ot(x,D));Bt(x,L,{time:g,overrideTex:S||null}),Ut=null}let en=null;function $t(x,D){return en===null&&(en=t.createTexture(),t.bindTexture(t.TEXTURE_2D,en),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE)),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindTexture(t.TEXTURE_2D,en),t.copyTexImage2D(t.TEXTURE_2D,0,t.RGB8,0,0,x,D,0),en}function Jn(x,D,H,z,G,g,S,L){const E=$t(S,L),N=Dt(x,G);let j=N.m;j=Ln(j,N.w,N.h,1);const I=Mt(g,j),B=[[-.5,.5],[.5,.5],[-.5,-.5],[.5,-.5]].map(([C,Q])=>{const ee=ua(I,C,Q,0);return[ee[0]*.5+.5,ee[1]*.5+.5]}),[O,Y,$,P]=B,y=new Float32Array([0,z,0,O[0],O[1],0,0,0,$[0],$[1],H,z,0,Y[0],Y[1],H,z,0,Y[0],Y[1],0,0,0,$[0],$[1],H,0,0,P[0],P[1]]);t.useProgram(V),Ye("normal"),t.disable(t.BLEND),t.bindFramebuffer(t.FRAMEBUFFER,D.fbo),t.viewport(0,0,H,z),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.bindVertexArray(q),t.bindBuffer(t.ARRAY_BUFFER,W),t.bufferData(t.ARRAY_BUFFER,y,t.DYNAMIC_DRAW),Ut=null,t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,E),t.uniform1i(ct.tex,0),t.uniformMatrix4fv(ct.mvp,!1,yn(0,H,0,z,-1e4,1e4)),t.drawArrays(t.TRIANGLES,0,6),t.enable(t.BLEND)}function er(x,D,H,z,G){if(!It||Fe)return;const g=Et.get(x.id);if(!g||g.size===0)return;const S=Math.max(1,Math.round(Math.abs(x.size[0]*(x.scale[0]||1)))),L=Math.max(1,Math.round(Math.abs(x.size[1]*(x.scale[1]||1))));if(S<=1&&L<=1)return;const E=re(S,L,"lc:"+x.id);Jn(x,E,S,L,D,H,z,G);for(const N of g)St.set(N,E);Et.delete(x.id),t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,z,G)}async function tr(x,D,H,z,G,g,S,L){K++,t.viewport(0,0,H,z);const E=x.general||{};if(E.clearenabled!==!1){const y=Wo(E.clearcolor||"0 0 0");t.clearColor(y[0],y[1],y[2],1)}else t.clearColor(0,0,0,1);if(t.clear(t.COLOR_BUFFER_BIT),me>=0){const y=G-me;ft=y>0&&y<1?y:Math.min(.1,Math.max(.001,y||1/60))}me=G;const N=pa(x,H,z,g,S,L);let j=Mt(N.projection,N.view);const I=E.cameraparallax,B=I===!0||I!==null&&typeof I=="object"&&I.value===!0;Ie=0,We=0;const O=Be();if(O&&(Me.x=O.u*2-1,Me.y=O.v*2-1),!N.perspective&&n.parallax!==!1&&B){const y=(Oe,ce)=>{const pe=Oe!==null&&typeof Oe=="object"?Oe.value:Oe;return typeof pe=="number"&&Number.isFinite(pe)?pe:ce},C=y(E.cameraparallaxamount,0),Q=y(E.cameraparallaxmouseinfluence,1),ee=y(E.cameraparallaxdelay,1),ie=G-_e;_e=G;const oe=ie>0?1-Math.exp(-ie/Math.max(.05,ee)):1;Me.sx+=(Me.x-Me.sx)*oe,Me.sy+=(Me.y-Me.sy)*oe;const fe=C*Q,ge=60,nt=Me.sx*fe*N.viewW,pt=Me.sy*fe*N.viewH,ht=Math.max(Math.abs(nt),Math.abs(pt))/ge,Ct=ht>1?1/ht:1;Ie=-(nt*Ct),We=-(pt*Ct)}if(!N.perspective&&n.shake!==!1){const y=Er(E,G);if(y){const C=y.x*N.viewW*.02,Q=y.y*N.viewH*.02;(C!==0||Q!==0)&&(j=Mt(j,vn(bn(),C,Q,0)))}}if(le){const y=typeof le=="function"?le():le;y&&typeof y.syncWorld=="function"&&y.syncWorld(N,0,0)}if(!R){R=!0;const y=(x.layers||[]).filter(ee=>ee.isContainer),C=y.filter(ee=>(ee.effects||[]).some(ie=>ie.visible)&&!ee.hasChildren),Q=C.filter(ee=>(ee.effects||[]).some(ie=>(ie.materialPasses||[]).length>0));o(`containers total=${y.length} canvasCandidates=${C.length} passesResolved=${Q.length} names=${C.slice(0,4).map(ee=>ee.name||"?").join("/")}`)}await tn(x,D,N,H,z,G);const Y=new Map;for(const y of x.layers)y.id!==void 0&&Y.set(y.id,y);const $=new Set;for(const y of x.layers)!y.visible||y.destroyed||!y.isContainer||!y.hasChildren||!(y.effects||[]).some(Q=>Q.visible)||(y.childIds||[]).length===0||fr(y,Y,$);if(c)try{c()}catch(y){o("particle advance error: "+(y&&y.message))}const P=N.perspective?x.layers.slice().sort((y,C)=>+!!C.isSkybox-+!!y.isSkybox):x.layers;for(const y of P)if(!y.destroyed){if(!y.visible){Et.has(y.id)&&er(y,N,j,H,z);continue}if(!(y.isPostProcess&&!(y.effects||[]).some(C=>C.visible))&&!$.has(y.id)){if(y.isContainer){if(!(y.effects||[]).some(Q=>Q.visible)){er(y,N,j,H,z);continue}if(y.hasChildren){(y.childIds||[]).length>0&&await dn(y,x,D,N,j,H,z,G);continue}}if(y.particle){if(u)try{await u(y.id,N,j,H,z)}catch(C){o("particle render error: "+(C&&C.message))}continue}Qt(y,N)||await Pt(y,D,N,j,H,z,G)}}if(Gn(E)&&G<Tt){const y=Math.max(0,Math.min(1,G/Tt)),C=1-y*y*(3-2*y);if(C>.002){const Q=Wo(E.clearcolor||"0 0 0");t.useProgram(k),t.enable(t.BLEND),t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA),t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,H,z),t.bindVertexArray(q),st("pass",qt),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,Ee),t.uniform1i(we.tex,0),t.uniform4f(we.color,Q[0],Q[1],Q[2],C),Jt(we,null),we.blendPrep!==null&&we.blendPrep!==void 0&&t.uniform1i(we.blendPrep,0),t.uniformMatrix4fv(we.mvp,!1,dt),t.drawArrays(t.TRIANGLES,0,6)}}t.bindVertexArray(null),te()}async function tn(x,D,H,z,G,g){St.clear(),Et.clear();const S=new Map,L=new Set;let E=null;const N=j=>{if(typeof j!="string")return;const I=/^_rt_imageLayerComposite_(\d+)_[a-z]$/.exec(j);if(!I)return;const B=Number(I[1]);E!==null&&B===E&&L.add(B);let O=S.get(B);O||(O=new Set,S.set(B,O)),O.add(j)};for(const j of x.layers||[]){E=j.id;for(const I of j.effects||[])if(I.visible){for(const B of I.passes||[])for(const O of B.textures||[])N(O);for(const B of I.materialPasses||[]){for(const O of B.binds||[])N(O&&O.name);for(const O of B.textures||[])N(O)}}}if(S.size!==0){for(const[j,I]of S){const B=(x.layers||[]).find(ge=>ge.id===j);if(!B||B.particle||B.isPostProcess||L.has(j))continue;const O=typeof B.image=="string"?B.image:"";if(B.isContainer&&!B.hasChildren&&O.indexOf("models/util/composelayer")===0&&!(B.effects||[]).some(ge=>ge.visible)){Et.set(j,I);continue}const $=Math.max(1,Math.round(Math.abs(B.size[0]*(B.scale[0]||1)))),P=Math.max(1,Math.round(Math.abs(B.size[1]*(B.scale[1]||1))));if($<=1&&P<=1)continue;const y=re($,P,"lc:"+j);t.bindFramebuffer(t.FRAMEBUFFER,y.fbo),t.viewport(0,0,$,P),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT);const C={view:H.view,projection:yn(0,$,0,P,-1e4,1e4),eye:H.eye,projW:$,projH:P,offX:0,offY:0,viewW:$,viewH:P},Q=Fe,ee=B.origin,ie=B.scale,oe=B.angles,fe=B.visible;Fe={fbo:y,w:$,h:P},B.origin=[$/2,C.projH-P/2,ee[2]],B.scale=[Math.sign(ie[0])||1,Math.sign(ie[1])||1,ie[2]],B.angles=[0,0,0],B.visible=!0;try{await Pt(B,D,C,C.projection,$,P,g);for(const ge of I)St.set(ge,y)}catch(ge){o(`composite \u6E90\u5C42 ${j} \u6E32\u67D3\u5931\u8D25: ${ge&&ge.message}`)}finally{Fe=Q,B.origin=ee,B.scale=ie,B.angles=oe,B.visible=fe}}t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,z,G)}}async function dn(x,D,H,z,G,g,S,L){const E=Math.max(1,Math.round(Math.abs(x.size[0]))),N=Math.max(1,Math.round(Math.abs(x.size[1])));if((x.childIds||[]).length===0)return;const I=new Map;for(const oe of D.layers)oe.id!==void 0&&I.set(oe.id,oe);const B=fr(x,I),O=D.layers.filter(oe=>B.has(oe.id)&&oe.visible);if(O.length===0)return;const Y=re(E,N,"group");t.bindFramebuffer(t.FRAMEBUFFER,Y.fbo),t.viewport(0,0,E,N),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT);const $={view:z.view,projection:yn(0,E,0,N,-1e4,1e4),eye:z.eye,projW:E,projH:N,offX:0,offY:0,viewW:E,viewH:N},P=$.projection,y=x.scale[0]||1,C=x.scale[1]||1,Q=x.angles[2]||0,ee=Math.cos(-Q),ie=Math.sin(-Q);Fe={fbo:Y,w:E,h:N};try{for(const oe of O){if(oe.isPostProcess||oe.particle||oe.isContainer&&(oe.childIds||[]).length>0)continue;const fe=oe.origin,ge=oe.scale,nt=oe.angles,pt=fe[0]-x.origin[0],ht=fe[1]-x.origin[1],Ct=(pt*ee-ht*ie)/y,Oe=(pt*ie+ht*ee)/C;oe.origin=[E/2+Ct,N/2+Oe,fe[2]],oe.scale=[ge[0]/y,ge[1]/C,ge[2]],oe.angles=[nt[0],nt[1],nt[2]-Q];try{await Pt(oe,H,$,P,E,N,L)}finally{oe.origin=fe,oe.scale=ge,oe.angles=nt}}}finally{Fe=null}x.groupTex=Y.tex,x.groupW=E,x.groupH=N;try{await Pt(x,H,z,G,g,S,L)}finally{x.groupTex=null}}async function Pt(x,D,H,z,G,g,S){const L=!!(x.puppet&&Bt),E=!x.solid&&x.textureName?D.get(x.textureName):null;if(E&&E.video){const ce=E.video;if(ce.readyState>=2&&ce.currentTime!==E.lastUploaded){t.bindTexture(t.TEXTURE_2D,E.glTex);try{let pe=ce.videoWidth||E.width,ue=ce.videoHeight||E.height;const Ce=2048,rt=t.getParameter(t.MAX_TEXTURE_SIZE),Je=rt>0&&rt<4096?Math.min(Ce,rt):Ce;let lt=1;Math.max(pe,ue)>Je&&(lt=Je/Math.max(pe,ue));const ot=Math.max(1,Math.round(pe*lt)),Le=Math.max(1,Math.round(ue*lt));let pn=ce;if(i&&ot>0&&Le>0){(i.width!==ot||i.height!==Le)&&(i.width=ot,i.height=Le);const Lt=i.getContext("2d");Lt&&(Lt.clearRect(0,0,ot,Le),Lt.drawImage(ce,0,0,ot,Le),pn=i)}if(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,pn),t.getError()!==t.NO_ERROR&&i)try{const et=i.getContext("2d").getImageData(0,0,i.width,i.height);for(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,i.width,i.height,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array(et.data.buffer));t.getError()!==t.NO_ERROR;);}catch{}E.width=ot,E.height=Le,E.lastUploaded=ce.currentTime,s||(s=!0,o("video tex ready "+ot+"x"+Le+" (src "+pe+"x"+ue+")"))}catch(pe){s||(s=!0,o("video upload FAIL: "+(pe&&pe.message||pe))),console.warn("[we-scene] \u89C6\u9891\u5E27\u4E0A\u4F20\u5931\u8D25:",pe&&pe.message,"readyState=",ce.readyState,"cur=",ce.currentTime)}}}const N=x.groupTex?x.groupTex:E&&E.glTex?E.glTex:x.solid?Ee:Re,j=(!!x.passthrough||!!x.isPostProcess||qo(x))&&!x.groupTex&&!E&&!L;let I,B;if(x.groupTex?(I=x.groupW||x.size[0],B=x.groupH||x.size[1]):L||!E?(I=x.size[0],B=x.size[1]):(I=E.width,B=E.height),!L&&E&&x.spriteSheet){const ce=E.frames,pe=Array.isArray(ce)?ce:ce&&ce.list;pe&&pe.length&&(I=pe[0].width||I,B=pe[0].height||B)}const O=Math.max(1,Math.round(I)),Y=Math.max(1,Math.round(B)),$=[x.color[0]*x.brightness,x.color[1]*x.brightness,x.color[2]*x.brightness,x.alpha],P=(x.effects||[]).filter(ce=>ce.visible);let y=O,C=Y;if(a>0&&H.projW>0&&H.projH>0){const ce=Math.min(Math.abs(x.size[0]*x.scale[0]),H.viewW),pe=Math.min(Math.abs(x.size[1]*x.scale[1]),H.viewH),ue=ce*(G/H.projW),Ce=pe*(g/H.projH);if(ue>0&&Ce>0){const rt=Math.max(64,Math.round(ue*a)),Je=Math.max(64,Math.round(Ce*a));rt<O&&(y=rt),Je<Y&&(C=Je)}}if(P.length===0){L?fn(x,H,z,G,g,S):un(k,N,$,x,H,z,G,g,!1,An(x,E,S));return}const Q=re(y,C,"ping"),ee=re(y,C,"pong"),ie=yn(0,y,0,C,-1e4,1e4);if(L)t.useProgram(k),Ye("normal"),t.bindFramebuffer(t.FRAMEBUFFER,Q.fbo),t.viewport(0,0,y,C),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.bindVertexArray(q),Ut=null,st("layer"+y+"x"+C,Yt(y,C)),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,N),t.uniform1i(we.tex,0),t.uniform4f(we.color,1,1,1,1),Jt(we,null),we.blendPrep!==null&&we.blendPrep!==void 0&&t.uniform1i(we.blendPrep,0),t.uniformMatrix4fv(we.mvp,!1,ie),t.drawArrays(t.TRIANGLES,0,6);else if(j)Jn(x,Q,y,C,H,z,G,g);else{t.useProgram(k),Ye("normal"),t.bindFramebuffer(t.FRAMEBUFFER,Q.fbo),t.viewport(0,0,y,C),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.bindVertexArray(q),st("layer"+y+"x"+C,Yt(y,C)),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,N),t.uniform1i(we.tex,0);const ce=P.some(pe=>pe&&pe.layerMaterial)?[1,1,1,$[3]]:$;t.uniform4f(we.color,ce[0],ce[1],ce[2],ce[3]),Jt(we,An(x,E,S)),we.blendPrep!==null&&we.blendPrep!==void 0&&t.uniform1i(we.blendPrep,0),t.uniformMatrix4fv(we.mvp,!1,ie),t.drawArrays(t.TRIANGLES,0,6)}let oe=Q,fe=ee;const ge=new Map;let nt=!1,pt=Q;const ht=[],Ct=new Set;for(const ce of P){for(const ue of ce.fbos||[])if(!ge.has(ue.name)){const[Ce,rt]=Yo(ue,y,C),Je=ue.unique?x.id+":"+ue.name:ue.name;ge.set(ue.name,re(Ce,rt,Je))}const pe=ce.materialPasses||[];for(let ue=0;ue<pe.length;ue++)ht.push({eff:ce,mp:pe[ue],ov:ce.passes&&ce.passes[ue]})}const Oe=[];for(let ce=0;ce<ht.length;ce++){const{eff:pe,mp:ue,ov:Ce}=ht[ce];if(Ct.has(pe))continue;const rt={...ue.combos||{},...Ce&&Ce.combos||{}},Je=ue.textures||[],lt=Ce&&Ce.textures||[],ot=[];for(let ve=0;ve<Math.max(Je.length,lt.length);ve++)lt[ve]!==void 0&<[ve]!==null?ot[ve]=lt[ve]:ot[ve]=Je[ve]!==void 0?Je[ve]:null;if(ue.copyCommand){const ve=ue.source?ge.get(ue.source):null,ke=ue.target?ge.get(ue.target):null;ve&&ke&&(t.useProgram(U),Ye("normal"),t.bindFramebuffer(t.FRAMEBUFFER,ke.fbo),t.viewport(0,0,ke.width,ke.height),t.bindVertexArray(q),st("pass",qt),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,ve.tex),t.uniform1i(at.tex,0),at.blendPrep!==null&&at.blendPrep!==void 0&&t.uniform1i(at.blendPrep,0),t.uniformMatrix4fv(at.mvp,!1,dt),t.drawArrays(t.TRIANGLES,0,6),t.bindFramebuffer(t.FRAMEBUFFER,null));continue}let Le;try{Le=await Ve(ue.shader,rt,ot)}catch(ve){const ke=ve&&ve.message||String(ve);/已缓存/.test(ke)||console.warn("[we-scene] \u8DF3\u8FC7\u6548\u679C\uFF08pass \u7F16\u8BD1\u5931\u8D25\uFF09:",ue.shader,ke),Ct.add(pe);continue}const pn=Le.prog,Lt=Le.uni;Le.fragGlsl&&Oe.push(Le.fragGlsl);let et,Tn;ue.target?(nt||(pt=oe,nt=!0),et=ge.get(ue.target)||oe,Tn=pt):(nt=!1,et=fe,Tn=oe),t.useProgram(pn),Ye(ue.blending||"normal"),t.bindFramebuffer(t.FRAMEBUFFER,et.fbo),t.viewport(0,0,et.width,et.height),t.bindVertexArray(q);const go=!Le.ndcDirect;go?st("passPx"+et.width+"x"+et.height,Yt(et.width,et.height)):st("pass",qt);const ps=go?Lo(yn(0,et.width,0,et.height,-1e4,1e4)):dt,Lr=ue.textures||[],hs=Math.max(Lr.length,8),bo=new Map,ms=new Set;for(let ve=0;ve<hs;ve++){let ke=ve<Lr.length?Lr[ve]:null;Ce&&Ce.textures&&Ce.textures[ve]!==void 0&&Ce.textures[ve]!==null&&(ke=Ce.textures[ve]);for(const En of ue.binds||[])En.index===ve&&(ke=En.name);let xt;if(ve===0&&(ke==null||ke===""))xt=Tn;else{if((ke==null||ke==="")&&Le.samplerDefaults){const En=Le.samplerDefaults.get(ve);En&&(ke=En)}xt=Cr(ke,Tn,ge,D)}ke==="previous"&&(xt=Tn),xt===null&&(xt={glTex:Ee,width:1,height:1,tex:Ee});const Sn=xt.fbo?xt:{tex:xt.glTex||Ee,width:xt.width||1,height:xt.height||1};t.activeTexture(t.TEXTURE0+ve),t.bindTexture(t.TEXTURE_2D,Sn.tex),ms.add(ve),bo.set(ve,[Sn.width,Sn.height,Sn.width,Sn.height])}Yn(Lt,x,S,H.projW,H.projH,ps,ie,dt,bo,ie,H),Zn(Lt,ln(Kn({...ue.constants||{},...Ce&&Ce.constantshadervalues||{}},(x.id||x.name||"?")+"|"+(ue.shader||"?")+"|"+ce,S,x),(x.id||x.name||"?")+"|"+(ue.shader||"?")+"|"+ce,S),Le.matMeta),Pr(Lt),t.drawArrays(t.TRIANGLES,0,6),ue.target||(fe=oe,oe=et)}if(x.isContainer&&!x.groupTex&&!j&&x.containerAlphaMeaningful===void 0){let ce=!1;for(const pe of Oe){if(typeof pe!="string")continue;const ue=pe.match(/\bfloat\s+alpha\s*=\s*([^;]+);/);if(ue&&!/^\s*scene\s*\.\s*a\s*$/.test(ue[1])){ce=!0;break}}x.containerAlphaMeaningful=ce,o(`container "${x.name||"?"}" alpha ${ce?"\u643A\u5E26\u5F62\u72B6 \u2192 SRC_ALPHA":"\u65E0\u4FE1\u606F \u2192 \u52A0\u6CD5"}`)}if(L){fn(x,H,z,G,g,S,oe.tex);return}un(U,oe.tex,[1,1,1,1],x,H,z,G,g,!!x.isContainer&&!x.groupTex&&!j,null,null)}return{gl:t,render:tr,getFBO:re,getEffectProgram:Ve,progCache:X,shaderResolver:r,whiteTex:Ee,resetShaderCaches:function(){X.clear(),J.clear(),de&&de.clear()},setFboCapFactor:function(x){a=x},setParticleRenderer:function(x,D){c=typeof x=="function"?x:null,u=typeof D=="function"?D:null},setConstantScriptRuntime:F,applyConstUserProperties:function(x){if(x){for(const D of v.values())if(D&&typeof D.applyUserProperties=="function")try{D.applyUserProperties(x)}catch{}}},constantScriptStats:function(){return{..._,cached:v.size}},setCompositeEnabled:function(x){It=!!x},compositeStats:function(){const x=[],D=new Uint8Array(4);for(const[H,z]of St){let G=null;try{t.bindFramebuffer(t.FRAMEBUFFER,z.fbo),t.readPixels(z.w>>1,z.h>>1,1,1,t.RGBA,t.UNSIGNED_BYTE,D),G=[D[0],D[1],D[2],D[3]]}catch{}x.push({name:H,w:z.w,h:z.h,center:G})}return t.bindFramebuffer(t.FRAMEBUFFER,null),x},setPuppetRenderer:function(x){Bt=x},setAudioProvider:f,setPointerProvider:Pe,getParallaxOffset:function(){return{x:Ie,y:We}},dispose:function(){try{const x=t.getExtension("WEBGL_lose_context");x&&x.loseContext()}catch{}}}}const Da=Object.freeze(Object.defineProperty({__proto__:null,ALIGN:zo,XRAY_IDLE_SCREEN_UV:kn,applyColorBlendCPU:Fa,collectGroupDescendantIds:fr,colorBlendPlan:Xr,createRenderer:Ua,effectFboSize:Yo,layerWantsPreserveBackdrop:qo,makeTexture:Wr,makeTextureMip:Ea,puppetAnimMargin:Go,rewriteXrayFragScale:Zo,xrayShouldParkPointer:Gr,xrayUvScale:ka},Symbol.toStringTag,{value:"Module"}));function Ba(e=256,n=8){const t=e/n,r=Ko(1337),o=Ko(4242),i=new Float32Array(t*t),s=new Float32Array(t*t);for(let u=0;u<t*t;u++)i[u]=r(),s[u]=o();const a=new Uint8Array(e*e*4),c=n;for(let u=0;u<e;u++){const l=Math.floor(u/c),p=u%c/c,f=p*p*(3-2*p);for(let d=0;d<e;d++){const w=Math.floor(d/c),M=d%c/c,m=M*M*(3-2*M),A=w%t,h=(w+1)%t,b=l%t,v=(l+1)%t,T=i[b*t+A],_=i[b*t+h],F=i[v*t+A],R=i[v*t+h],k=s[b*t+A],U=s[b*t+h],V=s[v*t+A],q=s[v*t+h],W=T+(_-T)*m+(F-T)*f+(T-_-F+R)*m*f,Z=k+(U-k)*m+(V-k)*f+(k-U-V+q)*m*f,K=(u*e+d)*4;a[K]=Math.round(W*255),a[K+1]=Math.round(Z*255),a[K+2]=0,a[K+3]=255}}return a}function Ko(e){let n=e>>>0;return()=>{n|=0,n=n+1831565813|0;let t=Math.imul(n^n>>>15,1|n);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}const Ia=Object.freeze(Object.defineProperty({__proto__:null,generateNoiseTexture:Ba},Symbol.toStringTag,{value:"Module"})),gt=Math.PI*2;function Ne(e,n){return e==null?Math.random():n==null?e:e+Math.random()*(n-e)}function Qo(e,n,t){if(e==null)return Math.random();if(n==null)return e;const r=t&&t!==1?Math.pow(Math.random(),t):Math.random();return e+r*(n-e)}function be(e,n){if(Array.isArray(e))return[e[0]||0,e[1]||0,e[2]||0];if(e==null)return n?n.slice():[0,0,0];if(typeof e=="object")return be(e.value,n);if(typeof e=="number")return[e,e,e];const t=String(e).trim().split(/\s+/).map(Number);return[t[0]||0,t[1]||0,t[2]||0]}function Jo(e){return e==null?null:typeof e=="number"?[e,e,e]:be(e)}function ne(e,n){if(e==null)return n;if(typeof e=="object")return ne(e.value,n);const t=Number(e);return Number.isFinite(t)?t:n}function qr(e,n){const t=e[0],r=e[1]>t?e[1]:t+1e-6,o=Math.min(1,Math.max(0,(n-t)/(r-t)));return o*o*(3-2*o)}function Vt(e,n,t){const r=Math.sin(e*127.1+n*311.7+t*74.7)*43758.5453;return r-Math.floor(r)}function Oa(e,n,t){const r=Math.floor(e),o=Math.floor(n),i=Math.floor(t),s=e-r,a=n-o,c=t-i,u=s*s*(3-2*s),l=a*a*(3-2*a),p=c*c*(3-2*c),f=(A,h,b)=>A+(h-A)*b,d=f(Vt(r,o,i),Vt(r+1,o,i),u),w=f(Vt(r,o+1,i),Vt(r+1,o+1,i),u),M=f(Vt(r,o,i+1),Vt(r+1,o,i+1),u),m=f(Vt(r,o+1,i+1),Vt(r+1,o+1,i+1),u);return f(f(d,w,l),f(M,m,l),p)}function Yr(e,n,t,r){let o=0,i=.5,s=1,a=0;for(let c=0;c<r;c++)o+=i*Oa(e*s,n*s,t*s),a+=i,i*=.5,s*=2;return o/(a||1)}function Zr(e,n,t,r){return[Yr(e,n,t,r)*2-1,Yr(e+31.7,n+11.3,t+57.1,r)*2-1,Yr(e+73.9,n+92.1,t+13.7,r)*2-1]}function $a(e){const n=`#version 300 es
|
|
65
|
+
}`;function Da(e,n){return new Float32Array([0,n,0,0,1,0,0,0,0,0,e,n,0,1,1,e,n,0,1,1,0,0,0,0,0,e,0,0,1,0])}function Ba(){return new Float32Array([-1,1,0,0,1,-1,-1,0,0,0,1,1,0,1,1,1,1,0,1,1,-1,-1,0,0,0,1,-1,0,1,0])}function Ia(){return new Float32Array([-.5,.5,0,0,1,-.5,-.5,0,0,0,.5,.5,0,1,1,.5,.5,0,1,1,-.5,-.5,0,0,0,.5,-.5,0,1,0])}const Oa={5126:"float",35664:"vec2",35665:"vec3",35666:"vec4",5124:"int",35667:"ivec2",35668:"ivec3",35669:"ivec4",35670:"bool",35676:"mat4",35675:"mat3"};function lr(e,n,t){const r=Yo(e,e.VERTEX_SHADER,n),o=Yo(e,e.FRAGMENT_SHADER,t),i=e.createProgram();if(e.attachShader(i,r),e.attachShader(i,o),e.bindAttribLocation(i,0,"a_Position"),e.bindAttribLocation(i,1,"a_TexCoord"),e.linkProgram(i),!e.getProgramParameter(i,e.LINK_STATUS))throw new Error("\u7740\u8272\u5668\u94FE\u63A5\u5931\u8D25: "+e.getProgramInfoLog(i));return i}function Yo(e,n,t){const r=e.createShader(n);if(e.shaderSource(r,t),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS))throw new Error("\u7740\u8272\u5668\u7F16\u8BD1\u5931\u8D25: "+e.getShaderInfoLog(r));return r}function qo(e){e!==null&&typeof e=="object"&&"value"in e&&(e=e.value);const n=String(e??"").trim().split(/\s+/).map(Number);return[n[0]||0,n[1]||0,n[2]||0]}function Xr(e,n,t,r,o=null){const i=e.createTexture();return e.bindTexture(e.TEXTURE_2D,i),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),o?e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,o):e.texImage2D(e.TEXTURE_2D,0,e.RGBA,t,r,0,e.RGBA,e.UNSIGNED_BYTE,n),i}function $a(e,n,t=!1){const r=e.createTexture();e.bindTexture(e.TEXTURE_2D,r),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR);const o=n[0];if(o.bitmap)e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,o.bitmap);else if(t&&o.rgba){const i=o.width*o.height,s=new Uint8Array(i*2);for(let c=0;c<i;c++)s[c*2]=o.rgba[c*4+3],s[c*2+1]=o.rgba[c*4];const a=e.getParameter(e.UNPACK_ALIGNMENT);e.pixelStorei(e.UNPACK_ALIGNMENT,1),e.texImage2D(e.TEXTURE_2D,0,e.RG8,o.width,o.height,0,e.RG,e.UNSIGNED_BYTE,s),e.pixelStorei(e.UNPACK_ALIGNMENT,a)}else e.texImage2D(e.TEXTURE_2D,0,e.RGBA,o.width,o.height,0,e.RGBA,e.UNSIGNED_BYTE,o.rgba);return e.generateMipmap(e.TEXTURE_2D),r}function Gr(e,n,t,r,o){const i=1-o;return i*i*i*e+3*i*i*o*n+3*i*o*o*t+o*o*o*r}function ja(e,n,t,r,o){if(o<=e)return 0;if(o>=r)return 1;let i=r-e>1e-9?(o-e)/(r-e):.5;for(let c=0;c<8;c++){const u=Gr(e,n,t,r,i)-o;if(Math.abs(u)<1e-6)return i;const l=1-i,f=3*l*l*(n-e)+6*l*i*(t-n)+3*i*i*(r-t);if(Math.abs(f)<1e-9)break;const p=i-u/f;if(p<0||p>1||!Number.isFinite(p))break;i=p}let s=0,a=1;for(let c=0;c<40;c++)i=(s+a)/2,Gr(e,n,t,r,i)<o?s=i:a=i;return i}function ur(e,n,t){if(!e||e.length===0)return 0;if(e.length===1)return Number(e[0].value)||0;if(t&&t.length>0){const N=e[0],j=e[e.length-1],H=t.length-j.frame;if(H>1e-9&&n>j.frame&&n<=t.length)return ur([{frame:0,value:j.value,front:j.front,back:j.back},{frame:H,value:N.value,front:N.front,back:N.back}],n-j.frame)}if(n<=e[0].frame)return Number(e[0].value)||0;const r=e[e.length-1];if(n>=r.frame)return Number(r.value)||0;let o=0,i=e.length-1;for(;i-o>1;){const N=o+i>>1;e[N].frame<=n?o=N:i=N}const s=e[o],a=e[i],c=s.frame,u=a.frame,l=Number(s.value)||0,f=Number(a.value)||0,p=u-c;if(p<=0)return f;const d=s.front,y=a.back,x=p/3,m=!!(d&&d.enabled),M=!!(y&&y.enabled),h=m?Math.abs(Number(d.x)||0):1,g=M?Math.abs(Number(y.x)||0):1,v=c+Math.min(h,1.5)*x,A=u-Math.min(g,1.5)*x,_=m?l+(Number(d.y)||0):l+(f-l)/3,R=M?f+(Number(y.y)||0):f-(f-l)/3,L=ja(c,v,A,u,n);return Gr(l,_,R,f,L)}function Zo(e,n,t){const r=n>0?n:1;if(t==="loop"){let o=e%r;return o<0&&(o+=r),o}if(t==="mirror"){const o=r*2;let i=e%o;return i<0&&(i+=o),i<=r?i:o-i}return Math.max(0,Math.min(r,e))}function za(e){return Array.isArray(e)?e:typeof e=="string"?e.trim().split(/\s+/).map(Number):Number.isFinite(e)?[e]:[]}function Ko(e){const n=e&&e.options||{},t=Number(n.fps)>0?Number(n.fps):30,r=Number(n.length)>0?Number(n.length):0,o=n.mode==="loop"||n.mode==="mirror"?n.mode:"single",i=typeof n.name=="string"?n.name:"",s=!!(e&&e.relative),a=n.wraploop===!0&&o==="loop",c=[];for(let p=0;;p++){const d=e&&e["c"+p];if(!Array.isArray(d))break;c.push(d)}const u=n.startpaused!==!0,l=[],f={name:i,mode:o,fps:t,relative:s,channelCount:c.length,frame:0,rate:1,playing:u,ended:!1,get frameCount(){return r},play(){return f.playing=!0,f.ended=!1,f},pause(){return f.playing=!1,f},stop(){return f.playing=!1,f.frame=0,f.ended=!1,f},setFrame(p){const d=Number(p);return Number.isFinite(d)&&(f.frame=d),f},getFrame(){return f.frame},setRate(p){const d=Number(p);return Number.isFinite(d)&&(f.rate=d),f},addEndedCallback(p){return typeof p=="function"&&l.push(p),f},setBlend(){return f},setVisible(){return f},advance(p){if(f.playing&&(f.frame+=(Number(p)||0)*t*f.rate,o==="single"))if(f.frame>=r){if(f.frame=r,f.playing=!1,!f.ended){f.ended=!0;for(const d of l)try{d()}catch{}}}else f.frame<0&&(f.frame=0,f.playing=!1)},value(){const p=Zo(f.frame,r,o),d=a?{length:r}:void 0;if(c.length===1)return ur(c[0],p,d);const y=[];for(const x of c)y.push(ur(x,p,d));return y},applyTo(p){const d=f.value();if(!s)return d;const y=za(p);return Array.isArray(d)?d.map((x,m)=>x+(Number(y[m])||0)):d+(Number(y[0])||0)}};return f}function Va(){const e={name:"",mode:"single",fps:30,relative:!1,channelCount:0,frame:0,rate:1,playing:!1,ended:!1,get frameCount(){return 0},play(){return e},pause(){return e},stop(){return e},setFrame(){return e},getFrame(){return 0},setRate(){return e},addEndedCallback(){return e},setBlend(){return e},setVisible(){return e},advance(){},value(){return 0},applyTo(n){return n}};return e}const Wa=Object.freeze(Object.defineProperty({__proto__:null,createAnimation:Ko,createNeutralAnimation:Va,sampleChannel:ur,wrapFrame:Zo},Symbol.toStringTag,{value:"Module"}));function Qo(e){const n=e&&e.puppet&&e.puppet.animBound;return n?[n.x*Math.abs(e.scale[0]),n.y*Math.abs(e.scale[1])]:[0,0]}function Jo(e){for(const n of e&&e.effects||[]){if(n.visible===!1)continue;const t=Math.max((n.passes||[]).length,(n.materialPasses||[]).length);for(let r=0;r<t;r++){const o=n.passes&&n.passes[r]&&n.passes[r].combos||{},i=n.materialPasses&&n.materialPasses[r]&&n.materialPasses[r].combos||{},s=o.TRANSPARENCY!==void 0?o.TRANSPARENCY:i.TRANSPARENCY;if(Number(s)===0)return!0}}return!1}function fr(e,n,t){if(t||(t=new Set),!n)return t;for(const r of e.childIds||[]){const o=n.get(r);!o||o.particle||o.isPostProcess||(t.add(r),fr(o,n,t))}return t}function Yr(e){const n=Ra[e]||"translucent";return{mode:n,prep:ka[n]||0}}function Ha(e,n,t,r){const{mode:o,prep:i}=Yr(e);let s=t;return i===1?s=t*r:i===2&&(s=1-r+t*r),o==="screen"?s+n*(1-s):o==="multiply"?n*s:o==="additive"?n+t*r:n*(1-r)+t*r}function ei(e,n,t){const r=e&&Number(e.scale)||1;let o=Math.max(1,Math.round(n/r)),i=Math.max(1,Math.round(t/r));const s=e&&Number(e.fit);if(Number.isFinite(s)&&s>0){const a=Math.max(o,i);if(a>s){const c=s/a;o=Math.max(1,Math.round(o*c)),i=Math.max(1,Math.round(i*c))}}return[o,i]}function Xa(e){const n=Number(e);return!Number.isFinite(n)||n<.001?999:1/n}const On=-1;function qr(e,n){return!!n&&!e}const Ga="mix(999.0, 1.0 / max(g_PointerScale, 0.001), step(0.001, g_PointerScale))";function ti(e){if(typeof e!="string"||/unprojectedUVs\s*\*=\s*mix\(999\.0,\s*1\.0\s*\/\s*max\(\s*g_PointerScale/.test(e))return e;const n=/unprojectedUVs\s*\*=\s*v_PointerScale\s*\*/.test(e),t=/unprojectedUVs\s*\*=\s*g_PointerScale\s*\*/.test(e);if(!n&&!t)return e;let r=e;/uniform\s+float\s+g_PointerScale\b/.test(r)||(r=r.replace(/void\s+main\s*\(/,`uniform float g_PointerScale;
|
|
66
|
+
void main(`));const o=n?/unprojectedUVs\s*\*=\s*v_PointerScale\s*\*/:/unprojectedUVs\s*\*=\s*g_PointerScale\s*\*/;return r.replace(o,"unprojectedUVs *= "+Ga+" *")}const ni=1;function ri(e,n){return e==="g_PointerScale"?ni:n}function Ya(e,n={}){const t=e.getContext("webgl2",{premultipliedAlpha:!1,antialias:!1,alpha:!1,preserveDrawingBuffer:!0});if(!t)throw new Error("\u5F53\u524D\u6D4F\u89C8\u5668\u4E0D\u652F\u6301 WebGL2");const r=n.shaderResolver||(async()=>null),o=n.diag||(()=>{}),i=typeof document<"u"?document.createElement("canvas"):null;i&&(i.style.cssText="position:fixed;left:-9999px;top:-9999px;width:2px;height:2px;opacity:0");let s=!1,a=n.fboCapFactor===void 0?0:n.fboCapFactor,c=null,u=null,l=null;const f=[["g_AudioSpectrum16Left","left16"],["g_AudioSpectrum16Right","right16"],["g_AudioSpectrum32Left","left32"],["g_AudioSpectrum32Right","right32"],["g_AudioSpectrum64Left","left64"],["g_AudioSpectrum64Right","right64"]];function p(w){l=w||null}let d=null,y=null,x=null,m=null,M=null,h=null,g=null;const v=new Map,A=new Map,_={total:0,ok:0,failed:0};function R(w,U){d=typeof w=="function"?w:null,y=U&&U.userProperties||null,x=U&&U.audioViews||null,m=U&&U.shared||null,M=U&&U.inputView||null,h=U&&U.timers||null,g=U&&typeof U.onSandbox=="function"?U.onSandbox:null,v.clear(),A.clear()}let L=!1;const N=lr(t,Hr,Fa),j=lr(t,Hr,Na),H=lr(t,Hr,Ua),K=t.createVertexArray();t.bindVertexArray(K);const O=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,O),t.enableVertexAttribArray(0),t.vertexAttribPointer(0,3,t.FLOAT,!1,20,0),t.enableVertexAttribArray(1),t.vertexAttribPointer(1,2,t.FLOAT,!1,20,12),t.bindVertexArray(null);const W=new Map;let X=1;function ie(w,U,G){const V=(G||"")+"|"+w+"x"+U;if(W.has(V)){const b=W.get(V);return b.stamp=X,b}const Y=t.createFramebuffer(),ee=t.createTexture();t.bindTexture(t.TEXTURE_2D,ee),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,w,U,0,t.RGBA,t.UNSIGNED_BYTE,null),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.bindFramebuffer(t.FRAMEBUFFER,Y),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,ee,0),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.bindFramebuffer(t.FRAMEBUFFER,null);const oe={fbo:Y,tex:ee,width:w,height:U,stamp:X};return W.set(V,oe),oe}function J(){for(const[w,U]of W)U.stamp!==X&&(U.fbo&&t.deleteFramebuffer(U.fbo),U.tex&&t.deleteTexture(U.tex),W.delete(w))}const Z=new Map,te=new Map,le=new Map;function Fe(w){const U={},G=/uniform\s+[A-Za-z0-9_]+\s+([A-Za-z_][A-Za-z0-9_]*)[^;]*;\s*\/\/([^\n]*)/g;let V;for(;(V=G.exec(w))!==null;){const Y=V[1],ee=V[2],oe=/"material"\s*:\s*"([^"]+)"/.exec(ee);if(!oe)continue;const b=/"default"\s*:\s*("(?:[^"]*)"|-?\d+(?:\.\d+)?)/.exec(ee);U[oe[1]]={uniform:Y,default:b?Ve(b[1]):void 0}}return U}function _e(w){const U=new Map,G=/uniform\s+sampler2D\s+g_Texture(\d+)\s*;\s*\/\/([^\n]*)/g;let V;for(;(V=G.exec(w))!==null;){const Y=Number(V[1]),ee=/"default"\s*:\s*"([^"]+)"/.exec(V[2]);ee&&ee[1]&&U.set(Y,ee[1])}return U}function Ye(w){const U=[],G=/uniform\s+sampler2D\s+(g_Texture(\d+))[^;]*;\s*\/\/([^\n]*)/g;let V;for(;(V=G.exec(w))!==null;){const Y=/"combo"\s*:\s*"([^"]+)"/.exec(V[3]);Y&&U.push({slot:Number(V[2]),name:V[1],combo:Y[1]})}return U}function Ve(w){if(w.startsWith('"'))return w.slice(1,-1);const U=Number(w);return Number.isFinite(U)?U:void 0}async function Ne(w,U,G){let V=le.get(w);if(V===void 0){const oe=await r("shaders/"+w+".frag")||"",b=await r("shaders/"+w+".vert")||"";V={frag:oe,vert:b,texCombos:Ye(oe)},le.set(w,V)}const Y={...U};for(const oe of V.texCombos)G&&G[oe.slot]&&Y[oe.combo]===void 0&&(Y[oe.combo]=1);const ee=w+"|"+JSON.stringify(Y);if(Z.has(ee)){const oe=Z.get(ee);if(oe===null)throw new Error("shader="+w+" \u7F16\u8BD1\u5931\u8D25\uFF08\u5DF2\u7F13\u5B58\uFF09");return oe}for(let oe=0;oe<4;oe++){const b=new Set,T=I=>te.has(I)?te.get(I):(b.add(I),null),P=ti(Xo(V.frag,"frag",Y,T,V.vert)),C=Xo(V.vert,"vert",Y,T,V.frag);if(b.size===0){let I;try{I=lr(t,C,P)}catch(E){throw Z.set(ee,null),new Error("shader="+w+" "+(E&&E.message))}const D=new Map,$=t.getProgramParameter(I,t.ACTIVE_UNIFORMS);for(let E=0;E<$;E++){const k=t.getActiveUniform(I,E),F=k.name.replace(/\[0\]$/,"");D.set(F,{loc:t.getUniformLocation(I,k.name),type:Oa[k.type]||"unknown",size:k.size})}const z={...Fe(V.vert),...Fe(V.frag)},B=/gl_Position\s*=\s*vec4\s*\(\s*a_Position/.test(V.vert)&&!/[aA]_Position[\s\S]{0,40}mul\s*\(/.test(V.vert),q=new Map([..._e(V.vert),..._e(V.frag)]),S={prog:I,uni:D,matMeta:z,samplerDefaults:q,fragGlsl:P,vertGlsl:C,ndcDirect:B};return Z.set(ee,S),S}await Promise.all(Array.from(b).map(async I=>{te.set(I,await r("shaders/"+I)||"")}))}throw new Error("include \u89E3\u6790\u5931\u8D25: "+w)}const qe=Xr(t,new Uint8Array([255,255,255,255]),1,1),Ue=Xr(t,new Uint8Array([0,0,0,0]),1,1);let ye=null;function he(w){ye=w||null}function De(){if(!ye)return null;const w=typeof ye=="function"?ye():ye;return w&&w.state?w.state:w}const Pe={x:0,y:0,sx:0,sy:0};let Ze=0,Be=0,Ae=0,nt=1/60,rt=-1;const Ft=typeof n.fadeDuration=="number"&&n.fadeDuration>=0?n.fadeDuration:1,xe=(w,U)=>{const G=w!==null&&typeof w=="object"?w.value:w;return G===!0||G===1?!0:G===!1||G===0?!1:U},zt=(w,U)=>{const G=w!==null&&typeof w=="object"?w.value:w;return typeof G=="number"&&Number.isFinite(G)?G:U},Er=w=>n.fade!==!1&&xe(w.camerafade,!1);function Vt(w,U){if(!xe(w.camerashake,!1))return null;const G=zt(w.camerashakeamplitude,0);if(G===0)return null;const V=Math.max(0,Math.min(1,zt(w.camerashakeroughness,0))),Y=zt(w.camerashakespeed,1),ee=U*Y,oe=Math.sin(ee*2.1)*Math.cos(ee*.7),b=Math.cos(ee*1.7)*Math.sin(ee*.9),T=Math.sin(ee*11.3)*Math.cos(ee*7.1),P=Math.cos(ee*9.7)*Math.sin(ee*13.1);return{x:(oe*(1-V)+T*V)*G,y:(b*(1-V)+P*V)*G}}function Mn(){const w=new Date;return(w.getHours()*3600+w.getMinutes()*60+w.getSeconds())/86400}function Me(w,U,G){const V=w.get(U);V&&V.loc!==null&&G(V.loc,V.type,V.size)}function _n(w){if(typeof w=="number")return[w,w,w,w];const U=String(w).trim().split(/[\s,]+/).map(Number);return[U[0]||0,U[1]||0,U[2]||0,U[3]||0]}function Wt(w,U,G){const V=w.get(U);if(!V||V.loc===null)return;const Y=G&&G.value!==void 0?G.value:G,ee=_n(Y);switch(V.type){case"float":t.uniform1f(V.loc,ee[0]);break;case"int":case"bool":t.uniform1i(V.loc,Y===!0||Y===1?1:Math.round(ee[0]));break;case"vec2":t.uniform2f(V.loc,ee[0],ee[1]);break;case"vec3":t.uniform3f(V.loc,ee[0],ee[1],ee[2]);break;case"vec4":t.uniform4f(V.loc,ee[0],ee[1],ee[2],ee[3]);break;case"mat4":t.uniformMatrix4fv(V.loc,!1,it);break;case"mat3":t.uniformMatrix3fv(V.loc,!1,ht);break}}const Je=()=>new Float32Array([1,0,0,0,1,0,0,0,1]);function An(w,U,G,V,Y,ee,oe,b,T,P,C){if(Me(w,"g_Time",S=>t.uniform1f(S,G)),Me(w,"g_Daytime",S=>t.uniform1f(S,Mn())),Me(w,"g_ModelViewProjectionMatrix",S=>t.uniformMatrix4fv(S,!1,ee)),Me(w,"g_ModelMatrix",S=>t.uniformMatrix4fv(S,!1,oe)),Me(w,"g_ViewProjectionMatrix",S=>t.uniformMatrix4fv(S,!1,b)),w.get("g_ModelViewProjectionMatrixInverse")){let S=null;for(const[k,F]of T)k===0&&(S=F);const E=S&&S[0]>0&&S[1]>0?Uo(Dn(gn(),S[0]/2,S[1]/2,1)):it;Me(w,"g_ModelViewProjectionMatrixInverse",k=>t.uniformMatrix4fv(k,!1,E))}Me(w,"g_Brightness",S=>t.uniform1f(S,U.brightness)),Me(w,"g_UserAlpha",S=>t.uniform1f(S,U.alpha)),Me(w,"g_Alpha",S=>t.uniform1f(S,U.alpha)),Me(w,"g_Color",S=>t.uniform3f(S,U.color[0],U.color[1],U.color[2])),Me(w,"g_Color4",S=>t.uniform4f(S,U.color[0],U.color[1],U.color[2],1)),Me(w,"g_CompositeColor",S=>t.uniform3f(S,U.color[0],U.color[1],U.color[2])),Me(w,"g_TexelSize",S=>t.uniform2f(S,1/V,1/Y)),Me(w,"g_TexelSizeHalf",S=>t.uniform2f(S,.5/V,.5/Y)),Me(w,"g_TextureReductionScale",S=>t.uniform1f(S,1));const I=De(),D=qr(!!(I&&I.has),!!w.get("g_PointerScale"));let $=D?On:I?I.u:.5,z=D?On:I?I.v:.5,B=D?On:I?I.lastU:.5,q=D?On:I?I.lastV:.5;if(C&&U&&U.size&&U.size[0]>0&&U.size[1]>0){const S=Math.abs(U.size[0]*U.scale[0]),E=Math.abs(U.size[1]*U.scale[1]);if(S>0&&E>0){const k=U.origin[0]-S/2,F=C.projH-U.origin[1]-E/2,ne=ce=>(C.offX+ce*C.viewW-k)/S,Q=ce=>(C.offY+ce*C.viewH-F)/E;$=ne($),z=Q(z),B=ne(B),q=Q(q)}}Me(w,"g_PointerPosition",S=>t.uniform2f(S,$,z)),Me(w,"g_PointerPositionLast",S=>t.uniform2f(S,B,q)),Me(w,"g_PointerState",S=>t.uniform4f(S,$,z,I&&I.leftDown?1:0,0)),Me(w,"g_ParallaxPosition",S=>t.uniform2f(S,Pe.sx*.5+.5,Pe.sy*.5+.5)),Me(w,"g_Frametime",S=>t.uniform1f(S,nt)),w.get("g_EffectTextureProjectionMatrixInverse")&&Me(w,"g_EffectTextureProjectionMatrixInverse",S=>t.uniformMatrix4fv(S,!1,it));for(let S=0;S<8;S++)Me(w,"g_Texture"+S,E=>t.uniform1i(E,S));for(const[S,E]of T)Me(w,"g_Texture"+S+"Resolution",k=>t.uniform4f(k,E[0],E[1],E[2],E[3]));if(l){const S=typeof l=="function"?l():l;if(S)for(const[E,k]of f){const F=S[k];F&&Me(w,E,ne=>t.uniform1fv(ne,F))}}}function Ht(w,U,G){for(const[V,Y]of Object.entries(U||{})){const ee=G&&G[V];ee&&Wt(w,ee.uniform,Y)}for(const[V,Y]of Object.entries(G||{}))if(!U||!(V in U)){const ee=ri(Y.uniform,Y.default);ee!==void 0&&Wt(w,Y.uniform,ee)}}function Qn(w){const U=De();qr(!!(U&&U.has),!!w.get("g_PointerScale"))&&Me(w,"g_PointerScale",G=>t.uniform1f(G,0))}function Jn(w,U,G,V){if(!w)return w;let Y=!1;for(const oe of Object.values(w))if(oe!==null&&typeof oe=="object"&&typeof oe.script=="string"){Y=!0;break}if(!Y||!d)return w;const ee={...w};for(const[oe,b]of Object.entries(w)){if(b===null||typeof b!="object"||typeof b.script!="string")continue;const T=U+"|"+oe;let P=v.get(T);if(P===void 0){_.total++;try{P=d(b.script,b.scriptproperties||b.scriptProperties||null,{userProperties:y||{},audioViews:x||void 0,layer:V||null,shared:m||{},inputView:M||void 0,setTimeout:h?h.setTimeout:void 0,clearTimeout:h?h.clearTimeout:void 0,setInterval:h?h.setInterval:void 0,clearInterval:h?h.clearInterval:void 0})}catch{P=null}if(P?_.ok++:_.failed++,v.set(T,P),P){const B=b.value!==void 0?b.value:b,q=_n(B),E=typeof B=="number"?q[0]:{x:q[0],y:q[1],z:q[2]};P.init&&P.init(E)}if(P&&typeof P.applyUserProperties=="function")try{P.applyUserProperties(y||{})}catch{}if(P&&P.hasMediaHook&&g)try{g(P)}catch{}}if(!P||P.disabled||!P.hasUpdate)continue;if(P.engine){P.engine.runtime=G,P.engine.frametime=nt,P.engine.timeOfDay=Mn();const B=De();B&&B.screenW&&B.screenH&&(P.engine.screenResolution={x:B.screenW,y:B.screenH})}const C=_n(b.value!==void 0?b.value:b),D=typeof(b.value!==void 0?b.value:b)=="number"?C[0]:{x:C[0],y:C[1],z:C[2]};let $;try{$=P.callUpdate(D)}catch{$=void 0}const z=$??D;if(typeof z=="number"&&Number.isFinite(z))ee[oe]=z;else if(z&&typeof z=="object"){const B=Number(z.x),q=Number(z.y),S=Number(z.z);Number.isFinite(B)&&Number.isFinite(q)&&(ee[oe]=Number.isFinite(S)?`${B} ${q} ${S}`:`${B} ${q} 0`)}}return ee}function Pr(w,U,G){if(!w)return w;let V=!1;for(const ee of Object.values(w))if(ee&&typeof ee=="object"&&ee.animation&&ee.animation.options){V=!0;break}if(!V)return w;const Y={...w};for(const[ee,oe]of Object.entries(w)){if(!oe||typeof oe!="object"||!oe.animation||!oe.animation.options)continue;const b=U+"|anim|"+ee;let T=A.get(b);if(!T){const P=Ko(oe.animation),C=oe.value!==void 0?oe.value:0;P.baseNumeric=Array.isArray(C)?C.slice():C,T={ctrl:P},A.set(b,T)}T.ctrl.playing&&T.ctrl.setFrame(G*T.ctrl.fps*T.ctrl.rate),Y[ee]=T.ctrl.applyTo(T.ctrl.baseNumeric)}return Y}function er(w,U,G,V){return w==null||w===""?null:w.startsWith("_rt_")?w.startsWith("_rt_imageLayerComposite")?fn&&mt.has(w)?mt.get(w):U:G.has(w)?G.get(w):null:G.has(w)?G.get(w):V.get(w)||null}const Xt=Ba(),Cr=Ia(),un=new Map;function tn(w,U){const G=w+"x"+U;let V=un.get(G);return V===void 0&&(V=Da(w,U),un.set(G,V)),V}let ot=null;function dt(w,U){ot!==w&&(t.bindBuffer(t.ARRAY_BUFFER,O),t.bufferData(t.ARRAY_BUFFER,U,t.DYNAMIC_DRAW),ot=w)}const Te={mvp:t.getUniformLocation(N,"u_MVP"),tex:t.getUniformLocation(N,"u_Tex"),color:t.getUniformLocation(N,"u_Color4"),frameOrigin:t.getUniformLocation(N,"u_FrameOrigin"),frameU:t.getUniformLocation(N,"u_FrameU"),frameV:t.getUniformLocation(N,"u_FrameV"),blendPrep:t.getUniformLocation(N,"u_BlendPrep")},pt={mvp:t.getUniformLocation(j,"u_MVP"),tex:t.getUniformLocation(j,"u_Tex"),blendPrep:t.getUniformLocation(j,"u_BlendPrep")},Gt={mvp:t.getUniformLocation(H,"u_MVP"),tex:t.getUniformLocation(H,"u_Tex")},it=gn(),ht=Je();function At(w){w==="translucent"?(t.enable(t.BLEND),t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA)):w==="additive"?(t.enable(t.BLEND),t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE)):t.disable(t.BLEND)}let Nt=0;function Tt(w){const{mode:U,prep:G}=Yr(w);Nt=G,U==="additive"?(t.enable(t.BLEND),t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE)):U==="multiply"?(t.enable(t.BLEND),t.blendFuncSeparate(t.DST_COLOR,t.ZERO,t.ONE,t.ONE_MINUS_SRC_ALPHA)):U==="screen"?(t.enable(t.BLEND),t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_COLOR,t.ONE,t.ONE_MINUS_SRC_ALPHA)):At("translucent")}function Tn(w,U){if(U&&U.perspective)return!1;const G=w.size[0]*w.scale[0],V=w.size[1]*w.scale[1];if(G===0||V===0)return!1;let Y=Math.abs(G)/2,ee=Math.abs(V)/2;const oe=w.angles[2];if(oe!==0){const $=Math.abs(Math.cos(oe)),z=Math.abs(Math.sin(oe)),B=Y*$+ee*z,q=Y*z+ee*$;Y=B,ee=q}const b=w.origin[0],T=U.projH-w.origin[1];let P=64;w.parallaxDepth&&(P+=Math.abs(vn(w.parallaxDepth[0])*Be),P+=Math.abs(vn(w.parallaxDepth[1])*Ae));const C=Qo(w),I=P+C[0],D=P+C[1];return b+Y+I<U.offX||b-Y-I>U.offX+U.viewW||T+ee+D<U.offY||T-ee-D>U.offY+U.viewH}function Sn(w,U,G){if(!w.spriteSheet)return null;const V=U&&U.frames,Y=Array.isArray(V)?V:V&&V.list;if(!Y||Y.length===0)return null;const ee=V&&V.atlasWidth||U.width||0,oe=V&&V.atlasHeight||U.height||0;if(ee<=0||oe<=0)return null;w.spriteFrameCount=Y.length;let b=0;const T=w.textureAnimation;if(T&&T.frame!==null&&T.frame!==void 0)b=Math.floor(Number(T.frame))||0,b>=0||(b=0),b>=Y.length&&(b=Y.length-1);else if(Y.length>1){const z=T&&T.playing===!1;let B=0;for(const q of Y)B+=q.duration>0?q.duration:1/30;if(!z&&B>0){let q=G%B;q<0&&(q+=B);for(let S=0;S<Y.length;S++){const E=Y[S].duration>0?Y[S].duration:.03333333333333333;if(q<E){b=S;break}q-=E,b=S}}}const P=Y[b],C=P.uDir?P.uDir[0]:P.width,I=P.uDir?P.uDir[1]:0,D=P.vDir?P.vDir[0]:0,$=P.vDir?P.vDir[1]:P.height;return[P.x/ee,P.y/oe,C/ee,I/oe,D/ee,$/oe]}function Ut(w,U){const G=w.size[0]*w.scale[0],V=w.size[1]*w.scale[1];let Y=gn();if(U&&U.perspective){const oe=wa(w,U);Y=yn(Y,oe[0],oe[1],oe[2]);const b=w.angles[0]||0,T=w.angles[1]||0;T&&(Y=ya(Y,T)),b&&(Y=ba(Y,b)),Y=Do(Y,-w.angles[2])}else{if(Y=yn(Y,w.origin[0],U.projH-w.origin[1],w.origin[2]),w.parallaxDepth&&(Be!==0||Ae!==0)){const oe=vn(w.parallaxDepth[0]),b=vn(w.parallaxDepth[1]);Y=yn(Y,oe*Be,b*Ae,0)}Y=Do(Y,-w.angles[2])}const ee=Go[w.alignment]||[.5,.5];return(ee[0]!==.5||ee[1]!==.5)&&(Y=yn(Y,(.5-ee[0])*G,(.5-ee[1])*V,0)),{m:Y,w:G,h:V}}function En(w,U,G,V,Y,ee,oe,b,T=!1,P=null,C=null){const I=Ut(V,Y);let D=I.m;if(C){const B=(C[0]+C[2]/2)*V.scale[0],q=(C[1]+C[3]/2)*V.scale[1];D=yn(D,B,-q,0),D=Dn(D,C[2]*V.scale[0],C[3]*V.scale[1],1)}else D=Dn(D,I.w,I.h,1);const $=Lt(ee,D),z=w===j?pt:Te;t.useProgram(w),T?(Nt=0,t.enable(t.BLEND),V.containerAlphaMeaningful?t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA):t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA)):Tt(V.colorBlendMode),z.blendPrep!==null&&z.blendPrep!==void 0&&t.uniform1i(z.blendPrep,Nt),je?(t.bindFramebuffer(t.FRAMEBUFFER,je.fbo.fbo),t.viewport(0,0,je.w,je.h)):(t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,oe,b)),t.bindVertexArray(K),dt("local",Cr),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,U),t.uniform1i(z.tex,0),t.uniformMatrix4fv(z.mvp,!1,$),z.color!==null&&z.color!==void 0&&t.uniform4f(z.color,G[0],G[1],G[2],G[3]),Dt(z,P),t.drawArrays(t.TRIANGLES,0,6)}function Dt(w,U){!w||w.frameOrigin===null||w.frameOrigin===void 0||(U?(t.uniform2f(w.frameOrigin,U[0],U[1]),t.uniform2f(w.frameU,U[2],U[3]),t.uniform2f(w.frameV,U[4],U[5])):(t.uniform2f(w.frameOrigin,0,0),t.uniform2f(w.frameU,1,0),t.uniform2f(w.frameV,0,1)))}let nn=null,je=null;const mt=new Map,gt=new Map;let fn=!0;function Pn(w,U){const G=Ut(w,U),V=U&&U.perspective?w.scale[1]:-w.scale[1],Y=U&&U.perspective&&w.scale[2]||1;return Dn(G.m,w.scale[0],V,Y)}function rn(w,U,G,V,Y,ee,oe){je?(t.bindFramebuffer(t.FRAMEBUFFER,je.fbo.fbo),t.viewport(0,0,je.w,je.h)):(t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,V,Y));const b=Lt(G,Pn(w,U));nn(w,b,{time:ee,overrideTex:oe||null}),ot=null}let ut=null;function Cn(w,U){return ut===null&&(ut=t.createTexture(),t.bindTexture(t.TEXTURE_2D,ut),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE)),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindTexture(t.TEXTURE_2D,ut),t.copyTexImage2D(t.TEXTURE_2D,0,t.RGB8,0,0,w,U,0),ut}function tr(w,U,G,V,Y,ee,oe,b){const T=Cn(oe,b),P=Ut(w,Y);let C=P.m;C=Dn(C,P.w,P.h,1);const I=Lt(ee,C),D=[[-.5,.5],[.5,.5],[-.5,-.5],[.5,-.5]].map(([E,k])=>{const F=_a(I,E,k,0);return[F[0]*.5+.5,F[1]*.5+.5]}),[$,z,B,q]=D,S=new Float32Array([0,V,0,$[0],$[1],0,0,0,B[0],B[1],G,V,0,z[0],z[1],G,V,0,z[0],z[1],0,0,0,B[0],B[1],G,0,0,q[0],q[1]]);t.useProgram(H),At("normal"),t.disable(t.BLEND),t.bindFramebuffer(t.FRAMEBUFFER,U.fbo),t.viewport(0,0,G,V),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.bindVertexArray(K),t.bindBuffer(t.ARRAY_BUFFER,O),t.bufferData(t.ARRAY_BUFFER,S,t.DYNAMIC_DRAW),ot=null,t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,T),t.uniform1i(Gt.tex,0),t.uniformMatrix4fv(Gt.mvp,!1,bn(0,G,0,V,-1e4,1e4)),t.drawArrays(t.TRIANGLES,0,6),t.enable(t.BLEND)}function Bt(w,U,G,V,Y){if(!fn||je)return;const ee=gt.get(w.id);if(!ee||ee.size===0)return;const oe=Math.max(1,Math.round(Math.abs(w.size[0]*(w.scale[0]||1)))),b=Math.max(1,Math.round(Math.abs(w.size[1]*(w.scale[1]||1))));if(oe<=1&&b<=1)return;const T=ie(oe,b,"lc:"+w.id);tr(w,T,oe,b,U,G,V,Y);for(const P of ee)mt.set(P,T);gt.delete(w.id),t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,V,Y)}async function Lr(w,U,G,V,Y,ee,oe,b){X++,t.viewport(0,0,G,V);const T=w.general||{};if(T.clearenabled!==!1){const S=qo(T.clearcolor||"0 0 0");t.clearColor(S[0],S[1],S[2],1)}else t.clearColor(0,0,0,1);if(t.clear(t.COLOR_BUFFER_BIT),rt>=0){const S=Y-rt;nt=S>0&&S<1?S:Math.min(.1,Math.max(.001,S||1/60))}rt=Y;const P=Sa(w,G,V,ee,oe,b);let C=Lt(P.projection,P.view);const I=T.cameraparallax,D=I===!0||I!==null&&typeof I=="object"&&I.value===!0;Be=0,Ae=0;const $=De();if($&&(Pe.x=$.u*2-1,Pe.y=$.v*2-1),!P.perspective&&n.parallax!==!1&&D){const S=(yt,de)=>{const pe=yt!==null&&typeof yt=="object"?yt.value:yt;return typeof pe=="number"&&Number.isFinite(pe)?pe:de},E=S(T.cameraparallaxamount,0),k=S(T.cameraparallaxmouseinfluence,1),F=S(T.cameraparallaxdelay,1),ne=Y-Ze;Ze=Y;const Q=ne>0?1-Math.exp(-ne/Math.max(.05,F)):1;Pe.sx+=(Pe.x-Pe.sx)*Q,Pe.sy+=(Pe.y-Pe.sy)*Q;const ce=E*k,ue=60,me=Pe.sx*ce*P.viewW,Ie=Pe.sy*ce*P.viewH,bt=Math.max(Math.abs(me),Math.abs(Ie))/ue,Et=bt>1?1/bt:1;Be=-(me*Et),Ae=-(Ie*Et)}if(!P.perspective&&n.shake!==!1){const S=Vt(T,Y);if(S){const E=S.x*P.viewW*.02,k=S.y*P.viewH*.02;(E!==0||k!==0)&&(C=Lt(C,yn(gn(),E,k,0)))}}if(ye){const S=typeof ye=="function"?ye():ye;S&&typeof S.syncWorld=="function"&&S.syncWorld(P,0,0)}if(!L){L=!0;const S=(w.layers||[]).filter(F=>F.isContainer),E=S.filter(F=>(F.effects||[]).some(ne=>ne.visible)&&!F.hasChildren),k=E.filter(F=>(F.effects||[]).some(ne=>(ne.materialPasses||[]).length>0));o(`containers total=${S.length} canvasCandidates=${E.length} passesResolved=${k.length} names=${E.slice(0,4).map(F=>F.name||"?").join("/")}`)}await Rr(w,U,P,G,V,Y);const z=new Map;for(const S of w.layers)S.id!==void 0&&z.set(S.id,S);const B=new Set;for(const S of w.layers)!S.visible||S.destroyed||!S.isContainer||!S.hasChildren||!(S.effects||[]).some(k=>k.visible)||(S.childIds||[]).length===0||fr(S,z,B);if(c)try{c()}catch(S){o("particle advance error: "+(S&&S.message))}const q=P.perspective?w.layers.slice().sort((S,E)=>+!!E.isSkybox-+!!S.isSkybox):w.layers;for(const S of q)if(!S.destroyed){if(!S.visible){gt.has(S.id)&&Bt(S,P,C,G,V);continue}if(!(S.isPostProcess&&!(S.effects||[]).some(E=>E.visible))&&!B.has(S.id)){if(S.isContainer){if(!(S.effects||[]).some(k=>k.visible)){Bt(S,P,C,G,V);continue}if(S.hasChildren){(S.childIds||[]).length>0&&await nr(S,w,U,P,C,G,V,Y);continue}}if(S.particle){if(u)try{await u(S.id,P,C,G,V)}catch(E){o("particle render error: "+(E&&E.message))}continue}Tn(S,P)||await St(S,U,P,C,G,V,Y)}}if(Er(T)&&Y<Ft){const S=Math.max(0,Math.min(1,Y/Ft)),E=1-S*S*(3-2*S);if(E>.002){const k=qo(T.clearcolor||"0 0 0");t.useProgram(N),t.enable(t.BLEND),t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA),t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,G,V),t.bindVertexArray(K),dt("pass",Xt),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,qe),t.uniform1i(Te.tex,0),t.uniform4f(Te.color,k[0],k[1],k[2],E),Dt(Te,null),Te.blendPrep!==null&&Te.blendPrep!==void 0&&t.uniform1i(Te.blendPrep,0),t.uniformMatrix4fv(Te.mvp,!1,it),t.drawArrays(t.TRIANGLES,0,6)}}t.bindVertexArray(null),J()}async function Rr(w,U,G,V,Y,ee){mt.clear(),gt.clear();const oe=new Map,b=new Set;let T=null;const P=C=>{if(typeof C!="string")return;const I=/^_rt_imageLayerComposite_(\d+)_[a-z]$/.exec(C);if(!I)return;const D=Number(I[1]);T!==null&&D===T&&b.add(D);let $=oe.get(D);$||($=new Set,oe.set(D,$)),$.add(C)};for(const C of w.layers||[]){T=C.id;for(const I of C.effects||[])if(I.visible){for(const D of I.passes||[])for(const $ of D.textures||[])P($);for(const D of I.materialPasses||[]){for(const $ of D.binds||[])P($&&$.name);for(const $ of D.textures||[])P($)}}}if(oe.size!==0){for(const[C,I]of oe){const D=(w.layers||[]).find(ue=>ue.id===C);if(!D||D.particle||D.isPostProcess||b.has(C))continue;const $=typeof D.image=="string"?D.image:"";if(D.isContainer&&!D.hasChildren&&$.indexOf("models/util/composelayer")===0&&!(D.effects||[]).some(ue=>ue.visible)){gt.set(C,I);continue}const B=Math.max(1,Math.round(Math.abs(D.size[0]*(D.scale[0]||1)))),q=Math.max(1,Math.round(Math.abs(D.size[1]*(D.scale[1]||1))));if(B<=1&&q<=1)continue;const S=ie(B,q,"lc:"+C);t.bindFramebuffer(t.FRAMEBUFFER,S.fbo),t.viewport(0,0,B,q),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT);const E={view:G.view,projection:bn(0,B,0,q,-1e4,1e4),eye:G.eye,projW:B,projH:q,offX:0,offY:0,viewW:B,viewH:q},k=je,F=D.origin,ne=D.scale,Q=D.angles,ce=D.visible;je={fbo:S,w:B,h:q},D.origin=[B/2,E.projH-q/2,F[2]],D.scale=[Math.sign(ne[0])||1,Math.sign(ne[1])||1,ne[2]],D.angles=[0,0,0],D.visible=!0;try{await St(D,U,E,E.projection,B,q,ee);for(const ue of I)mt.set(ue,S)}catch(ue){o(`composite \u6E90\u5C42 ${C} \u6E32\u67D3\u5931\u8D25: ${ue&&ue.message}`)}finally{je=k,D.origin=F,D.scale=ne,D.angles=Q,D.visible=ce}}t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,V,Y)}}async function nr(w,U,G,V,Y,ee,oe,b){const T=Math.max(1,Math.round(Math.abs(w.size[0]))),P=Math.max(1,Math.round(Math.abs(w.size[1])));if((w.childIds||[]).length===0)return;const I=new Map;for(const Q of U.layers)Q.id!==void 0&&I.set(Q.id,Q);const D=fr(w,I),$=U.layers.filter(Q=>D.has(Q.id)&&Q.visible);if($.length===0)return;const z=ie(T,P,"group");t.bindFramebuffer(t.FRAMEBUFFER,z.fbo),t.viewport(0,0,T,P),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT);const B={view:V.view,projection:bn(0,T,0,P,-1e4,1e4),eye:V.eye,projW:T,projH:P,offX:0,offY:0,viewW:T,viewH:P},q=B.projection,S=w.scale[0]||1,E=w.scale[1]||1,k=w.angles[2]||0,F=Math.cos(-k),ne=Math.sin(-k);je={fbo:z,w:T,h:P};try{for(const Q of $){if(Q.isPostProcess||Q.particle||Q.isContainer&&(Q.childIds||[]).length>0)continue;const ce=Q.origin,ue=Q.scale,me=Q.angles,Ie=ce[0]-w.origin[0],bt=ce[1]-w.origin[1],Et=(Ie*F-bt*ne)/S,yt=(Ie*ne+bt*F)/E;Q.origin=[T/2+Et,P/2+yt,ce[2]],Q.scale=[ue[0]/S,ue[1]/E,ue[2]],Q.angles=[me[0],me[1],me[2]-k];try{await St(Q,G,B,q,T,P,b)}finally{Q.origin=ce,Q.scale=ue,Q.angles=me}}}finally{je=null}w.groupTex=z.tex,w.groupW=T,w.groupH=P;try{await St(w,G,V,Y,ee,oe,b)}finally{w.groupTex=null}}async function St(w,U,G,V,Y,ee,oe){const b=!!(w.puppet&&nn),T=!w.solid&&w.textureName?U.get(w.textureName):null;if(T&&T.video){const de=T.video;if(de.readyState>=2&&de.currentTime!==T.lastUploaded){t.bindTexture(t.TEXTURE_2D,T.glTex);try{let pe=de.videoWidth||T.width,fe=de.videoHeight||T.height;const Ee=2048,st=t.getParameter(t.MAX_TEXTURE_SIZE),at=st>0&&st<4096?Math.min(Ee,st):Ee;let vt=1;Math.max(pe,fe)>at&&(vt=at/Math.max(pe,fe));const et=Math.max(1,Math.round(pe*vt)),Ce=Math.max(1,Math.round(fe*vt));let dn=de;if(i&&et>0&&Ce>0){(i.width!==et||i.height!==Ce)&&(i.width=et,i.height=Ce);const ct=i.getContext("2d");ct&&(ct.clearRect(0,0,et,Ce),ct.drawImage(de,0,0,et,Ce),dn=i)}if(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,dn),t.getError()!==t.NO_ERROR&&i)try{const We=i.getContext("2d").getImageData(0,0,i.width,i.height);for(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,i.width,i.height,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array(We.data.buffer));t.getError()!==t.NO_ERROR;);}catch{}T.width=et,T.height=Ce,T.lastUploaded=de.currentTime,s||(s=!0,o("video tex ready "+et+"x"+Ce+" (src "+pe+"x"+fe+")"))}catch(pe){s||(s=!0,o("video upload FAIL: "+(pe&&pe.message||pe))),console.warn("[we-scene] \u89C6\u9891\u5E27\u4E0A\u4F20\u5931\u8D25:",pe&&pe.message,"readyState=",de.readyState,"cur=",de.currentTime)}}}const P=w.groupTex?w.groupTex:T&&T.glTex?T.glTex:w.solid?qe:Ue,C=(!!w.passthrough||!!w.isPostProcess||Jo(w))&&!w.groupTex&&!T&&!b;let I,D;if(w.groupTex?(I=w.groupW||w.size[0],D=w.groupH||w.size[1]):b||!T?(I=w.size[0],D=w.size[1]):(I=T.width,D=T.height),!b&&T&&w.spriteSheet){const de=T.frames,pe=Array.isArray(de)?de:de&&de.list;pe&&pe.length&&(I=pe[0].width||I,D=pe[0].height||D)}const $=Math.max(1,Math.round(I)),z=Math.max(1,Math.round(D)),B=[w.color[0]*w.brightness,w.color[1]*w.brightness,w.color[2]*w.brightness,w.alpha],q=(w.effects||[]).filter(de=>de.visible);let S=$,E=z;if(a>0&&G.projW>0&&G.projH>0){const de=Math.min(Math.abs(w.size[0]*w.scale[0]),G.viewW),pe=Math.min(Math.abs(w.size[1]*w.scale[1]),G.viewH),fe=de*(Y/G.projW),Ee=pe*(ee/G.projH);if(fe>0&&Ee>0){const st=Math.max(64,Math.round(fe*a)),at=Math.max(64,Math.round(Ee*a));st<$&&(S=st),at<z&&(E=at)}}if(q.length===0){b?rn(w,G,V,Y,ee,oe):En(N,P,B,w,G,V,Y,ee,!1,Sn(w,T,oe));return}const k=ie(S,E,"ping"),F=ie(S,E,"pong"),ne=bn(0,S,0,E,-1e4,1e4);if(b)t.useProgram(N),At("normal"),t.bindFramebuffer(t.FRAMEBUFFER,k.fbo),t.viewport(0,0,S,E),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.bindVertexArray(K),ot=null,dt("layer"+S+"x"+E,tn(S,E)),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,P),t.uniform1i(Te.tex,0),t.uniform4f(Te.color,1,1,1,1),Dt(Te,null),Te.blendPrep!==null&&Te.blendPrep!==void 0&&t.uniform1i(Te.blendPrep,0),t.uniformMatrix4fv(Te.mvp,!1,ne),t.drawArrays(t.TRIANGLES,0,6);else if(C)tr(w,k,S,E,G,V,Y,ee);else{t.useProgram(N),At("normal"),t.bindFramebuffer(t.FRAMEBUFFER,k.fbo),t.viewport(0,0,S,E),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.bindVertexArray(K),dt("layer"+S+"x"+E,tn(S,E)),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,P),t.uniform1i(Te.tex,0);const de=q.some(pe=>pe&&pe.layerMaterial)?[1,1,1,B[3]]:B;t.uniform4f(Te.color,de[0],de[1],de[2],de[3]),Dt(Te,Sn(w,T,oe)),Te.blendPrep!==null&&Te.blendPrep!==void 0&&t.uniform1i(Te.blendPrep,0),t.uniformMatrix4fv(Te.mvp,!1,ne),t.drawArrays(t.TRIANGLES,0,6)}let Q=k,ce=F;const ue=new Map;let me=!1,Ie=k;const bt=[],Et=new Set;for(const de of q){for(const fe of de.fbos||[])if(!ue.has(fe.name)){const[Ee,st]=ei(fe,S,E),at=fe.unique?w.id+":"+fe.name:fe.name;ue.set(fe.name,ie(Ee,st,at))}const pe=de.materialPasses||[];for(let fe=0;fe<pe.length;fe++)bt.push({eff:de,mp:pe[fe],ov:de.passes&&de.passes[fe]})}const yt=[];for(let de=0;de<bt.length;de++){const{eff:pe,mp:fe,ov:Ee}=bt[de];if(Et.has(pe))continue;const st={...fe.combos||{},...Ee&&Ee.combos||{}},at=fe.textures||[],vt=Ee&&Ee.textures||[],et=[];for(let ve=0;ve<Math.max(at.length,vt.length);ve++)vt[ve]!==void 0&&vt[ve]!==null?et[ve]=vt[ve]:et[ve]=at[ve]!==void 0?at[ve]:null;if(fe.copyCommand){const ve=fe.source?ue.get(fe.source):null,Le=fe.target?ue.get(fe.target):null;ve&&Le&&(t.useProgram(j),At("normal"),t.bindFramebuffer(t.FRAMEBUFFER,Le.fbo),t.viewport(0,0,Le.width,Le.height),t.bindVertexArray(K),dt("pass",Xt),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,ve.tex),t.uniform1i(pt.tex,0),pt.blendPrep!==null&&pt.blendPrep!==void 0&&t.uniform1i(pt.blendPrep,0),t.uniformMatrix4fv(pt.mvp,!1,it),t.drawArrays(t.TRIANGLES,0,6),t.bindFramebuffer(t.FRAMEBUFFER,null));continue}let Ce;try{Ce=await Ne(fe.shader,st,et)}catch(ve){const Le=ve&&ve.message||String(ve);/已缓存/.test(Le)||console.warn("[we-scene] \u8DF3\u8FC7\u6548\u679C\uFF08pass \u7F16\u8BD1\u5931\u8D25\uFF09:",fe.shader,Le),Et.add(pe);continue}const dn=Ce.prog,ct=Ce.uni;Ce.fragGlsl&&yt.push(Ce.fragGlsl);let We,Ln;fe.target?(me||(Ie=Q,me=!0),We=ue.get(fe.target)||Q,Ln=Ie):(me=!1,We=ce,Ln=Q),t.useProgram(dn),At(fe.blending||"normal"),t.bindFramebuffer(t.FRAMEBUFFER,We.fbo),t.viewport(0,0,We.width,We.height),t.bindVertexArray(K);const wo=!Ce.ndcDirect;wo?dt("passPx"+We.width+"x"+We.height,tn(We.width,We.height)):dt("pass",Xt);const As=wo?Uo(bn(0,We.width,0,We.height,-1e4,1e4)):it,kr=fe.textures||[],Ts=Math.max(kr.length,8),Mo=new Map,Ss=new Set;for(let ve=0;ve<Ts;ve++){let Le=ve<kr.length?kr[ve]:null;Ee&&Ee.textures&&Ee.textures[ve]!==void 0&&Ee.textures[ve]!==null&&(Le=Ee.textures[ve]);for(const kn of fe.binds||[])kn.index===ve&&(Le=kn.name);let Pt;if(ve===0&&(Le==null||Le===""))Pt=Ln;else{if((Le==null||Le==="")&&Ce.samplerDefaults){const kn=Ce.samplerDefaults.get(ve);kn&&(Le=kn)}Pt=er(Le,Ln,ue,U)}Le==="previous"&&(Pt=Ln),Pt===null&&(Pt={glTex:qe,width:1,height:1,tex:qe});const Rn=Pt.fbo?Pt:{tex:Pt.glTex||qe,width:Pt.width||1,height:Pt.height||1};t.activeTexture(t.TEXTURE0+ve),t.bindTexture(t.TEXTURE_2D,Rn.tex),Ss.add(ve),Mo.set(ve,[Rn.width,Rn.height,Rn.width,Rn.height])}An(ct,w,oe,G.projW,G.projH,As,ne,it,Mo,ne,G),Ht(ct,Pr(Jn({...fe.constants||{},...Ee&&Ee.constantshadervalues||{}},(w.id||w.name||"?")+"|"+(fe.shader||"?")+"|"+de,oe,w),(w.id||w.name||"?")+"|"+(fe.shader||"?")+"|"+de,oe),Ce.matMeta),Qn(ct),t.drawArrays(t.TRIANGLES,0,6),fe.target||(ce=Q,Q=We)}if(w.isContainer&&!w.groupTex&&!C&&w.containerAlphaMeaningful===void 0){let de=!1;for(const pe of yt){if(typeof pe!="string")continue;const fe=pe.match(/\bfloat\s+alpha\s*=\s*([^;]+);/);if(fe&&!/^\s*scene\s*\.\s*a\s*$/.test(fe[1])){de=!0;break}}w.containerAlphaMeaningful=de,o(`container "${w.name||"?"}" alpha ${de?"\u643A\u5E26\u5F62\u72B6 \u2192 SRC_ALPHA":"\u65E0\u4FE1\u606F \u2192 \u52A0\u6CD5"}`)}if(b){rn(w,G,V,Y,ee,oe,Q.tex);return}En(j,Q.tex,[1,1,1,1],w,G,V,Y,ee,!!w.isContainer&&!w.groupTex&&!C,null,null)}return{gl:t,render:Lr,getFBO:ie,getEffectProgram:Ne,progCache:Z,shaderResolver:r,whiteTex:qe,resetShaderCaches:function(){Z.clear(),te.clear(),le&&le.clear()},setFboCapFactor:function(w){a=w},setParticleRenderer:function(w,U){c=typeof w=="function"?w:null,u=typeof U=="function"?U:null},setConstantScriptRuntime:R,applyConstUserProperties:function(w){if(w){for(const U of v.values())if(U&&typeof U.applyUserProperties=="function")try{U.applyUserProperties(w)}catch{}}},constantScriptStats:function(){return{..._,cached:v.size}},setCompositeEnabled:function(w){fn=!!w},compositeStats:function(){const w=[],U=new Uint8Array(4);for(const[G,V]of mt){let Y=null;try{t.bindFramebuffer(t.FRAMEBUFFER,V.fbo),t.readPixels(V.w>>1,V.h>>1,1,1,t.RGBA,t.UNSIGNED_BYTE,U),Y=[U[0],U[1],U[2],U[3]]}catch{}w.push({name:G,w:V.w,h:V.h,center:Y})}return t.bindFramebuffer(t.FRAMEBUFFER,null),w},setPuppetRenderer:function(w){nn=w},setAudioProvider:p,setPointerProvider:he,getParallaxOffset:function(){return{x:Be,y:Ae}},dispose:function(){try{const w=t.getExtension("WEBGL_lose_context");w&&w.loseContext()}catch{}}}}const qa=Object.freeze(Object.defineProperty({__proto__:null,ALIGN:Go,XRAY_IDLE_SCREEN_UV:On,XRAY_SIZE_FALLBACK:ni,applyColorBlendCPU:Ha,collectGroupDescendantIds:fr,colorBlendPlan:Yr,constantFallback:ri,createRenderer:Ya,effectFboSize:ei,layerWantsPreserveBackdrop:Jo,makeTexture:Xr,makeTextureMip:$a,puppetAnimMargin:Qo,rewriteXrayFragScale:ti,xrayShouldParkPointer:qr,xrayUvScale:Xa},Symbol.toStringTag,{value:"Module"}));function Za(e=256,n=8){const t=e/n,r=oi(1337),o=oi(4242),i=new Float32Array(t*t),s=new Float32Array(t*t);for(let u=0;u<t*t;u++)i[u]=r(),s[u]=o();const a=new Uint8Array(e*e*4),c=n;for(let u=0;u<e;u++){const l=Math.floor(u/c),f=u%c/c,p=f*f*(3-2*f);for(let d=0;d<e;d++){const y=Math.floor(d/c),x=d%c/c,m=x*x*(3-2*x),M=y%t,h=(y+1)%t,g=l%t,v=(l+1)%t,A=i[g*t+M],_=i[g*t+h],R=i[v*t+M],L=i[v*t+h],N=s[g*t+M],j=s[g*t+h],H=s[v*t+M],K=s[v*t+h],O=A+(_-A)*m+(R-A)*p+(A-_-R+L)*m*p,W=N+(j-N)*m+(H-N)*p+(N-j-H+K)*m*p,X=(u*e+d)*4;a[X]=Math.round(O*255),a[X+1]=Math.round(W*255),a[X+2]=0,a[X+3]=255}}return a}function oi(e){let n=e>>>0;return()=>{n|=0,n=n+1831565813|0;let t=Math.imul(n^n>>>15,1|n);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}const Ka=Object.freeze(Object.defineProperty({__proto__:null,generateNoiseTexture:Za},Symbol.toStringTag,{value:"Module"})),wt=Math.PI*2;function Re(e,n){return e==null?Math.random():n==null?e:e+Math.random()*(n-e)}function ii(e,n,t){if(e==null)return Math.random();if(n==null)return e;const r=t&&t!==1?Math.pow(Math.random(),t):Math.random();return e+r*(n-e)}function be(e,n){if(Array.isArray(e))return[e[0]||0,e[1]||0,e[2]||0];if(e==null)return n?n.slice():[0,0,0];if(typeof e=="object")return be(e.value,n);if(typeof e=="number")return[e,e,e];const t=String(e).trim().split(/\s+/).map(Number);return[t[0]||0,t[1]||0,t[2]||0]}function si(e){return e==null?null:typeof e=="number"?[e,e,e]:be(e)}function re(e,n){if(e==null)return n;if(typeof e=="object")return re(e.value,n);const t=Number(e);return Number.isFinite(t)?t:n}function Zr(e,n){const t=e[0],r=e[1]>t?e[1]:t+1e-6,o=Math.min(1,Math.max(0,(n-t)/(r-t)));return o*o*(3-2*o)}function Zt(e,n,t){const r=Math.sin(e*127.1+n*311.7+t*74.7)*43758.5453;return r-Math.floor(r)}function Qa(e,n,t){const r=Math.floor(e),o=Math.floor(n),i=Math.floor(t),s=e-r,a=n-o,c=t-i,u=s*s*(3-2*s),l=a*a*(3-2*a),f=c*c*(3-2*c),p=(M,h,g)=>M+(h-M)*g,d=p(Zt(r,o,i),Zt(r+1,o,i),u),y=p(Zt(r,o+1,i),Zt(r+1,o+1,i),u),x=p(Zt(r,o,i+1),Zt(r+1,o,i+1),u),m=p(Zt(r,o+1,i+1),Zt(r+1,o+1,i+1),u);return p(p(d,y,l),p(x,m,l),f)}function Kr(e,n,t,r){let o=0,i=.5,s=1,a=0;for(let c=0;c<r;c++)o+=i*Qa(e*s,n*s,t*s),a+=i,i*=.5,s*=2;return o/(a||1)}function Qr(e,n,t,r){return[Kr(e,n,t,r)*2-1,Kr(e+31.7,n+11.3,t+57.1,r)*2-1,Kr(e+73.9,n+92.1,t+13.7,r)*2-1]}function Ja(e){const n=`#version 300 es
|
|
67
67
|
// \u5355\u4F4D quad\uFF08TRIANGLE_STRIP 4 \u9876\u70B9\uFF09\uFF0C\u6309\u5B9E\u4F8B\u7684 size/rot \u5C55\u5F00\u4E3A\u671D\u5C4F\u5E55\u7684\u7CBE\u7075
|
|
68
68
|
layout(location=0) in vec2 a_corner; // -0.5..0.5
|
|
69
69
|
layout(location=1) in vec3 a_pos; // \u5B9E\u4F8B\u4E2D\u5FC3\uFF08\u6295\u5F71\u7A7A\u95F4\u4E16\u754C\u5750\u6807\uFF09
|
|
@@ -138,7 +138,7 @@ void main(){
|
|
|
138
138
|
if (col.a < 0.004) discard;
|
|
139
139
|
}
|
|
140
140
|
fragColor = col;
|
|
141
|
-
}`,r=(u,l)=>{const p=e.createShader(u);if(e.shaderSource(p,l),e.compileShader(p),!e.getShaderParameter(p,e.COMPILE_STATUS))throw new Error("\u7C92\u5B50 shader: "+e.getShaderInfoLog(p));return p},o=e.createProgram();if(e.attachShader(o,r(e.VERTEX_SHADER,n)),e.attachShader(o,r(e.FRAGMENT_SHADER,t)),e.linkProgram(o),!e.getProgramParameter(o,e.LINK_STATUS))throw new Error("\u7C92\u5B50 shader \u94FE\u63A5\u5931\u8D25: "+e.getProgramInfoLog(o));const i=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,i),e.bufferData(e.ARRAY_BUFFER,new Float32Array([-.5,-.5,.5,-.5,-.5,.5,.5,.5]),e.STATIC_DRAW);const s=e.createBuffer(),a=e.createVertexArray();e.bindVertexArray(a),e.bindBuffer(e.ARRAY_BUFFER,i),e.enableVertexAttribArray(0),e.vertexAttribPointer(0,2,e.FLOAT,!1,8,0),e.vertexAttribDivisor(0,0),e.bindBuffer(e.ARRAY_BUFFER,s);const c=56;return e.enableVertexAttribArray(1),e.vertexAttribPointer(1,3,e.FLOAT,!1,c,0),e.vertexAttribDivisor(1,1),e.enableVertexAttribArray(2),e.vertexAttribPointer(2,2,e.FLOAT,!1,c,12),e.vertexAttribDivisor(2,1),e.enableVertexAttribArray(3),e.vertexAttribPointer(3,4,e.FLOAT,!1,c,20),e.vertexAttribDivisor(3,1),e.enableVertexAttribArray(4),e.vertexAttribPointer(4,3,e.FLOAT,!1,c,36),e.vertexAttribDivisor(4,1),e.enableVertexAttribArray(5),e.vertexAttribPointer(5,2,e.FLOAT,!1,c,48),e.vertexAttribDivisor(5,1),e.bindVertexArray(null),{prog:{prog:o,uniTex:e.getUniformLocation(o,"u_tex"),uniNormal:e.getUniformLocation(o,"u_normal"),uniScene:e.getUniformLocation(o,"u_scene"),uniRefract:e.getUniformLocation(o,"u_refract"),uniSampleScene:e.getUniformLocation(o,"u_sampleScene"),uniResolution:e.getUniformLocation(o,"u_resolution"),uniRefractScale:e.getUniformLocation(o,"u_refractScale"),uniMvp:e.getUniformLocation(o,"u_mvp"),uniFrameCount:e.getUniformLocation(o,"u_frameCount"),uniFrames:e.getUniformLocation(o,"u_frames")},quadBuf:i,vbuf:s,vao:a}}function ei(e){const n=e&&e.passes&&e.passes[0]&&e.passes[0].combos;return!!(n&&Number(n.REFRACT)===1)}function ja(e){if(!e||e.length<16)return!1;const n=e.length/4,t=Math.max(1,n/64|0);let r=0;for(let o=0;o<n;o+=t){const i=o*4;if(e[i]<250||e[i+1]<250||e[i+2]<250||e[i+3]<250)return!1;r++}return r>0}function ti(e,n,t,r){let o=Math.abs(Number(e)||0)*(Number(n)||0);const i=Number(t)||0,s=Number(r)||0;return i>0&&(o=Math.max(i,o)),s>0&&(o=Math.min(s,o)),o}function Kr(e,n){return e||n?Math.atan2(n,e)-Math.PI/2:0}function ni(e,n){return e&&e.kind==="ropetrail"?Math.max(1,n||1):1}function ri(e){if(!e||e.kind!=="ropetrail")return 1;const n=Math.round(Number(e.segments)||0);return n>=2?Math.min(32,n):8}function oi(e){if(!e||e.kind!=="ropetrail")return 0;const n=Number(e.length);return Number.isFinite(n)&&n>0?n:.2}function Qr(e){return e.life>0?e.age/e.life:0}class za{constructor(){this.alive=!1,this.x=this.y=this.z=0,this.vx=this.vy=this.vz=0,this.bx=this.by=this.bz=0,this.age=0,this.life=1,this.size=1,this.baseSize=1,this.rot=0,this.rotVel=0,this.r=this.g=this.b=1,this.baseR=this.baseG=this.baseB=1,this.alpha=1,this.baseAlpha=1,this.seed=0,this.frame=0,this.oscPhase=0,this.oscFreq=0,this.oscAmp=0,this.oscAPhase=0,this.oscAFreq=0,this.oscSPhase=0,this.oscSFreq=0,this.turbSpeed=0,this.turbPhase=0,this.trail=null,this.trailClock=0,this.seq=0}}class Va{constructor(n,t,r,o){this.gl=n,this.model=t||{},this.override=r||{},this.layer=o||null,this.syncLayerTransform(),this.maxCount=Math.max(1,Math.min(2e4,ne(this.model.maxcount,100))),this.simTime=0,this.paused=!1,this.texture=null,this.normalTex=null,this.material=null,this.blend="translucent",this.refract=!1,this.refractAmount=.04,this.opacityMul=1,this.lifetimeMul=1,this.visible=!0,this._ready=!1,this._prog=null,this._vbuf=null,this._quadBuf=null,this._vao=null,this._data=null,this._sceneTex=null,this.sequenceMul=Math.max(1,Math.round(ne(this.model.sequencemultiplier,1))),this.animationMode=this.model.animationmode||null,this.texFrames=null,this.frameCount=this.sequenceMul*this.sequenceMul,this.texAspectX=1,this.texAspectY=1,this.controlPoints=(this.model.controlpoint||[]).filter(Boolean).map(i=>({id:ne(i.id,0),lockToPointer:!!i.locktopointer||(ne(i.flags,0)&1)!==0,offset:be(i.offset),x:0,y:0,z:0})),this.pointer=null,this._followParent=null,this._followMode=null,this._followOffset=[0,0,0],this.ropeRenderer=null,this._seq=0,this._ropeOrder=[],this._ov={},this._applyOverride(),this.startTime=Math.max(0,Math.min(30,ne(this.model.starttime,0))),this._warmed=!1,this._compile()}reapplyOverride(){this._applyOverride()}_applyOverride(){this._ov={},this.opacityMul=1,this.lifetimeMul=1,this.maxCount=Math.max(1,Math.min(2e4,ne(this.model.maxcount,100)));const n=this.override||{};for(const t of Object.keys(n)){if(t==="id")continue;const r=n[t],o=r&&typeof r=="object"&&"value"in r?r.value:r;if(t==="count"){const i=ne(this.model.maxcount,100),s=Number(o),a=Number.isFinite(s)?s:1;this.maxCount=Math.max(1,Math.min(2e4,Math.round(i*a))),this._ov.countMul=a}else if(t==="alpha")this.opacityMul=Number(o),Number.isFinite(this.opacityMul)||(this.opacityMul=1);else if(t==="color"||t==="colorn"){const i=be(o);this._ov.color=t==="colorn"?i:[i[0]/255,i[1]/255,i[2]/255]}else t==="size"?this._ov.size=Number(o)||1:t==="rate"?(this._ov.rateMul=Number(o),Number.isFinite(this._ov.rateMul)||(this._ov.rateMul=1)):t==="speed"?this._ov.speed=Number(o)||1:t==="lifetime"?this.lifetimeMul=Number(o)||1:t==="brightness"?this._ov.brightness=Number(o)||1:this._ov[t]=o}this.pool=[];for(let t=0;t<this.maxCount;t++)this.pool.push(new za)}_compile(){const n=this.model;this.emitters=(n.emitter||[]).map(c=>({kind:c.name==="boxrandom"?"box":"sphere",origin:be(c.origin),directions:be(c.directions,[1,1,1]),distanceMin:Jo(c.distancemin),distanceMax:Jo(c.distancemax),sign:c.sign?be(c.sign):null,rate:ne(c.rate,0),audioDriven:c.audioprocessingmode!==void 0,audioBounds:be(c.audioprocessingbounds,[0,1]),fill:c.rate===void 0&&c.instantaneous===void 0&&c.audioprocessingmode===void 0,instantaneous:ne(c.instantaneous,0),speedMin:ne(c.speedmin,0),speedMax:ne(c.speedmax,0),controlPoint:c.controlpoint!==void 0&&c.controlpoint!==null?ne(c.controlpoint,0):0,_burst:!1}));const t=n.initializer||[];this.init={life:null,size:null,color:null,alpha:null,velocity:null,rotation:null,angularVelocity:null,turbulentVelocity:null,mapAround:null};for(const c of t)switch(c.name){case"lifetimerandom":this.init.life={min:ne(c.min,1),max:ne(c.max,1),exp:ne(c.exponent,1)};break;case"sizerandom":this.init.size={min:ne(c.min,1),max:ne(c.max,1),exp:ne(c.exponent,1)};break;case"colorrandom":this.init.color={min:be(c.min,[255,255,255]),max:be(c.max,[255,255,255])};break;case"alpharandom":this.init.alpha={min:ne(c.min,1),max:ne(c.max,1)};break;case"velocityrandom":this.init.velocity={min:be(c.min),max:be(c.max)};break;case"rotationrandom":this.init.rotation={min:be(c.min),max:be(c.max,[0,0,0]),exp:ne(c.exponent,1)};break;case"angularvelocityrandom":this.init.angularVelocity={min:be(c.min),max:be(c.max),exp:ne(c.exponent,1)};break;case"mapsequencearoundcontrolpoint":this.init.mapAround={count:Math.max(1,ne(c.count,1)),bounds:be(c.bounds,[0,1]),speedMin:be(c.speedmin),speedMax:be(c.speedmax,[0,0,0]),cp:ne(c.controlpoint,0)},this._mapAroundSeq=0;break;case"turbulentvelocityrandom":this.init.turbulentVelocity={scale:ne(c.scale,.1),offset:ne(c.offset,0),speedMin:ne(c.speedmin,0),speedMax:ne(c.speedmax,0),phaseMax:ne(c.phasemax,0),timeScale:ne(c.timescale,0),audioMode:ne(c.audioprocessingmode,0),audioBounds:be(c.audioprocessingbounds,[0,1])};break}const r=n.operator||[];this.ops={movement:null,angularMovement:null,alphaFade:null,alphaChange:null,sizeChange:null,colorChange:null,turbulence:[],oscAlpha:null,oscSize:null,oscPos:null,attract:[],vortex:[],remap:[]};for(const c of r)switch(c.name){case"movement":this.ops.movement={gravity:be(c.gravity),drag:ne(c.drag,0)};break;case"angularmovement":this.ops.angularMovement={force:be(c.force),drag:ne(c.drag,0)};break;case"alphafade":this.ops.alphaFade={fadeIn:ne(c.fadeintime,.1),fadeOut:ne(c.fadeouttime,.9)};break;case"alphachange":this.ops.alphaChange={startTime:ne(c.starttime,0),endTime:ne(c.endtime,1),startValue:ne(c.startvalue,1),endValue:ne(c.endvalue,0)};break;case"sizechange":this.ops.sizeChange={startTime:ne(c.starttime,0),endTime:ne(c.endtime,1),startValue:ne(c.startvalue,1),endValue:ne(c.endvalue,1)};break;case"colorchange":this.ops.colorChange={startTime:ne(c.starttime,0),endTime:ne(c.endtime,1),startValue:c.startvalue!==void 0?be(c.startvalue):null,endValue:be(c.endvalue,[1,1,1])};break;case"turbulence":this.ops.turbulence.push({scale:ne(c.scale,.01),speedMin:ne(c.speedmin,0),speedMax:ne(c.speedmax,0),timeScale:ne(c.timescale,1),phaseMin:ne(c.phasemin,0),phaseMax:ne(c.phasemax,0),mask:c.mask!==void 0?be(c.mask,[1,1,1]):[1,1,1]});break;case"oscillatealpha":this.ops.oscAlpha={freqMin:ne(c.frequencymin,ne(c.frequencymax,1)),freqMax:ne(c.frequencymax,1),scaleMin:ne(c.scalemin,0),scaleMax:ne(c.scalemax,1),phaseMax:ne(c.phasemax,gt)};break;case"oscillatesize":this.ops.oscSize={freqMin:ne(c.frequencymin,ne(c.frequencymax,1)),freqMax:ne(c.frequencymax,ne(c.frequencymin,1)),scaleMin:ne(c.scalemin,1),scaleMax:ne(c.scalemax,1),phaseMax:ne(c.phasemax,gt)};break;case"oscillateposition":this.ops.oscPos={freqMin:ne(c.frequencymin,ne(c.frequencymax,.5)),freqMax:ne(c.frequencymax,.5),scaleMin:ne(c.scalemin,0),scaleMax:ne(c.scalemax,1),phaseMin:ne(c.phasemin,0),phaseMax:ne(c.phasemax,gt),mask:c.mask!==void 0?be(c.mask,[1,1,0]):[1,1,0]};break;case"controlpointattract":this.ops.attract.push({cp:ne(c.controlpoint,0),origin:be(c.origin),scale:ne(c.scale,0),threshold:ne(c.threshold,0)});break;case"vortex":this.ops.vortex.push({axis:be(c.axis,[0,0,1]),offset:be(c.offset),distanceInner:ne(c.distanceinner,0),distanceOuter:ne(c.distanceouter,0),speedInner:ne(c.speedinner,0),speedOuter:ne(c.speedouter,0),cp:c.controlpoint!==void 0&&c.controlpoint!==null?ne(c.controlpoint,0):0,audioMode:ne(c.audioprocessingmode,0),audioBounds:be(c.audioprocessingbounds,[0,1])});break;case"remapvalue":this.ops.remap.push({output:c.output||"velocity",rangeMin:be(c.outputrangemin),rangeMax:be(c.outputrangemax),fn:c.transformfunction||"simplexnoise",inputScale:ne(c.transforminputscale,1)});break}const o=this.model.renderer,i=o==null,s=Array.isArray(o)?o:o?[o]:[];this.renderers=s.map(c=>{const u=c&&c.name||"sprite";return{kind:u,length:ne(c&&c.length,u==="spritetrail"?.1:u==="ropetrail"?.2:0),maxLength:ne(c&&c.maxlength,0),minLength:ne(c&&c.minlength,0),subdivision:ne(c&&c.subdivision,1),segments:ne(c&&c.segments,0),orientation:c&&c.orientation||null}}),i&&!this.renderers.length&&(this.renderers=[{kind:"sprite",length:0,maxLength:0,minLength:0,subdivision:1,segments:0,orientation:null}]);const a=this.renderers.find(c=>c.kind==="spritetrail"||c.kind==="ropetrail");if(this.trailCfg=a||null,this.trailSegments=1,this.trailDuration=0,this.trailSampleDt=0,a&&a.kind==="ropetrail"){const c=ri(a);this.trailSegments=c,this.trailDuration=oi(a),this.trailSampleDt=this.trailDuration/Math.max(1,c-1);for(const u of this.pool)u.trail=new Float32Array(c*3),u.trailClock=0}this.ropeRenderer=this.renderers.find(c=>c.kind==="rope")||null}setModel(n){this.model=n,this._compile()}setMaterial(n){this.material=n;const t=n&&n.passes&&n.passes[0];this.blend=t&&t.blending||"translucent",this.refract=ei(n);const r=t&&t.constantshadervalues,o=r&&r.ui_editor_properties_refract_amount,i=Number(o);this.refractAmount=Number.isFinite(i)?Math.min(.35,Math.max(0,i)):.04}setNormalTexture(n){this.normalTex=n||null}setTexture(n){this.texture=n,this._ready=!!n;const t=n&&n.frames,r=Array.isArray(t)?t:t&&t.list&&t.list.length?t.list:null,o=n&&n.width||r&&(t&&t.atlasWidth||r.atlasWidth)||0,i=n&&n.height||r&&(t&&t.atlasHeight||r.atlasHeight)||0;r&&o>0&&i>0?(this.texFrames=r.map(u=>({ou:u.x/o,ov:u.y/i,su:u.width/o,sv:u.height/i})),this.frameCount=this.texFrames.length):(this.texFrames=null,this.frameCount=this.sequenceMul*this.sequenceMul);let s=1,a=1;this.texFrames&&r?(s=r[0].width||1,a=r[0].height||1):n&&n.width>0&&n.height>0&&(s=n.width,a=n.height);const c=Math.max(s,a)||1;this.texAspectX=s/c,this.texAspectY=a/c,this._frameData=void 0}setVisible(n){this.visible=n}syncLayerTransform(){const n=this.layer,t=n&&n.origin?n.origin:[0,0,0],r=n&&n.scale?n.scale:[1,1,1],o=n&&n.angles?n.angles:[0,0,0];this.originX=t[0]||0,this.originY=t[1]||0,this.originZ=t[2]||0,this.scaleX=r[0]===0?1:r[0],this.scaleY=r[1]===0?1:r[1],this.angleZ=(o[2]||0)*Math.PI/180;const i=Math.abs(this.scaleX),s=Math.abs(this.scaleY);this.sysScale=Math.min(i,s)||1,this.spriteStretchX=i/this.sysScale,this.spriteStretchY=s/this.sysScale}setPointer(n,t){const r=n-this.originX,o=t-this.originY,i=Math.cos(-this.angleZ),s=Math.sin(-this.angleZ);this.pointer={x:(r*i-o*s)/(this.scaleX||1),y:(r*s+o*i)/(this.scaleY||1)}}attachFollow(n,t,r){this._followParent=n||null,this._followMode=t==="particle"||t==="origin"?t:null;const o=r||[0,0,0];this._followOffset=[o[0]||0,o[1]||0,o[2]||0],this._syncFollow()}leaderParticle(){const n=this.pool;for(let t=0;t<n.length;t++)if(n[t].alive)return n[t];return null}localToWorld(n,t){const r=n*this.scaleX,o=t*this.scaleY,i=Math.cos(this.angleZ),s=Math.sin(this.angleZ);return[this.originX+r*i-o*s,this.originY+r*s+o*i]}_syncFollow(){const n=this._followParent,t=this._followMode;if(!n||!t)return;const r=this._followOffset;if(t==="particle"){const o=n.leaderParticle();if(!o)return;const i=n.localToWorld(o.x+r[0],o.y+r[1]);this.originX=i[0],this.originY=i[1]}else{const o=n.localToWorld(r[0],r[1]);this.originX=o[0],this.originY=o[1]}}spawn(n){const t=this.pool,r=t.length;let o=null,i=this._cursor||0;for(let p=0;p<r;p++){const f=t[(i+p)%r];if(!f.alive){o=f,this._cursor=(i+p+1)%r;break}}if(!o)return;o.alive=!0,o.age=0,o.seed=Math.random(),o.rot=0,o.rotVel=0,o.vx=o.vy=o.vz=0,o.frame=0,o.seq=this._seq++;const s=n.origin;if(n.kind==="box"){const p=n.distanceMax||[0,0,0],f=n.distanceMin;o.x=s[0]+Ne(-p[0],p[0])+(f?f[0]:0),o.y=s[1]+Ne(-p[1],p[1])+(f?f[1]:0),o.z=s[2]+Ne(-p[2],p[2])+(f?f[2]:0)}else{const p=n.directions,f=n.distanceMin?n.distanceMin[0]:0,d=n.distanceMax?n.distanceMax[0]:0,w=Math.random()*2-1,M=Math.random()*gt,m=Math.sqrt(Math.max(0,1-w*w));let A=m*Math.cos(M),h=m*Math.sin(M),b=w;n.sign&&(n.sign[0]&&(A=Math.abs(A)*Math.sign(n.sign[0])),n.sign[1]&&(h=Math.abs(h)*Math.sign(n.sign[1])),n.sign[2]&&(b=Math.abs(b)*Math.sign(n.sign[2])));const v=Ne(f,d);if(o.x=s[0]+A*v*p[0],o.y=s[1]+h*v*p[1],o.z=s[2]+b*v*p[2],n.speedMax||n.speedMin){const T=Ne(n.speedMin,n.speedMax);o.vx+=A*T,o.vy+=h*T,o.vz+=b*T}}{const p=this._cpPos(n.controlPoint);if(p)o.x+=p[0],o.y+=p[1],o.z+=p[2];else{const f=this.controlPoints.find(d=>d.id===n.controlPoint);if(f&&f.lockToPointer){o.alive=!1;return}}}if(this.init.mapAround){const p=this.init.mapAround,f=this._cpPos(p.cp);if(f){const d=p.count,w=this._mapAroundSeq++,M=d>0?w%d/d:0,A=(p.bounds[0]+(p.bounds[1]-p.bounds[0])*M)*gt,h=n.distanceMin?n.distanceMin[0]:0,b=n.distanceMax?n.distanceMax[0]:0,v=b>0?b:h;o.x=f[0]+Math.cos(A)*v,o.y=f[1]+Math.sin(A)*v,o.z=f[2];const T=Math.random();o.vx+=p.speedMin[0]+(p.speedMax[0]-p.speedMin[0])*T,o.vy+=p.speedMin[1]+(p.speedMax[1]-p.speedMin[1])*T,o.vz+=p.speedMin[2]+(p.speedMax[2]-p.speedMin[2])*T}}const a=this.init,c=this._ov.speed||1,u=this._ov.size||1;if(o.life=a.life?Math.max(.001,Qo(a.life.min,a.life.max,a.life.exp)*this.lifetimeMul):1,o.baseSize=a.size?Qo(a.size.min,a.size.max,a.size.exp)*u:u,o.size=o.baseSize,a.color){const p=a.color.min,f=a.color.max,d=Math.random();o.baseR=(p[0]+(f[0]-p[0])*d)/255,o.baseG=(p[1]+(f[1]-p[1])*d)/255,o.baseB=(p[2]+(f[2]-p[2])*d)/255}else o.baseR=o.baseG=o.baseB=1;if(this._ov.color&&(o.baseR=this._ov.color[0],o.baseG=this._ov.color[1],o.baseB=this._ov.color[2]),o.r=o.baseR,o.g=o.baseG,o.b=o.baseB,o.baseAlpha=(a.alpha?Ne(a.alpha.min,a.alpha.max):1)*this.opacityMul,o.alpha=o.baseAlpha,a.velocity&&(o.vx+=Ne(a.velocity.min[0],a.velocity.max[0])*c,o.vy+=Ne(a.velocity.min[1],a.velocity.max[1])*c,o.vz+=Ne(a.velocity.min[2],a.velocity.max[2])*c),a.turbulentVelocity){const p=a.turbulentVelocity,f=p.audioMode?qr(p.audioBounds,this._audioLevel||0):1,d=Ne(p.speedMin,p.speedMax)*c*f,w=this.simTime*(p.timeScale||0),M=Zr(o.x*p.scale+p.offset,o.y*p.scale+p.offset,w+o.seed*(p.phaseMax||0),3);o.vx+=M[0]*d,o.vy+=M[1]*d,o.vz+=M[2]*d}a.rotation&&(o.rot=Ne(a.rotation.min[2],a.rotation.max[2])),a.angularVelocity&&(o.rotVel=Ne(a.angularVelocity.min[2],a.angularVelocity.max[2]));const l=this.ops;if(l.oscPos&&(o.oscFreq=Ne(l.oscPos.freqMin,l.oscPos.freqMax),o.oscAmp=Ne(l.oscPos.scaleMin,l.oscPos.scaleMax),o.oscPhase=Ne(l.oscPos.phaseMin,l.oscPos.phaseMax)+o.seed*gt),l.oscAlpha&&(o.oscAFreq=Ne(l.oscAlpha.freqMin,l.oscAlpha.freqMax),o.oscAPhase=Math.random()*(l.oscAlpha.phaseMax||gt)),l.oscSize&&(o.oscSFreq=Ne(l.oscSize.freqMin,l.oscSize.freqMax),o.oscSPhase=Math.random()*(l.oscSize.phaseMax||gt)),l.turbulence.length){const p=l.turbulence[0];o.turbSpeed=Ne(p.speedMin,p.speedMax),o.turbPhase=Ne(p.phaseMin,p.phaseMax)}if(this.frameCount>1&&(o.frame=this.animationMode==="randomframe"?Math.floor(Math.random()*this.frameCount):0),o.bx=o.x,o.by=o.y,o.bz=o.z,o.trail){for(let p=0;p<o.trail.length;p+=3)o.trail[p]=o.x,o.trail[p+1]=o.y,o.trail[p+2]=o.z;o.trailClock=0}}updateParticle(n,t){if(n.age+=t,n.age>=n.life){n.alive=!1;return}const r=n.age/n.life,o=this.ops;if(o.movement&&(n.vx+=o.movement.gravity[0]*t,n.vy+=o.movement.gravity[1]*t,n.vz+=o.movement.gravity[2]*t,o.movement.drag>0)){const a=Math.exp(-o.movement.drag*t);n.vx*=a,n.vy*=a,n.vz*=a}o.angularMovement&&(n.rotVel+=(o.angularMovement.force[2]||0)*t,o.angularMovement.drag>0&&(n.rotVel*=Math.exp(-o.angularMovement.drag*t)));for(const a of o.turbulence){const c=a.timeScale||1,u=Zr(n.bx*a.scale,n.by*a.scale,this.simTime*a.scale*c+n.turbPhase,3);n.vx+=u[0]*n.turbSpeed*a.mask[0]*t,n.vy+=u[1]*n.turbSpeed*a.mask[1]*t,n.vz+=u[2]*n.turbSpeed*a.mask[2]*t}for(const a of o.attract){const c=this._cpPos(a.cp);if(!c)continue;const u=c[0]+a.origin[0]-n.x,l=c[1]+a.origin[1]-n.y,p=Math.hypot(u,l);if(p<.001||a.threshold>0&&p>a.threshold)continue;const f=a.threshold>0?1-p/a.threshold:1,d=a.scale*f*t/Math.max(1,p);n.vx+=u*d,n.vy+=l*d}for(const a of o.vortex){const c=this._cpPos(a.cp)||[0,0,0],u=n.x-(c[0]+a.offset[0]),l=n.y-(c[1]+a.offset[1]),p=Math.hypot(u,l);if(p<.001)continue;const f=a.distanceOuter-a.distanceInner,d=f>0?Math.min(1,Math.max(0,(p-a.distanceInner)/f)):0,w=a.audioMode?qr(a.audioBounds,this._audioLevel||0):1,M=a.speedInner+(a.speedOuter-a.speedInner)*d;n.vx+=-l/p*M*t*w,n.vy+=u/p*M*t*w}for(const a of o.remap){const c=a.inputScale||1,u=Zr(n.bx*.01*c,n.by*.01*c,this.simTime*.1,a.fn==="fbmnoise"?4:2);if(a.output==="velocity")for(let l=0;l<3;l++){const p=(u[l]+1)/2,f=a.rangeMin[l]+(a.rangeMax[l]-a.rangeMin[l])*p;l===0?n.vx=f:l===1?n.vy=f:n.vz=f}else if(a.output==="speed"){const l=(u[0]+1)/2,p=a.rangeMin[0]+(a.rangeMax[0]-a.rangeMin[0])*l,f=Math.hypot(n.vx,n.vy)||1;n.vx=n.vx/f*p,n.vy=n.vy/f*p}}if(n.bx+=n.vx*t,n.by+=n.vy*t,n.bz+=n.vz*t,n.rot+=n.rotVel*t,n.x=n.bx,n.y=n.by,n.z=n.bz,o.oscPos){const a=this.simTime*n.oscFreq*gt+n.oscPhase,c=o.oscPos.mask;n.x+=Math.sin(a)*n.oscAmp*c[0],n.y+=Math.cos(a)*n.oscAmp*c[1],n.z+=Math.sin(a*.7)*n.oscAmp*c[2]}let i=n.baseSize;if(o.sizeChange){const a=o.sizeChange,c=a.endTime-a.startTime,u=c>0?Math.min(1,Math.max(0,(r-a.startTime)/c)):r>=a.startTime?1:0;i*=a.startValue+(a.endValue-a.startValue)*u}if(o.oscSize){const a=this.simTime*n.oscSFreq*gt+n.oscSPhase,c=o.oscSize,u=(c.scaleMin+c.scaleMax)/2,l=(c.scaleMax-c.scaleMin)/2;i*=u+Math.sin(a)*l}if(n.size=i,o.colorChange){const a=o.colorChange,c=a.endTime-a.startTime,u=c>0?Math.min(1,Math.max(0,(r-a.startTime)/c)):r>=a.startTime?1:0,l=a.startValue||[n.baseR,n.baseG,n.baseB];n.r=l[0]+(a.endValue[0]-l[0])*u,n.g=l[1]+(a.endValue[1]-l[1])*u,n.b=l[2]+(a.endValue[2]-l[2])*u}let s=n.baseAlpha;if(o.alphaFade){const a=o.alphaFade.fadeIn,c=o.alphaFade.fadeOut;a>0&&r<a&&(s*=r/a),c<1&&r>c&&(s*=Math.max(0,(1-r)/(1-c)))}else o.alphaChange||(r<.1?s*=r/.1:r>.85&&(s*=(1-r)/.15));if(o.alphaChange){const a=o.alphaChange,c=a.endTime-a.startTime,u=c>0?Math.min(1,Math.max(0,(r-a.startTime)/c)):r>=a.startTime?1:0;s*=a.startValue+(a.endValue-a.startValue)*u}if(o.oscAlpha){const a=this.simTime*n.oscAFreq*gt+n.oscAPhase,c=o.oscAlpha,u=(c.scaleMin+c.scaleMax)/2,l=(c.scaleMax-c.scaleMin)/2;s*=u+Math.sin(a)*l}if(n.alpha=Math.max(0,s),this.frameCount>1&&this.animationMode!=="randomframe"&&(n.frame=Math.min(this.frameCount-1,Math.floor(r*this.frameCount))),n.trail){const a=n.trail,c=this.trailSampleDt;if(c>0){n.trailClock=(n.trailClock||0)+t;let u=0;const l=this.trailSegments||8;for(;n.trailClock>=c&&u<l;){n.trailClock-=c,u++;for(let p=a.length-3;p>=3;p-=3)a[p]=a[p-3],a[p+1]=a[p-2],a[p+2]=a[p-1]}}a[0]=n.x,a[1]=n.y,a[2]=n.z}}_cpPos(n){const t=this.controlPoints.find(r=>r.id===n);return t?t.lockToPointer?this.pointer?[this.pointer.x+t.offset[0],this.pointer.y+t.offset[1],t.offset[2]]:null:t.offset:null}advance(n,t){if(!(this.paused||!this.visible)){if(this._syncFollow(),!this._warmed&&(this._warmed=!0,this.startTime>0)){const r=.03333333333333333,o=Math.min(900,Math.round(this.startTime/r));for(let i=0;i<o;i++)this._step(r)}this._step(n,t)}}_step(n,t){this.simTime+=n;const r=t&&Number.isFinite(t.level)?Math.max(0,Math.min(1,t.level)):0;this._audioLevel=r;for(const i of this.emitters){if(i.instantaneous>0&&!i._burst){i._burst=!0;for(let c=0;c<Math.min(i.instantaneous,this.maxCount);c++)this.spawn(i)}if(i.fill){const u=Math.min(this.maxCount,2048);let l=0;for(let f=0;f<this.pool.length;f++)this.pool[f].alive&&l++;let p=Math.min(u-l,512);for(;p-- >0;)this.spawn(i);continue}if(i.audioDriven){const c=qr(i.audioBounds,r);if(i.rate>0){const u=i.rate*c*(this._ov.rateMul!==void 0?this._ov.rateMul:1)*(this._ov.countMul!==void 0?this._ov.countMul:1);if(!(u>0))continue;i._accum=(i._accum||0)+u*n;let l=Math.floor(i._accum);if(l>0){i._accum-=l,l>this.maxCount&&(l=this.maxCount);for(let p=0;p<l;p++)this.spawn(i)}}else{const l=Math.round(Math.min(this.maxCount,2048)*c);let p=0;for(let d=0;d<this.pool.length;d++)this.pool[d].alive&&p++;let f=Math.min(l-p,256);for(;f-- >0;)this.spawn(i)}continue}const s=i.rate*(this._ov.rateMul!==void 0?this._ov.rateMul:1)*(this._ov.countMul!==void 0?this._ov.countMul:1);if(!(s>0))continue;i._accum=(i._accum||0)+s*n;let a=Math.floor(i._accum);if(a>0){i._accum-=a,a>this.maxCount&&(a=this.maxCount);for(let c=0;c<a;c++)this.spawn(i)}}const o=this.pool;for(let i=0;i<o.length;i++)o[i].alive&&this.updateParticle(o[i],n)}render(n,t,r,o,i){if(!this._ready||!this.visible||!this.renderers.length)return;const s=this.gl;this._prog||this._buildProgram(s);const a=this.trailCfg&&this.trailCfg.kind==="ropetrail"?this.trailCfg:null,c=this.trailCfg&&this.trailCfg.kind==="spritetrail"?this.trailCfg:null,u=this.ropeRenderer,l=ni(this.trailCfg,this.trailSegments),p=14,f=this.pool;let d=null;if(u){d=this._ropeOrder,d.length=0;for(let te=0;te<f.length;te++)f[te].alive&&d.push(f[te]);d.sort((te,X)=>te.seq-X.seq)}let w=0;if(d)w=d.length;else for(let te=0;te<f.length;te++)f[te].alive&&w++;if(w===0||u&&w<2)return;const M=u?w-1:w*l,m=M*p;(!this._data||this._data.length<m)&&(this._data=new Float32Array(Math.max(m,1024)));const A=this._data;let h=0;const b=this._ov.brightness||1,v=this.sysScale,T=this.spriteStretchX*(this.texAspectX||1),_=this.spriteStretchY*(this.texAspectY||1),F=Math.cos(this.angleZ),R=Math.sin(this.angleZ),k=this.originX,U=this.originY,V=this.scaleX,q=this.scaleY,W=(te,X)=>{const J=te*V,de=X*q;return[k+J*F-de*R,i-(U+J*R+de*F)]};if(u)for(let te=0;te+1<w;te++){const X=d[te],J=d[te+1],de=W(X.x,X.y),Se=W(J.x,J.y),Ae=Se[0]-de[0],De=Se[1]-de[1],Qe=Math.hypot(Ae,De),Ve=(Math.abs(X.size)+Math.abs(J.size))*.5*v;Ve>0&&(A[h++]=(de[0]+Se[0])*.5,A[h++]=(de[1]+Se[1])*.5,A[h++]=0,A[h++]=Ve,A[h++]=Math.atan2(-Ae,De),A[h++]=(X.r+J.r)*.5*b,A[h++]=(X.g+J.g)*.5*b,A[h++]=(X.b+J.b)*.5*b,A[h++]=(X.alpha+J.alpha)*.5,A[h++]=1,A[h++]=Qe/Ve,A[h++]=0,A[h++]=Qr(X),A[h++]=Qr(J))}for(let te=0;te<f.length&&!u;te++){const X=f[te];if(X.alive)for(let J=0;J<l;J++){let de=X.x,Se=X.y,Ae=1,De=1,Qe=X.rot,Ve=T,Ee=_,Re,le;if(a&&X.trail){de=X.trail[J*3],Se=X.trail[J*3+1];const Pe=l>1?J/(l-1):0;Ae=1-Pe,De=1-Pe*.55;let Be=0,Me=0;J+1<l?(Be=X.trail[J*3]-X.trail[(J+1)*3],Me=X.trail[J*3+1]-X.trail[(J+1)*3+1]):J>0?(Be=X.trail[(J-1)*3]-X.trail[J*3],Me=X.trail[(J-1)*3+1]-X.trail[J*3+1]):(Be=X.vx,Me=X.vy);const _e=W(de,Se),Ie=W(de-Be,Se-Me),We=_e[0]-Ie[0],ft=_e[1]-Ie[1],me=Math.hypot(We,ft),Tt=Math.max(.001,Math.abs(X.size)*v*De);me>.001?(Qe=Kr(We,ft),Re=(_e[0]+Ie[0])*.5,le=(_e[1]+Ie[1])*.5,Ee=Math.max(_,me/Tt)):(Re=_e[0],le=_e[1])}else{const Pe=W(de,Se);Re=Pe[0],le=Pe[1]}if(c){const Pe=W(X.x,X.y);Re=Pe[0],le=Pe[1];const Be=W(X.x+X.vx,X.y+X.vy);Qe=Kr(Be[0]-Pe[0],Be[1]-Pe[1]);const Me=ti(Math.hypot(X.vx,X.vy),c.length,c.minLength,c.maxLength);Ee=_*Me}A[h++]=Re,A[h++]=le,A[h++]=0,A[h++]=Math.abs(X.size)*v*De,A[h++]=Qe,A[h++]=X.r*b,A[h++]=X.g*b,A[h++]=X.b*b,A[h++]=X.alpha*Ae,A[h++]=Ve,A[h++]=Ee,A[h++]=X.frame,A[h++]=0,A[h++]=1}}const Z=this._prog;s.useProgram(Z.prog),s.bindVertexArray(this._vao),s.bindBuffer(s.ARRAY_BUFFER,this._vbuf),s.bufferData(s.ARRAY_BUFFER,A.subarray(0,h),s.DYNAMIC_DRAW),s.activeTexture(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,this.texture.glTex),s.uniform1i(Z.uniTex,0),s.uniformMatrix4fv(Z.uniMvp,!1,n);const K=this.refract&&this.normalTex&&this.normalTex.glTex;if(Z.uniRefract&&s.uniform1i(Z.uniRefract,K?1:0),K){s.activeTexture(s.TEXTURE1),s.bindTexture(s.TEXTURE_2D,this.normalTex.glTex),Z.uniNormal&&s.uniform1i(Z.uniNormal,1);const te=this.blend!=="additive";if(Z.uniSampleScene&&s.uniform1i(Z.uniSampleScene,te?1:0),te){const X=s.drawingBufferWidth||t,J=s.drawingBufferHeight||r;s.bindFramebuffer(s.FRAMEBUFFER,null),s.activeTexture(s.TEXTURE2),this._sceneTex?s.bindTexture(s.TEXTURE_2D,this._sceneTex):(this._sceneTex=s.createTexture(),s.bindTexture(s.TEXTURE_2D,this._sceneTex),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE)),s.copyTexImage2D(s.TEXTURE_2D,0,s.RGB8,0,0,X,J,0),Z.uniScene&&s.uniform1i(Z.uniScene,2),Z.uniResolution&&s.uniform2f(Z.uniResolution,X,J),Z.uniRefractScale&&s.uniform1f(Z.uniRefractScale,this.refractAmount||.04)}else s.activeTexture(s.TEXTURE2),s.bindTexture(s.TEXTURE_2D,this.texture.glTex),Z.uniScene&&s.uniform1i(Z.uniScene,2)}else Z.uniNormal&&(s.activeTexture(s.TEXTURE1),s.bindTexture(s.TEXTURE_2D,this.texture.glTex),s.uniform1i(Z.uniNormal,1),s.activeTexture(s.TEXTURE2),s.bindTexture(s.TEXTURE_2D,this.texture.glTex),Z.uniScene&&s.uniform1i(Z.uniScene,2),Z.uniSampleScene&&s.uniform1i(Z.uniSampleScene,0));const re=this._frameUniformData();re?(s.uniform1i(Z.uniFrameCount,re.count),s.uniform4fv(Z.uniFrames,re.arr)):s.uniform1i(Z.uniFrameCount,0),s.enable(s.BLEND),this.blend==="additive"?s.blendFunc(s.SRC_ALPHA,s.ONE):s.blendFunc(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA),s.depthMask(!1),s.drawArraysInstanced(s.TRIANGLE_STRIP,0,4,M),s.depthMask(!0),s.disable(s.BLEND),s.bindVertexArray(null)}_buildProgram(n){const t=$a(n);this._quadBuf=t.quadBuf,this._vbuf=t.vbuf,this._vao=t.vao,this._prog=t.prog}_frameUniformData(){if(this._frameData!==void 0)return this._frameData;let n=this.texFrames;if(!n&&this.sequenceMul>1){const o=this.sequenceMul;n=[];for(let i=0;i<o;i++)for(let s=0;s<o;s++)n.push({ou:s/o,ov:i/o,su:1/o,sv:1/o})}if(!n||n.length===0)return this._frameData=null,null;const t=Math.min(n.length,128),r=new Float32Array(t*4);for(let o=0;o<t;o++)r[o*4]=n[o].ou,r[o*4+1]=n[o].ov,r[o*4+2]=n[o].su,r[o*4+3]=n[o].sv;return this._frameData={count:t,arr:r},this._frameData}liveCount(){let n=0;for(const t of this.pool)t.alive&&n++;return n}dispose(){this.paused=!0;const n=this.gl;if(n){try{this._vbuf&&n.deleteBuffer(this._vbuf),this._quadBuf&&n.deleteBuffer(this._quadBuf),this._vao&&n.deleteVertexArray(this._vao),this._prog&&this._prog.prog&&n.deleteProgram(this._prog.prog),this._sceneTex&&n.deleteTexture(this._sceneTex)}catch{}this._prog=null,this._vbuf=null,this._quadBuf=null,this._vao=null,this._data=null,this._sceneTex=null}}}const Wa=Object.freeze(Object.defineProperty({__proto__:null,ParticleSystem:Va,particleInstanceSegs:ni,particlePassRefract:ei,rgbaIsBlankWhite:ja,ropeParticleV:Qr,ropeTrailDuration:oi,ropeTrailHistoryCount:ri,spriteTrailLengthFactor:ti,spriteTrailRotation:Kr},Symbol.toStringTag,{value:"Module"})),Nn=new Map,Jr=new Map;let dr=null;function Ha(e,n){const t=String(e);Jr.set(t,n),Nn.delete(t)}function Xa(e){dr=typeof e=="function"?e:null}function Ga(){Jr.clear(),dr=null,Nn.clear()}function qa(){return Object.keys(On)}function Te(e,n,t){e[n]=255,e[n+1]=255,e[n+2]=255,e[n+3]=Math.round(Math.min(1,Math.max(0,t))*255)}function Un(e,n){const{width:t,height:r,rgba:o}=e,i=Math.max(2,Math.round(Math.min(t,r)*.04));for(let s=0;s<r;s++)for(let a=0;a<t;a++){const c=Math.min(a,s,t-1-a,r-1-s);if(c>=i)continue;const u=c/i,l=(s*t+a)*4+3;o[l]=Math.round(o[l]*u)}if(n>0){let s=0;const a=t*r;for(let u=0;u<a;u++)s+=o[u*4+3];const c=s/a/255;if(c>n&&c>0){const u=n/c;for(let l=0;l<a;l++)o[l*4+3]=Math.round(o[l*4+3]*u)}}return e}function pr(e){let n=e>>>0;return function(){n|=0,n=n+1831565813|0;let t=Math.imul(n^n>>>15,1|n);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}const wn=e=>e*e*(3-2*e),ii=e=>e*e*e*(e*(e*6-15)+10),eo=(e,n,t)=>e+(n-e)*t,ae=(e,n)=>Math.exp(-(e*e)/(n*n));function rn(e,n,t,r){const o=Math.min(e,n,t-1-e,t-1-n);return o>=r?1:o/r}function Dn(e,n){const t=new Uint8Array(e*e*4),r=e/2;for(let o=0;o<e;o++)for(let i=0;i<e;i++){const s=Math.hypot((i+.5-r)/r,(o+.5-r)/r);let a=0;for(let c=0;c<n.length;c++)a+=n[c].w*ae(s,n[c].r);Te(t,(o*e+i)*4,a)}return{width:e,height:e,rgba:t}}function Ft(e,n,t){return Dn(e,[n,t])}function kt(e,n,t,r,o){const i=new Uint8Array(e*e*4),s=e/2,a=Math.max(2,Math.round(e*.03));for(let c=0;c<e;c++)for(let u=0;u<e;u++){const l=(u+.5-s)/s,p=(c+.5-s)/s,f=Math.hypot(l,p),d=Math.atan2(p,l),w=Math.pow(.5+.5*Math.cos(n*d),r);let M=ae(f,o)+w*ae(f,t);M*=rn(u,c,e,a),Te(i,(c*e+u)*4,M)}return{width:e,height:e,rgba:i}}function _t(e,n,t,r,o){const s=new Uint8Array(e*n*4);for(let a=0;a<n;a++){const c=a/(n-1),u=r?ae(c-.5,.27):wn(Math.min(1,c/.06))*Math.pow(1-c,1.35);for(let l=0;l<e;l++){const p=l/(e-1)*2-1,f=ae(p,t);Te(s,(a*e+l)*4,f*f*f*u*.55)}}return{width:e,height:n,rgba:s}}const Bn=4;function si(e,n,t,r,o){const i=o===void 0?.85:o,s=new Uint8Array(e*n*4),a=n/Bn,c=pr(335009),u=Math.tan(t*Math.PI/180),l=e/2;for(let p=0;p<Bn;p++){const f=i*(.8+c()*.35),d=r*(.85+c()*.5),w=(c()-.5)*e*.12;for(let M=0;M<a;M++){const m=M/(a-1),A=l+w+(a-1)*u/2-(a-1)*u*m,h=ae(m-.5,.27);for(let b=0;b<e;b++){const v=Math.abs(b+.5-A),_=Math.exp(-(v*v)/(d*d))*h*f;_<.004||Te(s,((p*a+M)*e+b)*4,_)}}}return{width:e,height:n,rgba:s}}function Ya(e){if(e==="particle/nature/rain1"||e==="particle/nature/rain2"){const n=[];for(let t=0;t<Bn;t++)n.push({ou:0,ov:t/Bn,su:1,sv:1/Bn});return n}return null}function to(e,n,t){const r=new Uint8Array(e*e*4),o=e/2;for(let i=0;i<e;i++)for(let s=0;s<e;s++){const a=Math.hypot((s-o)/o,(i-o)/o);Te(r,(i*e+s)*4,ae(a-n,t*.6)*Math.max(0,1-a))}return{width:e,height:e,rgba:r}}function ai(e,n){const t={1:{r:.78,t:.048,inner:.06,hi:[[-.28,-.32,.22,.9],[.32,.36,.12,.28]]},2:{r:.7,t:.07,inner:.14,hi:[[-.2,-.28,.3,.72],[.38,.2,.14,.4]]},3:{r:.84,t:.036,inner:.04,hi:[[-.34,-.18,.16,.95],[.2,.42,.1,.22],[.04,-.08,.07,.18]]}},r=t[n]||t[1],o=new Uint8Array(e*e*4),i=e/2;for(let s=0;s<e;s++)for(let a=0;a<e;a++){const c=(a+.5-i)/i,u=(s+.5-i)/i,l=Math.hypot(c,u);let p=ae(l-r.r,r.t*.85)*Math.max(0,1.05-l);l<r.r&&(p+=r.inner*ae(l,.5));for(let f=0;f<r.hi.length;f++){const d=r.hi[f];p+=d[3]*ae(Math.hypot(c-d[0],u-d[1]),d[2])}Te(o,(s*e+a)*4,p)}return Un({width:e,height:e,rgba:o},.05)}function In(e,n){const t=e>>1,r=new Uint8Array(e*e*4),o=n===1?[1,2,1,3]:n===2?[2,1,2,3]:[3,1,2,3];for(let i=0;i<2;i++)for(let s=0;s<2;s++){const a=ai(t,o[i*2+s]);for(let c=0;c<t;c++){const u=(i*t+c)*e,l=c*t;for(let p=0;p<t;p++){const f=(u+s*t+p)*4,d=(l+p)*4;r[f]=a.rgba[d],r[f+1]=a.rgba[d+1],r[f+2]=a.rgba[d+2],r[f+3]=a.rgba[d+3]}}}return{width:e,height:e,rgba:r}}function ci(e){const n=new Uint8Array(e*e*4),t=e/2,r=[[.32,0],[1.1,.35],[2.2,-.3],[-.7,.2]];for(let o=0;o<e;o++)for(let i=0;i<e;i++){const s=i>=t?1:0,a=o>=t?1:0,c=a*2+s,u=s*t+t/2,l=a*t+t/2,p=r[c][0],f=r[c][1],d=(i+.5-u)/(t*.4),w=(o+.5-l)/(t*.4),M=Math.cos(p),m=Math.sin(p);let A=d*M+w*m;const h=-d*m+w*M;A+=f*h*.18;const b=1-Math.max(0,h)*.42,v=Math.hypot(A/(.52*b),h/.92);let T=v>=1.12?0:ae(v,.48);T=Math.min(1,T+ae(A,.07)*ae(h,.65)*T*.4),Te(n,(o*e+i)*4,T)}return Un({width:e,height:e,rgba:n},.11)}function Xe(e,n){const t={0:{rx:.36,ry:.92,wave:0,folds:0},1:{rx:.48,ry:.86,wave:.05,folds:7},2:{rx:.4,ry:.88,wave:.08,folds:5},3:{rx:.58,ry:.72,wave:0,folds:0},5:{rx:.44,ry:.8,wave:.12,folds:9},6:{rx:.52,ry:.78,wave:.07,folds:4},7:{rx:.5,ry:.9,wave:.16,folds:3},8:{rx:.38,ry:.94,wave:.2,folds:2}},r=t[n]||t[0],o=new Uint8Array(e*e*4),i=e/2;for(let s=0;s<e;s++)for(let a=0;a<e;a++){const c=(a+.5-i)/i,u=(s+.5-i)/i,l=Math.atan2(c,u),p=r.wave?1+r.wave*Math.sin(l*r.folds):1,f=Math.hypot(c/(r.rx*p),u/r.ry);let d=f>=1.12?0:ae(f,.5);d>0&&(d=Math.min(1,d+ae(c,.028)*ae(u,.72)*.28)),Te(o,(s*e+a)*4,d)}return Un({width:e,height:e,rgba:o},.11)}function bt(e,n){const t=e.width,r=e.height,o=e.rgba,i=n??2.8,s=new Uint8Array(t*r*4),a=(c,u)=>{const l=c<0?0:c>=t?t-1:c,p=u<0?0:u>=r?r-1:u;return o[(p*t+l)*4+3]/255};for(let c=0;c<r;c++)for(let u=0;u<t;u++){const l=(a(u-1,c)-a(u+1,c))*i,p=(a(u,c-1)-a(u,c+1))*i,f=1/Math.hypot(l,p,1),d=(c*t+u)*4;s[d]=Math.round((l*f*.5+.5)*255),s[d+1]=Math.round((p*f*.5+.5)*255),s[d+2]=Math.round((f*.5+.5)*255),s[d+3]=255}return{width:t,height:r,rgba:s}}function li(e){const n=new Uint8Array(e*e*4),t=e/2;for(let r=0;r<e;r++)for(let o=0;o<e;o++){const i=(o+.5-t)/t,s=(r+.5-t)/t,a=Math.hypot(i,s),c=a>=1?0:Math.sqrt(Math.max(0,1-a*a)),u=ae(a-.62,.11)*.55;Te(n,(r*e+o)*4,Math.min(1,c*.85+u))}return{width:e,height:e,rgba:n}}function Za(e){const n=new Uint8Array(e*e*4),t=e/2;for(let r=0;r<e;r++)for(let o=0;o<e;o++){const i=(o+.5-t)/t,s=(r+.5-t)/t,a=Math.hypot(i,s),c=Math.atan2(s,i),u=ae(a,.38)*(.55+.45*Math.cos(c*3+a*6));Te(n,(r*e+o)*4,u)}return{width:e,height:e,rgba:n}}function ui(e){const n=new Uint8Array(e*e*4),t=e/2,r=Math.max(2,Math.round(e*.04));for(let o=0;o<e;o++)for(let i=0;i<e;i++){const s=(i+.5-t)/t,a=(o+.5-t)/t,c=Math.hypot(s,a),u=Math.atan2(a,s),l=wn(Math.max(0,Math.cos(u)*.55+.45)),p=ae(c-.68,.07)*l+.35*ae(c-.78,.12)*ae(u-.9,.55);Te(n,(o*e+i)*4,Math.min(1,p)*rn(i,o,e,r))}return{width:e,height:e,rgba:n}}function Ka(e){if(!e||e.length<16)return!1;const n=e.length/4,t=Math.max(1,n/48|0);let r=0;for(let o=0;o<n;o+=t){const i=o*4;if(e[i]<240||e[i+1]<240||e[i+2]<240)return!1;r++}return r>0}function Qa(e){return!e||!e.rgba?e:Ka(e.rgba)?bt(e,2.8):e}const Ja={"particle/drop":"particle/drop_normal","particle/water/rain_drops_sheet":"particle/water/rain_drops_sheet_normal","particle/bubbles/bubble1":"particle/bubbles/bubble1normal","particle/bubbles/bubble2":"particle/bubbles/bubble2_normal","particle/sharp_halo":"particle/sharp_halo_normal","particle/misc/wave":"particle/normal_splash","particle/halo":"particle/sharp_halo_normal"};function ec(e){if(!e)return null;const n=String(e);return/normal/i.test(n)?n:Ja[n]||n+"_normal"}function tc(e){const n=String(e);return/(^|\/)normal_/.test(n)?null:/_normal$/i.test(n)?n.replace(/_normal$/i,""):/normal$/i.test(n)?n.replace(/normal$/i,""):null}function nc(e){if(On[e])return On[e]();const n=String(e).toLowerCase();return/normal/.test(n)?Ft(64,{r:.18,w:1},{r:.4,w:.2}):yi(e)()}function fi(e,n,t){const r=pr(t*7919+17);let o=e;const i=[];for(let c=0;c<n;c++){const u=o*o,l=new Float32Array(u*2);for(let p=0;p<u;p++){const f=r()*Math.PI*2;l[p*2]=Math.cos(f),l[p*2+1]=Math.sin(f)}i.push({f:o,g:l,ox:c*7.31,oy:c*3.17}),o*=2}const s=(c,u,l,p,f)=>{const d=c.f,w=(u%d+d)%d,m=((l%d+d)%d*d+w)*2;return c.g[m]*p+c.g[m+1]*f},a=(c,u,l)=>{const p=(u+c.ox)*c.f,f=(l+c.oy)*c.f,d=Math.floor(p),w=Math.floor(f),M=p-d,m=f-w,A=ii(M),h=ii(m);return eo(eo(s(c,d,w,M,m),s(c,d+1,w,M-1,m),A),eo(s(c,d,w+1,M,m-1),s(c,d+1,w+1,M-1,m-1),A),h)};return function(u,l,p){const f=p==null?i.length:Math.min(p,i.length);let d=1,w=0,M=0;for(let m=0;m<f;m++)w+=(a(i[m],u,l)*.5+.5)*d,M+=d,d*=.55;return w/M}}function di(e,n,t){const{width:r,height:o,rgba:i}=e;if(r===n&&o===t)return e;const s=new Uint8Array(n*t*4);for(let a=0;a<t;a++){const c=(a+.5)/t*o-.5,u=Math.max(0,Math.min(o-1,Math.floor(c))),l=Math.max(0,Math.min(o-1,u+1)),p=c-Math.floor(c);for(let f=0;f<n;f++){const d=(f+.5)/n*r-.5,w=Math.max(0,Math.min(r-1,Math.floor(d))),M=Math.max(0,Math.min(r-1,w+1)),m=d-Math.floor(d),A=i[(u*r+w)*4+3],h=i[(u*r+M)*4+3],b=i[(l*r+w)*4+3],v=i[(l*r+M)*4+3],T=(A*(1-m)+h*m)*(1-p)+(b*(1-m)+v*m)*p;Te(s,(a*n+f)*4,T/255)}}return{width:n,height:t,rgba:s}}function Wt(e,n,t,r,o,i,s){const a=i===void 0?1:i,c=s===void 0?200:s,u=256,l=fi(n,t,r),p=new Uint8Array(u*u*4),f=u/2,d=u*u,w=new Float32Array(d);let M=1,m=0;for(let v=0;v<d;v++){const T=v%u,_=v/u|0,F=(T+.5)/u,R=(_+.5)/u,k=l(F+5.2,R+1.3,2)-.5,U=l(F+9.7,R+8.1,2)-.5,V=w[v]=l(F+k*.45,R+U*.45);V<M&&(M=V),V>m&&(m=V)}const A=m-M||1;for(let v=0;v<u;v++)for(let T=0;T<u;T++){const _=(w[v*u+T]-M)/A,F=Math.hypot((T+.5-f)/f,(v+.5-f)/f),R=Math.pow(Math.max(0,1-F),a);let k=Math.max(0,(_-(1-o))/(o||1));k=wn(Math.min(1,k))*R,Te(p,(v*u+T)*4,k)}let h=0;for(let v=0;v<d;v++)h=Math.max(h,p[v*4+3]);if(h>0&&h<c){const v=c/h;for(let T=0;T<d;T++)p[T*4+3]=Math.round(Math.min(255,p[T*4+3]*v))}const b={width:u,height:u,rgba:p};return u===e?b:di(b,e,e)}function no(e,n){const t=e,r=fi(3,5,n??23),o=new Uint8Array(t*t*4),i=t*t,s=new Float32Array(i);let a=1,c=0;for(let f=0;f<i;f++){const d=f%t,w=f/t|0,M=(d+.5)/t,m=(w+.5)/t,A=r(M+2.1,m+4.7,2)-.5,h=r(M+6.3,m+1.9,2)-.5,b=s[f]=r(M+A*.28,m+h*.55);b<a&&(a=b),b>c&&(c=b)}const u=c-a||1;for(let f=0;f<t;f++)for(let d=0;d<t;d++){const w=(f+.5)/t,M=(d+.5)/t*2-1,m=.1+.52*Math.pow(w,1.25),A=(s[f*t+d]-a)/u,h=ae(M/(m||.01),.55)*ae(w-.58,.42);let b=wn(Math.min(1,Math.max(0,(A-.18)/.72)))*h;b*=w<.06?w/.06:1,Te(o,(f*t+d)*4,b)}let l=0;for(let f=0;f<i;f++)l=Math.max(l,o[f*4+3]);if(l>0&&l<220){const f=220/l;for(let d=0;d<i;d++)o[d*4+3]=Math.round(Math.min(255,o[d*4+3]*f))}const p=Un({width:t,height:t,rgba:o},.08);return t===e?p:di(p,e,e)}function ro(e,n,t,r){const o=new Uint8Array(e*n*4),i=e/t,s=n/r;for(let a=0;a<n;a++)for(let c=0;c<e;c++){const u=Math.floor(c/i),l=Math.floor(a/s),p=(c+.5-u*i)/i*2-1,f=(a+.5-l*s)/s*2-1,d=1-Math.max(0,f)*.45,w=Math.hypot(p/(.52*d),f/.8),M=w>=1.12?0:ae(w,.48);Te(o,(a*e+c)*4,M)}return{width:e,height:n,rgba:o}}function pi(e){const n=new Uint8Array(e*e*4),t=pr(7),r=[];for(let o=0;o<11;o++)r.push({x:.14+t()*.72,y:.14+t()*.72,rx:.025+t()*.03,ry:.018+t()*.024,rot:t()*Math.PI});for(let o=0;o<e;o++)for(let i=0;i<e;i++){const s=(i+.5)/e,a=(o+.5)/e;let c=0;for(const u of r){const l=s-u.x,p=a-u.y,f=Math.cos(u.rot),d=Math.sin(u.rot),w=(l*f+p*d)/u.rx,M=(-l*d+p*f)/u.ry,m=ae(Math.hypot(w,M),.55);m>c&&(c=m)}Te(n,(o*e+i)*4,c)}return{width:e,height:e,rgba:n}}function hr(e,n){const t=n??19,r=pr(t),o=f=>Math.min(.86,Math.max(.14,f)),i=5+t%4,s=[];let a=o(.5+(r()-.5)*.16);for(let f=0;f<=i;f++){const d=.06+f/i*.86;f>0&&(a=o(a+(r()-.5)*.32)),s.push([a,d])}const c=[];for(let f=0;f<s.length-1;f++)c.push([s[f],s[f+1],1]);const u=1+t%2;for(let f=0;f<u;f++){const d=1+(t+f*3)%Math.max(1,s.length-2),w=s[d],M=[w];let m=w[0],A=w[1];const h=2+t%2;for(let b=0;b<h;b++)m=o(m+(r()-.5)*.36),A=Math.min(.92,A+.1+r()*.08),M.push([m,A]);for(let b=0;b<M.length-1;b++)c.push([M[b],M[b+1],.45+f*.1])}const l=new Uint8Array(e*e*4),p=Math.max(2,Math.round(e*.04));for(let f=0;f<e;f++)for(let d=0;d<e;d++){const w=(d+.5)/e,M=(f+.5)/e;let m=9,A=0;for(const[b,v,T]of c){const _=v[0]-b[0],F=v[1]-b[1],R=_*_+F*F||1e-8,k=Math.max(0,Math.min(1,((w-b[0])*_+(M-b[1])*F)/R)),U=Math.hypot(w-(b[0]+_*k),M-(b[1]+F*k));U/T<m&&(m=U/T,A=T)}const h=.95*ae(m,.012)+.3*ae(m,.05)*A;Te(l,(f*e+d)*4,Math.min(1,h)*rn(d,f,e,p))}return{width:e,height:e,rgba:l}}function oo(e,n){const t=new Uint8Array(e*n*4);for(let r=0;r<n;r++)for(let o=0;o<e;o++){const i=(o+.5-e/2)/(e/2),s=(r+.5-n/2)/(n/2),a=ae(i,.34)*Math.exp(-Math.max(0,-s-.05)*4.2)*(s<.1?1:Math.max(0,1-s*4)),c=Math.hypot(i/.34,(s-.42)/.3),u=c>=1?0:ae(c,.5);Te(t,(r*e+o)*4,Math.max(a,u))}return{width:e,height:n,rgba:t}}function rc(e){return Ft(e,{r:.1,w:1},{r:.3,w:.16})}function io(e,n){const t=new Uint8Array(e*n*4);for(let r=0;r<n;r++){const o=(r+.5)/n,i=wn(Math.min(1,Math.min(o/.08,(1-o)/.08))),s=ae(o-.46,.24)*i,a=.5*(1-wn(Math.min(1,Math.max(0,(o-.42)/.5)))*.6);for(let c=0;c<e;c++){const u=(c+.5-e/2)/(e/2);Te(t,(r*e+c)*4,ae(Math.abs(u)/(a||.01),.5)*s)}}return{width:e,height:n,rgba:t}}function hi(e){const n=new Uint8Array(e*e*4),t=e/2,r=Math.max(2,Math.round(e*.04));for(let o=0;o<e;o++)for(let i=0;i<e;i++){const s=(i+.5-t)/t,a=(o+.5-t)/t,c=ae(Math.hypot(s,a),.42),u=ae(Math.hypot(s-.34,a),.36),l=Math.max(0,c-u*1.08)*rn(i,o,e,r);Te(n,(o*e+i)*4,l)}return{width:e,height:e,rgba:n}}function mi(e){const n=new Uint8Array(e*e*4),t=e/2,r=Math.max(2,Math.round(e*.04));for(let o=0;o<e;o++)for(let i=0;i<e;i++){const s=(i+.5-t)/t,a=(o+.5-t)/t;let c=ae(Math.hypot(s,a),.08);for(let u=0;u<6;u++){const l=u*Math.PI/3,p=Math.cos(l),f=Math.sin(l),d=s*p+a*f,w=-s*f+a*p;if(d<0)continue;const M=Math.max(0,1.02-d/.72);c+=ae(w,.028)*ae(d,.5)*M,c+=.55*ae(w-(d-.28)*.65,.02)*ae(d-.28,.12)*M,c+=.55*ae(w+(d-.28)*.65,.02)*ae(d-.28,.12)*M,c+=.4*ae(w-(d-.48)*.7,.016)*ae(d-.48,.08)*M,c+=.4*ae(w+(d-.48)*.7,.016)*ae(d-.48,.08)*M}Te(n,(o*e+i)*4,Math.min(1,c)*rn(i,o,e,r))}return{width:e,height:e,rgba:n}}function gi(e,n){const t=new Uint8Array(e*e*4),r=e/2,o=Math.max(2,Math.round(e*.04)),i=Math.abs(n|0)%3;for(let s=0;s<e;s++)for(let a=0;a<e;a++){const c=(a+.5-r)/r*1.55,u=(s+.5-r)/r*1.55,l=Math.abs(Math.abs(c)+Math.abs(u)-.55);let p=ae(l,.016);i===0?(p+=ae(c,.012)*ae(u,.38),p+=ae(u,.012)*ae(c,.38)):i===1?(p+=ae(c-u,.012)*ae(c+u,.36),p+=ae(c+u,.012)*ae(c-u,.36)):(p+=ae(Math.hypot(c,u)-.26,.014),p+=ae(c,.012)*ae(u,.22)),Te(t,(s*e+a)*4,Math.min(1,p)*rn(a,s,e,o))}return Un({width:e,height:e,rgba:t},.03)}function so(e){let n=0;const t=String(e);for(let r=0;r<t.length;r++)n=n*31+t.charCodeAt(r)|0;return n}function bi(e){const n=new Uint8Array(e*e*4),t=e/2,r=Math.max(2,Math.round(e*.03));for(let o=0;o<e;o++)for(let i=0;i<e;i++){const s=(i+.5-t)/t,a=(o+.5-t)/t,c=Math.hypot(s,a),u=ae(c,.07)+.85*ae(s,.62)*ae(a,.045)+.22*ae(s,.92)*ae(a,.018);Te(n,(o*e+i)*4,Math.min(1,u)*rn(i,o,e,r))}return{width:e,height:e,rgba:n}}const On={"particle/halo_6":()=>Ft(256,{r:.14,w:1},{r:.4,w:.17}),"particle/normal_splash":()=>bt(li(256),3.2),"particle/drop_normal":()=>bt(io(128,512),3.4),"particle/normal_ring_smooth":()=>bt(to(256,.55,.12),3.1),"particle/normal_pinch_rotate":()=>bt(Za(256),2.8),"particle/water/rain_drops_sheet_normal":()=>bt(ro(256,512,2,4),3.6),"particle/bubbles/bubble1normal":()=>bt(In(256,1),3.2),"particle/bubbles/bubble2_normal":()=>bt(In(256,2),3.2),"particle/sharp_halo_normal":()=>bt(Dn(256,[{r:.035,w:1},{r:.09,w:.45},{r:.22,w:.08}]),3.4),"particle/beam/beam_0":()=>_t(128,512,.46,!0),"particle/beam/beam_1":()=>_t(128,512,.34,!0),"particle/beam/beam_2":()=>_t(128,512,.22,!0),"particle/beam/beam_2_fade":()=>_t(128,512,.24,!1),"particle/light/light_shafts_0":()=>_t(128,512,.42,!0),"particle/light/light_shafts_1":()=>_t(128,512,.3,!0),"particle/light/light_shafts_3":()=>_t(128,512,.26,!0),"particle/light/light_shafts_5":()=>_t(128,512,.23,!0),"particle/light/light_shafts_6":()=>_t(128,512,.2,!0),"particle/nature/rosepetals":()=>ci(256),"particle/nature/leaves":()=>Xe(256,0),"particle/nature/leaves1":()=>Xe(256,1),"particle/nature/leaves2":()=>Xe(256,2),"particle/nature/leaves3":()=>Xe(256,3),"particle/nature/leaves5":()=>Xe(256,5),"particle/nature/leaves6":()=>Xe(256,6),"particle/nature/leaves7":()=>Xe(256,7),"particle/nature/leaves8":()=>Xe(256,8),"particle/nature/snow":()=>mi(256),"particle/halo":()=>Ft(256,{r:.12,w:1},{r:.3,w:.15}),"particle/halo_1":()=>Ft(256,{r:.1,w:1},{r:.3,w:.13}),"particle/halo_2":()=>Ft(256,{r:.2,w:.9},{r:.44,w:.2}),"particle/halo_3":()=>Dn(256,[{r:.045,w:1},{r:.13,w:.85},{r:.36,w:.15}]),"particle/halo_4":()=>Ft(256,{r:.085,w:1},{r:.28,w:.12}),"particle/halo_5":()=>Dn(256,[{r:.04,w:1},{r:.11,w:.8},{r:.34,w:.17}]),"particle/sharp_halo":()=>Dn(256,[{r:.035,w:1},{r:.09,w:.45},{r:.22,w:.08}]),"particle/chromaticdot":()=>rc(128),"particle/light/flare_0":()=>kt(256,6,.58,10,.08),"particle/light/flare_1":()=>kt(512,4,.62,14,.07),"particle/light/flare_2":()=>bi(256),"particle/drop":()=>io(128,512),"particle/nature/rain1":()=>si(128,512,10,1,.78),"particle/nature/rain2":()=>si(128,512,10,1.6,.66),"particle/water/rain_drops_sheet":()=>ro(256,512,2,4),"particle/fog/fog1":()=>Wt(512,4,5,1,.4,.9,150),"particle/fog/fog2":()=>Wt(512,3,5,2,.45,.8,140),"particle/fog/fog3":()=>Wt(512,6,4,3,.36,1,150),"particle/smoke/smoke1":()=>Wt(512,3,5,7,.55,1.5,130),"particle/smoke/smoke2":()=>Wt(512,2,5,11,.6,1.7,120),"particle/smoke/smoke2light":()=>Wt(512,2,5,13,.4,1.7,110),"particle/misc/wave":()=>to(512,.72,.085),"particle/misc/star_0":()=>kt(256,5,.62,8,.1),"particle/bubbles/bubble1":()=>In(256,1),"particle/bubbles/bubble2":()=>In(256,2),"particle/bubbles/bubble3":()=>In(256,3),"particle/debris/debris1":()=>pi(128),"particle/lightning/lightning1":()=>hr(256,3),"particle/lightning/lightning2":()=>hr(256,11),"particle/lightning/lightning3":()=>hr(256,19),"particle/fire/fire1":()=>no(256,23),"particle/fire/fire2":()=>no(256,41),"particle/star":()=>kt(256,4,.58,12,.09),"particle/shape/circle_wind":()=>ui(256),"particle/sickle":()=>hi(256),"particle/magic/glyph_4":()=>gi(256,4),"@sparkle":()=>kt(256,4,.6,16,.08),"@star":()=>kt(256,5,.62,8,.1),"@trail":()=>oo(128,256)};function yi(e){const n=String(e).toLowerCase();if(/normal/.test(n)){const t=tc(e);return t?()=>bt(nc(t),2.8):()=>bt(li(128),2.6)}return/rosepetal|petal|sakura|blossom/.test(n)?()=>ci(256):/leaf|leaves|foliage/.test(n)?/leaves8/.test(n)?()=>Xe(256,8):/leaves7/.test(n)?()=>Xe(256,7):/leaves6/.test(n)?()=>Xe(256,6):/leaves5/.test(n)?()=>Xe(256,5):/leaves3/.test(n)?()=>Xe(256,3):/leaves2/.test(n)?()=>Xe(256,2):/leaves1/.test(n)?()=>Xe(256,1):()=>Xe(256,0):/circle_wind|windcircle/.test(n)?()=>ui(256):/fog|cloud|mist|vapor/.test(n)?()=>Wt(512,4,5,5,.4,.9,150):/smoke/.test(n)?()=>Wt(512,3,5,8,.55,1.5,130):/beam|shaft|ray|godray/.test(n)?()=>_t(128,512,.3,!0):/flare/.test(n)?()=>bi(256):/bubble/.test(n)?()=>ai(256,1):/ring|wave/.test(n)?()=>to(512,.72,.085):/fire|flame|ember|ash/.test(n)?()=>no(256,so(n)):/sickle|crescent|moon/.test(n)?()=>hi(256):/glyph|magic|rune/.test(n)?()=>gi(256,so(n)):/snowflake|雪花|snow/.test(n)?()=>mi(256):/流星|meteor|shooting/.test(n)?()=>oo(128,256):/star|星/.test(n)?()=>kt(256,5,.62,8,.1):/sparkle|glint|twinkle/.test(n)?()=>kt(256,4,.6,16,.08):/rain_drops_sheet|drops_sheet/.test(n)?()=>ro(256,512,2,4):/drop|rain/.test(n)?()=>io(128,512):/debris|dirt|rock/.test(n)?()=>pi(128):/lightning|bolt|arc/.test(n)?()=>hr(256,so(n)):/note|music/.test(n)?()=>kt(256,4,.55,8,.12):/trail|streak/.test(n)?()=>oo(128,256):()=>Ft(256,{r:.12,w:1},{r:.3,w:.15})}function oc(e){if(Nn.has(e))return Nn.get(e);let n=null;const t=Jr.get(e);if(t)try{n=t()}catch{n=null}if(!n&&dr)try{n=dr(e)}catch{n=null}if(!n&&On[e])try{n=On[e]()}catch{n=null}if(!n)try{n=yi(e)()}catch{n=null}return n||(n=Ft(256,{r:.12,w:1},{r:.3,w:.15})),Nn.set(e,n),n}function ic(e){return typeof e=="string"&&e.indexOf("particle/")===0}const sc=Object.freeze(Object.defineProperty({__proto__:null,buildBuiltinParticleTexture:oc,builtinParticleFrames:Ya,isBuiltinParticleTextureName:ic,listBuiltinParticleTextureNames:qa,particleNormalNameForAlbedo:ec,prepareParticleNormalTexture:Qa,resetParticleTextureFactories:Ga,setParticleTextureFactory:Ha,setParticleTextureProvider:Xa},Symbol.toStringTag,{value:"Module"})),vi=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);function Ht(e,n,t){const r=t||new Float32Array(16);for(let o=0;o<4;o++)for(let i=0;i<4;i++)r[o*4+i]=e[i]*n[o*4]+e[4+i]*n[o*4+1]+e[8+i]*n[o*4+2]+e[12+i]*n[o*4+3];return r}function xi(e){const n=[];for(let r=0;r<4;r++)n.push([e[r],e[4+r],e[8+r],e[12+r],0,0,0,0]),n[r][4+r]=1;for(let r=0;r<4;r++){let o=r;for(let a=r+1;a<4;a++)Math.abs(n[a][r])>Math.abs(n[o][r])&&(o=a);const i=n[r];n[r]=n[o],n[o]=i;const s=n[r][r];if(Math.abs(s)<1e-12)return Float32Array.from(vi);for(let a=0;a<8;a++)n[r][a]/=s;for(let a=0;a<4;a++){if(a===r)continue;const c=n[a][r];if(c!==0)for(let u=0;u<8;u++)n[a][u]-=c*n[r][u]}}const t=new Float32Array(16);for(let r=0;r<4;r++)for(let o=0;o<4;o++)t[r*4+o]=n[o][4+r];return t}function ao(e,n,t,r,o,i,s,a,c,u){const l=u||new Float32Array(16),p=Math.cos(r),f=Math.sin(r),d=Math.cos(o),w=Math.sin(o),M=Math.cos(i),m=Math.sin(i);return l[0]=M*d*s,l[1]=m*d*s,l[2]=-w*s,l[3]=0,l[4]=(M*w*f-m*p)*a,l[5]=(m*w*f+M*p)*a,l[6]=d*f*a,l[7]=0,l[8]=(M*w*p+m*f)*c,l[9]=(m*w*p-M*f)*c,l[10]=d*p*c,l[11]=0,l[12]=e,l[13]=n,l[14]=t,l[15]=1,l}function $n(e,n){const t=[];for(;n<e.byteLength;){const o=e.getUint8(n++);if(o===0)break;t.push(o)}let r="";try{r=new TextDecoder("utf-8").decode(new Uint8Array(t))}catch{r=String.fromCharCode.apply(null,t)}return{value:r,next:n}}function mr(e,n,t=0){const r=[];for(let o=0;o<n.length;o++)r.push(n.charCodeAt(o));e:for(let o=t;o<=e.length-r.length;o++){for(let i=0;i<r.length;i++)if(e[o+i]!==r[i])continue e;return o}return-1}function ac(e){const n=new DataView(e.buffer,e.byteOffset,e.byteLength),t=String.fromCharCode.apply(null,Array.from(e.subarray(0,8)));if(!t.startsWith("MDLV"))throw new Error("\u4E0D\u662F MDL: "+t);const r=$n(n,21),i=parseInt(t.slice(4),10)>=23?[{lenOff:32,stride:80,uv:72,bone:40,weight:56},{lenOff:32,stride:48,uv:40,bone:-1,weight:-1}]:[{lenOff:8,stride:52,uv:44,bone:12,weight:28},{lenOff:4,stride:52,uv:44,bone:12,weight:28},{lenOff:32,stride:80,uv:72,bone:40,weight:56}];let s=null,a=0,c=0;for(const K of i){const re=r.next+K.lenOff;if(re+4>e.byteLength)continue;const te=n.getUint32(re,!0);if(te>0&&te%K.stride===0&&re+4+te<=e.byteLength){s=K,a=te,c=re;break}}if(!s)throw new Error("\u9876\u70B9\u533A\u957F\u5EA6\u5F02\u5E38\uFF08"+t+"\uFF0C\u5DF2\u8BD5 stride "+i.map(K=>K.stride).join("/")+"\uFF09");const u=c+4,l=a/s.stride,p=new Float32Array(l*3),f=new Float32Array(l*2),d=new Float32Array(l*4),w=new Float32Array(l*4);for(let K=0;K<l;K++){const re=u+K*s.stride;if(p[K*3]=n.getFloat32(re,!0),p[K*3+1]=n.getFloat32(re+4,!0),p[K*3+2]=n.getFloat32(re+8,!0),f[K*2]=n.getFloat32(re+s.uv,!0),f[K*2+1]=n.getFloat32(re+s.uv+4,!0),s.bone>=0&&s.weight>=0)for(let te=0;te<4;te++)d[K*4+te]=n.getUint32(re+s.bone+te*4,!0),w[K*4+te]=n.getFloat32(re+s.weight+te*4,!0);else d[K*4]=0,w[K*4]=1}const M=n.getUint32(u+a,!0),m=u+a+4,A=l>65535&&M%4===0,h=A?M/4:M/2,b=A?new Uint32Array(h):new Uint16Array(h);if(A)for(let K=0;K<h;K++)b[K]=n.getUint32(m+K*4,!0);else for(let K=0;K<h;K++)b[K]=n.getUint16(m+K*2,!0);const v=lc(e,n),T=uc(e,n,v.length),_=dc(e,n,v),F=cc(e,n,v.length),R=[],k=[],U=[];if(v.length>0){const K=v.map((te,X)=>{const J=te.matrix,de=Math.hypot(J[0],J[1]),Se=Math.hypot(J[4],J[5]);return U[X]=Float32Array.from([J[12],J[13],J[14],0,0,Math.atan2(J[1],J[0]),de||1,Se||1,J[10]||1]),Float32Array.from(J)});for(let te=0;te<v.length;te++){const X=U[te],J=v[te].matrix;Math.hypot(X[0]-J[12],X[1]-J[13])>.001&&(K[te]=ao(X[0],X[1],X[2],X[3],X[4],X[5],X[6],X[7],X[8],new Float32Array(16)))}const re=[];for(let te=0;te<v.length;te++){const X=v[te].parent;re[te]=X>=0&&X<te?Ht(re[X],K[te]):Float32Array.from(K[te])}for(let te=0;te<v.length;te++)R[te]=xi(re[te]);if(_){const te=[];for(let X=0;X<v.length;X++){const J=v[X].parent;te[X]=J>=0&&J<X?Ht(te[J],_[X]):Float32Array.from(_[X])}for(let X=0;X<v.length;X++)k[X]=Ht(te[X],R[X])}}let V=1/0,q=-1/0,W=1/0,Z=-1/0;for(let K=0;K<l;K++){const re=p[K*3],te=p[K*3+1];re<V&&(V=re),re>q&&(q=re),te<W&&(W=te),te>Z&&(Z=te)}return{magic:t,materialPath:r.value,vertexCount:l,positions:p,uvs:f,boneIdx:d,weights:w,indexCount:h,indexType:A?"u32":"u16",indices:b,bones:v,animations:T,animBound:fc(T,v),invBindWorld:R,bindTRS:U.length>0?U:null,attachments:F.length>0?F:null,restCorrection:k.length>0?k:null,bounds:{minX:V,maxX:q,minY:W,maxY:Z}}}function cc(e,n,t){const r=mr(e,"MDAT");if(r<0)return[];const o=n.getUint16(r+13,!0);if(o<=0||o>256)return[];const i=[];let s=r+15;for(let a=0;a<o&&!(s+2>e.length);a++){const c=n.getUint16(s,!0),u=$n(n,s+2);if(u.next+64>e.length)break;const l=new Float32Array(16);for(let p=0;p<16;p++)l[p]=n.getFloat32(u.next+p*4,!0);c<t&&i.push({bone:c,name:u.value,matrix:l}),s=u.next+64}return i}function lc(e,n){const t=mr(e,"MDLS");if(t<0)return[];const r=n.getUint32(t+13,!0);if(r<=0||r>1024)return[];const o=[];let i=t+17;for(let s=0;s<r;s++){if(i+77>n.byteLength)return o;const a=n.getUint32(i+1,!0),c=n.getInt32(i+5,!0),u=new Float32Array(16);for(let p=0;p<16;p++)u[p]=n.getFloat32(i+13+p*4,!0);const l=$n(n,i+13+64);o.push({id:a,parent:c>=0&&c<r?c:-1,matrix:u}),i=l.next}return o}function uc(e,n,t){const r=mr(e,"MDLA");if(r<0)return[];let o=r+9;const i=n.getUint32(o,!0);o+=4;const s=n.getUint32(o,!0);if(o+=4,s<=0||s>256)return[];const a=[];for(let c=0;c<s&&!(o+16>n.byteLength);c++){const u=n.getUint32(o,!0);o+=8;const l=$n(n,o);o=l.next;const p=$n(n,o);if(o=p.next,o+16>n.byteLength)break;const f=n.getFloat32(o,!0);o+=4;const d=n.getUint32(o,!0);o+=8;const w=n.getUint32(o,!0);if(o+=4,w>1024)break;const M=[];for(let m=0;m<w&&!(o+8>n.byteLength);m++){o+=4;const A=n.getUint32(o,!0);o+=4;const h=Math.floor(A/36);if(o+A>n.byteLength)break;const b=new Float32Array(h*9);for(let v=0;v<h;v++){const T=o+v*36;for(let _=0;_<9;_++)b[v*9+_]=n.getFloat32(T+_*4,!0)}o+=A,M.push({frameCount:h,keyframes:b})}if(o+=35,M.length>0&&d>0&&f>0&&a.push({id:u,name:l.value,mode:p.value,fps:f,frameCount:d,duration:d/f,tracks:M}),o>=i)break}return a}function fc(e,n){let t=0,r=0;for(const o of e)for(let i=0;i<o.tracks.length;i++){const s=o.tracks[i];if(!s)continue;const a=n[i],c=a?a.matrix[12]:0,u=a?a.matrix[13]:0,l=s.keyframes;for(let p=0;p<s.frameCount;p++){const f=Math.abs(l[p*9]-c),d=Math.abs(l[p*9+1]-u);f>t&&(t=f),d>r&&(r=d)}}return{x:t,y:r}}function dc(e,n,t){if(t.length===0)return null;const r=mr(e,"MDLE");if(r<0)return null;const o=r+8+1+4+4;if(o+t.length*64>n.byteLength)return null;const i=[];for(let s=0;s<t.length;s++){const a=new Float32Array(16);for(let c=0;c<16;c++)a[c]=n.getFloat32(o+s*64+c*4,!0);i.push(a)}return i}function pc(e,n,t,r){const o=e.frameCount;if(o===0)return r[0]=0,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=0,r[6]=1,r[7]=1,r[8]=1,r;const i=t*n.fps;let s,a,c;if(n.mode==="loop"){const d=Math.max(1,o-1),w=(i%d+d)%d;s=Math.floor(w),a=(s+1)%o,c=w-s}else if(n.mode==="mirror"){const d=Math.max(1,o-1),w=d*2;let M=(i%w+w)%w;M>d&&(M=w-M),s=Math.floor(M),a=Math.min(s+1,o-1),c=M-s}else{const d=Math.min(Math.max(i,0),o-1);s=Math.floor(d),a=Math.min(s+1,o-1),c=d-s}const u=e.keyframes,l=s*9,p=a*9,f=1-c;for(let d=0;d<9;d++)if(d>=3&&d<=5){let w=u[p+d]-u[l+d];w>Math.PI?w-=2*Math.PI:w<-Math.PI&&(w+=2*Math.PI),r[d]=u[l+d]+w*c}else r[d]=u[l+d]*f+u[p+d]*c;return r}function hc(e,n,t){const r=e.bindTRS&&e.bindTRS[n];if(r)return t.set(r),t;const o=e.bones[n].matrix;return t[0]=o[12],t[1]=o[13],t[2]=o[14],t[3]=0,t[4]=0,t[5]=Math.atan2(o[1],o[0]),t[6]=Math.hypot(o[0],o[1])||1,t[7]=Math.hypot(o[4],o[5])||1,t[8]=o[10]||1,t}function co(e,n,t,r){const o=e.bones,i=o.length;if(i===0)return null;const s=!!(r&&r.size>0);if(!e._skin||e._skin.length!==i*16){e._skin=new Float32Array(i*16),e._local=[],e._world=[],e._tmp=new Float32Array(16),e._tmp2=new Float32Array(16);for(let f=0;f<i;f++)e._local.push(new Float32Array(16)),e._world.push(new Float32Array(16))}const a=Array.isArray(t)&&t.length>0,c=[];if(a)for(const f of t){if(f.visible===!1||f.visible===0)continue;const d=e.animations.find(w=>w.id===f.animation);d&&c.push({anim:d,additive:!!f.additive,blend:typeof f.blend=="number"?f.blend:1,rate:typeof f.rate=="number"?f.rate:1})}if(c.length===0&&!a){const f=e.animations[0];if(f)c.push({anim:f,additive:!1,blend:1,rate:1});else if(!s)return null}const u=e._trsBase||(e._trsBase=new Float32Array(9)),l=e._trsAcc||(e._trsAcc=new Float32Array(9)),p=e._trsSmp||(e._trsSmp=new Float32Array(9));for(let f=0;f<i;f++){hc(e,f,u),l.set(u);let d=!1,w=0;for(const m of c){const A=m.anim.tracks[f];if(!A)continue;pc(A,m.anim,n*m.rate,p);const h=m.blend;if(m.additive){for(let b=0;b<9;b++){let v=p[b]-u[b];b>=3&&b<=5&&(v>Math.PI?v-=2*Math.PI:v<-Math.PI&&(v+=2*Math.PI)),l[b]+=v*h}w+=h}else for(let b=0;b<9;b++)l[b]=l[b]*(1-h)+p[b]*h;d=!0}if(w>1)for(let m=0;m<9;m++)l[m]=u[m]+(l[m]-u[m])/w;const M=s?r.get(f):void 0;M&&(l[0]=M[0],l[1]=M[1],l[2]=M[2],d=!0),d?ao(l[0],l[1],l[2],l[3],l[4],l[5],l[6],l[7],l[8],e._local[f]):ao(u[0],u[1],u[2],u[3],u[4],u[5],u[6],u[7],u[8],e._local[f])}for(let f=0;f<i;f++){const d=o[f].parent;d>=0&&d<f?Ht(e._world[d],e._local[f],e._world[f]):e._world[f].set(e._local[f])}for(let f=0;f<i;f++)Ht(e._world[f],e.invBindWorld[f],e._tmp),e._skin.set(e._tmp,f*16);return e._skin}function wi(e,n){return!e||!e.invBindWorld||!(n>=0&&n<e.invBindWorld.length)?null:xi(e.invBindWorld[n])}function mc(e,n){return Ht(e,n)}function Mi(e,n){if(!e||!e.attachments||typeof n!="string"||n===""||!e._world)return null;for(const t of e.attachments)if(t.name===n)return t.bone<0||t.bone>=e._world.length?null:Ht(e._world[t.bone],t.matrix);return null}function _i(e,n){if(!e||!e.attachments||typeof n!="string"||n==="")return null;for(const t of e.attachments){if(t.name!==n)continue;const r=wi(e,t.bone);return r?Ht(r,t.matrix):null}return null}function lo(e,n,t){const r=e&&e.angles&&e.angles[2]||0,o=e&&e.scale?e.scale[0]:1,i=e&&e.scale?e.scale[1]:1,s=r*Math.PI/180,a=Math.cos(s),c=Math.sin(s),u=n*o,l=t*i;return[u*a-l*c,u*c+l*a]}function gc(e){const n=new Map,t=new Map;for(const i of e){if(!i||i.id===void 0||i.id===null||(n.set(i.id,i),i.parentId===void 0||i.parentId===null))continue;const s=t.get(i.parentId);s?s.push(i):t.set(i.parentId,[i])}const r=(i,s)=>{const a=t.get(i.id);if(a)for(const c of a)s.push(c),r(c,s)},o=[];for(const i of e){const s=i&&i.attachment;if(typeof s!="string"||s==="")continue;const a=n.get(i.parentId);if(!a||!a.puppet)continue;const c=_i(a.puppet,s);if(!c)continue;const u=c[12],l=c[13],p=lo(a,u,l),f=[];r(i,f),i.origin[0]+=p[0],i.origin[1]+=p[1];for(const d of f)d.origin[0]+=p[0],d.origin[1]+=p[1];i.parallaxDepth=a.parallaxDepth?a.parallaxDepth.slice():null;for(const d of f)d.parallaxDepth=i.parallaxDepth?i.parallaxDepth.slice():null;i.attachBindDelta=[p[0],p[1]],o.push({layer:i,parent:a,name:s,bindX:u,bindY:l,desc:f})}for(const i of o){i.baseX=i.layer.origin[0],i.baseY=i.layer.origin[1],i.subtree=[{layer:i.layer,x:i.layer.origin[0],y:i.layer.origin[1]}];for(const s of i.desc)i.subtree.push({layer:s,x:s.origin[0],y:s.origin[1]});for(const s of i.subtree)s.layer.attachBase||(s.layer.attachBase=[s.x,s.y])}return o}function bc(e,n,t){if(!e||e.length===0)return;const r=new Set,o=[];for(const a of e){const c=a.parent&&a.parent.puppet;if(!c){o.push(null);continue}if(!r.has(c)){r.add(c);const l=typeof t=="function"?t(a.parent):null;co(c,n,a.parent.animationLayers,l)}const u=Mi(c,a.name);if(!u){o.push(null);continue}o.push(lo(a.parent,u[12]-a.bindX,u[13]-a.bindY))}const i=a=>{const c=a.layer.attachBase;return c||[a.x,a.y]},s=new Set;for(const a of e){const c=a.subtree||[{layer:a.layer,x:a.baseX,y:a.baseY}];for(const u of c){if(s.has(u.layer))continue;s.add(u.layer);const l=i(u);u.layer.origin[0]=l[0],u.layer.origin[1]=l[1]}}for(let a=0;a<e.length;a++){const c=e[a],u=o[a],l=c.subtree||[{layer:c.layer,x:c.baseX,y:c.baseY}];if(u)for(const p of l)p.layer.origin[0]+=u[0],p.layer.origin[1]+=u[1]}}const yc=128,gr=24;function vc(e){const n=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS)||256,t=Math.floor((n-32)/4);return Math.max(gr,Math.min(yc,t))}const xc=e=>`#version 300 es
|
|
141
|
+
}`,r=(u,l)=>{const f=e.createShader(u);if(e.shaderSource(f,l),e.compileShader(f),!e.getShaderParameter(f,e.COMPILE_STATUS))throw new Error("\u7C92\u5B50 shader: "+e.getShaderInfoLog(f));return f},o=e.createProgram();if(e.attachShader(o,r(e.VERTEX_SHADER,n)),e.attachShader(o,r(e.FRAGMENT_SHADER,t)),e.linkProgram(o),!e.getProgramParameter(o,e.LINK_STATUS))throw new Error("\u7C92\u5B50 shader \u94FE\u63A5\u5931\u8D25: "+e.getProgramInfoLog(o));const i=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,i),e.bufferData(e.ARRAY_BUFFER,new Float32Array([-.5,-.5,.5,-.5,-.5,.5,.5,.5]),e.STATIC_DRAW);const s=e.createBuffer(),a=e.createVertexArray();e.bindVertexArray(a),e.bindBuffer(e.ARRAY_BUFFER,i),e.enableVertexAttribArray(0),e.vertexAttribPointer(0,2,e.FLOAT,!1,8,0),e.vertexAttribDivisor(0,0),e.bindBuffer(e.ARRAY_BUFFER,s);const c=56;return e.enableVertexAttribArray(1),e.vertexAttribPointer(1,3,e.FLOAT,!1,c,0),e.vertexAttribDivisor(1,1),e.enableVertexAttribArray(2),e.vertexAttribPointer(2,2,e.FLOAT,!1,c,12),e.vertexAttribDivisor(2,1),e.enableVertexAttribArray(3),e.vertexAttribPointer(3,4,e.FLOAT,!1,c,20),e.vertexAttribDivisor(3,1),e.enableVertexAttribArray(4),e.vertexAttribPointer(4,3,e.FLOAT,!1,c,36),e.vertexAttribDivisor(4,1),e.enableVertexAttribArray(5),e.vertexAttribPointer(5,2,e.FLOAT,!1,c,48),e.vertexAttribDivisor(5,1),e.bindVertexArray(null),{prog:{prog:o,uniTex:e.getUniformLocation(o,"u_tex"),uniNormal:e.getUniformLocation(o,"u_normal"),uniScene:e.getUniformLocation(o,"u_scene"),uniRefract:e.getUniformLocation(o,"u_refract"),uniSampleScene:e.getUniformLocation(o,"u_sampleScene"),uniResolution:e.getUniformLocation(o,"u_resolution"),uniRefractScale:e.getUniformLocation(o,"u_refractScale"),uniMvp:e.getUniformLocation(o,"u_mvp"),uniFrameCount:e.getUniformLocation(o,"u_frameCount"),uniFrames:e.getUniformLocation(o,"u_frames")},quadBuf:i,vbuf:s,vao:a}}function ai(e){const n=e&&e.passes&&e.passes[0]&&e.passes[0].combos;return!!(n&&Number(n.REFRACT)===1)}function ec(e){if(!e||e.length<16)return!1;const n=e.length/4,t=Math.max(1,n/64|0);let r=0;for(let o=0;o<n;o+=t){const i=o*4;if(e[i]<250||e[i+1]<250||e[i+2]<250||e[i+3]<250)return!1;r++}return r>0}function ci(e,n,t,r){let o=Math.abs(Number(e)||0)*(Number(n)||0);const i=Number(t)||0,s=Number(r)||0;return i>0&&(o=Math.max(i,o)),s>0&&(o=Math.min(s,o)),o}function Jr(e,n){return e||n?Math.atan2(n,e)-Math.PI/2:0}function li(e,n){return e&&e.kind==="ropetrail"?Math.max(1,n||1):1}function ui(e){if(!e||e.kind!=="ropetrail")return 1;const n=Math.round(Number(e.segments)||0);return n>=2?Math.min(32,n):8}function fi(e){if(!e||e.kind!=="ropetrail")return 0;const n=Number(e.length);return Number.isFinite(n)&&n>0?n:.2}function eo(e){return e.life>0?e.age/e.life:0}class tc{constructor(){this.alive=!1,this.x=this.y=this.z=0,this.vx=this.vy=this.vz=0,this.bx=this.by=this.bz=0,this.age=0,this.life=1,this.size=1,this.baseSize=1,this.rot=0,this.rotVel=0,this.r=this.g=this.b=1,this.baseR=this.baseG=this.baseB=1,this.alpha=1,this.baseAlpha=1,this.seed=0,this.frame=0,this.oscPhase=0,this.oscFreq=0,this.oscAmp=0,this.oscAPhase=0,this.oscAFreq=0,this.oscSPhase=0,this.oscSFreq=0,this.turbSpeed=0,this.turbPhase=0,this.trail=null,this.trailClock=0,this.seq=0}}class nc{constructor(n,t,r,o){this.gl=n,this.model=t||{},this.override=r||{},this.layer=o||null,this.syncLayerTransform(),this.maxCount=Math.max(1,Math.min(2e4,re(this.model.maxcount,100))),this.simTime=0,this.paused=!1,this.texture=null,this.normalTex=null,this.material=null,this.blend="translucent",this.refract=!1,this.refractAmount=.04,this.opacityMul=1,this.lifetimeMul=1,this.visible=!0,this._ready=!1,this._prog=null,this._vbuf=null,this._quadBuf=null,this._vao=null,this._data=null,this._sceneTex=null,this.sequenceMul=Math.max(1,Math.round(re(this.model.sequencemultiplier,1))),this.animationMode=this.model.animationmode||null,this.texFrames=null,this.frameCount=this.sequenceMul*this.sequenceMul,this.texAspectX=1,this.texAspectY=1,this.controlPoints=(this.model.controlpoint||[]).filter(Boolean).map(i=>({id:re(i.id,0),lockToPointer:!!i.locktopointer||(re(i.flags,0)&1)!==0,offset:be(i.offset),x:0,y:0,z:0})),this.pointer=null,this._followParent=null,this._followMode=null,this._followOffset=[0,0,0],this.ropeRenderer=null,this._seq=0,this._ropeOrder=[],this._ov={},this._applyOverride(),this.startTime=Math.max(0,Math.min(30,re(this.model.starttime,0))),this._warmed=!1,this._compile()}reapplyOverride(){this._applyOverride()}_applyOverride(){this._ov={},this.opacityMul=1,this.lifetimeMul=1,this.maxCount=Math.max(1,Math.min(2e4,re(this.model.maxcount,100)));const n=this.override||{};for(const t of Object.keys(n)){if(t==="id")continue;const r=n[t],o=r&&typeof r=="object"&&"value"in r?r.value:r;if(t==="count"){const i=re(this.model.maxcount,100),s=Number(o),a=Number.isFinite(s)?s:1;this.maxCount=Math.max(1,Math.min(2e4,Math.round(i*a))),this._ov.countMul=a}else if(t==="alpha")this.opacityMul=Number(o),Number.isFinite(this.opacityMul)||(this.opacityMul=1);else if(t==="color"||t==="colorn"){const i=be(o);this._ov.color=t==="colorn"?i:[i[0]/255,i[1]/255,i[2]/255]}else t==="size"?this._ov.size=Number(o)||1:t==="rate"?(this._ov.rateMul=Number(o),Number.isFinite(this._ov.rateMul)||(this._ov.rateMul=1)):t==="speed"?this._ov.speed=Number(o)||1:t==="lifetime"?this.lifetimeMul=Number(o)||1:t==="brightness"?this._ov.brightness=Number(o)||1:this._ov[t]=o}this.pool=[];for(let t=0;t<this.maxCount;t++)this.pool.push(new tc)}_compile(){const n=this.model;this.emitters=(n.emitter||[]).map(c=>({kind:c.name==="boxrandom"?"box":"sphere",origin:be(c.origin),directions:be(c.directions,[1,1,1]),distanceMin:si(c.distancemin),distanceMax:si(c.distancemax),sign:c.sign?be(c.sign):null,rate:re(c.rate,0),audioDriven:c.audioprocessingmode!==void 0,audioBounds:be(c.audioprocessingbounds,[0,1]),fill:c.rate===void 0&&c.instantaneous===void 0&&c.audioprocessingmode===void 0,instantaneous:re(c.instantaneous,0),speedMin:re(c.speedmin,0),speedMax:re(c.speedmax,0),controlPoint:c.controlpoint!==void 0&&c.controlpoint!==null?re(c.controlpoint,0):0,_burst:!1}));const t=n.initializer||[];this.init={life:null,size:null,color:null,alpha:null,velocity:null,rotation:null,angularVelocity:null,turbulentVelocity:null,mapAround:null};for(const c of t)switch(c.name){case"lifetimerandom":this.init.life={min:re(c.min,1),max:re(c.max,1),exp:re(c.exponent,1)};break;case"sizerandom":this.init.size={min:re(c.min,1),max:re(c.max,1),exp:re(c.exponent,1)};break;case"colorrandom":this.init.color={min:be(c.min,[255,255,255]),max:be(c.max,[255,255,255])};break;case"alpharandom":this.init.alpha={min:re(c.min,1),max:re(c.max,1)};break;case"velocityrandom":this.init.velocity={min:be(c.min),max:be(c.max)};break;case"rotationrandom":this.init.rotation={min:be(c.min),max:be(c.max,[0,0,0]),exp:re(c.exponent,1)};break;case"angularvelocityrandom":this.init.angularVelocity={min:be(c.min),max:be(c.max),exp:re(c.exponent,1)};break;case"mapsequencearoundcontrolpoint":this.init.mapAround={count:Math.max(1,re(c.count,1)),bounds:be(c.bounds,[0,1]),speedMin:be(c.speedmin),speedMax:be(c.speedmax,[0,0,0]),cp:re(c.controlpoint,0)},this._mapAroundSeq=0;break;case"turbulentvelocityrandom":this.init.turbulentVelocity={scale:re(c.scale,.1),offset:re(c.offset,0),speedMin:re(c.speedmin,0),speedMax:re(c.speedmax,0),phaseMax:re(c.phasemax,0),timeScale:re(c.timescale,0),audioMode:re(c.audioprocessingmode,0),audioBounds:be(c.audioprocessingbounds,[0,1])};break}const r=n.operator||[];this.ops={movement:null,angularMovement:null,alphaFade:null,alphaChange:null,sizeChange:null,colorChange:null,turbulence:[],oscAlpha:null,oscSize:null,oscPos:null,attract:[],vortex:[],remap:[]};for(const c of r)switch(c.name){case"movement":this.ops.movement={gravity:be(c.gravity),drag:re(c.drag,0)};break;case"angularmovement":this.ops.angularMovement={force:be(c.force),drag:re(c.drag,0)};break;case"alphafade":this.ops.alphaFade={fadeIn:re(c.fadeintime,.1),fadeOut:re(c.fadeouttime,.9)};break;case"alphachange":this.ops.alphaChange={startTime:re(c.starttime,0),endTime:re(c.endtime,1),startValue:re(c.startvalue,1),endValue:re(c.endvalue,0)};break;case"sizechange":this.ops.sizeChange={startTime:re(c.starttime,0),endTime:re(c.endtime,1),startValue:re(c.startvalue,1),endValue:re(c.endvalue,1)};break;case"colorchange":this.ops.colorChange={startTime:re(c.starttime,0),endTime:re(c.endtime,1),startValue:c.startvalue!==void 0?be(c.startvalue):null,endValue:be(c.endvalue,[1,1,1])};break;case"turbulence":this.ops.turbulence.push({scale:re(c.scale,.01),speedMin:re(c.speedmin,0),speedMax:re(c.speedmax,0),timeScale:re(c.timescale,1),phaseMin:re(c.phasemin,0),phaseMax:re(c.phasemax,0),mask:c.mask!==void 0?be(c.mask,[1,1,1]):[1,1,1]});break;case"oscillatealpha":this.ops.oscAlpha={freqMin:re(c.frequencymin,re(c.frequencymax,1)),freqMax:re(c.frequencymax,1),scaleMin:re(c.scalemin,0),scaleMax:re(c.scalemax,1),phaseMax:re(c.phasemax,wt)};break;case"oscillatesize":this.ops.oscSize={freqMin:re(c.frequencymin,re(c.frequencymax,1)),freqMax:re(c.frequencymax,re(c.frequencymin,1)),scaleMin:re(c.scalemin,1),scaleMax:re(c.scalemax,1),phaseMax:re(c.phasemax,wt)};break;case"oscillateposition":this.ops.oscPos={freqMin:re(c.frequencymin,re(c.frequencymax,.5)),freqMax:re(c.frequencymax,.5),scaleMin:re(c.scalemin,0),scaleMax:re(c.scalemax,1),phaseMin:re(c.phasemin,0),phaseMax:re(c.phasemax,wt),mask:c.mask!==void 0?be(c.mask,[1,1,0]):[1,1,0]};break;case"controlpointattract":this.ops.attract.push({cp:re(c.controlpoint,0),origin:be(c.origin),scale:re(c.scale,0),threshold:re(c.threshold,0)});break;case"vortex":this.ops.vortex.push({axis:be(c.axis,[0,0,1]),offset:be(c.offset),distanceInner:re(c.distanceinner,0),distanceOuter:re(c.distanceouter,0),speedInner:re(c.speedinner,0),speedOuter:re(c.speedouter,0),cp:c.controlpoint!==void 0&&c.controlpoint!==null?re(c.controlpoint,0):0,audioMode:re(c.audioprocessingmode,0),audioBounds:be(c.audioprocessingbounds,[0,1])});break;case"remapvalue":this.ops.remap.push({output:c.output||"velocity",rangeMin:be(c.outputrangemin),rangeMax:be(c.outputrangemax),fn:c.transformfunction||"simplexnoise",inputScale:re(c.transforminputscale,1)});break}const o=this.model.renderer,i=o==null,s=Array.isArray(o)?o:o?[o]:[];this.renderers=s.map(c=>{const u=c&&c.name||"sprite";return{kind:u,length:re(c&&c.length,u==="spritetrail"?.1:u==="ropetrail"?.2:0),maxLength:re(c&&c.maxlength,0),minLength:re(c&&c.minlength,0),subdivision:re(c&&c.subdivision,1),segments:re(c&&c.segments,0),orientation:c&&c.orientation||null}}),i&&!this.renderers.length&&(this.renderers=[{kind:"sprite",length:0,maxLength:0,minLength:0,subdivision:1,segments:0,orientation:null}]);const a=this.renderers.find(c=>c.kind==="spritetrail"||c.kind==="ropetrail");if(this.trailCfg=a||null,this.trailSegments=1,this.trailDuration=0,this.trailSampleDt=0,a&&a.kind==="ropetrail"){const c=ui(a);this.trailSegments=c,this.trailDuration=fi(a),this.trailSampleDt=this.trailDuration/Math.max(1,c-1);for(const u of this.pool)u.trail=new Float32Array(c*3),u.trailClock=0}this.ropeRenderer=this.renderers.find(c=>c.kind==="rope")||null}setModel(n){this.model=n,this._compile()}setMaterial(n){this.material=n;const t=n&&n.passes&&n.passes[0];this.blend=t&&t.blending||"translucent",this.refract=ai(n);const r=t&&t.constantshadervalues,o=r&&r.ui_editor_properties_refract_amount,i=Number(o);this.refractAmount=Number.isFinite(i)?Math.min(.35,Math.max(0,i)):.04}setNormalTexture(n){this.normalTex=n||null}setTexture(n){this.texture=n,this._ready=!!n;const t=n&&n.frames,r=Array.isArray(t)?t:t&&t.list&&t.list.length?t.list:null,o=n&&n.width||r&&(t&&t.atlasWidth||r.atlasWidth)||0,i=n&&n.height||r&&(t&&t.atlasHeight||r.atlasHeight)||0;r&&o>0&&i>0?(this.texFrames=r.map(u=>({ou:u.x/o,ov:u.y/i,su:u.width/o,sv:u.height/i})),this.frameCount=this.texFrames.length):(this.texFrames=null,this.frameCount=this.sequenceMul*this.sequenceMul);let s=1,a=1;this.texFrames&&r?(s=r[0].width||1,a=r[0].height||1):n&&n.width>0&&n.height>0&&(s=n.width,a=n.height);const c=Math.max(s,a)||1;this.texAspectX=s/c,this.texAspectY=a/c,this._frameData=void 0}setVisible(n){this.visible=n}syncLayerTransform(){const n=this.layer,t=n&&n.origin?n.origin:[0,0,0],r=n&&n.scale?n.scale:[1,1,1],o=n&&n.angles?n.angles:[0,0,0];this.originX=t[0]||0,this.originY=t[1]||0,this.originZ=t[2]||0,this.scaleX=r[0]===0?1:r[0],this.scaleY=r[1]===0?1:r[1],this.angleZ=(o[2]||0)*Math.PI/180;const i=Math.abs(this.scaleX),s=Math.abs(this.scaleY);this.sysScale=Math.min(i,s)||1,this.spriteStretchX=i/this.sysScale,this.spriteStretchY=s/this.sysScale}setPointer(n,t){const r=n-this.originX,o=t-this.originY,i=Math.cos(-this.angleZ),s=Math.sin(-this.angleZ);this.pointer={x:(r*i-o*s)/(this.scaleX||1),y:(r*s+o*i)/(this.scaleY||1)}}attachFollow(n,t,r){this._followParent=n||null,this._followMode=t==="particle"||t==="origin"?t:null;const o=r||[0,0,0];this._followOffset=[o[0]||0,o[1]||0,o[2]||0],this._syncFollow()}leaderParticle(){const n=this.pool;for(let t=0;t<n.length;t++)if(n[t].alive)return n[t];return null}localToWorld(n,t){const r=n*this.scaleX,o=t*this.scaleY,i=Math.cos(this.angleZ),s=Math.sin(this.angleZ);return[this.originX+r*i-o*s,this.originY+r*s+o*i]}_syncFollow(){const n=this._followParent,t=this._followMode;if(!n||!t)return;const r=this._followOffset;if(t==="particle"){const o=n.leaderParticle();if(!o)return;const i=n.localToWorld(o.x+r[0],o.y+r[1]);this.originX=i[0],this.originY=i[1]}else{const o=n.localToWorld(r[0],r[1]);this.originX=o[0],this.originY=o[1]}}spawn(n){const t=this.pool,r=t.length;let o=null,i=this._cursor||0;for(let f=0;f<r;f++){const p=t[(i+f)%r];if(!p.alive){o=p,this._cursor=(i+f+1)%r;break}}if(!o)return;o.alive=!0,o.age=0,o.seed=Math.random(),o.rot=0,o.rotVel=0,o.vx=o.vy=o.vz=0,o.frame=0,o.seq=this._seq++;const s=n.origin;if(n.kind==="box"){const f=n.distanceMax||[0,0,0],p=n.distanceMin;o.x=s[0]+Re(-f[0],f[0])+(p?p[0]:0),o.y=s[1]+Re(-f[1],f[1])+(p?p[1]:0),o.z=s[2]+Re(-f[2],f[2])+(p?p[2]:0)}else{const f=n.directions,p=n.distanceMin?n.distanceMin[0]:0,d=n.distanceMax?n.distanceMax[0]:0,y=Math.random()*2-1,x=Math.random()*wt,m=Math.sqrt(Math.max(0,1-y*y));let M=m*Math.cos(x),h=m*Math.sin(x),g=y;n.sign&&(n.sign[0]&&(M=Math.abs(M)*Math.sign(n.sign[0])),n.sign[1]&&(h=Math.abs(h)*Math.sign(n.sign[1])),n.sign[2]&&(g=Math.abs(g)*Math.sign(n.sign[2])));const v=Re(p,d);if(o.x=s[0]+M*v*f[0],o.y=s[1]+h*v*f[1],o.z=s[2]+g*v*f[2],n.speedMax||n.speedMin){const A=Re(n.speedMin,n.speedMax);o.vx+=M*A,o.vy+=h*A,o.vz+=g*A}}{const f=this._cpPos(n.controlPoint);if(f)o.x+=f[0],o.y+=f[1],o.z+=f[2];else{const p=this.controlPoints.find(d=>d.id===n.controlPoint);if(p&&p.lockToPointer){o.alive=!1;return}}}if(this.init.mapAround){const f=this.init.mapAround,p=this._cpPos(f.cp);if(p){const d=f.count,y=this._mapAroundSeq++,x=d>0?y%d/d:0,M=(f.bounds[0]+(f.bounds[1]-f.bounds[0])*x)*wt,h=n.distanceMin?n.distanceMin[0]:0,g=n.distanceMax?n.distanceMax[0]:0,v=g>0?g:h;o.x=p[0]+Math.cos(M)*v,o.y=p[1]+Math.sin(M)*v,o.z=p[2];const A=Math.random();o.vx+=f.speedMin[0]+(f.speedMax[0]-f.speedMin[0])*A,o.vy+=f.speedMin[1]+(f.speedMax[1]-f.speedMin[1])*A,o.vz+=f.speedMin[2]+(f.speedMax[2]-f.speedMin[2])*A}}const a=this.init,c=this._ov.speed||1,u=this._ov.size||1;if(o.life=a.life?Math.max(.001,ii(a.life.min,a.life.max,a.life.exp)*this.lifetimeMul):1,o.baseSize=a.size?ii(a.size.min,a.size.max,a.size.exp)*u:u,o.size=o.baseSize,a.color){const f=a.color.min,p=a.color.max,d=Math.random();o.baseR=(f[0]+(p[0]-f[0])*d)/255,o.baseG=(f[1]+(p[1]-f[1])*d)/255,o.baseB=(f[2]+(p[2]-f[2])*d)/255}else o.baseR=o.baseG=o.baseB=1;if(this._ov.color&&(o.baseR=this._ov.color[0],o.baseG=this._ov.color[1],o.baseB=this._ov.color[2]),o.r=o.baseR,o.g=o.baseG,o.b=o.baseB,o.baseAlpha=(a.alpha?Re(a.alpha.min,a.alpha.max):1)*this.opacityMul,o.alpha=o.baseAlpha,a.velocity&&(o.vx+=Re(a.velocity.min[0],a.velocity.max[0])*c,o.vy+=Re(a.velocity.min[1],a.velocity.max[1])*c,o.vz+=Re(a.velocity.min[2],a.velocity.max[2])*c),a.turbulentVelocity){const f=a.turbulentVelocity,p=f.audioMode?Zr(f.audioBounds,this._audioLevel||0):1,d=Re(f.speedMin,f.speedMax)*c*p,y=this.simTime*(f.timeScale||0),x=Qr(o.x*f.scale+f.offset,o.y*f.scale+f.offset,y+o.seed*(f.phaseMax||0),3);o.vx+=x[0]*d,o.vy+=x[1]*d,o.vz+=x[2]*d}a.rotation&&(o.rot=Re(a.rotation.min[2],a.rotation.max[2])),a.angularVelocity&&(o.rotVel=Re(a.angularVelocity.min[2],a.angularVelocity.max[2]));const l=this.ops;if(l.oscPos&&(o.oscFreq=Re(l.oscPos.freqMin,l.oscPos.freqMax),o.oscAmp=Re(l.oscPos.scaleMin,l.oscPos.scaleMax),o.oscPhase=Re(l.oscPos.phaseMin,l.oscPos.phaseMax)+o.seed*wt),l.oscAlpha&&(o.oscAFreq=Re(l.oscAlpha.freqMin,l.oscAlpha.freqMax),o.oscAPhase=Math.random()*(l.oscAlpha.phaseMax||wt)),l.oscSize&&(o.oscSFreq=Re(l.oscSize.freqMin,l.oscSize.freqMax),o.oscSPhase=Math.random()*(l.oscSize.phaseMax||wt)),l.turbulence.length){const f=l.turbulence[0];o.turbSpeed=Re(f.speedMin,f.speedMax),o.turbPhase=Re(f.phaseMin,f.phaseMax)}if(this.frameCount>1&&(o.frame=this.animationMode==="randomframe"?Math.floor(Math.random()*this.frameCount):0),o.bx=o.x,o.by=o.y,o.bz=o.z,o.trail){for(let f=0;f<o.trail.length;f+=3)o.trail[f]=o.x,o.trail[f+1]=o.y,o.trail[f+2]=o.z;o.trailClock=0}}updateParticle(n,t){if(n.age+=t,n.age>=n.life){n.alive=!1;return}const r=n.age/n.life,o=this.ops;if(o.movement&&(n.vx+=o.movement.gravity[0]*t,n.vy+=o.movement.gravity[1]*t,n.vz+=o.movement.gravity[2]*t,o.movement.drag>0)){const a=Math.exp(-o.movement.drag*t);n.vx*=a,n.vy*=a,n.vz*=a}o.angularMovement&&(n.rotVel+=(o.angularMovement.force[2]||0)*t,o.angularMovement.drag>0&&(n.rotVel*=Math.exp(-o.angularMovement.drag*t)));for(const a of o.turbulence){const c=a.timeScale||1,u=Qr(n.bx*a.scale,n.by*a.scale,this.simTime*a.scale*c+n.turbPhase,3);n.vx+=u[0]*n.turbSpeed*a.mask[0]*t,n.vy+=u[1]*n.turbSpeed*a.mask[1]*t,n.vz+=u[2]*n.turbSpeed*a.mask[2]*t}for(const a of o.attract){const c=this._cpPos(a.cp);if(!c)continue;const u=c[0]+a.origin[0]-n.x,l=c[1]+a.origin[1]-n.y,f=Math.hypot(u,l);if(f<.001||a.threshold>0&&f>a.threshold)continue;const p=a.threshold>0?1-f/a.threshold:1,d=a.scale*p*t/Math.max(1,f);n.vx+=u*d,n.vy+=l*d}for(const a of o.vortex){const c=this._cpPos(a.cp)||[0,0,0],u=n.x-(c[0]+a.offset[0]),l=n.y-(c[1]+a.offset[1]),f=Math.hypot(u,l);if(f<.001)continue;const p=a.distanceOuter-a.distanceInner,d=p>0?Math.min(1,Math.max(0,(f-a.distanceInner)/p)):0,y=a.audioMode?Zr(a.audioBounds,this._audioLevel||0):1,x=a.speedInner+(a.speedOuter-a.speedInner)*d;n.vx+=-l/f*x*t*y,n.vy+=u/f*x*t*y}for(const a of o.remap){const c=a.inputScale||1,u=Qr(n.bx*.01*c,n.by*.01*c,this.simTime*.1,a.fn==="fbmnoise"?4:2);if(a.output==="velocity")for(let l=0;l<3;l++){const f=(u[l]+1)/2,p=a.rangeMin[l]+(a.rangeMax[l]-a.rangeMin[l])*f;l===0?n.vx=p:l===1?n.vy=p:n.vz=p}else if(a.output==="speed"){const l=(u[0]+1)/2,f=a.rangeMin[0]+(a.rangeMax[0]-a.rangeMin[0])*l,p=Math.hypot(n.vx,n.vy)||1;n.vx=n.vx/p*f,n.vy=n.vy/p*f}}if(n.bx+=n.vx*t,n.by+=n.vy*t,n.bz+=n.vz*t,n.rot+=n.rotVel*t,n.x=n.bx,n.y=n.by,n.z=n.bz,o.oscPos){const a=this.simTime*n.oscFreq*wt+n.oscPhase,c=o.oscPos.mask;n.x+=Math.sin(a)*n.oscAmp*c[0],n.y+=Math.cos(a)*n.oscAmp*c[1],n.z+=Math.sin(a*.7)*n.oscAmp*c[2]}let i=n.baseSize;if(o.sizeChange){const a=o.sizeChange,c=a.endTime-a.startTime,u=c>0?Math.min(1,Math.max(0,(r-a.startTime)/c)):r>=a.startTime?1:0;i*=a.startValue+(a.endValue-a.startValue)*u}if(o.oscSize){const a=this.simTime*n.oscSFreq*wt+n.oscSPhase,c=o.oscSize,u=(c.scaleMin+c.scaleMax)/2,l=(c.scaleMax-c.scaleMin)/2;i*=u+Math.sin(a)*l}if(n.size=i,o.colorChange){const a=o.colorChange,c=a.endTime-a.startTime,u=c>0?Math.min(1,Math.max(0,(r-a.startTime)/c)):r>=a.startTime?1:0,l=a.startValue||[n.baseR,n.baseG,n.baseB];n.r=l[0]+(a.endValue[0]-l[0])*u,n.g=l[1]+(a.endValue[1]-l[1])*u,n.b=l[2]+(a.endValue[2]-l[2])*u}let s=n.baseAlpha;if(o.alphaFade){const a=o.alphaFade.fadeIn,c=o.alphaFade.fadeOut;a>0&&r<a&&(s*=r/a),c<1&&r>c&&(s*=Math.max(0,(1-r)/(1-c)))}else o.alphaChange||(r<.1?s*=r/.1:r>.85&&(s*=(1-r)/.15));if(o.alphaChange){const a=o.alphaChange,c=a.endTime-a.startTime,u=c>0?Math.min(1,Math.max(0,(r-a.startTime)/c)):r>=a.startTime?1:0;s*=a.startValue+(a.endValue-a.startValue)*u}if(o.oscAlpha){const a=this.simTime*n.oscAFreq*wt+n.oscAPhase,c=o.oscAlpha,u=(c.scaleMin+c.scaleMax)/2,l=(c.scaleMax-c.scaleMin)/2;s*=u+Math.sin(a)*l}if(n.alpha=Math.max(0,s),this.frameCount>1&&this.animationMode!=="randomframe"&&(n.frame=Math.min(this.frameCount-1,Math.floor(r*this.frameCount))),n.trail){const a=n.trail,c=this.trailSampleDt;if(c>0){n.trailClock=(n.trailClock||0)+t;let u=0;const l=this.trailSegments||8;for(;n.trailClock>=c&&u<l;){n.trailClock-=c,u++;for(let f=a.length-3;f>=3;f-=3)a[f]=a[f-3],a[f+1]=a[f-2],a[f+2]=a[f-1]}}a[0]=n.x,a[1]=n.y,a[2]=n.z}}_cpPos(n){const t=this.controlPoints.find(r=>r.id===n);return t?t.lockToPointer?this.pointer?[this.pointer.x+t.offset[0],this.pointer.y+t.offset[1],t.offset[2]]:null:t.offset:null}advance(n,t){if(!(this.paused||!this.visible)){if(this._syncFollow(),!this._warmed&&(this._warmed=!0,this.startTime>0)){const r=.03333333333333333,o=Math.min(900,Math.round(this.startTime/r));for(let i=0;i<o;i++)this._step(r)}this._step(n,t)}}_step(n,t){this.simTime+=n;const r=t&&Number.isFinite(t.level)?Math.max(0,Math.min(1,t.level)):0;this._audioLevel=r;for(const i of this.emitters){if(i.instantaneous>0&&!i._burst){i._burst=!0;for(let c=0;c<Math.min(i.instantaneous,this.maxCount);c++)this.spawn(i)}if(i.fill){const u=Math.min(this.maxCount,2048);let l=0;for(let p=0;p<this.pool.length;p++)this.pool[p].alive&&l++;let f=Math.min(u-l,512);for(;f-- >0;)this.spawn(i);continue}if(i.audioDriven){const c=Zr(i.audioBounds,r);if(i.rate>0){const u=i.rate*c*(this._ov.rateMul!==void 0?this._ov.rateMul:1)*(this._ov.countMul!==void 0?this._ov.countMul:1);if(!(u>0))continue;i._accum=(i._accum||0)+u*n;let l=Math.floor(i._accum);if(l>0){i._accum-=l,l>this.maxCount&&(l=this.maxCount);for(let f=0;f<l;f++)this.spawn(i)}}else{const l=Math.round(Math.min(this.maxCount,2048)*c);let f=0;for(let d=0;d<this.pool.length;d++)this.pool[d].alive&&f++;let p=Math.min(l-f,256);for(;p-- >0;)this.spawn(i)}continue}const s=i.rate*(this._ov.rateMul!==void 0?this._ov.rateMul:1)*(this._ov.countMul!==void 0?this._ov.countMul:1);if(!(s>0))continue;i._accum=(i._accum||0)+s*n;let a=Math.floor(i._accum);if(a>0){i._accum-=a,a>this.maxCount&&(a=this.maxCount);for(let c=0;c<a;c++)this.spawn(i)}}const o=this.pool;for(let i=0;i<o.length;i++)o[i].alive&&this.updateParticle(o[i],n)}render(n,t,r,o,i){if(!this._ready||!this.visible||!this.renderers.length)return;const s=this.gl;this._prog||this._buildProgram(s);const a=this.trailCfg&&this.trailCfg.kind==="ropetrail"?this.trailCfg:null,c=this.trailCfg&&this.trailCfg.kind==="spritetrail"?this.trailCfg:null,u=this.ropeRenderer,l=li(this.trailCfg,this.trailSegments),f=14,p=this.pool;let d=null;if(u){d=this._ropeOrder,d.length=0;for(let J=0;J<p.length;J++)p[J].alive&&d.push(p[J]);d.sort((J,Z)=>J.seq-Z.seq)}let y=0;if(d)y=d.length;else for(let J=0;J<p.length;J++)p[J].alive&&y++;if(y===0||u&&y<2)return;const x=u?y-1:y*l,m=x*f;(!this._data||this._data.length<m)&&(this._data=new Float32Array(Math.max(m,1024)));const M=this._data;let h=0;const g=this._ov.brightness||1,v=this.sysScale,A=this.spriteStretchX*(this.texAspectX||1),_=this.spriteStretchY*(this.texAspectY||1),R=Math.cos(this.angleZ),L=Math.sin(this.angleZ),N=this.originX,j=this.originY,H=this.scaleX,K=this.scaleY,O=(J,Z)=>{const te=J*H,le=Z*K;return[N+te*R-le*L,i-(j+te*L+le*R)]};if(u)for(let J=0;J+1<y;J++){const Z=d[J],te=d[J+1],le=O(Z.x,Z.y),Fe=O(te.x,te.y),_e=Fe[0]-le[0],Ye=Fe[1]-le[1],Ve=Math.hypot(_e,Ye),Ne=(Math.abs(Z.size)+Math.abs(te.size))*.5*v;Ne>0&&(M[h++]=(le[0]+Fe[0])*.5,M[h++]=(le[1]+Fe[1])*.5,M[h++]=0,M[h++]=Ne,M[h++]=Math.atan2(-_e,Ye),M[h++]=(Z.r+te.r)*.5*g,M[h++]=(Z.g+te.g)*.5*g,M[h++]=(Z.b+te.b)*.5*g,M[h++]=(Z.alpha+te.alpha)*.5,M[h++]=1,M[h++]=Ve/Ne,M[h++]=0,M[h++]=eo(Z),M[h++]=eo(te))}for(let J=0;J<p.length&&!u;J++){const Z=p[J];if(Z.alive)for(let te=0;te<l;te++){let le=Z.x,Fe=Z.y,_e=1,Ye=1,Ve=Z.rot,Ne=A,qe=_,Ue,ye;if(a&&Z.trail){le=Z.trail[te*3],Fe=Z.trail[te*3+1];const he=l>1?te/(l-1):0;_e=1-he,Ye=1-he*.55;let De=0,Pe=0;te+1<l?(De=Z.trail[te*3]-Z.trail[(te+1)*3],Pe=Z.trail[te*3+1]-Z.trail[(te+1)*3+1]):te>0?(De=Z.trail[(te-1)*3]-Z.trail[te*3],Pe=Z.trail[(te-1)*3+1]-Z.trail[te*3+1]):(De=Z.vx,Pe=Z.vy);const Ze=O(le,Fe),Be=O(le-De,Fe-Pe),Ae=Ze[0]-Be[0],nt=Ze[1]-Be[1],rt=Math.hypot(Ae,nt),Ft=Math.max(.001,Math.abs(Z.size)*v*Ye);rt>.001?(Ve=Jr(Ae,nt),Ue=(Ze[0]+Be[0])*.5,ye=(Ze[1]+Be[1])*.5,qe=Math.max(_,rt/Ft)):(Ue=Ze[0],ye=Ze[1])}else{const he=O(le,Fe);Ue=he[0],ye=he[1]}if(c){const he=O(Z.x,Z.y);Ue=he[0],ye=he[1];const De=O(Z.x+Z.vx,Z.y+Z.vy);Ve=Jr(De[0]-he[0],De[1]-he[1]);const Pe=ci(Math.hypot(Z.vx,Z.vy),c.length,c.minLength,c.maxLength);qe=_*Pe}M[h++]=Ue,M[h++]=ye,M[h++]=0,M[h++]=Math.abs(Z.size)*v*Ye,M[h++]=Ve,M[h++]=Z.r*g,M[h++]=Z.g*g,M[h++]=Z.b*g,M[h++]=Z.alpha*_e,M[h++]=Ne,M[h++]=qe,M[h++]=Z.frame,M[h++]=0,M[h++]=1}}const W=this._prog;s.useProgram(W.prog),s.bindVertexArray(this._vao),s.bindBuffer(s.ARRAY_BUFFER,this._vbuf),s.bufferData(s.ARRAY_BUFFER,M.subarray(0,h),s.DYNAMIC_DRAW),s.activeTexture(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,this.texture.glTex),s.uniform1i(W.uniTex,0),s.uniformMatrix4fv(W.uniMvp,!1,n);const X=this.refract&&this.normalTex&&this.normalTex.glTex;if(W.uniRefract&&s.uniform1i(W.uniRefract,X?1:0),X){s.activeTexture(s.TEXTURE1),s.bindTexture(s.TEXTURE_2D,this.normalTex.glTex),W.uniNormal&&s.uniform1i(W.uniNormal,1);const J=this.blend!=="additive";if(W.uniSampleScene&&s.uniform1i(W.uniSampleScene,J?1:0),J){const Z=s.drawingBufferWidth||t,te=s.drawingBufferHeight||r;s.bindFramebuffer(s.FRAMEBUFFER,null),s.activeTexture(s.TEXTURE2),this._sceneTex?s.bindTexture(s.TEXTURE_2D,this._sceneTex):(this._sceneTex=s.createTexture(),s.bindTexture(s.TEXTURE_2D,this._sceneTex),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE)),s.copyTexImage2D(s.TEXTURE_2D,0,s.RGB8,0,0,Z,te,0),W.uniScene&&s.uniform1i(W.uniScene,2),W.uniResolution&&s.uniform2f(W.uniResolution,Z,te),W.uniRefractScale&&s.uniform1f(W.uniRefractScale,this.refractAmount||.04)}else s.activeTexture(s.TEXTURE2),s.bindTexture(s.TEXTURE_2D,this.texture.glTex),W.uniScene&&s.uniform1i(W.uniScene,2)}else W.uniNormal&&(s.activeTexture(s.TEXTURE1),s.bindTexture(s.TEXTURE_2D,this.texture.glTex),s.uniform1i(W.uniNormal,1),s.activeTexture(s.TEXTURE2),s.bindTexture(s.TEXTURE_2D,this.texture.glTex),W.uniScene&&s.uniform1i(W.uniScene,2),W.uniSampleScene&&s.uniform1i(W.uniSampleScene,0));const ie=this._frameUniformData();ie?(s.uniform1i(W.uniFrameCount,ie.count),s.uniform4fv(W.uniFrames,ie.arr)):s.uniform1i(W.uniFrameCount,0),s.enable(s.BLEND),this.blend==="additive"?s.blendFunc(s.SRC_ALPHA,s.ONE):s.blendFunc(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA),s.depthMask(!1),s.drawArraysInstanced(s.TRIANGLE_STRIP,0,4,x),s.depthMask(!0),s.disable(s.BLEND),s.bindVertexArray(null)}_buildProgram(n){const t=Ja(n);this._quadBuf=t.quadBuf,this._vbuf=t.vbuf,this._vao=t.vao,this._prog=t.prog}_frameUniformData(){if(this._frameData!==void 0)return this._frameData;let n=this.texFrames;if(!n&&this.sequenceMul>1){const o=this.sequenceMul;n=[];for(let i=0;i<o;i++)for(let s=0;s<o;s++)n.push({ou:s/o,ov:i/o,su:1/o,sv:1/o})}if(!n||n.length===0)return this._frameData=null,null;const t=Math.min(n.length,128),r=new Float32Array(t*4);for(let o=0;o<t;o++)r[o*4]=n[o].ou,r[o*4+1]=n[o].ov,r[o*4+2]=n[o].su,r[o*4+3]=n[o].sv;return this._frameData={count:t,arr:r},this._frameData}liveCount(){let n=0;for(const t of this.pool)t.alive&&n++;return n}dispose(){this.paused=!0;const n=this.gl;if(n){try{this._vbuf&&n.deleteBuffer(this._vbuf),this._quadBuf&&n.deleteBuffer(this._quadBuf),this._vao&&n.deleteVertexArray(this._vao),this._prog&&this._prog.prog&&n.deleteProgram(this._prog.prog),this._sceneTex&&n.deleteTexture(this._sceneTex)}catch{}this._prog=null,this._vbuf=null,this._quadBuf=null,this._vao=null,this._data=null,this._sceneTex=null}}}const rc=Object.freeze(Object.defineProperty({__proto__:null,ParticleSystem:nc,particleInstanceSegs:li,particlePassRefract:ai,rgbaIsBlankWhite:ec,ropeParticleV:eo,ropeTrailDuration:fi,ropeTrailHistoryCount:ui,spriteTrailLengthFactor:ci,spriteTrailRotation:Jr},Symbol.toStringTag,{value:"Module"})),$n=new Map,to=new Map;let dr=null;function oc(e,n){const t=String(e);to.set(t,n),$n.delete(t)}function ic(e){dr=typeof e=="function"?e:null}function sc(){to.clear(),dr=null,$n.clear()}function ac(){return Object.keys(Hn)}function Se(e,n,t){e[n]=255,e[n+1]=255,e[n+2]=255,e[n+3]=Math.round(Math.min(1,Math.max(0,t))*255)}function jn(e,n){const{width:t,height:r,rgba:o}=e,i=Math.max(2,Math.round(Math.min(t,r)*.04));for(let s=0;s<r;s++)for(let a=0;a<t;a++){const c=Math.min(a,s,t-1-a,r-1-s);if(c>=i)continue;const u=c/i,l=(s*t+a)*4+3;o[l]=Math.round(o[l]*u)}if(n>0){let s=0;const a=t*r;for(let u=0;u<a;u++)s+=o[u*4+3];const c=s/a/255;if(c>n&&c>0){const u=n/c;for(let l=0;l<a;l++)o[l*4+3]=Math.round(o[l*4+3]*u)}}return e}function pr(e){let n=e>>>0;return function(){n|=0,n=n+1831565813|0;let t=Math.imul(n^n>>>15,1|n);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}const xn=e=>e*e*(3-2*e),di=e=>e*e*e*(e*(e*6-15)+10),no=(e,n,t)=>e+(n-e)*t,ae=(e,n)=>Math.exp(-(e*e)/(n*n));function sn(e,n,t,r){const o=Math.min(e,n,t-1-e,t-1-n);return o>=r?1:o/r}function zn(e,n){const t=new Uint8Array(e*e*4),r=e/2;for(let o=0;o<e;o++)for(let i=0;i<e;i++){const s=Math.hypot((i+.5-r)/r,(o+.5-r)/r);let a=0;for(let c=0;c<n.length;c++)a+=n[c].w*ae(s,n[c].r);Se(t,(o*e+i)*4,a)}return{width:e,height:e,rgba:t}}function Ot(e,n,t){return zn(e,[n,t])}function $t(e,n,t,r,o){const i=new Uint8Array(e*e*4),s=e/2,a=Math.max(2,Math.round(e*.03));for(let c=0;c<e;c++)for(let u=0;u<e;u++){const l=(u+.5-s)/s,f=(c+.5-s)/s,p=Math.hypot(l,f),d=Math.atan2(f,l),y=Math.pow(.5+.5*Math.cos(n*d),r);let x=ae(p,o)+y*ae(p,t);x*=sn(u,c,e,a),Se(i,(c*e+u)*4,x)}return{width:e,height:e,rgba:i}}function Rt(e,n,t,r,o){const s=new Uint8Array(e*n*4);for(let a=0;a<n;a++){const c=a/(n-1),u=r?ae(c-.5,.27):xn(Math.min(1,c/.06))*Math.pow(1-c,1.35);for(let l=0;l<e;l++){const f=l/(e-1)*2-1,p=ae(f,t);Se(s,(a*e+l)*4,p*p*p*u*.55)}}return{width:e,height:n,rgba:s}}const Vn=4;function pi(e,n,t,r,o){const i=o===void 0?.85:o,s=new Uint8Array(e*n*4),a=n/Vn,c=pr(335009),u=Math.tan(t*Math.PI/180),l=e/2;for(let f=0;f<Vn;f++){const p=i*(.8+c()*.35),d=r*(.85+c()*.5),y=(c()-.5)*e*.12;for(let x=0;x<a;x++){const m=x/(a-1),M=l+y+(a-1)*u/2-(a-1)*u*m,h=ae(m-.5,.27);for(let g=0;g<e;g++){const v=Math.abs(g+.5-M),_=Math.exp(-(v*v)/(d*d))*h*p;_<.004||Se(s,((f*a+x)*e+g)*4,_)}}}return{width:e,height:n,rgba:s}}function cc(e){if(e==="particle/nature/rain1"||e==="particle/nature/rain2"){const n=[];for(let t=0;t<Vn;t++)n.push({ou:0,ov:t/Vn,su:1,sv:1/Vn});return n}return null}function ro(e,n,t){const r=new Uint8Array(e*e*4),o=e/2;for(let i=0;i<e;i++)for(let s=0;s<e;s++){const a=Math.hypot((s-o)/o,(i-o)/o);Se(r,(i*e+s)*4,ae(a-n,t*.6)*Math.max(0,1-a))}return{width:e,height:e,rgba:r}}function hi(e,n){const t={1:{r:.78,t:.048,inner:.06,hi:[[-.28,-.32,.22,.9],[.32,.36,.12,.28]]},2:{r:.7,t:.07,inner:.14,hi:[[-.2,-.28,.3,.72],[.38,.2,.14,.4]]},3:{r:.84,t:.036,inner:.04,hi:[[-.34,-.18,.16,.95],[.2,.42,.1,.22],[.04,-.08,.07,.18]]}},r=t[n]||t[1],o=new Uint8Array(e*e*4),i=e/2;for(let s=0;s<e;s++)for(let a=0;a<e;a++){const c=(a+.5-i)/i,u=(s+.5-i)/i,l=Math.hypot(c,u);let f=ae(l-r.r,r.t*.85)*Math.max(0,1.05-l);l<r.r&&(f+=r.inner*ae(l,.5));for(let p=0;p<r.hi.length;p++){const d=r.hi[p];f+=d[3]*ae(Math.hypot(c-d[0],u-d[1]),d[2])}Se(o,(s*e+a)*4,f)}return jn({width:e,height:e,rgba:o},.05)}function Wn(e,n){const t=e>>1,r=new Uint8Array(e*e*4),o=n===1?[1,2,1,3]:n===2?[2,1,2,3]:[3,1,2,3];for(let i=0;i<2;i++)for(let s=0;s<2;s++){const a=hi(t,o[i*2+s]);for(let c=0;c<t;c++){const u=(i*t+c)*e,l=c*t;for(let f=0;f<t;f++){const p=(u+s*t+f)*4,d=(l+f)*4;r[p]=a.rgba[d],r[p+1]=a.rgba[d+1],r[p+2]=a.rgba[d+2],r[p+3]=a.rgba[d+3]}}}return{width:e,height:e,rgba:r}}function mi(e){const n=new Uint8Array(e*e*4),t=e/2,r=[[.32,0],[1.1,.35],[2.2,-.3],[-.7,.2]];for(let o=0;o<e;o++)for(let i=0;i<e;i++){const s=i>=t?1:0,a=o>=t?1:0,c=a*2+s,u=s*t+t/2,l=a*t+t/2,f=r[c][0],p=r[c][1],d=(i+.5-u)/(t*.4),y=(o+.5-l)/(t*.4),x=Math.cos(f),m=Math.sin(f);let M=d*x+y*m;const h=-d*m+y*x;M+=p*h*.18;const g=1-Math.max(0,h)*.42,v=Math.hypot(M/(.52*g),h/.92);let A=v>=1.12?0:ae(v,.48);A=Math.min(1,A+ae(M,.07)*ae(h,.65)*A*.4),Se(n,(o*e+i)*4,A)}return jn({width:e,height:e,rgba:n},.11)}function He(e,n){const t={0:{rx:.36,ry:.92,wave:0,folds:0},1:{rx:.48,ry:.86,wave:.05,folds:7},2:{rx:.4,ry:.88,wave:.08,folds:5},3:{rx:.58,ry:.72,wave:0,folds:0},5:{rx:.44,ry:.8,wave:.12,folds:9},6:{rx:.52,ry:.78,wave:.07,folds:4},7:{rx:.5,ry:.9,wave:.16,folds:3},8:{rx:.38,ry:.94,wave:.2,folds:2}},r=t[n]||t[0],o=new Uint8Array(e*e*4),i=e/2;for(let s=0;s<e;s++)for(let a=0;a<e;a++){const c=(a+.5-i)/i,u=(s+.5-i)/i,l=Math.atan2(c,u),f=r.wave?1+r.wave*Math.sin(l*r.folds):1,p=Math.hypot(c/(r.rx*f),u/r.ry);let d=p>=1.12?0:ae(p,.5);d>0&&(d=Math.min(1,d+ae(c,.028)*ae(u,.72)*.28)),Se(o,(s*e+a)*4,d)}return jn({width:e,height:e,rgba:o},.11)}function Mt(e,n){const t=e.width,r=e.height,o=e.rgba,i=n??2.8,s=new Uint8Array(t*r*4),a=(c,u)=>{const l=c<0?0:c>=t?t-1:c,f=u<0?0:u>=r?r-1:u;return o[(f*t+l)*4+3]/255};for(let c=0;c<r;c++)for(let u=0;u<t;u++){const l=(a(u-1,c)-a(u+1,c))*i,f=(a(u,c-1)-a(u,c+1))*i,p=1/Math.hypot(l,f,1),d=(c*t+u)*4;s[d]=Math.round((l*p*.5+.5)*255),s[d+1]=Math.round((f*p*.5+.5)*255),s[d+2]=Math.round((p*.5+.5)*255),s[d+3]=255}return{width:t,height:r,rgba:s}}function gi(e){const n=new Uint8Array(e*e*4),t=e/2;for(let r=0;r<e;r++)for(let o=0;o<e;o++){const i=(o+.5-t)/t,s=(r+.5-t)/t,a=Math.hypot(i,s),c=a>=1?0:Math.sqrt(Math.max(0,1-a*a)),u=ae(a-.62,.11)*.55;Se(n,(r*e+o)*4,Math.min(1,c*.85+u))}return{width:e,height:e,rgba:n}}function lc(e){const n=new Uint8Array(e*e*4),t=e/2;for(let r=0;r<e;r++)for(let o=0;o<e;o++){const i=(o+.5-t)/t,s=(r+.5-t)/t,a=Math.hypot(i,s),c=Math.atan2(s,i),u=ae(a,.38)*(.55+.45*Math.cos(c*3+a*6));Se(n,(r*e+o)*4,u)}return{width:e,height:e,rgba:n}}function bi(e){const n=new Uint8Array(e*e*4),t=e/2,r=Math.max(2,Math.round(e*.04));for(let o=0;o<e;o++)for(let i=0;i<e;i++){const s=(i+.5-t)/t,a=(o+.5-t)/t,c=Math.hypot(s,a),u=Math.atan2(a,s),l=xn(Math.max(0,Math.cos(u)*.55+.45)),f=ae(c-.68,.07)*l+.35*ae(c-.78,.12)*ae(u-.9,.55);Se(n,(o*e+i)*4,Math.min(1,f)*sn(i,o,e,r))}return{width:e,height:e,rgba:n}}function uc(e){if(!e||e.length<16)return!1;const n=e.length/4,t=Math.max(1,n/48|0);let r=0;for(let o=0;o<n;o+=t){const i=o*4;if(e[i]<240||e[i+1]<240||e[i+2]<240)return!1;r++}return r>0}function fc(e){return!e||!e.rgba?e:uc(e.rgba)?Mt(e,2.8):e}const dc={"particle/drop":"particle/drop_normal","particle/water/rain_drops_sheet":"particle/water/rain_drops_sheet_normal","particle/bubbles/bubble1":"particle/bubbles/bubble1normal","particle/bubbles/bubble2":"particle/bubbles/bubble2_normal","particle/sharp_halo":"particle/sharp_halo_normal","particle/misc/wave":"particle/normal_splash","particle/halo":"particle/sharp_halo_normal"};function pc(e){if(!e)return null;const n=String(e);return/normal/i.test(n)?n:dc[n]||n+"_normal"}function hc(e){const n=String(e);return/(^|\/)normal_/.test(n)?null:/_normal$/i.test(n)?n.replace(/_normal$/i,""):/normal$/i.test(n)?n.replace(/normal$/i,""):null}function mc(e){if(Hn[e])return Hn[e]();const n=String(e).toLowerCase();return/normal/.test(n)?Ot(64,{r:.18,w:1},{r:.4,w:.2}):Ti(e)()}function yi(e,n,t){const r=pr(t*7919+17);let o=e;const i=[];for(let c=0;c<n;c++){const u=o*o,l=new Float32Array(u*2);for(let f=0;f<u;f++){const p=r()*Math.PI*2;l[f*2]=Math.cos(p),l[f*2+1]=Math.sin(p)}i.push({f:o,g:l,ox:c*7.31,oy:c*3.17}),o*=2}const s=(c,u,l,f,p)=>{const d=c.f,y=(u%d+d)%d,m=((l%d+d)%d*d+y)*2;return c.g[m]*f+c.g[m+1]*p},a=(c,u,l)=>{const f=(u+c.ox)*c.f,p=(l+c.oy)*c.f,d=Math.floor(f),y=Math.floor(p),x=f-d,m=p-y,M=di(x),h=di(m);return no(no(s(c,d,y,x,m),s(c,d+1,y,x-1,m),M),no(s(c,d,y+1,x,m-1),s(c,d+1,y+1,x-1,m-1),M),h)};return function(u,l,f){const p=f==null?i.length:Math.min(f,i.length);let d=1,y=0,x=0;for(let m=0;m<p;m++)y+=(a(i[m],u,l)*.5+.5)*d,x+=d,d*=.55;return y/x}}function vi(e,n,t){const{width:r,height:o,rgba:i}=e;if(r===n&&o===t)return e;const s=new Uint8Array(n*t*4);for(let a=0;a<t;a++){const c=(a+.5)/t*o-.5,u=Math.max(0,Math.min(o-1,Math.floor(c))),l=Math.max(0,Math.min(o-1,u+1)),f=c-Math.floor(c);for(let p=0;p<n;p++){const d=(p+.5)/n*r-.5,y=Math.max(0,Math.min(r-1,Math.floor(d))),x=Math.max(0,Math.min(r-1,y+1)),m=d-Math.floor(d),M=i[(u*r+y)*4+3],h=i[(u*r+x)*4+3],g=i[(l*r+y)*4+3],v=i[(l*r+x)*4+3],A=(M*(1-m)+h*m)*(1-f)+(g*(1-m)+v*m)*f;Se(s,(a*n+p)*4,A/255)}}return{width:n,height:t,rgba:s}}function Kt(e,n,t,r,o,i,s){const a=i===void 0?1:i,c=s===void 0?200:s,u=256,l=yi(n,t,r),f=new Uint8Array(u*u*4),p=u/2,d=u*u,y=new Float32Array(d);let x=1,m=0;for(let v=0;v<d;v++){const A=v%u,_=v/u|0,R=(A+.5)/u,L=(_+.5)/u,N=l(R+5.2,L+1.3,2)-.5,j=l(R+9.7,L+8.1,2)-.5,H=y[v]=l(R+N*.45,L+j*.45);H<x&&(x=H),H>m&&(m=H)}const M=m-x||1;for(let v=0;v<u;v++)for(let A=0;A<u;A++){const _=(y[v*u+A]-x)/M,R=Math.hypot((A+.5-p)/p,(v+.5-p)/p),L=Math.pow(Math.max(0,1-R),a);let N=Math.max(0,(_-(1-o))/(o||1));N=xn(Math.min(1,N))*L,Se(f,(v*u+A)*4,N)}let h=0;for(let v=0;v<d;v++)h=Math.max(h,f[v*4+3]);if(h>0&&h<c){const v=c/h;for(let A=0;A<d;A++)f[A*4+3]=Math.round(Math.min(255,f[A*4+3]*v))}const g={width:u,height:u,rgba:f};return u===e?g:vi(g,e,e)}function oo(e,n){const t=e,r=yi(3,5,n??23),o=new Uint8Array(t*t*4),i=t*t,s=new Float32Array(i);let a=1,c=0;for(let p=0;p<i;p++){const d=p%t,y=p/t|0,x=(d+.5)/t,m=(y+.5)/t,M=r(x+2.1,m+4.7,2)-.5,h=r(x+6.3,m+1.9,2)-.5,g=s[p]=r(x+M*.28,m+h*.55);g<a&&(a=g),g>c&&(c=g)}const u=c-a||1;for(let p=0;p<t;p++)for(let d=0;d<t;d++){const y=(p+.5)/t,x=(d+.5)/t*2-1,m=.1+.52*Math.pow(y,1.25),M=(s[p*t+d]-a)/u,h=ae(x/(m||.01),.55)*ae(y-.58,.42);let g=xn(Math.min(1,Math.max(0,(M-.18)/.72)))*h;g*=y<.06?y/.06:1,Se(o,(p*t+d)*4,g)}let l=0;for(let p=0;p<i;p++)l=Math.max(l,o[p*4+3]);if(l>0&&l<220){const p=220/l;for(let d=0;d<i;d++)o[d*4+3]=Math.round(Math.min(255,o[d*4+3]*p))}const f=jn({width:t,height:t,rgba:o},.08);return t===e?f:vi(f,e,e)}function io(e,n,t,r){const o=new Uint8Array(e*n*4),i=e/t,s=n/r;for(let a=0;a<n;a++)for(let c=0;c<e;c++){const u=Math.floor(c/i),l=Math.floor(a/s),f=(c+.5-u*i)/i*2-1,p=(a+.5-l*s)/s*2-1,d=1-Math.max(0,p)*.45,y=Math.hypot(f/(.52*d),p/.8),x=y>=1.12?0:ae(y,.48);Se(o,(a*e+c)*4,x)}return{width:e,height:n,rgba:o}}function xi(e){const n=new Uint8Array(e*e*4),t=pr(7),r=[];for(let o=0;o<11;o++)r.push({x:.14+t()*.72,y:.14+t()*.72,rx:.025+t()*.03,ry:.018+t()*.024,rot:t()*Math.PI});for(let o=0;o<e;o++)for(let i=0;i<e;i++){const s=(i+.5)/e,a=(o+.5)/e;let c=0;for(const u of r){const l=s-u.x,f=a-u.y,p=Math.cos(u.rot),d=Math.sin(u.rot),y=(l*p+f*d)/u.rx,x=(-l*d+f*p)/u.ry,m=ae(Math.hypot(y,x),.55);m>c&&(c=m)}Se(n,(o*e+i)*4,c)}return{width:e,height:e,rgba:n}}function hr(e,n){const t=n??19,r=pr(t),o=p=>Math.min(.86,Math.max(.14,p)),i=5+t%4,s=[];let a=o(.5+(r()-.5)*.16);for(let p=0;p<=i;p++){const d=.06+p/i*.86;p>0&&(a=o(a+(r()-.5)*.32)),s.push([a,d])}const c=[];for(let p=0;p<s.length-1;p++)c.push([s[p],s[p+1],1]);const u=1+t%2;for(let p=0;p<u;p++){const d=1+(t+p*3)%Math.max(1,s.length-2),y=s[d],x=[y];let m=y[0],M=y[1];const h=2+t%2;for(let g=0;g<h;g++)m=o(m+(r()-.5)*.36),M=Math.min(.92,M+.1+r()*.08),x.push([m,M]);for(let g=0;g<x.length-1;g++)c.push([x[g],x[g+1],.45+p*.1])}const l=new Uint8Array(e*e*4),f=Math.max(2,Math.round(e*.04));for(let p=0;p<e;p++)for(let d=0;d<e;d++){const y=(d+.5)/e,x=(p+.5)/e;let m=9,M=0;for(const[g,v,A]of c){const _=v[0]-g[0],R=v[1]-g[1],L=_*_+R*R||1e-8,N=Math.max(0,Math.min(1,((y-g[0])*_+(x-g[1])*R)/L)),j=Math.hypot(y-(g[0]+_*N),x-(g[1]+R*N));j/A<m&&(m=j/A,M=A)}const h=.95*ae(m,.012)+.3*ae(m,.05)*M;Se(l,(p*e+d)*4,Math.min(1,h)*sn(d,p,e,f))}return{width:e,height:e,rgba:l}}function so(e,n){const t=new Uint8Array(e*n*4);for(let r=0;r<n;r++)for(let o=0;o<e;o++){const i=(o+.5-e/2)/(e/2),s=(r+.5-n/2)/(n/2),a=ae(i,.34)*Math.exp(-Math.max(0,-s-.05)*4.2)*(s<.1?1:Math.max(0,1-s*4)),c=Math.hypot(i/.34,(s-.42)/.3),u=c>=1?0:ae(c,.5);Se(t,(r*e+o)*4,Math.max(a,u))}return{width:e,height:n,rgba:t}}function gc(e){return Ot(e,{r:.1,w:1},{r:.3,w:.16})}function ao(e,n){const t=new Uint8Array(e*n*4);for(let r=0;r<n;r++){const o=(r+.5)/n,i=xn(Math.min(1,Math.min(o/.08,(1-o)/.08))),s=ae(o-.46,.24)*i,a=.5*(1-xn(Math.min(1,Math.max(0,(o-.42)/.5)))*.6);for(let c=0;c<e;c++){const u=(c+.5-e/2)/(e/2);Se(t,(r*e+c)*4,ae(Math.abs(u)/(a||.01),.5)*s)}}return{width:e,height:n,rgba:t}}function wi(e){const n=new Uint8Array(e*e*4),t=e/2,r=Math.max(2,Math.round(e*.04));for(let o=0;o<e;o++)for(let i=0;i<e;i++){const s=(i+.5-t)/t,a=(o+.5-t)/t,c=ae(Math.hypot(s,a),.42),u=ae(Math.hypot(s-.34,a),.36),l=Math.max(0,c-u*1.08)*sn(i,o,e,r);Se(n,(o*e+i)*4,l)}return{width:e,height:e,rgba:n}}function Mi(e){const n=new Uint8Array(e*e*4),t=e/2,r=Math.max(2,Math.round(e*.04));for(let o=0;o<e;o++)for(let i=0;i<e;i++){const s=(i+.5-t)/t,a=(o+.5-t)/t;let c=ae(Math.hypot(s,a),.08);for(let u=0;u<6;u++){const l=u*Math.PI/3,f=Math.cos(l),p=Math.sin(l),d=s*f+a*p,y=-s*p+a*f;if(d<0)continue;const x=Math.max(0,1.02-d/.72);c+=ae(y,.028)*ae(d,.5)*x,c+=.55*ae(y-(d-.28)*.65,.02)*ae(d-.28,.12)*x,c+=.55*ae(y+(d-.28)*.65,.02)*ae(d-.28,.12)*x,c+=.4*ae(y-(d-.48)*.7,.016)*ae(d-.48,.08)*x,c+=.4*ae(y+(d-.48)*.7,.016)*ae(d-.48,.08)*x}Se(n,(o*e+i)*4,Math.min(1,c)*sn(i,o,e,r))}return{width:e,height:e,rgba:n}}function _i(e,n){const t=new Uint8Array(e*e*4),r=e/2,o=Math.max(2,Math.round(e*.04)),i=Math.abs(n|0)%3;for(let s=0;s<e;s++)for(let a=0;a<e;a++){const c=(a+.5-r)/r*1.55,u=(s+.5-r)/r*1.55,l=Math.abs(Math.abs(c)+Math.abs(u)-.55);let f=ae(l,.016);i===0?(f+=ae(c,.012)*ae(u,.38),f+=ae(u,.012)*ae(c,.38)):i===1?(f+=ae(c-u,.012)*ae(c+u,.36),f+=ae(c+u,.012)*ae(c-u,.36)):(f+=ae(Math.hypot(c,u)-.26,.014),f+=ae(c,.012)*ae(u,.22)),Se(t,(s*e+a)*4,Math.min(1,f)*sn(a,s,e,o))}return jn({width:e,height:e,rgba:t},.03)}function co(e){let n=0;const t=String(e);for(let r=0;r<t.length;r++)n=n*31+t.charCodeAt(r)|0;return n}function Ai(e){const n=new Uint8Array(e*e*4),t=e/2,r=Math.max(2,Math.round(e*.03));for(let o=0;o<e;o++)for(let i=0;i<e;i++){const s=(i+.5-t)/t,a=(o+.5-t)/t,c=Math.hypot(s,a),u=ae(c,.07)+.85*ae(s,.62)*ae(a,.045)+.22*ae(s,.92)*ae(a,.018);Se(n,(o*e+i)*4,Math.min(1,u)*sn(i,o,e,r))}return{width:e,height:e,rgba:n}}const Hn={"particle/halo_6":()=>Ot(256,{r:.14,w:1},{r:.4,w:.17}),"particle/normal_splash":()=>Mt(gi(256),3.2),"particle/drop_normal":()=>Mt(ao(128,512),3.4),"particle/normal_ring_smooth":()=>Mt(ro(256,.55,.12),3.1),"particle/normal_pinch_rotate":()=>Mt(lc(256),2.8),"particle/water/rain_drops_sheet_normal":()=>Mt(io(256,512,2,4),3.6),"particle/bubbles/bubble1normal":()=>Mt(Wn(256,1),3.2),"particle/bubbles/bubble2_normal":()=>Mt(Wn(256,2),3.2),"particle/sharp_halo_normal":()=>Mt(zn(256,[{r:.035,w:1},{r:.09,w:.45},{r:.22,w:.08}]),3.4),"particle/beam/beam_0":()=>Rt(128,512,.46,!0),"particle/beam/beam_1":()=>Rt(128,512,.34,!0),"particle/beam/beam_2":()=>Rt(128,512,.22,!0),"particle/beam/beam_2_fade":()=>Rt(128,512,.24,!1),"particle/light/light_shafts_0":()=>Rt(128,512,.42,!0),"particle/light/light_shafts_1":()=>Rt(128,512,.3,!0),"particle/light/light_shafts_3":()=>Rt(128,512,.26,!0),"particle/light/light_shafts_5":()=>Rt(128,512,.23,!0),"particle/light/light_shafts_6":()=>Rt(128,512,.2,!0),"particle/nature/rosepetals":()=>mi(256),"particle/nature/leaves":()=>He(256,0),"particle/nature/leaves1":()=>He(256,1),"particle/nature/leaves2":()=>He(256,2),"particle/nature/leaves3":()=>He(256,3),"particle/nature/leaves5":()=>He(256,5),"particle/nature/leaves6":()=>He(256,6),"particle/nature/leaves7":()=>He(256,7),"particle/nature/leaves8":()=>He(256,8),"particle/nature/snow":()=>Mi(256),"particle/halo":()=>Ot(256,{r:.12,w:1},{r:.3,w:.15}),"particle/halo_1":()=>Ot(256,{r:.1,w:1},{r:.3,w:.13}),"particle/halo_2":()=>Ot(256,{r:.2,w:.9},{r:.44,w:.2}),"particle/halo_3":()=>zn(256,[{r:.045,w:1},{r:.13,w:.85},{r:.36,w:.15}]),"particle/halo_4":()=>Ot(256,{r:.085,w:1},{r:.28,w:.12}),"particle/halo_5":()=>zn(256,[{r:.04,w:1},{r:.11,w:.8},{r:.34,w:.17}]),"particle/sharp_halo":()=>zn(256,[{r:.035,w:1},{r:.09,w:.45},{r:.22,w:.08}]),"particle/chromaticdot":()=>gc(128),"particle/light/flare_0":()=>$t(256,6,.58,10,.08),"particle/light/flare_1":()=>$t(512,4,.62,14,.07),"particle/light/flare_2":()=>Ai(256),"particle/drop":()=>ao(128,512),"particle/nature/rain1":()=>pi(128,512,10,1,.78),"particle/nature/rain2":()=>pi(128,512,10,1.6,.66),"particle/water/rain_drops_sheet":()=>io(256,512,2,4),"particle/fog/fog1":()=>Kt(512,4,5,1,.4,.9,150),"particle/fog/fog2":()=>Kt(512,3,5,2,.45,.8,140),"particle/fog/fog3":()=>Kt(512,6,4,3,.36,1,150),"particle/smoke/smoke1":()=>Kt(512,3,5,7,.55,1.5,130),"particle/smoke/smoke2":()=>Kt(512,2,5,11,.6,1.7,120),"particle/smoke/smoke2light":()=>Kt(512,2,5,13,.4,1.7,110),"particle/misc/wave":()=>ro(512,.72,.085),"particle/misc/star_0":()=>$t(256,5,.62,8,.1),"particle/bubbles/bubble1":()=>Wn(256,1),"particle/bubbles/bubble2":()=>Wn(256,2),"particle/bubbles/bubble3":()=>Wn(256,3),"particle/debris/debris1":()=>xi(128),"particle/lightning/lightning1":()=>hr(256,3),"particle/lightning/lightning2":()=>hr(256,11),"particle/lightning/lightning3":()=>hr(256,19),"particle/fire/fire1":()=>oo(256,23),"particle/fire/fire2":()=>oo(256,41),"particle/star":()=>$t(256,4,.58,12,.09),"particle/shape/circle_wind":()=>bi(256),"particle/sickle":()=>wi(256),"particle/magic/glyph_4":()=>_i(256,4),"@sparkle":()=>$t(256,4,.6,16,.08),"@star":()=>$t(256,5,.62,8,.1),"@trail":()=>so(128,256)};function Ti(e){const n=String(e).toLowerCase();if(/normal/.test(n)){const t=hc(e);return t?()=>Mt(mc(t),2.8):()=>Mt(gi(128),2.6)}return/rosepetal|petal|sakura|blossom/.test(n)?()=>mi(256):/leaf|leaves|foliage/.test(n)?/leaves8/.test(n)?()=>He(256,8):/leaves7/.test(n)?()=>He(256,7):/leaves6/.test(n)?()=>He(256,6):/leaves5/.test(n)?()=>He(256,5):/leaves3/.test(n)?()=>He(256,3):/leaves2/.test(n)?()=>He(256,2):/leaves1/.test(n)?()=>He(256,1):()=>He(256,0):/circle_wind|windcircle/.test(n)?()=>bi(256):/fog|cloud|mist|vapor/.test(n)?()=>Kt(512,4,5,5,.4,.9,150):/smoke/.test(n)?()=>Kt(512,3,5,8,.55,1.5,130):/beam|shaft|ray|godray/.test(n)?()=>Rt(128,512,.3,!0):/flare/.test(n)?()=>Ai(256):/bubble/.test(n)?()=>hi(256,1):/ring|wave/.test(n)?()=>ro(512,.72,.085):/fire|flame|ember|ash/.test(n)?()=>oo(256,co(n)):/sickle|crescent|moon/.test(n)?()=>wi(256):/glyph|magic|rune/.test(n)?()=>_i(256,co(n)):/snowflake|雪花|snow/.test(n)?()=>Mi(256):/流星|meteor|shooting/.test(n)?()=>so(128,256):/star|星/.test(n)?()=>$t(256,5,.62,8,.1):/sparkle|glint|twinkle/.test(n)?()=>$t(256,4,.6,16,.08):/rain_drops_sheet|drops_sheet/.test(n)?()=>io(256,512,2,4):/drop|rain/.test(n)?()=>ao(128,512):/debris|dirt|rock/.test(n)?()=>xi(128):/lightning|bolt|arc/.test(n)?()=>hr(256,co(n)):/note|music/.test(n)?()=>$t(256,4,.55,8,.12):/trail|streak/.test(n)?()=>so(128,256):()=>Ot(256,{r:.12,w:1},{r:.3,w:.15})}function bc(e){if($n.has(e))return $n.get(e);let n=null;const t=to.get(e);if(t)try{n=t()}catch{n=null}if(!n&&dr)try{n=dr(e)}catch{n=null}if(!n&&Hn[e])try{n=Hn[e]()}catch{n=null}if(!n)try{n=Ti(e)()}catch{n=null}return n||(n=Ot(256,{r:.12,w:1},{r:.3,w:.15})),$n.set(e,n),n}function yc(e){return typeof e=="string"&&e.indexOf("particle/")===0}const vc=Object.freeze(Object.defineProperty({__proto__:null,buildBuiltinParticleTexture:bc,builtinParticleFrames:cc,isBuiltinParticleTextureName:yc,listBuiltinParticleTextureNames:ac,particleNormalNameForAlbedo:pc,prepareParticleNormalTexture:fc,resetParticleTextureFactories:sc,setParticleTextureFactory:oc,setParticleTextureProvider:ic},Symbol.toStringTag,{value:"Module"})),Si=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);function Qt(e,n,t){const r=t||new Float32Array(16);for(let o=0;o<4;o++)for(let i=0;i<4;i++)r[o*4+i]=e[i]*n[o*4]+e[4+i]*n[o*4+1]+e[8+i]*n[o*4+2]+e[12+i]*n[o*4+3];return r}function Ei(e){const n=[];for(let r=0;r<4;r++)n.push([e[r],e[4+r],e[8+r],e[12+r],0,0,0,0]),n[r][4+r]=1;for(let r=0;r<4;r++){let o=r;for(let a=r+1;a<4;a++)Math.abs(n[a][r])>Math.abs(n[o][r])&&(o=a);const i=n[r];n[r]=n[o],n[o]=i;const s=n[r][r];if(Math.abs(s)<1e-12)return Float32Array.from(Si);for(let a=0;a<8;a++)n[r][a]/=s;for(let a=0;a<4;a++){if(a===r)continue;const c=n[a][r];if(c!==0)for(let u=0;u<8;u++)n[a][u]-=c*n[r][u]}}const t=new Float32Array(16);for(let r=0;r<4;r++)for(let o=0;o<4;o++)t[r*4+o]=n[o][4+r];return t}function lo(e,n,t,r,o,i,s,a,c,u){const l=u||new Float32Array(16),f=Math.cos(r),p=Math.sin(r),d=Math.cos(o),y=Math.sin(o),x=Math.cos(i),m=Math.sin(i);return l[0]=x*d*s,l[1]=m*d*s,l[2]=-y*s,l[3]=0,l[4]=(x*y*p-m*f)*a,l[5]=(m*y*p+x*f)*a,l[6]=d*p*a,l[7]=0,l[8]=(x*y*f+m*p)*c,l[9]=(m*y*f-x*p)*c,l[10]=d*f*c,l[11]=0,l[12]=e,l[13]=n,l[14]=t,l[15]=1,l}function Xn(e,n){const t=[];for(;n<e.byteLength;){const o=e.getUint8(n++);if(o===0)break;t.push(o)}let r="";try{r=new TextDecoder("utf-8").decode(new Uint8Array(t))}catch{r=String.fromCharCode.apply(null,t)}return{value:r,next:n}}function mr(e,n,t=0){const r=[];for(let o=0;o<n.length;o++)r.push(n.charCodeAt(o));e:for(let o=t;o<=e.length-r.length;o++){for(let i=0;i<r.length;i++)if(e[o+i]!==r[i])continue e;return o}return-1}function xc(e){const n=new DataView(e.buffer,e.byteOffset,e.byteLength),t=String.fromCharCode.apply(null,Array.from(e.subarray(0,8)));if(!t.startsWith("MDLV"))throw new Error("\u4E0D\u662F MDL: "+t);const r=Xn(n,21),i=parseInt(t.slice(4),10)>=23?[{lenOff:32,stride:80,uv:72,bone:40,weight:56},{lenOff:32,stride:48,uv:40,bone:-1,weight:-1}]:[{lenOff:8,stride:52,uv:44,bone:12,weight:28},{lenOff:4,stride:52,uv:44,bone:12,weight:28},{lenOff:32,stride:80,uv:72,bone:40,weight:56}];let s=null,a=0,c=0;for(const X of i){const ie=r.next+X.lenOff;if(ie+4>e.byteLength)continue;const J=n.getUint32(ie,!0);if(J>0&&J%X.stride===0&&ie+4+J<=e.byteLength){s=X,a=J,c=ie;break}}if(!s)throw new Error("\u9876\u70B9\u533A\u957F\u5EA6\u5F02\u5E38\uFF08"+t+"\uFF0C\u5DF2\u8BD5 stride "+i.map(X=>X.stride).join("/")+"\uFF09");const u=c+4,l=a/s.stride,f=new Float32Array(l*3),p=new Float32Array(l*2),d=new Float32Array(l*4),y=new Float32Array(l*4);for(let X=0;X<l;X++){const ie=u+X*s.stride;if(f[X*3]=n.getFloat32(ie,!0),f[X*3+1]=n.getFloat32(ie+4,!0),f[X*3+2]=n.getFloat32(ie+8,!0),p[X*2]=n.getFloat32(ie+s.uv,!0),p[X*2+1]=n.getFloat32(ie+s.uv+4,!0),s.bone>=0&&s.weight>=0)for(let J=0;J<4;J++)d[X*4+J]=n.getUint32(ie+s.bone+J*4,!0),y[X*4+J]=n.getFloat32(ie+s.weight+J*4,!0);else d[X*4]=0,y[X*4]=1}const x=n.getUint32(u+a,!0),m=u+a+4,M=l>65535&&x%4===0,h=M?x/4:x/2,g=M?new Uint32Array(h):new Uint16Array(h);if(M)for(let X=0;X<h;X++)g[X]=n.getUint32(m+X*4,!0);else for(let X=0;X<h;X++)g[X]=n.getUint16(m+X*2,!0);const v=Mc(e,n),A=_c(e,n,v.length),_=Tc(e,n,v),R=wc(e,n,v.length),L=[],N=[],j=[];if(v.length>0){const X=v.map((J,Z)=>{const te=J.matrix,le=Math.hypot(te[0],te[1]),Fe=Math.hypot(te[4],te[5]);return j[Z]=Float32Array.from([te[12],te[13],te[14],0,0,Math.atan2(te[1],te[0]),le||1,Fe||1,te[10]||1]),Float32Array.from(te)});for(let J=0;J<v.length;J++){const Z=j[J],te=v[J].matrix;Math.hypot(Z[0]-te[12],Z[1]-te[13])>.001&&(X[J]=lo(Z[0],Z[1],Z[2],Z[3],Z[4],Z[5],Z[6],Z[7],Z[8],new Float32Array(16)))}const ie=[];for(let J=0;J<v.length;J++){const Z=v[J].parent;ie[J]=Z>=0&&Z<J?Qt(ie[Z],X[J]):Float32Array.from(X[J])}for(let J=0;J<v.length;J++)L[J]=Ei(ie[J]);if(_){const J=[];for(let Z=0;Z<v.length;Z++){const te=v[Z].parent;J[Z]=te>=0&&te<Z?Qt(J[te],_[Z]):Float32Array.from(_[Z])}for(let Z=0;Z<v.length;Z++)N[Z]=Qt(J[Z],L[Z])}}let H=1/0,K=-1/0,O=1/0,W=-1/0;for(let X=0;X<l;X++){const ie=f[X*3],J=f[X*3+1];ie<H&&(H=ie),ie>K&&(K=ie),J<O&&(O=J),J>W&&(W=J)}return{magic:t,materialPath:r.value,vertexCount:l,positions:f,uvs:p,boneIdx:d,weights:y,indexCount:h,indexType:M?"u32":"u16",indices:g,bones:v,animations:A,animBound:Ac(A,v),invBindWorld:L,bindTRS:j.length>0?j:null,attachments:R.length>0?R:null,restCorrection:N.length>0?N:null,bounds:{minX:H,maxX:K,minY:O,maxY:W}}}function wc(e,n,t){const r=mr(e,"MDAT");if(r<0)return[];const o=n.getUint16(r+13,!0);if(o<=0||o>256)return[];const i=[];let s=r+15;for(let a=0;a<o&&!(s+2>e.length);a++){const c=n.getUint16(s,!0),u=Xn(n,s+2);if(u.next+64>e.length)break;const l=new Float32Array(16);for(let f=0;f<16;f++)l[f]=n.getFloat32(u.next+f*4,!0);c<t&&i.push({bone:c,name:u.value,matrix:l}),s=u.next+64}return i}function Mc(e,n){const t=mr(e,"MDLS");if(t<0)return[];const r=n.getUint32(t+13,!0);if(r<=0||r>1024)return[];const o=[];let i=t+17;for(let s=0;s<r;s++){if(i+77>n.byteLength)return o;const a=n.getUint32(i+1,!0),c=n.getInt32(i+5,!0),u=new Float32Array(16);for(let f=0;f<16;f++)u[f]=n.getFloat32(i+13+f*4,!0);const l=Xn(n,i+13+64);o.push({id:a,parent:c>=0&&c<r?c:-1,matrix:u}),i=l.next}return o}function _c(e,n,t){const r=mr(e,"MDLA");if(r<0)return[];let o=r+9;const i=n.getUint32(o,!0);o+=4;const s=n.getUint32(o,!0);if(o+=4,s<=0||s>256)return[];const a=[];for(let c=0;c<s&&!(o+16>n.byteLength);c++){const u=n.getUint32(o,!0);o+=8;const l=Xn(n,o);o=l.next;const f=Xn(n,o);if(o=f.next,o+16>n.byteLength)break;const p=n.getFloat32(o,!0);o+=4;const d=n.getUint32(o,!0);o+=8;const y=n.getUint32(o,!0);if(o+=4,y>1024)break;const x=[];for(let m=0;m<y&&!(o+8>n.byteLength);m++){o+=4;const M=n.getUint32(o,!0);o+=4;const h=Math.floor(M/36);if(o+M>n.byteLength)break;const g=new Float32Array(h*9);for(let v=0;v<h;v++){const A=o+v*36;for(let _=0;_<9;_++)g[v*9+_]=n.getFloat32(A+_*4,!0)}o+=M,x.push({frameCount:h,keyframes:g})}if(o+=35,x.length>0&&d>0&&p>0&&a.push({id:u,name:l.value,mode:f.value,fps:p,frameCount:d,duration:d/p,tracks:x}),o>=i)break}return a}function Ac(e,n){let t=0,r=0;for(const o of e)for(let i=0;i<o.tracks.length;i++){const s=o.tracks[i];if(!s)continue;const a=n[i],c=a?a.matrix[12]:0,u=a?a.matrix[13]:0,l=s.keyframes;for(let f=0;f<s.frameCount;f++){const p=Math.abs(l[f*9]-c),d=Math.abs(l[f*9+1]-u);p>t&&(t=p),d>r&&(r=d)}}return{x:t,y:r}}function Tc(e,n,t){if(t.length===0)return null;const r=mr(e,"MDLE");if(r<0)return null;const o=r+8+1+4+4;if(o+t.length*64>n.byteLength)return null;const i=[];for(let s=0;s<t.length;s++){const a=new Float32Array(16);for(let c=0;c<16;c++)a[c]=n.getFloat32(o+s*64+c*4,!0);i.push(a)}return i}function Sc(e,n,t,r){const o=e.frameCount;if(o===0)return r[0]=0,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=0,r[6]=1,r[7]=1,r[8]=1,r;const i=t*n.fps;let s,a,c;if(n.mode==="loop"){const d=Math.max(1,o-1),y=(i%d+d)%d;s=Math.floor(y),a=(s+1)%o,c=y-s}else if(n.mode==="mirror"){const d=Math.max(1,o-1),y=d*2;let x=(i%y+y)%y;x>d&&(x=y-x),s=Math.floor(x),a=Math.min(s+1,o-1),c=x-s}else{const d=Math.min(Math.max(i,0),o-1);s=Math.floor(d),a=Math.min(s+1,o-1),c=d-s}const u=e.keyframes,l=s*9,f=a*9,p=1-c;for(let d=0;d<9;d++)if(d>=3&&d<=5){let y=u[f+d]-u[l+d];y>Math.PI?y-=2*Math.PI:y<-Math.PI&&(y+=2*Math.PI),r[d]=u[l+d]+y*c}else r[d]=u[l+d]*p+u[f+d]*c;return r}function Ec(e,n,t){const r=e.bindTRS&&e.bindTRS[n];if(r)return t.set(r),t;const o=e.bones[n].matrix;return t[0]=o[12],t[1]=o[13],t[2]=o[14],t[3]=0,t[4]=0,t[5]=Math.atan2(o[1],o[0]),t[6]=Math.hypot(o[0],o[1])||1,t[7]=Math.hypot(o[4],o[5])||1,t[8]=o[10]||1,t}function uo(e,n,t,r){const o=e.bones,i=o.length;if(i===0)return null;const s=!!(r&&r.size>0);if(!e._skin||e._skin.length!==i*16){e._skin=new Float32Array(i*16),e._local=[],e._world=[],e._tmp=new Float32Array(16),e._tmp2=new Float32Array(16);for(let p=0;p<i;p++)e._local.push(new Float32Array(16)),e._world.push(new Float32Array(16))}const a=Array.isArray(t)&&t.length>0,c=[];if(a)for(const p of t){if(p.visible===!1||p.visible===0)continue;const d=e.animations.find(y=>y.id===p.animation);d&&c.push({anim:d,additive:!!p.additive,blend:typeof p.blend=="number"?p.blend:1,rate:typeof p.rate=="number"?p.rate:1})}if(c.length===0&&!a){const p=e.animations[0];if(p)c.push({anim:p,additive:!1,blend:1,rate:1});else if(!s)return null}const u=e._trsBase||(e._trsBase=new Float32Array(9)),l=e._trsAcc||(e._trsAcc=new Float32Array(9)),f=e._trsSmp||(e._trsSmp=new Float32Array(9));for(let p=0;p<i;p++){Ec(e,p,u),l.set(u);let d=!1,y=0;for(const m of c){const M=m.anim.tracks[p];if(!M)continue;Sc(M,m.anim,n*m.rate,f);const h=m.blend;if(m.additive){for(let g=0;g<9;g++){let v=f[g]-u[g];g>=3&&g<=5&&(v>Math.PI?v-=2*Math.PI:v<-Math.PI&&(v+=2*Math.PI)),l[g]+=v*h}y+=h}else for(let g=0;g<9;g++)l[g]=l[g]*(1-h)+f[g]*h;d=!0}if(y>1)for(let m=0;m<9;m++)l[m]=u[m]+(l[m]-u[m])/y;const x=s?r.get(p):void 0;x&&(l[0]=x[0],l[1]=x[1],l[2]=x[2],d=!0),d?lo(l[0],l[1],l[2],l[3],l[4],l[5],l[6],l[7],l[8],e._local[p]):lo(u[0],u[1],u[2],u[3],u[4],u[5],u[6],u[7],u[8],e._local[p])}for(let p=0;p<i;p++){const d=o[p].parent;d>=0&&d<p?Qt(e._world[d],e._local[p],e._world[p]):e._world[p].set(e._local[p])}for(let p=0;p<i;p++)Qt(e._world[p],e.invBindWorld[p],e._tmp),e._skin.set(e._tmp,p*16);return e._skin}function Pi(e,n){return!e||!e.invBindWorld||!(n>=0&&n<e.invBindWorld.length)?null:Ei(e.invBindWorld[n])}function Pc(e,n){return Qt(e,n)}function Ci(e,n){if(!e||!e.attachments||typeof n!="string"||n===""||!e._world)return null;for(const t of e.attachments)if(t.name===n)return t.bone<0||t.bone>=e._world.length?null:Qt(e._world[t.bone],t.matrix);return null}function Li(e,n){if(!e||!e.attachments||typeof n!="string"||n==="")return null;for(const t of e.attachments){if(t.name!==n)continue;const r=Pi(e,t.bone);return r?Qt(r,t.matrix):null}return null}function fo(e,n,t){const r=e&&e.angles&&e.angles[2]||0,o=e&&e.scale?e.scale[0]:1,i=e&&e.scale?e.scale[1]:1,s=r*Math.PI/180,a=Math.cos(s),c=Math.sin(s),u=n*o,l=t*i;return[u*a-l*c,u*c+l*a]}function Cc(e){const n=new Map,t=new Map;for(const i of e){if(!i||i.id===void 0||i.id===null||(n.set(i.id,i),i.parentId===void 0||i.parentId===null))continue;const s=t.get(i.parentId);s?s.push(i):t.set(i.parentId,[i])}const r=(i,s)=>{const a=t.get(i.id);if(a)for(const c of a)s.push(c),r(c,s)},o=[];for(const i of e){const s=i&&i.attachment;if(typeof s!="string"||s==="")continue;const a=n.get(i.parentId);if(!a||!a.puppet)continue;const c=Li(a.puppet,s);if(!c)continue;const u=c[12],l=c[13],f=fo(a,u,l),p=[];r(i,p),i.origin[0]+=f[0],i.origin[1]+=f[1];for(const d of p)d.origin[0]+=f[0],d.origin[1]+=f[1];i.parallaxDepth=a.parallaxDepth?a.parallaxDepth.slice():null;for(const d of p)d.parallaxDepth=i.parallaxDepth?i.parallaxDepth.slice():null;i.attachBindDelta=[f[0],f[1]],o.push({layer:i,parent:a,name:s,bindX:u,bindY:l,desc:p})}for(const i of o){i.baseX=i.layer.origin[0],i.baseY=i.layer.origin[1],i.subtree=[{layer:i.layer,x:i.layer.origin[0],y:i.layer.origin[1]}];for(const s of i.desc)i.subtree.push({layer:s,x:s.origin[0],y:s.origin[1]});for(const s of i.subtree)s.layer.attachBase||(s.layer.attachBase=[s.x,s.y])}return o}function Lc(e,n,t){if(!e||e.length===0)return;const r=new Set,o=[];for(const a of e){const c=a.parent&&a.parent.puppet;if(!c){o.push(null);continue}if(!r.has(c)){r.add(c);const l=typeof t=="function"?t(a.parent):null;uo(c,n,a.parent.animationLayers,l)}const u=Ci(c,a.name);if(!u){o.push(null);continue}o.push(fo(a.parent,u[12]-a.bindX,u[13]-a.bindY))}const i=a=>{const c=a.layer.attachBase;return c||[a.x,a.y]},s=new Set;for(const a of e){const c=a.subtree||[{layer:a.layer,x:a.baseX,y:a.baseY}];for(const u of c){if(s.has(u.layer))continue;s.add(u.layer);const l=i(u);u.layer.origin[0]=l[0],u.layer.origin[1]=l[1]}}for(let a=0;a<e.length;a++){const c=e[a],u=o[a],l=c.subtree||[{layer:c.layer,x:c.baseX,y:c.baseY}];if(u)for(const f of l)f.layer.origin[0]+=u[0],f.layer.origin[1]+=u[1]}}const Rc=128,gr=24;function kc(e){const n=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS)||256,t=Math.floor((n-32)/4);return Math.max(gr,Math.min(Rc,t))}const Fc=e=>`#version 300 es
|
|
142
142
|
in vec3 a_pos;
|
|
143
143
|
in vec2 a_uv;
|
|
144
144
|
in vec4 a_bone;
|
|
@@ -164,7 +164,7 @@ void main() {
|
|
|
164
164
|
vec4 local = total > 0.0 ? skinned / total : p;
|
|
165
165
|
gl_Position = u_mvp * vec4(local.xy, 0.0, 1.0);
|
|
166
166
|
v_uv = a_uv;
|
|
167
|
-
}`,
|
|
167
|
+
}`,Nc=`#version 300 es
|
|
168
168
|
precision mediump float;
|
|
169
169
|
in vec2 v_uv;
|
|
170
170
|
uniform sampler2D u_tex;
|
|
@@ -173,12 +173,12 @@ out vec4 fragColor;
|
|
|
173
173
|
void main() {
|
|
174
174
|
vec4 t = texture(u_tex, v_uv);
|
|
175
175
|
fragColor = t * u_color;
|
|
176
|
-
}`;function
|
|
177
|
-
`);for(const _ of f)p.push(...l(_));let d=!1;if(n.limitrows&&n.maxrows>0&&p.length>n.maxrows&&(p=p.slice(0,n.maxrows),d=!0,n.limituseellipsis)){let _=p[n.maxrows-1];for(;_.length>0&&t(_+"\u2026")>u;)_=_.slice(0,-1);p[n.maxrows-1]=_+"\u2026"}const w=p.map(_=>t(_)),M=p.length*a,m=n.halign||"center",A=n.valign||"center",h=r/2,b=o/2,v=A==="top"?b:A==="bottom"?b-M:(o-M)/2;return{lines:p.map((_,F)=>{const R=w[F],k=m==="left"?h:m==="right"?h-R:(r-R)/2;return{text:_,width:R,x:k,y:v+F*a}}),lineHeight:a,totalH:M,truncated:d,boxW:r,boxH:o}}function Tc(e,n,t){const r=n.boxW,o=n.boxH,i=t.color||[1,1,1],s=t.alpha!==void 0?t.alpha:1,a=t.brightness!==void 0?t.brightness:1;e.font=t.font;try{e.letterSpacing=(t.spacing&&t.spacing[0]?t.spacing[0]:0)+"px"}catch{}if(e.textBaseline="middle",t.opaquebackground){const u=t.backgroundcolor||[0,0,0],l=t.backgroundbrightness!==void 0?t.backgroundbrightness:1;e.fillStyle=`rgba(${Math.round(u[0]*255*l)},${Math.round(u[1]*255*l)},${Math.round(u[2]*255*l)},${s})`,e.fillRect(0,0,r,o)}const c=(u,l,p)=>{e.fillStyle=p;for(const f of n.lines)e.fillText(f.text,f.x+u,f.y+n.lineHeight/2+l)};if(t.castshadow){const u=Math.max(1,(t.pointsize||24)/10);c(u,u,`rgba(0,0,0,${s*.75})`)}c(0,0,`rgba(${Math.round(i[0]*255*a)},${Math.round(i[1]*255*a)},${Math.round(i[2]*255*a)},${s})`)}const Ti=/^add[A-Z]/;function Si(){return{log:()=>{},warn:()=>{},error:()=>{},info:()=>{},debug:()=>{}}}function Ei(e){return new Proxy(e,{get(n,t,r){const o=Reflect.get(n,t,r);if(o==null&&typeof t=="string"&&t!=="then"){const i=()=>{};return n[t]=i,i}return o}})}function Mn(e,n){return()=>{}}function Pi(e,n){e.isScreensaver=!!n.isScreensaver,typeof n.isRunningInEditor=="boolean"&&(e.isRunningInEditor=n.isRunningInEditor),e.setInterval||(e.setInterval=n.setInterval||Mn),e.setTimeout||(e.setTimeout=n.setTimeout||Mn),e.clearTimeout||(e.clearTimeout=n.clearTimeout||(()=>{})),e.clearInterval||(e.clearInterval=n.clearInterval||(()=>{})),typeof n.openUserShortcut=="function"&&(e.openUserShortcut=n.openUserShortcut);const t=n.mediaControl||null;e.media={skipNext:()=>{if(t&&t.skipNext)return t.skipNext()},skipPrevious:()=>{if(t&&t.skipPrevious)return t.skipPrevious()},play:()=>{if(t&&t.play)return t.play()},pause:()=>{if(t&&t.pause)return t.pause()},playPause:()=>{if(t&&t.playPause)return t.playPause()},get snapshot(){return t&&t.snapshot?t.snapshot:null}};const r=n.windowTitle;Object.defineProperty(e,"windowTitle",{configurable:!0,enumerable:!0,get(){return r&&r.title?String(r.title):""}}),Object.defineProperty(e,"windowApp",{configurable:!0,enumerable:!0,get(){return r&&r.app?String(r.app):""}})}class he{constructor(n,t,r){if(n!==null&&typeof n=="object")this.x=n.x!==void 0?n.x:n.width||0,this.y=t!==void 0?t:n.y!==void 0?n.y:n.height||0,this.z=r!==void 0?r:n.z||0;else if(t===void 0&&r===void 0){const o=Number(n)||0;this.x=o,this.y=o,this.z=o}else this.x=Number(n)||0,this.y=Number(t)||0,this.z=Number(r)||0}add(n){const t=new he(n);return new he(this.x+t.x,this.y+t.y,this.z+t.z)}subtract(n){const t=new he(n);return new he(this.x-t.x,this.y-t.y,this.z-t.z)}multiply(n){return n&&typeof n=="object"?new he(this.x*n.x,this.y*n.y,this.z*n.z):new he(this.x*n,this.y*n,this.z*n)}divide(n){const t=(r,o)=>o===0?0:r/o;return n&&typeof n=="object"?new he(t(this.x,n.x),t(this.y,n.y),t(this.z,n.z)):new he(t(this.x,n),t(this.y,n),t(this.z,n))}copy(){return new he(this.x,this.y,this.z)}mix(n,t){const r=new he(n),o=Number(t),i=Number.isFinite(o)?o:0;return new he(this.x+(r.x-this.x)*i,this.y+(r.y-this.y)*i,this.z+(r.z-this.z)*i)}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}normalize(){const n=this.length();return n===0?new he(0,0,0):new he(this.x/n,this.y/n,this.z/n)}dot(n){const t=new he(n);return this.x*t.x+this.y*t.y+this.z*t.z}toString(){return this.x+" "+this.y+" "+this.z}}const Ci=he;function Li(e){if(e instanceof he||!e||typeof e!="object"||Array.isArray(e)||!("x"in e)&&!("y"in e)&&!("z"in e)||Object.getPrototypeOf(e)===he.prototype)return e;try{Object.setPrototypeOf(e,he.prototype)}catch{}return e}function Ri(e){return e&&e.cursorWorldPosition?e:{cursorWorldPosition:new he(0,0,0),cursorScreenPosition:new he(0,0,0),cursorPosition:new he(0,0,0),cursorPositionLast:new he(0,0,0),cursorLeftDown:!1}}function Sc(e,n,t){return new he(e||0,n||0,t||0)}function Ec(){const e={cursorWorldPosition:new he(0,0,0),cursorScreenPosition:new he(0,0,0),cursorPosition:new he(0,0,0),cursorPositionLast:new he(0,0,0),cursorLeftDown:!1};return e.update=function(n){return n&&(e.cursorWorldPosition.x=n.wx,e.cursorWorldPosition.y=n.originY!=null?n.originY:n.wy,e.cursorWorldPosition.z=0,e.cursorScreenPosition.x=n.screenX,e.cursorScreenPosition.y=n.screenY,e.cursorScreenPosition.z=0,e.cursorPosition.x=n.u,e.cursorPosition.y=n.v,e.cursorPosition.z=0,e.cursorPositionLast.x=n.lastU,e.cursorPositionLast.y=n.lastV,e.cursorPositionLast.z=0,e.cursorLeftDown=!!n.leftDown),e},e}const Fi={mix:(e,n,t)=>e+(n-e)*t,lerp:(e,n,t)=>e+(n-e)*t,clamp:(e,n,t)=>Math.min(t,Math.max(n,e)),saturate:e=>Math.min(1,Math.max(0,e)),smoothstep:(e,n,t)=>{const r=Math.min(1,Math.max(0,(t-e)/(n-e||1)));return r*r*(3-2*r)},smoothStep:(e,n,t)=>{const r=Math.min(1,Math.max(0,(t-e)/(n-e||1)));return r*r*(3-2*r)},random:(e,n)=>e===void 0?Math.random():e+Math.random()*((n===void 0?1:n)-e),randomInt:(e,n)=>Math.floor((e||0)+Math.random()*((n===void 0?1:n)+1-(e||0))),degrees:e=>e*180/Math.PI,radians:e=>e*Math.PI/180},ki={hsv2rgb:e=>{const n=e&&typeof e=="object"?e:{x:0,y:0,z:0},t=((Number(n.x)||0)%1+1)%1,r=Math.min(1,Math.max(0,Number(n.y)||0)),o=Math.min(1,Math.max(0,Number(n.z)||0)),i=Math.floor(t*6),s=t*6-i,a=o*(1-r),c=o*(1-s*r),u=o*(1-(1-s)*r),p=[[o,u,a],[c,o,a],[a,o,u],[a,c,o],[u,a,o],[o,a,c]][i%6];return{x:p[0],y:p[1],z:p[2]}},rgb2hsv:e=>{const n=e&&typeof e=="object"?e:{x:0,y:0,z:0},t=Number(n.x)||0,r=Number(n.y)||0,o=Number(n.z)||0,i=Math.max(t,r,o),s=Math.min(t,r,o),a=i-s;let c=0;return a>0&&(i===t?c=(r-o)/a/6:i===r?c=(2+(o-t)/a)/6:c=(4+(t-r)/a)/6,c<0&&(c+=1)),{x:c,y:i===0?0:a/i,z:i}}},Ni={add:(e,n)=>({x:(e.x||0)+(n.x||0),y:(e.y||0)+(n.y||0),z:(e.z||0)+(n.z||0)}),subtract:(e,n)=>({x:(e.x||0)-(n.x||0),y:(e.y||0)-(n.y||0),z:(e.z||0)-(n.z||0)}),scale:(e,n)=>({x:(e.x||0)*n,y:(e.y||0)*n,z:(e.z||0)*n}),length:e=>Math.hypot(e.x||0,e.y||0,e.z||0),dot:(e,n)=>(e.x||0)*(n.x||0)+(e.y||0)*(n.y||0)+(e.z||0)*(n.z||0),normalize:e=>{const n=Math.hypot(e.x||0,e.y||0,e.z||0)||1;return{x:(e.x||0)/n,y:(e.y||0)/n,z:(e.z||0)/n}},mix:(e,n,t)=>({x:(e.x||0)+((n.x||0)-(e.x||0))*t,y:(e.y||0)+((n.y||0)-(e.y||0))*t,z:(e.z||0)+((n.z||0)-(e.z||0))*t})},Ui=Object.freeze({PLAYBACK_STOPPED:0,PLAYBACK_PLAYING:1,PLAYBACK_PAUSED:2}),br=["mediaPropertiesChanged","mediaThumbnailChanged","mediaPlaybackChanged","mediaTimelineChanged","mediaStatusChanged","mediaLyricsChanged"],Pc=["scriptProperties","engine","WEMath","WEColor","WEVector","createScriptProperties","shared","console","process","globalThis","self","window","document","require","module","exports","fetch","XMLHttpRequest","Worker","importScripts","location","navigator","alert","confirm","prompt","setTimeout","setInterval","clearTimeout","clearInterval","requestAnimationFrame","cancelAnimationFrame","performance","Function","Vec3","Vec2","input","thisLayer","thisScene","thisObject","localStorage","MediaPlaybackEvent"],Cc=new RegExp(`(^[ \\t]*|;|\\})[ \\t]*(?:var|let|const)[ \\t]+(?=(?:${Pc.join("|")})\\b)`,"gm"),Lc={WEMath:!0,WEColor:!0,WEVector:!0};function Di(e){return typeof e!="string"?e:e.replace(/([!=])==(\s*)(['"])(-?\d+)\3/g,"$1=$2$3$4$3")}function Bi(e){return Di(e).replace(/\bimport\s*\*\s*as\s+(\w+)\s+from\s*['"]([^'"]+)['"]\s*;?/g,(n,t,r)=>{const o=String(r);return Lc[o]?t===o?"":`var ${t} = ${o};`:`var ${t} = {};`}).replace(/(^[ \t]*|;|\})[ \t]*import\s+(?:[^;'"]+\s+from\s+)?['"][^'"]*['"];?[ \t]*/gm,"$1").replace(/(^[ \t]*|;|\})[ \t]*export[ \t]+(?=(?:async[ \t]+)?function\b|(?:var|let|const)\b)/gm,"$1").replace(Cc,"$1")}function jn(e){return e!==null&&typeof e=="object"&&"value"in e?e.value:e}function Ii(e){const n=e||{width:1920,height:1080};return n.x!==void 0&&n.y!==void 0?n:{x:n.width,y:n.height,width:n.width,height:n.height}}function Rc(e,n,t={}){if(typeof e!="string"||e.length===0)return null;const r=Bi(e);if(r===e&&e.indexOf("update")<0)return null;const o={};if(n&&typeof n=="object")for(const[A,h]of Object.entries(n))o[A]=jn(h);const i=new Proxy(()=>i,{apply(){return i},get(A,h){if(h==="finish")return()=>o;if(typeof h=="string"&&Ti.test(h))return b=>(b&&typeof b=="object"&&typeof b.name=="string"&&!(b.name in o)&&(o[b.name]=jn(b.value)),i)}}),s={text:t.text!==void 0&&t.text!==null?String(t.text):"",font:t.font||"",pointsize:t.pointsize||24,color:(t.color||[1,1,1]).slice(),angles:(t.angles||[0,0,0]).slice(),scale:(t.scale||[1,1,1]).slice(),visible:t.visible!==!1,origin:vr(t.origin||[0,0,0])},a={registerAsset:()=>{},frametime:1/60,runtime:0,canvasSize:Ii(t.canvasSize),screenResolution:t.screenResolution||{x:1920,y:1080},timeOfDay:typeof t.timeOfDay=="number"?t.timeOfDay:0,userProperties:t.userProperties||{},AUDIO_RESOLUTION_16:16,AUDIO_RESOLUTION_32:32,AUDIO_RESOLUTION_64:64,setTimeout:t.setTimeout||Mn,clearTimeout:t.clearTimeout||(()=>{}),setInterval:t.setInterval||Mn,clearInterval:t.clearInterval||(()=>{}),openUserShortcut:t.openUserShortcut||(()=>{}),isRunningInEditor:!!t.isRunningInEditor,isScreensaver:!!t.isScreensaver};Pi(a,t);const c=t.audioViews;a.registerAudioBuffers=A=>{const h=Math.max(1,Math.min(64,Math.floor(Number(A)||0)));let b=c?c.get(h):void 0;return b||(b={left:new Float32Array(h),right:new Float32Array(h),average:new Float32Array(h)},c&&c.set(h,b)),b};const u={getLayer(A){const h=t.getLayerText?t.getLayerText(String(A)):void 0;return{text:h!=null?String(h):""}},createLayer(A){return{text:"",visible:!1,color:[0,0,0],alpha:1,pointsize:t.pointsize||24,font:t.font||"",origin:vr(t.origin||[0,0,0]),angles:[0,0,0],scale:[1,1,1]}},sortLayer:()=>{},getLayerIndex:()=>0},l=t.shared||{},p={console:Si()},f=Ri(t.inputView);let d;try{d=new Function("scriptProperties","engine","thisLayer","thisScene","WEMath","WEColor","WEVector","createScriptProperties","shared","console","process","globalThis","self","window","document","require","module","exports","fetch","XMLHttpRequest","Worker","importScripts","location","navigator","alert","confirm","prompt","setTimeout","setInterval","clearTimeout","clearInterval","requestAnimationFrame","cancelAnimationFrame","performance","Function","Vec3","Vec2","input","MediaPlaybackEvent",`"use strict";
|
|
176
|
+
}`;function Uc(e){const n=(u,l)=>{const f=e.createShader(u);if(e.shaderSource(f,l),e.compileShader(f),!e.getShaderParameter(f,e.COMPILE_STATUS))throw new Error("MDL \u7740\u8272\u5668\u7F16\u8BD1\u5931\u8D25: "+e.getShaderInfoLog(f));return f};let t=kc(e),r=null;for(;;){const u=e.createProgram();let l=!1;try{e.attachShader(u,n(e.VERTEX_SHADER,Fc(t))),e.attachShader(u,n(e.FRAGMENT_SHADER,Nc)),e.bindAttribLocation(u,0,"a_pos"),e.bindAttribLocation(u,1,"a_uv"),e.bindAttribLocation(u,2,"a_bone"),e.bindAttribLocation(u,3,"a_weight"),e.linkProgram(u),l=!!e.getProgramParameter(u,e.LINK_STATUS)}catch{l=!1}if(l){r=u;break}if(e.deleteProgram(u),t<=gr)throw new Error("MDL \u7740\u8272\u5668\u94FE\u63A5\u5931\u8D25\uFF08\u9AA8\u6570\u5DF2\u964D\u5230 "+gr+"\uFF09");t=Math.max(gr,t>>1)}const o=t,i={mvp:e.getUniformLocation(r,"u_mvp"),tex:e.getUniformLocation(r,"u_tex"),skin:e.getUniformLocation(r,"u_skin"),boneCount:e.getUniformLocation(r,"u_boneCount"),color:e.getUniformLocation(r,"u_color")},s=new Float32Array(o*16);for(let u=0;u<o;u++)s.set(Si,u*16);const a=new WeakMap;function c(u){let l=a.get(u);if(l)return l;const f=e.createVertexArray();e.bindVertexArray(f);const p=u.vertexCount,d=new Float32Array(p*13);for(let M=0;M<p;M++){const h=M*13;d[h]=u.positions[M*3],d[h+1]=u.positions[M*3+1],d[h+2]=u.positions[M*3+2],d[h+3]=u.uvs[M*2],d[h+4]=u.uvs[M*2+1];for(let g=0;g<4;g++)d[h+5+g]=u.boneIdx[M*4+g],d[h+9+g]=u.weights[M*4+g]}const y=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,y),e.bufferData(e.ARRAY_BUFFER,d,e.STATIC_DRAW);const x=52;e.enableVertexAttribArray(0),e.vertexAttribPointer(0,3,e.FLOAT,!1,x,0),e.enableVertexAttribArray(1),e.vertexAttribPointer(1,2,e.FLOAT,!1,x,12),e.enableVertexAttribArray(2),e.vertexAttribPointer(2,4,e.FLOAT,!1,x,20),e.enableVertexAttribArray(3),e.vertexAttribPointer(3,4,e.FLOAT,!1,x,36);const m=e.createBuffer();return e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,m),e.bufferData(e.ELEMENT_ARRAY_BUFFER,u.indices,e.STATIC_DRAW),e.bindVertexArray(null),l={vao:f,vbuf:y,ibuf:m},a.set(u,l),l}return{gl:e,prog:r,maxBones:o,upload(u){c(u)},draw(u,l,f,p){const d=c(l);e.useProgram(r),e.bindVertexArray(d.vao),e.activeTexture(e.TEXTURE0);const y=f.overrideTex||(p&&p.glTex?p.glTex:p);e.bindTexture(e.TEXTURE_2D,y),e.uniform1i(i.tex,0),e.uniformMatrix4fv(i.mvp,!1,u);const x=f.color||[1,1,1,1];e.uniform4f(i.color,x[0],x[1],x[2],x[3]);const m=uo(l,f.time||0,f.animLayers,f.boneOverrides),M=Math.min(l.bones.length,o);m&&M>0?(e.uniformMatrix4fv(i.skin,!1,m.subarray(0,M*16)),e.uniform1i(i.boneCount,M)):(e.uniformMatrix4fv(i.skin,!1,s),e.uniform1i(i.boneCount,0)),f.blending==="additive"?(e.enable(e.BLEND),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE)):f.blending==="normal"?e.disable(e.BLEND):(e.enable(e.BLEND),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA));const h=l.indexType==="u32"?e.UNSIGNED_INT:e.UNSIGNED_SHORT;e.drawElements(e.TRIANGLES,l.indexCount,h,0),e.bindVertexArray(null)}}}const Dc=Object.freeze(Object.defineProperty({__proto__:null,applyAttachmentBindOrigins:Cc,attachmentBind:Li,attachmentWorld:Ci,bindWorldOf:Pi,computeSkinMatrices:uo,createMDLRenderer:Uc,followAttachments:Lc,mat4MulOut:Pc,parentMeshToWorldDelta:fo,parseMDL:xc},Symbol.toStringTag,{value:"Module"}));function Ri(e,n,t){const r=Math.max(0,Number(t)||0),o=Math.max(1,Number(e)||1),i=Math.max(1,Number(n)||1);return r*2>=Math.min(o,i)?0:r}function Bc(e,n,t){const r=Math.max(1,n.boxW),o=Math.max(1,n.boxH),i=Ri(r,o,n.padding||0),s=n.spacing||[0,0],a=Math.max(1,n.lineHeight||(n.pointsize||24)*1.25+s[1]),c=Math.max(1,r-i*2),u=n.limitwidth&&n.maxwidth>0?Math.min(n.maxwidth,c):1/0;function l(_){if(t(_)<=u)return[_];const R=[];let L="",N=-1;for(const j of _)if(L+=j,(j===" "||j===" ")&&(N=L.length),t(L)>u&&L.length>1)for(N>0?(R.push(L.slice(0,N-1)),L=L.slice(N)):(R.push(L.slice(0,-1)),L=j),N=-1;t(L)>u&&L.length>1;)R.push(L.slice(0,-1)),L=L.slice(-1);return L!==""&&R.push(L),R.length?R:[""]}let f=[];const p=String(e??"").split(`
|
|
177
|
+
`);for(const _ of p)f.push(...l(_));let d=!1;if(n.limitrows&&n.maxrows>0&&f.length>n.maxrows&&(f=f.slice(0,n.maxrows),d=!0,n.limituseellipsis)){let _=f[n.maxrows-1];for(;_.length>0&&t(_+"\u2026")>u;)_=_.slice(0,-1);f[n.maxrows-1]=_+"\u2026"}const y=f.map(_=>t(_)),x=f.length*a,m=n.halign||"center",M=n.valign||"center",h=r/2,g=o/2,v=M==="top"?g:M==="bottom"?g-x:(o-x)/2;return{lines:f.map((_,R)=>{const L=y[R],N=m==="left"?h:m==="right"?h-L:(r-L)/2;return{text:_,width:L,x:N,y:v+R*a}}),lineHeight:a,totalH:x,truncated:d,boxW:r,boxH:o}}function Ic(e,n,t){const r=n.boxW,o=n.boxH,i=t.color||[1,1,1],s=t.alpha!==void 0?t.alpha:1,a=t.brightness!==void 0?t.brightness:1;e.font=t.font;try{e.letterSpacing=(t.spacing&&t.spacing[0]?t.spacing[0]:0)+"px"}catch{}if(e.textBaseline="middle",t.opaquebackground){const u=t.backgroundcolor||[0,0,0],l=t.backgroundbrightness!==void 0?t.backgroundbrightness:1;e.fillStyle=`rgba(${Math.round(u[0]*255*l)},${Math.round(u[1]*255*l)},${Math.round(u[2]*255*l)},${s})`,e.fillRect(0,0,r,o)}const c=(u,l,f)=>{e.fillStyle=f;for(const p of n.lines)e.fillText(p.text,p.x+u,p.y+n.lineHeight/2+l)};if(t.castshadow){const u=Math.max(1,(t.pointsize||24)/10);c(u,u,`rgba(0,0,0,${s*.75})`)}c(0,0,`rgba(${Math.round(i[0]*255*a)},${Math.round(i[1]*255*a)},${Math.round(i[2]*255*a)},${s})`)}const ki=/^add[A-Z]/;function Fi(){return{log:()=>{},warn:()=>{},error:()=>{},info:()=>{},debug:()=>{}}}function Ni(e){return new Proxy(e,{get(n,t,r){const o=Reflect.get(n,t,r);if(o==null&&typeof t=="string"&&t!=="then"){const i=()=>{};return n[t]=i,i}return o}})}function wn(e,n){return()=>{}}function Ui(e,n){e.isScreensaver=!!n.isScreensaver,typeof n.isRunningInEditor=="boolean"&&(e.isRunningInEditor=n.isRunningInEditor),e.setInterval||(e.setInterval=n.setInterval||wn),e.setTimeout||(e.setTimeout=n.setTimeout||wn),e.clearTimeout||(e.clearTimeout=n.clearTimeout||(()=>{})),e.clearInterval||(e.clearInterval=n.clearInterval||(()=>{})),typeof n.openUserShortcut=="function"&&(e.openUserShortcut=n.openUserShortcut);const t=n.mediaControl||null;e.media={skipNext:()=>{if(t&&t.skipNext)return t.skipNext()},skipPrevious:()=>{if(t&&t.skipPrevious)return t.skipPrevious()},play:()=>{if(t&&t.play)return t.play()},pause:()=>{if(t&&t.pause)return t.pause()},playPause:()=>{if(t&&t.playPause)return t.playPause()},get snapshot(){return t&&t.snapshot?t.snapshot:null}};const r=n.windowTitle;Object.defineProperty(e,"windowTitle",{configurable:!0,enumerable:!0,get(){return r&&r.title?String(r.title):""}}),Object.defineProperty(e,"windowApp",{configurable:!0,enumerable:!0,get(){return r&&r.app?String(r.app):""}})}class ge{constructor(n,t,r){if(n!==null&&typeof n=="object")this.x=n.x!==void 0?n.x:n.width||0,this.y=t!==void 0?t:n.y!==void 0?n.y:n.height||0,this.z=r!==void 0?r:n.z||0;else if(t===void 0&&r===void 0){const o=Number(n)||0;this.x=o,this.y=o,this.z=o}else this.x=Number(n)||0,this.y=Number(t)||0,this.z=Number(r)||0}add(n){const t=new ge(n);return new ge(this.x+t.x,this.y+t.y,this.z+t.z)}subtract(n){const t=new ge(n);return new ge(this.x-t.x,this.y-t.y,this.z-t.z)}multiply(n){return n&&typeof n=="object"?new ge(this.x*n.x,this.y*n.y,this.z*n.z):new ge(this.x*n,this.y*n,this.z*n)}divide(n){const t=(r,o)=>o===0?0:r/o;return n&&typeof n=="object"?new ge(t(this.x,n.x),t(this.y,n.y),t(this.z,n.z)):new ge(t(this.x,n),t(this.y,n),t(this.z,n))}copy(){return new ge(this.x,this.y,this.z)}mix(n,t){const r=new ge(n),o=Number(t),i=Number.isFinite(o)?o:0;return new ge(this.x+(r.x-this.x)*i,this.y+(r.y-this.y)*i,this.z+(r.z-this.z)*i)}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}normalize(){const n=this.length();return n===0?new ge(0,0,0):new ge(this.x/n,this.y/n,this.z/n)}dot(n){const t=new ge(n);return this.x*t.x+this.y*t.y+this.z*t.z}toString(){return this.x+" "+this.y+" "+this.z}}const Di=ge;function Bi(e){if(e instanceof ge||!e||typeof e!="object"||Array.isArray(e)||!("x"in e)&&!("y"in e)&&!("z"in e)||Object.getPrototypeOf(e)===ge.prototype)return e;try{Object.setPrototypeOf(e,ge.prototype)}catch{}return e}function Ii(e){return e&&e.cursorWorldPosition?e:{cursorWorldPosition:new ge(0,0,0),cursorScreenPosition:new ge(0,0,0),cursorPosition:new ge(0,0,0),cursorPositionLast:new ge(0,0,0),cursorLeftDown:!1}}function Oc(e,n,t){return new ge(e||0,n||0,t||0)}function $c(){const e={cursorWorldPosition:new ge(0,0,0),cursorScreenPosition:new ge(0,0,0),cursorPosition:new ge(0,0,0),cursorPositionLast:new ge(0,0,0),cursorLeftDown:!1};return e.update=function(n){return n&&(e.cursorWorldPosition.x=n.wx,e.cursorWorldPosition.y=n.originY!=null?n.originY:n.wy,e.cursorWorldPosition.z=0,e.cursorScreenPosition.x=n.screenX,e.cursorScreenPosition.y=n.screenY,e.cursorScreenPosition.z=0,e.cursorPosition.x=n.u,e.cursorPosition.y=n.v,e.cursorPosition.z=0,e.cursorPositionLast.x=n.lastU,e.cursorPositionLast.y=n.lastV,e.cursorPositionLast.z=0,e.cursorLeftDown=!!n.leftDown),e},e}const Oi={mix:(e,n,t)=>e+(n-e)*t,lerp:(e,n,t)=>e+(n-e)*t,clamp:(e,n,t)=>Math.min(t,Math.max(n,e)),saturate:e=>Math.min(1,Math.max(0,e)),smoothstep:(e,n,t)=>{const r=Math.min(1,Math.max(0,(t-e)/(n-e||1)));return r*r*(3-2*r)},smoothStep:(e,n,t)=>{const r=Math.min(1,Math.max(0,(t-e)/(n-e||1)));return r*r*(3-2*r)},random:(e,n)=>e===void 0?Math.random():e+Math.random()*((n===void 0?1:n)-e),randomInt:(e,n)=>Math.floor((e||0)+Math.random()*((n===void 0?1:n)+1-(e||0))),degrees:e=>e*180/Math.PI,radians:e=>e*Math.PI/180},$i={hsv2rgb:e=>{const n=e&&typeof e=="object"?e:{x:0,y:0,z:0},t=((Number(n.x)||0)%1+1)%1,r=Math.min(1,Math.max(0,Number(n.y)||0)),o=Math.min(1,Math.max(0,Number(n.z)||0)),i=Math.floor(t*6),s=t*6-i,a=o*(1-r),c=o*(1-s*r),u=o*(1-(1-s)*r),f=[[o,u,a],[c,o,a],[a,o,u],[a,c,o],[u,a,o],[o,a,c]][i%6];return{x:f[0],y:f[1],z:f[2]}},rgb2hsv:e=>{const n=e&&typeof e=="object"?e:{x:0,y:0,z:0},t=Number(n.x)||0,r=Number(n.y)||0,o=Number(n.z)||0,i=Math.max(t,r,o),s=Math.min(t,r,o),a=i-s;let c=0;return a>0&&(i===t?c=(r-o)/a/6:i===r?c=(2+(o-t)/a)/6:c=(4+(t-r)/a)/6,c<0&&(c+=1)),{x:c,y:i===0?0:a/i,z:i}}},ji={add:(e,n)=>({x:(e.x||0)+(n.x||0),y:(e.y||0)+(n.y||0),z:(e.z||0)+(n.z||0)}),subtract:(e,n)=>({x:(e.x||0)-(n.x||0),y:(e.y||0)-(n.y||0),z:(e.z||0)-(n.z||0)}),scale:(e,n)=>({x:(e.x||0)*n,y:(e.y||0)*n,z:(e.z||0)*n}),length:e=>Math.hypot(e.x||0,e.y||0,e.z||0),dot:(e,n)=>(e.x||0)*(n.x||0)+(e.y||0)*(n.y||0)+(e.z||0)*(n.z||0),normalize:e=>{const n=Math.hypot(e.x||0,e.y||0,e.z||0)||1;return{x:(e.x||0)/n,y:(e.y||0)/n,z:(e.z||0)/n}},mix:(e,n,t)=>({x:(e.x||0)+((n.x||0)-(e.x||0))*t,y:(e.y||0)+((n.y||0)-(e.y||0))*t,z:(e.z||0)+((n.z||0)-(e.z||0))*t})},zi=Object.freeze({PLAYBACK_STOPPED:0,PLAYBACK_PLAYING:1,PLAYBACK_PAUSED:2}),br=["mediaPropertiesChanged","mediaThumbnailChanged","mediaPlaybackChanged","mediaTimelineChanged","mediaStatusChanged","mediaLyricsChanged"],jc=["scriptProperties","engine","WEMath","WEColor","WEVector","createScriptProperties","shared","console","process","globalThis","self","window","document","require","module","exports","fetch","XMLHttpRequest","Worker","importScripts","location","navigator","alert","confirm","prompt","setTimeout","setInterval","clearTimeout","clearInterval","requestAnimationFrame","cancelAnimationFrame","performance","Function","Vec3","Vec2","input","thisLayer","thisScene","thisObject","localStorage","MediaPlaybackEvent"],zc=new RegExp(`(^[ \\t]*|;|\\})[ \\t]*(?:var|let|const)[ \\t]+(?=(?:${jc.join("|")})\\b)`,"gm"),Vc={WEMath:!0,WEColor:!0,WEVector:!0};function Vi(e){return typeof e!="string"?e:e.replace(/([!=])==(\s*)(['"])(-?\d+)\3/g,"$1=$2$3$4$3")}function Wi(e){return Vi(e).replace(/\bimport\s*\*\s*as\s+(\w+)\s+from\s*['"]([^'"]+)['"]\s*;?/g,(n,t,r)=>{const o=String(r);return Vc[o]?t===o?"":`var ${t} = ${o};`:`var ${t} = {};`}).replace(/(^[ \t]*|;|\})[ \t]*import\s+(?:[^;'"]+\s+from\s+)?['"][^'"]*['"];?[ \t]*/gm,"$1").replace(/(^[ \t]*|;|\})[ \t]*export[ \t]+(?=(?:async[ \t]+)?function\b|(?:var|let|const)\b)/gm,"$1").replace(zc,"$1")}function Gn(e){return e!==null&&typeof e=="object"&&"value"in e?e.value:e}function Hi(e){const n=e||{width:1920,height:1080};return n.x!==void 0&&n.y!==void 0?n:{x:n.width,y:n.height,width:n.width,height:n.height}}function Wc(e,n,t={}){if(typeof e!="string"||e.length===0)return null;const r=Wi(e);if(r===e&&e.indexOf("update")<0)return null;const o={};if(n&&typeof n=="object")for(const[M,h]of Object.entries(n))o[M]=Gn(h);const i=new Proxy(()=>i,{apply(){return i},get(M,h){if(h==="finish")return()=>o;if(typeof h=="string"&&ki.test(h))return g=>(g&&typeof g=="object"&&typeof g.name=="string"&&!(g.name in o)&&(o[g.name]=Gn(g.value)),i)}}),s={text:t.text!==void 0&&t.text!==null?String(t.text):"",font:t.font||"",pointsize:t.pointsize||24,color:(t.color||[1,1,1]).slice(),angles:(t.angles||[0,0,0]).slice(),scale:(t.scale||[1,1,1]).slice(),visible:t.visible!==!1,origin:vr(t.origin||[0,0,0])},a={registerAsset:()=>{},frametime:1/60,runtime:0,canvasSize:Hi(t.canvasSize),screenResolution:t.screenResolution||{x:1920,y:1080},timeOfDay:typeof t.timeOfDay=="number"?t.timeOfDay:0,userProperties:t.userProperties||{},AUDIO_RESOLUTION_16:16,AUDIO_RESOLUTION_32:32,AUDIO_RESOLUTION_64:64,setTimeout:t.setTimeout||wn,clearTimeout:t.clearTimeout||(()=>{}),setInterval:t.setInterval||wn,clearInterval:t.clearInterval||(()=>{}),openUserShortcut:t.openUserShortcut||(()=>{}),isRunningInEditor:!!t.isRunningInEditor,isScreensaver:!!t.isScreensaver};Ui(a,t);const c=t.audioViews;a.registerAudioBuffers=M=>{const h=Math.max(1,Math.min(64,Math.floor(Number(M)||0)));let g=c?c.get(h):void 0;return g||(g={left:new Float32Array(h),right:new Float32Array(h),average:new Float32Array(h)},c&&c.set(h,g)),g};const u={getLayer(M){const h=t.getLayerText?t.getLayerText(String(M)):void 0;return{text:h!=null?String(h):""}},createLayer(M){return{text:"",visible:!1,color:[0,0,0],alpha:1,pointsize:t.pointsize||24,font:t.font||"",origin:vr(t.origin||[0,0,0]),angles:[0,0,0],scale:[1,1,1]}},sortLayer:()=>{},getLayerIndex:()=>0},l=t.shared||{},f={console:Fi()},p=Ii(t.inputView);let d;try{d=new Function("scriptProperties","engine","thisLayer","thisScene","WEMath","WEColor","WEVector","createScriptProperties","shared","console","process","globalThis","self","window","document","require","module","exports","fetch","XMLHttpRequest","Worker","importScripts","location","navigator","alert","confirm","prompt","setTimeout","setInterval","clearTimeout","clearInterval","requestAnimationFrame","cancelAnimationFrame","performance","Function","Vec3","Vec2","input","MediaPlaybackEvent",`"use strict";
|
|
178
178
|
`+r+`
|
|
179
|
-
;return {update: typeof update === "function" ? update : null,init: typeof init === "function" ? init : null,applyUserProperties: typeof applyUserProperties === "function" ? applyUserProperties : null,cursorClick: typeof cursorClick === "function" ? cursorClick : null,cursorEnter: typeof cursorEnter === "function" ? cursorEnter : null,cursorLeave: typeof cursorLeave === "function" ? cursorLeave : null,cursorDown: typeof cursorDown === "function" ? cursorDown : null,cursorUp: typeof cursorUp === "function" ? cursorUp : null,cursorMove: typeof cursorMove === "function" ? cursorMove : null,`+br.map(h=>`${h}: typeof ${h} === "function" ? ${h} : null,`).join("")+"dummy_: 0};")(o,Ei(a),s,u,Fi,ki,Ni,i,l,p.console,void 0,p,p,p,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,he,Ci,f,Ui)}catch(A){return t.onError&&t.onError(A,"parse"),null}const w=!!(d&&br.some(A=>d[A])),M=!!(d&&typeof d.applyUserProperties=="function");if(!d||!d.update&&!w&&!M)return null;const m={engine:a,thisLayer:s,scriptProperties:o,hasUpdate:!!d.update,hasCursorHook:!!(d.cursorClick||d.cursorEnter||d.cursorLeave||d.cursorDown||d.cursorUp||d.cursorMove),hasMediaHook:w,hasApplyHook:M,errCount:0,disabled:!1,init(A){if(d.init)try{d.init(A)}catch(h){m.errCount++,t.onError&&t.onError(h,"init")}},applyUserProperties(A){if(d.applyUserProperties)try{d.applyUserProperties(A||{})}catch(h){m.errCount++,t.onError&&t.onError(h,"applyUserProperties")}},callUpdateRaw(A){if(!(!d.update||m.disabled))try{return d.update(A)}catch(h){m.errCount++,t.onError&&t.onError(h,"update"),m.errCount>=3&&(m.disabled=!0);return}},callUpdate(A){if(!d.update||m.disabled)return null;const h=s.text;let b;try{b=d.update(h!==""?h:A!==void 0?A:"")}catch(v){return m.errCount++,t.onError&&t.onError(v,"update"),m.errCount>=3&&(m.disabled=!0),null}return typeof b=="string"?(s.text=b,b):typeof b=="boolean"?null:b!=null?(s.text=String(b),s.text):s.text!==h?s.text:null},callCursor(A,h){if(m.disabled)return;const b=d[A];if(typeof b=="function")try{return b(h)}catch(v){m.errCount++,t.onError&&t.onError(v,A),m.errCount>=3&&(m.disabled=!0);return}},callMedia(A,h){if(m.disabled)return;const b=d[A];if(typeof b=="function")try{return b(h)}catch(v){m.errCount++,t.onError&&t.onError(v,A),m.errCount>=3&&(m.disabled=!0);return}}};return m}function zn(){const e={play:()=>e,pause:()=>e,stop:()=>e,setFrame:()=>e,setRate:()=>e,setBlend:()=>e,setVisible:()=>e,isPlaying:Object.assign(()=>!1,{valueOf:()=>!1,toString:()=>"false"}),get frame(){return 0},get frameCount(){return 0},get rate(){return 1}};return e}function Fc(e){if(!e)return zn();if(e.textureAnimation)return e.textureAnimation.api;const n={frame:null,playing:!0,rate:1},t={play:()=>(n.playing=!0,t),pause:()=>(n.playing=!1,t),stop:()=>(n.playing=!1,t),setFrame:r=>{const o=Number(r);return n.frame=Number.isFinite(o)?o:0,t},setRate:r=>{const o=Number(r);return Number.isFinite(o)&&(n.rate=o),t},setBlend:()=>t,setVisible:r=>(e.visible=!!r,t),isPlaying:Object.assign(()=>n.playing,{valueOf:()=>n.playing,toString:()=>String(n.playing)}),get frame(){return n.frame===null?0:n.frame},get frameCount(){return e.spriteFrameCount||0},get rate(){return n.rate}};return n.api=t,e.textureAnimation=n,t}function kc(e){if(e&&e.videoTextureApi)return e.videoTextureApi;const n=()=>e&&e.videoCtl||null,t={get duration(){const r=n(),o=r&&typeof r.duration=="function"?r.duration():0;return Number.isFinite(o)?o:0},get rate(){const r=n(),o=r&&typeof r.getRate=="function"?r.getRate():1;return Number.isFinite(o)&&o>0?o:1},set rate(r){const o=n(),i=Number(r);o&&typeof o.setRate=="function"&&Number.isFinite(i)&&o.setRate(i)},get loop(){const r=n();return r&&typeof r.getLoop=="function"?!!r.getLoop():!0},set loop(r){const o=n();o&&typeof o.setLoop=="function"&&o.setLoop(!!r)},play:()=>{const r=n();r&&r.play&&r.play()},pause:()=>{const r=n();r&&r.pause&&r.pause()},stop:()=>{const r=n();r&&r.stop&&r.stop()},isPlaying:Object.assign(()=>{const r=n();return!!(r&&typeof r.isPlaying=="function"&&r.isPlaying())},{valueOf(){const r=n();return!!(r&&typeof r.isPlaying=="function"&&r.isPlaying())},toString(){const r=n();return String(!!(r&&typeof r.isPlaying=="function"&&r.isPlaying()))}}),getCurrentTime:()=>{const r=n(),o=r&&typeof r.getCurrentTime=="function"?r.getCurrentTime():0;return Number.isFinite(o)?o:0},setCurrentTime:r=>{const o=n(),i=Number(r);o&&typeof o.setCurrentTime=="function"&&Number.isFinite(i)&&o.setCurrentTime(i)},addEndedCallback:r=>{const o=n();typeof r=="function"&&o&&typeof o.addEndedCallback=="function"&&o.addEndedCallback(r)}};return e&&(e.videoTextureApi=t),t}function Nc(){const e=new Map,n=r=>e.has(String(r))?e.get(String(r)):null,t=(r,o)=>{e.set(String(r),String(o))};return{getItem:n,setItem:t,get:n,set:t,removeItem:r=>{e.delete(String(r))},remove:r=>{e.delete(String(r))},clear:()=>{e.clear()},key:r=>Array.from(e.keys())[r]??null,get length(){return e.size}}}function Uc(e,n){const t=e&&e.puppet,r=t&&t.bones||null,o=r?r.length:0,i=e&&e.origin||[0,0,0],s=e&&e.scale||[1,1,1],a=s[0]||1,c=s[1]||1,u=(w,M)=>[i[0]+w*a,i[1]-M*c],l=(w,M)=>[(w-i[0])/a,-(M-i[1])/c],p=w=>{const M=n.get(w);if(M)return[M[0],M[1],M[2]];const m=r[w].matrix;return[m[12],m[13],m[14]]},f=w=>{let M=0,m=0,A=w;for(let h=0;A>=0&&A<o&&h<64;h++){const b=p(A);M+=b[0],m+=b[1],A=r[A].parent}return u(M,m)},d=w=>{const M={translation(m){if(m===void 0){const T=f(w);return new he(T[0],T[1],0)}const A=Xt(m);let h=0,b=0;if(r[w].parent>=0){const T=f(r[w].parent),_=l(T[0],T[1]);h=_[0],b=_[1]}const v=l(A[0],A[1]);return n.set(w,[v[0]-h,v[1]-b,0]),M},rotation(){return M},scale(){return M}};return M};return{getBoneCount:()=>o,getBoneTransform:w=>{const M=Math.floor(Number(w));if(!r||!(M>=0)||M>=o){const m={translation(A){return A===void 0?new he(0,0,0):m},rotation(){return m},scale(){return m}};return m}return d(M)},setBoneTransform:(w,M)=>{const m=Math.floor(Number(w));!r||!(m>=0)||m>=o},applyBonePhysicsImpulse:()=>{}}}function uo(e){return{get visible(){return e?!!e.visible:!1},set visible(n){e&&(e.visible=!!n)},get name(){return e&&e.name||""},getMaterial:()=>null}}function Oi(e,n){if(e==null)return null;const t=r=>{if(!r)return null;if(n&&typeof n.getSceneLayer=="function"){const o=n.getSceneLayer(String(r));if(o)return o}return n&&n.layer&&n.layer.name===r?n.layer:null};return t(typeof e=="object"?e.name:String(e))}function Dc(e,n){e&&(e.visibleSelf=!1,e.visible=!1,e.destroyed=!0,n&&typeof n.recomputeVisibility=="function"&&n.recomputeVisibility())}function $i(e,n){if(typeof e!="string"||!e||/\/workshop\//.test(e))return e;const t=n!=null&&n!==""?String(n):"";if(!t)return e;const r=e.match(/^(models|materials|shaders|particles|effects)\/(.+)$/);return r?`${r[1]}/workshop/${t}/${r[2]}`:e}function Bc(e){if(typeof e!="string")return null;const n=e.match(/export\s+let\s+__workshopId\s*=\s*['"](\d+)['"]/);return n?n[1]:null}function Ic(e){const n=t=>yr(t||null,e);return{getLayer(t){if(e.getSceneLayer){const r=e.getSceneLayer(String(t));if(r&&!r.destroyed)return n(r)}return n(null)},createLayer(t){if(typeof e.createSceneLayer!="function")return n(null);let r=t;if(typeof t=="string"){const i=typeof e.getWorkshopId=="function"?e.getWorkshopId():e.workshopId;r=$i(t,i)}const o=e.createSceneLayer(r);return n(o||null)},destroyLayer(t){Dc(Oi(t,e),e)},sortLayer:()=>{},getLayerIndex(t){const r=typeof e.enumerateSceneLayers=="function"?e.enumerateSceneLayers():[],o=t&&typeof t=="object"?t.name:String(t||""),i=r.findIndex(s=>s&&s.name===o);return i<0?0:i},enumerateLayers(){const t=typeof e.enumerateSceneLayers=="function"?e.enumerateSceneLayers():[],r=[];for(const o of t)o&&!o.destroyed&&r.push(n(o));return r},getAnimation(t){if(typeof e.getSceneAnimation=="function"){const r=e.getSceneAnimation(t);if(r)return r}return zn()},getCameraTransforms(){const t=e.cameraTransforms||{zoom:1};return{zoom:typeof t.zoom=="number"?t.zoom:1,center:t.center||null,eye:t.eye||null,parallaxAmount:typeof t.parallaxAmount=="number"?t.parallaxAmount:0}},setCameraTransforms(t){const r=e.cameraTransforms;!r||!t||typeof t!="object"||(typeof t.zoom=="number"&&Number.isFinite(t.zoom)&&t.zoom>0&&(r.zoom=t.zoom),t.center!==void 0&&(r.center=t.center),t.eye!==void 0&&(r.eye=t.eye),typeof t.parallaxAmount=="number"&&(r.parallaxAmount=t.parallaxAmount))},getInitialLayerConfig(t){return typeof e.getInitialLayerConfig=="function"?e.getInitialLayerConfig(t):Oi(t,e)||null}}}function yr(e,n){const t=s=>vr(Array.isArray(s)?s:[0,0,0]),r=n&&typeof n.getBoneOverrides=="function"&&e?n.getBoneOverrides(e):null,o={origin:t(e?e.origin:[0,0,0]),scale:t(e?e.scale:[1,1,1]),angles:jc(e),size:t(e?e.size:[0,0,0]),color:t(e?e.color:[1,1,1])},i={get name(){return e&&e.name||""},get id(){return e&&e.id||0},get visible(){const s=n&&n.targetEffect;return s?!!s.visible:e?e.visibleSelf!==void 0?!!e.visibleSelf:!!e.visible:!1},set visible(s){const a=n&&n.targetEffect;if(a){a.visible=!!s;return}e&&(e.visibleSelf=!!s,typeof n.recomputeVisibility=="function"?n.recomputeVisibility():e.visible=!!s)},get alpha(){return e&&typeof e.alpha=="number"?e.alpha:1},set alpha(s){e&&(e.alpha=Number(s)||0)},get brightness(){return e&&typeof e.brightness=="number"?e.brightness:1},set brightness(s){e&&(e.brightness=Number(s)||0)},get text(){return e&&e.text!==void 0?String(e.text):""},set text(s){e&&typeof s!="boolean"&&(e.text=s==null?"":String(s))},get pointsize(){return e&&e.textPointsize||24},set pointsize(s){e&&(e.textPointsize=Number(s)||24)},get font(){return e&&e.textFont||""},set font(s){e&&(e.textFont=String(s||""))},get alignment(){return e&&e.alignment||"center"},set alignment(s){if(!e)return;const a=String(s||"center").toLowerCase();e.alignment=a==="centre"?"center":a},...e&&e.puppet&&r?Uc(e,r):{getBoneCount:()=>0,getBoneTransform:()=>{const s={translation(a){return a===void 0?new he(0,0,0):s},rotation(){return s},scale(){return s}};return s},setBoneTransform:()=>{},applyBonePhysicsImpulse:()=>{}},getParent:()=>{if(!e||e.parentId==null)return null;const s=n&&typeof n.getSceneLayerById=="function"?n.getSceneLayerById(e.parentId):null;return!s||s.destroyed?null:yr(s,n)},getChildren:()=>{const s=e&&e.childIds||[];if(!s.length)return[];const a=n&&typeof n.getSceneLayerById=="function"?n.getSceneLayerById:null;if(!a)return[];const c=[];for(const u of s){const l=a(u);l&&!l.destroyed&&c.push(yr(l,n))}return c},getAnimation:s=>{const a=e&&e.animations,c=e&&e.animationList||[];return s==null||s===""?c[0]||zn():a&&a[s]?a[s]:typeof s=="number"&&c[s]?c[s]:typeof s=="string"&&/^\d+$/.test(s)&&c[Number(s)]?c[Number(s)]:zn()},getAnimationLayer:s=>{const a=e&&e.animations,c=e&&e.animationList||[];return a&&a[s]?a[s]:typeof s=="number"&&c[s]?c[s]:typeof s=="string"&&/^\d+$/.test(s)&&c[Number(s)]?c[Number(s)]:zn()},getAnimationLayerCount:()=>(e&&e.animationList||[]).length,getTextureAnimation:()=>Fc(e),play:()=>{e&&e.soundCtl&&e.soundCtl.play&&e.soundCtl.play(),e&&e.videoCtl&&e.videoCtl.play&&e.videoCtl.play()},pause:()=>{e&&e.soundCtl&&e.soundCtl.pause&&e.soundCtl.pause(),e&&e.videoCtl&&e.videoCtl.pause&&e.videoCtl.pause()},stop:()=>{e&&e.soundCtl&&e.soundCtl.stop&&e.soundCtl.stop(),e&&e.videoCtl&&e.videoCtl.stop&&e.videoCtl.stop()},isPlaying:Object.assign(()=>{const s=e&&e.soundCtl&&typeof e.soundCtl.isPlaying=="function"&&e.soundCtl.isPlaying(),a=e&&e.videoCtl&&typeof e.videoCtl.isPlaying=="function"&&e.videoCtl.isPlaying();return!!(s||a)},{valueOf(){const s=e&&e.soundCtl&&typeof e.soundCtl.isPlaying=="function"&&e.soundCtl.isPlaying(),a=e&&e.videoCtl&&typeof e.videoCtl.isPlaying=="function"&&e.videoCtl.isPlaying();return!!(s||a)},toString(){const s=e&&e.soundCtl&&typeof e.soundCtl.isPlaying=="function"&&e.soundCtl.isPlaying(),a=e&&e.videoCtl&&typeof e.videoCtl.isPlaying=="function"&&e.videoCtl.isPlaying();return String(!!(s||a))}}),get volume(){if(e&&e.soundCtl&&typeof e.soundCtl.getVolume=="function")return e.soundCtl.getVolume();const s=e&&e.soundprops&&e.soundprops.volume;return typeof s=="number"?s:1},set volume(s){const a=Number(s);if(!Number.isFinite(a)||!e)return;const c=Math.max(0,Math.min(1,a));e.soundprops&&(e.soundprops.volume=c),e.soundCtl&&typeof e.soundCtl.setVolume=="function"&&e.soundCtl.setVolume(c)},getVideoTexture:()=>kc(e),getTransformMatrix:()=>{const s=e&&e.origin||[0,0,0],a=new Float32Array(16);return a[0]=1,a[5]=1,a[10]=1,a[15]=1,a[12]=s[0]||0,a[13]=s[1]||0,a[14]=s[2]||0,{m:a}},getEffect:s=>{const a=e&&e.effects||null;if(!a||a.length===0)return uo(null);if(typeof s=="number"||typeof s=="string"&&/^\d+$/.test(s))return uo(a[Number(s)]||null);const c=String(s);return uo(a.find(u=>u&&u.name===c)||null)}};Object.defineProperty(i,"angles",{enumerable:!0,get(){return o.angles},set(s){if(e&&Array.isArray(e.angles)){const a=ji(s);e.angles[0]=a[0],e.angles[1]=a[1],e.angles[2]=a[2]}}});for(const s of["origin","scale","size","color"])Object.defineProperty(i,s,{enumerable:!0,get(){const a=e&&Array.isArray(e[s])?e[s]:null;return vr(a||[0,0,0])},set(a){const c=Xt(a);o[s].x=c[0],o[s].y=c[1],o[s].z=c[2],e&&Array.isArray(e[s])&&s!=="size"&&(e[s][0]=c[0],e[s][1]=c[1],e[s][2]=c[2])}});return i}function Oc(e,n,t={}){if(typeof e!="string"||e.length===0)return null;const r=Bi(e),o={};if(n&&typeof n=="object")for(const[T,_]of Object.entries(n))if(_!==null&&typeof _=="object"&&typeof _.user=="string"){const F=t.userProperties?t.userProperties[_.user]:void 0;o[T]=F!==void 0?F:jn(_)}else o[T]=jn(_);const i=new Proxy(()=>i,{apply(){return i},get(T,_){if(_==="finish")return()=>o;if(typeof _=="string"&&Ti.test(_))return F=>(F&&typeof F=="object"&&typeof F.name=="string"&&!(F.name in o)&&(o[F.name]=jn(F.value)),i)}}),s={registerAsset:()=>{},frametime:1/60,runtime:0,canvasSize:Ii(t.canvasSize),screenResolution:t.screenResolution||{x:1920,y:1080},timeOfDay:typeof t.timeOfDay=="number"?t.timeOfDay:0,userProperties:t.userProperties||{},AUDIO_RESOLUTION_16:16,AUDIO_RESOLUTION_32:32,AUDIO_RESOLUTION_64:64,setTimeout:t.setTimeout||Mn,clearTimeout:t.clearTimeout||(()=>{}),setInterval:t.setInterval||Mn,clearInterval:t.clearInterval||(()=>{}),openUserShortcut:t.openUserShortcut||(()=>{}),isRunningInEditor:!!t.isRunningInEditor,isScreensaver:!!t.isScreensaver};Pi(s,t);const a=t.audioViews;s.registerAudioBuffers=T=>{const _=Math.max(1,Math.min(64,Math.floor(Number(T)||0)));let F=a?a.get(_):void 0;return F||(F={left:new Float32Array(_),right:new Float32Array(_),average:new Float32Array(_)},a&&a.set(_,F)),F};const c=t.shared||{},u={console:Si()},l=Ri(t.inputView),p=t.layer||null,f=t.workshopId!=null?t.workshopId:Bc(e),d=yr(p,t),w=Ic({...t,workshopId:f,getWorkshopId:()=>f});let M;try{M=new Function("scriptProperties","engine","WEMath","WEColor","WEVector","createScriptProperties","shared","console","process","globalThis","self","window","document","require","module","exports","fetch","XMLHttpRequest","Worker","importScripts","location","navigator","alert","confirm","prompt","setTimeout","setInterval","clearTimeout","clearInterval","requestAnimationFrame","cancelAnimationFrame","performance","Function","Vec3","Vec2","input","thisLayer","thisScene","thisObject","localStorage","MediaPlaybackEvent",`"use strict";
|
|
179
|
+
;return {update: typeof update === "function" ? update : null,init: typeof init === "function" ? init : null,applyUserProperties: typeof applyUserProperties === "function" ? applyUserProperties : null,cursorClick: typeof cursorClick === "function" ? cursorClick : null,cursorEnter: typeof cursorEnter === "function" ? cursorEnter : null,cursorLeave: typeof cursorLeave === "function" ? cursorLeave : null,cursorDown: typeof cursorDown === "function" ? cursorDown : null,cursorUp: typeof cursorUp === "function" ? cursorUp : null,cursorMove: typeof cursorMove === "function" ? cursorMove : null,`+br.map(h=>`${h}: typeof ${h} === "function" ? ${h} : null,`).join("")+"dummy_: 0};")(o,Ni(a),s,u,Oi,$i,ji,i,l,f.console,void 0,f,f,f,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,ge,Di,p,zi)}catch(M){return t.onError&&t.onError(M,"parse"),null}const y=!!(d&&br.some(M=>d[M])),x=!!(d&&typeof d.applyUserProperties=="function");if(!d||!d.update&&!y&&!x)return null;const m={engine:a,thisLayer:s,scriptProperties:o,hasUpdate:!!d.update,hasCursorHook:!!(d.cursorClick||d.cursorEnter||d.cursorLeave||d.cursorDown||d.cursorUp||d.cursorMove),hasMediaHook:y,hasApplyHook:x,errCount:0,disabled:!1,init(M){if(d.init)try{d.init(M)}catch(h){m.errCount++,t.onError&&t.onError(h,"init")}},applyUserProperties(M){if(d.applyUserProperties)try{d.applyUserProperties(M||{})}catch(h){m.errCount++,t.onError&&t.onError(h,"applyUserProperties")}},callUpdateRaw(M){if(!(!d.update||m.disabled))try{return d.update(M)}catch(h){m.errCount++,t.onError&&t.onError(h,"update"),m.errCount>=3&&(m.disabled=!0);return}},callUpdate(M){if(!d.update||m.disabled)return null;const h=s.text;let g;try{g=d.update(h!==""?h:M!==void 0?M:"")}catch(v){return m.errCount++,t.onError&&t.onError(v,"update"),m.errCount>=3&&(m.disabled=!0),null}return typeof g=="string"?(s.text=g,g):typeof g=="boolean"?null:g!=null?(s.text=String(g),s.text):s.text!==h?s.text:null},callCursor(M,h){if(m.disabled)return;const g=d[M];if(typeof g=="function")try{return g(h)}catch(v){m.errCount++,t.onError&&t.onError(v,M),m.errCount>=3&&(m.disabled=!0);return}},callMedia(M,h){if(m.disabled)return;const g=d[M];if(typeof g=="function")try{return g(h)}catch(v){m.errCount++,t.onError&&t.onError(v,M),m.errCount>=3&&(m.disabled=!0);return}}};return m}function Yn(){const e={play:()=>e,pause:()=>e,stop:()=>e,setFrame:()=>e,setRate:()=>e,setBlend:()=>e,setVisible:()=>e,isPlaying:Object.assign(()=>!1,{valueOf:()=>!1,toString:()=>"false"}),get frame(){return 0},get frameCount(){return 0},get rate(){return 1}};return e}function Hc(e){if(!e)return Yn();if(e.textureAnimation)return e.textureAnimation.api;const n={frame:null,playing:!0,rate:1},t={play:()=>(n.playing=!0,t),pause:()=>(n.playing=!1,t),stop:()=>(n.playing=!1,t),setFrame:r=>{const o=Number(r);return n.frame=Number.isFinite(o)?o:0,t},setRate:r=>{const o=Number(r);return Number.isFinite(o)&&(n.rate=o),t},setBlend:()=>t,setVisible:r=>(e.visible=!!r,t),isPlaying:Object.assign(()=>n.playing,{valueOf:()=>n.playing,toString:()=>String(n.playing)}),get frame(){return n.frame===null?0:n.frame},get frameCount(){return e.spriteFrameCount||0},get rate(){return n.rate}};return n.api=t,e.textureAnimation=n,t}function Xc(e){if(e&&e.videoTextureApi)return e.videoTextureApi;const n=()=>e&&e.videoCtl||null,t={get duration(){const r=n(),o=r&&typeof r.duration=="function"?r.duration():0;return Number.isFinite(o)?o:0},get rate(){const r=n(),o=r&&typeof r.getRate=="function"?r.getRate():1;return Number.isFinite(o)&&o>0?o:1},set rate(r){const o=n(),i=Number(r);o&&typeof o.setRate=="function"&&Number.isFinite(i)&&o.setRate(i)},get loop(){const r=n();return r&&typeof r.getLoop=="function"?!!r.getLoop():!0},set loop(r){const o=n();o&&typeof o.setLoop=="function"&&o.setLoop(!!r)},play:()=>{const r=n();r&&r.play&&r.play()},pause:()=>{const r=n();r&&r.pause&&r.pause()},stop:()=>{const r=n();r&&r.stop&&r.stop()},isPlaying:Object.assign(()=>{const r=n();return!!(r&&typeof r.isPlaying=="function"&&r.isPlaying())},{valueOf(){const r=n();return!!(r&&typeof r.isPlaying=="function"&&r.isPlaying())},toString(){const r=n();return String(!!(r&&typeof r.isPlaying=="function"&&r.isPlaying()))}}),getCurrentTime:()=>{const r=n(),o=r&&typeof r.getCurrentTime=="function"?r.getCurrentTime():0;return Number.isFinite(o)?o:0},setCurrentTime:r=>{const o=n(),i=Number(r);o&&typeof o.setCurrentTime=="function"&&Number.isFinite(i)&&o.setCurrentTime(i)},addEndedCallback:r=>{const o=n();typeof r=="function"&&o&&typeof o.addEndedCallback=="function"&&o.addEndedCallback(r)}};return e&&(e.videoTextureApi=t),t}function Gc(){const e=new Map,n=r=>e.has(String(r))?e.get(String(r)):null,t=(r,o)=>{e.set(String(r),String(o))};return{getItem:n,setItem:t,get:n,set:t,removeItem:r=>{e.delete(String(r))},remove:r=>{e.delete(String(r))},clear:()=>{e.clear()},key:r=>Array.from(e.keys())[r]??null,get length(){return e.size}}}function Yc(e,n){const t=e&&e.puppet,r=t&&t.bones||null,o=r?r.length:0,i=e&&e.origin||[0,0,0],s=e&&e.scale||[1,1,1],a=s[0]||1,c=s[1]||1,u=(y,x)=>[i[0]+y*a,i[1]-x*c],l=(y,x)=>[(y-i[0])/a,-(x-i[1])/c],f=y=>{const x=n.get(y);if(x)return[x[0],x[1],x[2]];const m=r[y].matrix;return[m[12],m[13],m[14]]},p=y=>{let x=0,m=0,M=y;for(let h=0;M>=0&&M<o&&h<64;h++){const g=f(M);x+=g[0],m+=g[1],M=r[M].parent}return u(x,m)},d=y=>{const x={translation(m){if(m===void 0){const A=p(y);return new ge(A[0],A[1],0)}const M=Jt(m);let h=0,g=0;if(r[y].parent>=0){const A=p(r[y].parent),_=l(A[0],A[1]);h=_[0],g=_[1]}const v=l(M[0],M[1]);return n.set(y,[v[0]-h,v[1]-g,0]),x},rotation(){return x},scale(){return x}};return x};return{getBoneCount:()=>o,getBoneTransform:y=>{const x=Math.floor(Number(y));if(!r||!(x>=0)||x>=o){const m={translation(M){return M===void 0?new ge(0,0,0):m},rotation(){return m},scale(){return m}};return m}return d(x)},setBoneTransform:(y,x)=>{const m=Math.floor(Number(y));!r||!(m>=0)||m>=o},applyBonePhysicsImpulse:()=>{}}}function po(e){return{get visible(){return e?!!e.visible:!1},set visible(n){e&&(e.visible=!!n)},get name(){return e&&e.name||""},getMaterial:()=>null}}function Xi(e,n){if(e==null)return null;const t=r=>{if(!r)return null;if(n&&typeof n.getSceneLayer=="function"){const o=n.getSceneLayer(String(r));if(o)return o}return n&&n.layer&&n.layer.name===r?n.layer:null};return t(typeof e=="object"?e.name:String(e))}function qc(e,n){e&&(e.visibleSelf=!1,e.visible=!1,e.destroyed=!0,n&&typeof n.recomputeVisibility=="function"&&n.recomputeVisibility())}function Gi(e,n){if(typeof e!="string"||!e||/\/workshop\//.test(e))return e;const t=n!=null&&n!==""?String(n):"";if(!t)return e;const r=e.match(/^(models|materials|shaders|particles|effects)\/(.+)$/);return r?`${r[1]}/workshop/${t}/${r[2]}`:e}function Zc(e){if(typeof e!="string")return null;const n=e.match(/export\s+let\s+__workshopId\s*=\s*['"](\d+)['"]/);return n?n[1]:null}function Kc(e){const n=t=>yr(t||null,e);return{getLayer(t){if(e.getSceneLayer){const r=e.getSceneLayer(String(t));if(r&&!r.destroyed)return n(r)}return n(null)},createLayer(t){if(typeof e.createSceneLayer!="function")return n(null);let r=t;if(typeof t=="string"){const i=typeof e.getWorkshopId=="function"?e.getWorkshopId():e.workshopId;r=Gi(t,i)}const o=e.createSceneLayer(r);return n(o||null)},destroyLayer(t){qc(Xi(t,e),e)},sortLayer:()=>{},getLayerIndex(t){const r=typeof e.enumerateSceneLayers=="function"?e.enumerateSceneLayers():[],o=t&&typeof t=="object"?t.name:String(t||""),i=r.findIndex(s=>s&&s.name===o);return i<0?0:i},enumerateLayers(){const t=typeof e.enumerateSceneLayers=="function"?e.enumerateSceneLayers():[],r=[];for(const o of t)o&&!o.destroyed&&r.push(n(o));return r},getAnimation(t){if(typeof e.getSceneAnimation=="function"){const r=e.getSceneAnimation(t);if(r)return r}return Yn()},getCameraTransforms(){const t=e.cameraTransforms||{zoom:1};return{zoom:typeof t.zoom=="number"?t.zoom:1,center:t.center||null,eye:t.eye||null,parallaxAmount:typeof t.parallaxAmount=="number"?t.parallaxAmount:0}},setCameraTransforms(t){const r=e.cameraTransforms;!r||!t||typeof t!="object"||(typeof t.zoom=="number"&&Number.isFinite(t.zoom)&&t.zoom>0&&(r.zoom=t.zoom),t.center!==void 0&&(r.center=t.center),t.eye!==void 0&&(r.eye=t.eye),typeof t.parallaxAmount=="number"&&(r.parallaxAmount=t.parallaxAmount))},getInitialLayerConfig(t){return typeof e.getInitialLayerConfig=="function"?e.getInitialLayerConfig(t):Xi(t,e)||null}}}function yr(e,n){const t=s=>vr(Array.isArray(s)?s:[0,0,0]),r=n&&typeof n.getBoneOverrides=="function"&&e?n.getBoneOverrides(e):null,o={origin:t(e?e.origin:[0,0,0]),scale:t(e?e.scale:[1,1,1]),angles:el(e),size:t(e?e.size:[0,0,0]),color:t(e?e.color:[1,1,1])},i={get name(){return e&&e.name||""},get id(){return e&&e.id||0},get visible(){const s=n&&n.targetEffect;return s?!!s.visible:e?e.visibleSelf!==void 0?!!e.visibleSelf:!!e.visible:!1},set visible(s){const a=n&&n.targetEffect;if(a){a.visible=!!s;return}e&&(e.visibleSelf=!!s,typeof n.recomputeVisibility=="function"?n.recomputeVisibility():e.visible=!!s)},get alpha(){return e&&typeof e.alpha=="number"?e.alpha:1},set alpha(s){e&&(e.alpha=Number(s)||0)},get brightness(){return e&&typeof e.brightness=="number"?e.brightness:1},set brightness(s){e&&(e.brightness=Number(s)||0)},get text(){return e&&e.text!==void 0?String(e.text):""},set text(s){e&&typeof s!="boolean"&&(e.text=s==null?"":String(s))},get pointsize(){return e&&e.textPointsize||24},set pointsize(s){e&&(e.textPointsize=Number(s)||24)},get font(){return e&&e.textFont||""},set font(s){e&&(e.textFont=String(s||""))},get alignment(){return e&&e.alignment||"center"},set alignment(s){if(!e)return;const a=String(s||"center").toLowerCase();e.alignment=a==="centre"?"center":a},...e&&e.puppet&&r?Yc(e,r):{getBoneCount:()=>0,getBoneTransform:()=>{const s={translation(a){return a===void 0?new ge(0,0,0):s},rotation(){return s},scale(){return s}};return s},setBoneTransform:()=>{},applyBonePhysicsImpulse:()=>{}},getParent:()=>{if(!e||e.parentId==null)return null;const s=n&&typeof n.getSceneLayerById=="function"?n.getSceneLayerById(e.parentId):null;return!s||s.destroyed?null:yr(s,n)},getChildren:()=>{const s=e&&e.childIds||[];if(!s.length)return[];const a=n&&typeof n.getSceneLayerById=="function"?n.getSceneLayerById:null;if(!a)return[];const c=[];for(const u of s){const l=a(u);l&&!l.destroyed&&c.push(yr(l,n))}return c},getAnimation:s=>{const a=e&&e.animations,c=e&&e.animationList||[];return s==null||s===""?c[0]||Yn():a&&a[s]?a[s]:typeof s=="number"&&c[s]?c[s]:typeof s=="string"&&/^\d+$/.test(s)&&c[Number(s)]?c[Number(s)]:Yn()},getAnimationLayer:s=>{const a=e&&e.animations,c=e&&e.animationList||[];return a&&a[s]?a[s]:typeof s=="number"&&c[s]?c[s]:typeof s=="string"&&/^\d+$/.test(s)&&c[Number(s)]?c[Number(s)]:Yn()},getAnimationLayerCount:()=>(e&&e.animationList||[]).length,getTextureAnimation:()=>Hc(e),play:()=>{e&&e.soundCtl&&e.soundCtl.play&&e.soundCtl.play(),e&&e.videoCtl&&e.videoCtl.play&&e.videoCtl.play()},pause:()=>{e&&e.soundCtl&&e.soundCtl.pause&&e.soundCtl.pause(),e&&e.videoCtl&&e.videoCtl.pause&&e.videoCtl.pause()},stop:()=>{e&&e.soundCtl&&e.soundCtl.stop&&e.soundCtl.stop(),e&&e.videoCtl&&e.videoCtl.stop&&e.videoCtl.stop()},isPlaying:Object.assign(()=>{const s=e&&e.soundCtl&&typeof e.soundCtl.isPlaying=="function"&&e.soundCtl.isPlaying(),a=e&&e.videoCtl&&typeof e.videoCtl.isPlaying=="function"&&e.videoCtl.isPlaying();return!!(s||a)},{valueOf(){const s=e&&e.soundCtl&&typeof e.soundCtl.isPlaying=="function"&&e.soundCtl.isPlaying(),a=e&&e.videoCtl&&typeof e.videoCtl.isPlaying=="function"&&e.videoCtl.isPlaying();return!!(s||a)},toString(){const s=e&&e.soundCtl&&typeof e.soundCtl.isPlaying=="function"&&e.soundCtl.isPlaying(),a=e&&e.videoCtl&&typeof e.videoCtl.isPlaying=="function"&&e.videoCtl.isPlaying();return String(!!(s||a))}}),get volume(){if(e&&e.soundCtl&&typeof e.soundCtl.getVolume=="function")return e.soundCtl.getVolume();const s=e&&e.soundprops&&e.soundprops.volume;return typeof s=="number"?s:1},set volume(s){const a=Number(s);if(!Number.isFinite(a)||!e)return;const c=Math.max(0,Math.min(1,a));e.soundprops&&(e.soundprops.volume=c),e.soundCtl&&typeof e.soundCtl.setVolume=="function"&&e.soundCtl.setVolume(c)},getVideoTexture:()=>Xc(e),getTransformMatrix:()=>{const s=e&&e.origin||[0,0,0],a=new Float32Array(16);return a[0]=1,a[5]=1,a[10]=1,a[15]=1,a[12]=s[0]||0,a[13]=s[1]||0,a[14]=s[2]||0,{m:a}},getEffect:s=>{const a=e&&e.effects||null;if(!a||a.length===0)return po(null);if(typeof s=="number"||typeof s=="string"&&/^\d+$/.test(s))return po(a[Number(s)]||null);const c=String(s);return po(a.find(u=>u&&u.name===c)||null)}};Object.defineProperty(i,"angles",{enumerable:!0,get(){return o.angles},set(s){if(e&&Array.isArray(e.angles)){const a=Yi(s);e.angles[0]=a[0],e.angles[1]=a[1],e.angles[2]=a[2]}}});for(const s of["origin","scale","size","color"])Object.defineProperty(i,s,{enumerable:!0,get(){const a=e&&Array.isArray(e[s])?e[s]:null;return vr(a||[0,0,0])},set(a){const c=Jt(a);o[s].x=c[0],o[s].y=c[1],o[s].z=c[2],e&&Array.isArray(e[s])&&s!=="size"&&(e[s][0]=c[0],e[s][1]=c[1],e[s][2]=c[2])}});return i}function Qc(e,n,t={}){if(typeof e!="string"||e.length===0)return null;const r=Wi(e),o={};if(n&&typeof n=="object")for(const[A,_]of Object.entries(n))if(_!==null&&typeof _=="object"&&typeof _.user=="string"){const R=t.userProperties?t.userProperties[_.user]:void 0;o[A]=R!==void 0?R:Gn(_)}else o[A]=Gn(_);const i=new Proxy(()=>i,{apply(){return i},get(A,_){if(_==="finish")return()=>o;if(typeof _=="string"&&ki.test(_))return R=>(R&&typeof R=="object"&&typeof R.name=="string"&&!(R.name in o)&&(o[R.name]=Gn(R.value)),i)}}),s={registerAsset:()=>{},frametime:1/60,runtime:0,canvasSize:Hi(t.canvasSize),screenResolution:t.screenResolution||{x:1920,y:1080},timeOfDay:typeof t.timeOfDay=="number"?t.timeOfDay:0,userProperties:t.userProperties||{},AUDIO_RESOLUTION_16:16,AUDIO_RESOLUTION_32:32,AUDIO_RESOLUTION_64:64,setTimeout:t.setTimeout||wn,clearTimeout:t.clearTimeout||(()=>{}),setInterval:t.setInterval||wn,clearInterval:t.clearInterval||(()=>{}),openUserShortcut:t.openUserShortcut||(()=>{}),isRunningInEditor:!!t.isRunningInEditor,isScreensaver:!!t.isScreensaver};Ui(s,t);const a=t.audioViews;s.registerAudioBuffers=A=>{const _=Math.max(1,Math.min(64,Math.floor(Number(A)||0)));let R=a?a.get(_):void 0;return R||(R={left:new Float32Array(_),right:new Float32Array(_),average:new Float32Array(_)},a&&a.set(_,R)),R};const c=t.shared||{},u={console:Fi()},l=Ii(t.inputView),f=t.layer||null,p=t.workshopId!=null?t.workshopId:Zc(e),d=yr(f,t),y=Kc({...t,workshopId:p,getWorkshopId:()=>p});let x;try{x=new Function("scriptProperties","engine","WEMath","WEColor","WEVector","createScriptProperties","shared","console","process","globalThis","self","window","document","require","module","exports","fetch","XMLHttpRequest","Worker","importScripts","location","navigator","alert","confirm","prompt","setTimeout","setInterval","clearTimeout","clearInterval","requestAnimationFrame","cancelAnimationFrame","performance","Function","Vec3","Vec2","input","thisLayer","thisScene","thisObject","localStorage","MediaPlaybackEvent",`"use strict";
|
|
180
180
|
`+r+`
|
|
181
|
-
;return {update: typeof update === "function" ? update : null,init: typeof init === "function" ? init : null,applyUserProperties: typeof applyUserProperties === "function" ? applyUserProperties : null,cursorClick: typeof cursorClick === "function" ? cursorClick : null,cursorEnter: typeof cursorEnter === "function" ? cursorEnter : null,cursorLeave: typeof cursorLeave === "function" ? cursorLeave : null,cursorDown: typeof cursorDown === "function" ? cursorDown : null,cursorUp: typeof cursorUp === "function" ? cursorUp : null,cursorMove: typeof cursorMove === "function" ? cursorMove : null,`+br.map(_=>`${_}: typeof ${_} === "function" ? ${_} : null,`).join("")+"dummy_: 0};")(o,Ei(s),Fi,ki,Ni,i,c,u.console,void 0,u,u,u,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,he,Ci,l,d,w,d,Nc(),Ui)}catch(T){return t.onError&&t.onError(T,"parse"),null}const m=!!(M&&(M.cursorClick||M.cursorEnter||M.cursorLeave||M.cursorDown||M.cursorUp||M.cursorMove)),A=!!(M&&br.some(T=>M[T])),h=!!(M&&typeof M.applyUserProperties=="function"),b=/\bengine\s*\.\s*(runtime|frametime)\b/.test(r);if(!M||!M.update&&!m&&!A&&!h&&!b)return null;const v={engine:s,scriptProperties:o,hasUpdate:!!M.update,hasCursorHook:m,hasApplyHook:h,errCount:0,disabled:!1,init(T){if(M.init)try{M.init(Li(T))}catch(_){v.errCount++,t.onError&&t.onError(_,"init")}},applyUserProperties(T){if(M.applyUserProperties)try{M.applyUserProperties(T||{})}catch(_){v.errCount++,t.onError&&t.onError(_,"applyUserProperties")}},callUpdate(T){if(v.disabled||!M.update)return;let _;try{_=M.update(Li(T))}catch(F){v.errCount++,t.onError&&t.onError(F,"update"),v.errCount>=3&&(v.disabled=!0);return}return _},hasCursorHook:m,callCursor(T,_){if(v.disabled)return;const F=M[T];if(typeof F=="function")try{return F(_)}catch(R){v.errCount++,t.onError&&t.onError(R,T),v.errCount>=3&&(v.disabled=!0);return}},hasMediaHook:A,callMedia(T,_){if(v.disabled)return;const F=M[T];if(typeof F=="function")try{return F(_)}catch(R){v.errCount++,t.onError&&t.onError(R,T),v.errCount>=3&&(v.disabled=!0);return}}};return v}function vr(e){const n=Array.isArray(e)?e:[0,0,0],t={x:n[0]||0,y:n[1]||0,z:n[2]||0},r={get x(){return t.x},set x(o){t.x=Number(o)||0},get y(){return t.y},set y(o){t.y=Number(o)||0},get z(){return t.z},set z(o){t.z=Number(o)||0},add(o){const i=Xt(o);return t.x+=i[0],t.y+=i[1],t.z+=i[2],r},subtract(o){const i=Xt(o);return t.x-=i[0],t.y-=i[1],t.z-=i[2],r},multiply(o){if(o&&typeof o=="object"){const i=Xt(o);t.x*=i[0],t.y*=i[1],t.z*=i[2]}else{const i=Number(o)||0;t.x*=i,t.y*=i,t.z*=i}return r},copy(){return new he(t.x,t.y,t.z)},length(){return Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z)},toArray(){return[t.x,t.y,t.z]}};return r}function Xt(e){if(Array.isArray(e))return[e[0]||0,e[1]||0,e[2]||0];if(e&&typeof e=="object")return[e.x||0,e.y||0,e.z||0];const n=Number(e)||0;return[n,n,n]}const xr=Math.PI/180,wr=180/Math.PI;function $c(e){const n=Array.isArray(e)?e:[0,0,0];return{x:(n[0]||0)*wr,y:(n[1]||0)*wr,z:(n[2]||0)*wr}}function ji(e){const n=Xt(e);return[n[0]*xr,n[1]*xr,n[2]*xr]}function jc(e){const n={x:0,y:1,z:2},t={add(r){const o=Xt(r);return t.x+=o[0],t.y+=o[1],t.z+=o[2],t},subtract(r){const o=Xt(r);return t.x-=o[0],t.y-=o[1],t.z-=o[2],t},multiply(r){return t.x*=r,t.y*=r,t.z*=r,t},toArray(){return[t.x,t.y,t.z]}};for(const r of["x","y","z"])Object.defineProperty(t,r,{enumerable:!0,get(){return!e||!Array.isArray(e.angles)?0:(e.angles[n[r]]||0)*wr},set(o){!e||!Array.isArray(e.angles)||(e.angles[n[r]]=(Number(o)||0)*xr)}});return t}function zc(e,n){return Math.min(256,Math.ceil(Math.max(1,Number(e)||1)*2+8))}function Vc(e){for(const n of e&&e.effects?e.effects:[]){if(n&&n.visible===!1)continue;if(String(n&&(n.file||n.name)||"").includes("tint"))return!0;for(const r of n&&n.passes||[])for(const o of r&&r.textures||[])if(o&&String(o).toLowerCase().includes("mask"))return!0}return!1}const Wc=Object.freeze(Object.defineProperty({__proto__:null,createInputView:Ec,drawTextLayer:Tc,effectiveTextPadding:Ai,evalObjectScript:Oc,evalTextScript:Rc,layoutText:Ac,makeCursorEventVec:Sc,radToScriptAngles:$c,resolveWorkshopAssetPath:$i,rewriteComboStringEq:Di,scriptAnglesToRad:ji,textCanvasMargin:zc,textLayerHasTintMask:Vc},Symbol.toStringTag,{value:"Module"}));function Hc(e={},n={}){const t=typeof e.setTimeout=="function"?e.setTimeout:null,r=typeof e.clearTimeout=="function"?e.clearTimeout:null,o=typeof e.setInterval=="function"?e.setInterval:null,i=typeof e.clearInterval=="function"?e.clearInterval:null,s=typeof n.onError=="function"?n.onError:null,a=new Set,c=m=>{const A=Number(m);return Number.isFinite(A)&&A>0?A:0},u=m=>()=>{try{m()}catch(A){s&&s(A,"timer")}},l=(m,A)=>{const h=()=>{m.fired||(m.fired=!0,a.delete(h),A&&m.handle!=null&&A(m.handle))};return h.handle=null,h.valueOf=()=>typeof m.handle=="number"?m.handle:0,h};function p(m,A){if(typeof m!="function")return l({fired:!0,handle:null},null);const h={fired:!1,handle:null},b=l(h,r);return a.add(b),h.handle=t?t(u(()=>{h.fired=!0,a.delete(b),m()}),c(A)):null,b.handle=h.handle,b}function f(m,A){if(typeof m!="function")return l({fired:!0,handle:null},null);const h={fired:!1,handle:null},b=l(h,i);return a.add(b),h.handle=o?o(u(m),c(A)):null,b.handle=h.handle,b}function d(m){if(typeof m=="function"){m();return}r&&m!=null&&r(m)}function w(m){if(typeof m=="function"){m();return}i&&m!=null&&i(m)}function M(){for(const m of[...a])m();a.clear()}return{setTimeout:p,setInterval:f,clearTimeout:d,clearInterval:w,dispose:M,pendingCount:()=>a.size}}const Xc=Object.freeze(Object.defineProperty({__proto__:null,createEngineTimers:Hc},Symbol.toStringTag,{value:"Module"}));function Gc(e){let n=e>>>0;return function(){n|=0,n=n+1831565813|0;let t=Math.imul(n^n>>>15,1|n);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}function fo(e,n){const t=Math.floor(e),r=e-t,o=s=>{const a=Math.sin((s*127.1+n*311.7)*43758.5453)*43758.5453;return(a-Math.floor(a))*2-1},i=r*r*(3-2*r);return o(t)*(1-i)+o(t+1)*i}const qc=32,Yc=112,zi=60/Yc,Zc=3.2;function Kc(e){const n=new Float32Array(16),t=new Float32Array(16),r=new Float32Array(16);for(let o=0;o<16;o++)n[o]=o%4===0?1:o%4===2?.38+e()*.15:e()<.08?.5:0,t[o]=o%8===4?1:e()<.06?.6:0,r[o]=o%2===1?.5+e()*.4:o%4===0?.25:e()<.3?.3:0;return{kick:n,snare:t,hat:r}}function Vi(e=20260830){const n=Gc(e),t=Kc(n),r=new Float32Array(64);for(let h=0;h<64;h++)r[h]=n()*64;const o=64,i=new Float32Array(o),s=new Float32Array(o),a=new Float32Array(o),c=new Float32Array(o),u=new Float32Array(o),l=new Float32Array(o),p=new Float32Array(32),f=new Float32Array(32),d=new Float32Array(16),w=new Float32Array(16),M={left64:u,right64:l,left32:p,right32:f,left16:d,right16:w,preL64:a,preR64:c,level:0,silent:!1};function m(h,b){const v=b.length/h.length;for(let T=0;T<h.length;T++){let _=0;const F=Math.floor(T*v),R=Math.floor((T+1)*v);for(let k=F;k<Math.max(F+1,R);k++)_+=b[k];h[T]=_/Math.max(1,R-F)}}function A(h){const b=h/zi,v=b*4,T=Math.floor(v)%16,_=v-Math.floor(v),F=Math.exp(-_*zi*14),R=h%qc,k=R>=27&&R<29,U=R>=29?(R-29)/3:0,V=R>=24&&R<27?1-(R-24)/3:0,q=k?0:U>0?U*U:V>0?0:1,W=k?0:V>0?.35:1,Z=t.kick[T]*F*q,K=(t.snare[T]*F+t.hat[T]*F*.7)*q,re=t.hat[T]*F*q,te=U>0?Math.pow(U,3)*(.4+.6*Math.abs(fo(v*2,7))):0;let X=0;for(let J=0;J<o;J++){const de=J/o,Se=Math.pow(1-de*.85,1.6);let Ae=W*(.5+.3*fo(b*.5+r[J]*.05,J%8));if(Ae*=.35+.65*de,de<.2&&(Ae+=Z*(1-de/.2)),de>=.12&&de<.62){const Pe=1-Math.abs(de-.34)/.28;Pe>0&&(Ae+=K*.55*Pe)}de>=.45&&(Ae+=re*.5*((de-.45)/.55)),Ae+=te*.5,Ae*=Se;const De=Ae;Ae=Math.min(1,Ae*Zc);const Qe=.06+de*.2,Ve=fo(b*.13+J*.35,11)*Qe;let Ee=Math.min(1,Math.max(0,Ae*(1-Ve))),Re=Math.min(1,Math.max(0,Ae*(1+Ve)));const le=k?.012:0;i[J]=Math.max(le,Ee),s[J]=Math.max(le,Re),a[J]=Math.max(le,Math.max(0,De*(1-Ve))),c[J]=Math.max(le,Math.max(0,De*(1+Ve))),J<48&&(X+=(i[J]+s[J])*.5)}return u.set(i),l.set(s),m(p,i),m(f,s),m(d,i),m(w,s),M.level=Math.min(1,X/(48*1.2)),M.silent=k,M}return{update:A,snapshot:M,bands:o}}function Qc(e,n){for(const t of e.values()){Wi(t.left,n.left64),Wi(t.right,n.right64);for(let r=0;r<t.average.length;r++)t.average[r]=(t.left[r]+t.right[r])*.5}}function Wi(e,n){const t=n.length/e.length;for(let r=0;r<e.length;r++){let o=0;const i=Math.floor(r*t),s=Math.max(i+1,Math.floor((r+1)*t));for(let a=i;a<s;a++)o+=n[a];e[r]=o/(s-i)}}const Gt={STOPPED:0,PLAYING:1,PAUSED:2};class Ue{constructor(n,t,r){this.x=Number(n)||0,this.y=Number(t)||0,this.z=Number(r)||0}add(n){return new Ue(this.x+n.x,this.y+n.y,this.z+n.z)}subtract(n){return new Ue(this.x-n.x,this.y-n.y,this.z-n.z)}multiply(n){if(n!==null&&typeof n=="object")return new Ue(this.x*n.x,this.y*n.y,this.z*n.z);const t=Number(n)||0;return new Ue(this.x*t,this.y*t,this.z*t)}divide(n){const t=Number(n)||1;return new Ue(this.x/t,this.y/t,this.z/t)}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}copy(){return new Ue(this.x,this.y,this.z)}toArray(){return[this.x,this.y,this.z]}}function Jc(e,n,t){return new Ue(e,n,t)}const el=[{title:"\u591C\u822A\u661F",artist:"\u76F8\u4F4D\u8FC1\u79FB",album:"\u6DF1\u7A7A\u56DE\u58F0",albumArtist:"\u76F8\u4F4D\u8FC1\u79FB",duration:212,colors:{primary:[.24,.42,.86],secondary:[.12,.18,.42],tertiary:[.62,.74,.98],text:[.95,.97,1]},lyrics:[[0,"\u5728\u65E0\u5149\u7684\u822A\u9053\u4E0A"],[12,"\u6211\u4EEC\u53EA\u5E26\u8D70\u5F7C\u6B64\u7684\u540D\u5B57"],[26,"\u5F15\u64CE\u4F4E\u9E23\u50CF\u4E00\u53E5\u65E7\u8BFA\u8A00"],[41,"\u628A\u9ED1\u6697\u6298\u6210\u4E24\u534A"],[58,"\u591C\u822A\u661F\u554A"],[72,"\u522B\u5728\u4E2D\u9014\u7184\u706D"],[95,"\uFF08\u95F4\u594F\uFF09"],[126,"\u5982\u679C\u5750\u6807\u7EC8\u5C06\u5931\u6548"],[140,"\u5C31\u8BA9\u8F68\u8FF9\u81EA\u5DF1\u8BF4\u8BDD"],[158,"\u6211\u4EEC\u4E0D\u8FD4\u822A"],[176,"\u4E5F\u4E0D\u9057\u61BE"],[198,"\u2026\u2026"]]},{title:"Amber Lantern",artist:"Hollow Coast",album:"Tidewater",albumArtist:"Hollow Coast",duration:187,colors:{primary:[.93,.62,.24],secondary:[.44,.24,.1],tertiary:[.99,.82,.56],text:[1,.98,.93]},lyrics:[[0,"Salt on the window frame"],[14,"a lantern swinging slow"],[30,"you said the tide forgets"],[46,"but the harbour never does"],[63,"Amber lantern, burn a little longer"],[88,"(instrumental)"],[118,"Every rope remembers the knot"],[134,"every shore remembers the leaving"],[152,"burn a little longer"],[170,"for me"]]},{title:"\u82D4\u75D5",artist:"\u6797\u95F4\u7535\u53F0",album:"\u534A\u5C71\u96E8",albumArtist:"\u6797\u95F4\u7535\u53F0",duration:241,colors:{primary:[.3,.68,.44],secondary:[.1,.28,.2],tertiary:[.72,.92,.78],text:[.96,1,.97]},lyrics:[[0,"\u96E8\u505C\u5728\u7B2C\u4E09\u7EA7\u53F0\u9636"],[16,"\u82D4\u75D5\u722C\u6EE1\u4E86\u65E7\u95E8\u724C"],[33,"\u4F60\u8BF4\u6162\u4E00\u70B9\u4E5F\u6CA1\u5173\u7CFB"],[52,"\u5C71\u4E0D\u4F1A\u8D70"],[70,"\u800C\u6211\u4EEC\u6709\u7684\u662F\u65F6\u95F4"],[92,"\uFF08\u95F4\u594F\uFF09"],[130,"\u628A\u4F1E\u6536\u8D77\u6765\u5427"],[148,"\u8BA9\u6F6E\u6C14\u8BB0\u4F4F\u8FD9\u4E00\u523B"],[172,"\u6162\u4E00\u70B9"],[200,"\u771F\u7684\u6CA1\u5173\u7CFB"],[226,"\u2026\u2026"]]},{title:"Neon Ashes",artist:"VELVET//NULL",album:"Afterimage",albumArtist:"VELVET//NULL",duration:168,colors:{primary:[.86,.22,.58],secondary:[.3,.06,.22],tertiary:[.99,.64,.86],text:[1,.94,.98]},lyrics:[[0,"city bleeds into the lens"],[11,"we were only afterimage"],[24,"neon ashes on your coat"],[38,"nothing here stays lit"],[55,"burn out with me"],[76,"(drop)"],[104,"nothing here stays lit"],[122,"burn out with me"],[146,"\u2026"]]}],Mr=3;function Hi(e=20260901){const n=el,t=n.reduce((A,h)=>A+h.duration+Mr,0),r={hasMedia:!1,state:Gt.STOPPED,title:"",artist:"",album:"",albumArtist:"",position:0,duration:0,hasThumbnail:!1,primaryColor:new Ue(0,0,0),secondaryColor:new Ue(0,0,0),tertiaryColor:new Ue(0,0,0),textColor:new Ue(1,1,1),highContrastColor:new Ue(1,1,1),trackIndex:-1,lyrics:[],lyricLine:"",lyricIndex:-1};let o=0,i=!1,s=0,a=0;function c(A){let h=0;const b=(A%n.length+n.length)%n.length;for(let v=0;v<b;v++)h+=n[v].duration+Mr;return h}function u(A){let h=t>0?A%t:0;h<0&&(h+=t);let b=-1,v=0,T=!1;for(let V=0;V<n.length;V++){const q=n[V].duration;if(h<q){b=V,v=h;break}if(h-=q,h<Mr){b=V,v=q,T=!0;break}h-=Mr}b<0&&(b=n.length-1,v=n[b].duration,T=!0);const _=n[b];r.hasMedia=!0,r.trackIndex=b,r.title=_.title,r.artist=_.artist,r.album=_.album,r.albumArtist=_.albumArtist,r.duration=_.duration,r.position=v;const F=_.duration>0?v/_.duration:0;i?r.state=Gt.PAUSED:T?r.state=Gt.STOPPED:F>.7&&F<.76?r.state=Gt.PAUSED:r.state=Gt.PLAYING,r.hasThumbnail=!T;const R=_.colors;r.primaryColor=new Ue(R.primary[0],R.primary[1],R.primary[2]),r.secondaryColor=new Ue(R.secondary[0],R.secondary[1],R.secondary[2]),r.tertiaryColor=new Ue(R.tertiary[0],R.tertiary[1],R.tertiary[2]),r.textColor=new Ue(R.text[0],R.text[1],R.text[2]);const k=.2126*R.primary[0]+.7152*R.primary[1]+.0722*R.primary[2];r.highContrastColor=k>.5?new Ue(0,0,0):new Ue(1,1,1),r.lyrics=_.lyrics;let U=-1;for(let V=0;V<_.lyrics.length;V++)v>=_.lyrics[V][0]&&(U=V);return r.lyricIndex=U,r.lyricLine=U>=0?_.lyrics[U][1]:"",r}function l(A){a=Number(A)||0;const h=i?s:a+o;return u(h)}function p(A){i=!1;const h=c(A);return o=h-a,u(h)}function f(){const A=r.trackIndex<0?0:r.trackIndex+1;return p(A)}function d(){const A=r.trackIndex<0?n.length-1:r.trackIndex-1;return p(A)}function w(){return i||(s=a+o,i=!0,r.state=Gt.PAUSED),r}function M(){return i?(i=!1,o=s-a,u(s)):r}function m(){return i?M():w()}return{update:l,snapshot:r,tracks:n,cycle:t,MEDIA_PLAYBACK:Gt,skipNext:f,skipPrevious:d,play:M,pause:w,playPause:m}}function tl(e,n=512){const t=Math.max(8,n|0),r=new Uint8Array(t*t*4),o=e&&e.colors?e.colors:{primary:[.5,.5,.5],secondary:[.1,.1,.1],tertiary:[.8,.8,.8]},[i,s,a]=o.primary,[c,u,l]=o.secondary,[p,f,d]=o.tertiary;for(let w=0;w<t;w++)for(let M=0;M<t;M++){const m=M/(t-1),A=w/(t-1),h=m-.5,b=A-.5,v=Math.sqrt(h*h+b*b)*2,T=.5+.5*Math.sin(v*18-1.2),_=.5+.5*Math.sin((m+A)*6),F=Math.min(1,Math.max(0,v));let R=i*(1-F)+c*F,k=s*(1-F)+u*F,U=a*(1-F)+l*F;R=R*(.72+.28*T)+p*.18*_,k=k*(.72+.28*T)+f*.18*_,U=U*(.72+.28*T)+d*.18*_;const V=1-.35*Math.min(1,v*v),q=(w*t+M)*4;r[q]=Math.max(0,Math.min(255,Math.round(R*V*255))),r[q+1]=Math.max(0,Math.min(255,Math.round(k*V*255))),r[q+2]=Math.max(0,Math.min(255,Math.round(U*V*255))),r[q+3]=255}return{width:t,height:t,rgba:r}}function nl(e,n){const t=[];if(!n)return t;const r=!e;return(r||e.hasMedia!==n.hasMedia)&&t.push({name:"mediaStatusChanged",event:{enabled:n.hasMedia}}),(r||e.title!==n.title||e.artist!==n.artist||e.album!==n.album||e.albumArtist!==n.albumArtist)&&t.push({name:"mediaPropertiesChanged",event:{title:n.title,artist:n.artist,album:n.album,albumArtist:n.albumArtist,albumTitle:n.album,subTitle:"",trackType:"music"}}),(r||e.hasThumbnail!==n.hasThumbnail||e.trackIndex!==n.trackIndex)&&t.push({name:"mediaThumbnailChanged",event:{hasThumbnail:n.hasThumbnail,primaryColor:n.primaryColor,secondaryColor:n.secondaryColor,tertiaryColor:n.tertiaryColor,textColor:n.textColor,highContrastColor:n.highContrastColor}}),(r||e.state!==n.state)&&t.push({name:"mediaPlaybackChanged",event:{state:n.state}}),(r||Math.floor(e.position)!==Math.floor(n.position)||e.duration!==n.duration)&&t.push({name:"mediaTimelineChanged",event:{position:n.position,duration:n.duration}}),(r||e.lyricIndex!==n.lyricIndex||e.trackIndex!==n.trackIndex)&&t.push({name:"mediaLyricsChanged",event:{line:n.lyricLine,index:n.lyricIndex,lines:n.lyrics}}),t}function rl(e){return e?{hasMedia:e.hasMedia,state:e.state,title:e.title,artist:e.artist,album:e.album,albumArtist:e.albumArtist,position:e.position,duration:e.duration,hasThumbnail:e.hasThumbnail,trackIndex:e.trackIndex,lyricIndex:e.lyricIndex,lyricLine:e.lyricLine}:null}const ol=Object.freeze(Object.defineProperty({__proto__:null,MEDIA_PLAYBACK:Gt,cloneMediaSnapshot:rl,createSimulatedMedia:Hi,diffMediaEvents:nl,mediaVec3:Jc,renderThumbnail:tl},Symbol.toStringTag,{value:"Module"})),Xi=14,Vn=[{app:"Safari",title:"GitHub \xB7 we-scene-renderer",url:"https://github.com/oneincase/we-scene-renderer"},{app:"Google Chrome",title:"YouTube",url:"https://www.youtube.com/watch?v=dQw4w9WgXcQ"},{app:"Google Chrome",title:"Wallpaper Engine - Workshop",url:"https://steamcommunity.com/app/431960/workshop/"},{app:"Safari",title:"MDN Web Docs",url:"https://developer.mozilla.org/en-US/docs/Web/API"},{app:"Music",title:"\u591C\u822A\u661F \u2014 \u76F8\u4F4D\u8FC1\u79FB",url:""},{app:"Code",title:"we-scene-renderer \u2014 text.js",url:""}];function Gi(){const e={app:"",title:"",url:"",index:-1};function n(t){const r=Number(t)||0,o=Vn.length?Math.floor(r/Xi)%Vn.length:0,i=Vn[o]||Vn[0];return e.app=i.app,e.title=i.title,e.url=i.url,e.index=o,e}return n(0),{update:n,snapshot:e,tabs:Vn,hold:Xi}}function qi(e){const n={name:"",at:0};function t(r){return n.name=String(r||""),n.at=Date.now(),typeof e=="function"&&e(n.name),n.name}return{openUserShortcut:t,last:n}}function il(e){const n=Hi(e),t=Gi(),r=qi(null);return{media:n,windowTitle:t,shortcuts:r}}const sl=Object.freeze(Object.defineProperty({__proto__:null,createShortcutHandler:qi,createSimulatedSystem:il,createSimulatedWindowTitle:Gi},Symbol.toStringTag,{value:"Module"}));function al(e={}){const n=e.target||(typeof window<"u"?window:null),t=e.viewport||(typeof window<"u"?()=>({w:window.innerWidth||1,h:window.innerHeight||1}):null),r={u:.5,v:.5,screenX:0,screenY:0,wx:0,wy:0,originY:null,lastU:.5,lastV:.5,lastScreenX:0,lastScreenY:0,lastWx:0,lastWy:0,lastOriginY:null,leftDown:!1,has:!1,moveCount:0,downCount:0,upCount:0,lastEventTime:0,screenW:1,screenH:1};function o(){if(!t)return;const f=t();r.screenW=f.w||1,r.screenH=f.h||1}o();function i(f,d){const w=f/r.screenW,M=d/r.screenH;r.has||(r.lastU=w,r.lastV=M,r.lastScreenX=f,r.lastScreenY=d),r.screenX=f,r.screenY=d,r.u=w,r.v=M,r.has=!0,r.moveCount++,r.lastEventTime=Date.now()}function s(f){const d=(f&1)!==0;d!==r.leftDown&&(r.leftDown=d,d?r.downCount++:r.upCount++,r.lastEventTime=Date.now())}function a(f){o();let d=f.clientX,w=f.clientY;if(n&&typeof n.getBoundingClientRect=="function"){const M=n.getBoundingClientRect();d-=M.left,w-=M.top}i(d,w)}function c(f){f.button!==void 0&&f.button!==0||s(1)}function u(f){f.button!==void 0&&f.button!==0||s(0)}function l(){s(0)}let p=!1;return n&&n.addEventListener&&(p=!0,n.addEventListener("mousemove",a,{passive:!0}),n.addEventListener("mousedown",c,{passive:!0}),n.addEventListener("mouseup",u,{passive:!0}),n.addEventListener("blur",l,{passive:!0}),typeof document<"u"&&document.addEventListener&&document.addEventListener("mouseleave",l,{passive:!0})),{state:r,pushExternal(f){if(!f)return;o();const d=Number(f.u),w=Number(f.v);Number.isFinite(d)&&Number.isFinite(w)&&i(d*r.screenW,w*r.screenH),s(Number(f.buttons)||0)},pushExternalLeave(){s(0)},beginFrame(){o(),r.lastU=r.u,r.lastV=r.v,r.lastScreenX=r.screenX,r.lastScreenY=r.screenY,r.lastWx=r.wx,r.lastWy=r.wy,r.lastOriginY=r.originY},syncWorld(f,d=0,w=0){if(!f)return;r.wx=f.offX+r.u*f.viewW-d,r.wy=f.offY+r.v*f.viewH-w;const M=Number(f.projH);r.originY=Number.isFinite(M)?M-r.wy:r.wy,r.lastWx===0&&r.lastWy===0&&(r.lastWx=r.wx,r.lastWy=r.wy,r.lastOriginY=r.originY)},normalizedDelta(){const f=r.u-r.lastU,d=r.v-r.lastV;return Math.hypot(f,d)},dispose(){!p||!n||!n.removeEventListener||(p=!1,n.removeEventListener("mousemove",a),n.removeEventListener("mousedown",c),n.removeEventListener("mouseup",u),n.removeEventListener("blur",l),typeof document<"u"&&document.removeEventListener&&document.removeEventListener("mouseleave",l))}}}const cl=Object.freeze(Object.defineProperty({__proto__:null,createPointerSource:al},Symbol.toStringTag,{value:"Module"}));function Yi(e,n,t,r,o,i,s){const a=e.size||[0,0],c=e.scale||[1,1,1],u=a[0]*c[0],l=a[1]*c[1];if(!(u>0)||!(l>0))return null;const p=e.origin||[0,0,0];let f=p[0],d=r-p[1];if(e.parallaxDepth&&(o!==0||i!==0)){const h=e.parallaxDepth,b=xn(h[0]),v=xn(h[1]);f+=b*o,d+=v*i}let w=n-f,M=t-d;const m=e.angles?e.angles[2]:0;if(m){const h=Math.cos(-m),b=Math.sin(-m),v=w*h+M*b,T=-w*b+M*h;w=v,M=T}const A=s&&s[e.alignment]||[.5,.5];return(A[0]!==.5||A[1]!==.5)&&(w-=(.5-A[0])*u,M-=(.5-A[1])*l),{lx:w/u,ly:M/l,w:u,h:l}}function ll(e,n,t,r,o={}){if(!e||e.length===0)return null;const i=o.parOffX||0,s=o.parOffY||0,a=o.alignTable,c=o.filter;for(let u=e.length-1;u>=0;u--){const l=e[u];if(!l||!l.visible||l.destroyed||c&&!c(l))continue;const p=Yi(l,n,t,r,i,s,a);if(p&&Math.abs(p.lx)<=.5&&Math.abs(p.ly)<=.5)return l}return null}const ul=Object.freeze(Object.defineProperty({__proto__:null,hitTestLayers:ll,worldToLayerLocal:Yi},Symbol.toStringTag,{value:"Module"})),Ge=e=>e,qe=Ge(As),_r=Ge($s),Ze=Ge(Qs),At=Ge(ra),je=Ge(Da),fl=Ge(Ia),dl=Ge(Wa),on=Ge(sc),Wn=Ge(_c),tt=Ge(Wc),pl=Ge(Xc),xe=Ge(ol),Zi=Ge(sl),Ki=Ge(Ra),hl=Ge(cl),ml=Ge(ul);function gl(e,n,t){return{camera:null,general:{orthogonalprojection:{width:e,height:n},clearenabled:!0,clearcolor:"0 0 0"},layers:[{id:0,name:"media",visible:!0,image:t,textureName:t,particle:null,puppet:null,solid:!1,isContainer:!1,isPostProcess:!1,isText:!1,isSound:!1,isComponent:!1,sound:[],origin:[e/2,n/2,0],scale:[1,1,1],angles:[0,0,0],size:[e,n],alignment:"center",color:[1,1,1],alpha:1,brightness:1,colorBlendMode:0,copybackground:!1,parallaxDepth:null,animationLayers:[],effects:[]}],properties:{}}}async function bl(e){const n=await fetch(e);if(!n.ok)throw new Error(`HTTP ${n.status}`);const t=new window.ImageDecoder({data:await n.arrayBuffer(),type:"image/gif"});await t.tracks.ready,await t.completed;const r=t.tracks.selectedTrack;if(!r||!r.frameCount)return null;const o=Math.min(r.frameCount,300),i=[];let s=0,a=0;for(let c=0;c<o;c++){const{image:u}=await t.decode({frameIndex:c});s=u.displayWidth,a=u.displayHeight,i.push({bitmap:await createImageBitmap(u),durationMs:u.duration?u.duration/1e3:100}),u.close()}return t.close?.(),{width:s,height:a,frames:i}}function yl(e,n){if(nn(e),!n.src){e.fallbackPage?.();return}const t=n.type==="video",r=n.type==="gif",o=document.createElement("canvas"),i=nr(e,n);if(o.width=Math.max(1,Math.round(innerWidth*i)),o.height=Math.max(1,Math.round(innerHeight*i)),o.style.cssText="position:absolute;inset:0;width:100%;height:100%;",!o.getContext("webgl2",{premultipliedAlpha:!1,antialias:!1,alpha:!1,preserveDrawingBuffer:!0})){se(e,n,`media ${n.type}: WEBGL2_UNAVAILABLE\uFF0C\u56DE\u9000 DOM \u6E32\u67D3`),t?vl(e,n):xl(e,n);return}e.wrap?.appendChild(o),e.canvas=o;let a=!1;e.sceneCleanup=()=>{a=!0,e.renderer&&(e.renderer.dispose?.(),e.renderer=void 0)};let c,u,l=!1;e.sceneCtl={pause(){c?.()},resume(){u?.()},applyUserProperties(){}};const p=f=>{a||(a=!0,se(e,n,`media ${n.type} \u5931\u8D25: ${f}`),e.fallbackPage?.())};(async()=>{try{const f=je.createRenderer(o,{diag:k=>se(e,n,`renderer: ${k}`),fboCapFactor:0});if(e.renderer=f,a)return;const d="__media",w=new Map;let M,m=0,A=0;if(t){const k=document.createElement("video");if(k.autoplay=!0,k.loop=n.loop!==!1,k.muted=n.muted!==!1,k.playsInline=!0,k.preload="metadata",k.width=o.width,k.height=o.height,k.style.cssText="position:fixed;left:-9999px;top:-9999px;width:2px;height:2px;opacity:0;pointer-events:none",k.src=n.src,document.body.appendChild(k),e.video=k,(e.videoTextures??=[]).push(k),await new Promise((U,V)=>{k.addEventListener("loadedmetadata",()=>U(),{once:!0}),k.addEventListener("error",()=>V(new Error(`video error ${k.error?.code??"?"}`)),{once:!0})}),a)return;m=k.videoWidth||o.width,A=k.videoHeight||o.height,w.set(d,{video:k,glTex:je.makeTexture(f.gl,new Uint8Array([0,0,0,255]),1,1),width:m,height:A,rg88:!1,lastUploaded:-1}),e.paused||k.play().catch(()=>{}),se(e,n,`media video ${m}x${A} \u2192 scene \u6E32\u67D3`)}else{let k=!1;if(r&&typeof window.ImageDecoder=="function")try{const U=await bl(n.src);if(U&&U.frames.length>1){m=U.width,A=U.height;const V=f.gl,q={glTex:je.makeTexture(V,null,0,0,U.frames[0].bitmap),width:m,height:A,rg88:!1};w.set(d,q);let W=0,Z=performance.now()+U.frames[0].durationMs;M=()=>{const re=performance.now();if(!(re<Z)){W=(W+1)%U.frames.length,Z=re+U.frames[W].durationMs,V.bindTexture(V.TEXTURE_2D,q.glTex);try{V.texImage2D(V.TEXTURE_2D,0,V.RGBA,V.RGBA,V.UNSIGNED_BYTE,U.frames[W].bitmap)}catch{}}};const K=e.sceneCleanup;e.sceneCleanup=()=>{K?.();for(const re of U.frames)re.bitmap.close()},k=!0,se(e,n,`media gif ${m}x${A} ${U.frames.length} \u5E27 \u2192 scene \u6E32\u67D3`)}}catch(U){se(e,n,`gif \u89E3\u7801\u5931\u8D25\uFF0C\u56DE\u9000\u9759\u6001\u9996\u5E27: ${String(U.message).slice(0,80)}`)}if(!k){const U=new Image;if(U.crossOrigin="anonymous",U.src=n.src,await new Promise((V,q)=>{U.addEventListener("load",()=>V(),{once:!0}),U.addEventListener("error",()=>q(new Error("image load error")),{once:!0})}),a)return;m=U.naturalWidth||1,A=U.naturalHeight||1,e.img=U,w.set(d,{glTex:je.makeTexture(f.gl,null,0,0,U),width:m,height:A,rg88:!1}),se(e,n,`media ${n.type} ${m}x${A} \u2192 scene \u6E32\u67D3`)}}if(a)return;const h=gl(m,A,d),b=performance.now();let v=0,T=0,_=-1/0;const F=k=>{if(a||e.paused)return;const U=e.cfg.sceneFps||60;if(k-_>=1e3/U){_=k,rr(e,k),wo(e,o,e.cfg),M?.();const V=e.coverAlign;f.render(h,w,o.width,o.height,(k-b-v)/1e3,hn(e.cfg.fit),V.x,V.y).then(()=>{a||e.paused||(e.raf=requestAnimationFrame(F))}).catch(q=>p(String(q.message||q).slice(0,200)))}else e.paused||(e.raf=requestAnimationFrame(F))},R=()=>{a||e.paused||e.raf===void 0&&(e.raf=requestAnimationFrame(F))};c=()=>{e.raf!==void 0&&(cancelAnimationFrame(e.raf),e.raf=void 0),T||(T=performance.now());const k=e.video;l=!!(k&&!k.paused&&!k.ended),k?.pause()},u=()=>{T&&(v+=performance.now()-T,T=0),l&&e.video?.play().catch(()=>{}),l=!1,R()},R()}catch(f){p(String(f.message||f).slice(0,200))}})()}function vl(e,n){if(nn(e),!n.src){e.fallbackPage?.();return}const t=yo(n.fit),r=`position:absolute;inset:0;width:100%;height:100%;object-fit:${t.objectFit};object-position:50% 50%;background:${t.background};`;let o=!1;const i=()=>{o||(o=!0,console.warn("video error, fallback to default wallpaper"),e.fallbackPage?.())},s=document.createElement("video");s.autoplay=!0,s.loop=n.loop!==!1,s.muted=n.muted!==!1,s.playsInline=!0,s.preload="metadata";const a=Math.min(window.devicePixelRatio||1,e.cfg.renderDpr||1);s.width=Math.max(1,Math.round(innerWidth*a)),s.height=Math.max(1,Math.round(innerHeight*a)),s.style.cssText=r,s.src=n.src,s.addEventListener("error",i),e.wrap?.appendChild(s),e.video=s,s.addEventListener("canplay",()=>s.play().catch(()=>{}),{once:!0}),se(e,n,"video mounted (single + native loop)")}function xl(e,n){nn(e);const t=document.createElement("img"),r=yo(n.fit);t.style.cssText=`position:absolute;inset:0;width:100%;height:100%;object-fit:${r.objectFit};object-position:50% 50%;background:${r.background};`,t.src=n.src??"",t.addEventListener("error",()=>e.fallbackPage?.()),e.wrap?.appendChild(t),e.img=t}const wl=["scene.pkg","scenes/scene.pkg","gifscene.pkg"];function Qi(e,n){const t=e.replace(/\/+$/,"");return{key:t,async scenePkg(r){let o=null,i=null;for(const a of wl){let c;try{c=await fetch(`${t}/${a}`,{...n,signal:r})}catch(u){if(r?.aborted)throw u;i=u;continue}if(!c.ok){o=c.status;continue}try{return await c.arrayBuffer()}catch(u){if(r?.aborted)throw u;const l=u instanceof Error?u.message:String(u);throw new Error(`\u8BFB\u53D6 scene.pkg \u4F53\u5931\u8D25\uFF08${l}\uFF09`)}}if(o!=null)throw new Error(`scene.pkg \u52A0\u8F7D\u5931\u8D25\uFF08HTTP ${o}\uFF09`);const s=i instanceof Error?i.message:"Failed to fetch";throw new Error(`scene.pkg \u52A0\u8F7D\u5931\u8D25\uFF08${s}\uFF09`)},async project(r){try{const o=await fetch(`${t}/project.json`,{...n,signal:r});return o.ok?await o.json():null}catch{return null}},async webEntry(r){let o="index.html";try{const i=await fetch(`${t}/project.json`,{...n,signal:r});if(i.ok){const s=await i.json();s&&typeof s.file=="string"&&s.file.trim()&&(o=s.file.trim().replace(/^\/+/,""))}}catch{if(r?.aborted)throw new Error("aborted")}return{url:`${t}/${o}`}}}}function Ml(e,n){const t=e;return{key:typeof t.name=="string"?`file:${t.name}:${t.size}:${t.lastModified??0}`:void 0,scenePkg:()=>e.arrayBuffer(),project:async()=>n??null}}function _l(e,n,t){return{key:t,scenePkg:async()=>e,project:async()=>n??null}}const Ji=.5,Al=.04,es=.08;function Tl(e,n){const t=h=>{const b=document.createElement("video");h&&(b.src=e),b.muted=n.muted,b.playsInline=!0,b.preload="metadata";const v=Math.min(window.devicePixelRatio||1,n.renderDpr||1),T=Math.max(1,Math.round(n.maxW*v)),_=Math.max(1,Math.round(n.maxH*v));return b.width=T,b.height=_,b.loop=!0,b};let r=t(!0),o=t(!1),i=!1,s=1,a=n.muted;o.muted=!0;const c=()=>{i||(o.src=e,i=!0)};let u=!1,l=!1,p=-1,f=0,d=!1;const w=()=>{if(u=!1,l=!1,!o.paused){o.pause();try{o.currentTime=0}catch{}}},M=()=>{const h=r;r=o,o=h,u=!1,l=!1,r.play().catch(()=>{}),r.muted=a,r.volume=s,h.pause();try{h.currentTime=0}catch{}h.muted=!0,p=-1,i=!0,A.onSwap?.(r)},m=()=>{if(d)return;f=requestAnimationFrame(m);const h=r.duration;if(!isFinite(h)||h<=0)return;const b=r.currentTime;if(p>=0&&b<p-.05){const T=l;w(),p=b,T||A.onFallback?.();return}p=b;const v=h-b;if(v>Ji+.5){(u||l)&&w();return}if(l){(v<=es||b<=es)&&M();return}if(u){o.paused?o.play().catch(()=>{}):o.currentTime>=Al*.5&&(o.pause(),u=!1,l=!0);return}if(v<=Ji&&(c(),o.readyState>=2)){try{o.currentTime=0}catch{}o.play().catch(()=>{}),u=!0}};f=requestAnimationFrame(m);const A={get active(){return r},get standby(){return o},onSwap:void 0,onFallback:void 0,setVolume(h){s=Math.max(0,Math.min(1,h)),a=h<=0,r.muted=a,r.volume=s,o.muted=!0,o.volume=s},pause(){w(),r.pause(),f&&cancelAnimationFrame(f),f=0},resume(){d||(r.play().catch(h=>{h&&h.name}),f||(f=requestAnimationFrame(m)))},destroy(){d=!0,f&&cancelAnimationFrame(f),f=0;for(const h of[r,o]){h.pause(),h.removeAttribute("src");try{h.load()}catch{}h.remove()}}};return A}const ts=!1,ns=!0,rs=!1,Sl=!1,El=!1,os=4,Hn=64,is={STOPPED:0};function Pl(){return{left64:new Float32Array(Hn),right64:new Float32Array(Hn),left32:new Float32Array(32),right32:new Float32Array(32),left16:new Float32Array(16),right16:new Float32Array(16),level:0,silent:!0}}function Ar(e,n){const t=n.length/e.length;for(let r=0;r<e.length;r++){let o=0;const i=Math.floor(r*t),s=Math.max(i+1,Math.floor((r+1)*t));for(let a=i;a<s;a++)o+=n[a];e[r]=o/(s-i)}}function Cl(e,n,t){const r=n.length,o=t*.5,i=20,s=Math.min(2e4,o);let a=0;for(let c=0;c<Hn;c++){const u=c/Hn,l=(c+1)/Hn,p=i*Math.pow(s/i,u),f=i*Math.pow(s/i,l),d=Math.max(0,Math.floor(p/o*r)),w=Math.min(r,Math.max(d+1,Math.ceil(f/o*r)));let M=0;for(let A=d;A<w;A++)M+=n[A]/255;const m=Math.min(1,M/(w-d)*1.35);e.left64[c]=m,e.right64[c]=m,c<48&&(a+=m)}Ar(e.left32,e.left64),Ar(e.right32,e.right64),Ar(e.left16,e.left64),Ar(e.right16,e.right64),e.level=Math.min(1,a/(48*1.2)),e.silent=e.level<.02}function Ll(e){let n=2166136261;for(let t=0;t<e.length;t++)n^=e.charCodeAt(t),n=Math.imul(n,16777619);return(n>>>0)%360}function po(e,n,t){const r=n/100,o=t/100,i=(1-Math.abs(2*o-1))*r,s=e/60,a=i*(1-Math.abs(s%2-1));let c=0,u=0,l=0;s<1?[c,u,l]=[i,a,0]:s<2?[c,u,l]=[a,i,0]:s<3?[c,u,l]=[0,i,a]:s<4?[c,u,l]=[0,a,i]:s<5?[c,u,l]=[a,0,i]:[c,u,l]=[i,0,a];const p=o-i/2;return[c+p,u+p,l+p]}function Rl(e,n){const t=Ll(n||"empty"),[r,o,i]=po(t,72,48),[s,a,c]=po((t+40)%360,55,28),[u,l,p]=po((t+20)%360,70,72);e.primaryColor=xe.mediaVec3(r,o,i),e.secondaryColor=xe.mediaVec3(s,a,c),e.tertiaryColor=xe.mediaVec3(u,l,p),e.textColor=xe.mediaVec3(.98,.98,1),e.highContrastColor=xe.mediaVec3(1,1,1),e.hasThumbnail=!!n}function Fl(e,n,t){const r=document.createElement("canvas");r.width=32,r.height=32;const o=r.getContext("2d",{willReadFrequently:!0});if(!o)return null;o.drawImage(e,0,0,n,t,0,0,32,32);const i=o.getImageData(0,0,32,32).data;let s=0,a=0,c=0,u=0,l=0,p=0,f=0,d=-1;for(let A=0;A<i.length;A+=4){const h=i[A]/255,b=i[A+1]/255,v=i[A+2]/255;s+=h,a+=b,c+=v,u++;const T=Math.max(h,b,v),_=Math.min(h,b,v),F=T-_,R=.2126*h+.7152*b+.0722*v,k=F*1.4+(R>.15&&R<.85?.3:0);k>d&&(d=k,l=h,p=b,f=v)}if(!u)return null;const w=[l,p,f],M=[s/u*.55,a/u*.55,c/u*.55],m=[Math.min(1,w[0]*.45+.55),Math.min(1,w[1]*.45+.55),Math.min(1,w[2]*.45+.55)];return{primary:w,secondary:M,tertiary:m}}function kl(e,n,t,r=512){const o=document.createElement("canvas");o.width=r,o.height=r;const i=o.getContext("2d"),s=Math.max(r/Math.max(1,n),r/Math.max(1,t)),a=n*s,c=t*s;i.fillStyle="#000",i.fillRect(0,0,r,r),i.drawImage(e,(r-a)/2,(r-c)/2,a,c);const u=i.getImageData(0,0,r,r);return{width:r,height:r,rgba:new Uint8Array(u.data)}}function Nl(){return{hasMedia:!1,state:is.STOPPED,title:"",artist:"",album:"",albumArtist:"",position:0,duration:0,hasThumbnail:!1,primaryColor:xe.mediaVec3(0,0,0),secondaryColor:xe.mediaVec3(0,0,0),tertiaryColor:xe.mediaVec3(0,0,0),textColor:xe.mediaVec3(1,1,1),highContrastColor:xe.mediaVec3(1,1,1),trackIndex:-1,lyrics:[],lyricLine:"",lyricIndex:-1}}async function Ul(){if(!navigator.mediaDevices?.getUserMedia)return null;try{const e=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1},video:!1}),n=new AudioContext,t=n.createMediaStreamSource(e),r=n.createAnalyser();return r.fftSize=2048,r.smoothingTimeConstant=.8,t.connect(r),n.state==="suspended"&&await n.resume().catch(()=>{}),{ctx:n,stream:e,analyser:r,buf:new Uint8Array(r.frequencyBinCount)}}catch{return null}}async function Dl(e){const n=e?.origin??(typeof location<"u"?location.origin:""),t=e?.onArtwork,r=Pl(),o=Nl(),i={app:"",title:"",url:"",index:0};let s="off",a="offline",c="offline",u="",l=!1,p="";const f=await Ul();f?s="mic":navigator.mediaDevices?.getUserMedia?s="denied":s="unavailable";let d=null,w=null,M=!1;const m=(T,_,F)=>{!n||!t||!l||p!==T&&(p=T,t({url:`${n}/api/system/artwork?k=${encodeURIComponent(T)}&_=${Date.now()}`,trackKey:T,title:_,artist:F}))},A=T=>{if(!T||!T.hasMedia){o.hasMedia=!1,o.state=is.STOPPED,o.title="",o.artist="",o.album="",o.albumArtist="",o.position=0,o.duration=0,o.hasThumbnail=!1,o.trackIndex=-1,a=T?"empty":"offline",u="",l=!1,p="";return}a="live",o.hasMedia=!0,o.state=Number(T.state)===2?2:Number(T.state)===1?1:0,o.title=String(T.title??""),o.artist=String(T.artist??""),o.album=String(T.album??""),o.albumArtist=String(T.albumArtist??T.artist??""),o.position=Number(T.position)||0,o.duration=Number(T.duration)||0,l=T.hasArtwork===!0;const _=`${o.title}|${o.artist}|${o.album}`;_!==u&&(u=_,p="",o.trackIndex=o.trackIndex+1|0,Rl(o,_)),m(_,o.title,o.artist)},h=T=>{if(!T){c="offline";return}i.app=String(T.app??""),i.title=String(T.title??""),i.url=String(T.url??""),c=i.app||i.title?"live":"empty"},b=async()=>{if(!(!n||M))try{const[T,_]=await Promise.all([fetch(`${n}/api/system/media`,{cache:"no-store"}),fetch(`${n}/api/system/window`,{cache:"no-store"})]);if(T.ok){const F=await T.json();A(F)}else a="offline";_.ok&&h(await _.json())}catch{a=a==="live"?"live":"offline",c=c==="live"?"live":"offline"}};if(n){await b(),w=setInterval(()=>{b()},1e3);try{d=new EventSource(`${n}/api/system/stream`),d.onmessage=T=>{if(!M)try{const _=JSON.parse(T.data);A(_.media),h(_.window)}catch{}}}catch{}}const v=T=>{!n||M||fetch(`${n}/api/system/media-control`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:T})}).then(async _=>_.ok?_.json():null).then(_=>{_&&typeof _=="object"&&A(_),b()}).catch(()=>{b()})};return{audio:{snapshot:r,pump:()=>{if(!f||M){r.level=0,r.silent=!0;return}f.analyser.getByteFrequencyData(f.buf),Cl(r,f.buf,f.ctx.sampleRate||48e3)}},media:{snapshot:o,pump:()=>{},skipNext:()=>v("skipNext"),skipPrevious:()=>v("skipPrevious"),play:()=>v("play"),pause:()=>v("pause"),playPause:()=>v("playPause")},windowTitle:{snapshot:i,pump:()=>{}},status:()=>({audio:s,media:a,window:c,title:o.title,artist:o.artist,app:i.app,windowTitle:i.title,hasArtwork:l}),dispose:()=>{M=!0,w&&(clearInterval(w),w=null);try{d?.close()}catch{}if(d=null,f)try{f.stream.getTracks().forEach(T=>T.stop()),f.ctx.close()}catch{}}}}const Bl={"common.h":`// WE common.h\uFF08\u91CD\u5EFA\u5B50\u96C6\uFF0C\u4F9B we-scene \u6D4F\u89C8\u5668\u6E32\u67D3\uFF09
|
|
181
|
+
;return {update: typeof update === "function" ? update : null,init: typeof init === "function" ? init : null,applyUserProperties: typeof applyUserProperties === "function" ? applyUserProperties : null,cursorClick: typeof cursorClick === "function" ? cursorClick : null,cursorEnter: typeof cursorEnter === "function" ? cursorEnter : null,cursorLeave: typeof cursorLeave === "function" ? cursorLeave : null,cursorDown: typeof cursorDown === "function" ? cursorDown : null,cursorUp: typeof cursorUp === "function" ? cursorUp : null,cursorMove: typeof cursorMove === "function" ? cursorMove : null,`+br.map(_=>`${_}: typeof ${_} === "function" ? ${_} : null,`).join("")+"dummy_: 0};")(o,Ni(s),Oi,$i,ji,i,c,u.console,void 0,u,u,u,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,ge,Di,l,d,y,d,Gc(),zi)}catch(A){return t.onError&&t.onError(A,"parse"),null}const m=!!(x&&(x.cursorClick||x.cursorEnter||x.cursorLeave||x.cursorDown||x.cursorUp||x.cursorMove)),M=!!(x&&br.some(A=>x[A])),h=!!(x&&typeof x.applyUserProperties=="function"),g=/\bengine\s*\.\s*(runtime|frametime)\b/.test(r);if(!x||!x.update&&!m&&!M&&!h&&!g)return null;const v={engine:s,scriptProperties:o,hasUpdate:!!x.update,hasCursorHook:m,hasApplyHook:h,errCount:0,disabled:!1,init(A){if(x.init)try{x.init(Bi(A))}catch(_){v.errCount++,t.onError&&t.onError(_,"init")}},applyUserProperties(A){if(x.applyUserProperties)try{x.applyUserProperties(A||{})}catch(_){v.errCount++,t.onError&&t.onError(_,"applyUserProperties")}},callUpdate(A){if(v.disabled||!x.update)return;let _;try{_=x.update(Bi(A))}catch(R){v.errCount++,t.onError&&t.onError(R,"update"),v.errCount>=3&&(v.disabled=!0);return}return _},hasCursorHook:m,callCursor(A,_){if(v.disabled)return;const R=x[A];if(typeof R=="function")try{return R(_)}catch(L){v.errCount++,t.onError&&t.onError(L,A),v.errCount>=3&&(v.disabled=!0);return}},hasMediaHook:M,callMedia(A,_){if(v.disabled)return;const R=x[A];if(typeof R=="function")try{return R(_)}catch(L){v.errCount++,t.onError&&t.onError(L,A),v.errCount>=3&&(v.disabled=!0);return}}};return v}function vr(e){const n=Array.isArray(e)?e:[0,0,0],t={x:n[0]||0,y:n[1]||0,z:n[2]||0},r={get x(){return t.x},set x(o){t.x=Number(o)||0},get y(){return t.y},set y(o){t.y=Number(o)||0},get z(){return t.z},set z(o){t.z=Number(o)||0},add(o){const i=Jt(o);return t.x+=i[0],t.y+=i[1],t.z+=i[2],r},subtract(o){const i=Jt(o);return t.x-=i[0],t.y-=i[1],t.z-=i[2],r},multiply(o){if(o&&typeof o=="object"){const i=Jt(o);t.x*=i[0],t.y*=i[1],t.z*=i[2]}else{const i=Number(o)||0;t.x*=i,t.y*=i,t.z*=i}return r},copy(){return new ge(t.x,t.y,t.z)},length(){return Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z)},toArray(){return[t.x,t.y,t.z]}};return r}function Jt(e){if(Array.isArray(e))return[e[0]||0,e[1]||0,e[2]||0];if(e&&typeof e=="object")return[e.x||0,e.y||0,e.z||0];const n=Number(e)||0;return[n,n,n]}const xr=Math.PI/180,wr=180/Math.PI;function Jc(e){const n=Array.isArray(e)?e:[0,0,0];return{x:(n[0]||0)*wr,y:(n[1]||0)*wr,z:(n[2]||0)*wr}}function Yi(e){const n=Jt(e);return[n[0]*xr,n[1]*xr,n[2]*xr]}function el(e){const n={x:0,y:1,z:2},t={add(r){const o=Jt(r);return t.x+=o[0],t.y+=o[1],t.z+=o[2],t},subtract(r){const o=Jt(r);return t.x-=o[0],t.y-=o[1],t.z-=o[2],t},multiply(r){return t.x*=r,t.y*=r,t.z*=r,t},toArray(){return[t.x,t.y,t.z]}};for(const r of["x","y","z"])Object.defineProperty(t,r,{enumerable:!0,get(){return!e||!Array.isArray(e.angles)?0:(e.angles[n[r]]||0)*wr},set(o){!e||!Array.isArray(e.angles)||(e.angles[n[r]]=(Number(o)||0)*xr)}});return t}function tl(e,n){return Math.min(256,Math.ceil(Math.max(1,Number(e)||1)*2+8))}function nl(e){for(const n of e&&e.effects?e.effects:[]){if(n&&n.visible===!1)continue;if(String(n&&(n.file||n.name)||"").includes("tint"))return!0;for(const r of n&&n.passes||[])for(const o of r&&r.textures||[])if(o&&String(o).toLowerCase().includes("mask"))return!0}return!1}const rl=Object.freeze(Object.defineProperty({__proto__:null,createInputView:$c,drawTextLayer:Ic,effectiveTextPadding:Ri,evalObjectScript:Qc,evalTextScript:Wc,layoutText:Bc,makeCursorEventVec:Oc,radToScriptAngles:Jc,resolveWorkshopAssetPath:Gi,rewriteComboStringEq:Vi,scriptAnglesToRad:Yi,textCanvasMargin:tl,textLayerHasTintMask:nl},Symbol.toStringTag,{value:"Module"}));function ol(e={},n={}){const t=typeof e.setTimeout=="function"?e.setTimeout:null,r=typeof e.clearTimeout=="function"?e.clearTimeout:null,o=typeof e.setInterval=="function"?e.setInterval:null,i=typeof e.clearInterval=="function"?e.clearInterval:null,s=typeof n.onError=="function"?n.onError:null,a=new Set,c=m=>{const M=Number(m);return Number.isFinite(M)&&M>0?M:0},u=m=>()=>{try{m()}catch(M){s&&s(M,"timer")}},l=(m,M)=>{const h=()=>{m.fired||(m.fired=!0,a.delete(h),M&&m.handle!=null&&M(m.handle))};return h.handle=null,h.valueOf=()=>typeof m.handle=="number"?m.handle:0,h};function f(m,M){if(typeof m!="function")return l({fired:!0,handle:null},null);const h={fired:!1,handle:null},g=l(h,r);return a.add(g),h.handle=t?t(u(()=>{h.fired=!0,a.delete(g),m()}),c(M)):null,g.handle=h.handle,g}function p(m,M){if(typeof m!="function")return l({fired:!0,handle:null},null);const h={fired:!1,handle:null},g=l(h,i);return a.add(g),h.handle=o?o(u(m),c(M)):null,g.handle=h.handle,g}function d(m){if(typeof m=="function"){m();return}r&&m!=null&&r(m)}function y(m){if(typeof m=="function"){m();return}i&&m!=null&&i(m)}function x(){for(const m of[...a])m();a.clear()}return{setTimeout:f,setInterval:p,clearTimeout:d,clearInterval:y,dispose:x,pendingCount:()=>a.size}}const il=Object.freeze(Object.defineProperty({__proto__:null,createEngineTimers:ol},Symbol.toStringTag,{value:"Module"}));function sl(e){let n=e>>>0;return function(){n|=0,n=n+1831565813|0;let t=Math.imul(n^n>>>15,1|n);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}function ho(e,n){const t=Math.floor(e),r=e-t,o=s=>{const a=Math.sin((s*127.1+n*311.7)*43758.5453)*43758.5453;return(a-Math.floor(a))*2-1},i=r*r*(3-2*r);return o(t)*(1-i)+o(t+1)*i}const al=32,cl=112,qi=60/cl,ll=3.2;function ul(e){const n=new Float32Array(16),t=new Float32Array(16),r=new Float32Array(16);for(let o=0;o<16;o++)n[o]=o%4===0?1:o%4===2?.38+e()*.15:e()<.08?.5:0,t[o]=o%8===4?1:e()<.06?.6:0,r[o]=o%2===1?.5+e()*.4:o%4===0?.25:e()<.3?.3:0;return{kick:n,snare:t,hat:r}}function Zi(e=20260830){const n=sl(e),t=ul(n),r=new Float32Array(64);for(let h=0;h<64;h++)r[h]=n()*64;const o=64,i=new Float32Array(o),s=new Float32Array(o),a=new Float32Array(o),c=new Float32Array(o),u=new Float32Array(o),l=new Float32Array(o),f=new Float32Array(32),p=new Float32Array(32),d=new Float32Array(16),y=new Float32Array(16),x={left64:u,right64:l,left32:f,right32:p,left16:d,right16:y,preL64:a,preR64:c,level:0,silent:!1};function m(h,g){const v=g.length/h.length;for(let A=0;A<h.length;A++){let _=0;const R=Math.floor(A*v),L=Math.floor((A+1)*v);for(let N=R;N<Math.max(R+1,L);N++)_+=g[N];h[A]=_/Math.max(1,L-R)}}function M(h){const g=h/qi,v=g*4,A=Math.floor(v)%16,_=v-Math.floor(v),R=Math.exp(-_*qi*14),L=h%al,N=L>=27&&L<29,j=L>=29?(L-29)/3:0,H=L>=24&&L<27?1-(L-24)/3:0,K=N?0:j>0?j*j:H>0?0:1,O=N?0:H>0?.35:1,W=t.kick[A]*R*K,X=(t.snare[A]*R+t.hat[A]*R*.7)*K,ie=t.hat[A]*R*K,J=j>0?Math.pow(j,3)*(.4+.6*Math.abs(ho(v*2,7))):0;let Z=0;for(let te=0;te<o;te++){const le=te/o,Fe=Math.pow(1-le*.85,1.6);let _e=O*(.5+.3*ho(g*.5+r[te]*.05,te%8));if(_e*=.35+.65*le,le<.2&&(_e+=W*(1-le/.2)),le>=.12&&le<.62){const he=1-Math.abs(le-.34)/.28;he>0&&(_e+=X*.55*he)}le>=.45&&(_e+=ie*.5*((le-.45)/.55)),_e+=J*.5,_e*=Fe;const Ye=_e;_e=Math.min(1,_e*ll);const Ve=.06+le*.2,Ne=ho(g*.13+te*.35,11)*Ve;let qe=Math.min(1,Math.max(0,_e*(1-Ne))),Ue=Math.min(1,Math.max(0,_e*(1+Ne)));const ye=N?.012:0;i[te]=Math.max(ye,qe),s[te]=Math.max(ye,Ue),a[te]=Math.max(ye,Math.max(0,Ye*(1-Ne))),c[te]=Math.max(ye,Math.max(0,Ye*(1+Ne))),te<48&&(Z+=(i[te]+s[te])*.5)}return u.set(i),l.set(s),m(f,i),m(p,s),m(d,i),m(y,s),x.level=Math.min(1,Z/(48*1.2)),x.silent=N,x}return{update:M,snapshot:x,bands:o}}function fl(e,n){for(const t of e.values()){Ki(t.left,n.left64),Ki(t.right,n.right64);for(let r=0;r<t.average.length;r++)t.average[r]=(t.left[r]+t.right[r])*.5}}function Ki(e,n){const t=n.length/e.length;for(let r=0;r<e.length;r++){let o=0;const i=Math.floor(r*t),s=Math.max(i+1,Math.floor((r+1)*t));for(let a=i;a<s;a++)o+=n[a];e[r]=o/(s-i)}}const en={STOPPED:0,PLAYING:1,PAUSED:2};class ke{constructor(n,t,r){this.x=Number(n)||0,this.y=Number(t)||0,this.z=Number(r)||0}add(n){return new ke(this.x+n.x,this.y+n.y,this.z+n.z)}subtract(n){return new ke(this.x-n.x,this.y-n.y,this.z-n.z)}multiply(n){if(n!==null&&typeof n=="object")return new ke(this.x*n.x,this.y*n.y,this.z*n.z);const t=Number(n)||0;return new ke(this.x*t,this.y*t,this.z*t)}divide(n){const t=Number(n)||1;return new ke(this.x/t,this.y/t,this.z/t)}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}copy(){return new ke(this.x,this.y,this.z)}toArray(){return[this.x,this.y,this.z]}}function dl(e,n,t){return new ke(e,n,t)}const pl=[{title:"\u591C\u822A\u661F",artist:"\u76F8\u4F4D\u8FC1\u79FB",album:"\u6DF1\u7A7A\u56DE\u58F0",albumArtist:"\u76F8\u4F4D\u8FC1\u79FB",duration:212,colors:{primary:[.24,.42,.86],secondary:[.12,.18,.42],tertiary:[.62,.74,.98],text:[.95,.97,1]},lyrics:[[0,"\u5728\u65E0\u5149\u7684\u822A\u9053\u4E0A"],[12,"\u6211\u4EEC\u53EA\u5E26\u8D70\u5F7C\u6B64\u7684\u540D\u5B57"],[26,"\u5F15\u64CE\u4F4E\u9E23\u50CF\u4E00\u53E5\u65E7\u8BFA\u8A00"],[41,"\u628A\u9ED1\u6697\u6298\u6210\u4E24\u534A"],[58,"\u591C\u822A\u661F\u554A"],[72,"\u522B\u5728\u4E2D\u9014\u7184\u706D"],[95,"\uFF08\u95F4\u594F\uFF09"],[126,"\u5982\u679C\u5750\u6807\u7EC8\u5C06\u5931\u6548"],[140,"\u5C31\u8BA9\u8F68\u8FF9\u81EA\u5DF1\u8BF4\u8BDD"],[158,"\u6211\u4EEC\u4E0D\u8FD4\u822A"],[176,"\u4E5F\u4E0D\u9057\u61BE"],[198,"\u2026\u2026"]]},{title:"Amber Lantern",artist:"Hollow Coast",album:"Tidewater",albumArtist:"Hollow Coast",duration:187,colors:{primary:[.93,.62,.24],secondary:[.44,.24,.1],tertiary:[.99,.82,.56],text:[1,.98,.93]},lyrics:[[0,"Salt on the window frame"],[14,"a lantern swinging slow"],[30,"you said the tide forgets"],[46,"but the harbour never does"],[63,"Amber lantern, burn a little longer"],[88,"(instrumental)"],[118,"Every rope remembers the knot"],[134,"every shore remembers the leaving"],[152,"burn a little longer"],[170,"for me"]]},{title:"\u82D4\u75D5",artist:"\u6797\u95F4\u7535\u53F0",album:"\u534A\u5C71\u96E8",albumArtist:"\u6797\u95F4\u7535\u53F0",duration:241,colors:{primary:[.3,.68,.44],secondary:[.1,.28,.2],tertiary:[.72,.92,.78],text:[.96,1,.97]},lyrics:[[0,"\u96E8\u505C\u5728\u7B2C\u4E09\u7EA7\u53F0\u9636"],[16,"\u82D4\u75D5\u722C\u6EE1\u4E86\u65E7\u95E8\u724C"],[33,"\u4F60\u8BF4\u6162\u4E00\u70B9\u4E5F\u6CA1\u5173\u7CFB"],[52,"\u5C71\u4E0D\u4F1A\u8D70"],[70,"\u800C\u6211\u4EEC\u6709\u7684\u662F\u65F6\u95F4"],[92,"\uFF08\u95F4\u594F\uFF09"],[130,"\u628A\u4F1E\u6536\u8D77\u6765\u5427"],[148,"\u8BA9\u6F6E\u6C14\u8BB0\u4F4F\u8FD9\u4E00\u523B"],[172,"\u6162\u4E00\u70B9"],[200,"\u771F\u7684\u6CA1\u5173\u7CFB"],[226,"\u2026\u2026"]]},{title:"Neon Ashes",artist:"VELVET//NULL",album:"Afterimage",albumArtist:"VELVET//NULL",duration:168,colors:{primary:[.86,.22,.58],secondary:[.3,.06,.22],tertiary:[.99,.64,.86],text:[1,.94,.98]},lyrics:[[0,"city bleeds into the lens"],[11,"we were only afterimage"],[24,"neon ashes on your coat"],[38,"nothing here stays lit"],[55,"burn out with me"],[76,"(drop)"],[104,"nothing here stays lit"],[122,"burn out with me"],[146,"\u2026"]]}],Mr=3;function Qi(e=20260901){const n=pl,t=n.reduce((M,h)=>M+h.duration+Mr,0),r={hasMedia:!1,state:en.STOPPED,title:"",artist:"",album:"",albumArtist:"",position:0,duration:0,hasThumbnail:!1,primaryColor:new ke(0,0,0),secondaryColor:new ke(0,0,0),tertiaryColor:new ke(0,0,0),textColor:new ke(1,1,1),highContrastColor:new ke(1,1,1),trackIndex:-1,lyrics:[],lyricLine:"",lyricIndex:-1};let o=0,i=!1,s=0,a=0;function c(M){let h=0;const g=(M%n.length+n.length)%n.length;for(let v=0;v<g;v++)h+=n[v].duration+Mr;return h}function u(M){let h=t>0?M%t:0;h<0&&(h+=t);let g=-1,v=0,A=!1;for(let H=0;H<n.length;H++){const K=n[H].duration;if(h<K){g=H,v=h;break}if(h-=K,h<Mr){g=H,v=K,A=!0;break}h-=Mr}g<0&&(g=n.length-1,v=n[g].duration,A=!0);const _=n[g];r.hasMedia=!0,r.trackIndex=g,r.title=_.title,r.artist=_.artist,r.album=_.album,r.albumArtist=_.albumArtist,r.duration=_.duration,r.position=v;const R=_.duration>0?v/_.duration:0;i?r.state=en.PAUSED:A?r.state=en.STOPPED:R>.7&&R<.76?r.state=en.PAUSED:r.state=en.PLAYING,r.hasThumbnail=!A;const L=_.colors;r.primaryColor=new ke(L.primary[0],L.primary[1],L.primary[2]),r.secondaryColor=new ke(L.secondary[0],L.secondary[1],L.secondary[2]),r.tertiaryColor=new ke(L.tertiary[0],L.tertiary[1],L.tertiary[2]),r.textColor=new ke(L.text[0],L.text[1],L.text[2]);const N=.2126*L.primary[0]+.7152*L.primary[1]+.0722*L.primary[2];r.highContrastColor=N>.5?new ke(0,0,0):new ke(1,1,1),r.lyrics=_.lyrics;let j=-1;for(let H=0;H<_.lyrics.length;H++)v>=_.lyrics[H][0]&&(j=H);return r.lyricIndex=j,r.lyricLine=j>=0?_.lyrics[j][1]:"",r}function l(M){a=Number(M)||0;const h=i?s:a+o;return u(h)}function f(M){i=!1;const h=c(M);return o=h-a,u(h)}function p(){const M=r.trackIndex<0?0:r.trackIndex+1;return f(M)}function d(){const M=r.trackIndex<0?n.length-1:r.trackIndex-1;return f(M)}function y(){return i||(s=a+o,i=!0,r.state=en.PAUSED),r}function x(){return i?(i=!1,o=s-a,u(s)):r}function m(){return i?x():y()}return{update:l,snapshot:r,tracks:n,cycle:t,MEDIA_PLAYBACK:en,skipNext:p,skipPrevious:d,play:x,pause:y,playPause:m}}function hl(e,n=512){const t=Math.max(8,n|0),r=new Uint8Array(t*t*4),o=e&&e.colors?e.colors:{primary:[.5,.5,.5],secondary:[.1,.1,.1],tertiary:[.8,.8,.8]},[i,s,a]=o.primary,[c,u,l]=o.secondary,[f,p,d]=o.tertiary;for(let y=0;y<t;y++)for(let x=0;x<t;x++){const m=x/(t-1),M=y/(t-1),h=m-.5,g=M-.5,v=Math.sqrt(h*h+g*g)*2,A=.5+.5*Math.sin(v*18-1.2),_=.5+.5*Math.sin((m+M)*6),R=Math.min(1,Math.max(0,v));let L=i*(1-R)+c*R,N=s*(1-R)+u*R,j=a*(1-R)+l*R;L=L*(.72+.28*A)+f*.18*_,N=N*(.72+.28*A)+p*.18*_,j=j*(.72+.28*A)+d*.18*_;const H=1-.35*Math.min(1,v*v),K=(y*t+x)*4;r[K]=Math.max(0,Math.min(255,Math.round(L*H*255))),r[K+1]=Math.max(0,Math.min(255,Math.round(N*H*255))),r[K+2]=Math.max(0,Math.min(255,Math.round(j*H*255))),r[K+3]=255}return{width:t,height:t,rgba:r}}function ml(e,n){const t=[];if(!n)return t;const r=!e;return(r||e.hasMedia!==n.hasMedia)&&t.push({name:"mediaStatusChanged",event:{enabled:n.hasMedia}}),(r||e.title!==n.title||e.artist!==n.artist||e.album!==n.album||e.albumArtist!==n.albumArtist)&&t.push({name:"mediaPropertiesChanged",event:{title:n.title,artist:n.artist,album:n.album,albumArtist:n.albumArtist,albumTitle:n.album,subTitle:"",trackType:"music"}}),(r||e.hasThumbnail!==n.hasThumbnail||e.trackIndex!==n.trackIndex)&&t.push({name:"mediaThumbnailChanged",event:{hasThumbnail:n.hasThumbnail,primaryColor:n.primaryColor,secondaryColor:n.secondaryColor,tertiaryColor:n.tertiaryColor,textColor:n.textColor,highContrastColor:n.highContrastColor}}),(r||e.state!==n.state)&&t.push({name:"mediaPlaybackChanged",event:{state:n.state}}),(r||Math.floor(e.position)!==Math.floor(n.position)||e.duration!==n.duration)&&t.push({name:"mediaTimelineChanged",event:{position:n.position,duration:n.duration}}),(r||e.lyricIndex!==n.lyricIndex||e.trackIndex!==n.trackIndex)&&t.push({name:"mediaLyricsChanged",event:{line:n.lyricLine,index:n.lyricIndex,lines:n.lyrics}}),t}function gl(e){return e?{hasMedia:e.hasMedia,state:e.state,title:e.title,artist:e.artist,album:e.album,albumArtist:e.albumArtist,position:e.position,duration:e.duration,hasThumbnail:e.hasThumbnail,trackIndex:e.trackIndex,lyricIndex:e.lyricIndex,lyricLine:e.lyricLine}:null}const bl=Object.freeze(Object.defineProperty({__proto__:null,MEDIA_PLAYBACK:en,cloneMediaSnapshot:gl,createSimulatedMedia:Qi,diffMediaEvents:ml,mediaVec3:dl,renderThumbnail:hl},Symbol.toStringTag,{value:"Module"})),Ji=14,qn=[{app:"Safari",title:"GitHub \xB7 we-scene-renderer",url:"https://github.com/oneincase/we-scene-renderer"},{app:"Google Chrome",title:"YouTube",url:"https://www.youtube.com/watch?v=dQw4w9WgXcQ"},{app:"Google Chrome",title:"Wallpaper Engine - Workshop",url:"https://steamcommunity.com/app/431960/workshop/"},{app:"Safari",title:"MDN Web Docs",url:"https://developer.mozilla.org/en-US/docs/Web/API"},{app:"Music",title:"\u591C\u822A\u661F \u2014 \u76F8\u4F4D\u8FC1\u79FB",url:""},{app:"Code",title:"we-scene-renderer \u2014 text.js",url:""}];function es(){const e={app:"",title:"",url:"",index:-1};function n(t){const r=Number(t)||0,o=qn.length?Math.floor(r/Ji)%qn.length:0,i=qn[o]||qn[0];return e.app=i.app,e.title=i.title,e.url=i.url,e.index=o,e}return n(0),{update:n,snapshot:e,tabs:qn,hold:Ji}}function ts(e){const n={name:"",at:0};function t(r){return n.name=String(r||""),n.at=Date.now(),typeof e=="function"&&e(n.name),n.name}return{openUserShortcut:t,last:n}}function yl(e){const n=Qi(e),t=es(),r=ts(null);return{media:n,windowTitle:t,shortcuts:r}}const vl=Object.freeze(Object.defineProperty({__proto__:null,createShortcutHandler:ts,createSimulatedSystem:yl,createSimulatedWindowTitle:es},Symbol.toStringTag,{value:"Module"}));function xl(e={}){const n=e.target||(typeof window<"u"?window:null),t=e.viewport||(typeof window<"u"?()=>({w:window.innerWidth||1,h:window.innerHeight||1}):null),r={u:.5,v:.5,screenX:0,screenY:0,wx:0,wy:0,originY:null,lastU:.5,lastV:.5,lastScreenX:0,lastScreenY:0,lastWx:0,lastWy:0,lastOriginY:null,leftDown:!1,has:!1,moveCount:0,downCount:0,upCount:0,lastEventTime:0,screenW:1,screenH:1};function o(){if(!t)return;const p=t();r.screenW=p.w||1,r.screenH=p.h||1}o();function i(p,d){const y=p/r.screenW,x=d/r.screenH;r.has||(r.lastU=y,r.lastV=x,r.lastScreenX=p,r.lastScreenY=d),r.screenX=p,r.screenY=d,r.u=y,r.v=x,r.has=!0,r.moveCount++,r.lastEventTime=Date.now()}function s(p){const d=(p&1)!==0;d!==r.leftDown&&(r.leftDown=d,d?r.downCount++:r.upCount++,r.lastEventTime=Date.now())}function a(p){o();let d=p.clientX,y=p.clientY;if(n&&typeof n.getBoundingClientRect=="function"){const x=n.getBoundingClientRect();d-=x.left,y-=x.top}i(d,y)}function c(p){p.button!==void 0&&p.button!==0||s(1)}function u(p){p.button!==void 0&&p.button!==0||s(0)}function l(){s(0)}let f=!1;return n&&n.addEventListener&&(f=!0,n.addEventListener("mousemove",a,{passive:!0}),n.addEventListener("mousedown",c,{passive:!0}),n.addEventListener("mouseup",u,{passive:!0}),n.addEventListener("blur",l,{passive:!0}),typeof document<"u"&&document.addEventListener&&document.addEventListener("mouseleave",l,{passive:!0})),{state:r,pushExternal(p){if(!p)return;o();const d=Number(p.u),y=Number(p.v);Number.isFinite(d)&&Number.isFinite(y)&&i(d*r.screenW,y*r.screenH),s(Number(p.buttons)||0)},pushExternalLeave(){s(0)},beginFrame(){o(),r.lastU=r.u,r.lastV=r.v,r.lastScreenX=r.screenX,r.lastScreenY=r.screenY,r.lastWx=r.wx,r.lastWy=r.wy,r.lastOriginY=r.originY},syncWorld(p,d=0,y=0){if(!p)return;r.wx=p.offX+r.u*p.viewW-d,r.wy=p.offY+r.v*p.viewH-y;const x=Number(p.projH);r.originY=Number.isFinite(x)?x-r.wy:r.wy,r.lastWx===0&&r.lastWy===0&&(r.lastWx=r.wx,r.lastWy=r.wy,r.lastOriginY=r.originY)},normalizedDelta(){const p=r.u-r.lastU,d=r.v-r.lastV;return Math.hypot(p,d)},dispose(){!f||!n||!n.removeEventListener||(f=!1,n.removeEventListener("mousemove",a),n.removeEventListener("mousedown",c),n.removeEventListener("mouseup",u),n.removeEventListener("blur",l),typeof document<"u"&&document.removeEventListener&&document.removeEventListener("mouseleave",l))}}}const wl=Object.freeze(Object.defineProperty({__proto__:null,createPointerSource:xl},Symbol.toStringTag,{value:"Module"}));function ns(e,n,t,r,o,i,s){const a=e.size||[0,0],c=e.scale||[1,1,1],u=a[0]*c[0],l=a[1]*c[1];if(!(u>0)||!(l>0))return null;const f=e.origin||[0,0,0];let p=f[0],d=r-f[1];if(e.parallaxDepth&&(o!==0||i!==0)){const h=e.parallaxDepth,g=vn(h[0]),v=vn(h[1]);p+=g*o,d+=v*i}let y=n-p,x=t-d;const m=e.angles?e.angles[2]:0;if(m){const h=Math.cos(-m),g=Math.sin(-m),v=y*h+x*g,A=-y*g+x*h;y=v,x=A}const M=s&&s[e.alignment]||[.5,.5];return(M[0]!==.5||M[1]!==.5)&&(y-=(.5-M[0])*u,x-=(.5-M[1])*l),{lx:y/u,ly:x/l,w:u,h:l}}function Ml(e,n,t,r,o={}){if(!e||e.length===0)return null;const i=o.parOffX||0,s=o.parOffY||0,a=o.alignTable,c=o.filter;for(let u=e.length-1;u>=0;u--){const l=e[u];if(!l||!l.visible||l.destroyed||c&&!c(l))continue;const f=ns(l,n,t,r,i,s,a);if(f&&Math.abs(f.lx)<=.5&&Math.abs(f.ly)<=.5)return l}return null}const _l=Object.freeze(Object.defineProperty({__proto__:null,hitTestLayers:Ml,worldToLayerLocal:ns},Symbol.toStringTag,{value:"Module"})),Xe=e=>e,Ge=Xe(Bs),_r=Xe(Js),Ke=Xe(fa),kt=Xe(ga),$e=Xe(qa),Al=Xe(Ka),Tl=Xe(rc),an=Xe(vc),Zn=Xe(Dc),tt=Xe(rl),Sl=Xe(il),we=Xe(bl),rs=Xe(vl),os=Xe(Wa),El=Xe(wl),Pl=Xe(_l);function Cl(e,n,t){return{camera:null,general:{orthogonalprojection:{width:e,height:n},clearenabled:!0,clearcolor:"0 0 0"},layers:[{id:0,name:"media",visible:!0,image:t,textureName:t,particle:null,puppet:null,solid:!1,isContainer:!1,isPostProcess:!1,isText:!1,isSound:!1,isComponent:!1,sound:[],origin:[e/2,n/2,0],scale:[1,1,1],angles:[0,0,0],size:[e,n],alignment:"center",color:[1,1,1],alpha:1,brightness:1,colorBlendMode:0,copybackground:!1,parallaxDepth:null,animationLayers:[],effects:[]}],properties:{}}}async function Ll(e){const n=await fetch(e);if(!n.ok)throw new Error(`HTTP ${n.status}`);const t=new window.ImageDecoder({data:await n.arrayBuffer(),type:"image/gif"});await t.tracks.ready,await t.completed;const r=t.tracks.selectedTrack;if(!r||!r.frameCount)return null;const o=Math.min(r.frameCount,300),i=[];let s=0,a=0;for(let c=0;c<o;c++){const{image:u}=await t.decode({frameIndex:c});s=u.displayWidth,a=u.displayHeight,i.push({bitmap:await createImageBitmap(u),durationMs:u.duration?u.duration/1e3:100}),u.close()}return t.close?.(),{width:s,height:a,frames:i}}function Rl(e,n,t){if(e.audioBridge)return;const r=window.AudioContext||window.webkitAudioContext;if(!r)return;let o,i;try{o=new r;const l=o.createMediaElementSource(t);i=o.createAnalyser(),i.fftSize=256,i.smoothingTimeConstant=.75,l.connect(i),i.connect(o.destination)}catch(l){se(e,n,`media \u9891\u8C31\u63A5\u7BA1\u8DF3\u8FC7: ${l?.message??l}`);return}const s=new Uint8Array(i.frequencyBinCount),a=new Float32Array(64),c=new Float32Array(64),u=()=>{if(o.state!=="running")return null;i.getByteFrequencyData(s);const l=Math.min(64,s.length);for(let f=0;f<l;f++){const p=s[f]/255;a[f]=p,c[f]=p}for(let f=l;f<64;f++)a[f]=0,c[f]=0;return{left:a,right:c}};if(e.audioBridge=u,o.state==="suspended"){const l=()=>{o.resume().catch(()=>{}),window.removeEventListener("pointerdown",l),window.removeEventListener("keydown",l)};window.addEventListener("pointerdown",l,{once:!0}),window.addEventListener("keydown",l,{once:!0}),(e.wallpaperDisposers??=[]).push(()=>{window.removeEventListener("pointerdown",l),window.removeEventListener("keydown",l)})}(e.wallpaperDisposers??=[]).push(()=>{e.audioBridge===u&&(e.audioBridge=null),o.close().catch(()=>{})})}function kl(e,n){on(e);const t=m=>{se(e,n,`media ${n.type} \u5931\u8D25: ${m}`),e.onError?.(new Error(`\u5A92\u4F53\u58C1\u7EB8\uFF08${n.type}\uFF09${m}`)),e.fallbackPage?.()};if(!n.src){t("\u7F3A\u5C11\u8D44\u6E90 URL\uFF08cfg.src \u4E3A\u7A7A\uFF09");return}const r=n.type==="video",o=n.type==="gif",i=n.canvas instanceof HTMLCanvasElement,s=i?n.canvas:document.createElement("canvas"),a=rr(e,n),c=s.clientWidth||window.innerWidth||1,u=s.clientHeight||window.innerHeight||1;if(s.width=Math.max(1,Math.round(c*a)),s.height=Math.max(1,Math.round(u*a)),i||(s.style.cssText="position:absolute;inset:0;width:100%;height:100%;"),!s.getContext("webgl2",{premultipliedAlpha:!1,antialias:!1,alpha:!1,preserveDrawingBuffer:!0})){if(se(e,n,`media ${n.type}: WEBGL2_UNAVAILABLE`),i){e.onError?.(new Error("WEBGL2_UNAVAILABLE"));return}r?Fl(e,n):Nl(e,n);return}if(i||e.wrap?.appendChild(s),e.canvas=s,e.onSceneInfo){const m=e.onSceneInfo;e.onSceneInfo=void 0;try{m({width:c,height:u,layerCount:0,hasModels:!1,hasParticles:!1,hasText:!1})}catch{}}let f=!1;e.sceneCleanup=()=>{f=!0,e.renderer&&(e.renderer.dispose?.(),e.renderer=void 0)};let p,d,y=!1;e.sceneAudio={setVolume(m){const M=e.video;if(!M)return;const h=Math.max(0,Math.min(1,Number(m)||0));M.volume=h,M.muted=h<=0,h>0&&M.paused&&!e.paused&&M.play().catch(g=>{se(e,n,`media \u53D6\u6D88\u9759\u97F3\u540E\u81EA\u52A8\u64AD\u653E\u88AB\u62D2\u7EDD: ${g?.message??g}`)})},audios:[]},e.sceneCtl={pause(){p?.()},resume(){d?.()},applyUserProperties(){}};const x=m=>{f||(f=!0,t(m))};(async()=>{try{const m=$e.createRenderer(s,{diag:O=>se(e,n,`renderer: ${O}`),fboCapFactor:0});if(e.renderer=m,f)return;const M="__media",h=new Map;let g,v=0,A=0;if(r){const O=document.createElement("video");if(O.autoplay=!0,O.loop=n.loop!==!1,O.muted=n.muted!==!1,O.playsInline=!0,O.preload="metadata",O.width=s.width,O.height=s.height,O.style.cssText="position:fixed;left:-9999px;top:-9999px;width:2px;height:2px;opacity:0;pointer-events:none",O.src=n.src,document.body.appendChild(O),e.video=O,(e.videoTextures??=[]).push(O),await new Promise((W,X)=>{O.addEventListener("loadedmetadata",()=>W(),{once:!0}),O.addEventListener("error",()=>X(new Error(`video error ${O.error?.code??"?"}`)),{once:!0})}),f)return;v=O.videoWidth||s.width,A=O.videoHeight||s.height,h.set(M,{video:O,glTex:$e.makeTexture(m.gl,new Uint8Array([0,0,0,255]),1,1),width:v,height:A,rg88:!1,lastUploaded:-1}),e.paused||O.play().catch(()=>{}),Rl(e,n,O),se(e,n,`media video ${v}x${A} \u2192 scene \u6E32\u67D3`)}else{let O=!1;if(o&&typeof window.ImageDecoder=="function")try{const W=await Ll(n.src);if(W&&W.frames.length>1){v=W.width,A=W.height;const X=m.gl,ie={glTex:$e.makeTexture(X,null,0,0,W.frames[0].bitmap),width:v,height:A,rg88:!1};h.set(M,ie);let J=0,Z=performance.now()+W.frames[0].durationMs;g=()=>{const le=performance.now();if(!(le<Z)){J=(J+1)%W.frames.length,Z=le+W.frames[J].durationMs,X.bindTexture(X.TEXTURE_2D,ie.glTex);try{X.texImage2D(X.TEXTURE_2D,0,X.RGBA,X.RGBA,X.UNSIGNED_BYTE,W.frames[J].bitmap)}catch{}}};const te=e.sceneCleanup;e.sceneCleanup=()=>{te?.();for(const le of W.frames)le.bitmap.close()},O=!0,se(e,n,`media gif ${v}x${A} ${W.frames.length} \u5E27 \u2192 scene \u6E32\u67D3`)}}catch(W){se(e,n,`gif \u89E3\u7801\u5931\u8D25\uFF0C\u56DE\u9000\u9759\u6001\u9996\u5E27: ${String(W.message).slice(0,80)}`)}if(!O){const W=new Image;if(W.crossOrigin="anonymous",W.src=n.src,await new Promise((X,ie)=>{W.addEventListener("load",()=>X(),{once:!0}),W.addEventListener("error",()=>ie(new Error("image load error")),{once:!0})}),f)return;v=W.naturalWidth||1,A=W.naturalHeight||1,e.img=W,h.set(M,{glTex:$e.makeTexture(m.gl,null,0,0,W),width:v,height:A,rg88:!1}),se(e,n,`media ${n.type} ${v}x${A} \u2192 scene \u6E32\u67D3`)}}if(f)return;const _=Cl(v,A,M),R=performance.now();let L=0,N=0,j=-1/0;const H=O=>{if(f||e.paused)return;const W=e.cfg.sceneFps||60;if(O-j>=1e3/W){j=O,Fn(e,O),So(e,s,e.cfg),g?.();const X=e.coverAlign;m.render(_,h,s.width,s.height,(O-R-L)/1e3,pn(e.cfg.fit),X.x,X.y).then(()=>{if(e.onFirstFrame){const ie=e.onFirstFrame;e.onFirstFrame=void 0;try{ie()}catch{}}f||e.paused||(e.raf=requestAnimationFrame(H))}).catch(ie=>x(String(ie.message||ie).slice(0,200)))}else e.paused||(e.raf=requestAnimationFrame(H))},K=()=>{f||e.paused||e.raf===void 0&&(e.raf=requestAnimationFrame(H))};p=()=>{e.raf!==void 0&&(cancelAnimationFrame(e.raf),e.raf=void 0),N||(N=performance.now());const O=e.video;y=!!(O&&!O.paused&&!O.ended),O?.pause()},d=()=>{N&&(L+=performance.now()-N,N=0),y&&e.video?.play().catch(()=>{}),y=!1,K()},K()}catch(m){x(String(m.message||m).slice(0,200))}})()}function Fl(e,n){if(on(e),!n.src){e.fallbackPage?.();return}const t=_o(n.fit),r=`position:absolute;inset:0;width:100%;height:100%;object-fit:${t.objectFit};object-position:50% 50%;background:${t.background};`;let o=!1;const i=()=>{o||(o=!0,console.warn("video error, fallback to default wallpaper"),e.fallbackPage?.())},s=document.createElement("video");s.autoplay=!0,s.loop=n.loop!==!1,s.muted=n.muted!==!1,s.playsInline=!0,s.preload="metadata";const a=Math.min(window.devicePixelRatio||1,e.cfg.renderDpr||1);s.width=Math.max(1,Math.round(innerWidth*a)),s.height=Math.max(1,Math.round(innerHeight*a)),s.style.cssText=r,s.src=n.src,s.addEventListener("error",i),e.wrap?.appendChild(s),e.video=s,s.addEventListener("canplay",()=>s.play().catch(()=>{}),{once:!0}),se(e,n,"video mounted (single + native loop)")}function Nl(e,n){on(e);const t=document.createElement("img"),r=_o(n.fit);t.style.cssText=`position:absolute;inset:0;width:100%;height:100%;object-fit:${r.objectFit};object-position:50% 50%;background:${r.background};`,t.src=n.src??"",t.addEventListener("error",()=>e.fallbackPage?.()),e.wrap?.appendChild(t),e.img=t}const Ul=["scene.pkg","scenes/scene.pkg","gifscene.pkg"],Dl={mp4:"video",webm:"video",mov:"video",m4v:"video",ogv:"video",gif:"gif",png:"image",jpg:"image",jpeg:"image",webp:"image",avif:"image",bmp:"image"};function is(e){const n=e.toLowerCase().split(";")[0].trim();return n==="image/gif"?"gif":n.startsWith("video/")?"video":n.startsWith("image/")?"image":null}function mo(e){if(typeof e!="string"||!e)return null;let n=e;const t=n.indexOf("#");t>=0&&(n=n.slice(0,t));const r=n.indexOf("?");r>=0&&(n=n.slice(0,r));const o=n.split("/").pop()||"",i=o.lastIndexOf(".");return i<0?null:Dl[o.slice(i+1).toLowerCase()]??null}async function Bl(e,n,t){try{const r=await fetch(e,{...n,method:"HEAD",signal:t});return r.ok?is(r.headers.get("content-type")||""):null}catch{return null}}function ss(e,n){const t=e.replace(/\/+$/,"");return{key:t,async scenePkg(r){let o=null,i=null;for(const a of Ul){let c;try{c=await fetch(`${t}/${a}`,{...n,signal:r})}catch(u){if(r?.aborted)throw u;i=u;continue}if(!c.ok){o=c.status;continue}try{return await c.arrayBuffer()}catch(u){if(r?.aborted)throw u;const l=u instanceof Error?u.message:String(u);throw new Error(`\u8BFB\u53D6 scene.pkg \u4F53\u5931\u8D25\uFF08${l}\uFF09`)}}if(o!=null)throw new Error(`scene.pkg \u52A0\u8F7D\u5931\u8D25\uFF08HTTP ${o}\uFF09`);const s=i instanceof Error?i.message:"Failed to fetch";throw new Error(`scene.pkg \u52A0\u8F7D\u5931\u8D25\uFF08${s}\uFF09`)},async project(r){try{const o=await fetch(`${t}/project.json`,{...n,signal:r});return o.ok?await o.json():null}catch{return null}},async webEntry(r){let o="index.html";try{const i=await fetch(`${t}/project.json`,{...n,signal:r});if(i.ok){const s=await i.json();s&&typeof s.file=="string"&&s.file.trim()&&(o=s.file.trim().replace(/^\/+/,""))}}catch{if(r?.aborted)throw new Error("aborted")}return{url:`${t}/${o}`}},async mediaEntry(r){let o="";try{const i=await fetch(`${t}/project.json`,{...n,signal:r});if(i.ok){const s=await i.json();s&&typeof s.file=="string"&&s.file.trim()&&(o=s.file.trim().replace(/^\/+/,""))}}catch{if(r?.aborted)throw new Error("aborted")}return o?{url:`${t}/${o}`}:null}}}function Il(e,n){const t=e;return{key:typeof t.name=="string"?`file:${t.name}:${t.size}:${t.lastModified??0}`:void 0,scenePkg:()=>e.arrayBuffer(),project:async()=>n??null}}function Ol(e,n,t){return{key:t,scenePkg:async()=>e,project:async()=>n??null}}function $l(e,n){const t=typeof e!="string",r=e;let o=n?.type??(t?is(e.type||""):null)??mo(t?String(r.name??""):e),i=!1,s=null;const a=()=>t?(s||(s=URL.createObjectURL(e)),s):e;return{key:n?.key??(t?typeof r.name=="string"?`media:${r.name}:${r.size}:${r.lastModified??0}`:void 0:`media:${e}`),async scenePkg(){throw new Error("mediaSource \u662F\u7EAF\u5A92\u4F53\u6765\u6E90\uFF0C\u6CA1\u6709 scene.pkg\uFF08\u8BF7\u6539\u7528 httpSource/fileSource/bytesSource\uFF09")},async project(){return o?{type:o}:null},async mediaEntry(u){return!o&&!t&&!i&&(i=!0,o=await Bl(e,void 0,u)),{url:a(),type:o??void 0}},dispose(){s&&(URL.revokeObjectURL(s),s=null)}}}const as=.5,jl=.04,cs=.08;function zl(e,n){const t=h=>{const g=document.createElement("video");h&&(g.src=e),g.muted=n.muted,g.playsInline=!0,g.preload="metadata";const v=Math.min(window.devicePixelRatio||1,n.renderDpr||1),A=Math.max(1,Math.round(n.maxW*v)),_=Math.max(1,Math.round(n.maxH*v));return g.width=A,g.height=_,g.loop=!0,g};let r=t(!0),o=t(!1),i=!1,s=1,a=n.muted;o.muted=!0;const c=()=>{i||(o.src=e,i=!0)};let u=!1,l=!1,f=-1,p=0,d=!1;const y=()=>{if(u=!1,l=!1,!o.paused){o.pause();try{o.currentTime=0}catch{}}},x=()=>{const h=r;r=o,o=h,u=!1,l=!1,r.play().catch(()=>{}),r.muted=a,r.volume=s,h.pause();try{h.currentTime=0}catch{}h.muted=!0,f=-1,i=!0,M.onSwap?.(r)},m=()=>{if(d)return;p=requestAnimationFrame(m);const h=r.duration;if(!isFinite(h)||h<=0)return;const g=r.currentTime;if(f>=0&&g<f-.05){const A=l;y(),f=g,A||M.onFallback?.();return}f=g;const v=h-g;if(v>as+.5){(u||l)&&y();return}if(l){(v<=cs||g<=cs)&&x();return}if(u){o.paused?o.play().catch(()=>{}):o.currentTime>=jl*.5&&(o.pause(),u=!1,l=!0);return}if(v<=as&&(c(),o.readyState>=2)){try{o.currentTime=0}catch{}o.play().catch(()=>{}),u=!0}};p=requestAnimationFrame(m);const M={get active(){return r},get standby(){return o},onSwap:void 0,onFallback:void 0,setVolume(h){s=Math.max(0,Math.min(1,h)),a=h<=0,r.muted=a,r.volume=s,o.muted=!0,o.volume=s},pause(){y(),r.pause(),p&&cancelAnimationFrame(p),p=0},resume(){d||(r.play().catch(h=>{h&&h.name}),p||(p=requestAnimationFrame(m)))},destroy(){d=!0,p&&cancelAnimationFrame(p),p=0;for(const h of[r,o]){h.pause(),h.removeAttribute("src");try{h.load()}catch{}h.remove()}}};return M}const ls=!1,us=!0,fs=!1,Vl=!1,Wl=!1,ds=4,Kn=64,ps={STOPPED:0};function Hl(){return{left64:new Float32Array(Kn),right64:new Float32Array(Kn),left32:new Float32Array(32),right32:new Float32Array(32),left16:new Float32Array(16),right16:new Float32Array(16),level:0,silent:!0}}function Ar(e,n){const t=n.length/e.length;for(let r=0;r<e.length;r++){let o=0;const i=Math.floor(r*t),s=Math.max(i+1,Math.floor((r+1)*t));for(let a=i;a<s;a++)o+=n[a];e[r]=o/(s-i)}}function Xl(e,n,t){const r=n.length,o=t*.5,i=20,s=Math.min(2e4,o);let a=0;for(let c=0;c<Kn;c++){const u=c/Kn,l=(c+1)/Kn,f=i*Math.pow(s/i,u),p=i*Math.pow(s/i,l),d=Math.max(0,Math.floor(f/o*r)),y=Math.min(r,Math.max(d+1,Math.ceil(p/o*r)));let x=0;for(let M=d;M<y;M++)x+=n[M]/255;const m=Math.min(1,x/(y-d)*1.35);e.left64[c]=m,e.right64[c]=m,c<48&&(a+=m)}Ar(e.left32,e.left64),Ar(e.right32,e.right64),Ar(e.left16,e.left64),Ar(e.right16,e.right64),e.level=Math.min(1,a/(48*1.2)),e.silent=e.level<.02}function Gl(e){let n=2166136261;for(let t=0;t<e.length;t++)n^=e.charCodeAt(t),n=Math.imul(n,16777619);return(n>>>0)%360}function go(e,n,t){const r=n/100,o=t/100,i=(1-Math.abs(2*o-1))*r,s=e/60,a=i*(1-Math.abs(s%2-1));let c=0,u=0,l=0;s<1?[c,u,l]=[i,a,0]:s<2?[c,u,l]=[a,i,0]:s<3?[c,u,l]=[0,i,a]:s<4?[c,u,l]=[0,a,i]:s<5?[c,u,l]=[a,0,i]:[c,u,l]=[i,0,a];const f=o-i/2;return[c+f,u+f,l+f]}function Yl(e,n){const t=Gl(n||"empty"),[r,o,i]=go(t,72,48),[s,a,c]=go((t+40)%360,55,28),[u,l,f]=go((t+20)%360,70,72);e.primaryColor=we.mediaVec3(r,o,i),e.secondaryColor=we.mediaVec3(s,a,c),e.tertiaryColor=we.mediaVec3(u,l,f),e.textColor=we.mediaVec3(.98,.98,1),e.highContrastColor=we.mediaVec3(1,1,1),e.hasThumbnail=!!n}function ql(e,n,t){const r=document.createElement("canvas");r.width=32,r.height=32;const o=r.getContext("2d",{willReadFrequently:!0});if(!o)return null;o.drawImage(e,0,0,n,t,0,0,32,32);const i=o.getImageData(0,0,32,32).data;let s=0,a=0,c=0,u=0,l=0,f=0,p=0,d=-1;for(let M=0;M<i.length;M+=4){const h=i[M]/255,g=i[M+1]/255,v=i[M+2]/255;s+=h,a+=g,c+=v,u++;const A=Math.max(h,g,v),_=Math.min(h,g,v),R=A-_,L=.2126*h+.7152*g+.0722*v,N=R*1.4+(L>.15&&L<.85?.3:0);N>d&&(d=N,l=h,f=g,p=v)}if(!u)return null;const y=[l,f,p],x=[s/u*.55,a/u*.55,c/u*.55],m=[Math.min(1,y[0]*.45+.55),Math.min(1,y[1]*.45+.55),Math.min(1,y[2]*.45+.55)];return{primary:y,secondary:x,tertiary:m}}function Zl(e,n,t,r=512){const o=document.createElement("canvas");o.width=r,o.height=r;const i=o.getContext("2d"),s=Math.max(r/Math.max(1,n),r/Math.max(1,t)),a=n*s,c=t*s;i.fillStyle="#000",i.fillRect(0,0,r,r),i.drawImage(e,(r-a)/2,(r-c)/2,a,c);const u=i.getImageData(0,0,r,r);return{width:r,height:r,rgba:new Uint8Array(u.data)}}function Kl(){return{hasMedia:!1,state:ps.STOPPED,title:"",artist:"",album:"",albumArtist:"",position:0,duration:0,hasThumbnail:!1,primaryColor:we.mediaVec3(0,0,0),secondaryColor:we.mediaVec3(0,0,0),tertiaryColor:we.mediaVec3(0,0,0),textColor:we.mediaVec3(1,1,1),highContrastColor:we.mediaVec3(1,1,1),trackIndex:-1,lyrics:[],lyricLine:"",lyricIndex:-1}}async function Ql(){if(!navigator.mediaDevices?.getUserMedia)return null;try{const e=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1},video:!1}),n=new AudioContext,t=n.createMediaStreamSource(e),r=n.createAnalyser();return r.fftSize=2048,r.smoothingTimeConstant=.8,t.connect(r),n.state==="suspended"&&await n.resume().catch(()=>{}),{ctx:n,stream:e,analyser:r,buf:new Uint8Array(r.frequencyBinCount)}}catch{return null}}async function hs(e){const n=e?.origin??(typeof location<"u"?location.origin:""),t=e?.onArtwork,r=Hl(),o=Kl(),i={app:"",title:"",url:"",index:0};let s="off",a="offline",c="offline",u="",l=!1,f="";const p=await Ql();p?s="mic":navigator.mediaDevices?.getUserMedia?s="denied":s="unavailable";let d=null,y=null,x=!1;const m=(A,_,R)=>{!n||!t||!l||f!==A&&(f=A,t({url:`${n}/api/system/artwork?k=${encodeURIComponent(A)}&_=${Date.now()}`,trackKey:A,title:_,artist:R}))},M=A=>{if(!A||!A.hasMedia){o.hasMedia=!1,o.state=ps.STOPPED,o.title="",o.artist="",o.album="",o.albumArtist="",o.position=0,o.duration=0,o.hasThumbnail=!1,o.trackIndex=-1,a=A?"empty":"offline",u="",l=!1,f="";return}a="live",o.hasMedia=!0,o.state=Number(A.state)===2?2:Number(A.state)===1?1:0,o.title=String(A.title??""),o.artist=String(A.artist??""),o.album=String(A.album??""),o.albumArtist=String(A.albumArtist??A.artist??""),o.position=Number(A.position)||0,o.duration=Number(A.duration)||0,l=A.hasArtwork===!0;const _=`${o.title}|${o.artist}|${o.album}`;_!==u&&(u=_,f="",o.trackIndex=o.trackIndex+1|0,Yl(o,_)),m(_,o.title,o.artist)},h=A=>{if(!A){c="offline";return}i.app=String(A.app??""),i.title=String(A.title??""),i.url=String(A.url??""),c=i.app||i.title?"live":"empty"},g=async()=>{if(!(!n||x))try{const[A,_]=await Promise.all([fetch(`${n}/api/system/media`,{cache:"no-store"}),fetch(`${n}/api/system/window`,{cache:"no-store"})]);if(A.ok){const R=await A.json();M(R)}else a="offline";_.ok&&h(await _.json())}catch{a=a==="live"?"live":"offline",c=c==="live"?"live":"offline"}};if(n){await g(),y=setInterval(()=>{g()},1e3);try{d=new EventSource(`${n}/api/system/stream`),d.onmessage=A=>{if(!x)try{const _=JSON.parse(A.data);M(_.media),h(_.window)}catch{}}}catch{}}const v=A=>{!n||x||fetch(`${n}/api/system/media-control`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:A})}).then(async _=>_.ok?_.json():null).then(_=>{_&&typeof _=="object"&&M(_),g()}).catch(()=>{g()})};return{audio:{snapshot:r,pump:()=>{if(!p||x){r.level=0,r.silent=!0;return}p.analyser.getByteFrequencyData(p.buf),Xl(r,p.buf,p.ctx.sampleRate||48e3)}},media:{snapshot:o,pump:()=>{},skipNext:()=>v("skipNext"),skipPrevious:()=>v("skipPrevious"),play:()=>v("play"),pause:()=>v("pause"),playPause:()=>v("playPause")},windowTitle:{snapshot:i,pump:()=>{}},status:()=>({audio:s,media:a,window:c,title:o.title,artist:o.artist,app:i.app,windowTitle:i.title,hasArtwork:l}),dispose:()=>{x=!0,y&&(clearInterval(y),y=null);try{d?.close()}catch{}if(d=null,p)try{p.stream.getTracks().forEach(A=>A.stop()),p.ctx.close()}catch{}}}}const Jl={"common.h":`// WE common.h\uFF08\u91CD\u5EFA\u5B50\u96C6\uFF0C\u4F9B we-scene \u6D4F\u89C8\u5668\u6E32\u67D3\uFF09
|
|
182
182
|
#define M_PI 3.14159265359
|
|
183
183
|
// M_PI_2 \u662F\u300CPI \xD7 2\u300D\u800C\u4E0D\u662F\u300CPI \xF7 2\u300D\u2014\u2014 \u540D\u5B57\u6781\u6613\u8BFB\u53CD\uFF0C\u6B64\u524D\u8BEF\u5199\u6210 1.5708\uFF0C
|
|
184
184
|
// \u5F71\u54CD\u5168\u5E93 142 \u4E2A\u6587\u4EF6\uFF0864 \u4E2A\u58C1\u7EB8\uFF09\u3002\u4E09\u6761\u72EC\u7ACB\u8BC1\u636E\uFF1A
|
|
@@ -509,11 +509,11 @@ vec3 DecompressNormal(vec4 tex) {
|
|
|
509
509
|
return vec3(xy, sqrt(clamp(1.0 - dot(xy, xy), 0.0, 1.0)));
|
|
510
510
|
}
|
|
511
511
|
`,"common_vertex.h":`// WE common_vertex.h\uFF08\u91CD\u5EFA\uFF1A\u7A7A\u5360\u4F4D\uFF0C\u89C1 headers.ts \u6CE8\u91CA\uFF09
|
|
512
|
-
`};function Il(e){if(!e||e.length<12)return e;const n=e[0],t=e[1],r=e[2],o=e[3];if(!(n===0&&t===1&&r===0&&o===0)&&!(n===79&&t===84&&r===84&&o===79))return e;const a=Uint8Array.from(e),c=new DataView(a.buffer,a.byteOffset,a.byteLength),u=c.getUint16(4);if(u<=0||12+u*16>a.length)return e;let l=-1,p=0,f=0;for(let A=0;A<u;A++){const h=12+A*16;if(String.fromCharCode(a[h],a[h+1],a[h+2],a[h+3])==="cmap"){l=h,p=c.getUint32(h+8),f=c.getUint32(h+12);break}}if(l<0||p+f>a.length)return e;let d=!1;const w=c.getUint16(p+2);for(let A=0;A<w;A++){const h=p+4+A*8,b=c.getUint32(h+4),v=p+b;if(v+14>a.length||c.getUint16(v)!==4)continue;const T=c.getUint16(v+6),_=T>>>1;if(_<1)continue;const F=2*Math.pow(2,Math.floor(Math.log2(_))),R=Math.floor(Math.log2(_)),k=T-F,U=c.getUint16(v+8),V=c.getUint16(v+10),q=c.getUint16(v+12);U===F&&V===R&&q===k||(c.setUint16(v+8,F),c.setUint16(v+10,R),c.setUint16(v+12,k),d=!0)}if(!d)return e;let M=0;const m=p+f;for(let A=p;A<m;A+=4){const h=a[A]||0,b=A+1<m?a[A+1]:0,v=A+2<m?a[A+2]:0,T=A+3<m?a[A+3]:0;M=M+(h<<24|b<<16|v<<8|T)>>>0}return c.setUint32(l+4,M),a}const Ol={systemfont_segoe:"'Segoe UI', 'Helvetica Neue', Arial, sans-serif",systemfont_arial:"Arial, 'Helvetica Neue', sans-serif",systemfont_verdana:"Verdana, Geneva, sans-serif",systemfont_tahoma:"Tahoma, Geneva, sans-serif",systemfont_timesnewroman:"'Times New Roman', Times, serif",systemfont_georgia:"Georgia, 'Times New Roman', serif",systemfont_couriernew:"'Courier New', Courier, monospace",systemfont_trebuchetms:"'Trebuchet MS', 'Helvetica Neue', sans-serif",systemfont_impact:"Impact, 'Arial Black', sans-serif",systemfont_comicsansms:"'Comic Sans MS', 'Comic Sans', cursive",systemfont_sylfaen:"Palatino, 'Times New Roman', serif",systemfont_calibri:"Calibri, Carlito, 'Helvetica Neue', sans-serif",systemfont_cambria:"Cambria, Georgia, serif",systemfont_consolas:"Consolas, 'Courier New', monospace",systemfont_microsoftyahei:"'Microsoft YaHei', 'PingFang SC', 'Hiragino Sans GB', sans-serif",systemfont_simsun:"SimSun, 'Songti SC', serif",systemfont_simhei:"SimHei, 'Heiti SC', sans-serif"},Tr=new Map;function $l(e){let n=5381;for(let t=0;t<e.length;t++)n=(n<<5)+n+e.charCodeAt(t)|0;return(n>>>0).toString(36)}function jl(e){for(const n of e){const t=Tr.get(n);if(t&&(t.refs--,!(t.refs>0))){Tr.delete(n);try{const r=[];document.fonts.forEach(o=>{o.family===t.family&&r.push(o)});for(const o of r)document.fonts.delete(o)}catch{}}}}const sn=new Map,zl=512*1024*1024;let ho=0;function Vl(e){for(;sn.size>0&&(sn.size>2||ho>zl);){let n=null,t=1/0;for(const[o,i]of sn)o!==e&&i.at<t&&(t=i.at,n=o);if(!n)break;const r=sn.get(n);ho-=r.parsed.fileSize||0,sn.delete(n)}}async function Wl(e,n,t,r){const o=t.key;if(o){const c=sn.get(o);if(c)return c.at=Date.now(),se(e,n,`pkg cache hit: ${c.parsed.fileSize} bytes`),c.parsed}let i;try{i=await t.scenePkg(r)}catch(c){throw r.aborted||c instanceof Error?c:new Error(String(c))}se(e,n,`pkg body: ${i.byteLength} bytes`);const s=i instanceof Uint8Array?i:new Uint8Array(i),a=qe.parsePkg(s);return o&&(sn.set(o,{parsed:a,at:Date.now()}),ho+=a.fileSize||0,Vl(o)),a}function Hl(e,n){nn(e);const t=(n.canvas instanceof HTMLCanvasElement?n.canvas:null)??document.createElement("canvas"),r=nr(e,n),o=t.clientWidth||window.innerWidth||1,i=t.clientHeight||window.innerHeight||1;t.width=Math.max(1,Math.round(o*r)),t.height=Math.max(1,Math.round(i*r)),n.canvas instanceof HTMLCanvasElement||(t.style.cssText="position:absolute;inset:0;width:100%;height:100%;",e.wrap?.appendChild(t)),e.canvas=t;let s=!1;const a=console.warn.bind(console);console.warn=(...w)=>{const M=w.map(m=>typeof m=="string"?m:String(m?.message??m)).join(" ");if(M.includes("[we-scene]"))try{se(e,n,M.slice(0,300))}catch{}a(...w)};const c=new AbortController;let u;e.sceneCleanup=()=>{s=!0,console.warn=a,c.abort(),e.sceneTextUpdate=void 0,u&&(u(),u=void 0),e.renderer&&(e.renderer.dispose?.(),e.renderer=void 0)};let l=null,p,f,d;e.sceneCtl={pause(){f?.()},resume(){d?.()},applyUserProperties(w){p?p(w):l={...l||{},...w}}},(async()=>{try{const w=n.source??Qi(`${n.mediaBase}/${n.src}`);if(!n.source&&(!n.mediaBase||!n.src))throw new Error("\u573A\u666F\u58C1\u7EB8\u7F3A\u5C11 mediaBase/src");se(e,n,"mountScene start");const M=await Wl(e,n,w,c.signal);if(s)return;let m=null;try{m=await w.project?.(c.signal)??null}catch{}if(!t.getContext("webgl2",{premultipliedAlpha:!1,antialias:!1,alpha:!1,preserveDrawingBuffer:!0}))throw new Error("WEBGL2_UNAVAILABLE");const h=qe.getEntry(M,"scene.json");if(!h)throw new Error("pkg \u4E2D\u6CA1\u6709 scene.json\uFF08\u4E0D\u662F\u573A\u666F\u58C1\u7EB8\uFF1F\uFF09");const b=Ze.parseScene(JSON.parse(mt(h)),m);if(n.clearColor){const g=b.general??={};g.clearcolor=n.clearColor,g.clearenabled=!0}{const g=b.general?.zoom,S=Number(g&&typeof g=="object"?g.value:g);b.cameraTransforms={zoom:Number.isFinite(S)&&S>0?S:1}}const v=Ws(b.properties||{});e.liveUserProps=v;const T=()=>Ze.recomputeLayerVisibility(b.layers);if(e.onSceneInfo){const g=b.general?.orthogonalprojection||{},S=Number(g.width)>0?Number(g.width):t.width,L=Number(g.height)>0?Number(g.height):t.height,E=b.layers||[],N={width:S,height:L,layerCount:E.length,hasModels:E.some(I=>!!I.model),hasParticles:E.some(I=>!!I.particle),hasText:E.some(I=>!!I.text)},j=e.onSceneInfo;e.onSceneInfo=void 0,j(N)}const _=[];ns&&(b.layers=b.layers.filter(g=>!(ns&&g.isComponent)));const F=g=>{const S=g.startsWith("shaders/")?g:"shaders/"+g,L=g.startsWith("shaders/")?g.slice(8):g,E=qe.getEntry(M,S);let N=E?mt(E):Bl[L]??null;const j=window.__shaderPatch;if(N&&j){const I=L.replace(/\.(frag|vert|h)$/,""),B=j[I]||j[L];if(typeof B=="function")try{const O=B(N,L);typeof O=="string"&&(N=O)}catch{}}return Promise.resolve(N)},R=je.createRenderer(t,{shaderResolver:F,diag:g=>se(e,n,`renderer: ${g}`),fboCapFactor:0});if(e.renderer=R,s)return;const k=m?.general?.supportsaudioprocessing!==!1,U=Vi(),V=xe.createSimulatedMedia(),q=Zi.createSimulatedWindowTitle();let W=null;const Z={mediaDriver:null,lastSnap:{get:()=>null,setHasThumbnail:()=>{}}},K={current:null};let re=V,te=q;const X={enabled:k},J=g=>new Float32Array(g),de={left16:J(16),right16:J(16),left32:J(32),right32:J(32),left64:J(64),right64:J(64),level:0,silent:!0},Se=(()=>{const g={left64:J(64),right64:J(64),left32:J(32),right32:J(32),left16:J(16),right16:J(16),preL64:J(64),preR64:J(64),level:0,silent:!0},S=(L,E)=>{const N=E.length/L.length;for(let j=0;j<L.length;j++){let I=0;const B=Math.floor(j*N),O=Math.max(B+1,Math.floor((j+1)*N));for(let Y=B;Y<O;Y++)I+=E[Y];L[j]=I/(O-B)}};return{active:!1,snapshot:g,pump(){const L=e.audioBridge?.();if(!L||!L.left||!L.right){this.active=!1;return}const E=Math.min(64,L.left.length,L.right.length);let N=0;for(let j=0;j<E;j++){const I=L.left[j]||0,B=L.right[j]||0;g.left64[j]=I,g.right64[j]=B,g.preL64[j]=I,g.preR64[j]=B,j<48&&(N+=I)}for(let j=E;j<64;j++)g.left64[j]=0,g.right64[j]=0,g.preL64[j]=0,g.preR64[j]=0;S(g.left32,g.left64),S(g.right32,g.right64),S(g.left16,g.left64),S(g.right16,g.right64),g.level=Math.min(1,N/48),g.silent=g.level<.02,this.active=!0}}})(),Ae=()=>Se.active?Se.snapshot:K.current?K.current.snapshot:U.snapshot;R.setAudioProvider(()=>X.enabled?Ae():de);const De=new Map;window.__audioStats=()=>({enabled:X.enabled,live:!!K.current,level:X.enabled?Math.round((K.current?K.current.snapshot:U.snapshot).level*1e3)/1e3:0,silent:X.enabled?(K.current?K.current.snapshot:U.snapshot).silent:!0,bass:X.enabled?Math.round((K.current?K.current.snapshot:U.snapshot).left64[2]*1e3)/1e3:0}),window.__audioMute=g=>(X.enabled=!g,X.enabled),se(e,n,`audio: ${K.current?"live mic":"simulated"} stream, supportsaudioprocessing=${k}`);const Qe=Zi.createShortcutHandler(g=>{se(e,n,`openUserShortcut: ${g}`)}),Ve={enabled:!0,override:null},Ee=[];let Re=null;Z.lastSnap={get:()=>Re,setHasThumbnail:g=>{Re&&(Re.hasThumbnail=g)}};const le=()=>re.snapshot,Pe=g=>{if(!(!g||!g.hasMediaHook||Ee.includes(g))&&(Ee.push(g),!!le().hasMedia))for(const{name:S,event:L}of xe.diffMediaEvents(null,le()))try{g.callMedia(S,L)}catch{}};window.__mediaStats=()=>({enabled:Ve.enabled,live:!!W,hooks:Ee.length,title:le().title,artist:le().artist,album:le().album,state:le().state,position:Math.round(le().position),duration:le().duration,hasThumbnail:le().hasThumbnail,lyric:le().lyricLine,primaryColor:le().primaryColor?[le().primaryColor.x,le().primaryColor.y,le().primaryColor.z]:null}),window.__mediaSet=g=>{Object.assign(le(),g||{});const S=xe.diffMediaEvents(Re,le());for(const{name:L,event:E}of S)for(const N of Ee)N.callMedia(L,E);return Re=xe.cloneMediaSnapshot(le()),window.__mediaStats()};const Be=()=>{const g=xe.diffMediaEvents(Re,le());for(const{name:S,event:L}of g)for(const E of Ee)try{E.callMedia(S,L)}catch{}Re=xe.cloneMediaSnapshot(le())},Me={get snapshot(){return le()},skipNext:()=>(re.skipNext(),Be(),le()),skipPrevious:()=>(re.skipPrevious(),Be(),le()),play:()=>(re.play(),Be(),le()),pause:()=>(re.pause(),Be(),le()),playPause:()=>(re.playPause(),Be(),le())};window.__mediaControl=Me,window.__system={media:Me,windowTitle:te.snapshot,shortcuts:Qe.last,live:null},window.__liveSystem=()=>({audio:"off",media:"offline",window:"offline"});const _e=hl.createPointerSource(n.canvas?{target:n.canvas,viewport:()=>({w:n.canvas.clientWidth||window.innerWidth||1,h:n.canvas.clientHeight||window.innerHeight||1})}:{});R.setPointerProvider(()=>_e),e.pointerCtl={push:g=>_e.pushExternal(g),leave:()=>_e.pushExternalLeave()};{const g=u;u=()=>{g?.(),_e.dispose()}}const Ie=tt.createInputView(),We=pl.createEngineTimers({setTimeout:(g,S)=>window.setTimeout(g,S),clearTimeout:g=>window.clearTimeout(g),setInterval:(g,S)=>window.setInterval(g,S),clearInterval:g=>window.clearInterval(g)},{onError:(()=>{let g=!1;return S=>{g||(g=!0,se(e,n,`engine \u5B9A\u65F6\u5668\u56DE\u8C03\u629B\u9519\uFF08\u6B64\u540E\u540C\u7C7B\u9759\u9ED8\uFF09: ${String(S?.message||S).slice(0,90)}`))}})()}),ft={setTimeout:We.setTimeout,clearTimeout:We.clearTimeout,setInterval:We.setInterval,clearInterval:We.clearInterval};{const g=u;u=()=>{g?.(),We.dispose()}}window.__pointerStats=()=>{const g=_e.state,S=L=>Math.round(L*1e3)/1e3;return{normalized:{u:S(g.u),v:S(g.v)},last:{u:S(g.lastU),v:S(g.lastV)},world:{x:Math.round(g.wx),y:Math.round(g.wy)},originY:g.originY!=null?Math.round(g.originY):null,screen:{x:g.screenX,y:g.screenY,w:g.screenW,h:g.screenH},leftDown:g.leftDown,has:g.has,delta:S(_e.normalizedDelta()),counts:{move:g.moveCount,down:g.downCount,up:g.upCount}}};const me=new Map;me.set("util/white",{glTex:je.makeTexture(R.gl,new Uint8Array([255,255,255,255]),1,1),width:1,height:1,rg88:!1}),me.set("util/noflow",{glTex:je.makeTexture(R.gl,new Uint8Array([127,127,127,255]),1,1),width:1,height:1,rg88:!1}),me.set("util/noise",{glTex:je.makeTexture(R.gl,fl.generateNoiseTexture(),256,256),width:256,height:256,rg88:!1,mips:null});{const g=L=>{const E=xe.renderThumbnail(L,512);return{glTex:je.makeTextureMip(R.gl,[E],!1),width:E.width,height:E.height,rg88:!1,mips:[E],generated:!0}},S=V.tracks||[];S.length&&(me.set("$mediaThumbnail",g(S[0])),me.set("$mediaPreviousThumbnail",g(S[S.length-1])))}if(n.liveSystem)try{const g=async L=>{try{const E=await fetch(L.url,{cache:"no-store"});if(!E.ok)return;const N=await E.blob(),j=await createImageBitmap(N),I=kl(j,j.width,j.height,512),B=Fl(j,j.width,j.height);j.close?.();const O=me.get("$mediaThumbnail");O&&me.set("$mediaPreviousThumbnail",O);const Y=R.gl,$=me.get("$mediaThumbnail");$?.glTex?(Y.bindTexture(Y.TEXTURE_2D,$.glTex),Y.texImage2D(Y.TEXTURE_2D,0,Y.RGBA,I.width,I.height,0,Y.RGBA,Y.UNSIGNED_BYTE,I.rgba),$.width=I.width,$.height=I.height,$.mips=[I]):me.set("$mediaThumbnail",{glTex:je.makeTextureMip(Y,[I],!1),width:I.width,height:I.height,rg88:!1,mips:[I],generated:!0});const P=re.snapshot;B&&(P.primaryColor=xe.mediaVec3(...B.primary),P.secondaryColor=xe.mediaVec3(...B.secondary),P.tertiaryColor=xe.mediaVec3(...B.tertiary),P.textColor=xe.mediaVec3(.98,.98,1),P.highContrastColor=xe.mediaVec3(1,1,1)),P.hasThumbnail=!0,Z.lastSnap.setHasThumbnail(!1),se(e,n,`liveSystem: artwork ${L.title||L.trackKey}`)}catch(E){se(e,n,`liveSystem: artwork \u5931\u8D25 (${E instanceof Error?E.message:E})`)}};if(W=await Dl({origin:location.origin,onArtwork:L=>{g(L)}}),re=W.media,te=W.windowTitle,Z.mediaDriver=W.media,W.status().audio==="mic"&&(K.current=W.audio),re.snapshot.hasMedia){for(const{name:L,event:E}of xe.diffMediaEvents(null,re.snapshot))for(const N of Ee)try{N.callMedia(L,E)}catch{}Re=xe.cloneMediaSnapshot(re.snapshot)}const S=W.status();se(e,n,`liveSystem: audio=${S.audio} media=${S.media} window=${S.window}`+(S.title?` title="${S.title}"`:"")+(S.hasArtwork?" artwork=1":"")),se(e,n,`audio: ${K.current?"live mic":"simulated"} stream, supportsaudioprocessing=${k}`),window.__system={media:Me,windowTitle:te.snapshot,shortcuts:Qe.last,live:()=>W.status()},window.__liveSystem=()=>W.status()}catch(g){se(e,n,`liveSystem: \u542F\u52A8\u5931\u8D25\uFF0C\u56DE\u9000\u6A21\u62DF\u6E90 (${g instanceof Error?g.message:g})`),W=null}{const g=u;u=()=>{g?.(),W?.dispose(),W=null}}const Tt=new Map,Xn=async g=>{if(me.has(g))return me.get(g);const S=qe.getEntry(M,`materials/${g}.tex`);if(!S){if(on.isBuiltinParticleTextureName(g)){const I=on.buildBuiltinParticleTexture(g);if(I){const B={glTex:je.makeTextureMip(R.gl,[I],!1),width:I.width,height:I.height,rg88:!1,mips:[I],generated:!0};return me.set(g,B),B}}return null}const L=_r.parseTex(S),E=_r.decodeMip0(L),N=L.format===8;let j=null;if(E.video!==void 0){const I=URL.createObjectURL(new Blob([E.video],{type:"video/mp4"})),B=Tl(I,{muted:!0,renderDpr:nr(e,n),maxW:t.clientWidth||window.innerWidth||1,maxH:t.clientHeight||window.innerHeight||1});for(const C of[B.active,B.standby])C.style.cssText="position:fixed;left:-9999px;top:-9999px;width:2px;height:2px;opacity:0;pointer-events:none",document.body.appendChild(C),(e.videoTextures??=[]).push(C);(e.objectUrls??=[]).push(I),(e.videoPairs??=[]).push(B),B.active.addEventListener("loadedmetadata",()=>{se(e,n,`video tex '${g}': ${B.active.videoWidth}x${B.active.videoHeight}`)}),B.active.addEventListener("error",()=>{se(e,n,`video tex '${g}' ERROR: ${B.active.error?.code}`)});const O=[],Y=C=>{for(const Q of O)C.addEventListener("ended",Q)},$={play:()=>{s||B.resume()},pause:()=>B.pause(),stop:()=>{B.pause();try{B.active.currentTime=0}catch{}},isPlaying:()=>!B.active.paused&&!B.active.ended,duration:()=>Number.isFinite(B.active.duration)?B.active.duration:0,getCurrentTime:()=>B.active.currentTime||0,setCurrentTime:C=>{try{B.active.currentTime=C}catch{}},getRate:()=>B.active.playbackRate||1,setRate:C=>{B.active.playbackRate=C,B.standby.playbackRate=C},getLoop:()=>B.active.loop,setLoop:C=>{B.active.loop=C,B.standby.loop=C},addEndedCallback:C=>{O.push(C),B.active.addEventListener("ended",C)}},P={get video(){return B.active},glTex:je.makeTexture(R.gl,new Uint8Array([0,0,0,0]),1,1),width:E.width,height:E.height,rg88:!1,lastUploaded:-1,videoCtl:$};let y=0;return B.onSwap=C=>{P.lastUploaded=-1,Y(C),y++,(y===1||y===10||y===100)&&se(e,n,`video tex '${g}' loop swap ok x${y}`)},B.onFallback=()=>{se(e,n,`video tex '${g}' loop fallback (native loop used)`)},me.set(g,P),P}else if(E.png!==void 0||E.image!==void 0&&E.fif===_r.FIF.JPEG){const I=new Blob([E.png||E.image],{type:E.png?"image/png":"image/jpeg"}),B=await createImageBitmap(I);j={glTex:je.makeTexture(R.gl,null,0,0,B),width:B.width,height:B.height,rg88:N}}else{if(E.image!==void 0)return null;{const I=_r.decodeMip0(L);j={glTex:je.makeTextureMip(R.gl,[I],N),width:I.width,height:I.height,rg88:N,mips:[I]}}}if(!j)return null;if(L.frames?.list?.length){const I=L.frames.list;I.atlasWidth=j.width,I.atlasHeight=j.height,j.frames=I}return me.set(g,j),j},yt=g=>{if(me.has(g))return Promise.resolve(me.get(g));const S=Tt.get(g);if(S)return S;const L=Xn(g);return Tt.set(g,L),L.finally(()=>{Tt.get(g)===L&&Tt.delete(g)}),L},Gn=/uniform\s+sampler2D\s+g_Texture\d+\s*;\s*\/\/[^\n]*"default"\s*:\s*"([^"]+)"/g,Er=async g=>{for(const S of g.materialPasses||[])if(S.shader)for(const L of["frag","vert"]){const E=qe.getEntry(M,`shaders/${S.shader}.${L}`);if(!E)continue;const N=mt(E);Gn.lastIndex=0;let j;for(;(j=Gn.exec(N))!==null;){const I=j[1];!I||I.startsWith("util/")||I.startsWith("_rt_")||me.has(I)||await yt(I)}}};let qn=0;const ye=[];for(let g=0;g<b.layers.length;g++){const S=b.layers[g];if(S.image)try{let L;if(At.BUILTIN_MODELS[S.image])L=At.BUILTIN_MODELS[S.image];else{const P=qe.getEntry(M,S.image);if(!P)continue;L=JSON.parse(mt(P))}Ze.applySolidFromModel(S,L);const E=S.srcObject?.instance?.usertextures,N=E?.[0]&&typeof E[0].name=="string"&&E[0].name.startsWith("$")?E[0].name:null,j=N&&me.has(N)?N:null;if(j&&(S.textureName=j,S.solid=!1),L&&typeof L=="object"&&"width"in L&&"height"in L){const P=L;(S.size?.[0]||0)===0&&(S.size?.[1]||0)===0&&P.width>0&&P.height>0&&(S.size=[P.width,P.height])}const I=Ze.resolveMaterial(L);if(!I)continue;let B;if(At.BUILTIN_MATERIALS[I.materialPath])B=At.BUILTIN_MATERIALS[I.materialPath];else{const P=qe.getEntry(M,I.materialPath);if(P)B=JSON.parse(mt(P));else if(S.solid&&At.BUILTIN_MATERIALS["materials/util/solidlayer.json"])B=At.BUILTIN_MATERIALS["materials/util/solidlayer.json"];else continue}const O=B.passes?.[0],Y=O?.textures||[],$=Y[0];if(O?.combos){for(const P of Object.keys(O.combos))if(P.toLowerCase()==="spritesheet"&&Number(O.combos[P])===1){S.spriteSheet=!0;break}}for(let P=0;P<Y.length;P++){const y=Y[P];typeof y!="string"||!y||y.startsWith("util/")||y.startsWith("_rt_")||ye.push(yt(y).then(C=>{C&&P===0&&!j&&(S.textureName=y,qn++,C.videoCtl&&(S.videoCtl=C.videoCtl))}))}O?.shader&&qe.getEntry(M,`shaders/${O.shader}.frag`)&&At.attachLayerMaterialEffect(S,O);for(const P of S.effects||[])At.resolveEffectChain(M,P,mt);for(const P of S.effects||[]){for(const y of P.passes||[])for(const C of y.textures||[])typeof C=="string"&&C!==""&&!C.startsWith("util/")&&!C.startsWith("_rt_")&&ye.push(yt(C));ye.push(Er(P))}}catch(L){console.warn(`\u56FE\u5C42 ${S.name||g} \u52A0\u8F7D\u5931\u8D25: ${L.message}`)}}if(!rs){for(const g of b.layers)if(!(!g.isText||!(g.effects||[]).length))try{for(const S of g.effects||[])At.resolveEffectChain(M,S,mt);for(const S of g.effects||[])for(const L of S.passes||[])for(const E of L.textures||[])typeof E=="string"&&E!==""&&!E.startsWith("util/")&&!E.startsWith("_rt_")&&ye.push(yt(E))}catch(S){console.warn(`\u6587\u5B57\u5C42\u6548\u679C ${g.name} \u89E3\u6790\u5931\u8D25: ${S.message}`)}}await Promise.all(ye);for(const[g,S]of me){if(!S?.videoCtl)continue;b.layers.some(E=>E.textureName===g&&E.visible&&!E.destroyed)&&!e.paused&&S.videoCtl.play()}const He=[],cn=[],Nt=new Map;let Yn=0;const Zn=async g=>{const S=await yt(g);if(S)return S;const L=on.buildBuiltinParticleTexture(g);if(!L)return null;const E={glTex:je.makeTextureMip(R.gl,[L],!1),width:L.width,height:L.height,rg88:!1,mips:[L],generated:!0,frames:on.builtinParticleFrames(g)??void 0};return me.set(g,E),Yn++,E},Pr=g=>{if(!g)return null;const S=g.mips&&g.mips[0];if(S?.rgba&&typeof on.prepareParticleNormalTexture=="function"){const L=on.prepareParticleNormalTexture(S);if(L&&L!==S)return{glTex:je.makeTextureMip(R.gl,[L],!1),width:L.width,height:L.height,rg88:!1,mips:[L],generated:!0}}return g},Kn=async(g,S,L,E)=>{if(E>3)return null;const N=qe.getEntry(M,g);if(!N)return se(e,n,`particle '${g}' \u4E0D\u5728 pkg\uFF0C\u8DF3\u8FC7`),null;const j=JSON.parse(mt(N)),I=new dl.ParticleSystem(R.gl,j,L,S);let B=null,O=null;if(j.material){const y=qe.getEntry(M,j.material);if(y){const C=JSON.parse(mt(y));I.setMaterial(C);const Q=C?.passes?.[0]?.textures||[];B=Q[0]||null,O=Q[1]||null}}const Y=await Zn(B||"particle/halo");if(!Y)return se(e,n,`particle '${g}' \u65E0\u8D34\u56FE\u53EF\u7528\uFF0C\u8DF3\u8FC7`),null;I.setTexture({glTex:Y.glTex,width:Y.width,height:Y.height,frames:Y.frames});const $=O||(I.refract?on.particleNormalNameForAlbedo(B||"particle/halo"):null);if($){const y=Pr(await Zn($));y&&I.setNormalTexture({glTex:y.glTex,width:y.width,height:y.height})}I.setVisible(!!S.visible),He.push(I);const P=S.id;if(P!==void 0){let y=Nt.get(P);y||(y=[],Nt.set(P,y)),y.push(I)}for(const y of j.children||[]){if(!y||typeof y.name!="string")continue;const C=String(y.origin??"0 0 0").trim().split(/\s+/).map(Number),Q=String(y.scale??"1 1 1").trim().split(/\s+/).map(Number),ee=String(y.angles??"0 0 0").trim().split(/\s+/).map(Number),ie=y.type==="eventfollow"?"particle":!y.type||y.type==="static"?"origin":null,oe=I.localToWorld(C[0]||0,C[1]||0),fe={...S,origin:[oe[0],oe[1],(S.origin?.[2]||0)+(C[2]||0)],scale:[(S.scale?.[0]??1)*(Q[0]||1),(S.scale?.[1]??1)*(Q[1]||1),(S.scale?.[2]??1)*(Q[2]||1)],angles:[(S.angles?.[0]||0)+(ee[0]||0),(S.angles?.[1]||0)+(ee[1]||0),(S.angles?.[2]||0)+(ee[2]||0)]},ge=await Kn(y.name,fe,y.instanceoverride||L,E+1);ge&&ie&&ge.attachFollow(I,ie,[C[0]||0,C[1]||0,C[2]||0])}return I};if(!Sl){for(const g of b.layers)if(g.particle)try{await Kn(g.particle,g,g.instanceoverride,0)}catch(S){console.warn(`\u7C92\u5B50\u56FE\u5C42 ${g.name} \u52A0\u8F7D\u5931\u8D25: ${S.message}`),se(e,n,`particle '${g.name}' FAIL: ${S.message.slice(0,80)}`)}}if(He.length>0){const g=u;u=()=>{g?.();for(const S of He)S.dispose()}}const ln=[];for(const g of b.layers)if(!(!g.sound||!g.sound.length))try{for(const S of g.sound){const L=qe.getEntry(M,S);if(!L)continue;const E=(S.split(".").pop()||"").toLowerCase(),N=E==="mp3"?"audio/mpeg":E==="ogg"?"audio/ogg":E==="flac"?"audio/flac":"audio/wav",j=new Blob([L],{type:N}),I=URL.createObjectURL(j);(e.objectUrls??=[]).push(I);const B=document.createElement("audio");B.src=I,B.loop=g.soundprops?.playbackmode==="loop",B.volume=Math.max(0,Math.min(1,g.soundprops?.volume??1)),B.muted=n.muted!==!1,g.soundCtl={play(){if(B.ended)try{B.currentTime=0}catch{}B.play().catch(()=>{})},pause(){B.pause()},stop(){B.pause();try{B.currentTime=0}catch{}},isPlaying:()=>!B.paused&&!B.ended,getVolume:()=>B.volume,setVolume:O=>{B.volume=Math.max(0,Math.min(1,O))}},!g.soundprops?.startsilent&&!e.paused&&B.play().catch(()=>{}),ln.push(B);break}}catch(S){console.warn(`\u58F0\u97F3\u56FE\u5C42 ${g.name} \u52A0\u8F7D\u5931\u8D25: ${S.message}`)}const Cr=g=>{for(const S of ln)S.volume=Math.max(0,Math.min(1,g)),S.muted=g<=0};if(e.sceneAudio={setVolume:Cr,audios:ln},s)return;let qt=performance.now(),_n=0;R.setParticleRenderer(()=>{const g=performance.now(),S=Math.min(.05,(g-qt)/1e3);if(qt=g,_e.state.has){const{wx:L,wy:E,originY:N}=_e.state,j=N??E;for(const I of He)I.setPointer(L,j)}if(cn.length)for(const L of cn)L.syncLayerTransform();for(const L of He)L.advance(S,X.enabled?Ae():null);if(_n<2&&(_n++,_n===2)){const L=He.reduce((E,N)=>E+N.liveCount(),0);se(e,n,`particles live: ${L} across ${He.length} systems`)}},(g,S,L,E,N)=>{if(g===void 0)return;const j=Nt.get(g);if(j)for(const I of j)I.render(L,E,N,S.projW,S.projH)}),se(e,n,`particles: ${He.length} systems, ${Yn} builtin tex generated`),window.__particleStats=()=>He.map(g=>{let S=0,L=1/0,E=-1/0,N=1/0,j=-1/0,I=1/0,B=-1/0;for(const O of g.pool){if(!O.alive)continue;S++;const Y=g.originX+O.x*g.scaleX,$=g.originY+O.y*g.scaleY;Y<L&&(L=Y),Y>E&&(E=Y),$<N&&(N=$),$>j&&(j=$);const P=Math.abs(O.size)*g.sysScale;P<I&&(I=P),P>B&&(B=P)}return{live:S,max:g.maxCount,blend:g.blend,renderer:g.renderers.map(O=>O.kind).join("+"),origin:[Math.round(g.originX),Math.round(g.originY)],bbox:S?[Math.round(L),Math.round(N),Math.round(E),Math.round(j)]:null,size:S?[Math.round(I),Math.round(B)]:null}}),window.__particleToggle=(g,S)=>{for(let L=0;L<He.length;L++)He[L].setVisible(S===void 0?g:L===S);return He.length};const vt=[],Yt=new Map,Ut=g=>{if(!g||!g.puppet)return null;let S=Yt.get(g);return S||(S=new Map,Yt.set(g,S)),S};for(const g of b.layers)if(g.image)try{if(At.BUILTIN_MODELS[g.image])continue;const S=qe.getEntry(M,g.image);if(!S)continue;const L=JSON.parse(mt(S));if(!L.puppet)continue;const E=qe.getEntry(M,L.puppet);if(!E)continue;const N=Wn.parseMDL(new Uint8Array(E)),j=g.textureName?me.get(g.textureName):null;if(!j){se(e,n,`puppet '${g.name}' \u65E0\u8D34\u56FE\uFF0C\u8DF3\u8FC7`);continue}g.puppet=N,vt.push({mdl:N,tex:j,layer:g});const I=N.animations[0];se(e,n,`puppet '${g.name}' v=${N.vertexCount} bones=${N.bones.length}`+(I?` anim='${I.name}' ${I.fps}fps\xD7${I.frameCount}`:" \u65E0\u52A8\u753B"))}catch(S){console.warn(`puppet \u56FE\u5C42 ${g.name} \u52A0\u8F7D\u5931\u8D25: ${S.message}`),se(e,n,`puppet '${g.name}' \u5931\u8D25: ${S.message}`)}for(const g of b.layers)if(g.model&&!g.puppet)try{const S=qe.getEntry(M,g.model);if(!S)continue;const L=Wn.parseMDL(new Uint8Array(S));let E=null;if(L.materialPath){const j=qe.getEntry(M,L.materialPath);if(j){const B=JSON.parse(mt(j))?.passes?.[0]?.textures?.[0];typeof B=="string"&&B&&(E=B)}}E&&(await yt(E),g.textureName=E);const N=E?me.get(E):null;if(!N){se(e,n,`model '${g.name}' \u65E0\u8D34\u56FE\uFF0C\u8DF3\u8FC7`);continue}g.puppet=L,vt.push({mdl:L,tex:N,layer:g}),se(e,n,`model '${g.name}' v=${L.vertexCount} static ${L.materialPath||""}`)}catch(S){console.warn(`model \u56FE\u5C42 ${g.name} \u52A0\u8F7D\u5931\u8D25: ${S.message}`),se(e,n,`model '${g.name}' \u5931\u8D25: ${S.message}`)}let st=null;if(vt.length>0)try{st=Wn.createMDLRenderer(R.gl);for(const S of vt)st.upload(S.mdl);const g=new Map;for(const S of vt)g.set(S.layer,S);R.setPuppetRenderer((S,L,E)=>{const N=g.get(S);N&&st.draw(L,N.mdl,{time:E.time,animLayers:S.animationLayers,boneOverrides:Yt.get(S),overrideTex:E.overrideTex||null,color:[S.color[0]*S.brightness,S.color[1]*S.brightness,S.color[2]*S.brightness,S.alpha]},N.tex)})}catch(g){console.warn(`puppet \u6E32\u67D3\u5668\u521D\u59CB\u5316\u5931\u8D25: ${g.message}`),se(e,n,`puppet renderer \u5931\u8D25: ${g.message}`),st=null;for(const S of vt)S.layer.puppet=null}if(s)return;se(e,n,`puppet: ${vt.length} meshes`);const we=Wn.applyAttachmentBindOrigins(b.layers);we.length&&se(e,n,`attachments: ${we.length} hanging layers`);const at=Ze.collectTransformDirty(b.layers,we.map(g=>g.layer));if(at.size){se(e,n,`transform graph: ${at.size} live layers`);for(const[g,S]of Nt)if(at.has(g))for(const L of S)cn.push(L)}const ct=[],dt=new Map,Zt={};let Ye=null,Kt=null,Qn=0;if(!rs&&b.layers.some(g=>g.isText)){const g=b.general?.orthogonalprojection,S=g?.width||t.width,L=g?.height||t.height,E=jr(hn(e.cfg.fit),S,L,t.width,t.height),N=Math.min(3,Math.max(.5,t.width/Math.max(1,E.viewW))),j=new Map,I=[],B=new Set;for(const $ of b.layers)$.isText&&$.textFont&&B.add($.textFont);for(const $ of M.entries||[])typeof $.name=="string"&&/^fonts\/.+\.(ttf|otf|woff2?)$/i.test($.name)&&B.add($.name);for(const $ of B){const P=`${n.src}|${$}`,y=Tr.get(P);if(y){y.refs++,I.push(P),j.set($,y.family);continue}const C=Ol[$.toLowerCase()];if(C){j.set($,C);continue}try{const Q=qe.getEntry(M,$);if(!Q)continue;const ee=Il(Q instanceof Uint8Array?Q:new Uint8Array(Q)),ie="wefont_"+$l(P)+"_"+$.split("/").pop().replace(/[^a-zA-Z0-9]/g,"_"),oe=URL.createObjectURL(new Blob([ee])),fe=new FontFace(ie,`url(${oe})`);if(await fe.load(),s){URL.revokeObjectURL(oe);break}document.fonts.add(fe),(e.objectUrls??=[]).push(oe),j.set($,ie),Tr.set(P,{family:ie,refs:1}),I.push(P)}catch(Q){console.warn(`\u5B57\u4F53\u52A0\u8F7D\u5931\u8D25 ${$}: ${Q.message}`)}}if(I.length){const $=e.sceneCleanup;e.sceneCleanup=()=>{jl(I),$?.()}}Ye=document.createElement("canvas"),Kt=Ye.getContext("2d");const O=2048;for(const $ of b.layers)if($.isText)try{const P={layer:$,sandbox:null,texName:"__wstext_"+$.id,entry:null,lastKey:null,quality:N};if($.textScript&&(P.sandbox=tt.evalTextScript($.textScript,$.textScriptProps,{text:$.text??"",font:$.textFont||"",pointsize:$.textPointsize,color:$.textColor,angles:$.angles,origin:$.origin,scale:$.scale,visible:$.visible,canvasSize:{width:S,height:L},userProperties:v,shared:Zt,audioViews:De,inputView:Ie,...ft,mediaControl:Me,windowTitle:te.snapshot,openUserShortcut:Qe.openUserShortcut,getLayerText:ee=>dt.get(ee),onError:ee=>{se(e,n,`text script '${$.name}' \u5931\u8D25: ${String(ee.message||ee).slice(0,120)}`)}}),P.sandbox&&(_.push(P.sandbox),P.sandbox.init(),P.sandbox.applyUserProperties(v),P.sandbox.hasMediaHook&&Pe(P.sandbox))),dt.set($.name||"",String($.text??"")),$.textAnchor!=="center"&&$.size[0]>0&&$.size[1]>0){const ee=$.size[0]*($.scale[0]||1)/2,ie=$.size[1]*($.scale[1]||1)/2,oe=$.textAnchor;let fe=0,ge=0;oe.includes("left")&&(fe+=ee),oe.includes("right")&&(fe-=ee),oe.includes("top")&&(ge-=ie),oe.includes("bottom")&&(ge+=ie),$.origin[0]+=fe,$.origin[1]+=ge,$.localOrigin&&($.localOrigin[0]+=fe,$.localOrigin[1]+=ge)}const y=os*Math.max(1,$.textPointsize),C=tt.textLayerHasTintMask($)?8:256,Q=Math.min(C,tt.textCanvasMargin(y,0));P.boxW=$.size[0]>0?$.size[0]:y*4,P.boxH=$.size[1]>0?$.size[1]:y*1.6,P.margin=Q,$.size=[P.boxW+Q*2,P.boxH+Q*2],P.entry={glTex:je.makeTexture(R.gl,new Uint8Array([0,0,0,0]),1,1),width:1,height:1,rg88:!1},me.set(P.texName,P.entry),$.textureName=P.texName,$.solid=!1,ct.push(P)}catch(P){console.warn(`\u6587\u5B57\u5BF9\u8C61 ${$.name} \u521D\u59CB\u5316\u5931\u8D25: ${P.message}`)}if(ct.length>0){const $=u;u=()=>{$?.();for(const P of ct)R.gl.deleteTexture(P.entry.glTex)}}const Y=$=>{if(!Kt||!Ye)return;const P=Kt;for(const y of ct){const C=y.layer;let Q=String(C.text??"");if(y.sandbox&&y.sandbox.hasUpdate){y.sandbox.engine.runtime=$;const fe=y.sandbox.callUpdate(Q);fe!=null?Q=String(fe):y.sandbox.thisLayer.text&&(Q=String(y.sandbox.thisLayer.text))}else y.sandbox&&typeof y.sandbox.thisLayer?.text=="string"&&(Q=String(y.sandbox.thisLayer.text));if(dt.set(C.name||"",Q),!C.visible)continue;const ee=Math.max(1,y.sandbox?y.sandbox.thisLayer.pointsize:C.textPointsize),ie=y.sandbox&&y.sandbox.thisLayer.font||C.textFont||"",oe=`${Q}\0${ee}\0${ie}\0${C.alpha}\0${C.textCastshadow}`;if(y.lastKey!==oe){y.lastKey=oe;try{const fe=os*ee,ge=y.boxW,nt=y.boxH,pt=y.margin,ht=Math.abs(C.scale[0]||1),Ct=Math.abs(C.scale[1]||1);let Oe=Math.max(1,Math.round(C.size[0]*ht*y.quality)),ce=Math.max(1,Math.round(C.size[1]*Ct*y.quality));const pe=Math.min(1,O/Math.max(Oe,ce));Oe=Math.max(1,Math.round(Oe*pe)),ce=Math.max(1,Math.round(ce*pe)),Ye.width!==Oe||Ye.height!==ce?(Ye.width=Oe,Ye.height=ce):(P.setTransform(1,0,0,1,0,0),P.clearRect(0,0,Oe,ce));const ue=Math.min(Oe/C.size[0],ce/C.size[1]);P.setTransform(ue,0,0,ue,0,0),P.translate(pt,pt);const Ce=ie&&j.get(ie)||"sans-serif";P.font=`${fe}px "${Ce}", sans-serif`;const rt=P.measureText(""),Je=(rt.fontBoundingBoxAscent||0)+(rt.fontBoundingBoxDescent||0),lt=C.textSpacing||[0,0],ot=tt.layoutText(Q,{boxW:ge,boxH:nt,pointsize:fe,lineHeight:(Je>0?Je:fe*1.25)+lt[1],spacing:lt,padding:C.textPadding||0,maxwidth:C.textMaxwidth||0,limitwidth:!!C.textLimitwidth,maxrows:C.textMaxrows||0,limitrows:!!C.textLimitrows,limituseellipsis:!!C.textLimituseellipsis,halign:C.textHAlign,valign:C.textVAlign},pn=>P.measureText(pn).width);tt.drawTextLayer(P,ot,{font:P.font,color:C.textColor,alpha:C.alpha,brightness:C.brightness,spacing:lt,pointsize:fe,opaquebackground:!!C.textOpaquebackground,backgroundcolor:C.textBackgroundcolor,backgroundbrightness:C.textBackgroundbrightness,castshadow:!!C.textCastshadow});const Le=y.entry;R.gl.bindTexture(R.gl.TEXTURE_2D,Le.glTex),R.gl.texImage2D(R.gl.TEXTURE_2D,0,R.gl.RGBA,R.gl.RGBA,R.gl.UNSIGNED_BYTE,Ye),Le.width=Oe,Le.height=ce}catch(fe){console.warn(`\u6587\u5B57\u5BF9\u8C61 ${C.name} \u7ED8\u5236\u5931\u8D25: ${fe.message}`),y.lastKey=null}}}};e.sceneTextUpdate=Y,window.__textWidgets=ct,se(e,n,`text widgets: ${ct.length} (scripts ${ct.filter($=>$.sandbox).length}, fonts ${j.size}, quality ${N.toFixed(2)})`)}if(s)return;const Qt=[],An=[],Dt=[],un={},Jt=[],Bt=[],Fe=new Map,St=(g,S)=>{if(!S||typeof S.callCursor!="function"||!S.hasCursorHook)return;const L=Fe.get(g);L?L.push(S):Fe.set(g,[S])};for(const g of ct)g.sandbox&&St(g.layer,g.sandbox);{const g=b.general?.orthogonalprojection,S=g?.width||t.width,L=g?.height||t.height,E=v,N=(P,y)=>{const C=b.general||{};if(P==="zoom"&&typeof y=="number"&&Number.isFinite(y)&&y>0){b.cameraTransforms.zoom=y,C.zoom&&typeof C.zoom=="object"?C.zoom.value=y:C.zoom=y;return}C[P]&&typeof C[P]=="object"&&"value"in C[P]?C[P].value=y:C[P]=y};let j=1+Math.max(0,...b.layers.map(P=>Number(P.id)||0));const I={recomputeVisibility:T,getSceneLayer:P=>b.layers.find(y=>y.name===P&&!y.destroyed)||null,getSceneLayerById:P=>b.layers.find(y=>y.id===P&&!y.destroyed)||null,enumerateSceneLayers:()=>b.layers.filter(P=>!P.destroyed),getSceneAnimation:P=>{if(P==null||P==="")return null;if(un[P])return un[P];for(const y of b.layers)if(y.animations&&y.animations[P])return y.animations[P];return null},cameraTransforms:b.cameraTransforms,getInitialLayerConfig:P=>{const y=P&&typeof P=="object"?P.name:String(P||"");return b.layers.find(C=>C.name===y)||null},createSceneLayer:P=>{let y=P&&typeof P=="object"?P:null;if(typeof P=="string"){const Q=P;if(y=b.layers.find(ee=>ee&&!ee.destroyed&&ee.image===Q&&ee.textureName)||b.layers.find(ee=>ee&&!ee.destroyed&&ee.image===Q)||null,!y)return se(e,n,`createLayer('${Q}') \u627E\u4E0D\u5230\u5DF2\u52A0\u8F7D\u7684\u540C\u6A21\u578B\u5C42`),null}y||(y={});const C={...y,id:j++,origin:Array.isArray(y.origin)?y.origin.slice():[0,0,0],scale:Array.isArray(y.scale)?y.scale.slice():[1,1,1],angles:Array.isArray(y.angles)?y.angles.slice():[0,0,0],size:Array.isArray(y.size)?y.size.slice():[0,0],color:Array.isArray(y.color)?y.color.slice():[1,1,1],childIds:null,hasChildren:!1,destroyed:!1,animations:{},animationList:[],objectScripts:null};return delete C.textureAnimation,delete C.videoTextureApi,delete C.soundCtl,delete C.videoCtl,Array.isArray(y.effects)&&(C.effects=y.effects.map(Q=>({...Q,passes:Array.isArray(Q.passes)?Q.passes.map(ee=>({...ee})):Q.passes}))),b.layers.push(C),C},mediaControl:Me,windowTitle:te.snapshot,openUserShortcut:Qe.openUserShortcut,isScreensaver:!1};R.setConstantScriptRuntime?.(tt.evalObjectScript,{userProperties:E,audioViews:De,shared:Zt,inputView:Ie,timers:We,...I,onSandbox:P=>{P&&P.hasMediaHook&&Pe(P)}});const B={origin:"localOrigin",scale:"localScale",angles:"localAngles"},O=(P,y)=>{const C=B[y];return C&&P&&Array.isArray(P[C])?C:y};for(const P of b.layers){const y=P.objectAnimations;if(y){P.animations=P.animations||{},P.animationList=P.animationList||[];for(const[C,Q]of Object.entries(y))try{const ee=Ki.createAnimation(Q.animation);ee.field=C,ee.baseValue=Q.value;const ie=O(P,C),oe=P[ie];ee.baseNumeric=Array.isArray(oe)?oe.slice():oe,ee.slot=ie,P.animationList.push(ee),ee.name&&(P.animations[ee.name]=ee),An.push({layer:P,field:C,slot:ie,ctrl:ee})}catch(ee){se(e,n,`animation '${P.name}.${C}' \u5EFA\u63A7\u5236\u5668\u5931\u8D25: ${String(ee.message).slice(0,80)}`)}}}for(const P of b.layers){for(const[C,Q]of(P.effects||[]).entries()){const ee=Q.visibleScript;if(ee)try{const ie=tt.evalObjectScript(ee.script,ee.scriptproperties,{canvasSize:{width:S,height:L},userProperties:E,audioViews:De,inputView:Ie,...ft,layer:P,targetEffect:Q,...I,shared:Zt,onError:oe=>se(e,n,`effect visible script '${P.name}#${C}' \u5931\u8D25: ${String(oe.message||oe).slice(0,80)}`)});if(!ie)continue;_.push(ie),ie.init(Q.visible),ie.applyUserProperties(E),ie.hasMediaHook&&Pe(ie),ie.hasUpdate&&Jt.push({effect:Q,sandbox:ie})}catch(ie){console.warn(`\u6548\u679C\u5F00\u5173\u811A\u672C ${P.name}#${C} \u6C42\u503C\u5931\u8D25: ${ie.message}`)}}const y=P.objectScripts;if(y)for(const[C,Q]of Object.entries(y))try{const ee=tt.evalObjectScript(Q.script,Q.scriptproperties,{canvasSize:{width:S,height:L},screenResolution:{x:t.clientWidth||window.innerWidth||1,y:t.clientHeight||window.innerHeight||1},timeOfDay:(()=>{const ie=new Date;return(ie.getHours()*3600+ie.getMinutes()*60+ie.getSeconds())/86400})(),userProperties:E,audioViews:De,inputView:Ie,layer:P,...I,getBoneOverrides:Ut,shared:Zt,...ft,onError:ie=>se(e,n,`object script '${P.name}.${C}' \u5931\u8D25: ${String(ie.message||ie).slice(0,90)}`)});if(ee){_.push(ee);const ie=O(P,C),oe=P[ie],fe=C==="angles"&&Array.isArray(oe)?tt.radToScriptAngles(oe):Array.isArray(oe)?{x:oe[0]??0,y:oe[1]??0,z:oe[2]??0}:oe;ee.init(fe),ee.applyUserProperties(E),St(P,ee),ee.hasMediaHook&&Pe(ee),ee.hasUpdate&&Qt.push({layer:P,field:C,slot:ie,kind:C==="visible"?"bool":C==="alpha"||C==="brightness"?"scalar":"vec3",sandbox:ee})}}catch(ee){console.warn(`\u5BF9\u8C61\u811A\u672C ${P.name}.${C} \u6C42\u503C\u5931\u8D25: ${ee.message}`)}}const Y=b.generalScripts;if(Y){for(const[P,y]of Object.entries(Y))try{const C=tt.evalObjectScript(y.script,y.scriptproperties,{canvasSize:{width:S,height:L},userProperties:E,audioViews:De,inputView:Ie,...ft,...I,shared:Zt,onError:ee=>se(e,n,`general script '${P}' \u5931\u8D25: ${String(ee.message||ee).slice(0,80)}`)});if(!C)continue;_.push(C),C.init(y.value),C.applyUserProperties(E),C.hasMediaHook&&Pe(C);const Q=ee=>N(P,ee);C.hasUpdate&&Bt.push({field:P,sandbox:C,write:Q})}catch(C){console.warn(`general \u811A\u672C ${P} \u6C42\u503C\u5931\u8D25: ${C.message}`)}Bt.length&&se(e,n,`general scripts: ${Bt.map(P=>P.field).join(",")}`)}const $=b.generalAnimations;if($){for(const[P,y]of Object.entries($))try{const C=Ki.createAnimation(y.animation);C.field=P,C.baseValue=y.value,C.baseNumeric=y.value,C.name&&(un[C.name]=C),Dt.push({field:P,ctrl:C,write:Q=>N(P,Q)})}catch(C){se(e,n,`general animation '${P}' \u5EFA\u63A7\u5236\u5668\u5931\u8D25: ${String(C.message).slice(0,80)}`)}Dt.length&&se(e,n,`general animations: ${Dt.map(P=>P.field).join(",")}`)}}Qt.length&&(se(e,n,`object scripts: ${Qt.length}`),window.__objScripts=Qt),window.__mediaHooks=Ee,window.__sceneLayers=b.layers,window.__compositeStats=()=>R.compositeStats?.()??null,window.__compositeEnable=g=>R.setCompositeEnabled?.(g),window.__scene=b,window.__textures=me;const Et=Array.from(Fe.keys());Et.length&&se(e,n,`cursor hooks: ${Et.length} layers`);let It=null,Ot=null,fn=!1;const en=()=>({worldPosition:tt.makeCursorEventVec(_e.state.wx,_e.state.originY!=null?_e.state.originY:_e.state.wy,0)}),$t=(g,S,L)=>{const E=Fe.get(g);if(E)for(const N of E)N.callCursor(S,L)},Jn=()=>{if(Et.length===0)return;const g=_e.state;if(!g.has)return;const S=R.getParallaxOffset?R.getParallaxOffset():{x:0,y:0},L=b.general?.orthogonalprojection?.height||t.height,E=ml.hitTestLayers(b.layers,g.wx,g.wy,L,{parOffX:S.x,parOffY:S.y,alignTable:je.ALIGN,filter:j=>Fe.has(j)}),N=en();E!==It&&(It&&$t(It,"cursorLeave",N),It=E,E&&$t(E,"cursorEnter",N)),E&&$t(E,"cursorMove",N),g.leftDown&&!fn?(Ot=E,E&&$t(E,"cursorDown",N)):!g.leftDown&&fn&&(Ot&&$t(Ot,"cursorUp",N),Ot&&Ot===E&&$t(E,"cursorClick",N),Ot=null),fn=g.leftDown},er=performance.now();let tr=0,tn=0;const dn=[],Pt=[];let x=-1/0,D=0;const H=g=>{if(s||e.paused)return;const L=1e3/(e.cfg.sceneFps||60);if(g-x>=L){if(x=g,rr(e,g),e.onFirstFrame){const O=e.onFirstFrame;e.onFirstFrame=void 0,O()}wo(e,t,e.cfg);const E=(g-er-tr)/1e3;if(Ie.update(_e.state),Ve.enabled){W?.media?W.media.pump():V.update(E);const O=le(),Y=xe.diffMediaEvents(Re,O);if(Y.length){for(const{name:$,event:P}of Y)for(const y of Ee)y.disabled||y.callMedia($,P);Re=xe.cloneMediaSnapshot(O)}}W?.windowTitle?W.windowTitle.pump():q.update(E);const N=Math.max(0,E-D);D=E;for(const O of An){O.ctrl.advance(N);const Y=O.field,$=O.slot||Y,P=O.ctrl.applyTo(O.ctrl.baseNumeric);if(Array.isArray(P)){const y=O.layer[$];if(Array.isArray(y))for(let C=0;C<P.length&&C<y.length;C++)y[C]=P[C]}else Number.isFinite(P)&&(Y==="visible"?O.layer[Y]=!!P:O.layer[$]=P)}for(const O of Dt){O.ctrl.advance(N);const Y=O.ctrl.applyTo(O.ctrl.baseNumeric);typeof Y=="number"&&Number.isFinite(Y)?O.write(Y):Array.isArray(Y)&&Number.isFinite(Y[0])&&O.write(Y[0])}for(const O of Jt){if(O.sandbox.disabled)continue;O.sandbox.engine.frametime=N,O.sandbox.engine.runtime=E;const Y=O.sandbox.callUpdate(!!O.effect.visible);typeof Y=="boolean"&&(O.effect.visible=Y)}for(const O of Bt){if(O.sandbox.disabled)continue;O.sandbox.engine.frametime=N,O.sandbox.engine.runtime=E;const Y=b.general||{},$=Y[O.field]&&typeof Y[O.field]=="object"&&"value"in Y[O.field]?Y[O.field].value:Y[O.field],P=O.sandbox.callUpdate($);P!==void 0&&O.write(P)}const j={x:t.clientWidth||window.innerWidth||1,y:t.clientHeight||window.innerHeight||1};for(const O of _)!O||O.disabled||(O.engine.frametime=N,O.engine.runtime=E,O.engine.screenResolution=j);let I=!1;for(const O of Qt){if(O.sandbox.disabled)continue;O.sandbox.engine.frametime=N,O.sandbox.engine.runtime=E,O.sandbox.engine.screenResolution=j;const Y=O.layer[O.field];if(O.kind==="bool"){const $=O.sandbox.callUpdate(!!Y);typeof $=="boolean"&&(O.field==="visible"?O.layer.visibleSelf!==$&&(O.layer.visibleSelf=$,I=!0):O.layer[O.field]=$)}else if(O.kind==="scalar"){const $=O.sandbox.callUpdate(Number(Y)||0),P=Number($);Number.isFinite(P)&&(O.layer[O.field]=P)}else{const $=O.slot||O.field,P=O.layer[$],y=O.field==="angles"?tt.radToScriptAngles(P):{x:P[0]||0,y:P[1]||0,z:P[2]||0},C=O.sandbox.callUpdate(y),Q=C&&typeof C=="object"&&"x"in C?C:y;O.layer[$]=O.field==="angles"?tt.scriptAnglesToRad(Q):[Q.x||0,Q.y||0,Q.z||0]}}I&&T(),at.size&&Ze.recomposeWorld(b.layers,at),X.enabled&&(Se.pump(),Se.active||(K.current?K.current.pump():U.update(E)),Qc(De,Ae())),we.length&&Wn.followAttachments(we,E,Ut);const B=e.coverAlign;R.render(b,me,t.width,t.height,E,hn(e.cfg.fit),B.x,B.y).then(()=>{if(!(s||e.paused)){try{Jn()}catch{}_e.beginFrame();try{e.sceneTextUpdate&&g>=Qn&&(Qn=g+100,e.sceneTextUpdate(E))}catch{}e.raf=requestAnimationFrame(H)}}).catch(O=>{console.warn("scene render error:",O),se(e,n,`render: ${String(O.message||O).slice(0,200)}`),s=!0})}else e.paused||(e.raf=requestAnimationFrame(H))},z=()=>{s||e.paused||e.raf===void 0&&(e.raf=requestAnimationFrame(H))},G=g=>{if(s)return;const S=b.properties||{},L=Hs(S,v,g);if(Object.keys(L).length){for(const E of b.layers){const N=E.srcObject;if(!N)continue;mn(N,S,0);const j=wt(N.visible);j&&j in L&&(E.visibleSelf=Ze.parseBool(N.visible,!0));const I=wt(N.color);I&&I in L&&(E.color=Ze.parseColor(N.color),E.isText&&(E.textColor=E.color));const B=wt(N.alpha);B&&B in L&&(E.alpha=Ze.parseNum(N.alpha,1));const O=wt(N.brightness);O&&O in L&&(E.brightness=Ze.parseNum(N.brightness,1));const Y=wt(N.volume);if(Y&&Y in L){const P=Ze.parseNum(N.volume,1);E.soundprops&&(E.soundprops.volume=P),E.soundCtl?.setVolume?.(P)}for(let P=0;P<(N.animationlayers||[]).length;P++){const y=N.animationlayers[P],C=E.animationLayers?.[P];if(!y||!C)continue;const Q=wt(y.visible);Q&&Q in L&&(C.visible=Ze.parseBool(y.visible,!0));const ee=wt(y.rate);ee&&ee in L&&(C.rate=Ze.parseNum(y.rate,1));const ie=wt(y.blend);ie&&ie in L&&(C.blend=Ze.parseNum(y.blend,1))}for(let P=0;P<(N.effects||[]).length;P++){const y=N.effects[P],C=E.effects?.[P];if(!y||!C)continue;const Q=wt(y.visible);Q&&Q in L&&!C.visibleScript&&(C.visible=Ze.parseBool(y.visible,!0))}const $=N.instanceoverride;if($&&typeof $=="object"&&E.particle){let P=!1;for(const y of Object.keys($)){if(y==="id")continue;const C=wt($[y]);if(C&&C in L){P=!0;break}}if(P){const y=Nt.get(E.id);if(y)for(const C of y)C.reapplyOverride?.()}}}for(const E of _)if(!(!E||E.disabled))try{E.applyUserProperties(L)}catch{}T();for(const E of b.layers){if(!E.particle)continue;const N=Nt.get(E.id);if(N)for(const j of N)j.setVisible(!!E.visible)}R.applyConstUserProperties?.(L);for(const E of ct)E.lastKey=null;se(e,n,`props hot: ${Object.keys(L).join(",")}`)}};f=()=>{e.raf!==void 0&&(cancelAnimationFrame(e.raf),e.raf=void 0),tn||(tn=performance.now()),dn.length=0;for(const g of me.values())g?.videoCtl?.isPlaying?.()&&(dn.push(g.videoCtl),g.videoCtl.pause());Pt.length=0;for(const g of ln)!g.paused&&!g.ended&&(Pt.push(g),g.pause())},d=()=>{tn&&(tr+=performance.now()-tn,tn=0),qt=performance.now();for(const g of dn)try{g.play()}catch{}dn.length=0;for(const g of Pt)g.play().catch(()=>{});Pt.length=0,z()},p=G,l&&(G(l),l=null),z();{const g=b.general?.orthogonalprojection,S=g?.width||t.width,L=g?.height||t.height,E=hn(e.cfg.fit),N=jr(E,S,L,t.width,t.height);se(e,n,`fit ${E}: view ${Math.round(N.viewW)}x${Math.round(N.viewH)} scene ${S}x${L} canvas ${t.width}x${t.height}`)}se(e,n,`renderer started: ${b.layers.length} layers`)}catch(w){if(s||w&&w.name==="AbortError")return;console.warn("scene render failed:",w);const M=w instanceof Error?w:new Error(String(w));se(e,n,`failed: ${String(M.message||M).slice(0,200)}`),e.onError?e.onError(M):e.fallbackPage?.()}})()}const Xl='data-we-shim="1"',ss="data-we-shim-src";function Gl(e){try{const n=new URL(e),t=n.pathname,r=t.lastIndexOf("/");return n.pathname=r<0?"/":t.slice(0,r+1),n.hash="",n.search="",n.href}catch{const n=e.replace(/[#?].*$/,""),t=n.lastIndexOf("/");return t<0?n:n.slice(0,t+1)}}function ql(e){const n=/<meta[^>]+http-equiv\s*=\s*["']?Content-Security-Policy["']?[^>]*>/gi;let t;for(;t=n.exec(e);){const r=t[0],o=/content\s*=\s*"([^"]*)"/i.exec(r)?.[1]??/content\s*=\s*'([^']*)'/i.exec(r)?.[1]??"";if(/script-src/i.test(o)&&!/script-src[^;]*'unsafe-inline'/i.test(o)&&!/script-src[^;]*\*/i.test(o))return!0}return!1}function as(e){return e.replace(/<\/script/gi,"<\\/script")}function Yl(e,n,t){if(e||(e=""),e.includes(Xl)||e.includes(ss))return e;const r=t.baseHref&&!/<base\b/i.test(e)?`<base href="${t.baseHref.replace(/"/g,""")}">`:"",o=`<script ${ss}="1">
|
|
513
|
-
${
|
|
512
|
+
`};function eu(e){if(!e||e.length<12)return e;const n=e[0],t=e[1],r=e[2],o=e[3];if(!(n===0&&t===1&&r===0&&o===0)&&!(n===79&&t===84&&r===84&&o===79))return e;const a=Uint8Array.from(e),c=new DataView(a.buffer,a.byteOffset,a.byteLength),u=c.getUint16(4);if(u<=0||12+u*16>a.length)return e;let l=-1,f=0,p=0;for(let M=0;M<u;M++){const h=12+M*16;if(String.fromCharCode(a[h],a[h+1],a[h+2],a[h+3])==="cmap"){l=h,f=c.getUint32(h+8),p=c.getUint32(h+12);break}}if(l<0||f+p>a.length)return e;let d=!1;const y=c.getUint16(f+2);for(let M=0;M<y;M++){const h=f+4+M*8,g=c.getUint32(h+4),v=f+g;if(v+14>a.length||c.getUint16(v)!==4)continue;const A=c.getUint16(v+6),_=A>>>1;if(_<1)continue;const R=2*Math.pow(2,Math.floor(Math.log2(_))),L=Math.floor(Math.log2(_)),N=A-R,j=c.getUint16(v+8),H=c.getUint16(v+10),K=c.getUint16(v+12);j===R&&H===L&&K===N||(c.setUint16(v+8,R),c.setUint16(v+10,L),c.setUint16(v+12,N),d=!0)}if(!d)return e;let x=0;const m=f+p;for(let M=f;M<m;M+=4){const h=a[M]||0,g=M+1<m?a[M+1]:0,v=M+2<m?a[M+2]:0,A=M+3<m?a[M+3]:0;x=x+(h<<24|g<<16|v<<8|A)>>>0}return c.setUint32(l+4,x),a}const tu={systemfont_segoe:"'Segoe UI', 'Helvetica Neue', Arial, sans-serif",systemfont_arial:"Arial, 'Helvetica Neue', sans-serif",systemfont_verdana:"Verdana, Geneva, sans-serif",systemfont_tahoma:"Tahoma, Geneva, sans-serif",systemfont_timesnewroman:"'Times New Roman', Times, serif",systemfont_georgia:"Georgia, 'Times New Roman', serif",systemfont_couriernew:"'Courier New', Courier, monospace",systemfont_trebuchetms:"'Trebuchet MS', 'Helvetica Neue', sans-serif",systemfont_impact:"Impact, 'Arial Black', sans-serif",systemfont_comicsansms:"'Comic Sans MS', 'Comic Sans', cursive",systemfont_sylfaen:"Palatino, 'Times New Roman', serif",systemfont_calibri:"Calibri, Carlito, 'Helvetica Neue', sans-serif",systemfont_cambria:"Cambria, Georgia, serif",systemfont_consolas:"Consolas, 'Courier New', monospace",systemfont_microsoftyahei:"'Microsoft YaHei', 'PingFang SC', 'Hiragino Sans GB', sans-serif",systemfont_simsun:"SimSun, 'Songti SC', serif",systemfont_simhei:"SimHei, 'Heiti SC', sans-serif"},Tr=new Map;function nu(e){let n=5381;for(let t=0;t<e.length;t++)n=(n<<5)+n+e.charCodeAt(t)|0;return(n>>>0).toString(36)}function ru(e){for(const n of e){const t=Tr.get(n);if(t&&(t.refs--,!(t.refs>0))){Tr.delete(n);try{const r=[];document.fonts.forEach(o=>{o.family===t.family&&r.push(o)});for(const o of r)document.fonts.delete(o)}catch{}}}}const cn=new Map,ou=512*1024*1024;let bo=0;function iu(e){for(;cn.size>0&&(cn.size>2||bo>ou);){let n=null,t=1/0;for(const[o,i]of cn)o!==e&&i.at<t&&(t=i.at,n=o);if(!n)break;const r=cn.get(n);bo-=r.parsed.fileSize||0,cn.delete(n)}}async function su(e,n,t,r){const o=t.key;if(o){const c=cn.get(o);if(c)return c.at=Date.now(),se(e,n,`pkg cache hit: ${c.parsed.fileSize} bytes`),c.parsed}let i;try{i=await t.scenePkg(r)}catch(c){throw r.aborted||c instanceof Error?c:new Error(String(c))}se(e,n,`pkg body: ${i.byteLength} bytes`);const s=i instanceof Uint8Array?i:new Uint8Array(i),a=Ge.parsePkg(s);return o&&(cn.set(o,{parsed:a,at:Date.now()}),bo+=a.fileSize||0,iu(o)),a}function au(e,n){on(e);const t=(n.canvas instanceof HTMLCanvasElement?n.canvas:null)??document.createElement("canvas"),r=rr(e,n),o=t.clientWidth||window.innerWidth||1,i=t.clientHeight||window.innerHeight||1;t.width=Math.max(1,Math.round(o*r)),t.height=Math.max(1,Math.round(i*r)),n.canvas instanceof HTMLCanvasElement||(t.style.cssText="position:absolute;inset:0;width:100%;height:100%;",e.wrap?.appendChild(t)),e.canvas=t;let s=!1;const a=console.warn.bind(console);console.warn=(...y)=>{const x=y.map(m=>typeof m=="string"?m:String(m?.message??m)).join(" ");if(x.includes("[we-scene]"))try{se(e,n,x.slice(0,300))}catch{}a(...y)};const c=new AbortController;let u;e.sceneCleanup=()=>{s=!0,console.warn=a,c.abort(),e.sceneTextUpdate=void 0,u&&(u(),u=void 0),e.renderer&&(e.renderer.dispose?.(),e.renderer=void 0)};let l=null,f,p,d;e.sceneCtl={pause(){p?.()},resume(){d?.()},applyUserProperties(y){f?f(y):l={...l||{},...y}}},(async()=>{try{const y=n.source??ss(`${n.mediaBase}/${n.src}`);if(!n.source&&(!n.mediaBase||!n.src))throw new Error("\u573A\u666F\u58C1\u7EB8\u7F3A\u5C11 mediaBase/src");se(e,n,"mountScene start");const x=await su(e,n,y,c.signal);if(s)return;let m=null;try{m=await y.project?.(c.signal)??null}catch{}if(!t.getContext("webgl2",{premultipliedAlpha:!1,antialias:!1,alpha:!1,preserveDrawingBuffer:!0}))throw new Error("WEBGL2_UNAVAILABLE");const h=Ge.getEntry(x,"scene.json");if(!h)throw new Error("pkg \u4E2D\u6CA1\u6709 scene.json\uFF08\u4E0D\u662F\u573A\u666F\u58C1\u7EB8\uFF1F\uFF09");const g=Ke.parseScene(JSON.parse(xt(h)),m);if(n.clearColor){const b=g.general??={};b.clearcolor=n.clearColor,b.clearenabled=!0}{const b=g.general?.zoom,T=Number(b&&typeof b=="object"?b.value:b);g.cameraTransforms={zoom:Number.isFinite(T)&&T>0?T:1}}const v=ra(g.properties||{});e.liveUserProps=v;const A=()=>Ke.recomputeLayerVisibility(g.layers);if(e.onSceneInfo){const b=g.general?.orthogonalprojection||{},T=Number(b.width)>0?Number(b.width):t.width,P=Number(b.height)>0?Number(b.height):t.height,C=g.layers||[],I={width:T,height:P,layerCount:C.length,hasModels:C.some($=>!!$.model),hasParticles:C.some($=>!!$.particle),hasText:C.some($=>!!$.text)},D=e.onSceneInfo;e.onSceneInfo=void 0,D(I)}const _=[];us&&(g.layers=g.layers.filter(b=>!(us&&b.isComponent)));const R=b=>{const T=b.startsWith("shaders/")?b:"shaders/"+b,P=b.startsWith("shaders/")?b.slice(8):b,C=Ge.getEntry(x,T);let I=C?xt(C):Jl[P]??null;const D=window.__shaderPatch;if(I&&D){const $=P.replace(/\.(frag|vert|h)$/,""),z=D[$]||D[P];if(typeof z=="function")try{const B=z(I,P);typeof B=="string"&&(I=B)}catch{}}return Promise.resolve(I)},L=$e.createRenderer(t,{shaderResolver:R,diag:b=>se(e,n,`renderer: ${b}`),fboCapFactor:0});if(e.renderer=L,s)return;const N=m?.general?.supportsaudioprocessing!==!1,j=Zi(),H=we.createSimulatedMedia(),K=rs.createSimulatedWindowTitle();let O=null;const W={mediaDriver:null,lastSnap:{get:()=>null,setHasThumbnail:()=>{}}},X={current:null};let ie=null;const J=()=>ie??e.mediaSource??H;let Z=K;const te={enabled:N&&!e.audioDisabled},le=b=>new Float32Array(b),Fe={left16:le(16),right16:le(16),left32:le(32),right32:le(32),left64:le(64),right64:le(64),level:0,silent:!0},_e=(()=>{const b={left64:le(64),right64:le(64),left32:le(32),right32:le(32),left16:le(16),right16:le(16),preL64:le(64),preR64:le(64),level:0,silent:!0},T=(P,C)=>{const I=C.length/P.length;for(let D=0;D<P.length;D++){let $=0;const z=Math.floor(D*I),B=Math.max(z+1,Math.floor((D+1)*I));for(let q=z;q<B;q++)$+=C[q];P[D]=$/(B-z)}};return{active:!1,snapshot:b,pump(){const P=e.audioBridge?.();if(!P||!P.left||!P.right){this.active=!1;return}const C=Math.min(64,P.left.length,P.right.length);let I=0;for(let D=0;D<C;D++){const $=P.left[D]||0,z=P.right[D]||0;b.left64[D]=$,b.right64[D]=z,b.preL64[D]=$,b.preR64[D]=z,D<48&&(I+=$)}for(let D=C;D<64;D++)b.left64[D]=0,b.right64[D]=0,b.preL64[D]=0,b.preR64[D]=0;T(b.left32,b.left64),T(b.right32,b.right64),T(b.left16,b.left64),T(b.right16,b.right64),b.level=Math.min(1,I/48),b.silent=b.level<.02,this.active=!0}}})(),Ye=()=>_e.active?_e.snapshot:X.current?X.current.snapshot:j.snapshot;L.setAudioProvider(()=>te.enabled?Ye():Fe);const Ve=new Map;window.__audioStats=()=>({enabled:te.enabled,live:!!X.current,level:te.enabled?Math.round((X.current?X.current.snapshot:j.snapshot).level*1e3)/1e3:0,silent:te.enabled?(X.current?X.current.snapshot:j.snapshot).silent:!0,bass:te.enabled?Math.round((X.current?X.current.snapshot:j.snapshot).left64[2]*1e3)/1e3:0}),window.__audioMute=b=>(te.enabled=!b,te.enabled),se(e,n,`audio: ${X.current?"live mic":"simulated"} stream, supportsaudioprocessing=${N}`);const Ne=rs.createShortcutHandler(b=>{se(e,n,`openUserShortcut: ${b}`)}),qe={enabled:!e.mediaDisabled,override:null},Ue=[];let ye=null;W.lastSnap={get:()=>ye,setHasThumbnail:b=>{ye&&(ye.hasThumbnail=b)}};const he=()=>J().snapshot,De=b=>{if(!(!b||!b.hasMediaHook||Ue.includes(b))&&(Ue.push(b),!!he().hasMedia))for(const{name:T,event:P}of we.diffMediaEvents(null,he()))try{b.callMedia(T,P)}catch{}};window.__mediaStats=()=>({enabled:qe.enabled,live:!!O,hooks:Ue.length,title:he().title,artist:he().artist,album:he().album,state:he().state,position:Math.round(he().position),duration:he().duration,hasThumbnail:he().hasThumbnail,lyric:he().lyricLine,primaryColor:he().primaryColor?[he().primaryColor.x,he().primaryColor.y,he().primaryColor.z]:null}),window.__mediaSet=b=>{Object.assign(he(),b||{});const T=we.diffMediaEvents(ye,he());for(const{name:P,event:C}of T)for(const I of Ue)I.callMedia(P,C);return ye=we.cloneMediaSnapshot(he()),window.__mediaStats()};const Pe=()=>{const b=we.diffMediaEvents(ye,he());for(const{name:T,event:P}of b)for(const C of Ue)try{C.callMedia(T,P)}catch{}ye=we.cloneMediaSnapshot(he())},Ze=b=>{const T=J(),P=T?.[b];if(typeof P=="function")try{P.call(T)}catch(C){se(e,n,`media ${b} \u5931\u8D25: ${C?.message}`)}return Pe(),he()},Be={get snapshot(){return he()},skipNext:()=>Ze("skipNext"),skipPrevious:()=>Ze("skipPrevious"),play:()=>Ze("play"),pause:()=>Ze("pause"),playPause:()=>Ze("playPause")};e.mediaCtl=Be,window.__mediaControl=Be,window.__system={media:Be,windowTitle:Z.snapshot,shortcuts:Ne.last,live:null},window.__liveSystem=()=>({audio:"off",media:"offline",window:"offline"});const Ae=El.createPointerSource(n.canvas?{target:n.canvas,viewport:()=>({w:n.canvas.clientWidth||window.innerWidth||1,h:n.canvas.clientHeight||window.innerHeight||1})}:{});L.setPointerProvider(()=>Ae),e.pointerCtl={push:b=>Ae.pushExternal(b),leave:()=>Ae.pushExternalLeave()};{const b=u;u=()=>{b?.(),Ae.dispose()}}const nt=tt.createInputView(),rt=Sl.createEngineTimers({setTimeout:(b,T)=>window.setTimeout(b,T),clearTimeout:b=>window.clearTimeout(b),setInterval:(b,T)=>window.setInterval(b,T),clearInterval:b=>window.clearInterval(b)},{onError:(()=>{let b=!1;return T=>{b||(b=!0,se(e,n,`engine \u5B9A\u65F6\u5668\u56DE\u8C03\u629B\u9519\uFF08\u6B64\u540E\u540C\u7C7B\u9759\u9ED8\uFF09: ${String(T?.message||T).slice(0,90)}`))}})()}),Ft={setTimeout:rt.setTimeout,clearTimeout:rt.clearTimeout,setInterval:rt.setInterval,clearInterval:rt.clearInterval};{const b=u;u=()=>{b?.(),rt.dispose()}}window.__pointerStats=()=>{const b=Ae.state,T=P=>Math.round(P*1e3)/1e3;return{normalized:{u:T(b.u),v:T(b.v)},last:{u:T(b.lastU),v:T(b.lastV)},world:{x:Math.round(b.wx),y:Math.round(b.wy)},originY:b.originY!=null?Math.round(b.originY):null,screen:{x:b.screenX,y:b.screenY,w:b.screenW,h:b.screenH},leftDown:b.leftDown,has:b.has,delta:T(Ae.normalizedDelta()),counts:{move:b.moveCount,down:b.downCount,up:b.upCount}}};const xe=new Map;xe.set("util/white",{glTex:$e.makeTexture(L.gl,new Uint8Array([255,255,255,255]),1,1),width:1,height:1,rg88:!1}),xe.set("util/noflow",{glTex:$e.makeTexture(L.gl,new Uint8Array([127,127,127,255]),1,1),width:1,height:1,rg88:!1}),xe.set("util/noise",{glTex:$e.makeTexture(L.gl,Al.generateNoiseTexture(),256,256),width:256,height:256,rg88:!1,mips:null});{const b=P=>{const C=we.renderThumbnail(P,512);return{glTex:$e.makeTextureMip(L.gl,[C],!1),width:C.width,height:C.height,rg88:!1,mips:[C],generated:!0}},T=H.tracks||[];T.length&&(xe.set("$mediaThumbnail",b(T[0])),xe.set("$mediaPreviousThumbnail",b(T[T.length-1])))}if(n.liveSystem){const b={handle:null,dead:!1};(e.wallpaperDisposers??=[]).push(()=>{b.dead=!0;try{b.handle?.dispose()}catch{}b.handle=null});try{const T=async P=>{try{const C=await fetch(P.url,{cache:"no-store"});if(!C.ok)return;const I=await C.blob(),D=await createImageBitmap(I),$=Zl(D,D.width,D.height,512),z=ql(D,D.width,D.height);D.close?.();const B=xe.get("$mediaThumbnail");B&&xe.set("$mediaPreviousThumbnail",B);const q=L.gl,S=xe.get("$mediaThumbnail");S?.glTex?(q.bindTexture(q.TEXTURE_2D,S.glTex),q.texImage2D(q.TEXTURE_2D,0,q.RGBA,$.width,$.height,0,q.RGBA,q.UNSIGNED_BYTE,$.rgba),S.width=$.width,S.height=$.height,S.mips=[$]):xe.set("$mediaThumbnail",{glTex:$e.makeTextureMip(q,[$],!1),width:$.width,height:$.height,rg88:!1,mips:[$],generated:!0});const E=J().snapshot;z&&(E.primaryColor=we.mediaVec3(...z.primary),E.secondaryColor=we.mediaVec3(...z.secondary),E.tertiaryColor=we.mediaVec3(...z.tertiary),E.textColor=we.mediaVec3(.98,.98,1),E.highContrastColor=we.mediaVec3(1,1,1)),E.hasThumbnail=!0,W.lastSnap.setHasThumbnail(!1),se(e,n,`liveSystem: artwork ${P.title||P.trackKey}`)}catch(C){se(e,n,`liveSystem: artwork \u5931\u8D25 (${C instanceof Error?C.message:C})`)}};if(O=await hs({origin:location.origin,onArtwork:P=>{T(P)}}),b.dead){try{O.dispose()}catch{}O=null}else{if(b.handle=O,ie=O.media,Z=O.windowTitle,W.mediaDriver=O.media,O.status().audio==="mic"&&(X.current=O.audio),J().snapshot.hasMedia){for(const{name:C,event:I}of we.diffMediaEvents(null,J().snapshot))for(const D of Ue)try{D.callMedia(C,I)}catch{}ye=we.cloneMediaSnapshot(J().snapshot)}const P=O.status();se(e,n,`liveSystem: audio=${P.audio} media=${P.media} window=${P.window}`+(P.title?` title="${P.title}"`:"")+(P.hasArtwork?" artwork=1":"")),se(e,n,`audio: ${X.current?"live mic":"simulated"} stream, supportsaudioprocessing=${N}`),window.__system={media:Be,windowTitle:Z.snapshot,shortcuts:Ne.last,live:()=>O.status()},window.__liveSystem=()=>O.status()}}catch(T){se(e,n,`liveSystem: \u542F\u52A8\u5931\u8D25\uFF0C\u56DE\u9000\u6A21\u62DF\u6E90 (${T instanceof Error?T.message:T})`),O=null}}{const b=u;u=()=>{b?.(),O?.dispose(),O=null}}const zt=new Map,Er=async b=>{if(xe.has(b))return xe.get(b);const T=Ge.getEntry(x,`materials/${b}.tex`);if(!T){if(an.isBuiltinParticleTextureName(b)){const $=an.buildBuiltinParticleTexture(b);if($){const z={glTex:$e.makeTextureMip(L.gl,[$],!1),width:$.width,height:$.height,rg88:!1,mips:[$],generated:!0};return xe.set(b,z),z}}return null}const P=_r.parseTex(T),C=_r.decodeMip0(P),I=P.format===8;let D=null;if(C.video!==void 0){const $=URL.createObjectURL(new Blob([C.video],{type:"video/mp4"})),z=zl($,{muted:!0,renderDpr:rr(e,n),maxW:t.clientWidth||window.innerWidth||1,maxH:t.clientHeight||window.innerHeight||1});for(const F of[z.active,z.standby])F.style.cssText="position:fixed;left:-9999px;top:-9999px;width:2px;height:2px;opacity:0;pointer-events:none",document.body.appendChild(F),(e.videoTextures??=[]).push(F);(e.objectUrls??=[]).push($),(e.videoPairs??=[]).push(z),z.active.addEventListener("loadedmetadata",()=>{se(e,n,`video tex '${b}': ${z.active.videoWidth}x${z.active.videoHeight}`)}),z.active.addEventListener("error",()=>{se(e,n,`video tex '${b}' ERROR: ${z.active.error?.code}`)});const B=[],q=F=>{for(const ne of B)F.addEventListener("ended",ne)},S={play:()=>{s||z.resume()},pause:()=>z.pause(),stop:()=>{z.pause();try{z.active.currentTime=0}catch{}},isPlaying:()=>!z.active.paused&&!z.active.ended,duration:()=>Number.isFinite(z.active.duration)?z.active.duration:0,getCurrentTime:()=>z.active.currentTime||0,setCurrentTime:F=>{try{z.active.currentTime=F}catch{}},getRate:()=>z.active.playbackRate||1,setRate:F=>{z.active.playbackRate=F,z.standby.playbackRate=F},getLoop:()=>z.active.loop,setLoop:F=>{z.active.loop=F,z.standby.loop=F},addEndedCallback:F=>{B.push(F),z.active.addEventListener("ended",F)}},E={get video(){return z.active},glTex:$e.makeTexture(L.gl,new Uint8Array([0,0,0,0]),1,1),width:C.width,height:C.height,rg88:!1,lastUploaded:-1,videoCtl:S};let k=0;return z.onSwap=F=>{E.lastUploaded=-1,q(F),k++,(k===1||k===10||k===100)&&se(e,n,`video tex '${b}' loop swap ok x${k}`)},z.onFallback=()=>{se(e,n,`video tex '${b}' loop fallback (native loop used)`)},xe.set(b,E),E}else if(C.png!==void 0||C.image!==void 0&&C.fif===_r.FIF.JPEG){const $=new Blob([C.png||C.image],{type:C.png?"image/png":"image/jpeg"}),z=await createImageBitmap($);D={glTex:$e.makeTexture(L.gl,null,0,0,z),width:z.width,height:z.height,rg88:I}}else{if(C.image!==void 0)return null;{const $=_r.decodeMip0(P);D={glTex:$e.makeTextureMip(L.gl,[$],I),width:$.width,height:$.height,rg88:I,mips:[$]}}}if(!D)return null;if(P.frames?.list?.length){const $=P.frames.list;$.atlasWidth=D.width,$.atlasHeight=D.height,D.frames=$}return xe.set(b,D),D},Vt=b=>{if(xe.has(b))return Promise.resolve(xe.get(b));const T=zt.get(b);if(T)return T;const P=Er(b);return zt.set(b,P),P.finally(()=>{zt.get(b)===P&&zt.delete(b)}),P},Mn=/uniform\s+sampler2D\s+g_Texture\d+\s*;\s*\/\/[^\n]*"default"\s*:\s*"([^"]+)"/g,Me=async b=>{for(const T of b.materialPasses||[])if(T.shader)for(const P of["frag","vert"]){const C=Ge.getEntry(x,`shaders/${T.shader}.${P}`);if(!C)continue;const I=xt(C);Mn.lastIndex=0;let D;for(;(D=Mn.exec(I))!==null;){const $=D[1];!$||$.startsWith("util/")||$.startsWith("_rt_")||xe.has($)||await Vt($)}}};let _n=0;const Wt=[];for(let b=0;b<g.layers.length;b++){const T=g.layers[b];if(T.image)try{let P;if(kt.BUILTIN_MODELS[T.image])P=kt.BUILTIN_MODELS[T.image];else{const E=Ge.getEntry(x,T.image);if(!E)continue;P=JSON.parse(xt(E))}Ke.applySolidFromModel(T,P);const C=T.srcObject?.instance?.usertextures,I=C?.[0]&&typeof C[0].name=="string"&&C[0].name.startsWith("$")?C[0].name:null,D=I&&xe.has(I)?I:null;if(D&&(T.textureName=D,T.solid=!1),P&&typeof P=="object"&&"width"in P&&"height"in P){const E=P;(T.size?.[0]||0)===0&&(T.size?.[1]||0)===0&&E.width>0&&E.height>0&&(T.size=[E.width,E.height])}const $=Ke.resolveMaterial(P);if(!$)continue;let z;if(kt.BUILTIN_MATERIALS[$.materialPath])z=kt.BUILTIN_MATERIALS[$.materialPath];else{const E=Ge.getEntry(x,$.materialPath);if(E)z=JSON.parse(xt(E));else if(T.solid&&kt.BUILTIN_MATERIALS["materials/util/solidlayer.json"])z=kt.BUILTIN_MATERIALS["materials/util/solidlayer.json"];else continue}const B=z.passes?.[0],q=B?.textures||[],S=q[0];if(B?.combos){for(const E of Object.keys(B.combos))if(E.toLowerCase()==="spritesheet"&&Number(B.combos[E])===1){T.spriteSheet=!0;break}}for(let E=0;E<q.length;E++){const k=q[E];typeof k!="string"||!k||k.startsWith("util/")||k.startsWith("_rt_")||Wt.push(Vt(k).then(F=>{F&&E===0&&!D&&(T.textureName=k,_n++,F.videoCtl&&(T.videoCtl=F.videoCtl))}))}B?.shader&&Ge.getEntry(x,`shaders/${B.shader}.frag`)&&kt.attachLayerMaterialEffect(T,B);for(const E of T.effects||[])kt.resolveEffectChain(x,E,xt);for(const E of T.effects||[]){for(const k of E.passes||[])for(const F of k.textures||[])typeof F=="string"&&F!==""&&!F.startsWith("util/")&&!F.startsWith("_rt_")&&Wt.push(Vt(F));Wt.push(Me(E))}}catch(P){console.warn(`\u56FE\u5C42 ${T.name||b} \u52A0\u8F7D\u5931\u8D25: ${P.message}`)}}if(!fs){for(const b of g.layers)if(!(!b.isText||!(b.effects||[]).length))try{for(const T of b.effects||[])kt.resolveEffectChain(x,T,xt);for(const T of b.effects||[])for(const P of T.passes||[])for(const C of P.textures||[])typeof C=="string"&&C!==""&&!C.startsWith("util/")&&!C.startsWith("_rt_")&&Wt.push(Vt(C))}catch(T){console.warn(`\u6587\u5B57\u5C42\u6548\u679C ${b.name} \u89E3\u6790\u5931\u8D25: ${T.message}`)}}await Promise.all(Wt);for(const[b,T]of xe){if(!T?.videoCtl)continue;g.layers.some(C=>C.textureName===b&&C.visible&&!C.destroyed)&&!e.paused&&T.videoCtl.play()}const Je=[],An=[],Ht=new Map;let Qn=0;const Jn=async b=>{const T=await Vt(b);if(T)return T;const P=an.buildBuiltinParticleTexture(b);if(!P)return null;const C={glTex:$e.makeTextureMip(L.gl,[P],!1),width:P.width,height:P.height,rg88:!1,mips:[P],generated:!0,frames:an.builtinParticleFrames(b)??void 0};return xe.set(b,C),Qn++,C},Pr=b=>{if(!b)return null;const T=b.mips&&b.mips[0];if(T?.rgba&&typeof an.prepareParticleNormalTexture=="function"){const P=an.prepareParticleNormalTexture(T);if(P&&P!==T)return{glTex:$e.makeTextureMip(L.gl,[P],!1),width:P.width,height:P.height,rg88:!1,mips:[P],generated:!0}}return b},er=async(b,T,P,C)=>{if(C>3)return null;const I=Ge.getEntry(x,b);if(!I)return se(e,n,`particle '${b}' \u4E0D\u5728 pkg\uFF0C\u8DF3\u8FC7`),null;const D=JSON.parse(xt(I)),$=new Tl.ParticleSystem(L.gl,D,P,T);let z=null,B=null;if(D.material){const k=Ge.getEntry(x,D.material);if(k){const F=JSON.parse(xt(k));$.setMaterial(F);const ne=F?.passes?.[0]?.textures||[];z=ne[0]||null,B=ne[1]||null}}const q=await Jn(z||"particle/halo");if(!q)return se(e,n,`particle '${b}' \u65E0\u8D34\u56FE\u53EF\u7528\uFF0C\u8DF3\u8FC7`),null;$.setTexture({glTex:q.glTex,width:q.width,height:q.height,frames:q.frames});const S=B||($.refract?an.particleNormalNameForAlbedo(z||"particle/halo"):null);if(S){const k=Pr(await Jn(S));k&&$.setNormalTexture({glTex:k.glTex,width:k.width,height:k.height})}$.setVisible(!!T.visible),Je.push($);const E=T.id;if(E!==void 0){let k=Ht.get(E);k||(k=[],Ht.set(E,k)),k.push($)}for(const k of D.children||[]){if(!k||typeof k.name!="string")continue;const F=String(k.origin??"0 0 0").trim().split(/\s+/).map(Number),ne=String(k.scale??"1 1 1").trim().split(/\s+/).map(Number),Q=String(k.angles??"0 0 0").trim().split(/\s+/).map(Number),ce=k.type==="eventfollow"?"particle":!k.type||k.type==="static"?"origin":null,ue=$.localToWorld(F[0]||0,F[1]||0),me={...T,origin:[ue[0],ue[1],(T.origin?.[2]||0)+(F[2]||0)],scale:[(T.scale?.[0]??1)*(ne[0]||1),(T.scale?.[1]??1)*(ne[1]||1),(T.scale?.[2]??1)*(ne[2]||1)],angles:[(T.angles?.[0]||0)+(Q[0]||0),(T.angles?.[1]||0)+(Q[1]||0),(T.angles?.[2]||0)+(Q[2]||0)]},Ie=await er(k.name,me,k.instanceoverride||P,C+1);Ie&&ce&&Ie.attachFollow($,ce,[F[0]||0,F[1]||0,F[2]||0])}return $};if(!Vl){for(const b of g.layers)if(b.particle)try{await er(b.particle,b,b.instanceoverride,0)}catch(T){console.warn(`\u7C92\u5B50\u56FE\u5C42 ${b.name} \u52A0\u8F7D\u5931\u8D25: ${T.message}`),se(e,n,`particle '${b.name}' FAIL: ${T.message.slice(0,80)}`)}}if(Je.length>0){const b=u;u=()=>{b?.();for(const T of Je)T.dispose()}}const Xt=[];for(const b of g.layers)if(!(!b.sound||!b.sound.length))try{for(const T of b.sound){const P=Ge.getEntry(x,T);if(!P)continue;const C=(T.split(".").pop()||"").toLowerCase(),I=C==="mp3"?"audio/mpeg":C==="ogg"?"audio/ogg":C==="flac"?"audio/flac":"audio/wav",D=new Blob([P],{type:I}),$=URL.createObjectURL(D);(e.objectUrls??=[]).push($);const z=document.createElement("audio");z.src=$,z.loop=b.soundprops?.playbackmode==="loop",z.volume=Math.max(0,Math.min(1,b.soundprops?.volume??1)),z.muted=n.muted!==!1,b.soundCtl={play(){if(z.ended)try{z.currentTime=0}catch{}z.play().catch(()=>{})},pause(){z.pause()},stop(){z.pause();try{z.currentTime=0}catch{}},isPlaying:()=>!z.paused&&!z.ended,getVolume:()=>z.volume,setVolume:B=>{z.volume=Math.max(0,Math.min(1,B))}},!b.soundprops?.startsilent&&!e.paused&&z.play().catch(()=>{}),Xt.push(z);break}}catch(T){console.warn(`\u58F0\u97F3\u56FE\u5C42 ${b.name} \u52A0\u8F7D\u5931\u8D25: ${T.message}`)}const Cr=b=>{for(const T of Xt)T.volume=Math.max(0,Math.min(1,b)),T.muted=b<=0};if(e.sceneAudio={setVolume:Cr,audios:Xt},s)return;let un=performance.now(),tn=0;L.setParticleRenderer(()=>{const b=performance.now(),T=Math.min(.05,(b-un)/1e3);if(un=b,Ae.state.has){const{wx:P,wy:C,originY:I}=Ae.state,D=I??C;for(const $ of Je)$.setPointer(P,D)}if(An.length)for(const P of An)P.syncLayerTransform();for(const P of Je)P.advance(T,te.enabled?Ye():null);if(tn<2&&(tn++,tn===2)){const P=Je.reduce((C,I)=>C+I.liveCount(),0);se(e,n,`particles live: ${P} across ${Je.length} systems`)}},(b,T,P,C,I)=>{if(b===void 0)return;const D=Ht.get(b);if(D)for(const $ of D)$.render(P,C,I,T.projW,T.projH)}),se(e,n,`particles: ${Je.length} systems, ${Qn} builtin tex generated`),window.__particleStats=()=>Je.map(b=>{let T=0,P=1/0,C=-1/0,I=1/0,D=-1/0,$=1/0,z=-1/0;for(const B of b.pool){if(!B.alive)continue;T++;const q=b.originX+B.x*b.scaleX,S=b.originY+B.y*b.scaleY;q<P&&(P=q),q>C&&(C=q),S<I&&(I=S),S>D&&(D=S);const E=Math.abs(B.size)*b.sysScale;E<$&&($=E),E>z&&(z=E)}return{live:T,max:b.maxCount,blend:b.blend,renderer:b.renderers.map(B=>B.kind).join("+"),origin:[Math.round(b.originX),Math.round(b.originY)],bbox:T?[Math.round(P),Math.round(I),Math.round(C),Math.round(D)]:null,size:T?[Math.round($),Math.round(z)]:null}}),window.__particleToggle=(b,T)=>{for(let P=0;P<Je.length;P++)Je[P].setVisible(T===void 0?b:P===T);return Je.length};const ot=[],dt=new Map,Te=b=>{if(!b||!b.puppet)return null;let T=dt.get(b);return T||(T=new Map,dt.set(b,T)),T};for(const b of g.layers)if(b.image)try{if(kt.BUILTIN_MODELS[b.image])continue;const T=Ge.getEntry(x,b.image);if(!T)continue;const P=JSON.parse(xt(T));if(!P.puppet)continue;const C=Ge.getEntry(x,P.puppet);if(!C)continue;const I=Zn.parseMDL(new Uint8Array(C)),D=b.textureName?xe.get(b.textureName):null;if(!D){se(e,n,`puppet '${b.name}' \u65E0\u8D34\u56FE\uFF0C\u8DF3\u8FC7`);continue}b.puppet=I,ot.push({mdl:I,tex:D,layer:b});const $=I.animations[0];se(e,n,`puppet '${b.name}' v=${I.vertexCount} bones=${I.bones.length}`+($?` anim='${$.name}' ${$.fps}fps\xD7${$.frameCount}`:" \u65E0\u52A8\u753B"))}catch(T){console.warn(`puppet \u56FE\u5C42 ${b.name} \u52A0\u8F7D\u5931\u8D25: ${T.message}`),se(e,n,`puppet '${b.name}' \u5931\u8D25: ${T.message}`)}for(const b of g.layers)if(b.model&&!b.puppet)try{const T=Ge.getEntry(x,b.model);if(!T)continue;const P=Zn.parseMDL(new Uint8Array(T));let C=null;if(P.materialPath){const D=Ge.getEntry(x,P.materialPath);if(D){const z=JSON.parse(xt(D))?.passes?.[0]?.textures?.[0];typeof z=="string"&&z&&(C=z)}}C&&(await Vt(C),b.textureName=C);const I=C?xe.get(C):null;if(!I){se(e,n,`model '${b.name}' \u65E0\u8D34\u56FE\uFF0C\u8DF3\u8FC7`);continue}b.puppet=P,ot.push({mdl:P,tex:I,layer:b}),se(e,n,`model '${b.name}' v=${P.vertexCount} static ${P.materialPath||""}`)}catch(T){console.warn(`model \u56FE\u5C42 ${b.name} \u52A0\u8F7D\u5931\u8D25: ${T.message}`),se(e,n,`model '${b.name}' \u5931\u8D25: ${T.message}`)}let pt=null;if(ot.length>0)try{pt=Zn.createMDLRenderer(L.gl);for(const T of ot)pt.upload(T.mdl);const b=new Map;for(const T of ot)b.set(T.layer,T);L.setPuppetRenderer((T,P,C)=>{const I=b.get(T);I&&pt.draw(P,I.mdl,{time:C.time,animLayers:T.animationLayers,boneOverrides:dt.get(T),overrideTex:C.overrideTex||null,color:[T.color[0]*T.brightness,T.color[1]*T.brightness,T.color[2]*T.brightness,T.alpha]},I.tex)})}catch(b){console.warn(`puppet \u6E32\u67D3\u5668\u521D\u59CB\u5316\u5931\u8D25: ${b.message}`),se(e,n,`puppet renderer \u5931\u8D25: ${b.message}`),pt=null;for(const T of ot)T.layer.puppet=null}if(s)return;se(e,n,`puppet: ${ot.length} meshes`);const Gt=Zn.applyAttachmentBindOrigins(g.layers);Gt.length&&se(e,n,`attachments: ${Gt.length} hanging layers`);const it=Ke.collectTransformDirty(g.layers,Gt.map(b=>b.layer));if(it.size){se(e,n,`transform graph: ${it.size} live layers`);for(const[b,T]of Ht)if(it.has(b))for(const P of T)An.push(P)}const ht=[],At=new Map,Nt={};let Tt=null,Tn=null,Sn=0;if(!fs&&g.layers.some(b=>b.isText)){const b=g.general?.orthogonalprojection,T=b?.width||t.width,P=b?.height||t.height,C=Vr(pn(e.cfg.fit),T,P,t.width,t.height),I=Math.min(3,Math.max(.5,t.width/Math.max(1,C.viewW))),D=new Map,$=[],z=new Set;for(const S of g.layers)S.isText&&S.textFont&&z.add(S.textFont);for(const S of x.entries||[])typeof S.name=="string"&&/^fonts\/.+\.(ttf|otf|woff2?)$/i.test(S.name)&&z.add(S.name);for(const S of z){const E=`${n.src}|${S}`,k=Tr.get(E);if(k){k.refs++,$.push(E),D.set(S,k.family);continue}const F=tu[S.toLowerCase()];if(F){D.set(S,F);continue}try{const ne=Ge.getEntry(x,S);if(!ne)continue;const Q=eu(ne instanceof Uint8Array?ne:new Uint8Array(ne)),ce="wefont_"+nu(E)+"_"+S.split("/").pop().replace(/[^a-zA-Z0-9]/g,"_"),ue=URL.createObjectURL(new Blob([Q])),me=new FontFace(ce,`url(${ue})`);if(await me.load(),s){URL.revokeObjectURL(ue);break}document.fonts.add(me),(e.objectUrls??=[]).push(ue),D.set(S,ce),Tr.set(E,{family:ce,refs:1}),$.push(E)}catch(ne){console.warn(`\u5B57\u4F53\u52A0\u8F7D\u5931\u8D25 ${S}: ${ne.message}`)}}if($.length){const S=e.sceneCleanup;e.sceneCleanup=()=>{ru($),S?.()}}Tt=document.createElement("canvas"),Tn=Tt.getContext("2d");const B=2048;for(const S of g.layers)if(S.isText)try{const E={layer:S,sandbox:null,texName:"__wstext_"+S.id,entry:null,lastKey:null,quality:I};if(S.textScript&&(E.sandbox=tt.evalTextScript(S.textScript,S.textScriptProps,{text:S.text??"",font:S.textFont||"",pointsize:S.textPointsize,color:S.textColor,angles:S.angles,origin:S.origin,scale:S.scale,visible:S.visible,canvasSize:{width:T,height:P},userProperties:v,shared:Nt,audioViews:Ve,inputView:nt,...Ft,mediaControl:Be,windowTitle:Z.snapshot,openUserShortcut:Ne.openUserShortcut,getLayerText:Q=>At.get(Q),onError:Q=>{se(e,n,`text script '${S.name}' \u5931\u8D25: ${String(Q.message||Q).slice(0,120)}`)}}),E.sandbox&&(_.push(E.sandbox),E.sandbox.init(),E.sandbox.applyUserProperties(v),E.sandbox.hasMediaHook&&De(E.sandbox))),At.set(S.name||"",String(S.text??"")),S.textAnchor!=="center"&&S.size[0]>0&&S.size[1]>0){const Q=S.size[0]*(S.scale[0]||1)/2,ce=S.size[1]*(S.scale[1]||1)/2,ue=S.textAnchor;let me=0,Ie=0;ue.includes("left")&&(me+=Q),ue.includes("right")&&(me-=Q),ue.includes("top")&&(Ie-=ce),ue.includes("bottom")&&(Ie+=ce),S.origin[0]+=me,S.origin[1]+=Ie,S.localOrigin&&(S.localOrigin[0]+=me,S.localOrigin[1]+=Ie)}const k=ds*Math.max(1,S.textPointsize),F=tt.textLayerHasTintMask(S)?8:256,ne=Math.min(F,tt.textCanvasMargin(k,0));E.boxW=S.size[0]>0?S.size[0]:k*4,E.boxH=S.size[1]>0?S.size[1]:k*1.6,E.margin=ne,S.size=[E.boxW+ne*2,E.boxH+ne*2],E.entry={glTex:$e.makeTexture(L.gl,new Uint8Array([0,0,0,0]),1,1),width:1,height:1,rg88:!1},xe.set(E.texName,E.entry),S.textureName=E.texName,S.solid=!1,ht.push(E)}catch(E){console.warn(`\u6587\u5B57\u5BF9\u8C61 ${S.name} \u521D\u59CB\u5316\u5931\u8D25: ${E.message}`)}if(ht.length>0){const S=u;u=()=>{S?.();for(const E of ht)L.gl.deleteTexture(E.entry.glTex)}}const q=S=>{if(!Tn||!Tt)return;const E=Tn;for(const k of ht){const F=k.layer;let ne=String(F.text??"");if(k.sandbox&&k.sandbox.hasUpdate){k.sandbox.engine.runtime=S;const me=k.sandbox.callUpdate(ne);me!=null?ne=String(me):k.sandbox.thisLayer.text&&(ne=String(k.sandbox.thisLayer.text))}else k.sandbox&&typeof k.sandbox.thisLayer?.text=="string"&&(ne=String(k.sandbox.thisLayer.text));if(At.set(F.name||"",ne),!F.visible)continue;const Q=Math.max(1,k.sandbox?k.sandbox.thisLayer.pointsize:F.textPointsize),ce=k.sandbox&&k.sandbox.thisLayer.font||F.textFont||"",ue=`${ne}\0${Q}\0${ce}\0${F.alpha}\0${F.textCastshadow}`;if(k.lastKey!==ue){k.lastKey=ue;try{const me=ds*Q,Ie=k.boxW,bt=k.boxH,Et=k.margin,yt=Math.abs(F.scale[0]||1),de=Math.abs(F.scale[1]||1);let pe=Math.max(1,Math.round(F.size[0]*yt*k.quality)),fe=Math.max(1,Math.round(F.size[1]*de*k.quality));const Ee=Math.min(1,B/Math.max(pe,fe));pe=Math.max(1,Math.round(pe*Ee)),fe=Math.max(1,Math.round(fe*Ee)),Tt.width!==pe||Tt.height!==fe?(Tt.width=pe,Tt.height=fe):(E.setTransform(1,0,0,1,0,0),E.clearRect(0,0,pe,fe));const st=Math.min(pe/F.size[0],fe/F.size[1]);E.setTransform(st,0,0,st,0,0),E.translate(Et,Et);const at=ce&&D.get(ce)||"sans-serif";E.font=`${me}px "${at}", sans-serif`;const vt=E.measureText(""),et=(vt.fontBoundingBoxAscent||0)+(vt.fontBoundingBoxDescent||0),Ce=F.textSpacing||[0,0],dn=tt.layoutText(ne,{boxW:Ie,boxH:bt,pointsize:me,lineHeight:(et>0?et:me*1.25)+Ce[1],spacing:Ce,padding:F.textPadding||0,maxwidth:F.textMaxwidth||0,limitwidth:!!F.textLimitwidth,maxrows:F.textMaxrows||0,limitrows:!!F.textLimitrows,limituseellipsis:!!F.textLimituseellipsis,halign:F.textHAlign,valign:F.textVAlign},We=>E.measureText(We).width);tt.drawTextLayer(E,dn,{font:E.font,color:F.textColor,alpha:F.alpha,brightness:F.brightness,spacing:Ce,pointsize:me,opaquebackground:!!F.textOpaquebackground,backgroundcolor:F.textBackgroundcolor,backgroundbrightness:F.textBackgroundbrightness,castshadow:!!F.textCastshadow});const ct=k.entry;L.gl.bindTexture(L.gl.TEXTURE_2D,ct.glTex),L.gl.texImage2D(L.gl.TEXTURE_2D,0,L.gl.RGBA,L.gl.RGBA,L.gl.UNSIGNED_BYTE,Tt),ct.width=pe,ct.height=fe}catch(me){console.warn(`\u6587\u5B57\u5BF9\u8C61 ${F.name} \u7ED8\u5236\u5931\u8D25: ${me.message}`),k.lastKey=null}}}};e.sceneTextUpdate=q,window.__textWidgets=ht,se(e,n,`text widgets: ${ht.length} (scripts ${ht.filter(S=>S.sandbox).length}, fonts ${D.size}, quality ${I.toFixed(2)})`)}if(s)return;const Ut=[],En=[],Dt=[],nn={},je=[],mt=[],gt=new Map,fn=(b,T)=>{if(!T||typeof T.callCursor!="function"||!T.hasCursorHook)return;const P=gt.get(b);P?P.push(T):gt.set(b,[T])};for(const b of ht)b.sandbox&&fn(b.layer,b.sandbox);{const b=g.general?.orthogonalprojection,T=b?.width||t.width,P=b?.height||t.height,C=v,I=(E,k)=>{const F=g.general||{};if(E==="zoom"&&typeof k=="number"&&Number.isFinite(k)&&k>0){g.cameraTransforms.zoom=k,F.zoom&&typeof F.zoom=="object"?F.zoom.value=k:F.zoom=k;return}F[E]&&typeof F[E]=="object"&&"value"in F[E]?F[E].value=k:F[E]=k};let D=1+Math.max(0,...g.layers.map(E=>Number(E.id)||0));const $={recomputeVisibility:A,getSceneLayer:E=>g.layers.find(k=>k.name===E&&!k.destroyed)||null,getSceneLayerById:E=>g.layers.find(k=>k.id===E&&!k.destroyed)||null,enumerateSceneLayers:()=>g.layers.filter(E=>!E.destroyed),getSceneAnimation:E=>{if(E==null||E==="")return null;if(nn[E])return nn[E];for(const k of g.layers)if(k.animations&&k.animations[E])return k.animations[E];return null},cameraTransforms:g.cameraTransforms,getInitialLayerConfig:E=>{const k=E&&typeof E=="object"?E.name:String(E||"");return g.layers.find(F=>F.name===k)||null},createSceneLayer:E=>{let k=E&&typeof E=="object"?E:null;if(typeof E=="string"){const ne=E;if(k=g.layers.find(Q=>Q&&!Q.destroyed&&Q.image===ne&&Q.textureName)||g.layers.find(Q=>Q&&!Q.destroyed&&Q.image===ne)||null,!k)return se(e,n,`createLayer('${ne}') \u627E\u4E0D\u5230\u5DF2\u52A0\u8F7D\u7684\u540C\u6A21\u578B\u5C42`),null}k||(k={});const F={...k,id:D++,origin:Array.isArray(k.origin)?k.origin.slice():[0,0,0],scale:Array.isArray(k.scale)?k.scale.slice():[1,1,1],angles:Array.isArray(k.angles)?k.angles.slice():[0,0,0],size:Array.isArray(k.size)?k.size.slice():[0,0],color:Array.isArray(k.color)?k.color.slice():[1,1,1],childIds:null,hasChildren:!1,destroyed:!1,animations:{},animationList:[],objectScripts:null};return delete F.textureAnimation,delete F.videoTextureApi,delete F.soundCtl,delete F.videoCtl,Array.isArray(k.effects)&&(F.effects=k.effects.map(ne=>({...ne,passes:Array.isArray(ne.passes)?ne.passes.map(Q=>({...Q})):ne.passes}))),g.layers.push(F),F},mediaControl:Be,windowTitle:Z.snapshot,openUserShortcut:Ne.openUserShortcut,isScreensaver:!1};L.setConstantScriptRuntime?.(tt.evalObjectScript,{userProperties:C,audioViews:Ve,shared:Nt,inputView:nt,timers:rt,...$,onSandbox:E=>{E&&E.hasMediaHook&&De(E)}});const z={origin:"localOrigin",scale:"localScale",angles:"localAngles"},B=(E,k)=>{const F=z[k];return F&&E&&Array.isArray(E[F])?F:k};for(const E of g.layers){const k=E.objectAnimations;if(k){E.animations=E.animations||{},E.animationList=E.animationList||[];for(const[F,ne]of Object.entries(k))try{const Q=os.createAnimation(ne.animation);Q.field=F,Q.baseValue=ne.value;const ce=B(E,F),ue=E[ce];Q.baseNumeric=Array.isArray(ue)?ue.slice():ue,Q.slot=ce,E.animationList.push(Q),Q.name&&(E.animations[Q.name]=Q),En.push({layer:E,field:F,slot:ce,ctrl:Q})}catch(Q){se(e,n,`animation '${E.name}.${F}' \u5EFA\u63A7\u5236\u5668\u5931\u8D25: ${String(Q.message).slice(0,80)}`)}}}for(const E of g.layers){for(const[F,ne]of(E.effects||[]).entries()){const Q=ne.visibleScript;if(Q)try{const ce=tt.evalObjectScript(Q.script,Q.scriptproperties,{canvasSize:{width:T,height:P},userProperties:C,audioViews:Ve,inputView:nt,...Ft,layer:E,targetEffect:ne,...$,shared:Nt,onError:ue=>se(e,n,`effect visible script '${E.name}#${F}' \u5931\u8D25: ${String(ue.message||ue).slice(0,80)}`)});if(!ce)continue;_.push(ce),ce.init(ne.visible),ce.applyUserProperties(C),ce.hasMediaHook&&De(ce),ce.hasUpdate&&je.push({effect:ne,sandbox:ce})}catch(ce){console.warn(`\u6548\u679C\u5F00\u5173\u811A\u672C ${E.name}#${F} \u6C42\u503C\u5931\u8D25: ${ce.message}`)}}const k=E.objectScripts;if(k)for(const[F,ne]of Object.entries(k))try{const Q=tt.evalObjectScript(ne.script,ne.scriptproperties,{canvasSize:{width:T,height:P},screenResolution:{x:t.clientWidth||window.innerWidth||1,y:t.clientHeight||window.innerHeight||1},timeOfDay:(()=>{const ce=new Date;return(ce.getHours()*3600+ce.getMinutes()*60+ce.getSeconds())/86400})(),userProperties:C,audioViews:Ve,inputView:nt,layer:E,...$,getBoneOverrides:Te,shared:Nt,...Ft,onError:ce=>se(e,n,`object script '${E.name}.${F}' \u5931\u8D25: ${String(ce.message||ce).slice(0,90)}`)});if(Q){_.push(Q);const ce=B(E,F),ue=E[ce],me=F==="angles"&&Array.isArray(ue)?tt.radToScriptAngles(ue):Array.isArray(ue)?{x:ue[0]??0,y:ue[1]??0,z:ue[2]??0}:ue;Q.init(me),Q.applyUserProperties(C),fn(E,Q),Q.hasMediaHook&&De(Q),Q.hasUpdate&&Ut.push({layer:E,field:F,slot:ce,kind:F==="visible"?"bool":F==="alpha"||F==="brightness"?"scalar":"vec3",sandbox:Q})}}catch(Q){console.warn(`\u5BF9\u8C61\u811A\u672C ${E.name}.${F} \u6C42\u503C\u5931\u8D25: ${Q.message}`)}}const q=g.generalScripts;if(q){for(const[E,k]of Object.entries(q))try{const F=tt.evalObjectScript(k.script,k.scriptproperties,{canvasSize:{width:T,height:P},userProperties:C,audioViews:Ve,inputView:nt,...Ft,...$,shared:Nt,onError:Q=>se(e,n,`general script '${E}' \u5931\u8D25: ${String(Q.message||Q).slice(0,80)}`)});if(!F)continue;_.push(F),F.init(k.value),F.applyUserProperties(C),F.hasMediaHook&&De(F);const ne=Q=>I(E,Q);F.hasUpdate&&mt.push({field:E,sandbox:F,write:ne})}catch(F){console.warn(`general \u811A\u672C ${E} \u6C42\u503C\u5931\u8D25: ${F.message}`)}mt.length&&se(e,n,`general scripts: ${mt.map(E=>E.field).join(",")}`)}const S=g.generalAnimations;if(S){for(const[E,k]of Object.entries(S))try{const F=os.createAnimation(k.animation);F.field=E,F.baseValue=k.value,F.baseNumeric=k.value,F.name&&(nn[F.name]=F),Dt.push({field:E,ctrl:F,write:ne=>I(E,ne)})}catch(F){se(e,n,`general animation '${E}' \u5EFA\u63A7\u5236\u5668\u5931\u8D25: ${String(F.message).slice(0,80)}`)}Dt.length&&se(e,n,`general animations: ${Dt.map(E=>E.field).join(",")}`)}}Ut.length&&(se(e,n,`object scripts: ${Ut.length}`),window.__objScripts=Ut),window.__mediaHooks=Ue,window.__sceneLayers=g.layers,window.__compositeStats=()=>L.compositeStats?.()??null,window.__compositeEnable=b=>L.setCompositeEnabled?.(b),window.__scene=g,window.__textures=xe;const Pn=Array.from(gt.keys());Pn.length&&se(e,n,`cursor hooks: ${Pn.length} layers`);let rn=null,ut=null,Cn=!1;const tr=()=>({worldPosition:tt.makeCursorEventVec(Ae.state.wx,Ae.state.originY!=null?Ae.state.originY:Ae.state.wy,0)}),Bt=(b,T,P)=>{const C=gt.get(b);if(C)for(const I of C)I.callCursor(T,P)},Lr=()=>{if(Pn.length===0)return;const b=Ae.state;if(!b.has)return;const T=L.getParallaxOffset?L.getParallaxOffset():{x:0,y:0},P=g.general?.orthogonalprojection?.height||t.height,C=Pl.hitTestLayers(g.layers,b.wx,b.wy,P,{parOffX:T.x,parOffY:T.y,alignTable:$e.ALIGN,filter:D=>gt.has(D)}),I=tr();C!==rn&&(rn&&Bt(rn,"cursorLeave",I),rn=C,C&&Bt(C,"cursorEnter",I)),C&&Bt(C,"cursorMove",I),b.leftDown&&!Cn?(ut=C,C&&Bt(C,"cursorDown",I)):!b.leftDown&&Cn&&(ut&&Bt(ut,"cursorUp",I),ut&&ut===C&&Bt(C,"cursorClick",I),ut=null),Cn=b.leftDown},Rr=performance.now();let nr=0,St=0;const w=[],U=[];let G=-1/0,V=0;const Y=b=>{if(s||e.paused)return;const P=1e3/(e.cfg.sceneFps||60);if(b-G>=P){G=b,Fn(e,b),So(e,t,e.cfg);const C=(b-Rr-nr)/1e3;if(nt.update(Ae.state),qe.enabled){if(O?.media)O.media.pump();else{const S=J();typeof S?.update=="function"&&S.update(C)}const B=he(),q=we.diffMediaEvents(ye,B);if(q.length){for(const{name:S,event:E}of q)for(const k of Ue)k.disabled||k.callMedia(S,E);ye=we.cloneMediaSnapshot(B)}}O?.windowTitle?O.windowTitle.pump():K.update(C);const I=Math.max(0,C-V);V=C;for(const B of En){B.ctrl.advance(I);const q=B.field,S=B.slot||q,E=B.ctrl.applyTo(B.ctrl.baseNumeric);if(Array.isArray(E)){const k=B.layer[S];if(Array.isArray(k))for(let F=0;F<E.length&&F<k.length;F++)k[F]=E[F]}else Number.isFinite(E)&&(q==="visible"?B.layer[q]=!!E:B.layer[S]=E)}for(const B of Dt){B.ctrl.advance(I);const q=B.ctrl.applyTo(B.ctrl.baseNumeric);typeof q=="number"&&Number.isFinite(q)?B.write(q):Array.isArray(q)&&Number.isFinite(q[0])&&B.write(q[0])}for(const B of je){if(B.sandbox.disabled)continue;B.sandbox.engine.frametime=I,B.sandbox.engine.runtime=C;const q=B.sandbox.callUpdate(!!B.effect.visible);typeof q=="boolean"&&(B.effect.visible=q)}for(const B of mt){if(B.sandbox.disabled)continue;B.sandbox.engine.frametime=I,B.sandbox.engine.runtime=C;const q=g.general||{},S=q[B.field]&&typeof q[B.field]=="object"&&"value"in q[B.field]?q[B.field].value:q[B.field],E=B.sandbox.callUpdate(S);E!==void 0&&B.write(E)}const D={x:t.clientWidth||window.innerWidth||1,y:t.clientHeight||window.innerHeight||1};for(const B of _)!B||B.disabled||(B.engine.frametime=I,B.engine.runtime=C,B.engine.screenResolution=D);let $=!1;for(const B of Ut){if(B.sandbox.disabled)continue;B.sandbox.engine.frametime=I,B.sandbox.engine.runtime=C,B.sandbox.engine.screenResolution=D;const q=B.layer[B.field];if(B.kind==="bool"){const S=B.sandbox.callUpdate(!!q);typeof S=="boolean"&&(B.field==="visible"?B.layer.visibleSelf!==S&&(B.layer.visibleSelf=S,$=!0):B.layer[B.field]=S)}else if(B.kind==="scalar"){const S=B.sandbox.callUpdate(Number(q)||0),E=Number(S);Number.isFinite(E)&&(B.layer[B.field]=E)}else{const S=B.slot||B.field,E=B.layer[S],k=B.field==="angles"?tt.radToScriptAngles(E):{x:E[0]||0,y:E[1]||0,z:E[2]||0},F=B.sandbox.callUpdate(k),ne=F&&typeof F=="object"&&"x"in F?F:k;B.layer[S]=B.field==="angles"?tt.scriptAnglesToRad(ne):[ne.x||0,ne.y||0,ne.z||0]}}$&&A(),it.size&&Ke.recomposeWorld(g.layers,it),te.enabled&&(_e.pump(),_e.active||(X.current?X.current.pump():j.update(C)),fl(Ve,Ye())),Gt.length&&Zn.followAttachments(Gt,C,Te);const z=e.coverAlign;L.render(g,xe,t.width,t.height,C,pn(e.cfg.fit),z.x,z.y).then(()=>{if(e.onFirstFrame){const B=e.onFirstFrame;e.onFirstFrame=void 0;try{B()}catch{}}if(!(s||e.paused)){try{Lr()}catch{}Ae.beginFrame();try{e.sceneTextUpdate&&b>=Sn&&(Sn=b+100,e.sceneTextUpdate(C))}catch{}e.raf=requestAnimationFrame(Y)}}).catch(B=>{console.warn("scene render error:",B),se(e,n,`render: ${String(B.message||B).slice(0,200)}`),s=!0})}else e.paused||(e.raf=requestAnimationFrame(Y))},ee=()=>{s||e.paused||e.raf===void 0&&(e.raf=requestAnimationFrame(Y))},oe=b=>{if(s)return;const T=g.properties||{},P=oa(T,v,b);if(Object.keys(P).length){for(const C of g.layers){const I=C.srcObject;if(!I)continue;hn(I,T,0);const D=Ct(I.visible);D&&D in P&&(C.visibleSelf=Ke.parseBool(I.visible,!0));const $=Ct(I.color);$&&$ in P&&(C.color=Ke.parseColor(I.color),C.isText&&(C.textColor=C.color));const z=Ct(I.alpha);z&&z in P&&(C.alpha=Ke.parseNum(I.alpha,1));const B=Ct(I.brightness);B&&B in P&&(C.brightness=Ke.parseNum(I.brightness,1));const q=Ct(I.volume);if(q&&q in P){const E=Ke.parseNum(I.volume,1);C.soundprops&&(C.soundprops.volume=E),C.soundCtl?.setVolume?.(E)}for(let E=0;E<(I.animationlayers||[]).length;E++){const k=I.animationlayers[E],F=C.animationLayers?.[E];if(!k||!F)continue;const ne=Ct(k.visible);ne&&ne in P&&(F.visible=Ke.parseBool(k.visible,!0));const Q=Ct(k.rate);Q&&Q in P&&(F.rate=Ke.parseNum(k.rate,1));const ce=Ct(k.blend);ce&&ce in P&&(F.blend=Ke.parseNum(k.blend,1))}for(let E=0;E<(I.effects||[]).length;E++){const k=I.effects[E],F=C.effects?.[E];if(!k||!F)continue;const ne=Ct(k.visible);ne&&ne in P&&!F.visibleScript&&(F.visible=Ke.parseBool(k.visible,!0))}const S=I.instanceoverride;if(S&&typeof S=="object"&&C.particle){let E=!1;for(const k of Object.keys(S)){if(k==="id")continue;const F=Ct(S[k]);if(F&&F in P){E=!0;break}}if(E){const k=Ht.get(C.id);if(k)for(const F of k)F.reapplyOverride?.()}}}for(const C of _)if(!(!C||C.disabled))try{C.applyUserProperties(P)}catch{}A();for(const C of g.layers){if(!C.particle)continue;const I=Ht.get(C.id);if(I)for(const D of I)D.setVisible(!!C.visible)}L.applyConstUserProperties?.(P);for(const C of ht)C.lastKey=null;se(e,n,`props hot: ${Object.keys(P).join(",")}`)}};p=()=>{e.raf!==void 0&&(cancelAnimationFrame(e.raf),e.raf=void 0),St||(St=performance.now()),w.length=0;for(const b of xe.values())b?.videoCtl?.isPlaying?.()&&(w.push(b.videoCtl),b.videoCtl.pause());U.length=0;for(const b of Xt)!b.paused&&!b.ended&&(U.push(b),b.pause())},d=()=>{St&&(nr+=performance.now()-St,St=0),un=performance.now();for(const b of w)try{b.play()}catch{}w.length=0;for(const b of U)b.play().catch(()=>{});U.length=0,ee()},f=oe,l&&(oe(l),l=null),ee();{const b=g.general?.orthogonalprojection,T=b?.width||t.width,P=b?.height||t.height,C=pn(e.cfg.fit),I=Vr(C,T,P,t.width,t.height);se(e,n,`fit ${C}: view ${Math.round(I.viewW)}x${Math.round(I.viewH)} scene ${T}x${P} canvas ${t.width}x${t.height}`)}se(e,n,`renderer started: ${g.layers.length} layers`)}catch(y){if(s||y&&y.name==="AbortError")return;console.warn("scene render failed:",y);const x=y instanceof Error?y:new Error(String(y));se(e,n,`failed: ${String(x.message||x).slice(0,200)}`),e.onError?e.onError(x):e.fallbackPage?.()}})()}const cu='data-we-shim="1"',ms="data-we-shim-src";function lu(e){try{const n=new URL(e),t=n.pathname,r=t.lastIndexOf("/");return n.pathname=r<0?"/":t.slice(0,r+1),n.hash="",n.search="",n.href}catch{const n=e.replace(/[#?].*$/,""),t=n.lastIndexOf("/");return t<0?n:n.slice(0,t+1)}}function uu(e){const n=/<meta[^>]+http-equiv\s*=\s*["']?Content-Security-Policy["']?[^>]*>/gi;let t;for(;t=n.exec(e);){const r=t[0],o=/content\s*=\s*"([^"]*)"/i.exec(r)?.[1]??/content\s*=\s*'([^']*)'/i.exec(r)?.[1]??"";if(/script-src/i.test(o)&&!/script-src[^;]*'unsafe-inline'/i.test(o)&&!/script-src[^;]*\*/i.test(o))return!0}return!1}function gs(e){return e.replace(/<\/script/gi,"<\\/script")}function fu(e,n,t){if(e||(e=""),e.includes(cu)||e.includes(ms))return e;const r=t.baseHref&&!/<base\b/i.test(e)?`<base href="${t.baseHref.replace(/"/g,""")}">`:"",o=`<script ${ms}="1">
|
|
513
|
+
${gs(n)}
|
|
514
514
|
<\/script>`,i=t.seedScript&&t.seedScript.trim()?`<script>
|
|
515
|
-
${
|
|
516
|
-
<\/script>`:"",s=`${r}${o}${i}`,a=/<head(\s[^>]*)?>/i.exec(e);if(a){const u=a.index+a[0].length;return e.slice(0,u)+s+e.slice(u)}const c=/<html(\s[^>]*)?>/i.exec(e);if(c){const u=c.index+c[0].length;return e.slice(0,u)+`<head>${s}</head>`+e.slice(u)}return`<!DOCTYPE html><html><head>${s}</head><body>${e}</body></html>`}const
|
|
515
|
+
${gs(t.seedScript)}
|
|
516
|
+
<\/script>`:"",s=`${r}${o}${i}`,a=/<head(\s[^>]*)?>/i.exec(e);if(a){const u=a.index+a[0].length;return e.slice(0,u)+s+e.slice(u)}const c=/<html(\s[^>]*)?>/i.exec(e);if(c){const u=c.index+c[0].length;return e.slice(0,u)+`<head>${s}</head>`+e.slice(u)}return`<!DOCTYPE html><html><head>${s}</head><body>${e}</body></html>`}const du=`/**
|
|
517
517
|
* WE \u7F51\u9875\u58C1\u7EB8\u517C\u5BB9 shim\uFF08\u6CE8\u5165\u5230 iframe\uFF0C\u5FC5\u987B\u5728\u4F5C\u8005\u811A\u672C\u4E4B\u524D\u6267\u884C\uFF09\u3002
|
|
518
518
|
*
|
|
519
519
|
* \u8BED\u6599\uFF1A\u672C\u673A\u5E93 42 \u5F20 web \u58C1\u7EB8\u626B\u63CF\uFF082026-09\uFF09\u2014\u2014
|
|
@@ -1714,7 +1714,7 @@ ${as(t.seedScript)}
|
|
|
1714
1714
|
installRafThrottle();
|
|
1715
1715
|
})(window);
|
|
1716
1716
|
|
|
1717
|
-
`;function
|
|
1718
|
-
`)}function su(e,n,t){const r="position:absolute;border:none;background:transparent;",o=()=>{n.style.cssText=r+"inset:0;width:100%;height:100%;"};o();let i="";const s=()=>{if(!n.isConnected)return;let f=null;try{f=n.contentDocument}catch{return}if(!f)return;const d=t.clientWidth||window.innerWidth||0,w=t.clientHeight||window.innerHeight||0,M=hn(e.cfg.fit)==="cover";o();const m=M&&d>0&&w>0?hu(f):null,A=m?pu(d,w,m.contentAspect):null,h=A?`${Math.round(A.width)}x${Math.round(A.height)}`:"full";if(!A){i="full";return}n.style.cssText=r+`left:${A.left}px;top:${A.top}px;width:${A.width}px;height:${A.height}px;`,h!==i&&(i=h,se(e,e.cfg,`\u7F51\u9875\u58C1\u7EB8\u9732\u5E95\u81EA\u9002\u914D\uFF1A\u89C6\u53E3\u6309\u5185\u5BB9\u6BD4\u4F8B\u6539\u4E3A ${Math.round(A.width)}\xD7${Math.round(A.height)}\uFF08cover \u5C45\u4E2D\u88C1\u5207\uFF09`))},a=()=>s();window.addEventListener("resize",a);let c;typeof ResizeObserver<"u"&&(c=new ResizeObserver(()=>s()),c.observe(t));const u=[],l=()=>{s();for(const f of[120,400,1200])u.push(window.setTimeout(s,f));try{const f=n.contentDocument;if(f)for(const d of f.querySelectorAll("video,img"))d.addEventListener("loadedmetadata",s,{once:!0}),d.addEventListener("load",s,{once:!0})}catch{}};n.addEventListener("load",l),e.webRelayout=s;const p=e.sceneCleanup;e.sceneCleanup=()=>{window.removeEventListener("resize",a),c?.disconnect();for(const f of u)clearTimeout(f);n.removeEventListener("load",l),e.webRelayout===s&&(e.webRelayout=void 0);try{p?.()}catch{}}}function au(e,n,t,r,o){if(!Number.isFinite(e)||!Number.isFinite(n)||!(t.width>0)||!(t.height>0))return null;const i=r.width>0&&o.width>0?r.width/o.width:1,s=r.height>0&&o.height>0?r.height/o.height:1;return{x:(e*t.width-(r.left-t.left))/(i||1),y:(n*t.height-(r.top-t.top))/(s||1)}}function cu(e,n,t){e.pointerCtl={push(r){if(!n.isConnected)return;const o=t.getBoundingClientRect(),i=n.getBoundingClientRect(),s=au(Number(r?.u),Number(r?.v),{left:o.left,top:o.top,width:o.width||t.clientWidth||window.innerWidth||0,height:o.height||t.clientHeight||window.innerHeight||0},{left:i.left,top:i.top,width:i.width,height:i.height},{width:n.clientWidth,height:n.clientHeight});s&&Ke(e,a=>a.__wePushPointer?.(s.x,s.y,Number(r.buttons)||0))},leave(){Ke(e,r=>r.__wePointerLeave?.())}}}function mo(e,n,t,r,o){const i=document.createElement("iframe");i.setAttribute("sandbox","allow-scripts allow-same-origin"),i.style.cssText="position:absolute;inset:0;width:100%;height:100%;border:none;background:transparent;",!e.wrap&&getComputedStyle(t).position==="static"&&(t.style.position="relative"),i.src=r,t.appendChild(i),e.iframe=i,o.blobUrl&&(e.objectUrls??=[]).push(o.blobUrl),su(e,i,t),o.injected&&cu(e,i,t);const s=c=>{if(c.source!==i.contentWindow)return;const u=c.data;if(!u||u.op!=="we-frame"||e.paused)return;const l=typeof u.t=="number"?u.t:performance.now();o.frameClock&&(o.frameClock.last=l),rr(e,l)};window.addEventListener("message",s);const a=e.sceneCleanup;e.sceneCleanup=()=>{window.removeEventListener("message",s);try{a?.()}catch{}},i.addEventListener("load",()=>{try{const l=i.contentDocument;l&&window.__blockContextMenu?.(l),o.injected||Kl(e,i,l)}catch{}Ke(e,l=>{const p={};for(const[f,d]of Object.entries(e.liveUserProps??{}))p[f]={value:d};l.__weApplyProps?.(p),l.__weSetFps?.(e.cfg.sceneFps??60),l.__weSetVolume?.(e.cfg.muted===!1?1:0),e.paused&&l.__weSetPaused?.(!0)});try{e.onFirstFrame?.(),e.onFirstFrame=void 0}catch{}const c=t.clientWidth||window.innerWidth||1,u=t.clientHeight||window.innerHeight||1;try{e.onSceneInfo?.({width:c,height:u,layerCount:0,hasModels:!1,hasParticles:!1,hasText:!1})}catch{}})}const lu=.005,uu=.01,fu=.2,du=6;function pu(e,n,t){if(!(e>0)||!(n>0)||!(t>0))return null;const r=e/n;if(Math.abs(r-t)<=lu)return null;if(r<t){const i=n*t;return{width:i,height:n,left:(e-i)/2,top:0}}const o=e/t;return{width:e,height:o,left:0,top:(n-o)/2}}function hu(e){const n=e.defaultView;if(!n)return null;const t=n.innerWidth,r=n.innerHeight;if(!(t>0)||!(r>0))return null;const o=[...e.querySelectorAll("video,img")];for(const i of o){const s=i.getBoundingClientRect();if(s.width<=0||s.height<=0||s.width<t*.98||Math.abs(s.left)>t*.02||s.top>r*.02||r-s.height<r*uu)continue;const a=i.videoWidth||i.naturalWidth||0,c=i.videoHeight||i.naturalHeight||0;if(!(a>0)||!(c>0))continue;const u=a/c;if(!(!Number.isFinite(u)||u<fu||u>du))return{contentAspect:u}}return null}function an(e){if(!e)return"rgb(128,128,128)";const n=Math.round(Math.max(0,Math.min(1,Number(e.x)||0))*255),t=Math.round(Math.max(0,Math.min(1,Number(e.y)||0))*255),r=Math.round(Math.max(0,Math.min(1,Number(e.z)||0))*255);return`rgb(${n},${t},${r})`}function mu(e){try{const n=document.createElement("canvas");n.width=n.height=64;const t=n.getContext("2d");if(!t)return"";const r=e.primaryColor,o=e.secondaryColor,i=t.createLinearGradient(0,0,64,64);return i.addColorStop(0,an(r)),i.addColorStop(1,an(o)),t.fillStyle=i,t.fillRect(0,0,64,64),n.toDataURL("image/jpeg",.85)}catch{return""}}function gu(){return xe.createSimulatedMedia()}function bu(e,n,t){const r=xe.diffMediaEvents(n,t);for(const{name:o,event:i}of r)if(o==="mediaStatusChanged")Ke(e,s=>s.__wePushMedia?.({op:"status",enabled:!!i.enabled}));else if(o==="mediaPropertiesChanged")Ke(e,s=>s.__wePushMedia?.({op:"properties",title:i.title??"",artist:i.artist??"",album:i.album??"",albumArtist:i.albumArtist??""}));else if(o==="mediaThumbnailChanged"){const s=mu(t);Ke(e,a=>a.__wePushMedia?.({op:"thumbnail",thumbnail:s,hasThumbnail:!!i.hasThumbnail||!!s,primaryColor:an(i.primaryColor),secondaryColor:an(i.secondaryColor),tertiaryColor:an(i.tertiaryColor),textColor:an(i.textColor),highContrastColor:an(i.highContrastColor)}))}else o==="mediaPlaybackChanged"?Ke(e,s=>s.__wePushMedia?.({op:"playback",state:Number(i.state)||0})):o==="mediaTimelineChanged"&&Ke(e,s=>s.__wePushMedia?.({op:"timeline",position:Number(i.position)||0,duration:Number(i.duration)||0}));return xe.cloneMediaSnapshot(t)}function ls(e,n,t){if(!n)return;let r=0,o=0;const i=a=>{if(r=requestAnimationFrame(i),e.paused||!e.iframe)return;const c=e.cfg.sceneFps||60,l=1e3/Math.min(Math.max(1,c),nu);if(!(a-o<l*.85)){o=a;try{n.tick?.(a);const p=n.snapshot(),f=Jl(Ql,p.left,p.right);Ke(e,d=>d.__wePushAudio?.(f)),t&&a-t.last>200&&rr(e,a)}catch{}}};r=requestAnimationFrame(i);const s=e.sceneCleanup;e.sceneCleanup=()=>{cancelAnimationFrame(r);try{s?.()}catch{}}}function us(e,n){if(!n)return;let t=0,r=null,o=0;const i=a=>{if(t=requestAnimationFrame(i),!(e.paused||!e.iframe)&&!(a-o<200)){o=a;try{n.update(a/1e3),r=bu(e,r,n.snapshot)}catch{}}};t=requestAnimationFrame(i);const s=e.sceneCleanup;e.sceneCleanup=()=>{cancelAnimationFrame(t);try{s?.()}catch{}}}function yu(e){e.sceneCtl={pause(){e.paused=!0,Ke(e,n=>n.__weSetPaused?.(!0))},resume(){e.paused=!1,Ke(e,n=>n.__weSetPaused?.(!1))},applyUserProperties(n){const t={...e.liveUserProps??{}};for(const[r,o]of Object.entries(n??{})){const i=o&&typeof o=="object"&&"value"in o?o.value:o;t[r]=i}e.liveUserProps=t,Ke(e,r=>r.__weApplyProps?.(n))}}}function vu(e){try{return new URL(e,location.href).origin===location.origin}catch{return!1}}function xu(e){const n=e?.general?.properties;if(!n||typeof n!="object")return{};const t={};for(const[r,o]of Object.entries(n)){if(!o||typeof o!="object"||typeof o.type!="string")continue;const i=o.value,s=o.type.toLowerCase();if(i==null){if(s==="file"||s==="directory"){t[r]={value:""};continue}if(!("value"in o))continue}t[r]={value:i}}return t}async function wu(e){try{const n=new URL("project.json",new URL(e,location.href)),t=await fetch(n.href,{credentials:"same-origin"});return t.ok?xu(await t.json()):{}}catch{return{}}}function Mu(e,n){const t={...e};if(n)for(const[r,o]of Object.entries(n))t[r]={value:o};return t}function _u(e,n){nn(e),e.cfg=n;const t=ou(e,n);if(!t){se(e,n,"\u7F51\u9875\u58C1\u7EB8\uFF1A\u65E0\u53EF\u7528\u5BB9\u5668"),e.onError?.(new Error("\u7F51\u9875\u58C1\u7EB8\uFF1A\u65E0\u53EF\u7528\u5BB9\u5668"));return}const r=n.src??"";if(!r){se(e,n,"\u7F51\u9875\u58C1\u7EB8\uFF1A\u7F3A\u5C11 src"),e.onError?.(new Error("\u7F51\u9875\u58C1\u7EB8\uFF1A\u7F3A\u5C11 src"));return}yu(e);const o=n,i=o._webAudio===null?null:o._webAudio??ru(),s=o._webMedia===null?null:o._webMedia??gu(),a=l=>{se(e,n,`\u7F51\u9875\u58C1\u7EB8 shim \u6CE8\u5165\u5931\u8D25\uFF08${l}\uFF09\uFF0C\u9000\u56DE\u88F8 iframe`),mo(e,n,t,r,{injected:!1}),ls(e,null),us(e,null)},c={last:0},u=()=>{ls(e,i,c),us(e,s)};(async()=>{const l=await wu(r),p=Mu(l,e.liveUserProps);if(e.liveUserProps=Object.fromEntries(Object.entries(p).map(([f,d])=>[f,d.value])),vu(r)){mo(e,n,t,r,{injected:!0,frameClock:c}),u(),e.iframe?.addEventListener("load",()=>{let d=!1;Ke(e,w=>{d=typeof w.__weSetPaused=="function"}),d||se(e,n,"\u7F51\u9875\u58C1\u7EB8\uFF1A\u540C\u6E90\u5165\u53E3\u672A\u68C0\u6D4B\u5230 WE shim\uFF08host \u672A\u6CE8\u5165\uFF1F\uFF09\uFF1BSpine \u7C7B\u58C1\u7EB8\u8BF7\u786E\u8BA4 /web/ HTML \u6539\u5199")},{once:!0});return}try{const f=await fetch(r,{credentials:"same-origin"});if(!f.ok){a(`HTTP ${f.status}`);return}const d=await f.text();if(ql(d)){a("CSP \u963B\u6B62 inline script");return}const w=Yl(d,Zl,{baseHref:Gl(r),seedScript:iu(p,n.sceneFps,n.muted===!1?1:0)}),M=new Blob([w],{type:"text/html;charset=utf-8"}),m=URL.createObjectURL(M);mo(e,n,t,m,{blobUrl:m,injected:!0,frameClock:c}),u()}catch(f){a(f instanceof Error?f.message:String(f))}})()}function Sr(e,n){const t=String(n.type??"").toLowerCase();n={...n,type:t},e.cfg=n,(t==="video"||t==="gif"||t==="image")&&n.src?yl(e,n):t==="scene"&&(n.source||n.src)?Hl(e,n):t==="web"&&n.src?_u(e,n):e.onUnhandledType?.(n)}function Au(e){return e==="fit"?"contain":e==="fill"?"cover":e==="contain"||e==="stretch"?e:"cover"}function Tu(e){const n=e?.type;return typeof n=="string"&&n.toLowerCase()==="web"}function Su(e){if(e instanceof HTMLCanvasElement)return e;const n=e.querySelector(":scope > canvas[data-webwallgl]");if(n instanceof HTMLCanvasElement)return n;const t=document.createElement("canvas");return t.setAttribute("data-webwallgl","1"),t.style.cssText="position:absolute;inset:0;width:100%;height:100%;display:block;",getComputedStyle(e).position==="static"&&(e.style.position="relative"),e.appendChild(t),t}async function fs(e,n){const t={fit:Au(n.fit),renderDpr:n.renderDpr??1,sceneFps:n.fps??60,muted:(n.volume??0)<=0,loop:!0,canvas:e,source:n.source};let r=null;try{r=await n.source.project?.()??null}catch{r=null}if(Tu(r)){let i;try{i=(await n.source.webEntry?.())?.url}catch{i=void 0}if(!i&&n.source.key){const s=r&&typeof r.file=="string"&&String(r.file).trim().replace(/^\/+/,"")||"index.html";i=`${n.source.key.replace(/\/+$/,"")}/${s}`}if(!i)throw new Error("\u7F51\u9875\u58C1\u7EB8\uFF1A\u65E0\u6CD5\u89E3\u6790\u5165\u53E3 URL\uFF08\u9700\u8981 Source.webEntry \u6216 httpSource\uFF09");return{...t,type:"web",src:i,source:n.source}}const o=Su(e);return{...t,type:"scene",canvas:o,source:n.source}}function ds(e,n){const t=gs(),r={ready:[],error:[],diagnostic:[]};let o={...n??{},source:null},i=e;const s=f=>{for(const d of r.error)try{d(f)}catch{}},a=f=>{t.onDiagnostic=(d,w)=>{try{f.onDiagnostic?.(d,w)}catch{}for(const M of r.diagnostic)try{M(d,w)}catch{}},t.onError=d=>{try{f.onError?.(d)}catch{}s(d)},t.onSceneInfo=d=>{t.info=d}},c=()=>new Promise(f=>{const d=t.onFirstFrame;t.onFirstFrame=()=>{t.onFirstFrame=void 0,d?.();const w=t.info??{width:0,height:0,layerCount:0,hasModels:!1,hasParticles:!1,hasText:!1};try{o.onReady?.(w)}catch{}for(const M of r.ready)try{M(w)}catch{}f()}}),u=()=>{let f=()=>{};return{promise:new Promise((w,M)=>{f=l.on("error",m=>M(m))}),off:f}},l={get canvas(){return i},pause(){t.paused=!0,t.sceneCtl?.pause()},resume(){t.paused=!1,xo(t),t.sceneCtl?.resume()},get paused(){return!!t.paused},setFit(f){t.cfg.fit=f,Rr(t)},setFps(f){t.cfg.sceneFps=f,Ke(t,d=>d.__weSetFps?.(f))},setVolume(f){const d=Math.max(0,Math.min(1,f));t.cfg.muted=d<=0,t.sceneAudio?.setVolume(d),Ke(t,w=>w.__weSetVolume?.(d))},setRenderDpr(f){t.cfg.renderDpr=f,Sr(t,t.cfg)},setProperties(f){const d={};for(const[w,M]of Object.entries(f))d[w]={value:M};t.sceneCtl?.applyUserProperties(d)},getProperties(){return{...t.liveUserProps??{}}},async load(f){o={...o,source:f},a(o);const d=await fs(i,o);d.type==="scene"&&d.canvas instanceof HTMLCanvasElement&&(i=d.canvas),t.cfg=d,t.paused=!1,t.info=void 0,Rr(t),o.properties&&(t.liveUserProps={...o.properties});const w=c(),M=u();Sr(t,d);try{await Promise.race([w,M.promise])}finally{M.off()}},release(){nn(t)},restore(){Sr(t,t.cfg)},destroy(){bs(t),t.onDiagnostic=void 0,t.onError=void 0,t.onFirstFrame=void 0,t.onSceneInfo=void 0,r.ready.length=0,r.error.length=0,r.diagnostic.length=0},get stats(){return vs(t)},get info(){return t.info??null},on(f,d){const w=r[f];return w.push(d),()=>{const M=w.indexOf(d);M>=0&&w.splice(M,1)}}},p=async f=>{o=f,a(f);const d=await fs(e,f);d.type==="scene"&&d.canvas instanceof HTMLCanvasElement&&(i=d.canvas),t.cfg=d,t.paused=f.autoplay===!1,t.info=void 0,Rr(t),f.properties&&Object.keys(f.properties).length&&(t.liveUserProps={...f.properties});const w=c(),M=u();Sr(t,t.cfg);try{await Promise.race([w,M.promise])}finally{M.off()}(f.volume??0)>0&&l.setVolume(f.volume),f.properties&&Object.keys(f.properties).length&&l.setProperties(f.properties)};return l.__applyOptions=p,l}async function Eu(e,n){const t=ds(e,n);return await t.__applyOptions(n),t}export{_l as bytesSource,ds as createScene,Ml as fileSource,Qi as httpSource,Eu as mount};
|
|
1717
|
+
`;function Qe(e,n){try{const t=e.iframe?.contentWindow;t&&n(t)}catch{}}function pu(e,n,t){const r=n.contentWindow;if(!r||r.requestAnimationFrame?.__weThrottled)return;const o=e.cfg.sceneFps||30;if(o>=60)return;const i=1e3/o;try{const s=r.requestAnimationFrame.bind(r),a=new Map;let c=0;r.requestAnimationFrame=u=>{const l=++c,f=r.setTimeout(()=>{a.delete(l),s(p=>{try{u(p)}catch{}})},i);return a.set(l,f),l},r.cancelAnimationFrame=u=>{const l=a.get(u);l!==void 0&&(r.clearTimeout(l),a.delete(u))}}catch{}}const hu=new Float32Array(128);function mu(e,n,t){const r=Math.min(64,n.length),o=Math.min(64,t.length);for(let i=0;i<r;i++)e[i]=Number(n[i])||0;for(let i=0;i<o;i++)e[64+i]=Number(t[i])||0;return e}const gu=1.8,bu=1.8,yu=30;function bs(e){const n=Number(e)||0;return n<=0?0:Math.min(1,Math.pow(n,bu)*gu)}function vu(){const e=Zi(),n=new Float32Array(64),t=new Float32Array(64);return{tick(r){e.update(r/1e3)},snapshot(){const r=e.snapshot,o=r.preL64,i=r.preR64;for(let s=0;s<64;s++)o&&i?(n[s]=bs(o[s]),t[s]=bs(i[s])):(n[s]=(Number(r.left64[s])||0)*.2,t[s]=(Number(r.right64[s])||0)*.2);return{left:n,right:t}}}}function xu(e){const n=new Float32Array(64),t=new Float32Array(64);return{snapshot(){const r=e.audioBridge?.(),o=r?.left,i=r?.right,s=o&&i?Math.min(64,o.length,i.length):0;for(let a=0;a<s;a++)n[a]=Math.max(0,Math.min(1,Number(o[a])||0)),t[a]=Math.max(0,Math.min(1,Number(i[a])||0));for(let a=s;a<64;a++)n[a]=0,t[a]=0;return{left:n,right:t}}}}function wu(e){const n=new Float32Array(64),t=new Float32Array(64);return{tick(){e.audio.pump()},snapshot(){const r=e.audio.snapshot;for(let o=0;o<64;o++)n[o]=Math.max(0,Math.min(1,Number(r.left64[o])||0)),t[o]=Math.max(0,Math.min(1,Number(r.right64[o])||0));return{left:n,right:t}}}}function Mu(e,n){if(e.wrap)return e.wrap;const t=n.canvas;if(!t)return null;if(t instanceof HTMLCanvasElement){const r=t.parentElement;return r?(se(e,n,"\u7F51\u9875\u58C1\u7EB8\u6302\u5728 canvas \u7236\u5BB9\u5668\u4E0A\uFF08canvas \u4E0D\u80FD\u6709\u5B50\u8282\u70B9\uFF1B\u66F4\u9002\u5408\u7A7A div\uFF09"),r):null}return t}function _u(e,n,t){const r=[];return n!=null&&Number.isFinite(n)&&r.push(`window.__weSetFps(${Number(n)});`),t!=null&&Number.isFinite(t)&&r.push(`window.__weSetVolume(${Math.max(0,Math.min(1,Number(t)))});`),e&&Object.keys(e).length&&r.push(`window.__weSeedProps(${JSON.stringify(e)});`),r.join(`
|
|
1718
|
+
`)}function Au(e,n,t){const r="position:absolute;border:none;background:transparent;",o=()=>{n.style.cssText=r+"inset:0;width:100%;height:100%;"};o();let i="";const s=()=>{if(!n.isConnected)return;let p=null;try{p=n.contentDocument}catch{return}if(!p)return;const d=t.clientWidth||window.innerWidth||0,y=t.clientHeight||window.innerHeight||0,x=pn(e.cfg.fit)==="cover";o();const m=x&&d>0&&y>0?ku(p):null,M=m?Ru(d,y,m.contentAspect):null,h=M?`${Math.round(M.width)}x${Math.round(M.height)}`:"full";if(!M){i="full";return}n.style.cssText=r+`left:${M.left}px;top:${M.top}px;width:${M.width}px;height:${M.height}px;`,h!==i&&(i=h,se(e,e.cfg,`\u7F51\u9875\u58C1\u7EB8\u9732\u5E95\u81EA\u9002\u914D\uFF1A\u89C6\u53E3\u6309\u5185\u5BB9\u6BD4\u4F8B\u6539\u4E3A ${Math.round(M.width)}\xD7${Math.round(M.height)}\uFF08cover \u5C45\u4E2D\u88C1\u5207\uFF09`))},a=()=>s();window.addEventListener("resize",a);let c;typeof ResizeObserver<"u"&&(c=new ResizeObserver(()=>s()),c.observe(t));const u=[],l=()=>{s();for(const p of[120,400,1200])u.push(window.setTimeout(s,p));try{const p=n.contentDocument;if(p)for(const d of p.querySelectorAll("video,img"))d.addEventListener("loadedmetadata",s,{once:!0}),d.addEventListener("load",s,{once:!0})}catch{}};n.addEventListener("load",l),e.webRelayout=s;const f=e.sceneCleanup;e.sceneCleanup=()=>{window.removeEventListener("resize",a),c?.disconnect();for(const p of u)clearTimeout(p);n.removeEventListener("load",l),e.webRelayout===s&&(e.webRelayout=void 0);try{f?.()}catch{}}}function Tu(e,n,t,r,o){if(!Number.isFinite(e)||!Number.isFinite(n)||!(t.width>0)||!(t.height>0))return null;const i=r.width>0&&o.width>0?r.width/o.width:1,s=r.height>0&&o.height>0?r.height/o.height:1;return{x:(e*t.width-(r.left-t.left))/(i||1),y:(n*t.height-(r.top-t.top))/(s||1)}}function Su(e,n,t){e.pointerCtl={push(r){if(!n.isConnected)return;const o=t.getBoundingClientRect(),i=n.getBoundingClientRect(),s=Tu(Number(r?.u),Number(r?.v),{left:o.left,top:o.top,width:o.width||t.clientWidth||window.innerWidth||0,height:o.height||t.clientHeight||window.innerHeight||0},{left:i.left,top:i.top,width:i.width,height:i.height},{width:n.clientWidth,height:n.clientHeight});s&&Qe(e,a=>a.__wePushPointer?.(s.x,s.y,Number(r.buttons)||0))},leave(){Qe(e,r=>r.__wePointerLeave?.())}}}function yo(e,n,t,r,o){const i=document.createElement("iframe");i.setAttribute("sandbox","allow-scripts allow-same-origin"),i.style.cssText="position:absolute;inset:0;width:100%;height:100%;border:none;background:transparent;",!e.wrap&&getComputedStyle(t).position==="static"&&(t.style.position="relative"),i.src=r,t.appendChild(i),e.iframe=i,o.blobUrl&&(e.objectUrls??=[]).push(o.blobUrl),Au(e,i,t),o.injected&&Su(e,i,t);const s=c=>{if(c.source!==i.contentWindow)return;const u=c.data;if(!u||u.op!=="we-frame"||e.paused)return;const l=typeof u.t=="number"?u.t:performance.now();o.frameClock&&(o.frameClock.last=l),Fn(e,l)};window.addEventListener("message",s);const a=e.sceneCleanup;e.sceneCleanup=()=>{window.removeEventListener("message",s);try{a?.()}catch{}},i.addEventListener("load",()=>{try{const l=i.contentDocument;l&&window.__blockContextMenu?.(l),o.injected||pu(e,i,l)}catch{}Qe(e,l=>{const f={};for(const[p,d]of Object.entries(e.liveUserProps??{}))f[p]={value:d};l.__weApplyProps?.(f),l.__weSetFps?.(e.cfg.sceneFps??60),l.__weSetVolume?.(e.cfg.muted===!1?1:0),e.paused&&l.__weSetPaused?.(!0)});try{e.onFirstFrame?.(),e.onFirstFrame=void 0}catch{}const c=t.clientWidth||window.innerWidth||1,u=t.clientHeight||window.innerHeight||1;try{e.onSceneInfo?.({width:c,height:u,layerCount:0,hasModels:!1,hasParticles:!1,hasText:!1})}catch{}})}const Eu=.005,Pu=.01,Cu=.2,Lu=6;function Ru(e,n,t){if(!(e>0)||!(n>0)||!(t>0))return null;const r=e/n;if(Math.abs(r-t)<=Eu)return null;if(r<t){const i=n*t;return{width:i,height:n,left:(e-i)/2,top:0}}const o=e/t;return{width:e,height:o,left:0,top:(n-o)/2}}function ku(e){const n=e.defaultView;if(!n)return null;const t=n.innerWidth,r=n.innerHeight;if(!(t>0)||!(r>0))return null;const o=[...e.querySelectorAll("video,img")];for(const i of o){const s=i.getBoundingClientRect();if(s.width<=0||s.height<=0||s.width<t*.98||Math.abs(s.left)>t*.02||s.top>r*.02||r-s.height<r*Pu)continue;const a=i.videoWidth||i.naturalWidth||0,c=i.videoHeight||i.naturalHeight||0;if(!(a>0)||!(c>0))continue;const u=a/c;if(!(!Number.isFinite(u)||u<Cu||u>Lu))return{contentAspect:u}}return null}function ln(e){if(!e)return"rgb(128,128,128)";const n=Math.round(Math.max(0,Math.min(1,Number(e.x)||0))*255),t=Math.round(Math.max(0,Math.min(1,Number(e.y)||0))*255),r=Math.round(Math.max(0,Math.min(1,Number(e.z)||0))*255);return`rgb(${n},${t},${r})`}function Fu(e){try{const n=document.createElement("canvas");n.width=n.height=64;const t=n.getContext("2d");if(!t)return"";const r=e.primaryColor,o=e.secondaryColor,i=t.createLinearGradient(0,0,64,64);return i.addColorStop(0,ln(r)),i.addColorStop(1,ln(o)),t.fillStyle=i,t.fillRect(0,0,64,64),n.toDataURL("image/jpeg",.85)}catch{return""}}function Nu(){return we.createSimulatedMedia()}function Uu(e,n,t){const r=we.diffMediaEvents(n,t);for(const{name:o,event:i}of r)if(o==="mediaStatusChanged")Qe(e,s=>s.__wePushMedia?.({op:"status",enabled:!!i.enabled}));else if(o==="mediaPropertiesChanged")Qe(e,s=>s.__wePushMedia?.({op:"properties",title:i.title??"",artist:i.artist??"",album:i.album??"",albumArtist:i.albumArtist??""}));else if(o==="mediaThumbnailChanged"){const s=Fu(t);Qe(e,a=>a.__wePushMedia?.({op:"thumbnail",thumbnail:s,hasThumbnail:!!i.hasThumbnail||!!s,primaryColor:ln(i.primaryColor),secondaryColor:ln(i.secondaryColor),tertiaryColor:ln(i.tertiaryColor),textColor:ln(i.textColor),highContrastColor:ln(i.highContrastColor)}))}else o==="mediaPlaybackChanged"?Qe(e,s=>s.__wePushMedia?.({op:"playback",state:Number(i.state)||0})):o==="mediaTimelineChanged"&&Qe(e,s=>s.__wePushMedia?.({op:"timeline",position:Number(i.position)||0,duration:Number(i.duration)||0}));return we.cloneMediaSnapshot(t)}function ys(e,n,t,r={driver:null}){if(!n)return;const o=xu(e),i=()=>e.audioBridge?o:r.driver??n;let s=0,a=0;const c=l=>{if(s=requestAnimationFrame(c),e.paused||!e.iframe)return;const f=e.cfg.sceneFps||60,d=1e3/Math.min(Math.max(1,f),yu);if(!(l-a<d*.85)){a=l;try{const y=i();y.tick?.(l);const x=y.snapshot(),m=mu(hu,x.left,x.right);Qe(e,M=>M.__wePushAudio?.(m)),t&&l-t.last>200&&Fn(e,l)}catch{}}};s=requestAnimationFrame(c);const u=e.sceneCleanup;e.sceneCleanup=()=>{cancelAnimationFrame(s);try{u?.()}catch{}}}function vs(e,n){if(!n)return;const t=()=>e.mediaSource??n;let r=0,o=null,i=0;const s=c=>{if(r=requestAnimationFrame(s),!(e.paused||!e.iframe)&&!(c-i<200)){i=c;try{const u=t();u.update?.(c/1e3),o=Uu(e,o,u.snapshot)}catch{}}};r=requestAnimationFrame(s);const a=e.sceneCleanup;e.sceneCleanup=()=>{cancelAnimationFrame(r);try{a?.()}catch{}}}function Du(e){e.sceneCtl={pause(){e.paused=!0,Qe(e,n=>n.__weSetPaused?.(!0))},resume(){e.paused=!1,Qe(e,n=>n.__weSetPaused?.(!1))},applyUserProperties(n){const t={...e.liveUserProps??{}};for(const[r,o]of Object.entries(n??{})){const i=o&&typeof o=="object"&&"value"in o?o.value:o;t[r]=i}e.liveUserProps=t,Qe(e,r=>r.__weApplyProps?.(n))}}}function Bu(e){try{return new URL(e,location.href).origin===location.origin}catch{return!1}}function Iu(e){const n=e?.general?.properties;if(!n||typeof n!="object")return{};const t={};for(const[r,o]of Object.entries(n)){if(!o||typeof o!="object"||typeof o.type!="string")continue;const i=o.value,s=o.type.toLowerCase();if(i==null){if(s==="file"||s==="directory"){t[r]={value:""};continue}if(!("value"in o))continue}t[r]={value:i}}return t}async function Ou(e){try{const n=new URL("project.json",new URL(e,location.href)),t=await fetch(n.href,{credentials:"same-origin"});return t.ok?Iu(await t.json()):{}}catch{return{}}}function $u(e,n){const t={...e};if(n)for(const[r,o]of Object.entries(n))t[r]={value:o};return t}function ju(e,n){on(e),e.cfg=n;const t=Mu(e,n);if(!t){se(e,n,"\u7F51\u9875\u58C1\u7EB8\uFF1A\u65E0\u53EF\u7528\u5BB9\u5668"),e.onError?.(new Error("\u7F51\u9875\u58C1\u7EB8\uFF1A\u65E0\u53EF\u7528\u5BB9\u5668"));return}const r=n.src??"";if(!r){se(e,n,"\u7F51\u9875\u58C1\u7EB8\uFF1A\u7F3A\u5C11 src"),e.onError?.(new Error("\u7F51\u9875\u58C1\u7EB8\uFF1A\u7F3A\u5C11 src"));return}Du(e);const o=n,i=o._webAudio===null||e.audioDisabled?null:o._webAudio??vu(),s=o._webMedia===null||e.mediaDisabled?null:o._webMedia??Nu(),a=f=>{se(e,n,`\u7F51\u9875\u58C1\u7EB8 shim \u6CE8\u5165\u5931\u8D25\uFF08${f}\uFF09\uFF0C\u9000\u56DE\u88F8 iframe`),yo(e,n,t,r,{injected:!1}),ys(e,null),vs(e,null);let p=0;const d=y=>{e.iframe&&(p=requestAnimationFrame(d),!e.paused&&Fn(e,y))};p=requestAnimationFrame(d),(e.wallpaperDisposers??=[]).push(()=>cancelAnimationFrame(p))},c={last:0},u={driver:null},l=()=>{if(ys(e,i,c,u),vs(e,s),n.liveSystem&&i){const f={handle:null,dead:!1};(e.wallpaperDisposers??=[]).push(()=>{f.dead=!0,u.driver=null;try{f.handle?.dispose()}catch{}f.handle=null}),(async()=>{try{const p=await hs({origin:location.origin});if(f.dead){try{p.dispose()}catch{}return}f.handle=p;const d=p.status();d.audio==="mic"?(u.driver=wu(p),se(e,n,"liveSystem: \u7F51\u9875\u58C1\u7EB8\u97F3\u9891\u6539\u7528\u9EA6\u514B\u98CE")):se(e,n,`liveSystem: \u9EA6\u514B\u98CE\u4E0D\u53EF\u7528\uFF08${d.audio}\uFF09\uFF0C\u7F51\u9875\u58C1\u7EB8\u6CBF\u7528\u6A21\u62DF\u6E90`)}catch(p){se(e,n,`liveSystem: \u542F\u52A8\u5931\u8D25\uFF0C\u7F51\u9875\u58C1\u7EB8\u6CBF\u7528\u6A21\u62DF\u6E90 (${p?.message??p})`)}})()}};(async()=>{const f=await Ou(r),p=$u(f,e.liveUserProps);if(e.liveUserProps=Object.fromEntries(Object.entries(p).map(([d,y])=>[d,y.value])),Bu(r)){yo(e,n,t,r,{injected:!0,frameClock:c}),l(),e.iframe?.addEventListener("load",()=>{let y=!1;Qe(e,x=>{y=typeof x.__weSetPaused=="function"}),y||se(e,n,"\u7F51\u9875\u58C1\u7EB8\uFF1A\u540C\u6E90\u5165\u53E3\u672A\u68C0\u6D4B\u5230 WE shim\uFF08host \u672A\u6CE8\u5165\uFF1F\uFF09\uFF1BSpine \u7C7B\u58C1\u7EB8\u8BF7\u786E\u8BA4 /web/ HTML \u6539\u5199")},{once:!0});return}try{const d=await fetch(r,{credentials:"same-origin"});if(!d.ok){a(`HTTP ${d.status}`);return}const y=await d.text();if(uu(y)){a("CSP \u963B\u6B62 inline script");return}const x=fu(y,du,{baseHref:lu(r),seedScript:_u(p,n.sceneFps,n.muted===!1?1:0)}),m=new Blob([x],{type:"text/html;charset=utf-8"}),M=URL.createObjectURL(m);yo(e,n,t,M,{blobUrl:M,injected:!0,frameClock:c}),l()}catch(d){a(d instanceof Error?d.message:String(d))}})()}function Sr(e,n){const t=String(n.type??"").toLowerCase();n={...n,type:t},e.cfg=n,(t==="video"||t==="gif"||t==="image")&&n.src?kl(e,n):t==="scene"&&(n.source||n.src)?au(e,n):t==="web"&&n.src?ju(e,n):e.onUnhandledType?.(n)}class jt{x;y;z;constructor(n,t,r){this.x=Number(n)||0,this.y=Number(t)||0,this.z=Number(r)||0}add(n){return new jt(this.x+n.x,this.y+n.y,this.z+n.z)}subtract(n){return new jt(this.x-n.x,this.y-n.y,this.z-n.z)}multiply(n){return typeof n=="number"?new jt(this.x*n,this.y*n,this.z*n):new jt(this.x*n.x,this.y*n.y,this.z*n.z)}toString(){return`${this.x} ${this.y} ${this.z}`}}function _t(e,n,t){if(e instanceof jt)return e;if(Array.isArray(e))return new jt(e[0]??0,e[1]??0,e[2]??0);if(typeof e=="object"&&e!==null){const r=e;return new jt(r.x??0,r.y??0,r.z??0)}return new jt(e,n??0,t??0)}const zu=[.35,.38,.45],Vu=[.12,.13,.17],Wu=[.72,.76,.84],xs=[.95,.96,.98];function Hu(e,n){if(!Array.isArray(e)||e.length===0)return{line:"",index:-1};let t=-1;for(let r=0;r<e.length;r++){const o=Number(e[r]?.[0]);if(Number.isFinite(o)&&o<=n)t=r;else break}return{line:t>=0?String(e[t][1]??""):"",index:t}}function ws(e){const n=Number(e.position)||0,t=Array.isArray(e.lyrics)?e.lyrics:[],{line:r,index:o}=Hu(t,n),i=e.state!==void 0?e.state:e.playing===!1?2:e.playing?1:0;return{hasMedia:e.hasMedia??(e.title!=null||e.artist!=null||!!e.playing),state:i,title:String(e.title??""),artist:String(e.artist??""),album:String(e.album??""),albumArtist:String(e.albumArtist??e.artist??""),position:n,duration:Number(e.duration)||0,hasThumbnail:e.hasThumbnail??!1,primaryColor:_t(e.primaryColor??zu),secondaryColor:_t(e.secondaryColor??Vu),tertiaryColor:_t(e.tertiaryColor??Wu),textColor:_t(e.textColor??xs),highContrastColor:_t(e.highContrastColor??e.textColor??xs),trackIndex:Number(e.trackIndex)||0,lyrics:t,lyricLine:r,lyricIndex:o}}function Xu(e={},n={}){let t={...e},r=ws(t);return{get snapshot(){return r},set(o){t={...t,...o},r=ws(t)},update(){},skipNext:n.skipNext,skipPrevious:n.skipPrevious,play:n.play,pause:n.pause,playPause:n.playPause}}function Gu(e){return e==="fit"?"contain":e==="fill"?"cover":e==="contain"||e==="stretch"?e:"cover"}function Yu(e){const n=e?.type;return typeof n=="string"&&n.toLowerCase()==="web"}const vo=new Set(["video","gif","image"]);function qu(e){const n=e?.type;if(typeof n!="string")return null;const t=n.toLowerCase();return vo.has(t)?t:null}function xo(e){if(e instanceof HTMLCanvasElement)return e;const n=e.querySelector(":scope > canvas[data-webwallgl]");if(n instanceof HTMLCanvasElement)return n;const t=document.createElement("canvas");return t.setAttribute("data-webwallgl","1"),t.style.cssText="position:absolute;inset:0;width:100%;height:100%;display:block;",getComputedStyle(e).position==="static"&&(e.style.position="relative"),e.appendChild(t),t}async function Ms(e,n){const t={fit:Gu(n.fit),renderDpr:n.renderDpr??1,sceneFps:n.fps??60,muted:(n.volume??0)<=0,loop:!0,canvas:e,source:n.source};let r=null;try{r=await n.source.project?.()??null}catch{r=null}if(Yu(r)){let a;try{a=(await n.source.webEntry?.())?.url}catch{a=void 0}if(!a&&n.source.key){const c=r&&typeof r.file=="string"&&String(r.file).trim().replace(/^\/+/,"")||"index.html";a=`${n.source.key.replace(/\/+$/,"")}/${c}`}if(!a)throw new Error("\u7F51\u9875\u58C1\u7EB8\uFF1A\u65E0\u6CD5\u89E3\u6790\u5165\u53E3 URL\uFF08\u9700\u8981 Source.webEntry \u6216 httpSource\uFF09");return{...t,type:"web",src:a,source:n.source}}const o=qu(r);if(o){let a,c;try{const f=await n.source.mediaEntry?.();a=f?.url,c=f?.type}catch{a=void 0}if(!a&&n.source.key){const f=r&&typeof r.file=="string"?String(r.file).trim().replace(/^\/+/,""):"";f&&(a=`${n.source.key.replace(/\/+$/,"")}/${f}`)}if(!a)throw new Error(`\u5A92\u4F53\u58C1\u7EB8\uFF08${o}\uFF09\uFF1A\u65E0\u6CD5\u89E3\u6790\u8D44\u6E90 URL\uFF08\u9700\u8981 Source.mediaEntry \u6216 project.file + httpSource\uFF09`);const u=xo(e),l=vo.has(String(c).toLowerCase())?String(c).toLowerCase():o;return{...t,type:l,src:a,canvas:u,source:n.source}}if(!(typeof r?.type=="string"?String(r.type).trim():"")&&typeof n.source.mediaEntry=="function"){let a,c;try{const l=await n.source.mediaEntry();a=l?.url,c=l?.type}catch{a=void 0}const u=(vo.has(String(c).toLowerCase())?String(c).toLowerCase():null)??(a?mo(a):null);if(a&&u){const l=xo(e);return{...t,type:u,src:a,canvas:l,source:n.source}}}const s=xo(e);return{...t,type:"scene",canvas:s,source:n.source}}function _s(e,n){const t=Es(),r={ready:[],error:[],diagnostic:[]};let o={...n??{},source:null},i=e;const s=d=>{for(const y of r.error)try{y(d)}catch{}},a=d=>{t.onDiagnostic=(y,x)=>{try{d.onDiagnostic?.(y,x)}catch{}for(const m of r.diagnostic)try{m(y,x)}catch{}},t.onError=y=>{try{d.onError?.(y)}catch{}s(y)},t.onSceneInfo=y=>{t.info=y},"audio"in d&&c(d.audio??null),"media"in d&&(t.mediaSource=d.media??null,t.mediaDisabled=d.media===null)},c=d=>{if(t.audioDisabled=d===null,!d){t.audioBridge=null;return}t.audioBridge=()=>{try{const y=d.snapshot();return y&&y.left&&y.right?y:null}catch{return null}}},u=()=>new Promise(d=>{const y=t.onFirstFrame;t.onFirstFrame=()=>{t.onFirstFrame=void 0,y?.();const x=t.info??{width:0,height:0,layerCount:0,hasModels:!1,hasParticles:!1,hasText:!1};try{o.onReady?.(x)}catch{}for(const m of r.ready)try{m(x)}catch{}d()}}),l=()=>{let d=()=>{};return{promise:new Promise((x,m)=>{d=f.on("error",M=>m(M))}),off:d}},f={get canvas(){return i},pause(){t.paused=!0,t.sceneCtl?.pause()},resume(){t.paused=!1,To(t),t.sceneCtl?.resume()},get paused(){return!!t.paused},setFit(d){t.cfg.fit=d,Fr(t),t.webRelayout?.()},setFps(d){t.cfg.sceneFps=d,Qe(t,y=>y.__weSetFps?.(d))},setVolume(d){const y=Math.max(0,Math.min(1,d));t.cfg.muted=y<=0,t.sceneAudio?.setVolume(y),Qe(t,x=>x.__weSetVolume?.(y))},setRenderDpr(d){t.cfg.renderDpr=d,Sr(t,t.cfg)},setProperties(d){const y={};for(const[x,m]of Object.entries(d))y[x]={value:m};t.sceneCtl?.applyUserProperties(y)},getProperties(){return{...t.liveUserProps??{}}},setAudio(d){o={...o,audio:d},c(d),t.audioDisabled=!1},setMedia(d){o={...o,media:d},t.mediaSource=d??null,t.mediaDisabled=!1},get media(){const d=t.mediaCtl;if(d)return d;const y={hasMedia:!1,state:0,title:"",artist:"",album:"",albumArtist:"",position:0,duration:0,hasThumbnail:!1,primaryColor:_t(0,0,0),secondaryColor:_t(0,0,0),tertiaryColor:_t(0,0,0),textColor:_t(1,1,1),highContrastColor:_t(1,1,1),trackIndex:0,lyrics:[],lyricLine:"",lyricIndex:-1},x=()=>y;return{get snapshot(){return y},skipNext:x,skipPrevious:x,play:x,pause:x,playPause:x}},pushPointer(d,y,x){t.pointerCtl?.push({u:d,v:y,buttons:x})},pointerLeave(){t.pointerCtl?.leave()},async load(d){const y=o.source;if(y&&y!==d)try{y.dispose?.()}catch{}o={...o,source:d},a(o);const x=await Ms(i,o);x.type!=="web"&&x.canvas instanceof HTMLCanvasElement&&(i=x.canvas),t.cfg=x,t.paused=!1,t.info=void 0,Fr(t),o.properties&&(t.liveUserProps={...o.properties});const m=u(),M=l();Sr(t,x);try{await Promise.race([m,M.promise])}finally{M.off()}},release(){on(t)},restore(){Sr(t,t.cfg)},destroy(){Ps(t);try{o.source?.dispose?.()}catch{}t.onDiagnostic=void 0,t.onError=void 0,t.onFirstFrame=void 0,t.onSceneInfo=void 0,r.ready.length=0,r.error.length=0,r.diagnostic.length=0},get stats(){return Ls(t)},get info(){return t.info??null},on(d,y){const x=r[d];return x.push(y),()=>{const m=x.indexOf(y);m>=0&&x.splice(m,1)}}},p=async d=>{o=d,a(d);const y=await Ms(e,d);y.type!=="web"&&y.canvas instanceof HTMLCanvasElement&&(i=y.canvas),t.cfg=y,t.paused=!1,t.info=void 0,Fr(t),d.properties&&Object.keys(d.properties).length&&(t.liveUserProps={...d.properties});const x=u(),m=l();Sr(t,t.cfg);try{await Promise.race([x,m.promise])}finally{m.off()}d.autoplay===!1&&f.pause(),(d.volume??0)>0&&f.setVolume(d.volume),d.properties&&Object.keys(d.properties).length&&f.setProperties(d.properties)};return f.__applyOptions=p,f}async function Zu(e,n){const t=_s(e,n);return await t.__applyOptions(n),t}export{Ol as bytesSource,Xu as createMediaSource,_s as createScene,Il as fileSource,ss as httpSource,_t as mediaColor,$l as mediaSource,Zu as mount,mo as sniffMediaType};
|
|
1719
1719
|
|
|
1720
1720
|
//# sourceMappingURL=webwallgl.min.mjs.map
|