{"version":3,"file":"656.js","sources":["webpack://frontend/./src/utils/ag_grid_utils/agGridConstants.tsx","webpack://frontend/./src/utils/ag_grid_utils/agGridLicense.ts","webpack://frontend/./src/utils/ag_grid_utils/agGridUtils.tsx"],"sourcesContent":["// ag-grid table component column definition\r\nexport const wcDefaultColDef = (extraColDefOptions?: {\r\n [key: string]: unknown\r\n}) => {\r\n let defaultColDef = {\r\n flex: 1,\r\n minWidth: 120,\r\n sortable: true,\r\n resizable: true,\r\n suppressMenu: true,\r\n cellStyle: { lineHeight: '46px' }, // rowHeight in wcGridOptions - 2px\r\n cellClass: 'h-full',\r\n suppressFillHandle: true\r\n // cellStyle: {minHeight:\"100%\", alignItems:\"center\"},\r\n }\r\n return extraColDefOptions\r\n ? { ...defaultColDef, ...extraColDefOptions }\r\n : defaultColDef\r\n}\r\n// ag-grid grid options\r\nexport const wcGripOptions = (extraGripOptions?: {\r\n [key: string]: unknown\r\n}) => {\r\n let defaultGridOptions = {\r\n animateRows: true,\r\n // enableRangeSelection:true,\r\n // enableFillHandle:true,\r\n enableCellChangeFlash: true,\r\n rowSelection: 'multiple',\r\n suppressContextMenu: true,\r\n suppressMovableColumns: true,\r\n suppressMultiSort: true,\r\n suppressRowClickSelection: true,\r\n unSortIcon: true,\r\n singleClickEdit: true,\r\n undoRedoCellEditing: true,\r\n rowHeight: 48,\r\n headerHeight: 42\r\n // rowClass:[\"flex\", \"items-center\"],\r\n // enableCellTextSelection:true,\r\n }\r\n return extraGripOptions\r\n ? { ...defaultGridOptions, ...extraGripOptions }\r\n : defaultGridOptions\r\n}\r\n","//AgGrid Enterprise License\r\n\r\n// Purchased 30 Jan 2023\r\n\r\n// Allows One Licensed Developer to use ag-Grid in One Application in perpetuity. Includes a 1-year subscription to New Versions, Support and Maintenance.\r\n// Allows Licensed Developers to sub-license ag-Grid for One Application on One Production Environment in perpetuity. Includes a 1-year subscription to New Versions, Support and Maintenance.\r\n\r\nexport const agGridLicense =\r\n 'Using_this_{AG_Grid}_Enterprise_key_{AG-072365}_in_excess_of_the_licence_granted_is_not_permitted___Please_report_misuse_to_legal@ag-grid.com___For_help_with_changing_this_key_please_contact_info@ag-grid.com___{Water_Corporation}_is_granted_a_{Single_Application}_Developer_License_for_the_application_{Water_Corporation}_only_for_{2}_Front-End_JavaScript_developers___All_Front-End_JavaScript_developers_working_on_{Water_Corporation}_need_to_be_licensed___{Water_Corporation}_has_been_granted_a_Deployment_License_Add-on_for_{1}_Production_Environment___This_key_works_with_{AG_Grid}_Enterprise_versions_released_before_{29_January_2026}____[v3]_[01]_MTc2OTY0NDgwMDAwMA==59c0d1028d3fb1251cbe54fdc494b2a3'\r\n","import { useState, useEffect, useRef } from 'react'\r\nimport { renderToString } from 'react-dom/server'\r\nimport { convertToMoney, isABNValid } from 'utils'\r\nimport { Icon } from 'utils/Icon'\r\n\r\n/**\r\n *\r\n * @param value - the value to be formatted\r\n * @param delay number in ms to wait\r\n * @returns value\r\n */\r\nexport const useDebounce = (value: string, delay: number) => {\r\n // State and setters for debounced value\r\n const [debouncedValue, setDebouncedValue] = useState(value)\r\n\r\n useEffect(\r\n () => {\r\n // Update debounced value after delay\r\n const handler = setTimeout(() => {\r\n setDebouncedValue(value)\r\n }, delay)\r\n // Cancel the timeout if value changes (also on delay change or unmount)\r\n // This is how we prevent debounced value from updating if value is changed ...\r\n // .. within the delay period. Timeout gets cleared and restarted.\r\n return () => {\r\n clearTimeout(handler)\r\n }\r\n },\r\n [value, delay] // Only re-call effect if value or delay changes\r\n )\r\n return debouncedValue\r\n}\r\n\r\n/* useComponentWillMount:\r\n1. useRef is a hook that returns a mutable ref object whose .current property is initialized to the passed argument (initialValue).\r\n2. useEffect is a hook that calls a provided function (func) after the component renders for the first time.\r\n3. useEffect will only call func if willMount.current is true.\r\n4. willMount.current is set to false after the first render.\r\n5. func is called.\r\n6. The return value of useEffect is a cleanup function that is used to undo any work that was done in the effect.\r\n7. The cleanup function is not called until the component is unmounted. */\r\nexport const useComponentWillMount = (func: () => void) => {\r\n const willMount = useRef(true)\r\n if (willMount.current) {\r\n func()\r\n }\r\n willMount.current = false\r\n}\r\n\r\n/**\r\n *\r\n * @param dateString - the date string to be formatted\r\n * @returns date - a new date object with the date described in the dateString parameter\r\n */\r\nexport const dateFromWatercorpDate = (dateString: string): Date => {\r\n let year = +dateString.substring(0, 4)\r\n let month = +dateString.substring(4, 6) - 1\r\n let day = +dateString.substring(6, 8)\r\n let date = new Date(year, month, day)\r\n return date\r\n}\r\n\r\n// Returns a date object from a string in the format dd/mm/yyyy\r\nexport const simpleDateRenderer = (props: any) => {\r\n let formattedDate = new Date(props.value).toLocaleDateString('en-AU', {\r\n day: '2-digit',\r\n month: '2-digit',\r\n year: '2-digit'\r\n })\r\n if (!props?.value || formattedDate?.includes('1970')) {\r\n return ''\r\n }\r\n return {formattedDate}\r\n}\r\n\r\n// Returns formated date with link and pdf icon eg pdf icon 02 Feb 2022\r\nexport const pdfLinkDate = (props: any) => {\r\n let formattedDateNumericYear = new Date(props.value)\r\n .toLocaleDateString(undefined, {\r\n month: 'short',\r\n day: '2-digit',\r\n year: 'numeric'\r\n })\r\n .replace(',', '')\r\n\r\n if (!props?.value || formattedDateNumericYear?.includes('1970')) {\r\n return ''\r\n }\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n {formattedDateNumericYear}\r\n \r\n )\r\n}\r\n\r\n// Returns formated date in dd/MMM/YYYY e.g. 02 Feb 2022\r\nexport const billDateFormat = (props: any) => {\r\n let formattedDateNumericYear = new Date(props.value)\r\n .toLocaleDateString(undefined, {\r\n month: 'short',\r\n day: '2-digit',\r\n year: 'numeric'\r\n })\r\n .replace(',', '')\r\n\r\n if (!props?.value || formattedDateNumericYear?.includes('1970')) {\r\n return ''\r\n }\r\n\r\n return {formattedDateNumericYear}\r\n}\r\n\r\n/**\r\n *\r\n * @param d - the date to be formatted\r\n * @returns - a string of the date in the Watercorp specific format\r\n */\r\nexport const toWatercorpDateFormat = (d: Date): string => {\r\n let date =\r\n Object.prototype.toString.call(d) == '[object Date]' ? d : new Date(d)\r\n let dString = date.toLocaleDateString('en-US', {\r\n year: 'numeric',\r\n month: '2-digit',\r\n day: '2-digit'\r\n })\r\n return `${dString.slice(-4)}${dString.slice(0, 2)}${dString.slice(-7, -5)}`\r\n}\r\n\r\n/**\r\n *\r\n * @param params - the params to be formatted\r\n * @returns - a string of the params in the Australian specific date format\r\n */\r\nexport const dateValueFormatter = (params: any): string => {\r\n if (!params.value) {\r\n return 'N/A'\r\n }\r\n let dString = new Date(params.value).toLocaleDateString('en-AU', {\r\n year: 'numeric',\r\n month: '2-digit',\r\n day: '2-digit'\r\n })\r\n return dString\r\n}\r\n\r\n/**\r\n *\r\n * @returns - a template string of a right aligned header cell\r\n */\r\nexport function rightAlignedColumnHeader() {\r\n return {\r\n template: `\r\n
\r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n \r\n
\r\n `\r\n }\r\n}\r\n/**\r\n *\r\n * @param children - the children to be contained in the cell\r\n * @returns - a template string of a special header cell\r\n */\r\nexport function wcSpecialColumnHeader(children?: any) {\r\n return {\r\n template: `\r\n
\r\n \r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n ${children ? renderToString(children) : ''}\r\n
\r\n
\r\n `\r\n }\r\n}\r\n\r\n// export function wcHeaderTooltipIcon() {\r\n// return (\r\n// {\r\n// template:\r\n// `\r\n//
\r\n// \r\n//
\r\n// \r\n// \r\n// \r\n// \r\n// \r\n// \r\n// \r\n// \r\n// \r\n//
\r\n//
\r\n// `\r\n// }\r\n// )\r\n// }\r\n/**\r\n *\r\n * @returns - a template string of a header tooltip icon\r\n */\r\nexport function wcHeaderTooltipIcon() {\r\n return {\r\n template: `\r\n
\r\n \r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n
\r\n `\r\n }\r\n}\r\n\r\n/**\r\n *\r\n * @param params - the ag-grid params to be sorted\r\n * @returns -1 if the first param is less than the second, 0 if they are equal, 1 if the first is greater than the second\r\n */\r\nexport function alphabeticalGroupSort(params: any) {\r\n let a = ((params.nodeA.key as string) ?? '')?.toLowerCase()\r\n let b = ((params.nodeB.key as string) ?? '')?.toLowerCase()\r\n if (a === 'ungrouped properties') {\r\n a = '~'\r\n }\r\n if (b === 'ungrouped properties') {\r\n b = '~'\r\n }\r\n return a < b ? -1 : a > b ? 1 : 0\r\n}\r\n\r\n/**\r\n *\r\n * @param params - the ag-grid params\r\n * @returns - the value of the cell or if the value is undefined or null, N/A\r\n */\r\nexport const returnNAifNull = (params: any) => {\r\n return params?.value ? params?.value : 'N/A'\r\n}\r\n\r\n/**\r\n *\r\n * @param props - the ag-grid props\r\n * @returns an error message to display in the table\r\n */\r\nexport const NetworkRequestFailed = (props: { errorText: string }) => {\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n

{props.errorText}

\r\n \r\n )\r\n}\r\n\r\n/**\r\n *\r\n * @param customContent - the custom content message to be displayed in the button\r\n * @returns a button to linl to the custom content\r\n */\r\nexport const editableValueRenderer = (customContent?: string) => {\r\n if (customContent) {\r\n return (props: any) => {\r\n const cellValue = props.valueFormatted\r\n ? props.valueFormatted\r\n : props.value\r\n return cellValue ? (\r\n \r\n ) : (\r\n \r\n \r\n \r\n \r\n {customContent}\r\n \r\n )\r\n }\r\n }\r\n return (props: any) => {\r\n const cellValue = props.valueFormatted ? props.valueFormatted : props.value\r\n return cellValue ? (\r\n \r\n ) : (\r\n \r\n \r\n \r\n \r\n Not supplied\r\n \r\n )\r\n }\r\n}\r\n\r\n/**\r\n *\r\n * @param props - { value: string, valueFormatted: string, customContent: string } from ag-grid\r\n * @returns - a cell renderer that renders a link to the supplied value or not supplied if value is null\r\n */\r\nexport const editableValueDropdownRenderer = (props: any) => {\r\n const cellValue = props.valueFormatted ? props.valueFormatted : props.value\r\n if (cellValue === 'N/A' || cellValue === 'NA') {\r\n return N/A\r\n }\r\n return cellValue ? (\r\n \r\n \r\n \r\n \r\n {cellValue}\r\n \r\n \r\n ) : (\r\n \r\n \r\n \r\n \r\n Not supplied\r\n \r\n \r\n )\r\n}\r\n\r\n// UI CR and DR prepended to the value\r\nexport const accountBalanceIndicator = (params: any) => {\r\n if (!params) {\r\n return N/A\r\n }\r\n let isPositive = params?.value[0] === '+' ?? false\r\n let value = params?.value.replace('-', 'DR ').replace('+', 'CR ') ?? ''\r\n let IsOverdue = params?.data?.IsOverdue\r\n let colorClass = isPositive\r\n ? 'text-validation-green'\r\n : IsOverdue\r\n ? 'text-validation-red'\r\n : 'text-corporate-blue-6'\r\n return {value ?? ''}\r\n}\r\n\r\n/**\r\n *\r\n * @param params - { value: string, valueFormatted: string, customContent: string } from ag-grid\r\n * @returns - a cell renderer that renders a money value or N/A if value is null\r\n */\r\nexport const accountBalanceIndicatorAlternative = (params: { valueFormatted: string, value: number, data: Record }) => {\r\n let cellValue = params.valueFormatted ? Number(params.valueFormatted) : params.value\r\n if (!cellValue) {\r\n return N/A\r\n }\r\n // Bill payment history table fix\r\n // changing from > to less than, as the value is flipped wrong way in the api\r\n let isPositive = (cellValue ?? 0) < 0\r\n let isZero = cellValue === 0;\r\n let isNegative = params?.data?.IsOverdue\r\n let value = `${isPositive ? 'CR' : isZero ? '' : 'DR'} ${convertToMoney(\r\n cellValue\r\n )}`.replace('-', '')\r\n let colorClass = isPositive\r\n ? 'text-validation-green'\r\n : isNegative\r\n ? 'text-validation-red'\r\n : 'text-corporate-blue-6'\r\n return {cellValue ? value : ''}\r\n}\r\n"],"names":["wcDefaultColDef","extraColDefOptions","defaultColDef","agGridLicense","dateFromWatercorpDate","dateString","Date","simpleDateRenderer","props","formattedDate","pdfLinkDate","formattedDateNumericYear","undefined","toWatercorpDateFormat","d","dString","date","Object","dateValueFormatter","params","rightAlignedColumnHeader","wcHeaderTooltipIcon","alphabeticalGroupSort","_this","_this1","a","b","returnNAifNull","NetworkRequestFailed","editableValueDropdownRenderer","cellValue","accountBalanceIndicator","_params_data","isPositive","value","IsOverdue","accountBal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