# typed: strict
class Domain::Fa::Parser::Base
  extend T::Sig

  sig { returns(Symbol) }
  attr_reader :page_version

  sig { params(page_version: Symbol).void }
  def initialize(page_version:)
    @page_version = page_version
  end

  sig { returns(T.noreturn) }
  def unimplemented_version!
    raise("unimplemented page version: #{page_version}")
  end

  sig do
    type_parameters(:Elem)
      .params(
        elem: T.all(T.type_parameter(:Elem), Nokogiri::XML::Node),
        csses: T::Array[String],
      )
      .returns(T.nilable(T.type_parameter(:Elem)))
  end
  def first_matching_css(elem, csses)
    for css in csses
      e = elem.css(css).first
      return e if e
    end
    nil
  end
end
