class Playbook::KitBase

def combined_html_options

def combined_html_options
  merged = default_html_options.dup
  html_options.each do |key, value|
    if key == :style && value.is_a?(Hash)
      # Convert style hash to CSS string
      merged[:style] = value.map { |k, v| "#{k.to_s.gsub('_', '-')}: #{v}" }.join("; ")
    else
      merged[key] = value
    end
  end
  inline_styles = dynamic_inline_props
  merged[:style] = if inline_styles.present?
                     merged[:style].present? ? "#{merged[:style]}; #{inline_styles}" : inline_styles
                   end
  merged.deep_merge(data_attributes)
end

def data_attributes

def data_attributes
  {
    data: data,
    aria: aria,
  }.transform_keys { |key| key.to_s.tr("_", "-").to_sym }
end

def default_html_options

def default_html_options
  {}
end

def dynamic_inline_props

def dynamic_inline_props
  styles = global_inline_props.map { |key, value| "#{key.to_s.gsub('_', '-')}: #{value}" if inline_validator(key, value) }.compact
  styles.join("; ").presence
end

def global_inline_props

def global_inline_props
  {
    height: height,
    min_height: min_height,
    max_height: max_height,
  }.compact
end

def inline_validator(key, value)

def inline_validator(key, value)
  return false if value.nil?
  return false if height_values.include?(value) && key == :height
  return false if min_height_values.include?(value) && key == :min_height
  return false if max_height_values.include?(value) && key == :max_height
  true
end

def kit_base_default_options

def kit_base_default_options
  options = {
    id: id,
    data: data,
    class: classname,
    aria: aria,
  }
  inline_styles = dynamic_inline_props
  options[:style] = inline_styles if inline_styles.present? && !html_options.key?(:style)
  options
end

def object

def object
  self
end

def pb_content_tag(name = :div, content_or_options_with_block = {}, options = {}, escape = true, &block)

rubocop:disable Style/OptionalBooleanParameter
def pb_content_tag(name = :div, content_or_options_with_block = {}, options = {}, escape = true, &block)
  combined_options = options
                     .merge(combined_html_options)
                     .merge(kit_base_default_options.merge(content_or_options_with_block))
  content_tag(name, combined_options, options, escape, &block)
end