<gh_stars>10-100
\AcroModule{interface}{definitions of user commands}

% --------------------------------------------------------------------------
% helper commands
\NewDocumentCommand \AcroAddRow {+m}
  {
    \tl_put_right:Ne \AcronymTable
      {
        \exp_not:n { \tl_gset:Nn \AcronymID } { \AcronymID }
        \exp_not:n {#1}
      }
  }

\NewDocumentCommand \AcroRerun {}
  { \acro_rerun:n {list} }

\NewDocumentCommand \AcroPropertiesMap {+m}
  { \acro_properties_map:n {#1} }

\NewDocumentCommand \AcroAcronymsMap {+m}
  { \acro_map_acronyms:n { \tl_set:Nn \AcronymID {##1} #1 } }

\NewExpandableDocumentCommand \AcroMapBreak {} { \acro_map_break: }
  
\NewDocumentCommand \AcroPropertiesSet {m+m}
  { \acro_properties_set:nn {#1} {#2} }
  
\NewDocumentCommand \AcroMap {m+m}
  { \acro_list_map:nn {#1} {#2} }

\NewDocumentCommand \AcroNeedPackage {m}
  {
    \clist_map_inline:nn {#1}
      {
        \acro_package_if_loaded:nF {##1}
          { \msg_error:nnen {acro} {package-needed} { \AcroTemplateName } {##1} }
      }
  }

% --------------------------------------------------------------------------
% general commands:
\NewDocumentCommand \acsetup {+m}
  { \acro_setup:n {#1} }

\NewDocumentCommand \acroloadstyle {m}
  { \acro_style_load:n {#1} }

\NewExpandableDocumentCommand \acroifstarredTF {}
  { \bool_if:NTF \l__acro_star_bool }

\NewExpandableDocumentCommand \acroifstarredT {}
  { \bool_if:NT \l__acro_star_bool }

\NewExpandableDocumentCommand \acroifstarredF {}
  { \bool_if:NF \l__acro_star_bool }
  
\NewExpandableDocumentCommand \acroifusedTF {m}
  { \acro_boolean_property_if:nnTF {#1} {used} }

\NewExpandableDocumentCommand \acroifusedT {m}
  { \acro_boolean_property_if:nnT {#1} {used} }

\NewExpandableDocumentCommand \acroifusedF {m}
  { \acro_boolean_property_if:nnF {#1} {used} }

\NewDocumentCommand \acuse {m}
  { \acro_use:n {#1} }

\NewDocumentCommand \acuseall {}
  { \acro_use_all: }

\NewDocumentCommand \acreset {m}
  { \acro_reset:n {#1} }

\NewDocumentCommand \acresetall {}
  { \acro_reset_all: }

\NewExpandableDocumentCommand \acsimple {mm}
  { \acro_pdfstring_template:nn {#1} {#2} }

\NewDocumentCommand \acbarrier {}
  { \acro_barrier: }

\NewDocumentCommand \acswitchoff {}
  { \acro_switch_off: }

\NewDocumentCommand \acswitchon {}
  { \acro_switch_on: }

% --------------------------------------------------------------------------
\NewDocumentCommand \DeclareAcroProperty {st?t!t|t>m}
  {
    \acro_property_declare:en
      {
        \IfBooleanT {#1} {unique=true,}
        \IfBooleanT {#2} {boolean=true,}
        \IfBooleanT {#3} {mandatory=true,}
        \IfBooleanT {#4} {static=true,}
        \IfBooleanT {#5} {display=true}
      }
      {#6}
  }

\NewDocumentCommand \DeclareAcroPropertyAlias {st?t!t|t>mm}
  {
    \acro_property_declare:en
      {
        \IfBooleanT {#1} {unique=true,}
        \IfBooleanT {#2} {boolean=true,}
        \IfBooleanT {#3} {mandatory=true,}
        \IfBooleanT {#4} {static=true,}
        \IfBooleanT {#5} {display=true}
      }
      {#6}
    \acro_property_make_alias:nn {#6} {#7}
  }

\NewDocumentCommand \MakeAcroPropertyAlias {mm}
  { \acro_property_make_alias:nn {#1} {#2} }

\NewDocumentCommand \NewAcroPreset {m+m}
  { \acro_preset_new:nn {#1} {#2} }

\NewDocumentCommand \RenewAcroPreset {m+m}
  { \acro_preset_renew:nn {#1} {#2} }

\NewDocumentCommand \DeclareAcroPreset {m+m}
  { \acro_preset_declare:nn {#1} {#2} }

% --------------------------------------------------------------------------
\NewDocumentCommand \UseAcroTemplate {O{acronym}mO{1}}
  { \acro_template_use:nnn {#3} {#1} {#2} }

\NewDocumentCommand \NewAcroTemplate {O{acronym}m+m}
  { \use:c {acro_#1_template_new:nn} {#2} {#3} }

\NewDocumentCommand \RenewAcroTemplate {O{acronym}m+m}
  { \use:c {acro_#1_template_renew:nn} {#2} {#3} }

\NewDocumentCommand \SetupAcroTemplate {O{acronym}m+m}
  { \acro_template_setup:nnn {#1} {#2} {#3} }

\NewDocumentCommand \SetupNextAcroTemplate {O{acronym}m+m}
  { \acro_next_template_setup:nnn {#1} {#2} {#3} }

\NewDocumentCommand \DeclareAcronym {m+m}
  { \acro_declare_acronym:nn {#1} {#2} }

% declaring acronyms in the document body does not work,
% cf. https://tex.stackexchange.com/q/568856/
% so lets prevent people from doing so:
\@onlypreamble \NewDocumentCommand

\NewDocumentCommand \DeclareAcroEnding {mmm}
  { \acro_declare_ending:nnn {#1} {#2} {#3} }

\NewDocumentCommand \DeclareAcroArticle {mm}
  { \acro_article_declare:nn {#1} {#2} }

\NewDocumentCommand \DeclareAcroTranslation {m+m}
  { \acro_declare_translations:nn {#1} {#2} }

\NewDocumentCommand \AddAcroTranslations {m+m}
  { \acro_add_translations:nn {#1} {#2} }

\NewExpandableDocumentCommand \acrotranslate {m}
  { \acro_translate:n {#1} }

\NewExpandableDocumentCommand \aciftrailing {}
  { \acro_trailing_if_tokens:nTF }

\NewDocumentCommand \acfootnote {m}
  { \acro_footnote:n {#1} }

\NewDocumentCommand \acgobbletrail {}
  { \bool_gset_true:N \g__acro_gobble_trail_bool }

\NewExpandableDocumentCommand \acdot   {} { \acro_dot: }
\NewExpandableDocumentCommand \acspace {} { \acro_space: }
\NewExpandableDocumentCommand \abbrdot {} { .\@ }

\NewDocumentCommand \acroupper {} { \acro_upper: }
\NewDocumentCommand \acrofull {} { \acro_first: }

\NewDocumentCommand \printacronyms {o}
  {
    \group_begin:
      \IfNoValueF {#1}
        { \keys_set:nn {acro/list} {#1} }
      \acro_list:
    \group_end:
  }

% --------------------------------------------------------------------------
% commands for list templates
\NewDocumentCommand \acroheading  {} { \acro_heading: }
\NewDocumentCommand \acropreamble {} { \acro_preamble: }
\NewDocumentCommand \acropostamble {} { \acro_postamble: }

\NewExpandableDocumentCommand \acrolistname {}
  { \tl_use:N \l__acro_list_name_tl }

% --------------------------------------------------------------------------
% cmmands for use in templates:
\NewDocumentCommand \acronymsmapTF {+m+m+m}
  {
    \acro_acronyms_map:nTF
      {
        \tl_set:Nn \AcronymID {##1}
        #1
      }
      {#2}
      {#3}
  }

\NewDocumentCommand \acronymsmapT {+m+m}
  { \acronymsmapTF {#1} {#2} {} }

\NewDocumentCommand \acronymsmapF {+m+m}
  { \acronymsmapTF {#1} {} {#2} }

\NewDocumentCommand \acronymsmap {+m}
  { \acronymsmapTF {#1} {} {} }

\NewExpandableDocumentCommand \acrofield {mm}
  { \acro_property_get:nn {#1} {#2} }

\NewDocumentCommand \acroprintfield {mm}
  {
    \acro_property_if_eq:nnTF {#2} {list}
      {
        \bool_if:NT \l__acro_upper_list_bool { \acro_upper: }
        \acro_write:en {#1} {#2}
      }
      { \acro_write:en {#1} {#2} }
  }

\NewExpandableDocumentCommand \acroiffieldTF {+m+m+m+m}
  { \acro_property_if_set:nnTF {#1} {#2} {#3} {#4} }

\NewDocumentCommand \acroifanyfieldTF {mm+m+m}
  { \acro_property_if_any:nnTF {#1} {#2} {#3} {#4} }

\NewDocumentCommand \acroifallfieldsTF {mm+m+m}
  { \acro_property_if_all:nnTF {#1} {#2} {#3} {#4} }

\NewExpandableDocumentCommand \acroifpagefieldTF {m}
  { \acro_if_pages:nTF {#1} }

\NewDocumentCommand \acrowrite {m}
  { \acroprintfield { \AcronymID } {#1} }

\NewDocumentCommand \acroshow {m}
  { \acro_property_show:en { \AcronymID } {#1} }

\NewDocumentCommand \acrodonotuse {}
  { \acro_use_false: }

\NewDocumentCommand \acroformat {mm}
  { \acro_format:enn { \AcronymID } {#1} {#2} }

\NewDocumentCommand \acrogroupcite {}
  {
    \bool_if:NT \l__acro_cite_group_bool
      {
        \tl_set_eq:NN \l__acro_cite_pre_tl \l__acro_cite_between_tl
        \cs_set_eq:NN \__acro_cite_cmd:w \__acro_cite_group_cmd:w
        \acro_cite_if:neT { \l__acro_star_bool } { \AcronymID }
          { \acro_cite:e { \AcronymID } }
      }
  }

\NewDocumentCommand \acrocite {}
  { \bool_set_true:N \l__acro_cite_always_bool }

\NewExpandableDocumentCommand \acroifpropertyTF {m}
  { \acro_property_if_exist:nTF {#1} }

\NewExpandableDocumentCommand \acroifpropertyT {m}
  { \acro_property_if_exist:nT {#1} }

\NewExpandableDocumentCommand \acroifpropertyF {m}
  { \acro_property_if_exist:nF {#1} }
  
\NewExpandableDocumentCommand \acroifbooleanTF {m}
  { \acro_boolean_property_if:enTF { \AcronymID } {#1} }

\NewExpandableDocumentCommand \acroifbooleanT {m}
  { \acro_boolean_property_if:enT { \AcronymID } {#1} }

\NewExpandableDocumentCommand \acroifbooleanF {m}
  { \acro_boolean_property_if:enF { \AcronymID } {#1} }

\NewExpandableDocumentCommand \acroifTF {m}
  { \acro_property_if_set:enTF { \AcronymID } {#1} }
\NewExpandableDocumentCommand \acroifT {m}
  { \acro_property_if_set:enT { \AcronymID } {#1} }
\NewExpandableDocumentCommand \acroifF {m}
  { \acro_property_if_set:enF { \AcronymID } {#1} }

\NewDocumentCommand \acroifanyTF {m+m+m}
  { \acro_property_if_any:enTF { \AcronymID } {#1} {#2} {#3} }
\NewDocumentCommand \acroifanyT {m+m}
  { \acro_property_if_any:enTF { \AcronymID } {#1} {#2} {} }
\NewDocumentCommand \acroifanyF {m+m}
  { \acro_property_if_any:enTF { \AcronymID } {#1} {} {#2} }

\NewDocumentCommand \acroifallTF {m+m+m}
  { \acro_property_if_all:enTF { \AcronymID } {#1} {#2} {#3} }
\NewDocumentCommand \acroifallT {m+m}
  { \acro_property_if_all:enTF { \AcronymID } {#1} {#2} {} }
\NewDocumentCommand \acroifallF {m+m}
  { \acro_property_if_all:enTF { \AcronymID } {#1} {} {#2} }

\NewDocumentCommand \acroifsingleTF {+m+m}
  { \acro_if_single:eTF { \AcronymID } {#1} {#2} }
\NewDocumentCommand \acroifsingleT {+m}
  { \acro_if_single:eTF { \AcronymID } {#1} {} }
\NewDocumentCommand \acroifsingleF {+m}
  { \acro_if_single:eTF { \AcronymID } {} {#1} }

\NewDocumentCommand \acroiffirstTF {+m+m}
  { \acro_if_first:eTF { \AcronymID } {#1} {#2} }
\NewDocumentCommand \acroiffirstT {+m}
  { \acro_if_first:eTF { \AcronymID } {#1} {} }
\NewDocumentCommand \acroiffirstF {+m}
  { \acro_if_first:eTF { \AcronymID } {} {#1} }

\NewDocumentCommand \acroiftagTF {m+m+m}
  { \acro_tag_if:enTF { \AcronymID } {#1} {#2} {#3} }
\NewDocumentCommand \acroiftagT {m+m}
  { \acro_tag_if:enT { \AcronymID } {#1} {#2} }
\NewDocumentCommand \acroiftagF {m+m}
  { \acro_tag_if:enF { \AcronymID } {#1} {#2} }

\NewDocumentCommand \acropages {mm}
  { \acro_print_pages:enn { \AcronymID } {#1} {#2} }

\NewDocumentCommand \acronopagerange {}
  { \acro_no_page_ranges:e { \AcroTemplateName } }

\NewDocumentCommand \acroneedpages {}
  { \acro_need_pages: }

\NewDocumentCommand \acropagefill {}
  { \acro_if_pages:eT  { \AcronymID } { \tl_use:N \l__acro_pages_fill_tl } }

\NewDocumentCommand \acrodotfill {} { \acro_dot_fill: }
  
\NewExpandableDocumentCommand \acroifpagesTF {}
  { \acro_if_pages:eTF { \AcronymID } }

\NewExpandableDocumentCommand \acroifpagesT {}
  { \acro_if_pages:eT { \AcronymID } }

\NewExpandableDocumentCommand \acroifpagesF {}
  { \acro_if_pages:eF { \AcronymID } }

\NewExpandableDocumentCommand \acroifchapterTF {}
  { \cs_if_exist:NTF \chapter }

\NewExpandableDocumentCommand \acroifchapterT {}
  { \cs_if_exist:NT \chapter }

\NewExpandableDocumentCommand \acroifchapterF {}
  { \cs_if_exist:NF \chapter }

% --------------------------------------------------------------------------
\AcroModuleEnd
