dsh-plugin-beyond-simulator 2.0.7 → 2.0.10

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,4 +1,4 @@
1
- import{parentPort as Dn}from"node:worker_threads";import{existsSync as ei,readFileSync as is}from"node:fs";import{randomUUID as ns}from"node:crypto";import{isAbsolute as Kn,win32 as Hn}from"node:path";function Xn(e,t=!1){let i=String(e??"").trim().replaceAll("\\","/");if(t&&(!i||i==="."))return"";if(!i||Kn(i)||Hn.isAbsolute(i)||i.split("/").some(n=>!n||n==="."||n===".."||/[<>:"|?*\x00-\x1f]/.test(n)||/[. ]$/.test(n)||/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test(n)))throw new Error("\u811A\u672C\u76EE\u5F55/\u8DEF\u5F84\u5FC5\u987B\u662F\u6709\u6548\u7684\u76F8\u5BF9\u8DEF\u5F84\uFF0C\u4E0D\u80FD\u5305\u542B .. \u6216 Windows \u7279\u6B8A\u6587\u4EF6\u540D");return i}function Pi(e){if(e==null)return null;if(e.version!==1)throw new Error("unsupported scriptSync version");let t=String(e.clientImportRoot||"").trim();if(!Kn(t)&&!Hn.isAbsolute(t))throw new Error("\u5B9E\u673A\u5BFC\u5165\u6839\u76EE\u5F55\u5FC5\u987B\u662F\u7EDD\u5BF9\u8DEF\u5F84");return{version:1,workspaceDir:Xn(e.workspaceDir,!0),clientImportRoot:t,clientSubdir:Xn(e.clientSubdir,!0)}}import{basename as kt,dirname as rs,isAbsolute as os,join as Do,resolve as zo}from"node:path";var se=Object.freeze(["KEYBOARD","TOUCHSCREEN","CONTROLLER_CONSOLE","CONTROLLER_MOBILE"]),ie=Object.freeze({"pc-16-9":{id:"pc-16-9",device:"pc",platform:"KEYBOARD",width:1600,height:900,ratio:"16:9",luaDevice:"KeyboardAndMouse",label:"PC 1600\xD7900"},"pc-21-9":{id:"pc-21-9",device:"pc",platform:"KEYBOARD",width:2100,height:900,ratio:"21:9",luaDevice:"KeyboardAndMouse",label:"PC 2100\xD7900"},"mobile-16-9":{id:"mobile-16-9",device:"mobile",platform:"TOUCHSCREEN",width:1280,height:720,ratio:"16:9",luaDevice:"Mobile",label:"\u624B\u673A 1280\xD7720"},"mobile-19.5-9":{id:"mobile-19.5-9",device:"mobile",platform:"TOUCHSCREEN",width:1560,height:720,ratio:"19.5:9",luaDevice:"Mobile",label:"\u624B\u673A 1560\xD7720"},"mobile-4-3":{id:"mobile-4-3",device:"mobile",platform:"TOUCHSCREEN",width:1280,height:960,ratio:"4:3",luaDevice:"Mobile",label:"\u624B\u673A 1280\xD7960"}}),oi="pc-16-9",pe=2,mt=Object.freeze({KEYBOARD:"pc-16-9",TOUCHSCREEN:"mobile-16-9",CONTROLLER_CONSOLE:"pc-16-9",CONTROLLER_MOBILE:"mobile-16-9"}),pt=Object.freeze({"server-container":"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u5BB9\u5668",container:"\u5BB9\u5668\u8282\u70B9",textbox:"\u6587\u672C\u6846",image:"\u56FE\u7247",button:"\u9884\u8BBE\u6309\u94AE",cursor:"\u5149\u6807\u68C0\u6D4B\u533A\u57DF",grid:"\u7F51\u683C\u89C6\u7A97",reference:"\u6A21\u677F\u5F15\u7528\u63A7\u4EF6",textwindow:"\u6587\u672C\u89C6\u7A97",keyhint:"\u6309\u952E\u63D0\u793A",animation:"\u754C\u9762\u52A8\u6548",fullscreen:"\u5168\u5C4F\u52A8\u6548"}),ai=Object.freeze(["server-container","container","textbox","cursor","reference","grid","image","button","textwindow","keyhint","animation","fullscreen"]),Ln=Object.freeze({"server-container":null,container:[150,150],textbox:[100,40],image:[80,80],button:[150,50],cursor:[150,50],grid:[80,80],reference:[80,80],textwindow:[100,40],keyhint:[40,40],animation:[100,100],fullscreen:null}),gt=Object.freeze({100001:"rect",100002:"circle",100003:"triangle",100004:"fourstar",100005:"fivestar",100006:"ring"}),Wn=50888,Ft=Object.freeze({font:4294967295,bg:16777215,outline:858993459,image:4294967295});function yt(e,t="$",i=new Set){if(e===void 0)throw new Error(`undefined at ${t}`);if(typeof e=="number"&&!Number.isFinite(e))throw new Error(`non-finite number at ${t}`);if(typeof e=="bigint"||typeof e=="function"||typeof e=="symbol")throw new Error(`non-JSON value at ${t}`);if(!(e===null||typeof e!="object")){if(i.has(e))throw new Error(`circular value at ${t}`);if(i.add(e),Array.isArray(e))e.forEach((n,r)=>yt(n,`${t}[${r}]`,i));else for(let[n,r]of Object.entries(e))yt(r,`${t}.${n}`,i);i.delete(e)}}function G(e){return yt(e),JSON.parse(JSON.stringify(e))}function jn(e,t="$"){yt(e,t)}function qn(e){return ie[e]||ie[oi]}function Ot(e,t=0,i=0){return!e||typeof e!="object"?{x:t,y:i}:{x:Number(e.x??t),y:Number(e.y??i)}}function la(e){return!e||typeof e!="object"?{x:1,y:1,z:1}:{x:Number(e.x??1),y:Number(e.y??1),z:Number(e.z??1)}}function sa(e){return!e||typeof e!="object"?{x:0,y:0,z:0}:{x:Number(e.x??0),y:Number(e.y??0),z:Number(e.z??0)}}function li({layout:e="center",size:t=[100,40],offset:i=[0,0]}={}){return e==="stretch"?{scale:{x:1,y:1,z:1},rotation:{x:0,y:0,z:0},anchorMin:{x:0,y:0},anchorMax:{x:1,y:1},offset:{x:0,y:0},size:{x:0,y:0},pivot:{x:.5,y:.5}}:{scale:{x:1,y:1,z:1},rotation:{x:0,y:0,z:0},anchorMin:{x:.5,y:.5},anchorMax:{x:.5,y:.5},offset:{x:Number(i[0]??0),y:Number(i[1]??0)},size:{x:Number(t[0]??0),y:Number(t[1]??0)},pivot:{x:.5,y:.5}}}function Re(e){let t=e||li();return{scale:la(t.scale),rotation:sa(t.rotation),anchorMin:Ot(t.anchorMin??t.anchor_min,.5,.5),anchorMax:Ot(t.anchorMax??t.anchor_max,.5,.5),offset:Ot(t.offset,0,0),size:Ot(t.size,0,0),pivot:Ot(t.pivot,.5,.5)}}function ge(e,t=0){let i=Number(e);return Number.isFinite(i)?i:t}function Ne(e,t){let i=e.width,n=e.height,r=e.left,o=e.bottom,a=t.anchorMin||{x:t.anchorMinX,y:t.anchorMinY},l=t.anchorMax||{x:t.anchorMaxX,y:t.anchorMaxY},c=t.offset||{x:t.anchoredPositionX,y:t.anchoredPositionY},s=t.size||{x:t.sizeDeltaX,y:t.sizeDeltaY},f=t.pivot||{x:t.pivotX,y:t.pivotY},m=ge(a?.x,.5)*i,h=ge(a?.y,.5)*n,g=ge(l?.x,.5)*i,b=ge(l?.y,.5)*n,w=ge(s?.x),M=ge(s?.y),E=ge(f?.x,.5),A=ge(f?.y,.5),U=g-m+w,$=b-h+M,q=r+m+ge(c?.x)-w*E,ee=o+h+ge(c?.y)-M*A;return{left:q,bottom:ee,width:U,height:$,right:q+U,top:ee+$,centerX:q+U/2,centerY:ee+$/2}}function bt(){return{a:1,b:0,c:0,d:1,tx:0,ty:0}}function ua(e,t){return{a:e.a*t.a+e.c*t.b,b:e.b*t.a+e.d*t.b,c:e.a*t.c+e.c*t.d,d:e.b*t.c+e.d*t.d,tx:e.a*t.tx+e.c*t.ty+e.tx,ty:e.b*t.tx+e.d*t.ty+e.ty}}function Je(e,t,i){return{x:e.a*t+e.c*i+e.tx,y:e.b*t+e.d*i+e.ty}}function si(e){let t=e.a*e.d-e.b*e.c;return!Number.isFinite(t)||Math.abs(t)<1e-8?null:{a:e.d/t,b:-e.b/t,c:-e.c/t,d:e.a/t,tx:(e.c*e.ty-e.d*e.tx)/t,ty:(e.b*e.tx-e.a*e.ty)/t}}function Mi(e,t){let i=t.rotation||{z:t.localRotationZ},n=t.scale||{x:t.localScaleX,y:t.localScaleY},r=t.pivot||{x:t.pivotX,y:t.pivotY},o=ge(i?.z)*Math.PI/180,a=Math.cos(o),l=Math.sin(o),c=ge(n?.x,1),s=ge(n?.y,1),f=e.left+e.width*ge(r?.x,.5),m=e.bottom+e.height*ge(r?.y,.5),h=a*c,g=l*c,b=-l*s,w=a*s;return{a:h,b:g,c:b,d:w,tx:f-h*f-b*m,ty:m-g*f-w*m}}function $t(e,t,i){return ua(e||bt(),Mi(t,i))}function Jn(e,t){let i=Je(t,e.centerX,e.centerY),n=Math.abs(e.width*Math.hypot(t.a,t.b)),r=Math.abs(e.height*Math.hypot(t.c,t.d));return{left:i.x-n/2,bottom:i.y-r/2,width:n,height:r,centerX:i.x,centerY:i.y,rotationZ:Math.atan2(t.b,t.a)*180/Math.PI}}function ye(e){let t=typeof e=="string"?qn(e):e;return{left:0,bottom:0,width:t.width,height:t.height,right:t.width,top:t.height,centerX:t.width/2,centerY:t.height/2}}function Ni(e){return{posX:e.centerX,posY:e.centerY,width:e.width,height:e.height}}function Ze(e,t,i){let n=Re(t),r=e.width,o=e.height,a=n.anchorMin.x*r,l=n.anchorMin.y*o,c=n.anchorMax.x*r,s=n.anchorMax.y*o,f=Number(i.width),m=Number(i.height),h=Number(i.posX),g=Number(i.posY),b=h-f/2,w=g-m/2;return n.size={x:f-(c-a),y:m-(s-l)},n.offset={x:b-e.left-a+n.size.x*n.pivot.x,y:w-e.bottom-l+n.size.y*n.pivot.y},n}function Zn(e,t){let i=Re(e),r={"bottom-left":[[0,0],[0,0],[0,0]],bottom:[[.5,0],[.5,0],[.5,0]],"bottom-right":[[1,0],[1,0],[1,0]],left:[[0,.5],[0,.5],[0,.5]],center:[[.5,.5],[.5,.5],[.5,.5]],right:[[1,.5],[1,.5],[1,.5]],"top-left":[[0,1],[0,1],[0,1]],top:[[.5,1],[.5,1],[.5,1]],"top-right":[[1,1],[1,1],[1,1]],stretch:[[0,0],[1,1],[.5,.5]],"stretch-horizontal":[[0,.5],[1,.5],[.5,.5]],"stretch-vertical":[[.5,0],[.5,1],[.5,.5]]}[t];return r&&(i.anchorMin={x:r[0][0],y:r[0][1]},i.anchorMax={x:r[1][0],y:r[1][1]},i.pivot={x:r[2][0],y:r[2][1]}),i}function Qn(e){let t=Re(e),i=(n,r)=>Math.abs(n-r)<1e-4;if(i(t.anchorMin.x,0)&&i(t.anchorMin.y,0)&&i(t.anchorMax.x,1)&&i(t.anchorMax.y,1))return"stretch";if(i(t.anchorMin.x,t.anchorMax.x)&&i(t.anchorMin.y,t.anchorMax.y)){let n=t.anchorMin.x,r=t.anchorMin.y,o=[[0,0,"bottom-left"],[.5,0,"bottom"],[1,0,"bottom-right"],[0,.5,"left"],[.5,.5,"center"],[1,.5,"right"],[0,1,"top-left"],[.5,1,"top"],[1,1,"top-right"]];for(let a of o)if(i(n,a[0])&&i(r,a[1]))return a[2]}return"custom"}function Qe(e){return qn(e).platform}function er(e){let t={};for(let i of se)t[i]=e(i);return t}var ca={scale:["x","y","z"],rotation:["x","y","z"],anchorMin:["x","y"],anchorMax:["x","y"],offset:["x","y"],size:["x","y"],pivot:["x","y"]};function tr(e,t){for(let[i,n]of Object.entries(ca))for(let r of n)if(!Number.isFinite(e?.[i]?.[r]))throw new Error(`${t}.${i}.${r} must be a finite number`)}function De(e,t="transformByPlatform"){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t}: \u9700\u8981\u5B8C\u6574\u7684\u56DB\u5E73\u53F0\u5E03\u5C40`);for(let i of Object.keys(e))if(!se.includes(i))throw new Error(`${t}: unknown platform ${i}`);for(let i of se)tr(e[i],`${t}.${i}`)}function et(e){if(Object.hasOwn(e,"transformByCanvas"))throw new Error(`${e.name||e.id||"\u63A7\u4EF6"}: \u4E0D\u518D\u652F\u6301 transformByCanvas\uFF1B\u8BF7\u4F7F\u7528\u56DB\u5E73\u53F0 transformByPlatform \u5E03\u5C40`);De(e.transformByPlatform,`${e.name||e.id||"\u63A7\u4EF6"}.transformByPlatform`)}function tt(e,t){if(!se.includes(t))throw new Error(`unknown platform ${t}`);return tr(e?.[t],`transformByPlatform.${t}`),Re(e[t])}var fa=Object.freeze([{key:"genericField501",label:"\u901A\u7528\u69FD field501",type:"number",defaultValue:0,wire:"GenericSlot.field501"},{key:"footerField505",label:"\u5C3E\u90E8\u69FD field505",type:"number",defaultValue:0,wire:"FooterSlot.field505"}]),da=Object.freeze({container:[],textbox:[{key:"textField501",label:"\u6587\u672C\u914D\u7F6E field501",type:"number",defaultValue:20,wire:"TextConfig.field501"},{key:"textField503",label:"\u6587\u672C\u914D\u7F6E field503",type:"number",defaultValue:12,wire:"TextConfig.field503"},{key:"textAlign",label:"\u6C34\u5E73\u5BF9\u9F50\u679A\u4E3E\u539F\u59CB\u503C",type:"enum",defaultValue:0,wire:"TextConfig.align",options:[{value:0,label:"0 \xB7 \u5DE6\u5BF9\u9F50"},{value:1,label:"1 \xB7 \u5C45\u4E2D"},{value:2,label:"2 \xB7 \u53F3\u5BF9\u9F50"}]}],textwindow:[{key:"textField501",label:"\u6587\u672C\u914D\u7F6E field501",type:"number",defaultValue:20,wire:"TextConfig.field501"},{key:"textField503",label:"\u6587\u672C\u914D\u7F6E field503",type:"number",defaultValue:12,wire:"TextConfig.field503"},{key:"textAlign",label:"\u6C34\u5E73\u5BF9\u9F50\u679A\u4E3E\u539F\u59CB\u503C",type:"enum",defaultValue:0,wire:"TextConfig.align",options:[{value:0,label:"0 \xB7 \u5DE6\u5BF9\u9F50"},{value:1,label:"1 \xB7 \u5C45\u4E2D"},{value:2,label:"2 \xB7 \u53F3\u5BF9\u9F50"}]},{key:"textField511",label:"\u6587\u672C\u89C6\u7A97 field511",type:"number",defaultValue:1,wire:"TextConfig.field511"},{key:"textViewField502",label:"\u89C6\u7A97\u6807\u8BB0 field502",type:"number",defaultValue:1,wire:"TextConfig.viewFlags.field502"},{key:"textViewField503",label:"\u89C6\u7A97\u6807\u8BB0 field503",type:"number",defaultValue:1,wire:"TextConfig.viewFlags.field503"}],cursor:[{key:"cursorField501",label:"\u5149\u6807\u68C0\u6D4B field501",type:"number",defaultValue:1,wire:"CursorConfig.field501"}],reference:[{key:"templateRefSlot",label:"\u6A21\u677F\u5F15\u7528\u69FD\u539F\u59CB\u503C",type:"string",defaultValue:"",wire:"Details.templateRefSlot"}],grid:[{key:"gridField501",label:"\u7F51\u683C\u6807\u8BB0 field501",type:"number",defaultValue:1,wire:"GridViewConfig.field501"},{key:"gridField507",label:"\u7F51\u683C\u6807\u8BB0 field507",type:"number",defaultValue:1,wire:"GridViewConfig.field507"},{key:"gridField508",label:"\u7F51\u683C\u6807\u8BB0 field508",type:"number",defaultValue:1,wire:"GridViewConfig.field508"},{key:"gridField509",label:"\u7F51\u683C\u6807\u8BB0 field509",type:"number",defaultValue:1,wire:"GridViewConfig.field509"},{key:"gridField511",label:"\u7F51\u683C\u6807\u8BB0 field511",type:"number",defaultValue:5,wire:"GridViewConfig.field511"},{key:"gridField512",label:"\u7F51\u683C\u6807\u8BB0 field512",type:"number",defaultValue:1,wire:"GridViewConfig.field512"}],keyhint:[{key:"keyHintField501",label:"\u6309\u952E\u63D0\u793A field501",type:"number",defaultValue:1,wire:"KeyHintConfig.field501"},{key:"keyHintField502",label:"\u952E\u9F20\u952E\u4F4D\u539F\u59CB\u503C",type:"number",defaultValue:1,wire:"KeyHintConfig.field502"}],image:[{key:"imageField502",label:"\u56FE\u7247\u6807\u8BB0 field502",type:"number",defaultValue:1,wire:"ImageConfig.field502"},{key:"imageField504",label:"\u56FE\u7247\u6807\u8BB0 field504",type:"number",defaultValue:1,wire:"ImageConfig.field504"},{key:"imageField505",label:"\u56FE\u7247\u6807\u8BB0 field505",type:"number",defaultValue:1,wire:"ImageConfig.field505"},{key:"imageField507",label:"\u56FE\u7247\u6807\u8BB0 field507",type:"number",defaultValue:2,wire:"ImageConfig.field507"},{key:"imageFillType",label:"\u586B\u5145\u5F62\u72B6\u679A\u4E3E\u539F\u59CB\u503C",type:"enum",defaultValue:1,wire:"ImageConfig.fillType",options:[{value:1,label:"1 \xB7 \u6A2A\u5411"},{value:2,label:"2 \xB7 \u7EB5\u5411"},{value:3,label:"3 \xB7 90\u5EA6\u73AF\u7ED5"},{value:4,label:"4 \xB7 180\u5EA6\u73AF\u7ED5"},{value:5,label:"5 \xB7 360\u5EA6\u73AF\u7ED5"}]}],animation:[{key:"effectSlot",label:"\u754C\u9762\u52A8\u6548\u69FD\u539F\u59CB\u503C",type:"string",defaultValue:"",wire:"Details.effectSlot"}],fullscreen:[{key:"fullscreenEffectSlot",label:"\u5168\u5C4F\u52A8\u6548\u69FD\u539F\u59CB\u503C",type:"string",defaultValue:"",wire:"Details.fullscreenEffectSlot"}]});function ir(e){return[...fa,...da[e]||[]]}function nr(e,t){return ir(e).find(i=>i.key===t)||null}function Fi(e,t){if(!e)throw new Error("unknown raw GIA field");if(e.type==="string")return String(t??"");let i=Number(t);if(!Number.isFinite(i))throw new Error(`${e.wire} must be a finite number`);return Math.trunc(i)}function rr(e,t={}){let i={};for(let n of ir(e)){let r=Object.hasOwn(t||{},n.key)?t[n.key]:n.defaultValue;i[n.key]=Fi(n,r)}return i}function we(e){let t=Number(e);return Number.isSafeInteger(t)&&t>0&&t<=2147483647}function Oi(e,t){if(e){t(e);for(let i of e.children||[])Oi(i,t)}}function vt(e,t=new Set,{skipServerContainer:i=!1}={}){return Oi(e,n=>{i&&n.kind==="server-container"||we(n.guid)&&t.add(Number(n.guid))}),t}function ze(e,t=1073741850){let i=Number.isSafeInteger(t)&&t>0?t:1073741850;i<1073741850&&(i=1073741850);for(let n of e)we(n)&&n>=i&&(i=Number(n)+1);for(;e.has(i);)i+=1;if(i>2147483647)throw new Error("GUID space exhausted");return i}function or(e,t=new Set,{skipServerContainer:i=!1}={}){let n=[];Oi(e,r=>{if(i&&r.kind==="server-container")return;let o=Number(r.guid);if(we(o)&&!t.has(o)){t.add(o),r.guid=o;return}n.push(r)});for(let r of n){let o=ze(t);r.guid=o,t.add(o)}return t}var $i=1;function Gi(e="n"){let t=`${e}${$i}`;return $i+=1,t}function ui(e=1){$i=e}function Di(e,{isRootContainer:t=!1}={}){if(e==="server-container"||e==="fullscreen"||e==="container"&&t)return li({layout:"stretch"});let i=Ln[e]||[80,80];return li({layout:"center",size:i})}function ha(e,t){return er(()=>Di(e,t))}function ma(e){De(e);let t={};for(let i of se)t[i]=tt(e,i);return t}function H(e,t={}){if(!pt[e])throw new Error(`unknown kind: ${e}`);Object.hasOwn(t,"transformByCanvas")&&et(t);let i=t.isRootContainer===!0,n=t.id||Gi(e==="server-container"?"sc":"n"),r=Object.hasOwn(t,"transformByPlatform")?ma(t.transformByPlatform):ha(e,{isRootContainer:i}),o={id:n,kind:e,name:t.name||pt[e],guid:t.guid??0,giaRelatedGuids:Array.isArray(t.giaRelatedGuids)?t.giaRelatedGuids.filter(a=>Number.isSafeInteger(Number(a))&&Number(a)>0).map(Number):[],...Number.isSafeInteger(Number(t.giaInfoIndex))&&Number(t.giaInfoIndex)>0?{giaInfoIndex:Number(t.giaInfoIndex)}:{},active:t.active!==!1,visible:t.visible!==!1,canControllerFocus:t.canControllerFocus??t.giaRaw?.footerField505===1,syncAllDevices:t.syncAllDevices!==!1,giaRaw:rr(e,t.giaRaw),transformByPlatform:r,children:[],scriptMappingIds:Array.isArray(t.scriptMappingIds)?t.scriptMappingIds.filter(a=>Number.isSafeInteger(Number(a))&&Number(a)>0).map(Number):[]};if(e==="container"&&(o.isolateNavigation=t.isolateNavigation===!0,o.disableKeyEventPassthrough=t.disableKeyEventPassthrough===!0,o.disableCursorEventPassthrough=t.disableCursorEventPassthrough===!0,o.showCursor=t.showCursor===!0),(e==="textbox"||e==="textwindow")&&(o.fontSize=t.fontSize??20,o.adaptiveFontSize=t.adaptiveFontSize===!0,o.minimumFontSize=t.minimumFontSize??20,o.fontColor=t.fontColor??Ft.font,o.bgColor=t.bgColor??Ft.bg,o.enableOutline=t.enableOutline!==!1,o.outlineColor=t.outlineColor??Ft.outline,o.horizontalAlignment=t.horizontalAlignment||"Left",o.verticalAlignment=t.verticalAlignment||"Top",Number.isInteger(t.giaRaw?.textVerticalAlign)&&![0,1,2].includes(t.giaRaw.textVerticalAlign)&&(o.giaRaw.textVerticalAlign=t.giaRaw.textVerticalAlign),o.text=t.text??"",Object.hasOwn(t.giaRaw||{},"textAlign")||(o.giaRaw.textAlign={Left:0,Middle:1,Right:2}[o.horizontalAlignment]??o.giaRaw.textAlign),e==="textwindow"&&(o.interactable=t.interactable!==!1,o.showScrollBar=t.showScrollBar!==!1)),e==="image"&&(o.imageSource=t.imageSource||"StaticReference",o.imageId=t.imageId??100001,o.imageColor=t.imageColor??Ft.image,o.enableMask=t.enableMask===!0,o.enableSoftEdge=t.enableSoftEdge===!0,o.softEdgeMode=t.softEdgeMode||"Percentage",o.softEdgeWidthX=t.softEdgeWidthX??8,o.softEdgeWidthY=t.softEdgeWidthY??8,o.horizontalSoftRange=t.horizontalSoftRange??85,o.verticalSoftRange=t.verticalSoftRange??85,o.enableFill=t.enableFill===!0,o.fillType=t.fillType||"Horizontal",o.fillHorizontalType=t.fillHorizontalType||"Left",o.fillVerticalType=t.fillVerticalType||"Bottom",o.fillRadial90Type=t.fillRadial90Type||"BottomLeft",o.fillRadialType=t.fillRadialType||"Bottom",o.fillAmount=t.fillAmount??1,o.reverseMaskArea=t.reverseMaskArea===!0||t.reverseMask===!0,Object.hasOwn(t.giaRaw||{},"imageFillType")||(o.giaRaw.imageFillType={Horizontal:1,Vertical:2,Radial90:3,Radial180:4,Radial360:5}[o.fillType]??o.giaRaw.imageFillType)),e==="button"&&(o.raycastTarget=t.raycastTarget!==!1,o.interactable=t.interactable!==!1,o.clickAudioId=t.clickAudioId??Wn,o.unavailableChildId=t.unavailableChildId??null,o.hoverChildId=t.hoverChildId??null,o.pressedChildId=t.pressedChildId??null,o.selectedChildId=t.selectedChildId??null),e==="cursor"&&(o.raycastTarget=t.raycastTarget??t.giaRaw?.cursorField501!==0),e==="reference"&&(o.referencedPrefabId=t.referencedPrefabId??t.giaRaw?.templateRefSlot??null,Object.hasOwn(t.giaRaw||{},"templateRefSlot")||(o.giaRaw.templateRefSlot=String(o.referencedPrefabId??""))),e==="grid"&&(o.itemPrefabId=t.itemPrefabId??null,o.raycastTarget=t.raycastTarget!==!1,o.interactable=t.interactable!==!1,o.showScrollBar=t.showScrollBar!==!1,o.scrollDirection=t.scrollDirection||"Vertical",o.layoutConstraint=t.layoutConstraint||"AutoWrap",o.layoutConstraintFixedCount=t.layoutConstraintFixedCount??null,o.cellSizeX=t.cellSizeX??50,o.cellSizeY=t.cellSizeY??50,o.spacingX=t.spacingX??8,o.spacingY=t.spacingY??8,o.padding1X=t.padding1X??20,o.padding1Y=t.padding1Y??20,o.padding2X=t.padding2X??20,o.padding2Y=t.padding2Y??20,o.previewCount=t.previewCount??t.giaRaw?.gridField511??5,Object.hasOwn(t.giaRaw||{},"gridField511")||(o.giaRaw.gridField511=Math.trunc(o.previewCount))),e==="keyhint"&&(o.keyboardKeyCode=t.keyboardKeyCode??t.giaRaw?.keyHintField502??null,o.controllerKeyCode=t.controllerKeyCode??t.giaRaw?.keyHintField501??null,Object.hasOwn(t.giaRaw||{},"keyHintField502")||(o.giaRaw.keyHintField502=Math.trunc(o.keyboardKeyCode??1)),Object.hasOwn(t.giaRaw||{},"keyHintField501")||(o.giaRaw.keyHintField501=Math.trunc(o.controllerKeyCode??1))),e==="animation"||e==="fullscreen"){let a=e==="animation"?t.giaRaw?.effectSlot:t.giaRaw?.fullscreenEffectSlot;o.animationId=t.animationId??a??null,o.playSoundEffect=t.playSoundEffect??null,e==="animation"&&(o.layer=t.layer??null);let l=e==="animation"?"effectSlot":"fullscreenEffectSlot";Object.hasOwn(t.giaRaw||{},l)||(o.giaRaw[l]=String(o.animationId??""))}if(t.children)for(let a of t.children)o.children.push(a);return o}function it(){ui(1);let e=H("server-container",{id:"sc1",name:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u5BB9\u5668"}),t=H("container",{id:"n1",name:"\u5BB9\u5668\u8282\u70B9",isRootContainer:!0}),i=H("textbox",{id:"n2",name:"\u6587\u672C\u6846",text:"\u6587\u672C"}),n=H("cursor",{id:"n3",name:"\u5149\u6807\u68C0\u6D4B\u533A\u57DF"}),r=H("reference",{id:"n4",name:"\u6A21\u677F\u5F15\u7528\u63A7\u4EF6"}),o=H("grid",{id:"n5",name:"\u7F51\u683C\u89C6\u7A97"}),a=H("button",{id:"n6",name:"\u9884\u8BBE\u6309\u94AE"}),l=H("textwindow",{id:"n7",name:"\u6587\u672C\u89C6\u7A97"}),c=H("keyhint",{id:"n8",name:"\u6309\u952E\u63D0\u793A"}),s=H("image",{id:"n9",name:"\u56FE\u7247",imageId:100005}),f=H("animation",{id:"n10",name:"\u754C\u9762\u52A8\u6548"}),m=H("fullscreen",{id:"n11",name:"\u5168\u5C4F\u52A8\u6548"}),h=(g,b,w)=>{for(let M of Object.values(g.transformByPlatform))M.offset={x:b,y:w}};return h(i,-300,250),h(n,-300,140),h(r,-300,30),h(o,-300,-100),h(a,0,0),h(l,300,250),h(c,300,140),h(s,300,30),h(f,300,-100),t.children.push(i,n,r,o,a,l,c,s,f,m),e.children.push(t),ui(12),or(e),{version:1,layoutSchemaVersion:pe,meta:{name:"\u672A\u547D\u540D\u754C\u9762\u63A7\u4EF6\u7EC4",assetType:"server-control-template",sourceFormat:"authoring",sourceFile:""},canvasId:"pc-16-9",selectedId:"n2",root:e}}function St(){ui(1);let e=H("server-container",{id:"sc1",name:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F"}),t=H("container",{id:"n1",guid:1073742100,name:"Lua\u5B9E\u4F8B\u5316\u9762\u677F"}),i=H("textbox",{id:"n2",guid:1073742101,name:"\u6A21\u677F\u6807\u9898",text:"\u5BA2\u6237\u7AEF\u6A21\u677F\u5DF2\u5B9E\u4F8B\u5316",fontSize:28,horizontalAlignment:"Middle"}),n=H("image",{id:"n3",guid:1073742102,name:"\u6A21\u677F\u56FE\u6807",imageId:100005}),r=H("button",{id:"n4",guid:1073742103,name:"\u786E\u8BA4\u6309\u94AE"}),o=H("textbox",{id:"n5",guid:1073742104,name:"\u6309\u94AE\u6587\u5B57",text:"\u786E\u8BA4",horizontalAlignment:"Middle",verticalAlignment:"Top"}),a=(c,s,f)=>{for(let m of Object.values(c.transformByPlatform))m.offset={x:s,y:f}};return((c,s,f)=>{for(let m of Object.values(c.transformByPlatform))m.size={x:s,y:f}})(t,520,320),a(i,0,110),a(n,0,0),a(r,0,-110),r.children.push(o),t.children.push(i,n,r),e.children.push(t),ui(6),{version:1,layoutSchemaVersion:pe,meta:{name:"Lua\u5B9E\u4F8B\u5316\u9762\u677F",assetType:"client-control-template",sourceFormat:"authoring",sourceFile:"",gameVersion:"7.0.50",giaOwnerUid:114514,giaFileId:1073741829,giaFileName:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u5217\u8868.gia"},canvasId:"pc-16-9",selectedId:"n1",root:e}}function j(e,t,i=null){t(e,i);for(let n of e.children||[])j(n,t,e)}function ce(e,t){let i=null;return j(e,n=>{n.id===t&&(i=n)}),i}function zi(e,t="n"){let i=Gi(t);for(;ce(e,i);)i=Gi(t);return i}function Ve(e,t){let i=null;return j(e,(n,r)=>{n.id===t&&(i=r)}),i}function Vi(e){let t=e.root||e;return t.kind==="container"?t:(t.children||[]).find(i=>i.kind==="container")||(t.children||[])[0]||t}function Gt(e){if(e.meta?.assetType!=="client-control-template")return Vi(e);let t=ce(e.root,e.selectedId);if(!t||t.kind==="server-container")return e.root.children?.[0]||e.root;let i=Ve(e.root,t.id);for(;i&&i.kind!=="server-container";)t=i,i=Ve(e.root,t.id);return t}function Yi(e){et(e);let t={id:e.id,name:e.name,guid:e.guid,giaRelatedGuids:e.giaRelatedGuids,giaInfoIndex:e.giaInfoIndex,scriptMappingIds:e.scriptMappingIds,giaRaw:e.giaRaw,active:e.active,visible:e.visible,canControllerFocus:e.canControllerFocus,syncAllDevices:e.syncAllDevices,transformByPlatform:e.transformByPlatform};e.kind==="container"&&(t.isolateNavigation=e.isolateNavigation,t.disableKeyEventPassthrough=e.disableKeyEventPassthrough,t.disableCursorEventPassthrough=e.disableCursorEventPassthrough,t.showCursor=e.showCursor),(e.kind==="textbox"||e.kind==="textwindow")&&(t.fontSize=e.fontSize,t.adaptiveFontSize=e.adaptiveFontSize,t.minimumFontSize=e.minimumFontSize,t.fontColor=e.fontColor,t.bgColor=e.bgColor,t.enableOutline=e.enableOutline,t.outlineColor=e.outlineColor,t.horizontalAlignment=e.horizontalAlignment,t.verticalAlignment=e.verticalAlignment,t.text=e.text??"",e.kind==="textwindow"&&(t.interactable=e.interactable,t.showScrollBar=e.showScrollBar)),e.kind==="image"&&(t.imageSource=e.imageSource,t.imageId=e.imageId,t.imageColor=e.imageColor,t.enableMask=e.enableMask,t.enableSoftEdge=e.enableSoftEdge,t.softEdgeMode=e.softEdgeMode,t.softEdgeWidthX=e.softEdgeWidthX,t.softEdgeWidthY=e.softEdgeWidthY,t.horizontalSoftRange=e.horizontalSoftRange,t.verticalSoftRange=e.verticalSoftRange,t.enableFill=e.enableFill,t.fillType=e.fillType,t.fillHorizontalType=e.fillHorizontalType,t.fillVerticalType=e.fillVerticalType,t.fillRadial90Type=e.fillRadial90Type,t.fillRadialType=e.fillRadialType,t.fillAmount=e.fillAmount,t.reverseMaskArea=e.reverseMaskArea??e.reverseMask),e.kind==="button"&&(t.raycastTarget=e.raycastTarget,t.interactable=e.interactable,t.clickAudioId=e.clickAudioId,t.unavailableChildId=e.unavailableChildId??null,t.hoverChildId=e.hoverChildId??null,t.pressedChildId=e.pressedChildId??null,t.selectedChildId=e.selectedChildId??null),e.kind==="cursor"&&(t.raycastTarget=e.raycastTarget),e.kind==="reference"&&(t.referencedPrefabId=e.referencedPrefabId??null),e.kind==="grid"&&(t.itemPrefabId=e.itemPrefabId??null,t.raycastTarget=e.raycastTarget,t.interactable=e.interactable,t.showScrollBar=e.showScrollBar,t.scrollDirection=e.scrollDirection,t.layoutConstraint=e.layoutConstraint,t.layoutConstraintFixedCount=e.layoutConstraintFixedCount??null,t.cellSizeX=e.cellSizeX,t.cellSizeY=e.cellSizeY,t.spacingX=e.spacingX,t.spacingY=e.spacingY,t.padding1X=e.padding1X,t.padding1Y=e.padding1Y,t.padding2X=e.padding2X,t.padding2Y=e.padding2Y,t.previewCount=e.previewCount),e.kind==="keyhint"&&(t.keyboardKeyCode=e.keyboardKeyCode??null,t.controllerKeyCode=e.controllerKeyCode??null),(e.kind==="animation"||e.kind==="fullscreen")&&(t.animationId=e.animationId??null,t.playSoundEffect=e.playSoundEffect??null,e.kind==="animation"&&(t.layer=e.layer??null)),t.isRootContainer=e.kind==="container"&&pa(e.transformByPlatform);let i=H(e.kind,t);return i.children=(e.children||[]).map(n=>Yi(n)),i}function pa(e){let t=e&&(e.KEYBOARD||Object.values(e)[0]);return t?Math.abs(t.anchorMin?.x??.5)<1e-4&&Math.abs(t.anchorMin?.y??.5)<1e-4&&Math.abs((t.anchorMax?.x??.5)-1)<1e-4&&Math.abs((t.anchorMax?.y??.5)-1)<1e-4:!1}function ar(e,t,i={}){if(e.kind==="server-container"&&t!=="container")throw new Error("server container only accepts container nodes");let n=H(t,i);return e.children.push(n),n}function lr(e,t){if(e.id===t)throw new Error("cannot remove root");let i=Ve(e,t);if(!i)return!1;let n=i.children.findIndex(r=>r.id===t);return n<0?!1:(i.children.splice(n,1),!0)}var sr=1e-4;function ga(e,t){return Math.abs(e.anchorMax[t]-e.anchorMin[t])>sr&&Math.abs(e.size[t])<=sr}function ya(e,t,i){if(!(t.width>0)||!(t.height>0))throw new Error("source parent must have positive size");if(!(i.width>0)||!(i.height>0))throw new Error("target parent must have positive size");let n=Ne(t,e),r=(n.centerX-t.left)/t.width,o=(n.centerY-t.bottom)/t.height,a=Ze(i,e,{posX:i.left+r*i.width,posY:i.bottom+o*i.height,width:n.width,height:n.height});for(let l of["x","y"])ga(e,l)&&(a.offset[l]=e.offset[l],a.size[l]=e.size[l]);return a}function ur({transformByPlatform:e,source:t,canvasId:i,syncAllDevices:n,sourceParentBox:r=ye(i),targetParentBoxByPlatform:o={}}){De(e);let a=Qe(i),l={};for(let c of se)c===a?l[c]=Re(t):n!==!1?l[c]=ya(t,r,o[c]||ye(mt[c])):l[c]=tt(e,c);return De(l),l}function Ye(e,t){return tt(e,Qe(t))}function cr(e,t){let i=[];function n(r){t[r.id]&&i.push(t[r.id]);let o=r.children||[];for(let a=o.length-1;a>=0;a-=1)n(o[a])}return n(e),i}function Ue(e,t,i=Qe(t)){let n=ye(t),r={};function o(a,l,c){let s=tt(a.transformByPlatform,i),f=Ne(l,s),m=a.kind==="server-container"?c:$t(c,f,s),h=Jn(f,m);r[a.id]={...f,...Ni(f),id:a.id,kind:a.kind,name:a.name,visible:a.visible!==!1,active:a.active!==!1,rotationZ:s.rotation.z,renderLeft:h.left,renderBottom:h.bottom,renderWidth:h.width,renderHeight:h.height,renderRotationZ:h.rotationZ,renderMatrix:m,primitive:a.kind==="image"?gt[a.imageId]||"missing":null,...a.kind==="textbox"||a.kind==="textwindow"?{text:a.text??"",fontSize:a.fontSize,fontColor:a.fontColor,bgColor:a.bgColor,enableOutline:a.enableOutline!==!1,outlineColor:a.outlineColor,horizontalAlignment:a.horizontalAlignment,verticalAlignment:a.verticalAlignment}:{},...a.kind==="image"?{imageSource:a.imageSource,imageId:a.imageId,imageColor:a.imageColor,enableMask:a.enableMask===!0,enableSoftEdge:a.enableSoftEdge===!0,softEdgeMode:a.softEdgeMode,softEdgeWidthX:a.softEdgeWidthX,softEdgeWidthY:a.softEdgeWidthY,horizontalSoftRange:a.horizontalSoftRange,verticalSoftRange:a.verticalSoftRange,enableFill:a.enableFill===!0,fillType:a.fillType,fillHorizontalType:a.fillHorizontalType,fillVerticalType:a.fillVerticalType,fillRadial90Type:a.fillRadial90Type,fillRadialType:a.fillRadialType,fillAmount:a.fillAmount,reverseMaskArea:a.reverseMaskArea===!0}:{},...a.kind==="button"?{raycastTarget:a.raycastTarget!==!1,interactable:a.interactable!==!1,clickAudioId:a.clickAudioId,unavailableChildId:a.unavailableChildId??null,hoverChildId:a.hoverChildId??null,pressedChildId:a.pressedChildId??null,selectedChildId:a.selectedChildId??null}:{}};let g=a.kind==="server-container"?l:f;for(let b of a.children||[])o(b,g,m)}return o(e,n,bt()),{canvas:n,boxes:r}}function Ui(e,t){let i=[];function n(r,o,a=null,l=[],c=0,s=1,f=e.id){i.push({id:r.id,guid:t?.get(r.id)??(r.guid||0),kind:r.kind,name:r.name,label:pt[r.kind]||r.kind,depth:o,parentId:a,ancestorIds:l,siblingIndex:c,siblingCount:s,templateId:f,childCount:(r.children||[]).length,incomplete:!ai.includes(r.kind)});let m=r.children||[];for(let h=0;h<m.length;h+=1)n(m[h],o+1,r.id,[...l,r.id],h,m.length,f)}return n(e,0),i}function T(e,t,i,n,r={}){return{key:e,label:t,type:i,value:n,...r}}function fr(e,t,i,n){if(!e)return null;let r=Ye(e.transformByPlatform,t),o=Ni(i),a=[T("name","\u540D\u79F0","string",e.name),T("active","\u521D\u59CB\u6FC0\u6D3B","bool",e.active!==!1),T("visible","\u521D\u59CB\u53EF\u89C1\u6027","bool",e.visible!==!1),T("canControllerFocus","\u53EF\u88AB\u624B\u67C4\u6447\u6746\u5BFC\u822A\u9009\u4E2D","bool",e.canControllerFocus===!0),T("posX","\u4F4D\u7F6E X","number",o.posX,{computed:!0}),T("posY","\u4F4D\u7F6E Y","number",o.posY,{computed:!0}),T("width","\u5927\u5C0F W","number",o.width,{computed:!0}),T("height","\u5927\u5C0F H","number",o.height,{computed:!0}),T("rotationZ","\u65CB\u8F6C Z","number",r.rotation.z),T("syncAllDevices","\u540C\u6B65\u4FE1\u606F\u81F3\u6240\u6709\u8BBE\u5907","bool",e.syncAllDevices!==!1),T("anchorType","\u951A\u70B9\u7C7B\u578B","enum",Qn(r),{options:[{value:"center",label:"\u5C45\u4E2D"},{value:"top-left",label:"\u5DE6\u4E0A"},{value:"top",label:"\u4E0A\u65B9"},{value:"top-right",label:"\u53F3\u4E0A"},{value:"left",label:"\u5DE6\u4FA7"},{value:"right",label:"\u53F3\u4FA7"},{value:"bottom-left",label:"\u5DE6\u4E0B"},{value:"bottom",label:"\u4E0B\u65B9"},{value:"bottom-right",label:"\u53F3\u4E0B"},{value:"stretch",label:"\u53CC\u5411\u62C9\u4F38"},{value:"stretch-horizontal",label:"\u6C34\u5E73\u62C9\u4F38"},{value:"stretch-vertical",label:"\u5782\u76F4\u62C9\u4F38"},{value:"custom",label:"\u81EA\u5B9A\u4E49"}]}),T("anchorMinX","\u951A\u70B9 Min X","number",r.anchorMin.x),T("anchorMinY","\u951A\u70B9 Min Y","number",r.anchorMin.y),T("anchorMaxX","\u951A\u70B9 Max X","number",r.anchorMax.x),T("anchorMaxY","\u951A\u70B9 Max Y","number",r.anchorMax.y),T("pivotX","\u4E2D\u5FC3 X","number",r.pivot.x),T("pivotY","\u4E2D\u5FC3 Y","number",r.pivot.y)];if(e.kind==="container"&&a.push(T("isolateNavigation","\u9694\u79BB\u624B\u67C4\u5BFC\u822A","bool",e.isolateNavigation===!0),T("disableKeyEventPassthrough","\u5C4F\u853D\u6309\u952E\u4E8B\u4EF6\u7A7F\u900F","bool",e.disableKeyEventPassthrough===!0),T("disableCursorEventPassthrough","\u5C4F\u853D\u533A\u57DF\u5185\u70B9\u51FB\u4E8B\u4EF6\u7A7F\u900F","bool",e.disableCursorEventPassthrough===!0),T("showCursor","\u663E\u793A\u5E38\u9A7B\u5149\u6807","bool",e.showCursor===!0)),e.kind==="textbox"||e.kind==="textwindow"){let l=e.giaRaw?.textAlign,c=[0,1,2].includes(l)?e.horizontalAlignment||"Left":`__unrecognized:${l}`;a.push(T("fontSize","\u5B57\u53F7","number",e.fontSize),T("adaptiveFontSize","\u5B57\u53F7\u81EA\u9002\u5E94","bool",e.adaptiveFontSize===!0),T("minimumFontSize","\u6700\u5C0F\u5B57\u53F7","number",e.minimumFontSize),T("fontColor","\u6587\u672C\u8272","color",e.fontColor),T("bgColor","\u80CC\u666F\u8272","color",e.bgColor),T("enableOutline","\u542F\u7528\u63CF\u8FB9","bool",e.enableOutline!==!1),T("outlineColor","\u63CF\u8FB9\u8272","color",e.outlineColor),T("horizontalAlignment","\u6C34\u5E73\u5BF9\u9F50","enum",c,{...[0,1,2].includes(l)?{}:{unknownValue:l},options:[{value:"Left",label:"\u5DE6\u5BF9\u9F50"},{value:"Middle",label:"\u5C45\u4E2D"},{value:"Right",label:"\u53F3\u5BF9\u9F50"}]}),T("verticalAlignment","\u5782\u76F4\u5BF9\u9F50","enum",e.verticalAlignment||"Top",{options:[{value:"Top",label:"\u9876\u90E8"},{value:"Middle",label:"\u5C45\u4E2D"},{value:"Bottom",label:"\u5E95\u90E8"}]}),T("text","\u6587\u672C","text",e.text??""))}if(e.kind==="image"){let l=e.giaRaw?.imageFillType,c=[1,2,3,4,5].includes(l)?e.fillType:`__unrecognized:${l}`;a.push(T("imageSource","\u56FE\u7247\u6E90","enum",e.imageSource,{readonly:!0,evidence:"W",options:[{value:"StaticReference",label:"\u9759\u6001\u5F15\u7528"}]}),T("imageId","imageId","number",e.imageId??0),T("imageColor","\u586B\u5145\u8272","color",e.imageColor),T("enableMask","\u5F00\u542F\u906E\u7F69","bool",e.enableMask===!0),T("enableSoftEdge","\u8FB9\u7F18\u7FBD\u5316","bool",e.enableSoftEdge===!0,{gia:"W"}),T("softEdgeMode","\u7FBD\u5316\u6A21\u5F0F","enum",e.softEdgeMode,{options:[{value:"Percentage",label:"\u767E\u5206\u6BD4"},{value:"Pixel",label:"\u50CF\u7D20"}]}),T("softEdgeWidthX","\u7FBD\u5316\u5BBD\u5EA6 X","number",e.softEdgeWidthX),T("softEdgeWidthY","\u7FBD\u5316\u5BBD\u5EA6 Y","number",e.softEdgeWidthY),T("horizontalSoftRange","\u6C34\u5E73\u7FBD\u5316\u8303\u56F4","number",e.horizontalSoftRange),T("verticalSoftRange","\u5782\u76F4\u7FBD\u5316\u8303\u56F4","number",e.verticalSoftRange),T("enableFill","\u6309\u8FDB\u5EA6\u586B\u5145","bool",e.enableFill===!0,{gia:"W"}),T("fillType","\u5F62\u72B6","enum",c,{...[1,2,3,4,5].includes(l)?{}:{unknownValue:l},options:[{value:"Horizontal",label:"\u6A2A\u5411"},{value:"Vertical",label:"\u7EB5\u5411"},{value:"Radial90",label:"90\u5EA6\u73AF\u7ED5"},{value:"Radial180",label:"180\u5EA6\u73AF\u7ED5"},{value:"Radial360",label:"360\u5EA6\u73AF\u7ED5"}]}),T("fillHorizontalType","\u65B9\u5411","enum",e.fillHorizontalType,{options:[{value:"Left",label:"\u4ECE\u5DE6\u81F3\u53F3"},{value:"Right",label:"\u4ECE\u53F3\u81F3\u5DE6"}]}),T("fillVerticalType","\u65B9\u5411","enum",e.fillVerticalType,{options:[{value:"Bottom",label:"\u4ECE\u4E0B\u81F3\u4E0A"},{value:"Top",label:"\u4ECE\u4E0A\u81F3\u4E0B"}]}),T("fillRadial90Type","\u8D77\u70B9","enum",e.fillRadial90Type,{options:[{value:"BottomLeft",label:"\u5DE6\u4E0B"},{value:"TopLeft",label:"\u5DE6\u4E0A"},{value:"TopRight",label:"\u53F3\u4E0A"},{value:"BottomRight",label:"\u53F3\u4E0B"}]}),T("fillRadialType","\u8D77\u70B9","enum",e.fillRadialType,{options:[{value:"Bottom",label:"\u4E0B\u65B9"},{value:"Left",label:"\u5DE6\u4FA7"},{value:"Top",label:"\u4E0A\u65B9"},{value:"Right",label:"\u53F3\u4FA7"}]}),T("fillAmount","\u8FDB\u5EA6","percent",e.fillAmount),T("reverseMaskArea","\u906E\u7F69\u533A\u57DF\u53CD\u8F6C","bool",e.reverseMaskArea===!0,{gia:"W"}))}if(e.kind==="button"){let l=[{value:"",label:"\u672A\u8BBE\u7F6E"},...(e.children||[]).map(c=>({value:c.id,label:`${c.name} \xB7 ${c.id}`}))];a.push(T("raycastTarget","\u53EF\u88AB\u5149\u6807\u5C04\u7EBF\u68C0\u6D4B","bool",e.raycastTarget!==!1),T("interactable","\u6309\u94AE\u662F\u5426\u53EF\u7528","bool",e.interactable!==!1),T("unavailableChildId","\u4E0D\u53EF\u7528\u72B6\u6001\u8282\u70B9","node",e.unavailableChildId,{options:l,gia:"W"}),T("hoverChildId","\u60AC\u505C\u72B6\u6001\u8282\u70B9","node",e.hoverChildId,{options:l,gia:"W"}),T("pressedChildId","\u6309\u4E0B\u72B6\u6001\u8282\u70B9","node",e.pressedChildId,{options:l,gia:"W"}),T("selectedChildId","\u9009\u4E2D\u72B6\u6001\u8282\u70B9","node",e.selectedChildId,{options:l,gia:"W"}),T("clickAudioId","\u70B9\u51FB\u97F3\u6548","number",e.clickAudioId))}return e.kind==="reference"&&a.push(T("referencedPrefabId","\u5F15\u7528\u63A7\u4EF6\u6A21\u677F\u7D22\u5F15","string",e.referencedPrefabId??"")),e.kind==="grid"&&a.push(T("cellSizeX","\u5217\u8868\u9879\u5927\u5C0F W","number",e.cellSizeX,{evidence:"W"}),T("cellSizeY","\u5217\u8868\u9879\u5927\u5C0F H","number",e.cellSizeY,{evidence:"W"}),T("spacingX","\u5217\u8868\u9879\u95F4\u9694 X","number",e.spacingX,{evidence:"W"}),T("spacingY","\u5217\u8868\u9879\u95F4\u9694 Y","number",e.spacingY,{evidence:"W"}),T("padding1X","\u8FB9\u8DDD\u5411\u91CF 1 X","number",e.padding1X,{evidence:"W"}),T("padding1Y","\u8FB9\u8DDD\u5411\u91CF 1 Y","number",e.padding1Y,{evidence:"W"}),T("padding2X","\u8FB9\u8DDD\u5411\u91CF 2 X","number",e.padding2X,{evidence:"W"}),T("padding2Y","\u8FB9\u8DDD\u5411\u91CF 2 Y","number",e.padding2Y,{evidence:"W"}),T("previewCount","\u9884\u89C8\u6570\u91CF","number",e.previewCount)),e.kind==="keyhint"&&a.push(T("keyboardKeyCode","\u952E\u9F20\u6309\u952E","number",e.keyboardKeyCode??e.giaRaw?.keyHintField502??1,{gia:"W"}),T("controllerKeyCode","\u624B\u67C4\u6309\u952E","number",e.controllerKeyCode??e.giaRaw?.keyHintField501??1)),(e.kind==="animation"||e.kind==="fullscreen")&&a.push(T("animationId",e.kind==="animation"?"\u52A8\u6548\u7D22\u5F15":"\u5168\u5C4F\u52A8\u6548\u7D22\u5F15","string",e.animationId??"")),ai.includes(e.kind)||a.push(T("incomplete","\u5B8C\u6574\u5EA6","note","\u672C\u9636\u6BB5\u4EC5\u516C\u5171\u53D8\u6362\uFF0C\u4E1A\u52A1\u69FD\u4E0D\u5B8C\u6574")),{id:e.id,guid:n?.get(e.id)??(e.guid||0),kind:e.kind,label:pt[e.kind]||e.kind,incomplete:!ai.includes(e.kind),fields:a}}function dr(e,t,i){let n=(Array.isArray(e)?e:Object.values(e)).filter(r=>r.kind!=="server-container");for(let r=n.length-1;r>=0;r-=1){let o=n[r];if(!o.visible||!o.active)continue;let a=o.renderMatrix&&si(o.renderMatrix),l=a&&Je(a,t,i);if(l&&l.x>=o.left&&l.x<=o.right&&l.y>=o.bottom&&l.y<=o.top)return o.id}return null}import ba from"protobufjs";var va=String.raw`
1
+ import{parentPort as Ln}from"node:worker_threads";import{existsSync as oi,readFileSync as As}from"node:fs";import{randomUUID as _s}from"node:crypto";import{isAbsolute as ir,win32 as nr}from"node:path";function tr(e,t=!1){let i=String(e??"").trim().replaceAll("\\","/");if(t&&(!i||i==="."))return"";if(!i||ir(i)||nr.isAbsolute(i)||i.split("/").some(n=>!n||n==="."||n===".."||/[<>:"|?*\x00-\x1f]/.test(n)||/[. ]$/.test(n)||/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test(n)))throw new Error("\u811A\u672C\u76EE\u5F55/\u8DEF\u5F84\u5FC5\u987B\u662F\u6709\u6548\u7684\u76F8\u5BF9\u8DEF\u5F84\uFF0C\u4E0D\u80FD\u5305\u542B .. \u6216 Windows \u7279\u6B8A\u6587\u4EF6\u540D");return i}function Bi(e){if(e==null)return null;if(e.version!==1)throw new Error("unsupported scriptSync version");let t=String(e.clientImportRoot||"").trim();if(!ir(t)&&!nr.isAbsolute(t))throw new Error("\u5B9E\u673A\u5BFC\u5165\u6839\u76EE\u5F55\u5FC5\u987B\u662F\u7EDD\u5BF9\u8DEF\u5F84");return{version:1,workspaceDir:tr(e.workspaceDir,!0),clientImportRoot:t,clientSubdir:tr(e.clientSubdir,!0)}}import{basename as Tt,dirname as Ps,isAbsolute as Rs,join as oa,resolve as aa}from"node:path";var _a=[[100001,100006],[100101,100213],[101001,101018],[101020,101028],[101030,101046],[101048,101048],[101050,101054],[101056,101080],[102001,102052],[103001,103148],[104001,104010],[105001,105140],[105142,105219],[105221,105317],[106001,106047],[106049,106096],[107001,107007],[107010,107020],[107031,107092],[107094,107180],[107183,107201],[107203,107205],[107207,107228],[107231,107278],[107280,107402],[108001,108017],[108019,108020],[109001,109031],[109033,109034],[109036,109075],[110001,110053],[111001,111139],[112001,112042]];function rr(e){return Number.isSafeInteger(e)&&e>100006&&_a.some(([t,i])=>e>=t&&e<=i)}var se=Object.freeze(["KEYBOARD","TOUCHSCREEN","CONTROLLER_CONSOLE","CONTROLLER_MOBILE"]),ie=Object.freeze({"pc-16-9":{id:"pc-16-9",device:"pc",platform:"KEYBOARD",width:1600,height:900,ratio:"16:9",luaDevice:"KeyboardAndMouse",label:"PC 1600\xD7900"},"pc-21-9":{id:"pc-21-9",device:"pc",platform:"KEYBOARD",width:2100,height:900,ratio:"21:9",luaDevice:"KeyboardAndMouse",label:"PC 2100\xD7900"},"mobile-16-9":{id:"mobile-16-9",device:"mobile",platform:"TOUCHSCREEN",width:1280,height:720,ratio:"16:9",luaDevice:"Mobile",label:"\u624B\u673A 1280\xD7720"},"mobile-19.5-9":{id:"mobile-19.5-9",device:"mobile",platform:"TOUCHSCREEN",width:1560,height:720,ratio:"19.5:9",luaDevice:"Mobile",label:"\u624B\u673A 1560\xD7720"},"mobile-4-3":{id:"mobile-4-3",device:"mobile",platform:"TOUCHSCREEN",width:1280,height:960,ratio:"4:3",luaDevice:"Mobile",label:"\u624B\u673A 1280\xD7960"}}),ci="pc-16-9",pe=2,gt=Object.freeze({KEYBOARD:"pc-16-9",TOUCHSCREEN:"mobile-16-9",CONTROLLER_CONSOLE:"pc-16-9",CONTROLLER_MOBILE:"mobile-16-9"}),yt=Object.freeze({"server-container":"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u5BB9\u5668",container:"\u5BB9\u5668\u8282\u70B9",textbox:"\u6587\u672C\u6846",image:"\u56FE\u7247",button:"\u9884\u8BBE\u6309\u94AE",cursor:"\u5149\u6807\u68C0\u6D4B\u533A\u57DF",grid:"\u7F51\u683C\u89C6\u7A97",reference:"\u6A21\u677F\u5F15\u7528\u63A7\u4EF6",textwindow:"\u6587\u672C\u89C6\u7A97",keyhint:"\u6309\u952E\u63D0\u793A",animation:"\u754C\u9762\u52A8\u6548",fullscreen:"\u5168\u5C4F\u52A8\u6548"}),fi=Object.freeze(["server-container","container","textbox","cursor","reference","grid","image","button","textwindow","keyhint","animation","fullscreen"]),or=Object.freeze({"server-container":null,container:[150,150],textbox:[100,40],image:[80,80],button:[150,50],cursor:[150,50],grid:[80,80],reference:[80,80],textwindow:[100,40],keyhint:[40,40],animation:[100,100],fullscreen:null}),Pa=Object.freeze({100001:"rect",100002:"circle",100003:"triangle",100004:"fourstar",100005:"fivestar",100006:"ring"});function bt(e){return Pa[e]||(rr(e)?"sprite":"missing")}var ar=50888,$t=Object.freeze({font:4294967295,bg:16777215,outline:858993459,image:4294967295});function vt(e,t="$",i=new Set){if(e===void 0)throw new Error(`undefined at ${t}`);if(typeof e=="number"&&!Number.isFinite(e))throw new Error(`non-finite number at ${t}`);if(typeof e=="bigint"||typeof e=="function"||typeof e=="symbol")throw new Error(`non-JSON value at ${t}`);if(!(e===null||typeof e!="object")){if(i.has(e))throw new Error(`circular value at ${t}`);if(i.add(e),Array.isArray(e))e.forEach((n,r)=>vt(n,`${t}[${r}]`,i));else for(let[n,r]of Object.entries(e))vt(r,`${t}.${n}`,i);i.delete(e)}}function D(e){return vt(e),JSON.parse(JSON.stringify(e))}function lr(e,t="$"){vt(e,t)}function sr(e){return ie[e]||ie[ci]}function Gt(e,t=0,i=0){return!e||typeof e!="object"?{x:t,y:i}:{x:Number(e.x??t),y:Number(e.y??i)}}function Ra(e){return!e||typeof e!="object"?{x:1,y:1,z:1}:{x:Number(e.x??1),y:Number(e.y??1),z:Number(e.z??1)}}function Ta(e){return!e||typeof e!="object"?{x:0,y:0,z:0}:{x:Number(e.x??0),y:Number(e.y??0),z:Number(e.z??0)}}function di({layout:e="center",size:t=[100,40],offset:i=[0,0]}={}){return e==="stretch"?{scale:{x:1,y:1,z:1},rotation:{x:0,y:0,z:0},anchorMin:{x:0,y:0},anchorMax:{x:1,y:1},offset:{x:0,y:0},size:{x:0,y:0},pivot:{x:.5,y:.5}}:{scale:{x:1,y:1,z:1},rotation:{x:0,y:0,z:0},anchorMin:{x:.5,y:.5},anchorMax:{x:.5,y:.5},offset:{x:Number(i[0]??0),y:Number(i[1]??0)},size:{x:Number(t[0]??0),y:Number(t[1]??0)},pivot:{x:.5,y:.5}}}function Te(e){let t=e||di();return{scale:Ra(t.scale),rotation:Ta(t.rotation),anchorMin:Gt(t.anchorMin??t.anchor_min,.5,.5),anchorMax:Gt(t.anchorMax??t.anchor_max,.5,.5),offset:Gt(t.offset,0,0),size:Gt(t.size,0,0),pivot:Gt(t.pivot,.5,.5)}}function ge(e,t=0){let i=Number(e);return Number.isFinite(i)?i:t}function Fe(e,t){let i=e.width,n=e.height,r=e.left,o=e.bottom,a=t.anchorMin||{x:t.anchorMinX,y:t.anchorMinY},l=t.anchorMax||{x:t.anchorMaxX,y:t.anchorMaxY},c=t.offset||{x:t.anchoredPositionX,y:t.anchoredPositionY},s=t.size||{x:t.sizeDeltaX,y:t.sizeDeltaY},f=t.pivot||{x:t.pivotX,y:t.pivotY},h=ge(a?.x,.5)*i,m=ge(a?.y,.5)*n,p=ge(l?.x,.5)*i,y=ge(l?.y,.5)*n,v=ge(s?.x),E=ge(s?.y),x=ge(f?.x,.5),A=ge(f?.y,.5),$=p-h+v,O=y-m+E,J=r+h+ge(c?.x)-v*x,ee=o+m+ge(c?.y)-E*A;return{left:J,bottom:ee,width:$,height:O,right:J+$,top:ee+O,centerX:J+$/2,centerY:ee+O/2}}function St(){return{a:1,b:0,c:0,d:1,tx:0,ty:0}}function Ma(e,t){return{a:e.a*t.a+e.c*t.b,b:e.b*t.a+e.d*t.b,c:e.a*t.c+e.c*t.d,d:e.b*t.c+e.d*t.d,tx:e.a*t.tx+e.c*t.ty+e.tx,ty:e.b*t.tx+e.d*t.ty+e.ty}}function Oe(e,t,i){return{x:e.a*t+e.c*i+e.tx,y:e.b*t+e.d*i+e.ty}}function Vt(e){let t=e.a*e.d-e.b*e.c;return!Number.isFinite(t)||Math.abs(t)<1e-8?null:{a:e.d/t,b:-e.b/t,c:-e.c/t,d:e.a/t,tx:(e.c*e.ty-e.d*e.tx)/t,ty:(e.b*e.tx-e.a*e.ty)/t}}function Ui(e,t){let i=t.rotation||{z:t.localRotationZ},n=t.scale||{x:t.localScaleX,y:t.localScaleY},r=t.pivot||{x:t.pivotX,y:t.pivotY},o=ge(i?.z)*Math.PI/180,a=Math.cos(o),l=Math.sin(o),c=ge(n?.x,1),s=ge(n?.y,1),f=e.left+e.width*ge(r?.x,.5),h=e.bottom+e.height*ge(r?.y,.5),m=a*c,p=l*c,y=-l*s,v=a*s;return{a:m,b:p,c:y,d:v,tx:f-m*f-y*h,ty:h-p*f-v*h}}function Yt(e,t,i){return Ma(e||St(),Ui(t,i))}function ur(e,t){let i=Oe(t,e.centerX,e.centerY),n=Math.abs(e.width*Math.hypot(t.a,t.b)),r=Math.abs(e.height*Math.hypot(t.c,t.d));return{left:i.x-n/2,bottom:i.y-r/2,width:n,height:r,centerX:i.x,centerY:i.y,rotationZ:Math.atan2(t.b,t.a)*180/Math.PI}}function ye(e){let t=typeof e=="string"?sr(e):e;return{left:0,bottom:0,width:t.width,height:t.height,right:t.width,top:t.height,centerX:t.width/2,centerY:t.height/2}}function ji(e){return{posX:e.centerX,posY:e.centerY,width:e.width,height:e.height}}function Qe(e,t,i){let n=Te(t),r=e.width,o=e.height,a=n.anchorMin.x*r,l=n.anchorMin.y*o,c=n.anchorMax.x*r,s=n.anchorMax.y*o,f=Number(i.width),h=Number(i.height),m=Number(i.posX),p=Number(i.posY),y=m-f/2,v=p-h/2;return n.size={x:f-(c-a),y:h-(s-l)},n.offset={x:y-e.left-a+n.size.x*n.pivot.x,y:v-e.bottom-l+n.size.y*n.pivot.y},n}function cr(e,t){let i=Te(e),r={"bottom-left":[[0,0],[0,0],[0,0]],bottom:[[.5,0],[.5,0],[.5,0]],"bottom-right":[[1,0],[1,0],[1,0]],left:[[0,.5],[0,.5],[0,.5]],center:[[.5,.5],[.5,.5],[.5,.5]],right:[[1,.5],[1,.5],[1,.5]],"top-left":[[0,1],[0,1],[0,1]],top:[[.5,1],[.5,1],[.5,1]],"top-right":[[1,1],[1,1],[1,1]],stretch:[[0,0],[1,1],[.5,.5]],"stretch-horizontal":[[0,.5],[1,.5],[.5,.5]],"stretch-vertical":[[.5,0],[.5,1],[.5,.5]]}[t];return r&&(i.anchorMin={x:r[0][0],y:r[0][1]},i.anchorMax={x:r[1][0],y:r[1][1]},i.pivot={x:r[2][0],y:r[2][1]}),i}function fr(e){let t=Te(e),i=(n,r)=>Math.abs(n-r)<1e-4;if(i(t.anchorMin.x,0)&&i(t.anchorMin.y,0)&&i(t.anchorMax.x,1)&&i(t.anchorMax.y,1))return"stretch";if(i(t.anchorMin.x,t.anchorMax.x)&&i(t.anchorMin.y,t.anchorMax.y)){let n=t.anchorMin.x,r=t.anchorMin.y,o=[[0,0,"bottom-left"],[.5,0,"bottom"],[1,0,"bottom-right"],[0,.5,"left"],[.5,.5,"center"],[1,.5,"right"],[0,1,"top-left"],[.5,1,"top"],[1,1,"top-right"]];for(let a of o)if(i(n,a[0])&&i(r,a[1]))return a[2]}return"custom"}function et(e){return sr(e).platform}function dr(e){let t={};for(let i of se)t[i]=e(i);return t}var Na={scale:["x","y","z"],rotation:["x","y","z"],anchorMin:["x","y"],anchorMax:["x","y"],offset:["x","y"],size:["x","y"],pivot:["x","y"]};function hr(e,t){for(let[i,n]of Object.entries(Na))for(let r of n)if(!Number.isFinite(e?.[i]?.[r]))throw new Error(`${t}.${i}.${r} must be a finite number`)}function Ve(e,t="transformByPlatform"){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t}: \u9700\u8981\u5B8C\u6574\u7684\u56DB\u5E73\u53F0\u5E03\u5C40`);for(let i of Object.keys(e))if(!se.includes(i))throw new Error(`${t}: unknown platform ${i}`);for(let i of se)hr(e[i],`${t}.${i}`)}function tt(e){if(Object.hasOwn(e,"transformByCanvas"))throw new Error(`${e.name||e.id||"\u63A7\u4EF6"}: \u4E0D\u518D\u652F\u6301 transformByCanvas\uFF1B\u8BF7\u4F7F\u7528\u56DB\u5E73\u53F0 transformByPlatform \u5E03\u5C40`);Ve(e.transformByPlatform,`${e.name||e.id||"\u63A7\u4EF6"}.transformByPlatform`)}function it(e,t){if(!se.includes(t))throw new Error(`unknown platform ${t}`);return hr(e?.[t],`transformByPlatform.${t}`),Te(e[t])}var Fa=Object.freeze([{key:"genericField501",label:"\u901A\u7528\u69FD field501",type:"number",defaultValue:0,wire:"GenericSlot.field501"},{key:"footerField505",label:"\u5C3E\u90E8\u69FD field505",type:"number",defaultValue:0,wire:"FooterSlot.field505"}]),Oa=Object.freeze({container:[],textbox:[{key:"textField501",label:"\u6587\u672C\u914D\u7F6E field501",type:"number",defaultValue:20,wire:"TextConfig.field501"},{key:"textField503",label:"\u6587\u672C\u914D\u7F6E field503",type:"number",defaultValue:12,wire:"TextConfig.field503"},{key:"textAlign",label:"\u6C34\u5E73\u5BF9\u9F50\u679A\u4E3E\u539F\u59CB\u503C",type:"enum",defaultValue:0,wire:"TextConfig.align",options:[{value:0,label:"0 \xB7 \u5DE6\u5BF9\u9F50"},{value:1,label:"1 \xB7 \u5C45\u4E2D"},{value:2,label:"2 \xB7 \u53F3\u5BF9\u9F50"}]}],textwindow:[{key:"textField501",label:"\u6587\u672C\u914D\u7F6E field501",type:"number",defaultValue:20,wire:"TextConfig.field501"},{key:"textField503",label:"\u6587\u672C\u914D\u7F6E field503",type:"number",defaultValue:12,wire:"TextConfig.field503"},{key:"textAlign",label:"\u6C34\u5E73\u5BF9\u9F50\u679A\u4E3E\u539F\u59CB\u503C",type:"enum",defaultValue:0,wire:"TextConfig.align",options:[{value:0,label:"0 \xB7 \u5DE6\u5BF9\u9F50"},{value:1,label:"1 \xB7 \u5C45\u4E2D"},{value:2,label:"2 \xB7 \u53F3\u5BF9\u9F50"}]},{key:"textField511",label:"\u6587\u672C\u89C6\u7A97 field511",type:"number",defaultValue:1,wire:"TextConfig.field511"},{key:"textViewField502",label:"\u89C6\u7A97\u6807\u8BB0 field502",type:"number",defaultValue:1,wire:"TextConfig.viewFlags.field502"},{key:"textViewField503",label:"\u89C6\u7A97\u6807\u8BB0 field503",type:"number",defaultValue:1,wire:"TextConfig.viewFlags.field503"}],cursor:[{key:"cursorField501",label:"\u5149\u6807\u68C0\u6D4B field501",type:"number",defaultValue:1,wire:"CursorConfig.field501"}],reference:[{key:"templateRefSlot",label:"\u6A21\u677F\u5F15\u7528\u69FD\u539F\u59CB\u503C",type:"string",defaultValue:"",wire:"Details.templateRefSlot"}],grid:[{key:"gridField501",label:"\u7F51\u683C\u6807\u8BB0 field501",type:"number",defaultValue:1,wire:"GridViewConfig.field501"},{key:"gridField507",label:"\u7F51\u683C\u6807\u8BB0 field507",type:"number",defaultValue:1,wire:"GridViewConfig.field507"},{key:"gridField508",label:"\u7F51\u683C\u6807\u8BB0 field508",type:"number",defaultValue:1,wire:"GridViewConfig.field508"},{key:"gridField509",label:"\u7F51\u683C\u6807\u8BB0 field509",type:"number",defaultValue:1,wire:"GridViewConfig.field509"},{key:"gridField511",label:"\u7F51\u683C\u6807\u8BB0 field511",type:"number",defaultValue:5,wire:"GridViewConfig.field511"},{key:"gridField512",label:"\u7F51\u683C\u6807\u8BB0 field512",type:"number",defaultValue:1,wire:"GridViewConfig.field512"}],keyhint:[{key:"keyHintField501",label:"\u6309\u952E\u63D0\u793A field501",type:"number",defaultValue:1,wire:"KeyHintConfig.field501"},{key:"keyHintField502",label:"\u952E\u9F20\u952E\u4F4D\u539F\u59CB\u503C",type:"number",defaultValue:1,wire:"KeyHintConfig.field502"}],image:[{key:"imageField502",label:"\u56FE\u7247\u6807\u8BB0 field502",type:"number",defaultValue:1,wire:"ImageConfig.field502"},{key:"imageField504",label:"\u56FE\u7247\u6807\u8BB0 field504",type:"number",defaultValue:1,wire:"ImageConfig.field504"},{key:"imageField505",label:"\u56FE\u7247\u6807\u8BB0 field505",type:"number",defaultValue:1,wire:"ImageConfig.field505"},{key:"imageField507",label:"\u56FE\u7247\u6807\u8BB0 field507",type:"number",defaultValue:2,wire:"ImageConfig.field507"},{key:"imageFillType",label:"\u586B\u5145\u5F62\u72B6\u679A\u4E3E\u539F\u59CB\u503C",type:"enum",defaultValue:1,wire:"ImageConfig.fillType",options:[{value:1,label:"1 \xB7 \u6A2A\u5411"},{value:2,label:"2 \xB7 \u7EB5\u5411"},{value:3,label:"3 \xB7 90\u5EA6\u73AF\u7ED5"},{value:4,label:"4 \xB7 180\u5EA6\u73AF\u7ED5"},{value:5,label:"5 \xB7 360\u5EA6\u73AF\u7ED5"}]}],animation:[{key:"effectSlot",label:"\u754C\u9762\u52A8\u6548\u69FD\u539F\u59CB\u503C",type:"string",defaultValue:"",wire:"Details.effectSlot"}],fullscreen:[{key:"fullscreenEffectSlot",label:"\u5168\u5C4F\u52A8\u6548\u69FD\u539F\u59CB\u503C",type:"string",defaultValue:"",wire:"Details.fullscreenEffectSlot"}]});function mr(e){return[...Fa,...Oa[e]||[]]}function pr(e,t){return mr(e).find(i=>i.key===t)||null}function Xi(e,t){if(!e)throw new Error("unknown raw GIA field");if(e.type==="string")return String(t??"");let i=Number(t);if(!Number.isFinite(i))throw new Error(`${e.wire} must be a finite number`);return Math.trunc(i)}function gr(e,t={}){let i={};for(let n of mr(e)){let r=Object.hasOwn(t||{},n.key)?t[n.key]:n.defaultValue;i[n.key]=Xi(n,r)}return i}function xe(e){let t=Number(e);return Number.isSafeInteger(t)&&t>0&&t<=2147483647}function Hi(e,t){if(e){t(e);for(let i of e.children||[])Hi(i,t)}}function wt(e,t=new Set,{skipServerContainer:i=!1}={}){return Hi(e,n=>{i&&n.kind==="server-container"||xe(n.guid)&&t.add(Number(n.guid))}),t}function Ye(e,t=1073741850){let i=Number.isSafeInteger(t)&&t>0?t:1073741850;i<1073741850&&(i=1073741850);for(let n of e)xe(n)&&n>=i&&(i=Number(n)+1);for(;e.has(i);)i+=1;if(i>2147483647)throw new Error("GUID space exhausted");return i}function yr(e,t=new Set,{skipServerContainer:i=!1}={}){let n=[];Hi(e,r=>{if(i&&r.kind==="server-container")return;let o=Number(r.guid);if(xe(o)&&!t.has(o)){t.add(o),r.guid=o;return}n.push(r)});for(let r of n){let o=Ye(t);r.guid=o,t.add(o)}return t}var Ki=1;function qi(e="n"){let t=`${e}${Ki}`;return Ki+=1,t}function hi(e=1){Ki=e}function Li(e,{isRootContainer:t=!1}={}){if(e==="server-container"||e==="fullscreen"||e==="container"&&t)return di({layout:"stretch"});let i=or[e]||[80,80];return di({layout:"center",size:i})}function za(e,t){return dr(()=>Li(e,t))}function Da(e){Ve(e);let t={};for(let i of se)t[i]=it(e,i);return t}function H(e,t={}){if(!yt[e])throw new Error(`unknown kind: ${e}`);Object.hasOwn(t,"transformByCanvas")&&tt(t);let i=t.isRootContainer===!0,n=t.id||qi(e==="server-container"?"sc":"n"),r=Object.hasOwn(t,"transformByPlatform")?Da(t.transformByPlatform):za(e,{isRootContainer:i}),o={id:n,kind:e,name:t.name||yt[e],guid:t.guid??0,giaRelatedGuids:Array.isArray(t.giaRelatedGuids)?t.giaRelatedGuids.filter(a=>Number.isSafeInteger(Number(a))&&Number(a)>0).map(Number):[],...Number.isSafeInteger(Number(t.giaInfoIndex))&&Number(t.giaInfoIndex)>0?{giaInfoIndex:Number(t.giaInfoIndex)}:{},active:t.active!==!1,visible:t.visible!==!1,canControllerFocus:t.canControllerFocus??t.giaRaw?.footerField505===1,syncAllDevices:t.syncAllDevices!==!1,giaRaw:gr(e,t.giaRaw),transformByPlatform:r,children:[],scriptMappingIds:Array.isArray(t.scriptMappingIds)?t.scriptMappingIds.filter(a=>Number.isSafeInteger(Number(a))&&Number(a)>0).map(Number):[]};if(e==="container"&&(o.isolateNavigation=t.isolateNavigation===!0,o.disableKeyEventPassthrough=t.disableKeyEventPassthrough===!0,o.disableCursorEventPassthrough=t.disableCursorEventPassthrough===!0,o.showCursor=t.showCursor===!0),(e==="textbox"||e==="textwindow")&&(o.fontSize=t.fontSize??20,o.adaptiveFontSize=t.adaptiveFontSize===!0,o.minimumFontSize=t.minimumFontSize??20,o.fontColor=t.fontColor??$t.font,o.bgColor=t.bgColor??$t.bg,o.enableOutline=t.enableOutline!==!1,o.outlineColor=t.outlineColor??$t.outline,o.horizontalAlignment=t.horizontalAlignment||"Left",o.verticalAlignment=t.verticalAlignment||"Top",Number.isInteger(t.giaRaw?.textVerticalAlign)&&![0,1,2].includes(t.giaRaw.textVerticalAlign)&&(o.giaRaw.textVerticalAlign=t.giaRaw.textVerticalAlign),o.text=t.text??"",Object.hasOwn(t.giaRaw||{},"textAlign")||(o.giaRaw.textAlign={Left:0,Middle:1,Right:2}[o.horizontalAlignment]??o.giaRaw.textAlign),e==="textwindow"&&(o.interactable=t.interactable!==!1,o.showScrollBar=t.showScrollBar!==!1)),e==="image"&&(o.imageSource=t.imageSource||"StaticReference",o.imageId=t.imageId??100001,o.imageColor=t.imageColor??$t.image,o.enableMask=t.enableMask===!0,o.enableSoftEdge=t.enableSoftEdge===!0,o.softEdgeMode=t.softEdgeMode||"Percentage",o.softEdgeWidthX=t.softEdgeWidthX??8,o.softEdgeWidthY=t.softEdgeWidthY??8,o.horizontalSoftRange=t.horizontalSoftRange??85,o.verticalSoftRange=t.verticalSoftRange??85,o.enableFill=t.enableFill===!0,o.fillType=t.fillType||"Horizontal",o.fillHorizontalType=t.fillHorizontalType||"Left",o.fillVerticalType=t.fillVerticalType||"Bottom",o.fillRadial90Type=t.fillRadial90Type||"BottomLeft",o.fillRadialType=t.fillRadialType||"Bottom",o.fillAmount=t.fillAmount??1,o.reverseMaskArea=t.reverseMaskArea===!0||t.reverseMask===!0,Object.hasOwn(t.giaRaw||{},"imageFillType")||(o.giaRaw.imageFillType={Horizontal:1,Vertical:2,Radial90:3,Radial180:4,Radial360:5}[o.fillType]??o.giaRaw.imageFillType)),e==="button"&&(o.raycastTarget=t.raycastTarget!==!1,o.interactable=t.interactable!==!1,o.clickAudioId=t.clickAudioId??ar,o.unavailableChildId=t.unavailableChildId??null,o.hoverChildId=t.hoverChildId??null,o.pressedChildId=t.pressedChildId??null,o.selectedChildId=t.selectedChildId??null),e==="cursor"&&(o.raycastTarget=t.raycastTarget??t.giaRaw?.cursorField501!==0),e==="reference"&&(o.referencedPrefabId=t.referencedPrefabId??t.giaRaw?.templateRefSlot??null,Object.hasOwn(t.giaRaw||{},"templateRefSlot")||(o.giaRaw.templateRefSlot=String(o.referencedPrefabId??""))),e==="grid"&&(o.itemPrefabId=t.itemPrefabId??null,o.raycastTarget=t.raycastTarget!==!1,o.interactable=t.interactable!==!1,o.showScrollBar=t.showScrollBar!==!1,o.scrollDirection=t.scrollDirection||"Vertical",o.layoutConstraint=t.layoutConstraint||"AutoWrap",o.layoutConstraintFixedCount=t.layoutConstraintFixedCount??null,o.cellSizeX=t.cellSizeX??50,o.cellSizeY=t.cellSizeY??50,o.spacingX=t.spacingX??8,o.spacingY=t.spacingY??8,o.padding1X=t.padding1X??20,o.padding1Y=t.padding1Y??20,o.padding2X=t.padding2X??20,o.padding2Y=t.padding2Y??20,o.previewCount=t.previewCount??t.giaRaw?.gridField511??5,Object.hasOwn(t.giaRaw||{},"gridField511")||(o.giaRaw.gridField511=Math.trunc(o.previewCount))),e==="keyhint"&&(o.keyboardKeyCode=t.keyboardKeyCode??t.giaRaw?.keyHintField502??null,o.controllerKeyCode=t.controllerKeyCode??t.giaRaw?.keyHintField501??null,Object.hasOwn(t.giaRaw||{},"keyHintField502")||(o.giaRaw.keyHintField502=Math.trunc(o.keyboardKeyCode??1)),Object.hasOwn(t.giaRaw||{},"keyHintField501")||(o.giaRaw.keyHintField501=Math.trunc(o.controllerKeyCode??1))),e==="animation"||e==="fullscreen"){let a=e==="animation"?t.giaRaw?.effectSlot:t.giaRaw?.fullscreenEffectSlot;o.animationId=t.animationId??a??null,o.playSoundEffect=t.playSoundEffect??null,e==="animation"&&(o.layer=t.layer??null);let l=e==="animation"?"effectSlot":"fullscreenEffectSlot";Object.hasOwn(t.giaRaw||{},l)||(o.giaRaw[l]=String(o.animationId??""))}if(t.children)for(let a of t.children)o.children.push(a);return o}function nt(){hi(1);let e=H("server-container",{id:"sc1",name:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u5BB9\u5668"}),t=H("container",{id:"n1",name:"\u5BB9\u5668\u8282\u70B9",isRootContainer:!0}),i=H("textbox",{id:"n2",name:"\u6587\u672C\u6846",text:"\u6587\u672C"}),n=H("cursor",{id:"n3",name:"\u5149\u6807\u68C0\u6D4B\u533A\u57DF"}),r=H("reference",{id:"n4",name:"\u6A21\u677F\u5F15\u7528\u63A7\u4EF6"}),o=H("grid",{id:"n5",name:"\u7F51\u683C\u89C6\u7A97"}),a=H("button",{id:"n6",name:"\u9884\u8BBE\u6309\u94AE"}),l=H("textwindow",{id:"n7",name:"\u6587\u672C\u89C6\u7A97"}),c=H("keyhint",{id:"n8",name:"\u6309\u952E\u63D0\u793A"}),s=H("image",{id:"n9",name:"\u56FE\u7247",imageId:100005}),f=H("animation",{id:"n10",name:"\u754C\u9762\u52A8\u6548"}),h=H("fullscreen",{id:"n11",name:"\u5168\u5C4F\u52A8\u6548"}),m=(p,y,v)=>{for(let E of Object.values(p.transformByPlatform))E.offset={x:y,y:v}};return m(i,-300,250),m(n,-300,140),m(r,-300,30),m(o,-300,-100),m(a,0,0),m(l,300,250),m(c,300,140),m(s,300,30),m(f,300,-100),t.children.push(i,n,r,o,a,l,c,s,f,h),e.children.push(t),hi(12),yr(e),{version:1,layoutSchemaVersion:pe,meta:{name:"\u672A\u547D\u540D\u754C\u9762\u63A7\u4EF6\u7EC4",assetType:"server-control-template",sourceFormat:"authoring",sourceFile:""},canvasId:"pc-16-9",selectedId:"n2",root:e}}function Ct(){hi(1);let e=H("server-container",{id:"sc1",name:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F"}),t=H("container",{id:"n1",guid:1073742100,name:"Lua\u5B9E\u4F8B\u5316\u9762\u677F"}),i=H("textbox",{id:"n2",guid:1073742101,name:"\u6A21\u677F\u6807\u9898",text:"\u5BA2\u6237\u7AEF\u6A21\u677F\u5DF2\u5B9E\u4F8B\u5316",fontSize:28,horizontalAlignment:"Middle"}),n=H("image",{id:"n3",guid:1073742102,name:"\u6A21\u677F\u56FE\u6807",imageId:100005}),r=H("button",{id:"n4",guid:1073742103,name:"\u786E\u8BA4\u6309\u94AE"}),o=H("textbox",{id:"n5",guid:1073742104,name:"\u6309\u94AE\u6587\u5B57",text:"\u786E\u8BA4",horizontalAlignment:"Middle",verticalAlignment:"Top"}),a=(c,s,f)=>{for(let h of Object.values(c.transformByPlatform))h.offset={x:s,y:f}};return((c,s,f)=>{for(let h of Object.values(c.transformByPlatform))h.size={x:s,y:f}})(t,520,320),a(i,0,110),a(n,0,0),a(r,0,-110),r.children.push(o),t.children.push(i,n,r),e.children.push(t),hi(6),{version:1,layoutSchemaVersion:pe,meta:{name:"Lua\u5B9E\u4F8B\u5316\u9762\u677F",assetType:"client-control-template",sourceFormat:"authoring",sourceFile:"",gameVersion:"7.0.50",giaOwnerUid:114514,giaFileId:1073741829,giaFileName:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u5217\u8868.gia"},canvasId:"pc-16-9",selectedId:"n1",root:e}}function L(e,t,i=null){t(e,i);for(let n of e.children||[])L(n,t,e)}function ce(e,t){let i=null;return L(e,n=>{n.id===t&&(i=n)}),i}function Wi(e,t="n"){let i=qi(t);for(;ce(e,i);)i=qi(t);return i}function Be(e,t){let i=null;return L(e,(n,r)=>{n.id===t&&(i=r)}),i}function Ji(e){let t=e.root||e;return t.kind==="container"?t:(t.children||[]).find(i=>i.kind==="container")||(t.children||[])[0]||t}function Bt(e){if(e.meta?.assetType!=="client-control-template")return Ji(e);let t=ce(e.root,e.selectedId);if(!t||t.kind==="server-container")return e.root.children?.[0]||e.root;let i=Be(e.root,t.id);for(;i&&i.kind!=="server-container";)t=i,i=Be(e.root,t.id);return t}function Zi(e){tt(e);let t={id:e.id,name:e.name,guid:e.guid,giaRelatedGuids:e.giaRelatedGuids,giaInfoIndex:e.giaInfoIndex,scriptMappingIds:e.scriptMappingIds,giaRaw:e.giaRaw,active:e.active,visible:e.visible,canControllerFocus:e.canControllerFocus,syncAllDevices:e.syncAllDevices,transformByPlatform:e.transformByPlatform};e.kind==="container"&&(t.isolateNavigation=e.isolateNavigation,t.disableKeyEventPassthrough=e.disableKeyEventPassthrough,t.disableCursorEventPassthrough=e.disableCursorEventPassthrough,t.showCursor=e.showCursor),(e.kind==="textbox"||e.kind==="textwindow")&&(t.fontSize=e.fontSize,t.adaptiveFontSize=e.adaptiveFontSize,t.minimumFontSize=e.minimumFontSize,t.fontColor=e.fontColor,t.bgColor=e.bgColor,t.enableOutline=e.enableOutline,t.outlineColor=e.outlineColor,t.horizontalAlignment=e.horizontalAlignment,t.verticalAlignment=e.verticalAlignment,t.text=e.text??"",e.kind==="textwindow"&&(t.interactable=e.interactable,t.showScrollBar=e.showScrollBar)),e.kind==="image"&&(t.imageSource=e.imageSource,t.imageId=e.imageId,t.imageColor=e.imageColor,t.enableMask=e.enableMask,t.enableSoftEdge=e.enableSoftEdge,t.softEdgeMode=e.softEdgeMode,t.softEdgeWidthX=e.softEdgeWidthX,t.softEdgeWidthY=e.softEdgeWidthY,t.horizontalSoftRange=e.horizontalSoftRange,t.verticalSoftRange=e.verticalSoftRange,t.enableFill=e.enableFill,t.fillType=e.fillType,t.fillHorizontalType=e.fillHorizontalType,t.fillVerticalType=e.fillVerticalType,t.fillRadial90Type=e.fillRadial90Type,t.fillRadialType=e.fillRadialType,t.fillAmount=e.fillAmount,t.reverseMaskArea=e.reverseMaskArea??e.reverseMask),e.kind==="button"&&(t.raycastTarget=e.raycastTarget,t.interactable=e.interactable,t.clickAudioId=e.clickAudioId,t.unavailableChildId=e.unavailableChildId??null,t.hoverChildId=e.hoverChildId??null,t.pressedChildId=e.pressedChildId??null,t.selectedChildId=e.selectedChildId??null),e.kind==="cursor"&&(t.raycastTarget=e.raycastTarget),e.kind==="reference"&&(t.referencedPrefabId=e.referencedPrefabId??null),e.kind==="grid"&&(t.itemPrefabId=e.itemPrefabId??null,t.raycastTarget=e.raycastTarget,t.interactable=e.interactable,t.showScrollBar=e.showScrollBar,t.scrollDirection=e.scrollDirection,t.layoutConstraint=e.layoutConstraint,t.layoutConstraintFixedCount=e.layoutConstraintFixedCount??null,t.cellSizeX=e.cellSizeX,t.cellSizeY=e.cellSizeY,t.spacingX=e.spacingX,t.spacingY=e.spacingY,t.padding1X=e.padding1X,t.padding1Y=e.padding1Y,t.padding2X=e.padding2X,t.padding2Y=e.padding2Y,t.previewCount=e.previewCount),e.kind==="keyhint"&&(t.keyboardKeyCode=e.keyboardKeyCode??null,t.controllerKeyCode=e.controllerKeyCode??null),(e.kind==="animation"||e.kind==="fullscreen")&&(t.animationId=e.animationId??null,t.playSoundEffect=e.playSoundEffect??null,e.kind==="animation"&&(t.layer=e.layer??null)),t.isRootContainer=e.kind==="container"&&$a(e.transformByPlatform);let i=H(e.kind,t);return i.children=(e.children||[]).map(n=>Zi(n)),i}function $a(e){let t=e&&(e.KEYBOARD||Object.values(e)[0]);return t?Math.abs(t.anchorMin?.x??.5)<1e-4&&Math.abs(t.anchorMin?.y??.5)<1e-4&&Math.abs((t.anchorMax?.x??.5)-1)<1e-4&&Math.abs((t.anchorMax?.y??.5)-1)<1e-4:!1}function br(e,t,i={}){if(e.kind==="server-container"&&t!=="container")throw new Error("server container only accepts container nodes");let n=H(t,i);return e.children.push(n),n}function vr(e,t){if(e.id===t)throw new Error("cannot remove root");let i=Be(e,t);if(!i)return!1;let n=i.children.findIndex(r=>r.id===t);return n<0?!1:(i.children.splice(n,1),!0)}var Sr=1e-4;function Ga(e,t){return Math.abs(e.anchorMax[t]-e.anchorMin[t])>Sr&&Math.abs(e.size[t])<=Sr}function Va(e,t,i){if(!(t.width>0)||!(t.height>0))throw new Error("source parent must have positive size");if(!(i.width>0)||!(i.height>0))throw new Error("target parent must have positive size");let n=Fe(t,e),r=(n.centerX-t.left)/t.width,o=(n.centerY-t.bottom)/t.height,a=Qe(i,e,{posX:i.left+r*i.width,posY:i.bottom+o*i.height,width:n.width,height:n.height});for(let l of["x","y"])Ga(e,l)&&(a.offset[l]=e.offset[l],a.size[l]=e.size[l]);return a}function wr({transformByPlatform:e,source:t,canvasId:i,syncAllDevices:n,sourceParentBox:r=ye(i),targetParentBoxByPlatform:o={}}){Ve(e);let a=et(i),l={};for(let c of se)c===a?l[c]=Te(t):n!==!1?l[c]=Va(t,r,o[c]||ye(gt[c])):l[c]=it(e,c);return Ve(l),l}function Ue(e,t){return it(e,et(t))}function Cr(e,t){let i=[];function n(r){t[r.id]&&i.push(t[r.id]);let o=r.children||[];for(let a=o.length-1;a>=0;a-=1)n(o[a])}return n(e),i}function je(e,t,i=et(t)){let n=ye(t),r={};function o(a,l,c){let s=it(a.transformByPlatform,i),f=Fe(l,s),h=a.kind==="server-container"?c:Yt(c,f,s),m=ur(f,h);r[a.id]={...f,...ji(f),id:a.id,kind:a.kind,name:a.name,visible:a.visible!==!1,active:a.active!==!1,rotationZ:s.rotation.z,renderLeft:m.left,renderBottom:m.bottom,renderWidth:m.width,renderHeight:m.height,renderRotationZ:m.rotationZ,renderMatrix:h,primitive:a.kind==="image"?bt(a.imageId):null,...a.kind==="textbox"||a.kind==="textwindow"?{text:a.text??"",fontSize:a.fontSize,fontColor:a.fontColor,bgColor:a.bgColor,enableOutline:a.enableOutline!==!1,outlineColor:a.outlineColor,horizontalAlignment:a.horizontalAlignment,verticalAlignment:a.verticalAlignment}:{},...a.kind==="image"?{imageSource:a.imageSource,imageId:a.imageId,imageColor:a.imageColor,enableMask:a.enableMask===!0,enableSoftEdge:a.enableSoftEdge===!0,softEdgeMode:a.softEdgeMode,softEdgeWidthX:a.softEdgeWidthX,softEdgeWidthY:a.softEdgeWidthY,horizontalSoftRange:a.horizontalSoftRange,verticalSoftRange:a.verticalSoftRange,enableFill:a.enableFill===!0,fillType:a.fillType,fillHorizontalType:a.fillHorizontalType,fillVerticalType:a.fillVerticalType,fillRadial90Type:a.fillRadial90Type,fillRadialType:a.fillRadialType,fillAmount:a.fillAmount,reverseMaskArea:a.reverseMaskArea===!0}:{},...a.kind==="button"?{raycastTarget:a.raycastTarget!==!1,interactable:a.interactable!==!1,clickAudioId:a.clickAudioId,unavailableChildId:a.unavailableChildId??null,hoverChildId:a.hoverChildId??null,pressedChildId:a.pressedChildId??null,selectedChildId:a.selectedChildId??null}:{}};let p=a.kind==="server-container"?l:f;for(let y of a.children||[])o(y,p,h)}return o(e,n,St()),{canvas:n,boxes:r}}function Qi(e,t){let i=[];function n(r,o,a=null,l=[],c=0,s=1,f=e.id){i.push({id:r.id,guid:t?.get(r.id)??(r.guid||0),kind:r.kind,name:r.name,label:yt[r.kind]||r.kind,depth:o,parentId:a,ancestorIds:l,siblingIndex:c,siblingCount:s,templateId:f,childCount:(r.children||[]).length,incomplete:!fi.includes(r.kind)});let h=r.children||[];for(let m=0;m<h.length;m+=1)n(h[m],o+1,r.id,[...l,r.id],m,h.length,f)}return n(e,0),i}function _(e,t,i,n,r={}){return{key:e,label:t,type:i,value:n,...r}}function Ir(e,t,i,n){if(!e)return null;let r=Ue(e.transformByPlatform,t),o=ji(i),a=[_("name","\u540D\u79F0","string",e.name),_("active","\u521D\u59CB\u6FC0\u6D3B","bool",e.active!==!1),_("visible","\u521D\u59CB\u53EF\u89C1\u6027","bool",e.visible!==!1),_("canControllerFocus","\u53EF\u88AB\u624B\u67C4\u6447\u6746\u5BFC\u822A\u9009\u4E2D","bool",e.canControllerFocus===!0),_("posX","\u4F4D\u7F6E X","number",o.posX,{computed:!0}),_("posY","\u4F4D\u7F6E Y","number",o.posY,{computed:!0}),_("width","\u5927\u5C0F W","number",o.width,{computed:!0}),_("height","\u5927\u5C0F H","number",o.height,{computed:!0}),_("rotationZ","\u65CB\u8F6C Z","number",r.rotation.z),_("syncAllDevices","\u540C\u6B65\u4FE1\u606F\u81F3\u6240\u6709\u8BBE\u5907","bool",e.syncAllDevices!==!1),_("anchorType","\u951A\u70B9\u7C7B\u578B","enum",fr(r),{options:[{value:"center",label:"\u5C45\u4E2D"},{value:"top-left",label:"\u5DE6\u4E0A"},{value:"top",label:"\u4E0A\u65B9"},{value:"top-right",label:"\u53F3\u4E0A"},{value:"left",label:"\u5DE6\u4FA7"},{value:"right",label:"\u53F3\u4FA7"},{value:"bottom-left",label:"\u5DE6\u4E0B"},{value:"bottom",label:"\u4E0B\u65B9"},{value:"bottom-right",label:"\u53F3\u4E0B"},{value:"stretch",label:"\u53CC\u5411\u62C9\u4F38"},{value:"stretch-horizontal",label:"\u6C34\u5E73\u62C9\u4F38"},{value:"stretch-vertical",label:"\u5782\u76F4\u62C9\u4F38"},{value:"custom",label:"\u81EA\u5B9A\u4E49"}]}),_("anchorMinX","\u951A\u70B9 Min X","number",r.anchorMin.x),_("anchorMinY","\u951A\u70B9 Min Y","number",r.anchorMin.y),_("anchorMaxX","\u951A\u70B9 Max X","number",r.anchorMax.x),_("anchorMaxY","\u951A\u70B9 Max Y","number",r.anchorMax.y),_("pivotX","\u4E2D\u5FC3 X","number",r.pivot.x),_("pivotY","\u4E2D\u5FC3 Y","number",r.pivot.y)];if(e.kind==="container"&&a.push(_("isolateNavigation","\u9694\u79BB\u624B\u67C4\u5BFC\u822A","bool",e.isolateNavigation===!0),_("disableKeyEventPassthrough","\u5C4F\u853D\u6309\u952E\u4E8B\u4EF6\u7A7F\u900F","bool",e.disableKeyEventPassthrough===!0),_("disableCursorEventPassthrough","\u5C4F\u853D\u533A\u57DF\u5185\u70B9\u51FB\u4E8B\u4EF6\u7A7F\u900F","bool",e.disableCursorEventPassthrough===!0),_("showCursor","\u663E\u793A\u5E38\u9A7B\u5149\u6807","bool",e.showCursor===!0)),e.kind==="textbox"||e.kind==="textwindow"){let l=e.giaRaw?.textAlign,c=[0,1,2].includes(l)?e.horizontalAlignment||"Left":`__unrecognized:${l}`;a.push(_("fontSize","\u5B57\u53F7","number",e.fontSize),_("adaptiveFontSize","\u5B57\u53F7\u81EA\u9002\u5E94","bool",e.adaptiveFontSize===!0),_("minimumFontSize","\u6700\u5C0F\u5B57\u53F7","number",e.minimumFontSize),_("fontColor","\u6587\u672C\u8272","color",e.fontColor),_("bgColor","\u80CC\u666F\u8272","color",e.bgColor),_("enableOutline","\u542F\u7528\u63CF\u8FB9","bool",e.enableOutline!==!1),_("outlineColor","\u63CF\u8FB9\u8272","color",e.outlineColor),_("horizontalAlignment","\u6C34\u5E73\u5BF9\u9F50","enum",c,{...[0,1,2].includes(l)?{}:{unknownValue:l},options:[{value:"Left",label:"\u5DE6\u5BF9\u9F50"},{value:"Middle",label:"\u5C45\u4E2D"},{value:"Right",label:"\u53F3\u5BF9\u9F50"}]}),_("verticalAlignment","\u5782\u76F4\u5BF9\u9F50","enum",e.verticalAlignment||"Top",{options:[{value:"Top",label:"\u9876\u90E8"},{value:"Middle",label:"\u5C45\u4E2D"},{value:"Bottom",label:"\u5E95\u90E8"}]}),_("text","\u6587\u672C","text",e.text??""))}if(e.kind==="image"){let l=e.giaRaw?.imageFillType,c=[1,2,3,4,5].includes(l)?e.fillType:`__unrecognized:${l}`;a.push(_("imageSource","\u56FE\u7247\u6E90","enum",e.imageSource,{readonly:!0,evidence:"W",options:[{value:"StaticReference",label:"\u9759\u6001\u5F15\u7528"}]}),_("imageId","imageId","number",e.imageId??0),_("imageColor","\u586B\u5145\u8272","color",e.imageColor),_("enableMask","\u5F00\u542F\u906E\u7F69","bool",e.enableMask===!0),_("enableSoftEdge","\u8FB9\u7F18\u7FBD\u5316","bool",e.enableSoftEdge===!0,{gia:"W"}),_("softEdgeMode","\u7FBD\u5316\u6A21\u5F0F","enum",e.softEdgeMode,{options:[{value:"Percentage",label:"\u767E\u5206\u6BD4"},{value:"Pixel",label:"\u50CF\u7D20"}]}),_("softEdgeWidthX","\u7FBD\u5316\u5BBD\u5EA6 X","number",e.softEdgeWidthX),_("softEdgeWidthY","\u7FBD\u5316\u5BBD\u5EA6 Y","number",e.softEdgeWidthY),_("horizontalSoftRange","\u6C34\u5E73\u7FBD\u5316\u8303\u56F4","number",e.horizontalSoftRange),_("verticalSoftRange","\u5782\u76F4\u7FBD\u5316\u8303\u56F4","number",e.verticalSoftRange),_("enableFill","\u6309\u8FDB\u5EA6\u586B\u5145","bool",e.enableFill===!0,{gia:"W"}),_("fillType","\u5F62\u72B6","enum",c,{...[1,2,3,4,5].includes(l)?{}:{unknownValue:l},options:[{value:"Horizontal",label:"\u6A2A\u5411"},{value:"Vertical",label:"\u7EB5\u5411"},{value:"Radial90",label:"90\u5EA6\u73AF\u7ED5"},{value:"Radial180",label:"180\u5EA6\u73AF\u7ED5"},{value:"Radial360",label:"360\u5EA6\u73AF\u7ED5"}]}),_("fillHorizontalType","\u65B9\u5411","enum",e.fillHorizontalType,{options:[{value:"Left",label:"\u4ECE\u5DE6\u81F3\u53F3"},{value:"Right",label:"\u4ECE\u53F3\u81F3\u5DE6"}]}),_("fillVerticalType","\u65B9\u5411","enum",e.fillVerticalType,{options:[{value:"Bottom",label:"\u4ECE\u4E0B\u81F3\u4E0A"},{value:"Top",label:"\u4ECE\u4E0A\u81F3\u4E0B"}]}),_("fillRadial90Type","\u8D77\u70B9","enum",e.fillRadial90Type,{options:[{value:"BottomLeft",label:"\u5DE6\u4E0B"},{value:"TopLeft",label:"\u5DE6\u4E0A"},{value:"TopRight",label:"\u53F3\u4E0A"},{value:"BottomRight",label:"\u53F3\u4E0B"}]}),_("fillRadialType","\u8D77\u70B9","enum",e.fillRadialType,{options:[{value:"Bottom",label:"\u4E0B\u65B9"},{value:"Left",label:"\u5DE6\u4FA7"},{value:"Top",label:"\u4E0A\u65B9"},{value:"Right",label:"\u53F3\u4FA7"}]}),_("fillAmount","\u8FDB\u5EA6","percent",e.fillAmount),_("reverseMaskArea","\u906E\u7F69\u533A\u57DF\u53CD\u8F6C","bool",e.reverseMaskArea===!0,{gia:"W"}))}if(e.kind==="button"){let l=[{value:"",label:"\u672A\u8BBE\u7F6E"},...(e.children||[]).map(c=>({value:c.id,label:`${c.name} \xB7 ${c.id}`}))];a.push(_("raycastTarget","\u53EF\u88AB\u5149\u6807\u5C04\u7EBF\u68C0\u6D4B","bool",e.raycastTarget!==!1),_("interactable","\u6309\u94AE\u662F\u5426\u53EF\u7528","bool",e.interactable!==!1),_("unavailableChildId","\u4E0D\u53EF\u7528\u72B6\u6001\u8282\u70B9","node",e.unavailableChildId,{options:l,gia:"W"}),_("hoverChildId","\u60AC\u505C\u72B6\u6001\u8282\u70B9","node",e.hoverChildId,{options:l,gia:"W"}),_("pressedChildId","\u6309\u4E0B\u72B6\u6001\u8282\u70B9","node",e.pressedChildId,{options:l,gia:"W"}),_("selectedChildId","\u9009\u4E2D\u72B6\u6001\u8282\u70B9","node",e.selectedChildId,{options:l,gia:"W"}),_("clickAudioId","\u70B9\u51FB\u97F3\u6548","number",e.clickAudioId))}return e.kind==="reference"&&a.push(_("referencedPrefabId","\u5F15\u7528\u63A7\u4EF6\u6A21\u677F\u7D22\u5F15","string",e.referencedPrefabId??"")),(e.kind==="textwindow"||e.kind==="grid")&&a.push(_("interactable","\u5141\u8BB8\u6EDA\u52A8\u4EA4\u4E92","bool",e.interactable!==!1),_("showScrollBar","\u663E\u793A\u6EDA\u52A8\u6761","bool",e.showScrollBar!==!1)),e.kind==="grid"&&a.push(_("itemPrefabId","\u5217\u8868\u9879\u6A21\u677F\u7D22\u5F15","number",e.itemPrefabId??0),_("raycastTarget","\u53EF\u88AB\u5149\u6807\u5C04\u7EBF\u68C0\u6D4B","bool",e.raycastTarget!==!1),_("scrollDirection","\u6EDA\u52A8\u65B9\u5411","enum",e.scrollDirection,{options:[{value:"Vertical",label:"\u7EB5\u5411"},{value:"Horizontal",label:"\u6A2A\u5411"}]}),_("layoutConstraint","\u6392\u5217\u9650\u5236","enum",e.layoutConstraint,{options:[{value:"AutoWrap",label:"\u81EA\u52A8\u6362\u884C"},{value:"Fixed",label:"\u56FA\u5B9A\u884C\u5217\u6570"}]}),_("layoutConstraintFixedCount","\u6BCF\u884C\u6216\u6BCF\u5217\u6570\u91CF","number",e.layoutConstraintFixedCount??1),_("cellSizeX","\u5217\u8868\u9879\u5927\u5C0F W","number",e.cellSizeX,{evidence:"W"}),_("cellSizeY","\u5217\u8868\u9879\u5927\u5C0F H","number",e.cellSizeY,{evidence:"W"}),_("spacingX","\u5217\u8868\u9879\u95F4\u9694 X","number",e.spacingX,{evidence:"W"}),_("spacingY","\u5217\u8868\u9879\u95F4\u9694 Y","number",e.spacingY,{evidence:"W"}),_("padding1X","\u8FB9\u8DDD\u5411\u91CF 1 X","number",e.padding1X,{evidence:"W"}),_("padding1Y","\u8FB9\u8DDD\u5411\u91CF 1 Y","number",e.padding1Y,{evidence:"W"}),_("padding2X","\u8FB9\u8DDD\u5411\u91CF 2 X","number",e.padding2X,{evidence:"W"}),_("padding2Y","\u8FB9\u8DDD\u5411\u91CF 2 Y","number",e.padding2Y,{evidence:"W"}),_("previewCount","\u9884\u89C8\u6570\u91CF","number",e.previewCount)),e.kind==="keyhint"&&a.push(_("keyboardKeyCode","\u952E\u9F20\u6309\u952E","number",e.keyboardKeyCode??e.giaRaw?.keyHintField502??1,{gia:"W"}),_("controllerKeyCode","\u624B\u67C4\u6309\u952E","number",e.controllerKeyCode??e.giaRaw?.keyHintField501??1)),(e.kind==="animation"||e.kind==="fullscreen")&&a.push(_("animationId",e.kind==="animation"?"\u52A8\u6548\u7D22\u5F15":"\u5168\u5C4F\u52A8\u6548\u7D22\u5F15","string",e.animationId??"")),(!fi.includes(e.kind)||e.kind==="textwindow"||e.kind==="grid")&&a.push(_("incomplete","\u5B8C\u6574\u5EA6","note",e.kind==="textwindow"||e.kind==="grid"?"\u8BD5\u73A9\u652F\u6301\u57FA\u7840\u6EDA\u52A8\uFF1B\u6EDA\u52A8\u4EA4\u4E92\u3001\u6EDA\u52A8\u6761\u53CA\u5217\u8868\u914D\u7F6E\u4EE5 JSON/Lua \u4E3A\u51C6\uFF0C\u76F8\u5173 GIA \u5F00\u5173\u6620\u5C04\u5C1A\u672A\u6838\u5B9E\u3002":"\u672C\u9636\u6BB5\u4EC5\u516C\u5171\u53D8\u6362\uFF0C\u4E1A\u52A1\u69FD\u4E0D\u5B8C\u6574")),{id:e.id,guid:n?.get(e.id)??(e.guid||0),kind:e.kind,label:yt[e.kind]||e.kind,incomplete:!fi.includes(e.kind),fields:a}}function xr(e,t,i){let n=(Array.isArray(e)?e:Object.values(e)).filter(r=>r.kind!=="server-container");for(let r=n.length-1;r>=0;r-=1){let o=n[r];if(!o.visible||!o.active)continue;let a=o.renderMatrix&&Vt(o.renderMatrix),l=a&&Oe(a,t,i);if(l&&l.x>=o.left&&l.x<=o.right&&l.y>=o.bottom&&l.y<=o.top)return o.id}return null}import Ya from"protobufjs";var Ba=String.raw`
2
2
  syntax = "proto3";
3
3
  // Root.graph is singular in the game's canonical schema, but template-list
4
4
  // assets legally emit field 1 more than once. Model it as repeated here so
@@ -99,10 +99,12 @@ message ImageConfig {
99
99
  message SliceVector { float field501 = 501; float field502 = 502; }
100
100
  }
101
101
  message FooterSlot { int32 field505 = 505; }
102
- `,{root:Sa}=ba.parse(va,{keepCase:!1}),xe=Sa.lookupType("Root"),Be=20,Bi=4,mr=806,pr=1657,Dt={image:23,"server-container":24,container:25,grid:26,reference:27,button:28,animation:29,fullscreen:30,textbox:31,textwindow:32,cursor:33,keyhint:34},gr={"server-container":1,container:2,textbox:3,cursor:4,reference:5,grid:6,button:7,textwindow:8,keyhint:9,image:10,animation:11,fullscreen:12},yr={KEYBOARD:0,TOUCHSCREEN:1,CONTROLLER_CONSOLE:2,CONTROLLER_MOBILE:3},Ca="server-control-template",fi="client-control-template";function ci(e,t){let i=Number(e);return Number.isFinite(i)?i:t}var Ia=Object.fromEntries(Object.entries(yr).map(([e,t])=>[t,e])),br=Object.freeze({container:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["68/91","empty78","containerNodeSlot"],["67/90","empty77","footerSlot"]],textbox:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["64/84","empty74","textConfig"],["67/90","empty77","footerSlot"]],cursor:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["65/85","empty75","cursorConfig"],["67/90","empty77","footerSlot"]],reference:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["66/89","empty76","templateRefSlot"],["67/90","empty77","footerSlot"]],grid:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["69/92","empty79","gridView"],["67/90","empty77","footerSlot"]],button:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["70/93","empty80","buttonPreset"],["67/90","empty77","footerSlot"]],textwindow:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["71/94","empty81","textConfig"],["67/90","empty77","footerSlot"]],keyhint:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["72/95","empty82","keyHint"],["67/90","empty77","footerSlot"]],image:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["73/96","empty83","imageSlot"],["74/97","empty84","image"],["67/90","empty77","footerSlot"]],animation:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["75/98","empty85","effectSlot"],["67/90","empty77","footerSlot"]],fullscreen:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["76/99","empty86","fullscreenEffectSlot"],["67/90","empty77","footerSlot"]]}),vr=Object.freeze({"4/23":5,"4/86":5,"1/12":4,"62/82":64,"63/83":65,"64/84":66,"65/85":67,"66/89":68,"67/90":69,"68/91":70,"69/92":71,"70/93":72,"71/94":66,"72/95":74,"73/96":75,"74/97":76,"75/98":77,"76/99":78}),wa=Object.freeze([["2/15","name",null],["4/23","field14","field14"],["1/12","transform","transform"],["62/82","empty72","rootChildRef"]]);function Xi(e){return{class:1,type:8,id:e}}function zt(e,t,i,n){return{...n,field501:t,field502:i,field503:1,nodeRef:Xi(e)}}function xa(e){let t=[],i=e.meta?.assetType==="client-control-template";return j(e.root,n=>{i&&n.kind==="server-container"||t.push(n)}),t}function Vt(e,t=new Set){let i=new Map,n=[];for(let r of xa(e)){let o=Number(r.guid);we(o)&&!t.has(o)?(t.add(o),r.guid=o,i.set(r.id,o)):n.push(r)}for(let r of n){let o=ze(t);t.add(o),r.guid=o,i.set(r.id,o)}return i}function Ea(e){return{scale:{x:e.scale.x,y:e.scale.y,z:e.scale.z},anchorMin:{x:e.anchorMin.x,y:e.anchorMin.y},anchorMax:{x:e.anchorMax.x,y:e.anchorMax.y},offset:{x:e.offset.x,y:e.offset.y},size:{x:e.size.x,y:e.size.y},pivot:{x:e.pivot.x,y:e.pivot.y},field508:e.rotation.z?{z:e.rotation.z}:{}}}function Aa(e,t){let n={multiPlatform:{platforms:se.map(r=>({platformType:yr[r],transform:Ea(e.transformByPlatform[r])})),field502:Dt[e.kind]||25,...e.syncAllDevices===!1?{}:{field504:1}},type:2};return{transform:{multiPlatform:{},type:2},field501:1,field502:12,details:zt(t,4,12,{transform:n})}}function ka(e,t,i){let n=i?{empty15:"",field501:5}:{field17:{},field501:7},r=i?n:{...n,...e.visible===!1?{field17:{initiallyHidden:!0}}:{},...e.active===!1?{initiallyInactive:!0}:{}};return[{name:{value:e.name},field501:2,field502:15},{field14:n,field501:4,field502:i?23:86,details:zt(t,5,i?23:86,{field14:r})},Aa(e,t)]}function _a(e,t,i,n){let r=(s,f,m,h,g)=>({[m]:"",field501:s,field502:f,details:zt(t,s+2,f,{[h]:g})}),o=e.giaRaw||{},a=Array.isArray(e.scriptMappingIds)&&e.scriptMappingIds.length?{field501:o.genericField501||1,field502:e.scriptMappingIds.map(s=>({field1:{id:Number(s)}}))}:{field501:o.genericField501??0},l=r(63,83,"empty73","genericSlot",a),c=r(67,90,"empty77","footerSlot",{field505:[void 0,0,1].includes(o.footerField505)?e.canControllerFocus?1:0:o.footerField505});if(e.kind==="container")return[l,r(68,91,"empty78","containerNodeSlot",{...e.isolateNavigation?{isolateNavigation:!0}:{},...e.disableKeyEventPassthrough?{disableKeyEventPassthrough:!0}:{},...e.disableCursorEventPassthrough?{disableCursorEventPassthrough:!0}:{},...e.showCursor?{showCursor:!0}:{}}),c];if(e.kind==="textbox"||e.kind==="textwindow"){e.verticalAlignment==="Middle"&&n.push(`${e.name}: \u5782\u76F4\u5C45\u4E2D\u6309\u63A8\u5B9A\u503C\u5BFC\u51FA\uFF0C\u5C1A\u5F85\u5B9E\u673A\u786E\u8BA4\u3002`);let s={Left:0,Middle:1,Right:2}[e.horizontalAlignment]??0,f=Number.isFinite(o.textAlign)?Math.trunc(o.textAlign):s,m={field501:o.textField501??20,field503:o.textField503??12,color:e.fontColor>>>0,color2:e.bgColor>>>0,color3:e.outlineColor>>>0,text:{value:e.text||""},fontSize:Math.trunc(e.fontSize),minimumFontSize:Math.trunc(e.minimumFontSize),...e.adaptiveFontSize?{adaptive:1}:{},...e.enableOutline===!1?{outlineOff:1}:{},...f?{align:f}:{},verticalAlign:o.textVerticalAlign??{Top:0,Middle:1,Bottom:2}[e.verticalAlignment]??0};return e.kind==="textwindow"?(m.field511=o.textField511??1,m.viewFlags={field502:o.textViewField502??1,field503:o.textViewField503??1},[l,{empty81:"",field501:71,field502:94,details:zt(t,66,94,{textConfig:m})},c]):[l,r(64,84,"empty74","textConfig",m),c]}if(e.kind==="image"){let s={Horizontal:1,Vertical:2,Radial90:3,Radial180:4,Radial360:5}[e.fillType],f=Number.isFinite(o.imageFillType)?Math.trunc(o.imageFillType):s||1;e.enableFill&&!f&&n.push(`${e.name}: \u586B\u5145\u5F62\u72B6\u539F\u59CB\u679A\u4E3E\u4E3A 0\uFF0C\u5DF2\u5173\u95ED\u5BFC\u51FA\u6587\u4EF6\u4E2D\u7684\u8FDB\u5EA6\u586B\u5145\u3002`),e.fillType==="Horizontal"&&e.fillHorizontalType!=="Left"&&n.push(`${e.name}: \u5F53\u524D\u6A2A\u5411\u586B\u5145\u65B9\u5411\u6682\u4E0D\u652F\u6301\u5199\u5165 GIA\u3002`),e.fillType==="Radial180"&&e.fillRadialType!=="Bottom"&&n.push(`${e.name}: \u5F53\u524D 180 \u5EA6\u586B\u5145\u8D77\u70B9\u6682\u4E0D\u652F\u6301\u5199\u5165 GIA\u3002`);let m={field502:o.imageField502??1,field504:o.imageField504??1,field505:o.imageField505??1,field507:o.imageField507??2,field508:Math.round(Math.max(0,Math.min(1,Number(e.fillAmount)||0))*100),border:{field501:ci(e.softEdgeWidthX,8),field502:ci(e.softEdgeWidthY,8)},field512:ci(e.horizontalSoftRange,85),field513:ci(e.verticalSoftRange,85),fillType:f,...e.enableMask?{enableMask:1}:{},...e.enableSoftEdge?{enableSoftEdge:1}:{},...e.softEdgeMode==="Pixel"?{softEdgePixel:1}:{},...e.enableFill&&f?{enableFill:1}:{},...e.reverseMaskArea?{reverseMask:1}:{}};return[l,r(73,96,"empty83","imageSlot",{field502:Number.isFinite(e.imageColor)?e.imageColor>>>0:4294967295,assetId:e.imageId>>>0}),r(74,97,"empty84","image",m),c]}if(e.kind==="button"){let s=(b,w)=>{let M=e[b];return M?(e.children||[]).some(E=>E.id===M)?i.get(M)||0:(n.push(`${e.name}: ${w}\u72B6\u6001\u8282\u70B9\u4E0D\u662F\u6309\u94AE\u7684\u76F4\u63A5\u5B50\u63A7\u4EF6\uFF0CGIA \u672A\u5199\u5165\u8BE5\u72B6\u6001\u3002`),0):0},f=s("unavailableChildId","\u4E0D\u53EF\u7528"),m=s("hoverChildId","\u60AC\u505C"),h=s("pressedChildId","\u6309\u4E0B"),g=s("selectedChildId","\u9009\u4E2D");return[l,r(70,93,"empty80","buttonPreset",{clickAudioId:Math.trunc(e.clickAudioId),...f?{disabledChild:f}:{},...m?{hoverChild:m}:{},...h?{pressedChild:h}:{},...g?{selectedChild:g}:{},...e.interactable?{interactable:1}:{},...e.raycastTarget?{raycastTarget:1}:{}}),c]}return e.kind==="cursor"?[l,r(65,85,"empty75","cursorConfig",{field501:[void 0,0,1].includes(o.cursorField501)?e.raycastTarget!==!1?1:0:o.cursorField501}),c]:e.kind==="reference"?[l,r(66,89,"empty76","templateRefSlot",o.templateRefSlot??""),c]:e.kind==="grid"?[l,r(69,92,"empty79","gridView",{field501:o.gridField501??1,cellSize:{field501:e.cellSizeX,field502:e.cellSizeY},gap:{field501:e.spacingX,field502:e.spacingY},padding1:{field501:e.padding1X,field502:e.padding1Y},padding2:{field501:e.padding2X,field502:e.padding2Y},field507:o.gridField507??1,field508:o.gridField508??1,field509:o.gridField509??1,field511:o.gridField511??5,field512:o.gridField512??1}),c]:e.kind==="keyhint"?[l,r(72,95,"empty82","keyHint",{field501:Number.isFinite(o.keyHintField501)?Math.trunc(o.keyHintField501):e.controllerKeyCode??1,field502:Number.isFinite(o.keyHintField502)?Math.trunc(o.keyHintField502):e.keyboardKeyCode??1}),c]:e.kind==="animation"?[l,r(75,98,"empty85","effectSlot",o.effectSlot??""),c]:e.kind==="fullscreen"?[l,r(76,99,"empty86","fullscreenEffectSlot",o.fullscreenEffectSlot??""),c]:(n.push(`${e.name}: ${e.kind} \u4E0D\u662F\u5DF2\u77E5 GIA \u63A7\u4EF6\u7C7B\u578B\uFF0C\u5DF2\u4EC5\u5199\u516C\u5171\u53D8\u6362\u3002`),[l,c])}function Ta(e,t){return t?1:Number.isSafeInteger(Number(e.giaInfoIndex))&&Number(e.giaInfoIndex)>0?Number(e.giaInfoIndex):gr[e.kind]||2}function Ra(e,t,i){let n=Array.isArray(e.giaRelatedGuids)?e.giaRelatedGuids.filter(r=>Number.isSafeInteger(r)&&r>0&&r<=2147483647):[];return n.length?n:(t.push(`${e.name}: \u65B0${i}\u5199\u5165\u663E\u5F0F\u7A7A Info.related\uFF0C\u907F\u514D\u8DE8\u6C99\u7BB1\u590D\u7528\u4F34\u751F\u8D44\u6E90 GUID \u4EA7\u751F\u65E0\u6CD5\u52A0\u8F7D\u7684\u7D22\u5F15\u3002`),[])}function Ki(e,t){let i=String(e.meta?.giaFilePath||"").trim();if(/^\d+-\d+-\d+-\\.+\.gia$/iu.test(i))return i;let n=(s,f)=>Number.isSafeInteger(Number(s))&&Number(s)>0?Number(s):f,r=n(e.meta?.giaOwnerUid,114514),o=n(e.meta?.giaTimestamp,Math.floor(Date.now()/1e3)),a=n(e.meta?.giaFileId,t?1073741829:1073741830),l=t?"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u5217\u8868.gia":"\u670D\u52A1\u7AEF\u63A7\u4EF6\u6A21\u677F-\u5BA2\u6237\u7AEF\u63A7\u4EF6\u5BB9\u5668.gia",c=String(e.meta?.giaFileName||l).replace(/[\\/:*?"<>|]/gu,"-").replace(/\.gia$/iu,"").trim()||l.replace(/\.gia$/iu,"");return`${r}-${o}-${a}-\\${c}.gia`}function di(e,t,i,n,r,o=!1,a=!1,l=a,c=!1){let s=i.get(e.id),m=(c?[...e.children||[]].reverse():e.children||[]).map(b=>i.get(b.id)),h=o?n:m,g=ka(e,s,o);if(o){let b=e.children?.[0];b&&g.push({empty72:"",field501:62,field502:82,details:zt(s,64,82,{rootChildRef:{guid:i.get(b.id)}})})}else g.push(..._a(e,s,i,r));return{id:Xi(s),relatedIds:h.map(b=>Xi(b)),name:e.name,which:o?21:a?70:15,ui:{content:{guid:s,info:[{guid:{value:s},field501:1,field502:5},...o||l?[{index:{value:Ta(e,o)},field501:2,field502:6}]:[],...o||a?[{related:{value:Ra(e,r,o?"\u670D\u52A1\u7AEF\u63A7\u4EF6\u6A21\u677F":"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F")},field501:4,field502:4}]:[]],children:o?[]:m,parent:t&&t.kind!=="server-container"?i.get(t.id):0,data:g}}}}function Sr(e){let t=[];return j(e.root,(i,n)=>{i.kind!=="server-container"&&t.push({node:i,parent:n})}),t}function Pa(e,t){let i=new Map;for(let n of e||[]){if(!n.controlId||!(t===fi?n.controlAsset===fi:n.controlAsset!==fi))continue;let o=i.get(n.controlId)||[];o.push(n.guid),i.set(n.controlId,o)}return i}function Cr(e,t,i,n){let r=Pa(t,i),o=new Map;j(e.root,a=>{r.has(a.id)&&(o.set(a,a.scriptMappingIds),a.scriptMappingIds=r.get(a.id))});try{return n()}finally{for(let[a,l]of o)l===void 0?delete a.scriptMappingIds:a.scriptMappingIds=l}}function Hi(e){let t=Number(e.meta?.giaModeFlag);return Number.isSafeInteger(t)&&t>=0?{modeFlag:t}:{}}function Ir(e,t,i,n,r=[]){let o=Sr(e),a=o.filter(({parent:f})=>f?.kind==="server-container");if(!a.length)throw new Error("\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u5217\u8868\u81F3\u5C11\u9700\u8981\u4E00\u4E2A\u6A21\u677F");let l=new Set(a.map(({node:f})=>f.id)),c=o.filter(({node:f})=>!l.has(f.id)),s=o.map(({node:f})=>t.get(f.id));return Cr(e,r,fi,()=>({graph:a.map(({node:f,parent:m})=>di(f,m,t,s,i,!1,!0)),accessories:c.map(({node:f,parent:m})=>di(f,m,t,s,i,!1,!1,!0)),filePath:n||Ki(e,!0),gameVersion:e.meta?.gameVersion||"7.0.50",...Hi(e)}))}function wr(e,t,i,n,r){let o=Sr(e),a=[o[0],...o.slice(1).reverse()],l=a.map(({node:c})=>t.get(c.id));return Cr(e,i.scripts,Ca,()=>({graph:[di(e.root,null,t,l,n,!0,!1,!1,!0),...i.units||[]],accessories:a.map(({node:c,parent:s})=>di(c,s,t,l,n,!1,!1,!1,!0)),filePath:r||Ki(e,!1),gameVersion:e.meta?.gameVersion||"7.0.50",...Hi(e)}))}function xr(e,t){let i=Tr(e),n=t(i);if(!n.valid)throw new Error(`GIA compatibility validation failed:
102
+ `,{root:Ua}=Ya.parse(Ba,{keepCase:!1}),ke=Ua.lookupType("Root"),Xe=20,en=4,Er=806,Ar=1657,Ut={image:23,"server-container":24,container:25,grid:26,reference:27,button:28,animation:29,fullscreen:30,textbox:31,textwindow:32,cursor:33,keyhint:34},_r={"server-container":1,container:2,textbox:3,cursor:4,reference:5,grid:6,button:7,textwindow:8,keyhint:9,image:10,animation:11,fullscreen:12},Pr={KEYBOARD:0,TOUCHSCREEN:1,CONTROLLER_CONSOLE:2,CONTROLLER_MOBILE:3},ja="server-control-template",pi="client-control-template";function mi(e,t){let i=Number(e);return Number.isFinite(i)?i:t}var Xa=Object.fromEntries(Object.entries(Pr).map(([e,t])=>[t,e])),Rr=Object.freeze({container:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["68/91","empty78","containerNodeSlot"],["67/90","empty77","footerSlot"]],textbox:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["64/84","empty74","textConfig"],["67/90","empty77","footerSlot"]],cursor:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["65/85","empty75","cursorConfig"],["67/90","empty77","footerSlot"]],reference:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["66/89","empty76","templateRefSlot"],["67/90","empty77","footerSlot"]],grid:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["69/92","empty79","gridView"],["67/90","empty77","footerSlot"]],button:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["70/93","empty80","buttonPreset"],["67/90","empty77","footerSlot"]],textwindow:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["71/94","empty81","textConfig"],["67/90","empty77","footerSlot"]],keyhint:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["72/95","empty82","keyHint"],["67/90","empty77","footerSlot"]],image:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["73/96","empty83","imageSlot"],["74/97","empty84","image"],["67/90","empty77","footerSlot"]],animation:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["75/98","empty85","effectSlot"],["67/90","empty77","footerSlot"]],fullscreen:[["2/15","name",null],["4/86","field14","field14"],["1/12","transform","transform"],["63/83","empty73","genericSlot"],["76/99","empty86","fullscreenEffectSlot"],["67/90","empty77","footerSlot"]]}),Tr=Object.freeze({"4/23":5,"4/86":5,"1/12":4,"62/82":64,"63/83":65,"64/84":66,"65/85":67,"66/89":68,"67/90":69,"68/91":70,"69/92":71,"70/93":72,"71/94":66,"72/95":74,"73/96":75,"74/97":76,"75/98":77,"76/99":78}),Ha=Object.freeze([["2/15","name",null],["4/23","field14","field14"],["1/12","transform","transform"],["62/82","empty72","rootChildRef"]]);function tn(e){return{class:1,type:8,id:e}}function jt(e,t,i,n){return{...n,field501:t,field502:i,field503:1,nodeRef:tn(e)}}function Ka(e){let t=[],i=e.meta?.assetType==="client-control-template";return L(e.root,n=>{i&&n.kind==="server-container"||t.push(n)}),t}function Xt(e,t=new Set){let i=new Map,n=[];for(let r of Ka(e)){let o=Number(r.guid);xe(o)&&!t.has(o)?(t.add(o),r.guid=o,i.set(r.id,o)):n.push(r)}for(let r of n){let o=Ye(t);t.add(o),r.guid=o,i.set(r.id,o)}return i}function qa(e){return{scale:{x:e.scale.x,y:e.scale.y,z:e.scale.z},anchorMin:{x:e.anchorMin.x,y:e.anchorMin.y},anchorMax:{x:e.anchorMax.x,y:e.anchorMax.y},offset:{x:e.offset.x,y:e.offset.y},size:{x:e.size.x,y:e.size.y},pivot:{x:e.pivot.x,y:e.pivot.y},field508:e.rotation.z?{z:e.rotation.z}:{}}}function La(e,t){let n={multiPlatform:{platforms:se.map(r=>({platformType:Pr[r],transform:qa(e.transformByPlatform[r])})),field502:Ut[e.kind]||25,...e.syncAllDevices===!1?{}:{field504:1}},type:2};return{transform:{multiPlatform:{},type:2},field501:1,field502:12,details:jt(t,4,12,{transform:n})}}function Wa(e,t,i){let n=i?{empty15:"",field501:5}:{field17:{},field501:7},r=i?n:{...n,...e.visible===!1?{field17:{initiallyHidden:!0}}:{},...e.active===!1?{initiallyInactive:!0}:{}};return[{name:{value:e.name},field501:2,field502:15},{field14:n,field501:4,field502:i?23:86,details:jt(t,5,i?23:86,{field14:r})},La(e,t)]}function Ja(e,t,i,n){let r=(s,f,h,m,p)=>({[h]:"",field501:s,field502:f,details:jt(t,s+2,f,{[m]:p})}),o=e.giaRaw||{},a=Array.isArray(e.scriptMappingIds)&&e.scriptMappingIds.length?{field501:o.genericField501||1,field502:e.scriptMappingIds.map(s=>({field1:{id:Number(s)}}))}:{field501:o.genericField501??0},l=r(63,83,"empty73","genericSlot",a),c=r(67,90,"empty77","footerSlot",{field505:[void 0,0,1].includes(o.footerField505)?e.canControllerFocus?1:0:o.footerField505});if(e.kind==="container")return[l,r(68,91,"empty78","containerNodeSlot",{...e.isolateNavigation?{isolateNavigation:!0}:{},...e.disableKeyEventPassthrough?{disableKeyEventPassthrough:!0}:{},...e.disableCursorEventPassthrough?{disableCursorEventPassthrough:!0}:{},...e.showCursor?{showCursor:!0}:{}}),c];if(e.kind==="textbox"||e.kind==="textwindow"){e.verticalAlignment==="Middle"&&n.push(`${e.name}: \u5782\u76F4\u5C45\u4E2D\u6309\u63A8\u5B9A\u503C\u5BFC\u51FA\uFF0C\u5C1A\u5F85\u5B9E\u673A\u786E\u8BA4\u3002`);let s={Left:0,Middle:1,Right:2}[e.horizontalAlignment]??0,f=Number.isFinite(o.textAlign)?Math.trunc(o.textAlign):s,h={field501:o.textField501??20,field503:o.textField503??12,color:e.fontColor>>>0,color2:e.bgColor>>>0,color3:e.outlineColor>>>0,text:{value:e.text||""},fontSize:Math.trunc(e.fontSize),minimumFontSize:Math.trunc(e.minimumFontSize),...e.adaptiveFontSize?{adaptive:1}:{},...e.enableOutline===!1?{outlineOff:1}:{},...f?{align:f}:{},verticalAlign:o.textVerticalAlign??{Top:0,Middle:1,Bottom:2}[e.verticalAlignment]??0};return e.kind==="textwindow"?((e.interactable===!1||e.showScrollBar===!1)&&n.push(`${e.name}: \u6587\u672C\u89C6\u7A97\u4EA4\u4E92/\u6EDA\u52A8\u6761\u5F00\u5173\u4EC5\u4FDD\u5B58\u5728 JSON\uFF0CGIA \u672A\u6620\u5C04\u8FD9\u4E9B\u6539\u52A8\u3002`),h.field511=o.textField511??1,h.viewFlags={field502:o.textViewField502??1,field503:o.textViewField503??1},[l,{empty81:"",field501:71,field502:94,details:jt(t,66,94,{textConfig:h})},c]):[l,r(64,84,"empty74","textConfig",h),c]}if(e.kind==="image"){let s={Horizontal:1,Vertical:2,Radial90:3,Radial180:4,Radial360:5}[e.fillType],f=Number.isFinite(o.imageFillType)?Math.trunc(o.imageFillType):s||1;e.enableFill&&!f&&n.push(`${e.name}: \u586B\u5145\u5F62\u72B6\u539F\u59CB\u679A\u4E3E\u4E3A 0\uFF0C\u5DF2\u5173\u95ED\u5BFC\u51FA\u6587\u4EF6\u4E2D\u7684\u8FDB\u5EA6\u586B\u5145\u3002`),e.fillType==="Horizontal"&&e.fillHorizontalType!=="Left"&&n.push(`${e.name}: \u5F53\u524D\u6A2A\u5411\u586B\u5145\u65B9\u5411\u6682\u4E0D\u652F\u6301\u5199\u5165 GIA\u3002`),e.fillType==="Radial180"&&e.fillRadialType!=="Bottom"&&n.push(`${e.name}: \u5F53\u524D 180 \u5EA6\u586B\u5145\u8D77\u70B9\u6682\u4E0D\u652F\u6301\u5199\u5165 GIA\u3002`);let h={field502:o.imageField502??1,field504:o.imageField504??1,field505:o.imageField505??1,field507:o.imageField507??2,field508:Math.round(Math.max(0,Math.min(1,Number(e.fillAmount)||0))*100),border:{field501:mi(e.softEdgeWidthX,8),field502:mi(e.softEdgeWidthY,8)},field512:mi(e.horizontalSoftRange,85),field513:mi(e.verticalSoftRange,85),fillType:f,...e.enableMask?{enableMask:1}:{},...e.enableSoftEdge?{enableSoftEdge:1}:{},...e.softEdgeMode==="Pixel"?{softEdgePixel:1}:{},...e.enableFill&&f?{enableFill:1}:{},...e.reverseMaskArea?{reverseMask:1}:{}};return[l,r(73,96,"empty83","imageSlot",{field502:Number.isFinite(e.imageColor)?e.imageColor>>>0:4294967295,assetId:e.imageId>>>0}),r(74,97,"empty84","image",h),c]}if(e.kind==="button"){let s=(y,v)=>{let E=e[y];return E?(e.children||[]).some(x=>x.id===E)?i.get(E)||0:(n.push(`${e.name}: ${v}\u72B6\u6001\u8282\u70B9\u4E0D\u662F\u6309\u94AE\u7684\u76F4\u63A5\u5B50\u63A7\u4EF6\uFF0CGIA \u672A\u5199\u5165\u8BE5\u72B6\u6001\u3002`),0):0},f=s("unavailableChildId","\u4E0D\u53EF\u7528"),h=s("hoverChildId","\u60AC\u505C"),m=s("pressedChildId","\u6309\u4E0B"),p=s("selectedChildId","\u9009\u4E2D");return[l,r(70,93,"empty80","buttonPreset",{clickAudioId:Math.trunc(e.clickAudioId),...f?{disabledChild:f}:{},...h?{hoverChild:h}:{},...m?{pressedChild:m}:{},...p?{selectedChild:p}:{},...e.interactable?{interactable:1}:{},...e.raycastTarget?{raycastTarget:1}:{}}),c]}return e.kind==="cursor"?[l,r(65,85,"empty75","cursorConfig",{field501:[void 0,0,1].includes(o.cursorField501)?e.raycastTarget!==!1?1:0:o.cursorField501}),c]:e.kind==="reference"?[l,r(66,89,"empty76","templateRefSlot",o.templateRefSlot??""),c]:e.kind==="grid"?((e.itemPrefabId||e.interactable===!1||e.showScrollBar===!1||e.raycastTarget===!1||e.scrollDirection!=="Vertical"||e.layoutConstraint!=="AutoWrap")&&n.push(`${e.name}: \u7F51\u683C\u5217\u8868\u9879\u6A21\u677F\u3001\u4EA4\u4E92/\u6EDA\u52A8\u6761\u5F00\u5173\u3001\u6EDA\u52A8\u65B9\u5411\u53CA\u6392\u5217\u9650\u5236\u4EC5\u4FDD\u5B58\u5728 JSON\uFF0CGIA \u672A\u6620\u5C04\u8FD9\u4E9B\u6539\u52A8\u3002`),[l,r(69,92,"empty79","gridView",{field501:o.gridField501??1,cellSize:{field501:e.cellSizeX,field502:e.cellSizeY},gap:{field501:e.spacingX,field502:e.spacingY},padding1:{field501:e.padding1X,field502:e.padding1Y},padding2:{field501:e.padding2X,field502:e.padding2Y},field507:o.gridField507??1,field508:o.gridField508??1,field509:o.gridField509??1,field511:o.gridField511??5,field512:o.gridField512??1}),c]):e.kind==="keyhint"?[l,r(72,95,"empty82","keyHint",{field501:Number.isFinite(o.keyHintField501)?Math.trunc(o.keyHintField501):e.controllerKeyCode??1,field502:Number.isFinite(o.keyHintField502)?Math.trunc(o.keyHintField502):e.keyboardKeyCode??1}),c]:e.kind==="animation"?[l,r(75,98,"empty85","effectSlot",o.effectSlot??""),c]:e.kind==="fullscreen"?[l,r(76,99,"empty86","fullscreenEffectSlot",o.fullscreenEffectSlot??""),c]:(n.push(`${e.name}: ${e.kind} \u4E0D\u662F\u5DF2\u77E5 GIA \u63A7\u4EF6\u7C7B\u578B\uFF0C\u5DF2\u4EC5\u5199\u516C\u5171\u53D8\u6362\u3002`),[l,c])}function Za(e,t){return t?1:Number.isSafeInteger(Number(e.giaInfoIndex))&&Number(e.giaInfoIndex)>0?Number(e.giaInfoIndex):_r[e.kind]||2}function Qa(e,t,i){let n=Array.isArray(e.giaRelatedGuids)?e.giaRelatedGuids.filter(r=>Number.isSafeInteger(r)&&r>0&&r<=2147483647):[];return n.length?n:(t.push(`${e.name}: \u65B0${i}\u5199\u5165\u663E\u5F0F\u7A7A Info.related\uFF0C\u907F\u514D\u8DE8\u6C99\u7BB1\u590D\u7528\u4F34\u751F\u8D44\u6E90 GUID \u4EA7\u751F\u65E0\u6CD5\u52A0\u8F7D\u7684\u7D22\u5F15\u3002`),[])}function nn(e,t){let i=String(e.meta?.giaFilePath||"").trim();if(/^\d+-\d+-\d+-\\.+\.gia$/iu.test(i))return i;let n=(s,f)=>Number.isSafeInteger(Number(s))&&Number(s)>0?Number(s):f,r=n(e.meta?.giaOwnerUid,114514),o=n(e.meta?.giaTimestamp,Math.floor(Date.now()/1e3)),a=n(e.meta?.giaFileId,t?1073741829:1073741830),l=t?"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u5217\u8868.gia":"\u670D\u52A1\u7AEF\u63A7\u4EF6\u6A21\u677F-\u5BA2\u6237\u7AEF\u63A7\u4EF6\u5BB9\u5668.gia",c=String(e.meta?.giaFileName||l).replace(/[\\/:*?"<>|]/gu,"-").replace(/\.gia$/iu,"").trim()||l.replace(/\.gia$/iu,"");return`${r}-${o}-${a}-\\${c}.gia`}function gi(e,t,i,n,r,o=!1,a=!1,l=a,c=!1){let s=i.get(e.id),h=(c?[...e.children||[]].reverse():e.children||[]).map(y=>i.get(y.id)),m=o?n:h,p=Wa(e,s,o);if(o){let y=e.children?.[0];y&&p.push({empty72:"",field501:62,field502:82,details:jt(s,64,82,{rootChildRef:{guid:i.get(y.id)}})})}else p.push(...Ja(e,s,i,r));return{id:tn(s),relatedIds:m.map(y=>tn(y)),name:e.name,which:o?21:a?70:15,ui:{content:{guid:s,info:[{guid:{value:s},field501:1,field502:5},...o||l?[{index:{value:Za(e,o)},field501:2,field502:6}]:[],...o||a?[{related:{value:Qa(e,r,o?"\u670D\u52A1\u7AEF\u63A7\u4EF6\u6A21\u677F":"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F")},field501:4,field502:4}]:[]],children:o?[]:h,parent:t&&t.kind!=="server-container"?i.get(t.id):0,data:p}}}}function Mr(e){let t=[];return L(e.root,(i,n)=>{i.kind!=="server-container"&&t.push({node:i,parent:n})}),t}function el(e,t){let i=new Map;for(let n of e||[]){if(!n.controlId||!(t===pi?n.controlAsset===pi:n.controlAsset!==pi))continue;let o=i.get(n.controlId)||[];o.push(n.guid),i.set(n.controlId,o)}return i}function Nr(e,t,i,n){let r=el(t,i),o=new Map;L(e.root,a=>{r.has(a.id)&&(o.set(a,a.scriptMappingIds),a.scriptMappingIds=r.get(a.id))});try{return n()}finally{for(let[a,l]of o)l===void 0?delete a.scriptMappingIds:a.scriptMappingIds=l}}function rn(e){let t=Number(e.meta?.giaModeFlag);return Number.isSafeInteger(t)&&t>=0?{modeFlag:t}:{}}function Fr(e,t,i,n,r=[]){let o=Mr(e),a=o.filter(({parent:f})=>f?.kind==="server-container");if(!a.length)throw new Error("\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u5217\u8868\u81F3\u5C11\u9700\u8981\u4E00\u4E2A\u6A21\u677F");let l=new Set(a.map(({node:f})=>f.id)),c=o.filter(({node:f})=>!l.has(f.id)),s=o.map(({node:f})=>t.get(f.id));return Nr(e,r,pi,()=>({graph:a.map(({node:f,parent:h})=>gi(f,h,t,s,i,!1,!0)),accessories:c.map(({node:f,parent:h})=>gi(f,h,t,s,i,!1,!1,!0)),filePath:n||nn(e,!0),gameVersion:e.meta?.gameVersion||"7.0.50",...rn(e)}))}function Or(e,t,i,n,r){let o=Mr(e),a=[o[0],...o.slice(1).reverse()],l=a.map(({node:c})=>t.get(c.id));return Nr(e,i.scripts,ja,()=>({graph:[gi(e.root,null,t,l,n,!0,!1,!1,!0),...i.units||[]],accessories:a.map(({node:c,parent:s})=>gi(c,s,t,l,n,!1,!1,!1,!0)),filePath:r||nn(e,!1),gameVersion:e.meta?.gameVersion||"7.0.50",...rn(e)}))}function zr(e,t){let i=Yr(e),n=t(i);if(!n.valid)throw new Error(`GIA compatibility validation failed:
103
103
  ${n.errors.join(`
104
- `)}`);return i}function Er(e,t={}){j(e.root,et);let i=Vt(G(e)),n=[],r=e.meta?.assetType==="client-control-template",o;if(r)o=Ir(e,i,n,void 0,t.scripts||[]);else{let l=Li(t.scripts||[],new Set(i.values()));n.push(...l.warnings),o=wr(e,i,l,n)}return{buffer:xr(o,r?Or:ji),warnings:[...new Set(n)]}}function Ar(e,t,i={}){j(e.root,et),t&&j(t.root,et);let n=["\u6574\u5408\u5305\u628A\u670D\u52A1\u7AEF UIControlGroup \u4E0E\u5BA2\u6237\u7AEF UIControlTemplate \u5E76\u6392\u5199\u5165\u540C\u4E00 GIA \u7684 Root.graph\uFF1B\u5BFC\u5165\u65F6\u62C6\u56DE\u4E24\u7C7B\u8D44\u4EA7\uFF0C\u6A21\u677F\u8FB9\u754C\u3001\u811A\u672C\u6620\u5C04\u4E0E\u63A7\u4EF6\u6302\u8F7D\u5173\u7CFB\u4F1A\u4FDD\u7559\u3002"],r=t?.root?.children||[];r.length||n.push("\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u4E3A\u7A7A\uFF0C\u6574\u5408\u5305\u53EA\u5305\u542B\u670D\u52A1\u7AEF\u63A7\u4EF6\u4E0E\u811A\u672C\u3002");let o=new Set,a=G(e),l=t?G(t):null,c=Vt(a,o),s=Li(i.scripts||[],o);n.push(...s.warnings.filter(M=>M!==_r));let f=String(i.fileName||`${a.meta?.name||"\u6574\u5408\u5305"} \xB7 \u6574\u5408\u5305.gia`),m=Ki({...a,meta:{...a.meta,giaFileName:f}},!1),h=wr(a,c,s,n,m),g={graph:[],accessories:[]};if(r.length&&l){let M=Vt({...l,meta:{...l.meta,assetType:"client-control-template"}},o);g=Ir(l,M,n,m,s.scripts)}let b={graph:[...h.graph,...g.graph],accessories:[...h.accessories,...g.accessories],filePath:m,gameVersion:e.meta?.gameVersion||t?.meta?.gameVersion||"7.0.50",...Hi(e)};return{buffer:xr(b,ji),warnings:[...new Set(n)]}}var Ct=69,kr=30,_r="\u811A\u672C\u6302\u8F7D\u5173\u7CFB\u4E0D\u8FDB\u5165 GIA\uFF1A\u5B98\u65B9 script.gia \u53EA\u542B\u6620\u5C04\uFF08ID/\u540D\u79F0/\u8DEF\u5F84/\u6E90\u7801\uFF09\uFF0C\u5BFC\u5165\u540E\u9700\u91CD\u65B0\u6302\u8F7D\u3002";function Ma(e){return(String(e.path||"").replace(/\\/g,"/").split("/").pop()||"").replace(/\.lua$/iu,"")||`\u811A\u672C${e.id||""}`}function Tr(e){let t=xe.verify(e);if(t)throw new Error(`GIA encode validation failed: ${t}`);let i=xe.encode(xe.create(e)).finish(),n=Buffer.alloc(Be+i.length+Bi);return n.writeUInt32BE(n.length-4,0),n.writeUInt32BE(1,4),n.writeUInt32BE(mr,8),n.writeUInt32BE(3,12),n.writeUInt32BE(i.length,16),Buffer.from(i).copy(n,Be),n.writeUInt32BE(pr,Be+i.length),n}function Li(e,t=new Set){let i=(e||[]).filter(a=>a.path||a.source).map(a=>({...a})),n=[];for(let a of i){let l=Number(a.guid);we(l)&&!t.has(l)?(t.add(l),a.guid=l):n.push(a)}for(let a of n){let l=ze(t);t.add(l),a.guid=l}let r=[];return(e||[]).some(a=>a.controlId)&&r.push(_r),{units:i.map(a=>{let l=Ma(a),c=String(a.path||"").replace(/\\/g,"/"),s=/\.lua$/iu.test(c)?c:`${c||l}.lua`,f={id:a.guid,name:l,filePath:s};return String(a.source||"")&&(f.source=String(a.source)),{id:{class:kr,id:a.guid},name:l,which:Ct,script:{mapping:f}}}),warnings:r,scripts:i}}function Rr(e){let t=Li(e);if(!t.units.length)throw new Error("\u6CA1\u6709\u53EF\u5BFC\u51FA\u7684 Lua \u811A\u672C\uFF0C\u8BF7\u5148\u5728\u201CLua \u811A\u672C\u201D\u9875\u521B\u5EFA");let i={graph:t.units,filePath:`114514-${Math.floor(Date.now()/1e3)}-1073741832-\\script.gia`,gameVersion:"7.0.51"},n=Tr(i),r=Na(n);if(!r.valid)throw new Error(`GIA compatibility validation failed:
104
+ `)}`);return i}function Dr(e,t={}){L(e.root,tt);let i=Xt(D(e)),n=[],r=e.meta?.assetType==="client-control-template",o;if(r)o=Fr(e,i,n,void 0,t.scripts||[]);else{let l=on(t.scripts||[],new Set(i.values()));n.push(...l.warnings),o=Or(e,i,l,n)}return{buffer:zr(o,r?Kr:ln),warnings:[...new Set(n)]}}function $r(e,t,i={}){L(e.root,tt),t&&L(t.root,tt);let n=["\u6574\u5408\u5305\u628A\u670D\u52A1\u7AEF UIControlGroup \u4E0E\u5BA2\u6237\u7AEF UIControlTemplate \u5E76\u6392\u5199\u5165\u540C\u4E00 GIA \u7684 Root.graph\uFF1B\u5BFC\u5165\u65F6\u62C6\u56DE\u4E24\u7C7B\u8D44\u4EA7\uFF0C\u6A21\u677F\u8FB9\u754C\u3001\u811A\u672C\u6620\u5C04\u4E0E\u63A7\u4EF6\u6302\u8F7D\u5173\u7CFB\u4F1A\u4FDD\u7559\u3002"],r=t?.root?.children||[];r.length||n.push("\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u4E3A\u7A7A\uFF0C\u6574\u5408\u5305\u53EA\u5305\u542B\u670D\u52A1\u7AEF\u63A7\u4EF6\u4E0E\u811A\u672C\u3002");let o=new Set,a=D(e),l=t?D(t):null,c=Xt(a,o),s=on(i.scripts||[],o);n.push(...s.warnings.filter(E=>E!==Vr));let f=String(i.fileName||`${a.meta?.name||"\u6574\u5408\u5305"} \xB7 \u6574\u5408\u5305.gia`),h=nn({...a,meta:{...a.meta,giaFileName:f}},!1),m=Or(a,c,s,n,h),p={graph:[],accessories:[]};if(r.length&&l){let E=Xt({...l,meta:{...l.meta,assetType:"client-control-template"}},o);p=Fr(l,E,n,h,s.scripts)}let y={graph:[...m.graph,...p.graph],accessories:[...m.accessories,...p.accessories],filePath:h,gameVersion:e.meta?.gameVersion||t?.meta?.gameVersion||"7.0.50",...rn(e)};return{buffer:zr(y,ln),warnings:[...new Set(n)]}}var It=69,Gr=30,Vr="\u811A\u672C\u6302\u8F7D\u5173\u7CFB\u4E0D\u8FDB\u5165 GIA\uFF1A\u5B98\u65B9 script.gia \u53EA\u542B\u6620\u5C04\uFF08ID/\u540D\u79F0/\u8DEF\u5F84/\u6E90\u7801\uFF09\uFF0C\u5BFC\u5165\u540E\u9700\u91CD\u65B0\u6302\u8F7D\u3002";function tl(e){return(String(e.path||"").replace(/\\/g,"/").split("/").pop()||"").replace(/\.lua$/iu,"")||`\u811A\u672C${e.id||""}`}function Yr(e){let t=ke.verify(e);if(t)throw new Error(`GIA encode validation failed: ${t}`);let i=ke.encode(ke.create(e)).finish(),n=Buffer.alloc(Xe+i.length+en);return n.writeUInt32BE(n.length-4,0),n.writeUInt32BE(1,4),n.writeUInt32BE(Er,8),n.writeUInt32BE(3,12),n.writeUInt32BE(i.length,16),Buffer.from(i).copy(n,Xe),n.writeUInt32BE(Ar,Xe+i.length),n}function on(e,t=new Set){let i=(e||[]).filter(a=>a.path||a.source).map(a=>({...a})),n=[];for(let a of i){let l=Number(a.guid);xe(l)&&!t.has(l)?(t.add(l),a.guid=l):n.push(a)}for(let a of n){let l=Ye(t);t.add(l),a.guid=l}let r=[];return(e||[]).some(a=>a.controlId)&&r.push(Vr),{units:i.map(a=>{let l=tl(a),c=String(a.path||"").replace(/\\/g,"/"),s=/\.lua$/iu.test(c)?c:`${c||l}.lua`,f={id:a.guid,name:l,filePath:s};return String(a.source||"")&&(f.source=String(a.source)),{id:{class:Gr,id:a.guid},name:l,which:It,script:{mapping:f}}}),warnings:r,scripts:i}}function Br(e){let t=on(e);if(!t.units.length)throw new Error("\u6CA1\u6709\u53EF\u5BFC\u51FA\u7684 Lua \u811A\u672C\uFF0C\u8BF7\u5148\u5728\u201CLua \u811A\u672C\u201D\u9875\u521B\u5EFA");let i={graph:t.units,filePath:`114514-${Math.floor(Date.now()/1e3)}-1073741832-\\script.gia`,gameVersion:"7.0.51"},n=Yr(i),r=il(n);if(!r.valid)throw new Error(`GIA compatibility validation failed:
105
105
  ${r.errors.join(`
106
- `)}`);return{buffer:n,warnings:[...new Set(t.warnings)]}}function Wi(e){return xe.toObject(xe.decode(mi(e)),{longs:Number,enums:Number,bytes:Buffer,defaults:!1,arrays:!0,objects:!0})}function Pr(e){try{let i=Wi(e).graph||[];return i.length>0&&i.every(n=>Number(n.which)===Ct)}catch{return!1}}function Mr(e){let t=(e.graph||[]).filter(r=>Number(r.which)===Ct),i=[],n=t.map((r,o)=>{let a=r.script?.mapping||{},l=Number(r.id?.id)||0;l<=0&&i.push(`\u7B2C ${o+1} \u6761\u811A\u672C\u6620\u5C04\u7F3A\u5C11 GraphUnit.id.id\uFF0C\u5DF2\u6309 0 \u5904\u7406\uFF08\u5BFC\u51FA\u65F6\u4F1A\u91CD\u65B0\u5206\u914D\uFF09\u3002`);let c=Number(a.id)||0;return c&&c!==l&&i.push(`\u7B2C ${o+1} \u6761\u811A\u672C\u6620\u5C04 id(${c}) \u4E0E\u5355\u5143 id(${l}) \u4E0D\u4E00\u81F4\uFF0C\u4EE5\u5355\u5143 id \u4E3A\u51C6\u3002`),{guid:l,path:String(a.filePath||""),source:String(a.source||"")}});for(let[r,o]of n.entries())o.path&&!/\.lua$/iu.test(o.path)&&i.push(`\u7B2C ${r+1} \u6761\u811A\u672C\u6620\u5C04 file_path \u7F3A\u5C11 .lua \u540E\u7F00\uFF08${o.path}\uFF09\uFF0C\u771F\u673A\u53EF\u80FD\u62D2\u7EDD\u5BFC\u5165\uFF1B\u6A21\u62DF\u5668\u5185\u6309\u5F52\u4E00\u5316\u8DEF\u5F84\u7167\u5E38 require\u3002`);return{scripts:n,warnings:i}}function Nr(e){let t=Wi(e),i=Mr(t);if(!i.scripts.length)throw new Error("GIA \u5185\u6CA1\u6709\u811A\u672C\u6620\u5C04\u5355\u5143\uFF08which=69\uFF09");return{scripts:i.scripts,warnings:i.warnings,metadata:{assetType:"lua-script"}}}function Na(e){let t=[],i;try{i=Wi(e)}catch(r){return{valid:!1,errors:[r?.message||String(r)],scriptCount:0}}let n=i.graph||[];return n.length||t.push("Root.graph \u4E3A\u7A7A"),(i.accessories||[]).length&&t.push("script.gia \u4E0D\u5E94\u5305\u542B accessories"),n.forEach((r,o)=>{let a=`\u5355\u5143 ${o+1}`;Number(r.which)!==Ct&&t.push(`${a}: which \u5E94\u4E3A 69\uFF0C\u5B9E\u9645 ${r.which}`),Number(r.id?.class)!==kr&&t.push(`${a}: id.class \u5E94\u4E3A 30\uFF0C\u5B9E\u9645 ${r.id?.class}`),Number(r.id?.type??0)!==0&&t.push(`${a}: id.type \u5E94\u7F3A\u7701`);let l=r.script?.mapping;if(!l){t.push(`${a}: \u7F3A\u5C11 field35 ScriptMappingWrapper`);return}Number(r.id?.id)<=0&&t.push(`${a}: GraphUnit.id.id \u975E\u6CD5`),Number(l.id)!==Number(r.id?.id)&&t.push(`${a}: mapping.id \u5E94\u7B49\u4E8E GraphUnit.id.id`),String(l.name||"")!==String(r.name||"")&&t.push(`${a}: mapping.name \u5E94\u7B49\u4E8E GraphUnit.name`),String(l.filePath||"").trim()?/\.lua$/iu.test(String(l.filePath))||t.push(`${a}: file_path \u5E94\u4EE5 .lua \u7ED3\u5C3E\uFF08\u5B98\u65B9 script.gia \u6837\u672C\u5747\u4E3A \u540D\u79F0.lua\uFF0C\u771F\u673A require \u65F6\u624D\u53BB\u6269\u5C55\u540D\uFF09`):t.push(`${a}: file_path \u4E3A\u7A7A`)}),{valid:t.length===0,errors:t,scriptCount:n.length}}function mi(e){let t=Buffer.isBuffer(e)?e:Buffer.from(e);if(t.length<Be+Bi)throw new Error("GIA \u6587\u4EF6\u8FC7\u77ED");if(t.readUInt32BE(4)!==1||t.readUInt32BE(8)!==mr||t.readUInt32BE(12)!==3)throw new Error("\u4E0D\u662F\u53D7\u652F\u6301\u7684 GIA v1 \u6587\u4EF6");let i=t.readUInt32BE(16);if(i!==t.length-Be-Bi)throw new Error("GIA payload \u957F\u5EA6\u4E0D\u4E00\u81F4");if(t.readUInt32BE(Be+i)!==pr)throw new Error("GIA \u5C3E\u6807\u8BB0\u65E0\u6548");return t.subarray(Be,Be+i)}function fe(e,t){return e.ui?.content?.data?.find(i=>i.details?.[t])?.details?.[t]||null}function Fa(e){let t=fe(e,"transform")?.multiPlatform,i={};for(let r of t?.platforms||[]){let o=Ia[r.platformType||0],a=r.transform||{};i[o]={scale:a.scale?{x:a.scale.x??0,y:a.scale.y??0,z:a.scale.z??0}:{x:1,y:1,z:1},rotation:{x:0,y:0,z:a.field508?.z??0},anchorMin:{x:a.anchorMin?.x??0,y:a.anchorMin?.y??0},anchorMax:{x:a.anchorMax?.x??0,y:a.anchorMax?.y??0},offset:{x:a.offset?.x??0,y:a.offset?.y??0},size:{x:a.size?.x??0,y:a.size?.y??0},pivot:a.pivot?{x:a.pivot.x??0,y:a.pivot.y??0}:{x:.5,y:.5}}}let n=i.KEYBOARD||i[Object.keys(i)[0]];if(!n)throw new Error(`GIA \u63A7\u4EF6 ${e.name||e.id?.id} \u7F3A\u5C11\u591A\u5E73\u53F0\u53D8\u6362`);for(let r of se)i[r]||(i[r]=structuredClone(n));return i}function hi(e){let t=e.ui?.content?.data||[];return t.some(i=>i.details?.textConfig)?t.some(i=>i.field501===71)?"textwindow":"textbox":t.some(i=>i.details?.cursorConfig)?"cursor":t.some(i=>Object.hasOwn(i.details||{},"templateRefSlot"))?"reference":t.some(i=>i.details?.gridView)?"grid":t.some(i=>i.details?.buttonPreset)?"button":t.some(i=>i.details?.keyHint)?"keyhint":t.some(i=>i.details?.image||i.details?.imageSlot)?"image":t.some(i=>Object.hasOwn(i.details||{},"effectSlot"))?"animation":t.some(i=>Object.hasOwn(i.details||{},"fullscreenEffectSlot"))?"fullscreen":(t.some(i=>Object.hasOwn(i.details||{},"containerNodeSlot")),"container")}function hr(e,{reverseSiblings:t=!1,idOffset:i=0}={}){if(!e.length)return{nodes:new Map,rootCandidates:[],warnings:[]};let n=new Map(e.map((s,f)=>[s.id?.id,`n${i+f+1}`])),r=new Map,o=new Map,a=[];for(let s of e){let f=hi(s),m=fe(s,"textConfig"),h=fe(s,"imageSlot"),g=fe(s,"image"),b=fe(s,"buttonPreset"),w=fe(s,"gridView"),M=fe(s,"genericSlot"),E=fe(s,"footerSlot"),A=fe(s,"cursorConfig"),U=fe(s,"keyHint"),$=fe(s,"containerNodeSlot"),q=fe(s,"templateRefSlot"),ee=fe(s,"effectSlot"),J=fe(s,"fullscreenEffectSlot"),O=H(f,{id:n.get(s.id?.id),guid:s.id?.id||0,giaInfoIndex:(s.ui?.content?.info||[]).find(y=>y.field501===2&&y.field502===6)?.index?.value,giaRelatedGuids:(s.ui?.content?.info||[]).find(y=>y.field501===4&&y.field502===4)?.related?.value||[],name:s.name||f,visible:fe(s,"field14")?.field17?.initiallyHidden!==!0,active:fe(s,"field14")?.initiallyInactive!==!0,canControllerFocus:E?.field505===1,scriptMappingIds:(M?.field502||[]).map(y=>Number(y?.field1?.id)).filter(y=>Number.isSafeInteger(y)&&y>0),transformByPlatform:Fa(s),syncAllDevices:fe(s,"transform")?.multiPlatform?.field504===1,giaRaw:{genericField501:M?.field501??0,footerField505:E?.field505??0,...f==="textbox"||f==="textwindow"?{textField501:m?.field501??20,textField503:m?.field503??12,textAlign:m?.align??0,...[void 0,0,1,2].includes(m?.verticalAlign)?{}:{textVerticalAlign:m.verticalAlign},...f==="textwindow"?{textField511:m?.field511??1,textViewField502:m?.viewFlags?.field502??1,textViewField503:m?.viewFlags?.field503??1}:{}}:{},...f==="cursor"?{cursorField501:A?.field501??0}:{},...f==="reference"?{templateRefSlot:q??""}:{},...f==="grid"?{gridField501:w?.field501??1,gridField507:w?.field507??1,gridField508:w?.field508??1,gridField509:w?.field509??1,gridField511:w?.field511??5,gridField512:w?.field512??1}:{},...f==="keyhint"?{keyHintField501:U?.field501??1,keyHintField502:U?.field502??1}:{},...f==="image"?{imageField502:g?.field502??1,imageField504:g?.field504??1,imageField505:g?.field505??1,imageField507:g?.field507??2,imageFillType:g?.fillType??1}:{},...f==="animation"?{effectSlot:ee??""}:{},...f==="fullscreen"?{fullscreenEffectSlot:J??""}:{}},...f==="container"?{isolateNavigation:$?.isolateNavigation===!0,disableKeyEventPassthrough:$?.disableKeyEventPassthrough===!0,disableCursorEventPassthrough:$?.disableCursorEventPassthrough===!0,showCursor:$?.showCursor===!0}:{},...f==="cursor"?{raycastTarget:A?.field501===1}:{},...f==="textbox"||f==="textwindow"?{text:m?.text?.value??"",fontSize:m?.fontSize??20,minimumFontSize:m?.minimumFontSize??20,adaptiveFontSize:m?.adaptive===1,fontColor:m?.color??4294967295,bgColor:m?.color2??0,enableOutline:m?.outlineOff!==1,outlineColor:m?.color3??858993459,horizontalAlignment:m?.align===1?"Middle":m?.align===2?"Right":"Left",verticalAlignment:{0:"Top",1:"Middle",2:"Bottom"}[m?.verticalAlign??0]||"Top",...f==="textwindow"?{interactable:!0,showScrollBar:!0}:{}}:{},...f==="image"?{imageSource:"StaticReference",imageId:h?.assetId??0,imageColor:Number.isFinite(h?.field502)?h.field502>>>0:4294967295,enableMask:g?.enableMask===1,enableSoftEdge:g?.enableSoftEdge===1,enableFill:g?.enableFill===1,softEdgeMode:g?.softEdgePixel===1?"Pixel":"Percentage",softEdgeWidthX:g?.border?.field501??8,softEdgeWidthY:g?.border?.field502??8,horizontalSoftRange:g?.field512??85,verticalSoftRange:g?.field513??85,fillType:{1:"Horizontal",2:"Vertical",3:"Radial90",4:"Radial180",5:"Radial360"}[g?.fillType]||"Horizontal",fillAmount:Number.isFinite(g?.field508)?Math.max(0,Math.min(1,g.field508/100)):g?.enableFill===1?0:1,reverseMaskArea:g?.reverseMask===1}:{},...f==="button"?{interactable:b?.interactable===1,raycastTarget:b?.raycastTarget===1,clickAudioId:b?.clickAudioId??50888}:{},...f==="grid"?{cellSizeX:w?.cellSize?.field501??50,cellSizeY:w?.cellSize?.field502??50,spacingX:w?.gap?.field501??8,spacingY:w?.gap?.field502??8,padding1X:w?.padding1?.field501??20,padding1Y:w?.padding1?.field502??20,padding2X:w?.padding2?.field501??20,padding2Y:w?.padding2?.field502??20,previewCount:w?.field511??5}:{},...f==="reference"?{referencedPrefabId:q??""}:{},...f==="keyhint"?{keyboardKeyCode:U?.field502??null,controllerKeyCode:U?.field501??null}:{},...f==="animation"?{animationId:ee??""}:{},...f==="fullscreen"?{animationId:J??""}:{}});r.set(s.id?.id,O),(f==="textbox"||f==="textwindow")&&![void 0,0,1,2].includes(m?.align)&&a.push(`${O.name}: \u6C34\u5E73\u5BF9\u9F50\u679A\u4E3E ${m.align} \u7684\u542B\u4E49\u672A\u77E5\uFF0C\u5DF2\u539F\u6837\u4FDD\u7559\u3002`),(f==="textbox"||f==="textwindow")&&![void 0,0,1,2].includes(m?.verticalAlign)&&a.push(`${O.name}: \u5782\u76F4\u5BF9\u9F50\u679A\u4E3E ${m.verticalAlign} \u7684\u542B\u4E49\u672A\u77E5\uFF0C\u5DF2\u539F\u6837\u4FDD\u7559\u3002`),f==="image"&&![void 0,0,1,2,3,4,5].includes(g?.fillType)&&a.push(`${O.name}: \u586B\u5145\u5F62\u72B6\u679A\u4E3E ${g.fillType} \u672A\u8BC6\u522B\uFF0C\u5DF2\u4FDD\u7559\u539F\u503C\u3002`),f==="button"&&o.set(O.id,{unavailableChildId:b?.disabledChild,hoverChildId:b?.hoverChild,pressedChildId:b?.pressedChild,selectedChildId:b?.selectedChild})}let l=[],c=new Set;for(let s of e){let f=r.get(s.id?.id),m=(s.ui?.content?.children||[]).map(h=>r.get(h)).filter(Boolean);if(m.length){f.children=t?m.slice().reverse():m;for(let h of m)c.add(h.id)}}for(let s of e){let f=r.get(s.id?.id),m=s.ui?.content?.parent||0,h=r.get(m);h?c.has(f.id)||(t?h.children.unshift(f):h.children.push(f)):l.push(f)}for(let[s,f]of o){let m=[...r.values()].find(h=>h.id===s);for(let[h,g]of Object.entries(f))m[h]=n.get(g)||null}return{nodes:r,rootCandidates:l,warnings:a}}function Fr(e){let t=mi(e),i=xe.toObject(xe.decode(t),{longs:Number,enums:Number,bytes:Buffer,defaults:!1,arrays:!0,objects:!0}),n=i.graph||[];if(!n.some(b=>b.ui?.content))throw new Error("GIA \u4E0D\u542B\u53EF\u8BC6\u522B\u7684 UIControlGroup \u4E3B\u56FE");let r=n.find(b=>b.which===21)||null,o=n.filter(b=>Number(b.which)===70),a=i.accessories||[],l=new Set((r?.relatedIds||[]).map(b=>b.id||0)),c=r?l.size?a.filter(b=>l.has(b.id?.id||0)):a:[],s=o.length?[...o,...a.filter(b=>!l.has(b.id?.id||0))]:r?[]:[...n,...a];if(!c.length&&!s.length)throw new Error("GIA \u4E0D\u542B\u5BA2\u6237\u7AEF\u63A7\u4EF6");let f=["GIA \u5BFC\u5165\u4E3A\u5DF2\u9A8C\u8BC1 UI \u5B57\u6BB5\u7684\u8BED\u4E49\u5BFC\u5165\uFF1B\u672A\u77E5 protobuf \u5B57\u6BB5\u4E0D\u4F1A\u8FDB\u5165 Authoring JSON\u3002"],m=Mr(i);f.push(...m.warnings);let h=null,g=null;if(c.length){let b=hr(c,{reverseSiblings:!0,idOffset:0});f.push(...b.warnings);let w=b.rootCandidates.find(E=>E.kind==="container")||b.rootCandidates[0];if(!w)throw new Error("GIA \u672A\u627E\u5230\u5BA2\u6237\u7AEF\u6839\u63A7\u4EF6");let M=H("server-container",{id:"sc1",guid:r?.id?.id||0,name:r?.name||"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u5BB9\u5668",giaRelatedGuids:(r?.ui?.content?.info||[]).find(E=>E.field501===4&&E.field502===4)?.related?.value||[]});M.children=[w],b.rootCandidates.length>1&&f.push(`\u68C0\u6D4B\u5230 ${b.rootCandidates.length} \u4E2A\u65E0\u7236\u8282\u70B9\u63A7\u4EF6\uFF0C\u4EC5\u5BFC\u5165\u4EE5\u201C${w.name}\u201D\u4E3A\u6839\u7684\u6811\u3002`),h={version:1,layoutSchemaVersion:pe,meta:{name:r?.name||"\u5BFC\u5165\u7684\u754C\u9762\u63A7\u4EF6\u7EC4",assetType:"server-control-template",sourceFormat:"gia",sourceFile:"",gameVersion:i.gameVersion||"",giaFilePath:i.filePath||"",...Number.isSafeInteger(Number(i.modeFlag))?{giaModeFlag:Number(i.modeFlag)}:{}},canvasId:"pc-16-9",selectedId:w.id,script:{controlId:w.id,path:"",source:""},root:M}}if(s.length){let b=hr(s,{reverseSiblings:!1,idOffset:1e3});if(f.push(...b.warnings),!b.rootCandidates.length)throw new Error("GIA \u672A\u627E\u5230\u5BA2\u6237\u7AEF\u6A21\u677F");let w=H("server-container",{id:"sc1",guid:0,name:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F"});w.children=b.rootCandidates,g={version:1,layoutSchemaVersion:pe,meta:{name:b.rootCandidates.length===1?b.rootCandidates[0].name:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u5217\u8868",assetType:"client-control-template",sourceFormat:"gia",sourceFile:"",gameVersion:i.gameVersion||"",giaFilePath:i.filePath||"",...Number.isSafeInteger(Number(i.modeFlag))?{giaModeFlag:Number(i.modeFlag)}:{}},canvasId:"pc-16-9",selectedId:b.rootCandidates[0].id,script:{controlId:b.rootCandidates[0].id,path:"",source:""},root:w},h||(h=g)}return{project:h,clientProject:g&&h!==g?g:void 0,scripts:m.scripts,warnings:f,metadata:{gameVersion:i.gameVersion||"",filePath:i.filePath||"",...Number.isSafeInteger(Number(i.modeFlag))?{modeFlag:Number(i.modeFlag)}:{},combined:!!(r&&o.length)}}}function Or(e){let t=mi(e),i=xe.toObject(xe.decode(t),{longs:Number,enums:Number,defaults:!1,arrays:!0,objects:!0}),n=i.graph||[],r=i.accessories||[],o=[],a=(h,g)=>h!=null&&Object.prototype.hasOwnProperty.call(h,g),l=new Map,c=[];/^\d+-\d+-\d+-\\.+\.gia$/iu.test(i.filePath||"")||o.push(`Root.filePath \u4E0D\u662F UID-TIME-ID-\\\u6587\u4EF6\u540D.gia\uFF1A${i.filePath||"<missing>"}`);let s=n.filter(h=>h.which===70).map(h=>{let g=hi(h),b=h.ui?.content?.info||[],w=b.find(U=>U.field501===2&&U.field502===6)?.index?.value,M=gr[g],E=b.find(U=>U.field501===4&&U.field502===4),A=E?.related?.value||[];return(!Number.isSafeInteger(w)||w<=0)&&o.push(`${h.name}: Info.index=${w??"<missing>"}\uFF0C\u5FC5\u987B\u662F\u6B63\u6574\u6570`),E||o.push(`${h.name}: \u9876\u5C42 UIControlTemplate \u7F3A\u5C11 Info.related \u8BB0\u5F55`),{id:h.id?.id||0,name:h.name||"",kind:g,actualIndex:w,expectedIndex:M,relatedPresent:!!E,relatedGuids:A}});s.length||o.push("Root.graph \u4E0D\u542B UIControlTemplate(70)");let f=0,m=0;for(let h of[...n,...r]){if(!h.ui?.content)continue;let g=h.id?.id||0,b=h.ui.content,w=hi(h),M=n.includes(h)&&h.which===70,E=`${h.name||"<unnamed>"}(${g||"<missing-guid>"})`;!Number.isSafeInteger(g)||g<=0||g>2147483647?o.push(`${E}: GraphUnit GUID \u975E\u6CD5`):l.has(g)?o.push(`${E}: GUID \u4E0E ${l.get(g).name||"<unnamed>"} \u91CD\u590D`):l.set(g,h),(h.id?.class!==1||h.id?.type!==8)&&o.push(`${E}: GraphUnit.id \u5FC5\u987B\u4E3A class=1,type=8`),b.guid!==g&&o.push(`${E}: content.guid=${b.guid??"<missing>"} \u4E0E GraphUnit.id.id \u4E0D\u4E00\u81F4`),M&&h.which!==70&&o.push(`${E}: \u6A21\u677F\u6839 which \u5FC5\u987B\u4E3A UIControlTemplate(70)`),!M&&h.which!==15&&o.push(`${E}: \u9644\u4EF6\u63A7\u4EF6 which \u5FC5\u987B\u4E3A UIControl(15)`);let A=b.info||[],U=A.find(S=>S.field501===1&&S.field502===5),$=A.find(S=>S.field501===2&&S.field502===6);U?.guid?.value!==g&&o.push(`${E}: Info.self GUID \u7F3A\u5931\u6216\u4E0E\u81EA\u8EAB\u4E0D\u4E00\u81F4`),(!Number.isSafeInteger($?.index?.value)||$.index.value<=0)&&o.push(`${E}: Info.index=${$?.index?.value??"<missing>"}\uFF0C\u5FC5\u987B\u662F\u6B63\u6574\u6570`);let q=A.find(S=>S.field501===4&&S.field502===4);M&&!q&&o.push(`${E}: \u9876\u5C42\u6A21\u677F\u7F3A\u5C11 Info.related \u8BB0\u5F55`),!M&&q&&o.push(`${E}: \u9644\u4EF6\u63A7\u4EF6\u4E0D\u5E94\u5199 Info.related`);let ee=br[w],J=b.data||[],O=J.map(S=>`${S.field501}/${S.field502}`),y=ee?.map(([S])=>S)||[];ee?JSON.stringify(O)!==JSON.stringify(y)&&o.push(`${E}: Data \u69FD\u4F4D\u987A\u5E8F ${O.join(",")}\uFF0C\u5E94\u4E3A ${y.join(",")}`):o.push(`${E}: \u672A\u77E5\u5BA2\u6237\u7AEF\u63A7\u4EF6\u7C7B\u578B ${w}`);for(let S=0;S<Math.min(J.length,ee?.length||0);S+=1){let P=J[S],[D,B,le]=ee[S];if(a(P,B)||o.push(`${E}: Data ${D} \u7F3A\u5C11 ${B} \u5206\u652F`),!le)continue;a(P.details,le)||o.push(`${E}: Details ${D} \u7F3A\u5C11 ${le} \u5206\u652F`);let K=vr[D];(P.details?.field501!==K||P.details?.field502!==P.field502||P.details?.field503!==1)&&o.push(`${E}: Details ${D} \u6807\u8BB0\u5E94\u4E3A ${K}/${P.field502}/1`);let he=P.details?.nodeRef;(he?.class!==1||he?.type!==8||he?.id!==g)&&o.push(`${E}: Details ${D} node_ref \u672A\u6307\u5411\u81EA\u8EAB`)}let x=(h.ui.content.data||[]).find(S=>S.field501===4&&S.field502===86);x&&(a(x.field14,"field17")?f+=1:o.push(`${E}: \u7C7B\u578B Data \u7F3A\u5C11\u663E\u5F0F Field14.field17 \u7A7A\u4E32`),a(x.details?.field14,"field17")?f+=1:o.push(`${E}: \u7C7B\u578B Details \u7F3A\u5C11\u663E\u5F0F Field14.field17 \u7A7A\u4E32`));let v=(h.ui.content.data||[]).find(S=>S.details?.transform)?.details?.transform?.multiPlatform?.platforms||[];v.length!==4&&o.push(`${E}: \u591A\u5E73\u53F0\u53D8\u6362\u6570\u91CF=${v.length}\uFF0C\u5E94\u4E3A 4`);let I=v.map(S=>S.platformType||0);JSON.stringify(I)!==JSON.stringify([0,1,2,3])&&o.push(`${E}: \u5E73\u53F0\u987A\u5E8F ${I.join(",")}\uFF0C\u5E94\u4E3A 0,1,2,3`);let F=(h.ui.content.data||[]).find(S=>S.details?.transform)?.details?.transform;F?.multiPlatform?.field502!==Dt[w]&&o.push(`${E}: \u53D8\u6362 preset=${F?.multiPlatform?.field502??"<missing>"}\uFF0C${w} \u5E94\u4E3A ${Dt[w]}`);for(let S of v)a(S.transform,"field508")?m+=1:o.push(`${E}: RectTransform \u7F3A\u5C11\u663E\u5F0F field508 \u7A7A\u4E32`);c.push({id:g,name:h.name||"",kind:w,template:M,parent:b.parent||0,children:[...b.children||[]],relatedIds:(h.relatedIds||[]).map(S=>S.id||0),dataSignatures:O})}for(let h of c){let g=`${h.name||"<unnamed>"}(${h.id})`;if(JSON.stringify(h.relatedIds)!==JSON.stringify(h.children)&&o.push(`${g}: GraphUnit.relatedIds \u4E0E content.children \u4E0D\u4E00\u81F4`),h.template&&h.parent&&o.push(`${g}: \u9876\u5C42\u6A21\u677F\u4E0D\u5E94\u6709 parent`),!h.template){let b=l.get(h.parent);b?(b.ui?.content?.children||[]).includes(h.id)||o.push(`${g}: \u7236\u63A7\u4EF6 children \u672A\u53CD\u5411\u5305\u542B\u81EA\u8EAB`):o.push(`${g}: parent=${h.parent||"<missing>"} \u4E0D\u5B58\u5728`)}for(let b of h.children){let w=l.get(b);w?(w.ui?.content?.parent||0)!==h.id&&o.push(`${g}: child=${b} \u7684 parent \u672A\u6307\u56DE\u81EA\u8EAB`):o.push(`${g}: child=${b} \u4E0D\u5B58\u5728`)}}return{valid:o.length===0,errors:o,filePath:i.filePath||"",gameVersion:i.gameVersion||"",templateCount:s.length,accessoryCount:r.length,templates:s,units:c,explicitEmpty:{field17:f,rectField508:m}}}function ji(e){let t=mi(e),i=xe.toObject(xe.decode(t),{longs:Number,enums:Number,defaults:!1,arrays:!0,objects:!0}),n=(i.graph||[]).filter(S=>S.ui?.content&&Number(S.which)===21),r=(i.graph||[]).filter(S=>Number(S.which)===70),o=(i.graph||[]).filter(S=>Number(S.which)===Ct),a=(i.accessories||[]).filter(S=>S.ui?.content),l=[],c=(S,P)=>S!=null&&Object.prototype.hasOwnProperty.call(S,P);/^\d+-\d+-\d+-\\.+\.gia$/iu.test(i.filePath||"")||l.push(`Root.filePath \u4E0D\u662F UID-TIME-ID-\\\u6587\u4EF6\u540D.gia\uFF1A${i.filePath||"<missing>"}`),n.length!==1&&l.push(`\u670D\u52A1\u7AEF\u63A7\u4EF6\u6A21\u677F UIControlGroup \u6570\u91CF=${n.length}\uFF0C\u5E94\u4E3A 1`);let s=(i.graph||[]).filter(S=>{let P=Number(S.which);return P===Ct||P===70||P===21?!1:!S.ui?.content});s.length&&l.push(`Root.graph \u542B ${s.length} \u4E2A\u65E0\u6CD5\u8BC6\u522B\u7684\u975E\u63A7\u4EF6/\u975E\u811A\u672C\u5355\u5143`);let f=n[0];if(!f)return{valid:!1,errors:l,filePath:i.filePath||"",gameVersion:i.gameVersion||"",accessoryCount:a.length,controls:[],scriptCount:o.length,explicitEmpty:{field17:0,rectField508:0}};let m=[f,...a],h=new Map;for(let S of m){let P=S.id?.id||0,D=`${S.name||"<unnamed>"}(${P||"<missing-guid>"})`;!Number.isSafeInteger(P)||P<=0||P>2147483647?l.push(`${D}: GraphUnit GUID \u975E\u6CD5`):h.has(P)?l.push(`${D}: GUID \u91CD\u590D`):h.set(P,S),(S.id?.class!==1||S.id?.type!==8)&&l.push(`${D}: GraphUnit.id \u5FC5\u987B\u4E3A class=1,type=8`),S.ui?.content?.guid!==P&&l.push(`${D}: content.guid \u4E0E GraphUnit.id.id \u4E0D\u4E00\u81F4`)}let g=f.id?.id||0,b=f.ui.content,w=`${f.name||"<unnamed>"}(${g})`;f.which!==21&&l.push(`${w}: which \u5FC5\u987B\u4E3A UIControlGroup(21)`);let M=b.info||[];M.find(S=>S.field501===1&&S.field502===5)?.guid?.value!==g&&l.push(`${w}: Info.self GUID \u7F3A\u5931\u6216\u4E0D\u4E00\u81F4`),M.find(S=>S.field501===2&&S.field502===6)?.index?.value!==1&&l.push(`${w}: Info.index \u5FC5\u987B\u4E3A 1`);let E=M.find(S=>S.field501===4&&S.field502===4);E||l.push(`${w}: \u7F3A\u5C11\u663E\u5F0F Info.related \u8BB0\u5F55`);let A=0,U=0,$=(S,P,D,B=!1)=>{let le=S.id?.id||0,K=`${S.name||"<unnamed>"}(${le})`,he=S.ui.content.data||[],je=he.map(ne=>`${ne.field501}/${ne.field502}`),ht=D.map(([ne])=>ne);JSON.stringify(je)!==JSON.stringify(ht)&&l.push(`${K}: Data \u69FD\u4F4D\u987A\u5E8F ${je.join(",")}\uFF0C\u5E94\u4E3A ${ht.join(",")}`);for(let ne=0;ne<Math.min(he.length,D.length);ne+=1){let ke=he[ne],[Me,Tt,Rt]=D[ne];if(c(ke,Tt)||l.push(`${K}: Data ${Me} \u7F3A\u5C11 ${Tt} \u5206\u652F`),!Rt)continue;c(ke.details,Rt)||l.push(`${K}: Details ${Me} \u7F3A\u5C11 ${Rt} \u5206\u652F`);let Ge=vr[Me];(ke.details?.field501!==Ge||ke.details?.field502!==ke.field502||ke.details?.field503!==1)&&l.push(`${K}: Details ${Me} \u6807\u8BB0\u5E94\u4E3A ${Ge}/${ke.field502}/1`);let Pt=ke.details?.nodeRef;(Pt?.class!==1||Pt?.type!==8||Pt?.id!==le)&&l.push(`${K}: Details ${Me} node_ref \u672A\u6307\u5411\u81EA\u8EAB`)}let _t=he.find(ne=>ne.field501===4&&ne.field502===(B?23:86)),te=B?"empty15":"field17";c(_t?.field14,te)?B||(A+=1):l.push(`${K}: \u7C7B\u578B Data \u7F3A\u5C11\u663E\u5F0F Field14.${te} \u7A7A\u4E32`),c(_t?.details?.field14,te)?B||(A+=1):l.push(`${K}: \u7C7B\u578B Details \u7F3A\u5C11\u663E\u5F0F Field14.${te} \u7A7A\u4E32`);let Ae=he.find(ne=>ne.details?.transform)?.details?.transform,qe=Ae?.multiPlatform?.platforms||[];qe.length!==4&&l.push(`${K}: \u591A\u5E73\u53F0\u53D8\u6362\u6570\u91CF=${qe.length}\uFF0C\u5E94\u4E3A 4`);let ni=qe.map(ne=>ne.platformType||0);JSON.stringify(ni)!==JSON.stringify([0,1,2,3])&&l.push(`${K}: \u5E73\u53F0\u987A\u5E8F ${ni.join(",")}\uFF0C\u5E94\u4E3A 0,1,2,3`);let ri=B?Dt["server-container"]:Dt[P];Ae?.multiPlatform?.field502!==ri&&l.push(`${K}: \u53D8\u6362 preset=${Ae?.multiPlatform?.field502??"<missing>"}\uFF0C\u5E94\u4E3A ${ri}`);for(let ne of qe)c(ne.transform,"field508")?U+=1:l.push(`${K}: RectTransform \u7F3A\u5C11\u663E\u5F0F field508 \u7A7A\u4E32`);return je};$(f,"server-container",wa,!0);let q=(f.relatedIds||[]).map(S=>S.id||0),ee=new Set(q),J=a.filter(S=>ee.has(S.id?.id||0)),O=J.map(S=>S.id?.id||0);JSON.stringify(q)!==JSON.stringify(O)&&l.push(`${w}: \u4E3B\u56FE relatedIds \u5FC5\u987B\u6309\u987A\u5E8F\u8986\u76D6\u672C\u7EC4 accessories`);let y=b.data?.find(S=>S.details?.rootChildRef)?.details?.rootChildRef?.guid||0,x=h.get(y);(!x||!J.includes(x))&&l.push(`${w}: 62/82 \u6839\u8282\u70B9\u5F15\u7528\u4E0D\u5B58\u5728`),O[0]!==y&&l.push(`${w}: \u6839\u5BB9\u5668\u8282\u70B9\u5FC5\u987B\u662F\u672C\u7EC4 accessories[0]`);let v=[];for(let S of J){let P=S.id?.id||0,D=S.ui.content,B=`${S.name||"<unnamed>"}(${P})`,le=hi(S);S.which!==15&&l.push(`${B}: which \u5FC5\u987B\u4E3A UIControl(15)`);let K=D.info||[];(K.length!==1||K[0]?.field501!==1||K[0]?.field502!==5||K[0]?.guid?.value!==P)&&l.push(`${B}: \u670D\u52A1\u7AEF\u5BB9\u5668\u5185\u63A7\u4EF6 Info \u5FC5\u987B\u53EA\u542B\u81EA\u8EAB GUID`);let he=br[le];he||l.push(`${B}: \u672A\u77E5\u5BA2\u6237\u7AEF\u63A7\u4EF6\u7C7B\u578B ${le}`);let je=he?$(S,le,he):[];v.push({id:P,name:S.name||"",kind:le,parent:D.parent||0,children:[...D.children||[]],relatedIds:(S.relatedIds||[]).map(ht=>ht.id||0),dataSignatures:je})}let I=v.find(S=>S.id===y);I&&(I.kind!=="container"&&l.push(`${I.name}(${y}): \u6839\u63A7\u4EF6\u5FC5\u987B\u4E3A\u5BB9\u5668\u8282\u70B9`),I.parent&&l.push(`${I.name}(${y}): \u6839\u63A7\u4EF6\u4E0D\u5E94\u6709 parent`));let F=new Map(v.map(S=>[S.id,S]));for(let S of v){let P=`${S.name}(${S.id})`;if(JSON.stringify(S.relatedIds)!==JSON.stringify(S.children)&&l.push(`${P}: relatedIds \u5FC5\u987B\u4E0E\u76F4\u63A5 children \u4E00\u81F4`),S.id!==y){let D=F.get(S.parent);D?D.children.includes(S.id)||l.push(`${P}: \u7236\u63A7\u4EF6 children \u672A\u53CD\u5411\u5305\u542B\u81EA\u8EAB`):l.push(`${P}: parent=${S.parent||"<missing>"} \u4E0D\u5B58\u5728`)}for(let D of S.children){let B=F.get(D);B?B.parent!==S.id&&l.push(`${P}: child=${D} \u7684 parent \u672A\u6307\u56DE\u81EA\u8EAB`):l.push(`${P}: child=${D} \u4E0D\u5B58\u5728`)}}return{valid:l.length===0,errors:l,filePath:i.filePath||"",gameVersion:i.gameVersion||"",graph:{id:g,name:f.name||"",relatedGuids:E?.related?.value||[],rootGuid:y},accessoryCount:a.length,controls:v,scriptCount:o.length,explicitEmpty:{field17:A,rectField508:U}}}function $r(e,t=[]){if(!e||e.layoutSchemaVersion===pe)return e;if(e.layoutSchemaVersion!==void 0&&e.layoutSchemaVersion!==1)throw new Error(`\u4EC5\u652F\u6301 layoutSchemaVersion=2 \u6216\u53EF\u8FC1\u79FB\u7684\u65E7\u5E03\u5C40\uFF0C\u6536\u5230 ${e.layoutSchemaVersion}`);if(!e.root)return{...e,layoutSchemaVersion:pe};let i=structuredClone(e),n=0;return j(i.root,r=>{let o=r.transformByPlatform||{},a=r.transformByCanvas||{},l=r.name||r.id;for(let s of Object.keys(o))if(!se.includes(s))throw new Error(`${l}: unknown platform ${s}`);let c={};for(let s of se){let f=mt[s],m=ie[f].platform,h=Object.keys(ie).filter(M=>ie[M].platform===m&&a[M]),g=a[f]?f:h[0],b=s==="CONTROLLER_CONSOLE"?c.KEYBOARD:s==="CONTROLLER_MOBILE"?c.TOUCHSCREEN:null,w=o[s]??b??(g?a[g]:null);if(c[s]=w?Re(w):Di(r.kind),w||t.push(`${l}: ${s} \u65E0\u65E7\u5E03\u5C40\uFF0C\u5DF2\u4F7F\u7528\u63A7\u4EF6\u9ED8\u8BA4\u503C`),!o[s]&&!b&&g&&g!==f&&t.push(`${l}: \u7F3A\u5C11 ${f}\uFF0C\u5DF2\u91C7\u7528 ${g} \u7684\u951A\u70B9\u548C\u5C3A\u5BF8\u53C2\u6570`),!b)for(let M of h)JSON.stringify(c[s])!==JSON.stringify(Re(a[M]))&&t.push(`${l}: ${M} \u4E0E ${s} \u5E03\u5C40\u51B2\u7A81\uFF0C\u4FDD\u7559${o[s]?"\u5DF2\u6709\u5E73\u53F0":g}\u53C2\u6570`)}De(c,`${l}.transformByPlatform`),r.transformByPlatform=c,delete r.transformByCanvas,n++}),i.layoutSchemaVersion=pe,t.unshift(`\u5DF2\u81EA\u52A8\u8FC1\u79FB\u65E7\u5E03\u5C40\uFF1A${n} \u4E2A\u63A7\u4EF6\u8F6C\u6362\u4E3A\u56DB\u5E73\u53F0\u53C2\u6570\uFF1B\u518D\u6B21\u4FDD\u5B58\u5C06\u4F7F\u7528\u65B0\u7248\u683C\u5F0F`),i}function qi(e){if(![1,2,3,4].includes(e))throw new Error(`\u4EC5\u652F\u6301 version=1\u20134 \u7684\u5B58\u6863\uFF0C\u6536\u5230 ${e}`)}function Zi(e,t,i,n=e.canvasId){let r=Ve(e.root,t);return!r||r.kind==="server-container"?ye(n):i[r.id]||ye(n)}function Xe(e,{warnings:t=[]}={}){if(!e)return it();if(e=$r(e,t),(e.root||e.layoutSchemaVersion!==void 0)&&e.layoutSchemaVersion!==pe)throw new Error(`\u4EC5\u652F\u6301 layoutSchemaVersion=${pe} \u7684\u56DB\u5E73\u53F0\u5E03\u5C40\uFF0C\u4E0D\u652F\u6301\u65E7\u753B\u5E03\u5E03\u5C40\u6216\u5176\u4ED6\u7248\u672C`);let i=e.meta?.assetType==="client-control-template"?"client-control-template":"server-control-template",n=i==="client-control-template"?St():it(),r={layoutSchemaVersion:pe,version:Number.isSafeInteger(e.version)&&e.version>0?e.version:1,meta:{name:String(e.meta?.name||n.meta.name),assetType:i,sourceFormat:String(e.meta?.sourceFormat||n.meta.sourceFormat),sourceFile:String(e.meta?.sourceFile||""),...e.meta?.gameVersion?{gameVersion:String(e.meta.gameVersion)}:{},...e.meta?.giaFilePath?{giaFilePath:String(e.meta.giaFilePath)}:{},...Number.isSafeInteger(Number(e.meta?.giaOwnerUid))?{giaOwnerUid:Number(e.meta.giaOwnerUid)}:{},...Number.isSafeInteger(Number(e.meta?.giaTimestamp))?{giaTimestamp:Number(e.meta.giaTimestamp)}:{},...Number.isSafeInteger(Number(e.meta?.giaFileId))?{giaFileId:Number(e.meta.giaFileId)}:{},...e.meta?.giaFileName?{giaFileName:String(e.meta.giaFileName)}:{},...Number.isSafeInteger(Number(e.meta?.giaModeFlag))&&Number(e.meta.giaModeFlag)>=0?{giaModeFlag:Number(e.meta.giaModeFlag)}:{}},canvasId:e.canvasId&&ie[e.canvasId]?e.canvasId:oi,selectedId:e.selectedId||n.selectedId,root:Yi(e.root||n.root)};return Yr(r),r}function Yr(e){let t=new Set;j(e.root,i=>{if(typeof i.id!="string"||!i.id)throw new Error("node id must be a non-empty string");if(t.has(i.id))throw new Error(`duplicate node id: ${i.id}`);t.add(i.id)}),t.has(e.selectedId)||(e.selectedId=Vi(e.root).id)}function Gr(e){return ze(vt(e))}function Oa(e,t){let i=!1;return j(e,n=>{n.id===t&&(i=!0)}),i}function $a(e,t,i,n){let o=Ue(e.root,e.canvasId).boxes[t.id],a=i.children.findIndex(m=>m.id===t.id);if(a<0)throw new Error("reparent: source node is not attached");if(i.children.splice(a,1),n.children.push(t),!o)return;let l=Ue(e.root,e.canvasId),c=n.kind==="server-container"?ye(e.canvasId):l.boxes[n.id]||ye(e.canvasId),s=Ye(t.transformByPlatform,e.canvasId),f=Ze(c,s,{posX:o.centerX,posY:o.centerY,width:o.width,height:o.height});It(e,t,f)}function Ga(e,t){return e.meta.assetType!=="client-control-template"?Ui(e.root,t):(e.root.children||[]).flatMap(i=>Ui(i,t))}function Ur(e,t){let i=cr(e.root,t);if(e.meta.assetType!=="client-control-template")return i;let n=Gt(e),r=new Set;return n&&n.kind!=="server-container"&&j(n,o=>r.add(o.id)),i.filter(o=>r.has(o.id))}function Br(e){let{canvas:t,boxes:i}=Ue(e.root,e.canvasId),n=Vt(e),r=ce(e.root,e.selectedId),o=r?i[r.id]:null;return G({layoutSchemaVersion:pe,version:e.version,meta:{...e.meta},canvasId:e.canvasId,canvas:{id:e.canvasId,width:t.width,height:t.height,platform:ie[e.canvasId].platform,label:ie[e.canvasId].label,presets:Object.values(ie).map(a=>({id:a.id,label:a.label,width:a.width,height:a.height,platform:a.platform}))},selectedId:e.selectedId,asset:{type:e.meta.assetType,label:e.meta.assetType==="client-control-template"?"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F":"\u670D\u52A1\u7AEF\u63A7\u4EF6\u6A21\u677F",templateCount:e.meta.assetType==="client-control-template"?e.root.children.length:1,currentTemplateId:e.meta.assetType==="client-control-template"&&Gt(e)?.id||""},tree:Ga(e,n),boxes:Ur(e,i),inspector:fr(r,e.canvasId,o||t,n),root:e.root})}function It(e,t,i){let n=Ue(e.root,e.canvasId),r=Zi(e,t.id,n.boxes),o={};if(t.syncAllDevices!==!1)for(let a of se){if(a===Qe(e.canvasId))continue;let l=mt[a],c=Ue(e.root,l,a);o[a]=Zi(e,t.id,c.boxes,l)}t.transformByPlatform=ur({transformByPlatform:t.transformByPlatform,source:i,canvasId:e.canvasId,syncAllDevices:t.syncAllDevices!==!1,sourceParentBox:r,targetParentBoxByPlatform:o})}var Da=new Set(["name","active","visible","canControllerFocus","isolateNavigation","disableKeyEventPassthrough","disableCursorEventPassthrough","showCursor","fontSize","adaptiveFontSize","minimumFontSize","fontColor","bgColor","enableOutline","outlineColor","horizontalAlignment","verticalAlignment","text","imageId","imageColor","enableMask","enableSoftEdge","softEdgeMode","softEdgeWidthX","softEdgeWidthY","horizontalSoftRange","verticalSoftRange","enableFill","fillType","fillHorizontalType","fillVerticalType","fillRadial90Type","fillRadialType","fillAmount","reverseMaskArea","raycastTarget","interactable","clickAudioId","unavailableChildId","hoverChildId","pressedChildId","selectedChildId","showScrollBar","cellSizeX","cellSizeY","spacingX","spacingY","padding1X","padding1Y","padding2X","padding2Y","previewCount","scrollDirection","layoutConstraint","referencedPrefabId","animationId","keyboardKeyCode","controllerKeyCode"]),za=new Set(["posX","posY","width","height"]),Va=new Set(["anchorMinX","anchorMinY","anchorMaxX","anchorMaxY","pivotX","pivotY"]);function Ya(e){if(typeof e=="number"&&Number.isFinite(e))return e>>>0;if(typeof e=="string"){let t=e.trim();if(t.startsWith("#")){let n=t.slice(1);if(n.length===6)return(4278190080|parseInt(n,16))>>>0;if(n.length===8)return parseInt(n,16)>>>0}let i=Number(t);if(Number.isFinite(i))return i>>>0}throw new Error("color must be an ARGB integer or #RRGGBB/#AARRGGBB string")}function Fe(e,t){let i=Number(e);if(!Number.isFinite(i))throw new Error(`${t} must be a finite number`);return i}function Dr(e){if(e===!0||e===1||e==="1"||e==="true")return!0;if(e===!1||e===0||e==="0"||e==="false")return!1;throw new Error("boolean field requires true or false")}var Ua=new Set(["fontSize","minimumFontSize","imageId","clickAudioId","softEdgeWidthX","softEdgeWidthY","horizontalSoftRange","verticalSoftRange","fillAmount","cellSizeX","cellSizeY","spacingX","spacingY","padding1X","padding1Y","padding2X","padding2Y","previewCount","keyboardKeyCode","controllerKeyCode"]),Ba=new Set(["active","visible","canControllerFocus","isolateNavigation","disableKeyEventPassthrough","disableCursorEventPassthrough","showCursor","adaptiveFontSize","enableOutline","enableMask","enableSoftEdge","enableFill","reverseMaskArea","raycastTarget","interactable","showScrollBar"]),Xa=new Set(["name","horizontalAlignment","verticalAlignment","text","softEdgeMode","fillType","fillHorizontalType","fillVerticalType","fillRadial90Type","fillRadialType","scrollDirection","layoutConstraint","referencedPrefabId","animationId"]),zr=new Set(["unavailableChildId","hoverChildId","pressedChildId","selectedChildId"]),Vr={softEdgeMode:["Percentage","Pixel"],fillType:["Horizontal","Vertical","Radial90","Radial180","Radial360"],fillHorizontalType:["Left","Right"],fillVerticalType:["Bottom","Top"],fillRadial90Type:["BottomLeft","TopLeft","TopRight","BottomRight"],fillRadialType:["Bottom","Left","Top","Right"]};function Ka(e,t){if(!t||typeof t!="object")throw new Error("patch requires op");let i=t.op;if(i==="select")return t.id&&ce(e.root,t.id)&&(e.selectedId=t.id),e;if(i==="pick"){let{boxes:n}=Ue(e.root,e.canvasId),r=Ur(e,n),o=dr(r,Number(t.x),Number(t.y));return o&&(e.selectedId=o),e}if(i==="setCanvas")return t.canvasId&&ie[t.canvasId]&&(e.canvasId=t.canvasId),e;if(i==="setScript")throw new Error("\u811A\u672C\u7531\u5B58\u6863\u7EDF\u4E00\u7BA1\u7406\uFF0C\u8BF7\u4F7F\u7528 addScript / updateScript / removeScript \u64CD\u4F5C");if(i==="newAsset"){let n=t.assetType==="client-control-template"?St():it();return e.version=n.version,e.meta=n.meta,e.canvasId=n.canvasId,e.selectedId=n.selectedId,e.root=n.root,e}if(i==="addTemplate"){if(e.meta.assetType!=="client-control-template")throw new Error("\u53EA\u6709\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u5DE5\u7A0B\u53EF\u4EE5\u65B0\u589E\u6A21\u677F");let n=H(t.kind,{id:zi(e.root),guid:Gr(e.root),name:t.name||`\u65B0${t.kind==="container"?"\u5BB9\u5668\u8282\u70B9":t.kind}\u6A21\u677F`});return e.root.children.push(n),e.selectedId=n.id,e}if(i==="add"){let n=ce(e.root,t.parentId||e.selectedId);if(!n)throw new Error("add: parent not found");let r=ar(n,t.kind,{id:zi(e.root),guid:Gr(e.root),name:t.name});return e.selectedId=r.id,e}if(i==="reparent"){if(e.meta.assetType!=="client-control-template")throw new Error("\u5C42\u7EA7\u8C03\u6574\u4EC5\u9002\u7528\u4E8E\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u5DE5\u7A0B");let n=ce(e.root,t.id||e.selectedId),r=n?Ve(e.root,n.id):null,o=ce(e.root,t.parentId);if(!n||n.kind==="server-container"||!r)throw new Error("reparent: node not found");if(!o)throw new Error("reparent: parent not found");if(o.id===n.id||Oa(n,o.id))throw new Error("\u63A7\u4EF6\u4E0D\u80FD\u79FB\u52A8\u5230\u81EA\u8EAB\u6216\u5176\u540E\u4EE3\u4E0B\u9762");if(o.kind==="server-container"&&r.kind==="server-container")return e;if(r.kind==="server-container"&&o.kind!=="server-container"&&e.root.children.length<=1)throw new Error("\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u5217\u8868\u81F3\u5C11\u4FDD\u7559\u4E00\u4E2A\u9876\u5C42\u6A21\u677F");return $a(e,n,r,o),e.selectedId=n.id,e}if(i==="moveSibling"){let n=ce(e.root,t.id||e.selectedId),r=n?Ve(e.root,n.id):null;if(!n||!r)throw new Error("moveSibling: node not found");let o=r.children.findIndex(c=>c.id===n.id),a=t.direction==="up"?-1:t.direction==="down"?1:0,l=o+a;return!a||l<0||l>=r.children.length||(r.children.splice(o,1),r.children.splice(l,0,n),e.selectedId=n.id),e}if(i==="remove"){let n=t.id||e.selectedId,r=Ve(e.root,n);if(r?.kind==="server-container"){if(e.meta.assetType!=="client-control-template")throw new Error("\u670D\u52A1\u7AEF\u63A7\u4EF6\u6A21\u677F\u7684\u5BA2\u6237\u7AEF\u6839\u8282\u70B9\u4E0D\u80FD\u5220\u9664");if((e.root.children||[]).length<=1)throw new Error("\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u5217\u8868\u81F3\u5C11\u4FDD\u7559\u4E00\u4E2A\u6A21\u677F")}return lr(e.root,n)&&(j(e.root,o=>{if(o.kind==="button")for(let a of zr)o[a]&&!ce(e.root,o[a])&&(o[a]=null)}),e.selectedId=r?r.id:e.root.id),e}if(i==="set"){let n=ce(e.root,t.id||e.selectedId);if(!n)throw new Error("set: node not found");let r=t.key;r==="reverseMask"&&(r="reverseMaskArea");let o=t.value;if(r.startsWith("giaRaw.")){let s=r.slice(7);if(!s||s.includes("."))throw new Error("invalid raw GIA field path");let f=nr(n.kind,s);if(!f)throw new Error(`unknown raw GIA field for ${n.kind}: ${s}`);if(n.giaRaw||={},n.giaRaw[s]=Fi(f,o),s==="footerField505"&&[0,1].includes(n.giaRaw[s])&&(n.canControllerFocus=n.giaRaw[s]===1),n.kind==="cursor"&&s==="cursorField501"&&[0,1].includes(n.giaRaw[s])&&(n.raycastTarget=n.giaRaw[s]===1),(n.kind==="textbox"||n.kind==="textwindow")&&s==="textAlign"){let m={0:"Left",1:"Middle",2:"Right"}[n.giaRaw[s]];m&&(n.horizontalAlignment=m)}if(n.kind==="image"&&s==="imageFillType"){let m={1:"Horizontal",2:"Vertical",3:"Radial90",4:"Radial180",5:"Radial360"}[n.giaRaw[s]];m&&(n.fillType=m)}return n.kind==="keyhint"&&s==="keyHintField502"&&(n.keyboardKeyCode=n.giaRaw[s]),n.kind==="keyhint"&&s==="keyHintField501"&&(n.controllerKeyCode=n.giaRaw[s]),e}if(r==="syncAllDevices"){if(n.syncAllDevices=Dr(o),n.syncAllDevices){let s=Ye(n.transformByPlatform,e.canvasId);It(e,n,s)}return e}if(Da.has(r)){if(r.endsWith("Color")&&(o=Ya(o)),Ua.has(r)){if(o=Fe(o,r),o<0)throw new Error(`${r} must not be negative`);if((r==="imageId"||r==="clickAudioId"||r==="keyboardKeyCode"||r==="controllerKeyCode")&&(o=Math.trunc(o)),r==="fillAmount"&&o>1)throw new Error("fillAmount must be between 0 and 1")}if(Ba.has(r)&&(o=Dr(o)),Xa.has(r)&&(o=String(o??"")),r==="horizontalAlignment"&&!["Left","Middle","Right"].includes(o))throw new Error("invalid horizontalAlignment");if(r==="verticalAlignment"&&!["Top","Middle","Bottom"].includes(o))throw new Error("invalid verticalAlignment");if(Vr[r]&&!Vr[r].includes(o))throw new Error(`invalid ${r}`);if(zr.has(r))if(o===""||o===void 0||o===null)o=null;else{o=String(o);let s=ce(e.root,o);if(!s||s===n||s.kind==="server-container"||!(n.children||[]).some(f=>f.id===o))throw new Error(`${r} must reference a direct child of this button`)}if(n[r]=o,r==="canControllerFocus"&&(n.giaRaw.footerField505=o?1:0),n.kind==="cursor"&&r==="raycastTarget"&&(n.giaRaw.cursorField501=o?1:0),(n.kind==="textbox"||n.kind==="textwindow")&&r==="horizontalAlignment"&&(n.giaRaw.textAlign={Left:0,Middle:1,Right:2}[o]),(n.kind==="textbox"||n.kind==="textwindow")&&r==="verticalAlignment"&&delete n.giaRaw.textVerticalAlign,n.kind==="image"&&r==="fillType"){let s={Horizontal:1,Vertical:2,Radial90:3,Radial180:4,Radial360:5}[o];s&&(n.giaRaw.imageFillType=s)}return n.kind==="reference"&&r==="referencedPrefabId"&&(n.giaRaw.templateRefSlot=o),n.kind==="grid"&&r==="previewCount"&&(n.giaRaw.gridField511=Math.trunc(o)),n.kind==="keyhint"&&r==="keyboardKeyCode"&&(n.giaRaw.keyHintField502=Math.trunc(o)),n.kind==="keyhint"&&r==="controllerKeyCode"&&(n.giaRaw.keyHintField501=Math.trunc(o)),(n.kind==="animation"||n.kind==="fullscreen")&&r==="animationId"&&(n.giaRaw[n.kind==="animation"?"effectSlot":"fullscreenEffectSlot"]=o),e}let{boxes:a}=Ue(e.root,e.canvasId),l=Zi(e,n.id,a),c=Ye(n.transformByPlatform,e.canvasId);if(r==="anchorType"){let s=Ji(a[n.id]),f=Zn(c,o);return f=Ze(l,f,s),It(e,n,f),e}if(r==="rotationZ"){let s={...c,rotation:{...c.rotation,z:Fe(o,r)}};return It(e,n,s),e}if(Va.has(r)){let s=Ji(a[n.id]),f={...c,anchorMin:{...c.anchorMin},anchorMax:{...c.anchorMax},pivot:{...c.pivot}};return r==="anchorMinX"&&(f.anchorMin.x=Fe(o,r)),r==="anchorMinY"&&(f.anchorMin.y=Fe(o,r)),r==="anchorMaxX"&&(f.anchorMax.x=Fe(o,r)),r==="anchorMaxY"&&(f.anchorMax.y=Fe(o,r)),r==="pivotX"&&(f.pivot.x=Fe(o,r)),r==="pivotY"&&(f.pivot.y=Fe(o,r)),It(e,n,Ze(l,f,s)),e}if(za.has(r)){let s=Ji(a[n.id]),f=Fe(o,r);if((r==="width"||r==="height")&&f<0)throw new Error(`${r} must not be negative`);return s[r]=f,It(e,n,Ze(l,c,s)),e}throw new Error(`set: unknown key ${r}`)}if(i==="replace"){let n=Xe(t.project);return e.version=n.version,e.meta=n.meta,e.canvasId=n.canvasId,e.selectedId=n.selectedId,e.root=n.root,e}throw new Error(`unknown op ${i}`)}function Qi(e,t){if(!t||typeof t!="object")throw new Error("patch requires op");if(t.expectedRevision!==void 0&&Number(t.expectedRevision)!==e.version)throw new Error(`revision conflict: expected ${t.expectedRevision}, current ${e.version}`);let i=e.version,n=JSON.parse(JSON.stringify(e));return Ka(n,t),Yr(n),n.version=i+1,Object.keys(e).forEach(r=>{delete e[r]}),Object.assign(e,n),e}function Ji(e){return e?{posX:e.centerX,posY:e.centerY,width:e.width,height:e.height}:{posX:0,posY:0,width:0,height:0}}import Ha from"fengari";var{lua:u,lauxlib:Q,lualib:Xr,to_luastring:pi,to_jsstring:La}=Ha,Wa=u.LUA_TNIL,ja=u.LUA_TBOOLEAN,qa=u.LUA_TNUMBER,Ja=u.LUA_TSTRING,Kr=u.LUA_TTABLE,Za=u.LUA_TFUNCTION,en=u.LUA_TUSERDATA,Ee=u.LUA_OK,Hr=new WeakMap,tn=Symbol("luaTableEntries"),nn={__scriptHostKey:!0};function _(e){return pi(String(e))}function nt(e,t){Hr.set(e,t)}function Ie(e){return Hr.get(e)}var Yt=class{constructor(t){this.value=t}};function ae(e,t,i){if(i instanceof Yt){u.lua_pushnumber(e,i.value);return}if(i==null){u.lua_pushnil(e);return}let n=typeof i;if(n==="boolean"){u.lua_pushboolean(e,i);return}if(n==="number"){Number.isInteger(i)&&Math.abs(i)<=2147483647?u.lua_pushinteger(e,i):u.lua_pushnumber(e,i);return}if(n==="string"){u.lua_pushstring(e,_(i));return}if(n==="function"){tl(e,t,i);return}if(i&&i[tn]){let r=i[tn];u.lua_createtable(e,Array.isArray(i)?i.length:0,r.length);for(let[o,a]of r)ae(e,t,o),ae(e,t,a),u.lua_settable(e,-3);return}if(Array.isArray(i)){u.lua_createtable(e,i.length,0);for(let r=0;r<i.length;r++)ae(e,t,i[r]),u.lua_rawseti(e,-2,r+1);return}if(i&&i.__kind==="EnumItem"){t.pushEnumItem(e,i);return}if(i&&i.__kind==="CursorEventData"){t.pushCursor(e,i);return}if(i&&i.__kind==="Script"){t.pushScript(e,i);return}if(i&&i.typeofName){t.pushControl(e,i);return}if(i&&i.__kind==="ServerSignal"){t.pushSignal(e,i);return}if(i&&(i.SetEase||i.Append)){t.pushTween(e,i);return}if(n==="object"){u.lua_createtable(e,0,Object.keys(i).length);for(let[r,o]of Object.entries(i))ae(e,t,o),u.lua_setfield(e,-2,_(r));return}u.lua_pushnil(e)}function W(e,t){if(u.lua_isnil(e,t)||u.lua_type(e,t)===u.LUA_TNONE)return"";if(!u.lua_isstring(e,t)&&u.lua_type(e,t)!==u.LUA_TNUMBER)return`lua_type=${u.lua_type(e,t)}`;let i=u.lua_tostring(e,t);return i==null?"":La(i)}function Oe(e,t){t=u.lua_absindex(e,t);let i=u.lua_type(e,t);if(i===en)return Ie(u.lua_touserdata(e,t));if(i===Kr){u.lua_pushlightuserdata(e,nn),u.lua_rawget(e,t);let n=u.lua_type(e,-1)===en?u.lua_touserdata(e,-1):null;return u.lua_pop(e,1),n?Ie(n):null}return null}function de(e,t,i){i=u.lua_absindex(e,i);let n=u.lua_type(e,i);if(n===Wa)return null;if(n===ja)return!!u.lua_toboolean(e,i);if(n===qa)return u.lua_isinteger(e,i)?u.lua_tointeger(e,i):u.lua_tonumber(e,i);if(n===Ja)return W(e,i);if(n===en){let r=u.lua_touserdata(e,i);return Ie(r)??r}if(n===Za)return Qa(e,t,i);if(n===Kr){let r=Oe(e,i);if(r)return r;let o=[];for(u.lua_pushnil(e);u.lua_next(e,i)!==0;){let s=de(e,t,-2),f=de(e,t,-1);o.push([s,f]),u.lua_pop(e,1)}let a=new Map(o.filter(([s])=>Number.isInteger(s)&&s>=1)),l=0;for(;a.has(l+1);)l+=1;let c=l>0?[]:{};for(let[s,f]of o)Array.isArray(c)&&Number.isInteger(s)&&s>=1?c[s-1]=f:(typeof s=="string"||typeof s=="number")&&(c[s]=f);return Object.defineProperty(c,tn,{value:o}),c}return null}function Qa(e,t,i){t.luaFunctions||(t.luaFunctions=new Map);let n=typeof u.lua_topointer=="function"?u.lua_topointer(e,i):null;if(n!=null&&t.luaFunctions.has(n))return t.luaFunctions.get(n);u.lua_pushvalue(e,i);let r=Q.luaL_ref(e,u.LUA_REGISTRYINDEX),o=el(e,t,r);return n!=null&&t.luaFunctions.set(n,o),o}function el(e,t,i){let n=(...r)=>{if(n.__luaRef==null)throw new Error("attempt to call a released Lua callback");let o=u.lua_gettop(e);u.lua_rawgeti(e,u.LUA_REGISTRYINDEX,n.__luaRef);for(let s of r)ae(e,t,s);if(u.lua_pcall(e,r.length,u.LUA_MULTRET,0)!==Ee){let s=W(e,-1);throw u.lua_settop(e,o),new Error(s)}let l=u.lua_gettop(e)-o,c=[];for(let s=1;s<=l;s++)c.push(de(e,t,o+s));if(u.lua_settop(e,o),c.length!==0)return c.length===1?c[0]:c};return n.__luaRef=i,n.__luaState=e,n}function Lr(e){e?.__luaRef!=null&&(e.__luaHolds=(e.__luaHolds||0)+1)}function Wr(e,t){if(!t||t.__luaRef==null||!t.__luaState)return;if(t.__luaHolds>1){t.__luaHolds-=1;return}let i=t.__luaState;if((!e?.luaStates||e.luaStates.has(i))&&Q.luaL_unref(i,u.LUA_REGISTRYINDEX,t.__luaRef),t.__luaRef=null,t.__luaState=null,e?.luaFunctions)for(let[n,r]of e.luaFunctions)r===t&&e.luaFunctions.delete(n)}function tl(e,t,i){u.lua_pushlightuserdata(e,i),u.lua_pushlightuserdata(e,t),u.lua_pushcclosure(e,function(r){let o=u.lua_touserdata(r,u.lua_upvalueindex(1)),a=u.lua_touserdata(r,u.lua_upvalueindex(2)),l=u.lua_gettop(r),c=[];for(let s=1;s<=l;s++)c.push(de(r,a,s));try{let s=o(...c);if(Array.isArray(s)&&s.__multi){for(let f of s)ae(r,a,f);return s.length}return s===void 0?0:(ae(r,a,s),1)}catch(s){return u.lua_pushstring(r,_(String(s&&s.message?s.message:s))),u.lua_error(r)}},2)}function jr(e){!e||typeof u.lua_close!="function"||u.lua_close(e)}function qr(e){if(Q.luaL_loadstring(e,_(["local nativeGetMetatable = getmetatable","getmetatable = function(value)",' if type(value) == "string" then return nil end'," return nativeGetMetatable(value)","end"].join(`
107
- `)))===Ee&&u.lua_pcall(e,0,0,0),u.lua_settop(e,0),u.lua_pushnil(e),u.lua_setglobal(e,_("_VERSION")),u.lua_getglobal(e,_("string")),!u.lua_isnil(e,-1))for(let i of["dump","pack","unpack"])u.lua_pushnil(e),u.lua_setfield(e,-2,_(i));if(u.lua_pop(e,1),u.lua_pushnil(e),u.lua_setglobal(e,_("io")),u.lua_getglobal(e,_("os")),!u.lua_isnil(e,-1))for(let i of Object.keys({execute:1,getenv:1,remove:1,rename:1,tmpname:1,setlocale:1,exit:1}))u.lua_pushnil(e),u.lua_setfield(e,-2,_(i));u.lua_pop(e,1),u.lua_getglobal(e,_("debug")),u.lua_isnil(e,-1)?u.lua_pop(e,1):(u.lua_getfield(e,-1,_("traceback")),u.lua_newtable(e),u.lua_pushvalue(e,-2),u.lua_setfield(e,-2,_("traceback")),u.lua_setglobal(e,_("debug")),u.lua_pop(e,2)),u.lua_getglobal(e,_("math")),u.lua_isnil(e,-1)||(u.lua_pushcfunction(e,i=>{let n=u.lua_tonumber(i,1);return u.lua_pushboolean(i,Number.isNaN(n)),1}),u.lua_setfield(e,-2,_("isnan")),u.lua_pushcfunction(e,i=>{let n=u.lua_tonumber(i,1);return u.lua_pushboolean(i,n===1/0||n===-1/0),1}),u.lua_setfield(e,-2,_("isinf"))),u.lua_pop(e,1),u.lua_pushnil(e),u.lua_setglobal(e,_("package")),u.lua_pushnil(e),u.lua_setglobal(e,_("load")),u.lua_pushnil(e),u.lua_setglobal(e,_("loadfile")),u.lua_pushnil(e),u.lua_setglobal(e,_("dofile")),u.lua_pushnil(e),u.lua_setglobal(e,_("collectgarbage")),u.lua_pushnil(e),u.lua_setglobal(e,_("coroutine")),u.lua_pushnil(e),u.lua_setglobal(e,_("fengari"))}var Jr={container:"ClientUIContainerControl",textbox:"ClientUITextBoxControl",textwindow:"ClientUITextWindowControl",image:"ClientUIImageControl",button:"ClientUIPresetButtonControl",cursor:"ClientUICursorEventAreaControl",grid:"ClientUIGridScrollerControl",keyhint:"ClientUIKeyHintControl",animation:"ClientUIAnimationControl",fullscreen:"ClientUIFullscreenAnimationControl",reference:"ClientUIReferenceControl"},il=["alive","Id","prefabIndex","active","activeInHierarchy","visible"],gi=new Set(["active","visible","parent","sizeDeltaX","sizeDeltaY","anchorMinX","anchorMinY","anchorMaxX","anchorMaxY","pivotX","pivotY"]),nl=["name","parent","anchoredPositionX","anchoredPositionY","sizeDeltaX","sizeDeltaY","anchorMinX","anchorMinY","anchorMaxX","anchorMaxY","pivotX","pivotY","localScaleX","localScaleY","localScaleZ","localRotationX","localRotationY","localRotationZ","canControllerFocus"],rl={image:["imageSource","imageId"],grid:["itemCount","scrollDirection","layoutConstraint","layoutConstraintFixedCount"],reference:["referencedPrefabIndex"]},ol={container:["isolateNavigation","disableKeyEventPassthrough","disableCursorEventPassthrough","showCursor"],textbox:["text","fontSize","fontColor","bgColor","enableOutline","outlineColor","horizontalAlignment","verticalAlignment","adaptiveFontSize","minimumFontSize"],textwindow:["interactable","showScrollBar","text","fontSize","fontColor","bgColor","enableOutline","outlineColor","horizontalAlignment","verticalAlignment","adaptiveFontSize","minimumFontSize"],image:["imageColor","enableMask","enableSoftEdge","softEdgeMode","softEdgeWidthX","softEdgeWidthY","horizontalSoftRange","verticalSoftRange","reverseMaskArea","fillType","fillHorizontalType","fillVerticalType","fillRadial90Type","fillRadialType","fillAmount"],button:["interactable","clickAudioId","raycastTarget"],cursor:["raycastTarget"],grid:["itemPrefabIndex","raycastTarget","showScrollBar","interactable","scrollProgress"],keyhint:["keyboardKeyCode","controllerKeyCode"],animation:["animationId","playSoundEffect","layer"],fullscreen:["animationId","playSoundEffect"]},al=["GetChildren","GetChild","FindChild","SetActive","SetVisible","GetSiblingIndex","SetSiblingIndex","SetAsFirstSibling","SetAsLastSibling","GetAnchoredPosition","SetAnchoredPosition","GetSizeDelta","SetSizeDelta","GetAnchorMin","SetAnchorMin","GetAnchorMax","SetAnchorMax","GetPivot","SetPivot","GetLocalScale","SetLocalScale","GetLocalRotation","SetLocalRotation","GetScriptByPath","GetScript","GetScripts","AddKeyEventListener","RemoveKeyEventListener","RemoveKeyEventListeners","RemoveAllKeyEventListeners","AddNavigationEventListener","RemoveNavigationEventListener","RemoveNavigationEventListeners","RemoveAllNavigationEventListeners","SetControllerNavigation","GetControllerNavigation"],Zr=["AddCursorEventListener","RemoveCursorEventListener","RemoveCursorEventListeners","RemoveAllCursorEventListeners","SimulateCursorClick"],ll={image:["SetImage","SetSoftEdgeWidth","SetFillUnused","SetFillHorizontal","SetFillVertical","SetFillRadial90","SetFillRadial180","SetFillRadial360"],button:Zr,cursor:Zr,animation:["PlayAnimation","StopAnimation"],grid:["RefreshItems","GetItemIndex","GetItemSize","GetItemSpacing","GetPadding","ScrollToItemAt","GetContentLength"]};function on(e,t){return il.includes(t)||(rl[e.kind]||[]).includes(t)?"ro":nl.includes(t)||(ol[e.kind]||[]).includes(t)?"rw":null}var sl=["localRotationX","localRotationY","localRotationZ"],wt=Math.PI/180;function Qr(e,t){return[e[3]*t[0]+e[0]*t[3]+e[1]*t[2]-e[2]*t[1],e[3]*t[1]-e[0]*t[2]+e[1]*t[3]+e[2]*t[0],e[3]*t[2]+e[0]*t[1]-e[1]*t[0]+e[2]*t[3],e[3]*t[3]-e[0]*t[0]-e[1]*t[1]-e[2]*t[2]]}function rn(e){if(Object.is(e,-0))return e;let t=(e%360+360)%360,i=Math.round(t*1e6)/1e6;return i>=360?0:i}function eo(e,t,i){let n=A=>[Math.sin(A*wt/2),Math.cos(A*wt/2)],[r,o]=n(e),[a,l]=n(t),[c,s]=n(i),[f,m,h,g]=Qr(Qr([0,a,0,l],[r,0,0,o]),[0,0,c,s]),b=Math.max(-1,Math.min(1,-2*(m*h-g*f))),w,M,E;return Math.abs(b)>.999999?(w=Math.sign(b)*90,M=2*Math.atan2(m,g)/wt,E=0):(w=Math.asin(b)/wt,M=Math.atan2(2*(g*m+f*h),1-2*(f*f+m*m))/wt,E=Math.atan2(2*(g*h+f*m),1-2*(f*f+h*h))/wt),[rn(w),rn(M),rn(E)]}function to(e,t){return al.includes(t)||(ll[e.kind]||[]).includes(t)}var ul={container:{isolateNavigation:!1,disableKeyEventPassthrough:!1,disableCursorEventPassthrough:!1,showCursor:!1},textbox:{text:"",fontSize:20,fontColor:4294967295,bgColor:0,enableOutline:!1,outlineColor:0,horizontalAlignment:null,verticalAlignment:null,adaptiveFontSize:!1,minimumFontSize:10},textwindow:{interactable:!0,showScrollBar:!0,text:"",fontSize:20,fontColor:4294967295,bgColor:0,enableOutline:!1,outlineColor:0,horizontalAlignment:null,verticalAlignment:null,adaptiveFontSize:!1,minimumFontSize:10},image:{imageSource:null,imageId:0,imageColor:4294967295,imageType:null,enableMask:!1,enableSoftEdge:!1,softEdgeMode:"Percentage",softEdgeWidthX:8,softEdgeWidthY:8,horizontalSoftRange:85,verticalSoftRange:85,enableFill:!1,fillType:"Unused",fillHorizontalType:"Left",fillVerticalType:"Bottom",fillRadial90Type:"BottomLeft",fillRadialType:"Bottom",reverseMaskArea:!1,fillAmount:1},button:{interactable:!0,clickAudioId:0,raycastTarget:!0,unavailableChildId:null,hoverChildId:null,pressedChildId:null,selectedChildId:null,pressed:!1},cursor:{raycastTarget:!0},grid:{itemCount:0,itemPrefabIndex:null,raycastTarget:!0,interactable:!0,showScrollBar:!0,scrollDirection:"Vertical",layoutConstraint:"AutoWrap",layoutConstraintFixedCount:null,scrollProgress:0,cellSizeX:50,cellSizeY:50,spacingX:8,spacingY:8,padding1X:20,padding1Y:20,padding2X:20,padding2Y:20,previewCount:5},keyhint:{keyboardKeyCode:null,controllerKeyCode:null},animation:{animationId:null,playSoundEffect:null,layer:null,raycastTarget:!1},fullscreen:{animationId:null,playSoundEffect:null,raycastTarget:!1},reference:{referencedPrefabIndex:null}},Ke=class e{constructor(t,i){this.runtime=t,this.kind=i.kind||"container",this.typeofName=Jr[this.kind]||Jr.container,this.alive=!0,this.Id=i.Id??t.nextControlId(),this.authoringId=i.authoringId??null,this.prefabIndex=i.prefabIndex??0,this.name=i.name??"",this.active=i.active===!0,this.visible=i.visible!==!1,this._parent=null,this.children=[],this.scripts=[],this.cursorListeners=new Map,this.keyListeners=new Map,this.navListeners=new Map,this.navConfig=new Map,this.anchoredPositionX=i.anchoredPositionX??0,this.anchoredPositionY=i.anchoredPositionY??0,this.sizeDeltaX=i.sizeDeltaX??0,this.sizeDeltaY=i.sizeDeltaY??0,this.anchorMinX=i.anchorMinX??.5,this.anchorMinY=i.anchorMinY??.5,this.anchorMaxX=i.anchorMaxX??.5,this.anchorMaxY=i.anchorMaxY??.5,this.pivotX=i.pivotX??.5,this.pivotY=i.pivotY??.5,this.localScaleX=i.localScaleX??1,this.localScaleY=i.localScaleY??1,this.localScaleZ=i.localScaleZ??1,this.localRotationX=i.localRotationX??0,this.localRotationY=i.localRotationY??0,this.localRotationZ=i.localRotationZ??0,this.canControllerFocus=i.canControllerFocus??!1,this._playDirty=!0,this._playDeepDirty=!0,this._playChildDirty=!1;let n=ul[this.kind]||{};for(let[r,o]of Object.entries(n))this[r]===void 0&&(this[r]=i[r]!==void 0?i[r]:o);if(i.children)for(let r of i.children){let o=r instanceof e?r:new e(t,r);this.addChild(o)}}get parent(){return this._parent}set parent(t){if(this._parent===t)return;if(t!==null&&!(t instanceof e))throw new Error("parent must be a Control or nil");if(t&&t.runtime!==this.runtime)throw new Error("parent must belong to the same runtime");if(t===this)throw new Error("cannot parent a control to itself or its descendant");for(let n=t;n;n=n._parent)if(n===this)throw new Error("cannot parent a control to itself or its descendant");let i=this._parent;if(i){let n=i.children.indexOf(this);n>=0&&i.children.splice(n,1),i.markPlayDirty(!0)}else{let n=this.runtime.roots.indexOf(this);n>=0&&this.runtime.roots.splice(n,1)}this._parent=t,this.markPlayDirty(!0),t&&!t.children.includes(this)?(t.children.push(this),t.markPlayDirty(!0)):!t&&this.alive&&!this.runtime.roots.includes(this)&&this.runtime.roots.push(this)}markPlayDirty(t=!1){this._playDirty=!0,t&&(this._playDeepDirty=!0);for(let i=this._parent;i&&!i._playChildDirty;i=i._parent)i._playChildDirty=!0}get activeInHierarchy(){return this.active?this._parent?this._parent.activeInHierarchy:!0:!1}addChild(t){return t.parent=this,t}GetChildren(){return this.children.slice()}GetChild(t){return this.children.find(i=>i.name===t)||null}FindChild(t){if(!t)return null;if(!t.includes("/"))return this.GetChild(t);let i=t.split("/").filter(Boolean),n=this;for(let r of i)if(n=n.GetChild(r),!n)return null;return n}SetActive(t){let i=!!t;if(this.active!==i){if(typeof this.runtime?.onControlActiveChanging=="function"){this.runtime.onControlActiveChanging(this,i);return}this.active=i,this.markPlayDirty(!0)}}SetVisible(t){this.visible=!!t,this.markPlayDirty(!0)}GetSiblingIndex(){if(!this._parent)return-1;let t=this._parent.children,i=t.indexOf(this);return i<0?-1:t.length-1-i}SetSiblingIndex(t){if(!this._parent)return!1;let i=this._parent.children,n=i.indexOf(this);if(n<0)return!1;let r=i.length-1;return!Number.isInteger(t)||t<0||t>r?!1:(i.splice(n,1),i.splice(r-t,0,this),this._parent.markPlayDirty(!0),this.markPlayDirty(),!0)}SetAsFirstSibling(){return this.SetSiblingIndex(0)}SetAsLastSibling(){return this._parent?this.SetSiblingIndex(this._parent.children.length-1):!1}GetAnchoredPosition(){return[this.anchoredPositionX,this.anchoredPositionY]}SetAnchoredPosition(t,i){this.anchoredPositionX=t,this.anchoredPositionY=i,this.markPlayDirty()}GetSizeDelta(){return[this.sizeDeltaX,this.sizeDeltaY]}SetSizeDelta(t,i){this.sizeDeltaX=t,this.sizeDeltaY=i,this.markPlayDirty(!0)}GetAnchorMin(){return[this.anchorMinX,this.anchorMinY]}SetAnchorMin(t,i){this.anchorMinX=t,this.anchorMinY=i,this.markPlayDirty(!0)}GetAnchorMax(){return[this.anchorMaxX,this.anchorMaxY]}SetAnchorMax(t,i){this.anchorMaxX=t,this.anchorMaxY=i,this.markPlayDirty(!0)}GetPivot(){return[this.pivotX,this.pivotY]}SetPivot(t,i){this.pivotX=t,this.pivotY=i,this.markPlayDirty(!0)}GetLocalScale(){return[this.localScaleX,this.localScaleY,this.localScaleZ]}SetLocalScale(t,i,n){this.localScaleX=t,this.localScaleY=i,this.localScaleZ=n,this.markPlayDirty()}GetLocalRotation(){return eo(this.localRotationX,this.localRotationY,this.localRotationZ)}luaFieldValue(t){let i=sl.indexOf(t);return i<0?this[t]:eo(this.localRotationX,this.localRotationY,this.localRotationZ)[i]}SetLocalRotation(t,i,n){this.localRotationX=t,this.localRotationY=i,this.localRotationZ=n,this.markPlayDirty()}GetScriptByPath(t){return this.scripts.find(i=>i.path===t)||null}GetScript(t){return this.scripts.find(i=>i.scriptMappingId===t)||null}GetScripts(){return this.scripts.slice()}_addListener(t,i,n){let r=t.get(i)||[];r.push(n),t.set(i,r),this.runtime.retainLuaCallback?.(n)}_removeListener(t,i,n){let r=t.get(i);if(!r)return;let o=r.filter(a=>a!==n);t.set(i,o);for(let a=o.length;a<r.length;a++)this.runtime.unrefLuaCallback?.(n)}_removeListeners(t,i){let n=t.get(i)||[];for(let r of n)this.runtime.unrefLuaCallback?.(r);t.delete(i)}_removeAllListeners(t){for(let i of t.values())for(let n of i)this.runtime.unrefLuaCallback?.(n);t.clear()}AddCursorEventListener(t,i){this._addListener(this.cursorListeners,t,i)}RemoveCursorEventListener(t,i){this._removeListener(this.cursorListeners,t,i)}RemoveCursorEventListeners(t){this._removeListeners(this.cursorListeners,t)}RemoveAllCursorEventListeners(){this._removeAllListeners(this.cursorListeners)}SimulateCursorClick(){let t=this.runtime.makeCursorEventData({x:0,y:0,pressX:0,pressY:0});this.emitCursor("CursorDown",t),this.emitCursor("CursorUp",t),this.emitCursor("CursorClick",t)}emitCursor(t,i){if(!this.runtime.cursorEventsEnabled(this))return;let n=this.cursorListeners.get(t)||[];for(let r of n)r(i)}AddKeyEventListener(t,i){this._addListener(this.keyListeners,t,i)}RemoveKeyEventListener(t,i){this._removeListener(this.keyListeners,t,i)}RemoveKeyEventListeners(t){this._removeListeners(this.keyListeners,t)}RemoveAllKeyEventListeners(){this._removeAllListeners(this.keyListeners)}emitKey(t){let i=this.keyListeners.get(t)||[];for(let n of i)if(n()===!0)return!0;return!1}AddNavigationEventListener(t,i){this._addListener(this.navListeners,t,i)}RemoveNavigationEventListener(t,i){this._removeListener(this.navListeners,t,i)}RemoveNavigationEventListeners(t){this._removeListeners(this.navListeners,t)}RemoveAllNavigationEventListeners(){this._removeAllListeners(this.navListeners)}SetControllerNavigation(t,i,n){this.navConfig.set(t,{mode:i,target:n})}GetControllerNavigation(t){let i=this.navConfig.get(t),n=i?[i.mode,i.target]:[null,null];return n.__multi=!0,n}SetImage(t,i){this.imageSource=t,this.imageId=i,this.markPlayDirty()}SetSoftEdgeWidth(t,i){this.softEdgeWidthX=t,this.softEdgeWidthY=i,this.markPlayDirty()}SetFillUnused(){this.fillType="Unused",this.markPlayDirty()}SetFillHorizontal(t,i){this.fillType="Horizontal",this.fillHorizontalType=t,this.fillAmount=i,this.markPlayDirty()}SetFillVertical(t,i){this.fillType="Vertical",this.fillVerticalType=t,this.fillAmount=i,this.markPlayDirty()}SetFillRadial90(t,i){this.fillType="Radial90",this.fillRadial90Type=t,this.fillAmount=i,this.markPlayDirty()}SetFillRadial180(t,i){this.fillType="Radial180",this.fillRadialType=t,this.fillAmount=i,this.markPlayDirty()}SetFillRadial360(t,i){this.fillType="Radial360",this.fillRadialType=t,this.fillAmount=i,this.markPlayDirty()}PlayAnimation(){}StopAnimation(){}RefreshItems(){throw new Error("ClientUIGridScrollerControl:RefreshItems not implemented")}GetItemIndex(){throw new Error("ClientUIGridScrollerControl:GetItemIndex not implemented")}GetItemSize(){throw new Error("ClientUIGridScrollerControl:GetItemSize not implemented")}GetItemSpacing(){throw new Error("ClientUIGridScrollerControl:GetItemSpacing not implemented")}GetPadding(){throw new Error("ClientUIGridScrollerControl:GetPadding not implemented")}ScrollToItemAt(){throw new Error("ClientUIGridScrollerControl:ScrollToItemAt not implemented")}GetContentLength(){throw new Error("ClientUIGridScrollerControl:GetContentLength not implemented")}};function Pe(e,t){t(e);for(let i of e.children)Pe(i,t)}function an(e,t=[],i=""){t.push(`${i}${e.name||"(unnamed)"} [${e.typeofName}] Id=${e.Id}`);for(let n of e.children)an(n,t,i+" ");return t}function yi(e){return e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375}var io={Linear:e=>e,InSine:e=>1-Math.cos(e*Math.PI/2),OutSine:e=>Math.sin(e*Math.PI/2),InOutSine:e=>-(Math.cos(Math.PI*e)-1)/2,InQuad:e=>e*e,OutQuad:e=>1-(1-e)*(1-e),InOutQuad:e=>e<.5?2*e*e:1-(-2*e+2)**2/2,InCubic:e=>e*e*e,OutCubic:e=>1-(1-e)**3,InOutCubic:e=>e<.5?4*e*e*e:1-(-2*e+2)**3/2,InQuart:e=>e**4,OutQuart:e=>1-(1-e)**4,InOutQuart:e=>e<.5?8*e**4:1-(-2*e+2)**4/2,InQuint:e=>e**5,OutQuint:e=>1-(1-e)**5,InOutQuint:e=>e<.5?16*e**5:1-(-2*e+2)**5/2,InExpo:e=>e===0?0:2**(10*e-10),OutExpo:e=>e===1?1:1-2**(-10*e),InOutExpo:e=>e===0||e===1?e:e<.5?2**(20*e-10)/2:(2-2**(-20*e+10))/2,InCirc:e=>1-Math.sqrt(1-e**2),OutCirc:e=>Math.sqrt(1-(e-1)**2),InOutCirc:e=>e<.5?(1-Math.sqrt(1-(2*e)**2))/2:(Math.sqrt(1-(-2*e+2)**2)+1)/2,InBack:e=>(1.70158+1)*e*e*e-1.70158*e*e,OutBack:e=>1+2.70158*(e-1)**3+1.70158*(e-1)**2,InOutBack:e=>{let i=2.5949095;return e<.5?(2*e)**2*((i+1)*2*e-i)/2:((2*e-2)**2*((i+1)*(e*2-2)+i)+2)/2},InElastic:e=>e===0||e===1?e:-(2**(10*e-10))*Math.sin((e*10-10.75)*(2*Math.PI/3)),OutElastic:e=>e===0||e===1?e:2**(-10*e)*Math.sin((e*10-.75)*(2*Math.PI/3))+1,InOutElastic:e=>{if(e===0||e===1)return e;let t=2*Math.PI/4.5;return e<.5?-(2**(20*e-10)*Math.sin((20*e-11.125)*t))/2:2**(-20*e+10)*Math.sin((20*e-11.125)*t)/2+1},InBounce:e=>1-yi(1-e),OutBounce:yi,InOutBounce:e=>e<.5?(1-yi(1-2*e))/2:(1+yi(2*e-1))/2};function no(e,t){let i=io[e]||io.Linear;return t<=0?0:t>=1?1:i(t)}function xt(e,t,i,n=255){let r=bi(e),o=bi(t),a=bi(i);return((n==null?255:bi(n))<<24|r<<16|o<<8|a)>>>0}function Ut(e){let t=e>>>0;return[t>>>16&255,t>>>8&255,t&255,t>>>24&255]}function bi(e){let t=Number(e);return Number.isFinite(t)?Math.max(0,Math.min(255,Math.trunc(t))):0}function ro(e,t,i){let n=Ut(e),r=Ut(t);return xt(n[0]+(r[0]-n[0])*i,n[1]+(r[1]-n[1])*i,n[2]+(r[2]-n[2])*i,n[3]+(r[3]-n[3])*i)}var cl=new Set(["fontColor","bgColor","outlineColor","imageColor"]),fl=new Set(["fontSize","minimumFontSize"]),ln=1e-9;function dl(e,t){return typeof e?.luaFieldValue=="function"?e.luaFieldValue(t):e[t]}var Bt=class{constructor(t,i,n,r){this.runtime=t,this.object=i,this.data={...n},this.duration=Math.max(0,Number(r)||0),this.easeName="Linear",this.relative=!1,this.playing=!1,this.paused=!1,this.elapsed=0,this.loops=1,this.loopIndex=0,this.from={},this.to={},this.initialFrom=null,this.initialTo=null,this.onComplete=null,this.onStepComplete=null,this.killed=!1,this.dead=!1,this.completed=!1}capture(){this.from={},this.to={};for(let[t,i]of Object.entries(this.data)){let n=dl(this.object,t);this.from[t]=n,this.to[t]=this.relative?Number(n)+Number(i):i}}restoreInitial(){this.from={...this.initialFrom},this.to={...this.initialTo}}SetEase(t){return this.easeName=typeof t=="string"?t:t?.Name||"Linear",this}SetRelative(t){return this.relative=!!t,this}Play(){return this.dead?this:this.playing?(this.paused=!1,this):this._start(!1)}_begin(t){this.playing=!0,this.paused=!1,this.elapsed=0,this.loopIndex=0,this.killed=!1,this.completed=!1,t&&this.initialFrom?this.restoreInitial():(this.capture(),this.initialFrom={...this.from},this.initialTo={...this.to})}_start(t){return this._begin(t),this.runtime.tweens.add(this),this.runtime.animations.add(this),this}get loopCount(){return this.loops>0?this.loops:1}Pause(){this.paused=!0}Resume(){this.paused=!1}Restart(){return this.dead?this:this._start(!0)}Complete(){this.dead||this.completed||(this.initialFrom||this._begin(!1),this.apply(1),this.finish(!0))}Kill(t){t?this.Complete():this.finish(!1),this.dead=!0}SetOnComplete(t){return this.onComplete=t,this}SetOnStepComplete(t){return this.onStepComplete=t,this}SetLoops(t){return this.loops=t,this}apply(t){if(this.object?.alive===!1)return;let i=no(this.easeName,t),n=!1,r=!1;for(let o of Object.keys(this.to)){let a=this.from[o],l=this.to[o];if(cl.has(o)&&typeof a=="number"&&typeof l=="number")this.object[o]=ro(a,l,i);else if(typeof a=="number"&&typeof l=="number"){let c=a+(l-a)*i;this.object[o]=fl.has(o)?Math.trunc(c):c}else this.object[o]=i>=1?l:a;n=!0,gi.has(o)&&(r=!0)}n&&typeof this.object?.markPlayDirty=="function"&&this.object.markPlayDirty(r)}_advance(t,i){this.elapsed+=t;let n=this.duration<=0?1:Math.min(1,this.elapsed/this.duration);return this.apply(n),n<1?!1:i>=0&&this.loopIndex+1>=i?!0:(this.onStepComplete&&this.runtime.safeCall(this.onStepComplete),this.loopIndex++,this.elapsed=0,this.restoreInitial(),!1)}step(t){!this.playing||this.paused||this.killed||this._advance(t,this.loops<0?-1:this.loopCount)&&(this.onStepComplete&&this.runtime.safeCall(this.onStepComplete),this.finish(!0))}finish(t){this.playing=!1,this.killed=!0,t&&(this.completed=!0),this.runtime.tweens.delete(this),this.runtime.animations.delete(this),t&&this.onComplete&&this.runtime.safeCall(this.onComplete)}},Et=class{constructor(t){this.runtime=t,this.steps=[],this.playing=!1,this.paused=!1,this.killed=!1,this.dead=!1,this.completed=!1,this.elapsed=0,this.loops=1,this.loopIndex=0,this.onComplete=null,this.onStepComplete=null,this._entries=null}Append(t){return this.steps.push({kind:"tween",tween:t,parallel:!1}),this}AppendInterval(t){return this.steps.push({kind:"interval",duration:t}),this}AppendCallback(t){return this.steps.push({kind:"callback",fn:t}),this}Join(t){return this.steps.push({kind:"tween",tween:t,parallel:!0}),this}Insert(t,i){return this.steps.push({kind:"insert",time:t,tween:i}),this}InsertCallback(t,i){return this.steps.push({kind:"insertCb",time:t,fn:i}),this}Play(){return this.dead?this:this.playing?(this.paused=!1,this):this._play()}_play(){return this.playing=!0,this.paused=!1,this.killed=!1,this.completed=!1,this.elapsed=0,this.loopIndex=0,this._schedule(),this.runtime.sequences.add(this),this.runtime.animations.add(this),this}_schedule(){let t=0,i=0,n=!1,r=[],o=a=>a.duration*a.loopCount;for(let a of this.steps)if(a.kind==="tween"&&a.parallel){let l=n?i:t;r.push({at:l,tween:a.tween}),t=Math.max(t,l+o(a.tween))}else a.kind==="tween"?(r.push({at:t,tween:a.tween}),i=t,n=!0,t+=o(a.tween)):a.kind==="interval"?(i=t,n=!0,t+=a.duration):a.kind==="callback"?r.push({at:t,fn:a.fn}):a.kind==="insert"?(r.push({at:a.time,tween:a.tween}),t=Math.max(t,a.time+o(a.tween))):a.kind==="insertCb"&&(r.push({at:a.time,fn:a.fn}),t=Math.max(t,a.time));this._entries=r.map((a,l)=>({...a,index:l,end:a.tween?a.at+o(a.tween):a.at})),this._end=t,this._resetEntries()}_resetEntries(){for(let t of this._entries)t.started=!1,t.done=!1}_startChild(t){t.started=!0,t.tween._begin(!!t.tween.initialFrom)}_finishChild(t){t.done=!0,t.tween.apply(1),t.tween.onStepComplete&&this.runtime.safeCall(t.tween.onStepComplete),t.tween.finish(!0)}_advanceTo(t,i){let n=this._entries,r=[];for(let a of n)!a.started&&a.at<=t+ln&&r.push({at:a.at,rank:a.fn?1:2,entry:a}),a.tween&&!a.done&&a.end<=t+ln&&r.push({at:a.end,rank:0,entry:a});r.sort((a,l)=>a.at-l.at||a.rank-l.rank||a.entry.index-l.entry.index);let o=new Set;for(let{rank:a,entry:l}of r)if(a===1){if(l.started=!0,this.runtime.safeCall(l.fn),!this.playing||this.killed||this._entries!==n)return!1}else l.started||(this._startChild(l),o.add(l)),a===0&&!l.done&&this._finishChild(l);for(let a of n)!a.tween||!a.started||a.done||(o.has(a)?a.tween._advance(t-a.at,a.tween.loopCount):a.tween._advance(i,a.tween.loopCount));return!0}step(t){!this.playing||this.paused||this.killed||(this.elapsed+=t,this._advanceTo(this.elapsed,t)&&(this.elapsed+ln<this._end||(this.onStepComplete&&this.runtime.safeCall(this.onStepComplete),this.loopIndex++,this.loops<0||this.loopIndex<this.loops?(this.elapsed=0,this._resetEntries()):this.finish(!0))))}Pause(){this.paused=!0}Resume(){this.paused=!1}Restart(){this.dead||this._play()}Complete(){this.dead||this.completed||(this._entries||this._schedule(),this.playing=!0,this.killed=!1,this._advanceTo(1/0,0)&&(this.onStepComplete&&this.runtime.safeCall(this.onStepComplete),this.finish(!0)))}Kill(t){t?this.Complete():this.finish(!1),this.dead=!0}SetOnComplete(t){return this.onComplete=t,this}SetOnStepComplete(t){return this.onStepComplete=t,this}SetLoops(t){return this.loops=t,this}finish(t){this.playing=!1,this.killed=!0,t&&(this.completed=!0),this.runtime.sequences.delete(this),this.runtime.animations.delete(this),t&&this.onComplete&&this.runtime.safeCall(this.onComplete)}};var vi={EaseType:["Linear","InSine","OutSine","InOutSine","InQuad","OutQuad","InOutQuad","InCubic","OutCubic","InOutCubic","InQuart","OutQuart","InOutQuart","InQuint","OutQuint","InOutQuint","InExpo","OutExpo","InOutExpo","InCirc","OutCirc","InOutCirc","InBack","OutBack","InOutBack","InElastic","OutElastic","InOutElastic","InBounce","OutBounce","InOutBounce"],CustomVariableEntityType:["Level","PlayerSelf","AvatarSelf"],Device:["KeyboardAndMouse","Mobile","Controller","MobileController"],StageMode:["Beyond","Classic"],LanguageType:["LanguageNone","LanguageEng","LanguageChs","LanguageCht","LanguageFra","LanguageDeu","LanguageSpa","LanguagePor","LanguageRus","LanguageJpn","LanguageKor","LanguageTha","LanguageVie","LanguageInd","LanguageTur","LanguageIta"],ParamType:["Entity","EntityList","Int","IntList","Bool","BoolList","Float","FloatList","String","StringList","Vector3","Vector3List","Guid","GuidList","ConfigId","PrefabId","ConfigIdList","PrefabIdList"],CursorEventType:["CursorDown","CursorUp","CursorEnter","CursorExit","CursorDrag","CursorBeginDrag","CursorEndDrag","CursorClick"],ScrollDirection:["Horizontal","Vertical"],ScrollLayoutConstraint:["AutoWrap","Fixed"],ScrollAlignType:["Bottom","Center","Top"],ControllerNavigationDir:["Up","Down","Left","Right"],ControllerNavigationEventType:["Confirm","Cancel","Focus","LostFocus","RightStickUp","RightStickDown","RightStickRight","RightStickLeft","LeftStickUp","LeftStickDown","LeftStickRight","LeftStickLeft"],ControllerNavigationMode:["None","NearestControl","Specified"],TextHorizontalAlignment:["Left","Middle","Right"],TextVerticalAlignment:["Top","Middle","Bottom"],ImageType:["Basic","Stretch"],ImageSource:["StaticReference","Item","Equipment","Skill","UnitStatus","Faction","Currency","Prefab"],ImageFillType:["Unused","Horizontal","Vertical","Radial90","Radial180","Radial360"],ImageFillHorizontalType:["Left","Right"],ImageFillVerticalType:["Bottom","Top"],ImageFillRadial90Type:["BottomLeft","TopLeft","TopRight","BottomRight"],ImageFillRadialType:["Bottom","Left","Top","Right"],ImageMaskSoftEdgeMode:["Percentage","Pixel"],UIAnimationLayer:["AboveAllControls","BelowAllControls"]},hl=[...Array.from({length:43},(e,t)=>`CraftspersonKey${t+1}`),"MoveForwardKey","MoveBackwardKey","MoveLeftKey","MoveRightKey","SwitchToWalkOrRunKey","SprintKey","JumpKey","DropKey","OpenShortcutWheelKey","InteractKey","NormalAttackKey","CharacterSkill1Key","CharacterSkill2Key","CharacterSkill3Key","CharacterSkill4Key","None"],ml=[...Array.from({length:14},(e,t)=>`CraftspersonKey${t+1}`),"SprintKey","JumpKey","InteractKey","NormalAttackKey","CharacterSkill1Key","CharacterSkill2Key","CharacterSkill3Key","CharacterSkill4Key","MenuConfirmKey","MenuBackKey","None"];function pl(){let e=[];for(let t of["Down","Up"]){for(let i=1;i<=43;i++)e.push(`KeyboardCraftspersonKey${i}${t}`);for(let i of["MoveForwardKey","MoveBackwardKey","MoveLeftKey","MoveRightKey","SwitchToWalkOrRunKey","SprintKey","JumpKey","DropKey","OpenShortcutWheelKey","InteractKey","NormalAttackKey","CharacterSkill1Key","CharacterSkill2Key","CharacterSkill3Key","CharacterSkill4Key"])e.push(`Keyboard${i}${t}`);for(let i=1;i<=14;i++)e.push(`ControllerCraftspersonKey${i}${t}`);for(let i of["SprintKey","JumpKey","InteractKey","NormalAttackKey","CharacterSkill1Key","CharacterSkill2Key","CharacterSkill3Key","CharacterSkill4Key","MenuConfirmKey","MenuBackKey"])e.push(`Controller${i}${t}`)}return e}vi.KeyboardKeyCode=hl;vi.ControllerKeyCode=ml;vi.KeyEventType=pl();var oo=new Map;function rt(e,t){let i=`${e}\0${t}`,n=oo.get(i);return n||(n={__kind:"EnumItem",Name:t,FullName:`Enum.${e}.${t}`,EnumType:e},oo.set(i,n)),n}function sn(e,t){return t==null?t:t.__kind==="EnumItem"?rt(t.EnumType||e,t.Name):typeof t=="string"&&t?rt(e,t):t}function un(){let e={};for(let[t,i]of Object.entries(vi)){let n={};for(let r of i)n[r]=rt(t,r);e[t]=n}return e}var gl=new Set(["Id","prefabIndex","imageId","fontSize","minimumFontSize","clickAudioId","itemCount","itemPrefabIndex","animationId","referencedPrefabIndex"]),yl=new Set(["imageColor","fontColor","bgColor","outlineColor"]),ao={horizontalAlignment:"TextHorizontalAlignment",verticalAlignment:"TextVerticalAlignment",imageSource:"ImageSource",fillType:"ImageFillType",fillHorizontalType:"ImageFillHorizontalType",fillVerticalType:"ImageFillVerticalType",fillRadial90Type:"ImageFillRadial90Type",fillRadialType:"ImageFillRadialType",softEdgeMode:"ImageMaskSoftEdgeMode",layer:"UIAnimationLayer",scrollDirection:"ScrollDirection",layoutConstraint:"ScrollLayoutConstraint"},ot=u.LUA_REGISTRYINDEX,lo=u.LUA_MULTRET,bl=Object.freeze({InstantiateClientUIControl:2,DestroyClientUIControl:1,GetClientUIControl:1,FindClientUIRoot:1,GetClientUIRoots:0,GetUICanvasSize:0,GetCursorUIPos:0,GetDevice:0,SetControllerFocus:1,GetControllerFocus:0,GetControllerLeftStickAxis:0,GetControllerRightStickAxis:0,Tween:3,TweenSequence:0,ServerSignal:1,GetGlobalCustomVariableValue:2,PauseLevelTime:1,IsLevelTimePaused:0,PlayAudio2D:1,StopAudio:1,IsAudioAlive:1,GetLanguageType:0,GetStageMode:0,IsTestPlay:0,GetText:1,PrintClientUITree:0});function be(e){return e==null?"":typeof e=="string"?e:e.Name||e.FullName||String(e)}var Si=class{constructor(t={}){this.canvasWidth=t.canvasWidth??1600,this.canvasHeight=t.canvasHeight??900,this.device=t.device??"KeyboardAndMouse",this.language=t.language??"LanguageChs",this.stageMode=t.stageMode??"Classic",this.testPlay=t.testPlay!==!1,this.clock={time:0,levelTime:0,paused:!1,frame:0},this.logs=[],this.mountErrors=[],this.tweens=new Set,this.sequences=new Set,this.animations=new Set,this.audios=new Map,this.nextAudioId=1,this._nextControlId=1,this._playRemoved=[],this._nextScriptMappingId=1,this.lifecyclePhase="idle",this.controlsById=new Map,this.roots=[],this.templates=new Map,this.scriptFiles=new Map,this.requireAliases=new Map,this.requireCache=new Map,this.moduleBaseEnvironments=new Map,this.luaFunctions=new Map,this.mountedScripts=[],this.serverVars={Level:Object.create(null),PlayerSelf:Object.create(null),AvatarSelf:Object.create(null)},this.serverBridge=null,this.varHandlers=[],this.signalHandlers=[],this.cursor={x:0,y:0},this.focus=null,this.stick={left:[0,0],right:[0,0]},this.enumTree=un(),this.luaStates=new Set,this.L=null}nextControlId(){let t=this._nextControlId;return this._nextControlId+=1,t}resolveScriptMappingId(t){let i=Number(t);if(Number.isSafeInteger(i)&&i>0)return this._nextScriptMappingId=Math.max(this._nextScriptMappingId,i+1),i;let n=this._nextScriptMappingId;return this._nextScriptMappingId+=1,n}pushPackedColor(t,i){let n=i>>>0;(n|0)===n?u.lua_pushinteger(t,n):u.lua_pushnumber(t,n)}retainLuaCallback(t){Lr(t)}unrefLuaCallback(t){Wr(this,t)}log(t,...i){let n=i.map(r=>r==null?"nil":typeof r=="object"&&r!==null&&r.__kind==="EnumItem"?r.Name:String(r)).join(" ");this.logs.push({level:t,text:n,time:this.clock.time})}safeCall(t,...i){try{return t(...i)}catch(n){this.log("lua-error",n&&n.message?n.message:String(n))}}scriptCanRun(t){if(!t?.alive||!t.enabled)return!1;let i=t.object;return!i||i.alive&&i.activeInHierarchy}cursorEventsEnabled(t){for(let i=t;i;i=i.parent)if(i.kind==="container"&&i.showCursor===!0)return!0;return!1}registerTemplate(t,i){this.templates.set(Number(t),i)}registerScriptFile(t,i){let n=this.normalizeRequirePath(t);this.scriptFiles.set(n,i),n.startsWith("default_import_file/")||this.requireAliases.set(`default_import_file/${n}`,n)}normalizeRequirePath(t){let i=String(t).replace(/\\/g,"/");return i.endsWith(".lua")&&(i=i.slice(0,-4)),i}addRoot(t){let i=t instanceof Ke?t:new Ke(this,t);return this.roots.push(i),Pe(i,n=>this.controlsById.set(n.Id,n)),this.mountSpecScripts(t,i),i}mountSpecScripts(t,i){if(t instanceof Ke)return;let n=o=>(o.scripts?.length||0)>0||(o.children||[]).some(n);if(!t||!n(t))return;let r=this.lifecyclePhase;try{let o=(a,l)=>{for(let s of a.scripts||[])try{this.mountScript({path:s.path,source:s.source,control:l,scriptMappingId:s.scriptMappingId})}catch(f){let m=f&&f.message?f.message:String(f);this.mountErrors.push(m),this.log("lua-error",m)}let c=a.children||[];for(let s=0;s<c.length;s+=1)o(c[s],l?.children?.[s])};o(t,i)}finally{this.lifecyclePhase=r}}makeCursorEventData({x:t=0,y:i=0,pressX:n=t,pressY:r=i,deltaX:o=t-n,deltaY:a=i-r,dragging:l=!1,touchId:c=-1}={}){let s=this;return{__kind:"CursorEventData",typeofName:"CursorEventData",dragging:l,touchId:c,x:t,y:i,pressX:n,pressY:r,GetUIPos(){return[t,i]},GetPressUIPos(){return[n,r]},GetUIPosDelta(){return[o,a]}}}boot(){let t=this.newLuaThread();this.L=t}installGlobals(t){let i=this;u.lua_pushcfunction(t,n=>{let r=u.lua_gettop(n),o=[];for(let a=1;a<=r;a++)o.push(de(n,i,a));return i.log("info",...o),0}),u.lua_setglobal(t,_("print")),u.lua_pushcfunction(t,n=>{let r=u.lua_gettop(n),o=[];for(let a=1;a<=r;a++)o.push(de(n,i,a));return i.log("error",...o),0}),u.lua_setglobal(t,_("printerr")),u.lua_pushcfunction(t,n=>{if(u.lua_type(n,1)===u.LUA_TTABLE&&!Oe(n,1))return u.lua_pushstring(n,_("table")),1;let r=de(n,i,1);return u.lua_pushstring(n,_(i.typeofOf(r))),1}),u.lua_setglobal(t,_("typeof")),this.pushColorLib(t),this.pushEnumLib(t),this.pushGameLib(t),u.lua_pushcfunction(t,n=>i.luaRequire(n)),u.lua_setglobal(t,_("require"))}typeofOf(t){return t==null?"nil":t.__kind==="Script"?"Script":t.__kind==="EnumItem"?"EnumItem":t.__kind==="CursorEventData"?"CursorEventData":t.__kind==="ServerSignal"?"ServerSignal":t instanceof Et?"TweenSequence":t instanceof Bt?"Tween":t.typeofName?t.typeofName:typeof t=="number"?"number":typeof t=="string"?"string":typeof t=="boolean"?"boolean":typeof t}pushColorLib(t){u.lua_newtable(t),u.lua_pushcfunction(t,i=>(this.pushPackedColor(i,xt(u.lua_tonumber(i,1),u.lua_tonumber(i,2),u.lua_tonumber(i,3),255)),1)),u.lua_setfield(t,-2,_("FromRGB")),u.lua_pushcfunction(t,i=>{let n=u.lua_isnoneornil(i,4)?255:u.lua_tonumber(i,4);return this.pushPackedColor(i,xt(u.lua_tonumber(i,1),u.lua_tonumber(i,2),u.lua_tonumber(i,3),n)),1}),u.lua_setfield(t,-2,_("FromRGBA")),u.lua_pushcfunction(t,i=>{let n=u.lua_tonumber(i,1)>>>0;for(let r of Ut(n))u.lua_pushinteger(i,r);return 4}),u.lua_setfield(t,-2,_("ToRGBA")),u.lua_newtable(t),u.lua_pushcfunction(t,i=>{let n=u.lua_tonumber(i,2),r=u.lua_tonumber(i,3),o=u.lua_tonumber(i,4),a=u.lua_isnoneornil(i,5)?255:u.lua_tonumber(i,5);return this.pushPackedColor(i,xt(n,r,o,a)),1}),u.lua_setfield(t,-2,_("__call")),u.lua_setmetatable(t,-2),u.lua_setglobal(t,_("Color"))}pushEnumLib(t){u.lua_newtable(t);for(let[i,n]of Object.entries(this.enumTree)){u.lua_newtable(t);for(let[r,o]of Object.entries(n))this.pushEnumItem(t,o),u.lua_setfield(t,-2,_(r));u.lua_setfield(t,-2,_(i))}u.lua_setglobal(t,_("Enum"))}pushEnumItem(t,i){let n=u.lua_newuserdata(t,0);nt(n,i),Q.luaL_setmetatable(t,_("EnumItem"))}pushControl(t,i){let n=u.lua_newuserdata(t,0);nt(n,i),Q.luaL_setmetatable(t,_("Control"))}pushScript(t,i){u.lua_newtable(t),u.lua_pushlightuserdata(t,nn);let n=u.lua_newuserdata(t,0);nt(n,i),u.lua_rawset(t,-3),Q.luaL_getmetatable(t,_("Script")),u.lua_setmetatable(t,-2)}pushTween(t,i){let n=u.lua_newuserdata(t,0);nt(n,i);let r=i instanceof Et?"TweenSequence":"Tween";Q.luaL_setmetatable(t,_(r))}pushSignal(t,i){let n=u.lua_newuserdata(t,0);nt(n,i),Q.luaL_setmetatable(t,_("ServerSignal"))}pushCursor(t,i){let n=u.lua_newuserdata(t,0);nt(n,i),Q.luaL_setmetatable(t,_("CursorEventData"))}pushGameLib(t){let i=this;u.lua_newtable(t);let n={InstantiateClientUIControl:r=>{let o=u.lua_tointeger(r,1),a=Ie(u.lua_touserdata(r,2)),l=i.instantiate(o,a,i.lifecyclePhase);return l?(i.pushControl(r,l),1):(u.lua_pushnil(r),1)},DestroyClientUIControl:r=>{let o=Ie(u.lua_touserdata(r,1));return o&&i.destroyControl(o),0},GetClientUIControl:r=>{let o=u.lua_tointeger(r,1),a=i.controlsById.get(o);return a?i.pushControl(r,a):u.lua_pushnil(r),1},FindClientUIRoot:r=>{let o=W(r,1),a=i.roots.find(l=>l.name===o);return a?i.pushControl(r,a):u.lua_pushnil(r),1},GetClientUIRoots:r=>(u.lua_createtable(r,i.roots.length,0),i.roots.forEach((o,a)=>{i.pushControl(r,o),u.lua_rawseti(r,-2,a+1)}),1),GetUICanvasSize:r=>(u.lua_pushnumber(r,i.canvasWidth),u.lua_pushnumber(r,i.canvasHeight),2),GetCursorUIPos:r=>(u.lua_pushnumber(r,i.cursor.x),u.lua_pushnumber(r,i.cursor.y),2),GetDevice:r=>(i.pushEnumItem(r,rt("Device",i.device)),1),SetControllerFocus:r=>(i.focus=Ie(u.lua_touserdata(r,1)),0),GetControllerFocus:r=>(i.focus?i.pushControl(r,i.focus):u.lua_pushnil(r),1),GetControllerLeftStickAxis:r=>(u.lua_pushnumber(r,i.stick.left[0]),u.lua_pushnumber(r,i.stick.left[1]),2),GetControllerRightStickAxis:r=>(u.lua_pushnumber(r,i.stick.right[0]),u.lua_pushnumber(r,i.stick.right[1]),2),Tween:r=>{let o=Ie(u.lua_touserdata(r,1))||de(r,i,1),a=de(r,i,2)||{},l=u.lua_tonumber(r,3),c=new Bt(i,o,a,l);return i.pushTween(r,c),1},TweenSequence:r=>(i.pushTween(r,new Et(i)),1),ServerSignal:r=>{let o=W(r,1);return i.pushSignal(r,i.makeServerSignal(o)),1},GetGlobalCustomVariableValue:r=>{let o=be(de(r,i,1)),a=W(r,2);return ae(r,i,i.getVar(o,a)),1},PauseLevelTime:r=>(i.clock.paused=!!u.lua_toboolean(r,1),0),IsLevelTimePaused:r=>(u.lua_pushboolean(r,i.clock.paused),1),PlayAudio2D:r=>{let o=i.nextAudioId++;return i.audios.set(o,{audioId:u.lua_tointeger(r,1),alive:!0}),u.lua_pushinteger(r,o),1},StopAudio:r=>{let o=u.lua_tointeger(r,1),a=i.audios.get(o);return a&&(a.alive=!1),0},IsAudioAlive:r=>{let o=i.audios.get(u.lua_tointeger(r,1));return u.lua_pushboolean(r,!!(o&&o.alive)),1},GetLanguageType:r=>(i.pushEnumItem(r,rt("LanguageType",i.language)),1),GetStageMode:r=>(i.pushEnumItem(r,rt("StageMode",i.stageMode)),1),IsTestPlay:r=>(u.lua_pushboolean(r,i.testPlay),1),GetText:r=>{let o=W(r,1);return u.lua_pushstring(r,_(o)),1},PrintClientUITree:r=>{for(let o of i.roots)i.log("info",an(o).join(`
108
- `));return 0}};for(let[r,o]of Object.entries(n)){let a=bl[r];if(a===void 0)throw new Error(`missing game arity for ${r}`);u.lua_pushcfunction(t,l=>{let c=u.lua_gettop(l);return c!==a?Q.luaL_error(l,_(`bad argument count to '${r}' (${a} expected, got ${c})`)):o(l)}),u.lua_setfield(t,-2,_(r))}u.lua_setglobal(t,_("game"))}makeServerSignal(t){let i=[],n=this;return{__kind:"ServerSignal",name:t,AddParam(r,o){i.push({type:be(r),value:o})},AddInt(r){i.push({type:"Int",value:r})},AddIntList(r){i.push({type:"IntList",value:r})},AddFloat(r){i.push({type:"Float",value:r})},AddFloatList(r){i.push({type:"FloatList",value:r})},AddString(r){i.push({type:"String",value:r})},AddStringList(r){i.push({type:"StringList",value:r})},AddVector3(r){i.push({type:"Vector3",value:r})},AddVector3List(r){i.push({type:"Vector3List",value:r})},AddBool(r){i.push({type:"Bool",value:r})},AddBoolList(r){i.push({type:"BoolList",value:r})},AddGuid(r){i.push({type:"Guid",value:r})},AddGuidList(r){i.push({type:"GuidList",value:r})},AddEntity(r){i.push({type:"Entity",value:r})},AddEntityList(r){i.push({type:"EntityList",value:r})},AddPrefabId(r){i.push({type:"PrefabId",value:r})},AddPrefabIdList(r){i.push({type:"PrefabIdList",value:r})},AddConfigId(r){i.push({type:"ConfigId",value:r})},AddConfigIdList(r){i.push({type:"ConfigIdList",value:r})},SendSignal(){let r=i.slice();n.serverBridge&&typeof n.serverBridge.receiveFromClient=="function"&&n.serverBridge.receiveFromClient(t,r)}}}instantiate(t,i,n){if(n==="OnInit"||n==="OnDestroy")return null;let r=this.templates.get(Number(t));if(!r||!i)return null;let o=new Ke(this,{...r,Id:this.nextControlId(),authoringId:null,prefabIndex:Number(t)});return i.addChild(o),o.SetAsLastSibling(),Pe(o,a=>this.controlsById.set(a.Id,a)),this.mountSpecScripts(r,o),o}destroyControl(t){if(!(!t||!t.alive)){if(t._destroying)throw new Error(`\u5BA2\u6237\u7AEF\u63A7\u4EF6\u751F\u547D\u5468\u671F\u5904\u4E8E\u521B\u5EFA\u6216\u9500\u6BC1\u65F6\uFF0C\u65E0\u6CD5\u8C03\u7528DestroyClientUIControl, ID:${t.name}`);Pe(t,i=>{i._destroying=!0}),this._destroyControlTree(t)}}_destroyControlTree(t){this.releaseControlListeners(t);for(let i of t.scripts.slice())this.unmountScript(i);for(let i of t.children.slice())this._destroyControlTree(i);if(t.alive=!1,this._playRemoved.push(t.Id),t.parent){let i=t.parent,n=i.children.indexOf(t);n>=0&&i.children.splice(n,1),t._parent=null,i.markPlayDirty(!0)}else{let i=this.roots.indexOf(t);i>=0&&this.roots.splice(i,1)}this.controlsById.delete(t.Id),this.focus===t&&(this.focus=null);for(let i of[...this.tweens])i.object===t&&i.Kill(!1)}releaseControlListeners(t){for(let i of t.cursorListeners.values())for(let n of i)this.unrefLuaCallback(n);for(let i of t.keyListeners.values())for(let n of i)this.unrefLuaCallback(n);for(let i of t.navListeners.values())for(let n of i)this.unrefLuaCallback(n);t.cursorListeners.clear(),t.keyListeners.clear(),t.navListeners.clear(),t.navConfig.clear()}onControlActiveChanging(t,i){let n=[];Pe(t,r=>n.push({control:r,was:r.activeInHierarchy})),t.active=!!i,t.markPlayDirty(!0);for(let r of n){let o=r.control.activeInHierarchy;if(r.was!==o)for(let a of r.control.scripts.slice())o?this.enableScript(a):this.disableScript(a)}}bindScriptEnv(t){let i=t.env;return i?(this.pushScript(i,t),u.lua_setglobal(i,_("script")),i):null}disableScript(t){if(!t?.alive||!t.env||t.lifecyclePhase!=="running")return;let i=this.lifecyclePhase;this.lifecyclePhase="OnDisable",t.lifecyclePhase="OnDisable",this.bindScriptEnv(t),this.callGlobal(t.env,"OnDisable"),t.lifecyclePhase="disabled",this.lifecyclePhase=i}enableScript(t){if(!t?.alive||!t.env||t.lifecyclePhase!=="disabled")return;let i=this.lifecyclePhase;this.lifecyclePhase="OnEnable",t.lifecyclePhase="OnEnable",this.bindScriptEnv(t),this.callGlobal(t.env,"OnEnable"),t.lifecyclePhase="running",this.lifecyclePhase=i}unmountScript(t){if(!t||!t.alive)return;let i=t.env,n=this.lifecyclePhase;i&&(t.lifecyclePhase==="running"&&(this.lifecyclePhase="OnDisable",t.lifecyclePhase="OnDisable",this.bindScriptEnv(t),this.callGlobal(i,"OnDisable")),this.lifecyclePhase="OnDestroy",t.lifecyclePhase="OnDestroy",this.bindScriptEnv(t),this.callGlobal(i,"OnDestroy")),t.alive=!1,t.lifecyclePhase="destroyed",this.lifecyclePhase=n,this.mountedScripts=this.mountedScripts.filter(r=>r!==t),t.object&&(t.object.scripts=t.object.scripts.filter(r=>r!==t)),this.varHandlers=this.varHandlers.filter(r=>r.script!==t),this.signalHandlers=this.signalHandlers.filter(r=>r.script!==t),i&&i!==this.L&&this.closeTrackedLuaState(i),t.env=null}installMetatables(t){this.mtEnum(t),this.mtControl(t),this.mtScript(t),this.mtTween(t),this.mtSeq(t),this.mtSignal(t),this.mtCursor(t)}mtIndexNewindex(t,i,n,r,o,a){Q.luaL_newmetatable(t,_(i)),u.lua_pushcfunction(t,l=>{let c=Oe(l,1)||Ie(u.lua_touserdata(l,1)),s=W(l,2);if(o[s]&&(!a||a(c,s)))return u.lua_pushcfunction(l,o[s]),1;let f;try{f=n(c,s)}catch(m){return Q.luaL_error(l,_(String(m.message||m)))}return f===void 0?(u.lua_pushnil(l),1):(ae(l,this,f),1)}),u.lua_setfield(t,-2,_("__index")),u.lua_pushcfunction(t,l=>{try{let c=Oe(l,1)||Ie(u.lua_touserdata(l,1)),s=W(l,2),f=de(l,this,3);return r(c,s,f),0}catch(c){return u.lua_pushstring(l,_(String(c.message||c))),u.lua_error(l)}}),u.lua_setfield(t,-2,_("__newindex")),u.lua_pushcfunction(t,l=>{let c=Oe(l,1)||Ie(u.lua_touserdata(l,1)),s=Oe(l,2)||Ie(u.lua_touserdata(l,2));return u.lua_pushboolean(l,c===s),1}),u.lua_setfield(t,-2,_("__eq")),u.lua_pop(t,1)}method(t){let i=this;return n=>{let r=Oe(n,1)||Ie(u.lua_touserdata(n,1)),o=u.lua_gettop(n),a=[];for(let l=2;l<=o;l++)a.push(de(n,i,l));try{let l=t(r,...a);if(l===r)return u.lua_pushvalue(n,1),1;if(l===void 0)return 0;if(Array.isArray(l)&&l.__multi){for(let c of l)ae(n,i,c);return l.length}if(Array.isArray(l)&&!(l.length&&typeof l[0]=="object"&&l[0]?.typeofName)){if(l.__controls)return u.lua_createtable(n,l.length,0),l.forEach((c,s)=>{i.pushControl(n,c),u.lua_rawseti(n,-2,s+1)}),1;if(l.__scripts)return u.lua_createtable(n,l.length,0),l.forEach((c,s)=>{i.pushScript(n,c),u.lua_rawseti(n,-2,s+1)}),1;if(typeof l[0]=="number"&&l.length<=4){for(let c of l)u.lua_pushnumber(n,c);return l.length}}return ae(n,i,l),1}catch(l){return u.lua_pushstring(n,_(String(l.message||l))),u.lua_error(n)}}}mtEnum(t){let i=new Set(["Name","FullName","EnumType"]);this.mtIndexNewindex(t,"EnumItem",(n,r)=>i.has(r)?n[r]:void 0,(n,r)=>{throw new Error(`cannot set ${r}, no such field`)},{})}mtCursor(t){let i=new Set(["dragging","touchId"]);this.mtIndexNewindex(t,"CursorEventData",(n,r)=>i.has(r)?n[r]:void 0,(n,r)=>{throw new Error(`cannot set ${r}, no such field`)},{GetUIPos:this.method(n=>n.GetUIPos()),GetPressUIPos:this.method(n=>n.GetPressUIPos()),GetUIPosDelta:this.method(n=>n.GetUIPosDelta())})}mtControl(t){let i={GetChildren:this.method(n=>{let r=n.GetChildren();return r.__controls=!0,r}),GetChild:this.method((n,r)=>n.GetChild(r)),FindChild:this.method((n,r)=>n.FindChild(r)),SetActive:this.method((n,r)=>n.SetActive(r)),SetVisible:this.method((n,r)=>n.SetVisible(r)),GetSiblingIndex:this.method(n=>n.GetSiblingIndex()),SetSiblingIndex:this.method((n,r)=>n.SetSiblingIndex(r)),SetAsFirstSibling:this.method(n=>n.SetAsFirstSibling()),SetAsLastSibling:this.method(n=>n.SetAsLastSibling()),GetAnchoredPosition:this.method(n=>n.GetAnchoredPosition()),SetAnchoredPosition:this.method((n,r,o)=>n.SetAnchoredPosition(r,o)),GetSizeDelta:this.method(n=>n.GetSizeDelta()),SetSizeDelta:this.method((n,r,o)=>n.SetSizeDelta(r,o)),GetAnchorMin:this.method(n=>n.GetAnchorMin()),SetAnchorMin:this.method((n,r,o)=>n.SetAnchorMin(r,o)),GetAnchorMax:this.method(n=>n.GetAnchorMax()),SetAnchorMax:this.method((n,r,o)=>n.SetAnchorMax(r,o)),GetPivot:this.method(n=>n.GetPivot()),SetPivot:this.method((n,r,o)=>n.SetPivot(r,o)),GetLocalScale:this.method(n=>n.GetLocalScale()),SetLocalScale:this.method((n,r,o,a)=>n.SetLocalScale(r,o,a)),GetLocalRotation:this.method(n=>n.GetLocalRotation()),SetLocalRotation:this.method((n,r,o,a)=>n.SetLocalRotation(r,o,a)),GetScriptByPath:this.method((n,r)=>n.GetScriptByPath(r)),GetScript:this.method((n,r)=>n.GetScript(r)),GetScripts:this.method(n=>{let r=n.GetScripts();return r.__scripts=!0,r}),AddCursorEventListener:this.method((n,r,o)=>n.AddCursorEventListener(be(r),o)),RemoveCursorEventListener:this.method((n,r,o)=>n.RemoveCursorEventListener(be(r),o)),RemoveCursorEventListeners:this.method((n,r)=>n.RemoveCursorEventListeners(be(r))),RemoveAllCursorEventListeners:this.method(n=>n.RemoveAllCursorEventListeners()),SimulateCursorClick:this.method(n=>n.SimulateCursorClick()),AddKeyEventListener:this.method((n,r,o)=>n.AddKeyEventListener(be(r),o)),RemoveKeyEventListener:this.method((n,r,o)=>n.RemoveKeyEventListener(be(r),o)),RemoveKeyEventListeners:this.method((n,r)=>n.RemoveKeyEventListeners(be(r))),RemoveAllKeyEventListeners:this.method(n=>n.RemoveAllKeyEventListeners()),AddNavigationEventListener:this.method((n,r,o)=>n.AddNavigationEventListener(be(r),o)),RemoveNavigationEventListener:this.method((n,r,o)=>n.RemoveNavigationEventListener(be(r),o)),RemoveNavigationEventListeners:this.method((n,r)=>n.RemoveNavigationEventListeners(be(r))),RemoveAllNavigationEventListeners:this.method(n=>n.RemoveAllNavigationEventListeners()),SetControllerNavigation:this.method((n,r,o,a)=>n.SetControllerNavigation(be(r),o,a)),GetControllerNavigation:this.method((n,r)=>n.GetControllerNavigation(be(r))),SetImage:this.method((n,r,o)=>n.SetImage(r,o)),SetSoftEdgeWidth:this.method((n,r,o)=>n.SetSoftEdgeWidth(r,o)),SetFillUnused:this.method(n=>n.SetFillUnused()),SetFillHorizontal:this.method((n,r,o)=>n.SetFillHorizontal(r,o)),SetFillVertical:this.method((n,r,o)=>n.SetFillVertical(r,o)),SetFillRadial90:this.method((n,r,o)=>n.SetFillRadial90(r,o)),SetFillRadial180:this.method((n,r,o)=>n.SetFillRadial180(r,o)),SetFillRadial360:this.method((n,r,o)=>n.SetFillRadial360(r,o)),PlayAnimation:this.method(n=>n.PlayAnimation()),StopAnimation:this.method(n=>n.StopAnimation()),RefreshItems:this.method(n=>n.RefreshItems()),GetItemIndex:this.method(n=>n.GetItemIndex()),GetItemSize:this.method(n=>n.GetItemSize()),GetItemSpacing:this.method(n=>n.GetItemSpacing()),GetPadding:this.method(n=>n.GetPadding()),ScrollToItemAt:this.method(n=>n.ScrollToItemAt()),GetContentLength:this.method(n=>n.GetContentLength())};this.mtIndexNewindex(t,"Control",(n,r)=>{if(!on(n,r))return;if(!n.alive&&r!=="alive")throw new Error(`attempt to read '${r}' of a destroyed control`);let o=n.luaFieldValue(r),a=ao[r];return a?sn(a,o):typeof o=="number"&&!gl.has(r)&&!yl.has(r)?new Yt(o):o},(n,r,o)=>{if(on(n,r)==="rw"){if((r==="fontSize"||r==="minimumFontSize")&&!Number.isInteger(o)){let c=o===null?"nil":typeof o;throw new Error(`bad argument #2 to '${r}' (integer expected, got ${c})`)}let l=ao[r];n[r]=l?sn(l,o):o,typeof n.markPlayDirty=="function"&&n.markPlayDirty(gi.has(r));return}throw new Error(`cannot set ${r}, no such field`)},i,to)}mtScript(t){let i=this,n=new Set(["alive","scriptMappingId","object","path","enabled"]);this.mtIndexNewindex(t,"Script",(r,o)=>n.has(o)?r[o]:void 0,(r,o,a)=>{if(o==="enabled"){r.enabled=!!a;return}throw new Error(`cannot set ${o}, no such field`)},{GetParam:this.method((r,o)=>Object.prototype.hasOwnProperty.call(r.params,o)?r.params[o]:null),Invoke:r=>i.luaInvoke(r),EnableUpdate:this.method((r,o)=>{r.updateEnabled=!!o}),RegisterServerSignalHandler:this.method((r,o,a)=>{i.signalHandlers.push({script:r,name:o,fn:a})}),UnregisterServerSignalHandler:this.method((r,o)=>{i.signalHandlers=i.signalHandlers.filter(a=>!(a.script===r&&a.name===o))}),RegisterCustomVariableChangedHandler:this.method((r,o,a,l)=>{i.varHandlers.push({script:r,entityType:be(o),name:a,fn:l})}),UnregisterCustomVariableChangedHandler:this.method((r,o,a)=>{let l=be(o);i.varHandlers=i.varHandlers.filter(c=>!(c.script===r&&c.entityType===l&&c.name===a))})})}mtTween(t){this.mtIndexNewindex(t,"Tween",()=>{},()=>{},{SetEase:this.method((i,n)=>i.SetEase(n)),SetRelative:this.method((i,n)=>i.SetRelative(n)),Play:this.method(i=>i.Play()),Pause:this.method(i=>i.Pause()),Resume:this.method(i=>i.Resume()),Restart:this.method(i=>i.Restart()),Complete:this.method(i=>i.Complete()),Kill:this.method((i,n)=>i.Kill(n)),SetOnComplete:this.method((i,n)=>i.SetOnComplete(n)),SetOnStepComplete:this.method((i,n)=>i.SetOnStepComplete(n)),SetLoops:this.method((i,n)=>i.SetLoops(n))})}mtSeq(t){this.mtIndexNewindex(t,"TweenSequence",()=>{},()=>{},{Append:this.method((i,n)=>i.Append(n)),AppendInterval:this.method((i,n)=>i.AppendInterval(n)),AppendCallback:this.method((i,n)=>i.AppendCallback(n)),Join:this.method((i,n)=>i.Join(n)),Insert:this.method((i,n,r)=>i.Insert(n,r)),InsertCallback:this.method((i,n,r)=>i.InsertCallback(n,r)),Play:this.method(i=>i.Play()),Pause:this.method(i=>i.Pause()),Resume:this.method(i=>i.Resume()),Restart:this.method(i=>i.Restart()),Complete:this.method(i=>i.Complete()),Kill:this.method((i,n)=>i.Kill(n)),SetOnComplete:this.method((i,n)=>i.SetOnComplete(n)),SetOnStepComplete:this.method((i,n)=>i.SetOnStepComplete(n)),SetLoops:this.method((i,n)=>i.SetLoops(n))})}mtSignal(t){this.mtIndexNewindex(t,"ServerSignal",()=>{},()=>{},{AddParam:this.method((i,n,r)=>i.AddParam(n,r)),SendSignal:this.method(i=>i.SendSignal()),AddInt:this.method((i,n)=>i.AddInt(n)),AddIntList:this.method((i,n)=>i.AddIntList(n)),AddFloat:this.method((i,n)=>i.AddFloat(n)),AddFloatList:this.method((i,n)=>i.AddFloatList(n)),AddString:this.method((i,n)=>i.AddString(n)),AddStringList:this.method((i,n)=>i.AddStringList(n)),AddVector3:this.method((i,n)=>i.AddVector3(n)),AddVector3List:this.method((i,n)=>i.AddVector3List(n)),AddBool:this.method((i,n)=>i.AddBool(n)),AddBoolList:this.method((i,n)=>i.AddBoolList(n)),AddGuid:this.method((i,n)=>i.AddGuid(n)),AddGuidList:this.method((i,n)=>i.AddGuidList(n)),AddEntity:this.method((i,n)=>i.AddEntity(n)),AddEntityList:this.method((i,n)=>i.AddEntityList(n)),AddPrefabId:this.method((i,n)=>i.AddPrefabId(n)),AddPrefabIdList:this.method((i,n)=>i.AddPrefabIdList(n)),AddConfigId:this.method((i,n)=>i.AddConfigId(n)),AddConfigIdList:this.method((i,n)=>i.AddConfigIdList(n))})}luaRequire(t){let i=W(t,1),n=this.normalizeRequirePath(i),r=this.requireAliases.get(n)||n;u.lua_rawgeti(t,ot,u.LUA_RIDX_MAINTHREAD);let o=u.lua_tothread(t,-1);u.lua_pop(t,1);let a=this.requireCache.get(o);a||(a=new Map,this.requireCache.set(o,a));let l=a.get(r);if(l?.loading)return u.lua_pushstring(t,_(`failed to load script '${n}': cyclic require`)),u.lua_error(t);if(l&&l.ref!=null)return u.lua_rawgeti(t,ot,l.ref),1;let c=this.scriptFiles.get(r);if(c==null)return u.lua_pushstring(t,_(`failed to load script '${n}'`)),u.lua_error(t);let s=u.lua_gettop(t);a.set(r,{loading:!0});try{this.loadModule(t,o,r,c),u.lua_pushvalue(t,-1);let f=Q.luaL_ref(t,ot);return a.set(r,{ref:f}),1}catch(f){return a.delete(r),u.lua_settop(t,s),u.lua_pushstring(t,_(`failed to load script '${n}': ${f.message||f}`)),u.lua_error(t)}}newLuaThread(){let t=Q.luaL_newstate();return Xr.luaL_openlibs(t),qr(t),this.installMetatables(t),this.installGlobals(t),this.luaStates.add(t),u.lua_pushglobaltable(t),this.copyLuaEnvironment(t,-1),u.lua_remove(t,-2),this.moduleBaseEnvironments.set(t,Q.luaL_ref(t,ot)),t}copyLuaEnvironment(t,i){let n=u.lua_absindex(t,i);u.lua_newtable(t);let r=u.lua_absindex(t,-1);for(u.lua_pushnil(t);u.lua_next(t,n)!==0;)u.lua_pushvalue(t,-2),u.lua_pushvalue(t,-2),u.lua_rawset(t,r),u.lua_pop(t,1);u.lua_pushvalue(t,r),u.lua_setfield(t,r,_("_G"))}closeTrackedLuaState(t){if(!t||!this.luaStates.has(t))return;for(let n of this.requireCache.get(t)?.values()||[])n.ref!=null&&Q.luaL_unref(t,ot,n.ref);this.requireCache.delete(t);let i=this.moduleBaseEnvironments.get(t);if(i!=null&&Q.luaL_unref(t,ot,i),this.moduleBaseEnvironments.delete(t),this.luaStates.delete(t),this.luaFunctions)for(let[n,r]of this.luaFunctions)r.__luaState===t&&this.luaFunctions.delete(n);jr(t)}loadModule(t,i,n,r){let o={__kind:"Script",alive:!0,scriptMappingId:this.resolveScriptMappingId(),object:null,path:n,enabled:!0,updateEnabled:!1,params:{},env:t,invoke(){}},a=String(r).replace(/^\uFEFF/,""),l=pi(a);if(Q.luaL_loadbuffer(t,l,l.length,_(`@${n}`))!==Ee)throw new Error(W(t,-1));let s=u.lua_absindex(t,-1);if(u.lua_rawgeti(t,ot,this.moduleBaseEnvironments.get(i)),this.copyLuaEnvironment(t,-1),u.lua_remove(t,-2),this.pushScript(t,o),u.lua_setfield(t,-2,_("script")),u.lua_setupvalue(t,s,1),u.lua_pcall(t,0,1,0)!==Ee)throw new Error(W(t,-1))}mountScript({path:t,source:i,control:n,params:r={},scriptMappingId:o=void 0}){this.L||this.boot();let a=this.newLuaThread(),l={__kind:"Script",alive:!0,scriptMappingId:this.resolveScriptMappingId(o),object:n,path:this.normalizeRequirePath(t),enabled:!0,updateEnabled:!1,params:r,env:a,lifecyclePhase:"idle"};l.invoke=(s,f)=>this.invokeOn(a,s,f),n&&n.scripts.push(l),this.mountedScripts.push(l),this.pushScript(a,l),u.lua_setglobal(a,_("script"));let c=this.lifecyclePhase;try{this.lifecyclePhase="OnInit",l.lifecyclePhase="OnInit",this.runChunk(a,i,t);let s=this.callGlobal(a,"OnInit");s&&this.mountErrors.push(s),this.lifecyclePhase="OnEnable",l.lifecyclePhase="OnEnable";let f=this.callGlobal(a,"OnEnable");f&&this.mountErrors.push(f),this.lifecyclePhase="OnStart",l.lifecyclePhase="OnStart";let m=this.callGlobal(a,"OnStart");return m&&this.mountErrors.push(m),this.lifecyclePhase="running",l.lifecyclePhase="running",l}catch(s){throw l.alive=!1,l.lifecyclePhase="failed",this.mountedScripts=this.mountedScripts.filter(f=>f!==l),n&&(n.scripts=n.scripts.filter(f=>f!==l)),this.varHandlers=this.varHandlers.filter(f=>f.script!==l),this.signalHandlers=this.signalHandlers.filter(f=>f.script!==l),this.lifecyclePhase=c,a&&a!==this.L&&this.closeTrackedLuaState(a),l.env=null,s}}runChunk(t,i,n){let r=String(i).replace(/^\uFEFF/,""),o=pi(r),a=Q.luaL_loadbuffer(t,o,o.length,_(`@${n}`));if(a!==Ee){let c=W(t,-1)||`luaL_loadbuffer status ${a}`;throw u.lua_pop(t,1),new Error(c)}let l=u.lua_pcall(t,0,0,0);if(l!==Ee){let c=W(t,-1)||`lua_pcall status ${l}`;throw u.lua_pop(t,1),new Error(c)}}callGlobal(t,i){if(u.lua_getglobal(t,_(i)),u.lua_isfunction(t,-1)){if(u.lua_pcall(t,0,0,0)!==Ee){let r=W(t,-1);u.lua_pop(t,1);let o=`${i}: ${r}`;return this.log("lua-error",o),o}}else u.lua_pop(t,1);return null}callGlobalDt(t,i,n){if(u.lua_getglobal(t,_(i)),u.lua_isfunction(t,-1)){if(u.lua_pushnumber(t,n),u.lua_pcall(t,1,0,0)!==Ee){let o=W(t,-1);u.lua_pop(t,1),this.log("lua-error",`${i}: ${o}`)}}else u.lua_pop(t,1)}luaInvoke(t){let i=Oe(t,1);if(!i||i.__kind!=="Script")return Q.luaL_error(t,_("bad self to 'Invoke' (Script expected)"));let n=W(t,2),r=i.env;if(!r||r.l_G!==t.l_G){let c=[];for(let m=3;m<=u.lua_gettop(t);m++)c.push(de(t,this,m));let s;try{s=i.invoke(n,c)}catch(m){return Q.luaL_error(t,_(String(m.message||m)))}if(s===void 0)return 0;let f=Array.isArray(s)&&s.__multi?s:[s];for(let m of f)ae(t,this,m);return f.length}let o=2;if(u.lua_getglobal(t,_(n)),!u.lua_isfunction(t,-1))return 0;u.lua_replace(t,o),u.lua_remove(t,1);let a=u.lua_gettop(t)-1;return u.lua_pcall(t,a,lo,0)!==Ee?u.lua_error(t):u.lua_gettop(t)}invokeOn(t,i,n){let r=u.lua_gettop(t);if(u.lua_getglobal(t,_(i)),!u.lua_isfunction(t,-1)){u.lua_settop(t,r);return}for(let c of n)ae(t,this,c);if(u.lua_pcall(t,n.length,lo,0)!==Ee){let c=W(t,-1);throw u.lua_settop(t,r),new Error(c)}let a=u.lua_gettop(t)-r;if(a<=0){u.lua_settop(t,r);return}if(a===1){let c=de(t,this,-1);return u.lua_settop(t,r),c}let l=[];for(let c=1;c<=a;c++)l.push(de(t,this,r+c));return u.lua_settop(t,r),l.__multi=!0,l}runScriptPhase(t,i){for(let n of this.mountedScripts){if(!this.scriptCanRun(n))continue;let r=n.env;r&&(this.pushScript(r,n),u.lua_setglobal(r,_("script")),!(t==="OnUpdate"&&!n.updateEnabled)&&this.callGlobalDt(r,t,i))}}step(t=1/30){if(typeof t!="number"||!Number.isFinite(t)||t<0)throw new TypeError("dt must be a finite non-negative number");this.clock.frame++,this.clock.time+=t;let i=!this.clock.paused;for(let n of[...this.animations])n.step(t);this.runScriptPhase("OnUpdate",t),i&&(this.clock.levelTime+=t,this.runScriptPhase("OnLevelUpdate",t))}injectKey(t){let i=n=>{if(!n.alive||!n.activeInHierarchy)return!1;if(n.keyListeners.has(t)&&n.emitKey(t))return!0;for(let r of[...n.children])if(i(r))return!0;return!1};for(let n of[...this.roots])i(n)}injectCursor(t,i,n){let r=n||this.makeCursorEventData({});Number.isFinite(r.x)&&Number.isFinite(r.y)&&(this.cursor.x=r.x,this.cursor.y=r.y),t.emitCursor(i,r)}getVar(t,i){if(this.serverBridge&&typeof this.serverBridge.getVar=="function")return this.serverBridge.getVar(t,i);let n=this.serverVars[t];return n?n[i]:void 0}notifyVarHandlers(t,i){for(let n of this.varHandlers)this.scriptCanRun(n.script)&&n.entityType===t&&n.name===i&&this.safeCall(n.fn,this.enumTree.CustomVariableEntityType[t],i)}setVar(t,i,n){if(this.serverBridge&&typeof this.serverBridge.setVar=="function"){this.serverBridge.setVar(t,i,n);return}let r=this.serverVars[t]||(this.serverVars[t]=Object.create(null));r[i]=n,this.notifyVarHandlers(t,i)}sendClientSignal(t,i){for(let n of this.signalHandlers)this.scriptCanRun(n.script)&&n.name===t&&this.safeCall(n.fn,t,i)}evalQueryScript(t,i){this.L||this.boot();let n=this.L;u.lua_createtable(n,0,5);let r=(o,a)=>{u.lua_pushcfunction(n,a),u.lua_setfield(n,-2,_(o))};return r("var",o=>(ae(o,this,i.var(W(o,1),W(o,2))),1)),r("logContains",o=>(u.lua_pushboolean(o,i.logContains(W(o,1))),1)),r("control",o=>(ae(o,this,i.control(W(o,1))),1)),r("logs",o=>(ae(o,this,i.logs()),1)),r("signals",o=>(ae(o,this,i.signals(W(o,1))),1)),r("serverLogs",o=>(ae(o,this,i.serverLogs?i.serverLogs():[]),1)),r("serverLogContains",o=>{let a=i.serverLogContains;return u.lua_pushboolean(o,a?!!a(W(o,1)):!1),1}),u.lua_setglobal(n,_("query")),this.runChunk(n,t,"autotest-assert"),!0}destroy(){for(let t of this.roots.slice())this.destroyControl(t);for(let t of this.mountedScripts.slice())this.unmountScript(t);this.lifecyclePhase="idle",this.mountedScripts=[],this.luaFunctions.clear();for(let t of[...this.luaStates])this.closeTrackedLuaState(t);this.L=null}};function Xt(e){let t=new Si(e);return t.boot(),t}var lt=Object.freeze(Array.from({length:8},(e,t)=>`Player${t+1}`)),dn=Object.freeze(Array.from({length:8},(e,t)=>`Avatar${t+1}`)),go=Object.freeze(["Level","PlayerSelf","AvatarSelf"]);var cn=Object.freeze([...go,...lt,...dn]),yo=Object.freeze(["PlayerSelf","AllPlayers",...lt]),vl=Object.freeze(["Level","PlayerSelf",...lt]),so=Object.freeze(["Int","Float","String","Bool","Vector3","Entity","Guid","PrefabId","ConfigId","IntList","FloatList","StringList","BoolList","Vector3List","EntityList","GuidList","PrefabIdList","ConfigIdList","Dict","Struct"]),Sl=-2147483648,Cl=2147483647,Il=new Set(["set-custom-variable","get-custom-variable","custom-variable-changed","\u8BBE\u7F6E\u81EA\u5B9A\u4E49\u53D8\u91CF","\u83B7\u53D6\u81EA\u5B9A\u4E49\u53D8\u91CF","\u81EA\u5B9A\u4E49\u53D8\u91CF\u53D8\u5316\u65F6","send-signal","listen-signal","send-client-script-signal","\u53D1\u9001\u4FE1\u53F7","\u76D1\u542C\u4FE1\u53F7","\u53D1\u9001\u5BA2\u6237\u7AEF\u811A\u672C\u4FE1\u53F7","setVar","getVar","signal","var"]);function Kt(e){return`Player${Number(e)}`}function Ci(e){return`Avatar${Number(e)}`}function uo(e){let t=String(e||"").match(/^(?:Player|Avatar)([1-8])$/);return t?Number(t[1]):0}function at(e){if(e==null||e==="")return 1;let t=Number(e);if(!Number.isInteger(t)||t<1||t>8)throw new Error("playerCount must be an integer 1-8");return t}function $e(e,t=8){let i=at(t);if(e==null||e==="")return 1;let n=Number(e);if(!Number.isInteger(n)||n<1||n>i)throw new Error(`playerIndex must be an integer 1-${i}`);return n}function co(){let e={Level:Object.create(null),PlayerSelf:Object.create(null),AvatarSelf:Object.create(null)};for(let t of lt)e[t]=Object.create(null);for(let t of dn)e[t]=Object.create(null);return e}function bo(e){let t=String(e||"");if(!cn.includes(t))throw new Error(`unknown CustomVariableEntityType: ${e}`);return t}function wl(e,t){let i=bo(e);if(!vl.includes(i))throw new Error(`${t}.entityType must be Level, PlayerSelf, or Player1-8`);return i}function Ht(e){let t=String(e??"");if(!t)throw new Error("custom variable name is required");return t}function Ii(e){let t=String(e??"");if(!t)throw new Error("signal name is required");return t}function fn(e){let t=String(e||"PlayerSelf");if(!yo.includes(t))throw new Error(`unsupported client signal target: ${e}. use PlayerSelf, AllPlayers, or Player1-8`);return t}function Lt(e){if(e==null)return"";if(typeof e=="boolean")return"Bool";if(typeof e=="string")return"String";if(typeof e=="number")return Number.isInteger(e)?"Int":"Float";if(Array.isArray(e)){if(e.length===0)return"IntList";let t=Lt(e[0]);return t&&!t.endsWith("List")&&t!=="Dict"&&t!=="Struct"?`${t}List`:"IntList"}return e&&typeof e=="object"?"x"in e||"y"in e||"z"in e?"Vector3":"Dict":""}function Se(e){return e===void 0?null:JSON.parse(JSON.stringify(e))}function fo(e){return Array.isArray(e)?e.map(t=>t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"value")&&"type"in t?t.value:t):[]}function ho(e){return Array.isArray(e)?e.map(t=>t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"value")&&"type"in t?{type:String(t.type||""),value:t.value}:{type:Lt(t),value:t}):[]}function xl(e){return String(e?.kind||e?.type||e?.name||e?.id||"")}function wi(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function vo(e,t){if(!wi(e)||!Object.prototype.hasOwnProperty.call(e,"fromSignalParam"))return null;if(Object.keys(e).some(n=>n!=="fromSignalParam"))throw new Error(`${t}.fromSignalParam cannot be combined with literal fields`);let i=Number(e.fromSignalParam);if(!Number.isSafeInteger(i)||i<0)throw new Error(`${t}.fromSignalParam must be a non-negative integer`);return{fromSignalParam:i}}function mo(e,t){return vo(e,t)||Se(e)}function El(e,t,i){if(!wi(e))throw new Error(`serverLogic.rules[${t}].actions[${i}] must be an object`);let n=String(e.kind||e.type||""),r=`serverLogic.rules[${t}].actions[${i}]`;if(n==="setCustomVariable"){let o=wl(e.entityType,r);if(!Object.prototype.hasOwnProperty.call(e,"value"))throw new Error(`${r}.value is required`);return{kind:n,entityType:o,name:Ht(e.name),value:mo(e.value,`${r}.value`),...e.variableType?{variableType:String(e.variableType)}:{}}}if(n==="sendClientScriptSignal"){if(!Array.isArray(e.params))throw new Error(`${r}.params must be an array`);return{kind:n,target:fn(e.target),signalName:Ii(e.signalName),params:e.params.map((o,a)=>mo(o,`${r}.params[${a}]`))}}throw new Error(`${r}.kind must be setCustomVariable or sendClientScriptSignal`)}function Wt(e){if(e==null)return{version:1,rules:[]};if(!wi(e))throw new Error("serverLogic must be an object");let t=e.rules===void 0?[]:e.rules;if(!Array.isArray(t))throw new Error("serverLogic.rules must be an array");return{version:1,rules:t.map((i,n)=>{if(!wi(i))throw new Error(`serverLogic.rules[${n}] must be an object`);if(!Array.isArray(i.actions)||i.actions.length===0)throw new Error(`serverLogic.rules[${n}].actions must be a non-empty array`);return{id:String(i.id||`signal-${n+1}`),signalName:Ii(i.signalName),actions:i.actions.map((r,o)=>El(r,n,o))}})}}function po(e,t,{typed:i=!1}={}){let n=vo(e,"server logic value");if(n){let r=i?t.params:t.values;if(n.fromSignalParam>=r.length)throw new Error(`signal ${t.name} has no parameter at index ${n.fromSignalParam}`);return Se(r[n.fromSignalParam])}return Se(e)}function Al(e){return e==="Level"?"Level":lt.includes(e)?"PlayerSelf":dn.includes(e)?"AvatarSelf":e}function So(e={}){let t=co(),i=co(),n=[],r=[],o=[],a=[],l=Array.from({length:9},()=>null),c=1,s=0,f=Number(e.onlineLatencyMs||0);(!Number.isFinite(f)||f<0)&&(f=0);let m=Wt(e.logic),h=at(e.playerCount),g=$e(e.viewPlayerIndex,h);function b(y,x){a.push({source:"server",level:String(y||"engine"),text:String(x),time:s})}function w(y){let x=l[y||g],v=Number(x?.clock?.time);Number.isFinite(v)&&(s=v)}function M(y,x,v,I){t[y][x]=v,i[y][x]={type:I||Lt(v)||i[y][x]?.type||""}}function E(y,x,v){return typeof v!="number"||!Number.isInteger(v)?{ok:!0,value:v}:v>=Sl&&v<=Cl?{ok:!0,value:v}:(b("engine",`Int custom variable ${y}.${x} out of range ${v}; keeping previous legal value`),{ok:!1,value:t[y][x]})}function A(y,x){let v=bo(y),I=x||g;return v==="PlayerSelf"?Kt(I):v==="AvatarSelf"?Ci(I):v}function U(y,x){let v=Al(y);if(y==="Level"){for(let S=1;S<=h;S+=1){let P=l[S];P&&typeof P.notifyVarHandlers=="function"&&P.notifyVarHandlers("Level",x)}return}let I=uo(y);if(!I)return;let F=l[I];F&&typeof F.notifyVarHandlers=="function"&&F.notifyVarHandlers(v,x)}function $(y,x){let v=fn(y);return v==="AllPlayers"?Array.from({length:h},(I,F)=>F+1):v==="PlayerSelf"?[x||g]:[uo(v)]}function q(y){for(let x of m.rules)if(x.signalName===y.name)for(let v of x.actions){if(v.kind==="setCustomVariable"){let I=po(v.value,y);O.setVar(v.entityType,v.name,I,{type:v.variableType,playerIndex:y.playerIndex}),b("info",`logic ${x.id}: set ${v.entityType}.${v.name}`);continue}if(v.kind==="sendClientScriptSignal"){let I=v.params.map(F=>po(F,y,{typed:!0}));O.sendToClient(v.signalName,I,{target:v.target,playerIndex:y.playerIndex}),b("info",`logic ${x.id}: sent ${v.signalName} to ${v.target}`)}}}function ee(y,x){y&&(y.serverBridge={getVar:(v,I)=>O.getVar(v,I,{playerIndex:x}),setVar:(v,I,F)=>O.setVar(v,I,F,{playerIndex:x}),receiveFromClient:(v,I)=>O.receiveFromClient(v,I,{playerIndex:x})})}function J(y){y&&(y.serverBridge=null)}let O={ENTITY_TYPES:go,ALL_ENTITY_TYPES:cn,CLIENT_SIGNAL_TARGETS:yo,get clock(){return s},get playerCount(){return h},get viewPlayerIndex(){return g},setClock(y){s=Number(y)||0},setPlayerCount(y){return h=at(y),g>h&&(g=h),h},setViewPlayerIndex(y){return g=$e(y,h),g},log(y,x){b(y,x)},defineVar(y,x,v={},{playerIndex:I}={}){let F=A(y,I),S=Ht(x);if(Object.prototype.hasOwnProperty.call(t[F],S))throw new Error(`custom variable already exists: ${F}.${S}`);let P=v.type?String(v.type):Lt(v.value??v.defaultValue);if(P&&!so.includes(P))throw new Error(`unsupported custom variable type: ${P}`);let D=v.value!==void 0?v.value:v.defaultValue!==void 0?v.defaultValue:null;return M(F,S,D,P),O.getVar(F,S)},getVar(y,x,{playerIndex:v}={}){let I=A(y,v),F=Ht(x);if(!Object.prototype.hasOwnProperty.call(t[I],F)){b("engine",`GetGlobalCustomVariableValue missing ${I}.${F}; returning nil (simulator policy)`);return}return t[I][F]},setVar(y,x,v,{notify:I=!0,type:F,playerIndex:S}={}){let P=A(y,S),D=Ht(x),B=F||i[P][D]?.type||Lt(v);if(B&&!so.includes(B)&&B!=="")throw new Error(`unsupported custom variable type: ${B}`);let le=v;if(!((B==="Int"||B===""&&typeof v=="number"&&Number.isInteger(v))&&(le=E(P,D,v).value,le===void 0)))return M(P,D,le,B),I&&U(P,D),le},listVars(y){let x=y?[A(y)]:["Level",...Array.from({length:h},(I,F)=>Kt(F+1)),...Array.from({length:h},(I,F)=>Ci(F+1))],v=[];for(let I of x)for(let F of Object.keys(t[I]))v.push({entityType:I,name:F,type:i[I][F]?.type||"",value:Se(t[I][F])});return v},receiveFromClient(y,x=[],{playerIndex:v}={}){let I=$e(v||g,h);w(I);let F=Ii(y),S={id:c++,direction:"inbound",name:F,params:ho(x),values:fo(x),time:s,playerIndex:I,from:Kt(I)};return n.push(S),q(S),S},sendToClient(y,x=[],{target:v="PlayerSelf",playerIndex:I}={}){let F=Ii(y),S=fn(v),D=$(S,I||g),B={id:c++,direction:"outbound",name:F,params:ho(x),values:fo(x),time:s,target:S,players:D,deliverAt:s+f/1e3,delivered:!1};return r.push(B),f===0?O.deliver(B):o.push(B),B},getLogic(){return Se(m)},setLogic(y){return m=Wt(y),O.getLogic()},deliver(y){if(!y||y.delivered)return;y.delivered=!0;let x=Array.isArray(y.players)&&y.players.length?y.players:$(y.target);for(let v of x){let I=l[v];I&&typeof I.sendClientSignal=="function"&&I.sendClientSignal(y.name,y.values)}},flush(y){y!==void 0&&(s=Number(y)||0);let x=[];for(let v=o.length-1;v>=0;v-=1)o[v].deliverAt<=s&&x.push(o.splice(v,1)[0]);x.sort((v,I)=>v.id-I.id);for(let v of x)O.deliver(v);return x},inbound(){return n.slice()},outbound(){return r.slice()},loadConfig(y){if(y!=null){if(typeof y!="object")throw new Error("server config must be an object");if(y.graph&&!Array.isArray(y.nodes))throw new Error("unsupported server node graph: v1 only accepts custom variables and signals");for(let x of y.nodes||[]){let v=xl(x);if(!Il.has(v))throw new Error(`unsupported server node: ${v||JSON.stringify(x)}. v1 only supports custom variables and signals`)}if(y.onlineLatencyMs!==void 0){let x=Number(y.onlineLatencyMs);if(!Number.isFinite(x)||x<0)throw new Error("onlineLatencyMs must be a non-negative finite number");f=x}y.playerCount!==void 0&&O.setPlayerCount(y.playerCount),y.viewPlayerIndex!==void 0&&O.setViewPlayerIndex(y.viewPlayerIndex),(y.logic!==void 0||y.serverLogic!==void 0)&&O.setLogic(y.logic??y.serverLogic);for(let x of y.vars||[]){let v=A(x.entityType),I=Ht(x.name);Object.prototype.hasOwnProperty.call(t[v],I)?O.setVar(v,I,x.value??x.defaultValue,{notify:!1,type:x.type}):O.defineVar(v,I,x)}}},attachRuntime(y,{playerIndex:x=1}={}){let v=$e(x,8);return l[v]&&l[v]!==y&&J(l[v]),l[v]=y||null,ee(l[v],v),O},attachRuntimes(y){O.detachRuntime();let x=Array.isArray(y)?y:[];for(let v=0;v<x.length&&v<8;v+=1)l[v+1]=x[v]||null,ee(l[v+1],v+1);return O},detachRuntime(){for(let y=1;y<=8;y+=1)J(l[y]),l[y]=null},snapshot(){let y=Kt(g),x=Ci(g),v={Level:{},PlayerSelf:{},AvatarSelf:{}};for(let I of Object.keys(t.Level))v.Level[I]={type:i.Level[I]?.type||"",value:Se(t.Level[I])};for(let I of Object.keys(t[y]))v.PlayerSelf[I]={type:i[y][I]?.type||"",value:Se(t[y][I])};for(let I of Object.keys(t[x]))v.AvatarSelf[I]={type:i[x][I]?.type||"",value:Se(t[x][I])};for(let I=1;I<=h;I+=1){let F=Kt(I),S=Ci(I);v[F]={},v[S]={};for(let P of Object.keys(t[F]))v[F][P]={type:i[F][P]?.type||"",value:Se(t[F][P])};for(let P of Object.keys(t[S]))v[S][P]={type:i[S][P]?.type||"",value:Se(t[S][P])}}return{clock:s,onlineLatencyMs:f,playerCount:h,viewPlayerIndex:g,logic:O.getLogic(),vars:v,inbound:n.map(I=>({id:I.id,name:I.name,params:Se(I.params),values:Se(I.values),time:I.time,playerIndex:I.playerIndex,from:I.from})),outbound:r.map(I=>({id:I.id,name:I.name,params:Se(I.params),values:Se(I.values),time:I.time,target:I.target,players:Array.isArray(I.players)?I.players.slice():[],deliverAt:I.deliverAt,delivered:!!I.delivered})),logs:a.map(I=>({source:"server",level:I.level,text:I.text,time:I.time}))}},reset(){for(let y of cn){for(let x of Object.keys(t[y]))delete t[y][x];for(let x of Object.keys(i[y]))delete i[y][x]}n.length=0,r.length=0,o.length=0,a.length=0,c=1,s=0},destroy(){O.detachRuntime(),O.reset()}};e.config&&O.loadConfig(e.config);for(let y of e.vars||[])O.defineVar(y.entityType,y.name,y);return O}var kl={container:"container",textbox:"textbox",image:"image",button:"button",cursor:"cursor",grid:"grid",reference:"reference",textwindow:"textwindow",keyhint:"keyhint",animation:"animation",fullscreen:"fullscreen"};function hn(e,t,i=null){let n=Ye(e.transformByPlatform,t),r={authoringId:e.id,kind:kl[e.kind]||"container",name:e.name,prefabIndex:e.guid||0,active:e.active!==!1,visible:e.visible!==!1,canControllerFocus:e.canControllerFocus===!0,anchoredPositionX:n.offset.x,anchoredPositionY:n.offset.y,sizeDeltaX:n.size.x,sizeDeltaY:n.size.y,anchorMinX:n.anchorMin.x,anchorMinY:n.anchorMin.y,anchorMaxX:n.anchorMax.x,anchorMaxY:n.anchorMax.y,pivotX:n.pivot.x,pivotY:n.pivot.y,localScaleX:n.scale.x,localScaleY:n.scale.y,localScaleZ:n.scale.z,localRotationX:n.rotation.x,localRotationY:n.rotation.y,localRotationZ:n.rotation.z,children:(e.children||[]).map(a=>hn(a,t,i))},o=i?.get(e.id);return o?.length&&(r.scripts=o.map(a=>{let l=Number(a.guid);return{path:a.path||a.id,source:a.source||"",...Number.isSafeInteger(l)&&l>0?{scriptMappingId:l}:{}}})),e.kind==="container"&&(r.isolateNavigation=e.isolateNavigation===!0,r.disableKeyEventPassthrough=e.disableKeyEventPassthrough===!0,r.disableCursorEventPassthrough=e.disableCursorEventPassthrough===!0,r.showCursor=e.showCursor===!0),(e.kind==="textbox"||e.kind==="textwindow")&&(r.text=e.text??"",r.fontSize=e.fontSize,r.adaptiveFontSize=e.adaptiveFontSize===!0,r.minimumFontSize=e.minimumFontSize,r.fontColor=e.fontColor,r.bgColor=e.bgColor,r.enableOutline=e.enableOutline!==!1,r.outlineColor=e.outlineColor,r.horizontalAlignment=e.horizontalAlignment||"Left",r.verticalAlignment=e.verticalAlignment||"Top",e.kind==="textwindow"&&(r.interactable=e.interactable!==!1,r.showScrollBar=e.showScrollBar!==!1)),e.kind==="image"&&(r.imageSource=e.imageSource,r.imageId=e.imageId??0,r.imageColor=e.imageColor,r.raycastTarget=e.raycastTarget===!0,r.enableMask=e.enableMask===!0,r.enableSoftEdge=e.enableSoftEdge===!0,r.softEdgeMode=e.softEdgeMode,r.softEdgeWidthX=e.softEdgeWidthX,r.softEdgeWidthY=e.softEdgeWidthY,r.horizontalSoftRange=e.horizontalSoftRange,r.verticalSoftRange=e.verticalSoftRange,r.enableFill=e.enableFill===!0,r.fillType=e.enableFill?e.fillType:"Unused",r.fillHorizontalType=e.fillHorizontalType,r.fillVerticalType=e.fillVerticalType,r.fillRadial90Type=e.fillRadial90Type,r.fillRadialType=e.fillRadialType,r.fillAmount=e.fillAmount,r.reverseMaskArea=e.reverseMaskArea===!0),e.kind==="button"&&(r.raycastTarget=e.raycastTarget!==!1,r.interactable=e.interactable!==!1,r.clickAudioId=e.clickAudioId,r.unavailableChildId=e.unavailableChildId??null,r.hoverChildId=e.hoverChildId??null,r.pressedChildId=e.pressedChildId??null,r.selectedChildId=e.selectedChildId??null),e.kind==="cursor"&&(r.raycastTarget=e.raycastTarget!==!1),e.kind==="reference"&&(r.referencedPrefabIndex=e.referencedPrefabId),e.kind==="grid"&&(r.itemPrefabIndex=e.itemPrefabId,r.raycastTarget=e.raycastTarget!==!1,r.interactable=e.interactable!==!1,r.showScrollBar=e.showScrollBar!==!1,r.scrollDirection=e.scrollDirection,r.layoutConstraint=e.layoutConstraint,r.layoutConstraintFixedCount=e.layoutConstraintFixedCount,r.cellSizeX=e.cellSizeX,r.cellSizeY=e.cellSizeY,r.spacingX=e.spacingX,r.spacingY=e.spacingY,r.padding1X=e.padding1X,r.padding1Y=e.padding1Y,r.padding2X=e.padding2X,r.padding2Y=e.padding2Y,r.previewCount=e.previewCount),e.kind==="keyhint"&&(r.keyboardKeyCode=e.keyboardKeyCode,r.controllerKeyCode=e.controllerKeyCode),(e.kind==="animation"||e.kind==="fullscreen")&&(r.raycastTarget=!1,r.animationId=e.animationId,r.playSoundEffect=e.playSoundEffect,e.kind==="animation"&&(r.layer=e.layer)),r}function mn(e,t=[],i=""){let n=i&&ie[i]?i:e.canvasId,r=ie[n],o=Gt(e),a=new Map;for(let c of t){if(!c.controlId)continue;let s=a.get(c.controlId)||[];s.push(c),a.set(c.controlId,s)}let l=e.meta?.assetType==="client-control-template"?(e.root.children||[]).map(c=>hn(c,n,a)):[];return{canvasId:n,platform:r.platform,device:r.luaDevice,canvasWidth:r.width,canvasHeight:r.height,root:hn(o,n,a),templates:l}}var xi="qxqy-autotest";var st=.03333333333333333,_l=new Set(["pointer","key","click","pause","resume","serverSet","serverSend","view"]),Tl=new Set(["log","control","var","signal","tree","lua"]);function jt(e,t){let i=Number(e);if(!Number.isFinite(i))throw new Error(`${t} must be a finite number`);return i}function pn(e){return JSON.parse(JSON.stringify(e??null))}function Ei(e,t){if(!e||typeof e!="object")throw new Error(`events[${t}] must be an object`);let i=String(e.kind||e.do||"");if(!_l.has(i))throw new Error(`unsupported event kind: ${i||"(empty)"}`);let n=e.payload&&typeof e.payload=="object"?{...e.payload}:{};if(i==="pointer")!n.type&&e.type&&(n.type=e.type),n.x===void 0&&(n.x=e.x),n.y===void 0&&(n.y=e.y),n.x=jt(n.x,"pointer.x"),n.y=jt(n.y,"pointer.y"),n.type=String(n.type||"click");else if(i==="key"){if(n.typeName=String(n.typeName||n.key||e.typeName||e.key||""),!n.typeName)throw new Error("key event requires typeName")}else if(i==="click"){if(n.name=String(n.name||e.name||""),!n.name)throw new Error("click event requires control name")}else if(i==="serverSet"){if(n.entityType=String(n.entityType||e.entityType||""),n.name=String(n.name||e.name||""),n.value===void 0&&(n.value=e.value),n.value===void 0&&(n.value=null),!n.entityType||!n.name)throw new Error("serverSet requires entityType and name")}else if(i==="serverSend"){if(n.name=String(n.name||e.name||""),n.params=Array.isArray(n.params)?n.params:Array.isArray(e.params)?e.params:[],n.target=String(n.target||e.target||"PlayerSelf"),!n.name)throw new Error("serverSend requires signal name")}else if(i==="view"&&(n.playerIndex=Number(n.playerIndex||n.viewPlayerIndex||e.playerIndex||e.viewPlayerIndex||0),!Number.isInteger(n.playerIndex)||n.playerIndex<1))throw new Error("view event requires playerIndex 1-8");return{t:jt(e.t??0,"event.t"),source:String(e.source||"user"),kind:i,payload:n}}function gn(e,t){if(!e||typeof e!="object")throw new Error(`asserts[${t}] must be an object`);let i=String(e.kind||(e.check?"log":""));if(!Tl.has(i))throw new Error(`unsupported assert kind: ${i||"(empty)"}`);let n={kind:i};if(e.at!==void 0&&(n.at=jt(e.at,"assert.at")),i==="log"){if(n.contains=String(e.contains||e.check||e.text||""),n.source=e.source==="server"?"server":"client",e.level&&(n.level=String(e.level)),!n.contains)throw new Error("log assert requires contains")}else if(i==="control"){if(n.id=e.id?String(e.id):"",n.name=e.name?String(e.name):"",n.field=String(e.field||""),!n.field)throw new Error("control assert requires field");if(!n.id&&!n.name)throw new Error("control assert requires id or name");if(!Object.prototype.hasOwnProperty.call(e,"equals"))throw new Error("control assert requires equals");n.equals=pn(e.equals)}else if(i==="var"){if(n.entityType=String(e.entityType||""),n.name=String(e.name||""),!n.entityType||!n.name)throw new Error("var assert requires entityType and name");if(!Object.prototype.hasOwnProperty.call(e,"equals"))throw new Error("var assert requires equals");n.equals=pn(e.equals)}else if(i==="signal"){if(n.direction=e.direction==="outbound"?"outbound":"inbound",n.name=String(e.name||""),!n.name)throw new Error("signal assert requires name");e.values!==void 0&&(n.values=pn(e.values))}else if(i==="tree"){if(n.name=String(e.name||""),n.exists=e.exists!==!1,!n.name)throw new Error("tree assert requires name")}else if(i==="lua"&&(n.source=String(e.source||""),!n.source.trim()))throw new Error("lua assert requires source");return n}function Co(e){let t=0,i=[],n=[];for(let r of e){if(!r||typeof r!="object")throw new Error("queue step must be an object");if(r.do!=="start"){if(r.do==="step"){t+=jt(r.dt??st,"step.dt");continue}if(r.do==="pointer"||r.do==="key"||r.do==="click"||r.do==="pause"||r.do==="resume"||r.do==="serverSet"||r.do==="serverSend"||r.do==="view"){i.push(Ei({...r,kind:r.do,t},i.length));continue}if(r.assert||r.check||r.kind){n.push(gn({...r.assert||r,at:r.at??t},n.length));continue}throw new Error(`unsupported queue step: ${JSON.stringify(r)}`)}}return{events:i,asserts:n,dt:st}}function qt(e){if(Array.isArray(e)){let n=Co(e);return{format:xi,version:1,name:"",dt:n.dt,events:n.events,asserts:n.asserts}}if(!e||typeof e!="object")throw new Error("autotest case must be an object or step array");if(Array.isArray(e.queue)||Array.isArray(e.steps)){let n=Co(e.queue||e.steps);return{format:xi,version:1,name:String(e.name||""),dt:Number(e.dt)>0?Number(e.dt):n.dt,events:n.events,asserts:n.asserts}}let t=(e.events||[]).map((n,r)=>Ei(n,r)),i=(e.asserts||[]).map((n,r)=>gn(n,r));return t.sort((n,r)=>n.t-r.t||0),{format:xi,version:1,name:String(e.name||""),dt:Number(e.dt)>0?Number(e.dt):st,playerCount:Number(e.playerCount)>0?Number(e.playerCount):1,events:t,asserts:i}}function Io(e,t={}){let i=(e||[]).map((n,r)=>Ei(n,r));return{format:xi,version:1,name:String(t.name||""),dt:Number(t.dt)>0?Number(t.dt):st,playerCount:Number(t.playerCount)>0?Number(t.playerCount):1,events:i,asserts:(t.asserts||[]).map((n,r)=>gn(n,r))}}function wo(e,t,i){if(!e)return null;let n=Ei({...t,t:t.t??i??0},e.events.length);return e.events.push(n),n}var Rl=Object.freeze(Object.values(ie).map(e=>Object.freeze({id:e.id,label:e.label,platform:e.platform,width:e.width,height:e.height})));function Sn(e){let t=ye({width:e.runtime.canvasWidth,height:e.runtime.canvasHeight}),i=new Map;function n(r,o,a){let l=Ne(o,r);l.activeInHierarchy=a&&r.active!==!1,i.set(r.Id,l);let c=l.activeInHierarchy;for(let s of r.children)n(s,l,c)}for(let r of e.runtime.roots)n(r,t,!0);return i}function Pl(e,t=Sn(e)){let i=new Map;function n(r,o){let a=t.get(r.Id);if(!a)return;let l=$t(o,a,r);i.set(r.Id,l);for(let c of r.children)n(c,l)}for(let r of e.runtime.roots)n(r,bt());return i}function Eo(e,t){let i=t.get(e.Id);return{id:e.Id,prefabId:e.prefabIndex,authoringId:e.authoringId,name:e.name,kind:e.kind,typeofName:e.typeofName,instantiated:!e.authoringId,active:!!e.active,visible:!!e.visible,activeInHierarchy:!!i?.activeInHierarchy,raycastTarget:e.raycastTarget!==!1,interactable:e.interactable!==!1,pressed:e.pressed===!0,anchoredPositionX:e.anchoredPositionX,anchoredPositionY:e.anchoredPositionY,sizeDeltaX:e.sizeDeltaX,sizeDeltaY:e.sizeDeltaY,localScaleX:e.localScaleX,localScaleY:e.localScaleY,localScaleZ:e.localScaleZ,localRotationZ:e.localRotationZ,text:e.kind==="textbox"||e.kind==="textwindow"?e.text??"":null,fontSize:e.kind==="textbox"||e.kind==="textwindow"?e.fontSize:null,fontColor:e.kind==="textbox"||e.kind==="textwindow"?e.fontColor:null,bgColor:e.kind==="textbox"||e.kind==="textwindow"?e.bgColor:null,enableOutline:e.kind==="textbox"||e.kind==="textwindow"?e.enableOutline===!0:null,outlineColor:e.kind==="textbox"||e.kind==="textwindow"?e.outlineColor:null,imageId:e.kind==="image"?e.imageId??0:null,primitive:e.kind==="image"?gt[e.imageId]||"missing":null,imageColor:e.kind==="image"?e.imageColor:null,enableMask:e.kind==="image"?e.enableMask===!0:null,enableSoftEdge:e.kind==="image"?e.enableSoftEdge===!0:null,softEdgeMode:e.kind==="image"?e.softEdgeMode:null,softEdgeWidthX:e.kind==="image"?e.softEdgeWidthX:null,softEdgeWidthY:e.kind==="image"?e.softEdgeWidthY:null,horizontalSoftRange:e.kind==="image"?e.horizontalSoftRange:null,verticalSoftRange:e.kind==="image"?e.verticalSoftRange:null,enableFill:e.kind==="image"?e.enableFill===!0:null,fillType:e.kind==="image"?e.fillType:null,fillHorizontalType:e.kind==="image"?e.fillHorizontalType:null,fillVerticalType:e.kind==="image"?e.fillVerticalType:null,fillRadial90Type:e.kind==="image"?e.fillRadial90Type:null,fillRadialType:e.kind==="image"?e.fillRadialType:null,reverseMaskArea:e.kind==="image"?e.reverseMaskArea===!0:null,fillAmount:e.kind==="image"?e.fillAmount:null,box:i?{left:i.left,bottom:i.bottom,width:i.width,height:i.height}:null,children:e.children.map(n=>Eo(n,t))}}function Ml(){return{pointerDownControl:null,pointerDownPosition:null,pointerLastPosition:null,pointerDragging:!1,pointerHoverControl:null,hoveredControl:null,selectedControl:null,stateRestores:new Map,viewCache:null}}function Nl(e,t,i,n){let r=Xt({canvasWidth:e.canvasWidth,canvasHeight:e.canvasHeight,device:e.device,...n?{language:n}:{}});for(let o of[...e.templates||[],...t?.templates||[]])Number.isSafeInteger(o.prefabIndex)&&o.prefabIndex>0&&r.registerTemplate(o.prefabIndex,o);for(let o of i){let a=o.path||o.id,l=o.source||"";a&&l&&r.registerScriptFile(a,l)}return r}var Fl=["pointerDownControl","pointerDownPosition","pointerLastPosition","pointerDragging","pointerHoverControl","hoveredControl","selectedControl","stateRestores","viewCache"];function Ol(e){Object.defineProperty(e,"runtime",{configurable:!0,enumerable:!0,get(){return e.runtimes[e.viewPlayerIndex-1]}});for(let t of Fl)Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){return e.views[e.viewPlayerIndex-1][t]},set(i){e.views[e.viewPlayerIndex-1][t]=i}})}function Ao(e,{templatesProject:t=null,scripts:i=[],sceneScripts:n=null,templateScripts:r=null,serverConfig:o=null,canvasId:a="",playerCount:l=1,viewPlayerIndex:c=1,language:s=""}={}){let f=n||i,m=r||i,h=mn(e,f,a),g=t?mn(t,m,a):null,b=at(l),w=$e(c,b),M=So({playerCount:b,viewPlayerIndex:w});o&&M.loadConfig({...o,playerCount:b,viewPlayerIndex:w});let E=[];for(let $=0;$<b;$+=1)E.push(Nl(h,g,i,s));M.attachRuntimes(E);for(let $ of E)$.addRoot(h.root);let A={runtimes:E,views:E.map(()=>Ml()),playerCount:b,viewPlayerIndex:w,server:M,compiled:h,mountError:E.find($=>$.mountErrors[0])?.mountErrors[0]||null,debugPaused:!1,history:{events:[]},recording:!0};Ol(A);let U=A.viewPlayerIndex;for(let $=1;$<=b;$+=1)A.viewPlayerIndex=$,Ll(A);return A.viewPlayerIndex=U,A}function Cn(e,t){if(!e)throw new Error("play session has not started");let i=$e(t,e.playerCount);return i===e.viewPlayerIndex||(He(e,{kind:"view",payload:{playerIndex:i}}),e.viewPlayerIndex=i,e.viewCache=null,e.server&&e.server.setViewPlayerIndex(i)),i}function He(e,t){!e?.recording||!e.history||wo(e.history,{...t,source:t.source||"user"},e.runtime.clock.time)}function $l(e){return e?.history?.events||[]}var In=new Set(["image","textbox","textwindow","button"]);function Gl(e,t){let i=Je(t,e.centerX,e.centerY);return{centerX:i.x,centerY:i.y,scaleX:Math.hypot(t.a,t.b),scaleY:Math.hypot(t.c,t.d),rotationZ:Math.atan2(t.b,t.a)*180/Math.PI,matrix:{a:t.a,b:t.b,c:t.c,d:t.d,tx:i.x,ty:i.y}}}function ut(e){return typeof e=="string"?e:e?.Name}function ko(e){return{fillType:ut(e.fillType),fillHorizontalType:ut(e.fillHorizontalType),fillVerticalType:ut(e.fillVerticalType),fillAmount:e.fillAmount}}function Dl(e,t,i){let n=Math.abs(t.width*i.scaleX),r=Math.abs(t.height*i.scaleY),o={id:e.Id,kind:e.kind,name:e.name,left:i.centerX-n/2,bottom:i.centerY-r/2,width:n,height:r,sourceWidth:t.width,sourceHeight:t.height,rotationZ:i.rotationZ,matrix:i.matrix,pressed:e.pressed===!0};return e.kind==="image"&&(o.primitive=gt[e.imageId]||"missing",o.imageColor=e.imageColor,o.imageId=e.imageId,Object.assign(o,ko(e))),(e.kind==="textbox"||e.kind==="textwindow")&&(o.text=e.text??"",o.fontSize=e.fontSize,o.fontColor=e.fontColor,o.bgColor=e.bgColor,o.enableOutline=e.enableOutline===!0,o.outlineColor=e.outlineColor,o.horizontalAlignment=ut(e.horizontalAlignment),o.verticalAlignment=ut(e.verticalAlignment)),o}function zl(e,t=Sn(e)){let i=[],n=Pl(e,t);function r(o){let a=t.get(o.Id);if(!a||o.visible===!1||!a.activeInHierarchy)return;let l=n.get(o.Id);if(!l)return;let c=Gl(a,l);In.has(o.kind)&&i.push(Dl(o,a,c));let s=o.children||[];for(let f=s.length-1;f>=0;f-=1)r(s[f])}for(let o of e.runtime.roots)r(o);return i}function Vl(e,t){let i={kind:e.kind,name:e.name,sourceWidth:t.width,sourceHeight:t.height,pressed:e.pressed===!0};return e.kind==="image"&&(i.primitive=gt[e.imageId]||"missing",i.imageColor=e.imageColor,i.imageId=e.imageId,Object.assign(i,ko(e))),(e.kind==="textbox"||e.kind==="textwindow")&&(i.text=e.text??"",i.fontSize=e.fontSize,i.fontColor=e.fontColor,i.bgColor=e.bgColor,i.enableOutline=e.enableOutline===!0,i.outlineColor=e.outlineColor,i.horizontalAlignment=ut(e.horizontalAlignment),i.verticalAlignment=ut(e.verticalAlignment)),i}function Yl(e,t,i){let n=Mi(e,t),r=Je(n,e.centerX,e.centerY);return{a:n.a,b:n.b,c:n.c,d:n.d,tx:r.x-(i?i.centerX:0),ty:r.y-(i?i.centerY:0)}}function _o(e){let t=e.matrix;return[e.parent,e.z,e.group?1:0,t.a,t.b,t.c,t.d,t.tx,t.ty,e.kind,e.name,e.sourceWidth,e.sourceHeight,e.pressed,e.primitive,e.imageColor,e.imageId,e.fillType,e.fillHorizontalType,e.fillVerticalType,e.fillAmount,e.text,e.fontSize,e.fontColor,e.bgColor,e.enableOutline,e.outlineColor,e.horizontalAlignment,e.verticalAlignment].join(" ")}function To(e,t,i,n,r,o){return{id:e.Id,parent:t,z:r,group:o>=16,matrix:Yl(n,e,i),...Vl(e,n)}}function Ul(e){let t=ye({width:e.runtime.canvasWidth,height:e.runtime.canvasHeight}),i=new Set,n=new Map,r=new Map;function o(c,s,f){let m=Ne(s,c);if(m.activeInHierarchy=f&&c.active!==!1,r.set(c.Id,m),c.visible===!1||!m.activeInHierarchy)return!1;let h=c.children||[],g=In.has(c.kind),b=0;for(let w=0;w<h.length;w+=1)o(h[w],m,m.activeInHierarchy)&&(g=!0,b+=1);return g?(i.add(c.Id),n.set(c.Id,b),!0):!1}function a(c,s,f,m){if(!i.has(c.Id))return;let h=r.get(c.Id);l.push(To(c,s,f,h,m,n.get(c.Id)||0));let g=c.children||[];for(let b=0;b<g.length;b+=1)a(g[b],c.Id,h,b)}let l=[];for(let c=0;c<e.runtime.roots.length;c+=1)o(e.runtime.roots[c],t,!0),a(e.runtime.roots[c],null,null,c);return{nodes:l,childCounts:n}}function vn(e){let t=e._playChildDirty===!0||e._playDeepDirty===!0;if(e._playDirty=!1,e._playChildDirty=!1,e._playDeepDirty=!1,!t)return;let i=e.children;for(let n=0;n<i.length;n+=1)vn(i[n])}function Bl(e,t){let i=ye({width:e.runtime.canvasWidth,height:e.runtime.canvasHeight}),n=[],r=[],o=t.count,a=e.runtime._playRemoved||[];for(let s=0;s<a.length;s+=1){let f=a[s];t.fingerprints.has(f)&&(r.push(f),t.fingerprints.delete(f),t.childCounts.delete(f),o-=1)}e.runtime._playRemoved=[];function l(s){t.fingerprints.has(s.Id)&&(r.push(s.Id),t.fingerprints.delete(s.Id),t.childCounts.delete(s.Id),o-=1);let f=s.children;for(let m=0;m<f.length;m+=1)l(f[m])}function c(s,f,m,h,g,b){let w=b||s._playDeepDirty===!0,M=w||s._playDirty===!0,E=w||s._playChildDirty===!0;if(!M&&!E)return;if(!(g&&s.active!==!1)||s.visible===!1){l(s);return}let U=Ne(f,s),$=t.childCounts.get(s.Id)||0;if(E){$=0;let x=s.children;for(let v=0;v<x.length;v+=1)c(x[v],U,s.Id,v,!0,w),t.fingerprints.has(x[v].Id)&&($+=1)}if(!(In.has(s.kind)||$>0)){t.fingerprints.has(s.Id)&&(r.push(s.Id),t.fingerprints.delete(s.Id),t.childCounts.delete(s.Id),o-=1);return}let ee=t.childCounts.get(s.Id);t.childCounts.set(s.Id,$);let J=$>=16!=(ee||0)>=16;if(!M&&!J&&t.fingerprints.has(s.Id))return;let O=To(s,m,f===i?null:f,U,h,$),y=_o(O);t.fingerprints.get(O.id)!==y&&(t.fingerprints.has(O.id)||(o+=1),t.fingerprints.set(O.id,y),n.push(O))}for(let s=0;s<e.runtime.roots.length;s+=1)c(e.runtime.roots[s],i,null,s,!0,!1);return t.count=o,{changed:n,removed:r,count:o}}function Xl(e,t){let i=e.viewCache||(e.viewCache={rev:0,fingerprints:new Map,childCounts:new Map,count:0}),n=Number(t);if(!(Number.isFinite(n)&&n===i.rev&&i.fingerprints.size>0)){let{nodes:c,childCounts:s}=Ul(e);i.rev+=1,i.fingerprints=new Map(c.map(f=>[f.id,_o(f)])),i.childCounts=s,i.count=c.length;for(let f of e.runtime.roots)vn(f);return{format:"tree-v1",revision:i.rev,reset:!0,count:c.length,nodes:c}}let{changed:o,removed:a,count:l}=Bl(e,i);i.rev+=1;for(let c of e.runtime.roots)vn(c);return{format:"tree-v1",revision:i.rev,reset:!1,count:l,changed:o,removed:a}}function wn(e,{inspect:t=!1,view:i=!1,paint:n=!1,sceneRev:r,compact:o=!1}={}){let a=e.runtime,l=e.compiled,[c,s]=[a.canvasWidth,a.canvasHeight];e.server&&e.server.setClock(a.clock.time);let f=o?a.logs.slice(-100):a.logs,m=$l(e),h=e.server?e.server.snapshot():{vars:{},inbound:[],outbound:[],logs:[]};o&&(h.inbound=h.inbound.slice(-100),h.outbound=h.outbound.slice(-100),h.logs=h.logs.slice(-100));let g={canvasId:l.canvasId,platform:l.platform,device:a.device,canvasWidth:c,canvasHeight:s,canvasPresets:Rl,playerCount:e.playerCount||1,viewPlayerIndex:e.viewPlayerIndex||1,players:Array.from({length:e.playerCount||1},(b,w)=>({index:w+1,label:`\u73A9\u5BB6${w+1}`,entityType:`Player${w+1}`})),time:a.clock.time,frame:a.clock.frame,paused:!!e.debugPaused,levelTimePaused:!!a.clock.paused,mountError:e.mountError||a.mountErrors[0]||null,logs:f.map(b=>({source:"client",level:b.level,text:b.text,time:b.time})),tree:[],paint:[],scene:null,server:h,history:(o?m.slice(-100):m).map(b=>({t:b.t,source:b.source||"user",kind:b.kind,payload:b.payload||{}}))};if(t||n){let b=Sn(e);t&&(g.tree=a.roots.map(w=>Eo(w,b))),n&&(g.paint=zl(e,b))}return i&&(g.scene=Xl(e,r)),yt(g),g}function Ai(e,t=1/30){let i=e.runtimes||(e.runtime?[e.runtime]:[]);for(let n of i)n.step(t);e.server&&(e.server.setClock(e.runtime.clock.time),e.server.flush())}function xn(e,t){He(e,{kind:"key",payload:{typeName:String(t)}}),e.runtime.injectKey(t)}function Kl(e,t){let i=null;for(let n of e.runtime.roots)Pe(n,r=>{!i&&r.name===t&&(i=r)});return i}function En(e,t){He(e,{kind:"click",payload:{name:String(t)}});let i=Kl(e,t);i&&An(i)&&(i.kind==="button"||i.kind==="cursor")&&i.SimulateCursorClick()}function Hl(e,t){return!e||!t?null:e.children.find(i=>i.authoringId===t||i.Id===t)||null}var Ro={unavailable:"unavailableChildId",hover:"hoverChildId",pressed:"pressedChildId",selected:"selectedChildId"};function Po(e,t){let i=[];for(let[n,r]of Object.entries(Ro)){let o=t[r]?Hl(t,t[r]):null;o&&i.push({state:n,child:o})}return i}function Ll(e){for(let t of e.runtime.roots)Pe(t,i=>{if(i.kind==="button"){for(let{child:n}of Po(e,i))e.stateRestores.has(n.Id)||e.stateRestores.set(n.Id,{child:n,active:n.active,visible:n.visible}),n.active=!0,n.visible=!1,typeof n.markPlayDirty=="function"&&n.markPlayDirty(!0);Zt(e,i)}})}function Zt(e,t){if(!t||t.kind!=="button")return;let i=null;t.interactable===!1?i="unavailable":t.pressed===!0?i="pressed":e.hoveredControl===t?i="hover":e.selectedControl===t&&(i="selected");for(let n of Po(e,t))n.child.active=!0,n.child.visible=n.state===i,typeof n.child.markPlayDirty=="function"&&n.child.markPlayDirty(!0)}function yn(e){if(!e)return null;let t=e.parent;return t?.kind==="button"&&Object.values(Ro).map(n=>t[n]).filter(Boolean).includes(e.authoringId)?t:e}function An(e){return e.kind==="button"?e.raycastTarget!==!1&&e.interactable!==!1:e.kind==="cursor"||e.kind==="grid"?e.raycastTarget!==!1:e.kind==="textwindow"?e.interactable!==!1:e.raycastTarget===!0}function Mo(e){return e.kind==="container"||e.kind==="grid"||e.kind==="textwindow"||e.kind==="reference"||e.kind==="button"}function No(e,t){let i=e.Id,n=t.get(i);if(n!==void 0)return n;let r=An(e);if(!r&&Mo(e)){let o=e.children;for(let a=0;a<o.length;a+=1)if(No(o[a],t)){r=!0;break}}return t.set(i,r),r}function bn(e,t,i){let n=ye({width:e.runtime.canvasWidth,height:e.runtime.canvasHeight}),r=new Map;function o(l,c,s,f){if(!f||l.active===!1||l.visible===!1||!No(l,r))return null;let m=Ne(c,l),h=$t(s,m,l),g=si(h);if(!g)return null;let b=Je(g,t,i);if(b.x<m.left||b.x>m.right||b.y<m.bottom||b.y>m.top)return null;if(Mo(l))for(let w=0;w<l.children.length;w+=1){let M=o(l.children[w],m,h,!0);if(M)return M}return An(l)?l:null}let a=bt();for(let l=e.runtime.roots.length-1;l>=0;l-=1){let c=o(e.runtime.roots[l],n,a,!0);if(c)return c}return null}function Jt(e,t,i,{dragging:n=!1,press:r=null,previous:o=null}={}){let a=r||{x:t,y:i},l=o||{x:t,y:i};return e.runtime.makeCursorEventData({x:t,y:i,pressX:a.x,pressY:a.y,deltaX:t-l.x,deltaY:i-l.y,dragging:n})}function xo(e,t,i){t.pressed=i,typeof t.markPlayDirty=="function"&&t.markPlayDirty(),Zt(e,t)}function Qt(e,t,i,n,r={}){let o=Number(i),a=Number(n);if(!Number.isFinite(o)||!Number.isFinite(a))throw new Error("pointer coordinates must be finite");if(e.runtime.cursor.x=o,e.runtime.cursor.y=a,r.silent||He(e,{kind:"pointer",payload:{type:t,x:o,y:a}}),t==="move"){let l=e.pointerLastPosition||{x:o,y:a},c=e.pointerHoverControl,s=yn(bn(e,o,a)),f=Jt(e,o,a,{previous:l});c&&c!==s&&e.runtime.injectCursor(c,"CursorExit",f),s&&c!==s&&e.runtime.injectCursor(s,"CursorEnter",f),e.pointerHoverControl=s;let m=e.hoveredControl;e.hoveredControl=s?.kind==="button"?s:null,m&&m!==e.hoveredControl&&Zt(e,m),e.hoveredControl&&Zt(e,e.hoveredControl);let h=e.pointerDownControl;if(h){let g=e.pointerDownPosition||l,b=o!==l.x||a!==l.y;!e.pointerDragging&&b&&(e.runtime.injectCursor(h,"CursorBeginDrag",Jt(e,o,a,{press:g,previous:l,dragging:!1})),e.pointerDragging=!0),e.pointerDragging&&e.runtime.injectCursor(h,"CursorDrag",Jt(e,o,a,{press:g,previous:l,dragging:!0}))}return e.pointerLastPosition={x:o,y:a},s}if(t==="down"){let l=yn(bn(e,o,a));return e.pointerDownControl=l,e.pointerDownPosition={x:o,y:a},e.pointerLastPosition={x:o,y:a},e.pointerDragging=!1,l&&(xo(e,l,!0),e.runtime.injectCursor(l,"CursorDown",Jt(e,o,a))),l}if(t==="up"){let l=e.pointerDownControl,c=yn(bn(e,o,a));if(l){let s=Jt(e,o,a,{press:e.pointerDownPosition,previous:e.pointerLastPosition,dragging:e.pointerDragging});if(e.runtime.injectCursor(l,"CursorUp",s),e.pointerDragging)e.runtime.injectCursor(l,"CursorEndDrag",s);else if(c===l){e.runtime.injectCursor(l,"CursorClick",s);let f=e.selectedControl;e.selectedControl=l.kind==="button"?l:null,f&&f!==e.selectedControl&&Zt(e,f)}xo(e,l,!1)}return e.pointerDownControl=null,e.pointerDownPosition=null,e.pointerLastPosition={x:o,y:a},e.pointerDragging=!1,c}if(t==="click")return Qt(e,"down",o,a,{silent:!0}),Qt(e,"up",o,a,{silent:!0});throw new Error(`unknown pointer type ${t}`)}function kn(e,t,i,n){if(!e?.server)throw new Error("play session has no server");return He(e,{kind:"serverSet",payload:{entityType:t,name:i,value:n,playerIndex:e.viewPlayerIndex}}),e.server.setVar(t,i,n,{playerIndex:e.viewPlayerIndex})}function Fo(e,t,i){if(!e?.server)throw new Error("play session has no server");let n=e.server.getVar(t,i,{playerIndex:e.viewPlayerIndex});return n===void 0?null:n}function _n(e,t,i=[],n="PlayerSelf"){if(!e?.server)throw new Error("play session has no server");return He(e,{kind:"serverSend",payload:{name:t,params:i,target:n,playerIndex:e.viewPlayerIndex}}),e.server.sendToClient(t,i,{target:n,playerIndex:e.viewPlayerIndex})}function ki(e){return{snapshot:t=>wn(e,t),step:t=>Ai(e,t),pointer:(t,i,n)=>Qt(e,t,i,n),key:t=>xn(e,t),click:t=>En(e,t),view:t=>Cn(e,t),pause:()=>{He(e,{kind:"pause",payload:{}}),e.debugPaused=!0},resume:()=>{He(e,{kind:"resume",payload:{}}),e.debugPaused=!1},serverSet:(t,i,n)=>kn(e,t,i,n),serverSend:(t,i,n)=>_n(e,t,i,n)}}function Tn(e){e?.server&&e.server.destroy();let t=e?.runtimes||(e?.runtime?[e.runtime]:[]);for(let i of t)i.destroy()}function Rn(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Oo(e,t){for(let i of e||[])t(i),i.children?.length&&Oo(i.children,t)}function Pn(e,{id:t,name:i}){let n=null;return Oo(e,r=>{n||(t&&String(r.id)===String(t)||!t&&i&&r.name===i)&&(n=r)}),n}function Wl(e,t){if(e){if(Object.prototype.hasOwnProperty.call(e,t))return e[t];if(e.box&&Object.prototype.hasOwnProperty.call(e.box,t))return e.box[t]}}function jl(e){return{var(t,i){return e.server?.vars?.[t]?.[i]?.value??null},logs(){return(e.logs||[]).map(t=>t.text)},logContains(t){return(e.logs||[]).some(i=>String(i.text||"").includes(String(t)))},serverLogs(){return(e.server?.logs||e.serverLogs||[]).map(t=>t.text)},serverLogContains(t){return(e.server?.logs||e.serverLogs||[]).some(i=>String(i.text||"").includes(String(t)))},control(t){let i=Pn(e.tree,{name:String(t)});return i?{id:i.id,name:i.name,kind:i.kind,active:i.active,visible:i.visible,pressed:i.pressed,text:i.text,interactable:i.interactable}:null},signals(t){let i=t==="outbound"?"outbound":"inbound";return(e.server?.[i]||[]).map(n=>({name:n.name,values:n.values}))}}}function ql(e,t){if(e.kind==="log"){let i=e.source==="server"?t.server?.logs||t.serverLogs||[]:t.logs||[];return i.some(r=>e.level&&r.level!==e.level?!1:String(r.text||"").includes(e.contains))?{ok:!0,actual:e.contains}:{ok:!1,actual:i.map(r=>r.text).slice(-8),expected:e.contains}}if(e.kind==="control"){let i=Pn(t.tree,e);if(!i)return{ok:!1,actual:null,expected:e.equals,message:`control not found: ${e.id||e.name}`};let n=Wl(i,e.field);return Rn(n,e.equals)?{ok:!0,actual:n}:{ok:!1,actual:n,expected:e.equals}}if(e.kind==="var"){let i=t.server?.vars?.[e.entityType],r=!i||!Object.prototype.hasOwnProperty.call(i,e.name)?null:i[e.name].value;return Rn(r,e.equals)?{ok:!0,actual:r}:{ok:!1,actual:r,expected:e.equals}}if(e.kind==="signal"){let i=e.direction==="outbound"?t.server?.outbound||[]:t.server?.inbound||[],n=i.find(r=>r.name===e.name&&(e.values===void 0||Rn(r.values,e.values)));return n?{ok:!0,actual:n.values}:{ok:!1,actual:i.map(r=>({name:r.name,values:r.values})),expected:{name:e.name,values:e.values??null}}}if(e.kind==="tree"){let i=!!Pn(t.tree,{name:e.name});return i===e.exists?{ok:!0,actual:i}:{ok:!1,actual:i,expected:e.exists}}return{ok:!1,message:`unsupported assert kind ${e.kind}`}}function Jl(e,t){let i=Xt();try{return i.evalQueryScript(e,jl(t)),{ok:!0,actual:!0}}catch(n){return{ok:!1,message:n?.message||String(n)}}finally{i.destroy()}}function $o(e,t){return e.kind==="lua"?Jl(e.source,t):ql(e,t)}function Zl(e,t){let i=t>0?t:st;return Math.round((e+i)*1e9)/1e9}function Ql(e,t){let i=t.payload||{};if(t.kind==="pointer")e.pointer(i.type,i.x,i.y);else if(t.kind==="key")e.key(i.typeName);else if(t.kind==="click")e.click(i.name);else if(t.kind==="pause")e.pause();else if(t.kind==="resume")e.resume();else if(t.kind==="serverSet")e.serverSet(i.entityType,i.name,i.value);else if(t.kind==="serverSend")e.serverSend(i.name,i.params,i.target);else if(t.kind==="view")e.view(i.playerIndex);else throw new Error(`unsupported event kind: ${t.kind}`)}function es(e,t){let i=$o(e,t);return{kind:e.kind,at:Number(e.at||0),ok:!!i.ok,actual:i.actual??null,expected:i.expected??null,message:i.message||""}}function Go(e,t){let i=qt(t),n=i.events.slice().sort((E,A)=>E.t-A.t),r=i.asserts.slice(),o=i.dt||st,a=n.reduce((E,A)=>Math.max(E,A.t),0),l=r.reduce((E,A)=>Math.max(E,Number(A.at||0)),0),c=Math.max(a,l),s=0,f=[],m=0,h=r.some(E=>E.kind==="control"||E.kind==="tree"||E.kind==="lua"),g=e.snapshot({inspect:h}),b=()=>{for(;s<n.length&&n[s].t<=m+1e-9;)Ql(e,n[s]),s+=1,g=e.snapshot({inspect:h})},w=()=>{for(let E of r)if(!E._done&&Number(E.at||0)<=m+1e-9){let A=es(E,g);if(f.push(A),E._done=!0,!A.ok)return{passed:!1,failedAt:m,frame:g.frame||0,results:f,snapshot:g}}return null};b();let M=w();if(M)return Mn(i,M);for(;m+1e-9<c;){e.step(o),m=Zl(m,o),g=e.snapshot({inspect:h}),b();let E=w();if(E)return Mn(i,E)}return Mn(i,{passed:f.every(E=>E.ok),failedAt:null,frame:g.frame||0,results:f,snapshot:g})}function Mn(e,t){return G({format:e.format,name:e.name,passed:t.passed,failedAt:t.failedAt,frame:t.frame,results:t.results,snapshot:{time:t.snapshot?.time??0,frame:t.snapshot?.frame??0,logs:t.snapshot?.logs||[],serverLogs:t.snapshot?.serverLogs||t.snapshot?.server?.logs||[],server:t.snapshot?.server||{vars:{},inbound:[],outbound:[],logs:[]}}})}function Nn(e){return Array.isArray(e)?e.slice():[]}var as={Level:"\u5173\u5361",PlayerSelf:"\u5F53\u524D\u73A9\u5BB6",AvatarSelf:"\u5F53\u524D\u89D2\u8272",...Object.fromEntries(lt.map((e,t)=>[e,`\u73A9\u5BB6${t+1}`])),...Object.fromEntries(Array.from({length:8},(e,t)=>[`Avatar${t+1}`,`\u89D2\u8272${t+1}`]))};function ls(e,t=1){let i=e?.vars||{},n=[],r=Number(t)>0?Number(t):1,o=["Level","PlayerSelf","AvatarSelf"];if(r>1)for(let l=1;l<=r;l+=1)o.push(`Player${l}`,`Avatar${l}`);let a=new Set;for(let l of o){if(a.has(l)||!i[l])continue;a.add(l);let c=i[l]||{};for(let s of Object.keys(c))n.push(G({entityType:l,entityLabel:as[l]||l,name:s,type:c[s]?.type||"",value:c[s]?.value??null}))}return n}var ft="qxqy-simulator-save",ss="qxqy-simulator-scripts",oe="server-control-template",Y="client-control-template",Fn={[oe]:"\u670D\u52A1\u5668\u63A7\u4EF6\u6A21\u677F",[Y]:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F"};function ct(e){return e===Y?"client":"server"}function _i(e){if(!(typeof e=="number"||typeof e=="string"&&/^\d+$/.test(e.trim()))||!we(e))throw new Error("\u63A7\u4EF6\u7D22\u5F15\u5FC5\u987B\u662F 1\u20132147483647 \u8303\u56F4\u5185\u7684\u6574\u6570");return Number(e)}function On(e=[]){if(!Array.isArray(e))throw new Error("controlGuidChanges \u5FC5\u987B\u662F\u6570\u7EC4");let t=new Set;return e.map(i=>{if(!i||typeof i.id!="string"||!i.id||t.has(i.id)||![oe,Y].includes(i.controlAsset)||typeof i.controlId!="string"||!i.controlId||typeof i.controlName!="string")throw new Error("controlGuidChanges \u5305\u542B\u65E0\u6548\u6216\u91CD\u590D\u7684\u53D8\u66F4\u8BB0\u5F55");return t.add(i.id),{id:i.id,controlAsset:i.controlAsset,controlId:i.controlId,controlName:i.controlName,oldGuid:_i(i.oldGuid),newGuid:_i(i.newGuid)}})}function us(e){let t=[e?.guid,e?.id];for(let i of t){let n=Number(i);if(Number.isSafeInteger(n)&&n>0&&n<=2147483647)return n}return 0}function Ti(e){let t=String(e?.controlAsset||""),i=us(e);return{id:String(i||e?.id||""),guid:i,path:String(e?.path||""),source:String(e?.source||""),controlId:String(e?.controlId||""),controlAsset:t===Y||t==="client"?Y:t===oe||t==="server"?oe:""}}function cs(e){let t=[],i=(n,r="")=>{if(n&&(n.path||n.source)){let o=Ti(n);t.push(r?{...o,controlAsset:r}:o)}};if(Array.isArray(e?.assets?.scripts)){for(let n of e.assets.scripts)n&&(n.path||n.source)&&t.push(Ti(n));return t}if(i(e?.assets?.server?.script,oe),i(e?.assets?.client?.script,Y),e&&e.format!==ft){i(e?.script);for(let n of e?.scripts||[])i(n)}return t}function $n(e){return Xe(e===Y?St():it())}var fs="\u672A\u7ED1\u5B9A",At="\u672A\u547D\u540D\u5B58\u6863",ds="\u672A\u547D\u540D\u754C\u9762";function hs(e){let t=e;for(let i=0;i<8;i++){if(ei(Do(t,"simulator","studio"))&&ei(Do(t,"lua")))return t;let n=rs(t);if(n===t)break;t=n}return e}function ms(e){return e?{name:kt(e),path:e,bound:!0}:{name:fs,path:"",bound:!1}}function ps(e,t=process.cwd()){if(os(e)&&ei(e))return e;let i=t||process.cwd(),n=hs(i),r=zo(n,e);if(ei(r))return r;let o=zo(i,e);if(ei(o))return o;throw new Error("script file not found: "+e)}function Gn(e,t={}){e?.format===ft&&qi(e.version);let i=[],n=typeof t.workspacePath=="string"&&t.workspacePath?t.workspacePath:"",r=e?.format===ft&&e.assets,o=On(e?.controlGuidChanges),a=Pi(e?.scriptSync),l=r?null:Xe(e,{warnings:i}),c={server:r&&e.assets.server?Xe(e.assets.server,{warnings:i}):$n(oe),client:r&&e.assets.client?Xe(e.assets.client,{warnings:i}):$n(Y)};l&&(c[ct(l.meta.assetType)]=l);let s=r&&e.activeAssetType===Y?Y:l?.meta.assetType||oe,f=r&&e.meta?.name?String(e.meta.name):"",m=()=>f||At;!e?.meta?.name&&c.server.meta.name==="\u672A\u547D\u540D\u754C\u9762\u63A7\u4EF6\u7EC4"&&(c.server.meta.name=ds);let h=[],g=new Set;function b(){g.clear(),vt(c.server.root,g),vt(c.client.root,g,{skipServerContainer:!0});for(let d of h)we(d.guid)&&g.add(Number(d.guid))}function w(d=0){b();let p=we(d)&&!g.has(Number(d))?Number(d):ze(g);return g.add(p),p}function M(d){let p=Ti(d),C=w(p.guid);return{...p,guid:C,id:String(C)}}Ge(cs(e));let E=Wt(e?.serverLogic),A=null,U="",$=1,q=1;function ee(d){let p=String(d||"").trim();if(!p)return"";if(!ie[p])throw new Error(`unknown canvas preset: ${p} (available: ${Object.keys(ie).join(", ")})`);return p}let J=()=>c[ct(s)];function O(d){if(!d)return null;for(let[p,C]of[["server",c.server],["client",c.client]]){let k=ce(C.root,d);if(k&&k.kind!=="server-container")return{key:p,node:k}}return null}function y(d){if(!d.controlId)return null;let p=d.controlAsset===Y?"client":d.controlAsset===oe?"server":null;if(p){let C=ce(c[p].root,d.controlId);return C&&C.kind!=="server-container"?{key:p,node:C}:null}return O(d.controlId)}function x(){for(let d of h)d.controlId&&!y(d)&&(d.controlId="",d.controlAsset="")}function v(d){if(!we(d))return null;for(let[p,C]of[[oe,c.server],[Y,c.client]]){let k="";if(j(C.root,R=>{!k&&(R.scriptMappingIds||[]).includes(Number(d))&&(k=R.id)}),k)return{controlId:k,controlAsset:p}}return null}function I(d,p,C){let k=c[ct(d.controlAsset)],R=k&&ce(k.root,d.controlId);R&&(R.scriptMappingIds=(R.scriptMappingIds||[]).map(N=>Number(N)===Number(p)?Number(C):N))}x();function F(){return h.map(d=>{let p=y(d),C=p?p.key==="client"?Y:oe:"";return G({id:d.id,guid:d.guid||0,path:d.path||"",source:d.source||"",controlId:d.controlId||"",controlAsset:d.controlAsset||C,controlName:p?.node.name||"",assetType:C,assetLabel:p?Fn[C]:"",mounted:!!p})})}function S(){let d=[],p=(C,k)=>{j(C.root,R=>{R.kind!=="server-container"&&d.push(G({id:R.id,name:R.name,kind:R.kind,assetType:k,assetLabel:Fn[k]}))})};return p(c.server,oe),p(c.client,Y),d}function P(d){let p=[];return j(d.root,C=>{C.kind!=="server-container"&&p.push(JSON.stringify({kind:C.kind,guid:C.guid,name:C.name,text:C.text??null,imageId:C.imageId??null,fontSize:C.fontSize??null,fontColor:C.fontColor??null,bgColor:C.bgColor??null,imageColor:C.imageColor??null,fillType:C.fillType??null,fillAmount:C.fillAmount??null,syncAllDevices:C.syncAllDevices!==!1,transformByPlatform:C.transformByPlatform||null}))}),p.join("/")}let D=P(St()),B=P(it());function le(d){let p=P(d);return d.meta?.assetType===Y?p===D:p===B}function K(d,p){return String(d||"").replace(/[\\/:*?"<>|]/g,"-").trim()||p}function he(d){let p=K(m(),At),C=d.meta?.assetType===Y?"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F":"\u670D\u52A1\u5668\u63A7\u4EF6\u6A21\u677F";return`${p} \xB7 ${C}`}function je(){if(!((c.server.root.children||[]).find(p=>p.kind==="container")||c.server.root.children?.[0]))throw new Error("\u6574\u5408\u5305\u9700\u8981\u670D\u52A1\u7AEF\u5BA2\u6237\u7AEF\u63A7\u4EF6\u5BB9\u5668\u4E0B\u81F3\u5C11\u6709\u4E00\u4E2A\u6839\u63A7\u4EF6");return Ar(c.server,c.client,{scripts:h,fileName:`${K(m(),At)} \xB7 \u6574\u5408\u5305.gia`})}function ht(){let d=p=>({type:p.meta.assetType,name:p.meta.name,sourceFile:p.meta.sourceFile||""});return{format:ft,name:m(),activeAssetType:s,assets:{server:d(c.server),client:d(c.client),scripts:F()}}}function _t(){return G({format:ft,version:4,meta:{name:m()},activeAssetType:s,serverLogic:E,controlGuidChanges:o,scriptSync:a,assets:{server:c.server,client:c.client,scripts:h.map(d=>G({id:d.id,guid:d.guid||0,path:d.path||"",source:d.source||"",controlId:d.controlId||"",controlAsset:d.controlAsset||""}))}})}function te(){let d=J(),p=Br(d);return p.workspace=ms(n),p.save=ht(),p.scripts=F(),p.mountTargets=S(),p.serverLogic=E,p.migrationWarnings=[...i],p.controlGuidChanges=G(o),p.scriptSync=G(a),jn(p),p}function Ae(d){let p=J();if(d.expectedRevision!==void 0&&Number(d.expectedRevision)!==p.version)throw new Error(`revision conflict: expected ${d.expectedRevision}, current ${p.version}`);return p}function qe(d,p,C=""){let k=String(p||"");if(k){let R=C===Y?Y:C===oe?oe:"";if(!y({controlId:k,controlAsset:R}))throw new Error("\u6302\u8F7D\u76EE\u6807\u5FC5\u987B\u662F\u5B58\u6863\u5185\u7684\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6216\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F");d.controlAsset=R}else d.controlAsset="";d.controlId=k}function ni(d){let p=Ae(d);if(d.op==="addScript"){let C=M({path:String(d.path||""),source:String(d.source||""),controlId:"",controlAsset:""});d.controlId!==void 0&&d.controlId!==""&&qe(C,d.controlId,d.controlAsset),h.push(C)}else if(d.op==="updateScript"){let C=h.find(k=>k.id===d.id);if(!C)throw new Error(`\u811A\u672C\u4E0D\u5B58\u5728: ${d.id}`);d.controlId!==void 0&&qe(C,d.controlId,d.controlAsset),d.path!==void 0&&(C.path=String(d.path)),d.source!==void 0&&(C.source=String(d.source))}else if(d.op==="removeScript"){let C=h.length;if(h=h.filter(k=>k.id!==d.id),h.length===C)throw new Error(`\u811A\u672C\u4E0D\u5B58\u5728: ${d.id}`)}return p.version+=1,te()}function ri(d){let p=Ae(d),C=ce(p.root,d.id??p.selectedId);if(!C||C.kind==="server-container")throw new Error("\u4EC5\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6216\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u5141\u8BB8\u4FEE\u6539\u7D22\u5F15");let k=_i(d.guid),R=_i(C.guid);if(k===R)return te();let N=[];for(let V of Object.values(c))j(V.root,re=>{V===c.client&&re.kind==="server-container"||N.push({node:re,project:V})});if(N.some(V=>V.node!==C&&Number(V.node.guid)===k)||h.some(V=>Number(V.guid)===k))throw new Error(`\u63A7\u4EF6\u7D22\u5F15 ${k} \u5DF2\u88AB\u5176\u4ED6\u63A7\u4EF6\u6216\u811A\u672C\u5360\u7528`);let z=[],L=(V,re,Te)=>{let Z=V?.[re];(typeof Z=="number"||typeof Z=="string"&&/^\d+$/.test(Z.trim()))&&Number(Z)===R&&z.push({owner:V,key:re,project:Te.project})};for(let V of N)L(V.node,"referencedPrefabId",V),L(V.node,"itemPrefabId",V),L(V.node.giaRaw,"templateRefSlot",V);if(z.length&&N.filter(V=>Number(V.node.guid)===R).length!==1)throw new Error(`\u65E7\u7D22\u5F15 ${R} \u5728\u591A\u68F5\u8D44\u4EA7\u6811\u4E2D\u91CD\u590D\uFF0C\u65E0\u6CD5\u786E\u5B9A\u6A21\u677F\u5F15\u7528\u5F52\u5C5E\uFF1B\u8BF7\u5148\u6D88\u9664\u6B67\u4E49\u540E\u4FEE\u6539`);let _e={id:ns(),controlAsset:s,controlId:C.id,controlName:C.name,oldGuid:R,newGuid:k};C.guid=k;let me=new Set([p]);for(let{owner:V,key:re,project:Te}of z)V[re]=typeof V[re]=="string"?String(k):k,me.add(Te);o.push(_e);for(let V of me)V.version+=1;return te()}function ne(d){let p=Ae(d);if(!Array.isArray(d.changeIds)||!d.changeIds.length||d.changeIds.some(k=>typeof k!="string"||!o.some(R=>R.id===k)))throw new Error("\u8BF7\u660E\u786E\u6307\u5B9A\u5DF2\u6838\u5BF9 Lua \u5F15\u7528\u7684\u6709\u6548\u7D22\u5F15\u53D8\u66F4\u8BB0\u5F55 changeIds");let C=new Set(d.changeIds);return o=o.filter(k=>!C.has(k.id)),p.version+=1,te()}function ke(d){if(!d||typeof d!="object")throw new Error("patch requires op");if(d.op==="setScriptSync"){let p=Ae(d);return a=Pi(d.config),p.version+=1,te()}if(d.op==="setControlGuid")return ri(d);if(d.op==="acknowledgeControlGuidChanges")return ne(d);if(d.op==="setServerLogic"){let p=Ae(d);return E=Wt(d.logic),p.version+=1,te()}if(d.op==="addScript"||d.op==="updateScript"||d.op==="removeScript")return ni(d);if(d.op==="selectAsset")return s=d.assetType===Y?Y:oe,te();if(d.op==="renameSave"){let p=String(d.name||"").trim();if(!p)throw new Error("\u5B58\u6863\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A");return f=p,te()}if(d.op==="newAsset"){let p=Ae(d);s=d.assetType===Y?Y:oe;let C=$n(s);return C.version=p.version+1,c[ct(s)]=C,o=o.filter(k=>k.controlAsset!==s),x(),te()}return Qi(J(),d),x(),te()}function Me(d){return h.filter(p=>{let C=y(p);return!!(C&&C.key==="client"==(d===Y))})}function Tt(d="json",p=""){let C=Rt(d,p);if(o.length&&!["save","archive"].includes(String(d).toLowerCase())){let k=o.map(R=>`\u63A7\u4EF6\u7D22\u5F15\u5F85\u6838\u5BF9 Lua \u5F15\u7528\uFF1A${Fn[R.controlAsset]} / ${R.controlName} (${R.controlId})\uFF1A${R.oldGuid} \u2192 ${R.newGuid}\u3002\u8BF7\u6309\u8BED\u4E49\u66F4\u65B0\u811A\u672C\u4E2D\u7684\u63A7\u4EF6\u7D22\u5F15\u5F15\u7528\uFF0C\u6838\u5BF9\u540E\u786E\u8BA4\u53D8\u66F4\u8BB0\u5F55 ${R.id}\uFF1B\u4E0D\u8981\u5168\u5C40\u66FF\u6362\u540C\u503C\u6570\u5B57\u3002`);C.warnings=[...new Set([...C.warnings||[],...k])]}return C}function Rt(d="json",p=""){let C=String(d).toLowerCase();if(C==="save"||C==="archive"){let N=Buffer.from(JSON.stringify(_t(),null,2),"utf8");return G({filename:`${m().replace(/[\\/:*?"<>|]/g,"-")} \xB7 \u8D44\u4EA7\u5305.json`,mimeType:"application/json",encoding:"base64",data:N.toString("base64"),warnings:[]})}if(C==="save-gia"||C==="archive-gia"){let N=[],z=[],L=(me,V="")=>{let re=Tt(me,V);N.push(G({filename:re.filename,mimeType:re.mimeType,encoding:re.encoding,data:re.data,warnings:re.warnings||[]})),z.push(...re.warnings||[])},_e=(me,V)=>{let re=c[ct(me)],Te=me===s,Z=h.some(ve=>ve.controlAsset===me&&ve.controlId);if(!Te&&le(re)&&!Z){z.push(V);return}L("gia",me)};if(_e(oe,"\u670D\u52A1\u5668\u63A7\u4EF6\u6A21\u677F\u4ECD\u662F\u9ED8\u8BA4\u6A71\u7A97\uFF0C\u672A\u6539\u52A8\u4E14\u5F53\u524D\u672A\u663E\u793A\uFF0C\u5DF2\u4ECE\u8D44\u4EA7\u5305 GIA \u4E2D\u7701\u7565\u3002"),_e(Y,"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u4ECD\u662F\u9ED8\u8BA4\u300CLua\u5B9E\u4F8B\u5316\u9762\u677F\u300D\uFF0C\u672A\u6539\u52A8\u4E14\u5F53\u524D\u672A\u663E\u793A\uFF0C\u5DF2\u4ECE\u8D44\u4EA7\u5305 GIA \u4E2D\u7701\u7565\u3002"),h.some(me=>me.path||me.source)&&L("scripts-gia"),!N.length)throw new Error("\u8D44\u4EA7\u5305 GIA \u6CA1\u6709\u53EF\u5BFC\u51FA\u7684\u5DF2\u6539\u52A8\u9879\uFF1B\u8BF7\u5148\u7F16\u8F91\u5F53\u524D\u754C\u9762\uFF0C\u6216\u6539\u7528\u300C\u5F53\u524D\u754C\u9762 GIA\u300D\u3002");return G({format:"qxqy-gia-package",files:N,warnings:[...new Set(z)]})}if(C==="gia-combined"||C==="combined-gia"||C==="combined"){let N=je();return G({filename:`${K(m(),At)} \xB7 \u6574\u5408\u5305.gia`,mimeType:"application/octet-stream",encoding:"base64",data:N.buffer.toString("base64"),warnings:[...new Set(N.warnings||[])]})}if(C==="scripts"){let N=G({format:ss,version:1,scripts:h.map(L=>G({id:L.id,guid:L.guid||0,path:L.path||"",source:L.source||"",controlId:L.controlId||"",controlAsset:L.controlAsset||""}))}),z=Buffer.from(JSON.stringify(N,null,2),"utf8");return G({filename:`${K(m(),At)} \xB7 \u811A\u672C.json`,mimeType:"application/json",encoding:"base64",data:z.toString("base64"),warnings:[]})}if(C==="scripts-gia"||C==="scriptsgia"){let N=Rr(h);return G({filename:`${K(m(),At)} \xB7 \u811A\u672C.gia`,mimeType:"application/octet-stream",encoding:"base64",data:N.buffer.toString("base64"),warnings:N.warnings})}if(C==="lua"){let N=h.find(L=>L.id===p)||h.find(L=>L.path===p);if(!N)throw new Error("\u6CA1\u6709\u53EF\u5BFC\u51FA\u7684 Lua \u811A\u672C\uFF0C\u8BF7\u5148\u5728\u201CLua \u811A\u672C\u201D\u9875\u521B\u5EFA");let z=kt(N.path||"")||`qxqy-script-${N.id}`;return G({filename:/\.lua$/i.test(z)?z:`${z}.lua`,mimeType:"text/x-lua",encoding:"base64",data:Buffer.from(N.source||"","utf8").toString("base64"),warnings:[]})}let k=p?c[ct(p)]:J(),R=he(k);if(C==="json"){let N=G({...k,scripts:Me(k.meta.assetType),controlGuidChanges:o.filter(L=>L.controlAsset===k.meta.assetType)}),z=Buffer.from(JSON.stringify(N,null,2),"utf8");return G({filename:`${R}.json`,mimeType:"application/json",encoding:"base64",data:z.toString("base64"),warnings:[]})}if(C==="gia"){let N=Er(k,k.meta.assetType===Y?{scripts:Me(Y)}:{}),z=k.meta.assetType===Y?[]:Me(oe);return z.length&&N.warnings.unshift(`\u5F53\u524D\u670D\u52A1\u5668\u63A7\u4EF6 GIA \u4E0D\u5305\u542B ${z.length} \u4E2A Lua \u811A\u672C\u7684\u6E90\u7801\uFF1B\u8BF7\u4F7F\u7528\u300C\u8D44\u4EA7\u5305 GIA \u6574\u5408\u5305\u300D\uFF0C\u6216\u53E6\u884C\u5BFC\u5165\u811A\u672C\u5305\u5E76\u6838\u5BF9\u6302\u8F7D\u3002`),G({filename:`${R}.gia`,mimeType:"application/octet-stream",encoding:"base64",data:N.buffer.toString("base64"),warnings:N.warnings})}throw new Error(`unsupported export format: ${d}`)}function Ge(d){for(let p of d){let C=Ti(p);if(!C.path&&!C.source)continue;let k=C.controlId?null:v(C.guid),R=M(k?{...C,...k}:C);k&&R.guid!==C.guid&&I(k,C.guid,R.guid),R.controlId&&!y(R)&&(R.controlId="",R.controlAsset=""),h.push(R)}}function Pt(d,p,C=""){let k=String(d||"").toLowerCase();if(typeof p!="string"||!p)throw new Error("import data is required");let R=Buffer.from(p,"base64"),N,z=[],L={};if(k==="json"){try{N=JSON.parse(R.toString("utf8"))}catch{throw new Error("JSON \u6587\u4EF6\u65E0\u6548")}if(N?.project&&(N=N.project),N?.format===ft&&N?.assets){qi(N.version);let Z=Gn(N);z.push(...Z.get().migrationWarnings);let ve=Z.archiveData();return c.server=ve.assets.server,c.client=ve.assets.client,i=[...z],s=N.activeAssetType===Y?Y:oe,f=String(N.meta?.name||kt(C).replace(/\.json$/i,"")||f),E=ve.serverLogic,h=ve.assets.scripts,o=ve.controlGuidChanges,a=ve.scriptSync,g.clear(),G({snapshot:te(),warnings:z,metadata:{format:ft}})}}else{if(k==="lua")return h.push(M({path:kt(C||"imported.lua"),source:R.toString("utf8"),controlId:""})),G({snapshot:te(),warnings:z,metadata:{assetType:"lua-script"}});if(k==="gia"){if(Pr(R)){let Ce=Nr(R);return Ge(Ce.scripts),G({snapshot:te(),warnings:Ce.warnings,metadata:Ce.metadata})}let Z=Fr(R);N=Z.project,z=Z.warnings,L=Z.metadata,Z.clientProject&&(c.client=Xe(Z.clientProject),o=o.filter(Ce=>Ce.controlAsset!==Y),z.push("\u6574\u5408\u5305\u5DF2\u62C6\u56DE\u300CUI\u63A7\u4EF6-\u670D\u52A1\u7AEF\u300D\u4E0E\u300CUI\u63A7\u4EF6-\u5BA2\u6237\u7AEF\u300D\uFF1B\u5BA2\u6237\u7AEF\u6A21\u677F\u8FB9\u754C\u5DF2\u4FDD\u7559\u3002"));let ve=new Map,Yn=(Ce,aa)=>{Ce&&j(Ce.root,Un=>{for(let Ri of Un.scriptMappingIds||[]){let Bn=ve.get(Number(Ri));if(Bn){z.push(`\u811A\u672C GUID ${Ri} \u540C\u65F6\u6302\u8F7D\u5230\u591A\u4E2A\u63A7\u4EF6\uFF0C\u5DF2\u4FDD\u7559\u201C${Bn.controlAsset===oe?"\u670D\u52A1\u7AEF":"\u5BA2\u6237\u7AEF"}\u201D\u76EE\u6807\u3002`);continue}ve.set(Number(Ri),{controlId:Un.id,controlAsset:aa})}})};Yn(Z.project,oe),Yn(Z.clientProject,Y),Ge((Z.scripts||[]).map(Ce=>ve.has(Number(Ce.guid))?{...Ce,...ve.get(Number(Ce.guid))}:Ce))}else throw new Error(`unsupported import format: ${d}`)}let _e=Xe(N,{warnings:z}),me=On(N?.controlGuidChanges);if(me.some(Z=>Z.controlAsset!==_e.meta.assetType))throw new Error("\u5355\u8D44\u4EA7 JSON \u7684\u7D22\u5F15\u53D8\u66F4\u8BB0\u5F55\u5FC5\u987B\u5C5E\u4E8E\u5F53\u524D\u5BFC\u5165\u8D44\u4EA7");let V=On([...o.filter(Z=>Z.controlAsset!==_e.meta.assetType),...me]);i=[...z];let re=ct(_e.meta.assetType);c[re]=_e,o=V,s=_e.meta.assetType;let Te=c[re];return C&&(Te.meta.name=kt(C).replace(/\.(json|gia)$/i,"")||Te.meta.name,Te.meta.sourceFile=kt(C),Te.meta.sourceFormat=k),Ge(N?.scripts||[]),N?.script&&(N.script.path||N.script.source)&&Ge([N.script]),G({snapshot:te(),warnings:z,metadata:L})}function Vo(d,p){return Qi(J(),{op:"pick",x:d,y:p}),te()}function Yo(d){let p=typeof d=="string"&&d?d:"";!p||p===n||(n=p)}function Uo(d){let p=d.source||"";if(!p.trim()&&d.path.trim())try{p=is(ps(d.path,n),"utf8")}catch(C){throw new Error(`\u811A\u672C ${d.path} \u8BFB\u53D6\u5931\u8D25: ${C?.message||C}`)}return p}function Mt(d={}){let p=ee(d.canvasId);p&&(U=p),d.playerCount!==void 0&&d.playerCount!==null&&d.playerCount!==""&&($=at(d.playerCount),q>$&&(q=1)),d.viewPlayerIndex!==void 0&&d.viewPlayerIndex!==null&&d.viewPlayerIndex!==""&&(q=$e(d.viewPlayerIndex,$)),A&&Tn(A);let C=h.map(R=>{try{return{id:R.id,guid:R.guid||0,path:R.path||R.id,source:Uo(R),controlId:R.controlId||"",controlAsset:R.controlAsset||""}}catch(N){return{id:R.id,guid:R.guid||0,path:R.path||R.id,source:`error([==[ ${String(N.message).replace(/]=+]/g,"] =]")} ])`,controlId:R.controlId||"",controlAsset:R.controlAsset||""}}}),k=R=>C.filter(N=>{let z={controlId:N.controlId,controlAsset:N.controlAsset},L=N.controlId?y(z):null;return!!(L&&L.key===R)});return A=Ao(c.server,{templatesProject:c.client,scripts:C,sceneScripts:k("server"),templateScripts:k("client"),serverConfig:{logic:E},canvasId:U,playerCount:$,viewPlayerIndex:q,language:d.language||""}),ue(d)}function Bo(d,p={}){let C=ee(d);if(!C)throw new Error("playSetCanvas requires canvasId");return Mt({...p,canvasId:C})}function ue(d={}){if(!A)return G({running:!1,tree:[],logs:[],serverLogs:[],serverVars:[]});let p=wn(A,d);return p.running=!0,p.logs=Nn(p.logs),p.serverLogs=Nn(p.server?.logs||[]),p.serverVars=ls(p.server,p.playerCount||1),p}function Xo(d,p={}){return A||Mt(),Ai(A,d),p.observe===!1?G({running:!0,time:A.runtime.clock.time,frame:A.runtime.clock.frame,paused:!!A.debugPaused,levelTimePaused:!!A.runtime.clock.paused,playerCount:A.playerCount||1,viewPlayerIndex:A.viewPlayerIndex||1}):ue(p)}function Ko(d=0){Mt();let p=Math.max(0,Number(d)||0);for(let C=0;C<p;C++)Ai(A,1/30);return ue()}function Ho(){return A&&Tn(A),A=null,U="",$=1,q=1,G({running:!1,tree:[],logs:[],serverLogs:[],serverVars:[]})}function Lo(d,p={}){let C=Nt();return q=Cn(C,d),p.observe===!1?null:ue(p)}function Wo(d,p={}){if(!A)throw new Error("play session has not started");return xn(A,d),p.observe===!1?null:ue(p)}function jo(d,p={}){if(!A)throw new Error("play session has not started");return En(A,d),p.observe===!1?null:ue(p)}function qo(d,p,C,k={}){if(!A)throw new Error("play session has not started");return Qt(A,d,p,C),k.observe===!1?null:ue(k)}function Jo(d={}){return A&&ki(A).pause(),d.observe===!1?null:ue(d)}function Zo(d={}){return A&&ki(A).resume(),d.observe===!1?null:ue(d)}function Nt(){if(!A)throw new Error("play session has not started");return A}function Qo(d,p){let C=Nt();if(!d&&!p){let k=ue();return G({vars:k.serverVars||[]})}return G({entityType:String(d||""),name:String(p||""),value:Fo(C,d,p)})}function ea(d,p,C){let k=Nt();return kn(k,d,p,C),ue()}function ta(d,p=[],C="PlayerSelf"){let k=Nt();return _n(k,d,p,C),ue()}function ia(){let d=ue();return G({events:d.history||[],case:Io(d.history||[],{playerCount:d.playerCount||1})})}function na(d={}){let p=ue(),C=qt({name:d.name||"",dt:d.dt,playerCount:d.playerCount||p.playerCount||1,events:d.events||p.history||[],asserts:d.asserts||[]});return G(C)}function ra(d,p={}){let C=qt(d);Mt({...p,playerCount:p.playerCount||C.playerCount||1});let k=Nt();k.recording=!1;try{return Go(ki(k),d)}finally{k.recording=!0}}function oa(){if(!A)return{running:!1,paused:!1,time:0,frame:0,playerCount:1,viewPlayerIndex:1};let d=A.runtime.clock;return{running:!0,paused:!!A.debugPaused,levelTimePaused:!!d.paused,time:d.time,frame:d.frame,playerCount:A.playerCount||1,viewPlayerIndex:A.viewPlayerIndex||1}}let Vn={get:te,patch:ke,setWorkspace:Yo,exportData:Tt,importData:Pt,pick:Vo,playStart:Mt,playSetCanvas:Bo,playSetView:Lo,playGet:ue,playStatus:oa,playStep:Xo,playRun:Ko,playStop:Ho,playKey:Wo,playClick:jo,playPointer:qo,playPause:Jo,playResume:Zo,playServerGet:Qo,playServerSet:ea,playServerSend:ta,playHistory:ia,playSaveCase:na,playRunCase:ra,archiveData:_t};return Object.defineProperty(Vn,"_project",{enumerable:!1,get:J}),Vn}var X=null,zn=!1,dt=0,We=0,gs=33,ti=1/30,ys=5;function ii(e={}){return{...e.inspect?{inspect:!0}:{},...e.view?{view:!0}:{},...e.paint?{paint:!0}:{},...e.compact?{compact:!0}:{},...e.sceneRev!==void 0&&e.sceneRev!==null?{sceneRev:e.sceneRev}:{}}}function bs(e={}){let t=ii(e);for(let i of["canvasId","playerCount","viewPlayerIndex","language"])e[i]!==void 0&&e[i]!==null&&e[i]!==""&&(t[i]=e[i]);return t}function Le(e={}){return e.light?{...X.playStatus()}:X.playGet(ii(e))}function vs(){if(!X||zn)return;let e=X.playStatus();if(!e.running||e.paused){dt=0,We=0;return}let t=Date.now();if(!dt){dt=t;return}zn=!0;try{We+=Math.min(.25,Math.max(0,(t-dt)/1e3)),dt=t;let i=0;for(;We>=ti&&i<ys;)X.playStep(ti,{observe:!1}),We-=ti,i+=1;We>ti&&(We=ti)}finally{zn=!1}}var Tc=setInterval(vs,gs);function Ss(e,t={}){if(e==="start")return X&&X.playStop(),X=Gn(t.archive||t.project,{workspacePath:t.workspacePath||""}),dt=0,We=0,X.playStart(bs(t));if(!X)throw new Error("play session has not started");if(e==="get")return t.light?Le(t):X.playGet(ii(t));if(e==="step"){let i=X.playStep(t.dt,t.light?{observe:!1}:ii(t));return t.light?Le(t):i}if(e==="pointer")return X.playPointer(t.type,t.x,t.y,{observe:!1}),Le(t);if(e==="key")return X.playKey(t.key,{observe:!1}),Le(t);if(e==="click")return X.playClick(t.name,{observe:!1}),Le(t);if(e==="pause")return X.playPause({observe:!1}),Le(t);if(e==="resume")return X.playResume({observe:!1}),Le(t);if(e==="device")return X.playSetCanvas(t.canvasId,ii(t));if(e==="view")return X.playSetView(t.playerIndex??t.viewPlayerIndex,{observe:!1}),Le(t);if(e==="serverGet")return X.playServerGet(t.entityType,t.name);if(e==="serverSet")return X.playServerSet(t.entityType,t.name,t.value);if(e==="serverSend")return X.playServerSend(t.name,t.params||[],t.target||"PlayerSelf");if(e==="history")return X.playHistory();if(e==="saveCase")return X.playSaveCase(t.case||t);if(e==="runCase")return X.playRunCase(t.case||t,{canvasId:t.canvasId,playerCount:t.playerCount,viewPlayerIndex:t.viewPlayerIndex});if(e==="stop"){let i=X.playStop();return X=null,dt=0,We=0,i}throw new Error(`unknown play action: ${e}`)}Dn.on("message",e=>{let{id:t,action:i,args:n={}}=e||{};try{Dn.postMessage({id:t,ok:!0,value:Ss(i,n),error:null})}catch(r){Dn.postMessage({id:t,ok:!1,value:null,error:r?.message||String(r)})}});
106
+ `)}`);return{buffer:n,warnings:[...new Set(t.warnings)]}}function an(e){return ke.toObject(ke.decode(bi(e)),{longs:Number,enums:Number,bytes:Buffer,defaults:!1,arrays:!0,objects:!0})}function Ur(e){try{let i=an(e).graph||[];return i.length>0&&i.every(n=>Number(n.which)===It)}catch{return!1}}function jr(e){let t=(e.graph||[]).filter(r=>Number(r.which)===It),i=[],n=t.map((r,o)=>{let a=r.script?.mapping||{},l=Number(r.id?.id)||0;l<=0&&i.push(`\u7B2C ${o+1} \u6761\u811A\u672C\u6620\u5C04\u7F3A\u5C11 GraphUnit.id.id\uFF0C\u5DF2\u6309 0 \u5904\u7406\uFF08\u5BFC\u51FA\u65F6\u4F1A\u91CD\u65B0\u5206\u914D\uFF09\u3002`);let c=Number(a.id)||0;return c&&c!==l&&i.push(`\u7B2C ${o+1} \u6761\u811A\u672C\u6620\u5C04 id(${c}) \u4E0E\u5355\u5143 id(${l}) \u4E0D\u4E00\u81F4\uFF0C\u4EE5\u5355\u5143 id \u4E3A\u51C6\u3002`),{guid:l,path:String(a.filePath||""),source:String(a.source||"")}});for(let[r,o]of n.entries())o.path&&!/\.lua$/iu.test(o.path)&&i.push(`\u7B2C ${r+1} \u6761\u811A\u672C\u6620\u5C04 file_path \u7F3A\u5C11 .lua \u540E\u7F00\uFF08${o.path}\uFF09\uFF0C\u771F\u673A\u53EF\u80FD\u62D2\u7EDD\u5BFC\u5165\uFF1B\u6A21\u62DF\u5668\u5185\u6309\u5F52\u4E00\u5316\u8DEF\u5F84\u7167\u5E38 require\u3002`);return{scripts:n,warnings:i}}function Xr(e){let t=an(e),i=jr(t);if(!i.scripts.length)throw new Error("GIA \u5185\u6CA1\u6709\u811A\u672C\u6620\u5C04\u5355\u5143\uFF08which=69\uFF09");return{scripts:i.scripts,warnings:i.warnings,metadata:{assetType:"lua-script"}}}function il(e){let t=[],i;try{i=an(e)}catch(r){return{valid:!1,errors:[r?.message||String(r)],scriptCount:0}}let n=i.graph||[];return n.length||t.push("Root.graph \u4E3A\u7A7A"),(i.accessories||[]).length&&t.push("script.gia \u4E0D\u5E94\u5305\u542B accessories"),n.forEach((r,o)=>{let a=`\u5355\u5143 ${o+1}`;Number(r.which)!==It&&t.push(`${a}: which \u5E94\u4E3A 69\uFF0C\u5B9E\u9645 ${r.which}`),Number(r.id?.class)!==Gr&&t.push(`${a}: id.class \u5E94\u4E3A 30\uFF0C\u5B9E\u9645 ${r.id?.class}`),Number(r.id?.type??0)!==0&&t.push(`${a}: id.type \u5E94\u7F3A\u7701`);let l=r.script?.mapping;if(!l){t.push(`${a}: \u7F3A\u5C11 field35 ScriptMappingWrapper`);return}Number(r.id?.id)<=0&&t.push(`${a}: GraphUnit.id.id \u975E\u6CD5`),Number(l.id)!==Number(r.id?.id)&&t.push(`${a}: mapping.id \u5E94\u7B49\u4E8E GraphUnit.id.id`),String(l.name||"")!==String(r.name||"")&&t.push(`${a}: mapping.name \u5E94\u7B49\u4E8E GraphUnit.name`),String(l.filePath||"").trim()?/\.lua$/iu.test(String(l.filePath))||t.push(`${a}: file_path \u5E94\u4EE5 .lua \u7ED3\u5C3E\uFF08\u5B98\u65B9 script.gia \u6837\u672C\u5747\u4E3A \u540D\u79F0.lua\uFF0C\u771F\u673A require \u65F6\u624D\u53BB\u6269\u5C55\u540D\uFF09`):t.push(`${a}: file_path \u4E3A\u7A7A`)}),{valid:t.length===0,errors:t,scriptCount:n.length}}function bi(e){let t=Buffer.isBuffer(e)?e:Buffer.from(e);if(t.length<Xe+en)throw new Error("GIA \u6587\u4EF6\u8FC7\u77ED");if(t.readUInt32BE(4)!==1||t.readUInt32BE(8)!==Er||t.readUInt32BE(12)!==3)throw new Error("\u4E0D\u662F\u53D7\u652F\u6301\u7684 GIA v1 \u6587\u4EF6");let i=t.readUInt32BE(16);if(i!==t.length-Xe-en)throw new Error("GIA payload \u957F\u5EA6\u4E0D\u4E00\u81F4");if(t.readUInt32BE(Xe+i)!==Ar)throw new Error("GIA \u5C3E\u6807\u8BB0\u65E0\u6548");return t.subarray(Xe,Xe+i)}function fe(e,t){return e.ui?.content?.data?.find(i=>i.details?.[t])?.details?.[t]||null}function nl(e){let t=fe(e,"transform")?.multiPlatform,i={};for(let r of t?.platforms||[]){let o=Xa[r.platformType||0],a=r.transform||{};i[o]={scale:a.scale?{x:a.scale.x??0,y:a.scale.y??0,z:a.scale.z??0}:{x:1,y:1,z:1},rotation:{x:0,y:0,z:a.field508?.z??0},anchorMin:{x:a.anchorMin?.x??0,y:a.anchorMin?.y??0},anchorMax:{x:a.anchorMax?.x??0,y:a.anchorMax?.y??0},offset:{x:a.offset?.x??0,y:a.offset?.y??0},size:{x:a.size?.x??0,y:a.size?.y??0},pivot:a.pivot?{x:a.pivot.x??0,y:a.pivot.y??0}:{x:.5,y:.5}}}let n=i.KEYBOARD||i[Object.keys(i)[0]];if(!n)throw new Error(`GIA \u63A7\u4EF6 ${e.name||e.id?.id} \u7F3A\u5C11\u591A\u5E73\u53F0\u53D8\u6362`);for(let r of se)i[r]||(i[r]=structuredClone(n));return i}function yi(e){let t=e.ui?.content?.data||[];return t.some(i=>i.details?.textConfig)?t.some(i=>i.field501===71)?"textwindow":"textbox":t.some(i=>i.details?.cursorConfig)?"cursor":t.some(i=>Object.hasOwn(i.details||{},"templateRefSlot"))?"reference":t.some(i=>i.details?.gridView)?"grid":t.some(i=>i.details?.buttonPreset)?"button":t.some(i=>i.details?.keyHint)?"keyhint":t.some(i=>i.details?.image||i.details?.imageSlot)?"image":t.some(i=>Object.hasOwn(i.details||{},"effectSlot"))?"animation":t.some(i=>Object.hasOwn(i.details||{},"fullscreenEffectSlot"))?"fullscreen":(t.some(i=>Object.hasOwn(i.details||{},"containerNodeSlot")),"container")}function kr(e,{reverseSiblings:t=!1,idOffset:i=0}={}){if(!e.length)return{nodes:new Map,rootCandidates:[],warnings:[]};let n=new Map(e.map((s,f)=>[s.id?.id,`n${i+f+1}`])),r=new Map,o=new Map,a=[];for(let s of e){let f=yi(s),h=fe(s,"textConfig"),m=fe(s,"imageSlot"),p=fe(s,"image"),y=fe(s,"buttonPreset"),v=fe(s,"gridView"),E=fe(s,"genericSlot"),x=fe(s,"footerSlot"),A=fe(s,"cursorConfig"),$=fe(s,"keyHint"),O=fe(s,"containerNodeSlot"),J=fe(s,"templateRefSlot"),ee=fe(s,"effectSlot"),Z=fe(s,"fullscreenEffectSlot"),z=H(f,{id:n.get(s.id?.id),guid:s.id?.id||0,giaInfoIndex:(s.ui?.content?.info||[]).find(b=>b.field501===2&&b.field502===6)?.index?.value,giaRelatedGuids:(s.ui?.content?.info||[]).find(b=>b.field501===4&&b.field502===4)?.related?.value||[],name:s.name||f,visible:fe(s,"field14")?.field17?.initiallyHidden!==!0,active:fe(s,"field14")?.initiallyInactive!==!0,canControllerFocus:x?.field505===1,scriptMappingIds:(E?.field502||[]).map(b=>Number(b?.field1?.id)).filter(b=>Number.isSafeInteger(b)&&b>0),transformByPlatform:nl(s),syncAllDevices:fe(s,"transform")?.multiPlatform?.field504===1,giaRaw:{genericField501:E?.field501??0,footerField505:x?.field505??0,...f==="textbox"||f==="textwindow"?{textField501:h?.field501??20,textField503:h?.field503??12,textAlign:h?.align??0,...[void 0,0,1,2].includes(h?.verticalAlign)?{}:{textVerticalAlign:h.verticalAlign},...f==="textwindow"?{textField511:h?.field511??1,textViewField502:h?.viewFlags?.field502??1,textViewField503:h?.viewFlags?.field503??1}:{}}:{},...f==="cursor"?{cursorField501:A?.field501??0}:{},...f==="reference"?{templateRefSlot:J??""}:{},...f==="grid"?{gridField501:v?.field501??1,gridField507:v?.field507??1,gridField508:v?.field508??1,gridField509:v?.field509??1,gridField511:v?.field511??5,gridField512:v?.field512??1}:{},...f==="keyhint"?{keyHintField501:$?.field501??1,keyHintField502:$?.field502??1}:{},...f==="image"?{imageField502:p?.field502??1,imageField504:p?.field504??1,imageField505:p?.field505??1,imageField507:p?.field507??2,imageFillType:p?.fillType??1}:{},...f==="animation"?{effectSlot:ee??""}:{},...f==="fullscreen"?{fullscreenEffectSlot:Z??""}:{}},...f==="container"?{isolateNavigation:O?.isolateNavigation===!0,disableKeyEventPassthrough:O?.disableKeyEventPassthrough===!0,disableCursorEventPassthrough:O?.disableCursorEventPassthrough===!0,showCursor:O?.showCursor===!0}:{},...f==="cursor"?{raycastTarget:A?.field501===1}:{},...f==="textbox"||f==="textwindow"?{text:h?.text?.value??"",fontSize:h?.fontSize??20,minimumFontSize:h?.minimumFontSize??20,adaptiveFontSize:h?.adaptive===1,fontColor:h?.color??4294967295,bgColor:h?.color2??0,enableOutline:h?.outlineOff!==1,outlineColor:h?.color3??858993459,horizontalAlignment:h?.align===1?"Middle":h?.align===2?"Right":"Left",verticalAlignment:{0:"Top",1:"Middle",2:"Bottom"}[h?.verticalAlign??0]||"Top",...f==="textwindow"?{interactable:!0,showScrollBar:!0}:{}}:{},...f==="image"?{imageSource:"StaticReference",imageId:m?.assetId??0,imageColor:Number.isFinite(m?.field502)?m.field502>>>0:4294967295,enableMask:p?.enableMask===1,enableSoftEdge:p?.enableSoftEdge===1,enableFill:p?.enableFill===1,softEdgeMode:p?.softEdgePixel===1?"Pixel":"Percentage",softEdgeWidthX:p?.border?.field501??8,softEdgeWidthY:p?.border?.field502??8,horizontalSoftRange:p?.field512??85,verticalSoftRange:p?.field513??85,fillType:{1:"Horizontal",2:"Vertical",3:"Radial90",4:"Radial180",5:"Radial360"}[p?.fillType]||"Horizontal",fillAmount:Number.isFinite(p?.field508)?Math.max(0,Math.min(1,p.field508/100)):p?.enableFill===1?0:1,reverseMaskArea:p?.reverseMask===1}:{},...f==="button"?{interactable:y?.interactable===1,raycastTarget:y?.raycastTarget===1,clickAudioId:y?.clickAudioId??50888}:{},...f==="grid"?{cellSizeX:v?.cellSize?.field501??50,cellSizeY:v?.cellSize?.field502??50,spacingX:v?.gap?.field501??8,spacingY:v?.gap?.field502??8,padding1X:v?.padding1?.field501??20,padding1Y:v?.padding1?.field502??20,padding2X:v?.padding2?.field501??20,padding2Y:v?.padding2?.field502??20,previewCount:v?.field511??5}:{},...f==="reference"?{referencedPrefabId:J??""}:{},...f==="keyhint"?{keyboardKeyCode:$?.field502??null,controllerKeyCode:$?.field501??null}:{},...f==="animation"?{animationId:ee??""}:{},...f==="fullscreen"?{animationId:Z??""}:{}});r.set(s.id?.id,z),(f==="textbox"||f==="textwindow")&&![void 0,0,1,2].includes(h?.align)&&a.push(`${z.name}: \u6C34\u5E73\u5BF9\u9F50\u679A\u4E3E ${h.align} \u7684\u542B\u4E49\u672A\u77E5\uFF0C\u5DF2\u539F\u6837\u4FDD\u7559\u3002`),(f==="textbox"||f==="textwindow")&&![void 0,0,1,2].includes(h?.verticalAlign)&&a.push(`${z.name}: \u5782\u76F4\u5BF9\u9F50\u679A\u4E3E ${h.verticalAlign} \u7684\u542B\u4E49\u672A\u77E5\uFF0C\u5DF2\u539F\u6837\u4FDD\u7559\u3002`),f==="image"&&![void 0,0,1,2,3,4,5].includes(p?.fillType)&&a.push(`${z.name}: \u586B\u5145\u5F62\u72B6\u679A\u4E3E ${p.fillType} \u672A\u8BC6\u522B\uFF0C\u5DF2\u4FDD\u7559\u539F\u503C\u3002`),f==="button"&&o.set(z.id,{unavailableChildId:y?.disabledChild,hoverChildId:y?.hoverChild,pressedChildId:y?.pressedChild,selectedChildId:y?.selectedChild})}let l=[],c=new Set;for(let s of e){let f=r.get(s.id?.id),h=(s.ui?.content?.children||[]).map(m=>r.get(m)).filter(Boolean);if(h.length){f.children=t?h.slice().reverse():h;for(let m of h)c.add(m.id)}}for(let s of e){let f=r.get(s.id?.id),h=s.ui?.content?.parent||0,m=r.get(h);m?c.has(f.id)||(t?m.children.unshift(f):m.children.push(f)):l.push(f)}for(let[s,f]of o){let h=[...r.values()].find(m=>m.id===s);for(let[m,p]of Object.entries(f))h[m]=n.get(p)||null}return{nodes:r,rootCandidates:l,warnings:a}}function Hr(e){let t=bi(e),i=ke.toObject(ke.decode(t),{longs:Number,enums:Number,bytes:Buffer,defaults:!1,arrays:!0,objects:!0}),n=i.graph||[];if(!n.some(y=>y.ui?.content))throw new Error("GIA \u4E0D\u542B\u53EF\u8BC6\u522B\u7684 UIControlGroup \u4E3B\u56FE");let r=n.find(y=>y.which===21)||null,o=n.filter(y=>Number(y.which)===70),a=i.accessories||[],l=new Set((r?.relatedIds||[]).map(y=>y.id||0)),c=r?l.size?a.filter(y=>l.has(y.id?.id||0)):a:[],s=o.length?[...o,...a.filter(y=>!l.has(y.id?.id||0))]:r?[]:[...n,...a];if(!c.length&&!s.length)throw new Error("GIA \u4E0D\u542B\u5BA2\u6237\u7AEF\u63A7\u4EF6");let f=["GIA \u5BFC\u5165\u4E3A\u5DF2\u9A8C\u8BC1 UI \u5B57\u6BB5\u7684\u8BED\u4E49\u5BFC\u5165\uFF1B\u672A\u77E5 protobuf \u5B57\u6BB5\u4E0D\u4F1A\u8FDB\u5165 Authoring JSON\u3002"],h=jr(i);f.push(...h.warnings);let m=null,p=null;if(c.length){let y=kr(c,{reverseSiblings:!0,idOffset:0});f.push(...y.warnings);let v=y.rootCandidates.find(x=>x.kind==="container")||y.rootCandidates[0];if(!v)throw new Error("GIA \u672A\u627E\u5230\u5BA2\u6237\u7AEF\u6839\u63A7\u4EF6");let E=H("server-container",{id:"sc1",guid:r?.id?.id||0,name:r?.name||"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u5BB9\u5668",giaRelatedGuids:(r?.ui?.content?.info||[]).find(x=>x.field501===4&&x.field502===4)?.related?.value||[]});E.children=[v],y.rootCandidates.length>1&&f.push(`\u68C0\u6D4B\u5230 ${y.rootCandidates.length} \u4E2A\u65E0\u7236\u8282\u70B9\u63A7\u4EF6\uFF0C\u4EC5\u5BFC\u5165\u4EE5\u201C${v.name}\u201D\u4E3A\u6839\u7684\u6811\u3002`),m={version:1,layoutSchemaVersion:pe,meta:{name:r?.name||"\u5BFC\u5165\u7684\u754C\u9762\u63A7\u4EF6\u7EC4",assetType:"server-control-template",sourceFormat:"gia",sourceFile:"",gameVersion:i.gameVersion||"",giaFilePath:i.filePath||"",...Number.isSafeInteger(Number(i.modeFlag))?{giaModeFlag:Number(i.modeFlag)}:{}},canvasId:"pc-16-9",selectedId:v.id,script:{controlId:v.id,path:"",source:""},root:E}}if(s.length){let y=kr(s,{reverseSiblings:!1,idOffset:1e3});if(f.push(...y.warnings),!y.rootCandidates.length)throw new Error("GIA \u672A\u627E\u5230\u5BA2\u6237\u7AEF\u6A21\u677F");let v=H("server-container",{id:"sc1",guid:0,name:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F"});v.children=y.rootCandidates,p={version:1,layoutSchemaVersion:pe,meta:{name:y.rootCandidates.length===1?y.rootCandidates[0].name:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u5217\u8868",assetType:"client-control-template",sourceFormat:"gia",sourceFile:"",gameVersion:i.gameVersion||"",giaFilePath:i.filePath||"",...Number.isSafeInteger(Number(i.modeFlag))?{giaModeFlag:Number(i.modeFlag)}:{}},canvasId:"pc-16-9",selectedId:y.rootCandidates[0].id,script:{controlId:y.rootCandidates[0].id,path:"",source:""},root:v},m||(m=p)}return{project:m,clientProject:p&&m!==p?p:void 0,scripts:h.scripts,warnings:f,metadata:{gameVersion:i.gameVersion||"",filePath:i.filePath||"",...Number.isSafeInteger(Number(i.modeFlag))?{modeFlag:Number(i.modeFlag)}:{},combined:!!(r&&o.length)}}}function Kr(e){let t=bi(e),i=ke.toObject(ke.decode(t),{longs:Number,enums:Number,defaults:!1,arrays:!0,objects:!0}),n=i.graph||[],r=i.accessories||[],o=[],a=(m,p)=>m!=null&&Object.prototype.hasOwnProperty.call(m,p),l=new Map,c=[];/^\d+-\d+-\d+-\\.+\.gia$/iu.test(i.filePath||"")||o.push(`Root.filePath \u4E0D\u662F UID-TIME-ID-\\\u6587\u4EF6\u540D.gia\uFF1A${i.filePath||"<missing>"}`);let s=n.filter(m=>m.which===70).map(m=>{let p=yi(m),y=m.ui?.content?.info||[],v=y.find($=>$.field501===2&&$.field502===6)?.index?.value,E=_r[p],x=y.find($=>$.field501===4&&$.field502===4),A=x?.related?.value||[];return(!Number.isSafeInteger(v)||v<=0)&&o.push(`${m.name}: Info.index=${v??"<missing>"}\uFF0C\u5FC5\u987B\u662F\u6B63\u6574\u6570`),x||o.push(`${m.name}: \u9876\u5C42 UIControlTemplate \u7F3A\u5C11 Info.related \u8BB0\u5F55`),{id:m.id?.id||0,name:m.name||"",kind:p,actualIndex:v,expectedIndex:E,relatedPresent:!!x,relatedGuids:A}});s.length||o.push("Root.graph \u4E0D\u542B UIControlTemplate(70)");let f=0,h=0;for(let m of[...n,...r]){if(!m.ui?.content)continue;let p=m.id?.id||0,y=m.ui.content,v=yi(m),E=n.includes(m)&&m.which===70,x=`${m.name||"<unnamed>"}(${p||"<missing-guid>"})`;!Number.isSafeInteger(p)||p<=0||p>2147483647?o.push(`${x}: GraphUnit GUID \u975E\u6CD5`):l.has(p)?o.push(`${x}: GUID \u4E0E ${l.get(p).name||"<unnamed>"} \u91CD\u590D`):l.set(p,m),(m.id?.class!==1||m.id?.type!==8)&&o.push(`${x}: GraphUnit.id \u5FC5\u987B\u4E3A class=1,type=8`),y.guid!==p&&o.push(`${x}: content.guid=${y.guid??"<missing>"} \u4E0E GraphUnit.id.id \u4E0D\u4E00\u81F4`),E&&m.which!==70&&o.push(`${x}: \u6A21\u677F\u6839 which \u5FC5\u987B\u4E3A UIControlTemplate(70)`),!E&&m.which!==15&&o.push(`${x}: \u9644\u4EF6\u63A7\u4EF6 which \u5FC5\u987B\u4E3A UIControl(15)`);let A=y.info||[],$=A.find(w=>w.field501===1&&w.field502===5),O=A.find(w=>w.field501===2&&w.field502===6);$?.guid?.value!==p&&o.push(`${x}: Info.self GUID \u7F3A\u5931\u6216\u4E0E\u81EA\u8EAB\u4E0D\u4E00\u81F4`),(!Number.isSafeInteger(O?.index?.value)||O.index.value<=0)&&o.push(`${x}: Info.index=${O?.index?.value??"<missing>"}\uFF0C\u5FC5\u987B\u662F\u6B63\u6574\u6570`);let J=A.find(w=>w.field501===4&&w.field502===4);E&&!J&&o.push(`${x}: \u9876\u5C42\u6A21\u677F\u7F3A\u5C11 Info.related \u8BB0\u5F55`),!E&&J&&o.push(`${x}: \u9644\u4EF6\u63A7\u4EF6\u4E0D\u5E94\u5199 Info.related`);let ee=Rr[v],Z=y.data||[],z=Z.map(w=>`${w.field501}/${w.field502}`),b=ee?.map(([w])=>w)||[];ee?JSON.stringify(z)!==JSON.stringify(b)&&o.push(`${x}: Data \u69FD\u4F4D\u987A\u5E8F ${z.join(",")}\uFF0C\u5E94\u4E3A ${b.join(",")}`):o.push(`${x}: \u672A\u77E5\u5BA2\u6237\u7AEF\u63A7\u4EF6\u7C7B\u578B ${v}`);for(let w=0;w<Math.min(Z.length,ee?.length||0);w+=1){let M=Z[w],[G,U,le]=ee[w];if(a(M,U)||o.push(`${x}: Data ${G} \u7F3A\u5C11 ${U} \u5206\u652F`),!le)continue;a(M.details,le)||o.push(`${x}: Details ${G} \u7F3A\u5C11 ${le} \u5206\u652F`);let X=Tr[G];(M.details?.field501!==X||M.details?.field502!==M.field502||M.details?.field503!==1)&&o.push(`${x}: Details ${G} \u6807\u8BB0\u5E94\u4E3A ${X}/${M.field502}/1`);let he=M.details?.nodeRef;(he?.class!==1||he?.type!==8||he?.id!==p)&&o.push(`${x}: Details ${G} node_ref \u672A\u6307\u5411\u81EA\u8EAB`)}let k=(m.ui.content.data||[]).find(w=>w.field501===4&&w.field502===86);k&&(a(k.field14,"field17")?f+=1:o.push(`${x}: \u7C7B\u578B Data \u7F3A\u5C11\u663E\u5F0F Field14.field17 \u7A7A\u4E32`),a(k.details?.field14,"field17")?f+=1:o.push(`${x}: \u7C7B\u578B Details \u7F3A\u5C11\u663E\u5F0F Field14.field17 \u7A7A\u4E32`));let S=(m.ui.content.data||[]).find(w=>w.details?.transform)?.details?.transform?.multiPlatform?.platforms||[];S.length!==4&&o.push(`${x}: \u591A\u5E73\u53F0\u53D8\u6362\u6570\u91CF=${S.length}\uFF0C\u5E94\u4E3A 4`);let I=S.map(w=>w.platformType||0);JSON.stringify(I)!==JSON.stringify([0,1,2,3])&&o.push(`${x}: \u5E73\u53F0\u987A\u5E8F ${I.join(",")}\uFF0C\u5E94\u4E3A 0,1,2,3`);let F=(m.ui.content.data||[]).find(w=>w.details?.transform)?.details?.transform;F?.multiPlatform?.field502!==Ut[v]&&o.push(`${x}: \u53D8\u6362 preset=${F?.multiPlatform?.field502??"<missing>"}\uFF0C${v} \u5E94\u4E3A ${Ut[v]}`);for(let w of S)a(w.transform,"field508")?h+=1:o.push(`${x}: RectTransform \u7F3A\u5C11\u663E\u5F0F field508 \u7A7A\u4E32`);c.push({id:p,name:m.name||"",kind:v,template:E,parent:y.parent||0,children:[...y.children||[]],relatedIds:(m.relatedIds||[]).map(w=>w.id||0),dataSignatures:z})}for(let m of c){let p=`${m.name||"<unnamed>"}(${m.id})`;if(JSON.stringify(m.relatedIds)!==JSON.stringify(m.children)&&o.push(`${p}: GraphUnit.relatedIds \u4E0E content.children \u4E0D\u4E00\u81F4`),m.template&&m.parent&&o.push(`${p}: \u9876\u5C42\u6A21\u677F\u4E0D\u5E94\u6709 parent`),!m.template){let y=l.get(m.parent);y?(y.ui?.content?.children||[]).includes(m.id)||o.push(`${p}: \u7236\u63A7\u4EF6 children \u672A\u53CD\u5411\u5305\u542B\u81EA\u8EAB`):o.push(`${p}: parent=${m.parent||"<missing>"} \u4E0D\u5B58\u5728`)}for(let y of m.children){let v=l.get(y);v?(v.ui?.content?.parent||0)!==m.id&&o.push(`${p}: child=${y} \u7684 parent \u672A\u6307\u56DE\u81EA\u8EAB`):o.push(`${p}: child=${y} \u4E0D\u5B58\u5728`)}}return{valid:o.length===0,errors:o,filePath:i.filePath||"",gameVersion:i.gameVersion||"",templateCount:s.length,accessoryCount:r.length,templates:s,units:c,explicitEmpty:{field17:f,rectField508:h}}}function ln(e){let t=bi(e),i=ke.toObject(ke.decode(t),{longs:Number,enums:Number,defaults:!1,arrays:!0,objects:!0}),n=(i.graph||[]).filter(w=>w.ui?.content&&Number(w.which)===21),r=(i.graph||[]).filter(w=>Number(w.which)===70),o=(i.graph||[]).filter(w=>Number(w.which)===It),a=(i.accessories||[]).filter(w=>w.ui?.content),l=[],c=(w,M)=>w!=null&&Object.prototype.hasOwnProperty.call(w,M);/^\d+-\d+-\d+-\\.+\.gia$/iu.test(i.filePath||"")||l.push(`Root.filePath \u4E0D\u662F UID-TIME-ID-\\\u6587\u4EF6\u540D.gia\uFF1A${i.filePath||"<missing>"}`),n.length!==1&&l.push(`\u670D\u52A1\u7AEF\u63A7\u4EF6\u6A21\u677F UIControlGroup \u6570\u91CF=${n.length}\uFF0C\u5E94\u4E3A 1`);let s=(i.graph||[]).filter(w=>{let M=Number(w.which);return M===It||M===70||M===21?!1:!w.ui?.content});s.length&&l.push(`Root.graph \u542B ${s.length} \u4E2A\u65E0\u6CD5\u8BC6\u522B\u7684\u975E\u63A7\u4EF6/\u975E\u811A\u672C\u5355\u5143`);let f=n[0];if(!f)return{valid:!1,errors:l,filePath:i.filePath||"",gameVersion:i.gameVersion||"",accessoryCount:a.length,controls:[],scriptCount:o.length,explicitEmpty:{field17:0,rectField508:0}};let h=[f,...a],m=new Map;for(let w of h){let M=w.id?.id||0,G=`${w.name||"<unnamed>"}(${M||"<missing-guid>"})`;!Number.isSafeInteger(M)||M<=0||M>2147483647?l.push(`${G}: GraphUnit GUID \u975E\u6CD5`):m.has(M)?l.push(`${G}: GUID \u91CD\u590D`):m.set(M,w),(w.id?.class!==1||w.id?.type!==8)&&l.push(`${G}: GraphUnit.id \u5FC5\u987B\u4E3A class=1,type=8`),w.ui?.content?.guid!==M&&l.push(`${G}: content.guid \u4E0E GraphUnit.id.id \u4E0D\u4E00\u81F4`)}let p=f.id?.id||0,y=f.ui.content,v=`${f.name||"<unnamed>"}(${p})`;f.which!==21&&l.push(`${v}: which \u5FC5\u987B\u4E3A UIControlGroup(21)`);let E=y.info||[];E.find(w=>w.field501===1&&w.field502===5)?.guid?.value!==p&&l.push(`${v}: Info.self GUID \u7F3A\u5931\u6216\u4E0D\u4E00\u81F4`),E.find(w=>w.field501===2&&w.field502===6)?.index?.value!==1&&l.push(`${v}: Info.index \u5FC5\u987B\u4E3A 1`);let x=E.find(w=>w.field501===4&&w.field502===4);x||l.push(`${v}: \u7F3A\u5C11\u663E\u5F0F Info.related \u8BB0\u5F55`);let A=0,$=0,O=(w,M,G,U=!1)=>{let le=w.id?.id||0,X=`${w.name||"<unnamed>"}(${le})`,he=w.ui.content.data||[],Je=he.map(ne=>`${ne.field501}/${ne.field502}`),pt=G.map(([ne])=>ne);JSON.stringify(Je)!==JSON.stringify(pt)&&l.push(`${X}: Data \u69FD\u4F4D\u987A\u5E8F ${Je.join(",")}\uFF0C\u5E94\u4E3A ${pt.join(",")}`);for(let ne=0;ne<Math.min(he.length,G.length);ne+=1){let _e=he[ne],[Ne,Nt,Ft]=G[ne];if(c(_e,Nt)||l.push(`${X}: Data ${Ne} \u7F3A\u5C11 ${Nt} \u5206\u652F`),!Ft)continue;c(_e.details,Ft)||l.push(`${X}: Details ${Ne} \u7F3A\u5C11 ${Ft} \u5206\u652F`);let Ge=Tr[Ne];(_e.details?.field501!==Ge||_e.details?.field502!==_e.field502||_e.details?.field503!==1)&&l.push(`${X}: Details ${Ne} \u6807\u8BB0\u5E94\u4E3A ${Ge}/${_e.field502}/1`);let Ot=_e.details?.nodeRef;(Ot?.class!==1||Ot?.type!==8||Ot?.id!==le)&&l.push(`${X}: Details ${Ne} node_ref \u672A\u6307\u5411\u81EA\u8EAB`)}let Mt=he.find(ne=>ne.field501===4&&ne.field502===(U?23:86)),te=U?"empty15":"field17";c(Mt?.field14,te)?U||(A+=1):l.push(`${X}: \u7C7B\u578B Data \u7F3A\u5C11\u663E\u5F0F Field14.${te} \u7A7A\u4E32`),c(Mt?.details?.field14,te)?U||(A+=1):l.push(`${X}: \u7C7B\u578B Details \u7F3A\u5C11\u663E\u5F0F Field14.${te} \u7A7A\u4E32`);let Ae=he.find(ne=>ne.details?.transform)?.details?.transform,Ze=Ae?.multiPlatform?.platforms||[];Ze.length!==4&&l.push(`${X}: \u591A\u5E73\u53F0\u53D8\u6362\u6570\u91CF=${Ze.length}\uFF0C\u5E94\u4E3A 4`);let si=Ze.map(ne=>ne.platformType||0);JSON.stringify(si)!==JSON.stringify([0,1,2,3])&&l.push(`${X}: \u5E73\u53F0\u987A\u5E8F ${si.join(",")}\uFF0C\u5E94\u4E3A 0,1,2,3`);let ui=U?Ut["server-container"]:Ut[M];Ae?.multiPlatform?.field502!==ui&&l.push(`${X}: \u53D8\u6362 preset=${Ae?.multiPlatform?.field502??"<missing>"}\uFF0C\u5E94\u4E3A ${ui}`);for(let ne of Ze)c(ne.transform,"field508")?$+=1:l.push(`${X}: RectTransform \u7F3A\u5C11\u663E\u5F0F field508 \u7A7A\u4E32`);return Je};O(f,"server-container",Ha,!0);let J=(f.relatedIds||[]).map(w=>w.id||0),ee=new Set(J),Z=a.filter(w=>ee.has(w.id?.id||0)),z=Z.map(w=>w.id?.id||0);JSON.stringify(J)!==JSON.stringify(z)&&l.push(`${v}: \u4E3B\u56FE relatedIds \u5FC5\u987B\u6309\u987A\u5E8F\u8986\u76D6\u672C\u7EC4 accessories`);let b=y.data?.find(w=>w.details?.rootChildRef)?.details?.rootChildRef?.guid||0,k=m.get(b);(!k||!Z.includes(k))&&l.push(`${v}: 62/82 \u6839\u8282\u70B9\u5F15\u7528\u4E0D\u5B58\u5728`),z[0]!==b&&l.push(`${v}: \u6839\u5BB9\u5668\u8282\u70B9\u5FC5\u987B\u662F\u672C\u7EC4 accessories[0]`);let S=[];for(let w of Z){let M=w.id?.id||0,G=w.ui.content,U=`${w.name||"<unnamed>"}(${M})`,le=yi(w);w.which!==15&&l.push(`${U}: which \u5FC5\u987B\u4E3A UIControl(15)`);let X=G.info||[];(X.length!==1||X[0]?.field501!==1||X[0]?.field502!==5||X[0]?.guid?.value!==M)&&l.push(`${U}: \u670D\u52A1\u7AEF\u5BB9\u5668\u5185\u63A7\u4EF6 Info \u5FC5\u987B\u53EA\u542B\u81EA\u8EAB GUID`);let he=Rr[le];he||l.push(`${U}: \u672A\u77E5\u5BA2\u6237\u7AEF\u63A7\u4EF6\u7C7B\u578B ${le}`);let Je=he?O(w,le,he):[];S.push({id:M,name:w.name||"",kind:le,parent:G.parent||0,children:[...G.children||[]],relatedIds:(w.relatedIds||[]).map(pt=>pt.id||0),dataSignatures:Je})}let I=S.find(w=>w.id===b);I&&(I.kind!=="container"&&l.push(`${I.name}(${b}): \u6839\u63A7\u4EF6\u5FC5\u987B\u4E3A\u5BB9\u5668\u8282\u70B9`),I.parent&&l.push(`${I.name}(${b}): \u6839\u63A7\u4EF6\u4E0D\u5E94\u6709 parent`));let F=new Map(S.map(w=>[w.id,w]));for(let w of S){let M=`${w.name}(${w.id})`;if(JSON.stringify(w.relatedIds)!==JSON.stringify(w.children)&&l.push(`${M}: relatedIds \u5FC5\u987B\u4E0E\u76F4\u63A5 children \u4E00\u81F4`),w.id!==b){let G=F.get(w.parent);G?G.children.includes(w.id)||l.push(`${M}: \u7236\u63A7\u4EF6 children \u672A\u53CD\u5411\u5305\u542B\u81EA\u8EAB`):l.push(`${M}: parent=${w.parent||"<missing>"} \u4E0D\u5B58\u5728`)}for(let G of w.children){let U=F.get(G);U?U.parent!==w.id&&l.push(`${M}: child=${G} \u7684 parent \u672A\u6307\u56DE\u81EA\u8EAB`):l.push(`${M}: child=${G} \u4E0D\u5B58\u5728`)}}return{valid:l.length===0,errors:l,filePath:i.filePath||"",gameVersion:i.gameVersion||"",graph:{id:p,name:f.name||"",relatedGuids:x?.related?.value||[],rootGuid:b},accessoryCount:a.length,controls:S,scriptCount:o.length,explicitEmpty:{field17:A,rectField508:$}}}function qr(e,t=[]){if(!e||e.layoutSchemaVersion===pe)return e;if(e.layoutSchemaVersion!==void 0&&e.layoutSchemaVersion!==1)throw new Error(`\u4EC5\u652F\u6301 layoutSchemaVersion=2 \u6216\u53EF\u8FC1\u79FB\u7684\u65E7\u5E03\u5C40\uFF0C\u6536\u5230 ${e.layoutSchemaVersion}`);if(!e.root)return{...e,layoutSchemaVersion:pe};let i=structuredClone(e),n=0;return L(i.root,r=>{let o=r.transformByPlatform||{},a=r.transformByCanvas||{},l=r.name||r.id;for(let s of Object.keys(o))if(!se.includes(s))throw new Error(`${l}: unknown platform ${s}`);let c={};for(let s of se){let f=gt[s],h=ie[f].platform,m=Object.keys(ie).filter(E=>ie[E].platform===h&&a[E]),p=a[f]?f:m[0],y=s==="CONTROLLER_CONSOLE"?c.KEYBOARD:s==="CONTROLLER_MOBILE"?c.TOUCHSCREEN:null,v=o[s]??y??(p?a[p]:null);if(c[s]=v?Te(v):Li(r.kind),v||t.push(`${l}: ${s} \u65E0\u65E7\u5E03\u5C40\uFF0C\u5DF2\u4F7F\u7528\u63A7\u4EF6\u9ED8\u8BA4\u503C`),!o[s]&&!y&&p&&p!==f&&t.push(`${l}: \u7F3A\u5C11 ${f}\uFF0C\u5DF2\u91C7\u7528 ${p} \u7684\u951A\u70B9\u548C\u5C3A\u5BF8\u53C2\u6570`),!y)for(let E of m)JSON.stringify(c[s])!==JSON.stringify(Te(a[E]))&&t.push(`${l}: ${E} \u4E0E ${s} \u5E03\u5C40\u51B2\u7A81\uFF0C\u4FDD\u7559${o[s]?"\u5DF2\u6709\u5E73\u53F0":p}\u53C2\u6570`)}Ve(c,`${l}.transformByPlatform`),r.transformByPlatform=c,delete r.transformByCanvas,n++}),i.layoutSchemaVersion=pe,t.unshift(`\u5DF2\u81EA\u52A8\u8FC1\u79FB\u65E7\u5E03\u5C40\uFF1A${n} \u4E2A\u63A7\u4EF6\u8F6C\u6362\u4E3A\u56DB\u5E73\u53F0\u53C2\u6570\uFF1B\u518D\u6B21\u4FDD\u5B58\u5C06\u4F7F\u7528\u65B0\u7248\u683C\u5F0F`),i}function sn(e){if(![1,2,3,4].includes(e))throw new Error(`\u4EC5\u652F\u6301 version=1\u20134 \u7684\u5B58\u6863\uFF0C\u6536\u5230 ${e}`)}function cn(e,t,i,n=e.canvasId){let r=Be(e.root,t);return!r||r.kind==="server-container"?ye(n):i[r.id]||ye(n)}function He(e,{warnings:t=[]}={}){if(!e)return nt();if(e=qr(e,t),(e.root||e.layoutSchemaVersion!==void 0)&&e.layoutSchemaVersion!==pe)throw new Error(`\u4EC5\u652F\u6301 layoutSchemaVersion=${pe} \u7684\u56DB\u5E73\u53F0\u5E03\u5C40\uFF0C\u4E0D\u652F\u6301\u65E7\u753B\u5E03\u5E03\u5C40\u6216\u5176\u4ED6\u7248\u672C`);let i=e.meta?.assetType==="client-control-template"?"client-control-template":"server-control-template",n=i==="client-control-template"?Ct():nt(),r={layoutSchemaVersion:pe,version:Number.isSafeInteger(e.version)&&e.version>0?e.version:1,meta:{name:String(e.meta?.name||n.meta.name),assetType:i,sourceFormat:String(e.meta?.sourceFormat||n.meta.sourceFormat),sourceFile:String(e.meta?.sourceFile||""),...e.meta?.gameVersion?{gameVersion:String(e.meta.gameVersion)}:{},...e.meta?.giaFilePath?{giaFilePath:String(e.meta.giaFilePath)}:{},...Number.isSafeInteger(Number(e.meta?.giaOwnerUid))?{giaOwnerUid:Number(e.meta.giaOwnerUid)}:{},...Number.isSafeInteger(Number(e.meta?.giaTimestamp))?{giaTimestamp:Number(e.meta.giaTimestamp)}:{},...Number.isSafeInteger(Number(e.meta?.giaFileId))?{giaFileId:Number(e.meta.giaFileId)}:{},...e.meta?.giaFileName?{giaFileName:String(e.meta.giaFileName)}:{},...Number.isSafeInteger(Number(e.meta?.giaModeFlag))&&Number(e.meta.giaModeFlag)>=0?{giaModeFlag:Number(e.meta.giaModeFlag)}:{}},canvasId:e.canvasId&&ie[e.canvasId]?e.canvasId:ci,selectedId:e.selectedId||n.selectedId,root:Zi(e.root||n.root)};return Qr(r),r}function Qr(e){let t=new Set;L(e.root,i=>{if(typeof i.id!="string"||!i.id)throw new Error("node id must be a non-empty string");if(t.has(i.id))throw new Error(`duplicate node id: ${i.id}`);t.add(i.id)}),t.has(e.selectedId)||(e.selectedId=Ji(e.root).id)}function Lr(e){return Ye(wt(e))}function rl(e,t){let i=!1;return L(e,n=>{n.id===t&&(i=!0)}),i}function ol(e,t,i,n){let o=je(e.root,e.canvasId).boxes[t.id],a=i.children.findIndex(h=>h.id===t.id);if(a<0)throw new Error("reparent: source node is not attached");if(i.children.splice(a,1),n.children.push(t),!o)return;let l=je(e.root,e.canvasId),c=n.kind==="server-container"?ye(e.canvasId):l.boxes[n.id]||ye(e.canvasId),s=Ue(t.transformByPlatform,e.canvasId),f=Qe(c,s,{posX:o.centerX,posY:o.centerY,width:o.width,height:o.height});xt(e,t,f)}function al(e,t){return e.meta.assetType!=="client-control-template"?Qi(e.root,t):(e.root.children||[]).flatMap(i=>Qi(i,t))}function eo(e,t){let i=Cr(e.root,t);if(e.meta.assetType!=="client-control-template")return i;let n=Bt(e),r=new Set;return n&&n.kind!=="server-container"&&L(n,o=>r.add(o.id)),i.filter(o=>r.has(o.id))}function to(e){let{canvas:t,boxes:i}=je(e.root,e.canvasId),n=Xt(e),r=ce(e.root,e.selectedId),o=r?i[r.id]:null;return D({layoutSchemaVersion:pe,version:e.version,meta:{...e.meta},canvasId:e.canvasId,canvas:{id:e.canvasId,width:t.width,height:t.height,platform:ie[e.canvasId].platform,label:ie[e.canvasId].label,presets:Object.values(ie).map(a=>({id:a.id,label:a.label,width:a.width,height:a.height,platform:a.platform}))},selectedId:e.selectedId,asset:{type:e.meta.assetType,label:e.meta.assetType==="client-control-template"?"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F":"\u670D\u52A1\u7AEF\u63A7\u4EF6\u6A21\u677F",templateCount:e.meta.assetType==="client-control-template"?e.root.children.length:1,currentTemplateId:e.meta.assetType==="client-control-template"&&Bt(e)?.id||""},tree:al(e,n),boxes:eo(e,i),inspector:Ir(r,e.canvasId,o||t,n),root:e.root})}function xt(e,t,i){let n=je(e.root,e.canvasId),r=cn(e,t.id,n.boxes),o={};if(t.syncAllDevices!==!1)for(let a of se){if(a===et(e.canvasId))continue;let l=gt[a],c=je(e.root,l,a);o[a]=cn(e,t.id,c.boxes,l)}t.transformByPlatform=wr({transformByPlatform:t.transformByPlatform,source:i,canvasId:e.canvasId,syncAllDevices:t.syncAllDevices!==!1,sourceParentBox:r,targetParentBoxByPlatform:o})}var ll=new Set(["name","active","visible","canControllerFocus","isolateNavigation","disableKeyEventPassthrough","disableCursorEventPassthrough","showCursor","fontSize","adaptiveFontSize","minimumFontSize","fontColor","bgColor","enableOutline","outlineColor","horizontalAlignment","verticalAlignment","text","imageId","imageColor","enableMask","enableSoftEdge","softEdgeMode","softEdgeWidthX","softEdgeWidthY","horizontalSoftRange","verticalSoftRange","enableFill","fillType","fillHorizontalType","fillVerticalType","fillRadial90Type","fillRadialType","fillAmount","reverseMaskArea","raycastTarget","interactable","clickAudioId","unavailableChildId","hoverChildId","pressedChildId","selectedChildId","showScrollBar","cellSizeX","cellSizeY","spacingX","spacingY","padding1X","padding1Y","padding2X","padding2Y","previewCount","scrollDirection","layoutConstraint","referencedPrefabId","animationId","keyboardKeyCode","controllerKeyCode","itemPrefabId","layoutConstraintFixedCount"]),sl=new Set(["posX","posY","width","height"]),ul=new Set(["anchorMinX","anchorMinY","anchorMaxX","anchorMaxY","pivotX","pivotY"]);function cl(e){if(typeof e=="number"&&Number.isFinite(e))return e>>>0;if(typeof e=="string"){let t=e.trim();if(t.startsWith("#")){let n=t.slice(1);if(n.length===6)return(4278190080|parseInt(n,16))>>>0;if(n.length===8)return parseInt(n,16)>>>0}let i=Number(t);if(Number.isFinite(i))return i>>>0}throw new Error("color must be an ARGB integer or #RRGGBB/#AARRGGBB string")}function ze(e,t){let i=Number(e);if(!Number.isFinite(i))throw new Error(`${t} must be a finite number`);return i}function Wr(e){if(e===!0||e===1||e==="1"||e==="true")return!0;if(e===!1||e===0||e==="0"||e==="false")return!1;throw new Error("boolean field requires true or false")}var fl=new Set(["fontSize","minimumFontSize","imageId","clickAudioId","softEdgeWidthX","softEdgeWidthY","horizontalSoftRange","verticalSoftRange","fillAmount","cellSizeX","cellSizeY","spacingX","spacingY","padding1X","padding1Y","padding2X","padding2Y","previewCount","keyboardKeyCode","controllerKeyCode","itemPrefabId","layoutConstraintFixedCount"]),dl=new Set(["active","visible","canControllerFocus","isolateNavigation","disableKeyEventPassthrough","disableCursorEventPassthrough","showCursor","adaptiveFontSize","enableOutline","enableMask","enableSoftEdge","enableFill","reverseMaskArea","raycastTarget","interactable","showScrollBar"]),hl=new Set(["name","horizontalAlignment","verticalAlignment","text","softEdgeMode","fillType","fillHorizontalType","fillVerticalType","fillRadial90Type","fillRadialType","scrollDirection","layoutConstraint","referencedPrefabId","animationId"]),Jr=new Set(["unavailableChildId","hoverChildId","pressedChildId","selectedChildId"]),Zr={scrollDirection:["Horizontal","Vertical"],layoutConstraint:["AutoWrap","Fixed"],softEdgeMode:["Percentage","Pixel"],fillType:["Horizontal","Vertical","Radial90","Radial180","Radial360"],fillHorizontalType:["Left","Right"],fillVerticalType:["Bottom","Top"],fillRadial90Type:["BottomLeft","TopLeft","TopRight","BottomRight"],fillRadialType:["Bottom","Left","Top","Right"]};function ml(e,t){if(!t||typeof t!="object")throw new Error("patch requires op");let i=t.op;if(i==="select")return t.id&&ce(e.root,t.id)&&(e.selectedId=t.id),e;if(i==="pick"){let{boxes:n}=je(e.root,e.canvasId),r=eo(e,n),o=xr(r,Number(t.x),Number(t.y));return o&&(e.selectedId=o),e}if(i==="setCanvas")return t.canvasId&&ie[t.canvasId]&&(e.canvasId=t.canvasId),e;if(i==="setScript")throw new Error("\u811A\u672C\u7531\u5B58\u6863\u7EDF\u4E00\u7BA1\u7406\uFF0C\u8BF7\u4F7F\u7528 addScript / updateScript / removeScript \u64CD\u4F5C");if(i==="newAsset"){let n=t.assetType==="client-control-template"?Ct():nt();return e.version=n.version,e.meta=n.meta,e.canvasId=n.canvasId,e.selectedId=n.selectedId,e.root=n.root,e}if(i==="addTemplate"){if(e.meta.assetType!=="client-control-template")throw new Error("\u53EA\u6709\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u5DE5\u7A0B\u53EF\u4EE5\u65B0\u589E\u6A21\u677F");let n=H(t.kind,{id:Wi(e.root),guid:Lr(e.root),name:t.name||`\u65B0${t.kind==="container"?"\u5BB9\u5668\u8282\u70B9":t.kind}\u6A21\u677F`});return e.root.children.push(n),e.selectedId=n.id,e}if(i==="add"){let n=ce(e.root,t.parentId||e.selectedId);if(!n)throw new Error("add: parent not found");let r=br(n,t.kind,{id:Wi(e.root),guid:Lr(e.root),name:t.name});return e.selectedId=r.id,e}if(i==="reparent"){if(e.meta.assetType!=="client-control-template")throw new Error("\u5C42\u7EA7\u8C03\u6574\u4EC5\u9002\u7528\u4E8E\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u5DE5\u7A0B");let n=ce(e.root,t.id||e.selectedId),r=n?Be(e.root,n.id):null,o=ce(e.root,t.parentId);if(!n||n.kind==="server-container"||!r)throw new Error("reparent: node not found");if(!o)throw new Error("reparent: parent not found");if(o.id===n.id||rl(n,o.id))throw new Error("\u63A7\u4EF6\u4E0D\u80FD\u79FB\u52A8\u5230\u81EA\u8EAB\u6216\u5176\u540E\u4EE3\u4E0B\u9762");if(o.kind==="server-container"&&r.kind==="server-container")return e;if(r.kind==="server-container"&&o.kind!=="server-container"&&e.root.children.length<=1)throw new Error("\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u5217\u8868\u81F3\u5C11\u4FDD\u7559\u4E00\u4E2A\u9876\u5C42\u6A21\u677F");return ol(e,n,r,o),e.selectedId=n.id,e}if(i==="moveSibling"){let n=ce(e.root,t.id||e.selectedId),r=n?Be(e.root,n.id):null;if(!n||!r)throw new Error("moveSibling: node not found");let o=r.children.findIndex(c=>c.id===n.id),a=t.direction==="up"?-1:t.direction==="down"?1:0,l=o+a;return!a||l<0||l>=r.children.length||(r.children.splice(o,1),r.children.splice(l,0,n),e.selectedId=n.id),e}if(i==="remove"){let n=t.id||e.selectedId,r=Be(e.root,n);if(r?.kind==="server-container"){if(e.meta.assetType!=="client-control-template")throw new Error("\u670D\u52A1\u7AEF\u63A7\u4EF6\u6A21\u677F\u7684\u5BA2\u6237\u7AEF\u6839\u8282\u70B9\u4E0D\u80FD\u5220\u9664");if((e.root.children||[]).length<=1)throw new Error("\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u5217\u8868\u81F3\u5C11\u4FDD\u7559\u4E00\u4E2A\u6A21\u677F")}return vr(e.root,n)&&(L(e.root,o=>{if(o.kind==="button")for(let a of Jr)o[a]&&!ce(e.root,o[a])&&(o[a]=null)}),e.selectedId=r?r.id:e.root.id),e}if(i==="set"){let n=ce(e.root,t.id||e.selectedId);if(!n)throw new Error("set: node not found");let r=t.key;r==="reverseMask"&&(r="reverseMaskArea");let o=t.value;if(r.startsWith("giaRaw.")){let s=r.slice(7);if(!s||s.includes("."))throw new Error("invalid raw GIA field path");let f=pr(n.kind,s);if(!f)throw new Error(`unknown raw GIA field for ${n.kind}: ${s}`);if(n.giaRaw||={},n.giaRaw[s]=Xi(f,o),s==="footerField505"&&[0,1].includes(n.giaRaw[s])&&(n.canControllerFocus=n.giaRaw[s]===1),n.kind==="cursor"&&s==="cursorField501"&&[0,1].includes(n.giaRaw[s])&&(n.raycastTarget=n.giaRaw[s]===1),(n.kind==="textbox"||n.kind==="textwindow")&&s==="textAlign"){let h={0:"Left",1:"Middle",2:"Right"}[n.giaRaw[s]];h&&(n.horizontalAlignment=h)}if(n.kind==="image"&&s==="imageFillType"){let h={1:"Horizontal",2:"Vertical",3:"Radial90",4:"Radial180",5:"Radial360"}[n.giaRaw[s]];h&&(n.fillType=h)}return n.kind==="keyhint"&&s==="keyHintField502"&&(n.keyboardKeyCode=n.giaRaw[s]),n.kind==="keyhint"&&s==="keyHintField501"&&(n.controllerKeyCode=n.giaRaw[s]),e}if(r==="syncAllDevices"){if(n.syncAllDevices=Wr(o),n.syncAllDevices){let s=Ue(n.transformByPlatform,e.canvasId);xt(e,n,s)}return e}if(ll.has(r)){if(r.endsWith("Color")&&(o=cl(o)),fl.has(r)){if(o=ze(o,r),o<0)throw new Error(`${r} must not be negative`);if((r==="imageId"||r==="clickAudioId"||r==="keyboardKeyCode"||r==="controllerKeyCode")&&(o=Math.trunc(o)),r==="fillAmount"&&o>1)throw new Error("fillAmount must be between 0 and 1")}if(dl.has(r)&&(o=Wr(o)),hl.has(r)&&(o=String(o??"")),r==="horizontalAlignment"&&!["Left","Middle","Right"].includes(o))throw new Error("invalid horizontalAlignment");if(r==="verticalAlignment"&&!["Top","Middle","Bottom"].includes(o))throw new Error("invalid verticalAlignment");if(Zr[r]&&!Zr[r].includes(o))throw new Error(`invalid ${r}`);if(Jr.has(r))if(o===""||o===void 0||o===null)o=null;else{o=String(o);let s=ce(e.root,o);if(!s||s===n||s.kind==="server-container"||!(n.children||[]).some(f=>f.id===o))throw new Error(`${r} must reference a direct child of this button`)}if(n[r]=o,r==="canControllerFocus"&&(n.giaRaw.footerField505=o?1:0),n.kind==="cursor"&&r==="raycastTarget"&&(n.giaRaw.cursorField501=o?1:0),(n.kind==="textbox"||n.kind==="textwindow")&&r==="horizontalAlignment"&&(n.giaRaw.textAlign={Left:0,Middle:1,Right:2}[o]),(n.kind==="textbox"||n.kind==="textwindow")&&r==="verticalAlignment"&&delete n.giaRaw.textVerticalAlign,n.kind==="image"&&r==="fillType"){let s={Horizontal:1,Vertical:2,Radial90:3,Radial180:4,Radial360:5}[o];s&&(n.giaRaw.imageFillType=s)}return n.kind==="reference"&&r==="referencedPrefabId"&&(n.giaRaw.templateRefSlot=o),n.kind==="grid"&&r==="previewCount"&&(n.giaRaw.gridField511=Math.trunc(o)),n.kind==="keyhint"&&r==="keyboardKeyCode"&&(n.giaRaw.keyHintField502=Math.trunc(o)),n.kind==="keyhint"&&r==="controllerKeyCode"&&(n.giaRaw.keyHintField501=Math.trunc(o)),(n.kind==="animation"||n.kind==="fullscreen")&&r==="animationId"&&(n.giaRaw[n.kind==="animation"?"effectSlot":"fullscreenEffectSlot"]=o),e}let{boxes:a}=je(e.root,e.canvasId),l=cn(e,n.id,a),c=Ue(n.transformByPlatform,e.canvasId);if(r==="anchorType"){let s=un(a[n.id]),f=cr(c,o);return f=Qe(l,f,s),xt(e,n,f),e}if(r==="rotationZ"){let s={...c,rotation:{...c.rotation,z:ze(o,r)}};return xt(e,n,s),e}if(ul.has(r)){let s=un(a[n.id]),f={...c,anchorMin:{...c.anchorMin},anchorMax:{...c.anchorMax},pivot:{...c.pivot}};return r==="anchorMinX"&&(f.anchorMin.x=ze(o,r)),r==="anchorMinY"&&(f.anchorMin.y=ze(o,r)),r==="anchorMaxX"&&(f.anchorMax.x=ze(o,r)),r==="anchorMaxY"&&(f.anchorMax.y=ze(o,r)),r==="pivotX"&&(f.pivot.x=ze(o,r)),r==="pivotY"&&(f.pivot.y=ze(o,r)),xt(e,n,Qe(l,f,s)),e}if(sl.has(r)){let s=un(a[n.id]),f=ze(o,r);if((r==="width"||r==="height")&&f<0)throw new Error(`${r} must not be negative`);return s[r]=f,xt(e,n,Qe(l,c,s)),e}throw new Error(`set: unknown key ${r}`)}if(i==="replace"){let n=He(t.project);return e.version=n.version,e.meta=n.meta,e.canvasId=n.canvasId,e.selectedId=n.selectedId,e.root=n.root,e}throw new Error(`unknown op ${i}`)}function fn(e,t){if(!t||typeof t!="object")throw new Error("patch requires op");if(t.expectedRevision!==void 0&&Number(t.expectedRevision)!==e.version)throw new Error(`revision conflict: expected ${t.expectedRevision}, current ${e.version}`);let i=e.version,n=JSON.parse(JSON.stringify(e));return ml(n,t),Qr(n),n.version=i+1,Object.keys(e).forEach(r=>{delete e[r]}),Object.assign(e,n),e}function un(e){return e?{posX:e.centerX,posY:e.centerY,width:e.width,height:e.height}:{posX:0,posY:0,width:0,height:0}}import pl from"fengari";var{lua:u,lauxlib:W,lualib:io,to_luastring:vi,to_jsstring:gl}=pl,yl=u.LUA_TNIL,bl=u.LUA_TBOOLEAN,vl=u.LUA_TNUMBER,Sl=u.LUA_TSTRING,no=u.LUA_TTABLE,wl=u.LUA_TFUNCTION,dn=u.LUA_TUSERDATA,Ee=u.LUA_OK,ro=new WeakMap,hn=Symbol("luaTableEntries"),mn={__scriptHostKey:!0};function R(e){return vi(String(e))}function rt(e,t){ro.set(e,t)}function Ce(e){return ro.get(e)}var Ht=class{constructor(t){this.value=t}};function ae(e,t,i){if(i instanceof Ht){u.lua_pushnumber(e,i.value);return}if(i==null){u.lua_pushnil(e);return}let n=typeof i;if(n==="boolean"){u.lua_pushboolean(e,i);return}if(n==="number"){Number.isInteger(i)&&Math.abs(i)<=2147483647?u.lua_pushinteger(e,i):u.lua_pushnumber(e,i);return}if(n==="string"){u.lua_pushstring(e,R(i));return}if(n==="function"){xl(e,t,i);return}if(i&&i[hn]){let r=i[hn];u.lua_createtable(e,Array.isArray(i)?i.length:0,r.length);for(let[o,a]of r)ae(e,t,o),ae(e,t,a),u.lua_settable(e,-3);return}if(Array.isArray(i)){u.lua_createtable(e,i.length,0);for(let r=0;r<i.length;r++)ae(e,t,i[r]),u.lua_rawseti(e,-2,r+1);return}if(i&&i.__kind==="EnumItem"){t.pushEnumItem(e,i);return}if(i&&i.__kind==="CursorEventData"){t.pushCursor(e,i);return}if(i&&i.__kind==="Script"){t.pushScript(e,i);return}if(i&&i.typeofName){t.pushControl(e,i);return}if(i&&i.__kind==="ServerSignal"){t.pushSignal(e,i);return}if(i&&(i.SetEase||i.Append)){t.pushTween(e,i);return}if(n==="object"){u.lua_createtable(e,0,Object.keys(i).length);for(let[r,o]of Object.entries(i))ae(e,t,o),u.lua_setfield(e,-2,R(r));return}u.lua_pushnil(e)}function q(e,t){if(u.lua_isnil(e,t)||u.lua_type(e,t)===u.LUA_TNONE)return"";if(!u.lua_isstring(e,t)&&u.lua_type(e,t)!==u.LUA_TNUMBER)return`lua_type=${u.lua_type(e,t)}`;let i=u.lua_tostring(e,t);return i==null?"":gl(i)}function De(e,t){t=u.lua_absindex(e,t);let i=u.lua_type(e,t);if(i===dn)return Ce(u.lua_touserdata(e,t));if(i===no){u.lua_pushlightuserdata(e,mn),u.lua_rawget(e,t);let n=u.lua_type(e,-1)===dn?u.lua_touserdata(e,-1):null;return u.lua_pop(e,1),n?Ce(n):null}return null}function de(e,t,i){i=u.lua_absindex(e,i);let n=u.lua_type(e,i);if(n===yl)return null;if(n===bl)return!!u.lua_toboolean(e,i);if(n===vl)return u.lua_isinteger(e,i)?u.lua_tointeger(e,i):u.lua_tonumber(e,i);if(n===Sl)return q(e,i);if(n===dn){let r=u.lua_touserdata(e,i);return Ce(r)??r}if(n===wl)return Cl(e,t,i);if(n===no){let r=De(e,i);if(r)return r;let o=[];for(u.lua_pushnil(e);u.lua_next(e,i)!==0;){let s=de(e,t,-2),f=de(e,t,-1);o.push([s,f]),u.lua_pop(e,1)}let a=new Map(o.filter(([s])=>Number.isInteger(s)&&s>=1)),l=0;for(;a.has(l+1);)l+=1;let c=l>0?[]:{};for(let[s,f]of o)Array.isArray(c)&&Number.isInteger(s)&&s>=1?c[s-1]=f:(typeof s=="string"||typeof s=="number")&&(c[s]=f);return Object.defineProperty(c,hn,{value:o}),c}return null}function Cl(e,t,i){t.luaFunctions||(t.luaFunctions=new Map);let n=typeof u.lua_topointer=="function"?u.lua_topointer(e,i):null;if(n!=null&&t.luaFunctions.has(n))return t.luaFunctions.get(n);u.lua_pushvalue(e,i);let r=W.luaL_ref(e,u.LUA_REGISTRYINDEX),o=Il(e,t,r);return n!=null&&t.luaFunctions.set(n,o),o}function Il(e,t,i){let n=(...r)=>{if(n.__luaRef==null)throw new Error("attempt to call a released Lua callback");let o=u.lua_gettop(e);u.lua_rawgeti(e,u.LUA_REGISTRYINDEX,n.__luaRef);for(let s of r)ae(e,t,s);if(u.lua_pcall(e,r.length,u.LUA_MULTRET,0)!==Ee){let s=q(e,-1);throw u.lua_settop(e,o),new Error(s)}let l=u.lua_gettop(e)-o,c=[];for(let s=1;s<=l;s++)c.push(de(e,t,o+s));if(u.lua_settop(e,o),c.length!==0)return c.length===1?c[0]:c};return n.__luaRef=i,n.__luaState=e,n}function oo(e){e?.__luaRef!=null&&(e.__luaHolds=(e.__luaHolds||0)+1)}function ao(e,t){if(!t||t.__luaRef==null||!t.__luaState)return;if(t.__luaHolds>1){t.__luaHolds-=1;return}let i=t.__luaState;if((!e?.luaStates||e.luaStates.has(i))&&W.luaL_unref(i,u.LUA_REGISTRYINDEX,t.__luaRef),t.__luaRef=null,t.__luaState=null,e?.luaFunctions)for(let[n,r]of e.luaFunctions)r===t&&e.luaFunctions.delete(n)}function xl(e,t,i){u.lua_pushlightuserdata(e,i),u.lua_pushlightuserdata(e,t),u.lua_pushcclosure(e,function(r){let o=u.lua_touserdata(r,u.lua_upvalueindex(1)),a=u.lua_touserdata(r,u.lua_upvalueindex(2)),l=u.lua_gettop(r),c=[];for(let s=1;s<=l;s++)c.push(de(r,a,s));try{let s=o(...c);if(Array.isArray(s)&&s.__multi){for(let f of s)ae(r,a,f);return s.length}return s===void 0?0:(ae(r,a,s),1)}catch(s){return u.lua_pushstring(r,R(String(s&&s.message?s.message:s))),u.lua_error(r)}},2)}function lo(e){!e||typeof u.lua_close!="function"||u.lua_close(e)}function so(e){if(W.luaL_loadstring(e,R(["local nativeGetMetatable = getmetatable","getmetatable = function(value)",' if type(value) == "string" then return nil end'," return nativeGetMetatable(value)","end"].join(`
107
+ `)))===Ee&&u.lua_pcall(e,0,0,0),u.lua_settop(e,0),u.lua_pushnil(e),u.lua_setglobal(e,R("_VERSION")),u.lua_getglobal(e,R("string")),!u.lua_isnil(e,-1))for(let i of["dump","pack","unpack"])u.lua_pushnil(e),u.lua_setfield(e,-2,R(i));if(u.lua_pop(e,1),u.lua_pushnil(e),u.lua_setglobal(e,R("io")),u.lua_getglobal(e,R("os")),!u.lua_isnil(e,-1))for(let i of Object.keys({execute:1,getenv:1,remove:1,rename:1,tmpname:1,setlocale:1,exit:1}))u.lua_pushnil(e),u.lua_setfield(e,-2,R(i));u.lua_pop(e,1),u.lua_getglobal(e,R("debug")),u.lua_isnil(e,-1)?u.lua_pop(e,1):(u.lua_getfield(e,-1,R("traceback")),u.lua_newtable(e),u.lua_pushvalue(e,-2),u.lua_setfield(e,-2,R("traceback")),u.lua_setglobal(e,R("debug")),u.lua_pop(e,2)),u.lua_getglobal(e,R("math")),u.lua_isnil(e,-1)||(u.lua_pushcfunction(e,i=>{let n=u.lua_tonumber(i,1);return u.lua_pushboolean(i,Number.isNaN(n)),1}),u.lua_setfield(e,-2,R("isnan")),u.lua_pushcfunction(e,i=>{let n=u.lua_tonumber(i,1);return u.lua_pushboolean(i,n===1/0||n===-1/0),1}),u.lua_setfield(e,-2,R("isinf"))),u.lua_pop(e,1),u.lua_pushnil(e),u.lua_setglobal(e,R("package")),u.lua_pushnil(e),u.lua_setglobal(e,R("load")),u.lua_pushnil(e),u.lua_setglobal(e,R("loadfile")),u.lua_pushnil(e),u.lua_setglobal(e,R("dofile")),u.lua_pushnil(e),u.lua_setglobal(e,R("collectgarbage")),u.lua_pushnil(e),u.lua_setglobal(e,R("coroutine")),u.lua_pushnil(e),u.lua_setglobal(e,R("fengari"))}var Ie=(e,t=0)=>Number.isFinite(Number(e))?Number(e):t,uo=e=>e?.Name||e,Si=e=>Math.max(0,Math.min(1,Ie(e)));function Kt(e){let t=e.parent?Kt(e.parent):[e.runtime.canvasWidth,e.runtime.canvasHeight];return[Math.max(0,(e.anchorMaxX-e.anchorMinX)*t[0]+Ie(e.sizeDeltaX)),Math.max(0,(e.anchorMaxY-e.anchorMinY)*t[1]+Ie(e.sizeDeltaY))]}function qt(e){let[t,i]=Kt(e),n=uo(e.scrollDirection)==="Horizontal",r=Math.max(1,Ie(e.cellSizeX,50)),o=Math.max(1,Ie(e.cellSizeY,50)),a=Math.max(0,Ie(e.spacingX)),l=Math.max(0,Ie(e.spacingY)),c=Math.max(0,Ie(e.padding1X)),s=Math.max(0,Ie(e.padding1Y)),f=Math.max(0,Ie(e.padding2X)),h=Math.max(0,Ie(e.padding2Y)),m=n?i-s-h:t-c-f,p=n?o:r,y=n?l:a,v=uo(e.layoutConstraint)==="Fixed"?Math.max(1,Math.floor(Ie(e.layoutConstraintFixedCount,1))):Math.max(1,Math.floor((m+y)/(p+y))),E=Math.ceil(e.itemCount/v),x=E?n?c+f+E*r+(E-1)*a:s+h+E*o+(E-1)*l:0,A=n?t:i,$=Math.max(0,x-A);return{width:t,height:i,horizontal:n,cellW:r,cellH:o,gapX:a,gapY:l,left:c,top:s,right:f,bottom:h,lanes:v,length:x,viewport:A,max:$,offset:Si(e.scrollProgress)*$}}function kt(e){let t=qt(e);for(let i=0;i<(e._gridItems?.length||0);i+=1){let n=e._gridItems[i];if(!n.alive||n.parent!==e)continue;let r=Math.floor(i/t.lanes),o=i%t.lanes,a=t.horizontal?r:o,l=t.horizontal?o:r,c=t.left+a*(t.cellW+t.gapX)+t.cellW/2-(t.horizontal?t.offset:0),s=-t.top-l*(t.cellH+t.gapY)-t.cellH/2+(t.horizontal?0:t.offset),f={anchorMinX:0,anchorMaxX:0,anchorMinY:1,anchorMaxY:1,pivotX:.5,pivotY:.5,sizeDeltaX:t.cellW,sizeDeltaY:t.cellH,anchoredPositionX:c,anchoredPositionY:s};Object.entries(f).some(([h,m])=>n[h]!==m)&&(Object.assign(n,f),n.markPlayDirty(!0))}return t}var co={container:"ClientUIContainerControl",textbox:"ClientUITextBoxControl",textwindow:"ClientUITextWindowControl",image:"ClientUIImageControl",button:"ClientUIPresetButtonControl",cursor:"ClientUICursorEventAreaControl",grid:"ClientUIGridScrollerControl",keyhint:"ClientUIKeyHintControl",animation:"ClientUIAnimationControl",fullscreen:"ClientUIFullscreenAnimationControl",reference:"ClientUIReferenceControl"},kl=["alive","Id","prefabIndex","active","activeInHierarchy","visible"],wi=new Set(["active","visible","parent","sizeDeltaX","sizeDeltaY","anchorMinX","anchorMinY","anchorMaxX","anchorMaxY","pivotX","pivotY"]),El=["name","parent","anchoredPositionX","anchoredPositionY","sizeDeltaX","sizeDeltaY","anchorMinX","anchorMinY","anchorMaxX","anchorMaxY","pivotX","pivotY","localScaleX","localScaleY","localScaleZ","localRotationX","localRotationY","localRotationZ","canControllerFocus"],Al={image:["imageSource","imageId"],grid:["itemCount","scrollDirection","layoutConstraint","layoutConstraintFixedCount"],reference:["referencedPrefabIndex"]},_l={container:["isolateNavigation","disableKeyEventPassthrough","disableCursorEventPassthrough","showCursor"],textbox:["text","fontSize","fontColor","bgColor","enableOutline","outlineColor","horizontalAlignment","verticalAlignment","adaptiveFontSize","minimumFontSize"],textwindow:["interactable","showScrollBar","text","fontSize","fontColor","bgColor","enableOutline","outlineColor","horizontalAlignment","verticalAlignment","adaptiveFontSize","minimumFontSize"],image:["imageColor","enableMask","enableSoftEdge","softEdgeMode","softEdgeWidthX","softEdgeWidthY","horizontalSoftRange","verticalSoftRange","reverseMaskArea","fillType","fillHorizontalType","fillVerticalType","fillRadial90Type","fillRadialType","fillAmount"],button:["interactable","clickAudioId","raycastTarget"],cursor:["raycastTarget"],grid:["itemPrefabIndex","raycastTarget","showScrollBar","interactable","scrollProgress"],keyhint:["keyboardKeyCode","controllerKeyCode"],animation:["animationId","playSoundEffect","layer"],fullscreen:["animationId","playSoundEffect"]},Pl=["GetChildren","GetChild","FindChild","SetActive","SetVisible","GetSiblingIndex","SetSiblingIndex","SetAsFirstSibling","SetAsLastSibling","GetAnchoredPosition","SetAnchoredPosition","GetSizeDelta","SetSizeDelta","GetAnchorMin","SetAnchorMin","GetAnchorMax","SetAnchorMax","GetPivot","SetPivot","GetLocalScale","SetLocalScale","GetLocalRotation","SetLocalRotation","GetScriptByPath","GetScript","GetScripts","AddKeyEventListener","RemoveKeyEventListener","RemoveKeyEventListeners","RemoveAllKeyEventListeners","AddNavigationEventListener","RemoveNavigationEventListener","RemoveNavigationEventListeners","RemoveAllNavigationEventListeners","SetControllerNavigation","GetControllerNavigation"],fo=["AddCursorEventListener","RemoveCursorEventListener","RemoveCursorEventListeners","RemoveAllCursorEventListeners","SimulateCursorClick"],Rl={image:["SetImage","SetSoftEdgeWidth","SetFillUnused","SetFillHorizontal","SetFillVertical","SetFillRadial90","SetFillRadial180","SetFillRadial360"],button:fo,cursor:fo,animation:["PlayAnimation","StopAnimation"],grid:["RefreshItems","GetItemIndex","GetItemSize","GetItemSpacing","GetPadding","ScrollToItemAt","GetContentLength"]};function gn(e,t){return kl.includes(t)||(Al[e.kind]||[]).includes(t)?"ro":El.includes(t)||(_l[e.kind]||[]).includes(t)?"rw":null}var Tl=["localRotationX","localRotationY","localRotationZ"],Et=Math.PI/180;function ho(e,t){return[e[3]*t[0]+e[0]*t[3]+e[1]*t[2]-e[2]*t[1],e[3]*t[1]-e[0]*t[2]+e[1]*t[3]+e[2]*t[0],e[3]*t[2]+e[0]*t[1]-e[1]*t[0]+e[2]*t[3],e[3]*t[3]-e[0]*t[0]-e[1]*t[1]-e[2]*t[2]]}function pn(e){if(Object.is(e,-0))return e;let t=(e%360+360)%360,i=Math.round(t*1e6)/1e6;return i>=360?0:i}function mo(e,t,i){let n=A=>[Math.sin(A*Et/2),Math.cos(A*Et/2)],[r,o]=n(e),[a,l]=n(t),[c,s]=n(i),[f,h,m,p]=ho(ho([0,a,0,l],[r,0,0,o]),[0,0,c,s]),y=Math.max(-1,Math.min(1,-2*(h*m-p*f))),v,E,x;return Math.abs(y)>.999999?(v=Math.sign(y)*90,E=2*Math.atan2(h,p)/Et,x=0):(v=Math.asin(y)/Et,E=Math.atan2(2*(p*h+f*m),1-2*(f*f+h*h))/Et,x=Math.atan2(2*(p*m+f*h),1-2*(f*f+m*m))/Et),[pn(v),pn(E),pn(x)]}function po(e,t){return Pl.includes(t)||(Rl[e.kind]||[]).includes(t)}var Ml={container:{isolateNavigation:!1,disableKeyEventPassthrough:!1,disableCursorEventPassthrough:!1,showCursor:!1},textbox:{text:"",fontSize:20,fontColor:4294967295,bgColor:0,enableOutline:!1,outlineColor:0,horizontalAlignment:null,verticalAlignment:null,adaptiveFontSize:!1,minimumFontSize:10},textwindow:{interactable:!0,showScrollBar:!0,text:"",fontSize:20,fontColor:4294967295,bgColor:0,enableOutline:!1,outlineColor:0,horizontalAlignment:null,verticalAlignment:null,adaptiveFontSize:!1,minimumFontSize:10},image:{imageSource:null,imageId:0,imageColor:4294967295,imageType:null,enableMask:!1,enableSoftEdge:!1,softEdgeMode:"Percentage",softEdgeWidthX:8,softEdgeWidthY:8,horizontalSoftRange:85,verticalSoftRange:85,enableFill:!1,fillType:"Unused",fillHorizontalType:"Left",fillVerticalType:"Bottom",fillRadial90Type:"BottomLeft",fillRadialType:"Bottom",reverseMaskArea:!1,fillAmount:1},button:{interactable:!0,clickAudioId:0,raycastTarget:!0,unavailableChildId:null,hoverChildId:null,pressedChildId:null,selectedChildId:null,pressed:!1},cursor:{raycastTarget:!0},grid:{itemCount:0,itemPrefabIndex:null,raycastTarget:!0,interactable:!0,showScrollBar:!0,scrollDirection:"Vertical",layoutConstraint:"AutoWrap",layoutConstraintFixedCount:null,scrollProgress:0,cellSizeX:50,cellSizeY:50,spacingX:8,spacingY:8,padding1X:20,padding1Y:20,padding2X:20,padding2Y:20,previewCount:5},keyhint:{keyboardKeyCode:null,controllerKeyCode:null},animation:{animationId:null,playSoundEffect:null,layer:null,raycastTarget:!1},fullscreen:{animationId:null,playSoundEffect:null,raycastTarget:!1},reference:{referencedPrefabIndex:null}},Ke=class e{constructor(t,i){this.runtime=t,this.kind=i.kind||"container",this.typeofName=co[this.kind]||co.container,this.alive=!0,this.Id=i.Id??t.nextControlId(),this.authoringId=i.authoringId??null,this.prefabIndex=i.prefabIndex??0,this.name=i.name??"",this.active=i.active===!0,this.visible=i.visible!==!1,this._parent=null,this.children=[],this.scripts=[],this.cursorListeners=new Map,this.keyListeners=new Map,this.navListeners=new Map,this.navConfig=new Map,this.anchoredPositionX=i.anchoredPositionX??0,this.anchoredPositionY=i.anchoredPositionY??0,this.sizeDeltaX=i.sizeDeltaX??0,this.sizeDeltaY=i.sizeDeltaY??0,this.anchorMinX=i.anchorMinX??.5,this.anchorMinY=i.anchorMinY??.5,this.anchorMaxX=i.anchorMaxX??.5,this.anchorMaxY=i.anchorMaxY??.5,this.pivotX=i.pivotX??.5,this.pivotY=i.pivotY??.5,this.localScaleX=i.localScaleX??1,this.localScaleY=i.localScaleY??1,this.localScaleZ=i.localScaleZ??1,this.localRotationX=i.localRotationX??0,this.localRotationY=i.localRotationY??0,this.localRotationZ=i.localRotationZ??0,this.canControllerFocus=i.canControllerFocus??!1,this._playDirty=!0,this._playDeepDirty=!0,this._playChildDirty=!1,(this.kind==="grid"||this.kind==="textwindow")&&(this.runtime.scrollControls||=new Set,this.runtime.scrollControls.add(this));let n=Ml[this.kind]||{};for(let[r,o]of Object.entries(n))this[r]===void 0&&(this[r]=i[r]!==void 0?i[r]:o);if(this.kind==="grid"&&(this.scrollProgress=i.scrollProgress??0),i.children)for(let r of i.children){let o=r instanceof e?r:new e(t,r);this.addChild(o)}}get parent(){return this._parent}set parent(t){if(this._parent===t)return;if(t!==null&&!(t instanceof e))throw new Error("parent must be a Control or nil");if(t&&t.runtime!==this.runtime)throw new Error("parent must belong to the same runtime");if(t===this)throw new Error("cannot parent a control to itself or its descendant");for(let n=t;n;n=n._parent)if(n===this)throw new Error("cannot parent a control to itself or its descendant");let i=this._parent;if(i){let n=i.children.indexOf(this);n>=0&&i.children.splice(n,1),i.markPlayDirty(!0)}else{let n=this.runtime.roots.indexOf(this);n>=0&&this.runtime.roots.splice(n,1)}this._parent=t,this.markPlayDirty(!0),t&&!t.children.includes(this)?(t.children.push(this),t.markPlayDirty(!0)):!t&&this.alive&&!this.runtime.roots.includes(this)&&this.runtime.roots.push(this)}markPlayDirty(t=!1){this._playDirty=!0,t&&(this._playDeepDirty=!0);for(let i=this._parent;i&&!i._playChildDirty;i=i._parent)i._playChildDirty=!0}get activeInHierarchy(){return this.active?this._parent?this._parent.activeInHierarchy:!0:!1}get scrollProgress(){return this._scrollProgress??0}set scrollProgress(t){if(typeof t!="number"||!Number.isFinite(t))throw new Error("scrollProgress must be a finite number");this._scrollProgress=Si(t),this.markPlayDirty()}addChild(t){return t.parent=this,t}GetChildren(){return this.children.slice()}GetChild(t){return this.children.find(i=>i.name===t)||null}FindChild(t){if(!t)return null;if(!t.includes("/"))return this.GetChild(t);let i=t.split("/").filter(Boolean),n=this;for(let r of i)if(n=n.GetChild(r),!n)return null;return n}SetActive(t){let i=!!t;if(this.active!==i){if(typeof this.runtime?.onControlActiveChanging=="function"){this.runtime.onControlActiveChanging(this,i);return}this.active=i,this.markPlayDirty(!0)}}SetVisible(t){this.visible=!!t,this.markPlayDirty(!0)}GetSiblingIndex(){if(!this._parent)return-1;let t=this._parent.children,i=t.indexOf(this);return i<0?-1:t.length-1-i}SetSiblingIndex(t){if(!this._parent)return!1;let i=this._parent.children,n=i.indexOf(this);if(n<0)return!1;let r=i.length-1;return!Number.isInteger(t)||t<0||t>r?!1:(i.splice(n,1),i.splice(r-t,0,this),this._parent.markPlayDirty(!0),this.markPlayDirty(),!0)}SetAsFirstSibling(){return this.SetSiblingIndex(0)}SetAsLastSibling(){return this._parent?this.SetSiblingIndex(this._parent.children.length-1):!1}GetAnchoredPosition(){return[this.anchoredPositionX,this.anchoredPositionY]}SetAnchoredPosition(t,i){this.anchoredPositionX=t,this.anchoredPositionY=i,this.markPlayDirty()}GetSizeDelta(){return[this.sizeDeltaX,this.sizeDeltaY]}SetSizeDelta(t,i){this.sizeDeltaX=t,this.sizeDeltaY=i,this.markPlayDirty(!0)}GetAnchorMin(){return[this.anchorMinX,this.anchorMinY]}SetAnchorMin(t,i){this.anchorMinX=t,this.anchorMinY=i,this.markPlayDirty(!0)}GetAnchorMax(){return[this.anchorMaxX,this.anchorMaxY]}SetAnchorMax(t,i){this.anchorMaxX=t,this.anchorMaxY=i,this.markPlayDirty(!0)}GetPivot(){return[this.pivotX,this.pivotY]}SetPivot(t,i){this.pivotX=t,this.pivotY=i,this.markPlayDirty(!0)}GetLocalScale(){return[this.localScaleX,this.localScaleY,this.localScaleZ]}SetLocalScale(t,i,n){this.localScaleX=t,this.localScaleY=i,this.localScaleZ=n,this.markPlayDirty()}GetLocalRotation(){return mo(this.localRotationX,this.localRotationY,this.localRotationZ)}luaFieldValue(t){let i=Tl.indexOf(t);return i<0?this[t]:mo(this.localRotationX,this.localRotationY,this.localRotationZ)[i]}SetLocalRotation(t,i,n){this.localRotationX=t,this.localRotationY=i,this.localRotationZ=n,this.markPlayDirty()}GetScriptByPath(t){return this.scripts.find(i=>i.path===t)||null}GetScript(t){return this.scripts.find(i=>i.scriptMappingId===t)||null}GetScripts(){return this.scripts.slice()}_addListener(t,i,n){let r=t.get(i)||[];r.push(n),t.set(i,r),this.runtime.retainLuaCallback?.(n)}_removeListener(t,i,n){let r=t.get(i);if(!r)return;let o=r.filter(a=>a!==n);t.set(i,o);for(let a=o.length;a<r.length;a++)this.runtime.unrefLuaCallback?.(n)}_removeListeners(t,i){let n=t.get(i)||[];for(let r of n)this.runtime.unrefLuaCallback?.(r);t.delete(i)}_removeAllListeners(t){for(let i of t.values())for(let n of i)this.runtime.unrefLuaCallback?.(n);t.clear()}AddCursorEventListener(t,i){this._addListener(this.cursorListeners,t,i)}RemoveCursorEventListener(t,i){this._removeListener(this.cursorListeners,t,i)}RemoveCursorEventListeners(t){this._removeListeners(this.cursorListeners,t)}RemoveAllCursorEventListeners(){this._removeAllListeners(this.cursorListeners)}SimulateCursorClick(){let t=this.runtime.makeCursorEventData({x:0,y:0,pressX:0,pressY:0});this.emitCursor("CursorDown",t),this.emitCursor("CursorUp",t),this.emitCursor("CursorClick",t)}emitCursor(t,i){if(!this.runtime.cursorEventsEnabled(this))return;let n=this.cursorListeners.get(t)||[];for(let r of n)r(i)}AddKeyEventListener(t,i){this._addListener(this.keyListeners,t,i)}RemoveKeyEventListener(t,i){this._removeListener(this.keyListeners,t,i)}RemoveKeyEventListeners(t){this._removeListeners(this.keyListeners,t)}RemoveAllKeyEventListeners(){this._removeAllListeners(this.keyListeners)}emitKey(t){let i=this.keyListeners.get(t)||[];for(let n of i)if(n()===!0)return!0;return!1}AddNavigationEventListener(t,i){this._addListener(this.navListeners,t,i)}RemoveNavigationEventListener(t,i){this._removeListener(this.navListeners,t,i)}RemoveNavigationEventListeners(t){this._removeListeners(this.navListeners,t)}RemoveAllNavigationEventListeners(){this._removeAllListeners(this.navListeners)}SetControllerNavigation(t,i,n){this.navConfig.set(t,{mode:i,target:n})}GetControllerNavigation(t){let i=this.navConfig.get(t),n=i?[i.mode,i.target]:[null,null];return n.__multi=!0,n}SetImage(t,i){this.imageSource=t,this.imageId=i,this.markPlayDirty()}SetSoftEdgeWidth(t,i){this.softEdgeWidthX=t,this.softEdgeWidthY=i,this.markPlayDirty()}SetFillUnused(){this.fillType="Unused",this.markPlayDirty()}SetFillHorizontal(t,i){this.fillType="Horizontal",this.fillHorizontalType=t,this.fillAmount=i,this.markPlayDirty()}SetFillVertical(t,i){this.fillType="Vertical",this.fillVerticalType=t,this.fillAmount=i,this.markPlayDirty()}SetFillRadial90(t,i){this.fillType="Radial90",this.fillRadial90Type=t,this.fillAmount=i,this.markPlayDirty()}SetFillRadial180(t,i){this.fillType="Radial180",this.fillRadialType=t,this.fillAmount=i,this.markPlayDirty()}SetFillRadial360(t,i){this.fillType="Radial360",this.fillRadialType=t,this.fillAmount=i,this.markPlayDirty()}PlayAnimation(){}StopAnimation(){}RefreshItems(t,i){if(!Number.isInteger(t)||t<0||t>2e3)throw new Error("RefreshItems: simulator supports 0..2000 items");if(typeof i!="function")throw new Error("RefreshItems: callback must be a function");if(!this.alive||this._refreshingGrid)throw new Error("RefreshItems: destroyed control or recursive refresh");if(t&&!this.runtime.templates.has(Number(this.itemPrefabIndex)))throw new Error("RefreshItems: item template not found");if(t&&["OnInit","OnDestroy"].includes(this.runtime.lifecyclePhase))throw new Error("RefreshItems: items cannot be created during OnInit/OnDestroy");this._refreshingGrid=!0;try{this._gridItems||=[];let n=[];for(let r of this._gridItems)r.alive&&r.parent===this&&r.prefabIndex===Number(this.itemPrefabIndex)&&n.length<t?n.push(r):r.alive&&r.parent===this&&this.runtime.destroyControl(r);for(this._gridItems=n;n.length<t;){let r=this.runtime.instantiate(this.itemPrefabIndex,this,this.runtime.lifecyclePhase);if(!r)throw new Error("RefreshItems: could not instantiate item");n.push(r),r.SetActive(!0)}this.itemCount=t,kt(this),this.markPlayDirty(!0);for(let r=0;r<n.length&&this.alive;r+=1)i(n[r],r)}finally{this._refreshingGrid=!1}}GetItemIndex(t){return t?.alive&&t.parent===this?this._gridItems?.indexOf(t)??-1:-1}GetItemSize(){return[this.cellSizeX,this.cellSizeY]}GetItemSpacing(){return[this.spacingX,this.spacingY]}GetPadding(){return[this.padding1Y,this.padding2Y,this.padding1X,this.padding2X]}ScrollToItemAt(t,i){if(!Number.isInteger(t)||t<0||t>=this.itemCount)throw new Error("ScrollToItemAt: item index out of range");let n=qt(this),r=n.horizontal?n.cellW:n.cellH,o=n.horizontal?n.gapX:n.gapY,a=(n.horizontal?n.left:n.top)+Math.floor(t/n.lanes)*(r+o),l=i?.Name||i;if(!["Top","Center","Bottom"].includes(l))throw new Error("ScrollToItemAt: invalid alignment");let c=a-(l==="Center"?(n.viewport-r)/2:l==="Bottom"?n.viewport-r:0);this.scrollProgress=n.max?Si(c/n.max):0,kt(this),this.markPlayDirty(!0)}GetContentLength(){return qt(this).length}};function Me(e,t){t(e);for(let i of e.children)Me(i,t)}function yn(e,t=[],i=""){t.push(`${i}${e.name||"(unnamed)"} [${e.typeofName}] Id=${e.Id}`);for(let n of e.children)yn(n,t,i+" ");return t}function Ci(e){return e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375}var go={Linear:e=>e,InSine:e=>1-Math.cos(e*Math.PI/2),OutSine:e=>Math.sin(e*Math.PI/2),InOutSine:e=>-(Math.cos(Math.PI*e)-1)/2,InQuad:e=>e*e,OutQuad:e=>1-(1-e)*(1-e),InOutQuad:e=>e<.5?2*e*e:1-(-2*e+2)**2/2,InCubic:e=>e*e*e,OutCubic:e=>1-(1-e)**3,InOutCubic:e=>e<.5?4*e*e*e:1-(-2*e+2)**3/2,InQuart:e=>e**4,OutQuart:e=>1-(1-e)**4,InOutQuart:e=>e<.5?8*e**4:1-(-2*e+2)**4/2,InQuint:e=>e**5,OutQuint:e=>1-(1-e)**5,InOutQuint:e=>e<.5?16*e**5:1-(-2*e+2)**5/2,InExpo:e=>e===0?0:2**(10*e-10),OutExpo:e=>e===1?1:1-2**(-10*e),InOutExpo:e=>e===0||e===1?e:e<.5?2**(20*e-10)/2:(2-2**(-20*e+10))/2,InCirc:e=>1-Math.sqrt(1-e**2),OutCirc:e=>Math.sqrt(1-(e-1)**2),InOutCirc:e=>e<.5?(1-Math.sqrt(1-(2*e)**2))/2:(Math.sqrt(1-(-2*e+2)**2)+1)/2,InBack:e=>(1.70158+1)*e*e*e-1.70158*e*e,OutBack:e=>1+2.70158*(e-1)**3+1.70158*(e-1)**2,InOutBack:e=>{let i=2.5949095;return e<.5?(2*e)**2*((i+1)*2*e-i)/2:((2*e-2)**2*((i+1)*(e*2-2)+i)+2)/2},InElastic:e=>e===0||e===1?e:-(2**(10*e-10))*Math.sin((e*10-10.75)*(2*Math.PI/3)),OutElastic:e=>e===0||e===1?e:2**(-10*e)*Math.sin((e*10-.75)*(2*Math.PI/3))+1,InOutElastic:e=>{if(e===0||e===1)return e;let t=2*Math.PI/4.5;return e<.5?-(2**(20*e-10)*Math.sin((20*e-11.125)*t))/2:2**(-20*e+10)*Math.sin((20*e-11.125)*t)/2+1},InBounce:e=>1-Ci(1-e),OutBounce:Ci,InOutBounce:e=>e<.5?(1-Ci(1-2*e))/2:(1+Ci(2*e-1))/2};function yo(e,t){let i=go[e]||go.Linear;return t<=0?0:t>=1?1:i(t)}function At(e,t,i,n=255){let r=Ii(e),o=Ii(t),a=Ii(i);return((n==null?255:Ii(n))<<24|r<<16|o<<8|a)>>>0}function Lt(e){let t=e>>>0;return[t>>>16&255,t>>>8&255,t&255,t>>>24&255]}function Ii(e){let t=Number(e);return Number.isFinite(t)?Math.max(0,Math.min(255,Math.trunc(t))):0}function bo(e,t,i){let n=Lt(e),r=Lt(t);return At(n[0]+(r[0]-n[0])*i,n[1]+(r[1]-n[1])*i,n[2]+(r[2]-n[2])*i,n[3]+(r[3]-n[3])*i)}var Nl=new Set(["fontColor","bgColor","outlineColor","imageColor"]),Fl=new Set(["fontSize","minimumFontSize"]),bn=1e-9;function Ol(e,t){return typeof e?.luaFieldValue=="function"?e.luaFieldValue(t):e[t]}var Wt=class{constructor(t,i,n,r){this.runtime=t,this.object=i,this.data={...n},this.duration=Math.max(0,Number(r)||0),this.easeName="Linear",this.relative=!1,this.playing=!1,this.paused=!1,this.elapsed=0,this.loops=1,this.loopIndex=0,this.from={},this.to={},this.initialFrom=null,this.initialTo=null,this.onComplete=null,this.onStepComplete=null,this.killed=!1,this.dead=!1,this.completed=!1}capture(){this.from={},this.to={};for(let[t,i]of Object.entries(this.data)){let n=Ol(this.object,t);this.from[t]=n,this.to[t]=this.relative?Number(n)+Number(i):i}}restoreInitial(){this.from={...this.initialFrom},this.to={...this.initialTo}}SetEase(t){return this.easeName=typeof t=="string"?t:t?.Name||"Linear",this}SetRelative(t){return this.relative=!!t,this}Play(){return this.dead?this:this.playing?(this.paused=!1,this):this._start(!1)}_begin(t){this.playing=!0,this.paused=!1,this.elapsed=0,this.loopIndex=0,this.killed=!1,this.completed=!1,t&&this.initialFrom?this.restoreInitial():(this.capture(),this.initialFrom={...this.from},this.initialTo={...this.to})}_start(t){return this._begin(t),this.runtime.tweens.add(this),this.runtime.animations.add(this),this}get loopCount(){return this.loops>0?this.loops:1}Pause(){this.paused=!0}Resume(){this.paused=!1}Restart(){return this.dead?this:this._start(!0)}Complete(){this.dead||this.completed||(this.initialFrom||this._begin(!1),this.apply(1),this.finish(!0))}Kill(t){t?this.Complete():this.finish(!1),this.dead=!0}SetOnComplete(t){return this.onComplete=t,this}SetOnStepComplete(t){return this.onStepComplete=t,this}SetLoops(t){return this.loops=t,this}apply(t){if(this.object?.alive===!1)return;let i=yo(this.easeName,t),n=!1,r=!1;for(let o of Object.keys(this.to)){let a=this.from[o],l=this.to[o];if(Nl.has(o)&&typeof a=="number"&&typeof l=="number")this.object[o]=bo(a,l,i);else if(typeof a=="number"&&typeof l=="number"){let c=a+(l-a)*i;this.object[o]=Fl.has(o)?Math.trunc(c):c}else this.object[o]=i>=1?l:a;n=!0,wi.has(o)&&(r=!0)}n&&typeof this.object?.markPlayDirty=="function"&&this.object.markPlayDirty(r)}_advance(t,i){this.elapsed+=t;let n=this.duration<=0?1:Math.min(1,this.elapsed/this.duration);return this.apply(n),n<1?!1:i>=0&&this.loopIndex+1>=i?!0:(this.onStepComplete&&this.runtime.safeCall(this.onStepComplete),this.loopIndex++,this.elapsed=0,this.restoreInitial(),!1)}step(t){!this.playing||this.paused||this.killed||this._advance(t,this.loops<0?-1:this.loopCount)&&(this.onStepComplete&&this.runtime.safeCall(this.onStepComplete),this.finish(!0))}finish(t){this.playing=!1,this.killed=!0,t&&(this.completed=!0),this.runtime.tweens.delete(this),this.runtime.animations.delete(this),t&&this.onComplete&&this.runtime.safeCall(this.onComplete)}},_t=class{constructor(t){this.runtime=t,this.steps=[],this.playing=!1,this.paused=!1,this.killed=!1,this.dead=!1,this.completed=!1,this.elapsed=0,this.loops=1,this.loopIndex=0,this.onComplete=null,this.onStepComplete=null,this._entries=null}Append(t){return this.steps.push({kind:"tween",tween:t,parallel:!1}),this}AppendInterval(t){return this.steps.push({kind:"interval",duration:t}),this}AppendCallback(t){return this.steps.push({kind:"callback",fn:t}),this}Join(t){return this.steps.push({kind:"tween",tween:t,parallel:!0}),this}Insert(t,i){return this.steps.push({kind:"insert",time:t,tween:i}),this}InsertCallback(t,i){return this.steps.push({kind:"insertCb",time:t,fn:i}),this}Play(){return this.dead?this:this.playing?(this.paused=!1,this):this._play()}_play(){return this.playing=!0,this.paused=!1,this.killed=!1,this.completed=!1,this.elapsed=0,this.loopIndex=0,this._schedule(),this.runtime.sequences.add(this),this.runtime.animations.add(this),this}_schedule(){let t=0,i=0,n=!1,r=[],o=a=>a.duration*a.loopCount;for(let a of this.steps)if(a.kind==="tween"&&a.parallel){let l=n?i:t;r.push({at:l,tween:a.tween}),t=Math.max(t,l+o(a.tween))}else a.kind==="tween"?(r.push({at:t,tween:a.tween}),i=t,n=!0,t+=o(a.tween)):a.kind==="interval"?(i=t,n=!0,t+=a.duration):a.kind==="callback"?r.push({at:t,fn:a.fn}):a.kind==="insert"?(r.push({at:a.time,tween:a.tween}),t=Math.max(t,a.time+o(a.tween))):a.kind==="insertCb"&&(r.push({at:a.time,fn:a.fn}),t=Math.max(t,a.time));this._entries=r.map((a,l)=>({...a,index:l,end:a.tween?a.at+o(a.tween):a.at})),this._end=t,this._resetEntries()}_resetEntries(){for(let t of this._entries)t.started=!1,t.done=!1}_startChild(t){t.started=!0,t.tween._begin(!!t.tween.initialFrom)}_finishChild(t){t.done=!0,t.tween.apply(1),t.tween.onStepComplete&&this.runtime.safeCall(t.tween.onStepComplete),t.tween.finish(!0)}_advanceTo(t,i){let n=this._entries,r=[];for(let a of n)!a.started&&a.at<=t+bn&&r.push({at:a.at,rank:a.fn?1:2,entry:a}),a.tween&&!a.done&&a.end<=t+bn&&r.push({at:a.end,rank:0,entry:a});r.sort((a,l)=>a.at-l.at||a.rank-l.rank||a.entry.index-l.entry.index);let o=new Set;for(let{rank:a,entry:l}of r)if(a===1){if(l.started=!0,this.runtime.safeCall(l.fn),!this.playing||this.killed||this._entries!==n)return!1}else l.started||(this._startChild(l),o.add(l)),a===0&&!l.done&&this._finishChild(l);for(let a of n)!a.tween||!a.started||a.done||(o.has(a)?a.tween._advance(t-a.at,a.tween.loopCount):a.tween._advance(i,a.tween.loopCount));return!0}step(t){!this.playing||this.paused||this.killed||(this.elapsed+=t,this._advanceTo(this.elapsed,t)&&(this.elapsed+bn<this._end||(this.onStepComplete&&this.runtime.safeCall(this.onStepComplete),this.loopIndex++,this.loops<0||this.loopIndex<this.loops?(this.elapsed=0,this._resetEntries()):this.finish(!0))))}Pause(){this.paused=!0}Resume(){this.paused=!1}Restart(){this.dead||this._play()}Complete(){this.dead||this.completed||(this._entries||this._schedule(),this.playing=!0,this.killed=!1,this._advanceTo(1/0,0)&&(this.onStepComplete&&this.runtime.safeCall(this.onStepComplete),this.finish(!0)))}Kill(t){t?this.Complete():this.finish(!1),this.dead=!0}SetOnComplete(t){return this.onComplete=t,this}SetOnStepComplete(t){return this.onStepComplete=t,this}SetLoops(t){return this.loops=t,this}finish(t){this.playing=!1,this.killed=!0,t&&(this.completed=!0),this.runtime.sequences.delete(this),this.runtime.animations.delete(this),t&&this.onComplete&&this.runtime.safeCall(this.onComplete)}};var xi={EaseType:["Linear","InSine","OutSine","InOutSine","InQuad","OutQuad","InOutQuad","InCubic","OutCubic","InOutCubic","InQuart","OutQuart","InOutQuart","InQuint","OutQuint","InOutQuint","InExpo","OutExpo","InOutExpo","InCirc","OutCirc","InOutCirc","InBack","OutBack","InOutBack","InElastic","OutElastic","InOutElastic","InBounce","OutBounce","InOutBounce"],CustomVariableEntityType:["Level","PlayerSelf","AvatarSelf"],Device:["KeyboardAndMouse","Mobile","Controller","MobileController"],StageMode:["Beyond","Classic"],LanguageType:["LanguageNone","LanguageEng","LanguageChs","LanguageCht","LanguageFra","LanguageDeu","LanguageSpa","LanguagePor","LanguageRus","LanguageJpn","LanguageKor","LanguageTha","LanguageVie","LanguageInd","LanguageTur","LanguageIta"],ParamType:["Entity","EntityList","Int","IntList","Bool","BoolList","Float","FloatList","String","StringList","Vector3","Vector3List","Guid","GuidList","ConfigId","PrefabId","ConfigIdList","PrefabIdList"],CursorEventType:["CursorDown","CursorUp","CursorEnter","CursorExit","CursorDrag","CursorBeginDrag","CursorEndDrag","CursorClick"],ScrollDirection:["Horizontal","Vertical"],ScrollLayoutConstraint:["AutoWrap","Fixed"],ScrollAlignType:["Bottom","Center","Top"],ControllerNavigationDir:["Up","Down","Left","Right"],ControllerNavigationEventType:["Confirm","Cancel","Focus","LostFocus","RightStickUp","RightStickDown","RightStickRight","RightStickLeft","LeftStickUp","LeftStickDown","LeftStickRight","LeftStickLeft"],ControllerNavigationMode:["None","NearestControl","Specified"],TextHorizontalAlignment:["Left","Middle","Right"],TextVerticalAlignment:["Top","Middle","Bottom"],ImageType:["Basic","Stretch"],ImageSource:["StaticReference","Item","Equipment","Skill","UnitStatus","Faction","Currency","Prefab"],ImageFillType:["Unused","Horizontal","Vertical","Radial90","Radial180","Radial360"],ImageFillHorizontalType:["Left","Right"],ImageFillVerticalType:["Bottom","Top"],ImageFillRadial90Type:["BottomLeft","TopLeft","TopRight","BottomRight"],ImageFillRadialType:["Bottom","Left","Top","Right"],ImageMaskSoftEdgeMode:["Percentage","Pixel"],UIAnimationLayer:["AboveAllControls","BelowAllControls"]},zl=[...Array.from({length:43},(e,t)=>`CraftspersonKey${t+1}`),"MoveForwardKey","MoveBackwardKey","MoveLeftKey","MoveRightKey","SwitchToWalkOrRunKey","SprintKey","JumpKey","DropKey","OpenShortcutWheelKey","InteractKey","NormalAttackKey","CharacterSkill1Key","CharacterSkill2Key","CharacterSkill3Key","CharacterSkill4Key","None"],Dl=[...Array.from({length:14},(e,t)=>`CraftspersonKey${t+1}`),"SprintKey","JumpKey","InteractKey","NormalAttackKey","CharacterSkill1Key","CharacterSkill2Key","CharacterSkill3Key","CharacterSkill4Key","MenuConfirmKey","MenuBackKey","None"];function $l(){let e=[];for(let t of["Down","Up"]){for(let i=1;i<=43;i++)e.push(`KeyboardCraftspersonKey${i}${t}`);for(let i of["MoveForwardKey","MoveBackwardKey","MoveLeftKey","MoveRightKey","SwitchToWalkOrRunKey","SprintKey","JumpKey","DropKey","OpenShortcutWheelKey","InteractKey","NormalAttackKey","CharacterSkill1Key","CharacterSkill2Key","CharacterSkill3Key","CharacterSkill4Key"])e.push(`Keyboard${i}${t}`);for(let i=1;i<=14;i++)e.push(`ControllerCraftspersonKey${i}${t}`);for(let i of["SprintKey","JumpKey","InteractKey","NormalAttackKey","CharacterSkill1Key","CharacterSkill2Key","CharacterSkill3Key","CharacterSkill4Key","MenuConfirmKey","MenuBackKey"])e.push(`Controller${i}${t}`)}return e}xi.KeyboardKeyCode=zl;xi.ControllerKeyCode=Dl;xi.KeyEventType=$l();var vo=new Map;function ot(e,t){let i=`${e}\0${t}`,n=vo.get(i);return n||(n={__kind:"EnumItem",Name:t,FullName:`Enum.${e}.${t}`,EnumType:e},vo.set(i,n)),n}function vn(e,t){return t==null?t:t.__kind==="EnumItem"?ot(t.EnumType||e,t.Name):typeof t=="string"&&t?ot(e,t):t}function Sn(){let e={};for(let[t,i]of Object.entries(xi)){let n={};for(let r of i)n[r]=ot(t,r);e[t]=n}return e}var Gl=new Set(["Id","prefabIndex","imageId","fontSize","minimumFontSize","clickAudioId","itemCount","itemPrefabIndex","animationId","referencedPrefabIndex"]),Vl=new Set(["imageColor","fontColor","bgColor","outlineColor"]),So={horizontalAlignment:"TextHorizontalAlignment",verticalAlignment:"TextVerticalAlignment",imageSource:"ImageSource",fillType:"ImageFillType",fillHorizontalType:"ImageFillHorizontalType",fillVerticalType:"ImageFillVerticalType",fillRadial90Type:"ImageFillRadial90Type",fillRadialType:"ImageFillRadialType",softEdgeMode:"ImageMaskSoftEdgeMode",layer:"UIAnimationLayer",scrollDirection:"ScrollDirection",layoutConstraint:"ScrollLayoutConstraint"},at=u.LUA_REGISTRYINDEX,wo=u.LUA_MULTRET,Yl=Object.freeze({InstantiateClientUIControl:2,DestroyClientUIControl:1,GetClientUIControl:1,FindClientUIRoot:1,GetClientUIRoots:0,GetUICanvasSize:0,GetCursorUIPos:0,GetDevice:0,SetControllerFocus:1,GetControllerFocus:0,GetControllerLeftStickAxis:0,GetControllerRightStickAxis:0,Tween:3,TweenSequence:0,ServerSignal:1,GetGlobalCustomVariableValue:2,PauseLevelTime:1,IsLevelTimePaused:0,PlayAudio2D:1,StopAudio:1,IsAudioAlive:1,GetLanguageType:0,GetStageMode:0,IsTestPlay:0,GetText:1,PrintClientUITree:0});function be(e){return e==null?"":typeof e=="string"?e:e.Name||e.FullName||String(e)}var ki=class{constructor(t={}){this.canvasWidth=t.canvasWidth??1600,this.canvasHeight=t.canvasHeight??900,this.device=t.device??"KeyboardAndMouse",this.language=t.language??"LanguageChs",this.stageMode=t.stageMode??"Classic",this.testPlay=t.testPlay!==!1,this.clock={time:0,levelTime:0,paused:!1,frame:0},this.logs=[],this.mountErrors=[],this.tweens=new Set,this.sequences=new Set,this.animations=new Set,this.audios=new Map,this.nextAudioId=1,this.audioDuration=t.audioDuration||(()=>null),this.audioHistory=[],this.audioWarnings=new Set,this.audioRevision=0,this._nextControlId=1,this._playRemoved=[],this._nextScriptMappingId=1,this.lifecyclePhase="idle",this.controlsById=new Map,this.roots=[],this.templates=new Map,this.scriptFiles=new Map,this.requireAliases=new Map,this.requireCache=new Map,this.moduleBaseEnvironments=new Map,this.luaFunctions=new Map,this.mountedScripts=[],this.serverVars={Level:Object.create(null),PlayerSelf:Object.create(null),AvatarSelf:Object.create(null)},this.serverBridge=null,this.varHandlers=[],this.signalHandlers=[],this.cursor={x:0,y:0},this.focus=null,this.stick={left:[0,0],right:[0,0]},this.enumTree=Sn(),this.luaStates=new Set,this.L=null}nextControlId(){let t=this._nextControlId;return this._nextControlId+=1,t}resolveScriptMappingId(t){let i=Number(t);if(Number.isSafeInteger(i)&&i>0)return this._nextScriptMappingId=Math.max(this._nextScriptMappingId,i+1),i;let n=this._nextScriptMappingId;return this._nextScriptMappingId+=1,n}pushPackedColor(t,i){let n=i>>>0;(n|0)===n?u.lua_pushinteger(t,n):u.lua_pushnumber(t,n)}retainLuaCallback(t){oo(t)}unrefLuaCallback(t){ao(this,t)}log(t,...i){let n=i.map(r=>r==null?"nil":typeof r=="object"&&r!==null&&r.__kind==="EnumItem"?r.Name:String(r)).join(" ");this.logs.push({level:t,text:n,time:this.clock.time})}safeCall(t,...i){try{return t(...i)}catch(n){this.log("lua-error",n&&n.message?n.message:String(n))}}scriptCanRun(t){if(!t?.alive||!t.enabled)return!1;let i=t.object;return!i||i.alive&&i.activeInHierarchy}cursorEventsEnabled(t){for(let i=t;i;i=i.parent)if(i.kind==="container"&&i.showCursor===!0)return!0;return!1}registerTemplate(t,i){this.templates.set(Number(t),i)}registerScriptFile(t,i){let n=this.normalizeRequirePath(t);this.scriptFiles.set(n,i),n.startsWith("default_import_file/")||this.requireAliases.set(`default_import_file/${n}`,n)}normalizeRequirePath(t){let i=String(t).replace(/\\/g,"/");return i.endsWith(".lua")&&(i=i.slice(0,-4)),i}addRoot(t){let i=t instanceof Ke?t:new Ke(this,t);return this.roots.push(i),Me(i,n=>this.controlsById.set(n.Id,n)),this.mountSpecScripts(t,i),i}mountSpecScripts(t,i){if(t instanceof Ke)return;let n=o=>(o.scripts?.length||0)>0||(o.children||[]).some(n);if(!t||!n(t))return;let r=this.lifecyclePhase;try{let o=(a,l)=>{for(let s of a.scripts||[])try{this.mountScript({path:s.path,source:s.source,control:l,scriptMappingId:s.scriptMappingId})}catch(f){let h=f&&f.message?f.message:String(f);this.mountErrors.push(h),this.log("lua-error",h)}let c=a.children||[];for(let s=0;s<c.length;s+=1)o(c[s],l?.children?.[s])};o(t,i)}finally{this.lifecyclePhase=r}}makeCursorEventData({x:t=0,y:i=0,pressX:n=t,pressY:r=i,deltaX:o=t-n,deltaY:a=i-r,dragging:l=!1,touchId:c=-1}={}){let s=this;return{__kind:"CursorEventData",typeofName:"CursorEventData",dragging:l,touchId:c,x:t,y:i,pressX:n,pressY:r,GetUIPos(){return[t,i]},GetPressUIPos(){return[n,r]},GetUIPosDelta(){return[o,a]}}}boot(){let t=this.newLuaThread();this.L=t}installGlobals(t){let i=this;u.lua_pushcfunction(t,n=>{let r=u.lua_gettop(n),o=[];for(let a=1;a<=r;a++)o.push(de(n,i,a));return i.log("info",...o),0}),u.lua_setglobal(t,R("print")),u.lua_pushcfunction(t,n=>{let r=u.lua_gettop(n),o=[];for(let a=1;a<=r;a++)o.push(de(n,i,a));return i.log("error",...o),0}),u.lua_setglobal(t,R("printerr")),u.lua_pushcfunction(t,n=>{if(u.lua_type(n,1)===u.LUA_TTABLE&&!De(n,1))return u.lua_pushstring(n,R("table")),1;let r=de(n,i,1);return u.lua_pushstring(n,R(i.typeofOf(r))),1}),u.lua_setglobal(t,R("typeof")),this.pushColorLib(t),this.pushEnumLib(t),this.pushGameLib(t),u.lua_pushcfunction(t,n=>i.luaRequire(n)),u.lua_setglobal(t,R("require"))}typeofOf(t){return t==null?"nil":t.__kind==="Script"?"Script":t.__kind==="EnumItem"?"EnumItem":t.__kind==="CursorEventData"?"CursorEventData":t.__kind==="ServerSignal"?"ServerSignal":t instanceof _t?"TweenSequence":t instanceof Wt?"Tween":t.typeofName?t.typeofName:typeof t=="number"?"number":typeof t=="string"?"string":typeof t=="boolean"?"boolean":typeof t}pushColorLib(t){u.lua_newtable(t),u.lua_pushcfunction(t,i=>(this.pushPackedColor(i,At(u.lua_tonumber(i,1),u.lua_tonumber(i,2),u.lua_tonumber(i,3),255)),1)),u.lua_setfield(t,-2,R("FromRGB")),u.lua_pushcfunction(t,i=>{let n=u.lua_isnoneornil(i,4)?255:u.lua_tonumber(i,4);return this.pushPackedColor(i,At(u.lua_tonumber(i,1),u.lua_tonumber(i,2),u.lua_tonumber(i,3),n)),1}),u.lua_setfield(t,-2,R("FromRGBA")),u.lua_pushcfunction(t,i=>{let n=u.lua_tonumber(i,1)>>>0;for(let r of Lt(n))u.lua_pushinteger(i,r);return 4}),u.lua_setfield(t,-2,R("ToRGBA")),u.lua_newtable(t),u.lua_pushcfunction(t,i=>{let n=u.lua_tonumber(i,2),r=u.lua_tonumber(i,3),o=u.lua_tonumber(i,4),a=u.lua_isnoneornil(i,5)?255:u.lua_tonumber(i,5);return this.pushPackedColor(i,At(n,r,o,a)),1}),u.lua_setfield(t,-2,R("__call")),u.lua_setmetatable(t,-2),u.lua_setglobal(t,R("Color"))}pushEnumLib(t){u.lua_newtable(t);for(let[i,n]of Object.entries(this.enumTree)){u.lua_newtable(t);for(let[r,o]of Object.entries(n))this.pushEnumItem(t,o),u.lua_setfield(t,-2,R(r));u.lua_setfield(t,-2,R(i))}u.lua_setglobal(t,R("Enum"))}pushEnumItem(t,i){let n=u.lua_newuserdata(t,0);rt(n,i),W.luaL_setmetatable(t,R("EnumItem"))}pushControl(t,i){let n=u.lua_newuserdata(t,0);rt(n,i),W.luaL_setmetatable(t,R("Control"))}pushScript(t,i){u.lua_newtable(t),u.lua_pushlightuserdata(t,mn);let n=u.lua_newuserdata(t,0);rt(n,i),u.lua_rawset(t,-3),W.luaL_getmetatable(t,R("Script")),u.lua_setmetatable(t,-2)}pushTween(t,i){let n=u.lua_newuserdata(t,0);rt(n,i);let r=i instanceof _t?"TweenSequence":"Tween";W.luaL_setmetatable(t,R(r))}pushSignal(t,i){let n=u.lua_newuserdata(t,0);rt(n,i),W.luaL_setmetatable(t,R("ServerSignal"))}pushCursor(t,i){let n=u.lua_newuserdata(t,0);rt(n,i),W.luaL_setmetatable(t,R("CursorEventData"))}pushGameLib(t){let i=this;u.lua_newtable(t);let n={InstantiateClientUIControl:r=>{let o=u.lua_tointeger(r,1),a=Ce(u.lua_touserdata(r,2)),l=i.instantiate(o,a,i.lifecyclePhase);return l?(i.pushControl(r,l),1):(u.lua_pushnil(r),1)},DestroyClientUIControl:r=>{let o=Ce(u.lua_touserdata(r,1));return o&&i.destroyControl(o),0},GetClientUIControl:r=>{let o=u.lua_tointeger(r,1),a=i.controlsById.get(o);return a?i.pushControl(r,a):u.lua_pushnil(r),1},FindClientUIRoot:r=>{let o=q(r,1),a=i.roots.find(l=>l.name===o);return a?i.pushControl(r,a):u.lua_pushnil(r),1},GetClientUIRoots:r=>(u.lua_createtable(r,i.roots.length,0),i.roots.forEach((o,a)=>{i.pushControl(r,o),u.lua_rawseti(r,-2,a+1)}),1),GetUICanvasSize:r=>(u.lua_pushnumber(r,i.canvasWidth),u.lua_pushnumber(r,i.canvasHeight),2),GetCursorUIPos:r=>(u.lua_pushnumber(r,i.cursor.x),u.lua_pushnumber(r,i.cursor.y),2),GetDevice:r=>(i.pushEnumItem(r,ot("Device",i.device)),1),SetControllerFocus:r=>(i.focus=Ce(u.lua_touserdata(r,1)),0),GetControllerFocus:r=>(i.focus?i.pushControl(r,i.focus):u.lua_pushnil(r),1),GetControllerLeftStickAxis:r=>(u.lua_pushnumber(r,i.stick.left[0]),u.lua_pushnumber(r,i.stick.left[1]),2),GetControllerRightStickAxis:r=>(u.lua_pushnumber(r,i.stick.right[0]),u.lua_pushnumber(r,i.stick.right[1]),2),Tween:r=>{let o=Ce(u.lua_touserdata(r,1))||de(r,i,1),a=de(r,i,2)||{},l=u.lua_tonumber(r,3),c=new Wt(i,o,a,l);return i.pushTween(r,c),1},TweenSequence:r=>(i.pushTween(r,new _t(i)),1),ServerSignal:r=>{let o=q(r,1);return i.pushSignal(r,i.makeServerSignal(o)),1},GetGlobalCustomVariableValue:r=>{let o=be(de(r,i,1)),a=q(r,2);return ae(r,i,i.getVar(o,a)),1},PauseLevelTime:r=>(i.clock.paused=!!u.lua_toboolean(r,1),0),IsLevelTimePaused:r=>(u.lua_pushboolean(r,i.clock.paused),1),PlayAudio2D:r=>{let o=i.playAudio(i.audioInteger(r));return u.lua_pushinteger(r,o),1},StopAudio:r=>(i.stopAudio(i.audioInteger(r)),0),IsAudioAlive:r=>{let o=i.audios.get(i.audioInteger(r));return u.lua_pushboolean(r,!!(o&&o.alive)),1},GetLanguageType:r=>(i.pushEnumItem(r,ot("LanguageType",i.language)),1),GetStageMode:r=>(i.pushEnumItem(r,ot("StageMode",i.stageMode)),1),IsTestPlay:r=>(u.lua_pushboolean(r,i.testPlay),1),GetText:r=>{let o=q(r,1);return u.lua_pushstring(r,R(o)),1},PrintClientUITree:r=>{for(let o of i.roots)i.log("info",yn(o).join(`
108
+ `));return 0}};for(let[r,o]of Object.entries(n)){let a=Yl[r];if(a===void 0)throw new Error(`missing game arity for ${r}`);u.lua_pushcfunction(t,l=>{let c=u.lua_gettop(l);return c!==a?W.luaL_error(l,R(`bad argument count to '${r}' (${a} expected, got ${c})`)):o(l)}),u.lua_setfield(t,-2,R(r))}u.lua_setglobal(t,R("game"))}makeServerSignal(t){let i=[],n=this;return{__kind:"ServerSignal",name:t,AddParam(r,o){i.push({type:be(r),value:o})},AddInt(r){i.push({type:"Int",value:r})},AddIntList(r){i.push({type:"IntList",value:r})},AddFloat(r){i.push({type:"Float",value:r})},AddFloatList(r){i.push({type:"FloatList",value:r})},AddString(r){i.push({type:"String",value:r})},AddStringList(r){i.push({type:"StringList",value:r})},AddVector3(r){i.push({type:"Vector3",value:r})},AddVector3List(r){i.push({type:"Vector3List",value:r})},AddBool(r){i.push({type:"Bool",value:r})},AddBoolList(r){i.push({type:"BoolList",value:r})},AddGuid(r){i.push({type:"Guid",value:r})},AddGuidList(r){i.push({type:"GuidList",value:r})},AddEntity(r){i.push({type:"Entity",value:r})},AddEntityList(r){i.push({type:"EntityList",value:r})},AddPrefabId(r){i.push({type:"PrefabId",value:r})},AddPrefabIdList(r){i.push({type:"PrefabIdList",value:r})},AddConfigId(r){i.push({type:"ConfigId",value:r})},AddConfigIdList(r){i.push({type:"ConfigIdList",value:r})},SendSignal(){let r=i.slice();n.serverBridge&&typeof n.serverBridge.receiveFromClient=="function"&&n.serverBridge.receiveFromClient(t,r)}}}audioInteger(t){let i=u.lua_tonumber(t,1);return u.lua_type(t,1)!==u.LUA_TNUMBER||!Number.isSafeInteger(i)?W.luaL_error(t,R("audio argument must be an integer")):i}playAudio(t){this.audioRevision++;let i=this.nextAudioId++,n=this.audioDuration(t),r=Number.isFinite(n)&&n>0,o={instanceId:i,audioId:t,startedAt:this.clock.time,duration:r?n:0,alive:r,stopped:!1};return this.audioHistory.push(o),this.audioHistory.length>128&&this.audioHistory.shift(),r?(this.audios.size>=128&&this.stopAudio(this.audios.keys().next().value),this.audios.set(i,o)):this.audioWarnings.has(t)||(this.audioWarnings.size>=128&&this.audioWarnings.delete(this.audioWarnings.values().next().value),this.audioWarnings.add(t),this.log("warn",`\u97F3\u6548 ${t} \u672A\u5217\u5165\u6A21\u62DF\u5668\u97F3\u9891\u767D\u540D\u5355`)),i}stopAudio(t){let i=this.audios.get(t)||this.audioHistory.find(n=>n.instanceId===t);i&&!i.stopped&&(i.alive=!1,i.stopped=!0,this.audioRevision++),this.audios.delete(t)}audioSnapshot(){return{sequence:this.nextAudioId-1,revision:this.audioRevision,active:[...this.audios.values()].map(t=>({...t})),recent:this.audioHistory.map(t=>({...t}))}}instantiate(t,i,n){if(n==="OnInit"||n==="OnDestroy")return null;let r=this.templates.get(Number(t));if(!r||!i)return null;let o=new Ke(this,{...r,Id:this.nextControlId(),authoringId:null,prefabIndex:Number(t)});return i.addChild(o),o.SetAsLastSibling(),Me(o,a=>this.controlsById.set(a.Id,a)),this.mountSpecScripts(r,o),o}destroyControl(t){if(!(!t||!t.alive)){if(t._destroying)throw new Error(`\u5BA2\u6237\u7AEF\u63A7\u4EF6\u751F\u547D\u5468\u671F\u5904\u4E8E\u521B\u5EFA\u6216\u9500\u6BC1\u65F6\uFF0C\u65E0\u6CD5\u8C03\u7528DestroyClientUIControl, ID:${t.name}`);Me(t,i=>{i._destroying=!0}),this._destroyControlTree(t)}}_destroyControlTree(t){this.releaseControlListeners(t);for(let i of t.scripts.slice())this.unmountScript(i);for(let i of t.children.slice())this._destroyControlTree(i);if(t.alive=!1,this.scrollControls?.delete(t),this._playRemoved.push(t.Id),t.parent){let i=t.parent,n=i.children.indexOf(t);n>=0&&i.children.splice(n,1),t._parent=null,i.markPlayDirty(!0)}else{let i=this.roots.indexOf(t);i>=0&&this.roots.splice(i,1)}this.controlsById.delete(t.Id),this.focus===t&&(this.focus=null);for(let i of[...this.tweens])i.object===t&&i.Kill(!1)}releaseControlListeners(t){for(let i of t.cursorListeners.values())for(let n of i)this.unrefLuaCallback(n);for(let i of t.keyListeners.values())for(let n of i)this.unrefLuaCallback(n);for(let i of t.navListeners.values())for(let n of i)this.unrefLuaCallback(n);t.cursorListeners.clear(),t.keyListeners.clear(),t.navListeners.clear(),t.navConfig.clear()}onControlActiveChanging(t,i){let n=[];Me(t,r=>n.push({control:r,was:r.activeInHierarchy})),t.active=!!i,t.markPlayDirty(!0);for(let r of n){let o=r.control.activeInHierarchy;if(r.was!==o)for(let a of r.control.scripts.slice())o?this.enableScript(a):this.disableScript(a)}}bindScriptEnv(t){let i=t.env;return i?(this.pushScript(i,t),u.lua_setglobal(i,R("script")),i):null}disableScript(t){if(!t?.alive||!t.env||t.lifecyclePhase!=="running")return;let i=this.lifecyclePhase;this.lifecyclePhase="OnDisable",t.lifecyclePhase="OnDisable",this.bindScriptEnv(t),this.callGlobal(t.env,"OnDisable"),t.lifecyclePhase="disabled",this.lifecyclePhase=i}enableScript(t){if(!t?.alive||!t.env||t.lifecyclePhase!=="disabled")return;let i=this.lifecyclePhase;this.lifecyclePhase="OnEnable",t.lifecyclePhase="OnEnable",this.bindScriptEnv(t),this.callGlobal(t.env,"OnEnable"),t.lifecyclePhase="running",this.lifecyclePhase=i}unmountScript(t){if(!t||!t.alive)return;let i=t.env,n=this.lifecyclePhase;i&&(t.lifecyclePhase==="running"&&(this.lifecyclePhase="OnDisable",t.lifecyclePhase="OnDisable",this.bindScriptEnv(t),this.callGlobal(i,"OnDisable")),this.lifecyclePhase="OnDestroy",t.lifecyclePhase="OnDestroy",this.bindScriptEnv(t),this.callGlobal(i,"OnDestroy")),t.alive=!1,t.lifecyclePhase="destroyed",this.lifecyclePhase=n,this.mountedScripts=this.mountedScripts.filter(r=>r!==t),t.object&&(t.object.scripts=t.object.scripts.filter(r=>r!==t)),this.varHandlers=this.varHandlers.filter(r=>r.script!==t),this.signalHandlers=this.signalHandlers.filter(r=>r.script!==t),i&&i!==this.L&&this.closeTrackedLuaState(i),t.env=null}installMetatables(t){this.mtEnum(t),this.mtControl(t),this.mtScript(t),this.mtTween(t),this.mtSeq(t),this.mtSignal(t),this.mtCursor(t)}mtIndexNewindex(t,i,n,r,o,a){W.luaL_newmetatable(t,R(i)),u.lua_pushcfunction(t,l=>{let c=De(l,1)||Ce(u.lua_touserdata(l,1)),s=q(l,2);if(o[s]&&(!a||a(c,s)))return u.lua_pushcfunction(l,o[s]),1;let f;try{f=n(c,s)}catch(h){return W.luaL_error(l,R(String(h.message||h)))}return f===void 0?(u.lua_pushnil(l),1):(ae(l,this,f),1)}),u.lua_setfield(t,-2,R("__index")),u.lua_pushcfunction(t,l=>{try{let c=De(l,1)||Ce(u.lua_touserdata(l,1)),s=q(l,2),f=de(l,this,3);return r(c,s,f),0}catch(c){return u.lua_pushstring(l,R(String(c.message||c))),u.lua_error(l)}}),u.lua_setfield(t,-2,R("__newindex")),u.lua_pushcfunction(t,l=>{let c=De(l,1)||Ce(u.lua_touserdata(l,1)),s=De(l,2)||Ce(u.lua_touserdata(l,2));return u.lua_pushboolean(l,c===s),1}),u.lua_setfield(t,-2,R("__eq")),u.lua_pop(t,1)}method(t){let i=this;return n=>{let r=De(n,1)||Ce(u.lua_touserdata(n,1)),o=u.lua_gettop(n),a=[];for(let l=2;l<=o;l++)a.push(de(n,i,l));try{let l=t(r,...a);if(l===r)return u.lua_pushvalue(n,1),1;if(l===void 0)return 0;if(Array.isArray(l)&&l.__multi){for(let c of l)ae(n,i,c);return l.length}if(Array.isArray(l)&&!(l.length&&typeof l[0]=="object"&&l[0]?.typeofName)){if(l.__controls)return u.lua_createtable(n,l.length,0),l.forEach((c,s)=>{i.pushControl(n,c),u.lua_rawseti(n,-2,s+1)}),1;if(l.__scripts)return u.lua_createtable(n,l.length,0),l.forEach((c,s)=>{i.pushScript(n,c),u.lua_rawseti(n,-2,s+1)}),1;if(typeof l[0]=="number"&&l.length<=4){for(let c of l)u.lua_pushnumber(n,c);return l.length}}return ae(n,i,l),1}catch(l){return u.lua_pushstring(n,R(String(l.message||l))),u.lua_error(n)}}}mtEnum(t){let i=new Set(["Name","FullName","EnumType"]);this.mtIndexNewindex(t,"EnumItem",(n,r)=>i.has(r)?n[r]:void 0,(n,r)=>{throw new Error(`cannot set ${r}, no such field`)},{})}mtCursor(t){let i=new Set(["dragging","touchId"]);this.mtIndexNewindex(t,"CursorEventData",(n,r)=>i.has(r)?n[r]:void 0,(n,r)=>{throw new Error(`cannot set ${r}, no such field`)},{GetUIPos:this.method(n=>n.GetUIPos()),GetPressUIPos:this.method(n=>n.GetPressUIPos()),GetUIPosDelta:this.method(n=>n.GetUIPosDelta())})}mtControl(t){let i={GetChildren:this.method(n=>{let r=n.GetChildren();return r.__controls=!0,r}),GetChild:this.method((n,r)=>n.GetChild(r)),FindChild:this.method((n,r)=>n.FindChild(r)),SetActive:this.method((n,r)=>n.SetActive(r)),SetVisible:this.method((n,r)=>n.SetVisible(r)),GetSiblingIndex:this.method(n=>n.GetSiblingIndex()),SetSiblingIndex:this.method((n,r)=>n.SetSiblingIndex(r)),SetAsFirstSibling:this.method(n=>n.SetAsFirstSibling()),SetAsLastSibling:this.method(n=>n.SetAsLastSibling()),GetAnchoredPosition:this.method(n=>n.GetAnchoredPosition()),SetAnchoredPosition:this.method((n,r,o)=>n.SetAnchoredPosition(r,o)),GetSizeDelta:this.method(n=>n.GetSizeDelta()),SetSizeDelta:this.method((n,r,o)=>n.SetSizeDelta(r,o)),GetAnchorMin:this.method(n=>n.GetAnchorMin()),SetAnchorMin:this.method((n,r,o)=>n.SetAnchorMin(r,o)),GetAnchorMax:this.method(n=>n.GetAnchorMax()),SetAnchorMax:this.method((n,r,o)=>n.SetAnchorMax(r,o)),GetPivot:this.method(n=>n.GetPivot()),SetPivot:this.method((n,r,o)=>n.SetPivot(r,o)),GetLocalScale:this.method(n=>n.GetLocalScale()),SetLocalScale:this.method((n,r,o,a)=>n.SetLocalScale(r,o,a)),GetLocalRotation:this.method(n=>n.GetLocalRotation()),SetLocalRotation:this.method((n,r,o,a)=>n.SetLocalRotation(r,o,a)),GetScriptByPath:this.method((n,r)=>n.GetScriptByPath(r)),GetScript:this.method((n,r)=>n.GetScript(r)),GetScripts:this.method(n=>{let r=n.GetScripts();return r.__scripts=!0,r}),AddCursorEventListener:this.method((n,r,o)=>n.AddCursorEventListener(be(r),o)),RemoveCursorEventListener:this.method((n,r,o)=>n.RemoveCursorEventListener(be(r),o)),RemoveCursorEventListeners:this.method((n,r)=>n.RemoveCursorEventListeners(be(r))),RemoveAllCursorEventListeners:this.method(n=>n.RemoveAllCursorEventListeners()),SimulateCursorClick:this.method(n=>n.SimulateCursorClick()),AddKeyEventListener:this.method((n,r,o)=>n.AddKeyEventListener(be(r),o)),RemoveKeyEventListener:this.method((n,r,o)=>n.RemoveKeyEventListener(be(r),o)),RemoveKeyEventListeners:this.method((n,r)=>n.RemoveKeyEventListeners(be(r))),RemoveAllKeyEventListeners:this.method(n=>n.RemoveAllKeyEventListeners()),AddNavigationEventListener:this.method((n,r,o)=>n.AddNavigationEventListener(be(r),o)),RemoveNavigationEventListener:this.method((n,r,o)=>n.RemoveNavigationEventListener(be(r),o)),RemoveNavigationEventListeners:this.method((n,r)=>n.RemoveNavigationEventListeners(be(r))),RemoveAllNavigationEventListeners:this.method(n=>n.RemoveAllNavigationEventListeners()),SetControllerNavigation:this.method((n,r,o,a)=>n.SetControllerNavigation(be(r),o,a)),GetControllerNavigation:this.method((n,r)=>n.GetControllerNavigation(be(r))),SetImage:this.method((n,r,o)=>n.SetImage(r,o)),SetSoftEdgeWidth:this.method((n,r,o)=>n.SetSoftEdgeWidth(r,o)),SetFillUnused:this.method(n=>n.SetFillUnused()),SetFillHorizontal:this.method((n,r,o)=>n.SetFillHorizontal(r,o)),SetFillVertical:this.method((n,r,o)=>n.SetFillVertical(r,o)),SetFillRadial90:this.method((n,r,o)=>n.SetFillRadial90(r,o)),SetFillRadial180:this.method((n,r,o)=>n.SetFillRadial180(r,o)),SetFillRadial360:this.method((n,r,o)=>n.SetFillRadial360(r,o)),PlayAnimation:this.method(n=>n.PlayAnimation()),StopAnimation:this.method(n=>n.StopAnimation()),RefreshItems:this.method((n,r,o)=>{this.retainLuaCallback(o);try{n.RefreshItems(r,o)}finally{this.unrefLuaCallback(o)}}),GetItemIndex:this.method((n,r)=>n.GetItemIndex(r)),GetItemSize:this.method(n=>n.GetItemSize()),GetItemSpacing:this.method(n=>n.GetItemSpacing()),GetPadding:this.method(n=>n.GetPadding()),ScrollToItemAt:this.method((n,r,o)=>n.ScrollToItemAt(r,o)),GetContentLength:this.method(n=>n.GetContentLength())};this.mtIndexNewindex(t,"Control",(n,r)=>{if(!gn(n,r))return;if(!n.alive&&r!=="alive")throw new Error(`attempt to read '${r}' of a destroyed control`);let o=n.luaFieldValue(r),a=So[r];return a?vn(a,o):typeof o=="number"&&!Gl.has(r)&&!Vl.has(r)?new Ht(o):o},(n,r,o)=>{if(gn(n,r)==="rw"){if((r==="fontSize"||r==="minimumFontSize")&&!Number.isInteger(o)){let c=o===null?"nil":typeof o;throw new Error(`bad argument #2 to '${r}' (integer expected, got ${c})`)}let l=So[r];n[r]=l?vn(l,o):o,typeof n.markPlayDirty=="function"&&n.markPlayDirty(wi.has(r));return}throw new Error(`cannot set ${r}, no such field`)},i,po)}mtScript(t){let i=this,n=new Set(["alive","scriptMappingId","object","path","enabled"]);this.mtIndexNewindex(t,"Script",(r,o)=>n.has(o)?r[o]:void 0,(r,o,a)=>{if(o==="enabled"){r.enabled=!!a;return}throw new Error(`cannot set ${o}, no such field`)},{GetParam:this.method((r,o)=>Object.prototype.hasOwnProperty.call(r.params,o)?r.params[o]:null),Invoke:r=>i.luaInvoke(r),EnableUpdate:this.method((r,o)=>{r.updateEnabled=!!o}),RegisterServerSignalHandler:this.method((r,o,a)=>{i.signalHandlers.push({script:r,name:o,fn:a})}),UnregisterServerSignalHandler:this.method((r,o)=>{i.signalHandlers=i.signalHandlers.filter(a=>!(a.script===r&&a.name===o))}),RegisterCustomVariableChangedHandler:this.method((r,o,a,l)=>{i.varHandlers.push({script:r,entityType:be(o),name:a,fn:l})}),UnregisterCustomVariableChangedHandler:this.method((r,o,a)=>{let l=be(o);i.varHandlers=i.varHandlers.filter(c=>!(c.script===r&&c.entityType===l&&c.name===a))})})}mtTween(t){this.mtIndexNewindex(t,"Tween",()=>{},()=>{},{SetEase:this.method((i,n)=>i.SetEase(n)),SetRelative:this.method((i,n)=>i.SetRelative(n)),Play:this.method(i=>i.Play()),Pause:this.method(i=>i.Pause()),Resume:this.method(i=>i.Resume()),Restart:this.method(i=>i.Restart()),Complete:this.method(i=>i.Complete()),Kill:this.method((i,n)=>i.Kill(n)),SetOnComplete:this.method((i,n)=>i.SetOnComplete(n)),SetOnStepComplete:this.method((i,n)=>i.SetOnStepComplete(n)),SetLoops:this.method((i,n)=>i.SetLoops(n))})}mtSeq(t){this.mtIndexNewindex(t,"TweenSequence",()=>{},()=>{},{Append:this.method((i,n)=>i.Append(n)),AppendInterval:this.method((i,n)=>i.AppendInterval(n)),AppendCallback:this.method((i,n)=>i.AppendCallback(n)),Join:this.method((i,n)=>i.Join(n)),Insert:this.method((i,n,r)=>i.Insert(n,r)),InsertCallback:this.method((i,n,r)=>i.InsertCallback(n,r)),Play:this.method(i=>i.Play()),Pause:this.method(i=>i.Pause()),Resume:this.method(i=>i.Resume()),Restart:this.method(i=>i.Restart()),Complete:this.method(i=>i.Complete()),Kill:this.method((i,n)=>i.Kill(n)),SetOnComplete:this.method((i,n)=>i.SetOnComplete(n)),SetOnStepComplete:this.method((i,n)=>i.SetOnStepComplete(n)),SetLoops:this.method((i,n)=>i.SetLoops(n))})}mtSignal(t){this.mtIndexNewindex(t,"ServerSignal",()=>{},()=>{},{AddParam:this.method((i,n,r)=>i.AddParam(n,r)),SendSignal:this.method(i=>i.SendSignal()),AddInt:this.method((i,n)=>i.AddInt(n)),AddIntList:this.method((i,n)=>i.AddIntList(n)),AddFloat:this.method((i,n)=>i.AddFloat(n)),AddFloatList:this.method((i,n)=>i.AddFloatList(n)),AddString:this.method((i,n)=>i.AddString(n)),AddStringList:this.method((i,n)=>i.AddStringList(n)),AddVector3:this.method((i,n)=>i.AddVector3(n)),AddVector3List:this.method((i,n)=>i.AddVector3List(n)),AddBool:this.method((i,n)=>i.AddBool(n)),AddBoolList:this.method((i,n)=>i.AddBoolList(n)),AddGuid:this.method((i,n)=>i.AddGuid(n)),AddGuidList:this.method((i,n)=>i.AddGuidList(n)),AddEntity:this.method((i,n)=>i.AddEntity(n)),AddEntityList:this.method((i,n)=>i.AddEntityList(n)),AddPrefabId:this.method((i,n)=>i.AddPrefabId(n)),AddPrefabIdList:this.method((i,n)=>i.AddPrefabIdList(n)),AddConfigId:this.method((i,n)=>i.AddConfigId(n)),AddConfigIdList:this.method((i,n)=>i.AddConfigIdList(n))})}luaRequire(t){let i=q(t,1),n=this.normalizeRequirePath(i),r=this.requireAliases.get(n)||n;u.lua_rawgeti(t,at,u.LUA_RIDX_MAINTHREAD);let o=u.lua_tothread(t,-1);u.lua_pop(t,1);let a=this.requireCache.get(o);a||(a=new Map,this.requireCache.set(o,a));let l=a.get(r);if(l?.loading)return u.lua_pushstring(t,R(`failed to load script '${n}': cyclic require`)),u.lua_error(t);if(l&&l.ref!=null)return u.lua_rawgeti(t,at,l.ref),1;let c=this.scriptFiles.get(r);if(c==null)return u.lua_pushstring(t,R(`failed to load script '${n}'`)),u.lua_error(t);let s=u.lua_gettop(t);a.set(r,{loading:!0});try{this.loadModule(t,o,r,c),u.lua_pushvalue(t,-1);let f=W.luaL_ref(t,at);return a.set(r,{ref:f}),1}catch(f){return a.delete(r),u.lua_settop(t,s),u.lua_pushstring(t,R(`failed to load script '${n}': ${f.message||f}`)),u.lua_error(t)}}newLuaThread(){let t=W.luaL_newstate();return io.luaL_openlibs(t),so(t),this.installMetatables(t),this.installGlobals(t),this.luaStates.add(t),u.lua_pushglobaltable(t),this.copyLuaEnvironment(t,-1),u.lua_remove(t,-2),this.moduleBaseEnvironments.set(t,W.luaL_ref(t,at)),t}copyLuaEnvironment(t,i){let n=u.lua_absindex(t,i);u.lua_newtable(t);let r=u.lua_absindex(t,-1);for(u.lua_pushnil(t);u.lua_next(t,n)!==0;)u.lua_pushvalue(t,-2),u.lua_pushvalue(t,-2),u.lua_rawset(t,r),u.lua_pop(t,1);u.lua_pushvalue(t,r),u.lua_setfield(t,r,R("_G"))}closeTrackedLuaState(t){if(!t||!this.luaStates.has(t))return;for(let n of this.requireCache.get(t)?.values()||[])n.ref!=null&&W.luaL_unref(t,at,n.ref);this.requireCache.delete(t);let i=this.moduleBaseEnvironments.get(t);if(i!=null&&W.luaL_unref(t,at,i),this.moduleBaseEnvironments.delete(t),this.luaStates.delete(t),this.luaFunctions)for(let[n,r]of this.luaFunctions)r.__luaState===t&&this.luaFunctions.delete(n);lo(t)}loadModule(t,i,n,r){let o={__kind:"Script",alive:!0,scriptMappingId:this.resolveScriptMappingId(),object:null,path:n,enabled:!0,updateEnabled:!1,params:{},env:t,invoke(){}},a=String(r).replace(/^\uFEFF/,""),l=vi(a);if(W.luaL_loadbuffer(t,l,l.length,R(`@${n}`))!==Ee)throw new Error(q(t,-1));let s=u.lua_absindex(t,-1);if(u.lua_rawgeti(t,at,this.moduleBaseEnvironments.get(i)),this.copyLuaEnvironment(t,-1),u.lua_remove(t,-2),this.pushScript(t,o),u.lua_setfield(t,-2,R("script")),u.lua_setupvalue(t,s,1),u.lua_pcall(t,0,1,0)!==Ee)throw new Error(q(t,-1))}mountScript({path:t,source:i,control:n,params:r={},scriptMappingId:o=void 0}){this.L||this.boot();let a=this.newLuaThread(),l={__kind:"Script",alive:!0,scriptMappingId:this.resolveScriptMappingId(o),object:n,path:this.normalizeRequirePath(t),enabled:!0,updateEnabled:!1,params:r,env:a,lifecyclePhase:"idle"};l.invoke=(s,f)=>this.invokeOn(a,s,f),n&&n.scripts.push(l),this.mountedScripts.push(l),this.pushScript(a,l),u.lua_setglobal(a,R("script"));let c=this.lifecyclePhase;try{this.lifecyclePhase="OnInit",l.lifecyclePhase="OnInit",this.runChunk(a,i,t);let s=this.callGlobal(a,"OnInit");s&&this.mountErrors.push(s),this.lifecyclePhase="OnEnable",l.lifecyclePhase="OnEnable";let f=this.callGlobal(a,"OnEnable");f&&this.mountErrors.push(f),this.lifecyclePhase="OnStart",l.lifecyclePhase="OnStart";let h=this.callGlobal(a,"OnStart");return h&&this.mountErrors.push(h),this.lifecyclePhase="running",l.lifecyclePhase="running",l}catch(s){throw l.alive=!1,l.lifecyclePhase="failed",this.mountedScripts=this.mountedScripts.filter(f=>f!==l),n&&(n.scripts=n.scripts.filter(f=>f!==l)),this.varHandlers=this.varHandlers.filter(f=>f.script!==l),this.signalHandlers=this.signalHandlers.filter(f=>f.script!==l),this.lifecyclePhase=c,a&&a!==this.L&&this.closeTrackedLuaState(a),l.env=null,s}}runChunk(t,i,n){let r=String(i).replace(/^\uFEFF/,""),o=vi(r),a=W.luaL_loadbuffer(t,o,o.length,R(`@${n}`));if(a!==Ee){let c=q(t,-1)||`luaL_loadbuffer status ${a}`;throw u.lua_pop(t,1),new Error(c)}let l=u.lua_pcall(t,0,0,0);if(l!==Ee){let c=q(t,-1)||`lua_pcall status ${l}`;throw u.lua_pop(t,1),new Error(c)}}callGlobal(t,i){if(u.lua_getglobal(t,R(i)),u.lua_isfunction(t,-1)){if(u.lua_pcall(t,0,0,0)!==Ee){let r=q(t,-1);u.lua_pop(t,1);let o=`${i}: ${r}`;return this.log("lua-error",o),o}}else u.lua_pop(t,1);return null}callGlobalDt(t,i,n){if(u.lua_getglobal(t,R(i)),u.lua_isfunction(t,-1)){if(u.lua_pushnumber(t,n),u.lua_pcall(t,1,0,0)!==Ee){let o=q(t,-1);u.lua_pop(t,1),this.log("lua-error",`${i}: ${o}`)}}else u.lua_pop(t,1)}luaInvoke(t){let i=De(t,1);if(!i||i.__kind!=="Script")return W.luaL_error(t,R("bad self to 'Invoke' (Script expected)"));let n=q(t,2),r=i.env;if(!r||r.l_G!==t.l_G){let c=[];for(let h=3;h<=u.lua_gettop(t);h++)c.push(de(t,this,h));let s;try{s=i.invoke(n,c)}catch(h){return W.luaL_error(t,R(String(h.message||h)))}if(s===void 0)return 0;let f=Array.isArray(s)&&s.__multi?s:[s];for(let h of f)ae(t,this,h);return f.length}let o=2;if(u.lua_getglobal(t,R(n)),!u.lua_isfunction(t,-1))return 0;u.lua_replace(t,o),u.lua_remove(t,1);let a=u.lua_gettop(t)-1;return u.lua_pcall(t,a,wo,0)!==Ee?u.lua_error(t):u.lua_gettop(t)}invokeOn(t,i,n){let r=u.lua_gettop(t);if(u.lua_getglobal(t,R(i)),!u.lua_isfunction(t,-1)){u.lua_settop(t,r);return}for(let c of n)ae(t,this,c);if(u.lua_pcall(t,n.length,wo,0)!==Ee){let c=q(t,-1);throw u.lua_settop(t,r),new Error(c)}let a=u.lua_gettop(t)-r;if(a<=0){u.lua_settop(t,r);return}if(a===1){let c=de(t,this,-1);return u.lua_settop(t,r),c}let l=[];for(let c=1;c<=a;c++)l.push(de(t,this,r+c));return u.lua_settop(t,r),l.__multi=!0,l}runScriptPhase(t,i){for(let n of this.mountedScripts){if(!this.scriptCanRun(n))continue;let r=n.env;r&&(this.pushScript(r,n),u.lua_setglobal(r,R("script")),!(t==="OnUpdate"&&!n.updateEnabled)&&this.callGlobalDt(r,t,i))}}step(t=1/30){if(typeof t!="number"||!Number.isFinite(t)||t<0)throw new TypeError("dt must be a finite non-negative number");this.clock.frame++,this.clock.time+=t;for(let[n,r]of this.audios)this.clock.time+1e-9>=r.startedAt+r.duration&&(r.alive=!1,this.audios.delete(n),this.audioRevision++);let i=!this.clock.paused;for(let n of[...this.animations])n.step(t);this.runScriptPhase("OnUpdate",t),i&&(this.clock.levelTime+=t,this.runScriptPhase("OnLevelUpdate",t))}injectKey(t){let i=n=>{if(!n.alive||!n.activeInHierarchy)return!1;if(n.keyListeners.has(t)&&n.emitKey(t))return!0;for(let r of[...n.children])if(i(r))return!0;return!1};for(let n of[...this.roots])i(n)}injectCursor(t,i,n){let r=n||this.makeCursorEventData({});Number.isFinite(r.x)&&Number.isFinite(r.y)&&(this.cursor.x=r.x,this.cursor.y=r.y),t.emitCursor(i,r)}getVar(t,i){if(this.serverBridge&&typeof this.serverBridge.getVar=="function")return this.serverBridge.getVar(t,i);let n=this.serverVars[t];return n?n[i]:void 0}notifyVarHandlers(t,i){for(let n of this.varHandlers)this.scriptCanRun(n.script)&&n.entityType===t&&n.name===i&&this.safeCall(n.fn,this.enumTree.CustomVariableEntityType[t],i)}setVar(t,i,n){if(this.serverBridge&&typeof this.serverBridge.setVar=="function"){this.serverBridge.setVar(t,i,n);return}let r=this.serverVars[t]||(this.serverVars[t]=Object.create(null));r[i]=n,this.notifyVarHandlers(t,i)}sendClientSignal(t,i){for(let n of this.signalHandlers)this.scriptCanRun(n.script)&&n.name===t&&this.safeCall(n.fn,t,i)}evalQueryScript(t,i){this.L||this.boot();let n=this.L;u.lua_createtable(n,0,5);let r=(o,a)=>{u.lua_pushcfunction(n,a),u.lua_setfield(n,-2,R(o))};return r("var",o=>(ae(o,this,i.var(q(o,1),q(o,2))),1)),r("logContains",o=>(u.lua_pushboolean(o,i.logContains(q(o,1))),1)),r("control",o=>(ae(o,this,i.control(q(o,1))),1)),r("logs",o=>(ae(o,this,i.logs()),1)),r("signals",o=>(ae(o,this,i.signals(q(o,1))),1)),r("serverLogs",o=>(ae(o,this,i.serverLogs?i.serverLogs():[]),1)),r("serverLogContains",o=>{let a=i.serverLogContains;return u.lua_pushboolean(o,a?!!a(q(o,1)):!1),1}),u.lua_setglobal(n,R("query")),this.runChunk(n,t,"autotest-assert"),!0}destroy(){for(let t of this.roots.slice())this.destroyControl(t);for(let t of this.mountedScripts.slice())this.unmountScript(t);this.lifecyclePhase="idle",this.mountedScripts=[],this.luaFunctions.clear();for(let t of[...this.luaStates])this.closeTrackedLuaState(t);this.L=null,this.audios.clear(),this.audioHistory.length=0,this.audioWarnings.clear()}};function Jt(e){let t=new ki(e);return t.boot(),t}var st=Object.freeze(Array.from({length:8},(e,t)=>`Player${t+1}`)),In=Object.freeze(Array.from({length:8},(e,t)=>`Avatar${t+1}`)),Po=Object.freeze(["Level","PlayerSelf","AvatarSelf"]);var wn=Object.freeze([...Po,...st,...In]),Ro=Object.freeze(["PlayerSelf","AllPlayers",...st]),Bl=Object.freeze(["Level","PlayerSelf",...st]),Co=Object.freeze(["Int","Float","String","Bool","Vector3","Entity","Guid","PrefabId","ConfigId","IntList","FloatList","StringList","BoolList","Vector3List","EntityList","GuidList","PrefabIdList","ConfigIdList","Dict","Struct"]),Ul=-2147483648,jl=2147483647,Xl=new Set(["set-custom-variable","get-custom-variable","custom-variable-changed","\u8BBE\u7F6E\u81EA\u5B9A\u4E49\u53D8\u91CF","\u83B7\u53D6\u81EA\u5B9A\u4E49\u53D8\u91CF","\u81EA\u5B9A\u4E49\u53D8\u91CF\u53D8\u5316\u65F6","send-signal","listen-signal","send-client-script-signal","\u53D1\u9001\u4FE1\u53F7","\u76D1\u542C\u4FE1\u53F7","\u53D1\u9001\u5BA2\u6237\u7AEF\u811A\u672C\u4FE1\u53F7","setVar","getVar","signal","var"]);function Zt(e){return`Player${Number(e)}`}function Ei(e){return`Avatar${Number(e)}`}function Io(e){let t=String(e||"").match(/^(?:Player|Avatar)([1-8])$/);return t?Number(t[1]):0}function lt(e){if(e==null||e==="")return 1;let t=Number(e);if(!Number.isInteger(t)||t<1||t>8)throw new Error("playerCount must be an integer 1-8");return t}function $e(e,t=8){let i=lt(t);if(e==null||e==="")return 1;let n=Number(e);if(!Number.isInteger(n)||n<1||n>i)throw new Error(`playerIndex must be an integer 1-${i}`);return n}function xo(){let e={Level:Object.create(null),PlayerSelf:Object.create(null),AvatarSelf:Object.create(null)};for(let t of st)e[t]=Object.create(null);for(let t of In)e[t]=Object.create(null);return e}function To(e){let t=String(e||"");if(!wn.includes(t))throw new Error(`unknown CustomVariableEntityType: ${e}`);return t}function Hl(e,t){let i=To(e);if(!Bl.includes(i))throw new Error(`${t}.entityType must be Level, PlayerSelf, or Player1-8`);return i}function Qt(e){let t=String(e??"");if(!t)throw new Error("custom variable name is required");return t}function Ai(e){let t=String(e??"");if(!t)throw new Error("signal name is required");return t}function Cn(e){let t=String(e||"PlayerSelf");if(!Ro.includes(t))throw new Error(`unsupported client signal target: ${e}. use PlayerSelf, AllPlayers, or Player1-8`);return t}function ei(e){if(e==null)return"";if(typeof e=="boolean")return"Bool";if(typeof e=="string")return"String";if(typeof e=="number")return Number.isInteger(e)?"Int":"Float";if(Array.isArray(e)){if(e.length===0)return"IntList";let t=ei(e[0]);return t&&!t.endsWith("List")&&t!=="Dict"&&t!=="Struct"?`${t}List`:"IntList"}return e&&typeof e=="object"?"x"in e||"y"in e||"z"in e?"Vector3":"Dict":""}function Se(e){return e===void 0?null:JSON.parse(JSON.stringify(e))}function ko(e){return Array.isArray(e)?e.map(t=>t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"value")&&"type"in t?t.value:t):[]}function Eo(e){return Array.isArray(e)?e.map(t=>t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"value")&&"type"in t?{type:String(t.type||""),value:t.value}:{type:ei(t),value:t}):[]}function Kl(e){return String(e?.kind||e?.type||e?.name||e?.id||"")}function _i(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Mo(e,t){if(!_i(e)||!Object.prototype.hasOwnProperty.call(e,"fromSignalParam"))return null;if(Object.keys(e).some(n=>n!=="fromSignalParam"))throw new Error(`${t}.fromSignalParam cannot be combined with literal fields`);let i=Number(e.fromSignalParam);if(!Number.isSafeInteger(i)||i<0)throw new Error(`${t}.fromSignalParam must be a non-negative integer`);return{fromSignalParam:i}}function Ao(e,t){return Mo(e,t)||Se(e)}function ql(e,t,i){if(!_i(e))throw new Error(`serverLogic.rules[${t}].actions[${i}] must be an object`);let n=String(e.kind||e.type||""),r=`serverLogic.rules[${t}].actions[${i}]`;if(n==="setCustomVariable"){let o=Hl(e.entityType,r);if(!Object.prototype.hasOwnProperty.call(e,"value"))throw new Error(`${r}.value is required`);return{kind:n,entityType:o,name:Qt(e.name),value:Ao(e.value,`${r}.value`),...e.variableType?{variableType:String(e.variableType)}:{}}}if(n==="sendClientScriptSignal"){if(!Array.isArray(e.params))throw new Error(`${r}.params must be an array`);return{kind:n,target:Cn(e.target),signalName:Ai(e.signalName),params:e.params.map((o,a)=>Ao(o,`${r}.params[${a}]`))}}throw new Error(`${r}.kind must be setCustomVariable or sendClientScriptSignal`)}function ti(e){if(e==null)return{version:1,rules:[]};if(!_i(e))throw new Error("serverLogic must be an object");let t=e.rules===void 0?[]:e.rules;if(!Array.isArray(t))throw new Error("serverLogic.rules must be an array");return{version:1,rules:t.map((i,n)=>{if(!_i(i))throw new Error(`serverLogic.rules[${n}] must be an object`);if(!Array.isArray(i.actions)||i.actions.length===0)throw new Error(`serverLogic.rules[${n}].actions must be a non-empty array`);return{id:String(i.id||`signal-${n+1}`),signalName:Ai(i.signalName),actions:i.actions.map((r,o)=>ql(r,n,o))}})}}function _o(e,t,{typed:i=!1}={}){let n=Mo(e,"server logic value");if(n){let r=i?t.params:t.values;if(n.fromSignalParam>=r.length)throw new Error(`signal ${t.name} has no parameter at index ${n.fromSignalParam}`);return Se(r[n.fromSignalParam])}return Se(e)}function Ll(e){return e==="Level"?"Level":st.includes(e)?"PlayerSelf":In.includes(e)?"AvatarSelf":e}function No(e={}){let t=xo(),i=xo(),n=[],r=[],o=[],a=[],l=Array.from({length:9},()=>null),c=1,s=0,f=Number(e.onlineLatencyMs||0);(!Number.isFinite(f)||f<0)&&(f=0);let h=ti(e.logic),m=lt(e.playerCount),p=$e(e.viewPlayerIndex,m);function y(b,k){a.push({source:"server",level:String(b||"engine"),text:String(k),time:s})}function v(b){let k=l[b||p],S=Number(k?.clock?.time);Number.isFinite(S)&&(s=S)}function E(b,k,S,I){t[b][k]=S,i[b][k]={type:I||ei(S)||i[b][k]?.type||""}}function x(b,k,S){return typeof S!="number"||!Number.isInteger(S)?{ok:!0,value:S}:S>=Ul&&S<=jl?{ok:!0,value:S}:(y("engine",`Int custom variable ${b}.${k} out of range ${S}; keeping previous legal value`),{ok:!1,value:t[b][k]})}function A(b,k){let S=To(b),I=k||p;return S==="PlayerSelf"?Zt(I):S==="AvatarSelf"?Ei(I):S}function $(b,k){let S=Ll(b);if(b==="Level"){for(let w=1;w<=m;w+=1){let M=l[w];M&&typeof M.notifyVarHandlers=="function"&&M.notifyVarHandlers("Level",k)}return}let I=Io(b);if(!I)return;let F=l[I];F&&typeof F.notifyVarHandlers=="function"&&F.notifyVarHandlers(S,k)}function O(b,k){let S=Cn(b);return S==="AllPlayers"?Array.from({length:m},(I,F)=>F+1):S==="PlayerSelf"?[k||p]:[Io(S)]}function J(b){for(let k of h.rules)if(k.signalName===b.name)for(let S of k.actions){if(S.kind==="setCustomVariable"){let I=_o(S.value,b);z.setVar(S.entityType,S.name,I,{type:S.variableType,playerIndex:b.playerIndex}),y("info",`logic ${k.id}: set ${S.entityType}.${S.name}`);continue}if(S.kind==="sendClientScriptSignal"){let I=S.params.map(F=>_o(F,b,{typed:!0}));z.sendToClient(S.signalName,I,{target:S.target,playerIndex:b.playerIndex}),y("info",`logic ${k.id}: sent ${S.signalName} to ${S.target}`)}}}function ee(b,k){b&&(b.serverBridge={getVar:(S,I)=>z.getVar(S,I,{playerIndex:k}),setVar:(S,I,F)=>z.setVar(S,I,F,{playerIndex:k}),receiveFromClient:(S,I)=>z.receiveFromClient(S,I,{playerIndex:k})})}function Z(b){b&&(b.serverBridge=null)}let z={ENTITY_TYPES:Po,ALL_ENTITY_TYPES:wn,CLIENT_SIGNAL_TARGETS:Ro,get clock(){return s},get playerCount(){return m},get viewPlayerIndex(){return p},setClock(b){s=Number(b)||0},setPlayerCount(b){return m=lt(b),p>m&&(p=m),m},setViewPlayerIndex(b){return p=$e(b,m),p},log(b,k){y(b,k)},defineVar(b,k,S={},{playerIndex:I}={}){let F=A(b,I),w=Qt(k);if(Object.prototype.hasOwnProperty.call(t[F],w))throw new Error(`custom variable already exists: ${F}.${w}`);let M=S.type?String(S.type):ei(S.value??S.defaultValue);if(M&&!Co.includes(M))throw new Error(`unsupported custom variable type: ${M}`);let G=S.value!==void 0?S.value:S.defaultValue!==void 0?S.defaultValue:null;return E(F,w,G,M),z.getVar(F,w)},getVar(b,k,{playerIndex:S}={}){let I=A(b,S),F=Qt(k);if(!Object.prototype.hasOwnProperty.call(t[I],F)){y("engine",`GetGlobalCustomVariableValue missing ${I}.${F}; returning nil (simulator policy)`);return}return t[I][F]},setVar(b,k,S,{notify:I=!0,type:F,playerIndex:w}={}){let M=A(b,w),G=Qt(k),U=F||i[M][G]?.type||ei(S);if(U&&!Co.includes(U)&&U!=="")throw new Error(`unsupported custom variable type: ${U}`);let le=S;if(!((U==="Int"||U===""&&typeof S=="number"&&Number.isInteger(S))&&(le=x(M,G,S).value,le===void 0)))return E(M,G,le,U),I&&$(M,G),le},listVars(b){let k=b?[A(b)]:["Level",...Array.from({length:m},(I,F)=>Zt(F+1)),...Array.from({length:m},(I,F)=>Ei(F+1))],S=[];for(let I of k)for(let F of Object.keys(t[I]))S.push({entityType:I,name:F,type:i[I][F]?.type||"",value:Se(t[I][F])});return S},receiveFromClient(b,k=[],{playerIndex:S}={}){let I=$e(S||p,m);v(I);let F=Ai(b),w={id:c++,direction:"inbound",name:F,params:Eo(k),values:ko(k),time:s,playerIndex:I,from:Zt(I)};return n.push(w),J(w),w},sendToClient(b,k=[],{target:S="PlayerSelf",playerIndex:I}={}){let F=Ai(b),w=Cn(S),G=O(w,I||p),U={id:c++,direction:"outbound",name:F,params:Eo(k),values:ko(k),time:s,target:w,players:G,deliverAt:s+f/1e3,delivered:!1};return r.push(U),f===0?z.deliver(U):o.push(U),U},getLogic(){return Se(h)},setLogic(b){return h=ti(b),z.getLogic()},deliver(b){if(!b||b.delivered)return;b.delivered=!0;let k=Array.isArray(b.players)&&b.players.length?b.players:O(b.target);for(let S of k){let I=l[S];I&&typeof I.sendClientSignal=="function"&&I.sendClientSignal(b.name,b.values)}},flush(b){b!==void 0&&(s=Number(b)||0);let k=[];for(let S=o.length-1;S>=0;S-=1)o[S].deliverAt<=s&&k.push(o.splice(S,1)[0]);k.sort((S,I)=>S.id-I.id);for(let S of k)z.deliver(S);return k},inbound(){return n.slice()},outbound(){return r.slice()},loadConfig(b){if(b!=null){if(typeof b!="object")throw new Error("server config must be an object");if(b.graph&&!Array.isArray(b.nodes))throw new Error("unsupported server node graph: v1 only accepts custom variables and signals");for(let k of b.nodes||[]){let S=Kl(k);if(!Xl.has(S))throw new Error(`unsupported server node: ${S||JSON.stringify(k)}. v1 only supports custom variables and signals`)}if(b.onlineLatencyMs!==void 0){let k=Number(b.onlineLatencyMs);if(!Number.isFinite(k)||k<0)throw new Error("onlineLatencyMs must be a non-negative finite number");f=k}b.playerCount!==void 0&&z.setPlayerCount(b.playerCount),b.viewPlayerIndex!==void 0&&z.setViewPlayerIndex(b.viewPlayerIndex),(b.logic!==void 0||b.serverLogic!==void 0)&&z.setLogic(b.logic??b.serverLogic);for(let k of b.vars||[]){let S=A(k.entityType),I=Qt(k.name);Object.prototype.hasOwnProperty.call(t[S],I)?z.setVar(S,I,k.value??k.defaultValue,{notify:!1,type:k.type}):z.defineVar(S,I,k)}}},attachRuntime(b,{playerIndex:k=1}={}){let S=$e(k,8);return l[S]&&l[S]!==b&&Z(l[S]),l[S]=b||null,ee(l[S],S),z},attachRuntimes(b){z.detachRuntime();let k=Array.isArray(b)?b:[];for(let S=0;S<k.length&&S<8;S+=1)l[S+1]=k[S]||null,ee(l[S+1],S+1);return z},detachRuntime(){for(let b=1;b<=8;b+=1)Z(l[b]),l[b]=null},snapshot(){let b=Zt(p),k=Ei(p),S={Level:{},PlayerSelf:{},AvatarSelf:{}};for(let I of Object.keys(t.Level))S.Level[I]={type:i.Level[I]?.type||"",value:Se(t.Level[I])};for(let I of Object.keys(t[b]))S.PlayerSelf[I]={type:i[b][I]?.type||"",value:Se(t[b][I])};for(let I of Object.keys(t[k]))S.AvatarSelf[I]={type:i[k][I]?.type||"",value:Se(t[k][I])};for(let I=1;I<=m;I+=1){let F=Zt(I),w=Ei(I);S[F]={},S[w]={};for(let M of Object.keys(t[F]))S[F][M]={type:i[F][M]?.type||"",value:Se(t[F][M])};for(let M of Object.keys(t[w]))S[w][M]={type:i[w][M]?.type||"",value:Se(t[w][M])}}return{clock:s,onlineLatencyMs:f,playerCount:m,viewPlayerIndex:p,logic:z.getLogic(),vars:S,inbound:n.map(I=>({id:I.id,name:I.name,params:Se(I.params),values:Se(I.values),time:I.time,playerIndex:I.playerIndex,from:I.from})),outbound:r.map(I=>({id:I.id,name:I.name,params:Se(I.params),values:Se(I.values),time:I.time,target:I.target,players:Array.isArray(I.players)?I.players.slice():[],deliverAt:I.deliverAt,delivered:!!I.delivered})),logs:a.map(I=>({source:"server",level:I.level,text:I.text,time:I.time}))}},reset(){for(let b of wn){for(let k of Object.keys(t[b]))delete t[b][k];for(let k of Object.keys(i[b]))delete i[b][k]}n.length=0,r.length=0,o.length=0,a.length=0,c=1,s=0},destroy(){z.detachRuntime(),z.reset()}};e.config&&z.loadConfig(e.config);for(let b of e.vars||[])z.defineVar(b.entityType,b.name,b);return z}var Wl={container:"container",textbox:"textbox",image:"image",button:"button",cursor:"cursor",grid:"grid",reference:"reference",textwindow:"textwindow",keyhint:"keyhint",animation:"animation",fullscreen:"fullscreen"};function xn(e,t,i=null){let n=Ue(e.transformByPlatform,t),r={authoringId:e.id,kind:Wl[e.kind]||"container",name:e.name,prefabIndex:e.guid||0,active:e.active!==!1,visible:e.visible!==!1,canControllerFocus:e.canControllerFocus===!0,anchoredPositionX:n.offset.x,anchoredPositionY:n.offset.y,sizeDeltaX:n.size.x,sizeDeltaY:n.size.y,anchorMinX:n.anchorMin.x,anchorMinY:n.anchorMin.y,anchorMaxX:n.anchorMax.x,anchorMaxY:n.anchorMax.y,pivotX:n.pivot.x,pivotY:n.pivot.y,localScaleX:n.scale.x,localScaleY:n.scale.y,localScaleZ:n.scale.z,localRotationX:n.rotation.x,localRotationY:n.rotation.y,localRotationZ:n.rotation.z,children:(e.children||[]).map(a=>xn(a,t,i))},o=i?.get(e.id);return o?.length&&(r.scripts=o.map(a=>{let l=Number(a.guid);return{path:a.path||a.id,source:a.source||"",...Number.isSafeInteger(l)&&l>0?{scriptMappingId:l}:{}}})),e.kind==="container"&&(r.isolateNavigation=e.isolateNavigation===!0,r.disableKeyEventPassthrough=e.disableKeyEventPassthrough===!0,r.disableCursorEventPassthrough=e.disableCursorEventPassthrough===!0,r.showCursor=e.showCursor===!0),(e.kind==="textbox"||e.kind==="textwindow")&&(r.text=e.text??"",r.fontSize=e.fontSize,r.adaptiveFontSize=e.adaptiveFontSize===!0,r.minimumFontSize=e.minimumFontSize,r.fontColor=e.fontColor,r.bgColor=e.bgColor,r.enableOutline=e.enableOutline!==!1,r.outlineColor=e.outlineColor,r.horizontalAlignment=e.horizontalAlignment||"Left",r.verticalAlignment=e.verticalAlignment||"Top",e.kind==="textwindow"&&(r.interactable=e.interactable!==!1,r.showScrollBar=e.showScrollBar!==!1)),e.kind==="image"&&(r.imageSource=e.imageSource,r.imageId=e.imageId??0,r.imageColor=e.imageColor,r.raycastTarget=e.raycastTarget===!0,r.enableMask=e.enableMask===!0,r.enableSoftEdge=e.enableSoftEdge===!0,r.softEdgeMode=e.softEdgeMode,r.softEdgeWidthX=e.softEdgeWidthX,r.softEdgeWidthY=e.softEdgeWidthY,r.horizontalSoftRange=e.horizontalSoftRange,r.verticalSoftRange=e.verticalSoftRange,r.enableFill=e.enableFill===!0,r.fillType=e.enableFill?e.fillType:"Unused",r.fillHorizontalType=e.fillHorizontalType,r.fillVerticalType=e.fillVerticalType,r.fillRadial90Type=e.fillRadial90Type,r.fillRadialType=e.fillRadialType,r.fillAmount=e.fillAmount,r.reverseMaskArea=e.reverseMaskArea===!0),e.kind==="button"&&(r.raycastTarget=e.raycastTarget!==!1,r.interactable=e.interactable!==!1,r.clickAudioId=e.clickAudioId,r.unavailableChildId=e.unavailableChildId??null,r.hoverChildId=e.hoverChildId??null,r.pressedChildId=e.pressedChildId??null,r.selectedChildId=e.selectedChildId??null),e.kind==="cursor"&&(r.raycastTarget=e.raycastTarget!==!1),e.kind==="reference"&&(r.referencedPrefabIndex=e.referencedPrefabId),e.kind==="grid"&&(r.itemPrefabIndex=e.itemPrefabId,r.raycastTarget=e.raycastTarget!==!1,r.interactable=e.interactable!==!1,r.showScrollBar=e.showScrollBar!==!1,r.scrollDirection=e.scrollDirection,r.layoutConstraint=e.layoutConstraint,r.layoutConstraintFixedCount=e.layoutConstraintFixedCount,r.cellSizeX=e.cellSizeX,r.cellSizeY=e.cellSizeY,r.spacingX=e.spacingX,r.spacingY=e.spacingY,r.padding1X=e.padding1X,r.padding1Y=e.padding1Y,r.padding2X=e.padding2X,r.padding2Y=e.padding2Y,r.previewCount=e.previewCount),e.kind==="keyhint"&&(r.keyboardKeyCode=e.keyboardKeyCode,r.controllerKeyCode=e.controllerKeyCode),(e.kind==="animation"||e.kind==="fullscreen")&&(r.raycastTarget=!1,r.animationId=e.animationId,r.playSoundEffect=e.playSoundEffect,e.kind==="animation"&&(r.layer=e.layer)),r}function kn(e,t=[],i=""){let n=i&&ie[i]?i:e.canvasId,r=ie[n],o=Bt(e),a=new Map;for(let c of t){if(!c.controlId)continue;let s=a.get(c.controlId)||[];s.push(c),a.set(c.controlId,s)}let l=e.meta?.assetType==="client-control-template"?(e.root.children||[]).map(c=>xn(c,n,a)):[];return{canvasId:n,platform:r.platform,device:r.luaDevice,canvasWidth:r.width,canvasHeight:r.height,root:xn(o,n,a),templates:l}}var Pi="qxqy-autotest";var ct=.03333333333333333,Jl=new Set(["pointer","key","click","pause","resume","serverSet","serverSend","view"]),Zl=new Set(["log","control","var","signal","tree","lua"]);function ut(e,t){let i=Number(e);if(!Number.isFinite(i))throw new Error(`${t} must be a finite number`);return i}function En(e){return JSON.parse(JSON.stringify(e??null))}function Ri(e,t){if(!e||typeof e!="object")throw new Error(`events[${t}] must be an object`);let i=String(e.kind||e.do||"");if(!Jl.has(i))throw new Error(`unsupported event kind: ${i||"(empty)"}`);let n=e.payload&&typeof e.payload=="object"?{...e.payload}:{};if(i==="pointer")!n.type&&e.type&&(n.type=e.type),n.x===void 0&&(n.x=e.x),n.y===void 0&&(n.y=e.y),n.x=ut(n.x,"pointer.x"),n.y=ut(n.y,"pointer.y"),n.type=String(n.type||"click"),n.type==="wheel"&&(n.deltaX=ut(n.deltaX??e.deltaX??0,"pointer.deltaX"),n.deltaY=ut(n.deltaY??e.deltaY??0,"pointer.deltaY"));else if(i==="key"){if(n.typeName=String(n.typeName||n.key||e.typeName||e.key||""),!n.typeName)throw new Error("key event requires typeName")}else if(i==="click"){if(n.name=String(n.name||e.name||""),!n.name)throw new Error("click event requires control name")}else if(i==="serverSet"){if(n.entityType=String(n.entityType||e.entityType||""),n.name=String(n.name||e.name||""),n.value===void 0&&(n.value=e.value),n.value===void 0&&(n.value=null),!n.entityType||!n.name)throw new Error("serverSet requires entityType and name")}else if(i==="serverSend"){if(n.name=String(n.name||e.name||""),n.params=Array.isArray(n.params)?n.params:Array.isArray(e.params)?e.params:[],n.target=String(n.target||e.target||"PlayerSelf"),!n.name)throw new Error("serverSend requires signal name")}else if(i==="view"&&(n.playerIndex=Number(n.playerIndex||n.viewPlayerIndex||e.playerIndex||e.viewPlayerIndex||0),!Number.isInteger(n.playerIndex)||n.playerIndex<1))throw new Error("view event requires playerIndex 1-8");return{t:ut(e.t??0,"event.t"),source:String(e.source||"user"),kind:i,payload:n}}function An(e,t){if(!e||typeof e!="object")throw new Error(`asserts[${t}] must be an object`);let i=String(e.kind||(e.check?"log":""));if(!Zl.has(i))throw new Error(`unsupported assert kind: ${i||"(empty)"}`);let n={kind:i};if(e.at!==void 0&&(n.at=ut(e.at,"assert.at")),i==="log"){if(n.contains=String(e.contains||e.check||e.text||""),n.source=e.source==="server"?"server":"client",e.level&&(n.level=String(e.level)),!n.contains)throw new Error("log assert requires contains")}else if(i==="control"){if(n.id=e.id?String(e.id):"",n.name=e.name?String(e.name):"",n.field=String(e.field||""),!n.field)throw new Error("control assert requires field");if(!n.id&&!n.name)throw new Error("control assert requires id or name");if(!Object.prototype.hasOwnProperty.call(e,"equals"))throw new Error("control assert requires equals");n.equals=En(e.equals)}else if(i==="var"){if(n.entityType=String(e.entityType||""),n.name=String(e.name||""),!n.entityType||!n.name)throw new Error("var assert requires entityType and name");if(!Object.prototype.hasOwnProperty.call(e,"equals"))throw new Error("var assert requires equals");n.equals=En(e.equals)}else if(i==="signal"){if(n.direction=e.direction==="outbound"?"outbound":"inbound",n.name=String(e.name||""),!n.name)throw new Error("signal assert requires name");e.values!==void 0&&(n.values=En(e.values))}else if(i==="tree"){if(n.name=String(e.name||""),n.exists=e.exists!==!1,!n.name)throw new Error("tree assert requires name")}else if(i==="lua"&&(n.source=String(e.source||""),!n.source.trim()))throw new Error("lua assert requires source");return n}function Fo(e){let t=0,i=[],n=[];for(let r of e){if(!r||typeof r!="object")throw new Error("queue step must be an object");if(r.do!=="start"){if(r.do==="step"){t+=ut(r.dt??ct,"step.dt");continue}if(r.do==="pointer"||r.do==="key"||r.do==="click"||r.do==="pause"||r.do==="resume"||r.do==="serverSet"||r.do==="serverSend"||r.do==="view"){i.push(Ri({...r,kind:r.do,t},i.length));continue}if(r.assert||r.check||r.kind){n.push(An({...r.assert||r,at:r.at??t},n.length));continue}throw new Error(`unsupported queue step: ${JSON.stringify(r)}`)}}return{events:i,asserts:n,dt:ct}}function ii(e){if(Array.isArray(e)){let n=Fo(e);return{format:Pi,version:1,name:"",dt:n.dt,events:n.events,asserts:n.asserts}}if(!e||typeof e!="object")throw new Error("autotest case must be an object or step array");if(Array.isArray(e.queue)||Array.isArray(e.steps)){let n=Fo(e.queue||e.steps);return{format:Pi,version:1,name:String(e.name||""),dt:Number(e.dt)>0?Number(e.dt):n.dt,events:n.events,asserts:n.asserts}}let t=(e.events||[]).map((n,r)=>Ri(n,r)),i=(e.asserts||[]).map((n,r)=>An(n,r));return t.sort((n,r)=>n.t-r.t||0),{format:Pi,version:1,name:String(e.name||""),dt:Number(e.dt)>0?Number(e.dt):ct,playerCount:Number(e.playerCount)>0?Number(e.playerCount):1,events:t,asserts:i}}function Oo(e,t={}){let i=(e||[]).map((n,r)=>Ri(n,r));return{format:Pi,version:1,name:String(t.name||""),dt:Number(t.dt)>0?Number(t.dt):ct,playerCount:Number(t.playerCount)>0?Number(t.playerCount):1,events:i,asserts:(t.asserts||[]).map((n,r)=>An(n,r))}}function zo(e,t,i){if(!e)return null;let n=Ri({...t,t:t.t??i??0},e.events.length);return e.events.push(n),n}import{createCanvas as Ql}from"@napi-rs/canvas";var Do=Ql(1,1).getContext("2d"),es='"Microsoft YaHei UI","Microsoft YaHei",sans-serif',Ti=(e,t)=>Math.max(0,Math.min(t,Number.isFinite(e)?e:0));function $o(e,t,i){let n=Math.max(8,Number(e.fontSize)||12),r=String(e.text??"").replace(/\r\n?/g,`
109
+ `),o=JSON.stringify([r,t,i,n,e.showScrollBar]),a=e._textWindowLayout;if(a?.key!==o){Do.font=`${n}px ${es}`;let s=p=>{let y=[];for(let v of r.split(`
110
+ `)){let E="";for(let x of v)E&&Do.measureText(E+x).width>p&&(y.push(E),E=""),E+=x;y.push(E)}return y},f=s(Math.max(1,t-4)),h=e.showScrollBar!==!1&&f.length*n*1.2>i,m=Math.max(1,t-4-(h?12:0));h&&(f=s(m)),a=e._textWindowLayout={key:o,lines:f,font:n,textWidth:m,lineHeight:n*1.2,length:f.length*n*1.2}}let l=Math.max(0,a.length-i),c=Ti(e._scrollOffset||0,l);return e._scrollOffset=c,{...a,max:l,offset:c,viewport:i,horizontal:!1,width:t,height:i}}function Mi(e,t,i){if(!e?.showBar||e.max<=0||t<=0||i<=0)return null;let n=e.horizontal===!0,r=n?t:i,o=Math.max(0,r-4),a=Math.min(o,Math.max(18,o*r/(r+e.max))),l=o-a,c=l*e.offset/e.max,s=Math.min(8,n?i:t),f=n?{x:-t/2+2,y:i/2-s-2,width:o,height:s}:{x:t/2-s-2,y:-i/2+2,width:s,height:o},h=n?{...f,x:f.x+c,width:a}:{...f,y:f.y+c,height:a};return{track:f,thumb:h,travel:l}}var ts=[[10001,"ura.1ht4.2ag9.1hh5.jbb.k02.jcw.2tv.2wn.2xk.2r3.d5s.94l.ebv.kcr.b40.77k.9gp.97w.1hb5.jag.btu.jc9.hp5.bmj.blq.blq.ff9.ffk.o74.1owl.rp.mg.l3.lf.lh.qy.1a3z.2xk.2xk.2xk.2xk.2xk.17dc.1f2b.2bc.2bc.2bc.2bc.2bc.ffo.ffo.126.1fk.4mo.4mo.15e.1h2.237.2ba.2kd.2bc.4mo.4mo.4mo.4mo.1mc.1n6.2cu.1ud.2b1.2ee.1tj.1tk"],[20001,"o6.fh.kb.cr.og.sm.6x.8c.87.o7.vz.kt.qo.lg.ob.9w.mg.1kz.zc.1ex.1d5.ps.uu.su.qs.ys.zp.10k.15a.xc.uk.mx.1ax.nt.tu.19m.uj.1ku.tt.100.ie.d3.fp.ie.ie.d3.fp.ie.8p.7k.fw.h0.qc.ot.uc.ot.rk.gb.1c2.ff.cl.9v.wg.1ir.1lr.1b8.1ri.1p0.104.10n.mw.j6.jb.f1.dv.84.a0.cp.bx.1ko.1au.1ia.rs.rt.rs.t7.x6.wi.zc.16f.1i6.2jh.28d.qh.k8.1gz.1ko.2iv.1xp.1l4.1gk.10j.yo.1jk.1jk.xv.104.15o.1xg.1xg.1xi.25i.p1.t1.yh.1ak.1i6.1y2.xt.32u.3g6.1bz.2mn.14l.14c.1e1.op.s8.p2.v5.2ix.1a0.ry.16m.17n.13c.134.ys.yu.xr.sl.sr.sd.yh.z5.gd.gl.hx.h2.g8.fj.iy.hz.jj.th.12n.16r.d3.j9.dg.lj.fl.a7.f9.iw.el.27f.1dh.1rh.2ph.yd.w5.x5.tr.pq.zf.16h.1a5.17t.wy.vn.y8.wl.yv.2ye.2qt.1ah.163.19t.uf.119.2vv.1bm.13h.14p.1so.c3.as.9z.19w.1l4.1nl.rj.we"],[30001,"jo.my.ss.dw.c1.b4.hl.hl.hl.cz.dw.dw.b4.dw.fr.kd.qv.px.px.74.6u.8h.60.8q.8b.eo.eo.eo.8k.a5.99.12v.13y.lg.m4.qr.dw.ex.g0.ef.cd.br.11n.17h.1b8.1c9.9p.ag.9z.l9.m8.m8.lw.m8.cz.99.b4.8c.63.7f.6h.99.re.pp.pi.cq.c9.cp.ck.c6.b0.bd.al.f6.gl.ed.fs.lc.k6.kh.i6.cx.j1.hk.gb.d7.h7.g2.em.kj.kn.k4.j5.rh.t0.qt.mj.i7.ih.i2.hd.3r.8d.6u.6z.by.de.dg.cr.1a5.1ab.16c.18g.n2.ly.no.nt.f9.de.lr.fe.f0.fj.el.fo.t1.g9.ly.h3.g6.de.2ak.2f3.wf.kg.qn.11p.rg.uj.u6.11c.22o.2cs.3dp.3dq.3d5.3d6.1zx.18v"],[40001,"19x.215.2zt.1ex.2pj.7hy.1ur.1gn.1g7.1b1.u9.1tw.108.1ew.rs.1qu.w9.lk.244.qi.b6.tk.jg.jg.jg.y4.c1.b4.iv.hi.r4.n7.gy.ev.qe.12z.18n.dw.1l6.ou.wz.1un.19t.18k.yy.1hs.sl.dw.1vl.100.14k.1q8.209.1jk.1xr.ua.1j2.pr.26h.1gs.s9.px.15v.pf.1jk.xc.1hb.111.172.ut.285.1oh.149.zj.22r.2l9.14a.ok.23y.1eh.xe.1j0.1rp.1cz.wf.1mh.22k.334.1z2.1xo.1br.4ji.5nq.5nf.2za.18r.h3.eo.ia.1kn.dc.ss.s0.1bl.1oc.is.km.177.1ec.1ao.h4.hp.dx.l9.iw.i3.12w.n1.yq.12w.1ju.yx.14s.18b.22t.u3.my.2rb.36w.13u.z8.20r.18g.19r.2x9.w4.q2.1d2.wo.13a.v6.17w.ur.288.1b6.14m.1fi.1xx.1ee.kj.121.j2.1d2.2ad.1ri.2lc.1vk.138.12r.xj.1h5.1c5.2qx.1gj.t2.lv.rf.18q.1kz.dw.2aq.ia.1i9.k5.199.f4.10y.18a.xf.rk.1g9.1q3.10h.sj.15o.e3.dz.sv.135.w9.yg.aw.2a2.19m.22w.1c8.272.13o.104.1sr.rs.1pb.d5.df.kp.jq.1a7.s8.1ao.ba.rb.in.pz.q8.140.ij.1e7.jl.yk.117.10i.1tn.1oj.1sv.sj.1e3.2so.1c7.1gv.178.107.10n.1dx.1qi.1wp.2bc.218.16r.105.xc.z6.11w.1mc.1y9.17p.1cs.2ij.18c.1ie.nn.16c.1ce.xb.1ei.3j0.ve.14x.1sx.285.1b8.1at.v4.rv.rs.10z.xq.11o.15k.xq.u1.i2.pu.i4.l3.9u.oh.mc.nm.pw.1i3.1h4.pj.111.l4.lb.qq.qf.u0.h4.nk.yf.6h.ij.ds.oy.re.m8.1gl.cz.16z.a1.1f8.1x6.vp.dz.gp.g6.fr.vl.fr.gg.qc.aj.99.go.ij.fz.11a.x5.mo.1u9.h0.m8.10m.1an.2bc.3uw.2gk.124.xb.1uk.1b6.2xj.1os.11a.vs.1i9.1lr.2gv.265.668.1xg.45j.404.2x1.1io.3om.4q2.4mo.1d4.2bp.1pr.166.2y6.2bv.361.2nc.2bc.3g0.7g4.334.2bc.2xo.3uw.6ic.4ig.3uw.23v.1la.2zr.1jt.1cq.27a.1n1.19x.1qg.1jn.1ca.26y.2d6.4v4.4mo.4mo.7ps.1jk.153.1fo.1dm.1s2.1w1.oe.1lb.319.2eg.58p.4mo.3dw.2y2.2xm.1u8.1ko.12n.1e0.2sd.1md.2cl.1q2.372.4mo.48s.b14.3fu.334.334.34i.4nf.4ji.5eg.3uw.2u8.1g1.110.37x.2jo.su.334.3aj.3uw.63f.2bc.2bc.8v4.1ts.ax5.5du.34d.3oc.34j.4si.174.rt.1rp.2b0.37d.1ta.2gh.28a.22z.1nc.1a5.1pa.4dd.3ha.2cs.5mv.4mq.5c2.3uw.1gf.4md.113.10x.21o.2hj.1b3.1cx.1ol.3ar.1fv.17t.1a7.2uj.2we.1jk"],[50001,"1o8.1k1.mo.1wu.2c9.22d.1kb.23n.1b8.1ic.24c.2wz.1mq.1mu.1jx.1z1.o3.190.vp.1h7.th.4mo.1rp.4mo.4mo.7ps.zz.143.21v.1nf.34s.1s3.r9.18t.s1.r9.21w.277.ls.25k.5v1.2bc.1kh.wt.14i.1eq.15o.668.sh.rl.3wi.3vc.43c.3yn.17c.f5.xu.jg.176.19v.1xy.23m.18x.30c.10l.13k.v8.vp.17t.qj.17m.1wr.1la.8t.s7.18d.1l2.152.mx.1c8.1l4.1f5.1xe.rz.2hz.1et.13t.xb.14r.15o.z0.1zo.ur.257.1gb.li.12d.15a.132.1m1.3vu.296.1mg.11m.z0.159.mp.hd.x4.1go.ns.xh.2a7.tt.2vb.1bx.1kh.u3.11i.1y1.24e.2hp.2mn.1w6.3zm.166.14g.1mo.2v9.2rg.2f9.1r0.139.m1.k3.ys.1dy.29k.1mm.22m.3zx.4dr.2h7.22o.tv.rm.1et.2wv.2ar.1t7.ku.12s.10b.1v9.1gu.12m.1b3.tv.1c8.tk.10s.ul.1tt.ka.oi.qb.13f.13f.13k.17h.1uh.ez.en.2x7.2ln.2h8.3h8.ig.n9.27o.18b.hl.nm.uk.11a.1ta.1k4.1eh.wv.1go.1gg.sc.18u.1dz.2aq.vt.2l7.25h.1l5.1kn.1vc.1b4.28i.17t.1d6.1k2.18z.jy.jw.dh.1mx.fr.vp.35w.34z.35w.34z.4so.vf.yx.1bg.1d3.2yc.1tg.8q3.99g.am.2du.rm.rg.xa.2cw.xc.1j6.1if.18z.13a.yz.142.1z5.262.1bj.1y8.ur.u5.16j.1pf.1bi.l8.1il.3vz.2dr.jo.ls.18s.16l.18c.141.219.1yz.1fc.24t.27e.481.1vp.25h.1yq.1zn.1uw.11u.1jp.1pz.39o.t6.1mj.1u5.11l.1vd.1dk.1zb.1ic.3ql.14p.1wq.25x.267.zn.zn.1pf.13z.1j7.r9.1hb.4yp.1lt.1cw.1z4.19z.1og.1j4.1cl.1eg.u8.16s.1en.zu.1hr.1js.19g.303.22j.2oa.180.1v7.2ud.2d7.21s.3g9.vh.v1.284.3lg.3lg.17q.1h3.4mo.1cm.1rv.22i.2mc.2j3.27o.333.1q8.237.2ll.23b.2sp.2ll.2ox.2cf.2f8.2hz.1uo.y4.s9.w6.2dg.2q9.up.1m1.1vz.2n8.192.1eb.z7.2em.2q3.1sd.1gj.348.3vf.2iu.29x.1dc.7oj.4pq.5vb.4mx.5me.5sf.5yf.7ps.yj.q0.10w.13p.18b.2wd.11q.2vx.dd.iv.12p.jh.u9.1uy.w0.3f0.3bj.126.qo.1gj.11k.pu.22h.1z6.rp.y4.y0.xl.1d0.11s.wa.1a6.127.10m.12r.1nh.1fy.yo.1js.162.n4.174.1aj.y4.o8.qz.rh.qa.18s.mr.j3.ii.sr.sx.1jk.17l.mj.zr.uy.wa.19t.2bt.xe.1od.hs.xr.5b.12c.1ab.we.gz.mz.4y.sf.11s.e0.1l7.ew.h6.jz.l0.e8.1cx.p6.17u.bw.1ah.10r.10e.o9.1bc.uv.lq.tl.zb.100.jy.b8.bj.336.10n.na.sq.14r.yr.nm.123.tf.l1.zp.1xc.1vk.31l.zl.2bj.2b9.2fv.17p.y0.so.1ln.29c.1eh.nh.xn.131.qc.186.ff.fc.xq.1bm.la.l8.14f.243.111.xi.qw.1qn.11v.1ur.1jx.1ks.s9.nz.269.1zj.2zd.1pv.18n.2vk.p3.1fh.13v.1lf.1lu.2db.1sr.1k3.26o.1dl.1f3.187.2lh.166.v9.xh.1e3.119.s2.mt.1iu.1k6.1o2.12s.u4.2br.1q3.qv.1e4.1zu.1v4.1vk.1t3.3p7.1ob.14d.1ns.1ef.1e4.12w.2kk.1ba.2jx.1e0.1s5.12w.17r.14s.wz.1qp.183.3fb.188.1gr.2ot.168.1u7.w8.28o.1zd.32z.230.w7.vq.x8.1qh.19f.14o.2r9.qg.1ey.1qr.1p6.3a3.1ov.13d.tz.wk.22v.1qa.2l9.yw.yf.nw.p6.1ly.1jk.1nh.x9.q0.17r.17h.ux.uw.12y.p7.g7.kt.14c.ze.1kh.1eo.18a.1d8.26j.15k.19f.1ym.1j5.1c6.11k.1sd.1jp.1ws.13s.1o5.214.sx.px.20x.14h.1ja.s6.1q8.w8.1ks.so.ub.121.202.1ej.1g1.1s8.2bc.4t1.bih.3uw.3pb.avp.6c7.bko.5eg.79c.6wh.3wd.4pn.55j.4a5.3gg.bko.5ei.52p.578.bcv.6gr.2bc.4j9.5y7.9d2.2bb.2bc.668.73z.5pg.50f.5m7.788.267.642.8h2.8h2.49s.64g.5e8.5e8.2bb.3ih.5ur.6bk.578.4ck.3sg.5fe.23i.e9w.2b8.5oj.6bw.2al.2rk.2rk.5pj.n6e.350.6v9.70t.639.3uw.3uw.2bg.639.2bb.2bd.6gj.2bh.660.578.3bk.65e.359.3o0.44i.4tn.1zq.5ee.4a5.3zu.rs.639.33q.5eg.1k1.15o.dw.3uw.b7p.7qd.898.4l4.5uu.5uu.b4g.2yh.2yh.3uw.51a.51a.5kk.66f.iq9.3n7.4nb.46a.1wb.20p.bih.8xa.7ps.70t.70t.4rv.5p1.6aq.ts.63z.668.5v2.5nu.563.55s.55s.5p3.2ga.32x.42x.5cr.4c2.71b.5zp.5c2.66t.4c8.2bc.2bc.2gn.3ea.2kp.fz6.8hz.3e8.4an.bko.j7e.jag.7sr.2bc.3zx.7qd.5ut.5jp.2wk.5q7.3uw.334.4i3.3uw.4bd.5eu.46h.4i2.6t4.446.5s7.5cg.4bk.5nd.7bf.4rt.23b.2bc.2bc.2bc.2bc.2ba.4mo.4dv.3wn.2bc.1we.4he.2bc.4gz.3wn.3km.4xy.4hi.4mr.2bc.247.3yj.2c6.2bc.3aj.446.4ub.3uw.51.e0.86.is.i1.hg.mn.m4.2c.7h.sg.e3.jb.7r.eq.nf.u0.60.4o.ke.47.47.47.47.b8.4x.dr.dy.rw.rw.59.8j.5z.a5.l3.c0.ik.f7.li.lr.7x.dv.du.dd.5e.91.1b.ce.cc.59.bh.e6.8m.9n.cl.lt.7ip.4mr.4si.4kf.vo.we.13e.17n.1iw.2pi.lp.r6.gw.7x.xz.qt.bq.ls.q1.eh.bx.cr.3c.j7.b8.fz.4k.8p.bg.5w.iy.j3.12o.rs.cz.dp.yz.jk.63.63.7ps.7ps.7ps.40g.3jp.4tw.89k.88a.7s0.83d.668.7ps.2fw.2ev.2fp.7ps.2jb.2dh.2ud.25i.24c.2bt.1pa.17r.1a7.7ps.7pt.5rg.4nl.3vv.7qo.31a.2p0.2k0.49a.3v4.3nl.1ug.1ug.1l6.7s1.7ps.2cp.2f8.2i7.7ps.28q.2be.275.1ma.1oz.1q7.16s.1iq.1e0.78m.7ps.2bc.2bc.2bc.bko.2wu.2wu.2wu.3b4.38f.3uw.3uw.3uw.3uw.7ps.7qa.32n.2gg.2wk.7rv.1v3.1qq.1rb.1zk.1my.1zp.1yn.1oh.1uh.7st.9q.9q.9q.9q.9q.kk.kk.kk.kk.kk.dw.dp.dw.rs.rs.rs.rs.s4.sd.54j.5n8.2n6.21r.1nu.1o5.14u.t6.3f7.2j0.32c.304.189.1gf.18w.18j.1st.1vq.116.kw.3uw.3uw.vr.zx.xc.tc.7d.7r.9d.9w.8s.9p.3b.3b"]].map(([e,t])=>[e,t.split(".").map(i=>parseInt(i,36)/1e3)]);function Go(e){if(!Number.isSafeInteger(e))return null;for(let[t,i]of ts)if(e>=t&&e<t+i.length)return i[e-t];return null}import{randomUUID as Uo}from"node:crypto";function Oi(e){for(let t of e.runtime.scrollControls||[]){let[i,n]=Kt(t),r=t.kind==="grid"?kt(t):$o(t,i,n),o={offset:r.offset,max:r.max,horizontal:r.horizontal,showBar:t.showScrollBar!==!1,textWidth:r.textWidth??0,lines:r.lines||[],lineHeight:r.lineHeight||0,contentLength:r.length},a=JSON.stringify(o);t._scrollKey!==a&&(t._scrollKey=a,t._scroll=o,t.markPlayDirty())}}function jo(e){return{...e._scroll?{scroll:e._scroll}:{},...e.parent?._gridItems?.includes(e)?{clipToParent:!0}:{}}}function _n(e,t){let i=e._scroll?.max||0;e.kind==="grid"?e.scrollProgress=i?Ti(t,i)/i:0:e._scrollOffset=Ti(t,i),e.markPlayDirty()}var is=Object.freeze(Object.values(ie).map(e=>Object.freeze({id:e.id,label:e.label,platform:e.platform,width:e.width,height:e.height})));function zi(e){Oi(e);let t=ye({width:e.runtime.canvasWidth,height:e.runtime.canvasHeight}),i=new Map;function n(r,o,a){let l=Fe(o,r);l.activeInHierarchy=a&&r.active!==!1,i.set(r.Id,l);let c=l.activeInHierarchy;for(let s of r.children)n(s,l,c)}for(let r of e.runtime.roots)n(r,t,!0);return i}function Xo(e,t=zi(e)){let i=new Map;function n(r,o){let a=t.get(r.Id);if(!a)return;let l=Yt(o,a,r);i.set(r.Id,l);for(let c of r.children)n(c,l)}for(let r of e.runtime.roots)n(r,St());return i}function Ho(e,t){let i=t.get(e.Id);return{id:e.Id,prefabId:e.prefabIndex,authoringId:e.authoringId,name:e.name,kind:e.kind,typeofName:e.typeofName,instantiated:!e.authoringId,active:!!e.active,visible:!!e.visible,activeInHierarchy:!!i?.activeInHierarchy,raycastTarget:e.raycastTarget!==!1,interactable:e.interactable!==!1,pressed:e.pressed===!0,...e._scroll?{scrollOffset:e._scroll.offset,scrollMax:e._scroll.max}:{},...e.kind==="grid"?{itemCount:e.itemCount,scrollProgress:e.scrollProgress}:{},anchoredPositionX:e.anchoredPositionX,anchoredPositionY:e.anchoredPositionY,sizeDeltaX:e.sizeDeltaX,sizeDeltaY:e.sizeDeltaY,localScaleX:e.localScaleX,localScaleY:e.localScaleY,localScaleZ:e.localScaleZ,localRotationZ:e.localRotationZ,text:e.kind==="textbox"||e.kind==="textwindow"?e.text??"":null,fontSize:e.kind==="textbox"||e.kind==="textwindow"?e.fontSize:null,fontColor:e.kind==="textbox"||e.kind==="textwindow"?e.fontColor:null,bgColor:e.kind==="textbox"||e.kind==="textwindow"?e.bgColor:null,enableOutline:e.kind==="textbox"||e.kind==="textwindow"?e.enableOutline===!0:null,outlineColor:e.kind==="textbox"||e.kind==="textwindow"?e.outlineColor:null,imageId:e.kind==="image"?e.imageId??0:null,primitive:e.kind==="image"?bt(e.imageId):null,imageColor:e.kind==="image"?e.imageColor:null,enableMask:e.kind==="image"?e.enableMask===!0:null,enableSoftEdge:e.kind==="image"?e.enableSoftEdge===!0:null,softEdgeMode:e.kind==="image"?e.softEdgeMode:null,softEdgeWidthX:e.kind==="image"?e.softEdgeWidthX:null,softEdgeWidthY:e.kind==="image"?e.softEdgeWidthY:null,horizontalSoftRange:e.kind==="image"?e.horizontalSoftRange:null,verticalSoftRange:e.kind==="image"?e.verticalSoftRange:null,enableFill:e.kind==="image"?e.enableFill===!0:null,fillType:e.kind==="image"?e.fillType:null,fillHorizontalType:e.kind==="image"?e.fillHorizontalType:null,fillVerticalType:e.kind==="image"?e.fillVerticalType:null,fillRadial90Type:e.kind==="image"?e.fillRadial90Type:null,fillRadialType:e.kind==="image"?e.fillRadialType:null,reverseMaskArea:e.kind==="image"?e.reverseMaskArea===!0:null,fillAmount:e.kind==="image"?e.fillAmount:null,box:i?{left:i.left,bottom:i.bottom,width:i.width,height:i.height}:null,children:e.children.map(n=>Ho(n,t))}}function ns(){return{pointerDownControl:null,pointerDownPosition:null,pointerLastPosition:null,pointerDragging:!1,pointerHoverControl:null,pointerScroll:null,hoveredControl:null,selectedControl:null,stateRestores:new Map,viewCache:null}}function rs(e,t,i,n){let r=Jt({canvasWidth:e.canvasWidth,canvasHeight:e.canvasHeight,device:e.device,audioDuration:Go,...n?{language:n}:{}});for(let o of[...e.templates||[],...t?.templates||[]])Number.isSafeInteger(o.prefabIndex)&&o.prefabIndex>0&&r.registerTemplate(o.prefabIndex,o);for(let o of i){let a=o.path||o.id,l=o.source||"";a&&l&&r.registerScriptFile(a,l)}return r}var os=["pointerDownControl","pointerDownPosition","pointerLastPosition","pointerDragging","pointerHoverControl","pointerScroll","hoveredControl","selectedControl","stateRestores","viewCache"];function as(e){Object.defineProperty(e,"runtime",{configurable:!0,enumerable:!0,get(){return e.runtimes[e.viewPlayerIndex-1]}});for(let t of os)Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){return e.views[e.viewPlayerIndex-1][t]},set(i){e.views[e.viewPlayerIndex-1][t]=i}})}function Ko(e,{templatesProject:t=null,scripts:i=[],sceneScripts:n=null,templateScripts:r=null,serverConfig:o=null,canvasId:a="",playerCount:l=1,viewPlayerIndex:c=1,language:s=""}={}){let f=n||i,h=r||i,m=kn(e,f,a),p=t?kn(t,h,a):null,y=lt(l),v=$e(c,y),E=No({playerCount:y,viewPlayerIndex:v});o&&E.loadConfig({...o,playerCount:y,viewPlayerIndex:v});let x=[];for(let O=0;O<y;O+=1)x.push(rs(m,p,i,s));E.attachRuntimes(x);for(let O of x)O.addRoot(m.root);let A={audioSessionId:Uo(),runtimes:x,views:x.map(()=>ns()),playerCount:y,viewPlayerIndex:v,server:E,compiled:m,mountError:x.find(O=>O.mountErrors[0])?.mountErrors[0]||null,debugPaused:!1,history:{events:[]},recording:!0};as(A);let $=A.viewPlayerIndex;for(let O=1;O<=y;O+=1)A.viewPlayerIndex=O,bs(A);return A.viewPlayerIndex=$,A}function Mn(e,t){if(!e)throw new Error("play session has not started");let i=$e(t,e.playerCount);return i===e.viewPlayerIndex||(qe(e,{kind:"view",payload:{playerIndex:i}}),e.viewPlayerIndex=i,e.viewCache=null,e.server&&e.server.setViewPlayerIndex(i)),i}function qe(e,t){!e?.recording||!e.history||zo(e.history,{...t,source:t.source||"user"},e.runtime.clock.time)}function ls(e){return e?.history?.events||[]}var Nn=new Set(["image","textbox","textwindow","button","grid"]);function ss(e,t){let i=Oe(t,e.centerX,e.centerY);return{centerX:i.x,centerY:i.y,scaleX:Math.hypot(t.a,t.b),scaleY:Math.hypot(t.c,t.d),rotationZ:Math.atan2(t.b,t.a)*180/Math.PI,matrix:{a:t.a,b:t.b,c:t.c,d:t.d,tx:i.x,ty:i.y}}}function ft(e){return typeof e=="string"?e:e?.Name}function qo(e){return{fillType:ft(e.fillType),fillHorizontalType:ft(e.fillHorizontalType),fillVerticalType:ft(e.fillVerticalType),fillAmount:e.fillAmount}}function us(e,t,i){let n=Math.abs(t.width*i.scaleX),r=Math.abs(t.height*i.scaleY),o={id:e.Id,kind:e.kind,name:e.name,left:i.centerX-n/2,bottom:i.centerY-r/2,width:n,height:r,sourceWidth:t.width,sourceHeight:t.height,rotationZ:i.rotationZ,matrix:i.matrix,pressed:e.pressed===!0,...jo(e)};return e.kind==="image"&&(o.primitive=bt(e.imageId),o.imageColor=e.imageColor,o.imageId=e.imageId,Object.assign(o,qo(e))),(e.kind==="textbox"||e.kind==="textwindow")&&(o.text=e.text??"",o.fontSize=e.fontSize,o.fontColor=e.fontColor,o.bgColor=e.bgColor,o.enableOutline=e.enableOutline===!0,o.outlineColor=e.outlineColor,o.horizontalAlignment=ft(e.horizontalAlignment),o.verticalAlignment=ft(e.verticalAlignment)),o}function cs(e,t=zi(e)){let i=[],n=Xo(e,t);function r(o,a=[]){let l=t.get(o.Id);if(!l||o.visible===!1||!l.activeInHierarchy)return;let c=n.get(o.Id);if(!c)return;let s=ss(l,c),f=()=>i.push({...us(o,l,s),...a.length?{clipPolygons:a}:{}});Nn.has(o.kind)&&o.kind!=="grid"&&f();let h=o.children||[];for(let m=h.length-1;m>=0;m-=1){let p=o._gridItems?.includes(h[m])?[...a,[[l.left,l.bottom],[l.right,l.bottom],[l.right,l.top],[l.left,l.top]].map(([y,v])=>Oe(c,y,v))]:a;r(h[m],p)}o.kind==="grid"&&f()}for(let o of e.runtime.roots)r(o);return i}function fs(e,t){let i={kind:e.kind,name:e.name,sourceWidth:t.width,sourceHeight:t.height,pressed:e.pressed===!0,...jo(e)};return e.kind==="image"&&(i.primitive=bt(e.imageId),i.imageColor=e.imageColor,i.imageId=e.imageId,Object.assign(i,qo(e))),(e.kind==="textbox"||e.kind==="textwindow")&&(i.text=e.text??"",i.fontSize=e.fontSize,i.fontColor=e.fontColor,i.bgColor=e.bgColor,i.enableOutline=e.enableOutline===!0,i.outlineColor=e.outlineColor,i.horizontalAlignment=ft(e.horizontalAlignment),i.verticalAlignment=ft(e.verticalAlignment)),i}function ds(e,t,i){let n=Ui(e,t),r=Oe(n,e.centerX,e.centerY);return{a:n.a,b:n.b,c:n.c,d:n.d,tx:r.x-(i?i.centerX:0),ty:r.y-(i?i.centerY:0)}}function Lo(e){let t=e.matrix;return[e.parent,e.z,e.group?1:0,t.a,t.b,t.c,t.d,t.tx,t.ty,e.kind,e.name,e.sourceWidth,e.sourceHeight,e.pressed,e.primitive,e.imageColor,e.imageId,e.fillType,e.fillHorizontalType,e.fillVerticalType,e.fillAmount,e.text,e.fontSize,e.fontColor,e.bgColor,e.enableOutline,e.outlineColor,e.horizontalAlignment,e.verticalAlignment,JSON.stringify(e.scroll),e.clipToParent].join(" ")}function Wo(e,t,i,n,r,o){return{id:e.Id,parent:t,z:r,group:o>=16,matrix:ds(n,e,i),...fs(e,n)}}function hs(e){let t=ye({width:e.runtime.canvasWidth,height:e.runtime.canvasHeight}),i=new Set,n=new Map,r=new Map;function o(c,s,f){let h=Fe(s,c);if(h.activeInHierarchy=f&&c.active!==!1,r.set(c.Id,h),c.visible===!1||!h.activeInHierarchy)return!1;let m=c.children||[],p=Nn.has(c.kind),y=0;for(let v=0;v<m.length;v+=1)o(m[v],h,h.activeInHierarchy)&&(p=!0,y+=1);return p?(i.add(c.Id),n.set(c.Id,y),!0):!1}function a(c,s,f,h){if(!i.has(c.Id))return;let m=r.get(c.Id);l.push(Wo(c,s,f,m,h,n.get(c.Id)||0));let p=c.children||[];for(let y=0;y<p.length;y+=1)a(p[y],c.Id,m,y)}let l=[];for(let c=0;c<e.runtime.roots.length;c+=1)o(e.runtime.roots[c],t,!0),a(e.runtime.roots[c],null,null,c);return{nodes:l,childCounts:n}}function Rn(e){let t=e._playChildDirty===!0||e._playDeepDirty===!0;if(e._playDirty=!1,e._playChildDirty=!1,e._playDeepDirty=!1,!t)return;let i=e.children;for(let n=0;n<i.length;n+=1)Rn(i[n])}function ms(e,t){let i=ye({width:e.runtime.canvasWidth,height:e.runtime.canvasHeight}),n=[],r=[],o=t.count,a=e.runtime._playRemoved||[];for(let s=0;s<a.length;s+=1){let f=a[s];t.fingerprints.has(f)&&(r.push(f),t.fingerprints.delete(f),t.childCounts.delete(f),o-=1)}e.runtime._playRemoved=[];function l(s){t.fingerprints.has(s.Id)&&(r.push(s.Id),t.fingerprints.delete(s.Id),t.childCounts.delete(s.Id),o-=1);let f=s.children;for(let h=0;h<f.length;h+=1)l(f[h])}function c(s,f,h,m,p,y){let v=y||s._playDeepDirty===!0,E=v||s._playDirty===!0,x=v||s._playChildDirty===!0;if(!E&&!x)return;if(!(p&&s.active!==!1)||s.visible===!1){l(s);return}let $=Fe(f,s),O=t.childCounts.get(s.Id)||0;if(x){O=0;let k=s.children;for(let S=0;S<k.length;S+=1)c(k[S],$,s.Id,S,!0,v),t.fingerprints.has(k[S].Id)&&(O+=1)}if(!(Nn.has(s.kind)||O>0)){t.fingerprints.has(s.Id)&&(r.push(s.Id),t.fingerprints.delete(s.Id),t.childCounts.delete(s.Id),o-=1);return}let ee=t.childCounts.get(s.Id);t.childCounts.set(s.Id,O);let Z=O>=16!=(ee||0)>=16;if(!E&&!Z&&t.fingerprints.has(s.Id))return;let z=Wo(s,h,f===i?null:f,$,m,O),b=Lo(z);t.fingerprints.get(z.id)!==b&&(t.fingerprints.has(z.id)||(o+=1),t.fingerprints.set(z.id,b),n.push(z))}for(let s=0;s<e.runtime.roots.length;s+=1)c(e.runtime.roots[s],i,null,s,!0,!1);return t.count=o,{changed:n,removed:r,count:o}}function ps(e,t){let i=e.viewCache||(e.viewCache={rev:0,fingerprints:new Map,childCounts:new Map,count:0}),n=Number(t);if(!(Number.isFinite(n)&&n===i.rev&&i.fingerprints.size>0)){let{nodes:c,childCounts:s}=hs(e);i.rev+=1,i.fingerprints=new Map(c.map(f=>[f.id,Lo(f)])),i.childCounts=s,i.count=c.length;for(let f of e.runtime.roots)Rn(f);return{format:"tree-v1",revision:i.rev,reset:!0,count:c.length,nodes:c}}let{changed:o,removed:a,count:l}=ms(e,i);i.rev+=1;for(let c of e.runtime.roots)Rn(c);return{format:"tree-v1",revision:i.rev,reset:!1,count:l,changed:o,removed:a}}function Fn(e,{inspect:t=!1,view:i=!1,paint:n=!1,sceneRev:r,compact:o=!1}={}){Oi(e),e.audioSessionId||=Uo();let a=e.runtime,l=e.compiled,[c,s]=[a.canvasWidth,a.canvasHeight];e.server&&e.server.setClock(a.clock.time);let f=o?a.logs.slice(-100):a.logs,h=ls(e),m=e.server?e.server.snapshot():{vars:{},inbound:[],outbound:[],logs:[]};o&&(m.inbound=m.inbound.slice(-100),m.outbound=m.outbound.slice(-100),m.logs=m.logs.slice(-100));let p={canvasId:l.canvasId,platform:l.platform,device:a.device,canvasWidth:c,canvasHeight:s,canvasPresets:is,playerCount:e.playerCount||1,viewPlayerIndex:e.viewPlayerIndex||1,players:Array.from({length:e.playerCount||1},(y,v)=>({index:v+1,label:`\u73A9\u5BB6${v+1}`,entityType:`Player${v+1}`})),time:a.clock.time,frame:a.clock.frame,paused:!!e.debugPaused,levelTimePaused:!!a.clock.paused,audio:{sessionId:e.audioSessionId,playerIndex:e.viewPlayerIndex||1,...a.audioSnapshot()},mountError:e.mountError||a.mountErrors[0]||null,logs:f.map(y=>({source:"client",level:y.level,text:y.text,time:y.time})),tree:[],paint:[],scene:null,server:m,history:(o?h.slice(-100):h).map(y=>({t:y.t,source:y.source||"user",kind:y.kind,payload:y.payload||{}}))};if(t||n){let y=zi(e);t&&(p.tree=a.roots.map(v=>Ho(v,y))),n&&(p.paint=cs(e,y))}return i&&(p.scene=ps(e,r)),vt(p),p}function Di(e,t=1/30){let i=e.runtimes||(e.runtime?[e.runtime]:[]);for(let n of i)n.step(t);e.server&&(e.server.setClock(e.runtime.clock.time),e.server.flush())}function On(e,t){qe(e,{kind:"key",payload:{typeName:String(t)}}),e.runtime.injectKey(t)}function gs(e,t){let i=null;for(let n of e.runtime.roots)Me(n,r=>{!i&&r.name===t&&(i=r)});return i}function zn(e,t){qe(e,{kind:"click",payload:{name:String(t)}});let i=gs(e,t);i&&Dn(i)&&(i.kind==="button"||i.kind==="cursor")&&i.SimulateCursorClick()}function ys(e,t){return!e||!t?null:e.children.find(i=>i.authoringId===t||i.Id===t)||null}var Jo={unavailable:"unavailableChildId",hover:"hoverChildId",pressed:"pressedChildId",selected:"selectedChildId"};function Zo(e,t){let i=[];for(let[n,r]of Object.entries(Jo)){let o=t[r]?ys(t,t[r]):null;o&&i.push({state:n,child:o})}return i}function bs(e){for(let t of e.runtime.roots)Me(t,i=>{if(i.kind==="button"){for(let{child:n}of Zo(e,i))e.stateRestores.has(n.Id)||e.stateRestores.set(n.Id,{child:n,active:n.active,visible:n.visible}),n.active=!0,n.visible=!1,typeof n.markPlayDirty=="function"&&n.markPlayDirty(!0);ni(e,i)}})}function ni(e,t){if(!t||t.kind!=="button")return;let i=null;t.interactable===!1?i="unavailable":t.pressed===!0?i="pressed":e.hoveredControl===t?i="hover":e.selectedControl===t&&(i="selected");for(let n of Zo(e,t))n.child.active=!0,n.child.visible=n.state===i,typeof n.child.markPlayDirty=="function"&&n.child.markPlayDirty(!0)}function Pn(e){if(!e)return null;let t=e.parent;return t?.kind==="button"&&Object.values(Jo).map(n=>t[n]).filter(Boolean).includes(e.authoringId)?t:e}function Dn(e){return e.kind==="button"?e.raycastTarget!==!1&&e.interactable!==!1:e.kind==="cursor"||e.kind==="grid"?e.raycastTarget!==!1:e.kind==="textwindow"?e.interactable!==!1:e.raycastTarget===!0}function Qo(e){return e.kind==="container"||e.kind==="grid"||e.kind==="textwindow"||e.kind==="reference"||e.kind==="button"}function ea(e,t){let i=e.Id,n=t.get(i);if(n!==void 0)return n;let r=Dn(e);if(!r&&Qo(e)){let o=e.children;for(let a=0;a<o.length;a+=1)if(ea(o[a],t)){r=!0;break}}return t.set(i,r),r}function Ni(e,t,i){Oi(e);let n=ye({width:e.runtime.canvasWidth,height:e.runtime.canvasHeight}),r=new Map;function o(l,c,s,f){if(!f||l.active===!1||l.visible===!1||!ea(l,r))return null;let h=Fe(c,l),m=Yt(s,h,l),p=Vt(m);if(!p)return null;let y=Oe(p,t,i);if(y.x<h.left||y.x>h.right||y.y<h.bottom||y.y>h.top)return null;if(Fi(l)){let v=Mi(l._scroll,h.width,h.height)?.track,E=y.x-h.centerX,x=h.centerY-y.y;if(v&&E>=v.x&&E<=v.x+v.width&&x>=v.y&&x<=v.y+v.height)return l}if(Qo(l))for(let v=0;v<l.children.length;v+=1){let E=o(l.children[v],h,m,!0);if(E)return E}return Dn(l)?l:null}let a=St();for(let l=e.runtime.roots.length-1;l>=0;l-=1){let c=o(e.runtime.roots[l],n,a,!0);if(c)return c}return null}function Pt(e,t,i,{dragging:n=!1,press:r=null,previous:o=null}={}){let a=r||{x:t,y:i},l=o||{x:t,y:i};return e.runtime.makeCursorEventData({x:t,y:i,pressX:a.x,pressY:a.y,deltaX:t-l.x,deltaY:i-l.y,dragging:n})}function Tn(e,t,i){t.kind==="grid"||t.kind==="textwindow"||(t.pressed=i,typeof t.markPlayDirty=="function"&&t.markPlayDirty(),ni(e,t))}function Fi(e){if(!e?.alive||!e.activeInHierarchy||e.interactable===!1||e.raycastTarget===!1)return!1;for(let t=e;t;t=t.parent)if(t.visible===!1)return!1;return e._scroll?.max>0}function Vo(e){for(let t=e;t;t=t.parent)if(Fi(t))return t;return null}function Yo(e,t,i,n){let r=zi(e),o=r.get(t.Id),a=Xo(e,r).get(t.Id),l=a&&Vt(a);if(!o||!l)return null;let c=Oe(l,i,n);return{x:c.x-o.centerX,y:o.centerY-c.y,width:o.width,height:o.height}}function Bo(e,t,i){let n=e.pointerDownControl;if(n?.alive){let r=Pt(e,t,i,{dragging:e.pointerDragging,press:e.pointerDownPosition,previous:e.pointerLastPosition});e.runtime.injectCursor(n,"CursorUp",r),e.pointerDragging&&!e.pointerScroll&&e.runtime.injectCursor(n,"CursorEndDrag",r),Tn(e,n,!1)}e.pointerDownControl=null,e.pointerScroll=null,e.pointerDownPosition=null,e.pointerDragging=!1,e.pointerLastPosition={x:t,y:i}}function ri(e,t,i,n,r={}){let o=Number(i),a=Number(n);if(!Number.isFinite(o)||!Number.isFinite(a))throw new Error("pointer coordinates must be finite");e.runtime.cursor.x=o,e.runtime.cursor.y=a;let l=Number(r.deltaX??0),c=Number(r.deltaY??0);if(t==="wheel"&&(!Number.isFinite(l)||!Number.isFinite(c)))throw new Error("wheel deltas must be finite");if(r.silent||qe(e,{kind:"pointer",payload:{type:t,x:o,y:a,...t==="wheel"?{deltaX:l,deltaY:c}:{}}}),t==="wheel"){let s=Ni(e,o,a),f=Vo(s);if(f){let h=f._scroll.horizontal&&l||c;_n(f,f._scroll.offset+h)}return s}if(t==="cancel")return Bo(e,o,a),null;if((t==="move"||t==="up")&&e.pointerScroll&&!Fi(e.pointerScroll.control)&&Bo(e,o,a),t==="move"){let s=e.pointerLastPosition||{x:o,y:a},f=e.pointerHoverControl,h=Pn(Ni(e,o,a)),m=Pt(e,o,a,{previous:s});f&&f!==h&&e.runtime.injectCursor(f,"CursorExit",m),h&&f!==h&&e.runtime.injectCursor(h,"CursorEnter",m),e.pointerHoverControl=h;let p=e.hoveredControl;e.hoveredControl=h?.kind==="button"?h:null,p&&p!==e.hoveredControl&&ni(e,p),e.hoveredControl&&ni(e,e.hoveredControl);let y=e.pointerDownControl,v=e.pointerScroll;if(v)if(!Fi(v.control))e.pointerScroll=null;else{let E=Yo(e,v.control,o,a);if(E){let x=v.control._scroll,A=x.horizontal?E.x-v.start.x:E.y-v.start.y,$=Mi(x,E.width,E.height)?.travel||0,O=v.bar?$?A*x.max/$:0:-A;_n(v.control,v.offset+O)}}if(y?.alive){let E=e.pointerDownPosition||s,x=o!==s.x||a!==s.y;!e.pointerDragging&&x&&(v||e.runtime.injectCursor(y,"CursorBeginDrag",Pt(e,o,a,{press:E,previous:s,dragging:!1})),e.pointerDragging=!0),e.pointerDragging&&!v&&e.runtime.injectCursor(y,"CursorDrag",Pt(e,o,a,{press:E,previous:s,dragging:!0}))}return e.pointerLastPosition={x:o,y:a},h}if(t==="down"){let s=Pn(Ni(e,o,a));e.pointerDownControl=s,e.pointerDownPosition={x:o,y:a},e.pointerLastPosition={x:o,y:a},e.pointerDragging=!1,e.pointerScroll=null;let f=Vo(s);if(f){let h=Yo(e,f,o,a),m=h&&Mi(f._scroll,h.width,h.height),p=v=>h.x>=v.x&&h.x<=v.x+v.width&&h.y>=v.y&&h.y<=v.y+v.height,y=m&&p(m.track);if(y&&!p(m.thumb)){let v=f._scroll.horizontal?h.x-m.track.x-m.thumb.width/2:h.y-m.track.y-m.thumb.height/2;_n(f,m.travel?v/m.travel*f._scroll.max:0),Oi(e)}h&&(e.pointerScroll={control:f,start:h,offset:f._scroll.offset,bar:!!y})}return s&&(Tn(e,s,!0),e.runtime.injectCursor(s,"CursorDown",Pt(e,o,a))),s}if(t==="up"){let s=e.pointerDownControl,f=Pn(Ni(e,o,a));if(s?.alive){let h=Pt(e,o,a,{press:e.pointerDownPosition,previous:e.pointerLastPosition,dragging:e.pointerDragging});if(e.runtime.injectCursor(s,"CursorUp",h),e.pointerDragging)e.pointerScroll||e.runtime.injectCursor(s,"CursorEndDrag",h);else if(f===s&&!e.pointerScroll?.bar){e.runtime.injectCursor(s,"CursorClick",h);let m=e.selectedControl;e.selectedControl=s.kind==="button"?s:null,m&&m!==e.selectedControl&&ni(e,m)}Tn(e,s,!1)}return e.pointerDownControl=null,e.pointerDownPosition=null,e.pointerLastPosition={x:o,y:a},e.pointerDragging=!1,e.pointerScroll=null,f}if(t==="click")return ri(e,"down",o,a,{silent:!0}),ri(e,"up",o,a,{silent:!0});throw new Error(`unknown pointer type ${t}`)}function $n(e,t,i,n){if(!e?.server)throw new Error("play session has no server");return qe(e,{kind:"serverSet",payload:{entityType:t,name:i,value:n,playerIndex:e.viewPlayerIndex}}),e.server.setVar(t,i,n,{playerIndex:e.viewPlayerIndex})}function ta(e,t,i){if(!e?.server)throw new Error("play session has no server");let n=e.server.getVar(t,i,{playerIndex:e.viewPlayerIndex});return n===void 0?null:n}function Gn(e,t,i=[],n="PlayerSelf"){if(!e?.server)throw new Error("play session has no server");return qe(e,{kind:"serverSend",payload:{name:t,params:i,target:n,playerIndex:e.viewPlayerIndex}}),e.server.sendToClient(t,i,{target:n,playerIndex:e.viewPlayerIndex})}function $i(e){return{snapshot:t=>Fn(e,t),step:t=>Di(e,t),pointer:(t,i,n,r)=>ri(e,t,i,n,r),key:t=>On(e,t),click:t=>zn(e,t),view:t=>Mn(e,t),pause:()=>{qe(e,{kind:"pause",payload:{}}),e.debugPaused=!0},resume:()=>{qe(e,{kind:"resume",payload:{}}),e.debugPaused=!1},serverSet:(t,i,n)=>$n(e,t,i,n),serverSend:(t,i,n)=>Gn(e,t,i,n)}}function Vn(e){e?.server&&e.server.destroy();let t=e?.runtimes||(e?.runtime?[e.runtime]:[]);for(let i of t)i.destroy()}function Yn(e,t){return JSON.stringify(e)===JSON.stringify(t)}function ia(e,t){for(let i of e||[])t(i),i.children?.length&&ia(i.children,t)}function Bn(e,{id:t,name:i}){let n=null;return ia(e,r=>{n||(t&&String(r.id)===String(t)||!t&&i&&r.name===i)&&(n=r)}),n}function vs(e,t){if(e){if(Object.prototype.hasOwnProperty.call(e,t))return e[t];if(e.box&&Object.prototype.hasOwnProperty.call(e.box,t))return e.box[t]}}function Ss(e){return{var(t,i){return e.server?.vars?.[t]?.[i]?.value??null},logs(){return(e.logs||[]).map(t=>t.text)},logContains(t){return(e.logs||[]).some(i=>String(i.text||"").includes(String(t)))},serverLogs(){return(e.server?.logs||e.serverLogs||[]).map(t=>t.text)},serverLogContains(t){return(e.server?.logs||e.serverLogs||[]).some(i=>String(i.text||"").includes(String(t)))},control(t){let i=Bn(e.tree,{name:String(t)});return i?{id:i.id,name:i.name,kind:i.kind,active:i.active,visible:i.visible,pressed:i.pressed,text:i.text,interactable:i.interactable}:null},signals(t){let i=t==="outbound"?"outbound":"inbound";return(e.server?.[i]||[]).map(n=>({name:n.name,values:n.values}))}}}function ws(e,t){if(e.kind==="log"){let i=e.source==="server"?t.server?.logs||t.serverLogs||[]:t.logs||[];return i.some(r=>e.level&&r.level!==e.level?!1:String(r.text||"").includes(e.contains))?{ok:!0,actual:e.contains}:{ok:!1,actual:i.map(r=>r.text).slice(-8),expected:e.contains}}if(e.kind==="control"){let i=Bn(t.tree,e);if(!i)return{ok:!1,actual:null,expected:e.equals,message:`control not found: ${e.id||e.name}`};let n=vs(i,e.field);return Yn(n,e.equals)?{ok:!0,actual:n}:{ok:!1,actual:n,expected:e.equals}}if(e.kind==="var"){let i=t.server?.vars?.[e.entityType],r=!i||!Object.prototype.hasOwnProperty.call(i,e.name)?null:i[e.name].value;return Yn(r,e.equals)?{ok:!0,actual:r}:{ok:!1,actual:r,expected:e.equals}}if(e.kind==="signal"){let i=e.direction==="outbound"?t.server?.outbound||[]:t.server?.inbound||[],n=i.find(r=>r.name===e.name&&(e.values===void 0||Yn(r.values,e.values)));return n?{ok:!0,actual:n.values}:{ok:!1,actual:i.map(r=>({name:r.name,values:r.values})),expected:{name:e.name,values:e.values??null}}}if(e.kind==="tree"){let i=!!Bn(t.tree,{name:e.name});return i===e.exists?{ok:!0,actual:i}:{ok:!1,actual:i,expected:e.exists}}return{ok:!1,message:`unsupported assert kind ${e.kind}`}}function Cs(e,t){let i=Jt();try{return i.evalQueryScript(e,Ss(t)),{ok:!0,actual:!0}}catch(n){return{ok:!1,message:n?.message||String(n)}}finally{i.destroy()}}function na(e,t){return e.kind==="lua"?Cs(e.source,t):ws(e,t)}function Is(e,t){let i=t>0?t:ct;return Math.round((e+i)*1e9)/1e9}function xs(e,t){let i=t.payload||{};if(t.kind==="pointer")e.pointer(i.type,i.x,i.y,i);else if(t.kind==="key")e.key(i.typeName);else if(t.kind==="click")e.click(i.name);else if(t.kind==="pause")e.pause();else if(t.kind==="resume")e.resume();else if(t.kind==="serverSet")e.serverSet(i.entityType,i.name,i.value);else if(t.kind==="serverSend")e.serverSend(i.name,i.params,i.target);else if(t.kind==="view")e.view(i.playerIndex);else throw new Error(`unsupported event kind: ${t.kind}`)}function ks(e,t){let i=na(e,t);return{kind:e.kind,at:Number(e.at||0),ok:!!i.ok,actual:i.actual??null,expected:i.expected??null,message:i.message||""}}function ra(e,t){let i=ii(t),n=i.events.slice().sort((x,A)=>x.t-A.t),r=i.asserts.slice(),o=i.dt||ct,a=n.reduce((x,A)=>Math.max(x,A.t),0),l=r.reduce((x,A)=>Math.max(x,Number(A.at||0)),0),c=Math.max(a,l),s=0,f=[],h=0,m=r.some(x=>x.kind==="control"||x.kind==="tree"||x.kind==="lua"),p=e.snapshot({inspect:m}),y=()=>{for(;s<n.length&&n[s].t<=h+1e-9;)xs(e,n[s]),s+=1,p=e.snapshot({inspect:m})},v=()=>{for(let x of r)if(!x._done&&Number(x.at||0)<=h+1e-9){let A=ks(x,p);if(f.push(A),x._done=!0,!A.ok)return{passed:!1,failedAt:h,frame:p.frame||0,results:f,snapshot:p}}return null};y();let E=v();if(E)return Un(i,E);for(;h+1e-9<c;){e.step(o),h=Is(h,o),p=e.snapshot({inspect:m}),y();let x=v();if(x)return Un(i,x)}return Un(i,{passed:f.every(x=>x.ok),failedAt:null,frame:p.frame||0,results:f,snapshot:p})}function Un(e,t){return D({format:e.format,name:e.name,passed:t.passed,failedAt:t.failedAt,frame:t.frame,results:t.results,snapshot:{time:t.snapshot?.time??0,frame:t.snapshot?.frame??0,logs:t.snapshot?.logs||[],serverLogs:t.snapshot?.serverLogs||t.snapshot?.server?.logs||[],server:t.snapshot?.server||{vars:{},inbound:[],outbound:[],logs:[]}}})}function jn(e){return Array.isArray(e)?e.slice():[]}var Ts={Level:"\u5173\u5361",PlayerSelf:"\u5F53\u524D\u73A9\u5BB6",AvatarSelf:"\u5F53\u524D\u89D2\u8272",...Object.fromEntries(st.map((e,t)=>[e,`\u73A9\u5BB6${t+1}`])),...Object.fromEntries(Array.from({length:8},(e,t)=>[`Avatar${t+1}`,`\u89D2\u8272${t+1}`]))};function Ms(e,t=1){let i=e?.vars||{},n=[],r=Number(t)>0?Number(t):1,o=["Level","PlayerSelf","AvatarSelf"];if(r>1)for(let l=1;l<=r;l+=1)o.push(`Player${l}`,`Avatar${l}`);let a=new Set;for(let l of o){if(a.has(l)||!i[l])continue;a.add(l);let c=i[l]||{};for(let s of Object.keys(c))n.push(D({entityType:l,entityLabel:Ts[l]||l,name:s,type:c[s]?.type||"",value:c[s]?.value??null}))}return n}var ht="qxqy-simulator-save",Ns="qxqy-simulator-scripts",oe="server-control-template",B="client-control-template",Xn={[oe]:"\u670D\u52A1\u5668\u63A7\u4EF6\u6A21\u677F",[B]:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F"};function dt(e){return e===B?"client":"server"}function Gi(e){if(!(typeof e=="number"||typeof e=="string"&&/^\d+$/.test(e.trim()))||!xe(e))throw new Error("\u63A7\u4EF6\u7D22\u5F15\u5FC5\u987B\u662F 1\u20132147483647 \u8303\u56F4\u5185\u7684\u6574\u6570");return Number(e)}function Hn(e=[]){if(!Array.isArray(e))throw new Error("controlGuidChanges \u5FC5\u987B\u662F\u6570\u7EC4");let t=new Set;return e.map(i=>{if(!i||typeof i.id!="string"||!i.id||t.has(i.id)||![oe,B].includes(i.controlAsset)||typeof i.controlId!="string"||!i.controlId||typeof i.controlName!="string")throw new Error("controlGuidChanges \u5305\u542B\u65E0\u6548\u6216\u91CD\u590D\u7684\u53D8\u66F4\u8BB0\u5F55");return t.add(i.id),{id:i.id,controlAsset:i.controlAsset,controlId:i.controlId,controlName:i.controlName,oldGuid:Gi(i.oldGuid),newGuid:Gi(i.newGuid)}})}function Fs(e){let t=[e?.guid,e?.id];for(let i of t){let n=Number(i);if(Number.isSafeInteger(n)&&n>0&&n<=2147483647)return n}return 0}function Vi(e){let t=String(e?.controlAsset||""),i=Fs(e);return{id:String(i||e?.id||""),guid:i,path:String(e?.path||""),source:String(e?.source||""),controlId:String(e?.controlId||""),controlAsset:t===B||t==="client"?B:t===oe||t==="server"?oe:""}}function Os(e){let t=[],i=(n,r="")=>{if(n&&(n.path||n.source)){let o=Vi(n);t.push(r?{...o,controlAsset:r}:o)}};if(Array.isArray(e?.assets?.scripts)){for(let n of e.assets.scripts)n&&(n.path||n.source)&&t.push(Vi(n));return t}if(i(e?.assets?.server?.script,oe),i(e?.assets?.client?.script,B),e&&e.format!==ht){i(e?.script);for(let n of e?.scripts||[])i(n)}return t}function Kn(e){return He(e===B?Ct():nt())}var zs="\u672A\u7ED1\u5B9A",Rt="\u672A\u547D\u540D\u5B58\u6863",Ds="\u672A\u547D\u540D\u754C\u9762";function $s(e){let t=e;for(let i=0;i<8;i++){if(oi(oa(t,"simulator","studio"))&&oi(oa(t,"lua")))return t;let n=Ps(t);if(n===t)break;t=n}return e}function Gs(e){return e?{name:Tt(e),path:e,bound:!0}:{name:zs,path:"",bound:!1}}function Vs(e,t=process.cwd()){if(Rs(e)&&oi(e))return e;let i=t||process.cwd(),n=$s(i),r=aa(n,e);if(oi(r))return r;let o=aa(i,e);if(oi(o))return o;throw new Error("script file not found: "+e)}function qn(e,t={}){e?.format===ht&&sn(e.version);let i=[],n=typeof t.workspacePath=="string"&&t.workspacePath?t.workspacePath:"",r=e?.format===ht&&e.assets,o=Hn(e?.controlGuidChanges),a=Bi(e?.scriptSync),l=r?null:He(e,{warnings:i}),c={server:r&&e.assets.server?He(e.assets.server,{warnings:i}):Kn(oe),client:r&&e.assets.client?He(e.assets.client,{warnings:i}):Kn(B)};l&&(c[dt(l.meta.assetType)]=l);let s=r&&e.activeAssetType===B?B:l?.meta.assetType||oe,f=r&&e.meta?.name?String(e.meta.name):"",h=()=>f||Rt;!e?.meta?.name&&c.server.meta.name==="\u672A\u547D\u540D\u754C\u9762\u63A7\u4EF6\u7EC4"&&(c.server.meta.name=Ds);let m=[],p=new Set;function y(){p.clear(),wt(c.server.root,p),wt(c.client.root,p,{skipServerContainer:!0});for(let d of m)xe(d.guid)&&p.add(Number(d.guid))}function v(d=0){y();let g=xe(d)&&!p.has(Number(d))?Number(d):Ye(p);return p.add(g),g}function E(d){let g=Vi(d),C=v(g.guid);return{...g,guid:C,id:String(C)}}Ge(Os(e));let x=ti(e?.serverLogic),A=null,$="",O=1,J=1;function ee(d){let g=String(d||"").trim();if(!g)return"";if(!ie[g])throw new Error(`unknown canvas preset: ${g} (available: ${Object.keys(ie).join(", ")})`);return g}let Z=()=>c[dt(s)];function z(d){if(!d)return null;for(let[g,C]of[["server",c.server],["client",c.client]]){let P=ce(C.root,d);if(P&&P.kind!=="server-container")return{key:g,node:P}}return null}function b(d){if(!d.controlId)return null;let g=d.controlAsset===B?"client":d.controlAsset===oe?"server":null;if(g){let C=ce(c[g].root,d.controlId);return C&&C.kind!=="server-container"?{key:g,node:C}:null}return z(d.controlId)}function k(){for(let d of m)d.controlId&&!b(d)&&(d.controlId="",d.controlAsset="")}function S(d){if(!xe(d))return null;for(let[g,C]of[[oe,c.server],[B,c.client]]){let P="";if(L(C.root,T=>{!P&&(T.scriptMappingIds||[]).includes(Number(d))&&(P=T.id)}),P)return{controlId:P,controlAsset:g}}return null}function I(d,g,C){let P=c[dt(d.controlAsset)],T=P&&ce(P.root,d.controlId);T&&(T.scriptMappingIds=(T.scriptMappingIds||[]).map(N=>Number(N)===Number(g)?Number(C):N))}k();function F(){return m.map(d=>{let g=b(d),C=g?g.key==="client"?B:oe:"";return D({id:d.id,guid:d.guid||0,path:d.path||"",source:d.source||"",controlId:d.controlId||"",controlAsset:d.controlAsset||C,controlName:g?.node.name||"",assetType:C,assetLabel:g?Xn[C]:"",mounted:!!g})})}function w(){let d=[],g=(C,P)=>{L(C.root,T=>{T.kind!=="server-container"&&d.push(D({id:T.id,name:T.name,kind:T.kind,assetType:P,assetLabel:Xn[P]}))})};return g(c.server,oe),g(c.client,B),d}function M(d){let g=[];return L(d.root,C=>{C.kind!=="server-container"&&g.push(JSON.stringify({kind:C.kind,guid:C.guid,name:C.name,text:C.text??null,imageId:C.imageId??null,fontSize:C.fontSize??null,fontColor:C.fontColor??null,bgColor:C.bgColor??null,imageColor:C.imageColor??null,fillType:C.fillType??null,fillAmount:C.fillAmount??null,syncAllDevices:C.syncAllDevices!==!1,transformByPlatform:C.transformByPlatform||null}))}),g.join("/")}let G=M(Ct()),U=M(nt());function le(d){let g=M(d);return d.meta?.assetType===B?g===G:g===U}function X(d,g){return String(d||"").replace(/[\\/:*?"<>|]/g,"-").trim()||g}function he(d){let g=X(h(),Rt),C=d.meta?.assetType===B?"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F":"\u670D\u52A1\u5668\u63A7\u4EF6\u6A21\u677F";return`${g} \xB7 ${C}`}function Je(){if(!((c.server.root.children||[]).find(g=>g.kind==="container")||c.server.root.children?.[0]))throw new Error("\u6574\u5408\u5305\u9700\u8981\u670D\u52A1\u7AEF\u5BA2\u6237\u7AEF\u63A7\u4EF6\u5BB9\u5668\u4E0B\u81F3\u5C11\u6709\u4E00\u4E2A\u6839\u63A7\u4EF6");return $r(c.server,c.client,{scripts:m,fileName:`${X(h(),Rt)} \xB7 \u6574\u5408\u5305.gia`})}function pt(){let d=g=>({type:g.meta.assetType,name:g.meta.name,sourceFile:g.meta.sourceFile||""});return{format:ht,name:h(),activeAssetType:s,assets:{server:d(c.server),client:d(c.client),scripts:F()}}}function Mt(){return D({format:ht,version:4,meta:{name:h()},activeAssetType:s,serverLogic:x,controlGuidChanges:o,scriptSync:a,assets:{server:c.server,client:c.client,scripts:m.map(d=>D({id:d.id,guid:d.guid||0,path:d.path||"",source:d.source||"",controlId:d.controlId||"",controlAsset:d.controlAsset||""}))}})}function te(){let d=Z(),g=to(d);return g.workspace=Gs(n),g.save=pt(),g.scripts=F(),g.mountTargets=w(),g.serverLogic=x,g.migrationWarnings=[...i],g.controlGuidChanges=D(o),g.scriptSync=D(a),lr(g),g}function Ae(d){let g=Z();if(d.expectedRevision!==void 0&&Number(d.expectedRevision)!==g.version)throw new Error(`revision conflict: expected ${d.expectedRevision}, current ${g.version}`);return g}function Ze(d,g,C=""){let P=String(g||"");if(P){let T=C===B?B:C===oe?oe:"";if(!b({controlId:P,controlAsset:T}))throw new Error("\u6302\u8F7D\u76EE\u6807\u5FC5\u987B\u662F\u5B58\u6863\u5185\u7684\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6216\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F");d.controlAsset=T}else d.controlAsset="";d.controlId=P}function si(d){let g=Ae(d);if(d.op==="addScript"){let C=E({path:String(d.path||""),source:String(d.source||""),controlId:"",controlAsset:""});d.controlId!==void 0&&d.controlId!==""&&Ze(C,d.controlId,d.controlAsset),m.push(C)}else if(d.op==="updateScript"){let C=m.find(P=>P.id===d.id);if(!C)throw new Error(`\u811A\u672C\u4E0D\u5B58\u5728: ${d.id}`);d.controlId!==void 0&&Ze(C,d.controlId,d.controlAsset),d.path!==void 0&&(C.path=String(d.path)),d.source!==void 0&&(C.source=String(d.source))}else if(d.op==="removeScript"){let C=m.length;if(m=m.filter(P=>P.id!==d.id),m.length===C)throw new Error(`\u811A\u672C\u4E0D\u5B58\u5728: ${d.id}`)}return g.version+=1,te()}function ui(d){let g=Ae(d),C=ce(g.root,d.id??g.selectedId);if(!C||C.kind==="server-container")throw new Error("\u4EC5\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6216\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u5141\u8BB8\u4FEE\u6539\u7D22\u5F15");let P=Gi(d.guid),T=Gi(C.guid);if(P===T)return te();let N=[];for(let Y of Object.values(c))L(Y.root,re=>{Y===c.client&&re.kind==="server-container"||N.push({node:re,project:Y})});if(N.some(Y=>Y.node!==C&&Number(Y.node.guid)===P)||m.some(Y=>Number(Y.guid)===P))throw new Error(`\u63A7\u4EF6\u7D22\u5F15 ${P} \u5DF2\u88AB\u5176\u4ED6\u63A7\u4EF6\u6216\u811A\u672C\u5360\u7528`);let V=[],K=(Y,re,Re)=>{let Q=Y?.[re];(typeof Q=="number"||typeof Q=="string"&&/^\d+$/.test(Q.trim()))&&Number(Q)===T&&V.push({owner:Y,key:re,project:Re.project})};for(let Y of N)K(Y.node,"referencedPrefabId",Y),K(Y.node,"itemPrefabId",Y),K(Y.node.giaRaw,"templateRefSlot",Y);if(V.length&&N.filter(Y=>Number(Y.node.guid)===T).length!==1)throw new Error(`\u65E7\u7D22\u5F15 ${T} \u5728\u591A\u68F5\u8D44\u4EA7\u6811\u4E2D\u91CD\u590D\uFF0C\u65E0\u6CD5\u786E\u5B9A\u6A21\u677F\u5F15\u7528\u5F52\u5C5E\uFF1B\u8BF7\u5148\u6D88\u9664\u6B67\u4E49\u540E\u4FEE\u6539`);let Pe={id:_s(),controlAsset:s,controlId:C.id,controlName:C.name,oldGuid:T,newGuid:P};C.guid=P;let me=new Set([g]);for(let{owner:Y,key:re,project:Re}of V)Y[re]=typeof Y[re]=="string"?String(P):P,me.add(Re);o.push(Pe);for(let Y of me)Y.version+=1;return te()}function ne(d){let g=Ae(d);if(!Array.isArray(d.changeIds)||!d.changeIds.length||d.changeIds.some(P=>typeof P!="string"||!o.some(T=>T.id===P)))throw new Error("\u8BF7\u660E\u786E\u6307\u5B9A\u5DF2\u6838\u5BF9 Lua \u5F15\u7528\u7684\u6709\u6548\u7D22\u5F15\u53D8\u66F4\u8BB0\u5F55 changeIds");let C=new Set(d.changeIds);return o=o.filter(P=>!C.has(P.id)),g.version+=1,te()}function _e(d){if(!d||typeof d!="object")throw new Error("patch requires op");if(d.op==="setScriptSync"){let g=Ae(d);return a=Bi(d.config),g.version+=1,te()}if(d.op==="setControlGuid")return ui(d);if(d.op==="acknowledgeControlGuidChanges")return ne(d);if(d.op==="setServerLogic"){let g=Ae(d);return x=ti(d.logic),g.version+=1,te()}if(d.op==="addScript"||d.op==="updateScript"||d.op==="removeScript")return si(d);if(d.op==="selectAsset")return s=d.assetType===B?B:oe,te();if(d.op==="renameSave"){let g=String(d.name||"").trim();if(!g)throw new Error("\u5B58\u6863\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A");return f=g,te()}if(d.op==="newAsset"){let g=Ae(d);s=d.assetType===B?B:oe;let C=Kn(s);return C.version=g.version+1,c[dt(s)]=C,o=o.filter(P=>P.controlAsset!==s),k(),te()}return fn(Z(),d),k(),te()}function Ne(d){return m.filter(g=>{let C=b(g);return!!(C&&C.key==="client"==(d===B))})}function Nt(d="json",g=""){let C=Ft(d,g);if(o.length&&!["save","archive"].includes(String(d).toLowerCase())){let P=o.map(T=>`\u63A7\u4EF6\u7D22\u5F15\u5F85\u6838\u5BF9 Lua \u5F15\u7528\uFF1A${Xn[T.controlAsset]} / ${T.controlName} (${T.controlId})\uFF1A${T.oldGuid} \u2192 ${T.newGuid}\u3002\u8BF7\u6309\u8BED\u4E49\u66F4\u65B0\u811A\u672C\u4E2D\u7684\u63A7\u4EF6\u7D22\u5F15\u5F15\u7528\uFF0C\u6838\u5BF9\u540E\u786E\u8BA4\u53D8\u66F4\u8BB0\u5F55 ${T.id}\uFF1B\u4E0D\u8981\u5168\u5C40\u66FF\u6362\u540C\u503C\u6570\u5B57\u3002`);C.warnings=[...new Set([...C.warnings||[],...P])]}return C}function Ft(d="json",g=""){let C=String(d).toLowerCase();if(C==="save"||C==="archive"){let N=Buffer.from(JSON.stringify(Mt(),null,2),"utf8");return D({filename:`${h().replace(/[\\/:*?"<>|]/g,"-")} \xB7 \u8D44\u4EA7\u5305.json`,mimeType:"application/json",encoding:"base64",data:N.toString("base64"),warnings:[]})}if(C==="save-gia"||C==="archive-gia"){let N=[],V=[],K=(me,Y="")=>{let re=Nt(me,Y);N.push(D({filename:re.filename,mimeType:re.mimeType,encoding:re.encoding,data:re.data,warnings:re.warnings||[]})),V.push(...re.warnings||[])},Pe=(me,Y)=>{let re=c[dt(me)],Re=me===s,Q=m.some(ve=>ve.controlAsset===me&&ve.controlId);if(!Re&&le(re)&&!Q){V.push(Y);return}K("gia",me)};if(Pe(oe,"\u670D\u52A1\u5668\u63A7\u4EF6\u6A21\u677F\u4ECD\u662F\u9ED8\u8BA4\u6A71\u7A97\uFF0C\u672A\u6539\u52A8\u4E14\u5F53\u524D\u672A\u663E\u793A\uFF0C\u5DF2\u4ECE\u8D44\u4EA7\u5305 GIA \u4E2D\u7701\u7565\u3002"),Pe(B,"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F\u4ECD\u662F\u9ED8\u8BA4\u300CLua\u5B9E\u4F8B\u5316\u9762\u677F\u300D\uFF0C\u672A\u6539\u52A8\u4E14\u5F53\u524D\u672A\u663E\u793A\uFF0C\u5DF2\u4ECE\u8D44\u4EA7\u5305 GIA \u4E2D\u7701\u7565\u3002"),m.some(me=>me.path||me.source)&&K("scripts-gia"),!N.length)throw new Error("\u8D44\u4EA7\u5305 GIA \u6CA1\u6709\u53EF\u5BFC\u51FA\u7684\u5DF2\u6539\u52A8\u9879\uFF1B\u8BF7\u5148\u7F16\u8F91\u5F53\u524D\u754C\u9762\uFF0C\u6216\u6539\u7528\u300C\u5F53\u524D\u754C\u9762 GIA\u300D\u3002");return D({format:"qxqy-gia-package",files:N,warnings:[...new Set(V)]})}if(C==="gia-combined"||C==="combined-gia"||C==="combined"){let N=Je();return D({filename:`${X(h(),Rt)} \xB7 \u6574\u5408\u5305.gia`,mimeType:"application/octet-stream",encoding:"base64",data:N.buffer.toString("base64"),warnings:[...new Set(N.warnings||[])]})}if(C==="scripts"){let N=D({format:Ns,version:1,scripts:m.map(K=>D({id:K.id,guid:K.guid||0,path:K.path||"",source:K.source||"",controlId:K.controlId||"",controlAsset:K.controlAsset||""}))}),V=Buffer.from(JSON.stringify(N,null,2),"utf8");return D({filename:`${X(h(),Rt)} \xB7 \u811A\u672C.json`,mimeType:"application/json",encoding:"base64",data:V.toString("base64"),warnings:[]})}if(C==="scripts-gia"||C==="scriptsgia"){let N=Br(m);return D({filename:`${X(h(),Rt)} \xB7 \u811A\u672C.gia`,mimeType:"application/octet-stream",encoding:"base64",data:N.buffer.toString("base64"),warnings:N.warnings})}if(C==="lua"){let N=m.find(K=>K.id===g)||m.find(K=>K.path===g);if(!N)throw new Error("\u6CA1\u6709\u53EF\u5BFC\u51FA\u7684 Lua \u811A\u672C\uFF0C\u8BF7\u5148\u5728\u201CLua \u811A\u672C\u201D\u9875\u521B\u5EFA");let V=Tt(N.path||"")||`qxqy-script-${N.id}`;return D({filename:/\.lua$/i.test(V)?V:`${V}.lua`,mimeType:"text/x-lua",encoding:"base64",data:Buffer.from(N.source||"","utf8").toString("base64"),warnings:[]})}let P=g?c[dt(g)]:Z(),T=he(P);if(C==="json"){let N=D({...P,scripts:Ne(P.meta.assetType),controlGuidChanges:o.filter(K=>K.controlAsset===P.meta.assetType)}),V=Buffer.from(JSON.stringify(N,null,2),"utf8");return D({filename:`${T}.json`,mimeType:"application/json",encoding:"base64",data:V.toString("base64"),warnings:[]})}if(C==="gia"){let N=Dr(P,P.meta.assetType===B?{scripts:Ne(B)}:{}),V=P.meta.assetType===B?[]:Ne(oe);return V.length&&N.warnings.unshift(`\u5F53\u524D\u670D\u52A1\u5668\u63A7\u4EF6 GIA \u4E0D\u5305\u542B ${V.length} \u4E2A Lua \u811A\u672C\u7684\u6E90\u7801\uFF1B\u8BF7\u4F7F\u7528\u300C\u8D44\u4EA7\u5305 GIA \u6574\u5408\u5305\u300D\uFF0C\u6216\u53E6\u884C\u5BFC\u5165\u811A\u672C\u5305\u5E76\u6838\u5BF9\u6302\u8F7D\u3002`),D({filename:`${T}.gia`,mimeType:"application/octet-stream",encoding:"base64",data:N.buffer.toString("base64"),warnings:N.warnings})}throw new Error(`unsupported export format: ${d}`)}function Ge(d){for(let g of d){let C=Vi(g);if(!C.path&&!C.source)continue;let P=C.controlId?null:S(C.guid),T=E(P?{...C,...P}:C);P&&T.guid!==C.guid&&I(P,C.guid,T.guid),T.controlId&&!b(T)&&(T.controlId="",T.controlAsset=""),m.push(T)}}function Ot(d,g,C=""){let P=String(d||"").toLowerCase();if(typeof g!="string"||!g)throw new Error("import data is required");let T=Buffer.from(g,"base64"),N,V=[],K={};if(P==="json"){try{N=JSON.parse(T.toString("utf8"))}catch{throw new Error("JSON \u6587\u4EF6\u65E0\u6548")}if(N?.project&&(N=N.project),N?.format===ht&&N?.assets){sn(N.version);let Q=qn(N);V.push(...Q.get().migrationWarnings);let ve=Q.archiveData();return c.server=ve.assets.server,c.client=ve.assets.client,i=[...V],s=N.activeAssetType===B?B:oe,f=String(N.meta?.name||Tt(C).replace(/\.json$/i,"")||f),x=ve.serverLogic,m=ve.assets.scripts,o=ve.controlGuidChanges,a=ve.scriptSync,p.clear(),D({snapshot:te(),warnings:V,metadata:{format:ht}})}}else{if(P==="lua")return m.push(E({path:Tt(C||"imported.lua"),source:T.toString("utf8"),controlId:""})),D({snapshot:te(),warnings:V,metadata:{assetType:"lua-script"}});if(P==="gia"){if(Ur(T)){let we=Xr(T);return Ge(we.scripts),D({snapshot:te(),warnings:we.warnings,metadata:we.metadata})}let Q=Hr(T);N=Q.project,V=Q.warnings,K=Q.metadata,Q.clientProject&&(c.client=He(Q.clientProject),o=o.filter(we=>we.controlAsset!==B),V.push("\u6574\u5408\u5305\u5DF2\u62C6\u56DE\u300CUI\u63A7\u4EF6-\u670D\u52A1\u7AEF\u300D\u4E0E\u300CUI\u63A7\u4EF6-\u5BA2\u6237\u7AEF\u300D\uFF1B\u5BA2\u6237\u7AEF\u6A21\u677F\u8FB9\u754C\u5DF2\u4FDD\u7559\u3002"));let ve=new Map,Zn=(we,Aa)=>{we&&L(we.root,Qn=>{for(let Yi of Qn.scriptMappingIds||[]){let er=ve.get(Number(Yi));if(er){V.push(`\u811A\u672C GUID ${Yi} \u540C\u65F6\u6302\u8F7D\u5230\u591A\u4E2A\u63A7\u4EF6\uFF0C\u5DF2\u4FDD\u7559\u201C${er.controlAsset===oe?"\u670D\u52A1\u7AEF":"\u5BA2\u6237\u7AEF"}\u201D\u76EE\u6807\u3002`);continue}ve.set(Number(Yi),{controlId:Qn.id,controlAsset:Aa})}})};Zn(Q.project,oe),Zn(Q.clientProject,B),Ge((Q.scripts||[]).map(we=>ve.has(Number(we.guid))?{...we,...ve.get(Number(we.guid))}:we))}else throw new Error(`unsupported import format: ${d}`)}let Pe=He(N,{warnings:V}),me=Hn(N?.controlGuidChanges);if(me.some(Q=>Q.controlAsset!==Pe.meta.assetType))throw new Error("\u5355\u8D44\u4EA7 JSON \u7684\u7D22\u5F15\u53D8\u66F4\u8BB0\u5F55\u5FC5\u987B\u5C5E\u4E8E\u5F53\u524D\u5BFC\u5165\u8D44\u4EA7");let Y=Hn([...o.filter(Q=>Q.controlAsset!==Pe.meta.assetType),...me]);i=[...V];let re=dt(Pe.meta.assetType);c[re]=Pe,o=Y,s=Pe.meta.assetType;let Re=c[re];return C&&(Re.meta.name=Tt(C).replace(/\.(json|gia)$/i,"")||Re.meta.name,Re.meta.sourceFile=Tt(C),Re.meta.sourceFormat=P),Ge(N?.scripts||[]),N?.script&&(N.script.path||N.script.source)&&Ge([N.script]),D({snapshot:te(),warnings:V,metadata:K})}function la(d,g){return fn(Z(),{op:"pick",x:d,y:g}),te()}function sa(d){let g=typeof d=="string"&&d?d:"";!g||g===n||(n=g)}function ua(d){let g=d.source||"";if(!g.trim()&&d.path.trim())try{g=As(Vs(d.path,n),"utf8")}catch(C){throw new Error(`\u811A\u672C ${d.path} \u8BFB\u53D6\u5931\u8D25: ${C?.message||C}`)}return g}function zt(d={}){let g=ee(d.canvasId);g&&($=g),d.playerCount!==void 0&&d.playerCount!==null&&d.playerCount!==""&&(O=lt(d.playerCount),J>O&&(J=1)),d.viewPlayerIndex!==void 0&&d.viewPlayerIndex!==null&&d.viewPlayerIndex!==""&&(J=$e(d.viewPlayerIndex,O)),A&&Vn(A);let C=m.map(T=>{try{return{id:T.id,guid:T.guid||0,path:T.path||T.id,source:ua(T),controlId:T.controlId||"",controlAsset:T.controlAsset||""}}catch(N){return{id:T.id,guid:T.guid||0,path:T.path||T.id,source:`error([==[ ${String(N.message).replace(/]=+]/g,"] =]")} ])`,controlId:T.controlId||"",controlAsset:T.controlAsset||""}}}),P=T=>C.filter(N=>{let V={controlId:N.controlId,controlAsset:N.controlAsset},K=N.controlId?b(V):null;return!!(K&&K.key===T)});return A=Ko(c.server,{templatesProject:c.client,scripts:C,sceneScripts:P("server"),templateScripts:P("client"),serverConfig:{logic:x},canvasId:$,playerCount:O,viewPlayerIndex:J,language:d.language||""}),ue(d)}function ca(d,g={}){let C=ee(d);if(!C)throw new Error("playSetCanvas requires canvasId");return zt({...g,canvasId:C})}function ue(d={}){if(!A)return D({running:!1,tree:[],logs:[],serverLogs:[],serverVars:[]});let g=Fn(A,d);return g.running=!0,g.logs=jn(g.logs),g.serverLogs=jn(g.server?.logs||[]),g.serverVars=Ms(g.server,g.playerCount||1),g}function fa(d,g={}){return A||zt(),Di(A,d),g.observe===!1?D({running:!0,time:A.runtime.clock.time,frame:A.runtime.clock.frame,paused:!!A.debugPaused,levelTimePaused:!!A.runtime.clock.paused,playerCount:A.playerCount||1,viewPlayerIndex:A.viewPlayerIndex||1}):ue(g)}function da(d=0){zt();let g=Math.max(0,Number(d)||0);for(let C=0;C<g;C++)Di(A,1/30);return ue()}function ha(){return A&&Vn(A),A=null,$="",O=1,J=1,D({running:!1,tree:[],logs:[],serverLogs:[],serverVars:[]})}function ma(d,g={}){let C=Dt();return J=Mn(C,d),g.observe===!1?null:ue(g)}function pa(d,g={}){if(!A)throw new Error("play session has not started");return On(A,d),g.observe===!1?null:ue(g)}function ga(d,g={}){if(!A)throw new Error("play session has not started");return zn(A,d),g.observe===!1?null:ue(g)}function ya(d,g,C,P={}){if(!A)throw new Error("play session has not started");return ri(A,d,g,C,P),P.observe===!1?null:ue(P)}function ba(d={}){return A&&$i(A).pause(),d.observe===!1?null:ue(d)}function va(d={}){return A&&$i(A).resume(),d.observe===!1?null:ue(d)}function Dt(){if(!A)throw new Error("play session has not started");return A}function Sa(d,g){let C=Dt();if(!d&&!g){let P=ue();return D({vars:P.serverVars||[]})}return D({entityType:String(d||""),name:String(g||""),value:ta(C,d,g)})}function wa(d,g,C){let P=Dt();return $n(P,d,g,C),ue()}function Ca(d,g=[],C="PlayerSelf"){let P=Dt();return Gn(P,d,g,C),ue()}function Ia(){let d=ue();return D({events:d.history||[],case:Oo(d.history||[],{playerCount:d.playerCount||1})})}function xa(d={}){let g=ue(),C=ii({name:d.name||"",dt:d.dt,playerCount:d.playerCount||g.playerCount||1,events:d.events||g.history||[],asserts:d.asserts||[]});return D(C)}function ka(d,g={}){let C=ii(d);zt({...g,playerCount:g.playerCount||C.playerCount||1});let P=Dt();P.recording=!1;try{return ra($i(P),d)}finally{P.recording=!0}}function Ea(){if(!A)return{running:!1,paused:!1,time:0,frame:0,playerCount:1,viewPlayerIndex:1};let d=A.runtime.clock;return{running:!0,paused:!!A.debugPaused,levelTimePaused:!!d.paused,time:d.time,frame:d.frame,playerCount:A.playerCount||1,viewPlayerIndex:A.viewPlayerIndex||1}}let Jn={get:te,patch:_e,setWorkspace:sa,exportData:Nt,importData:Ot,pick:la,playStart:zt,playSetCanvas:ca,playSetView:ma,playGet:ue,playStatus:Ea,playStep:fa,playRun:da,playStop:ha,playKey:pa,playClick:ga,playPointer:ya,playPause:ba,playResume:va,playServerGet:Sa,playServerSet:wa,playServerSend:Ca,playHistory:Ia,playSaveCase:xa,playRunCase:ka,archiveData:Mt};return Object.defineProperty(Jn,"_project",{enumerable:!1,get:Z}),Jn}var j=null,Wn=!1,mt=0,We=0,Ys=33,ai=1/30,Bs=5;function li(e={}){return{...e.inspect?{inspect:!0}:{},...e.view?{view:!0}:{},...e.paint?{paint:!0}:{},...e.compact?{compact:!0}:{},...e.sceneRev!==void 0&&e.sceneRev!==null?{sceneRev:e.sceneRev}:{}}}function Us(e={}){let t=li(e);for(let i of["canvasId","playerCount","viewPlayerIndex","language"])e[i]!==void 0&&e[i]!==null&&e[i]!==""&&(t[i]=e[i]);return t}function Le(e={}){return e.light?{...j.playStatus()}:j.playGet(li(e))}function js(){if(!j||Wn)return;let e=j.playStatus();if(!e.running||e.paused){mt=0,We=0;return}let t=Date.now();if(!mt){mt=t;return}Wn=!0;try{We+=Math.min(.25,Math.max(0,(t-mt)/1e3)),mt=t;let i=0;for(;We>=ai&&i<Bs;)j.playStep(ai,{observe:!1}),We-=ai,i+=1;We>ai&&(We=ai)}finally{Wn=!1}}var mf=setInterval(js,Ys);function Xs(e,t={}){if(e==="start")return j&&j.playStop(),j=qn(t.archive||t.project,{workspacePath:t.workspacePath||""}),mt=0,We=0,j.playStart(Us(t));if(!j)throw new Error("play session has not started");if(e==="get")return t.light?Le(t):j.playGet(li(t));if(e==="step"){let i=j.playStep(t.dt,t.light?{observe:!1}:li(t));return t.light?Le(t):i}if(e==="pointer")return j.playPointer(t.type,t.x,t.y,{observe:!1,deltaX:t.deltaX,deltaY:t.deltaY}),Le(t);if(e==="key")return j.playKey(t.key,{observe:!1}),Le(t);if(e==="click")return j.playClick(t.name,{observe:!1}),Le(t);if(e==="pause")return j.playPause({observe:!1}),Le(t);if(e==="resume")return j.playResume({observe:!1}),Le(t);if(e==="device")return j.playSetCanvas(t.canvasId,li(t));if(e==="view")return j.playSetView(t.playerIndex??t.viewPlayerIndex,{observe:!1}),Le(t);if(e==="serverGet")return j.playServerGet(t.entityType,t.name);if(e==="serverSet")return j.playServerSet(t.entityType,t.name,t.value);if(e==="serverSend")return j.playServerSend(t.name,t.params||[],t.target||"PlayerSelf");if(e==="history")return j.playHistory();if(e==="saveCase")return j.playSaveCase(t.case||t);if(e==="runCase")return j.playRunCase(t.case||t,{canvasId:t.canvasId,playerCount:t.playerCount,viewPlayerIndex:t.viewPlayerIndex});if(e==="stop"){let i=j.playStop();return j=null,mt=0,We=0,i}throw new Error(`unknown play action: ${e}`)}Ln.on("message",e=>{let{id:t,action:i,args:n={}}=e||{};try{Ln.postMessage({id:t,ok:!0,value:Xs(i,n),error:null})}catch(r){Ln.postMessage({id:t,ok:!1,value:null,error:r?.message||String(r)})}});