/**
 * Copyright © Volker Schukai and all contributing authors, 2026. All rights reserved.
 * Node module: @schukai/monster
 *
 * This source code is licensed under the GNU Affero General Public License version 3 (AGPLv3).
 * The full text of the license can be found at: https://www.gnu.org/licenses/agpl-3.0.en.html
 *
 * For those who do not wish to adhere to the AGPLv3, a commercial license is available.
 * Acquiring a commercial license allows you to use this software without complying with the AGPLv3 terms.
 * For more information about purchasing a commercial license, please contact Volker Schukai.
 */

import { addAttributeToken } from "../../dom/attributes.mjs";
import { ATTRIBUTE_ERRORMESSAGE } from "../../dom/constants.mjs";

export { FormStyleSheet };

/**
 * @private
 * @type {CSSStyleSheet}
 */
const FormStyleSheet = new CSSStyleSheet();

try {
	FormStyleSheet.insertRule(
		`
@layer form {
input,meter,progress,select,textarea{accent-color:var(--monster-color-secondary-2);box-sizing:border-box;color:var(--monster-color-primary-1);background-color:var(--monster-bg-color-primary-1);font-family:inherit;font-size:100%;margin:0;outline:none;border-width:var(--monster-theme-control-border-width);border-radius:var(--monster-theme-control-border-radius);border-style:var(--monster-theme-control-border-style);border-color:var(--monster-theme-control-border-color)}input,select,textarea{padding:.4rem .6rem;height:-moz-fit-content;height:fit-content}textarea{resize:vertical;min-height:6rem}input[type=color]{padding:.1rem;margin:0;height:2rem;width:2rem}input:hover:not([type=radio]):not([type=checkbox]):not([type=range]),select:hover,textarea:hover{transition:background .8s,color .25s .0833333333s;box-shadow:var(--monster-box-shadow-2)}input:focus,select:focus,textarea:focus{outline:1px dashed var(--monster-color-selection-3);outline-offset:3px}
}`,
		0,
	);
} catch (e) {
	addAttributeToken(
		document.getRootNode().querySelector("html"),
		ATTRIBUTE_ERRORMESSAGE,
		e + "",
	);
}
