import { toKebabCase } from '../../esl-utils/misc/format' ; import type { ESLBaseElement } from '../core/esl-base-element' ; /** HTML boolean (marker) attribute mapping configuration */ type BoolAttrDescriptor = { /** HTML attribute name. Uses kebab-cased variable name by default */ name ? : string ; /** Create getter only */ readonly ? : boolean ; /** Use data-* attribute */ dataAttr ? : boolean ; } ; function buildConditionalDescriptor ( attrName , readOnly ) { function get ( ) { return this . hasAttribute ( attrName ) ; } function set ( value ) { this . toggleAttribute ( attrName , value ) ; } return readOnly ? { get } : { get , set } ; } const buildAttrName = ( propName , dataAttr ) : string => dataAttr ? `data-${ toKebabCase ( propName ) }` : toKebabCase ( propName ) ; param config - mapping configuration. See  BoolAttrDescriptor export const boolAttr = ( config = { } ) : PropertyDecorator => { return ( target , propName ) : void => { const attrName = buildAttrName ( config . name || propName , ! ! config . dataAttr ) ; Object . defineProperty ( target , propName , buildConditionalDescriptor ( attrName , ! ! config . readonly ) ) ; } ; } ;