dsh-plugin-beyond-simulator 2.0.2 → 2.0.4

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 An}from"node:worker_threads";import{existsSync as jt,readFileSync as Nl}from"node:fs";import{basename as kt,dirname as Fl,isAbsolute as Ol,join as ba,resolve as va}from"node:path";var re=Object.freeze(["KEYBOARD","TOUCHSCREEN","CONTROLLER_CONSOLE","CONTROLLER_MOBILE"]),J=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"}}),Qt="pc-16-9",fe=2,pt=Object.freeze({KEYBOARD:"pc-16-9",TOUCHSCREEN:"mobile-16-9",CONTROLLER_CONSOLE:"pc-16-9",CONTROLLER_MOBILE:"mobile-16-9"}),gt=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"}),ei=Object.freeze(["server-container","container","textbox","cursor","reference","grid","image","button","textwindow","keyhint","animation","fullscreen"]),Mn=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}),yt=Object.freeze({100001:"rect",100002:"circle",100003:"triangle",100004:"fourstar",100005:"fivestar",100006:"ring"}),Nn=50888,Mt=Object.freeze({font:4294967295,bg:16777215,outline:858993459,image:4294967295});function bt(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)=>bt(n,`${t}[${r}]`,i));else for(let[n,r]of Object.entries(e))bt(r,`${t}.${n}`,i);i.delete(e)}}function D(e){return bt(e),JSON.parse(JSON.stringify(e))}function Fn(e,t="$"){bt(e,t)}function On(e){return J[e]||J[Qt]}function Nt(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 Va(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 Ya(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 ti({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 Ie(e){let t=e||ti();return{scale:Va(t.scale),rotation:Ya(t.rotation),anchorMin:Nt(t.anchorMin??t.anchor_min,.5,.5),anchorMax:Nt(t.anchorMax??t.anchor_max,.5,.5),offset:Nt(t.offset,0,0),size:Nt(t.size,0,0),pivot:Nt(t.pivot,.5,.5)}}function de(e,t=0){let i=Number(e);return Number.isFinite(i)?i:t}function Ae(e,t){let i=e.width,n=e.height,r=e.left,a=e.bottom,o=t.anchorMin||{x:t.anchorMinX,y:t.anchorMinY},l=t.anchorMax||{x:t.anchorMaxX,y:t.anchorMaxY},f=t.offset||{x:t.anchoredPositionX,y:t.anchoredPositionY},s=t.size||{x:t.sizeDeltaX,y:t.sizeDeltaY},c=t.pivot||{x:t.pivotX,y:t.pivotY},m=de(o?.x,.5)*i,h=de(o?.y,.5)*n,p=de(l?.x,.5)*i,v=de(l?.y,.5)*n,w=de(s?.x),x=de(s?.y),k=de(c?.x,.5),$=de(c?.y,.5),O=p-m+w,Y=v-h+x,L=r+m+de(f?.x)-w*k,Z=a+h+de(f?.y)-x*$;return{left:L,bottom:Z,width:O,height:Y,right:L+O,top:Z+Y,centerX:L+O/2,centerY:Z+Y/2}}function vt(){return{a:1,b:0,c:0,d:1,tx:0,ty:0}}function Ba(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 We(e,t,i){return{x:e.a*t+e.c*i+e.tx,y:e.b*t+e.d*i+e.ty}}function ii(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 ki(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},a=de(i?.z)*Math.PI/180,o=Math.cos(a),l=Math.sin(a),f=de(n?.x,1),s=de(n?.y,1),c=e.left+e.width*de(r?.x,.5),m=e.bottom+e.height*de(r?.y,.5),h=o*f,p=l*f,v=-l*s,w=o*s;return{a:h,b:p,c:v,d:w,tx:c-h*c-v*m,ty:m-p*c-w*m}}function Ft(e,t,i){return Ba(e||vt(),ki(t,i))}function $n(e,t){let i=We(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 he(e){let t=typeof e=="string"?On(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 Ai(e){return{posX:e.centerX,posY:e.centerY,width:e.width,height:e.height}}function je(e,t,i){let n=Ie(t),r=e.width,a=e.height,o=n.anchorMin.x*r,l=n.anchorMin.y*a,f=n.anchorMax.x*r,s=n.anchorMax.y*a,c=Number(i.width),m=Number(i.height),h=Number(i.posX),p=Number(i.posY),v=h-c/2,w=p-m/2;return n.size={x:c-(f-o),y:m-(s-l)},n.offset={x:v-e.left-o+n.size.x*n.pivot.x,y:w-e.bottom-l+n.size.y*n.pivot.y},n}function Dn(e,t){let i=Ie(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 Gn(e){let t=Ie(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,a=[[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 o of a)if(i(n,o[0])&&i(r,o[1]))return o[2]}return"custom"}function qe(e){return On(e).platform}function zn(e){let t={};for(let i of re)t[i]=e(i);return t}var Ua={scale:["x","y","z"],rotation:["x","y","z"],anchorMin:["x","y"],anchorMax:["x","y"],offset:["x","y"],size:["x","y"],pivot:["x","y"]};function Vn(e,t){for(let[i,n]of Object.entries(Ua))for(let r of n)if(!Number.isFinite(e?.[i]?.[r]))throw new Error(`${t}.${i}.${r} must be a finite number`)}function Fe(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(!re.includes(i))throw new Error(`${t}: unknown platform ${i}`);for(let i of re)Vn(e[i],`${t}.${i}`)}function Je(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`);Fe(e.transformByPlatform,`${e.name||e.id||"\u63A7\u4EF6"}.transformByPlatform`)}function Ze(e,t){if(!re.includes(t))throw new Error(`unknown platform ${t}`);return Vn(e?.[t],`transformByPlatform.${t}`),Ie(e[t])}var Ka=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"}]),Xa=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 Yn(e){return[...Ka,...Xa[e]||[]]}function Bn(e,t){return Yn(e).find(i=>i.key===t)||null}function _i(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 Un(e,t={}){let i={};for(let n of Yn(e)){let r=Object.hasOwn(t||{},n.key)?t[n.key]:n.defaultValue;i[n.key]=_i(n,r)}return i}function we(e){let t=Number(e);return Number.isSafeInteger(t)&&t>0&&t<=2147483647}function Pi(e,t){if(e){t(e);for(let i of e.children||[])Pi(i,t)}}function St(e,t=new Set,{skipServerContainer:i=!1}={}){return Pi(e,n=>{i&&n.kind==="server-container"||we(n.guid)&&t.add(Number(n.guid))}),t}function Oe(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 Kn(e,t=new Set,{skipServerContainer:i=!1}={}){let n=[];Pi(e,r=>{if(i&&r.kind==="server-container")return;let a=Number(r.guid);if(we(a)&&!t.has(a)){t.add(a),r.guid=a;return}n.push(r)});for(let r of n){let a=Oe(t);r.guid=a,t.add(a)}return t}var Ti=1;function Ri(e="n"){let t=`${e}${Ti}`;return Ti+=1,t}function ni(e=1){Ti=e}function Mi(e,{isRootContainer:t=!1}={}){if(e==="server-container"||e==="fullscreen"||e==="container"&&t)return ti({layout:"stretch"});let i=Mn[e]||[80,80];return ti({layout:"center",size:i})}function Ha(e,t){return zn(()=>Mi(e,t))}function La(e){Fe(e);let t={};for(let i of re)t[i]=Ze(e,i);return t}function K(e,t={}){if(!gt[e])throw new Error(`unknown kind: ${e}`);Object.hasOwn(t,"transformByCanvas")&&Je(t);let i=t.isRootContainer===!0,n=t.id||Ri(e==="server-container"?"sc":"n"),r=Object.hasOwn(t,"transformByPlatform")?La(t.transformByPlatform):Ha(e,{isRootContainer:i}),a={id:n,kind:e,name:t.name||gt[e],guid:t.guid??0,giaRelatedGuids:Array.isArray(t.giaRelatedGuids)?t.giaRelatedGuids.filter(o=>Number.isSafeInteger(Number(o))&&Number(o)>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:Un(e,t.giaRaw),transformByPlatform:r,children:[],scriptMappingIds:Array.isArray(t.scriptMappingIds)?t.scriptMappingIds.filter(o=>Number.isSafeInteger(Number(o))&&Number(o)>0).map(Number):[]};if(e==="container"&&(a.isolateNavigation=t.isolateNavigation===!0,a.disableKeyEventPassthrough=t.disableKeyEventPassthrough===!0,a.disableCursorEventPassthrough=t.disableCursorEventPassthrough===!0,a.showCursor=t.showCursor===!0),(e==="textbox"||e==="textwindow")&&(a.fontSize=t.fontSize??20,a.adaptiveFontSize=t.adaptiveFontSize===!0,a.minimumFontSize=t.minimumFontSize??20,a.fontColor=t.fontColor??Mt.font,a.bgColor=t.bgColor??Mt.bg,a.enableOutline=t.enableOutline!==!1,a.outlineColor=t.outlineColor??Mt.outline,a.horizontalAlignment=t.horizontalAlignment||"Left",a.verticalAlignment=t.verticalAlignment||"Top",Number.isInteger(t.giaRaw?.textVerticalAlign)&&![0,1,2].includes(t.giaRaw.textVerticalAlign)&&(a.giaRaw.textVerticalAlign=t.giaRaw.textVerticalAlign),a.text=t.text??"",Object.hasOwn(t.giaRaw||{},"textAlign")||(a.giaRaw.textAlign={Left:0,Middle:1,Right:2}[a.horizontalAlignment]??a.giaRaw.textAlign),e==="textwindow"&&(a.interactable=t.interactable!==!1,a.showScrollBar=t.showScrollBar!==!1)),e==="image"&&(a.imageSource=t.imageSource||"StaticReference",a.imageId=t.imageId??100001,a.imageColor=t.imageColor??Mt.image,a.enableMask=t.enableMask===!0,a.enableSoftEdge=t.enableSoftEdge===!0,a.softEdgeMode=t.softEdgeMode||"Percentage",a.softEdgeWidthX=t.softEdgeWidthX??8,a.softEdgeWidthY=t.softEdgeWidthY??8,a.horizontalSoftRange=t.horizontalSoftRange??85,a.verticalSoftRange=t.verticalSoftRange??85,a.enableFill=t.enableFill===!0,a.fillType=t.fillType||"Horizontal",a.fillHorizontalType=t.fillHorizontalType||"Left",a.fillVerticalType=t.fillVerticalType||"Bottom",a.fillRadial90Type=t.fillRadial90Type||"BottomLeft",a.fillRadialType=t.fillRadialType||"Bottom",a.fillAmount=t.fillAmount??1,a.reverseMaskArea=t.reverseMaskArea===!0||t.reverseMask===!0,Object.hasOwn(t.giaRaw||{},"imageFillType")||(a.giaRaw.imageFillType={Horizontal:1,Vertical:2,Radial90:3,Radial180:4,Radial360:5}[a.fillType]??a.giaRaw.imageFillType)),e==="button"&&(a.raycastTarget=t.raycastTarget!==!1,a.interactable=t.interactable!==!1,a.clickAudioId=t.clickAudioId??Nn,a.unavailableChildId=t.unavailableChildId??null,a.hoverChildId=t.hoverChildId??null,a.pressedChildId=t.pressedChildId??null,a.selectedChildId=t.selectedChildId??null),e==="cursor"&&(a.raycastTarget=t.raycastTarget??t.giaRaw?.cursorField501!==0),e==="reference"&&(a.referencedPrefabId=t.referencedPrefabId??t.giaRaw?.templateRefSlot??null,Object.hasOwn(t.giaRaw||{},"templateRefSlot")||(a.giaRaw.templateRefSlot=String(a.referencedPrefabId??""))),e==="grid"&&(a.itemPrefabId=t.itemPrefabId??null,a.raycastTarget=t.raycastTarget!==!1,a.interactable=t.interactable!==!1,a.showScrollBar=t.showScrollBar!==!1,a.scrollDirection=t.scrollDirection||"Vertical",a.layoutConstraint=t.layoutConstraint||"AutoWrap",a.layoutConstraintFixedCount=t.layoutConstraintFixedCount??null,a.cellSizeX=t.cellSizeX??50,a.cellSizeY=t.cellSizeY??50,a.spacingX=t.spacingX??8,a.spacingY=t.spacingY??8,a.padding1X=t.padding1X??20,a.padding1Y=t.padding1Y??20,a.padding2X=t.padding2X??20,a.padding2Y=t.padding2Y??20,a.previewCount=t.previewCount??t.giaRaw?.gridField511??5,Object.hasOwn(t.giaRaw||{},"gridField511")||(a.giaRaw.gridField511=Math.trunc(a.previewCount))),e==="keyhint"&&(a.keyboardKeyCode=t.keyboardKeyCode??t.giaRaw?.keyHintField502??null,a.controllerKeyCode=t.controllerKeyCode??t.giaRaw?.keyHintField501??null,Object.hasOwn(t.giaRaw||{},"keyHintField502")||(a.giaRaw.keyHintField502=Math.trunc(a.keyboardKeyCode??1)),Object.hasOwn(t.giaRaw||{},"keyHintField501")||(a.giaRaw.keyHintField501=Math.trunc(a.controllerKeyCode??1))),e==="animation"||e==="fullscreen"){let o=e==="animation"?t.giaRaw?.effectSlot:t.giaRaw?.fullscreenEffectSlot;a.animationId=t.animationId??o??null,a.playSoundEffect=t.playSoundEffect??null,e==="animation"&&(a.layer=t.layer??null);let l=e==="animation"?"effectSlot":"fullscreenEffectSlot";Object.hasOwn(t.giaRaw||{},l)||(a.giaRaw[l]=String(a.animationId??""))}if(t.children)for(let o of t.children)a.children.push(o);return a}function De(){ni(1);let e=K("server-container",{id:"sc1",name:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u5BB9\u5668"}),t=K("container",{id:"n1",name:"\u5BB9\u5668\u8282\u70B9",isRootContainer:!0}),i=K("textbox",{id:"n2",name:"\u6587\u672C\u6846",text:"\u6587\u672C"}),n=K("cursor",{id:"n3",name:"\u5149\u6807\u68C0\u6D4B\u533A\u57DF"}),r=K("reference",{id:"n4",name:"\u6A21\u677F\u5F15\u7528\u63A7\u4EF6"}),a=K("grid",{id:"n5",name:"\u7F51\u683C\u89C6\u7A97"}),o=K("button",{id:"n6",name:"\u9884\u8BBE\u6309\u94AE"}),l=K("textwindow",{id:"n7",name:"\u6587\u672C\u89C6\u7A97"}),f=K("keyhint",{id:"n8",name:"\u6309\u952E\u63D0\u793A"}),s=K("image",{id:"n9",name:"\u56FE\u7247",imageId:100005}),c=K("animation",{id:"n10",name:"\u754C\u9762\u52A8\u6548"}),m=K("fullscreen",{id:"n11",name:"\u5168\u5C4F\u52A8\u6548"}),h=(p,v,w)=>{for(let x of Object.values(p.transformByPlatform))x.offset={x:v,y:w}};return h(i,-300,250),h(n,-300,140),h(r,-300,30),h(a,-300,-100),h(o,0,0),h(l,300,250),h(f,300,140),h(s,300,30),h(c,300,-100),t.children.push(i,n,r,a,o,l,f,s,c,m),e.children.push(t),ni(12),Kn(e),{version:1,layoutSchemaVersion:fe,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 Qe(){ni(1);let e=K("server-container",{id:"sc1",name:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F"}),t=K("container",{id:"n1",guid:1073742100,name:"Lua\u5B9E\u4F8B\u5316\u9762\u677F"}),i=K("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=K("image",{id:"n3",guid:1073742102,name:"\u6A21\u677F\u56FE\u6807",imageId:100005}),r=K("button",{id:"n4",guid:1073742103,name:"\u786E\u8BA4\u6309\u94AE"}),a=K("textbox",{id:"n5",guid:1073742104,name:"\u6309\u94AE\u6587\u5B57",text:"\u786E\u8BA4",horizontalAlignment:"Middle",verticalAlignment:"Top"}),o=(f,s,c)=>{for(let m of Object.values(f.transformByPlatform))m.offset={x:s,y:c}};return((f,s,c)=>{for(let m of Object.values(f.transformByPlatform))m.size={x:s,y:c}})(t,520,320),o(i,0,110),o(n,0,0),o(r,0,-110),r.children.push(a),t.children.push(i,n,r),e.children.push(t),ni(6),{version:1,layoutSchemaVersion:fe,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 q(e,t,i=null){t(e,i);for(let n of e.children||[])q(n,t,e)}function ue(e,t){let i=null;return q(e,n=>{n.id===t&&(i=n)}),i}function Ni(e,t="n"){let i=Ri(t);for(;ue(e,i);)i=Ri(t);return i}function $e(e,t){let i=null;return q(e,(n,r)=>{n.id===t&&(i=r)}),i}function Fi(e){let t=e.root||e;return t.kind==="container"?t:(t.children||[]).find(i=>i.kind==="container")||(t.children||[])[0]||t}function Ot(e){if(e.meta?.assetType!=="client-control-template")return Fi(e);let t=ue(e.root,e.selectedId);if(!t||t.kind==="server-container")return e.root.children?.[0]||e.root;let i=$e(e.root,t.id);for(;i&&i.kind!=="server-container";)t=i,i=$e(e.root,t.id);return t}function Oi(e){Je(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"&&Wa(e.transformByPlatform);let i=K(e.kind,t);return i.children=(e.children||[]).map(n=>Oi(n)),i}function Wa(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 Xn(e,t,i={}){if(e.kind==="server-container"&&t!=="container")throw new Error("server container only accepts container nodes");let n=K(t,i);return e.children.push(n),n}function Hn(e,t){if(e.id===t)throw new Error("cannot remove root");let i=$e(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 Ln=1e-4;function ja(e,t){return Math.abs(e.anchorMax[t]-e.anchorMin[t])>Ln&&Math.abs(e.size[t])<=Ln}function qa(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=Ae(t,e),r=(n.centerX-t.left)/t.width,a=(n.centerY-t.bottom)/t.height,o=je(i,e,{posX:i.left+r*i.width,posY:i.bottom+a*i.height,width:n.width,height:n.height});for(let l of["x","y"])ja(e,l)&&(o.offset[l]=e.offset[l],o.size[l]=e.size[l]);return o}function Wn({transformByPlatform:e,source:t,canvasId:i,syncAllDevices:n,sourceParentBox:r=he(i),targetParentBoxByPlatform:a={}}){Fe(e);let o=qe(i),l={};for(let f of re)f===o?l[f]=Ie(t):n!==!1?l[f]=qa(t,r,a[f]||he(pt[f])):l[f]=Ze(e,f);return Fe(l),l}function Ge(e,t){return Ze(e,qe(t))}function jn(e,t){let i=[];function n(r){t[r.id]&&i.push(t[r.id]);let a=r.children||[];for(let o=a.length-1;o>=0;o-=1)n(a[o])}return n(e),i}function ze(e,t,i=qe(t)){let n=he(t),r={};function a(o,l,f){let s=Ze(o.transformByPlatform,i),c=Ae(l,s),m=o.kind==="server-container"?f:Ft(f,c,s),h=$n(c,m);r[o.id]={...c,...Ai(c),id:o.id,kind:o.kind,name:o.name,visible:o.visible!==!1,active:o.active!==!1,rotationZ:s.rotation.z,renderLeft:h.left,renderBottom:h.bottom,renderWidth:h.width,renderHeight:h.height,renderRotationZ:h.rotationZ,renderMatrix:m,primitive:o.kind==="image"?yt[o.imageId]||"missing":null,...o.kind==="textbox"||o.kind==="textwindow"?{text:o.text??"",fontSize:o.fontSize,fontColor:o.fontColor,bgColor:o.bgColor,enableOutline:o.enableOutline!==!1,outlineColor:o.outlineColor,horizontalAlignment:o.horizontalAlignment,verticalAlignment:o.verticalAlignment}:{},...o.kind==="image"?{imageSource:o.imageSource,imageId:o.imageId,imageColor:o.imageColor,enableMask:o.enableMask===!0,enableSoftEdge:o.enableSoftEdge===!0,softEdgeMode:o.softEdgeMode,softEdgeWidthX:o.softEdgeWidthX,softEdgeWidthY:o.softEdgeWidthY,horizontalSoftRange:o.horizontalSoftRange,verticalSoftRange:o.verticalSoftRange,enableFill:o.enableFill===!0,fillType:o.fillType,fillHorizontalType:o.fillHorizontalType,fillVerticalType:o.fillVerticalType,fillRadial90Type:o.fillRadial90Type,fillRadialType:o.fillRadialType,fillAmount:o.fillAmount,reverseMaskArea:o.reverseMaskArea===!0}:{},...o.kind==="button"?{raycastTarget:o.raycastTarget!==!1,interactable:o.interactable!==!1,clickAudioId:o.clickAudioId,unavailableChildId:o.unavailableChildId??null,hoverChildId:o.hoverChildId??null,pressedChildId:o.pressedChildId??null,selectedChildId:o.selectedChildId??null}:{}};let p=o.kind==="server-container"?l:c;for(let v of o.children||[])a(v,p,m)}return a(e,n,vt()),{canvas:n,boxes:r}}function $i(e,t){let i=[];function n(r,a,o=null,l=[],f=0,s=1,c=e.id){i.push({id:r.id,guid:t?.get(r.id)??(r.guid||0),kind:r.kind,name:r.name,label:gt[r.kind]||r.kind,depth:a,parentId:o,ancestorIds:l,siblingIndex:f,siblingCount:s,templateId:c,childCount:(r.children||[]).length,incomplete:!ei.includes(r.kind)});let m=r.children||[];for(let h=0;h<m.length;h+=1)n(m[h],a+1,r.id,[...l,r.id],h,m.length,c)}return n(e,0),i}function A(e,t,i,n,r={}){return{key:e,label:t,type:i,value:n,...r}}function qn(e,t,i,n){if(!e)return null;let r=Ge(e.transformByPlatform,t),a=Ai(i),o=[A("name","\u540D\u79F0","string",e.name),A("active","\u521D\u59CB\u6FC0\u6D3B","bool",e.active!==!1),A("visible","\u521D\u59CB\u53EF\u89C1\u6027","bool",e.visible!==!1),A("canControllerFocus","\u53EF\u88AB\u624B\u67C4\u6447\u6746\u5BFC\u822A\u9009\u4E2D","bool",e.canControllerFocus===!0),A("posX","\u4F4D\u7F6E X","number",a.posX,{computed:!0}),A("posY","\u4F4D\u7F6E Y","number",a.posY,{computed:!0}),A("width","\u5927\u5C0F W","number",a.width,{computed:!0}),A("height","\u5927\u5C0F H","number",a.height,{computed:!0}),A("rotationZ","\u65CB\u8F6C Z","number",r.rotation.z),A("syncAllDevices","\u540C\u6B65\u4FE1\u606F\u81F3\u6240\u6709\u8BBE\u5907","bool",e.syncAllDevices!==!1),A("anchorType","\u951A\u70B9\u7C7B\u578B","enum",Gn(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"}]}),A("anchorMinX","\u951A\u70B9 Min X","number",r.anchorMin.x),A("anchorMinY","\u951A\u70B9 Min Y","number",r.anchorMin.y),A("anchorMaxX","\u951A\u70B9 Max X","number",r.anchorMax.x),A("anchorMaxY","\u951A\u70B9 Max Y","number",r.anchorMax.y),A("pivotX","\u4E2D\u5FC3 X","number",r.pivot.x),A("pivotY","\u4E2D\u5FC3 Y","number",r.pivot.y)];if(e.kind==="container"&&o.push(A("isolateNavigation","\u9694\u79BB\u624B\u67C4\u5BFC\u822A","bool",e.isolateNavigation===!0),A("disableKeyEventPassthrough","\u5C4F\u853D\u6309\u952E\u4E8B\u4EF6\u7A7F\u900F","bool",e.disableKeyEventPassthrough===!0),A("disableCursorEventPassthrough","\u5C4F\u853D\u533A\u57DF\u5185\u70B9\u51FB\u4E8B\u4EF6\u7A7F\u900F","bool",e.disableCursorEventPassthrough===!0),A("showCursor","\u663E\u793A\u5E38\u9A7B\u5149\u6807","bool",e.showCursor===!0)),e.kind==="textbox"||e.kind==="textwindow"){let l=e.giaRaw?.textAlign,f=[0,1,2].includes(l)?e.horizontalAlignment||"Left":`__unrecognized:${l}`;o.push(A("fontSize","\u5B57\u53F7","number",e.fontSize),A("adaptiveFontSize","\u5B57\u53F7\u81EA\u9002\u5E94","bool",e.adaptiveFontSize===!0),A("minimumFontSize","\u6700\u5C0F\u5B57\u53F7","number",e.minimumFontSize),A("fontColor","\u6587\u672C\u8272","color",e.fontColor),A("bgColor","\u80CC\u666F\u8272","color",e.bgColor),A("enableOutline","\u542F\u7528\u63CF\u8FB9","bool",e.enableOutline!==!1),A("outlineColor","\u63CF\u8FB9\u8272","color",e.outlineColor),A("horizontalAlignment","\u6C34\u5E73\u5BF9\u9F50","enum",f,{...[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"}]}),A("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"}]}),A("text","\u6587\u672C","text",e.text??""))}if(e.kind==="image"){let l=e.giaRaw?.imageFillType,f=[1,2,3,4,5].includes(l)?e.fillType:`__unrecognized:${l}`;o.push(A("imageSource","\u56FE\u7247\u6E90","enum",e.imageSource,{readonly:!0,evidence:"W",options:[{value:"StaticReference",label:"\u9759\u6001\u5F15\u7528"}]}),A("imageId","imageId","number",e.imageId??0),A("imageColor","\u586B\u5145\u8272","color",e.imageColor),A("enableMask","\u5F00\u542F\u906E\u7F69","bool",e.enableMask===!0),A("enableSoftEdge","\u8FB9\u7F18\u7FBD\u5316","bool",e.enableSoftEdge===!0,{gia:"W"}),A("softEdgeMode","\u7FBD\u5316\u6A21\u5F0F","enum",e.softEdgeMode,{options:[{value:"Percentage",label:"\u767E\u5206\u6BD4"},{value:"Pixel",label:"\u50CF\u7D20"}]}),A("softEdgeWidthX","\u7FBD\u5316\u5BBD\u5EA6 X","number",e.softEdgeWidthX),A("softEdgeWidthY","\u7FBD\u5316\u5BBD\u5EA6 Y","number",e.softEdgeWidthY),A("horizontalSoftRange","\u6C34\u5E73\u7FBD\u5316\u8303\u56F4","number",e.horizontalSoftRange),A("verticalSoftRange","\u5782\u76F4\u7FBD\u5316\u8303\u56F4","number",e.verticalSoftRange),A("enableFill","\u6309\u8FDB\u5EA6\u586B\u5145","bool",e.enableFill===!0,{gia:"W"}),A("fillType","\u5F62\u72B6","enum",f,{...[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"}]}),A("fillHorizontalType","\u65B9\u5411","enum",e.fillHorizontalType,{options:[{value:"Left",label:"\u4ECE\u5DE6\u81F3\u53F3"},{value:"Right",label:"\u4ECE\u53F3\u81F3\u5DE6"}]}),A("fillVerticalType","\u65B9\u5411","enum",e.fillVerticalType,{options:[{value:"Bottom",label:"\u4ECE\u4E0B\u81F3\u4E0A"},{value:"Top",label:"\u4ECE\u4E0A\u81F3\u4E0B"}]}),A("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"}]}),A("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"}]}),A("fillAmount","\u8FDB\u5EA6","percent",e.fillAmount),A("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(f=>({value:f.id,label:`${f.name} \xB7 ${f.id}`}))];o.push(A("raycastTarget","\u53EF\u88AB\u5149\u6807\u5C04\u7EBF\u68C0\u6D4B","bool",e.raycastTarget!==!1),A("interactable","\u6309\u94AE\u662F\u5426\u53EF\u7528","bool",e.interactable!==!1),A("unavailableChildId","\u4E0D\u53EF\u7528\u72B6\u6001\u8282\u70B9","node",e.unavailableChildId,{options:l,gia:"W"}),A("hoverChildId","\u60AC\u505C\u72B6\u6001\u8282\u70B9","node",e.hoverChildId,{options:l,gia:"W"}),A("pressedChildId","\u6309\u4E0B\u72B6\u6001\u8282\u70B9","node",e.pressedChildId,{options:l,gia:"W"}),A("selectedChildId","\u9009\u4E2D\u72B6\u6001\u8282\u70B9","node",e.selectedChildId,{options:l,gia:"W"}),A("clickAudioId","\u70B9\u51FB\u97F3\u6548","number",e.clickAudioId))}return e.kind==="reference"&&o.push(A("referencedPrefabId","\u5F15\u7528\u63A7\u4EF6\u6A21\u677F\u7D22\u5F15","string",e.referencedPrefabId??"")),e.kind==="grid"&&o.push(A("cellSizeX","\u5217\u8868\u9879\u5927\u5C0F W","number",e.cellSizeX,{evidence:"W"}),A("cellSizeY","\u5217\u8868\u9879\u5927\u5C0F H","number",e.cellSizeY,{evidence:"W"}),A("spacingX","\u5217\u8868\u9879\u95F4\u9694 X","number",e.spacingX,{evidence:"W"}),A("spacingY","\u5217\u8868\u9879\u95F4\u9694 Y","number",e.spacingY,{evidence:"W"}),A("padding1X","\u8FB9\u8DDD\u5411\u91CF 1 X","number",e.padding1X,{evidence:"W"}),A("padding1Y","\u8FB9\u8DDD\u5411\u91CF 1 Y","number",e.padding1Y,{evidence:"W"}),A("padding2X","\u8FB9\u8DDD\u5411\u91CF 2 X","number",e.padding2X,{evidence:"W"}),A("padding2Y","\u8FB9\u8DDD\u5411\u91CF 2 Y","number",e.padding2Y,{evidence:"W"}),A("previewCount","\u9884\u89C8\u6570\u91CF","number",e.previewCount)),e.kind==="keyhint"&&o.push(A("keyboardKeyCode","\u952E\u9F20\u6309\u952E","number",e.keyboardKeyCode??e.giaRaw?.keyHintField502??1,{gia:"W"}),A("controllerKeyCode","\u624B\u67C4\u6309\u952E","number",e.controllerKeyCode??e.giaRaw?.keyHintField501??1)),(e.kind==="animation"||e.kind==="fullscreen")&&o.push(A("animationId",e.kind==="animation"?"\u52A8\u6548\u7D22\u5F15":"\u5168\u5C4F\u52A8\u6548\u7D22\u5F15","string",e.animationId??"")),ei.includes(e.kind)||o.push(A("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:gt[e.kind]||e.kind,incomplete:!ei.includes(e.kind),fields:o}}function Jn(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 a=n[r];if(!a.visible||!a.active)continue;let o=a.renderMatrix&&ii(a.renderMatrix),l=o&&We(o,t,i);if(l&&l.x>=a.left&&l.x<=a.right&&l.y>=a.bottom&&l.y<=a.top)return a.id}return null}import Ja from"protobufjs";var Za=String.raw`
1
+ import{parentPort as Fn}from"node:worker_threads";import{existsSync as qt,readFileSync as Kl}from"node:fs";import{randomUUID as Xl}from"node:crypto";import{isAbsolute as Yn,win32 as Bn}from"node:path";function Vn(e,t=!1){let i=String(e??"").trim().replaceAll("\\","/");if(t&&(!i||i==="."))return"";if(!i||Yn(i)||Bn.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(!Yn(t)&&!Bn.isAbsolute(t))throw new Error("\u5B9E\u673A\u5BFC\u5165\u6839\u76EE\u5F55\u5FC5\u987B\u662F\u7EDD\u5BF9\u8DEF\u5F84");return{version:1,workspaceDir:Vn(e.workspaceDir,!0),clientImportRoot:t,clientSubdir:Vn(e.clientSubdir,!0)}}import{basename as Et,dirname as Hl,isAbsolute as Ll,join as To,resolve as Ro}from"node:path";var le=Object.freeze(["KEYBOARD","TOUCHSCREEN","CONTROLLER_CONSOLE","CONTROLLER_MOBILE"]),te=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"}}),ti="pc-16-9",me=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"}),ii=Object.freeze(["server-container","container","textbox","cursor","reference","grid","image","button","textwindow","keyhint","animation","fullscreen"]),Un=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"}),Kn=50888,Mt=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 Xn(e,t="$"){yt(e,t)}function Hn(e){return te[e]||te[ti]}function Nt(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 Qo(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 ea(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 ni({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 Pe(e){let t=e||ni();return{scale:Qo(t.scale),rotation:ea(t.rotation),anchorMin:Nt(t.anchorMin??t.anchor_min,.5,.5),anchorMax:Nt(t.anchorMax??t.anchor_max,.5,.5),offset:Nt(t.offset,0,0),size:Nt(t.size,0,0),pivot:Nt(t.pivot,.5,.5)}}function pe(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=pe(a?.x,.5)*i,h=pe(a?.y,.5)*n,g=pe(l?.x,.5)*i,v=pe(l?.y,.5)*n,w=pe(s?.x),N=pe(s?.y),E=pe(f?.x,.5),k=pe(f?.y,.5),B=g-m+w,$=v-h+N,q=r+m+pe(c?.x)-w*E,Q=o+h+pe(c?.y)-N*k;return{left:q,bottom:Q,width:B,height:$,right:q+B,top:Q+$,centerX:q+B/2,centerY:Q+$/2}}function bt(){return{a:1,b:0,c:0,d:1,tx:0,ty:0}}function ta(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 ri(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 Ti(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=pe(i?.z)*Math.PI/180,a=Math.cos(o),l=Math.sin(o),c=pe(n?.x,1),s=pe(n?.y,1),f=e.left+e.width*pe(r?.x,.5),m=e.bottom+e.height*pe(r?.y,.5),h=a*c,g=l*c,v=-l*s,w=a*s;return{a:h,b:g,c:v,d:w,tx:f-h*f-v*m,ty:m-g*f-w*m}}function Ft(e,t,i){return ta(e||bt(),Ti(t,i))}function Ln(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 ge(e){let t=typeof e=="string"?Hn(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 Ri(e){return{posX:e.centerX,posY:e.centerY,width:e.width,height:e.height}}function Ze(e,t,i){let n=Pe(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),v=h-f/2,w=g-m/2;return n.size={x:f-(c-a),y:m-(s-l)},n.offset={x:v-e.left-a+n.size.x*n.pivot.x,y:w-e.bottom-l+n.size.y*n.pivot.y},n}function Wn(e,t){let i=Pe(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 jn(e){let t=Pe(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 Hn(e).platform}function qn(e){let t={};for(let i of le)t[i]=e(i);return t}var ia={scale:["x","y","z"],rotation:["x","y","z"],anchorMin:["x","y"],anchorMax:["x","y"],offset:["x","y"],size:["x","y"],pivot:["x","y"]};function Jn(e,t){for(let[i,n]of Object.entries(ia))for(let r of n)if(!Number.isFinite(e?.[i]?.[r]))throw new Error(`${t}.${i}.${r} must be a finite number`)}function Ge(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(!le.includes(i))throw new Error(`${t}: unknown platform ${i}`);for(let i of le)Jn(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`);Ge(e.transformByPlatform,`${e.name||e.id||"\u63A7\u4EF6"}.transformByPlatform`)}function tt(e,t){if(!le.includes(t))throw new Error(`unknown platform ${t}`);return Jn(e?.[t],`transformByPlatform.${t}`),Pe(e[t])}var na=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"}]),ra=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 Zn(e){return[...na,...ra[e]||[]]}function Qn(e,t){return Zn(e).find(i=>i.key===t)||null}function Mi(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 er(e,t={}){let i={};for(let n of Zn(e)){let r=Object.hasOwn(t||{},n.key)?t[n.key]:n.defaultValue;i[n.key]=Mi(n,r)}return i}function we(e){let t=Number(e);return Number.isSafeInteger(t)&&t>0&&t<=2147483647}function Ni(e,t){if(e){t(e);for(let i of e.children||[])Ni(i,t)}}function vt(e,t=new Set,{skipServerContainer:i=!1}={}){return Ni(e,n=>{i&&n.kind==="server-container"||we(n.guid)&&t.add(Number(n.guid))}),t}function De(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 tr(e,t=new Set,{skipServerContainer:i=!1}={}){let n=[];Ni(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=De(t);r.guid=o,t.add(o)}return t}var Fi=1;function Oi(e="n"){let t=`${e}${Fi}`;return Fi+=1,t}function oi(e=1){Fi=e}function $i(e,{isRootContainer:t=!1}={}){if(e==="server-container"||e==="fullscreen"||e==="container"&&t)return ni({layout:"stretch"});let i=Un[e]||[80,80];return ni({layout:"center",size:i})}function oa(e,t){return qn(()=>$i(e,t))}function aa(e){Ge(e);let t={};for(let i of le)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||Oi(e==="server-container"?"sc":"n"),r=Object.hasOwn(t,"transformByPlatform")?aa(t.transformByPlatform):oa(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:er(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??Mt.font,o.bgColor=t.bgColor??Mt.bg,o.enableOutline=t.enableOutline!==!1,o.outlineColor=t.outlineColor??Mt.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??Mt.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??Kn,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(){oi(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,v,w)=>{for(let N of Object.values(g.transformByPlatform))N.offset={x:v,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),oi(12),tr(e),{version:1,layoutSchemaVersion:me,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(){oi(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),oi(6),{version:1,layoutSchemaVersion:me,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 W(e,t,i=null){t(e,i);for(let n of e.children||[])W(n,t,e)}function ce(e,t){let i=null;return W(e,n=>{n.id===t&&(i=n)}),i}function Gi(e,t="n"){let i=Oi(t);for(;ce(e,i);)i=Oi(t);return i}function ze(e,t){let i=null;return W(e,(n,r)=>{n.id===t&&(i=r)}),i}function Di(e){let t=e.root||e;return t.kind==="container"?t:(t.children||[]).find(i=>i.kind==="container")||(t.children||[])[0]||t}function Ot(e){if(e.meta?.assetType!=="client-control-template")return Di(e);let t=ce(e.root,e.selectedId);if(!t||t.kind==="server-container")return e.root.children?.[0]||e.root;let i=ze(e.root,t.id);for(;i&&i.kind!=="server-container";)t=i,i=ze(e.root,t.id);return t}function zi(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"&&la(e.transformByPlatform);let i=H(e.kind,t);return i.children=(e.children||[]).map(n=>zi(n)),i}function la(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 ir(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 nr(e,t){if(e.id===t)throw new Error("cannot remove root");let i=ze(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 rr=1e-4;function sa(e,t){return Math.abs(e.anchorMax[t]-e.anchorMin[t])>rr&&Math.abs(e.size[t])<=rr}function ua(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"])sa(e,l)&&(a.offset[l]=e.offset[l],a.size[l]=e.size[l]);return a}function or({transformByPlatform:e,source:t,canvasId:i,syncAllDevices:n,sourceParentBox:r=ge(i),targetParentBoxByPlatform:o={}}){Ge(e);let a=Qe(i),l={};for(let c of le)c===a?l[c]=Pe(t):n!==!1?l[c]=ua(t,r,o[c]||ge(mt[c])):l[c]=tt(e,c);return Ge(l),l}function Ve(e,t){return tt(e,Qe(t))}function ar(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 Ye(e,t,i=Qe(t)){let n=ge(t),r={};function o(a,l,c){let s=tt(a.transformByPlatform,i),f=Ne(l,s),m=a.kind==="server-container"?c:Ft(c,f,s),h=Ln(f,m);r[a.id]={...f,...Ri(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 v of a.children||[])o(v,g,m)}return o(e,n,bt()),{canvas:n,boxes:r}}function Vi(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:!ii.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 _(e,t,i,n,r={}){return{key:e,label:t,type:i,value:n,...r}}function lr(e,t,i,n){if(!e)return null;let r=Ve(e.transformByPlatform,t),o=Ri(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",jn(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==="grid"&&a.push(_("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??"")),ii.includes(e.kind)||a.push(_("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:!ii.includes(e.kind),fields:a}}function sr(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&&ri(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 ca from"protobufjs";var fa=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,10 @@ message ImageConfig {
99
99
  message SliceVector { float field501 = 501; float field502 = 502; }
100
100
  }
101
101
  message FooterSlot { int32 field505 = 505; }
102
- `,{root:Qa}=Ja.parse(Za,{keepCase:!1}),Se=Qa.lookupType("Root"),Ve=20,Di=4,Qn=806,er=1657,$t={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},tr={"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},ir={KEYBOARD:0,TOUCHSCREEN:1,CONTROLLER_CONSOLE:2,CONTROLLER_MOBILE:3},eo="server-control-template",ai="client-control-template";function ri(e,t){let i=Number(e);return Number.isFinite(i)?i:t}var to=Object.fromEntries(Object.entries(ir).map(([e,t])=>[t,e])),nr=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"]]}),rr=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}),io=Object.freeze([["2/15","name",null],["4/23","field14","field14"],["1/12","transform","transform"],["62/82","empty72","rootChildRef"]]);function Gi(e){return{class:1,type:8,id:e}}function Dt(e,t,i,n){return{...n,field501:t,field502:i,field503:1,nodeRef:Gi(e)}}function no(e){let t=[],i=e.meta?.assetType==="client-control-template";return q(e.root,n=>{i&&n.kind==="server-container"||t.push(n)}),t}function Gt(e,t=new Set){let i=new Map,n=[];for(let r of no(e)){let a=Number(r.guid);we(a)&&!t.has(a)?(t.add(a),r.guid=a,i.set(r.id,a)):n.push(r)}for(let r of n){let a=Oe(t);t.add(a),r.guid=a,i.set(r.id,a)}return i}function ro(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 ao(e,t){let n={multiPlatform:{platforms:re.map(r=>({platformType:ir[r],transform:ro(e.transformByPlatform[r])})),field502:$t[e.kind]||25,...e.syncAllDevices===!1?{}:{field504:1}},type:2};return{transform:{multiPlatform:{},type:2},field501:1,field502:12,details:Dt(t,4,12,{transform:n})}}function oo(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:Dt(t,5,i?23:86,{field14:r})},ao(e,t)]}function lo(e,t,i,n){let r=(s,c,m,h,p)=>({[m]:"",field501:s,field502:c,details:Dt(t,s+2,c,{[h]:p})}),a=e.giaRaw||{},o=Array.isArray(e.scriptMappingIds)&&e.scriptMappingIds.length?{field501:a.genericField501||1,field502:e.scriptMappingIds.map(s=>({field1:{id:Number(s)}}))}:{field501:a.genericField501??0},l=r(63,83,"empty73","genericSlot",o),f=r(67,90,"empty77","footerSlot",{field505:[void 0,0,1].includes(a.footerField505)?e.canControllerFocus?1:0:a.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}:{}}),f];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,c=Number.isFinite(a.textAlign)?Math.trunc(a.textAlign):s,m={field501:a.textField501??20,field503:a.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}:{},...c?{align:c}:{},verticalAlign:a.textVerticalAlign??{Top:0,Middle:1,Bottom:2}[e.verticalAlignment]??0};return e.kind==="textwindow"?(m.field511=a.textField511??1,m.viewFlags={field502:a.textViewField502??1,field503:a.textViewField503??1},[l,{empty81:"",field501:71,field502:94,details:Dt(t,66,94,{textConfig:m})},f]):[l,r(64,84,"empty74","textConfig",m),f]}if(e.kind==="image"){let s={Horizontal:1,Vertical:2,Radial90:3,Radial180:4,Radial360:5}[e.fillType],c=Number.isFinite(a.imageFillType)?Math.trunc(a.imageFillType):s||1;e.enableFill&&!c&&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:a.imageField502??1,field504:a.imageField504??1,field505:a.imageField505??1,field507:a.imageField507??2,field508:Math.round(Math.max(0,Math.min(1,Number(e.fillAmount)||0))*100),border:{field501:ri(e.softEdgeWidthX,8),field502:ri(e.softEdgeWidthY,8)},field512:ri(e.horizontalSoftRange,85),field513:ri(e.verticalSoftRange,85),fillType:c,...e.enableMask?{enableMask:1}:{},...e.enableSoftEdge?{enableSoftEdge:1}:{},...e.softEdgeMode==="Pixel"?{softEdgePixel:1}:{},...e.enableFill&&c?{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),f]}if(e.kind==="button"){let s=(v,w)=>{let x=e[v];return x?(e.children||[]).some(k=>k.id===x)?i.get(x)||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},c=s("unavailableChildId","\u4E0D\u53EF\u7528"),m=s("hoverChildId","\u60AC\u505C"),h=s("pressedChildId","\u6309\u4E0B"),p=s("selectedChildId","\u9009\u4E2D");return[l,r(70,93,"empty80","buttonPreset",{clickAudioId:Math.trunc(e.clickAudioId),...c?{disabledChild:c}:{},...m?{hoverChild:m}:{},...h?{pressedChild:h}:{},...p?{selectedChild:p}:{},...e.interactable?{interactable:1}:{},...e.raycastTarget?{raycastTarget:1}:{}}),f]}return e.kind==="cursor"?[l,r(65,85,"empty75","cursorConfig",{field501:[void 0,0,1].includes(a.cursorField501)?e.raycastTarget!==!1?1:0:a.cursorField501}),f]:e.kind==="reference"?[l,r(66,89,"empty76","templateRefSlot",a.templateRefSlot??""),f]:e.kind==="grid"?[l,r(69,92,"empty79","gridView",{field501:a.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:a.gridField507??1,field508:a.gridField508??1,field509:a.gridField509??1,field511:a.gridField511??5,field512:a.gridField512??1}),f]:e.kind==="keyhint"?[l,r(72,95,"empty82","keyHint",{field501:Number.isFinite(a.keyHintField501)?Math.trunc(a.keyHintField501):e.controllerKeyCode??1,field502:Number.isFinite(a.keyHintField502)?Math.trunc(a.keyHintField502):e.keyboardKeyCode??1}),f]:e.kind==="animation"?[l,r(75,98,"empty85","effectSlot",a.effectSlot??""),f]:e.kind==="fullscreen"?[l,r(76,99,"empty86","fullscreenEffectSlot",a.fullscreenEffectSlot??""),f]:(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,f])}function so(e,t){return t?1:Number.isSafeInteger(Number(e.giaInfoIndex))&&Number(e.giaInfoIndex)>0?Number(e.giaInfoIndex):tr[e.kind]||2}function uo(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 zi(e,t){let i=String(e.meta?.giaFilePath||"").trim();if(/^\d+-\d+-\d+-\\.+\.gia$/iu.test(i))return i;let n=(s,c)=>Number.isSafeInteger(Number(s))&&Number(s)>0?Number(s):c,r=n(e.meta?.giaOwnerUid,114514),a=n(e.meta?.giaTimestamp,Math.floor(Date.now()/1e3)),o=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",f=String(e.meta?.giaFileName||l).replace(/[\\/:*?"<>|]/gu,"-").replace(/\.gia$/iu,"").trim()||l.replace(/\.gia$/iu,"");return`${r}-${a}-${o}-\\${f}.gia`}function oi(e,t,i,n,r,a=!1,o=!1,l=o,f=!1){let s=i.get(e.id),m=(f?[...e.children||[]].reverse():e.children||[]).map(v=>i.get(v.id)),h=a?n:m,p=oo(e,s,a);if(a){let v=e.children?.[0];v&&p.push({empty72:"",field501:62,field502:82,details:Dt(s,64,82,{rootChildRef:{guid:i.get(v.id)}})})}else p.push(...lo(e,s,i,r));return{id:Gi(s),relatedIds:h.map(v=>Gi(v)),name:e.name,which:a?21:o?70:15,ui:{content:{guid:s,info:[{guid:{value:s},field501:1,field502:5},...a||l?[{index:{value:so(e,a)},field501:2,field502:6}]:[],...a||o?[{related:{value:uo(e,r,a?"\u670D\u52A1\u7AEF\u63A7\u4EF6\u6A21\u677F":"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F")},field501:4,field502:4}]:[]],children:a?[]:m,parent:t&&t.kind!=="server-container"?i.get(t.id):0,data:p}}}}function ar(e){let t=[];return q(e.root,(i,n)=>{i.kind!=="server-container"&&t.push({node:i,parent:n})}),t}function co(e,t){let i=new Map;for(let n of e||[]){if(!n.controlId||!(t===ai?n.controlAsset===ai:n.controlAsset!==ai))continue;let a=i.get(n.controlId)||[];a.push(n.guid),i.set(n.controlId,a)}return i}function or(e,t,i,n){let r=co(t,i),a=new Map;q(e.root,o=>{r.has(o.id)&&(a.set(o,o.scriptMappingIds),o.scriptMappingIds=r.get(o.id))});try{return n()}finally{for(let[o,l]of a)l===void 0?delete o.scriptMappingIds:o.scriptMappingIds=l}}function Vi(e){let t=Number(e.meta?.giaModeFlag);return Number.isSafeInteger(t)&&t>=0?{modeFlag:t}:{}}function lr(e,t,i,n,r=[]){let a=ar(e),o=a.filter(({parent:c})=>c?.kind==="server-container");if(!o.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(o.map(({node:c})=>c.id)),f=a.filter(({node:c})=>!l.has(c.id)),s=a.map(({node:c})=>t.get(c.id));return or(e,r,ai,()=>({graph:o.map(({node:c,parent:m})=>oi(c,m,t,s,i,!1,!0)),accessories:f.map(({node:c,parent:m})=>oi(c,m,t,s,i,!1,!1,!0)),filePath:n||zi(e,!0),gameVersion:e.meta?.gameVersion||"7.0.50",...Vi(e)}))}function sr(e,t,i,n,r){let a=ar(e),o=[a[0],...a.slice(1).reverse()],l=o.map(({node:f})=>t.get(f.id));return or(e,i.scripts,eo,()=>({graph:[oi(e.root,null,t,l,n,!0,!1,!1,!0),...i.units||[]],accessories:o.map(({node:f,parent:s})=>oi(f,s,t,l,n,!1,!1,!1,!0)),filePath:r||zi(e,!1),gameVersion:e.meta?.gameVersion||"7.0.50",...Vi(e)}))}function ur(e,t){let i=mr(e),n=t(i);if(!n.valid)throw new Error(`GIA compatibility validation failed:
102
+ `,{root:da}=ca.parse(fa,{keepCase:!1}),xe=da.lookupType("Root"),Be=20,Yi=4,cr=806,fr=1657,$t={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},dr={"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},hr={KEYBOARD:0,TOUCHSCREEN:1,CONTROLLER_CONSOLE:2,CONTROLLER_MOBILE:3},ha="server-control-template",li="client-control-template";function ai(e,t){let i=Number(e);return Number.isFinite(i)?i:t}var ma=Object.fromEntries(Object.entries(hr).map(([e,t])=>[t,e])),mr=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"]]}),pr=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}),pa=Object.freeze([["2/15","name",null],["4/23","field14","field14"],["1/12","transform","transform"],["62/82","empty72","rootChildRef"]]);function Bi(e){return{class:1,type:8,id:e}}function Gt(e,t,i,n){return{...n,field501:t,field502:i,field503:1,nodeRef:Bi(e)}}function ga(e){let t=[],i=e.meta?.assetType==="client-control-template";return W(e.root,n=>{i&&n.kind==="server-container"||t.push(n)}),t}function Dt(e,t=new Set){let i=new Map,n=[];for(let r of ga(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=De(t);t.add(o),r.guid=o,i.set(r.id,o)}return i}function ya(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 ba(e,t){let n={multiPlatform:{platforms:le.map(r=>({platformType:hr[r],transform:ya(e.transformByPlatform[r])})),field502:$t[e.kind]||25,...e.syncAllDevices===!1?{}:{field504:1}},type:2};return{transform:{multiPlatform:{},type:2},field501:1,field502:12,details:Gt(t,4,12,{transform:n})}}function va(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:Gt(t,5,i?23:86,{field14:r})},ba(e,t)]}function Sa(e,t,i,n){let r=(s,f,m,h,g)=>({[m]:"",field501:s,field502:f,details:Gt(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:Gt(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:ai(e.softEdgeWidthX,8),field502:ai(e.softEdgeWidthY,8)},field512:ai(e.horizontalSoftRange,85),field513:ai(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=(v,w)=>{let N=e[v];return N?(e.children||[]).some(E=>E.id===N)?i.get(N)||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 Ca(e,t){return t?1:Number.isSafeInteger(Number(e.giaInfoIndex))&&Number(e.giaInfoIndex)>0?Number(e.giaInfoIndex):dr[e.kind]||2}function Ia(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 Ui(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 si(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(v=>i.get(v.id)),h=o?n:m,g=va(e,s,o);if(o){let v=e.children?.[0];v&&g.push({empty72:"",field501:62,field502:82,details:Gt(s,64,82,{rootChildRef:{guid:i.get(v.id)}})})}else g.push(...Sa(e,s,i,r));return{id:Bi(s),relatedIds:h.map(v=>Bi(v)),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:Ca(e,o)},field501:2,field502:6}]:[],...o||a?[{related:{value:Ia(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 gr(e){let t=[];return W(e.root,(i,n)=>{i.kind!=="server-container"&&t.push({node:i,parent:n})}),t}function wa(e,t){let i=new Map;for(let n of e||[]){if(!n.controlId||!(t===li?n.controlAsset===li:n.controlAsset!==li))continue;let o=i.get(n.controlId)||[];o.push(n.guid),i.set(n.controlId,o)}return i}function yr(e,t,i,n){let r=wa(t,i),o=new Map;W(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 Ki(e){let t=Number(e.meta?.giaModeFlag);return Number.isSafeInteger(t)&&t>=0?{modeFlag:t}:{}}function br(e,t,i,n,r=[]){let o=gr(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 yr(e,r,li,()=>({graph:a.map(({node:f,parent:m})=>si(f,m,t,s,i,!1,!0)),accessories:c.map(({node:f,parent:m})=>si(f,m,t,s,i,!1,!1,!0)),filePath:n||Ui(e,!0),gameVersion:e.meta?.gameVersion||"7.0.50",...Ki(e)}))}function vr(e,t,i,n,r){let o=gr(e),a=[o[0],...o.slice(1).reverse()],l=a.map(({node:c})=>t.get(c.id));return yr(e,i.scripts,ha,()=>({graph:[si(e.root,null,t,l,n,!0,!1,!1,!0),...i.units||[]],accessories:a.map(({node:c,parent:s})=>si(c,s,t,l,n,!1,!1,!1,!0)),filePath:r||Ui(e,!1),gameVersion:e.meta?.gameVersion||"7.0.50",...Ki(e)}))}function Sr(e,t){let i=Er(e),n=t(i);if(!n.valid)throw new Error(`GIA compatibility validation failed:
103
103
  ${n.errors.join(`
104
- `)}`);return i}function cr(e,t={}){q(e.root,Je);let i=Gt(D(e)),n=[],r=e.meta?.assetType==="client-control-template",a;if(r)a=lr(e,i,n,void 0,t.scripts||[]);else{let l=Yi(t.scripts||[],new Set(i.values()));n.push(...l.warnings),a=sr(e,i,l,n)}return{buffer:ur(a,r?Sr:Ui),warnings:[...new Set(n)]}}function fr(e,t,i={}){q(e.root,Je),t&&q(t.root,Je);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 a=new Set,o=D(e),l=t?D(t):null,f=Gt(o,a),s=Yi(i.scripts||[],a);n.push(...s.warnings.filter(x=>x!==hr));let c=String(i.fileName||`${o.meta?.name||"\u6574\u5408\u5305"} \xB7 \u6574\u5408\u5305.gia`),m=zi({...o,meta:{...o.meta,giaFileName:c}},!1),h=sr(o,f,s,n,m),p={graph:[],accessories:[]};if(r.length&&l){let x=Gt({...l,meta:{...l.meta,assetType:"client-control-template"}},a);p=lr(l,x,n,m,s.scripts)}let v={graph:[...h.graph,...p.graph],accessories:[...h.accessories,...p.accessories],filePath:m,gameVersion:e.meta?.gameVersion||t?.meta?.gameVersion||"7.0.50",...Vi(e)};return{buffer:ur(v,Ui),warnings:[...new Set(n)]}}var Ct=69,dr=30,hr="\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 fo(e){return(String(e.path||"").replace(/\\/g,"/").split("/").pop()||"").replace(/\.lua$/iu,"")||`\u811A\u672C${e.id||""}`}function mr(e){let t=Se.verify(e);if(t)throw new Error(`GIA encode validation failed: ${t}`);let i=Se.encode(Se.create(e)).finish(),n=Buffer.alloc(Ve+i.length+Di);return n.writeUInt32BE(n.length-4,0),n.writeUInt32BE(1,4),n.writeUInt32BE(Qn,8),n.writeUInt32BE(3,12),n.writeUInt32BE(i.length,16),Buffer.from(i).copy(n,Ve),n.writeUInt32BE(er,Ve+i.length),n}function Yi(e,t=new Set){let i=(e||[]).filter(o=>o.path||o.source).map(o=>({...o})),n=[];for(let o of i){let l=Number(o.guid);we(l)&&!t.has(l)?(t.add(l),o.guid=l):n.push(o)}for(let o of n){let l=Oe(t);t.add(l),o.guid=l}let r=[];return(e||[]).some(o=>o.controlId)&&r.push(hr),{units:i.map(o=>{let l=fo(o),f=String(o.path||"").replace(/\\/g,"/"),s=/\.lua$/iu.test(f)?f:`${f||l}.lua`,c={id:o.guid,name:l,filePath:s};return String(o.source||"")&&(c.source=String(o.source)),{id:{class:dr,id:o.guid},name:l,which:Ct,script:{mapping:c}}}),warnings:r,scripts:i}}function pr(e){let t=Yi(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=mr(i),r=ho(n);if(!r.valid)throw new Error(`GIA compatibility validation failed:
104
+ `)}`);return i}function Cr(e,t={}){W(e.root,et);let i=Dt(G(e)),n=[],r=e.meta?.assetType==="client-control-template",o;if(r)o=br(e,i,n,void 0,t.scripts||[]);else{let l=Xi(t.scripts||[],new Set(i.values()));n.push(...l.warnings),o=vr(e,i,l,n)}return{buffer:Sr(o,r?Rr:Li),warnings:[...new Set(n)]}}function Ir(e,t,i={}){W(e.root,et),t&&W(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=Dt(a,o),s=Xi(i.scripts||[],o);n.push(...s.warnings.filter(N=>N!==xr));let f=String(i.fileName||`${a.meta?.name||"\u6574\u5408\u5305"} \xB7 \u6574\u5408\u5305.gia`),m=Ui({...a,meta:{...a.meta,giaFileName:f}},!1),h=vr(a,c,s,n,m),g={graph:[],accessories:[]};if(r.length&&l){let N=Dt({...l,meta:{...l.meta,assetType:"client-control-template"}},o);g=br(l,N,n,m,s.scripts)}let v={graph:[...h.graph,...g.graph],accessories:[...h.accessories,...g.accessories],filePath:m,gameVersion:e.meta?.gameVersion||t?.meta?.gameVersion||"7.0.50",...Ki(e)};return{buffer:Sr(v,Li),warnings:[...new Set(n)]}}var Ct=69,wr=30,xr="\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 xa(e){return(String(e.path||"").replace(/\\/g,"/").split("/").pop()||"").replace(/\.lua$/iu,"")||`\u811A\u672C${e.id||""}`}function Er(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+Yi);return n.writeUInt32BE(n.length-4,0),n.writeUInt32BE(1,4),n.writeUInt32BE(cr,8),n.writeUInt32BE(3,12),n.writeUInt32BE(i.length,16),Buffer.from(i).copy(n,Be),n.writeUInt32BE(fr,Be+i.length),n}function Xi(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=De(t);t.add(l),a.guid=l}let r=[];return(e||[]).some(a=>a.controlId)&&r.push(xr),{units:i.map(a=>{let l=xa(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:wr,id:a.guid},name:l,which:Ct,script:{mapping:f}}}),warnings:r,scripts:i}}function Ar(e){let t=Xi(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=Er(i),r=Ea(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 Bi(e){return Se.toObject(Se.decode(si(e)),{longs:Number,enums:Number,bytes:Buffer,defaults:!1,arrays:!0,objects:!0})}function gr(e){try{let i=Bi(e).graph||[];return i.length>0&&i.every(n=>Number(n.which)===Ct)}catch{return!1}}function yr(e){let t=(e.graph||[]).filter(r=>Number(r.which)===Ct),i=[],n=t.map((r,a)=>{let o=r.script?.mapping||{},l=Number(r.id?.id)||0;l<=0&&i.push(`\u7B2C ${a+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 f=Number(o.id)||0;return f&&f!==l&&i.push(`\u7B2C ${a+1} \u6761\u811A\u672C\u6620\u5C04 id(${f}) \u4E0E\u5355\u5143 id(${l}) \u4E0D\u4E00\u81F4\uFF0C\u4EE5\u5355\u5143 id \u4E3A\u51C6\u3002`),{guid:l,path:String(o.filePath||""),source:String(o.source||"")}});for(let[r,a]of n.entries())a.path&&!/\.lua$/iu.test(a.path)&&i.push(`\u7B2C ${r+1} \u6761\u811A\u672C\u6620\u5C04 file_path \u7F3A\u5C11 .lua \u540E\u7F00\uFF08${a.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 br(e){let t=Bi(e),i=yr(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 ho(e){let t=[],i;try{i=Bi(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,a)=>{let o=`\u5355\u5143 ${a+1}`;Number(r.which)!==Ct&&t.push(`${o}: which \u5E94\u4E3A 69\uFF0C\u5B9E\u9645 ${r.which}`),Number(r.id?.class)!==dr&&t.push(`${o}: id.class \u5E94\u4E3A 30\uFF0C\u5B9E\u9645 ${r.id?.class}`),Number(r.id?.type??0)!==0&&t.push(`${o}: id.type \u5E94\u7F3A\u7701`);let l=r.script?.mapping;if(!l){t.push(`${o}: \u7F3A\u5C11 field35 ScriptMappingWrapper`);return}Number(r.id?.id)<=0&&t.push(`${o}: GraphUnit.id.id \u975E\u6CD5`),Number(l.id)!==Number(r.id?.id)&&t.push(`${o}: mapping.id \u5E94\u7B49\u4E8E GraphUnit.id.id`),String(l.name||"")!==String(r.name||"")&&t.push(`${o}: mapping.name \u5E94\u7B49\u4E8E GraphUnit.name`),String(l.filePath||"").trim()?/\.lua$/iu.test(String(l.filePath))||t.push(`${o}: 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(`${o}: file_path \u4E3A\u7A7A`)}),{valid:t.length===0,errors:t,scriptCount:n.length}}function si(e){let t=Buffer.isBuffer(e)?e:Buffer.from(e);if(t.length<Ve+Di)throw new Error("GIA \u6587\u4EF6\u8FC7\u77ED");if(t.readUInt32BE(4)!==1||t.readUInt32BE(8)!==Qn||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-Ve-Di)throw new Error("GIA payload \u957F\u5EA6\u4E0D\u4E00\u81F4");if(t.readUInt32BE(Ve+i)!==er)throw new Error("GIA \u5C3E\u6807\u8BB0\u65E0\u6548");return t.subarray(Ve,Ve+i)}function se(e,t){return e.ui?.content?.data?.find(i=>i.details?.[t])?.details?.[t]||null}function mo(e){let t=se(e,"transform")?.multiPlatform,i={};for(let r of t?.platforms||[]){let a=to[r.platformType||0],o=r.transform||{};i[a]={scale:o.scale?{x:o.scale.x??0,y:o.scale.y??0,z:o.scale.z??0}:{x:1,y:1,z:1},rotation:{x:0,y:0,z:o.field508?.z??0},anchorMin:{x:o.anchorMin?.x??0,y:o.anchorMin?.y??0},anchorMax:{x:o.anchorMax?.x??0,y:o.anchorMax?.y??0},offset:{x:o.offset?.x??0,y:o.offset?.y??0},size:{x:o.size?.x??0,y:o.size?.y??0},pivot:o.pivot?{x:o.pivot.x??0,y:o.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 re)i[r]||(i[r]=structuredClone(n));return i}function li(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 Zn(e,{reverseSiblings:t=!1,idOffset:i=0}={}){if(!e.length)return{nodes:new Map,rootCandidates:[],warnings:[]};let n=new Map(e.map((s,c)=>[s.id?.id,`n${i+c+1}`])),r=new Map,a=new Map,o=[];for(let s of e){let c=li(s),m=se(s,"textConfig"),h=se(s,"imageSlot"),p=se(s,"image"),v=se(s,"buttonPreset"),w=se(s,"gridView"),x=se(s,"genericSlot"),k=se(s,"footerSlot"),$=se(s,"cursorConfig"),O=se(s,"keyHint"),Y=se(s,"containerNodeSlot"),L=se(s,"templateRefSlot"),Z=se(s,"effectSlot"),W=se(s,"fullscreenEffectSlot"),N=K(c,{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||c,visible:se(s,"field14")?.field17?.initiallyHidden!==!0,active:se(s,"field14")?.initiallyInactive!==!0,canControllerFocus:k?.field505===1,scriptMappingIds:(x?.field502||[]).map(y=>Number(y?.field1?.id)).filter(y=>Number.isSafeInteger(y)&&y>0),transformByPlatform:mo(s),syncAllDevices:se(s,"transform")?.multiPlatform?.field504===1,giaRaw:{genericField501:x?.field501??0,footerField505:k?.field505??0,...c==="textbox"||c==="textwindow"?{textField501:m?.field501??20,textField503:m?.field503??12,textAlign:m?.align??0,...[void 0,0,1,2].includes(m?.verticalAlign)?{}:{textVerticalAlign:m.verticalAlign},...c==="textwindow"?{textField511:m?.field511??1,textViewField502:m?.viewFlags?.field502??1,textViewField503:m?.viewFlags?.field503??1}:{}}:{},...c==="cursor"?{cursorField501:$?.field501??0}:{},...c==="reference"?{templateRefSlot:L??""}:{},...c==="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}:{},...c==="keyhint"?{keyHintField501:O?.field501??1,keyHintField502:O?.field502??1}:{},...c==="image"?{imageField502:p?.field502??1,imageField504:p?.field504??1,imageField505:p?.field505??1,imageField507:p?.field507??2,imageFillType:p?.fillType??1}:{},...c==="animation"?{effectSlot:Z??""}:{},...c==="fullscreen"?{fullscreenEffectSlot:W??""}:{}},...c==="container"?{isolateNavigation:Y?.isolateNavigation===!0,disableKeyEventPassthrough:Y?.disableKeyEventPassthrough===!0,disableCursorEventPassthrough:Y?.disableCursorEventPassthrough===!0,showCursor:Y?.showCursor===!0}:{},...c==="cursor"?{raycastTarget:$?.field501===1}:{},...c==="textbox"||c==="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",...c==="textwindow"?{interactable:!0,showScrollBar:!0}:{}}:{},...c==="image"?{imageSource:"StaticReference",imageId:h?.assetId??0,imageColor:Number.isFinite(h?.field502)?h.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}:{},...c==="button"?{interactable:v?.interactable===1,raycastTarget:v?.raycastTarget===1,clickAudioId:v?.clickAudioId??50888}:{},...c==="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}:{},...c==="reference"?{referencedPrefabId:L??""}:{},...c==="keyhint"?{keyboardKeyCode:O?.field502??null,controllerKeyCode:O?.field501??null}:{},...c==="animation"?{animationId:Z??""}:{},...c==="fullscreen"?{animationId:W??""}:{}});r.set(s.id?.id,N),(c==="textbox"||c==="textwindow")&&![void 0,0,1,2].includes(m?.align)&&o.push(`${N.name}: \u6C34\u5E73\u5BF9\u9F50\u679A\u4E3E ${m.align} \u7684\u542B\u4E49\u672A\u77E5\uFF0C\u5DF2\u539F\u6837\u4FDD\u7559\u3002`),(c==="textbox"||c==="textwindow")&&![void 0,0,1,2].includes(m?.verticalAlign)&&o.push(`${N.name}: \u5782\u76F4\u5BF9\u9F50\u679A\u4E3E ${m.verticalAlign} \u7684\u542B\u4E49\u672A\u77E5\uFF0C\u5DF2\u539F\u6837\u4FDD\u7559\u3002`),c==="image"&&![void 0,0,1,2,3,4,5].includes(p?.fillType)&&o.push(`${N.name}: \u586B\u5145\u5F62\u72B6\u679A\u4E3E ${p.fillType} \u672A\u8BC6\u522B\uFF0C\u5DF2\u4FDD\u7559\u539F\u503C\u3002`),c==="button"&&a.set(N.id,{unavailableChildId:v?.disabledChild,hoverChildId:v?.hoverChild,pressedChildId:v?.pressedChild,selectedChildId:v?.selectedChild})}let l=[],f=new Set;for(let s of e){let c=r.get(s.id?.id),m=(s.ui?.content?.children||[]).map(h=>r.get(h)).filter(Boolean);if(m.length){c.children=t?m.slice().reverse():m;for(let h of m)f.add(h.id)}}for(let s of e){let c=r.get(s.id?.id),m=s.ui?.content?.parent||0,h=r.get(m);h?f.has(c.id)||(t?h.children.unshift(c):h.children.push(c)):l.push(c)}for(let[s,c]of a){let m=[...r.values()].find(h=>h.id===s);for(let[h,p]of Object.entries(c))m[h]=n.get(p)||null}return{nodes:r,rootCandidates:l,warnings:o}}function vr(e){let t=si(e),i=Se.toObject(Se.decode(t),{longs:Number,enums:Number,bytes:Buffer,defaults:!1,arrays:!0,objects:!0}),n=i.graph||[];if(!n.some(v=>v.ui?.content))throw new Error("GIA \u4E0D\u542B\u53EF\u8BC6\u522B\u7684 UIControlGroup \u4E3B\u56FE");let r=n.find(v=>v.which===21)||null,a=n.filter(v=>Number(v.which)===70),o=i.accessories||[],l=new Set((r?.relatedIds||[]).map(v=>v.id||0)),f=r?l.size?o.filter(v=>l.has(v.id?.id||0)):o:[],s=a.length?[...a,...o.filter(v=>!l.has(v.id?.id||0))]:r?[]:[...n,...o];if(!f.length&&!s.length)throw new Error("GIA \u4E0D\u542B\u5BA2\u6237\u7AEF\u63A7\u4EF6");let c=["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=yr(i);c.push(...m.warnings);let h=null,p=null;if(f.length){let v=Zn(f,{reverseSiblings:!0,idOffset:0});c.push(...v.warnings);let w=v.rootCandidates.find(k=>k.kind==="container")||v.rootCandidates[0];if(!w)throw new Error("GIA \u672A\u627E\u5230\u5BA2\u6237\u7AEF\u6839\u63A7\u4EF6");let x=K("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(k=>k.field501===4&&k.field502===4)?.related?.value||[]});x.children=[w],v.rootCandidates.length>1&&c.push(`\u68C0\u6D4B\u5230 ${v.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:fe,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:x}}if(s.length){let v=Zn(s,{reverseSiblings:!1,idOffset:1e3});if(c.push(...v.warnings),!v.rootCandidates.length)throw new Error("GIA \u672A\u627E\u5230\u5BA2\u6237\u7AEF\u6A21\u677F");let w=K("server-container",{id:"sc1",guid:0,name:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F"});w.children=v.rootCandidates,p={version:1,layoutSchemaVersion:fe,meta:{name:v.rootCandidates.length===1?v.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:v.rootCandidates[0].id,script:{controlId:v.rootCandidates[0].id,path:"",source:""},root:w},h||(h=p)}return{project:h,clientProject:p&&h!==p?p:void 0,scripts:m.scripts,warnings:c,metadata:{gameVersion:i.gameVersion||"",filePath:i.filePath||"",...Number.isSafeInteger(Number(i.modeFlag))?{modeFlag:Number(i.modeFlag)}:{},combined:!!(r&&a.length)}}}function Sr(e){let t=si(e),i=Se.toObject(Se.decode(t),{longs:Number,enums:Number,defaults:!1,arrays:!0,objects:!0}),n=i.graph||[],r=i.accessories||[],a=[],o=(h,p)=>h!=null&&Object.prototype.hasOwnProperty.call(h,p),l=new Map,f=[];/^\d+-\d+-\d+-\\.+\.gia$/iu.test(i.filePath||"")||a.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 p=li(h),v=h.ui?.content?.info||[],w=v.find(O=>O.field501===2&&O.field502===6)?.index?.value,x=tr[p],k=v.find(O=>O.field501===4&&O.field502===4),$=k?.related?.value||[];return(!Number.isSafeInteger(w)||w<=0)&&a.push(`${h.name}: Info.index=${w??"<missing>"}\uFF0C\u5FC5\u987B\u662F\u6B63\u6574\u6570`),k||a.push(`${h.name}: \u9876\u5C42 UIControlTemplate \u7F3A\u5C11 Info.related \u8BB0\u5F55`),{id:h.id?.id||0,name:h.name||"",kind:p,actualIndex:w,expectedIndex:x,relatedPresent:!!k,relatedGuids:$}});s.length||a.push("Root.graph \u4E0D\u542B UIControlTemplate(70)");let c=0,m=0;for(let h of[...n,...r]){if(!h.ui?.content)continue;let p=h.id?.id||0,v=h.ui.content,w=li(h),x=n.includes(h)&&h.which===70,k=`${h.name||"<unnamed>"}(${p||"<missing-guid>"})`;!Number.isSafeInteger(p)||p<=0||p>2147483647?a.push(`${k}: GraphUnit GUID \u975E\u6CD5`):l.has(p)?a.push(`${k}: GUID \u4E0E ${l.get(p).name||"<unnamed>"} \u91CD\u590D`):l.set(p,h),(h.id?.class!==1||h.id?.type!==8)&&a.push(`${k}: GraphUnit.id \u5FC5\u987B\u4E3A class=1,type=8`),v.guid!==p&&a.push(`${k}: content.guid=${v.guid??"<missing>"} \u4E0E GraphUnit.id.id \u4E0D\u4E00\u81F4`),x&&h.which!==70&&a.push(`${k}: \u6A21\u677F\u6839 which \u5FC5\u987B\u4E3A UIControlTemplate(70)`),!x&&h.which!==15&&a.push(`${k}: \u9644\u4EF6\u63A7\u4EF6 which \u5FC5\u987B\u4E3A UIControl(15)`);let $=v.info||[],O=$.find(S=>S.field501===1&&S.field502===5),Y=$.find(S=>S.field501===2&&S.field502===6);O?.guid?.value!==p&&a.push(`${k}: Info.self GUID \u7F3A\u5931\u6216\u4E0E\u81EA\u8EAB\u4E0D\u4E00\u81F4`),(!Number.isSafeInteger(Y?.index?.value)||Y.index.value<=0)&&a.push(`${k}: Info.index=${Y?.index?.value??"<missing>"}\uFF0C\u5FC5\u987B\u662F\u6B63\u6574\u6570`);let L=$.find(S=>S.field501===4&&S.field502===4);x&&!L&&a.push(`${k}: \u9876\u5C42\u6A21\u677F\u7F3A\u5C11 Info.related \u8BB0\u5F55`),!x&&L&&a.push(`${k}: \u9644\u4EF6\u63A7\u4EF6\u4E0D\u5E94\u5199 Info.related`);let Z=nr[w],W=v.data||[],N=W.map(S=>`${S.field501}/${S.field502}`),y=Z?.map(([S])=>S)||[];Z?JSON.stringify(N)!==JSON.stringify(y)&&a.push(`${k}: Data \u69FD\u4F4D\u987A\u5E8F ${N.join(",")}\uFF0C\u5E94\u4E3A ${y.join(",")}`):a.push(`${k}: \u672A\u77E5\u5BA2\u6237\u7AEF\u63A7\u4EF6\u7C7B\u578B ${w}`);for(let S=0;S<Math.min(W.length,Z?.length||0);S+=1){let P=W[S],[G,z,ne]=Z[S];if(o(P,z)||a.push(`${k}: Data ${G} \u7F3A\u5C11 ${z} \u5206\u652F`),!ne)continue;o(P.details,ne)||a.push(`${k}: Details ${G} \u7F3A\u5C11 ${ne} \u5206\u652F`);let j=rr[G];(P.details?.field501!==j||P.details?.field502!==P.field502||P.details?.field503!==1)&&a.push(`${k}: Details ${G} \u6807\u8BB0\u5E94\u4E3A ${j}/${P.field502}/1`);let ce=P.details?.nodeRef;(ce?.class!==1||ce?.type!==8||ce?.id!==p)&&a.push(`${k}: Details ${G} node_ref \u672A\u6307\u5411\u81EA\u8EAB`)}let E=(h.ui.content.data||[]).find(S=>S.field501===4&&S.field502===86);E&&(o(E.field14,"field17")?c+=1:a.push(`${k}: \u7C7B\u578B Data \u7F3A\u5C11\u663E\u5F0F Field14.field17 \u7A7A\u4E32`),o(E.details?.field14,"field17")?c+=1:a.push(`${k}: \u7C7B\u578B Details \u7F3A\u5C11\u663E\u5F0F Field14.field17 \u7A7A\u4E32`));let b=(h.ui.content.data||[]).find(S=>S.details?.transform)?.details?.transform?.multiPlatform?.platforms||[];b.length!==4&&a.push(`${k}: \u591A\u5E73\u53F0\u53D8\u6362\u6570\u91CF=${b.length}\uFF0C\u5E94\u4E3A 4`);let I=b.map(S=>S.platformType||0);JSON.stringify(I)!==JSON.stringify([0,1,2,3])&&a.push(`${k}: \u5E73\u53F0\u987A\u5E8F ${I.join(",")}\uFF0C\u5E94\u4E3A 0,1,2,3`);let M=(h.ui.content.data||[]).find(S=>S.details?.transform)?.details?.transform;M?.multiPlatform?.field502!==$t[w]&&a.push(`${k}: \u53D8\u6362 preset=${M?.multiPlatform?.field502??"<missing>"}\uFF0C${w} \u5E94\u4E3A ${$t[w]}`);for(let S of b)o(S.transform,"field508")?m+=1:a.push(`${k}: RectTransform \u7F3A\u5C11\u663E\u5F0F field508 \u7A7A\u4E32`);f.push({id:p,name:h.name||"",kind:w,template:x,parent:v.parent||0,children:[...v.children||[]],relatedIds:(h.relatedIds||[]).map(S=>S.id||0),dataSignatures:N})}for(let h of f){let p=`${h.name||"<unnamed>"}(${h.id})`;if(JSON.stringify(h.relatedIds)!==JSON.stringify(h.children)&&a.push(`${p}: GraphUnit.relatedIds \u4E0E content.children \u4E0D\u4E00\u81F4`),h.template&&h.parent&&a.push(`${p}: \u9876\u5C42\u6A21\u677F\u4E0D\u5E94\u6709 parent`),!h.template){let v=l.get(h.parent);v?(v.ui?.content?.children||[]).includes(h.id)||a.push(`${p}: \u7236\u63A7\u4EF6 children \u672A\u53CD\u5411\u5305\u542B\u81EA\u8EAB`):a.push(`${p}: parent=${h.parent||"<missing>"} \u4E0D\u5B58\u5728`)}for(let v of h.children){let w=l.get(v);w?(w.ui?.content?.parent||0)!==h.id&&a.push(`${p}: child=${v} \u7684 parent \u672A\u6307\u56DE\u81EA\u8EAB`):a.push(`${p}: child=${v} \u4E0D\u5B58\u5728`)}}return{valid:a.length===0,errors:a,filePath:i.filePath||"",gameVersion:i.gameVersion||"",templateCount:s.length,accessoryCount:r.length,templates:s,units:f,explicitEmpty:{field17:c,rectField508:m}}}function Ui(e){let t=si(e),i=Se.toObject(Se.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),a=(i.graph||[]).filter(S=>Number(S.which)===Ct),o=(i.accessories||[]).filter(S=>S.ui?.content),l=[],f=(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 c=n[0];if(!c)return{valid:!1,errors:l,filePath:i.filePath||"",gameVersion:i.gameVersion||"",accessoryCount:o.length,controls:[],scriptCount:a.length,explicitEmpty:{field17:0,rectField508:0}};let m=[c,...o],h=new Map;for(let S of m){let P=S.id?.id||0,G=`${S.name||"<unnamed>"}(${P||"<missing-guid>"})`;!Number.isSafeInteger(P)||P<=0||P>2147483647?l.push(`${G}: GraphUnit GUID \u975E\u6CD5`):h.has(P)?l.push(`${G}: GUID \u91CD\u590D`):h.set(P,S),(S.id?.class!==1||S.id?.type!==8)&&l.push(`${G}: GraphUnit.id \u5FC5\u987B\u4E3A class=1,type=8`),S.ui?.content?.guid!==P&&l.push(`${G}: content.guid \u4E0E GraphUnit.id.id \u4E0D\u4E00\u81F4`)}let p=c.id?.id||0,v=c.ui.content,w=`${c.name||"<unnamed>"}(${p})`;c.which!==21&&l.push(`${w}: which \u5FC5\u987B\u4E3A UIControlGroup(21)`);let x=v.info||[];x.find(S=>S.field501===1&&S.field502===5)?.guid?.value!==p&&l.push(`${w}: Info.self GUID \u7F3A\u5931\u6216\u4E0D\u4E00\u81F4`),x.find(S=>S.field501===2&&S.field502===6)?.index?.value!==1&&l.push(`${w}: Info.index \u5FC5\u987B\u4E3A 1`);let k=x.find(S=>S.field501===4&&S.field502===4);k||l.push(`${w}: \u7F3A\u5C11\u663E\u5F0F Info.related \u8BB0\u5F55`);let $=0,O=0,Y=(S,P,G,z=!1)=>{let ne=S.id?.id||0,j=`${S.name||"<unnamed>"}(${ne})`,ce=S.ui.content.data||[],Te=ce.map(X=>`${X.field501}/${X.field502}`),oe=G.map(([X])=>X);JSON.stringify(Te)!==JSON.stringify(oe)&&l.push(`${j}: Data \u69FD\u4F4D\u987A\u5E8F ${Te.join(",")}\uFF0C\u5E94\u4E3A ${oe.join(",")}`);for(let X=0;X<Math.min(ce.length,G.length);X+=1){let Ce=ce[X],[Le,Zt,Pt]=G[X];if(f(Ce,Zt)||l.push(`${j}: Data ${Le} \u7F3A\u5C11 ${Zt} \u5206\u652F`),!Pt)continue;f(Ce.details,Pt)||l.push(`${j}: Details ${Le} \u7F3A\u5C11 ${Pt} \u5206\u652F`);let Re=rr[Le];(Ce.details?.field501!==Re||Ce.details?.field502!==Ce.field502||Ce.details?.field503!==1)&&l.push(`${j}: Details ${Le} \u6807\u8BB0\u5E94\u4E3A ${Re}/${Ce.field502}/1`);let Tt=Ce.details?.nodeRef;(Tt?.class!==1||Tt?.type!==8||Tt?.id!==ne)&&l.push(`${j}: Details ${Le} node_ref \u672A\u6307\u5411\u81EA\u8EAB`)}let ct=ce.find(X=>X.field501===4&&X.field502===(z?23:86)),He=z?"empty15":"field17";f(ct?.field14,He)?z||($+=1):l.push(`${j}: \u7C7B\u578B Data \u7F3A\u5C11\u663E\u5F0F Field14.${He} \u7A7A\u4E32`),f(ct?.details?.field14,He)?z||($+=1):l.push(`${j}: \u7C7B\u578B Details \u7F3A\u5C11\u663E\u5F0F Field14.${He} \u7A7A\u4E32`);let At=ce.find(X=>X.details?.transform)?.details?.transform,ft=At?.multiPlatform?.platforms||[];ft.length!==4&&l.push(`${j}: \u591A\u5E73\u53F0\u53D8\u6362\u6570\u91CF=${ft.length}\uFF0C\u5E94\u4E3A 4`);let dt=ft.map(X=>X.platformType||0);JSON.stringify(dt)!==JSON.stringify([0,1,2,3])&&l.push(`${j}: \u5E73\u53F0\u987A\u5E8F ${dt.join(",")}\uFF0C\u5E94\u4E3A 0,1,2,3`);let _t=z?$t["server-container"]:$t[P];At?.multiPlatform?.field502!==_t&&l.push(`${j}: \u53D8\u6362 preset=${At?.multiPlatform?.field502??"<missing>"}\uFF0C\u5E94\u4E3A ${_t}`);for(let X of ft)f(X.transform,"field508")?O+=1:l.push(`${j}: RectTransform \u7F3A\u5C11\u663E\u5F0F field508 \u7A7A\u4E32`);return Te};Y(c,"server-container",io,!0);let L=(c.relatedIds||[]).map(S=>S.id||0),Z=new Set(L),W=o.filter(S=>Z.has(S.id?.id||0)),N=W.map(S=>S.id?.id||0);JSON.stringify(L)!==JSON.stringify(N)&&l.push(`${w}: \u4E3B\u56FE relatedIds \u5FC5\u987B\u6309\u987A\u5E8F\u8986\u76D6\u672C\u7EC4 accessories`);let y=v.data?.find(S=>S.details?.rootChildRef)?.details?.rootChildRef?.guid||0,E=h.get(y);(!E||!W.includes(E))&&l.push(`${w}: 62/82 \u6839\u8282\u70B9\u5F15\u7528\u4E0D\u5B58\u5728`),N[0]!==y&&l.push(`${w}: \u6839\u5BB9\u5668\u8282\u70B9\u5FC5\u987B\u662F\u672C\u7EC4 accessories[0]`);let b=[];for(let S of W){let P=S.id?.id||0,G=S.ui.content,z=`${S.name||"<unnamed>"}(${P})`,ne=li(S);S.which!==15&&l.push(`${z}: which \u5FC5\u987B\u4E3A UIControl(15)`);let j=G.info||[];(j.length!==1||j[0]?.field501!==1||j[0]?.field502!==5||j[0]?.guid?.value!==P)&&l.push(`${z}: \u670D\u52A1\u7AEF\u5BB9\u5668\u5185\u63A7\u4EF6 Info \u5FC5\u987B\u53EA\u542B\u81EA\u8EAB GUID`);let ce=nr[ne];ce||l.push(`${z}: \u672A\u77E5\u5BA2\u6237\u7AEF\u63A7\u4EF6\u7C7B\u578B ${ne}`);let Te=ce?Y(S,ne,ce):[];b.push({id:P,name:S.name||"",kind:ne,parent:G.parent||0,children:[...G.children||[]],relatedIds:(S.relatedIds||[]).map(oe=>oe.id||0),dataSignatures:Te})}let I=b.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 M=new Map(b.map(S=>[S.id,S]));for(let S of b){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 G=M.get(S.parent);G?G.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 G of S.children){let z=M.get(G);z?z.parent!==S.id&&l.push(`${P}: child=${G} \u7684 parent \u672A\u6307\u56DE\u81EA\u8EAB`):l.push(`${P}: child=${G} \u4E0D\u5B58\u5728`)}}return{valid:l.length===0,errors:l,filePath:i.filePath||"",gameVersion:i.gameVersion||"",graph:{id:p,name:c.name||"",relatedGuids:k?.related?.value||[],rootGuid:y},accessoryCount:o.length,controls:b,scriptCount:a.length,explicitEmpty:{field17:$,rectField508:O}}}function Cr(e,t=[]){if(!e||e.layoutSchemaVersion===fe)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:fe};let i=structuredClone(e),n=0;return q(i.root,r=>{let a=r.transformByPlatform||{},o=r.transformByCanvas||{},l=r.name||r.id;for(let s of Object.keys(a))if(!re.includes(s))throw new Error(`${l}: unknown platform ${s}`);let f={};for(let s of re){let c=pt[s],m=J[c].platform,h=Object.keys(J).filter(x=>J[x].platform===m&&o[x]),p=o[c]?c:h[0],v=s==="CONTROLLER_CONSOLE"?f.KEYBOARD:s==="CONTROLLER_MOBILE"?f.TOUCHSCREEN:null,w=a[s]??v??(p?o[p]:null);if(f[s]=w?Ie(w):Mi(r.kind),w||t.push(`${l}: ${s} \u65E0\u65E7\u5E03\u5C40\uFF0C\u5DF2\u4F7F\u7528\u63A7\u4EF6\u9ED8\u8BA4\u503C`),!a[s]&&!v&&p&&p!==c&&t.push(`${l}: \u7F3A\u5C11 ${c}\uFF0C\u5DF2\u91C7\u7528 ${p} \u7684\u951A\u70B9\u548C\u5C3A\u5BF8\u53C2\u6570`),!v)for(let x of h)JSON.stringify(f[s])!==JSON.stringify(Ie(o[x]))&&t.push(`${l}: ${x} \u4E0E ${s} \u5E03\u5C40\u51B2\u7A81\uFF0C\u4FDD\u7559${a[s]?"\u5DF2\u6709\u5E73\u53F0":p}\u53C2\u6570`)}Fe(f,`${l}.transformByPlatform`),r.transformByPlatform=f,delete r.transformByCanvas,n++}),i.layoutSchemaVersion=fe,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 Ki(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 Hi(e,t,i,n=e.canvasId){let r=$e(e.root,t);return!r||r.kind==="server-container"?he(n):i[r.id]||he(n)}function xe(e,{warnings:t=[]}={}){if(!e)return De();if(e=Cr(e,t),(e.root||e.layoutSchemaVersion!==void 0)&&e.layoutSchemaVersion!==fe)throw new Error(`\u4EC5\u652F\u6301 layoutSchemaVersion=${fe} \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"?Qe():De(),r={layoutSchemaVersion:fe,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&&J[e.canvasId]?e.canvasId:Qt,selectedId:e.selectedId||n.selectedId,root:Oi(e.root||n.root)};return kr(r),r}function kr(e){let t=new Set;q(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=Fi(e.root).id)}function Ir(e){return Oe(St(e))}function po(e,t){let i=!1;return q(e,n=>{n.id===t&&(i=!0)}),i}function go(e,t,i,n){let a=ze(e.root,e.canvasId).boxes[t.id],o=i.children.findIndex(m=>m.id===t.id);if(o<0)throw new Error("reparent: source node is not attached");if(i.children.splice(o,1),n.children.push(t),!a)return;let l=ze(e.root,e.canvasId),f=n.kind==="server-container"?he(e.canvasId):l.boxes[n.id]||he(e.canvasId),s=Ge(t.transformByPlatform,e.canvasId),c=je(f,s,{posX:a.centerX,posY:a.centerY,width:a.width,height:a.height});It(e,t,c)}function yo(e,t){return e.meta.assetType!=="client-control-template"?$i(e.root,t):(e.root.children||[]).flatMap(i=>$i(i,t))}function Ar(e,t){let i=jn(e.root,t);if(e.meta.assetType!=="client-control-template")return i;let n=Ot(e),r=new Set;return n&&n.kind!=="server-container"&&q(n,a=>r.add(a.id)),i.filter(a=>r.has(a.id))}function _r(e){let{canvas:t,boxes:i}=ze(e.root,e.canvasId),n=Gt(e),r=ue(e.root,e.selectedId),a=r?i[r.id]:null;return D({layoutSchemaVersion:fe,version:e.version,meta:{...e.meta},canvasId:e.canvasId,canvas:{id:e.canvasId,width:t.width,height:t.height,platform:J[e.canvasId].platform,label:J[e.canvasId].label,presets:Object.values(J).map(o=>({id:o.id,label:o.label,width:o.width,height:o.height,platform:o.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"&&Ot(e)?.id||""},tree:yo(e,n),boxes:Ar(e,i),inspector:qn(r,e.canvasId,a||t,n),root:e.root})}function It(e,t,i){let n=ze(e.root,e.canvasId),r=Hi(e,t.id,n.boxes),a={};if(t.syncAllDevices!==!1)for(let o of re){if(o===qe(e.canvasId))continue;let l=pt[o],f=ze(e.root,l,o);a[o]=Hi(e,t.id,f.boxes,l)}t.transformByPlatform=Wn({transformByPlatform:t.transformByPlatform,source:i,canvasId:e.canvasId,syncAllDevices:t.syncAllDevices!==!1,sourceParentBox:r,targetParentBoxByPlatform:a})}var bo=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"]),vo=new Set(["posX","posY","width","height"]),So=new Set(["anchorMinX","anchorMinY","anchorMaxX","anchorMaxY","pivotX","pivotY"]);function Co(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 _e(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 Io=new Set(["fontSize","minimumFontSize","imageId","clickAudioId","softEdgeWidthX","softEdgeWidthY","horizontalSoftRange","verticalSoftRange","fillAmount","cellSizeX","cellSizeY","spacingX","spacingY","padding1X","padding1Y","padding2X","padding2Y","previewCount","keyboardKeyCode","controllerKeyCode"]),wo=new Set(["active","visible","canControllerFocus","isolateNavigation","disableKeyEventPassthrough","disableCursorEventPassthrough","showCursor","adaptiveFontSize","enableOutline","enableMask","enableSoftEdge","enableFill","reverseMaskArea","raycastTarget","interactable","showScrollBar"]),xo=new Set(["name","horizontalAlignment","verticalAlignment","text","softEdgeMode","fillType","fillHorizontalType","fillVerticalType","fillRadial90Type","fillRadialType","scrollDirection","layoutConstraint","referencedPrefabId","animationId"]),xr=new Set(["unavailableChildId","hoverChildId","pressedChildId","selectedChildId"]),Er={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 Eo(e,t){if(!t||typeof t!="object")throw new Error("patch requires op");let i=t.op;if(i==="select")return t.id&&ue(e.root,t.id)&&(e.selectedId=t.id),e;if(i==="pick"){let{boxes:n}=ze(e.root,e.canvasId),r=Ar(e,n),a=Jn(r,Number(t.x),Number(t.y));return a&&(e.selectedId=a),e}if(i==="setCanvas")return t.canvasId&&J[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"?Qe():De();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=K(t.kind,{id:Ni(e.root),guid:Ir(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=ue(e.root,t.parentId||e.selectedId);if(!n)throw new Error("add: parent not found");let r=Xn(n,t.kind,{id:Ni(e.root),guid:Ir(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=ue(e.root,t.id||e.selectedId),r=n?$e(e.root,n.id):null,a=ue(e.root,t.parentId);if(!n||n.kind==="server-container"||!r)throw new Error("reparent: node not found");if(!a)throw new Error("reparent: parent not found");if(a.id===n.id||po(n,a.id))throw new Error("\u63A7\u4EF6\u4E0D\u80FD\u79FB\u52A8\u5230\u81EA\u8EAB\u6216\u5176\u540E\u4EE3\u4E0B\u9762");if(a.kind==="server-container"&&r.kind==="server-container")return e;if(r.kind==="server-container"&&a.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 go(e,n,r,a),e.selectedId=n.id,e}if(i==="moveSibling"){let n=ue(e.root,t.id||e.selectedId),r=n?$e(e.root,n.id):null;if(!n||!r)throw new Error("moveSibling: node not found");let a=r.children.findIndex(f=>f.id===n.id),o=t.direction==="up"?-1:t.direction==="down"?1:0,l=a+o;return!o||l<0||l>=r.children.length||(r.children.splice(a,1),r.children.splice(l,0,n),e.selectedId=n.id),e}if(i==="remove"){let n=t.id||e.selectedId,r=$e(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 Hn(e.root,n)&&(q(e.root,a=>{if(a.kind==="button")for(let o of xr)a[o]&&!ue(e.root,a[o])&&(a[o]=null)}),e.selectedId=r?r.id:e.root.id),e}if(i==="set"){let n=ue(e.root,t.id||e.selectedId);if(!n)throw new Error("set: node not found");let r=t.key;r==="reverseMask"&&(r="reverseMaskArea");let a=t.value;if(r.startsWith("giaRaw.")){let s=r.slice(7);if(!s||s.includes("."))throw new Error("invalid raw GIA field path");let c=Bn(n.kind,s);if(!c)throw new Error(`unknown raw GIA field for ${n.kind}: ${s}`);if(n.giaRaw||={},n.giaRaw[s]=_i(c,a),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=wr(a),n.syncAllDevices){let s=Ge(n.transformByPlatform,e.canvasId);It(e,n,s)}return e}if(bo.has(r)){if(r.endsWith("Color")&&(a=Co(a)),Io.has(r)){if(a=_e(a,r),a<0)throw new Error(`${r} must not be negative`);if((r==="imageId"||r==="clickAudioId"||r==="keyboardKeyCode"||r==="controllerKeyCode")&&(a=Math.trunc(a)),r==="fillAmount"&&a>1)throw new Error("fillAmount must be between 0 and 1")}if(wo.has(r)&&(a=wr(a)),xo.has(r)&&(a=String(a??"")),r==="horizontalAlignment"&&!["Left","Middle","Right"].includes(a))throw new Error("invalid horizontalAlignment");if(r==="verticalAlignment"&&!["Top","Middle","Bottom"].includes(a))throw new Error("invalid verticalAlignment");if(Er[r]&&!Er[r].includes(a))throw new Error(`invalid ${r}`);if(xr.has(r))if(a===""||a===void 0||a===null)a=null;else{a=String(a);let s=ue(e.root,a);if(!s||s===n||s.kind==="server-container"||!(n.children||[]).some(c=>c.id===a))throw new Error(`${r} must reference a direct child of this button`)}if(n[r]=a,r==="canControllerFocus"&&(n.giaRaw.footerField505=a?1:0),n.kind==="cursor"&&r==="raycastTarget"&&(n.giaRaw.cursorField501=a?1:0),(n.kind==="textbox"||n.kind==="textwindow")&&r==="horizontalAlignment"&&(n.giaRaw.textAlign={Left:0,Middle:1,Right:2}[a]),(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}[a];s&&(n.giaRaw.imageFillType=s)}return n.kind==="reference"&&r==="referencedPrefabId"&&(n.giaRaw.templateRefSlot=a),n.kind==="grid"&&r==="previewCount"&&(n.giaRaw.gridField511=Math.trunc(a)),n.kind==="keyhint"&&r==="keyboardKeyCode"&&(n.giaRaw.keyHintField502=Math.trunc(a)),n.kind==="keyhint"&&r==="controllerKeyCode"&&(n.giaRaw.keyHintField501=Math.trunc(a)),(n.kind==="animation"||n.kind==="fullscreen")&&r==="animationId"&&(n.giaRaw[n.kind==="animation"?"effectSlot":"fullscreenEffectSlot"]=a),e}let{boxes:o}=ze(e.root,e.canvasId),l=Hi(e,n.id,o),f=Ge(n.transformByPlatform,e.canvasId);if(r==="anchorType"){let s=Xi(o[n.id]),c=Dn(f,a);return c=je(l,c,s),It(e,n,c),e}if(r==="rotationZ"){let s={...f,rotation:{...f.rotation,z:_e(a,r)}};return It(e,n,s),e}if(So.has(r)){let s=Xi(o[n.id]),c={...f,anchorMin:{...f.anchorMin},anchorMax:{...f.anchorMax},pivot:{...f.pivot}};return r==="anchorMinX"&&(c.anchorMin.x=_e(a,r)),r==="anchorMinY"&&(c.anchorMin.y=_e(a,r)),r==="anchorMaxX"&&(c.anchorMax.x=_e(a,r)),r==="anchorMaxY"&&(c.anchorMax.y=_e(a,r)),r==="pivotX"&&(c.pivot.x=_e(a,r)),r==="pivotY"&&(c.pivot.y=_e(a,r)),It(e,n,je(l,c,s)),e}if(vo.has(r)){let s=Xi(o[n.id]),c=_e(a,r);if((r==="width"||r==="height")&&c<0)throw new Error(`${r} must not be negative`);return s[r]=c,It(e,n,je(l,f,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 Li(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 Eo(n,t),kr(n),n.version=i+1,Object.keys(e).forEach(r=>{delete e[r]}),Object.assign(e,n),e}function Xi(e){return e?{posX:e.centerX,posY:e.centerY,width:e.width,height:e.height}:{posX:0,posY:0,width:0,height:0}}import ko from"fengari";var{lua:u,lauxlib:te,lualib:Pr,to_luastring:ui,to_jsstring:Ao}=ko,_o=u.LUA_TNIL,Po=u.LUA_TBOOLEAN,To=u.LUA_TNUMBER,Ro=u.LUA_TSTRING,Tr=u.LUA_TTABLE,Mo=u.LUA_TFUNCTION,Wi=u.LUA_TUSERDATA,Ee=u.LUA_OK,Rr=new WeakMap,ji=Symbol("luaTableEntries"),qi={__scriptHostKey:!0};function _(e){return ui(String(e))}function et(e,t){Rr.set(e,t)}function be(e){return Rr.get(e)}function ae(e,t,i){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"){Oo(e,t,i);return}if(i&&i[ji]){let r=i[ji];u.lua_createtable(e,Array.isArray(i)?i.length:0,r.length);for(let[a,o]of r)ae(e,t,a),ae(e,t,o),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.SetEase){t.pushTween(e,i);return}if(n==="object"){u.lua_createtable(e,0,Object.keys(i).length);for(let[r,a]of Object.entries(i))ae(e,t,a),u.lua_setfield(e,-2,_(r));return}u.lua_pushnil(e)}function H(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?"":Ao(i)}function Ye(e,t){t=u.lua_absindex(e,t);let i=u.lua_type(e,t);if(i===Wi)return be(u.lua_touserdata(e,t));if(i===Tr){u.lua_pushlightuserdata(e,qi),u.lua_rawget(e,t);let n=u.lua_type(e,-1)===Wi?u.lua_touserdata(e,-1):null;return u.lua_pop(e,1),n?be(n):null}return null}function me(e,t,i){i=u.lua_absindex(e,i);let n=u.lua_type(e,i);if(n===_o)return null;if(n===Po)return!!u.lua_toboolean(e,i);if(n===To)return u.lua_isinteger(e,i)?u.lua_tointeger(e,i):u.lua_tonumber(e,i);if(n===Ro)return H(e,i);if(n===Wi){let r=u.lua_touserdata(e,i);return be(r)??r}if(n===Mo)return No(e,t,i);if(n===Tr){let r=Ye(e,i);if(r)return r;let a=[];for(u.lua_pushnil(e);u.lua_next(e,i)!==0;){let s=me(e,t,-2),c=me(e,t,-1);a.push([s,c]),u.lua_pop(e,1)}let o=new Map(a.filter(([s])=>Number.isInteger(s)&&s>=1)),l=0;for(;o.has(l+1);)l+=1;let f=l>0?[]:{};for(let[s,c]of a)Array.isArray(f)&&Number.isInteger(s)&&s>=1?f[s-1]=c:(typeof s=="string"||typeof s=="number")&&(f[s]=c);return Object.defineProperty(f,ji,{value:a}),f}return null}function No(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=te.luaL_ref(e,u.LUA_REGISTRYINDEX),a=Fo(e,t,r);return n!=null&&t.luaFunctions.set(n,a),a}function Fo(e,t,i){let n=(...r)=>{let a=u.lua_gettop(e);u.lua_rawgeti(e,u.LUA_REGISTRYINDEX,i);for(let s of r)ae(e,t,s);if(u.lua_pcall(e,r.length,u.LUA_MULTRET,0)!==Ee){let s=H(e,-1);throw u.lua_settop(e,a),new Error(s)}let l=u.lua_gettop(e)-a,f=[];for(let s=1;s<=l;s++)f.push(me(e,t,a+s));if(u.lua_settop(e,a),f.length!==0)return f.length===1?f[0]:f};return n.__luaRef=i,n.__luaState=e,n}function Mr(e,t){if(!t||t.__luaRef==null||!t.__luaState)return;let i=t.__luaState;if((!e?.luaStates||e.luaStates.has(i))&&te.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 Oo(e,t,i){u.lua_pushlightuserdata(e,i),u.lua_pushlightuserdata(e,t),u.lua_pushcclosure(e,function(r){let a=u.lua_touserdata(r,u.lua_upvalueindex(1)),o=u.lua_touserdata(r,u.lua_upvalueindex(2)),l=u.lua_gettop(r),f=[];for(let s=1;s<=l;s++)f.push(me(r,o,s));try{let s=a(...f);if(Array.isArray(s)&&s.__multi){for(let c of s)ae(r,o,c);return s.length}return s===void 0?0:(ae(r,o,s),1)}catch(s){return u.lua_pushstring(r,_(String(s&&s.message?s.message:s))),u.lua_error(r)}},2)}function Nr(e){!e||typeof u.lua_close!="function"||u.lua_close(e)}function Fr(e){if(te.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 Or={container:"ClientUIContainerControl",textbox:"ClientUITextBoxControl",textwindow:"ClientUITextWindowControl",image:"ClientUIImageControl",button:"ClientUIPresetButtonControl",cursor:"ClientUICursorEventAreaControl",grid:"ClientUIGridScrollerControl",keyhint:"ClientUIKeyHintControl",animation:"ClientUIAnimationControl",fullscreen:"ClientUIFullscreenAnimationControl",reference:"ClientUIReferenceControl"},$o=["alive","Id","prefabIndex","active","activeInHierarchy","visible"],ci=new Set(["active","visible","parent","sizeDeltaX","sizeDeltaY","anchorMinX","anchorMinY","anchorMaxX","anchorMaxY","pivotX","pivotY"]),Do=["name","parent","anchoredPositionX","anchoredPositionY","sizeDeltaX","sizeDeltaY","anchorMinX","anchorMinY","anchorMaxX","anchorMaxY","pivotX","pivotY","localScaleX","localScaleY","localScaleZ","localRotationX","localRotationY","localRotationZ","canControllerFocus"],Go={image:["imageSource","imageId"],grid:["itemCount","scrollDirection","layoutConstraint","layoutConstraintFixedCount"],reference:["referencedPrefabIndex"]},zo={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"]},Vo=["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"],$r=["AddCursorEventListener","RemoveCursorEventListener","RemoveCursorEventListeners","RemoveAllCursorEventListeners","SimulateCursorClick"],Yo={image:["SetImage","SetSoftEdgeWidth","SetFillUnused","SetFillHorizontal","SetFillVertical","SetFillRadial90","SetFillRadial180","SetFillRadial360"],button:$r,cursor:$r,animation:["PlayAnimation","StopAnimation"],grid:["RefreshItems","GetItemIndex","GetItemSize","GetItemSpacing","GetPadding","ScrollToItemAt","GetContentLength"]};function Ji(e,t){return $o.includes(t)||(Go[e.kind]||[]).includes(t)?"ro":Do.includes(t)||(zo[e.kind]||[]).includes(t)?"rw":null}function Dr(e,t){return Vo.includes(t)||(Yo[e.kind]||[]).includes(t)}var Bo={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}},Be=class e{constructor(t,i){this.runtime=t,this.kind=i.kind||"container",this.typeofName=Or[this.kind]||Or.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=Bo[this.kind]||{};for(let[r,a]of Object.entries(n))this[r]===void 0&&(this[r]=i[r]!==void 0?i[r]:a);if(i.children)for(let r of i.children){let a=r instanceof e?r:new e(t,r);this.addChild(a)}}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[this.localRotationX,this.localRotationY,this.localRotationZ]}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)}_removeListener(t,i,n){let r=t.get(i);r&&(t.set(i,r.filter(a=>a!==n)),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 ke(e,t){t(e);for(let i of e.children)ke(i,t)}function Zi(e,t=[],i=""){t.push(`${i}${e.name||"(unnamed)"} [${e.typeofName}] Id=${e.Id}`);for(let n of e.children)Zi(n,t,i+" ");return t}function fi(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 Gr={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-fi(1-e),OutBounce:fi,InOutBounce:e=>e<.5?(1-fi(1-2*e))/2:(1+fi(2*e-1))/2};function zr(e,t){let i=Gr[e]||Gr.Linear;return t<=0?0:t>=1?1:i(t)}function wt(e,t,i,n=255){let r=di(e),a=di(t),o=di(i);return((n==null?255:di(n))<<24|r<<16|a<<8|o)>>>0}function zt(e){let t=e>>>0;return[t>>>16&255,t>>>8&255,t&255,t>>>24&255]}function di(e){let t=Number(e);return Number.isFinite(t)?Math.max(0,Math.min(255,Math.trunc(t))):0}function Vr(e,t,i){let n=zt(e),r=zt(t);return wt(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 Uo=new Set(["fontColor","bgColor","outlineColor","imageColor"]),hi=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}capture(){this.from={},this.to={};for(let[t,i]of Object.entries(this.data)){let n=this.object[t];this.from[t]=n,this.to[t]=this.relative?Number(n)+Number(i):i}}restoreInitial(){this.initialFrom?(this.from={...this.initialFrom},this.to={...this.initialTo}):this.capture()}SetEase(t){return this.easeName=typeof t=="string"?t:t?.Name||"Linear",this}SetRelative(t){return this.relative=!!t,this}Play(){return this._start(!1)}_start(t){return this.playing=!0,this.paused=!1,this.elapsed=0,this.loopIndex=0,this.killed=!1,t&&this.initialFrom?this.restoreInitial():(this.capture(),this.initialFrom={...this.from},this.initialTo={...this.to}),this.runtime.tweens.add(this),this.duration===0&&this.Complete(),this}Pause(){this.paused=!0}Resume(){this.paused=!1}Restart(){return this._start(!0)}Complete(){this.apply(1),this.finish(!0)}Kill(t){t?this.Complete():this.finish(!1)}SetOnComplete(t){return this.onComplete=t,this}SetOnStepComplete(t){return this.onStepComplete=t,this}SetLoops(t){return this.loops=t,this}apply(t){let i=zr(this.easeName,t),n=!1,r=!1;for(let a of Object.keys(this.to)){let o=this.from[a],l=this.to[a];Uo.has(a)&&typeof o=="number"&&typeof l=="number"?this.object[a]=Vr(o,l,i):typeof o=="number"&&typeof l=="number"?this.object[a]=o+(l-o)*i:this.object[a]=i>=1?l:o,n=!0,ci.has(a)&&(r=!0)}n&&typeof this.object?.markPlayDirty=="function"&&this.object.markPlayDirty(r)}step(t){if(!this.playing||this.paused||this.killed)return;this.elapsed+=t;let i=this.duration<=0?1:Math.min(1,this.elapsed/this.duration);if(this.apply(i),i>=1){this.onStepComplete&&this.runtime.safeCall(this.onStepComplete);let n=this.loops<0;if(this.loopIndex++,n||this.loopIndex<this.loops){this.elapsed=Math.max(0,this.elapsed-this.duration),this.relative?this.capture():this.restoreInitial();let r=this.duration<=0?1:Math.min(1,this.elapsed/this.duration);this.apply(r)}else this.finish(!0)}}finish(t){this.playing=!1,this.killed=!0,this.runtime.tweens.delete(this),t&&this.onComplete&&this.runtime.safeCall(this.onComplete)}},mi=class{constructor(t){this.runtime=t,this.steps=[],this.playing=!1,this.paused=!1,this.killed=!1,this.elapsed=0,this.loops=1,this.loopIndex=0,this.onComplete=null,this.onStepComplete=null,this._built=[]}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.playing=!0,this.paused=!1,this.killed=!1,this.elapsed=0,this.loopIndex=0,this._schedule(),this._activateDueEntries(),this.runtime.sequences.add(this),this}_schedule(){let t=0,i=0,n=!1;this._built=[];for(let r of this.steps)if(r.kind==="tween"&&r.parallel){let a=n?i:t;this._built.push({at:a,tween:r.tween}),t=Math.max(t,a+r.tween.duration)}else r.kind==="tween"?(this._built.push({at:t,tween:r.tween}),i=t,n=!0,t+=r.tween.duration):r.kind==="interval"?(i=t,n=!0,t+=r.duration):r.kind==="callback"?this._built.push({at:t,fn:r.fn}):r.kind==="insert"?(this._built.push({at:r.time,tween:r.tween}),t=Math.max(t,r.time+r.tween.duration)):r.kind==="insertCb"&&(this._built.push({at:r.time,fn:r.fn}),t=Math.max(t,r.time));this._end=t,this._fired=new Set}Pause(){this.paused=!0;for(let t of this._built)t.tween&&this._fired.has(t)&&t.tween.Pause()}Resume(){this.paused=!1;for(let t of this._built)t.tween&&this._fired.has(t)&&t.tween.Resume()}Restart(){this.Play()}Complete(){for(let t of this._built)t.tween&&(this._fired.has(t)||t.tween.Play(),t.tween.Complete()),t.fn&&!this._fired.has(t)&&this.runtime.safeCall(t.fn),this._fired.add(t);this.finish(!0)}Kill(t){if(t)this.Complete();else{for(let i of this._built)i.tween&&this._fired.has(i)&&i.tween.Kill(!1);this.finish(!1)}}SetOnComplete(t){return this.onComplete=t,this}SetOnStepComplete(t){return this.onStepComplete=t,this}SetLoops(t){return this.loops=t,this}_activateDueEntries(){for(let t of this._built)this._fired.has(t)||this.elapsed+1e-9<t.at||(this._fired.add(t),t.tween&&t.tween.Play(),t.fn&&this.runtime.safeCall(t.fn))}step(t){!this.playing||this.paused||this.killed||(this.elapsed+=t,this._activateDueEntries(),this.elapsed>=this._end&&(this.onStepComplete&&this.runtime.safeCall(this.onStepComplete),this.loopIndex++,this.loops<0||this.loopIndex<this.loops?(this.elapsed=0,this._schedule()):this.finish(!0)))}finish(t){this.playing=!1,this.killed=!0,this.runtime.sequences.delete(this),t&&this.onComplete&&this.runtime.safeCall(this.onComplete)}};var pi={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"]},Ko=[...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"],Xo=[...Array.from({length:14},(e,t)=>`CraftspersonKey${t+1}`),"SprintKey","JumpKey","InteractKey","NormalAttackKey","CharacterSkill1Key","CharacterSkill2Key","CharacterSkill3Key","CharacterSkill4Key","MenuConfirmKey","MenuBackKey","None"];function Ho(){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}pi.KeyboardKeyCode=Ko;pi.ControllerKeyCode=Xo;pi.KeyEventType=Ho();var Yr=new Map;function tt(e,t){let i=`${e}\0${t}`,n=Yr.get(i);return n||(n={__kind:"EnumItem",Name:t,FullName:`Enum.${e}.${t}`,EnumType:e},Yr.set(i,n)),n}function Qi(e,t){return t==null?t:t.__kind==="EnumItem"?tt(t.EnumType||e,t.Name):typeof t=="string"&&t?tt(e,t):t}function en(){let e={};for(let[t,i]of Object.entries(pi)){let n={};for(let r of i)n[r]=tt(t,r);e[t]=n}return e}var Br={horizontalAlignment:"TextHorizontalAlignment",verticalAlignment:"TextVerticalAlignment",imageSource:"ImageSource",fillType:"ImageFillType",fillHorizontalType:"ImageFillHorizontalType",fillVerticalType:"ImageFillVerticalType",fillRadial90Type:"ImageFillRadial90Type",fillRadialType:"ImageFillRadialType",softEdgeMode:"ImageMaskSoftEdgeMode",layer:"UIAnimationLayer",scrollDirection:"ScrollDirection",layoutConstraint:"ScrollLayoutConstraint"},it=u.LUA_REGISTRYINDEX,Lo=u.LUA_MULTRET,Wo=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 pe(e){return e==null?"":typeof e=="string"?e:e.Name||e.FullName||String(e)}function jo(e){let t=String(e).replace(/\\/g,"/").replace(/\.lua$/i,"");return t.split("/").pop()||t}var gi=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.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=en(),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)}unrefLuaCallback(t){Mr(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 Be?t:new Be(this,t);return this.roots.push(i),ke(i,n=>this.controlsById.set(n.Id,n)),this.mountSpecScripts(t,i),i}mountSpecScripts(t,i){if(t instanceof Be)return;let n=a=>(a.scripts?.length||0)>0||(a.children||[]).some(n);if(!t||!n(t))return;let r=this.lifecyclePhase;try{let a=(o,l)=>{for(let s of o.scripts||[])try{this.mountScript({path:s.path,source:s.source,control:l,scriptMappingId:s.scriptMappingId})}catch(c){let m=c&&c.message?c.message:String(c);this.mountErrors.push(m),this.log("lua-error",m)}let f=o.children||[];for(let s=0;s<f.length;s+=1)a(f[s],l?.children?.[s])};a(t,i)}finally{this.lifecyclePhase=r}}makeCursorEventData({x:t=0,y:i=0,pressX:n=t,pressY:r=i,deltaX:a=t-n,deltaY:o=i-r,dragging:l=!1,touchId:f=-1}={}){let s=this;return{__kind:"CursorEventData",typeofName:"CursorEventData",dragging:l,touchId:f,x:t,y:i,pressX:n,pressY:r,GetUIPos(){return[t,i]},GetPressUIPos(){return[n,r]},GetUIPosDelta(){return[a,o]}}}boot(){let t=this.newLuaThread();this.L=t}installGlobals(t){let i=this;u.lua_pushcfunction(t,n=>{let r=u.lua_gettop(n),a=[];for(let o=1;o<=r;o++)a.push(me(n,i,o));return i.log("info",...a),0}),u.lua_setglobal(t,_("print")),u.lua_pushcfunction(t,n=>{let r=u.lua_gettop(n),a=[];for(let o=1;o<=r;o++)a.push(me(n,i,o));return i.log("error",...a),0}),u.lua_setglobal(t,_("printerr")),u.lua_pushcfunction(t,n=>{if(u.lua_type(n,1)===u.LUA_TTABLE&&!Ye(n,1))return u.lua_pushstring(n,_("table")),1;let r=me(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.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,wt(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,wt(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,[r,a,o,l]=zt(n);return u.lua_pushnumber(i,r),u.lua_pushnumber(i,a),u.lua_pushnumber(i,o),u.lua_pushnumber(i,l),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),a=u.lua_tonumber(i,4),o=u.lua_isnoneornil(i,5)?255:u.lua_tonumber(i,5);return this.pushPackedColor(i,wt(n,r,a,o)),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,a]of Object.entries(n))this.pushEnumItem(t,a),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);et(n,i),te.luaL_setmetatable(t,_("EnumItem"))}pushControl(t,i){let n=u.lua_newuserdata(t,0);et(n,i),te.luaL_setmetatable(t,_("Control"))}pushScript(t,i){u.lua_newtable(t),u.lua_pushlightuserdata(t,qi);let n=u.lua_newuserdata(t,0);et(n,i),u.lua_rawset(t,-3),te.luaL_getmetatable(t,_("Script")),u.lua_setmetatable(t,-2)}pushTween(t,i){let n=u.lua_newuserdata(t,0);et(n,i);let r=i.Append?"TweenSequence":"Tween";te.luaL_setmetatable(t,_(r))}pushCursor(t,i){let n=u.lua_newuserdata(t,0);et(n,i),te.luaL_setmetatable(t,_("CursorEventData"))}pushGameLib(t){let i=this;u.lua_newtable(t);let n={InstantiateClientUIControl:r=>{let a=u.lua_tointeger(r,1),o=be(u.lua_touserdata(r,2)),l=i.instantiate(a,o,i.lifecyclePhase);return l?(i.pushControl(r,l),1):(u.lua_pushnil(r),1)},DestroyClientUIControl:r=>{let a=be(u.lua_touserdata(r,1));return a&&i.destroyControl(a),0},GetClientUIControl:r=>{let a=u.lua_tointeger(r,1),o=i.controlsById.get(a);return o?i.pushControl(r,o):u.lua_pushnil(r),1},FindClientUIRoot:r=>{let a=H(r,1),o=i.roots.find(l=>l.name===a);return o?i.pushControl(r,o):u.lua_pushnil(r),1},GetClientUIRoots:r=>(u.lua_createtable(r,i.roots.length,0),i.roots.forEach((a,o)=>{i.pushControl(r,a),u.lua_rawseti(r,-2,o+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,tt("Device",i.device)),1),SetControllerFocus:r=>(i.focus=be(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 a=be(u.lua_touserdata(r,1))||me(r,i,1),o=me(r,i,2)||{},l=u.lua_tonumber(r,3),f=new hi(i,a,o,l);return i.pushTween(r,f),1},TweenSequence:r=>(i.pushTween(r,new mi(i)),1),ServerSignal:r=>{let a=H(r,1),o=i.makeServerSignal(a),l=u.lua_newuserdata(r,0);return et(l,o),te.luaL_setmetatable(r,_("ServerSignal")),1},GetGlobalCustomVariableValue:r=>{let a=pe(me(r,i,1)),o=H(r,2);return ae(r,i,i.getVar(a,o)),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 a=i.nextAudioId++;return i.audios.set(a,{audioId:u.lua_tointeger(r,1),alive:!0}),u.lua_pushinteger(r,a),1},StopAudio:r=>{let a=u.lua_tointeger(r,1),o=i.audios.get(a);return o&&(o.alive=!1),0},IsAudioAlive:r=>{let a=i.audios.get(u.lua_tointeger(r,1));return u.lua_pushboolean(r,!!(a&&a.alive)),1},GetLanguageType:r=>(i.pushEnumItem(r,tt("LanguageType",i.language)),1),GetStageMode:r=>(i.pushEnumItem(r,tt("StageMode",i.stageMode)),1),IsTestPlay:r=>(u.lua_pushboolean(r,i.testPlay),1),GetText:r=>{let a=H(r,1);return u.lua_pushstring(r,_(a)),1},PrintClientUITree:r=>{for(let a of i.roots)i.log("info",Zi(a).join(`
108
- `));return 0}};for(let[r,a]of Object.entries(n)){let o=Wo[r];if(o===void 0)throw new Error(`missing game arity for ${r}`);u.lua_pushcfunction(t,l=>{let f=u.lua_gettop(l);return f!==o?te.luaL_error(l,_(`bad argument count to '${r}' (${o} expected, got ${f})`)):a(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,a){i.push({type:pe(r),value:a})},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 a=new Be(this,{...r,Id:this.nextControlId(),authoringId:null,prefabIndex:Number(t)});return i.addChild(a),ke(a,o=>this.controlsById.set(o.Id,o)),this.mountSpecScripts(r,a),a}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}`);ke(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=[];ke(t,r=>n.push({control:r,was:r.activeInHierarchy})),t.active=!!i,t.markPlayDirty(!0);for(let r of n){let a=r.control.activeInHierarchy;if(r.was!==a)for(let o of r.control.scripts.slice())a?this.enableScript(o):this.disableScript(o)}}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,a,o){te.luaL_newmetatable(t,_(i)),u.lua_pushcfunction(t,l=>{let f=Ye(l,1)||be(u.lua_touserdata(l,1)),s=H(l,2);if(a[s]&&(!o||o(f,s)))return u.lua_pushcfunction(l,a[s]),1;let c=n(f,s);return c===void 0?(u.lua_pushnil(l),1):(ae(l,this,c),1)}),u.lua_setfield(t,-2,_("__index")),u.lua_pushcfunction(t,l=>{try{let f=Ye(l,1)||be(u.lua_touserdata(l,1)),s=H(l,2),c=me(l,this,3);return r(f,s,c),0}catch(f){return u.lua_pushstring(l,_(String(f.message||f))),u.lua_error(l)}}),u.lua_setfield(t,-2,_("__newindex")),u.lua_pushcfunction(t,l=>{let f=Ye(l,1)||be(u.lua_touserdata(l,1)),s=Ye(l,2)||be(u.lua_touserdata(l,2));return u.lua_pushboolean(l,f===s),1}),u.lua_setfield(t,-2,_("__eq")),u.lua_pop(t,1)}method(t){let i=this;return n=>{let r=Ye(n,1)||be(u.lua_touserdata(n,1)),a=u.lua_gettop(n),o=[];for(let l=2;l<=a;l++)o.push(me(n,i,l));try{let l=t(r,...o);if(l===r)return u.lua_pushvalue(n,1),1;if(l===void 0)return 0;if(Array.isArray(l)&&l.__multi){for(let f of l)ae(n,i,f);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((f,s)=>{i.pushControl(n,f),u.lua_rawseti(n,-2,s+1)}),1;if(l.__scripts)return u.lua_createtable(n,l.length,0),l.forEach((f,s)=>{i.pushScript(n,f),u.lua_rawseti(n,-2,s+1)}),1;if(typeof l[0]=="number"&&l.length<=4){for(let f of l)u.lua_pushnumber(n,f);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,a)=>n.SetAnchoredPosition(r,a)),GetSizeDelta:this.method(n=>n.GetSizeDelta()),SetSizeDelta:this.method((n,r,a)=>n.SetSizeDelta(r,a)),GetAnchorMin:this.method(n=>n.GetAnchorMin()),SetAnchorMin:this.method((n,r,a)=>n.SetAnchorMin(r,a)),GetAnchorMax:this.method(n=>n.GetAnchorMax()),SetAnchorMax:this.method((n,r,a)=>n.SetAnchorMax(r,a)),GetPivot:this.method(n=>n.GetPivot()),SetPivot:this.method((n,r,a)=>n.SetPivot(r,a)),GetLocalScale:this.method(n=>n.GetLocalScale()),SetLocalScale:this.method((n,r,a,o)=>n.SetLocalScale(r,a,o)),GetLocalRotation:this.method(n=>n.GetLocalRotation()),SetLocalRotation:this.method((n,r,a,o)=>n.SetLocalRotation(r,a,o)),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,a)=>n.AddCursorEventListener(pe(r),a)),RemoveCursorEventListener:this.method((n,r,a)=>n.RemoveCursorEventListener(pe(r),a)),RemoveCursorEventListeners:this.method((n,r)=>n.RemoveCursorEventListeners(pe(r))),RemoveAllCursorEventListeners:this.method(n=>n.RemoveAllCursorEventListeners()),SimulateCursorClick:this.method(n=>n.SimulateCursorClick()),AddKeyEventListener:this.method((n,r,a)=>n.AddKeyEventListener(pe(r),a)),RemoveKeyEventListener:this.method((n,r,a)=>n.RemoveKeyEventListener(pe(r),a)),RemoveKeyEventListeners:this.method((n,r)=>n.RemoveKeyEventListeners(pe(r))),RemoveAllKeyEventListeners:this.method(n=>n.RemoveAllKeyEventListeners()),AddNavigationEventListener:this.method((n,r,a)=>n.AddNavigationEventListener(pe(r),a)),RemoveNavigationEventListener:this.method((n,r,a)=>n.RemoveNavigationEventListener(pe(r),a)),RemoveNavigationEventListeners:this.method((n,r)=>n.RemoveNavigationEventListeners(pe(r))),RemoveAllNavigationEventListeners:this.method(n=>n.RemoveAllNavigationEventListeners()),SetControllerNavigation:this.method((n,r,a,o)=>n.SetControllerNavigation(pe(r),a,o)),GetControllerNavigation:this.method((n,r)=>n.GetControllerNavigation(pe(r))),SetImage:this.method((n,r,a)=>n.SetImage(r,a)),SetSoftEdgeWidth:this.method((n,r,a)=>n.SetSoftEdgeWidth(r,a)),SetFillUnused:this.method(n=>n.SetFillUnused()),SetFillHorizontal:this.method((n,r,a)=>n.SetFillHorizontal(r,a)),SetFillVertical:this.method((n,r,a)=>n.SetFillVertical(r,a)),SetFillRadial90:this.method((n,r,a)=>n.SetFillRadial90(r,a)),SetFillRadial180:this.method((n,r,a)=>n.SetFillRadial180(r,a)),SetFillRadial360:this.method((n,r,a)=>n.SetFillRadial360(r,a)),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(!Ji(n,r))return;let a=n[r],o=Br[r];return o?Qi(o,a):a},(n,r,a)=>{if(Ji(n,r)==="rw"){let l=Br[r];n[r]=l?Qi(l,a):a,typeof n.markPlayDirty=="function"&&n.markPlayDirty(ci.has(r));return}throw new Error(`cannot set ${r}, no such field`)},i,Dr)}mtScript(t){let i=this,n=new Set(["alive","scriptMappingId","object","path","enabled"]);this.mtIndexNewindex(t,"Script",(r,a)=>n.has(a)?r[a]:void 0,(r,a,o)=>{if(a==="enabled"){r.enabled=!!o;return}throw new Error(`cannot set ${a}, no such field`)},{GetParam:this.method((r,a)=>Object.prototype.hasOwnProperty.call(r.params,a)?r.params[a]:null),Invoke:this.method((r,a,...o)=>r.invoke(a,o)),EnableUpdate:this.method((r,a)=>{r.updateEnabled=!!a}),RegisterServerSignalHandler:this.method((r,a,o)=>{i.signalHandlers.push({script:r,name:a,fn:o})}),UnregisterServerSignalHandler:this.method((r,a)=>{i.signalHandlers=i.signalHandlers.filter(o=>!(o.script===r&&o.name===a))}),RegisterCustomVariableChangedHandler:this.method((r,a,o,l)=>{i.varHandlers.push({script:r,entityType:pe(a),name:o,fn:l})}),UnregisterCustomVariableChangedHandler:this.method((r,a,o)=>{let l=pe(a);i.varHandlers=i.varHandlers.filter(f=>!(f.script===r&&f.entityType===l&&f.name===o))})})}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=H(t,1),n=this.normalizeRequirePath(i),r=this.requireAliases.get(n)||n;u.lua_rawgeti(t,it,u.LUA_RIDX_MAINTHREAD);let a=u.lua_tothread(t,-1);u.lua_pop(t,1);let o=this.requireCache.get(a);o||(o=new Map,this.requireCache.set(a,o));let l=o.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,it,l.ref),1;let f=this.scriptFiles.get(r);if(f==null)return u.lua_pushstring(t,_(`failed to load script '${n}'`)),u.lua_error(t);let s=u.lua_gettop(t);o.set(r,{loading:!0});try{this.loadModule(t,a,r,f),u.lua_pushvalue(t,-1);let c=te.luaL_ref(t,it);return o.set(r,{ref:c}),1}catch(c){return o.delete(r),u.lua_settop(t,s),u.lua_pushstring(t,_(`failed to load script '${n}': ${c.message||c}`)),u.lua_error(t)}}newLuaThread(){let t=te.luaL_newstate();return Pr.luaL_openlibs(t),Fr(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,te.luaL_ref(t,it)),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&&te.luaL_unref(t,it,n.ref);this.requireCache.delete(t);let i=this.moduleBaseEnvironments.get(t);if(i!=null&&te.luaL_unref(t,it,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);Nr(t)}loadModule(t,i,n,r){let a={__kind:"Script",alive:!0,scriptMappingId:this.resolveScriptMappingId(),object:null,path:n,enabled:!0,updateEnabled:!1,params:{},env:t,invoke(){}},o=String(r).replace(/^\uFEFF/,""),l=ui(o);if(te.luaL_loadbuffer(t,l,l.length,_(`@${n}`))!==Ee)throw new Error(H(t,-1));let s=u.lua_absindex(t,-1);if(u.lua_rawgeti(t,it,this.moduleBaseEnvironments.get(i)),this.copyLuaEnvironment(t,-1),u.lua_remove(t,-2),this.pushScript(t,a),u.lua_setfield(t,-2,_("script")),u.lua_setupvalue(t,s,1),u.lua_pcall(t,0,1,0)!==Ee)throw new Error(H(t,-1))}mountScript({path:t,source:i,control:n,params:r={},scriptMappingId:a=void 0}){this.L||this.boot();let o=this.newLuaThread(),l={__kind:"Script",alive:!0,scriptMappingId:this.resolveScriptMappingId(a),object:n,path:jo(t),enabled:!0,updateEnabled:!1,params:r,env:o,lifecyclePhase:"idle"};l.invoke=(s,c)=>this.invokeOn(o,s,c),n&&n.scripts.push(l),this.mountedScripts.push(l),this.pushScript(o,l),u.lua_setglobal(o,_("script"));let f=this.lifecyclePhase;try{this.lifecyclePhase="OnInit",l.lifecyclePhase="OnInit",this.runChunk(o,i,t);let s=this.callGlobal(o,"OnInit");s&&this.mountErrors.push(s),this.lifecyclePhase="OnEnable",l.lifecyclePhase="OnEnable";let c=this.callGlobal(o,"OnEnable");c&&this.mountErrors.push(c),this.lifecyclePhase="OnStart",l.lifecyclePhase="OnStart";let m=this.callGlobal(o,"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(c=>c!==l),n&&(n.scripts=n.scripts.filter(c=>c!==l)),this.varHandlers=this.varHandlers.filter(c=>c.script!==l),this.signalHandlers=this.signalHandlers.filter(c=>c.script!==l),this.lifecyclePhase=f,o&&o!==this.L&&this.closeTrackedLuaState(o),l.env=null,s}}runChunk(t,i,n){let r=String(i).replace(/^\uFEFF/,""),a=ui(r),o=te.luaL_loadbuffer(t,a,a.length,_(`@${n}`));if(o!==Ee){let f=H(t,-1)||`luaL_loadbuffer status ${o}`;throw u.lua_pop(t,1),new Error(f)}let l=u.lua_pcall(t,0,0,0);if(l!==Ee){let f=H(t,-1)||`lua_pcall status ${l}`;throw u.lua_pop(t,1),new Error(f)}}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=H(t,-1);u.lua_pop(t,1);let a=`${i}: ${r}`;return this.log("lua-error",a),a}}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 a=H(t,-1);u.lua_pop(t,1),this.log("lua-error",`${i}: ${a}`)}}else u.lua_pop(t,1)}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 f of n)ae(t,this,f);if(u.lua_pcall(t,n.length,Lo,0)!==Ee){let f=H(t,-1);throw u.lua_settop(t,r),new Error(f)}let o=u.lua_gettop(t)-r;if(o<=0){u.lua_settop(t,r);return}if(o===1){let f=me(t,this,-1);return u.lua_settop(t,r),f}let l=[];for(let f=1;f<=o;f++)l.push(me(t,this,r+f));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.tweens])n.step(t);for(let n of[...this.sequences])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=(a,o)=>{u.lua_pushcfunction(n,o),u.lua_setfield(n,-2,_(a))};return r("var",a=>(ae(a,this,i.var(H(a,1),H(a,2))),1)),r("logContains",a=>(u.lua_pushboolean(a,i.logContains(H(a,1))),1)),r("control",a=>(ae(a,this,i.control(H(a,1))),1)),r("logs",a=>(ae(a,this,i.logs()),1)),r("signals",a=>(ae(a,this,i.signals(H(a,1))),1)),r("serverLogs",a=>(ae(a,this,i.serverLogs?i.serverLogs():[]),1)),r("serverLogContains",a=>{let o=i.serverLogContains;return u.lua_pushboolean(a,o?!!o(H(a,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 Vt(e){let t=new gi(e);return t.boot(),t}var rt=Object.freeze(Array.from({length:8},(e,t)=>`Player${t+1}`)),rn=Object.freeze(Array.from({length:8},(e,t)=>`Avatar${t+1}`)),qr=Object.freeze(["Level","PlayerSelf","AvatarSelf"]);var tn=Object.freeze([...qr,...rt,...rn]),Jr=Object.freeze(["PlayerSelf","AllPlayers",...rt]),qo=Object.freeze(["Level","PlayerSelf",...rt]),Ur=Object.freeze(["Int","Float","String","Bool","Vector3","Entity","Guid","PrefabId","ConfigId","IntList","FloatList","StringList","BoolList","Vector3List","EntityList","GuidList","PrefabIdList","ConfigIdList","Dict","Struct"]),Jo=-2147483648,Zo=2147483647,Qo=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 Yt(e){return`Player${Number(e)}`}function yi(e){return`Avatar${Number(e)}`}function Kr(e){let t=String(e||"").match(/^(?:Player|Avatar)([1-8])$/);return t?Number(t[1]):0}function nt(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 Pe(e,t=8){let i=nt(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 Xr(){let e={Level:Object.create(null),PlayerSelf:Object.create(null),AvatarSelf:Object.create(null)};for(let t of rt)e[t]=Object.create(null);for(let t of rn)e[t]=Object.create(null);return e}function Zr(e){let t=String(e||"");if(!tn.includes(t))throw new Error(`unknown CustomVariableEntityType: ${e}`);return t}function el(e,t){let i=Zr(e);if(!qo.includes(i))throw new Error(`${t}.entityType must be Level, PlayerSelf, or Player1-8`);return i}function Bt(e){let t=String(e??"");if(!t)throw new Error("custom variable name is required");return t}function bi(e){let t=String(e??"");if(!t)throw new Error("signal name is required");return t}function nn(e){let t=String(e||"PlayerSelf");if(!Jr.includes(t))throw new Error(`unsupported client signal target: ${e}. use PlayerSelf, AllPlayers, or Player1-8`);return t}function Ut(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=Ut(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 ye(e){return e===void 0?null:JSON.parse(JSON.stringify(e))}function Hr(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 Lr(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:Ut(t),value:t}):[]}function tl(e){return String(e?.kind||e?.type||e?.name||e?.id||"")}function vi(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Qr(e,t){if(!vi(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 Wr(e,t){return Qr(e,t)||ye(e)}function il(e,t,i){if(!vi(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 a=el(e.entityType,r);if(!Object.prototype.hasOwnProperty.call(e,"value"))throw new Error(`${r}.value is required`);return{kind:n,entityType:a,name:Bt(e.name),value:Wr(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:nn(e.target),signalName:bi(e.signalName),params:e.params.map((a,o)=>Wr(a,`${r}.params[${o}]`))}}throw new Error(`${r}.kind must be setCustomVariable or sendClientScriptSignal`)}function xt(e){if(e==null)return{version:1,rules:[]};if(!vi(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(!vi(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:bi(i.signalName),actions:i.actions.map((r,a)=>il(r,n,a))}})}}function jr(e,t,{typed:i=!1}={}){let n=Qr(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 ye(r[n.fromSignalParam])}return ye(e)}function nl(e){return e==="Level"?"Level":rt.includes(e)?"PlayerSelf":rn.includes(e)?"AvatarSelf":e}function ea(e={}){let t=Xr(),i=Xr(),n=[],r=[],a=[],o=[],l=Array.from({length:9},()=>null),f=1,s=0,c=Number(e.onlineLatencyMs||0);(!Number.isFinite(c)||c<0)&&(c=0);let m=xt(e.logic),h=nt(e.playerCount),p=Pe(e.viewPlayerIndex,h);function v(y,E){o.push({source:"server",level:String(y||"engine"),text:String(E),time:s})}function w(y){let E=l[y||p],b=Number(E?.clock?.time);Number.isFinite(b)&&(s=b)}function x(y,E,b,I){t[y][E]=b,i[y][E]={type:I||Ut(b)||i[y][E]?.type||""}}function k(y,E,b){return typeof b!="number"||!Number.isInteger(b)?{ok:!0,value:b}:b>=Jo&&b<=Zo?{ok:!0,value:b}:(v("engine",`Int custom variable ${y}.${E} out of range ${b}; keeping previous legal value`),{ok:!1,value:t[y][E]})}function $(y,E){let b=Zr(y),I=E||p;return b==="PlayerSelf"?Yt(I):b==="AvatarSelf"?yi(I):b}function O(y,E){let b=nl(y);if(y==="Level"){for(let S=1;S<=h;S+=1){let P=l[S];P&&typeof P.notifyVarHandlers=="function"&&P.notifyVarHandlers("Level",E)}return}let I=Kr(y);if(!I)return;let M=l[I];M&&typeof M.notifyVarHandlers=="function"&&M.notifyVarHandlers(b,E)}function Y(y,E){let b=nn(y);return b==="AllPlayers"?Array.from({length:h},(I,M)=>M+1):b==="PlayerSelf"?[E||p]:[Kr(b)]}function L(y){for(let E of m.rules)if(E.signalName===y.name)for(let b of E.actions){if(b.kind==="setCustomVariable"){let I=jr(b.value,y);N.setVar(b.entityType,b.name,I,{type:b.variableType,playerIndex:y.playerIndex}),v("info",`logic ${E.id}: set ${b.entityType}.${b.name}`);continue}if(b.kind==="sendClientScriptSignal"){let I=b.params.map(M=>jr(M,y,{typed:!0}));N.sendToClient(b.signalName,I,{target:b.target,playerIndex:y.playerIndex}),v("info",`logic ${E.id}: sent ${b.signalName} to ${b.target}`)}}}function Z(y,E){y&&(y.serverBridge={getVar:(b,I)=>N.getVar(b,I,{playerIndex:E}),setVar:(b,I,M)=>N.setVar(b,I,M,{playerIndex:E}),receiveFromClient:(b,I)=>N.receiveFromClient(b,I,{playerIndex:E})})}function W(y){y&&(y.serverBridge=null)}let N={ENTITY_TYPES:qr,ALL_ENTITY_TYPES:tn,CLIENT_SIGNAL_TARGETS:Jr,get clock(){return s},get playerCount(){return h},get viewPlayerIndex(){return p},setClock(y){s=Number(y)||0},setPlayerCount(y){return h=nt(y),p>h&&(p=h),h},setViewPlayerIndex(y){return p=Pe(y,h),p},log(y,E){v(y,E)},defineVar(y,E,b={},{playerIndex:I}={}){let M=$(y,I),S=Bt(E);if(Object.prototype.hasOwnProperty.call(t[M],S))throw new Error(`custom variable already exists: ${M}.${S}`);let P=b.type?String(b.type):Ut(b.value??b.defaultValue);if(P&&!Ur.includes(P))throw new Error(`unsupported custom variable type: ${P}`);let G=b.value!==void 0?b.value:b.defaultValue!==void 0?b.defaultValue:null;return x(M,S,G,P),N.getVar(M,S)},getVar(y,E,{playerIndex:b}={}){let I=$(y,b),M=Bt(E);if(!Object.prototype.hasOwnProperty.call(t[I],M)){v("engine",`GetGlobalCustomVariableValue missing ${I}.${M}; returning nil (simulator policy)`);return}return t[I][M]},setVar(y,E,b,{notify:I=!0,type:M,playerIndex:S}={}){let P=$(y,S),G=Bt(E),z=M||i[P][G]?.type||Ut(b);if(z&&!Ur.includes(z)&&z!=="")throw new Error(`unsupported custom variable type: ${z}`);let ne=b;if(!((z==="Int"||z===""&&typeof b=="number"&&Number.isInteger(b))&&(ne=k(P,G,b).value,ne===void 0)))return x(P,G,ne,z),I&&O(P,G),ne},listVars(y){let E=y?[$(y)]:["Level",...Array.from({length:h},(I,M)=>Yt(M+1)),...Array.from({length:h},(I,M)=>yi(M+1))],b=[];for(let I of E)for(let M of Object.keys(t[I]))b.push({entityType:I,name:M,type:i[I][M]?.type||"",value:ye(t[I][M])});return b},receiveFromClient(y,E=[],{playerIndex:b}={}){let I=Pe(b||p,h);w(I);let M=bi(y),S={id:f++,direction:"inbound",name:M,params:Lr(E),values:Hr(E),time:s,playerIndex:I,from:Yt(I)};return n.push(S),L(S),S},sendToClient(y,E=[],{target:b="PlayerSelf",playerIndex:I}={}){let M=bi(y),S=nn(b),G=Y(S,I||p),z={id:f++,direction:"outbound",name:M,params:Lr(E),values:Hr(E),time:s,target:S,players:G,deliverAt:s+c/1e3,delivered:!1};return r.push(z),c===0?N.deliver(z):a.push(z),z},getLogic(){return ye(m)},setLogic(y){return m=xt(y),N.getLogic()},deliver(y){if(!y||y.delivered)return;y.delivered=!0;let E=Array.isArray(y.players)&&y.players.length?y.players:Y(y.target);for(let b of E){let I=l[b];I&&typeof I.sendClientSignal=="function"&&I.sendClientSignal(y.name,y.values)}},flush(y){y!==void 0&&(s=Number(y)||0);let E=[];for(let b=a.length-1;b>=0;b-=1)a[b].deliverAt<=s&&E.push(a.splice(b,1)[0]);E.sort((b,I)=>b.id-I.id);for(let b of E)N.deliver(b);return E},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 E of y.nodes||[]){let b=tl(E);if(!Qo.has(b))throw new Error(`unsupported server node: ${b||JSON.stringify(E)}. v1 only supports custom variables and signals`)}if(y.onlineLatencyMs!==void 0){let E=Number(y.onlineLatencyMs);if(!Number.isFinite(E)||E<0)throw new Error("onlineLatencyMs must be a non-negative finite number");c=E}y.playerCount!==void 0&&N.setPlayerCount(y.playerCount),y.viewPlayerIndex!==void 0&&N.setViewPlayerIndex(y.viewPlayerIndex),(y.logic!==void 0||y.serverLogic!==void 0)&&N.setLogic(y.logic??y.serverLogic);for(let E of y.vars||[]){let b=$(E.entityType),I=Bt(E.name);Object.prototype.hasOwnProperty.call(t[b],I)?N.setVar(b,I,E.value??E.defaultValue,{notify:!1,type:E.type}):N.defineVar(b,I,E)}}},attachRuntime(y,{playerIndex:E=1}={}){let b=Pe(E,8);return l[b]&&l[b]!==y&&W(l[b]),l[b]=y||null,Z(l[b],b),N},attachRuntimes(y){N.detachRuntime();let E=Array.isArray(y)?y:[];for(let b=0;b<E.length&&b<8;b+=1)l[b+1]=E[b]||null,Z(l[b+1],b+1);return N},detachRuntime(){for(let y=1;y<=8;y+=1)W(l[y]),l[y]=null},snapshot(){let y=Yt(p),E=yi(p),b={Level:{},PlayerSelf:{},AvatarSelf:{}};for(let I of Object.keys(t.Level))b.Level[I]={type:i.Level[I]?.type||"",value:ye(t.Level[I])};for(let I of Object.keys(t[y]))b.PlayerSelf[I]={type:i[y][I]?.type||"",value:ye(t[y][I])};for(let I of Object.keys(t[E]))b.AvatarSelf[I]={type:i[E][I]?.type||"",value:ye(t[E][I])};for(let I=1;I<=h;I+=1){let M=Yt(I),S=yi(I);b[M]={},b[S]={};for(let P of Object.keys(t[M]))b[M][P]={type:i[M][P]?.type||"",value:ye(t[M][P])};for(let P of Object.keys(t[S]))b[S][P]={type:i[S][P]?.type||"",value:ye(t[S][P])}}return{clock:s,onlineLatencyMs:c,playerCount:h,viewPlayerIndex:p,logic:N.getLogic(),vars:b,inbound:n.map(I=>({id:I.id,name:I.name,params:ye(I.params),values:ye(I.values),time:I.time,playerIndex:I.playerIndex,from:I.from})),outbound:r.map(I=>({id:I.id,name:I.name,params:ye(I.params),values:ye(I.values),time:I.time,target:I.target,players:Array.isArray(I.players)?I.players.slice():[],deliverAt:I.deliverAt,delivered:!!I.delivered})),logs:o.map(I=>({source:"server",level:I.level,text:I.text,time:I.time}))}},reset(){for(let y of tn){for(let E of Object.keys(t[y]))delete t[y][E];for(let E of Object.keys(i[y]))delete i[y][E]}n.length=0,r.length=0,a.length=0,o.length=0,f=1,s=0},destroy(){N.detachRuntime(),N.reset()}};e.config&&N.loadConfig(e.config);for(let y of e.vars||[])N.defineVar(y.entityType,y.name,y);return N}var rl={container:"container",textbox:"textbox",image:"image",button:"button",cursor:"cursor",grid:"grid",reference:"reference",textwindow:"textwindow",keyhint:"keyhint",animation:"animation",fullscreen:"fullscreen"};function an(e,t,i=null){let n=Ge(e.transformByPlatform,t),r={authoringId:e.id,kind:rl[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(o=>an(o,t,i))},a=i?.get(e.id);return a?.length&&(r.scripts=a.map(o=>{let l=Number(o.guid);return{path:o.path||o.id,source:o.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 on(e,t=[],i=""){let n=i&&J[i]?i:e.canvasId,r=J[n],a=Ot(e),o=new Map;for(let f of t){if(!f.controlId)continue;let s=o.get(f.controlId)||[];s.push(f),o.set(f.controlId,s)}let l=e.meta?.assetType==="client-control-template"?(e.root.children||[]).map(f=>an(f,n,o)):[];return{canvasId:n,platform:r.platform,device:r.luaDevice,canvasWidth:r.width,canvasHeight:r.height,root:an(a,n,o),templates:l}}var Si="qxqy-autotest";var at=.03333333333333333,al=new Set(["pointer","key","click","pause","resume","serverSet","serverSend","view"]),ol=new Set(["log","control","var","signal","tree","lua"]);function Kt(e,t){let i=Number(e);if(!Number.isFinite(i))throw new Error(`${t} must be a finite number`);return i}function ln(e){return JSON.parse(JSON.stringify(e??null))}function Ci(e,t){if(!e||typeof e!="object")throw new Error(`events[${t}] must be an object`);let i=String(e.kind||e.do||"");if(!al.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=Kt(n.x,"pointer.x"),n.y=Kt(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:Kt(e.t??0,"event.t"),source:String(e.source||"user"),kind:i,payload:n}}function sn(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(!ol.has(i))throw new Error(`unsupported assert kind: ${i||"(empty)"}`);let n={kind:i};if(e.at!==void 0&&(n.at=Kt(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=ln(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=ln(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=ln(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 ta(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+=Kt(r.dt??at,"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(Ci({...r,kind:r.do,t},i.length));continue}if(r.assert||r.check||r.kind){n.push(sn({...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:at}}function Xt(e){if(Array.isArray(e)){let n=ta(e);return{format:Si,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=ta(e.queue||e.steps);return{format:Si,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)=>Ci(n,r)),i=(e.asserts||[]).map((n,r)=>sn(n,r));return t.sort((n,r)=>n.t-r.t||0),{format:Si,version:1,name:String(e.name||""),dt:Number(e.dt)>0?Number(e.dt):at,playerCount:Number(e.playerCount)>0?Number(e.playerCount):1,events:t,asserts:i}}function ia(e,t={}){let i=(e||[]).map((n,r)=>Ci(n,r));return{format:Si,version:1,name:String(t.name||""),dt:Number(t.dt)>0?Number(t.dt):at,playerCount:Number(t.playerCount)>0?Number(t.playerCount):1,events:i,asserts:(t.asserts||[]).map((n,r)=>sn(n,r))}}function na(e,t,i){if(!e)return null;let n=Ci({...t,t:t.t??i??0},e.events.length);return e.events.push(n),n}var ll=Object.freeze(Object.values(J).map(e=>Object.freeze({id:e.id,label:e.label,platform:e.platform,width:e.width,height:e.height})));function dn(e){let t=he({width:e.runtime.canvasWidth,height:e.runtime.canvasHeight}),i=new Map;function n(r,a,o){let l=Ae(a,r);l.activeInHierarchy=o&&r.active!==!1,i.set(r.Id,l);let f=l.activeInHierarchy;for(let s of r.children)n(s,l,f)}for(let r of e.runtime.roots)n(r,t,!0);return i}function sl(e,t=dn(e)){let i=new Map;function n(r,a){let o=t.get(r.Id);if(!o)return;let l=Ft(a,o,r);i.set(r.Id,l);for(let f of r.children)n(f,l)}for(let r of e.runtime.roots)n(r,vt());return i}function aa(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"?yt[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=>aa(n,t))}}function ul(){return{pointerDownControl:null,pointerDownPosition:null,pointerLastPosition:null,pointerDragging:!1,pointerHoverControl:null,hoveredControl:null,selectedControl:null,stateRestores:new Map,viewCache:null}}function cl(e,t,i){let n=Vt({canvasWidth:e.canvasWidth,canvasHeight:e.canvasHeight,device:e.device});for(let r of[...e.templates||[],...t?.templates||[]])Number.isSafeInteger(r.prefabIndex)&&r.prefabIndex>0&&n.registerTemplate(r.prefabIndex,r);for(let r of i){let a=r.path||r.id,o=r.source||"";a&&o&&n.registerScriptFile(a,o)}return n}var fl=["pointerDownControl","pointerDownPosition","pointerLastPosition","pointerDragging","pointerHoverControl","hoveredControl","selectedControl","stateRestores","viewCache"];function dl(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 oa(e,{templatesProject:t=null,scripts:i=[],sceneScripts:n=null,templateScripts:r=null,serverConfig:a=null,canvasId:o="",playerCount:l=1,viewPlayerIndex:f=1}={}){let s=n||i,c=r||i,m=on(e,s,o),h=t?on(t,c,o):null,p=nt(l),v=Pe(f,p),w=ea({playerCount:p,viewPlayerIndex:v});a&&w.loadConfig({...a,playerCount:p,viewPlayerIndex:v});let x=[];for(let O=0;O<p;O+=1)x.push(cl(m,h,i));w.attachRuntimes(x);for(let O of x)O.addRoot(m.root);let k={runtimes:x,views:x.map(()=>ul()),playerCount:p,viewPlayerIndex:v,server:w,compiled:m,mountError:x.find(O=>O.mountErrors[0])?.mountErrors[0]||null,debugPaused:!1,history:{events:[]},recording:!0};dl(k);let $=k.viewPlayerIndex;for(let O=1;O<=p;O+=1)k.viewPlayerIndex=O,xl(k);return k.viewPlayerIndex=$,k}function hn(e,t){if(!e)throw new Error("play session has not started");let i=Pe(t,e.playerCount);return i===e.viewPlayerIndex||(Ue(e,{kind:"view",payload:{playerIndex:i}}),e.viewPlayerIndex=i,e.viewCache=null,e.server&&e.server.setViewPlayerIndex(i)),i}function Ue(e,t){!e?.recording||!e.history||na(e.history,{...t,source:t.source||"user"},e.runtime.clock.time)}function hl(e){return e?.history?.events||[]}var mn=new Set(["image","textbox","textwindow","button"]);function ml(e,t){let i=We(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 ot(e){return typeof e=="string"?e:e?.Name}function la(e){return{fillType:ot(e.fillType),fillHorizontalType:ot(e.fillHorizontalType),fillVerticalType:ot(e.fillVerticalType),fillAmount:e.fillAmount}}function pl(e,t,i){let n=Math.abs(t.width*i.scaleX),r=Math.abs(t.height*i.scaleY),a={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"&&(a.primitive=yt[e.imageId]||"missing",a.imageColor=e.imageColor,a.imageId=e.imageId,Object.assign(a,la(e))),(e.kind==="textbox"||e.kind==="textwindow")&&(a.text=e.text??"",a.fontSize=e.fontSize,a.fontColor=e.fontColor,a.bgColor=e.bgColor,a.enableOutline=e.enableOutline===!0,a.outlineColor=e.outlineColor,a.horizontalAlignment=ot(e.horizontalAlignment),a.verticalAlignment=ot(e.verticalAlignment)),a}function gl(e,t=dn(e)){let i=[],n=sl(e,t);function r(a){let o=t.get(a.Id);if(!o||a.visible===!1||!o.activeInHierarchy)return;let l=n.get(a.Id);if(!l)return;let f=ml(o,l);mn.has(a.kind)&&i.push(pl(a,o,f));let s=a.children||[];for(let c=s.length-1;c>=0;c-=1)r(s[c])}for(let a of e.runtime.roots)r(a);return i}function yl(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=yt[e.imageId]||"missing",i.imageColor=e.imageColor,i.imageId=e.imageId,Object.assign(i,la(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=ot(e.horizontalAlignment),i.verticalAlignment=ot(e.verticalAlignment)),i}function bl(e,t,i){let n=ki(e,t),r=We(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 sa(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 ua(e,t,i,n,r,a){return{id:e.Id,parent:t,z:r,group:a>=16,matrix:bl(n,e,i),...yl(e,n)}}function vl(e){let t=he({width:e.runtime.canvasWidth,height:e.runtime.canvasHeight}),i=new Set,n=new Map,r=new Map;function a(f,s,c){let m=Ae(s,f);if(m.activeInHierarchy=c&&f.active!==!1,r.set(f.Id,m),f.visible===!1||!m.activeInHierarchy)return!1;let h=f.children||[],p=mn.has(f.kind),v=0;for(let w=0;w<h.length;w+=1)a(h[w],m,m.activeInHierarchy)&&(p=!0,v+=1);return p?(i.add(f.Id),n.set(f.Id,v),!0):!1}function o(f,s,c,m){if(!i.has(f.Id))return;let h=r.get(f.Id);l.push(ua(f,s,c,h,m,n.get(f.Id)||0));let p=f.children||[];for(let v=0;v<p.length;v+=1)o(p[v],f.Id,h,v)}let l=[];for(let f=0;f<e.runtime.roots.length;f+=1)a(e.runtime.roots[f],t,!0),o(e.runtime.roots[f],null,null,f);return{nodes:l,childCounts:n}}function fn(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)fn(i[n])}function Sl(e,t){let i=he({width:e.runtime.canvasWidth,height:e.runtime.canvasHeight}),n=[],r=[],a=t.count,o=e.runtime._playRemoved||[];for(let s=0;s<o.length;s+=1){let c=o[s];t.fingerprints.has(c)&&(r.push(c),t.fingerprints.delete(c),t.childCounts.delete(c),a-=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),a-=1);let c=s.children;for(let m=0;m<c.length;m+=1)l(c[m])}function f(s,c,m,h,p,v){let w=v||s._playDeepDirty===!0,x=w||s._playDirty===!0,k=w||s._playChildDirty===!0;if(!x&&!k)return;if(!(p&&s.active!==!1)||s.visible===!1){l(s);return}let O=Ae(c,s),Y=t.childCounts.get(s.Id)||0;if(k){Y=0;let E=s.children;for(let b=0;b<E.length;b+=1)f(E[b],O,s.Id,b,!0,w),t.fingerprints.has(E[b].Id)&&(Y+=1)}if(!(mn.has(s.kind)||Y>0)){t.fingerprints.has(s.Id)&&(r.push(s.Id),t.fingerprints.delete(s.Id),t.childCounts.delete(s.Id),a-=1);return}let Z=t.childCounts.get(s.Id);t.childCounts.set(s.Id,Y);let W=Y>=16!=(Z||0)>=16;if(!x&&!W&&t.fingerprints.has(s.Id))return;let N=ua(s,m,c===i?null:c,O,h,Y),y=sa(N);t.fingerprints.get(N.id)!==y&&(t.fingerprints.has(N.id)||(a+=1),t.fingerprints.set(N.id,y),n.push(N))}for(let s=0;s<e.runtime.roots.length;s+=1)f(e.runtime.roots[s],i,null,s,!0,!1);return t.count=a,{changed:n,removed:r,count:a}}function Cl(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:f,childCounts:s}=vl(e);i.rev+=1,i.fingerprints=new Map(f.map(c=>[c.id,sa(c)])),i.childCounts=s,i.count=f.length;for(let c of e.runtime.roots)fn(c);return{format:"tree-v1",revision:i.rev,reset:!0,count:f.length,nodes:f}}let{changed:a,removed:o,count:l}=Sl(e,i);i.rev+=1;for(let f of e.runtime.roots)fn(f);return{format:"tree-v1",revision:i.rev,reset:!1,count:l,changed:a,removed:o}}function pn(e,{inspect:t=!1,view:i=!1,paint:n=!1,sceneRev:r,compact:a=!1}={}){let o=e.runtime,l=e.compiled,[f,s]=[o.canvasWidth,o.canvasHeight];e.server&&e.server.setClock(o.clock.time);let c=a?o.logs.slice(-100):o.logs,m=hl(e),h=e.server?e.server.snapshot():{vars:{},inbound:[],outbound:[],logs:[]};a&&(h.inbound=h.inbound.slice(-100),h.outbound=h.outbound.slice(-100),h.logs=h.logs.slice(-100));let p={canvasId:l.canvasId,platform:l.platform,device:o.device,canvasWidth:f,canvasHeight:s,canvasPresets:ll,playerCount:e.playerCount||1,viewPlayerIndex:e.viewPlayerIndex||1,players:Array.from({length:e.playerCount||1},(v,w)=>({index:w+1,label:`\u73A9\u5BB6${w+1}`,entityType:`Player${w+1}`})),time:o.clock.time,frame:o.clock.frame,paused:!!e.debugPaused,levelTimePaused:!!o.clock.paused,mountError:e.mountError||o.mountErrors[0]||null,logs:c.map(v=>({source:"client",level:v.level,text:v.text,time:v.time})),tree:[],paint:[],scene:null,server:h,history:(a?m.slice(-100):m).map(v=>({t:v.t,source:v.source||"user",kind:v.kind,payload:v.payload||{}}))};if(t||n){let v=dn(e);t&&(p.tree=o.roots.map(w=>aa(w,v))),n&&(p.paint=gl(e,v))}return i&&(p.scene=Cl(e,r)),bt(p),p}function Ii(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 gn(e,t){Ue(e,{kind:"key",payload:{typeName:String(t)}}),e.runtime.injectKey(t)}function Il(e,t){let i=null;for(let n of e.runtime.roots)ke(n,r=>{!i&&r.name===t&&(i=r)});return i}function yn(e,t){Ue(e,{kind:"click",payload:{name:String(t)}});let i=Il(e,t);i&&bn(i)&&(i.kind==="button"||i.kind==="cursor")&&i.SimulateCursorClick()}function wl(e,t){return!e||!t?null:e.children.find(i=>i.authoringId===t||i.Id===t)||null}var ca={unavailable:"unavailableChildId",hover:"hoverChildId",pressed:"pressedChildId",selected:"selectedChildId"};function fa(e,t){let i=[];for(let[n,r]of Object.entries(ca)){let a=t[r]?wl(t,t[r]):null;a&&i.push({state:n,child:a})}return i}function xl(e){for(let t of e.runtime.roots)ke(t,i=>{if(i.kind==="button"){for(let{child:n}of fa(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);Lt(e,i)}})}function Lt(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 fa(e,t))n.child.active=!0,n.child.visible=n.state===i,typeof n.child.markPlayDirty=="function"&&n.child.markPlayDirty(!0)}function un(e){if(!e)return null;let t=e.parent;return t?.kind==="button"&&Object.values(ca).map(n=>t[n]).filter(Boolean).includes(e.authoringId)?t:e}function bn(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 da(e){return e.kind==="container"||e.kind==="grid"||e.kind==="textwindow"||e.kind==="reference"||e.kind==="button"}function ha(e,t){let i=e.Id,n=t.get(i);if(n!==void 0)return n;let r=bn(e);if(!r&&da(e)){let a=e.children;for(let o=0;o<a.length;o+=1)if(ha(a[o],t)){r=!0;break}}return t.set(i,r),r}function cn(e,t,i){let n=he({width:e.runtime.canvasWidth,height:e.runtime.canvasHeight}),r=new Map;function a(l,f,s,c){if(!c||l.active===!1||l.visible===!1||!ha(l,r))return null;let m=Ae(f,l),h=Ft(s,m,l),p=ii(h);if(!p)return null;let v=We(p,t,i);if(v.x<m.left||v.x>m.right||v.y<m.bottom||v.y>m.top)return null;if(da(l))for(let w=0;w<l.children.length;w+=1){let x=a(l.children[w],m,h,!0);if(x)return x}return bn(l)?l:null}let o=vt();for(let l=e.runtime.roots.length-1;l>=0;l-=1){let f=a(e.runtime.roots[l],n,o,!0);if(f)return f}return null}function Ht(e,t,i,{dragging:n=!1,press:r=null,previous:a=null}={}){let o=r||{x:t,y:i},l=a||{x:t,y:i};return e.runtime.makeCursorEventData({x:t,y:i,pressX:o.x,pressY:o.y,deltaX:t-l.x,deltaY:i-l.y,dragging:n})}function ra(e,t,i){t.pressed=i,typeof t.markPlayDirty=="function"&&t.markPlayDirty(),Lt(e,t)}function Wt(e,t,i,n,r={}){let a=Number(i),o=Number(n);if(!Number.isFinite(a)||!Number.isFinite(o))throw new Error("pointer coordinates must be finite");if(e.runtime.cursor.x=a,e.runtime.cursor.y=o,r.silent||Ue(e,{kind:"pointer",payload:{type:t,x:a,y:o}}),t==="move"){let l=e.pointerLastPosition||{x:a,y:o},f=e.pointerHoverControl,s=un(cn(e,a,o)),c=Ht(e,a,o,{previous:l});f&&f!==s&&e.runtime.injectCursor(f,"CursorExit",c),s&&f!==s&&e.runtime.injectCursor(s,"CursorEnter",c),e.pointerHoverControl=s;let m=e.hoveredControl;e.hoveredControl=s?.kind==="button"?s:null,m&&m!==e.hoveredControl&&Lt(e,m),e.hoveredControl&&Lt(e,e.hoveredControl);let h=e.pointerDownControl;if(h){let p=e.pointerDownPosition||l,v=a!==l.x||o!==l.y;!e.pointerDragging&&v&&(e.runtime.injectCursor(h,"CursorBeginDrag",Ht(e,a,o,{press:p,previous:l,dragging:!1})),e.pointerDragging=!0),e.pointerDragging&&e.runtime.injectCursor(h,"CursorDrag",Ht(e,a,o,{press:p,previous:l,dragging:!0}))}return e.pointerLastPosition={x:a,y:o},s}if(t==="down"){let l=un(cn(e,a,o));return e.pointerDownControl=l,e.pointerDownPosition={x:a,y:o},e.pointerLastPosition={x:a,y:o},e.pointerDragging=!1,l&&(ra(e,l,!0),e.runtime.injectCursor(l,"CursorDown",Ht(e,a,o))),l}if(t==="up"){let l=e.pointerDownControl,f=un(cn(e,a,o));if(l){let s=Ht(e,a,o,{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(f===l){e.runtime.injectCursor(l,"CursorClick",s);let c=e.selectedControl;e.selectedControl=l.kind==="button"?l:null,c&&c!==e.selectedControl&&Lt(e,c)}ra(e,l,!1)}return e.pointerDownControl=null,e.pointerDownPosition=null,e.pointerLastPosition={x:a,y:o},e.pointerDragging=!1,f}if(t==="click")return Wt(e,"down",a,o,{silent:!0}),Wt(e,"up",a,o,{silent:!0});throw new Error(`unknown pointer type ${t}`)}function vn(e,t,i,n){if(!e?.server)throw new Error("play session has no server");return Ue(e,{kind:"serverSet",payload:{entityType:t,name:i,value:n,playerIndex:e.viewPlayerIndex}}),e.server.setVar(t,i,n,{playerIndex:e.viewPlayerIndex})}function ma(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 Sn(e,t,i=[],n="PlayerSelf"){if(!e?.server)throw new Error("play session has no server");return Ue(e,{kind:"serverSend",payload:{name:t,params:i,target:n,playerIndex:e.viewPlayerIndex}}),e.server.sendToClient(t,i,{target:n,playerIndex:e.viewPlayerIndex})}function wi(e){return{snapshot:t=>pn(e,t),step:t=>Ii(e,t),pointer:(t,i,n)=>Wt(e,t,i,n),key:t=>gn(e,t),click:t=>yn(e,t),view:t=>hn(e,t),pause:()=>{Ue(e,{kind:"pause",payload:{}}),e.debugPaused=!0},resume:()=>{Ue(e,{kind:"resume",payload:{}}),e.debugPaused=!1},serverSet:(t,i,n)=>vn(e,t,i,n),serverSend:(t,i,n)=>Sn(e,t,i,n)}}function Cn(e){e?.server&&e.server.destroy();let t=e?.runtimes||(e?.runtime?[e.runtime]:[]);for(let i of t)i.destroy()}function In(e,t){return JSON.stringify(e)===JSON.stringify(t)}function pa(e,t){for(let i of e||[])t(i),i.children?.length&&pa(i.children,t)}function wn(e,{id:t,name:i}){let n=null;return pa(e,r=>{n||(t&&String(r.id)===String(t)||!t&&i&&r.name===i)&&(n=r)}),n}function El(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 kl(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=wn(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 Al(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=wn(t.tree,e);if(!i)return{ok:!1,actual:null,expected:e.equals,message:`control not found: ${e.id||e.name}`};let n=El(i,e.field);return In(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 In(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||In(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=!!wn(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 _l(e,t){let i=Vt();try{return i.evalQueryScript(e,kl(t)),{ok:!0,actual:!0}}catch(n){return{ok:!1,message:n?.message||String(n)}}finally{i.destroy()}}function ga(e,t){return e.kind==="lua"?_l(e.source,t):Al(e,t)}function Pl(e,t){let i=t>0?t:at;return Math.round((e+i)*1e9)/1e9}function Tl(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 Rl(e,t){let i=ga(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 ya(e,t){let i=Xt(t),n=i.events.slice().sort((k,$)=>k.t-$.t),r=i.asserts.slice(),a=i.dt||at,o=n.reduce((k,$)=>Math.max(k,$.t),0),l=r.reduce((k,$)=>Math.max(k,Number($.at||0)),0),f=Math.max(o,l),s=0,c=[],m=0,h=r.some(k=>k.kind==="control"||k.kind==="tree"||k.kind==="lua"),p=e.snapshot({inspect:h}),v=()=>{for(;s<n.length&&n[s].t<=m+1e-9;)Tl(e,n[s]),s+=1,p=e.snapshot({inspect:h})},w=()=>{for(let k of r)if(!k._done&&Number(k.at||0)<=m+1e-9){let $=Rl(k,p);if(c.push($),k._done=!0,!$.ok)return{passed:!1,failedAt:m,frame:p.frame||0,results:c,snapshot:p}}return null};v();let x=w();if(x)return xn(i,x);for(;m+1e-9<f;){e.step(a),m=Pl(m,a),p=e.snapshot({inspect:h}),v();let k=w();if(k)return xn(i,k)}return xn(i,{passed:c.every(k=>k.ok),failedAt:null,frame:p.frame||0,results:c,snapshot:p})}function xn(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 En(e){return Array.isArray(e)?e.slice():[]}var $l={Level:"\u5173\u5361",PlayerSelf:"\u5F53\u524D\u73A9\u5BB6",AvatarSelf:"\u5F53\u524D\u89D2\u8272",...Object.fromEntries(rt.map((e,t)=>[e,`\u73A9\u5BB6${t+1}`])),...Object.fromEntries(Array.from({length:8},(e,t)=>[`Avatar${t+1}`,`\u89D2\u8272${t+1}`]))};function Dl(e,t=1){let i=e?.vars||{},n=[],r=Number(t)>0?Number(t):1,a=["Level","PlayerSelf","AvatarSelf"];if(r>1)for(let l=1;l<=r;l+=1)a.push(`Player${l}`,`Avatar${l}`);let o=new Set;for(let l of a){if(o.has(l)||!i[l])continue;o.add(l);let f=i[l]||{};for(let s of Object.keys(f))n.push(D({entityType:l,entityLabel:$l[l]||l,name:s,type:f[s]?.type||"",value:f[s]?.value??null}))}return n}var st="qxqy-simulator-save",Gl="qxqy-simulator-scripts",ie="server-control-template",V="client-control-template",Sa={[ie]:"\u670D\u52A1\u5668\u63A7\u4EF6\u6A21\u677F",[V]:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F"};function lt(e){return e===V?"client":"server"}function zl(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 xi(e){let t=String(e?.controlAsset||""),i=zl(e);return{id:String(i||e?.id||""),guid:i,path:String(e?.path||""),source:String(e?.source||""),controlId:String(e?.controlId||""),controlAsset:t===V||t==="client"?V:t===ie||t==="server"?ie:""}}function Ca(e){let t=[],i=(n,r="")=>{if(n&&(n.path||n.source)){let a=xi(n);t.push(r?{...a,controlAsset:r}:a)}};if(Array.isArray(e?.assets?.scripts)){for(let n of e.assets.scripts)n&&(n.path||n.source)&&t.push(xi(n));return t}if(i(e?.assets?.server?.script,ie),i(e?.assets?.client?.script,V),e&&e.format!==st){i(e?.script);for(let n of e?.scripts||[])i(n)}return t}function kn(e){return xe(e===V?Qe():De())}var Vl="\u672A\u7ED1\u5B9A",Et="\u672A\u547D\u540D\u5B58\u6863",Yl="\u672A\u547D\u540D\u754C\u9762";function Bl(e){let t=e;for(let i=0;i<8;i++){if(jt(ba(t,"simulator","studio"))&&jt(ba(t,"lua")))return t;let n=Fl(t);if(n===t)break;t=n}return e}function Ul(e){return e?{name:kt(e),path:e,bound:!0}:{name:Vl,path:"",bound:!1}}function Kl(e,t=process.cwd()){if(Ol(e)&&jt(e))return e;let i=t||process.cwd(),n=Bl(i),r=va(n,e);if(jt(r))return r;let a=va(i,e);if(jt(a))return a;throw new Error("script file not found: "+e)}function Ia(e,t={}){e?.format===st&&Ki(e.version);let i=[],n=typeof t.workspacePath=="string"&&t.workspacePath?t.workspacePath:"",r=e?.format===st&&e.assets,a=r?null:xe(e,{warnings:i}),o={server:r&&e.assets.server?xe(e.assets.server,{warnings:i}):kn(ie),client:r&&e.assets.client?xe(e.assets.client,{warnings:i}):kn(V)};a&&(o[lt(a.meta.assetType)]=a);let l=r&&e.activeAssetType===V?V:a?.meta.assetType||ie,f=r&&e.meta?.name?String(e.meta.name):"",s=()=>f||Et;!e?.meta?.name&&o.server.meta.name==="\u672A\u547D\u540D\u754C\u9762\u63A7\u4EF6\u7EC4"&&(o.server.meta.name=Yl);let c=[],m=new Set;function h(){m.clear(),St(o.server.root,m),St(o.client.root,m,{skipServerContainer:!0});for(let d of c)we(d.guid)&&m.add(Number(d.guid))}function p(d=0){h();let g=we(d)&&!m.has(Number(d))?Number(d):Oe(m);return m.add(g),g}function v(d){let g=xi(d),C=p(g.guid);return{...g,guid:C,id:String(C)}}for(let d of Ca(e))c.push(v(d));let w=xt(e?.serverLogic),x=null,k="",$=1,O=1;function Y(d){let g=String(d||"").trim();if(!g)return"";if(!J[g])throw new Error(`unknown canvas preset: ${g} (available: ${Object.keys(J).join(", ")})`);return g}let L=()=>o[lt(l)];function Z(d){if(!d)return null;for(let[g,C]of[["server",o.server],["client",o.client]]){let T=ue(C.root,d);if(T&&T.kind!=="server-container")return{key:g,node:T}}return null}function W(d){if(!d.controlId)return null;let g=d.controlAsset===V?"client":d.controlAsset===ie?"server":null;if(g){let C=ue(o[g].root,d.controlId);return C&&C.kind!=="server-container"?{key:g,node:C}:null}return Z(d.controlId)}function N(){for(let d of c)d.controlId&&!W(d)&&(d.controlId="",d.controlAsset="")}function y(d){if(!we(d))return null;for(let[g,C]of[[ie,o.server],[V,o.client]]){let T="";if(q(C.root,F=>{!T&&(F.scriptMappingIds||[]).includes(Number(d))&&(T=F.id)}),T)return{controlId:T,controlAsset:g}}return null}function E(d,g,C){let T=o[lt(d.controlAsset)],F=T&&ue(T.root,d.controlId);F&&(F.scriptMappingIds=(F.scriptMappingIds||[]).map(R=>Number(R)===Number(g)?Number(C):R))}N();function b(){return c.map(d=>{let g=W(d),C=g?g.key==="client"?V:ie:"";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?Sa[C]:"",mounted:!!g})})}function I(){let d=[],g=(C,T)=>{q(C.root,F=>{F.kind!=="server-container"&&d.push(D({id:F.id,name:F.name,kind:F.kind,assetType:T,assetLabel:Sa[T]}))})};return g(o.server,ie),g(o.client,V),d}function M(d){let g=[];return q(d.root,C=>{C.kind!=="server-container"&&g.push(JSON.stringify({kind:C.kind,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 S=M(Qe()),P=M(De());function G(d){let g=M(d);return d.meta?.assetType===V?g===S:g===P}function z(d,g){return String(d||"").replace(/[\\/:*?"<>|]/g,"-").trim()||g}function ne(d){let g=z(s(),Et),C=d.meta?.assetType===V?"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F":"\u670D\u52A1\u5668\u63A7\u4EF6\u6A21\u677F";return`${g} \xB7 ${C}`}function j(){if(!((o.server.root.children||[]).find(g=>g.kind==="container")||o.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 fr(o.server,o.client,{scripts:c,fileName:`${z(s(),Et)} \xB7 \u6574\u5408\u5305.gia`})}function ce(){let d=g=>({type:g.meta.assetType,name:g.meta.name,sourceFile:g.meta.sourceFile||""});return{format:st,name:s(),activeAssetType:l,assets:{server:d(o.server),client:d(o.client),scripts:b()}}}function Te(){return D({format:st,version:4,meta:{name:s()},activeAssetType:l,serverLogic:w,assets:{server:o.server,client:o.client,scripts:c.map(d=>D({id:d.id,guid:d.guid||0,path:d.path||"",source:d.source||"",controlId:d.controlId||"",controlAsset:d.controlAsset||""}))}})}function oe(){let d=L(),g=_r(d);return g.workspace=Ul(n),g.save=ce(),g.scripts=b(),g.mountTargets=I(),g.serverLogic=w,g.migrationWarnings=[...i],Fn(g),g}function ct(d){let g=L();if(d.expectedRevision!==void 0&&Number(d.expectedRevision)!==g.version)throw new Error(`revision conflict: expected ${d.expectedRevision}, current ${g.version}`);return g}function He(d,g,C=""){let T=String(g||"");if(T){let F=C===V?V:C===ie?ie:"";if(!W({controlId:T,controlAsset:F}))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=F}else d.controlAsset="";d.controlId=T}function At(d){let g=ct(d);if(d.op==="addScript"){let C=v({path:String(d.path||""),source:String(d.source||""),controlId:"",controlAsset:""});d.controlId!==void 0&&d.controlId!==""&&He(C,d.controlId,d.controlAsset),c.push(C)}else if(d.op==="updateScript"){let C=c.find(T=>T.id===d.id);if(!C)throw new Error(`\u811A\u672C\u4E0D\u5B58\u5728: ${d.id}`);d.controlId!==void 0&&He(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=c.length;if(c=c.filter(T=>T.id!==d.id),c.length===C)throw new Error(`\u811A\u672C\u4E0D\u5B58\u5728: ${d.id}`)}return g.version+=1,oe()}function ft(d){if(!d||typeof d!="object")throw new Error("patch requires op");if(d.op==="setServerLogic"){let g=ct(d);return w=xt(d.logic),g.version+=1,oe()}if(d.op==="addScript"||d.op==="updateScript"||d.op==="removeScript")return At(d);if(d.op==="selectAsset")return l=d.assetType===V?V:ie,oe();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,oe()}if(d.op==="newAsset"){let g=ct(d);l=d.assetType===V?V:ie;let C=kn(l);return C.version=g.version+1,o[lt(l)]=C,N(),oe()}return Li(L(),d),N(),oe()}function dt(d){return c.filter(g=>{let C=W(g);return!!(C&&C.key==="client"==(d===V))})}function _t(d="json",g=""){let C=String(d).toLowerCase();if(C==="save"||C==="archive"){let R=Buffer.from(JSON.stringify(Te(),null,2),"utf8");return D({filename:`${s().replace(/[\\/:*?"<>|]/g,"-")} \xB7 \u8D44\u4EA7\u5305.json`,mimeType:"application/json",encoding:"base64",data:R.toString("base64"),warnings:[]})}if(C==="save-gia"||C==="archive-gia"){let R=[],B=[],Q=(ve,Me="")=>{let ee=_t(ve,Me);R.push(D({filename:ee.filename,mimeType:ee.mimeType,encoding:ee.encoding,data:ee.data,warnings:ee.warnings||[]})),B.push(...ee.warnings||[])},ht=(ve,Me)=>{let ee=o[lt(ve)],Ne=ve===l,mt=c.some(ge=>ge.controlAsset===ve&&ge.controlId);if(!Ne&&G(ee)&&!mt){B.push(Me);return}Q("gia",ve)};if(ht(ie,"\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"),ht(V,"\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"),c.some(ve=>ve.path||ve.source)&&Q("scripts-gia"),!R.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:R,warnings:[...new Set(B)]})}if(C==="gia-combined"||C==="combined-gia"||C==="combined"){let R=j();return D({filename:`${z(s(),Et)} \xB7 \u6574\u5408\u5305.gia`,mimeType:"application/octet-stream",encoding:"base64",data:R.buffer.toString("base64"),warnings:[...new Set(R.warnings||[])]})}if(C==="scripts"){let R=D({format:Gl,version:1,scripts:c.map(Q=>D({id:Q.id,guid:Q.guid||0,path:Q.path||"",source:Q.source||"",controlId:Q.controlId||"",controlAsset:Q.controlAsset||""}))}),B=Buffer.from(JSON.stringify(R,null,2),"utf8");return D({filename:`${z(s(),Et)} \xB7 \u811A\u672C.json`,mimeType:"application/json",encoding:"base64",data:B.toString("base64"),warnings:[]})}if(C==="scripts-gia"||C==="scriptsgia"){let R=pr(c);return D({filename:`${z(s(),Et)} \xB7 \u811A\u672C.gia`,mimeType:"application/octet-stream",encoding:"base64",data:R.buffer.toString("base64"),warnings:R.warnings})}if(C==="lua"){let R=c.find(Q=>Q.id===g)||c.find(Q=>Q.path===g);if(!R)throw new Error("\u6CA1\u6709\u53EF\u5BFC\u51FA\u7684 Lua \u811A\u672C\uFF0C\u8BF7\u5148\u5728\u201CLua \u811A\u672C\u201D\u9875\u521B\u5EFA");let B=kt(R.path||"")||`qxqy-script-${R.id}`;return D({filename:/\.lua$/i.test(B)?B:`${B}.lua`,mimeType:"text/x-lua",encoding:"base64",data:Buffer.from(R.source||"","utf8").toString("base64"),warnings:[]})}let T=g?o[lt(g)]:L(),F=ne(T);if(C==="json"){let R=D({...T,scripts:dt(T.meta.assetType)}),B=Buffer.from(JSON.stringify(R,null,2),"utf8");return D({filename:`${F}.json`,mimeType:"application/json",encoding:"base64",data:B.toString("base64"),warnings:[]})}if(C==="gia"){let R=cr(T,T.meta.assetType===V?{scripts:dt(V)}:{}),B=T.meta.assetType===V?[]:dt(ie);return B.length&&R.warnings.unshift(`\u5F53\u524D\u670D\u52A1\u5668\u63A7\u4EF6 GIA \u4E0D\u5305\u542B ${B.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:`${F}.gia`,mimeType:"application/octet-stream",encoding:"base64",data:R.buffer.toString("base64"),warnings:R.warnings})}throw new Error(`unsupported export format: ${d}`)}function X(d){for(let g of d){let C=xi(g);if(!C.path&&!C.source)continue;let T=C.controlId?null:y(C.guid),F=v(T?{...C,...T}:C);T&&F.guid!==C.guid&&E(T,C.guid,F.guid),F.controlId&&!W(F)&&(F.controlId="",F.controlAsset=""),c.push(F)}}function Ce(d,g,C=""){let T=String(d||"").toLowerCase();if(typeof g!="string"||!g)throw new Error("import data is required");let F=Buffer.from(g,"base64"),R,B=[],Q={};if(T==="json"){try{R=JSON.parse(F.toString("utf8"))}catch{throw new Error("JSON \u6587\u4EF6\u65E0\u6548")}if(R?.project&&(R=R.project),R?.format===st&&R?.assets){Ki(R.version);let ee=xe(R.assets.server||De(),{warnings:B}),Ne=xe(R.assets.client||Qe(),{warnings:B}),mt=xt(R.serverLogic);return o.server=ee,o.client=Ne,i=[...B],l=R.activeAssetType===V?V:ie,f=String(R.meta?.name||kt(C).replace(/\.json$/i,"")||f),w=mt,c=[],m.clear(),X(Ca(R)),N(),D({snapshot:oe(),warnings:B,metadata:{format:st}})}}else{if(T==="lua")return c.push(v({path:kt(C||"imported.lua"),source:F.toString("utf8"),controlId:""})),D({snapshot:oe(),warnings:B,metadata:{assetType:"lua-script"}});if(T==="gia"){if(gr(F)){let ge=br(F);return X(ge.scripts),D({snapshot:oe(),warnings:ge.warnings,metadata:ge.metadata})}let ee=vr(F);R=ee.project,B=ee.warnings,Q=ee.metadata,ee.clientProject&&(o.client=xe(ee.clientProject),B.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 Ne=new Map,mt=(ge,za)=>{ge&&q(ge.root,Tn=>{for(let Ei of Tn.scriptMappingIds||[]){let Rn=Ne.get(Number(Ei));if(Rn){B.push(`\u811A\u672C GUID ${Ei} \u540C\u65F6\u6302\u8F7D\u5230\u591A\u4E2A\u63A7\u4EF6\uFF0C\u5DF2\u4FDD\u7559\u201C${Rn.controlAsset===ie?"\u670D\u52A1\u7AEF":"\u5BA2\u6237\u7AEF"}\u201D\u76EE\u6807\u3002`);continue}Ne.set(Number(Ei),{controlId:Tn.id,controlAsset:za})}})};mt(ee.project,ie),mt(ee.clientProject,V),X((ee.scripts||[]).map(ge=>Ne.has(Number(ge.guid))?{...ge,...Ne.get(Number(ge.guid))}:ge))}else throw new Error(`unsupported import format: ${d}`)}let ht=xe(R,{warnings:B});i=[...B];let ve=lt(ht.meta.assetType);o[ve]=ht,l=ht.meta.assetType;let Me=o[ve];return C&&(Me.meta.name=kt(C).replace(/\.(json|gia)$/i,"")||Me.meta.name,Me.meta.sourceFile=kt(C),Me.meta.sourceFormat=T),X(R?.scripts||[]),R?.script&&(R.script.path||R.script.source)&&X([R.script]),D({snapshot:oe(),warnings:B,metadata:Q})}function Le(d,g){return Li(L(),{op:"pick",x:d,y:g}),oe()}function Zt(d){let g=typeof d=="string"&&d?d:"";!g||g===n||(n=g)}function Pt(d){let g=d.source||"";if(!g.trim()&&d.path.trim())try{g=Nl(Kl(d.path,n),"utf8")}catch(C){throw new Error(`\u811A\u672C ${d.path} \u8BFB\u53D6\u5931\u8D25: ${C?.message||C}`)}return g}function Re(d={}){let g=Y(d.canvasId);g&&(k=g),d.playerCount!==void 0&&d.playerCount!==null&&d.playerCount!==""&&($=nt(d.playerCount),O>$&&(O=1)),d.viewPlayerIndex!==void 0&&d.viewPlayerIndex!==null&&d.viewPlayerIndex!==""&&(O=Pe(d.viewPlayerIndex,$)),x&&Cn(x);let C=c.map(F=>{try{return{id:F.id,guid:F.guid||0,path:F.path||F.id,source:Pt(F),controlId:F.controlId||"",controlAsset:F.controlAsset||""}}catch(R){return{id:F.id,guid:F.guid||0,path:F.path||F.id,source:`error([==[ ${String(R.message).replace(/]=+]/g,"] =]")} ])`,controlId:F.controlId||"",controlAsset:F.controlAsset||""}}}),T=F=>C.filter(R=>{let B={controlId:R.controlId,controlAsset:R.controlAsset},Q=R.controlId?W(B):null;return!!(Q&&Q.key===F)});return x=oa(o.server,{templatesProject:o.client,scripts:C,sceneScripts:T("server"),templateScripts:T("client"),serverConfig:{logic:w},canvasId:k,playerCount:$,viewPlayerIndex:O}),le(d)}function Tt(d,g={}){let C=Y(d);if(!C)throw new Error("playSetCanvas requires canvasId");return Re({...g,canvasId:C})}function le(d={}){if(!x)return D({running:!1,tree:[],logs:[],serverLogs:[],serverVars:[]});let g=pn(x,d);return g.running=!0,g.logs=En(g.logs),g.serverLogs=En(g.server?.logs||[]),g.serverVars=Dl(g.server,g.playerCount||1),g}function wa(d,g={}){return x||Re(),Ii(x,d),g.observe===!1?D({running:!0,time:x.runtime.clock.time,frame:x.runtime.clock.frame,paused:!!x.debugPaused,levelTimePaused:!!x.runtime.clock.paused,playerCount:x.playerCount||1,viewPlayerIndex:x.viewPlayerIndex||1}):le(g)}function xa(d=0){Re();let g=Math.max(0,Number(d)||0);for(let C=0;C<g;C++)Ii(x,1/30);return le()}function Ea(){return x&&Cn(x),x=null,k="",$=1,O=1,D({running:!1,tree:[],logs:[],serverLogs:[],serverVars:[]})}function ka(d,g={}){let C=Rt();return O=hn(C,d),g.observe===!1?null:le(g)}function Aa(d,g={}){if(!x)throw new Error("play session has not started");return gn(x,d),g.observe===!1?null:le(g)}function _a(d,g={}){if(!x)throw new Error("play session has not started");return yn(x,d),g.observe===!1?null:le(g)}function Pa(d,g,C,T={}){if(!x)throw new Error("play session has not started");return Wt(x,d,g,C),T.observe===!1?null:le(T)}function Ta(d={}){return x&&wi(x).pause(),d.observe===!1?null:le(d)}function Ra(d={}){return x&&wi(x).resume(),d.observe===!1?null:le(d)}function Rt(){if(!x)throw new Error("play session has not started");return x}function Ma(d,g){let C=Rt();if(!d&&!g){let T=le();return D({vars:T.serverVars||[]})}return D({entityType:String(d||""),name:String(g||""),value:ma(C,d,g)})}function Na(d,g,C){let T=Rt();return vn(T,d,g,C),le()}function Fa(d,g=[],C="PlayerSelf"){let T=Rt();return Sn(T,d,g,C),le()}function Oa(){let d=le();return D({events:d.history||[],case:ia(d.history||[],{playerCount:d.playerCount||1})})}function $a(d={}){let g=le(),C=Xt({name:d.name||"",dt:d.dt,playerCount:d.playerCount||g.playerCount||1,events:d.events||g.history||[],asserts:d.asserts||[]});return D(C)}function Da(d,g={}){let C=Xt(d);Re({...g,playerCount:g.playerCount||C.playerCount||1});let T=Rt();T.recording=!1;try{return ya(wi(T),d)}finally{T.recording=!0}}function Ga(){if(!x)return{running:!1,paused:!1,time:0,frame:0,playerCount:1,viewPlayerIndex:1};let d=x.runtime.clock;return{running:!0,paused:!!x.debugPaused,levelTimePaused:!!d.paused,time:d.time,frame:d.frame,playerCount:x.playerCount||1,viewPlayerIndex:x.viewPlayerIndex||1}}let Pn={get:oe,patch:ft,setWorkspace:Zt,exportData:_t,importData:Ce,pick:Le,playStart:Re,playSetCanvas:Tt,playSetView:ka,playGet:le,playStatus:Ga,playStep:wa,playRun:xa,playStop:Ea,playKey:Aa,playClick:_a,playPointer:Pa,playPause:Ta,playResume:Ra,playServerGet:Ma,playServerSet:Na,playServerSend:Fa,playHistory:Oa,playSaveCase:$a,playRunCase:Da,archiveData:Te};return Object.defineProperty(Pn,"_project",{enumerable:!1,get:L}),Pn}var U=null,_n=!1,ut=0,Xe=0,Xl=33,qt=1/30,Hl=5;function Jt(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 Ll(e={}){let t=Jt(e);for(let i of["canvasId","playerCount","viewPlayerIndex"])e[i]!==void 0&&e[i]!==null&&e[i]!==""&&(t[i]=e[i]);return t}function Ke(e={}){return e.light?{...U.playStatus()}:U.playGet(Jt(e))}function Wl(){if(!U||_n)return;let e=U.playStatus();if(!e.running||e.paused){ut=0,Xe=0;return}let t=Date.now();if(!ut){ut=t;return}_n=!0;try{Xe+=Math.min(.25,Math.max(0,(t-ut)/1e3)),ut=t;let i=0;for(;Xe>=qt&&i<Hl;)U.playStep(qt,{observe:!1}),Xe-=qt,i+=1;Xe>qt&&(Xe=qt)}finally{_n=!1}}var ec=setInterval(Wl,Xl);function jl(e,t={}){if(e==="start")return U&&U.playStop(),U=Ia(t.archive||t.project,{workspacePath:t.workspacePath||""}),ut=0,Xe=0,U.playStart(Ll(t));if(!U)throw new Error("play session has not started");if(e==="get")return t.light?Ke(t):U.playGet(Jt(t));if(e==="step"){let i=U.playStep(t.dt,t.light?{observe:!1}:Jt(t));return t.light?Ke(t):i}if(e==="pointer")return U.playPointer(t.type,t.x,t.y,{observe:!1}),Ke(t);if(e==="key")return U.playKey(t.key,{observe:!1}),Ke(t);if(e==="click")return U.playClick(t.name,{observe:!1}),Ke(t);if(e==="pause")return U.playPause({observe:!1}),Ke(t);if(e==="resume")return U.playResume({observe:!1}),Ke(t);if(e==="device")return U.playSetCanvas(t.canvasId,Jt(t));if(e==="view")return U.playSetView(t.playerIndex??t.viewPlayerIndex,{observe:!1}),Ke(t);if(e==="serverGet")return U.playServerGet(t.entityType,t.name);if(e==="serverSet")return U.playServerSet(t.entityType,t.name,t.value);if(e==="serverSend")return U.playServerSend(t.name,t.params||[],t.target||"PlayerSelf");if(e==="history")return U.playHistory();if(e==="saveCase")return U.playSaveCase(t.case||t);if(e==="runCase")return U.playRunCase(t.case||t,{canvasId:t.canvasId,playerCount:t.playerCount,viewPlayerIndex:t.viewPlayerIndex});if(e==="stop"){let i=U.playStop();return U=null,ut=0,Xe=0,i}throw new Error(`unknown play action: ${e}`)}An.on("message",e=>{let{id:t,action:i,args:n={}}=e||{};try{An.postMessage({id:t,ok:!0,value:jl(i,n),error:null})}catch(r){An.postMessage({id:t,ok:!1,value:null,error:r?.message||String(r)})}});
106
+ `)}`);return{buffer:n,warnings:[...new Set(t.warnings)]}}function Hi(e){return xe.toObject(xe.decode(ci(e)),{longs:Number,enums:Number,bytes:Buffer,defaults:!1,arrays:!0,objects:!0})}function kr(e){try{let i=Hi(e).graph||[];return i.length>0&&i.every(n=>Number(n.which)===Ct)}catch{return!1}}function _r(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 Pr(e){let t=Hi(e),i=_r(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 Ea(e){let t=[],i;try{i=Hi(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)!==wr&&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 ci(e){let t=Buffer.isBuffer(e)?e:Buffer.from(e);if(t.length<Be+Yi)throw new Error("GIA \u6587\u4EF6\u8FC7\u77ED");if(t.readUInt32BE(4)!==1||t.readUInt32BE(8)!==cr||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-Yi)throw new Error("GIA payload \u957F\u5EA6\u4E0D\u4E00\u81F4");if(t.readUInt32BE(Be+i)!==fr)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 Aa(e){let t=fe(e,"transform")?.multiPlatform,i={};for(let r of t?.platforms||[]){let o=ma[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 le)i[r]||(i[r]=structuredClone(n));return i}function ui(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 ur(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=ui(s),m=fe(s,"textConfig"),h=fe(s,"imageSlot"),g=fe(s,"image"),v=fe(s,"buttonPreset"),w=fe(s,"gridView"),N=fe(s,"genericSlot"),E=fe(s,"footerSlot"),k=fe(s,"cursorConfig"),B=fe(s,"keyHint"),$=fe(s,"containerNodeSlot"),q=fe(s,"templateRefSlot"),Q=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:(N?.field502||[]).map(y=>Number(y?.field1?.id)).filter(y=>Number.isSafeInteger(y)&&y>0),transformByPlatform:Aa(s),syncAllDevices:fe(s,"transform")?.multiPlatform?.field504===1,giaRaw:{genericField501:N?.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:k?.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:B?.field501??1,keyHintField502:B?.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:Q??""}:{},...f==="fullscreen"?{fullscreenEffectSlot:J??""}:{}},...f==="container"?{isolateNavigation:$?.isolateNavigation===!0,disableKeyEventPassthrough:$?.disableKeyEventPassthrough===!0,disableCursorEventPassthrough:$?.disableCursorEventPassthrough===!0,showCursor:$?.showCursor===!0}:{},...f==="cursor"?{raycastTarget:k?.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:v?.interactable===1,raycastTarget:v?.raycastTarget===1,clickAudioId:v?.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:B?.field502??null,controllerKeyCode:B?.field501??null}:{},...f==="animation"?{animationId:Q??""}:{},...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:v?.disabledChild,hoverChildId:v?.hoverChild,pressedChildId:v?.pressedChild,selectedChildId:v?.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 Tr(e){let t=ci(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(v=>v.ui?.content))throw new Error("GIA \u4E0D\u542B\u53EF\u8BC6\u522B\u7684 UIControlGroup \u4E3B\u56FE");let r=n.find(v=>v.which===21)||null,o=n.filter(v=>Number(v.which)===70),a=i.accessories||[],l=new Set((r?.relatedIds||[]).map(v=>v.id||0)),c=r?l.size?a.filter(v=>l.has(v.id?.id||0)):a:[],s=o.length?[...o,...a.filter(v=>!l.has(v.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=_r(i);f.push(...m.warnings);let h=null,g=null;if(c.length){let v=ur(c,{reverseSiblings:!0,idOffset:0});f.push(...v.warnings);let w=v.rootCandidates.find(E=>E.kind==="container")||v.rootCandidates[0];if(!w)throw new Error("GIA \u672A\u627E\u5230\u5BA2\u6237\u7AEF\u6839\u63A7\u4EF6");let N=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||[]});N.children=[w],v.rootCandidates.length>1&&f.push(`\u68C0\u6D4B\u5230 ${v.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:me,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:N}}if(s.length){let v=ur(s,{reverseSiblings:!1,idOffset:1e3});if(f.push(...v.warnings),!v.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=v.rootCandidates,g={version:1,layoutSchemaVersion:me,meta:{name:v.rootCandidates.length===1?v.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:v.rootCandidates[0].id,script:{controlId:v.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 Rr(e){let t=ci(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=ui(h),v=h.ui?.content?.info||[],w=v.find(B=>B.field501===2&&B.field502===6)?.index?.value,N=dr[g],E=v.find(B=>B.field501===4&&B.field502===4),k=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:N,relatedPresent:!!E,relatedGuids:k}});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,v=h.ui.content,w=ui(h),N=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`),v.guid!==g&&o.push(`${E}: content.guid=${v.guid??"<missing>"} \u4E0E GraphUnit.id.id \u4E0D\u4E00\u81F4`),N&&h.which!==70&&o.push(`${E}: \u6A21\u677F\u6839 which \u5FC5\u987B\u4E3A UIControlTemplate(70)`),!N&&h.which!==15&&o.push(`${E}: \u9644\u4EF6\u63A7\u4EF6 which \u5FC5\u987B\u4E3A UIControl(15)`);let k=v.info||[],B=k.find(S=>S.field501===1&&S.field502===5),$=k.find(S=>S.field501===2&&S.field502===6);B?.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=k.find(S=>S.field501===4&&S.field502===4);N&&!q&&o.push(`${E}: \u9876\u5C42\u6A21\u677F\u7F3A\u5C11 Info.related \u8BB0\u5F55`),!N&&q&&o.push(`${E}: \u9644\u4EF6\u63A7\u4EF6\u4E0D\u5E94\u5199 Info.related`);let Q=mr[w],J=v.data||[],O=J.map(S=>`${S.field501}/${S.field502}`),y=Q?.map(([S])=>S)||[];Q?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,Q?.length||0);S+=1){let R=J[S],[D,U,ae]=Q[S];if(a(R,U)||o.push(`${E}: Data ${D} \u7F3A\u5C11 ${U} \u5206\u652F`),!ae)continue;a(R.details,ae)||o.push(`${E}: Details ${D} \u7F3A\u5C11 ${ae} \u5206\u652F`);let X=pr[D];(R.details?.field501!==X||R.details?.field502!==R.field502||R.details?.field503!==1)&&o.push(`${E}: Details ${D} \u6807\u8BB0\u5E94\u4E3A ${X}/${R.field502}/1`);let de=R.details?.nodeRef;(de?.class!==1||de?.type!==8||de?.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 b=(h.ui.content.data||[]).find(S=>S.details?.transform)?.details?.transform?.multiPlatform?.platforms||[];b.length!==4&&o.push(`${E}: \u591A\u5E73\u53F0\u53D8\u6362\u6570\u91CF=${b.length}\uFF0C\u5E94\u4E3A 4`);let I=b.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!==$t[w]&&o.push(`${E}: \u53D8\u6362 preset=${F?.multiPlatform?.field502??"<missing>"}\uFF0C${w} \u5E94\u4E3A ${$t[w]}`);for(let S of b)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:N,parent:v.parent||0,children:[...v.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 v=l.get(h.parent);v?(v.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 v of h.children){let w=l.get(v);w?(w.ui?.content?.parent||0)!==h.id&&o.push(`${g}: child=${v} \u7684 parent \u672A\u6307\u56DE\u81EA\u8EAB`):o.push(`${g}: child=${v} \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 Li(e){let t=ci(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,R)=>S!=null&&Object.prototype.hasOwnProperty.call(S,R);/^\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 R=Number(S.which);return R===Ct||R===70||R===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 R=S.id?.id||0,D=`${S.name||"<unnamed>"}(${R||"<missing-guid>"})`;!Number.isSafeInteger(R)||R<=0||R>2147483647?l.push(`${D}: GraphUnit GUID \u975E\u6CD5`):h.has(R)?l.push(`${D}: GUID \u91CD\u590D`):h.set(R,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!==R&&l.push(`${D}: content.guid \u4E0E GraphUnit.id.id \u4E0D\u4E00\u81F4`)}let g=f.id?.id||0,v=f.ui.content,w=`${f.name||"<unnamed>"}(${g})`;f.which!==21&&l.push(`${w}: which \u5FC5\u987B\u4E3A UIControlGroup(21)`);let N=v.info||[];N.find(S=>S.field501===1&&S.field502===5)?.guid?.value!==g&&l.push(`${w}: Info.self GUID \u7F3A\u5931\u6216\u4E0D\u4E00\u81F4`),N.find(S=>S.field501===2&&S.field502===6)?.index?.value!==1&&l.push(`${w}: Info.index \u5FC5\u987B\u4E3A 1`);let E=N.find(S=>S.field501===4&&S.field502===4);E||l.push(`${w}: \u7F3A\u5C11\u663E\u5F0F Info.related \u8BB0\u5F55`);let k=0,B=0,$=(S,R,D,U=!1)=>{let ae=S.id?.id||0,X=`${S.name||"<unnamed>"}(${ae})`,de=S.ui.content.data||[],je=de.map(ie=>`${ie.field501}/${ie.field502}`),ht=D.map(([ie])=>ie);JSON.stringify(je)!==JSON.stringify(ht)&&l.push(`${X}: Data \u69FD\u4F4D\u987A\u5E8F ${je.join(",")}\uFF0C\u5E94\u4E3A ${ht.join(",")}`);for(let ie=0;ie<Math.min(de.length,D.length);ie+=1){let Ae=de[ie],[Me,kt,_t]=D[ie];if(c(Ae,kt)||l.push(`${X}: Data ${Me} \u7F3A\u5C11 ${kt} \u5206\u652F`),!_t)continue;c(Ae.details,_t)||l.push(`${X}: Details ${Me} \u7F3A\u5C11 ${_t} \u5206\u652F`);let $e=pr[Me];(Ae.details?.field501!==$e||Ae.details?.field502!==Ae.field502||Ae.details?.field503!==1)&&l.push(`${X}: Details ${Me} \u6807\u8BB0\u5E94\u4E3A ${$e}/${Ae.field502}/1`);let Pt=Ae.details?.nodeRef;(Pt?.class!==1||Pt?.type!==8||Pt?.id!==ae)&&l.push(`${X}: Details ${Me} node_ref \u672A\u6307\u5411\u81EA\u8EAB`)}let At=de.find(ie=>ie.field501===4&&ie.field502===(U?23:86)),ee=U?"empty15":"field17";c(At?.field14,ee)?U||(k+=1):l.push(`${X}: \u7C7B\u578B Data \u7F3A\u5C11\u663E\u5F0F Field14.${ee} \u7A7A\u4E32`),c(At?.details?.field14,ee)?U||(k+=1):l.push(`${X}: \u7C7B\u578B Details \u7F3A\u5C11\u663E\u5F0F Field14.${ee} \u7A7A\u4E32`);let Ee=de.find(ie=>ie.details?.transform)?.details?.transform,qe=Ee?.multiPlatform?.platforms||[];qe.length!==4&&l.push(`${X}: \u591A\u5E73\u53F0\u53D8\u6362\u6570\u91CF=${qe.length}\uFF0C\u5E94\u4E3A 4`);let Qt=qe.map(ie=>ie.platformType||0);JSON.stringify(Qt)!==JSON.stringify([0,1,2,3])&&l.push(`${X}: \u5E73\u53F0\u987A\u5E8F ${Qt.join(",")}\uFF0C\u5E94\u4E3A 0,1,2,3`);let ei=U?$t["server-container"]:$t[R];Ee?.multiPlatform?.field502!==ei&&l.push(`${X}: \u53D8\u6362 preset=${Ee?.multiPlatform?.field502??"<missing>"}\uFF0C\u5E94\u4E3A ${ei}`);for(let ie of qe)c(ie.transform,"field508")?B+=1:l.push(`${X}: RectTransform \u7F3A\u5C11\u663E\u5F0F field508 \u7A7A\u4E32`);return je};$(f,"server-container",pa,!0);let q=(f.relatedIds||[]).map(S=>S.id||0),Q=new Set(q),J=a.filter(S=>Q.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=v.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 b=[];for(let S of J){let R=S.id?.id||0,D=S.ui.content,U=`${S.name||"<unnamed>"}(${R})`,ae=ui(S);S.which!==15&&l.push(`${U}: which \u5FC5\u987B\u4E3A UIControl(15)`);let X=D.info||[];(X.length!==1||X[0]?.field501!==1||X[0]?.field502!==5||X[0]?.guid?.value!==R)&&l.push(`${U}: \u670D\u52A1\u7AEF\u5BB9\u5668\u5185\u63A7\u4EF6 Info \u5FC5\u987B\u53EA\u542B\u81EA\u8EAB GUID`);let de=mr[ae];de||l.push(`${U}: \u672A\u77E5\u5BA2\u6237\u7AEF\u63A7\u4EF6\u7C7B\u578B ${ae}`);let je=de?$(S,ae,de):[];b.push({id:R,name:S.name||"",kind:ae,parent:D.parent||0,children:[...D.children||[]],relatedIds:(S.relatedIds||[]).map(ht=>ht.id||0),dataSignatures:je})}let I=b.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(b.map(S=>[S.id,S]));for(let S of b){let R=`${S.name}(${S.id})`;if(JSON.stringify(S.relatedIds)!==JSON.stringify(S.children)&&l.push(`${R}: 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(`${R}: \u7236\u63A7\u4EF6 children \u672A\u53CD\u5411\u5305\u542B\u81EA\u8EAB`):l.push(`${R}: parent=${S.parent||"<missing>"} \u4E0D\u5B58\u5728`)}for(let D of S.children){let U=F.get(D);U?U.parent!==S.id&&l.push(`${R}: child=${D} \u7684 parent \u672A\u6307\u56DE\u81EA\u8EAB`):l.push(`${R}: 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:b,scriptCount:o.length,explicitEmpty:{field17:k,rectField508:B}}}function Mr(e,t=[]){if(!e||e.layoutSchemaVersion===me)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:me};let i=structuredClone(e),n=0;return W(i.root,r=>{let o=r.transformByPlatform||{},a=r.transformByCanvas||{},l=r.name||r.id;for(let s of Object.keys(o))if(!le.includes(s))throw new Error(`${l}: unknown platform ${s}`);let c={};for(let s of le){let f=mt[s],m=te[f].platform,h=Object.keys(te).filter(N=>te[N].platform===m&&a[N]),g=a[f]?f:h[0],v=s==="CONTROLLER_CONSOLE"?c.KEYBOARD:s==="CONTROLLER_MOBILE"?c.TOUCHSCREEN:null,w=o[s]??v??(g?a[g]:null);if(c[s]=w?Pe(w):$i(r.kind),w||t.push(`${l}: ${s} \u65E0\u65E7\u5E03\u5C40\uFF0C\u5DF2\u4F7F\u7528\u63A7\u4EF6\u9ED8\u8BA4\u503C`),!o[s]&&!v&&g&&g!==f&&t.push(`${l}: \u7F3A\u5C11 ${f}\uFF0C\u5DF2\u91C7\u7528 ${g} \u7684\u951A\u70B9\u548C\u5C3A\u5BF8\u53C2\u6570`),!v)for(let N of h)JSON.stringify(c[s])!==JSON.stringify(Pe(a[N]))&&t.push(`${l}: ${N} \u4E0E ${s} \u5E03\u5C40\u51B2\u7A81\uFF0C\u4FDD\u7559${o[s]?"\u5DF2\u6709\u5E73\u53F0":g}\u53C2\u6570`)}Ge(c,`${l}.transformByPlatform`),r.transformByPlatform=c,delete r.transformByCanvas,n++}),i.layoutSchemaVersion=me,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 Wi(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 qi(e,t,i,n=e.canvasId){let r=ze(e.root,t);return!r||r.kind==="server-container"?ge(n):i[r.id]||ge(n)}function Ue(e,{warnings:t=[]}={}){if(!e)return it();if(e=Mr(e,t),(e.root||e.layoutSchemaVersion!==void 0)&&e.layoutSchemaVersion!==me)throw new Error(`\u4EC5\u652F\u6301 layoutSchemaVersion=${me} \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:me,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&&te[e.canvasId]?e.canvasId:ti,selectedId:e.selectedId||n.selectedId,root:zi(e.root||n.root)};return Gr(r),r}function Gr(e){let t=new Set;W(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=Di(e.root).id)}function Nr(e){return De(vt(e))}function ka(e,t){let i=!1;return W(e,n=>{n.id===t&&(i=!0)}),i}function _a(e,t,i,n){let o=Ye(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=Ye(e.root,e.canvasId),c=n.kind==="server-container"?ge(e.canvasId):l.boxes[n.id]||ge(e.canvasId),s=Ve(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 Pa(e,t){return e.meta.assetType!=="client-control-template"?Vi(e.root,t):(e.root.children||[]).flatMap(i=>Vi(i,t))}function Dr(e,t){let i=ar(e.root,t);if(e.meta.assetType!=="client-control-template")return i;let n=Ot(e),r=new Set;return n&&n.kind!=="server-container"&&W(n,o=>r.add(o.id)),i.filter(o=>r.has(o.id))}function zr(e){let{canvas:t,boxes:i}=Ye(e.root,e.canvasId),n=Dt(e),r=ce(e.root,e.selectedId),o=r?i[r.id]:null;return G({layoutSchemaVersion:me,version:e.version,meta:{...e.meta},canvasId:e.canvasId,canvas:{id:e.canvasId,width:t.width,height:t.height,platform:te[e.canvasId].platform,label:te[e.canvasId].label,presets:Object.values(te).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"&&Ot(e)?.id||""},tree:Pa(e,n),boxes:Dr(e,i),inspector:lr(r,e.canvasId,o||t,n),root:e.root})}function It(e,t,i){let n=Ye(e.root,e.canvasId),r=qi(e,t.id,n.boxes),o={};if(t.syncAllDevices!==!1)for(let a of le){if(a===Qe(e.canvasId))continue;let l=mt[a],c=Ye(e.root,l,a);o[a]=qi(e,t.id,c.boxes,l)}t.transformByPlatform=or({transformByPlatform:t.transformByPlatform,source:i,canvasId:e.canvasId,syncAllDevices:t.syncAllDevices!==!1,sourceParentBox:r,targetParentBoxByPlatform:o})}var Ta=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"]),Ra=new Set(["posX","posY","width","height"]),Ma=new Set(["anchorMinX","anchorMinY","anchorMaxX","anchorMaxY","pivotX","pivotY"]);function Na(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 Fr(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 Fa=new Set(["fontSize","minimumFontSize","imageId","clickAudioId","softEdgeWidthX","softEdgeWidthY","horizontalSoftRange","verticalSoftRange","fillAmount","cellSizeX","cellSizeY","spacingX","spacingY","padding1X","padding1Y","padding2X","padding2Y","previewCount","keyboardKeyCode","controllerKeyCode"]),Oa=new Set(["active","visible","canControllerFocus","isolateNavigation","disableKeyEventPassthrough","disableCursorEventPassthrough","showCursor","adaptiveFontSize","enableOutline","enableMask","enableSoftEdge","enableFill","reverseMaskArea","raycastTarget","interactable","showScrollBar"]),$a=new Set(["name","horizontalAlignment","verticalAlignment","text","softEdgeMode","fillType","fillHorizontalType","fillVerticalType","fillRadial90Type","fillRadialType","scrollDirection","layoutConstraint","referencedPrefabId","animationId"]),Or=new Set(["unavailableChildId","hoverChildId","pressedChildId","selectedChildId"]),$r={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 Ga(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}=Ye(e.root,e.canvasId),r=Dr(e,n),o=sr(r,Number(t.x),Number(t.y));return o&&(e.selectedId=o),e}if(i==="setCanvas")return t.canvasId&&te[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:Gi(e.root),guid:Nr(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=ir(n,t.kind,{id:Gi(e.root),guid:Nr(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?ze(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||ka(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?ze(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=ze(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 nr(e.root,n)&&(W(e.root,o=>{if(o.kind==="button")for(let a of Or)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=Qn(n.kind,s);if(!f)throw new Error(`unknown raw GIA field for ${n.kind}: ${s}`);if(n.giaRaw||={},n.giaRaw[s]=Mi(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=Fr(o),n.syncAllDevices){let s=Ve(n.transformByPlatform,e.canvasId);It(e,n,s)}return e}if(Ta.has(r)){if(r.endsWith("Color")&&(o=Na(o)),Fa.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(Oa.has(r)&&(o=Fr(o)),$a.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($r[r]&&!$r[r].includes(o))throw new Error(`invalid ${r}`);if(Or.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}=Ye(e.root,e.canvasId),l=qi(e,n.id,a),c=Ve(n.transformByPlatform,e.canvasId);if(r==="anchorType"){let s=ji(a[n.id]),f=Wn(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(Ma.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(Ra.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=Ue(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 Ji(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 Ga(n,t),Gr(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 Da from"fengari";var{lua:u,lauxlib:oe,lualib:Vr,to_luastring:fi,to_jsstring:za}=Da,Va=u.LUA_TNIL,Ya=u.LUA_TBOOLEAN,Ba=u.LUA_TNUMBER,Ua=u.LUA_TSTRING,Yr=u.LUA_TTABLE,Ka=u.LUA_TFUNCTION,Zi=u.LUA_TUSERDATA,Te=u.LUA_OK,Br=new WeakMap,Qi=Symbol("luaTableEntries"),en={__scriptHostKey:!0};function P(e){return fi(String(e))}function nt(e,t){Br.set(e,t)}function Ie(e){return Br.get(e)}function se(e,t,i){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,P(i));return}if(n==="function"){La(e,t,i);return}if(i&&i[Qi]){let r=i[Qi];u.lua_createtable(e,Array.isArray(i)?i.length:0,r.length);for(let[o,a]of r)se(e,t,o),se(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++)se(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.SetEase){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))se(e,t,o),u.lua_setfield(e,-2,P(r));return}u.lua_pushnil(e)}function j(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?"":za(i)}function Ke(e,t){t=u.lua_absindex(e,t);let i=u.lua_type(e,t);if(i===Zi)return Ie(u.lua_touserdata(e,t));if(i===Yr){u.lua_pushlightuserdata(e,en),u.lua_rawget(e,t);let n=u.lua_type(e,-1)===Zi?u.lua_touserdata(e,-1):null;return u.lua_pop(e,1),n?Ie(n):null}return null}function ye(e,t,i){i=u.lua_absindex(e,i);let n=u.lua_type(e,i);if(n===Va)return null;if(n===Ya)return!!u.lua_toboolean(e,i);if(n===Ba)return u.lua_isinteger(e,i)?u.lua_tointeger(e,i):u.lua_tonumber(e,i);if(n===Ua)return j(e,i);if(n===Zi){let r=u.lua_touserdata(e,i);return Ie(r)??r}if(n===Ka)return Xa(e,t,i);if(n===Yr){let r=Ke(e,i);if(r)return r;let o=[];for(u.lua_pushnil(e);u.lua_next(e,i)!==0;){let s=ye(e,t,-2),f=ye(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,Qi,{value:o}),c}return null}function Xa(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=oe.luaL_ref(e,u.LUA_REGISTRYINDEX),o=Ha(e,t,r);return n!=null&&t.luaFunctions.set(n,o),o}function Ha(e,t,i){let n=(...r)=>{let o=u.lua_gettop(e);u.lua_rawgeti(e,u.LUA_REGISTRYINDEX,i);for(let s of r)se(e,t,s);if(u.lua_pcall(e,r.length,u.LUA_MULTRET,0)!==Te){let s=j(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(ye(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 Ur(e,t){if(!t||t.__luaRef==null||!t.__luaState)return;let i=t.__luaState;if((!e?.luaStates||e.luaStates.has(i))&&oe.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 La(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(ye(r,a,s));try{let s=o(...c);if(Array.isArray(s)&&s.__multi){for(let f of s)se(r,a,f);return s.length}return s===void 0?0:(se(r,a,s),1)}catch(s){return u.lua_pushstring(r,P(String(s&&s.message?s.message:s))),u.lua_error(r)}},2)}function Kr(e){!e||typeof u.lua_close!="function"||u.lua_close(e)}function Xr(e){if(oe.luaL_loadstring(e,P(["local nativeGetMetatable = getmetatable","getmetatable = function(value)",' if type(value) == "string" then return nil end'," return nativeGetMetatable(value)","end"].join(`
107
+ `)))===Te&&u.lua_pcall(e,0,0,0),u.lua_settop(e,0),u.lua_pushnil(e),u.lua_setglobal(e,P("_VERSION")),u.lua_getglobal(e,P("string")),!u.lua_isnil(e,-1))for(let i of["dump","pack","unpack"])u.lua_pushnil(e),u.lua_setfield(e,-2,P(i));if(u.lua_pop(e,1),u.lua_pushnil(e),u.lua_setglobal(e,P("io")),u.lua_getglobal(e,P("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,P(i));u.lua_pop(e,1),u.lua_getglobal(e,P("debug")),u.lua_isnil(e,-1)?u.lua_pop(e,1):(u.lua_getfield(e,-1,P("traceback")),u.lua_newtable(e),u.lua_pushvalue(e,-2),u.lua_setfield(e,-2,P("traceback")),u.lua_setglobal(e,P("debug")),u.lua_pop(e,2)),u.lua_getglobal(e,P("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,P("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,P("isinf"))),u.lua_pop(e,1),u.lua_pushnil(e),u.lua_setglobal(e,P("package")),u.lua_pushnil(e),u.lua_setglobal(e,P("load")),u.lua_pushnil(e),u.lua_setglobal(e,P("loadfile")),u.lua_pushnil(e),u.lua_setglobal(e,P("dofile")),u.lua_pushnil(e),u.lua_setglobal(e,P("collectgarbage")),u.lua_pushnil(e),u.lua_setglobal(e,P("coroutine")),u.lua_pushnil(e),u.lua_setglobal(e,P("fengari"))}var Hr={container:"ClientUIContainerControl",textbox:"ClientUITextBoxControl",textwindow:"ClientUITextWindowControl",image:"ClientUIImageControl",button:"ClientUIPresetButtonControl",cursor:"ClientUICursorEventAreaControl",grid:"ClientUIGridScrollerControl",keyhint:"ClientUIKeyHintControl",animation:"ClientUIAnimationControl",fullscreen:"ClientUIFullscreenAnimationControl",reference:"ClientUIReferenceControl"},Wa=["alive","Id","prefabIndex","active","activeInHierarchy","visible"],di=new Set(["active","visible","parent","sizeDeltaX","sizeDeltaY","anchorMinX","anchorMinY","anchorMaxX","anchorMaxY","pivotX","pivotY"]),ja=["name","parent","anchoredPositionX","anchoredPositionY","sizeDeltaX","sizeDeltaY","anchorMinX","anchorMinY","anchorMaxX","anchorMaxY","pivotX","pivotY","localScaleX","localScaleY","localScaleZ","localRotationX","localRotationY","localRotationZ","canControllerFocus"],qa={image:["imageSource","imageId"],grid:["itemCount","scrollDirection","layoutConstraint","layoutConstraintFixedCount"],reference:["referencedPrefabIndex"]},Ja={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"]},Za=["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"],Lr=["AddCursorEventListener","RemoveCursorEventListener","RemoveCursorEventListeners","RemoveAllCursorEventListeners","SimulateCursorClick"],Qa={image:["SetImage","SetSoftEdgeWidth","SetFillUnused","SetFillHorizontal","SetFillVertical","SetFillRadial90","SetFillRadial180","SetFillRadial360"],button:Lr,cursor:Lr,animation:["PlayAnimation","StopAnimation"],grid:["RefreshItems","GetItemIndex","GetItemSize","GetItemSpacing","GetPadding","ScrollToItemAt","GetContentLength"]};function tn(e,t){return Wa.includes(t)||(qa[e.kind]||[]).includes(t)?"ro":ja.includes(t)||(Ja[e.kind]||[]).includes(t)?"rw":null}function Wr(e,t){return Za.includes(t)||(Qa[e.kind]||[]).includes(t)}var el={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}},Xe=class e{constructor(t,i){this.runtime=t,this.kind=i.kind||"container",this.typeofName=Hr[this.kind]||Hr.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=el[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[this.localRotationX,this.localRotationY,this.localRotationZ]}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)}_removeListener(t,i,n){let r=t.get(i);r&&(t.set(i,r.filter(o=>o!==n)),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 Re(e,t){t(e);for(let i of e.children)Re(i,t)}function nn(e,t=[],i=""){t.push(`${i}${e.name||"(unnamed)"} [${e.typeofName}] Id=${e.Id}`);for(let n of e.children)nn(n,t,i+" ");return t}function hi(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 jr={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-hi(1-e),OutBounce:hi,InOutBounce:e=>e<.5?(1-hi(1-2*e))/2:(1+hi(2*e-1))/2};function qr(e,t){let i=jr[e]||jr.Linear;return t<=0?0:t>=1?1:i(t)}function wt(e,t,i,n=255){let r=mi(e),o=mi(t),a=mi(i);return((n==null?255:mi(n))<<24|r<<16|o<<8|a)>>>0}function zt(e){let t=e>>>0;return[t>>>16&255,t>>>8&255,t&255,t>>>24&255]}function mi(e){let t=Number(e);return Number.isFinite(t)?Math.max(0,Math.min(255,Math.trunc(t))):0}function Jr(e,t,i){let n=zt(e),r=zt(t);return wt(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 tl=new Set(["fontColor","bgColor","outlineColor","imageColor"]),pi=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}capture(){this.from={},this.to={};for(let[t,i]of Object.entries(this.data)){let n=this.object[t];this.from[t]=n,this.to[t]=this.relative?Number(n)+Number(i):i}}restoreInitial(){this.initialFrom?(this.from={...this.initialFrom},this.to={...this.initialTo}):this.capture()}SetEase(t){return this.easeName=typeof t=="string"?t:t?.Name||"Linear",this}SetRelative(t){return this.relative=!!t,this}Play(){return this._start(!1)}_start(t){return this.playing=!0,this.paused=!1,this.elapsed=0,this.loopIndex=0,this.killed=!1,t&&this.initialFrom?this.restoreInitial():(this.capture(),this.initialFrom={...this.from},this.initialTo={...this.to}),this.runtime.tweens.add(this),this.duration===0&&this.Complete(),this}Pause(){this.paused=!0}Resume(){this.paused=!1}Restart(){return this._start(!0)}Complete(){this.apply(1),this.finish(!0)}Kill(t){t?this.Complete():this.finish(!1)}SetOnComplete(t){return this.onComplete=t,this}SetOnStepComplete(t){return this.onStepComplete=t,this}SetLoops(t){return this.loops=t,this}apply(t){let i=qr(this.easeName,t),n=!1,r=!1;for(let o of Object.keys(this.to)){let a=this.from[o],l=this.to[o];tl.has(o)&&typeof a=="number"&&typeof l=="number"?this.object[o]=Jr(a,l,i):typeof a=="number"&&typeof l=="number"?this.object[o]=a+(l-a)*i:this.object[o]=i>=1?l:a,n=!0,di.has(o)&&(r=!0)}n&&typeof this.object?.markPlayDirty=="function"&&this.object.markPlayDirty(r)}step(t){if(!this.playing||this.paused||this.killed)return;this.elapsed+=t;let i=this.duration<=0?1:Math.min(1,this.elapsed/this.duration);if(this.apply(i),i>=1){this.onStepComplete&&this.runtime.safeCall(this.onStepComplete);let n=this.loops<0;if(this.loopIndex++,n||this.loopIndex<this.loops){this.elapsed=Math.max(0,this.elapsed-this.duration),this.relative?this.capture():this.restoreInitial();let r=this.duration<=0?1:Math.min(1,this.elapsed/this.duration);this.apply(r)}else this.finish(!0)}}finish(t){this.playing=!1,this.killed=!0,this.runtime.tweens.delete(this),t&&this.onComplete&&this.runtime.safeCall(this.onComplete)}},gi=class{constructor(t){this.runtime=t,this.steps=[],this.playing=!1,this.paused=!1,this.killed=!1,this.elapsed=0,this.loops=1,this.loopIndex=0,this.onComplete=null,this.onStepComplete=null,this._built=[]}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.playing=!0,this.paused=!1,this.killed=!1,this.elapsed=0,this.loopIndex=0,this._schedule(),this._activateDueEntries(),this.runtime.sequences.add(this),this}_schedule(){let t=0,i=0,n=!1;this._built=[];for(let r of this.steps)if(r.kind==="tween"&&r.parallel){let o=n?i:t;this._built.push({at:o,tween:r.tween}),t=Math.max(t,o+r.tween.duration)}else r.kind==="tween"?(this._built.push({at:t,tween:r.tween}),i=t,n=!0,t+=r.tween.duration):r.kind==="interval"?(i=t,n=!0,t+=r.duration):r.kind==="callback"?this._built.push({at:t,fn:r.fn}):r.kind==="insert"?(this._built.push({at:r.time,tween:r.tween}),t=Math.max(t,r.time+r.tween.duration)):r.kind==="insertCb"&&(this._built.push({at:r.time,fn:r.fn}),t=Math.max(t,r.time));this._end=t,this._fired=new Set}Pause(){this.paused=!0;for(let t of this._built)t.tween&&this._fired.has(t)&&t.tween.Pause()}Resume(){this.paused=!1;for(let t of this._built)t.tween&&this._fired.has(t)&&t.tween.Resume()}Restart(){this.Play()}Complete(){for(let t of this._built)t.tween&&(this._fired.has(t)||t.tween.Play(),t.tween.Complete()),t.fn&&!this._fired.has(t)&&this.runtime.safeCall(t.fn),this._fired.add(t);this.finish(!0)}Kill(t){if(t)this.Complete();else{for(let i of this._built)i.tween&&this._fired.has(i)&&i.tween.Kill(!1);this.finish(!1)}}SetOnComplete(t){return this.onComplete=t,this}SetOnStepComplete(t){return this.onStepComplete=t,this}SetLoops(t){return this.loops=t,this}_activateDueEntries(){for(let t of this._built)this._fired.has(t)||this.elapsed+1e-9<t.at||(this._fired.add(t),t.tween&&t.tween.Play(),t.fn&&this.runtime.safeCall(t.fn))}step(t){!this.playing||this.paused||this.killed||(this.elapsed+=t,this._activateDueEntries(),this.elapsed>=this._end&&(this.onStepComplete&&this.runtime.safeCall(this.onStepComplete),this.loopIndex++,this.loops<0||this.loopIndex<this.loops?(this.elapsed=0,this._schedule()):this.finish(!0)))}finish(t){this.playing=!1,this.killed=!0,this.runtime.sequences.delete(this),t&&this.onComplete&&this.runtime.safeCall(this.onComplete)}};var yi={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"]},il=[...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"],nl=[...Array.from({length:14},(e,t)=>`CraftspersonKey${t+1}`),"SprintKey","JumpKey","InteractKey","NormalAttackKey","CharacterSkill1Key","CharacterSkill2Key","CharacterSkill3Key","CharacterSkill4Key","MenuConfirmKey","MenuBackKey","None"];function rl(){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}yi.KeyboardKeyCode=il;yi.ControllerKeyCode=nl;yi.KeyEventType=rl();var Zr=new Map;function rt(e,t){let i=`${e}\0${t}`,n=Zr.get(i);return n||(n={__kind:"EnumItem",Name:t,FullName:`Enum.${e}.${t}`,EnumType:e},Zr.set(i,n)),n}function rn(e,t){return t==null?t:t.__kind==="EnumItem"?rt(t.EnumType||e,t.Name):typeof t=="string"&&t?rt(e,t):t}function on(){let e={};for(let[t,i]of Object.entries(yi)){let n={};for(let r of i)n[r]=rt(t,r);e[t]=n}return e}var Qr={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,ol=u.LUA_MULTRET,al=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 bi=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.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=on(),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)}unrefLuaCallback(t){Ur(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 Xe?t:new Xe(this,t);return this.roots.push(i),Re(i,n=>this.controlsById.set(n.Id,n)),this.mountSpecScripts(t,i),i}mountSpecScripts(t,i){if(t instanceof Xe)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(ye(n,i,a));return i.log("info",...o),0}),u.lua_setglobal(t,P("print")),u.lua_pushcfunction(t,n=>{let r=u.lua_gettop(n),o=[];for(let a=1;a<=r;a++)o.push(ye(n,i,a));return i.log("error",...o),0}),u.lua_setglobal(t,P("printerr")),u.lua_pushcfunction(t,n=>{if(u.lua_type(n,1)===u.LUA_TTABLE&&!Ke(n,1))return u.lua_pushstring(n,P("table")),1;let r=ye(n,i,1);return u.lua_pushstring(n,P(i.typeofOf(r))),1}),u.lua_setglobal(t,P("typeof")),this.pushColorLib(t),this.pushEnumLib(t),this.pushGameLib(t),u.lua_pushcfunction(t,n=>i.luaRequire(n)),u.lua_setglobal(t,P("require"))}typeofOf(t){return t==null?"nil":t.__kind==="Script"?"Script":t.__kind==="EnumItem"?"EnumItem":t.__kind==="CursorEventData"?"CursorEventData":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,wt(u.lua_tonumber(i,1),u.lua_tonumber(i,2),u.lua_tonumber(i,3),255)),1)),u.lua_setfield(t,-2,P("FromRGB")),u.lua_pushcfunction(t,i=>{let n=u.lua_isnoneornil(i,4)?255:u.lua_tonumber(i,4);return this.pushPackedColor(i,wt(u.lua_tonumber(i,1),u.lua_tonumber(i,2),u.lua_tonumber(i,3),n)),1}),u.lua_setfield(t,-2,P("FromRGBA")),u.lua_pushcfunction(t,i=>{let n=u.lua_tonumber(i,1)>>>0,[r,o,a,l]=zt(n);return u.lua_pushnumber(i,r),u.lua_pushnumber(i,o),u.lua_pushnumber(i,a),u.lua_pushnumber(i,l),4}),u.lua_setfield(t,-2,P("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,wt(n,r,o,a)),1}),u.lua_setfield(t,-2,P("__call")),u.lua_setmetatable(t,-2),u.lua_setglobal(t,P("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,P(r));u.lua_setfield(t,-2,P(i))}u.lua_setglobal(t,P("Enum"))}pushEnumItem(t,i){let n=u.lua_newuserdata(t,0);nt(n,i),oe.luaL_setmetatable(t,P("EnumItem"))}pushControl(t,i){let n=u.lua_newuserdata(t,0);nt(n,i),oe.luaL_setmetatable(t,P("Control"))}pushScript(t,i){u.lua_newtable(t),u.lua_pushlightuserdata(t,en);let n=u.lua_newuserdata(t,0);nt(n,i),u.lua_rawset(t,-3),oe.luaL_getmetatable(t,P("Script")),u.lua_setmetatable(t,-2)}pushTween(t,i){let n=u.lua_newuserdata(t,0);nt(n,i);let r=i.Append?"TweenSequence":"Tween";oe.luaL_setmetatable(t,P(r))}pushCursor(t,i){let n=u.lua_newuserdata(t,0);nt(n,i),oe.luaL_setmetatable(t,P("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=j(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))||ye(r,i,1),a=ye(r,i,2)||{},l=u.lua_tonumber(r,3),c=new pi(i,o,a,l);return i.pushTween(r,c),1},TweenSequence:r=>(i.pushTween(r,new gi(i)),1),ServerSignal:r=>{let o=j(r,1),a=i.makeServerSignal(o),l=u.lua_newuserdata(r,0);return nt(l,a),oe.luaL_setmetatable(r,P("ServerSignal")),1},GetGlobalCustomVariableValue:r=>{let o=be(ye(r,i,1)),a=j(r,2);return se(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=j(r,1);return u.lua_pushstring(r,P(o)),1},PrintClientUITree:r=>{for(let o of i.roots)i.log("info",nn(o).join(`
108
+ `));return 0}};for(let[r,o]of Object.entries(n)){let a=al[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?oe.luaL_error(l,P(`bad argument count to '${r}' (${a} expected, got ${c})`)):o(l)}),u.lua_setfield(t,-2,P(r))}u.lua_setglobal(t,P("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 Xe(this,{...r,Id:this.nextControlId(),authoringId:null,prefabIndex:Number(t)});return i.addChild(o),Re(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}`);Re(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=[];Re(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,P("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){oe.luaL_newmetatable(t,P(i)),u.lua_pushcfunction(t,l=>{let c=Ke(l,1)||Ie(u.lua_touserdata(l,1)),s=j(l,2);if(o[s]&&(!a||a(c,s)))return u.lua_pushcfunction(l,o[s]),1;let f=n(c,s);return f===void 0?(u.lua_pushnil(l),1):(se(l,this,f),1)}),u.lua_setfield(t,-2,P("__index")),u.lua_pushcfunction(t,l=>{try{let c=Ke(l,1)||Ie(u.lua_touserdata(l,1)),s=j(l,2),f=ye(l,this,3);return r(c,s,f),0}catch(c){return u.lua_pushstring(l,P(String(c.message||c))),u.lua_error(l)}}),u.lua_setfield(t,-2,P("__newindex")),u.lua_pushcfunction(t,l=>{let c=Ke(l,1)||Ie(u.lua_touserdata(l,1)),s=Ke(l,2)||Ie(u.lua_touserdata(l,2));return u.lua_pushboolean(l,c===s),1}),u.lua_setfield(t,-2,P("__eq")),u.lua_pop(t,1)}method(t){let i=this;return n=>{let r=Ke(n,1)||Ie(u.lua_touserdata(n,1)),o=u.lua_gettop(n),a=[];for(let l=2;l<=o;l++)a.push(ye(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)se(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 se(n,i,l),1}catch(l){return u.lua_pushstring(n,P(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(!tn(n,r))return;let o=n[r],a=Qr[r];return a?rn(a,o):o},(n,r,o)=>{if(tn(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=Qr[r];n[r]=l?rn(l,o):o,typeof n.markPlayDirty=="function"&&n.markPlayDirty(di.has(r));return}throw new Error(`cannot set ${r}, no such field`)},i,Wr)}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:this.method((r,o,...a)=>r.invoke(o,a)),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=j(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,P(`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,P(`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=oe.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,P(`failed to load script '${n}': ${f.message||f}`)),u.lua_error(t)}}newLuaThread(){let t=oe.luaL_newstate();return Vr.luaL_openlibs(t),Xr(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,oe.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,P("_G"))}closeTrackedLuaState(t){if(!t||!this.luaStates.has(t))return;for(let n of this.requireCache.get(t)?.values()||[])n.ref!=null&&oe.luaL_unref(t,ot,n.ref);this.requireCache.delete(t);let i=this.moduleBaseEnvironments.get(t);if(i!=null&&oe.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);Kr(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=fi(a);if(oe.luaL_loadbuffer(t,l,l.length,P(`@${n}`))!==Te)throw new Error(j(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,P("script")),u.lua_setupvalue(t,s,1),u.lua_pcall(t,0,1,0)!==Te)throw new Error(j(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,P("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=fi(r),a=oe.luaL_loadbuffer(t,o,o.length,P(`@${n}`));if(a!==Te){let c=j(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!==Te){let c=j(t,-1)||`lua_pcall status ${l}`;throw u.lua_pop(t,1),new Error(c)}}callGlobal(t,i){if(u.lua_getglobal(t,P(i)),u.lua_isfunction(t,-1)){if(u.lua_pcall(t,0,0,0)!==Te){let r=j(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,P(i)),u.lua_isfunction(t,-1)){if(u.lua_pushnumber(t,n),u.lua_pcall(t,1,0,0)!==Te){let o=j(t,-1);u.lua_pop(t,1),this.log("lua-error",`${i}: ${o}`)}}else u.lua_pop(t,1)}invokeOn(t,i,n){let r=u.lua_gettop(t);if(u.lua_getglobal(t,P(i)),!u.lua_isfunction(t,-1)){u.lua_settop(t,r);return}for(let c of n)se(t,this,c);if(u.lua_pcall(t,n.length,ol,0)!==Te){let c=j(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=ye(t,this,-1);return u.lua_settop(t,r),c}let l=[];for(let c=1;c<=a;c++)l.push(ye(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,P("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.tweens])n.step(t);for(let n of[...this.sequences])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,P(o))};return r("var",o=>(se(o,this,i.var(j(o,1),j(o,2))),1)),r("logContains",o=>(u.lua_pushboolean(o,i.logContains(j(o,1))),1)),r("control",o=>(se(o,this,i.control(j(o,1))),1)),r("logs",o=>(se(o,this,i.logs()),1)),r("signals",o=>(se(o,this,i.signals(j(o,1))),1)),r("serverLogs",o=>(se(o,this,i.serverLogs?i.serverLogs():[]),1)),r("serverLogContains",o=>{let a=i.serverLogContains;return u.lua_pushboolean(o,a?!!a(j(o,1)):!1),1}),u.lua_setglobal(n,P("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 Vt(e){let t=new bi(e);return t.boot(),t}var lt=Object.freeze(Array.from({length:8},(e,t)=>`Player${t+1}`)),sn=Object.freeze(Array.from({length:8},(e,t)=>`Avatar${t+1}`)),lo=Object.freeze(["Level","PlayerSelf","AvatarSelf"]);var an=Object.freeze([...lo,...lt,...sn]),so=Object.freeze(["PlayerSelf","AllPlayers",...lt]),ll=Object.freeze(["Level","PlayerSelf",...lt]),eo=Object.freeze(["Int","Float","String","Bool","Vector3","Entity","Guid","PrefabId","ConfigId","IntList","FloatList","StringList","BoolList","Vector3List","EntityList","GuidList","PrefabIdList","ConfigIdList","Dict","Struct"]),sl=-2147483648,ul=2147483647,cl=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 Yt(e){return`Player${Number(e)}`}function vi(e){return`Avatar${Number(e)}`}function to(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 Oe(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 io(){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 sn)e[t]=Object.create(null);return e}function uo(e){let t=String(e||"");if(!an.includes(t))throw new Error(`unknown CustomVariableEntityType: ${e}`);return t}function fl(e,t){let i=uo(e);if(!ll.includes(i))throw new Error(`${t}.entityType must be Level, PlayerSelf, or Player1-8`);return i}function Bt(e){let t=String(e??"");if(!t)throw new Error("custom variable name is required");return t}function Si(e){let t=String(e??"");if(!t)throw new Error("signal name is required");return t}function ln(e){let t=String(e||"PlayerSelf");if(!so.includes(t))throw new Error(`unsupported client signal target: ${e}. use PlayerSelf, AllPlayers, or Player1-8`);return t}function Ut(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=Ut(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 no(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 ro(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:Ut(t),value:t}):[]}function dl(e){return String(e?.kind||e?.type||e?.name||e?.id||"")}function Ci(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function co(e,t){if(!Ci(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 oo(e,t){return co(e,t)||Se(e)}function hl(e,t,i){if(!Ci(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=fl(e.entityType,r);if(!Object.prototype.hasOwnProperty.call(e,"value"))throw new Error(`${r}.value is required`);return{kind:n,entityType:o,name:Bt(e.name),value:oo(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:ln(e.target),signalName:Si(e.signalName),params:e.params.map((o,a)=>oo(o,`${r}.params[${a}]`))}}throw new Error(`${r}.kind must be setCustomVariable or sendClientScriptSignal`)}function Kt(e){if(e==null)return{version:1,rules:[]};if(!Ci(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(!Ci(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:Si(i.signalName),actions:i.actions.map((r,o)=>hl(r,n,o))}})}}function ao(e,t,{typed:i=!1}={}){let n=co(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 ml(e){return e==="Level"?"Level":lt.includes(e)?"PlayerSelf":sn.includes(e)?"AvatarSelf":e}function fo(e={}){let t=io(),i=io(),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=Kt(e.logic),h=at(e.playerCount),g=Oe(e.viewPlayerIndex,h);function v(y,x){a.push({source:"server",level:String(y||"engine"),text:String(x),time:s})}function w(y){let x=l[y||g],b=Number(x?.clock?.time);Number.isFinite(b)&&(s=b)}function N(y,x,b,I){t[y][x]=b,i[y][x]={type:I||Ut(b)||i[y][x]?.type||""}}function E(y,x,b){return typeof b!="number"||!Number.isInteger(b)?{ok:!0,value:b}:b>=sl&&b<=ul?{ok:!0,value:b}:(v("engine",`Int custom variable ${y}.${x} out of range ${b}; keeping previous legal value`),{ok:!1,value:t[y][x]})}function k(y,x){let b=uo(y),I=x||g;return b==="PlayerSelf"?Yt(I):b==="AvatarSelf"?vi(I):b}function B(y,x){let b=ml(y);if(y==="Level"){for(let S=1;S<=h;S+=1){let R=l[S];R&&typeof R.notifyVarHandlers=="function"&&R.notifyVarHandlers("Level",x)}return}let I=to(y);if(!I)return;let F=l[I];F&&typeof F.notifyVarHandlers=="function"&&F.notifyVarHandlers(b,x)}function $(y,x){let b=ln(y);return b==="AllPlayers"?Array.from({length:h},(I,F)=>F+1):b==="PlayerSelf"?[x||g]:[to(b)]}function q(y){for(let x of m.rules)if(x.signalName===y.name)for(let b of x.actions){if(b.kind==="setCustomVariable"){let I=ao(b.value,y);O.setVar(b.entityType,b.name,I,{type:b.variableType,playerIndex:y.playerIndex}),v("info",`logic ${x.id}: set ${b.entityType}.${b.name}`);continue}if(b.kind==="sendClientScriptSignal"){let I=b.params.map(F=>ao(F,y,{typed:!0}));O.sendToClient(b.signalName,I,{target:b.target,playerIndex:y.playerIndex}),v("info",`logic ${x.id}: sent ${b.signalName} to ${b.target}`)}}}function Q(y,x){y&&(y.serverBridge={getVar:(b,I)=>O.getVar(b,I,{playerIndex:x}),setVar:(b,I,F)=>O.setVar(b,I,F,{playerIndex:x}),receiveFromClient:(b,I)=>O.receiveFromClient(b,I,{playerIndex:x})})}function J(y){y&&(y.serverBridge=null)}let O={ENTITY_TYPES:lo,ALL_ENTITY_TYPES:an,CLIENT_SIGNAL_TARGETS:so,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=Oe(y,h),g},log(y,x){v(y,x)},defineVar(y,x,b={},{playerIndex:I}={}){let F=k(y,I),S=Bt(x);if(Object.prototype.hasOwnProperty.call(t[F],S))throw new Error(`custom variable already exists: ${F}.${S}`);let R=b.type?String(b.type):Ut(b.value??b.defaultValue);if(R&&!eo.includes(R))throw new Error(`unsupported custom variable type: ${R}`);let D=b.value!==void 0?b.value:b.defaultValue!==void 0?b.defaultValue:null;return N(F,S,D,R),O.getVar(F,S)},getVar(y,x,{playerIndex:b}={}){let I=k(y,b),F=Bt(x);if(!Object.prototype.hasOwnProperty.call(t[I],F)){v("engine",`GetGlobalCustomVariableValue missing ${I}.${F}; returning nil (simulator policy)`);return}return t[I][F]},setVar(y,x,b,{notify:I=!0,type:F,playerIndex:S}={}){let R=k(y,S),D=Bt(x),U=F||i[R][D]?.type||Ut(b);if(U&&!eo.includes(U)&&U!=="")throw new Error(`unsupported custom variable type: ${U}`);let ae=b;if(!((U==="Int"||U===""&&typeof b=="number"&&Number.isInteger(b))&&(ae=E(R,D,b).value,ae===void 0)))return N(R,D,ae,U),I&&B(R,D),ae},listVars(y){let x=y?[k(y)]:["Level",...Array.from({length:h},(I,F)=>Yt(F+1)),...Array.from({length:h},(I,F)=>vi(F+1))],b=[];for(let I of x)for(let F of Object.keys(t[I]))b.push({entityType:I,name:F,type:i[I][F]?.type||"",value:Se(t[I][F])});return b},receiveFromClient(y,x=[],{playerIndex:b}={}){let I=Oe(b||g,h);w(I);let F=Si(y),S={id:c++,direction:"inbound",name:F,params:ro(x),values:no(x),time:s,playerIndex:I,from:Yt(I)};return n.push(S),q(S),S},sendToClient(y,x=[],{target:b="PlayerSelf",playerIndex:I}={}){let F=Si(y),S=ln(b),D=$(S,I||g),U={id:c++,direction:"outbound",name:F,params:ro(x),values:no(x),time:s,target:S,players:D,deliverAt:s+f/1e3,delivered:!1};return r.push(U),f===0?O.deliver(U):o.push(U),U},getLogic(){return Se(m)},setLogic(y){return m=Kt(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 b of x){let I=l[b];I&&typeof I.sendClientSignal=="function"&&I.sendClientSignal(y.name,y.values)}},flush(y){y!==void 0&&(s=Number(y)||0);let x=[];for(let b=o.length-1;b>=0;b-=1)o[b].deliverAt<=s&&x.push(o.splice(b,1)[0]);x.sort((b,I)=>b.id-I.id);for(let b of x)O.deliver(b);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 b=dl(x);if(!cl.has(b))throw new Error(`unsupported server node: ${b||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 b=k(x.entityType),I=Bt(x.name);Object.prototype.hasOwnProperty.call(t[b],I)?O.setVar(b,I,x.value??x.defaultValue,{notify:!1,type:x.type}):O.defineVar(b,I,x)}}},attachRuntime(y,{playerIndex:x=1}={}){let b=Oe(x,8);return l[b]&&l[b]!==y&&J(l[b]),l[b]=y||null,Q(l[b],b),O},attachRuntimes(y){O.detachRuntime();let x=Array.isArray(y)?y:[];for(let b=0;b<x.length&&b<8;b+=1)l[b+1]=x[b]||null,Q(l[b+1],b+1);return O},detachRuntime(){for(let y=1;y<=8;y+=1)J(l[y]),l[y]=null},snapshot(){let y=Yt(g),x=vi(g),b={Level:{},PlayerSelf:{},AvatarSelf:{}};for(let I of Object.keys(t.Level))b.Level[I]={type:i.Level[I]?.type||"",value:Se(t.Level[I])};for(let I of Object.keys(t[y]))b.PlayerSelf[I]={type:i[y][I]?.type||"",value:Se(t[y][I])};for(let I of Object.keys(t[x]))b.AvatarSelf[I]={type:i[x][I]?.type||"",value:Se(t[x][I])};for(let I=1;I<=h;I+=1){let F=Yt(I),S=vi(I);b[F]={},b[S]={};for(let R of Object.keys(t[F]))b[F][R]={type:i[F][R]?.type||"",value:Se(t[F][R])};for(let R of Object.keys(t[S]))b[S][R]={type:i[S][R]?.type||"",value:Se(t[S][R])}}return{clock:s,onlineLatencyMs:f,playerCount:h,viewPlayerIndex:g,logic:O.getLogic(),vars:b,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 an){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 pl={container:"container",textbox:"textbox",image:"image",button:"button",cursor:"cursor",grid:"grid",reference:"reference",textwindow:"textwindow",keyhint:"keyhint",animation:"animation",fullscreen:"fullscreen"};function un(e,t,i=null){let n=Ve(e.transformByPlatform,t),r={authoringId:e.id,kind:pl[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=>un(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 cn(e,t=[],i=""){let n=i&&te[i]?i:e.canvasId,r=te[n],o=Ot(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=>un(c,n,a)):[];return{canvasId:n,platform:r.platform,device:r.luaDevice,canvasWidth:r.width,canvasHeight:r.height,root:un(o,n,a),templates:l}}var Ii="qxqy-autotest";var st=.03333333333333333,gl=new Set(["pointer","key","click","pause","resume","serverSet","serverSend","view"]),yl=new Set(["log","control","var","signal","tree","lua"]);function Xt(e,t){let i=Number(e);if(!Number.isFinite(i))throw new Error(`${t} must be a finite number`);return i}function fn(e){return JSON.parse(JSON.stringify(e??null))}function wi(e,t){if(!e||typeof e!="object")throw new Error(`events[${t}] must be an object`);let i=String(e.kind||e.do||"");if(!gl.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=Xt(n.x,"pointer.x"),n.y=Xt(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:Xt(e.t??0,"event.t"),source:String(e.source||"user"),kind:i,payload:n}}function dn(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(!yl.has(i))throw new Error(`unsupported assert kind: ${i||"(empty)"}`);let n={kind:i};if(e.at!==void 0&&(n.at=Xt(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=fn(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=fn(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=fn(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 ho(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+=Xt(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(wi({...r,kind:r.do,t},i.length));continue}if(r.assert||r.check||r.kind){n.push(dn({...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 Ht(e){if(Array.isArray(e)){let n=ho(e);return{format:Ii,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=ho(e.queue||e.steps);return{format:Ii,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)=>wi(n,r)),i=(e.asserts||[]).map((n,r)=>dn(n,r));return t.sort((n,r)=>n.t-r.t||0),{format:Ii,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 mo(e,t={}){let i=(e||[]).map((n,r)=>wi(n,r));return{format:Ii,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)=>dn(n,r))}}function po(e,t,i){if(!e)return null;let n=wi({...t,t:t.t??i??0},e.events.length);return e.events.push(n),n}var bl=Object.freeze(Object.values(te).map(e=>Object.freeze({id:e.id,label:e.label,platform:e.platform,width:e.width,height:e.height})));function gn(e){let t=ge({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 vl(e,t=gn(e)){let i=new Map;function n(r,o){let a=t.get(r.Id);if(!a)return;let l=Ft(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 yo(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=>yo(n,t))}}function Sl(){return{pointerDownControl:null,pointerDownPosition:null,pointerLastPosition:null,pointerDragging:!1,pointerHoverControl:null,hoveredControl:null,selectedControl:null,stateRestores:new Map,viewCache:null}}function Cl(e,t,i,n){let r=Vt({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 Il=["pointerDownControl","pointerDownPosition","pointerLastPosition","pointerDragging","pointerHoverControl","hoveredControl","selectedControl","stateRestores","viewCache"];function wl(e){Object.defineProperty(e,"runtime",{configurable:!0,enumerable:!0,get(){return e.runtimes[e.viewPlayerIndex-1]}});for(let t of Il)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 bo(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=cn(e,f,a),g=t?cn(t,m,a):null,v=at(l),w=Oe(c,v),N=fo({playerCount:v,viewPlayerIndex:w});o&&N.loadConfig({...o,playerCount:v,viewPlayerIndex:w});let E=[];for(let $=0;$<v;$+=1)E.push(Cl(h,g,i,s));N.attachRuntimes(E);for(let $ of E)$.addRoot(h.root);let k={runtimes:E,views:E.map(()=>Sl()),playerCount:v,viewPlayerIndex:w,server:N,compiled:h,mountError:E.find($=>$.mountErrors[0])?.mountErrors[0]||null,debugPaused:!1,history:{events:[]},recording:!0};wl(k);let B=k.viewPlayerIndex;for(let $=1;$<=v;$+=1)k.viewPlayerIndex=$,Ol(k);return k.viewPlayerIndex=B,k}function yn(e,t){if(!e)throw new Error("play session has not started");let i=Oe(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||po(e.history,{...t,source:t.source||"user"},e.runtime.clock.time)}function xl(e){return e?.history?.events||[]}var bn=new Set(["image","textbox","textwindow","button"]);function El(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 vo(e){return{fillType:ut(e.fillType),fillHorizontalType:ut(e.fillHorizontalType),fillVerticalType:ut(e.fillVerticalType),fillAmount:e.fillAmount}}function Al(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,vo(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 kl(e,t=gn(e)){let i=[],n=vl(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=El(a,l);bn.has(o.kind)&&i.push(Al(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 _l(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,vo(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 Pl(e,t,i){let n=Ti(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 So(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 Co(e,t,i,n,r,o){return{id:e.Id,parent:t,z:r,group:o>=16,matrix:Pl(n,e,i),..._l(e,n)}}function Tl(e){let t=ge({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=bn.has(c.kind),v=0;for(let w=0;w<h.length;w+=1)o(h[w],m,m.activeInHierarchy)&&(g=!0,v+=1);return g?(i.add(c.Id),n.set(c.Id,v),!0):!1}function a(c,s,f,m){if(!i.has(c.Id))return;let h=r.get(c.Id);l.push(Co(c,s,f,h,m,n.get(c.Id)||0));let g=c.children||[];for(let v=0;v<g.length;v+=1)a(g[v],c.Id,h,v)}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 pn(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)pn(i[n])}function Rl(e,t){let i=ge({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,v){let w=v||s._playDeepDirty===!0,N=w||s._playDirty===!0,E=w||s._playChildDirty===!0;if(!N&&!E)return;if(!(g&&s.active!==!1)||s.visible===!1){l(s);return}let B=Ne(f,s),$=t.childCounts.get(s.Id)||0;if(E){$=0;let x=s.children;for(let b=0;b<x.length;b+=1)c(x[b],B,s.Id,b,!0,w),t.fingerprints.has(x[b].Id)&&($+=1)}if(!(bn.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 Q=t.childCounts.get(s.Id);t.childCounts.set(s.Id,$);let J=$>=16!=(Q||0)>=16;if(!N&&!J&&t.fingerprints.has(s.Id))return;let O=Co(s,m,f===i?null:f,B,h,$),y=So(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 Ml(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}=Tl(e);i.rev+=1,i.fingerprints=new Map(c.map(f=>[f.id,So(f)])),i.childCounts=s,i.count=c.length;for(let f of e.runtime.roots)pn(f);return{format:"tree-v1",revision:i.rev,reset:!0,count:c.length,nodes:c}}let{changed:o,removed:a,count:l}=Rl(e,i);i.rev+=1;for(let c of e.runtime.roots)pn(c);return{format:"tree-v1",revision:i.rev,reset:!1,count:l,changed:o,removed:a}}function vn(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=xl(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:bl,playerCount:e.playerCount||1,viewPlayerIndex:e.viewPlayerIndex||1,players:Array.from({length:e.playerCount||1},(v,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(v=>({source:"client",level:v.level,text:v.text,time:v.time})),tree:[],paint:[],scene:null,server:h,history:(o?m.slice(-100):m).map(v=>({t:v.t,source:v.source||"user",kind:v.kind,payload:v.payload||{}}))};if(t||n){let v=gn(e);t&&(g.tree=a.roots.map(w=>yo(w,v))),n&&(g.paint=kl(e,v))}return i&&(g.scene=Ml(e,r)),yt(g),g}function xi(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 Sn(e,t){He(e,{kind:"key",payload:{typeName:String(t)}}),e.runtime.injectKey(t)}function Nl(e,t){let i=null;for(let n of e.runtime.roots)Re(n,r=>{!i&&r.name===t&&(i=r)});return i}function Cn(e,t){He(e,{kind:"click",payload:{name:String(t)}});let i=Nl(e,t);i&&In(i)&&(i.kind==="button"||i.kind==="cursor")&&i.SimulateCursorClick()}function Fl(e,t){return!e||!t?null:e.children.find(i=>i.authoringId===t||i.Id===t)||null}var Io={unavailable:"unavailableChildId",hover:"hoverChildId",pressed:"pressedChildId",selected:"selectedChildId"};function wo(e,t){let i=[];for(let[n,r]of Object.entries(Io)){let o=t[r]?Fl(t,t[r]):null;o&&i.push({state:n,child:o})}return i}function Ol(e){for(let t of e.runtime.roots)Re(t,i=>{if(i.kind==="button"){for(let{child:n}of wo(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);Wt(e,i)}})}function Wt(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 wo(e,t))n.child.active=!0,n.child.visible=n.state===i,typeof n.child.markPlayDirty=="function"&&n.child.markPlayDirty(!0)}function hn(e){if(!e)return null;let t=e.parent;return t?.kind==="button"&&Object.values(Io).map(n=>t[n]).filter(Boolean).includes(e.authoringId)?t:e}function In(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 xo(e){return e.kind==="container"||e.kind==="grid"||e.kind==="textwindow"||e.kind==="reference"||e.kind==="button"}function Eo(e,t){let i=e.Id,n=t.get(i);if(n!==void 0)return n;let r=In(e);if(!r&&xo(e)){let o=e.children;for(let a=0;a<o.length;a+=1)if(Eo(o[a],t)){r=!0;break}}return t.set(i,r),r}function mn(e,t,i){let n=ge({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||!Eo(l,r))return null;let m=Ne(c,l),h=Ft(s,m,l),g=ri(h);if(!g)return null;let v=Je(g,t,i);if(v.x<m.left||v.x>m.right||v.y<m.bottom||v.y>m.top)return null;if(xo(l))for(let w=0;w<l.children.length;w+=1){let N=o(l.children[w],m,h,!0);if(N)return N}return In(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 Lt(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 go(e,t,i){t.pressed=i,typeof t.markPlayDirty=="function"&&t.markPlayDirty(),Wt(e,t)}function jt(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=hn(mn(e,o,a)),f=Lt(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&&Wt(e,m),e.hoveredControl&&Wt(e,e.hoveredControl);let h=e.pointerDownControl;if(h){let g=e.pointerDownPosition||l,v=o!==l.x||a!==l.y;!e.pointerDragging&&v&&(e.runtime.injectCursor(h,"CursorBeginDrag",Lt(e,o,a,{press:g,previous:l,dragging:!1})),e.pointerDragging=!0),e.pointerDragging&&e.runtime.injectCursor(h,"CursorDrag",Lt(e,o,a,{press:g,previous:l,dragging:!0}))}return e.pointerLastPosition={x:o,y:a},s}if(t==="down"){let l=hn(mn(e,o,a));return e.pointerDownControl=l,e.pointerDownPosition={x:o,y:a},e.pointerLastPosition={x:o,y:a},e.pointerDragging=!1,l&&(go(e,l,!0),e.runtime.injectCursor(l,"CursorDown",Lt(e,o,a))),l}if(t==="up"){let l=e.pointerDownControl,c=hn(mn(e,o,a));if(l){let s=Lt(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&&Wt(e,f)}go(e,l,!1)}return e.pointerDownControl=null,e.pointerDownPosition=null,e.pointerLastPosition={x:o,y:a},e.pointerDragging=!1,c}if(t==="click")return jt(e,"down",o,a,{silent:!0}),jt(e,"up",o,a,{silent:!0});throw new Error(`unknown pointer type ${t}`)}function wn(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 Ao(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 xn(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 Ei(e){return{snapshot:t=>vn(e,t),step:t=>xi(e,t),pointer:(t,i,n)=>jt(e,t,i,n),key:t=>Sn(e,t),click:t=>Cn(e,t),view:t=>yn(e,t),pause:()=>{He(e,{kind:"pause",payload:{}}),e.debugPaused=!0},resume:()=>{He(e,{kind:"resume",payload:{}}),e.debugPaused=!1},serverSet:(t,i,n)=>wn(e,t,i,n),serverSend:(t,i,n)=>xn(e,t,i,n)}}function En(e){e?.server&&e.server.destroy();let t=e?.runtimes||(e?.runtime?[e.runtime]:[]);for(let i of t)i.destroy()}function An(e,t){return JSON.stringify(e)===JSON.stringify(t)}function ko(e,t){for(let i of e||[])t(i),i.children?.length&&ko(i.children,t)}function kn(e,{id:t,name:i}){let n=null;return ko(e,r=>{n||(t&&String(r.id)===String(t)||!t&&i&&r.name===i)&&(n=r)}),n}function $l(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 Gl(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=kn(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 Dl(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=kn(t.tree,e);if(!i)return{ok:!1,actual:null,expected:e.equals,message:`control not found: ${e.id||e.name}`};let n=$l(i,e.field);return An(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 An(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||An(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=!!kn(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 zl(e,t){let i=Vt();try{return i.evalQueryScript(e,Gl(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"?zl(e.source,t):Dl(e,t)}function Vl(e,t){let i=t>0?t:st;return Math.round((e+i)*1e9)/1e9}function Yl(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 Bl(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 Po(e,t){let i=Ht(t),n=i.events.slice().sort((E,k)=>E.t-k.t),r=i.asserts.slice(),o=i.dt||st,a=n.reduce((E,k)=>Math.max(E,k.t),0),l=r.reduce((E,k)=>Math.max(E,Number(k.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}),v=()=>{for(;s<n.length&&n[s].t<=m+1e-9;)Yl(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 k=Bl(E,g);if(f.push(k),E._done=!0,!k.ok)return{passed:!1,failedAt:m,frame:g.frame||0,results:f,snapshot:g}}return null};v();let N=w();if(N)return _n(i,N);for(;m+1e-9<c;){e.step(o),m=Vl(m,o),g=e.snapshot({inspect:h}),v();let E=w();if(E)return _n(i,E)}return _n(i,{passed:f.every(E=>E.ok),failedAt:null,frame:g.frame||0,results:f,snapshot:g})}function _n(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 Pn(e){return Array.isArray(e)?e.slice():[]}var Wl={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 jl(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:Wl[l]||l,name:s,type:c[s]?.type||"",value:c[s]?.value??null}))}return n}var ft="qxqy-simulator-save",ql="qxqy-simulator-scripts",re="server-control-template",Y="client-control-template",Tn={[re]:"\u670D\u52A1\u5668\u63A7\u4EF6\u6A21\u677F",[Y]:"\u5BA2\u6237\u7AEF\u63A7\u4EF6\u6A21\u677F"};function ct(e){return e===Y?"client":"server"}function Ai(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 Rn(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)||![re,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:Ai(i.oldGuid),newGuid:Ai(i.newGuid)}})}function Jl(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 ki(e){let t=String(e?.controlAsset||""),i=Jl(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===re||t==="server"?re:""}}function Zl(e){let t=[],i=(n,r="")=>{if(n&&(n.path||n.source)){let o=ki(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(ki(n));return t}if(i(e?.assets?.server?.script,re),i(e?.assets?.client?.script,Y),e&&e.format!==ft){i(e?.script);for(let n of e?.scripts||[])i(n)}return t}function Mn(e){return Ue(e===Y?St():it())}var Ql="\u672A\u7ED1\u5B9A",xt="\u672A\u547D\u540D\u5B58\u6863",es="\u672A\u547D\u540D\u754C\u9762";function ts(e){let t=e;for(let i=0;i<8;i++){if(qt(To(t,"simulator","studio"))&&qt(To(t,"lua")))return t;let n=Hl(t);if(n===t)break;t=n}return e}function is(e){return e?{name:Et(e),path:e,bound:!0}:{name:Ql,path:"",bound:!1}}function ns(e,t=process.cwd()){if(Ll(e)&&qt(e))return e;let i=t||process.cwd(),n=ts(i),r=Ro(n,e);if(qt(r))return r;let o=Ro(i,e);if(qt(o))return o;throw new Error("script file not found: "+e)}function Nn(e,t={}){e?.format===ft&&Wi(e.version);let i=[],n=typeof t.workspacePath=="string"&&t.workspacePath?t.workspacePath:"",r=e?.format===ft&&e.assets,o=Rn(e?.controlGuidChanges),a=Pi(e?.scriptSync),l=r?null:Ue(e,{warnings:i}),c={server:r&&e.assets.server?Ue(e.assets.server,{warnings:i}):Mn(re),client:r&&e.assets.client?Ue(e.assets.client,{warnings:i}):Mn(Y)};l&&(c[ct(l.meta.assetType)]=l);let s=r&&e.activeAssetType===Y?Y:l?.meta.assetType||re,f=r&&e.meta?.name?String(e.meta.name):"",m=()=>f||xt;!e?.meta?.name&&c.server.meta.name==="\u672A\u547D\u540D\u754C\u9762\u63A7\u4EF6\u7EC4"&&(c.server.meta.name=es);let h=[],g=new Set;function v(){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){v();let p=we(d)&&!g.has(Number(d))?Number(d):De(g);return g.add(p),p}function N(d){let p=ki(d),C=w(p.guid);return{...p,guid:C,id:String(C)}}$e(Zl(e));let E=Kt(e?.serverLogic),k=null,B="",$=1,q=1;function Q(d){let p=String(d||"").trim();if(!p)return"";if(!te[p])throw new Error(`unknown canvas preset: ${p} (available: ${Object.keys(te).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 A=ce(C.root,d);if(A&&A.kind!=="server-container")return{key:p,node:A}}return null}function y(d){if(!d.controlId)return null;let p=d.controlAsset===Y?"client":d.controlAsset===re?"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 b(d){if(!we(d))return null;for(let[p,C]of[[re,c.server],[Y,c.client]]){let A="";if(W(C.root,T=>{!A&&(T.scriptMappingIds||[]).includes(Number(d))&&(A=T.id)}),A)return{controlId:A,controlAsset:p}}return null}function I(d,p,C){let A=c[ct(d.controlAsset)],T=A&&ce(A.root,d.controlId);T&&(T.scriptMappingIds=(T.scriptMappingIds||[]).map(M=>Number(M)===Number(p)?Number(C):M))}x();function F(){return h.map(d=>{let p=y(d),C=p?p.key==="client"?Y:re:"";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?Tn[C]:"",mounted:!!p})})}function S(){let d=[],p=(C,A)=>{W(C.root,T=>{T.kind!=="server-container"&&d.push(G({id:T.id,name:T.name,kind:T.kind,assetType:A,assetLabel:Tn[A]}))})};return p(c.server,re),p(c.client,Y),d}function R(d){let p=[];return W(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=R(St()),U=R(it());function ae(d){let p=R(d);return d.meta?.assetType===Y?p===D:p===U}function X(d,p){return String(d||"").replace(/[\\/:*?"<>|]/g,"-").trim()||p}function de(d){let p=X(m(),xt),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 Ir(c.server,c.client,{scripts:h,fileName:`${X(m(),xt)} \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 At(){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 ee(){let d=J(),p=zr(d);return p.workspace=is(n),p.save=ht(),p.scripts=F(),p.mountTargets=S(),p.serverLogic=E,p.migrationWarnings=[...i],p.controlGuidChanges=G(o),p.scriptSync=G(a),Xn(p),p}function Ee(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 A=String(p||"");if(A){let T=C===Y?Y:C===re?re:"";if(!y({controlId:A,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=A}function Qt(d){let p=Ee(d);if(d.op==="addScript"){let C=N({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(A=>A.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(A=>A.id!==d.id),h.length===C)throw new Error(`\u811A\u672C\u4E0D\u5B58\u5728: ${d.id}`)}return p.version+=1,ee()}function ei(d){let p=Ee(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 A=Ai(d.guid),T=Ai(C.guid);if(A===T)return ee();let M=[];for(let V of Object.values(c))W(V.root,ne=>{V===c.client&&ne.kind==="server-container"||M.push({node:ne,project:V})});if(M.some(V=>V.node!==C&&Number(V.node.guid)===A)||h.some(V=>Number(V.guid)===A))throw new Error(`\u63A7\u4EF6\u7D22\u5F15 ${A} \u5DF2\u88AB\u5176\u4ED6\u63A7\u4EF6\u6216\u811A\u672C\u5360\u7528`);let z=[],L=(V,ne,_e)=>{let Z=V?.[ne];(typeof Z=="number"||typeof Z=="string"&&/^\d+$/.test(Z.trim()))&&Number(Z)===T&&z.push({owner:V,key:ne,project:_e.project})};for(let V of M)L(V.node,"referencedPrefabId",V),L(V.node,"itemPrefabId",V),L(V.node.giaRaw,"templateRefSlot",V);if(z.length&&M.filter(V=>Number(V.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 ke={id:Xl(),controlAsset:s,controlId:C.id,controlName:C.name,oldGuid:T,newGuid:A};C.guid=A;let he=new Set([p]);for(let{owner:V,key:ne,project:_e}of z)V[ne]=typeof V[ne]=="string"?String(A):A,he.add(_e);o.push(ke);for(let V of he)V.version+=1;return ee()}function ie(d){let p=Ee(d);if(!Array.isArray(d.changeIds)||!d.changeIds.length||d.changeIds.some(A=>typeof A!="string"||!o.some(T=>T.id===A)))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(A=>!C.has(A.id)),p.version+=1,ee()}function Ae(d){if(!d||typeof d!="object")throw new Error("patch requires op");if(d.op==="setScriptSync"){let p=Ee(d);return a=Pi(d.config),p.version+=1,ee()}if(d.op==="setControlGuid")return ei(d);if(d.op==="acknowledgeControlGuidChanges")return ie(d);if(d.op==="setServerLogic"){let p=Ee(d);return E=Kt(d.logic),p.version+=1,ee()}if(d.op==="addScript"||d.op==="updateScript"||d.op==="removeScript")return Qt(d);if(d.op==="selectAsset")return s=d.assetType===Y?Y:re,ee();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,ee()}if(d.op==="newAsset"){let p=Ee(d);s=d.assetType===Y?Y:re;let C=Mn(s);return C.version=p.version+1,c[ct(s)]=C,o=o.filter(A=>A.controlAsset!==s),x(),ee()}return Ji(J(),d),x(),ee()}function Me(d){return h.filter(p=>{let C=y(p);return!!(C&&C.key==="client"==(d===Y))})}function kt(d="json",p=""){let C=_t(d,p);if(o.length&&!["save","archive"].includes(String(d).toLowerCase())){let A=o.map(T=>`\u63A7\u4EF6\u7D22\u5F15\u5F85\u6838\u5BF9 Lua \u5F15\u7528\uFF1A${Tn[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||[],...A])]}return C}function _t(d="json",p=""){let C=String(d).toLowerCase();if(C==="save"||C==="archive"){let M=Buffer.from(JSON.stringify(At(),null,2),"utf8");return G({filename:`${m().replace(/[\\/:*?"<>|]/g,"-")} \xB7 \u8D44\u4EA7\u5305.json`,mimeType:"application/json",encoding:"base64",data:M.toString("base64"),warnings:[]})}if(C==="save-gia"||C==="archive-gia"){let M=[],z=[],L=(he,V="")=>{let ne=kt(he,V);M.push(G({filename:ne.filename,mimeType:ne.mimeType,encoding:ne.encoding,data:ne.data,warnings:ne.warnings||[]})),z.push(...ne.warnings||[])},ke=(he,V)=>{let ne=c[ct(he)],_e=he===s,Z=h.some(ve=>ve.controlAsset===he&&ve.controlId);if(!_e&&ae(ne)&&!Z){z.push(V);return}L("gia",he)};if(ke(re,"\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"),ke(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(he=>he.path||he.source)&&L("scripts-gia"),!M.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:M,warnings:[...new Set(z)]})}if(C==="gia-combined"||C==="combined-gia"||C==="combined"){let M=je();return G({filename:`${X(m(),xt)} \xB7 \u6574\u5408\u5305.gia`,mimeType:"application/octet-stream",encoding:"base64",data:M.buffer.toString("base64"),warnings:[...new Set(M.warnings||[])]})}if(C==="scripts"){let M=G({format:ql,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(M,null,2),"utf8");return G({filename:`${X(m(),xt)} \xB7 \u811A\u672C.json`,mimeType:"application/json",encoding:"base64",data:z.toString("base64"),warnings:[]})}if(C==="scripts-gia"||C==="scriptsgia"){let M=Ar(h);return G({filename:`${X(m(),xt)} \xB7 \u811A\u672C.gia`,mimeType:"application/octet-stream",encoding:"base64",data:M.buffer.toString("base64"),warnings:M.warnings})}if(C==="lua"){let M=h.find(L=>L.id===p)||h.find(L=>L.path===p);if(!M)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=Et(M.path||"")||`qxqy-script-${M.id}`;return G({filename:/\.lua$/i.test(z)?z:`${z}.lua`,mimeType:"text/x-lua",encoding:"base64",data:Buffer.from(M.source||"","utf8").toString("base64"),warnings:[]})}let A=p?c[ct(p)]:J(),T=de(A);if(C==="json"){let M=G({...A,scripts:Me(A.meta.assetType),controlGuidChanges:o.filter(L=>L.controlAsset===A.meta.assetType)}),z=Buffer.from(JSON.stringify(M,null,2),"utf8");return G({filename:`${T}.json`,mimeType:"application/json",encoding:"base64",data:z.toString("base64"),warnings:[]})}if(C==="gia"){let M=Cr(A,A.meta.assetType===Y?{scripts:Me(Y)}:{}),z=A.meta.assetType===Y?[]:Me(re);return z.length&&M.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:`${T}.gia`,mimeType:"application/octet-stream",encoding:"base64",data:M.buffer.toString("base64"),warnings:M.warnings})}throw new Error(`unsupported export format: ${d}`)}function $e(d){for(let p of d){let C=ki(p);if(!C.path&&!C.source)continue;let A=C.controlId?null:b(C.guid),T=N(A?{...C,...A}:C);A&&T.guid!==C.guid&&I(A,C.guid,T.guid),T.controlId&&!y(T)&&(T.controlId="",T.controlAsset=""),h.push(T)}}function Pt(d,p,C=""){let A=String(d||"").toLowerCase();if(typeof p!="string"||!p)throw new Error("import data is required");let T=Buffer.from(p,"base64"),M,z=[],L={};if(A==="json"){try{M=JSON.parse(T.toString("utf8"))}catch{throw new Error("JSON \u6587\u4EF6\u65E0\u6548")}if(M?.project&&(M=M.project),M?.format===ft&&M?.assets){Wi(M.version);let Z=Nn(M);z.push(...Z.get().migrationWarnings);let ve=Z.archiveData();return c.server=ve.assets.server,c.client=ve.assets.client,i=[...z],s=M.activeAssetType===Y?Y:re,f=String(M.meta?.name||Et(C).replace(/\.json$/i,"")||f),E=ve.serverLogic,h=ve.assets.scripts,o=ve.controlGuidChanges,a=ve.scriptSync,g.clear(),G({snapshot:ee(),warnings:z,metadata:{format:ft}})}}else{if(A==="lua")return h.push(N({path:Et(C||"imported.lua"),source:T.toString("utf8"),controlId:""})),G({snapshot:ee(),warnings:z,metadata:{assetType:"lua-script"}});if(A==="gia"){if(kr(T)){let Ce=Pr(T);return $e(Ce.scripts),G({snapshot:ee(),warnings:Ce.warnings,metadata:Ce.metadata})}let Z=Tr(T);M=Z.project,z=Z.warnings,L=Z.metadata,Z.clientProject&&(c.client=Ue(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,Gn=(Ce,Zo)=>{Ce&&W(Ce.root,Dn=>{for(let _i of Dn.scriptMappingIds||[]){let zn=ve.get(Number(_i));if(zn){z.push(`\u811A\u672C GUID ${_i} \u540C\u65F6\u6302\u8F7D\u5230\u591A\u4E2A\u63A7\u4EF6\uFF0C\u5DF2\u4FDD\u7559\u201C${zn.controlAsset===re?"\u670D\u52A1\u7AEF":"\u5BA2\u6237\u7AEF"}\u201D\u76EE\u6807\u3002`);continue}ve.set(Number(_i),{controlId:Dn.id,controlAsset:Zo})}})};Gn(Z.project,re),Gn(Z.clientProject,Y),$e((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 ke=Ue(M,{warnings:z}),he=Rn(M?.controlGuidChanges);if(he.some(Z=>Z.controlAsset!==ke.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=Rn([...o.filter(Z=>Z.controlAsset!==ke.meta.assetType),...he]);i=[...z];let ne=ct(ke.meta.assetType);c[ne]=ke,o=V,s=ke.meta.assetType;let _e=c[ne];return C&&(_e.meta.name=Et(C).replace(/\.(json|gia)$/i,"")||_e.meta.name,_e.meta.sourceFile=Et(C),_e.meta.sourceFormat=A),$e(M?.scripts||[]),M?.script&&(M.script.path||M.script.source)&&$e([M.script]),G({snapshot:ee(),warnings:z,metadata:L})}function Mo(d,p){return Ji(J(),{op:"pick",x:d,y:p}),ee()}function No(d){let p=typeof d=="string"&&d?d:"";!p||p===n||(n=p)}function Fo(d){let p=d.source||"";if(!p.trim()&&d.path.trim())try{p=Kl(ns(d.path,n),"utf8")}catch(C){throw new Error(`\u811A\u672C ${d.path} \u8BFB\u53D6\u5931\u8D25: ${C?.message||C}`)}return p}function Tt(d={}){let p=Q(d.canvasId);p&&(B=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=Oe(d.viewPlayerIndex,$)),k&&En(k);let C=h.map(T=>{try{return{id:T.id,guid:T.guid||0,path:T.path||T.id,source:Fo(T),controlId:T.controlId||"",controlAsset:T.controlAsset||""}}catch(M){return{id:T.id,guid:T.guid||0,path:T.path||T.id,source:`error([==[ ${String(M.message).replace(/]=+]/g,"] =]")} ])`,controlId:T.controlId||"",controlAsset:T.controlAsset||""}}}),A=T=>C.filter(M=>{let z={controlId:M.controlId,controlAsset:M.controlAsset},L=M.controlId?y(z):null;return!!(L&&L.key===T)});return k=bo(c.server,{templatesProject:c.client,scripts:C,sceneScripts:A("server"),templateScripts:A("client"),serverConfig:{logic:E},canvasId:B,playerCount:$,viewPlayerIndex:q,language:d.language||""}),ue(d)}function Oo(d,p={}){let C=Q(d);if(!C)throw new Error("playSetCanvas requires canvasId");return Tt({...p,canvasId:C})}function ue(d={}){if(!k)return G({running:!1,tree:[],logs:[],serverLogs:[],serverVars:[]});let p=vn(k,d);return p.running=!0,p.logs=Pn(p.logs),p.serverLogs=Pn(p.server?.logs||[]),p.serverVars=jl(p.server,p.playerCount||1),p}function $o(d,p={}){return k||Tt(),xi(k,d),p.observe===!1?G({running:!0,time:k.runtime.clock.time,frame:k.runtime.clock.frame,paused:!!k.debugPaused,levelTimePaused:!!k.runtime.clock.paused,playerCount:k.playerCount||1,viewPlayerIndex:k.viewPlayerIndex||1}):ue(p)}function Go(d=0){Tt();let p=Math.max(0,Number(d)||0);for(let C=0;C<p;C++)xi(k,1/30);return ue()}function Do(){return k&&En(k),k=null,B="",$=1,q=1,G({running:!1,tree:[],logs:[],serverLogs:[],serverVars:[]})}function zo(d,p={}){let C=Rt();return q=yn(C,d),p.observe===!1?null:ue(p)}function Vo(d,p={}){if(!k)throw new Error("play session has not started");return Sn(k,d),p.observe===!1?null:ue(p)}function Yo(d,p={}){if(!k)throw new Error("play session has not started");return Cn(k,d),p.observe===!1?null:ue(p)}function Bo(d,p,C,A={}){if(!k)throw new Error("play session has not started");return jt(k,d,p,C),A.observe===!1?null:ue(A)}function Uo(d={}){return k&&Ei(k).pause(),d.observe===!1?null:ue(d)}function Ko(d={}){return k&&Ei(k).resume(),d.observe===!1?null:ue(d)}function Rt(){if(!k)throw new Error("play session has not started");return k}function Xo(d,p){let C=Rt();if(!d&&!p){let A=ue();return G({vars:A.serverVars||[]})}return G({entityType:String(d||""),name:String(p||""),value:Ao(C,d,p)})}function Ho(d,p,C){let A=Rt();return wn(A,d,p,C),ue()}function Lo(d,p=[],C="PlayerSelf"){let A=Rt();return xn(A,d,p,C),ue()}function Wo(){let d=ue();return G({events:d.history||[],case:mo(d.history||[],{playerCount:d.playerCount||1})})}function jo(d={}){let p=ue(),C=Ht({name:d.name||"",dt:d.dt,playerCount:d.playerCount||p.playerCount||1,events:d.events||p.history||[],asserts:d.asserts||[]});return G(C)}function qo(d,p={}){let C=Ht(d);Tt({...p,playerCount:p.playerCount||C.playerCount||1});let A=Rt();A.recording=!1;try{return Po(Ei(A),d)}finally{A.recording=!0}}function Jo(){if(!k)return{running:!1,paused:!1,time:0,frame:0,playerCount:1,viewPlayerIndex:1};let d=k.runtime.clock;return{running:!0,paused:!!k.debugPaused,levelTimePaused:!!d.paused,time:d.time,frame:d.frame,playerCount:k.playerCount||1,viewPlayerIndex:k.viewPlayerIndex||1}}let $n={get:ee,patch:Ae,setWorkspace:No,exportData:kt,importData:Pt,pick:Mo,playStart:Tt,playSetCanvas:Oo,playSetView:zo,playGet:ue,playStatus:Jo,playStep:$o,playRun:Go,playStop:Do,playKey:Vo,playClick:Yo,playPointer:Bo,playPause:Uo,playResume:Ko,playServerGet:Xo,playServerSet:Ho,playServerSend:Lo,playHistory:Wo,playSaveCase:jo,playRunCase:qo,archiveData:At};return Object.defineProperty($n,"_project",{enumerable:!1,get:J}),$n}var K=null,On=!1,dt=0,We=0,rs=33,Jt=1/30,os=5;function Zt(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 as(e={}){let t=Zt(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?{...K.playStatus()}:K.playGet(Zt(e))}function ls(){if(!K||On)return;let e=K.playStatus();if(!e.running||e.paused){dt=0,We=0;return}let t=Date.now();if(!dt){dt=t;return}On=!0;try{We+=Math.min(.25,Math.max(0,(t-dt)/1e3)),dt=t;let i=0;for(;We>=Jt&&i<os;)K.playStep(Jt,{observe:!1}),We-=Jt,i+=1;We>Jt&&(We=Jt)}finally{On=!1}}var yc=setInterval(ls,rs);function ss(e,t={}){if(e==="start")return K&&K.playStop(),K=Nn(t.archive||t.project,{workspacePath:t.workspacePath||""}),dt=0,We=0,K.playStart(as(t));if(!K)throw new Error("play session has not started");if(e==="get")return t.light?Le(t):K.playGet(Zt(t));if(e==="step"){let i=K.playStep(t.dt,t.light?{observe:!1}:Zt(t));return t.light?Le(t):i}if(e==="pointer")return K.playPointer(t.type,t.x,t.y,{observe:!1}),Le(t);if(e==="key")return K.playKey(t.key,{observe:!1}),Le(t);if(e==="click")return K.playClick(t.name,{observe:!1}),Le(t);if(e==="pause")return K.playPause({observe:!1}),Le(t);if(e==="resume")return K.playResume({observe:!1}),Le(t);if(e==="device")return K.playSetCanvas(t.canvasId,Zt(t));if(e==="view")return K.playSetView(t.playerIndex??t.viewPlayerIndex,{observe:!1}),Le(t);if(e==="serverGet")return K.playServerGet(t.entityType,t.name);if(e==="serverSet")return K.playServerSet(t.entityType,t.name,t.value);if(e==="serverSend")return K.playServerSend(t.name,t.params||[],t.target||"PlayerSelf");if(e==="history")return K.playHistory();if(e==="saveCase")return K.playSaveCase(t.case||t);if(e==="runCase")return K.playRunCase(t.case||t,{canvasId:t.canvasId,playerCount:t.playerCount,viewPlayerIndex:t.viewPlayerIndex});if(e==="stop"){let i=K.playStop();return K=null,dt=0,We=0,i}throw new Error(`unknown play action: ${e}`)}Fn.on("message",e=>{let{id:t,action:i,args:n={}}=e||{};try{Fn.postMessage({id:t,ok:!0,value:ss(i,n),error:null})}catch(r){Fn.postMessage({id:t,ok:!1,value:null,error:r?.message||String(r)})}});