import "./class-map-CwiboTfb.mjs"; import { i as s } from "./element-internals-3IY9gE4L.mjs"; /** * @license * Copyright 2023 Google LLC * SPDX-License-Identifier: Apache-2.0 */ const c = Symbol("createValidator"), u = Symbol("getValidityAnchor"), l = Symbol("privateValidator"), a = Symbol("privateSyncValidity"), r = Symbol("privateCustomValidationMessage"); function g(d) { var e; class h extends d { constructor() { super(...arguments), this[e] = ""; } get validity() { return this[a](), this[s].validity; } get validationMessage() { return this[a](), this[s].validationMessage; } get willValidate() { return this[a](), this[s].willValidate; } checkValidity() { return this[a](), this[s].checkValidity(); } reportValidity() { return this[a](), this[s].reportValidity(); } setCustomValidity(i) { this[r] = i, this[a](); } requestUpdate(i, o, n) { super.requestUpdate(i, o, n), this[a](); } firstUpdated(i) { super.firstUpdated(i), this[a](); } [(e = r, a)]() { this[l] || (this[l] = this[c]()); const { validity: i, validationMessage: o } = this[l].getValidity(), n = !!this[r], y = this[r] || o; this[s].setValidity({ ...i, customError: n }, y, this[u]() ?? void 0); } [c]() { throw new Error("Implement [createValidator]"); } [u]() { throw new Error("Implement [getValidityAnchor]"); } } return h; } /** * @license * Copyright 2023 Google LLC * SPDX-License-Identifier: Apache-2.0 */ class m { /** * Creates a new validator. * * @param getCurrentState A callback that returns the current state of * constraint validation-related properties. */ constructor(e) { this.getCurrentState = e, this.currentValidity = { validity: {}, validationMessage: "" }; } /** * Returns the current `ValidityStateFlags` and validation message for the * validator. * * If the constraint validation state has not changed, this will return a * cached result. This is important since `getValidity()` can be called * frequently in response to synchronous property changes. * * @return The current validity and validation message. */ getValidity() { const e = this.getCurrentState(); if (!(!this.prevState || !this.equals(this.prevState, e))) return this.currentValidity; const { validity: t, validationMessage: i } = this.computeValidity(e); return this.prevState = this.copy(e), this.currentValidity = { validationMessage: i, validity: { // Change any `ValidityState` instances into `ValidityStateFlags` since // `ValidityState` cannot be easily `{...spread}`. badInput: t.badInput, customError: t.customError, patternMismatch: t.patternMismatch, rangeOverflow: t.rangeOverflow, rangeUnderflow: t.rangeUnderflow, stepMismatch: t.stepMismatch, tooLong: t.tooLong, tooShort: t.tooShort, typeMismatch: t.typeMismatch, valueMissing: t.valueMissing } }, this.currentValidity; } } export { m as V, c, u as g, g as m };