webwallgl 1.0.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.
@@ -1,24 +1,26 @@
1
- (()=>{var Cl=(rt,We)=>()=>{try{return We||rt((We={exports:{}}).exports,We),We.exports}catch(Xt){throw We=0,Xt}};var Rl=Cl((_r,Ji)=>{(function(rt,We){typeof _r=="object"&&typeof Ji<"u"?We(_r):typeof define=="function"&&define.amd?define(["exports"],We):(rt=typeof globalThis<"u"?globalThis:rt||self,We(rt.WebWallGL={}))})(_r,function(rt){"use strict";function We(e,n){const t=n?.renderDpr??e.cfg?.renderDpr??1;return Math.min(window.devicePixelRatio||1,t)}function Xt(e){return e==="fit"?"contain":e==="fill"?"cover":e==="contain"||e==="stretch"?e:"cover"}function lo(e){const n=Xt(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 en(e){e.wrap&&(e.wrap.innerHTML=""),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.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,ho(e)}function ts(e){en(e);for(const n of e.disposers.splice(0))try{n()}catch{}e.wrap?.remove(),e.wrap=void 0}const ns=new TextDecoder,ct=e=>ns.decode(e).replace(/^\uFEFF/,""),uo=500;function fo(e,n){const t=e.frameMeter.stamps;t.push(n),e.frameMeter.last=n;const o=n-uo;for(;t.length&&t[0]<o;)t.shift();const r=t.length>=2?t[t.length-1]-t[0]:0;e.frameMeter.fps=r>0?(t.length-1)*1e3/r:0}function ho(e){e.frameMeter.stamps.length=0,e.frameMeter.last=0,e.frameMeter.fps=0}function rs(e){return!e.frameMeter.last||e.paused?{fps:0,running:!1}:performance.now()-e.frameMeter.last>Math.max(uo,400)?{fps:0,running:!1}:{fps:e.frameMeter.fps,running:!0}}function re(e,n,t){try{e.onDiagnostic?.(t,/fail|error|失败|ERROR/.test(t)?"error":"info")}catch{}try{const o=n.mediaBase?new URL(n.mediaBase).origin:"";if(o){const r=new Image;r.src=`${o}/diag?msg=${encodeURIComponent(`scene ${n.src??"?"}: ${t.slice(0,500)}`)}`}}catch{}}function Tr(e){e.coverAlign.x=e.coverAlign.y=e.coverAlign.tx=e.coverAlign.ty=.5,os(e)}function os(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 mo(e,n,t){const o=We(e,t),r=Math.max(1,Math.round((n.clientWidth||window.innerWidth||1)*o)),i=Math.max(1,Math.round((n.clientHeight||window.innerHeight||1)*o));return n.width===r&&n.height===i?!1:(n.width=r,n.height=i,!0)}function is(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 o=po(e,4,t);if(!o.startsWith("PKGV"))throw new Error("\u4E0D\u662F scene.pkg\uFF0C\u9B54\u6570: "+o);const r=n.getUint32(4+t,!0);let i=4+t+4;const s=[];for(let a=0;a<r;a++){if(i+8>e.length)throw new Error("\u5165\u53E3\u8868\u8D8A\u754C @"+a);const f=n.getUint32(i,!0);if(i+=4,i+f+8>e.length)throw new Error("\u5165\u53E3 "+a+" \u8D8A\u754C");const l=as(e,i,f);i+=f;const d=n.getUint32(i,!0);i+=4;const h=n.getUint32(i,!0);i+=4,s.push({name:l,offset:d,size:h})}const c=i;return{magic:o,version:o.slice(4),count:r,entries:s,dataStart:c,fileSize:e.length,buf:e}}function Sr(e,n){const t=e.entries.find(i=>i.name===n);if(t===void 0)return null;const o=e.dataStart+t.offset,r=o+t.size;if(o<0||r>e.fileSize)throw new Error("\u5165\u53E3 "+n+" \u8D8A\u754C");return e.buf.subarray(o,r)}function ss(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 po(e,n,t){let o="";for(let r=n;r<n+t;r++)o+=String.fromCharCode(e[r]);return o}function as(e,n,t){try{return new TextDecoder("utf-8",{fatal:!0}).decode(e.subarray(n,n+t))}catch{return po(e,n,t)}}const cs=Object.freeze(Object.defineProperty({__proto__:null,getEntry:Sr,parsePkg:is,verifyLayout:ss},Symbol.toStringTag,{value:"Module"})),Er={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"},Nt={UNKNOWN:-1,JPEG:2,PNG:13,GIF:25,WEBP:35,MP4:35};function ls(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===Nt.PNG)return{width:t.width,height:t.height,png:t.data};if(e.freeImageFormat!==Nt.UNKNOWN)return{width:t.width,height:t.height,image:t.data,fif:e.freeImageFormat};const o=Pr(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:go(o,t.width,t.height,e.width,e.height)}:{width:t.width,height:t.height,rgba:o}}function us(e){const n=e.images[0];if(!n||n.length===0)throw new Error("\u65E0\u56FE\u50CF\u6570\u636E");const t=[];for(const o of n){if(e.freeImageFormat!==Nt.UNKNOWN){t.push({width:o.width,height:o.height,image:o.data,fif:e.freeImageFormat});continue}const r=Pr(e.format,o.data,o.width,o.height);t.push({width:o.width,height:o.height,rgba:r})}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:go(t[0].rgba,t[0].width,t[0].height,e.width,e.height)}),t}function go(e,n,t,o,r){const i=new Uint8Array(o*r*4);for(let s=0;s<r;s++)i.set(e.subarray(s*n*4,s*n*4+o*4),s*o*4);return i}function Pr(e,n,t,o){switch(e){case 0:return fs(n,t,o);case 1:return ds(n,t,o);case 2:return hs(n,t,o);case 4:return ys(n,t,o);case 6:return bs(n,t,o);case 7:return gs(n,t,o);case 8:return ms(n,t,o);case 9:return ps(n,t,o);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: "+(Er[e]||e))}}function fs(e,n,t){return new Uint8Array(e.buffer,e.byteOffset,n*t*4).slice()}function ds(e,n,t){const o=new Uint8Array(n*t*4);for(let r=0;r<n*t;r++)o[r*4]=e[r*3],o[r*4+1]=e[r*3+1],o[r*4+2]=e[r*3+2],o[r*4+3]=255;return o}function hs(e,n,t){const o=new Uint8Array(n*t*4);for(let r=0;r<n*t;r++){const i=e[r*2]|e[r*2+1]<<8,s=i>>11&31,c=i>>5&63,a=i&31;o[r*4]=s<<3|s>>2,o[r*4+1]=c<<2|c>>4,o[r*4+2]=a<<3|a>>2,o[r*4+3]=255}return o}function ms(e,n,t){const o=new Uint8Array(n*t*4);for(let r=0;r<n*t;r++)o[r*4]=e[r*2+1],o[r*4+1]=e[r*2+1],o[r*4+2]=e[r*2+1],o[r*4+3]=e[r*2];return o}function ps(e,n,t){const o=new Uint8Array(n*t*4);for(let r=0;r<n*t;r++)o[r*4]=e[r],o[r*4+1]=e[r],o[r*4+2]=e[r],o[r*4+3]=255;return o}function gs(e,n,t){return Cr(e,n,t,!0,0)}function bs(e,n,t){return Cr(e,n,t,!1,3)}function ys(e,n,t){return Cr(e,n,t,!1,5)}function Cr(e,n,t,o,r){const i=new Uint8Array(n*t*4),s=o?8:16,c=new Uint8Array(16);let a=0;for(let f=0;f<t;f+=4)for(let l=0;l<n;l+=4){if(a+s>e.length)return i;c.set(e.subarray(a,a+s)),a+=s;const d=vs(c,o),h=xs(c,o),m=r===3?ws(c):r===5?Ms(c):null;for(let M=0;M<4;M++)for(let g=0;g<4;g++){const y=l+g,b=f+M;if(y>=n||b>=t)continue;const p=M*4+g,v=(b*n+y)*4;i[v]=d[h[p]*4],i[v+1]=d[h[p]*4+1],i[v+2]=d[h[p]*4+2],i[v+3]=m!==null?m[p]:d[h[p]*4+3]}}return i}function bo(e,n){const t=e[n]|e[n+1]<<8,o=t>>11&31,r=t>>5&63,i=t&31;return[t,o<<3|o>>2,r<<2|r>>4,i<<3|i>>2]}function vs(e,n){const t=n?0:8,o=bo(e,t),r=bo(e,t+2),i=new Uint8Array(16);return i[0]=o[1],i[1]=o[2],i[2]=o[3],i[3]=255,i[4]=r[1],i[5]=r[2],i[6]=r[3],i[7]=255,n&&o[0]<=r[0]?(i[8]=o[1]+r[1]>>1,i[9]=o[2]+r[2]>>1,i[10]=o[3]+r[3]>>1,i[11]=255,i[12]=0,i[13]=0,i[14]=0,i[15]=0):(i[8]=Math.floor((2*o[1]+r[1])/3),i[9]=Math.floor((2*o[2]+r[2])/3),i[10]=Math.floor((2*o[3]+r[3])/3),i[11]=255,i[12]=Math.floor((o[1]+2*r[1])/3),i[13]=Math.floor((o[2]+2*r[2])/3),i[14]=Math.floor((o[3]+2*r[3])/3),i[15]=255),i}function xs(e,n){const t=n?4:12,o=new Uint8Array(16);for(let r=0;r<4;r++){const i=e[t+r];o[r*4]=i&3,o[r*4+1]=i>>2&3,o[r*4+2]=i>>4&3,o[r*4+3]=i>>6&3}return o}function ws(e){const n=new Uint8Array(16);for(let t=0;t<8;t++){const o=e[t],r=o&15,i=o&240;n[2*t]=r|r<<4,n[2*t+1]=i|i>>4}return n}function Ms(e){const n=e[0],t=e[1],o=new Uint8Array(8);if(o[0]=n,o[1]=t,n<=t){for(let c=1;c<5;c++)o[1+c]=Math.floor(((5-c)*n+c*t)/5);o[6]=0,o[7]=255}else for(let c=1;c<7;c++)o[c+1]=Math.floor(((7-c)*n+c*t)/7);const r=new Uint8Array(16);let i=0;for(let c=0;c<2;c++){let a=0;for(let f=0;f<3;f++)a|=e[2+c*3+f]<<8*f;for(let f=0;f<8;f++)r[i++]=a>>3*f&7}const s=new Uint8Array(16);for(let c=0;c<16;c++)s[c]=o[r[c]];return s}function yo(e,n){const t=new Uint8Array(n);let o=0,r=0;for(;o<e.length;){const i=e[o++];let s=i>>4;if(s===15){let l;do l=e[o++],s+=l;while(l===255)}for(let l=0;l<s;l++)t[r++]=e[o++];if(o>=e.length)break;const c=e[o]|e[o+1]<<8;o+=2;let a=4+(i&15);if((i&15)===15){let l;do l=e[o++],a+=l;while(l===255)}const f=r-c;for(let l=0;l<a;l++)t[r++]=t[f+l]}return t}function Ie(e,n){return(e[n]|e[n+1]<<8|e[n+2]<<16|e[n+3]<<24)>>>0}function vo(e,n){return Ie(e,n)|0}const bn=new DataView(new ArrayBuffer(4));function kt(e,n){return bn.setUint8(0,e[n]),bn.setUint8(1,e[n+1]),bn.setUint8(2,e[n+2]),bn.setUint8(3,e[n+3]),bn.getFloat32(0,!0)}function As(e){let n=0;const t=Yn(e,n,9);if(n+=9,t!=="TEXV0005\0")throw new Error("\u4E0D\u662F .tex \u6587\u4EF6: "+t);const o=Yn(e,n,9);if(n+=9,o!=="TEXI0001\0")throw new Error("\u672A\u77E5 TEXI \u5B50\u5BB9\u5668: "+o);const r=Ie(e,n);n+=4;const i=Ie(e,n);n+=4;const s=Ie(e,n);n+=4;const c=Ie(e,n);n+=4;const a=Ie(e,n);n+=4;const f=Ie(e,n);n+=4,n+=4;const l=Yn(e,n,9);n+=9;const d=Ie(e,n);n+=4;let h=Nt.UNKNOWN,m=0;if(l==="TEXB0004\0"){h=Ie(e,n)|0,n+=4;const _=Ie(e,n);n+=4,h===Nt.UNKNOWN&&_===1&&(h=Nt.MP4),m=_===1?4:3}else if(l==="TEXB0003\0")h=Ie(e,n)|0,n+=4,m=3;else if(l==="TEXB0002\0")m=2;else if(l==="TEXB0001\0")m=1;else throw new Error("\u672A\u77E5 TEXB \u5BB9\u5668: "+l);const M=(i&32)!==0||h===Nt.MP4,g=[];for(let _=0;_<d;_++){const w=Ie(e,n);n+=4;const L=[];for(let F=0;F<w;F++){if(m===4){for(n+=8;n<e.length&&e[n]!==0;)n++;n+=1,n+=4}const D=Ie(e,n);n+=4;const B=Ie(e,n);n+=4;let z=0,V=0;m>=2&&(z=Ie(e,n),n+=4,V=vo(e,n),n+=4);const Y=vo(e,n);if(n+=4,M){L.push({width:D,height:B,compression:0,data:e.subarray(n)}),n=e.length;continue}z===0&&(V=Y);const Z=e.subarray(n,n+Y);n+=Y;let X=Z;z===1&&(X=yo(Z,V)),L.push({width:D,height:B,compression:z,data:X})}g.push(L)}const y=g[0]&&g[0][0],b=y?y.width:s,p=y?y.height:c;let v=null;if(n+13<=e.length){const _=Yn(e,n,9);if(_.indexOf("TEXS")===0){let w=n+9;const L=Ie(e,w);w+=4;let F=0,D=0;_==="TEXS0003\0"&&(F=Ie(e,w),w+=4,D=Ie(e,w),w+=4);const B=e.length-w,z=L>0&&B>0&&B%L===0?B/L:0;if(L>0&&L<=4096&&z>=32){const V=[];for(let Z=0;Z<L;Z++){const X=w+Z*z;if(X+32>e.length)break;const q=kt(e,X+8),oe=kt(e,X+12),H=kt(e,X+16),j=kt(e,X+20),ee=kt(e,X+24),le=kt(e,X+28);V.push({imageId:kt(e,X)|0,duration:kt(e,X+4),x:q,y:oe,width:Math.hypot(H,j)||F,height:Math.hypot(ee,le)||D,uDir:[H,j],vDir:[ee,le],rotated:Math.abs(j)>.5||Math.abs(ee)>.5})}V.length===L&&V.every(Z=>{if(!(Z.width>0&&Z.height>0))return!1;const X=[Z.x,Z.x+Z.uDir[0],Z.x+Z.vDir[0],Z.x+Z.uDir[0]+Z.vDir[0]],q=[Z.y,Z.y+Z.uDir[1],Z.y+Z.vDir[1],Z.y+Z.uDir[1]+Z.vDir[1]];return Math.min(...X)>=-1&&Math.max(...X)<=b+1&&Math.min(...q)>=-1&&Math.max(...q)<=p+1})&&(v={magic:_,frameWidth:F,frameHeight:D,atlasWidth:b,atlasHeight:p,list:V})}}}return{format:r,formatName:Er[r]||String(r),flags:i,textureWidth:s,textureHeight:c,width:a,height:f,freeImageFormat:h,containerMagic:l,containerVersion:m,isVideo:M,images:g,frames:v}}function Yn(e,n,t){let o="";for(let r=n;r<n+t;r++)o+=String.fromCharCode(e[r]);return o}const _s=Object.freeze(Object.defineProperty({__proto__:null,FIF:Nt,TEXTURE_FORMATS:Er,decodeMip0:ls,decodeMips:us,decodePixels:Pr,lz4Decompress:yo,parseTex:As},Symbol.toStringTag,{value:"Module"}));function xo(e,n){if(!e||typeof n!="string")return null;const t=e[n];return t&&typeof t=="object"?t:null}function Rr(e){return typeof e=="string"?e:e&&typeof e=="object"&&typeof e.name=="string"?e.name:null}function Ts(e,n){return qn(e)&&qn(n)?Number(e)===Number(n):String(e)===String(n)}function Lr(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 Ss(e){switch(e.type){case"bool":return"bool";case"slider":return"num";case"color":return"num";case"textinput":return"text";default:return Lr(e.value)}}function wo(e,n){if(e===null||typeof e!="object")return e;if(e.user&&typeof e.user=="object"&&typeof e.user.name=="string"){const o=xo(n,e.user.name);if(!o||o.value===void 0||o.value===null)return e.value;const r=o.type==="combo"?Fr(o.value,o.options):o.value;return Ts(r,e.user.condition)}if(typeof e.user!="string")return e;const t=xo(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(Lr(e.value)==="bool"&&t.type==="slider"){const o=Number(t.value);return Number.isFinite(o)?o!==0:e.value}return Lr(e.value)===Ss(t)?t.value:e.value}function tn(e,n,t){if(t>32||e===null||typeof e!="object")return e;if(Array.isArray(e)){for(let o=0;o<e.length;o++)e[o]=tn(e[o],n,t+1);return e}if(Rr(e.user)){let o=wo(e,n);for(let r=0;r<8&&o!==null&&typeof o=="object"&&Rr(o.user);r++)o=wo(o,n);return e.value=tn(o,n,t+1),e}for(const o of Object.keys(e))e[o]=tn(e[o],n,t+1);return e}function Es(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 qn(e){return typeof e=="number"?Number.isInteger(e):typeof e=="string"&&/^-?\d+$/.test(e.trim())}function Fr(e,n){const t=Es(n);return!(t.length>0?t.every(qn):qn(e))||typeof e=="number"&&Number.isFinite(e)?e:typeof e=="string"&&/^-?\d+$/.test(e.trim())?Number(e):e}function Ps(e){const n={};if(!e||typeof e!="object")return n;for(const[t,o]of Object.entries(e))!o||typeof o!="object"||!("value"in o)||(n[t]=o.type==="combo"?Fr(o.value,o.options):o.value);return n}function gt(e){return e&&typeof e=="object"?Rr(e.user):null}function Cs(e,n,t){const o={};if(!t||typeof t!="object")return o;const r=e&&typeof e=="object"?e:{},i=n&&typeof n=="object"?n:{};for(const[s,c]of Object.entries(t)){const a=c&&typeof c=="object"&&"value"in c?c.value:c,f=r[s];if(f&&typeof f=="object"){f.value=a,f.userOverridden=!0;const l=f.type==="combo"?Fr(f.value,f.options):f.value;i[s]=l,o[s]=l}else i[s]=a,o[s]=a}return o}function nn(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 yn(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 Zn(e){return e==null?[1,1,1]:typeof e=="string"?nn(e):typeof e=="object"&&e!==null?nn(e.value):[1,1,1]}function Ke(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 ot(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 Rs(e,n){const t=n&&n.general&&n.general.properties||{},o=e.objects||[];tn(o,t,0),tn(e.general||{},t,0);const r=new Map;for(const g of o)g.id!==void 0&&r.set(g.id,g);const i=o.map(g=>({id:g.id,parent:g.parent,origin:nn(g.origin||"0 0 0"),scale:nn(g.scale||"1 1 1"),angles:nn(g.angles||"0 0 0")}));for(let g=0;g<8;g++){let y=!1;for(const b of i){if(b.parent===void 0||b.parent===null||!r.get(b.parent))continue;const v=i.findIndex(q=>q.id===b.parent);if(v<0)continue;const _=i[v];if(_.parent!==void 0&&_.parent!==null)continue;const w=o[v],L=w.scale,F=L!==null&&typeof L=="object"&&(typeof L.script=="string"||L.user!==void 0),D=!w.image&&!w.model&&!w.particle&&w.text==null&&!w.size,B=F&&D?[1,1,1]:_.scale,z=_.angles[2]*Math.PI/180,V=Math.cos(z),Y=Math.sin(z),Z=b.origin[0]*B[0],X=b.origin[1]*B[1];b.origin[0]=_.origin[0]+Z*V-X*Y,b.origin[1]=_.origin[1]+Z*Y+X*V,b.origin[2]=_.origin[2]+b.origin[2],b.angles[2]=_.angles[2]+b.angles[2],b.scale[0]=B[0]*b.scale[0],b.scale[1]=B[1]*b.scale[1],b.scale[2]=B[2]*b.scale[2],b.parent=null,y=!0}if(!y)break}const s=o.map(g=>Ke(g.visible,!0)),c=new Map;o.forEach((g,y)=>{g.id!==void 0&&c.set(g.id,y)});const a=new Map,f=new Map;for(const g of o)if(g.parent!==void 0&&g.parent!==null){a.set(g.parent,(a.get(g.parent)||0)+1);const y=g.id!==void 0?g.id:null;if(y!==null){const b=f.get(g.parent);b?b.push(y):f.set(g.parent,[y])}}const l=o.map(()=>!0);for(let g=0;g<o.length;g++){let y=s[g],b=o[g].parent;for(let p=0;y&&b!==void 0&&b!==null&&p<64;p++){const v=c.get(b);if(v===void 0)break;s[v]||(y=!1),b=o[v].parent}l[g]=y}const d=o.map((g,y)=>{const b=i[y],p=typeof g.image=="string"&&(g.image.indexOf("models/util/projectlayer")===0||g.image.indexOf("models/util/fullscreenlayer")===0);let v=yn(g.size||"0 0"),_=b.origin;if(p){const w=(e.general||{}).orthogonalprojection,L=w&&Number(w.width),F=w&&Number(w.height);L>0&&F>0&&(v=[L,F],_=[L/2,F/2,b.origin[2]||0])}return{id:g.id!==void 0?g.id:y,name:g.name||"",visible:l[y],visibleSelf:s[y],srcObject:g,image:typeof g.image=="string"?g.image:null,model:typeof g.model=="string"?g.model:null,isSkybox:typeof g.name=="string"&&g.name.indexOf("\u5929\u7A7A\u76D2")>=0,particle:typeof g.particle=="string"?g.particle:null,instanceoverride:g.instanceoverride||null,sound:Array.isArray(g.sound)?g.sound.filter(w=>typeof w=="string"):[],soundprops:{volume:ot(g.volume,1),playbackmode:g.playbackmode||"single",startsilent:Ke(g.startsilent,!1),maxtime:ot(g.maxtime,0),mintime:ot(g.mintime,0),spatialization:Ke(g.spatialization,!1),muteineditor:Ke(g.muteineditor,!1)},text:typeof g.text=="string"?g.text:g.text&&typeof g.text=="object"?g.text.value:null,textScript:g.text&&typeof g.text=="object"&&g.text.script||null,textScriptProps:g.text&&typeof g.text=="object"&&g.text.scriptproperties||null,component:typeof g.component=="string"?g.component:null,isText:g.text!==void 0&&g.text!==null,textFont:typeof g.font=="string"?g.font:null,textPointsize:ot(g.pointsize,24)||24,textColor:Zn(g.color),textAnchor:typeof g.anchor=="string"&&g.anchor!=="none"?g.anchor:"center",textMaxwidth:ot(g.maxwidth,0),textMaxrows:ot(g.maxrows,0),textLimitwidth:Ke(g.limitwidth,!1),textLimitrows:Ke(g.limitrows,!1),textLimituseellipsis:Ke(g.limituseellipsis,!1),textHAlign:g.horizontalalign||"center",textVAlign:g.verticalalign||"center",textSpacing:g.spacing?yn(g.spacing):[0,0],textPadding:(()=>{const w=g.padding;if(typeof w=="number")return w;const L=String(w??"").trim().split(/\s+/).map(Number).filter(F=>Number.isFinite(F));return L.length?L.reduce((F,D)=>F+D,0)/L.length:0})(),textOpaquebackground:Ke(g.opaquebackground,!1),textBackgroundcolor:Zn(g.backgroundcolor),textBackgroundbrightness:ot(g.backgroundbrightness,1),textCastshadow:Ke(g.castshadow,!1),isSound:!!(g.sound&&g.sound.length),isComponent:!!g.component,objectScripts:(()=>{const w={};for(const L of["scale","origin","color","alpha","brightness","angles","visible"]){const F=g[L];F&&typeof F=="object"&&typeof F.script=="string"&&F.script&&(w[L]={script:F.script,scriptproperties:F.scriptproperties||null,value:F.value})}return Object.keys(w).length?w:null})(),objectAnimations:(()=>{const w={};for(const L of["scale","origin","color","alpha","brightness","angles","visible","volume","maxwidth","zoom"]){const F=g[L];F&&typeof F=="object"&&F.animation&&typeof F.animation=="object"&&F.animation.options&&(w[L]={animation:F.animation,value:F.value})}return Object.keys(w).length?w:null})(),animationLayers:(g.animationlayers||[]).filter(w=>w&&typeof w.animation=="number").map(w=>({animation:w.animation,visible:Ke(w.visible,!0),additive:Ke(w.additive,!1),blend:ot(w.blend,1),rate:ot(w.rate,1)})),solid:(()=>{if(typeof g.particle=="string")return!1;const w=typeof g.image=="string"?g.image:"";return w.indexOf("models/util/composelayer")===0?!1:w.indexOf("models/util/solidlayer")===0?!0:g.solid?!w||w.indexOf("models/util/")===0:!1})(),isContainer:typeof g.image=="string"&&g.image.indexOf("models/util/composelayer")===0,hasChildren:(a.get(g.id!==void 0?g.id:y)||0)>0,childIds:f.get(g.id!==void 0?g.id:y)||null,parentId:g.parent!==void 0&&g.parent!==null?g.parent:null,attachment:typeof g.attachment=="string"&&g.attachment!==""?g.attachment:null,passthrough:!!(g.config&&g.config.passthrough===!0),isPostProcess:p,origin:_,scale:b.scale,angles:b.angles,size:v,alignment:g.alignment||"center",color:Zn(g.color),alpha:ot(g.alpha,1),brightness:ot(g.brightness,1),copybackground:!!g.copybackground,colorBlendMode:g.colorBlendMode||0,parallaxDepth:g.parallaxDepth!==void 0?yn(g.parallaxDepth):null,effects:(g.effects||[]).map(w=>({file:w.file||"",name:typeof w.name=="string"?w.name:"",visible:Ke(w.visible,!0),visibleScript:w.visible&&typeof w.visible=="object"&&typeof w.visible.script=="string"&&w.visible.script?{script:w.visible.script,scriptproperties:w.visible.scriptproperties||null,value:!!w.visible.value}:null,passes:(w.passes||[]).map(L=>({combos:L.combos||{},constantshadervalues:L.constantshadervalues||{},textures:L.textures||[]}))}))}}),h=e.general||{},m=(()=>{const g={};for(const[y,b]of Object.entries(h))b&&typeof b=="object"&&typeof b.script=="string"&&b.script&&(g[y]={script:b.script,scriptproperties:b.scriptproperties||null,value:b.value});return Object.keys(g).length?g:null})(),M=(()=>{const g={};for(const[y,b]of Object.entries(h))b&&typeof b=="object"&&b.animation&&typeof b.animation=="object"&&b.animation.options&&(g[y]={animation:b.animation,value:b.value});return Object.keys(g).length?g:null})();{const g=new Map;for(const y of d)y.id!==void 0&&g.set(y.id,y);for(let y=0;y<8;y++){let b=!1;for(const p of d){if(p.parallaxDepth||p.parentId==null)continue;const v=g.get(p.parentId);!v||!v.parallaxDepth||v.image||v.particle||v.model||(p.parallaxDepth=v.parallaxDepth.slice(),b=!0)}if(!b)break}}return{camera:e.camera||null,general:h,generalScripts:m,generalAnimations:M,layers:d,properties:t}}function Ls(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 o=t.visibleSelf!==!1,r=t.parentId;for(let i=0;o&&r!=null&&i<64;i++){const s=n.get(r);if(!s)break;(s.visibleSelf===!1||s.destroyed)&&(o=!1),r=s.parentId}t.visible=o}}function Fs(e,n){!e||!n||typeof n!="object"||e.isContainer||n.solidlayer===!0&&(e.solid=!0)}function Ns(e){return!e||typeof e.material!="string"?null:{materialPath:e.material,autosize:!!e.autosize,cropoffset:e.cropoffset?yn(e.cropoffset):null}}const ks=Object.freeze(Object.defineProperty({__proto__:null,applySolidFromModel:Fs,parseBool:Ke,parseColor:Zn,parseNum:ot,parseScene:Rs,parseVec2:yn,parseVec3:nn,recomputeLayerVisibility:Ls,resolveMaterial:Ns},Symbol.toStringTag,{value:"Module"}));function Us(e,n,t){const o=Sr(e,n.file);if(o===null)return;let r;try{r=JSON.parse(t(o))}catch{return}n.fbos=r.fbos||[],n.materialPasses=(r.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=Sr(e,i.material);if(s===null)return{shader:null,copyCommand:!1,target:i.target||null,binds:i.bind||[],blending:"normal",textures:[],combos:{},constants:{}};const c=JSON.parse(t(s)),a=c.passes&&c.passes[0]||{};return{shader:a.shader||null,copyCommand:!1,target:i.target||null,binds:i.bind||[],blending:a.blending||"normal",textures:a.textures||[],combos:a.combos||{},constants:a.constantshadervalues||{}}})}const Is={"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 Mo(e){if(!e||typeof e!="string")return!0;const n=e.toLowerCase();return n==="generic"||n==="sprite"||n==="flat"||n.startsWith("genericimage")}function Bs(e,n){return!e||!n||!n.shader||Mo(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 Os=Object.freeze(Object.defineProperty({__proto__:null,BUILTIN_MATERIALS:{"materials/util/solidlayer.json":{passes:[{shader:"flat",blending:"translucent",cullmode:"nocull",depthtest:"disabled",depthwrite:"disabled",textures:[],combos:{}}]}},BUILTIN_MODELS:Is,attachLayerMaterialEffect:Bs,isBuiltinAlbedoShader:Mo,resolveEffectChain:Us},Symbol.toStringTag,{value:"Module"}));function rn(){return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function bt(e,n){const t=new Float32Array(16);for(let o=0;o<4;o++)for(let r=0;r<4;r++){let i=0;for(let s=0;s<4;s++)i+=e[s*4+r]*n[o*4+s];t[o*4+r]=i}return t}function vn(e,n,t,o,r,i){const s=rn();return s[0]=2/(n-e),s[5]=2/(o-t),s[10]=-2/(i-r),s[12]=-(n+e)/(n-e),s[13]=-(o+t)/(o-t),s[14]=-0/(i-r),s}function on(e,n,t,o){return bt(e,new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,n,t,o,1]))}function Ds(e){const n=new Float32Array(16);for(let t=0;t<4;t++)for(let o=0;o<4;o++)n[o*4+t]=e[t*4+o];return n}function xn(e,n,t,o){return bt(e,new Float32Array([n,0,0,0,0,t,0,0,0,0,o,0,0,0,0,1]))}function Ao(e,n){const t=Math.cos(n),o=Math.sin(n);return bt(e,new Float32Array([t,o,0,0,-o,t,0,0,0,0,1,0,0,0,0,1]))}function $s(e,n){const t=Math.cos(n),o=Math.sin(n);return bt(e,new Float32Array([1,0,0,0,0,t,o,0,0,-o,t,0,0,0,0,1]))}function zs(e,n){const t=Math.cos(n),o=Math.sin(n);return bt(e,new Float32Array([t,0,-o,0,0,1,0,0,o,0,t,0,0,0,0,1]))}function js(e,n,t,o){const r=1/Math.tan(e*Math.PI/180/2),i=new Float32Array(16);return i[0]=r/(n||1),i[5]=r,i[10]=(o+t)/(t-o),i[11]=-1,i[14]=2*o*t/(t-o),i}function Kn(e,n){const t=e&&typeof e=="object"?e.value:e;return typeof t=="number"&&Number.isFinite(t)?t:n}function Vs(e){const n=e&&e.general;return!n||n.orthogonalprojection?!1:Kn(n.fov,0)>0}function Ws(e,n){return n&&n.perspective&&e&&e.isSkybox&&n.eye?n.eye:e.origin}function Hs(e,n,t){const o=To([e[0]-n[0],e[1]-n[1],e[2]-n[2]]),r=To(So(t,o)),i=So(o,r),s=new Float32Array([r[0],i[0],o[0],0,r[1],i[1],o[1],0,r[2],i[2],o[2],0,0,0,0,1]);return s[12]=-(r[0]*e[0]+r[1]*e[1]+r[2]*e[2]),s[13]=-(i[0]*e[0]+i[1]*e[1]+i[2]*e[2]),s[14]=-(o[0]*e[0]+o[1]*e[1]+o[2]*e[2]),s}function Xs(e,n,t,o){const r=e[3]*n+e[7]*t+e[11]*o+e[15];return[(e[0]*n+e[4]*t+e[8]*o+e[12])/r,(e[1]*n+e[5]*t+e[9]*o+e[13])/r,(e[2]*n+e[6]*t+e[10]*o+e[14])/r]}const Gs=[[16,9],[16,10],[21,9],[32,9]];function Ys(e,n,t,o,r){const i=e/n;if(!Number.isFinite(i)||i<=0||!(t>0)||!(o>0))return null;const s=.02,c=t/o;if(Math.abs(i-c)<=s*c)return{viewW:t,viewH:o};for(const[a,f]of Gs){const l=a/f;if(Math.abs(i-l)>s*l)continue;const d=o,h=o*l;return h>t+1e-6?{viewW:t,viewH:t/l}:{viewW:h,viewH:d}}return null}function Nr(e,n,t,o,r,i,s){const c=_o(i),a=_o(s);if(e==="cover"){const f=Ys(o,r,n,t);if(f)return{offX:(n-f.viewW)*c,offY:(t-f.viewH)*a,viewW:f.viewW,viewH:f.viewH};const l=Math.max(o/n,r/t),d=o/l,h=r/l;return{offX:(n-d)*c,offY:(t-h)*a,viewW:d,viewH:h}}if(e==="contain"){const f=o/r;if(n/t>f){const m=n,M=n/f;return{offX:0,offY:(t-M)/2,viewW:m,viewH:M}}const d=t,h=t*f;return{offY:0,offX:(n-h)/2,viewW:h,viewH:d}}return{offX:0,offY:0,viewW:n,viewH:t}}function qs(e,n,t,o,r,i){const s=e.general,c=e.camera,a=c&&c.eye?kr(c.eye):[0,0,0],f=c&&c.center?kr(c.center):[0,0,-1],l=c&&c.up?kr(c.up):[0,1,0];if(Vs(e)){const v=t>0?n/t:1.7777777777777777,_=Kn(s.fov,50),w=Math.max(Kn(s.nearz,.01),1e-4),L=Math.max(Kn(s.farz,1e4),w+1),F=Hs(a,f,l),D=js(_,v,w,L);return{view:F,projection:D,eye:a,center:f,projW:v,projH:1,offX:0,offY:0,viewW:v,viewH:1,perspective:!0}}const d=rn(),h=s&&s.orthogonalprojection&&s.orthogonalprojection.width||n,m=s&&s.orthogonalprojection&&s.orthogonalprojection.height||t,M=Nr(o,h,m,n,t,r,i),g=e&&e.cameraTransforms?e.cameraTransforms.zoom:s&&s.zoom,y=g&&typeof g=="object"?g.value:g,b=Number(y);if(Number.isFinite(b)&&b>0&&Math.abs(b-1)>1e-6){const v=M.offX+M.viewW/2,_=M.offY+M.viewH/2,w=M.viewW/b,L=M.viewH/b;M.offX=v-w/2,M.offY=_-L/2,M.viewW=w,M.viewH=L}const p=vn(M.offX,M.offX+M.viewW,M.offY+M.viewH,M.offY,-1e4,1e4);return{view:d,projection:p,eye:a,projW:h,projH:m,offX:M.offX,offY:M.offY,viewW:M.viewW,viewH:M.viewH,perspective:!1}}function _o(e){const n=Number(e);return Number.isFinite(n)?n<0?0:n>1?1:n:.5}function kr(e){return String(e).trim().split(/\s+/).map(Number)}function To(e){const n=Math.hypot(e[0],e[1],e[2])||1;return[e[0]/n,e[1]/n,e[2]/n]}function So(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 sn(e){const n=Number(e);return Number.isFinite(n)?n*.5:0}function Zs(e){const n=new Map,t=new Map,o=/^[ \t]*#define[ \t]+([A-Za-z_][A-Za-z0-9_]*)(?:\(([^)]*)\))?[ \t]*(.*)$/gm;let r;for(;(r=o.exec(e))!==null;){const i=s=>s.replace(/\/\/.*$/,"").replace(/\/\*[\s\S]*?\*\//g,"").trim();r[2]!==void 0?t.set(r[1],{args:r[2].split(",").map(s=>s.trim()).filter(Boolean),body:i(r[3])}):n.set(r[1],i(r[3]))}return{defs:n,fns:t}}function Ks(e,n,t,o){const r=[];let i=0;for(;i<e.length;){const s=e.indexOf(n,i);if(s===-1){r.push(e.slice(i));break}r.push(e.slice(i,s));let a=s+n.length;for(;a<e.length&&/\s/.test(e[a]);)a++;if(e[a]!=="("){r.push(e.slice(s,a)),i=a;continue}let f=0,l=a;for(;l<e.length;l++)if(e[l]==="(")f++;else if(e[l]===")"&&(f--,f===0))break;if(l>=e.length){r.push(e.slice(s));break}const d=e.slice(a+1,l),h=St(d);let m=t.body;t.args.forEach((M,g)=>{const y=h[g]!==void 0?h[g].trim():"";m=wn(m,M,y)}),o>0&&(m=Eo(m,o-1)),r.push("("+m+")"),i=l+1}return r.join("")}function wn(e,n,t){return e.replace(new RegExp("\\b"+n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+"\\b","g"),t)}function St(e){const n=[];let t=0,o="";for(let r=0;r<e.length;r++){const i=e[r];i==="("?t++:i===")"&&t--,i===","&&t===0?(n.push(o),o=""):o+=i}return o.trim()!==""&&n.push(o),n}function Eo(e,n){for(let t=0;t<12;t++){const{defs:o,fns:r}=Zs(e);if(o.size===0&&r.size===0)break;const i=e.split(`
2
- `);let s=!1;for(let c=0;c<i.length;c++){const a=i[c];if(/^[ \t]*#/.test(a))continue;let f=a;for(const[l,d]of o)new RegExp("\\b"+l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+"\\b").test(f)&&(f=wn(f,l,d),s=!0);for(const[l,d]of r)f.includes(l)&&(f=Ks(f,l,d,n),s=!0);i[c]=f}if(e=i.join(`
3
- `),!s)break}return e}function Po(e,n,t){const o=m=>n[m]!==void 0?String(n[m]):t.has(m)?"("+t.get(m)+")":"0";let r=e.replace(/\b[A-Za-z_][A-Za-z0-9_]*\b/g,m=>o(m)),i=0;function s(){for(;i<r.length&&/\s/.test(r[i]);)i++}function c(){let m=a();for(s();r.startsWith("||",i);){i+=2;const M=a();m=m||M,s()}return m}function a(){let m=f();for(s();r.startsWith("&&",i);){i+=2;const M=f();m=m&&M,s()}return m}function f(){let m=l();for(s();r.startsWith("==",i)||r.startsWith("!=",i);){const M=r[i]==="="?"==":"!=";i+=2;const g=l();m=M==="=="?m===g:m!==g,s()}return m}function l(){let m=d();for(s();/^[<>]/.test(r[i]||"");){let M=r[i];r[i+1]==="="&&(M+="=",i++),i++;const g=d();M==="<"?m=m<g:M===">"?m=m>g:M==="<="?m=m<=g:m=m>=g,s()}return m}function d(){return s(),r[i]==="!"?(i++,!d()):h()}function h(){if(s(),r[i]==="("){i++;const M=c();return s(),i++,M}const m=/^-?\d+(\.\d+)?/.exec(r.slice(i));return m?(i+=m[0].length,Number(m[0])):!1}return c()}function Co(e){let n="",t=0;const o=e.length;for(;t<o;){const r=e[t],i=e[t+1];if(r==="/"&&i==="*"){for(t+=2;t<o&&!(e[t]==="*"&&e[t+1]==="/");)e[t]===`
1
+ (function(Je,Wt){typeof exports=="object"&&typeof module<"u"?Wt(exports):typeof define=="function"&&define.amd?define(["exports"],Wt):(Je=typeof globalThis<"u"?globalThis:Je||self,Wt(Je.WebWallGL={}))})(this,function(Je){"use strict";function Wt(e,n){const t=n?.renderDpr??e.cfg?.renderDpr??1;return Math.min(window.devicePixelRatio||1,t)}function dn(e){return e==="fit"?"contain":e==="fill"?"cover":e==="contain"||e==="stretch"?e:"cover"}function Mo(e){const n=dn(e);return n==="contain"?{objectFit:"contain",background:"rgba(10,12,16,0.85)"}:n==="stretch"?{objectFit:"fill",background:"transparent"}:{objectFit:"cover",background:"transparent"}}function Ts(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 rn(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,Rs(),Ao(e)}function Ss(e){try{rn(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 Es=new TextDecoder,pt=e=>Es.decode(e).replace(/^\uFEFF/,""),_o=500;function An(e,n){const t=e.frameMeter.stamps;t.push(n),e.frameMeter.last=n;const r=n-_o;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 Ao(e){e.frameMeter.stamps.length=0,e.frameMeter.last=0,e.frameMeter.fps=0}function Ps(e){return!e.frameMeter.last||e.paused?{fps:0,running:!1}:performance.now()-e.frameMeter.last>Math.max(_o,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 Pr(e){e.coverAlign.x=e.coverAlign.y=e.coverAlign.tx=e.coverAlign.ty=.5,Cs(e)}function Cs(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 Ls=["__scene","__sceneLayers","__textures","__objScripts","__textWidgets","__mediaHooks","__mediaControl","__mediaStats","__mediaSet","__system","__liveSystem","__audioStats","__audioMute","__particleStats","__particleToggle","__pointerStats","__compositeStats","__compositeEnable"];function Rs(){const e=window;for(const n of Ls)n in e&&delete e[n]}function To(e,n,t){const r=Wt(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 ks(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=So(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=Ns(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 Cr(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 Fs(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 So(e,n,t){let r="";for(let o=n;o<n+t;o++)r+=String.fromCharCode(e[o]);return r}function Ns(e,n,t){try{return new TextDecoder("utf-8",{fatal:!0}).decode(e.subarray(n,n+t))}catch{return So(e,n,t)}}const Us=Object.freeze(Object.defineProperty({__proto__:null,getEntry:Cr,parsePkg:ks,verifyLayout:Fs},Symbol.toStringTag,{value:"Module"})),Lr={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"},Vt={UNKNOWN:-1,JPEG:2,PNG:13,GIF:25,WEBP:35,MP4:35};function Ds(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===Vt.PNG)return{width:t.width,height:t.height,png:t.data};if(e.freeImageFormat!==Vt.UNKNOWN)return{width:t.width,height:t.height,image:t.data,fif:e.freeImageFormat};const r=Rr(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:Eo(r,t.width,t.height,e.width,e.height)}:{width:t.width,height:t.height,rgba:r}}function Bs(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!==Vt.UNKNOWN){t.push({width:r.width,height:r.height,image:r.data,fif:e.freeImageFormat});continue}const o=Rr(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:Eo(t[0].rgba,t[0].width,t[0].height,e.width,e.height)}),t}function Eo(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 Rr(e,n,t,r){switch(e){case 0:return Is(n,t,r);case 1:return Os(n,t,r);case 2:return $s(n,t,r);case 4:return Hs(n,t,r);case 6:return Vs(n,t,r);case 7:return Ws(n,t,r);case 8:return js(n,t,r);case 9:return zs(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: "+(Lr[e]||e))}}function Is(e,n,t){return new Uint8Array(e.buffer,e.byteOffset,n*t*4).slice()}function Os(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 $s(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 js(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 zs(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 Ws(e,n,t){return kr(e,n,t,!0,0)}function Vs(e,n,t){return kr(e,n,t,!1,3)}function Hs(e,n,t){return kr(e,n,t,!1,5)}function kr(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=Xs(a,r),p=Gs(a,r),d=o===3?Ys(a):o===5?qs(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 Po(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 Xs(e,n){const t=n?0:8,r=Po(e,t),o=Po(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 Gs(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 Ys(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 qs(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 Co(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 Fe(e,n){return(e[n]|e[n+1]<<8|e[n+2]<<16|e[n+3]<<24)>>>0}function Lo(e,n){return Fe(e,n)|0}const Tn=new DataView(new ArrayBuffer(4));function Ht(e,n){return Tn.setUint8(0,e[n]),Tn.setUint8(1,e[n+1]),Tn.setUint8(2,e[n+2]),Tn.setUint8(3,e[n+3]),Tn.getFloat32(0,!0)}function Zs(e){let n=0;const t=er(e,n,9);if(n+=9,t!=="TEXV0005\0")throw new Error("\u4E0D\u662F .tex \u6587\u4EF6: "+t);const r=er(e,n,9);if(n+=9,r!=="TEXI0001\0")throw new Error("\u672A\u77E5 TEXI \u5B50\u5BB9\u5668: "+r);const o=Fe(e,n);n+=4;const i=Fe(e,n);n+=4;const s=Fe(e,n);n+=4;const a=Fe(e,n);n+=4;const c=Fe(e,n);n+=4;const u=Fe(e,n);n+=4,n+=4;const l=er(e,n,9);n+=9;const f=Fe(e,n);n+=4;let p=Vt.UNKNOWN,d=0;if(l==="TEXB0004\0"){p=Fe(e,n)|0,n+=4;const v=Fe(e,n);n+=4,p===Vt.UNKNOWN&&v===1&&(p=Vt.MP4),d=v===1?4:3}else if(l==="TEXB0003\0")p=Fe(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===Vt.MP4,x=[];for(let v=0;v<f;v++){const A=Fe(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=Fe(e,n);n+=4;const N=Fe(e,n);n+=4;let j=0,H=0;d>=2&&(j=Fe(e,n),n+=4,H=Lo(e,n),n+=4);const K=Lo(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 V=O;j===1&&(V=Co(O,H)),_.push({width:L,height:N,compression:j,data:V})}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=er(e,n,9);if(v.indexOf("TEXS")===0){let A=n+9;const _=Fe(e,A);A+=4;let R=0,L=0;v==="TEXS0003\0"&&(R=Fe(e,A),A+=4,L=Fe(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 V=A+O*j;if(V+32>e.length)break;const X=Ht(e,V+8),ie=Ht(e,V+12),J=Ht(e,V+16),Z=Ht(e,V+20),te=Ht(e,V+24),le=Ht(e,V+28);H.push({imageId:Ht(e,V)|0,duration:Ht(e,V+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 V=[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(...V)>=-1&&Math.max(...V)<=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:Lr[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 er(e,n,t){let r="";for(let o=n;o<n+t;o++)r+=String.fromCharCode(e[o]);return r}const Ks=Object.freeze(Object.defineProperty({__proto__:null,FIF:Vt,TEXTURE_FORMATS:Lr,decodeMip0:Ds,decodeMips:Bs,decodePixels:Rr,lz4Decompress:Co,parseTex:Zs},Symbol.toStringTag,{value:"Module"}));function Ro(e,n){if(!e||typeof n!="string")return null;const t=e[n];return t&&typeof t=="object"?t:null}function Fr(e){return typeof e=="string"?e:e&&typeof e=="object"&&typeof e.name=="string"?e.name:null}function Qs(e,n){return tr(e)&&tr(n)?Number(e)===Number(n):String(e)===String(n)}function Nr(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 Js(e){switch(e.type){case"bool":return"bool";case"slider":return"num";case"color":return"num";case"textinput":return"text";default:return Nr(e.value)}}function ko(e,n){if(e===null||typeof e!="object")return e;if(e.user&&typeof e.user=="object"&&typeof e.user.name=="string"){const r=Ro(n,e.user.name);if(!r||r.value===void 0||r.value===null)return e.value;const o=r.type==="combo"?Ur(r.value,r.options):r.value;return Qs(o,e.user.condition)}if(typeof e.user!="string")return e;const t=Ro(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(Nr(e.value)==="bool"&&t.type==="slider"){const r=Number(t.value);return Number.isFinite(r)?r!==0:e.value}return Nr(e.value)===Js(t)?t.value:e.value}function pn(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]=pn(e[r],n,t+1);return e}if(Fr(e.user)){let r=ko(e,n);for(let o=0;o<8&&r!==null&&typeof r=="object"&&Fr(r.user);o++)r=ko(r,n);return e.value=pn(r,n,t+1),e}for(const r of Object.keys(e))e[r]=pn(e[r],n,t+1);return e}function ea(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 tr(e){return typeof e=="number"?Number.isInteger(e):typeof e=="string"&&/^-?\d+$/.test(e.trim())}function Ur(e,n){const t=ea(n);return!(t.length>0?t.every(tr):tr(e))||typeof e=="number"&&Number.isFinite(e)?e:typeof e=="string"&&/^-?\d+$/.test(e.trim())?Number(e):e}function ta(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"?Ur(r.value,r.options):r.value);return n}function Tt(e){return e&&typeof e=="object"?Fr(e.user):null}function na(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"?Ur(u.value,u.options):u.value;i[s]=l,r[s]=l}else i[s]=c,r[s]=c}return r}function hn(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 Sn(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 nr(e){return e==null?[1,1,1]:typeof e=="string"?hn(e):typeof e=="object"&&e!==null?hn(e.value):[1,1,1]}function rt(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 Dr(e){return e?!e.image&&!e.model&&!e.particle&&e.text==null&&!e.size:!1}function Br(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 ra(e,n){const t=n&&n.general&&n.general.properties||{},r=e.objects||[];pn(r,t,0),pn(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:hn(m.origin||"0 0 0"),scale:hn(m.scale||"1 1 1"),angles:hn(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)&&Dr(_)),j=Br(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=>rt(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=Sn(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:rt(m.startsilent,!1),maxtime:ft(m.maxtime,0),mintime:ft(m.mintime,0),spatialization:rt(m.spatialization,!1),muteineditor:rt(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:nr(m.color),textAnchor:typeof m.anchor=="string"&&m.anchor!=="none"?m.anchor:"center",textMaxwidth:ft(m.maxwidth,0),textMaxrows:ft(m.maxrows,0),textLimitwidth:rt(m.limitwidth,!1),textLimitrows:rt(m.limitrows,!1),textLimituseellipsis:rt(m.limituseellipsis,!1),textHAlign:m.horizontalalign||"center",textVAlign:m.verticalalign||"center",textSpacing:m.spacing?Sn(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:rt(m.opaquebackground,!1),textBackgroundcolor:nr(m.backgroundcolor),textBackgroundbrightness:ft(m.backgroundbrightness,1),textCastshadow:rt(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:rt(_.visible,!0),additive:rt(_.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:Dr(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:nr(m.color),alpha:ft(m.alpha,1),brightness:ft(m.brightness,1),copybackground:!!m.copybackground,colorBlendMode:m.colorBlendMode||0,parallaxDepth:m.parallaxDepth!==void 0?Sn(m.parallaxDepth):null,effects:(m.effects||[]).map(_=>({file:_.file||"",name:typeof _.name=="string"?_.name:"",visible:rt(_.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 oa(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 ia(e,n){!e||!n||typeof n!="object"||e.isContainer||n.solidlayer===!0&&(e.solid=!0)}function sa(e){return!e||typeof e.material!="string"?null:{materialPath:e.material,autosize:!!e.autosize,cropoffset:e.cropoffset?Sn(e.cropoffset):null}}function aa(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=Br({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 ca(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 la=Object.freeze(Object.defineProperty({__proto__:null,applySolidFromModel:ia,collectTransformDirty:ca,composeChildTransform:Br,isRenderInert:Dr,parseBool:rt,parseColor:nr,parseNum:ft,parseScene:ra,parseVec2:Sn,parseVec3:hn,recomposeWorld:aa,recomputeLayerVisibility:oa,resolveMaterial:sa},Symbol.toStringTag,{value:"Module"}));function ua(e,n,t){const r=Cr(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=Cr(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 fa={"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 Fo(e){if(!e||typeof e!="string")return!0;const n=e.toLowerCase();return n==="generic"||n==="sprite"||n==="flat"||n.startsWith("genericimage")}function da(e,n){return!e||!n||!n.shader||Fo(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 pa=Object.freeze(Object.defineProperty({__proto__:null,BUILTIN_MATERIALS:{"materials/util/solidlayer.json":{passes:[{shader:"flat",blending:"translucent",cullmode:"nocull",depthtest:"disabled",depthwrite:"disabled",textures:[],combos:{}}]}},BUILTIN_MODELS:fa,attachLayerMaterialEffect:da,isBuiltinAlbedoShader:Fo,resolveEffectChain:ua},Symbol.toStringTag,{value:"Module"}));function mn(){return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function St(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 gn(e,n,t,r,o,i){const s=mn();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 bn(e,n,t,r){return St(e,new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,n,t,r,1]))}function No(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 En(e,n,t,r){return St(e,new Float32Array([n,0,0,0,0,t,0,0,0,0,r,0,0,0,0,1]))}function Uo(e,n){const t=Math.cos(n),r=Math.sin(n);return St(e,new Float32Array([t,r,0,0,-r,t,0,0,0,0,1,0,0,0,0,1]))}function ha(e,n){const t=Math.cos(n),r=Math.sin(n);return St(e,new Float32Array([1,0,0,0,0,t,r,0,0,-r,t,0,0,0,0,1]))}function ma(e,n){const t=Math.cos(n),r=Math.sin(n);return St(e,new Float32Array([t,0,-r,0,0,1,0,0,r,0,t,0,0,0,0,1]))}function ga(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 rr(e,n){const t=e&&typeof e=="object"?e.value:e;return typeof t=="number"&&Number.isFinite(t)?t:n}function ba(e){const n=e&&e.general;return!n||n.orthogonalprojection?!1:rr(n.fov,0)>0}function ya(e,n){return n&&n.perspective&&e&&e.isSkybox&&n.eye?n.eye:e.origin}function va(e,n,t){const r=Bo([e[0]-n[0],e[1]-n[1],e[2]-n[2]]),o=Bo(Io(t,r)),i=Io(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 xa(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 wa=[[16,9],[16,10],[21,9],[32,9]];function Ma(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 wa){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 Ir(e,n,t,r,o,i,s){const a=Do(i),c=Do(s);if(e==="cover"){const u=Ma(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 _a(e,n,t,r,o,i){const s=e.general,a=e.camera,c=a&&a.eye?Or(a.eye):[0,0,0],u=a&&a.center?Or(a.center):[0,0,-1],l=a&&a.up?Or(a.up):[0,1,0];if(ba(e)){const g=t>0?n/t:1.7777777777777777,v=rr(s.fov,50),A=Math.max(rr(s.nearz,.01),1e-4),_=Math.max(rr(s.farz,1e4),A+1),R=va(c,u,l),L=ga(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=mn(),p=s&&s.orthogonalprojection&&s.orthogonalprojection.width||n,d=s&&s.orthogonalprojection&&s.orthogonalprojection.height||t,y=Ir(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=gn(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 Do(e){const n=Number(e);return Number.isFinite(n)?n<0?0:n>1?1:n:.5}function Or(e){return String(e).trim().split(/\s+/).map(Number)}function Bo(e){const n=Math.hypot(e[0],e[1],e[2])||1;return[e[0]/n,e[1]/n,e[2]/n]}function Io(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 yn(e){const n=Number(e);return Number.isFinite(n)?n*.5:0}function Aa(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 Ta(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=Nt(f);let d=t.body;t.args.forEach((y,x)=>{const m=p[x]!==void 0?p[x].trim():"";d=Pn(d,y,m)}),r>0&&(d=Oo(d,r-1)),o.push("("+d+")"),i=l+1}return o.join("")}function Pn(e,n,t){return e.replace(new RegExp("\\b"+n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+"\\b","g"),t)}function Nt(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 Oo(e,n){for(let t=0;t<12;t++){const{defs:r,fns:o}=Aa(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=Pn(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=Ta(f,p,d,n),c=!0)}i[u]=f}if(e=i.join(`
3
+ `),!c)break}return e}function $o(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 jo(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
- `),t++;t+=2;continue}if(r==="/"&&i==="/"){for(;t<o&&e[t]!==`
6
- `;)t++;continue}n+=r,t++}return n}function Ro(e,n,t,o){const r=e.split(`
7
- `),i=[],s=[],c=new Map;for(let a=0;a<r.length;a++){const f=r[a],l=f.trim();if(l.startsWith("#include")){if(Mn(s)){const d=/^#include[ \t]+"([^"]+)"|^#include[ \t]+<([^>]+)>/.exec(l),h=d&&(d[1]||d[2]),m=h&&t?t(h):null;m!=null?i.push(Ro(Co(m),n,t)):i.push("// [include \u7F3A\u5931: "+h+"]")}continue}if(l.startsWith("#define")){if(Mn(s)){i.push(f);const d=/^#define[ \t]+([A-Za-z_][A-Za-z0-9_]*)(?:\([^)]*\))?[ \t]*(.*)$/.exec(l);d&&c.set(d[1],d[2].trim())}continue}if(l.startsWith("#undef")){Mn(s)&&i.push(f);continue}if(l.startsWith("#ifdef")||l.startsWith("#ifndef")||l.startsWith("#if")){const d=Mn(s);let h=!1;if(l.startsWith("#ifdef")){const m=l.slice(6).trim().split(/\s+/)[0];h=n[m]!==void 0||c.has(m)}else if(l.startsWith("#ifndef")){const m=l.slice(7).trim().split(/\s+/)[0];h=!(n[m]!==void 0||c.has(m))}else try{h=!!Po(l.slice(3).trim(),n,c)}catch{h=!1}s.push({parent:d,hit:h,done:h});continue}if(l.startsWith("#else")){if(s.length>0){const d=s[s.length-1];d.hit=!d.done,d.done=!0}continue}if(l.startsWith("#elif")){if(s.length>0){const d=s[s.length-1];if(d.done)d.hit=!1;else{let h=!1;try{h=!!Po(l.slice(5).trim(),n,c)}catch{h=!1}d.hit=h,d.done=h}}continue}if(l.startsWith("#endif")){s.length>0&&s.pop();continue}l.startsWith("#")||Mn(s)&&i.push(f)}return i.join(`
8
- `)}function Mn(e){return e.every(n=>n.parent&&n.hit)}function Qn(e,n,t,o){let r=0;for(let i=n;i<e.length;i++)if(e[i]===t)r++;else if(e[i]===o&&(r--,r===0))return i;return-1}function Lo(e,n){return Qn(e,n,"(",")")}const Qs=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 Js(e,n){let t=n-1;for(;t>=0&&/[ \t]/.test(e[t]);)t--;if(t<0||t===n-1)return!1;let o=t+1;for(;t>=0&&/[A-Za-z0-9_]/.test(e[t]);)t--;const r=e.slice(t+1,o);return Qs.has(r)}function De(e,n,t){let o="",r=0;for(;r<e.length;){const i=e.indexOf(n,r);if(i===-1){o+=e.slice(r);break}if(i>0&&/[A-Za-z0-9_]/.test(e[i-1])){o+=e.slice(r,i+1),r=i+1;continue}const s=i+n.length;if(s<e.length&&/[A-Za-z0-9_]/.test(e[s])){o+=e.slice(r,s),r=s;continue}if(Js(e,i)){o+=e.slice(r,s),r=s;continue}o+=e.slice(r,i);let c=i+n.length;for(;c<e.length&&/\s/.test(e[c]);)c++;if(e[c]!=="("){o+=e.slice(i,c),r=c;continue}const a=Lo(e,c);if(a===-1){o+=e.slice(i);break}const f=e.slice(c+1,a);o+=t(f,i),r=a+1}return o}function Fo(e,n,t,o,r){const i=e;e=Co(e);const s={},c=/\[COMBO\][^\n]*?"combo"\s*:\s*"([^"]+)"[^\n]*?"default"\s*:\s*(-?\d+)/g;let a;if(typeof r=="string"&&r){const y=new RegExp(c.source,"g");let b;for(;(b=y.exec(r))!==null;)s[b[1]]=Number(b[2])}for(;(a=c.exec(i))!==null;)s[a[1]]=Number(a[2]);const f={GLSL:1,...s,...t||{}};let l=Ro(e,f,o);l=Eo(l,20),l=l.replace(/^[ \t]*#define[^\n]*\n?/gm,"");{const y=new Set,b=/\[COMBO\][^\n]*"combo"\s*:\s*"([^"]+)"/g;let p;for(;(p=b.exec(i))!==null;)y.add(p[1]);for(const v of Object.keys(f))y.add(v);y.delete("GLSL");for(const v of y){const _=f[v]!==void 0?f[v]:0;l=wn(l,v,String(_))}}l=wn(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=De(l,"saturate",y=>"clamp("+y+", 0.0, 1.0)"),l=De(l,"CAST4",y=>"vec4("+y+")"),l=De(l,"CAST3",y=>"vec3("+y+")"),l=De(l,"CAST2",y=>"vec2("+y+")"),l=l.replace(/\b(max|min)\(\s*(-?\d+(?:\.\d+)?)\s*,\s*([A-Za-z_]\w*\.(rgb|xyz|rg|xy|r|x))\s*\)/g,(y,b,p,v,_)=>{const w=_.length;return b+"(vec"+w+"("+p+"), "+v+")"}),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");{const y=new Set,b=/\b(?:uniform\s+)?(?:highp|mediump|lowp\s+)?(?:float|vec2|vec3|vec4|mat2|mat3|mat4)\s+([A-Za-z_][A-Za-z0-9_]*)/g;let p;for(;(p=b.exec(l))!==null;)y.add(p[1]);if(y.size>0){const v=Array.from(y).sort((_,w)=>w.length-_.length).join("|");l=l.replace(new RegExp("(^|[^\\w.])(\\d+)\\s*([+-])\\s*("+v+")(?![A-Za-z0-9_])","g"),"$1$2.0 $3 $4")}}{const y=["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 p of y)l=De(l,p,v=>{const w=St(v).map(L=>{if(b.test(L))return L;const F=[];let D=L.replace(/\[[^\]]*\]/g,B=>(F.push(B),"\0"+(F.length-1)+"\0")).replace(/\b(?:ivec[234]|uvec[234]|int|uint)\s*\([^()]*\)/g,B=>(F.push(B),"\0"+(F.length-1)+"\0"));return D=D.replace(/(?<![A-Za-z0-9_.\u0000])(\d+)(?![.\d])(?![A-Za-z_])/g,"$1.0"),D.replace(/\u0000(\d+)\u0000/g,(B,z)=>F[Number(z)])});return p+"("+w.join(",")+")"});l=De(l,"pow",p=>{const v=St(p);if(v.length!==2)return"pow("+p+")";const _=v[0].trim(),w=v[1].trim(),L=/\.(xyzw|rgba|xyz|rgb|xy|rg|zw)\s*$/.exec(_),D=L?{xyzw:4,rgba:4,xyz:3,rgb:3,xy:2,rg:2,zw:2}[L[1]]:0,B=/\bvec[234]\s*\(/.test(w)||/\.(xyzw|rgba|xyz|rgb|xy|rg|zw)\b/.test(w);return D>=2&&!B?"pow("+_+", vec"+D+"("+w+"))":"pow("+_+", "+w+")"})}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 y=new Set,b=/\b(?:vec[234])\s+([A-Za-z_][A-Za-z0-9_]*)/g;let p;for(;(p=b.exec(l))!==null;)y.add(p[1]);if(y.size>0){const v=Array.from(y).sort((_,w)=>w.length-_.length).join("|");l=l.replace(new RegExp("\\b("+v+")\\s*([+-])\\s*(\\d+)(?![\\d.])","g"),"$1 $2 $3.0")}}{const y=new Set,b=/\b(?:int|uint)\s+([A-Za-z_][A-Za-z0-9_]*)/g;let p;for(;(p=b.exec(l))!==null;)y.add(p[1]);l=l.replace(/\buint\b/g,"int"),l=l.replace(/\b([A-Za-z_][A-Za-z0-9_]*)\s*%\s*(\d+)(?![\d.])/g,(v,_,w)=>y.has(_)?v:"mod("+_+", "+w+".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,(y,b,p,v)=>{const _=v.trim();return/^(vec[234]|mat[234]|int\b|float\b)/.test(_)?y:b+" "+p+" = "+b+"("+_+");"});for(const y of["mix","clamp","step","smoothstep","min","max","mod","pow"])l=De(l,y,b=>y+"("+b.replace(/(?<![A-Za-z0-9_.])(\d+)(?![.\d])/g,"$1.0")+")");l=De(l,"clamp",y=>{const b=St(y);if(b.length!==3)return"clamp("+y+")";const p=b[0].trim(),v=b[1].trim(),_=w=>/^-?\d+\.?\d*$/.test(w);return _(p)&&_(v)&&Number(p)===0&&Number(v)===1?"clamp("+b[2].trim()+", "+p+", "+v+")":"clamp("+y+")"}),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=De(l,"smoothstep",y=>{const b=St(y);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("+y+")"});{const y=new Map,b=/\b(?:uniform|varying|attribute|in|out)?\s*\b(vec([234]))\s+([A-Za-z_]\w*)/g;let p;for(;(p=b.exec(l))!==null;)y.set(p[3],Number(p[2]));if(y.size>0){const v={2:"xy",3:"xyz",4:"xyzw"};l=l.replace(/(^|[;{}\n]\s*)([A-Za-z_]\w*)\s*=\s*([A-Za-z_]\w*)\s*;/g,(_,w,L,F)=>{const D=y.get(L),B=y.get(F);return!D||!B||D>=B?_:w+L+" = "+F+"."+v[D]+";"})}if(y.size>0){const v=new Set,_=/\b(?:uniform|varying|attribute|in|out)?\s*\bfloat\s+([A-Za-z_]\w*)/g;let w;for(;(w=_.exec(l))!==null;)v.add(w[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",F=/^(?:length|distance|dot)$/,D=z=>{const V=z.match(new RegExp("^(?:"+L+")\\s*\\("));if(!V)return!1;let Y=0;const Z=V[0].length-1;let X=-1;for(let H=Z;H<z.length;H++)if(z[H]==="(")Y++;else if(z[H]===")"&&(Y--,Y===0)){X=H;break}if(X!==z.length-1)return!1;const q=V[0].replace(/\s*\($/,"");if(F.test(q))return!0;const oe=z.slice(Z+1,X);if(/\bvec[234]\s*\(/.test(oe)||/\.[xyzwrgba]{2,4}\b/.test(oe))return!1;for(const H of y.keys()){const j=H.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp("(?<!\\.)\\b"+j+"\\b(?!\\s*\\.[xyzwrgba]\\b)").test(oe))return!1}return!0},B=new Set;if(l=l.replace(/(^|[;{}\n]\s*)([A-Za-z_]\w*)\s*=\s*([^;]+);/g,(z,V,Y,Z)=>{const X=y.get(Y);if(!X)return z;const q=Z.trim();if(new RegExp("^vec"+X+"\\s*\\(").test(q)||y.has(q))return z;const oe=/^-?\d+(?:\.\d+)?(?:e[-+]?\d+)?$/i.test(q),H=v.has(q);return!oe&&!H&&!D(q)?z:(B.add(Y),V+Y+" = vec"+X+"("+q+");")}),B.size>0){const z=[...B].sort((V,Y)=>Y.length-V.length).join("|");l=l.replace(new RegExp(`\\b([A-Za-z_]\\w*)\\s*([*/])\\s*(${z})\\b`,"g"),(V,Y,Z,X)=>y.has(Y)?V:`${Y} ${Z} ${X}.x`),l=l.replace(new RegExp(`\\b(${z})\\s*([*/])\\s*([A-Za-z_]\\w*)\\b`,"g"),(V,Y,Z,X)=>y.has(X)?V:`${Y}.x ${Z} ${X}`)}}}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,(y,b,p,v)=>b==="float"?`${b} ${p} = ${v}.0;`:`${b} ${p} = ${b}(${v}.0);`);{const y=new Set,b=/\b(?:uniform|varying|attribute|in|out)?\s*\bfloat\s+([A-Za-z_]\w*)/g;let p;for(;(p=b.exec(l))!==null;)y.add(p[1]);if(y.size>0){const v=[...y].sort((_,w)=>w.length-_.length).join("|");l=l.replace(new RegExp(`\\b(${v})\\s*=\\s*(-?\\d+)\\s*;`,"g"),"$1 = $2.0;"),l=l.replace(new RegExp(`\\b(${v})\\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");{const y=new Set,b=/\bbool\s+([A-Za-z_]\w*)\s*=/g;let p;for(;(p=b.exec(l))!==null;)y.add(p[1]);if(y.size>0){const v=[...y].join("|");l=l.replace(new RegExp(`([-+*/]=\\s*)(${v})\\b`,"g"),(_,w,L)=>`${w}float(${L})`)}}{const y=new Set;for(const b of l.matchAll(/\b(?:uniform\s+)?(?:highp|mediump|lowp\s+)?float\s+([A-Za-z_]\w*)\s*\[/g))y.add(b[1]);if(y.size){const b=[...y].sort((L,F)=>F.length-L.length).join("|"),p=new RegExp("\\b("+b+")\\s*\\[","g");let v="",_=0,w;for(;w=p.exec(l);){const L=w.index+w[0].length-1,F=Qn(l,L,"[","]");if(F<0)break;let D=F+1;for(;D<l.length&&/[ \t]/.test(l[D]);)D++;if(l[D]!=="["){p.lastIndex=F+1;continue}const B=Qn(l,D,"[","]");if(B<0)break;const z=l.slice(L+1,F),V=l.slice(D+1,B);v+=l.slice(_,w.index),v+=w[1]+"[int(("+z+")) * 4 + int(("+V+"))]",_=B+1,p.lastIndex=_}l=v+l.slice(_)}}l=De(l,"mix",(y,b)=>{const p=St(y);if(p.length!==3)return"mix("+y+")";const v=D=>{const B=D.trim(),z=/\.([xyzwrgba]{1,4})\s*$/.exec(B);if(z)return z[1].length;const V=/^vec([234])\s*\(/.exec(B);if(V)return Number(V[1]);if(!/^[A-Za-z_]\w*$/.test(B))return 0;const Y=new RegExp("\\b(vec([234])|float)\\s+"+B+"\\b","g");let Z=0,X;for(;(X=Y.exec(l))!==null&&X.index<b;)Z=X[1].startsWith("vec")?Number(X[2]):1;return Z},_=p[0].trim(),w=p[1].trim(),L=v(_),F=v(w);if(L>=2&&F>=2&&L!==F){const D=Math.min(L,F),B=D===2?".xy":D===3?".xyz":"";return B?"mix("+(L>D?_+B:_)+", "+(F>D?w+B:w)+", "+p[2].trim()+")":"mix("+y+")"}return"mix("+y+")"});{const y=/\b(vec([234]))\s+([A-Za-z_]\w*)\s*\(/g;let b="",p=0,v;for(;v=y.exec(l);){const _=Lo(l,v.index+v[0].length-1);if(_<0)break;let w=_+1;for(;w<l.length&&/\s/.test(l[w]);)w++;if(l[w]!=="{")continue;const L=Qn(l,w,"{","}");if(L<0)break;const F=Number(v[2]);if(F>=4){y.lastIndex=L;continue}let D=l.slice(w+1,L);const B=new Map;for(const V of l.slice(0,v.index).matchAll(/\buniform\s+(?:highp|mediump|lowp\s+)?(vec([234]))\s+([A-Za-z_]\w*)/g))B.set(V[3],Number(V[2]));for(const V of D.matchAll(/\b(vec([234]))\s+([A-Za-z_]\w*)/g))B.set(V[3],Number(V[2]));const z=F===2?"xy":"xyz";D=D.replace(/\breturn\s+([A-Za-z_]\w*)\s*;/g,(V,Y)=>{const Z=B.get(Y);return Z&&Z>F?"return "+Y+"."+z+";":V}),b+=l.slice(p,w+1)+D,p=L,y.lastIndex=L}l=b+l.slice(p)}const h=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;)h.add(M[1]);if(l=De(l,"mul",y=>{const b=St(y);if(b.length!==2)return"mul("+y+")";const p=b[0].trim(),v=b[1].trim(),_=w=>h.has(w.split(/[\[.\s]/)[0])||/^mat[234]\(/.test(w);return _(p)&&_(v)?"(transpose("+v+") * transpose("+p+"))":_(v)?"(transpose("+v+") * "+p+")":"("+p+" * "+v+")"}),l=l.replace(/\blerp\b/g,"mix").replace(/\bfrac\b/g,"fract"),l=De(l,"atan2",y=>"atan("+y+")"),l=De(l,"fmod",y=>{const b=St(y);if(b.length!==2)return"mod("+y+")";const p=b[0].trim(),v=b[1].trim();return"(("+p+") - ("+v+") * trunc(("+p+") / ("+v+")))"}),l=De(l,"ddx",y=>"dFdx("+y+")"),l=De(l,"ddy",y=>"dFdy("+y+")"),l=De(l,"CAST3X3",y=>"mat3("+y+")"),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 r=="string"&&r){const p=new Map,v=/^\s*(?:varying|out)\s+(?:highp|mediump|lowp\s+)?(vec[234]|float)\s+([A-Za-z_]\w*)\s*;/gm;let _;for(;(_=v.exec(r))!==null;)p.set(_[2],_[1]);const w={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,(F,D,B,z,V,Y)=>{const Z=p.get(V);return!Z||w[Z]<=w[B]?F:(L.set(V,w[B]),D+Z+z+V+Y)}),L.size>0){const F={1:"x",2:"xy",3:"xyz"};for(const[D,B]of L){const z=F[B];z&&(l=l.split(`
9
- `).map(V=>/^\s*in\s/.test(V)?V:V.replace(new RegExp("\\b"+D+"\\b(?!\\s*[.\\w])","g"),D+"."+z)).join(`
10
- `))}}}{const p=new Map,v=/^\s*in\s+(?:highp|mediump|lowp\s+)?(vec[34])\s+([A-Za-z_]\w*)\s*;/gm;let _;for(;(_=v.exec(l))!==null;)p.set(_[2],Number(_[1].slice(3)));const w=new Map(p),L=/\b(vec[34])\s+([A-Za-z_]\w*)\s*[=;]/g;for(;(_=L.exec(l))!==null;)w.has(_[2])||w.set(_[2],Number(_[1].slice(3)));if(w.size>0){const F=D=>{const B=D.trim();if(!B)return D;const z=/^([A-Za-z_]\w*)$/.exec(B);if(z&&w.has(z[1]))return z[1]+".xy";const V=/^([A-Za-z_]\w*)(\s*[+\-].+)$/.exec(B);return V&&w.has(V[1])?"("+V[1]+".xy"+V[2]+")":D};for(const D of["textureLod","texture"])l=De(l,D,B=>{const z=St(B);return z.length>=2&&(z[1]=F(z[1])),D+"("+z.join(", ")+")"})}p.size>0&&(l=l.split(`
11
- `).map(F=>{if(!/\bvec2\s+[A-Za-z_]\w*\s*=/.test(F))return F;let D=F;for(const B of p.keys())D=D.replace(new RegExp("\\b"+B+"\\b(?!\\s*[.\\w])","g"),B+".xy");return D}).join(`
12
- `))}const y=new Set,b=new Set;{const p=/^\s*in\s+(?:highp|mediump|lowp\s+)?(vec[234]|float)\s+([A-Za-z_]\w*)\s*;/gm;let v;for(;(v=p.exec(l))!==null;)b.add(v[2])}for(const p of b)new RegExp("\\b"+p+"\\b\\s*(?:\\.[xyzwrgba]{1,4})?\\s*(?:[-+*/]?=(?!=)|\\+\\+|--)").test(l)&&y.add(p);if(y.size>0){const p=l.search(/\bvoid\s+main\s*\([^)]*\)\s*\{/);if(p!==-1){const v=l.indexOf("{",p),_=l.slice(0,v+1);let w=l.slice(v+1);const L=[];for(const F of y){const D=new RegExp("^\\s*in\\s+(?:highp|mediump|lowp\\s+)?(vec[234]|float)\\s+"+F+"\\s*;","m").exec(l),B=D?D[1]:"vec4";L.push(" "+B+" "+F+"_rw = "+F+";"),w=wn(w,F,F+"_rw")}w=`
13
- `+L.map(F=>F.replace(/= (\w+)_rw;/,"= $1;")).join(`
5
+ `),t++;t+=2;continue}if(o==="/"&&i==="/"){for(;t<r&&e[t]!==`
6
+ `;)t++;continue}n+=o,t++}return n}function zo(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(Cn(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(zo(jo(d),n,t)):i.push("// [include \u7F3A\u5931: "+p+"]")}continue}if(l.startsWith("#define")){if(Cn(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")){Cn(s)&&i.push(u);continue}if(l.startsWith("#ifdef")||l.startsWith("#ifndef")||l.startsWith("#if")){const f=Cn(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=!!$o(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=!!$o(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("#")||Cn(s)&&i.push(u)}return i.join(`
8
+ `)}function Cn(e){return e.every(n=>n.parent&&n.hit)}function or(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 or(e,n,"(",")")}const Sa=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 Ea(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 Sa.has(o)}function Vo(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 je(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(Ea(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 Ho(e,n,t,r,o){const i=e;e=jo(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=zo(e,u,r);l=Oo(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=Pn(l,A,String(_))}}l=Pn(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=je(l,"saturate",h=>"clamp("+h+", 0.0, 1.0)"),l=je(l,"CAST4",h=>"vec4("+h+")"),l=je(l,"CAST3",h=>"vec3("+h+")"),l=je(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 V=j[K];if(V==="(")H++;else if(V===")"){if(H--,H===0){K++;break}}else if(H===0&&(V===";"||V===","||V===`
9
+ `))break}for(;K<j.length;K++){const V=j[K];if(V===";"||V===","||V===`
10
+ `||V===")")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=je(l,v,A=>{const R=Nt(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=je(l,"pow",v=>{const A=Nt(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=je(l,h,g=>h+"("+g.replace(/(?<![A-Za-z0-9_.])(\d+)(?![.\d])/g,"$1.0")+")");l=je(l,"clamp",h=>{const g=Nt(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=je(l,"smoothstep",h=>{const g=Nt(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 V=N.indexOf("(");V<N.length;V++)if(N[V]==="(")O++;else if(N[V]===")"&&(O--,O===0))return V===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 V=0;const X=O[0].length-1;let ie=-1;for(let te=X;te<K.length;te++)if(K[te]==="(")V++;else if(K[te]===")"&&(V--,V===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,V,X)=>{const ie=h.get(V);if(!ie||A.has(V))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(V),O+V+" = vec"+ie+"("+J+");")}),H.size>0){const K=[...H].sort((O,V)=>V.length-O.length).join("|");l=l.replace(new RegExp(`\\b([A-Za-z_]\\w*)\\s*([*/])\\s*(${K})\\b`,"g"),(O,V,X,ie)=>h.has(V)?O:`${V} ${X} ${ie}.x`),l=l.replace(new RegExp(`\\b(${K})\\s*([*/])\\s*([A-Za-z_]\\w*)\\b`,"g"),(O,V,X,ie)=>h.has(ie)?O:`${V}.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=Vo(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=Vo(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=or(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=or(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=je(l,"mix",(h,g)=>{const v=Nt(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 V=new RegExp("\\b(vec([234])|float)\\s+"+H+"\\b","g");let X=0,ie;for(;(ie=V.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=or(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,V)=>{const X=H.get(V);return X&&X>N?"return "+V+"."+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=je(l,"mul",h=>{const g=Nt(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=je(l,"atan2",h=>"atan("+h+")"),l=je(l,"fmod",h=>{const g=Nt(h);if(g.length!==2)return"mod("+h+")";const v=g[0].trim(),A=g[1].trim();return"(("+v+") - ("+A+") * trunc(("+v+") / ("+A+")))"}),l=je(l,"ddx",h=>"dFdx("+h+")"),l=je(l,"ddy",h=>"dFdy("+h+")"),l=je(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,V)=>{const X=v.get(O);return!X||R[X]<=R[H]?N:(L.set(O,R[H]),j+X+K+O+V)}),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,V)=>{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+V})}{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=je(l,j,H=>{const K=Nt(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=Pn(R,N,N+"_rw")}L.length>0&&(R=`
15
+ `+L.map(N=>N.replace(/= (\w+)_rw;/,"= $1;")).join(`
14
16
  `)+`
15
- `+w,l=_+w}}}l=l.replace(/\[(?:unroll|loop|branch|flatten)\]\s*/g,""),l=l.replace(/\bstatic\s+/g,"");{const y=new Set;for(const b of l.matchAll(/\b(?:uniform[ \t]+)?(?:highp|mediump|lowp)?[ \t]*float[ \t]+([A-Za-z_]\w*)[ \t]*[;=]/g))y.add(b[1]);if(y.size){const b=p=>{const v=p.trim().startsWith("-"),_=p.replace(/^-\s*/,"").trim();return y.has(_)?(v?"-":"")+"int("+_+")":p};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,(p,v,_,w,L,F,D)=>v+b(w)+L+b(F)+D)}}{const y=new Set;l=l.split(`
16
- `).map(b=>{const p=/^[ \t]*uniform[ \t]+(?:highp|mediump|lowp[ \t]+)?[A-Za-z0-9_]+[ \t]+([A-Za-z_][A-Za-z0-9_]*)/.exec(b);if(!p)return b;const v=p[1];return y.has(v)?"":(y.add(v),b)}).join(`
17
- `)}let g=`#version 300 es
18
- `;return n==="vert"&&(g+=`precision highp float;
19
- `),n==="frag"&&(g+=`precision highp float;
20
- `,/\bgl_FragColor\b/.test(l)&&(g+=`out vec4 fragColor;
21
- `,l=l.replace(/\bgl_FragColor\b/g,"fragColor"))),g+l}const No={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]},ea={2:"multiply",6:"additive",7:"screen",9:"additive",31:"additive"},ta={screen:1,multiply:2},Ur=`#version 300 es
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 Xo={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]},Pa={2:"multiply",6:"additive",7:"screen",9:"additive",31:"additive"},Ca={screen:1,multiply:2},$r=`#version 300 es
22
24
  in vec3 a_Position;
23
25
  in vec2 a_TexCoord;
24
26
  uniform mat4 u_MVP;
@@ -26,7 +28,7 @@ out vec2 v_UV;
26
28
  void main() {
27
29
  gl_Position = u_MVP * vec4(a_Position, 1.0);
28
30
  v_UV = a_TexCoord;
29
- }`,na=`#version 300 es
31
+ }`,La=`#version 300 es
30
32
  precision mediump float;
31
33
  in vec2 v_UV;
32
34
  uniform sampler2D u_Tex;
@@ -42,7 +44,7 @@ void main() {
42
44
  if (u_BlendPrep == 1) c.rgb *= c.a;
43
45
  else if (u_BlendPrep == 2) c.rgb = mix(vec3(1.0), c.rgb, c.a);
44
46
  fragColor = c;
45
- }`,ra=`#version 300 es
47
+ }`,Ra=`#version 300 es
46
48
  precision mediump float;
47
49
  in vec2 v_UV;
48
50
  uniform sampler2D u_Tex;
@@ -53,15 +55,15 @@ void main() {
53
55
  if (u_BlendPrep == 1) c.rgb *= c.a;
54
56
  else if (u_BlendPrep == 2) c.rgb = mix(vec3(1.0), c.rgb, c.a);
55
57
  fragColor = c;
56
- }`,oa=`#version 300 es
58
+ }`,ka=`#version 300 es
57
59
  precision mediump float;
58
60
  in vec2 v_UV;
59
61
  uniform sampler2D u_Tex;
60
62
  out vec4 fragColor;
61
63
  void main() {
62
64
  fragColor = vec4(texture(u_Tex, v_UV).rgb, 1.0);
63
- }`;function ia(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 sa(){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 aa(){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 ca={5126:"float",35664:"vec2",35665:"vec3",35666:"vec4",5124:"int",35667:"ivec2",35668:"ivec3",35669:"ivec4",35670:"bool",35676:"mat4",35675:"mat3"};function Jn(e,n,t){const o=ko(e,e.VERTEX_SHADER,n),r=ko(e,e.FRAGMENT_SHADER,t),i=e.createProgram();if(e.attachShader(i,o),e.attachShader(i,r),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 ko(e,n,t){const o=e.createShader(n);if(e.shaderSource(o,t),e.compileShader(o),!e.getShaderParameter(o,e.COMPILE_STATUS))throw new Error("\u7740\u8272\u5668\u7F16\u8BD1\u5931\u8D25: "+e.getShaderInfoLog(o));return o}function Uo(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 Ir(e,n,t,o,r=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),r?e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,r):e.texImage2D(e.TEXTURE_2D,0,e.RGBA,t,o,0,e.RGBA,e.UNSIGNED_BYTE,n),i}function la(e,n,t=!1){const o=e.createTexture();e.bindTexture(e.TEXTURE_2D,o),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 r=n[0];if(r.bitmap)e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,r.bitmap);else if(t&&r.rgba){const i=r.width*r.height,s=new Uint8Array(i*2);for(let a=0;a<i;a++)s[a*2]=r.rgba[a*4+3],s[a*2+1]=r.rgba[a*4];const c=e.getParameter(e.UNPACK_ALIGNMENT);e.pixelStorei(e.UNPACK_ALIGNMENT,1),e.texImage2D(e.TEXTURE_2D,0,e.RG8,r.width,r.height,0,e.RG,e.UNSIGNED_BYTE,s),e.pixelStorei(e.UNPACK_ALIGNMENT,c)}else e.texImage2D(e.TEXTURE_2D,0,e.RGBA,r.width,r.height,0,e.RGBA,e.UNSIGNED_BYTE,r.rgba);return e.generateMipmap(e.TEXTURE_2D),o}function Br(e,n,t,o,r){const i=1-r;return i*i*i*e+3*i*i*r*n+3*i*r*r*t+r*r*r*o}function ua(e,n,t,o,r){if(r<=e)return 0;if(r>=o)return 1;let i=o-e>1e-9?(r-e)/(o-e):.5;for(let a=0;a<8;a++){const f=Br(e,n,t,o,i)-r;if(Math.abs(f)<1e-6)return i;const l=1-i,d=3*l*l*(n-e)+6*l*i*(t-n)+3*i*i*(o-t);if(Math.abs(d)<1e-9)break;const h=i-f/d;if(h<0||h>1||!Number.isFinite(h))break;i=h}let s=0,c=1;for(let a=0;a<40;a++)i=(s+c)/2,Br(e,n,t,o,i)<r?s=i:c=i;return i}function er(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 B=e[0],z=e[e.length-1],V=t.length-z.frame;if(V>1e-9&&n>z.frame&&n<=t.length)return er([{frame:0,value:z.value,front:z.front,back:z.back},{frame:V,value:B.value,front:B.front,back:B.back}],n-z.frame)}if(n<=e[0].frame)return Number(e[0].value)||0;const o=e[e.length-1];if(n>=o.frame)return Number(o.value)||0;let r=0,i=e.length-1;for(;i-r>1;){const B=r+i>>1;e[B].frame<=n?r=B:i=B}const s=e[r],c=e[i],a=s.frame,f=c.frame,l=Number(s.value)||0,d=Number(c.value)||0,h=f-a;if(h<=0)return d;const m=s.front,M=c.back,g=h/3,y=!!(m&&m.enabled),b=!!(M&&M.enabled),p=y?Math.abs(Number(m.x)||0):1,v=b?Math.abs(Number(M.x)||0):1,_=a+Math.min(p,1.5)*g,w=f-Math.min(v,1.5)*g,L=y?l+(Number(m.y)||0):l+(d-l)/3,F=b?d+(Number(M.y)||0):d-(d-l)/3,D=ua(a,_,w,f,n);return Br(l,L,F,d,D)}function Io(e,n,t){const o=n>0?n:1;if(t==="loop"){let r=e%o;return r<0&&(r+=o),r}if(t==="mirror"){const r=o*2;let i=e%r;return i<0&&(i+=r),i<=o?i:r-i}return Math.max(0,Math.min(o,e))}function fa(e){return Array.isArray(e)?e:typeof e=="string"?e.trim().split(/\s+/).map(Number):Number.isFinite(e)?[e]:[]}function Bo(e){const n=e&&e.options||{},t=Number(n.fps)>0?Number(n.fps):30,o=Number(n.length)>0?Number(n.length):0,r=n.mode==="loop"||n.mode==="mirror"?n.mode:"single",i=typeof n.name=="string"?n.name:"",s=!!(e&&e.relative),c=n.wraploop===!0&&r==="loop",a=[];for(let h=0;;h++){const m=e&&e["c"+h];if(!Array.isArray(m))break;a.push(m)}const f=n.startpaused!==!0,l=[],d={name:i,mode:r,fps:t,relative:s,channelCount:a.length,frame:0,rate:1,playing:f,ended:!1,get frameCount(){return o},play(){return d.playing=!0,d.ended=!1,d},pause(){return d.playing=!1,d},stop(){return d.playing=!1,d.frame=0,d.ended=!1,d},setFrame(h){const m=Number(h);return Number.isFinite(m)&&(d.frame=m),d},getFrame(){return d.frame},setRate(h){const m=Number(h);return Number.isFinite(m)&&(d.rate=m),d},addEndedCallback(h){return typeof h=="function"&&l.push(h),d},setBlend(){return d},setVisible(){return d},advance(h){if(d.playing&&(d.frame+=(Number(h)||0)*t*d.rate,r==="single"))if(d.frame>=o){if(d.frame=o,d.playing=!1,!d.ended){d.ended=!0;for(const m of l)try{m()}catch{}}}else d.frame<0&&(d.frame=0,d.playing=!1)},value(){const h=Io(d.frame,o,r),m=c?{length:o}:void 0;if(a.length===1)return er(a[0],h,m);const M=[];for(const g of a)M.push(er(g,h,m));return M},applyTo(h){const m=d.value();if(!s)return m;const M=fa(h);return Array.isArray(m)?m.map((g,y)=>g+(Number(M[y])||0)):m+(Number(M[0])||0)}};return d}function da(){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 ha=Object.freeze(Object.defineProperty({__proto__:null,createAnimation:Bo,createNeutralAnimation:da,sampleChannel:er,wrapFrame:Io},Symbol.toStringTag,{value:"Module"}));function Oo(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 Do(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 o=0;o<t;o++){const r=n.passes&&n.passes[o]&&n.passes[o].combos||{},i=n.materialPasses&&n.materialPasses[o]&&n.materialPasses[o].combos||{},s=r.TRANSPARENCY!==void 0?r.TRANSPARENCY:i.TRANSPARENCY;if(Number(s)===0)return!0}}return!1}function tr(e,n,t){if(t||(t=new Set),!n)return t;for(const o of e.childIds||[]){const r=n.get(o);!r||r.particle||r.isPostProcess||(t.add(o),tr(r,n,t))}return t}function Or(e){const n=ea[e]||"translucent";return{mode:n,prep:ta[n]||0}}function ma(e,n,t,o){const{mode:r,prep:i}=Or(e);let s=t;return i===1?s=t*o:i===2&&(s=1-o+t*o),r==="screen"?s+n*(1-s):r==="multiply"?n*s:r==="additive"?n+t*o:n*(1-o)+t*o}function $o(e,n,t){const o=e&&Number(e.scale)||1;let r=Math.max(1,Math.round(n/o)),i=Math.max(1,Math.round(t/o));const s=e&&Number(e.fit);if(Number.isFinite(s)&&s>0){const c=Math.max(r,i);if(c>s){const a=s/c;r=Math.max(1,Math.round(r*a)),i=Math.max(1,Math.round(i*a))}}return[r,i]}function pa(e){const n=Number(e);return!Number.isFinite(n)||n<.001?999:1/n}const An=-1;function Dr(e,n){return!!n&&!e}const ga="mix(999.0, 1.0 / max(g_PointerScale, 0.001), step(0.001, g_PointerScale))";function zo(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 o=e;/uniform\s+float\s+g_PointerScale\b/.test(o)||(o=o.replace(/void\s+main\s*\(/,`uniform float g_PointerScale;
64
- void main(`));const r=n?/unprojectedUVs\s*\*=\s*v_PointerScale\s*\*/:/unprojectedUVs\s*\*=\s*g_PointerScale\s*\*/;return o.replace(r,"unprojectedUVs *= "+ga+" *")}function ba(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 o=n.shaderResolver||(async()=>null),r=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,c=n.fboCapFactor===void 0?0:n.fboCapFactor,a=null,f=null,l=null;const d=[["g_AudioSpectrum16Left","left16"],["g_AudioSpectrum16Right","right16"],["g_AudioSpectrum32Left","left32"],["g_AudioSpectrum32Right","right32"],["g_AudioSpectrum64Left","left64"],["g_AudioSpectrum64Right","right64"]];function h(u){l=u||null}let m=null,M=null,g=null,y=null,b=null,p=null,v=null;const _=new Map,w=new Map,L={total:0,ok:0,failed:0};function F(u,x){m=typeof u=="function"?u:null,M=x&&x.userProperties||null,g=x&&x.audioViews||null,y=x&&x.shared||null,b=x&&x.inputView||null,p=x&&x.timers||null,v=x&&typeof x.onSandbox=="function"?x.onSandbox:null,_.clear(),w.clear()}let D=!1;const B=Jn(t,Ur,na),z=Jn(t,Ur,ra),V=Jn(t,Ur,oa),Y=t.createVertexArray();t.bindVertexArray(Y);const Z=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,Z),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 X=new Map;let q=1;function oe(u,x,S){const P=(S||"")+"|"+u+"x"+x;if(X.has(P)){const $=X.get(P);return $.stamp=q,$}const I=t.createFramebuffer(),N=t.createTexture();t.bindTexture(t.TEXTURE_2D,N),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,u,x,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,I),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,N,0),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.bindFramebuffer(t.FRAMEBUFFER,null);const E={fbo:I,tex:N,width:u,height:x,stamp:q};return X.set(P,E),E}function H(){for(const[u,x]of X)x.stamp!==q&&(x.fbo&&t.deleteFramebuffer(x.fbo),x.tex&&t.deleteTexture(x.tex),X.delete(u))}const j=new Map,ee=new Map,le=new Map;function Se(u){const x={},S=/uniform\s+[A-Za-z0-9_]+\s+([A-Za-z_][A-Za-z0-9_]*)[^;]*;\s*\/\/([^\n]*)/g;let P;for(;(P=S.exec(u))!==null;){const I=P[1],N=P[2],E=/"material"\s*:\s*"([^"]+)"/.exec(N);if(!E)continue;const $=/"default"\s*:\s*("(?:[^"]*)"|-?\d+(?:\.\d+)?)/.exec(N);x[E[1]]={uniform:I,default:$?Pe($[1]):void 0}}return x}function Xe(u){const x=new Map,S=/uniform\s+sampler2D\s+g_Texture(\d+)\s*;\s*\/\/([^\n]*)/g;let P;for(;(P=S.exec(u))!==null;){const I=Number(P[1]),N=/"default"\s*:\s*"([^"]+)"/.exec(P[2]);N&&N[1]&&x.set(I,N[1])}return x}function Le(u){const x=[],S=/uniform\s+sampler2D\s+(g_Texture(\d+))[^;]*;\s*\/\/([^\n]*)/g;let P;for(;(P=S.exec(u))!==null;){const I=/"combo"\s*:\s*"([^"]+)"/.exec(P[3]);I&&x.push({slot:Number(P[2]),name:P[1],combo:I[1]})}return x}function Pe(u){if(u.startsWith('"'))return u.slice(1,-1);const x=Number(u);return Number.isFinite(x)?x:void 0}async function ue(u,x,S){let P=le.get(u);if(P===void 0){const E=await o("shaders/"+u+".frag")||"",$=await o("shaders/"+u+".vert")||"";P={frag:E,vert:$,texCombos:Le(E)},le.set(u,P)}const I={...x};for(const E of P.texCombos)S&&S[E.slot]&&I[E.combo]===void 0&&(I[E.combo]=1);const N=u+"|"+JSON.stringify(I);if(j.has(N)){const E=j.get(N);if(E===null)throw new Error("shader="+u+" \u7F16\u8BD1\u5931\u8D25\uFF08\u5DF2\u7F13\u5B58\uFF09");return E}for(let E=0;E<4;E++){const $=new Set,A=k=>ee.has(k)?ee.get(k):($.add(k),null),R=zo(Fo(P.frag,"frag",I,A,P.vert)),C=Fo(P.vert,"vert",I,A,P.frag);if($.size===0){let k;try{k=Jn(t,C,R)}catch(O){throw j.set(N,null),new Error("shader="+u+" "+(O&&O.message))}const U=new Map,W=t.getProgramParameter(k,t.ACTIVE_UNIFORMS);for(let O=0;O<W;O++){const K=t.getActiveUniform(k,O),se=K.name.replace(/\[0\]$/,"");U.set(se,{loc:t.getUniformLocation(k,K.name),type:ca[K.type]||"unknown",size:K.size})}const J={...Se(P.vert),...Se(P.frag)},Q=new Map([...Xe(P.vert),...Xe(P.frag)]),te={prog:k,uni:U,matMeta:J,samplerDefaults:Q,fragGlsl:R,vertGlsl:C};return j.set(N,te),te}await Promise.all(Array.from($).map(async k=>{ee.set(k,await o("shaders/"+k)||"")}))}throw new Error("include \u89E3\u6790\u5931\u8D25: "+u)}const Fe=Ir(t,new Uint8Array([255,255,255,255]),1,1),Je=Ir(t,new Uint8Array([0,0,0,0]),1,1);let Ee=null;function xe(u){Ee=u||null}function Ne(){if(!Ee)return null;const u=typeof Ee=="function"?Ee():Ee;return u&&u.state?u.state:u}const we={x:0,y:0,sx:0,sy:0};let Ge=0,fe=0,Ye=0,$t=1/60,et=-1;const qt=typeof n.fadeDuration=="number"&&n.fadeDuration>=0?n.fadeDuration:1,pr=(u,x)=>{const S=u!==null&&typeof u=="object"?u.value:u;return S===!0||S===1?!0:S===!1||S===0?!1:x},Bn=(u,x)=>{const S=u!==null&&typeof u=="object"?u.value:u;return typeof S=="number"&&Number.isFinite(S)?S:x},Zt=u=>n.fade!==!1&&pr(u.camerafade,!1);function qe(u,x){if(!pr(u.camerashake,!1))return null;const S=Bn(u.camerashakeamplitude,0);if(S===0)return null;const P=Math.max(0,Math.min(1,Bn(u.camerashakeroughness,0))),I=Bn(u.camerashakespeed,1),N=x*I,E=Math.sin(N*2.1)*Math.cos(N*.7),$=Math.cos(N*1.7)*Math.sin(N*.9),A=Math.sin(N*11.3)*Math.cos(N*7.1),R=Math.cos(N*9.7)*Math.sin(N*13.1);return{x:(E*(1-P)+A*P)*S,y:($*(1-P)+R*P)*S}}function zt(){const u=new Date;return(u.getHours()*3600+u.getMinutes()*60+u.getSeconds())/86400}function ye(u,x,S){const P=u.get(x);P&&P.loc!==null&&S(P.loc,P.type,P.size)}function ln(u){if(typeof u=="number")return[u,u,u,u];const x=String(u).trim().split(/[\s,]+/).map(Number);return[x[0]||0,x[1]||0,x[2]||0,x[3]||0]}function gr(u,x,S){const P=u.get(x);if(!P||P.loc===null)return;const I=S&&S.value!==void 0?S.value:S,N=ln(I);switch(P.type){case"float":t.uniform1f(P.loc,N[0]);break;case"int":case"bool":t.uniform1i(P.loc,I===!0||I===1?1:Math.round(N[0]));break;case"vec2":t.uniform2f(P.loc,N[0],N[1]);break;case"vec3":t.uniform3f(P.loc,N[0],N[1],N[2]);break;case"vec4":t.uniform4f(P.loc,N[0],N[1],N[2],N[3]);break;case"mat4":t.uniformMatrix4fv(P.loc,!1,tt);break;case"mat3":t.uniformMatrix3fv(P.loc,!1,yr);break}}const br=()=>new Float32Array([1,0,0,0,1,0,0,0,1]);function un(u,x,S,P,I,N,E,$,A,R,C){if(ye(u,"g_Time",O=>t.uniform1f(O,S)),ye(u,"g_Daytime",O=>t.uniform1f(O,zt())),ye(u,"g_ModelViewProjectionMatrix",O=>t.uniformMatrix4fv(O,!1,N)),ye(u,"g_ModelMatrix",O=>t.uniformMatrix4fv(O,!1,E)),ye(u,"g_ViewProjectionMatrix",O=>t.uniformMatrix4fv(O,!1,$)),u.get("g_ModelViewProjectionMatrixInverse")){let O=null;for(const[se,ge]of A)se===0&&(O=ge);const K=O&&O[0]>0&&O[1]>0?Ds(xn(rn(),O[0]/2,O[1]/2,1)):tt;ye(u,"g_ModelViewProjectionMatrixInverse",se=>t.uniformMatrix4fv(se,!1,K))}ye(u,"g_Brightness",O=>t.uniform1f(O,x.brightness)),ye(u,"g_UserAlpha",O=>t.uniform1f(O,x.alpha)),ye(u,"g_Alpha",O=>t.uniform1f(O,x.alpha)),ye(u,"g_Color",O=>t.uniform3f(O,x.color[0],x.color[1],x.color[2])),ye(u,"g_Color4",O=>t.uniform4f(O,x.color[0],x.color[1],x.color[2],1)),ye(u,"g_CompositeColor",O=>t.uniform3f(O,x.color[0],x.color[1],x.color[2])),ye(u,"g_TexelSize",O=>t.uniform2f(O,1/P,1/I)),ye(u,"g_TexelSizeHalf",O=>t.uniform2f(O,.5/P,.5/I)),ye(u,"g_TextureReductionScale",O=>t.uniform1f(O,1));const k=Ne(),U=Dr(!!(k&&k.has),!!u.get("g_PointerScale"));let W=U?An:k?k.u:.5,J=U?An:k?k.v:.5,Q=U?An:k?k.lastU:.5,te=U?An:k?k.lastV:.5;if(C&&x&&x.size&&x.size[0]>0&&x.size[1]>0){const O=Math.abs(x.size[0]*x.scale[0]),K=Math.abs(x.size[1]*x.scale[1]);if(O>0&&K>0){const se=x.origin[0]-O/2,ge=C.projH-x.origin[1]-K/2,Me=Ae=>(C.offX+Ae*C.viewW-se)/O,ie=Ae=>(C.offY+Ae*C.viewH-ge)/K;W=Me(W),J=ie(J),Q=Me(Q),te=ie(te)}}ye(u,"g_PointerPosition",O=>t.uniform2f(O,W,J)),ye(u,"g_PointerPositionLast",O=>t.uniform2f(O,Q,te)),ye(u,"g_PointerState",O=>t.uniform4f(O,W,J,k&&k.leftDown?1:0,0)),ye(u,"g_ParallaxPosition",O=>t.uniform2f(O,we.sx*.5+.5,we.sy*.5+.5)),ye(u,"g_Frametime",O=>t.uniform1f(O,$t)),u.get("g_EffectTextureProjectionMatrixInverse")&&ye(u,"g_EffectTextureProjectionMatrixInverse",O=>t.uniformMatrix4fv(O,!1,tt));for(let O=0;O<8;O++)ye(u,"g_Texture"+O,K=>t.uniform1i(K,O));for(const[O,K]of A)ye(u,"g_Texture"+O+"Resolution",se=>t.uniform4f(se,K[0],K[1],K[2],K[3]));if(l){const O=typeof l=="function"?l():l;if(O)for(const[K,se]of d){const ge=O[se];ge&&ye(u,K,Me=>t.uniform1fv(Me,ge))}}}function so(u,x,S){for(const[P,I]of Object.entries(x||{})){const N=S&&S[P];N&&gr(u,N.uniform,I)}for(const[P,I]of Object.entries(S||{}))(!x||!(P in x))&&I.default!==void 0&&gr(u,I.uniform,I.default)}function On(u){const x=Ne();Dr(!!(x&&x.has),!!u.get("g_PointerScale"))&&ye(u,"g_PointerScale",S=>t.uniform1f(S,0))}function Dn(u,x,S,P){if(!u)return u;let I=!1;for(const E of Object.values(u))if(E!==null&&typeof E=="object"&&typeof E.script=="string"){I=!0;break}if(!I||!m)return u;const N={...u};for(const[E,$]of Object.entries(u)){if($===null||typeof $!="object"||typeof $.script!="string")continue;const A=x+"|"+E;let R=_.get(A);if(R===void 0){L.total++;try{R=m($.script,$.scriptproperties||$.scriptProperties||null,{userProperties:M||{},audioViews:g||void 0,layer:P||null,shared:y||{},inputView:b||void 0,setTimeout:p?p.setTimeout:void 0,clearTimeout:p?p.clearTimeout:void 0,setInterval:p?p.setInterval:void 0,clearInterval:p?p.clearInterval:void 0})}catch{R=null}if(R?L.ok++:L.failed++,_.set(A,R),R){const Q=$.value!==void 0?$.value:$,te=ln(Q),K=typeof Q=="number"?te[0]:{x:te[0],y:te[1],z:te[2]};R.init&&R.init(K)}if(R&&typeof R.applyUserProperties=="function")try{R.applyUserProperties(M||{})}catch{}if(R&&R.hasMediaHook&&v)try{v(R)}catch{}}if(!R||R.disabled||!R.hasUpdate)continue;if(R.engine){R.engine.runtime=S,R.engine.frametime=$t,R.engine.timeOfDay=zt();const Q=Ne();Q&&Q.screenW&&Q.screenH&&(R.engine.screenResolution={x:Q.screenW,y:Q.screenH})}const C=ln($.value!==void 0?$.value:$),U=typeof($.value!==void 0?$.value:$)=="number"?C[0]:{x:C[0],y:C[1],z:C[2]};let W;try{W=R.callUpdate(U)}catch{W=void 0}const J=W??U;if(typeof J=="number"&&Number.isFinite(J))N[E]=J;else if(J&&typeof J=="object"){const Q=Number(J.x),te=Number(J.y),O=Number(J.z);Number.isFinite(Q)&&Number.isFinite(te)&&(N[E]=Number.isFinite(O)?`${Q} ${te} ${O}`:`${Q} ${te} 0`)}}return N}function Ct(u,x,S){if(!u)return u;let P=!1;for(const N of Object.values(u))if(N&&typeof N=="object"&&N.animation&&N.animation.options){P=!0;break}if(!P)return u;const I={...u};for(const[N,E]of Object.entries(u)){if(!E||typeof E!="object"||!E.animation||!E.animation.options)continue;const $=x+"|anim|"+N;let A=w.get($);if(!A){const R=Bo(E.animation),C=E.value!==void 0?E.value:0;R.baseNumeric=Array.isArray(C)?C.slice():C,A={ctrl:R},w.set($,A)}A.ctrl.playing&&A.ctrl.setFrame(S*A.ctrl.fps*A.ctrl.rate),I[N]=A.ctrl.applyTo(A.ctrl.baseNumeric)}return I}function $n(u,x,S,P){return u==null||u===""?null:u.startsWith("_rt_")?u.startsWith("_rt_imageLayerComposite")?jn&&Vt.has(u)?Vt.get(u):x:S.has(u)?S.get(u):null:S.has(u)?S.get(u):P.get(u)||null}const fn=sa(),dn=aa(),Kt=new Map;function it(u,x){const S=u+"x"+x;let P=Kt.get(S);return P===void 0&&(P=ia(u,x),Kt.set(S,P)),P}let Rt=null;function st(u,x){Rt!==u&&(t.bindBuffer(t.ARRAY_BUFFER,Z),t.bufferData(t.ARRAY_BUFFER,x,t.DYNAMIC_DRAW),Rt=u)}const pe={mvp:t.getUniformLocation(B,"u_MVP"),tex:t.getUniformLocation(B,"u_Tex"),color:t.getUniformLocation(B,"u_Color4"),frameOrigin:t.getUniformLocation(B,"u_FrameOrigin"),frameU:t.getUniformLocation(B,"u_FrameU"),frameV:t.getUniformLocation(B,"u_FrameV"),blendPrep:t.getUniformLocation(B,"u_BlendPrep")},xt={mvp:t.getUniformLocation(z,"u_MVP"),tex:t.getUniformLocation(z,"u_Tex"),blendPrep:t.getUniformLocation(z,"u_BlendPrep")},zn={mvp:t.getUniformLocation(V,"u_MVP"),tex:t.getUniformLocation(V,"u_Tex")},tt=rn(),yr=br();function ft(u){u==="translucent"?(t.enable(t.BLEND),t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA)):u==="additive"?(t.enable(t.BLEND),t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE)):t.disable(t.BLEND)}let Qt=0;function vr(u){const{mode:x,prep:S}=Or(u);Qt=S,x==="additive"?(t.enable(t.BLEND),t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE)):x==="multiply"?(t.enable(t.BLEND),t.blendFuncSeparate(t.DST_COLOR,t.ZERO,t.ONE,t.ONE_MINUS_SRC_ALPHA)):x==="screen"?(t.enable(t.BLEND),t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_COLOR,t.ONE,t.ONE_MINUS_SRC_ALPHA)):ft("translucent")}function hn(u,x){if(x&&x.perspective)return!1;const S=u.size[0]*u.scale[0],P=u.size[1]*u.scale[1];if(S===0||P===0)return!1;let I=Math.abs(S)/2,N=Math.abs(P)/2;const E=u.angles[2];if(E!==0){const W=Math.abs(Math.cos(E)),J=Math.abs(Math.sin(E)),Q=I*W+N*J,te=I*J+N*W;I=Q,N=te}const $=u.origin[0],A=x.projH-u.origin[1];let R=64;u.parallaxDepth&&(R+=Math.abs(sn(u.parallaxDepth[0])*fe),R+=Math.abs(sn(u.parallaxDepth[1])*Ye));const C=Oo(u),k=R+C[0],U=R+C[1];return $+I+k<x.offX||$-I-k>x.offX+x.viewW||A+N+U<x.offY||A-N-U>x.offY+x.viewH}function jt(u,x,S){if(!u.spriteSheet)return null;const P=x&&x.frames,I=Array.isArray(P)?P:P&&P.list;if(!I||I.length===0)return null;const N=P&&P.atlasWidth||x.width||0,E=P&&P.atlasHeight||x.height||0;if(N<=0||E<=0)return null;u.spriteFrameCount=I.length;let $=0;const A=u.textureAnimation;if(A&&A.frame!==null&&A.frame!==void 0)$=Math.floor(Number(A.frame))||0,$>=0||($=0),$>=I.length&&($=I.length-1);else if(I.length>1){const J=A&&A.playing===!1;let Q=0;for(const te of I)Q+=te.duration>0?te.duration:1/30;if(!J&&Q>0){let te=S%Q;te<0&&(te+=Q);for(let O=0;O<I.length;O++){const K=I[O].duration>0?I[O].duration:.03333333333333333;if(te<K){$=O;break}te-=K,$=O}}}const R=I[$],C=R.uDir?R.uDir[0]:R.width,k=R.uDir?R.uDir[1]:0,U=R.vDir?R.vDir[0]:0,W=R.vDir?R.vDir[1]:R.height;return[R.x/N,R.y/E,C/N,k/E,U/N,W/E]}function mn(u,x){const S=u.size[0]*u.scale[0],P=u.size[1]*u.scale[1];let I=rn();if(x&&x.perspective){const E=Ws(u,x);I=on(I,E[0],E[1],E[2]);const $=u.angles[0]||0,A=u.angles[1]||0;A&&(I=zs(I,A)),$&&(I=$s(I,$)),I=Ao(I,-u.angles[2])}else{if(I=on(I,u.origin[0],x.projH-u.origin[1],u.origin[2]),u.parallaxDepth&&(fe!==0||Ye!==0)){const E=sn(u.parallaxDepth[0]),$=sn(u.parallaxDepth[1]);I=on(I,E*fe,$*Ye,0)}I=Ao(I,-u.angles[2])}const N=No[u.alignment]||[.5,.5];return(N[0]!==.5||N[1]!==.5)&&(I=on(I,(.5-N[0])*S,(.5-N[1])*P,0)),{m:I,w:S,h:P}}function pn(u,x,S,P,I,N,E,$,A=!1,R=null,C=null){const k=mn(P,I);let U=k.m;if(C){const Q=(C[0]+C[2]/2)*P.scale[0],te=(C[1]+C[3]/2)*P.scale[1];U=on(U,Q,-te,0),U=xn(U,C[2]*P.scale[0],C[3]*P.scale[1],1)}else U=xn(U,k.w,k.h,1);const W=bt(N,U),J=u===z?xt:pe;t.useProgram(u),A?(Qt=0,t.enable(t.BLEND),P.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)):vr(P.colorBlendMode),J.blendPrep!==null&&J.blendPrep!==void 0&&t.uniform1i(J.blendPrep,Qt),Oe?(t.bindFramebuffer(t.FRAMEBUFFER,Oe.fbo.fbo),t.viewport(0,0,Oe.w,Oe.h)):(t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,E,$)),t.bindVertexArray(Y),st("local",dn),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,x),t.uniform1i(J.tex,0),t.uniformMatrix4fv(J.mvp,!1,W),J.color!==null&&J.color!==void 0&&t.uniform4f(J.color,S[0],S[1],S[2],S[3]),Lt(J,R),t.drawArrays(t.TRIANGLES,0,6)}function Lt(u,x){!u||u.frameOrigin===null||u.frameOrigin===void 0||(x?(t.uniform2f(u.frameOrigin,x[0],x[1]),t.uniform2f(u.frameU,x[2],x[3]),t.uniform2f(u.frameV,x[4],x[5])):(t.uniform2f(u.frameOrigin,0,0),t.uniform2f(u.frameU,1,0),t.uniform2f(u.frameV,0,1)))}let wt=null,Oe=null;const Vt=new Map,dt=new Map;let jn=!0;function ao(u,x){const S=mn(u,x),P=x&&x.perspective?u.scale[1]:-u.scale[1],I=x&&x.perspective&&u.scale[2]||1;return xn(S.m,u.scale[0],P,I)}function Vn(u,x,S,P,I,N,E){Oe?(t.bindFramebuffer(t.FRAMEBUFFER,Oe.fbo.fbo),t.viewport(0,0,Oe.w,Oe.h)):(t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,P,I));const $=bt(S,ao(u,x));wt(u,$,{time:N,overrideTex:E||null}),Rt=null}let ht=null;function gn(u,x){return ht===null&&(ht=t.createTexture(),t.bindTexture(t.TEXTURE_2D,ht),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,ht),t.copyTexImage2D(t.TEXTURE_2D,0,t.RGB8,0,0,u,x,0),ht}function Jt(u,x,S,P,I,N,E,$){const A=gn(E,$),R=mn(u,I);let C=R.m;C=xn(C,R.w,R.h,1);const k=bt(N,C),U=[[-.5,.5],[.5,.5],[-.5,-.5],[.5,-.5]].map(([K,se])=>{const ge=Xs(k,K,se,0);return[ge[0]*.5+.5,ge[1]*.5+.5]}),[W,J,Q,te]=U,O=new Float32Array([0,P,0,W[0],W[1],0,0,0,Q[0],Q[1],S,P,0,J[0],J[1],S,P,0,J[0],J[1],0,0,0,Q[0],Q[1],S,0,0,te[0],te[1]]);t.useProgram(V),ft("normal"),t.disable(t.BLEND),t.bindFramebuffer(t.FRAMEBUFFER,x.fbo),t.viewport(0,0,S,P),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.bindVertexArray(Y),t.bindBuffer(t.ARRAY_BUFFER,Z),t.bufferData(t.ARRAY_BUFFER,O,t.DYNAMIC_DRAW),Rt=null,t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,A),t.uniform1i(zn.tex,0),t.uniformMatrix4fv(zn.mvp,!1,vn(0,S,0,P,-1e4,1e4)),t.drawArrays(t.TRIANGLES,0,6),t.enable(t.BLEND)}function xr(u,x,S,P,I){if(!jn||Oe)return;const N=dt.get(u.id);if(!N||N.size===0)return;const E=Math.max(1,Math.round(Math.abs(u.size[0]*(u.scale[0]||1)))),$=Math.max(1,Math.round(Math.abs(u.size[1]*(u.scale[1]||1))));if(E<=1&&$<=1)return;const A=oe(E,$,"lc:"+u.id);Jt(u,A,E,$,x,S,P,I);for(const R of N)Vt.set(R,A);dt.delete(u.id),t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,P,I)}async function Wn(u,x,S,P,I,N,E,$){q++,t.viewport(0,0,S,P);const A=u.general||{};if(A.clearenabled!==!1){const O=Uo(A.clearcolor||"0 0 0");t.clearColor(O[0],O[1],O[2],1)}else t.clearColor(0,0,0,1);if(t.clear(t.COLOR_BUFFER_BIT),et>=0){const O=I-et;$t=O>0&&O<1?O:Math.min(.1,Math.max(.001,O||1/60))}et=I;const R=qs(u,S,P,N,E,$);let C=bt(R.projection,R.view);const k=A.cameraparallax,U=k===!0||k!==null&&typeof k=="object"&&k.value===!0;fe=0,Ye=0;const W=Ne();if(W&&(we.x=W.u*2-1,we.y=W.v*2-1),!R.perspective&&n.parallax!==!1&&U){const O=(nt,ae)=>{const de=nt!==null&&typeof nt=="object"?nt.value:nt;return typeof de=="number"&&Number.isFinite(de)?de:ae},K=O(A.cameraparallaxamount,0),se=O(A.cameraparallaxmouseinfluence,1),ge=O(A.cameraparallaxdelay,1),Me=I-Ge;Ge=I;const ie=Me>0?1-Math.exp(-Me/Math.max(.05,ge)):1;we.sx+=(we.x-we.sx)*ie,we.sy+=(we.y-we.sy)*ie;const Ae=K*se,_e=60,Ze=we.sx*Ae*R.viewW,Mt=we.sy*Ae*R.viewH,at=Math.max(Math.abs(Ze),Math.abs(Mt))/_e,At=at>1?1/at:1;fe=-(Ze*At),Ye=-(Mt*At)}if(!R.perspective&&n.shake!==!1){const O=qe(A,I);if(O){const K=O.x*R.viewW*.02,se=O.y*R.viewH*.02;(K!==0||se!==0)&&(C=bt(C,on(rn(),K,se,0)))}}if(Ee){const O=typeof Ee=="function"?Ee():Ee;O&&typeof O.syncWorld=="function"&&O.syncWorld(R,0,0)}if(!D){D=!0;const O=(u.layers||[]).filter(ge=>ge.isContainer),K=O.filter(ge=>(ge.effects||[]).some(Me=>Me.visible)&&!ge.hasChildren),se=K.filter(ge=>(ge.effects||[]).some(Me=>(Me.materialPasses||[]).length>0));r(`containers total=${O.length} canvasCandidates=${K.length} passesResolved=${se.length} names=${K.slice(0,4).map(ge=>ge.name||"?").join("/")}`)}await wr(u,x,R,S,P,I);const J=new Map;for(const O of u.layers)O.id!==void 0&&J.set(O.id,O);const Q=new Set;for(const O of u.layers)!O.visible||O.destroyed||!O.isContainer||!O.hasChildren||!(O.effects||[]).some(se=>se.visible)||(O.childIds||[]).length===0||tr(O,J,Q);if(a)try{a()}catch(O){r("particle advance error: "+(O&&O.message))}const te=R.perspective?u.layers.slice().sort((O,K)=>+!!K.isSkybox-+!!O.isSkybox):u.layers;for(const O of te)if(!(!O.visible||O.destroyed)&&!(O.isPostProcess&&!(O.effects||[]).some(K=>K.visible))&&!Q.has(O.id)){if(O.isContainer){if(!(O.effects||[]).some(se=>se.visible)){xr(O,R,C,S,P);continue}if(O.hasChildren){(O.childIds||[]).length>0&&await Mr(O,u,x,R,C,S,P,I);continue}}if(O.particle){if(f)try{await f(O.id,R,C,S,P)}catch(K){r("particle render error: "+(K&&K.message))}continue}hn(O,R)||await T(O,x,R,C,S,P,I)}if(Zt(A)&&I<qt){const O=Math.max(0,Math.min(1,I/qt)),K=1-O*O*(3-2*O);if(K>.002){const se=Uo(A.clearcolor||"0 0 0");t.useProgram(B),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,S,P),t.bindVertexArray(Y),st("pass",fn),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,Fe),t.uniform1i(pe.tex,0),t.uniform4f(pe.color,se[0],se[1],se[2],K),Lt(pe,null),pe.blendPrep!==null&&pe.blendPrep!==void 0&&t.uniform1i(pe.blendPrep,0),t.uniformMatrix4fv(pe.mvp,!1,tt),t.drawArrays(t.TRIANGLES,0,6)}}t.bindVertexArray(null),H()}async function wr(u,x,S,P,I,N){Vt.clear(),dt.clear();const E=new Map,$=new Set;let A=null;const R=C=>{if(typeof C!="string")return;const k=/^_rt_imageLayerComposite_(\d+)_[a-z]$/.exec(C);if(!k)return;const U=Number(k[1]);A!==null&&U===A&&$.add(U);let W=E.get(U);W||(W=new Set,E.set(U,W)),W.add(C)};for(const C of u.layers||[]){A=C.id;for(const k of C.effects||[])if(k.visible){for(const U of k.passes||[])for(const W of U.textures||[])R(W);for(const U of k.materialPasses||[]){for(const W of U.binds||[])R(W&&W.name);for(const W of U.textures||[])R(W)}}}if(E.size!==0){for(const[C,k]of E){const U=(u.layers||[]).find(_e=>_e.id===C);if(!U||U.particle||U.isPostProcess||$.has(C))continue;const W=typeof U.image=="string"?U.image:"";if(U.isContainer&&!U.hasChildren&&W.indexOf("models/util/composelayer")===0&&!(U.effects||[]).some(_e=>_e.visible)){dt.set(C,k);continue}const Q=Math.max(1,Math.round(Math.abs(U.size[0]*(U.scale[0]||1)))),te=Math.max(1,Math.round(Math.abs(U.size[1]*(U.scale[1]||1))));if(Q<=1&&te<=1)continue;const O=oe(Q,te,"lc:"+C);t.bindFramebuffer(t.FRAMEBUFFER,O.fbo),t.viewport(0,0,Q,te),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT);const K={view:S.view,projection:vn(0,Q,0,te,-1e4,1e4),eye:S.eye,projW:Q,projH:te,offX:0,offY:0,viewW:Q,viewH:te},se=Oe,ge=U.origin,Me=U.scale,ie=U.angles,Ae=U.visible;Oe={fbo:O,w:Q,h:te},U.origin=[Q/2,K.projH-te/2,ge[2]],U.scale=[Math.sign(Me[0])||1,Math.sign(Me[1])||1,Me[2]],U.angles=[0,0,0],U.visible=!0;try{await T(U,x,K,K.projection,Q,te,N);for(const _e of k)Vt.set(_e,O)}catch(_e){r(`composite \u6E90\u5C42 ${C} \u6E32\u67D3\u5931\u8D25: ${_e&&_e.message}`)}finally{Oe=se,U.origin=ge,U.scale=Me,U.angles=ie,U.visible=Ae}}t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,P,I)}}async function Mr(u,x,S,P,I,N,E,$){const A=Math.max(1,Math.round(Math.abs(u.size[0]))),R=Math.max(1,Math.round(Math.abs(u.size[1])));if((u.childIds||[]).length===0)return;const k=new Map;for(const ie of x.layers)ie.id!==void 0&&k.set(ie.id,ie);const U=tr(u,k),W=x.layers.filter(ie=>U.has(ie.id)&&ie.visible);if(W.length===0)return;const J=oe(A,R,"group");t.bindFramebuffer(t.FRAMEBUFFER,J.fbo),t.viewport(0,0,A,R),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT);const Q={view:P.view,projection:vn(0,A,0,R,-1e4,1e4),eye:P.eye,projW:A,projH:R,offX:0,offY:0,viewW:A,viewH:R},te=Q.projection,O=u.scale[0]||1,K=u.scale[1]||1,se=u.angles[2]||0,ge=Math.cos(-se),Me=Math.sin(-se);Oe={fbo:J,w:A,h:R};try{for(const ie of W){if(ie.isPostProcess||ie.particle||ie.isContainer&&(ie.childIds||[]).length>0)continue;const Ae=ie.origin,_e=ie.scale,Ze=ie.angles,Mt=Ae[0]-u.origin[0],at=Ae[1]-u.origin[1],At=(Mt*ge-at*Me)/O,nt=(Mt*Me+at*ge)/K;ie.origin=[A/2+At,R/2+nt,Ae[2]],ie.scale=[_e[0]/O,_e[1]/K,_e[2]],ie.angles=[Ze[0],Ze[1],Ze[2]-se];try{await T(ie,S,Q,te,A,R,$)}finally{ie.origin=Ae,ie.scale=_e,ie.angles=Ze}}}finally{Oe=null}u.groupTex=J.tex,u.groupW=A,u.groupH=R;try{await T(u,S,P,I,N,E,$)}finally{u.groupTex=null}}async function T(u,x,S,P,I,N,E){const $=!!(u.puppet&&wt),A=!u.solid&&u.textureName?x.get(u.textureName):null;if(A&&A.video){const ae=A.video;if(ae.readyState>=2&&ae.currentTime!==A.lastUploaded){t.bindTexture(t.TEXTURE_2D,A.glTex);try{let de=ae.videoWidth||A.width,ce=ae.videoHeight||A.height;const ke=2048,_t=t.getParameter(t.MAX_TEXTURE_SIZE),mt=_t>0&&_t<4096?Math.min(ke,_t):ke;let Wt=1;Math.max(de,ce)>mt&&(Wt=mt/Math.max(de,ce));const pt=Math.max(1,Math.round(de*Wt)),Ve=Math.max(1,Math.round(ce*Wt));let Ar=ae;if(i&&pt>0&&Ve>0){(i.width!==pt||i.height!==Ve)&&(i.width=pt,i.height=Ve);const Ft=i.getContext("2d");Ft&&(Ft.clearRect(0,0,pt,Ve),Ft.drawImage(ae,0,0,pt,Ve),Ar=i)}if(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,Ar),t.getError()!==t.NO_ERROR&&i)try{const Ht=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(Ht.data.buffer));t.getError()!==t.NO_ERROR;);}catch{}A.width=pt,A.height=Ve,A.lastUploaded=ae.currentTime,s||(s=!0,r("video tex ready "+pt+"x"+Ve+" (src "+de+"x"+ce+")"))}catch(de){s||(s=!0,r("video upload FAIL: "+(de&&de.message||de))),console.warn("[we-scene] \u89C6\u9891\u5E27\u4E0A\u4F20\u5931\u8D25:",de&&de.message,"readyState=",ae.readyState,"cur=",ae.currentTime)}}}const R=u.groupTex?u.groupTex:A&&A.glTex?A.glTex:u.solid?Fe:Je,C=(!!u.passthrough||!!u.isPostProcess||Do(u))&&!u.groupTex&&!A&&!$;let k,U;if(u.groupTex?(k=u.groupW||u.size[0],U=u.groupH||u.size[1]):$||!A?(k=u.size[0],U=u.size[1]):(k=A.width,U=A.height),!$&&A&&u.spriteSheet){const ae=A.frames,de=Array.isArray(ae)?ae:ae&&ae.list;de&&de.length&&(k=de[0].width||k,U=de[0].height||U)}const W=Math.max(1,Math.round(k)),J=Math.max(1,Math.round(U)),Q=[u.color[0]*u.brightness,u.color[1]*u.brightness,u.color[2]*u.brightness,u.alpha],te=(u.effects||[]).filter(ae=>ae.visible);let O=W,K=J;if(c>0&&S.projW>0&&S.projH>0){const ae=Math.min(Math.abs(u.size[0]*u.scale[0]),S.viewW),de=Math.min(Math.abs(u.size[1]*u.scale[1]),S.viewH),ce=ae*(I/S.projW),ke=de*(N/S.projH);if(ce>0&&ke>0){const _t=Math.max(64,Math.round(ce*c)),mt=Math.max(64,Math.round(ke*c));_t<W&&(O=_t),mt<J&&(K=mt)}}if(te.length===0){$?Vn(u,S,P,I,N,E):pn(B,R,Q,u,S,P,I,N,!1,jt(u,A,E));return}const se=oe(O,K,"ping"),ge=oe(O,K,"pong"),Me=vn(0,O,0,K,-1e4,1e4);if($)t.useProgram(B),ft("normal"),t.bindFramebuffer(t.FRAMEBUFFER,se.fbo),t.viewport(0,0,O,K),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.bindVertexArray(Y),Rt=null,st("layer"+O+"x"+K,it(O,K)),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,R),t.uniform1i(pe.tex,0),t.uniform4f(pe.color,1,1,1,1),Lt(pe,null),pe.blendPrep!==null&&pe.blendPrep!==void 0&&t.uniform1i(pe.blendPrep,0),t.uniformMatrix4fv(pe.mvp,!1,Me),t.drawArrays(t.TRIANGLES,0,6);else if(C)Jt(u,se,O,K,S,P,I,N);else{t.useProgram(B),ft("normal"),t.bindFramebuffer(t.FRAMEBUFFER,se.fbo),t.viewport(0,0,O,K),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.bindVertexArray(Y),st("layer"+O+"x"+K,it(O,K)),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,R),t.uniform1i(pe.tex,0);const ae=te.some(de=>de&&de.layerMaterial)?[1,1,1,Q[3]]:Q;t.uniform4f(pe.color,ae[0],ae[1],ae[2],ae[3]),Lt(pe,jt(u,A,E)),pe.blendPrep!==null&&pe.blendPrep!==void 0&&t.uniform1i(pe.blendPrep,0),t.uniformMatrix4fv(pe.mvp,!1,Me),t.drawArrays(t.TRIANGLES,0,6)}let ie=se,Ae=ge;const _e=new Map;let Ze=!1,Mt=se;const at=[],At=new Set;for(const ae of te){for(const ce of ae.fbos||[])if(!_e.has(ce.name)){const[ke,_t]=$o(ce,O,K),mt=ce.unique?u.id+":"+ce.name:ce.name;_e.set(ce.name,oe(ke,_t,mt))}const de=ae.materialPasses||[];for(let ce=0;ce<de.length;ce++)at.push({eff:ae,mp:de[ce],ov:ae.passes&&ae.passes[ce]})}const nt=[];for(let ae=0;ae<at.length;ae++){const{eff:de,mp:ce,ov:ke}=at[ae];if(At.has(de))continue;const _t={...ce.combos||{},...ke&&ke.combos||{}},mt=ce.textures||[],Wt=ke&&ke.textures||[],pt=[];for(let be=0;be<Math.max(mt.length,Wt.length);be++)Wt[be]!==void 0&&Wt[be]!==null?pt[be]=Wt[be]:pt[be]=mt[be]!==void 0?mt[be]:null;if(ce.copyCommand){const be=ce.source?_e.get(ce.source):null,Ue=ce.target?_e.get(ce.target):null;be&&Ue&&(t.useProgram(z),ft("normal"),t.bindFramebuffer(t.FRAMEBUFFER,Ue.fbo),t.viewport(0,0,Ue.width,Ue.height),t.bindVertexArray(Y),st("pass",fn),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,be.tex),t.uniform1i(xt.tex,0),xt.blendPrep!==null&&xt.blendPrep!==void 0&&t.uniform1i(xt.blendPrep,0),t.uniformMatrix4fv(xt.mvp,!1,tt),t.drawArrays(t.TRIANGLES,0,6),t.bindFramebuffer(t.FRAMEBUFFER,null));continue}let Ve;try{Ve=await ue(ce.shader,_t,pt)}catch(be){const Ue=be&&be.message||String(be);/已缓存/.test(Ue)||console.warn("[we-scene] \u8DF3\u8FC7\u6548\u679C\uFF08pass \u7F16\u8BD1\u5931\u8D25\uFF09:",ce.shader,Ue),At.add(de);continue}const Ar=Ve.prog,Ft=Ve.uni;Ve.fragGlsl&&nt.push(Ve.fragGlsl);let Ht,Hn;ce.target?(Ze||(Mt=ie,Ze=!0),Ht=_e.get(ce.target)||ie,Hn=Mt):(Ze=!1,Ht=Ae,Hn=ie),t.useProgram(Ar),ft(ce.blending||"normal"),t.bindFramebuffer(t.FRAMEBUFFER,Ht.fbo),t.viewport(0,0,Ht.width,Ht.height),t.bindVertexArray(Y),st("pass",fn);const co=ce.textures||[],El=Math.max(co.length,8),Qi=new Map,Pl=new Set;for(let be=0;be<El;be++){let Ue=be<co.length?co[be]:null;ke&&ke.textures&&ke.textures[be]!==void 0&&ke.textures[be]!==null&&(Ue=ke.textures[be]);for(const Gn of ce.binds||[])Gn.index===be&&(Ue=Gn.name);let Tt;if(be===0&&(Ue==null||Ue===""))Tt=Hn;else{if((Ue==null||Ue==="")&&Ve.samplerDefaults){const Gn=Ve.samplerDefaults.get(be);Gn&&(Ue=Gn)}Tt=$n(Ue,Hn,_e,x)}Ue==="previous"&&(Tt=Hn),Tt===null&&(Tt={glTex:Fe,width:1,height:1,tex:Fe});const Xn=Tt.fbo?Tt:{tex:Tt.glTex||Fe,width:Tt.width||1,height:Tt.height||1};t.activeTexture(t.TEXTURE0+be),t.bindTexture(t.TEXTURE_2D,Xn.tex),Pl.add(be),Qi.set(be,[Xn.width,Xn.height,Xn.width,Xn.height])}un(Ft,u,E,S.projW,S.projH,tt,Me,tt,Qi,Me,S),so(Ft,Ct(Dn({...ce.constants||{},...ke&&ke.constantshadervalues||{}},(u.id||u.name||"?")+"|"+(ce.shader||"?")+"|"+ae,E,u),(u.id||u.name||"?")+"|"+(ce.shader||"?")+"|"+ae,E),Ve.matMeta),On(Ft),t.drawArrays(t.TRIANGLES,0,6),ce.target||(Ae=ie,ie=Ht)}if(u.isContainer&&!u.groupTex&&!C&&u.containerAlphaMeaningful===void 0){let ae=!1;for(const de of nt){if(typeof de!="string")continue;const ce=de.match(/\bfloat\s+alpha\s*=\s*([^;]+);/);if(ce&&!/^\s*scene\s*\.\s*a\s*$/.test(ce[1])){ae=!0;break}}u.containerAlphaMeaningful=ae,r(`container "${u.name||"?"}" alpha ${ae?"\u643A\u5E26\u5F62\u72B6 \u2192 SRC_ALPHA":"\u65E0\u4FE1\u606F \u2192 \u52A0\u6CD5"}`)}if($){Vn(u,S,P,I,N,E,ie.tex);return}pn(z,ie.tex,[1,1,1,1],u,S,P,I,N,!!u.isContainer&&!u.groupTex&&!C,null,null)}return{gl:t,render:Wn,getFBO:oe,getEffectProgram:ue,progCache:j,shaderResolver:o,whiteTex:Fe,resetShaderCaches:function(){j.clear(),ee.clear(),le&&le.clear()},setFboCapFactor:function(u){c=u},setParticleRenderer:function(u,x){a=typeof u=="function"?u:null,f=typeof x=="function"?x:null},setConstantScriptRuntime:F,applyConstUserProperties:function(u){if(u){for(const x of _.values())if(x&&typeof x.applyUserProperties=="function")try{x.applyUserProperties(u)}catch{}}},constantScriptStats:function(){return{...L,cached:_.size}},setCompositeEnabled:function(u){jn=!!u},compositeStats:function(){const u=[],x=new Uint8Array(4);for(const[S,P]of Vt){let I=null;try{t.bindFramebuffer(t.FRAMEBUFFER,P.fbo),t.readPixels(P.w>>1,P.h>>1,1,1,t.RGBA,t.UNSIGNED_BYTE,x),I=[x[0],x[1],x[2],x[3]]}catch{}u.push({name:S,w:P.w,h:P.h,center:I})}return t.bindFramebuffer(t.FRAMEBUFFER,null),u},setPuppetRenderer:function(u){wt=u},setAudioProvider:h,setPointerProvider:xe,getParallaxOffset:function(){return{x:fe,y:Ye}},dispose:function(){try{const u=t.getExtension("WEBGL_lose_context");u&&u.loseContext()}catch{}}}}const ya=Object.freeze(Object.defineProperty({__proto__:null,ALIGN:No,XRAY_IDLE_SCREEN_UV:An,applyColorBlendCPU:ma,collectGroupDescendantIds:tr,colorBlendPlan:Or,createRenderer:ba,effectFboSize:$o,layerWantsPreserveBackdrop:Do,makeTexture:Ir,makeTextureMip:la,puppetAnimMargin:Oo,rewriteXrayFragScale:zo,xrayShouldParkPointer:Dr,xrayUvScale:pa},Symbol.toStringTag,{value:"Module"}));function va(e=256,n=8){const t=e/n,o=jo(1337),r=jo(4242),i=new Float32Array(t*t),s=new Float32Array(t*t);for(let f=0;f<t*t;f++)i[f]=o(),s[f]=r();const c=new Uint8Array(e*e*4),a=n;for(let f=0;f<e;f++){const l=Math.floor(f/a),d=f%a/a,h=d*d*(3-2*d);for(let m=0;m<e;m++){const M=Math.floor(m/a),g=m%a/a,y=g*g*(3-2*g),b=M%t,p=(M+1)%t,v=l%t,_=(l+1)%t,w=i[v*t+b],L=i[v*t+p],F=i[_*t+b],D=i[_*t+p],B=s[v*t+b],z=s[v*t+p],V=s[_*t+b],Y=s[_*t+p],Z=w+(L-w)*y+(F-w)*h+(w-L-F+D)*y*h,X=B+(z-B)*y+(V-B)*h+(B-z-V+Y)*y*h,q=(f*e+m)*4;c[q]=Math.round(Z*255),c[q+1]=Math.round(X*255),c[q+2]=0,c[q+3]=255}}return c}function jo(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 xa=Object.freeze(Object.defineProperty({__proto__:null,generateNoiseTexture:va},Symbol.toStringTag,{value:"Module"})),lt=Math.PI*2;function Ce(e,n){return e==null?Math.random():n==null?e:e+Math.random()*(n-e)}function Vo(e,n,t){if(e==null)return Math.random();if(n==null)return e;const o=t&&t!==1?Math.pow(Math.random(),t):Math.random();return e+o*(n-e)}function me(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 me(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 Wo(e){return e==null?null:typeof e=="number"?[e,e,e]:me(e)}function G(e,n){if(e==null)return n;if(typeof e=="object")return G(e.value,n);const t=Number(e);return Number.isFinite(t)?t:n}function $r(e,n){const t=e[0],o=e[1]>t?e[1]:t+1e-6,r=Math.min(1,Math.max(0,(n-t)/(o-t)));return r*r*(3-2*r)}function Ut(e,n,t){const o=Math.sin(e*127.1+n*311.7+t*74.7)*43758.5453;return o-Math.floor(o)}function wa(e,n,t){const o=Math.floor(e),r=Math.floor(n),i=Math.floor(t),s=e-o,c=n-r,a=t-i,f=s*s*(3-2*s),l=c*c*(3-2*c),d=a*a*(3-2*a),h=(b,p,v)=>b+(p-b)*v,m=h(Ut(o,r,i),Ut(o+1,r,i),f),M=h(Ut(o,r+1,i),Ut(o+1,r+1,i),f),g=h(Ut(o,r,i+1),Ut(o+1,r,i+1),f),y=h(Ut(o,r+1,i+1),Ut(o+1,r+1,i+1),f);return h(h(m,M,l),h(g,y,l),d)}function zr(e,n,t,o){let r=0,i=.5,s=1,c=0;for(let a=0;a<o;a++)r+=i*wa(e*s,n*s,t*s),c+=i,i*=.5,s*=2;return r/(c||1)}function jr(e,n,t,o){return[zr(e,n,t,o)*2-1,zr(e+31.7,n+11.3,t+57.1,o)*2-1,zr(e+73.9,n+92.1,t+13.7,o)*2-1]}function Ma(e){const n=`#version 300 es
65
+ }`;function Fa(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 Na(){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 Ua(){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 Da={5126:"float",35664:"vec2",35665:"vec3",35666:"vec4",5124:"int",35667:"ivec2",35668:"ivec3",35669:"ivec4",35670:"bool",35676:"mat4",35675:"mat3"};function ir(e,n,t){const r=Go(e,e.VERTEX_SHADER,n),o=Go(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 Go(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 Yo(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 jr(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 Ba(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 zr(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 Ia(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=zr(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,zr(e,n,t,r,i)<o?s=i:a=i;return i}function sr(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 sr([{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=Ia(c,v,A,u,n);return zr(l,_,R,f,L)}function qo(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 Oa(e){return Array.isArray(e)?e:typeof e=="string"?e.trim().split(/\s+/).map(Number):Number.isFinite(e)?[e]:[]}function Zo(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=qo(f.frame,r,o),d=a?{length:r}:void 0;if(c.length===1)return sr(c[0],p,d);const y=[];for(const x of c)y.push(sr(x,p,d));return y},applyTo(p){const d=f.value();if(!s)return d;const y=Oa(p);return Array.isArray(d)?d.map((x,m)=>x+(Number(y[m])||0)):d+(Number(y[0])||0)}};return f}function $a(){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 ja=Object.freeze(Object.defineProperty({__proto__:null,createAnimation:Zo,createNeutralAnimation:$a,sampleChannel:sr,wrapFrame:qo},Symbol.toStringTag,{value:"Module"}));function Ko(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 Qo(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 ar(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),ar(o,n,t))}return t}function Wr(e){const n=Pa[e]||"translucent";return{mode:n,prep:Ca[n]||0}}function za(e,n,t,r){const{mode:o,prep:i}=Wr(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 Jo(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 Wa(e){const n=Number(e);return!Number.isFinite(n)||n<.001?999:1/n}const Ln=-1;function Vr(e,n){return!!n&&!e}const Va="mix(999.0, 1.0 / max(g_PointerScale, 0.001), step(0.001, g_PointerScale))";function ei(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 *= "+Va+" *")}const ti=1;function ni(e,n){return e==="g_PointerScale"?ti:n}function Ha(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=ir(t,$r,La),j=ir(t,$r,Ra),H=ir(t,$r,ka),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 V=new Map;let X=1;function ie(w,U,G){const W=(G||"")+"|"+w+"x"+U;if(V.has(W)){const b=V.get(W);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 V.set(W,oe),oe}function J(){for(const[w,U]of V)U.stamp!==X&&(U.fbo&&t.deleteFramebuffer(U.fbo),U.tex&&t.deleteTexture(U.tex),V.delete(w))}const Z=new Map,te=new Map,le=new Map;function Ue(w){const U={},G=/uniform\s+[A-Za-z0-9_]+\s+([A-Za-z_][A-Za-z0-9_]*)[^;]*;\s*\/\/([^\n]*)/g;let W;for(;(W=G.exec(w))!==null;){const Y=W[1],ee=W[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?Xe(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 W;for(;(W=G.exec(w))!==null;){const Y=Number(W[1]),ee=/"default"\s*:\s*"([^"]+)"/.exec(W[2]);ee&&ee[1]&&U.set(Y,ee[1])}return U}function Ze(w){const U=[],G=/uniform\s+sampler2D\s+(g_Texture(\d+))[^;]*;\s*\/\/([^\n]*)/g;let W;for(;(W=G.exec(w))!==null;){const Y=/"combo"\s*:\s*"([^"]+)"/.exec(W[3]);Y&&U.push({slot:Number(W[2]),name:W[1],combo:Y[1]})}return U}function Xe(w){if(w.startsWith('"'))return w.slice(1,-1);const U=Number(w);return Number.isFinite(U)?U:void 0}async function De(w,U,G){let W=le.get(w);if(W===void 0){const oe=await r("shaders/"+w+".frag")||"",b=await r("shaders/"+w+".vert")||"";W={frag:oe,vert:b,texCombos:Ze(oe)},le.set(w,W)}const Y={...U};for(const oe of W.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=ei(Ho(W.frag,"frag",Y,T,W.vert)),C=Ho(W.vert,"vert",Y,T,W.frag);if(b.size===0){let I;try{I=ir(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:Da[k.type]||"unknown",size:k.size})}const z={...Ue(W.vert),...Ue(W.frag)},B=/gl_Position\s*=\s*vec4\s*\(\s*a_Position/.test(W.vert)&&!/[aA]_Position[\s\S]{0,40}mul\s*\(/.test(W.vert),q=new Map([..._e(W.vert),..._e(W.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 Ke=jr(t,new Uint8Array([255,255,255,255]),1,1),Be=jr(t,new Uint8Array([0,0,0,0]),1,1);let ye=null;function he(w){ye=w||null}function Ie(){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 Qe=0,Oe=0,Ae=0,ot=1/60,it=-1;const It=typeof n.fadeDuration=="number"&&n.fadeDuration>=0?n.fadeDuration:1,we=(w,U)=>{const G=w!==null&&typeof w=="object"?w.value:w;return G===!0||G===1?!0:G===!1||G===0?!1:U},Kt=(w,U)=>{const G=w!==null&&typeof w=="object"?w.value:w;return typeof G=="number"&&Number.isFinite(G)?G:U},go=w=>n.fade!==!1&&we(w.camerafade,!1);function Qt(w,U){if(!we(w.camerashake,!1))return null;const G=Kt(w.camerashakeamplitude,0);if(G===0)return null;const W=Math.max(0,Math.min(1,Kt(w.camerashakeroughness,0))),Y=Kt(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-W)+T*W)*G,y:(b*(1-W)+P*W)*G}}function Wn(){const w=new Date;return(w.getHours()*3600+w.getMinutes()*60+w.getSeconds())/86400}function Me(w,U,G){const W=w.get(U);W&&W.loc!==null&&G(W.loc,W.type,W.size)}function Vn(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 Jt(w,U,G){const W=w.get(U);if(!W||W.loc===null)return;const Y=G&&G.value!==void 0?G.value:G,ee=Vn(Y);switch(W.type){case"float":t.uniform1f(W.loc,ee[0]);break;case"int":case"bool":t.uniform1i(W.loc,Y===!0||Y===1?1:Math.round(ee[0]));break;case"vec2":t.uniform2f(W.loc,ee[0],ee[1]);break;case"vec3":t.uniform3f(W.loc,ee[0],ee[1],ee[2]);break;case"vec4":t.uniform4f(W.loc,ee[0],ee[1],ee[2],ee[3]);break;case"mat4":t.uniformMatrix4fv(W.loc,!1,at);break;case"mat3":t.uniformMatrix3fv(W.loc,!1,vt);break}}const tt=()=>new Float32Array([1,0,0,0,1,0,0,0,1]);function Hn(w,U,G,W,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,Wn())),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?No(En(mn(),S[0]/2,S[1]/2,1)):at;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/W,1/Y)),Me(w,"g_TexelSizeHalf",S=>t.uniform2f(S,.5/W,.5/Y)),Me(w,"g_TextureReductionScale",S=>t.uniform1f(S,1));const I=Ie(),D=Vr(!!(I&&I.has),!!w.get("g_PointerScale"));let $=D?Ln:I?I.u:.5,z=D?Ln:I?I.v:.5,B=D?Ln:I?I.lastU:.5,q=D?Ln: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,re=ce=>(C.offX+ce*C.viewW-k)/S,Q=ce=>(C.offY+ce*C.viewH-F)/E;$=re($),z=Q(z),B=re(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,ot)),w.get("g_EffectTextureProjectionMatrixInverse")&&Me(w,"g_EffectTextureProjectionMatrixInverse",S=>t.uniformMatrix4fv(S,!1,at));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,re=>t.uniform1fv(re,F))}}}function en(w,U,G){for(const[W,Y]of Object.entries(U||{})){const ee=G&&G[W];ee&&Jt(w,ee.uniform,Y)}for(const[W,Y]of Object.entries(G||{}))if(!U||!(W in U)){const ee=ni(Y.uniform,Y.default);ee!==void 0&&Jt(w,Y.uniform,ee)}}function _r(w){const U=Ie();Vr(!!(U&&U.has),!!w.get("g_PointerScale"))&&Me(w,"g_PointerScale",G=>t.uniform1f(G,0))}function Ar(w,U,G,W){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:W||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=Vn(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=ot,P.engine.timeOfDay=Wn();const B=Ie();B&&B.screenW&&B.screenH&&(P.engine.screenResolution={x:B.screenW,y:B.screenH})}const C=Vn(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 bo(w,U,G){if(!w)return w;let W=!1;for(const ee of Object.values(w))if(ee&&typeof ee=="object"&&ee.animation&&ee.animation.options){W=!0;break}if(!W)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=Zo(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 Tr(w,U,G,W){return w==null||w===""?null:w.startsWith("_rt_")?w.startsWith("_rt_imageLayerComposite")?Mn&&xt.has(w)?xt.get(w):U:G.has(w)?G.get(w):null:G.has(w)?G.get(w):W.get(w)||null}const tn=Na(),yo=Ua(),wn=new Map;function ln(w,U){const G=w+"x"+U;let W=wn.get(G);return W===void 0&&(W=Fa(w,U),wn.set(G,W)),W}let st=null;function bt(w,U){st!==w&&(t.bindBuffer(t.ARRAY_BUFFER,O),t.bufferData(t.ARRAY_BUFFER,U,t.DYNAMIC_DRAW),st=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")},yt={mvp:t.getUniformLocation(j,"u_MVP"),tex:t.getUniformLocation(j,"u_Tex"),blendPrep:t.getUniformLocation(j,"u_BlendPrep")},nn={mvp:t.getUniformLocation(H,"u_MVP"),tex:t.getUniformLocation(H,"u_Tex")},at=mn(),vt=tt();function Ct(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 Ot=0;function Lt(w){const{mode:U,prep:G}=Wr(w);Ot=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)):Ct("translucent")}function Xn(w,U){if(U&&U.perspective)return!1;const G=w.size[0]*w.scale[0],W=w.size[1]*w.scale[1];if(G===0||W===0)return!1;let Y=Math.abs(G)/2,ee=Math.abs(W)/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(yn(w.parallaxDepth[0])*Oe),P+=Math.abs(yn(w.parallaxDepth[1])*Ae));const C=Ko(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 Gn(w,U,G){if(!w.spriteSheet)return null;const W=U&&U.frames,Y=Array.isArray(W)?W:W&&W.list;if(!Y||Y.length===0)return null;const ee=W&&W.atlasWidth||U.width||0,oe=W&&W.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 $t(w,U){const G=w.size[0]*w.scale[0],W=w.size[1]*w.scale[1];let Y=mn();if(U&&U.perspective){const oe=ya(w,U);Y=bn(Y,oe[0],oe[1],oe[2]);const b=w.angles[0]||0,T=w.angles[1]||0;T&&(Y=ma(Y,T)),b&&(Y=ha(Y,b)),Y=Uo(Y,-w.angles[2])}else{if(Y=bn(Y,w.origin[0],U.projH-w.origin[1],w.origin[2]),w.parallaxDepth&&(Oe!==0||Ae!==0)){const oe=yn(w.parallaxDepth[0]),b=yn(w.parallaxDepth[1]);Y=bn(Y,oe*Oe,b*Ae,0)}Y=Uo(Y,-w.angles[2])}const ee=Xo[w.alignment]||[.5,.5];return(ee[0]!==.5||ee[1]!==.5)&&(Y=bn(Y,(.5-ee[0])*G,(.5-ee[1])*W,0)),{m:Y,w:G,h:W}}function Yn(w,U,G,W,Y,ee,oe,b,T=!1,P=null,C=null){const I=$t(W,Y);let D=I.m;if(C){const B=(C[0]+C[2]/2)*W.scale[0],q=(C[1]+C[3]/2)*W.scale[1];D=bn(D,B,-q,0),D=En(D,C[2]*W.scale[0],C[3]*W.scale[1],1)}else D=En(D,I.w,I.h,1);const $=St(ee,D),z=w===j?yt:Te;t.useProgram(w),T?(Ot=0,t.enable(t.BLEND),W.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)):Lt(W.colorBlendMode),z.blendPrep!==null&&z.blendPrep!==void 0&&t.uniform1i(z.blendPrep,Ot),ze?(t.bindFramebuffer(t.FRAMEBUFFER,ze.fbo.fbo),t.viewport(0,0,ze.w,ze.h)):(t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,oe,b)),t.bindVertexArray(K),bt("local",yo),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]),jt(z,P),t.drawArrays(t.TRIANGLES,0,6)}function jt(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 un=null,ze=null;const xt=new Map,wt=new Map;let Mn=!0;function qn(w,U){const G=$t(w,U),W=U&&U.perspective?w.scale[1]:-w.scale[1],Y=U&&U.perspective&&w.scale[2]||1;return En(G.m,w.scale[0],W,Y)}function fn(w,U,G,W,Y,ee,oe){ze?(t.bindFramebuffer(t.FRAMEBUFFER,ze.fbo.fbo),t.viewport(0,0,ze.w,ze.h)):(t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,W,Y));const b=St(G,qn(w,U));un(w,b,{time:ee,overrideTex:oe||null}),st=null}let dt=null;function Zn(w,U){return dt===null&&(dt=t.createTexture(),t.bindTexture(t.TEXTURE_2D,dt),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,dt),t.copyTexImage2D(t.TEXTURE_2D,0,t.RGB8,0,0,w,U,0),dt}function Sr(w,U,G,W,Y,ee,oe,b){const T=Zn(oe,b),P=$t(w,Y);let C=P.m;C=En(C,P.w,P.h,1);const I=St(ee,C),D=[[-.5,.5],[.5,.5],[-.5,-.5],[.5,-.5]].map(([E,k])=>{const F=xa(I,E,k,0);return[F[0]*.5+.5,F[1]*.5+.5]}),[$,z,B,q]=D,S=new Float32Array([0,W,0,$[0],$[1],0,0,0,B[0],B[1],G,W,0,z[0],z[1],G,W,0,z[0],z[1],0,0,0,B[0],B[1],G,0,0,q[0],q[1]]);t.useProgram(H),Ct("normal"),t.disable(t.BLEND),t.bindFramebuffer(t.FRAMEBUFFER,U.fbo),t.viewport(0,0,G,W),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),st=null,t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,T),t.uniform1i(nn.tex,0),t.uniformMatrix4fv(nn.mvp,!1,gn(0,G,0,W,-1e4,1e4)),t.drawArrays(t.TRIANGLES,0,6),t.enable(t.BLEND)}function zt(w,U,G,W,Y){if(!Mn||ze)return;const ee=wt.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);Sr(w,T,oe,b,U,G,W,Y);for(const P of ee)xt.set(P,T);wt.delete(w.id),t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,W,Y)}async function vo(w,U,G,W,Y,ee,oe,b){X++,t.viewport(0,0,G,W);const T=w.general||{};if(T.clearenabled!==!1){const S=Yo(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),it>=0){const S=Y-it;ot=S>0&&S<1?S:Math.min(.1,Math.max(.001,S||1/60))}it=Y;const P=_a(w,G,W,ee,oe,b);let C=St(P.projection,P.view);const I=T.cameraparallax,D=I===!0||I!==null&&typeof I=="object"&&I.value===!0;Oe=0,Ae=0;const $=Ie();if($&&(Pe.x=$.u*2-1,Pe.y=$.v*2-1),!P.perspective&&n.parallax!==!1&&D){const S=(_t,de)=>{const pe=_t!==null&&typeof _t=="object"?_t.value:_t;return typeof pe=="number"&&Number.isFinite(pe)?pe:de},E=S(T.cameraparallaxamount,0),k=S(T.cameraparallaxmouseinfluence,1),F=S(T.cameraparallaxdelay,1),re=Y-Qe;Qe=Y;const Q=re>0?1-Math.exp(-re/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,ge=Pe.sx*ce*P.viewW,$e=Pe.sy*ce*P.viewH,Mt=Math.max(Math.abs(ge),Math.abs($e))/ue,kt=Mt>1?1/Mt:1;Oe=-(ge*kt),Ae=-($e*kt)}if(!P.perspective&&n.shake!==!1){const S=Qt(T,Y);if(S){const E=S.x*P.viewW*.02,k=S.y*P.viewH*.02;(E!==0||k!==0)&&(C=St(C,bn(mn(),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(re=>re.visible)&&!F.hasChildren),k=E.filter(F=>(F.effects||[]).some(re=>(re.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 xo(w,U,P,G,W,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||ar(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){wt.has(S.id)&&zt(S,P,C,G,W);continue}if(!(S.isPostProcess&&!(S.effects||[]).some(E=>E.visible))&&!B.has(S.id)){if(S.isContainer){if(!(S.effects||[]).some(k=>k.visible)){zt(S,P,C,G,W);continue}if(S.hasChildren){(S.childIds||[]).length>0&&await Er(S,w,U,P,C,G,W,Y);continue}}if(S.particle){if(u)try{await u(S.id,P,C,G,W)}catch(E){o("particle render error: "+(E&&E.message))}continue}Xn(S,P)||await Rt(S,U,P,C,G,W,Y)}}if(go(T)&&Y<It){const S=Math.max(0,Math.min(1,Y/It)),E=1-S*S*(3-2*S);if(E>.002){const k=Yo(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,W),t.bindVertexArray(K),bt("pass",tn),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,Ke),t.uniform1i(Te.tex,0),t.uniform4f(Te.color,k[0],k[1],k[2],E),jt(Te,null),Te.blendPrep!==null&&Te.blendPrep!==void 0&&t.uniform1i(Te.blendPrep,0),t.uniformMatrix4fv(Te.mvp,!1,at),t.drawArrays(t.TRIANGLES,0,6)}}t.bindVertexArray(null),J()}async function xo(w,U,G,W,Y,ee){xt.clear(),wt.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)){wt.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:gn(0,B,0,q,-1e4,1e4),eye:G.eye,projW:B,projH:q,offX:0,offY:0,viewW:B,viewH:q},k=ze,F=D.origin,re=D.scale,Q=D.angles,ce=D.visible;ze={fbo:S,w:B,h:q},D.origin=[B/2,E.projH-q/2,F[2]],D.scale=[Math.sign(re[0])||1,Math.sign(re[1])||1,re[2]],D.angles=[0,0,0],D.visible=!0;try{await Rt(D,U,E,E.projection,B,q,ee);for(const ue of I)xt.set(ue,S)}catch(ue){o(`composite \u6E90\u5C42 ${C} \u6E32\u67D3\u5931\u8D25: ${ue&&ue.message}`)}finally{ze=k,D.origin=F,D.scale=re,D.angles=Q,D.visible=ce}}t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,W,Y)}}async function Er(w,U,G,W,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=ar(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:W.view,projection:gn(0,T,0,P,-1e4,1e4),eye:W.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),re=Math.sin(-k);ze={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,ge=Q.angles,$e=ce[0]-w.origin[0],Mt=ce[1]-w.origin[1],kt=($e*F-Mt*re)/S,_t=($e*re+Mt*F)/E;Q.origin=[T/2+kt,P/2+_t,ce[2]],Q.scale=[ue[0]/S,ue[1]/E,ue[2]],Q.angles=[ge[0],ge[1],ge[2]-k];try{await Rt(Q,G,B,q,T,P,b)}finally{Q.origin=ce,Q.scale=ue,Q.angles=ge}}}finally{ze=null}w.groupTex=z.tex,w.groupW=T,w.groupH=P;try{await Rt(w,G,W,Y,ee,oe,b)}finally{w.groupTex=null}}async function Rt(w,U,G,W,Y,ee,oe){const b=!!(w.puppet&&un),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,ct=t.getParameter(t.MAX_TEXTURE_SIZE),lt=ct>0&&ct<4096?Math.min(Ee,ct):Ee;let At=1;Math.max(pe,fe)>lt&&(At=lt/Math.max(pe,fe));const nt=Math.max(1,Math.round(pe*At)),Ce=Math.max(1,Math.round(fe*At));let _n=de;if(i&&nt>0&&Ce>0){(i.width!==nt||i.height!==Ce)&&(i.width=nt,i.height=Ce);const ut=i.getContext("2d");ut&&(ut.clearRect(0,0,nt,Ce),ut.drawImage(de,0,0,nt,Ce),_n=i)}if(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,_n),t.getError()!==t.NO_ERROR&&i)try{const Ge=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(Ge.data.buffer));t.getError()!==t.NO_ERROR;);}catch{}T.width=nt,T.height=Ce,T.lastUploaded=de.currentTime,s||(s=!0,o("video tex ready "+nt+"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?Ke:Be,C=(!!w.passthrough||!!w.isPostProcess||Qo(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 ct=Math.max(64,Math.round(fe*a)),lt=Math.max(64,Math.round(Ee*a));ct<$&&(S=ct),lt<z&&(E=lt)}}if(q.length===0){b?fn(w,G,W,Y,ee,oe):Yn(N,P,B,w,G,W,Y,ee,!1,Gn(w,T,oe));return}const k=ie(S,E,"ping"),F=ie(S,E,"pong"),re=gn(0,S,0,E,-1e4,1e4);if(b)t.useProgram(N),Ct("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),st=null,bt("layer"+S+"x"+E,ln(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),jt(Te,null),Te.blendPrep!==null&&Te.blendPrep!==void 0&&t.uniform1i(Te.blendPrep,0),t.uniformMatrix4fv(Te.mvp,!1,re),t.drawArrays(t.TRIANGLES,0,6);else if(C)Sr(w,k,S,E,G,W,Y,ee);else{t.useProgram(N),Ct("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),bt("layer"+S+"x"+E,ln(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]),jt(Te,Gn(w,T,oe)),Te.blendPrep!==null&&Te.blendPrep!==void 0&&t.uniform1i(Te.blendPrep,0),t.uniformMatrix4fv(Te.mvp,!1,re),t.drawArrays(t.TRIANGLES,0,6)}let Q=k,ce=F;const ue=new Map;let ge=!1,$e=k;const Mt=[],kt=new Set;for(const de of q){for(const fe of de.fbos||[])if(!ue.has(fe.name)){const[Ee,ct]=Jo(fe,S,E),lt=fe.unique?w.id+":"+fe.name:fe.name;ue.set(fe.name,ie(Ee,ct,lt))}const pe=de.materialPasses||[];for(let fe=0;fe<pe.length;fe++)Mt.push({eff:de,mp:pe[fe],ov:de.passes&&de.passes[fe]})}const _t=[];for(let de=0;de<Mt.length;de++){const{eff:pe,mp:fe,ov:Ee}=Mt[de];if(kt.has(pe))continue;const ct={...fe.combos||{},...Ee&&Ee.combos||{}},lt=fe.textures||[],At=Ee&&Ee.textures||[],nt=[];for(let ve=0;ve<Math.max(lt.length,At.length);ve++)At[ve]!==void 0&&At[ve]!==null?nt[ve]=At[ve]:nt[ve]=lt[ve]!==void 0?lt[ve]:null;if(fe.copyCommand){const ve=fe.source?ue.get(fe.source):null,ke=fe.target?ue.get(fe.target):null;ve&&ke&&(t.useProgram(j),Ct("normal"),t.bindFramebuffer(t.FRAMEBUFFER,ke.fbo),t.viewport(0,0,ke.width,ke.height),t.bindVertexArray(K),bt("pass",tn),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,ve.tex),t.uniform1i(yt.tex,0),yt.blendPrep!==null&&yt.blendPrep!==void 0&&t.uniform1i(yt.blendPrep,0),t.uniformMatrix4fv(yt.mvp,!1,at),t.drawArrays(t.TRIANGLES,0,6),t.bindFramebuffer(t.FRAMEBUFFER,null));continue}let Ce;try{Ce=await De(fe.shader,ct,nt)}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:",fe.shader,ke),kt.add(pe);continue}const _n=Ce.prog,ut=Ce.uni;Ce.fragGlsl&&_t.push(Ce.fragGlsl);let Ge,Kn;fe.target?(ge||($e=Q,ge=!0),Ge=ue.get(fe.target)||Q,Kn=$e):(ge=!1,Ge=ce,Kn=Q),t.useProgram(_n),Ct(fe.blending||"normal"),t.bindFramebuffer(t.FRAMEBUFFER,Ge.fbo),t.viewport(0,0,Ge.width,Ge.height),t.bindVertexArray(K);const _s=!Ce.ndcDirect;_s?bt("passPx"+Ge.width+"x"+Ge.height,ln(Ge.width,Ge.height)):bt("pass",tn);const Gu=_s?No(gn(0,Ge.width,0,Ge.height,-1e4,1e4)):at,wo=fe.textures||[],Yu=Math.max(wo.length,8),As=new Map,qu=new Set;for(let ve=0;ve<Yu;ve++){let ke=ve<wo.length?wo[ve]:null;Ee&&Ee.textures&&Ee.textures[ve]!==void 0&&Ee.textures[ve]!==null&&(ke=Ee.textures[ve]);for(const Jn of fe.binds||[])Jn.index===ve&&(ke=Jn.name);let Ft;if(ve===0&&(ke==null||ke===""))Ft=Kn;else{if((ke==null||ke==="")&&Ce.samplerDefaults){const Jn=Ce.samplerDefaults.get(ve);Jn&&(ke=Jn)}Ft=Tr(ke,Kn,ue,U)}ke==="previous"&&(Ft=Kn),Ft===null&&(Ft={glTex:Ke,width:1,height:1,tex:Ke});const Qn=Ft.fbo?Ft:{tex:Ft.glTex||Ke,width:Ft.width||1,height:Ft.height||1};t.activeTexture(t.TEXTURE0+ve),t.bindTexture(t.TEXTURE_2D,Qn.tex),qu.add(ve),As.set(ve,[Qn.width,Qn.height,Qn.width,Qn.height])}Hn(ut,w,oe,G.projW,G.projH,Gu,re,at,As,re,G),en(ut,bo(Ar({...fe.constants||{},...Ee&&Ee.constantshadervalues||{}},(w.id||w.name||"?")+"|"+(fe.shader||"?")+"|"+de,oe,w),(w.id||w.name||"?")+"|"+(fe.shader||"?")+"|"+de,oe),Ce.matMeta),_r(ut),t.drawArrays(t.TRIANGLES,0,6),fe.target||(ce=Q,Q=Ge)}if(w.isContainer&&!w.groupTex&&!C&&w.containerAlphaMeaningful===void 0){let de=!1;for(const pe of _t){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){fn(w,G,W,Y,ee,oe,Q.tex);return}Yn(j,Q.tex,[1,1,1,1],w,G,W,Y,ee,!!w.isContainer&&!w.groupTex&&!C,null,null)}return{gl:t,render:vo,getFBO:ie,getEffectProgram:De,progCache:Z,shaderResolver:r,whiteTex:Ke,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){Mn=!!w},compositeStats:function(){const w=[],U=new Uint8Array(4);for(const[G,W]of xt){let Y=null;try{t.bindFramebuffer(t.FRAMEBUFFER,W.fbo),t.readPixels(W.w>>1,W.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:W.w,h:W.h,center:Y})}return t.bindFramebuffer(t.FRAMEBUFFER,null),w},setPuppetRenderer:function(w){un=w},setAudioProvider:p,setPointerProvider:he,getParallaxOffset:function(){return{x:Oe,y:Ae}},dispose:function(){try{const w=t.getExtension("WEBGL_lose_context");w&&w.loseContext()}catch{}}}}const Xa=Object.freeze(Object.defineProperty({__proto__:null,ALIGN:Xo,XRAY_IDLE_SCREEN_UV:Ln,XRAY_SIZE_FALLBACK:ti,applyColorBlendCPU:za,collectGroupDescendantIds:ar,colorBlendPlan:Wr,constantFallback:ni,createRenderer:Ha,effectFboSize:Jo,layerWantsPreserveBackdrop:Qo,makeTexture:jr,makeTextureMip:Ba,puppetAnimMargin:Ko,rewriteXrayFragScale:ei,xrayShouldParkPointer:Vr,xrayUvScale:Wa},Symbol.toStringTag,{value:"Module"}));function Ga(e=256,n=8){const t=e/n,r=ri(1337),o=ri(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,V=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(V*255),a[X+2]=0,a[X+3]=255}}return a}function ri(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 Ya=Object.freeze(Object.defineProperty({__proto__:null,generateNoiseTexture:Ga},Symbol.toStringTag,{value:"Module"})),ht=Math.PI*2;function Le(e,n){return e==null?Math.random():n==null?e:e+Math.random()*(n-e)}function oi(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 ii(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 Hr(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 Xt(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(Xt(r,o,i),Xt(r+1,o,i),u),y=p(Xt(r,o+1,i),Xt(r+1,o+1,i),u),x=p(Xt(r,o,i+1),Xt(r+1,o,i+1),u),m=p(Xt(r,o+1,i+1),Xt(r+1,o+1,i+1),u);return p(p(d,y,l),p(x,m,l),f)}function Xr(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 Gr(e,n,t,r){return[Xr(e,n,t,r)*2-1,Xr(e+31.7,n+11.3,t+57.1,r)*2-1,Xr(e+73.9,n+92.1,t+13.7,r)*2-1]}function Za(e){const n=`#version 300 es
65
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
66
68
  layout(location=0) in vec2 a_corner; // -0.5..0.5
67
69
  layout(location=1) in vec3 a_pos; // \u5B9E\u4F8B\u4E2D\u5FC3\uFF08\u6295\u5F71\u7A7A\u95F4\u4E16\u754C\u5750\u6807\uFF09
@@ -136,7 +138,7 @@ void main(){
136
138
  if (col.a < 0.004) discard;
137
139
  }
138
140
  fragColor = col;
139
- }`,o=(f,l)=>{const d=e.createShader(f);if(e.shaderSource(d,l),e.compileShader(d),!e.getShaderParameter(d,e.COMPILE_STATUS))throw new Error("\u7C92\u5B50 shader: "+e.getShaderInfoLog(d));return d},r=e.createProgram();if(e.attachShader(r,o(e.VERTEX_SHADER,n)),e.attachShader(r,o(e.FRAGMENT_SHADER,t)),e.linkProgram(r),!e.getProgramParameter(r,e.LINK_STATUS))throw new Error("\u7C92\u5B50 shader \u94FE\u63A5\u5931\u8D25: "+e.getProgramInfoLog(r));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(),c=e.createVertexArray();e.bindVertexArray(c),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 a=56;return e.enableVertexAttribArray(1),e.vertexAttribPointer(1,3,e.FLOAT,!1,a,0),e.vertexAttribDivisor(1,1),e.enableVertexAttribArray(2),e.vertexAttribPointer(2,2,e.FLOAT,!1,a,12),e.vertexAttribDivisor(2,1),e.enableVertexAttribArray(3),e.vertexAttribPointer(3,4,e.FLOAT,!1,a,20),e.vertexAttribDivisor(3,1),e.enableVertexAttribArray(4),e.vertexAttribPointer(4,3,e.FLOAT,!1,a,36),e.vertexAttribDivisor(4,1),e.enableVertexAttribArray(5),e.vertexAttribPointer(5,2,e.FLOAT,!1,a,48),e.vertexAttribDivisor(5,1),e.bindVertexArray(null),{prog:{prog:r,uniTex:e.getUniformLocation(r,"u_tex"),uniNormal:e.getUniformLocation(r,"u_normal"),uniScene:e.getUniformLocation(r,"u_scene"),uniRefract:e.getUniformLocation(r,"u_refract"),uniSampleScene:e.getUniformLocation(r,"u_sampleScene"),uniResolution:e.getUniformLocation(r,"u_resolution"),uniRefractScale:e.getUniformLocation(r,"u_refractScale"),uniMvp:e.getUniformLocation(r,"u_mvp"),uniFrameCount:e.getUniformLocation(r,"u_frameCount"),uniFrames:e.getUniformLocation(r,"u_frames")},quadBuf:i,vbuf:s,vao:c}}function Ho(e){const n=e&&e.passes&&e.passes[0]&&e.passes[0].combos;return!!(n&&Number(n.REFRACT)===1)}function Aa(e){if(!e||e.length<16)return!1;const n=e.length/4,t=Math.max(1,n/64|0);let o=0;for(let r=0;r<n;r+=t){const i=r*4;if(e[i]<250||e[i+1]<250||e[i+2]<250||e[i+3]<250)return!1;o++}return o>0}function Xo(e,n,t,o){let r=Math.abs(Number(e)||0)*(Number(n)||0);const i=Number(t)||0,s=Number(o)||0;return i>0&&(r=Math.max(i,r)),s>0&&(r=Math.min(s,r)),r}function Vr(e,n){return e||n?Math.atan2(n,e)-Math.PI/2:0}function Go(e,n){return e&&e.kind==="ropetrail"?Math.max(1,n||1):1}function Yo(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 qo(e){if(!e||e.kind!=="ropetrail")return 0;const n=Number(e.length);return Number.isFinite(n)&&n>0?n:.2}function Wr(e){return e.life>0?e.age/e.life:0}class _a{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 Ta{constructor(n,t,o,r){this.gl=n,this.model=t||{},this.override=o||{},this.layer=r||null;const i=r&&r.origin?r.origin:[0,0,0],s=r&&r.scale?r.scale:[1,1,1],c=r&&r.angles?r.angles:[0,0,0];this.originX=i[0]||0,this.originY=i[1]||0,this.originZ=i[2]||0,this.scaleX=s[0]===0?1:s[0],this.scaleY=s[1]===0?1:s[1],this.angleZ=(c[2]||0)*Math.PI/180;const a=Math.abs(this.scaleX),f=Math.abs(this.scaleY);this.sysScale=Math.min(a,f)||1,this.spriteStretchX=a/this.sysScale,this.spriteStretchY=f/this.sysScale,this.maxCount=Math.max(1,Math.min(2e4,G(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(G(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(l=>({id:G(l.id,0),lockToPointer:!!l.locktopointer||(G(l.flags,0)&1)!==0,offset:me(l.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,G(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,G(this.model.maxcount,100)));const n=this.override||{};for(const t of Object.keys(n)){if(t==="id")continue;const o=n[t],r=o&&typeof o=="object"&&"value"in o?o.value:o;if(t==="count"){const i=G(this.model.maxcount,100),s=Number(r),c=Number.isFinite(s)?s:1;this.maxCount=Math.max(1,Math.min(2e4,Math.round(i*c))),this._ov.countMul=c}else if(t==="alpha")this.opacityMul=Number(r),Number.isFinite(this.opacityMul)||(this.opacityMul=1);else if(t==="color"||t==="colorn"){const i=me(r);this._ov.color=t==="colorn"?i:[i[0]/255,i[1]/255,i[2]/255]}else t==="size"?this._ov.size=Number(r)||1:t==="rate"?(this._ov.rateMul=Number(r),Number.isFinite(this._ov.rateMul)||(this._ov.rateMul=1)):t==="speed"?this._ov.speed=Number(r)||1:t==="lifetime"?this.lifetimeMul=Number(r)||1:t==="brightness"?this._ov.brightness=Number(r)||1:this._ov[t]=r}this.pool=[];for(let t=0;t<this.maxCount;t++)this.pool.push(new _a)}_compile(){const n=this.model;this.emitters=(n.emitter||[]).map(a=>({kind:a.name==="boxrandom"?"box":"sphere",origin:me(a.origin),directions:me(a.directions,[1,1,1]),distanceMin:Wo(a.distancemin),distanceMax:Wo(a.distancemax),sign:a.sign?me(a.sign):null,rate:G(a.rate,0),audioDriven:a.audioprocessingmode!==void 0,audioBounds:me(a.audioprocessingbounds,[0,1]),fill:a.rate===void 0&&a.instantaneous===void 0&&a.audioprocessingmode===void 0,instantaneous:G(a.instantaneous,0),speedMin:G(a.speedmin,0),speedMax:G(a.speedmax,0),controlPoint:a.controlpoint!==void 0&&a.controlpoint!==null?G(a.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 a of t)switch(a.name){case"lifetimerandom":this.init.life={min:G(a.min,1),max:G(a.max,1),exp:G(a.exponent,1)};break;case"sizerandom":this.init.size={min:G(a.min,1),max:G(a.max,1),exp:G(a.exponent,1)};break;case"colorrandom":this.init.color={min:me(a.min,[255,255,255]),max:me(a.max,[255,255,255])};break;case"alpharandom":this.init.alpha={min:G(a.min,1),max:G(a.max,1)};break;case"velocityrandom":this.init.velocity={min:me(a.min),max:me(a.max)};break;case"rotationrandom":this.init.rotation={min:me(a.min),max:me(a.max,[0,0,0]),exp:G(a.exponent,1)};break;case"angularvelocityrandom":this.init.angularVelocity={min:me(a.min),max:me(a.max),exp:G(a.exponent,1)};break;case"mapsequencearoundcontrolpoint":this.init.mapAround={count:Math.max(1,G(a.count,1)),bounds:me(a.bounds,[0,1]),speedMin:me(a.speedmin),speedMax:me(a.speedmax,[0,0,0]),cp:G(a.controlpoint,0)},this._mapAroundSeq=0;break;case"turbulentvelocityrandom":this.init.turbulentVelocity={scale:G(a.scale,.1),offset:G(a.offset,0),speedMin:G(a.speedmin,0),speedMax:G(a.speedmax,0),phaseMax:G(a.phasemax,0),timeScale:G(a.timescale,0),audioMode:G(a.audioprocessingmode,0),audioBounds:me(a.audioprocessingbounds,[0,1])};break}const o=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 a of o)switch(a.name){case"movement":this.ops.movement={gravity:me(a.gravity),drag:G(a.drag,0)};break;case"angularmovement":this.ops.angularMovement={force:me(a.force),drag:G(a.drag,0)};break;case"alphafade":this.ops.alphaFade={fadeIn:G(a.fadeintime,.1),fadeOut:G(a.fadeouttime,.9)};break;case"alphachange":this.ops.alphaChange={startTime:G(a.starttime,0),endTime:G(a.endtime,1),startValue:G(a.startvalue,1),endValue:G(a.endvalue,0)};break;case"sizechange":this.ops.sizeChange={startTime:G(a.starttime,0),endTime:G(a.endtime,1),startValue:G(a.startvalue,1),endValue:G(a.endvalue,1)};break;case"colorchange":this.ops.colorChange={startTime:G(a.starttime,0),endTime:G(a.endtime,1),startValue:a.startvalue!==void 0?me(a.startvalue):null,endValue:me(a.endvalue,[1,1,1])};break;case"turbulence":this.ops.turbulence.push({scale:G(a.scale,.01),speedMin:G(a.speedmin,0),speedMax:G(a.speedmax,0),timeScale:G(a.timescale,1),phaseMin:G(a.phasemin,0),phaseMax:G(a.phasemax,0),mask:a.mask!==void 0?me(a.mask,[1,1,1]):[1,1,1]});break;case"oscillatealpha":this.ops.oscAlpha={freqMin:G(a.frequencymin,G(a.frequencymax,1)),freqMax:G(a.frequencymax,1),scaleMin:G(a.scalemin,0),scaleMax:G(a.scalemax,1),phaseMax:G(a.phasemax,lt)};break;case"oscillatesize":this.ops.oscSize={freqMin:G(a.frequencymin,G(a.frequencymax,1)),freqMax:G(a.frequencymax,G(a.frequencymin,1)),scaleMin:G(a.scalemin,1),scaleMax:G(a.scalemax,1),phaseMax:G(a.phasemax,lt)};break;case"oscillateposition":this.ops.oscPos={freqMin:G(a.frequencymin,G(a.frequencymax,.5)),freqMax:G(a.frequencymax,.5),scaleMin:G(a.scalemin,0),scaleMax:G(a.scalemax,1),phaseMin:G(a.phasemin,0),phaseMax:G(a.phasemax,lt),mask:a.mask!==void 0?me(a.mask,[1,1,0]):[1,1,0]};break;case"controlpointattract":this.ops.attract.push({cp:G(a.controlpoint,0),origin:me(a.origin),scale:G(a.scale,0),threshold:G(a.threshold,0)});break;case"vortex":this.ops.vortex.push({axis:me(a.axis,[0,0,1]),offset:me(a.offset),distanceInner:G(a.distanceinner,0),distanceOuter:G(a.distanceouter,0),speedInner:G(a.speedinner,0),speedOuter:G(a.speedouter,0),cp:a.controlpoint!==void 0&&a.controlpoint!==null?G(a.controlpoint,0):0,audioMode:G(a.audioprocessingmode,0),audioBounds:me(a.audioprocessingbounds,[0,1])});break;case"remapvalue":this.ops.remap.push({output:a.output||"velocity",rangeMin:me(a.outputrangemin),rangeMax:me(a.outputrangemax),fn:a.transformfunction||"simplexnoise",inputScale:G(a.transforminputscale,1)});break}const r=this.model.renderer,i=r==null,s=Array.isArray(r)?r:r?[r]:[];this.renderers=s.map(a=>{const f=a&&a.name||"sprite";return{kind:f,length:G(a&&a.length,f==="spritetrail"?.1:f==="ropetrail"?.2:0),maxLength:G(a&&a.maxlength,0),minLength:G(a&&a.minlength,0),subdivision:G(a&&a.subdivision,1),segments:G(a&&a.segments,0),orientation:a&&a.orientation||null}}),i&&!this.renderers.length&&(this.renderers=[{kind:"sprite",length:0,maxLength:0,minLength:0,subdivision:1,segments:0,orientation:null}]);const c=this.renderers.find(a=>a.kind==="spritetrail"||a.kind==="ropetrail");if(this.trailCfg=c||null,this.trailSegments=1,this.trailDuration=0,this.trailSampleDt=0,c&&c.kind==="ropetrail"){const a=Yo(c);this.trailSegments=a,this.trailDuration=qo(c),this.trailSampleDt=this.trailDuration/Math.max(1,a-1);for(const f of this.pool)f.trail=new Float32Array(a*3),f.trailClock=0}this.ropeRenderer=this.renderers.find(a=>a.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=Ho(n);const o=t&&t.constantshadervalues,r=o&&o.ui_editor_properties_refract_amount,i=Number(r);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,o=Array.isArray(t)?t:t&&t.list&&t.list.length?t.list:null,r=n&&n.width||o&&(t&&t.atlasWidth||o.atlasWidth)||0,i=n&&n.height||o&&(t&&t.atlasHeight||o.atlasHeight)||0;o&&r>0&&i>0?(this.texFrames=o.map(f=>({ou:f.x/r,ov:f.y/i,su:f.width/r,sv:f.height/i})),this.frameCount=this.texFrames.length):(this.texFrames=null,this.frameCount=this.sequenceMul*this.sequenceMul);let s=1,c=1;this.texFrames&&o?(s=o[0].width||1,c=o[0].height||1):n&&n.width>0&&n.height>0&&(s=n.width,c=n.height);const a=Math.max(s,c)||1;this.texAspectX=s/a,this.texAspectY=c/a,this._frameData=void 0}setVisible(n){this.visible=n}setPointer(n,t){const o=n-this.originX,r=t-this.originY,i=Math.cos(-this.angleZ),s=Math.sin(-this.angleZ);this.pointer={x:(o*i-r*s)/(this.scaleX||1),y:(o*s+r*i)/(this.scaleY||1)}}attachFollow(n,t,o){this._followParent=n||null,this._followMode=t==="particle"||t==="origin"?t:null;const r=o||[0,0,0];this._followOffset=[r[0]||0,r[1]||0,r[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 o=n*this.scaleX,r=t*this.scaleY,i=Math.cos(this.angleZ),s=Math.sin(this.angleZ);return[this.originX+o*i-r*s,this.originY+o*s+r*i]}_syncFollow(){const n=this._followParent,t=this._followMode;if(!n||!t)return;const o=this._followOffset;if(t==="particle"){const r=n.leaderParticle();if(!r)return;const i=n.localToWorld(r.x+o[0],r.y+o[1]);this.originX=i[0],this.originY=i[1]}else{const r=n.localToWorld(o[0],o[1]);this.originX=r[0],this.originY=r[1]}}spawn(n){const t=this.pool,o=t.length;let r=null,i=this._cursor||0;for(let d=0;d<o;d++){const h=t[(i+d)%o];if(!h.alive){r=h,this._cursor=(i+d+1)%o;break}}if(!r)return;r.alive=!0,r.age=0,r.seed=Math.random(),r.rot=0,r.rotVel=0,r.vx=r.vy=r.vz=0,r.frame=0,r.seq=this._seq++;const s=n.origin;if(n.kind==="box"){const d=n.distanceMax||[0,0,0],h=n.distanceMin;r.x=s[0]+Ce(-d[0],d[0])+(h?h[0]:0),r.y=s[1]+Ce(-d[1],d[1])+(h?h[1]:0),r.z=s[2]+Ce(-d[2],d[2])+(h?h[2]:0)}else{const d=n.directions,h=n.distanceMin?n.distanceMin[0]:0,m=n.distanceMax?n.distanceMax[0]:0,M=Math.random()*2-1,g=Math.random()*lt,y=Math.sqrt(Math.max(0,1-M*M));let b=y*Math.cos(g),p=y*Math.sin(g),v=M;n.sign&&(n.sign[0]&&(b=Math.abs(b)*Math.sign(n.sign[0])),n.sign[1]&&(p=Math.abs(p)*Math.sign(n.sign[1])),n.sign[2]&&(v=Math.abs(v)*Math.sign(n.sign[2])));const _=Ce(h,m);if(r.x=s[0]+b*_*d[0],r.y=s[1]+p*_*d[1],r.z=s[2]+v*_*d[2],n.speedMax||n.speedMin){const w=Ce(n.speedMin,n.speedMax);r.vx+=b*w,r.vy+=p*w,r.vz+=v*w}}{const d=this._cpPos(n.controlPoint);if(d)r.x+=d[0],r.y+=d[1],r.z+=d[2];else{const h=this.controlPoints.find(m=>m.id===n.controlPoint);if(h&&h.lockToPointer){r.alive=!1;return}}}if(this.init.mapAround){const d=this.init.mapAround,h=this._cpPos(d.cp);if(h){const m=d.count,M=this._mapAroundSeq++,g=m>0?M%m/m:0,b=(d.bounds[0]+(d.bounds[1]-d.bounds[0])*g)*lt,p=n.distanceMin?n.distanceMin[0]:0,v=n.distanceMax?n.distanceMax[0]:0,_=v>0?v:p;r.x=h[0]+Math.cos(b)*_,r.y=h[1]+Math.sin(b)*_,r.z=h[2];const w=Math.random();r.vx+=d.speedMin[0]+(d.speedMax[0]-d.speedMin[0])*w,r.vy+=d.speedMin[1]+(d.speedMax[1]-d.speedMin[1])*w,r.vz+=d.speedMin[2]+(d.speedMax[2]-d.speedMin[2])*w}}const c=this.init,a=this._ov.speed||1,f=this._ov.size||1;if(r.life=c.life?Math.max(.001,Vo(c.life.min,c.life.max,c.life.exp)*this.lifetimeMul):1,r.baseSize=c.size?Vo(c.size.min,c.size.max,c.size.exp)*f:f,r.size=r.baseSize,c.color){const d=c.color.min,h=c.color.max,m=Math.random();r.baseR=(d[0]+(h[0]-d[0])*m)/255,r.baseG=(d[1]+(h[1]-d[1])*m)/255,r.baseB=(d[2]+(h[2]-d[2])*m)/255}else r.baseR=r.baseG=r.baseB=1;if(this._ov.color&&(r.baseR=this._ov.color[0],r.baseG=this._ov.color[1],r.baseB=this._ov.color[2]),r.r=r.baseR,r.g=r.baseG,r.b=r.baseB,r.baseAlpha=(c.alpha?Ce(c.alpha.min,c.alpha.max):1)*this.opacityMul,r.alpha=r.baseAlpha,c.velocity&&(r.vx+=Ce(c.velocity.min[0],c.velocity.max[0])*a,r.vy+=Ce(c.velocity.min[1],c.velocity.max[1])*a,r.vz+=Ce(c.velocity.min[2],c.velocity.max[2])*a),c.turbulentVelocity){const d=c.turbulentVelocity,h=d.audioMode?$r(d.audioBounds,this._audioLevel||0):1,m=Ce(d.speedMin,d.speedMax)*a*h,M=this.simTime*(d.timeScale||0),g=jr(r.x*d.scale+d.offset,r.y*d.scale+d.offset,M+r.seed*(d.phaseMax||0),3);r.vx+=g[0]*m,r.vy+=g[1]*m,r.vz+=g[2]*m}c.rotation&&(r.rot=Ce(c.rotation.min[2],c.rotation.max[2])),c.angularVelocity&&(r.rotVel=Ce(c.angularVelocity.min[2],c.angularVelocity.max[2]));const l=this.ops;if(l.oscPos&&(r.oscFreq=Ce(l.oscPos.freqMin,l.oscPos.freqMax),r.oscAmp=Ce(l.oscPos.scaleMin,l.oscPos.scaleMax),r.oscPhase=Ce(l.oscPos.phaseMin,l.oscPos.phaseMax)+r.seed*lt),l.oscAlpha&&(r.oscAFreq=Ce(l.oscAlpha.freqMin,l.oscAlpha.freqMax),r.oscAPhase=Math.random()*(l.oscAlpha.phaseMax||lt)),l.oscSize&&(r.oscSFreq=Ce(l.oscSize.freqMin,l.oscSize.freqMax),r.oscSPhase=Math.random()*(l.oscSize.phaseMax||lt)),l.turbulence.length){const d=l.turbulence[0];r.turbSpeed=Ce(d.speedMin,d.speedMax),r.turbPhase=Ce(d.phaseMin,d.phaseMax)}if(this.frameCount>1&&(r.frame=this.animationMode==="randomframe"?Math.floor(Math.random()*this.frameCount):0),r.bx=r.x,r.by=r.y,r.bz=r.z,r.trail){for(let d=0;d<r.trail.length;d+=3)r.trail[d]=r.x,r.trail[d+1]=r.y,r.trail[d+2]=r.z;r.trailClock=0}}updateParticle(n,t){if(n.age+=t,n.age>=n.life){n.alive=!1;return}const o=n.age/n.life,r=this.ops;if(r.movement&&(n.vx+=r.movement.gravity[0]*t,n.vy+=r.movement.gravity[1]*t,n.vz+=r.movement.gravity[2]*t,r.movement.drag>0)){const c=Math.exp(-r.movement.drag*t);n.vx*=c,n.vy*=c,n.vz*=c}r.angularMovement&&(n.rotVel+=(r.angularMovement.force[2]||0)*t,r.angularMovement.drag>0&&(n.rotVel*=Math.exp(-r.angularMovement.drag*t)));for(const c of r.turbulence){const a=c.timeScale||1,f=jr(n.bx*c.scale,n.by*c.scale,this.simTime*c.scale*a+n.turbPhase,3);n.vx+=f[0]*n.turbSpeed*c.mask[0]*t,n.vy+=f[1]*n.turbSpeed*c.mask[1]*t,n.vz+=f[2]*n.turbSpeed*c.mask[2]*t}for(const c of r.attract){const a=this._cpPos(c.cp);if(!a)continue;const f=a[0]+c.origin[0]-n.x,l=a[1]+c.origin[1]-n.y,d=Math.hypot(f,l);if(d<.001||c.threshold>0&&d>c.threshold)continue;const h=c.threshold>0?1-d/c.threshold:1,m=c.scale*h*t/Math.max(1,d);n.vx+=f*m,n.vy+=l*m}for(const c of r.vortex){const a=this._cpPos(c.cp)||[0,0,0],f=n.x-(a[0]+c.offset[0]),l=n.y-(a[1]+c.offset[1]),d=Math.hypot(f,l);if(d<.001)continue;const h=c.distanceOuter-c.distanceInner,m=h>0?Math.min(1,Math.max(0,(d-c.distanceInner)/h)):0,M=c.audioMode?$r(c.audioBounds,this._audioLevel||0):1,g=c.speedInner+(c.speedOuter-c.speedInner)*m;n.vx+=-l/d*g*t*M,n.vy+=f/d*g*t*M}for(const c of r.remap){const a=c.inputScale||1,f=jr(n.bx*.01*a,n.by*.01*a,this.simTime*.1,c.fn==="fbmnoise"?4:2);if(c.output==="velocity")for(let l=0;l<3;l++){const d=(f[l]+1)/2,h=c.rangeMin[l]+(c.rangeMax[l]-c.rangeMin[l])*d;l===0?n.vx=h:l===1?n.vy=h:n.vz=h}else if(c.output==="speed"){const l=(f[0]+1)/2,d=c.rangeMin[0]+(c.rangeMax[0]-c.rangeMin[0])*l,h=Math.hypot(n.vx,n.vy)||1;n.vx=n.vx/h*d,n.vy=n.vy/h*d}}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,r.oscPos){const c=this.simTime*n.oscFreq*lt+n.oscPhase,a=r.oscPos.mask;n.x+=Math.sin(c)*n.oscAmp*a[0],n.y+=Math.cos(c)*n.oscAmp*a[1],n.z+=Math.sin(c*.7)*n.oscAmp*a[2]}let i=n.baseSize;if(r.sizeChange){const c=r.sizeChange,a=c.endTime-c.startTime,f=a>0?Math.min(1,Math.max(0,(o-c.startTime)/a)):o>=c.startTime?1:0;i*=c.startValue+(c.endValue-c.startValue)*f}if(r.oscSize){const c=this.simTime*n.oscSFreq*lt+n.oscSPhase,a=r.oscSize,f=(a.scaleMin+a.scaleMax)/2,l=(a.scaleMax-a.scaleMin)/2;i*=f+Math.sin(c)*l}if(n.size=i,r.colorChange){const c=r.colorChange,a=c.endTime-c.startTime,f=a>0?Math.min(1,Math.max(0,(o-c.startTime)/a)):o>=c.startTime?1:0,l=c.startValue||[n.baseR,n.baseG,n.baseB];n.r=l[0]+(c.endValue[0]-l[0])*f,n.g=l[1]+(c.endValue[1]-l[1])*f,n.b=l[2]+(c.endValue[2]-l[2])*f}let s=n.baseAlpha;if(r.alphaFade){const c=r.alphaFade.fadeIn,a=r.alphaFade.fadeOut;c>0&&o<c&&(s*=o/c),a<1&&o>a&&(s*=Math.max(0,(1-o)/(1-a)))}else r.alphaChange||(o<.1?s*=o/.1:o>.85&&(s*=(1-o)/.15));if(r.alphaChange){const c=r.alphaChange,a=c.endTime-c.startTime,f=a>0?Math.min(1,Math.max(0,(o-c.startTime)/a)):o>=c.startTime?1:0;s*=c.startValue+(c.endValue-c.startValue)*f}if(r.oscAlpha){const c=this.simTime*n.oscAFreq*lt+n.oscAPhase,a=r.oscAlpha,f=(a.scaleMin+a.scaleMax)/2,l=(a.scaleMax-a.scaleMin)/2;s*=f+Math.sin(c)*l}if(n.alpha=Math.max(0,s),this.frameCount>1&&this.animationMode!=="randomframe"&&(n.frame=Math.min(this.frameCount-1,Math.floor(o*this.frameCount))),n.trail){const c=n.trail,a=this.trailSampleDt;if(a>0){n.trailClock=(n.trailClock||0)+t;let f=0;const l=this.trailSegments||8;for(;n.trailClock>=a&&f<l;){n.trailClock-=a,f++;for(let d=c.length-3;d>=3;d-=3)c[d]=c[d-3],c[d+1]=c[d-2],c[d+2]=c[d-1]}}c[0]=n.x,c[1]=n.y,c[2]=n.z}}_cpPos(n){const t=this.controlPoints.find(o=>o.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 o=.03333333333333333,r=Math.min(900,Math.round(this.startTime/o));for(let i=0;i<r;i++)this._step(o)}this._step(n,t)}}_step(n,t){this.simTime+=n;const o=t&&Number.isFinite(t.level)?Math.max(0,Math.min(1,t.level)):0;this._audioLevel=o;for(const i of this.emitters){if(i.instantaneous>0&&!i._burst){i._burst=!0;for(let a=0;a<Math.min(i.instantaneous,this.maxCount);a++)this.spawn(i)}if(i.fill){const f=Math.min(this.maxCount,2048);let l=0;for(let h=0;h<this.pool.length;h++)this.pool[h].alive&&l++;let d=Math.min(f-l,512);for(;d-- >0;)this.spawn(i);continue}if(i.audioDriven){const a=$r(i.audioBounds,o);if(i.rate>0){const f=i.rate*a*(this._ov.rateMul!==void 0?this._ov.rateMul:1)*(this._ov.countMul!==void 0?this._ov.countMul:1);if(!(f>0))continue;i._accum=(i._accum||0)+f*n;let l=Math.floor(i._accum);if(l>0){i._accum-=l,l>this.maxCount&&(l=this.maxCount);for(let d=0;d<l;d++)this.spawn(i)}}else{const l=Math.round(Math.min(this.maxCount,2048)*a);let d=0;for(let m=0;m<this.pool.length;m++)this.pool[m].alive&&d++;let h=Math.min(l-d,256);for(;h-- >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 c=Math.floor(i._accum);if(c>0){i._accum-=c,c>this.maxCount&&(c=this.maxCount);for(let a=0;a<c;a++)this.spawn(i)}}const r=this.pool;for(let i=0;i<r.length;i++)r[i].alive&&this.updateParticle(r[i],n)}render(n,t,o,r,i){if(!this._ready||!this.visible||!this.renderers.length)return;const s=this.gl;this._prog||this._buildProgram(s);const c=this.trailCfg&&this.trailCfg.kind==="ropetrail"?this.trailCfg:null,a=this.trailCfg&&this.trailCfg.kind==="spritetrail"?this.trailCfg:null,f=this.ropeRenderer,l=Go(this.trailCfg,this.trailSegments),d=14,h=this.pool;let m=null;if(f){m=this._ropeOrder,m.length=0;for(let H=0;H<h.length;H++)h[H].alive&&m.push(h[H]);m.sort((H,j)=>H.seq-j.seq)}let M=0;if(m)M=m.length;else for(let H=0;H<h.length;H++)h[H].alive&&M++;if(M===0||f&&M<2)return;const g=f?M-1:M*l,y=g*d;(!this._data||this._data.length<y)&&(this._data=new Float32Array(Math.max(y,1024)));const b=this._data;let p=0;const v=this._ov.brightness||1,_=this.sysScale,w=this.spriteStretchX*(this.texAspectX||1),L=this.spriteStretchY*(this.texAspectY||1),F=Math.cos(this.angleZ),D=Math.sin(this.angleZ),B=this.originX,z=this.originY,V=this.scaleX,Y=this.scaleY,Z=(H,j)=>{const ee=H*V,le=j*Y;return[B+ee*F-le*D,i-(z+ee*D+le*F)]};if(f)for(let H=0;H+1<M;H++){const j=m[H],ee=m[H+1],le=Z(j.x,j.y),Se=Z(ee.x,ee.y),Xe=Se[0]-le[0],Le=Se[1]-le[1],Pe=Math.hypot(Xe,Le),ue=(Math.abs(j.size)+Math.abs(ee.size))*.5*_;ue>0&&(b[p++]=(le[0]+Se[0])*.5,b[p++]=(le[1]+Se[1])*.5,b[p++]=0,b[p++]=ue,b[p++]=Math.atan2(-Xe,Le),b[p++]=(j.r+ee.r)*.5*v,b[p++]=(j.g+ee.g)*.5*v,b[p++]=(j.b+ee.b)*.5*v,b[p++]=(j.alpha+ee.alpha)*.5,b[p++]=1,b[p++]=Pe/ue,b[p++]=0,b[p++]=Wr(j),b[p++]=Wr(ee))}for(let H=0;H<h.length&&!f;H++){const j=h[H];if(j.alive)for(let ee=0;ee<l;ee++){let le=j.x,Se=j.y,Xe=1,Le=1,Pe=j.rot,ue=w,Fe=L,Je,Ee;if(c&&j.trail){le=j.trail[ee*3],Se=j.trail[ee*3+1];const xe=l>1?ee/(l-1):0;Xe=1-xe,Le=1-xe*.55;let Ne=0,we=0;ee+1<l?(Ne=j.trail[ee*3]-j.trail[(ee+1)*3],we=j.trail[ee*3+1]-j.trail[(ee+1)*3+1]):ee>0?(Ne=j.trail[(ee-1)*3]-j.trail[ee*3],we=j.trail[(ee-1)*3+1]-j.trail[ee*3+1]):(Ne=j.vx,we=j.vy);const Ge=Z(le,Se),fe=Z(le-Ne,Se-we),Ye=Ge[0]-fe[0],$t=Ge[1]-fe[1],et=Math.hypot(Ye,$t),qt=Math.max(.001,Math.abs(j.size)*_*Le);et>.001?(Pe=Vr(Ye,$t),Je=(Ge[0]+fe[0])*.5,Ee=(Ge[1]+fe[1])*.5,Fe=Math.max(L,et/qt)):(Je=Ge[0],Ee=Ge[1])}else{const xe=Z(le,Se);Je=xe[0],Ee=xe[1]}if(a){const xe=Z(j.x,j.y);Je=xe[0],Ee=xe[1];const Ne=Z(j.x+j.vx,j.y+j.vy);Pe=Vr(Ne[0]-xe[0],Ne[1]-xe[1]);const we=Xo(Math.hypot(j.vx,j.vy),a.length,a.minLength,a.maxLength);Fe=L*we}b[p++]=Je,b[p++]=Ee,b[p++]=0,b[p++]=Math.abs(j.size)*_*Le,b[p++]=Pe,b[p++]=j.r*v,b[p++]=j.g*v,b[p++]=j.b*v,b[p++]=j.alpha*Xe,b[p++]=ue,b[p++]=Fe,b[p++]=j.frame,b[p++]=0,b[p++]=1}}const X=this._prog;s.useProgram(X.prog),s.bindVertexArray(this._vao),s.bindBuffer(s.ARRAY_BUFFER,this._vbuf),s.bufferData(s.ARRAY_BUFFER,b.subarray(0,p),s.DYNAMIC_DRAW),s.activeTexture(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,this.texture.glTex),s.uniform1i(X.uniTex,0),s.uniformMatrix4fv(X.uniMvp,!1,n);const q=this.refract&&this.normalTex&&this.normalTex.glTex;if(X.uniRefract&&s.uniform1i(X.uniRefract,q?1:0),q){s.activeTexture(s.TEXTURE1),s.bindTexture(s.TEXTURE_2D,this.normalTex.glTex),X.uniNormal&&s.uniform1i(X.uniNormal,1);const H=this.blend!=="additive";if(X.uniSampleScene&&s.uniform1i(X.uniSampleScene,H?1:0),H){const j=s.drawingBufferWidth||t,ee=s.drawingBufferHeight||o;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,j,ee,0),X.uniScene&&s.uniform1i(X.uniScene,2),X.uniResolution&&s.uniform2f(X.uniResolution,j,ee),X.uniRefractScale&&s.uniform1f(X.uniRefractScale,this.refractAmount||.04)}else s.activeTexture(s.TEXTURE2),s.bindTexture(s.TEXTURE_2D,this.texture.glTex),X.uniScene&&s.uniform1i(X.uniScene,2)}else X.uniNormal&&(s.activeTexture(s.TEXTURE1),s.bindTexture(s.TEXTURE_2D,this.texture.glTex),s.uniform1i(X.uniNormal,1),s.activeTexture(s.TEXTURE2),s.bindTexture(s.TEXTURE_2D,this.texture.glTex),X.uniScene&&s.uniform1i(X.uniScene,2),X.uniSampleScene&&s.uniform1i(X.uniSampleScene,0));const oe=this._frameUniformData();oe?(s.uniform1i(X.uniFrameCount,oe.count),s.uniform4fv(X.uniFrames,oe.arr)):s.uniform1i(X.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,g),s.depthMask(!0),s.disable(s.BLEND),s.bindVertexArray(null)}_buildProgram(n){const t=Ma(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 r=this.sequenceMul;n=[];for(let i=0;i<r;i++)for(let s=0;s<r;s++)n.push({ou:s/r,ov:i/r,su:1/r,sv:1/r})}if(!n||n.length===0)return this._frameData=null,null;const t=Math.min(n.length,128),o=new Float32Array(t*4);for(let r=0;r<t;r++)o[r*4]=n[r].ou,o[r*4+1]=n[r].ov,o[r*4+2]=n[r].su,o[r*4+3]=n[r].sv;return this._frameData={count:t,arr:o},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 Sa=Object.freeze(Object.defineProperty({__proto__:null,ParticleSystem:Ta,particleInstanceSegs:Go,particlePassRefract:Ho,rgbaIsBlankWhite:Aa,ropeParticleV:Wr,ropeTrailDuration:qo,ropeTrailHistoryCount:Yo,spriteTrailLengthFactor:Xo,spriteTrailRotation:Vr},Symbol.toStringTag,{value:"Module"})),_n=new Map,Hr=new Map;let nr=null;function Ea(e,n){const t=String(e);Hr.set(t,n),_n.delete(t)}function Pa(e){nr=typeof e=="function"?e:null}function Ca(){Hr.clear(),nr=null,_n.clear()}function Ra(){return Object.keys(Cn)}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 Tn(e,n){const{width:t,height:o,rgba:r}=e,i=Math.max(2,Math.round(Math.min(t,o)*.04));for(let s=0;s<o;s++)for(let c=0;c<t;c++){const a=Math.min(c,s,t-1-c,o-1-s);if(a>=i)continue;const f=a/i,l=(s*t+c)*4+3;r[l]=Math.round(r[l]*f)}if(n>0){let s=0;const c=t*o;for(let f=0;f<c;f++)s+=r[f*4+3];const a=s/c/255;if(a>n&&a>0){const f=n/a;for(let l=0;l<c;l++)r[l*4+3]=Math.round(r[l*4+3]*f)}}return e}function rr(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 an=e=>e*e*(3-2*e),Zo=e=>e*e*e*(e*(e*6-15)+10),Xr=(e,n,t)=>e+(n-e)*t,ne=(e,n)=>Math.exp(-(e*e)/(n*n));function Gt(e,n,t,o){const r=Math.min(e,n,t-1-e,t-1-n);return r>=o?1:r/o}function Sn(e,n){const t=new Uint8Array(e*e*4),o=e/2;for(let r=0;r<e;r++)for(let i=0;i<e;i++){const s=Math.hypot((i+.5-o)/o,(r+.5-o)/o);let c=0;for(let a=0;a<n.length;a++)c+=n[a].w*ne(s,n[a].r);Te(t,(r*e+i)*4,c)}return{width:e,height:e,rgba:t}}function Et(e,n,t){return Sn(e,[n,t])}function Pt(e,n,t,o,r){const i=new Uint8Array(e*e*4),s=e/2,c=Math.max(2,Math.round(e*.03));for(let a=0;a<e;a++)for(let f=0;f<e;f++){const l=(f+.5-s)/s,d=(a+.5-s)/s,h=Math.hypot(l,d),m=Math.atan2(d,l),M=Math.pow(.5+.5*Math.cos(n*m),o);let g=ne(h,r)+M*ne(h,t);g*=Gt(f,a,e,c),Te(i,(a*e+f)*4,g)}return{width:e,height:e,rgba:i}}function yt(e,n,t,o,r){const s=new Uint8Array(e*n*4);for(let c=0;c<n;c++){const a=c/(n-1),f=o?ne(a-.5,.27):an(Math.min(1,a/.06))*Math.pow(1-a,1.35);for(let l=0;l<e;l++){const d=l/(e-1)*2-1,h=ne(d,t);Te(s,(c*e+l)*4,h*h*h*f*.55)}}return{width:e,height:n,rgba:s}}const En=4;function Ko(e,n,t,o,r){const i=r===void 0?.85:r,s=new Uint8Array(e*n*4),c=n/En,a=rr(335009),f=Math.tan(t*Math.PI/180),l=e/2;for(let d=0;d<En;d++){const h=i*(.8+a()*.35),m=o*(.85+a()*.5),M=(a()-.5)*e*.12;for(let g=0;g<c;g++){const y=g/(c-1),b=l+M+(c-1)*f/2-(c-1)*f*y,p=ne(y-.5,.27);for(let v=0;v<e;v++){const _=Math.abs(v+.5-b),L=Math.exp(-(_*_)/(m*m))*p*h;L<.004||Te(s,((d*c+g)*e+v)*4,L)}}}return{width:e,height:n,rgba:s}}function La(e){if(e==="particle/nature/rain1"||e==="particle/nature/rain2"){const n=[];for(let t=0;t<En;t++)n.push({ou:0,ov:t/En,su:1,sv:1/En});return n}return null}function Gr(e,n,t){const o=new Uint8Array(e*e*4),r=e/2;for(let i=0;i<e;i++)for(let s=0;s<e;s++){const c=Math.hypot((s-r)/r,(i-r)/r);Te(o,(i*e+s)*4,ne(c-n,t*.6)*Math.max(0,1-c))}return{width:e,height:e,rgba:o}}function Qo(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]]}},o=t[n]||t[1],r=new Uint8Array(e*e*4),i=e/2;for(let s=0;s<e;s++)for(let c=0;c<e;c++){const a=(c+.5-i)/i,f=(s+.5-i)/i,l=Math.hypot(a,f);let d=ne(l-o.r,o.t*.85)*Math.max(0,1.05-l);l<o.r&&(d+=o.inner*ne(l,.5));for(let h=0;h<o.hi.length;h++){const m=o.hi[h];d+=m[3]*ne(Math.hypot(a-m[0],f-m[1]),m[2])}Te(r,(s*e+c)*4,d)}return Tn({width:e,height:e,rgba:r},.05)}function Pn(e,n){const t=e>>1,o=new Uint8Array(e*e*4),r=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 c=Qo(t,r[i*2+s]);for(let a=0;a<t;a++){const f=(i*t+a)*e,l=a*t;for(let d=0;d<t;d++){const h=(f+s*t+d)*4,m=(l+d)*4;o[h]=c.rgba[m],o[h+1]=c.rgba[m+1],o[h+2]=c.rgba[m+2],o[h+3]=c.rgba[m+3]}}}return{width:e,height:e,rgba:o}}function Jo(e){const n=new Uint8Array(e*e*4),t=e/2,o=[[.32,0],[1.1,.35],[2.2,-.3],[-.7,.2]];for(let r=0;r<e;r++)for(let i=0;i<e;i++){const s=i>=t?1:0,c=r>=t?1:0,a=c*2+s,f=s*t+t/2,l=c*t+t/2,d=o[a][0],h=o[a][1],m=(i+.5-f)/(t*.4),M=(r+.5-l)/(t*.4),g=Math.cos(d),y=Math.sin(d);let b=m*g+M*y;const p=-m*y+M*g;b+=h*p*.18;const v=1-Math.max(0,p)*.42,_=Math.hypot(b/(.52*v),p/.92);let w=_>=1.12?0:ne(_,.48);w=Math.min(1,w+ne(b,.07)*ne(p,.65)*w*.4),Te(n,(r*e+i)*4,w)}return Tn({width:e,height:e,rgba:n},.11)}function $e(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}},o=t[n]||t[0],r=new Uint8Array(e*e*4),i=e/2;for(let s=0;s<e;s++)for(let c=0;c<e;c++){const a=(c+.5-i)/i,f=(s+.5-i)/i,l=Math.atan2(a,f),d=o.wave?1+o.wave*Math.sin(l*o.folds):1,h=Math.hypot(a/(o.rx*d),f/o.ry);let m=h>=1.12?0:ne(h,.5);m>0&&(m=Math.min(1,m+ne(a,.028)*ne(f,.72)*.28)),Te(r,(s*e+c)*4,m)}return Tn({width:e,height:e,rgba:r},.11)}function ut(e,n){const t=e.width,o=e.height,r=e.rgba,i=n??2.8,s=new Uint8Array(t*o*4),c=(a,f)=>{const l=a<0?0:a>=t?t-1:a,d=f<0?0:f>=o?o-1:f;return r[(d*t+l)*4+3]/255};for(let a=0;a<o;a++)for(let f=0;f<t;f++){const l=(c(f-1,a)-c(f+1,a))*i,d=(c(f,a-1)-c(f,a+1))*i,h=1/Math.hypot(l,d,1),m=(a*t+f)*4;s[m]=Math.round((l*h*.5+.5)*255),s[m+1]=Math.round((d*h*.5+.5)*255),s[m+2]=Math.round((h*.5+.5)*255),s[m+3]=255}return{width:t,height:o,rgba:s}}function ei(e){const n=new Uint8Array(e*e*4),t=e/2;for(let o=0;o<e;o++)for(let r=0;r<e;r++){const i=(r+.5-t)/t,s=(o+.5-t)/t,c=Math.hypot(i,s),a=c>=1?0:Math.sqrt(Math.max(0,1-c*c)),f=ne(c-.62,.11)*.55;Te(n,(o*e+r)*4,Math.min(1,a*.85+f))}return{width:e,height:e,rgba:n}}function Fa(e){const n=new Uint8Array(e*e*4),t=e/2;for(let o=0;o<e;o++)for(let r=0;r<e;r++){const i=(r+.5-t)/t,s=(o+.5-t)/t,c=Math.hypot(i,s),a=Math.atan2(s,i),f=ne(c,.38)*(.55+.45*Math.cos(a*3+c*6));Te(n,(o*e+r)*4,f)}return{width:e,height:e,rgba:n}}function ti(e){const n=new Uint8Array(e*e*4),t=e/2,o=Math.max(2,Math.round(e*.04));for(let r=0;r<e;r++)for(let i=0;i<e;i++){const s=(i+.5-t)/t,c=(r+.5-t)/t,a=Math.hypot(s,c),f=Math.atan2(c,s),l=an(Math.max(0,Math.cos(f)*.55+.45)),d=ne(a-.68,.07)*l+.35*ne(a-.78,.12)*ne(f-.9,.55);Te(n,(r*e+i)*4,Math.min(1,d)*Gt(i,r,e,o))}return{width:e,height:e,rgba:n}}function Na(e){if(!e||e.length<16)return!1;const n=e.length/4,t=Math.max(1,n/48|0);let o=0;for(let r=0;r<n;r+=t){const i=r*4;if(e[i]<240||e[i+1]<240||e[i+2]<240)return!1;o++}return o>0}function ka(e){return!e||!e.rgba?e:Na(e.rgba)?ut(e,2.8):e}const Ua={"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 Ia(e){if(!e)return null;const n=String(e);return/normal/i.test(n)?n:Ua[n]||n+"_normal"}function Ba(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 Oa(e){if(Cn[e])return Cn[e]();const n=String(e).toLowerCase();return/normal/.test(n)?Et(64,{r:.18,w:1},{r:.4,w:.2}):li(e)()}function ni(e,n,t){const o=rr(t*7919+17);let r=e;const i=[];for(let a=0;a<n;a++){const f=r*r,l=new Float32Array(f*2);for(let d=0;d<f;d++){const h=o()*Math.PI*2;l[d*2]=Math.cos(h),l[d*2+1]=Math.sin(h)}i.push({f:r,g:l,ox:a*7.31,oy:a*3.17}),r*=2}const s=(a,f,l,d,h)=>{const m=a.f,M=(f%m+m)%m,y=((l%m+m)%m*m+M)*2;return a.g[y]*d+a.g[y+1]*h},c=(a,f,l)=>{const d=(f+a.ox)*a.f,h=(l+a.oy)*a.f,m=Math.floor(d),M=Math.floor(h),g=d-m,y=h-M,b=Zo(g),p=Zo(y);return Xr(Xr(s(a,m,M,g,y),s(a,m+1,M,g-1,y),b),Xr(s(a,m,M+1,g,y-1),s(a,m+1,M+1,g-1,y-1),b),p)};return function(f,l,d){const h=d==null?i.length:Math.min(d,i.length);let m=1,M=0,g=0;for(let y=0;y<h;y++)M+=(c(i[y],f,l)*.5+.5)*m,g+=m,m*=.55;return M/g}}function ri(e,n,t){const{width:o,height:r,rgba:i}=e;if(o===n&&r===t)return e;const s=new Uint8Array(n*t*4);for(let c=0;c<t;c++){const a=(c+.5)/t*r-.5,f=Math.max(0,Math.min(r-1,Math.floor(a))),l=Math.max(0,Math.min(r-1,f+1)),d=a-Math.floor(a);for(let h=0;h<n;h++){const m=(h+.5)/n*o-.5,M=Math.max(0,Math.min(o-1,Math.floor(m))),g=Math.max(0,Math.min(o-1,M+1)),y=m-Math.floor(m),b=i[(f*o+M)*4+3],p=i[(f*o+g)*4+3],v=i[(l*o+M)*4+3],_=i[(l*o+g)*4+3],w=(b*(1-y)+p*y)*(1-d)+(v*(1-y)+_*y)*d;Te(s,(c*n+h)*4,w/255)}}return{width:n,height:t,rgba:s}}function It(e,n,t,o,r,i,s){const c=i===void 0?1:i,a=s===void 0?200:s,f=256,l=ni(n,t,o),d=new Uint8Array(f*f*4),h=f/2,m=f*f,M=new Float32Array(m);let g=1,y=0;for(let _=0;_<m;_++){const w=_%f,L=_/f|0,F=(w+.5)/f,D=(L+.5)/f,B=l(F+5.2,D+1.3,2)-.5,z=l(F+9.7,D+8.1,2)-.5,V=M[_]=l(F+B*.45,D+z*.45);V<g&&(g=V),V>y&&(y=V)}const b=y-g||1;for(let _=0;_<f;_++)for(let w=0;w<f;w++){const L=(M[_*f+w]-g)/b,F=Math.hypot((w+.5-h)/h,(_+.5-h)/h),D=Math.pow(Math.max(0,1-F),c);let B=Math.max(0,(L-(1-r))/(r||1));B=an(Math.min(1,B))*D,Te(d,(_*f+w)*4,B)}let p=0;for(let _=0;_<m;_++)p=Math.max(p,d[_*4+3]);if(p>0&&p<a){const _=a/p;for(let w=0;w<m;w++)d[w*4+3]=Math.round(Math.min(255,d[w*4+3]*_))}const v={width:f,height:f,rgba:d};return f===e?v:ri(v,e,e)}function Yr(e,n){const t=e,o=ni(3,5,n??23),r=new Uint8Array(t*t*4),i=t*t,s=new Float32Array(i);let c=1,a=0;for(let h=0;h<i;h++){const m=h%t,M=h/t|0,g=(m+.5)/t,y=(M+.5)/t,b=o(g+2.1,y+4.7,2)-.5,p=o(g+6.3,y+1.9,2)-.5,v=s[h]=o(g+b*.28,y+p*.55);v<c&&(c=v),v>a&&(a=v)}const f=a-c||1;for(let h=0;h<t;h++)for(let m=0;m<t;m++){const M=(h+.5)/t,g=(m+.5)/t*2-1,y=.1+.52*Math.pow(M,1.25),b=(s[h*t+m]-c)/f,p=ne(g/(y||.01),.55)*ne(M-.58,.42);let v=an(Math.min(1,Math.max(0,(b-.18)/.72)))*p;v*=M<.06?M/.06:1,Te(r,(h*t+m)*4,v)}let l=0;for(let h=0;h<i;h++)l=Math.max(l,r[h*4+3]);if(l>0&&l<220){const h=220/l;for(let m=0;m<i;m++)r[m*4+3]=Math.round(Math.min(255,r[m*4+3]*h))}const d=Tn({width:t,height:t,rgba:r},.08);return t===e?d:ri(d,e,e)}function qr(e,n,t,o){const r=new Uint8Array(e*n*4),i=e/t,s=n/o;for(let c=0;c<n;c++)for(let a=0;a<e;a++){const f=Math.floor(a/i),l=Math.floor(c/s),d=(a+.5-f*i)/i*2-1,h=(c+.5-l*s)/s*2-1,m=1-Math.max(0,h)*.45,M=Math.hypot(d/(.52*m),h/.8),g=M>=1.12?0:ne(M,.48);Te(r,(c*e+a)*4,g)}return{width:e,height:n,rgba:r}}function oi(e){const n=new Uint8Array(e*e*4),t=rr(7),o=[];for(let r=0;r<11;r++)o.push({x:.14+t()*.72,y:.14+t()*.72,rx:.025+t()*.03,ry:.018+t()*.024,rot:t()*Math.PI});for(let r=0;r<e;r++)for(let i=0;i<e;i++){const s=(i+.5)/e,c=(r+.5)/e;let a=0;for(const f of o){const l=s-f.x,d=c-f.y,h=Math.cos(f.rot),m=Math.sin(f.rot),M=(l*h+d*m)/f.rx,g=(-l*m+d*h)/f.ry,y=ne(Math.hypot(M,g),.55);y>a&&(a=y)}Te(n,(r*e+i)*4,a)}return{width:e,height:e,rgba:n}}function or(e,n){const t=n??19,o=rr(t),r=h=>Math.min(.86,Math.max(.14,h)),i=5+t%4,s=[];let c=r(.5+(o()-.5)*.16);for(let h=0;h<=i;h++){const m=.06+h/i*.86;h>0&&(c=r(c+(o()-.5)*.32)),s.push([c,m])}const a=[];for(let h=0;h<s.length-1;h++)a.push([s[h],s[h+1],1]);const f=1+t%2;for(let h=0;h<f;h++){const m=1+(t+h*3)%Math.max(1,s.length-2),M=s[m],g=[M];let y=M[0],b=M[1];const p=2+t%2;for(let v=0;v<p;v++)y=r(y+(o()-.5)*.36),b=Math.min(.92,b+.1+o()*.08),g.push([y,b]);for(let v=0;v<g.length-1;v++)a.push([g[v],g[v+1],.45+h*.1])}const l=new Uint8Array(e*e*4),d=Math.max(2,Math.round(e*.04));for(let h=0;h<e;h++)for(let m=0;m<e;m++){const M=(m+.5)/e,g=(h+.5)/e;let y=9,b=0;for(const[v,_,w]of a){const L=_[0]-v[0],F=_[1]-v[1],D=L*L+F*F||1e-8,B=Math.max(0,Math.min(1,((M-v[0])*L+(g-v[1])*F)/D)),z=Math.hypot(M-(v[0]+L*B),g-(v[1]+F*B));z/w<y&&(y=z/w,b=w)}const p=.95*ne(y,.012)+.3*ne(y,.05)*b;Te(l,(h*e+m)*4,Math.min(1,p)*Gt(m,h,e,d))}return{width:e,height:e,rgba:l}}function Zr(e,n){const t=new Uint8Array(e*n*4);for(let o=0;o<n;o++)for(let r=0;r<e;r++){const i=(r+.5-e/2)/(e/2),s=(o+.5-n/2)/(n/2),c=ne(i,.34)*Math.exp(-Math.max(0,-s-.05)*4.2)*(s<.1?1:Math.max(0,1-s*4)),a=Math.hypot(i/.34,(s-.42)/.3),f=a>=1?0:ne(a,.5);Te(t,(o*e+r)*4,Math.max(c,f))}return{width:e,height:n,rgba:t}}function Da(e){return Et(e,{r:.1,w:1},{r:.3,w:.16})}function Kr(e,n){const t=new Uint8Array(e*n*4);for(let o=0;o<n;o++){const r=(o+.5)/n,i=an(Math.min(1,Math.min(r/.08,(1-r)/.08))),s=ne(r-.46,.24)*i,c=.5*(1-an(Math.min(1,Math.max(0,(r-.42)/.5)))*.6);for(let a=0;a<e;a++){const f=(a+.5-e/2)/(e/2);Te(t,(o*e+a)*4,ne(Math.abs(f)/(c||.01),.5)*s)}}return{width:e,height:n,rgba:t}}function ii(e){const n=new Uint8Array(e*e*4),t=e/2,o=Math.max(2,Math.round(e*.04));for(let r=0;r<e;r++)for(let i=0;i<e;i++){const s=(i+.5-t)/t,c=(r+.5-t)/t,a=ne(Math.hypot(s,c),.42),f=ne(Math.hypot(s-.34,c),.36),l=Math.max(0,a-f*1.08)*Gt(i,r,e,o);Te(n,(r*e+i)*4,l)}return{width:e,height:e,rgba:n}}function si(e){const n=new Uint8Array(e*e*4),t=e/2,o=Math.max(2,Math.round(e*.04));for(let r=0;r<e;r++)for(let i=0;i<e;i++){const s=(i+.5-t)/t,c=(r+.5-t)/t;let a=ne(Math.hypot(s,c),.08);for(let f=0;f<6;f++){const l=f*Math.PI/3,d=Math.cos(l),h=Math.sin(l),m=s*d+c*h,M=-s*h+c*d;if(m<0)continue;const g=Math.max(0,1.02-m/.72);a+=ne(M,.028)*ne(m,.5)*g,a+=.55*ne(M-(m-.28)*.65,.02)*ne(m-.28,.12)*g,a+=.55*ne(M+(m-.28)*.65,.02)*ne(m-.28,.12)*g,a+=.4*ne(M-(m-.48)*.7,.016)*ne(m-.48,.08)*g,a+=.4*ne(M+(m-.48)*.7,.016)*ne(m-.48,.08)*g}Te(n,(r*e+i)*4,Math.min(1,a)*Gt(i,r,e,o))}return{width:e,height:e,rgba:n}}function ai(e,n){const t=new Uint8Array(e*e*4),o=e/2,r=Math.max(2,Math.round(e*.04)),i=Math.abs(n|0)%3;for(let s=0;s<e;s++)for(let c=0;c<e;c++){const a=(c+.5-o)/o*1.55,f=(s+.5-o)/o*1.55,l=Math.abs(Math.abs(a)+Math.abs(f)-.55);let d=ne(l,.016);i===0?(d+=ne(a,.012)*ne(f,.38),d+=ne(f,.012)*ne(a,.38)):i===1?(d+=ne(a-f,.012)*ne(a+f,.36),d+=ne(a+f,.012)*ne(a-f,.36)):(d+=ne(Math.hypot(a,f)-.26,.014),d+=ne(a,.012)*ne(f,.22)),Te(t,(s*e+c)*4,Math.min(1,d)*Gt(c,s,e,r))}return Tn({width:e,height:e,rgba:t},.03)}function Qr(e){let n=0;const t=String(e);for(let o=0;o<t.length;o++)n=n*31+t.charCodeAt(o)|0;return n}function ci(e){const n=new Uint8Array(e*e*4),t=e/2,o=Math.max(2,Math.round(e*.03));for(let r=0;r<e;r++)for(let i=0;i<e;i++){const s=(i+.5-t)/t,c=(r+.5-t)/t,a=Math.hypot(s,c),f=ne(a,.07)+.85*ne(s,.62)*ne(c,.045)+.22*ne(s,.92)*ne(c,.018);Te(n,(r*e+i)*4,Math.min(1,f)*Gt(i,r,e,o))}return{width:e,height:e,rgba:n}}const Cn={"particle/halo_6":()=>Et(256,{r:.14,w:1},{r:.4,w:.17}),"particle/normal_splash":()=>ut(ei(256),3.2),"particle/drop_normal":()=>ut(Kr(128,512),3.4),"particle/normal_ring_smooth":()=>ut(Gr(256,.55,.12),3.1),"particle/normal_pinch_rotate":()=>ut(Fa(256),2.8),"particle/water/rain_drops_sheet_normal":()=>ut(qr(256,512,2,4),3.6),"particle/bubbles/bubble1normal":()=>ut(Pn(256,1),3.2),"particle/bubbles/bubble2_normal":()=>ut(Pn(256,2),3.2),"particle/sharp_halo_normal":()=>ut(Sn(256,[{r:.035,w:1},{r:.09,w:.45},{r:.22,w:.08}]),3.4),"particle/beam/beam_0":()=>yt(128,512,.46,!0),"particle/beam/beam_1":()=>yt(128,512,.34,!0),"particle/beam/beam_2":()=>yt(128,512,.22,!0),"particle/beam/beam_2_fade":()=>yt(128,512,.24,!1),"particle/light/light_shafts_0":()=>yt(128,512,.42,!0),"particle/light/light_shafts_1":()=>yt(128,512,.3,!0),"particle/light/light_shafts_3":()=>yt(128,512,.26,!0),"particle/light/light_shafts_5":()=>yt(128,512,.23,!0),"particle/light/light_shafts_6":()=>yt(128,512,.2,!0),"particle/nature/rosepetals":()=>Jo(256),"particle/nature/leaves":()=>$e(256,0),"particle/nature/leaves1":()=>$e(256,1),"particle/nature/leaves2":()=>$e(256,2),"particle/nature/leaves3":()=>$e(256,3),"particle/nature/leaves5":()=>$e(256,5),"particle/nature/leaves6":()=>$e(256,6),"particle/nature/leaves7":()=>$e(256,7),"particle/nature/leaves8":()=>$e(256,8),"particle/nature/snow":()=>si(256),"particle/halo":()=>Et(256,{r:.12,w:1},{r:.3,w:.15}),"particle/halo_1":()=>Et(256,{r:.1,w:1},{r:.3,w:.13}),"particle/halo_2":()=>Et(256,{r:.2,w:.9},{r:.44,w:.2}),"particle/halo_3":()=>Sn(256,[{r:.045,w:1},{r:.13,w:.85},{r:.36,w:.15}]),"particle/halo_4":()=>Et(256,{r:.085,w:1},{r:.28,w:.12}),"particle/halo_5":()=>Sn(256,[{r:.04,w:1},{r:.11,w:.8},{r:.34,w:.17}]),"particle/sharp_halo":()=>Sn(256,[{r:.035,w:1},{r:.09,w:.45},{r:.22,w:.08}]),"particle/chromaticdot":()=>Da(128),"particle/light/flare_0":()=>Pt(256,6,.58,10,.08),"particle/light/flare_1":()=>Pt(512,4,.62,14,.07),"particle/light/flare_2":()=>ci(256),"particle/drop":()=>Kr(128,512),"particle/nature/rain1":()=>Ko(128,512,10,1,.78),"particle/nature/rain2":()=>Ko(128,512,10,1.6,.66),"particle/water/rain_drops_sheet":()=>qr(256,512,2,4),"particle/fog/fog1":()=>It(512,4,5,1,.4,.9,150),"particle/fog/fog2":()=>It(512,3,5,2,.45,.8,140),"particle/fog/fog3":()=>It(512,6,4,3,.36,1,150),"particle/smoke/smoke1":()=>It(512,3,5,7,.55,1.5,130),"particle/smoke/smoke2":()=>It(512,2,5,11,.6,1.7,120),"particle/smoke/smoke2light":()=>It(512,2,5,13,.4,1.7,110),"particle/misc/wave":()=>Gr(512,.72,.085),"particle/misc/star_0":()=>Pt(256,5,.62,8,.1),"particle/bubbles/bubble1":()=>Pn(256,1),"particle/bubbles/bubble2":()=>Pn(256,2),"particle/bubbles/bubble3":()=>Pn(256,3),"particle/debris/debris1":()=>oi(128),"particle/lightning/lightning1":()=>or(256,3),"particle/lightning/lightning2":()=>or(256,11),"particle/lightning/lightning3":()=>or(256,19),"particle/fire/fire1":()=>Yr(256,23),"particle/fire/fire2":()=>Yr(256,41),"particle/star":()=>Pt(256,4,.58,12,.09),"particle/shape/circle_wind":()=>ti(256),"particle/sickle":()=>ii(256),"particle/magic/glyph_4":()=>ai(256,4),"@sparkle":()=>Pt(256,4,.6,16,.08),"@star":()=>Pt(256,5,.62,8,.1),"@trail":()=>Zr(128,256)};function li(e){const n=String(e).toLowerCase();if(/normal/.test(n)){const t=Ba(e);return t?()=>ut(Oa(t),2.8):()=>ut(ei(128),2.6)}return/rosepetal|petal|sakura|blossom/.test(n)?()=>Jo(256):/leaf|leaves|foliage/.test(n)?/leaves8/.test(n)?()=>$e(256,8):/leaves7/.test(n)?()=>$e(256,7):/leaves6/.test(n)?()=>$e(256,6):/leaves5/.test(n)?()=>$e(256,5):/leaves3/.test(n)?()=>$e(256,3):/leaves2/.test(n)?()=>$e(256,2):/leaves1/.test(n)?()=>$e(256,1):()=>$e(256,0):/circle_wind|windcircle/.test(n)?()=>ti(256):/fog|cloud|mist|vapor/.test(n)?()=>It(512,4,5,5,.4,.9,150):/smoke/.test(n)?()=>It(512,3,5,8,.55,1.5,130):/beam|shaft|ray|godray/.test(n)?()=>yt(128,512,.3,!0):/flare/.test(n)?()=>ci(256):/bubble/.test(n)?()=>Qo(256,1):/ring|wave/.test(n)?()=>Gr(512,.72,.085):/fire|flame|ember|ash/.test(n)?()=>Yr(256,Qr(n)):/sickle|crescent|moon/.test(n)?()=>ii(256):/glyph|magic|rune/.test(n)?()=>ai(256,Qr(n)):/snowflake|雪花|snow/.test(n)?()=>si(256):/流星|meteor|shooting/.test(n)?()=>Zr(128,256):/star|星/.test(n)?()=>Pt(256,5,.62,8,.1):/sparkle|glint|twinkle/.test(n)?()=>Pt(256,4,.6,16,.08):/rain_drops_sheet|drops_sheet/.test(n)?()=>qr(256,512,2,4):/drop|rain/.test(n)?()=>Kr(128,512):/debris|dirt|rock/.test(n)?()=>oi(128):/lightning|bolt|arc/.test(n)?()=>or(256,Qr(n)):/note|music/.test(n)?()=>Pt(256,4,.55,8,.12):/trail|streak/.test(n)?()=>Zr(128,256):()=>Et(256,{r:.12,w:1},{r:.3,w:.15})}function $a(e){if(_n.has(e))return _n.get(e);let n=null;const t=Hr.get(e);if(t)try{n=t()}catch{n=null}if(!n&&nr)try{n=nr(e)}catch{n=null}if(!n&&Cn[e])try{n=Cn[e]()}catch{n=null}if(!n)try{n=li(e)()}catch{n=null}return n||(n=Et(256,{r:.12,w:1},{r:.3,w:.15})),_n.set(e,n),n}function za(e){return typeof e=="string"&&e.indexOf("particle/")===0}const ja=Object.freeze(Object.defineProperty({__proto__:null,buildBuiltinParticleTexture:$a,builtinParticleFrames:La,isBuiltinParticleTextureName:za,listBuiltinParticleTextureNames:Ra,particleNormalNameForAlbedo:Ia,prepareParticleNormalTexture:ka,resetParticleTextureFactories:Ca,setParticleTextureFactory:Ea,setParticleTextureProvider:Pa},Symbol.toStringTag,{value:"Module"})),ui=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);function Bt(e,n,t){const o=t||new Float32Array(16);for(let r=0;r<4;r++)for(let i=0;i<4;i++)o[r*4+i]=e[i]*n[r*4]+e[4+i]*n[r*4+1]+e[8+i]*n[r*4+2]+e[12+i]*n[r*4+3];return o}function fi(e){const n=[];for(let o=0;o<4;o++)n.push([e[o],e[4+o],e[8+o],e[12+o],0,0,0,0]),n[o][4+o]=1;for(let o=0;o<4;o++){let r=o;for(let c=o+1;c<4;c++)Math.abs(n[c][o])>Math.abs(n[r][o])&&(r=c);const i=n[o];n[o]=n[r],n[r]=i;const s=n[o][o];if(Math.abs(s)<1e-12)return Float32Array.from(ui);for(let c=0;c<8;c++)n[o][c]/=s;for(let c=0;c<4;c++){if(c===o)continue;const a=n[c][o];if(a!==0)for(let f=0;f<8;f++)n[c][f]-=a*n[o][f]}}const t=new Float32Array(16);for(let o=0;o<4;o++)for(let r=0;r<4;r++)t[o*4+r]=n[r][4+o];return t}function Jr(e,n,t,o,r,i,s,c,a,f){const l=f||new Float32Array(16),d=Math.cos(o),h=Math.sin(o),m=Math.cos(r),M=Math.sin(r),g=Math.cos(i),y=Math.sin(i);return l[0]=g*m*s,l[1]=y*m*s,l[2]=-M*s,l[3]=0,l[4]=(g*M*h-y*d)*c,l[5]=(y*M*h+g*d)*c,l[6]=m*h*c,l[7]=0,l[8]=(g*M*d+y*h)*a,l[9]=(y*M*d-g*h)*a,l[10]=m*d*a,l[11]=0,l[12]=e,l[13]=n,l[14]=t,l[15]=1,l}function Rn(e,n){const t=[];for(;n<e.byteLength;){const r=e.getUint8(n++);if(r===0)break;t.push(r)}let o="";try{o=new TextDecoder("utf-8").decode(new Uint8Array(t))}catch{o=String.fromCharCode.apply(null,t)}return{value:o,next:n}}function ir(e,n,t=0){const o=[];for(let r=0;r<n.length;r++)o.push(n.charCodeAt(r));e:for(let r=t;r<=e.length-o.length;r++){for(let i=0;i<o.length;i++)if(e[r+i]!==o[i])continue e;return r}return-1}function Va(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 o=Rn(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,c=0,a=0;for(const q of i){const oe=o.next+q.lenOff;if(oe+4>e.byteLength)continue;const H=n.getUint32(oe,!0);if(H>0&&H%q.stride===0&&oe+4+H<=e.byteLength){s=q,c=H,a=oe;break}}if(!s)throw new Error("\u9876\u70B9\u533A\u957F\u5EA6\u5F02\u5E38\uFF08"+t+"\uFF0C\u5DF2\u8BD5 stride "+i.map(q=>q.stride).join("/")+"\uFF09");const f=a+4,l=c/s.stride,d=new Float32Array(l*3),h=new Float32Array(l*2),m=new Float32Array(l*4),M=new Float32Array(l*4);for(let q=0;q<l;q++){const oe=f+q*s.stride;if(d[q*3]=n.getFloat32(oe,!0),d[q*3+1]=n.getFloat32(oe+4,!0),d[q*3+2]=n.getFloat32(oe+8,!0),h[q*2]=n.getFloat32(oe+s.uv,!0),h[q*2+1]=n.getFloat32(oe+s.uv+4,!0),s.bone>=0&&s.weight>=0)for(let H=0;H<4;H++)m[q*4+H]=n.getUint32(oe+s.bone+H*4,!0),M[q*4+H]=n.getFloat32(oe+s.weight+H*4,!0);else m[q*4]=0,M[q*4]=1}const g=n.getUint32(f+c,!0),y=f+c+4,b=l>65535&&g%4===0,p=b?g/4:g/2,v=b?new Uint32Array(p):new Uint16Array(p);if(b)for(let q=0;q<p;q++)v[q]=n.getUint32(y+q*4,!0);else for(let q=0;q<p;q++)v[q]=n.getUint16(y+q*2,!0);const _=Ha(e,n),w=Xa(e,n,_.length),L=Ya(e,n,_),F=Wa(e,n,_.length),D=[],B=[],z=[];if(_.length>0){const q=_.map((H,j)=>{const ee=H.matrix,le=Math.hypot(ee[0],ee[1]),Se=Math.hypot(ee[4],ee[5]);return z[j]=Float32Array.from([ee[12],ee[13],ee[14],0,0,Math.atan2(ee[1],ee[0]),le||1,Se||1,ee[10]||1]),Float32Array.from(ee)});for(let H=0;H<_.length;H++){const j=z[H],ee=_[H].matrix;Math.hypot(j[0]-ee[12],j[1]-ee[13])>.001&&(q[H]=Jr(j[0],j[1],j[2],j[3],j[4],j[5],j[6],j[7],j[8],new Float32Array(16)))}const oe=[];for(let H=0;H<_.length;H++){const j=_[H].parent;oe[H]=j>=0&&j<H?Bt(oe[j],q[H]):Float32Array.from(q[H])}for(let H=0;H<_.length;H++)D[H]=fi(oe[H]);if(L){const H=[];for(let j=0;j<_.length;j++){const ee=_[j].parent;H[j]=ee>=0&&ee<j?Bt(H[ee],L[j]):Float32Array.from(L[j])}for(let j=0;j<_.length;j++)B[j]=Bt(H[j],D[j])}}let V=1/0,Y=-1/0,Z=1/0,X=-1/0;for(let q=0;q<l;q++){const oe=d[q*3],H=d[q*3+1];oe<V&&(V=oe),oe>Y&&(Y=oe),H<Z&&(Z=H),H>X&&(X=H)}return{magic:t,materialPath:o.value,vertexCount:l,positions:d,uvs:h,boneIdx:m,weights:M,indexCount:p,indexType:b?"u32":"u16",indices:v,bones:_,animations:w,animBound:Ga(w,_),invBindWorld:D,bindTRS:z.length>0?z:null,attachments:F.length>0?F:null,restCorrection:B.length>0?B:null,bounds:{minX:V,maxX:Y,minY:Z,maxY:X}}}function Wa(e,n,t){const o=ir(e,"MDAT");if(o<0)return[];const r=n.getUint16(o+13,!0);if(r<=0||r>256)return[];const i=[];let s=o+15;for(let c=0;c<r&&!(s+2>e.length);c++){const a=n.getUint16(s,!0),f=Rn(n,s+2);if(f.next+64>e.length)break;const l=new Float32Array(16);for(let d=0;d<16;d++)l[d]=n.getFloat32(f.next+d*4,!0);a<t&&i.push({bone:a,name:f.value,matrix:l}),s=f.next+64}return i}function Ha(e,n){const t=ir(e,"MDLS");if(t<0)return[];const o=n.getUint32(t+13,!0);if(o<=0||o>1024)return[];const r=[];let i=t+17;for(let s=0;s<o;s++){if(i+77>n.byteLength)return r;const c=n.getUint32(i+1,!0),a=n.getInt32(i+5,!0),f=new Float32Array(16);for(let d=0;d<16;d++)f[d]=n.getFloat32(i+13+d*4,!0);const l=Rn(n,i+13+64);r.push({id:c,parent:a>=0&&a<o?a:-1,matrix:f}),i=l.next}return r}function Xa(e,n,t){const o=ir(e,"MDLA");if(o<0)return[];let r=o+9;const i=n.getUint32(r,!0);r+=4;const s=n.getUint32(r,!0);if(r+=4,s<=0||s>256)return[];const c=[];for(let a=0;a<s&&!(r+16>n.byteLength);a++){const f=n.getUint32(r,!0);r+=8;const l=Rn(n,r);r=l.next;const d=Rn(n,r);if(r=d.next,r+16>n.byteLength)break;const h=n.getFloat32(r,!0);r+=4;const m=n.getUint32(r,!0);r+=8;const M=n.getUint32(r,!0);if(r+=4,M>1024)break;const g=[];for(let y=0;y<M&&!(r+8>n.byteLength);y++){r+=4;const b=n.getUint32(r,!0);r+=4;const p=Math.floor(b/36);if(r+b>n.byteLength)break;const v=new Float32Array(p*9);for(let _=0;_<p;_++){const w=r+_*36;for(let L=0;L<9;L++)v[_*9+L]=n.getFloat32(w+L*4,!0)}r+=b,g.push({frameCount:p,keyframes:v})}if(r+=35,g.length>0&&m>0&&h>0&&c.push({id:f,name:l.value,mode:d.value,fps:h,frameCount:m,duration:m/h,tracks:g}),r>=i)break}return c}function Ga(e,n){let t=0,o=0;for(const r of e)for(let i=0;i<r.tracks.length;i++){const s=r.tracks[i];if(!s)continue;const c=n[i],a=c?c.matrix[12]:0,f=c?c.matrix[13]:0,l=s.keyframes;for(let d=0;d<s.frameCount;d++){const h=Math.abs(l[d*9]-a),m=Math.abs(l[d*9+1]-f);h>t&&(t=h),m>o&&(o=m)}}return{x:t,y:o}}function Ya(e,n,t){if(t.length===0)return null;const o=ir(e,"MDLE");if(o<0)return null;const r=o+8+1+4+4;if(r+t.length*64>n.byteLength)return null;const i=[];for(let s=0;s<t.length;s++){const c=new Float32Array(16);for(let a=0;a<16;a++)c[a]=n.getFloat32(r+s*64+a*4,!0);i.push(c)}return i}function qa(e,n,t,o){const r=e.frameCount;if(r===0)return o[0]=0,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=0,o[6]=1,o[7]=1,o[8]=1,o;const i=t*n.fps;let s,c,a;if(n.mode==="loop"){const m=Math.max(1,r-1),M=(i%m+m)%m;s=Math.floor(M),c=(s+1)%r,a=M-s}else if(n.mode==="mirror"){const m=Math.max(1,r-1),M=m*2;let g=(i%M+M)%M;g>m&&(g=M-g),s=Math.floor(g),c=Math.min(s+1,r-1),a=g-s}else{const m=Math.min(Math.max(i,0),r-1);s=Math.floor(m),c=Math.min(s+1,r-1),a=m-s}const f=e.keyframes,l=s*9,d=c*9,h=1-a;for(let m=0;m<9;m++)if(m>=3&&m<=5){let M=f[d+m]-f[l+m];M>Math.PI?M-=2*Math.PI:M<-Math.PI&&(M+=2*Math.PI),o[m]=f[l+m]+M*a}else o[m]=f[l+m]*h+f[d+m]*a;return o}function Za(e,n,t){const o=e.bindTRS&&e.bindTRS[n];if(o)return t.set(o),t;const r=e.bones[n].matrix;return t[0]=r[12],t[1]=r[13],t[2]=r[14],t[3]=0,t[4]=0,t[5]=Math.atan2(r[1],r[0]),t[6]=Math.hypot(r[0],r[1])||1,t[7]=Math.hypot(r[4],r[5])||1,t[8]=r[10]||1,t}function eo(e,n,t,o){const r=e.bones,i=r.length;if(i===0)return null;const s=!!(o&&o.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 h=0;h<i;h++)e._local.push(new Float32Array(16)),e._world.push(new Float32Array(16))}const c=Array.isArray(t)&&t.length>0,a=[];if(c)for(const h of t){if(h.visible===!1||h.visible===0)continue;const m=e.animations.find(M=>M.id===h.animation);m&&a.push({anim:m,additive:!!h.additive,blend:typeof h.blend=="number"?h.blend:1,rate:typeof h.rate=="number"?h.rate:1})}if(a.length===0&&!c){const h=e.animations[0];if(h)a.push({anim:h,additive:!1,blend:1,rate:1});else if(!s)return null}const f=e._trsBase||(e._trsBase=new Float32Array(9)),l=e._trsAcc||(e._trsAcc=new Float32Array(9)),d=e._trsSmp||(e._trsSmp=new Float32Array(9));for(let h=0;h<i;h++){Za(e,h,f),l.set(f);let m=!1,M=0;for(const y of a){const b=y.anim.tracks[h];if(!b)continue;qa(b,y.anim,n*y.rate,d);const p=y.blend;if(y.additive){for(let v=0;v<9;v++){let _=d[v]-f[v];v>=3&&v<=5&&(_>Math.PI?_-=2*Math.PI:_<-Math.PI&&(_+=2*Math.PI)),l[v]+=_*p}M+=p}else for(let v=0;v<9;v++)l[v]=l[v]*(1-p)+d[v]*p;m=!0}if(M>1)for(let y=0;y<9;y++)l[y]=f[y]+(l[y]-f[y])/M;const g=s?o.get(h):void 0;g&&(l[0]=g[0],l[1]=g[1],l[2]=g[2],m=!0),m?Jr(l[0],l[1],l[2],l[3],l[4],l[5],l[6],l[7],l[8],e._local[h]):Jr(f[0],f[1],f[2],f[3],f[4],f[5],f[6],f[7],f[8],e._local[h])}for(let h=0;h<i;h++){const m=r[h].parent;m>=0&&m<h?Bt(e._world[m],e._local[h],e._world[h]):e._world[h].set(e._local[h])}for(let h=0;h<i;h++)Bt(e._world[h],e.invBindWorld[h],e._tmp),e._skin.set(e._tmp,h*16);return e._skin}function di(e,n){return!e||!e.invBindWorld||!(n>=0&&n<e.invBindWorld.length)?null:fi(e.invBindWorld[n])}function Ka(e,n){return Bt(e,n)}function hi(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:Bt(e._world[t.bone],t.matrix);return null}function mi(e,n){if(!e||!e.attachments||typeof n!="string"||n==="")return null;for(const t of e.attachments){if(t.name!==n)continue;const o=di(e,t.bone);return o?Bt(o,t.matrix):null}return null}function to(e,n,t){const o=e&&e.angles&&e.angles[2]||0,r=e&&e.scale?e.scale[0]:1,i=e&&e.scale?e.scale[1]:1,s=o*Math.PI/180,c=Math.cos(s),a=Math.sin(s),f=n*r,l=t*i;return[f*c-l*a,f*a+l*c]}function Qa(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 o=(i,s)=>{const c=t.get(i.id);if(c)for(const a of c)s.push(a),o(a,s)},r=[];for(const i of e){const s=i&&i.attachment;if(typeof s!="string"||s==="")continue;const c=n.get(i.parentId);if(!c||!c.puppet)continue;const a=mi(c.puppet,s);if(!a)continue;const f=a[12],l=a[13],d=to(c,f,l),h=[];o(i,h),i.origin[0]+=d[0],i.origin[1]+=d[1];for(const m of h)m.origin[0]+=d[0],m.origin[1]+=d[1];i.parallaxDepth=c.parallaxDepth?c.parallaxDepth.slice():null;for(const m of h)m.parallaxDepth=i.parallaxDepth?i.parallaxDepth.slice():null;r.push({layer:i,parent:c,name:s,bindX:f,bindY:l,desc:h})}for(const i of r){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]})}return r}function Ja(e,n,t){if(!e||e.length===0)return;const o=new Set,r=[];for(const s of e){const c=s.parent&&s.parent.puppet;if(!c){r.push(null);continue}if(!o.has(c)){o.add(c);const f=typeof t=="function"?t(s.parent):null;eo(c,n,s.parent.animationLayers,f)}const a=hi(c,s.name);if(!a){r.push(null);continue}r.push(to(s.parent,a[12]-s.bindX,a[13]-s.bindY))}const i=new Set;for(const s of e){const c=s.subtree||[{layer:s.layer,x:s.baseX,y:s.baseY}];for(const a of c)i.has(a.layer)||(i.add(a.layer),a.layer.origin[0]=a.x,a.layer.origin[1]=a.y)}for(let s=0;s<e.length;s++){const c=e[s],a=r[s],f=c.subtree||[{layer:c.layer,x:c.baseX,y:c.baseY}];if(a)for(const l of f)l.layer.origin[0]+=a[0],l.layer.origin[1]+=a[1]}}const ec=128,sr=24;function tc(e){const n=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS)||256,t=Math.floor((n-32)/4);return Math.max(sr,Math.min(ec,t))}const nc=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 si(e){const n=e&&e.passes&&e.passes[0]&&e.passes[0].combos;return!!(n&&Number(n.REFRACT)===1)}function Ka(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 ai(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 Yr(e,n){return e||n?Math.atan2(n,e)-Math.PI/2:0}function ci(e,n){return e&&e.kind==="ropetrail"?Math.max(1,n||1):1}function li(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 ui(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 Qa{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 Ja{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 Qa)}_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:ii(c.distancemin),distanceMax:ii(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,ht)};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,ht)};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,ht),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=li(a);this.trailSegments=c,this.trailDuration=ui(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=si(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]+Le(-f[0],f[0])+(p?p[0]:0),o.y=s[1]+Le(-f[1],f[1])+(p?p[1]:0),o.z=s[2]+Le(-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()*ht,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=Le(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=Le(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)*ht,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,oi(a.life.min,a.life.max,a.life.exp)*this.lifetimeMul):1,o.baseSize=a.size?oi(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?Le(a.alpha.min,a.alpha.max):1)*this.opacityMul,o.alpha=o.baseAlpha,a.velocity&&(o.vx+=Le(a.velocity.min[0],a.velocity.max[0])*c,o.vy+=Le(a.velocity.min[1],a.velocity.max[1])*c,o.vz+=Le(a.velocity.min[2],a.velocity.max[2])*c),a.turbulentVelocity){const f=a.turbulentVelocity,p=f.audioMode?Hr(f.audioBounds,this._audioLevel||0):1,d=Le(f.speedMin,f.speedMax)*c*p,y=this.simTime*(f.timeScale||0),x=Gr(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=Le(a.rotation.min[2],a.rotation.max[2])),a.angularVelocity&&(o.rotVel=Le(a.angularVelocity.min[2],a.angularVelocity.max[2]));const l=this.ops;if(l.oscPos&&(o.oscFreq=Le(l.oscPos.freqMin,l.oscPos.freqMax),o.oscAmp=Le(l.oscPos.scaleMin,l.oscPos.scaleMax),o.oscPhase=Le(l.oscPos.phaseMin,l.oscPos.phaseMax)+o.seed*ht),l.oscAlpha&&(o.oscAFreq=Le(l.oscAlpha.freqMin,l.oscAlpha.freqMax),o.oscAPhase=Math.random()*(l.oscAlpha.phaseMax||ht)),l.oscSize&&(o.oscSFreq=Le(l.oscSize.freqMin,l.oscSize.freqMax),o.oscSPhase=Math.random()*(l.oscSize.phaseMax||ht)),l.turbulence.length){const f=l.turbulence[0];o.turbSpeed=Le(f.speedMin,f.speedMax),o.turbPhase=Le(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=Gr(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?Hr(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=Gr(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*ht+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*ht+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*ht+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=Hr(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=ci(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),Ue=O(te.x,te.y),_e=Ue[0]-le[0],Ze=Ue[1]-le[1],Xe=Math.hypot(_e,Ze),De=(Math.abs(Z.size)+Math.abs(te.size))*.5*v;De>0&&(M[h++]=(le[0]+Ue[0])*.5,M[h++]=(le[1]+Ue[1])*.5,M[h++]=0,M[h++]=De,M[h++]=Math.atan2(-_e,Ze),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++]=Xe/De,M[h++]=0,M[h++]=qr(Z),M[h++]=qr(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,Ue=Z.y,_e=1,Ze=1,Xe=Z.rot,De=A,Ke=_,Be,ye;if(a&&Z.trail){le=Z.trail[te*3],Ue=Z.trail[te*3+1];const he=l>1?te/(l-1):0;_e=1-he,Ze=1-he*.55;let Ie=0,Pe=0;te+1<l?(Ie=Z.trail[te*3]-Z.trail[(te+1)*3],Pe=Z.trail[te*3+1]-Z.trail[(te+1)*3+1]):te>0?(Ie=Z.trail[(te-1)*3]-Z.trail[te*3],Pe=Z.trail[(te-1)*3+1]-Z.trail[te*3+1]):(Ie=Z.vx,Pe=Z.vy);const Qe=O(le,Ue),Oe=O(le-Ie,Ue-Pe),Ae=Qe[0]-Oe[0],ot=Qe[1]-Oe[1],it=Math.hypot(Ae,ot),It=Math.max(.001,Math.abs(Z.size)*v*Ze);it>.001?(Xe=Yr(Ae,ot),Be=(Qe[0]+Oe[0])*.5,ye=(Qe[1]+Oe[1])*.5,Ke=Math.max(_,it/It)):(Be=Qe[0],ye=Qe[1])}else{const he=O(le,Ue);Be=he[0],ye=he[1]}if(c){const he=O(Z.x,Z.y);Be=he[0],ye=he[1];const Ie=O(Z.x+Z.vx,Z.y+Z.vy);Xe=Yr(Ie[0]-he[0],Ie[1]-he[1]);const Pe=ai(Math.hypot(Z.vx,Z.vy),c.length,c.minLength,c.maxLength);Ke=_*Pe}M[h++]=Be,M[h++]=ye,M[h++]=0,M[h++]=Math.abs(Z.size)*v*Ze,M[h++]=Xe,M[h++]=Z.r*g,M[h++]=Z.g*g,M[h++]=Z.b*g,M[h++]=Z.alpha*_e,M[h++]=De,M[h++]=Ke,M[h++]=Z.frame,M[h++]=0,M[h++]=1}}const V=this._prog;s.useProgram(V.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(V.uniTex,0),s.uniformMatrix4fv(V.uniMvp,!1,n);const X=this.refract&&this.normalTex&&this.normalTex.glTex;if(V.uniRefract&&s.uniform1i(V.uniRefract,X?1:0),X){s.activeTexture(s.TEXTURE1),s.bindTexture(s.TEXTURE_2D,this.normalTex.glTex),V.uniNormal&&s.uniform1i(V.uniNormal,1);const J=this.blend!=="additive";if(V.uniSampleScene&&s.uniform1i(V.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),V.uniScene&&s.uniform1i(V.uniScene,2),V.uniResolution&&s.uniform2f(V.uniResolution,Z,te),V.uniRefractScale&&s.uniform1f(V.uniRefractScale,this.refractAmount||.04)}else s.activeTexture(s.TEXTURE2),s.bindTexture(s.TEXTURE_2D,this.texture.glTex),V.uniScene&&s.uniform1i(V.uniScene,2)}else V.uniNormal&&(s.activeTexture(s.TEXTURE1),s.bindTexture(s.TEXTURE_2D,this.texture.glTex),s.uniform1i(V.uniNormal,1),s.activeTexture(s.TEXTURE2),s.bindTexture(s.TEXTURE_2D,this.texture.glTex),V.uniScene&&s.uniform1i(V.uniScene,2),V.uniSampleScene&&s.uniform1i(V.uniSampleScene,0));const ie=this._frameUniformData();ie?(s.uniform1i(V.uniFrameCount,ie.count),s.uniform4fv(V.uniFrames,ie.arr)):s.uniform1i(V.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=Za(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 ec=Object.freeze(Object.defineProperty({__proto__:null,ParticleSystem:Ja,particleInstanceSegs:ci,particlePassRefract:si,rgbaIsBlankWhite:Ka,ropeParticleV:qr,ropeTrailDuration:ui,ropeTrailHistoryCount:li,spriteTrailLengthFactor:ai,spriteTrailRotation:Yr},Symbol.toStringTag,{value:"Module"})),Rn=new Map,Zr=new Map;let cr=null;function tc(e,n){const t=String(e);Zr.set(t,n),Rn.delete(t)}function nc(e){cr=typeof e=="function"?e:null}function rc(){Zr.clear(),cr=null,Rn.clear()}function oc(){return Object.keys(Dn)}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 kn(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 lr(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 vn=e=>e*e*(3-2*e),fi=e=>e*e*e*(e*(e*6-15)+10),Kr=(e,n,t)=>e+(n-e)*t,ae=(e,n)=>Math.exp(-(e*e)/(n*n));function on(e,n,t,r){const o=Math.min(e,n,t-1-e,t-1-n);return o>=r?1:o/r}function Fn(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 Ut(e,n,t){return Fn(e,[n,t])}function Dt(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*=on(u,c,e,a),Se(i,(c*e+u)*4,x)}return{width:e,height:e,rgba:i}}function Et(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):vn(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 Nn=4;function di(e,n,t,r,o){const i=o===void 0?.85:o,s=new Uint8Array(e*n*4),a=n/Nn,c=lr(335009),u=Math.tan(t*Math.PI/180),l=e/2;for(let f=0;f<Nn;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 ic(e){if(e==="particle/nature/rain1"||e==="particle/nature/rain2"){const n=[];for(let t=0;t<Nn;t++)n.push({ou:0,ov:t/Nn,su:1,sv:1/Nn});return n}return null}function Qr(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 pi(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 kn({width:e,height:e,rgba:o},.05)}function Un(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=pi(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 hi(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 kn({width:e,height:e,rgba:n},.11)}function We(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 kn({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 mi(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 sc(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 gi(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=vn(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)*on(i,o,e,r))}return{width:e,height:e,rgba:n}}function ac(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 cc(e){return!e||!e.rgba?e:ac(e.rgba)?mt(e,2.8):e}const lc={"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 uc(e){if(!e)return null;const n=String(e);return/normal/i.test(n)?n:lc[n]||n+"_normal"}function fc(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 dc(e){if(Dn[e])return Dn[e]();const n=String(e).toLowerCase();return/normal/.test(n)?Ut(64,{r:.18,w:1},{r:.4,w:.2}):Ai(e)()}function bi(e,n,t){const r=lr(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=fi(x),h=fi(m);return Kr(Kr(s(c,d,y,x,m),s(c,d+1,y,x-1,m),M),Kr(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 yi(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 Gt(e,n,t,r,o,i,s){const a=i===void 0?1:i,c=s===void 0?200:s,u=256,l=bi(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=vn(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:yi(g,e,e)}function Jr(e,n){const t=e,r=bi(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=vn(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=kn({width:t,height:t,rgba:o},.08);return t===e?f:yi(f,e,e)}function eo(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 vi(e){const n=new Uint8Array(e*e*4),t=lr(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 ur(e,n){const t=n??19,r=lr(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)*on(d,p,e,f))}return{width:e,height:e,rgba:l}}function to(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 pc(e){return Ut(e,{r:.1,w:1},{r:.3,w:.16})}function no(e,n){const t=new Uint8Array(e*n*4);for(let r=0;r<n;r++){const o=(r+.5)/n,i=vn(Math.min(1,Math.min(o/.08,(1-o)/.08))),s=ae(o-.46,.24)*i,a=.5*(1-vn(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 xi(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)*on(i,o,e,r);Se(n,(o*e+i)*4,l)}return{width:e,height:e,rgba:n}}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;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)*on(i,o,e,r))}return{width:e,height:e,rgba:n}}function Mi(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)*on(a,s,e,o))}return kn({width:e,height:e,rgba:t},.03)}function ro(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 _i(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)*on(i,o,e,r))}return{width:e,height:e,rgba:n}}const Dn={"particle/halo_6":()=>Ut(256,{r:.14,w:1},{r:.4,w:.17}),"particle/normal_splash":()=>mt(mi(256),3.2),"particle/drop_normal":()=>mt(no(128,512),3.4),"particle/normal_ring_smooth":()=>mt(Qr(256,.55,.12),3.1),"particle/normal_pinch_rotate":()=>mt(sc(256),2.8),"particle/water/rain_drops_sheet_normal":()=>mt(eo(256,512,2,4),3.6),"particle/bubbles/bubble1normal":()=>mt(Un(256,1),3.2),"particle/bubbles/bubble2_normal":()=>mt(Un(256,2),3.2),"particle/sharp_halo_normal":()=>mt(Fn(256,[{r:.035,w:1},{r:.09,w:.45},{r:.22,w:.08}]),3.4),"particle/beam/beam_0":()=>Et(128,512,.46,!0),"particle/beam/beam_1":()=>Et(128,512,.34,!0),"particle/beam/beam_2":()=>Et(128,512,.22,!0),"particle/beam/beam_2_fade":()=>Et(128,512,.24,!1),"particle/light/light_shafts_0":()=>Et(128,512,.42,!0),"particle/light/light_shafts_1":()=>Et(128,512,.3,!0),"particle/light/light_shafts_3":()=>Et(128,512,.26,!0),"particle/light/light_shafts_5":()=>Et(128,512,.23,!0),"particle/light/light_shafts_6":()=>Et(128,512,.2,!0),"particle/nature/rosepetals":()=>hi(256),"particle/nature/leaves":()=>We(256,0),"particle/nature/leaves1":()=>We(256,1),"particle/nature/leaves2":()=>We(256,2),"particle/nature/leaves3":()=>We(256,3),"particle/nature/leaves5":()=>We(256,5),"particle/nature/leaves6":()=>We(256,6),"particle/nature/leaves7":()=>We(256,7),"particle/nature/leaves8":()=>We(256,8),"particle/nature/snow":()=>wi(256),"particle/halo":()=>Ut(256,{r:.12,w:1},{r:.3,w:.15}),"particle/halo_1":()=>Ut(256,{r:.1,w:1},{r:.3,w:.13}),"particle/halo_2":()=>Ut(256,{r:.2,w:.9},{r:.44,w:.2}),"particle/halo_3":()=>Fn(256,[{r:.045,w:1},{r:.13,w:.85},{r:.36,w:.15}]),"particle/halo_4":()=>Ut(256,{r:.085,w:1},{r:.28,w:.12}),"particle/halo_5":()=>Fn(256,[{r:.04,w:1},{r:.11,w:.8},{r:.34,w:.17}]),"particle/sharp_halo":()=>Fn(256,[{r:.035,w:1},{r:.09,w:.45},{r:.22,w:.08}]),"particle/chromaticdot":()=>pc(128),"particle/light/flare_0":()=>Dt(256,6,.58,10,.08),"particle/light/flare_1":()=>Dt(512,4,.62,14,.07),"particle/light/flare_2":()=>_i(256),"particle/drop":()=>no(128,512),"particle/nature/rain1":()=>di(128,512,10,1,.78),"particle/nature/rain2":()=>di(128,512,10,1.6,.66),"particle/water/rain_drops_sheet":()=>eo(256,512,2,4),"particle/fog/fog1":()=>Gt(512,4,5,1,.4,.9,150),"particle/fog/fog2":()=>Gt(512,3,5,2,.45,.8,140),"particle/fog/fog3":()=>Gt(512,6,4,3,.36,1,150),"particle/smoke/smoke1":()=>Gt(512,3,5,7,.55,1.5,130),"particle/smoke/smoke2":()=>Gt(512,2,5,11,.6,1.7,120),"particle/smoke/smoke2light":()=>Gt(512,2,5,13,.4,1.7,110),"particle/misc/wave":()=>Qr(512,.72,.085),"particle/misc/star_0":()=>Dt(256,5,.62,8,.1),"particle/bubbles/bubble1":()=>Un(256,1),"particle/bubbles/bubble2":()=>Un(256,2),"particle/bubbles/bubble3":()=>Un(256,3),"particle/debris/debris1":()=>vi(128),"particle/lightning/lightning1":()=>ur(256,3),"particle/lightning/lightning2":()=>ur(256,11),"particle/lightning/lightning3":()=>ur(256,19),"particle/fire/fire1":()=>Jr(256,23),"particle/fire/fire2":()=>Jr(256,41),"particle/star":()=>Dt(256,4,.58,12,.09),"particle/shape/circle_wind":()=>gi(256),"particle/sickle":()=>xi(256),"particle/magic/glyph_4":()=>Mi(256,4),"@sparkle":()=>Dt(256,4,.6,16,.08),"@star":()=>Dt(256,5,.62,8,.1),"@trail":()=>to(128,256)};function Ai(e){const n=String(e).toLowerCase();if(/normal/.test(n)){const t=fc(e);return t?()=>mt(dc(t),2.8):()=>mt(mi(128),2.6)}return/rosepetal|petal|sakura|blossom/.test(n)?()=>hi(256):/leaf|leaves|foliage/.test(n)?/leaves8/.test(n)?()=>We(256,8):/leaves7/.test(n)?()=>We(256,7):/leaves6/.test(n)?()=>We(256,6):/leaves5/.test(n)?()=>We(256,5):/leaves3/.test(n)?()=>We(256,3):/leaves2/.test(n)?()=>We(256,2):/leaves1/.test(n)?()=>We(256,1):()=>We(256,0):/circle_wind|windcircle/.test(n)?()=>gi(256):/fog|cloud|mist|vapor/.test(n)?()=>Gt(512,4,5,5,.4,.9,150):/smoke/.test(n)?()=>Gt(512,3,5,8,.55,1.5,130):/beam|shaft|ray|godray/.test(n)?()=>Et(128,512,.3,!0):/flare/.test(n)?()=>_i(256):/bubble/.test(n)?()=>pi(256,1):/ring|wave/.test(n)?()=>Qr(512,.72,.085):/fire|flame|ember|ash/.test(n)?()=>Jr(256,ro(n)):/sickle|crescent|moon/.test(n)?()=>xi(256):/glyph|magic|rune/.test(n)?()=>Mi(256,ro(n)):/snowflake|雪花|snow/.test(n)?()=>wi(256):/流星|meteor|shooting/.test(n)?()=>to(128,256):/star|星/.test(n)?()=>Dt(256,5,.62,8,.1):/sparkle|glint|twinkle/.test(n)?()=>Dt(256,4,.6,16,.08):/rain_drops_sheet|drops_sheet/.test(n)?()=>eo(256,512,2,4):/drop|rain/.test(n)?()=>no(128,512):/debris|dirt|rock/.test(n)?()=>vi(128):/lightning|bolt|arc/.test(n)?()=>ur(256,ro(n)):/note|music/.test(n)?()=>Dt(256,4,.55,8,.12):/trail|streak/.test(n)?()=>to(128,256):()=>Ut(256,{r:.12,w:1},{r:.3,w:.15})}function hc(e){if(Rn.has(e))return Rn.get(e);let n=null;const t=Zr.get(e);if(t)try{n=t()}catch{n=null}if(!n&&cr)try{n=cr(e)}catch{n=null}if(!n&&Dn[e])try{n=Dn[e]()}catch{n=null}if(!n)try{n=Ai(e)()}catch{n=null}return n||(n=Ut(256,{r:.12,w:1},{r:.3,w:.15})),Rn.set(e,n),n}function mc(e){return typeof e=="string"&&e.indexOf("particle/")===0}const gc=Object.freeze(Object.defineProperty({__proto__:null,buildBuiltinParticleTexture:hc,builtinParticleFrames:ic,isBuiltinParticleTextureName:mc,listBuiltinParticleTextureNames:oc,particleNormalNameForAlbedo:uc,prepareParticleNormalTexture:cc,resetParticleTextureFactories:rc,setParticleTextureFactory:tc,setParticleTextureProvider:nc},Symbol.toStringTag,{value:"Module"})),Ti=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);function Yt(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 Si(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(Ti);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 oo(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 Bn(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 fr(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 bc(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=Bn(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=vc(e,n),A=xc(e,n,v.length),_=Mc(e,n,v),R=yc(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]),Ue=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,Ue||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]=oo(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?Yt(ie[Z],X[J]):Float32Array.from(X[J])}for(let J=0;J<v.length;J++)L[J]=Si(ie[J]);if(_){const J=[];for(let Z=0;Z<v.length;Z++){const te=v[Z].parent;J[Z]=te>=0&&te<Z?Yt(J[te],_[Z]):Float32Array.from(_[Z])}for(let Z=0;Z<v.length;Z++)N[Z]=Yt(J[Z],L[Z])}}let H=1/0,K=-1/0,O=1/0,V=-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>V&&(V=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:wc(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:V}}}function yc(e,n,t){const r=fr(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=Bn(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 vc(e,n){const t=fr(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=Bn(n,i+13+64);o.push({id:a,parent:c>=0&&c<r?c:-1,matrix:u}),i=l.next}return o}function xc(e,n,t){const r=fr(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=Bn(n,o);o=l.next;const f=Bn(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 wc(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 Mc(e,n,t){if(t.length===0)return null;const r=fr(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 _c(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 Ac(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 io(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++){Ac(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;_c(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?oo(l[0],l[1],l[2],l[3],l[4],l[5],l[6],l[7],l[8],e._local[p]):oo(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?Yt(e._world[d],e._local[p],e._world[p]):e._world[p].set(e._local[p])}for(let p=0;p<i;p++)Yt(e._world[p],e.invBindWorld[p],e._tmp),e._skin.set(e._tmp,p*16);return e._skin}function Ei(e,n){return!e||!e.invBindWorld||!(n>=0&&n<e.invBindWorld.length)?null:Si(e.invBindWorld[n])}function Tc(e,n){return Yt(e,n)}function Pi(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:Yt(e._world[t.bone],t.matrix);return null}function Ci(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=Ei(e,t.bone);return r?Yt(r,t.matrix):null}return null}function so(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 Sc(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=Ci(a.puppet,s);if(!c)continue;const u=c[12],l=c[13],f=so(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 Ec(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;io(c,n,a.parent.animationLayers,l)}const u=Pi(c,a.name);if(!u){o.push(null);continue}o.push(so(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 Pc=128,dr=24;function Cc(e){const n=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS)||256,t=Math.floor((n-32)/4);return Math.max(dr,Math.min(Pc,t))}const Lc=e=>`#version 300 es
140
142
  in vec3 a_pos;
141
143
  in vec2 a_uv;
142
144
  in vec4 a_bone;
@@ -162,7 +164,7 @@ void main() {
162
164
  vec4 local = total > 0.0 ? skinned / total : p;
163
165
  gl_Position = u_mvp * vec4(local.xy, 0.0, 1.0);
164
166
  v_uv = a_uv;
165
- }`,rc=`#version 300 es
167
+ }`,Rc=`#version 300 es
166
168
  precision mediump float;
167
169
  in vec2 v_uv;
168
170
  uniform sampler2D u_tex;
@@ -171,12 +173,12 @@ out vec4 fragColor;
171
173
  void main() {
172
174
  vec4 t = texture(u_tex, v_uv);
173
175
  fragColor = t * u_color;
174
- }`;function oc(e){const n=(f,l)=>{const d=e.createShader(f);if(e.shaderSource(d,l),e.compileShader(d),!e.getShaderParameter(d,e.COMPILE_STATUS))throw new Error("MDL \u7740\u8272\u5668\u7F16\u8BD1\u5931\u8D25: "+e.getShaderInfoLog(d));return d};let t=tc(e),o=null;for(;;){const f=e.createProgram();let l=!1;try{e.attachShader(f,n(e.VERTEX_SHADER,nc(t))),e.attachShader(f,n(e.FRAGMENT_SHADER,rc)),e.bindAttribLocation(f,0,"a_pos"),e.bindAttribLocation(f,1,"a_uv"),e.bindAttribLocation(f,2,"a_bone"),e.bindAttribLocation(f,3,"a_weight"),e.linkProgram(f),l=!!e.getProgramParameter(f,e.LINK_STATUS)}catch{l=!1}if(l){o=f;break}if(e.deleteProgram(f),t<=sr)throw new Error("MDL \u7740\u8272\u5668\u94FE\u63A5\u5931\u8D25\uFF08\u9AA8\u6570\u5DF2\u964D\u5230 "+sr+"\uFF09");t=Math.max(sr,t>>1)}const r=t,i={mvp:e.getUniformLocation(o,"u_mvp"),tex:e.getUniformLocation(o,"u_tex"),skin:e.getUniformLocation(o,"u_skin"),boneCount:e.getUniformLocation(o,"u_boneCount"),color:e.getUniformLocation(o,"u_color")},s=new Float32Array(r*16);for(let f=0;f<r;f++)s.set(ui,f*16);const c=new WeakMap;function a(f){let l=c.get(f);if(l)return l;const d=e.createVertexArray();e.bindVertexArray(d);const h=f.vertexCount,m=new Float32Array(h*13);for(let b=0;b<h;b++){const p=b*13;m[p]=f.positions[b*3],m[p+1]=f.positions[b*3+1],m[p+2]=f.positions[b*3+2],m[p+3]=f.uvs[b*2],m[p+4]=f.uvs[b*2+1];for(let v=0;v<4;v++)m[p+5+v]=f.boneIdx[b*4+v],m[p+9+v]=f.weights[b*4+v]}const M=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,M),e.bufferData(e.ARRAY_BUFFER,m,e.STATIC_DRAW);const g=52;e.enableVertexAttribArray(0),e.vertexAttribPointer(0,3,e.FLOAT,!1,g,0),e.enableVertexAttribArray(1),e.vertexAttribPointer(1,2,e.FLOAT,!1,g,12),e.enableVertexAttribArray(2),e.vertexAttribPointer(2,4,e.FLOAT,!1,g,20),e.enableVertexAttribArray(3),e.vertexAttribPointer(3,4,e.FLOAT,!1,g,36);const y=e.createBuffer();return e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,y),e.bufferData(e.ELEMENT_ARRAY_BUFFER,f.indices,e.STATIC_DRAW),e.bindVertexArray(null),l={vao:d,vbuf:M,ibuf:y},c.set(f,l),l}return{gl:e,prog:o,maxBones:r,upload(f){a(f)},draw(f,l,d,h){const m=a(l);e.useProgram(o),e.bindVertexArray(m.vao),e.activeTexture(e.TEXTURE0);const M=d.overrideTex||(h&&h.glTex?h.glTex:h);e.bindTexture(e.TEXTURE_2D,M),e.uniform1i(i.tex,0),e.uniformMatrix4fv(i.mvp,!1,f);const g=d.color||[1,1,1,1];e.uniform4f(i.color,g[0],g[1],g[2],g[3]);const y=eo(l,d.time||0,d.animLayers,d.boneOverrides),b=Math.min(l.bones.length,r);y&&b>0?(e.uniformMatrix4fv(i.skin,!1,y.subarray(0,b*16)),e.uniform1i(i.boneCount,b)):(e.uniformMatrix4fv(i.skin,!1,s),e.uniform1i(i.boneCount,0)),d.blending==="additive"?(e.enable(e.BLEND),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE)):d.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 p=l.indexType==="u32"?e.UNSIGNED_INT:e.UNSIGNED_SHORT;e.drawElements(e.TRIANGLES,l.indexCount,p,0),e.bindVertexArray(null)}}}const ic=Object.freeze(Object.defineProperty({__proto__:null,applyAttachmentBindOrigins:Qa,attachmentBind:mi,attachmentWorld:hi,bindWorldOf:di,computeSkinMatrices:eo,createMDLRenderer:oc,followAttachments:Ja,mat4MulOut:Ka,parentMeshToWorldDelta:to,parseMDL:Va},Symbol.toStringTag,{value:"Module"}));function pi(e,n,t){const o=Math.max(0,Number(t)||0),r=Math.max(1,Number(e)||1),i=Math.max(1,Number(n)||1);return o*2>=Math.min(r,i)?0:o}function sc(e,n,t){const o=Math.max(1,n.boxW),r=Math.max(1,n.boxH),i=pi(o,r,n.padding||0),s=n.spacing||[0,0],c=Math.max(1,n.lineHeight||(n.pointsize||24)*1.25+s[1]),a=Math.max(1,o-i*2),f=n.limitwidth&&n.maxwidth>0?Math.min(n.maxwidth,a):1/0;function l(L){if(t(L)<=f)return[L];const F=[];let D="",B=-1;for(const z of L)if(D+=z,(z===" "||z===" ")&&(B=D.length),t(D)>f&&D.length>1)for(B>0?(F.push(D.slice(0,B-1)),D=D.slice(B)):(F.push(D.slice(0,-1)),D=z),B=-1;t(D)>f&&D.length>1;)F.push(D.slice(0,-1)),D=D.slice(-1);return D!==""&&F.push(D),F.length?F:[""]}let d=[];const h=String(e??"").split(`
175
- `);for(const L of h)d.push(...l(L));let m=!1;if(n.limitrows&&n.maxrows>0&&d.length>n.maxrows&&(d=d.slice(0,n.maxrows),m=!0,n.limituseellipsis)){let L=d[n.maxrows-1];for(;L.length>0&&t(L+"\u2026")>f;)L=L.slice(0,-1);d[n.maxrows-1]=L+"\u2026"}const M=d.map(L=>t(L)),g=d.length*c,y=n.halign||"center",b=n.valign||"center",p=o/2,v=r/2,_=b==="top"?v:b==="bottom"?v-g:(r-g)/2;return{lines:d.map((L,F)=>{const D=M[F],B=y==="left"?p:y==="right"?p-D:(o-D)/2;return{text:L,width:D,x:B,y:_+F*c}}),lineHeight:c,totalH:g,truncated:m,boxW:o,boxH:r}}function ac(e,n,t){const o=n.boxW,r=n.boxH,i=t.color||[1,1,1],s=t.alpha!==void 0?t.alpha:1,c=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 f=t.backgroundcolor||[0,0,0],l=t.backgroundbrightness!==void 0?t.backgroundbrightness:1;e.fillStyle=`rgba(${Math.round(f[0]*255*l)},${Math.round(f[1]*255*l)},${Math.round(f[2]*255*l)},${s})`,e.fillRect(0,0,o,r)}const a=(f,l,d)=>{e.fillStyle=d;for(const h of n.lines)e.fillText(h.text,h.x+f,h.y+n.lineHeight/2+l)};if(t.castshadow){const f=Math.max(1,(t.pointsize||24)/10);a(f,f,`rgba(0,0,0,${s*.75})`)}a(0,0,`rgba(${Math.round(i[0]*255*c)},${Math.round(i[1]*255*c)},${Math.round(i[2]*255*c)},${s})`)}const gi=/^add[A-Z]/;function bi(){return{log:()=>{},warn:()=>{},error:()=>{},info:()=>{},debug:()=>{}}}function yi(e){return new Proxy(e,{get(n,t,o){const r=Reflect.get(n,t,o);if(r==null&&typeof t=="string"&&t!=="then"){const i=()=>{};return n[t]=i,i}return r}})}function cn(e,n){return()=>{}}function vi(e,n){e.isScreensaver=!!n.isScreensaver,typeof n.isRunningInEditor=="boolean"&&(e.isRunningInEditor=n.isRunningInEditor),e.setInterval||(e.setInterval=n.setInterval||cn),e.setTimeout||(e.setTimeout=n.setTimeout||cn),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 o=n.windowTitle;Object.defineProperty(e,"windowTitle",{configurable:!0,enumerable:!0,get(){return o&&o.title?String(o.title):""}}),Object.defineProperty(e,"windowApp",{configurable:!0,enumerable:!0,get(){return o&&o.app?String(o.app):""}})}class he{constructor(n,t,o){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=o!==void 0?o:n.z||0;else if(t===void 0&&o===void 0){const r=Number(n)||0;this.x=r,this.y=r,this.z=r}else this.x=Number(n)||0,this.y=Number(t)||0,this.z=Number(o)||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=(o,r)=>r===0?0:o/r;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 o=new he(n),r=Number(t),i=Number.isFinite(r)?r:0;return new he(this.x+(o.x-this.x)*i,this.y+(o.y-this.y)*i,this.z+(o.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 xi=he;function wi(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 Mi(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 cc(e,n,t){return new he(e||0,n||0,t||0)}function lc(){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 Ai={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 o=Math.min(1,Math.max(0,(t-e)/(n-e||1)));return o*o*(3-2*o)},smoothStep:(e,n,t)=>{const o=Math.min(1,Math.max(0,(t-e)/(n-e||1)));return o*o*(3-2*o)},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,o=Math.min(1,Math.max(0,Number(n.y)||0)),r=Math.min(1,Math.max(0,Number(n.z)||0)),i=Math.floor(t*6),s=t*6-i,c=r*(1-o),a=r*(1-s*o),f=r*(1-(1-s)*o),d=[[r,f,c],[a,r,c],[c,r,f],[c,a,r],[f,c,r],[r,c,a]][i%6];return{x:d[0],y:d[1],z:d[2]}},rgb2hsv:e=>{const n=e&&typeof e=="object"?e:{x:0,y:0,z:0},t=Number(n.x)||0,o=Number(n.y)||0,r=Number(n.z)||0,i=Math.max(t,o,r),s=Math.min(t,o,r),c=i-s;let a=0;return c>0&&(i===t?a=(o-r)/c/6:i===o?a=(2+(r-t)/c)/6:a=(4+(t-o)/c)/6,a<0&&(a+=1)),{x:a,y:i===0?0:c/i,z:i}}},Ti={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})},Si=Object.freeze({PLAYBACK_STOPPED:0,PLAYBACK_PLAYING:1,PLAYBACK_PAUSED:2}),ar=["mediaPropertiesChanged","mediaThumbnailChanged","mediaPlaybackChanged","mediaTimelineChanged","mediaStatusChanged","mediaLyricsChanged"],uc=["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"],fc=new RegExp(`(^[ \\t]*|;|\\})[ \\t]*(?:var|let|const)[ \\t]+(?=(?:${uc.join("|")})\\b)`,"gm"),dc={WEMath:!0,WEColor:!0,WEVector:!0};function Ei(e){return typeof e!="string"?e:e.replace(/([!=])==(\s*)(['"])(-?\d+)\3/g,"$1=$2$3$4$3")}function Pi(e){return Ei(e).replace(/\bimport\s*\*\s*as\s+(\w+)\s+from\s*['"]([^'"]+)['"]\s*;?/g,(n,t,o)=>{const r=String(o);return dc[r]?t===r?"":`var ${t} = ${r};`:`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(fc,"$1")}function Ln(e){return e!==null&&typeof e=="object"&&"value"in e?e.value:e}function Ci(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 hc(e,n,t={}){if(typeof e!="string"||e.length===0)return null;const o=Pi(e);if(o===e&&e.indexOf("update")<0)return null;const r={};if(n&&typeof n=="object")for(const[b,p]of Object.entries(n))r[b]=Ln(p);const i=new Proxy(()=>i,{apply(){return i},get(b,p){if(p==="finish")return()=>r;if(typeof p=="string"&&gi.test(p))return v=>(v&&typeof v=="object"&&typeof v.name=="string"&&!(v.name in r)&&(r[v.name]=Ln(v.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:ro(t.origin||[0,0,0])},c={registerAsset:()=>{},frametime:1/60,runtime:0,canvasSize:Ci(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||cn,clearTimeout:t.clearTimeout||(()=>{}),setInterval:t.setInterval||cn,clearInterval:t.clearInterval||(()=>{}),openUserShortcut:t.openUserShortcut||(()=>{}),isRunningInEditor:!!t.isRunningInEditor,isScreensaver:!!t.isScreensaver};vi(c,t);const a=t.audioViews;c.registerAudioBuffers=b=>{const p=Math.max(1,Math.min(64,Math.floor(Number(b)||0)));let v=a?a.get(p):void 0;return v||(v={left:new Float32Array(p),right:new Float32Array(p),average:new Float32Array(p)},a&&a.set(p,v)),v};const f={getLayer(b){const p=t.getLayerText?t.getLayerText(String(b)):void 0;return{text:p!=null?String(p):""}},createLayer(b){return{text:"",visible:!1,color:[0,0,0],alpha:1,pointsize:t.pointsize||24,font:t.font||"",origin:ro(t.origin||[0,0,0]),angles:[0,0,0],scale:[1,1,1]}},sortLayer:()=>{},getLayerIndex:()=>0},l=t.shared||{},d={console:bi()},h=Mi(t.inputView);let m;try{m=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
- `+o+`
177
- ;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,`+ar.map(p=>`${p}: typeof ${p} === "function" ? ${p} : null,`).join("")+"dummy_: 0};")(r,yi(c),s,f,Ai,_i,Ti,i,l,d.console,void 0,d,d,d,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,xi,h,Si)}catch(b){return t.onError&&t.onError(b,"parse"),null}const M=!!(m&&ar.some(b=>m[b])),g=!!(m&&typeof m.applyUserProperties=="function");if(!m||!m.update&&!M&&!g)return null;const y={engine:c,thisLayer:s,scriptProperties:r,hasUpdate:!!m.update,hasCursorHook:!!(m.cursorClick||m.cursorEnter||m.cursorLeave||m.cursorDown||m.cursorUp||m.cursorMove),hasMediaHook:M,hasApplyHook:g,errCount:0,disabled:!1,init(b){if(m.init)try{m.init(b)}catch(p){y.errCount++,t.onError&&t.onError(p,"init")}},applyUserProperties(b){if(m.applyUserProperties)try{m.applyUserProperties(b||{})}catch(p){y.errCount++,t.onError&&t.onError(p,"applyUserProperties")}},callUpdate(b){if(!m.update||y.disabled)return null;const p=s.text;let v;try{v=m.update(p!==""?p:b!==void 0?b:"")}catch(_){return y.errCount++,t.onError&&t.onError(_,"update"),y.errCount>=3&&(y.disabled=!0),null}return typeof v=="string"?(s.text=v,v):typeof v=="boolean"?null:v!=null?(s.text=String(v),s.text):s.text!==p?s.text:null},callCursor(b,p){if(y.disabled)return;const v=m[b];if(typeof v=="function")try{return v(p)}catch(_){y.errCount++,t.onError&&t.onError(_,b),y.errCount>=3&&(y.disabled=!0);return}},callMedia(b,p){if(y.disabled)return;const v=m[b];if(typeof v=="function")try{return v(p)}catch(_){y.errCount++,t.onError&&t.onError(_,b),y.errCount>=3&&(y.disabled=!0);return}}};return y}function Fn(){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 mc(e){if(!e)return Fn();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:o=>{const r=Number(o);return n.frame=Number.isFinite(r)?r:0,t},setRate:o=>{const r=Number(o);return Number.isFinite(r)&&(n.rate=r),t},setBlend:()=>t,setVisible:o=>(e.visible=!!o,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 pc(e){if(e&&e.videoTextureApi)return e.videoTextureApi;const n=()=>e&&e.videoCtl||null,t={get duration(){const o=n(),r=o&&typeof o.duration=="function"?o.duration():0;return Number.isFinite(r)?r:0},get rate(){const o=n(),r=o&&typeof o.getRate=="function"?o.getRate():1;return Number.isFinite(r)&&r>0?r:1},set rate(o){const r=n(),i=Number(o);r&&typeof r.setRate=="function"&&Number.isFinite(i)&&r.setRate(i)},get loop(){const o=n();return o&&typeof o.getLoop=="function"?!!o.getLoop():!0},set loop(o){const r=n();r&&typeof r.setLoop=="function"&&r.setLoop(!!o)},play:()=>{const o=n();o&&o.play&&o.play()},pause:()=>{const o=n();o&&o.pause&&o.pause()},stop:()=>{const o=n();o&&o.stop&&o.stop()},isPlaying:Object.assign(()=>{const o=n();return!!(o&&typeof o.isPlaying=="function"&&o.isPlaying())},{valueOf(){const o=n();return!!(o&&typeof o.isPlaying=="function"&&o.isPlaying())},toString(){const o=n();return String(!!(o&&typeof o.isPlaying=="function"&&o.isPlaying()))}}),getCurrentTime:()=>{const o=n(),r=o&&typeof o.getCurrentTime=="function"?o.getCurrentTime():0;return Number.isFinite(r)?r:0},setCurrentTime:o=>{const r=n(),i=Number(o);r&&typeof r.setCurrentTime=="function"&&Number.isFinite(i)&&r.setCurrentTime(i)},addEndedCallback:o=>{const r=n();typeof o=="function"&&r&&typeof r.addEndedCallback=="function"&&r.addEndedCallback(o)}};return e&&(e.videoTextureApi=t),t}function gc(){const e=new Map,n=o=>e.has(String(o))?e.get(String(o)):null,t=(o,r)=>{e.set(String(o),String(r))};return{getItem:n,setItem:t,get:n,set:t,removeItem:o=>{e.delete(String(o))},remove:o=>{e.delete(String(o))},clear:()=>{e.clear()},key:o=>Array.from(e.keys())[o]??null,get length(){return e.size}}}function bc(e,n){const t=e&&e.puppet,o=t&&t.bones||null,r=o?o.length:0,i=e&&e.origin||[0,0,0],s=e&&e.scale||[1,1,1],c=s[0]||1,a=s[1]||1,f=(M,g)=>[i[0]+M*c,i[1]-g*a],l=(M,g)=>[(M-i[0])/c,-(g-i[1])/a],d=M=>{const g=n.get(M);if(g)return[g[0],g[1],g[2]];const y=o[M].matrix;return[y[12],y[13],y[14]]},h=M=>{let g=0,y=0,b=M;for(let p=0;b>=0&&b<r&&p<64;p++){const v=d(b);g+=v[0],y+=v[1],b=o[b].parent}return f(g,y)},m=M=>{const g={translation(y){if(y===void 0){const w=h(M);return new he(w[0],w[1],0)}const b=Ot(y);let p=0,v=0;if(o[M].parent>=0){const w=h(o[M].parent),L=l(w[0],w[1]);p=L[0],v=L[1]}const _=l(b[0],b[1]);return n.set(M,[_[0]-p,_[1]-v,0]),g},rotation(){return g},scale(){return g}};return g};return{getBoneCount:()=>r,getBoneTransform:M=>{const g=Math.floor(Number(M));if(!o||!(g>=0)||g>=r){const y={translation(b){return b===void 0?new he(0,0,0):y},rotation(){return y},scale(){return y}};return y}return m(g)},setBoneTransform:(M,g)=>{const y=Math.floor(Number(M));!o||!(y>=0)||y>=r},applyBonePhysicsImpulse:()=>{}}}function no(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 Ri(e,n){if(e==null)return null;const t=o=>{if(!o)return null;if(n&&typeof n.getSceneLayer=="function"){const r=n.getSceneLayer(String(o));if(r)return r}return n&&n.layer&&n.layer.name===o?n.layer:null};return t(typeof e=="object"?e.name:String(e))}function yc(e,n){e&&(e.visibleSelf=!1,e.visible=!1,e.destroyed=!0,n&&typeof n.recomputeVisibility=="function"&&n.recomputeVisibility())}function Li(e,n){if(typeof e!="string"||!e||/\/workshop\//.test(e))return e;const t=n!=null&&n!==""?String(n):"";if(!t)return e;const o=e.match(/^(models|materials|shaders|particles|effects)\/(.+)$/);return o?`${o[1]}/workshop/${t}/${o[2]}`:e}function vc(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 xc(e){const n=t=>cr(t||null,e);return{getLayer(t){if(e.getSceneLayer){const o=e.getSceneLayer(String(t));if(o&&!o.destroyed)return n(o)}return n(null)},createLayer(t){if(typeof e.createSceneLayer!="function")return n(null);let o=t;if(typeof t=="string"){const i=typeof e.getWorkshopId=="function"?e.getWorkshopId():e.workshopId;o=Li(t,i)}const r=e.createSceneLayer(o);return n(r||null)},destroyLayer(t){yc(Ri(t,e),e)},sortLayer:()=>{},getLayerIndex(t){const o=typeof e.enumerateSceneLayers=="function"?e.enumerateSceneLayers():[],r=t&&typeof t=="object"?t.name:String(t||""),i=o.findIndex(s=>s&&s.name===r);return i<0?0:i},enumerateLayers(){const t=typeof e.enumerateSceneLayers=="function"?e.enumerateSceneLayers():[],o=[];for(const r of t)r&&!r.destroyed&&o.push(n(r));return o},getAnimation(t){if(typeof e.getSceneAnimation=="function"){const o=e.getSceneAnimation(t);if(o)return o}return Fn()},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 o=e.cameraTransforms;!o||!t||typeof t!="object"||(typeof t.zoom=="number"&&Number.isFinite(t.zoom)&&t.zoom>0&&(o.zoom=t.zoom),t.center!==void 0&&(o.center=t.center),t.eye!==void 0&&(o.eye=t.eye),typeof t.parallaxAmount=="number"&&(o.parallaxAmount=t.parallaxAmount))},getInitialLayerConfig(t){return typeof e.getInitialLayerConfig=="function"?e.getInitialLayerConfig(t):Ri(t,e)||null}}}function cr(e,n){const t=s=>ro(Array.isArray(s)?s:[0,0,0]),o=n&&typeof n.getBoneOverrides=="function"&&e?n.getBoneOverrides(e):null,r={origin:t(e?e.origin:[0,0,0]),scale:t(e?e.scale:[1,1,1]),angles:Ac(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 c=n&&n.targetEffect;if(c){c.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 c=String(s||"center").toLowerCase();e.alignment=c==="centre"?"center":c},...e&&e.puppet&&o?bc(e,o):{getBoneCount:()=>0,getBoneTransform:()=>{const s={translation(c){return c===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:cr(s,n)},getChildren:()=>{const s=e&&e.childIds||[];if(!s.length)return[];const c=n&&typeof n.getSceneLayerById=="function"?n.getSceneLayerById:null;if(!c)return[];const a=[];for(const f of s){const l=c(f);l&&!l.destroyed&&a.push(cr(l,n))}return a},getAnimation:s=>{const c=e&&e.animations,a=e&&e.animationList||[];return s==null||s===""?a[0]||Fn():c&&c[s]?c[s]:typeof s=="number"&&a[s]?a[s]:typeof s=="string"&&/^\d+$/.test(s)&&a[Number(s)]?a[Number(s)]:Fn()},getAnimationLayer:s=>{const c=e&&e.animations,a=e&&e.animationList||[];return c&&c[s]?c[s]:typeof s=="number"&&a[s]?a[s]:typeof s=="string"&&/^\d+$/.test(s)&&a[Number(s)]?a[Number(s)]:Fn()},getAnimationLayerCount:()=>(e&&e.animationList||[]).length,getTextureAnimation:()=>mc(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(),c=e&&e.videoCtl&&typeof e.videoCtl.isPlaying=="function"&&e.videoCtl.isPlaying();return!!(s||c)},{valueOf(){const s=e&&e.soundCtl&&typeof e.soundCtl.isPlaying=="function"&&e.soundCtl.isPlaying(),c=e&&e.videoCtl&&typeof e.videoCtl.isPlaying=="function"&&e.videoCtl.isPlaying();return!!(s||c)},toString(){const s=e&&e.soundCtl&&typeof e.soundCtl.isPlaying=="function"&&e.soundCtl.isPlaying(),c=e&&e.videoCtl&&typeof e.videoCtl.isPlaying=="function"&&e.videoCtl.isPlaying();return String(!!(s||c))}}),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 c=Number(s);if(!Number.isFinite(c)||!e)return;const a=Math.max(0,Math.min(1,c));e.soundprops&&(e.soundprops.volume=a),e.soundCtl&&typeof e.soundCtl.setVolume=="function"&&e.soundCtl.setVolume(a)},getVideoTexture:()=>pc(e),getTransformMatrix:()=>{const s=e&&e.origin||[0,0,0],c=new Float32Array(16);return c[0]=1,c[5]=1,c[10]=1,c[15]=1,c[12]=s[0]||0,c[13]=s[1]||0,c[14]=s[2]||0,{m:c}},getEffect:s=>{const c=e&&e.effects||null;if(!c||c.length===0)return no(null);if(typeof s=="number"||typeof s=="string"&&/^\d+$/.test(s))return no(c[Number(s)]||null);const a=String(s);return no(c.find(f=>f&&f.name===a)||null)}};Object.defineProperty(i,"angles",{enumerable:!0,get(){return r.angles},set(s){if(e&&Array.isArray(e.angles)){const c=Fi(s);e.angles[0]=c[0],e.angles[1]=c[1],e.angles[2]=c[2]}}});for(const s of["origin","scale","size","color"])Object.defineProperty(i,s,{enumerable:!0,get(){if(e&&Array.isArray(e[s])){const c=e[s];r[s].x=c[0]||0,r[s].y=c[1]||0,r[s].z=c[2]||0}return r[s]},set(c){const a=Ot(c);r[s].x=a[0],r[s].y=a[1],r[s].z=a[2],e&&Array.isArray(e[s])&&s!=="size"&&(e[s][0]=a[0],e[s][1]=a[1],e[s][2]=a[2])}});return i}function wc(e,n,t={}){if(typeof e!="string"||e.length===0)return null;const o=Pi(e),r={};if(n&&typeof n=="object")for(const[_,w]of Object.entries(n))if(w!==null&&typeof w=="object"&&typeof w.user=="string"){const L=t.userProperties?t.userProperties[w.user]:void 0;r[_]=L!==void 0?L:Ln(w)}else r[_]=Ln(w);const i=new Proxy(()=>i,{apply(){return i},get(_,w){if(w==="finish")return()=>r;if(typeof w=="string"&&gi.test(w))return L=>(L&&typeof L=="object"&&typeof L.name=="string"&&!(L.name in r)&&(r[L.name]=Ln(L.value)),i)}}),s={registerAsset:()=>{},frametime:1/60,runtime:0,canvasSize:Ci(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||cn,clearTimeout:t.clearTimeout||(()=>{}),setInterval:t.setInterval||cn,clearInterval:t.clearInterval||(()=>{}),openUserShortcut:t.openUserShortcut||(()=>{}),isRunningInEditor:!!t.isRunningInEditor,isScreensaver:!!t.isScreensaver};vi(s,t);const c=t.audioViews;s.registerAudioBuffers=_=>{const w=Math.max(1,Math.min(64,Math.floor(Number(_)||0)));let L=c?c.get(w):void 0;return L||(L={left:new Float32Array(w),right:new Float32Array(w),average:new Float32Array(w)},c&&c.set(w,L)),L};const a=t.shared||{},f={console:bi()},l=Mi(t.inputView),d=t.layer||null,h=t.workshopId!=null?t.workshopId:vc(e),m=cr(d,t),M=xc({...t,workshopId:h,getWorkshopId:()=>h});let g;try{g=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";
178
- `+o+`
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,`+ar.map(w=>`${w}: typeof ${w} === "function" ? ${w} : null,`).join("")+"dummy_: 0};")(r,yi(s),Ai,_i,Ti,i,a,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,he,xi,l,m,M,m,gc(),Si)}catch(_){return t.onError&&t.onError(_,"parse"),null}const y=!!(g&&(g.cursorClick||g.cursorEnter||g.cursorLeave||g.cursorDown||g.cursorUp||g.cursorMove)),b=!!(g&&ar.some(_=>g[_])),p=!!(g&&typeof g.applyUserProperties=="function");if(!g||!g.update&&!y&&!b&&!p)return null;const v={engine:s,scriptProperties:r,hasUpdate:!!g.update,hasCursorHook:y,hasApplyHook:p,errCount:0,disabled:!1,init(_){if(g.init)try{g.init(wi(_))}catch(w){v.errCount++,t.onError&&t.onError(w,"init")}},applyUserProperties(_){if(g.applyUserProperties)try{g.applyUserProperties(_||{})}catch(w){v.errCount++,t.onError&&t.onError(w,"applyUserProperties")}},callUpdate(_){if(v.disabled||!g.update)return;let w;try{w=g.update(wi(_))}catch(L){v.errCount++,t.onError&&t.onError(L,"update"),v.errCount>=3&&(v.disabled=!0);return}return w},hasCursorHook:y,callCursor(_,w){if(v.disabled)return;const L=g[_];if(typeof L=="function")try{return L(w)}catch(F){v.errCount++,t.onError&&t.onError(F,_),v.errCount>=3&&(v.disabled=!0);return}},hasMediaHook:b,callMedia(_,w){if(v.disabled)return;const L=g[_];if(typeof L=="function")try{return L(w)}catch(F){v.errCount++,t.onError&&t.onError(F,_),v.errCount>=3&&(v.disabled=!0);return}}};return v}function ro(e){const n=Array.isArray(e)?e:[0,0,0],t={x:n[0]||0,y:n[1]||0,z:n[2]||0},o={get x(){return t.x},set x(r){t.x=Number(r)||0},get y(){return t.y},set y(r){t.y=Number(r)||0},get z(){return t.z},set z(r){t.z=Number(r)||0},add(r){const i=Ot(r);return t.x+=i[0],t.y+=i[1],t.z+=i[2],o},subtract(r){const i=Ot(r);return t.x-=i[0],t.y-=i[1],t.z-=i[2],o},multiply(r){if(r&&typeof r=="object"){const i=Ot(r);t.x*=i[0],t.y*=i[1],t.z*=i[2]}else{const i=Number(r)||0;t.x*=i,t.y*=i,t.z*=i}return o},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 o}function Ot(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 lr=Math.PI/180,ur=180/Math.PI;function Mc(e){const n=Array.isArray(e)?e:[0,0,0];return{x:(n[0]||0)*ur,y:(n[1]||0)*ur,z:(n[2]||0)*ur}}function Fi(e){const n=Ot(e);return[n[0]*lr,n[1]*lr,n[2]*lr]}function Ac(e){const n={x:0,y:1,z:2},t={add(o){const r=Ot(o);return t.x+=r[0],t.y+=r[1],t.z+=r[2],t},subtract(o){const r=Ot(o);return t.x-=r[0],t.y-=r[1],t.z-=r[2],t},multiply(o){return t.x*=o,t.y*=o,t.z*=o,t},toArray(){return[t.x,t.y,t.z]}};for(const o of["x","y","z"])Object.defineProperty(t,o,{enumerable:!0,get(){return!e||!Array.isArray(e.angles)?0:(e.angles[n[o]]||0)*ur},set(r){!e||!Array.isArray(e.angles)||(e.angles[n[o]]=(Number(r)||0)*lr)}});return t}function _c(e,n){return Math.min(256,Math.ceil(Math.max(1,Number(e)||1)*2+8))}function Tc(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 o of n&&n.passes||[])for(const r of o&&o.textures||[])if(r&&String(r).toLowerCase().includes("mask"))return!0}return!1}const Sc=Object.freeze(Object.defineProperty({__proto__:null,createInputView:lc,drawTextLayer:ac,effectiveTextPadding:pi,evalObjectScript:wc,evalTextScript:hc,layoutText:sc,makeCursorEventVec:cc,radToScriptAngles:Mc,resolveWorkshopAssetPath:Li,rewriteComboStringEq:Ei,scriptAnglesToRad:Fi,textCanvasMargin:_c,textLayerHasTintMask:Tc},Symbol.toStringTag,{value:"Module"}));function Ec(e={},n={}){const t=typeof e.setTimeout=="function"?e.setTimeout:null,o=typeof e.clearTimeout=="function"?e.clearTimeout:null,r=typeof e.setInterval=="function"?e.setInterval:null,i=typeof e.clearInterval=="function"?e.clearInterval:null,s=typeof n.onError=="function"?n.onError:null,c=new Set,a=y=>{const b=Number(y);return Number.isFinite(b)&&b>0?b:0},f=y=>()=>{try{y()}catch(b){s&&s(b,"timer")}},l=(y,b)=>{const p=()=>{y.fired||(y.fired=!0,c.delete(p),b&&y.handle!=null&&b(y.handle))};return p.handle=null,p.valueOf=()=>typeof y.handle=="number"?y.handle:0,p};function d(y,b){if(typeof y!="function")return l({fired:!0,handle:null},null);const p={fired:!1,handle:null},v=l(p,o);return c.add(v),p.handle=t?t(f(()=>{p.fired=!0,c.delete(v),y()}),a(b)):null,v.handle=p.handle,v}function h(y,b){if(typeof y!="function")return l({fired:!0,handle:null},null);const p={fired:!1,handle:null},v=l(p,i);return c.add(v),p.handle=r?r(f(y),a(b)):null,v.handle=p.handle,v}function m(y){if(typeof y=="function"){y();return}o&&y!=null&&o(y)}function M(y){if(typeof y=="function"){y();return}i&&y!=null&&i(y)}function g(){for(const y of[...c])y();c.clear()}return{setTimeout:d,setInterval:h,clearTimeout:m,clearInterval:M,dispose:g,pendingCount:()=>c.size}}const Pc=Object.freeze(Object.defineProperty({__proto__:null,createEngineTimers:Ec},Symbol.toStringTag,{value:"Module"}));function Cc(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 oo(e,n){const t=Math.floor(e),o=e-t,r=s=>{const c=Math.sin((s*127.1+n*311.7)*43758.5453)*43758.5453;return(c-Math.floor(c))*2-1},i=o*o*(3-2*o);return r(t)*(1-i)+r(t+1)*i}const Rc=32,Ni=60/112,Lc=3.2;function Fc(e){const n=new Float32Array(16),t=new Float32Array(16),o=new Float32Array(16);for(let r=0;r<16;r++)n[r]=r%4===0?1:r%4===2?.38+e()*.15:e()<.08?.5:0,t[r]=r%8===4?1:e()<.06?.6:0,o[r]=r%2===1?.5+e()*.4:r%4===0?.25:e()<.3?.3:0;return{kick:n,snare:t,hat:o}}function Nc(e=20260830){const n=Cc(e),t=Fc(n),o=new Float32Array(64);for(let y=0;y<64;y++)o[y]=n()*64;const r=64,i=new Float32Array(r),s=new Float32Array(r),c=new Float32Array(r),a=new Float32Array(r),f=new Float32Array(32),l=new Float32Array(32),d=new Float32Array(16),h=new Float32Array(16),m={left64:c,right64:a,left32:f,right32:l,left16:d,right16:h,level:0,silent:!1};function M(y,b){const p=b.length/y.length;for(let v=0;v<y.length;v++){let _=0;const w=Math.floor(v*p),L=Math.floor((v+1)*p);for(let F=w;F<Math.max(w+1,L);F++)_+=b[F];y[v]=_/Math.max(1,L-w)}}function g(y){const b=y/Ni,p=b*4,v=Math.floor(p)%16,_=p-Math.floor(p),w=Math.exp(-_*Ni*14),L=y%Rc,F=L>=27&&L<29,D=L>=29?(L-29)/3:0,B=L>=24&&L<27?1-(L-24)/3:0,z=F?0:D>0?D*D:B>0?0:1,V=F?0:B>0?.35:1,Y=t.kick[v]*w*z,Z=(t.snare[v]*w+t.hat[v]*w*.7)*z,X=t.hat[v]*w*z,q=D>0?Math.pow(D,3)*(.4+.6*Math.abs(oo(p*2,7))):0;let oe=0;for(let H=0;H<r;H++){const j=H/r,ee=Math.pow(1-j*.85,1.6);let le=V*(.5+.3*oo(b*.5+o[H]*.05,H%8));if(le*=.35+.65*j,j<.2&&(le+=Y*(1-j/.2)),j>=.12&&j<.62){const Fe=1-Math.abs(j-.34)/.28;Fe>0&&(le+=Z*.55*Fe)}j>=.45&&(le+=X*.5*((j-.45)/.55)),le+=q*.5,le*=ee,le=Math.min(1,le*Lc);const Se=.06+j*.2,Xe=oo(b*.13+H*.35,11)*Se;let Le=Math.min(1,Math.max(0,le*(1-Xe))),Pe=Math.min(1,Math.max(0,le*(1+Xe)));const ue=F?.012:0;i[H]=Math.max(ue,Le),s[H]=Math.max(ue,Pe),H<48&&(oe+=(i[H]+s[H])*.5)}return c.set(i),a.set(s),M(f,i),M(l,s),M(d,i),M(h,s),m.level=Math.min(1,oe/(48*1.2)),m.silent=F,m}return{update:g,snapshot:m,bands:r}}function kc(e,n){for(const t of e.values()){ki(t.left,n.left64),ki(t.right,n.right64);for(let o=0;o<t.average.length;o++)t.average[o]=(t.left[o]+t.right[o])*.5}}function ki(e,n){const t=n.length/e.length;for(let o=0;o<e.length;o++){let r=0;const i=Math.floor(o*t),s=Math.max(i+1,Math.floor((o+1)*t));for(let c=i;c<s;c++)r+=n[c];e[o]=r/(s-i)}}const Dt={STOPPED:0,PLAYING:1,PAUSED:2};class Re{constructor(n,t,o){this.x=Number(n)||0,this.y=Number(t)||0,this.z=Number(o)||0}add(n){return new Re(this.x+n.x,this.y+n.y,this.z+n.z)}subtract(n){return new Re(this.x-n.x,this.y-n.y,this.z-n.z)}multiply(n){if(n!==null&&typeof n=="object")return new Re(this.x*n.x,this.y*n.y,this.z*n.z);const t=Number(n)||0;return new Re(this.x*t,this.y*t,this.z*t)}divide(n){const t=Number(n)||1;return new Re(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 Re(this.x,this.y,this.z)}toArray(){return[this.x,this.y,this.z]}}function Uc(e,n,t){return new Re(e,n,t)}const Ic=[{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"]]}],fr=3;function Ui(e=20260901){const n=Ic,t=n.reduce((b,p)=>b+p.duration+fr,0),o={hasMedia:!1,state:Dt.STOPPED,title:"",artist:"",album:"",albumArtist:"",position:0,duration:0,hasThumbnail:!1,primaryColor:new Re(0,0,0),secondaryColor:new Re(0,0,0),tertiaryColor:new Re(0,0,0),textColor:new Re(1,1,1),highContrastColor:new Re(1,1,1),trackIndex:-1,lyrics:[],lyricLine:"",lyricIndex:-1};let r=0,i=!1,s=0,c=0;function a(b){let p=0;const v=(b%n.length+n.length)%n.length;for(let _=0;_<v;_++)p+=n[_].duration+fr;return p}function f(b){let p=t>0?b%t:0;p<0&&(p+=t);let v=-1,_=0,w=!1;for(let V=0;V<n.length;V++){const Y=n[V].duration;if(p<Y){v=V,_=p;break}if(p-=Y,p<fr){v=V,_=Y,w=!0;break}p-=fr}v<0&&(v=n.length-1,_=n[v].duration,w=!0);const L=n[v];o.hasMedia=!0,o.trackIndex=v,o.title=L.title,o.artist=L.artist,o.album=L.album,o.albumArtist=L.albumArtist,o.duration=L.duration,o.position=_;const F=L.duration>0?_/L.duration:0;i?o.state=Dt.PAUSED:w?o.state=Dt.STOPPED:F>.7&&F<.76?o.state=Dt.PAUSED:o.state=Dt.PLAYING,o.hasThumbnail=!w;const D=L.colors;o.primaryColor=new Re(D.primary[0],D.primary[1],D.primary[2]),o.secondaryColor=new Re(D.secondary[0],D.secondary[1],D.secondary[2]),o.tertiaryColor=new Re(D.tertiary[0],D.tertiary[1],D.tertiary[2]),o.textColor=new Re(D.text[0],D.text[1],D.text[2]);const B=.2126*D.primary[0]+.7152*D.primary[1]+.0722*D.primary[2];o.highContrastColor=B>.5?new Re(0,0,0):new Re(1,1,1),o.lyrics=L.lyrics;let z=-1;for(let V=0;V<L.lyrics.length;V++)_>=L.lyrics[V][0]&&(z=V);return o.lyricIndex=z,o.lyricLine=z>=0?L.lyrics[z][1]:"",o}function l(b){c=Number(b)||0;const p=i?s:c+r;return f(p)}function d(b){i=!1;const p=a(b);return r=p-c,f(p)}function h(){const b=o.trackIndex<0?0:o.trackIndex+1;return d(b)}function m(){const b=o.trackIndex<0?n.length-1:o.trackIndex-1;return d(b)}function M(){return i||(s=c+r,i=!0,o.state=Dt.PAUSED),o}function g(){return i?(i=!1,r=s-c,f(s)):o}function y(){return i?g():M()}return{update:l,snapshot:o,tracks:n,cycle:t,MEDIA_PLAYBACK:Dt,skipNext:h,skipPrevious:m,play:g,pause:M,playPause:y}}function Bc(e,n=512){const t=Math.max(8,n|0),o=new Uint8Array(t*t*4),r=e&&e.colors?e.colors:{primary:[.5,.5,.5],secondary:[.1,.1,.1],tertiary:[.8,.8,.8]},[i,s,c]=r.primary,[a,f,l]=r.secondary,[d,h,m]=r.tertiary;for(let M=0;M<t;M++)for(let g=0;g<t;g++){const y=g/(t-1),b=M/(t-1),p=y-.5,v=b-.5,_=Math.sqrt(p*p+v*v)*2,w=.5+.5*Math.sin(_*18-1.2),L=.5+.5*Math.sin((y+b)*6),F=Math.min(1,Math.max(0,_));let D=i*(1-F)+a*F,B=s*(1-F)+f*F,z=c*(1-F)+l*F;D=D*(.72+.28*w)+d*.18*L,B=B*(.72+.28*w)+h*.18*L,z=z*(.72+.28*w)+m*.18*L;const V=1-.35*Math.min(1,_*_),Y=(M*t+g)*4;o[Y]=Math.max(0,Math.min(255,Math.round(D*V*255))),o[Y+1]=Math.max(0,Math.min(255,Math.round(B*V*255))),o[Y+2]=Math.max(0,Math.min(255,Math.round(z*V*255))),o[Y+3]=255}return{width:t,height:t,rgba:o}}function Oc(e,n){const t=[];if(!n)return t;const o=!e;return(o||e.hasMedia!==n.hasMedia)&&t.push({name:"mediaStatusChanged",event:{enabled:n.hasMedia}}),(o||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"}}),(o||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}}),(o||e.state!==n.state)&&t.push({name:"mediaPlaybackChanged",event:{state:n.state}}),(o||Math.floor(e.position)!==Math.floor(n.position)||e.duration!==n.duration)&&t.push({name:"mediaTimelineChanged",event:{position:n.position,duration:n.duration}}),(o||e.lyricIndex!==n.lyricIndex||e.trackIndex!==n.trackIndex)&&t.push({name:"mediaLyricsChanged",event:{line:n.lyricLine,index:n.lyricIndex,lines:n.lyrics}}),t}function Dc(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 $c=Object.freeze(Object.defineProperty({__proto__:null,MEDIA_PLAYBACK:Dt,cloneMediaSnapshot:Dc,createSimulatedMedia:Ui,diffMediaEvents:Oc,mediaVec3:Uc,renderThumbnail:Bc},Symbol.toStringTag,{value:"Module"})),Ii=14,Nn=[{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 Bi(){const e={app:"",title:"",url:"",index:-1};function n(t){const o=Number(t)||0,r=Nn.length?Math.floor(o/Ii)%Nn.length:0,i=Nn[r]||Nn[0];return e.app=i.app,e.title=i.title,e.url=i.url,e.index=r,e}return n(0),{update:n,snapshot:e,tabs:Nn,hold:Ii}}function Oi(e){const n={name:"",at:0};function t(o){return n.name=String(o||""),n.at=Date.now(),typeof e=="function"&&e(n.name),n.name}return{openUserShortcut:t,last:n}}function zc(e){const n=Ui(e),t=Bi(),o=Oi(null);return{media:n,windowTitle:t,shortcuts:o}}const jc=Object.freeze(Object.defineProperty({__proto__:null,createShortcutHandler:Oi,createSimulatedSystem:zc,createSimulatedWindowTitle:Bi},Symbol.toStringTag,{value:"Module"}));function Vc(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),o={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 r(){if(!t)return;const l=t();o.screenW=l.w||1,o.screenH=l.h||1}r();function i(l){r();let d=l.clientX,h=l.clientY;if(n&&typeof n.getBoundingClientRect=="function"){const g=n.getBoundingClientRect();d-=g.left,h-=g.top}const m=d/o.screenW,M=h/o.screenH;o.has||(o.lastU=m,o.lastV=M,o.lastScreenX=d,o.lastScreenY=h),o.screenX=d,o.screenY=h,o.u=m,o.v=M,o.has=!0,o.moveCount++,o.lastEventTime=Date.now()}function s(l){l.button!==void 0&&l.button!==0||(o.leftDown=!0,o.downCount++)}function c(l){l.button!==void 0&&l.button!==0||(o.leftDown=!1,o.upCount++)}function a(){o.leftDown=!1}let f=!1;return n&&n.addEventListener&&(f=!0,n.addEventListener("mousemove",i,{passive:!0}),n.addEventListener("mousedown",s,{passive:!0}),n.addEventListener("mouseup",c,{passive:!0}),n.addEventListener("blur",a,{passive:!0}),typeof document<"u"&&document.addEventListener&&document.addEventListener("mouseleave",a,{passive:!0})),{state:o,beginFrame(){r(),o.lastU=o.u,o.lastV=o.v,o.lastScreenX=o.screenX,o.lastScreenY=o.screenY,o.lastWx=o.wx,o.lastWy=o.wy,o.lastOriginY=o.originY},syncWorld(l,d=0,h=0){if(!l)return;o.wx=l.offX+o.u*l.viewW-d,o.wy=l.offY+o.v*l.viewH-h;const m=Number(l.projH);o.originY=Number.isFinite(m)?m-o.wy:o.wy,o.lastWx===0&&o.lastWy===0&&(o.lastWx=o.wx,o.lastWy=o.wy,o.lastOriginY=o.originY)},normalizedDelta(){const l=o.u-o.lastU,d=o.v-o.lastV;return Math.hypot(l,d)},dispose(){!f||!n||!n.removeEventListener||(f=!1,n.removeEventListener("mousemove",i),n.removeEventListener("mousedown",s),n.removeEventListener("mouseup",c),n.removeEventListener("blur",a),typeof document<"u"&&document.removeEventListener&&document.removeEventListener("mouseleave",a))}}}const Wc=Object.freeze(Object.defineProperty({__proto__:null,createPointerSource:Vc},Symbol.toStringTag,{value:"Module"}));function Di(e,n,t,o,r,i,s){const c=e.size||[0,0],a=e.scale||[1,1,1],f=c[0]*a[0],l=c[1]*a[1];if(!(f>0)||!(l>0))return null;const d=e.origin||[0,0,0];let h=d[0],m=o-d[1];if(e.parallaxDepth&&(r!==0||i!==0)){const p=e.parallaxDepth,v=sn(p[0]),_=sn(p[1]);h+=v*r,m+=_*i}let M=n-h,g=t-m;const y=e.angles?e.angles[2]:0;if(y){const p=Math.cos(-y),v=Math.sin(-y),_=M*p+g*v,w=-M*v+g*p;M=_,g=w}const b=s&&s[e.alignment]||[.5,.5];return(b[0]!==.5||b[1]!==.5)&&(M-=(.5-b[0])*f,g-=(.5-b[1])*l),{lx:M/f,ly:g/l,w:f,h:l}}function Hc(e,n,t,o,r={}){if(!e||e.length===0)return null;const i=r.parOffX||0,s=r.parOffY||0,c=r.alignTable,a=r.filter;for(let f=e.length-1;f>=0;f--){const l=e[f];if(!l||!l.visible||l.destroyed||a&&!a(l))continue;const d=Di(l,n,t,o,i,s,c);if(d&&Math.abs(d.lx)<=.5&&Math.abs(d.ly)<=.5)return l}return null}const Xc=Object.freeze(Object.defineProperty({__proto__:null,hitTestLayers:Hc,worldToLayerLocal:Di},Symbol.toStringTag,{value:"Module"})),ze=e=>e,je=ze(cs),dr=ze(_s),Qe=ze(ks),vt=ze(Os),Be=ze(ya),Gc=ze(xa),Yc=ze(Sa),Yt=ze(ja),kn=ze(ic),He=ze(Sc),qc=ze(Pc),ve=ze($c),$i=ze(jc),zi=ze(ha),Zc=ze(Wc),Kc=ze(Xc);function Qc(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 Jc(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 o=t.tracks.selectedTrack;if(!o||!o.frameCount)return null;const r=Math.min(o.frameCount,300),i=[];let s=0,c=0;for(let a=0;a<r;a++){const{image:f}=await t.decode({frameIndex:a});s=f.displayWidth,c=f.displayHeight,i.push({bitmap:await createImageBitmap(f),durationMs:f.duration?f.duration/1e3:100}),f.close()}return t.close?.(),{width:s,height:c,frames:i}}function el(e,n){if(en(e),!n.src){e.fallbackPage?.();return}const t=n.type==="video",o=n.type==="gif",r=document.createElement("canvas"),i=We(e,n);if(r.width=Math.max(1,Math.round(innerWidth*i)),r.height=Math.max(1,Math.round(innerHeight*i)),r.style.cssText="position:absolute;inset:0;width:100%;height:100%;",!r.getContext("webgl2",{premultipliedAlpha:!1,antialias:!1,alpha:!1,preserveDrawingBuffer:!0})){re(e,n,`media ${n.type}: WEBGL2_UNAVAILABLE\uFF0C\u56DE\u9000 DOM \u6E32\u67D3`),t?tl(e,n):nl(e,n);return}e.wrap?.appendChild(r),e.canvas=r;let c=!1;e.sceneCleanup=()=>{c=!0,e.renderer&&(e.renderer.dispose?.(),e.renderer=void 0)};let a,f,l=!1;e.sceneCtl={pause(){a?.()},resume(){f?.()},applyUserProperties(){}};const d=h=>{c||(c=!0,re(e,n,`media ${n.type} \u5931\u8D25: ${h}`),e.fallbackPage?.())};(async()=>{try{const h=Be.createRenderer(r,{diag:B=>re(e,n,`renderer: ${B}`),fboCapFactor:0});if(e.renderer=h,c)return;const m="__media",M=new Map;let g,y=0,b=0;if(t){const B=document.createElement("video");if(B.autoplay=!0,B.loop=n.loop!==!1,B.muted=n.muted!==!1,B.playsInline=!0,B.preload="metadata",B.width=r.width,B.height=r.height,B.style.cssText="position:fixed;left:-9999px;top:-9999px;width:2px;height:2px;opacity:0;pointer-events:none",B.src=n.src,document.body.appendChild(B),e.video=B,(e.videoTextures??=[]).push(B),await new Promise((z,V)=>{B.addEventListener("loadedmetadata",()=>z(),{once:!0}),B.addEventListener("error",()=>V(new Error(`video error ${B.error?.code??"?"}`)),{once:!0})}),c)return;y=B.videoWidth||r.width,b=B.videoHeight||r.height,M.set(m,{video:B,glTex:Be.makeTexture(h.gl,new Uint8Array([0,0,0,255]),1,1),width:y,height:b,rg88:!1,lastUploaded:-1}),e.paused||B.play().catch(()=>{}),re(e,n,`media video ${y}x${b} \u2192 scene \u6E32\u67D3`)}else{let B=!1;if(o&&typeof window.ImageDecoder=="function")try{const z=await Jc(n.src);if(z&&z.frames.length>1){y=z.width,b=z.height;const V=h.gl,Y={glTex:Be.makeTexture(V,null,0,0,z.frames[0].bitmap),width:y,height:b,rg88:!1};M.set(m,Y);let Z=0,X=performance.now()+z.frames[0].durationMs;g=()=>{const oe=performance.now();if(!(oe<X)){Z=(Z+1)%z.frames.length,X=oe+z.frames[Z].durationMs,V.bindTexture(V.TEXTURE_2D,Y.glTex);try{V.texImage2D(V.TEXTURE_2D,0,V.RGBA,V.RGBA,V.UNSIGNED_BYTE,z.frames[Z].bitmap)}catch{}}};const q=e.sceneCleanup;e.sceneCleanup=()=>{q?.();for(const oe of z.frames)oe.bitmap.close()},B=!0,re(e,n,`media gif ${y}x${b} ${z.frames.length} \u5E27 \u2192 scene \u6E32\u67D3`)}}catch(z){re(e,n,`gif \u89E3\u7801\u5931\u8D25\uFF0C\u56DE\u9000\u9759\u6001\u9996\u5E27: ${String(z.message).slice(0,80)}`)}if(!B){const z=new Image;if(z.crossOrigin="anonymous",z.src=n.src,await new Promise((V,Y)=>{z.addEventListener("load",()=>V(),{once:!0}),z.addEventListener("error",()=>Y(new Error("image load error")),{once:!0})}),c)return;y=z.naturalWidth||1,b=z.naturalHeight||1,e.img=z,M.set(m,{glTex:Be.makeTexture(h.gl,null,0,0,z),width:y,height:b,rg88:!1}),re(e,n,`media ${n.type} ${y}x${b} \u2192 scene \u6E32\u67D3`)}}if(c)return;const p=Qc(y,b,m),v=performance.now();let _=0,w=0,L=-1/0;const F=B=>{if(c||e.paused)return;const z=e.cfg.sceneFps||60;if(B-L>=1e3/z){L=B,fo(e,B),mo(e,r,e.cfg),g?.();const V=e.coverAlign;h.render(p,M,r.width,r.height,(B-v-_)/1e3,Xt(e.cfg.fit),V.x,V.y).then(()=>{c||e.paused||(e.raf=requestAnimationFrame(F))}).catch(Y=>d(String(Y.message||Y).slice(0,200)))}else e.paused||(e.raf=requestAnimationFrame(F))},D=()=>{c||e.paused||e.raf===void 0&&(e.raf=requestAnimationFrame(F))};a=()=>{e.raf!==void 0&&(cancelAnimationFrame(e.raf),e.raf=void 0),w||(w=performance.now());const B=e.video;l=!!(B&&!B.paused&&!B.ended),B?.pause()},f=()=>{w&&(_+=performance.now()-w,w=0),l&&e.video?.play().catch(()=>{}),l=!1,D()},D()}catch(h){d(String(h.message||h).slice(0,200))}})()}function tl(e,n){if(en(e),!n.src){e.fallbackPage?.();return}const t=lo(n.fit),o=`position:absolute;inset:0;width:100%;height:100%;object-fit:${t.objectFit};object-position:50% 50%;background:${t.background};`;let r=!1;const i=()=>{r||(r=!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 c=Math.min(window.devicePixelRatio||1,e.cfg.renderDpr||1);s.width=Math.max(1,Math.round(innerWidth*c)),s.height=Math.max(1,Math.round(innerHeight*c)),s.style.cssText=o,s.src=n.src,s.addEventListener("error",i),e.wrap?.appendChild(s),e.video=s,s.addEventListener("canplay",()=>s.play().catch(()=>{}),{once:!0}),re(e,n,"video mounted (single + native loop)")}function nl(e,n){en(e);const t=document.createElement("img"),o=lo(n.fit);t.style.cssText=`position:absolute;inset:0;width:100%;height:100%;object-fit:${o.objectFit};object-position:50% 50%;background:${o.background};`,t.src=n.src??"",t.addEventListener("error",()=>e.fallbackPage?.()),e.wrap?.appendChild(t),e.img=t}const rl=["scene.pkg","scenes/scene.pkg","gifscene.pkg"];function ji(e,n){const t=e.replace(/\/+$/,"");return{key:t,async scenePkg(o){let r=null,i=null;for(const c of rl){let a;try{a=await fetch(`${t}/${c}`,{...n,signal:o})}catch(f){if(o?.aborted)throw f;i=f;continue}if(!a.ok){r=a.status;continue}try{return await a.arrayBuffer()}catch(f){if(o?.aborted)throw f;const l=f instanceof Error?f.message:String(f);throw new Error(`\u8BFB\u53D6 scene.pkg \u4F53\u5931\u8D25\uFF08${l}\uFF09`)}}if(r!=null)throw new Error(`scene.pkg \u52A0\u8F7D\u5931\u8D25\uFF08HTTP ${r}\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(o){try{const r=await fetch(`${t}/project.json`,{...n,signal:o});return r.ok?await r.json():null}catch{return null}}}}function ol(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 il(e,n,t){return{key:t,scenePkg:async()=>e,project:async()=>n??null}}const Vi=.5,sl=.04,Wi=.08;function al(e,n){const t=p=>{const v=document.createElement("video");p&&(v.src=e),v.muted=n.muted,v.playsInline=!0,v.preload="metadata";const _=Math.min(window.devicePixelRatio||1,n.renderDpr||1),w=Math.max(1,Math.round(n.maxW*_)),L=Math.max(1,Math.round(n.maxH*_));return v.width=w,v.height=L,v.loop=!0,v};let o=t(!0),r=t(!1),i=!1,s=1,c=n.muted;r.muted=!0;const a=()=>{i||(r.src=e,i=!0)};let f=!1,l=!1,d=-1,h=0,m=!1;const M=()=>{if(f=!1,l=!1,!r.paused){r.pause();try{r.currentTime=0}catch{}}},g=()=>{const p=o;o=r,r=p,f=!1,l=!1,o.play().catch(()=>{}),o.muted=c,o.volume=s,p.pause();try{p.currentTime=0}catch{}p.muted=!0,d=-1,i=!0,b.onSwap?.(o)},y=()=>{if(m)return;h=requestAnimationFrame(y);const p=o.duration;if(!isFinite(p)||p<=0)return;const v=o.currentTime;if(d>=0&&v<d-.05){const w=l;M(),d=v,w||b.onFallback?.();return}d=v;const _=p-v;if(_>Vi+.5){(f||l)&&M();return}if(l){(_<=Wi||v<=Wi)&&g();return}if(f){r.paused?r.play().catch(()=>{}):r.currentTime>=sl*.5&&(r.pause(),f=!1,l=!0);return}if(_<=Vi&&(a(),r.readyState>=2)){try{r.currentTime=0}catch{}r.play().catch(()=>{}),f=!0}};h=requestAnimationFrame(y);const b={get active(){return o},get standby(){return r},onSwap:void 0,onFallback:void 0,setVolume(p){s=Math.max(0,Math.min(1,p)),c=p<=0,o.muted=c,o.volume=s,r.muted=!0,r.volume=s},pause(){M(),o.pause(),h&&cancelAnimationFrame(h),h=0},resume(){m||(o.play().catch(p=>{p&&p.name}),h||(h=requestAnimationFrame(y)))},destroy(){m=!0,h&&cancelAnimationFrame(h),h=0;for(const p of[o,r]){p.pause(),p.removeAttribute("src");try{p.load()}catch{}p.remove()}}};return b}const Hi=!1,Xi=!0,Gi=!1,cl=!1,ll=!1,Yi=4,Un=64,qi={STOPPED:0};function ul(){return{left64:new Float32Array(Un),right64:new Float32Array(Un),left32:new Float32Array(32),right32:new Float32Array(32),left16:new Float32Array(16),right16:new Float32Array(16),level:0,silent:!0}}function hr(e,n){const t=n.length/e.length;for(let o=0;o<e.length;o++){let r=0;const i=Math.floor(o*t),s=Math.max(i+1,Math.floor((o+1)*t));for(let c=i;c<s;c++)r+=n[c];e[o]=r/(s-i)}}function fl(e,n,t){const o=n.length,r=t*.5,i=20,s=Math.min(2e4,r);let c=0;for(let a=0;a<Un;a++){const f=a/Un,l=(a+1)/Un,d=i*Math.pow(s/i,f),h=i*Math.pow(s/i,l),m=Math.max(0,Math.floor(d/r*o)),M=Math.min(o,Math.max(m+1,Math.ceil(h/r*o)));let g=0;for(let b=m;b<M;b++)g+=n[b]/255;const y=Math.min(1,g/(M-m)*1.35);e.left64[a]=y,e.right64[a]=y,a<48&&(c+=y)}hr(e.left32,e.left64),hr(e.right32,e.right64),hr(e.left16,e.left64),hr(e.right16,e.right64),e.level=Math.min(1,c/(48*1.2)),e.silent=e.level<.02}function dl(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 io(e,n,t){const o=n/100,r=t/100,i=(1-Math.abs(2*r-1))*o,s=e/60,c=i*(1-Math.abs(s%2-1));let a=0,f=0,l=0;s<1?[a,f,l]=[i,c,0]:s<2?[a,f,l]=[c,i,0]:s<3?[a,f,l]=[0,i,c]:s<4?[a,f,l]=[0,c,i]:s<5?[a,f,l]=[c,0,i]:[a,f,l]=[i,0,c];const d=r-i/2;return[a+d,f+d,l+d]}function hl(e,n){const t=dl(n||"empty"),[o,r,i]=io(t,72,48),[s,c,a]=io((t+40)%360,55,28),[f,l,d]=io((t+20)%360,70,72);e.primaryColor=ve.mediaVec3(o,r,i),e.secondaryColor=ve.mediaVec3(s,c,a),e.tertiaryColor=ve.mediaVec3(f,l,d),e.textColor=ve.mediaVec3(.98,.98,1),e.highContrastColor=ve.mediaVec3(1,1,1),e.hasThumbnail=!!n}function ml(e,n,t){const o=document.createElement("canvas");o.width=32,o.height=32;const r=o.getContext("2d",{willReadFrequently:!0});if(!r)return null;r.drawImage(e,0,0,n,t,0,0,32,32);const i=r.getImageData(0,0,32,32).data;let s=0,c=0,a=0,f=0,l=0,d=0,h=0,m=-1;for(let b=0;b<i.length;b+=4){const p=i[b]/255,v=i[b+1]/255,_=i[b+2]/255;s+=p,c+=v,a+=_,f++;const w=Math.max(p,v,_),L=Math.min(p,v,_),F=w-L,D=.2126*p+.7152*v+.0722*_,B=F*1.4+(D>.15&&D<.85?.3:0);B>m&&(m=B,l=p,d=v,h=_)}if(!f)return null;const M=[l,d,h],g=[s/f*.55,c/f*.55,a/f*.55],y=[Math.min(1,M[0]*.45+.55),Math.min(1,M[1]*.45+.55),Math.min(1,M[2]*.45+.55)];return{primary:M,secondary:g,tertiary:y}}function pl(e,n,t,o=512){const r=document.createElement("canvas");r.width=o,r.height=o;const i=r.getContext("2d"),s=Math.max(o/Math.max(1,n),o/Math.max(1,t)),c=n*s,a=t*s;i.fillStyle="#000",i.fillRect(0,0,o,o),i.drawImage(e,(o-c)/2,(o-a)/2,c,a);const f=i.getImageData(0,0,o,o);return{width:o,height:o,rgba:new Uint8Array(f.data)}}function gl(){return{hasMedia:!1,state:qi.STOPPED,title:"",artist:"",album:"",albumArtist:"",position:0,duration:0,hasThumbnail:!1,primaryColor:ve.mediaVec3(0,0,0),secondaryColor:ve.mediaVec3(0,0,0),tertiaryColor:ve.mediaVec3(0,0,0),textColor:ve.mediaVec3(1,1,1),highContrastColor:ve.mediaVec3(1,1,1),trackIndex:-1,lyrics:[],lyricLine:"",lyricIndex:-1}}async function bl(){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),o=n.createAnalyser();return o.fftSize=2048,o.smoothingTimeConstant=.8,t.connect(o),n.state==="suspended"&&await n.resume().catch(()=>{}),{ctx:n,stream:e,analyser:o,buf:new Uint8Array(o.frequencyBinCount)}}catch{return null}}async function yl(e){const n=e?.origin??(typeof location<"u"?location.origin:""),t=e?.onArtwork,o=ul(),r=gl(),i={app:"",title:"",url:"",index:0};let s="off",c="offline",a="offline",f="",l=!1,d="";const h=await bl();h?s="mic":navigator.mediaDevices?.getUserMedia?s="denied":s="unavailable";let m=null,M=null,g=!1;const y=(w,L,F)=>{!n||!t||!l||d!==w&&(d=w,t({url:`${n}/api/system/artwork?k=${encodeURIComponent(w)}&_=${Date.now()}`,trackKey:w,title:L,artist:F}))},b=w=>{if(!w||!w.hasMedia){r.hasMedia=!1,r.state=qi.STOPPED,r.title="",r.artist="",r.album="",r.albumArtist="",r.position=0,r.duration=0,r.hasThumbnail=!1,r.trackIndex=-1,c=w?"empty":"offline",f="",l=!1,d="";return}c="live",r.hasMedia=!0,r.state=Number(w.state)===2?2:Number(w.state)===1?1:0,r.title=String(w.title??""),r.artist=String(w.artist??""),r.album=String(w.album??""),r.albumArtist=String(w.albumArtist??w.artist??""),r.position=Number(w.position)||0,r.duration=Number(w.duration)||0,l=w.hasArtwork===!0;const L=`${r.title}|${r.artist}|${r.album}`;L!==f&&(f=L,d="",r.trackIndex=r.trackIndex+1|0,hl(r,L)),y(L,r.title,r.artist)},p=w=>{if(!w){a="offline";return}i.app=String(w.app??""),i.title=String(w.title??""),i.url=String(w.url??""),a=i.app||i.title?"live":"empty"},v=async()=>{if(!(!n||g))try{const[w,L]=await Promise.all([fetch(`${n}/api/system/media`,{cache:"no-store"}),fetch(`${n}/api/system/window`,{cache:"no-store"})]);if(w.ok){const F=await w.json();b(F)}else c="offline";L.ok&&p(await L.json())}catch{c=c==="live"?"live":"offline",a=a==="live"?"live":"offline"}};if(n){await v(),M=setInterval(()=>{v()},1e3);try{m=new EventSource(`${n}/api/system/stream`),m.onmessage=w=>{if(!g)try{const L=JSON.parse(w.data);b(L.media),p(L.window)}catch{}}}catch{}}const _=w=>{!n||g||fetch(`${n}/api/system/media-control`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:w})}).then(async L=>L.ok?L.json():null).then(L=>{L&&typeof L=="object"&&b(L),v()}).catch(()=>{v()})};return{audio:{snapshot:o,pump:()=>{if(!h||g){o.level=0,o.silent=!0;return}h.analyser.getByteFrequencyData(h.buf),fl(o,h.buf,h.ctx.sampleRate||48e3)}},media:{snapshot:r,pump:()=>{},skipNext:()=>_("skipNext"),skipPrevious:()=>_("skipPrevious"),play:()=>_("play"),pause:()=>_("pause"),playPause:()=>_("playPause")},windowTitle:{snapshot:i,pump:()=>{}},status:()=>({audio:s,media:c,window:a,title:r.title,artist:r.artist,app:i.app,windowTitle:i.title,hasArtwork:l}),dispose:()=>{g=!0,M&&(clearInterval(M),M=null);try{m?.close()}catch{}if(m=null,h)try{h.stream.getTracks().forEach(w=>w.stop()),h.ctx.close()}catch{}}}}const vl={"common.h":`// WE common.h\uFF08\u91CD\u5EFA\u5B50\u96C6\uFF0C\u4F9B we-scene \u6D4F\u89C8\u5668\u6E32\u67D3\uFF09
176
+ }`;function kc(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=Cc(e),r=null;for(;;){const u=e.createProgram();let l=!1;try{e.attachShader(u,n(e.VERTEX_SHADER,Lc(t))),e.attachShader(u,n(e.FRAGMENT_SHADER,Rc)),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<=dr)throw new Error("MDL \u7740\u8272\u5668\u94FE\u63A5\u5931\u8D25\uFF08\u9AA8\u6570\u5DF2\u964D\u5230 "+dr+"\uFF09");t=Math.max(dr,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(Ti,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=io(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 Fc=Object.freeze(Object.defineProperty({__proto__:null,applyAttachmentBindOrigins:Sc,attachmentBind:Ci,attachmentWorld:Pi,bindWorldOf:Ei,computeSkinMatrices:io,createMDLRenderer:kc,followAttachments:Ec,mat4MulOut:Tc,parentMeshToWorldDelta:so,parseMDL:bc},Symbol.toStringTag,{value:"Module"}));function Li(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 Nc(e,n,t){const r=Math.max(1,n.boxW),o=Math.max(1,n.boxH),i=Li(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 Uc(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 Ri=/^add[A-Z]/;function ki(){return{log:()=>{},warn:()=>{},error:()=>{},info:()=>{},debug:()=>{}}}function Fi(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 xn(e,n){return()=>{}}function Ni(e,n){e.isScreensaver=!!n.isScreensaver,typeof n.isRunningInEditor=="boolean"&&(e.isRunningInEditor=n.isRunningInEditor),e.setInterval||(e.setInterval=n.setInterval||xn),e.setTimeout||(e.setTimeout=n.setTimeout||xn),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 me{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 me(n);return new me(this.x+t.x,this.y+t.y,this.z+t.z)}subtract(n){const t=new me(n);return new me(this.x-t.x,this.y-t.y,this.z-t.z)}multiply(n){return n&&typeof n=="object"?new me(this.x*n.x,this.y*n.y,this.z*n.z):new me(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 me(t(this.x,n.x),t(this.y,n.y),t(this.z,n.z)):new me(t(this.x,n),t(this.y,n),t(this.z,n))}copy(){return new me(this.x,this.y,this.z)}mix(n,t){const r=new me(n),o=Number(t),i=Number.isFinite(o)?o:0;return new me(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 me(0,0,0):new me(this.x/n,this.y/n,this.z/n)}dot(n){const t=new me(n);return this.x*t.x+this.y*t.y+this.z*t.z}toString(){return this.x+" "+this.y+" "+this.z}}const Ui=me;function Di(e){if(e instanceof me||!e||typeof e!="object"||Array.isArray(e)||!("x"in e)&&!("y"in e)&&!("z"in e)||Object.getPrototypeOf(e)===me.prototype)return e;try{Object.setPrototypeOf(e,me.prototype)}catch{}return e}function Bi(e){return e&&e.cursorWorldPosition?e:{cursorWorldPosition:new me(0,0,0),cursorScreenPosition:new me(0,0,0),cursorPosition:new me(0,0,0),cursorPositionLast:new me(0,0,0),cursorLeftDown:!1}}function Dc(e,n,t){return new me(e||0,n||0,t||0)}function Bc(){const e={cursorWorldPosition:new me(0,0,0),cursorScreenPosition:new me(0,0,0),cursorPosition:new me(0,0,0),cursorPositionLast:new me(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 Ii={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},Oi={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}}},$i={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})},ji=Object.freeze({PLAYBACK_STOPPED:0,PLAYBACK_PLAYING:1,PLAYBACK_PAUSED:2}),pr=["mediaPropertiesChanged","mediaThumbnailChanged","mediaPlaybackChanged","mediaTimelineChanged","mediaStatusChanged","mediaLyricsChanged"],Ic=["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"],Oc=new RegExp(`(^[ \\t]*|;|\\})[ \\t]*(?:var|let|const)[ \\t]+(?=(?:${Ic.join("|")})\\b)`,"gm"),$c={WEMath:!0,WEColor:!0,WEVector:!0};function zi(e){return typeof e!="string"?e:e.replace(/([!=])==(\s*)(['"])(-?\d+)\3/g,"$1=$2$3$4$3")}function Wi(e){return zi(e).replace(/\bimport\s*\*\s*as\s+(\w+)\s+from\s*['"]([^'"]+)['"]\s*;?/g,(n,t,r)=>{const o=String(r);return $c[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(Oc,"$1")}function In(e){return e!==null&&typeof e=="object"&&"value"in e?e.value:e}function Vi(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 jc(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]=In(h);const i=new Proxy(()=>i,{apply(){return i},get(M,h){if(h==="finish")return()=>o;if(typeof h=="string"&&Ri.test(h))return g=>(g&&typeof g=="object"&&typeof g.name=="string"&&!(g.name in o)&&(o[g.name]=In(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:mr(t.origin||[0,0,0])},a={registerAsset:()=>{},frametime:1/60,runtime:0,canvasSize:Vi(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||xn,clearTimeout:t.clearTimeout||(()=>{}),setInterval:t.setInterval||xn,clearInterval:t.clearInterval||(()=>{}),openUserShortcut:t.openUserShortcut||(()=>{}),isRunningInEditor:!!t.isRunningInEditor,isScreensaver:!!t.isScreensaver};Ni(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:mr(t.origin||[0,0,0]),angles:[0,0,0],scale:[1,1,1]}},sortLayer:()=>{},getLayerIndex:()=>0},l=t.shared||{},f={console:ki()},p=Bi(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
+ `+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,`+pr.map(h=>`${h}: typeof ${h} === "function" ? ${h} : null,`).join("")+"dummy_: 0};")(o,Fi(a),s,u,Ii,Oi,$i,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,me,Ui,p,ji)}catch(M){return t.onError&&t.onError(M,"parse"),null}const y=!!(d&&pr.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 On(){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 zc(e){if(!e)return On();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 Wc(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 Vc(){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 Hc(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 me(A[0],A[1],0)}const M=qt(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 me(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 ao(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 Hi(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 Xc(e,n){e&&(e.visibleSelf=!1,e.visible=!1,e.destroyed=!0,n&&typeof n.recomputeVisibility=="function"&&n.recomputeVisibility())}function Xi(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 Gc(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 Yc(e){const n=t=>hr(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=Xi(t,i)}const o=e.createSceneLayer(r);return n(o||null)},destroyLayer(t){Xc(Hi(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 On()},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):Hi(t,e)||null}}}function hr(e,n){const t=s=>mr(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:Kc(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?Hc(e,r):{getBoneCount:()=>0,getBoneTransform:()=>{const s={translation(a){return a===void 0?new me(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:hr(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(hr(l,n))}return c},getAnimation:s=>{const a=e&&e.animations,c=e&&e.animationList||[];return s==null||s===""?c[0]||On():a&&a[s]?a[s]:typeof s=="number"&&c[s]?c[s]:typeof s=="string"&&/^\d+$/.test(s)&&c[Number(s)]?c[Number(s)]:On()},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)]:On()},getAnimationLayerCount:()=>(e&&e.animationList||[]).length,getTextureAnimation:()=>zc(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:()=>Wc(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 ao(null);if(typeof s=="number"||typeof s=="string"&&/^\d+$/.test(s))return ao(a[Number(s)]||null);const c=String(s);return ao(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=Gi(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 mr(a||[0,0,0])},set(a){const c=qt(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:In(_)}else o[A]=In(_);const i=new Proxy(()=>i,{apply(){return i},get(A,_){if(_==="finish")return()=>o;if(typeof _=="string"&&Ri.test(_))return R=>(R&&typeof R=="object"&&typeof R.name=="string"&&!(R.name in o)&&(o[R.name]=In(R.value)),i)}}),s={registerAsset:()=>{},frametime:1/60,runtime:0,canvasSize:Vi(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||xn,clearTimeout:t.clearTimeout||(()=>{}),setInterval:t.setInterval||xn,clearInterval:t.clearInterval||(()=>{}),openUserShortcut:t.openUserShortcut||(()=>{}),isRunningInEditor:!!t.isRunningInEditor,isScreensaver:!!t.isScreensaver};Ni(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:ki()},l=Bi(t.inputView),f=t.layer||null,p=t.workshopId!=null?t.workshopId:Gc(e),d=hr(f,t),y=Yc({...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
+ `+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,`+pr.map(_=>`${_}: typeof ${_} === "function" ? ${_} : null,`).join("")+"dummy_: 0};")(o,Fi(s),Ii,Oi,$i,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,me,Ui,l,d,y,d,Vc(),ji)}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&&pr.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(Di(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(Di(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 mr(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=qt(o);return t.x+=i[0],t.y+=i[1],t.z+=i[2],r},subtract(o){const i=qt(o);return t.x-=i[0],t.y-=i[1],t.z-=i[2],r},multiply(o){if(o&&typeof o=="object"){const i=qt(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 me(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 qt(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 gr=Math.PI/180,br=180/Math.PI;function Zc(e){const n=Array.isArray(e)?e:[0,0,0];return{x:(n[0]||0)*br,y:(n[1]||0)*br,z:(n[2]||0)*br}}function Gi(e){const n=qt(e);return[n[0]*gr,n[1]*gr,n[2]*gr]}function Kc(e){const n={x:0,y:1,z:2},t={add(r){const o=qt(r);return t.x+=o[0],t.y+=o[1],t.z+=o[2],t},subtract(r){const o=qt(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)*br},set(o){!e||!Array.isArray(e.angles)||(e.angles[n[r]]=(Number(o)||0)*gr)}});return t}function Qc(e,n){return Math.min(256,Math.ceil(Math.max(1,Number(e)||1)*2+8))}function Jc(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 el=Object.freeze(Object.defineProperty({__proto__:null,createInputView:Bc,drawTextLayer:Uc,effectiveTextPadding:Li,evalObjectScript:qc,evalTextScript:jc,layoutText:Nc,makeCursorEventVec:Dc,radToScriptAngles:Zc,resolveWorkshopAssetPath:Xi,rewriteComboStringEq:zi,scriptAnglesToRad:Gi,textCanvasMargin:Qc,textLayerHasTintMask:Jc},Symbol.toStringTag,{value:"Module"}));function tl(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 nl=Object.freeze(Object.defineProperty({__proto__:null,createEngineTimers:tl},Symbol.toStringTag,{value:"Module"}));function rl(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 co(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 ol=32,Yi=60/112,il=3.2;function sl(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 qi(e=20260830){const n=rl(e),t=sl(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/Yi,v=g*4,A=Math.floor(v)%16,_=v-Math.floor(v),R=Math.exp(-_*Yi*14),L=h%ol,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,V=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(co(v*2,7))):0;let Z=0;for(let te=0;te<o;te++){const le=te/o,Ue=Math.pow(1-le*.85,1.6);let _e=O*(.5+.3*co(g*.5+r[te]*.05,te%8));if(_e*=.35+.65*le,le<.2&&(_e+=V*(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*=Ue;const Ze=_e;_e=Math.min(1,_e*il);const Xe=.06+le*.2,De=co(g*.13+te*.35,11)*Xe;let Ke=Math.min(1,Math.max(0,_e*(1-De))),Be=Math.min(1,Math.max(0,_e*(1+De)));const ye=N?.012:0;i[te]=Math.max(ye,Ke),s[te]=Math.max(ye,Be),a[te]=Math.max(ye,Math.max(0,Ze*(1-De))),c[te]=Math.max(ye,Math.max(0,Ze*(1+De))),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 al(e,n){for(const t of e.values()){Zi(t.left,n.left64),Zi(t.right,n.right64);for(let r=0;r<t.average.length;r++)t.average[r]=(t.left[r]+t.right[r])*.5}}function Zi(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 Zt={STOPPED:0,PLAYING:1,PAUSED:2};class Re{constructor(n,t,r){this.x=Number(n)||0,this.y=Number(t)||0,this.z=Number(r)||0}add(n){return new Re(this.x+n.x,this.y+n.y,this.z+n.z)}subtract(n){return new Re(this.x-n.x,this.y-n.y,this.z-n.z)}multiply(n){if(n!==null&&typeof n=="object")return new Re(this.x*n.x,this.y*n.y,this.z*n.z);const t=Number(n)||0;return new Re(this.x*t,this.y*t,this.z*t)}divide(n){const t=Number(n)||1;return new Re(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 Re(this.x,this.y,this.z)}toArray(){return[this.x,this.y,this.z]}}function cl(e,n,t){return new Re(e,n,t)}const ll=[{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"]]}],yr=3;function Ki(e=20260901){const n=ll,t=n.reduce((M,h)=>M+h.duration+yr,0),r={hasMedia:!1,state:Zt.STOPPED,title:"",artist:"",album:"",albumArtist:"",position:0,duration:0,hasThumbnail:!1,primaryColor:new Re(0,0,0),secondaryColor:new Re(0,0,0),tertiaryColor:new Re(0,0,0),textColor:new Re(1,1,1),highContrastColor:new Re(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+yr;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<yr){g=H,v=K,A=!0;break}h-=yr}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=Zt.PAUSED:A?r.state=Zt.STOPPED:R>.7&&R<.76?r.state=Zt.PAUSED:r.state=Zt.PLAYING,r.hasThumbnail=!A;const L=_.colors;r.primaryColor=new Re(L.primary[0],L.primary[1],L.primary[2]),r.secondaryColor=new Re(L.secondary[0],L.secondary[1],L.secondary[2]),r.tertiaryColor=new Re(L.tertiary[0],L.tertiary[1],L.tertiary[2]),r.textColor=new Re(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 Re(0,0,0):new Re(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=Zt.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:Zt,skipNext:p,skipPrevious:d,play:x,pause:y,playPause:m}}function ul(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 fl(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 dl(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 pl=Object.freeze(Object.defineProperty({__proto__:null,MEDIA_PLAYBACK:Zt,cloneMediaSnapshot:dl,createSimulatedMedia:Ki,diffMediaEvents:fl,mediaVec3:cl,renderThumbnail:ul},Symbol.toStringTag,{value:"Module"})),Qi=14,$n=[{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 Ji(){const e={app:"",title:"",url:"",index:-1};function n(t){const r=Number(t)||0,o=$n.length?Math.floor(r/Qi)%$n.length:0,i=$n[o]||$n[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:$n,hold:Qi}}function es(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 hl(e){const n=Ki(e),t=Ji(),r=es(null);return{media:n,windowTitle:t,shortcuts:r}}const ml=Object.freeze(Object.defineProperty({__proto__:null,createShortcutHandler:es,createSimulatedSystem:hl,createSimulatedWindowTitle:Ji},Symbol.toStringTag,{value:"Module"}));function gl(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 bl=Object.freeze(Object.defineProperty({__proto__:null,createPointerSource:gl},Symbol.toStringTag,{value:"Module"}));function ts(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=yn(h[0]),v=yn(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 yl(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=ts(l,n,t,r,i,s,a);if(f&&Math.abs(f.lx)<=.5&&Math.abs(f.ly)<=.5)return l}return null}const vl=Object.freeze(Object.defineProperty({__proto__:null,hitTestLayers:yl,worldToLayerLocal:ts},Symbol.toStringTag,{value:"Module"})),Ve=e=>e,He=Ve(Us),vr=Ve(Ks),Ye=Ve(la),Pt=Ve(pa),Ne=Ve(Xa),xl=Ve(Ya),wl=Ve(ec),sn=Ve(gc),jn=Ve(Fc),et=Ve(el),Ml=Ve(nl),xe=Ve(pl),ns=Ve(ml),rs=Ve(ja),_l=Ve(bl),Al=Ve(vl);function Tl(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 Sl(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 El(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 Pl(e,n){rn(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=Wt(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?Cl(e,n):Ll(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=Ne.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((V,X)=>{O.addEventListener("loadedmetadata",()=>V(),{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:Ne.makeTexture(m.gl,new Uint8Array([0,0,0,255]),1,1),width:v,height:A,rg88:!1,lastUploaded:-1}),e.paused||O.play().catch(()=>{}),El(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 V=await Sl(n.src);if(V&&V.frames.length>1){v=V.width,A=V.height;const X=m.gl,ie={glTex:Ne.makeTexture(X,null,0,0,V.frames[0].bitmap),width:v,height:A,rg88:!1};h.set(M,ie);let J=0,Z=performance.now()+V.frames[0].durationMs;g=()=>{const le=performance.now();if(!(le<Z)){J=(J+1)%V.frames.length,Z=le+V.frames[J].durationMs,X.bindTexture(X.TEXTURE_2D,ie.glTex);try{X.texImage2D(X.TEXTURE_2D,0,X.RGBA,X.RGBA,X.UNSIGNED_BYTE,V.frames[J].bitmap)}catch{}}};const te=e.sceneCleanup;e.sceneCleanup=()=>{te?.();for(const le of V.frames)le.bitmap.close()},O=!0,se(e,n,`media gif ${v}x${A} ${V.frames.length} \u5E27 \u2192 scene \u6E32\u67D3`)}}catch(V){se(e,n,`gif \u89E3\u7801\u5931\u8D25\uFF0C\u56DE\u9000\u9759\u6001\u9996\u5E27: ${String(V.message).slice(0,80)}`)}if(!O){const V=new Image;if(V.crossOrigin="anonymous",V.src=n.src,await new Promise((X,ie)=>{V.addEventListener("load",()=>X(),{once:!0}),V.addEventListener("error",()=>ie(new Error("image load error")),{once:!0})}),f)return;v=V.naturalWidth||1,A=V.naturalHeight||1,e.img=V,h.set(M,{glTex:Ne.makeTexture(m.gl,null,0,0,V),width:v,height:A,rg88:!1}),se(e,n,`media ${n.type} ${v}x${A} \u2192 scene \u6E32\u67D3`)}}if(f)return;const _=Tl(v,A,M),R=performance.now();let L=0,N=0,j=-1/0;const H=O=>{if(f||e.paused)return;const V=e.cfg.sceneFps||60;if(O-j>=1e3/V){j=O,An(e,O),To(e,s,e.cfg),g?.();const X=e.coverAlign;m.render(_,h,s.width,s.height,(O-R-L)/1e3,dn(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 Cl(e,n){if(rn(e),!n.src){e.fallbackPage?.();return}const t=Mo(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 Ll(e,n){rn(e);const t=document.createElement("img"),r=Mo(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 Rl=["scene.pkg","scenes/scene.pkg","gifscene.pkg"],kl={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 os(e){const n=e.toLowerCase().split(";")[0].trim();return n==="image/gif"?"gif":n.startsWith("video/")?"video":n.startsWith("image/")?"image":null}function lo(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:kl[o.slice(i+1).toLowerCase()]??null}async function Fl(e,n,t){try{const r=await fetch(e,{...n,method:"HEAD",signal:t});return r.ok?os(r.headers.get("content-type")||""):null}catch{return null}}function is(e,n){const t=e.replace(/\/+$/,"");return{key:t,async scenePkg(r){let o=null,i=null;for(const a of Rl){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 Nl(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 Ul(e,n,t){return{key:t,scenePkg:async()=>e,project:async()=>n??null}}function Dl(e,n){const t=typeof e!="string",r=e;let o=n?.type??(t?os(e.type||""):null)??lo(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 Fl(e,void 0,u)),{url:a(),type:o??void 0}},dispose(){s&&(URL.revokeObjectURL(s),s=null)}}}const ss=.5,Bl=.04,as=.08;function Il(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>ss+.5){(u||l)&&y();return}if(l){(v<=as||g<=as)&&x();return}if(u){o.paused?o.play().catch(()=>{}):o.currentTime>=Bl*.5&&(o.pause(),u=!1,l=!0);return}if(v<=ss&&(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 cs=!1,ls=!0,us=!1,Ol=!1,$l=!1,fs=4,zn=64,ds={STOPPED:0};function jl(){return{left64:new Float32Array(zn),right64:new Float32Array(zn),left32:new Float32Array(32),right32:new Float32Array(32),left16:new Float32Array(16),right16:new Float32Array(16),level:0,silent:!0}}function xr(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 zl(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<zn;c++){const u=c/zn,l=(c+1)/zn,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)}xr(e.left32,e.left64),xr(e.right32,e.right64),xr(e.left16,e.left64),xr(e.right16,e.right64),e.level=Math.min(1,a/(48*1.2)),e.silent=e.level<.02}function Wl(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 uo(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 Vl(e,n){const t=Wl(n||"empty"),[r,o,i]=uo(t,72,48),[s,a,c]=uo((t+40)%360,55,28),[u,l,f]=uo((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,f),e.textColor=xe.mediaVec3(.98,.98,1),e.highContrastColor=xe.mediaVec3(1,1,1),e.hasThumbnail=!!n}function Hl(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 Xl(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 Gl(){return{hasMedia:!1,state:ds.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 Yl(){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 ps(e){const n=e?.origin??(typeof location<"u"?location.origin:""),t=e?.onArtwork,r=jl(),o=Gl(),i={app:"",title:"",url:"",index:0};let s="off",a="offline",c="offline",u="",l=!1,f="";const p=await Yl();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=ds.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,Vl(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),zl(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 ql={"common.h":`// WE common.h\uFF08\u91CD\u5EFA\u5B50\u96C6\uFF0C\u4F9B we-scene \u6D4F\u89C8\u5668\u6E32\u67D3\uFF09
180
182
  #define M_PI 3.14159265359
181
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
182
184
  // \u5F71\u54CD\u5168\u5E93 142 \u4E2A\u6587\u4EF6\uFF0864 \u4E2A\u58C1\u7EB8\uFF09\u3002\u4E09\u6761\u72EC\u7ACB\u8BC1\u636E\uFF1A
@@ -507,6 +509,1212 @@ vec3 DecompressNormal(vec4 tex) {
507
509
  return vec3(xy, sqrt(clamp(1.0 - dot(xy, xy), 0.0, 1.0)));
508
510
  }
509
511
  `,"common_vertex.h":`// WE common_vertex.h\uFF08\u91CD\u5EFA\uFF1A\u7A7A\u5360\u4F4D\uFF0C\u89C1 headers.ts \u6CE8\u91CA\uFF09
510
- `};function xl(e){if(!e||e.length<12)return e;const n=e[0],t=e[1],o=e[2],r=e[3];if(!(n===0&&t===1&&o===0&&r===0)&&!(n===79&&t===84&&o===84&&r===79))return e;const c=Uint8Array.from(e),a=new DataView(c.buffer,c.byteOffset,c.byteLength),f=a.getUint16(4);if(f<=0||12+f*16>c.length)return e;let l=-1,d=0,h=0;for(let b=0;b<f;b++){const p=12+b*16;if(String.fromCharCode(c[p],c[p+1],c[p+2],c[p+3])==="cmap"){l=p,d=a.getUint32(p+8),h=a.getUint32(p+12);break}}if(l<0||d+h>c.length)return e;let m=!1;const M=a.getUint16(d+2);for(let b=0;b<M;b++){const p=d+4+b*8,v=a.getUint32(p+4),_=d+v;if(_+14>c.length||a.getUint16(_)!==4)continue;const w=a.getUint16(_+6),L=w>>>1;if(L<1)continue;const F=2*Math.pow(2,Math.floor(Math.log2(L))),D=Math.floor(Math.log2(L)),B=w-F,z=a.getUint16(_+8),V=a.getUint16(_+10),Y=a.getUint16(_+12);z===F&&V===D&&Y===B||(a.setUint16(_+8,F),a.setUint16(_+10,D),a.setUint16(_+12,B),m=!0)}if(!m)return e;let g=0;const y=d+h;for(let b=d;b<y;b+=4){const p=c[b]||0,v=b+1<y?c[b+1]:0,_=b+2<y?c[b+2]:0,w=b+3<y?c[b+3]:0;g=g+(p<<24|v<<16|_<<8|w)>>>0}return a.setUint32(l+4,g),c}const wl={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"},Zi=new Map,In=new Map;async function Ml(e,n,t,o){const r=t.key;if(r){const a=In.get(r);if(a)return a.at=Date.now(),re(e,n,`pkg cache hit: ${a.parsed.fileSize} bytes`),a.parsed}let i;try{i=await t.scenePkg(o)}catch(a){throw o.aborted||a instanceof Error?a:new Error(String(a))}re(e,n,`pkg body: ${i.byteLength} bytes`);const s=i instanceof Uint8Array?i:new Uint8Array(i),c=je.parsePkg(s);if(!r)return c;if(In.set(r,{parsed:c,at:Date.now()}),In.size>2){let a=null,f=1/0;for(const[l,d]of In)l!==r&&d.at<f&&(f=d.at,a=l);a&&In.delete(a)}return c}function Al(e,n){en(e);const t=n.canvas??document.createElement("canvas"),o=We(e,n),r=t.clientWidth||window.innerWidth||1,i=t.clientHeight||window.innerHeight||1;t.width=Math.max(1,Math.round(r*o)),t.height=Math.max(1,Math.round(i*o)),n.canvas||(t.style.cssText="position:absolute;inset:0;width:100%;height:100%;",e.wrap?.appendChild(t)),e.canvas=t;let s=!1;const c=new AbortController;let a;e.sceneCleanup=()=>{s=!0,c.abort(),e.sceneTextUpdate=void 0,a&&(a(),a=void 0),e.renderer&&(e.renderer.dispose?.(),e.renderer=void 0)};let f=null,l,d,h;e.sceneCtl={pause(){d?.()},resume(){h?.()},applyUserProperties(m){l?l(m):f={...f||{},...m}}},(async()=>{try{const m=n.source??ji(`${n.mediaBase}/${n.src}`);if(!n.source&&(!n.mediaBase||!n.src))throw new Error("\u573A\u666F\u58C1\u7EB8\u7F3A\u5C11 mediaBase/src");re(e,n,"mountScene start");const M=await Ml(e,n,m,c.signal);if(s)return;let g=null;try{g=await m.project?.(c.signal)??null}catch{}if(!t.getContext("webgl2",{premultipliedAlpha:!1,antialias:!1,alpha:!1,preserveDrawingBuffer:!0}))throw new Error("WEBGL2_UNAVAILABLE");const b=je.getEntry(M,"scene.json");if(!b)throw new Error("pkg \u4E2D\u6CA1\u6709 scene.json\uFF08\u4E0D\u662F\u573A\u666F\u58C1\u7EB8\uFF1F\uFF09");const p=Qe.parseScene(JSON.parse(ct(b)),g);{const T=p.general?.zoom,u=Number(T&&typeof T=="object"?T.value:T);p.cameraTransforms={zoom:Number.isFinite(u)&&u>0?u:1}}const v=Ps(p.properties||{});e.liveUserProps=v;const _=()=>Qe.recomputeLayerVisibility(p.layers);if(e.onSceneInfo){const T=p.general?.orthogonalprojection||{},u=Number(T.width)>0?Number(T.width):t.width,x=Number(T.height)>0?Number(T.height):t.height,S=p.layers||[],P={width:u,height:x,layerCount:S.length,hasModels:S.some(N=>!!N.model),hasParticles:S.some(N=>!!N.particle),hasText:S.some(N=>!!N.text)},I=e.onSceneInfo;e.onSceneInfo=void 0,I(P)}const w=[];Xi&&(p.layers=p.layers.filter(T=>!(Xi&&T.isComponent)));const L=T=>{const u=T.startsWith("shaders/")?T:"shaders/"+T,x=T.startsWith("shaders/")?T.slice(8):T,S=je.getEntry(M,u);let P=S?ct(S):vl[x]??null;const I=window.__shaderPatch;if(P&&I){const N=x.replace(/\.(frag|vert|h)$/,""),E=I[N]||I[x];if(typeof E=="function")try{const $=E(P,x);typeof $=="string"&&(P=$)}catch{}}return Promise.resolve(P)},F=Be.createRenderer(t,{shaderResolver:L,diag:T=>re(e,n,`renderer: ${T}`),fboCapFactor:0});if(e.renderer=F,s)return;const D=g?.general?.supportsaudioprocessing!==!1,B=Nc(),z=ve.createSimulatedMedia(),V=$i.createSimulatedWindowTitle();let Y=null;const Z={mediaDriver:null,lastSnap:{get:()=>null,setHasThumbnail:()=>{}}},X={current:null};let q=z,oe=V;const H={enabled:D},j=T=>new Float32Array(T),ee={left16:j(16),right16:j(16),left32:j(32),right32:j(32),left64:j(64),right64:j(64),level:0,silent:!0};F.setAudioProvider(()=>H.enabled?X.current?X.current.snapshot:B.snapshot:ee);const le=new Map;window.__audioStats=()=>({enabled:H.enabled,live:!!X.current,level:H.enabled?Math.round((X.current?X.current.snapshot:B.snapshot).level*1e3)/1e3:0,silent:H.enabled?(X.current?X.current.snapshot:B.snapshot).silent:!0,bass:H.enabled?Math.round((X.current?X.current.snapshot:B.snapshot).left64[2]*1e3)/1e3:0}),window.__audioMute=T=>(H.enabled=!T,H.enabled),re(e,n,`audio: ${X.current?"live mic":"simulated"} stream, supportsaudioprocessing=${D}`);const Se=$i.createShortcutHandler(T=>{re(e,n,`openUserShortcut: ${T}`)}),Xe={enabled:!0,override:null},Le=[];let Pe=null;Z.lastSnap={get:()=>Pe,setHasThumbnail:T=>{Pe&&(Pe.hasThumbnail=T)}};const ue=()=>q.snapshot,Fe=T=>{if(!(!T||!T.hasMediaHook||Le.includes(T))&&(Le.push(T),!!ue().hasMedia))for(const{name:u,event:x}of ve.diffMediaEvents(null,ue()))try{T.callMedia(u,x)}catch{}};window.__mediaStats=()=>({enabled:Xe.enabled,live:!!Y,hooks:Le.length,title:ue().title,artist:ue().artist,album:ue().album,state:ue().state,position:Math.round(ue().position),duration:ue().duration,hasThumbnail:ue().hasThumbnail,lyric:ue().lyricLine,primaryColor:ue().primaryColor?[ue().primaryColor.x,ue().primaryColor.y,ue().primaryColor.z]:null}),window.__mediaSet=T=>{Object.assign(ue(),T||{});const u=ve.diffMediaEvents(Pe,ue());for(const{name:x,event:S}of u)for(const P of Le)P.callMedia(x,S);return Pe=ve.cloneMediaSnapshot(ue()),window.__mediaStats()};const Je=()=>{const T=ve.diffMediaEvents(Pe,ue());for(const{name:u,event:x}of T)for(const S of Le)try{S.callMedia(u,x)}catch{}Pe=ve.cloneMediaSnapshot(ue())},Ee={get snapshot(){return ue()},skipNext:()=>(q.skipNext(),Je(),ue()),skipPrevious:()=>(q.skipPrevious(),Je(),ue()),play:()=>(q.play(),Je(),ue()),pause:()=>(q.pause(),Je(),ue()),playPause:()=>(q.playPause(),Je(),ue())};window.__mediaControl=Ee,window.__system={media:Ee,windowTitle:oe.snapshot,shortcuts:Se.last,live:null},window.__liveSystem=()=>({audio:"off",media:"offline",window:"offline"});const xe=Zc.createPointerSource(n.canvas?{target:n.canvas,viewport:()=>({w:n.canvas.clientWidth||window.innerWidth||1,h:n.canvas.clientHeight||window.innerHeight||1})}:{});F.setPointerProvider(()=>xe);{const T=a;a=()=>{T?.(),xe.dispose()}}const Ne=He.createInputView(),we=qc.createEngineTimers({setTimeout:(T,u)=>window.setTimeout(T,u),clearTimeout:T=>window.clearTimeout(T),setInterval:(T,u)=>window.setInterval(T,u),clearInterval:T=>window.clearInterval(T)},{onError:(()=>{let T=!1;return u=>{T||(T=!0,re(e,n,`engine \u5B9A\u65F6\u5668\u56DE\u8C03\u629B\u9519\uFF08\u6B64\u540E\u540C\u7C7B\u9759\u9ED8\uFF09: ${String(u?.message||u).slice(0,90)}`))}})()}),Ge={setTimeout:we.setTimeout,clearTimeout:we.clearTimeout,setInterval:we.setInterval,clearInterval:we.clearInterval};{const T=a;a=()=>{T?.(),we.dispose()}}window.__pointerStats=()=>{const T=xe.state,u=x=>Math.round(x*1e3)/1e3;return{normalized:{u:u(T.u),v:u(T.v)},last:{u:u(T.lastU),v:u(T.lastV)},world:{x:Math.round(T.wx),y:Math.round(T.wy)},originY:T.originY!=null?Math.round(T.originY):null,screen:{x:T.screenX,y:T.screenY,w:T.screenW,h:T.screenH},leftDown:T.leftDown,has:T.has,delta:u(xe.normalizedDelta()),counts:{move:T.moveCount,down:T.downCount,up:T.upCount}}};const fe=new Map;fe.set("util/white",{glTex:Be.makeTexture(F.gl,new Uint8Array([255,255,255,255]),1,1),width:1,height:1,rg88:!1}),fe.set("util/noflow",{glTex:Be.makeTexture(F.gl,new Uint8Array([127,127,127,255]),1,1),width:1,height:1,rg88:!1}),fe.set("util/noise",{glTex:Be.makeTexture(F.gl,Gc.generateNoiseTexture(),256,256),width:256,height:256,rg88:!1,mips:null});{const T=x=>{const S=ve.renderThumbnail(x,512);return{glTex:Be.makeTextureMip(F.gl,[S],!1),width:S.width,height:S.height,rg88:!1,mips:[S],generated:!0}},u=z.tracks||[];u.length&&(fe.set("$mediaThumbnail",T(u[0])),fe.set("$mediaPreviousThumbnail",T(u[u.length-1])))}if(n.liveSystem)try{const T=async x=>{try{const S=await fetch(x.url,{cache:"no-store"});if(!S.ok)return;const P=await S.blob(),I=await createImageBitmap(P),N=pl(I,I.width,I.height,512),E=ml(I,I.width,I.height);I.close?.();const $=fe.get("$mediaThumbnail");$&&fe.set("$mediaPreviousThumbnail",$);const A=F.gl,R=fe.get("$mediaThumbnail");R?.glTex?(A.bindTexture(A.TEXTURE_2D,R.glTex),A.texImage2D(A.TEXTURE_2D,0,A.RGBA,N.width,N.height,0,A.RGBA,A.UNSIGNED_BYTE,N.rgba),R.width=N.width,R.height=N.height,R.mips=[N]):fe.set("$mediaThumbnail",{glTex:Be.makeTextureMip(A,[N],!1),width:N.width,height:N.height,rg88:!1,mips:[N],generated:!0});const C=q.snapshot;E&&(C.primaryColor=ve.mediaVec3(...E.primary),C.secondaryColor=ve.mediaVec3(...E.secondary),C.tertiaryColor=ve.mediaVec3(...E.tertiary),C.textColor=ve.mediaVec3(.98,.98,1),C.highContrastColor=ve.mediaVec3(1,1,1)),C.hasThumbnail=!0,Z.lastSnap.setHasThumbnail(!1),re(e,n,`liveSystem: artwork ${x.title||x.trackKey}`)}catch(S){re(e,n,`liveSystem: artwork \u5931\u8D25 (${S instanceof Error?S.message:S})`)}};if(Y=await yl({origin:location.origin,onArtwork:x=>{T(x)}}),q=Y.media,oe=Y.windowTitle,Z.mediaDriver=Y.media,Y.status().audio==="mic"&&(X.current=Y.audio),q.snapshot.hasMedia){for(const{name:x,event:S}of ve.diffMediaEvents(null,q.snapshot))for(const P of Le)try{P.callMedia(x,S)}catch{}Pe=ve.cloneMediaSnapshot(q.snapshot)}const u=Y.status();re(e,n,`liveSystem: audio=${u.audio} media=${u.media} window=${u.window}`+(u.title?` title="${u.title}"`:"")+(u.hasArtwork?" artwork=1":"")),re(e,n,`audio: ${X.current?"live mic":"simulated"} stream, supportsaudioprocessing=${D}`),window.__system={media:Ee,windowTitle:oe.snapshot,shortcuts:Se.last,live:()=>Y.status()},window.__liveSystem=()=>Y.status()}catch(T){re(e,n,`liveSystem: \u542F\u52A8\u5931\u8D25\uFF0C\u56DE\u9000\u6A21\u62DF\u6E90 (${T instanceof Error?T.message:T})`),Y=null}{const T=a;a=()=>{T?.(),Y?.dispose(),Y=null}}const Ye=new Map,$t=async T=>{if(fe.has(T))return fe.get(T);const u=je.getEntry(M,`materials/${T}.tex`);if(!u){if(Yt.isBuiltinParticleTextureName(T)){const N=Yt.buildBuiltinParticleTexture(T);if(N){const E={glTex:Be.makeTextureMip(F.gl,[N],!1),width:N.width,height:N.height,rg88:!1,mips:[N],generated:!0};return fe.set(T,E),E}}return null}const x=dr.parseTex(u),S=dr.decodeMip0(x),P=x.format===8;let I=null;if(S.video!==void 0){const N=URL.createObjectURL(new Blob([S.video],{type:"video/mp4"})),E=al(N,{muted:!0,renderDpr:We(e,n),maxW:t.clientWidth||window.innerWidth||1,maxH:t.clientHeight||window.innerHeight||1});for(const U of[E.active,E.standby])U.style.cssText="position:fixed;left:-9999px;top:-9999px;width:2px;height:2px;opacity:0;pointer-events:none",document.body.appendChild(U),(e.videoTextures??=[]).push(U);(e.objectUrls??=[]).push(N),(e.videoPairs??=[]).push(E),E.active.addEventListener("loadedmetadata",()=>{re(e,n,`video tex '${T}': ${E.active.videoWidth}x${E.active.videoHeight}`)}),E.active.addEventListener("error",()=>{re(e,n,`video tex '${T}' ERROR: ${E.active.error?.code}`)});const $=[],A=U=>{for(const W of $)U.addEventListener("ended",W)},R={play:()=>{s||E.resume()},pause:()=>E.pause(),stop:()=>{E.pause();try{E.active.currentTime=0}catch{}},isPlaying:()=>!E.active.paused&&!E.active.ended,duration:()=>Number.isFinite(E.active.duration)?E.active.duration:0,getCurrentTime:()=>E.active.currentTime||0,setCurrentTime:U=>{try{E.active.currentTime=U}catch{}},getRate:()=>E.active.playbackRate||1,setRate:U=>{E.active.playbackRate=U,E.standby.playbackRate=U},getLoop:()=>E.active.loop,setLoop:U=>{E.active.loop=U,E.standby.loop=U},addEndedCallback:U=>{$.push(U),E.active.addEventListener("ended",U)}},C={get video(){return E.active},glTex:Be.makeTexture(F.gl,new Uint8Array([0,0,0,0]),1,1),width:S.width,height:S.height,rg88:!1,lastUploaded:-1,videoCtl:R};let k=0;return E.onSwap=U=>{C.lastUploaded=-1,A(U),k++,(k===1||k===10||k===100)&&re(e,n,`video tex '${T}' loop swap ok x${k}`)},E.onFallback=()=>{re(e,n,`video tex '${T}' loop fallback (native loop used)`)},fe.set(T,C),C}else if(S.png!==void 0||S.image!==void 0&&S.fif===dr.FIF.JPEG){const N=new Blob([S.png||S.image],{type:S.png?"image/png":"image/jpeg"}),E=await createImageBitmap(N);I={glTex:Be.makeTexture(F.gl,null,0,0,E),width:E.width,height:E.height,rg88:P}}else{if(S.image!==void 0)return null;{const N=dr.decodeMip0(x);I={glTex:Be.makeTextureMip(F.gl,[N],P),width:N.width,height:N.height,rg88:P,mips:[N]}}}if(!I)return null;if(x.frames?.list?.length){const N=x.frames.list;N.atlasWidth=I.width,N.atlasHeight=I.height,I.frames=N}return fe.set(T,I),I},et=T=>{if(fe.has(T))return Promise.resolve(fe.get(T));const u=Ye.get(T);if(u)return u;const x=$t(T);return Ye.set(T,x),x.finally(()=>{Ye.get(T)===x&&Ye.delete(T)}),x},qt=/uniform\s+sampler2D\s+g_Texture\d+\s*;\s*\/\/[^\n]*"default"\s*:\s*"([^"]+)"/g,pr=async T=>{for(const u of T.materialPasses||[])if(u.shader)for(const x of["frag","vert"]){const S=je.getEntry(M,`shaders/${u.shader}.${x}`);if(!S)continue;const P=ct(S);qt.lastIndex=0;let I;for(;(I=qt.exec(P))!==null;){const N=I[1];!N||N.startsWith("util/")||N.startsWith("_rt_")||fe.has(N)||await et(N)}}};let Bn=0;const Zt=[];for(let T=0;T<p.layers.length;T++){const u=p.layers[T];if(u.image)try{let x;if(vt.BUILTIN_MODELS[u.image])x=vt.BUILTIN_MODELS[u.image];else{const C=je.getEntry(M,u.image);if(!C)continue;x=JSON.parse(ct(C))}Qe.applySolidFromModel(u,x);const S=u.srcObject?.instance?.usertextures,P=S?.[0]&&typeof S[0].name=="string"&&S[0].name.startsWith("$")?S[0].name:null,I=P&&fe.has(P)?P:null;if(I&&(u.textureName=I,u.solid=!1),x&&typeof x=="object"&&"width"in x&&"height"in x){const C=x;(u.size?.[0]||0)===0&&(u.size?.[1]||0)===0&&C.width>0&&C.height>0&&(u.size=[C.width,C.height])}const N=Qe.resolveMaterial(x);if(!N)continue;let E;if(vt.BUILTIN_MATERIALS[N.materialPath])E=vt.BUILTIN_MATERIALS[N.materialPath];else{const C=je.getEntry(M,N.materialPath);if(C)E=JSON.parse(ct(C));else if(u.solid&&vt.BUILTIN_MATERIALS["materials/util/solidlayer.json"])E=vt.BUILTIN_MATERIALS["materials/util/solidlayer.json"];else continue}const $=E.passes?.[0],A=$?.textures||[],R=A[0];if($?.combos){for(const C of Object.keys($.combos))if(C.toLowerCase()==="spritesheet"&&Number($.combos[C])===1){u.spriteSheet=!0;break}}for(let C=0;C<A.length;C++){const k=A[C];typeof k!="string"||!k||k.startsWith("util/")||k.startsWith("_rt_")||Zt.push(et(k).then(U=>{U&&C===0&&!I&&(u.textureName=k,Bn++,U.videoCtl&&(u.videoCtl=U.videoCtl))}))}$?.shader&&je.getEntry(M,`shaders/${$.shader}.frag`)&&vt.attachLayerMaterialEffect(u,$);for(const C of u.effects||[])vt.resolveEffectChain(M,C,ct);for(const C of u.effects||[]){for(const k of C.passes||[])for(const U of k.textures||[])typeof U=="string"&&U!==""&&!U.startsWith("util/")&&!U.startsWith("_rt_")&&Zt.push(et(U));Zt.push(pr(C))}}catch(x){console.warn(`\u56FE\u5C42 ${u.name||T} \u52A0\u8F7D\u5931\u8D25: ${x.message}`)}}if(!Gi){for(const T of p.layers)if(!(!T.isText||!(T.effects||[]).length))try{for(const u of T.effects||[])vt.resolveEffectChain(M,u,ct);for(const u of T.effects||[])for(const x of u.passes||[])for(const S of x.textures||[])typeof S=="string"&&S!==""&&!S.startsWith("util/")&&!S.startsWith("_rt_")&&Zt.push(et(S))}catch(u){console.warn(`\u6587\u5B57\u5C42\u6548\u679C ${T.name} \u89E3\u6790\u5931\u8D25: ${u.message}`)}}await Promise.all(Zt);for(const[T,u]of fe){if(!u?.videoCtl)continue;p.layers.some(S=>S.textureName===T&&S.visible&&!S.destroyed)&&!e.paused&&u.videoCtl.play()}const qe=[],zt=new Map;let ye=0;const ln=async T=>{const u=await et(T);if(u)return u;const x=Yt.buildBuiltinParticleTexture(T);if(!x)return null;const S={glTex:Be.makeTextureMip(F.gl,[x],!1),width:x.width,height:x.height,rg88:!1,mips:[x],generated:!0,frames:Yt.builtinParticleFrames(T)??void 0};return fe.set(T,S),ye++,S},gr=T=>{if(!T)return null;const u=T.mips&&T.mips[0];if(u?.rgba&&typeof Yt.prepareParticleNormalTexture=="function"){const x=Yt.prepareParticleNormalTexture(u);if(x&&x!==u)return{glTex:Be.makeTextureMip(F.gl,[x],!1),width:x.width,height:x.height,rg88:!1,mips:[x],generated:!0}}return T},br=async(T,u,x,S)=>{if(S>3)return null;const P=je.getEntry(M,T);if(!P)return re(e,n,`particle '${T}' \u4E0D\u5728 pkg\uFF0C\u8DF3\u8FC7`),null;const I=JSON.parse(ct(P)),N=new Yc.ParticleSystem(F.gl,I,x,u);let E=null,$=null;if(I.material){const k=je.getEntry(M,I.material);if(k){const U=JSON.parse(ct(k));N.setMaterial(U);const W=U?.passes?.[0]?.textures||[];E=W[0]||null,$=W[1]||null}}const A=await ln(E||"particle/halo");if(!A)return re(e,n,`particle '${T}' \u65E0\u8D34\u56FE\u53EF\u7528\uFF0C\u8DF3\u8FC7`),null;N.setTexture({glTex:A.glTex,width:A.width,height:A.height,frames:A.frames});const R=$||(N.refract?Yt.particleNormalNameForAlbedo(E||"particle/halo"):null);if(R){const k=gr(await ln(R));k&&N.setNormalTexture({glTex:k.glTex,width:k.width,height:k.height})}N.setVisible(!!u.visible),qe.push(N);const C=u.id;if(C!==void 0){let k=zt.get(C);k||(k=[],zt.set(C,k)),k.push(N)}for(const k of I.children||[]){if(!k||typeof k.name!="string")continue;const U=String(k.origin??"0 0 0").trim().split(/\s+/).map(Number),W=String(k.scale??"1 1 1").trim().split(/\s+/).map(Number),J=String(k.angles??"0 0 0").trim().split(/\s+/).map(Number),Q=k.type==="eventfollow"?"particle":!k.type||k.type==="static"?"origin":null,te=N.localToWorld(U[0]||0,U[1]||0),O={...u,origin:[te[0],te[1],(u.origin?.[2]||0)+(U[2]||0)],scale:[(u.scale?.[0]??1)*(W[0]||1),(u.scale?.[1]??1)*(W[1]||1),(u.scale?.[2]??1)*(W[2]||1)],angles:[(u.angles?.[0]||0)+(J[0]||0),(u.angles?.[1]||0)+(J[1]||0),(u.angles?.[2]||0)+(J[2]||0)]},K=await br(k.name,O,k.instanceoverride||x,S+1);K&&Q&&K.attachFollow(N,Q,[U[0]||0,U[1]||0,U[2]||0])}return N};if(!cl){for(const T of p.layers)if(T.particle)try{await br(T.particle,T,T.instanceoverride,0)}catch(u){console.warn(`\u7C92\u5B50\u56FE\u5C42 ${T.name} \u52A0\u8F7D\u5931\u8D25: ${u.message}`),re(e,n,`particle '${T.name}' FAIL: ${u.message.slice(0,80)}`)}}if(qe.length>0){const T=a;a=()=>{T?.();for(const u of qe)u.dispose()}}const un=[];for(const T of p.layers)if(!(!T.sound||!T.sound.length))try{for(const u of T.sound){const x=je.getEntry(M,u);if(!x)continue;const S=(u.split(".").pop()||"").toLowerCase(),P=S==="mp3"?"audio/mpeg":S==="ogg"?"audio/ogg":S==="flac"?"audio/flac":"audio/wav",I=new Blob([x],{type:P}),N=URL.createObjectURL(I);(e.objectUrls??=[]).push(N);const E=document.createElement("audio");E.src=N,E.loop=T.soundprops?.playbackmode==="loop",E.volume=Math.max(0,Math.min(1,T.soundprops?.volume??1)),E.muted=n.muted!==!1,T.soundCtl={play(){if(E.ended)try{E.currentTime=0}catch{}E.play().catch(()=>{})},pause(){E.pause()},stop(){E.pause();try{E.currentTime=0}catch{}},isPlaying:()=>!E.paused&&!E.ended,getVolume:()=>E.volume,setVolume:$=>{E.volume=Math.max(0,Math.min(1,$))}},!T.soundprops?.startsilent&&!e.paused&&E.play().catch(()=>{}),un.push(E);break}}catch(u){console.warn(`\u58F0\u97F3\u56FE\u5C42 ${T.name} \u52A0\u8F7D\u5931\u8D25: ${u.message}`)}const so=T=>{for(const u of un)u.volume=Math.max(0,Math.min(1,T)),u.muted=T<=0};if(e.sceneAudio={setVolume:so,audios:un},s)return;let On=performance.now(),Dn=0;F.setParticleRenderer(()=>{const T=performance.now(),u=Math.min(.05,(T-On)/1e3);if(On=T,xe.state.has){const{wx:x,wy:S,originY:P}=xe.state,I=P??S;for(const N of qe)N.setPointer(x,I)}for(const x of qe)x.advance(u,H.enabled?B.snapshot:null);if(Dn<2&&(Dn++,Dn===2)){const x=qe.reduce((S,P)=>S+P.liveCount(),0);re(e,n,`particles live: ${x} across ${qe.length} systems`)}},(T,u,x,S,P)=>{if(T===void 0)return;const I=zt.get(T);if(I)for(const N of I)N.render(x,S,P,u.projW,u.projH)}),re(e,n,`particles: ${qe.length} systems, ${ye} builtin tex generated`),window.__particleStats=()=>qe.map(T=>{let u=0,x=1/0,S=-1/0,P=1/0,I=-1/0,N=1/0,E=-1/0;for(const $ of T.pool){if(!$.alive)continue;u++;const A=T.originX+$.x*T.scaleX,R=T.originY+$.y*T.scaleY;A<x&&(x=A),A>S&&(S=A),R<P&&(P=R),R>I&&(I=R);const C=Math.abs($.size)*T.sysScale;C<N&&(N=C),C>E&&(E=C)}return{live:u,max:T.maxCount,blend:T.blend,renderer:T.renderers.map($=>$.kind).join("+"),origin:[Math.round(T.originX),Math.round(T.originY)],bbox:u?[Math.round(x),Math.round(P),Math.round(S),Math.round(I)]:null,size:u?[Math.round(N),Math.round(E)]:null}}),window.__particleToggle=(T,u)=>{for(let x=0;x<qe.length;x++)qe[x].setVisible(u===void 0?T:x===u);return qe.length};const Ct=[],$n=new Map,fn=T=>{if(!T||!T.puppet)return null;let u=$n.get(T);return u||(u=new Map,$n.set(T,u)),u};for(const T of p.layers)if(T.image)try{if(vt.BUILTIN_MODELS[T.image])continue;const u=je.getEntry(M,T.image);if(!u)continue;const x=JSON.parse(ct(u));if(!x.puppet)continue;const S=je.getEntry(M,x.puppet);if(!S)continue;const P=kn.parseMDL(new Uint8Array(S)),I=T.textureName?fe.get(T.textureName):null;if(!I){re(e,n,`puppet '${T.name}' \u65E0\u8D34\u56FE\uFF0C\u8DF3\u8FC7`);continue}T.puppet=P,Ct.push({mdl:P,tex:I,layer:T});const N=P.animations[0];re(e,n,`puppet '${T.name}' v=${P.vertexCount} bones=${P.bones.length}`+(N?` anim='${N.name}' ${N.fps}fps\xD7${N.frameCount}`:" \u65E0\u52A8\u753B"))}catch(u){console.warn(`puppet \u56FE\u5C42 ${T.name} \u52A0\u8F7D\u5931\u8D25: ${u.message}`),re(e,n,`puppet '${T.name}' \u5931\u8D25: ${u.message}`)}for(const T of p.layers)if(T.model&&!T.puppet)try{const u=je.getEntry(M,T.model);if(!u)continue;const x=kn.parseMDL(new Uint8Array(u));let S=null;if(x.materialPath){const I=je.getEntry(M,x.materialPath);if(I){const E=JSON.parse(ct(I))?.passes?.[0]?.textures?.[0];typeof E=="string"&&E&&(S=E)}}S&&(await et(S),T.textureName=S);const P=S?fe.get(S):null;if(!P){re(e,n,`model '${T.name}' \u65E0\u8D34\u56FE\uFF0C\u8DF3\u8FC7`);continue}T.puppet=x,Ct.push({mdl:x,tex:P,layer:T}),re(e,n,`model '${T.name}' v=${x.vertexCount} static ${x.materialPath||""}`)}catch(u){console.warn(`model \u56FE\u5C42 ${T.name} \u52A0\u8F7D\u5931\u8D25: ${u.message}`),re(e,n,`model '${T.name}' \u5931\u8D25: ${u.message}`)}let dn=null;if(Ct.length>0)try{dn=kn.createMDLRenderer(F.gl);for(const u of Ct)dn.upload(u.mdl);const T=new Map;for(const u of Ct)T.set(u.layer,u);F.setPuppetRenderer((u,x,S)=>{const P=T.get(u);P&&dn.draw(x,P.mdl,{time:S.time,animLayers:u.animationLayers,boneOverrides:$n.get(u),overrideTex:S.overrideTex||null,color:[u.color[0]*u.brightness,u.color[1]*u.brightness,u.color[2]*u.brightness,u.alpha]},P.tex)})}catch(T){console.warn(`puppet \u6E32\u67D3\u5668\u521D\u59CB\u5316\u5931\u8D25: ${T.message}`),re(e,n,`puppet renderer \u5931\u8D25: ${T.message}`),dn=null;for(const u of Ct)u.layer.puppet=null}if(s)return;re(e,n,`puppet: ${Ct.length} meshes`);const Kt=kn.applyAttachmentBindOrigins(p.layers);Kt.length&&re(e,n,`attachments: ${Kt.length} hanging layers`);const it=[],Rt=new Map,st={};let pe=null,xt=null,zn=0;if(!Gi&&p.layers.some(T=>T.isText)){const T=p.general?.orthogonalprojection,u=T?.width||t.width,x=T?.height||t.height,S=Nr(Xt(e.cfg.fit),u,x,t.width,t.height),P=Math.min(3,Math.max(.5,t.width/Math.max(1,S.viewW))),I=new Map,N=new Set;for(const A of p.layers)A.isText&&A.textFont&&N.add(A.textFont);for(const A of M.entries||[])typeof A.name=="string"&&/^fonts\/.+\.(ttf|otf|woff2?)$/i.test(A.name)&&N.add(A.name);for(const A of N){const R=Zi.get(`${n.src}|${A}`);if(R){I.set(A,R);continue}const C=wl[A.toLowerCase()];if(C){I.set(A,C);continue}try{const k=je.getEntry(M,A);if(!k)continue;const U=xl(k instanceof Uint8Array?k:new Uint8Array(k)),W="wefont_"+A.split("/").pop().replace(/[^a-zA-Z0-9]/g,"_"),J=URL.createObjectURL(new Blob([U])),Q=new FontFace(W,`url(${J})`);await Q.load(),document.fonts.add(Q),(e.objectUrls??=[]).push(J),I.set(A,W),Zi.set(`${n.src}|${A}`,W)}catch(k){console.warn(`\u5B57\u4F53\u52A0\u8F7D\u5931\u8D25 ${A}: ${k.message}`)}}pe=document.createElement("canvas"),xt=pe.getContext("2d");const E=2048;for(const A of p.layers)if(A.isText)try{const R={layer:A,sandbox:null,texName:"__wstext_"+A.id,entry:null,lastKey:null,quality:P};if(A.textScript&&(R.sandbox=He.evalTextScript(A.textScript,A.textScriptProps,{text:A.text??"",font:A.textFont||"",pointsize:A.textPointsize,color:A.textColor,angles:A.angles,origin:A.origin,scale:A.scale,visible:A.visible,canvasSize:{width:u,height:x},userProperties:v,shared:st,audioViews:le,inputView:Ne,...Ge,mediaControl:Ee,windowTitle:oe.snapshot,openUserShortcut:Se.openUserShortcut,getLayerText:W=>Rt.get(W),onError:W=>{re(e,n,`text script '${A.name}' \u5931\u8D25: ${String(W.message||W).slice(0,120)}`)}}),R.sandbox&&(w.push(R.sandbox),R.sandbox.init(),R.sandbox.applyUserProperties(v),R.sandbox.hasMediaHook&&Fe(R.sandbox))),Rt.set(A.name||"",String(A.text??"")),A.textAnchor!=="center"&&A.size[0]>0&&A.size[1]>0){const W=A.size[0]*(A.scale[0]||1)/2,J=A.size[1]*(A.scale[1]||1)/2,Q=A.textAnchor;Q.includes("left")&&(A.origin[0]+=W),Q.includes("right")&&(A.origin[0]-=W),Q.includes("top")&&(A.origin[1]-=J),Q.includes("bottom")&&(A.origin[1]+=J)}const C=Yi*Math.max(1,A.textPointsize),k=He.textLayerHasTintMask(A)?8:256,U=Math.min(k,He.textCanvasMargin(C,0));R.boxW=A.size[0]>0?A.size[0]:C*4,R.boxH=A.size[1]>0?A.size[1]:C*1.6,R.margin=U,A.size=[R.boxW+U*2,R.boxH+U*2],R.entry={glTex:Be.makeTexture(F.gl,new Uint8Array([0,0,0,0]),1,1),width:1,height:1,rg88:!1},fe.set(R.texName,R.entry),A.textureName=R.texName,A.solid=!1,it.push(R)}catch(R){console.warn(`\u6587\u5B57\u5BF9\u8C61 ${A.name} \u521D\u59CB\u5316\u5931\u8D25: ${R.message}`)}if(it.length>0){const A=a;a=()=>{A?.();for(const R of it)F.gl.deleteTexture(R.entry.glTex)}}const $=A=>{if(!xt||!pe)return;const R=xt;for(const C of it){const k=C.layer;let U=String(k.text??"");if(C.sandbox&&C.sandbox.hasUpdate){C.sandbox.engine.runtime=A;const te=C.sandbox.callUpdate(U);te!=null?U=String(te):C.sandbox.thisLayer.text&&(U=String(C.sandbox.thisLayer.text))}else C.sandbox&&typeof C.sandbox.thisLayer?.text=="string"&&(U=String(C.sandbox.thisLayer.text));if(Rt.set(k.name||"",U),!k.visible)continue;const W=Math.max(1,C.sandbox?C.sandbox.thisLayer.pointsize:k.textPointsize),J=C.sandbox&&C.sandbox.thisLayer.font||k.textFont||"",Q=`${U}\0${W}\0${J}\0${k.alpha}\0${k.textCastshadow}`;if(C.lastKey!==Q){C.lastKey=Q;try{const te=Yi*W,O=C.boxW,K=C.boxH,se=C.margin,ge=Math.abs(k.scale[0]||1),Me=Math.abs(k.scale[1]||1);let ie=Math.max(1,Math.round(k.size[0]*ge*C.quality)),Ae=Math.max(1,Math.round(k.size[1]*Me*C.quality));const _e=Math.min(1,E/Math.max(ie,Ae));ie=Math.max(1,Math.round(ie*_e)),Ae=Math.max(1,Math.round(Ae*_e)),pe.width!==ie||pe.height!==Ae?(pe.width=ie,pe.height=Ae):(R.setTransform(1,0,0,1,0,0),R.clearRect(0,0,ie,Ae));const Ze=Math.min(ie/k.size[0],Ae/k.size[1]);R.setTransform(Ze,0,0,Ze,0,0),R.translate(se,se);const Mt=J&&I.get(J)||"sans-serif";R.font=`${te}px "${Mt}", sans-serif`;const at=R.measureText(""),At=(at.fontBoundingBoxAscent||0)+(at.fontBoundingBoxDescent||0),nt=k.textSpacing||[0,0],ae=He.layoutText(U,{boxW:O,boxH:K,pointsize:te,lineHeight:(At>0?At:te*1.25)+nt[1],spacing:nt,padding:k.textPadding||0,maxwidth:k.textMaxwidth||0,limitwidth:!!k.textLimitwidth,maxrows:k.textMaxrows||0,limitrows:!!k.textLimitrows,limituseellipsis:!!k.textLimituseellipsis,halign:k.textHAlign,valign:k.textVAlign},ce=>R.measureText(ce).width);He.drawTextLayer(R,ae,{font:R.font,color:k.textColor,alpha:k.alpha,brightness:k.brightness,spacing:nt,pointsize:te,opaquebackground:!!k.textOpaquebackground,backgroundcolor:k.textBackgroundcolor,backgroundbrightness:k.textBackgroundbrightness,castshadow:!!k.textCastshadow});const de=C.entry;F.gl.bindTexture(F.gl.TEXTURE_2D,de.glTex),F.gl.texImage2D(F.gl.TEXTURE_2D,0,F.gl.RGBA,F.gl.RGBA,F.gl.UNSIGNED_BYTE,pe),de.width=ie,de.height=Ae}catch(te){console.warn(`\u6587\u5B57\u5BF9\u8C61 ${k.name} \u7ED8\u5236\u5931\u8D25: ${te.message}`),C.lastKey=null}}}};e.sceneTextUpdate=$,window.__textWidgets=it,re(e,n,`text widgets: ${it.length} (scripts ${it.filter(A=>A.sandbox).length}, fonts ${I.size}, quality ${P.toFixed(2)})`)}if(s)return;const tt=[],yr=[],ft=[],Qt={},vr=[],hn=[],jt=new Map,mn=(T,u)=>{if(!u||typeof u.callCursor!="function"||!u.hasCursorHook)return;const x=jt.get(T);x?x.push(u):jt.set(T,[u])};for(const T of it)T.sandbox&&mn(T.layer,T.sandbox);{const T=p.general?.orthogonalprojection,u=T?.width||t.width,x=T?.height||t.height,S=v,P=(A,R)=>{const C=p.general||{};if(A==="zoom"&&typeof R=="number"&&Number.isFinite(R)&&R>0){p.cameraTransforms.zoom=R,C.zoom&&typeof C.zoom=="object"?C.zoom.value=R:C.zoom=R;return}C[A]&&typeof C[A]=="object"&&"value"in C[A]?C[A].value=R:C[A]=R};let I=1+Math.max(0,...p.layers.map(A=>Number(A.id)||0));const N={recomputeVisibility:_,getSceneLayer:A=>p.layers.find(R=>R.name===A&&!R.destroyed)||null,getSceneLayerById:A=>p.layers.find(R=>R.id===A&&!R.destroyed)||null,enumerateSceneLayers:()=>p.layers.filter(A=>!A.destroyed),getSceneAnimation:A=>{if(A==null||A==="")return null;if(Qt[A])return Qt[A];for(const R of p.layers)if(R.animations&&R.animations[A])return R.animations[A];return null},cameraTransforms:p.cameraTransforms,getInitialLayerConfig:A=>{const R=A&&typeof A=="object"?A.name:String(A||"");return p.layers.find(C=>C.name===R)||null},createSceneLayer:A=>{let R=A&&typeof A=="object"?A:null;if(typeof A=="string"){const k=A;if(R=p.layers.find(U=>U&&!U.destroyed&&U.image===k&&U.textureName)||p.layers.find(U=>U&&!U.destroyed&&U.image===k)||null,!R)return re(e,n,`createLayer('${k}') \u627E\u4E0D\u5230\u5DF2\u52A0\u8F7D\u7684\u540C\u6A21\u578B\u5C42`),null}R||(R={});const C={...R,id:I++,origin:Array.isArray(R.origin)?R.origin.slice():[0,0,0],scale:Array.isArray(R.scale)?R.scale.slice():[1,1,1],angles:Array.isArray(R.angles)?R.angles.slice():[0,0,0],size:Array.isArray(R.size)?R.size.slice():[0,0],color:Array.isArray(R.color)?R.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(R.effects)&&(C.effects=R.effects.map(k=>({...k,passes:Array.isArray(k.passes)?k.passes.map(U=>({...U})):k.passes}))),p.layers.push(C),C},mediaControl:Ee,windowTitle:oe.snapshot,openUserShortcut:Se.openUserShortcut,isScreensaver:!1};F.setConstantScriptRuntime?.(He.evalObjectScript,{userProperties:S,audioViews:le,shared:st,inputView:Ne,timers:we,...N,onSandbox:A=>{A&&A.hasMediaHook&&Fe(A)}});for(const A of p.layers){const R=A.objectAnimations;if(R){A.animations=A.animations||{},A.animationList=A.animationList||[];for(const[C,k]of Object.entries(R))try{const U=zi.createAnimation(k.animation);U.field=C,U.baseValue=k.value;const W=A[C];U.baseNumeric=Array.isArray(W)?W.slice():W,A.animationList.push(U),U.name&&(A.animations[U.name]=U),yr.push({layer:A,field:C,ctrl:U})}catch(U){re(e,n,`animation '${A.name}.${C}' \u5EFA\u63A7\u5236\u5668\u5931\u8D25: ${String(U.message).slice(0,80)}`)}}}for(const A of p.layers){for(const[C,k]of(A.effects||[]).entries()){const U=k.visibleScript;if(U)try{const W=He.evalObjectScript(U.script,U.scriptproperties,{canvasSize:{width:u,height:x},userProperties:S,audioViews:le,inputView:Ne,...Ge,layer:A,targetEffect:k,...N,shared:st,onError:J=>re(e,n,`effect visible script '${A.name}#${C}' \u5931\u8D25: ${String(J.message||J).slice(0,80)}`)});if(!W)continue;w.push(W),W.init(k.visible),W.applyUserProperties(S),W.hasMediaHook&&Fe(W),W.hasUpdate&&vr.push({effect:k,sandbox:W})}catch(W){console.warn(`\u6548\u679C\u5F00\u5173\u811A\u672C ${A.name}#${C} \u6C42\u503C\u5931\u8D25: ${W.message}`)}}const R=A.objectScripts;if(R)for(const[C,k]of Object.entries(R))try{const U=He.evalObjectScript(k.script,k.scriptproperties,{canvasSize:{width:u,height:x},screenResolution:{x:t.clientWidth||window.innerWidth||1,y:t.clientHeight||window.innerHeight||1},timeOfDay:(()=>{const W=new Date;return(W.getHours()*3600+W.getMinutes()*60+W.getSeconds())/86400})(),userProperties:S,audioViews:le,inputView:Ne,layer:A,...N,getBoneOverrides:fn,shared:st,...Ge,onError:W=>re(e,n,`object script '${A.name}.${C}' \u5931\u8D25: ${String(W.message||W).slice(0,90)}`)});if(U){w.push(U);const W=A[C],J=C==="angles"&&Array.isArray(W)?He.radToScriptAngles(W):Array.isArray(W)?{x:W[0]??0,y:W[1]??0,z:W[2]??0}:W;U.init(J),U.applyUserProperties(S),mn(A,U),U.hasMediaHook&&Fe(U),U.hasUpdate&&tt.push({layer:A,field:C,kind:C==="visible"?"bool":C==="alpha"||C==="brightness"?"scalar":"vec3",sandbox:U})}}catch(U){console.warn(`\u5BF9\u8C61\u811A\u672C ${A.name}.${C} \u6C42\u503C\u5931\u8D25: ${U.message}`)}}const E=p.generalScripts;if(E){for(const[A,R]of Object.entries(E))try{const C=He.evalObjectScript(R.script,R.scriptproperties,{canvasSize:{width:u,height:x},userProperties:S,audioViews:le,inputView:Ne,...Ge,...N,shared:st,onError:U=>re(e,n,`general script '${A}' \u5931\u8D25: ${String(U.message||U).slice(0,80)}`)});if(!C)continue;w.push(C),C.init(R.value),C.applyUserProperties(S),C.hasMediaHook&&Fe(C);const k=U=>P(A,U);C.hasUpdate&&hn.push({field:A,sandbox:C,write:k})}catch(C){console.warn(`general \u811A\u672C ${A} \u6C42\u503C\u5931\u8D25: ${C.message}`)}hn.length&&re(e,n,`general scripts: ${hn.map(A=>A.field).join(",")}`)}const $=p.generalAnimations;if($){for(const[A,R]of Object.entries($))try{const C=zi.createAnimation(R.animation);C.field=A,C.baseValue=R.value,C.baseNumeric=R.value,C.name&&(Qt[C.name]=C),ft.push({field:A,ctrl:C,write:k=>P(A,k)})}catch(C){re(e,n,`general animation '${A}' \u5EFA\u63A7\u5236\u5668\u5931\u8D25: ${String(C.message).slice(0,80)}`)}ft.length&&re(e,n,`general animations: ${ft.map(A=>A.field).join(",")}`)}}tt.length&&(re(e,n,`object scripts: ${tt.length}`),window.__objScripts=tt),window.__mediaHooks=Le,window.__compositeStats=()=>F.compositeStats?.()??null,window.__compositeEnable=T=>F.setCompositeEnabled?.(T),window.__scene=p,window.__textures=fe;const pn=Array.from(jt.keys());pn.length&&re(e,n,`cursor hooks: ${pn.length} layers`);let Lt=null,wt=null,Oe=!1;const Vt=()=>({worldPosition:He.makeCursorEventVec(xe.state.wx,xe.state.originY!=null?xe.state.originY:xe.state.wy,0)}),dt=(T,u,x)=>{const S=jt.get(T);if(S)for(const P of S)P.callCursor(u,x)},jn=()=>{if(pn.length===0)return;const T=xe.state;if(!T.has)return;const u=F.getParallaxOffset?F.getParallaxOffset():{x:0,y:0},x=p.general?.orthogonalprojection?.height||t.height,S=Kc.hitTestLayers(p.layers,T.wx,T.wy,x,{parOffX:u.x,parOffY:u.y,alignTable:Be.ALIGN,filter:I=>jt.has(I)}),P=Vt();S!==Lt&&(Lt&&dt(Lt,"cursorLeave",P),Lt=S,S&&dt(S,"cursorEnter",P)),S&&dt(S,"cursorMove",P),T.leftDown&&!Oe?(wt=S,S&&dt(S,"cursorDown",P)):!T.leftDown&&Oe&&(wt&&dt(wt,"cursorUp",P),wt&&wt===S&&dt(S,"cursorClick",P),wt=null),Oe=T.leftDown},ao=performance.now();let Vn=0,ht=0;const gn=[],Jt=[];let xr=-1/0;const Wn=T=>{if(s||e.paused)return;const x=1e3/(e.cfg.sceneFps||60);if(T-xr>=x){if(xr=T,fo(e,T),e.onFirstFrame){const E=e.onFirstFrame;e.onFirstFrame=void 0,E()}mo(e,t,e.cfg);const S=(T-ao-Vn)/1e3;if(Ne.update(xe.state),Xe.enabled){Y?.media?Y.media.pump():z.update(S);const E=ue(),$=ve.diffMediaEvents(Pe,E);if($.length){for(const{name:A,event:R}of $)for(const C of Le)C.disabled||C.callMedia(A,R);Pe=ve.cloneMediaSnapshot(E)}}Y?.windowTitle?Y.windowTitle.pump():V.update(S);for(const E of yr){E.ctrl.advance(x/1e3);const $=E.field,A=E.ctrl.applyTo(E.ctrl.baseNumeric);if(Array.isArray(A)){const R=E.layer[$];if(Array.isArray(R))for(let C=0;C<A.length&&C<R.length;C++)R[C]=A[C]}else Number.isFinite(A)&&($==="visible"?E.layer[$]=!!A:E.layer[$]=A)}for(const E of ft){E.ctrl.advance(x/1e3);const $=E.ctrl.applyTo(E.ctrl.baseNumeric);typeof $=="number"&&Number.isFinite($)?E.write($):Array.isArray($)&&Number.isFinite($[0])&&E.write($[0])}for(const E of vr){if(E.sandbox.disabled)continue;E.sandbox.engine.frametime=x/1e3,E.sandbox.engine.runtime=S;const $=E.sandbox.callUpdate(!!E.effect.visible);typeof $=="boolean"&&(E.effect.visible=$)}for(const E of hn){if(E.sandbox.disabled)continue;E.sandbox.engine.frametime=x/1e3,E.sandbox.engine.runtime=S;const $=p.general||{},A=$[E.field]&&typeof $[E.field]=="object"&&"value"in $[E.field]?$[E.field].value:$[E.field],R=E.sandbox.callUpdate(A);R!==void 0&&E.write(R)}const P={x:t.clientWidth||window.innerWidth||1,y:t.clientHeight||window.innerHeight||1};let I=!1;for(const E of tt){if(E.sandbox.disabled)continue;E.sandbox.engine.frametime=x/1e3,E.sandbox.engine.runtime=S,E.sandbox.engine.screenResolution=P;const $=E.layer[E.field];if(E.kind==="bool"){const A=E.sandbox.callUpdate(!!$);typeof A=="boolean"&&(E.field==="visible"?E.layer.visibleSelf!==A&&(E.layer.visibleSelf=A,I=!0):E.layer[E.field]=A)}else if(E.kind==="scalar"){const A=E.sandbox.callUpdate(Number($)||0),R=Number(A);Number.isFinite(R)&&(E.layer[E.field]=R)}else{const A=E.field==="angles"?He.radToScriptAngles($):{x:$[0]||0,y:$[1]||0,z:$[2]||0},R=E.sandbox.callUpdate(A),C=R&&typeof R=="object"&&"x"in R?R:A;E.layer[E.field]=E.field==="angles"?He.scriptAnglesToRad(C):[C.x||0,C.y||0,C.z||0]}}I&&_(),H.enabled&&(X.current?X.current.pump():B.update(S),kc(le,X.current?X.current.snapshot:B.snapshot)),Kt.length&&kn.followAttachments(Kt,S,fn);const N=e.coverAlign;F.render(p,fe,t.width,t.height,S,Xt(e.cfg.fit),N.x,N.y).then(()=>{if(!(s||e.paused)){try{jn()}catch{}xe.beginFrame();try{e.sceneTextUpdate&&T>=zn&&(zn=T+100,e.sceneTextUpdate(S))}catch{}e.raf=requestAnimationFrame(Wn)}}).catch(E=>{console.warn("scene render error:",E),re(e,n,`render: ${String(E.message||E).slice(0,200)}`),s=!0})}else e.paused||(e.raf=requestAnimationFrame(Wn))},wr=()=>{s||e.paused||e.raf===void 0&&(e.raf=requestAnimationFrame(Wn))},Mr=T=>{if(s)return;const u=p.properties||{},x=Cs(u,v,T);if(Object.keys(x).length){for(const S of p.layers){const P=S.srcObject;if(!P)continue;tn(P,u,0);const I=gt(P.visible);I&&I in x&&(S.visibleSelf=Qe.parseBool(P.visible,!0));const N=gt(P.color);N&&N in x&&(S.color=Qe.parseColor(P.color),S.isText&&(S.textColor=S.color));const E=gt(P.alpha);E&&E in x&&(S.alpha=Qe.parseNum(P.alpha,1));const $=gt(P.brightness);$&&$ in x&&(S.brightness=Qe.parseNum(P.brightness,1));const A=gt(P.volume);if(A&&A in x){const C=Qe.parseNum(P.volume,1);S.soundprops&&(S.soundprops.volume=C),S.soundCtl?.setVolume?.(C)}for(let C=0;C<(P.animationlayers||[]).length;C++){const k=P.animationlayers[C],U=S.animationLayers?.[C];if(!k||!U)continue;const W=gt(k.visible);W&&W in x&&(U.visible=Qe.parseBool(k.visible,!0));const J=gt(k.rate);J&&J in x&&(U.rate=Qe.parseNum(k.rate,1));const Q=gt(k.blend);Q&&Q in x&&(U.blend=Qe.parseNum(k.blend,1))}for(let C=0;C<(P.effects||[]).length;C++){const k=P.effects[C],U=S.effects?.[C];if(!k||!U)continue;const W=gt(k.visible);W&&W in x&&!U.visibleScript&&(U.visible=Qe.parseBool(k.visible,!0))}const R=P.instanceoverride;if(R&&typeof R=="object"&&S.particle){let C=!1;for(const k of Object.keys(R)){if(k==="id")continue;const U=gt(R[k]);if(U&&U in x){C=!0;break}}if(C){const k=zt.get(S.id);if(k)for(const U of k)U.reapplyOverride?.()}}}for(const S of w)if(!(!S||S.disabled))try{S.applyUserProperties(x)}catch{}_();for(const S of p.layers){if(!S.particle)continue;const P=zt.get(S.id);if(P)for(const I of P)I.setVisible(!!S.visible)}F.applyConstUserProperties?.(x);for(const S of it)S.lastKey=null;re(e,n,`props hot: ${Object.keys(x).join(",")}`)}};d=()=>{e.raf!==void 0&&(cancelAnimationFrame(e.raf),e.raf=void 0),ht||(ht=performance.now()),gn.length=0;for(const T of fe.values())T?.videoCtl?.isPlaying?.()&&(gn.push(T.videoCtl),T.videoCtl.pause());Jt.length=0;for(const T of un)!T.paused&&!T.ended&&(Jt.push(T),T.pause())},h=()=>{ht&&(Vn+=performance.now()-ht,ht=0),On=performance.now();for(const T of gn)try{T.play()}catch{}gn.length=0;for(const T of Jt)T.play().catch(()=>{});Jt.length=0,wr()},l=Mr,f&&(Mr(f),f=null),wr();{const T=p.general?.orthogonalprojection,u=T?.width||t.width,x=T?.height||t.height,S=Xt(e.cfg.fit),P=Nr(S,u,x,t.width,t.height);re(e,n,`fit ${S}: view ${Math.round(P.viewW)}x${Math.round(P.viewH)} scene ${u}x${x} canvas ${t.width}x${t.height}`)}re(e,n,`renderer started: ${p.layers.length} layers`)}catch(m){if(s||m&&m.name==="AbortError")return;console.warn("scene render failed:",m);const M=m instanceof Error?m:new Error(String(m));re(e,n,`failed: ${String(M.message||M).slice(0,200)}`),e.onError?e.onError(M):e.fallbackPage?.()}})()}function mr(e,n){(n.type==="video"||n.type==="gif"||n.type==="image")&&n.src?el(e,n):n.type==="scene"&&(n.source||n.src)?Al(e,n):e.onUnhandledType?.(n)}function _l(e){return e==="fit"?"contain":e==="fill"?"cover":e==="contain"||e==="stretch"?e:"cover"}function Tl(e,n){return{type:"scene",canvas:e,source:n.source,fit:_l(n.fit),renderDpr:n.renderDpr??1,sceneFps:n.fps??60,muted:(n.volume??0)<=0,loop:!0}}function Ki(e,n){const t=es(),o={ready:[],error:[],diagnostic:[]};let r={...n??{},source:null};const i=d=>{for(const h of o.error)try{h(d)}catch{}},s=d=>{t.onDiagnostic=(h,m)=>{try{d.onDiagnostic?.(h,m)}catch{}for(const M of o.diagnostic)try{M(h,m)}catch{}},t.onError=h=>{try{d.onError?.(h)}catch{}i(h)},t.onSceneInfo=h=>{t.info=h}},c=()=>new Promise(d=>{const h=t.onFirstFrame;t.onFirstFrame=()=>{t.onFirstFrame=void 0,h?.(),d()}}),a=()=>{let d=()=>{};return{promise:new Promise((m,M)=>{d=f.on("error",g=>M(g))}),off:d}},f={canvas:e,pause(){t.paused=!0,t.sceneCtl?.pause()},resume(){t.paused=!1,ho(t),t.sceneCtl?.resume()},get paused(){return!!t.paused},setFit(d){t.cfg.fit=d,Tr(t)},setFps(d){t.cfg.sceneFps=d},setVolume(d){const h=Math.max(0,Math.min(1,d));t.cfg.muted=h<=0,t.sceneAudio?.setVolume(h)},setRenderDpr(d){t.cfg.renderDpr=d,mr(t,t.cfg)},setProperties(d){const h={};for(const[m,M]of Object.entries(d))h[m]={value:M};t.sceneCtl?.applyUserProperties(h)},getProperties(){return{...t.liveUserProps??{}}},async load(d){r={...r,source:d},s(r);const h={...t.cfg,type:"scene",source:d,src:void 0,mediaBase:void 0};t.cfg=h,t.paused=!1,t.info=void 0,Tr(t);const m=c(),M=a();mr(t,h);try{await Promise.race([m,M.promise])}finally{M.off()}},release(){en(t)},restore(){mr(t,t.cfg)},destroy(){ts(t),t.onDiagnostic=void 0,t.onError=void 0,t.onFirstFrame=void 0,t.onSceneInfo=void 0,o.ready.length=0,o.error.length=0,o.diagnostic.length=0},get stats(){return rs(t)},get info(){return t.info??null},on(d,h){const m=o[d];return m.push(h),()=>{const M=m.indexOf(h);M>=0&&m.splice(M,1)}}},l=async d=>{r=d,s(d),t.cfg=Tl(e,d),t.paused=d.autoplay===!1,t.info=void 0,Tr(t);const h=c(),m=a();mr(t,t.cfg);try{await Promise.race([h,m.promise])}finally{m.off()}(d.volume??0)>0&&f.setVolume(d.volume),d.properties&&Object.keys(d.properties).length&&f.setProperties(d.properties)};return f.__applyOptions=l,f}async function Sl(e,n){const t=Ki(e,n);return await t.__applyOptions(n),t}rt.bytesSource=il,rt.createScene=Ki,rt.fileSource=ol,rt.httpSource=ji,rt.mount=Sl,Object.defineProperty(rt,Symbol.toStringTag,{value:"Module"})})});Rl();})();
512
+ `};function Zl(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 Kl={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"},wr=new Map;function Ql(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=wr.get(n);if(t&&(t.refs--,!(t.refs>0))){wr.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 an=new Map,eu=512*1024*1024;let fo=0;function tu(e){for(;an.size>0&&(an.size>2||fo>eu);){let n=null,t=1/0;for(const[o,i]of an)o!==e&&i.at<t&&(t=i.at,n=o);if(!n)break;const r=an.get(n);fo-=r.parsed.fileSize||0,an.delete(n)}}async function nu(e,n,t,r){const o=t.key;if(o){const c=an.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=He.parsePkg(s);return o&&(an.set(o,{parsed:a,at:Date.now()}),fo+=a.fileSize||0,tu(o)),a}function ru(e,n){rn(e);const t=(n.canvas instanceof HTMLCanvasElement?n.canvas:null)??document.createElement("canvas"),r=Wt(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??is(`${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 nu(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=He.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=Ye.parseScene(JSON.parse(pt(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=ta(g.properties||{});e.liveUserProps=v;const A=()=>Ye.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 _=[];ls&&(g.layers=g.layers.filter(b=>!(ls&&b.isComponent)));const R=b=>{const T=b.startsWith("shaders/")?b:"shaders/"+b,P=b.startsWith("shaders/")?b.slice(8):b,C=He.getEntry(x,T);let I=C?pt(C):ql[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=Ne.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=qi(),H=xe.createSimulatedMedia(),K=ns.createSimulatedWindowTitle();let O=null;const V={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),Ue={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}}})(),Ze=()=>_e.active?_e.snapshot:X.current?X.current.snapshot:j.snapshot;L.setAudioProvider(()=>te.enabled?Ze():Ue);const Xe=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 De=ns.createShortcutHandler(b=>{se(e,n,`openUserShortcut: ${b}`)}),Ke={enabled:!e.mediaDisabled,override:null},Be=[];let ye=null;V.lastSnap={get:()=>ye,setHasThumbnail:b=>{ye&&(ye.hasThumbnail=b)}};const he=()=>J().snapshot,Ie=b=>{if(!(!b||!b.hasMediaHook||Be.includes(b))&&(Be.push(b),!!he().hasMedia))for(const{name:T,event:P}of xe.diffMediaEvents(null,he()))try{b.callMedia(T,P)}catch{}};window.__mediaStats=()=>({enabled:Ke.enabled,live:!!O,hooks:Be.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=xe.diffMediaEvents(ye,he());for(const{name:P,event:C}of T)for(const I of Be)I.callMedia(P,C);return ye=xe.cloneMediaSnapshot(he()),window.__mediaStats()};const Pe=()=>{const b=xe.diffMediaEvents(ye,he());for(const{name:T,event:P}of b)for(const C of Be)try{C.callMedia(T,P)}catch{}ye=xe.cloneMediaSnapshot(he())},Qe=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()},Oe={get snapshot(){return he()},skipNext:()=>Qe("skipNext"),skipPrevious:()=>Qe("skipPrevious"),play:()=>Qe("play"),pause:()=>Qe("pause"),playPause:()=>Qe("playPause")};e.mediaCtl=Oe,window.__mediaControl=Oe,window.__system={media:Oe,windowTitle:Z.snapshot,shortcuts:De.last,live:null},window.__liveSystem=()=>({audio:"off",media:"offline",window:"offline"});const Ae=_l.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 ot=et.createInputView(),it=Ml.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)}`))}})()}),It={setTimeout:it.setTimeout,clearTimeout:it.clearTimeout,setInterval:it.setInterval,clearInterval:it.clearInterval};{const b=u;u=()=>{b?.(),it.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 we=new Map;we.set("util/white",{glTex:Ne.makeTexture(L.gl,new Uint8Array([255,255,255,255]),1,1),width:1,height:1,rg88:!1}),we.set("util/noflow",{glTex:Ne.makeTexture(L.gl,new Uint8Array([127,127,127,255]),1,1),width:1,height:1,rg88:!1}),we.set("util/noise",{glTex:Ne.makeTexture(L.gl,xl.generateNoiseTexture(),256,256),width:256,height:256,rg88:!1,mips:null});{const b=P=>{const C=xe.renderThumbnail(P,512);return{glTex:Ne.makeTextureMip(L.gl,[C],!1),width:C.width,height:C.height,rg88:!1,mips:[C],generated:!0}},T=H.tracks||[];T.length&&(we.set("$mediaThumbnail",b(T[0])),we.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),$=Xl(D,D.width,D.height,512),z=Hl(D,D.width,D.height);D.close?.();const B=we.get("$mediaThumbnail");B&&we.set("$mediaPreviousThumbnail",B);const q=L.gl,S=we.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=[$]):we.set("$mediaThumbnail",{glTex:Ne.makeTextureMip(q,[$],!1),width:$.width,height:$.height,rg88:!1,mips:[$],generated:!0});const E=J().snapshot;z&&(E.primaryColor=xe.mediaVec3(...z.primary),E.secondaryColor=xe.mediaVec3(...z.secondary),E.tertiaryColor=xe.mediaVec3(...z.tertiary),E.textColor=xe.mediaVec3(.98,.98,1),E.highContrastColor=xe.mediaVec3(1,1,1)),E.hasThumbnail=!0,V.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 ps({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,V.mediaDriver=O.media,O.status().audio==="mic"&&(X.current=O.audio),J().snapshot.hasMedia){for(const{name:C,event:I}of xe.diffMediaEvents(null,J().snapshot))for(const D of Be)try{D.callMedia(C,I)}catch{}ye=xe.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:Oe,windowTitle:Z.snapshot,shortcuts:De.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 Kt=new Map,go=async b=>{if(we.has(b))return we.get(b);const T=He.getEntry(x,`materials/${b}.tex`);if(!T){if(sn.isBuiltinParticleTextureName(b)){const $=sn.buildBuiltinParticleTexture(b);if($){const z={glTex:Ne.makeTextureMip(L.gl,[$],!1),width:$.width,height:$.height,rg88:!1,mips:[$],generated:!0};return we.set(b,z),z}}return null}const P=vr.parseTex(T),C=vr.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=Il($,{muted:!0,renderDpr:Wt(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 re of B)F.addEventListener("ended",re)},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:Ne.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)`)},we.set(b,E),E}else if(C.png!==void 0||C.image!==void 0&&C.fif===vr.FIF.JPEG){const $=new Blob([C.png||C.image],{type:C.png?"image/png":"image/jpeg"}),z=await createImageBitmap($);D={glTex:Ne.makeTexture(L.gl,null,0,0,z),width:z.width,height:z.height,rg88:I}}else{if(C.image!==void 0)return null;{const $=vr.decodeMip0(P);D={glTex:Ne.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 we.set(b,D),D},Qt=b=>{if(we.has(b))return Promise.resolve(we.get(b));const T=Kt.get(b);if(T)return T;const P=go(b);return Kt.set(b,P),P.finally(()=>{Kt.get(b)===P&&Kt.delete(b)}),P},Wn=/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=He.getEntry(x,`shaders/${T.shader}.${P}`);if(!C)continue;const I=pt(C);Wn.lastIndex=0;let D;for(;(D=Wn.exec(I))!==null;){const $=D[1];!$||$.startsWith("util/")||$.startsWith("_rt_")||we.has($)||await Qt($)}}};let Vn=0;const Jt=[];for(let b=0;b<g.layers.length;b++){const T=g.layers[b];if(T.image)try{let P;if(Pt.BUILTIN_MODELS[T.image])P=Pt.BUILTIN_MODELS[T.image];else{const E=He.getEntry(x,T.image);if(!E)continue;P=JSON.parse(pt(E))}Ye.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&&we.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 $=Ye.resolveMaterial(P);if(!$)continue;let z;if(Pt.BUILTIN_MATERIALS[$.materialPath])z=Pt.BUILTIN_MATERIALS[$.materialPath];else{const E=He.getEntry(x,$.materialPath);if(E)z=JSON.parse(pt(E));else if(T.solid&&Pt.BUILTIN_MATERIALS["materials/util/solidlayer.json"])z=Pt.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_")||Jt.push(Qt(k).then(F=>{F&&E===0&&!D&&(T.textureName=k,Vn++,F.videoCtl&&(T.videoCtl=F.videoCtl))}))}B?.shader&&He.getEntry(x,`shaders/${B.shader}.frag`)&&Pt.attachLayerMaterialEffect(T,B);for(const E of T.effects||[])Pt.resolveEffectChain(x,E,pt);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_")&&Jt.push(Qt(F));Jt.push(Me(E))}}catch(P){console.warn(`\u56FE\u5C42 ${T.name||b} \u52A0\u8F7D\u5931\u8D25: ${P.message}`)}}if(!us){for(const b of g.layers)if(!(!b.isText||!(b.effects||[]).length))try{for(const T of b.effects||[])Pt.resolveEffectChain(x,T,pt);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_")&&Jt.push(Qt(C))}catch(T){console.warn(`\u6587\u5B57\u5C42\u6548\u679C ${b.name} \u89E3\u6790\u5931\u8D25: ${T.message}`)}}await Promise.all(Jt);for(const[b,T]of we){if(!T?.videoCtl)continue;g.layers.some(C=>C.textureName===b&&C.visible&&!C.destroyed)&&!e.paused&&T.videoCtl.play()}const tt=[],Hn=[],en=new Map;let _r=0;const Ar=async b=>{const T=await Qt(b);if(T)return T;const P=sn.buildBuiltinParticleTexture(b);if(!P)return null;const C={glTex:Ne.makeTextureMip(L.gl,[P],!1),width:P.width,height:P.height,rg88:!1,mips:[P],generated:!0,frames:sn.builtinParticleFrames(b)??void 0};return we.set(b,C),_r++,C},bo=b=>{if(!b)return null;const T=b.mips&&b.mips[0];if(T?.rgba&&typeof sn.prepareParticleNormalTexture=="function"){const P=sn.prepareParticleNormalTexture(T);if(P&&P!==T)return{glTex:Ne.makeTextureMip(L.gl,[P],!1),width:P.width,height:P.height,rg88:!1,mips:[P],generated:!0}}return b},Tr=async(b,T,P,C)=>{if(C>3)return null;const I=He.getEntry(x,b);if(!I)return se(e,n,`particle '${b}' \u4E0D\u5728 pkg\uFF0C\u8DF3\u8FC7`),null;const D=JSON.parse(pt(I)),$=new wl.ParticleSystem(L.gl,D,P,T);let z=null,B=null;if(D.material){const k=He.getEntry(x,D.material);if(k){const F=JSON.parse(pt(k));$.setMaterial(F);const re=F?.passes?.[0]?.textures||[];z=re[0]||null,B=re[1]||null}}const q=await Ar(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?sn.particleNormalNameForAlbedo(z||"particle/halo"):null);if(S){const k=bo(await Ar(S));k&&$.setNormalTexture({glTex:k.glTex,width:k.width,height:k.height})}$.setVisible(!!T.visible),tt.push($);const E=T.id;if(E!==void 0){let k=en.get(E);k||(k=[],en.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),re=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),ge={...T,origin:[ue[0],ue[1],(T.origin?.[2]||0)+(F[2]||0)],scale:[(T.scale?.[0]??1)*(re[0]||1),(T.scale?.[1]??1)*(re[1]||1),(T.scale?.[2]??1)*(re[2]||1)],angles:[(T.angles?.[0]||0)+(Q[0]||0),(T.angles?.[1]||0)+(Q[1]||0),(T.angles?.[2]||0)+(Q[2]||0)]},$e=await Tr(k.name,ge,k.instanceoverride||P,C+1);$e&&ce&&$e.attachFollow($,ce,[F[0]||0,F[1]||0,F[2]||0])}return $};if(!Ol){for(const b of g.layers)if(b.particle)try{await Tr(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(tt.length>0){const b=u;u=()=>{b?.();for(const T of tt)T.dispose()}}const tn=[];for(const b of g.layers)if(!(!b.sound||!b.sound.length))try{for(const T of b.sound){const P=He.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(()=>{}),tn.push(z);break}}catch(T){console.warn(`\u58F0\u97F3\u56FE\u5C42 ${b.name} \u52A0\u8F7D\u5931\u8D25: ${T.message}`)}const yo=b=>{for(const T of tn)T.volume=Math.max(0,Math.min(1,b)),T.muted=b<=0};if(e.sceneAudio={setVolume:yo,audios:tn},s)return;let wn=performance.now(),ln=0;L.setParticleRenderer(()=>{const b=performance.now(),T=Math.min(.05,(b-wn)/1e3);if(wn=b,Ae.state.has){const{wx:P,wy:C,originY:I}=Ae.state,D=I??C;for(const $ of tt)$.setPointer(P,D)}if(Hn.length)for(const P of Hn)P.syncLayerTransform();for(const P of tt)P.advance(T,te.enabled?Ze():null);if(ln<2&&(ln++,ln===2)){const P=tt.reduce((C,I)=>C+I.liveCount(),0);se(e,n,`particles live: ${P} across ${tt.length} systems`)}},(b,T,P,C,I)=>{if(b===void 0)return;const D=en.get(b);if(D)for(const $ of D)$.render(P,C,I,T.projW,T.projH)}),se(e,n,`particles: ${tt.length} systems, ${_r} builtin tex generated`),window.__particleStats=()=>tt.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<tt.length;P++)tt[P].setVisible(T===void 0?b:P===T);return tt.length};const st=[],bt=new Map,Te=b=>{if(!b||!b.puppet)return null;let T=bt.get(b);return T||(T=new Map,bt.set(b,T)),T};for(const b of g.layers)if(b.image)try{if(Pt.BUILTIN_MODELS[b.image])continue;const T=He.getEntry(x,b.image);if(!T)continue;const P=JSON.parse(pt(T));if(!P.puppet)continue;const C=He.getEntry(x,P.puppet);if(!C)continue;const I=jn.parseMDL(new Uint8Array(C)),D=b.textureName?we.get(b.textureName):null;if(!D){se(e,n,`puppet '${b.name}' \u65E0\u8D34\u56FE\uFF0C\u8DF3\u8FC7`);continue}b.puppet=I,st.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=He.getEntry(x,b.model);if(!T)continue;const P=jn.parseMDL(new Uint8Array(T));let C=null;if(P.materialPath){const D=He.getEntry(x,P.materialPath);if(D){const z=JSON.parse(pt(D))?.passes?.[0]?.textures?.[0];typeof z=="string"&&z&&(C=z)}}C&&(await Qt(C),b.textureName=C);const I=C?we.get(C):null;if(!I){se(e,n,`model '${b.name}' \u65E0\u8D34\u56FE\uFF0C\u8DF3\u8FC7`);continue}b.puppet=P,st.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 yt=null;if(st.length>0)try{yt=jn.createMDLRenderer(L.gl);for(const T of st)yt.upload(T.mdl);const b=new Map;for(const T of st)b.set(T.layer,T);L.setPuppetRenderer((T,P,C)=>{const I=b.get(T);I&&yt.draw(P,I.mdl,{time:C.time,animLayers:T.animationLayers,boneOverrides:bt.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}`),yt=null;for(const T of st)T.layer.puppet=null}if(s)return;se(e,n,`puppet: ${st.length} meshes`);const nn=jn.applyAttachmentBindOrigins(g.layers);nn.length&&se(e,n,`attachments: ${nn.length} hanging layers`);const at=Ye.collectTransformDirty(g.layers,nn.map(b=>b.layer));if(at.size){se(e,n,`transform graph: ${at.size} live layers`);for(const[b,T]of en)if(at.has(b))for(const P of T)Hn.push(P)}const vt=[],Ct=new Map,Ot={};let Lt=null,Xn=null,Gn=0;if(!us&&g.layers.some(b=>b.isText)){const b=g.general?.orthogonalprojection,T=b?.width||t.width,P=b?.height||t.height,C=Ir(dn(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=wr.get(E);if(k){k.refs++,$.push(E),D.set(S,k.family);continue}const F=Kl[S.toLowerCase()];if(F){D.set(S,F);continue}try{const re=He.getEntry(x,S);if(!re)continue;const Q=Zl(re instanceof Uint8Array?re:new Uint8Array(re)),ce="wefont_"+Ql(E)+"_"+S.split("/").pop().replace(/[^a-zA-Z0-9]/g,"_"),ue=URL.createObjectURL(new Blob([Q])),ge=new FontFace(ce,`url(${ue})`);if(await ge.load(),s){URL.revokeObjectURL(ue);break}document.fonts.add(ge),(e.objectUrls??=[]).push(ue),D.set(S,ce),wr.set(E,{family:ce,refs:1}),$.push(E)}catch(re){console.warn(`\u5B57\u4F53\u52A0\u8F7D\u5931\u8D25 ${S}: ${re.message}`)}}if($.length){const S=e.sceneCleanup;e.sceneCleanup=()=>{Jl($),S?.()}}Lt=document.createElement("canvas"),Xn=Lt.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=et.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:Ot,audioViews:Xe,inputView:ot,...It,mediaControl:Oe,windowTitle:Z.snapshot,openUserShortcut:De.openUserShortcut,getLayerText:Q=>Ct.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&&Ie(E.sandbox))),Ct.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 ge=0,$e=0;ue.includes("left")&&(ge+=Q),ue.includes("right")&&(ge-=Q),ue.includes("top")&&($e-=ce),ue.includes("bottom")&&($e+=ce),S.origin[0]+=ge,S.origin[1]+=$e,S.localOrigin&&(S.localOrigin[0]+=ge,S.localOrigin[1]+=$e)}const k=fs*Math.max(1,S.textPointsize),F=et.textLayerHasTintMask(S)?8:256,re=Math.min(F,et.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=re,S.size=[E.boxW+re*2,E.boxH+re*2],E.entry={glTex:Ne.makeTexture(L.gl,new Uint8Array([0,0,0,0]),1,1),width:1,height:1,rg88:!1},we.set(E.texName,E.entry),S.textureName=E.texName,S.solid=!1,vt.push(E)}catch(E){console.warn(`\u6587\u5B57\u5BF9\u8C61 ${S.name} \u521D\u59CB\u5316\u5931\u8D25: ${E.message}`)}if(vt.length>0){const S=u;u=()=>{S?.();for(const E of vt)L.gl.deleteTexture(E.entry.glTex)}}const q=S=>{if(!Xn||!Lt)return;const E=Xn;for(const k of vt){const F=k.layer;let re=String(F.text??"");if(k.sandbox&&k.sandbox.hasUpdate){k.sandbox.engine.runtime=S;const ge=k.sandbox.callUpdate(re);ge!=null?re=String(ge):k.sandbox.thisLayer.text&&(re=String(k.sandbox.thisLayer.text))}else k.sandbox&&typeof k.sandbox.thisLayer?.text=="string"&&(re=String(k.sandbox.thisLayer.text));if(Ct.set(F.name||"",re),!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=`${re}\0${Q}\0${ce}\0${F.alpha}\0${F.textCastshadow}`;if(k.lastKey!==ue){k.lastKey=ue;try{const ge=fs*Q,$e=k.boxW,Mt=k.boxH,kt=k.margin,_t=Math.abs(F.scale[0]||1),de=Math.abs(F.scale[1]||1);let pe=Math.max(1,Math.round(F.size[0]*_t*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)),Lt.width!==pe||Lt.height!==fe?(Lt.width=pe,Lt.height=fe):(E.setTransform(1,0,0,1,0,0),E.clearRect(0,0,pe,fe));const ct=Math.min(pe/F.size[0],fe/F.size[1]);E.setTransform(ct,0,0,ct,0,0),E.translate(kt,kt);const lt=ce&&D.get(ce)||"sans-serif";E.font=`${ge}px "${lt}", sans-serif`;const At=E.measureText(""),nt=(At.fontBoundingBoxAscent||0)+(At.fontBoundingBoxDescent||0),Ce=F.textSpacing||[0,0],_n=et.layoutText(re,{boxW:$e,boxH:Mt,pointsize:ge,lineHeight:(nt>0?nt:ge*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},Ge=>E.measureText(Ge).width);et.drawTextLayer(E,_n,{font:E.font,color:F.textColor,alpha:F.alpha,brightness:F.brightness,spacing:Ce,pointsize:ge,opaquebackground:!!F.textOpaquebackground,backgroundcolor:F.textBackgroundcolor,backgroundbrightness:F.textBackgroundbrightness,castshadow:!!F.textCastshadow});const ut=k.entry;L.gl.bindTexture(L.gl.TEXTURE_2D,ut.glTex),L.gl.texImage2D(L.gl.TEXTURE_2D,0,L.gl.RGBA,L.gl.RGBA,L.gl.UNSIGNED_BYTE,Lt),ut.width=pe,ut.height=fe}catch(ge){console.warn(`\u6587\u5B57\u5BF9\u8C61 ${F.name} \u7ED8\u5236\u5931\u8D25: ${ge.message}`),k.lastKey=null}}}};e.sceneTextUpdate=q,window.__textWidgets=vt,se(e,n,`text widgets: ${vt.length} (scripts ${vt.filter(S=>S.sandbox).length}, fonts ${D.size}, quality ${I.toFixed(2)})`)}if(s)return;const $t=[],Yn=[],jt=[],un={},ze=[],xt=[],wt=new Map,Mn=(b,T)=>{if(!T||typeof T.callCursor!="function"||!T.hasCursorHook)return;const P=wt.get(b);P?P.push(T):wt.set(b,[T])};for(const b of vt)b.sandbox&&Mn(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(un[E])return un[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 re=E;if(k=g.layers.find(Q=>Q&&!Q.destroyed&&Q.image===re&&Q.textureName)||g.layers.find(Q=>Q&&!Q.destroyed&&Q.image===re)||null,!k)return se(e,n,`createLayer('${re}') \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(re=>({...re,passes:Array.isArray(re.passes)?re.passes.map(Q=>({...Q})):re.passes}))),g.layers.push(F),F},mediaControl:Oe,windowTitle:Z.snapshot,openUserShortcut:De.openUserShortcut,isScreensaver:!1};L.setConstantScriptRuntime?.(et.evalObjectScript,{userProperties:C,audioViews:Xe,shared:Ot,inputView:ot,timers:it,...$,onSandbox:E=>{E&&E.hasMediaHook&&Ie(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,re]of Object.entries(k))try{const Q=rs.createAnimation(re.animation);Q.field=F,Q.baseValue=re.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),Yn.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,re]of(E.effects||[]).entries()){const Q=re.visibleScript;if(Q)try{const ce=et.evalObjectScript(Q.script,Q.scriptproperties,{canvasSize:{width:T,height:P},userProperties:C,audioViews:Xe,inputView:ot,...It,layer:E,targetEffect:re,...$,shared:Ot,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(re.visible),ce.applyUserProperties(C),ce.hasMediaHook&&Ie(ce),ce.hasUpdate&&ze.push({effect:re,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,re]of Object.entries(k))try{const Q=et.evalObjectScript(re.script,re.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:Xe,inputView:ot,layer:E,...$,getBoneOverrides:Te,shared:Ot,...It,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],ge=F==="angles"&&Array.isArray(ue)?et.radToScriptAngles(ue):Array.isArray(ue)?{x:ue[0]??0,y:ue[1]??0,z:ue[2]??0}:ue;Q.init(ge),Q.applyUserProperties(C),Mn(E,Q),Q.hasMediaHook&&Ie(Q),Q.hasUpdate&&$t.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=et.evalObjectScript(k.script,k.scriptproperties,{canvasSize:{width:T,height:P},userProperties:C,audioViews:Xe,inputView:ot,...It,...$,shared:Ot,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&&Ie(F);const re=Q=>I(E,Q);F.hasUpdate&&xt.push({field:E,sandbox:F,write:re})}catch(F){console.warn(`general \u811A\u672C ${E} \u6C42\u503C\u5931\u8D25: ${F.message}`)}xt.length&&se(e,n,`general scripts: ${xt.map(E=>E.field).join(",")}`)}const S=g.generalAnimations;if(S){for(const[E,k]of Object.entries(S))try{const F=rs.createAnimation(k.animation);F.field=E,F.baseValue=k.value,F.baseNumeric=k.value,F.name&&(un[F.name]=F),jt.push({field:E,ctrl:F,write:re=>I(E,re)})}catch(F){se(e,n,`general animation '${E}' \u5EFA\u63A7\u5236\u5668\u5931\u8D25: ${String(F.message).slice(0,80)}`)}jt.length&&se(e,n,`general animations: ${jt.map(E=>E.field).join(",")}`)}}$t.length&&(se(e,n,`object scripts: ${$t.length}`),window.__objScripts=$t),window.__mediaHooks=Be,window.__sceneLayers=g.layers,window.__compositeStats=()=>L.compositeStats?.()??null,window.__compositeEnable=b=>L.setCompositeEnabled?.(b),window.__scene=g,window.__textures=we;const qn=Array.from(wt.keys());qn.length&&se(e,n,`cursor hooks: ${qn.length} layers`);let fn=null,dt=null,Zn=!1;const Sr=()=>({worldPosition:et.makeCursorEventVec(Ae.state.wx,Ae.state.originY!=null?Ae.state.originY:Ae.state.wy,0)}),zt=(b,T,P)=>{const C=wt.get(b);if(C)for(const I of C)I.callCursor(T,P)},vo=()=>{if(qn.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=Al.hitTestLayers(g.layers,b.wx,b.wy,P,{parOffX:T.x,parOffY:T.y,alignTable:Ne.ALIGN,filter:D=>wt.has(D)}),I=Sr();C!==fn&&(fn&&zt(fn,"cursorLeave",I),fn=C,C&&zt(C,"cursorEnter",I)),C&&zt(C,"cursorMove",I),b.leftDown&&!Zn?(dt=C,C&&zt(C,"cursorDown",I)):!b.leftDown&&Zn&&(dt&&zt(dt,"cursorUp",I),dt&&dt===C&&zt(C,"cursorClick",I),dt=null),Zn=b.leftDown},xo=performance.now();let Er=0,Rt=0;const w=[],U=[];let G=-1/0,W=0;const Y=b=>{if(s||e.paused)return;const P=1e3/(e.cfg.sceneFps||60);if(b-G>=P){G=b,An(e,b),To(e,t,e.cfg);const C=(b-xo-Er)/1e3;if(ot.update(Ae.state),Ke.enabled){if(O?.media)O.media.pump();else{const S=J();typeof S?.update=="function"&&S.update(C)}const B=he(),q=xe.diffMediaEvents(ye,B);if(q.length){for(const{name:S,event:E}of q)for(const k of Be)k.disabled||k.callMedia(S,E);ye=xe.cloneMediaSnapshot(B)}}O?.windowTitle?O.windowTitle.pump():K.update(C);const I=Math.max(0,C-W);W=C;for(const B of Yn){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 jt){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 ze){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 xt){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 $t){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"?et.radToScriptAngles(E):{x:E[0]||0,y:E[1]||0,z:E[2]||0},F=B.sandbox.callUpdate(k),re=F&&typeof F=="object"&&"x"in F?F:k;B.layer[S]=B.field==="angles"?et.scriptAnglesToRad(re):[re.x||0,re.y||0,re.z||0]}}$&&A(),at.size&&Ye.recomposeWorld(g.layers,at),te.enabled&&(_e.pump(),_e.active||(X.current?X.current.pump():j.update(C)),al(Xe,Ze())),nn.length&&jn.followAttachments(nn,C,Te);const z=e.coverAlign;L.render(g,we,t.width,t.height,C,dn(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{vo()}catch{}Ae.beginFrame();try{e.sceneTextUpdate&&b>=Gn&&(Gn=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=na(T,v,b);if(Object.keys(P).length){for(const C of g.layers){const I=C.srcObject;if(!I)continue;pn(I,T,0);const D=Tt(I.visible);D&&D in P&&(C.visibleSelf=Ye.parseBool(I.visible,!0));const $=Tt(I.color);$&&$ in P&&(C.color=Ye.parseColor(I.color),C.isText&&(C.textColor=C.color));const z=Tt(I.alpha);z&&z in P&&(C.alpha=Ye.parseNum(I.alpha,1));const B=Tt(I.brightness);B&&B in P&&(C.brightness=Ye.parseNum(I.brightness,1));const q=Tt(I.volume);if(q&&q in P){const E=Ye.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 re=Tt(k.visible);re&&re in P&&(F.visible=Ye.parseBool(k.visible,!0));const Q=Tt(k.rate);Q&&Q in P&&(F.rate=Ye.parseNum(k.rate,1));const ce=Tt(k.blend);ce&&ce in P&&(F.blend=Ye.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 re=Tt(k.visible);re&&re in P&&!F.visibleScript&&(F.visible=Ye.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=Tt(S[k]);if(F&&F in P){E=!0;break}}if(E){const k=en.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=en.get(C.id);if(I)for(const D of I)D.setVisible(!!C.visible)}L.applyConstUserProperties?.(P);for(const C of vt)C.lastKey=null;se(e,n,`props hot: ${Object.keys(P).join(",")}`)}};p=()=>{e.raf!==void 0&&(cancelAnimationFrame(e.raf),e.raf=void 0),Rt||(Rt=performance.now()),w.length=0;for(const b of we.values())b?.videoCtl?.isPlaying?.()&&(w.push(b.videoCtl),b.videoCtl.pause());U.length=0;for(const b of tn)!b.paused&&!b.ended&&(U.push(b),b.pause())},d=()=>{Rt&&(Er+=performance.now()-Rt,Rt=0),wn=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=dn(e.cfg.fit),I=Ir(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 ou='data-we-shim="1"',hs="data-we-shim-src";function iu(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 su(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 ms(e){return e.replace(/<\/script/gi,"<\\/script")}function au(e,n,t){if(e||(e=""),e.includes(ou)||e.includes(hs))return e;const r=t.baseHref&&!/<base\b/i.test(e)?`<base href="${t.baseHref.replace(/"/g,"&quot;")}">`:"",o=`<script ${hs}="1">
513
+ ${ms(n)}
514
+ <\/script>`,i=t.seedScript&&t.seedScript.trim()?`<script>
515
+ ${ms(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 cu=`/**
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
+ *
519
+ * \u8BED\u6599\uFF1A\u672C\u673A\u5E93 42 \u5F20 web \u58C1\u7EB8\u626B\u63CF\uFF082026-09\uFF09\u2014\u2014
520
+ * wallpaperPropertyListener 29 / RegisterAudioListener 22 /
521
+ * RequestRandomFileForProperty 8 / userDirectoryFiles* 9 /
522
+ * Media*Listener 2 / PluginListener 2
523
+ *
524
+ * \u5B98\u65B9 CEF \u5728\u4EFB\u4F55\u58C1\u7EB8\u811A\u672C\u524D\u5C31\u628A\u8FD9\u4E9B\u505A\u6210\u539F\u751F\u51FD\u6570\uFF1B\u5DE5\u574A\u9876\u5C42\u76F4\u63A5\u6CE8\u518C\u3002
525
+ * \u672C\u6587\u4EF6\u4F5C\u4E3A <head> \u9996\u4E2A classic script \u63D2\u5165\u3002
526
+ *
527
+ * \u7236\u9875\u63A7\u5236\u9762 __we*\uFF08main.ts weShimCall / web.ts \u6CF5\uFF09\uFF1A
528
+ * __weSetPaused / __weSetFps / __weSetVolume / __weApplyProps / __weSeedProps
529
+ * __wePushAudio(arr128)
530
+ * __wePushMedia(event) \u2014 {op, payload} \u89C1\u4E0B
531
+ * __wePushDirectoryFiles(prop, files) / __weRemoveDirectoryFiles(prop, files)
532
+ * __weRewriteFileUrl(s) \u2014 file:/// \u2192 \u540C\u6E90\u76F8\u5BF9\uFF08HTTP \u9875\uFF09\uFF1B\u7A7A file:/// \u2192 ""
533
+ * __wePushPointer(x, y, buttons) / __wePointerLeave() \u2014 \u5916\u90E8\u6307\u9488\u6CE8\u5165\uFF08\u89C1\u6587\u672B\uFF09
534
+ */
535
+ (function (w) {
536
+ "use strict";
537
+ try {
538
+ if (w.document && w.document.documentElement) {
539
+ w.document.documentElement.setAttribute("data-we-shim", "1");
540
+ }
541
+ } catch (_) {
542
+ /* \u5FFD\u7565 */
543
+ }
544
+
545
+ var audioListener = null;
546
+ var propertyListener = null;
547
+ var paused = false;
548
+ var fps = 60;
549
+ var volume = 0;
550
+ var pendingProps = null;
551
+ var pendingGeneral = null;
552
+ var rafMap = Object.create(null);
553
+ var rafCounter = 0;
554
+ var origRaf = w.requestAnimationFrame.bind(w);
555
+ var origCaf = w.cancelAnimationFrame.bind(w);
556
+
557
+ // \u5B98\u65B9 CEF \u4EE5\u6587\u4EF6\u7CFB\u7EDF\u4E3A\u6E90\uFF0C\u4F5C\u8005\u666E\u904D \`'file:///' + value\`\u3002HTTP \u540C\u6E90\u9875\u91CC
558
+ // file:///files/x.webm \u52A0\u8F7D\u5931\u8D25\uFF1B\u7A7A value \u53D8\u6210 file:///\uFF081748506393\uFF09\u3002
559
+ // file: \u534F\u8BAE\u9875\u4FDD\u6301\u539F\u6837\uFF08\u771F\u672C\u5730\u5D4C\u5165\uFF09\u3002
560
+ function rewriteBareFileUrl(url) {
561
+ if (typeof url !== "string") return url;
562
+ var s = url.trim();
563
+ if (!/^file:/i.test(s)) return s;
564
+ try {
565
+ var loc = w.location;
566
+ if (loc && loc.protocol === "file:") return s;
567
+ } catch (_) {
568
+ /* \u5FFD\u7565 */
569
+ }
570
+ var rest = s.replace(/^file:\\/\\//i, "").replace(/^\\/+/, "");
571
+ if (!rest) return "";
572
+ if (/^[a-zA-Z][:|]/.test(rest)) return "";
573
+ if (/^(Users|home|tmp|var|etc|private|Volumes)\\//.test(rest)) return "";
574
+ try {
575
+ var href = w.location && w.location.href;
576
+ if (href) return new URL(rest, href).href;
577
+ } catch (_) {
578
+ /* \u5FFD\u7565 */
579
+ }
580
+ return rest;
581
+ }
582
+
583
+ function rewriteWeFileUrl(input) {
584
+ if (typeof input !== "string") return input;
585
+ if (/url\\(/i.test(input)) {
586
+ return input.replace(/url\\(\\s*(['"]?)([^)'"]*?)\\1\\s*\\)/gi, function (_m, q, inner) {
587
+ var next = rewriteBareFileUrl(inner);
588
+ if (!next) return "none";
589
+ var quote = q || '"';
590
+ return "url(" + quote + next + quote + ")";
591
+ });
592
+ }
593
+ return rewriteBareFileUrl(input);
594
+ }
595
+
596
+ w.__weRewriteFileUrl = rewriteWeFileUrl;
597
+
598
+ function installFileUrlHooks() {
599
+ try {
600
+ if (w.Element && w.Element.prototype && typeof w.Element.prototype.setAttribute === "function") {
601
+ var origSetAttr = w.Element.prototype.setAttribute;
602
+ w.Element.prototype.setAttribute = function (name, value) {
603
+ var n = String(name || "").toLowerCase();
604
+ if (n === "src" || n === "href" || n === "poster") value = rewriteWeFileUrl(value);
605
+ return origSetAttr.call(this, name, value);
606
+ };
607
+ }
608
+ } catch (_) {
609
+ /* \u65E0 DOM \u7684 verifier \u8DF3\u8FC7 */
610
+ }
611
+ var ctorNames = ["HTMLImageElement", "HTMLMediaElement", "HTMLSourceElement", "HTMLScriptElement"];
612
+ for (var i = 0; i < ctorNames.length; i++) {
613
+ try {
614
+ var Ctor = w[ctorNames[i]];
615
+ if (!Ctor || !Ctor.prototype) continue;
616
+ var desc = Object.getOwnPropertyDescriptor(Ctor.prototype, "src");
617
+ if (!desc || typeof desc.set !== "function") continue;
618
+ (function (d) {
619
+ Object.defineProperty(Ctor.prototype, "src", {
620
+ configurable: true,
621
+ enumerable: d.enumerable,
622
+ get: d.get,
623
+ set: function (v) {
624
+ d.set.call(this, rewriteWeFileUrl(v));
625
+ },
626
+ });
627
+ })(desc);
628
+ } catch (_) {
629
+ /* \u5FFD\u7565\u5355\u4E2A\u539F\u578B */
630
+ }
631
+ }
632
+ try {
633
+ var styleDesc =
634
+ w.HTMLElement && Object.getOwnPropertyDescriptor(w.HTMLElement.prototype, "style");
635
+ // Chromium \u7684 backgroundImage \u4E0D\u662F\u539F\u578B\u81EA\u6709\u63CF\u8FF0\u7B26\uFF0C\u53EA\u80FD\u5305 HTMLElement.style \u7684 Proxy\u3002
636
+ if (styleDesc && typeof styleDesc.get === "function" && w.Proxy && w.WeakMap) {
637
+ var styleCache = new w.WeakMap();
638
+ Object.defineProperty(w.HTMLElement.prototype, "style", {
639
+ configurable: true,
640
+ enumerable: styleDesc.enumerable,
641
+ get: function () {
642
+ var raw = styleDesc.get.call(this);
643
+ if (!raw) return raw;
644
+ var cached = styleCache.get(raw);
645
+ if (cached) return cached;
646
+ var proxy = new w.Proxy(raw, {
647
+ set: function (target, prop, value) {
648
+ if (typeof value === "string" && typeof prop === "string" && /background/i.test(prop)) {
649
+ value = rewriteWeFileUrl(value);
650
+ }
651
+ target[prop] = value;
652
+ return true;
653
+ },
654
+ get: function (target, prop) {
655
+ var v = target[prop];
656
+ if (typeof v === "function") return v.bind(target);
657
+ return v;
658
+ },
659
+ });
660
+ styleCache.set(raw, proxy);
661
+ return proxy;
662
+ },
663
+ set: styleDesc.set,
664
+ });
665
+ }
666
+ var styleProto = w.CSSStyleDeclaration && w.CSSStyleDeclaration.prototype;
667
+ if (styleProto && typeof styleProto.setProperty === "function") {
668
+ var origSetProp = styleProto.setProperty;
669
+ styleProto.setProperty = function (name, value, priority) {
670
+ if (typeof value === "string" && /background/i.test(String(name || ""))) {
671
+ value = rewriteWeFileUrl(value);
672
+ }
673
+ return origSetProp.call(this, name, value, priority);
674
+ };
675
+ }
676
+ } catch (_) {
677
+ /* \u5FFD\u7565 */
678
+ }
679
+ }
680
+ installFileUrlHooks();
681
+
682
+ // propertyName \u2192 string[]\uFF08\u7EDD\u5BF9/\u76F8\u5BF9\u8DEF\u5F84\uFF1B\u968F\u673A\u6587\u4EF6\u4ECE\u6B64\u62BD\uFF09
683
+ var directoryFiles = Object.create(null);
684
+
685
+ var mediaListeners = {
686
+ properties: null,
687
+ thumbnail: null,
688
+ playback: null,
689
+ timeline: null,
690
+ status: null,
691
+ };
692
+ // \u665A\u6CE8\u518C\u65F6\u56DE\u653E\u6700\u8FD1\u4E00\u5E27\uFF08\u4F5C\u8005\u811A\u672C\u5E38\u5728 DOMContentLoaded \u540E\u624D Register\uFF09
693
+ var lastMedia = {
694
+ properties: null,
695
+ thumbnail: null,
696
+ playback: null,
697
+ timeline: null,
698
+ status: null,
699
+ };
700
+
701
+ function callApplyUserProperties(props) {
702
+ if (!propertyListener || typeof propertyListener.applyUserProperties !== "function") return;
703
+ try {
704
+ propertyListener.applyUserProperties(props || {});
705
+ } catch (_) {
706
+ /* \u58C1\u7EB8\u811A\u672C\u629B\u9519\u4E0D\u6253\u65AD\u5BBF\u4E3B */
707
+ }
708
+ }
709
+
710
+ function callApplyGeneralProperties(props) {
711
+ if (!propertyListener || typeof propertyListener.applyGeneralProperties !== "function") return;
712
+ try {
713
+ propertyListener.applyGeneralProperties(props || {});
714
+ } catch (_) {
715
+ /* \u5FFD\u7565 */
716
+ }
717
+ }
718
+
719
+ function callSetPaused(v) {
720
+ if (!propertyListener || typeof propertyListener.setPaused !== "function") return;
721
+ try {
722
+ propertyListener.setPaused(!!v);
723
+ } catch (_) {
724
+ /* \u5FFD\u7565 */
725
+ }
726
+ }
727
+
728
+ function callDirectoryAdded(prop, files) {
729
+ if (!propertyListener || typeof propertyListener.userDirectoryFilesAddedOrChanged !== "function")
730
+ return;
731
+ try {
732
+ propertyListener.userDirectoryFilesAddedOrChanged(prop, files);
733
+ } catch (_) {
734
+ /* \u5FFD\u7565 */
735
+ }
736
+ }
737
+
738
+ function callDirectoryRemoved(prop, files) {
739
+ if (!propertyListener || typeof propertyListener.userDirectoryFilesRemoved !== "function") return;
740
+ try {
741
+ propertyListener.userDirectoryFilesRemoved(prop, files);
742
+ } catch (_) {
743
+ /* \u5FFD\u7565 */
744
+ }
745
+ }
746
+
747
+ function flushPending() {
748
+ if (pendingProps) {
749
+ var p = pendingProps;
750
+ pendingProps = null;
751
+ callApplyUserProperties(p);
752
+ }
753
+ if (pendingGeneral) {
754
+ var g = pendingGeneral;
755
+ pendingGeneral = null;
756
+ callApplyGeneralProperties(g);
757
+ }
758
+ }
759
+
760
+ /**
761
+ * \u5DE5\u574A\u5E38\u5728 React render \u91CC\u5199 \`window.wallpaperPropertyListener = {\u2026}\`\uFF082905017768\uFF09\u3002
762
+ * \u5B98\u65B9 CEF \u4E0D\u4F1A\u5728\u8D4B\u503C\u5F53\u4E0B\u540C\u6B65\u56DE\u8C03 setPaused/apply*\uFF1B\u82E5\u6211\u4EEC\u540C\u6B65 flush\uFF0C
763
+ * \u7B49\u4E8E render \u4E2D setState \u2192 React \u7194\u65AD \u2192 #root \u7A7A\uFF08\u4E00\u7247\u9ED1\uFF09\u3002
764
+ */
765
+ function afterAssign(fn) {
766
+ try {
767
+ if (typeof w.queueMicrotask === "function") w.queueMicrotask(fn);
768
+ else w.setTimeout(fn, 0);
769
+ } catch (_) {
770
+ try {
771
+ fn();
772
+ } catch (_) {
773
+ /* \u5FFD\u7565 */
774
+ }
775
+ }
776
+ }
777
+
778
+ function safeCall(fn, arg) {
779
+ if (typeof fn !== "function") return;
780
+ try {
781
+ fn(arg);
782
+ } catch (_) {
783
+ /* \u5FFD\u7565 */
784
+ }
785
+ }
786
+
787
+ // \u2014\u2014 \u5A92\u4F53\u96C6\u6210\u679A\u4E3E\uFF083747222633\uFF1A\u7F3A\u7701\u65F6 PLAYBACK_PLAYING||0 \u4F1A\u628A\u300C\u64AD\u653E\u300D\u5F53\u6210 0\uFF09\u2014\u2014
788
+ w.wallpaperMediaIntegration = {
789
+ PLAYBACK_STOPPED: 0,
790
+ PLAYBACK_PLAYING: 1,
791
+ PLAYBACK_PAUSED: 2,
792
+ };
793
+
794
+ // \u2014\u2014 \u5B98\u65B9 API\uFF1A\u97F3\u9891 \u2014\u2014
795
+ w.wallpaperRegisterAudioListener = function (cb) {
796
+ audioListener = typeof cb === "function" ? cb : null;
797
+ };
798
+
799
+ // \u2014\u2014 \u5B98\u65B9 API\uFF1A\u5A92\u4F53 \u2014\u2014
800
+ w.wallpaperRegisterMediaPropertiesListener = function (cb) {
801
+ mediaListeners.properties = typeof cb === "function" ? cb : null;
802
+ if (mediaListeners.properties && lastMedia.properties) {
803
+ safeCall(mediaListeners.properties, lastMedia.properties);
804
+ }
805
+ };
806
+ w.wallpaperRegisterMediaThumbnailListener = function (cb) {
807
+ mediaListeners.thumbnail = typeof cb === "function" ? cb : null;
808
+ if (mediaListeners.thumbnail && lastMedia.thumbnail) {
809
+ safeCall(mediaListeners.thumbnail, lastMedia.thumbnail);
810
+ }
811
+ };
812
+ w.wallpaperRegisterMediaPlaybackListener = function (cb) {
813
+ mediaListeners.playback = typeof cb === "function" ? cb : null;
814
+ if (mediaListeners.playback && lastMedia.playback) {
815
+ safeCall(mediaListeners.playback, lastMedia.playback);
816
+ }
817
+ };
818
+ w.wallpaperRegisterMediaTimelineListener = function (cb) {
819
+ mediaListeners.timeline = typeof cb === "function" ? cb : null;
820
+ if (mediaListeners.timeline && lastMedia.timeline) {
821
+ safeCall(mediaListeners.timeline, lastMedia.timeline);
822
+ }
823
+ };
824
+ w.wallpaperRegisterMediaStatusListener = function (cb) {
825
+ mediaListeners.status = typeof cb === "function" ? cb : null;
826
+ if (mediaListeners.status && lastMedia.status) {
827
+ safeCall(mediaListeners.status, lastMedia.status);
828
+ }
829
+ };
830
+
831
+ // \u2014\u2014 \u5B98\u65B9 API\uFF1A\u968F\u673A\u6587\u4EF6\uFF08slideshow\uFF09\u2014\u2014
832
+ // \u56DE\u8C03\u7B7E\u540D\uFF1Afunction(propertyName, filePath)\u3002\u65E0\u5E93\u5B58\u6587\u4EF6\u65F6 filePath \u4E3A\u7A7A\u4E32\uFF08\u8BED\u6599 if(i) \u5B88\u536B\uFF09\u3002
833
+ w.wallpaperRequestRandomFileForProperty = function (propertyName, callback) {
834
+ if (typeof callback !== "function") return;
835
+ var prop = String(propertyName || "");
836
+ var list = directoryFiles[prop];
837
+ var path = "";
838
+ if (list && list.length) {
839
+ path = String(list[(Math.random() * list.length) | 0] || "");
840
+ }
841
+ try {
842
+ callback(prop, path);
843
+ } catch (_) {
844
+ /* \u5FFD\u7565 */
845
+ }
846
+ };
847
+
848
+ // \u2014\u2014 PropertyListener\uFF08getter/setter\uFF1B\u56DE\u8C03\u5EF6\u540E\u5230\u5FAE\u4EFB\u52A1\uFF0C\u89C1 afterAssign\uFF09\u2014\u2014
849
+ // \u5B98\u65B9\u5728\u9875\u9762\u52A0\u8F7D\u5B8C\u6210\u540E\u624D\u53D1\u5168\u91CF\u5C5E\u6027/\u6682\u505C\u72B6\u6001\uFF1B\u9996\u5C4F\u811A\u672C\uFF08body onLoad=init \u7B49\uFF09\u5E38
850
+ // \u5047\u8BBE\u5C5E\u6027\u5230\u8FBE\u65F6 DOM/\u573A\u666F\u5DF2\u521D\u59CB\u5316\uFF08827982449\uFF1AapplyUserProperties\u2192cl() \u5728 load \u524D
851
+ // \u8DD1\u4F1A\u649E\u4E0A\u672A\u521B\u5EFA\u7684 scene/material\uFF09\u3002\u672A\u52A0\u8F7D\u5B8C\u6210\u65F6\u7B49 window load + \u4E00\u4E2A\u5B8F\u4EFB\u52A1
852
+ // \uFF08\u4FDD\u8BC1\u6392\u5728 onLoad \u5C5E\u6027\u5904\u7406\u5668\u4E4B\u540E\uFF09\uFF0C\u5DF2\u52A0\u8F7D\u5B8C\u6210\u5219\u5FAE\u4EFB\u52A1\u5373\u53D1\u3002
853
+ function whenPageReady(fn) {
854
+ var ready = "complete";
855
+ try {
856
+ ready = w.document.readyState;
857
+ } catch (_) {
858
+ /* \u5FFD\u7565 */
859
+ }
860
+ if (ready === "complete") {
861
+ afterAssign(fn);
862
+ return;
863
+ }
864
+ try {
865
+ w.addEventListener("load", function () {
866
+ // setTimeout \u4FDD\u8BC1\u6392\u5728 load \u540C\u6B65\u94FE\uFF08onLoad \u5904\u7406\u5668\uFF09\u4E4B\u540E
867
+ w.setTimeout(fn, 0);
868
+ }, { once: true });
869
+ } catch (_) {
870
+ afterAssign(fn);
871
+ }
872
+ }
873
+ Object.defineProperty(w, "wallpaperPropertyListener", {
874
+ configurable: true,
875
+ enumerable: true,
876
+ get: function () {
877
+ return propertyListener;
878
+ },
879
+ set: function (v) {
880
+ var next = v && typeof v === "object" ? v : null;
881
+ var prev = propertyListener;
882
+ propertyListener = next;
883
+ if (!next) return;
884
+ // \u4EC5\u9996\u6B21\u6CE8\u518C\u8865\u53D1\u6302\u8F7D\u72B6\u6001\u3002\u5B98\u65B9 CEF \u4ECE\u4E0D\u5728\u8D4B\u503C\u5F53\u4E0B\u56DE\u8C03\uFF1B2905017768 \u7B49 React \u58C1\u7EB8\u5728
885
+ // \u6E32\u67D3\u4F53\u91CC\u91CD\u65B0\u8D4B\u503C\uFF08\u65B0\u5BF9\u8C61\u5B57\u9762\u91CF\uFF09\uFF0C\u82E5\u6BCF\u6B21\u90FD\u8865 setPaused \u4F1A\u5F62\u6210
886
+ // \u6E32\u67D3 \u2192 \u8D4B\u503C \u2192 \u8865\u53D1 setState \u2192 \u518D\u6E32\u67D3 \u7684\u5FAE\u4EFB\u52A1\u6B7B\u5FAA\u73AF\uFF08\u70B9\u4E0B\u4E00\u66F2\u6574\u9875\u5361\u6B7B\uFF09\u3002
887
+ if (prev) return;
888
+ whenPageReady(function () {
889
+ flushPending();
890
+ callApplyGeneralProperties({ fps: fps });
891
+ callSetPaused(paused);
892
+ // \u5DF2\u7F13\u5B58\u7684\u76EE\u5F55\u6587\u4EF6\u8865\u63A8\u4E00\u6B21\uFF08\u4F5C\u8005\u53EF\u80FD\u540E\u6302 userDirectoryFilesAddedOrChanged\uFF09
893
+ for (var prop in directoryFiles) {
894
+ if (Object.prototype.hasOwnProperty.call(directoryFiles, prop) && directoryFiles[prop].length) {
895
+ callDirectoryAdded(prop, directoryFiles[prop].slice());
896
+ }
897
+ }
898
+ });
899
+ },
900
+ });
901
+
902
+ // \u2014\u2014 Plugin\uFF08iCUE \u7B49\uFF1B\u65E0\u786C\u4EF6\u65F6\u7A7A\u5B9E\u73B0\uFF0C\u907F\u514D if \u5224\u65AD\u5931\u8D25\uFF09\u2014\u2014
903
+ if (!w.wallpaperPluginListener) {
904
+ w.wallpaperPluginListener = {
905
+ onPluginLoaded: function () {},
906
+ };
907
+ }
908
+
909
+ // \u2014\u2014 \u5B9A\u65F6\u5668\u51BB\u7ED3\uFF1A\u5B98\u65B9\u6682\u505C = "fully freeze the process that renders the wallpaper"\uFF0C
910
+ // rAF \u5DF2\u5728\u8282\u6D41\u5C42\u6302\u8D77\uFF0C\u8FD9\u91CC\u51BB\u7ED3\u5B9A\u65F6\u5668\uFF1A\u6682\u505C\u671F\u95F4\u65B0\u5EFA\u7684\u6302\u8D77\u767B\u8BB0\u3001\u6062\u590D\u65F6\u6309\u539F\u5EF6\u8FDF/\u95F4\u9694
911
+ // \u91CD\u65B0\u542F\u52A8\uFF1B**\u5DF2\u542F\u52A8**\u7684\u771F\u5B9A\u65F6\u5668\u5230\u671F\u7531\u5305\u88C5\u56DE\u8C03\u62E6\u4E0B\u2014\u2014timeout \u8F6C\u6302\u8D77\uFF08\u6062\u590D\u540E\u7ACB\u5373\u8865\u8DD1\uFF0C
912
+ // \u8FD1\u4F3C\u5B98\u65B9\u7684\u5269\u4F59\u7B49\u5F85\uFF09\uFF0Cinterval \u76F4\u63A5\u8DF3\u8FC7\u8BE5\u5468\u671F\uFF08\u6062\u590D\u540E\u4ECE\u4E0B\u4E2A\u5468\u671F\u7EE7\u7EED\uFF09\u3002
913
+ var pendTimers = [];
914
+ var tmSeq = 0;
915
+ var TM_BASE = 0x40000000; // \u5047 id \u6BB5\uFF0C\u907F\u514D\u4E0E\u771F\u5B9E timer id \u6DF7\u6DC6
916
+ var origST = w.setTimeout;
917
+ var origSI = w.setInterval;
918
+ var origCTO = w.clearTimeout;
919
+ var origCIT = w.clearInterval;
920
+ function guardTimeout(fn) {
921
+ if (typeof fn !== "function") return fn;
922
+ return function () {
923
+ if (paused) {
924
+ pendTimers.push({ id: 0, kind: "t", fn: fn, ms: 1, extra: [] });
925
+ return;
926
+ }
927
+ return fn.apply(this, arguments);
928
+ };
929
+ }
930
+ function guardInterval(fn) {
931
+ if (typeof fn !== "function") return fn;
932
+ return function () {
933
+ if (paused) return;
934
+ return fn.apply(this, arguments);
935
+ };
936
+ }
937
+ function startTimer(kind, fn, ms, extra) {
938
+ if (paused) {
939
+ var id = TM_BASE + ++tmSeq;
940
+ pendTimers.push({ id: id, kind: kind, fn: fn, ms: ms, extra: extra });
941
+ return id;
942
+ }
943
+ var args = [kind === "t" ? guardTimeout(fn) : guardInterval(fn), ms].concat(extra);
944
+ return (kind === "t" ? origST : origSI).apply(w, args);
945
+ }
946
+ w.setTimeout = function (fn, ms) {
947
+ return startTimer("t", fn, ms, Array.prototype.slice.call(arguments, 2));
948
+ };
949
+ w.setInterval = function (fn, ms) {
950
+ return startTimer("i", fn, ms, Array.prototype.slice.call(arguments, 2));
951
+ };
952
+ function unpend(id) {
953
+ for (var i = 0; i < pendTimers.length; i++) {
954
+ if (pendTimers[i].id === id) {
955
+ pendTimers.splice(i, 1);
956
+ return true;
957
+ }
958
+ }
959
+ return false;
960
+ }
961
+ w.clearTimeout = function (id) {
962
+ if (unpend(id)) return;
963
+ origCTO.call(w, id);
964
+ };
965
+ w.clearInterval = function (id) {
966
+ if (unpend(id)) return;
967
+ origCIT.call(w, id);
968
+ };
969
+ function resumeTimers() {
970
+ var list = pendTimers;
971
+ pendTimers = [];
972
+ for (var i = 0; i < list.length; i++) {
973
+ var t = list[i];
974
+ (t.kind === "t" ? origST : origSI).call(w, t.fn, t.ms, t.extra);
975
+ }
976
+ }
977
+
978
+ /**
979
+ * \u6062\u590D\u6682\u505C\u671F\u95F4\u88AB\u6302\u8D77\u7684 rAF \u8BF7\u6C42\u3002
980
+ *
981
+ * **\u4E0D\u8865\u8DD1\u8FD9\u4E9B\u56DE\u8C03\uFF0C\u4E3B\u5FAA\u73AF\u5C31\u6C38\u4E45\u65AD\u6389**\uFF081278092907 Monstercat\uFF1A\`draw()\` \u5728\u51FD\u6570\u4F53
982
+ * \u5F00\u5934\u5C31 \`requestAnimationFrame(draw)\` \u518D\u753B\uFF0C\u6682\u505C\u671F\u95F4\u90A3\u6B21\u8BF7\u6C42\u88AB\u767B\u8BB0\u6210 hold\uFF0C
983
+ * \u6062\u590D\u540E\u6CA1\u4EBA\u8DD1\u5B83 \u2192 \u6574\u6761\u94FE\u6CA1\u6709\u4E0B\u4E00\u5E27\uFF0C\u753B\u9762\u6C38\u4E45\u5B9A\u683C\uFF0C\u4E14\u6CA1\u6709\u4EFB\u4F55\u62A5\u9519\uFF09\u3002
984
+ * \u8FD9\u662F rAF \u81EA\u9012\u5F52\u7684\u901A\u7528\u5F62\u6001\uFF0C\u4E0D\u662F\u8FD9\u4E00\u5F20\u7684\u7279\u4F8B\u3002
985
+ *
986
+ * \u8D70 \`w.requestAnimationFrame\` \u800C\u4E0D\u662F \`origRaf\`\uFF1A\u6B64\u65F6\u5DF2 unpaused\uFF0C\u8981\u8BA9\u5B83\u91CD\u65B0\u7ECF\u8FC7
987
+ * \u8282\u6D41\u5C42\uFF08\u4F4E fps \u65F6\u8BE5\u8D70 setTimeout \u8DEF\u5F84\uFF09\uFF0C\u5E76\u7167\u5E38\u53D1 we-frame \u6253\u70B9\u3002
988
+ */
989
+ function resumeRafHolds() {
990
+ var holds = [];
991
+ for (var id in rafMap) {
992
+ if (!Object.prototype.hasOwnProperty.call(rafMap, id)) continue;
993
+ if (rafMap[id] && rafMap[id].kind === "hold") {
994
+ holds.push(rafMap[id].cb);
995
+ delete rafMap[id];
996
+ }
997
+ }
998
+ for (var i = 0; i < holds.length; i++) {
999
+ try {
1000
+ w.requestAnimationFrame(holds[i]);
1001
+ } catch (_) {
1002
+ /* \u5355\u4E2A\u56DE\u8C03\u91CD\u6302\u5931\u8D25\u4E0D\u5F71\u54CD\u5176\u5B83 */
1003
+ }
1004
+ }
1005
+ }
1006
+
1007
+ // \u2014\u2014 \u5A92\u4F53\u97F3\u91CF\uFF1A\u5BF9\u9F50\u5B98\u65B9 CEF \u8BED\u4E49\uFF08\u6D4F\u89C8\u5668\u7EA7\u4E3B\u97F3\u91CF\u4E0E\u4F5C\u8005\u9875\u9762\u5185\u97F3\u91CF\u72EC\u7ACB\u76F8\u4E58\uFF09\u2014\u2014
1008
+ // \u4F5C\u8005\u5E38\u5728\u64AD\u653E\u524D\u91CD\u8BBE a.volume = uiVolume\uFF08Bocchi\uFF09\uFF0C\u4E14\u97F3\u9891\u591A\u4E3A \`new Audio()\` \u4E0D\u8FDB
1009
+ // DOM\u2014\u2014querySelectorAll \u627E\u4E0D\u5230\u3001\u76F4\u63A5\u8986\u76D6 volume \u53C8\u4F1A\u88AB\u4F5C\u8005\u56DE\u5199\u3002\u56E0\u6B64 hook \u539F\u578B\uFF1A
1010
+ // setter \u8BB0\u4F5C\u8005\u503C\uFF0C\u5143\u7D20\u5B9E\u9645\u97F3\u91CF = \u4F5C\u8005\u503C \xD7 \u4E3B\u97F3\u91CF\uFF1B\`__weSetVolume\` \u6539\u7CFB\u6570\u5E76\u5237\u65B0
1011
+ // \u5168\u90E8\u6D3B\u5B9E\u4F8B\uFF08DOM \u5185 + Audio \u6784\u9020\u5668\u767B\u8BB0\u7684 WeakRef\uFF09\u3002
1012
+ var hostVolume = 1;
1013
+ var liveMedia = []; // WeakRef<HTMLMediaElement>
1014
+ function trackMedia(el) {
1015
+ if (!w.WeakRef) return;
1016
+ liveMedia.push(new w.WeakRef(el));
1017
+ }
1018
+ function applyMediaVolume(el) {
1019
+ if (el.__weBaseVol != null) {
1020
+ mediaVolDesc.set.call(el, el.__weBaseVol * hostVolume);
1021
+ } else {
1022
+ mediaVolDesc.set.call(el, hostVolume);
1023
+ }
1024
+ var baseMuted = !!el.__weBaseMuted;
1025
+ mediaMutedDesc.set.call(el, baseMuted || hostVolume <= 0);
1026
+ }
1027
+ function refreshAllMediaVolume() {
1028
+ try {
1029
+ var nodes = w.document.querySelectorAll("audio,video");
1030
+ for (var i = 0; i < nodes.length; i++) applyMediaVolume(nodes[i]);
1031
+ } catch (_) {
1032
+ /* \u5FFD\u7565 */
1033
+ }
1034
+ for (var j = liveMedia.length - 1; j >= 0; j--) {
1035
+ var el = liveMedia[j].deref();
1036
+ if (!el) {
1037
+ liveMedia.splice(j, 1);
1038
+ continue;
1039
+ }
1040
+ applyMediaVolume(el);
1041
+ }
1042
+ }
1043
+ var mediaVolDesc = null;
1044
+ var mediaMutedDesc = null;
1045
+ function installMediaVolumeHooks() {
1046
+ try {
1047
+ if (!w.HTMLMediaElement || !w.HTMLMediaElement.prototype) return;
1048
+ var proto = w.HTMLMediaElement.prototype;
1049
+ mediaVolDesc = Object.getOwnPropertyDescriptor(proto, "volume");
1050
+ mediaMutedDesc = Object.getOwnPropertyDescriptor(proto, "muted");
1051
+ if (mediaVolDesc && typeof mediaVolDesc.set === "function") {
1052
+ Object.defineProperty(proto, "volume", {
1053
+ configurable: true,
1054
+ enumerable: mediaVolDesc.enumerable,
1055
+ get: function () {
1056
+ return this.__weBaseVol != null ? this.__weBaseVol : mediaVolDesc.get.call(this);
1057
+ },
1058
+ set: function (v) {
1059
+ this.__weBaseVol = Math.max(0, Math.min(1, Number(v) || 0));
1060
+ mediaVolDesc.set.call(this, this.__weBaseVol * hostVolume);
1061
+ },
1062
+ });
1063
+ }
1064
+ if (mediaMutedDesc && typeof mediaMutedDesc.set === "function") {
1065
+ Object.defineProperty(proto, "muted", {
1066
+ configurable: true,
1067
+ enumerable: mediaMutedDesc.enumerable,
1068
+ get: function () {
1069
+ return this.__weBaseMuted != null
1070
+ ? this.__weBaseMuted || hostVolume <= 0
1071
+ : mediaMutedDesc.get.call(this);
1072
+ },
1073
+ set: function (v) {
1074
+ this.__weBaseMuted = !!v;
1075
+ mediaMutedDesc.set.call(this, !!v || hostVolume <= 0);
1076
+ },
1077
+ });
1078
+ }
1079
+ // \`new Audio()\` \u4E0D\u8FDB DOM\uFF1A\u6784\u9020\u5668\u767B\u8BB0 WeakRef \u4EE5\u4FBF\u4E3B\u97F3\u91CF\u53D8\u5316\u65F6\u5237\u65B0
1080
+ if (typeof w.Audio === "function" && w.WeakRef) {
1081
+ var OrigAudio = w.Audio;
1082
+ function WrappedAudio(src) {
1083
+ var a = new OrigAudio(src);
1084
+ trackMedia(a);
1085
+ applyMediaVolume(a);
1086
+ return a;
1087
+ }
1088
+ WrappedAudio.prototype = OrigAudio.prototype;
1089
+ w.Audio = WrappedAudio;
1090
+ }
1091
+ } catch (_) {
1092
+ /* \u65E0\u5A92\u4F53\u73AF\u5883\u7684 verifier \u8DF3\u8FC7 */
1093
+ }
1094
+ }
1095
+ installMediaVolumeHooks();
1096
+
1097
+ // \u2014\u2014 \u7236\u9875\u63A7\u5236\u9762 \u2014\u2014
1098
+ // \u5B98\u65B9 setPaused \u53EA\u5728\u6682\u505C\u72B6\u6001\u5B9E\u9645\u53D8\u5316\u65F6\u8C03\u7528\u4E00\u6B21\uFF1B\u91CD\u590D\u8C03\u7528\u53BB\u91CD\u3002
1099
+ // \u6682\u505C\u8FD8\u8981\u51BB\u7ED3\u9875\u5185\u5A92\u4F53\uFF1A\u5B98\u65B9\u662F\u8FDB\u7A0B\u7EA7\u51BB\u7ED3\uFF08\u65E0\u58F0\u3001\u89E3\u7801\u5668\u53EF\u56DE\u6536\uFF09\uFF0C\u4F5C\u8005\u7684
1100
+ // setPaused \u5E38\u53EA\u7BA1\u81EA\u5DF1\u7684\u903B\u8F91\u3002\u53EA\u8BB0\u5F55\u300C\u6211\u4EEC\u4EE3\u4E3A\u6682\u505C\u300D\u7684\u5143\u7D20\uFF0C\u6062\u590D\u65F6\u4EC5\u8FD8\u539F\u8FD9\u90E8\u5206\uFF0C
1101
+ // \u4E0D\u78B0\u4F5C\u8005\u81EA\u5DF1\u6682\u505C\u7684\u3002
1102
+ var weFrozenMedia = [];
1103
+ function freezePageMedia() {
1104
+ weFrozenMedia.length = 0;
1105
+ try {
1106
+ var nodes = w.document.querySelectorAll("audio,video");
1107
+ for (var i = 0; i < nodes.length; i++) {
1108
+ if (!nodes[i].paused) {
1109
+ weFrozenMedia.push(nodes[i]);
1110
+ try {
1111
+ nodes[i].pause();
1112
+ } catch (_) {
1113
+ /* \u5FFD\u7565 */
1114
+ }
1115
+ }
1116
+ }
1117
+ } catch (_) {
1118
+ /* \u5FFD\u7565 */
1119
+ }
1120
+ }
1121
+ function thawPageMedia() {
1122
+ for (var i = 0; i < weFrozenMedia.length; i++) {
1123
+ try {
1124
+ var p = weFrozenMedia[i].play();
1125
+ if (p && p.catch) p.catch(function () {});
1126
+ } catch (_) {
1127
+ /* \u5FFD\u7565 */
1128
+ }
1129
+ }
1130
+ weFrozenMedia.length = 0;
1131
+ }
1132
+
1133
+ /**
1134
+ * \u6682\u505C\u8FD8\u8981\u51BB\u7ED3 **CSS \u52A8\u753B / \u8FC7\u6E21**\uFF08Web Animations \u65F6\u95F4\u8F74\uFF09\u3002
1135
+ *
1136
+ * rAF \u4E0E\u5B9A\u65F6\u5668\u51BB\u7ED3\u7BA1\u4E0D\u5230\u5B83\u4EEC\uFF1ACSS \`animation\` \u7531\u6D4F\u89C8\u5668**\u5408\u6210\u5668**\u72EC\u7ACB\u9A71\u52A8\uFF0C
1137
+ * \u4E0E JS \u4E3B\u7EBF\u7A0B\u65E0\u5173\u30021444432396 Glitch Clock \u7684\u6574\u4E2A\u89C6\u89C9\uFF08\u80CC\u666F\u79FB\u52A8\u3001\u6296\u52A8\u3001\u6545\u969C
1138
+ * \u95EA\u70C1\uFF09\u662F 10 \u5904 \`animation: \u2026 infinite\`\uFF0C\u53EA\u6709\u65F6\u949F\u6587\u5B57\u8D70 \`setInterval\` \u2014\u2014
1139
+ * \u6682\u505C\u540E\u753B\u9762\u7167\u65E7\u52A8\u4E2A\u4E0D\u505C\uFF0C\u7528\u6237\u770B\u5230\u7684\u5C31\u662F\u300C\u65E0\u6CD5\u6682\u505C\u300D\uFF08\u5B9E\u6D4B\u6682\u505C\u671F\u95F4 6 \u4E2A\u52A8\u753B
1140
+ * \u5168\u4E3A \`playState:"running"\`\uFF0C\`currentTime\` 700ms \u63A8\u8FDB\u6574 700ms\uFF09\u3002
1141
+ *
1142
+ * \u5B98\u65B9\u6682\u505C\u8BED\u4E49\u662F\u300Cfully freeze the process that renders the wallpaper\u300D\uFF0C
1143
+ * \u5408\u6210\u5668\u52A8\u753B\u81EA\u7136\u4E5F\u5728\u51BB\u7ED3\u8303\u56F4\u5185\u3002
1144
+ *
1145
+ * \u4E0E\u5A92\u4F53\u51BB\u7ED3\u540C\u4E00\u6761\u7EAA\u5F8B\uFF1A**\u53EA\u8BB0\u5F55\u6211\u4EEC\u4EE3\u4E3A\u6682\u505C\u7684**\uFF0C\u6062\u590D\u65F6\u4EC5\u8FD8\u539F\u8FD9\u90E8\u5206\u2014\u2014
1146
+ * \u4F5C\u8005\u81EA\u5DF1\u7528 \`animation-play-state: paused\` \u505C\u4E0B\u7684\uFF08\u5E38\u89C1\u4E8E hover \u624D\u64AD\u7684\u88C5\u9970\uFF09
1147
+ * \u4E0D\u80FD\u88AB\u6211\u4EEC\u5524\u9192\u3002\`getAnimations()\` \u62FF\u7684\u662F\u6D3B\u52A8\u52A8\u753B\u5BF9\u8C61\uFF0C\`pause()\`/\`play()\`
1148
+ * \u76F4\u63A5\u4F5C\u7528\u5728\u65F6\u95F4\u8F74\u4E0A\uFF0C\u6BD4\u6539 \`style.animationPlayState\` \u5E72\u51C0\uFF08\u540E\u8005\u4F1A\u6C61\u67D3\u4F5C\u8005\u7684
1149
+ * \u5185\u8054\u6837\u5F0F\uFF0C\u4E14\u88AB\u4F5C\u8005\u4E0B\u4E00\u6B21\u6837\u5F0F\u5199\u5165\u8986\u76D6\uFF09\u3002
1150
+ */
1151
+ var weFrozenAnims = [];
1152
+ function freezePageAnimations() {
1153
+ weFrozenAnims.length = 0;
1154
+ try {
1155
+ if (typeof w.document.getAnimations !== "function") return;
1156
+ var anims = w.document.getAnimations();
1157
+ for (var i = 0; i < anims.length; i++) {
1158
+ var a = anims[i];
1159
+ if (a && a.playState === "running") {
1160
+ weFrozenAnims.push(a);
1161
+ try {
1162
+ a.pause();
1163
+ } catch (_) {
1164
+ /* \u4E2A\u522B\u52A8\u753B\u4E0D\u53EF\u6682\u505C\u65F6\u8DF3\u8FC7 */
1165
+ }
1166
+ }
1167
+ }
1168
+ } catch (_) {
1169
+ /* \u65E7\u5F15\u64CE\u65E0 getAnimations\uFF1A\u9000\u5316\u4E3A\u4E0D\u51BB\u7ED3\uFF0C\u4E0D\u62A5\u9519 */
1170
+ }
1171
+ }
1172
+ function thawPageAnimations() {
1173
+ for (var i = 0; i < weFrozenAnims.length; i++) {
1174
+ try {
1175
+ weFrozenAnims[i].play();
1176
+ } catch (_) {
1177
+ /* \u5DF2\u88AB\u4F5C\u8005\u79FB\u9664\u7684\u52A8\u753B\u5FFD\u7565 */
1178
+ }
1179
+ }
1180
+ weFrozenAnims.length = 0;
1181
+ }
1182
+ w.__weSetPaused = function (v) {
1183
+ var next = !!v;
1184
+ if (next === paused) return;
1185
+ paused = next;
1186
+ if (paused) {
1187
+ callSetPaused(true);
1188
+ freezePageMedia();
1189
+ freezePageAnimations();
1190
+ } else {
1191
+ callSetPaused(false);
1192
+ thawPageMedia();
1193
+ thawPageAnimations();
1194
+ resumeTimers();
1195
+ // rAF \u6302\u8D77\u9879\u5FC5\u987B\u8865\u8DD1\uFF0C\u5426\u5219\u81EA\u9012\u5F52\u7684\u4E3B\u5FAA\u73AF\u6C38\u4E45\u65AD\u94FE\uFF081278092907\uFF09
1196
+ resumeRafHolds();
1197
+ }
1198
+ };
1199
+
1200
+ w.__weSetFps = function (n) {
1201
+ var next = Number(n);
1202
+ if (!Number.isFinite(next) || next <= 0) return;
1203
+ fps = next;
1204
+ callApplyGeneralProperties({ fps: fps });
1205
+ };
1206
+
1207
+ w.__weSetVolume = function (v) {
1208
+ var next = Math.max(0, Math.min(1, Number(v) || 0));
1209
+ volume = next;
1210
+ hostVolume = next;
1211
+ refreshAllMediaVolume();
1212
+ };
1213
+
1214
+ w.__weApplyProps = function (props) {
1215
+ if (!props || typeof props !== "object") return;
1216
+ // file \u5C5E\u6027\uFF1A\u503C\u662F\u8DEF\u5F84\u65F6\u767B\u8BB0\u8FDB\u968F\u673A\u6C60\uFF08\u5355\u6587\u4EF6 slideshow\uFF09
1217
+ try {
1218
+ for (var key in props) {
1219
+ if (!Object.prototype.hasOwnProperty.call(props, key)) continue;
1220
+ var ent = props[key];
1221
+ var val = ent && typeof ent === "object" && "value" in ent ? ent.value : ent;
1222
+ if (typeof val === "string" && val !== "" && /\\.(png|jpe?g|gif|webp|webm|mp4|bmp)$/i.test(val)) {
1223
+ directoryFiles[key] = [val];
1224
+ }
1225
+ }
1226
+ } catch (_) {
1227
+ /* \u5FFD\u7565 */
1228
+ }
1229
+ if (!propertyListener || typeof propertyListener.applyUserProperties !== "function") {
1230
+ pendingProps = props;
1231
+ return;
1232
+ }
1233
+ callApplyUserProperties(props);
1234
+ };
1235
+
1236
+ w.__weSeedProps = function (props) {
1237
+ if (!props || typeof props !== "object") return;
1238
+ if (propertyListener && typeof propertyListener.applyUserProperties === "function") {
1239
+ w.__weApplyProps(props);
1240
+ } else {
1241
+ pendingProps = props;
1242
+ }
1243
+ };
1244
+
1245
+ w.__wePushAudio = function (arr) {
1246
+ if (paused || !audioListener) return;
1247
+ try {
1248
+ audioListener(arr);
1249
+ } catch (_) {
1250
+ /* \u5FFD\u7565 */
1251
+ }
1252
+ };
1253
+
1254
+ /**
1255
+ * \u5A92\u4F53\u4E8B\u4EF6\u6CF5\u3002payload \u5F62\u6001\u5BF9\u9F50\u5B98\u65B9\uFF1A
1256
+ * { op:"properties", title, artist, album, albumArtist }
1257
+ * { op:"thumbnail", thumbnail, primaryColor, textColor, ... }
1258
+ * { op:"playback", state } // 0/1/2
1259
+ * { op:"timeline", position, duration }
1260
+ * { op:"status", enabled }
1261
+ */
1262
+ w.__wePushMedia = function (payload) {
1263
+ if (!payload || typeof payload !== "object") return;
1264
+ var op = payload.op;
1265
+ if (op === "properties") {
1266
+ lastMedia.properties = payload;
1267
+ safeCall(mediaListeners.properties, payload);
1268
+ } else if (op === "thumbnail") {
1269
+ lastMedia.thumbnail = payload;
1270
+ safeCall(mediaListeners.thumbnail, payload);
1271
+ } else if (op === "playback") {
1272
+ lastMedia.playback = payload;
1273
+ safeCall(mediaListeners.playback, payload);
1274
+ } else if (op === "timeline") {
1275
+ lastMedia.timeline = payload;
1276
+ safeCall(mediaListeners.timeline, payload);
1277
+ } else if (op === "status") {
1278
+ lastMedia.status = payload;
1279
+ safeCall(mediaListeners.status, payload);
1280
+ }
1281
+ };
1282
+
1283
+ /** \u76EE\u5F55\u6587\u4EF6\u5217\u8868\uFF08\u9996\u6B21\u6216\u8FFD\u52A0\uFF09\u3002files: string[] */
1284
+ w.__wePushDirectoryFiles = function (propertyName, files) {
1285
+ var prop = String(propertyName || "");
1286
+ if (!prop || !Array.isArray(files)) return;
1287
+ var cleaned = [];
1288
+ for (var i = 0; i < files.length; i++) {
1289
+ if (files[i] != null && String(files[i]) !== "") cleaned.push(String(files[i]));
1290
+ }
1291
+ if (!directoryFiles[prop]) directoryFiles[prop] = [];
1292
+ // \u9996\u6B21\u5168\u91CF\u66FF\u6362\u8BED\u4E49\u7531\u8C03\u7528\u65B9\u51B3\u5B9A\uFF1B\u8FD9\u91CC concat \u53BB\u91CD
1293
+ var seen = Object.create(null);
1294
+ for (var j = 0; j < directoryFiles[prop].length; j++) seen[directoryFiles[prop][j]] = 1;
1295
+ var added = [];
1296
+ for (var k = 0; k < cleaned.length; k++) {
1297
+ if (!seen[cleaned[k]]) {
1298
+ seen[cleaned[k]] = 1;
1299
+ directoryFiles[prop].push(cleaned[k]);
1300
+ added.push(cleaned[k]);
1301
+ }
1302
+ }
1303
+ if (added.length) callDirectoryAdded(prop, added);
1304
+ };
1305
+
1306
+ w.__weRemoveDirectoryFiles = function (propertyName, files) {
1307
+ var prop = String(propertyName || "");
1308
+ if (!prop || !Array.isArray(files) || !directoryFiles[prop]) return;
1309
+ var removeSet = Object.create(null);
1310
+ for (var i = 0; i < files.length; i++) removeSet[String(files[i])] = 1;
1311
+ var kept = [];
1312
+ var removed = [];
1313
+ for (var j = 0; j < directoryFiles[prop].length; j++) {
1314
+ var f = directoryFiles[prop][j];
1315
+ if (removeSet[f]) removed.push(f);
1316
+ else kept.push(f);
1317
+ }
1318
+ directoryFiles[prop] = kept;
1319
+ if (removed.length) callDirectoryRemoved(prop, removed);
1320
+ };
1321
+
1322
+ // \u2014\u2014 \u5916\u90E8\u6307\u9488\u6CE8\u5165\uFF08\u684C\u9762 underlay \u5C42\u6536\u4E0D\u5230\u9F20\u6807\u4E8B\u4EF6\uFF0C\u7236\u9875\u7ECF __wp.pushPointer \u63A8\u5165\uFF09\u2014\u2014
1323
+ //
1324
+ // \u573A\u666F\u58C1\u7EB8\u90A3\u6761\u901A\u9053\u662F\u300C\u5199\u4E00\u4E2A\u72B6\u6001\u5BF9\u8C61\u3001\u6E32\u67D3\u5668\u6BCF\u5E27\u8BFB\u300D\uFF08render/pointer.js\uFF09\uFF1B\u7F51\u9875\u58C1\u7EB8
1325
+ // \u6CA1\u6709\u8FD9\u6837\u7684\u5355\u4E00\u6D88\u8D39\u70B9 \u2014\u2014 \u4F5C\u8005\u4EE3\u7801\u5C31\u662F**\u76D1\u542C DOM \u4E8B\u4EF6**\u7684\uFF0C\u6240\u4EE5\u8FD9\u91CC\u5FC5\u987B\u628A\u63A8\u9001
1326
+ // \u8FD8\u539F\u6210\u4E00\u4E32\u5408\u6210\u4E8B\u4EF6\u3002\u8BED\u6599\uFF08\u672C\u673A 49 \u5F20 web\uFF09\uFF1Amousemove 24 \u5F20\u3001click 29 \u5F20\u3001
1327
+ // mouseover/out 17 \u5F20\u3001mouseenter/leave 8 \u5F20\u3001pointer* 16 \u5F20\uFF08createjs \u7CFB\u4E00\u5F8B\u8D70
1328
+ // pointerdown/move/up\uFF09\u3001.button 18 \u5F20\u3001.which 17 \u5F20\u3001pointerId/relatedTarget 15 \u5F20\u3002
1329
+ //
1330
+ // \u4E09\u6761\u8981\u70B9\uFF08\u90FD\u6709\u8BED\u6599\u4F9D\u636E\uFF0C\u6539\u9519\u4E86\u4F1A\u9759\u9ED8\u5931\u6548\uFF09\uFF1A
1331
+ //
1332
+ // 1. **\u5FC5\u987B elementFromPoint \u6309\u547D\u4E2D\u5143\u7D20\u6D3E\u53D1**\uFF0C\u4E0D\u80FD\u4E00\u5F8B\u6253 document\u3002\u4F5C\u8005\u65E2\u6709\u6302
1333
+ // document/window \u7684\uFF0815 \u5F20\uFF0C\u9760\u5192\u6CE1\u6536\u5230\uFF09\uFF0C\u4E5F\u6709\u6302 canvas \u4E0A\u8BFB \`event.offsetX\`
1334
+ // \u7684\uFF081748506393 \u6D41\u4F53 \`pointers[0].dx = (e.offsetX - \u2026)\`\uFF09\u3002offsetX/offsetY \u7531
1335
+ // \u6D4F\u89C8\u5668\u6309 target \u7684 padding box \u73B0\u7B97 \u2014\u2014 target \u6253\u9519\u5C31\u662F\u9519\u7684\u504F\u79FB\uFF0C\u4E14\u65E0\u4EFB\u4F55\u62A5\u9519\u3002
1336
+ // pageX/pageY \u540C\u7406\u7531 clientX + \u6EDA\u52A8\u91CF\u73B0\u7B97\uFF0C\u4E0D\u7528\u6211\u4EEC\u586B\u3002
1337
+ //
1338
+ // 2. **over/out/enter/leave \u94FE\u8981\u6309 W3C \u8BED\u4E49\u8865\u5168**\u30021748506393 \u9760 canvas \u7684
1339
+ // \`mouseenter\` \u628A \`pointers[0].down\` \u7F6E true\uFF08\u4E0D\u8FDB\u8FD9\u4E2A\u5206\u652F\u5219\u9F20\u6807\u600E\u4E48\u52A8\u90FD\u4E0D\u51FA\u67D3\u6599\uFF09\u3001
1340
+ // \u9760 window \u7684 \`mouseleave\` \u590D\u4F4D\uFF1B1081733658 animatedGrid \u9760 \`document.body\` \u7684
1341
+ // mouseover/mouseleave \u8D77\u505C\u6574\u4E2A\u7F51\u683C\u52A8\u753B\u3002leave/enter \u4E0D\u5192\u6CE1\uFF0C\u5FC5\u987B\u81EA\u5DF1\u6CBF\u7956\u5148\u94FE\u8D70\u5230
1342
+ // \u6700\u8FD1\u516C\u5171\u7956\u5148\uFF0C\u53EA\u53D1\u751F\u53D8\u5316\u7684\u90A3\u4E00\u6BB5\u3002
1343
+ //
1344
+ // 3. **click \u8981\u9760 down/up \u8FB9\u7F18\u5408\u6210**\uFF0C\u4E14 down \u4E0E up \u7684 target \u4E0D\u540C\uFF08\u62D6\u62FD\uFF09\u65F6\u4E0D\u53D1\u3002
1345
+ // 29 \u5F20\u542C click \u662F\u6700\u5927\u7684\u6D88\u8D39\u65B9\uFF1B\u8F6E\u8BE2\u63A8\u9001\u91CC\u6CA1\u6709\u300C\u70B9\u51FB\u300D\u8FD9\u4E2A\u4E8B\u4EF6\uFF0C\u53EA\u6709\u6309\u952E\u63A9\u7801\u7684
1346
+ // \u8DF3\u53D8\uFF0C\u8FB9\u7F18\u4E22\u4E86\u5C31\u7B49\u4E8E\u6574\u7C7B\u4EA4\u4E92\u6D88\u5931\u3002
1347
+ //
1348
+ // \u786C\u9650\u5236\uFF08\u5199\u5728\u8FD9\u91CC\u907F\u514D\u53CD\u590D\u8BD5\uFF09\uFF1ACSS \`:hover\` \u7531\u6D4F\u89C8\u5668\u81EA\u5DF1\u7684 hit-test \u9A71\u52A8\uFF0C\u5408\u6210\u4E8B\u4EF6
1349
+ // \u6C38\u8FDC\u70B9\u4E0D\u4EAE\u5B83\uFF0818 \u5F20\u542B \`:hover\`\uFF09\u2014\u2014 \u7EAF CSS hover \u52A8\u753B\u7684\u58C1\u7EB8\u65E0\u6CD5\u7528\u6CE8\u5165\u901A\u9053\u54CD\u5E94\uFF0C
1350
+ // \u8FD9\u4E0D\u662F\u5B9E\u73B0\u7F3A\u9677\uFF0C\u662F\u5408\u6210\u4E8B\u4EF6\u7684\u56FA\u6709\u8FB9\u754C\u3002
1351
+ var ptrHas = false; // \u662F\u5426\u6536\u5230\u8FC7\u63A8\u9001\uFF08\u9996\u5E27 movement \u5F52\u96F6\u7528\uFF09
1352
+ var ptrX = 0;
1353
+ var ptrY = 0;
1354
+ var ptrButtons = 0;
1355
+ var ptrTarget = null; // \u4E0A\u6B21\u547D\u4E2D\u5143\u7D20\uFF08over/out \u94FE\u7684\u65E7\u7AEF\uFF09
1356
+ var ptrDownTarget = null; // \u6309\u4E0B\u65F6\u7684\u547D\u4E2D\u5143\u7D20\uFF08click \u5224\u5B9A\uFF09
1357
+ var ptrLastClickTime = 0;
1358
+ var ptrLastClickTarget = null;
1359
+ /** \u53CC\u51FB\u5224\u5B9A\u7A97\u53E3\uFF08ms\uFF09\u3002\u4E0E\u4E3B\u6D41\u6D4F\u89C8\u5668\u4E00\u81F4\uFF0C\u8BED\u6599\u91CC 5 \u5F20\u542C dblclick\u3002 */
1360
+ var PTR_DBLCLICK_MS = 500;
1361
+
1362
+ function ptrRoot() {
1363
+ try {
1364
+ return w.document.body || w.document.documentElement || null;
1365
+ } catch (_) {
1366
+ return null;
1367
+ }
1368
+ }
1369
+
1370
+ function ptrHitTest(x, y) {
1371
+ try {
1372
+ if (typeof w.document.elementFromPoint === "function") {
1373
+ var el = w.document.elementFromPoint(x, y);
1374
+ if (el) return el;
1375
+ }
1376
+ } catch (_) {
1377
+ /* \u5FFD\u7565 */
1378
+ }
1379
+ return ptrRoot();
1380
+ }
1381
+
1382
+ /** node \u2192 [node, parent, \u2026, root]\uFF1B\u7528 parentNode \u800C\u975E parentElement\uFF0C
1383
+ * \u8FD9\u6837 document / documentElement \u4E5F\u5728\u94FE\u91CC\uFF08\u4F5C\u8005\u6302 document \u7684 leave \u8981\u6536\u5230\uFF09\u3002 */
1384
+ function ptrChain(node) {
1385
+ var out = [];
1386
+ var n = node;
1387
+ while (n) {
1388
+ out.push(n);
1389
+ try {
1390
+ n = n.parentNode || null;
1391
+ } catch (_) {
1392
+ n = null;
1393
+ }
1394
+ }
1395
+ return out;
1396
+ }
1397
+
1398
+ function ptrCommonAncestor(a, b) {
1399
+ if (!a || !b) return null;
1400
+ var ca = ptrChain(a);
1401
+ var seen = [];
1402
+ for (var i = 0; i < ca.length; i++) seen.push(ca[i]);
1403
+ var cb = ptrChain(b);
1404
+ for (var j = 0; j < cb.length; j++) {
1405
+ for (var k = 0; k < seen.length; k++) {
1406
+ if (seen[k] === cb[j]) return cb[j];
1407
+ }
1408
+ }
1409
+ return null;
1410
+ }
1411
+
1412
+ /**
1413
+ * \u9020\u4E00\u4E2A\u5408\u6210\u9F20\u6807/\u6307\u9488\u4E8B\u4EF6\u3002
1414
+ *
1415
+ * \`PointerEvent\` \u4F18\u5148\uFF1Acreatejs \u4E00\u65CF\uFF08\u8BED\u6599 7 \u5F20\uFF09\u53EA\u6302 pointerdown/move/up\uFF0C
1416
+ * \u4E14\u4F1A\u8BFB \`pointerId\` / \`pointerType\` / \`isPrimary\`\u3002\u73AF\u5883\u6CA1\u6709 PointerEvent \u65F6
1417
+ * \u9000\u56DE MouseEvent\uFF08\u4E8B\u4EF6\u540D\u7167\u65E7\uFF0C\u4F5C\u8005\u7684 addEventListener('pointermove') \u4ECD\u80FD\u6536\u5230\uFF09\u3002
1418
+ */
1419
+ function ptrMakeEvent(type, x, y, opts) {
1420
+ var o = opts || {};
1421
+ var isPointer = type.indexOf("pointer") === 0;
1422
+ var init = {
1423
+ bubbles: o.bubbles !== false,
1424
+ cancelable: o.cancelable !== false,
1425
+ // composed\uFF1A\u4F5C\u8005\u628A canvas \u653E\u8FDB shadow DOM \u65F6\u4E8B\u4EF6\u8981\u80FD\u7A7F\u51FA\u6765
1426
+ composed: true,
1427
+ view: w,
1428
+ detail: o.detail || 0,
1429
+ clientX: x,
1430
+ clientY: y,
1431
+ // screenX/screenY \u662F init \u5B57\u6BB5\uFF08\u4E0D\u50CF pageX/offsetX \u90A3\u6837\u73B0\u7B97\uFF09\u3002iframe \u91CC
1432
+ // \u53EA\u80FD\u6309\u5916\u5C42\u7A97\u53E3\u539F\u70B9\u8FD1\u4F3C\uFF1B16 \u5F20\u8BFB screenX\uFF0C\u591A\u7528\u4E8E\u7B97\u76F8\u5BF9\u4F4D\u79FB\u800C\u975E\u7EDD\u5BF9\u5B9A\u4F4D\u3002
1433
+ screenX: x + (Number(w.screenX) || 0),
1434
+ screenY: y + (Number(w.screenY) || 0),
1435
+ // button\uFF1A**\u79FB\u52A8/\u60AC\u505C\u7C7B\u4E8B\u4EF6\u5FC5\u987B\u662F -1**\uFF0C\u53EA\u6709 down/up/click \u624D\u662F 0\uFF08\u5DE6\uFF09/1\uFF08\u4E2D\uFF09/2\uFF08\u53F3\uFF09\u3002
1436
+ // \u8FD9\u6761\u662F W3C \u89C4\u5B9A\u7684\u300C\u6CA1\u6709\u6309\u952E\u72B6\u6001\u53D8\u5316\u300D\u54E8\u5175\u503C\uFF0C\u4E0D\u662F\u53EF\u7701\u7684\u7EC6\u8282\uFF1AGameMaker HTML5
1437
+ // \u5BFC\u51FA\u7684\u8FD0\u884C\u65F6\uFF082517518192 FNAF\uFF09\u5728 pointermove \u5206\u652F\u91CC\u7167\u6284 \`_tq = e.button\` \u518D
1438
+ // \`_mq |= (1 << _tq)\`\uFF0C\u800C _mq \u53EA\u5728 pointerup/out \u624D\u6E05\u96F6 \u2014\u2014 \u586B 0 \u7B49\u4E8E\u544A\u8BC9\u6E38\u620F
1439
+ // \u300C\u5DE6\u952E\u4E00\u76F4\u6309\u7740\u300D\uFF0C\u9F20\u6807\u53EA\u662F\u79FB\u8FC7\u53BB\u5C31\u6C38\u4E45\u5361\u5728\u6309\u4E0B\u6001\uFF08\u4E14\u6CA1\u6709\u4EFB\u4F55\u62A5\u9519\uFF09\u3002
1440
+ button: o.button != null ? o.button : -1,
1441
+ buttons: o.buttons != null ? o.buttons : ptrButtons,
1442
+ movementX: o.movementX || 0,
1443
+ movementY: o.movementY || 0,
1444
+ ctrlKey: false,
1445
+ shiftKey: false,
1446
+ altKey: false,
1447
+ metaKey: false,
1448
+ };
1449
+ if ("relatedTarget" in o) init.relatedTarget = o.relatedTarget || null;
1450
+ // \`button: -1\` \u65E0\u6CD5\u7ECF MouseEvent \u6784\u9020\u5668\u8868\u8FBE\uFF1AChromium \u628A -1 \u89C4\u8303\u5316\u6210 0
1451
+ // \uFF08\u5B9E\u6D4B \`new MouseEvent("x", {button:-1}).button === 0\`\uFF0C\u800C -2 \u80FD\u539F\u6837\u901A\u8FC7 \u2014\u2014
1452
+ // \u4E0D\u662F\u94B3\u4F4D\uFF0C\u662F\u5BF9 -1 \u7684\u7279\u6B8A\u5904\u7406\uFF09\u3002PointerEvent \u6784\u9020\u5668\u5219\u4FDD\u7559 -1\u3002
1453
+ // \u6240\u4EE5 mouse \u7C7B\u4E8B\u4EF6\u5FC5\u987B\u5728\u6784\u9020\u540E\u628A -1 \u76D6\u56DE\u53BB\uFF0C\u5426\u5219\u300C\u79FB\u52A8=\u5DE6\u952E\u6309\u4E0B\u300D\u7684\u5751
1454
+ // \u53EA\u5728 pointer \u8DEF\u5F84\u4FEE\u597D\u3001mouse \u8DEF\u5F84\u4F9D\u65E7\uFF082517518192 \u6070\u597D\u8D70 pointer\uFF0C
1455
+ // \u5149\u770B\u5B83\u4F1A\u8BEF\u4EE5\u4E3A\u5DF2\u7ECF\u4FEE\u5B8C\uFF09\u3002
1456
+ var needsButtonPatch = init.button < 0;
1457
+ var ev = null;
1458
+ if (isPointer) {
1459
+ init.pointerId = 1;
1460
+ init.pointerType = "mouse";
1461
+ init.isPrimary = true;
1462
+ init.width = 1;
1463
+ init.height = 1;
1464
+ init.pressure = init.buttons ? 0.5 : 0;
1465
+ try {
1466
+ if (typeof w.PointerEvent === "function") ev = new w.PointerEvent(type, init);
1467
+ } catch (_) {
1468
+ /* \u9000\u56DE MouseEvent */
1469
+ }
1470
+ }
1471
+ if (!ev) {
1472
+ try {
1473
+ if (typeof w.MouseEvent === "function") ev = new w.MouseEvent(type, init);
1474
+ } catch (_) {
1475
+ /* \u5FFD\u7565 */
1476
+ }
1477
+ }
1478
+ if (ev && needsButtonPatch && ev.button !== init.button) {
1479
+ try {
1480
+ Object.defineProperty(ev, "button", { configurable: true, get: function () {
1481
+ return init.button;
1482
+ } });
1483
+ } catch (_) {
1484
+ /* \u53EA\u8BFB\u4E14\u4E0D\u53EF\u91CD\u5B9A\u4E49\u65F6\u4FDD\u6301\u6784\u9020\u503C */
1485
+ }
1486
+ }
1487
+ return ev;
1488
+ }
1489
+
1490
+ function ptrDispatch(node, type, x, y, opts) {
1491
+ if (!node || typeof node.dispatchEvent !== "function") return;
1492
+ var ev = ptrMakeEvent(type, x, y, opts);
1493
+ if (!ev) return;
1494
+ try {
1495
+ node.dispatchEvent(ev);
1496
+ } catch (_) {
1497
+ /* \u4F5C\u8005\u5904\u7406\u5668\u629B\u9519\u4E0D\u6253\u65AD\u540E\u7EED\u4E8B\u4EF6\uFF08\u4E0E\u5B98\u65B9 CEF \u4E00\u81F4\uFF1A\u4E00\u4E2A\u574F listener \u4E0D\u8BE5
1498
+ \u8BA9\u6574\u6761\u94FE\u65AD\u6389\uFF0C\u5426\u5219 leave \u53D1\u4E0D\u51FA\u53BB\u4F1A\u7559\u4E0B\u6C38\u4E45 hover/\u6309\u4E0B\u6001\uFF09 */
1499
+ }
1500
+ }
1501
+
1502
+ /** \u547D\u4E2D\u5143\u7D20\u53D8\u5316\u65F6\u8865 out/leave + over/enter \u56DB\u6BB5\uFF0C\u987A\u5E8F\u4E0E\u6D4F\u89C8\u5668\u4E00\u81F4\u3002 */
1503
+ function ptrCrossBoundary(prev, next, x, y) {
1504
+ if (prev === next) return;
1505
+ var ancestor = ptrCommonAncestor(prev, next);
1506
+ if (prev) {
1507
+ ptrDispatch(prev, "pointerout", x, y, { relatedTarget: next });
1508
+ ptrDispatch(prev, "mouseout", x, y, { relatedTarget: next });
1509
+ var leaving = ptrChain(prev);
1510
+ for (var i = 0; i < leaving.length; i++) {
1511
+ if (leaving[i] === ancestor) break;
1512
+ // leave \u4E0D\u5192\u6CE1\uFF1A\u5FC5\u987B\u9010\u4E2A\u53D1\uFF0C\u4E14 target \u5C31\u662F\u5B83\u81EA\u5DF1
1513
+ ptrDispatch(leaving[i], "pointerleave", x, y, {
1514
+ bubbles: false,
1515
+ cancelable: false,
1516
+ relatedTarget: next,
1517
+ });
1518
+ ptrDispatch(leaving[i], "mouseleave", x, y, {
1519
+ bubbles: false,
1520
+ cancelable: false,
1521
+ relatedTarget: next,
1522
+ });
1523
+ }
1524
+ }
1525
+ if (next) {
1526
+ ptrDispatch(next, "pointerover", x, y, { relatedTarget: prev });
1527
+ ptrDispatch(next, "mouseover", x, y, { relatedTarget: prev });
1528
+ var entering = [];
1529
+ var chain = ptrChain(next);
1530
+ for (var j = 0; j < chain.length; j++) {
1531
+ if (chain[j] === ancestor) break;
1532
+ entering.push(chain[j]);
1533
+ }
1534
+ // enter \u7531\u5916\u5411\u5185\uFF08\u7956\u5148\u5148\u6536\u5230\uFF09\uFF0C\u4E0E\u6D4F\u89C8\u5668\u4E00\u81F4
1535
+ for (var k = entering.length - 1; k >= 0; k--) {
1536
+ ptrDispatch(entering[k], "pointerenter", x, y, {
1537
+ bubbles: false,
1538
+ cancelable: false,
1539
+ relatedTarget: prev,
1540
+ });
1541
+ ptrDispatch(entering[k], "mouseenter", x, y, {
1542
+ bubbles: false,
1543
+ cancelable: false,
1544
+ relatedTarget: prev,
1545
+ });
1546
+ }
1547
+ }
1548
+ }
1549
+
1550
+ /**
1551
+ * \u5916\u90E8\u6307\u9488\u6CE8\u5165\u5165\u53E3\u3002
1552
+ *
1553
+ * @param {number} x \u76F8\u5BF9 iframe \u89C6\u53E3\u5DE6\u8FB9\u7684 **CSS \u50CF\u7D20**\uFF08= clientX \u7A7A\u95F4\uFF09
1554
+ * @param {number} y \u540C\u4E0A\uFF0C\u76F8\u5BF9\u4E0A\u8FB9\uFF0CY \u671D\u4E0B
1555
+ * @param {number} [buttons] \u6309\u952E\u4F4D\u63A9\u7801\uFF0Cbit0 \u5DE6\u952E\u3002\u4E0E\u573A\u666F\u901A\u9053\u540C\u4E00\u7EA6\u5B9A\uFF0C
1556
+ * \u5F53\u524D\u53EA\u6D88\u8D39 bit0\uFF08\u53F3/\u4E2D\u952E\u4F4D\u4FDD\u7559\uFF1B\u684C\u9762\u53F3\u952E\u5C5E\u4E8E Finder\uFF0C\u4E0D\u8BE5\u88AB\u58C1\u7EB8\u52AB\u6301\uFF09
1557
+ *
1558
+ * \u63A5**\u50CF\u7D20**\u800C\u4E0D\u662F\u5F52\u4E00\u5316\u5750\u6807\uFF1A\u7F51\u9875\u58C1\u7EB8\u7684 iframe \u5728 cover \u9732\u5E95\u81EA\u9002\u914D\u4E0B\u53EF\u80FD\u6BD4\u821E\u53F0\u5927
1559
+ * \u5E76\u5E26\u5C45\u4E2D\u504F\u79FB\uFF08\u89C1 web.ts installLetterboxFix\uFF09\uFF0C\u6362\u7B97\u9700\u8981 iframe \u7684\u51E0\u4F55 \u2014\u2014 \u90A3\u662F\u7236\u9875
1560
+ * \u624D\u77E5\u9053\u7684\u4FE1\u606F\uFF0C\u7236\u9875\u6362\u7B97\u5B8C\u518D\u63A8\u8FDB\u6765\uFF0Cshim \u4E0D\u505A\u4E8C\u6B21\u9664\u6CD5\u3002
1561
+ *
1562
+ * \u6682\u505C\u671F\u95F4\u4E22\u5F03\uFF1A\u5B98\u65B9\u6682\u505C\u8BED\u4E49\u662F\u300C\u51BB\u7ED3\u6E32\u67D3\u8FDB\u7A0B\u300D\uFF0C\u6B64\u65F6\u6D3E\u53D1\u4E8B\u4EF6\u4F1A\u8BA9\u4F5C\u8005\u7684\u52A8\u753B\u72B6\u6001
1563
+ * \u5728\u51BB\u7ED3\u4E2D\u7EE7\u7EED\u63A8\u8FDB\uFF0C\u6062\u590D\u65F6\u753B\u9762\u8DF3\u4E00\u4E0B\u3002
1564
+ */
1565
+ w.__wePushPointer = function (x, y, buttons) {
1566
+ if (paused) return;
1567
+ var nx = Number(x);
1568
+ var ny = Number(y);
1569
+ // \u975E\u6709\u9650\u503C\u76F4\u63A5\u4E22\u5F03\uFF08\u4E0E\u573A\u666F\u901A\u9053\u540C\u4E00\u7EA6\u5B9A\uFF09\uFF1ANaN \u4F20\u8FDB clientX \u4F1A\u8BA9 elementFromPoint
1570
+ // \u8FD4\u56DE null\u3001\u540E\u7EED offsetX \u5168\u6210 NaN\uFF0C\u4F5C\u8005\u7684\u4F4D\u79FB\u79EF\u5206\u4F1A\u4E00\u6B21\u6027\u6C61\u67D3\u6210 NaN \u4E14\u4E0D\u62A5\u9519\u3002
1571
+ if (!isFinite(nx) || !isFinite(ny)) return;
1572
+ var mask = Number(buttons) || 0;
1573
+ var moved = !ptrHas || nx !== ptrX || ny !== ptrY;
1574
+ var maskChanged = mask !== ptrButtons;
1575
+ // \u4F4D\u7F6E\u4E0E\u6309\u952E\u90FD\u6CA1\u53D8\u5C31\u4EC0\u4E48\u90FD\u4E0D\u53D1\uFF1A\u5BBF\u4E3B\u6309 ~90Hz \u63A8\u9001\uFF0C\u9759\u6B62\u65F6\u91CD\u590D\u6D3E\u53D1
1576
+ // mousemove \u4F1A\u8BA9\u4F5C\u8005\u7684\u300C\u6709\u6CA1\u6709\u5728\u52A8\u300D\u5224\u5B9A\uFF081081733658 \u7F51\u683C\uFF09\u6C38\u8FDC\u8BA4\u4E3A\u5728\u52A8\u3002
1577
+ if (!moved && !maskChanged) return;
1578
+
1579
+ var dx = ptrHas ? nx - ptrX : 0;
1580
+ var dy = ptrHas ? ny - ptrY : 0;
1581
+ ptrX = nx;
1582
+ ptrY = ny;
1583
+ ptrHas = true;
1584
+
1585
+ var target = ptrHitTest(nx, ny);
1586
+ if (moved) {
1587
+ ptrCrossBoundary(ptrTarget, target, nx, ny);
1588
+ ptrTarget = target;
1589
+ ptrDispatch(target, "pointermove", nx, ny, { movementX: dx, movementY: dy });
1590
+ ptrDispatch(target, "mousemove", nx, ny, { movementX: dx, movementY: dy });
1591
+ } else {
1592
+ ptrTarget = target;
1593
+ }
1594
+
1595
+ if (!maskChanged) return;
1596
+ var wasDown = (ptrButtons & 1) !== 0;
1597
+ var isDown = (mask & 1) !== 0;
1598
+ ptrButtons = mask;
1599
+ if (isDown === wasDown) return; // \u53EA\u6709\u9AD8\u4F4D\u53D8\u5316\uFF1A\u5F53\u524D\u4E0D\u6D88\u8D39
1600
+ if (isDown) {
1601
+ ptrDownTarget = target;
1602
+ ptrDispatch(target, "pointerdown", nx, ny, { button: 0, detail: 1 });
1603
+ ptrDispatch(target, "mousedown", nx, ny, { button: 0, detail: 1 });
1604
+ return;
1605
+ }
1606
+ ptrDispatch(target, "pointerup", nx, ny, { button: 0, detail: 1 });
1607
+ ptrDispatch(target, "mouseup", nx, ny, { button: 0, detail: 1 });
1608
+ // click \u53EA\u5728 down/up \u843D\u5728\u540C\u4E00\u5143\u7D20\u4E0A\u65F6\u53D1\uFF08\u5426\u5219\u662F\u62D6\u62FD\uFF0C\u6D4F\u89C8\u5668\u4E5F\u4E0D\u53D1\uFF09
1609
+ if (ptrDownTarget && ptrDownTarget === target) {
1610
+ var now = Date.now();
1611
+ var isDouble =
1612
+ ptrLastClickTarget === target && now - ptrLastClickTime <= PTR_DBLCLICK_MS;
1613
+ ptrDispatch(target, "click", nx, ny, { button: 0, detail: isDouble ? 2 : 1 });
1614
+ if (isDouble) {
1615
+ ptrDispatch(target, "dblclick", nx, ny, { button: 0, detail: 2 });
1616
+ ptrLastClickTarget = null;
1617
+ ptrLastClickTime = 0;
1618
+ } else {
1619
+ ptrLastClickTarget = target;
1620
+ ptrLastClickTime = now;
1621
+ }
1622
+ }
1623
+ ptrDownTarget = null;
1624
+ };
1625
+
1626
+ /**
1627
+ * \u6307\u9488\u79BB\u5F00\u672C\u7A97\u53E3\uFF08\u9F20\u6807\u53BB\u4E86\u522B\u7684\u663E\u793A\u5668\uFF09\u3002
1628
+ *
1629
+ * \u4E0E\u573A\u666F\u901A\u9053\u4E0D\u540C\uFF0C\u8FD9\u91CC**\u5FC5\u987B\u628A out/leave \u94FE\u53D1\u51FA\u53BB**\uFF1A\u573A\u666F\u4FA7\u53EA\u662F\u6E05\u4E00\u4E2A\u72B6\u6001\u4F4D\uFF0C
1630
+ * \u800C\u7F51\u9875\u4F5C\u8005\u7684 hover \u6001\u662F\u81EA\u5DF1\u8BB0\u7684\uFF0C\u4E0D\u53D1 leave \u5C31\u6C38\u4E45\u5361\u5728\u300C\u9F20\u6807\u8FD8\u5728\u4E0A\u9762\u300D
1631
+ * \uFF081081733658 \u7F51\u683C\u4F1A\u4E00\u76F4\u8DD1\u30011748506393 \u7684 \`pointers[0].down\` \u4E00\u76F4\u4E3A true\uFF09\u3002
1632
+ * \u6309\u4E0B\u6001\u4E5F\u8981\u8865\u4E00\u6B21 up\uFF0C\u5426\u5219\u62D6\u62FD\u903B\u8F91\u6C38\u8FDC\u4E0D\u7ED3\u675F\u3002
1633
+ */
1634
+ w.__wePointerLeave = function () {
1635
+ if ((ptrButtons & 1) !== 0 && ptrTarget) {
1636
+ ptrDispatch(ptrTarget, "pointerup", ptrX, ptrY, { button: 0, buttons: 0, detail: 1 });
1637
+ ptrDispatch(ptrTarget, "mouseup", ptrX, ptrY, { button: 0, buttons: 0, detail: 1 });
1638
+ }
1639
+ ptrButtons = 0;
1640
+ ptrDownTarget = null;
1641
+ if (ptrTarget) {
1642
+ ptrCrossBoundary(ptrTarget, null, ptrX, ptrY);
1643
+ ptrTarget = null;
1644
+ }
1645
+ // \u4F4D\u7F6E\uFF08ptrX/ptrY\uFF09\u4E0E ptrHas \u4FDD\u7559\uFF1A\u4E0B\u6B21\u8FDB\u6765\u65F6 movement \u624D\u662F\u771F\u5B9E\u4F4D\u79FB\uFF0C
1646
+ // \u800C\u4E0D\u662F\u4ECE (0,0) \u8DF3\u8FC7\u6765\u7684\u4E00\u4E2A\u5DE8\u5927\u5047 delta\u3002
1647
+ };
1648
+
1649
+ // \u2014\u2014 rAF \u8282\u6D41\uFF08\u5E26 __weThrottled\uFF0C\u907F\u514D\u7236\u9875 injectGpuThrottle \u53CC\u5C42\u51CF\u534A\uFF09\u2014\u2014
1650
+
1651
+ function installRafThrottle() {
1652
+ var throttled = function (cb) {
1653
+ if (typeof cb !== "function") return 0;
1654
+ if (paused) {
1655
+ var idHold = ++rafCounter;
1656
+ rafMap[idHold] = { kind: "hold", cb: cb };
1657
+ return idHold;
1658
+ }
1659
+ var limit = fps >= 60 ? 0 : 1000 / fps;
1660
+ if (limit <= 0) {
1661
+ var idNative = origRaf(function (now) {
1662
+ delete rafMap[idNative];
1663
+ try {
1664
+ cb(now);
1665
+ } catch (_) {
1666
+ /* \u5FFD\u7565 */
1667
+ }
1668
+ try {
1669
+ w.parent.postMessage({ op: "we-frame", t: now }, "*");
1670
+ } catch (_) {
1671
+ /* \u5FFD\u7565 */
1672
+ }
1673
+ });
1674
+ rafMap[idNative] = { kind: "native", id: idNative };
1675
+ return idNative;
1676
+ }
1677
+ var id = ++rafCounter;
1678
+ var to = w.setTimeout(function () {
1679
+ delete rafMap[id];
1680
+ origRaf(function (now) {
1681
+ try {
1682
+ cb(now);
1683
+ } catch (_) {
1684
+ /* \u5FFD\u7565 */
1685
+ }
1686
+ try {
1687
+ w.parent.postMessage({ op: "we-frame", t: now }, "*");
1688
+ } catch (_) {
1689
+ /* \u5FFD\u7565 */
1690
+ }
1691
+ });
1692
+ }, limit);
1693
+ rafMap[id] = { kind: "timeout", to: to };
1694
+ return id;
1695
+ };
1696
+ throttled.__weThrottled = true;
1697
+ w.requestAnimationFrame = throttled;
1698
+ w.cancelAnimationFrame = function (id) {
1699
+ var ent = rafMap[id];
1700
+ if (!ent) {
1701
+ try {
1702
+ origCaf(id);
1703
+ } catch (_) {
1704
+ /* \u5FFD\u7565 */
1705
+ }
1706
+ return;
1707
+ }
1708
+ delete rafMap[id];
1709
+ if (ent.kind === "timeout") w.clearTimeout(ent.to);
1710
+ else if (ent.kind === "native") origCaf(ent.id);
1711
+ };
1712
+ }
1713
+
1714
+ installRafThrottle();
1715
+ })(window);
1716
+
1717
+ `;function qe(e,n){try{const t=e.iframe?.contentWindow;t&&n(t)}catch{}}function lu(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 uu=new Float32Array(128);function fu(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 du=1.8,pu=1.8,hu=30;function gs(e){const n=Number(e)||0;return n<=0?0:Math.min(1,Math.pow(n,pu)*du)}function mu(){const e=qi(),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]=gs(o[s]),t[s]=gs(i[s])):(n[s]=(Number(r.left64[s])||0)*.2,t[s]=(Number(r.right64[s])||0)*.2);return{left:n,right:t}}}}function gu(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 bu(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 yu(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 vu(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 xu(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=dn(e.cfg.fit)==="cover";o();const m=x&&d>0&&y>0?Pu(p):null,M=m?Eu(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 wu(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 Mu(e,n,t){e.pointerCtl={push(r){if(!n.isConnected)return;const o=t.getBoundingClientRect(),i=n.getBoundingClientRect(),s=wu(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 po(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),xu(e,i,t),o.injected&&Mu(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),An(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||lu(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 _u=.005,Au=.01,Tu=.2,Su=6;function Eu(e,n,t){if(!(e>0)||!(n>0)||!(t>0))return null;const r=e/n;if(Math.abs(r-t)<=_u)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 Pu(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*Au)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<Tu||u>Su))return{contentAspect:u}}return null}function cn(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 Cu(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,cn(r)),i.addColorStop(1,cn(o)),t.fillStyle=i,t.fillRect(0,0,64,64),n.toDataURL("image/jpeg",.85)}catch{return""}}function Lu(){return xe.createSimulatedMedia()}function Ru(e,n,t){const r=xe.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=Cu(t);qe(e,a=>a.__wePushMedia?.({op:"thumbnail",thumbnail:s,hasThumbnail:!!i.hasThumbnail||!!s,primaryColor:cn(i.primaryColor),secondaryColor:cn(i.secondaryColor),tertiaryColor:cn(i.tertiaryColor),textColor:cn(i.textColor),highContrastColor:cn(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 xe.cloneMediaSnapshot(t)}function bs(e,n,t,r={driver:null}){if(!n)return;const o=gu(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),hu);if(!(l-a<d*.85)){a=l;try{const y=i();y.tick?.(l);const x=y.snapshot(),m=fu(uu,x.left,x.right);qe(e,M=>M.__wePushAudio?.(m)),t&&l-t.last>200&&An(e,l)}catch{}}};s=requestAnimationFrame(c);const u=e.sceneCleanup;e.sceneCleanup=()=>{cancelAnimationFrame(s);try{u?.()}catch{}}}function ys(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=Ru(e,o,u.snapshot)}catch{}}};r=requestAnimationFrame(s);const a=e.sceneCleanup;e.sceneCleanup=()=>{cancelAnimationFrame(r);try{a?.()}catch{}}}function ku(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 Fu(e){try{return new URL(e,location.href).origin===location.origin}catch{return!1}}function Nu(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 Uu(e){try{const n=new URL("project.json",new URL(e,location.href)),t=await fetch(n.href,{credentials:"same-origin"});return t.ok?Nu(await t.json()):{}}catch{return{}}}function Du(e,n){const t={...e};if(n)for(const[r,o]of Object.entries(n))t[r]={value:o};return t}function Bu(e,n){rn(e),e.cfg=n;const t=yu(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}ku(e);const o=n,i=o._webAudio===null||e.audioDisabled?null:o._webAudio??mu(),s=o._webMedia===null||e.mediaDisabled?null:o._webMedia??Lu(),a=f=>{se(e,n,`\u7F51\u9875\u58C1\u7EB8 shim \u6CE8\u5165\u5931\u8D25\uFF08${f}\uFF09\uFF0C\u9000\u56DE\u88F8 iframe`),po(e,n,t,r,{injected:!1}),bs(e,null),ys(e,null);let p=0;const d=y=>{e.iframe&&(p=requestAnimationFrame(d),!e.paused&&An(e,y))};p=requestAnimationFrame(d),(e.wallpaperDisposers??=[]).push(()=>cancelAnimationFrame(p))},c={last:0},u={driver:null},l=()=>{if(bs(e,i,c,u),ys(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 ps({origin:location.origin});if(f.dead){try{p.dispose()}catch{}return}f.handle=p;const d=p.status();d.audio==="mic"?(u.driver=bu(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 Uu(r),p=Du(f,e.liveUserProps);if(e.liveUserProps=Object.fromEntries(Object.entries(p).map(([d,y])=>[d,y.value])),Fu(r)){po(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(su(y)){a("CSP \u963B\u6B62 inline script");return}const x=au(y,cu,{baseHref:iu(r),seedScript:vu(p,n.sceneFps,n.muted===!1?1:0)}),m=new Blob([x],{type:"text/html;charset=utf-8"}),M=URL.createObjectURL(m);po(e,n,t,M,{blobUrl:M,injected:!0,frameClock:c}),l()}catch(d){a(d instanceof Error?d.message:String(d))}})()}function Mr(e,n){const t=String(n.type??"").toLowerCase();n={...n,type:t},e.cfg=n,(t==="video"||t==="gif"||t==="image")&&n.src?Pl(e,n):t==="scene"&&(n.source||n.src)?ru(e,n):t==="web"&&n.src?Bu(e,n):e.onUnhandledType?.(n)}class Bt{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 Bt(this.x+n.x,this.y+n.y,this.z+n.z)}subtract(n){return new Bt(this.x-n.x,this.y-n.y,this.z-n.z)}multiply(n){return typeof n=="number"?new Bt(this.x*n,this.y*n,this.z*n):new Bt(this.x*n.x,this.y*n.y,this.z*n.z)}toString(){return`${this.x} ${this.y} ${this.z}`}}function gt(e,n,t){if(e instanceof Bt)return e;if(Array.isArray(e))return new Bt(e[0]??0,e[1]??0,e[2]??0);if(typeof e=="object"&&e!==null){const r=e;return new Bt(r.x??0,r.y??0,r.z??0)}return new Bt(e,n??0,t??0)}const Iu=[.35,.38,.45],Ou=[.12,.13,.17],$u=[.72,.76,.84],vs=[.95,.96,.98];function ju(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 xs(e){const n=Number(e.position)||0,t=Array.isArray(e.lyrics)?e.lyrics:[],{line:r,index:o}=ju(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:gt(e.primaryColor??Iu),secondaryColor:gt(e.secondaryColor??Ou),tertiaryColor:gt(e.tertiaryColor??$u),textColor:gt(e.textColor??vs),highContrastColor:gt(e.highContrastColor??e.textColor??vs),trackIndex:Number(e.trackIndex)||0,lyrics:t,lyricLine:r,lyricIndex:o}}function zu(e={},n={}){let t={...e},r=xs(t);return{get snapshot(){return r},set(o){t={...t,...o},r=xs(t)},update(){},skipNext:n.skipNext,skipPrevious:n.skipPrevious,play:n.play,pause:n.pause,playPause:n.playPause}}function Wu(e){return e==="fit"?"contain":e==="fill"?"cover":e==="contain"||e==="stretch"?e:"cover"}function Vu(e){const n=e?.type;return typeof n=="string"&&n.toLowerCase()==="web"}const ho=new Set(["video","gif","image"]);function Hu(e){const n=e?.type;if(typeof n!="string")return null;const t=n.toLowerCase();return ho.has(t)?t:null}function mo(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 ws(e,n){const t={fit:Wu(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(Vu(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=Hu(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=mo(e),l=ho.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=(ho.has(String(c).toLowerCase())?String(c).toLowerCase():null)??(a?lo(a):null);if(a&&u){const l=mo(e);return{...t,type:u,src:a,canvas:l,source:n.source}}}const s=mo(e);return{...t,type:"scene",canvas:s,source:n.source}}function Ms(e,n){const t=Ts(),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,Ao(t),t.sceneCtl?.resume()},get paused(){return!!t.paused},setFit(d){t.cfg.fit=d,Pr(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,Mr(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:gt(0,0,0),secondaryColor:gt(0,0,0),tertiaryColor:gt(0,0,0),textColor:gt(1,1,1),highContrastColor:gt(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 ws(i,o);x.type!=="web"&&x.canvas instanceof HTMLCanvasElement&&(i=x.canvas),t.cfg=x,t.paused=!1,t.info=void 0,Pr(t),o.properties&&(t.liveUserProps={...o.properties});const m=u(),M=l();Mr(t,x);try{await Promise.race([m,M.promise])}finally{M.off()}},release(){rn(t)},restore(){Mr(t,t.cfg)},destroy(){Ss(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 Ps(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 ws(e,d);y.type!=="web"&&y.canvas instanceof HTMLCanvasElement&&(i=y.canvas),t.cfg=y,t.paused=!1,t.info=void 0,Pr(t),d.properties&&Object.keys(d.properties).length&&(t.liveUserProps={...d.properties});const x=u(),m=l();Mr(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 Xu(e,n){const t=Ms(e,n);return await t.__applyOptions(n),t}Je.bytesSource=Ul,Je.createMediaSource=zu,Je.createScene=Ms,Je.fileSource=Nl,Je.httpSource=is,Je.mediaColor=gt,Je.mediaSource=Dl,Je.mount=Xu,Je.sniffMediaType=lo,Object.defineProperty(Je,Symbol.toStringTag,{value:"Module"})});
511
1719
 
512
1720
  //# sourceMappingURL=webwallgl.global.min.js.map