@shimotsuki/core 3.0.10 → 3.0.11

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 +1,2417 @@
1
- import e from"@babel/runtime-corejs3/core-js/global-this";import{AudioSource as t,_decorator as i,AudioClip as o,error as s,Node as n,director as r,log as a,Component as l,Prefab as c,instantiate as h,isValid as u,Layers as p,view as d,Widget as m,v3 as _,tween as g,Enum as f,game as y,Label as v,UIOpacity as b,Tween as C,BlockInputEvents as E,Button as S,Director as w,assetManager as A,warn as I,AsyncDelegate as T,Game as k,Asset as O,resources as M,sys as R,SpriteFrame as U,Sprite as N}from"cc";import D from"@babel/runtime-corejs3/core-js-stable/reflect/get";import L from"@babel/runtime-corejs3/core-js-stable/reflect/set";import F from"@babel/runtime-corejs3/core-js-stable/object/assign";import x from"@babel/runtime-corejs3/core-js-stable/promise";import B from"eventemitter3";import P from"@babel/runtime-corejs3/core-js-stable/instance/includes";import G from"@babel/runtime-corejs3/core-js-stable/json/stringify";import j from"@babel/runtime-corejs3/core-js-stable/map";import H from"@babel/runtime-corejs3/core-js-stable/instance/for-each";import $ from"@babel/runtime-corejs3/core-js-stable/instance/find";import K from"@babel/runtime-corejs3/core-js-stable/instance/filter";import W from"@babel/runtime-corejs3/core-js-stable/array/is-array";import V from"@babel/runtime-corejs3/core-js-stable/reflect/own-keys";import z from"@babel/runtime-corejs3/core-js-stable/instance/bind";import{makeObservable as q,observable as Q,autorun as J,reaction as X}from"@shimotsuki/mobx";import Z from"@babel/runtime-corejs3/core-js-stable/set-timeout";import Y from"@babel/runtime-corejs3/core-js-stable/instance/map";import ee from"@babel/runtime-corejs3/core-js-stable/array/from";import te from"@babel/runtime-corejs3/core-js-stable/instance/every";import{SocketConnectStatus as ie}from"pitayaclient";import{DEBUG as oe,WECHAT as se,PREVIEW as ne}from"cc/env";import{SocialGameClient as re}from"sgc";import ae from"crypto-es";import le from"@babel/runtime-corejs3/core-js-stable/date/now";import ce from"@babel/runtime-corejs3/core-js-stable/set-interval";import he from"@babel/runtime-corejs3/core-js-stable/instance/values";import ue from"@babel/runtime-corejs3/core-js-stable/instance/entries";class CommonAudio extends t{cat;initAudio(e){return this.cat=e,this}}const{ccclass:pe,menu:de}=i;let me=class AudioEffect extends CommonAudio{effects=(()=>new j)();load(e,t){return new x((i,s)=>{let n,r=null;void 0!==t?(r=e,n=t):n=e;const a=(e,t)=>{if(e)return s(e);this.effects.set(n,t),this.playOneShot(t,this.volume),i(t)};r?this.cat.res.load(r,n,o,a):this.cat.res.load(n,o,a)})}release(){for(let e in this.effects)this.cat.res.release(e);this.effects.clear()}};const{ccclass:_e,menu:ge}=i;class AudioMusic extends CommonAudio{onComplete=null;_progress=0;_url=null;_isPlay=!1;get progress(){return this.duration>0&&(this._progress=this.currentTime/this.duration),this._progress}set progress(e){this._progress=e,this.currentTime=e*this.duration}load(e,t){return new x((i,n)=>{let r,a=null;void 0!==t?(a=e,r=t):r=e;const l=(e,t)=>{if(e)return s(e),n(e);this.playing&&(this._isPlay=!1,this.stop(),this.cat.res.release(this._url)),this.playOnAwake=!1,this.enabled=!0,this.clip=t,this._url=r,i(t)};a?this.cat.res.load(a,r,o,l):this.cat.res.load(r,o,l)})}update(e){this.currentTime>0&&(this._isPlay=!0),this._isPlay&&0==this.playing&&(this._isPlay=!1,this.enabled=!1,this.onComplete&&this.onComplete())}release(){this._url&&(this.cat.res.release(this._url),this._url=null)}}class BaseManager{cat;constructor(e){this.cat=e}}var fe;!function(e){e.MUSIC_ON="AudioEventConstant/MUSIC_ON",e.MUSIC_OFF="AudioEventConstant/MUSIC_OFF",e.EFFECT_ON="AudioEventConstant/EFFECT_ON",e.EFFECT_OFF="AudioEventConstant/EFFECT_OFF",e.PAUSE_AUDIO="AudioEventConstant/PAUSE_AUDIO",e.RESUME_AUDIO="AudioEventConstant/RESUME_AUDIO"}(fe||(fe={}));class AudioManager extends BaseManager{local_data={};music;effect;_volume_music=1;_volume_effect=1;_switch_music=!0;_switch_effect=!0;local_store_key="game_audio";extra={};constructor(e){super(e),this.local_store_key=this.cat.audio_local_store_key;var t=new n("UIAudioManager");r.addPersistRootNode(t);var i=new n("UIMusic");i.parent=t,this.music=i.addComponent(AudioMusic).initAudio(e);var o=new n("UIEffect");o.parent=t,this.effect=o.addComponent(me).initAudio(e),this.load()}setMusicComplete(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this.music.onComplete=e}async playMusic(e,t){if(this.music.loop=!0,!this._switch_music)return;let i,o;void 0!==t?(o=e,i=t):i=e,i.length&&await(o?this.music.load(o,i):this.music.load(i)).then(()=>{this._switch_music&&this.music.play()})}stopMusic(){0!=this.music.state&&this.music?.stop()}pauseMusic(){1==this.music.state&&this.music?.pause()}resumeMusic(){var e;P(e=[0,2]).call(e,this.music.state)&&this.music?.play()}get progressMusic(){return this.music.progress}set progressMusic(e){this.music.progress=e}get volumeMusic(){return this._volume_music}set volumeMusic(e){this._volume_music=e,this.music.volume=e}get switchMusic(){return this._switch_music}set switchMusic(e){if(a("设置背景音乐开关值",e,this._switch_music),e==this._switch_music)return;this._switch_music=e,e?this.resumeMusic():this.pauseMusic();const t=e?fe.MUSIC_ON:fe.MUSIC_OFF;this.cat.event.emit(t),this.save()}async playEffect(e,t){if(!this._switch_effect)return;let i,o;void 0!==t?(o=e,i=t):i=e,i.length&&await(o?this.effect.load(o,i):this.effect.load(i)).then(()=>{this.effect.play()})}stopEffect(){this.effect?.stop()}get volumeEffect(){return this._volume_effect}set volumeEffect(e){this._volume_effect=e,this.effect.volume=e}get switchEffect(){return this._switch_effect}set switchEffect(e){if(e==this._switch_effect)return;this._switch_effect=e,e?this.effect?.play():this.effect?.stop();const t=e?fe.EFFECT_ON:fe.EFFECT_OFF;this.cat.event.emit(t),this.save()}resumeAll(){this.switchMusic&&this.music?.play(),this.switchEffect&&this.effect?.play()}pauseAll(){this.music?.pause(),this.effect?.pause()}stopAll(){this.music?.stop(),this.effect?.stop()}save(){this.local_data.volume_music=this._volume_music,this.local_data.volume_effect=this._volume_effect,this.local_data.switch_music=this._switch_music,this.local_data.switch_effect=this._switch_effect,this.local_data.extra=this.extra;let e=G(this.local_data);return this.cat.storage.set(this.local_store_key,e),this}load(){try{let e=this.cat.storage.get(this.local_store_key);this.local_data=JSON.parse(e),this._volume_music=this.local_data.volume_music,this._volume_effect=this.local_data.volume_effect,this._switch_music=this.local_data.switch_music,this._switch_effect=this.local_data.switch_effect,this.extra=this.local_data.extra}catch(e){this.local_data={},this._volume_music=.6,this._volume_effect=1,this._switch_music=!0,this._switch_effect=!0,this.extra={}}this.music&&(this.music.volume=this._volume_music),this.effect&&(this.effect.volume=this._volume_effect)}}function ye(e,t,i,o){var s,n=arguments.length,r=n<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,i,o);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(r=(n<3?s(r):n>3?s(t,i,r):s(t,i))||r);return n>3&&r&&Object.defineProperty(t,i,r),r}function ve(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}"function"==typeof SuppressedError&&SuppressedError;class BaseComponent extends l{props={};data={};cat=(()=>e._cat)();autorunDisposers=[];reactionDisposers=[];eventEmitter=[];hook={destroyed:()=>{},started:()=>{}};initUI(){}__preload(){this.initUI(),this.onAutoObserver()}constructor(){super(),q(this,{props:Q,data:Q})}onAutoObserver(){}addAutorun(e){const t=W(e)?e:[e];return H(t).call(t,e=>{const t=J(e);this.autorunDisposers.push(t)}),this}addReaction(e,t,i){const o=X(e,t,i);return this.reactionDisposers.push(o),this}addAudoListener(e){var t;return P(t=this.eventEmitter).call(t,e)||e===this.cat.event||this.eventEmitter.push(e),e}_onPreDestroy(){var e,t;if(H(e=this.autorunDisposers).call(e,e=>{e()}),H(t=this.reactionDisposers).call(t,e=>{e()}),this.autorunDisposers=[],this.reactionDisposers=[],!super._onPreDestroy)throw new Error("_onPreDestroy已弃用");super._onPreDestroy()}onDisable(){var e;this.onHide(),this.deleteAllEventByEmitter(this.cat.event),H(e=this.eventEmitter).call(e,e=>{this.deleteAllEventByEmitter(e)}),this.eventEmitter=[],this.removeListener()}deleteAllEventByEmitter(e){const t=e._events;for(const i in t){let o=t[i];W(o)||(o=[o]),H(o).call(o,t=>{t.context===this&&e.off(i,t.fn,this)})}}onEnable(){this.onShow(),this.addListener(),this.onEventListener()}onEventListener(){}addListener(){}removeListener(){}addToParent(e,t,i){const o=e instanceof c?h(e):e instanceof l?e.node:e;if("number"==typeof t){const e=t,s=i;this.setOptions(s),o.insertChild(this.node,e)}else{const e=t;this.setOptions(e),o.addChild(this.node)}return this}setOptions(e){if(e)for(let t in e)switch(t){case"hook":e.hook&&(this.hook=e.hook);break;case"props":null!==e.props&&"object"==typeof e.props&&(this.props=e.props);break;case"data":null!==e.data&&"object"==typeof e.data&&(this.data=e.data)}}setUpdateData(e){if(this.data)return e&&F(this.data,this.toPlainObject(e)),this}setUpdateProps(e){if(this.props)return e&&F(this.props,this.toPlainObject(e)),this}toPlainObject(e){const t={};for(const i of V(e))if("string"==typeof i)try{t[i]=e[i]}catch{}return t}removeAndDestroy(){u(this?.node)&&(this.node.removeFromParent(),this.node.destroy())}setPosition(e){return this.node.setPosition(e),this}setScale(e){return this.node.setScale(e),this}setAngle(e){return this.node.angle=e,this}setRotation(e){return this.node.setRotation(e),this}setRotationFromEuler(e){return this.node.setRotationFromEuler(e),this}onShow(){}onHide(){}setNodeAndChildrenLayer(e){return be(this.node,e),this}}const be=(e,t)=>{var i,o,s;e.layer="string"==typeof t?2**p.nameToLayer(t):t,(null==(i=e)?void 0:z(s=Function.call).call(s,H(o=i.children),o))?.(e=>{be(e,t)})};class UILayer extends BaseComponent{lastEnterDirection="center";screen;isClosing=!1;root;constructor(){super(),this._init()}_init(){this.root=this.node,this.screen=d.getVisibleSize()}async showTween(e){let{isMotion:t=!0,direction:i="center",duration:o=.1,isBounce:s=!0,bounceDuration:n=.05}=e;if(this.lastEnterDirection=i,t){const e=this.node.getComponent(m);let t,n;e&&(e.updateAlignment(),e.enabled=!1),_(1.1,1.1,1),"center"==i?(t=_(.01,.01,.01),n=_(1,1,1)):(t="left"==i?_(-this.screen.width,0,0):"right"==i?_(this.screen.width,0,0):_(0,"top"==i?this.screen.height:-this.screen.height,0),n=_(0,0,0)),await this.handle(i,o,t,n,s),e&&(e.enabled=!0)}}async hideTween(e){let{isMotion:t=!0,direction:i,duration:o=.1}=e;if(i=i||this.lastEnterDirection,!this.isClosing){if(this.isClosing=!0,g(this.node).removeSelf(),t){const e=this.node.getComponent(m);let t,s;e&&(e.enabled=!1),"center"==i?(t=this.node.scale,s=_(0,0,0)):(s="left"==i?_(-this.screen.width,0,0):"right"==i?_(this.screen.width,0,0):_(0,"top"==i?this.screen.height:-this.screen.height,0),t=this.node.getPosition()),await this.handle(i,o,t,s,!1)}this.removeAndDestroy()}}async handle(e,t,i,o,s){"center"==e?this.node.setScale(i):this.node.setPosition(i),await this.deftween(t,{["center"==e?"scale":"position"]:o},s)}deftween(e,t,i,o){return new x((i,o)=>{g(this.node).to(e,t).call(()=>{i()}).start()})}}const{ccclass:Ce,property:Ee}=i;var Se;!function(e){e[e.EFFECT=0]="EFFECT",e[e.BGM=1]="BGM"}(Se||(Se={}));class AudioSourceBaseComponent extends BaseComponent{type=(()=>Se.EFFECT)();clip=null;loop=!1;volume=1;playOnAwake=!1;audioSource=(()=>new t)();onEnable(){super.onEnable(),this.clip&&(this.audioSource.clip=this.clip),this.audioSource.loop=this.loop,this.audioSource.volume=this.volume,this.audioSource.playOnAwake=this.playOnAwake,this.cat.event.on(fe.EFFECT_ON,this.onPlayEffectHandler,this).on(fe.EFFECT_OFF,this.onStopEffectHandler,this).on(fe.MUSIC_ON,this.onPlayMusicHandler,this).on(fe.MUSIC_OFF,this.onStopMusicHandler,this)}__preload(){super.__preload();const{volumeEffect:e,volumeMusic:t}=this.cat.audio;this.audioSource.volume=this.type===Se.BGM?t:e}start(){}stopAudio(){this.audioSource.stop()}playAudio(){const{switchEffect:e,switchMusic:t}=this.cat.audio;this.audioSource.playing||!(this.type===Se.BGM?t:e)||y._paused||this.audioSource.play()}onPlayEffectHandler(){}onStopEffectHandler(){this.stopAudio()}onPlayMusicHandler(){}onStopMusicHandler(){this.stopAudio()}_onPreDestroy(){this.onStopMusicHandler(),super._onPreDestroy()}}ye([Ee({tooltip:"类型:\n EFFECT 音效\n BGM 音乐",type:f(Se)}),ve("design:type",Number)],AudioSourceBaseComponent.prototype,"type",void 0),ye([Ee({tooltip:"音源",type:o}),ve("design:type",o)],AudioSourceBaseComponent.prototype,"clip",void 0),ye([Ee({tooltip:"循环"}),ve("design:type",Boolean)],AudioSourceBaseComponent.prototype,"loop",void 0),ye([Ee({tooltip:"音量"}),ve("design:type",Number)],AudioSourceBaseComponent.prototype,"volume",void 0),ye([Ee({tooltip:"是否启用自动播放"}),ve("design:type",Boolean)],AudioSourceBaseComponent.prototype,"playOnAwake",void 0);const{ccclass:we,property:Ae}=i;class AudioSourceUILayer extends UILayer{type=(()=>Se.EFFECT)();clip=null;loop=!1;volume=1;playOnAwake=!1;audioSource=(()=>new t)();onEnable(){super.onEnable(),this.cat.event.on(fe.EFFECT_ON,this.onPlayEffectHandler,this).on(fe.EFFECT_OFF,this.onStopEffectHandler,this).on(fe.MUSIC_ON,this.onPlayMusicHandler,this).on(fe.MUSIC_OFF,this.onStopMusicHandler,this)}__preload(){this.clip&&(this.audioSource.clip=this.clip),this.audioSource.loop=this.loop,this.audioSource.volume=this.volume,this.audioSource.playOnAwake=this.playOnAwake,super.__preload();const{volumeEffect:e,volumeMusic:t}=this.cat.audio;this.audioSource.volume=this.type===Se.BGM?t:e}stopAudio(){this.audioSource.stop()}playAudio(){const{switchEffect:e,switchMusic:t}=this.cat.audio;this.audioSource.playing||!(this.type===Se.BGM?t:e)||y._paused||this.audioSource.play()}onPlayEffectHandler(){}onStopEffectHandler(){this.stopAudio()}onPlayMusicHandler(){}onStopMusicHandler(){this.stopAudio()}_onPreDestroy(){this.onStopMusicHandler(),super._onPreDestroy()}}ye([Ae({tooltip:"类型:\n EFFECT 音效\n BGM 音乐",type:f(Se)}),ve("design:type",Number)],AudioSourceUILayer.prototype,"type",void 0),ye([Ae({tooltip:"音源",type:o}),ve("design:type",o)],AudioSourceUILayer.prototype,"clip",void 0),ye([Ae({tooltip:"循环"}),ve("design:type",Boolean)],AudioSourceUILayer.prototype,"loop",void 0),ye([Ae({tooltip:"音量"}),ve("design:type",Number)],AudioSourceUILayer.prototype,"volume",void 0),ye([Ae({tooltip:"是否启用自动播放"}),ve("design:type",Boolean)],AudioSourceUILayer.prototype,"playOnAwake",void 0);const{ccclass:Ie,property:Te,menu:ke}=i;var Oe;!function(e){e[e.FIXED=0]="FIXED",e[e.SLIDE=1]="SLIDE"}(Oe||(Oe={}));let Me=class CoreToast extends BaseComponent{fixed_node;slide_node;fixed_label;slide_label;onLoad(){this.fixed_node.active=this.slide_node.active=!1}start(){this.show()}async show(){return new x(async(e,t)=>{const{title:i,type:o,fixed_time:s}=this.props;o==Oe.FIXED?(this.fixed_node.active=!0,this.fixed_label.string=`${i}`,this.scheduleOnce(()=>{this.node.destroy(),e()},s)):(this.slide_node.active=!0,this.slide_label.string=`${i}`,this.playAnim(this.node).then(()=>{e()}))})}playAnim(e){return new x((t,i)=>{const o=this.node.getComponent(b),s=g(o).delay(1.2).to(.5,{opacity:0}).call(()=>{C.stopAllByTarget(e),this.node.destroy(),t()});g(e).by(.5,{position:_(0,400,0)}).call(()=>{s.start()}).start()})}onDestroy(){C.stopAllByTarget(this.node),this.unscheduleAllCallbacks()}};var Re;ye([Te({type:n,tooltip:"固定节点"}),ve("design:type",n)],Me.prototype,"fixed_node",void 0),ye([Te({type:n,tooltip:"滑动节点"}),ve("design:type",n)],Me.prototype,"slide_node",void 0),ye([Te({type:v,tooltip:"固定标签节点"}),ve("design:type",v)],Me.prototype,"fixed_label",void 0),ye([Te({type:v,tooltip:"滑动标签节点"}),ve("design:type",v)],Me.prototype,"slide_label",void 0),Me=ye([Ie("CoreToast"),ke("CATCORE/CoreToast")],Me),function(e){e.EVENT_SHOW="GlobalEventConstant/EVENT_SHOW",e.EVENT_HIDE="GlobalEventConstant/EVENT_HIDE",e.GAME_RESIZE="GlobalEventConstant/GAME_RESIZE",e.EVENT_CLOSE="GlobalEventConstant/EVENT_CLOSE",e.ONLINE="GlobalEventConstant/ONLINE",e.OFFLINE="GlobalEventConstant/OFFLINE",e.ROOT_MASK_UPDATE="GlobalEventConstant/ROOT_MASK_UPDATE",e.ROOT_MASK_CHANGE="GlobalEventConstant/ROOT_MASK_CHANGE"}(Re||(Re={}));const{ccclass:Ue,property:Ne,menu:De}=i;let Le=class CoreBlackMask extends BaseComponent{tween};ye([Ne({type:n,tooltip:"动画节点"}),ve("design:type",n)],Le.prototype,"tween",void 0),Le=ye([Ue("CoreBlackMask"),De("CATCORE/CoreBlackMask")],Le);const{ccclass:Fe,property:xe,menu:Be}=i;let Pe=class CoreUIContainer extends UILayer{scene_mask_node;ui_container;gui=null;onLoad(){this.setSceneMaskActive(!1)}get scene_mask(){return this.scene_mask_node.getComponent(Le)}get brother(){return this.ui_container.children||[]}get tweenChildren(){return this.scene_mask.tween.children}onEventListener(){this.cat.event.on(Re.ROOT_MASK_CHANGE,this.uiMaskChanged,this)}addMask(){const e=this.brother[this.brother.length-1];e&&this.scene_mask.node.setSiblingIndex(e.getSiblingIndex()),this.blockMaskSiblingIndexChanged()}subMask(){const e=this.brother[this.brother.length-2];e&&this.scene_mask.node.setSiblingIndex(e.getSiblingIndex()),this.blockMaskSiblingIndexChanged()}blockMaskSiblingIndexChanged(){this.tweenChildren.length>1||this.brother.length>1?this.show():this.hide()}addNodeToTween(e){return u(this)&&this.scene_mask&&this.scene_mask.tween.addChild(e),this}show(){this.setSceneMaskActive(!0)}hide(){this.setSceneMaskActive(!1)}setGui(e){return this.gui=e,this}uiMaskChanged(){this.blockMaskSiblingIndexChanged()}setSceneMaskActive(e){this.scene_mask.node.active=e}};ye([xe({type:n}),ve("design:type",n)],Pe.prototype,"scene_mask_node",void 0),ye([xe({type:n}),ve("design:type",n)],Pe.prototype,"ui_container",void 0),Pe=ye([Fe("CoreUIContainer"),Be("CATCORE/CoreUIContainer")],Pe);class RootUILayer extends UILayer{onEnable(){super.onEnable(),this.updateMask()}onDisable(){super.onDisable(),this.updateMask()}updateMask(){this.cat.event.emit(Re.ROOT_MASK_UPDATE)}}const{ccclass:Ge,property:je,menu:He}=i;let $e=class CoreShowLoading extends RootUILayer{title;loadingTween;loading_rotate=0;onAutoObserver(){this.addAutorun([()=>{this.props?.title&&(this.title.string=`${this.props?.title}`),this.title.node.active=!!this.props?.title?.length},()=>{this.getComponent(E).enabled=!!this.props?.mask}])}update(e){this.loading_rotate+=220*e,this.loadingTween.setRotationFromEuler(0,0,-this.loading_rotate%360),this.loading_rotate>360&&(this.loading_rotate-=360)}};var Ke;ye([je({type:v,tooltip:"标题"}),ve("design:type",v)],$e.prototype,"title",void 0),ye([je({type:n,tooltip:"动画"}),ve("design:type",n)],$e.prototype,"loadingTween",void 0),$e=ye([Ge("CoreShowLoading"),He("CATCORE/CoreShowLoading")],$e),function(e){e.RECONNECTED="重连成功",e.RECONNECTING="正在重连",e.MAX_RECONNECT="重连次数超出限制,请检查网络",e.RECONNECTED_ERROR="重连失败,请检查网络",e.CONNECT_PARAM_ERROR="游戏参数错误,请重新加载",e.KICK="账号已下线",e.OFFLINE="网络已断开",e.ONLINE="网络已连接",e.GAME_ERROR="连接游戏服错误"}(Ke||(Ke={}));const{ccclass:We,property:Ve,menu:ze}=i;let qe=class CoreReconnection extends RootUILayer{common_prompt_text;btn_confirm;btn_close;is_close=!1;props={content:null};initUI(){}onLoad(){this.btn_confirm.node.on(S.EventType.CLICK,this.onConfirmHandler,this),this.btn_close.node.on(S.EventType.CLICK,this.onConfirmHandler,this),this.addAutorun([()=>{this.common_prompt_text.string=this.props.content??""}])}onDestroy(){this.unscheduleAllCallbacks()}updateProps(e){this.updatePromptText(e,e==Ke.RECONNECTING)}updatePromptText(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.unscheduleAllCallbacks(),this.props.content=e,a("更新提示文案:",e),t){let t=0;const i=()=>{t=(t+1)%4,this.common_prompt_text.string=e+["","·","··","···"][t]};this.schedule(i,.5)}}onConfirmHandler(){this.is_close=!0,this.cat.gui.hideReconnect()}};ye([Ve({type:v,tooltip:"通用提示文本"}),ve("design:type",v)],qe.prototype,"common_prompt_text",void 0),ye([Ve({type:S,tooltip:"确定按钮"}),ve("design:type",S)],qe.prototype,"btn_confirm",void 0),ye([Ve({type:S,tooltip:"关闭按钮"}),ve("design:type",S)],qe.prototype,"btn_close",void 0),qe=ye([We("CoreReconnection"),ze("CATCORE/CoreReconnection")],qe);const{ccclass:Qe,property:Je,menu:Xe}=i;let Ze=class CoreNotice extends RootUILayer{text;btn_confirm;btn_close;onLoad(){this.btn_confirm.node.on(S.EventType.CLICK,this.onConfrimHandler,this)}start(){this.props&&this.updateProps(this.props)}onConfrimHandler(){this.props?.confrim?.(),this.cat.gui.hideNotice()}updateProps(e){this.text.string=`${e.text}`}};ye([Je({type:v,tooltip:"提示文本"}),ve("design:type",v)],Ze.prototype,"text",void 0),ye([Je({type:S,tooltip:"确定按钮"}),ve("design:type",S)],Ze.prototype,"btn_confirm",void 0),ye([Je({type:S,tooltip:"关闭按钮"}),ve("design:type",S)],Ze.prototype,"btn_close",void 0),Ze=ye([Qe("CoreNotice"),Xe("CATCORE/CoreNotice")],Ze);class SceneLayer extends BaseComponent{isReload}const{ccclass:Ye,property:et,menu:tt}=i;var it;!function(e){e[e.UI=0]="UI",e[e.LOADING=1]="LOADING",e[e.TOAST=2]="TOAST",e[e.RECONNECTTION=3]="RECONNECTTION",e[e.NOTICE=4]="NOTICE"}(it||(it={}));let ot=class Gui extends BaseComponent{reconnection_ui_prefab;toast_ui_prefab;loading_ui_prefab;notice_ui_prefab;ui_prefab;root_ui;root_toast;root_mask;ui_container_component;reconnection_ui_component;notice_ui_component;loading_ui_component;toast_ui_component;currentScene;currentSceneUUID;onEventListener(){this.cat.event.on(Re.ROOT_MASK_UPDATE,this.onRootUpdate,this)}init(e){this.cat=e;const t=r.getScene();return a("init scene"),t&&this.changeScene(t),this}start(){this.onRootUpdate()}toastQueue=[];isScheduling=!1;minInterval=.2;showToast(e){this.toastQueue.push(e),this.isScheduling||this.processQueueWithInterval()}processQueueWithInterval(){if(0===this.toastQueue.length)return void(this.isScheduling=!1);this.isScheduling=!0;const e=this.toastQueue.shift(),t=()=>{h(this.toast_ui_prefab).getComponent(Me).addToParent(this.root_toast,{props:e}),this.scheduleOnce(()=>{this.processQueueWithInterval()},this.minInterval)};0===this.root_toast.children.length?t():this.scheduleOnce(t,this.minInterval)}hideToast(){var e;this.root_toast&&H(e=this.root_toast.children).call(e,e=>{e.getComponent(Me)?.removeAndDestroy()});return this.toastQueue=[],this.unschedule(this.processQueueWithInterval),this.isScheduling=!1,this}showLoading(){let{title:e="",mask:t=!0,black:i=!0}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(a("showLoading",e),this.loading_ui_component)this.loading_ui_component.setOptions({props:{title:e,mask:t,black:i}});else{const o=h(this.loading_ui_prefab);this.loading_ui_component=o.getComponent($e).addToParent(this.root_ui,{props:{title:e,mask:t,black:i}})}return this}hideLoading(){return this.loading_ui_component?.removeAndDestroy(),this.loading_ui_component=null,this}showReconnect(e){if(this.reconnection_ui_component)this.reconnection_ui_component.setUpdateProps({content:e});else{const t=h(this.reconnection_ui_prefab);this.reconnection_ui_component=t.getComponent(qe).addToParent(this.root_ui,{props:{content:e}})}return this}hideReconnect(){return this.reconnection_ui_component?.removeAndDestroy(),this.reconnection_ui_component=null,this}showNotice(e){const t=h(this.notice_ui_prefab);return this.notice_ui_component=t.getComponent(Ze).addToParent(this.root_ui,{props:e}),this}hideNotice(){return this.notice_ui_component?.removeAndDestroy(),this}loadScene(e,t,i){a("[加载场景名][参数][重新加载]",e,t,i);let o={},n=i??!0;if("boolean"==typeof t?n=t:o=t??{},r.once(w.EVENT_BEFORE_SCENE_LAUNCH,e=>{a("Director.EVENT_BEFORE_SCENE_LAUNCH",e),this.changeScene(e,o,n)}),"string"==typeof e){var l;const t=$(l=A.bundles).call(l,e=>{const t=e.getSceneInfo(this.currentScene);return t?.uuid===this.currentSceneUUID});t&&"main"!==t.name?t.loadScene(this.currentScene,(e,t)=>{e?s("loadScene err",e):r.runScene(t)}):r.loadScene(e)}else r.runScene(e);return this}resetScene(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return e=e||this.currentScene,this.loadScene(e)}cleanScene(){this.resetScene().hideLoading().hideNotice().hideReconnect().hideToast()}changeScene(e,t,i){this.currentScene=e.name,this.createUILayer(e);const o=e.getComponentInChildren(SceneLayer);a("给场景传递属性值=======",o),o&&(o.isReload=i??!0),o?.setOptions(t)}createUILayer(e){this.ui_container_component?.removeAndDestroy(),this.ui_container_component=null;const t=h(this.ui_prefab);this.ui_container_component=t.getComponent(Pe),this.ui_container_component?.setGui(this).addToParent(e,this.node.getSiblingIndex())}reloadScene(){a("重新加载当前场景"),this.loadScene(this.currentSceneUUID,!0)}async closeUI(e,t){const{component:i}=this.findUIBaseLayer(e,!1);i&&(i.setOptions({...t?.hook??{},...t?.props??{}}),await i.hideTween(t||{}),this.ui_container_component?.subMask())}async openUI(e,t){const{rootNode:i,component:o}=this.findUIBaseLayer(e,!0);i.getComponent(UILayer),o?.setOptions(t),i&&this.ui_container_component?.addNodeToTween(i).addMask(),o&&await o.showTween(t||{}),this.ui_container_component?.ui_container&&o?.addToParent(this.ui_container_component.ui_container)}findUIBaseLayer(e,t){let i,o=null;if(e instanceof n){var r;i=e;const t=K(r=e.components).call(r,e=>e instanceof UILayer);if(!t.length)return s(`${e.name}节点未找到继承自BaseLayer的组件`),{rootNode:i,component:o};1==t.length?o=t[0]:I(`${e.name}节点存在多个继承自BaseLayer的组件`)}else if(i=e.node,o=e,t){for(;i.parent;)i=i.parent;o.root=i}else i=e.root;return{rootNode:i,component:o}}onRootUpdate(){const e=this.root_ui.children.findLastIndex(e=>e.active&&e!=this.root_mask);if(this.root_mask.active=-1!=e,e>-1){const t=this.root_ui.children[e].getSiblingIndex()-1;this.root_mask.setSiblingIndex(t<0?0:t)}this.cat.event.emit(Re.ROOT_MASK_CHANGE)}};var st;ye([et({type:c,tooltip:"断线重连UI预制体"}),ve("design:type",c)],ot.prototype,"reconnection_ui_prefab",void 0),ye([et({type:c,tooltip:"提示UI预制体"}),ve("design:type",c)],ot.prototype,"toast_ui_prefab",void 0),ye([et({type:c,tooltip:"加载UI预制体"}),ve("design:type",c)],ot.prototype,"loading_ui_prefab",void 0),ye([et({type:c,tooltip:"公告UI预制体"}),ve("design:type",c)],ot.prototype,"notice_ui_prefab",void 0),ye([et({type:c,tooltip:"UI层预制体"}),ve("design:type",c)],ot.prototype,"ui_prefab",void 0),ye([et({type:n,tooltip:"root-UI层"}),ve("design:type",n)],ot.prototype,"root_ui",void 0),ye([et({type:n,tooltip:"root-组件层"}),ve("design:type",n)],ot.prototype,"root_toast",void 0),ye([et({type:n,tooltip:"root-mask"}),ve("design:type",n)],ot.prototype,"root_mask",void 0),ot=ye([Ye("Gui"),tt("CATCORE/Gui")],ot),function(e){e.Root="prefabs/root",e.Toast="prefabs/toast",e.BlackMask="prefabs/black-mask",e.Loading="prefabs/loading",e.Notice="prefabs/notice",e.Reconnection="prefabs/reconnection"}(st||(st={}));class GuiManager extends BaseManager{gui;#e="core";getGuiPrefabByType=(e,t)=>new x((i,o)=>{a(e,`${t}`),this.cat.res.load(e,t,(e,t)=>{e?o(e):i(t)})});async init(){this.cat.gui_bundle_name&&(this.#e=this.cat.gui_bundle_name);const e=await this.getGuiPrefabByType(this.#e,st.Root),t=h(e);return this.gui=t.getComponent(ot).init(this.cat),r.addPersistRootNode(t),this}}class WrapperSocialGameClient extends re{showRequestErrInfo=!1;logBlackList=[];ignore=e=>{var t;return P(t=this.logBlackList).call(t,e)};constructor(e,t,i,o){super(t,i,o,e),this.showRequestErrInfo=o?.showRequestErrInfo??!1}destroy(){this.disconnect(!0),e._cat.socialGameClient.unregister(this)}async GameRequest(t,i,o){let{forwardReq:n=!1,forwardResp:r=!1}=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return new x((l,c)=>{super.GameRequest(t,i,o,{forwardReq:n,forwardResp:r}).then(e=>{oe&&a(`%c ws服务端消息 %c [Response][${new Date}] %c ${t} %c`,"background:#ff00ff ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#3d7daa ; padding: 1px; color: #fff","background:#ff00ff ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent",i),l(e)},t=>{s(t),this.showRequestErrInfo&&t?.msg&&e._cat.gui.showToast({title:t.msg}),c(t)})})}subscribe(t,i,o){return super.subscribe(t,i,i=>{oe&&!this.ignore(t)&&a(`%c ws服务端消息:[subscribe][${new Date}] %c ${t} %c`,"background:#35495e ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#410083 ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent",i),e._cat.event.emit(t,i),o?.(i)}),this}}class SocialGameClientManager extends BaseManager{managedClients=(()=>new j)();isGlobalOnline=!0;isInBackground=!1;reconnecting=!1;onEventHideDelegate=(()=>new T)();onEventShowDelegate=(()=>new T)();onEventReloadSceneDelegate=(()=>new T)();reconnectTimer=null;scheduleReconnect(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3;this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.reconnectTimer=Z(()=>{this.reconnectTimer=null,this.triggerReconnectAll()},e)}get activeClients(){var e,t;return K(e=Y(t=ee(this.managedClients)).call(t,e=>{let[t,i]=e;return i})).call(e,e=>e.socket)}constructor(e){super(e),this.initGlobalListeners()}createWebSocket(e,t,i,o){if(this.managedClients.has(e)){this.managedClients.get(e).destroy(),a(`清理旧的 ${e} 客户端`)}const s=new WrapperSocialGameClient(e,i,o,F({reconnectMaxAttempts:1/0},{...t,isAutoConnect:!1,isArrayBuffer:se}));return this.register(s),s}register(e){e.on("reconnected",this.handleSingleReconnect),e.on("close",this.handleSingleClose),e.on("kick",this.handleSingleKick),this.managedClients.set(e.name,e)}unregister(e){e.off("reconnected",this.handleSingleReconnect),e.off("close",this.handleSingleClose),e.off("kick",this.handleSingleKick),this.managedClients.delete(e.name)}initGlobalListeners(){this.cat.event.on(Re.ONLINE,()=>this.handleGlobalStateChange("online"),this).on(Re.OFFLINE,()=>this.handleGlobalStateChange("offline"),this),y.on(k.EVENT_SHOW,()=>this.handleGlobalStateChange("show")),y.on(k.EVENT_HIDE,()=>this.handleGlobalStateChange("hide"))}async handleGlobalStateChange(e){switch(e){case"online":this.cat.gui.hideLoading().showToast({title:Ke.ONLINE}),this.isGlobalOnline=!0,this.triggerReconnectAll();break;case"offline":this.isGlobalOnline=!1,this.disconnectAll(!0),this.cat.gui.showLoading({title:Ke.OFFLINE});break;case"show":this.isInBackground=!1,await this.triggerReconnectAll(),await this.onEventShowDelegate.dispatch();break;case"hide":await this.onEventHideDelegate.dispatch(),this.isInBackground=!0,this.disconnectAll(!0)}}async triggerReconnectAll(){if(a("触发所有客户端重连[正在重连][在线][后台][ws数量]",this.reconnecting,this.isGlobalOnline,this.isInBackground,this.managedClients.size),this.reconnecting||!this.isGlobalOnline||this.isInBackground||0===this.managedClients.size)return this.onEventReloadSceneDelegate.dispatch();this.reconnecting=!0,this.cat.gui.showLoading({title:"正在重连"});try{var e,t;await x.allSettled(Y(e=this.activeClients).call(e,async e=>{try{await e.reconnectPromise()}catch(t){s(`${e.name}服重连失败`,t)}}));const i=K(t=this.activeClients).call(t,e=>e.socketConnectStatus!==ie.CONNECTED);i.length>0?(console.error("部分WS重连失败:",Y(i).call(i,e=>e)),a("2s后重连所有客户端"),this.reconnecting=!1,this.scheduleReconnect()):this.reconnecting=!1}catch(e){throw this.reconnecting=!1,e}}disconnectAll(e){var t;H(t=this.managedClients).call(t,t=>{a("断开连接",t.name,e,t.socket),t.disconnect(e)})}handleSingleClose=()=>{this.reconnecting||(a("3s后重连所有客户端"),this.scheduleReconnect(3e3))};handleSingleReconnect=async()=>{var e,t;te(e=this.activeClients).call(e,e=>e.socketConnectStatus===ie.CONNECTED)&&(a("单个WS重连成功回调===",this.managedClients),await x.allSettled(Y(t=this.activeClients).call(t,async e=>{try{await e.connectRequest()}catch(t){s(`${e.name}服登录错误`,t),this.cat.gui.showToast({title:`登录${e.name}服错误`})}})),this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),await this.onEventReloadSceneDelegate.dispatch(),this.cat.gui.hideLoading(),r.getScene()?.getComponentInChildren(SceneLayer)?.isReload&&this.cat.gui.reloadScene())};handleSingleKick=()=>{this.cat.gui.showReconnect(Ke.KICK)}}class ResLoader{get=(()=>function(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"resources";return A.getBundle(i).get(e,t)})();isAssetType=e=>"function"==typeof e&&e.prototype instanceof O;async load(){let e=null,t=null,i=null;for(var o=arguments.length,s=new Array(o),n=0;n<o;n++)s[n]=arguments[n];"string"==typeof s[0]&&"string"==typeof s[1]&&(e=s.shift());let r=s.shift();this.isAssetType(s[0])&&(t=s.shift()),2==s.length&&(i=s.shift());const a=s.shift();let l=M;if(e&&"resources"!=e){A.bundles.has(e)||await this.loadBundle(e);let t=A.bundles.get(e);t&&(l=t)}i&&a?l.load(r,t,i,a):a?l.load(r,t,a):l.load(r,t)}async loadDir(){let e=null,t=null,i=null,o=null;for(var s=arguments.length,n=new Array(s),r=0;r<s;r++)n[r]=arguments[r];"string"==typeof n[0]&&"string"==typeof n[1]&&(e=n.shift());let a=n.shift();this.isAssetType(n[0])&&(t=n.shift()),2==n.length&&(i=n.shift()),o=n.shift();let l=M;if(e&&"resources"!=e){A.bundles.has(e)||await this.loadBundle(e);let t=A.bundles.get(e);t&&(l=t)}i&&o?l.loadDir(a,t,i,o):o?l.loadDir(a,t,o):l.loadDir(a,t)}loadRemote(e){for(var t,i=null,o=arguments.length,s=new Array(o>1?o-1:0),n=1;n<o;n++)s[n-1]=arguments[n];2==s.length&&(i=s.shift()),t=s.shift(),A.loadRemote(e,{ext:".png",...i},t)}loadBundle=(e,t)=>new x((i,o)=>{const s=(e,t)=>{if(e)return o(e);i(t)};t?A.loadBundle(e,{version:t},s):A.loadBundle(e,s)});releasePrefabtDepsRecursively=e=>{var t=A.assets.get(e);if(A.releaseAsset(t),t instanceof c){var i=A.dependUtil.getDepsRecursively(e);H(i).call(i,e=>{A.assets.get(e).decRef()})}};release=(()=>{var e=this;return function(t){let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"resources";var o=A.getBundle(i);if(o){var s=o.get(t);s&&e.releasePrefabtDepsRecursively(s._uuid)}}})();releaseDir=(()=>{var e=this;return function(t){var i,o;let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"resources";var n=A.getBundle(s),r=n?.getDirWithPath(t);(null==(i=r)?void 0:z(o=Function.call).call(o,Y(i),i))?.(t=>{e.releasePrefabtDepsRecursively(t.uuid)}),!t&&"resources"!=s&&n&&A.removeBundle(n)}})();dump=()=>{var e;H(e=A.assets).call(e,(e,t)=>{a(A.assets.get(t))}),a(`当前资源总数:${A.assets.count}`)};loadAssetsWithProgress(e,t){return new x((i,o)=>{const s=e.getDirWithPath(""),n=s.length;let r=0;if(0===n)return t(1),void i();H(s).call(s,s=>{e.load(s.path,e=>{e?o(e):(r++,t(r/n),r===n&&i())})})})}}class BaseStore{rootStore;constructor(e){this.rootStore=e}}class CoreStore extends BaseManager{}let nt=null;const rt={stringify:e=>{const t={ct:e.ciphertext.toString(ae.enc.Base64)};return e.iv&&(t.iv=e.iv.toString()),e.salt&&(t.s=e.salt.toString()),G(t)},parse:e=>{const t=JSON.parse(e),i=ae.lib.CipherParams.create({ciphertext:ae.enc.Base64.parse(t.ct)});return t.iv&&(i.iv=ae.enc.Hex.parse(t.iv)),t.s&&(i.salt=ae.enc.Hex.parse(t.s)),i}};var at=Object.freeze({__proto__:null,JsonFormatter:rt,aesDecrypt:(e,t,i)=>ae.AES.decrypt(e,t,{iv:nt,format:rt}).toString(ae.enc.Utf8),aesEncrypt:(e,t,i)=>ae.AES.encrypt(e,t,{iv:nt,format:rt}).toString(),initCrypto:(e,t)=>{nt=ae.enc.Hex.parse(t)},md5:e=>ae.MD5(e).toString()});class CoreUtil extends BaseManager{encryptUtil=(()=>at)()}class StorageManager extends BaseManager{_key=null;_iv=null;_id="";init(e,t){this.cat.util.encryptUtil.initCrypto(e,t),this._key=this.cat.util.encryptUtil.md5(e),this._iv=this.cat.util.encryptUtil.md5(t)}setUser(e){this._id=e}set(e,t){if(null!=(e=`${e}_${this._id}`)){if(ne||(e=this.cat.util.encryptUtil.md5(e)),null==t)return console.warn("存储的值为空,则直接移除该存储"),void this.remove(e);if("function"!=typeof t){if("object"==typeof t)try{t=G(t)}catch(e){return void console.error(`解析失败,str = ${t}`)}else"number"==typeof t&&(t+="");ne||null==this._key||null==this._iv||(t=this.cat.util.encryptUtil.aesEncrypt(`${t}`,this._key,this._iv)),R.localStorage.setItem(e,t)}else console.error("储存的值不能为方法")}else console.error("存储的key不能为空")}get(e,t){if(null==e)return console.error("存储的key不能为空"),null;e=`${e}_${this._id}`,ne||(e=this.cat.util.encryptUtil.md5(e));let i=R.localStorage.getItem(e);return null==i||""===i||ne||null==this._key||null==this._iv||(i=this.cat.util.encryptUtil.aesDecrypt(i,this._key,this._iv)),null===i?t:i}getNumber(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;var i=this.get(e);return Number(i)||t}getBoolean(e){var t=this.get(e);return Boolean(t)||!1}getJson(e,t){var i=this.get(e);return i&&JSON.parse(i)||t}remove(e){null!=e?(e=`${e}_${this._id}`,ne||(e=this.cat.util.encryptUtil.md5(e)),R.localStorage.removeItem(e)):console.error("存储的key不能为空")}clear(){R.localStorage.clear()}}class Manager{static#t=null;#i=!1;static get instance(){return this.#t??(this.#t=new Manager)}onAppInitDelegate=(()=>new T)();onPlugInInitDelegate=(()=>new T)();#o=null;get audio(){return this.#o}#s=null;get event(){return this.#s}#n=null;get gui(){return this.#n}#r=null;get storage(){return this.#r}#a=null;get res(){return this.#a}#l=null;get util(){return this.#l}#c=null;get socialGameClient(){return this.#c}#h=null;get store(){return this.#h}#u="";get gui_bundle_name(){return this.#u}#p="";get audio_local_store_key(){return this.#p}#d="";get default_audio_effect(){return this.#d}setConfig=(()=>{var e=this;return function(){let{default_audio_effect:t="",gui_bundleName:i="resources",audio_local_store_key:o="game_audio"}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(e.#i)throw new Error("[CAT] 已初始化,无法修改配置");return e.#u=i,e.#p=o,e.#d=t,e}})();async boot(){if(this.#i)throw new Error("[CAT] 已初始化");try{this.#h=new CoreStore(this),this.#a=new ResLoader,this.#l=new CoreUtil(this),this.#r=new StorageManager(this),this.#s=new B,this.#o=new AudioManager(this),this.#c=new SocialGameClientManager(this),this.#n=(await new GuiManager(this).init()).gui,this.#i=!0}catch(e){throw console.error("[CAT] 初始化失败:",e),e}}merge(e,t){if(!this.#i)throw new Error("[CAT] 未初始化");if("string"!=typeof e)throw new Error("merge方法第一个参数应该为string类型");return D(this,e)||L(this,e,t),F(D(this,e),t),this}appendPlugInInitDelegate(e){return this.#i?x.resolve().then(e).catch(e=>{console.error("[CAT] appendPlugInInitDelegate 回调执行失败:",e)}):this.onPlugInInitDelegate.add(e),this}}const{ccclass:lt,property:ct,menu:ht}=i;let ut=class CoreUIModal extends UILayer{default_title=null;title;prompt_content_str;prompt_content_spriteFrame;btn_confirm;confirm_spriteFrame;btn_cancel;cancel_spriteFrame;btn_close;isConfirm=!1;props={title:this.default_title,content:null,confirmCB:()=>{},cancelCB:()=>{},style:null};onLoad(){this.btn_cancel.node.on(S.EventType.CLICK,this.onCancelHandler,this),this.btn_confirm.node.on(S.EventType.CLICK,this.onConfirmHandler,this),this.btn_close.node.on(S.EventType.CLICK,this.onCloseHandler,this),this.addAutorun([()=>{this.title.spriteFrame=this.props?.title||this.default_title},()=>{this.props.content&&(this.props.content instanceof U?this.prompt_content_spriteFrame.spriteFrame=this.props.content:"string"==typeof this.props.content?this.prompt_content_str.string=this.props.content:console.error("未知类型的【UIModal】内容"))},()=>{null===this.props?.style?.confirm?this.btn_confirm.node.active=!1:(this.btn_confirm.node.active=!0,this.btn_confirm.getComponent(N).spriteFrame=this.props.style?.confirm||this.confirm_spriteFrame),null===this.props?.style?.cancel?this.btn_cancel.node.active=!1:(this.btn_cancel.node.active=!0,this.btn_cancel.getComponent(N).spriteFrame=this.props.style?.cancel||this.cancel_spriteFrame)}])}close(){this.props.cancelCB?.(),this.cat.gui.closeUI(this)}onCancelHandler(){this.close()}onConfirmHandler(){this.props.confirmCB?.()}onDestroy(){this.isConfirm&&this.props.onDestroy?.()}onCloseHandler(){this.close()}};var pt;ye([ct({type:U,tooltip:"默认标题"}),ve("design:type",U)],ut.prototype,"default_title",void 0),ye([ct({type:N,tooltip:"标题节点"}),ve("design:type",N)],ut.prototype,"title",void 0),ye([ct({type:v,tooltip:"字符串内容按钮"}),ve("design:type",v)],ut.prototype,"prompt_content_str",void 0),ye([ct({type:N,tooltip:"图片精灵内容按钮"}),ve("design:type",N)],ut.prototype,"prompt_content_spriteFrame",void 0),ye([ct({type:S,tooltip:"确认按钮"}),ve("design:type",S)],ut.prototype,"btn_confirm",void 0),ye([ct({type:U,tooltip:"确认按钮精灵图"}),ve("design:type",U)],ut.prototype,"confirm_spriteFrame",void 0),ye([ct({type:S,tooltip:"取消按钮"}),ve("design:type",S)],ut.prototype,"btn_cancel",void 0),ye([ct({type:U,tooltip:"取消按钮精灵图"}),ve("design:type",U)],ut.prototype,"cancel_spriteFrame",void 0),ye([ct({type:S,tooltip:"关闭按钮"}),ve("design:type",S)],ut.prototype,"btn_close",void 0),ut=ye([lt("CoreUIModal"),ht("CATCORE/CoreUIModal")],ut),function(e){e[e.Delay=0]="Delay",e[e.Interval=1]="Interval"}(pt||(pt={}));class TimerEntry{tag;type;callback;remainingTime;executionTime=0;initialTime;constructor(e,t,i,o){this.tag=e,this.type=t,this.remainingTime=i,this.initialTime=i,this.callback=o}}class TimerManager extends BaseManager{timers=(()=>new j)();lastUpdateTime=(()=>le())();constructor(e){var t;super(e),e.event.on(Re.EVENT_HIDE,this.onHandleAppBackground,this),e.event.on(Re.EVENT_SHOW,this.onHandleAppForeground,this),ce(z(t=this.update).call(t,this),1e3)}onHandleAppBackground(){this.lastUpdateTime=le()}onHandleAppForeground(){const e=le(),t=e-this.lastUpdateTime;a("elapsedTime",t);for(const e of he(i=this.timers).call(i)){var i;e.remainingTime>0&&(e.remainingTime-=t,e.executionTime+=t)}this.lastUpdateTime=e}registerInterval(e,t,i){if(this.has(e))return s(`${e}定时器已存在,请勿重复注册`);const o=new TimerEntry(e,pt.Interval,t,i);this.timers.set(e,o)}registerDelay(e,t,i){if(this.has(e))return s(`${e}延时器已存在,请勿重复注册`);const o=new TimerEntry(e,pt.Delay,t,i);this.timers.set(e,o)}unregister(e){this.has(e)&&this.timers.delete(e)}has(e){return this.timers.has(e)}update(){const e=[];for(const[i,o]of ue(t=this.timers).call(t)){var t;o.remainingTime-=1e3,o.remainingTime<=0&&(o.type===pt.Interval&&(o.executionTime+=o.initialTime),o.callback(o.executionTime),o.type===pt.Interval?o.remainingTime=o.initialTime:e.push(i))}for(const t of e)this.timers.delete(t)}}const dt=(t,i)=>(o,s,n)=>{let r=n.value;return n.value=function(){const o=t??e._cat.default_audio_effect;o?e._cat.audio.playEffect(o):console.warn("请添加音效路径参数"),i&&i();for(var s=arguments.length,n=new Array(s),a=0;a<s;a++)n[a]=arguments[a];r.apply(this,n)},n},mt=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1?arguments[1]:void 0;return function(i,o,s){let n=s.value,r=!1;return s.value=function(){if(r)t&&t();else{r=!0,Z(()=>{r=!1},1e3*e);for(var i=arguments.length,o=new Array(i),s=0;s<i;s++)o[s]=arguments[s];n.apply(this,o)}},s}},_t=e._cat??=Manager.instance;y.onPostProjectInitDelegate.add(async()=>{console.time("[Init App]");try{await _t.boot(),await _t.onAppInitDelegate.dispatch(),await _t.onPlugInInitDelegate.dispatch()}catch(e){throw s(`[Init App] 初始化失败: ${e instanceof Error?e.message:String(e)}`),e}finally{console.timeEnd("[Init App]")}});export{dt as AudioEffect,fe as AudioEventConstant,AudioManager,AudioSourceBaseComponent,AudioSourceUILayer,Se as AudioTypeEnum,BaseComponent,BaseManager,st as BasePrefab,BaseStore,mt as ButtonLock,Le as CoreBlackMask,Ze as CoreNotice,qe as CoreReconnection,$e as CoreShowLoading,CoreStore,Me as CoreToast,Pe as CoreUIContainer,ut as CoreUIModal,CoreUtil,Re as GlobalEventConstant,ot as Gui,GuiManager,it as LayerType,Manager,Ke as ReconnectPrompt,RootUILayer,SceneLayer,TimerManager,Oe as ToastType,UILayer,WrapperSocialGameClient,_t as cat};
1
+ import e from "@babel/runtime-corejs3/core-js/global-this";
2
+
3
+ import { AudioSource as t, _decorator as i, AudioClip as s, error as n, Node as o, director as r, log as a, Component as l, Prefab as c, instantiate as h, isValid as u, Layers as d, view as p, Widget as f, v3 as m, tween as _, Enum as g, game as y, Label as v, UIOpacity as b, Tween as C, BlockInputEvents as E, Button as S, Director as w, assetManager as A, warn as I, AsyncDelegate as T, Game as k, Asset as O, resources as M, sys as R, SpriteFrame as U, Sprite as N } from "cc";
4
+
5
+ import D from "@babel/runtime-corejs3/core-js-stable/reflect/get";
6
+
7
+ import L from "@babel/runtime-corejs3/core-js-stable/reflect/set";
8
+
9
+ import F from "@babel/runtime-corejs3/core-js-stable/object/assign";
10
+
11
+ import x from "@babel/runtime-corejs3/core-js-stable/promise";
12
+
13
+ import B from "eventemitter3";
14
+
15
+ import P from "@babel/runtime-corejs3/core-js-stable/instance/includes";
16
+
17
+ import G from "@babel/runtime-corejs3/core-js-stable/json/stringify";
18
+
19
+ import j from "@babel/runtime-corejs3/core-js-stable/map";
20
+
21
+ import H from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
22
+
23
+ import $ from "@babel/runtime-corejs3/core-js-stable/instance/find";
24
+
25
+ import K from "@babel/runtime-corejs3/core-js-stable/instance/filter";
26
+
27
+ import W from "@babel/runtime-corejs3/core-js-stable/array/is-array";
28
+
29
+ import V from "@babel/runtime-corejs3/core-js-stable/reflect/own-keys";
30
+
31
+ import z from "@babel/runtime-corejs3/core-js-stable/instance/bind";
32
+
33
+ import { makeObservable as q, observable as Q, autorun as J, reaction as X } from "@shimotsuki/mobx";
34
+
35
+ import Z from "@babel/runtime-corejs3/core-js-stable/set-timeout";
36
+
37
+ import Y from "@babel/runtime-corejs3/core-js-stable/instance/map";
38
+
39
+ import ee from "@babel/runtime-corejs3/core-js-stable/array/from";
40
+
41
+ import te from "@babel/runtime-corejs3/core-js-stable/instance/every";
42
+
43
+ import { SocketConnectStatus as ie } from "pitayaclient";
44
+
45
+ import { DEBUG as se, WECHAT as ne, PREVIEW as oe } from "cc/env";
46
+
47
+ import { SocialGameClient as re } from "sgc";
48
+
49
+ import ae from "crypto-es";
50
+
51
+ import le from "@babel/runtime-corejs3/core-js-stable/date/now";
52
+
53
+ import ce from "@babel/runtime-corejs3/core-js-stable/set-interval";
54
+
55
+ import he from "@babel/runtime-corejs3/core-js-stable/instance/values";
56
+
57
+ import ue from "@babel/runtime-corejs3/core-js-stable/instance/entries";
58
+
59
+ class CommonAudio extends t {
60
+ cat;
61
+ initAudio(e) {
62
+ this.cat = e;
63
+ return this;
64
+ }
65
+ }
66
+
67
+ const {ccclass: de, menu: pe} = i;
68
+
69
+ let fe = class AudioEffect extends CommonAudio {
70
+ effects=(() => new j)();
71
+ load(e, t) {
72
+ return new x((i, n) => {
73
+ let o = null;
74
+ let r;
75
+ if (t !== undefined) {
76
+ o = e;
77
+ r = t;
78
+ } else {
79
+ r = e;
80
+ }
81
+ const a = (e, t) => {
82
+ if (e) {
83
+ return n(e);
84
+ }
85
+ this.effects.set(r, t);
86
+ this.playOneShot(t, this.volume);
87
+ i(t);
88
+ };
89
+ o ? this.cat.res.load(o, r, s, a) : this.cat.res.load(r, s, a);
90
+ });
91
+ }
92
+ release() {
93
+ for (let e in this.effects) {
94
+ this.cat.res.release(e);
95
+ }
96
+ this.effects.clear();
97
+ }
98
+ };
99
+
100
+ const {ccclass: me, menu: _e} = i;
101
+
102
+ class AudioMusic extends CommonAudio {
103
+ onComplete=null;
104
+ _progress=0;
105
+ _url=null;
106
+ _isPlay=false;
107
+ get progress() {
108
+ if (this.duration > 0) this._progress = this.currentTime / this.duration;
109
+ return this._progress;
110
+ }
111
+ set progress(e) {
112
+ this._progress = e;
113
+ this.currentTime = e * this.duration;
114
+ }
115
+ load(e, t) {
116
+ return new x((i, o) => {
117
+ let r = null;
118
+ let a;
119
+ if (t !== undefined) {
120
+ r = e;
121
+ a = t;
122
+ } else {
123
+ a = e;
124
+ }
125
+ const l = (e, t) => {
126
+ if (e) {
127
+ n(e);
128
+ return o(e);
129
+ }
130
+ if (this.playing) {
131
+ this._isPlay = false;
132
+ this.stop();
133
+ this.cat.res.release(this._url);
134
+ }
135
+ this.playOnAwake = false;
136
+ this.enabled = true;
137
+ this.clip = t;
138
+ this._url = a;
139
+ i(t);
140
+ };
141
+ r ? this.cat.res.load(r, a, s, l) : this.cat.res.load(a, s, l);
142
+ });
143
+ }
144
+ update(e) {
145
+ if (this.currentTime > 0) {
146
+ this._isPlay = true;
147
+ }
148
+ if (this._isPlay && this.playing == false) {
149
+ this._isPlay = false;
150
+ this.enabled = false;
151
+ this.onComplete && this.onComplete();
152
+ }
153
+ }
154
+ release() {
155
+ if (this._url) {
156
+ this.cat.res.release(this._url);
157
+ this._url = null;
158
+ }
159
+ }
160
+ }
161
+
162
+ class BaseManager {
163
+ cat;
164
+ constructor(e) {
165
+ this.cat = e;
166
+ }
167
+ }
168
+
169
+ var ge;
170
+
171
+ (function(e) {
172
+ e["MUSIC_ON"] = "AudioEventConstant/MUSIC_ON";
173
+ e["MUSIC_OFF"] = "AudioEventConstant/MUSIC_OFF";
174
+ e["EFFECT_ON"] = "AudioEventConstant/EFFECT_ON";
175
+ e["EFFECT_OFF"] = "AudioEventConstant/EFFECT_OFF";
176
+ e["PAUSE_AUDIO"] = "AudioEventConstant/PAUSE_AUDIO";
177
+ e["RESUME_AUDIO"] = "AudioEventConstant/RESUME_AUDIO";
178
+ })(ge || (ge = {}));
179
+
180
+ class AudioManager extends BaseManager {
181
+ local_data={};
182
+ music;
183
+ effect;
184
+ _volume_music=1;
185
+ _volume_effect=1;
186
+ _switch_music=true;
187
+ _switch_effect=true;
188
+ local_store_key="game_audio";
189
+ extra={};
190
+ constructor(e) {
191
+ super(e);
192
+ this.local_store_key = this.cat.audio_local_store_key;
193
+ var t = new o("UIAudioManager");
194
+ r.addPersistRootNode(t);
195
+ var i = new o("UIMusic");
196
+ i.parent = t;
197
+ this.music = i.addComponent(AudioMusic).initAudio(e);
198
+ var s = new o("UIEffect");
199
+ s.parent = t;
200
+ this.effect = s.addComponent(fe).initAudio(e);
201
+ this.load();
202
+ }
203
+ setMusicComplete() {
204
+ let e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
205
+ this.music.onComplete = e;
206
+ }
207
+ async playMusic(e, t) {
208
+ this.music.loop = true;
209
+ if (!this._switch_music) return;
210
+ let i;
211
+ let s;
212
+ if (t !== undefined) {
213
+ s = e;
214
+ i = t;
215
+ } else {
216
+ i = e;
217
+ }
218
+ if (!i.length) return;
219
+ await (s ? this.music.load(s, i) : this.music.load(i)).then(() => {
220
+ if (this._switch_music) {
221
+ this.music.play();
222
+ }
223
+ });
224
+ }
225
+ stopMusic() {
226
+ if (this.music.state != 0) this.music?.stop();
227
+ }
228
+ pauseMusic() {
229
+ if (this.music.state == 1) this.music?.pause();
230
+ }
231
+ resumeMusic() {
232
+ var e;
233
+ if (P(e = [ 0, 2 ]).call(e, this.music.state)) this.music?.play();
234
+ }
235
+ get progressMusic() {
236
+ return this.music.progress;
237
+ }
238
+ set progressMusic(e) {
239
+ this.music.progress = e;
240
+ }
241
+ get volumeMusic() {
242
+ return this._volume_music;
243
+ }
244
+ set volumeMusic(e) {
245
+ this._volume_music = e;
246
+ this.music.volume = e;
247
+ }
248
+ get switchMusic() {
249
+ return this._switch_music;
250
+ }
251
+ set switchMusic(e) {
252
+ a("设置背景音乐开关值", e, this._switch_music);
253
+ if (e == this._switch_music) return;
254
+ this._switch_music = e;
255
+ e ? this.resumeMusic() : this.pauseMusic();
256
+ const t = e ? ge.MUSIC_ON : ge.MUSIC_OFF;
257
+ this.cat.event.emit(t);
258
+ this.save();
259
+ }
260
+ async playEffect(e, t) {
261
+ if (!this._switch_effect) return;
262
+ let i;
263
+ let s;
264
+ if (t !== undefined) {
265
+ s = e;
266
+ i = t;
267
+ } else {
268
+ i = e;
269
+ }
270
+ if (!i.length) return;
271
+ await (s ? this.effect.load(s, i) : this.effect.load(i)).then(() => {
272
+ this.effect.play();
273
+ });
274
+ }
275
+ stopEffect() {
276
+ this.effect?.stop();
277
+ }
278
+ get volumeEffect() {
279
+ return this._volume_effect;
280
+ }
281
+ set volumeEffect(e) {
282
+ this._volume_effect = e;
283
+ this.effect.volume = e;
284
+ }
285
+ get switchEffect() {
286
+ return this._switch_effect;
287
+ }
288
+ set switchEffect(e) {
289
+ if (e == this._switch_effect) return;
290
+ this._switch_effect = e;
291
+ e ? this.effect?.play() : this.effect?.stop();
292
+ const t = e ? ge.EFFECT_ON : ge.EFFECT_OFF;
293
+ this.cat.event.emit(t);
294
+ this.save();
295
+ }
296
+ resumeAll() {
297
+ this.switchMusic && this.music?.play();
298
+ this.switchEffect && this.effect?.play();
299
+ }
300
+ pauseAll() {
301
+ this.music?.pause();
302
+ this.effect?.pause();
303
+ }
304
+ stopAll() {
305
+ this.music?.stop();
306
+ this.effect?.stop();
307
+ }
308
+ save() {
309
+ this.local_data.volume_music = this._volume_music;
310
+ this.local_data.volume_effect = this._volume_effect;
311
+ this.local_data.switch_music = this._switch_music;
312
+ this.local_data.switch_effect = this._switch_effect;
313
+ this.local_data.extra = this.extra;
314
+ let e = G(this.local_data);
315
+ this.cat.storage.set(this.local_store_key, e);
316
+ return this;
317
+ }
318
+ load() {
319
+ try {
320
+ let e = this.cat.storage.get(this.local_store_key);
321
+ this.local_data = JSON.parse(e);
322
+ this._volume_music = this.local_data.volume_music;
323
+ this._volume_effect = this.local_data.volume_effect;
324
+ this._switch_music = this.local_data.switch_music;
325
+ this._switch_effect = this.local_data.switch_effect;
326
+ this.extra = this.local_data.extra;
327
+ } catch (e) {
328
+ this.local_data = {};
329
+ this._volume_music = .6;
330
+ this._volume_effect = 1;
331
+ this._switch_music = true;
332
+ this._switch_effect = true;
333
+ this.extra = {};
334
+ }
335
+ if (this.music) this.music.volume = this._volume_music;
336
+ if (this.effect) this.effect.volume = this._volume_effect;
337
+ }
338
+ }
339
+
340
+ function ye(e, t, i, s) {
341
+ var n = arguments.length, o = n < 3 ? t : s === null ? s = Object.getOwnPropertyDescriptor(t, i) : s, r;
342
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") o = Reflect.decorate(e, t, i, s); else for (var a = e.length - 1; a >= 0; a--) if (r = e[a]) o = (n < 3 ? r(o) : n > 3 ? r(t, i, o) : r(t, i)) || o;
343
+ return n > 3 && o && Object.defineProperty(t, i, o), o;
344
+ }
345
+
346
+ function ve(e, t) {
347
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(e, t);
348
+ }
349
+
350
+ typeof SuppressedError === "function" ? SuppressedError : function(e, t, i) {
351
+ var s = new Error(i);
352
+ return s.name = "SuppressedError", s.error = e, s.suppressed = t, s;
353
+ };
354
+
355
+ class BaseComponent extends l {
356
+ props={};
357
+ data={};
358
+ cat=(() => e._cat)();
359
+ autorunDisposers=[];
360
+ reactionDisposers=[];
361
+ eventEmitter=[];
362
+ hook={
363
+ destroyed: () => {},
364
+ started: () => {}
365
+ };
366
+ initUI() {}
367
+ __preload() {
368
+ this.initUI();
369
+ this.onAutoObserver();
370
+ }
371
+ constructor() {
372
+ super();
373
+ q(this, {
374
+ props: Q,
375
+ data: Q
376
+ });
377
+ }
378
+ onAutoObserver() {}
379
+ addAutorun(e) {
380
+ const t = W(e) ? e : [ e ];
381
+ H(t).call(t, e => {
382
+ const t = J(e);
383
+ this.autorunDisposers.push(t);
384
+ });
385
+ return this;
386
+ }
387
+ addReaction(e, t, i) {
388
+ const s = X(e, t, i);
389
+ this.reactionDisposers.push(s);
390
+ return this;
391
+ }
392
+ addAudoListener(e) {
393
+ var t;
394
+ if (!P(t = this.eventEmitter).call(t, e) && e !== this.cat.event) {
395
+ this.eventEmitter.push(e);
396
+ }
397
+ return e;
398
+ }
399
+ _onPreDestroy() {
400
+ var e, t;
401
+ H(e = this.autorunDisposers).call(e, e => {
402
+ e();
403
+ });
404
+ H(t = this.reactionDisposers).call(t, e => {
405
+ e();
406
+ });
407
+ this.autorunDisposers = [];
408
+ this.reactionDisposers = [];
409
+ if (!super._onPreDestroy) {
410
+ throw new Error("_onPreDestroy已弃用");
411
+ } else {
412
+ super._onPreDestroy();
413
+ }
414
+ }
415
+ onDisable() {
416
+ var e;
417
+ this.onHide();
418
+ this.deleteAllEventByEmitter(this.cat.event);
419
+ H(e = this.eventEmitter).call(e, e => {
420
+ this.deleteAllEventByEmitter(e);
421
+ });
422
+ this.eventEmitter = [];
423
+ this.removeListener();
424
+ }
425
+ deleteAllEventByEmitter(e) {
426
+ const t = e["_events"];
427
+ for (const i in t) {
428
+ let s = t[i];
429
+ if (!W(s)) {
430
+ s = [ s ];
431
+ }
432
+ H(s).call(s, t => {
433
+ if (t.context === this) {
434
+ e.off(i, t.fn, this);
435
+ }
436
+ });
437
+ }
438
+ }
439
+ onEnable() {
440
+ this.onShow();
441
+ this.addListener();
442
+ this.onEventListener();
443
+ }
444
+ onEventListener() {}
445
+ addListener() {}
446
+ removeListener() {}
447
+ addToParent(e, t, i) {
448
+ const s = e instanceof c ? h(e) : e instanceof l ? e.node : e;
449
+ if (typeof t === "number") {
450
+ const e = t;
451
+ const n = i;
452
+ this.setOptions(n);
453
+ s.insertChild(this.node, e);
454
+ } else {
455
+ const e = t;
456
+ this.setOptions(e);
457
+ s.addChild(this.node);
458
+ }
459
+ return this;
460
+ }
461
+ setOptions(e) {
462
+ if (!e) return;
463
+ for (let t in e) {
464
+ switch (t) {
465
+ case "hook":
466
+ e.hook && (this.hook = e.hook);
467
+ break;
468
+
469
+ case "props":
470
+ if (e.props !== null && typeof e.props === "object") {
471
+ this.props = e.props;
472
+ }
473
+ break;
474
+
475
+ case "data":
476
+ if (e.data !== null && typeof e.data === "object") {
477
+ this.data = e.data;
478
+ }
479
+ break;
480
+ }
481
+ }
482
+ }
483
+ setUpdateData(e) {
484
+ if (!this.data) return;
485
+ e && F(this.data, this.toPlainObject(e));
486
+ return this;
487
+ }
488
+ setUpdateProps(e) {
489
+ if (!this.props) return;
490
+ e && F(this.props, this.toPlainObject(e));
491
+ return this;
492
+ }
493
+ toPlainObject(e) {
494
+ const t = {};
495
+ for (const i of V(e)) {
496
+ if (typeof i === "string") {
497
+ try {
498
+ t[i] = e[i];
499
+ } catch {}
500
+ }
501
+ }
502
+ return t;
503
+ }
504
+ removeAndDestroy() {
505
+ if (u(this?.node)) {
506
+ this.node.removeFromParent();
507
+ this.node.destroy();
508
+ }
509
+ }
510
+ setPosition(e) {
511
+ this.node.setPosition(e);
512
+ return this;
513
+ }
514
+ setScale(e) {
515
+ this.node.setScale(e);
516
+ return this;
517
+ }
518
+ setAngle(e) {
519
+ this.node.angle = e;
520
+ return this;
521
+ }
522
+ setRotation(e) {
523
+ this.node.setRotation(e);
524
+ return this;
525
+ }
526
+ setRotationFromEuler(e) {
527
+ this.node.setRotationFromEuler(e);
528
+ return this;
529
+ }
530
+ onShow() {}
531
+ onHide() {}
532
+ setNodeAndChildrenLayer(e) {
533
+ be(this.node, e);
534
+ return this;
535
+ }
536
+ }
537
+
538
+ const be = (e, t) => {
539
+ var i, s, n;
540
+ e.layer = typeof t === "string" ? 2 ** d.nameToLayer(t) : t;
541
+ ((i = e) == null ? void 0 : z(n = Function.call).call(n, H(s = i.children), s))?.(e => {
542
+ be(e, t);
543
+ });
544
+ };
545
+
546
+ class UILayer extends BaseComponent {
547
+ lastEnterDirection="center";
548
+ screen;
549
+ isClosing=false;
550
+ root;
551
+ constructor() {
552
+ super();
553
+ this._init();
554
+ }
555
+ _init() {
556
+ this.root = this.node;
557
+ this.screen = p.getVisibleSize();
558
+ }
559
+ async showTween(e) {
560
+ let {isMotion: t = true, direction: i = "center", duration: s = .1, isBounce: n = true, bounceDuration: o = .05} = e;
561
+ this.lastEnterDirection = i;
562
+ if (t) {
563
+ const e = this.node.getComponent(f);
564
+ if (e) {
565
+ e.updateAlignment();
566
+ e.enabled = false;
567
+ }
568
+ let t;
569
+ let o;
570
+ m(1.1, 1.1, 1);
571
+ if (i == "center") {
572
+ t = m(.01, .01, .01);
573
+ o = m(1, 1, 1);
574
+ } else {
575
+ if (i == "left") {
576
+ t = m(-this.screen.width, 0, 0);
577
+ } else if (i == "right") {
578
+ t = m(this.screen.width, 0, 0);
579
+ } else if (i == "top") {
580
+ t = m(0, this.screen.height, 0);
581
+ } else {
582
+ t = m(0, -this.screen.height, 0);
583
+ }
584
+ o = m(0, 0, 0);
585
+ }
586
+ await this.handle(i, s, t, o, n);
587
+ if (e) e.enabled = true;
588
+ }
589
+ }
590
+ async hideTween(e) {
591
+ let {isMotion: t = true, direction: i, duration: s = .1} = e;
592
+ i = i || this.lastEnterDirection;
593
+ if (this.isClosing) return;
594
+ this.isClosing = true;
595
+ _(this.node).removeSelf();
596
+ if (t) {
597
+ const e = this.node.getComponent(f);
598
+ if (e) e.enabled = false;
599
+ let t;
600
+ let n;
601
+ if (i == "center") {
602
+ t = this.node.scale;
603
+ n = m(0, 0, 0);
604
+ } else {
605
+ if (i == "left") {
606
+ n = m(-this.screen.width, 0, 0);
607
+ } else if (i == "right") {
608
+ n = m(this.screen.width, 0, 0);
609
+ } else if (i == "top") {
610
+ n = m(0, this.screen.height, 0);
611
+ } else {
612
+ n = m(0, -this.screen.height, 0);
613
+ }
614
+ t = this.node.getPosition();
615
+ }
616
+ await this.handle(i, s, t, n, false);
617
+ }
618
+ this.removeAndDestroy();
619
+ }
620
+ async handle(e, t, i, s, n) {
621
+ if (e == "center") {
622
+ this.node.setScale(i);
623
+ } else {
624
+ this.node.setPosition(i);
625
+ }
626
+ await this.deftween(t, {
627
+ [e == "center" ? "scale" : "position"]: s
628
+ }, n);
629
+ }
630
+ deftween(e, t, i, s) {
631
+ return new x((i, s) => {
632
+ _(this.node).to(e, t).call(() => {
633
+ i();
634
+ }).start();
635
+ });
636
+ }
637
+ }
638
+
639
+ const {ccclass: Ce, property: Ee} = i;
640
+
641
+ var Se;
642
+
643
+ (function(e) {
644
+ e[e["EFFECT"] = 0] = "EFFECT";
645
+ e[e["BGM"] = 1] = "BGM";
646
+ })(Se || (Se = {}));
647
+
648
+ class AudioSourceBaseComponent extends BaseComponent {
649
+ type=(() => Se.EFFECT)();
650
+ clip=null;
651
+ loop=false;
652
+ volume=1;
653
+ playOnAwake=false;
654
+ audioSource=(() => new t)();
655
+ onEnable() {
656
+ super.onEnable();
657
+ this.clip && (this.audioSource.clip = this.clip);
658
+ this.audioSource.loop = this.loop;
659
+ this.audioSource.volume = this.volume;
660
+ this.audioSource.playOnAwake = this.playOnAwake;
661
+ this.cat.event.on(ge.EFFECT_ON, this.onPlayEffectHandler, this).on(ge.EFFECT_OFF, this.onStopEffectHandler, this).on(ge.MUSIC_ON, this.onPlayMusicHandler, this).on(ge.MUSIC_OFF, this.onStopMusicHandler, this);
662
+ }
663
+ __preload() {
664
+ super.__preload();
665
+ const {volumeEffect: e, volumeMusic: t} = this.cat.audio;
666
+ this.audioSource.volume = this.type === Se.BGM ? t : e;
667
+ }
668
+ start() {}
669
+ stopAudio() {
670
+ this.audioSource.stop();
671
+ }
672
+ playAudio() {
673
+ const {switchEffect: e, switchMusic: t} = this.cat.audio;
674
+ if (!this.audioSource.playing && (this.type === Se.BGM ? t : e) && !y._paused) this.audioSource.play();
675
+ }
676
+ onPlayEffectHandler() {}
677
+ onStopEffectHandler() {
678
+ this.stopAudio();
679
+ }
680
+ onPlayMusicHandler() {}
681
+ onStopMusicHandler() {
682
+ this.stopAudio();
683
+ }
684
+ _onPreDestroy() {
685
+ this.onStopMusicHandler();
686
+ super._onPreDestroy();
687
+ }
688
+ }
689
+
690
+ ye([ Ee({
691
+ tooltip: `类型:\n EFFECT 音效\n BGM 音乐`,
692
+ type: g(Se)
693
+ }), ve("design:type", Number) ], AudioSourceBaseComponent.prototype, "type", void 0);
694
+
695
+ ye([ Ee({
696
+ tooltip: "音源",
697
+ type: s
698
+ }), ve("design:type", s) ], AudioSourceBaseComponent.prototype, "clip", void 0);
699
+
700
+ ye([ Ee({
701
+ tooltip: "循环"
702
+ }), ve("design:type", Boolean) ], AudioSourceBaseComponent.prototype, "loop", void 0);
703
+
704
+ ye([ Ee({
705
+ tooltip: "音量"
706
+ }), ve("design:type", Number) ], AudioSourceBaseComponent.prototype, "volume", void 0);
707
+
708
+ ye([ Ee({
709
+ tooltip: "是否启用自动播放"
710
+ }), ve("design:type", Boolean) ], AudioSourceBaseComponent.prototype, "playOnAwake", void 0);
711
+
712
+ const {ccclass: we, property: Ae} = i;
713
+
714
+ class AudioSourceUILayer extends UILayer {
715
+ type=(() => Se.EFFECT)();
716
+ clip=null;
717
+ loop=false;
718
+ volume=1;
719
+ playOnAwake=false;
720
+ audioSource=(() => new t)();
721
+ onEnable() {
722
+ super.onEnable();
723
+ this.cat.event.on(ge.EFFECT_ON, this.onPlayEffectHandler, this).on(ge.EFFECT_OFF, this.onStopEffectHandler, this).on(ge.MUSIC_ON, this.onPlayMusicHandler, this).on(ge.MUSIC_OFF, this.onStopMusicHandler, this);
724
+ }
725
+ __preload() {
726
+ this.clip && (this.audioSource.clip = this.clip);
727
+ this.audioSource.loop = this.loop;
728
+ this.audioSource.volume = this.volume;
729
+ this.audioSource.playOnAwake = this.playOnAwake;
730
+ super.__preload();
731
+ const {volumeEffect: e, volumeMusic: t} = this.cat.audio;
732
+ this.audioSource.volume = this.type === Se.BGM ? t : e;
733
+ }
734
+ stopAudio() {
735
+ this.audioSource.stop();
736
+ }
737
+ playAudio() {
738
+ const {switchEffect: e, switchMusic: t} = this.cat.audio;
739
+ if (!this.audioSource.playing && (this.type === Se.BGM ? t : e) && !y._paused) this.audioSource.play();
740
+ }
741
+ onPlayEffectHandler() {}
742
+ onStopEffectHandler() {
743
+ this.stopAudio();
744
+ }
745
+ onPlayMusicHandler() {}
746
+ onStopMusicHandler() {
747
+ this.stopAudio();
748
+ }
749
+ _onPreDestroy() {
750
+ this.onStopMusicHandler();
751
+ super._onPreDestroy();
752
+ }
753
+ }
754
+
755
+ ye([ Ae({
756
+ tooltip: `类型:\n EFFECT 音效\n BGM 音乐`,
757
+ type: g(Se)
758
+ }), ve("design:type", Number) ], AudioSourceUILayer.prototype, "type", void 0);
759
+
760
+ ye([ Ae({
761
+ tooltip: "音源",
762
+ type: s
763
+ }), ve("design:type", s) ], AudioSourceUILayer.prototype, "clip", void 0);
764
+
765
+ ye([ Ae({
766
+ tooltip: "循环"
767
+ }), ve("design:type", Boolean) ], AudioSourceUILayer.prototype, "loop", void 0);
768
+
769
+ ye([ Ae({
770
+ tooltip: "音量"
771
+ }), ve("design:type", Number) ], AudioSourceUILayer.prototype, "volume", void 0);
772
+
773
+ ye([ Ae({
774
+ tooltip: "是否启用自动播放"
775
+ }), ve("design:type", Boolean) ], AudioSourceUILayer.prototype, "playOnAwake", void 0);
776
+
777
+ const {ccclass: Ie, property: Te, menu: ke} = i;
778
+
779
+ var Oe;
780
+
781
+ (function(e) {
782
+ e[e["FIXED"] = 0] = "FIXED";
783
+ e[e["SLIDE"] = 1] = "SLIDE";
784
+ })(Oe || (Oe = {}));
785
+
786
+ let Me = class CoreToast extends BaseComponent {
787
+ fixed_node;
788
+ slide_node;
789
+ fixed_label;
790
+ slide_label;
791
+ onLoad() {
792
+ this.fixed_node.active = this.slide_node.active = false;
793
+ }
794
+ start() {
795
+ this.show();
796
+ }
797
+ async show() {
798
+ return new x(async (e, t) => {
799
+ const {title: i, type: s, fixed_time: n} = this.props;
800
+ if (s == Oe.FIXED) {
801
+ this.fixed_node.active = true;
802
+ this.fixed_label.string = `${i}`;
803
+ this.scheduleOnce(() => {
804
+ this.node.destroy();
805
+ e();
806
+ }, n);
807
+ } else {
808
+ this.slide_node.active = true;
809
+ this.slide_label.string = `${i}`;
810
+ this.playAnim(this.node).then(() => {
811
+ e();
812
+ });
813
+ }
814
+ });
815
+ }
816
+ playAnim(e) {
817
+ return new x((t, i) => {
818
+ const s = 1.2;
819
+ const n = .5;
820
+ const o = this.node.getComponent(b);
821
+ const r = _(o).delay(s).to(n, {
822
+ opacity: 0
823
+ }).call(() => {
824
+ C.stopAllByTarget(e);
825
+ this.node.destroy();
826
+ t();
827
+ });
828
+ _(e).by(n, {
829
+ position: m(0, 400, 0)
830
+ }).call(() => {
831
+ r.start();
832
+ }).start();
833
+ });
834
+ }
835
+ onDestroy() {
836
+ C.stopAllByTarget(this.node);
837
+ this.unscheduleAllCallbacks();
838
+ }
839
+ };
840
+
841
+ ye([ Te({
842
+ type: o,
843
+ tooltip: "固定节点"
844
+ }), ve("design:type", o) ], Me.prototype, "fixed_node", void 0);
845
+
846
+ ye([ Te({
847
+ type: o,
848
+ tooltip: "滑动节点"
849
+ }), ve("design:type", o) ], Me.prototype, "slide_node", void 0);
850
+
851
+ ye([ Te({
852
+ type: v,
853
+ tooltip: "固定标签节点"
854
+ }), ve("design:type", v) ], Me.prototype, "fixed_label", void 0);
855
+
856
+ ye([ Te({
857
+ type: v,
858
+ tooltip: "滑动标签节点"
859
+ }), ve("design:type", v) ], Me.prototype, "slide_label", void 0);
860
+
861
+ Me = ye([ Ie("CoreToast"), ke("CATCORE/CoreToast") ], Me);
862
+
863
+ var Re;
864
+
865
+ (function(e) {
866
+ e["EVENT_SHOW"] = "GlobalEventConstant/EVENT_SHOW";
867
+ e["EVENT_HIDE"] = "GlobalEventConstant/EVENT_HIDE";
868
+ e["GAME_RESIZE"] = "GlobalEventConstant/GAME_RESIZE";
869
+ e["EVENT_CLOSE"] = "GlobalEventConstant/EVENT_CLOSE";
870
+ e["ONLINE"] = "GlobalEventConstant/ONLINE";
871
+ e["OFFLINE"] = "GlobalEventConstant/OFFLINE";
872
+ e["ROOT_MASK_UPDATE"] = "GlobalEventConstant/ROOT_MASK_UPDATE";
873
+ e["ROOT_MASK_CHANGE"] = "GlobalEventConstant/ROOT_MASK_CHANGE";
874
+ })(Re || (Re = {}));
875
+
876
+ const {ccclass: Ue, property: Ne, menu: De} = i;
877
+
878
+ let Le = class CoreBlackMask extends BaseComponent {
879
+ tween;
880
+ };
881
+
882
+ ye([ Ne({
883
+ type: o,
884
+ tooltip: "动画节点"
885
+ }), ve("design:type", o) ], Le.prototype, "tween", void 0);
886
+
887
+ Le = ye([ Ue("CoreBlackMask"), De("CATCORE/CoreBlackMask") ], Le);
888
+
889
+ const {ccclass: Fe, property: xe, menu: Be} = i;
890
+
891
+ let Pe = class CoreUIContainer extends UILayer {
892
+ scene_mask_node;
893
+ ui_container;
894
+ gui=null;
895
+ onLoad() {
896
+ this.setSceneMaskActive(false);
897
+ }
898
+ get scene_mask() {
899
+ return this.scene_mask_node.getComponent(Le);
900
+ }
901
+ get brother() {
902
+ return this.ui_container.children || [];
903
+ }
904
+ get tweenChildren() {
905
+ return this.scene_mask.tween.children;
906
+ }
907
+ onEventListener() {
908
+ this.cat.event.on(Re.ROOT_MASK_CHANGE, this.uiMaskChanged, this);
909
+ }
910
+ addMask() {
911
+ const e = this.brother[this.brother.length - 1];
912
+ e && this.scene_mask.node.setSiblingIndex(e.getSiblingIndex());
913
+ this.blockMaskSiblingIndexChanged();
914
+ }
915
+ subMask() {
916
+ const e = this.brother[this.brother.length - 2];
917
+ e && this.scene_mask.node.setSiblingIndex(e.getSiblingIndex());
918
+ this.blockMaskSiblingIndexChanged();
919
+ }
920
+ blockMaskSiblingIndexChanged() {
921
+ this.tweenChildren.length > 1 || this.brother.length > 1 ? this.show() : this.hide();
922
+ }
923
+ addNodeToTween(e) {
924
+ if (u(this) && this.scene_mask) {
925
+ this.scene_mask.tween.addChild(e);
926
+ }
927
+ return this;
928
+ }
929
+ show() {
930
+ this.setSceneMaskActive(true);
931
+ }
932
+ hide() {
933
+ this.setSceneMaskActive(false);
934
+ }
935
+ setGui(e) {
936
+ this.gui = e;
937
+ return this;
938
+ }
939
+ uiMaskChanged() {
940
+ this.blockMaskSiblingIndexChanged();
941
+ }
942
+ setSceneMaskActive(e) {
943
+ this.scene_mask.node.active = e;
944
+ }
945
+ };
946
+
947
+ ye([ xe({
948
+ type: o
949
+ }), ve("design:type", o) ], Pe.prototype, "scene_mask_node", void 0);
950
+
951
+ ye([ xe({
952
+ type: o
953
+ }), ve("design:type", o) ], Pe.prototype, "ui_container", void 0);
954
+
955
+ Pe = ye([ Fe("CoreUIContainer"), Be("CATCORE/CoreUIContainer") ], Pe);
956
+
957
+ class RootUILayer extends UILayer {
958
+ onEnable() {
959
+ super.onEnable();
960
+ this.updateMask();
961
+ }
962
+ onDisable() {
963
+ super.onDisable();
964
+ this.updateMask();
965
+ }
966
+ updateMask() {
967
+ this.cat.event.emit(Re.ROOT_MASK_UPDATE);
968
+ }
969
+ }
970
+
971
+ const {ccclass: Ge, property: je, menu: He} = i;
972
+
973
+ let $e = class CoreShowLoading extends RootUILayer {
974
+ title;
975
+ loadingTween;
976
+ loading_rotate=0;
977
+ onAutoObserver() {
978
+ this.addAutorun([ () => {
979
+ if (this.props?.title) {
980
+ this.title.string = `${this.props?.title}`;
981
+ }
982
+ this.title.node.active = !!this.props?.title?.length;
983
+ }, () => {
984
+ this.getComponent(E).enabled = !!this.props?.mask;
985
+ } ]);
986
+ }
987
+ update(e) {
988
+ this.loading_rotate += e * 220;
989
+ this.loadingTween.setRotationFromEuler(0, 0, -this.loading_rotate % 360);
990
+ if (this.loading_rotate > 360) {
991
+ this.loading_rotate -= 360;
992
+ }
993
+ }
994
+ };
995
+
996
+ ye([ je({
997
+ type: v,
998
+ tooltip: "标题"
999
+ }), ve("design:type", v) ], $e.prototype, "title", void 0);
1000
+
1001
+ ye([ je({
1002
+ type: o,
1003
+ tooltip: "动画"
1004
+ }), ve("design:type", o) ], $e.prototype, "loadingTween", void 0);
1005
+
1006
+ $e = ye([ Ge("CoreShowLoading"), He("CATCORE/CoreShowLoading") ], $e);
1007
+
1008
+ var Ke;
1009
+
1010
+ (function(e) {
1011
+ e["RECONNECTED"] = "重连成功";
1012
+ e["RECONNECTING"] = "正在重连";
1013
+ e["MAX_RECONNECT"] = "重连次数超出限制,请检查网络";
1014
+ e["RECONNECTED_ERROR"] = "重连失败,请检查网络";
1015
+ e["CONNECT_PARAM_ERROR"] = "游戏参数错误,请重新加载";
1016
+ e["KICK"] = "账号已下线";
1017
+ e["OFFLINE"] = "网络已断开";
1018
+ e["ONLINE"] = "网络已连接";
1019
+ e["GAME_ERROR"] = "连接游戏服错误";
1020
+ })(Ke || (Ke = {}));
1021
+
1022
+ const {ccclass: We, property: Ve, menu: ze} = i;
1023
+
1024
+ let qe = class CoreReconnection extends RootUILayer {
1025
+ common_prompt_text;
1026
+ btn_confirm;
1027
+ btn_close;
1028
+ is_close=false;
1029
+ props={
1030
+ content: null
1031
+ };
1032
+ initUI() {}
1033
+ onLoad() {
1034
+ this.btn_confirm.node.on(S.EventType.CLICK, this.onConfirmHandler, this);
1035
+ this.btn_close.node.on(S.EventType.CLICK, this.onConfirmHandler, this);
1036
+ this.addAutorun([ () => {
1037
+ this.common_prompt_text.string = this.props.content ?? "";
1038
+ } ]);
1039
+ }
1040
+ onDestroy() {
1041
+ this.unscheduleAllCallbacks();
1042
+ }
1043
+ updateProps(e) {
1044
+ this.updatePromptText(e, e == Ke.RECONNECTING);
1045
+ }
1046
+ updatePromptText(e) {
1047
+ let t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1048
+ this.unscheduleAllCallbacks();
1049
+ this.props.content = e;
1050
+ a("更新提示文案:", e);
1051
+ if (t) {
1052
+ let t = 0;
1053
+ const i = () => {
1054
+ t = (t + 1) % 4;
1055
+ this.common_prompt_text.string = e + [ "", "·", "··", "···" ][t];
1056
+ };
1057
+ this.schedule(i, .5);
1058
+ }
1059
+ }
1060
+ onConfirmHandler() {
1061
+ this.is_close = true;
1062
+ this.cat.gui.hideReconnect();
1063
+ }
1064
+ };
1065
+
1066
+ ye([ Ve({
1067
+ type: v,
1068
+ tooltip: "通用提示文本"
1069
+ }), ve("design:type", v) ], qe.prototype, "common_prompt_text", void 0);
1070
+
1071
+ ye([ Ve({
1072
+ type: S,
1073
+ tooltip: "确定按钮"
1074
+ }), ve("design:type", S) ], qe.prototype, "btn_confirm", void 0);
1075
+
1076
+ ye([ Ve({
1077
+ type: S,
1078
+ tooltip: "关闭按钮"
1079
+ }), ve("design:type", S) ], qe.prototype, "btn_close", void 0);
1080
+
1081
+ qe = ye([ We("CoreReconnection"), ze("CATCORE/CoreReconnection") ], qe);
1082
+
1083
+ const {ccclass: Qe, property: Je, menu: Xe} = i;
1084
+
1085
+ let Ze = class CoreNotice extends RootUILayer {
1086
+ text;
1087
+ btn_confirm;
1088
+ btn_close;
1089
+ onLoad() {
1090
+ this.btn_confirm.node.on(S.EventType.CLICK, this.onConfrimHandler, this);
1091
+ }
1092
+ start() {
1093
+ this.props && this.updateProps(this.props);
1094
+ }
1095
+ onConfrimHandler() {
1096
+ this.props?.confrim?.();
1097
+ this.cat.gui.hideNotice();
1098
+ }
1099
+ updateProps(e) {
1100
+ this.text.string = `${e.text}`;
1101
+ }
1102
+ };
1103
+
1104
+ ye([ Je({
1105
+ type: v,
1106
+ tooltip: "提示文本"
1107
+ }), ve("design:type", v) ], Ze.prototype, "text", void 0);
1108
+
1109
+ ye([ Je({
1110
+ type: S,
1111
+ tooltip: "确定按钮"
1112
+ }), ve("design:type", S) ], Ze.prototype, "btn_confirm", void 0);
1113
+
1114
+ ye([ Je({
1115
+ type: S,
1116
+ tooltip: "关闭按钮"
1117
+ }), ve("design:type", S) ], Ze.prototype, "btn_close", void 0);
1118
+
1119
+ Ze = ye([ Qe("CoreNotice"), Xe("CATCORE/CoreNotice") ], Ze);
1120
+
1121
+ class SceneLayer extends BaseComponent {
1122
+ isReload;
1123
+ }
1124
+
1125
+ const {ccclass: Ye, property: et, menu: tt} = i;
1126
+
1127
+ var it;
1128
+
1129
+ (function(e) {
1130
+ e[e["UI"] = 0] = "UI";
1131
+ e[e["LOADING"] = 1] = "LOADING";
1132
+ e[e["TOAST"] = 2] = "TOAST";
1133
+ e[e["RECONNECTTION"] = 3] = "RECONNECTTION";
1134
+ e[e["NOTICE"] = 4] = "NOTICE";
1135
+ })(it || (it = {}));
1136
+
1137
+ let st = class Gui extends BaseComponent {
1138
+ reconnection_ui_prefab;
1139
+ toast_ui_prefab;
1140
+ loading_ui_prefab;
1141
+ notice_ui_prefab;
1142
+ ui_prefab;
1143
+ root_ui;
1144
+ root_toast;
1145
+ root_mask;
1146
+ ui_container_component;
1147
+ reconnection_ui_component;
1148
+ notice_ui_component;
1149
+ loading_ui_component;
1150
+ toast_ui_component;
1151
+ currentScene;
1152
+ currentSceneUUID;
1153
+ onEventListener() {
1154
+ this.cat.event.on(Re.ROOT_MASK_UPDATE, this.onRootUpdate, this);
1155
+ }
1156
+ init(e) {
1157
+ this.cat = e;
1158
+ const t = r.getScene();
1159
+ a("init scene");
1160
+ t && this.changeScene(t);
1161
+ return this;
1162
+ }
1163
+ start() {
1164
+ this.onRootUpdate();
1165
+ }
1166
+ toastQueue=[];
1167
+ isScheduling=false;
1168
+ minInterval=.2;
1169
+ showToast(e) {
1170
+ this.toastQueue.push(e);
1171
+ if (!this.isScheduling) {
1172
+ this.processQueueWithInterval();
1173
+ }
1174
+ }
1175
+ processQueueWithInterval() {
1176
+ if (this.toastQueue.length === 0) {
1177
+ this.isScheduling = false;
1178
+ return;
1179
+ }
1180
+ this.isScheduling = true;
1181
+ const e = this.toastQueue.shift();
1182
+ const t = () => {
1183
+ const t = h(this.toast_ui_prefab);
1184
+ const i = t.getComponent(Me);
1185
+ i.addToParent(this.root_toast, {
1186
+ props: e
1187
+ });
1188
+ this.scheduleOnce(() => {
1189
+ this.processQueueWithInterval();
1190
+ }, this.minInterval);
1191
+ };
1192
+ if (this.root_toast.children.length === 0) {
1193
+ t();
1194
+ } else {
1195
+ this.scheduleOnce(t, this.minInterval);
1196
+ }
1197
+ }
1198
+ hideToast() {
1199
+ if (this.root_toast) {
1200
+ var e;
1201
+ H(e = this.root_toast.children).call(e, e => {
1202
+ e.getComponent(Me)?.removeAndDestroy();
1203
+ });
1204
+ }
1205
+ this.toastQueue = [];
1206
+ this.unschedule(this.processQueueWithInterval);
1207
+ this.isScheduling = false;
1208
+ return this;
1209
+ }
1210
+ showLoading() {
1211
+ let {title: e = "", mask: t = true, black: i = true} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1212
+ a("showLoading", e);
1213
+ if (this.loading_ui_component) {
1214
+ this.loading_ui_component.setOptions({
1215
+ props: {
1216
+ title: e,
1217
+ mask: t,
1218
+ black: i
1219
+ }
1220
+ });
1221
+ } else {
1222
+ const s = h(this.loading_ui_prefab);
1223
+ this.loading_ui_component = s.getComponent($e).addToParent(this.root_ui, {
1224
+ props: {
1225
+ title: e,
1226
+ mask: t,
1227
+ black: i
1228
+ }
1229
+ });
1230
+ }
1231
+ return this;
1232
+ }
1233
+ hideLoading() {
1234
+ this.loading_ui_component?.removeAndDestroy();
1235
+ this.loading_ui_component = null;
1236
+ return this;
1237
+ }
1238
+ showReconnect(e) {
1239
+ if (!this.reconnection_ui_component) {
1240
+ const t = h(this.reconnection_ui_prefab);
1241
+ this.reconnection_ui_component = t.getComponent(qe).addToParent(this.root_ui, {
1242
+ props: {
1243
+ content: e
1244
+ }
1245
+ });
1246
+ } else {
1247
+ this.reconnection_ui_component.setUpdateProps({
1248
+ content: e
1249
+ });
1250
+ }
1251
+ return this;
1252
+ }
1253
+ hideReconnect() {
1254
+ this.reconnection_ui_component?.removeAndDestroy();
1255
+ this.reconnection_ui_component = null;
1256
+ return this;
1257
+ }
1258
+ showNotice(e) {
1259
+ const t = h(this.notice_ui_prefab);
1260
+ this.notice_ui_component = t.getComponent(Ze).addToParent(this.root_ui, {
1261
+ props: e
1262
+ });
1263
+ return this;
1264
+ }
1265
+ hideNotice() {
1266
+ this.notice_ui_component?.removeAndDestroy();
1267
+ return this;
1268
+ }
1269
+ loadScene(e, t, i) {
1270
+ a("[加载场景名][参数][重新加载]", e, t, i);
1271
+ let s = {};
1272
+ let o = i ?? true;
1273
+ if (typeof t === "boolean") {
1274
+ o = t;
1275
+ } else {
1276
+ s = t ?? {};
1277
+ }
1278
+ r.once(w.EVENT_BEFORE_SCENE_LAUNCH, e => {
1279
+ a("Director.EVENT_BEFORE_SCENE_LAUNCH", e);
1280
+ this.changeScene(e, s, o);
1281
+ });
1282
+ if (typeof e === "string") {
1283
+ var l;
1284
+ const t = $(l = A.bundles).call(l, e => {
1285
+ const t = e.getSceneInfo(this.currentScene);
1286
+ return t?.uuid === this.currentSceneUUID;
1287
+ });
1288
+ if (t && t.name !== "main") {
1289
+ t.loadScene(this.currentScene, (e, t) => {
1290
+ if (e) {
1291
+ n("loadScene err", e);
1292
+ } else {
1293
+ r.runScene(t);
1294
+ }
1295
+ });
1296
+ } else {
1297
+ r.loadScene(e);
1298
+ }
1299
+ } else {
1300
+ r.runScene(e);
1301
+ }
1302
+ return this;
1303
+ }
1304
+ resetScene() {
1305
+ let e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
1306
+ e = e || this.currentScene;
1307
+ return this.loadScene(e);
1308
+ }
1309
+ cleanScene() {
1310
+ this.resetScene().hideLoading().hideNotice().hideReconnect().hideToast();
1311
+ }
1312
+ changeScene(e, t, i) {
1313
+ this.currentScene = e.name;
1314
+ this.currentSceneUUID = e.uuid;
1315
+ this.createUILayer(e);
1316
+ const s = e.getComponentInChildren(SceneLayer);
1317
+ a("给场景传递属性值=======", s);
1318
+ if (s) {
1319
+ s.isReload = i ?? true;
1320
+ }
1321
+ s?.setOptions(t);
1322
+ }
1323
+ createUILayer(e) {
1324
+ this.ui_container_component?.removeAndDestroy();
1325
+ this.ui_container_component = null;
1326
+ const t = h(this.ui_prefab);
1327
+ this.ui_container_component = t.getComponent(Pe);
1328
+ this.ui_container_component?.setGui(this).addToParent(e, this.node.getSiblingIndex());
1329
+ }
1330
+ reloadScene() {
1331
+ a("重新加载当前场景");
1332
+ this.loadScene(this.currentSceneUUID, true);
1333
+ }
1334
+ async closeUI(e, t) {
1335
+ const {component: i} = this.findUIBaseLayer(e, false);
1336
+ if (i) {
1337
+ i.setOptions({
1338
+ ...t?.hook ?? {},
1339
+ ...t?.props ?? {}
1340
+ });
1341
+ await i.hideTween(t || {});
1342
+ this.ui_container_component?.subMask();
1343
+ }
1344
+ }
1345
+ async openUI(e, t) {
1346
+ const {rootNode: i, component: s} = this.findUIBaseLayer(e, true);
1347
+ i.getComponent(UILayer);
1348
+ s?.setOptions(t);
1349
+ if (i) {
1350
+ this.ui_container_component?.addNodeToTween(i).addMask();
1351
+ }
1352
+ if (s) {
1353
+ await s.showTween(t || {});
1354
+ }
1355
+ this.ui_container_component?.ui_container && s?.addToParent(this.ui_container_component.ui_container);
1356
+ }
1357
+ findUIBaseLayer(e, t) {
1358
+ let i;
1359
+ let s = null;
1360
+ if (e instanceof o) {
1361
+ var r;
1362
+ i = e;
1363
+ const t = K(r = e.components).call(r, e => e instanceof UILayer);
1364
+ if (t.length) {
1365
+ if (t.length == 1) {
1366
+ s = t[0];
1367
+ } else {
1368
+ I(`${e.name}节点存在多个继承自BaseLayer的组件`);
1369
+ }
1370
+ } else {
1371
+ n(`${e.name}节点未找到继承自BaseLayer的组件`);
1372
+ return {
1373
+ rootNode: i,
1374
+ component: s
1375
+ };
1376
+ }
1377
+ } else {
1378
+ i = e.node;
1379
+ s = e;
1380
+ if (t) {
1381
+ while (i.parent) {
1382
+ i = i.parent;
1383
+ }
1384
+ s.root = i;
1385
+ } else {
1386
+ i = e.root;
1387
+ }
1388
+ }
1389
+ return {
1390
+ rootNode: i,
1391
+ component: s
1392
+ };
1393
+ }
1394
+ onRootUpdate() {
1395
+ const e = this.root_ui.children.findLastIndex(e => e.active && e != this.root_mask);
1396
+ this.root_mask.active = e != -1;
1397
+ if (e > -1) {
1398
+ const t = this.root_ui.children[e];
1399
+ const i = t.getSiblingIndex() - 1;
1400
+ this.root_mask.setSiblingIndex(i < 0 ? 0 : i);
1401
+ }
1402
+ this.cat.event.emit(Re.ROOT_MASK_CHANGE);
1403
+ }
1404
+ };
1405
+
1406
+ ye([ et({
1407
+ type: c,
1408
+ tooltip: "断线重连UI预制体"
1409
+ }), ve("design:type", c) ], st.prototype, "reconnection_ui_prefab", void 0);
1410
+
1411
+ ye([ et({
1412
+ type: c,
1413
+ tooltip: "提示UI预制体"
1414
+ }), ve("design:type", c) ], st.prototype, "toast_ui_prefab", void 0);
1415
+
1416
+ ye([ et({
1417
+ type: c,
1418
+ tooltip: "加载UI预制体"
1419
+ }), ve("design:type", c) ], st.prototype, "loading_ui_prefab", void 0);
1420
+
1421
+ ye([ et({
1422
+ type: c,
1423
+ tooltip: "公告UI预制体"
1424
+ }), ve("design:type", c) ], st.prototype, "notice_ui_prefab", void 0);
1425
+
1426
+ ye([ et({
1427
+ type: c,
1428
+ tooltip: "UI层预制体"
1429
+ }), ve("design:type", c) ], st.prototype, "ui_prefab", void 0);
1430
+
1431
+ ye([ et({
1432
+ type: o,
1433
+ tooltip: "root-UI层"
1434
+ }), ve("design:type", o) ], st.prototype, "root_ui", void 0);
1435
+
1436
+ ye([ et({
1437
+ type: o,
1438
+ tooltip: "root-组件层"
1439
+ }), ve("design:type", o) ], st.prototype, "root_toast", void 0);
1440
+
1441
+ ye([ et({
1442
+ type: o,
1443
+ tooltip: "root-mask"
1444
+ }), ve("design:type", o) ], st.prototype, "root_mask", void 0);
1445
+
1446
+ st = ye([ Ye("Gui"), tt("CATCORE/Gui") ], st);
1447
+
1448
+ var nt;
1449
+
1450
+ (function(e) {
1451
+ e["Root"] = "prefabs/root";
1452
+ e["Toast"] = "prefabs/toast";
1453
+ e["BlackMask"] = "prefabs/black-mask";
1454
+ e["Loading"] = "prefabs/loading";
1455
+ e["Notice"] = "prefabs/notice";
1456
+ e["Reconnection"] = "prefabs/reconnection";
1457
+ })(nt || (nt = {}));
1458
+
1459
+ class GuiManager extends BaseManager {
1460
+ gui;
1461
+ #e="core";
1462
+ getGuiPrefabByType=(e, t) => new x((i, s) => {
1463
+ a(e, `${t}`);
1464
+ this.cat.res.load(e, t, (e, t) => {
1465
+ if (e) {
1466
+ s(e);
1467
+ } else {
1468
+ i(t);
1469
+ }
1470
+ });
1471
+ });
1472
+ async init() {
1473
+ this.cat.gui_bundle_name && (this.#e = this.cat.gui_bundle_name);
1474
+ const e = await this.getGuiPrefabByType(this.#e, nt.Root);
1475
+ const t = h(e);
1476
+ this.gui = t.getComponent(st).init(this.cat);
1477
+ r.addPersistRootNode(t);
1478
+ return this;
1479
+ }
1480
+ }
1481
+
1482
+ class WrapperSocialGameClient extends re {
1483
+ showRequestErrInfo=false;
1484
+ logBlackList=[];
1485
+ ignore=e => {
1486
+ var t;
1487
+ return P(t = this.logBlackList).call(t, e);
1488
+ };
1489
+ constructor(e, t, i, s) {
1490
+ super(t, i, s, e);
1491
+ this.showRequestErrInfo = s?.showRequestErrInfo ?? false;
1492
+ }
1493
+ destroy() {
1494
+ this.disconnect(true);
1495
+ e._cat.socialGameClient.unregister(this);
1496
+ }
1497
+ async GameRequest(t, i, s) {
1498
+ let {forwardReq: o = false, forwardResp: r = false} = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1499
+ return new x((l, c) => {
1500
+ super.GameRequest(t, i, s, {
1501
+ forwardReq: o,
1502
+ forwardResp: r
1503
+ }).then(e => {
1504
+ if (se) {
1505
+ a(`%c ws服务端消息 %c [Response][${new Date}] %c ${t} %c`, "background:#ff00ff ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff", "background:#3d7daa ; padding: 1px; color: #fff", "background:#ff00ff ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff", "background:transparent", i);
1506
+ }
1507
+ l(e);
1508
+ }, t => {
1509
+ n(t);
1510
+ this.showRequestErrInfo && t?.msg && e._cat.gui.showToast({
1511
+ title: t.msg
1512
+ });
1513
+ c(t);
1514
+ });
1515
+ });
1516
+ }
1517
+ subscribe(t, i, s) {
1518
+ super.subscribe(t, i, i => {
1519
+ if (se && !this.ignore(t)) {
1520
+ a(`%c ws服务端消息:[subscribe][${new Date}] %c ${t} %c`, "background:#35495e ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff", "background:#410083 ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff", "background:transparent", i);
1521
+ }
1522
+ e._cat.event.emit(t, i);
1523
+ s?.(i);
1524
+ });
1525
+ return this;
1526
+ }
1527
+ }
1528
+
1529
+ class SocialGameClientManager extends BaseManager {
1530
+ managedClients=(() => new j)();
1531
+ isGlobalOnline=true;
1532
+ isInBackground=false;
1533
+ reconnecting=false;
1534
+ onEventHideDelegate=(() => new T)();
1535
+ onEventShowDelegate=(() => new T)();
1536
+ onEventReloadSceneDelegate=(() => new T)();
1537
+ reconnectTimer=null;
1538
+ scheduleReconnect() {
1539
+ let e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 2e3;
1540
+ if (this.reconnectTimer) {
1541
+ clearTimeout(this.reconnectTimer);
1542
+ this.reconnectTimer = null;
1543
+ }
1544
+ this.reconnectTimer = Z(() => {
1545
+ this.reconnectTimer = null;
1546
+ this.triggerReconnectAll();
1547
+ }, e);
1548
+ }
1549
+ get activeClients() {
1550
+ var e, t;
1551
+ return K(e = Y(t = ee(this.managedClients)).call(t, e => {
1552
+ let [t, i] = e;
1553
+ return i;
1554
+ })).call(e, e => e.socket);
1555
+ }
1556
+ constructor(e) {
1557
+ super(e);
1558
+ this.initGlobalListeners();
1559
+ }
1560
+ createWebSocket(e, t, i, s) {
1561
+ if (this.managedClients.has(e)) {
1562
+ const t = this.managedClients.get(e);
1563
+ t.destroy();
1564
+ a(`清理旧的 ${e} 客户端`);
1565
+ }
1566
+ const n = new WrapperSocialGameClient(e, i, s, F({
1567
+ reconnectMaxAttempts: Infinity
1568
+ }, {
1569
+ ...t,
1570
+ isAutoConnect: false,
1571
+ isArrayBuffer: ne
1572
+ }));
1573
+ this.register(n);
1574
+ return n;
1575
+ }
1576
+ register(e) {
1577
+ e.on("reconnected", this.handleSingleReconnect);
1578
+ e.on("close", this.handleSingleClose);
1579
+ e.on("kick", this.handleSingleKick);
1580
+ this.managedClients.set(e.name, e);
1581
+ }
1582
+ unregister(e) {
1583
+ e.off("reconnected", this.handleSingleReconnect);
1584
+ e.off("close", this.handleSingleClose);
1585
+ e.off("kick", this.handleSingleKick);
1586
+ this.managedClients.delete(e.name);
1587
+ }
1588
+ initGlobalListeners() {
1589
+ this.cat.event.on(Re.ONLINE, () => this.handleGlobalStateChange("online"), this).on(Re.OFFLINE, () => this.handleGlobalStateChange("offline"), this);
1590
+ y.on(k.EVENT_SHOW, () => this.handleGlobalStateChange("show"));
1591
+ y.on(k.EVENT_HIDE, () => this.handleGlobalStateChange("hide"));
1592
+ }
1593
+ async handleGlobalStateChange(e) {
1594
+ switch (e) {
1595
+ case "online":
1596
+ this.cat.gui.hideLoading().showToast({
1597
+ title: Ke.ONLINE
1598
+ });
1599
+ this.isGlobalOnline = true;
1600
+ this.triggerReconnectAll();
1601
+ break;
1602
+
1603
+ case "offline":
1604
+ this.isGlobalOnline = false;
1605
+ this.disconnectAll(true);
1606
+ this.cat.gui.showLoading({
1607
+ title: Ke.OFFLINE
1608
+ });
1609
+ break;
1610
+
1611
+ case "show":
1612
+ this.isInBackground = false;
1613
+ await this.triggerReconnectAll();
1614
+ await this.onEventShowDelegate.dispatch();
1615
+ break;
1616
+
1617
+ case "hide":
1618
+ await this.onEventHideDelegate.dispatch();
1619
+ this.isInBackground = true;
1620
+ this.disconnectAll(true);
1621
+ break;
1622
+ }
1623
+ }
1624
+ async triggerReconnectAll() {
1625
+ a("触发所有客户端重连[正在重连][在线][后台][ws数量]", this.reconnecting, this.isGlobalOnline, this.isInBackground, this.managedClients.size);
1626
+ if (this.reconnecting || !this.isGlobalOnline || this.isInBackground || this.managedClients.size === 0) return this.onEventReloadSceneDelegate.dispatch();
1627
+ this.reconnecting = true;
1628
+ this.cat.gui.showLoading({
1629
+ title: "正在重连"
1630
+ });
1631
+ try {
1632
+ var e, t;
1633
+ await x.allSettled(Y(e = this.activeClients).call(e, async e => {
1634
+ try {
1635
+ await e.reconnectPromise();
1636
+ } catch (t) {
1637
+ n(`${e.name}服重连失败`, t);
1638
+ }
1639
+ }));
1640
+ const i = K(t = this.activeClients).call(t, e => e.socketConnectStatus !== ie.CONNECTED);
1641
+ if (i.length > 0) {
1642
+ console.error("部分WS重连失败:", Y(i).call(i, e => e));
1643
+ a("2s后重连所有客户端");
1644
+ this.reconnecting = false;
1645
+ this.scheduleReconnect();
1646
+ } else {
1647
+ this.reconnecting = false;
1648
+ }
1649
+ } catch (e) {
1650
+ this.reconnecting = false;
1651
+ throw e;
1652
+ }
1653
+ }
1654
+ disconnectAll(e) {
1655
+ var t;
1656
+ H(t = this.managedClients).call(t, t => {
1657
+ a("断开连接", t.name, e, t.socket);
1658
+ t.disconnect(e);
1659
+ });
1660
+ }
1661
+ handleSingleClose=() => {
1662
+ if (!this.reconnecting) {
1663
+ a("3s后重连所有客户端");
1664
+ this.scheduleReconnect(3e3);
1665
+ }
1666
+ };
1667
+ handleSingleReconnect=async () => {
1668
+ var e;
1669
+ if (te(e = this.activeClients).call(e, e => e.socketConnectStatus === ie.CONNECTED)) {
1670
+ var t;
1671
+ a("单个WS重连成功回调===", this.managedClients);
1672
+ await x.allSettled(Y(t = this.activeClients).call(t, async e => {
1673
+ try {
1674
+ await e.connectRequest();
1675
+ } catch (t) {
1676
+ n(`${e.name}服登录错误`, t);
1677
+ this.cat.gui.showToast({
1678
+ title: `登录${e.name}服错误`
1679
+ });
1680
+ }
1681
+ }));
1682
+ if (this.reconnectTimer) {
1683
+ clearTimeout(this.reconnectTimer);
1684
+ this.reconnectTimer = null;
1685
+ }
1686
+ await this.onEventReloadSceneDelegate.dispatch();
1687
+ this.cat.gui.hideLoading();
1688
+ if (r.getScene()?.getComponentInChildren(SceneLayer)?.isReload) this.cat.gui.reloadScene();
1689
+ }
1690
+ };
1691
+ handleSingleKick=() => {
1692
+ this.cat.gui.showReconnect(Ke.KICK);
1693
+ };
1694
+ }
1695
+
1696
+ class ResLoader {
1697
+ get=(() => function(e, t) {
1698
+ let i = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "resources";
1699
+ var s = A.getBundle(i);
1700
+ return s.get(e, t);
1701
+ })();
1702
+ isAssetType=e => typeof e === "function" && e.prototype instanceof O;
1703
+ async load() {
1704
+ let e = null;
1705
+ let t = null;
1706
+ let i = null;
1707
+ for (var s = arguments.length, n = new Array(s), o = 0; o < s; o++) {
1708
+ n[o] = arguments[o];
1709
+ }
1710
+ if (typeof n[0] === "string" && typeof n[1] === "string") {
1711
+ e = n.shift();
1712
+ }
1713
+ let r = n.shift();
1714
+ if (this.isAssetType(n[0])) {
1715
+ t = n.shift();
1716
+ }
1717
+ if (n.length == 2) {
1718
+ i = n.shift();
1719
+ }
1720
+ const a = n.shift();
1721
+ let l = M;
1722
+ if (e && e != "resources") {
1723
+ if (!A.bundles.has(e)) {
1724
+ await this.loadBundle(e);
1725
+ }
1726
+ let t = A.bundles.get(e);
1727
+ if (t) {
1728
+ l = t;
1729
+ }
1730
+ }
1731
+ if (i && a) {
1732
+ l.load(r, t, i, a);
1733
+ } else if (a) {
1734
+ l.load(r, t, a);
1735
+ } else {
1736
+ l.load(r, t);
1737
+ }
1738
+ }
1739
+ async loadDir() {
1740
+ let e = null;
1741
+ let t = null;
1742
+ let i = null;
1743
+ let s = null;
1744
+ for (var n = arguments.length, o = new Array(n), r = 0; r < n; r++) {
1745
+ o[r] = arguments[r];
1746
+ }
1747
+ if (typeof o[0] === "string" && typeof o[1] === "string") {
1748
+ e = o.shift();
1749
+ }
1750
+ let a = o.shift();
1751
+ if (this.isAssetType(o[0])) {
1752
+ t = o.shift();
1753
+ }
1754
+ if (o.length == 2) {
1755
+ i = o.shift();
1756
+ }
1757
+ s = o.shift();
1758
+ let l = M;
1759
+ if (e && e != "resources") {
1760
+ if (!A.bundles.has(e)) {
1761
+ await this.loadBundle(e);
1762
+ }
1763
+ let t = A.bundles.get(e);
1764
+ if (t) {
1765
+ l = t;
1766
+ }
1767
+ }
1768
+ if (i && s) {
1769
+ l.loadDir(a, t, i, s);
1770
+ } else if (s) {
1771
+ l.loadDir(a, t, s);
1772
+ } else {
1773
+ l.loadDir(a, t);
1774
+ }
1775
+ }
1776
+ loadRemote(e) {
1777
+ var t = null;
1778
+ var i = null;
1779
+ for (var s = arguments.length, n = new Array(s > 1 ? s - 1 : 0), o = 1; o < s; o++) {
1780
+ n[o - 1] = arguments[o];
1781
+ }
1782
+ if (n.length == 2) {
1783
+ t = n.shift();
1784
+ }
1785
+ i = n.shift();
1786
+ A.loadRemote(e, {
1787
+ ext: ".png",
1788
+ ...t
1789
+ }, i);
1790
+ }
1791
+ loadBundle=(e, t) => new x((i, s) => {
1792
+ const n = (e, t) => {
1793
+ if (e) {
1794
+ return s(e);
1795
+ }
1796
+ i(t);
1797
+ };
1798
+ t ? A.loadBundle(e, {
1799
+ version: t
1800
+ }, n) : A.loadBundle(e, n);
1801
+ });
1802
+ releasePrefabtDepsRecursively=e => {
1803
+ var t = A.assets.get(e);
1804
+ A.releaseAsset(t);
1805
+ if (t instanceof c) {
1806
+ var i = A.dependUtil.getDepsRecursively(e);
1807
+ H(i).call(i, e => {
1808
+ var t = A.assets.get(e);
1809
+ t.decRef();
1810
+ });
1811
+ }
1812
+ };
1813
+ release=(() => {
1814
+ var e = this;
1815
+ return function(t) {
1816
+ let i = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "resources";
1817
+ var s = A.getBundle(i);
1818
+ if (s) {
1819
+ var n = s.get(t);
1820
+ if (n) {
1821
+ e.releasePrefabtDepsRecursively(n._uuid);
1822
+ }
1823
+ }
1824
+ };
1825
+ })();
1826
+ releaseDir=(() => {
1827
+ var e = this;
1828
+ return function(t) {
1829
+ var i, s;
1830
+ let n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "resources";
1831
+ var o = A.getBundle(n);
1832
+ var r = o?.getDirWithPath(t);
1833
+ ((i = r) == null ? void 0 : z(s = Function.call).call(s, Y(i), i))?.(t => {
1834
+ e.releasePrefabtDepsRecursively(t.uuid);
1835
+ });
1836
+ if (!t && n != "resources" && o) {
1837
+ A.removeBundle(o);
1838
+ }
1839
+ };
1840
+ })();
1841
+ dump=() => {
1842
+ var e;
1843
+ H(e = A.assets).call(e, (e, t) => {
1844
+ a(A.assets.get(t));
1845
+ });
1846
+ a(`当前资源总数:${A.assets.count}`);
1847
+ };
1848
+ loadAssetsWithProgress(e, t) {
1849
+ return new x((i, s) => {
1850
+ const n = e.getDirWithPath("");
1851
+ const o = n.length;
1852
+ let r = 0;
1853
+ if (o === 0) {
1854
+ t(1);
1855
+ i();
1856
+ return;
1857
+ }
1858
+ H(n).call(n, n => {
1859
+ e.load(n.path, e => {
1860
+ if (e) {
1861
+ s(e);
1862
+ return;
1863
+ }
1864
+ r++;
1865
+ t(r / o);
1866
+ if (r === o) {
1867
+ i();
1868
+ }
1869
+ });
1870
+ });
1871
+ });
1872
+ }
1873
+ }
1874
+
1875
+ class BaseStore {
1876
+ rootStore;
1877
+ constructor(e) {
1878
+ this.rootStore = e;
1879
+ }
1880
+ }
1881
+
1882
+ class CoreStore extends BaseManager {}
1883
+
1884
+ let ot = null;
1885
+
1886
+ const rt = e => ae.MD5(e).toString();
1887
+
1888
+ const at = (e, t) => {
1889
+ ot = ae.enc.Hex.parse(t);
1890
+ };
1891
+
1892
+ const lt = (e, t, i) => ae.AES.encrypt(e, t, {
1893
+ iv: ot,
1894
+ format: ht
1895
+ }).toString();
1896
+
1897
+ const ct = (e, t, i) => {
1898
+ const s = ae.AES.decrypt(e, t, {
1899
+ iv: ot,
1900
+ format: ht
1901
+ });
1902
+ return s.toString(ae.enc.Utf8);
1903
+ };
1904
+
1905
+ const ht = {
1906
+ stringify: e => {
1907
+ const t = {
1908
+ ct: e.ciphertext.toString(ae.enc.Base64)
1909
+ };
1910
+ if (e.iv) {
1911
+ t.iv = e.iv.toString();
1912
+ }
1913
+ if (e.salt) {
1914
+ t.s = e.salt.toString();
1915
+ }
1916
+ return G(t);
1917
+ },
1918
+ parse: e => {
1919
+ const t = JSON.parse(e);
1920
+ const i = ae.lib.CipherParams.create({
1921
+ ciphertext: ae.enc.Base64.parse(t.ct)
1922
+ });
1923
+ if (t.iv) {
1924
+ i.iv = ae.enc.Hex.parse(t.iv);
1925
+ }
1926
+ if (t.s) {
1927
+ i.salt = ae.enc.Hex.parse(t.s);
1928
+ }
1929
+ return i;
1930
+ }
1931
+ };
1932
+
1933
+ var ut = Object.freeze({
1934
+ __proto__: null,
1935
+ JsonFormatter: ht,
1936
+ aesDecrypt: ct,
1937
+ aesEncrypt: lt,
1938
+ initCrypto: at,
1939
+ md5: rt
1940
+ });
1941
+
1942
+ class CoreUtil extends BaseManager {
1943
+ encryptUtil=(() => ut)();
1944
+ }
1945
+
1946
+ class StorageManager extends BaseManager {
1947
+ _key=null;
1948
+ _iv=null;
1949
+ _id="";
1950
+ init(e, t) {
1951
+ this.cat.util.encryptUtil.initCrypto(e, t);
1952
+ this._key = this.cat.util.encryptUtil.md5(e);
1953
+ this._iv = this.cat.util.encryptUtil.md5(t);
1954
+ }
1955
+ setUser(e) {
1956
+ this._id = e;
1957
+ }
1958
+ set(e, t) {
1959
+ e = `${e}_${this._id}`;
1960
+ if (null == e) {
1961
+ console.error("存储的key不能为空");
1962
+ return;
1963
+ }
1964
+ if (!oe) {
1965
+ e = this.cat.util.encryptUtil.md5(e);
1966
+ }
1967
+ if (null == t) {
1968
+ console.warn("存储的值为空,则直接移除该存储");
1969
+ this.remove(e);
1970
+ return;
1971
+ }
1972
+ if (typeof t === "function") {
1973
+ console.error("储存的值不能为方法");
1974
+ return;
1975
+ }
1976
+ if (typeof t === "object") {
1977
+ try {
1978
+ t = G(t);
1979
+ } catch (e) {
1980
+ console.error(`解析失败,str = ${t}`);
1981
+ return;
1982
+ }
1983
+ } else if (typeof t === "number") {
1984
+ t = t + "";
1985
+ }
1986
+ if (!oe && null != this._key && null != this._iv) {
1987
+ t = this.cat.util.encryptUtil.aesEncrypt(`${t}`, this._key, this._iv);
1988
+ }
1989
+ R.localStorage.setItem(e, t);
1990
+ }
1991
+ get(e, t) {
1992
+ if (null == e) {
1993
+ console.error("存储的key不能为空");
1994
+ return null;
1995
+ }
1996
+ e = `${e}_${this._id}`;
1997
+ if (!oe) {
1998
+ e = this.cat.util.encryptUtil.md5(e);
1999
+ }
2000
+ let i = R.localStorage.getItem(e);
2001
+ if (null != i && "" !== i && !oe && null != this._key && null != this._iv) {
2002
+ i = this.cat.util.encryptUtil.aesDecrypt(i, this._key, this._iv);
2003
+ }
2004
+ if (null === i) {
2005
+ return t;
2006
+ }
2007
+ return i;
2008
+ }
2009
+ getNumber(e) {
2010
+ let t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
2011
+ var i = this.get(e);
2012
+ return Number(i) || t;
2013
+ }
2014
+ getBoolean(e) {
2015
+ var t = this.get(e);
2016
+ return Boolean(t) || false;
2017
+ }
2018
+ getJson(e, t) {
2019
+ var i = this.get(e);
2020
+ return i && JSON.parse(i) || t;
2021
+ }
2022
+ remove(e) {
2023
+ if (null == e) {
2024
+ console.error("存储的key不能为空");
2025
+ return;
2026
+ }
2027
+ e = `${e}_${this._id}`;
2028
+ if (!oe) {
2029
+ e = this.cat.util.encryptUtil.md5(e);
2030
+ }
2031
+ R.localStorage.removeItem(e);
2032
+ }
2033
+ clear() {
2034
+ R.localStorage.clear();
2035
+ }
2036
+ }
2037
+
2038
+ class Manager {
2039
+ static #t=null;
2040
+ #i=false;
2041
+ static get instance() {
2042
+ return this.#t ?? (this.#t = new Manager);
2043
+ }
2044
+ onAppInitDelegate=(() => new T)();
2045
+ onPlugInInitDelegate=(() => new T)();
2046
+ #s=null;
2047
+ get audio() {
2048
+ return this.#s;
2049
+ }
2050
+ #n=null;
2051
+ get event() {
2052
+ return this.#n;
2053
+ }
2054
+ #o=null;
2055
+ get gui() {
2056
+ return this.#o;
2057
+ }
2058
+ #r=null;
2059
+ get storage() {
2060
+ return this.#r;
2061
+ }
2062
+ #a=null;
2063
+ get res() {
2064
+ return this.#a;
2065
+ }
2066
+ #l=null;
2067
+ get util() {
2068
+ return this.#l;
2069
+ }
2070
+ #c=null;
2071
+ get socialGameClient() {
2072
+ return this.#c;
2073
+ }
2074
+ #h=null;
2075
+ get store() {
2076
+ return this.#h;
2077
+ }
2078
+ #u="";
2079
+ get gui_bundle_name() {
2080
+ return this.#u;
2081
+ }
2082
+ #d="";
2083
+ get audio_local_store_key() {
2084
+ return this.#d;
2085
+ }
2086
+ #p="";
2087
+ get default_audio_effect() {
2088
+ return this.#p;
2089
+ }
2090
+ setConfig=(() => {
2091
+ var e = this;
2092
+ return function() {
2093
+ let {default_audio_effect: t = "", gui_bundleName: i = "resources", audio_local_store_key: s = "game_audio"} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2094
+ if (e.#i) {
2095
+ throw new Error("[CAT] 已初始化,无法修改配置");
2096
+ }
2097
+ e.#u = i;
2098
+ e.#d = s;
2099
+ e.#p = t;
2100
+ return e;
2101
+ };
2102
+ })();
2103
+ async boot() {
2104
+ if (this.#i) {
2105
+ throw new Error("[CAT] 已初始化");
2106
+ }
2107
+ try {
2108
+ this.#h = new CoreStore(this);
2109
+ this.#a = new ResLoader;
2110
+ this.#l = new CoreUtil(this);
2111
+ this.#r = new StorageManager(this);
2112
+ this.#n = new B;
2113
+ this.#s = new AudioManager(this);
2114
+ this.#c = new SocialGameClientManager(this);
2115
+ this.#o = (await new GuiManager(this).init()).gui;
2116
+ this.#i = true;
2117
+ } catch (e) {
2118
+ console.error(`[CAT] 初始化失败:`, e);
2119
+ throw e;
2120
+ }
2121
+ }
2122
+ merge(e, t) {
2123
+ if (!this.#i) throw new Error("[CAT] 未初始化");
2124
+ if (typeof e !== "string") {
2125
+ throw new Error(`merge方法第一个参数应该为string类型`);
2126
+ }
2127
+ if (!D(this, e)) {
2128
+ L(this, e, t);
2129
+ }
2130
+ F(D(this, e), t);
2131
+ return this;
2132
+ }
2133
+ appendPlugInInitDelegate(e) {
2134
+ if (this.#i) {
2135
+ x.resolve().then(e).catch(e => {
2136
+ console.error("[CAT] appendPlugInInitDelegate 回调执行失败:", e);
2137
+ });
2138
+ } else {
2139
+ this.onPlugInInitDelegate.add(e);
2140
+ }
2141
+ return this;
2142
+ }
2143
+ }
2144
+
2145
+ const {ccclass: dt, property: pt, menu: ft} = i;
2146
+
2147
+ let mt = class CoreUIModal extends UILayer {
2148
+ default_title=null;
2149
+ title;
2150
+ prompt_content_str;
2151
+ prompt_content_spriteFrame;
2152
+ btn_confirm;
2153
+ confirm_spriteFrame;
2154
+ btn_cancel;
2155
+ cancel_spriteFrame;
2156
+ btn_close;
2157
+ isConfirm=false;
2158
+ props={
2159
+ title: this.default_title,
2160
+ content: null,
2161
+ confirmCB: () => {},
2162
+ cancelCB: () => {},
2163
+ style: null
2164
+ };
2165
+ onLoad() {
2166
+ this.btn_cancel.node.on(S.EventType.CLICK, this.onCancelHandler, this);
2167
+ this.btn_confirm.node.on(S.EventType.CLICK, this.onConfirmHandler, this);
2168
+ this.btn_close.node.on(S.EventType.CLICK, this.onCloseHandler, this);
2169
+ this.addAutorun([ () => {
2170
+ this.title.spriteFrame = this.props?.title || this.default_title;
2171
+ }, () => {
2172
+ if (this.props.content) {
2173
+ if (this.props.content instanceof U) {
2174
+ this.prompt_content_spriteFrame.spriteFrame = this.props.content;
2175
+ } else if (typeof this.props.content === "string") {
2176
+ this.prompt_content_str.string = this.props.content;
2177
+ } else {
2178
+ console.error("未知类型的【UIModal】内容");
2179
+ }
2180
+ }
2181
+ }, () => {
2182
+ if (this.props?.style?.confirm === null) {
2183
+ this.btn_confirm.node.active = false;
2184
+ } else {
2185
+ this.btn_confirm.node.active = true;
2186
+ this.btn_confirm.getComponent(N).spriteFrame = this.props.style?.confirm || this.confirm_spriteFrame;
2187
+ }
2188
+ if (this.props?.style?.cancel === null) {
2189
+ this.btn_cancel.node.active = false;
2190
+ } else {
2191
+ this.btn_cancel.node.active = true;
2192
+ this.btn_cancel.getComponent(N).spriteFrame = this.props.style?.cancel || this.cancel_spriteFrame;
2193
+ }
2194
+ } ]);
2195
+ }
2196
+ close() {
2197
+ this.props.cancelCB?.();
2198
+ this.cat.gui.closeUI(this);
2199
+ }
2200
+ onCancelHandler() {
2201
+ this.close();
2202
+ }
2203
+ onConfirmHandler() {
2204
+ this.props.confirmCB?.();
2205
+ }
2206
+ onDestroy() {
2207
+ if (this.isConfirm) this.props.onDestroy?.();
2208
+ }
2209
+ onCloseHandler() {
2210
+ this.close();
2211
+ }
2212
+ };
2213
+
2214
+ ye([ pt({
2215
+ type: U,
2216
+ tooltip: "默认标题"
2217
+ }), ve("design:type", U) ], mt.prototype, "default_title", void 0);
2218
+
2219
+ ye([ pt({
2220
+ type: N,
2221
+ tooltip: "标题节点"
2222
+ }), ve("design:type", N) ], mt.prototype, "title", void 0);
2223
+
2224
+ ye([ pt({
2225
+ type: v,
2226
+ tooltip: "字符串内容按钮"
2227
+ }), ve("design:type", v) ], mt.prototype, "prompt_content_str", void 0);
2228
+
2229
+ ye([ pt({
2230
+ type: N,
2231
+ tooltip: "图片精灵内容按钮"
2232
+ }), ve("design:type", N) ], mt.prototype, "prompt_content_spriteFrame", void 0);
2233
+
2234
+ ye([ pt({
2235
+ type: S,
2236
+ tooltip: "确认按钮"
2237
+ }), ve("design:type", S) ], mt.prototype, "btn_confirm", void 0);
2238
+
2239
+ ye([ pt({
2240
+ type: U,
2241
+ tooltip: "确认按钮精灵图"
2242
+ }), ve("design:type", U) ], mt.prototype, "confirm_spriteFrame", void 0);
2243
+
2244
+ ye([ pt({
2245
+ type: S,
2246
+ tooltip: "取消按钮"
2247
+ }), ve("design:type", S) ], mt.prototype, "btn_cancel", void 0);
2248
+
2249
+ ye([ pt({
2250
+ type: U,
2251
+ tooltip: "取消按钮精灵图"
2252
+ }), ve("design:type", U) ], mt.prototype, "cancel_spriteFrame", void 0);
2253
+
2254
+ ye([ pt({
2255
+ type: S,
2256
+ tooltip: "关闭按钮"
2257
+ }), ve("design:type", S) ], mt.prototype, "btn_close", void 0);
2258
+
2259
+ mt = ye([ dt("CoreUIModal"), ft("CATCORE/CoreUIModal") ], mt);
2260
+
2261
+ var _t;
2262
+
2263
+ (function(e) {
2264
+ e[e["Delay"] = 0] = "Delay";
2265
+ e[e["Interval"] = 1] = "Interval";
2266
+ })(_t || (_t = {}));
2267
+
2268
+ class TimerEntry {
2269
+ tag;
2270
+ type;
2271
+ callback;
2272
+ remainingTime;
2273
+ executionTime=0;
2274
+ initialTime;
2275
+ constructor(e, t, i, s) {
2276
+ this.tag = e;
2277
+ this.type = t;
2278
+ this.remainingTime = i;
2279
+ this.initialTime = i;
2280
+ this.callback = s;
2281
+ }
2282
+ }
2283
+
2284
+ class TimerManager extends BaseManager {
2285
+ timers=(() => new j)();
2286
+ lastUpdateTime=(() => le())();
2287
+ constructor(e) {
2288
+ var t;
2289
+ super(e);
2290
+ e.event.on(Re.EVENT_HIDE, this.onHandleAppBackground, this);
2291
+ e.event.on(Re.EVENT_SHOW, this.onHandleAppForeground, this);
2292
+ ce(z(t = this.update).call(t, this), 1e3);
2293
+ }
2294
+ onHandleAppBackground() {
2295
+ this.lastUpdateTime = le();
2296
+ }
2297
+ onHandleAppForeground() {
2298
+ const e = le();
2299
+ const t = e - this.lastUpdateTime;
2300
+ a("elapsedTime", t);
2301
+ for (const e of he(i = this.timers).call(i)) {
2302
+ var i;
2303
+ if (e.remainingTime > 0) {
2304
+ e.remainingTime -= t;
2305
+ e.executionTime += t;
2306
+ }
2307
+ }
2308
+ this.lastUpdateTime = e;
2309
+ }
2310
+ registerInterval(e, t, i) {
2311
+ if (this.has(e)) {
2312
+ return n(`${e}定时器已存在,请勿重复注册`);
2313
+ }
2314
+ const s = new TimerEntry(e, _t.Interval, t, i);
2315
+ this.timers.set(e, s);
2316
+ }
2317
+ registerDelay(e, t, i) {
2318
+ if (this.has(e)) {
2319
+ return n(`${e}延时器已存在,请勿重复注册`);
2320
+ }
2321
+ const s = new TimerEntry(e, _t.Delay, t, i);
2322
+ this.timers.set(e, s);
2323
+ }
2324
+ unregister(e) {
2325
+ if (this.has(e)) {
2326
+ this.timers.delete(e);
2327
+ }
2328
+ }
2329
+ has(e) {
2330
+ return this.timers.has(e);
2331
+ }
2332
+ update() {
2333
+ const e = [];
2334
+ for (const [i, s] of ue(t = this.timers).call(t)) {
2335
+ var t;
2336
+ s.remainingTime -= 1e3;
2337
+ if (s.remainingTime <= 0) {
2338
+ if (s.type === _t.Interval) {
2339
+ s.executionTime += s.initialTime;
2340
+ }
2341
+ s.callback(s.executionTime);
2342
+ if (s.type === _t.Interval) {
2343
+ s.remainingTime = s.initialTime;
2344
+ } else {
2345
+ e.push(i);
2346
+ }
2347
+ }
2348
+ }
2349
+ for (const t of e) {
2350
+ this.timers.delete(t);
2351
+ }
2352
+ }
2353
+ }
2354
+
2355
+ const gt = (t, i) => (s, n, o) => {
2356
+ let r = o.value;
2357
+ o.value = function() {
2358
+ const s = t ?? e._cat.default_audio_effect;
2359
+ if (s) {
2360
+ e._cat.audio.playEffect(s);
2361
+ } else {
2362
+ console.warn(`请添加音效路径参数`);
2363
+ }
2364
+ if (i) {
2365
+ i();
2366
+ }
2367
+ for (var n = arguments.length, o = new Array(n), a = 0; a < n; a++) {
2368
+ o[a] = arguments[a];
2369
+ }
2370
+ r.apply(this, o);
2371
+ };
2372
+ return o;
2373
+ };
2374
+
2375
+ const yt = function() {
2376
+ let e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
2377
+ let t = arguments.length > 1 ? arguments[1] : undefined;
2378
+ return function(i, s, n) {
2379
+ let o = n.value;
2380
+ let r = false;
2381
+ n.value = function() {
2382
+ if (r) {
2383
+ if (t) {
2384
+ t();
2385
+ }
2386
+ return;
2387
+ }
2388
+ r = true;
2389
+ Z(() => {
2390
+ r = false;
2391
+ }, e * 1e3);
2392
+ for (var i = arguments.length, s = new Array(i), n = 0; n < i; n++) {
2393
+ s[n] = arguments[n];
2394
+ }
2395
+ o.apply(this, s);
2396
+ };
2397
+ return n;
2398
+ };
2399
+ };
2400
+
2401
+ const vt = e._cat ??= Manager.instance;
2402
+
2403
+ y.onPostProjectInitDelegate.add(async () => {
2404
+ console.time("[Init App]");
2405
+ try {
2406
+ await vt.boot();
2407
+ await vt.onAppInitDelegate.dispatch();
2408
+ await vt.onPlugInInitDelegate.dispatch();
2409
+ } catch (e) {
2410
+ n(`[Init App] 初始化失败: ${e instanceof Error ? e.message : String(e)}`);
2411
+ throw e;
2412
+ } finally {
2413
+ console.timeEnd("[Init App]");
2414
+ }
2415
+ });
2416
+
2417
+ export { gt as AudioEffect, ge as AudioEventConstant, AudioManager, AudioSourceBaseComponent, AudioSourceUILayer, Se as AudioTypeEnum, BaseComponent, BaseManager, nt as BasePrefab, BaseStore, yt as ButtonLock, Le as CoreBlackMask, Ze as CoreNotice, qe as CoreReconnection, $e as CoreShowLoading, CoreStore, Me as CoreToast, Pe as CoreUIContainer, mt as CoreUIModal, CoreUtil, Re as GlobalEventConstant, st as Gui, GuiManager, it as LayerType, Manager, Ke as ReconnectPrompt, RootUILayer, SceneLayer, TimerManager, Oe as ToastType, UILayer, WrapperSocialGameClient, vt as cat };