%%
%% This is file `cdcmd.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% cdcmd.dtx  (with options: `package')
%% 
%%     Copyright (C) 2021--2021
%%     Wenjian Chern (Longaster) and any individual authors listed elsewhere in this file.
%%  --------------------------------------------------------------------------
%% 
%%     This work may be distributed and/or modified under the
%%     conditions of the LaTeX Project Public License, either
%%     version 1.3c of this license or (at your option) any later
%%     version. This version of this license is in
%%         http://www.latex-project.org/lppl/lppl-1-3c.txt
%%     and the latest version of this license is in
%%         http://www.latex-project.org/lppl.txt
%%     and version 1.3 or later is part of all distributions of
%%     LaTeX version 2005/12/01 or later.
%% 
%%     This work has the LPPL maintenance status `maintained'.
%% 
%%     The Current Maintainers of this work are Wenjian Chern (Longaster).
%%  --------------------------------------------------------------------------
%% 
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{expl3}[2021/05/11]
\GetIdInfo$Id: cdcmd.dtx 1.0 2021/10/12 +0815 Longaster$
  {Expandable Conditional Command In LaTeX2e}
\ProvidesExplPackage{cdcmd}
  {\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
\str_const:Nn \c_cdcmd_all_str { * }
\clist_new:N \g__cdcmd_clist
\bool_new:N \l__cdcmd_clear_set_bool
\msg_new:nnn { cdcmd } { condition-exist }
  { The~ condition~ `#1'~ you~ try~ to~ new~ already~ exists. }
\msg_new:nnn { cdcmd } { condition-not-exist }
  { The~ condition~ `#1'~ not~ exists. }
\msg_new:nnn { cdcmd } { condition-id-not-exist }
  { The~ id~ `#2' of~ condition~ `#1'~ not~ exists. }
\prg_new_conditional:Npnn \cdcmd_if_exist:n #1 { p, T, F, TF }
  {
    \clist_if_exist:cTF { c__cdcmd_condition@ #1 _clist }
      { \prg_return_true: } { \prg_return_false: }
  }
\prg_new_conditional:Npnn \cdcmd_cd_id_if_exist:nn #1#2 { T, F, TF }
  {
    \clist_if_in:cnTF { c__cdcmd_condition@ #1 _clist } {#2}
      { \prg_return_true: } { \prg_return_false: }
  }
\cs_new_nopar:Npn \cdcmd_new:nn #1#2
  {
    \cdcmd_if_exist:nTF {#1}
      { \msg_error:nnn { cdcmd } { condition-exist } {#1} }
      {
        \clist_gput_right:Nn \g__cdcmd_clist {#1}
        \clist_const:cn { c__cdcmd_condition@ #1 _clist } {#2}
        \clist_new:c { l__cdcmd_curr_condition@ #1 _clist }
      }
  }
\cs_new_nopar:Npn \cdcmd_set:nn #1#2
  {
    \cdcmd_if_exist:nTF {#1}
      {
        \bool_if:NT \l__cdcmd_clear_set_bool
          { \clist_clear:c { l__cdcmd_curr_condition@ #1 _clist } }
        \clist_map_inline:nn {#2}
          {
            \str_if_eq:eeTF {##1} { \c_cdcmd_all_str }
              { \clist_map_break:n { \cdcmd_set_cdcmd_all:n {#1} } }
              { \cdcmd_set_cdcmd_single:nn {#1} {##1} }
          }
      }
      { \msg_warning:nnn { cdcmd } { condition-not-exist } {#1} }
  }
\cs_new_nopar:Npn \cdcmd_set_cdcmd_single:nn #1#2
  {
    \cdcmd_if_exist:nTF {#1}
      {
        \cdcmd_cd_id_if_exist:nnTF {#1} {#2}
          { \clist_put_right:cn { l__cdcmd_curr_condition@ #1 _clist } {#2} }
          { \msg_warning:nnnn { cdcmd } { condition-id-not-exist } {#1} {#2} }
      }
      { \msg_warning:nnn { cdcmd } { condition-not-exist } }
  }
\cs_new_nopar:Npn \cdcmd_set_cdcmd_all:n #1
  {
    \cdcmd_if_exist:nTF {#1}
      {
        \clist_set_eq:cc
          { l__cdcmd_curr_condition@ #1 _clist }
          { c__cdcmd_condition@ #1 _clist }
      }
      { \msg_warning:nnn { cdcmd } { condition-not-exist } {#1} }
  }
\cs_new_nopar:Npn \cdcmd_set:n
  { \keyval_parse:NNn \cdcmd_set_cdcmd_all:n \cdcmd_set:nn }
\cs_new_nopar:Npn \cdcmd_clear_set:n #1
  {
    \bool_set_true:N \l__cdcmd_clear_set_bool
    \keyval_parse:NNn \cdcmd_set_cdcmd_all:n \cdcmd_set:nn {#1}
    \bool_set_false:N \l__cdcmd_clear_set_bool
  }
\cs_new:Npn \cdcmd_any_if:nTF #1
  {
    \bool_if:nTF
      {
        \keyval_parse:NNn
          \__cdcmd_any_i:n \__cdcmd_any_ii:nn {#1}
        \c_false_bool
      }
  }
\cs_new:Npn \cdcmd_any_if_p:n #1
  {
    \bool_if_p:n
      {
        \keyval_parse:NNn
          \__cdcmd_any_i:n \__cdcmd_any_ii:nn {#1}
        \c_false_bool
      }
  }
\cs_new:Npn \cdcmd_any_if:nT #1#2 { \cdcmd_any_if:nTF {#1} {#2} { } }
\cs_new:Npn \cdcmd_any_if:nF #1   { \cdcmd_any_if:nTF {#1} { } }
\cs_new:Npn \cdcmd_any_if:nFT #1#2#3 { \cdcmd_any_if:nTF {#1} {#3} {#2} }
\prg_generate_conditional_variant:Nnn \cdcmd_any_if:n { o, V, f } { p, T, F, TF }
\cs_new:Npn \__cdcmd_any_i:n #1
  {
    \str_if_eq:eeTF {#1} { \c_cdcmd_all_str }
      { \c_true_bool || }
      { \cdcmd_if_exist:nT {#1} { \c_true_bool || } }
  }
\cs_new:Npn \__cdcmd_any_ii:nn #1#2
  {
    \cdcmd_if_exist:nT {#1}
      {
        \clist_map_tokens:nn {#2}
          { \__cdcmd_any_ii_aux:nn {#1} }
      }
  }
\cs_new:Npn \__cdcmd_any_ii_aux:nn #1#2
  {
    \str_if_eq:eeTF {#2} { \c_cdcmd_all_str }
      { \clist_map_break:n { \tex_the:D \c_true_bool || } }
      {
        \__cdcmd_clist_if_in:cnT { l__cdcmd_curr_condition@ #1 _clist } {#2}
          { \clist_map_break:n { \tex_the:D \c_true_bool || } }
      }
  }
\cs_new:Npn \cdcmd_all_if:nTF #1
  {
    \bool_if:nTF
      {
        \keyval_parse:NNn
          \__cdcmd_all_i:n \__cdcmd_all_ii:nn {#1}
        \c_true_bool
      }
  }
\cs_new:Npn \cdcmd_all_if_p:n #1
  {
    \bool_if_p:n
      {
        \keyval_parse:NNn
          \__cdcmd_all_i:n \__cdcmd_all_ii:nn {#1}
        \c_true_bool
      }
  }
\cs_new:Npn \cdcmd_all_if:nT #1#2 { \cdcmd_all_if:nTF {#1} {#2} { } }
\cs_new:Npn \cdcmd_all_if:nF #1   { \cdcmd_all_if:nTF {#1} { } }
\cs_new:Npn \cdcmd_all_if:nFT #1#2#3 { \cdcmd_all_if:nTF {#1} {#3} {#2} }
\prg_generate_conditional_variant:Nnn \cdcmd_all_if:n { o, V, f } { p, T, F, TF }
\cs_new:Npn \__cdcmd_all_i:n #1
  {
    \str_if_eq:eeF {#1} { \c_cdcmd_all_str }
      { \cdcmd_if_exist:nF {#1} { \c_false_bool && } }
  }
\cs_new:Npn \__cdcmd_all_ii:nn #1#2
  {
    \cdcmd_if_exist:nTF {#1}
      {
        \bool_lazy_and_p:nn
          { \int_compare_p:n { \clist_count:n {#2} > 0 } }
          {
            \int_compare_p:n
              { \clist_map_tokens:nn {#2} { \__cdcmd_all_ii_aux:nn {#1} } 1 > 0 }
          } &&
      }
      { \c_false_bool && }
  }
\cs_new:Npn \__cdcmd_all_ii_aux:nn #1#2
  {
    \str_if_eq:eeF {#2} { \c_cdcmd_all_str }
      {
        \__cdcmd_clist_if_in:cnF { l__cdcmd_curr_condition@ #1 _clist } {#2}
          { \clist_map_break:n { - } }
      }
  }
\prg_new_conditional:Npnn \__cdcmd_clist_if_in:Nn #1#2 { p, T, F, TF }
  {
    \int_compare:nTF
      { 0 \clist_map_tokens:Nn #1 { \__cdcmd_if_eq_break:ee {#2} } > 0 }
      { \prg_return_true: } { \prg_return_false: }
  }
\prg_generate_conditional_variant:Nnn \__cdcmd_clist_if_in:Nn
  { NV, No, cn, cV, co } { p, T, F, TF }
\prg_new_conditional:Npnn \__cdcmd_clist_if_in:nn #1#2 { p, T, F, TF }
  {
    \int_compare:nTF
      { 0 \clist_map_tokens:nn {#1} { \__cdcmd_if_eq_break:ee {#2} } > 0 }
      { \prg_return_true: } { \prg_return_false: }
  }
\prg_generate_conditional_variant:Nnn \__cdcmd_clist_if_in:nn { nV, no } { p, T, F, TF }
\cs_new:Npn \__cdcmd_if_eq_break:ee #1#2
  {
    \str_if_eq:eeT {#1} {#2} { \clist_map_break:n { 1 } }
  }
\scan_new:N \s__cdcmd_mark
\scan_new:N \s__cdcmd_stop
\cs_new:Npn \cdcmd_any_case_true:nTF { \exp:w \__cdcmd_any_case_true:nTF }
\cs_new:Npn \cdcmd_any_case_true:n #1 { \exp:w \__cdcmd_any_case_true:nTF {#1} { } { } }
\cs_new:Npn \cdcmd_all_case_true:nTF { \exp:w \__cdcmd_all_case_true:nTF }
\cs_new:Npn \cdcmd_all_case_true:n #1 { \exp:w \__cdcmd_all_case_true:nTF {#1} { } { } }
\cs_new:Npn \cdcmd_any_case_false:nTF { \exp:w \__cdcmd_any_case_false:nTF }
\cs_new:Npn \cdcmd_any_case_false:n #1 { \exp:w \__cdcmd_any_case_false:nTF {#1} { } { } }
\cs_new:Npn \cdcmd_all_case_false:nTF { \exp:w \__cdcmd_all_case_false:nTF }
\cs_new:Npn \cdcmd_all_case_false:n #1 { \exp:w \__cdcmd_all_case_false:nTF {#1} { } { } }
\cs_new:Npn \__cdcmd_any_case_true:nTF #1#2#3
  {
    \__cdcmd_case:Nw \cdcmd_any_if:nTF #1 { * } { }
      \s__cdcmd_mark {#2} \s__cdcmd_mark {#3} \s__cdcmd_stop
  }
\cs_new:Npn \__cdcmd_all_case_true:nTF #1#2#3
  {
    \__cdcmd_case:Nw \cdcmd_all_if:nTF #1 { * } { }
      \s__cdcmd_mark {#2} \s__cdcmd_mark {#3} \s__cdcmd_stop
  }
\cs_new:Npn \__cdcmd_any_case_false:nTF #1#2#3
  {
    \__cdcmd_case:Nw \cdcmd_any_if:nFT #1 { * } { }
      \s__cdcmd_mark {#2} \s__cdcmd_mark {#3} \s__cdcmd_stop
  }
\cs_new:Npn \__cdcmd_all_case_false:nTF #1#2#3
  {
    \__cdcmd_case:Nw \cdcmd_all_if:nFT #1 { * } { }
      \s__cdcmd_mark {#2} \s__cdcmd_mark {#3} \s__cdcmd_stop
  }
\cs_new:Npn \__cdcmd_case:Nw #1#2#3
  { #1 {#2} { \__cdcmd_case_end:nw {#3} } { \__cdcmd_case:Nw #1 } }
\cs_new:Npn \__cdcmd_case_end:nw #1#2#3 \s__cdcmd_mark #4#5 \s__cdcmd_stop
  { \exp_end: #1 #4 }
\NewDocumentCommand \newcondition { >{ \TrimSpaces } m } { \cdcmd_new:nn {#1} }
\NewDocumentCommand \setcondition { t+ }
  { \IfBooleanTF {#1} { \cdcmd_set:n } { \cdcmd_clear_set:n } }
\NewDocumentCommand \clearcondition { !O{*} }
  {
    \clist_map_inline:nn {#1}
      {
        \str_if_eq:eeTF {##1} { \c_cdcmd_all_str }
          {
            \clist_map_break:n
              { \exp_after:wN \clearcondition \exp_after:wN [ \g__cdcmd_clist ] }
          }
          {
            \cdcmd_if_exist:nTF {##1}
              { \clist_clear:c { l__cdcmd_curr_condition@ ##1 _clist } }
              { \msg_warning:nnn { cdcmd } { condition-not-exist } {##1} }
          }
      }
  }
\NewExpandableDocumentCommand \econditionif { s O{*} +m +m }
  {
    \IfBooleanTF {#1}
      { \cdcmd_all_if:nTF }
      { \cdcmd_any_if:nTF }
        {#2} {#3} {#4}
  }
\NewExpandableDocumentCommand \econditioncmd { s O{*} +m }
  {
    \IfBooleanTF {#1}
      { \cdcmd_all_if:nTF }
      { \cdcmd_any_if:nTF }
        {#2} {#3} { }
  }
\NewExpandableDocumentCommand \econditioncase { s +m }
  {
    \IfBooleanTF {#1}
      { \cdcmd_all_case:n {#2} }
      { \cdcmd_any_case:n {#2} }
  }
\NewExpandableDocumentCommand \econditioncaseTF { s +m }
  {
    \IfBooleanTF {#1}
      { \cdcmd_all_case:nTF {#2} }
      { \cdcmd_any_case:nTF {#2} }
  }
\NewDocumentCommand \conditionif { s O{*} +m +m }
  {
    \IfBooleanTF {#1}
      { \cdcmd_all_if:nTF }
      { \cdcmd_any_if:nTF }
        {#2} {#3} {#4}
  }
\NewDocumentCommand \conditioncmd { s O{*} +m }
  {
    \IfBooleanTF {#1}
      { \cdcmd_all_if:nTF }
      { \cdcmd_any_if:nTF }
        {#2} {#3} { }
  }
\NewDocumentCommand \conditioncase { s t! +m }
  {
    \IfBooleanTF {#2}
      {
        \IfBooleanTF {#1}
          { \cdcmd_all_case_false:n {#3} }
          { \cdcmd_any_case_false:n {#3} }
      }
      {
        \IfBooleanTF {#1}
          { \cdcmd_all_case_true:n {#3} }
          { \cdcmd_any_case_true:n {#3} }
      }
  }
\NewDocumentCommand \conditioncaseTF { s t! +m }
  {
    \IfBooleanTF {#2}
      {
        \IfBooleanTF {#1}
          { \cdcmd_all_case_false:nTF {#3} }
          { \cdcmd_any_case_false:nTF {#3} }
      }
      {
        \IfBooleanTF {#1}
          { \cdcmd_all_case_true:nTF {#3} }
          { \cdcmd_any_case_true:nTF {#3} }
      }
  }
\str_const:Nn \c_cdcmd_pair_u_str { cdcmd@u@ }
\str_const:Nn \c_cdcmd_pair_n_str { cdcmd@n@ }
\cs_new_nopar:Npn \__cdcmd_cs_pair_u:N #1
  { \c_cdcmd_pair_u_str \cs_to_str:N #1 }
\cs_new_nopar:Npn \__cdcmd_cs_pair_n:N #1
  { \c_cdcmd_pair_n_str \cs_to_str:N #1 }
\cs_new:Npn \__cdcmd_arg_spec_from_num:nn #1#2
  {
    \if_case:w 0#1 \exp_stop_f:
    \or: #2 \or: #2#2 \or: #2#2#2 \or: #2#2#2#2 \or: #2#2#2#2#2 \or: #2#2#2#2#2#2
    \or: #2#2#2#2#2#2#2 \or: #2#2#2#2#2#2#2#2 \else: #2#2#2#2#2#2#2#2#2 \fi:
  }
\cs_new_nopar:Npn \__cdcmd_cs_pair_u:Nn #1#2
  {
    \c_cdcmd_pair_u_str
    \cs_to_str:N #1 :
    \__cdcmd_arg_spec_from_num:nn {#2} { n }
  }
\cs_new_nopar:Npn \__cdcmd_cs_pair_n:Nn #1#2
  {
    \c_cdcmd_pair_n_str
    \cs_to_str:N #1 :
    \__cdcmd_arg_spec_from_num:nn {#2} { n }
  }
\cs_new:Npn \__cdcmd_new_cdcmd_command:NN #1#2
  {
    \cs_new_protected:Npn #1 ##1##2##3
      {
        #2 ##1 { t+ m }
          {
            \IfBooleanTF {####1}
              { \cdcmd_all_if:nTF }
              { \cdcmd_any_if:nTF }
                {####2}
                { \use:c { \__cdcmd_cs_pair_u:N ##1 } }
                { \use:c { \__cdcmd_cs_pair_n:N ##1 } }
          }
        \exp_args:Nc #2
          { \__cdcmd_cs_pair_u:N ##1 } {##2} {##3}
        \exp_args:Nc #2
          { \__cdcmd_cs_pair_n:N ##1 } {##2} { }
      }
  }
\seq_const_from_clist:Nn \c__cdcmd_Command_seq
  {
    \NewDocumentCommand ,
    \RenewDocumentCommand ,
    \ProvideDocumentCommand ,
    \DeclareDocumentCommand ,
    \NewExpandableDocumentCommand ,
    \RenewExpandableDocumentCommand ,
    \ProvideExpandableDocumentCommand ,
    \DeclareExpandableDocumentCommand ,
  }
\seq_const_from_clist:Nn \c__cdcmd_COMMAND_seq
  {
    \NewConditionCommand ,
    \RenewConditionCommand ,
    \ProvideConditionCommand ,
    \DeclareConditionCommand ,
    \NewExpandableConditionCommand ,
    \RenewExpandableConditionCommand ,
    \ProvideExpandableConditionCommand ,
    \DeclareExpandableConditionCommand ,
  }
\seq_mapthread_function:NNN
  \c__cdcmd_COMMAND_seq
  \c__cdcmd_Command_seq
  \__cdcmd_new_cdcmd_command:NN
\cs_new:Npn \__cdcmd_new_cdcmd_cmd_no:nnn #1#2#3
  {
    \cs_new_protected:Npn #1 ##1##2##3
      {
        #3 ##1 { t+ m }
          {
            \IfBooleanTF {####1}
              { \cdcmd_all_if:nTF }
              { \cdcmd_any_if:nTF }
                { ####2 }
                { \use:c { \__cdcmd_cs_pair_u:Nn ##1 {##2} } }
                { \use:c { \__cdcmd_cs_pair_n:Nn ##1 {##2} } }
          }
        #2 { \__cdcmd_cs_pair_u:Nn ##1 {##2} } {##3}
        #2 { \__cdcmd_cs_pair_n:Nn ##1 {##2} } { }
      }
  }
\cs_generate_variant:Nn \__cdcmd_new_cdcmd_cmd_no:nnn { xxx }
\seq_const_from_clist:Nn \c__cdcmd_cmd_no_seq
  {
    \cs_set_protected:cn , \cs_set_protected_nopar:cn ,
    \cs_set_protected:cn , \cs_set_protected_nopar:cn ,
    \cs_set_protected:cn , \cs_set_protected_nopar:cn ,
    \cs_set:cn , \cs_set_nopar:cn ,
    \cs_set:cn , \cs_set_nopar:cn ,
    \cs_set:cn , \cs_set_nopar:cn ,
  }
\seq_const_from_clist:Nn \c__cdcmd_Cmd_no_seq
  {
    \NewDocumentCommand , \NewDocumentCommand ,
    \RenewDocumentCommand , \RenewDocumentCommand ,
    \DeclareDocumentCommand , \DeclareDocumentCommand ,
    \NewExpandableDocumentCommand , \NewExpandableDocumentCommand ,
    \RenewExpandableDocumentCommand , \RenewExpandableDocumentCommand ,
    \DeclareExpandableDocumentCommand , \DeclareExpandableDocumentCommand ,
  }
\seq_const_from_clist:Nn \c__cdcmd_CMD_no_seq
  {
    \__cdcmd_new_cdcmd_p_l_num:Nnn , \__cdcmd_new_cdcmd_p_nl_num:Nnn ,
    \__cdcmd_renew_cdcmd_p_l_num:Nnn , \__cdcmd_renew_cdcmd_p_nl_num:Nnn ,
    \__cdcmd_declare_cdcmd_p_l_num:Nnn , \__cdcmd_declare_cdcmd_p_nl_num:Nnn ,
    \__cdcmd_new_cdcmd_np_l_num:Nnn , \__cdcmd_new_cdcmd_np_nl_num:Nnn ,
    \__cdcmd_renew_cdcmd_np_l_num:Nnn , \__cdcmd_renew_cdcmd_np_nl_num:Nnn ,
    \__cdcmd_declare_cdcmd_np_l_num:Nnn , \__cdcmd_declare_cdcmd_np_nl_num:Nnn ,
  }
\int_step_inline:nn { 6 }
  {
    \__cdcmd_new_cdcmd_cmd_no:xxx
      { \seq_item:Nn \c__cdcmd_CMD_no_seq {#1} }
      { \seq_item:Nn \c__cdcmd_cmd_no_seq {#1} }
      { \seq_item:Nn \c__cdcmd_Cmd_no_seq {#1} }
  }
\tl_new:N \l__cdcmd_arg_spec_tl
\cs_new:Npn \__cdcmd_generate_arg_spec:nnn #1#2#3
  {
    \tl_set:Nn \l__cdcmd_arg_spec_tl { O{#2} }
    \if_int_compare:w #1 > 1 \exp_stop_f:
      \int_step_inline:nn {#1-1} { \tl_put_right:Nn \l__cdcmd_arg_spec_tl {#3} }
    \fi:
  }
\cs_new:Npn \__cdcmd_new_cdcmd_cmd_o_aux:nn #1#2
  {
    \cs_new_protected:Npn #1 ##1##2##3##4##5
      {
        #2 ##1 { t+ m }
          {
            \IfBooleanTF{####1}
              { \cdcmd_all_if:nTF }
              { \cdcmd_any_if:nTF }
                {####2}
                { \use:c { \__cdcmd_cs_pair_u:N ##1 } }
                { \use:c { \__cdcmd_cs_pair_n:N ##1 } }
          }
        \__cdcmd_generate_arg_spec:nnn {##2} {##3} {##5}
        \exp_args:NcV #2 { \__cdcmd_cs_pair_u:N ##1 } \l__cdcmd_arg_spec_tl {##4}
        \exp_args:NcV #2 { \__cdcmd_cs_pair_n:N ##1 } \l__cdcmd_arg_spec_tl { }
      }
  }
\seq_const_from_clist:Nn \c__cdcmd_CMD_o_seq
  { \NewDocumentCommand , \RenewDocumentCommand , \DeclareDocumentCommand }
\seq_const_from_clist:Nn \c__cdcmd_cmd_o_seq
  {
    \__cdcmd_new_cdcmd_o_num:Nnnnn ,
    \__cdcmd_renew_cdcmd_o_num:Nnnnn ,
    \__cdcmd_declare_cdcmd_o_num:Nnnnn ,
  }
\seq_mapthread_function:NNN
  \c__cdcmd_cmd_o_seq
  \c__cdcmd_CMD_o_seq
  \__cdcmd_new_cdcmd_cmd_o_aux:nn
\cs_new_protected:Npn \__cdcmd_new_cdcmd_cmd_ne_aux:n #1
  {
    \exp_args:Nc \NewDocumentCommand { #1 conditioncommand } { s m O{0} o +m }
      {
        \IfBooleanTF{##1}
          {
            \IfNoValueTF{##4}
              { \use:c { __cdcmd_ #1 _cdcmd_p_nl_num:Nnn } ##2 {##3} {##5} }
              { \use:c { __cdcmd_ #1 _cdcmd_o_num:Nnnnn } ##2 {##3} {##4} {##5} { m } }
          }
          {
            \IfNoValueTF{##4}
              { \use:c { __cdcmd_ #1 _cdcmd_p_l_num:Nnn } ##2 {##3} {##5} }
              { \use:c { __cdcmd_ #1 _cdcmd_o_num:Nnnnn } ##2 {##3} {##4} {##5} { +m } }
          }
      }
  }
\clist_map_function:nN { new, renew, declare } \__cdcmd_new_cdcmd_cmd_ne_aux:n
\NewDocumentCommand \provideconditioncommand { s m O{0} o +m }
  {
    \cs_if_free:NT #2
      {
        \IfBooleanTF{#1}
          {
            \IfNoValueTF{#4}
              { \newconditioncommand * #2 [#3] {#5} }
              { \newconditioncommand * #2 [#3] [#4] {#5} }
          }
          {
            \IfNoValueTF{#4}
              { \newconditioncommand #2 [#3] {#5} }
              { \newconditioncommand #2 [#3] [#4] {#5} }
          }
      }
  }

\int_step_inline:nnnn { 7 } { 1 } { 12 }
  {
    \__cdcmd_new_cdcmd_cmd_no:xxx
      { \seq_item:Nn \c__cdcmd_CMD_no_seq {#1} }
      { \seq_item:Nn \c__cdcmd_cmd_no_seq {#1} }
      { \seq_item:Nn \c__cdcmd_Cmd_no_seq {#1} }
  }

\cs_new_protected:Npn \__cdcmd_new_cdcmd_cmd_e_no_aux:n #1
  {
    \exp_args:Nc \NewDocumentCommand { #1 econditioncommand } { s m O{0} +m }
      {
        \IfBooleanTF{##1}
          { \use:c { __cdcmd_ #1 _cdcmd_np_nl_num:Nnn } ##2 {##3} {##4} }
          { \use:c { __cdcmd_ #1 _cdcmd_np_l_num:Nnn } ##2 {##3} {##4} }
      }
  }
\clist_map_function:nN { new, renew, declare } \__cdcmd_new_cdcmd_cmd_e_no_aux:n
\NewDocumentCommand \provideeconditioncommand { s m O{0} +m }
  {
    \cs_if_free:NT #2
      {
        \IfBooleanTF{#1}
          { \neweconditioncommand * #2 [#3] {#4} }
          { \neweconditioncommand #2 [#2] {#4} }
      }
  }
%% 
%%     This work consists of the file  cdcmd.dtx,
%%               and the derived files cdcmd.pdf,
%%                                     cdcmd.sty,
%%                                     cdcmd-cn.tex,
%%                                     cdcmd-cn.pdf,
%%                                     cdcmd-test.tex,
%%                                     cdcmd.ins and
%%                                     README.md
%%
%% End of file `cdcmd.sty'.
