{"version":3,"sources":["node_modules/@angular/material/fesm2022/checkbox.mjs"],"sourcesContent":["import * as i0 from '@angular/core';\nimport { InjectionToken, forwardRef, EventEmitter, ANIMATION_MODULE_TYPE, booleanAttribute, numberAttribute, Component, ViewEncapsulation, ChangeDetectionStrategy, Attribute, Optional, Inject, Input, Output, ViewChild, Directive, NgModule } from '@angular/core';\nimport { NG_VALUE_ACCESSOR, NG_VALIDATORS, CheckboxRequiredValidator } from '@angular/forms';\nimport { MatRipple, _MatInternalFormField, MatCommonModule } from '@angular/material/core';\n\n/** Injection token to be used to override the default options for `mat-checkbox`. */\nconst _c0 = [\"input\"];\nconst _c1 = [\"label\"];\nconst _c2 = [\"*\"];\nconst MAT_CHECKBOX_DEFAULT_OPTIONS = /*#__PURE__*/new InjectionToken('mat-checkbox-default-options', {\n providedIn: 'root',\n factory: MAT_CHECKBOX_DEFAULT_OPTIONS_FACTORY\n});\n/** @docs-private */\nfunction MAT_CHECKBOX_DEFAULT_OPTIONS_FACTORY() {\n return {\n color: 'accent',\n clickAction: 'check-indeterminate'\n };\n}\n\n/**\n * Represents the different states that require custom transitions between them.\n * @docs-private\n */\nvar TransitionCheckState = /*#__PURE__*/function (TransitionCheckState) {\n /** The initial state of the component before any user interaction. */\n TransitionCheckState[TransitionCheckState[\"Init\"] = 0] = \"Init\";\n /** The state representing the component when it's becoming checked. */\n TransitionCheckState[TransitionCheckState[\"Checked\"] = 1] = \"Checked\";\n /** The state representing the component when it's becoming unchecked. */\n TransitionCheckState[TransitionCheckState[\"Unchecked\"] = 2] = \"Unchecked\";\n /** The state representing the component when it's becoming indeterminate. */\n TransitionCheckState[TransitionCheckState[\"Indeterminate\"] = 3] = \"Indeterminate\";\n return TransitionCheckState;\n}(TransitionCheckState || {});\n/**\n * @deprecated Will stop being exported.\n * @breaking-change 19.0.0\n */\nconst MAT_CHECKBOX_CONTROL_VALUE_ACCESSOR = {\n provide: NG_VALUE_ACCESSOR,\n useExisting: /*#__PURE__*/forwardRef(() => MatCheckbox),\n multi: true\n};\n/** Change event object emitted by checkbox. */\nclass MatCheckboxChange {}\n// Increasing integer for generating unique ids for checkbox components.\nlet nextUniqueId = 0;\n// Default checkbox configuration.\nconst defaults = /*#__PURE__*/MAT_CHECKBOX_DEFAULT_OPTIONS_FACTORY();\nlet MatCheckbox = /*#__PURE__*/(() => {\n class MatCheckbox {\n /** Focuses the checkbox. */\n focus() {\n this._inputElement.nativeElement.focus();\n }\n /** Creates the change event that will be emitted by the checkbox. */\n _createChangeEvent(isChecked) {\n const event = new MatCheckboxChange();\n event.source = this;\n event.checked = isChecked;\n return event;\n }\n /** Gets the element on which to add the animation CSS classes. */\n _getAnimationTargetElement() {\n return this._inputElement?.nativeElement;\n }\n /** Returns the unique id for the visual hidden input. */\n get inputId() {\n return `${this.id || this._uniqueId}-input`;\n }\n constructor(_elementRef, _changeDetectorRef, _ngZone, tabIndex, _animationMode, _options) {\n this._elementRef = _elementRef;\n this._changeDetectorRef = _changeDetectorRef;\n this._ngZone = _ngZone;\n this._animationMode = _animationMode;\n this._options = _options;\n /** CSS classes to add when transitioning between the different checkbox states. */\n this._animationClasses = {\n uncheckedToChecked: 'mdc-checkbox--anim-unchecked-checked',\n uncheckedToIndeterminate: 'mdc-checkbox--anim-unchecked-indeterminate',\n checkedToUnchecked: 'mdc-checkbox--anim-checked-unchecked',\n checkedToIndeterminate: 'mdc-checkbox--anim-checked-indeterminate',\n indeterminateToChecked: 'mdc-checkbox--anim-indeterminate-checked',\n indeterminateToUnchecked: 'mdc-checkbox--anim-indeterminate-unchecked'\n };\n /**\n * Attached to the aria-label attribute of the host element. In most cases, aria-labelledby will\n * take precedence so this may be omitted.\n */\n this.ariaLabel = '';\n /**\n * Users can specify the `aria-labelledby` attribute which will be forwarded to the input element\n */\n this.ariaLabelledby = null;\n /** Whether the label should appear after or before the checkbox. Defaults to 'after' */\n this.labelPosition = 'after';\n /** Name value will be applied to the input element if present */\n this.name = null;\n /** Event emitted when the checkbox's `checked` value changes. */\n this.change = new EventEmitter();\n /** Event emitted when the checkbox's `indeterminate` value changes. */\n this.indeterminateChange = new EventEmitter();\n /**\n * Called when the checkbox is blurred. Needed to properly implement ControlValueAccessor.\n * @docs-private\n */\n this._onTouched = () => {};\n this._currentAnimationClass = '';\n this._currentCheckState = TransitionCheckState.Init;\n this._controlValueAccessorChangeFn = () => {};\n this._validatorChangeFn = () => {};\n this._checked = false;\n this._disabled = false;\n this._indeterminate = false;\n this._options = this._options || defaults;\n this.color = this._options.color || defaults.color;\n this.tabIndex = parseInt(tabIndex) || 0;\n this.id = this._uniqueId = `mat-mdc-checkbox-${++nextUniqueId}`;\n }\n ngOnChanges(changes) {\n if (changes['required']) {\n this._validatorChangeFn();\n }\n }\n ngAfterViewInit() {\n this._syncIndeterminate(this._indeterminate);\n }\n /** Whether the checkbox is checked. */\n get checked() {\n return this._checked;\n }\n set checked(value) {\n if (value != this.checked) {\n this._checked = value;\n this._changeDetectorRef.markForCheck();\n }\n }\n /** Whether the checkbox is disabled. */\n get disabled() {\n return this._disabled;\n }\n set disabled(value) {\n if (value !== this.disabled) {\n this._disabled = value;\n this._changeDetectorRef.markForCheck();\n }\n }\n /**\n * Whether the checkbox is indeterminate. This is also known as \"mixed\" mode and can be used to\n * represent a checkbox with three states, e.g. a checkbox that represents a nested list of\n * checkable items. Note that whenever checkbox is manually clicked, indeterminate is immediately\n * set to false.\n */\n get indeterminate() {\n return this._indeterminate;\n }\n set indeterminate(value) {\n const changed = value != this._indeterminate;\n this._indeterminate = value;\n if (changed) {\n if (this._indeterminate) {\n this._transitionCheckState(TransitionCheckState.Indeterminate);\n } else {\n this._transitionCheckState(this.checked ? TransitionCheckState.Checked : TransitionCheckState.Unchecked);\n }\n this.indeterminateChange.emit(this._indeterminate);\n }\n this._syncIndeterminate(this._indeterminate);\n }\n _isRippleDisabled() {\n return this.disableRipple || this.disabled;\n }\n /** Method being called whenever the label text changes. */\n _onLabelTextChange() {\n // Since the event of the `cdkObserveContent` directive runs outside of the zone, the checkbox\n // component will be only marked for check, but no actual change detection runs automatically.\n // Instead of going back into the zone in order to trigger a change detection which causes\n // *all* components to be checked (if explicitly marked or not using OnPush), we only trigger\n // an explicit change detection for the checkbox view and its children.\n this._changeDetectorRef.detectChanges();\n }\n // Implemented as part of ControlValueAccessor.\n writeValue(value) {\n this.checked = !!value;\n }\n // Implemented as part of ControlValueAccessor.\n registerOnChange(fn) {\n this._controlValueAccessorChangeFn = fn;\n }\n // Implemented as part of ControlValueAccessor.\n registerOnTouched(fn) {\n this._onTouched = fn;\n }\n // Implemented as part of ControlValueAccessor.\n setDisabledState(isDisabled) {\n this.disabled = isDisabled;\n }\n // Implemented as a part of Validator.\n validate(control) {\n return this.required && control.value !== true ? {\n 'required': true\n } : null;\n }\n // Implemented as a part of Validator.\n registerOnValidatorChange(fn) {\n this._validatorChangeFn = fn;\n }\n _transitionCheckState(newState) {\n let oldState = this._currentCheckState;\n let element = this._getAnimationTargetElement();\n if (oldState === newState || !element) {\n return;\n }\n if (this._currentAnimationClass) {\n element.classList.remove(this._currentAnimationClass);\n }\n this._currentAnimationClass = this._getAnimationClassForCheckStateTransition(oldState, newState);\n this._currentCheckState = newState;\n if (this._currentAnimationClass.length > 0) {\n element.classList.add(this._currentAnimationClass);\n // Remove the animation class to avoid animation when the checkbox is moved between containers\n const animationClass = this._currentAnimationClass;\n this._ngZone.runOutsideAngular(() => {\n setTimeout(() => {\n element.classList.remove(animationClass);\n }, 1000);\n });\n }\n }\n _emitChangeEvent() {\n this._controlValueAccessorChangeFn(this.checked);\n this.change.emit(this._createChangeEvent(this.checked));\n // Assigning the value again here is redundant, but we have to do it in case it was\n // changed inside the `change` listener which will cause the input to be out of sync.\n if (this._inputElement) {\n this._inputElement.nativeElement.checked = this.checked;\n }\n }\n /** Toggles the `checked` state of the checkbox. */\n toggle() {\n this.checked = !this.checked;\n this._controlValueAccessorChangeFn(this.checked);\n }\n _handleInputClick() {\n const clickAction = this._options?.clickAction;\n // If resetIndeterminate is false, and the current state is indeterminate, do nothing on click\n if (!this.disabled && clickAction !== 'noop') {\n // When user manually click on the checkbox, `indeterminate` is set to false.\n if (this.indeterminate && clickAction !== 'check') {\n Promise.resolve().then(() => {\n this._indeterminate = false;\n this.indeterminateChange.emit(this._indeterminate);\n });\n }\n this._checked = !this._checked;\n this._transitionCheckState(this._checked ? TransitionCheckState.Checked : TransitionCheckState.Unchecked);\n // Emit our custom change event if the native input emitted one.\n // It is important to only emit it, if the native input triggered one, because\n // we don't want to trigger a change event, when the `checked` variable changes for example.\n this._emitChangeEvent();\n } else if (!this.disabled && clickAction === 'noop') {\n // Reset native input when clicked with noop. The native checkbox becomes checked after\n // click, reset it to be align with `checked` value of `mat-checkbox`.\n this._inputElement.nativeElement.checked = this.checked;\n this._inputElement.nativeElement.indeterminate = this.indeterminate;\n }\n }\n _onInteractionEvent(event) {\n // We always have to stop propagation on the change event.\n // Otherwise the change event, from the input element, will bubble up and\n // emit its event object to the `change` output.\n event.stopPropagation();\n }\n _onBlur() {\n // When a focused element becomes disabled, the browser *immediately* fires a blur event.\n // Angular does not expect events to be raised during change detection, so any state change\n // (such as a form control's 'ng-touched') will cause a changed-after-checked error.\n // See https://github.com/angular/angular/issues/17793. To work around this, we defer\n // telling the form control it has been touched until the next tick.\n Promise.resolve().then(() => {\n this._onTouched();\n this._changeDetectorRef.markForCheck();\n });\n }\n _getAnimationClassForCheckStateTransition(oldState, newState) {\n // Don't transition if animations are disabled.\n if (this._animationMode === 'NoopAnimations') {\n return '';\n }\n switch (oldState) {\n case TransitionCheckState.Init:\n // Handle edge case where user interacts with checkbox that does not have [(ngModel)] or\n // [checked] bound to it.\n if (newState === TransitionCheckState.Checked) {\n return this._animationClasses.uncheckedToChecked;\n } else if (newState == TransitionCheckState.Indeterminate) {\n return this._checked ? this._animationClasses.checkedToIndeterminate : this._animationClasses.uncheckedToIndeterminate;\n }\n break;\n case TransitionCheckState.Unchecked:\n return newState === TransitionCheckState.Checked ? this._animationClasses.uncheckedToChecked : this._animationClasses.uncheckedToIndeterminate;\n case TransitionCheckState.Checked:\n return newState === TransitionCheckState.Unchecked ? this._animationClasses.checkedToUnchecked : this._animationClasses.checkedToIndeterminate;\n case TransitionCheckState.Indeterminate:\n return newState === TransitionCheckState.Checked ? this._animationClasses.indeterminateToChecked : this._animationClasses.indeterminateToUnchecked;\n }\n return '';\n }\n /**\n * Syncs the indeterminate value with the checkbox DOM node.\n *\n * We sync `indeterminate` directly on the DOM node, because in Ivy the check for whether a\n * property is supported on an element boils down to `if (propName in element)`. Domino's\n * HTMLInputElement doesn't have an `indeterminate` property so Ivy will warn during\n * server-side rendering.\n */\n _syncIndeterminate(value) {\n const nativeCheckbox = this._inputElement;\n if (nativeCheckbox) {\n nativeCheckbox.nativeElement.indeterminate = value;\n }\n }\n _onInputClick() {\n this._handleInputClick();\n }\n _onTouchTargetClick() {\n this._handleInputClick();\n if (!this.disabled) {\n // Normally the input should be focused already, but if the click\n // comes from the touch target, then we might have to focus it ourselves.\n this._inputElement.nativeElement.focus();\n }\n }\n /**\n * Prevent click events that come from the `