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E,cAAcvE,QAAQgB,iBAAiB,eAAgBtB,EAC9D,EAIAW,SAASoE,iBAAoC,iBAAiBxF,SAAQ,SAAAyF,GACpE,IAAIR,EACJ,IACEA,EAAUS,KAAKC,MAAMF,EAAOG,QAAQX,SAAW,KAIjD,CAHE,MAAO5E,GACPlB,QAAQ0G,MAAMxF,GACd4E,EAAU,CAAC,CACb,CACK,IAAIxG,EAAQgH,EAAQR,EAC3B,G","sources":["webpack://slaask/./app/packs/entrypoints/Choices.ts","webpack://slaask/./app/packs/src/shared/Choices/Choices.ts"],"sourcesContent":["import { Choices } from '@/shared/Choices'\n\nexport default Choices\n","import './Choices.scss'\nimport OriginalChoices from 'choices.js'\nimport Container from 'choices.js/src/scripts/components/container.js'\n\n/*\n\n This file provides the Choices module, augmented with custom options and\n behaviors.\n\n Modifications:\n - The constructor is overridden to allow custom configs without emitting a\n warning in the console\n - The dropdown will be aware of a container with its overflow hidden, and\n will shrink to make sure it is fuly visible\n\n New config properties:\n - positionFixed: (boolean) The dropdown will be positionned using \"fixed\" to\n allow overflowing even if a container has its overflow hidden\n\n Config defaults:\n - searchEnabled: true\n - silent: true\n - position: 'auto'\n - positionFixed: false\n\n*/\n\n/*\n\n AUTO INIT\n =========\n\n For an easier instanciation, select tags are automatically initialized with\n Choices when they have the .make-choices class.\n\n ```html\n \n ```\n\n*/\n\n/* CUSTOM OPTIONS */\n\nexport type AugmentedOptions = Required & {\n /**\n * This will allow the dropdown to overflow even inside a container\n * having its overflow hidden.\n *\n * **Input types affected:** select-one, select-multiple\n *\n * @default false\n */\n positionFixed: boolean\n}\n\nconst CUSTOM_CONFIGS = ['positionFixed']\n\n/* TYPING */\n\nexport type Choice = NonNullable[0]\n\nexport type ChoicesGroup = {\n label: string,\n id: string,\n disabled: boolean,\n choices: Choice[]\n}\n\nclass AugmentedChoicesConstructor extends OriginalChoices {\n constructor (\n selectorOrElement: string | HTMLInputElement | HTMLSelectElement,\n userConfig?: Partial\n ) {\n if (console && console.warn) {\n const warnBackup = console.warn\n try {\n /**\n * Override the \"unknown config\" warning.\n * This function will remove the custom configs declare above from the\n * unknown configs list. The warning will only be emitted if other unknown\n * configs are still left.\n */\n console.warn = function (...args: unknown[]) {\n if (args[0] !== 'Unknown config option(s) passed') {\n warnBackup(...args)\n } else {\n try {\n const configs = (args[1] as string).split(', ')\n const unknownConfigs: string[] = []\n configs.forEach(config => {\n if (CUSTOM_CONFIGS.indexOf(config) === -1) {\n unknownConfigs.push(config)\n }\n })\n if (unknownConfigs.length > 0) {\n warnBackup(args[0], unknownConfigs.join(', '))\n }\n } catch (e) {\n warnBackup(e)\n }\n }\n }\n super(selectorOrElement, userConfig)\n console.warn = warnBackup\n } catch (e) {\n console.warn = warnBackup\n throw e\n }\n } else super(selectorOrElement, userConfig)\n }\n}\n\ndeclare class AugmentedChoices extends AugmentedChoicesConstructor {\n declare static readonly defaults: {\n readonly options: Partial\n readonly templates: typeof OriginalChoices.defaults.templates\n }\n\n declare readonly config: AugmentedOptions\n\n get containerOuter (): Container\n get dropdown (): Container\n\n getValue (valueOnly: boolean): string | string[]\n getValue (): Choice | Choice[]\n getValue (\n ...args: Parameters\n ): (string | Choice) | (string | Choice)[]\n}\n\nexport const Choices = AugmentedChoicesConstructor as unknown as typeof AugmentedChoices\nexport type Choices = AugmentedChoices\n\ndeclare global {\n interface HTMLSelectElement {\n choices?: Choices\n }\n\n interface HTMLInputElement {\n choices?: Choices\n }\n}\n\n/* POSITIONING */\n\n/**\n * Makes sure the dropdown does not touch the edge, a small margin will be left\n */\nconst marginFromEdge = 4\n\n/**\n * @param element Element where to start to bubble through DOM\n * @returns The first container having its overflow hidden\n */\nconst getOverflow = (element: HTMLElement): HTMLElement => {\n let parent: HTMLElement | null = element\n const path: HTMLElement[] = []\n while (parent = parent.parentElement) { // eslint-disable-line no-cond-assign\n path.push(parent)\n }\n for (let i = 0; i < path.length; i++) {\n const style = window.getComputedStyle(path[i])\n if (style['overflow'] != 'visible' || style['overflow-x'] != 'visible' || style['overflow-y'] != 'visible') { // eslint-disable-line dot-notation\n return path[i]\n }\n }\n return document.body\n}\n\nconst findRequiredZIndex = (reference: Element): number => {\n let zIndex = 0\n const path: Element[] = []\n let parent: Element | null = reference\n while (parent = parent.parentElement) { // eslint-disable-line no-cond-assign\n path.push(parent)\n }\n for (let i = path.length - 1; i >= 0; i--) {\n const style = window.getComputedStyle(path[i])\n if (style['position'] != 'static' && style['z-index'] != 'auto') { // eslint-disable-line dot-notation\n zIndex = parseInt(style['z-index']) + 1\n break\n }\n }\n return zIndex\n}\n\n/**\n * Handles dropdown position (top, bottom), the height, and whether it should\n * use fixed position or not.\n */\nconst handleDropdownPosition = function (this: HTMLSelectElement | HTMLInputElement) {\n const choices = this.choices\n if (choices) {\n const position: string = choices.config.position\n const dropdownElement = choices.dropdown.element\n const containerElement = choices.containerOuter.element\n const overflowElement = choices.config.positionFixed ? (document.getElementById('body') || document.body) : getOverflow(dropdownElement)\n\n this.addEventListener('hideDropdown', () => {\n dropdownElement.style.position = ''\n dropdownElement.style.bottom = ''\n dropdownElement.style.top = ''\n dropdownElement.style.width = ''\n dropdownElement.style.left = ''\n choices.containerOuter.position = position\n }, {\n once: true\n })\n\n dropdownElement.style.height = ''\n\n if (choices.config.positionFixed) {\n const parentElement = dropdownElement.parentElement\n\n if (parentElement) {\n dropdownElement.style.position = 'fixed'\n const parentRect = parentElement.getBoundingClientRect()\n dropdownElement.style.width = parentRect.width + 'px'\n dropdownElement.style.left = parentRect.x + 'px'\n dropdownElement.style.zIndex = findRequiredZIndex(parentElement)\n let isBottom = position == 'bottom'\n isBottom ||= position == 'auto' && !choices.containerOuter.isFlipped\n if (isBottom) {\n dropdownElement.style.top = (parentRect.y + parentRect.height) + 'px'\n } else {\n dropdownElement.style.bottom = (window.innerHeight - parentRect.y) + 'px'\n }\n hideOnScroll.call(this)\n }\n } else {\n const overflowRect = overflowElement == document.documentElement\n ? { top: 0, bottom: document.documentElement.scrollHeight }\n : overflowElement.getBoundingClientRect()\n const dropdownRect = dropdownElement.getBoundingClientRect()\n const containerRect = containerElement.getBoundingClientRect()\n\n // Takes dropdown margins into account\n const defaultSpaceTaken = choices.containerOuter.isFlipped\n ? containerRect.top - dropdownRect.top\n : dropdownRect.bottom - containerRect.bottom\n\n const availableSpaceBelow = overflowRect.bottom - containerRect.bottom\n const availableSpaceAbove = containerRect.top - overflowRect.top\n\n const getNewHeight = (availableSpace) => {\n const overflowingHeight = defaultSpaceTaken - availableSpace\n return dropdownRect.height - overflowingHeight - marginFromEdge + 'px'\n }\n\n if (position == 'auto') {\n if (defaultSpaceTaken > availableSpaceBelow) {\n if (defaultSpaceTaken <= availableSpaceAbove) {\n choices.containerOuter.position = 'top'\n } else {\n if (availableSpaceAbove > availableSpaceBelow) choices.containerOuter.position = 'top'\n else choices.containerOuter.position = 'bottom'\n const bestSpace = Math.max(availableSpaceBelow, availableSpaceAbove)\n dropdownElement.style.height = getNewHeight(bestSpace)\n }\n choices.containerOuter.open(0) // Refresh top/bottom position\n } else choices.containerOuter.position = 'bottom'\n } else if (position == 'bottom') {\n if (defaultSpaceTaken > availableSpaceBelow) {\n dropdownElement.style.height = getNewHeight(availableSpaceBelow)\n }\n } else if (position == 'top') {\n if (defaultSpaceTaken > availableSpaceAbove) {\n dropdownElement.style.height = getNewHeight(availableSpaceAbove)\n }\n }\n }\n }\n}\n\n/**\n * Once a parent of the element is scrolled, the dropdown wil be hidden.\n */\nconst hideOnScroll = function (this: HTMLSelectElement | HTMLInputElement) {\n const choices = this.choices\n if (choices) {\n const scrollProps = ['overflow', 'overflow-x', 'overflow-y']\n const scrollValues = ['auto', 'scroll']\n const scrollableParents: HTMLElement[] = []\n let bubble: HTMLElement | null = choices.containerOuter.element\n while (bubble && (bubble = bubble.parentElement)) { // eslint-disable-line no-cond-assign\n const style = window.getComputedStyle(bubble)\n if (scrollProps.map(prop => scrollValues.includes(style[prop])).includes(true)) {\n scrollableParents.push(bubble)\n }\n }\n\n let stoppedListening = false\n\n const scrollHandler = () => choices.hideDropdown()\n\n const listen = () => {\n scrollableParents.forEach(scrollableParent => {\n scrollableParent.addEventListener('scroll', scrollHandler)\n })\n window.addEventListener('resize', scrollHandler)\n }\n\n const stopListening = () => {\n stoppedListening = true\n scrollableParents.forEach(scrollableParent => {\n scrollableParent.removeEventListener('scroll', scrollHandler)\n })\n window.removeEventListener('resize', scrollHandler)\n }\n\n this.addEventListener('hideDropdown', () => {\n stopListening()\n }, { once: true })\n // Opening the dropdown may cause a scroll, listening is delayed to ignore it\n requestAnimationFrame(() => {\n if (!stoppedListening) listen()\n })\n }\n}\n\n/* DEFAULT OPTIONS OVERRIDE */\n\nChoices.defaults.options.searchEnabled = false\nChoices.defaults.options.silent = true\nChoices.defaults.options.position = 'auto'\nChoices.defaults.options.positionFixed = false\nChoices.defaults.options.callbackOnInit = function (this: Choices) {\n if (\n this.passedElement.element.choices?.initialised &&\n this.passedElement.element.choices != this\n ) {\n console.warn('Potential duplicate Choices instance detected on select')\n }\n this.passedElement.element.choices = this as Choices\n\n this.passedElement.element.removeEventListener('showDropdown', handleDropdownPosition)\n this.passedElement.element.addEventListener('showDropdown', handleDropdownPosition)\n}\n\n/* AUTO INIT .make-choices */\n\ndocument.querySelectorAll('.make-choices').forEach(select => {\n let options\n try {\n options = JSON.parse(select.dataset.options || '{}')\n } catch (e) {\n console.error(e)\n options = {}\n }\n void new Choices(select, options)\n})\n"],"names":["CUSTOM_CONFIGS","Choices","_OriginalChoices","_inherits","AugmentedChoicesConstructor","_super","_createSuper","selectorOrElement","userConfig","_this","_classCallCheck","console","warn","warnBackup","_len","arguments","length","args","Array","_key","apply","configs","split","unknownConfigs","forEach","config","indexOf","push","join","e","call","_possibleConstructorReturn","OriginalChoices","handleDropdownPosition","choices","this","position","dropdownElement","dropdown","element","containerElement","containerOuter","overflowElement","positionFixed","document","getElementById","body","parent","path","parentElement","i","style","window","getComputedStyle","getOverflow","addEventListener","bottom","top","width","left","once","height","parentRect","getBoundingClientRect","x","zIndex","reference","parseInt","findRequiredZIndex","isBottom","isFlipped","y","innerHeight","hideOnScroll","overflowRect","documentElement","scrollHeight","dropdownRect","containerRect","defaultSpaceTaken","availableSpaceBelow","availableSpaceAbove","getNewHeight","availableSpace","overflowingHeight","bestSpace","Math","max","open","_this2","scrollProps","scrollValues","scrollableParents","bubble","_loop","map","prop","includes","stoppedListening","scrollHandler","hideDropdown","scrollableParent","removeEventListener","requestAnimationFrame","defaults","options","searchEnabled","silent","callbackOnInit","_this$passedElement$e","passedElement","initialised","querySelectorAll","select","JSON","parse","dataset","error"],"sourceRoot":""}