(self.webpackChunkkiwibank_structure=self.webpackChunkkiwibank_structure||[]).push([[0],{54171:function(e,t,n){"use strict";var r=n(76071),o=n(22983),a=(n(1995),n(62642),n(21914)),i=n(10579),u=n(42982),s=n(15671),l=n(43144),c=n(97326),p=n(60136),m=n(82963),h=n(61120),d=n(4942),f=n(14161),y=n(92972),g=n.n(y),v=n(51569),b=n.n(v),w=n(74660),P=n(98651),x=n(14507),T=n.n(x);function M(e){var t=e.totalLoanBalanceFunc,n=e.onSubmit,r=e.resetForm,o=structureConfig,i=a.createElement(P.J2e,{id:"total-loan-balance-tooltip",title:"",className:"totalLoanBalance-popover"},o.tooltips.totalLoanBalance),u=T()({"internal-wrapper":"right","icon-wrapper":"icon-wrapper","icon-tooltip":"icon-tooltip"});return a.createElement(a.Fragment,null,a.createElement(P.d_2,{initialValues:e,enableReinitialize:!0,validateOnChange:!1,onSubmit:n},a.createElement(P.l09,{className:"calc-inputs-wrapper"},a.createElement("div",{className:"inputs-container"},a.createElement("span",{className:"inline-text"},"My home loan has a total balance of"),a.createElement("div",{className:"label-wrapper"},a.createElement(P.cwH,{fieldName:"totalLoanBalance",className:"currency-field",validationState:{}.totalLoanBalance},a.createElement(P.uoj,{name:"totalLoanBalance",prefix:"$",min:o.minValues.totalLoanBalance,max:o.maxValues.totalLoanBalance,minDecimalPlaces:0,maxLength:o.maxValues.totalLoanBalance.toString().length,allowNegatives:!1,maxDecimalPlaces:0,autoComplete:"off",onBlur:function(e,n){return t(""===n?"":Number(n))},validate:(0,P.Enm)((0,P.AsH)())}),a.createElement(P.beA,{fieldName:"totalLoanBalance"})),""!==o.tooltips.totalLoanBalance?a.createElement(P.OxE,{placement:"bottom",overlay:i},a.createElement(P.zxk,{type:"button",className:u},a.createElement("span",{className:"accessibility-only"},"Tooltip"))):"",a.createElement("span",{className:"nl-text"},"."))),a.createElement("div",{className:"button-wrapper"},a.createElement(P.zxk,{type:"submit",mode:"primary"},o.naturalLanguage.nextButton),a.createElement(P.zxk,{type:"reset",mode:"default",inverse:!0,className:"reset-button",onClick:r},o.naturalLanguage.resetButton)))))}M.propTypes={totalLoanBalanceFunc:g().func.isRequired,onSubmit:g().func.isRequired,resetForm:g().func.isRequired};var R=M,A=n(31528);function k(e){var t=e.portionAmountMax,n=e.portionAmountMin,r=e.portionCustomRateMin,o=e.portionCustomRateMax,i=e.portionRateList,u=e.portionTimeToPayMin,s=e.portionTimeToPayMax,l=e.numberOfCards,c=e.isMobile,p=e.portions,m=e.optionId,h=e.portionsValuesUpdateFunc,d=e.addPortionClickFunc,f=e.editingPortionKey,y=e.portionAmountsTooLarge,g=e.portionAmountsTooLargeBalance,v=e.portionRepaymentsFrequencyList,b=e.deletePortionFunc,w=e.onSubmit,x=e.validRates,M={},R=structureConfig,k=T()({"internal-wrapper":"right","icon-wrapper":"icon-wrapper","bulb-tooltip":"bulb-tooltip"}),C=T()({"internal-wrapper":"right","icon-wrapper":"icon-wrapper","plus-button":"plus-button"}),B=T()({"internal-wrapper":"right","icon-wrapper":"icon-wrapper","flag-icon":"flag-icon"}),L=a.createElement(P.J2e,{id:"portion-rate-tooltip",title:"",className:"bulb-popover",closeButton:!0},a.createElement("div",{className:"title"},R.tooltips.portionRate.title),a.createElement("p",{dangerouslySetInnerHTML:{__html:R.tooltips.portionRate.content}}),a.createElement("button",{className:"close CloseButton",onClick:function(){return S.ref.hide()}})),E=a.createElement(P.J2e,{id:"portion-repayments-tooltip",title:"",className:"bulb-popover",closeButton:!0},a.createElement("div",{className:"title"},R.tooltips.portionRepayments.title),a.createElement("p",{dangerouslySetInnerHTML:{__html:R.tooltips.portionRepayments.content}}),a.createElement("button",{className:"close CloseButton",onClick:function(){return D.ref.hide()}})),I=a.createElement(P.J2e,{id:"portion-time-to-pay-tooltip",title:"",className:"bulb-popover",closeButton:!0},a.createElement("div",{className:"title"},R.tooltips.portionTimeToPay.title),a.createElement("p",{dangerouslySetInnerHTML:{__html:R.tooltips.portionTimeToPay.content}}),a.createElement("button",{className:"close CloseButton",onClick:function(){return O.ref.hide()}})),S=null,D=null,O=null,F=p.findIndex((function(e){return e.key===f}))!==p.length-1;return a.createElement(a.Fragment,null,a.createElement("div",{className:"results-wrapper"},a.createElement("div",{className:"results ".concat(l>1?"multiple-results":"")},a.createElement("div",null,!c||1===l&&c?a.createElement("div",{className:"results-header"},a.createElement("div",{className:"header-content"},"".concat(R.portion.labels.header," ").concat(m))):null,p.map((function(e,l){return a.createElement(P.d_2,{key:e.key,enableReinitialize:!0,initialValues:e,validateOnChange:!0,onSubmit:function(e){return w(e,m)}},(function(){return a.createElement(P.l09,{className:"form-wrapper ".concat(f&&e.key===f?"":"readonly")},a.createElement("div",{className:"control-wrapper portion-amount-wrapper"},a.createElement(P.J$v,null,"".concat(R.portion.labels.amount," ").concat(l+1)),a.createElement("div",{className:"portion-inputs-wrapper"},a.createElement(P.cwH,{fieldName:"portionAmount",className:"portion-amount",validationState:M.portionAmount},a.createElement(P.uoj,{name:"portionAmount",prefix:"$",min:n,customfocus:l===p.length-1?"".concat(m):void 0,max:t,minDecimalPlaces:0,maxDecimalPlaces:0,autoComplete:"off",onBlur:function(t,n){return h("portionAmount",Number(n),e.key,m)},validate:(0,P.Enm)((0,P.AsH)())}),a.createElement(P.beA,{fieldName:"portionAmount"}),p.length>1?a.createElement(P.zxk,{type:"button",className:"delete-portion-button",onClick:function(){return b(m,e.key)}}):null))),x?null:a.createElement("div",{className:"control-wrapper"},a.createElement("div",{className:"invalid-rates-wrapper"},a.createElement("div",{className:"invalid-rates-icon"}),a.createElement("p",{className:"enter-a-rate"},"Enter a rate"),a.createElement("p",{className:"invalid-rates"},R.results.invalidRatesFile))),x?a.createElement("div",{className:"control-wrapper portion-rate-wrapper"},a.createElement(P.J$v,null,R.portion.labels.rate),a.createElement("div",{className:"portion-inputs-wrapper"},a.createElement(P.cwH,{fieldName:"portionRate",className:"portion-rate",validationState:M.portionRate},a.createElement(P.aeb,{name:"portionRate",options:i,placeholder:"Select a rate",searchable:!1,onChange:function(t){return h("portionRate",t.value,e.key,m)},validate:(0,P.Enm)((0,P.AsH)())}),a.createElement(P.beA,{fieldName:"portionRate"}),a.createElement(P.OxE,{ref:function(e){return S=e},placement:"bottom",overlay:L,trigger:"click",onClick:function(){}},a.createElement(P.zxk,{type:"submit",className:k},a.createElement("span",{className:"accessibility-only"},"Tooltip")))))):null,"custom"===e.portionRate?a.createElement("div",{className:"control-wrapper portion-custom-rate-wrapper"},a.createElement(P.J$v,null,R.portion.labels.customRate),a.createElement("div",{className:"portion-inputs-wrapper"},a.createElement(P.cwH,{fieldName:"portionCustomRate",className:"portion-custom-rate",validationState:M.portionCustomRate},a.createElement(P._Xj,{name:"portionCustomRate",min:r,max:o,minDecimalPlaces:2,maxDecimalPlaces:2,suffix:"%",autoComplete:"off",onBlur:function(t,n){return h("portionCustomRate",Number(n),e.key,m)},validate:(0,P.Enm)((0,P.AsH)())}),a.createElement(P.beA,{fieldName:"portionCustomRate"})),a.createElement("span",null,"p.a."))):null,a.createElement("div",{className:"control-wrapper portion-repayments-wrapper"},a.createElement(P.J$v,null,R.portion.labels.repayments),a.createElement("div",{className:"portion-inputs-slider-wrapper"},a.createElement("div",{className:"portion-inputs-wrapper"},a.createElement(P.cwH,{fieldName:"portionRepaymentsAmount",className:"portion-repayments-amount",validationState:M.portionRepaymentsAmount},a.createElement(P.uoj,{name:"portionRepaymentsAmount",prefix:"$",min:e.minRepayment,max:e.maxRepayment,minDecimalPlaces:2,maxDecimalPlaces:2,autoComplete:"off",onBlur:function(t,n){return h("portionRepaymentsAmount",Number(n),e.key,m)},validate:(0,P.Enm)((0,P.AsH)())}),a.createElement(P.beA,{fieldName:"portionRepaymentsAmount"})),a.createElement(P.cwH,{fieldName:"portionRepaymentsFrequency",className:"portion-repayments-frequency",validationState:M.portionRepaymentsFrequency},a.createElement(P.aeb,{name:"portionRepaymentsFrequency",options:v,searchable:!1,onChange:function(t){return h("portionRepaymentsFrequency",t.value,e.key,m)},validate:(0,P.Enm)((0,P.AsH)())}),a.createElement(P.beA,{fieldName:"portionRepaymentsFrequency"}))),a.createElement("div",{className:"portion-repayments-slider-wrapper"},a.createElement(A.Z,{className:"horizontal-slider",thumbClassName:"example-thumb",trackClassName:"example-track",min:e.minRepayment,max:e.maxRepayment,step:.01,value:e.portionRepaymentsAmount,onChange:function(t){return h("portionRepaymentsAmount",Number(t),e.key,m)},onSliderClick:function(t){return h("portionRepaymentsAmount",Number(t),e.key,m)}})),a.createElement(P.OxE,{ref:function(e){return D=e},placement:"bottom",overlay:E,trigger:"click",onClick:function(){}},a.createElement(P.zxk,{type:"submit",className:k},a.createElement("span",{className:"accessibility-only"},"Tooltip"))))),a.createElement("div",{className:"control-wrapper portion-time-to-pay-wrapper"},a.createElement(P.J$v,null,R.portion.labels.term),a.createElement("div",{className:"portion-inputs-slider-wrapper"},a.createElement("div",{className:"portion-inputs-wrapper"},a.createElement(P.cwH,{fieldName:"portionTimeToPayYear",className:"portion-time-to-pay-year",validationState:M.portionTimeToPayYear},a.createElement(P._Xj,{name:"portionTimeToPayYear",min:u,max:s,minDecimalPlaces:0,maxDecimalPlaces:0,suffix:"".concat(e.portionTimeToPayYear<2?"year":"years"),autoComplete:"off",onBlur:function(t,n){return h("portionTimeToPayYear",Number(n),e.key,m)}}),a.createElement(P.beA,{fieldName:"portionTimeToPayYear"})),a.createElement(P.cwH,{fieldName:"portionTimeToPayMonth",className:"portion-time-to-pay-month",validationState:M.portionTimeToPayMonth},a.createElement(P._Xj,{name:"portionTimeToPayMonth",min:0,max:e.portionTimeToPayYear===s?0:11,minDecimalPlaces:0,maxDecimalPlaces:0,suffix:"".concat(e.portionTimeToPayMonth<2?"month":"months"),autoComplete:"off",onBlur:function(t,n){return h("portionTimeToPayMonth",Number(n),e.key,m)}}),a.createElement(P.beA,{fieldName:"portionTimeToPayMonth"}))),a.createElement("div",{className:"portion-time-to-pay-slider-wrapper"},a.createElement(A.Z,{className:"horizontal-slider",thumbClassName:"example-thumb",trackClassName:"example-track",min:u,max:s,step:.01,value:e.portionTimeToPay,onChange:function(t){return h("portionTimeToPay",Number(t),e.key,m)},onSliderClick:function(t){return h("portionTimeToPay",Number(t),e.key,m)}})),a.createElement(P.OxE,{ref:function(e){return O=e},placement:"bottom",overlay:I,trigger:"click",onClick:function(){}},a.createElement(P.zxk,{type:"submit",className:k},a.createElement("span",{className:"accessibility-only"},"Tooltip"))))))}))})),p.length<10?a.createElement(a.Fragment,null,a.createElement("div",{className:"control-wrapper plus-button-wrapper ".concat(F?"readonly":"")},a.createElement(P.zxk,{type:"submit",className:C,onClick:function(){return d(m)}},a.createElement("span",{className:"accessibility-only"},"Tooltip"))),a.createElement("div",{className:"control-wrapper add-portion-text-wrapper"},a.createElement("span",null,R.addNewPortion.body))):null,y?a.createElement(a.Fragment,null,a.createElement("div",{className:"control-wrapper flag-icon-wrapper ".concat(p.length>=10?"":"readonly")},a.createElement("div",{className:B})),a.createElement("div",{className:"control-wrapper add-portion-text-wrapper note-text-wrapper"},a.createElement("span",null,R.portionAmountExceeded.header),a.createElement("span",null,"".concat(R.portionAmountExceeded.body," ").concat(g)))):null))))}k.propTypes={portionAmountMax:g().number.isRequired,portionAmountMin:g().number.isRequired,validRates:g().bool.isRequired,numberOfCards:g().number.isRequired,isMobile:g().bool.isRequired,portionRateList:g().array.isRequired,portionTimeToPayMin:g().number.isRequired,portionTimeToPayMax:g().number.isRequired,portionCustomRateMin:g().number.isRequired,portionCustomRateMax:g().number.isRequired,helpTooltipArrowButtonFunc:g().func,helpTooltipButtonFunc:g().func,helpTooltipScreen2:g().bool,helpTooltipAccordionActiveKey:g().oneOfType([g().string,g().array]),onSelectHelpTooltipAccordion:g().func,portions:g().array.isRequired,optionId:g().number.isRequired,portionsValuesUpdateFunc:g().func.isRequired,addPortionClickFunc:g().func.isRequired,editingPortionKey:g().string,portionAmountsTooLarge:g().bool,portionAmountsTooLargeBalance:g().string,portionRepaymentsFrequencyList:g().array.isRequired,deletePortionFunc:g().func.isRequired,onSubmit:g().func.isRequired};var C=k,B=n(48997),L=n.n(B),E=n(75605),I=n(38004);function S(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function D(e){for(var t=1;t0&&i.length&&(n["option".concat(a,"Portions")]=(0,u.Z)(i),i=[]),a++,s=0):n.activeItemIndex="".concat(c)?Number(c):0;else if(c.includes(",")){var p=c.split(","),m={key:(0,I.Z)(),portionRepaymentsFrequency:o,changeType:"r"===p[0]?"repayment":"term",portionAmount:Number(p[1]),minTerm:t.config.minValues.portionTimeToPay,maxTerm:t.config.maxValues.portionTimeToPay,portionCustomRate:"c"===p[p.length-1]?t.getNumberValue(p[2]):"",portionRate:"c"===p[p.length-1]?"custom":t.getNumberValue(p[2]),portionRepaymentsAmount:"r"===p[0]?t.getNumberValue(p[3]):"",portionTimeToPay:"r"===p[0]?"":t.getNumberValue(p[3])};Number.isFinite(m.portionTimeToPay)&&(m.portionTimeToPayYear=t.calculatePortionTimeToPayYear(m.portionTimeToPay),m.portionTimeToPayMonth=t.calculatePortionTimeToPayMonth(m.portionTimeToPay)),i.push(m)}else 1===s&&(n["showOption".concat(a,"Graph")]="true"===c),2===s&&(n["showScenario".concat(a)]="true"===c),s>2&&(n.showScreen2="true"===c)}a>0&&i.length&&(n["option".concat(a,"Portions")]=(0,u.Z)(i)),n.numberOfCards=a,a>1&&(n.maxNumberOfCards=2)}return n})),(0,d.Z)((0,c.Z)(t),"generateStringFromData",(function(e){var n=e.totalLoanBalance,r=e.numberOfCards,o=e.option1Portions,a=e.option2Portions,i=e.option3Portions,u=e.showOption1Graph,s=e.showOption2Graph,l=e.showOption3Graph,c=e.showScenario1,p=e.showScenario2,m=e.showScenario3,h=e.activeItemIndex,d=e.showScreen2;if(!n)return"";var f="".concat(n,"|");return r>=1&&o.forEach((function(e,n){f=f.concat(t.mapPortionDataToString(e,n,u,c))})),r>=2&&a.forEach((function(e,n){f=f.concat(t.mapPortionDataToString(e,n,s,p))})),3===r&&i.forEach((function(e,n){f=f.concat(t.mapPortionDataToString(e,n,l,m))})),f=(f=f.concat("".concat(h,"|"))).concat("".concat(d,"|"))})),(0,d.Z)((0,c.Z)(t),"getCTALink",(function(e){var n=t.generateQSFromParams(e),r="".concat(window.location.origin).concat(window.location.pathname),o="".concat(r,"?").concat(n),a=t.config.cta.applyNowLink,i="".concat(a,"?calculator_url=").concat(encodeURIComponent(o));if(a&&a.includes("#")){var u=a.lastIndexOf("#");i="".concat(a.slice(0,u),"?calculator_url=").concat(encodeURIComponent(o)).concat(a.slice(u))}return i})),(0,d.Z)((0,c.Z)(t),"updateDimensions",(function(){var e=window.innerWidth<1200,n=window.innerWidth<870;t.setState({width:window.innerWidth,isMobile:e,isSmallHelpButtonBreakpoint:n})})),(0,d.Z)((0,c.Z)(t),"handleScrollToResults",(function(){t.scrollCalc(t.resultsRef.current.offsetTop)})),(0,d.Z)((0,c.Z)(t),"resetForm",(function(){var e={totalLoanBalance:"",showScreen2:!1,validRates:t.checkIfRatesAreValid(),activeItemIndex:0,maxNumberOfCards:1,numberOfCards:1,showScenario1:!0,showScenario2:!1,showScenario3:!1};t.setState(e),t.updateCookie(e),t.cookies.remove("structureCalculatorParams")})),(0,d.Z)((0,c.Z)(t),"onSubmit",(function(e){t.setState({totalLoanBalance:Number(e.totalLoanBalance),showScreen2:!0,activeItemIndex:0,maxNumberOfCards:1,numberOfCards:1,showScenario1:!0,showScenario2:!1,showScenario3:!1,option1Portions:[{key:(0,I.Z)(),changeType:"term",portionAmount:Number(e.totalLoanBalance),portionRate:"",portionRepaymentsAmount:"",portionRepaymentsFrequency:"fortnight",portionTimeToPay:25,portionTimeToPayYear:25,portionTimeToPayMonth:0}],option2Portions:[{key:(0,I.Z)(),changeType:"term",portionAmount:Number(e.totalLoanBalance),portionRate:"",portionRepaymentsAmount:"",portionRepaymentsFrequency:"fortnight",portionTimeToPay:25,portionTimeToPayYear:25,portionTimeToPayMonth:0}],option3Portions:[{key:(0,I.Z)(),changeType:"term",portionAmount:Number(e.totalLoanBalance),portionRate:"",portionRepaymentsAmount:"",portionRepaymentsFrequency:"fortnight",portionTimeToPay:25,portionTimeToPayYear:25,portionTimeToPayMonth:0}],graphData:[],option1TotalRepaymentAmount:"",option1TotalAmount:"",option1TotalInterest:"",option1RepaymentTermYears:"",option1EditingPortionKey:"",bestOptionIds:[],bestOptionSaveAmount:"",option1TotalPay:"",showOption1Graph:!1,option2TotalRepaymentAmount:"",option2TotalAmount:"",option2TotalInterest:"",option2RepaymentTermYears:"",option2EditingPortionKey:"",option2TotalPay:"",showOption2Graph:!1,option3TotalRepaymentAmount:"",option3TotalAmount:"",option3TotalInterest:"",option3RepaymentTermYears:"",option3EditingPortionKey:"",option3TotalPay:"",showOption3Graph:!1,option1GraphDataPoints:[],option2GraphDataPoints:[],option3GraphDataPoints:[]}),t.handleScrollToResults(),setTimeout((function(){window.dispatchEvent(new Event("resize"))}),0)})),(0,d.Z)((0,c.Z)(t),"updateCookie",(function(e){var n=t.generateStringFromData(e),r=btoa(n);t.cookies.set("structureCalculatorParams",r,{path:"/",sameSite:"None",secure:!0})})),(0,d.Z)((0,c.Z)(t),"totalLoanBalanceFunc",(function(e){t.setState({totalLoanBalance:e})})),(0,d.Z)((0,c.Z)(t),"recalculateBestOption",(function(e,n){var r=[],o="",a=t.state,i=a.option1TotalPay,s=a.option2TotalPay,l=a.option3TotalPay,c=a.option1Portions,p=a.option2Portions,m=a.option3Portions,h=a.totalLoanBalance,d=c.reduce((function(e,t){return e+t.portionAmount}),0),f=p.reduce((function(e,t){return e+t.portionAmount}),0),y=m.reduce((function(e,t){return e+t.portionAmount}),0),g=d&&h&&d!==h,v=f&&h&&f!==h,b=y&&h&&y!==h;1===e?i=n:2===e?s=n:3===e&&(l=n);var w=[{optionId:1,value:i},{optionId:2,value:s},{optionId:3,value:l}].filter((function(e){return Number.isFinite(e.value)}));if(g&&(w=w.filter((function(e){return 1!==e.optionId}))),v&&(w=w.filter((function(e){return 2!==e.optionId}))),b&&(w=w.filter((function(e){return 3!==e.optionId}))),w.length>1){var P=Math.max.apply(Math,(0,u.Z)(w.map((function(e){return e.value})))),x=Math.min.apply(Math,(0,u.Z)(w.map((function(e){return e.value}))));"$0"!==t.formatCurrency(P-x,0,0)&&(o=P-x,r=w.filter((function(e){return e.value===x})).map((function(e){return e.optionId})))}t.setState({bestOptionIds:r,bestOptionSaveAmount:o})})),(0,d.Z)((0,c.Z)(t),"formatCurrency",(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return new Intl.NumberFormat("en-AU",{style:"currency",currency:"AUD",minimumFractionDigits:t,maximumFractionDigits:n}).format(e)})),(0,d.Z)((0,c.Z)(t),"recalculatePortionResults",(function(e,n){var r=(0,u.Z)(n),o=t.calcEngine.getResults(n),a=o.repaymentFrequency,i=o.totalPay,s=o.totalRepayment,l=o.totalTerm,c=o.totalTermNaturalLanguage,p=o.newPortions,m=o.graphDataPoints,h=t.state.totalLoanBalance,d=Number.isFinite(s)?"".concat(t.formatCurrency(s,2,2)," ").concat(a):"",f=c;f=f.includes("NaN")||f.includes("Infinity")?"":f;var y=Number.isFinite(i)?t.formatCurrency(i):"",g=Number.isFinite(i)&&Number.isFinite(h)?t.formatCurrency(Math.round(i)-h):"";r=r.map((function(e,n){return"repayment"===e.changeType?D(D({},e),{},{portionTimeToPay:Number.isFinite(p[n].portionTimeToPay)?p[n].portionTimeToPay:e.portionTimeToPay,portionTimeToPayYear:Number.isFinite(p[n].portionTimeToPay)?t.calculatePortionTimeToPayYear(p[n].portionTimeToPay):e.portionTimeToPayYear,portionTimeToPayMonth:Number.isFinite(p[n].portionTimeToPay)?t.calculatePortionTimeToPayMonth(p[n].portionTimeToPay):e.portionTimeToPayMonth,minRepayment:Number.isFinite(p[n].minRepayment)?p[n].minRepayment:null,maxRepayment:Number.isFinite(p[n].maxRepayment)?p[n].maxRepayment:null}):D(D({},e),{},{portionRepaymentsAmount:Number.isFinite(p[n].portionRepaymentsAmount)?p[n].portionRepaymentsAmount:e.portionRepaymentsAmount,minRepayment:Number.isFinite(p[n].minRepayment)?p[n].minRepayment:null,maxRepayment:Number.isFinite(p[n].maxRepayment)?p[n].maxRepayment:null})})),1===e?t.setState({option1TotalRepaymentAmount:d,option1RepaymentTermYears:f,option1TotalAmount:y,option1TotalInterest:g,option1Portions:r,option1TotalPay:i,option1TotalTerm:l,option1GraphDataPoints:m},(function(){t.recalculateBestOption(e,i),t.updateGraphData()})):2===e?t.setState({option2TotalRepaymentAmount:d,option2RepaymentTermYears:f,option2TotalAmount:y,option2TotalInterest:g,option2Portions:r,option2TotalPay:i,option2TotalTerm:l,option2GraphDataPoints:m},(function(){t.recalculateBestOption(e,i),t.updateGraphData()})):3===e&&t.setState({option3TotalRepaymentAmount:d,option3RepaymentTermYears:f,option3TotalAmount:y,option3TotalInterest:g,option3Portions:r,option3TotalPay:i,option3TotalTerm:l,option3GraphDataPoints:m},(function(){t.recalculateBestOption(e,i),t.updateGraphData()}))})),(0,d.Z)((0,c.Z)(t),"calculateRemainingPay",(function(e,t,n){return Math.trunc(-1*t*e/n+t)})),(0,d.Z)((0,c.Z)(t),"contructGraphDataPoints",(function(e){if(!e||!e.length)return[];var n=e.map((function(e){return{x:e[0],y:t.roundUp(e[1],0)}})),r=n[n.length-1];return r.y>0&&n.push({x:r.x+1,y:0}),n})),(0,d.Z)((0,c.Z)(t),"constructGraphData",(function(e,n,r){var o=[];return e&&Number.isFinite(t.state.option1TotalPay)&&Number.isFinite(t.state.option1TotalTerm)&&o.push({totalPay:t.state.option1TotalPay,id:"".concat(t.config.graph.labels.id," 1"),data:t.contructGraphDataPoints(t.state.option1GraphDataPoints)}),n&&Number.isFinite(t.state.option2TotalPay)&&Number.isFinite(t.state.option2TotalTerm)&&o.push({totalPay:t.state.option2TotalPay,id:"".concat(t.config.graph.labels.id," 2"),data:t.contructGraphDataPoints(t.state.option2GraphDataPoints)}),r&&Number.isFinite(t.state.option3TotalPay)&&Number.isFinite(t.state.option3TotalTerm)&&o.push({totalPay:t.state.option3TotalPay,id:"".concat(t.config.graph.labels.id," 3"),data:t.contructGraphDataPoints(t.state.option3GraphDataPoints)}),o.sort((function(e,t){return e.totalPay-t.totalPay})),o})),(0,d.Z)((0,c.Z)(t),"getAxisLeftTickValuesArray",(function(e){for(var t=Math.max.apply(Math,(0,u.Z)(e)),n="".concat(Math.trunc(t)).length,r=Math.ceil(t/Math.pow(10,n-1))*Math.pow(10,n-1),o=[],a=Math.pow(10,n-1);a<=r;)o.push(a),a+=Math.pow(10,n-1);return o})),(0,d.Z)((0,c.Z)(t),"getDistinctValuesArray",(function(e){var t=[];return e.forEach((function(e){t.includes(e)||t.push(e)})),t})),(0,d.Z)((0,c.Z)(t),"updateGraphData",(function(){var e=t.state,n=e.showOption1Graph,r=e.showOption2Graph,o=e.showOption3Graph,a=e.option1Portions,i=e.option2Portions,s=e.option3Portions,l=e.totalLoanBalance,c=a.reduce((function(e,t){return e+t.portionAmount}),0),p=i.reduce((function(e,t){return e+t.portionAmount}),0),m=s.reduce((function(e,t){return e+t.portionAmount}),0),h=c&&l&&c!==l,d=p&&l&&p!==l,f=m&&l&&m!==l,y=t.constructGraphData(n&&!h,r&&!d,o&&!f),g=t.getAxisLeftTickValuesArray(y.map((function(e){return e.data[0].y}))),v=t.getDistinctValuesArray(y.map((function(e){return e.data[e.data.length-1].x}))),b=y.length?1.1*Math.max.apply(Math,(0,u.Z)(v)):0,w=y.length?1.1*Math.max.apply(Math,(0,u.Z)(g)):0,P=y.length?[0].concat((0,u.Z)(g)):[0],x=y.length?(0,u.Z)(v):[];t.setState({graphData:y,xScaleMax:b,yScaleMax:w,axisLeftTickValues:P,axisBottomTickValues:x})})),(0,d.Z)((0,c.Z)(t),"graphButtonClick",(function(){var e=t.state,n=e.showOption1Graph,r=e.showOption2Graph,o=e.showOption3Graph;t.setState({showOption1Graph:!n,showOption2Graph:!r,showOption3Graph:!o},(function(){t.updateGraphData()}))})),(0,d.Z)((0,c.Z)(t),"roundDown",(function(e,t){var n=Math.pow(10,t);return Math.floor(e*n)/n})),(0,d.Z)((0,c.Z)(t),"roundUp",(function(e,t){var n=Math.pow(10,t);return Math.ceil(e*n)/n})),(0,d.Z)((0,c.Z)(t),"calculatePortionTimeToPay",(function(e,n){return e+t.roundDown(n/12,2)})),(0,d.Z)((0,c.Z)(t),"calculatePortionTimeToPayYear",(function(e){var n=t.roundDown(e,0);return 12===t.roundUp(12*e%12,0)&&n++,n})),(0,d.Z)((0,c.Z)(t),"calculatePortionTimeToPayMonth",(function(e){var n=t.roundUp(12*e%12,0);return 12===n?0:n})),(0,d.Z)((0,c.Z)(t),"updateFields",(function(e,n,r){["portionAmount","portionRepaymentsAmount","portionTimeToPay","portionTimeToPayMonth","portionTimeToPayYear","portionCustomRate"].forEach((function(o){Number(e[o])!==Number(n[o])&&t.portionsValuesUpdateFunc(o,Number(e[o]),e.key,r)}))})),(0,d.Z)((0,c.Z)(t),"onSubmitResults",(function(e,n){var r={};1===n?r=t.state.option1Portions.find((function(t){return t.key===e.key})):2===n?r=t.state.option2Portions.find((function(t){return t.key===e.key})):3===n&&(r=t.state.option3Portions.find((function(t){return t.key===e.key}))),t.updateFields(e,r,n)})),(0,d.Z)((0,c.Z)(t),"updatePortionsValues",(function(e,n,r,o){return e.map((function(e){var a=D({},e);if("portionRepaymentsFrequency"!==n&&e.key!==o||(a[n]=r),"portionRepaymentsAmount"===n&&e.key===o&&(a.changeType="repayment"),"portionRepaymentsAmount"!==n&&e.key===o&&(a.changeType="term"),"portionTimeToPay"===n&&e.key===o&&(a.portionTimeToPayYear=t.calculatePortionTimeToPayYear(r),a.portionTimeToPayMonth=t.calculatePortionTimeToPayMonth(r)),"portionTimeToPayYear"===n&&e.key===o&&(r===t.config.maxValues.portionTimeToPay&&(a.portionTimeToPayMonth=0),a.portionTimeToPay=t.calculatePortionTimeToPay(r,a.portionTimeToPayMonth)),"portionTimeToPayMonth"===n&&e.key===o){var i=r;a.portionTimeToPayYear===t.config.maxValues.portionTimeToPay&&(i=0,a.portionTimeToPayMonth=0),a.portionTimeToPay=t.calculatePortionTimeToPay(a.portionTimeToPayYear,i)}return"portionRate"===n&&"custom"===r&&e.key===o&&(a.portionCustomRate=""),a.minTerm=t.config.minValues.portionTimeToPay,a.maxTerm=t.config.maxValues.portionTimeToPay,a}))})),(0,d.Z)((0,c.Z)(t),"portionsValuesUpdateFunc",(function(e,n,r,o){if(1===o){var a=t.state.option1Portions;t.recalculatePortionResults(o,t.updatePortionsValues(a,e,n,r))}else if(2===o){var i=t.state.option2Portions;t.recalculatePortionResults(o,t.updatePortionsValues(i,e,n,r))}else if(3===o){var u=t.state.option3Portions;t.recalculatePortionResults(o,t.updatePortionsValues(u,e,n,r))}})),(0,d.Z)((0,c.Z)(t),"deletePortionFunc",(function(e,n){if(1===e){var r=t.state.option1Portions.filter((function(e){return e.key!==n}));t.recalculatePortionResults(e,r)}else if(2===e){var o=t.state.option2Portions.filter((function(e){return e.key!==n}));t.recalculatePortionResults(e,o)}else if(3===e){var a=t.state.option3Portions.filter((function(e){return e.key!==n}));t.recalculatePortionResults(e,a)}})),(0,d.Z)((0,c.Z)(t),"focusAccordingly",(function(e,n){var r=t.state,o=r.isMobile,a=r.numberOfCards;1===e.length&&setTimeout((function(){e[0].focus()}),100),2!==e.length&&3!==e.length||(1!==n||0!==t.state.activeItemIndex||o||3!==a?setTimeout((function(){e[1].focus()}),100):setTimeout((function(){e[0].focus()}),100))})),(0,d.Z)((0,c.Z)(t),"addPortionClickFunc",(function(e){if(1===e){var n=t.state.option1Portions,r=n[n.length-1],o=(0,I.Z)();n.push({portionAmount:0,portionRate:"",portionRepaymentsAmount:"",portionRepaymentsFrequency:r.portionRepaymentsFrequency,portionTimeToPay:25,portionTimeToPayYear:25,portionTimeToPayMonth:0,key:o}),t.recalculatePortionResults(e,n),t.setState({option1EditingPortionKey:o},(function(){var n=document.querySelectorAll('[customfocus="1"]');t.focusAccordingly(n,e)}))}else if(2===e){var a=t.state.option2Portions,i=a[a.length-1],u=(0,I.Z)();a.push({portionAmount:0,portionRate:"",portionRepaymentsAmount:"",portionRepaymentsFrequency:i.portionRepaymentsFrequency,portionTimeToPay:25,portionTimeToPayYear:25,portionTimeToPayMonth:0,key:u}),t.recalculatePortionResults(e,a),t.setState({option2EditingPortionKey:u},(function(){var n=document.querySelectorAll('[customfocus="2"]');t.focusAccordingly(n,e)}))}else if(3===e){var s=t.state.option3Portions,l=s[s.length-1],c=(0,I.Z)();s.push({portionAmount:0,portionRate:"",portionRepaymentsAmount:"",portionRepaymentsFrequency:l.portionRepaymentsFrequency,portionTimeToPay:25,portionTimeToPayYear:25,portionTimeToPayMonth:0,key:c}),t.recalculatePortionResults(e,s),t.setState({option3EditingPortionKey:c},(function(){var n=document.querySelectorAll('[customfocus="3"]');t.focusAccordingly(n,e)}))}})),(0,d.Z)((0,c.Z)(t),"setActiveItemIndex",(function(e){t.setState({activeItemIndex:e<0?(e+3)%3:e%3})})),(0,d.Z)((0,c.Z)(t),"cloneScenario2Into3",(function(e,n,r){var o=t.state,a=o.numberOfCards,i=o.option2Portions,u=o.option2TotalRepaymentAmount,s=o.option2TotalAmount,l=o.option2TotalInterest,c=o.option2RepaymentTermYears,p=o.option2TotalPay,m=o.option2TotalTerm,h=o.showOption2Graph,d=o.option2GraphDataPoints;t.setState({maxNumberOfCards:2,numberOfCards:a+1,showScenario1:e,showScenario2:n,showScenario3:r,option3Portions:i.map((function(e){return D(D({},e),{},{key:(0,I.Z)()})})),option3TotalRepaymentAmount:u,option3TotalAmount:s,option3TotalInterest:l,option3RepaymentTermYears:c,option3EditingPortionKey:"",option3TotalPay:p,option3TotalTerm:m,showOption3Graph:h,option3GraphDataPoints:d,bestOptionIds:[],bestOptionSaveAmount:""},(function(){t.recalculateBestOption(3,p),t.updateGraphData()}))})),(0,d.Z)((0,c.Z)(t),"cloneScenario1Into2",(function(e,n,r){var o=t.state,a=o.numberOfCards,i=o.option1Portions,u=o.option1TotalRepaymentAmount,s=o.option1TotalAmount,l=o.option1TotalInterest,c=o.option1RepaymentTermYears,p=o.option1TotalPay,m=o.option1TotalTerm,h=o.showOption1Graph,d=o.option1GraphDataPoints;t.setState({maxNumberOfCards:2,numberOfCards:a+1,showScenario1:e,showScenario2:n,showScenario3:r,option2Portions:i.map((function(e){return D(D({},e),{},{key:(0,I.Z)()})})),option2TotalRepaymentAmount:u,option2TotalAmount:s,option2TotalInterest:l,option2RepaymentTermYears:c,option2EditingPortionKey:"",option2TotalPay:p,option2TotalTerm:m,showOption2Graph:h,option2GraphDataPoints:d,bestOptionIds:[],bestOptionSaveAmount:""},(function(){t.recalculateBestOption(2,p),t.updateGraphData()}))})),(0,d.Z)((0,c.Z)(t),"duplicatePanel",(function(){var e=t.state,n=e.numberOfCards,r=e.showScenario2,o=e.isMobile,a=!1,i=!1,u=!1;2===n?(a=!0,i=!0,u=!0,r?(t.setActiveItemIndex(o?2:1),t.cloneScenario2Into3(a,i,u)):(t.setActiveItemIndex(o?1:0),t.cloneScenario1Into2(a,i,u))):r?(i=!0,u=!0,t.setActiveItemIndex(o?2:1),t.cloneScenario2Into3(a,i,u)):(a=!0,i=!0,t.setActiveItemIndex(o?1:0),t.cloneScenario1Into2(a,i,u)),t.handleScrollToResults(),setTimeout((function(){window.dispatchEvent(new Event("resize"))}),0)})),(0,d.Z)((0,c.Z)(t),"removeScenario1AndCloneScenario2and3",(function(){var e=t.state,n=e.option2Portions,r=e.option2TotalRepaymentAmount,o=e.option2TotalAmount,a=e.option2TotalInterest,i=e.option2RepaymentTermYears,u=e.option2TotalPay,s=e.option2TotalTerm,l=e.showOption2Graph,c=e.option3Portions,p=e.option3TotalRepaymentAmount,m=e.option3TotalAmount,h=e.option3TotalInterest,d=e.option3RepaymentTermYears,f=e.option3TotalPay,y=e.option3TotalTerm,g=e.showOption3Graph,v=e.totalLoanBalance,b=e.option2GraphDataPoints,w=e.option3GraphDataPoints;t.setState({maxNumberOfCards:2,numberOfCards:2,showScenario1:!0,showScenario2:!0,showScenario3:!1,option1Portions:n.map((function(e){return D(D({},e),{},{key:(0,I.Z)()})})),option1TotalRepaymentAmount:r,option1TotalAmount:o,option1TotalInterest:a,option1RepaymentTermYears:i,option1EditingPortionKey:"",option1TotalPay:u,option1TotalTerm:s,showOption1Graph:l,option1GraphDataPoints:b,option2Portions:c.map((function(e){return D(D({},e),{},{key:(0,I.Z)()})})),option2TotalRepaymentAmount:p,option2TotalAmount:m,option2TotalInterest:h,option2RepaymentTermYears:d,option2EditingPortionKey:"",option2TotalPay:f,option2TotalTerm:y,showOption2Graph:g,option2GraphDataPoints:w,option3Portions:[{key:(0,I.Z)(),changeType:"term",portionAmount:v,portionRate:"",portionRepaymentsAmount:"",portionRepaymentsFrequency:"fortnight",portionTimeToPay:25,portionTimeToPayYear:25,portionTimeToPayMonth:0}],option3TotalRepaymentAmount:"",option3TotalAmount:"",option3TotalInterest:"",option3RepaymentTermYears:"",option3EditingPortionKey:"",option3TotalPay:"",option3TotalTerm:"",showOption3Graph:!1,option3GraphDataPoints:[],bestOptionIds:[],bestOptionSaveAmount:""},(function(){t.recalculateBestOption(1,u),t.updateGraphData()}))})),(0,d.Z)((0,c.Z)(t),"removeScenario1AndCloneScenario2",(function(){var e=t.state,n=e.option2Portions,r=e.option2TotalRepaymentAmount,o=e.option2TotalAmount,a=e.option2TotalInterest,i=e.option2RepaymentTermYears,u=e.option2TotalPay,s=e.option2TotalTerm,l=e.showOption2Graph,c=e.totalLoanBalance,p=e.option2GraphDataPoints;t.setState({maxNumberOfCards:1,numberOfCards:1,showScenario1:!0,showScenario2:!1,showScenario3:!1,option1Portions:n.map((function(e){return D(D({},e),{},{key:(0,I.Z)()})})),option1TotalRepaymentAmount:r,option1TotalAmount:o,option1TotalInterest:a,option1RepaymentTermYears:i,option1EditingPortionKey:"",option1TotalPay:u,option1TotalTerm:s,showOption1Graph:l,option1GraphDataPoints:p,option2Portions:[{key:(0,I.Z)(),changeType:"term",portionAmount:c,portionRate:"",portionRepaymentsAmount:"",portionRepaymentsFrequency:"fortnight",portionTimeToPay:25,portionTimeToPayYear:25,portionTimeToPayMonth:0}],option2TotalRepaymentAmount:"",option2TotalAmount:"",option2TotalInterest:"",option2RepaymentTermYears:"",option2EditingPortionKey:"",option2TotalPay:"",option2TotalTerm:"",showOption2Graph:!1,option2GraphDataPoints:[],bestOptionIds:[],bestOptionSaveAmount:""},(function(){t.recalculateBestOption(1,u),t.updateGraphData()}))})),(0,d.Z)((0,c.Z)(t),"closeScenario1",(function(){var e=t.state,n=e.showScenario2,r=e.showScenario3,o=e.numberOfCards;n&&r?(t.removeScenario1AndCloneScenario2and3(),t.setActiveItemIndex(0)):n&&!r?t.removeScenario1AndCloneScenario2():t.setState({maxNumberOfCards:3===o?2:1,numberOfCards:o-1,showScenario1:!1}),setTimeout((function(){window.dispatchEvent(new Event("resize"))}),0)})),(0,d.Z)((0,c.Z)(t),"closeScenario2",(function(){var e=t.state,n=e.showScenario3,r=e.numberOfCards,o=e.totalLoanBalance;n?(t.removeScenario2AndCloneScenario3(),t.setActiveItemIndex(0)):t.setState({maxNumberOfCards:3===r?2:1,numberOfCards:r-1,showScenario2:!1,option2Portions:[{key:(0,I.Z)(),changeType:"term",portionAmount:o,portionRate:"",portionRepaymentsAmount:"",portionRepaymentsFrequency:"fortnight",portionTimeToPay:25,portionTimeToPayYear:25,portionTimeToPayMonth:0}],option2TotalRepaymentAmount:"",option2TotalAmount:"",option2TotalInterest:"",option2RepaymentTermYears:"",option2EditingPortionKey:"",option2TotalPay:"",option2TotalTerm:"",showOption2Graph:!1,option2GraphDataPoints:[],bestOptionIds:[],bestOptionSaveAmount:""},(function(){t.recalculateBestOption(2,null),t.updateGraphData()})),setTimeout((function(){window.dispatchEvent(new Event("resize"))}),0)})),(0,d.Z)((0,c.Z)(t),"closeScenario3",(function(){var e=t.state,n=e.numberOfCards,r=e.showScenario2,o=e.totalLoanBalance;r&&t.setActiveItemIndex(0),t.setState({maxNumberOfCards:3===n?2:1,numberOfCards:n-1,showScenario3:!1,option3Portions:[{key:(0,I.Z)(),changeType:"term",portionAmount:o,portionRate:"",portionRepaymentsAmount:"",portionRepaymentsFrequency:"fortnight",portionTimeToPay:25,portionTimeToPayYear:25,portionTimeToPayMonth:0}],option3TotalRepaymentAmount:"",option3TotalAmount:"",option3TotalInterest:"",option3RepaymentTermYears:"",option3EditingPortionKey:"",option3TotalPay:"",option3TotalTerm:"",showOption3Graph:!1,option3GraphDataPoints:[],bestOptionIds:[],bestOptionSaveAmount:""},(function(){t.recalculateBestOption(3,null),t.updateGraphData()})),setTimeout((function(){window.dispatchEvent(new Event("resize"))}),0)})),(0,d.Z)((0,c.Z)(t),"showScenario1",(function(){t.setActiveItemIndex(0)})),(0,d.Z)((0,c.Z)(t),"showScenario2",(function(){t.setActiveItemIndex(1)})),(0,d.Z)((0,c.Z)(t),"showScenario3",(function(){t.setActiveItemIndex(2)})),(0,d.Z)((0,c.Z)(t),"getChartLeftMargin",(function(){var e=t.state,n=e.isMobile,r=e.axisLeftTickValues,o=Math.max.apply(Math,(0,u.Z)(r||[]));if(n){if(Number.isFinite(o))switch("".concat(Math.trunc(o)).length){case 1:default:return 50;case 2:return 55;case 3:return 60;case 4:return 70;case 5:return 80;case 6:return 85;case 7:return 95;case 8:return 100;case 9:return 105}return 50}return 130})),(0,d.Z)((0,c.Z)(t),"getPortionAmountsTooLargeBalance",(function(e,n){return"".concat(e>n?"+":"-")+t.formatCurrency(Math.abs(e-n))})),(0,d.Z)((0,c.Z)(t),"fixGraphTooltipPosition",(function(){setTimeout((function(){var e=document.querySelectorAll("div.graph-tooltip");e.length&&(e[0].parentNode.style.left="0px",setTimeout((function(){var t=e[0].getBoundingClientRect();if(t.left<0){var n=Math.trunc(Math.abs(t.left))+10;setTimeout((function(){e[0].parentNode.style.left="".concat(n,"px")}),100)}else if(t.right>document.documentElement.clientWidth){var r=Math.trunc(t.right-document.documentElement.clientWidth)+10;setTimeout((function(){e[0].parentNode.style.left="-".concat(r,"px")}),100)}}),300))}),200)})),(0,d.Z)((0,c.Z)(t),"updateRateToCustom",(function(e){var t=!1;return{newPortions:e.map((function(e){var n=D({},e);return"custom"!==n.portionRate&&(n.portionRate="custom",t=!0),n})),updated:t}})),(0,d.Z)((0,c.Z)(t),"updateRateAsPerValidRates",(function(e){if(!e){var n=t.state,r=n.option1Portions,o=n.option2Portions,a=n.option3Portions,i=t.updateRateToCustom(r),u=t.updateRateToCustom(o),s=t.updateRateToCustom(a);i.updated&&t.recalculatePortionResults(1,i.newPortions),u.updated&&t.recalculatePortionResults(2,u.newPortions),s.updated&&t.recalculatePortionResults(3,s.newPortions)}})),t.inputsRef=a.createRef(),t.resultsRef=a.createRef(),t.config=structureConfig,t.urlParameters=b().parse(e.location.search,{ignoreQueryPrefix:!0}),t.rates="undefined"!=typeof rates?rates:{},t.state={},t.portionRepaymentsFrequencyList=[{value:"month",label:t.config.naturalLanguage.frequency.month},{value:"fortnight",label:t.config.naturalLanguage.frequency.fortnight},{value:"week",label:t.config.naturalLanguage.frequency.week}],t.checkGetPreviewConfig(),t.isProduction=!1,t.calcEngine=new f.KiwibankStructureEngine,t.calcIsReady=!1,t}return(0,l.Z)(o,[{key:"componentDidMount",value:function(){window.addEventListener("resize",this.updateDimensions),this.havePreviewConfig||this.initCalc(),setTimeout((function(){window.dispatchEvent(new Event("resize"))}),0)}},{key:"componentWillUnmount",value:function(){window.removeEventListener("resize",this.updateDimensions)}},{key:"componentDidUpdate",value:function(e,t){var n=this.checkIfRatesAreValid();n||""===this.state.interestRate?t.validRates!==this.state.validRates&&this.setState({validRates:n}):this.setState({interestRate:"",validRates:!1})}},{key:"initCalc",value:function(){var e=this;this.config=structureConfig;var t=this.checkIfRatesAreValid(),n=window.innerWidth<1200,r=window.innerWidth<870,o={totalLoanBalance:"",showScreen2:!1,validRates:t,activeItemIndex:0,maxNumberOfCards:1,numberOfCards:1,showScenario1:!0,showScenario2:!1,showScenario3:!1,width:window.innerWidth,isMobile:n,isSmallHelpButtonBreakpoint:r,option1Portions:[{key:(0,I.Z)(),changeType:"term",portionAmount:"",portionRate:"",portionRepaymentsAmount:"",portionRepaymentsFrequency:"fortnight",portionTimeToPay:25,portionTimeToPayYear:25,portionTimeToPayMonth:0}],option2Portions:[{key:(0,I.Z)(),changeType:"term",portionAmount:"",portionRate:"",portionRepaymentsAmount:"",portionRepaymentsFrequency:"fortnight",portionTimeToPay:25,portionTimeToPayYear:25,portionTimeToPayMonth:0}],option3Portions:[{key:(0,I.Z)(),changeType:"term",portionAmount:"",portionRate:"",portionRepaymentsAmount:"",portionRepaymentsFrequency:"fortnight",portionTimeToPay:25,portionTimeToPayYear:25,portionTimeToPayMonth:0}],helpTooltipScreen2:!1,helpTooltipAccordionActiveKey:"",option1TotalRepaymentAmount:"",option1TotalAmount:"",option1TotalInterest:"",option1RepaymentTermYears:"",option2TotalRepaymentAmount:"",option2TotalAmount:"",option2TotalInterest:"",option2RepaymentTermYears:"",option3TotalRepaymentAmount:"",option3TotalAmount:"",option3TotalInterest:"",option3RepaymentTermYears:"",option1EditingPortionKey:"",option2EditingPortionKey:"",option3EditingPortionKey:"",bestOptionIds:[],bestOptionSaveAmount:"",option1TotalPay:"",option2TotalPay:"",option3TotalPay:"",showOption1Graph:!1,showOption2Graph:!1,showOption3Graph:!1,graphData:[],option1GraphDataPoints:[],option2GraphDataPoints:[],option3GraphDataPoints:[]};if(this.cookies=new w.Z,!this.updateParamsFromQS(o)){var a=this.cookies.get("structureCalculatorParams"),i=a?window.atob(a):null,u=this.reconstructDataFromString(i);Object.keys(u).forEach((function(e){o[e]=u[e]}))}this.calcIsReady=!0,this.setState(o,(function(){e.recalculatePortionResults(1,o.option1Portions),e.recalculatePortionResults(2,o.option2Portions),e.recalculatePortionResults(3,o.option3Portions)}))}},{key:"checkGetPreviewConfig",value:function(){var e=this,t=this.urlParameters.config;t&&(this.havePreviewConfig=!0,(0,E.Z)(t).then((function(e){if(200!==e.status)throw new Error("Network response was not OK");return e.data})).then((function(e){var t,n,r=e.config.replace(/^(\s*?let\s+?)/,"");(n=(t=document).createElement("script")).type="text/javascript",n.async=!1,n.defer=!1,n.innerText=r,t.getElementsByTagName("head")[0].appendChild(n)})).finally((function(){e.initCalc()})))}},{key:"checkIfRatesAreValid",value:function(){if("undefined"==typeof rates)return!1;if(void 0===rates.Rates)return!1;for(var e=0,t=!1;e18e5&&(t=!0)}if(!t){var o=this.getMatchingProducts("special");o.length<2&&(t=!0),(o=this.getMatchingProducts("standard")).length<2&&(t=!0)}return!t}},{key:"scrollCalc",value:function(e){window.self!==window.top?setTimeout((function(){window.parent.postMessage({task:"scroll_to",offset:e},"*")}),50):window.scrollTo(0,e)}},{key:"handleScrollToInputs",value:function(){this.scrollCalc(this.inputsRef.current.offsetTop)}},{key:"getInterestList",value:function(e){return this.checkIfRatesAreValid()?this.getMatchingProducts(e):[{id:"",value:"",label:"Select"}]}},{key:"getMatchingProducts",value:function(e){var t=[];t.push({value:"",label:"Select"});for(var n="standard"===e?this.config.interestRatesList:this.config.interestRatesSpecialList,r=rates.Rates,o=0;o1&&s?a.createElement("div",{className:"tab-wrapper ".concat(0===o?"active":"inactive")},a.createElement(P.zxk,{type:"button",className:"scenario-tab",onClick:this.showScenario1},"".concat(this.config.portion.labels.header," 1")),a.createElement(P.zxk,{type:"button",className:"close-button-mobile",onClick:this.closeScenario1})):null,u>1&&l?a.createElement("div",{className:"tab-wrapper ".concat(1===o?"active":"inactive")},a.createElement(P.zxk,{type:"button",className:"scenario-tab",onClick:this.showScenario2},"".concat(this.config.portion.labels.header," 2")),a.createElement(P.zxk,{type:"button",className:"close-button-mobile",onClick:this.closeScenario2})):null,u>1&&c?a.createElement("div",{className:"tab-wrapper ".concat(2===o?"active":"inactive")},a.createElement(P.zxk,{type:"button",className:"scenario-tab",onClick:this.showScenario3},"".concat(this.config.portion.labels.header," 3")),a.createElement(P.zxk,{type:"button",className:"close-button-mobile",onClick:this.closeScenario3})):null):"",a.createElement(L(),{requestToChangeActive:this.setActiveItemIndex,activeItemIndex:o,numberOfCards:p?1:i,gutter:10,leftChevron:fe,rightChevron:ye,outsideChevron:!0,chevronWidth:40,showSlither:!1,disableSwipe:!0,classes:ge,infiniteLoop:u>1},[s?a.createElement("div",{key:"1",className:"results-parent-wrapper ".concat(ae?"note-text-background":"")},a.createElement(a.Fragment,null,u>1&&!p?a.createElement(P.zxk,{type:"button",className:"close-button-desktop",onClick:this.closeScenario1}):null,a.createElement(C,{deletePortionFunc:this.deletePortionFunc,editingPortionKey:B,optionId:1,portionRepaymentsFrequencyList:this.portionRepaymentsFrequencyList,addPortionClickFunc:this.addPortionClickFunc,portionsValuesUpdateFunc:this.portionsValuesUpdateFunc,portions:d,portionCustomRateMin:this.config.minValues.portionCustomRate,portionCustomRateMax:this.config.maxValues.portionCustomRate,portionAmountMax:this.config.maxValues.portionAmount,portionAmountMin:this.config.minValues.portionAmount,portionTimeToPayMin:this.config.minValues.portionTimeToPay,portionTimeToPayMax:this.config.maxValues.portionTimeToPay,portionRateList:X,validRates:ve,numberOfCards:u,isMobile:p,portionAmountsTooLarge:ae,portionAmountsTooLargeBalance:ae?this.getPortionAmountsTooLargeBalance(n,ne):"",onSubmit:this.onSubmitResults})),a.createElement("div",null,S.includes(1)&&a.createElement("div",{className:"portion-save-wrapper"},a.createElement("span",null,"Of the options compared, this structure could reduce total interest paid by ".concat(this.formatCurrency(D,0,0),".*")),a.createElement("div",{className:"arrow"})),a.createElement("div",{className:"portion-results-wrapper"},a.createElement("div",{className:"results-table-wrapper"},a.createElement("div",{className:"results-table-row"},a.createElement(P.J$v,null,this.config.resultsPanel.labels.totalRepayment),a.createElement("span",null,g&&!ae?g:"$ -")),a.createElement("div",{className:"results-table-row"},a.createElement(P.J$v,null,this.config.resultsPanel.labels.term),a.createElement("span",null,b&&!ae?b:"-")),a.createElement("div",{className:"results-table-row"},a.createElement(P.J$v,null,this.config.resultsPanel.labels.totalBorrowing),a.createElement("span",null,n&&!ae?this.formatCurrency(n):"$ -")),a.createElement("div",{className:"results-table-row"},a.createElement(P.J$v,null,this.config.resultsPanel.labels.totalInterest),a.createElement("span",null,K&&!ae?K:"$ -")),a.createElement("div",{className:"results-table-row"},a.createElement(P.J$v,null,this.config.resultsPanel.labels.totalPay),a.createElement("span",null,v&&!ae?v:"$ -")),pe&&a.createElement("div",{className:"results-table-row"},a.createElement(P.zxk,{type:"button",className:"graph-button ".concat(se?"":"not-show"),onClick:function(){return e.graphButtonClick()}},a.createElement("div",{className:"graph-icon"}),"".concat("".concat(O?this.config.resultsPanel.graphButton.hidePrefix:this.config.resultsPanel.graphButton.viewPrefix)," ").concat(this.config.resultsPanel.graphButton.suffix))))))):null,l?a.createElement("div",{key:"2",className:"results-parent-wrapper ".concat(ie?"note-text-background":"")},a.createElement(a.Fragment,null,u>1?a.createElement(P.zxk,{type:"button",className:"close-button-desktop",onClick:this.closeScenario2}):null,a.createElement(C,{deletePortionFunc:this.deletePortionFunc,editingPortionKey:E,optionId:2,portionRepaymentsFrequencyList:this.portionRepaymentsFrequencyList,addPortionClickFunc:this.addPortionClickFunc,portionsValuesUpdateFunc:this.portionsValuesUpdateFunc,portions:f,portionCustomRateMin:this.config.minValues.portionCustomRate,portionCustomRateMax:this.config.maxValues.portionCustomRate,portionAmountMax:this.config.maxValues.portionAmount,portionAmountMin:this.config.minValues.portionAmount,portionTimeToPayMin:this.config.minValues.portionTimeToPay,portionTimeToPayMax:this.config.maxValues.portionTimeToPay,portionRateList:ee,validRates:ve,numberOfCards:u,isMobile:p,portionAmountsTooLarge:ie,portionAmountsTooLargeBalance:ie?this.getPortionAmountsTooLargeBalance(n,re):"",onSubmit:this.onSubmitResults})),a.createElement("div",null,S.includes(2)&&a.createElement("div",{className:"portion-save-wrapper"},a.createElement("span",null,"Of the options compared, this structure could reduce total interest paid by ".concat(this.formatCurrency(D,0,0),".*")),a.createElement("div",{className:"arrow"})),a.createElement("div",{className:"portion-results-wrapper"},a.createElement("div",{className:"results-table-wrapper"},a.createElement("div",{className:"results-table-row"},a.createElement(P.J$v,null,this.config.resultsPanel.labels.totalRepayment),a.createElement("span",null,w&&!ie?w:"$ -")),a.createElement("div",{className:"results-table-row"},a.createElement(P.J$v,null,this.config.resultsPanel.labels.term),a.createElement("span",null,T&&!ie?T:"-")),a.createElement("div",{className:"results-table-row"},a.createElement(P.J$v,null,this.config.resultsPanel.labels.totalBorrowing),a.createElement("span",null,n&&!ie?this.formatCurrency(n):"$ -")),a.createElement("div",{className:"results-table-row"},a.createElement(P.J$v,null,this.config.resultsPanel.labels.totalInterest),a.createElement("span",null,J&&!ae?J:"$ -")),a.createElement("div",{className:"results-table-row"},a.createElement(P.J$v,null,this.config.resultsPanel.labels.totalPay),a.createElement("span",null,x&&!ie?x:"$ -")),pe&&a.createElement("div",{className:"results-table-row"},a.createElement(P.zxk,{type:"button",className:"graph-button ".concat(le?"":"not-show"),onClick:function(){return e.graphButtonClick()}},a.createElement("div",{className:"graph-icon"}),"".concat("".concat(F?this.config.resultsPanel.graphButton.hidePrefix:this.config.resultsPanel.graphButton.viewPrefix)," ").concat(this.config.resultsPanel.graphButton.suffix))))))):null,c?a.createElement("div",{key:"3",className:"results-parent-wrapper ".concat(ue?"note-text-background":"")},a.createElement(a.Fragment,null,u>1?a.createElement(P.zxk,{type:"button",className:"close-button-desktop",onClick:this.closeScenario3}):null,a.createElement(C,{deletePortionFunc:this.deletePortionFunc,editingPortionKey:I,optionId:3,portionRepaymentsFrequencyList:this.portionRepaymentsFrequencyList,addPortionClickFunc:this.addPortionClickFunc,portionsValuesUpdateFunc:this.portionsValuesUpdateFunc,portions:y,portionCustomRateMin:this.config.minValues.portionCustomRate,portionCustomRateMax:this.config.maxValues.portionCustomRate,portionAmountMax:this.config.maxValues.portionAmount,portionAmountMin:this.config.minValues.portionAmount,portionTimeToPayMin:this.config.minValues.portionTimeToPay,portionTimeToPayMax:this.config.maxValues.portionTimeToPay,portionRateList:te,validRates:ve,numberOfCards:u,isMobile:p,portionAmountsTooLarge:ue,portionAmountsTooLargeBalance:ue?this.getPortionAmountsTooLargeBalance(n,oe):"",onSubmit:this.onSubmitResults})),a.createElement("div",null,S.includes(3)&&a.createElement("div",{className:"portion-save-wrapper"},a.createElement("span",null,"Of the options compared, this structure could reduce total interest paid by ".concat(this.formatCurrency(D,0,0),".*")),a.createElement("div",{className:"arrow"})),a.createElement("div",{className:"portion-results-wrapper"},a.createElement("div",{className:"results-table-wrapper"},a.createElement("div",{className:"results-table-row"},a.createElement(P.J$v,null,this.config.resultsPanel.labels.totalRepayment),a.createElement("span",null,M&&!ue?M:"$ -")),a.createElement("div",{className:"results-table-row"},a.createElement(P.J$v,null,this.config.resultsPanel.labels.term),a.createElement("span",null,k&&!ue?k:"-")),a.createElement("div",{className:"results-table-row"},a.createElement(P.J$v,null,this.config.resultsPanel.labels.totalBorrowing),a.createElement("span",null,n&&!ue?this.formatCurrency(n):"$ -")),a.createElement("div",{className:"results-table-row"},a.createElement(P.J$v,null,this.config.resultsPanel.labels.totalInterest),a.createElement("span",null,$&&!ae?$:"$ -")),a.createElement("div",{className:"results-table-row"},a.createElement(P.J$v,null,this.config.resultsPanel.labels.totalPay),a.createElement("span",null,A&&!ue?A:"$ -")),pe&&a.createElement("div",{className:"results-table-row"},a.createElement(P.zxk,{type:"button",className:"graph-button ".concat(ce?"":"not-show"),onClick:function(){return e.graphButtonClick()}},a.createElement("div",{className:"graph-icon"}),"".concat("".concat(N?this.config.resultsPanel.graphButton.hidePrefix:this.config.resultsPanel.graphButton.viewPrefix)," ").concat(this.config.resultsPanel.graphButton.suffix))))))):null]),a.createElement("div",null,1!==u||p?null:a.createElement("div",{className:"duplicate-wrapper-desktop ".concat(ve?"":"rates-error-message"," ").concat(pe?"with-graph-button":"")},a.createElement(P.zxk,{type:"button",onClick:this.duplicatePanel},a.createElement("div",{className:"duplicate-icon"}),a.createElement("div",{className:"duplicate-to"},"Duplicate to"),a.createElement("div",{className:"compare"},"compare"),a.createElement("div",{className:"another"},"another option"))),2!==u||p?null:a.createElement("div",{className:"duplicate-wrapper-small"},a.createElement(P.zxk,{type:"button",onClick:this.duplicatePanel}))))):"",r&&a.createElement("div",{className:"footer-div ".concat(pe?"with-graph-button":""," ").concat(p?"is-mobile":"")},V.length?a.createElement(P.wWH,{margin:{top:50,right:p?40:150,bottom:p?3===V.length?140:2===V.length?120:100:75,left:this.getChartLeftMargin()},data:V,theme:{textColor:"#fff",axis:{ticks:{text:{fontSize:p?"11px":"17px"},line:{stroke:"#fff"}},legend:{text:{fontSize:"12px"}}},legends:{text:{fontSize:p?"11px":"14px"}}},xScale:{type:"linear",max:_},yScale:{type:"linear",max:z},axisLeft:{legend:this.config.graph.labels.axisLeft,legendPosition:"start",legendOffset:-15,tickPadding:20,tickValues:U,format:function(t){return e.formatCurrency(t)}},axisBottom:{legend:this.config.graph.labels.axisBottom,legendPosition:"start",legendOffset:15,tickPadding:20,tickValues:W},gridXValues:[0],gridYValues:[0],enablePointLabel:!1,enableArea:!0,enableSlices:"x",sliceTooltip:function(t){p&&e.fixGraphTooltipPosition();var n=t.slice.points[0].data.x;return Number.isInteger(n)?a.createElement("div",{className:"graph-tooltip"},a.createElement("div",{className:"graph-tooltip-header"},"Year ".concat(n)),t.slice.points.map((function(t){return a.createElement("div",{key:t.serieId,className:"graph-tooltip-row"},a.createElement("div",{className:"option-name"},a.createElement("span",{className:"option-color",style:{"background-color":t.color}}),a.createElement("span",null,t.serieId)),a.createElement("div",{className:"option-balance"},e.formatCurrency(t.data.y)))}))):null},pointSymbol:function(e){return 0===e.datum.x||0===e.datum.y?a.createElement("circle",{r:"5",fill:e.color,stroke:e.borderColor,strokeWidth:"2"}):null},legends:p?[{anchor:"bottom",direction:"column",justify:!1,translateY:3===V.length?120:2===V.length?100:80,itemsSpacing:0,itemDirection:"left-to-right",itemWidth:80,itemHeight:20,itemOpacity:.75,symbolSize:12,symbolShape:"circle",symbolBorderColor:"rgba(0, 0, 0, .5)",effects:[{on:"hover",style:{itemBackground:"rgba(0, 0, 0, .03)",itemOpacity:1}}]}]:void 0}):null),r&&u<3&&p?a.createElement("div",{className:"duplicate-wrapper-mobile"},a.createElement(P.zxk,{type:"button",onClick:this.duplicatePanel},a.createElement("div",{className:"duplicate-icon"}),a.createElement("div",{className:"compare"},"Duplicate to compare"),a.createElement("div",{className:"another"},"another option"))):null,r?a.createElement(a.Fragment,null,a.createElement("div",{className:"footer"},a.createElement("div",null,a.createElement("div",null,this.config.cta.title),a.createElement("div",{className:"sub-text"},this.config.cta.subtext)),a.createElement(P.zxk,{type:"button",mode:"primary",onClick:function(){window.open("".concat(e.getCTALink(e.state)))}},this.config.cta.applyNowText)),a.createElement("div",{className:"email-wrapper"},"Email yourself this calculation"),a.createElement("div",{className:"learn-more-wrapper"},"Learn more about the home loan journey"),ve?a.createElement("div",{className:"last-update-wrapper"},a.createElement("p",{className:"last-update"},"Rates last updated at: ",this.calcTime(new Date(rates.DateCreated),"+12")+" (New Zealand Standard Time)")):a.createElement("div",{className:"last-update-wrapper"},a.createElement("p",{className:"last-update"},this.config.results.invalidRatesFile)),r?a.createElement("a",{href:de,target:"_blank",rel:"noreferrer nofollow"},a.createElement("div",{className:"gbst-icon"})):null):""),a.createElement("div",{className:"disclaimer"}),a.createElement("div",{className:"logo-name"},a.createElement("a",{href:de,target:"_blank",rel:"noreferrer nofollow",style:"true"===me?{}:{display:"none"}},"GBST")))}}]),o}(a.Component);O.propTypes={location:g().shape({search:g().string})},O.defaultProps={location:{}};var F=O,N=function(e){var t=e.className,n=e.children;return a.createElement("div",{className:T()("PageWrapper",t)},n)};N.propTypes={className:g().string,children:g().oneOfType([g().string,g().arrayOf(g().node),g().node])},N.defaultProps={className:"",children:""};var V=N,q=document.getElementById("app");q&&(0,i.render)(a.createElement(V,null,a.createElement(r.BrowserRouter,null,a.createElement("div",null,a.createElement(o.rs,null,a.createElement(o.AW,{path:"/partners-widgets/gbst/ltv/calculator/interactive/",component:F}),a.createElement(o.AW,{path:"/",component:F}))))),q)},91939:function(e,t){"use strict";function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function r(e,t){for(var r=0;r0&&i0;){var T=this.getTotalLumpSumAmount(t,0);if(0===a)i=o-T,c.push({year:r,i:0,exitFeesAmount:x,ongoingsFeesAmount:0,payment:0,adjustedBalance:0,interest:0,totalInterestPaid:0,extraRepayment:0,lumpsumAmount:T,closingBalance:i}),u=i;else{var M=this.isFullYear(a,h);r=M?this.getCurrentYear(a,h):"";var R=this.getPayment(p,e,n,m,h,a),A=0===a||M?this.getTotalLumpSumAmount(t,r):0,k=M?this.getOngoingFeesAmount(w,P):0;l+=k;var C=u-A<0?0:u-A,B=C*(this.getInterestRate(p,d,f,y,m,h,a)/h);s+=B;var L=this.getPrincipal(C,R,B),E=this.getExtraRepayment4By2Rule(p,v,g,m,h,a);u=i=L-b-E,c.push({year:r,i:a,exitFeesAmount:0,ongoingsFeesAmount:k,payment:R+E,adjustedBalance:C,interest:B,totalInterestPaid:s,extraRepayment:b,lumpsumAmount:A,closingBalance:i})}a++}var I=this.getGraphData(e,t,s,c,n);return{totalPayment:t.principal+s+l+x,totalInterestPaid:s,totalSummaryList:I.totalSummaryList,totalPeriods:a,debugList:I.debugList}}},{key:"get4By2Calculations",value:function(e,t,n,r,o){var a,i;return a=this.pmt(e,t/12,n/r*12),{repaymentDifference:(i=26===r?a/2:a/4)-o,repaymentBy42Calculation:i}}},{key:"getTimeSaved",value:function(e,t,n,r){var o=e-1,a=(e-1)%n,i=t-1,u=(t-1)%r/r*12,s=12*Math.floor(o/n)+Math.round(a/n*12)-(12*Math.floor(i/r)+Math.round(u));return{years:s<0?Math.ceil(s/12):Math.floor(s/12),months:s<0?-Math.abs(s)%12:Math.abs(s)%12}}},{key:"getRepaymentsSaved",value:function(e,t,n,r,o){var a=t+n,i=e;return n!==o&&(i=e*r/o),Math.round(i)-Math.round(a)}},{key:"calculateRemainingPrincipal",value:function(e,t,n,r){return e*((1-Math.pow(1+t/n,-r))/(t/n))}},{key:"calculateNPER",value:function(e,t,n,r,o){var a=void 0===o?0:o,i=t*(1+e*a)-(void 0===r?0:r)*e,u=n*e+t*(1+e*a);return Math.log(i/u)/Math.log(1+e)}},{key:"getClientSummary",value:function(e){var t={},n=e.clientLoan.principal,r=e.clientLoan.term,o=e.clientLoan.interestRate,a=e.clientLoan.hasSecondRate,i=this.isInterestOnly(e.clientLoan.loanType),u=e.clientLoan.introductoryTerm,s=e.clientLoan.introductoryRate,l=e.clientLoan.remainingRate,c=e.clientLoan.frequency,p=0,m=0,h=r*c-u*c,d=0;if(a)if(i)p=n*(s/c),m=this.pmt(n,l/c,h),t=this.calculateLoan(p,e.clientLoan,m);else{p=this.pmt(n,s/c,r*c);var f=this.calculateRemainingPrincipal(p,s,c,c*(r-u));m=this.pmt(f,l/c,h),t=this.calculateLoan(p,e.clientLoan,m)}else d=this.pmt(n,o/c,r*c),t=this.calculateLoan(d,e.clientLoan),p=d,m=d;return{summary:t,pmt1:d,pmtClientIntro:p,pmtClientRemaining:m}}},{key:"getAthenaSummary",value:function(e){var t,n,r,o=e.athenaLoan,a=o.principal,i=o.term,u=o.hasSecondRate,s=o.interestRate,l=o.introductoryRate,c=o.introductoryTerm,p=o.remainingRate,m=o.frequency,h=o.loanType,d=this.isInterestOnly(h),f=12===m,y=i*m-c*m,g=p/m,v=0,b={},w={};if(u){if(d)t=a*(l/m),n=this.pmt(a,g,y);else{t=this.pmt(a,l/m,i*m);var P=this.calculateRemainingPrincipal(t,l,m,m*(i-c));n=this.pmt(P,g,y)}if(!f)if(d)b=this.get4By2Calculations(a,p,y,m,n),e.athenaLoan.extraRepayment4By2Rule=b.repaymentDifference;else{w=this.get4By2Calculations(a,l,i*m,m,t);var x=this.calculateNPER(l/m,w.repaymentBy42Calculation,-a,0,0),T=this.calculateRemainingPrincipal(w.repaymentBy42Calculation,l,m,x-c*m);b=this.get4By2Calculations(T,p,y,m,n),e.athenaLoan.extraRepayment4By2RuleIntro=w.repaymentDifference,e.athenaLoan.extraRepayment4By2Rule=b.repaymentDifference}r=this.calculateLoan(t,e.athenaLoan,n),t+=e.athenaLoan.extraRepayment4By2RuleIntro?e.athenaLoan.extraRepayment4By2RuleIntro:0,n+=e.athenaLoan.extraRepayment4By2Rule?e.athenaLoan.extraRepayment4By2Rule:0}else{var M=this.pmt(a,s/m,i*m);f||(b=this.get4By2Calculations(a,s,i*m,m,M),e.athenaLoan.extraRepayment4By2Rule=b.repaymentDifference),r=this.calculateLoan(M,e.athenaLoan),t=v=f?M:b.repaymentBy42Calculation,n=v}return{summary:r,pmt2Adjusted:v,pmtAthenaIntro:t,pmtAthenaRemaining:n}}},{key:"getEmptyCLientResults",value:function(){return{pmt1:0,pmtClientIntro:0,pmtClientRemaining:0,summary:{debugList:[],totalInterestPaid:0,totalPayment:0,totalPeriods:0,totalSummaryList:[]}}}},{key:"getAthenaCLientResults",value:function(){return{pmt2Adjusted:0,pmtAthenaIntro:0,pmtAthenaRemaining:0,summary:{debugList:[],totalInterestPaid:0,totalPayment:0,totalPeriods:0,totalSummaryList:[]}}}},{key:"getEmptyTimeSaved",value:function(){return{months:0,years:0}}},{key:"calculateAthenaLoanComparison",value:function(e){var t,n,r=e.clientLoan.frequency,o=e.athenaLoan.frequency,a=e.athenaLoan.extraRepayment,i=0===e.clientLoan.term,u=0===e.athenaLoan.term,s=0===e.athenaLoan.interestRate,l=0===e.athenaLoan.introductoryRate,c=0===e.clientLoan.interestRate,p=0===e.clientLoan.introductoryRate,m=0===e.clientLoan.remainingRate,h=i||c||p||m?this.getEmptyCLientResults():this.getClientSummary(e),d=u||s||l?this.getAthenaCLientResults():this.getAthenaSummary(e),f=Math.round(h.pmt1),y=Math.round(h.pmtClientIntro),g=Math.round(h.pmtClientRemaining),v=i||u?this.getEmptyTimeSaved():this.getTimeSaved(h.summary.totalPeriods,d.summary.totalPeriods,r,o),b=u||u?0:this.getRepaymentsSaved(f,d.pmt2Adjusted,a,r,o);return t=i||u||s||l||c||p||m?0:this.getRepaymentsSaved(y,d.pmtAthenaIntro,a,r,o),n=i||u||s||l||c||p||m?0:this.getRepaymentsSaved(g,d.pmtAthenaRemaining,a,r,o),{clientLoan:{monthlyPayments:f,pmtClientIntro:y,pmtClientRemaining:g,interestPaid:h.summary.totalInterestPaid,totalRepayments:h.summary.totalPayment},athenaLoan:{monthlyPayments:Math.round(d.pmt2Adjusted+e.athenaLoan.extraRepayment),pmtAthenaIntro:Math.round(d.pmtAthenaIntro+e.athenaLoan.extraRepayment),pmtAthenaRemaining:Math.round(d.pmtAthenaRemaining+e.athenaLoan.extraRepayment),interestPaid:d.summary.totalInterestPaid,totalRepayments:d.summary.totalPayment},savings:{monthlyPayments:b,introMonthlyPayments:t,ongoingMonthlyPayments:n,interestPaid:h.summary.totalInterestPaid-d.summary.totalInterestPaid,totalRepayments:h.summary.totalPayment-d.summary.totalPayment,timeSaved:v},graphData:{series1:d.summary.totalSummaryList,series2:h.summary.totalSummaryList},clientDebugInfo:h.summary.debugList,athenaDebugInfo:d.summary.debugList}}},{key:"calculateAthenaLoanTeaserRepayments",value:function(e){var t=e.athenaLoan.principal,n=e.athenaLoan.interestRate,r=e.athenaLoan.frequency,o=e.athenaLoan.term*r,a=e.clientLoan.principal,i=e.clientLoan.remainingRate,u=e.clientLoan.frequency,s=e.clientLoan.term*u,l=this.pmt(t,n/r,o),c=this.pmt(a,i/u,s);return{extraRepayment:c-l>0?c-l:0,pmtAthena:l,pmtClient:c}}}])&&r(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();t.default=o},94501:function(e,t,n){"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function o(e,t){for(var n=0;n=o.min&&r<=o.max)return{rate:o.rate,id:o.id};n++}return{rate:0,id:null}}},{key:"getLoanRepayment",value:function(e,t,n){var r=t*this.frequenciesPerYear;return a.pmt(n,e/100/this.frequenciesPerYear,r)}},{key:"getTotalRepayment",value:function(e,t,n,r,o){return e+t+n+r+o}},{key:"getTotalRepaymentUI",value:function(e,t,n,r,o){return Math.round(100*e)/100+Math.round(100*t)/100+Math.round(100*n)/100+Math.round(100*r)/100+Math.round(100*o)/100}},{key:"getPropertyTaxes",value:function(e,t,n){return 0!==e?e:t*(n/100)/12}},{key:"getDefaultInsuranceAmount",value:function(e,t){return e*t/this.frequenciesPerYear}},{key:"getInsuranceResults",value:function(e,t,n){return e||this.getDefaultInsuranceAmount(t,n,this.frequenciesPerYear)}},{key:"getPMIResults",value:function(e,t,n,r){return t<=this.maxLVRNoPMI?0:e||n*r/this.frequenciesPerYear}},{key:"getClosingCosts",value:function(e,t){return e*t}},{key:"getDebtToIncomeRatio",value:function(e,t,n){return(e+t)/(n/this.frequenciesPerYear)*100}},{key:"getRepaymentAmount",value:function(e,t,n){return a.roundDown(e*n-t,this.repaymentRounding)}},{key:"getRangeLoanAmount",value:function(e,t,n,r,o,i,u,s,l,c){var p=((e-t)*n*this.frequenciesPerYear-i*r*n-u*n*this.frequenciesPerYear)/(o+i*n-i*this.defaultClosingCosts*n),m=((e-t)*n*this.frequenciesPerYear-s*r*n-l*n*this.frequenciesPerYear)/(o+s*n-s*this.defaultClosingCosts*n);return a.median(p,m,c)}},{key:"getMaxLoanAmountWithNoPMI",value:function(e){var t=1-(this.maxLVRNoPMI-this.maxLVRNoPMI*this.defaultClosingCosts);return(this.maxLVRNoPMI*e/t+(e-this.defaultClosingCosts*(this.maxLVRNoPMI*e/t))-e)/(1-this.defaultClosingCosts)}},{key:"getRanges",value:function(e){var t=e.annualHouseholdIncome,n=e.downPayment,r=e.monthlyDebtPayment,o=e.loanTerm,i=e.interestRate,u=e.propertyTax,s=e.homeOwnersInsurance,l=e.pmi,c=e.hoa,p=e.taxPercentage,m=t/this.frequenciesPerYear,h=this.getRepaymentAmount(m,r,this.repaymentPercentLower),d=this.getRepaymentAmount(m,r,this.repaymentPercentAffordable),f=this.getRepaymentAmount(m,r,this.repaymentPercentReach),y=this.getRepaymentAmount(m,r,this.repaymentPercentAggressive),g=i/100,v=1-Math.pow(1+g/this.frequenciesPerYear,-o*this.frequenciesPerYear),b=l>0?0:this.defaultPMI,w=s>0?0:this.defaultInsurance,P=u>0?0:p/100,x=b+w+P,T=l+u+s,M=w+P,R=u+s,A=this.getMaxLoanAmountWithNoPMI(n),k=this.getRangeLoanAmount(h,c,v,n,g,x,T,M,R,A),C=this.getRangeLoanAmount(d,c,v,n,g,x,T,M,R,A),B=this.getRangeLoanAmount(f,c,v,n,g,x,T,M,R,A),L=this.getRangeLoanAmount(y,c,v,n,g,x,T,M,R,A),E=a.roundDown(this.getHousePrice(k,n),this.finalPriceRounding),I=a.roundDown(this.getHousePrice(C,n),this.finalPriceRounding),S=a.roundDown(this.getHousePrice(B,n),this.finalPriceRounding),D=a.roundDown(this.getHousePrice(L,n),this.finalPriceRounding);return{repaymentLower:h,repaymentAffordable:d,repaymentReach:f,repaymentAggressive:y,loanAmountLower:k=a.roundDown(k,this.finalPriceRounding),loanAmountAffordable:C=a.roundDown(C,this.finalPriceRounding),loanAmountReach:B=a.roundDown(B,this.finalPriceRounding),loanAmountAggressive:L=a.roundDown(L,this.finalPriceRounding),housePriceLower:E,housePriceAffordable:I,housePriceReach:S,housePriceAggressive:D}}},{key:"getHousePrice",value:function(e,t){return e+(t-this.defaultClosingCosts*e)}},{key:"getResults",value:function(e){var t=e.annualHouseholdIncome,n=e.downPayment,r=e.monthlyDebtPayment,o=e.loanTerm,i=e.interestRate,u=e.propertyTax,s=e.homeOwnersInsurance,l=e.pmi,c=e.hoa,p=e.taxPercentage,m=e.housePrice,h=this.getRanges(e),d=h.housePriceAffordable,f=m>0?m:d;f=Math.min(f,h.housePriceAggressive);var y=((f=Math.max(f,h.housePriceLower))-n)/(1-this.defaultClosingCosts),g=this.getClosingCosts(y,this.defaultClosingCosts),v=n-g,b=this.getLoanRepayment(i,o,y),w=this.getPropertyTaxes(u,f,p),P=this.getInsuranceResults(s,f,this.defaultInsurance),x=a.roundDown(y/f,2),T=this.getPMIResults(l,x,f,this.defaultPMI),M=this.getTotalRepayment(b,w,c,P,T);return{monthlyPayment:M,downPayment:n,housePrice:f,debtToIncomeRatio:this.getDebtToIncomeRatio(M,r,t),breakdown:{principalAndInterest:b,homeOwnersInsurance:P,propertyTax:w,hoaFees:c,pmi:T,closingCosts:g,actualDownPayment:v},ranges:h,defaultHousePrice:d,loanAmount:y,defaultClosingCosts:this.defaultClosingCosts,lvr:x}}}])&&o(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();t.default=i},42665:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=n(31073);function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function a(e,t){for(var n=0;n0?(0,r.endOfMonth)((0,r.addMonths)(t,n-1)):null}},{key:"getApplyExtraRepayment",value:function(e,t){return-1===(0,r.compareAsc)(e,t)}},{key:"getLoanOriginationDate",value:function(e,t,n){return new Date(e.getFullYear()-(t-n),e.getMonth(),e.getDate())}},{key:"getAmortizationAdditionalLoan",value:function(e){for(var t=1,n=e.originalLoanAmount,r=e.frequency,o=e.originalLoanTerm,a=r*o,u=e.interestRate/100,s=this.getLoanOriginationDate(e.currentDate,o,e.remainingTerm),l=e.extraContStartDate,c=i.pmt(n,u/r,a),p=c+e.extraPaymentAmount,m=[],h=0,d=0,f=0,y=-1;t<=a&&y<0;){var g=this.getStartingBalance(t,a,n,h),v=this.getInterestPaidAdditional(g,u,r);d+=v;var b=this.getPaymentDateAdditional(g,s,t),w=this.getApplyExtraRepayment(l,b),P=this.getPrincipalAndRepaymentAdditional(t,a,g,p,v,w,c);f+=P;var x=this.getPrincipalPaidAdditional(t,a,P,v);y=this.getLoanBalance(g,x),m.push({period:t,startingBalance:g,principalPaid:x,interestPaid:v,loanBalance:y,paymentDate:b,applyExtraRepayment:w,principalAndInterestRepayment:P,totalInterestPaid:d,principalAndInterestPaid:f}),h=y,t++}return m}},{key:"getAmortizationCurrentLoan",value:function(e){for(var t=1,n=e.originalLoanAmount,r=e.frequency,o=e.originalLoanTerm,a=r*o,u=e.interestRate/100,s=this.getLoanOriginationDate(e.currentDate,o,e.remainingTerm),l=i.pmt(n,u/r,a),c=[],p=0,m=0,h=0;t<=a;){var d=this.getStartingBalance(t,a,n,p),f=this.getInterestPaidCurrent(t,a,u,r,l,n);m+=f;var y=this.getPrincipalAndRepaymentCurrent(t,a,l);h+=y;var g=this.getPaymentDateCurrent(y,s,t),v=this.getPrincipalPaidCurrent(t,a,u,r,n),b=this.getLoanBalance(d,v);c.push({period:t,startingBalance:d,principalPaid:v,interestPaid:f,loanBalance:b,paymentDate:g,principalAndInterestRepayment:y,totalInterestPaid:m,principalAndInterestPaid:h}),p=b,t++}return c}},{key:"getTineSaved",value:function(e,t,n){var o=(0,r.differenceInYears)(e,t);return{years:o,months:(0,r.differenceInMonths)(e,t)-o*n}}},{key:"getResults",value:function(e){var t=this.getAmortizationCurrentLoan(e),n=this.getAmortizationAdditionalLoan(e),r=t[t.length-1],o=n[n.length-1],a=r.totalInterestPaid-o.totalInterestPaid,i=r.totalInterestPaid,u=this.getTineSaved(r.paymentDate,o.paymentDate,e.frequency),s=a/i*100;return{summary:{difference:{totalInterestSaved:a,principalAndInterestSaved:r.principalAndInterestPaid-o.principalAndInterestPaid,totalTimeSaved:u,percentageSaved:s},currentLoan:{totalInterestPaid:i,principalAndInterestPaid:r.principalAndInterestPaid,payOffDate:r.paymentDate},additionalPayment:{totalInterestPaid:o.totalInterestPaid,principalAndInterestPaid:o.principalAndInterestPaid,payOffDate:o.paymentDate}},currentLoanList:t,additionalLoanList:n}}}])&&a(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();t.default=u},68176:function(e,t,n){"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function o(e,t){for(var n=0;n=n+1)return null;var o=this.pmt(-r,e,n);return o-this.ipmt(e,t-1,o,r)}},{key:"getStateTax",value:function(e){for(var t=this.stateRates,n=0,r=Number(e);n=o.min&&r<=o.max)return o.rate;n++}return 0}},{key:"getOpeningLoanBalance",value:function(e,t,n,r){return e<=t?1===e?-n:r:0}},{key:"getPrincipalPaid",value:function(e,t,n,r,o,a){return e<=t?this.ppmt(n/r,e,o*r,-a):0}},{key:"getInterestPaid",value:function(e,t,n,r,o){var a=n/r,i=this.pmt(o,a,t);return e<=t?this.ipmt(a,e-1,i,-o):0}},{key:"getPrincipalAndInterest",value:function(e,t,n,r,o){return e<=r?this.pmt(t,n/o,r):0}},{key:"getClosingLoanBalance",value:function(e,t){return e+t}},{key:"getPmi",value:function(e,t,n){return-e/t>.8?n:0}},{key:"getHoa",value:function(e,t,n){return e<=t?n:0}},{key:"getTax",value:function(e,t,n){return e<=t?n:0}},{key:"getInsurance",value:function(e,t,n){return e<=t?n:0}},{key:"getDefaultTaxAmount",value:function(e,t,n){return e*t/n}},{key:"getDefaultInsuranceAmount",value:function(e,t,n){return e*t/n}},{key:"getDefaultPMI",value:function(e,t,n,r){return(e/t>.8?t*n:0)/r}},{key:"getPrincipalAndInterestPayment",value:function(e,t,n){return this.pmt(-e,t,n)}},{key:"getTaxResults",value:function(e,t,n,r){return e||this.getDefaultTaxAmount(t,n,r)}},{key:"getInsuranceResults",value:function(e,t,n,r){return e||this.getDefaultInsuranceAmount(t,n,r)}},{key:"getPMIResults",value:function(e,t,n,r,o){return e||this.getDefaultPMI(t,n,r,o)}},{key:"getMonthlyTotal",value:function(e,t,n,r,o){return e+t+n+r+o}},{key:"getResults",value:function(e){for(var t=[],n=12,r=e.term*n,o=e.loanAmount,a=e.interestRate,i=e.interestRate/n,u=e.term,s=e.homePrice,l=e.pmi,c=e.hoa,p=e.tax,m=e.insurance,h=e.taxPercentage,d=this.getTaxResults(p,s,h,n),f=this.getInsuranceResults(m,s,this.defaultInsurance,n),y=this.getPMIResults(l,o,s,this.defaultPMI,n),g=0,v=0,b=0,w=0,P=0,x=0,T=0,M=0;M0?e.homeValue:r,a=t/o,i=e.cashOutRefinance&&a0?e.closingCosts:s,c=this.getRepayment(e.newInterestRate,e.newLoanTerm,u),p=this.mortgageEngine.getResults({term:e.newLoanTerm,loanAmount:u,interestRate:e.newInterestRate/100,homePrice:o,pmi:0,hoa:0,tax:0,insurance:0}),m=this.mortgageEngine.getResults({term:e.remainingTerm,loanAmount:t,interestRate:e.currentInterestRate/100,homePrice:o,pmi:0,hoa:0,tax:0,insurance:0}),h=p.amortizationList.length,d=e.remainingTerm*this.periodsPerYear,f=Math.max(d,h),y=[],g=0,v=0,b=null,w=0;ww?p.amortizationList[w]:null;1===P&&(v+=l),w0&&(b=P),y.push({periodNumber:P,openingLoanBalance:null===x?0:x.openingLoanBalance,closingBalance:null===x?0:x.closingBalance,runningTotal:v,runningTotalOriginal:g,differenceInPayments:T})}var M=null===b?null:Math.round(b/this.periodsPerYear),R=y[y.length-1],A=p.lifetime.totalInterestPaid,k=R?R.runningTotal:0;return{amortizationList:y,currentLoan:{loanRepayment:n,loanInterestPaid:m.lifetime.totalInterestPaid,loanTotalPaid:R?R.runningTotalOriginal:0},newLoan:{loanRepayment:c,loanInterestPaid:A,loanTotalPaid:k},breakEvenPeriod:b,breakEvenYear:M,remainingBalance:t,newStartingBalance:u,homeValue:o,LVR:a,closingCosts:l,cashOutAmount:i}}}])&&i(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();t.default=s},74979:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=a(n(44207)),o=a(n(3005));function a(e){return e&&e.__esModule?e:{default:e}}function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i(e)}function u(e,t){for(var n=0;n1?"s":"");return n>0&&(o+=" and "+n+" month"+(n>1?"s":"")),o}},{key:"checkWithinBounds",value:function(e,t){return e=Math.max(e,t.min),Math.min(e,t.max)}},{key:"calculateOption",value:function(e){var t=e.changeType,n=e.frequencyLoan,o=e.customInterestRate,a={};a.minTerm=this.calculateMinTerm(e),a.minTerm=a.minTerm>this.config.maximumLoanTerm?this.config.maximumLoanTerm:a.minTerm,a.maxTerm=this.config.maximumLoanTerm,"term"===t&&(a.minTerm=Math.ceil(a.minTerm));var i=this.calculateActualTerm(e);i=this.checkWithinBounds(i,{min:a.minTerm,max:this.config.maximumLoanTerm});var u=this.frequencies[n],s=r.default.pmt(e.loanAmount,this.config.maximumInterestRate/100/u,this.config.minimumLoanTerm*u),l=Math.min(12*e.maxRepayments/u,r.default.roundDown(s,2)),c=Math.abs(r.default.rate(e.term*u,l,-e.loanAmount,0,0,0));a.minInterestRate=this.config.minimumInterestRate,a.maxInterestRate=Math.min(r.default.roundDown(c,8)*u*100,this.config.maximumInterestRate),a.customInterestRate=null===o||""===o?"":this.checkWithinBounds(o,{min:a.minInterestRate,max:a.maxInterestRate}),a.customInterestRate&&(e.customInterestRate=a.customInterestRate),a.minRepayment=this.calculateMinRepayment(e),a.maxRepayment=this.calculateMaxRepayment(e);var p=this.calculateRepayment(e);return p=this.checkWithinBounds(p,{min:a.minRepayment,max:a.maxRepayment}),"repayment"===t?(a.term=i,a.termNaturalLanguage=this.getTermNaturalLanguage(i)):a.repaymentsLoan=p,a.totalPay=this.calculateTotalPay(p,i,n),a}},{key:"getZ",value:function(){return(1-Math.pow(1+this.config.bpcr/this.config.borrowingPowerFrequency,-this.config.borrowingPowerTerm*this.config.borrowingPowerFrequency))/(this.config.bpcr/this.config.borrowingPowerFrequency)}},{key:"getAllowableLendingInvestment",value:function(e){var t=e.investmentOwnership,n=e.investmentPropertyValue,r=e.investmentPropertyLoanAmount;return t&&n>0?Math.max(n*this.config.investmentPropertyLVR-r,0):0}},{key:"getAllowableLendingOwnerOccupier",value:function(e){var t=e.ownerOccupierOwnership,n=e.ownerOccupierPropertyValue,r=e.ownerOccupierPropertyLoanAmount;return t&&n>0?Math.max(n*this.config.ownerOccupierLVR-r,0):0}},{key:"getCombinedGrossIncome",value:function(e){var t=e.applicationType,n=e.adult1GrossIncome,r=e.adult2GrossIncome;return"single"===t?n:n+r}},{key:"getTaxPayable",value:function(e){var t=this.getCombinedGrossIncome(e),n={taxBands:this.config.incomeTax,ACCLevyRate:this.config.ACCLevyRate,ACCLevyCap:this.config.ACCMaximumRate};return new o.default("nz",n).calculateNetIncome(t,"nz").totalAnnualTax}},{key:"getAccLevy",value:function(e){return this.getAdult1ACCLevy(e)+this.getAdult2ACCLevy(e)}},{key:"getSuperannuation",value:function(e){return this.getAdult1Superannuation(e)+this.getAdult2Superannuation(e)}},{key:"getNetIncome",value:function(e){return this.getAdult1NetIncome(e)+this.getAdult2NetIncome(e)+this.getRentalIncomeNet(e)}},{key:"getMonthlyNetIncome",value:function(e){return this.getNetIncome(e)/12}},{key:"getAdult1ACCLevy",value:function(e){var t=e.adult1GrossIncome;return t>this.config.ACCMinimumEarning?Math.min(this.config.ACCMaximumRate,t)*this.config.ACCLevyRate:0}},{key:"getAdult1TaxPayable",value:function(e){var t=e.adult1GrossIncome,n={taxBands:this.config.incomeTax,ACCLevyRate:this.config.ACCLevyRate,ACCLevyCap:this.config.ACCMaximumRate};return new o.default("nz",n).calculateNetIncome(t,"nz").totalAnnualTax}},{key:"getAdult1StudentLoan",value:function(e){var t=e.adult1StudentLoan,n=e.adult1GrossIncome;return t&&n>this.config.studentLoanThreshold?Math.max((n-this.config.studentLoanThreshold)*this.config.studentLoanRate,0):0}},{key:"getAdult1Superannuation",value:function(e){return e.adult1GrossIncome*this.config.superannuationRate}},{key:"getAdult1NetIncome",value:function(e){return e.adult1GrossIncome-this.getAdult1TaxPayable(e)-this.getAdult1ACCLevy(e)-this.getAdult1StudentLoan(e)-this.getAdult1Superannuation(e)}},{key:"getAdult2ACCLevy",value:function(e){var t=e.adult2GrossIncome;return t>this.config.ACCMinimumEarning?Math.min(this.config.ACCMaximumRate,t)*this.config.ACCLevyRate:0}},{key:"getAdult2TaxPayable",value:function(e){var t=e.adult2GrossIncome,n={taxBands:this.config.incomeTax,ACCLevyRate:this.config.ACCLevyRate,ACCLevyCap:this.config.ACCMaximumRate};return new o.default("nz",n).calculateNetIncome(t,"nz").totalAnnualTax}},{key:"getAdult2StudentLoan",value:function(e){var t=e.adult2StudentLoan,n=e.adult2GrossIncome;return t&&n>this.config.studentLoanThreshold?Math.max((n-this.config.studentLoanThreshold)*this.config.studentLoanRate,0):0}},{key:"getAdult2Superannuation",value:function(e){return e.adult2GrossIncome*this.config.superannuationRate}},{key:"getAdult2NetIncome",value:function(e){return e.adult2GrossIncome-this.getAdult2TaxPayable(e)-this.getAdult2ACCLevy(e)-this.getAdult2StudentLoan(e)-this.getAdult2Superannuation(e)}},{key:"getRentalIncomeGross",value:function(e){var t=e.investmentOwnership,n=e.investmentPropertyRentalIncome,r=e.investmentPropertyRentalIncomeFrequency;return t?n*this.frequencies[r]:0}},{key:"getRentalIncomeNet",value:function(e){return this.getRentalIncomeGross(e)*this.config.rentalFactor}},{key:"getMonthlyExpenses",value:function(e){var t=e.inputMethod,n=e.expenses,r=e.frequency;return"Breakdown"===t?0:n*this.frequencies[r]/12}},{key:"getMonthlyBenchmarkableExpenses",value:function(e){var t=e.inputMethod,n=e.totalBenchmarkable,r=e.totalInvestmentPropertyBenchmarkable,o=e.totalMainPropertyBenchmarkable,a=e.frequency;return"Breakdown"===t?(n+o+r)*this.frequencies[a]/12:0}},{key:"getCustomerDeclaredMLA",value:function(e){return"Breakdown"===e.inputMethod?this.getMonthlyBenchmarkableExpenses(e):this.getMonthlyExpenses(e)}},{key:"getHEB",value:function(e){return this.getCombinedGrossIncome(e)>=this.config.salaryFloor?this.getHEBBasic(e):0}},{key:"getHEBBasic",value:function(e){var t=e.applicationType,n=e.dependents,r="single"===t?1:2;return Math.exp(this.config.HEPBasicConstant+this.config.HEPBasicIncome*Math.log(this.getCombinedGrossIncome(e))+this.config.HEPBasicHouseholdSize*Math.log(r+this.config.HEPBasicChildWeighting*n)+0*this.config.HEPBasicStandardError+this.config.HEPBasicCPI)/12}},{key:"getHEBDiscretionary",value:function(e){var t=e.applicationType,n=e.dependents,r="single"===t?1:2;return Math.exp(this.config.HEPDiscretionaryConstant+this.config.HEPDiscretionaryIncome*Math.log(this.getCombinedGrossIncome(e))+this.config.HEPDiscretionaryHouseholdSize*Math.log(r+this.config.HEPDiscretionaryChildWeighting*n)+-.674489750196082*this.config.HEPDiscretionaryStandardError+this.config.HEPDiscretionaryCPI)/12}},{key:"getMLA",value:function(e){return Math.max(this.getCustomerDeclaredMLA(e),this.getHEB(e))+this.getAdditionalExpenses(e)}},{key:"getMonthlyDebts",value:function(e){var t=e.debts,n=e.frequency;return t*this.frequencies[n]/12}},{key:"getMonthlyNonBenchmarkableExpenses",value:function(e){var t=e.inputMethod,n=e.frequency,o=e.totalNonBenchmarkable,a=e.totalMainPropertyNonBenchmarkable,i=e.totalInvestmentPropertyNonBenchmarkable,u=r.default.roundDown(this.getRentalIncomeGross(e)*this.config.rentalExpenses/this.frequencies[e.frequency],2),s=0;return e.investmentOwnership&&(s=""===i?0:Math.max(u,i)),"Breakdown"===t?(o+a+s)*this.frequencies[n]/12:0}},{key:"getRentalExpenses",value:function(e){var t=e.investmentOwnership,n=e.inputMethod;return t&&"Total"===n?this.getRentalIncomeGross(e)*this.config.rentalExpenses/12:0}},{key:"getStressedHomeLoanRepayments",value:function(e){var t=e.ownerOccupierOwnership,n=e.ownerOccupierPropertyLoanAmount,o=e.investmentOwnership,a=e.investmentPropertyLoanAmount,i=0;t&&(i=r.default.pmt(n,this.config.bpcr/this.config.borrowingPowerFrequency,this.config.borrowingPowerTerm*this.config.borrowingPowerFrequency));var u=0;return o&&(u=r.default.pmt(a,this.config.bpcr/this.config.borrowingPowerFrequency,this.config.borrowingPowerTerm*this.config.borrowingPowerFrequency)),i+u}},{key:"getRentBoard",value:function(e){var t=e.ownerOccupierOwnership,n=e.rentAmount,r=e.frequency;return t?0:n*this.frequencies[r]/12}},{key:"getLiveInPropertyExpenses",value:function(e){var t=e.ownerOccupierOwnership,n=e.ownerOccupierPropertyValue;return"total"===e.inputMethod.toLowerCase()&&t?n*(this.config.propertyRates+this.config.houseInsuranceRate)/this.config.borrowingPowerFrequency:0}},{key:"getAdditionalExpenses",value:function(e){var t=e.ownerOccupierOwnership,n=e.inputMethod;return t&&"Total"===n?this.config.electricityAllowance+this.config.internetAllowance+this.config.maintenanceAllowance:0}},{key:"getNetMC",value:function(e){return this.getMonthlyDebts(e)+this.getStressedHomeLoanRepayments(e)+this.getRentalExpenses(e)+this.getMonthlyNonBenchmarkableExpenses(e)+this.getRentBoard(e)+this.getLiveInPropertyExpenses(e)}},{key:"getMaxRepayments",value:function(e){var t=Math.max(0,this.getMonthlyNetIncome(e)-(this.getMLA(e)+this.getNetMC(e)));return Math.floor(100*t)/100}},{key:"getMaxPropertyPrice",value:function(e){return 1e3*Math.floor(this.getMaxRepayments(e)*this.config.borrowingPowerFrequency*this.getZ()/(this.config.borrowingPowerFrequency*this.config.defaultLVR)/1e3)}},{key:"getMaxBorrowings",value:function(e){return 1e3*Math.floor(this.getMaxPropertyPrice(e)*this.config.defaultLVR/1e3)}},{key:"getBorrowingPower",value:function(e){var t=e.borrowMoreAmount;return this.getMaxBorrowings(e)>=t*(1-this.config.borrowingTolerance)}},{key:"getEquity",value:function(e){var t=e.borrowMoreAmount,n=this.getAvailableEquity(e);return n>=this.config.borrowingFloor&&n>=t}},{key:"getTotalAllowableLending",value:function(e){return this.getAllowableLendingOwnerOccupier(e)+this.getAllowableLendingInvestment(e)}},{key:"getAvailableEquity",value:function(e){return this.getTotalAllowableLending(e)*this.config.equityPercentage}},{key:"getResult",value:function(e){return this.getBorrowingPower(e)&&this.getAvailableEquity(e)>=this.config.borrowingFloor}},{key:"calculateBorrowingPower",value:function(e,t){var n=s.hexDecode(atob(t.reference));this.config.bpcr=n/100,this.config.borrowingPowerFrequency=void 0!==t.borrowingPowerFrequency?t.borrowingPowerFrequency:this.config.borrowingPowerFrequency,this.config.borrowingPowerTerm=void 0!==t.borrowingPowerTerm?t.borrowingPowerTerm:this.config.borrowingPowerTerm,this.config.overdraftLimitRate=void 0!==t.overdraftLimitRate?t.overdraftLimitRate/100:this.config.overdraftLimitRate,this.config.creditCardLimitRate=void 0!==t.creditCardLimitRate?t.creditCardLimitRate/100:this.config.creditCardLimitRate,this.config.studentLoanThreshold=void 0!==t.studentLoanThreshold?t.studentLoanThreshold:this.config.studentLoanThreshold,this.config.studentLoanRate=void 0!==t.studentLoanRate?t.studentLoanRate/100:this.config.studentLoanRate,this.config.superannuationRate=void 0!==t.superannuationRate?t.superannuationRate/100:this.config.superannuationRate,this.config.HEPBasicIncome=void 0!==t.HEPBasicIncome?t.HEPBasicIncome:this.config.HEPBasicIncome,this.config.HEPBasicConstant=void 0!==t.HEPBasicConstant?t.HEPBasicConstant:this.config.HEPBasicConstant,this.config.HEPBasicHouseholdSize=void 0!==t.HEPBasicHouseholdSize?t.HEPBasicHouseholdSize:this.config.HEPBasicHouseholdSize,this.config.HEPBasicChildWeighting=void 0!==t.HEPBasicChildWeighting?t.HEPBasicChildWeighting:this.config.HEPBasicChildWeighting,this.config.HEPBasicStandardError=void 0!==t.HEPBasicStandardError?t.HEPBasicStandardError:this.config.HEPBasicStandardError,this.config.HEPBasicCPI=void 0!==t.HEPBasicCPI?t.HEPBasicCPI:this.config.HEPBasicCPI,this.config.HEPDiscretionaryIncome=void 0!==t.HEPDiscretionaryIncome?t.HEPDiscretionaryIncome:this.config.HEPDiscretionaryIncome,this.config.HEPDiscretionaryConstant=void 0!==t.HEPDiscretionaryConstant?t.HEPDiscretionaryConstant:this.config.HEPDiscretionaryConstant,this.config.HEPDiscretionaryHouseholdSize=void 0!==t.HEPDiscretionaryHouseholdSize?t.HEPDiscretionaryHouseholdSize:this.config.HEPDiscretionaryHouseholdSize,this.config.HEPDiscretionaryChildWeighting=void 0!==t.HEPDiscretionaryChildWeighting?t.HEPDiscretionaryChildWeighting:this.config.HEPDiscretionaryChildWeighting,this.config.HEPDiscretionaryStandardError=void 0!==t.HEPDiscretionaryStandardError?t.HEPDiscretionaryStandardError:this.config.HEPDiscretionaryStandardError,this.config.HEPDiscretionaryCPI=void 0!==t.HEPDiscretionaryCPI?t.HEPDiscretionaryCPI:this.config.HEPDiscretionaryCPI,this.config.borrowingFloor=void 0!==t.borrowingFloor?t.borrowingFloor:this.config.borrowingFloor,this.config.minimumLVR=void 0!==t.minimumLVR?t.minimumLVR/100:this.config.minimumLVR,this.config.maximumLVR=void 0!==t.maximumLVR?t.maximumLVR/100:this.config.maximumLVR,this.config.minimumInterestRate=void 0!==t.minimumInterestRate?t.minimumInterestRate:this.config.minimumInterestRate,this.config.maximumInterestRate=void 0!==t.maximumInterestRate?t.maximumInterestRate:this.config.maximumInterestRate,this.config.minimumLoanTerm=void 0!==t.minimumLoanTerm?t.minimumLoanTerm:this.config.minimumLoanTerm,this.config.maximumLoanTerm=void 0!==t.maximumLoanTerm?t.maximumLoanTerm:this.config.maximumLoanTerm,this.config.propertyRates=void 0!==t.propertyRates?t.propertyRates/100:this.config.propertyRates,this.config.houseInsuranceRate=void 0!==t.houseInsuranceRate?t.houseInsuranceRate/100:this.config.houseInsuranceRate,this.config.defaultLVR=void 0!==t.defaultLVR?t.defaultLVR/100:this.config.defaultLVR,this.config.rentalFactor=void 0!==t.rentalFactor?t.rentalFactor/100:this.config.rentalFactor,this.config.rentalExpenses=void 0!==t.rentalExpenses?t.rentalExpenses/100:this.config.rentalExpenses,this.config.electricityAllowance=void 0!==t.electricityAllowance?t.electricityAllowance:this.config.electricityAllowance,this.config.internetAllowance=void 0!==t.internetAllowance?t.internetAllowance:this.config.internetAllowance,this.config.maintenanceAllowance=void 0!==t.maintenanceAllowance?t.maintenanceAllowance:this.config.maintenanceAllowance,this.config.salaryFloor=void 0!==t.salaryFloor?t.salaryFloor:this.config.salaryFloor,this.config.investmentPropertyLVR=void 0!==t.investmentPropertyLVR?t.investmentPropertyLVR/100:this.config.investmentPropertyLVR,this.config.ownerOccupierLVR=void 0!==t.ownerOccupierLVR?t.ownerOccupierLVR/100:this.config.ownerOccupierLVR,this.config.equityPercentage=void 0!==t.equityPercentage?t.equityPercentage/100:this.config.equityPercentage,this.config.borrowingTolerance=void 0!==t.borrowingtolerance?t.borrowingtolerance/100:this.config.borrowingTolerance,this.config.incomeTax=void 0!==t.incomeTax?t.incomeTax:this.config.incomeTax,this.config.ACCLevyRate=void 0!==t.ACCLevyRate?t.ACCLevyRate/100:this.config.ACCLevyRate,this.config.ACCMinimumEarning=void 0!==t.ACCMinimumEarning?t.ACCMinimumEarning:this.config.ACCMinimumEarning,this.config.ACCMaximumRate=void 0!==t.ACCMaximumRate?t.ACCMaximumRate:this.config.ACCMaximumRate;var r=this.getAvailableEquity(e),o=this.getBorrowingPower(e),a=this.getEquity(e),i=this.getResult(e);return{result:i,borrowingPower:o,equity:a,availableEquity:r,borrowingPowerAmount:o&&a?Math.max(Math.min(e.borrowMoreAmount,this.getMaxBorrowings(e)),this.config.borrowingFloor):i?r:0,maxRepayments:this.getMaxRepayments(e)}}}])&&u(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();t.default=l},94465:function(e,t,n){"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function a(e){for(var t=1;t=t?n:0}},{key:"getMLA",value:function(e,t){return Math.max(e,t)}},{key:"getNetMC",value:function(e,t){return e+t}},{key:"getMonthlyDebts",value:function(e,t){return e*t/12}},{key:"getNonBenchmarkMonthly",value:function(e,t,n){return"Breakdown"===e?t*n/12:0}},{key:"getAdultTaxPayable",value:function(e){return(new l.default).calculateNetIncome(e,"nz").totalAnnualTax}},{key:"getAdultACCLevy",value:function(e,t,n,r){return e>t?Math.min(n,e)*r:0}},{key:"getAdultStudentLoan",value:function(e,t,n,r){return e?(t-n)*r:0}},{key:"getAdultSuperannuation",value:function(e,t){return e*t}},{key:"getAdultNetIncome",value:function(e,t,n,r,o){return e-(t+n+r+o)}},{key:"getNetIncome",value:function(e,t){return e+t}},{key:"getMonthlyNetIncome",value:function(e){return e/12}},{key:"getMaxRepayments",value:function(e,t,n){var r=Math.max(0,e-(t+n));return Math.floor(100*r)/100}},{key:"getZ",value:function(e,t,n){return(1-Math.pow(1+e/t,-n*t))/(e/t)}},{key:"getMaxPropertyPrice",value:function(e,t,n,r,o,a){return 1e3*Math.floor(e*t*n/(t*r+n*(o+a))/1e3)}},{key:"getMaxBorrowings",value:function(e,t){return 1e3*Math.floor(e*t/1e3)}},{key:"getDefaultProperty",value:function(e,t){return e/t}},{key:"getBorrowingAmount",value:function(e,t,n,r){return"Deposit"===e?Math.min(t/(1-n)-t,r):Math.min(r,t*n)}},{key:"getDepositAmount",value:function(e,t,n,r,o,a){var i="Property Value"===e?Math.max(t/(1-r)-t,n-t):Math.min(n,o/a-o);return c.roundDown(i,0)}},{key:"getPropertyValue",value:function(e,t,n,r){return"Property Value"===e?r:t+n}},{key:"getRepaymentAmount",value:function(e,t,n,r){return c.pmt(r,e/t,n*t)}},{key:"getTotalMortgageAmount",value:function(e,t,n,r){return""===e?0:e>0?t*n*r:0}},{key:"getMultipleOfAmountBorrowing",value:function(e,t,n){return""===e?0:e>0?t/n:0}},{key:"getInterest",value:function(e,t,n){return""===e?0:e>0?t-n:0}},{key:"getBPDetermination",value:function(e,t,n,r,o,a){return!(r=n*t*(1-a)&&n*t>=o:n>=o/t-o)}},{key:"getRepaymentBounds",value:function(e,t,n,r,o){return""===e?{min:0,max:0}:{min:c.roundUp(c.pmt(n,e/t,30*t),2),max:Math.min(12*r/t,c.roundDown(c.pmt(n,e/t,t*o),2))}}},{key:"getTerm",value:function(e,t,n,r){return c.roundUp(c.nper(e/t,n,-r)/t,2)}},{key:"getMinTerm",value:function(e,t,n,r,o,a){if(""===e)return 0;var i=Math.min(12*a/r,c.roundDown(c.pmt(n,e/r,1*r),2));return Math.max(c.roundUp(c.nper(e/r,-i,n)/r,0),o)}},{key:"getMaxInterestRate",value:function(e,t,n,r,o,a){var i=Math.min(12*a/t,c.roundDown(c.pmt(n,o/t,1*t),2));return Math.min(c.roundDown(Math.abs(c.rate(e*t,i,-n,0,0,0)),8)*t*100,r)}},{key:"checkWithinBounds",value:function(e,t){return e=Math.max(e,t.min),Math.min(e,t.max)}},{key:"getLockingValid",value:function(e){var t=this,n=(e||[]).filter((function(e){return t.resultsFieldsValues.includes(e)}));return{validLockFields:Boolean(e&&e.length===this.resultsFieldsValues.length-2&&e.every((function(e){return t.resultsFieldsValues.includes(e)}))),correctedLockedFields:n}}},{key:"roundMinMaxes",value:function(e){e.borrowingAmountMax=Math.floor(e.borrowingAmountMax),e.borrowingAmountMin=Math.ceil(e.borrowingAmountMin),e.propertyValueMax=Math.floor(e.propertyValueMax),e.propertyValueMin=Math.ceil(e.propertyValueMin),e.depositAmountMax=Math.floor(e.depositAmountMax),e.depositAmountMin=Math.ceil(e.depositAmountMin)}},{key:"getLockingMinMax",value:function(e,t,n,r,o,a,i,u,s){var l={depositAmountMax:r,depositAmountMin:r,borrowingAmountMin:a,borrowingAmountMax:a,propertyValueMax:o,propertyValueMin:o},c=1-u;if(e){if(!t&&!n)return l.propertyValueMin=a/c,l.propertyValueMax=a/s.minimumLVR,this.checkCorrectMinMax.propertyValue(l,i,s.minimumLVR,l.borrowingAmountMin,r),l.depositAmountMin=a/c-a,l.depositAmountMax=a/s.minimumLVR-a,this.checkCorrectMinMax.depositAmount(l,i,c,s.borrowingFloor,s.minimumLVR,l.borrowingAmountMin,l.propertyValueMax),this.roundMinMaxes(l),l}else{if(!t)return l.borrowingAmountMin=r/(1-s.minimumLVR)-r,l.borrowingAmountMax=r/(1-c)-r,this.checkCorrectMinMax.borrowingAmount(l,i,s.borrowingFloor),l.propertyValueMin=Math.max(r/(1-s.minimumLVR),s.borrowingFloor/s.minimumLVR),l.propertyValueMax=Math.min(r/(1-c),i/(1-c),i+r),this.checkCorrectMinMax.propertyValue(l,i,s.minimumLVR,l.borrowingAmountMin,r),this.roundMinMaxes(l),l;if(!n)return l.borrowingAmountMin=o*s.minimumLVR,l.borrowingAmountMax=o*c,this.checkCorrectMinMax.borrowingAmount(l,i,s.borrowingFloor),l.depositAmountMin=Math.max(o*(1-c),o-l.borrowingAmountMax),l.depositAmountMax=Math.min(o*(1-s.minimumLVR),l.borrowingAmountMin/s.minimumLVR-l.borrowingAmountMin,l.propertyValueMax-l.borrowingAmountMin),this.roundMinMaxes(l),l}throw new Error("Invalid field lock combination")}},{key:"getLockCorrection",value:function(e,t,n,r,o,a,i,u){var s={borrowingAmount:r,propertyValue:n,depositAmount:o,latestUpdatedFieldValid:!1};if(!e)return s;if(t.includes(e))return s;if(!this.resultsFieldsValues.includes(e))throw new Error("Invalid latest updated field - ".concat(e));if(s.latestUpdatedFieldValid=!0,e===this.resultsFields.borrowingAmount){if(!i)return s.propertyValue=r+o,s;if(!u)return s.depositAmount=n-r,s}else if(e===this.resultsFields.depositAmount){if(!a)return s.borrowingAmount=n-o,s;if(!i)return s.propertyValue=r+o,s}else if(e===this.resultsFields.propertyValue){if(!a)return s.borrowingAmount=n-o,s;if(!u)return s.depositAmount=n-r,s}throw new Error("Invalid locked fields / latest changed combination - ".concat(e," - ").concat(JSON.stringify(t)))}},{key:"getLockingResults",value:function(e,t,n,r,o,i,u,s){var l,p,m,h,d=e&&e.includes(this.resultsFields.borrowingAmount),f=e&&e.includes(this.resultsFields.propertyValue),y=e&&e.includes(this.resultsFields.depositAmount);return t=isNaN(t)?0:c.round(t,2),n=isNaN(n)?0:c.round(n,2),r=isNaN(r)?0:c.round(r,2),(l=this.getLockingValid(e)).validLockFields&&(p=this.getLockingMinMax(d,f,y,r,t,n,o,u,s)),l&&l.validLockFields&&(t=Math.min(Math.max(t,p.propertyValueMin),p.propertyValueMax),n=Math.min(Math.max(n,p.borrowingAmountMin),p.borrowingAmountMax),r=Math.min(Math.max(r,p.depositAmountMin),p.depositAmountMax),m=this.getLockCorrection(i,e,t,n,r,d,f,y)),a(a(a({validLockFields:!!l&&l.validLockFields,lockedFields:l?l.correctedLockedFields:e},h),p),m)}},{key:"getResults",value:function(e,t){var n=a(a(a({},this.configuration),t),{},{borrowingPowerTerm:t.defaultLoanTerm?t.defaultLoanTerm:this.configuration.borrowingPowerTerm}),r=p.hexDecode(atob(n.reference));n.bpcr=r/100,n.overdraftLimitRate=n.overdraftLimitRate/100,n.creditCardLimitRate=n.creditCardLimitRate/100,n.studentLoanRate=n.studentLoanRate/100,n.superannuationRate=n.superannuationRate/100,n.propertyRates=n.propertyRates/100,n.houseInsuranceRate=n.houseInsuranceRate/100,n.minimumLVR=n.minimumLVR/100,n.maximumLVR=n.maximumLVR/100,n.defaultLVR=n.defaultLVR/100,n.borrowingTolerance=n.borrowingTolerance/100;var o=this.accLevy;o.ACCLevyRate=(t.ACCLevyRate?t.ACCLevyRate:o.ACCLevyRate)/100,o.ACCMaximumRate=t.ACCLevyCap?t.ACCLevyCap:o.ACCMaximumRate;var i=this.frequencies[e.frequency],u=this.frequencies[e.frequencyLoan],s="single"===e.applicationType?1:2,l=""===e.interestRate?"":e.interestRate/100,m=this.getAdultTaxPayable(e.yearlyIncome),h=this.getAdultACCLevy(e.yearlyIncome,o.ACCMinimumEarning,o.ACCMaximumRate,o.ACCLevyRate),d=this.getAdultStudentLoan(e.hasStudentLoan,e.yearlyIncome,n.studentLoanThreshold,n.studentLoanRate),f=this.getAdultSuperannuation(e.yearlyIncome,n.superannuationRate),y=this.getAdultNetIncome(e.yearlyIncome,m,h,d,f),g=s>1?this.getAdultTaxPayable(e.secondYearlyIncome):0,v=s>1?this.getAdultACCLevy(e.secondYearlyIncome,o.ACCMinimumEarning,o.ACCMaximumRate,o.ACCLevyRate):0,b=s>1?this.getAdultStudentLoan(e.hasSecondStudentLoan,e.secondYearlyIncome,n.studentLoanThreshold,n.studentLoanRate):0,w=s>1?this.getAdultSuperannuation(e.secondYearlyIncome,n.superannuationRate):0,P=s>1?this.getAdultNetIncome(e.secondYearlyIncome,g,v,b,w):0,x=this.getNetIncome(y,P),T=this.getMonthlyNetIncome(x),M=e.inputMethod,R=this.getMonthlyBenchmarkableExpenses(M,e.totalBenchmarkable,i),A=this.getMonthlyExpenses(M,e.expensesTotal,i),k=this.getCustomerDeclaredMLA(M,R,A),C=this.getCombinedGrossIncome(s,e.yearlyIncome,e.secondYearlyIncome),B=this.getHEBBasic(n.HEPBasicConstant,n.HEPBasicIncome,C,n.HEPBasicHouseholdSize,s,n.HEPBasicChildWeighting,e.dependents,n.HEPBasicStandardError,n.HEPBasicCPI),L=(this.getHEBDiscretionary(n.HEPDiscretionaryConstant,n.HEPDiscretionaryIncome,C,n.HEPDiscretionaryHouseholdSize,s,n.HEPDiscretionaryChildWeighting,e.dependents,n.HEPDiscretionaryStandardError,n.HEPDiscretionaryCPI),this.getHEB(C,n.salaryFloor,B)),E=this.getMLA(k,L),I=this.getMonthlyDebts(e.debts,i),S=this.getNonBenchmarkMonthly(M,e.totalNonBenchmarkable,i),D=this.getNetMC(I,S),O=this.getMaxRepayments(T,E,D),F=this.getZ(n.bpcr,n.borrowingPowerFrequency,n.borrowingPowerTerm),N=this.getMaxPropertyPrice(O,n.borrowingPowerFrequency,F,n.defaultLVR,n.propertyRates,n.houseInsuranceRate),V=this.getMaxBorrowings(N,n.defaultLVR),q=this.getBorrowingAmount(e.buyerModel,e.loanPurposeAmount,1-e.downPaymentPercentageDec,V),H=this.getDepositAmount(e.buyerModel,q,e.loanPurposeAmount,e.downPaymentPercentageDec,V,n.minimumLVR),Y=this.getPropertyValue(e.buyerModel,q,H,e.loanPurposeAmount),j=q,G=H,Z=e.latestUpdatedField;this.resultsFieldsValues.includes(Z)||(Z=null),Z&&(j=e.borrowingAmount,Y=e.propertyValue,G=e.depositAmount),Y=c.round(Y,2),j=c.round(j,2),G=c.round(G,2);var _,z,U,W=this.getLockingResults(e.lockedFields,Y,j,G,V,Z,e.downPaymentPercentageDec,n),K={min:n.borrowingFloor,max:Math.max(n.borrowingFloor,V)},J=W.validLockFields?W.propertyValue:Y,$=W.validLockFields?W.borrowingAmount:j,Q=W.validLockFields?W.depositAmount:G,X=this.getRepaymentBounds(l,u,$,O,n.minimumLoanTerm),ee={min:X.min,max:X.max},te=""===l;if(te)_=0,z=0,U="";else if(e.repaymentAmount>0){_=e.repaymentAmount,_=this.checkWithinBounds(_,ee),z=this.getTerm(l,u,_,$);var ne=c.roundDown(z,0),re=c.roundDown(12*z%12,0);U=ne+" year"+(ne>1?"s":""),re>0&&(U+=" and "+re+" month"+(re>1?"s":""))}else z=e.term,_=0===l?0:this.getRepaymentAmount(l,u,e.term,$),U=null;var oe=this.getTotalMortgageAmount(l,_,z,u),ae=this.getMultipleOfAmountBorrowing(l,oe,$),ie=this.getInterest(l,oe,$);z=isNaN(z)?0:z;var ue={min:n.minimumInterestRate,max:te?n.maximumInterestRate:this.getMaxInterestRate(z,u,$,n.maximumInterestRate,l,O)};l=te?"":this.checkWithinBounds(l,{min:ue.min/100,max:ue.max/100});var se={min:this.getMinTerm(l,_,$,u,n.minimumLoanTerm,O),max:n.maximumLoanTerm},le={borrowingPower:{min:W.validLockFields?W.borrowingAmountMin:$,max:W.validLockFields?W.borrowingAmountMax:$},depositAmount:{min:W.validLockFields?W.depositAmountMin:Q,max:W.validLockFields?W.depositAmountMax:Q},propertyValue:{min:W.validLockFields?W.propertyValueMin:J,max:W.validLockFields?W.propertyValueMax:J},interestRate:ue,terms:se,repaymentsLoan:ee};z=this.checkWithinBounds(z,se);var ce=this.getBPDetermination(e.buyerModel,n.defaultLVR,e.loanPurposeAmount,V,K.min,n.borrowingTolerance);return{borrowingPower:$,depositAmount:Q,propertyValue:J,interestRate:te?"":Math.round(100*l*100)/100,repaymentAmount:_,totalMortgageAmount:oe,multipleOfAmountBorrowing:ae,principal:$,interest:ie,maxBorrowings:V,fieldBounds:le,BPDetermination:ce,term:z,termNaturalLanguage:U,borrowingFloor:n.borrowingFloor,locking:W}}}])&&i(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();t.default=m},34950:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=a(n(3005)),o=a(n(44207));function a(e){return e&&e.__esModule?e:{default:e}}function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i(e)}function u(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function s(e){for(var t=1;tthis.config.ACCMinimumEarning){var t=Math.min(this.config.ACCMaximumRate,e)*this.config.ACCLevyRate;return o.default.round(t,2)}return 0}},{key:"getAdultStudentLoan",value:function(e,t){return e&&t>this.config.studentLoanThreshold?Math.max((t-this.config.studentLoanThreshold)*this.config.studentLoanRate,0):0}},{key:"getAdultSuperannuation",value:function(e){return e*this.config.superannuationRate}},{key:"getAdultNetIncome",value:function(e,t){var n=e-this.getAdultTaxPayable(e)-this.getAdultACCLevy(e)-this.getAdultStudentLoan(t,e)-this.getAdultSuperannuation(e);return o.default.round(n,2)}},{key:"getRentalIncomeGross",value:function(e,t,n){return e?t*n:0}},{key:"getRentalIncomeNet",value:function(e){return e*this.config.rentalFactor}},{key:"getMonthlyExpenses",value:function(e,t,n){return"Breakdown"===e?0:t*n/12}},{key:"getMonthlyBenchmarkableExpenses",value:function(e,t,n,r,o){return"Breakdown"===e?(t+r+n)*o/12:0}},{key:"getCustomerDeclaredMLA",value:function(e,t,n){return"Breakdown"===e?t:n}},{key:"getHEB",value:function(e,t){return t>=this.config.salaryFloor?e:0}},{key:"getHEBBasic",value:function(e,t,n){var r=Math.exp(this.config.HEPBasicConstant+this.config.HEPBasicIncome*Math.log(n)+this.config.HEPBasicHouseholdSize*Math.log(e+this.config.HEPBasicChildWeighting*t)+0*this.config.HEPBasicStandardError+this.config.HEPBasicCPI)/12;return o.default.round(r,2)}},{key:"getHEBDiscretionary",value:function(e,t,n){var r=Math.exp(this.config.HEPDiscretionaryConstant+this.config.HEPDiscretionaryIncome*Math.log(n)+this.config.HEPDiscretionaryHouseholdSize*Math.log(e+this.config.HEPDiscretionaryChildWeighting*t)+-.674489750196082*this.config.HEPDiscretionaryStandardError+this.config.HEPDiscretionaryCPI)/12;return o.default.round(r,2)}},{key:"getMLA",value:function(e,t,n,r){var o=this.getAdditionalExpenses(n,e);return Math.max(t,r)+o}},{key:"getMonthlyDebts",value:function(e,t){return e*t/12}},{key:"getMonthlyNonBenchmarkableExpenses",value:function(e,t,n,r,o){return"Breakdown"===e?(n+r+o)*t/12:0}},{key:"getRentalExpenses",value:function(e,t,n){return"Total"===e?(t+n)*this.config.rentalExpenses/12:0}},{key:"getStressedHomeLoanRepayments",value:function(e,t,n,r){var a=0,i=0;return e&&(a=o.default.pmt(t,this.config.bcpr/this.config.borrowingPowerFrequency,this.config.borrowingPowerTerm*this.config.borrowingPowerFrequency)),n&&(i=o.default.pmt(r,this.config.bcpr/this.config.borrowingPowerFrequency,this.config.borrowingPowerTerm*this.config.borrowingPowerFrequency)),a+i}},{key:"getAdditionalExpenses",value:function(e,t){return e&&"Total"===t?this.config.electricityAllowance+this.config.internetAllowance+this.config.maintenanceAllowance:0}},{key:"getRentBoard",value:function(e,t,n){return e?0:t*n/12}},{key:"getLiveInPropertyExpenses",value:function(e,t,n,r){return e&&"Total"===t?n*(this.config.propertyRates+this.config.houseInsuranceRate)/r:0}},{key:"getNetMC",value:function(e,t,n,r,o,a,i,u,s,l,c,p,m,h){return e+this.getStressedHomeLoanRepayments(n,r,o,a)+this.getRentalExpenses(i,u,s)+this.getMonthlyNonBenchmarkableExpenses(i,t,l,c,p)+this.getRentBoard(n,m,t)+this.getLiveInPropertyExpenses(n,i,h,t)}},{key:"getMaxRepayments",value:function(e,t,n){var r=Math.max(0,e-(t+n));return o.default.roundDown(r,2)}},{key:"getZ",value:function(){return(1-Math.pow(1+this.config.bcpr/this.config.borrowingPowerFrequency,-this.config.borrowingPowerTerm*this.config.borrowingPowerFrequency))/(this.config.bcpr/this.config.borrowingPowerFrequency)}},{key:"getMaxPropertyPrice",value:function(e){var t=this.getZ(),n=e*this.config.borrowingPowerFrequency*t/(this.config.borrowingPowerFrequency*this.config.defaultLVR);return o.default.roundDown(n,-3)}},{key:"getMaxBorrowings",value:function(e){return o.default.roundDown(e*this.config.defaultLVR,-3)}},{key:"getAllowableLendingOwnerOccupier",value:function(e,t,n){return e&&t>0?Math.max(t*this.config.ownerOccupierLVR-n,0):0}},{key:"getAllowableLendingInvestment",value:function(e,t,n){return e&&t>0?Math.max(t*this.config.investmentPropertyLVR-n,0):0}},{key:"getTotalAllowableLending",value:function(e,t,n,r,o,a){return this.getAllowableLendingOwnerOccupier(e,t,n)+this.getAllowableLendingInvestment(r,o,a)}},{key:"getAvailableEquity",value:function(e,t,n,r,o,a){return this.getTotalAllowableLending(e,t,n,r,o,a)*this.config.equityPercentage}},{key:"getCurrentEquityInvestment",value:function(e,t,n){return e&&t>0?Math.max(t-n,0):0}},{key:"getCurrentEquityOwnerOccupier",value:function(e,t,n){return e&&t>0?Math.max(t-n,0):0}},{key:"getTotalEquity",value:function(e,t,n,r,o,a){return this.getCurrentEquityOwnerOccupier(e,t,n)+this.getCurrentEquityInvestment(r,o,a)}},{key:"getEquityAsDeposit",value:function(e,t,n,r,a,i){return e&&(t||n)?o.default.roundDown(Math.min(r/this.config.defaultLVR-r,a,i-r),0):0}},{key:"getCashDeposit",value:function(e,t,n,r,a,i){return e&&(t||n)&&r>0?o.default.roundDown(a-r-i,0):0}},{key:"getDepositAmount",value:function(e,t,n,r){return!e||t||n?0:r*(1-this.config.defaultLVR)}},{key:"getPropertyValue",value:function(e,t,n,r){return e+t+n+r}},{key:"getRepaymentAmount",value:function(e,t,n,r){return o.default.pmt(r,e/t,n*t)}},{key:"getTotalMortgageAmount",value:function(e,t,n,r){return""===e?0:e>0?t*n*r:0}},{key:"getMultipleOfAmountBorrowing",value:function(e,t,n){return""===e?0:e>0?t/n:0}},{key:"getInterest",value:function(e,t,n){return""===e?0:e>0?t-n:0}},{key:"getBPCalculationResult",value:function(e,t){return this.config.defaultLVR,t*this.config.defaultLVR>=this.config.borrowingFloor}},{key:"getBorrowingAmount",value:function(e,t,n){return e?Math.min(t*this.config.defaultLVR,n):0}},{key:"getRepaymentBounds",value:function(e,t,n,r){return""===e?{min:0,max:0}:{min:o.default.roundUp(o.default.pmt(n,e/t,30*t),2),max:Math.min(12*r/t,o.default.roundDown(o.default.pmt(n,e/t,t*this.config.minimumLoanTerm),2))}}},{key:"getTerm",value:function(e,t,n,r){return o.default.roundUp(o.default.nper(e/t,n,-r)/t,2)}},{key:"getMinTerm",value:function(e,t,n,r){if(""===e)return 0;var a=Math.min(12*r/n,o.default.roundUp(o.default.pmt(t,e/n,this.config.minimumLoanTerm*n),2));return Math.max(o.default.roundUp(o.default.nper(e/n,a,-t)/n,2),this.config.minimumLoanTerm)}},{key:"getMaxInterestRate",value:function(e,t,n,r){var a=Math.min(12*r/t,o.default.roundDown(o.default.pmt(n,this.config.maximumInterestRate/t,this.config.minimumLoanTerm*t),2));return Math.min(o.default.roundDown(Math.abs(o.default.rate(e*t,a,-n,0,0,0)),8)*t*100,this.config.maximumInterestRate)}},{key:"checkWithinBounds",value:function(e,t){return e=Math.max(e,t.min),Math.min(e,t.max)}},{key:"getBorrowingPower",value:function(e,t){var n=t*this.config.defaultLVR;return e>=n*(1-this.config.borrowingTolerance)&&n>=this.config.borrowingFloor}},{key:"getEquity",value:function(e){return e>=this.config.borrowingFloor}},{key:"getNoEquityLockingMinMax",value:function(e,t,n,r,o,a,i){var u={depositAmountMax:r,depositAmountMin:r,borrowingAmountMin:a,borrowingAmountMax:a,propertyValueMax:o,propertyValueMin:o};if(e){if(!t&&!n)return u.depositAmountMin=a/this.config.defaultLVR-a,u.depositAmountMax=a/this.config.minimumLVR-a,this.checkCorrectMinMax.depositAmount(u,i,this.config.defaultLVR,this.config.borrowingFloor,this.config.minimumLVR),u.propertyValueMin=a/this.config.defaultLVR,u.propertyValueMax=a/this.config.minimumLVR,this.checkCorrectMinMax.propertyValue(u,i,this.config.defaultLVR,this.config.minimumLVR,this.config.borrowingFloor),this.roundMinMaxes(u),u}else{if(!t)return u.borrowingAmountMin=r/(1-this.config.minimumLVR)-r,u.borrowingAmountMax=r/(1-this.config.defaultLVR)-r,this.checkCorrectMinMax.borrowingAmount(u,i,this.config.borrowingFloor),u.propertyValueMin=r/(1-this.config.minimumLVR),u.propertyValueMax=Math.min(r/(1-this.config.defaultLVR),i/(1-this.config.defaultLVR),i+r),this.checkCorrectMinMax.propertyValue(u,i,this.config.defaultLVR,this.config.minimumLVR,this.config.borrowingFloor,r),this.roundMinMaxes(u),u;if(!n)return u.depositAmountMin=o*(1-this.config.defaultLVR),u.depositAmountMax=o*(1-this.config.minimumLVR),this.checkCorrectMinMax.depositAmount(u,i,this.config.defaultLVR,this.config.borrowingFloor,this.config.minimumLVR,o),u.borrowingAmountMin=o*this.config.minimumLVR,u.borrowingAmountMax=o*this.config.defaultLVR,this.checkCorrectMinMax.borrowingAmount(u,i,this.config.borrowingFloor),this.roundMinMaxes(u),u}throw new Error("Invalid field lock combination")}},{key:"getNoEquityLockingValid",value:function(e){return this.getLockingValid(e,this.noEquityLockFields)}},{key:"getHasEquityLockingValid",value:function(e){return this.getLockingValid(e,this.hasEquityLockFields)}},{key:"getLockingValid",value:function(e,t){var n=(e||[]).filter((function(e){return t.includes(e)}));return{validLockFields:Boolean(e&&e.length===t.length-2&&e.every((function(e){return t.includes(e)}))),correctedLockedFields:n}}},{key:"roundMinMaxes",value:function(e){e.borrowingAmountMax=Math.floor(e.borrowingAmountMax),e.borrowingAmountMin=Math.ceil(e.borrowingAmountMin),e.propertyValueMax=Math.floor(e.propertyValueMax),e.propertyValueMin=Math.ceil(e.propertyValueMin),e.equityAsDepositMax&&(e.equityAsDepositMax=Math.floor(e.equityAsDepositMax),e.equityAsDepositMin=Math.ceil(e.equityAsDepositMin),e.cashDepositMax=Math.floor(e.cashDepositMax),e.cashDepositMin=Math.ceil(e.cashDepositMin)),e.depositAmountMax&&(e.depositAmountMax=Math.floor(e.depositAmountMax),e.depositAmountMin=Math.ceil(e.depositAmountMin))}},{key:"getHasEquityLockingMinMax",value:function(e,t,n,r,o,a,i,u,s,l){var c={equityAsDepositMax:a,equityAsDepositMin:a,cashDepositMax:o,cashDepositMin:o,propertyValueMin:i,propertyValueMax:i,borrowingAmountMin:u,borrowingAmountMax:u};if(t)if(e){if(!r&&!n)return c.equityAsDepositMin=0,c.equityAsDepositMax=Math.min(i-u,s-u),this.checkCorrectMinMax.equityAsDeposit(c,l),c.cashDepositMin=i-u-c.equityAsDepositMax,c.cashDepositMax=i-u-c.equityAsDepositMin,this.checkCorrectMinMax.cashDeposit(c),this.roundMinMaxes(c),c}else{if(!r)return c.equityAsDepositMin=Math.min(i-o-i*this.config.defaultLVR,l),c.equityAsDepositMax=i-o-Math.max(i*this.config.minimumLVR,this.config.borrowingFloor),this.checkCorrectMinMax.equityAsDeposit(c,l,i,o,s,this.config.borrowingFloor),c.borrowingAmountMin=i-o-c.equityAsDepositMax,c.borrowingAmountMax=i-o-c.equityAsDepositMin,this.checkCorrectMinMax.borrowingAmount(c,s,this.config.borrowingFloor),this.roundMinMaxes(c),c;if(!n)return c.cashDepositMin=Math.max(0,i-s,i*(1-this.config.defaultLVR)-a),c.cashDepositMax=i-a-Math.max(i*this.config.minimumLVR,this.config.borrowingFloor),this.checkCorrectMinMax.cashDeposit(c,i,a,s,this.config.borrowingFloor),c.borrowingAmountMin=i-a-c.cashDepositMax,c.borrowingAmountMax=i-a-c.cashDepositMin,this.checkCorrectMinMax.borrowingAmount(c,s,this.config.borrowingFloor),this.roundMinMaxes(c),c}else{if(!e)return c.propertyValueMin=(a+o)/(1-this.config.minimumLVR),c.propertyValueMax=(o+a)/(1-this.config.defaultLVR),this.checkCorrectMinMax.propertyValue(c,s,this.config.defaultLVR,this.config.minimumLVR,this.config.borrowingFloor,a+o),c.borrowingAmountMin=c.propertyValueMin-o-a,c.borrowingAmountMax=c.propertyValueMax-o-a,c.borrowingAmountMax=Math.min(c.borrowingAmountMax,s-a),c.propertyValueMax=Math.min(c.propertyValueMax,c.borrowingAmountMax+o+a),this.checkCorrectMinMax.borrowingAmount(c,s,this.config.borrowingFloor),this.roundMinMaxes(c),c;if(!n)return c.cashDepositMin=Math.max(0,u/this.config.defaultLVR-u-a),c.cashDepositMax=u/this.config.minimumLVR-u-a,this.checkCorrectMinMax.cashDeposit(c),c.propertyValueMin=u+a+c.cashDepositMin,c.propertyValueMax=u+a+c.cashDepositMax,this.checkCorrectMinMax.propertyValue(c,s,this.config.defaultLVR,this.config.minimumLVR,this.config.borrowingFloor),this.roundMinMaxes(c),c;if(!r)return c.equityAsDepositMin=Math.max(0,u/this.config.defaultLVR-u-o),c.equityAsDepositMax=Math.min(u/this.config.minimumLVR-u-o,s-u),this.checkCorrectMinMax.equityAsDeposit(c,l),c.propertyValueMin=u+o+c.equityAsDepositMin,c.propertyValueMax=u+o+c.equityAsDepositMax,this.checkCorrectMinMax.propertyValue(c,s,this.config.defaultLVR,this.config.minimumLVR,this.config.borrowingFloor),this.roundMinMaxes(c),c}throw new Error("Invalid field lock combination")}},{key:"getNoEquityLockCorrection",value:function(e,t,n,r,o,a,i,u){var s={borrowingAmount:r,propertyValue:n,depositAmount:o,latestUpdatedFieldValid:!1};if(!e)return s;if(t.includes(e))return s;if(!this.noEquityLockFields.includes(e))throw new Error("Invalid latest updated field - ".concat(e));if(s.latestUpdatedFieldValid=!0,e===this.resultsFields.borrowingAmount){if(!i)return s.propertyValue=r+o,s;if(!u)return s.depositAmount=n-r,s}else if(e===this.resultsFields.depositAmount){if(!a)return s.borrowingAmount=n-o,s;if(!i)return s.propertyValue=r+o,s}else if(e===this.resultsFields.propertyValue){if(!a)return s.borrowingAmount=n-o,s;if(!u)return s.depositAmount=n-r,s}throw new Error("Invalid locked fields / latest changed combination - ".concat(e," - ").concat(JSON.stringify(t)))}},{key:"getHasEquityLockCorrection",value:function(e,t,n,r,o,a,i,u,s,l){var c={borrowingAmount:r,propertyValue:n,cashDeposit:o,equityAsDeposit:a,latestUpdatedFieldValid:!1};if(!e)return c;if(t.includes(e))return c;if(c.latestUpdatedFieldValid=!0,i)if(l){if(!s&&!u){if(e==this.resultsFields.cashDeposit)return c.propertyValue=r+o+a,c;if(e===this.resultsFields.propertyValue)return c.cashDeposit=[n]-r-a,c}}else if(s){if(!u){if(e==this.resultsFields.equityAsDeposit)return c.propertyValue=r+a+o,c;if(e===this.resultsFields.propertyValue)return c.equityAsDeposit=n-o-r,c}}else{if(e==this.resultsFields.equityAsDeposit)return c.cashDeposit=n-a-r,c;if(e===this.resultsFields.cashDeposit)return c.equityAsDeposit=n-o-r,c}else if(l)if(s){if(!u){if(e===this.resultsFields.borrowingAmount)return c.propertyValue=r+o+a,c;if(e===this.resultsFields.propertyValue)return c.borrowingAmount=n-a-o,c}}else{if(e===this.resultsFields.borrowingAmount)return c.cashDeposit=n-r-a,c;if(e===this.resultsFields.cashDeposit)return c.borrowingAmount=n-o-a,c}else{if(e===this.resultsFields.equityAsDeposit)return c.borrowingAmount=n-a-o,c;if(e===this.resultsFields.borrowingAmount)return c.equityAsDeposit=n-r-o,c}throw new Error("Invalid locked fields / latest changed combination - ".concat(e," - ").concat(JSON.stringify(t)))}},{key:"getLockingResults",value:function(e,t,n,r,a,i,u,l,c,p){var m,h,d,f,y=t&&t.includes(this.resultsFields.borrowingAmount),g=t&&t.includes(this.resultsFields.propertyValue),v=t&&t.includes(this.resultsFields.cashDeposit),b=t&&t.includes(this.resultsFields.equityAsDeposit),w=t&&t.includes(this.resultsFields.depositAmount);return n=isNaN(n)?0:o.default.round(n,2),r=isNaN(r)?0:o.default.round(r,2),a=isNaN(a)?0:o.default.round(a,2),i=isNaN(i)?0:o.default.round(i,2),u=isNaN(u)?0:o.default.round(u,2),e?(m=this.getHasEquityLockingValid(t)).validLockFields&&(h=this.getHasEquityLockingMinMax(y,g,v,b,i,a,n,r,l,c)):(m=this.getNoEquityLockingValid(t)).validLockFields&&(h=this.getNoEquityLockingMinMax(y,g,w,u,n,r,l)),m&&m.validLockFields&&(n=Math.min(Math.max(n,h.propertyValueMin),h.propertyValueMax),r=Math.min(Math.max(r,h.borrowingAmountMin),h.borrowingAmountMax),a=Math.min(Math.max(a,h.equityAsDepositMin),h.equityAsDepositMax),i=Math.min(Math.max(i,h.cashDepositMin),h.cashDepositMax),u=Math.min(Math.max(u,h.depositAmountMin),h.depositAmountMax),d=e?this.getHasEquityLockCorrection(p,t,n,r,i,a,y,g,v,b):this.getNoEquityLockCorrection(p,t,n,r,u,y,g,w)),s(s(s({depositAmount:0,cashDeposit:0,equityAsDeposit:0,depositAmountMin:0,depositAmountMax:0,equityAsDepositMax:0,equityAsDepositMin:0,cashDepositMax:0,cashDepositMin:0,validLockFields:!!m&&m.validLockFields,lockedFields:m?m.correctedLockedFields:t},f),h),d)}},{key:"getExpensesFromList",value:function(e,t,n,r,o){var a=Number(e.groceries),i=Number(e.transportation),u=Number(e.health),s=Number(e.entertainment),l=Number(e.insurance),c=Number(e.personalExpenses),p=Number(e.childCare),m=Number(e.childSupport),h=Number(e.other),d=Number(e.otherCost),f=Number(e.electricity),y=Number(e.phone),g=Number(e.housingMaintenance),v=Number(e.rates),b=Number(e.bodyCorporate),w=Number(e.insuranceHouseAndContents),P=Number(e.investmentPropertyExpenses),x=a+i+u+s+c+d,T=l+p+m+h,M=f+y+g,R=v+b+w,A=Math.floor((n+r)*this.config.rentalExpenses/o);return{totalBenchmarkable:x,totalNonBenchmarkable:T,totalMainPropertyBenchmarkable:M,totalMainPropertyNonBenchmarkable:R,totalInvestmentPropertyBenchmarkable:0,totalInvestmentPropertyNonBenchmarkable:t?Math.max(P,A):A}}},{key:"initConfig",value:function(e){var t=s(s({},this.defaultConfig),e),n=m.hexDecode(atob(e.reference));t.bcpr=n/100,t.overdraftLimitRate=t.overdraftLimitRate/100,t.creditCardLimitRate=t.creditCardLimitRate/100,t.studentLoanRate=t.studentLoanRate/100,t.superannuationRate=t.superannuationRate/100,t.minimumLVR=t.minimumLVR/100,t.maximumLVR=t.maximumLVR/100,t.propertyRates=t.propertyRates/100,t.houseInsuranceRate=t.houseInsuranceRate/100,t.defaultLVR=t.defaultLVR/100,t.rentalFactor=t.rentalFactor/100,t.rentalExpenses=t.rentalExpenses/100,t.investmentPropertyLVR=t.investmentPropertyLVR/100,t.ownerOccupierLVR=t.ownerOccupierLVR/100,t.equityPercentage=t.equityPercentage/100,t.ACCLevyRate=t.ACCLevyRate/100,t.borrowingTolerance=t.borrowingTolerance/100,this.config=t}},{key:"getResults",value:function(e,t){this.initConfig(t);var n=this.frequencies[e.frequency],r=this.frequencies[e.frequencyLoan],a=this.frequencies[e.rentalIncomeFrequency],i=this.frequencies[e.newRentalIncomeFrequency],u="single"===e.applicationType?1:2,s=""===e.interestRate?"":e.interestRate/100,l=e.inputMethod,c=this.getRentalIncomeGross(e.investmentOwnership,e.rentalIncome,a),p=this.getRentalIncomeNet(c),m=this.getRentalIncomeGross(!0,e.newRentalIncome,i),h=this.getRentalIncomeNet(m),d=this.getExpensesFromList(e.expensesList,e.investmentOwnership,c,m,n),f=this.getMonthlyBenchmarkableExpenses(l,d.totalBenchmarkable,d.totalMainPropertyBenchmarkable,d.totalInvestmentPropertyBenchmarkable,n),y=this.getMonthlyExpenses(l,e.expensesTotal,n),g=this.getCustomerDeclaredMLA(e.inputMethod,f,y),v=p+h,b=this.getAdultNetIncome(e.adult1GrossIncome,e.adult1StudentLoan),w=this.getAdultNetIncome(e.adult2GrossIncome,e.adult2StudentLoan),P=this.getNetIncome(b,w,v),x=this.getMonthlyNetIncome(P),T=this.getCombinedGrossIncome(u,e.adult1GrossIncome,e.adult2GrossIncome),M=this.getHEBBasic(u,e.dependents,T),R=this.getHEBDiscretionary(u,e.dependents,T),A=this.getHEB(M,T),k=this.getMonthlyDebts(e.debts,n),C=this.getNetMC(k,n,e.ownerOccupierOwnership,e.ownerOccupierPropertyLoanAmount,e.investmentOwnership,e.investmentPropertyLoanAmount,e.inputMethod,c,m,d.totalNonBenchmarkable,d.totalMainPropertyNonBenchmarkable,d.totalInvestmentPropertyNonBenchmarkable,e.rentAmount,e.ownerOccupierPropertyValue),B=this.getMLA(e.inputMethod,g,e.ownerOccupierOwnership,A),L=this.getMaxRepayments(x,B,C),E=this.getMaxPropertyPrice(L),I=this.getMaxBorrowings(E),S=this.getBorrowingPower(I,e.newPropertyPrice),D=this.getBPCalculationResult(I,e.newPropertyPrice),O=this.getBorrowingAmount(D,e.newPropertyPrice,I),F=this.getAvailableEquity(e.ownerOccupierOwnership,e.ownerOccupierPropertyValue,e.ownerOccupierPropertyLoanAmount,e.investmentOwnership,e.investmentPropertyValue,e.investmentPropertyLoanAmount),N=this.getTotalEquity(e.ownerOccupierOwnership,e.ownerOccupierPropertyValue,e.ownerOccupierPropertyLoanAmount,e.investmentOwnership,e.investmentPropertyValue,e.investmentPropertyLoanAmount),V=this.getEquityAsDeposit(D,e.investmentOwnership,e.ownerOccupierOwnership,O,F,I),q=this.getCashDeposit(D,e.investmentOwnership,e.ownerOccupierOwnership,O,e.newPropertyPrice,V),H=e.investmentOwnership||e.ownerOccupierOwnership,Y=this.getDepositAmount(D,e.investmentOwnership,e.ownerOccupierOwnership,e.newPropertyPrice),j=e.newPropertyPrice,G=O,Z=Y,_=V,z=q,U=e.latestUpdatedField;(H&&!this.hasEquityLockFields.includes(U)||!H&&!this.noEquityLockFields.includes(U))&&(U=null),U&&(G=e.borrowingAmount,j=e.propertyValue,Z=e.depositAmount,z=e.cashDeposit,_=e.equityAsDeposit),j=o.default.round(j,2),G=o.default.round(G,2),Z=o.default.round(Z,2),_=o.default.round(_,2),z=o.default.round(z,2);var W,K,J,$=this.getLockingResults(H,e.lockedFields,j,G,_,z,Z,I,F,U),Q=$.validLockFields?$.propertyValue:j,X=$.validLockFields?$.borrowingAmount:G,ee=$.validLockFields?$.depositAmount:Z,te=$.validLockFields?$.cashDeposit:z,ne=$.validLockFields?$.equityAsDeposit:_,re=X+ne,oe=""===s;if(oe)W=0,K=0,J="";else if(e.repaymentAmount>0){W=e.repaymentAmount,K=this.getTerm(s,r,W,re);var ae=o.default.roundDown(K,0),ie=o.default.roundDown(12*K%12,0);J=ae+" year"+(ae>1?"s":""),ie>0&&(J+=" and "+ie+" month"+(ie>1?"s":""))}else K=e.term,W=0===s?0:this.getRepaymentAmount(s,r,e.term,re),J=null;var ue=this.getTotalMortgageAmount(s,W,K,r),se=this.getMultipleOfAmountBorrowing(s,ue,re),le=this.getInterest(s,ue,re),ce=this.getRepaymentBounds(s,r,re,L);K=isNaN(K)?0:K;var pe={min:this.config.minimumInterestRate,max:oe?this.config.maximumInterestRate:this.getMaxInterestRate(K,r,re,L)};s=oe?"":this.checkWithinBounds(s,{min:pe.min/100,max:pe.max/100});var me={min:this.getMinTerm(s,re,r,L),max:this.config.maximumLoanTerm},he={min:ce.min,max:ce.max},de={borrowingAmount:{min:$.validLockFields?$.borrowingAmountMin:X,max:$.validLockFields?$.borrowingAmountMax:X},depositAmount:{min:$.validLockFields?$.depositAmountMin:ee,max:$.validLockFields?$.depositAmountMax:ee},equityAsDeposit:{min:$.validLockFields?$.equityAsDepositMin:ne,max:$.validLockFields?$.equityAsDepositMax:ne},cashDeposit:{min:$.validLockFields?$.cashDepositMin:te,max:$.validLockFields?$.cashDepositMax:te},propertyValue:{min:$.validLockFields?$.propertyValueMin:Q,max:$.validLockFields?$.propertyValueMax:Q},interestRate:pe,terms:me,repaymentsLoan:he};K=this.checkWithinBounds(K,me),W=this.checkWithinBounds(W,he);var fe=S;return{borrowingPowerCalculations:{combinedGrossIncome:T,monthlyExpenses:y,monthlyBenchmarkableExpenses:f,customerDeclaredMLA:g,HEB:A,HEBBasic:M,HEBDiscretionary:R,monthlyDebts:k},availableEquity:F,borrowingPower:S,borrowingAmount:X,depositAmount:ee,equityAsDeposit:ne,cashDeposit:te,propertyValue:Q,interestRate:oe?"":o.default.round(100*s,2),repaymentAmount:W,totalMortgageAmount:ue,multipleOfAmountBorrowing:se,principal:re,interest:le,fieldBounds:de,BPDetermination:fe,term:K,termNaturalLanguage:J,borrowingFloor:this.config.borrowingFloor,locking:$,currentPropertyEquity:N}}}])&&l(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();t.default=h},37057:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=i(n(3005)),o=i(n(44207)),a=["ACCLevyRate","ACCLevyCap"];function i(e){return e&&e.__esModule?e:{default:e}}function u(e){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u(e)}function s(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function l(e){for(var t=1;tt?Math.min(n,e)*r:0}},{key:"getAdultStudentLoan",value:function(e,t,n,r){return e&&t>n?Math.max((t-n)*r,0):0}},{key:"getAdultSuperannuation",value:function(e,t){return e*t}},{key:"getAdultNetIncome",value:function(e,t,n,r,o){return e-(t+n+r+o)}},{key:"getRentalIncomeGross",value:function(e,t,n,r,o){return"keep"!==e||"rent"!==t&&"rent"!==n?0:r*o}},{key:"getRentalIncomeNet",value:function(e,t){return e*t}},{key:"getMonthlyExpenses",value:function(e,t,n){return"Breakdown"===e?0:t*n/12}},{key:"getMonthlyBenchmarkableExpenses",value:function(e,t,n,r,o){return"Breakdown"===e?(t+n+r)*o/12:0}},{key:"getCustomerDeclaredMLA",value:function(e,t,n){return"Breakdown"===e?t:n}},{key:"getHEB",value:function(e,t,n){return e>=t?n:0}},{key:"getHEBBasic",value:function(e,t,n,r,o,a,i,u,s){return Math.exp(e+t*Math.log(n)+r*Math.log(o+a*i)+0*u+s)/12}},{key:"getHEBDiscretionary",value:function(e,t,n,r,o,a,i,u,s){return Math.exp(e+t*Math.log(n)+r*Math.log(o+a*i)+-.674489750196082*u+s)/12}},{key:"getMLA",value:function(e,t,n){return Math.max(e,t)+n}},{key:"getMonthlyDebts",value:function(e,t){return e*t/12}},{key:"getNonBenchmarkMonthly",value:function(e,t,n,r,o){return"Breakdown"===e?(t+n+r)*o/12:0}},{key:"getRentalExpenses",value:function(e,t,n,r){return"rent"===e||"rent"===t?n*r/12:0}},{key:"getStressedRepayment",value:function(e,t,n,r,a){return"keep"===e?o.default.pmt(t,n/r,a*r):0}},{key:"getAdditionalExpenses",value:function(e,t,n,r,o,a){return"keep"===e&&"also live in"===t&&"Total"===n?r+o+a:0}},{key:"getLiveInPropertyExpenses",value:function(e,t,n,r,o,a,i){return"Total"===e&&"live in"===t&&"keep"===n?r*(o+a)/i:0}},{key:"getNetMC",value:function(e,t,n,r,o){return e+t+n+r+o}},{key:"getMaxRepayments",value:function(e,t,n){var r=Math.max(0,e-(t+n));return Math.floor(100*r)/100}},{key:"getZ",value:function(e,t,n){return(1-Math.pow(1+e/t,-n*t))/(e/t)}},{key:"getMaxPropertyPrice",value:function(e,t,n,r,a,i,u,s,l){var c=e*t*n/(t*r+("Total"!==i||"sell"!==a&&"rent"===l?0:n*(u+s)));return o.default.roundDown(c,-3)}},{key:"getMaxBorrowings",value:function(e,t){return 1e3*o.default.roundDown(e*t/1e3,0)}},{key:"getNewPropertyLVR",value:function(e,t,n,r){return"sell"===e||"also live in"===n||"live in"===n?t:r}},{key:"getNewPropertyBorrowingAmount",value:function(e,t,n){return e?t*n:0}},{key:"getU",value:function(e,t){return e-t}},{key:"getCurrentPropertyEquity",value:function(e,t){return"keep"===e?o.default.roundDown(Math.max(t,0),0):0}},{key:"getCurrentPropertyLVR",value:function(e,t,n,r){return"sell"===e||"live in"===n?t:r}},{key:"getV2_",value:function(e,t,n){return e*t-n}},{key:"getAvailableEquity",value:function(e,t,n,r){return"keep"===e?o.default.roundDown(Math.max(0,Math.min(t,n/r-n)),0):0}},{key:"getEquityAsDeposit",value:function(e,t,n,r){return o.default.roundDown(Math.min(e/t-e,n,r-e),0)}},{key:"getCashDeposit",value:function(e,t,n){return o.default.roundDown(e>0?t-e-n:0,0)}},{key:"getPropertyValue",value:function(e,t,n){return"keep"===e&&t?n:0}},{key:"getRepaymentAmount",value:function(e,t,n,r){return o.default.pmt(r,e/t,n*t)}},{key:"getTotalMortgageAmount",value:function(e,t,n,r){return""===e?0:e>0?t*n*r:0}},{key:"getMultipleOfAmountBorrowing",value:function(e,t,n){return""===e?0:e>0?t/n:0}},{key:"getInterest",value:function(e,t,n){return""===e?0:e>0?t-n:0}},{key:"getBPCalculationResult",value:function(e,t,n,r,o){return e>=t&&n>=r&&t*o>=r}},{key:"getRepaymentBounds",value:function(e,t,n,r,a){return""===e?{min:0,max:0}:{min:o.default.roundUp(o.default.pmt(n,e/t,30*t),2),max:Math.min(12*r/t,o.default.roundDown(o.default.pmt(n,e/t,t*a),2))}}},{key:"getTerm",value:function(e,t,n,r){return o.default.roundUp(o.default.nper(e/t,n,-r)/t,2)}},{key:"getMinTerm",value:function(e,t,n,r,a){if(""===e)return 0;var i=Math.min(12*a/n,o.default.roundDown(o.default.pmt(t,e/n,1*n),2));return Math.max(o.default.roundUp(o.default.nper(e/n,-i,t)/n,2),r)}},{key:"getMaxInterestRate",value:function(e,t,n,r,a,i){var u=Math.min(12*i/t,o.default.roundDown(o.default.pmt(n,a/t,1*t),2));return Math.min(o.default.roundDown(Math.abs(o.default.rate(e*t,u,-n,0,0,0)),8)*t*100,r)}},{key:"checkWithinBounds",value:function(e,t){return e=Math.max(e,t.min),Math.min(e,t.max)}},{key:"getSellLockingValid",value:function(e){var t=this,n=(e||[]).filter((function(e){return t.sellLockFields.includes(e)}));return{validLockFields:Boolean(e&&1===e.length&&e.every((function(e){return t.sellLockFields.includes(e)}))),correctedLockedFields:n}}},{key:"getSellLockingMinMax",value:function(e,t,n,r,o,a,i,u,s,l){var c={depositAmountMax:r,depositAmountMin:r,borrowingAmountMin:a,borrowingAmountMax:a,propertyValueMax:o,propertyValueMin:o};if(e){if(!t&&!n)return c.depositAmountMin=a/s-a,c.depositAmountMax=a/u-a,this.checkCorrectMinMax.depositAmount(c,l,s,i,u),c.propertyValueMin=a/s,c.propertyValueMax=a/u,this.checkCorrectMinMax.propertyValue(c,l,s,u,i),this.roundMinMaxes(c),c}else{if(!t)return c.borrowingAmountMin=r/(1-u)-r,c.borrowingAmountMax=r/(1-s)-r,this.checkCorrectMinMax.borrowingAmount(c,l,i),c.propertyValueMin=r/(1-u),c.propertyValueMax=Math.min(r/(1-s),l/(1-s),l+r),this.checkCorrectMinMax.propertyValue(c,l,s,u,i,r),this.roundMinMaxes(c),c;if(!n)return c.depositAmountMin=o*(1-s),c.depositAmountMax=o*(1-u),this.checkCorrectMinMax.depositAmount(c,l,s,i,u,o),c.borrowingAmountMin=o*u,c.borrowingAmountMax=o*s,this.checkCorrectMinMax.borrowingAmount(c,l,i),this.roundMinMaxes(c),c}throw new Error("Invalid field lock combination")}},{key:"getKeepLockingValid",value:function(e){var t=this,n=(e||[]).filter((function(e){return t.keepLockFields.includes(e)}));return{validLockFields:Boolean(e&&2===e.length&&e.every((function(e){return t.keepLockFields.includes(e)}))),correctedLockedFields:n}}},{key:"roundMinMaxes",value:function(e){e.borrowingAmountMax=Math.floor(e.borrowingAmountMax),e.borrowingAmountMin=Math.ceil(e.borrowingAmountMin),e.propertyValueMax=Math.floor(e.propertyValueMax),e.propertyValueMin=Math.ceil(e.propertyValueMin),e.equityAsDepositMax&&(e.equityAsDepositMax=Math.floor(e.equityAsDepositMax),e.equityAsDepositMin=Math.ceil(e.equityAsDepositMin),e.cashDepositMax=Math.floor(e.cashDepositMax),e.cashDepositMin=Math.ceil(e.cashDepositMin)),e.depositAmountMax&&(e.depositAmountMax=Math.floor(e.depositAmountMax),e.depositAmountMin=Math.ceil(e.depositAmountMin))}},{key:"getKeepLockingMinMax",value:function(e,t,n,r,o,a,i,u,s,l,c,p,m){var h={equityAsDepositMax:a,equityAsDepositMin:a,cashDepositMax:o,cashDepositMin:o,propertyValueMin:i,propertyValueMax:i,borrowingAmountMin:u,borrowingAmountMax:u};if(t)if(e){if(!r&&!n)return h.equityAsDepositMin=0,h.equityAsDepositMax=Math.min(i-u,p-u),this.checkCorrectMinMax.equityAsDeposit(h,m),h.cashDepositMin=i-u-h.equityAsDepositMax,h.cashDepositMax=i-u-h.equityAsDepositMin,this.checkCorrectMinMax.cashDeposit(h),this.roundMinMaxes(h),h}else{if(!r)return h.equityAsDepositMin=Math.min(i-o-i*c,m),h.equityAsDepositMax=i-o-i*l,this.checkCorrectMinMax.equityAsDeposit(h,m,i,o,p,s),h.borrowingAmountMin=i-o-h.equityAsDepositMax,h.borrowingAmountMax=i-o-h.equityAsDepositMin,this.checkCorrectMinMax.borrowingAmount(h,p,s),this.roundMinMaxes(h),h;if(!n)return h.cashDepositMin=Math.max(0,i-p,i*(1-c)-a),h.cashDepositMax=i-a-i*l,this.checkCorrectMinMax.cashDeposit(h,i,a,p,s),h.borrowingAmountMin=i-a-h.cashDepositMax,h.borrowingAmountMax=i-a-h.cashDepositMin,this.checkCorrectMinMax.borrowingAmount(h,p,s),this.roundMinMaxes(h),h}else{if(!e)return h.propertyValueMin=(a+o)/(1-l),h.propertyValueMax=(o+a)/(1-c),this.checkCorrectMinMax.propertyValue(h,p,c,l,s,a+o),h.borrowingAmountMin=h.propertyValueMin-o-a,h.borrowingAmountMax=h.propertyValueMax-o-a,h.borrowingAmountMax=Math.min(h.borrowingAmountMax,p-a),h.propertyValueMax=Math.min(h.propertyValueMax,h.borrowingAmountMax+o+a),this.checkCorrectMinMax.borrowingAmount(h,p,s),this.roundMinMaxes(h),h;if(!n)return h.cashDepositMin=Math.max(0,u/c-u-a),h.cashDepositMax=u/l-u-a,this.checkCorrectMinMax.cashDeposit(h),h.propertyValueMin=u+a+h.cashDepositMin,h.propertyValueMax=u+a+h.cashDepositMax,this.checkCorrectMinMax.propertyValue(h,p,c,l,s),this.roundMinMaxes(h),h;if(!r)return h.equityAsDepositMin=Math.max(0,u/c-u-o),h.equityAsDepositMax=Math.min(u/l-u-o,p-u),this.checkCorrectMinMax.equityAsDeposit(h,m),h.propertyValueMin=u+o+h.equityAsDepositMin,h.propertyValueMax=u+o+h.equityAsDepositMax,this.checkCorrectMinMax.propertyValue(h,p,c,l,s),this.roundMinMaxes(h),h}throw new Error("Invalid field lock combination")}},{key:"getSellLockCorrection",value:function(e,t,n,r,o,a,i,u){var s={borrowingAmount:r,propertyValue:n,depositAmount:o,latestUpdatedFieldValid:!1};if(!e)return s;if(t.includes(e))return s;if(!this.sellLockFields.includes(e))throw new Error("Invalid latest updated field - ".concat(e));if(s.latestUpdatedFieldValid=!0,e===this.resultsFields.borrowingAmount){if(!i)return s.propertyValue=r+o,s;if(!u)return s.depositAmount=n-r,s}else if(e===this.resultsFields.depositAmount){if(!a)return s.borrowingAmount=n-o,s;if(!i)return s.propertyValue=r+o,s}else if(e===this.resultsFields.propertyValue){if(!a)return s.borrowingAmount=n-o,s;if(!u)return s.depositAmount=n-r,s}throw new Error("Invalid locked fields / latest changed combination - ".concat(e," - ").concat(JSON.stringify(t)))}},{key:"getKeepLockCorrection",value:function(e,t,n,r,o,a,i,u,s,l){var c={borrowingAmount:r,propertyValue:n,cashDeposit:o,equityAsDeposit:a,latestUpdatedFieldValid:!1};if(!e)return c;if(t.includes(e))return c;if(c.latestUpdatedFieldValid=!0,i)if(l){if(!s&&!u){if(e==this.resultsFields.cashDeposit)return c.propertyValue=r+o+a,c;if(e===this.resultsFields.propertyValue)return c.cashDeposit=[n]-r-a,c}}else if(s){if(!u){if(e==this.resultsFields.equityAsDeposit)return c.propertyValue=r+a+o,c;if(e===this.resultsFields.propertyValue)return c.equityAsDeposit=n-o-r,c}}else{if(e==this.resultsFields.equityAsDeposit)return c.cashDeposit=n-a-r,c;if(e===this.resultsFields.cashDeposit)return c.equityAsDeposit=n-o-r,c}else if(l)if(s){if(!u){if(e===this.resultsFields.borrowingAmount)return c.propertyValue=r+o+a,c;if(e===this.resultsFields.propertyValue)return c.borrowingAmount=n-a-o,c}}else{if(e===this.resultsFields.borrowingAmount)return c.cashDeposit=n-r-a,c;if(e===this.resultsFields.cashDeposit)return c.borrowingAmount=n-o-a,c}else{if(e===this.resultsFields.equityAsDeposit)return c.borrowingAmount=n-a-o,c;if(e===this.resultsFields.borrowingAmount)return c.equityAsDeposit=n-r-o,c}throw new Error("Invalid locked fields / latest changed combination - ".concat(e," - ").concat(JSON.stringify(t)))}},{key:"getLockingResults",value:function(e,t,n,r,a,i,u,s,c,p,m,h,d){var f,y,g,v,b=n&&n.includes(this.resultsFields.borrowingAmount),w=n&&n.includes(this.resultsFields.propertyValue),P=n&&n.includes(this.resultsFields.cashDeposit),x=n&&n.includes(this.resultsFields.equityAsDeposit),T=n&&n.includes(this.resultsFields.depositAmount);return r=isNaN(r)?0:o.default.round(r,2),a=isNaN(a)?0:o.default.round(a,2),i=isNaN(i)?0:o.default.round(i,2),u=isNaN(u)?0:o.default.round(u,2),s=isNaN(s)?0:o.default.round(s,2),e?(f=this.getKeepLockingValid(n)).validLockFields&&(y=this.getKeepLockingMinMax(b,w,P,x,u,i,r,a,c.borrowingFloor,c.minimumLVR,p,m,h)):t&&(f=this.getSellLockingValid(n)).validLockFields&&(y=this.getSellLockingMinMax(b,w,T,s,r,a,c.borrowingFloor,c.minimumLVR,p,m)),f&&f.validLockFields&&(e||t)&&(r=Math.min(Math.max(r,y.propertyValueMin),y.propertyValueMax),a=Math.min(Math.max(a,y.borrowingAmountMin),y.borrowingAmountMax),i=Math.min(Math.max(i,y.equityAsDepositMin),y.equityAsDepositMax),u=Math.min(Math.max(u,y.cashDepositMin),y.cashDepositMax),s=Math.min(Math.max(s,y.depositAmountMin),y.depositAmountMax),g=e?this.getKeepLockCorrection(d,n,r,a,u,i,b,w,P,x):this.getSellLockCorrection(d,n,r,a,s,b,w,T)),l(l(l({depositAmount:0,cashDeposit:0,equityAsDeposit:0,depositAmountMin:0,depositAmountMax:0,equityAsDepositMax:0,equityAsDepositMin:0,cashDepositMax:0,cashDepositMin:0,validLockFields:!!f&&f.validLockFields,lockedFields:f?f.correctedLockedFields:n},v),y),g)}},{key:"getResults",value:function(e,t){var n="keep"===e.buyerModel,r="sell"===e.buyerModel,i=t.ACCLevyRate,u=t.ACCLevyCap,s=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(t,a),c=l(l({},this.configuration),s),p=h.hexDecode(atob(c.reference));c.bpcr=p/100,c.overdraftLimitRate=c.overdraftLimitRate/100,c.creditCardLimitRate=c.creditCardLimitRate/100,c.studentLoanRate=c.studentLoanRate/100,c.superannuationRate=c.superannuationRate/100,c.minimumLVR=c.minimumLVR/100,c.maximumLVR=c.maximumLVR/100,c.propertyRates=c.propertyRates/100,c.houseInsuranceRate=c.houseInsuranceRate/100,c.defaultLVR=c.defaultLVR/100,c.rentalFactor=c.rentalFactor/100,c.rentalExpenses=c.rentalExpenses/100,c.investmentPropertyLVR=c.investmentPropertyLVR/100,c.ownerOccupierLVR=c.ownerOccupierLVR/100,c.incomeTax=t.taxBands?t.taxBands.threshold:this.incomeTax.threshold;var m=l(l({},this.accLevy),{},{ACCLevyRate:i/100,ACCMaximumRate:u}),d=this.frequenciesRent[e.estimatedRentalIncomePeriod],f=this.frequencies[e.frequency],y=this.frequencies[e.frequencyLoan],g="single"===e.applicationType?1:2,v=""===e.interestRate?"":e.interestRate/100,b=this.getAdultTaxPayable(e.adult1GrossIncome,m,c.incomeTax),w=this.getAdultACCLevy(e.adult1GrossIncome,m.ACCMinimumEarning,m.ACCMaximumRate,m.ACCLevyRate),P=this.getAdultStudentLoan(e.adult1StudentLoan,e.adult1GrossIncome,c.studentLoanThreshold,c.studentLoanRate),x=this.getAdultSuperannuation(e.adult1GrossIncome,c.superannuationRate),T=this.getAdultNetIncome(e.adult1GrossIncome,b,w,P,x),M=g>1?this.getAdultTaxPayable(e.adult2GrossIncome,m,c.incomeTax):0,R=g>1?this.getAdultACCLevy(e.adult2GrossIncome,m.ACCMinimumEarning,m.ACCMaximumRate,m.ACCLevyRate):0,A=g>1?this.getAdultStudentLoan(e.adult2StudentLoan,e.adult2GrossIncome,c.studentLoanThreshold,c.studentLoanRate):0,k=g>1?this.getAdultSuperannuation(e.adult2GrossIncome,c.superannuationRate):0,C=g>1?this.getAdultNetIncome(e.adult2GrossIncome,M,R,A,k):0,B=this.getRentalIncomeGross(e.buyerModel,e.currentProperty,e.newProperty,e.estimatedRentalIncome,d),L=this.getRentalIncomeNet(B,c.rentalFactor),E=this.getNetIncome(T,C,L),I=this.getMonthlyNetIncome(E),S=e.inputMethod,D=this.getMonthlyBenchmarkableExpenses(S,e.totalBenchmarkable,e.totalMainPropertyBenchmarkable,e.totalSecondPropertyBenchmarkable,f),O=this.getMonthlyExpenses(S,e.expensesTotal,f),F=this.getCustomerDeclaredMLA(S,D,O),N=this.getCombinedGrossIncome(g,e.adult1GrossIncome,e.adult2GrossIncome),V=this.getHEBBasic(c.HEPBasicConstant,c.HEPBasicIncome,N,c.HEPBasicHouseholdSize,g,c.HEPBasicChildWeighting,e.dependents,c.HEPBasicStandardError,c.HEPBasicCPI),q=this.getHEBDiscretionary(c.HEPDiscretionaryConstant,c.HEPDiscretionaryIncome,N,c.HEPDiscretionaryHouseholdSize,g,c.HEPDiscretionaryChildWeighting,e.dependents,c.HEPDiscretionaryStandardError,c.HEPDiscretionaryCPI),H=this.getHEB(N,c.salaryFloor,V),Y=this.getAdditionalExpenses(e.buyerModel,e.newProperty,S,c.electricityAllowance,c.internetAllowance,c.maintenanceAllowance),j=this.getMLA(F,H,Y),G=this.getMonthlyDebts(e.debts,f),Z=this.getNonBenchmarkMonthly(S,e.totalNonBenchmarkable,e.totalMainPropertyNonBenchmarkable,e.totalSecondPropertyNonBenchmarkable,f),_=this.getRentalExpenses(e.currentProperty,e.newProperty,B,c.rentalExpenses),z=this.getStressedRepayment(e.buyerModel,e.currentPropertyLoanAmount,c.bpcr,c.borrowingPowerFrequency,c.borrowingPowerTerm),U=this.getLiveInPropertyExpenses(S,e.currentProperty,e.buyerModel,e.currentPropertyValue,c.propertyRates,c.houseInsuranceRate,c.borrowingPowerFrequency),W=this.getNetMC(G,Z,_,z,U),K=this.getMaxRepayments(I,j,W),J=this.getZ(c.bpcr,c.borrowingPowerFrequency,c.borrowingPowerTerm),$=this.getNewPropertyLVR(e.buyerModel,c.ownerOccupierLVR,e.newProperty,c.investmentPropertyLVR),Q=this.getMaxPropertyPrice(K,c.borrowingPowerFrequency,J,$,e.buyerModel,e.inputMethod,c.propertyRates,c.houseInsuranceRate,e.newProperty),X=this.getMaxBorrowings(Q,$),ee=this.getBPCalculationResult(Q,e.newPropertyPrice,X,c.borrowingFloor,$),te=Number(e.newPropertyPrice),ne=this.getNewPropertyBorrowingAmount(ee,te,$),re=this.getU(e.currentPropertyValue,e.currentPropertyLoanAmount),oe=this.getCurrentPropertyEquity(e.buyerModel,re),ae=this.getCurrentPropertyLVR(e.buyerModel,c.ownerOccupierLVR,e.currentProperty,c.investmentPropertyLVR),ie=this.getV2_(e.currentPropertyValue,ae,e.currentPropertyLoanAmount),ue=this.getAvailableEquity(e.buyerModel,ie,X,c.minimumLVR),se=this.getEquityAsDeposit(ne,$,ue,X),le=this.getCashDeposit(ne,e.newPropertyPrice,se),ce=!n&&ee?o.default.roundDown(Math.max(re,0),0):0,pe=Math.min(ce,te*(1-c.minimumLVR),te-c.borrowingFloor),me=r?Math.max(pe,te*(1-$)):0,he=ce>=me?ce-pe:ce-me,de=n?this.getPropertyValue(e.buyerModel,ee,e.newPropertyPrice):te,fe=ne=r?te-me:ne,ye=me,ge=se,ve=le,be=e.latestUpdatedField;(n&&!this.keepLockFields.includes(be)||r&&!this.sellLockFields.includes(be))&&(be=null),be&&(fe=e.newPropertyBorrowingAmount,de=e.propertyValue,ye=e.depositAmount,ve=e.cashDeposit,ge=e.equityAsDeposit),de=o.default.round(de,2),fe=o.default.round(fe,2),ye=o.default.round(ye,2),ge=o.default.round(ge,2),ve=o.default.round(ve,2);var we,Pe,xe,Te=this.getLockingResults(n,r,e.lockedFields,de,fe,ge,ve,ye,c,$,X,ue,be),Me=Te.validLockFields?Te.propertyValue:de,Re=Te.validLockFields?Te.borrowingAmount:fe,Ae=Te.validLockFields?Te.depositAmount:ye,ke=Te.validLockFields?Te.cashDeposit:ve,Ce=Te.validLockFields?Te.equityAsDeposit:ge,Be=Re+(n?Ce:0),Le=""===v;if(Le)we=0,Pe=0,xe="";else if(e.repaymentAmount>0){we=e.repaymentAmount,Pe=this.getTerm(v,y,we,Be);var Ee=o.default.roundDown(Pe,0),Ie=o.default.roundDown(12*Pe%12,0);xe=Ee+" year"+(Ee>1?"s":""),Ie>0&&(xe+=" and "+Ie+" month"+(Ie>1?"s":""))}else Pe=e.term,we=0===v?0:this.getRepaymentAmount(v,y,Pe,Be),xe=null;var Se=this.getTotalMortgageAmount(v,we,Pe,y),De=this.getMultipleOfAmountBorrowing(v,Se,Be),Oe=this.getInterest(v,Se,Be),Fe=this.getRepaymentBounds(v,y,Be,K,c.minimumLoanTerm),Ne={min:c.minimumInterestRate,max:Le?c.maximumInterestRate:this.getMaxInterestRate(Pe,y,Be,c.maximumInterestRate,v,K)};v=Le?"":this.checkWithinBounds(v,{min:Ne.min/100,max:Ne.max/100});var Ve={min:this.getMinTerm(v,Be,y,c.minimumLoanTerm,K),max:c.maximumLoanTerm},qe={min:Fe.min,max:Fe.max},He={newPropertyBorrowingAmount:{min:Te.validLockFields?Te.borrowingAmountMin:Re,max:Te.validLockFields?Te.borrowingAmountMax:Re},depositAmount:{min:Te.validLockFields?Te.depositAmountMin:Ae,max:Te.validLockFields?Te.depositAmountMax:Ae},equityAsDeposit:{min:Te.validLockFields?Te.equityAsDepositMin:Ce,max:Te.validLockFields?Te.equityAsDepositMax:Ce},cashDeposit:{min:Te.validLockFields?Te.cashDepositMin:ke,max:Te.validLockFields?Te.cashDepositMax:ke},propertyValue:{min:Te.validLockFields?Te.propertyValueMin:Me,max:Te.validLockFields?Te.propertyValueMax:Me},interestRate:Ne,terms:Ve,repaymentsLoan:qe};return Pe=this.checkWithinBounds(Pe,Ve),we=this.checkWithinBounds(we,qe),{borrowingPowerCalculations:{combinedGrossIncome:N,netIncome:E,monthlyNetIncome:I,adult1TaxPayable:b,adult1ACCLevy:w,adult1StudentLoan:P,adult1Superannuation:x,adult1NetIncome:T,adult2TaxPayable:M,adult2ACCLevy:R,adult2StudentLoan:A,adult2Superannuation:k,adult2NetIncome:C,rentalIncomeGross:B,rentalIncomeNet:L,monthlyExpenses:O,monthlyBenchmarkableExpenses:D,customerDeclaredMLA:F,HEB:H,HEBBasic:V,HEBDiscretionary:q,MLA:j,monthlyDebts:G,monthlyNonBenchmarkableExpenses:Z,rentalExpenses:_,stressedHomeLoanRepayments:z,additionalExpenses:Y,netMC:W,maxRepayments:K,Z:J,maxPropertyPrice:Q,maxBorrowings:X},currentPropertyEquity:oe,availableEquity:ue,saleProceeds:ce,saleDepositAmount:pe,depositToSpare:he,newPropertyBorrowingAmount:Re,depositAmount:Ae,equityAsDeposit:Ce,cashDeposit:ke,propertyValue:Me,interestRate:Le?"":o.default.round(100*v,2),repaymentAmount:we,totalMortgageAmount:Se,multipleOfAmountBorrowing:De,principal:Be,interest:Oe,fieldBounds:He,BPDetermination:ee,term:Pe,termNaturalLanguage:xe,borrowingFloor:c.borrowingFloor,newPropertyLVR:$,locking:Te}}}])&&c(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();t.default=d},5947:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r,o=(r=n(44207))&&r.__esModule?r:{default:r};function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}function i(e,t){for(var n=0;n1?"s":"");return n>0&&(r+=" and "+n+" month"+(n>1?"s":"")),r}},{key:"calculateTotalPaid",value:function(e,t,n){return e*t*this.frequencies[n]}},{key:"calculateActualTerm",value:function(e){var t=e.portionTimeToPay,n=e.portionRate,r=e.portionCustomRate,a=e.portionRepaymentsFrequency,i=e.portionAmount,u=e.portionRepaymentsAmount,s="custom"===n?r:n;return"term"===e.changeType?t:o.default.roundUp(o.default.nper(s/100/this.frequencies[a],u,-i)/this.frequencies[a],2)}},{key:"calculateMinRepayment",value:function(e){var t=e.portionRate,n=e.portionCustomRate,r=e.portionRepaymentsFrequency,a=e.portionAmount,i=e.maxTerm,u="custom"===t?n:t;return o.default.roundUp(o.default.pmt(a,u/100/this.frequencies[r],(i||30)*this.frequencies[r]),2)}},{key:"calculateMaxRepayment",value:function(e){var t=e.portionRate,n=e.portionCustomRate,r=e.portionRepaymentsFrequency,a=e.portionAmount,i=e.minTerm,u="custom"===t?n:t;return o.default.roundUp(o.default.pmt(a,u/100/this.frequencies[r],(i||5)*this.frequencies[r]),2)}},{key:"calculateRepayment",value:function(e){var t=e.portionTimeToPay,n=e.portionRate,r=e.portionCustomRate,a=e.portionRepaymentsFrequency,i=e.portionAmount,u=e.portionRepaymentsAmount,s="custom"===n?r:n;return"term"===e.changeType?o.default.roundUp(o.default.pmt(i,s/100/this.frequencies[a],t*this.frequencies[a]),2):u}},{key:"calculateGraphDataPoints",value:function(e){var t=this,n=[];return e.forEach((function(e){t.calculateClosingBalances(e).forEach((function(e,t){void 0===n[t]?n[t]=e:n[t]+=e}))})),n.map((function(e,t){return[t,e]}))}},{key:"calculateEachOption",value:function(e){var t=this,n=[],r=[],o=0,a="",i=0,u=0;return e.forEach((function(e){var o=e.portionRepaymentsFrequency,i=e.changeType;!a&&o&&(a="".concat(o,"ly"));var u=t.calculateRepayment(e),s=t.calculateActualTerm(e);n.push({frequencyPerYear:t.frequencies[o],repayment:u,actualTerm:s,totalPaid:t.calculateTotalPaid(u,s,o)});var l=t.calculateMinRepayment(e),c=t.calculateMaxRepayment(e);"repayment"===i?r.push({portionTimeToPay:s,minRepayment:l,maxRepayment:c}):r.push({portionRepaymentsAmount:u,minRepayment:l,maxRepayment:c})})),n.forEach((function(e){i=Math.max(i,e.actualTerm),o+=e.repayment,u+=e.totalPaid})),{totalRepayment:o,repaymentFrequency:a,totalTerm:i,totalTermNaturalLanguage:this.getTermNaturalLanguage(i),totalPay:u,newPortions:r,graphDataPoints:this.calculateGraphDataPoints(n)}}},{key:"getResults",value:function(e){return e?this.calculateEachOption(e):{}}}])&&i(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();t.default=s},64550:function(e){"use strict";e.exports={incomeTax:{threshold:[{lowerBound:"0",taxRate:"0",upperBound:"18200"},{lowerBound:"18201",taxRate:"0.19",upperBound:"45000"},{lowerBound:"45001",taxRate:"0.325",upperBound:"120000"},{lowerBound:"120001",taxRate:"0.37",upperBound:"180000"},{lowerBound:"180001",taxRate:"0.45",upperBound:"+"}],year:"2023-2024"},incomeTaxNZ:{threshold:[{lowerBound:"0",taxRate:"0.105",upperBound:"14000"},{lowerBound:"14001",taxRate:"0.175",upperBound:"48000"},{lowerBound:"48001",taxRate:"0.30",upperBound:"70000"},{lowerBound:"70001",taxRate:"0.33",upperBound:"180000"},{lowerBound:"180001",taxRate:"0.39",upperBound:"+"}],year:"2023-2024"},standardDeduction:12950,incomeTaxNZAssumptions:{ACCLevyThreshold:{accMin:0,accMax:139384,accLevyRate:1.53},IETCThreshold:{maxIETC:520,reductionIETC:.13},studentLoansThreshold:{minimumEarning:22828,rate:12}},stampDutyData:{state:[{id:"nsw",name:"New South Wales",land_transfer_fee:{fee:"165.40"},mortgage_registration_fee:{fee:"165.40"},stamp_duty:[{threshold:[{lowerBound:"0",upperBound:"16000",fee:"0",extra:"1.25",per:"100",min:"10",partThereOf:"true"},{lowerBound:"16001",upperBound:"35000",fee:"200",extra:"1.5",per:"100",min:"10",partThereOf:"true"},{lowerBound:"35001",upperBound:"93000",fee:"485",extra:"1.75",per:"100",min:"10",partThereOf:"true"},{lowerBound:"93001",upperBound:"351000",fee:"1500",extra:"3.5",per:"100",min:"10",partThereOf:"true"},{lowerBound:"351001",upperBound:"1168000",fee:"10530",extra:"4.5",per:"100",min:"10",partThereOf:"true"},{lowerBound:"1168001",upperBound:"3505000",fee:"47295",extra:"5.5",per:"100",min:"10",partThereOf:"true"},{lowerBound:"3505001",upperBound:"+",fee:"175830",extra:"7",per:"100",min:"10",partThereOf:"true"}],type:"i-fh, i-fh-nh, i-fh-vl, ppr, ppr-nh, ppr-vl, i, i-nh, i-vl, i-off, i-fh-off, ppr-off, ppr-fh-off, ppr-pen, ppr-fh-pen, i-pen, i-fh-pen"},{threshold:[{lowerBound:"0",upperBound:"800000",fee:"0",extra:"0",per:"100",partThereOf:"true"},{lowerBound:"800001",upperBound:"1000000",additional:"1000000",additional2:"800000",additional3:"30735",fee:"30735",extra:"4.5",per:"100",min:"10",subtract:"1",appliedToTotal:"true"},{lowerBound:"1000001",upperBound:"1168000",fee:"39735",extra:"4.5",per:"100",min:"10",partThereOf:"true"},{lowerBound:"1168001",upperBound:"3505000",fee:"47295",extra:"5.5",per:"100",min:"10",partThereOf:"true"},{lowerBound:"3505000",upperBound:"+",fee:"175830",extra:"7",per:"100",min:"10",partThereOf:"true"}],type:"ppr-fh, ppr-fh-nh"},{threshold:[{lowerBound:"0",upperBound:"350000",fee:"0",extra:"0",per:"100",partThereOf:"true"},{lowerBound:"350001",upperBound:"351000",additional:"450000",additional2:"350000",additional3:"10495",fee:"10495",extra:"3.5",per:"100",min:"10",subtract:"1",appliedToTotal:"true"},{lowerBound:"351001",upperBound:"450000",additional:"450000",additional2:"350000",additional3:"10495",fee:"10530",extra:"4.5",per:"100",min:"10",subtract:"1",appliedToTotal:"true"},{lowerBound:"450001",upperBound:"1168000",fee:"14985",min:"10",extra:"4.50",per:"100",partThereOf:"true"},{lowerBound:"1168001",upperBound:"3505000",fee:"47295",min:"10",extra:"5.50",per:"100",partThereOf:"true"},{lowerBound:"3505001",upperBound:"+",fee:"175830",extra:"7",per:"100",min:"10",partThereOf:"true"}],type:"ppr-fh-vl"}],notes:"First home buyers are eligible for concessions on the purchase of an established home, new home, or vacant land. (Last updated 03 July 2023)"},{id:"qld",name:"Queensland",land_transfer_fee:{threshold:[{lowerBound:"0",upperBound:"180000",fee:"224.32",extra:"0",per:"1",appliedToTotal:"true"},{lowerBound:"180001",upperBound:"+",fee:"224.32",extra:"42.13",per:"10000",partThereOf:"true"}]},mortgage_registration_fee:{fee:"224.32"},stamp_duty:[{threshold:[{lowerBound:"0",upperBound:"5000",fee:"0",extra:"0",per:"100",partThereOf:"true"},{lowerBound:"5001",upperBound:"75000",fee:"0",extra:"1.5",per:"100",partThereOf:"true"},{lowerBound:"75001",upperBound:"540000",fee:"1050",extra:"3.5",per:"100",partThereOf:"true"},{lowerBound:"540001",upperBound:"1000000",fee:"17325",extra:"4.5",per:"100",partThereOf:"true"},{lowerBound:"1000001",upperBound:"+",fee:"38025",extra:"5.75",per:"100",partThereOf:"true"}],type:"i-fh, i-fh-nh, i-fh-vl, ppr-vl, i, i-nh, i-vl, i-off, i-fh-off, ppr-off, ppr-fh-off, ppr-pen, ppr-fh-pen, i-pen, i-fh-pen"},{threshold:[{lowerBound:"0",upperBound:"350000",fee:"0",extra:"1",per:"100",partThereOf:"true"},{lowerBound:"350001",upperBound:"540000",fee:"3500",extra:"3.5",per:"100",partThereOf:"true"},{lowerBound:"540001",upperBound:"1000000",fee:"10150",extra:"4.5",per:"100",partThereOf:"true"},{lowerBound:"1000001",upperBound:"+",fee:"30850",extra:"5.75",per:"100",partThereOf:"true"}],type:"ppr, ppr-nh"},{threshold:[{lowerBound:"0",upperBound:"350000",extra:"1",per:"100",fee:"0",appliedToTotal:"true",subtract:"8750",partThereOf:"true"},{lowerBound:"350001",upperBound:"504999.99",extra:"3.50",per:"100",fee:"3500",subtract:"8750",appliedToTotal:"false",partThereOf:"false"},{lowerBound:"505000",upperBound:"509999.99",extra:"3.50",per:"100",fee:"8925",subtract:"7875",appliedToTotal:"false",partThereOf:"false"},{lowerBound:"510000",upperBound:"514999.99",extra:"3.50",per:"100",fee:"9100",appliedToTotal:"false",subtract:"7000",partThereOf:"false"},{lowerBound:"515000",upperBound:"519999.99",extra:"3.50",per:"100",fee:"9275",appliedToTotal:"false",subtract:"6125",partThereOf:"false"},{lowerBound:"520000",upperBound:"524999.99",extra:"3.5",per:"100",fee:"9450",appliedToTotal:"false",subtract:"5250",partThereOf:"false"},{lowerBound:"525000",upperBound:"529999.99",extra:"3.5",per:"100",fee:"9625",appliedToTotal:"false",subtract:"4375",partThereOf:"false"},{lowerBound:"530000",upperBound:"534999.99",extra:"3.5",per:"100",fee:"9800",appliedToTotal:"false",subtract:"3500",partThereOf:"false"},{lowerBound:"535000",upperBound:"539999.99",extra:"3.5",per:"100",fee:"9975",appliedToTotal:"false",subtract:"2625",partThereOf:"false"},{lowerBound:"540000",upperBound:"544999.99",extra:"4.5",per:"100",fee:"10150",appliedToTotal:"false",subtract:"1750",partThereOf:"false"},{lowerBound:"545000",upperBound:"549999.99",extra:"4.5",per:"100",fee:"10375",appliedToTotal:"false",subtract:"875",partThereOf:"false"},{lowerBound:"550000",upperBound:"1000000",extra:"4.5",per:"100",fee:"10600",appliedToTotal:"false",subtract:"0",partThereOf:"false"},{lowerBound:"1000001",upperBound:"+",extra:"5.75",per:"100",fee:"30850",appliedToTotal:"false",subtract:"0",partThereOf:"true"}],type:"ppr-fh, ppr-fh-nh"},{threshold:[{lowerBound:"0",upperBound:"250000",fee:"0",extra:"0",per:"100",partThereOf:"true"},{lowerBound:"250001",upperBound:"259999.99",fee:"7175",extra:"3.5",per:"100",subtract:"7175",partThereOf:"true"},{lowerBound:"260000",upperBound:"269999.99",fee:"7525",extra:"3.5",per:"100",subtract:"6700",partThereOf:"false"},{lowerBound:"270000",upperBound:"279999.99",fee:"7875",extra:"3.5",per:"100",subtract:"6225",partThereOf:"false"},{lowerBound:"280000",upperBound:"289999.99",fee:"8225",extra:"3.5",per:"100",subtract:"5750",partThereOf:"false"},{lowerBound:"290000",upperBound:"299999.99",fee:"8575",extra:"3.5",per:"100",subtract:"5275",partThereOf:"false"},{lowerBound:"300000",upperBound:"309999.99",fee:"8925",extra:"3.5",per:"100",subtract:"4800",partThereOf:"false"},{lowerBound:"310000",upperBound:"319999.99",fee:"9275",extra:"3.5",per:"100",subtract:"4325",partThereOf:"false"},{lowerBound:"320000",upperBound:"329999.99",fee:"9625",extra:"3.5",per:"100",subtract:"3850",partThereOf:"false"},{lowerBound:"330000",upperBound:"339999.99",fee:"9975",extra:"3.5",per:"100",subtract:"3375",partThereOf:"false"},{lowerBound:"340000",upperBound:"349999.99",fee:"10325",extra:"3.5",per:"100",subtract:"2900",partThereOf:"false"},{lowerBound:"350000",upperBound:"359999.99",fee:"10675",extra:"3.5",per:"100",subtract:"2425",partThereOf:"false"},{lowerBound:"360000",upperBound:"369999.99",fee:"11025",extra:"3.5",per:"100",subtract:"1950",partThereOf:"false"},{lowerBound:"370000",upperBound:"379999.99",fee:"11375",extra:"3.5",per:"100",subtract:"1475",partThereOf:"false"},{lowerBound:"380000",upperBound:"389999.99",fee:"11725",extra:"3.5",per:"100",subtract:"1000",partThereOf:"false"},{lowerBound:"390000",upperBound:"399999.99",fee:"12075",extra:"3.5",per:"100",subtract:"525",partThereOf:"false"},{lowerBound:"400000",upperBound:"540000",fee:"12425",extra:"3.5",per:"100",subtract:"0",partThereOf:"false"},{lowerBound:"540001",upperBound:"1000000",fee:"17325",extra:"4.5",per:"100",subtract:"0",partThereOf:"true"},{lowerBound:"1000001",upperBound:"+",fee:"38025",extra:"5.75",per:"100",subtract:"0",partThereOf:"true"}],type:"ppr-fh-vl"}],notes:"A transfer duty (stamp duty) concession is available when purchasing a home to live in. Additional concessions are available for first home buyers including for the purchase of vacant land, provided a place of residence is constructed. (Last updated 03 July 2023)"},{id:"vic",name:"Victoria",land_transfer_fee:{threshold:[{lowerBound:"0",upperBound:"+",fee:"96.00",extra:"2.34",per:"1000",partThereOf:"false",appliedToTotal:"false",max:"3607"}]},mortgage_registration_fee:{fee:"118.90"},stamp_duty:[{threshold:[{lowerBound:"0",upperBound:"600000",fee:"0",extra:"0",per:"100",partThereOf:"true"},{lowerBound:"600001",upperBound:"750000",fee:"31070",extra:"6",per:"100",constant:"1",partThereOf:"true"},{lowerBound:"750001",upperBound:"960000",fee:"40070",extra:"6",per:"100",partThereOf:"true"},{lowerBound:"960001",upperBound:"2000000",fee:"0",extra:"5.5",per:"100",partThereOf:"false",appliedToTotal:"true"},{lowerBound:"2000001",upperBound:"+",fee:"0",extra:"6.5",per:"100",partThereOf:"false",appliedToTotal:"true"}],type:"ppr-fh, ppr-fh-nh, ppr-fh-vl, ppr-fh-off"},{threshold:[{lowerBound:"0",upperBound:"25000",fee:"0",extra:"1.40",per:"100",partThereOf:"false",appliedToTotal:"true"},{lowerBound:"25001",upperBound:"130000",fee:"350",extra:"2.40",per:"100",partThereOf:"true"},{lowerBound:"130001",upperBound:"440000",fee:"2870",extra:"5.00",per:"100",partThereOf:"true"},{lowerBound:"440001",upperBound:"550000",fee:"18370",extra:"6.00",per:"100",partThereOf:"true"},{lowerBound:"550001",upperBound:"960000",fee:"28070",extra:"6.00",per:"100",partThereOf:"true"},{lowerBound:"960001",upperBound:"2000000",fee:"0",extra:"5.50",per:"100",partThereOf:"true",appliedToTotal:"true"},{lowerBound:"2000001",upperBound:"+",fee:"110000",extra:"6.50",per:"100",partThereOf:"true"}],type:"ppr, ppr-vl, ppr-nh, ppr-off"},{threshold:[{lowerBound:"0",upperBound:"25000",fee:"0",extra:"1.4",per:"100",partThereOf:"false",appliedToTotal:"true"},{lowerBound:"25001",upperBound:"130000",fee:"350",extra:"2.4",per:"100",partThereOf:"true"},{lowerBound:"130001",upperBound:"960000",fee:"2870",extra:"6",per:"100",partThereOf:"true"},{lowerBound:"960001",upperBound:"2000000",fee:"0",extra:"5.5",per:"100",partThereOf:"true",appliedToTotal:"true"},{lowerBound:"2000001",upperBound:"+",fee:"110000",extra:"6.5",per:"100",partThereOf:"true"}],type:"i, i-fh, i-vl, i-fh-vl, i-off, i-fh-off, i-fh-nh, i-nh, i-pen, i-fh-pen"},{threshold:[{lowerBound:"0",upperBound:"330000",exception:"true"},{lowerBound:"330001",upperBound:"750000",constant1:"160875",constant2:"7",constant3:"429",constant4:"14000"},{lowerBound:"750001",upperBound:"+",fee:"0",extra:"5.5",per:"100",partThereOf:"true",appliedToTotal:"true"}],type:"ppr-pen, ppr-fh-pen"}],notes:"Transfer fee and mortgage registration fee are based on electronic lodgement. Duty concessions are available for pensioners and for off-the-plan purchases. When purchasing off-the-plan the duty is determined by the contract price paid minus construction costs. (Last updated 03 July 2023)"},{id:"sa",name:"South Australia",land_transfer_fee:{threshold:[{lowerBound:"0",upperBound:"5000",fee:"187",extra:"0",partThereOf:"true",appliedToTotal:"true"},{lowerBound:"5001",upperBound:"20000",fee:"209",extra:"0",partThereOf:"true",appliedToTotal:"true"},{lowerBound:"20001",upperBound:"40000",fee:"230",extra:"0",partThereOf:"true",appliedToTotal:"true"},{lowerBound:"40001",upperBound:"50000",fee:"323",extra:"0",partThereOf:"true",appliedToTotal:"true"},{lowerBound:"50001",upperBound:"+",fee:"323",extra:"96",per:"10000",partThereOf:"true"}]},mortgage_registration_fee:{fee:"187"},stamp_duty:[{threshold:[{lowerBound:"0",upperBound:"12000",fee:"0",extra:"1",per:"100",partThereOf:"true"},{lowerBound:"12001",upperBound:"30000",fee:"120",extra:"2",per:"100",partThereOf:"true"},{lowerBound:"30001",upperBound:"50000",fee:"480",extra:"3",per:"100",partThereOf:"true"},{lowerBound:"50001",upperBound:"100000",fee:"1080",extra:"3.5",per:"100",partThereOf:"true"},{lowerBound:"100001",upperBound:"200000",fee:"2830",extra:"4",per:"100",partThereOf:"true"},{lowerBound:"200001",upperBound:"250000",fee:"6830",extra:"4.25",per:"100",partThereOf:"true"},{lowerBound:"250001",upperBound:"300000",fee:"8955",extra:"4.75",per:"100",partThereOf:"true"},{lowerBound:"300001",upperBound:"500000",fee:"11330",extra:"5",per:"100",partThereOf:"true"},{lowerBound:"500001",upperBound:"+",fee:"21330",extra:"5.5",per:"100",partThereOf:"true"}],type:"ppr-fh, i-fh, i-fh-nh, i-fh-vl, ppr, ppr-nh, ppr-vl, i, i-nh, i-vl, ppr-off, ppr-fh-off, i-off, i-fh-off, ppr-pen, ppr-fh-pen, i-pen, i-fh-pen"},{threshold:[{lowerBound:"0",upperBound:"650000",fee:"0",extra:"0",per:"100",partThereOf:"true"},{lowerBound:"650001",upperBound:"700000",fee:"29580",extra:"5.50",per:"100",subtract:"1",partThereOf:"true"},{lowerBound:"700001",upperBound:"+",fee:"32330",extra:"5.50",per:"100",partThereOf:"true"}],type:"ppr-fh-nh"},{threshold:[{lowerBound:"0",upperBound:"400000",fee:"0",extra:"0",per:"100",partThereOf:"true"},{lowerBound:"400001",upperBound:"450000",fee:"16330",extra:"5",per:"100",subtract:"1",partThereOf:"true"},{lowerBound:"450001",upperBound:"500000",fee:"18830",extra:"5",per:"100",partThereOf:"true"},{lowerBound:"500001",upperBound:"+",fee:"21330",extra:"5.50",per:"100",partThereOf:"true"}],type:"ppr-fh-vl"}],notes:"First Home Owners are be eligible for the First Home Owner stamp duty relief for new homes and vacant land. A First Home Owner Grant is also available. (Last updated 03 July 2023)"},{id:"wa",name:"Western Australia",land_transfer_fee:{threshold:[{lowerBound:"0",upperBound:"85000",fee:"203"},{lowerBound:"85001",upperBound:"120000",fee:"213"},{lowerBound:"120001",upperBound:"200000",fee:"233"},{lowerBound:"200001",upperBound:"300000",fee:"253"},{lowerBound:"300001",upperBound:"400000",fee:"273"},{lowerBound:"400001",upperBound:"500000",fee:"293"},{lowerBound:"500001",upperBound:"600000",fee:"313"},{lowerBound:"600001",upperBound:"700000",fee:"333"},{lowerBound:"700001",upperBound:"800000",fee:"353"},{lowerBound:"800001",upperBound:"900000",fee:"373"},{lowerBound:"900001",upperBound:"1000000",fee:"393"},{lowerBound:"1000001",upperBound:"1100000",fee:"413"},{lowerBound:"1100001",upperBound:"1200000",fee:"433"},{lowerBound:"1200001",upperBound:"1300000",fee:"453"},{lowerBound:"1300001",upperBound:"1400000",fee:"473"},{lowerBound:"1400001",upperBound:"1500000",fee:"493"},{lowerBound:"1500001",upperBound:"1600000",fee:"513"},{lowerBound:"1600001",upperBound:"1700000",fee:"533"},{lowerBound:"1700001",upperBound:"1800000",fee:"553"},{lowerBound:"1800001",upperBound:"1900000",fee:"573"},{lowerBound:"1900001",upperBound:"2000000",fee:"593"},{lowerBound:"2000001",upperBound:"+",fee:"593",extra:"20",per:"100000",partThereOf:"true"}]},mortgage_registration_fee:{fee:"203"},stamp_duty:[{threshold:[{lowerBound:"0",upperBound:"120000",fee:"0",extra:"1.9",per:"100",partThereOf:"true"},{lowerBound:"120001",upperBound:"150000",fee:"2280",extra:"2.85",per:"100",partThereOf:"true"},{lowerBound:"150001",upperBound:"360000",fee:"3135",extra:"3.8",per:"100",partThereOf:"true"},{lowerBound:"360001",upperBound:"725000",fee:"11115",extra:"4.75",per:"100",partThereOf:"true"},{lowerBound:"725001",upperBound:"+",fee:"28453",extra:"5.15",per:"100",partThereOf:"true"}],type:"i-fh, i-fh-nh, i-fh-vl, ppr-nh, ppr-vl, i, i-nh, i-vl, i-off, i-fh-off, ppr-off, ppr-fh-off, ppr-pen, ppr-fh-pen, i-pen, i-fh-pen"},{threshold:[{lowerBound:"0",upperBound:"430000",fee:"0",extra:"0",per:"100",partThereOf:"true"},{lowerBound:"430001",upperBound:"530000",fee:"0",extra:"19.19",per:"100",partThereOf:"true"},{lowerBound:"530001",upperBound:"725000",fee:"19190",extra:"4.75",per:"100",partThereOf:"true"},{lowerBound:"725001",upperBound:"+",fee:"28453",extra:"5.15",per:"100",partThereOf:"true"}],type:"ppr-fh, ppr-fh-nh"},{threshold:[{lowerBound:"0",upperBound:"300000",fee:"0",extra:"0",per:"100",partThereOf:"true"},{lowerBound:"300001",upperBound:"400000",fee:"0",extra:"13.01",per:"100",partThereOf:"true"},{lowerBound:"400001",upperBound:"725000",fee:"13015",extra:"4.75",per:"100",partThereOf:"true"},{lowerBound:"725001",upperBound:"+",fee:"28453",extra:"5.15",per:"100",partThereOf:"true"}],type:"ppr-fh-vl"},{threshold:[{lowerBound:"0",upperBound:"120000",fee:"0",extra:"1.50",per:"100",partThereOf:"true"},{lowerBound:"120001",upperBound:"150000",fee:"2280",extra:"2.85",per:"100",partThereOf:"true"},{lowerBound:"150001",upperBound:"360000",fee:"3135",extra:"3.8",per:"100",partThereOf:"true"},{lowerBound:"360001",upperBound:"725000",fee:"11115",extra:"4.75",per:"100",partThereOf:"true"},{lowerBound:"725001",upperBound:"+",fee:"28453",extra:"5.15",per:"100",partThereOf:"true"}],type:"ppr"}],notes:"A concessional rate of duty applies to property that is a principal place of residence where the value of the entire property doesn't exceed $200,000. (Last updated 03 July 2023)"},{id:"nt",name:"Northern Territory",land_transfer_fee:{fee:"165"},mortgage_registration_fee:{fee:"165"},stamp_duty:[{threshold:[{lowerBound:"0",upperBound:"525000",constant:"0.06571441",multiplier:"15",divisor:"1000"},{lowerBound:"525001",upperBound:"3000000",fee:"0",extra:"4.95",per:"100",partThereOf:"true",appliedToTotal:"true"},{lowerBound:"3000001",upperBound:"5000000",fee:"0",extra:"5.75",per:"100",partThereOf:"true",appliedToTotal:"true"},{lowerBound:"5000001",upperBound:"+",fee:"0",extra:"5.95",per:"100",partThereOf:"true",appliedToTotal:"true"}],type:"ppr-fh, ppr-fh-nh, ppr-fh-vl, i-fh, i-fh-nh, i-fh-vl, ppr, ppr-nh, ppr-vl, i, i-nh, i-vl"}],notes:"Additional mortgage registration and transfer fees may be payable should the documents submitted exceed two pages in length. (Last updated 03 July 2023)"},{id:"act",name:"Australian Capital Territory",land_transfer_fee:{fee:"446"},mortgage_registration_fee:{fee:"166"},stamp_duty:[{threshold:[{lowerBound:"0",upperBound:"200000",fee:"0",extra:"1.20",per:"100",partThereOf:"true",min:"20"},{lowerBound:"200001",upperBound:"300000",fee:"2400",extra:"2.20",per:"100",partThereOf:"true"},{lowerBound:"300001",upperBound:"500000",fee:"4600",extra:"3.4",per:"100",partThereOf:"true"},{lowerBound:"500001",upperBound:"750000",fee:"11400",extra:"4.32",per:"100",partThereOf:"true"},{lowerBound:"750001",upperBound:"1000000",fee:"22200",extra:"5.90",per:"100",partThereOf:"true"},{lowerBound:"1000001",upperBound:"1455000",fee:"36950",extra:"6.40",per:"100",partThereOf:"true"},{lowerBound:"1455001",upperBound:"+",fee:"0",extra:"4.54",per:"100",partThereOf:"true",appliedToTotal:"true"}],type:"i-fh, i-fh-nh, i-fh-vl, i, i-nh, i-vl, i-off, i-fh-off, ppr-off, ppr-fh-off, ppr-pen, ppr-fh-pen, i-pen, i-fh-pen"},{threshold:[{lowerBound:"0",upperBound:"260000",fee:"0",extra:"0.49",per:"100",partThereOf:"true",min:"20"},{lowerBound:"260001",upperBound:"300000",fee:"1274",extra:"2.20",per:"100",partThereOf:"true"},{lowerBound:"300001",upperBound:"500000",fee:"2154",extra:"3.4",per:"100",partThereOf:"true"},{lowerBound:"500001",upperBound:"750000",fee:"8954",extra:"4.32",per:"100",partThereOf:"true"},{lowerBound:"750001",upperBound:"1000000",fee:"19754",extra:"5.90",per:"100",partThereOf:"true"},{lowerBound:"1000001",upperBound:"1455000",fee:"34504",extra:"6.40",per:"100",partThereOf:"true"},{lowerBound:"1455001",upperBound:"+",fee:"0",extra:"4.54",per:"100",partThereOf:"true",appliedToTotal:"true"}],type:"ppr, ppr-nh, ppr-vl"},{threshold:[{lowerBound:"0",upperBound:"1000000",fee:"0",extra:"0",per:"1",partThereOf:"true"},{lowerBound:"1000001",upperBound:"1455000",fee:"34504",extra:"6.40",per:"100",subtract:"34504",partThereOf:"true"},{lowerBound:"1455001",upperBound:"+",fee:"0",extra:"4.54",per:"100",subtract:"34504",partThereOf:"true",appliedToTotal:"true"}],type:"ppr-fh, ppr-fh-nh, ppr-fh-vl"}],notes:"The Home Buyer Concession scheme eliminates duty for purchases of primary residences where all purchases are over 18 and have not owned property in the past two years. Income thresholds apply to this concession. (Last updated 03 July 2023)"},{id:"tas",name:"Tasmania",land_transfer_fee:{fee:"233.18"},mortgage_registration_fee:{fee:"152.19"},stamp_duty:[{threshold:[{lowerBound:"0",upperBound:"3000",fee:"50",extra:"0",per:"100",partThereOf:"true"},{lowerBound:"3001",upperBound:"25000",fee:"50",extra:"1.75",per:"100",partThereOf:"true"},{lowerBound:"25001",upperBound:"75000",fee:"435",extra:"2.25",per:"100",partThereOf:"true"},{lowerBound:"75001",upperBound:"200000",fee:"1560",extra:"3.5",per:"100",partThereOf:"true"},{lowerBound:"200001",upperBound:"375000",fee:"5935",extra:"4.00",per:"100",partThereOf:"true"},{lowerBound:"375001",upperBound:"725000",fee:"12935",extra:"4.25",per:"100",partThereOf:"true"},{lowerBound:"725001",upperBound:"+",fee:"27810",extra:"4.50",per:"100",partThereOf:"true"}],type:"ppr-fh-nh, ppr-fh-vl, i-fh, i-fh-nh, i-fh-vl, ppr, ppr-nh, ppr-vl, i, i-nh, i-vl, i-off, i-fh-off, ppr-off, ppr-fh-off, ppr-pen, ppr-fh-pen, i-pen, i-fh-pen"},{threshold:[{lowerBound:"0",upperBound:"3000",fee:"50",extra:"0",per:"100",subtract:1,partThereOf:"true"},{lowerBound:"3001",upperBound:"25000",fee:"50",extra:"1.75",per:"100",subtract:1,partThereOf:"true"},{lowerBound:"25001",upperBound:"75000",fee:"435",extra:"2.25",per:"100",subtract:1,partThereOf:"true"},{lowerBound:"75001",upperBound:"200000",fee:"1560",extra:"3.5",per:"100",subtract:1,partThereOf:"true"},{lowerBound:"200001",upperBound:"375000",fee:"5935",extra:"4.00",per:"100",subtract:1,partThereOf:"true"},{lowerBound:"375001",upperBound:"600000",fee:"12935",extra:"4.25",per:"100",subtract:1,partThereOf:"true"},{lowerBound:"600001",upperBound:"725000",fee:"22498",extra:"4.25",per:"100",partThereOf:"true"},{lowerBound:"725001",upperBound:"+",fee:"27810",extra:"4.50",per:"100",partThereOf:"true"}],type:"ppr-fh"}],notes:"A transfer duty (stamp duty) concession via refund is available when purchasing a home to live in. Additional concessions are available for pensioners downsizing their homes. (Last updated 03 July 2023)"}]},superannuation:{sgcRate:.11,cpiRate:.04,cpiRateAtRetirement:.025,insideSuperTax:.15,minimumDrawdown:[{min:null,max:64,value:.04},{min:65,max:74,value:.05},{min:75,max:79,value:.06},{min:80,max:84,value:.07},{min:85,max:89,value:.09},{min:90,max:94,value:.11},{min:95,max:null,value:.14}],offsetTaxRate:.18,maximumSuperContributionBaseAmount:62270,maximumSuperContributionBaseFreq:4,coContributionPercentage:.5,coContributions:{taxRate:.15,excessTaxRate:.3,caps:[{ageFrom:0,ageTo:48,amount:27500},{ageFrom:49,ageTo:100,amount:27500}]},coContribution:[{from:0,to:43445,govCoCont:function(e,t){var n=t;return t>1e3&&(n=1e3),n}},{from:43445,to:58445,govCoCont:function(e){return 2*(500-.1/3*(e-42017))}},{from:58445,to:Number.POSITIVE_INFINITY,govCoCont:function(){return 0}}],nonCoContributions:{taxRate:0,excessTaxRate:.47,caps:[{ageFrom:0,ageTo:100,amount:11e4}]},partnerMaxCoContribution:{grossIncomeCap:37e3,offset:3e3,ageCap:75,savingsIncomeTaxRate:.18},yourMaxCoContribution:[{from:0,to:41112,govCoCont:function(e,t){var n=t;return t>1e3&&(n=1e3),n}},{from:41113,to:56112,govCoCont:function(e){return 2*(500-.1/3*(e-41113))}},{from:56113,to:Number.POSITIVE_INFINITY,govCoCont:function(){return 0}}],livingExpenses:{caps:[{from:0,to:18200,taxRate:0,amount:0},{from:18201,to:33428,taxRate:.81,amount:0},{from:33429,to:62453,taxRate:.675,amount:3572},{from:62454,to:125453,taxRate:.63,amount:17547},{from:125454,to:Number.POSITIVE_INFINITY,taxRate:.55,amount:54547}]}},LifeExpectancy:{year:"2018-2020",male:{0:81.19191,1:80.48396,2:79.50137,3:78.51255,4:77.52166,5:76.52905,6:75.53517,7:74.54047,8:73.54527,9:72.54972,10:71.55395,11:70.55824,12:69.56316,13:68.56949,14:67.57809,15:66.58992,16:65.60594,17:64.62704,18:63.6536,19:62.68437,20:61.71825,21:60.75393,22:59.79051,23:58.82736,24:57.86427,25:56.90112,26:55.93785,27:54.97463,28:54.01163,29:53.04916,30:52.08725,31:51.12597,32:50.16539,33:49.20581,34:48.24753,35:47.29092,36:46.33628,37:45.38374,38:44.43321,39:43.48469,40:42.5383,41:41.59398,42:40.65164,43:39.71157,44:38.7745,45:37.84116,46:36.91218,47:35.98768,48:35.06769,49:34.15207,50:33.24066,51:32.33344,52:31.43075,53:30.53304,54:29.64088,55:28.75486,56:27.87537,57:27.00291,58:26.13779,59:25.28019,60:24.43027,61:23.58784,62:22.75279,63:21.92525,64:21.10521,65:20.29213,66:19.48587,67:18.6868,68:17.89542,69:17.11302,70:16.34083,71:15.57973,72:14.83018,73:14.0926,74:13.36758,75:12.65586,76:11.95891,77:11.27813,78:10.61496,79:9.97142,80:9.34902,81:8.74859,82:8.17077,83:7.61636,84:7.08644,85:6.58259,86:6.10632,87:5.65816,88:5.23898,89:4.85026,90:4.4941,91:4.17091,92:3.87941,93:3.61653,94:3.37613,95:3.14777,96:2.92934,97:2.7211,98:2.51819,99:2.32555,100:2.17326},female:{0:85.34462,1:84.59847,2:83.6166,3:82.62555,4:81.63315,5:80.63948,6:79.64478,7:78.64933,8:77.65341,9:76.65731,10:75.66129,11:74.66571,12:73.67091,13:72.6772,14:71.68483,15:70.69394,16:69.70465,17:68.71697,18:67.73069,19:66.7453,20:65.7604,21:64.77559,22:63.79059,23:62.80534,24:61.81988,25:60.83431,26:59.84887,27:58.86377,28:57.87958,29:56.89592,30:55.91276,31:54.93016,32:53.94839,33:52.96785,34:51.98865,35:51.01113,36:50.03555,37:49.06162,38:48.08929,39:47.11876,40:46.1499,41:45.18264,42:44.21772,43:43.25564,44:42.2964,45:41.33992,46:40.38595,47:39.43467,48:38.48652,49:37.54135,50:36.59918,51:35.65999,52:34.72447,53:33.79299,54:32.86598,55:31.94328,56:31.02438,57:30.10904,58:29.19761,59:28.29042,60:27.38843,61:26.49261,62:25.60334,63:24.71908,64:23.83862,65:22.96141,66:22.08835,67:21.22079,68:20.36035,69:19.50829,70:18.66575,71:17.83349,72:17.01218,73:16.20257,74:15.4049,75:14.61963,76:13.84738,77:13.08809,78:12.34213,79:11.61203,80:10.90045,81:10.20985,82:9.54238,83:8.89863,84:8.27992,85:7.68844,86:7.12472,87:6.58907,88:6.08285,89:5.60637,90:5.16245,91:4.7533,92:4.37966,93:4.03771,94:3.72567,95:3.44268,96:3.18418,97:2.96092,98:2.78264,99:2.63257,100:2.5063}}}},6130:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r,o=n(31073),a=(r=n(64550))&&r.__esModule?r:{default:r};function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i(e)}function u(e,t){for(var n=0;n=t?"Post Pension":e>=n?"Pension":e>=r?"Invest":"NA"}},{key:"getNonConcessionalCont",value:function(e,t,n,r,o,a){return this.isInvest(n)&&t0;){var s=t[r],l=s.upperBound,c=l-u;o>=c&&c>-1?(i=c,o-=c):(i=o,o=0),a+=i*s.taxRate,u=l,r++}return{totalAnnualTax:a,netAnnualIncome:n-a}}}},{key:"calculateAnnualDependantsExpenses",value:function(e,t,n){return(e?n.jointBaseExpense:n.singleBaseExpense)+t*(e?n.jointDependentAdditionalExpense:n.singleDependentAdditionalExpense)}},{key:"calculateAverageMonthlyExpenses",value:function(e,t){return e.useDefault?this.calculateAnnualDependantsExpenses(e.hasJointIncome,e.dependants,t)/12:e.averageMonthlyExpenses}},{key:"calculateMonthlyExpenses",value:function(e,t){var n=this.calculateAverageMonthlyExpenses(e,t),r=e.carLoanRepayment,o=e.carLoanRepaymentFrequency,a=r*this.periods[o]/this.periods.month,i=0,u=e.creditCardRepayment;if(t.useCreditCardLimitExpense)i=u*t.creditCardLimitExpense;else{var s=e.creditCardRepaymentFrequency;i=u*this.periods[s]/this.periods.month}var l=e.otherPayments,c=e.otherPaymentsFrequency;return n+a+i+l*this.periods[c]/this.periods.month}},{key:"calculateIncomeTax",value:function(e){var t=new this.IncomeTaxManager,n=t.incomeTax;return t.calculateNetIncome(e,n.threshold).netAnnualIncome}},{key:"calculatePartialMonthlyIncome",value:function(e,t,n){var r=e*this.periods[n];return"gross"===t&&(r=this.calculateIncomeTax(r)),r/this.periods.month}},{key:"calculateMonthlyIncome",value:function(e){return this.calculatePartialMonthlyIncome(e.primarySalary,e.primarySalaryTax,e.primarySalaryFrequency)+(e.hasJointIncome?this.calculatePartialMonthlyIncome(e.secondarySalary,e.secondarySalaryTax,e.secondarySalaryFrequency):0)+this.calculatePartialMonthlyIncome(e.otherIncome,e.otherIncomeTax,e.otherIncomeFrequency)}},{key:"calculateMaxMonthlyRepayment",value:function(e,t){var n=this.calculateMonthlyIncome(e),r=this.calculateMonthlyExpenses(e,t),o=n*t.serviceableIncomeFactor-r;return Math.max(0,o)}},{key:"calculateRemainingPrincipal",value:function(e,t,n,r){var o=this.periods.month,a=r/100;return t*((1-Math.pow(1+a/o,-o*(e.term-n+1)))/(a/o))}},{key:"pmt",value:function(e,t,n){var r=t;return r*e/(1-Math.pow(1+r,-n))}},{key:"getInterestRatePerMonth",value:function(e){return e/100/this.periods.month}},{key:"calculateRemainingInterestAndPrincipal",value:function(e,t,n){return n*this.periods.month*(e.term-t+1)}},{key:"getPeriodsInMonths",value:function(e){return e*this.periods.month}},{key:"getGraphData",value:function(e,t){for(var n=[],r=[],o=e.term,a=0,i=1;i<=o;i+=1){var u=this.calculateRemainingPrincipal(e,t,i,e.interestRate),s=this.calculateRemainingInterestAndPrincipal(e,i,t);n.push({age:a,value:s}),r.push({age:a,value:u}),a+=1}return n.push({age:o,value:0}),r.push({age:o,value:0}),{series1:n,series2:r}}},{key:"calculateMaximumBorrowingAmount",value:function(e,t,n){var r=n.useIntRateBufferFlag?t.interestRate+100*n.interestRateBuffer:n.defaultBPIntRate,o=this.calculateRemainingPrincipal(t,e,1,r);return o/=1e3,1e3*(o=Math.floor(o))}},{key:"calculateBorrowingPower",value:function(e,t){var n=this.calculateMaxMonthlyRepayment(e,t),r=this.calculateMaximumBorrowingAmount(n,e,t),o=this.pmt(r,this.getInterestRatePerMonth(e.interestRate),this.getPeriodsInMonths(e.term));return{pmt:o,maximumBorrowingAmount:r,graphData:this.getGraphData(e,o)}}}])&&r(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();t.default=o},83540:function(e,t,n){"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function o(e,t){for(var n=0;n0?t:0}},{key:"getInterestRepayment",value:function(e,t,n,r){return e>0&&e<=t?-r*n:0}},{key:"getPrincipalPayment",value:function(e,t,n,r,o,a){return e>0?"io"===a.toLowerCase()&&e0?s*l%1:1):e>0?"interest only"===t.toLowerCase()&&e<=n?r:"fixed"===t.toLowerCase()&&e<=o?a:u:0}},{key:"getPeriodRepayment",value:function(e,t,n,r,o,a,i,u,s,l,c){return t>0&&t0&&e<=u.roundUp(t,0)&&n>a?e1e-6;i++){n=0,t=0;for(var u=0;u0;){var u=n[a],s=u.upperBound,l=s-o,c=void 0;r>=l&&l>-1?(c=l,r-=l):(c=r,r=0),i+=c*u.taxRate,o=s,a++}return{totalAnnualTax:i,netAnnualIncome:e-i}}},{key:"calculatePAYE",value:function(e){return this.calculateNetIncome(e,"nz").totalAnnualTax}},{key:"calculateACCLevy",value:function(e,t,n,r){return(e>t?Math.min(e,n):0)*(r/100)}},{key:"getTaxCreditThresholds",value:function(e,t,n){return[{lowerBound:0,upperBound:23999,taxCredit:0},{lowerBound:24e3,upperBound:44e3,taxCredit:t},{lowerBound:44001,upperBound:48e3,taxCredit:t-n*(e-44e3)},{lowerBound:48001,upperBound:"+",taxCredit:0}]}},{key:"calculateIETC",value:function(e,t,n){for(var r=this.getTaxCreditThresholds(e,t,n),o=0,a=!0,i=0;o=u.lowerBound&&e<=u.upperBound&&(a=!1,i=u.taxCredit),o++}return i}},{key:"calculateKiwiSaver",value:function(e,t){return e*t}},{key:"calculateStudentLoanRepayment",value:function(e,t,n,r){return r?e<=t?0:n/100*(e-t):0}},{key:"calculateTotalPayable",value:function(e,t,n){return t+e-n}},{key:"calculateNetIncomePerAnnum",value:function(e,t,n,r){return e-t-n-r}},{key:"calculateIncomePerWeek",value:function(e){return e/52}},{key:"getData",value:function(){return o.default}},{key:"calculateNZIncomeTax",value:function(e){var t=e.grossIncome,n=e.kiwiSaverPercentage,r=this.calculatePAYE(t),o=this.calculateACCLevy(t,this.ACCLevyThreshold.accMin,this.ACCLevyThreshold.accMax,this.ACCLevyThreshold.accLevyRate),a=this.calculateIETC(t,this.IETCThreshold.maxIETC,this.IETCThreshold.reductionIETC),i=this.calculateKiwiSaver(t,n),u=this.calculateStudentLoanRepayment(t,this.studentLoansThreshold.minimumEarning,this.studentLoansThreshold.rate,e.studentLoan),s=this.calculateTotalPayable(r,o,a),l=this.calculateNetIncomePerAnnum(t,s,i,u);return{PAYE:r,ACCLevy:o,IECT:a,kiwiSaver:i,studentLoanRepayment:u,totalPayable:s,netIncomePerAnnum:l,netIncomePerWeek:this.calculateIncomePerWeek(l)}}},{key:"calculateAUIncomeTax",value:function(e){var t=this.calculateNetIncome(e.grossIncome,"au").totalAnnualTax,n=e.grossIncome-t;return{yourIncomeTax:t,yourNetIncomePerAnnum:n,yourNetIncomePerWeek:this.calculateIncomePerWeek(n)}}},{key:"calculateIncomeTax",value:function(e,t){return"nz"===e?this.calculateNZIncomeTax(t):this.calculateAUIncomeTax(t)}}])&&i(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();t.default=u},71940:function(e,t){"use strict";function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function r(e,t){for(var r=0;r0?"principal and interest"===t.toLowerCase()?o.default.pmt(i,n/12,r/a*12):i*(n/12):0,10)}},{key:"getBalanceAtEndOfIOFixedIntroMonthly",value:function(e,t,n,r){return e>0?o.default.fv(t/12,e,n,-r):r}},{key:"getOngoingRepaymentMonthly",value:function(e,t,n,r,a){return o.default.round(-o.default.pmt(-a,e/12,t/n*12-r),10)}},{key:"getTermMonthly",value:function(e,t,n){return o.default.round(o.default.nper(e/12,t,-n,0,0),10)}},{key:"getTotalTermMonthly",value:function(e,t){return e+t}},{key:"getMonthlyTermRounded",value:function(e){return o.default.ceiling(e,12)}},{key:"getMonthlyTermYears",value:function(e){return o.default.trunc(e,0)}},{key:"getMonthlyTermMonths",value:function(e){return o.default.roundUp(12*(o.default.trunc(e,4)-o.default.trunc(e,0)),0)}},{key:"getTotalPaidMonthly",value:function(e,t,n,r){return e*t+n*r}},{key:"getInterestPaidMonthly",value:function(e,t){return e-t}},{key:"getTotalPeriodsDifference",value:function(e,t){return o.default.ceiling(e-t,1)}},{key:"getComparisonDiffYears",value:function(e){return o.default.trunc(e,0)}},{key:"getComparisonDiffMonths",value:function(e){return o.default.roundUp(12*(o.default.trunc(e,4)-o.default.trunc(e,0)),0)}},{key:"getRepayment",value:function(e,t,n){return e>0?t:n}},{key:"getOngoingRepaymentResult",value:function(e){return e}},{key:"getTerm",value:function(e,t){return e+" years"+(t>0?" & "+t+" months":"")}},{key:"getTotalInterestPaid",value:function(e){return e}},{key:"getTotalAmountRepaid",value:function(e){return e}},{key:"getInterestSavedVSMonthly",value:function(e,t){return e-t}},{key:"getTimeSavedVSMonthly",value:function(e,t){return e+" years"+(t>0?" & "+t+" months":"")}},{key:"getActualTotalPeriodsIntro",value:function(e,t,n,r,o,a,i){return"fixed"===e.toLowerCase()||"introductory"===e.toLowerCase()||"interest only"===t.toLowerCase()?this.getLambdaTermToPeriods(n,r,o,a,i):0}},{key:"getInitialRepayment",value:function(e,t,n,r,a,i,u,s,l,c){return e>0?"interest only"===t.toLowerCase()?o.default.round(n*r/a,10):"fixed"===i.toLowerCase()||"introductory"===i.toLowerCase()?o.default.round("standard"===s.toLowerCase()?o.default.pmt(n,r/a,l/12*a):o.default.pmt(n,r/12,l/a*12)/c,10):0:0}},{key:"getBalanceAtEndOfIOFixedIntro",value:function(e,t,n,r,a){return o.default.fv(e/t,n,r,-a)}},{key:"getOngoingRepayment",value:function(e,t,n,r,a,i,u,s){return o.default.round(("standard"===e.toLowerCase()?o.default.pmt(i,t/n,r-a):o.default.pmt(i,t/12,(r-a)/n*12)/u)+s,10)}},{key:"getRemainingTerm",value:function(e,t,n,r){return o.default.round(o.default.nper(e/t,n,-r,0,0),10)}},{key:"getTotalTerm",value:function(e,t){return e+t}},{key:"getTotalTermActual",value:function(e,t){return e+t}},{key:"getActualTermRounded",value:function(e,t){return o.default.ceiling(e/t,1/12)}},{key:"getActualTermYears",value:function(e){return o.default.trunc(e,0)}},{key:"getActualTermMonths",value:function(e){return o.default.roundUp(12*(o.default.trunc(e,4)-o.default.trunc(e,0)),0)}},{key:"getTotalPaidActual",value:function(e,t,n,r){return e*t+n*r}},{key:"getInterestPaid",value:function(e,t){return e-t}},{key:"getInitialRepaymentExtra",value:function(e,t,n){return e>0?t+n:0}},{key:"getBalanceExtra",value:function(e,t,n,r,a){return o.default.fv(e/t,n,r,-a)}},{key:"getOngoingRepaymentExtra",value:function(e,t,n,r,a,i,u,s){return("standard"===e.toLowerCase()?-o.default.pmt(-i,t/n,r-a):-o.default.pmt(-i,t/12,(r-a)/n*12)/u)+s}},{key:"getRemainingTermExtra",value:function(e,t,n,r){return o.default.round(o.default.nper(e/t,n,-r,0,0),10)}},{key:"getTotalTermExtra",value:function(e,t){return e+t}},{key:"getExtraTermRounded",value:function(e,t){return o.default.ceiling(e,t)}},{key:"getExtraTermYears",value:function(e){return o.default.trunc(e,0)}},{key:"getExtraTermMonths",value:function(e){return o.default.roundUp(12*(o.default.trunc(e,4)-o.default.trunc(e,0)),0)}},{key:"getTotalPaidExtra",value:function(e,t,n,r){return e*t+n*r}},{key:"getInterestPaidExtra",value:function(e,t){return e-t}},{key:"getInterestDifference",value:function(e,t){return e-t}},{key:"getPeriodMonthly",value:function(e){return e}},{key:"getYearNum",value:function(e){return e/12}},{key:"getYearNumActual",value:function(e,t){return e/t}},{key:"getMonthNum",value:function(e){return e}},{key:"getGraphPeriod",value:function(e,t,n){return"months"===e.toLowerCase()?t:n}},{key:"getGraph",value:function(e,t){return"months"===e.toLowerCase()||t%1==0}},{key:"getStartingPrincipal",value:function(e,t){return 0===e?0:t}},{key:"getClosingPrincipalBalance",value:function(e,t,n,r,o){return 0===e?t:Math.max(n-r-o,0)}},{key:"getStartingInterestBalance",value:function(e,t){return 0===e?0:t}},{key:"getRepaymentAmountMonthly",value:function(e,t,n,r,o,a,i){return 0===e||e>Math.ceil(t)?0:Math.min(e>n?r:o,a+i)}},{key:"getRepaymentAmount",value:function(e,t,n,r,o,a,i){return 0===e||e>Math.ceil(t)?0:Math.min(e<=n?r:o,a+i)}},{key:"getPrincipalPayment",value:function(e,t,n,r,o,a,i){return 0===e||e>t||"interest only"===n.toLowerCase()&&e<=r?0:Math.min(o-a,i)}},{key:"getExtraRepayment",value:function(e,t,n){return 0===e||e>Math.ceil(t)?0:n}},{key:"getInterestPaymentMonthly",value:function(e,t,n,r,o,a,i){return 0===e||e>t?0:Math.min(e>n?r*a/12:r*o/12,i)}},{key:"getInterestPayment",value:function(e,t,n,r,o,a,i,u){return 0===e||e>t?0:e<=n?Math.min(r*o/a,u):Math.min(r*i/a,u)}},{key:"getInterestBalance",value:function(e,t,n,r){return 0===e?t:n-r}},{key:"getTotalRemaining",value:function(e,t){return o.default.trunc(e+t,2)}},{key:"getMonthlyComparisonTable",value:function(e,t,n,r,o,a,i){for(var u=e.loanAmount,s=e.termType,l=0,c=u,p=[],m=t.introInterestRate,h=t.ongoingInterestRate,d=0,f=u;d<=r&&c>0;){var y=this.getPeriodMonthly(d),g=this.getYearNumActual(y,12),v=this.getMonthNum(y),b=this.getGraphPeriod(s,v,g),w=this.getGraph(s,g),P=this.getStartingPrincipal(y,c),x=this.getInterestPaymentMonthly(y,r,n,P,m,h,l),T=this.getRepaymentAmountMonthly(y,r,n,o,a,x,c),M=this.getPrincipalPayment(y,r,e.repaymentType,n,T,x,P);c=f=this.getClosingPrincipalBalance(y,u,P,M,0);var R=this.getStartingInterestBalance(y,l),A=this.getInterestBalance(y,i,R,x);l=A;var k=this.getTotalRemaining(f,A);p.push({period:y,yearNumber:g,monthNum:v,graphPeriod:b,graph:w,startingPrincipal:P,closingPrincipalBalance:f,startingInterestBalance:R,repaymentAmount:T,principalPayment:M,interestPayment:x,interestBalance:A,totalRemaining:k}),d++}return p.length>0&&(p[p.length-1].graph=!0),p}},{key:"getLoanTable",value:function(e,t,n,r,o,a,i){for(var u=e.loanAmount,s=e.termType,l=0,c=u,p=[],m=t.periodsPerYear,h=t.totalPeriods,d=t.introInterestRate,f=t.ongoingInterestRate,y=12===m,g=0,v=u;g<=h&&c>0;){var b=this.getPeriodMonthly(g),w=this.getYearNumActual(b,m),P=this.getMonthNum(b),x=this.getGraphPeriod(s,P,w),T=this.getGraph(s,w),M=this.getStartingPrincipal(b,c),R=this.getInterestPayment(b,h,n,M,d,m,f,l),A=this.getRepaymentAmount(b,r,n,a,o,R,c),k=this.getPrincipalPayment(b,y?r:h,e.repaymentType,n,A,R,M);c=v=this.getClosingPrincipalBalance(b,u,M,k,0);var C=this.getStartingInterestBalance(b,l),B=this.getInterestBalance(b,i,C,R);l=B;var L=this.getTotalRemaining(v,B);p.push({period:b,yearNumber:w,monthNum:P,graphPeriod:x,graph:T,startingPrincipal:M,closingPrincipalBalance:v,startingInterestBalance:C,repaymentAmount:A,principalPayment:k,interestPayment:R,interestBalance:B,totalRemaining:L}),g++}return p.length>0&&(p[p.length-1].graph=!0),p}},{key:"getLoanPlusExtraTable",value:function(e,t,n,r,o,a,i){for(var u=e.loanAmount,s=e.termType,l=0,c=u,p=[],m=t.periodsPerYear,h=t.totalPeriods,d=t.introInterestRate,f=t.ongoingInterestRate,y=12===m,g=0,v=u;g<=h&&c>0;){var b=this.getPeriodMonthly(g),w=this.getYearNumActual(b,m),P=this.getMonthNum(b),x=this.getGraphPeriod(s,P,w),T=this.getGraph(s,w),M=this.getStartingPrincipal(b,c),R=this.getInterestPayment(b,h,n,M,d,m,f,l),A=this.getRepaymentAmount(b,r,n,a,o,R,c),k=this.getPrincipalPayment(b,y?r:h,e.repaymentType,n,A,R,M);c=v=this.getClosingPrincipalBalance(b,u,M,k,0);var C=this.getStartingInterestBalance(b,l),B=this.getInterestBalance(b,i,C,R);l=B;var L=this.getTotalRemaining(v,B);p.push({period:b,yearNumber:w,monthNum:P,graphPeriod:x,graph:T,startingPrincipal:M,closingPrincipalBalance:v,startingInterestBalance:C,repaymentAmount:A,principalPayment:k,interestPayment:R,interestBalance:B,totalRemaining:L}),g++}return p.length>0&&(p[p.length-1].graph=!0),p}},{key:"getResults",value:function(e){var t=e.loanAmount,n=e.loanTerm,r=e.loanTermYears,o=e.loanTermMonths,a=e.rateType,i=e.repaymentType,u=e.termType,s=e.interestRate,l=e.monthlyDivided,c=e.interestOnlyTerm,p=e.interestOnlyTermYears,m=e.interestOnlyTermMonths,h=e.repaymentFrequency,d=e.paymentsPerYear,f=e.interestOnlyRate,y=e.extraRepayment,g=this.getRepaymentOption(h,"calcMethod"),v=this.getPeriodsPerYear(h,d),b=this.getActualTotalPeriodsIntro(a,i,u,c,p,m,v),w=this.getTotalPeriods(u,n,r,o,v),P=this.getDivisor(h,l),x=this.getIntroInterestRate(i,s,f),T=this.getOngoingInterestRate(i,s),M=this.getInitialRepayment(b,i,t,f,v,a,n,g,w,P),R=this.getInitialRepaymentExtra(b,M,y),A=this.getBalanceExtra(f,v,b,R,t),k=this.getOngoingRepaymentExtra(g,s,v,w,b,A,P,y),C=this.getRepayment(b,R,k),B=this.getOngoingRepayment(g,s,v,w,b,A,P,y),L=this.getRemainingTermExtra(s,v,k,A),E=this.getTotalTermExtra(L,b),I=this.getExtraTermRounded(E,v),S=this.getExtraTermYears(I),D=this.getExtraTermMonths(I),O=this.getTerm(S,D),F=this.getTotalPaidExtra(R,b,k,L),N=this.getInterestPaidExtra(F,t),V=this.getTotalAmountRepaid(F),q=this.getTotalPeriodsIOFixedIntro(a,i,u,c,p,m),H=this.getInitialRepaymentMonthly(q,i,f,w,v,t),Y=this.getBalanceAtEndOfIOFixedIntroMonthly(q,f,H,t),j=this.getOngoingRepaymentMonthly(s,w,v,q,Y),G=this.getTermMonthly(s,j,Y),Z=this.getTotalPaidMonthly(H,q,j,G),_=this.getInterestPaidMonthly(Z,t),z=this.getInterestPaidExtra(F,t),U=this.getInterestSavedVSMonthly(_,z),W=this.getTotalTermMonthly(G,q),K=this.getMonthlyTermRounded(W),J=this.getTotalPeriodsDifference(K,I),$=this.getComparisonDiffYears(J),Q=this.getComparisonDiffMonths(J),X=this.getTimeSavedVSMonthly($,Q),ee=this.getOngoingRepayment(g,s,v,w,b,A,P,0),te=this.getBalanceAtEndOfIOFixedIntro(x,v,b,M,t),ne=this.getRemainingTerm(T,v,ee,te),re=this.getTotalTermActual(ne,b),oe=this.getTotalPaidActual(M,b,ee,ne),ae=this.getInterestPaid(oe,t),ie={periodsPerYear:v,totalPeriods:w,introInterestRate:x,ongoingInterestRate:T};return{repayment:C,ongoingRepayment:B,term:O,totalInterestPaid:N,totalAmountRepaid:V,interestSavedVSMonthly:U,timeSavedVSMonthly:X,interestDifference:this.getInterestDifference(_,z),comparisonPeriodsDiff:J,monthlyComparisonTable:this.getMonthlyComparisonTable(e,ie,q,W,j,H,_),loanTable:this.getLoanTable(e,ie,b,re,ee,M,ae),loanExtraTable:this.getLoanPlusExtraTable(e,ie,b,L,k,R,z),totalPaidMonthly:Z,monthlyTotalInterest:_,interestPaidPeriod:0}}}])&&i(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();t.default=u},35550:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r,o=(r=n(44207))&&r.__esModule?r:{default:r};function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}function i(e,t){for(var n=0;ne.rent?"Buy":"Rent"}},{key:"getFinalValue",value:function(e,t){return"Buy"===e?t.buy-t.rent:t.rent-t.buy}},{key:"getResults",value:function(e,t,n,r,o){var a=this.getInitialPlusExitCost(t,e.initialCosts,e.initialCostsRent),i=this.getTotalCostPaid(n,r,o),u=this.getOpportunityCosts(n,r,o),s=this.getEquityBuyRentSelection(n,r,o),l=this.getNetProceeds(a.buy,u.buy,s.buy,u.rent,s.rent),c=this.getBestOption(l);return{initialCostsPlusExitsCosts:a,totalCostPaid:i,opportunityCosts:u,equityBuyRentSelection:s,netProceeds:l,bestOption:c,finalValue:this.getFinalValue(c,l)}}}])&&r(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();t.default=o},89726:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r,o=(r=n(64550))&&r.__esModule?r:{default:r};function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}function i(e,t){for(var n=0;ns)){n=a,r=!0;break}}return r||console.log("No valid threshold found for initialValue='".concat(e,"', thresholdList='").concat(t,"'")),n}},{key:"getPreviousUpperBound",value:function(e,t){var n=0;if(e>0){var r=t[e-1];n=parseFloat(r.upperBound,10)}return n}},{key:"calculateThresholdValue",value:function(e,t,n,r){var o=e,a=0,i=r,u=n.fee,s=u?parseFloat(u,10):0,l=parseFloat(n.extra,10),c=parseFloat(n.per,10),p="false"==n.partThereOf,m=n.subtract,h=m?parseFloat(m,10):0,d=n.min,f=d?parseFloat(d,10):0,y=n.max,g=y?parseFloat(y,10):Number.POSITIVE_INFINITY,v="true"==n.appliedToTotal,b=n.constant,w=Number(n.lowerBound);l>0&&c>0&&(isNaN(i)&&(i=o),v||(i=o-t,p?i-=i%c:b&&(i=(o-t-1)/(Number(n.upperBound)-t-1))),a=b?i*(s+(o-w)/c*l):Math.ceil(i/c)*l);var P=b?0:s;return P+=a,P-=h,Math.max(f,Math.min(g,P))}},{key:"handleVICStampDuty",value:function(e,t){var n,r=e.propertyValue,o=e.propertyType;if("ppr-fh-vl"===o||"ppr-fh"===o||"ppr-fh-nh"===o){var a=this.calculateStampDuty(r,"ppr",t),i=this.getThresholdsByPropertyType(t,o),u=i[this.getRelevantThresholdIndex(r,i)];if(n=u.appliedToTotal?this.calculateStampDuty(r,o,t):this.getThresholdValue(r,i,a),u.constant){var s=Number(u.fee),l=Number(u.upperBound),c=Number(u.lowerBound);n=(r-(c-1))/(l-(c-1))*(s+(r-(c-1))/Number(u.per)*Number(u.extra))}}else n=this.calculateStampDuty(r,o,t);return n}},{key:"handleSAStampDuty",value:function(e,t){var n,r=e.propertyValue,o=e.propertyType;if("ppr-fh-vl"===o||"ppr-fh"===o||"ppr-fh-nh"===o){var a=this.getThresholdsByPropertyType(t,o),i=a[this.getRelevantThresholdIndex(r,a)];if(i.subtract){var u=Number(i.fee),s=Number(i.upperBound),l=Number(i.lowerBound),c=Number(i.per),p=Number(i.extra);n=(u+Math.ceil((r-Math.max(l-1,0))/c)*p+0)*(1-(s-r)/(s-(l-1)))}else n=this.calculateStampDuty(r,o,t)}else n=this.calculateStampDuty(r,o,t);return n}},{key:"handleQLDStampDuty",value:function(e,t){var n,r=e.propertyValue,o=e.propertyType;if("ppr"===o||"ppr"===o){var a=this.calculateStampDuty(r,"ppr",t),i=this.getThresholdsByPropertyType(t,o);n=this.getThresholdValue(r,i,a)}else if("ppr-fh"===o||"ppr-fh-nh"===o||"ppr-fh-vl"===o){var u=this.getThresholdsByPropertyType(t,o),s=u[this.getRelevantThresholdIndex(r,u)],l=Number(s.fee),c=Number(s.lowerBound),p=Number(s.per),m=Number(s.extra),h=Number(s.subtract);n=l+Math.ceil((r-c)/p)*m-h,n=Math.max(n,0),s.partThereOf&&"true"===s.partThereOf&&(n=this.calculateStampDuty(r,o,t))}else n=this.calculateStampDuty(r,o,t);return n}},{key:"handleNSWStampDuty",value:function(e,t){var n,r=e.propertyValue,o=e.propertyType;if("ppr-fh-vl"===o||"ppr-fh"===o||"ppr-fh-nh"===o){var a=this.getThresholdsByPropertyType(t,o),i=a[this.getRelevantThresholdIndex(r,a)];if(i.subtract){var u=Number(i.fee),s=(Number(i.upperBound),Number(i.lowerBound)),l=Number(i.per),c=Number(i.extra),p=parseInt(i.min),m=void 0!==i.additional?parseInt(i.additional):0,h=void 0!==i.additional2?parseInt(i.additional2):0,d=void 0!==i.additional3?parseInt(i.additional3):0;n=(n=u+Math.ceil((r-(s-1))/l)*c-(m-r)/(m-h)*d)-1)return a.threshold}else if(n.type.split(", ").indexOf(t)>-1)return n.threshold;return null}}])&&i(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();t.default=u},69460:function(e,t){"use strict";function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function r(e,t){for(var r=0;r1?r:0):0}},{key:"getClosingBalance",value:function(e,t,n,r,o,a){return(e<=t?n?r:r+o:0)+a}},{key:"getResults",value:function(e,t,n){var r=e.deposit,o=e.ongoingDeposit,a=e.annualRate,i=e.term,u=e.interestPaid,s=e.interestPaymentOption,l=e.depositTiming,c=t.allowRatesInput,p=t.overrideCompoundingPeriods,m=t.compoundingPeriodsPerYear,h=t.allowPaymentOptions,d=0,f=0,y=0,g=[],v=[],b=this.getPaymentFrequency(u,i),w=this.getAnnualRateUsed(c,a,i,u,n),P=this.getAnnualRateEquivalent(p,b,w,m),x="income stream"===(h?s:t.interestPaymentOption).toLowerCase();v.push(x?y:r);for(var T=0;T=t?"Post Pension":e>=n?"Pension":e>=r?"Invest":"NA"}},{key:"getPersonalContributions",value:function(e,t,n,r,o,a){if("invest"===e.toLowerCase()){var i=Math.pow(1+o,a);return 0===t?n+r*i:r*i}return 0}},{key:"getTaxReliefPortion",value:function(e,t,n,r,o,a,i,u,s,l,c,p,m,h){var d=a+i+u+s;if("invest"===e.toLowerCase()&&t>0&&(0===n&&r||n>0&&o)){if(2!==t)return m*(1/(1-h)-1);if(d>0&&l0)return m*(1/(1-h))<=d-p?m*(1/(1-h)-1):(d-p)*h}return 0}},{key:"getEmployerContributions",value:function(e,t){return"invest"===e.toLowerCase()?t:0}},{key:"getTotalContributions",value:function(e,t,n){return e+t+n}},{key:"getOpeningBalance",value:function(e,t,n){return 0===e?t:n}},{key:"getCycle",value:function(e){return e%4}},{key:"getAnnualAllowanceType",value:function(e,t,n,o){var a=(0,r.getMonth)(n);if("invest"===t.toLowerCase()){if(e>=1)switch(a){case o-1:return"End";case o:return"Reset";default:return"Accumulate"}return"Reset"}return 0}},{key:"getYr0",value:function(e,t,n,r,o){return"invest"===e.toLowerCase()?"reset"===t.toLowerCase()&&0===n?r:Math.max(0,o):0}},{key:"getYr1",value:function(e,t,n,r,o){return"invest"===e.toLowerCase()?"reset"===t.toLowerCase()&&1===n?r:Math.max(0,o):0}},{key:"getYr2",value:function(e,t,n,r,o){return"invest"===e.toLowerCase()?"reset"===t.toLowerCase()&&2===n?r:Math.max(0,o):0}},{key:"getYr3",value:function(e,t,n,r,o){return"invest"===e.toLowerCase()?"reset"===t.toLowerCase()&&3===n?r:Math.max(0,o):0}},{key:"getYr0Deduct",value:function(e,t,n,r,o,a,i,u,s){var l=i+u+s,c=u+s;if("invest"===e.toLowerCase()&&(t>0||o>0))switch(n){case 0:return a>0?Math.min(r,a):0;case 1:return a>0&&l0&&c0&&s0||o>0))switch(n){case 0:return i>0&&a0?Math.min(r,i):0;case 2:return i>0&&l0&&c0||o>0))switch(n){case 0:return u>0&&c0&&i0?Math.min(r,u):0;case 3:return u>0&&l0||o>0))switch(n){case 0:return s>0&&c0&&p0&&u0?Math.min(r,s):0;default:return 0}return 0}},{key:"getYr0End",value:function(e,t){return e-t}},{key:"getYr1End",value:function(e,t,n){return"invest"===e.toLowerCase()?t-n:0}},{key:"getYr2End",value:function(e,t,n){return"invest"===e.toLowerCase()?t-n:0}},{key:"getYr3End",value:function(e,t,n){return"invest"===e.toLowerCase()?t-n:0}},{key:"getDrawing",value:function(e,t,n,r,o){return"pension"===e.toLowerCase()?t+("invest"===n.toLowerCase()?r*o:0):0}},{key:"getSubTotal",value:function(e,t,n,r){return"invest"===e.toLowerCase()?t+n:t-r}},{key:"getYield",value:function(e,t){return e*t}},{key:"getFees",value:function(e,t,n,r,o){return"invest"===e.toLowerCase()?(t+n)*r:(t+n)*o}},{key:"getClosingBalance",value:function(e,t,n){return e+t-n}},{key:"getInflationAdjusted",value:function(e,t,n){return e/Math.pow(1+t,n)}},{key:"getEffectiveRateNormal",value:function(e,t){return e[t.toLowerCase()].rateOfReturn/12}},{key:"getContributionsIncrease",value:function(e,t){return e[t.toLowerCase()].contributionsIncrease}},{key:"getTaxReliefType",value:function(e){return this.taxReliefTypes[e.toLowerCase()]}},{key:"getTaxReliefIncome",value:function(e,t){return e=n+1)return null;var o=this.pmt(-r,e,n);return o-this.ipmt(e,t-1,o,r)},pmt:function(e,t,n){return""===t||0===t?e/n:t*e/(1-Math.pow(1+t,-n))},ipmt:function(e,t,n,r){var o=Math.pow(1+e,t);return 0-(r*o*e+n*(o-1))},fv:function(e,t,n,r){var o;if(0===e)o=r+n*t;else{var a=Math.pow(1+e,t);o=r*a+n*(a-1)/e}return-o},round:function(e,t){var n=Math.pow(10,t);return Math.round(e*n)/n},roundDown:function(e,t){var n=Math.pow(10,t);return Math.floor(e*n)/n},roundUp:function(e,t){var n=Math.pow(10,t);return Math.ceil(e*n)/n},ceiling:function(e,t){return Math.ceil(e/t/(1/12))*(1/12)},median:function(){for(var e=arguments.length,t=new Array(e),n=0;n=n+1)return null;var o=this.pmt(-r,e,n);return o-this.ipmt(e,t-1,o,r)},hexEncode:function(e){var t,n="";for(t=0;t