\ProvidesFile{ext-biblatex-aux.def}
  [2018/03/20 v0.1a auxiliaries for extended biblatex citation style (MW)]

\def\extblx@requiredbiblatexversion{3.11}
\def\extblx@requiredbiblatexdate{2018/02/20}

\@ifpackagelater{biblatex}{\extblx@requiredbiblatexdate}
  {}
  {\PackageWarningNoLine{extbiblatex}
     {Outdated version of biblatex detected.\MessageBreak
      Upgrade to biblatex \extblx@requiredbiblatexversion\space
      (\extblx@requiredbiblatexdate) or later.\MessageBreak
      I found '\csuse{abx@version} (\csuse{abx@date})'}}

%{<context>}{<opening delim>}{<closing delim>}
\newcommand*{\DeclareOuterCiteDelim}{%
  \extblx@declareciteddelim{outer}}
\newrobustcmd*{\DeclareInnerCiteDelim}{%
  \extblx@declareciteddelim{inner}}

%{<inner/outer>}{<cite context>}{<opening delim>}{<closing delim>}
\def\extblx@declareciteddelim#1#2#3#4{%
  \csdef{extblx@citedelim@#2@#1@open}{#3}%
  \csdef{extblx@citedelim@#2@#1@close}{#4}}

%{<context>}
\newcommand*{\UndeclareOuterCiteDelim}{%
  \extblx@undeclareciteddelim{outer}}
\newrobustcmd*{\UndeclareInnerCiteDelim}{%
  \extblx@undeclareciteddelim{inner}}

%{<inner/outer>}{<cite context>}
\def\extblx@undeclareciteddelim#1#2{%
  \csundef{extblx@citedelim@#2@#1@open}%
  \csundef{extblx@citedelim@#2@#1@close}}

%{<alias>}{<cite context>}
\newcommand*{\DeclareOuterCiteDelimAlias}{%
  \@ifstar
    {\extblx@declareciteddelim@alias@i{outer}}
    {\extblx@declareciteddelim@alias{outer}}}
\newcommand*{\DeclareInnerCiteDelimAlias}{%
  \@ifstar
    {\extblx@declareciteddelim@alias@i{inner}}
    {\extblx@declareciteddelim@alias{inner}}}

%{<inner/outer>}{<alias>}{<cite context>}
\def\extblx@declareciteddelim@alias#1#2#3{%
  \csdef{extblx@citedelim@#2@#1@open}{\csuse{extblx@citedelim@#3@#1@open}}%
  \csdef{extblx@citedelim@#2@#1@close}{\csuse{extblx@citedelim@#3@#1@close}}}
\def\extblx@declareciteddelim@alias@i#1#2#3{%
  \csletcs{extblx@citedelim@#2@#1@open}{extblx@citedelim@#3@#1@open}%
  \csletcs{extblx@citedelim@#2@#1@close}{extblx@citedelim@#3@#1@close}}

% declare \mk...delim commands
\newrobustcmd*{\extblx@create@mkcitedelim}[2]{%
  \protected\csdef{mk#1#2delim}##1{%
    \begingroup
      \blx@blxinit
      \blx@setsfcodes
      \csuse{extblx@citedelim@#2@#1@open}%
      ##1%
      \csuse{extblx@citedelim@#2@#1@close}%
    \endgroup}}

\extblx@create@mkcitedelim{outer}{cite}
\extblx@create@mkcitedelim{outer}{parencite}
\extblx@create@mkcitedelim{outer}{textcite}
\extblx@create@mkcitedelim{outer}{bibinxrefcite}

\extblx@create@mkcitedelim{inner}{cite}
\extblx@create@mkcitedelim{inner}{parencite}
\extblx@create@mkcitedelim{inner}{textcite}
\extblx@create@mkcitedelim{inner}{footcite}

% smartcite is special
% According to the docs it is like \parencite in a footnote and \footcite in
% the body.
% To mirror that as closely as possible, we need to change the delimiter
% context. The delimcontext is set in the pre-code, it is too late to detect
% a footnote at that point (since we will have started the footnote ourselves
% with \mkbibfootnote from the body), so we need to do it earlier.
\newrobustcmd*{\mksmartcite}[1]{%
  \iffootnote
    {\mkouterparencitedelim{%
       \def\extblx@thisdelimcontext{parencite}%
       #1}}
    {\mkbibfootnote{%
       \def\extblx@thisdelimcontext{footcite}%
       #1}}}

\endinput
