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E,EAAAoE,UAAA,iBAYNO,EAAAA,QAAMvD,OAAAsD,yBAAA1E,EAAAoE,UAAA,iBAAApE,EAAAoE,YAAAD,EAAAA,EAAAA,GAAAnE,EAAAoE,UAAA,iBAoDNO,EAAAA,QAAMvD,OAAAsD,yBAAA1E,EAAAoE,UAAA,iBAAApE,EAAAoE,WAxJuEQ,EAwJvE5E,KAAA4E,IAjLwBC,EAAAA,EAAAA,sBAAAC,EAAArF,E","sources":["./components/filters/filters-manager/index.hbs","./components/filters/filters-manager/index.ts"],"sourcesContent":["import { precompileTemplate } from \"@ember/template-compilation\";\nexport default precompileTemplate(\"
\\n {{#each this.filterBlocks as |filterBlock|}}\\n
\\n {{#if filterBlock.selected}}\\n
\\n \\n
\\n {{/if}}\\n\\n {{#if filterBlock.showWarning}}\\n
\\n \\n
\\n {{/if}}\\n\\n
\\n {{#each filterBlock.icons as |icon|}}\\n \\n {{/each}}\\n
\\n\\n \\n\\n {{#if (and filterBlock.isComplete (is-fulfilled @filterCounts))}}\\n \\n {{else}}\\n

\\n {{#if (and (is-fulfilled @filterCounts) filterBlock.isCached)}}\\n {{filterBlock.count}}\\n {{else if (and (is-fulfilled @filterCounts) (is-fulfilled @uncachedFilterCounts))}}\\n {{filterBlock.count}}\\n {{else}}\\n \\n {{/if}}\\n

\\n {{/if}}\\n\\n

{{filterBlock.label}}

\\n\\n {{#if filterBlock.subFilterDropdownItems}}\\n \\n <:default as |id classes togglePopoverVisibility|>\\n \\n
\\n \\n
\\n \\n \\n \\n {{/if}}\\n
\\n {{/each}}\\n
\",{ moduleName: \"customer-site/components/filters/filters-manager/index.hbs\" })","/* import __COLOCATED_TEMPLATE__ from './index.hbs'; */\nimport Component from '@glimmer/component';\nimport { isEnterCode } from '@adc/ember-utils/utils/a11y';\nimport { getObjProperties } from '@adc/ember-utils/utils/ember-helpers';\nimport EmberObject, { computed, action } from '@ember/object';\nimport { inject as service } from '@ember/service';\nimport { isEmpty, typeOf } from '@ember/utils';\nimport { intlPath } from '@adc/i18n/path';\nimport { default as DropdownSelectItem, SELECTED, UNSELECTED } from '@adc/ui-components/utils/dropdown-select-item';\n\nimport './_style.scss';\nimport type ADCIntlService from '@adc/i18n/services/adc-intl';\nimport type SingleSystemFilter from 'customer-site/models/commercial/single-system-filter';\nimport type Filter from 'customer-site/models/enterprise/locations/filter';\nimport type FilterCount from 'customer-site/models/enterprise/locations/filter-count';\nimport type ContextManager from 'customer-site/services/context-manager';\n\ntype FilterBlock = EmberObject & {\n id: string | number;\n icons: string[];\n type: string;\n css: string;\n showWarning: boolean;\n isComplete: boolean;\n isCached: boolean;\n label: string;\n subFilterDropdownItems: DropdownSelectItem[];\n selected: boolean;\n count?: number;\n};\n\ndeclare interface FiltersManagerSignature {\n Element: HTMLDivElement;\n Args: {\n changeFilter: (a?: Record) => void;\n filters: ADCAsyncStoreFindAll | Awaited>;\n initialFilters: string;\n filterCounts: ADCAsyncStoreFindAll;\n uncachedFilterCounts?: ADCAsyncStoreFindAll;\n showWideFilters?: boolean;\n };\n}\n\n/**\n * Attempt to match filter counts with their filters, if the data has been loaded.\n */\nfunction setSingleFilterCount(this: FiltersManager, filterBlock: FilterBlock): void {\n // Get the corresponding filter counts based on whether the filter block is cached\n const filterCountsToSet = filterBlock.isCached ? this.args.filterCounts : this.args.uncachedFilterCounts;\n\n // Do nothing if the data has not fully loaded yet.\n if (!filterCountsToSet || filterCountsToSet.isPending) {\n return;\n }\n\n // set counts based on associated filter & sub-filters\n filterCountsToSet\n .filter((fc) => fc.id.split('-')[0] === filterBlock.id)\n .forEach((filterCount: FilterCount) => setSingleFilterCountHelper(filterBlock, filterCount));\n}\n\n/**\n * sets the filter or sub filter count for this block and filter\n */\nfunction setSingleFilterCountHelper(filterBlock: FilterBlock, filterCount: FilterCount): void {\n if (!filterBlock) {\n return;\n }\n\n const subFilterId = filterCount.id.split('-')[1];\n\n // If we have a subfilter, we need to handle that accordingly. Otherwise, just update the filter's count.\n if (subFilterId) {\n // Get relevant data about the subfilter\n const subFilterDropdownItem = filterBlock.subFilterDropdownItems.findBy('value', subFilterId),\n subFilterName = `${filterCount.name} (${filterCount.count})`;\n\n // If this subfilter has not been added to the dropdown yet, do so. Otherwise, just update the name.\n if (!subFilterDropdownItem) {\n filterBlock.set('subFilterDropdownItems', [\n ...filterBlock.subFilterDropdownItems,\n DropdownSelectItem.create({\n name: subFilterName,\n value: subFilterId,\n state: UNSELECTED\n })\n ]);\n } else {\n subFilterDropdownItem.set('name', subFilterName);\n }\n } else {\n filterBlock.setProperties({\n count: filterCount.count,\n isComplete: filterCount.isComplete,\n showWarning: filterCount.showWarning,\n label: filterCount.name,\n icons: filterCount.icons ? filterCount.icons : filterBlock.icons\n });\n }\n}\n\n/**\n * Resets all sub-filters on the given filter block to unselected.\n */\nfunction deselectAllSubFilters(filterBlock: FilterBlock): void {\n // We have to recreate the subfilters, otherwise the subFiltersChanged action won't behave properly.\n const newSubFilters = filterBlock.subFilterDropdownItems.map(({ name, value }) =>\n DropdownSelectItem.create({\n name,\n value,\n state: UNSELECTED\n })\n );\n\n filterBlock.subFilterDropdownItems = newSubFilters;\n}\n\n/**\n * @classdesc Manages a set of filters so that only one filter of a given type can be selected.\n */\n@intlPath({ path: 'filters/filter-manager' })\nexport default class FiltersManager extends Component {\n @service declare intl: ADCIntlService;\n @service declare contextManager: ContextManager;\n\n /**\n * The initial filters in object form.\n */\n @computed('args.initialFilters')\n get computedInitialFilters(): Record {\n const { initialFilters } = this.args;\n\n if (isEmpty(initialFilters) || typeOf(initialFilters) !== 'string') {\n return {} as Record;\n }\n\n try {\n return JSON.parse(initialFilters);\n } catch {\n return {} as Record;\n }\n }\n\n /**\n * The filter blocks to be displayed.\n */\n @computed('args.{filters,filterCounts.@each.count}', 'computedInitialFilters')\n get filterBlocks(): FilterBlock[] {\n // These are the filter models that have been passed into this component.\n const filters = this.args.filters;\n\n // Do nothing if we haven't received any filter models yet.\n if (!filters) {\n return [];\n }\n\n // Loop over the filter models and create the filter blocks.\n return filters.map((filter) => {\n const { id, type, css, icons, name, subFilters, showWarning, isComplete, isCached } = filter,\n isFilterSelected = Object.keys(this.computedInitialFilters).includes(id);\n\n // If this filter has subFilters, create DropdownSelectItems for them.\n const subFilterDropdownItems = (subFilters || []).map((subFilter) => {\n const [subFilterCompoundId, subFilterName] = getObjProperties(subFilter, 'id', 'name'),\n // The model has an id of filterType-subFilterId so that it is unique across subFilter models when sent from the back-end,\n // but we don't need it to be unique across filterTypes here, so just get the subFilterId.\n subFilterId = subFilterCompoundId.split('-')[1],\n isSubFilterSelected =\n isFilterSelected && this.computedInitialFilters[parseInt(id)].includes(subFilterId)\n ? SELECTED\n : UNSELECTED;\n\n // Create the DropdownSelectItem now that we know whether or not it was previously selected.\n return DropdownSelectItem.create({\n name: `${subFilterName}`,\n value: subFilterId,\n state: isSubFilterSelected\n });\n });\n // Create the filter block now that we have any subFilterDropdownItems.\n const filterBlock: FilterBlock = EmberObject.create({\n // Do not copy this deprecated usage. If you see this, please fix it\n // @ts-expect-error TypeScript doesn't understand EmberObject, please refactor to not use EmberObject.\n id,\n icons,\n type,\n css,\n showWarning,\n isComplete,\n isCached,\n label: name,\n subFilterDropdownItems,\n selected: isFilterSelected\n }) as FilterBlock;\n\n setSingleFilterCount.call(this, filterBlock);\n\n return filterBlock;\n });\n }\n\n /**\n * Returns the appropriate string used for the aria-label depending on if it's mobile.\n */\n get ariaLabel(): string {\n const labelWeb = this.intl.t('@adc/ui-components.triggerDropdown');\n const labelMobile = this.intl.t('generic.triggerDropdownMobile');\n\n return this.contextManager.isMobileApp ? labelMobile : labelWeb;\n }\n\n /**\n * Attempt to match filter counts with their filters, if the data has been loaded.\n * Only the cached or uncached filter counts get set at a time based on the parameter.\n */\n @action setFilterCounts(filterCountsToSet: ADCAsyncStoreFindAll): void {\n // Do nothing if the data has not fully loaded yet.\n if (!filterCountsToSet || filterCountsToSet.isPending || !this.filterBlocks) {\n return;\n }\n\n filterCountsToSet.forEach((filterCount: FilterCount) => {\n // Find the filter block that is associated with this filter count\n const filterId = filterCount.id.split('-')[0],\n filterBlock = this.filterBlocks.findBy('id', filterId);\n\n setSingleFilterCountHelper.call(this, filterBlock, filterCount);\n });\n }\n\n /**\n * Handles a subFilter (or multiple on one filter) changing selection by updating the filterBlock so that it's aware that it's now selected,\n * and then acts upon that filter selection.\n */\n @action subFiltersChanged(filterBlock: FilterBlock): void {\n const areSubItemsSelected = filterBlock.subFilterDropdownItems.some((item) => item.state === SELECTED);\n\n filterBlock.set('selected', areSubItemsSelected || filterBlock.selected);\n\n // Now handle the filter changing, but don't toggle selection.\n this.filterChanged(filterBlock, false);\n }\n\n /**\n * Handles filter selection/deselection.\n */\n @action filterChanged(changedFilterBlock: FilterBlock, forceSelectionToggle = true): void {\n // Toggle selection of the changedFilterBlock, if requested.\n if (forceSelectionToggle) {\n changedFilterBlock.toggleProperty('selected');\n }\n\n const isSelected = changedFilterBlock.selected;\n\n // The old set of filterBlocks that we had before a selection change was made. We need to update them so they have the same selections as the newFilterBlocks.\n const filterBlocks = this.filterBlocks;\n\n // If the item is selected, find other items that have the same type but that don't have the same id and deselect those items.\n // This will deselect mutually exclusive filters.\n // Otherwise, deselect all the subfilters for the filter.\n if (isSelected) {\n // Deselect all mutually exclusive filters and sub-filters.\n filterBlocks\n .filterBy('type', changedFilterBlock.type)\n .rejectBy('id', changedFilterBlock.id)\n .forEach((filter) => {\n filter.set('selected', false);\n deselectAllSubFilters.call(this, filter);\n });\n } else {\n // We're deselecting the filter, so we should deselect all subfilters as well.\n deselectAllSubFilters.call(this, changedFilterBlock);\n }\n\n // Create the newFilters array, with null values for all the filter types.\n const newFilters = filterBlocks\n .filterBy('selected')\n .reduce((newFilters: Record, { id, subFilterDropdownItems }) => {\n const subFilters = [];\n\n if (!isEmpty(subFilterDropdownItems)) {\n const selectedItems = subFilterDropdownItems.filterBy('isFullySelected');\n subFilters.push(\n ...(isEmpty(selectedItems) ? subFilterDropdownItems : selectedItems).mapBy('value')\n );\n }\n\n newFilters[id] = subFilters;\n return newFilters;\n }, {});\n\n // Send a notification that the filters have changed.\n this.args.changeFilter?.(newFilters);\n }\n\n /*\n * Called on input keydown.\n */\n @action handleKeyDown(changedFilterBlock: FilterBlock, evt: KeyboardEvent): void {\n if (isEnterCode(evt.key)) {\n evt.preventDefault();\n this.filterChanged(changedFilterBlock);\n }\n }\n}\n\ndeclare module '@glint/environment-ember-loose/registry' {\n export default interface Registry {\n 'Filters::FiltersManager': typeof FiltersManager;\n }\n}\n"],"names":["createTemplateFactory","scope","on","fn","svgSymbol_","didUpdate_","isFulfilled_","and_","spinnerSvg_","dropdownSelectMultiSelect_","buttonSimple_","t_","setSingleFilterCount","filterBlock","filterCountsToSet","isCached","this","args","filterCounts","uncachedFilterCounts","isPending","filter","fc","id","split","forEach","filterCount","setSingleFilterCountHelper","subFilterId","subFilterDropdownItem","subFilterDropdownItems","findBy","subFilterName","concat","name","count","set","DropdownSelectItem","create","value","state","UNSELECTED","setProperties","isComplete","showWarning","label","icons","deselectAllSubFilters","newSubFilters","map","_ref","FiltersManager","_dec","intlPath","path","_dec2","computed","_dec3","_class2","Component","constructor","arguments","_initializerDefineProperty","_descriptor","_descriptor2","computedInitialFilters","initialFilters","isEmpty","typeOf","JSON","parse","_unused","filterBlocks","filters","type","css","subFilters","isFilterSelected","Object","keys","includes","subFilter","subFilterCompoundId","getObjProperties","isSubFilterSelected","parseInt","SELECTED","EmberObject","selected","call","ariaLabel","labelWeb","intl","t","labelMobile","contextManager","isMobileApp","setFilterCounts","filterId","subFiltersChanged","areSubItemsSelected","some","item","filterChanged","changedFilterBlock","_this$args$changeFilt","_this$args","length","undefined","toggleProperty","isSelected","filterBy","rejectBy","newFilters","reduce","_ref2","selectedItems","push","mapBy","changeFilter","handleKeyDown","evt","isEnterCode","key","preventDefault","_applyDecoratedDescriptor","prototype","service","configurable","enumerable","writable","initializer","getOwnPropertyDescriptor","action","_class","setComponentTemplate","TEMPLATE"],"sourceRoot":""}