"use strict";
// eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair
/* eslint-disable unicorn/prefer-module */
Object.defineProperty(exports, "__esModule", { value: true });
(() => {
const los = exports.los;
const searchFilterFormElement = document.querySelector('#form--searchFilters');
const searchResultsContainerElement = document.querySelector('#container--searchResults');
const limit = Number.parseInt(document.querySelector('#searchFilter--limit').value, 10);
const offsetElement = document.querySelector('#searchFilter--offset');
function renderLotOccupancies(rawResponseJSON) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
const responseJSON = rawResponseJSON;
if (responseJSON.lotOccupancies.length === 0) {
// eslint-disable-next-line no-unsanitized/property
searchResultsContainerElement.innerHTML = `
There are no ${los.escapedAliases.occupancy} records that meet the search criteria.
`;
return;
}
const resultsTbodyElement = document.createElement('tbody');
const nowDateString = cityssm.dateToString(new Date());
for (const lotOccupancy of responseJSON.lotOccupancies) {
let occupancyTimeHTML = '';
if (lotOccupancy.occupancyStartDateString <= nowDateString &&
(lotOccupancy.occupancyEndDateString === '' ||
lotOccupancy.occupancyEndDateString >= nowDateString)) {
occupancyTimeHTML = `
`;
}
else if (lotOccupancy.occupancyStartDateString > nowDateString) {
occupancyTimeHTML = `
`;
}
else {
occupancyTimeHTML = `
`;
}
let occupantsHTML = '';
for (const occupant of (_a = lotOccupancy.lotOccupancyOccupants) !== null && _a !== void 0 ? _a : []) {
occupantsHTML += `
${cityssm.escapeHTML((_e = occupant.occupantName) !== null && _e !== void 0 ? _e : '')}
${cityssm.escapeHTML((_f = occupant.occupantFamilyName) !== null && _f !== void 0 ? _f : '')}
`;
}
const feeTotal = ((_h = (_g = lotOccupancy.lotOccupancyFees) === null || _g === void 0 ? void 0 : _g.reduce((soFar, currentFee) => {
var _a, _b, _c;
return (soFar +
(((_a = currentFee.feeAmount) !== null && _a !== void 0 ? _a : 0) + ((_b = currentFee.taxAmount) !== null && _b !== void 0 ? _b : 0)) *
((_c = currentFee.quantity) !== null && _c !== void 0 ? _c : 0));
}, 0)) !== null && _h !== void 0 ? _h : 0).toFixed(2);
const transactionTotal = ((_k = (_j = lotOccupancy.lotOccupancyTransactions) === null || _j === void 0 ? void 0 : _j.reduce((soFar, currentTransaction) => {
return soFar + currentTransaction.transactionAmount;
}, 0)) !== null && _k !== void 0 ? _k : 0).toFixed(2);
let feeIconHTML = '';
if (feeTotal !== '0.00' || transactionTotal !== '0.00') {
feeIconHTML = `
`;
}
// eslint-disable-next-line no-unsanitized/method
resultsTbodyElement.insertAdjacentHTML('beforeend', `
|
${occupancyTimeHTML}
|
${cityssm.escapeHTML((_l = lotOccupancy.occupancyType) !== null && _l !== void 0 ? _l : '')}
#${lotOccupancy.lotOccupancyId}
|
${((_m = lotOccupancy.lotId) !== null && _m !== void 0 ? _m : -1) === -1
? `(No ${los.escapedAliases.Lot})`
: `${cityssm.escapeHTML((_p = lotOccupancy.lotName) !== null && _p !== void 0 ? _p : '')}`}
${cityssm.escapeHTML((_q = lotOccupancy.mapName) !== null && _q !== void 0 ? _q : '')}
|
${lotOccupancy.occupancyStartDateString}
|
${lotOccupancy.occupancyEndDate
? lotOccupancy.occupancyEndDateString
: '(No End Date)'}
|
${occupantsHTML === ''
? ''
: ``}
|
${feeIconHTML}
|
${lotOccupancy.printEJS
? `
`
: ''} |
`);
}
// eslint-disable-next-line no-unsanitized/property
searchResultsContainerElement.innerHTML = `