function ClosingCostCredit(n,t){var i=this;i.closingCostCreditName=ko.observable(n);i.closingCostCreditAmount=ko.observable(t)}function LoanPayoff(n,t){var i=this;i.loanPayoffName=ko.observable(n);i.loanPayoffAmount=ko.observable(t)}function TitleServiceFee(n,t,i){var r=this;r.name=ko.observable(n);r.buyerAmount=ko.observable(t);r.sellerAmount=ko.observable(i);r.totalAmount=ko.pureComputed(function(){var n=0;return n+=rateCalc.ConvertStringToNumber(r.buyerAmount()),n+=rateCalc.ConvertStringToNumber(r.sellerAmount()),rateCalc.GetCurrencyValue(n)})}function AdditionalLoan(n,t,i){var r=this;r.amount=ko.observable(n);r.isInsured=ko.observable(t);r.checkedEndorsements=ko.observableArray(i);r.isCollateralMort=ko.observable(!1)}function FillResults(n){if(n!=null&&n.QuoteResponse!=null&&n.QuoteResponse.Provider!=null){let t=n.QuoteResponse.Provider.Name;t!=null&&(n.QuoteResponse.Provider.Name=escapeHTMLEntities(t))}if(rateCalc.numberRequestSentWithoutResponse-=1,rateCalc.numberRequestSentWithoutResponse===0)if(loadingResults.hide(),loadingResultsLoanAmount.hide(),loadingResultsConstructionLoan.hide(),rateCalc.isErrorReceivedForQuoteRequest)rateCalc.isErrorReceivedForQuoteRequest=!1;else{const t=$("#btnDownload");if(n.errorDetail){t.prop("disabled",!0);t.addClass("fa-disabled-no-cursor");let i=n.errorDetail.errorMessage;$("#pMissingInfoText").text(i);$('div[data-name="dialog-missinginfo"]').dialog("open");n.QuoteResponse=[]}else t.prop("disabled",!1),t.removeClass("fa-disabled-no-cursor");rateCalc.quoteResult=n;rateCalc.quoteRequestRoot.QuoteRequest.TransactionInformation.StewartReferenceNumber=n.QuoteResponse.StewartReferenceNumber;HandleCustomMessages(n);rateCalc.IsLoanEstimateQuoteType()?(rateCalc.RenderTEFEResults(n),rateCalc.isQuoteTriggerForTIP=!1,rateCalc.isQuoteTriggerForEndorsement=!1,rateCalc.isQuoteTriggerForTSF=!1,rateCalc.isQuoteTriggerForRecording=!1):rateCalc.IsNetSheetQuoteType()&&(rateCalc.updatedTitleServiceFeesList=[],RenderNetSheetResults(n));$.urlParam=function(n){const t=new RegExp("[?&]"+n+"=([^&#]*)","i").exec(window.location.href);return rateCalc.isLoadingUrl=!1,t==null?null:decodeURI(t[1])||0};const i=$.urlParam("autopdf");i=="true"&&isSaveDocumentPDF?rateCalc.isUrlRequestforAutoPDF&&(rateCalc.HandleCreatEstimateButtonClick(),rateCalc.isValidRequestforAutoPDF&&(rateCalc.GetTEFEDocument(),rateCalc.isUrlRequestforAutoPDF=!1,rateCalc.isValidRequestforAutoPDF=!1)):(rateCalc.isUrlRequestforAutoPDF=!1,rateCalc.isValidRequestforAutoPDF=!1);rateCalc.isQuoteCompleted=!0}}function HandleCustomMessages(n){if(n.QuoteResponse.hasOwnProperty("Messages")){let t;const i=n.QuoteResponse.Messages.Message;i&&(t=Array.isArray(i)?i.find(n=>n.startsWith(RECORDING_ERROR)):i,t!==undefined&&t.startsWith(RECORDING_ERROR)&&($("#pMissingInfoText").html(t.slice(t.indexOf(":")+2)),$('div[data-name="dialog-missinginfo"]').dialog("open"),rateCalc.ToggleSection($('span[data-name="toggle-tefe-'+FEES+'"]'),!1)))}}function RenderNetSheetResults(n){var r=n.QuoteResponse.Pricing,t,i;rateCalc.LoadQuoteResultForTitleEscrow(r);n.QuoteResponse.Provider&&n.QuoteResponse.Provider.Name&&rateCalc.LoadOfficeInfo(n.QuoteResponse.Provider);t=r.ClosingSheetFee;i=$("#hidNetsheetQuoteTrigger");t&&i.val()!==NETSHEET_QUOTE_TRIGGER_OWNER_PCT&&i.val()!==NETSHEET_QUOTE_TRIGGER_LOAN_PCT&&(rateCalc.closingSheetViewModel.buyerClosingCostList.removeAll(),rateCalc.closingSheetViewModel.buyerCreditItemList.removeAll(),rateCalc.closingSheetViewModel.sellerClosingCostList.removeAll(),rateCalc.closingSheetViewModel.sellerCreditItemList.removeAll(),rateCalc.RemoveRecordingFeeFromClosingCostList(t.ClosingCostList),rateCalc.LoadQuoteResultForClosingCostsCredits(t,BUYER),rateCalc.LoadQuoteResultForClosingCostsCredits(t,SELLER));n.QuoteResponse.Recording&&(rateCalc.LoadNetSheetRecordingFeesAndTransferTaxes(n.QuoteResponse.Recordings,BUYER),rateCalc.LoadNetSheetRecordingFeesAndTransferTaxes(n.QuoteResponse.Recordings,SELLER))}function ensureArray(n){Array.isArray(n.StateSettingList.State.Splits.Split)||(n.StateSettingList.State.Splits.Split===undefined?n.StateSettingList.State.Splits={Split:[]}:n.StateSettingList.State.Splits.Split=[n.StateSettingList.State.Splits.Split])}function escapeHTMLEntities(n){return n.replace(/[&<>"']/g,function(n){switch(n){case"&":return"&amp;";case"<":return"&lt;";case">":return"&gt;";case'"':return"&quot;";case"'":return"&apos;";default:return n}})}function FeeItem(n,t){this.Description=n;this.Amount=t}function TefeFeeItem(n,t,i,r,u,f,e){this.Description=n;this.TotalAmount=t;this.BuyerAmount=i;this.SellerAmount=r;this.TaxAmount=u;this.BuyerTaxAmount=f;this.SellerTaxAmount=e;this.DisplaySplits=rateCalc.GetDataForSelectedTransactionType(TRANSACTION_TYPE_KEYS.IS_DISPLAY_SPLITS).toString()}function addBuyerCostsSellerPropTaxesRow(n){$('[data-name="buyerCostsSellerPropTaxesRow"]').css("display")!=="none"&&n.push(new FeeItem(rateCalc.EscapeSpecialCharacters("Seller Owed Prop Tax"),rateCalc.ConvertStringToNumber($("#spanBuyerCostsSellerPropTaxes").text())))}function DeleteObjectNodes(n){if(n){const t=Object.keys(n);for(let i=0;i<t.length;i++)delete n[t[i]]}}rateCalc.closingSheetViewModel={};rateCalc.isUrlRequestforAutoPDF=!0;rateCalc.isValidRequestforAutoPDF=!1;$(document).ready(function(){if(rateCalc.quoteType){$("#buyerSellerLoanEstimateGroup").change(function(){value=$("input[name='pageBuyerSeller']:checked").val();rateCalc.HandleQuoteTypeChange(value)});rateCalc.quoteType===QUOTE_TYPE_BUYER?$("#rbBuyer").prop("checked",!0).change():rateCalc.quoteType===QUOTE_TYPE_SELLER?$("#rbSeller").prop("checked",!0).change():rateCalc.quoteType===QUOTE_TYPE_LOAN_ESTIMATE&&$("#rbLoanEstimate").prop("checked",!0).change();$(function(){$("#buyerProjectedClosingDate").datepicker({})});ko.applyBindings(rateCalc.closingSheetViewModel);closingSheetLookup&&rateCalc.InitializeClosingSheet();rateCalc.InitializeToolTips();rateCalc.InitializeTitleEscrowSection();rateCalc.InitializeRecordingFeeSection();let n=$("#TransactionType");$("#ddlBuyerLoanType").change(function(){switch(this.value){case CASH:rateCalc.closingSheetViewModel.loanType(CASH);n.val(CASH);$("#LoanAmount").val("$0.00");$('div[data-name="buyerLoanTypeWrapper"] .calculator-content').hide();var t=$("#headerBuyerLoanType span.expand-content"),i=t.find("i");t.addClass(SPAN_CLASS_DISABLED);i.attr("class",ICON_CLASS_DOWN_DISABLED);n.trigger("change");rateCalc.ClearLoansAndPrepaidsForBuyerCostSheet();break;default:getQuote()}});$("#btnEstimate").on("click",rateCalc.HandleCreatEstimateButtonClick);$("#btnCancel").on("click",function(){$('div[data-name="createEstimateButton"]').show();$('div[data-name="preparedByForWrapper"]').hide()})}String.prototype.endsWith||(String.prototype.endsWith=function(n,t){return(t===undefined||t>this.length)&&(t=this.length),this.substring(t-n.length,t)===n})});rateCalc.HandleCreatEstimateButtonClick=function(){var n,t,r,u,i;rateCalc.CanInvokeGetQuote()?(n=!0,t=!0,rateCalc.IsLoanEstimateQuoteType()&&(r=rateCalc.IsSectionEnabled(FEES),n=!r||r&&IsFeePageCompleted(),u=rateCalc.IsSectionEnabled(PREMIUM),t=!u||u&&rateCalc.IsTipSectionCompleted()),$(".calculator-content").hide(),$('.calculator-section span.expand-content i:not([class*="'+ICON_CLASS_DOWN_DISABLED+'"])').attr("class","fa fa-angle-double-down fa-2x"),n&&t?(SetSectionFieldsFromCache("CalculatorPreparedBy"),SetSectionFieldsFromCache("CalculatorPreparedFor"),rateCalc.IsLoanEstimateQuoteType()&&SetSectionFieldsFromCache("TefeDocumentType"),$('div[data-name="preparedByForWrapper"]').show(),$('div[data-name="createEstimateButton"]').hide(),rateCalc.isValidRequestforAutoPDF=rateCalc.isUrlRequestforAutoPDF):(rateCalc.isValidRequestforAutoPDF=!1,i="Enter all required information in the following sections:",t||(i+="<br />&nbsp;• Title Insurance Premium"),n||(i+="<br />&nbsp;• Recording Fees and Taxes (Click the Select Fee and Tax Info hyperlink)"),$("#pMissingInfoText").html(i),$('div[data-name="dialog-missinginfo"]').dialog("open"))):(rateCalc.isValidRequestforAutoPDF=!1,$("#txtPropertyLocation").val()?rateCalc.IsTransactionTypeSelected()?rateCalc.ConvertStringToNumber($("#txtPurchasePrice").val())<=0&&rateCalc.HighlightRequiredField($("#txtPurchasePrice")):rateCalc.HighlightRequiredField($("#TransactionType")):rateCalc.HighlightRequiredField($("#txtPropertyLocation")))};rateCalc.IsTipSectionCompleted=function(){var n=$('fieldset[data-name="tbTipPolicy"]'),t=n.find("input").filter("[required]").filter(function(){return $(this).css("display")!=="none"&&this.value===""}),i=n.find('select[required] option[value=""]:selected').filter(function(){return $(this).parent().css("display")!=="none"});return t.length===0&&i.length===0};rateCalc.InitializeToolTips=function(){$('div[data-name="dialog-help"]').dialog({autoOpen:!1,height:"auto",width:530});$("body").bind("click",function(n){!$('div[data-name="dialog-help"]').dialog("isOpen")||$(n.target).is(".ui-dialog")||$(n.target).parent().is(".help-icon")||$(n.target).closest(".ui-dialog").length||$('div[data-name="dialog-help"]').dialog("close")});$(".help-icon").click(function(){rateCalc.ProcessToolTip(this)})};rateCalc.InitializeTitleEscrowSection=function(){$("#titleEscrowBuyerOwnerPolicyGroup").change(function(){value=$("input[name='rbBuyerOwnerPolicy']:checked").val();rateCalc.HandleTitleEscrowOwnerButtonChange(OWNER,value)});$("#titleEscrowSellerOwnerPolicyGroup").change(function(){value=$("input[name='rbSellerOwnerPolicy']:checked").val();rateCalc.HandleTitleEscrowOwnerButtonChange(OWNER,value)});$("#titleEscrowBuyerLenderPolicyGroup").change(function(){value=$("input[name='rbBuyerLenderPolicy']:checked").val();rateCalc.HandleTitleEscrowOwnerButtonChange(LENDER,value)});$("#titleEscrowSellerLenderPolicyGroup").change(function(){value=$("input[name='rbSellerLenderPolicy']:checked").val();rateCalc.HandleTitleEscrowOwnerButtonChange(LENDER,value)});$("#txtBuyerAdditionalFees").change(function(){rateCalc.CalculateTotalTitleEscrow(rateCalc.quoteType)});$("#txtSellerAdditionalFees").change(function(){rateCalc.CalculateTotalTitleEscrow(rateCalc.quoteType)})};rateCalc.InitializeRecordingFeeSection=function(){$("#recordingFeesBuyerDeedFees").change(function(){var n=rateCalc.GetRecordingsByType(rateCalc.quoteResult.QuoteResponse.Recordings,RECORDING_LENDER_OWNER),t=n!==undefined?n.Deed.Fee?Number(n.Deed.Fee):0:0,i=$("input[name='rbBuyerDeedFees']:checked").val();rateCalc.ToggleSellerBuyerSplitButtons(QUOTE_TYPE_BUYER,i,$("#spanBuyerDeedFeesAmount"),t);$("#spanBuyerRecordingFeesTotal").text(rateCalc.GetRecordingTotalAmountString(BUYER));rateCalc.closingSheetViewModel.netsheetTotalDummyObservable.notifySubscribers()});$("#recordingFeesSellerDeedFees").change(function(){var n=rateCalc.GetRecordingsByType(rateCalc.quoteResult.QuoteResponse.Recordings,RECORDING_LENDER_OWNER),t=n!==undefined?n.Deed.Fee?Number(n.Deed.Fee):0:0,i=$("input[name='rbSellerDeedFees']:checked").val();rateCalc.ToggleSellerBuyerSplitButtons(QUOTE_TYPE_SELLER,i,$("#spanSellerDeedFeesAmount"),t);$("#spanSellerRecordingFeesTotal").text(rateCalc.GetRecordingTotalAmountString(SELLER));rateCalc.closingSheetViewModel.netsheetTotalDummyObservable.notifySubscribers()});$("#recordingFeesBuyerMortgageFees").change(function(){var n=rateCalc.GetRecordingsByType(rateCalc.quoteResult.QuoteResponse.Recordings,RECORDING_LENDER_OWNER),t=n!==undefined?n.Mortgage.Fee?Number(n.Mortgage.Fee):0:0,i=$("input[name='rbBuyerMortgageFees']:checked").val();rateCalc.ToggleSellerBuyerSplitButtons(QUOTE_TYPE_BUYER,i,$("#spanBuyerMortgageFeesAmount"),t);$("#spanBuyerRecordingFeesTotal").text(rateCalc.GetRecordingTotalAmountString(BUYER));rateCalc.closingSheetViewModel.netsheetTotalDummyObservable.notifySubscribers()});$("#recordingFeesSellerMortgageFees").change(function(){var n=rateCalc.GetRecordingsByType(rateCalc.quoteResult.QuoteResponse.Recordings,RECORDING_LENDER_OWNER),t=n!==undefined?n.Mortgage.Fee?Number(n.Mortgage.Fee):0:0,i=$("input[name='rbSellerMortgageFees']:checked").val();rateCalc.ToggleSellerBuyerSplitButtons(QUOTE_TYPE_SELLER,i,$("#spanSellerMortgageFeesAmount"),t);$("#spanSellerRecordingFeesTotal").text(rateCalc.GetRecordingTotalAmountString(SELLER));rateCalc.closingSheetViewModel.netsheetTotalDummyObservable.notifySubscribers()});$("#recordingFeesBuyerReleaseFees").change(function(){var n=rateCalc.GetRecordingsByType(rateCalc.quoteResult.QuoteResponse.Recordings,RECORDING_LENDER_OWNER),t=n!==undefined?n.Release.Fee?Number(n.Release.Fee):0:0,i=$("input[name='rbBuyerReleaseFees']:checked").val();rateCalc.ToggleSellerBuyerSplitButtons(QUOTE_TYPE_BUYER,i,$("#spanBuyerReleaseFeesAmount"),t);$("#spanBuyerRecordingFeesTotal").text(rateCalc.GetRecordingTotalAmountString(BUYER));rateCalc.closingSheetViewModel.netsheetTotalDummyObservable.notifySubscribers()});$("#recordingFeesSellerReleaseFees").change(function(){var n=rateCalc.GetRecordingsByType(rateCalc.quoteResult.QuoteResponse.Recordings,RECORDING_LENDER_OWNER),t=n!==undefined?n.Release.Fee?Number(n.Release.Fee):0:0,i=$("input[name='rbSellerReleaseFees']:checked").val();rateCalc.ToggleSellerBuyerSplitButtons(QUOTE_TYPE_SELLER,i,$("#spanSellerReleaseFeesAmount"),t);$("#spanSellerRecordingFeesTotal").text(rateCalc.GetRecordingTotalAmountString(SELLER));rateCalc.closingSheetViewModel.netsheetTotalDummyObservable.notifySubscribers()});$("#recordingFeesBuyerDeedTax").change(function(){var n=rateCalc.GetRecordingsByType(rateCalc.quoteResult.QuoteResponse.Recordings,RECORDING_LENDER_OWNER),t=n!==undefined?n.CFPB2015:"",i=rateCalc.GetAllRecordingTaxes(DEED,t),r=$("input[name='rbBuyerDeedTax']:checked").val();rateCalc.ToggleSellerBuyerSplitButtons(QUOTE_TYPE_BUYER,r,$("#spanBuyerDeedTaxAmount"),i);$("#spanBuyerRecordingFeesTotal").text(rateCalc.GetRecordingTotalAmountString(BUYER));rateCalc.closingSheetViewModel.netsheetTotalDummyObservable.notifySubscribers()});$("#recordingFeesSellerDeedTax").change(function(){var n=rateCalc.GetRecordingsByType(rateCalc.quoteResult.QuoteResponse.Recordings,RECORDING_LENDER_OWNER),t=n!==undefined?n.CFPB2015:"",i=rateCalc.GetAllRecordingTaxes(DEED,t),r=$("input[name='rbSellerDeedTax']:checked").val();rateCalc.ToggleSellerBuyerSplitButtons(QUOTE_TYPE_SELLER,r,$("#spanSellerDeedTaxAmount"),i);$("#spanSellerRecordingFeesTotal").text(rateCalc.GetRecordingTotalAmountString(SELLER));rateCalc.closingSheetViewModel.netsheetTotalDummyObservable.notifySubscribers()});$("#recordingFeesBuyerMortgageTax").change(function(){var n=rateCalc.GetRecordingsByType(rateCalc.quoteResult.QuoteResponse.Recordings,RECORDING_LENDER_OWNER),t=n!==undefined?n.CFPB2015:"",i=rateCalc.GetAllRecordingTaxes(MORTGAGE,t),r=$("input[name='rbBuyerMortgageTax']:checked").val();rateCalc.ToggleSellerBuyerSplitButtons(QUOTE_TYPE_BUYER,r,$("#spanBuyerMortgageTaxAmount"),i);$("#spanBuyerRecordingFeesTotal").text(rateCalc.GetRecordingTotalAmountString(BUYER));rateCalc.closingSheetViewModel.netsheetTotalDummyObservable.notifySubscribers()});$("#recordingFeesSellerMortgageTax").change(function(){var n=rateCalc.GetRecordingsByType(rateCalc.quoteResult.QuoteResponse.Recordings,RECORDING_LENDER_OWNER),t=n!==undefined?n.CFPB2015:"",i=rateCalc.GetAllRecordingTaxes(MORTGAGE,t),r=$("input[name='rbSellerMortgageTax']:checked").val();rateCalc.ToggleSellerBuyerSplitButtons(QUOTE_TYPE_SELLER,r,$("#spanSellerMortgageTaxAmount"),i);$("#spanSellerRecordingFeesTotal").text(rateCalc.GetRecordingTotalAmountString(SELLER));rateCalc.closingSheetViewModel.netsheetTotalDummyObservable.notifySubscribers()})};rateCalc.GetRecordingsByType=function(n,t){let i;if(n&&n.Recording){let r=rateCalc.GetAnArray(n.Recording);for(let n=0;n<r.length;n++)if(r[n].RecordingType===t){i=r[n];break}}return i};rateCalc.HandleDownloadPDFClick=function(){$('div[data-name="loadingPdf"]').show();rateCalc.quoteType===QUOTE_TYPE_LOAN_ESTIMATE?(rateCalc.GetTEFEDocument(),isSaveDocumentPDF&&rateCalc.UpdateQuoteResponse()):rateCalc.GetNetSheetDocument()};rateCalc.HandleQuoteTypeChange=function(n){var i=$("#txtBuyerPrepaidLoanAmount"),t=$("#LoanAmount"),r;rateCalc.propertyState&&rateCalc.propertyCity&&rateCalc.propertyCountyFIPS&&rateCalc.HideRecordingSection();n===BUYER?rateCalc.quoteType===QUOTE_TYPE_LOAN_ESTIMATE?rateCalc.ChangeQuoteType($("#ancNetsheet"),QUOTE_TYPE_BUYER):($("#sellerView").hide(),$("#buyerView").show(),rateCalc.quoteType=QUOTE_TYPE_BUYER,rateCalc.isFirstTimeNonCalculatedLoanAmount||rateCalc.ConvertStringToNumber(i.val())===rateCalc.ConvertStringToNumber(t.val())||rateCalc.closingSheetViewModel.calculatedLoanAmount(t.val())):n===SELLER?rateCalc.quoteType===QUOTE_TYPE_LOAN_ESTIMATE?rateCalc.ChangeQuoteType($("#ancNetsheet"),QUOTE_TYPE_SELLER):($("#buyerView").hide(),$("#sellerView").show(),rateCalc.quoteType=QUOTE_TYPE_SELLER,rateCalc.loanAmount&&rateCalc.isFirstTimeNonCalculatedLoanAmount&&(r=rateCalc.GetCurrencyValue(rateCalc.loanAmount),r!==t.val()&&t.val(r)),rateCalc.isFirstTimeNonCalculatedLoanAmount||rateCalc.ConvertStringToNumber(i.val())===rateCalc.ConvertStringToNumber(t.val())||(t.val(i.val()),rateCalc.CanInvokeGetQuoteForNetSheet()&&getQuote())):n===LOAN_ESTIMATE&&rateCalc.quoteType!==QUOTE_TYPE_LOAN_ESTIMATE&&rateCalc.ChangeQuoteType($("#ancLoanEstimate"),QUOTE_TYPE_LOAN_ESTIMATE)};rateCalc.ChangeQuoteType=function(n,t){var o,s;if(rateCalc.propertyState&&rateCalc.propertyCity&&rateCalc.propertyCountyFIPS){for(var u=!1,f=!1,e=!1,r=rateCalc.urlParams.split("&amp;"),i=0,i=0;i<r.length;i++)r[i]!==""&&(r[i].indexOf("state")===0?(r[i]="state="+rateCalc.propertyState,u=!0):r[i].indexOf("city")===0?(r[i]="city="+rateCalc.propertyCity,f=!0):r[i].indexOf("county")===0&&(r[i]="county="+rateCalc.propertyCountyName,e=!0));for(rateCalc.urlParams="",i=0;i<r.length;i++)r[i]!==""&&(rateCalc.urlParams=rateCalc.urlParams+"&"+r[i]);u||(rateCalc.urlParams=rateCalc.urlParams+"&state="+rateCalc.propertyState);f||(rateCalc.urlParams=rateCalc.urlParams+"&city="+rateCalc.propertyCity);e||(rateCalc.urlParams=rateCalc.urlParams+"&county="+rateCalc.propertyCountyName);rateCalc.HideRecordingSection()}o=n.attr("href");s=o.replace("urlParams=urlparamsplaceholder",rateCalc.urlParams+"&quotetype="+t).replace(/&amp;/g,"&");n.attr("href",s);n.children("span").trigger("click")};rateCalc.InitializeTitleEscrowButtons=function(){stateSettings.StateSettingList.State.OwnerBuyerSplitPercentDefault===""&&stateSettings.StateSettingList.State.OwnerSellerSplitPercentDefault===""||stateSettings.StateSettingList.State.OwnerSellerSplitPercentDefault===ONE_HUNDRED?($("#rbBuyerOwnerPolicySeller").prop("checked",!0),$("#rbSellerOwnerPolicySeller").prop("checked",!0)):stateSettings.StateSettingList.State.OwnerBuyerSplitPercentDefault===ONE_HUNDRED?($("#rbBuyerOwnerPolicyBuyer").prop("checked",!0),$("#rbSellerOwnerPolicyBuyer").prop("checked",!0)):stateSettings.StateSettingList.State.OwnerBuyerSplitPercentDefault!==ONE_HUNDRED&&stateSettings.StateSettingList.State.OwnerBuyerSplitPercentDefault!==ZERO&&($("#rbBuyerOwnerPolicySplit").prop("checked",!0),$("#rbSellerOwnerPolicySplit").prop("checked",!0));stateSettings.StateSettingList.State.LenderBuyerSplitPercentDefault===""&&stateSettings.StateSettingList.State.LenderSellerSplitPercentDefault===""||stateSettings.StateSettingList.State.LenderBuyerSplitPercentDefault===ONE_HUNDRED?($("#rbBuyerLenderPolicyBuyer").prop("checked",!0),$("#rbSellerLenderPolicyBuyer").prop("checked",!0)):stateSettings.StateSettingList.State.LenderSellerSplitPercentDefault===ONE_HUNDRED?($("#rbBuyerLenderPolicySeller").prop("checked",!0),$("#rbSellerLenderPolicySeller").prop("checked",!0)):stateSettings.StateSettingList.State.LenderBuyerSplitPercentDefault!==ONE_HUNDRED&&stateSettings.StateSettingList.State.LenderBuyerSplitPercentDefault!==ZERO&&($("#rbBuyerLenderPolicySplit").prop("checked",!0),$("#rbSellerLenderPolicySplit").prop("checked",!0));$("#rbBuyerTitleServiceFeesBuyer").prop("checked",!0);$("#rbSellerTitleServiceFeesSeller").prop("checked",!0);$("#rbBuyerEscrowServiceFeesBuyer").prop("checked",!0);$("#rbSellerEscrowServiceFeesSeller").prop("checked",!0)};rateCalc.HandleTitleEscrowOwnerButtonChange=function(n,t){var i,r,u,f;if(rateCalc.quoteResult)if(n===OWNER){let n=rateCalc.GetPoliciesByType(rateCalc.quoteResult.QuoteResponse.Pricing.RateManual.Policies,OWNER_PREMIUM);n&&(i=rateCalc.ConvertStringToNumber(n.Premium)+rateCalc.ConvertStringToNumber(n.SalesTax),r=rateCalc.GetTotalEndorsementAmount(n.EndorsementList),rateCalc.quoteType===QUOTE_TYPE_BUYER?(rateCalc.ToggleSellerBuyerSplitButtons(QUOTE_TYPE_BUYER,t,$("#spanBuyerOwnerPolicyPremiumAmount"),i),rateCalc.ToggleSellerBuyerSplitButtons(QUOTE_TYPE_BUYER,t,$("#spanBuyerOwnerPolicyCPLsEndorsements"),r)):rateCalc.quoteType===QUOTE_TYPE_SELLER&&(rateCalc.ToggleSellerBuyerSplitButtons(QUOTE_TYPE_SELLER,t,$("#spanSellerOwnerPolicyPremiumAmount"),i),rateCalc.ToggleSellerBuyerSplitButtons(QUOTE_TYPE_SELLER,t,$("#spanSellerOwnerPolicyCPLsEndorsements"),r)))}else if(n===LENDER){let n=rateCalc.GetPoliciesByType(rateCalc.quoteResult.QuoteResponse.Pricing.RateManual.Policies,LENDER_PREMIUM);n&&(u=rateCalc.ConvertStringToNumber(n.Premium)+ +rateCalc.ConvertStringToNumber(n.SalesTax),f=rateCalc.GetTotalEndorsementAmount(n.EndorsementList),rateCalc.quoteType===QUOTE_TYPE_BUYER?(rateCalc.ToggleSellerBuyerSplitButtons(QUOTE_TYPE_BUYER,t,$("#spanBuyerLenderPolicyPremiumAmount"),u),rateCalc.ToggleSellerBuyerSplitButtons(QUOTE_TYPE_BUYER,t,$("#spanBuyerLenderPolicyCPLsEndorsements"),f)):rateCalc.quoteType===QUOTE_TYPE_SELLER&&(rateCalc.ToggleSellerBuyerSplitButtons(QUOTE_TYPE_SELLER,t,$("#spanSellerLenderPolicyPremiumAmount"),u),rateCalc.ToggleSellerBuyerSplitButtons(QUOTE_TYPE_SELLER,t,$("#spanSellerLenderPolicyCPLsEndorsements"),f)))}rateCalc.CalculateTotalTitleEscrow(rateCalc.quoteType)};rateCalc.GetPoliciesByType=function(n,t){let i;if(n&&n.Policy){let r=rateCalc.GetAnArray(n.Policy);for(let n=0;n<r.length;n++)if(r[n].FeeType===t){i=r[n];break}}return i};rateCalc.ToggleSellerBuyerSplitButtons=function(n,t,i,r){var u=r/2;n===QUOTE_TYPE_BUYER?t===SELLER?(i.text(ZERO_DOLLAR),i.next().val(ZERO)):t===BUYER?(i.text(rateCalc.ConvertNumberToCurrencyString(r)),i.next().val(r.toString())):(i.text(rateCalc.ConvertNumberToCurrencyString(u)),i.next().val(u.toString())):n===QUOTE_TYPE_SELLER&&(t===SELLER?(i.text(rateCalc.ConvertNumberToCurrencyString(r)),i.next().val(r.toString())):t===BUYER?(i.text(ZERO_DOLLAR),i.next().val(ZERO)):(i.text(rateCalc.ConvertNumberToCurrencyString(u)),i.next().val(u.toString())))};rateCalc.CalculateTotalTitleEscrow=function(n){var t=0;n===QUOTE_TYPE_BUYER?(t=rateCalc.ConvertStringToNumber($("#hidBuyerOwnerPolicyPremiumAmount").val())+rateCalc.ConvertStringToNumber($("#hidBuyerOwnerPolicyCPLsEndorsements").val())+rateCalc.ConvertStringToNumber($("#hidBuyerLenderPolicyPremiumAmount").val())+rateCalc.ConvertStringToNumber($("#hidBuyerLenderPolicyCPLsEndorsements").val())+rateCalc.ConvertStringToNumber($("#"+BUYER+"spanBuyerTSFwTax").text())+rateCalc.ConvertStringToNumber($("#txtBuyerAdditionalFees").val()),$("#spanBuyerTitleAndEscrowTotal").text(rateCalc.ConvertNumberToCurrencyString(t))):n===QUOTE_TYPE_SELLER&&(t=rateCalc.ConvertStringToNumber($("#hidSellerOwnerPolicyPremiumAmount").val())+rateCalc.ConvertStringToNumber($("#hidSellerOwnerPolicyCPLsEndorsements").val())+rateCalc.ConvertStringToNumber($("#hidSellerLenderPolicyPremiumAmount").val())+rateCalc.ConvertStringToNumber($("#hidSellerLenderPolicyCPLsEndorsements").val())+rateCalc.ConvertStringToNumber($("#"+SELLER+"spanSellerTSFwTax").text())+rateCalc.ConvertStringToNumber($("#txtSellerAdditionalFees").val()),$("#spanSellerTitleAndEscrowTotal").text(rateCalc.ConvertNumberToCurrencyString(t)));rateCalc.closingSheetViewModel.netsheetTotalDummyObservable.notifySubscribers()};rateCalc.InitializeTransferTaxButtons=function(n,t){var r=[BUYER,SELLER,SPLIT],i;t.TransferTaxPaidBy&&r.indexOf(t.TransferTaxPaidBy)!==-1&&(i=[t.TransferTaxPaidBy],$('[name="rb'+n+'DeedTax"]').val(i))};rateCalc.InitializeClosingSheet=function(){rateCalc.closingSheetViewModel.ResetDirtyValues();rateCalc.closingSheetViewModel.propertyTaxRate(rateCalc.GetPercentageValue(closingSheetLookup.SellerMarketDefault.PropertyTaxRate));rateCalc.closingSheetViewModel.brokerCommissionRate(rateCalc.GetPercentageValue(closingSheetLookup.SellerMarketDefault.BrokerCommissionRate));rateCalc.closingSheetViewModel.buyerBrokerCommissionRate(rateCalc.GetPercentageValue(closingSheetLookup.SellerMarketDefault.BuyerBrokerCommissionRate));rateCalc.closingSheetViewModel.sellerBrokerCommissionRate(rateCalc.GetPercentageValue(closingSheetLookup.SellerMarketDefault.SellerBrokerCommissionRate));rateCalc.closingSheetViewModel.buyerBrokerCommissionRateForBuyer(rateCalc.GetPercentageValue(closingSheetLookup.BuyerMarketDefault.BuyerBrokerCommissionRate));rateCalc.closingSheetViewModel.loanPMI("Monthly");rateCalc.closingSheetViewModel.vaRegularOrReserve("regular");rateCalc.closingSheetViewModel.vaFirstTimeOrSubsequent("first");rateCalc.closingSheetViewModel.prepaidHazardInsuranceRate(rateCalc.GetPercentageValue(closingSheetLookup.BuyerMarketDefault.HazardInsuranceRate));rateCalc.closingSheetViewModel.inclVaFee("InclVaFeeYes");rateCalc.closingSheetViewModel.excemptVaFee("ExcemptVaFeeNo");rateCalc.closingSheetViewModel.buyerSellerTaxesCredit2Buyer("CreditToBuyerNo");rateCalc.closingSheetViewModel.inclConvSinglePmiPremium("PmiPremiumYes");rateCalc.closingSheetViewModel.inclFhaUpfrontMIP("InclFhaMipYes");rateCalc.closingSheetViewModel.inclFha6PercSellerContrib("Incl6PercNo");rateCalc.closingSheetViewModel.closingDate(moment().add(30,"days").format("MM/DD/YYYY"));rateCalc.closingSheetViewModel.showSimplifiedPropertyTaxBuyer(closingSheetLookup.BuyerMarketDefault.ShowSimplifiedPropertyTaxBuyer);rateCalc.closingSheetViewModel.showSimplifiedPropertyTaxSeller(closingSheetLookup.SellerMarketDefault.ShowSimplifiedPropertyTaxSeller);rateCalc.closingSheetViewModel.isClosingSheetLookupLoaded(!0);rateCalc.closingSheetViewModel.actualPropertyValue.notifySubscribers()};rateCalc.ProcessToolTip=function(n){switch($(n).attr("data-name")){case"buyerDownPaymentHelp":$("#pHelpText").html("The net sheet automatically calculates the <strong>Down Payment<\/strong> amount based on <strong>Purchase Price<\/strong> and <strong>Loan Type<\/strong>. You can manually change the amount if needed.");break;case"buyerCostsAndCreditsHelp":$("#pHelpText").html("Costs and credits not included in other sections of the net sheet. These include costs for appraisals, attorney fees, inspections, home warranties, surveys, etc. and credits for seller closing cost contributions, repairs and property taxes owed.");break;case"buyerPrepaidLoanIntRateHelp":$("#pHelpText").html("The amount of interest charged on the <strong>Loan Amount<\/strong> expressed as a percentage.");break;case"buyerPrepaidLoanTermHelp":$("#pHelpText").html("The length of the loan measured in years. The most common mortgage loans are 15 or 30 years.");break;case"buyerPrepaidLoanLenderPointsHelp":$("#pHelpText").html('Also known as "Discount Points". A one-time fee paid to the lender to reduce the <strong>Interest Rate<\/strong> on the loan. One point equals one percent of the loan amount.');break;case"buyerPrepaidLoanLenderOrigFeeHelp":$("#pHelpText").html("A charge by the lender to cover the administrative costs of making the loan.");break;case"buyerPrepaidPropTaxMosHelp":$("#pHelpText").html("Enter the number of months required to be paid in advance.");break;case"buyerPrepaidHazardInsMosHelp":$("#pHelpText").html('Also known as "Homeowners Insurance". Enter the number of months required to be paid in advance.');break;case"buyerTaxesPropTaxesHelp":$("#pHelpText").html("The yearly amount of property taxes. The net sheet automatically calculates this amount by multiplying the <strong>Property Value for Taxes<\/strong> by the <strong>Property Tax Rate<\/strong>. If needed, you can manually change this amount based on the property tax bill.");break;case"sellerCostsAndCreditsHelp":$("#pHelpText").html("Costs and credits not included in other sections of the net sheet. These include costs for real estate commissions, attorney fees, home warranties, recording fees, etc. and any miscellaneous credits.");break;case"sellerTaxesPropTaxesHelp":$("#pHelpText").html("The yearly amount of property taxes. The net sheet automatically calculates this amount by multiplying the <strong>Property Value for Taxes<\/strong> by the <strong>Property Tax Rate<\/strong>. If needed, you can manually change this amount based on the property tax bill.");break;case"OwnerPolicyCoverageTypeHelp":$("#pHelpText").html(rateCalc.GetToolTipForPolicyCoverageType("OwnerPolicyCoverageType").replace(/\n/g,"<br>"));break;case"LenderPolicyCoverageTypeHelp":$("#pHelpText").html(rateCalc.GetToolTipForPolicyCoverageType("LenderPolicyCoverageType").replace(/\n/g,"<br>"));break;case"RefiLenderPolicyCoverageTypeHelp":$("#pHelpText").html(rateCalc.GetToolTipForPolicyCoverageType("RefiLenderPolicyCoverageType").replace(/\n/g,"<br>"));break;case"LeaseholdOwnerPolicyCoverageTypeHelp":$("#pHelpText").html(rateCalc.GetToolTipForPolicyCoverageType("LeaseholdOwnerPolicyCoverageType").replace(/\n/g,"<br>"));break;case"LeaseholdLenderPolicyCoverageTypeHelp":$("#pHelpText").html(rateCalc.GetToolTipForPolicyCoverageType("LeaseholdLenderPolicyCoverageType").replace(/\n/g,"<br>"));break;case"ConstructionLenderPolicyCoverageTypeHelp":$("#pHelpText").html(rateCalc.GetToolTipForPolicyCoverageType("ConstructionLenderPolicyCoverageType").replace(/\n/g,"<br>"));break;case"ProjectLenderPolicyCoverageTypeHelp":$("#pHelpText").html(rateCalc.GetToolTipForPolicyCoverageType("ProjectLenderPolicyCoverageType").replace(/\n/g,"<br>"));break;case"PropertyTypeHelp":$("#pHelpText").html("For title premium purposes the TIRSA Rate Manual classifies property types as follows: <br>Residential Real Property is defined as a 1-4 family dwelling, and does not include vacant land; Commercial Real Property is any property not Residential Real Property, including vacant land. Please be aware that the applicable tax law may classify the property differently, especially with respect to mixed-use properties and vacant land.")}$('div[data-name="dialog-help"]').dialog("option","position",{at:"left top",of:n}).dialog("open")};rateCalc.InitializeClosingSheetViewModelDataBind=function(){function n(){var n=this,r=!1,t=!1,u=!1,o=!1,s=!1,h=!1,c=!1,f=!1,e=!1,i="MM/DD/YYYY";n.saleAmount=ko.observable(ZERO_DOLLAR);n.closingDate=ko.observable();n.loanPayoff1=ko.observable();n.loanPayoff2=ko.observable();n.actualLoanPayoffSubTotal=ko.observable();n.actualPropertyValue=ko.observable();n.actualPropertyTax=ko.observable();n.propertyTaxRate=ko.observable();n.actualDownPaymentAmount=ko.observable();n.actualLoanAmount=ko.observable();n.actualPriorYearTaxTotalAmount=ko.observable();n.actualPriorYearEstSellerPaidAmount=ko.observable();n.actualCurrentYearTaxProrationAmount=ko.observable();n.actualCurrentYearEstSellerPaidAmount=ko.observable();n.transferTaxBuyerRate=ko.observable();n.transferTaxSellerRate=ko.observable();n.brokerCommissionRate=ko.observable();n.buyerBrokerCommissionRate=ko.observable();n.buyerBrokerCommissionRateForBuyer=ko.observable();n.sellerBrokerCommissionRate=ko.observable();n.brokerCommissionAmount=ko.observable();n.buyerBrokerCommissionAmount=ko.observable();n.buyerBrokerCommissionAmountForBuyer=ko.observable();n.sellerBrokerCommissionAmount=ko.observable();n.loanType=ko.observable();n.vaRegularOrReserve=ko.observable();n.vaFirstTimeOrSubsequent=ko.observable();n.loanPMI=ko.observable();n.downPaymentRate=ko.observable();n.loanInterestRate=ko.observable();n.loanTermYears=ko.observable();n.loanLenderPointRate=ko.observable();n.loanLenderOriginationFee=ko.observable();n.loanLenderFee=ko.observable();n.prepaidPropertyTaxMonths=ko.observable();n.prepaidHazardInsuranceMonths=ko.observable();n.prepaidHazardInsuranceRate=ko.observable();n.selectedFhaPropType=ko.observable();n.inclVaFee=ko.observable();n.excemptVaFee=ko.observable();n.buyerSellerTaxesCredit2Buyer=ko.observable();n.inclConvSinglePmiPremium=ko.observable();n.inclFhaUpfrontMIP=ko.observable();n.inclFha6PercSellerContrib=ko.observable();n.isClosingSheetLookupLoaded=ko.observable();n.showSimplifiedPropertyTaxBuyer=ko.observable();n.showSimplifiedPropertyTaxSeller=ko.observable();n.additionalSellerClosingCostList=ko.observableArray([new ClosingCostCredit]);n.additionalSellerCreditItemList=ko.observableArray([new ClosingCostCredit]);n.additionalBuyerClosingCostList=ko.observableArray([new ClosingCostCredit]);n.additionalBuyerCreditItemList=ko.observableArray([new ClosingCostCredit]);n.buyerClosingCostList=ko.observableArray();n.buyerCreditItemList=ko.observableArray();n.sellerClosingCostList=ko.observableArray();n.sellerCreditItemList=ko.observableArray();n.additionalSellerLoanPayoffList=ko.observableArray([new LoanPayoff]);n.additionalTSFList=ko.observableArray([new TitleServiceFee("",ZERO_DOLLAR,ZERO_DOLLAR)]);n.isAdditionalTSFHeaderVisible=ko.observable(!1);n.transactionType=ko.observable();n.additionalLoanList=ko.observableArray();n.additionalLeaseholdLoanList=ko.observableArray();n.isDisplaySplits=ko.observable();$("#TransactionType").change(function(){var t=rateCalc.GetDataForSelectedTransactionType(TRANSACTION_TYPE_KEYS.IS_DISPLAY_SPLITS);n.isDisplaySplits(t)});n.earnestMoney=ko.observable(ZERO_DOLLAR);n.netsheetTotalDummyObservable=ko.observable();n.GetNumeralPrefix=function(n){return rateCalc.GetNumeralPrefix(n)};n.ResetDirtyValues=function(){f=!1};n.calculatedTotalBuyerNetSheetAmount=ko.pureComputed(function(){var t=0;return n.netsheetTotalDummyObservable(),t+=rateCalc.ConvertStringToNumber(n.calculatedDownPaymentAmount()),t+=rateCalc.ConvertStringToNumber(n.calculatedSubTotalLoanAndPrepaid()),t+=rateCalc.ConvertStringToNumber($("#spanBuyerTitleAndEscrowTotal").text()),t+=rateCalc.ConvertStringToNumber(n.calculatedBuyerSubTotalClosingCostCredit()),t+=rateCalc.ConvertStringToNumber($("#spanBuyerRecordingFeesTotal").text()),t-=rateCalc.ConvertStringToNumber(n.earnestMoney()),rateCalc.GetCurrencyValue(t)});n.calculatedTotalSellerNetSheetAmount=ko.pureComputed(function(){var t=0;return n.netsheetTotalDummyObservable(),t+=rateCalc.ConvertStringToNumber(n.saleAmount()),t-=rateCalc.ConvertStringToNumber(n.calculatedSubTotalPayoff()),t-=rateCalc.ConvertStringToNumber(n.calculatedSubTotalPropertyTaxes()),t-=rateCalc.ConvertStringToNumber($("#spanSellerTitleAndEscrowTotal").text()),t-=rateCalc.ConvertStringToNumber(n.calculatedSellerSubTotalClosingCostCredit()),t-=rateCalc.ConvertStringToNumber($("#spanSellerRecordingFeesTotal").text()),rateCalc.GetCurrencyValue(t)});n.calculatedDownPaymentRate=ko.pureComputed({read:function(){var r=0,i;if(n.downPaymentRate(),n.actualLoanAmount(),n.loanType()&&n.saleAmount()&&!t&&n.isClosingSheetLookupLoaded()){i="0";switch(n.loanType()){case"FHA":i="1";break;case"VA":i="2";break;case CASH:i="3"}closingSheetLookup&&$.each(closingSheetLookup.DownPaymentRateList.DownPaymentRate,function(t,u){var f,e,o,s;if(u.LoanType===i)return f=rateCalc.ConvertStringToNumber(u.Rate)*100,e=rateCalc.ConvertStringToNumber(n.saleAmount()),n.calculatedMinDownPaymentRate()>f&&(f=n.calculatedMinDownPaymentRate()),rateCalc.isFirstTimeNonCalculatedLoanAmount&&e>0&&(o=e>n.actualLoanAmount()?(e-n.actualLoanAmount())*100/e:0,o!==n.downPaymentRate()?f=o:rateCalc.isFirstTimeNonCalculatedLoanAmount=!1),s=e*f/100,n.actualDownPaymentAmount(rateCalc.GetCurrencyValue(s)),r=f,n.downPaymentRate(r),!1})}else n.downPaymentRate()&&(r=n.downPaymentRate());return rateCalc.GetPercentageValue(r)},write:function(i){t=!0;rateCalc.isFirstTimeNonCalculatedLoanAmount=!1;var r=rateCalc.ConvertStringToNumber(i),u=rateCalc.ConvertStringToNumber(n.saleAmount()),f=rateCalc.ConvertStringToNumber(n.calculatedFhaMaxAmount()),e=u-u*r/100;n.loanType()==="FHA"&&e>f&&(r=(u-f)*100/u,$("#txtBuyerPrepaidDownPayPercent").val(rateCalc.GetPercentageValue(r)));n.downPaymentRate(rateCalc.GetPercentageValue(r));n.actualDownPaymentAmount(rateCalc.GetCurrencyValue(u*r/100));t=!1;rateCalc.CanInvokeGetQuoteForNetSheet()&&getQuote()},owner:n});n.calculatedDownPaymentAmount=ko.pureComputed({read:function(){var i=0,r;return!t&&n.saleAmount()?(r=rateCalc.ConvertStringToNumber(n.saleAmount()),n.downPaymentRate()&&(i=r*n.downPaymentRate()/100),n.actualDownPaymentAmount(i)):n.actualDownPaymentAmount()&&(i=rateCalc.ConvertStringToNumber(n.actualDownPaymentAmount())),rateCalc.GetCurrencyValue(i)},write:function(i){t=!0;rateCalc.isFirstTimeNonCalculatedLoanAmount=!1;var r=rateCalc.ConvertStringToNumber(i),u=rateCalc.ConvertStringToNumber(n.saleAmount()),f=rateCalc.ConvertStringToNumber(n.calculatedFhaMaxAmount());n.loanType()==="FHA"&&u-r>f&&(r=u>n.actualLoanAmount()?u-f:0,$("#txtBuyerPrepaidDownPayment").val(rateCalc.GetCurrencyValue(r)));n.actualDownPaymentAmount(rateCalc.GetCurrencyValue(r));n.downPaymentRate(r*100/u);t=!1;rateCalc.CanInvokeGetQuoteForNetSheet()&&getQuote()},owner:n});n.calculatedFhaMaxAmount=ko.pureComputed(function(){var t=0;if(n.loanType()==="FHA"&&closingSheetLookup)switch(n.selectedFhaPropType()){case"Single":t=closingSheetLookup.LoanLimit.Single;break;case"Duplex":t=closingSheetLookup.LoanLimit.Duplex;break;case"Triplex":t=closingSheetLookup.LoanLimit.Triplex;break;case"Fourplex":t=closingSheetLookup.LoanLimit.Fourplex}return rateCalc.GetCurrencyValue(t)});n.calculatedMinDownPaymentRate=ko.pureComputed(function(){var i=0,t,r;return n.loanType()==="FHA"&&n.saleAmount()&&n.calculatedFhaMaxAmount()&&(t=rateCalc.ConvertStringToNumber(n.saleAmount()),r=rateCalc.ConvertStringToNumber(n.calculatedFhaMaxAmount()),i=(t-r)*100/t),i});n.calculatedLoanAmount=ko.pureComputed({read:function(){var t,i;return result=0,n.actualLoanAmount(),n.isClosingSheetLookupLoaded(),n.saleAmount()&&n.calculatedDownPaymentAmount()&&n.loanType()&&n.loanType()!==CASH&&(t=rateCalc.ConvertStringToNumber(n.saleAmount()),t>0&&(u||rateCalc.isFirstTimeNonCalculatedLoanAmount?n.actualLoanAmount()&&(result=n.actualLoanAmount()):(result=t-rateCalc.ConvertStringToNumber(n.calculatedDownPaymentAmount()),n.loanType()==="FHA"&&(i=rateCalc.ConvertStringToNumber(n.calculatedFhaMaxAmount()),i<result&&(result=i)),n.actualLoanAmount(result),rateCalc.isBuyerSalesPriceChanged&&(r?(getQuote(),rateCalc.isBuyerSalesPriceChanged=!1,r=!1):r=!0)))),rateCalc.GetCurrencyValue(result)},write:function(t){var i,r,f;u=!0;i=rateCalc.ConvertStringToNumber(n.saleAmount());r=rateCalc.ConvertStringToNumber(t);n.actualLoanAmount(rateCalc.ConvertStringToNumber(t));i>0&&(f=i>r?i-r:0,n.calculatedDownPaymentAmount(f));u=!1;rateCalc.isFirstTimeNonCalculatedLoanAmount=!1},owner:n});n.calculatedSinglePMIPremium=ko.pureComputed(function(){var i=0,r,t;return n.loanType()&&n.loanPMI()&&n.downPaymentRate()&&closingSheetLookup&&(r=1,t=rateCalc.GetValueFactor(r),n.loanType()==="Conventional"&&n.loanPMI()==="Single"&&(i=t===0&&n.downPaymentRate()<3?-99:Math.round(rateCalc.ConvertStringToNumber(n.calculatedLoanAmount())*t/100))),rateCalc.GetCurrencyValue(i)});n.calculatedFHAUpfrontMIP=ko.pureComputed(function(){var t=0;if(n.loanType()==="FHA"){var i=0,r=0;n.saleAmount()&&(r=rateCalc.ConvertStringToNumber(n.saleAmount())-rateCalc.ConvertStringToNumber(n.calculatedDownPaymentAmount())-rateCalc.ConvertStringToNumber(n.calculatedFhaMaxAmount()));i=r>0?2:3;t=rateCalc.ConvertStringToNumber(n.calculatedLoanAmount())*(rateCalc.ConvertStringToNumber(rateCalc.GetValueFactor(i))/100)}return rateCalc.GetCurrencyValue(t)});n.calculatedVAFundingFee=ko.pureComputed(function(){var i=0;if(n.loanType()==="VA"){var t=0;n.vaRegularOrReserve()==="regular"?n.vaFirstTimeOrSubsequent()==="first"?t=4:n.vaFirstTimeOrSubsequent()==="subseq"&&(t=5):n.vaRegularOrReserve()==="reserve"&&(n.vaFirstTimeOrSubsequent()==="first"?t=6:n.vaFirstTimeOrSubsequent()==="subseq"&&(t=7));i=rateCalc.ConvertStringToNumber(n.calculatedLoanAmount())*(rateCalc.ConvertStringToNumber(rateCalc.GetValueFactor(t))/100)}return n.excemptVaFee()&&n.excemptVaFee()==="ExcemptVaFeeYes"?"Exempt":rateCalc.GetCurrencyValue(i)});n.calculatedTotalLoanAmount=ko.pureComputed(function(){var t=0;return n.loanType()==="Conventional"?t=rateCalc.ConvertStringToNumber(n.calculatedLoanAmount())+rateCalc.ConvertStringToNumber(n.calculatedSinglePMIPremium()):n.loanType()==="FHA"?t=rateCalc.ConvertStringToNumber(n.calculatedLoanAmount())+rateCalc.ConvertStringToNumber(n.calculatedFHAUpfrontMIP()):n.loanType()==="VA"&&(t=rateCalc.ConvertStringToNumber(n.calculatedLoanAmount()),n.excemptVaFee()&&n.excemptVaFee()==="ExcemptVaFeeNo"&&(t+=rateCalc.ConvertStringToNumber(n.calculatedVAFundingFee()))),rateCalc.GetCurrencyValue(t)});n.calculatedPrepaidInterestDays=ko.pureComputed(function(){var r=0;if(n.closingDate()){var t=new Date(n.closingDate()),u=new Date(t.getFullYear(),t.getMonth()+1,0),f=moment(t,[i]),e=moment(u,[i]);r=e.diff(f,"days")+1}return r});n.calculatedPrepaidInterestAmount=ko.pureComputed(function(){if(n.loanInterestRate()){var t=rateCalc.ConvertStringToNumber(n.calculatedLoanAmount())*(rateCalc.ConvertStringToNumber(n.loanInterestRate())/100),i=t/365;return rateCalc.GetCurrencyValue(Math.round(i*n.calculatedPrepaidInterestDays(),0))}});n.calculatedPropertyTaxCollectedAmount=ko.pureComputed(function(){if(n.calculatedPropertyTax()&&n.prepaidPropertyTaxMonths()){var t=rateCalc.ConvertStringToNumber(n.calculatedPropertyTax())/12;return rateCalc.GetCurrencyValue(Math.round(n.prepaidPropertyTaxMonths()*t,0))}});n.calculatedHazardInsuranceCollectedAmount=ko.pureComputed(function(){if(n.prepaidHazardInsuranceMonths()){var t=rateCalc.ConvertStringToNumber(n.saleAmount())*(rateCalc.ConvertStringToNumber(n.prepaidHazardInsuranceRate())/100),i=t/12;return rateCalc.GetCurrencyValue(Math.round(n.prepaidHazardInsuranceMonths()*i,0))}});n.calculatedSubTotalLoanAndPrepaid=ko.pureComputed(function(){var t=0;return n.loanLenderPointRate()&&(t+=Math.round(rateCalc.ConvertStringToNumber(n.loanLenderPointRate())/100*rateCalc.ConvertStringToNumber(n.calculatedLoanAmount()))),n.loanLenderOriginationFee()&&(t+=rateCalc.ConvertStringToNumber(n.loanLenderOriginationFee())),n.loanLenderFee()&&(t+=rateCalc.ConvertStringToNumber(n.loanLenderFee())),n.calculatedPrepaidInterestAmount()&&(t+=rateCalc.ConvertStringToNumber(n.calculatedPrepaidInterestAmount())),n.calculatedPropertyTaxCollectedAmount()&&(t+=rateCalc.ConvertStringToNumber(n.calculatedPropertyTaxCollectedAmount())),n.calculatedHazardInsuranceCollectedAmount()&&(t+=rateCalc.ConvertStringToNumber(n.calculatedHazardInsuranceCollectedAmount())),n.calculatedSinglePMIPremium()&&n.inclConvSinglePmiPremium()&&n.inclConvSinglePmiPremium()==="PmiPremiumNo"&&(t+=rateCalc.ConvertStringToNumber(n.calculatedSinglePMIPremium())),n.calculatedFHAUpfrontMIP()&&n.inclFhaUpfrontMIP()&&n.inclFhaUpfrontMIP()==="InclFhaMipNo"&&(t+=rateCalc.ConvertStringToNumber(n.calculatedFHAUpfrontMIP())),n.calculatedVAFundingFee()&&n.inclVaFee()&&n.inclVaFee()==="InclVaFeeNo"&&n.excemptVaFee()&&n.excemptVaFee()==="ExcemptVaFeeNo"&&(t+=rateCalc.ConvertStringToNumber(n.calculatedVAFundingFee())),rateCalc.GetCurrencyValue(t)});n.calculateBuyerBrokerPercentageForBuyer=ko.pureComputed({read:function(){var t="0.00 %";return n.buyerBrokerCommissionRateForBuyer()&&(t=n.buyerBrokerCommissionRateForBuyer()),t},write:function(t){n.buyerBrokerCommissionRateForBuyer(t);var i=rateCalc.ConvertStringToNumber(n.buyerBrokerCommissionRateForBuyer())/100;n.buyerBrokerCommissionAmountForBuyer(rateCalc.GetCurrencyValue(i*rateCalc.ConvertStringToNumber(n.saleAmount())))},owner:n});n.calculatedBuyerBrokerCommissionForBuyer=ko.pureComputed({read:function(){var t=0,i;return n.buyerBrokerCommissionRateForBuyer()&&n.saleAmount()&&(i=rateCalc.ConvertStringToNumber(n.buyerBrokerCommissionRateForBuyer())/100,t=rateCalc.GetCurrencyValue(i*rateCalc.ConvertStringToNumber(n.saleAmount()))),t},write:function(t){n.buyerBrokerCommissionAmountForBuyer(t);n.buyerBrokerCommissionRateForBuyer(rateCalc.GetPercentageValue(rateCalc.ConvertStringToNumber(t)*100/rateCalc.ConvertStringToNumber(n.saleAmount())))},owner:n});n.addTitleServiceFee=function(){n.additionalTSFList.push(new TitleServiceFee("",ZERO_DOLLAR,ZERO_DOLLAR))};n.removeTitleServiceFee=function(){n.additionalTSFList().length>1&&n.additionalTSFList.remove(this)};n.removeTitleServiceFeeMobile=function(){n.additionalTSFList().length>1&&n.additionalTSFList.pop()};n.addBuyerClosingCost=function(){n.additionalBuyerClosingCostList.push(new ClosingCostCredit)};n.removeBuyerClosingCost=function(){n.additionalBuyerClosingCostList().length>1&&n.additionalBuyerClosingCostList.pop()};n.removeBuyerClosingCostAndCredit=function(){n.additionalBuyerClosingCostList().length>1&&n.additionalBuyerClosingCostList.remove(this)};n.addBuyerCreditItem=function(){n.additionalBuyerCreditItemList.push(new ClosingCostCredit)};n.removeBuyerCreditItem=function(){n.additionalBuyerCreditItemList().length>1&&n.additionalBuyerCreditItemList.pop()};n.calculatedSellerOwedPropTax=ko.pureComputed(function(){var t=ZERO_DOLLAR;return n.buyerSellerTaxesCredit2Buyer()&&n.calculatedPriorYearDiff()&&n.calculatedCurrentYearDiff()&&n.buyerSellerTaxesCredit2Buyer()==="CreditToBuyerYes"&&(t=rateCalc.GetCurrencyValue(rateCalc.ConvertStringToNumber(n.calculatedPriorYearDiff())+rateCalc.ConvertStringToNumber(n.calculatedCurrentYearDiff()))),t});n.calculatedSellerClosingContribution=ko.pureComputed(function(){var t=ZERO_DOLLAR;return n.loanType()==="FHA"&&n.inclFha6PercSellerContrib()&&n.inclFha6PercSellerContrib()==="Incl6PercYes"&&n.saleAmount()&&(t=rateCalc.GetCurrencyValue(rateCalc.ConvertStringToNumber(n.saleAmount())*6/100)),t});n.calculatedBuyerSubTotalClosingCostCredit=ko.computed(function(){var u=0,i=0,r,t;for(u+=rateCalc.ConvertStringToNumber(n.calculatedBuyerBrokerCommissionForBuyer()),i=0;i<n.buyerClosingCostList().length;i++)u+=rateCalc.ConvertStringToNumber(n.buyerClosingCostList()[i].closingCostCreditAmount());for(i=0;i<n.additionalBuyerClosingCostList().length;i++)u+=rateCalc.ConvertStringToNumber(n.additionalBuyerClosingCostList()[i].closingCostCreditAmount());for(r=0,t=0,t=0;t<n.buyerCreditItemList().length;t++)r+=rateCalc.ConvertStringToNumber(n.buyerCreditItemList()[t].closingCostCreditAmount());for(t=0;t<n.additionalBuyerCreditItemList().length;t++)r+=rateCalc.ConvertStringToNumber(n.additionalBuyerCreditItemList()[t].closingCostCreditAmount());return n.calculatedSellerOwedPropTax()&&(r+=rateCalc.ConvertStringToNumber(n.calculatedSellerOwedPropTax())),n.calculatedSellerClosingContribution()&&(r+=rateCalc.ConvertStringToNumber(n.calculatedSellerClosingContribution())),rateCalc.GetCurrencyValue(u-r)});n.addSellerLoanPayoff=function(){n.additionalSellerLoanPayoffList.push(new LoanPayoff)};n.removeSellerLoanPayoff=function(){n.additionalSellerLoanPayoffList().length>1&&n.additionalSellerLoanPayoffList.remove(this)};n.calculatedSubTotalPayoff=ko.computed({read:function(){var t=0,i;for(n.loanPayoff1()&&(t+=rateCalc.ConvertStringToNumber(n.loanPayoff1())),n.loanPayoff2()&&(t+=rateCalc.ConvertStringToNumber(n.loanPayoff2())),i=0;i<n.additionalSellerLoanPayoffList().length;i++)t+=rateCalc.ConvertStringToNumber(n.additionalSellerLoanPayoffList()[i].loanPayoffAmount());return rateCalc.GetCurrencyValue(t)},write:function(t){for(n.loanPayoff1(t),n.loanPayoff2(ZERO_DOLLAR),n.additionalSellerLoanPayoffList()[0].loanPayoffAmount(ZERO_DOLLAR);n.additionalSellerLoanPayoffList().length>1;){var i=n.additionalSellerLoanPayoffList()[n.additionalSellerLoanPayoffList().length-1];n.additionalSellerLoanPayoffList.remove(i)}},owner:n});n.calculatedPropertyValue=ko.computed({read:function(){let t=ZERO_DOLLAR;return n.saleAmount(),n.actualPropertyValue(),closingSheetLookup&&(!f&&n.saleAmount()?n.saleAmount()!=ZERO_DOLLAR&&(t=rateCalc.GetCurrencyValue((rateCalc.ConvertStringToNumber(n.saleAmount())-rateCalc.ConvertStringToNumber(closingSheetLookup.TaxValuation.ExemptionAmount))*rateCalc.ConvertStringToNumber(closingSheetLookup.TaxValuation.ValuationFactor)),n.actualPropertyValue(t)):t=n.actualPropertyValue()),t},write:function(t){f=!0;n.actualPropertyValue(t)},owner:n});n.calculatePropertyTaxRate=ko.pureComputed({read:function(){var t="0.00 %";return n.propertyTaxRate()&&(t=n.propertyTaxRate()),t},write:function(t){n.propertyTaxRate(t);var i=rateCalc.ConvertStringToNumber(n.propertyTaxRate())/100;n.actualPropertyTax(rateCalc.GetCurrencyValue(i*rateCalc.ConvertStringToNumber(n.actualPropertyValue())))},owner:n});n.calculatedPropertyTax=ko.pureComputed({read:function(){var t=ZERO_DOLLAR,i;return!e&&n.propertyTaxRate()&&n.actualPropertyValue()?(i=rateCalc.ConvertStringToNumber(n.propertyTaxRate())/100,t=rateCalc.GetCurrencyValue(i*rateCalc.ConvertStringToNumber(n.actualPropertyValue())),n.actualPropertyTax(t)):n.actualPropertyTax()&&(t=n.actualPropertyTax()),e=!1,t},write:function(t){e=!0;n.actualPropertyTax(t);n.propertyTaxRate(rateCalc.GetPercentageValue(rateCalc.ConvertStringToNumber(t)*100/rateCalc.ConvertStringToNumber(n.actualPropertyValue())))},owner:n});n.calculatedPriorYearTaxTotal=ko.computed({read:function(){if(!o&&n.propertyTaxRate()&&n.calculatedPropertyValue()){var i=rateCalc.ConvertStringToNumber(n.propertyTaxRate())/100,t=rateCalc.GetCurrencyValue(i*rateCalc.ConvertStringToNumber(n.actualPropertyValue()));return n.actualPriorYearTaxTotalAmount(t),n.actualPriorYearEstSellerPaidAmount(t),t}return n.actualPriorYearTaxTotalAmount()},write:function(t){n.actualPriorYearTaxTotalAmount(t);o=!0},owner:n});n.calculatedPriorYearEstSellerPaid=ko.computed({read:function(){var t=ZERO_DOLLAR;if(n.closingDate()&&closingSheetLookup&&!s){var i=new Date(n.closingDate()),u=rateCalc.GetDate(new Date(closingSheetLookup.PaymentDate.PriorYearPaymentDate2),i),r=rateCalc.GetDate(new Date(closingSheetLookup.PaymentDate.PriorYearPaymentDate1),i);return i>=u?t=n.calculatedPropertyTax():i>=r?t=rateCalc.GetCurrencyValue(rateCalc.ConvertStringToNumber(n.calculatedPropertyTax())/2):i<r&&(t=rateCalc.GetCurrencyValue(0)),n.actualPriorYearEstSellerPaidAmount(t),t}return n.actualPriorYearEstSellerPaidAmount()},write:function(t){n.actualPriorYearEstSellerPaidAmount(t);s=!0},owner:n});n.calculatedPriorYearDiff=ko.pureComputed(function(){if(n.actualPriorYearTaxTotalAmount()&&n.actualPriorYearEstSellerPaidAmount())return rateCalc.GetCurrencyValue(rateCalc.ConvertStringToNumber(n.actualPriorYearTaxTotalAmount())-rateCalc.ConvertStringToNumber(n.actualPriorYearEstSellerPaidAmount()))});n.calculatedCurrentYearTaxProration=ko.computed({read:function(){if(!h&&n.closingDate()&&n.calculatedPropertyTax()){var t=new Date(n.closingDate()).getFullYear(),u=moment("1/1/"+t,[i]),f=moment(n.closingDate(),[i]),e=f.diff(u,"days")+1,o=e/rateCalc.GetDaysInYear(t),r=rateCalc.GetCurrencyValue(o*rateCalc.ConvertStringToNumber(n.calculatedPropertyTax()));return n.actualCurrentYearTaxProrationAmount(r),r}},write:function(t){n.actualCurrentYearTaxProrationAmount(t);h=!0},owner:n});n.calculatedCurrentYearEstSellerPaid=ko.computed({read:function(){var i=ZERO_DOLLAR;if(n.closingDate()&&closingSheetLookup&&!c){var t=new Date(n.closingDate()),u=rateCalc.GetDate(new Date(closingSheetLookup.PaymentDate.PriorYearPaymentDate2),t),r=rateCalc.GetDate(new Date(closingSheetLookup.PaymentDate.PriorYearPaymentDate1),t),f=rateCalc.GetDate(new Date(closingSheetLookup.PaymentDate.CurrentYearBillingDateStart1),t),e=rateCalc.GetDate(new Date(closingSheetLookup.PaymentDate.CurrentYearBillingDateStart2),t),o=rateCalc.GetDate(new Date(closingSheetLookup.PaymentDate.CurrentYearBillingDateEnd1),t),s=rateCalc.GetDate(new Date(closingSheetLookup.PaymentDate.CurrentYearBillingDateEnd2),t);return t>f&&t<=o?t>r&&(i=rateCalc.GetCurrencyValue(rateCalc.ConvertStringToNumber(n.calculatedPropertyTax())/2)):t>=e&&t<=s&&(t>u?i=n.calculatedPropertyTax():t>r&&(i=rateCalc.GetCurrencyValue(rateCalc.ConvertStringToNumber(n.calculatedPropertyTax())/2))),n.actualCurrentYearEstSellerPaidAmount(i),i}return n.actualCurrentYearEstSellerPaidAmount()},write:function(t){n.actualCurrentYearEstSellerPaidAmount(t);c=!0},owner:n});n.calculatedCurrentYearDiff=ko.pureComputed(function(){if(n.actualCurrentYearTaxProrationAmount()&&n.actualCurrentYearEstSellerPaidAmount())return rateCalc.GetCurrencyValue(rateCalc.ConvertStringToNumber(n.actualCurrentYearTaxProrationAmount())-rateCalc.ConvertStringToNumber(n.actualCurrentYearEstSellerPaidAmount()))});n.calculatedSubTotalPropertyTaxes=ko.pureComputed(function(){var t=0;return n.calculatedPriorYearDiff()&&(t+=rateCalc.ConvertStringToNumber(n.calculatedPriorYearDiff())),n.calculatedCurrentYearDiff()&&(t+=rateCalc.ConvertStringToNumber(n.calculatedCurrentYearDiff())),rateCalc.GetCurrencyValue(t)});n.calculateBuyerBrokerPercentage=ko.pureComputed({read:function(){var t="0.00 %";return n.buyerBrokerCommissionRate()&&(t=n.buyerBrokerCommissionRate()),t},write:function(t){n.buyerBrokerCommissionRate(t);var i=rateCalc.ConvertStringToNumber(n.buyerBrokerCommissionRate())/100;n.buyerBrokerCommissionAmount(rateCalc.GetCurrencyValue(i*rateCalc.ConvertStringToNumber(n.saleAmount())))},owner:n});n.calculatedBuyerBrokerCommission=ko.pureComputed({read:function(){var t=0,i;return n.buyerBrokerCommissionRate()&&n.saleAmount()&&(i=rateCalc.ConvertStringToNumber(n.buyerBrokerCommissionRate())/100,t=rateCalc.GetCurrencyValue(i*rateCalc.ConvertStringToNumber(n.saleAmount()))),t},write:function(t){n.buyerBrokerCommissionAmount(t);n.buyerBrokerCommissionRate(rateCalc.GetPercentageValue(rateCalc.ConvertStringToNumber(t)*100/rateCalc.ConvertStringToNumber(n.saleAmount())))},owner:n});n.calculateSellerBrokerPercentage=ko.pureComputed({read:function(){var t="0.00 %";return n.sellerBrokerCommissionRate()&&(t=n.sellerBrokerCommissionRate()),t},write:function(t){n.sellerBrokerCommissionRate(t);var i=rateCalc.ConvertStringToNumber(n.sellerBrokerCommissionRate())/100;n.sellerBrokerCommissionAmount(rateCalc.GetCurrencyValue(i*rateCalc.ConvertStringToNumber(n.saleAmount())))},owner:n});n.calculatedSellerBrokerCommission=ko.pureComputed({read:function(){var t=0,i;return n.sellerBrokerCommissionRate()&&n.saleAmount()&&(i=rateCalc.ConvertStringToNumber(n.sellerBrokerCommissionRate())/100,t=rateCalc.GetCurrencyValue(i*rateCalc.ConvertStringToNumber(n.saleAmount()))),t},write:function(t){n.sellerBrokerCommissionAmount(t);n.sellerBrokerCommissionRate(rateCalc.GetPercentageValue(rateCalc.ConvertStringToNumber(t)*100/rateCalc.ConvertStringToNumber(n.saleAmount())))},owner:n});n.addSellerClosingCost=function(){n.additionalSellerClosingCostList.push(new ClosingCostCredit)};n.removeSellerClosingCost=function(){n.additionalSellerClosingCostList().length>1&&n.additionalSellerClosingCostList.pop()};n.removeSellerClosingCostAndCredit=function(){n.additionalSellerClosingCostList().length>1&&n.additionalSellerClosingCostList.remove(this)};n.addSellerCreditItem=function(){n.additionalSellerCreditItemList.push(new ClosingCostCredit)};n.removeSellerCreditItem=function(){n.additionalSellerCreditItemList().length>1&&n.additionalSellerCreditItemList.pop()};n.calculatedSellerSubTotalClosingCostCredit=ko.computed(function(){var r=0,i=0,u,t;for(r+=rateCalc.ConvertStringToNumber(n.calculatedBuyerBrokerCommission()),r+=rateCalc.ConvertStringToNumber(n.calculatedSellerBrokerCommission()),i=0;i<n.sellerClosingCostList().length;i++)r+=rateCalc.ConvertStringToNumber(n.sellerClosingCostList()[i].closingCostCreditAmount());for(i=0;i<n.additionalSellerClosingCostList().length;i++)r+=rateCalc.ConvertStringToNumber(n.additionalSellerClosingCostList()[i].closingCostCreditAmount());for(u=0,t=0,t=0;t<n.sellerCreditItemList().length;t++)u+=rateCalc.ConvertStringToNumber(n.sellerCreditItemList()[t].closingCostCreditAmount());for(t=0;t<n.additionalSellerCreditItemList().length;t++)u+=rateCalc.ConvertStringToNumber(n.additionalSellerCreditItemList()[t].closingCostCreditAmount());return rateCalc.GetCurrencyValue(r-u)});n.addLoan=function(){var e,r,o;if(rateCalc.ConvertStringToNumber($("#LoanAmount").val())>0&&n.additionalLoanList().length<rateCalc.numberOfMultipleMortgages){let s=GetQuestionList(LENDER_PREMIUM,1);var t=n.additionalLoanList().length+2,u=[],f=jQuery('<section class="tab-content"/>'),i=rateCalc.clonedLenderEndorsementList.clone(!0).appendTo(f);i.attr("data-policy-number",t);e=i.find('span[data-name="prefixMultiple"]');e.text(rateCalc.GetNumeralPrefix(t));r=i.find(":checkbox");r.each(function(n,t){var i=$(t),r=rateCalc.GetUniqueID(i.attr("id"));i.attr("id",r);i.closest("li").find("label").attr("for",r);i.is(":checked")&&u.push(i.val())});n.additionalLoanList.push(new AdditionalLoan(ZERO_DOLLAR,!0,u));r.on("click",function(){var t=$(this),r=t.closest("fieldset"),i=rateCalc.ConvertStringToNumber(r.attr("data-policy-number"));t.is(":checked")?n.additionalLoanList()[i-2].checkedEndorsements().push(t.val()):n.additionalLoanList()[i-2].checkedEndorsements.remove(t.val());rateCalc.isQuoteTriggerForEndorsement=!0});o=$("#divEndorsementWrapper").find('fieldset[data-policy-feetype="'+LENDER_PREMIUM+'"][data-policy-number="'+(t-1)+'"]').closest("section");f.insertAfter(o);n.additionalLoanList().length===rateCalc.numberOfMultipleMortgages&&$("[data-name='add-loan-span']").addClass(CLASS_DISABLED_NO_CURSOR);UpdatePolicyNumberDataAttributeValueForAdditionalLoans(LENDER_PREMIUM,t);RegisterClickEventForAccordionToggle(t,LENDER_PREMIUM);RegisterClickEventForQuestionRadioButtons();SyncRadioButtonsWithQuestionData(LENDER_PREMIUM,1,s);RegisterChangeEventForQuestionTextboxes()}};n.removeLoan=function(){var r,i,u,t;n.additionalLoanList().length>0&&(r=n.additionalLoanList.indexOf(this),n.additionalLoanList.remove(this),i=$("#divEndorsementWrapper"),i.find('fieldset[data-policy-feetype="'+LENDER_PREMIUM+'"][data-policy-number="'+(r+2)+'"]').closest("section").remove(),u=i.find('fieldset[data-policy-feetype="'+LENDER_PREMIUM+'"][data-policy-number!="1"]'),t=2,u.each(function(n,i){var r=$(i),u;r.attr("data-policy-number",t);u=r.find('span[data-name="prefixMultiple"]');u.text(rateCalc.GetNumeralPrefix(t));t++}),$("[data-name='add-loan-span']").removeClass(CLASS_DISABLED_NO_CURSOR),rateCalc.CanInvokeGetQuote()&&getQuote())};n.addLeaseholdLoan=function(){var i,o,r,s;if(rateCalc.ConvertStringToNumber($("#LeaseholdLoanAmount").val())>0&&n.additionalLeaseholdLoanList().length<rateCalc.numberOfMultipleMortgages){let h=GetQuestionList(LEASEHOLD_LENDER_PREMIUM,1);var t=n.additionalLeaseholdLoanList().length+2,u=[],f=jQuery('<section class="tab-content"/>'),e=rateCalc.clonedLeaseholdLenderEndorsementList.clone(!0);e.show();i=e.appendTo(f);i.attr("data-policy-number",t);o=i.find('span[data-name="prefixMultiple"]');o.text(rateCalc.GetNumeralPrefix(t));r=i.find(":checkbox");r.each(function(n,t){var i=$(t),r=rateCalc.GetUniqueID(i.attr("id"));i.attr("id",r);i.closest("li").find("label").attr("for",r);i.is(":checked")&&u.push(i.val())});n.additionalLeaseholdLoanList.push(new AdditionalLoan(ZERO_DOLLAR,!0,u));r.on("click",function(){var t=$(this),r=t.closest("fieldset"),i=rateCalc.ConvertStringToNumber(r.attr("data-policy-number"));t.is(":checked")?n.additionalLeaseholdLoanList()[i-2].checkedEndorsements().push(t.val()):n.additionalLeaseholdLoanList()[i-2].checkedEndorsements.remove(t.val());rateCalc.isQuoteTriggerForEndorsement=!0});s=$("#divEndorsementWrapper").find('fieldset[data-policy-feetype="'+LEASEHOLD_LENDER_PREMIUM+'"][data-policy-number="'+(t-1)+'"]').closest("section");f.insertAfter(s);n.additionalLeaseholdLoanList().length===rateCalc.numberOfMultipleMortgages&&$("[data-name='add-leaseholdloan-span']").addClass(CLASS_DISABLED_NO_CURSOR);UpdatePolicyNumberDataAttributeValueForAdditionalLoans(LEASEHOLD_LENDER_PREMIUM,t);RegisterClickEventForAccordionToggle(t,LEASEHOLD_LENDER_PREMIUM);RegisterClickEventForQuestionRadioButtons();SyncRadioButtonsWithQuestionData(LEASEHOLD_LENDER_PREMIUM,1,h);RegisterChangeEventForQuestionTextboxes()}};n.removeLeaseholdLoan=function(){var r,i,u,t;n.additionalLeaseholdLoanList().length>0&&(r=n.additionalLeaseholdLoanList.indexOf(this),n.additionalLeaseholdLoanList.remove(this),i=$("#divEndorsementWrapper"),i.find('fieldset[data-policy-feetype="'+LEASEHOLD_LENDER_PREMIUM+'"][data-policy-number="'+(r+2)+'"]').closest("section").remove(),u=i.find('fieldset[data-policy-feetype="'+LEASEHOLD_LENDER_PREMIUM+'"][data-policy-number!="1"]'),t=2,u.each(function(n,i){var r=$(i),u;r.attr("data-policy-number",t);u=r.find('span[data-name="prefixMultiple"]');u.text(rateCalc.GetNumeralPrefix(t));t++}),$("[data-name='add-leaseholdloan-span']").removeClass(CLASS_DISABLED_NO_CURSOR),rateCalc.CanInvokeGetQuote()&&getQuote())};n.allowCollateralMortgage=ko.observable(!1)}rateCalc.closingSheetViewModel=new n};rateCalc.GetUniqueID=function(n){return n+"-"+Math.random().toString(16).slice(2)};rateCalc.ConvertStringToNumber=function(n){let t=0,i=1;if(n){let r=n.toString().trim();r.startsWith("(")&&r.endsWith(")")&&(i=-1);t=Number(r.replace(/[^0-9.-]+/g,""))*i}return t};rateCalc.ConvertNumberToCurrencyString=function(n){return"$"+n.toLocaleString("en",{minimumFractionDigits:2,maximumFractionDigits:2})};rateCalc.GetDaysInYear=function(n){return rateCalc.IsLeapYear(n)?366:365};rateCalc.IsLeapYear=function(n){return n%400==0||n%100!=0&&n%4==0};rateCalc.GetValueFactor=function(n){var i=0,t;if(closingSheetLookup)for(t=0;t<closingSheetLookup.LoanTypeValueFactorList.LoanTypeValueFactor.length;t++)if(valueFactor=closingSheetLookup.LoanTypeValueFactorList.LoanTypeValueFactor[t],valueFactor.ValueFactorType===n&&valueFactor.LowerRange<=rateCalc.closingSheetViewModel.downPaymentRate()&&valueFactor.UpperRange>=rateCalc.closingSheetViewModel.downPaymentRate()){i=valueFactor.ValueFactor;break}return i};rateCalc.GetDate=function(n,t){n.setFullYear(n.getFullYear()+(t.getFullYear()-(new Date).getFullYear()))};rateCalc.GetClosingCostAndTitleServiceFee=function(){$("#hidNetworkID").val(rateCalc.networkID);$("#hidQuoteRequestRoot").val(JSON.stringify(rateCalc.quoteRequestRoot));sendAjaxRequest("POST","/api/pricing/closingsheetfees",$("#frmCalculateRates").serialize(),function(n){rateCalc.DisplayClosingCostAndTitleServiceFee(n,BUYER);rateCalc.DisplayClosingCostAndTitleServiceFee(n,SELLER)},DisplayError)};rateCalc.DisplayClosingCostAndTitleServiceFee=function(n,t){$('div[data-name="'+t+'CostsClosingCostWrapper"]').children().remove();$('div[data-name="'+t+'CostsCreditsWrapper"]').children().remove();var u,r,i;n.ClosingSheet&&(t===BUYER?(n.ClosingSheet.BuyerClosingCostList&&(i=rateCalc.GetSectionFields(t,n.ClosingSheet.BuyerClosingCostList.BuyerClosingCost,COSTS_CLOSING_COST,!0)),n.ClosingSheet.BuyerCreditList&&(u=rateCalc.GetSectionFields(t,n.ClosingSheet.BuyerCreditList.BuyerCredit,COSTS_CREDITS,!0))):(n.ClosingSheet.SellerClosingCostList&&(i=rateCalc.GetSectionFields(t,n.ClosingSheet.SellerClosingCostList.SellerClosingCost,COSTS_CLOSING_COST,!0)),n.ClosingSheet.SellerCreditList&&(u=rateCalc.GetSectionFields(t,n.ClosingSheet.SellerCreditList.SellerCredit,COSTS_CREDITS,!0))),n.TitleServiceFee&&n.TitleServiceFee.ItemizedTitleServiceFeeList&&(r=rateCalc.GetSectionFields(t,n.TitleServiceFee.ItemizedTitleServiceFeeList.ItemizedTitleServiceFee,COSTS_CLOSING_COST,!1)));(i&&i.children("div").length>0||r&&r.children("div").length>0)&&(i&&i.children("div").length>0&&i.appendTo('div[data-name="'+t+'CostsClosingCostWrapper"]'),r&&r.children("div").length>0&&r.appendTo('div[data-name="'+t+'CostsClosingCostWrapper"]'));u&&u.children("div").length>0&&u.appendTo('div[data-name="'+t+'CostsCreditsWrapper"]')};rateCalc.GetSectionFields=function(n,t,i,r){var u=0,f=jQuery("<div/>");return f.attr("data-name",n+i),$.each(t,function(){var e=this.Amount,s=jQuery("<div/>"),t,h,o,l,c,a,v;if(s.attr({"class":"row","data-name":n+i+"Row"+u}),t=jQuery("<div/>"),t.attr("class","columns four"),t.appendTo(s),h=jQuery("<p/>"),h.attr("class","columns four"),r?h.text(this.Description):h.text(this.Name),h.appendTo(s),t=jQuery("<div/>"),t.attr("class","columns four"),o="",r)o=n+i+"Text"+u,l=jQuery("<input/>"),l.attr({"class":"input-block",id:o,name:"txt"+n+ +i+"Text"+u,type:"text",value:rateCalc.GetCurrencyValue(e),onchange:"UpdateBuyerSellerObj(this, '$')","data-role":n,"data-closing-cost-credit-section":i}),l.appendTo(t);else if(e=n===BUYER?this.BuyerAmount:this.SellerAmount,e&&Number(e)>0)o=n+i+"Span"+u,c=jQuery("<span/>"),c.attr({"class":"total",id:o}),c.text(rateCalc.GetCurrencyValue(e)),c.appendTo(t);else return;t.appendTo(s);s.appendTo(f);i===COSTS_CLOSING_COST?(a=new ClosingCostCredit(o,e),n===BUYER?rateCalc.closingSheetViewModel.buyerClosingCostList.push(a):n===SELLER&&rateCalc.closingSheetViewModel.sellerClosingCostList.push(a)):i===COSTS_CREDITS&&(v=new ClosingCostCredit(o,e),n===BUYER?rateCalc.closingSheetViewModel.buyerCreditItemList.push(v):n===SELLER&&rateCalc.closingSheetViewModel.sellerCreditItemList.push(v));u=u+1}),f};rateCalc.UpdateFieldValue=function(n,t,i,r){switch(t){case"$":$(n).val(rateCalc.GetCurrencyValueWithLimits(n.value,i,r));break;case"%":$(n).val(rateCalc.GetPercentageValueWithLitits(n.value,i,r))}};rateCalc.GetCurrencyValueWithLimits=function(n,t,i){var r="",u=n.toString().trim(),f=!1,e;return(u.startsWith("-")||u.startsWith("(")&&u.endsWith(")"))&&(f=!0),n=parseFloat(u.replace(/[^0-9.]+/g,"")),$.isNumeric(n)&&(e=f?-1*n:n,n=e>t?t:e<i?i:n,r="$"+Math.abs(n).toFixed(2).replace(/(\d)(?=(\d\d\d)+(?!\d))/g,"$1,"),f&&n!==0&&(r="("+r+")")),r};rateCalc.GetPercentageValueWithLitits=function(n,t,i){var r="";return n=parseFloat(n.toString().replace(/[^0-9.]+/g,"")),$.isNumeric(n)&&(n=n>t?t:n<i?i:n,r=n.toFixed(2).replace(/(\d)(?=(\d\d\d)+(?!\d))/g,"$1,")+" %"),r};rateCalc.GetToolTipForPolicyCoverageType=function(n){let t=$("#"+n+" :selected"),i="";return t.length>0&&(i=t.data("helpingnote")),i};String.prototype.startsWith||(String.prototype.startsWith=function(n,t){return t=t||0,this.indexOf(n,t)===t});rateCalc.RenderTEFEResults=function(n){var t=n.QuoteResponse.Pricing;rateCalc.isQuoteTriggerForTIP||rateCalc.isQuoteTriggerForTSF?(rateCalc.LoadTEFEResultForTIPwithEndorsements(t),rateCalc.LoadTEFEResultForTitleServiceFees(n.QuoteResponse)):rateCalc.isQuoteTriggerForEndorsement?rateCalc.LoadTEFEResultForEndorsements(t):rateCalc.isQuoteTriggerForRecording?(rateCalc.LoadTEFEResultForRecordingFeesAndTransferTaxes(n.QuoteResponse.Recordings),rateCalc.UpdateTaxRow()):(rateCalc.LoadTEFEResultForTIPwithEndorsements(t),rateCalc.LoadTEFEResultForTitleServiceFees(n.QuoteResponse),rateCalc.LoadTEFEResultForRecordingFeesAndTransferTaxes(n.QuoteResponse.Recordings))};rateCalc.LoadTEFEResultForTIPwithEndorsements=function(n){const d=rateCalc.IsRefinance()||rateCalc.IsConstructionRefiTransaction(),g=rateCalc.IsSaleTransaction(),w=$('fieldset[data-name="tbTipPolicy"] table'),a=w.find("tbody"),l=$('div[data-name="endorsementsResultWrapper"]'),r=rateCalc.GetDataForSelectedTransactionType(TRANSACTION_TYPE_KEYS.IS_DISPLAY_SPLITS);let f,e,o,s,h,c,t,u=0,i,v=0,y=0,p=0;if(rateCalc.updatedEndorsementList={Owner:[],Lender:[],LeaseholdOwner:[],LeaseholdLender:[],ConstructionLender:[],ProjectLender:[]},l.find("table").remove(),w.show(),a.find('tr:not([data-policy-number="1"])').remove(),a.find('tr:not([class*="hidden-element"])').addClass("hidden-element"),a.find("[required]").hide(),a.find('input:not([data-dim="'+PERCENTAGE+'"])').val(EMPTY_STRING),a.find("span").text(EMPTY_STRING),a.find("td").css({border:"0"}),$('[data-name ="spanMobileArrow"]').hide(),rateCalc.policyInsuredTypeList&&rateCalc.policyInsuredTypeList.length>0)for(let n=0;n<rateCalc.policyInsuredTypeList.length;n++)switch(rateCalc.policyInsuredTypeList[n].Code){case COVERAGE_TYPE_CODES.OP:$("#txtOwnerPolicyBuyerAmount, #txtOwnerPolicySellerAmount").val(ZERO_DOLLAR);$("#spanOwnerPolicyTotal").text(ZERO_DOLLAR);t&&t.find("td").css({"border-bottom":TABLE_ROW_BORDER});t=$('tr[data-name="trOwnerPolicy"]');t.removeClass("hidden-element");t.find("[required]").filter(function(){return $(this).parent().css("display")!=="none"}).show();u++;break;case COVERAGE_TYPE_CODES.MP:$("#txtLenderPolicyBuyerAmount, #txtLenderPolicySellerAmount").val(ZERO_DOLLAR);$("#spanLenderPolicyTotal").text(ZERO_DOLLAR);t&&t.find("td").css({"border-bottom":TABLE_ROW_BORDER});t=$('tr[data-name="trLenderPolicy"]');t.removeClass("hidden-element");t.find("[required]").filter(function(){return $(this).parent().css("display")!=="none"}).show();u++;break;case COVERAGE_TYPE_CODES.CMP:$("#txtConstructionLenderPolicyBuyerAmount, #txtConstructionLenderPolicySellerAmount").val(ZERO_DOLLAR);$("#spanConstructionLenderPolicyTotal").text(ZERO_DOLLAR);t&&t.find("td").css({"border-bottom":TABLE_ROW_BORDER});t=$('tr[data-name="trConstructionLenderPolicy"]');t.removeClass("hidden-element");t.find("[required]").filter(function(){return $(this).parent().css("display")!=="none"}).show();u++;break;case COVERAGE_TYPE_CODES.PMP:$("#txtProjectLenderPolicyBuyerAmount, #txtProjectLenderPolicySellerAmount").val(ZERO_DOLLAR);$("#spanProjectLenderPolicyTotal").text(ZERO_DOLLAR);t&&t.find("td").css({"border-bottom":TABLE_ROW_BORDER});t=$('tr[data-name="trProjectLenderPolicy"]');t.removeClass("hidden-element");t.find("[required]").filter(function(){return $(this).parent().css("display")!=="none"}).show();u++;break;case COVERAGE_TYPE_CODES.LMP:$("#txtLeaseholdLenderPolicyBuyerAmount, #txtLeaseholdLenderPolicySellerAmount").val(ZERO_DOLLAR);$("#spanLeaseholdLenderPolicyTotal").text(ZERO_DOLLAR);t&&t.find("td").css({"border-bottom":TABLE_ROW_BORDER});t=$('tr[data-name="trLeaseholdLenderPolicy"]');t.removeClass("hidden-element");t.find("[required]").filter(function(){return $(this).parent().css("display")!=="none"}).show();u++;break;case COVERAGE_TYPE_CODES.LOP:$("#txtLeaseholdOwnerPolicyBuyerAmount, #txtLeaseholdOwnerPolicySellerAmount").val(ZERO_DOLLAR);$("#spanLeaseholdOwnerPolicyTotal").text(ZERO_DOLLAR);t&&t.find("td").css({"border-bottom":TABLE_ROW_BORDER});t=$('tr[data-name="trLeaseholdOwnerPolicy"]');t.removeClass("hidden-element");t.find("[required]").filter(function(){return $(this).parent().css("display")!=="none"}).show();u++}if(n&&n.RateManual.Policies&&n.RateManual.Policies.Policy){const w=rateCalc.GetAnArray(n.RateManual.Policies.Policy);let k,b,g,nt;n.TRID.PolicyList&&n.TRID.PolicyList.Policy&&(k=rateCalc.GetAnArray(n.TRID.PolicyList.Policy),g=k.filter(function(n){return rateCalc.ConvertStringToNumber(n.Premium)!==0})[0],nt=k.filter(function(n){return rateCalc.ConvertStringToNumber(n.SalesTax)!==0})[0]);for(let tt=0;tt<w.length;tt++)switch(w[tt].FeeType){case OWNER_PREMIUM:rateCalc.propertyState!==STATE_ABBRV_MO?(f=w[tt].Premium,e=w[tt].Splits.Buyer.Premium,o=w[tt].Splits.Seller.Premium,$("#labelOwnerPolicyPremium").text("Owner's:"),s=w[tt].SalesTax,h=w[tt].Splits.Buyer.SalesTax,c=w[tt].Splits.Seller.SalesTax,$("#labelOwnerPolicyTax").text("Tax:")):(f=w[tt].RiskRate,e=w[tt].Splits.Buyer.RiskRate,o=w[tt].Splits.Seller.RiskRate,$("#labelOwnerPolicyPremium").text("Owner's - Title Insurance Premium:"),s=w[tt].TitleServiceCharge,h=w[tt].Splits.Buyer.TitleServiceCharge,c=w[tt].Splits.Seller.TitleServiceCharge,$("#labelOwnerPolicyTax").text("Owner's - Title Service Charge:"));f?($("#spanOwnerPolicyTotal").text(rateCalc.GetCurrencyValue(f)),r&&(e?$("#txtOwnerPolicyBuyerAmount").val(rateCalc.GetCurrencyValue(e)):$("#txtOwnerPolicyBuyerAmount").val(ZERO_DOLLAR),o?$("#txtOwnerPolicySellerAmount").val(rateCalc.GetCurrencyValue(o)):$("#txtOwnerPolicySellerAmount").val(ZERO_DOLLAR))):($("#spanOwnerPolicyTotal").text(ZERO_DOLLAR),$("#OwnerPolicyBuyerSplit").val()&&($("#txtOwnerPolicyBuyerAmount").val(ZERO_DOLLAR),$("#txtOwnerPolicySellerAmount").val(ZERO_DOLLAR)));rateCalc.ConvertStringToNumber(s)>0&&($("#spanOwnerTotalTax").text(rateCalc.GetCurrencyValue(s)),r&&(h?$("#spanOwnerBuyerTax").text(rateCalc.GetCurrencyValue(h)):$("#spanOwnerBuyerTax").text(ZERO_DOLLAR),c?$("#spanOwnerSellerTax").text(rateCalc.GetCurrencyValue(c)):$("#spanOwnerSellerTax").text(ZERO_DOLLAR)),t=$('tr[data-name="trOwnerTax"]'),t.removeClass("hidden-element"),u++);b=k?k.filter(function(n){return n.FeeType===w[tt].FeeType})[0]:null;b&&(g&&($("#spanOwnerTotalTRID").text(rateCalc.GetCurrencyValue(b.Premium)),r&&(b.Splits.Buyer.Premium?$("#spanOwnerBuyerTRID").text(rateCalc.GetCurrencyValue(b.Splits.Buyer.Premium)):$("#spanOwnerBuyerTRID").text(ZERO_DOLLAR),b.Splits.Seller.Premium?$("#spanOwnerSellerTRID").text(rateCalc.GetCurrencyValue(b.Splits.Seller.Premium)):$("#spanOwnerSellerTRID").text(ZERO_DOLLAR)),t=$('tr[data-name="trOwnerTRID"]'),t.removeClass("hidden-element"),u++),nt&&($("#spanOwnerTotalTaxTRID").text(rateCalc.GetCurrencyValue(b.SalesTax)),r&&(b.Splits.Buyer.SalesTax?$("#spanOwnerBuyerTaxTRID").text(rateCalc.GetCurrencyValue(b.Splits.Buyer.SalesTax)):$("#spanOwnerBuyerTaxTRID").text(ZERO_DOLLAR),b.Splits.Seller.SalesTax?$("#spanOwnerSellerTaxTRID").text(rateCalc.GetCurrencyValue(b.Splits.Seller.SalesTax)):$("#spanOwnerSellerTaxTRID").text(ZERO_DOLLAR)),t=$('tr[data-name="trOwnerTaxTRID"]'),t.removeClass("hidden-element"),u++));i=rateCalc.GetEndorsements(l,OWNER_PREMIUM,w[tt].EndorsementList.Endorsement,1);v+=i.buyerTotalIncludingTax;y+=i.sellerTotalIncludingTax;p+=i.endorsementsTotalIncludingTax;break;case LENDER_PREMIUM:if(rateCalc.propertyState!==STATE_ABBRV_MO?(f=w[tt].Premium,e=w[tt].Splits.Buyer.Premium,o=w[tt].Splits.Seller.Premium,$("#labelLenderPolicyPremium").text("Lender's:"),s=w[tt].SalesTax,h=w[tt].Splits.Buyer.SalesTax,c=w[tt].Splits.Seller.SalesTax,$("#labelLenderPolicyTax").text("Tax:")):(f=w[tt].RiskRate,e=w[tt].Splits.Buyer.RiskRate,o=w[tt].Splits.Seller.RiskRate,$("#labelLenderPolicyPremium").text("Lender's - Title Insurance Premium:"),s=w[tt].TitleServiceCharge,h=w[tt].Splits.Buyer.TitleServiceCharge,c=w[tt].Splits.Seller.TitleServiceCharge,$("#labelLenderPolicyTax").text("Lender's - Title Service Charge:")),f?($("#spanLenderPolicyTotal").text(rateCalc.GetCurrencyValue(f)),r&&(e?$("#txtLenderPolicyBuyerAmount").val(rateCalc.GetCurrencyValue(e)):$("#txtLenderPolicyBuyerAmount").val(ZERO_DOLLAR),o?$("#txtLenderPolicySellerAmount").val(rateCalc.GetCurrencyValue(o)):$("#txtLenderPolicySellerAmount").val(ZERO_DOLLAR))):($("#spanLenderPolicyTotal").text(ZERO_DOLLAR),$("#LenderPolicyBuyerSplit").val()&&($("#txtLenderPolicyBuyerAmount").val(ZERO_DOLLAR),$("#txtLenderPolicySellerAmount").val(ZERO_DOLLAR))),rateCalc.ConvertStringToNumber(s)>0&&($("#spanLenderTotalTax").text(rateCalc.GetCurrencyValue(s)),r&&(h?$("#spanLenderBuyerTax").text(rateCalc.GetCurrencyValue(h)):$("#spanLenderBuyerTax").text(ZERO_DOLLAR),c?$("#spanLenderSellerTax").text(rateCalc.GetCurrencyValue(c)):$("#spanLenderSellerTax").text(ZERO_DOLLAR)),t=$('tr[data-name="trLenderTax"]'),t.removeClass("hidden-element"),u++),b=k?k.filter(function(n){return n.FeeType===w[tt].FeeType})[0]:null,b&&(g&&($("#spanLenderTotalTRID").text(rateCalc.GetCurrencyValue(b.Premium)),r&&(b.Splits.Buyer.Premium?$("#spanLenderBuyerTRID").text(rateCalc.GetCurrencyValue(b.Splits.Buyer.Premium)):$("#spanLenderBuyerTRID").text(ZERO_DOLLAR),b.Splits.Seller.Premium?$("#spanLenderSellerTRID").text(rateCalc.GetCurrencyValue(b.Splits.Seller.Premium)):$("#spanLenderSellerTRID").text(ZERO_DOLLAR)),t=$('tr[data-name="trLenderTRID"]'),t.removeClass("hidden-element"),u++),nt&&($("#spanLenderTotalTaxTRID").text(rateCalc.GetCurrencyValue(b.SalesTax)),r&&(b.Splits.Buyer.SalesTax?$("#spanLenderBuyerTaxTRID").text(rateCalc.GetCurrencyValue(b.Splits.Buyer.SalesTax)):$("#spanLenderBuyerTaxTRID").text(ZERO_DOLLAR),b.Splits.Seller.SalesTax?$("#spanLenderSellerTaxTRID").text(rateCalc.GetCurrencyValue(b.Splits.Seller.SalesTax)):$("#spanLenderSellerTaxTRID").text(ZERO_DOLLAR)),t=$('tr[data-name="trLenderTaxTRID"]'),t.removeClass("hidden-element"),u++)),i=rateCalc.GetEndorsements(l,LENDER_PREMIUM,w[tt].EndorsementList.Endorsement,1),v+=i.buyerTotalIncludingTax,y+=i.sellerTotalIncludingTax,p+=i.endorsementsTotalIncludingTax,w[tt].AdditionalPolicies&&w[tt].AdditionalPolicies.Policy){const s=rateCalc.GetAnArray(w[tt].AdditionalPolicies.Policy);let h=a.find('tr[data-policy-feetype="'+LENDER_PREMIUM+'"]:last').find("td:first").parent().index(),f,t,c,e,o,u;for(let w=0;w<s.length;w++){let g=rateCalc.closingSheetViewModel.additionalLoanList()[w].isInsured(),b=w+2,k=ZERO_DOLLAR;if(e=null,f=jQuery('<tr data-name="trLenderPolicy'+b+'" data-policy-feetype="'+LENDER_PREMIUM+'" data-policy-number="'+b+'"/>'),t=jQuery('<td class="label4"/>'),c=jQuery('<label class="total"/>'),c.text(rateCalc.GetNumeralPrefix(b)+(d?"Refi Loan:":"Lender's:")),c.appendTo(t),t.appendTo(f),t=jQuery("<td/>"),t.appendTo(f),r&&(t=jQuery("<td/>"),e=jQuery("<input/>"),e.attr({"class":"input-block input-percentage","data-dim":PERCENTAGE,"data-policy-feetype":LENDER_PREMIUM,"data-role":BUYER,id:"LenderPolicyBuyerSplit"+b,max:"100",min:"0",required:"required",step:"1",title:"A percentage value between 0 to 100",type:"number",value:$("#LenderPolicyBuyerSplit").val(),onblur:"rateCalc.SplitPolicyPercentage(this)","data-initial-value":$("#LenderPolicyBuyerSplit").val()}),e.appendTo(t),t.appendTo(f),t=jQuery('<td class="text-center"/>'),t.text("/"),t.appendTo(f),t=jQuery("<td/>"),e=jQuery("<input/>"),u=s[w].Splits.Buyer.Premium?rateCalc.GetCurrencyValue(s[w].Splits.Buyer.Premium):ZERO_DOLLAR,k=u,g||(u=ZERO_DOLLAR),e.attr({"class":"input-block","data-dim":CURRENCY,"data-policy-feetype":LENDER_PREMIUM,"data-role":BUYER,id:"txtLenderPolicyBuyerAmount"+b,value:u,maxlength:"35",required:"required",type:"text",onchange:"rateCalc.ChangePolicyAmount(this)","data-initial-value":k}),e.appendTo(t),t.appendTo(f),t=jQuery("<td/>"),e=jQuery("<input/>"),e.attr({"class":"input-block input-percentage","data-dim":PERCENTAGE,"data-policy-feetype":LENDER_PREMIUM,"data-role":SELLER,id:"LenderPolicySellerSplit"+b,max:"100",min:"0",required:"required",step:"1",title:"A percentage value between 0 to 100",type:"number",value:$("#LenderPolicySellerSplit").val(),onblur:"rateCalc.SplitPolicyPercentage(this)","data-initial-value":$("#LenderPolicySellerSplit").val()}),e.appendTo(t),t.appendTo(f),t=jQuery('<td class="text-center"/>'),t.text("/"),t.appendTo(f),t=jQuery("<td/>"),e=jQuery("<input/>"),u=s[w].Splits.Seller.Premium?rateCalc.GetCurrencyValue(s[w].Splits.Seller.Premium):ZERO_DOLLAR,k=u,g||(u=ZERO_DOLLAR),e.attr({"class":"input-block","data-dim":CURRENCY,"data-policy-feetype":LENDER_PREMIUM,"data-role":SELLER,id:"txtLenderPolicySellerAmount"+b,value:u,maxlength:"35",required:"required",type:"text",onchange:"rateCalc.ChangePolicyAmount(this)","data-initial-value":k}),e.appendTo(t),t.appendTo(f)),t=jQuery("<td/>"),o=jQuery('<span class="total pull-right"/>'),u=s[w].Premium?rateCalc.GetCurrencyValue(s[w].Premium):ZERO_DOLLAR,k=u,g||(u=ZERO_DOLLAR),o.attr({"class":"total pull-right",id:"spanLenderPolicyTotal"+b,"data-initial-value":k}),o.text(u),o.appendTo(t),t.appendTo(f),a.find("tr").eq(h).after(f),h++,n.TRID.TRIDAdditionalLenderPolicyList&&n.TRID.TRIDAdditionalLenderPolicyList.TRIDLenderPolicy){const i=n.TRID.TRIDAdditionalLenderPolicyList.TRIDLenderPolicy;f=jQuery('<tr data-name="trLenderTRID'+b+'" class="tefe-hidden-rows" data-policy-feetype="'+LENDER_PREMIUM+'" data-policy-number="'+b+'"/>');t=jQuery('<td class="label4"><label class="label-small">TRID<\/label><\/td>');t.appendTo(f);t=jQuery("<td/>");t.appendTo(f);t=jQuery("<td/>");t.appendTo(f);r&&(t=jQuery("<td/>"),t.appendTo(f),t=jQuery("<td/>"),u=i[w].Splits.Buyer.Premium?rateCalc.GetCurrencyValue(i[w].Splits.Buyer.Premium):ZERO_DOLLAR,k=u,g||(u=ZERO_DOLLAR),o=jQuery('<span  class="label-small pull-right" id="spanLenderBuyerTRID'+b+'" data-role="buyer" data-initial-value="'+k+'"/>'),o.text(u),o.appendTo(t),t.appendTo(f),t=jQuery("<td/>"),t.appendTo(f),t=jQuery("<td/>"),t.appendTo(f),t=jQuery("<td/>"),u=i[w].Splits.Seller.Premium?rateCalc.GetCurrencyValue(i[w].Splits.Seller.Premium):ZERO_DOLLAR,k=u,g||(u=ZERO_DOLLAR),o=jQuery('<span  class="label-small pull-right" id="spanLenderSellerTRID'+b+'" data-role="seller" data-initial-value="'+k+'"/>'),o.text(u),o.appendTo(t),t.appendTo(f),t=jQuery("<td/>"),u=i[w].Premium?rateCalc.GetCurrencyValue(i[w].Premium):ZERO_DOLLAR,k=u,g||(u=ZERO_DOLLAR));o=jQuery('<span  class="label-small pull-right" id="spanLenderTotalTRID'+b+'" data-initial-value="'+k+'"/>');o.text(u);o.appendTo(t);t.appendTo(f);a.find("tr").eq(h).after(f);h++}e&&(rateCalc.isTefeLoading=!0,e.change(),rateCalc.isTefeLoading=!1);i=rateCalc.GetEndorsements(l,LENDER_PREMIUM,s[w].EndorsementList.Endorsement,w+2);g&&(v+=i.buyerTotalIncludingTax,y+=i.sellerTotalIncludingTax,p+=i.endorsementsTotalIncludingTax)}}break;case LEASEHOLD_OWNER_PREMIUM:f=w[tt].Premium;e=w[tt].Splits.Buyer.Premium;o=w[tt].Splits.Seller.Premium;f?($("#spanLeaseholdOwnerPolicyTotal").text(rateCalc.GetCurrencyValue(f)),r&&(e?$("#txtLeaseholdOwnerPolicyBuyerAmount").val(rateCalc.GetCurrencyValue(e)):$("#txtLeaseholdOwnerPolicyBuyerAmount").val(ZERO_DOLLAR),o?$("#txtLeaseholdOwnerPolicySellerAmount").val(rateCalc.GetCurrencyValue(o)):$("#txtLeaseholdOwnerPolicySellerAmount").val(ZERO_DOLLAR))):($("#spanLeaseholdOwnerPolicyTotal").text(ZERO_DOLLAR),$("#LeaseholdOwnerPolicyBuyerSplit").val()&&($("#txtLeaseholdOwnerPolicyBuyerAmount").val(ZERO_DOLLAR),$("#txtLeaseholdOwnerPolicySellerAmount").val(ZERO_DOLLAR)));s=w[tt].SalesTax;h=w[tt].Splits.Buyer.SalesTax;c=w[tt].Splits.Seller.SalesTax;rateCalc.ConvertStringToNumber(s)>0&&($("#spanLeaseholdOwnerTotalTax").text(rateCalc.GetCurrencyValue(s)),r&&(h?$("#spanLeaseholdOwnerBuyerTax").text(rateCalc.GetCurrencyValue(h)):$("#spanLeaseholdOwnerBuyerTax").text(ZERO_DOLLAR),c?$("#spanLeaseholdOwnerSellerTax").text(rateCalc.GetCurrencyValue(c)):$("#spanLeaseholdOwnerSellerTax").text(ZERO_DOLLAR)),t=$('tr[data-name="trLeaseholdOwnerTax"]'),t.removeClass("hidden-element"),u++);i=rateCalc.GetEndorsements(l,LEASEHOLD_OWNER_PREMIUM,w[tt].EndorsementList.Endorsement,1);v+=i.buyerTotalIncludingTax;y+=i.sellerTotalIncludingTax;p+=i.endorsementsTotalIncludingTax;break;case LEASEHOLD_LENDER_PREMIUM:if(f=w[tt].Premium,e=w[tt].Splits.Buyer.Premium,o=w[tt].Splits.Seller.Premium,f?($("#spanLeaseholdLenderPolicyTotal").text(rateCalc.GetCurrencyValue(f)),r&&(e?$("#txtLeaseholdLenderPolicyBuyerAmount").val(rateCalc.GetCurrencyValue(e)):$("#txtLeaseholdLenderPolicyBuyerAmount").val(ZERO_DOLLAR),o?$("#txtLeaseholdLenderPolicySellerAmount").val(rateCalc.GetCurrencyValue(o)):$("#txtLeaseholdLenderPolicySellerAmount").val(ZERO_DOLLAR))):($("#spanLeaseholdLenderPolicyTotal").text(ZERO_DOLLAR),$("#LeaseholdLenderPolicyBuyerSplit").val()&&($("#txtLeaseholdLenderPolicyBuyerAmount").val(ZERO_DOLLAR),$("#txtLeaseholdLenderPolicySellerAmount").val(ZERO_DOLLAR))),s=w[tt].SalesTax,h=w[tt].Splits.Buyer.SalesTax,c=w[tt].Splits.Seller.SalesTax,rateCalc.ConvertStringToNumber(s)>0&&($("#spanLeaseholdLenderTotalTax").text(rateCalc.GetCurrencyValue(s)),r&&(h?$("#spanLeaseholdLenderBuyerTax").text(rateCalc.GetCurrencyValue(h)):$("#spanLeaseholdLenderBuyerTax").text(ZERO_DOLLAR),c?$("#spanLeaseholdLenderSellerTax").text(rateCalc.GetCurrencyValue(c)):$("#spanLeaseholdLenderSellerTax").text(ZERO_DOLLAR)),t=$('tr[data-name="trLeaseholdLenderTax"]'),t.removeClass("hidden-element"),u++),i=rateCalc.GetEndorsements(l,LEASEHOLD_LENDER_PREMIUM,w[tt].EndorsementList.Endorsement,1),v+=i.buyerTotalIncludingTax,y+=i.sellerTotalIncludingTax,p+=i.endorsementsTotalIncludingTax,w[tt].AdditionalPolicies&&w[tt].AdditionalPolicies.Policy){const e=rateCalc.GetAnArray(w[tt].AdditionalPolicies.Policy);let h=a.find('tr[data-policy-feetype="'+LEASEHOLD_LENDER_PREMIUM+'"]:last').find("td:first").parent().index(),f,n,s,t,o,u;for(let c=0;c<e.length;c++){let k=rateCalc.closingSheetViewModel.additionalLeaseholdLoanList()[c].isInsured(),w=c+2,b=ZERO_DOLLAR;t=null;f=jQuery('<tr data-name="trLeaseholdLenderPolicy'+w+'" data-policy-feetype="'+LEASEHOLD_LENDER_PREMIUM+'" data-policy-number="'+w+'"/>');n=jQuery('<td class="label4"/>');s=jQuery('<label class="total"/>');s.text(rateCalc.GetNumeralPrefix(w)+"Leasehold Lender's:");s.appendTo(n);n.appendTo(f);n=jQuery("<td/>");n.appendTo(f);r&&(n=jQuery("<td/>"),t=jQuery("<input/>"),t.attr({"class":"input-block input-percentage","data-dim":PERCENTAGE,"data-policy-feetype":LEASEHOLD_LENDER_PREMIUM,"data-role":BUYER,id:"LeaseholdLenderPolicyBuyerSplit"+w,max:"100",min:"0",required:"required",step:"1",title:"A percentage value between 0 to 100",type:"number",value:$("#LeaseholdLenderPolicyBuyerSplit").val(),onblur:"rateCalc.SplitPolicyPercentage(this)","data-initial-value":$("#LeaseholdLenderPolicyBuyerSplit").val()}),t.appendTo(n),n.appendTo(f),n=jQuery('<td class="text-center"/>'),n.text("/"),n.appendTo(f),n=jQuery("<td/>"),t=jQuery("<input/>"),u=e[c].Splits.Buyer.Premium?rateCalc.GetCurrencyValue(e[c].Splits.Buyer.Premium):ZERO_DOLLAR,b=u,k||(u=ZERO_DOLLAR),t.attr({"class":"input-block","data-dim":CURRENCY,"data-policy-feetype":LEASEHOLD_LENDER_PREMIUM,"data-role":BUYER,id:"txtLeaseholdLenderPolicyBuyerAmount"+w,value:u,maxlength:"35",required:"required",type:"text",onchange:"rateCalc.ChangePolicyAmount(this)","data-initial-value":b}),t.appendTo(n),n.appendTo(f),n=jQuery("<td/>"),t=jQuery("<input/>"),t.attr({"class":"input-block input-percentage","data-dim":PERCENTAGE,"data-policy-feetype":LEASEHOLD_LENDER_PREMIUM,"data-role":SELLER,id:"LeaseholdLenderPolicySellerSplit"+w,max:"100",min:"0",required:"required",step:"1",title:"A percentage value between 0 to 100",type:"number",value:$("#LeaseholdLenderPolicySellerSplit").val(),onblur:"rateCalc.SplitPolicyPercentage(this)","data-initial-value":$("#LeaseholdLenderPolicySellerSplit").val()}),t.appendTo(n),n.appendTo(f),n=jQuery('<td class="text-center"/>'),n.text("/"),n.appendTo(f),n=jQuery("<td/>"),t=jQuery("<input/>"),u=e[c].Splits.Seller.Premium?rateCalc.GetCurrencyValue(e[c].Splits.Seller.Premium):ZERO_DOLLAR,b=u,k||(u=ZERO_DOLLAR),t.attr({"class":"input-block","data-dim":CURRENCY,"data-policy-feetype":LEASEHOLD_LENDER_PREMIUM,"data-role":SELLER,id:"txtLeaseholdLenderPolicySellerAmount"+w,value:u,maxlength:"35",required:"required",type:"text",onchange:"rateCalc.ChangePolicyAmount(this)","data-initial-value":b}),t.appendTo(n),n.appendTo(f));n=jQuery("<td/>");o=jQuery('<span class="total pull-right"/>');u=e[c].Premium?rateCalc.GetCurrencyValue(e[c].Premium):ZERO_DOLLAR;b=u;k||(u=ZERO_DOLLAR);o.attr({"class":"total pull-right",id:"spanLeaseholdLenderPolicyTotal"+w,"data-initial-value":b});o.text(u);o.appendTo(n);n.appendTo(f);a.find("tr").eq(h).after(f);h++;t&&(rateCalc.isTefeLoading=!0,t.change(),rateCalc.isTefeLoading=!1);i=rateCalc.GetEndorsements(l,LEASEHOLD_LENDER_PREMIUM,e[c].EndorsementList.Endorsement,c+2);k&&(v+=i.buyerTotalIncludingTax,y+=i.sellerTotalIncludingTax,p+=i.endorsementsTotalIncludingTax)}}break;case CONSTRUCTION_LENDER_PREMIUM:f=w[tt].Premium;e=w[tt].Splits.Buyer.Premium;o=w[tt].Splits.Seller.Premium;f?($("#spanConstructionLenderPolicyTotal").text(rateCalc.GetCurrencyValue(f)),r&&(e?$("#txtConstructionLenderPolicyBuyerAmount").val(rateCalc.GetCurrencyValue(e)):$("#txtConstructionLenderPolicyBuyerAmount").val(ZERO_DOLLAR),o?$("#txtConstructionLenderPolicySellerAmount").val(rateCalc.GetCurrencyValue(o)):$("#txtConstructionLenderPolicySellerAmount").val(ZERO_DOLLAR))):($("#spanConstructionLenderPolicyTotal").text(ZERO_DOLLAR),$("#ConstructionLenderPolicyBuyerSplit").val()&&($("#txtConstructionLenderPolicyBuyerAmount").val(ZERO_DOLLAR),$("#txtConstructionLenderPolicySellerAmount").val(ZERO_DOLLAR)));s=w[tt].SalesTax;h=w[tt].Splits.Buyer.SalesTax;c=w[tt].Splits.Seller.SalesTax;rateCalc.ConvertStringToNumber(s)>0&&($("#spanConstructionLenderTotalTax").text(rateCalc.GetCurrencyValue(s)),r&&(h?$("#spanConstructionLenderBuyerTax").text(rateCalc.GetCurrencyValue(h)):$("#spanConstructionLenderBuyerTax").text(ZERO_DOLLAR),c?$("#spanConstructionLenderSellerTax").text(rateCalc.GetCurrencyValue(c)):$("#spanConstructionLenderSellerTax").text(ZERO_DOLLAR)),t=$('tr[data-name="trConstructionLenderTax"]'),t.removeClass("hidden-element"),u++);b=k?k.filter(function(n){return n.FeeType===w[tt].FeeType})[0]:null;b&&(g&&($("#spanConstructionLenderTotalTRID").text(rateCalc.GetCurrencyValue(b.Premium)),r&&(b.Splits.Buyer.Premium?$("#spanConstructionLenderBuyerTRID").text(rateCalc.GetCurrencyValue(b.Splits.Buyer.Premium)):$("#spanConstructionLenderBuyerTRID").text(ZERO_DOLLAR),b.Splits.Seller.Premium?$("#spanConstructionLenderSellerTRID").text(rateCalc.GetCurrencyValue(b.Splits.Seller.Premium)):$("#spanConstructionLenderSellerTRID").text(ZERO_DOLLAR)),t=$('tr[data-name="trConstructionLenderTRID"]'),t.removeClass("hidden-element"),u++),nt&&($("#spanConstructionLenderTotalTaxTRID").text(rateCalc.GetCurrencyValue(b.SalesTax)),r&&(b.Splits.Buyer.SalesTax?$("#spanConstructionLenderBuyerTaxTRID").text(rateCalc.GetCurrencyValue(b.Splits.Buyer.SalesTax)):$("#spanConstructionLenderBuyerTaxTRID").text(ZERO_DOLLAR),b.Splits.Seller.SalesTax?$("#spanConstructionLenderSellerTaxTRID").text(rateCalc.GetCurrencyValue(b.Splits.Seller.SalesTax)):$("#spanConstructionLenderSellerTaxTRID").text(ZERO_DOLLAR)),t=$('tr[data-name="trConstructionLenderTaxTRID"]'),t.removeClass("hidden-element"),u++));i=rateCalc.GetEndorsements(l,CONSTRUCTION_LENDER_PREMIUM,w[tt].EndorsementList.Endorsement,1);v+=i.buyerTotalIncludingTax;y+=i.sellerTotalIncludingTax;p+=i.endorsementsTotalIncludingTax;break;case PROJECT_LENDER_PREMIUM:f=w[tt].Premium;e=w[tt].Splits.Buyer.Premium;o=w[tt].Splits.Seller.Premium;f?($("#spanProjectLenderPolicyTotal").text(rateCalc.GetCurrencyValue(f)),r&&(e?$("#txtProjectLenderPolicyBuyerAmount").val(rateCalc.GetCurrencyValue(e)):$("#txtProjectLenderPolicyBuyerAmount").val(ZERO_DOLLAR),o?$("#txtProjectLenderPolicySellerAmount").val(rateCalc.GetCurrencyValue(o)):$("#txtProjectLenderPolicySellerAmount").val(ZERO_DOLLAR))):($("#spanProjectLenderPolicyTotal").text(ZERO_DOLLAR),$("#ProjectLenderPolicyBuyerSplit").val()&&($("#txtProjectLenderPolicyBuyerAmount").val(ZERO_DOLLAR),$("#txtProjectLenderPolicySellerAmount").val(ZERO_DOLLAR)));s=w[tt].SalesTax;h=w[tt].Splits.Buyer.SalesTax;c=w[tt].Splits.Seller.SalesTax;rateCalc.ConvertStringToNumber(s)>0&&($("#spanProjectLenderTotalTax").text(rateCalc.GetCurrencyValue(s)),r&&(h?$("#spanProjectLenderBuyerTax").text(rateCalc.GetCurrencyValue(h)):$("#spanProjectLenderBuyerTax").text(ZERO_DOLLAR),c?$("#spanProjectLenderSellerTax").text(rateCalc.GetCurrencyValue(c)):$("#spanProjectLenderSellerTax").text(ZERO_DOLLAR)),t=$('tr[data-name="trProjectLenderTax"]'),t.removeClass("hidden-element"),u++);b=k?k.filter(function(n){return n.FeeType===w[tt].FeeType})[0]:null;b&&(g&&($("#spanProjectLenderTotalTRID").text(rateCalc.GetCurrencyValue(b.Premium)),r&&(b.Splits.Buyer.Premium?$("#spanProjectLenderBuyerTRID").text(rateCalc.GetCurrencyValue(b.Splits.Buyer.Premium)):$("#spanProjectLenderBuyerTRID").text(ZERO_DOLLAR),b.Splits.Seller.Premium?$("#spanProjectLenderSellerTRID").text(rateCalc.GetCurrencyValue(b.Splits.Seller.Premium)):$("#spanProjectLenderSellerTRID").text(ZERO_DOLLAR)),t=$('tr[data-name="trProjectLenderTRID"]'),t.removeClass("hidden-element"),u++),nt&&($("#spanProjectLenderTotalTaxTRID").text(rateCalc.GetCurrencyValue(b.SalesTax)),r&&(b.Splits.Buyer.SalesTax?$("#spanProjectLenderBuyerTaxTRID").text(rateCalc.GetCurrencyValue(b.Splits.Buyer.SalesTax)):$("#spanProjectLenderBuyerTaxTRID").text(ZERO_DOLLAR),b.Splits.Seller.SalesTax?$("#spanProjectLenderSellerTaxTRID").text(rateCalc.GetCurrencyValue(b.Splits.Seller.SalesTax)):$("#spanProjectLenderSellerTaxTRID").text(ZERO_DOLLAR)),t=$('tr[data-name="trProjectLenderTaxTRID"]'),t.removeClass("hidden-element"),u++));i=rateCalc.GetEndorsements(l,PROJECT_LENDER_PREMIUM,w[tt].EndorsementList.Endorsement,1);v+=i.buyerTotalIncludingTax;y+=i.sellerTotalIncludingTax;p+=i.endorsementsTotalIncludingTax}}t&&t.find("td").css({"border-bottom":TABLE_ROW_BORDER});u===0?w.hide():u>1&&$('[data-name ="spanMobileArrow"]').show();rateCalc.premiumCalcTotals=rateCalc.GetPremiumCalcTotals();g&&rateCalc.UpdateTRIDOwnerPolicy();const b=l.find("table"),k=l.find('table[class*="hidden-element"]');if(b.length>0){v+=rateCalc.premiumCalcTotals.premiumCalcBuyerTotal;y+=rateCalc.premiumCalcTotals.premiumCalcSellerTotal;p+=rateCalc.premiumCalcTotals.premiumCalcTotal;const i=jQuery('<table id="total-premium-endorsement-result" class="table-results"><thead/><tbody/><\/table>'),u=i.find("tbody"),t=jQuery('<tr><td colspan="2"><label class="total">Total premium and Endorsements (including tax)<\/label><\/td><\/tr>');let n;r&&(n=jQuery('<td><span id="spanBuyerTotalPremEndors">'+rateCalc.GetCurrencyValue(v)+"<\/span><\/td>"),n.appendTo(t),n=jQuery('<td><span id="spanSellerTotalPremEndors">'+rateCalc.GetCurrencyValue(y)+"<\/span><\/td>"),n.appendTo(t));n=jQuery('<td><span id="spanTotalPremEndors">'+rateCalc.GetCurrencyValue(p)+"<\/span><\/td>");n.appendTo(t);t.appendTo(u);i.appendTo(l);k.length>0&&b.length===k.length&&i.addClass("hidden-element")}};rateCalc.LoadTEFEResultForEndorsements=function(n){const l=rateCalc.IsRefinance()||rateCalc.IsConstructionRefiTransaction(),r=$('div[data-name="endorsementsResultWrapper"]');let t,i,u;r.find("table").remove();rateCalc.updatedEndorsementList={Owner:[],Lender:[],LeaseholdOwner:[],LeaseholdLender:[],ConstructionLender:[],ProjectLender:[]};rateCalc.premiumCalcTotals=rateCalc.GetPremiumCalcTotals();let f=rateCalc.premiumCalcTotals.premiumCalcBuyerTotal,e=rateCalc.premiumCalcTotals.premiumCalcSellerTotal,o=rateCalc.premiumCalcTotals.premiumCalcTotal;if(n.RateManual.Policies&&n.RateManual.Policies.Policy){i=rateCalc.GetAnArray(n.RateManual.Policies.Policy);for(let n=0;n<i.length;n++)if(t=rateCalc.GetEndorsements(r,i[n].FeeType,i[n].EndorsementList.Endorsement,1),f+=t.buyerTotalIncludingTax,e+=t.sellerTotalIncludingTax,o+=t.endorsementsTotalIncludingTax,i[n].AdditionalPolicies&&i[n].AdditionalPolicies.Policy){u=rateCalc.GetAnArray(i[n].AdditionalPolicies.Policy);for(let s=0;s<u.length;s++)t=rateCalc.GetEndorsements(r,i[n].FeeType,u[s].EndorsementList.Endorsement,s+2),f+=t.buyerTotalIncludingTax,e+=t.sellerTotalIncludingTax,o+=t.endorsementsTotalIncludingTax}}const s=r.find("table"),h=r.find('table[class*="hidden-element"]'),c=rateCalc.GetDataForSelectedTransactionType(TRANSACTION_TYPE_KEYS.IS_DISPLAY_SPLITS);if(s.length>0){const i=jQuery('<table id="total-premium-endorsement-result" class="table-results"><thead/><tbody/><\/table>'),u=i.find("tbody"),t=jQuery('<tr><td colspan="2"><label class="total">Total premium and Endorsements (including tax)<\/label><\/td><\/tr>');let n;c&&(n=jQuery('<td><span id="spanBuyerTotalPremEndors">'+rateCalc.GetCurrencyValue(f)+"<\/span><\/td>"),n.appendTo(t),n=jQuery('<td><span id="spanSellerTotalPremEndors">'+rateCalc.GetCurrencyValue(e)+"<\/span><\/td>"),n.appendTo(t));n=jQuery('<td><span id="spanTotalPremEndors">'+rateCalc.GetCurrencyValue(o)+"<\/span><\/td>");n.appendTo(t);t.appendTo(u);i.appendTo(r);h.length>0&&s.length===h.length&&i.addClass("hidden-element")}};rateCalc.LoadTEFEResultForTitleServiceFees=function(n){n.Provider&&n.Provider.Name&&(rateCalc.negotiatedProvider&&(n.Provider.Name=rateCalc.negotiatedProvider.Provider.Name,n.Provider.Contact=rateCalc.negotiatedProvider.Provider.Contact,n.Provider.ContactEmail=rateCalc.negotiatedProvider.Provider.ContactEmail,n.Provider.Address=rateCalc.negotiatedProvider.Provider.Address,n.Provider.City=rateCalc.negotiatedProvider.Provider.City,n.Provider.StateCode=rateCalc.negotiatedProvider.Provider.StateCode,n.Provider.ZipCode=rateCalc.negotiatedProvider.Provider.ZipCode,n.Provider.Phone=rateCalc.negotiatedProvider.Provider.Phone,n.Provider.Fax=rateCalc.negotiatedProvider.Provider.Fax,n.Provider.PrimaryNote=rateCalc.negotiatedProvider.Provider.PrimaryNote,n.Provider.SecondaryNote=rateCalc.negotiatedProvider.Provider.SecondaryNote),rateCalc.LoadOfficeInfo(n.Provider));n.Pricing&&n.Pricing.TitleServiceFee.ItemizedTitleServiceFeeList?rateCalc.LoadQuoteResultForTitleServiceFees(n.Pricing.TitleServiceFee.ItemizedTitleServiceFeeList,BUYER):(rateCalc.updatedTitleServiceFeesList=[],$('div[data-name="'+BUYER+'TitleServiceFeesWrapper"]').empty(),rateCalc.closingSheetViewModel.isAdditionalTSFHeaderVisible(!0))};rateCalc.LoadTEFEResultForRecordingFeesAndTransferTaxes=function(n){var v,o,f,u,r,t,p,w,l,e,k,a;rateCalc.updatedRecordingFeesList=[];v=$('div[data-name="tefeRecordingResultWrapper"]');v.children().remove();o=!1;const b=rateCalc.GetDataForSelectedTransactionType(TRANSACTION_TYPE_KEYS.IS_DISPLAY_SPLITS);if(n&&n.Recording){const ft=rateCalc.IsRefinance()||rateCalc.IsConstructionRefiTransaction(),et=rateCalc.propertyState===STATE_ABBRV_NY,ot=jQuery('<table class="table-results"/>'),st=jQuery("<thead/>"),ut=jQuery('<tr><th colspan="2"/><\/tr>');let tt=0,rt,ht=!ft&&!rateCalc.IsAbleToModifyRecordingFeeSection||ft&&et||b;ht&&(rt=jQuery("<th>Buyer Amount<\/th>"),rt.appendTo(ut));b&&(rt=jQuery("<th>Seller Amount<\/th>"),rt.appendTo(ut));ft?et&&(rt=jQuery("<th>Lender Amount<\/th>"),rt.appendTo(ut)):rateCalc.IsAbleToModifyRecordingFeeSection||(rt=jQuery("<th>Lender Amount<\/th>"),rt.appendTo(ut));rt=jQuery("<th>Total<\/th>");rt.appendTo(ut);ut.appendTo(st);st.appendTo(ot);f=jQuery("<tbody/>");let it=rateCalc.GetAnArray(n.Recording);for(let n=0;n<it.length;n++){t={buyer:0,seller:0,lender:0,total:0};switch(it[n].RecordingType){case RECORDING_LENDER_OWNER:u=EMPTY_STRING;o=!1;break;case RECORDING_LEASEHOLD_LENDER_OWNER:u="Leasehold ";o=!1;break;case RECORDING_CONSTRUCTION_LENDER_OWNER:u="Construction ";o=!0;break;case RECORDING_PROJECT_LENDER_OWNER:u="Project ";o=!0}r=u+MORTGAGE_RECORDING_FEE;let v=it[n].Mortgage;var i=v.Fee?Number(v.Fee):0,h=v.BuyerSplitFee?Number(v.BuyerSplitFee):0,y=v.SellerSplitFee?Number(v.SellerSplitFee):0,c=v.LenderSplitFee?Number(v.LenderSplitFee):0;i>0&&(t.buyer=h,t.seller=y,t.lender=c,t.total=i,rateCalc.UpdateFeeRow(rateCalc.AddRecordingFeeToTable(f,r,t,tt,FEE)),tt=tt+1);r=u+REVERSE_MORTGAGE_FEE;var i=it[n].ReverseMortgage.Fee?Number(it[n].ReverseMortgage.Fee):0,h=it[n].ReverseMortgage.BuyerSplitFee?Number(it[n].ReverseMortgage.BuyerSplitFee):0,c=it[n].ReverseMortgage.LenderSplitFee?Number(it[n].ReverseMortgage.LenderSplitFee):0;if(i>0&&(t.buyer=h,t.lender=c,t.total=i,rateCalc.UpdateFeeRow(rateCalc.AddRecordingFeeToTable(f,r,t,tt,FEE)),tt=tt+1),!o){if(i=it[n].Deed.Fee?Number(it[n].Deed.Fee):0,i>0){r=u+DEED_RECORDING_FEE;var s=it[n].Deed,h=s.BuyerSplitFee?Number(s.BuyerSplitFee):0,y=s.SellerSplitFee?Number(s.SellerSplitFee):0,c=s.LenderSplitFee?Number(s.LenderSplitFee):0;t.buyer=h;t.seller=y;t.lender=c;t.total=i;rateCalc.UpdateFeeRow(rateCalc.AddRecordingFeeToTable(f,r,t,tt,FEE));tt=tt+1}if(i=it[n].Release.Fee?Number(it[n].Release.Fee):0,i>0){r=u+RELEASE_RECORDING_FEE;let e=it[n].Release;var d=e.BuyerSplitFee?Number(e.BuyerSplitFee):0,g=e.SellerSplitFee?Number(e.SellerSplitFee):0,nt=e.LenderSplitFee?Number(e.LenderSplitFee):0;t.buyer=d;t.seller=g;t.lender=nt;t.total=i;rateCalc.UpdateFeeRow(rateCalc.AddRecordingFeeToTable(f,r,t,tt,FEE));tt=tt+1}let e=it[n].CFPB2015.CFPBTax instanceof Array?it[n].CFPB2015.CFPBTax:it[n].CFPB2015;p=!1;i=it[n].Mortgage.ConservationFund?Number(it[n].Mortgage.ConservationFund):0;i>0&&(r=u+"Mortgage Conservation Fund Fee",t=rateCalc.GetUpdatedAmountsSplitFromCFBPTax(e,"MortgageConservationFund"),t.total=i,rateCalc.UpdateFeeRow(rateCalc.AddRecordingFeeToTable(f,r,t,tt,FEE)),tt=tt+1,p=!0);w=!1;i=it[n].Deed.ConservationFund?Number(it[n].Deed.ConservationFund):0;i>0&&(r=u+"Deed Conservation Fund Fee",t=rateCalc.GetUpdatedAmountsSplitFromCFBPTax(e,"DeedConservationFund"),t.total=i,rateCalc.UpdateFeeRow(rateCalc.AddRecordingFeeToTable(f,r,t,tt,FEE)),tt=tt+1,w=!0)}if(l=it[n].CFPB2015.CFPBTax instanceof Array?it[n].CFPB2015.CFPBTax:it[n].CFPB2015,$.each(l,function(n,i){if(i&&i.TaxType){taxTypeNode=i.TaxType;var s="",e="";taxTypeNode==DEED_TAX||taxTypeNode==MORTGAGE_TAX?(e=taxTypeNode.split(/(?=[A-Z])/)[0],s=e+"TT"):(e=taxTypeNode.split(/(?=[A-Z])/)[0],taxTypeNode.includes("Recordation")&&(s="Rec"));const n=taxTypeNode.includes(INTANGIBLE);$.each(i.TaxingEntities.TaxingEntity,function(n,i){p&&taxTypeNode==="MortgageConservationFund"||w&&taxTypeNode==="DeedConservationFund"||(r=u+taxTypeNode.replace(/([A-Z])/g," $1").trim()+" - "+i.TaxingEntityJurisdiction,o&&taxTypeNode===DEED_TAX)||(ft?et?(t.buyer=i.BuyerSplit?Number(i.BuyerSplit):0,t.lender=i.LenderSplit?Number(i.LenderSplit):0):(t.buyer=0,t.seller=0,t.lender=0):(t.buyer=i.BuyerSplit?Number(i.BuyerSplit):0,t.seller=i.SellerSplit?Number(i.SellerSplit):0,t.lender=i.LenderSplit?Number(i.LenderSplit):0),t.total=i.TaxAmount?Number(i.TaxAmount):0,rateCalc.AddRecordingFeeToTable(f,r,t,tt,TAX),tt=tt+1)})}}),it[n].AdditionalRecordingList&&it[n].AdditionalRecordingList.Recording){let o=rateCalc.GetAnArray(it[n].AdditionalRecordingList.Recording);for(e=0;e<o.length;e++){if(k=e+2,a=rateCalc.GetNumeralPrefix(k),t.buyer=0,t.seller=0,t.lender=0,i=o[e].Mortgage.Fee?Number(o[e].Mortgage.Fee):0,i>0){r=a+u+MORTGAGE_RECORDING_FEE;let n=o[e].Mortgage;var h=n.BuyerSplitFee?Number(n.BuyerSplitFee):0,y=n.SellerSplitFee?Number(n.SellerSplitFee):0,c=n.LenderSplitFee?Number(n.LenderSplitFee):0;t.buyer=h;t.seller=y;t.lender=c;t.total=i;rateCalc.UpdateFeeRow(rateCalc.AddRecordingFeeToTable(f,r,t,tt,FEE));tt=tt+1}i=o[e].ReverseMortgage.Fee?Number(o[e].ReverseMortgage.Fee):0;i>0&&(r=a+u+REVERSE_MORTGAGE_FEE,t.total=i,rateCalc.UpdateFeeRow(rateCalc.AddRecordingFeeToTable(f,r,t,tt,FEE)),tt=tt+1);l=Array.isArray(o[e].CFPB2015.CFPBTax)?o[e].CFPB2015.CFPBTax:o[e].CFPB2015;$.each(l,function(n,i){i&&i.TaxType&&(taxTypeNode=i.TaxType,taxTypeNode.toUpperCase().startsWith(MORTGAGE)&&$.each(i.TaxingEntities.TaxingEntity,function(n,i){r=a+u+taxTypeNode.replace(/([A-Z])/g," $1").trim()+" - "+i.TaxingEntityJurisdiction;ft?et?(t.buyer=i.BuyerSplit?Number(i.BuyerSplit):0,t.lender=i.LenderSplit?Number(i.LenderSplit):0):(t.buyer=0,t.seller=0,t.lender=0):(t.buyer=i.BuyerSplit?Number(i.BuyerSplit):0,t.seller=i.SellerSplit?Number(i.SellerSplit):0,t.lender=i.LenderSplit?Number(i.LenderSplit):0);t.total=i.TaxAmount?Number(i.TaxAmount):0;rateCalc.AddRecordingFeeToTable(f,r,t,tt,TAX);tt=tt+1}))})}}}f.appendTo(ot);ot.appendTo(v)}};rateCalc.GetUpdatedAmountsSplitFromCFBPTax=function(n,t){var i={buyer:0,seller:0,lender:0,total:0};return $.each(n,function(n,r){r&&r.TaxType&&(taxType=r.TaxType,$.each(r.TaxingEntities.TaxingEntity,function(n,r){taxType===t&&(i.buyer=r.BuyerSplit?Number(r.BuyerSplit):0,i.seller=r.SellerSplit?Number(r.SellerSplit):0,i.lender=r.LenderSplit?Number(r.LenderSplit):0)}))}),i};rateCalc.AddRecordingFeeToTable=function(n,t,i,r,u){const c=rateCalc.IsRefinance()||rateCalc.IsConstructionRefiTransaction(),s=rateCalc.propertyState===STATE_ABBRV_NY;let e=ZERO_DOLLAR;const o=jQuery('<tr data-rectype="'+u+'"/>');let f=jQuery("<td/>");f.attr("colspan","2");f.text(t);f.appendTo(o);const h=rateCalc.GetDataForSelectedTransactionType(TRANSACTION_TYPE_KEYS.IS_DISPLAY_SPLITS);isLender=!1;isLender=rateCalc.quoteType===QUOTE_TYPE_LOAN_ESTIMATE?c?s:!rateCalc.IsAbleToModifyRecordingFeeSection:s&&!rateCalc.IsAbleToModifyRecordingFeeSection;let l=h||isLender;if(l){f=jQuery("<td/>");e=rateCalc.GetCurrencyValue(i.buyer);let n=jQuery("<input/>");n.attr({"class":"input-block",id:"txtBuyerRecordingFeeRow"+r,name:"txtBuyerRecordingFeeRow"+r,"data-role":BUYER,type:"text",value:e,onchange:"rateCalc.UpdateRecording(this)"});rateCalc.IsAbleToModifyRecordingFeeSection||n.prop("disabled",!0);n.appendTo(f);f.appendTo(o)}return h&&(f=jQuery("<td/>"),e=rateCalc.GetCurrencyValue(i.seller),$input=jQuery("<input/>"),$input.attr({"class":"input-block",id:"txtSellerRecordingFeeRow"+r,name:"txtSellerRecordingFeeRow"+r,"data-role":SELLER,type:"text",value:e,onchange:"rateCalc.UpdateRecording(this)"}),$input.appendTo(f),rateCalc.IsAbleToModifyRecordingFeeSection||$input.prop("disabled",!0),f.appendTo(o)),isLender&&(f=jQuery("<td/>"),e=rateCalc.GetCurrencyValue(i.lender),$input=jQuery("<input/>"),$input.attr({"class":"input-block",id:"txtLenderRecordingFeeRow"+r,name:"txtLenderRecordingFeeRow"+r,"data-role":LENDER,type:"text",value:e,onchange:"rateCalc.UpdateRecording(this)"}),$input.prop("disabled",!0),$input.appendTo(f),f.appendTo(o)),f=jQuery("<td/>"),e=rateCalc.GetCurrencyValue(i.total),f.text(e),f.appendTo(o),o.appendTo(n),rateCalc.updatedRecordingFeesList.push({Name:t,BuyerAmount:rateCalc.GetCurrencyValue(i.buyer),SellerAmount:rateCalc.GetCurrencyValue(i.seller),LenderAmount:rateCalc.GetCurrencyValue(i.lender),TotalAmount:rateCalc.GetCurrencyValue(i.total)}),o};rateCalc.UpdateFeeRow=function(n){const t=rateCalc.IsRefinance()||rateCalc.IsConstructionRefiTransaction(),i=rateCalc.propertyState===STATE_ABBRV_NY;if(t){if(i){let e=n.find("td:first").html(),t=e.toUpperCase(),u=n.find("td:last").html(),f=n.find('input[type="text"]');t.match(/^\d/)&&(t=t.substr(t.indexOf(" ")+1));t.match(LEASEHOLD)&&(t=t.substr(t.indexOf(LEASEHOLD)+10));let r=t.startsWith(MORTGAGE)||t.startsWith(REVERSE_MORTGAGE)?rateCalc.RecordingFeesPayer.Mortgage:t.startsWith(RELEASE)?rateCalc.RecordingFeesPayer.Release:rateCalc.RecordingFeesPayer.Deed,i=rateCalc.GetIndexOfUpdatedItemInList(e,rateCalc.updatedRecordingFeesList);if(r!=="")if(rateCalc.updatedRecordingFeesList[i].BuyerAmount=ZERO_DOLLAR,rateCalc.updatedRecordingFeesList[i].SellerAmount=ZERO_DOLLAR,rateCalc.updatedRecordingFeesList[i].LenderAmount=ZERO_DOLLAR,r!==SPLIT){f.val(ZERO_DOLLAR);r=r===SELLER?BUYER:r;n.find('input[data-role="'+r+'"]').val(u);switch(r){case SELLER:rateCalc.updatedRecordingFeesList[i].SellerAmount=u;break;case BUYER:rateCalc.updatedRecordingFeesList[i].BuyerAmount=u;break;case LENDER:rateCalc.updatedRecordingFeesList[i].LenderAmount=u}}else{let r=rateCalc.ConvertStringToNumber(u),e=r/f.length,t=rateCalc.GetCurrencyValue(e);f.val(t);rateCalc.updatedRecordingFeesList[i].SellerAmount=t;f.length>2&&(rateCalc.updatedRecordingFeesList[i].LenderAmount=t);t=rateCalc.GetCurrencyValue(r-e*(f.length-1));n.find('input[data-role="buyer"]').val(t);rateCalc.updatedRecordingFeesList[i].BuyerAmount=t}}}else{let e=n.find("td:first").html(),t=e.toUpperCase(),u=n.find("td:last").html(),f=n.find('input[type="text"]');t.match(/^\d/)&&(t=t.substr(t.indexOf(" ")+1));t.match(LEASEHOLD)&&(t=t.substr(t.indexOf(LEASEHOLD)+10));let r=t.startsWith(MORTGAGE)||t.startsWith(REVERSE_MORTGAGE)?rateCalc.RecordingFeesPayer.Mortgage:t.startsWith(RELEASE)?rateCalc.RecordingFeesPayer.Release:rateCalc.RecordingFeesPayer.Deed,i=rateCalc.GetIndexOfUpdatedItemInList(e,rateCalc.updatedRecordingFeesList);if(e==="Deed Conservation Fund Fee"||e==="Mortgage Conservation Fund Fee"){let n=rateCalc.ConvertStringToNumber(rateCalc.updatedRecordingFeesList[i].BuyerAmount),t=rateCalc.ConvertStringToNumber(rateCalc.updatedRecordingFeesList[i].SellerAmount);n>0&&t<=0&&(r=BUYER);n<=0&&t>0&&(r=SELLER)}if(r!=="")if(rateCalc.updatedRecordingFeesList[i].BuyerAmount=ZERO_DOLLAR,rateCalc.updatedRecordingFeesList[i].SellerAmount=ZERO_DOLLAR,rateCalc.updatedRecordingFeesList[i].LenderAmount=ZERO_DOLLAR,r!==SPLIT){f.val(ZERO_DOLLAR);n.find('input[data-role="'+r+'"]').val(u);switch(r){case SELLER:rateCalc.updatedRecordingFeesList[i].SellerAmount=u;break;case BUYER:rateCalc.updatedRecordingFeesList[i].BuyerAmount=u;break;case LENDER:rateCalc.updatedRecordingFeesList[i].LenderAmount=u}}else{let r=rateCalc.ConvertStringToNumber(u),e=r/f.length,t=rateCalc.GetCurrencyValue(e);f.val(t);rateCalc.updatedRecordingFeesList[i].SellerAmount=t;f.length>2&&(rateCalc.updatedRecordingFeesList[i].LenderAmount=t);t=rateCalc.GetCurrencyValue(r-e*(f.length-1));n.find('input[data-role="buyer"]').val(t);rateCalc.updatedRecordingFeesList[i].BuyerAmount=t}}};rateCalc.UpdateTaxRow=function(){let n=$('div[data-name="tefeRecordingResultWrapper"] table tr[data-rectype="'+TAX+'"]');n.each(function(n,t){let i=$(t).find("td:first").html();if(rateCalc.propertyState===STATE_ABBRV_NY&&(i===DEED_TAX_STATE||i===LEASEHOLD_DEED_TAX_STATE)){let u=rateCalc.RecordingTaxPayer.Deed,n=rateCalc.GetIndexOfUpdatedItemInList(i,rateCalc.updatedRecordingFeesList),f=rateCalc.ConvertStringToNumber(rateCalc.updatedRecordingFeesList[n].BuyerAmount),e=rateCalc.ConvertStringToNumber(rateCalc.updatedRecordingFeesList[n].SellerAmount),o=f+e,r=rateCalc.GetCurrencyValue(o),s=$(t).find('input[type="text"]');s.val(ZERO_DOLLAR);rateCalc.updatedRecordingFeesList[n].BuyerAmount=ZERO_DOLLAR;rateCalc.updatedRecordingFeesList[n].SellerAmount=ZERO_DOLLAR;rateCalc.updatedRecordingFeesList[n].LenderAmount=ZERO_DOLLAR;u==SELLER?rateCalc.updatedRecordingFeesList[n].SellerAmount=r:rateCalc.updatedRecordingFeesList[n].BuyerAmount=r;$(t).find('input[data-role="'+u+'"]').val(r)}})};rateCalc.UpdateRecordingNYRefinance=function(n){var f=$(n).parent().parent(),l=f.children("td:first").html(),a=f.children("td:last"),e=rateCalc.ConvertStringToNumber(a.html()),i=ZERO_DOLLAR,r=ZERO_DOLLAR,s=rateCalc.quoteType===QUOTE_TYPE_BUYER?LENDER:BUYER,t=rateCalc.ConvertStringToNumber(n.value),u,h,c,o;t=t<=e?t:e;u=rateCalc.GetCurrencyValue(t);n.getAttribute("data-role")===BUYER?(i=u,r=rateCalc.GetCurrencyValue(e-t),h=f.find('input[data-role="'+LENDER+'"]'),h.val(r),$("#"+s+h.attr("name")).val(r)):(r=u,i=rateCalc.GetCurrencyValue(e-t),c=f.find('input[data-role="'+BUYER+'"]'),c.val(i),$("#"+s+c.attr("name")).val(i));$(n).val(u);$("#"+s+n.name).val(u);o=rateCalc.GetIndexOfUpdatedItemInList(l,rateCalc.updatedRecordingFeesList);o>-1&&(rateCalc.updatedRecordingFeesList[o].BuyerAmount=i,rateCalc.updatedRecordingFeesList[o].LenderAmount=r)};rateCalc.UpdateRecording=function(n){var l=rateCalc.ConvertStringToNumber($("#spanBuyerRecordingFeesTotal").text()),a=rateCalc.ConvertStringToNumber($("#spanTotalBuyerNetSheetAmount").text()),v=rateCalc.ConvertStringToNumber($("#spanSellerRecordingFeesTotal").text()),y=rateCalc.ConvertStringToNumber($("#spanTotalSellerNetSheetAmount").text()),f=$(n).parent().parent(),p=f.children("td:first").html(),w=f.children("td:last"),e=rateCalc.ConvertStringToNumber(w.html()),i=ZERO_DOLLAR,r=ZERO_DOLLAR,s=rateCalc.quoteType===QUOTE_TYPE_BUYER?SELLER:BUYER,t=rateCalc.ConvertStringToNumber(n.value),u,h,c,o;if(t=t<=e?t:e,u=rateCalc.GetCurrencyValue(t),n.getAttribute("data-role")===BUYER?(i=u,r=rateCalc.GetCurrencyValue(e-t),h=f.find('input[data-role="'+SELLER+'"]'),h.val(r),$("#"+s+h.attr("name")).val(r)):(r=u,i=rateCalc.GetCurrencyValue(e-t),c=f.find('input[data-role="'+BUYER+'"]'),c.val(i),$("#"+s+c.attr("name")).val(i)),$(n).val(u),$("#"+s+n.name).val(u),o=rateCalc.GetIndexOfUpdatedItemInList(p,rateCalc.updatedRecordingFeesList),o>-1&&(rateCalc.updatedRecordingFeesList[o].BuyerAmount=i,rateCalc.updatedRecordingFeesList[o].SellerAmount=r),rateCalc.IsNetSheetQuoteType()){$("#spanBuyerRecordingFeesTotal").text(rateCalc.GetRecordingTotalAmountString(BUYER));$("#spanSellerRecordingFeesTotal").text(rateCalc.GetRecordingTotalAmountString(SELLER));var b=rateCalc.ConvertStringToNumber($("#spanSellerRecordingFeesTotal").text()),k=rateCalc.ConvertStringToNumber($("#spanBuyerRecordingFeesTotal").text()),d=a+(k-l),g=v-b+y;$("#spanTotalSellerNetSheetAmount").text(rateCalc.GetCurrencyValue(g));$("#spanTotalBuyerNetSheetAmount").text(rateCalc.GetCurrencyValue(d))}};rateCalc.GetIndexOfUpdatedItemInList=function(n,t){for(var r=-1,i=0;i<t.length;i++)if(t[i].Name===n){r=i;break}return r};rateCalc.RemoveRecordingFeeFromClosingCostList=function(n){var i=-1,t;if(n.ClosingCost)for(t=0;t<n.ClosingCost.length;t++)if(n.ClosingCost[t].Name.toUpperCase()==="RECORDING FEE"){i=t;break}i!==-1&&n.ClosingCost.splice(i,1)};rateCalc.LoadQuoteResultForTitleEscrow=function(n){var u,t,i,r;if(n.RateManual.Policies&&n.RateManual.Policies.Policy){let f=rateCalc.GetAnArray(n.RateManual.Policies.Policy);for(let n=0;n<f.length;n++)switch(f[n].FeeType){case OWNER_PREMIUM:u=rateCalc.ConvertStringToNumber(f[n].Premium)+rateCalc.ConvertStringToNumber(f[n].SalesTax);t=rateCalc.GetTotalEndorsementAmount(f[n].EndorsementList);i=$("input[name='rbBuyerOwnerPolicy']:checked").val();rateCalc.ToggleSellerBuyerSplitButtons(QUOTE_TYPE_BUYER,i,$("#spanBuyerOwnerPolicyPremiumAmount"),u);r=$("input[name='rbSellerOwnerPolicy']:checked").val();rateCalc.ToggleSellerBuyerSplitButtons(QUOTE_TYPE_SELLER,r,$("#spanSellerOwnerPolicyPremiumAmount"),u);rateCalc.ToggleSellerBuyerSplitButtons(QUOTE_TYPE_BUYER,i,$("#spanBuyerOwnerPolicyCPLsEndorsements"),0);rateCalc.ToggleSellerBuyerSplitButtons(QUOTE_TYPE_SELLER,r,$("#spanSellerOwnerPolicyCPLsEndorsements"),0);t>0&&(rateCalc.ToggleSellerBuyerSplitButtons(QUOTE_TYPE_BUYER,i,$("#spanBuyerOwnerPolicyCPLsEndorsements"),t),rateCalc.ToggleSellerBuyerSplitButtons(QUOTE_TYPE_SELLER,r,$("#spanSellerOwnerPolicyCPLsEndorsements"),t));break;case LENDER_PREMIUM:u=rateCalc.ConvertStringToNumber(f[n].Premium)+rateCalc.ConvertStringToNumber(f[n].SalesTax);t=rateCalc.GetTotalEndorsementAmount(f[n].EndorsementList);i=$("input[name='rbBuyerLenderPolicy']:checked").val();rateCalc.ToggleSellerBuyerSplitButtons(QUOTE_TYPE_BUYER,i,$("#spanBuyerLenderPolicyPremiumAmount"),u);r=$("input[name='rbSellerLenderPolicy']:checked").val();rateCalc.ToggleSellerBuyerSplitButtons(QUOTE_TYPE_SELLER,r,$("#spanSellerLenderPolicyPremiumAmount"),u);rateCalc.ToggleSellerBuyerSplitButtons(QUOTE_TYPE_BUYER,i,$("#spanBuyerLenderPolicyCPLsEndorsements"),t);rateCalc.ToggleSellerBuyerSplitButtons(QUOTE_TYPE_SELLER,r,$("#spanSellerLenderPolicyCPLsEndorsements"),t)}}($("#hidNetsheetQuoteTrigger").val()===NETSHEET_QUOTE_TRIGGER_COUNTY||$("#hidNetsheetQuoteTrigger").val()===NETSHEET_QUOTE_TRIGGER_SALES_PRICE||$("#hidNetsheetQuoteTrigger").val()===NETSHEET_QUOTE_TRIGGER_LOAN_AMOUNT||$("#hidNetsheetQuoteTrigger").val()===NETSHEET_QUOTE_TRIGGER_LOAN_PCT||$("#hidNetsheetQuoteTrigger").val()===NETSHEET_QUOTE_TRIGGER_OWNER_PCT||$("#hidNetsheetQuoteTrigger").val()===NETSHEET_QUOTE_TRIGGER_TRANSACTION_TYPE)&&n.TitleServiceFee.ItemizedTitleServiceFeeList&&(rateCalc.ItemizedTitleServiceFeeList=n.TitleServiceFee.ItemizedTitleServiceFeeList,rateCalc.LoadQuoteResultForTitleServiceFees(rateCalc.ItemizedTitleServiceFeeList,BUYER),rateCalc.LoadQuoteResultForTitleServiceFees(rateCalc.ItemizedTitleServiceFeeList,SELLER));rateCalc.CalculateTotalTitleEscrow(QUOTE_TYPE_BUYER);rateCalc.CalculateTotalTitleEscrow(QUOTE_TYPE_SELLER)};rateCalc.LoadQuoteResultForTitleServiceFees=function(n,t){var h;const e=rateCalc.GetDataForSelectedTransactionType(TRANSACTION_TYPE_KEYS.IS_DISPLAY_SPLITS);if(rateCalc.IsLoanEstimateQuoteType()&&(rateCalc.updatedTitleServiceFeesList=[]),h=$('div[data-name="'+t+'TitleServiceFeesWrapper"]'),h.children().remove(),n.ItemizedTitleServiceFee&&n.ItemizedTitleServiceFee.length>0){var s=0,c=0,l=0,a=0,v=0,y=0,u=0,p=jQuery('<table class="table-results"/>'),w=jQuery("<thead/>"),o=jQuery("<tbody/>"),r=jQuery('<tr><th colspan="2"/><\/tr>'),f,i;e&&(f=jQuery("<th>Buyer Amount<\/th>"),f.appendTo(r),f=jQuery("<th>Seller Amount<\/th>"),f.appendTo(r));f=jQuery("<th>Total<\/th>");f.appendTo(r);r.appendTo(w);w.appendTo(p);$.each(n.ItemizedTitleServiceFee,function(n,f){var g=EMPTY_STRING,nt=EMPTY_STRING,k=EMPTY_STRING,d=0,h=0,p=ZERO_DOLLAR,b=rateCalc.GetIndexOfUpdatedTSF(f.Name),w;r=jQuery("<tr/>");i=jQuery("<td/>");i.attr("colspan","2");i.text(f.Name);i.appendTo(r);e&&(i=jQuery("<td/>"),f.BuyerAmount&&(h=Number(f.BuyerAmount),h&&typeof h=="number"||h===0?(c+=h,p=rateCalc.GetCurrencyValue(h),d+=h):p=f.BuyerAmount),g=p,w=jQuery("<input/>"),w.attr({"class":"input-block",id:t+"txtBuyerTitleServiceFeeRow"+u,name:"txtBuyerTitleServiceFeeRow"+u,"data-role":BUYER,type:"text",value:b>-1?rateCalc.updatedTitleServiceFeesList[b].BuyerAmount:p,onchange:"rateCalc.UpdateTSF(this)"}),w.appendTo(i),i.appendTo(r),f.SalesTaxBuyerAmount&&(v+=Number(f.SalesTaxBuyerAmount)),i=jQuery("<td/>"),p=ZERO_DOLLAR,f.SellerAmount&&(h=Number(f.SellerAmount),h&&typeof h=="number"||h===0?(l+=h,p=rateCalc.GetCurrencyValue(h),d+=h):p=f.SellerAmount),w=jQuery("<input/>"),w.attr({"class":"input-block",id:t+"txtSellerTitleServiceFeeRow"+u,name:"txtSellerTitleServiceFeeRow"+u,"data-role":SELLER,type:"text",value:b>-1?rateCalc.updatedTitleServiceFeesList[b].SellerAmount:p,onchange:"rateCalc.UpdateTSF(this)"}),w.appendTo(i),i.appendTo(r),f.SalesTaxSellerAmount&&(y+=Number(f.SalesTaxSellerAmount)),nt=p);i=jQuery("<td/>");f.Amount&&(h=Number(f.Amount),typeof h!="number"||isNaN(h)?(p=f.Amount,r.find("input").prop("disabled",!0),k=rateCalc.GetCurrencyValue(d)):(s=s+h,p=rateCalc.GetCurrencyValue(h),k=p));i.text(p);i.appendTo(r);r.appendTo(o);f.SalesTax&&(a+=Number(f.SalesTax));u=u+1;rateCalc.IsLoanEstimateQuoteType()&&rateCalc.updatedTitleServiceFeesList.push({Name:f.Name,BuyerAmount:g,SellerAmount:nt,TotalAmount:k,BuyerTaxAmount:f.SalesTaxBuyerAmount,SellerTaxAmount:f.SalesTaxSellerAmount,TotalTax:f.SalesTax})});r=jQuery("<tr/>");i=jQuery('<td><label class="total">Total for Title Service Fees (pre-tax)<\/label><\/td>');i.attr("colspan","2");i.appendTo(r);e&&(i=jQuery('<td><span id="'+t+'spanBuyerTSFnoTax">'+rateCalc.GetCurrencyValue(c)+"<\/span><\/td>"),i.appendTo(r),i=jQuery('<td><span id="'+t+'spanSellerTSFnoTax">'+rateCalc.GetCurrencyValue(l)+"<\/span><\/td>"),i.appendTo(r));i=jQuery('<td><span id="'+t+'spanTotalTSFnoTax">'+rateCalc.GetCurrencyValue(s)+"<\/span><\/td>");i.appendTo(r);r.appendTo(o);r=jQuery("<tr/>");i=jQuery('<td><label class="total">Total Tax for Title Service Fees<\/label><\/td>');i.attr("colspan","2");i.appendTo(r);e&&(i=jQuery('<td><span id="'+t+'spanBuyerTSF_Tax">'+rateCalc.GetCurrencyValue(v)+"<\/span><\/td>"),i.appendTo(r),i=jQuery('<td><span id="'+t+'spanSellerTSF_Tax">'+rateCalc.GetCurrencyValue(y)+"<\/span><\/td>"),i.appendTo(r));i=jQuery('<td><span id="'+t+'spanTotalTSF_Tax">'+rateCalc.GetCurrencyValue(a)+"<\/span><\/td>");i.appendTo(r);r.appendTo(o);r=jQuery("<tr/>");i=jQuery('<td><label class="total">Total for Title Service Fees (including tax)<\/label><\/td>');i.attr("colspan","2");i.appendTo(r);e&&(i=jQuery('<td><span id="'+t+'spanBuyerTSFwTax">'+rateCalc.GetCurrencyValue(c+v)+"<\/span><\/td>"),i.appendTo(r),i=jQuery('<td><span id="'+t+'spanSellerTSFwTax">'+rateCalc.GetCurrencyValue(l+y)+"<\/span><\/td>"),i.appendTo(r));i=jQuery('<td><span id="'+t+'spanTotalTSFwTax">'+rateCalc.GetCurrencyValue(s+a)+"<\/span><\/td>");i.appendTo(r);r.appendTo(o);o.appendTo(p);p.appendTo(h);rateCalc.closingSheetViewModel.isAdditionalTSFHeaderVisible(!1)}else rateCalc.IsLoanEstimateQuoteType()&&rateCalc.closingSheetViewModel.isAdditionalTSFHeaderVisible(!0)};rateCalc.UpdateTSF=function(n){var o=$(n).parent().parent(),l=o.children("td:first").html(),y=o.children("td:last"),r=rateCalc.ConvertStringToNumber(y.html()),i=ZERO_DOLLAR,u=ZERO_DOLLAR,s=rateCalc.quoteType===QUOTE_TYPE_BUYER?SELLER:BUYER,f=rateCalc.ConvertStringToNumber(n.value),e,h,c,t;if(f=f<=r?f:r,e=rateCalc.GetCurrencyValue(f),n.getAttribute("data-role")===BUYER?(i=e,u=rateCalc.GetCurrencyValue(r-f),h=o.find('input[data-role="'+SELLER+'"]'),h.val(u),$("#"+s+h.attr("name")).val(u)):(u=e,i=rateCalc.GetCurrencyValue(r-f),c=o.find('input[data-role="'+BUYER+'"]'),c.val(i),$("#"+s+c.attr("name")).val(i)),$(n).val(e),$("#"+s+n.name).val(e),t=rateCalc.GetIndexOfUpdatedTSF(l),rateCalc.IsNetSheetQuoteType())t>-1&&rateCalc.updatedTitleServiceFeesList.splice(t,1),rateCalc.updatedTitleServiceFeesList.push({Name:l,BuyerAmount:i,SellerAmount:u});else if(t>-1){var p=rateCalc.ConvertStringToNumber(i),w=r===0?0:Math.round(p*100/r),a=rateCalc.ConvertStringToNumber(rateCalc.updatedTitleServiceFeesList[t].TotalTax),v=Number((a*w/100).toFixed(2));rateCalc.updatedTitleServiceFeesList[t].BuyerAmount=i;rateCalc.updatedTitleServiceFeesList[t].SellerAmount=u;rateCalc.updatedTitleServiceFeesList[t].BuyerTaxAmount=rateCalc.GetCurrencyValue(v);rateCalc.updatedTitleServiceFeesList[t].SellerTaxAmount=rateCalc.GetCurrencyValue(a-v)}rateCalc.UpdateTotalTSFs(BUYER);rateCalc.CalculateTotalTitleEscrow(QUOTE_TYPE_BUYER);rateCalc.IsNetSheetQuoteType()&&(rateCalc.UpdateTotalTSFs(SELLER),rateCalc.CalculateTotalTitleEscrow(QUOTE_TYPE_SELLER))};rateCalc.UpdateTotalTSFs=function(n){var t=rateCalc.GetTotalItemizedTSFs(BUYER),u=rateCalc.ConvertStringToNumber($("#"+n+"spanTotalTSFnoTax").text()),r,i,f;$("#"+n+"spanBuyerTSFnoTax").text(rateCalc.GetCurrencyValue(t));$("#"+n+"spanSellerTSFnoTax").text(rateCalc.GetCurrencyValue(u-t));r=rateCalc.ConvertStringToNumber($("#"+n+"spanTotalTSF_Tax").text());i=r*t/u;$("#"+n+"spanBuyerTSF_Tax").text(rateCalc.GetCurrencyValue(i));$("#"+n+"spanSellerTSF_Tax").text(rateCalc.GetCurrencyValue(r-i));f=rateCalc.ConvertStringToNumber($("#"+n+"spanTotalTSFwTax").text());$("#"+n+"spanBuyerTSFwTax").text(rateCalc.GetCurrencyValue(t+i));$("#"+n+"spanSellerTSFwTax").text(rateCalc.GetCurrencyValue(f-(t+i)))};rateCalc.GetTotalItemizedTSFs=function(n){var i=$('div[data-name="'+n+'TitleServiceFeesWrapper"] table tbody tr input[data-role="'+n+'"]'),t=0;return i.each(function(n,i){var r=$(i);t+=rateCalc.ConvertStringToNumber(r.val())}),t};rateCalc.GetIndexOfUpdatedTSF=function(n){for(var i=-1,t=0;t<rateCalc.updatedTitleServiceFeesList.length;t++)if(rateCalc.updatedTitleServiceFeesList[t].Name===n){i=t;break}return i};rateCalc.LoadOfficeInfo=function(n){var u,r;rateCalc.selectedProvider=n;var i=200,f=n.Name+' (<a href="#" data-type="optionToggle" data-container-name="officeContainer">change office<\/a>)<br />',t=rateCalc.BuildLongerStringValues(f,n.Address,0,i);for(t=rateCalc.BuildLongerStringValues(t.builtStringValue,n.City,t.builtValueLastRowLength,i),t=rateCalc.BuildLongerStringValues(t.builtStringValue,n.StateCode+" "+n.ZipCode,t.builtValueLastRowLength,i),n.Contact&&(t=rateCalc.BuildLongerStringValues(t.builtStringValue,"Contact Name: "+n.Contact,t.builtValueLastRowLength,i)),n.ContactEmail&&(t=rateCalc.BuildLongerStringValues(t.builtStringValue,"Email: "+n.ContactEmail,t.builtValueLastRowLength,i)),n.Phone&&(t=rateCalc.BuildLongerStringValues(t.builtStringValue,"Tel: "+n.Phone,t.builtValueLastRowLength,i)),n.Fax&&(t=rateCalc.BuildLongerStringValues(t.builtStringValue,"Fax: "+n.Fax,t.builtValueLastRowLength,i)),rateCalc.IsLoanEstimateQuoteType()?$('div[data-name="tefeOfficeWrapper"]').html(t.builtStringValue):($('div[data-name="buyerOfficeWrapper"]').html(t.builtStringValue),$('div[data-name="sellerOfficeWrapper"]').html(t.builtStringValue)),u=document.querySelectorAll('[data-type="optionToggle"]'),r=0;r<u.length;r++)u[r].addEventListener("click",function(n){n.preventDefault;var t=this.getAttribute("data-container-name");rateCalc.showContainer(t,CALC_CONTAINER)})};rateCalc.BuildLongerStringValues=function(n,t,i,r){return t&&(i+t.length>r?(n+=",<br />",i=t.length):i>0?(n+=", ",i=n.length+t.length):i=t.length,n+=t),{builtStringValue:n,builtValueLastRowLength:i}};rateCalc.GetTotalEndorsementAmount=function(n){var t=0;return n&&$.each(n.Endorsement,function(n,i){t+=rateCalc.ConvertStringToNumber(i.Premium)+rateCalc.ConvertStringToNumber(i.SalesTax)}),t};rateCalc.LoadQuoteResultForClosingCostsCredits=function(n,t){$('div[data-name="'+t+'CostsClosingCostWrapper"]').children().remove();$('div[data-name="'+t+'CostsCreditsWrapper"]').children().remove();var r,i;n&&(n.ClosingCostList&&(i=rateCalc.GetSectionFields(t,n.ClosingCostList.ClosingCost,COSTS_CLOSING_COST)),n.ClosingCreditList&&(r=rateCalc.GetSectionFields(t,n.ClosingCreditList.ClosingCredit,COSTS_CREDITS)));i&&i.children("div").length>0&&i&&i.children("div").length>0&&i.appendTo('div[data-name="'+t+'CostsClosingCostWrapper"]');r&&r.children("div").length>0&&r.appendTo('div[data-name="'+t+'CostsCreditsWrapper"]')};rateCalc.GetSectionFields=function(n,t,i){var r=0,u=jQuery("<div/>");return u.attr("data-name",n+i),$.each(t,function(){var s=n===BUYER?this.BuyerAmount:this.SellerAmount,h,t,f,e,o,c,l;s&&(h=i===COSTS_CLOSING_COST?s:"-"+s,t=jQuery("<div/>"),t.attr({"class":"row","data-name":n+i+"Row"+r}),f=jQuery("<p/>"),f.attr("class","columns six"),f.text(this.Name),f.appendTo(t),e=jQuery("<div/>"),e.attr("class","columns three"),o="",o=n+i+"Text"+r+"_"+this.Name,c=jQuery("<input/>"),c.attr({"class":"input-block",id:o,name:"txt"+n+i+"Text"+r,type:"text",value:rateCalc.GetCurrencyValue(h),onchange:"UpdateBuyerSellerObj(this, '$')","data-role":n,"data-closing-cost-credit-section":COSTS_CLOSING_COST}),c.appendTo(e),e.appendTo(t),t.appendTo(u),l=new ClosingCostCredit(o,h),n===BUYER?rateCalc.closingSheetViewModel.buyerClosingCostList.push(l):n===SELLER&&rateCalc.closingSheetViewModel.sellerClosingCostList.push(l),r=r+1)}),u};rateCalc.GetRecordingTotalAmountString=function(n){var t=0,i=$('div[data-name="'+n+'RecordingFeesWrapper"] input[data-role="'+n+'"]');return i.each(function(n,i){t=t+rateCalc.ConvertStringToNumber($(i).val())}),rateCalc.ConvertNumberToCurrencyString(t)};rateCalc.GetAllRecordingTaxes=function(n,t){var i=0,r=t.CFPBTax instanceof Array?t.CFPBTax:t;return $.each(r,function(t,r){r&&r.TaxType&&(taxTypeNode=r.TaxType.toUpperCase(),(taxTypeNode.startsWith(n)||n===DEED&&(taxTypeNode==="MANSIONTAX"||taxTypeNode==="GRANTORTAX"||taxTypeNode==="GRANTEETAX"||taxTypeNode==="LANDBANKTAX"||taxTypeNode==="SALESDISCLOSUREFORMFEE"||taxTypeNode==="AUDITORTRANSFERFEE"))&&r.TotalTaxAmount&&(i=i+Number(r.TotalTaxAmount)))}),i};rateCalc.GetPremiumCalcTotals=function(){const a=rateCalc.IsSectionEnabled(PREMIUM),s=rateCalc.IsRefinance()||rateCalc.IsConstructionRefiTransaction(),v=rateCalc.IsLeaseholdTransaction(),y=rateCalc.IsConstructionTransaction()||rateCalc.IsConstructionRefiTransaction(),o=!s&&$("#IsSimultaneousIssueYes").is(":checked")?!0:!1,p=$("#OwnerPolicyCoverageType option:selected").val()?!0:!1,w=$("#LenderPolicyCoverageType option:selected").val()||$("#RefiLenderPolicyCoverageType option:selected").val()?!0:!1,e=rateCalc.GetDataForSelectedTransactionType(TRANSACTION_TYPE_KEYS.IS_DISPLAY_SPLITS);let h=0,c=0,l=0,f=2,i=0,r=0,u=0,t=0,n;if(a){if(e&&(o||p)&&(n=$("#txtOwnerPolicyBuyerAmount"),n.val()&&(t=rateCalc.ConvertStringToNumber(n.val()),i=i+t),n=$("#txtOwnerPolicySellerAmount"),n.val()&&(t=rateCalc.ConvertStringToNumber(n.val()),r=r+t),n=$("#spanOwnerPolicyTotal"),n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),u=u+t),n=$("#spanOwnerBuyerTax"),n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),i=i+t),n=$("#spanOwnerSellerTax"),n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),r=r+t),n=$("#spanOwnerTotalTax"),n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),u=u+t)),o||w){for(e&&(n=$("#txtLenderPolicyBuyerAmount"),n.val()&&(t=rateCalc.ConvertStringToNumber(n.val()),i=i+t),n=$("#txtLenderPolicySellerAmount"),n.val()&&(t=rateCalc.ConvertStringToNumber(n.val()),r=r+t)),n=$("#spanLenderPolicyTotal"),n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),u=u+t),n=$("#spanLenderPolicyTotal"+f);n.length>0;)rateCalc.closingSheetViewModel.additionalLoanList()[f-2].isInsured()&&(t=rateCalc.ConvertStringToNumber(n.text()),u=u+t,e&&(t=rateCalc.ConvertStringToNumber($("#txtLenderPolicyBuyerAmount"+f).val()),i=i+t,t=rateCalc.ConvertStringToNumber($("#txtLenderPolicySellerAmount"+f).val()),r=r+t)),f++,n=$("#spanLenderPolicyTotal"+f);s||(n=$("#spanLenderBuyerTax"),n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),i=i+t),n=$("#spanLenderSellerTax"),n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),r=r+t));n=$("#spanLenderTotalTax");n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),u=u+t)}if(v){for(n=$("#txtLeaseholdOwnerPolicyBuyerAmount"),n.val()&&(t=rateCalc.ConvertStringToNumber(n.val()),i=i+t),n=$("#txtLeaseholdOwnerPolicySellerAmount"),n.val()&&(t=rateCalc.ConvertStringToNumber(n.val()),r=r+t),n=$("#spanLeaseholdOwnerPolicyTotal"),n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),u=u+t),n=$("#spanLeaseholdOwnerBuyerTax"),n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),i=i+t),n=$("#spanLeaseholdOwnerSellerTax"),n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),r=r+t),n=$("#spanLeaseholdOwnerTotalTax"),n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),u=u+t),n=$("#txtLeaseholdLenderPolicyBuyerAmount"),n.val()&&(t=rateCalc.ConvertStringToNumber(n.val()),i=i+t),n=$("#txtLeaseholdLenderPolicySellerAmount"),n.val()&&(t=rateCalc.ConvertStringToNumber(n.val()),r=r+t),n=$("#spanLeaseholdLenderPolicyTotal"),n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),u=u+t),f=2,n=$("#spanLeaseholdLenderPolicyTotal"+f);n.length>0;)rateCalc.closingSheetViewModel.additionalLeaseholdLoanList()[f-2].isInsured()&&(t=rateCalc.ConvertStringToNumber(n.text()),u=u+t,t=rateCalc.ConvertStringToNumber($("#txtLeaseholdLenderPolicyBuyerAmount"+f).val()),i=i+t,t=rateCalc.ConvertStringToNumber($("#txtLeaseholdLenderPolicySellerAmount"+f).val()),r=r+t),f++,n=$("#spanLeaseholdLenderPolicyTotal"+f);n=$("#spanLeaseholdLenderBuyerTax");n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),i=i+t);n=$("#spanLeaseholdLenderSellerTax");n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),r=r+t);n=$("#spanLeaseholdLenderTotalTax");n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),u=u+t)}if(y&&(e&&(n=$("#txtConstructionLenderPolicyBuyerAmount"),n.val()&&(t=rateCalc.ConvertStringToNumber(n.val()),i=i+t),n=$("#txtConstructionLenderPolicySellerAmount"),n.val()&&(t=rateCalc.ConvertStringToNumber(n.val()),r=r+t)),n=$("#spanConstructionLenderPolicyTotal"),n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),u=u+t),e&&(n=$("#spanConstructionLenderBuyerTax"),n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),i=i+t),n=$("#spanConstructionLenderSellerTax"),n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),r=r+t)),n=$("#spanConstructionLenderTotalTax"),n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),u=u+t),e&&(n=$("#txtProjectLenderPolicyBuyerAmount"),n.val()&&(t=rateCalc.ConvertStringToNumber(n.val()),i=i+t),n=$("#txtProjectLenderPolicySellerAmount"),n.val()&&(t=rateCalc.ConvertStringToNumber(n.val()),r=r+t)),n=$("#spanProjectLenderPolicyTotal"),n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),u=u+t),e&&(n=$("#spanProjectLenderBuyerTax"),n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),i=i+t),n=$("#spanProjectLenderSellerTax"),n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),r=r+t)),n=$("#spanProjectLenderTotalTax"),n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),u=u+t)),l+=u,h=i,c=r,i=0,r=0,u=0,o){for(n=$("#spanOwnerBuyerTRID"),n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),i=i+t),n=$("#spanOwnerSellerTRID"),n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),r=r+t),n=$("#spanOwnerTotalTRID"),n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),u=u+t),n=$("#spanOwnerBuyerTaxTRID"),n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),i=i+t),n=$("#spanOwnerSellerTaxTRID"),n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),r=r+t),n=$("#spanOwnerTotalTaxTRID"),n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),u=u+t),n=$("#spanLenderBuyerTRID"),n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),i=i+t),n=$("#spanLenderSellerTRID"),n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),r=r+t),n=$("#spanLenderTotalTRID"),n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),u=u+t),f=2,n=$("#spanLenderTotalTRID"+f);n.length>0;)rateCalc.closingSheetViewModel.additionalLoanList()[f-2].isInsured()&&(t=rateCalc.ConvertStringToNumber(n.text()),u=u+t,e&&(t=rateCalc.ConvertStringToNumber($("#spanLenderBuyerTRID"+f).text()),i=i+t,t=rateCalc.ConvertStringToNumber($("#spanLenderSellerTRID"+f).text()),r=r+t)),f++,n=$("#spanLenderTotalTRID"+f);n=$("#spanLenderBuyerTaxTRID");n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),i=i+t);n=$("#spanLenderSellerTaxTRID");n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),r=r+t);n=$("#spanLenderTotalTaxTRID");n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),u=u+t);n=$("#spanConstructionLenderBuyerTRID");n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),i=i+t);n=$("#spanConstructionLenderSellerTRID");n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),r=r+t);n=$("#spanConstructionLenderTotalTRID");n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),u=u+t);n=$("#spanConstructionLenderBuyerTaxTRID");n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),i=i+t);n=$("#spanConstructionLenderSellerTaxTRID");n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),r=r+t);n=$("#spanConstructionLenderTotalTaxTRID");n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),u=u+t);n=$("#spanProjectLenderBuyerTRID");n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),i=i+t);n=$("#spanProjectLenderSellerTRID");n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),r=r+t);n=$("#spanProjectLenderTotalTRID");n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),u=u+t);n=$("#spanProjectLenderBuyerTaxTRID");n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),i=i+t);n=$("#spanProjectLenderSellerTaxTRID");n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),r=r+t);n=$("#spanProjectLenderTotalTaxTRID");n.text()&&(t=rateCalc.ConvertStringToNumber(n.text()),u=u+t)}}return{premiumCalcTotal:l,premiumCalcBuyerTotal:h,premiumCalcSellerTotal:c,tridBuyerTotal:i,tridSellerTotal:r}};rateCalc.GetEndorsements=function(n,t,i,r){const w=rateCalc.IsRefinance()||rateCalc.IsConstructionRefiTransaction();let s=0,h=0,c=0,l=0,e=0,o=0,f=[],u=t.replace("Premium",EMPTY_STRING);const a=u.match(/[A-Z]?[a-z]+|[0-9]+|[A-Z]+(?![a-z])/g).join(" ");switch(t){case OWNER_PREMIUM:rateCalc.updatedEndorsementList.Owner.push([]);f=rateCalc.updatedEndorsementList.Owner[r-1];break;case LENDER_PREMIUM:rateCalc.updatedEndorsementList.Lender.push([]);f=rateCalc.updatedEndorsementList.Lender[r-1];break;case LEASEHOLD_OWNER_PREMIUM:rateCalc.updatedEndorsementList.LeaseholdOwner.push([]);f=rateCalc.updatedEndorsementList.LeaseholdOwner[r-1];break;case LEASEHOLD_LENDER_PREMIUM:rateCalc.updatedEndorsementList.LeaseholdLender.push([]);f=rateCalc.updatedEndorsementList.LeaseholdLender[r-1];break;case CONSTRUCTION_LENDER_PREMIUM:rateCalc.updatedEndorsementList.ConstructionLender.push([]);f=rateCalc.updatedEndorsementList.ConstructionLender[r-1];break;case PROJECT_LENDER_PREMIUM:rateCalc.updatedEndorsementList.ProjectLender.push([]);f=rateCalc.updatedEndorsementList.ProjectLender[r-1]}if(i&&i.length>0){let d=EMPTY_STRING,tt=EMPTY_STRING,g=EMPTY_STRING;if(r>1){d=d+r;switch(t){case LENDER_PREMIUM:rateCalc.closingSheetViewModel.additionalLoanList()[r-2].isInsured()||(g=" hidden-element");break;case LEASEHOLD_LENDER_PREMIUM:rateCalc.closingSheetViewModel.additionalLeaseholdLoanList()[r-2].isInsured()||(g=" hidden-element")}}const nt=jQuery('<table id="'+t.toLowerCase()+d+'-endorsement-result" class="table-results'+g+'" data-policy-feetype="'+t+'" data-policy-number="'+r+'"/>'),it=jQuery("<thead/>");let y=jQuery("<tr/>"),w=jQuery("<th/>");w.attr("colspan","2");r>1&&(tt=rateCalc.GetNumeralPrefix(r)+" ");w.text(tt+a+"'s Endorsements");w.appendTo(y);u=u+d;const b=rateCalc.GetDataForSelectedTransactionType(TRANSACTION_TYPE_KEYS.IS_DISPLAY_SPLITS);b&&(w=jQuery("<th>Buyer Amount<\/th>"),w.appendTo(y),w=jQuery("<th>Seller Amount<\/th>"),w.appendTo(y));w=jQuery("<th>Total<\/th>");w.appendTo(y);y.appendTo(it);it.appendTo(nt);const k=jQuery("<tbody/>");let v,p=0;$.each(i,function(n,t){let w=0,d=0,i=0,a=ZERO_DOLLAR,r;y=jQuery("<tr/>");v=jQuery("<td/>");v.attr("colspan","2");v.text(t.Name);v.appendTo(y);b&&(t.Splits?(v=jQuery("<td/>"),t.Splits.Buyer&&(t.Splits.Buyer.Premium&&(i=Number(t.Splits.Buyer.Premium),(i&&typeof i=="number"||i===0)&&(c+=i,a=rateCalc.GetCurrencyValue(i))),t.Splits.Buyer.SalesTax&&(e=e+Number(t.Splits.Buyer.SalesTax))),w=i,r=jQuery("<input/>"),r.attr({"class":"input-block",id:"txtBuyer"+u+"Endorsement"+p,name:"txtBuyer"+u+"Endorsement"+p,"data-role":BUYER,type:"text",value:a,onchange:"rateCalc.UpdateEndorsement(this)"}),r.appendTo(v),v.appendTo(y),i=0,a=ZERO_DOLLAR,v=jQuery("<td/>"),t.Splits.Seller&&(t.Splits.Seller.Premium&&(i=Number(t.Splits.Seller.Premium),(i&&typeof i=="number"||i===0)&&(l+=i,a=rateCalc.GetCurrencyValue(i))),t.Splits.Seller.SalesTax&&(o=o+Number(t.Splits.Seller.SalesTax))),d=i,r=jQuery("<input/>"),r.attr({"class":"input-block",id:"txtSeller"+u+"Endorsement"+p,name:"txtSeller"+u+"Endorsement"+p,"data-role":SELLER,type:"text",value:a,onchange:"rateCalc.UpdateEndorsement(this)"}),r.appendTo(v),v.appendTo(y)):(v=jQuery("<td/>"),r=jQuery("<input/>"),r.attr({"class":"input-block",id:"txtBuyer"+u+"Endorsement"+p,name:"txtBuyer"+u+"Endorsement"+p,"data-role":BUYER,type:"text",value:ZERO_DOLLAR,onchange:"rateCalc.UpdateEndorsement(this)"}),r.appendTo(v),v.appendTo(y),v=jQuery("<td/>"),r=jQuery("<input/>"),r.attr({"class":"input-block",id:"txtSeller"+u+"Endorsement"+p,name:"txtSeller"+u+"Endorsement"+p,"data-role":SELLER,type:"text",value:ZERO_DOLLAR,onchange:"rateCalc.UpdateEndorsement(this)"}),r.appendTo(v),v.appendTo(y)));a=ZERO_DOLLAR;v=jQuery("<td/>");t.Premium&&(i=Number(t.Premium),i&&typeof i=="number"&&(s+=i,a=rateCalc.GetCurrencyValue(t.Premium)));v.text(a);v.appendTo(y);y.appendTo(k);t.SalesTax&&(h+=Number(t.SalesTax));f.push({Name:t.Name,BuyerAmount:rateCalc.ConvertStringToNumber(w),SellerAmount:rateCalc.ConvertStringToNumber(d),Total:rateCalc.ConvertStringToNumber(t.Premium),BuyerTaxAmount:rateCalc.ConvertStringToNumber(t.Splits.Buyer.SalesTax),SellerTaxAmount:rateCalc.ConvertStringToNumber(t.Splits.Seller.SalesTax),TotalTax:rateCalc.ConvertStringToNumber(t.SalesTax)});p=p+1});y=jQuery("<tr/>");v=jQuery('<td><label class="total">Total for Endorsements (pre-tax)<\/label><\/td>');v.attr("colspan","2");v.appendTo(y);b&&(v=jQuery('<td><span id="spanBuyer'+u+'EndorsementNoTax">'+rateCalc.GetCurrencyValue(c)+"<\/span><\/td>"),v.appendTo(y),v=jQuery('<td><span id="spanSeller'+u+'EndorsementNoTax">'+rateCalc.GetCurrencyValue(l)+"<\/span><\/td>"),v.appendTo(y));v=jQuery('<td><span id="spanTotal'+u+'EndorsementNoTax">'+rateCalc.GetCurrencyValue(s)+"<\/span><\/td>");v.appendTo(y);y.appendTo(k);y=jQuery("<tr/>");v=jQuery('<td><label class="total">Total Tax for Endorsements<\/label><\/td>');v.attr("colspan","2");v.appendTo(y);b&&(v=jQuery('<td><span id="spanBuyer'+u+'EndorsementTax">'+rateCalc.GetCurrencyValue(e)+"<\/span><\/td>"),v.appendTo(y),v=jQuery('<td><span id="spanSeller'+u+'EndorsementTax">'+rateCalc.GetCurrencyValue(o)+"<\/span><\/td>"),v.appendTo(y));v=jQuery('<td><span id="spanTotal'+u+'EndorsementTax">'+rateCalc.GetCurrencyValue(h)+"<\/span><\/td>");v.appendTo(y);y.appendTo(k);y=jQuery("<tr/>");v=jQuery('<td><label class="total">Total for Endorsements (including  tax)<\/label><\/td>');v.attr("colspan","2");v.appendTo(y);b&&(v=jQuery('<td><span id="spanBuyer'+u+'EndorsementWithTax">'+rateCalc.GetCurrencyValue(c+e)+"<\/span><\/td>"),v.appendTo(y),v=jQuery('<td><span id="spanSeller'+u+'EndorsementWithTax">'+rateCalc.GetCurrencyValue(l+o)+"<\/span><\/td>"),v.appendTo(y));v=jQuery('<td><span id="spanTotal'+u+'EndorsementWithTax">'+rateCalc.GetCurrencyValue(s+h)+"<\/span><\/td>");v.appendTo(y);y.appendTo(k);k.appendTo(nt);nt.appendTo(n)}const v=c+e,y=l+o,p=s+h;return{endorsementsTotalIncludingTax:p,buyerTotalIncludingTax:v,sellerTotalIncludingTax:y}};rateCalc.UpdateEndorsement=function(n){const a=$(n),u=a.closest("tr"),w=u.closest("table"),b=w.attr("data-policy-feetype"),k=b.replace("Premium",EMPTY_STRING),r=w.attr("data-policy-number"),d=u.children("td:last"),p=rateCalc.quoteType===QUOTE_TYPE_BUYER?SELLER:BUYER;let v=u.children("td:first").html(),f=rateCalc.ConvertStringToNumber(d.html()),c=ZERO_DOLLAR,l=ZERO_DOLLAR,e=rateCalc.ConvertStringToNumber(n.value);e=e<=f?e:f;let y=rateCalc.GetCurrencyValue(e);if(a.attr("data-role")===BUYER){c=y;l=rateCalc.GetCurrencyValue(f-e);const n=u.find('input[data-role="'+SELLER+'"]');n.val(l);$("#"+p+n.attr("name")).val(l)}else{l=y;c=rateCalc.GetCurrencyValue(f-e);const n=u.find('input[data-role="'+BUYER+'"]');n.val(c);$("#"+p+n.attr("name")).val(c)}a.val(y);$("#"+p+a.attr("name")).val(y);rateCalc.UpdateTotalEndorsement(r>1?k+r:k,u.parent());let i=2,o=rateCalc.premiumCalcTotals.premiumCalcBuyerTotal,s=rateCalc.premiumCalcTotals.premiumCalcSellerTotal;while($("#spanBuyerLender"+i+"EndorsementWithTax").length>0)rateCalc.closingSheetViewModel.additionalLoanList()[i-2].isInsured()&&(o+=rateCalc.ConvertStringToNumber($("#spanBuyerLender"+i+"EndorsementWithTax").text()),s+=rateCalc.ConvertStringToNumber($("#spanSellerLender"+i+"EndorsementWithTax").text())),i++;for(i=2;$("#spanBuyerLeaseholdLender"+i+"EndorsementWithTax").length>0;)rateCalc.closingSheetViewModel.additionalLeaseholdLoanList()[i-2].isInsured()&&(o+=rateCalc.ConvertStringToNumber($("#spanBuyerLeaseholdLender"+i+"EndorsementWithTax").text()),s+=rateCalc.ConvertStringToNumber($("#spanSellerLeaseholdLender"+i+"EndorsementWithTax").text())),i++;o+=rateCalc.ConvertStringToNumber($("#spanBuyerOwnerEndorsementWithTax").text())+rateCalc.ConvertStringToNumber($("#spanBuyerLenderEndorsementWithTax").text());s+=rateCalc.ConvertStringToNumber($("#spanSellerOwnerEndorsementWithTax").text())+rateCalc.ConvertStringToNumber($("#spanSellerLenderEndorsementWithTax").text());rateCalc.IsLeaseholdTransaction()&&(o+=rateCalc.ConvertStringToNumber($("#spanBuyerLeaseholdOwnerEndorsementWithTax").text())+rateCalc.ConvertStringToNumber($("#spanBuyerLeaseholdLenderEndorsementWithTax").text()),s+=rateCalc.ConvertStringToNumber($("#spanSellerLeaseholdOwnerEndorsementWithTax").text())+rateCalc.ConvertStringToNumber($("#spanSellerLeaseholdLenderEndorsementWithTax").text()));rateCalc.IsConstructionTransaction()&&(o+=rateCalc.ConvertStringToNumber($("#spanBuyerConstructionLenderEndorsementWithTax").text())+rateCalc.ConvertStringToNumber($("#spanBuyerProjectLenderEndorsementWithTax").text()),s+=rateCalc.ConvertStringToNumber($("#spanSellerConstructionLenderEndorsementWithTax").text())+rateCalc.ConvertStringToNumber($("#spanSellerProjectLenderEndorsementWithTax").text()));$("#spanBuyerTotalPremEndors").text(rateCalc.GetCurrencyValue(o));$("#spanSellerTotalPremEndors").text(rateCalc.GetCurrencyValue(s));let t;switch(b){case OWNER_PREMIUM:t=rateCalc.updatedEndorsementList.Owner[r-1];break;case LENDER_PREMIUM:t=rateCalc.updatedEndorsementList.Lender[r-1];break;case LEASEHOLD_OWNER_PREMIUM:t=rateCalc.updatedEndorsementList.LeaseholdOwner[r-1];break;case LEASEHOLD_LENDER_PREMIUM:t=rateCalc.updatedEndorsementList.LeaseholdLender[r-1];break;case CONSTRUCTION_LENDER_PREMIUM:t=rateCalc.updatedEndorsementList.ConstructionLender[r-1];break;case PROJECT_LENDER_PREMIUM:t=rateCalc.updatedEndorsementList.ProjectLender[r-1]}v.indexOf("&amp;")!==-1&&(v=v.replace(/&amp;/g,"&"));const h=rateCalc.GetIndexOfUpdatedItemInList(v,t);if(h>-1){const n=rateCalc.ConvertStringToNumber(c),u=f===0?0:Math.round(n*100/f),i=rateCalc.ConvertStringToNumber(t[h].TotalTax),r=Number((i*u/100).toFixed(2));t[h].BuyerAmount=n;t[h].SellerAmount=rateCalc.ConvertStringToNumber(l);t[h].BuyerTaxAmount=r;t[h].SellerTaxAmount=i-r}};rateCalc.UpdateTotalEndorsement=function(n,t){var r=rateCalc.GetTotalItemizedEndorsements(BUYER,t),f=rateCalc.ConvertStringToNumber($("#spanTotal"+n+"EndorsementNoTax").text()),u,i,e;$("#spanBuyer"+n+"EndorsementNoTax").text(rateCalc.GetCurrencyValue(r));$("#spanSeller"+n+"EndorsementNoTax").text(rateCalc.GetCurrencyValue(f-r));u=rateCalc.ConvertStringToNumber($("#spanTotal"+n+"EndorsementTax").text());i=u*r/f;isNaN(i)||($("#spanBuyer"+n+"EndorsementTax").text(rateCalc.GetCurrencyValue(i)),$("#spanSeller"+n+"EndorsementTax").text(rateCalc.GetCurrencyValue(u-i)));e=rateCalc.ConvertStringToNumber($("#spanTotal"+n+"EndorsementWithTax").text());isNaN(i)||($("#spanBuyer"+n+"EndorsementWithTax").text(rateCalc.GetCurrencyValue(r+i)),$("#spanSeller"+n+"EndorsementWithTax").text(rateCalc.GetCurrencyValue(e-(r+i))))};rateCalc.GetTotalItemizedEndorsements=function(n,t){var r=t.find('input[data-role="'+n+'"]'),i=0;return r.each(function(n,t){var r=$(t);i+=rateCalc.ConvertStringToNumber(r.val())}),i};rateCalc.GetNumeralPrefix=function(n){var t=""+n;if(n/10==1)t+="th ";else{n=n%10;switch(n){case 1:t+="st ";break;case 2:t+="nd ";break;case 3:t+="rd ";break;default:t+="th "}}return t};rateCalc.GetAnArray=function(n){let t=[];return Array.isArray(n)?t=n:t.push(n),t};rateCalc.LoadNetSheetRecordingFeesAndTransferTaxes=function(n,t){var s,f,e,u,i,l,a,p;rateCalc.updatedRecordingFeesList=[];s=$('div[data-name="'+t+'RecordingFeesWrapper"]');s.children().remove();const v=rateCalc.GetDataForSelectedTransactionType(TRANSACTION_TYPE_KEYS.IS_DISPLAY_SPLITS);if(n){const it=rateCalc.propertyState===STATE_ABBRV_NY,tt=jQuery('<table class="table-results"/>'),rt=jQuery("<thead/>"),nt=jQuery('<tr><th colspan="2"/><\/tr>');let d=0,g,ut=v||it&&!rateCalc.IsAbleToModifyRecordingFeeSection;ut&&(g=jQuery("<th>Buyer Amount<\/th>"),g.appendTo(nt));v&&(g=jQuery("<th>Seller Amount<\/th>"),g.appendTo(nt));it&&!rateCalc.IsAbleToModifyRecordingFeeSection&&(g=jQuery("<th>Lender Amount<\/th>"),g.appendTo(nt));g=jQuery("<th>Total<\/th>");g.appendTo(nt);nt.appendTo(rt);rt.appendTo(tt);f=jQuery("<tbody/>");let t=rateCalc.GetAnArray(n.Recording);for(let n=0;n<t.length;n++){i={buyer:0,seller:0,lender:0,total:0};switch(t[n].RecordingType){case RECORDING_LENDER_OWNER:e=EMPTY_STRING}u=e+MORTGAGE_RECORDING_FEE;let v=t[n].Mortgage;var r=v.Fee?Number(v.Fee):0,h=v.BuyerSplitFee?Number(v.BuyerSplitFee):0,y=v.SellerSplitFee?Number(v.SellerSplitFee):0,c=v.LenderSplitFee?Number(v.LenderSplitFee):0;r>0&&(i.buyer=h,i.seller=y,i.lender=c,i.total=r,rateCalc.UpdateFeeRow(rateCalc.AddRecordingFeeToTable(f,u,i,d,FEE)),d=d+1);u=e+REVERSE_MORTGAGE_FEE;var r=t[n].ReverseMortgage.Fee?Number(t[n].ReverseMortgage.Fee):0,h=t[n].ReverseMortgage.BuyerSplitFee?Number(t[n].ReverseMortgage.BuyerSplitFee):0,c=t[n].ReverseMortgage.LenderSplitFee?Number(t[n].ReverseMortgage.LenderSplitFee):0;if(r>0&&(i.buyer=h,i.lender=c,i.total=r,rateCalc.UpdateFeeRow(rateCalc.AddRecordingFeeToTable(f,u,i,d,FEE)),d=d+1),r=t[n].Deed.Fee?Number(t[n].Deed.Fee):0,r>0){u=e+DEED_RECORDING_FEE;var o=t[n].Deed,h=o.BuyerSplitFee?Number(o.BuyerSplitFee):0,y=o.SellerSplitFee?Number(o.SellerSplitFee):0,c=o.LenderSplitFee?Number(o.LenderSplitFee):0;i.buyer=h;i.seller=y;i.lender=c;i.total=r;rateCalc.UpdateFeeRow(rateCalc.AddRecordingFeeToTable(f,u,i,d,FEE));d=d+1}if(r=t[n].Release.Fee?Number(t[n].Release.Fee):0,r>0){u=e+RELEASE_RECORDING_FEE;let o=t[n].Release;var w=o.BuyerSplitFee?Number(o.BuyerSplitFee):0,b=o.SellerSplitFee?Number(o.SellerSplitFee):0,k=o.LenderSplitFee?Number(o.LenderSplitFee):0;i.buyer=w;i.lender=k;i.seller=b;i.total=r;rateCalc.UpdateFeeRow(rateCalc.AddRecordingFeeToTable(f,u,i,d,FEE));d=d+1}let g=t[n].CFPB2015.CFPBTax instanceof Array?t[n].CFPB2015.CFPBTax:t[n].CFPB2015;l=!1;r=t[n].Mortgage.ConservationFund?Number(t[n].Mortgage.ConservationFund):0;r>0&&(u=e+"Mortgage Conservation Fund Fee",i=rateCalc.GetUpdatedAmountsSplitFromCFBPTax(g,"MortgageConservationFund"),i.total=r,rateCalc.UpdateFeeRow(rateCalc.AddRecordingFeeToTable(f,u,i,d,FEE)),d=d+1,l=!0);a=!1;r=t[n].Deed.ConservationFund?Number(t[n].Deed.ConservationFund):0;r>0&&(u=e+"Deed Conservation Fund Fee",i=rateCalc.GetUpdatedAmountsSplitFromCFBPTax(g,"DeedConservationFund"),i.total=r,rateCalc.UpdateFeeRow(rateCalc.AddRecordingFeeToTable(f,u,i,d,FEE)),d=d+1,a=!0);p=t[n].CFPB2015.CFPBTax instanceof Array?t[n].CFPB2015.CFPBTax:t[n].CFPB2015;$.each(p,function(n,t){if(t&&t.TaxType){taxTypeNode=t.TaxType;var o="",r="";taxTypeNode==DEED_TAX||taxTypeNode==MORTGAGE_TAX?(r=taxTypeNode.split(/(?=[A-Z])/)[0],o=r+"TT"):(r=taxTypeNode.split(/(?=[A-Z])/)[0],taxTypeNode.includes("Recordation")&&(o="Rec"));const n=taxTypeNode.includes(INTANGIBLE);$.each(t.TaxingEntities.TaxingEntity,function(n,t){l&&taxTypeNode==="MortgageConservationFund"||a&&taxTypeNode==="DeedConservationFund"||(u=e+taxTypeNode.replace(/([A-Z])/g," $1").trim()+" - "+t.TaxingEntityJurisdiction,i.buyer=t.BuyerSplit?Number(t.BuyerSplit):0,i.seller=t.SellerSplit?Number(t.SellerSplit):0,i.lender=t.LenderSplit?Number(t.LenderSplit):0,i.total=t.TaxAmount?Number(t.TaxAmount):0,rateCalc.AddRecordingFeeToTable(f,u,i,d,TAX),d=d+1)})}});f.appendTo(tt);tt.appendTo(s)}}$("#spanBuyerRecordingFeesTotal").text(rateCalc.GetRecordingTotalAmountString(BUYER));$("#spanSellerRecordingFeesTotal").text(rateCalc.GetRecordingTotalAmountString(SELLER));rateCalc.closingSheetViewModel.netsheetTotalDummyObservable.notifySubscribers()};rateCalc.CalculatePremiumAndEndorsementTotal=function(n){let f=rateCalc.IsSectionEnabled(ENDORSEMENTS),e=rateCalc.IsRefinance(),o=rateCalc.IsLeaseholdTransaction(),s=rateCalc.IsConstructionTransaction(),t=2,r=0,u=0,i=0;if(e){for(i=rateCalc.ConvertStringToNumber($("#spanLenderPolicyTotal").text());$("#spanLenderPolicyTotal"+t).length>0;)rateCalc.closingSheetViewModel.additionalLoanList()[t-2].isInsured()&&(i+=rateCalc.ConvertStringToNumber($("#spanLenderPolicyTotal"+t).text())),t++;if(rateCalc.propertyState===STATE_ABBRV_MO&&(i+=rateCalc.ConvertStringToNumber($("#spanLenderTotalTax").text())),f)for(i+=rateCalc.ConvertStringToNumber($("#spanTotalLenderEndorsementNoTax").text()),t=2;$("#spanTotalLender"+t+"EndorsementNoTax").length>0;)rateCalc.closingSheetViewModel.additionalLoanList()[t-2].isInsured()&&(i+=rateCalc.ConvertStringToNumber($("#spanTotalLender"+t+"EndorsementNoTax").text())),t++;r=i}else{for(r=rateCalc.ConvertStringToNumber($("#txtOwnerPolicyBuyerAmount").val())+rateCalc.ConvertStringToNumber($("#txtLenderPolicyBuyerAmount").val()),u=rateCalc.ConvertStringToNumber($("#txtOwnerPolicySellerAmount").val())+rateCalc.ConvertStringToNumber($("#txtLenderPolicySellerAmount").val()),i=rateCalc.ConvertStringToNumber($("#spanOwnerPolicyTotal").text())+rateCalc.ConvertStringToNumber($("#spanLenderPolicyTotal").text()),t=2;$("#spanLenderPolicyTotal"+t).length>0;)rateCalc.closingSheetViewModel.additionalLoanList()[t-2].isInsured()&&(r+=rateCalc.ConvertStringToNumber($("#txtLenderPolicyBuyerAmount"+t).val()),u+=rateCalc.ConvertStringToNumber($("#txtLenderPolicySellerAmount"+t).val()),i+=rateCalc.ConvertStringToNumber($("#spanLenderPolicyTotal"+t).text())),t++;if(o)for(r+=rateCalc.ConvertStringToNumber($("#txtLeaseholdOwnerPolicyBuyerAmount").val())+rateCalc.ConvertStringToNumber($("#txtLeaseholdLenderPolicyBuyerAmount").val()),u+=rateCalc.ConvertStringToNumber($("#txtLeaseholdOwnerPolicySellerAmount").val())+rateCalc.ConvertStringToNumber($("#txtLeaseholdLenderPolicySellerAmount").val()),i+=rateCalc.ConvertStringToNumber($("#spanLeaseholdOwnerPolicyTotal").text())+rateCalc.ConvertStringToNumber($("#spanLeaseholdLenderPolicyTotal").text()),t=2;$("#spanLeaseholdLenderPolicyTotal"+t).length>0;)rateCalc.closingSheetViewModel.additionalLeaseholdLoanList()[t-2].isInsured()&&(r+=rateCalc.ConvertStringToNumber($("#txtLeaseholdLenderPolicyBuyerAmount"+t).val()),u+=rateCalc.ConvertStringToNumber($("#txtLeaseholdLenderPolicySellerAmount"+t).val()),i+=rateCalc.ConvertStringToNumber($("#spanLeaseholdLenderPolicyTotal"+t).text())),t++;if(s&&(r+=rateCalc.ConvertStringToNumber($("#txtConstructionLenderPolicyBuyerAmount").val())+rateCalc.ConvertStringToNumber($("#txtProjectLenderPolicyBuyerAmount").val()),u+=rateCalc.ConvertStringToNumber($("#txtConstructionLenderPolicySellerAmount").val())+rateCalc.ConvertStringToNumber($("#txtProjectLenderPolicySellerAmount").val()),i+=rateCalc.ConvertStringToNumber($("#spanConstructionLenderPolicyTotal").text())+rateCalc.ConvertStringToNumber($("#spanProjectLenderPolicyTotal").text())),rateCalc.propertyState===STATE_ABBRV_MO&&(r+=rateCalc.ConvertStringToNumber($("#spanOwnerBuyerTax").text())+rateCalc.ConvertStringToNumber($("#spanLenderBuyerTax").text()),u+=rateCalc.ConvertStringToNumber($("#spanOwnerSellerTax").text())+rateCalc.ConvertStringToNumber($("#spanLenderSellerTax").text()),i+=rateCalc.ConvertStringToNumber($("#spanOwnerTotalTax").text())+rateCalc.ConvertStringToNumber($("#spanLenderTotalTax").text())),f){for(r+=rateCalc.ConvertStringToNumber($("#spanBuyerLenderEndorsementNoTax").text())+rateCalc.ConvertStringToNumber($("#spanBuyerOwnerEndorsementNoTax").text()),u+=rateCalc.ConvertStringToNumber($("#spanSellerLenderEndorsementNoTax").text())+rateCalc.ConvertStringToNumber($("#spanSellerOwnerEndorsementNoTax").text()),i+=rateCalc.ConvertStringToNumber($("#spanTotalOwnerEndorsementNoTax").text())+rateCalc.ConvertStringToNumber($("#spanTotalLenderEndorsementNoTax").text()),t=2;$("#spanTotalLender"+t+"EndorsementNoTax").length>0;)rateCalc.closingSheetViewModel.additionalLoanList()[t-2].isInsured()&&(r+=rateCalc.ConvertStringToNumber($("#spanBuyerLender"+t+"EndorsementNoTax").text()),u+=rateCalc.ConvertStringToNumber($("#spanSellerLender"+t+"EndorsementNoTax").text()),i+=rateCalc.ConvertStringToNumber($("#spanTotalLender"+t+"EndorsementNoTax").text())),t++;if(o)for(r+=rateCalc.ConvertStringToNumber($("#spanBuyerLeaseholdLenderEndorsementNoTax").text())+rateCalc.ConvertStringToNumber($("#spanBuyerLeaseholdOwnerEndorsementNoTax").text()),u+=rateCalc.ConvertStringToNumber($("#spanSellerLeaseholdLenderEndorsementNoTax").text())+rateCalc.ConvertStringToNumber($("#spanSellerLeaseholdOwnerEndorsementNoTax").text()),i+=rateCalc.ConvertStringToNumber($("#spanTotalLeaseholdOwnerEndorsementNoTax").text())+rateCalc.ConvertStringToNumber($("#spanTotalLeaseholdLenderEndorsementNoTax").text()),t=2;$("#spanTotalLeaseholdLender"+t+"EndorsementNoTax").length>0;)rateCalc.closingSheetViewModel.additionalLeaseholdLoanList()[t-2].isInsured()&&(r+=rateCalc.ConvertStringToNumber($("#spanBuyerLeaseholdLender"+t+"EndorsementNoTax").text()),u+=rateCalc.ConvertStringToNumber($("#spanSellerLeaseholdLender"+t+"EndorsementNoTax").text()),i+=rateCalc.ConvertStringToNumber($("#spanTotalLeaseholdLender"+t+"EndorsementNoTax").text())),t++;s&&(r+=rateCalc.ConvertStringToNumber($("#spanBuyerConstructionLenderEndorsementNoTax").text())+rateCalc.ConvertStringToNumber($("#spanBuyerProjectLenderEndorsementNoTax").text()),u+=rateCalc.ConvertStringToNumber($("#spanSellerConstructionLenderEndorsementNoTax").text())+rateCalc.ConvertStringToNumber($("#spanSellerProjectLenderEndorsementNoTax").text()),i+=rateCalc.ConvertStringToNumber($("#spanTotalConstructionLenderEndorsementNoTax").text())+rateCalc.ConvertStringToNumber($("#spanTotalProjectLenderEndorsementNoTax").text()))}}n.TotalBuyerPremiumAndEndorsementPreTax=r;n.TotalSellerPremiumAndEndorsementPreTax=u;n.TotalPremiumAndEndorsementPreTax=i;let h=0,c=0,l=0,a=0,v=0;rateCalc.propertyState!==STATE_ABBRV_MO&&(h=rateCalc.ConvertStringToNumber($("#spanOwnerBuyerTax").text()),c=rateCalc.ConvertStringToNumber($("#spanLenderBuyerTax").text()),l=rateCalc.ConvertStringToNumber($("#spanLenderTotalTax").text()),a=rateCalc.ConvertStringToNumber($("#spanOwnerSellerTax").text()),v=rateCalc.ConvertStringToNumber($("#spanLenderSellerTax").text()));let w=f?rateCalc.ConvertStringToNumber($("#spanTotalLenderEndorsementTax").text()):0,b=f?rateCalc.ConvertStringToNumber($("#spanBuyerLenderEndorsementTax").text()):0,k=f?rateCalc.ConvertStringToNumber($("#spanSellerLenderEndorsementTax").text()):0,d=f?rateCalc.ConvertStringToNumber($("#spanBuyerOwnerEndorsementTax").text()):0,g=f?rateCalc.ConvertStringToNumber($("#spanSellerOwnerEndorsementTax").text()):0,y=e?l+w:b+d+c+h,p=k+g+v+a;n.TotalBuyerPremiumAndEndorsementTax=y;n.TotalSellerPremiumAndEndorsementTax=p;n.TotalPremiumAndEndorsementTax=y+p;f?(n.TotalBuyerPremiumAndEndorsement=$("#spanBuyerTotalPremEndors").text()===""?rateCalc.ConvertStringToNumber(rateCalc.premiumCalcTotals.premiumCalcBuyerTotal):rateCalc.ConvertStringToNumber($("#spanBuyerTotalPremEndors").text()),n.TotalSellerPremiumAndEndorsement=$("#spanSellerTotalPremEndors").text()===""?rateCalc.ConvertStringToNumber(rateCalc.premiumCalcTotals.premiumCalcSellerTotal):rateCalc.ConvertStringToNumber($("#spanSellerTotalPremEndors").text()),n.TotalPremiumAndEndorsement=$("#spanTotalPremEndors").text()===""?rateCalc.ConvertStringToNumber(rateCalc.premiumCalcTotals.premiumCalcTotal):rateCalc.ConvertStringToNumber($("#spanTotalPremEndors").text())):(n.TotalBuyerPremiumAndEndorsement=rateCalc.ConvertStringToNumber(rateCalc.premiumCalcTotals.premiumCalcBuyerTotal),n.TotalSellerPremiumAndEndorsement=rateCalc.ConvertStringToNumber(rateCalc.premiumCalcTotals.premiumCalcSellerTotal),n.TotalPremiumAndEndorsement=rateCalc.ConvertStringToNumber(rateCalc.premiumCalcTotals.premiumCalcTotal))};rateCalc.GetTEFEDocument=function(){var ir,ni,rr,ur;let t=rateCalc.IsSectionEnabled(ENDORSEMENTS);const n=rateCalc.GetDataForSelectedTransactionType(TRANSACTION_TYPE_KEYS.IS_DISPLAY_SPLITS);let ti="";stateSettings.StateSettingList.State.AllowCommercial==="true"&&(ti=$propertyTypeDropdown.find("option:selected").text());premiumAndEndorsementTotal={TotalBuyerPremiumAndEndorsementPreTax:0,TotalSellerPremiumAndEndorsementPreTax:0,TotalPremiumAndEndorsementPreTax:0,TotalBuyerPremiumAndEndorsementTax:0,TotalSellerPremiumAndEndorsementTax:0,TotalPremiumAndEndorsementTax:0,TotalBuyerPremiumAndEndorsement:0,TotalSellerPremiumAndEndorsement:0,TotalPremiumAndEndorsement:0};rateCalc.CalculatePremiumAndEndorsementTotal(premiumAndEndorsementTotal);additionalTSFTotal={TotalBuyer:0,TotalSeller:0};recordingTotal={TotalBuyerRecordingFeesTransferTaxes:0,TotalSellerRecordingFeesTransferTaxes:0,TotalLenderRecordingFeesTransferTaxes:0,TotalRecordingFeesTransferTaxes:0};var et=rateCalc.GetTransactionTypeGroup($("#TransactionType").val()),f=rateCalc.ConvertStringToNumber($("#txtOwnerPolicyBuyerAmount").val()),e=rateCalc.ConvertStringToNumber($("#spanOwnerBuyerTax").text()),l=rateCalc.ConvertStringToNumber($("#spanOwnerTotalTRID").text()),a=rateCalc.ConvertStringToNumber($("#spanOwnerBuyerTRID").text()),ii=rateCalc.ConvertStringToNumber($("#spanOwnerSellerTRID").text()),ot=rateCalc.ConvertStringToNumber($("#spanOwnerTotalTaxTRID").text()),st=rateCalc.ConvertStringToNumber($("#spanOwnerBuyerTaxTRID").text()),ri=rateCalc.ConvertStringToNumber($("#spanOwnerSellerTaxTRID").text()),v=rateCalc.ConvertStringToNumber($("#spanOwnerPolicyTotal").text()),y=rateCalc.ConvertStringToNumber($("#spanOwnerTotalTax").text()),p=rateCalc.ConvertStringToNumber($("#spanBuyerOwnerEndorsementWithTax").text()),w=rateCalc.ConvertStringToNumber($("#spanTotalOwnerEndorsementWithTax").text()),o=rateCalc.ConvertStringToNumber($("#txtLenderPolicyBuyerAmount").val()),s=rateCalc.ConvertStringToNumber($("#spanLenderBuyerTax").text()),b=rateCalc.ConvertStringToNumber($("#spanLenderTotalTax").text()),k=rateCalc.ConvertStringToNumber($("#spanLenderTotalTRID").text()),d=rateCalc.ConvertStringToNumber($("#spanLenderBuyerTRID").text()),ui=rateCalc.ConvertStringToNumber($("#spanLenderSellerTRID").text()),ht=rateCalc.ConvertStringToNumber($("#spanLenderTotalTaxTRID").text()),ct=rateCalc.ConvertStringToNumber($("#spanLenderBuyerTaxTRID").text()),fi=rateCalc.ConvertStringToNumber($("#spanLenderSellerTaxTRID").text()),g=rateCalc.ConvertStringToNumber($("#spanBuyerLenderEndorsementWithTax").text()),nt=rateCalc.ConvertStringToNumber($("#spanTotalLenderEndorsementWithTax").text()),tt=rateCalc.ConvertStringToNumber($("#spanLenderPolicyTotal").text()),ei=rateCalc.ConvertStringToNumber($("#txtLeaseholdOwnerPolicyBuyerAmount").val()),oi=rateCalc.ConvertStringToNumber($("#spanLeaseholdOwnerBuyerTax").text()),fr=rateCalc.ConvertStringToNumber($("#spanBuyerLeaseholdOwnerEndorsementWithTax").text()),er=rateCalc.ConvertStringToNumber($("#spanTotalLeaseholdOwnerEndorsementWithTax").text()),or=rateCalc.ConvertStringToNumber($("#spanLeaseholdOwnerPolicyTotal").text()),sr=rateCalc.ConvertStringToNumber($("#spanLeaseholdOwnerTotalTax").text()),si=rateCalc.ConvertStringToNumber($("#txtLeaseholdLenderPolicyBuyerAmount").val()),hi=rateCalc.ConvertStringToNumber($("#spanLeaseholdLenderBuyerTax").text()),hr=rateCalc.ConvertStringToNumber($("#spanLeaseholdLenderPolicyTotal").text()),cr=rateCalc.ConvertStringToNumber($("#spanLeaseholdLenderTotalTax").text()),lr=rateCalc.ConvertStringToNumber($("#spanBuyerLeaseholdLenderEndorsementWithTax").text()),ar=rateCalc.ConvertStringToNumber($("#spanTotalLeaseholdLenderEndorsementWithTax").text()),h=rateCalc.ConvertStringToNumber($("#buyerspanBuyerTSFwTax").text()),c=rateCalc.ConvertStringToNumber($("#buyerspanTotalTSFwTax").text()),lt=rateCalc.ConvertStringToNumber($("#txtConstructionLenderPolicyBuyerAmount").val()),vr=rateCalc.ConvertStringToNumber($("#txtConstructionLenderPolicySellerAmount").val()),at=rateCalc.ConvertStringToNumber($("#spanConstructionLenderPolicyTotal").text()),yr=rateCalc.ConvertStringToNumber($("#spanConstructionLenderBuyerTax").text()),pr=rateCalc.ConvertStringToNumber($("#spanConstructionLenderSellerTax").text()),wr=rateCalc.ConvertStringToNumber($("#spanConstructionLenderTotalTax").text()),it=rateCalc.ConvertStringToNumber($("#spanConstructionLenderBuyerTRID").text()),vt=rateCalc.ConvertStringToNumber($("#spanConstructionLenderSellerTRID").text()),ci=rateCalc.ConvertStringToNumber($("#spanConstructionLenderTotalTRID").text()),yt=rateCalc.ConvertStringToNumber($("#spanConstructionLenderBuyerTaxTRID").text()),pt=rateCalc.ConvertStringToNumber($("#spanConstructionLenderSellerTaxTRID").text()),br=rateCalc.ConvertStringToNumber($("#spanConstructionLenderTotalTaxTRID").text()),li=rateCalc.ConvertStringToNumber($("#spanBuyerConstructionLenderEndorsementWithTax").text()),ai=rateCalc.ConvertStringToNumber($("#spanTotalConstructionLenderEndorsementWithTax").text()),wt=rateCalc.ConvertStringToNumber($("#txtProjectLenderPolicyBuyerAmount").val()),kr=rateCalc.ConvertStringToNumber($("#txtProjectLenderPolicySellerAmount").val()),bt=rateCalc.ConvertStringToNumber($("#spanProjectLenderPolicyTotal").text()),dr=rateCalc.ConvertStringToNumber($("#spanProjectLenderBuyerTax").text()),gr=rateCalc.ConvertStringToNumber($("#spanProjectLenderSellerTax").text()),nu=rateCalc.ConvertStringToNumber($("#spanProjectLenderTotalTax").text()),rt=rateCalc.ConvertStringToNumber($("#spanProjectLenderBuyerTRID").text()),kt=rateCalc.ConvertStringToNumber($("#spanProjectLenderSellerTRID").text()),vi=rateCalc.ConvertStringToNumber($("#spanProjectLenderTotalTRID").text()),dt=rateCalc.ConvertStringToNumber($("#spanProjectLenderBuyerTaxTRID").text()),gt=rateCalc.ConvertStringToNumber($("#spanProjectLenderSellerTaxTRID").text()),tu=rateCalc.ConvertStringToNumber($("#spanProjectLenderTotalTaxTRID").text()),yi=rateCalc.ConvertStringToNumber($("#spanBuyerProjectLenderEndorsementWithTax").text()),pi=rateCalc.ConvertStringToNumber($("#spanTotalProjectLenderEndorsementWithTax").text()),iu=l+k+ot+ht+ci+br+vi+tu;documentType=$("#ddlDocumentType option:selected ").val();let ru=t?rateCalc.ConvertStringToNumber($("#spanTotalLenderEndorsementTax").text()):0,uu=t?rateCalc.ConvertStringToNumber($("#spanBuyerLenderEndorsementTax").text()):0,fu=t?rateCalc.ConvertStringToNumber($("#spanSellerLenderEndorsementTax").text()):0,eu=t?rateCalc.ConvertStringToNumber($("#spanTotalOwnerEndorsementTax").text()):0,ou=t?rateCalc.ConvertStringToNumber($("#spanBuyerOwnerEndorsementTax").text()):0,su=t?rateCalc.ConvertStringToNumber($("#spanSellerOwnerEndorsementTax").text()):0,hu=t?rateCalc.ConvertStringToNumber($("#spanTotalLeaseholdLenderEndorsementTax").text()):0,cu=t?rateCalc.ConvertStringToNumber($("#spanBuyerLeaseholdLenderEndorsementTax").text()):0,lu=t?rateCalc.ConvertStringToNumber($("#spanSellerLeaseholdLenderEndorsementTax").text()):0,au=t?rateCalc.ConvertStringToNumber($("#spanTotalLeaseholdOwnerEndorsementTax").text()):0,vu=t?rateCalc.ConvertStringToNumber($("#spanBuyerLeaseholdOwnerEndorsementTax").text()):0,yu=t?rateCalc.ConvertStringToNumber($("#spanSellerLeaseholdOwnerEndorsementTax").text()):0,pu=t?rateCalc.ConvertStringToNumber("0"):0,wu=t?rateCalc.ConvertStringToNumber("0"):0,bu=t?rateCalc.ConvertStringToNumber("0"):0,ku=t?rateCalc.ConvertStringToNumber("0"):0,du=t?rateCalc.ConvertStringToNumber("0"):0,gu=t?rateCalc.ConvertStringToNumber("0"):0;var i=0,u=0,r=0,wi=0,bi=0,ki=0,di=0,gi=0,nr=0,tr=0,nf=rateCalc.GetTefeTitleServiceFees(additionalTSFTotal),tf=rateCalc.GetTefeRecordingFeeList(recordingTotal);switch(et){case SALE:i=(n?d+ct+h:k+ht+c)+additionalTSFTotal.TotalBuyer;t&&(i+=n?g:nt);for(let r=0;r<rateCalc.closingSheetViewModel.additionalLoanList().length;r++)rateCalc.closingSheetViewModel.additionalLoanList()[r].isInsured()&&(t&&(i+=n?rateCalc.GetTextElementNumber($("#spanBuyerLender"+(r+2)+"EndorsementWithTax")):rateCalc.GetTextElementNumber($("#spanTotalLender"+(r+2)+"EndorsementWithTax"))),i+=n?rateCalc.GetTextElementNumber($("#spanLenderBuyerTRID"+(r+2))):rateCalc.GetTextElementNumber($("#spanLenderTotalTRID"+(r+2))),wi+=rateCalc.GetTextElementNumber($("#spanLenderBuyerTRID"+(r+2))),bi+=rateCalc.GetTextElementNumber($("#spanLenderSellerTRID"+(r+2))),ki+=rateCalc.GetTextElementNumber($("#spanLenderTotalTRID"+(r+2))));if(u=n?recordingTotal.TotalBuyerRecordingFeesTransferTaxes:recordingTotal.TotalRecordingFeesTransferTaxes,$("#IsSimultaneousIssueNo").is(":checked")){i+=n?o+s:tt;for(let t=0;t<rateCalc.closingSheetViewModel.additionalLoanList().length;t++)rateCalc.closingSheetViewModel.additionalLoanList()[t].isInsured()&&(i+=n?rateCalc.GetValueElementNumber($("#txtLenderPolicyBuyerAmount"+(t+2))):rateCalc.GetTextElementNumber($("#spanLenderPolicyTotal"+(t+2))));r=n?f+e:v+y}else r=n?a+st:l+ot;t&&(r+=n?p:w);break;case REFI:i=(n?o+s+h:tt+b+c)+additionalTSFTotal.TotalBuyer;t&&(i+=n?g:nt);for(let r=0;r<rateCalc.closingSheetViewModel.additionalLoanList().length;r++)rateCalc.closingSheetViewModel.additionalLoanList()[r].isInsured()&&(t&&(i+=n?rateCalc.GetTextElementNumber($("#spanBuyerLender"+(r+2)+"EndorsementWithTax")):rateCalc.GetTextElementNumber($("#spanTotalLender"+(r+2)+"EndorsementWithTax"))),i+=n?rateCalc.GetValueElementNumber($("#txtLenderPolicyBuyerAmount"+(r+2))):rateCalc.GetTextElementNumber($("#spanLenderPolicyTotal"+(r+2))));u=n?recordingTotal.TotalBuyerRecordingFeesTransferTaxes:recordingTotal.TotalRecordingFeesTransferTaxes;break;case CASH:i=(n?h:c)+additionalTSFTotal.TotalBuyer;u=n?recordingTotal.TotalBuyerRecordingFeesTransferTaxes:recordingTotal.TotalRecordingFeesTransferTaxes;r=n?f+e:v+y;t&&(r+=n?p:w);break;case LEASEHOLD:i=(n?o+s+si+hi+h:tt+b+hr+cr+c)+additionalTSFTotal.TotalBuyer;t&&(i+=n?g+lr:nt+ar);for(let r=0;r<rateCalc.closingSheetViewModel.additionalLoanList().length;r++)rateCalc.closingSheetViewModel.additionalLoanList()[r].isInsured()&&(t&&(i+=n?rateCalc.GetTextElementNumber($("#spanBuyerLender"+(r+2)+"EndorsementWithTax")):rateCalc.GetTextElementNumber($("#spanTotalLender"+(r+2)+"EndorsementWithTax"))),i+=n?rateCalc.GetValueElementNumber($("#txtLenderPolicyBuyerAmount"+(r+2))):rateCalc.GetTextElementNumber($("#spanLenderPolicyTotal"+(r+2))));for(let r=0;r<rateCalc.closingSheetViewModel.additionalLeaseholdLoanList().length;r++)rateCalc.closingSheetViewModel.additionalLeaseholdLoanList()[r].isInsured()&&(t&&(i+=n?rateCalc.GetTextElementNumber($("#spanBuyerLeaseholdLender"+(r+2)+"EndorsementWithTax")):rateCalc.GetTextElementNumber($("#spanTotalLeaseholdLender"+(r+2)+"EndorsementWithTax"))),i+=n?rateCalc.GetValueElementNumber($("#txtLeaseholdLenderPolicyBuyerAmount"+(r+2))):rateCalc.GetTextElementNumber($("#spanLeaseholdLenderPolicyTotal"+(r+2))));u=n?recordingTotal.TotalBuyerRecordingFeesTransferTaxes:recordingTotal.TotalRecordingFeesTransferTaxes;r=n?f+e+ei+oi:v+y+or+sr;t&&(r+=n?p+fr:w+er);break;case CONSTRUCTION:i=(n?h+o+lt+wt:c+tt+at+bt)+additionalTSFTotal.TotalBuyer;t&&(i+=n?g+li+yi:nt+ai+pi);u=n?recordingTotal.TotalBuyerRecordingFeesTransferTaxes:recordingTotal.TotalRecordingFeesTransferTaxes;r=n?f+e:v+y;t&&(r+=n?p:w);break;case CONSTRUCTIONREFI:i=(n?lt+wt:at+bt)+additionalTSFTotal.TotalBuyer;t&&(i+=n?li+yi:ai+pi);u=n?recordingTotal.TotalBuyerRecordingFeesTransferTaxes:recordingTotal.TotalRecordingFeesTransferTaxes}let ut=rateCalc.GetPoliciesByType(rateCalc.quoteResult.QuoteResponse.Pricing.RateManual.Policies,OWNER_PREMIUM);di=ut&&ut.FullPremium;gi=ut&&ut.PremiumDiscount*-1;let ft=rateCalc.GetPoliciesByType(rateCalc.quoteResult.QuoteResponse.Pricing.RateManual.Policies,et===CONSTRUCTIONREFI?CONSTRUCTION_LENDER_PREMIUM:LENDER_PREMIUM);nr=ft&&ft.FullPremium;tr=ft&&ft.PremiumDiscount*-1;ir={TitleEscrowFeeEstimate:{ReferenceId:rateCalc.quoteRequestRoot.QuoteRequest.TransactionInformation.StewartReferenceNumber,ClientReferenceId:encodeURIComponent(rateCalc.quoteRequestRoot.QuoteRequest.TransactionInformation.ClientReferenceNumber),TransactionTypeCode:et,TransactionTypeDescription:$("#TransactionType option:selected").text(),SalesPrice:rateCalc.ConvertStringToNumber($("#txtPurchasePrice").val()),LoanAmount:rateCalc.ConvertStringToNumber($("#LoanAmount").val()),LeaseholdAmount:rateCalc.ConvertStringToNumber($("#txtLeaseholdAmount").val()),LeaseholdLoanAmount:rateCalc.ConvertStringToNumber($("#LeaseholdLoanAmount").val()),ConstructionLoanAmount:rateCalc.ConvertStringToNumber($("#txtConstructionLoanAmount").val()),ProjectLoanAmount:rateCalc.ConvertStringToNumber($("#txtProjectLoanAmount").val()),ShowAdditionalMortgages:(rateCalc.closingSheetViewModel.additionalLoanList().length>0).toString(),AdditionalLoanAmounts:rateCalc.GetAdditionalLoanAmounts(rateCalc.closingSheetViewModel.additionalLoanList(),"Loan Amount"),ShowAdditionalLeaseholdMortgages:(rateCalc.closingSheetViewModel.additionalLeaseholdLoanList().length>0).toString(),AdditionalLeaseholdLoanAmounts:rateCalc.GetAdditionalLoanAmounts(rateCalc.closingSheetViewModel.additionalLeaseholdLoanList(),"Leasehold Loan Amount"),DisplaySplits:n.toString(),ShowTitleInsurancePremium:rateCalc.IsSectionEnabled(PREMIUM).toString(),TitleInsurancePremium:{RateManual:{IsSimultaneous:$("#IsSimultaneousIssueYes").is(":checked").toString(),OwnersPolicyType:$("#OwnerPolicyCoverageType").val()===EMPTY_STRING?EMPTY_STRING:$("#OwnerPolicyCoverageType option:selected").text(),OwnersBuyerAmount:f,OwnersTitleServiceChargeBuyerAmount:rateCalc.propertyState===STATE_ABBRV_MO?e:0,OwnersSellerAmount:rateCalc.ConvertStringToNumber($("#txtOwnerPolicySellerAmount").val()),OwnersTitleServiceChargeSellerAmount:rateCalc.propertyState===STATE_ABBRV_MO?rateCalc.ConvertStringToNumber($("#spanOwnerSellerTax").text()):0,OwnersTotalPremium:rateCalc.ConvertStringToNumber($("#spanOwnerPolicyTotal").text()),OwnersTitleServiceChargeTotalAmount:rateCalc.propertyState===STATE_ABBRV_MO?rateCalc.ConvertStringToNumber($("#spanOwnerTotalTax").text()):0,OwnersBuyerTax:e,OwnersSellerTax:rateCalc.ConvertStringToNumber($("#spanOwnerSellerTax").text()),OwnersTotalTax:rateCalc.ConvertStringToNumber($("#spanOwnerTotalTax").text()),ShowPriorOwnersPolicy:rateCalc.ShowPriorOwnersPolicy().toString(),PriorOwnersPolicyType:$("#ReissueOwnerPolicyCode").val()===EMPTY_STRING?EMPTY_STRING:$("#ReissueOwnerPolicyCode option:selected").text(),PriorOwnersPolicyAmount:rateCalc.ConvertStringToNumber($("#ReissueOwnerAmount").val()),PriorOwnersPolicyYears:$("#ReissueOwnerNumberOfYears").val()===null?0:$("#ReissueOwnerNumberOfYears").val(),OwnerPolicyUndiscountedPremium:rateCalc.ConvertStringToNumber(di),OwnerPolicyDiscountCreditAmount:rateCalc.ConvertStringToNumber(gi),LeaseholdOwnersPolicyType:$("#LeaseholdOwnerPolicyCoverageType").val()===EMPTY_STRING?EMPTY_STRING:$("#LeaseholdOwnerPolicyCoverageType option:selected").text(),LeaseholdOwnersBuyerAmount:ei,LeaseholdOwnersTitleServiceChargeBuyerAmount:0,LeaseholdOwnersSellerAmount:rateCalc.ConvertStringToNumber($("#txtLeaseholdOwnerPolicySellerAmount").val()),LeaseholdOwnersTitleServiceChargeSellerAmount:0,LeaseholdOwnersTotalPremium:rateCalc.ConvertStringToNumber($("#spanLeaseholdOwnerPolicyTotal").text()),LeaseholdOwnersTitleServiceChargeTotalAmount:0,LeaseholdOwnersBuyerTax:oi,LeaseholdOwnersSellerTax:rateCalc.ConvertStringToNumber($("#spanLeaseholdOwnerSellerTax").text()),LeaseholdOwnersTotalTax:rateCalc.ConvertStringToNumber($("#spanLeaseholdOwnerTotalTax").text()),ShowPriorLeaseholdOwnersPolicy:!1,PriorLeaseholdOwnersPolicyType:EMPTY_STRING,PriorLeaseholdOwnersPolicyAmount:0,PriorLeaseholdOwnersPolicyYears:EMPTY_STRING,LendersPolicyType:rateCalc.GetLenderPCTDescription(),LendersBuyerAmount:o,LendersTitleServiceChargeBuyerAmount:rateCalc.propertyState===STATE_ABBRV_MO?s:0,LendersSellerAmount:rateCalc.ConvertStringToNumber($("#txtLenderPolicySellerAmount").val()),LendersTitleServiceChargeSellerAmount:rateCalc.propertyState===STATE_ABBRV_MO?rateCalc.ConvertStringToNumber($("#spanLenderSellerTax").text()):0,LendersTotalPremium:rateCalc.ConvertStringToNumber($("#spanLenderPolicyTotal").text()),LendersTitleServiceChargeTotalAmount:rateCalc.propertyState===STATE_ABBRV_MO?b:0,LendersBuyerTax:s,LendersSellerTax:rateCalc.ConvertStringToNumber($("#spanLenderSellerTax").text()),LendersTotalTax:rateCalc.propertyState!==STATE_ABBRV_MO?b:0,ShowPriorLoanPolicy:rateCalc.ShowPriorLoanPolicy().toString(),PriorLoanPolicyType:$("#ReissueLenderPolicyCode").val()===EMPTY_STRING?EMPTY_STRING:$("#ReissueLenderPolicyCode option:selected").text(),PriorLoanPolicyAmount:rateCalc.ConvertStringToNumber($("#ReissueLenderAmount").val()),PriorLoanPolicyYears:$("#ReissueLoanNumberOfYears").val()===null?0:$("#ReissueLoanNumberOfYears").val(),LenderPolicyUndiscountedPremium:rateCalc.ConvertStringToNumber(nr),LenderPolicyDiscountCreditAmount:rateCalc.ConvertStringToNumber(tr),LeaseholdLendersPolicyType:$("#LeaseholdLenderPolicyCoverageType").val()===EMPTY_STRING?EMPTY_STRING:$("#LeaseholdLenderPolicyCoverageType option:selected").text(),LeaseholdLendersBuyerAmount:si,LeaseholdLendersTitleServiceChargeBuyerAmount:0,LeaseholdLendersSellerAmount:rateCalc.ConvertStringToNumber($("#txtLeaseholdLenderPolicySellerAmount").val()),LeaseholdLendersTitleServiceChargeSellerAmount:0,LeaseholdLendersTotalPremium:rateCalc.ConvertStringToNumber($("#spanLeaseholdLenderPolicyTotal").text()),LeaseholdLendersTitleServiceChargeTotalAmount:0,LeaseholdLendersBuyerTax:hi,LeaseholdLendersSellerTax:rateCalc.ConvertStringToNumber($("#spanLeaseholdLenderSellerTax").text()),LeaseholdLendersTotalTax:rateCalc.ConvertStringToNumber($("#spanLeaseholdLenderTotalTax").text()),ShowPriorLeaseholdLendersPolicy:!1,PriorLeaseholdLendersPolicyType:EMPTY_STRING,PriorLeaseholdLendersPolicyAmount:0,PriorLeaseholdLendersPolicyYears:EMPTY_STRING,ConstructionLendersPolicyType:$("#ConstructionLenderPolicyCoverageType").val()===EMPTY_STRING?EMPTY_STRING:$("#ConstructionLenderPolicyCoverageType option:selected").text(),ConstructionLendersBuyerAmount:lt,ConstructionLendersSellerAmount:vr,ConstructionLendersTotalPremium:at,PriorConstructionLendersPolicyType:EMPTY_STRING,PriorConstructionLendersPolicyAmount:0,PriorConstructionLendersPolicyYears:0,ShowPriorConstructionLendersPolicy:!1,ConstructionLendersTitleServiceChargeBuyerAmount:rateCalc.propertyState===STATE_ABBRV_MO?yr:0,ConstructionLendersTitleServiceChargeSellerAmount:rateCalc.propertyState===STATE_ABBRV_MO?pr:0,ConstructionLendersTitleServiceChargeTotalAmount:rateCalc.propertyState===STATE_ABBRV_MO?wr:0,ConstructionLendersBuyerTax:0,ConstructionLendersSellerTax:0,ConstructionLendersTotalTax:0,ProjectLendersPolicyType:$("#ProjectLenderPolicyCoverageType").val()===EMPTY_STRING?EMPTY_STRING:$("#ProjectLenderPolicyCoverageType option:selected").text(),ProjectLendersBuyerAmount:wt,ProjectLendersSellerAmount:kr,ProjectLendersTotalPremium:bt,PriorProjectLendersPolicyType:EMPTY_STRING,PriorProjectLendersPolicyAmount:0,PriorProjectLendersPolicyYears:0,ShowPriorProjectLendersPolicy:!1,ProjectLendersTitleServiceChargeBuyerAmount:rateCalc.propertyState===STATE_ABBRV_MO?dr:0,ProjectLendersTitleServiceChargeSellerAmount:rateCalc.propertyState===STATE_ABBRV_MO?gr:0,ProjectLendersTitleServiceChargeTotalAmount:rateCalc.propertyState===STATE_ABBRV_MO?nu:0,ProjectLendersBuyerTax:0,ProjectLendersSellerTax:0,ProjectLendersTotalTax:0},AdditionalRateManualLenderPremiums:rateCalc.GetAdditionalRateManualLenderPremiums(rateCalc.closingSheetViewModel.additionalLoanList(),"Lender’s Title Insurance Premium",EMPTY_STRING),AdditionalRateManualLeaseholdLenderPremiums:rateCalc.GetAdditionalRateManualLenderPremiums(rateCalc.closingSheetViewModel.additionalLeaseholdLoanList(),"Leasehold Lender’s Title Insurance Premium","Leasehold"),ShowTRID:(l>0||k>0||ci>0||vi>0).toString(),TRID:{TRIDOwnersBuyerAmount:a,TRIDOwnersSellerAmount:ii,TRIDOwnersTotalPremium:l,TRIDOwnersBuyerTax:st,TRIDOwnersSellerTax:ri,TRIDOwnersTotalTax:ot,TRIDLendersBuyerAmount:d,TRIDLendersSellerAmount:ui,TRIDLendersTotalPremium:k,TRIDLendersBuyerTax:ct,TRIDLendersSellerTax:fi,TRIDLendersTotalTax:ht,TRIDConstructionLendersBuyerAmount:it,TRIDConstructionLendersSellerAmount:vt,TRIDConstructionLendersTotalPremium:it+vt,TRIDConstructionLendersBuyerTax:yt,TRIDConstructionLendersSellerTax:pt,TRIDConstructionLendersTotalTax:yt+pt,TRIDProjectLendersBuyerAmount:rt,TRIDProjectLendersSellerAmount:kt,TRIDProjectLendersTotalPremium:rt+kt,TRIDProjectLendersBuyerTax:dt,TRIDProjectLendersSellerTax:gt,TRIDProjectLendersTotalTax:dt+gt,TRIDBuyerTotal:a+st+d+ct+wi+it+yt+rt+dt,TRIDSellerTotal:ii+ri+ui+fi+bi+vt+pt+kt+gt,TRIDTotal:iu+ki,TRIDAdjustment:rateCalc.propertyState!==STATE_ABBRV_MO?Math.abs(rateCalc.premiumCalcTotals.premiumCalcBuyerTotal-rateCalc.premiumCalcTotals.tridBuyerTotal):Math.abs(f+o-(a+d+it+rt))},AdditionalTRID:rateCalc.GetAdditionalTRID()},ShowEndorsement:rateCalc.IsSectionEnabled(ENDORSEMENTS).toString(),EndorsementsOtherProducts:{OwnersEndorsementList:rateCalc.GetTefeEndorsements(rateCalc.updatedEndorsementList.Owner.length>0?rateCalc.updatedEndorsementList.Owner[0]:[],EMPTY_STRING),LendersEndorsementList:rateCalc.GetTefeEndorsements(rateCalc.updatedEndorsementList.Lender.length>0?rateCalc.updatedEndorsementList.Lender[0]:[],EMPTY_STRING),LeaseholdOwnersEndorsementList:rateCalc.GetTefeEndorsements(rateCalc.updatedEndorsementList.LeaseholdOwner.length>0?rateCalc.updatedEndorsementList.LeaseholdOwner[0]:[],EMPTY_STRING),LeaseholdLendersEndorsementList:rateCalc.GetTefeEndorsements(rateCalc.updatedEndorsementList.LeaseholdLender.length>0?rateCalc.updatedEndorsementList.LeaseholdLender[0]:[],EMPTY_STRING),AdditionalLendersEndorsementList:rateCalc.GetAdditionalEndorsements(rateCalc.closingSheetViewModel.additionalLoanList(),rateCalc.updatedEndorsementList.Lender,"Lender's ",EMPTY_STRING),AdditionalLeaseholdLendersEndorsementList:rateCalc.GetAdditionalEndorsements(rateCalc.closingSheetViewModel.additionalLeaseholdLoanList(),rateCalc.updatedEndorsementList.LeaseholdLender,"Leasehold Lender's ","Leasehold"),ConstructionLendersEndorsementList:rateCalc.GetTefeEndorsements(rateCalc.updatedEndorsementList.ConstructionLender.length>0?rateCalc.updatedEndorsementList.ConstructionLender[0]:[],EMPTY_STRING),ProjectLendersEndorsementList:rateCalc.GetTefeEndorsements(rateCalc.updatedEndorsementList.ProjectLender.length>0?rateCalc.updatedEndorsementList.ProjectLender[0]:[],EMPTY_STRING),LendersBuyerEndorsementTax:uu,LendersSellerEndorsementTax:fu,LendersTotalEndorsementTax:ru,OwnersBuyerEndorsementTax:ou,OwnersSellerrEndorsementTax:su,OwnersTotalEndorsementTax:eu,LeaseholdLendersBuyerEndorsementTax:cu,LeaseholdLendersSellerEndorsementTax:lu,LeaseholdLendersTotalEndorsementTax:hu,LeaseholdOwnersBuyerEndorsementTax:vu,LeaseholdOwnersSellerrEndorsementTax:yu,LeaseholdOwnersTotalEndorsementTax:au,ConstructionLendersBuyerEndorsementTax:wu,ConstructionLendersSellerrEndorsementTax:bu,ConstructionLendersTotalEndorsementTax:pu,ProjectLendersBuyerEndorsementTax:du,ProjectLendersSellerEndorsementTax:gu,ProjectLendersTotalEndorsementTax:ku,TotalBuyerPremiumAndEndorsementPreTax:premiumAndEndorsementTotal.TotalBuyerPremiumAndEndorsementPreTax,TotalSellerPremiumAndEndorsementPreTax:premiumAndEndorsementTotal.TotalSellerPremiumAndEndorsementPreTax,TotalPremiumAndEndorsementPreTax:premiumAndEndorsementTotal.TotalPremiumAndEndorsementPreTax,TotalBuyerPremiumAndEndorsementTax:premiumAndEndorsementTotal.TotalBuyerPremiumAndEndorsementTax,TotalSellerPremiumAndEndorsementTax:premiumAndEndorsementTotal.TotalSellerPremiumAndEndorsementTax,TotalPremiumAndEndorsementTax:premiumAndEndorsementTotal.TotalPremiumAndEndorsementTax,TotalBuyerPremiumAndEndorsement:premiumAndEndorsementTotal.TotalBuyerPremiumAndEndorsement,TotalSellerPremiumAndEndorsement:premiumAndEndorsementTotal.TotalSellerPremiumAndEndorsement,TotalPremiumAndEndorsement:premiumAndEndorsementTotal.TotalPremiumAndEndorsement},ShowTitleServiceFee:rateCalc.IsSectionEnabled(OFFICE).toString(),TitleServiceFees:{TitleServiceFeeList:nf,TotalBuyerTax:rateCalc.ConvertStringToNumber($("#buyerspanBuyerTSF_Tax").text()),TotalSellerTax:rateCalc.ConvertStringToNumber($("#buyerspanSellerTSF_Tax").text()),TotalTax:rateCalc.ConvertStringToNumber($("#buyerspanTotalTSF_Tax").text()),TotalBuyerAmountPreTax:rateCalc.ConvertStringToNumber($("#buyerspanBuyerTSFnoTax").text())+additionalTSFTotal.TotalBuyer,TotalSellerAmountPreTax:rateCalc.ConvertStringToNumber($("#buyerspanSellerTSFnoTax").text())+additionalTSFTotal.TotalSeller,TotalAmountPreTax:rateCalc.ConvertStringToNumber($("#buyerspanTotalTSFnoTax").text())+additionalTSFTotal.TotalBuyer+additionalTSFTotal.TotalSeller,TotalBuyerAmountIncludeTax:rateCalc.ConvertStringToNumber($("#buyerspanBuyerTSFwTax").text())+additionalTSFTotal.TotalBuyer,TotalSellerAmountIncludeTax:rateCalc.ConvertStringToNumber($("#buyerspanSellerTSFwTax").text())+additionalTSFTotal.TotalSeller,TotalAmountIncludeTax:rateCalc.ConvertStringToNumber($("#buyerspanTotalTSFwTax").text())+additionalTSFTotal.TotalBuyer+additionalTSFTotal.TotalSeller},ShowRecordingFeesTransferTaxes:rateCalc.IsSectionEnabled(FEES).toString(),RecordingFeesTransferTaxes:{RecordingFeesTransferTaxesList:tf,TotalBuyerRecordingFeesTransferTaxes:recordingTotal.TotalBuyerRecordingFeesTransferTaxes,TotalSellerRecordingFeesTransferTaxes:recordingTotal.TotalSellerRecordingFeesTransferTaxes,TotalLenderRecordingFeesTransferTaxes:recordingTotal.TotalLenderRecordingFeesTransferTaxes,TotalRecordingFeesTransferTaxes:recordingTotal.TotalRecordingFeesTransferTaxes},PreparedInformation:{Logo:rateCalc.logoSource,BorrowerName:rateCalc.EscapeSpecialCharacters($("#txtBorrowerName").val()),PropertyStreetAddress:rateCalc.EscapeSpecialCharacters($("#txtPropertyStreetAddress").val()),ByName:rateCalc.EscapeSpecialCharacters($("#txtPreparedByName").val()),ByCompany:rateCalc.EscapeSpecialCharacters($("#txtPreparedByCompany").val()),ByAddress:rateCalc.EscapeSpecialCharacters($("#txtPreparedByAddress").val()),ByCsz:rateCalc.EscapeSpecialCharacters($("#txtPreparedByCityStateZip").val()),ByEmail:rateCalc.EscapeSpecialCharacters($("#txtPreparedByEmail").val()),ByPhone:rateCalc.EscapeSpecialCharacters($("#txtPreparedByPhone").val()),ForName:rateCalc.EscapeSpecialCharacters($("#txtPreparedForName").val()),ForCompany:rateCalc.EscapeSpecialCharacters($("#txtPreparedForCompany").val()),ForEmail:rateCalc.EscapeSpecialCharacters($("#txtPreparedForEmail").val()),ForNote:rateCalc.EscapeSpecialCharacters($("#txtPreparedForNote").val().replace(/[\n\r]+/g,"")),CloseDate:$("#buyerProjectedClosingDate").val(),FooterInformation:$("#paraDisclaimerNote").val(),CreatedByApp:"Stewart Rate Calculator"},PropertyInformation:{PropertyState:rateCalc.propertyState,PropertyCity:rateCalc.propertyCity,PropertyCounty:rateCalc.propertyCountyName,PropertyZipCode:rateCalc.propertyZipCode,StateNotes:$("#taStateNotes").val(),PropertyType:ti},SettlementOffice:{OfficeName:rateCalc.selectedProvider?rateCalc.EscapeSpecialCharacters(rateCalc.ConvertEntitiesToSymbols(rateCalc.selectedProvider.Name)):EMPTY_STRING,OfficeAddress:rateCalc.selectedProvider?rateCalc.selectedProvider.Address:EMPTY_STRING,OfficeState:rateCalc.selectedProvider?rateCalc.selectedProvider.StateCode:EMPTY_STRING,OfficeCity:rateCalc.selectedProvider?rateCalc.selectedProvider.City:EMPTY_STRING,OfficeZipCode:rateCalc.selectedProvider?rateCalc.selectedProvider.ZipCode:EMPTY_STRING,OfficeContactName:rateCalc.selectedProvider?rateCalc.selectedProvider.Contact:EMPTY_STRING,OfficeEmail:rateCalc.selectedProvider?rateCalc.selectedProvider.ContactEmail:EMPTY_STRING,OfficePhone:rateCalc.selectedProvider?"(P)"+rateCalc.selectedProvider.Phone:EMPTY_STRING,OfficeFax:rateCalc.selectedProvider?"(F)"+rateCalc.selectedProvider.Fax:EMPTY_STRING,ProviderNotes:rateCalc.GetProviderNotes(rateCalc.quoteResult.QuoteResponse.Provider)},Totals:{SectionBorCTotal:i,SectionETotal:u,SectionHTotal:r,GrandTotal:i+u+r}}};ni="";isSaveDocumentPDF&&(ni=encodeURIComponent(rateCalc.quoteRequestRoot.QuoteRequest.TransactionInformation.ClientReferenceNumber));rr=rateCalc.isValidRequestforAutoPDF;ur=rateCalc.quoteRequestRoot.QuoteRequest.TransactionInformation.StewartReferenceNumber;sendAjaxRequest(POST,"/api/pricing/document?clientrefid="+ni+"&type="+rateCalc.quoteType+"&referenceId="+ur+"&isItemized=true&documentType="+documentType,"="+JSON.stringify(ir),function(n){rr||(rateCalc.DisplayPdf(n.PDF),$('div[data-name="loadingPdf"]').hide())},DisplayError)};rateCalc.ShowPriorOwnersPolicy=function(){var n=!1;return($("#ReissueOwnerPolicyCode").val()||rateCalc.ConvertStringToNumber($("#ReissueOwnerAmount").val())>0||$("#ReissueOwnerNumberOfYears").val())&&(n=!0),n};rateCalc.ShowPriorLoanPolicy=function(){var n=!1;return($("#ReissueLenderPolicyCode").val()||rateCalc.ConvertStringToNumber($("#ReissueLenderAmount").val())>0||$("#ReissueLoanNumberOfYears").val())&&(n=!0),n};rateCalc.UpdateQuoteResponse=function(){var y,c,nt,v,e,u,f,d,t,r,s;const h=rateCalc.GetTransactionTypeGroup($("#TransactionType").val()),rt=rateCalc.IsSectionEnabled(PREMIUM).toString(),ut=rateCalc.IsSectionEnabled(ENDORSEMENTS).toString(),ot=rateCalc.IsSectionEnabled(OFFICE).toString(),ft=rateCalc.IsSectionEnabled(FEES).toString();let i=sellerAmount=buyerAmountCity=sellerAmountCity=buyerAmountCounty=sellerAmountCounty=cfpbTax_totalBuyerSplit=cfpbTax_totalSellerSplit=0,n=JSON.parse(JSON.stringify(rateCalc.quoteResult)),l=rateCalc.GetPoliciesByType(n.QuoteResponse.Pricing.RateManual.Policies,OWNER_PREMIUM),o=rateCalc.GetPoliciesByType(n.QuoteResponse.Pricing.RateManual.Policies,LENDER_PREMIUM);if(rt==="false"&&(DeleteObjectNodes(n.QuoteResponse.Pricing.RateManual.LenderPolicy),DeleteObjectNodes(n.QuoteResponse.Pricing.RateManual.OwnerPolicy),DeleteObjectNodes(n.QuoteResponse.Pricing.RateManual.AdditionalLenderPolicyList),DeleteObjectNodes(n.QuoteResponse.Pricing.RateManual.Policies),DeleteObjectNodes(n.QuoteResponse.Pricing.TRID.TRIDLenderPolicy),DeleteObjectNodes(n.QuoteResponse.Pricing.TRID.TRIDOwnerPolicy),DeleteObjectNodes(n.QuoteResponse.Pricing.TRID.TRIDAdditionalLenderPolicyList),DeleteObjectNodes(n.QuoteResponse.Pricing.TRID.PolicyList),DeleteObjectNodes(n.QuoteResponse.Pricing.TRID.TitleAdjustments)),ut==="false"){if(DeleteObjectNodes(n.QuoteResponse.Pricing.LenderEndorsementList),DeleteObjectNodes(n.QuoteResponse.Pricing.OwnerEndorsementList),y=n.QuoteResponse.Pricing.RateManual.AdditionalLenderPolicyList.LenderPolicy,Array.isArray(y)&&y.length>0)for(let t=0;t<y.length;t++)DeleteObjectNodes(n.QuoteResponse.Pricing.RateManual.AdditionalLenderPolicyList.LenderPolicy[t].EndorsementList);if(c=n.QuoteResponse.Pricing.RateManual.Policies.Policy,Array.isArray(c)&&c.length>0){for(let t=0;t<c.length;t++)if(DeleteObjectNodes(n.QuoteResponse.Pricing.RateManual.Policies.Policy[t].EndorsementList),nt=n.QuoteResponse.Pricing.RateManual.Policies.Policy[t].AdditionalPolicies.Policy,nt!==undefined)for(let i=0;i<nt.length;i++)DeleteObjectNodes(n.QuoteResponse.Pricing.RateManual.Policies.Policy[t].AdditionalPolicies.Policy[i].EndorsementList)}else DeleteObjectNodes(n.QuoteResponse.Pricing.RateManual.Policies.Policy.EndorsementList),DeleteObjectNodes(n.QuoteResponse.Pricing.RateManual.Policies.Policy.AdditionalPolicies.Policy.EndorsementList)}if(ot==="false"&&DeleteObjectNodes(n.QuoteResponse.Pricing.TitleServiceFee),ft==="false"&&(DeleteObjectNodes(n.QuoteResponse.Recording),DeleteObjectNodes(n.QuoteResponse.Recordings),DeleteObjectNodes(n.QuoteResponse.AdditionalRecordingList)),rt==="true"&&h!==REFI){let t=rateCalc.GetPoliciesByType(n.QuoteResponse.Pricing.TRID.PolicyList,OWNER_PREMIUM),r=rateCalc.GetPoliciesByType(n.QuoteResponse.Pricing.TRID.PolicyList,LENDER_PREMIUM);if(l&&(i=rateCalc.ConvertStringToNumber($("#txtOwnerPolicyBuyerAmount").val()).toFixed(2),n.QuoteResponse.Pricing.RateManual.OwnerPolicy.Splits.Buyer.Premium=i,l.Splits.Buyer.Premium=i,sellerAmount=rateCalc.ConvertStringToNumber($("#txtOwnerPolicySellerAmount").val()).toFixed(2),n.QuoteResponse.Pricing.RateManual.OwnerPolicy.Splits.Seller.Premium=sellerAmount,l.Splits.Seller.Premium=sellerAmount,i=rateCalc.ConvertStringToNumber($("#spanOwnerBuyerTRID").text()).toFixed(2),n.QuoteResponse.Pricing.TRID.TRIDOwnerPolicy.Splits.Buyer.Premium=i,sellerAmount=rateCalc.ConvertStringToNumber($("#spanOwnerSellerTRID").text()).toFixed(2),n.QuoteResponse.Pricing.TRID.TRIDOwnerPolicy.Splits.Seller.Premium=sellerAmount,t&&(t.Splits.Buyer.Premium=i,t.Splits.Seller.Premium=sellerAmount),i=rateCalc.ConvertStringToNumber($("#spanOwnerBuyerTax").text()).toFixed(2),n.QuoteResponse.Pricing.RateManual.OwnerPolicy.Splits.Buyer.SalesTax=i,l.Splits.Buyer.SalesTax=i,sellerAmount=rateCalc.ConvertStringToNumber($("#spanOwnerSellerTax").text()).toFixed(2),n.QuoteResponse.Pricing.RateManual.OwnerPolicy.Splits.Seller.SalesTax=sellerAmount,l.Splits.Seller.SalesTax=sellerAmount,i=rateCalc.ConvertStringToNumber($("#spanOwnerBuyerTaxTRID").text()).toFixed(2),n.QuoteResponse.Pricing.TRID.TRIDOwnerPolicy.Splits.Buyer.SalesTax=i,sellerAmount=rateCalc.ConvertStringToNumber($("#spanOwnerSellerTaxTRID").text()).toFixed(2),n.QuoteResponse.Pricing.TRID.TRIDOwnerPolicy.Splits.Seller.SalesTax=sellerAmount,t&&(t.Splits.Seller.SalesTax=sellerAmount,t.Splits.Buyer.SalesTax=i)),h!==CASH&&o){if(i=rateCalc.ConvertStringToNumber($("#txtLenderPolicyBuyerAmount").val()).toFixed(2),n.QuoteResponse.Pricing.RateManual.LenderPolicy.Splits.Buyer.Premium=i,o.Splits.Buyer.Premium=i,sellerAmount=rateCalc.ConvertStringToNumber($("#txtLenderPolicySellerAmount").val()).toFixed(2),n.QuoteResponse.Pricing.RateManual.LenderPolicy.Splits.Seller.Premium=sellerAmount,o.Splits.Seller.Premium=sellerAmount,i=rateCalc.ConvertStringToNumber($("#spanLenderBuyerTRID").text()).toFixed(2),n.QuoteResponse.Pricing.TRID.TRIDLenderPolicy.Splits.Buyer.Premium=i,sellerAmount=rateCalc.ConvertStringToNumber($("#spanLenderSellerTRID").text()).toFixed(2),n.QuoteResponse.Pricing.TRID.TRIDLenderPolicy.Splits.Seller.Premium=sellerAmount,r&&(r.Splits.Buyer.Premium=i,r.Splits.Seller.Premium=sellerAmount),rateCalc.closingSheetViewModel.additionalLoanList().length>0){let t=0;for(let r=0;r<rateCalc.closingSheetViewModel.additionalLoanList().length;r++)t=r+2,$('fieldset[data-name="tbTipPolicy"] table').find('tr[data-name="trLenderPolicy'+t+'"]').length>0&&(i=rateCalc.ConvertStringToNumber($("#txtLenderPolicyBuyerAmount"+t).val()).toFixed(2),n.QuoteResponse.Pricing.RateManual.AdditionalLenderPolicyList.LenderPolicy[r].Splits.Buyer.Premium=i,sellerAmount=rateCalc.ConvertStringToNumber($("#txtLenderPolicySellerAmount"+t).val()).toFixed(2),n.QuoteResponse.Pricing.RateManual.AdditionalLenderPolicyList.LenderPolicy[r].Splits.Seller.Premium=sellerAmount,Array.isArray(o.AdditionalPolicies.Policy)?(o.AdditionalPolicies.Policy[r].Splits.Buyer.Premium=i,o.AdditionalPolicies.Policy[r].Splits.Seller.Premium=sellerAmount):(o.AdditionalPolicies.Policy.Splits.Buyer.Premium=i,o.AdditionalPolicies.Policy.Splits.Seller.Premium=sellerAmount)),$('fieldset[data-name="tbTipPolicy"] table').find('tr[data-name="trLenderTRID'+t+'"]').length>0&&(i=rateCalc.ConvertStringToNumber($("#spanLenderBuyerTRID"+t).text()).toFixed(2),n.QuoteResponse.Pricing.TRID.TRIDAdditionalLenderPolicyList.TRIDLenderPolicy[r].Splits.Buyer.Premium=i,sellerAmount=rateCalc.ConvertStringToNumber($("#spanLenderSellerTRID"+t).text()).toFixed(2),n.QuoteResponse.Pricing.TRID.TRIDAdditionalLenderPolicyList.TRIDLenderPolicy[r].Splits.Seller.Premium=sellerAmount)}i=rateCalc.ConvertStringToNumber($("#spanLenderBuyerTax").text()).toFixed(2);n.QuoteResponse.Pricing.RateManual.LenderPolicy.Splits.Buyer.SalesTax=i;o.Splits.Buyer.SalesTax=i;sellerAmount=rateCalc.ConvertStringToNumber($("#spanLenderSellerTax").text()).toFixed(2);n.QuoteResponse.Pricing.RateManual.LenderPolicy.Splits.Seller.SalesTax=sellerAmount;o.Splits.Seller.SalesTax=sellerAmount;i=rateCalc.ConvertStringToNumber($("#spanLenderBuyerTaxTRID").text()).toFixed(2);n.QuoteResponse.Pricing.TRID.TRIDLenderPolicy.Splits.Buyer.SalesTax=i;sellerAmount=rateCalc.ConvertStringToNumber($("#spanLenderSellerTaxTRID").text()).toFixed(2);n.QuoteResponse.Pricing.TRID.TRIDLenderPolicy.Splits.Seller.SalesTax=sellerAmount;r&&(r.Splits.Buyer.SalesTax=i,r.Splits.Seller.SalesTax=sellerAmount)}if(h===LEASEHOLD){let r=rateCalc.GetPoliciesByType(n.QuoteResponse.Pricing.RateManual.Policies,LEASEHOLD_OWNER_PREMIUM);r&&(i=rateCalc.ConvertStringToNumber($("#txtLeaseholdOwnerPolicyBuyerAmount").val()).toFixed(2),r.Splits.Buyer.Premium=i,sellerAmount=rateCalc.ConvertStringToNumber($("#txtLeaseholdOwnerPolicySellerAmount").val()).toFixed(2),r.Splits.Seller.Premium=sellerAmount,i=rateCalc.ConvertStringToNumber($("#spanLeaseholdOwnerBuyerTax").text()).toFixed(2),r.Splits.Buyer.SalesTax=i,sellerAmount=rateCalc.ConvertStringToNumber($("#spanLeaseholdOwnerSellerTax").text()).toFixed(2),r.Splits.Seller.SalesTax=sellerAmount);let t=rateCalc.GetPoliciesByType(n.QuoteResponse.Pricing.RateManual.Policies,LEASEHOLD_LENDER_PREMIUM);if(t){if(i=rateCalc.ConvertStringToNumber($("#txtLeaseholdLenderPolicyBuyerAmount").val()).toFixed(2),t.Splits.Buyer.Premium=i,sellerAmount=rateCalc.ConvertStringToNumber($("#txtLeaseholdLenderPolicySellerAmount").val()).toFixed(2),t.Splits.Seller.Premium=sellerAmount,rateCalc.closingSheetViewModel.additionalLeaseholdLoanList().length>0){let n=0;for(let r=0;r<rateCalc.closingSheetViewModel.additionalLeaseholdLoanList().length;r++)n=r+2,$('fieldset[data-name="tbTipPolicy"] table').find('tr[data-name="trLeaseholdLenderPolicy'+n+'"]').length>0&&(i=rateCalc.ConvertStringToNumber($("#txtLeaseholdLenderPolicyBuyerAmount"+n).val()).toFixed(2),sellerAmount=rateCalc.ConvertStringToNumber($("#txtLeaseholdLenderPolicySellerAmount"+n).val()).toFixed(2),Array.isArray(t.AdditionalPolicies.Policy)?(t.AdditionalPolicies.Policy[r].Splits.Buyer.Premium=i,t.AdditionalPolicies.Policy[r].Splits.Seller.Premium=sellerAmount):(t.AdditionalPolicies.Policy.Splits.Buyer.Premium=i,t.AdditionalPolicies.Policy.Splits.Seller.Premium=sellerAmount))}i=rateCalc.ConvertStringToNumber($("#spanLeaseholdLenderBuyerTax").text()).toFixed(2);t.Splits.Buyer.SalesTax=i;sellerAmount=rateCalc.ConvertStringToNumber($("#spanLeaseholdLenderSellerTax").text()).toFixed(2);t.Splits.Seller.SalesTax=sellerAmount}}if(h===CONSTRUCTION){let t=rateCalc.GetPoliciesByType(n.QuoteResponse.Pricing.RateManual.Policies,CONSTRUCTION_LENDER_PREMIUM);t&&(i=rateCalc.ConvertStringToNumber($("#txtConstructionLenderPolicyBuyerAmount").val()).toFixed(2),t.Splits.Buyer.Premium=i,sellerAmount=rateCalc.ConvertStringToNumber($("#txtConstructionLenderPolicySellerAmount").val()).toFixed(2),t.Splits.Seller.Premium=sellerAmount);let r=rateCalc.GetPoliciesByType(n.QuoteResponse.Pricing.TRID.PolicyList,CONSTRUCTION_LENDER_PREMIUM);r&&(i=rateCalc.ConvertStringToNumber($("#spanConstructionLenderBuyerTRID").text()).toFixed(2),r.Splits.Buyer.Premium=i,sellerAmount=rateCalc.ConvertStringToNumber($("#spanConstructionLenderSellerTRID").text()).toFixed(2),r.Splits.Seller.Premium=sellerAmount);let u=rateCalc.GetPoliciesByType(n.QuoteResponse.Pricing.RateManual.Policies,PROJECT_LENDER_PREMIUM);u&&(i=rateCalc.ConvertStringToNumber($("#txtProjectLenderPolicyBuyerAmount").val()).toFixed(2),u.Splits.Buyer.Premium=i,sellerAmount=rateCalc.ConvertStringToNumber($("#txtProjectLenderPolicySellerAmount").val()).toFixed(2),u.Splits.Seller.Premium=sellerAmount);let f=rateCalc.GetPoliciesByType(n.QuoteResponse.Pricing.TRID.PolicyList,PROJECT_LENDER_PREMIUM);f&&(i=rateCalc.ConvertStringToNumber($("#spanProjectLenderBuyerTRID").text()).toFixed(2),f.Splits.Buyer.Premium=i,sellerAmount=rateCalc.ConvertStringToNumber($("#spanProjectLenderSellerTRID").text()).toFixed(2),f.Splits.Seller.Premium=sellerAmount)}}if(ut==="true"&&h!==REFI){var p=n.QuoteResponse.Pricing.OwnerEndorsementList.Endorsement,w=n.QuoteResponse.Pricing.LenderEndorsementList.Endorsement,a=n.QuoteResponse.Pricing.RateManual.AdditionalLenderPolicyList.LenderPolicy,c=n.QuoteResponse.Pricing.RateManual.Policies.Policy,tt=rateCalc.updatedEndorsementList.LeaseholdOwner,it=rateCalc.updatedEndorsementList.LeaseholdLender,b=rateCalc.updatedEndorsementList.ConstructionLender,k=rateCalc.updatedEndorsementList.ProjectLender;if(Array.isArray(p)&&p.length>0)for(t=0;t<p.length;t++){const r=rateCalc.updatedEndorsementList.Owner[0].find(function(n){return n.Name===p[t].Name});i=r.BuyerAmount.toFixed(2);sellerAmount=r.SellerAmount.toFixed(2);r!==undefined&&(n.QuoteResponse.Pricing.OwnerEndorsementList.Endorsement[t].Splits.Buyer.Premium=r.BuyerAmount.toFixed(2),n.QuoteResponse.Pricing.OwnerEndorsementList.Endorsement[t].Splits.Seller.Premium=r.SellerAmount.toFixed(2),l.EndorsementList.Endorsement[t].Splits.Buyer.Premium=i,l.EndorsementList.Endorsement[t].Splits.Seller.Premium=sellerAmount)}if(Array.isArray(w)&&w.length>0)for(t=0;t<w.length;t++){const r=rateCalc.updatedEndorsementList.Lender[0].find(function(n){return n.Name===w[t].Name});i=r.BuyerAmount.toFixed(2);sellerAmount=r.SellerAmount.toFixed(2);r!==undefined&&(n.QuoteResponse.Pricing.LenderEndorsementList.Endorsement[t].Splits.Buyer.Premium=r.BuyerAmount.toFixed(2),n.QuoteResponse.Pricing.LenderEndorsementList.Endorsement[t].Splits.Seller.Premium=r.SellerAmount.toFixed(2),o.EndorsementList.Endorsement[t].Splits.Buyer.Premium=i,o.EndorsementList.Endorsement[t].Splits.Seller.Premium=sellerAmount)}if(Array.isArray(a)&&a.length>0)for(t=0;t<a.length;t++)if(v=a[t].EndorsementList.Endorsement,Array.isArray(v)&&v.length>0)for(u=0;u<v.length;u++){const i=rateCalc.updatedEndorsementList.Lender[t+1].find(function(n){return n.Name===v[u].Name});if(i!==undefined)for(n.QuoteResponse.Pricing.RateManual.AdditionalLenderPolicyList.LenderPolicy[t].EndorsementList.Endorsement[u].Splits.Buyer.Premium=i.BuyerAmount.toFixed(2),n.QuoteResponse.Pricing.RateManual.AdditionalLenderPolicyList.LenderPolicy[t].EndorsementList.Endorsement[u].Splits.Seller.Premium=i.SellerAmount.toFixed(2),f=0;f<c.length;f++)c[f].FeeType==="LenderPremium"&&(a.length>1?(n.QuoteResponse.Pricing.RateManual.Policies.Policy[f].AdditionalPolicies.Policy[t].EndorsementList.Endorsement[u].Splits.Buyer.Premium=i.BuyerAmount.toFixed(2),n.QuoteResponse.Pricing.RateManual.Policies.Policy[f].AdditionalPolicies.Policy[t].EndorsementList.Endorsement[u].Splits.Seller.Premium=i.SellerAmount.toFixed(2)):(n.QuoteResponse.Pricing.RateManual.Policies.Policy[f].AdditionalPolicies.Policy.EndorsementList.Endorsement[u].Splits.Buyer.Premium=i.BuyerAmount.toFixed(2),n.QuoteResponse.Pricing.RateManual.Policies.Policy[f].AdditionalPolicies.Policy.EndorsementList.Endorsement[u].Splits.Seller.Premium=i.SellerAmount.toFixed(2)))}if(Array.isArray(tt)&&tt.length>0)for(t=0;t<tt.length;t++)for(e=rateCalc.updatedEndorsementList.LeaseholdOwner[t],u=0;u<e.length;u++)if(e!==undefined)for(f=0;f<c.length;f++)c[f].FeeType==="LeaseholdOwnerPremium"&&(n.QuoteResponse.Pricing.RateManual.Policies.Policy[f].EndorsementList.Endorsement[u].Splits.Buyer.Premium=e[u].BuyerAmount.toFixed(2),n.QuoteResponse.Pricing.RateManual.Policies.Policy[f].EndorsementList.Endorsement[u].Splits.Seller.Premium=e[u].SellerAmount.toFixed(2));if(Array.isArray(it)&&it.length>0)for(t=0;t<it.length;t++)for(e=rateCalc.updatedEndorsementList.LeaseholdLender[t],u=0;u<e.length;u++)for(f=0;f<c.length;f++)if(c[f].FeeType==="LeaseholdLenderPremium")if(t===0)n.QuoteResponse.Pricing.RateManual.Policies.Policy[f].EndorsementList.Endorsement[u].Name===e[u].Name&&(n.QuoteResponse.Pricing.RateManual.Policies.Policy[f].EndorsementList.Endorsement[u].Splits.Buyer.Premium=e[u].BuyerAmount.toFixed(2),n.QuoteResponse.Pricing.RateManual.Policies.Policy[f].EndorsementList.Endorsement[u].Splits.Seller.Premium=e[u].SellerAmount.toFixed(2));else if(Array.isArray(n.QuoteResponse.Pricing.RateManual.Policies.Policy[f].AdditionalPolicies.Policy)&&n.QuoteResponse.Pricing.RateManual.Policies.Policy[f].AdditionalPolicies.Policy.length>0)for(d=n.QuoteResponse.Pricing.RateManual.Policies.Policy[f].AdditionalPolicies.Policy[t-1].EndorsementList.Endorsement,r=0;r<d.length;r++)n.QuoteResponse.Pricing.RateManual.Policies.Policy[f].AdditionalPolicies.Policy[t-1].EndorsementList.Endorsement[r].Name===e[u].Name&&(n.QuoteResponse.Pricing.RateManual.Policies.Policy[f].AdditionalPolicies.Policy[t-1].EndorsementList.Endorsement[r].Splits.Buyer.Premium=e[u].BuyerAmount.toFixed(2),n.QuoteResponse.Pricing.RateManual.Policies.Policy[f].AdditionalPolicies.Policy[t-1].EndorsementList.Endorsement[r].Splits.Seller.Premium=e[u].SellerAmount.toFixed(2));else for(d=n.QuoteResponse.Pricing.RateManual.Policies.Policy[f].AdditionalPolicies.Policy.EndorsementList.Endorsement,r=0;r<d.length;r++)n.QuoteResponse.Pricing.RateManual.Policies.Policy[f].AdditionalPolicies.Policy.EndorsementList.Endorsement[r].Name===e[u].Name&&(n.QuoteResponse.Pricing.RateManual.Policies.Policy[f].AdditionalPolicies.Policy.EndorsementList.Endorsement[r].Splits.Buyer.Premium=e[u].BuyerAmount.toFixed(2),n.QuoteResponse.Pricing.RateManual.Policies.Policy[f].AdditionalPolicies.Policy.EndorsementList.Endorsement[r].Splits.Seller.Premium=e[u].SellerAmount.toFixed(2));let s=rateCalc.GetPoliciesByType(n.QuoteResponse.Pricing.RateManual.Policies,CONSTRUCTION_LENDER_PREMIUM);if(Array.isArray(b[0])&&b[0].length>0)for(t=0;t<b[0].length;t++){const n=rateCalc.updatedEndorsementList.ConstructionLender[0].find(function(n){return n.Name===b[0][t].Name});n!==undefined&&(s.EndorsementList.Endorsement[t].Splits.Buyer.Premium=n.BuyerAmount.toFixed(2),s.EndorsementList.Endorsement[t].Splits.Seller.Premium=n.SellerAmount.toFixed(2))}let h=rateCalc.GetPoliciesByType(n.QuoteResponse.Pricing.RateManual.Policies,PROJECT_LENDER_PREMIUM);if(Array.isArray(k[0])&&k[0].length>0)for(t=0;t<k[0].length;t++){const n=rateCalc.updatedEndorsementList.ProjectLender[0].find(function(n){return n.Name===k[0][t].Name});n!==undefined&&(h.EndorsementList.Endorsement[t].Splits.Buyer.Premium=n.BuyerAmount.toFixed(2),h.EndorsementList.Endorsement[t].Splits.Seller.Premium=n.SellerAmount.toFixed(2))}}if(ft==="true"){const a=rateCalc.IsRefinance()||rateCalc.IsConstructionRefiTransaction();var st=0,ht=0,ct=0,lt=0,et=n.QuoteResponse.Recording,g=n.QuoteResponse.AdditionalRecordingList.Recording,at=n.QuoteResponse.Recordings;const u=rateCalc.updatedRecordingFeesList.filter(function(n){return!(n.Name.toLowerCase().indexOf("Leasehold".toLowerCase())>-1)&&!(n.Name.toLowerCase().indexOf("Construction".toLowerCase())>-1)&&!(n.Name.toLowerCase().indexOf("Project".toLowerCase())>-1)&&!(n.Name.toLowerCase().indexOf("Mortgage".toLowerCase())>-1)||n.Name.toLowerCase().indexOf("Deed Conservation Fund Fee".toLowerCase())>-1}),f=u.filter(function(n){return n.Name.toLowerCase().indexOf(STATE.toLowerCase())>-1}),e=u.filter(function(n){return n.Name.toLowerCase().indexOf(COUNTY.toLowerCase())>-1}),o=u.filter(function(n){return n.Name.toLowerCase().indexOf(CITY.toLowerCase())>-1}),c=rateCalc.updatedRecordingFeesList.filter(function(n){return n.Name.toLowerCase().indexOf(LEASEHOLD_DEED_TAX_STATE.toLowerCase())>-1}),l=rateCalc.updatedRecordingFeesList.filter(function(n){return n.Name.toLowerCase().indexOf(LEASEHOLD_DEED_TAX_CITY.toLowerCase())>-1});if(c.length>0&&(st=rateCalc.ConvertStringToNumber(c[0].BuyerAmount).toFixed(2),ht=rateCalc.ConvertStringToNumber(c[0].SellerAmount).toFixed(2)),l.length>0&&(ct=rateCalc.ConvertStringToNumber(l[0].BuyerAmount).toFixed(2),lt=rateCalc.ConvertStringToNumber(l[0].SellerAmount).toFixed(2)),et!==undefined){for(i=sellerAmount=0,t=0;t<f.length;t++)i+=rateCalc.RoundCurrencyValue(rateCalc.ConvertStringToNumber(f[t].BuyerAmount).toFixed(2)),sellerAmount+=rateCalc.RoundCurrencyValue(rateCalc.ConvertStringToNumber(f[t].SellerAmount).toFixed(2));for(t=0;t<e.length;t++)buyerAmountCounty+=rateCalc.RoundCurrencyValue(rateCalc.ConvertStringToNumber(e[t].BuyerAmount).toFixed(2)),sellerAmountCounty+=rateCalc.RoundCurrencyValue(rateCalc.ConvertStringToNumber(e[t].SellerAmount).toFixed(2));for(t=0;t<o.length;t++)buyerAmountCity+=rateCalc.RoundCurrencyValue(rateCalc.ConvertStringToNumber(o[t].BuyerAmount).toFixed(2)),sellerAmountCity+=rateCalc.RoundCurrencyValue(rateCalc.ConvertStringToNumber(o[t].SellerAmount).toFixed(2));if(n.QuoteResponse.Recording.Deed!==undefined&&(n.QuoteResponse.Recording.Deed.BuyerSplitState!==undefined&&(n.QuoteResponse.Recording.Deed.BuyerSplitState=rateCalc.ConvertStringToNumber(i).toFixed(2),n.QuoteResponse.Recording.Deed.SellerSplitState=rateCalc.ConvertStringToNumber(sellerAmount).toFixed(2)),n.QuoteResponse.Recording.Deed.BuyerSplitCounty!==undefined&&(n.QuoteResponse.Recording.Deed.BuyerSplitCounty=rateCalc.ConvertStringToNumber(buyerAmountCounty).toFixed(2),n.QuoteResponse.Recording.Deed.SellerSplitCounty=rateCalc.ConvertStringToNumber(sellerAmountCounty).toFixed(2)),n.QuoteResponse.Recording.Deed.BuyerSplitCity!==undefined&&(n.QuoteResponse.Recording.Deed.BuyerSplitCity=rateCalc.ConvertStringToNumber(buyerAmountCity).toFixed(2),n.QuoteResponse.Recording.Deed.SellerSplitCity=rateCalc.ConvertStringToNumber(sellerAmountCity).toFixed(2))),!a){const t=rateCalc.updatedRecordingFeesList.filter(function(n){return n.Name.toLowerCase().indexOf("tax")>-1&&!$.isNumeric(n.Name.charAt(0))&&!(n.Name.toLowerCase().indexOf("construction")>-1)&&!(n.Name.toLowerCase().indexOf("project")>-1)&&!(n.Name.toLowerCase().indexOf("leasehold")>-1)});rateCalc.UpdateCFPB2015Nodes(t,et.CFPB2015,n.QuoteResponse.Recording,!0)}}if(Array.isArray(g)&&g.length>0)for(r=0;r<g.length;r++){if(n.QuoteResponse.AdditionalRecordingList.Recording[r].Deed=n.QuoteResponse.Recording.Deed,Array.isArray(n.QuoteResponse.Recording.CFPB2015.CFPBTax))for(s=0;s<n.QuoteResponse.Recording.CFPB2015.CFPBTax.length;s++){let t=n.QuoteResponse.Recording.CFPB2015.CFPBTax[s].TaxType;t!==MORTGAGE_TAX&&(n.QuoteResponse.AdditionalRecordingList.Recording[r].CFPB2015.CFPBTax[s]=n.QuoteResponse.Recording.CFPB2015.CFPBTax[s])}const t=rateCalc.updatedRecordingFeesList.filter(function(n){return n.Name.toLowerCase().indexOf("tax")>-1&&parseInt(n.Name.charAt(0))==r+2});rateCalc.UpdateCFPB2015Nodes(t,g[r].CFPB2015,n.QuoteResponse.AdditionalRecordingList.Recording[r],!0)}if(at!==undefined)if(h.toUpperCase()===CONSTRUCTION||h.toUpperCase()===LEASEHOLD){n.QuoteResponse.Recordings.Recording[0]!==undefined&&(n.QuoteResponse.Recordings.Recording[0].Mortgage=n.QuoteResponse.Recording.Mortgage,n.QuoteResponse.Recordings.Recording[0].Deed=n.QuoteResponse.Recording.Deed,n.QuoteResponse.Recordings.Recording[0].Release=n.QuoteResponse.Recording.Release,n.QuoteResponse.Recordings.Recording[0].CFPB2015=n.QuoteResponse.Recording.CFPB2015);const t=rateCalc.updatedRecordingFeesList.filter(function(n){return n.Name.toLowerCase().indexOf("tax")>-1&&n.Name.toLowerCase().indexOf("construction")>-1&&!$.isNumeric(n.Name.charAt(0))}),i=rateCalc.updatedRecordingFeesList.filter(function(n){return n.Name.toLowerCase().indexOf("tax")>-1&&n.Name.toLowerCase().indexOf("project")>-1&&!$.isNumeric(n.Name.charAt(0))}),u=rateCalc.updatedRecordingFeesList.filter(function(n){return n.Name.toLowerCase().indexOf("tax")>-1&&n.Name.toLowerCase().indexOf("leasehold")>-1});for(r=0;r<n.QuoteResponse.Recordings.Recording.length;r++){let f=n.QuoteResponse.Recordings.Recording[r].RecordingType;if(h.toUpperCase()===CONSTRUCTION){if(n.QuoteResponse.Recordings.Recording[r].Deed=n.QuoteResponse.Recording.Deed,n.QuoteResponse.Recordings.Recording[r].CFPB2015!==undefined&&Array.isArray(n.QuoteResponse.Recordings.Recording[r].CFPB2015.CFPBTax))for(s=0;s<n.QuoteResponse.Recordings.Recording[r].CFPB2015.CFPBTax.length;s++){let t=n.QuoteResponse.Recordings.Recording[r].CFPB2015.CFPBTax[s].TaxType;t==DEED_TAX&&(n.QuoteResponse.Recordings.Recording[r].CFPB2015.CFPBTax[s]=n.QuoteResponse.Recording.CFPB2015.CFPBTax[s])}f==RECORDING_CONSTRUCTION_LENDER_OWNER&&rateCalc.UpdateCFPB2015Nodes(t,n.QuoteResponse.Recordings.Recording[r].CFPB2015,n.QuoteResponse.Recordings.Recording[r],!1);f==RECORDING_PROJECT_LENDER_OWNER&&rateCalc.UpdateCFPB2015Nodes(i,n.QuoteResponse.Recordings.Recording[r].CFPB2015,n.QuoteResponse.Recordings.Recording[r],!1)}h.toUpperCase()===LEASEHOLD&&f==RECORDING_LEASEHOLD_LENDER_OWNER&&rateCalc.UpdateCFPB2015Nodes(u,n.QuoteResponse.Recordings.Recording[r].CFPB2015,n.QuoteResponse.Recordings.Recording[r],!0)}}else if(h.toUpperCase()===CONSTRUCTIONREFI){const t=rateCalc.updatedRecordingFeesList.filter(function(n){return n.Name.toLowerCase().indexOf("Mortgage Tax - State".toLowerCase())>-1});if(Array.isArray(n.QuoteResponse.Recordings.Recording)){let i=0;const r=/Construction|Project/;n.QuoteResponse.Recordings.Recording.forEach(n=>{const u=t[i].Name.match(r);n.RecordingType.includes(u)&&(n.Mortgage.BuyerSplit=rateCalc.ConvertStringToNumber(t[i].BuyerAmount).toFixed(2),n.Mortgage.LenderSplit=rateCalc.ConvertStringToNumber(t[i].LenderAmount).toFixed(2),n.Mortgage.SellerSplit&&delete n.Mortgage.SellerSplit);i++})}else n.QuoteResponse.Recordings.Recording.Mortgage.BuyerSplit=rateCalc.ConvertStringToNumber(t[0].BuyerAmount).toFixed(2),n.QuoteResponse.Recordings.Recording.Mortgage.LenderSplit=rateCalc.ConvertStringToNumber(t[0].LenderAmount).toFixed(2),n.QuoteResponse.Recordings.Recording.Mortgage.SellerSplit&&delete n.QuoteResponse.Recordings.Recording.Mortgage.SellerSplit}else n.QuoteResponse.Recordings.Recording.Mortgage=n.QuoteResponse.Recording.Mortgage,n.QuoteResponse.Recordings.Recording.Deed=n.QuoteResponse.Recording.Deed,n.QuoteResponse.Recordings.Recording.Release=n.QuoteResponse.Recording.Release,n.QuoteResponse.Recordings.Recording.CFPB2015=n.QuoteResponse.Recording.CFPB2015,n.QuoteResponse.Recordings.Recording.AdditionalRecordingList=n.QuoteResponse.AdditionalRecordingList}sendAjaxRequest(POST,"/api/pricing/updatedquoteresponse","="+encodeURIComponent(JSON.stringify(n)),function(){},DisplayError)};rateCalc.UpdateCFPB2015Nodes=function(n,t,i,r){buyerAmount=sellerAmount=0;for(var u=0;u<n.length;u++)if(taxName=n[u].Name,buyerAmount=rateCalc.ConvertStringToNumber(n[u].BuyerAmount).toFixed(2),sellerAmount=rateCalc.ConvertStringToNumber(n[u].SellerAmount).toFixed(2),t!==undefined){const n=rateCalc.fillCFPB2015(taxName,t,i,buyerAmount,sellerAmount);i.CFPB2015=n.CFPB2015}if(r&&t!==undefined){const n=rateCalc.fillCFPBTaxTotals(t,i);i.CFPB2015=n.CFPB2015}};rateCalc.fillCFPB2015=function(n,t,i,r,u){for(var e,h,c,o,s,f=0;f<t.CFPBTax.length;f++)e=t.CFPBTax[f].TaxType,s=n.charAt(0),$.isNumeric(s)&&(h=parseInt(s),c=rateCalc.GetNumeralPrefix(h),o=c+MORTGAGE_TAX_STATE),(n===DEED_TAX_STATE||n===DEED_TAX_CITY||n===DEED_TAX_COUNTY)&&e===DEED_TAX&&(i=rateCalc.updateCFPBTaxingEntities(f,n,DEED_TAX_STATE,DEED_TAX_CITY,DEED_TAX_COUNTY,t,i,r,u)),n===DEED_RECORDATION_TAX_STATE&&e===DEED_RECORDATION_TAX&&(i=rateCalc.updateCFPBTaxingEntities(f,n,DEED_RECORDATION_TAX_STATE,"","",t,i,r,u)),e===MORTGAGE_TAX&&(n===MORTGAGE_TAX_STATE||n===MORTGAGE_TAX_COUNTY?i=rateCalc.updateCFPBTaxingEntities(f,n,MORTGAGE_TAX_STATE,"",MORTGAGE_TAX_COUNTY,t,i,r,u):n===o&&(i=rateCalc.updateCFPBTaxingEntities(f,n,o,"","",t,i,r,u))),n===MANSION_TAX_STATE&&e===MANSION_TAX&&(i=rateCalc.updateCFPBTaxingEntities(f,n,MANSION_TAX_STATE,"","",t,i,r,u)),n===MORTGAGE_RECORDATION_TAX_STATE&&e===MORTGAGE_RECORDATION_TAX&&(i=rateCalc.updateCFPBTaxingEntities(f,n,MORTGAGE_RECORDATION_TAX_STATE,"","",t,i,r,u)),n===MORTGAGE_INTANGIBLE_TAX_STATE&&e===MORTGAGE_INTANGIBLE_TAX&&(i=rateCalc.updateCFPBTaxingEntities(f,n,MORTGAGE_INTANGIBLE_TAX_STATE,"","",t,i,r,u)),n===CONSTRUCTION_MORTGAGE_TAX_STATE&&e===MORTGAGE_TAX&&(i=rateCalc.updateCFPBTaxingEntities(f,n,CONSTRUCTION_MORTGAGE_TAX_STATE,"","",t,i,r,u)),n===CONSTRUCTION_MANSION_TAX_STATE&&e===MANSION_TAX&&(i=rateCalc.updateCFPBTaxingEntities(f,n,CONSTRUCTION_MANSION_TAX_STATE,"","",t,i,r,u)),n===PROJECT_MORTGAGE_TAX_STATE&&e===MORTGAGE_TAX&&(i=rateCalc.updateCFPBTaxingEntities(f,n,PROJECT_MORTGAGE_TAX_STATE,"","",t,i,r,u)),n===PROJECT_MANSION_TAX_STATE&&e===MANSION_TAX&&(i=rateCalc.updateCFPBTaxingEntities(f,n,PROJECT_MANSION_TAX_STATE,"","",t,i,r,u)),(n===LEASEHOLD_DEED_TAX_STATE||n===LEASEHOLD_DEED_TAX_CITY)&&e===DEED_TAX&&(i=rateCalc.updateCFPBTaxingEntities(f,n,LEASEHOLD_DEED_TAX_STATE,LEASEHOLD_DEED_TAX_CITY,"",t,i,r,u)),n===LEASEHOLD_MORTGAGE_TAX_STATE&&e===MORTGAGE_TAX&&(i=rateCalc.updateCFPBTaxingEntities(f,n,LEASEHOLD_MORTGAGE_TAX_STATE,"","",t,i,r,u)),n===LEASEHOLD_MANSION_TAX_STATE&&e===MANSION_TAX&&(i=rateCalc.updateCFPBTaxingEntities(f,n,LEASEHOLD_MANSION_TAX_STATE,"","",t,i,r,u)),(n===GRANTOR_TAX_STATE||n===GRANTOR_TAX_CITY||n===GRANTOR_TAX_COUNTY)&&e===GRANTOR_TAX&&(i=rateCalc.updateCFPBTaxingEntities(f,n,GRANTOR_TAX_STATE,GRANTOR_TAX_CITY,GRANTOR_TAX_COUNTY,t,i,r,u)),(n===GRANTEE_TAX_STATE||n===GRANTEE_TAX_CITY||n===GRANTEE_TAX_COUNTY)&&e===GRANTEE_TAX&&(i=rateCalc.updateCFPBTaxingEntities(f,n,GRANTEE_TAX_STATE,GRANTEE_TAX_CITY,GRANTEE_TAX_COUNTY,t,i,r,u));return i};rateCalc.updateCFPBTaxingEntities=function(n,t,i,r,u,f,e,o,s){if(e.CFPB2015.CFPBTax[n]!==undefined&&f.CFPBTax[n].TaxingEntities.TaxingEntity!==undefined)for(var h=0;h<f.CFPBTax[n].TaxingEntities.TaxingEntity.length;h++){let c=f.CFPBTax[n].TaxingEntities.TaxingEntity[h].TaxingEntityJurisdiction;t===i&&c===STATE&&(e.CFPB2015.CFPBTax[n].TaxingEntities.TaxingEntity[h].BuyerSplit=o,e.CFPB2015.CFPBTax[n].TaxingEntities.TaxingEntity[h].SellerSplit=s);t===r&&c===CITY&&(e.CFPB2015.CFPBTax[n].TaxingEntities.TaxingEntity[h].BuyerSplit=o,e.CFPB2015.CFPBTax[n].TaxingEntities.TaxingEntity[h].SellerSplit=s);t===u&&c===COUNTY&&(e.CFPB2015.CFPBTax[n].TaxingEntities.TaxingEntity[h].BuyerSplit=o,e.CFPB2015.CFPBTax[n].TaxingEntities.TaxingEntity[h].SellerSplit=s)}return e};rateCalc.fillCFPBTaxTotals=function(n,t){var i,u,r;if(Array.isArray(t.CFPB2015.CFPBTax))for(i=0;i<t.CFPB2015.CFPBTax.length;i++)if(u=totalSellerSplit=0,n.CFPBTax[i]!==null){for(r=0;r<n.CFPBTax[i].TaxingEntities.TaxingEntity.length;r++)u+=rateCalc.RoundCurrencyValue(t.CFPB2015.CFPBTax[i].TaxingEntities.TaxingEntity[r].BuyerSplit),totalSellerSplit+=rateCalc.RoundCurrencyValue(t.CFPB2015.CFPBTax[i].TaxingEntities.TaxingEntity[r].SellerSplit);n.CFPBTax[i].TotalBuyerSplit!==undefined&&(t.CFPB2015.CFPBTax[i].TotalBuyerSplit=rateCalc.ConvertStringToNumber(u).toFixed(2));n.CFPBTax[i].TotalSellerSplit!==undefined&&(t.CFPB2015.CFPBTax[i].TotalSellerSplit=rateCalc.ConvertStringToNumber(totalSellerSplit).toFixed(2))}return t};rateCalc.GetAdditionalLoanAmounts=function(n,t){var r=[],i;if(n.length>0)for(i=0;i<n.length;i++)r.push(new FeeItem(rateCalc.GetNumeralPrefix(i+2)+t,rateCalc.ConvertStringToNumber(n[i].amount())));return r};rateCalc.GetAdditionalRateManualLenderPremiums=function(n,t,i){var u=[],r;if(n.length>0){let f=0;for(r=0;r<n.length;r++)f=r+2,$('fieldset[data-name="tbTipPolicy"] table').find('tr[data-name="tr'+i+"LenderPolicy"+f+'"]').length>0&&u.push(new TefeFeeItem(rateCalc.EscapeSpecialCharacters(rateCalc.GetNumeralPrefix(r+2)+t),rateCalc.ConvertStringToNumber($("#span"+i+"LenderPolicyTotal"+f).text()),rateCalc.ConvertStringToNumber($("#txt"+i+"LenderPolicyBuyerAmount"+f).val()),rateCalc.ConvertStringToNumber($("#txt"+i+"LenderPolicySellerAmount"+f).val())))}return u};rateCalc.GetAdditionalTRID=function(){var t=[],n;if(rateCalc.closingSheetViewModel.additionalLoanList().length>0){let i=0;for(n=0;n<rateCalc.closingSheetViewModel.additionalLoanList().length;n++)i=n+2,$('fieldset[data-name="tbTipPolicy"] table').find('tr[data-name="trLenderTRID'+i+'"]').length>0&&t.push(new TefeFeeItem(rateCalc.EscapeSpecialCharacters(rateCalc.GetNumeralPrefix(n+2)+"Lender's Policy (TRID)"),rateCalc.ConvertStringToNumber($("#spanLenderTotalTRID"+i).text()),rateCalc.ConvertStringToNumber($("#spanLenderBuyerTRID"+i).text()),rateCalc.ConvertStringToNumber($("#spanLenderSellerTRID"+i).text())))}return t};rateCalc.GetAdditionalEndorsements=function(n,t,i,r){var u=[];if(rateCalc.IsSectionEnabled(ENDORSEMENTS))for(let f=1;f<t.length;f++)if(n[f-1].isInsured()){let n=rateCalc.GetNumeralPrefix(f+1)+i;u.push({Description:rateCalc.EscapeSpecialCharacters(n+"Endorsements"),EndorsementsList:rateCalc.GetTefeEndorsements(t[f],n),LendersBuyerEndorsementTax:rateCalc.GetTextElementNumber($("#spanBuyer"+r+"Lender"+(f+1)+"EndorsementTax")),LendersSellerEndorsementTax:rateCalc.GetTextElementNumber($("#spanSeller"+r+"Lender"+(f+1)+"EndorsementTax")),LendersTotalEndorsementTax:rateCalc.GetTextElementNumber($("#spanTotal"+r+"Lender"+(f+1)+"EndorsementTax"))})}return u};rateCalc.GetTextElementNumber=function(n){var t=0;return n.length>0&&(t=rateCalc.ConvertStringToNumber(n.text())),t};rateCalc.GetValueElementNumber=function(n){var t=0;return n.length>0&&(t=rateCalc.ConvertStringToNumber(n.val())),t};rateCalc.GetLenderPCTDescription=function(){return rateCalc.IsRefinance()?$("#RefiLenderPolicyCoverageType").val()===EMPTY_STRING?EMPTY_STRING:$("#RefiLenderPolicyCoverageType option:selected").text():$("#LenderPolicyCoverageType").val()===EMPTY_STRING?EMPTY_STRING:$("#LenderPolicyCoverageType option:selected").text()};rateCalc.GetProviderNotes=function(n){var t="";return n.PrimaryNote&&(t=n.PrimaryNote+" "),n.SecondaryNote&&(t=t+n.SecondaryNote),t};rateCalc.GetTefeEndorsements=function(n,t){var i=[];return rateCalc.IsSectionEnabled(ENDORSEMENTS)&&n.length>0&&$.each(n,function(n,r){let s=rateCalc.EscapeSpecialCharacters(t+r.Name),e=r.BuyerAmount,o=r.SellerAmount,u=rateCalc.RoundCurrencyValue(e)+rateCalc.RoundCurrencyValue(o),f=rateCalc.RoundCurrencyValue(r.Total);f!==u&&u>0&&(f=u);i.push(new TefeFeeItem(s,f,rateCalc.RoundCurrencyValue(e),rateCalc.RoundCurrencyValue(o),rateCalc.RoundCurrencyValue(r.TotalTax),rateCalc.RoundCurrencyValue(r.BuyerTaxAmount),rateCalc.RoundCurrencyValue(r.SellerTaxAmount)))}),i};rateCalc.GetTefeTitleServiceFees=function(n){var f=[],t;if(rateCalc.IsSectionEnabled(OFFICE)){var u="",i=0,r=0,e=0,o=0,s=0,h=0;for(rateCalc.updatedTitleServiceFeesList.length>0&&$.each(rateCalc.updatedTitleServiceFeesList,function(n,t){u=rateCalc.EscapeSpecialCharacters(t.Name);var c=rateCalc.GetIndexOfUpdatedTSF(t.Name);i=rateCalc.ConvertStringToNumber(rateCalc.updatedTitleServiceFeesList[c].BuyerAmount);r=rateCalc.ConvertStringToNumber(rateCalc.updatedTitleServiceFeesList[c].SellerAmount);e=rateCalc.ConvertStringToNumber(rateCalc.updatedTitleServiceFeesList[c].TotalAmount);o=rateCalc.ConvertStringToNumber(rateCalc.updatedTitleServiceFeesList[c].TotalTax);s=rateCalc.ConvertStringToNumber(rateCalc.updatedTitleServiceFeesList[c].BuyerTaxAmount);h=rateCalc.ConvertStringToNumber(rateCalc.updatedTitleServiceFeesList[c].SellerTaxAmount);f.push(new TefeFeeItem(u,rateCalc.RoundCurrencyValue(e),rateCalc.RoundCurrencyValue(i),rateCalc.RoundCurrencyValue(r),rateCalc.RoundCurrencyValue(o),rateCalc.RoundCurrencyValue(s),rateCalc.RoundCurrencyValue(h)))}),t=0;t<rateCalc.closingSheetViewModel.additionalTSFList().length;t++)rateCalc.closingSheetViewModel.additionalTSFList()[t].name()&&(u=rateCalc.EscapeSpecialCharacters(rateCalc.closingSheetViewModel.additionalTSFList()[t].name()),i=rateCalc.ConvertStringToNumber(rateCalc.closingSheetViewModel.additionalTSFList()[t].buyerAmount()),r=rateCalc.ConvertStringToNumber(rateCalc.closingSheetViewModel.additionalTSFList()[t].sellerAmount()),f.push(new TefeFeeItem(u,rateCalc.RoundCurrencyValue(i)+rateCalc.RoundCurrencyValue(r),rateCalc.RoundCurrencyValue(i),rateCalc.RoundCurrencyValue(r),0,0,0)),n.TotalBuyer=n.TotalBuyer+i,n.TotalSeller=n.TotalSeller+r)}return f};rateCalc.GetTefeRecordingFeeList=function(n){var e=[],o="",i=0,r=0,u=0,f=0,s=0,h=0,c=0,l=0,t;if(rateCalc.IsSectionEnabled(FEES)||rateCalc.IsNetSheetQuoteType()){for(t=0;t<rateCalc.updatedRecordingFeesList.length;t++)o=rateCalc.EscapeSpecialCharacters(rateCalc.updatedRecordingFeesList[t].Name),i=rateCalc.ConvertStringToNumber(rateCalc.updatedRecordingFeesList[t].BuyerAmount),r=rateCalc.ConvertStringToNumber(rateCalc.updatedRecordingFeesList[t].SellerAmount),u=rateCalc.ConvertStringToNumber(rateCalc.updatedRecordingFeesList[t].LenderAmount),f=rateCalc.ConvertStringToNumber(rateCalc.updatedRecordingFeesList[t].TotalAmount),e.push({Description:o,TotalAmount:rateCalc.RoundCurrencyValue(f),BuyerAmount:rateCalc.RoundCurrencyValue(i),SellerAmount:rateCalc.RoundCurrencyValue(r),LenderAmount:rateCalc.RoundCurrencyValue(u),DisplaySplits:rateCalc.GetDataForSelectedTransactionType(TRANSACTION_TYPE_KEYS.IS_DISPLAY_SPLITS).toString()}),l+=f,s+=i,h+=r,c+=u;n.TotalBuyerRecordingFeesTransferTaxes=rateCalc.RoundCurrencyValue(s);n.TotalSellerRecordingFeesTransferTaxes=rateCalc.RoundCurrencyValue(h);n.TotalLenderRecordingFeesTransferTaxes=rateCalc.RoundCurrencyValue(c);n.TotalRecordingFeesTransferTaxes=rateCalc.RoundCurrencyValue(l)}return e};rateCalc.GetNetSheetDocument=function(){recordingTotal={TotalBuyerRecordingFeesTransferTaxes:0,TotalSellerRecordingFeesTransferTaxes:0,TotalLenderRecordingFeesTransferTaxes:0,TotalRecordingFeesTransferTaxes:0};var t=rateCalc.GetTefeRecordingFeeList(recordingTotal),i={Netsheet:{QuoteDetails:{ReferenceId:rateCalc.quoteRequestRoot.QuoteRequest.TransactionInformation.StewartReferenceNumber,Type:rateCalc.quoteType===QUOTE_TYPE_BUYER?BUYER:SELLER,SalesPrice:rateCalc.ConvertStringToNumber($("#txtPurchasePrice").val()),TransactionTypeDescription:$("#TransactionType option:selected").text(),EarnestMoneyDeposit:rateCalc.ConvertStringToNumber($("input[name=EarnestMoneyDeposit]").val()),DownPayAmount:rateCalc.ConvertStringToNumber($("#txtBuyerPrepaidDownPayment").val()),DownPayPct:rateCalc.ConvertStringToNumber($("#txtBuyerPrepaidDownPayPercent").val()),LoanAmount:rateCalc.quoteType===QUOTE_TYPE_BUYER?rateCalc.ConvertStringToNumber($("#txtBuyerPrepaidLoanAmount").val()):rateCalc.ConvertStringToNumber($("#LoanAmount").val()),LoanPayoff:rateCalc.GetLoanPayoffList(),PayoffTotal:rateCalc.ConvertStringToNumber($("#txtSellerPayoffTotal").val()),LenderPointPct:rateCalc.ConvertStringToNumber($("#txtBuyerPrepaidLoanLenderPoints").val()),LenderPointAmount:rateCalc.ConvertStringToNumber($("#txtBuyerPrepaidLoanLenderPoints").val())/100*rateCalc.ConvertStringToNumber($("#txtBuyerPrepaidLoanAmount").val()),LoanOriginationFee:rateCalc.ConvertStringToNumber($("#txtBuyerPrepaidLoanLenderOrigFee").val()),OtherLenderFee:rateCalc.ConvertStringToNumber($("#txtBuyerPrepaidLoanLenderFees").val()),PrepaidInterestAmount:rateCalc.ConvertStringToNumber($("#lblBuyerPrepaidPrePaidInterest").text()),PrepaidInterestDays:rateCalc.ConvertStringToNumber($("#spanBuyerPrepaidPrePaidIntDays").text()),PrepaidPropTax:rateCalc.ConvertStringToNumber($("#lblBuyerPrepaidPropTaxCol").text()),PrepaidPropMonths:rateCalc.ConvertStringToNumber($("#txtBuyerPrepaidPropTaxMos").val()),PrepaidHaz:rateCalc.ConvertStringToNumber($("#lblBuyerPrepaidHazardInsCol").text()),PrepaidHazMonths:rateCalc.ConvertStringToNumber($("#txtBuyerPrepaidHazardInsMos").val()),LoanCostsPrepaidTotal:rateCalc.ConvertStringToNumber($("#spanBuyerPrepaidTotal").text()),LendersPolicyType:rateCalc.quoteType===QUOTE_TYPE_SELLER?$("#LenderPolicyCoverageTypeSellerNetSheet option:selected").text():$("#LenderPolicyCoverageType option:selected").text(),LendersPremium:rateCalc.RoundCurrencyValue(rateCalc.GetPremiumAmount(LENDER)),LendersCplEndorsementsOtherFees:rateCalc.RoundCurrencyValue(rateCalc.GetCplEndorsementsOtherFees(LENDER)),OwnersPolicyType:rateCalc.quoteType===QUOTE_TYPE_SELLER?$("#OwnerPolicyCoverageTypeSellerNetSheet option:selected").text():$("#OwnerPolicyCoverageType option:selected").text(),OwnersPremium:rateCalc.RoundCurrencyValue(rateCalc.GetPremiumAmount(OWNER)),OwnersCplEndorsementsOtherFees:rateCalc.RoundCurrencyValue(rateCalc.GetCplEndorsementsOtherFees(OWNER)),PremiumRelatedSubtotal:rateCalc.RoundCurrencyValue(rateCalc.GetPremiumRelatedSubtotal()),PremiumRelatedTaxes:rateCalc.RoundCurrencyValue(rateCalc.GetPremiumRelatedTaxes()),PremiumRelatedTotal:rateCalc.RoundCurrencyValue(rateCalc.GetPremiumRelatedSubtotal()+rateCalc.GetPremiumRelatedTaxes()),TitleFeesSubtotal:rateCalc.RoundCurrencyValue(rateCalc.GetTitleFeesSubtotal()),TitleFeesTax:rateCalc.RoundCurrencyValue(rateCalc.GetTitleFeesTax()),TitleFeesTotal:rateCalc.RoundCurrencyValue(rateCalc.GetTitleFeesSubtotal()+rateCalc.GetTitleFeesTax()),ClosingCostsCredits:rateCalc.GetClosingCostCreditList(),CostsCreditsTotal:rateCalc.GetClosingCostCreditTotal(),RecordingTransferTotal:rateCalc.quoteType===QUOTE_TYPE_BUYER?rateCalc.ConvertStringToNumber($("#spanBuyerRecordingFeesTotal").text()):rateCalc.ConvertStringToNumber($("#spanSellerRecordingFeesTotal").text()),BrokerComissionsRate:rateCalc.ConvertStringToNumber($("#txtSellerCostsBrokerCommission").val())+rateCalc.ConvertStringToNumber($("#txtBuyerCostsBrokerCommission").val()),NetsheetTotalType:rateCalc.quoteType===QUOTE_TYPE_BUYER?$("#legendEstimatedCashToCloseDesc").text():$("#legendEstimatedNetProceedsDesc").text(),NetsheetTotalAmount:rateCalc.quoteType===QUOTE_TYPE_BUYER?rateCalc.ConvertStringToNumber($("#spanTotalBuyerNetSheetAmount").text()):rateCalc.ConvertStringToNumber($("#spanTotalSellerNetSheetAmount").text())},PreparedInformation:{Logo:rateCalc.logoSource,BorrowerName:rateCalc.EscapeSpecialCharacters($("#txtBorrowerName").val()),PropertyStreetAddress:rateCalc.EscapeSpecialCharacters($("#txtPropertyStreetAddress").val()),ByName:rateCalc.EscapeSpecialCharacters($("#txtPreparedByName").val()),ByCompany:rateCalc.EscapeSpecialCharacters($("#txtPreparedByCompany").val()),ByAddress:rateCalc.EscapeSpecialCharacters($("#txtPreparedByAddress").val()),ByCsz:rateCalc.EscapeSpecialCharacters($("#txtPreparedByCityStateZip").val()),ByEmail:rateCalc.EscapeSpecialCharacters($("#txtPreparedByEmail").val()),ByPhone:rateCalc.EscapeSpecialCharacters($("#txtPreparedByPhone").val()),ForName:rateCalc.EscapeSpecialCharacters($("#txtPreparedForName").val()),ForCompany:rateCalc.EscapeSpecialCharacters($("#txtPreparedForCompany").val()),ForEmail:rateCalc.EscapeSpecialCharacters($("#txtPreparedForEmail").val()),ForNote:rateCalc.EscapeSpecialCharacters($("#txtPreparedForNote").val().replace(/[\n\r]+/g,"")),CloseDate:$("#buyerProjectedClosingDate").val(),PropertyState:rateCalc.propertyState,PropertyCity:rateCalc.propertyCity,PropertyCounty:rateCalc.propertyCountyName,StateNotes:$("#taStateNotes").val(),FooterInformation:$("#paraDisclaimerNote").val(),CreatedByApp:"Stewart Rate Calculator",ProviderId:rateCalc.quoteRequestRoot.QuoteRequest.TransactionInformation.ProviderID},SettlementOffice:rateCalc.GetProviderInfo(rateCalc.selectedProvider),Itemizations:{LendersItemized:rateCalc.GetLendersItemized(),LendersItemizedTotal:rateCalc.RoundCurrencyValue(rateCalc.GetLendersItemizedTotal()),OwnersItemized:rateCalc.GetOwnersItemized(),OwnersItemizedTotal:rateCalc.RoundCurrencyValue(rateCalc.GetOwnersItemizedTotal()),TitleItemized:rateCalc.GetTitleItemized(),BrokerComissionsItemized:rateCalc.GetBrokerCommissionItemized()},ShowRecordingFeesTransferTaxes:rateCalc.IsSectionEnabled(FEES).toString(),RecordingFeesTransferTaxes:{RecordingFeesTransferTaxesList:t,TotalBuyerRecordingFeesTransferTaxes:recordingTotal.TotalBuyerRecordingFeesTransferTaxes,TotalSellerRecordingFeesTransferTaxes:recordingTotal.TotalSellerRecordingFeesTransferTaxes,TotalLenderRecordingFeesTransferTaxes:recordingTotal.TotalLenderRecordingFeesTransferTaxes,TotalRecordingFeesTransferTaxes:recordingTotal.TotalRecordingFeesTransferTaxes,ShowLenderRecordingFeeTransferTaxes:rateCalc.ConvertStringToNumber(recordingTotal.TotalLenderRecordingFeesTransferTaxes)>0?"true":"false"}}},n="",r=rateCalc.quoteType===QUOTE_TYPE_BUYER?"ClosingSheet":"NetSheet",u=rateCalc.quoteRequestRoot.QuoteRequest.TransactionInformation.StewartReferenceNumber;isSaveDocumentPDF&&(n=encodeURIComponent(rateCalc.quoteRequestRoot.QuoteRequest.TransactionInformation.ClientReferenceNumber));sendAjaxRequest(POST,"/api/pricing/document?clientrefid="+n+"&type="+rateCalc.quoteType+"&referenceId="+u+"&isItemized="+$("#cbItemizePreparedByFor").prop("checked")+"&documentType="+r,"="+JSON.stringify(i),function(n){rateCalc.DisplayPdf(n.PDF);$('div[data-name="loadingPdf"]').hide()},DisplayError)};rateCalc.GetProviderInfo=function(n){return n?{OfficeName:rateCalc.EscapeSpecialCharacters(rateCalc.ConvertEntitiesToSymbols(rateCalc.selectedProvider.Name)),OfficeAddress:rateCalc.selectedProvider.Address,OfficeState:rateCalc.selectedProvider.StateCode,OfficeCity:rateCalc.selectedProvider.City,OfficeZipCode:rateCalc.selectedProvider.ZipCode,OfficeContactName:rateCalc.selectedProvider.Contact,OfficeEmail:rateCalc.selectedProvider.ContactEmail,OfficePhone:"(P)"+rateCalc.selectedProvider.Phone,OfficeFax:"(F)"+rateCalc.selectedProvider.Fax,ProviderNotes:rateCalc.GetProviderNotes(rateCalc.quoteResult.QuoteResponse.Provider)}:{OfficeName:EMPTY_STRING,OfficeAddress:EMPTY_STRING,OfficeState:EMPTY_STRING,OfficeCity:EMPTY_STRING,OfficeZipCode:EMPTY_STRING,OfficeContactName:EMPTY_STRING,OfficeEmail:EMPTY_STRING,OfficePhone:EMPTY_STRING,OfficeFax:EMPTY_STRING,ProviderNotes:EMPTY_STRING}};rateCalc.EscapeSpecialCharacters=function(n){return encodeURIComponent(n.replace(/\\/g,"\\\\").replace(/"/g,'\\"'))};rateCalc.ConvertEntitiesToSymbols=function(n){return n.replace(/(&amp;|&lt;|&gt;|&quot;|&apos;)/g,function(n){switch(n){case"&amp;":return"&";case"&lt;":return"<";case"&gt;":return">";case"&quot;":return'"';case"&apos;":return"'";default:return n}})};rateCalc.GetClosingCostCreditList=function(){var n=[];if(rateCalc.quoteType===QUOTE_TYPE_BUYER){let t=rateCalc.ConvertStringToNumber($("#idBuyerCostsBrokerCommission").val());n.push(new FeeItem(BROKER_COMPENSATION,t));rateCalc.AddFeeItemToClosingCostCreditList(n,rateCalc.closingSheetViewModel.buyerClosingCostList());rateCalc.AddAdditionalFeeItemToClosingCostCreditList(n,rateCalc.closingSheetViewModel.additionalBuyerClosingCostList())}else{rateCalc.ConvertStringToNumber($("#lblSellerTaxesPriorTotal").text())!==0&&n.push(new FeeItem("Prior Year Taxes",rateCalc.ConvertStringToNumber($("#lblSellerTaxesPriorTotal").text())));rateCalc.ConvertStringToNumber($("#lblSellerTaxesCurrentTotal").text())!==0&&n.push(new FeeItem("Current Year Prorated Taxes",rateCalc.ConvertStringToNumber($("#lblSellerTaxesCurrentTotal").text())));let t=rateCalc.ConvertStringToNumber($("#txtSellerCostsBrokerCommission").val()),i=rateCalc.ConvertStringToNumber($("#txtBuyerCostsBrokerCommission").val()),r=i+t;n.push(new FeeItem(BROKER_COMPENSATION,r));rateCalc.AddFeeItemToClosingCostCreditList(n,rateCalc.closingSheetViewModel.sellerClosingCostList());rateCalc.AddAdditionalFeeItemToClosingCostCreditList(n,rateCalc.closingSheetViewModel.additionalSellerClosingCostList())}return n};rateCalc.GetClosingCostCreditTotal=function(){var n=0;return rateCalc.quoteType===QUOTE_TYPE_BUYER?n+=rateCalc.ConvertStringToNumber($("#spanBuyerCostsTotal").text()):(n=rateCalc.ConvertStringToNumber($("#lblSellerTaxesPriorTotal").text()),n+=rateCalc.ConvertStringToNumber($("#lblSellerTaxesCurrentTotal").text()),n+=rateCalc.ConvertStringToNumber($("#spanSellerCostsTotal").text())),n};rateCalc.AddFeeItemToClosingCostCreditList=function(n,t){var i,r,u;if(t.length>0)for(i=0;i<t.length;i++)r=t[i].closingCostCreditName(),u=r.substr(r.indexOf("_")+1),n.push(new FeeItem(rateCalc.EscapeSpecialCharacters(u),rateCalc.ConvertStringToNumber(t[i].closingCostCreditAmount())));addBuyerCostsSellerPropTaxesRow(n)};rateCalc.AddAdditionalFeeItemToClosingCostCreditList=function(n,t){for(var i=0;i<t.length;i++)t[i].closingCostCreditName()&&n.push(new FeeItem(rateCalc.EscapeSpecialCharacters(t[i].closingCostCreditName()),rateCalc.ConvertStringToNumber(t[i].closingCostCreditAmount())))};rateCalc.GetTitleFeesSubtotal=function(){var t=0,n=0;return rateCalc.quoteResult.QuoteResponse.Pricing.TitleServiceFee.ItemizedTitleServiceFeeList.ItemizedTitleServiceFee&&$.each(rateCalc.quoteResult.QuoteResponse.Pricing.TitleServiceFee.ItemizedTitleServiceFeeList.ItemizedTitleServiceFee,function(i,r){var u=rateCalc.GetIndexOfUpdatedTSF(r.Name);n=rateCalc.quoteType===QUOTE_TYPE_BUYER?u>-1?rateCalc.ConvertStringToNumber(rateCalc.updatedTitleServiceFeesList[u].BuyerAmount):rateCalc.ConvertStringToNumber(r.BuyerAmount):u>-1?rateCalc.ConvertStringToNumber(rateCalc.updatedTitleServiceFeesList[u].SellerAmount):rateCalc.ConvertStringToNumber(r.SellerAmount);t+=n}),t+=rateCalc.quoteType===QUOTE_TYPE_BUYER?rateCalc.ConvertStringToNumber($("#txtBuyerAdditionalFees").val()):rateCalc.ConvertStringToNumber($("#txtSellerAdditionalFees").val())};rateCalc.GetTitleFeesTax=function(){var n;switch(rateCalc.quoteType){case QUOTE_TYPE_BUYER:n=rateCalc.ConvertStringToNumber($("#buyerspanBuyerTSF_Tax").text());break;case QUOTE_TYPE_SELLER:n=rateCalc.ConvertStringToNumber($("#sellerspanSellerTSF_Tax").text());break;default:n=0}return n};rateCalc.GetLendersItemized=function(){var t=[],n;let i=rateCalc.GetPoliciesByType(rateCalc.quoteResult.QuoteResponse.Pricing.RateManual.Policies,LENDER_PREMIUM);return i&&i.EndorsementList.Endorsement&&$.each(i.EndorsementList.Endorsement,function(i,r){var u=rateCalc.ConvertStringToNumber(r.Premium);rateCalc.quoteType===QUOTE_TYPE_BUYER?(n=$("input[name='rbBuyerLenderPolicy']:checked").val(),n!==SELLER&&(n===SPLIT&&(u=u/2),t.push(new FeeItem(rateCalc.EscapeSpecialCharacters(r.Name),rateCalc.RoundCurrencyValue(u))))):(n=$("input[name='rbSellerLenderPolicy']:checked").val(),n!==BUYER&&(n===SPLIT&&(u=u/2),t.push(new FeeItem(rateCalc.EscapeSpecialCharacters(r.Name),rateCalc.RoundCurrencyValue(u)))))}),t};rateCalc.GetLendersItemizedTotal=function(){var t=0,n;let i=rateCalc.GetPoliciesByType(rateCalc.quoteResult.QuoteResponse.Pricing.RateManual.Policies,LENDER_PREMIUM);return i&&i.EndorsementList.Endorsement&&$.each(i.EndorsementList.Endorsement,function(i,r){var u=rateCalc.ConvertStringToNumber(r.Premium);u>0&&(rateCalc.quoteType===QUOTE_TYPE_BUYER?(n=$("input[name='rbBuyerLenderPolicy']:checked").val(),n!==SELLER&&(n===SPLIT&&(u=u/2),t+=u)):(n=$("input[name='rbSellerLenderPolicy']:checked").val(),n!==BUYER&&(n===SPLIT&&(u=u/2),t+=u)))}),t};rateCalc.GetOwnersItemized=function(){var t=[],n;let i=rateCalc.GetPoliciesByType(rateCalc.quoteResult.QuoteResponse.Pricing.RateManual.Policies,OWNER_PREMIUM);return i&&i.EndorsementList.Endorsement&&$.each(i.EndorsementList.Endorsement,function(i,r){var u=rateCalc.ConvertStringToNumber(r.Premium);rateCalc.quoteType===QUOTE_TYPE_BUYER?(n=$("input[name='rbBuyerOwnerPolicy']:checked").val(),n!==SELLER&&(n===SPLIT&&(u=u/2),t.push(new FeeItem(rateCalc.EscapeSpecialCharacters(r.Name),rateCalc.RoundCurrencyValue(u))))):(n=$("input[name='rbSellerOwnerPolicy']:checked").val(),n!==BUYER&&(n===SPLIT&&(u=u/2),t.push(new FeeItem(rateCalc.EscapeSpecialCharacters(r.Name),rateCalc.RoundCurrencyValue(u)))))}),t};rateCalc.GetOwnersItemizedTotal=function(){var t=0,n;let i=rateCalc.GetPoliciesByType(rateCalc.quoteResult.QuoteResponse.Pricing.RateManual.Policies,OWNER_PREMIUM);return i&&i.EndorsementList.Endorsement&&$.each(i.EndorsementList.Endorsement,function(i,r){var u=rateCalc.ConvertStringToNumber(r.Premium);u>0&&(rateCalc.quoteType===QUOTE_TYPE_BUYER?(n=$("input[name='rbBuyerOwnerPolicy']:checked").val(),n!==SELLER&&(n===SPLIT&&(u=u/2),t+=u)):(n=$("input[name='rbSellerOwnerPolicy']:checked").val(),n!==BUYER&&(n===SPLIT&&(u=u/2),t+=u)))}),t};rateCalc.GetTitleItemized=function(){var n=[],t;return rateCalc.quoteResult.QuoteResponse.Pricing.TitleServiceFee.ItemizedTitleServiceFeeList.ItemizedTitleServiceFee&&$.each(rateCalc.quoteResult.QuoteResponse.Pricing.TitleServiceFee.ItemizedTitleServiceFeeList.ItemizedTitleServiceFee,function(t,i){var u=0,r=rateCalc.GetIndexOfUpdatedTSF(i.Name);u=rateCalc.quoteType===QUOTE_TYPE_BUYER?r>-1?rateCalc.ConvertStringToNumber(rateCalc.updatedTitleServiceFeesList[r].BuyerAmount):rateCalc.ConvertStringToNumber(i.BuyerAmount):r>-1?rateCalc.ConvertStringToNumber(rateCalc.updatedTitleServiceFeesList[r].SellerAmount):rateCalc.ConvertStringToNumber(i.SellerAmount);n.push(new FeeItem(rateCalc.EscapeSpecialCharacters(i.Name),rateCalc.RoundCurrencyValue(u)))}),rateCalc.quoteType===QUOTE_TYPE_BUYER&&rateCalc.ConvertStringToNumber($("#txtBuyerAdditionalFees").val())!==0?n.push(new FeeItem(ADDITIONAL_TITLE_FEES,rateCalc.RoundCurrencyValue(rateCalc.ConvertStringToNumber($("#txtBuyerAdditionalFees").val())))):rateCalc.quoteType===QUOTE_TYPE_SELLER&&rateCalc.ConvertStringToNumber($("#txtSellerAdditionalFees").val())!==0&&n.push(new FeeItem(ADDITIONAL_TITLE_FEES,rateCalc.RoundCurrencyValue(rateCalc.ConvertStringToNumber($("#txtSellerAdditionalFees").val())))),t=0,t=rateCalc.GetTitleFeesTax(),t>0&&n.push(new FeeItem("Tax (if applicable)",rateCalc.RoundCurrencyValue(t))),n};rateCalc.GetBrokerCommissionItemized=function(){let t=[],n=0;return(rateCalc.ConvertStringToNumber($("#txtBuyerCostsBrokerCommission").val())>0||rateCalc.ConvertStringToNumber($("#txtSellerCostsBrokerCommission").val())>0)&&(n=rateCalc.ConvertStringToNumber($("#txtBuyerCostsBrokerCommission").val()),n>0&&t.push(new FeeItem("Buyer Broker Compensation",n)),n=rateCalc.ConvertStringToNumber($("#txtSellerCostsBrokerCommission").val()),n>0&&t.push(new FeeItem("Seller Broker Compensation",n))),t};rateCalc.GetPremiumAmount=function(n){var t=0,i;if(n===LENDER){let n=rateCalc.GetPoliciesByType(rateCalc.quoteResult.QuoteResponse.Pricing.RateManual.Policies,LENDER_PREMIUM);n&&(t=rateCalc.ConvertStringToNumber(n.Premium),rateCalc.quoteType===QUOTE_TYPE_BUYER?(i=$("input[name='rbBuyerLenderPolicy']:checked").val(),i===SELLER?t=0:i===SPLIT&&(t=t/2)):(i=$("input[name='rbSellerLenderPolicy']:checked").val(),i===BUYER?t=0:i===SPLIT&&(t=t/2)))}else if(n===OWNER){let n=rateCalc.GetPoliciesByType(rateCalc.quoteResult.QuoteResponse.Pricing.RateManual.Policies,OWNER_PREMIUM);n&&(t=rateCalc.ConvertStringToNumber(n.Premium),rateCalc.quoteType===QUOTE_TYPE_BUYER?(i=$("input[name='rbBuyerOwnerPolicy']:checked").val(),i===SELLER?t=0:i===SPLIT&&(t=t/2)):(i=$("input[name='rbSellerOwnerPolicy']:checked").val(),i===BUYER?t=0:i===SPLIT&&(t=t/2)))}return t};rateCalc.GetCplEndorsementsOtherFees=function(n){var i=0,r,t;if(n===LENDER){let n=rateCalc.GetPoliciesByType(rateCalc.quoteResult.QuoteResponse.Pricing.RateManual.Policies,LENDER_PREMIUM);n&&(r=n.EndorsementList,t=rateCalc.quoteType===QUOTE_TYPE_BUYER?$("input[name='rbBuyerLenderPolicy']:checked").val():$("input[name='rbSellerLenderPolicy']:checked").val())}else if(n===OWNER){let n=rateCalc.GetPoliciesByType(rateCalc.quoteResult.QuoteResponse.Pricing.RateManual.Policies,OWNER_PREMIUM);n&&(r=n.EndorsementList,t=rateCalc.quoteType===QUOTE_TYPE_BUYER?$("input[name='rbBuyerOwnerPolicy']:checked").val():$("input[name='rbSellerOwnerPolicy']:checked").val())}return r&&$.each(r.Endorsement,function(n,r){rateCalc.quoteType===QUOTE_TYPE_BUYER?t===BUYER?i+=rateCalc.ConvertStringToNumber(r.Premium):t===SPLIT&&(i+=rateCalc.ConvertStringToNumber(r.Premium)/2):t===SELLER?i+=rateCalc.ConvertStringToNumber(r.Premium):t===SPLIT&&(i+=rateCalc.ConvertStringToNumber(r.Premium)/2)}),i};rateCalc.GetPremiumRelatedSubtotal=function(){return rateCalc.GetPremiumAmount(LENDER)+rateCalc.GetCplEndorsementsOtherFees(LENDER)+rateCalc.GetPremiumAmount(OWNER)+rateCalc.GetCplEndorsementsOtherFees(OWNER)};rateCalc.GetPremiumRelatedTaxes=function(){var n=0,t,i,r=0,u=0,f=0,e=0;let o=rateCalc.GetPoliciesByType(rateCalc.quoteResult.QuoteResponse.Pricing.RateManual.Policies,OWNER_PREMIUM);o&&(r=rateCalc.ConvertStringToNumber(o.SalesTax),o.EndorsementList&&$.each(o.EndorsementList.Endorsement,function(n,t){f+=rateCalc.ConvertStringToNumber(t.SalesTax)}));let s=rateCalc.GetPoliciesByType(rateCalc.quoteResult.QuoteResponse.Pricing.RateManual.Policies,LENDER_PREMIUM);return s&&(u=rateCalc.ConvertStringToNumber(s.SalesTax),s.EndorsementList&&$.each(s.EndorsementList.Endorsement,function(n,t){e+=rateCalc.ConvertStringToNumber(t.SalesTax)})),rateCalc.quoteType===QUOTE_TYPE_BUYER?(t=$("input[name='rbBuyerOwnerPolicy']:checked").val(),t===BUYER?n+=r+f:t===SPLIT&&(n+=(r+f)/2),i=$("input[name='rbBuyerLenderPolicy']:checked").val(),i===BUYER?n+=u+e:i===SPLIT&&(n+=(u+e)/2)):(t=$("input[name='rbSellerOwnerPolicy']:checked").val(),t===SELLER?n+=r+f:t===SPLIT&&(n+=(r+f)/2),i=$("input[name='rbSellerLenderPolicy']:checked").val(),i===SELLER?n+=u+e:i===SPLIT&&(n+=(u+e)/2)),n};rateCalc.GetLoanPayoffList=function(){var t=[],n,i;for($("#txtSellerPayoff1").val()!==""&&$("#txtSellerPayoff1").val()!==ZERO_DOLLAR&&t.push(new FeeItem("Payoff 1",rateCalc.ConvertStringToNumber($("#txtSellerPayoff1").val()))),$("#txtSellerPayoff2").val()!==""&&$("#txtSellerPayoff2").val()!==ZERO_DOLLAR&&t.push(new FeeItem("Payoff 2",rateCalc.ConvertStringToNumber($("#txtSellerPayoff2").val()))),n=0;n<rateCalc.closingSheetViewModel.additionalSellerLoanPayoffList().length;n++)rateCalc.closingSheetViewModel.additionalSellerLoanPayoffList()[n].loanPayoffAmount()&&rateCalc.closingSheetViewModel.additionalSellerLoanPayoffList()[n].loanPayoffAmount()!==""&&rateCalc.closingSheetViewModel.additionalSellerLoanPayoffList()[n].loanPayoffAmount()!==ZERO_DOLLAR&&(i=n+3,t.push(new FeeItem("Payoff "+i,rateCalc.ConvertStringToNumber(rateCalc.closingSheetViewModel.additionalSellerLoanPayoffList()[n].loanPayoffAmount()))));return t.length===0&&t.push(new FeeItem("Payoff 1",rateCalc.ConvertStringToNumber(ZERO_DOLLAR))),t};rateCalc.DisplayPdf=function(n){var i,r,t,f,u;if(n){for(i=atob(n),r=new Array(i.length),t=0;t<i.length;t++)r[t]=i.charCodeAt(t);f=new Uint8Array(r);u=new Blob([f],{type:"application/pdf"});window.navigator&&window.navigator.msSaveOrOpenBlob?window.navigator.msSaveOrOpenBlob(u,"NetSheetDocument.pdf"):window.open(URL.createObjectURL(u))}else alert("Failed to open the PDF document")};rateCalc.RoundCurrencyValue=function(n){return parseFloat(n.toLocaleString("en",{maximumFractionDigits:2,useGrouping:!1}))}