var e=class extends ui.view.CyberTheme.CyberPropertyUI{constructor(){super();let e=this.#e=core.PropertyTypes;this.btnCharmIncrease.on(Laya.Event.CLICK,this,this.onPropertyAllocate,[e.CHR,1]),this.btnCharmReduce.on(Laya.Event.CLICK,this,this.onPropertyAllocate,[e.CHR,-1]),this.btnIntelligenceIncrease.on(Laya.Event.CLICK,this,this.onPropertyAllocate,[e.INT,1]),this.btnIntelligenceReduce.on(Laya.Event.CLICK,this,this.onPropertyAllocate,[e.INT,-1]),this.btnStrengthIncrease.on(Laya.Event.CLICK,this,this.onPropertyAllocate,[e.STR,1]),this.btnStrengthReduce.on(Laya.Event.CLICK,this,this.onPropertyAllocate,[e.STR,-1]),this.btnMoneyIncrease.on(Laya.Event.CLICK,this,this.onPropertyAllocate,[e.MNY,1]),this.btnMoneyReduce.on(Laya.Event.CLICK,this,this.onPropertyAllocate,[e.MNY,-1]),this.inputCharm.on(Laya.Event.INPUT,this,this.onPropertyAllocateInput,[e.CHR]),this.inputIntelligence.on(Laya.Event.INPUT,this,this.onPropertyAllocateInput,[e.INT]),this.inputStrength.on(Laya.Event.INPUT,this,this.onPropertyAllocateInput,[e.STR]),this.inputMoney.on(Laya.Event.INPUT,this,this.onPropertyAllocateInput,[e.MNY]);let t=({currentTarget:e})=>{e.text=``};this.inputCharm.on(Laya.Event.MOUSE_DOWN,this,t),this.inputIntelligence.on(Laya.Event.MOUSE_DOWN,this,t),this.inputStrength.on(Laya.Event.MOUSE_DOWN,this,t),this.inputMoney.on(Laya.Event.MOUSE_DOWN,this,t),this.btnRandomAllocate.on(Laya.Event.CLICK,this,this.random),this.btnNext.on(Laya.Event.CLICK,this,this.next),this.listSelectedTalents.renderHandler=Laya.Handler.create(this,this.renderTalent,null,!1)}#e;#t;#n;#r;init({talents:e}){this.listSelectedTalents.array=e;let t=core.remake(e.map(e=>e.id));t.length>0&&$$event(`message`,[t.map(e=>[`F_TalentReplace`,e])]),this.#t=core.getPropertyPoints(),this.#r=core.propertyAllocateLimit,this.labLeftPropertyPoint.text=this.#t,this.#n={[this.#e.CHR]:0,[this.#e.INT]:0,[this.#e.STR]:0,[this.#e.MNY]:0},this.updateAllocate()}next(){let e=this.#t-this.total;if(e>0)return $$event(`message`,[`F_PropertyPointLeft`,e]);$ui.switchView(UI.pages.TRAJECTORY,{propertyAllocate:this.#n,talents:this.listSelectedTalents.array,enableExtend:!0})}get total(){return this.#n[this.#e.CHR]+this.#n[this.#e.INT]+this.#n[this.#e.STR]+this.#n[this.#e.MNY]}updateAllocate(){let e=this.#n[this.#e.CHR],t=this.#n[this.#e.INT],n=this.#n[this.#e.STR],r=this.#n[this.#e.MNY];this.inputCharm.text=``+e,this.inputIntelligence.text=``+t,this.inputStrength.text=``+n,this.inputMoney.text=``+r,this.labLeftPropertyPoint.text=this.#t-this.total,this.btnCharmIncrease.disabled=this.btnCharmIncrease.gray=!1,this.btnCharmReduce.disabled=this.btnCharmReduce.gray=!1,this.btnIntelligenceIncrease.disabled=this.btnIntelligenceIncrease.gray=!1,this.btnIntelligenceReduce.disabled=this.btnIntelligenceReduce.gray=!1,this.btnStrengthIncrease.disabled=this.btnStrengthIncrease.gray=!1,this.btnStrengthReduce.disabled=this.btnStrengthReduce.gray=!1,this.btnMoneyIncrease.disabled=this.btnMoneyIncrease.gray=!1,this.btnMoneyReduce.disabled=this.btnMoneyReduce.gray=!1,this.total>=this.#t?(this.btnCharmIncrease.disabled=this.btnCharmIncrease.gray=!0,this.btnIntelligenceIncrease.disabled=this.btnIntelligenceIncrease.gray=!0,this.btnStrengthIncrease.disabled=this.btnStrengthIncrease.gray=!0,this.btnMoneyIncrease.disabled=this.btnMoneyIncrease.gray=!0):this.total<=0&&(this.btnCharmReduce.disabled=this.btnCharmReduce.gray=!0,this.btnIntelligenceReduce.disabled=this.btnIntelligenceReduce.gray=!0,this.btnStrengthReduce.disabled=this.btnStrengthReduce.gray=!0,this.btnMoneyReduce.disabled=this.btnMoneyReduce.gray=!0),e<=this.#r[0]?this.btnCharmReduce.disabled=this.btnCharmReduce.gray=!0:e>=this.#r[1]&&(this.btnCharmIncrease.disabled=this.btnCharmIncrease.gray=!0),t<=this.#r[0]?this.btnIntelligenceReduce.disabled=this.btnIntelligenceReduce.gray=!0:t>=this.#r[1]&&(this.btnIntelligenceIncrease.disabled=this.btnIntelligenceIncrease.gray=!0),n<=this.#r[0]?this.btnStrengthReduce.disabled=this.btnStrengthReduce.gray=!0:n>=this.#r[1]&&(this.btnStrengthIncrease.disabled=this.btnStrengthIncrease.gray=!0),r<=this.#r[0]?this.btnMoneyReduce.disabled=this.btnMoneyReduce.gray=!0:r>=this.#r[1]&&(this.btnMoneyIncrease.disabled=this.btnMoneyIncrease.gray=!0)}check(e,t,n){return!(nt)}random(){let e=this.#t,t=[,,,,].fill(this.#r[1]);for(;e>0;){let n=Math.round(Math.random()*(Math.min(e,this.#r[1])-1))+1;for(;;){let r=Math.floor(Math.random()*4)%4;if(!(t[r]-n<0)){t[r]-=n,e-=n;break}}}this.#n[this.#e.CHR]=this.#r[1]-t[0],this.#n[this.#e.INT]=this.#r[1]-t[1],this.#n[this.#e.STR]=this.#r[1]-t[2],this.#n[this.#e.MNY]=this.#r[1]-t[3],this.updateAllocate()}onPropertyAllocate(e,t){this.check(this.#r[0],this.#r[1],this.#n[e]+t)&&this.check(0,this.#t,this.total+t)&&(this.#n[e]+=t,this.updateAllocate())}onPropertyAllocateInput(e,t){let n=parseInt(t.text)||0,r=this.total;r+n<0?n=this.#r[0]*4-r:r+n>this.#t&&(n=this.#t-r),nthis.#r[1]&&(n=this.#r[1]);let i=n-this.#n[e];i?this.onPropertyAllocate(e,i):this.updateAllocate()}renderTalent(e){let t=e.dataSource,n=e.getChildByName(`labTitle`),r=e.getChildByName(`grade1`),i=e.getChildByName(`grade2`),a=e.getChildByName(`grade3`),o=e.getChildByName(`labDescription`);switch(n.text=t.name,o.text=t.description,t.grade){case 1:r.visible=!0,i.visible=!1,a.visible=!1;break;case 2:r.visible=!1,i.visible=!0,a.visible=!1;break;case 3:r.visible=!1,i.visible=!1,a.visible=!0;break;default:r.visible=!1,i.visible=!1,a.visible=!1;break}}};export{e as default};