% $Id: biblatex.sty,v 0.8e 2009/07/04 15:02:31 lehman beta $

% Copyright (c) 2006-2009 Philipp Lehman.
%
% Permission is granted to copy, distribute and/or modify this
% software under the terms of the LaTeX Project Public License
% (LPPL), version 1.3.
%
% The LPPL maintenance status of this software is
% 'author-maintained'.
%
% This software is provided 'as is', without warranty of any kind,
% either expressed or implied, including, but not limited to, the
% implied warranties of merchantability and fitness for a
% particular purpose.

\def\abx@rcsid$#1: #2 #3 #4 #5${#4 v#3}
\def\abx@bbxid$#1: #2 #3 #4 #5${#4 v#3 biblatex bibliography style}
\def\abx@cbxid$#1: #2 #3 #4 #5${#4 v#3 biblatex citation style}
\def\abx@lbxid$#1: #2 #3 #4 #5${#4 v#3 biblatex localization}

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{biblatex}
[\abx@rcsid $Id: biblatex.sty,v 0.8e 2009/07/04 15:02:31 lehman beta $
 programmable bibliographies]

\def\blx@version$#1: #2 ${#2}
\edef\blx@version{\blx@version$Revision: 0.8d $}

%% Compatibility and requirements

\RequirePackage{etoolbox}
\RequirePackage{keyval}
\RequirePackage{ifthen}
\RequirePackage{url}

\@ifpackagelater{etoolbox}{2008/06/28}
  {}
  {\PackageError{biblatex}
     {Outdated 'etoolbox' package}
     {Upgrade to etoolbox v1.7 (2008/06/28) or later.\MessageBreak
      I found: '\csuse{ver@etoolbox.sty}'.\MessageBreak
      This is a fatal error. I'm aborting now.}%
   \endinput}

\AtEndPreamble{%
  \def\do#1{%
    \@ifpackageloaded{#1}
      {\blx@error{Incompatible package '#1'}{%
         The '#1' package and biblatex are
         incompatible.\MessageBreak See the
         biblatex manual for details}}
      {}}%
  \docsvlist{%
    amsrefs,apacite,babelbib,backref,bibtopic,bibunits,chapterbib,
    cite,citeref,drftcite,footbib,inlinebib,jurabib,mcite,mciteplus,
    mlbib,multibbl,multibib,natbib,opcit,overcite,splitbib}%
  \@ifpackageloaded{babel}
    {\blx@mkbabel}
    {\blx@mknobabel}%
  \csuse{abx@extras@\blx@languagename}%
  \csuse{abx@strings@\blx@languagename}%
  \undef\blx@mkbabel
  \undef\blx@mknobabel
  \ifnum\blx@hyperref=\z@
    \blx@mknohyperref
  \else
    \@ifpackageloaded{hyperref}
      {\blx@mkhyperref}
      {\ifnum\blx@hyperref=\@ne
	 \blx@warning@noline{%
           Missing 'hyperref' package.\MessageBreak
	   Setting hyperref=false}%
       \fi
       \blx@mknohyperref}%
  \fi
  \providecommand*{\nolinkurl}{\url}%
  \undef\blx@mkhyperref
  \undef\blx@mknohyperref
  \ifundef\TE@hook
    {\let\TE@hook\@empty
     \toggletrue{blx@tempa}%
     \def\do#1{%
       \patchcmd#1%
         {\let\isundefined\TE@undef}
         {\let\isundefined\TE@undef\TE@hook}
         {\togglefalse{blx@tempa}\listbreak}
         {}}%
     \docsvlist{%
       \ifthenelse,%          ifthen
       \org@ifthenelse,%      babel
       \HyOrg@ifthenelse,%    hyperref
       \NROrg@ifthenelse}%    nameref
     \iftoggle{blx@tempa}
       {\blx@err@patch{'ifthen' package}}
       {}}
    {}%
  \appto\TE@hook{\blx@TE@hook}%
  \toggletrue{blx@tempa}%
  \def\do#1{%
    \patchcmd#1%
      {\color@begingroup}
      {\color@begingroup\toggletrue{blx@footnote}}
      {\togglefalse{blx@tempa}\listbreak}
      {}}%
  \docsvlist{%
    \@footnotetext,%          latex
    \H@@footnotetext,%        hyperref
    \scr@saved@footnotetext,% koma-script 3.x
    \l@dold@footnotetext,%    ledmac
    \l@doldold@footnotetext,% ledmac
    \@fntORI}%                frenchle
  \@ifclassloaded{memoir}%    memoir
    {\togglefalse{blx@tempa}%
     \def\do#1{%
       \patchcmd#1%
         {\color@begingroup}
         {\color@begingroup\toggletrue{blx@footnote}}
         {}
         {\toggletrue{blx@tempa}}}%
     \docsvlist{%
       \m@mold@footnotetext,%
       \@twocolfootnotetext,%
       \@threecolfootnotetext,%
       \@parafootnotetext}}
    {}%
  \iftoggle{blx@tempa}
    {\blx@warning@noline{%
       Patching footnotes failed.\MessageBreak
       Will try to fork \string\@footnotetext}%
     \let\blx@org@footnotetext\@footnotetext
     \long\def\@footnotetext#1{%
       \toggletrue{blx@footnote}%
       \blx@org@footnotetext{#1}%
       \togglefalse{blx@footnote}}}
    {}%
  \@ifpackageloaded{endnotes}
    {\patchcmd\theendnotes
       {\enoteformat}
       {\toggletrue{blx@footnote}\enoteformat}
       {}
       {\blx@err@patch{'endnotes' package}}}
    {}%
  \@ifpackageloaded{bigfoot}
    {\apptocmd\@makefnstartbox
       {\toggletrue{blx@footnote}}
       {}
       {\blx@err@patch{'bigfoot' package}}}
    {}%
  \@ifpackageloaded{showkeys}
    {\ifdef\SK@
       {\ifundef\SK@cite % = 'notcite' disabled
	  {\AtEveryBibitem{\SK@\SK@@label{\thefield{entrykey}}}%
           \AtEveryLositem{\SK@\SK@@label{\thefield{entrykey}}}%
           \AtEveryCitekey{\SK@\SK@@ref{\thefield{entrykey}}}}
	  {}}
       {}}
    {}%
  \@ifpackageloaded{csquotes}
    {\@ifpackagelater{csquotes}{2009/05/30}
       {}
       {\blx@error
          {Outdated 'csquotes' package}
	  {Upgrade to csquotes v4.4 (2009/05/30) or later.\MessageBreak
           I found: '\csuse{ver@csquotes.sty}'}}%
     \BlockquoteDisable{\let\blx@thecheckpunct\@gobble}}
    {\@ifpackageloaded{babel}
       {\blx@warning@noline{%
          'babel' detected but 'csquotes' missing.\MessageBreak
          Loading 'csquotes' is strongly recommended}}
       {}%
     \newcommand*{\@quotelevel}{}%
     \newcount\@quotelevel
     \newcommand*{\@setquotesfcodes}{}%
     \let\@setquotesfcodes\relax
     \newcommand*{\@ifquotemarker}{}%
     \let\@ifquotemarker\@secondoftwo
     \newrobustcmd*{\initoquote}{\@quotelevel\@ne}%
     \newrobustcmd*{\initiquote}{\@quotelevel\tw@}%
     \newcommand*{\textooquote}{``}%
     \newcommand*{\textcoquote}{''}%
     \newcommand*{\textoiquote}{`}%
     \newcommand*{\textciquote}{'}%
     \newrobustcmd*{\enquote}{\@ifstar\blx@enquote@ii\blx@enquote}%
     \def\blx@enquote{%
       \ifnum\@quotelevel>\z@
         \expandafter\blx@enquote@ii
       \else
         \expandafter\blx@enquote@i
       \fi}%
     \long\def\blx@enquote@i#1{%
       \begingroup\initoquote
       \textooquote#1\textcoquote
       \endgroup}%
     \long\def\blx@enquote@ii#1{%
       \begingroup\initiquote
       \textoiquote#1\textciquote
       \endgroup}%
     \appto\blx@setsfcodes{%
       \sfcode`\`=\z@
       \sfcode`\'=\z@}}%
  \apptocmd\@floatboxreset
    {\boolfalse{citetracker}%
     \boolfalse{pagetracker}}
    {}
    {\blx@err@patch{floats}}%
  \addtocontents{toc}{%
     \string\boolfalse{citerequest}%
     \string\boolfalse{citetracker}%
     \string\boolfalse{pagetracker}}%
  \addtocontents{lof}{%
     \string\boolfalse{citerequest}%
     \string\boolfalse{citetracker}%
     \string\boolfalse{pagetracker}}%
  \addtocontents{lot}{%
     \string\boolfalse{citerequest}%
     \string\boolfalse{citetracker}%
     \string\boolfalse{pagetracker}}%
  \let\do\noexpand}

\begingroup
\@makeother\#
\AtEndPreamble{%
  \patchcmd\addtocontents
    {\string\@writefile}
    {\string\@writefile{#1}{\string\defcounter{refsection}{\the\c@refsection}}\blx@nl
     \string\@writefile}
    {}
    {\blx@err@patch{\string\addtocontents}}}
\endgroup

% trick hyperref into believing we're natbib
\let\NAT@parse\@empty
% trick showkeys into believing we're havard
\let\HAR@checkdef\@empty

% koma-script
\newcommand{\ifkomabibtotoc}[2]{#2}
\newcommand{\ifkomabibtotocnumbered}[2]{#2}
\ifdef\ds@bibtotoc
  {\DeclareOption{bibtotoc}{%
     \let\ifkomabibtotoc\@firstoftwo}
   \DeclareOption{bibtotocnumbered}{%
     \let\ifkomabibtotoc\@firstoftwo
     \let\ifkomabibtotocnumbered\@firstoftwo}
   \DeclareOption{bibliography=nottotoc}{%
     \let\ifkomabibtotoc\@secondoftwo
     \let\ifkomabibtotocnumbered\@secondoftwo}
   \DeclareOption{bibliography=totoc}{%
     \let\ifkomabibtotoc\@firstoftwo}
   \DeclareOption{bibliography=totocnumbered}{%
     \let\ifkomabibtotoc\@firstoftwo
     \let\ifkomabibtotocnumbered\@firstoftwo}}
  {}

% memoir
\@ifclassloaded{memoir}
  {\newcommand*{\ifmemoirbibintoc}{%
     \ifnobibintoc
       \expandafter\@secondoftwo
     \else
       \expandafter\@firstoftwo
     \fi}}
  {\newcommand{\ifmemoirbibintoc}[2]{#2}}

%% Category codes

\def\blx@docatcodes{%
  \do\=\do\<\do\>\do\-\do\"\do\'\do\`\do\.%
  \do\,\do\;\do\:\do\!\do\?\do\/}
\def\do#1{\noexpand\do\noexpand#1{\the\catcode`#1}}
\edef\blx@catcodes{\blx@docatcodes\do\^\do\~\do\&\do\|}

\def\blx@saneccodes{%
  \catcode`\~=\active
  \let\do\@makeother
  \blx@docatcodes
  \let\do\noexpand}

\blx@saneccodes
\catcode`\&=3
\catcode`\|=3
\catcode`\^=7
\def\blx@nl{^^J}

%% Allocation

\newcounter{listtotal}
\def\thelisttotal{\the\c@listtotal}
\newcounter{listcount}
\def\thelistcount{\the\c@listcount}
\newcounter{liststart}
\def\theliststart{\the\c@liststart}
\newcounter{liststop}
\def\theliststop{\the\c@liststop}
\newcounter{citecount}
\def\thecitecount{\the\c@citecount}
\newcounter{citetotal}
\def\thecitetotal{\the\c@citetotal}
\newcounter{multicitecount}
\def\themulticitecount{\the\c@multicitecount}
\newcounter{multicitetotal}
\def\themulticitetotal{\the\c@multicitetotal}
\newcounter{instcount}
\def\theinstcount{\the\c@instcount}
\newcounter{maxnames}
\def\themaxnames{\the\c@maxnames}
\newcounter{minnames}
\def\theminnames{\the\c@minnames}
\newcounter{maxitems}
\def\themaxitems{\the\c@maxitems}
\newcounter{minitems}
\def\theminitems{\the\c@minitems}
\newcounter{uniquename}
\def\theuniquename{\the\c@uniquename}
\newcounter{refsection}
\def\therefsection{\the\c@refsection}
\newcounter{refsegment}
\def\therefsegment{\the\c@refsegment}
\newcounter{maxlabelyear}
\def\themaxlabelyear{\the\c@maxlabelyear}
\newcounter{maxextraalpha}
\def\themaxextraalpha{\the\c@maxextraalpha}
\newcounter{abbrvpenalty}
\def\theabbrvpenalty{\the\c@abbrvpenalty}
\newcounter{highnamepenalty}
\def\thehighnamepenalty{\the\c@highnamepenalty}
\newcounter{lownamepenalty}
\def\thelownamepenalty{\the\c@lownamepenalty}

\newcount\blx@maxsection
\newcount\blx@maxsegment

\newlength{\labelnumberwidth}
\newlength{\labelalphawidth}
\newlength{\shorthandwidth}
\newlength{\biblabelsep}
\ifdef\bibitemsep % memoir
  {}
  {\newlength{\bibitemsep}}
\newlength{\bibnamesep}
\newlength{\bibinitsep}
\newlength{\bibparsep}
\newlength{\bibhang}

\newbool{citetracker}
\newbool{pagetracker}
\newbool{citerequest}
\booltrue{citerequest}

\newtoggle{blx@tempa}
\newtoggle{blx@tempb}
\newtoggle{blx@block}
\newtoggle{blx@unit}
\newtoggle{blx@insert}
\newtoggle{blx@lastins}
\newtoggle{blx@debug}
\newtoggle{blx@defernums}
\newtoggle{blx@footnote}
\newtoggle{blx@labelalpha}
\newtoggle{blx@labelnumber}
\newtoggle{blx@labelyear}
\newtoggle{blx@natbib}
\newtoggle{blx@loadfiles}
\newtoggle{blx@singletitle}
\newtoggle{blx@terseinits}
\newtoggle{blx@firstinits}
\newtoggle{blx@useauthor}
\newtoggle{blx@useeditor}
\newtoggle{blx@usetranslator}
\newtoggle{blx@useprefix}
\newtoggle{blx@addset}
\newtoggle{blx@setonly}
\newtoggle{blx@dataonly}
\newtoggle{blx@skipbib}
\newtoggle{blx@skiplos}
\newtoggle{blx@skiplab}
\newtoggle{blx@citation}
\newtoggle{blx@bibliography}
\newtoggle{blx@recode}
\newtoggle{blx@index}
\newtoggle{blx@citindex}
\newtoggle{blx@bibindex}

\def\blx@backend{0}
\def\blx@uniquename{0}

\newread\blx@auxin
\newwrite\blx@auxout

\def\blx@onlypreamble#1{%
  \gappto\blx@dopreamblecmds{\do#1}}

\def\blx@dopreamblecmds{%
  \do\blx@dopreamblecmds
  \do\blx@onlypreamble}

%% Initialization

\def\blx@blxinit{\let\blx@blxinit\relax}
\edef\blx@auxfile{\jobname}
\let\blx@theauxout\@mainaux
\newcommand*{\labelalphaothers}{+}
\newcommand*{\blxauxsuffix}{-blx}

\begingroup
\def\blx@tempa#1"#2{%
  #1\ifx#2\@empty\else
    \expandafter\blx@tempa
  \fi#2}
\edef\blx@ctrlfile{%
  \noexpand\blx@tempa
  \expandafter\blx@tempa\jobname"\@empty
  \space\noexpand\@empty}
\def\blx@tempa#1 #2{%
  #1\ifx#2\@empty\else
    \string_\expandafter\blx@tempa
  \fi#2}
\xdef\blx@ctrlfile{\blx@ctrlfile}
\endgroup

\def\blx@secinit{%
  \ifcsundef{blx@sort@\the\c@refsection}
    {\global\cslet{blx@sort@\the\c@refsection}\@empty}
    {}%
  \ifcsundef{blx@cite@\the\c@refsection}
    {\global\cslet{blx@cite@\the\c@refsection}\@empty}
    {}%
  \ifcsundef{blx@bsee@\the\c@refsection}
    {\global\cslet{blx@bsee@\the\c@refsection}\@empty}
    {}%
  \ifcsundef{blx@fsee@\the\c@refsection}
    {\global\cslet{blx@fsee@\the\c@refsection}\@empty}
    {}%
  \blx@ibidreset@force
  \blx@idemreset@force
  \blx@opcitreset@force
  \blx@loccitreset@force
  \ifcsundef{blx@segm@\the\c@refsection @\the\c@refsegment}
    {\global\cslet{blx@segm@\the\c@refsection @\the\c@refsegment}\@empty}
    {}}

%% Auxiliary commands

\protected\def\blx@safe@actives{%
  \let\blx@if@safe@actives\if@safe@actives
  \let\if@safe@actives\iftrue}

\protected\def\blx@rest@actives{%
  \let\if@safe@actives\blx@if@safe@actives}

% {<field>} => \do{<item1>}\do{<item2>}...

\def\blx@imc@docsvfield#1{%
  \blx@imc@iffieldundef{#1}
    {}
    {\expandafter\expandafter\expandafter\docsvlist
     \expandafter\expandafter\expandafter{%
       \csname abx@field@#1\endcsname}}}

\appto\blx@blxinit{%
  \let\docsvfield\blx@imc@docsvfield}

% {<list>|<listmacro>}

\protected\long\def\blx@listloop#1{%
  \expandafter\blx@listloop@i#1|&}
\long\def\blx@listloop@i#1|{%
  \ifblank{#1}
    {\blx@break}
    {\blx@do{#1}\blx@listloop@i}}

\long\def\blx@break#1&{%
  \blx@done
  \undef\blx@do
  \undef\blx@done}

% {<listmacro>}{<listcsname>} => matches in <listmacro>

\protected\def\blx@filter#1#2{%
  \def\do##1{%
    \ifinlistcs{##1}{#2}
      {\listadd#1{##1}}
      {}}%
  \blx@runfilter#1}

% {<listmacro>}{<listcsname>} => neg. matches in <listmacro>

\protected\def\blx@notfilter#1#2{%
  \def\do##1{%
    \ifinlistcs{##1}{#2}
      {}
      {\listadd#1{##1}}}%
  \blx@runfilter#1}

\def\blx@runfilter#1{%
  \begingroup\edef#1{\endgroup
    \unexpanded{\let#1\@empty\dolistloop}{#1}}%
  #1\let\do\noexpand}

% {<macro>}{<entrykey>,...} => <macro>{<entrykey>,...}

\protected\def\blx@sanitizekeys#1#2{%
  \begingroup
  \blx@safe@actives
  \let\protect\string
  \edef\blx@tempa{#2}%
  \edef\blx@tempa{%
    \endgroup\unexpanded{#1}{%
    \detokenize\expandafter{\blx@tempa}}}%
  \blx@tempa}

% {<file>}{<message>}{<preload>}{<postload>}{<success>}{<failure>}

\protected\long\def\blx@inputonce#1#2#3#4#5#6{%
  \ifcsundef{blx@file@#1}
    {\blx@info@noline{Trying to load #2..}%
     \IfFileExists{#1}
       {\blx@info@noline{... file '#1' found}%
        #3\@@input\@filef@und#4#5}
       {\blx@info@noline{... file '#1' not found}#6}%
     \global\csdef{blx@file@#1}{}%
     \@addtofilelist{#1}}
    {#5}}

% {<string>}

\protected\def\blx@auxwrite#1#2{%
  \if@filesw
    \begingroup
    \blx@safe@actives
    \let\protect\string
    \immediate\write#1{#2}%
    \endgroup
  \fi}

\def\blx@auxinit#1{%
  \blx@auxwrite\blx@theauxout{%
    \ifx\blx@theauxout\@mainaux
    \else
      \blx@msg@aux
    \fi
    \ifnum\blx@backend=\blx@backend@biber
      \expandafter\ifblank\expandafter{#1}
        {}
	{\string\bibdata{#1}}%
    \else
      \string\bibstyle{biblatex}\blx@nl
      \string\bibdata{%
        \blx@ctrlfile\blxauxsuffix
	\expandafter\ifblank\expandafter{#1}
          {}
	  {,#1}}\blx@nl
      \string\citation{biblatex-control}
    \fi}}

% {<file>}{<signature>}{<true>}{<false>}

\def\blx@ifsigned#1#2{%
  \begingroup
  \let\blx@tempa\@firstoftwo
  \edef\blx@tempb{\csuse{blx@sig@#2}}%
  \edef\blx@tempb{\detokenize\expandafter{\blx@tempb}}%
  \openin\blx@auxin #1.#2\relax
    \ifeof\blx@auxin
    \else
      \endlinechar\m@ne
      \readline\blx@auxin to \blx@tempc
      \ifeof\blx@auxin
      \else
        \ifx\blx@tempb\blx@tempc
          \readline\blx@auxin to \blx@tempc
          \edef\blx@tempb{\csuse{blx@ver@#2}}%
          \edef\blx@tempb{\detokenize\expandafter{\blx@tempb}}%
          \ifx\blx@tempb\blx@tempc
          \else
            \blx@warning@noline{%
              File '#1.#2' created\MessageBreak
              by wrong version of biblatex}%
          \fi
        \else
          \blx@error
            {File '#1.#2' not created by biblatex}
            {This file was apparently not created by biblatex.
             Rename it or\MessageBreak move it to a location were
             TeX will not find it. If this error\MessageBreak
             persists, consider redefining \string\blxauxsuffix.%
             See the biblatex\MessageBreak manual for details}%
          \let\blx@tempa\@secondoftwo
        \fi
      \fi
    \fi
  \closein\blx@auxin
  \expandafter\endgroup\blx@tempa}

\def\blx@sig@bib{@Comment{$ biblatex control file $}}
\edef\blx@ver@bib{@Comment{$ biblatex version \blx@version\space $}}
\edef\blx@sig@aux{\@percentchar\space $ biblatex auxiliary file $}
\edef\blx@ver@aux{\@percentchar\space$ biblatex version \blx@version\space $}
\let\blx@sig@bbl\blx@sig@aux
\let\blx@ver@bbl\blx@ver@aux
\def\blx@sig@bcf{<!-- biblatex control file -->}
\edef\blx@ver@bcf{<!-- biblatex version \blx@version\space -->}

\edef\blx@msg@aux{%
  \blx@sig@aux\blx@nl
  \blx@ver@aux\blx@nl
  \@percentchar\space Do not modify the above lines!\blx@nl
  \@percentchar\blx@nl
  \@percentchar\space This is an auxiliary file
  used by the 'biblatex' package.\blx@nl
  \@percentchar\space This file may safely be deleted.
  It will be recreated as\blx@nl
  \@percentchar\space required.\blx@nl
  \@percentchar\blx@nl\string\relax\blx@nl}
\edef\blx@msg@bib{%
  \blx@sig@bib\blx@nl
  \blx@ver@bib\blx@nl
  Do not modify the above lines!\blx@nl\blx@nl
  This is an auxiliary file used
  by the 'biblatex' package.\blx@nl
  This file may safely be deleted.
  It will be recreated as\blx@nl
  required.\blx@nl\blx@nl}

%% User feedback

\protected\def\blx@error#1#2{%
  \begingroup
  \blx@safe@actives
  \PackageError{biblatex}{#1}{#2.}%
  \endgroup}

\protected\def\blx@warning#1{%
  \begingroup
  \blx@safe@actives
  \PackageWarning{biblatex}{#1\blx@noline}%
  \endgroup}
\protected\def\blx@warning@noline#1{%
  \begingroup
  \blx@safe@actives
  \PackageWarning{biblatex}{#1\@gobble}%
  \endgroup}
\protected\def\blx@warning@entry#1{%
  \ifundef\abx@field@entrykey
    {\blx@warning{#1}}
    {\blx@warning{#1\MessageBreak at entry '\abx@field@entrykey'}}}

\protected\def\blx@info#1{%
  \begingroup
  \blx@safe@actives
  \PackageInfo{biblatex}{#1\blx@noline}%
  \endgroup}
\def\blx@info@noline#1{%
  \begingroup
  \blx@safe@actives
  \PackageInfo{biblatex}{#1\@gobble}%
  \endgroup}

\let\blx@noline\@gobble
\AtEndOfPackage{\let\blx@noline\@empty}
\def\blx@imc@BibliographyWarning{\blx@warning@entry}

\appto\blx@blxinit{%
  \let\BibliographyWarning\blx@imc@BibliographyWarning}

\def\blx@missing#1{%
  \mbox{\reset@font\bfseries#1}}

\def\blx@err@patch#1{%
  \blx@error
    {Patching #1 failed}
    {This is an internal issue typically caused by a
     conflict\MessageBreak between biblatex and some
     other package. Modifying\MessageBreak the package
     loading order may fix the problem}}

\def\blx@err@nolang#1{%
  \blx@error
    {Language '#1' not found}
    {The localization module for '#1' could not be found}}

\def\blx@err@invarg#1{%
  \blx@error
    {Argument '#1' invalid}
    {The argument you have supplied is invalid.\MessageBreak
     See the biblatex manual for details}}

\def\blx@err@invopt#1{%
  \blx@error
    {Option '#1' invalid}
    {The option you have supplied is invalid. See the biblatex
     manual\MessageBreak for valid option keys and their
     possible values}}

\def\blx@err@confopt#1{%
  \blx@error
    {Conflicting options}
    {#1}}

\def\blx@err@nodocdiv#1{%
  \blx@error
    {Failed to hook into \@backslashchar#1}
    {There are two possible reasons for this error.
     Either\MessageBreak the document class does not
     support chapters or the\MessageBreak implementation
     is not compatible with biblatex}}

\protected\def\blx@err@nestcite{%
  \blx@error
    {Nested citation command}
    {Citation commands may not be nested}}

\def\blx@err@nestenv#1{%
  \blx@error
    {Nested '#1' environment}
    {This environment may not be nested}}

\protected\def\blx@err@citecmd#1{%
  \begingroup
  \escapechar\m@ne
  \blx@error
    {Command '\@backslashchar\string#1' undefined}
    {The citation command '\@backslashchar\string#1'
     has not been defined\MessageBreak by the
     selected citation style}%
  \endgroup}

\def\blx@warn@nohyph#1{%
  \blx@warning{No hyphenation patterns for '#1'}}

\protected\def\blx@warn@citecmd#1#2{%
  \blx@warning{%
    '\string#1' not defined by citation style.\MessageBreak
    Falling back to '\string#2'}%
  #2}

\protected\def\blx@warn@nostring#1{%
  \blx@warning@entry{Bibliography string '#1' undefined}%
  \blx@missing{#1}}

\def\blx@warn@conflopt#1{%
  \blx@warning{Conflicting options.\MessageBreak#1}}

\def\blx@warn@bibempty{%
  \@latex@warning{Empty bibliography}}

\def\blx@warn@losempty{%
  \@latex@warning{Empty list of shorthands}}

\def\blx@inf@refsec{%
  \blx@info{Reference section=\the\c@refsection}}%

\def\blx@inf@refseg{%
  \ifnum\c@refsection=\z@
    \blx@info{Reference segment=\the\c@refsegment}%
  \else
    \blx@info{%
      Reference section/segment=%
      \the\c@refsection/\the\c@refsegment}%
  \fi}

\def\blx@inf@creset{%
  \blx@info{Resetting trackers}}%

\def\blx@msg@cundef#1{%
  Citation '#1' undefined}
\def\blx@msg@cundefon#1{%
  Citation '#1' on page \thepage\space undefined}

\let\blx@auxlist\@empty
\def\blx@logreq#1{%
  \xifinlist{\blx@auxfile.aux}{\blx@auxlist}
    {}
    {\listxadd\blx@auxlist{\blx@auxfile.aux}%
     \blx@logreq@bibtex{\blx@auxfile}}%
  \ifblank{#1}
    {}
    {\@latex@warning{#1}}%
  \blx@reruntrue}

\def\blx@logreq@latex{\typeout{REQ:1:latex:REQ}}
\def\blx@logreq@bibtex#1{%
  \begingroup
  \edef\blx@tempa{\endgroup
    \noexpand\typeout{REQ:2:bibtex:\blx@nl
      \ifcase\blx@backend
        binary=bibtex\blx@nl
      \or
        binary=bibtex8\blx@nl
	option=--mwizfuns 10000\blx@nl
      \or
        binary=biber\blx@nl
      \fi
      \ifundef\blx@mincrossrefs
        {}
        {\ifcase\blx@backend
	   option=-min-crossrefs=\blx@mincrossrefs\blx@nl
	 \or
	   option=--min\string_crossrefs \blx@mincrossrefs\blx@nl
	 \fi}%
      \ifdef\blx@bibencoding
        {\ifnum\blx@backend=\csuse{blx@backend@bibtex8}%
	   option=--csfile \blx@bibencoding.csf\blx@nl
	 \fi}
        {}%
      infile=#1\blx@nl:REQ}}%
  \blx@tempa}

\def\blx@warn@rerun{%
  \blx@warning@noline{Please rerun LaTeX}}

\def\blx@warn@auxlist{%
  \begingroup
  \edef\blx@tempa{%
    Please (re)run
    \ifnum\blx@backend=\blx@backend@biber
      Biber
    \else
      BibTeX
    \fi
    on the file(s):}%
  \def\do##1{\appto\blx@tempa{\MessageBreak##1}}%
  \dolistloop\blx@auxlist
  \blx@warning@noline{%
    \blx@tempa\MessageBreak
    and rerun LaTeX afterwards}%
  \endgroup}

\def\blx@reruntrue{%
  \G@refundefinedtrue
  \blx@logreq@latex
  \global\let\blx@reruntrue\relax}

\protected\def\blx@checksum{%
  \@tempcnta\z@
  \ifx\blx@checksum@old\blx@checksum@new
  \else
    \advance\@tempcnta\@ne
    \blx@reruntrue
  \fi
  \ifx\blx@auxlist\@empty
  \else
    \advance\@tempcnta\tw@
    \blx@reruntrue
  \fi
  \csuse{blx@rerun}%
  \ifcase\@tempcnta
  \or
    \blx@warn@rerun
  \else
    \blx@warn@auxlist
  \fi}

\let\blx@checksum@old\@empty
\let\blx@checksum@new\@empty
\let\abx@aux@checksum\relax

\def\blx@addchecksum#1{%
  \xdef\blx@checksum@old{\blx@checksum@old#1}}

\AtEndDocument{%
  \def\blx@addchecksum#1{%
    \xdef\blx@checksum@new{\blx@checksum@new#1}}}

\AfterEndDocument{\blx@checksum}

%% Punctuation and capitalization

% 1001       apostrophe (\printnames only)
% 1002       abbreviation dot
% 1003/1250  comma
% 1004/1500  semicolon
% 1005/2000  colon
% 1006/3000  period
% 1007/3001  exclamation mark
% 1008/3002  question mark
% 1009       suppress punctuation
% 1010       new paragaph

\mathchardef\blx@sf@apo=1001
\mathchardef\blx@sf@dot=1002
\mathchardef\blx@sf@comma=1003
\mathchardef\blx@sf@semicolon=1004
\mathchardef\blx@sf@colon=1005
\mathchardef\blx@sf@period=1006
\mathchardef\blx@sf@exclam=1007
\mathchardef\blx@sf@question=1008
\mathchardef\blx@sf@nopunct=1009
\mathchardef\blx@sf@par=1010
\mathchardef\blx@sf@threshold@low=1002
\mathchardef\blx@sf@threshold@high=1009

\csedef{blx@sf@1250}{\the\blx@sf@comma}
\csedef{blx@sf@1500}{\the\blx@sf@semicolon}
\csedef{blx@sf@2000}{\the\blx@sf@colon}
\csedef{blx@sf@3000}{\the\blx@sf@period}
\csedef{blx@sf@3001}{\the\blx@sf@exclam}
\csedef{blx@sf@3002}{\the\blx@sf@question}

\csdef{blx@pm@,}{comma}
\csdef{blx@pm@;}{semicolon}
\csdef{blx@pm@:}{colon}
\csdef{blx@pm@.}{period}
\csdef{blx@pm@!}{exclam}
\csdef{blx@pm@?}{question}

\def\blx@setsfcodes{%
  \let\blx@setsfcodes\relax
  \let\frenchspacing\blx@setfrcodes
  \let\nonfrenchspacing\blx@setencodes
  \ifnum\sfcode`\.>2000
    \blx@setencodes
  \else
    \blx@setfrcodes
  \fi
  \@setquotesfcodes
  \sfcode`\(=\z@
  \sfcode`\)=\z@
  \sfcode`\[=\z@
  \sfcode`\]=\z@
  \sfcode`\<=\z@
  \sfcode`\>=\z@}

\def\blx@setfrcodes{%
  \ifnum\sfcode`\A=\@m
  \else
    \blx@setazcodes
  \fi
  \sfcode`\,=\blx@sf@comma
  \sfcode`\;=\blx@sf@semicolon
  \sfcode`\:=\blx@sf@colon
  \sfcode`\.=\blx@sf@period
  \sfcode`\!=\blx@sf@exclam
  \sfcode`\?=\blx@sf@question
}

\def\blx@setencodes{%
  \sfcode`\,=1250
  \sfcode`\;=1500
  \sfcode`\:=2000
  \sfcode`\.=3000
  \sfcode`\!=3001
  \sfcode`\?=3002
}

\def\blx@namecodes{%
  \ifnum\sfcode`\A=\@m
  \else
    \blx@setazcodes
  \fi
  \sfcode`\'=\blx@sf@apo
}

\begingroup
\let\blx@setazcodes\@empty
\def\blx@tempa{%
  \xdef\blx@setazcodes{%
    \blx@setazcodes
    \sfcode\the\@tempcnta=\@m}
  \ifnum\@tempcnta<\@tempcntb
    \advance\@tempcnta\@ne
    \expandafter\blx@tempa
  \fi}
\@tempcnta`\A
\@tempcntb`\Z
\blx@tempa
\ifnum\inputlineno=\m@ne\else
  \@tempcnta"80
  \@tempcntb"9C
  \blx@tempa
  \@tempcnta"C0
  \@tempcntb"DF
  \blx@tempa
\fi
\endgroup

\def\blx@spacefactor{%
  \ifhmode
    \ifcsundef{blx@sf@\the\spacefactor}
      {\the\spacefactor}
      {\csname blx@sf@\the\spacefactor\endcsname}%
  \else
    \the\blx@sf@par
  \fi}

\protected\def\blx@leavevmode{%
  \ifhmode
  \else
    \leavevmode\spacefactor\blx@sf@par
  \fi}

\protected\def\blx@leavevmode@cite{%
  \ifhmode
    \ifnum\spacefactor=\blx@sf@par
    \else
      \spacefactor\@m
    \fi
  \else
    \leavevmode
  \fi}

\protected\def\blx@imc@setpunctfont#1{%
  \blx@ifpuncthook
    {\gdef\abx@puncthook{%
       \ifdim\lastkern>\z@\unkern\fi
       \blx@imc@resetpunctfont#1}}
    {}}
\protected\def\blx@imc@resetpunctfont{%
  \blx@ifpuncthook
    {\global\let\abx@puncthook\@firstofone}
    {}}

\protected\def\blx@setpostpunct#1{%
  \blx@ifuspunct
    {\global\let\blx@postpunct\blx@dopostpunct
     \ifdef\blx@thepostpunct
       {\gappto\blx@thepostpunct{#1}}
       {\gdef\blx@thepostpunct{#1}}}
    {}}

\def\blx@dopostpunct{%
  \blx@thepostpunct
  \global\let\blx@postpunct\@empty
  \global\undef\blx@thepostpunct}

% {<characters>}

\newrobustcmd*{\DeclareCapitalPunctuation}[1]{%
  \cslet{blx@cap@\the\blx@sf@par}\@empty
  \csundef{blx@cap@\the\blx@sf@comma}%
  \csundef{blx@cap@\the\blx@sf@semicolon}%
  \csundef{blx@cap@\the\blx@sf@colon}%
  \csundef{blx@cap@\the\blx@sf@period}%
  \csundef{blx@cap@\the\blx@sf@exclam}%
  \csundef{blx@cap@\the\blx@sf@question}%
  \ifblank{#1}
    {}
    {\expandafter\blx@defcapstring\detokenize{#1}\relax}}

\def\blx@defcapstring#1{%
  \ifx#1\relax
  \else
    \begingroup
    \blx@setfrcodes
    \ifcsdef{blx@pm@#1}
      {\expandafter\endgroup
       \expandafter\let
         \csname blx@cap@\the\sfcode`#1\endcsname\@empty}
      {\blx@warning{Ignoring invalid punctuation mark '#1'}%
       \endgroup}%
    \expandafter\blx@defcapstring
  \fi}

% {<characters>}

\newrobustcmd*{\DeclareQuotePunctuation}[1]{%
  \csdef{blx@qp@comma}{\blx@postpunct}%
  \csdef{blx@qp@semicolon}{\blx@postpunct}%
  \csdef{blx@qp@colon}{\blx@postpunct}%
  \csdef{blx@qp@period}{\blx@postpunct}%
  \csdef{blx@qp@exclam}{\blx@postpunct}%
  \csdef{blx@qp@question}{\blx@postpunct}%
  \cslet{blx@pq@comma}\@empty
  \cslet{blx@pq@semicolon}\@empty
  \cslet{blx@pq@colon}\@empty
  \cslet{blx@pq@period}\@empty
  \cslet{blx@pq@exclam}\@empty
  \cslet{blx@pq@question}\@empty
  \let\blx@quotepunct\@empty
  \ifblank{#1}
    {\let\blx@ifuspunct\@secondoftwo}
    {\let\blx@ifuspunct\@firstoftwo
     \expandafter\blx@defquotepunct\detokenize{#1}&}}

\def\blx@defquotepunct#1{%
  \ifx&#1\relax
  \else
    \ifcsdef{blx@pm@#1}
      {\appto\blx@quotepunct{#1}%
       \cslet{blx@qp@\csuse{blx@pm@#1}}\@empty
       \csdef{blx@pq@\csuse{blx@pm@#1}}{\blx@postpunct}}
      {\blx@warning{Ignoring invalid punctuation mark '#1'}}%
    \expandafter\blx@defquotepunct
  \fi}

% {<mark>}{<characters>}

\newrobustcmd*{\DeclarePunctuationPairs}[2]{%
  \ifcsdef{blx@sf@\detokenize{#1}}
    {\ifnum\csname blx@sf@\detokenize{#1}\endcsname>\blx@sf@apo
       \ifnum\csname blx@sf@\detokenize{#1}\endcsname<\blx@sf@nopunct
	 \expandafter\blx@defpunctpairs
	 \expandafter{\the\csname blx@sf@\detokenize{#1}\endcsname}{#2}%
       \else
         \blx@err@invarg{\detokenize{#1}}%
       \fi
     \else
       \blx@err@invarg{\detokenize{#1}}%
     \fi}
    {\blx@err@invarg{\detokenize{#1}}}}

\def\blx@defpunctpairs#1#2{%
  \blx@undefpair{#1}{\the\blx@sf@dot}%
  \blx@undefpair{#1}{\the\blx@sf@comma}%
  \blx@undefpair{#1}{\the\blx@sf@semicolon}%
  \blx@undefpair{#1}{\the\blx@sf@colon}%
  \blx@undefpair{#1}{\the\blx@sf@period}%
  \blx@undefpair{#1}{\the\blx@sf@exclam}%
  \blx@undefpair{#1}{\the\blx@sf@question}%
  \ifblank{#2}
    {}
    {\begingroup
     \def\blx@tempa{#1}%
     \let\blx@tempb\@empty
     \blx@setfrcodes
     \sfcode`\*=\blx@sf@dot
     \expandafter\blx@defpair\detokenize{#2}&%
     \expandafter\endgroup\blx@tempb}}

\def\blx@defpair#1{%
  \ifx&#1%
  \else
    \ifnum\the\sfcode`#1>\blx@sf@apo
      \ifnum\the\sfcode`#1<\blx@sf@nopunct
        \eappto\blx@tempb{%
	  \cslet{blx@pp@\blx@tempa @\the\sfcode`#1}\noexpand\@empty}%
      \else
        \blx@err@invarg{#1}%
      \fi
    \else
      \blx@err@invarg{#1}%
    \fi
    \expandafter\blx@defpair
  \fi}

\def\blx@undefpair#1#2{%
  \ifcsdef{blx@pp@#1@#2}
    {\csundef{blx@pp@#1@#2}}
    {}}

\protected\def\blx@resetpunct{%
  \DeclareCapitalPunctuation{.!?}%
  \DeclarePunctuationPairs{dot}{}%
  \DeclarePunctuationPairs{comma}{*!?}%
  \DeclarePunctuationPairs{semicolon}{*!?}%
  \DeclarePunctuationPairs{colon}{*!?}%
  \DeclarePunctuationPairs{period}{}%
  \DeclarePunctuationPairs{exclam}{*}%
  \DeclarePunctuationPairs{question}{*}%
  \DeclareQuotePunctuation{}%
  \def\abx@dot{\ifdim\lastkern>\z@\unkern\fi.\spacefactor\blx@sf@dot}%
  \def\abx@comma{\ifdim\lastkern>\z@\unkern\fi\abx@puncthook{,}}%
  \def\abx@semicolon{\abx@puncthook{;}}%
  \def\abx@colon{\abx@puncthook{:}}%
  \def\abx@period{\ifdim\lastkern>\z@\unkern\fi\abx@puncthook{.}}%
  \def\abx@exclam{\abx@puncthook{!}}%
  \def\abx@question{\abx@puncthook{?}}%
  \global\let\abx@puncthook\@firstofone
  \global\let\blx@postpunct\@empty}

\blx@resetpunct

% {<character>}{<true>}{<false>}

\protected\def\blx@imc@ifpunctmark#1{%
  \ifhmode
    \begingroup
    \sfcode`\*=\blx@sf@dot
    \ifnum\sfcode`#1=\spacefactor
      \endgroup
      \expandafter\expandafter
      \expandafter\@firstoftwo
    \else
      \endgroup
      \expandafter\expandafter
      \expandafter\@secondoftwo
    \fi
  \else
    \expandafter\@secondoftwo
  \fi}

% {<true>}{<false>}

\protected\def\blx@imc@ifterm{%
  \ifhmode
    \expandafter\blx@imc@ifcapital
  \else
    \expandafter\@secondoftwo
  \fi}

% {<true>}{<false>}

\protected\def\blx@imc@ifcapital{%
  \ifcsdef{blx@cap@\blx@spacefactor}}

% {<true>}{<false>}

\protected\def\blx@imc@ifpunct{%
  \ifnum\blx@spacefactor>\blx@sf@threshold@low
    \ifnum\blx@spacefactor<\blx@sf@threshold@high
      \expandafter\expandafter
      \expandafter\@firstoftwo
    \else
      \expandafter\expandafter
      \expandafter\@secondoftwo
    \fi
  \else
    \expandafter\@secondoftwo
  \fi}

% {<character>}

\protected\def\blx@imc@autocap{%
  \blx@imc@ifcapital\MakeUppercase\@firstofone}

\protected\def\blx@imc@nopunct{%
  \leavevmode\spacefactor\blx@sf@nopunct}

\protected\def\blx@imc@isdot{%
  \ifnum\blx@spacefactor=\blx@sf@period
    \spacefactor\blx@sf@dot
  \fi}

\protected\def\blx@imc@adddot{%
  \blx@addpunct{dot}%
  \ifnum\blx@spacefactor=\blx@sf@period
    \spacefactor\blx@sf@dot
  \fi}

\protected\def\blx@imc@addperiod{%
  \blx@addpunct{period}%
  \ifnum\blx@spacefactor=\blx@sf@dot
    \spacefactor\blx@sf@period
  \fi}

\protected\def\blx@imc@addcomma{\blx@addpunct{comma}}
\protected\def\blx@imc@addsemicolon{\blx@addpunct{semicolon}}
\protected\def\blx@imc@addcolon{\blx@addpunct{colon}}
\protected\def\blx@imc@addexclam{\blx@addpunct{exclam}}
\protected\def\blx@imc@addquestion{\blx@addpunct{question}}

\def\blx@addpunct#1{%
  \unspace
  \ifnum\blx@spacefactor<\blx@sf@threshold@low
    \csuse{blx@qp@#1}\csuse{abx@#1}%
  \else
    \ifnum\blx@spacefactor>\blx@sf@threshold@high
      \csuse{blx@qp@#1}\csuse{abx@#1}%
    \else
      \ifcsdef{blx@pp@\the\csname blx@sf@#1\endcsname @\blx@spacefactor}
	{\csuse{blx@qp@#1}\csuse{abx@#1}}
	{\csuse{blx@qp@#1}}%
    \fi
  \fi
  \csuse{blx@pq@#1}}

\newrobustcmd*{\unspace}{%
  \ifhmode
    \expandafter\blx@unspace
  \fi}

\def\blx@unspace{%
  \ifdim\lastskip>\z@
    \unskip
    \expandafter\blx@unspace
  \else
    \ifnum\lastpenalty>\z@
      \unpenalty
      \expandafter\expandafter
      \expandafter\blx@unspace
    \fi
  \fi}

\newrobustcmd*{\bibsentence}{%
  \leavevmode\spacefactor\blx@sf@par
  \ignorespaces}

\newrobustcmd*{\midsentence}{%
  \leavevmode
  \@ifstar
    {\ifnum\spacefactor=\blx@sf@dot
     \else
       \spacefactor\@m
     \fi}
    {\spacefactor\@m}}

\newrobustcmd*{\addslash}{%
  \unspace/\hskip\z@skip}

\newrobustcmd*{\addspace}{%
  \unspace\blx@postpunct
  \space\blx@imc@resetpunctfont}

\newrobustcmd*{\addnbspace}{%
  \unspace\blx@postpunct
  \nobreak\space\blx@imc@resetpunctfont}

\newrobustcmd*{\addthinspace}{%
  \unspace\blx@postpunct
  \hskip0.16667em\relax
  \blx@imc@resetpunctfont}

\newrobustcmd*{\addnbthinspace}{%
  \unspace\blx@postpunct
  \nobreak\hskip0.16667em\relax
  \blx@imc@resetpunctfont}

\newrobustcmd*{\addlowpenspace}{%
  \unspace\blx@postpunct
  \penalty\value{lownamepenalty}\space
  \blx@imc@resetpunctfont}

\newrobustcmd*{\addhighpenspace}{%
  \unspace\blx@postpunct
  \penalty\value{highnamepenalty}\space
  \blx@imc@resetpunctfont}

\newrobustcmd*{\addlpthinspace}{%
  \unspace\blx@postpunct
  \penalty\value{lownamepenalty}%
  \hskip0.16667em\relax\blx@imc@resetpunctfont}

\newrobustcmd*{\addhpthinspace}{%
  \unspace\blx@postpunct
  \penalty\value{highnamepenalty}%
  \hskip0.16667em\relax\blx@imc@resetpunctfont}

\newrobustcmd*{\addabbrvspace}{%
  \unspace\blx@postpunct
  \penalty\value{abbrvpenalty}%
  \space\blx@imc@resetpunctfont}

\newrobustcmd*{\addabthinspace}{%
  \unspace\blx@postpunct
  \penalty\value{abbrvpenalty}%
  \hskip0.16667em\relax
  \blx@imc@resetpunctfont}

\newrobustcmd*{\adddotspace}{%
  \unspace\adddot\blx@postpunct
  \penalty\value{abbrvpenalty}%
  \space\blx@imc@resetpunctfont}

\providerobustcmd*{\noligature}{%
  \penalty\@M\discretionary{-}{}{\kern0.03em}%
  \nobreak\hskip\z@skip}

\providerobustcmd*{\hyphen}{%
  \nobreak-\nobreak\hskip\z@skip}

\providerobustcmd*{\nbhyphen}{%
  \nobreak\mbox{-}\nobreak\hskip\z@skip}

\providerobustcmd*{\hyphenate}{%
  \nobreak\-\nobreak\hskip\z@skip}

\providerobustcmd*{\allowhyphens}{%
  \nobreak\hskip\z@skip}

\appto\blx@blxinit{%
  \let\setpunctfont\blx@imc@setpunctfont
  \let\resetpunctfont\blx@imc@resetpunctfont
  \let\ifcapital\blx@imc@ifcapital
  \let\autocap\blx@imc@autocap
  \let\ifpunctmark\blx@imc@ifpunctmark
  \let\ifpunct\blx@imc@ifpunct
  \let\ifterm\blx@imc@ifterm
  \let\nopunct\blx@imc@nopunct
  \let\isdot\blx@imc@isdot
  \let\adddot\blx@imc@adddot
  \let\addperiod\blx@imc@addperiod
  \let\addcomma\blx@imc@addcomma
  \let\addsemicolon\blx@imc@addsemicolon
  \let\addcolon\blx@imc@addcolon
  \let\addexclam\blx@imc@addexclam
  \let\addquestion\blx@imc@addquestion}

\appto\blx@blxinit{%
  \appto\nocorrlist{%
    \isdot
    \adddot
    \addperiod
    \addcomma}}

%% Style definition

% {<bibstyle>}

\newrobustcmd*{\RequireBibliographyStyle}[1]{%
  \blx@inputonce{#1.bbx}{bibliography style '#1'}{}{}{}
    {\blx@error
       {Style '#1' not found}
       {The bibliography style '#1' could not be found}}}
\@onlypreamble\RequireBibliographyStyle

% {<code>}

\newrobustcmd*{\InitializeBibliographyStyle}{\appto\blx@hook@bbxinit}
\@onlypreamble\InitializeBibliographyStyle

% {<type>}{<driverdef>}

\newrobustcmd*{\DeclareBibliographyDriver}[1]{%
  \long\csdef{blx@bbx@#1}}
\@onlypreamble\DeclareBibliographyDriver

\def\blx@driver#1{\csuse{blx@bbx@#1}}

% {<alias>}{<type>}

\newrobustcmd*{\DeclareBibliographyAlias}[2]{%
  \csedef{blx@bbx@#1}{%
    \expandafter\noexpand\csname blx@bbx@#2\endcsname}}
\@onlypreamble\DeclareBibliographyAlias

% {<key>}[<value>]{<code>}

\newrobustcmd*{\DeclareBibliographyOption}[1]{%
  \@ifnextchar[%]
    {\blx@defbibopt{#1}}
    {\blx@defbibopt{#1}[]}}

\long\def\blx@defbibopt#1[#2]#3{%
  \ifcsundef{KV@blx@opt@ldt@#1}
    {\ifcsundef{KV@blx@opt@pre@#1}
       {\ifblank{#2}
          {\define@key{blx@opt@pre}{#1}{#3}}
          {\define@key{blx@opt@pre}{#1}[#2]{#3}}}
       {\blx@err@confopt{The package option '#1' already exists}}}
    {\blx@err@confopt{The package option '#1' already exists}}}

% {<key>}[<value>]{<code>}

\newrobustcmd*{\DeclareEntryOption}[1]{%
  \@ifnextchar[%]
    {\blx@defentryopt{#1}}
    {\blx@defentryopt{#1}[]}}

\long\def\blx@defentryopt#1[#2]#3{%
  \ifcsundef{KV@blx@opt@bib@#1}
    {\ifblank{#2}
       {\define@key{blx@opt@bib}{#1}{#3}}
       {\define@key{blx@opt@bib}{#1}[#2]{#3}}}
    {\blx@err@confopt{The entry option '#1' already exists}}}

%% Auxiliary commands

\newrobustcmd*{\citereset}{%
  \csuse{blx@hook@cbxinit}%
  \@ifstar
    {}
    {\global\cslet{blx@bsee@\the\c@refsection}\@empty
     \global\cslet{blx@fsee@\the\c@refsection}\@empty
     \blx@ibidreset@force
     \blx@idemreset@force
     \blx@opcitreset@force
     \blx@loccitreset@force}}

\def\blx@save#1{%
  \ifcsdef{blx@saved@#1}
    {}
    {\blx@safe@actives
     \csletcs{blx@saved@#1}{#1}%
     \blx@rest@actives}}

\def\blx@restore#1{%
  \ifcsdef{blx@saved@#1}
    {\blx@safe@actives
     \csletcs{#1}{blx@saved@#1}%
     \csundef{blx@saved@#1}%
     \blx@rest@actives}
    {}}

\newrobustcmd*{\savecommand}[1]{%
  \ifcsdef{blx@saved@\detokenize{#1}}
    {}
    {\cslet{blx@saved@\detokenize{#1}}{#1}}}

\newrobustcmd*{\restorecommand}[1]{%
  \ifcsdef{blx@saved@\detokenize{#1}}
    {\letcs{#1}{blx@saved@\detokenize{#1}}%
     \csundef{blx@saved@\detokenize{#1}}}
    {}}

% {<name>}

\newrobustcmd*{\savebibmacro}[1]{%
  \blx@save{abx@macro@\detokenize{#1}}}

\newrobustcmd*{\restorebibmacro}[1]{%
  \blx@restore{abx@macro@\detokenize{#1}}}

% {<name>}{<definition>}

\newrobustcmd*{\newbibmacro}{%
  \@star@or@long{\blx@defbibmacro\new@command}}

\newrobustcmd*{\renewbibmacro}{%
  \@star@or@long{\blx@defbibmacro\renew@command}}

\def\blx@defbibmacro#1#2{%
  \expandafter#1\csname abx@macro@\detokenize{#2}\endcsname}

% {<name>}

\newrobustcmd*{\usebibmacro}[1]{%
  \ifcsundef{abx@macro@\detokenize{#1}}
    {\blx@error
       {Bibliography macro '\detokenize{#1}' undefined}
       {Use '\string\newbibmacro' to define this macro}}
    {\csuse{abx@macro@\detokenize{#1}}}}

% {<field>}

\def\blx@imc@thefield#1{\csuse{abx@field@#1}}

\def\blx@imc@strfield#1{%
  \ifcsdef{abx@field@#1}
    {\detokenize\expandafter\expandafter\expandafter
       {\csname abx@field@#1\endcsname}}
    {}}

% {<plainlist>}

\def\blx@imc@thelist#1{\csuse{abx@list@#1}}

% {<namelist>}

\def\blx@imc@thename#1{\csuse{abx@name@#1}}

% {<field>}

\protected\def\blx@imc@clearfield#1{%
  \csundef{abx@field@#1}}

% {<plainlist>}

\protected\def\blx@imc@clearlist#1{%
  \ifcsundef{abx@list@#1}
    {}
    {\togglefalse{abx@bool@more#1}%
     \csundef{abx@list@#1}%
     \csname c@#1\endcsname\z@}}

% {<namelist>}

\protected\def\blx@imc@clearname#1{%
  \ifcsundef{abx@name@#1}
    {}
    {\togglefalse{abx@bool@more#1}%
     \csundef{abx@name@#1}%
     \csname c@#1\endcsname\z@}}

% {<field>}{<macro>}

\protected\def\blx@imc@restorefield#1{\cslet{abx@field@#1}}

% {<plainlist>}{<macro>}

\protected\def\blx@imc@restorelist#1{\cslet{abx@list@#1}}

% {<namelist>}{<macro>}

\protected\def\blx@imc@restorename#1{\cslet{abx@name@#1}}

% {<field>}{<macro>}

\protected\def\blx@imc@savefield{%
  \@ifstar{\blx@savefield}{\global\blx@savefield}}
\def\blx@savefield#1#2{\letcs#2{abx@field@#1}}

% {<plainlist>}{<macro>}

\protected\def\blx@imc@savelist{%
  \@ifstar{\blx@savelist{list}}{\global\blx@savelist{list}}}
\def\blx@savelist#1#2#3{\letcs#3{abx@#1@#2}}

% {<namelist>}{<macro>}

\protected\def\blx@imc@savename{%
  \@ifstar{\blx@savelist{name}}{\global\blx@savelist{name}}}

% {<field>}{<csname>}

\protected\def\blx@imc@savefieldcs{%
  \@ifstar{\blx@savefieldcs}{\global\blx@savefieldcs}}
\def\blx@savefieldcs#1#2{\csletcs{#2}{abx@field@#1}}

% {<plainlist>}{<csname>}

\protected\def\blx@imc@savelistcs{%
  \@ifstar{\blx@savelistcs{list}}{\global\blx@savelistcs{list}}}
\def\blx@savelistcs#1#2#3{\csletcs{#3}{abx@#1@#2}}

% {<namelist>}{<csname>}

\protected\def\blx@imc@savenamecs{%
  \@ifstar{\blx@savelistcs{name}}{\global\blx@savelistcs{name}}}

% {<field>}{<true>}{<false>}

\def\blx@imc@iffieldundef#1{%
  \ifcsundef{abx@field@#1}}

% {<plainlist>}{<true>}{<false>}

\def\blx@imc@iflistundef#1{%
  \ifcsundef{abx@list@#1}}

% {<namelist>}{<true>}{<false>}

\def\blx@imc@ifnameundef#1{%
  \ifcsundef{abx@name@#1}}

% {<field1>}{<field2>}{<true>}{<false>}

\def\blx@imc@iffieldsequal#1#2{%
  \ifcsequal{abx@field@#1}{abx@field@#2}}

% {<plainlist1>}{<plainlist2>}{<true>}{<false>}

\def\blx@imc@iflistsequal#1#2{%
  \ifcsequal{abx@list@#1}{abx@list@#2}}

% {<namelist1>}{<namelist2>}{<true>}{<false>}

\def\blx@imc@ifnamesequal#1#2{%
  \ifcsequal{abx@name@#1}{abx@name@#2}}

% {<field>}{<macro>}{<true>}{<false>}

\def\blx@imc@iffieldequals#1#2{%
  \blx@imc@iffieldundef{#1}
    {\@secondoftwo}
    {\ifundef#2%
       {\@secondoftwo}
       {\expandafter\ifx\csname abx@field@#1\endcsname#2%
          \expandafter\@firstoftwo
        \else
          \expandafter\@secondoftwo
        \fi}}}

% {<plainlist>}{<macro>}{<true>}{<false>}

\def\blx@imc@iflistequals#1#2{%
  \blx@imc@iflistundef{#1}
    {\@secondoftwo}
    {\ifundef#2%
       {\@secondoftwo}
       {\expandafter\ifx\csname abx@list@#1\endcsname#2%
          \expandafter\@firstoftwo
        \else
          \expandafter\@secondoftwo
        \fi}}}

% {<namelist>}{<macro>}{<true>}{<false>}

\def\blx@imc@ifnameequals#1#2{%
  \blx@imc@ifnameundef{#1}
    {\@secondoftwo}
    {\ifundef#2%
       {\@secondoftwo}
       {\expandafter\ifx\csname abx@name@#1\endcsname#2%
          \expandafter\@firstoftwo
        \else
          \expandafter\@secondoftwo
        \fi}}}

% {<field>}{<csname>}{<true>}{<false>}

\def\blx@imc@iffieldequalcs#1{%
  \ifcsequal{abx@field@#1}}

% {<plainlist>}{<csname>}{<true>}{<false>}

\def\blx@imc@iflistequalcs#1{%
  \ifcsequal{abx@list@#1}}

% {<namelist>}{<csname>}{<true>}{<false>}

\def\blx@imc@ifnameequalcs#1{%
  \ifcsequal{abx@name@#1}}

% {<field>}{<string>}{<true>}{<false>}

\protected\long\def\blx@imc@iffieldequalstr#1#2{%
  \blx@imc@iffieldundef{#1}
    {\@secondoftwo}
    {\expandafter\expandafter\expandafter\ifstrequal
     \expandafter\expandafter\expandafter{%
       \csname abx@field@#1\endcsname}{#2}}}

% {<field>}{<true>}{<false>}

\protected\def\blx@imc@iffieldxref#1{%
  \blx@imc@iffieldundef{#1}
    {\@secondoftwo}
    {\blx@whichxref
       {\blx@iffieldxref{#1}}
       {\@secondoftwo}}}

\def\blx@iffieldxref#1#2{%
  \begingroup
  \letcs\blx@tempa{abx@field@#2}%
  \letcs\blx@tempb{abx@field@#1}%
  \csundef{abx@field@#1}%
  \blx@getdata{\blx@tempa}%
  \blx@imc@iffieldequals{#1}\blx@tempb
    {\aftergroup\@firstoftwo}
    {\aftergroup\@secondoftwo}%
  \endgroup}

\def\blx@whichxref#1#2{%
  \blx@imc@iffieldundef{crossref}
    {\blx@imc@iffieldundef{xref}
       {#2}
       {#1{xref}}}
    {#1{crossref}}}

% {<plainlist>}{<true>}{<false>}

\protected\def\blx@imc@iflistxref#1{%
  \blx@imc@iflistundef{#1}
    {\@secondoftwo}
    {\blx@whichxref
       {\blx@iflistxref{#1}}
       {\@secondoftwo}}}

\def\blx@iflistxref#1#2{%
  \begingroup
  \letcs\blx@tempa{abx@field@#2}%
  \letcs\blx@tempb{abx@list@#1}%
  \csundef{abx@list@#1}%
  \blx@getdata{\blx@tempa}%
  \blx@imc@iflistequals{#1}\blx@tempb
    {\aftergroup\@firstoftwo}
    {\aftergroup\@secondoftwo}%
  \endgroup}

% {<namelist>}{<true>}{<false>}

\protected\def\blx@imc@ifnamexref#1{%
  \blx@imc@ifnameundef{#1}
    {\@secondoftwo}
    {\blx@whichxref
       {\blx@ifnamexref{#1}}
       {\@secondoftwo}}}

\def\blx@ifnamexref#1#2{%
  \begingroup
  \letcs\blx@tempa{abx@field@#2}%
  \letcs\blx@tempb{abx@name@#1}%
  \csundef{abx@name@#1}%
  \blx@getdata{\blx@tempa}%
  \blx@imc@ifnameequals{#1}\blx@tempb
    {\aftergroup\@firstoftwo}
    {\aftergroup\@secondoftwo}%
  \endgroup}

% {<string>}{<true>}{<false>}

\protected\def\blx@imc@ifcurrentfield#1{%
  \begingroup
  \def\blx@tempa{#1}%
  \ifx\currentfield\blx@tempa
    \aftergroup\@firstoftwo
  \else
    \aftergroup\@secondoftwo
  \fi
  \endgroup}

% {<string>}{<true>}{<false>}

\protected\def\blx@imc@ifcurrentlist#1{%
  \begingroup
  \def\blx@tempa{#1}%
  \ifx\currentlist\blx@tempa
    \aftergroup\@firstoftwo
  \else
    \aftergroup\@secondoftwo
  \fi
  \endgroup}

% {<string>}{<true>}{<false>}

\protected\def\blx@imc@ifcurrentname#1{%
  \begingroup
  \def\blx@tempa{#1}%
  \ifx\currentname\blx@tempa
    \aftergroup\@firstoftwo
  \else
    \aftergroup\@secondoftwo
  \fi
  \endgroup}

% {<string>}{<true>}{<false>}

\protected\def\blx@imc@ifentrytype#1{%
  \begingroup
  \def\blx@tempa{#1}%
  \ifx\abx@field@entrytype\blx@tempa
    \aftergroup\@firstoftwo
  \else
    \aftergroup\@secondoftwo
  \fi
  \endgroup}

% {<true>}{<false>}

\def\blx@imc@ifmorenames{%
  \ifundef\currentname
    {\@secondoftwo}
    {\iftoggle{abx@bool@more\currentname}
       {\@firstoftwo}
       {\ifnum\c@listtotal>\c@liststop
          \expandafter\@firstoftwo
        \else
          \expandafter\@secondoftwo
        \fi}}}

% {<true>}{<false>}

\def\blx@imc@ifmoreitems{%
  \ifundef\currentlist
    {\@secondoftwo}
    {\iftoggle{abx@bool@more\currentlist}
       {\@firstoftwo}
       {\ifnum\c@listtotal>\c@liststop
          \expandafter\@firstoftwo
        \else
          \expandafter\@secondoftwo
        \fi}}}

% {<true>}{<false>}

\protected\def\blx@imc@ifciteseen@global{%
  \expandafter\blx@ifseen@global
  \expandafter{\abx@field@entrykey}}

\protected\def\blx@imc@ifciteseen@context{%
  \expandafter\blx@ifseen@context
  \expandafter{\abx@field@entrykey}}

% {<entrykey>}{<true>}{<false>}

\protected\def\blx@imc@ifentryseen@global{%
  \blx@sanitizekeys\blx@ifseen@global}

\protected\def\blx@imc@ifentryseen@context{%
  \blx@sanitizekeys\blx@ifseen@context}

\def\blx@ifseen@global#1{%
  \ifinlistcs{#1}{blx@bsee@\the\c@refsection}}

\def\blx@ifseen@context#1{%
  \iftoggle{blx@footnote}
    {\ifinlistcs{#1}{blx@fsee@\the\c@refsection}}
    {\ifinlistcs{#1}{blx@bsee@\the\c@refsection}}}

% {<true>}{<false>}

\def\blx@imc@ifciteibid@global{%
  \blx@imc@iffieldequals{entrykey}\blx@lastkey@text}

\def\blx@imc@ifciteibid@context{%
  \iftoggle{blx@footnote}
    {\blx@imc@iffieldequals{entrykey}\blx@lastkey@foot}
    {\blx@imc@iffieldequals{entrykey}\blx@lastkey@text}}

\def\blx@imc@ifciteibid@strict{%
  \blx@ifcitesingle
    {\blx@imc@ifciteibid@global}
    {\@secondoftwo}}%

\def\blx@imc@ifciteibid@constrict{%
  \blx@ifcitesingle
    {\iftoggle{blx@footnote}
       {\blx@ifmpfncheck
          {\blx@imc@iffieldequals{entrykey}\blx@lastkey@foot}
          {\@secondoftwo}}
       {\blx@imc@iffieldequals{entrykey}\blx@lastkey@text}}
    {\@secondoftwo}}%

% {<true>}{<false>}

\def\blx@imc@ifciteidem@global{%
  \blx@imc@iffieldequals{fullhash}\blx@lasthash@text}

\def\blx@imc@ifciteidem@context{%
  \iftoggle{blx@footnote}
    {\blx@imc@iffieldequals{fullhash}\blx@lasthash@foot}
    {\blx@imc@iffieldequals{fullhash}\blx@lasthash@text}}

\def\blx@imc@ifciteidem@strict{%
  \blx@ifcitesingle
    {\blx@imc@ifciteidem@global}
    {\@secondoftwo}}%

\def\blx@imc@ifciteidem@constrict{%
  \blx@ifcitesingle
    {\iftoggle{blx@footnote}
       {\blx@ifmpfncheck
          {\blx@imc@iffieldequals{fullhash}\blx@lasthash@foot}
          {\@secondoftwo}}
       {\blx@imc@iffieldequals{fullhash}\blx@lasthash@text}}
    {\@secondoftwo}}%

% {<true>}{<false>}

\def\blx@imc@ifopcit@global{%
  \blx@imc@iffieldequalcs{entrykey}{blx@lastkey@text@\abx@field@namehash}}

\def\blx@imc@ifopcit@context{%
  \iftoggle{blx@footnote}
    {\blx@imc@iffieldequalcs{entrykey}{blx@lastkey@foot@\abx@field@namehash}}
    {\blx@imc@iffieldequalcs{entrykey}{blx@lastkey@text@\abx@field@namehash}}}

\def\blx@imc@ifopcit@strict{%
  \blx@ifcitesingle
    {\blx@imc@ifopcit@global}
    {\@secondoftwo}}%

\def\blx@imc@ifopcit@constrict{%
  \blx@ifcitesingle
    {\iftoggle{blx@footnote}
       {\blx@ifmpfncheck
          {\blx@imc@iffieldequalcs{entrykey}{blx@lastkey@foot@\abx@field@namehash}}
          {\@secondoftwo}}
       {\blx@imc@iffieldequalcs{entrykey}{blx@lastkey@text@\abx@field@namehash}}}
    {\@secondoftwo}}%

% {<true>}{<false>}

\def\blx@imc@ifloccit@global{%
  \blx@loccit@check{text}}

\def\blx@imc@ifloccit@context{%
  \iftoggle{blx@footnote}
    {\blx@loccit@check{foot}}
    {\blx@loccit@check{text}}}

\def\blx@imc@ifloccit@strict{%
  \blx@ifcitesingle
    {\blx@loccit@numcheck{text}}
    {\@secondoftwo}}%

\def\blx@imc@ifloccit@constrict{%
  \blx@ifcitesingle
    {\iftoggle{blx@footnote}
       {\blx@ifmpfncheck
          {\blx@loccit@numcheck{foot}}
          {\@secondoftwo}}
       {\blx@loccit@numcheck{text}}}
    {\@secondoftwo}}

\def\blx@loccit@check#1{%
  \blx@imc@iffieldundef{postnote}
    {\@secondoftwo}
    {\blx@imc@iffieldequalcs{postnote}{blx@lastnote@#1@\abx@field@entrykey}}}

\def\blx@loccit@numcheck#1{%
  \blx@imc@iffieldundef{postnote}
    {\@secondoftwo}
    {\expandafter\blx@ifnumerals@loccit
     \expandafter{\abx@field@postnote}
       {\blx@imc@iffieldequalcs{postnote}{blx@lastnote@#1@\abx@field@entrykey}}
       {\@secondoftwo}}}

% {<true>}{<false>}

\def\blx@ifmpfncheck{%
  \ifnum\numexpr\value\@mpfn-\blx@lastmpfn<\tw@
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi}

\def\blx@mpfnsave{%
  \xdef\blx@lastmpfn{\the\value\@mpfn}}

\def\blx@mpfnreset{%
  \global\let\blx@lastmpfn\z@}

\blx@mpfnreset

% {<true>}{<false>}

\def\blx@imc@iffirstonpage{%
  \iftoggle{blx@footnote}
    {\blx@iffirstonpage{fnpage}}
    {\blx@iffirstonpage{page}}}

\def\blx@iffirstonpage#1{%
  \ifcsundef{blx@#1@\number\c@instcount}
    {\@secondoftwo}
    {\expandafter\blx@iffirstonpage@i
     \expandafter{\number\numexpr\c@instcount-1}{#1}}}

\def\blx@iffirstonpage@i#1#2{%
  \ifcsundef{blx@#2@#1}
    {\ifnum#1>\@ne
       \expandafter\@firstoftwo
     \else
       \expandafter\@secondoftwo
     \fi
     {\expandafter\blx@iffirstonpage@i
      \expandafter{\number\numexpr#1-1}{#2}}
     {\@firstoftwo}}
    {\ifnum\csuse{blx@#2@\number\c@instcount}=%
           \csuse{blx@#2@#1} %
       \expandafter\@secondoftwo
     \else
       \expandafter\@firstoftwo
     \fi}}

% {<count1>}{<count2>}{<true>}{<false>}

\def\blx@imc@ifsamepage#1#2{%
  \ifcsundef{blx@page@\number\numexpr#1}
    {\ifcsundef{blx@fnpage@\number\numexpr#1}
       {\@secondoftwo}
       {\blx@ifsamepage{#1}{#2}{fnpage}}}
    {\blx@ifsamepage{#1}{#2}{page}}}

\def\blx@ifsamepage#1#2#3{%
  \ifcsundef{blx@page@\number\numexpr#2}
    {\ifcsundef{blx@fnpage@\number\numexpr#2}
       {\@secondoftwo}
       {\blx@ifsamepage@i{#1}{#2}{#3}{fnpage}}}
    {\blx@ifsamepage@i{#1}{#2}{#3}{page}}}

\def\blx@ifsamepage@i#1#2#3#4{%
  \ifnum\csuse{blx@#3@\number\numexpr#1}=%
        \csuse{blx@#4@\number\numexpr#2} %
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi}

% {<string>}{<true>}{<false>}

\protected\long\def\blx@imc@ifinteger#1{%
  \begingroup
  \def\do##1{\uccode`##1=`\%}%
  \do\0\do\1\do\2\do\3\do\4\do\5\do\6\do\7\do\8\do\9%
  \makeatletter
  \catcode`\%=9
  \endlinechar\m@ne
  \uppercase{\scantokens{\def\blx@tempa{#1}}}%
  \ifx\blx@tempa\@empty
    \aftergroup\@firstoftwo
  \else
    \aftergroup\@secondoftwo
  \fi
  \endgroup}

% {<string>}{<true>}{<false>}

\protected\def\blx@imc@ifnumeral{%
  \begingroup
  \blx@hook@ifnum
  \blx@ifnum}

\protected\def\blx@imc@ifnumerals{%
  \begingroup
  \blx@hook@ifnum
  \blx@hook@ifnums
  \blx@ifnum}

\protected\def\blx@ifnumerals@loccit{%
  \begingroup
  \blx@hook@ifnum
  \blx@hook@ifnums
  \blx@hook@ifloccit
  \blx@ifnum}

\long\def\blx@ifnum#1{%
  \makeatletter
  \catcode`\%=9
  \endlinechar\m@ne
  \everyeof{\noexpand}%
  \let\protect\@unexpandable@protect
  \uppercase{\edef\blx@tempa{\scantokens{#1}}}%
  \ifx\blx@tempa\@empty
    \aftergroup\@firstoftwo
  \else
    \aftergroup\@secondoftwo
  \fi
  \endgroup}

\def\blx@hook@ifnum{%
  \def\do##1{\uccode`##1=`\%}%
  \do\ \do\0\do\1\do\2\do\3\do\4\do\5\do\6\do\7\do\8\do\9%
  \do\i\do\v\do\x\do\l\do\c\do\d\do\m
  \do\I\do\V\do\X\do\L\do\C\do\D\do\M
  \blx@donumchars
  \let\RN\@firstofone
  \let\Rn\@firstofone}

\def\blx@hook@ifnums{%
  \def\do##1{\uccode`##1=`\%}%
  \blx@dorangechars
  \def\do##1{\let##1\@empty}%
  \blx@dorangecmds}

\let\blx@hook@ifloccit\@empty

\newrobustcmd*{\DeclareNumChars}{%
  \@ifstar
    {\blx@defnumchars}
    {\global\let\blx@donumchars\@empty
     \blx@defnumchars}}

\def\blx@defnumchars#1{%
  \ifblank{#1}
    {}
    {\expandafter\blx@defdochars
     \expandafter\blx@donumchars
     \detokenize{#1}\relax}}

\newrobustcmd*{\DeclareRangeChars}{%
  \@ifstar
    {\blx@defrangechars}
    {\global\let\blx@dorangechars\@empty
     \blx@defrangechars}}

\def\blx@defrangechars#1{%
  \ifblank{#1}
    {}
    {\expandafter\blx@defdochars
     \expandafter\blx@dorangechars
     \detokenize{#1}\relax}}

\def\blx@defdochars#1#2{%
  \ifx#2\relax
  \else
    \xdef#1{%
      \expandonce#1\noexpand\do
      \expandafter\noexpand\csname#2\endcsname}%
    \expandafter\blx@defdochars
    \expandafter#1%
  \fi}

\newrobustcmd*{\DeclareRangeCommands}{%
  \@ifstar
    {\blx@defrangecmds}
    {\global\let\blx@dorangecmds\@empty
     \blx@defrangecmds}}

\def\blx@defrangecmds#1{%
  \ifblank{#1}
    {}
    {\blx@defrangecmds@i#1&}}

\def\blx@defrangecmds@i#1{%
  \ifx&#1%
  \else
    \gappto\blx@dorangecmds{\do#1}%
    \expandafter\blx@defrangecmds@i
  \fi}

\DeclareNumChars{.}
\DeclareRangeChars{~,;-+/}
\DeclareRangeCommands{%
  \ \,\space\nobreakspace\addspace\addnbspace
  \addthinspace\addnbthinspace\addlowpenspace
  \addhighpenspace\addlpthinspace\addhpthinspace
  \adddotspace\addabbrvspace\&\psq\psqq
  \bibrangedash\textendash\textemdash}

% *{<code>}

\newrobustcmd*{\NumCheckSetup}{\appto\blx@hook@ifnum}
\newcommand*{\NumcheckSetup}{\NumCheckSetup}

% [<pagination>]{<string>}

\newrobustcmd*{\blx@imc@mkpageprefix}[1][pagination]{%
  \blx@imc@iffieldequalstr{#1}{none}
    {\@firstofone}
    {\begingroup
     \def\blx@tempa{page}%
     \blx@imc@iffieldundef{#1}
       {}
       {\blx@imc@iffieldbibstring{#1}
          {\edef\blx@tempa{\blx@imc@thefield{#1}}}
          {\blx@warning@entry{%
             Unknown pagination type '\blx@imc@thefield{#1}'}}}%
     \expandafter\endgroup
     \expandafter\blx@mkpageprefix
     \expandafter{\blx@tempa}}}

\long\def\blx@mkpageprefix#1#2{%
  \blx@imc@ifnumeral{#2}
    {\blx@imc@bibstring{#1}\ppspace#2}
    {\blx@imc@ifnumerals{#2}
       {\blx@imc@bibstring{#1s}\ppspace#2}
       {\begingroup
        \def\pno{\blx@imc@bibstring{#1}}%
        \def\ppno{\blx@imc@bibstring{#1s}}%
        #2\endgroup}}}

% [<pagination>]{<string>}

\newrobustcmd*{\blx@imc@mkpagetotal}[1][bookpagination]{%
  \begingroup
  \def\blx@tempa{page}%
  \blx@imc@iffieldundef{#1}
    {}
    {\blx@imc@iffieldequalstr{#1}{none}
       {}
       {\blx@imc@iffieldbibstring{#1}
          {\edef\blx@tempa{\blx@imc@thefield{#1}}}
          {\blx@warning@entry{%
             Unknown pagination type '\blx@imc@thefield{#1}'}}}}%
  \expandafter\endgroup
  \expandafter\blx@mkpagetotal
  \expandafter{\blx@tempa}}

\long\def\blx@mkpagetotal#1#2{%
  \begingroup
  \blx@imc@ifnumeral{#2}
    {\setbox\@tempboxa=\hbox{%
       \@tempcnta0#2\relax
       \ifnum\@tempcnta=\@ne
         \aftergroup\@firstoftwo
       \else
         \aftergroup\@secondoftwo
       \fi}%
     {#2\ppspace\blx@imc@bibstring{#1}}
     {#2\ppspace\blx@imc@bibstring{#1s}}}
    {\def\pno{\blx@imc@bibstring{#1}}%
     \def\ppno{\blx@imc@bibstring{#1s}}%
     #2}%
  \endgroup}

\newcommand*{\ppspace}{\addnbspace}
\newcommand*{\sqspace}{\addnbspace}

\newrobustcmd*{\RN}[1]{%
  \begingroup
  \expandafter\RNfont
  \expandafter{\romannumeral#1}%
  \endgroup}
\newrobustcmd*{\Rn}[1]{%
  \begingroup
  \expandafter\Rnfont
  \expandafter{\romannumeral#1}%
  \endgroup}

\newcommand*{\RNfont}{\uppercase}
\newcommand*{\Rnfont}{}

% {<init>}{<entrytype>}

\protected\def\blx@imc@usedriver#1#2{%
  \begingroup
  \let\finentry\unspace
  \let\newblock\relax
  \let\abx@macro@bibindex\@empty
  \let\abx@macro@pageref\@empty
  \csuse{blx@hook@bbxinit}#1%
  \blx@begbabel
  \blx@driver{#2}%
  \blx@endbabel
  \endgroup}

% Punctuation

\def\blx@initunit{%
  \global\togglefalse{blx@block}%
  \global\togglefalse{blx@unit}%
  \global\togglefalse{blx@insert}%
  \global\togglefalse{blx@lastins}%
  \global\let\blx@unitpunct\newunitpunct
  \blx@imc@resetpunctfont}

\def\blx@nounit{%
  \global\togglefalse{blx@lastins}}

\def\blx@unitmark{23sp}

\def\blx@begunit{%
  \toggletrue{blx@tempa}%
  \iftoggle{blx@insert}
    {\iftoggle{blx@unit}
       {\begingroup
          \let\blx@begunit\@empty
          \let\blx@endunit\@empty
          \blx@unitpunct\blx@postpunct
        \endgroup
        \global\togglefalse{blx@unit}%
        \togglefalse{blx@tempa}}
       {\blx@postpunct}%
     \iftoggle{blx@block}
       {\begingroup
          \let\blx@begunit\@empty
          \let\blx@endunit\@empty
          \newblockpunct
        \endgroup
        \global\togglefalse{blx@block}%
        \togglefalse{blx@tempa}}
       {}}
    {}%
  \blx@postpunct
  \blx@imc@resetpunctfont
  \iftoggle{blx@tempa}
    {}
    {\global\togglefalse{blx@insert}}%
  \blx@leavevmode
  \@ifquotemarker
    {}
    {\penalty\@M
     \hskip-\blx@unitmark\relax
     \hskip\blx@unitmark\relax}%
  \begingroup}

\def\blx@endunit{%
  \endgroup
  \ifdim\lastskip=\blx@unitmark
    \unskip\unskip\unpenalty
    \global\togglefalse{blx@lastins}%
  \else
    \global\toggletrue{blx@insert}%
    \global\toggletrue{blx@lastins}%
  \fi}

\protected\def\blx@imc@newblock{%
  \global\toggletrue{blx@block}}%

\protected\def\blx@imc@newunit{%
  \global\let\blx@unitpunct\newunitpunct
  \global\toggletrue{blx@unit}}%

\protected\def\blx@imc@setunit{%
  \@ifstar\blx@setunit@i\blx@setunit}

\long\def\blx@setunit#1{%
  \long\gdef\blx@unitpunct{#1}%
  \global\toggletrue{blx@unit}}%

\def\blx@setunit@i{%
  \iftoggle{blx@lastins}
    {\blx@setunit}
    {\@gobble}}

\protected\def\blx@imc@finentry{%
  \unspace\finentrypunct
  \blx@postpunct
  \blx@initunit}

\protected\def\blx@imc@finentry@inset{%
  \blx@setunit\entrysetpunct
  \global\toggletrue{blx@block}}

\appto\blx@blxinit{%
  \let\thefield\blx@imc@thefield
  \let\strfield\blx@imc@strfield
  \let\thelist\blx@imc@thelist
  \let\thename\blx@imc@thename
  \let\clearfield\blx@imc@clearfield
  \let\clearlist\blx@imc@clearlist
  \let\clearname\blx@imc@clearname
  \let\restorefield\blx@imc@restorefield
  \let\restorelist\blx@imc@restorelist
  \let\restorename\blx@imc@restorename
  \let\ifciteseen\blx@imc@ifciteseen
  \let\ifentryseen\blx@imc@ifentryseen
  \let\ifciteibid\blx@imc@ifciteibid
  \let\ifciteidem\blx@imc@ifciteidem
  \let\ifopcit\blx@imc@ifopcit
  \let\ifloccit\blx@imc@ifloccit
  \let\ifcurrentfield\blx@imc@ifcurrentfield
  \let\ifcurrentlist\blx@imc@ifcurrentlist
  \let\ifcurrentname\blx@imc@ifcurrentname
  \let\ifentrytype\blx@imc@ifentrytype
  \let\iffieldequalcs\blx@imc@iffieldequalcs
  \let\iffieldequals\blx@imc@iffieldequals
  \let\iffieldequalstr\blx@imc@iffieldequalstr
  \let\iffieldsequal\blx@imc@iffieldsequal
  \let\iffieldundef\blx@imc@iffieldundef
  \let\iffieldxref\blx@imc@iffieldxref
  \let\iflistequalcs\blx@imc@iflistequalcs
  \let\iflistequals\blx@imc@iflistequals
  \let\iflistsequal\blx@imc@iflistsequal
  \let\iflistundef\blx@imc@iflistundef
  \let\iflistxref\blx@imc@iflistxref
  \let\ifmorenames\blx@imc@ifmorenames
  \let\ifmoreitems\blx@imc@ifmoreitems
  \let\ifnameequalcs\blx@imc@ifnameequalcs
  \let\ifnameequals\blx@imc@ifnameequals
  \let\ifnamesequal\blx@imc@ifnamesequal
  \let\ifnameundef\blx@imc@ifnameundef
  \let\ifnamexref\blx@imc@ifnamexref
  \let\iffirstonpage\blx@imc@iffirstonpage
  \let\ifsamepage\blx@imc@ifsamepage
  \let\savefield\blx@imc@savefield
  \let\savefieldcs\blx@imc@savefieldcs
  \let\savelist\blx@imc@savelist
  \let\savelistcs\blx@imc@savelistcs
  \let\savename\blx@imc@savename
  \let\savenamecs\blx@imc@savenamecs
  \let\usedriver\blx@imc@usedriver
  \let\ifinteger\blx@imc@ifinteger
  \let\ifnumeral\blx@imc@ifnumeral
  \let\ifnumerals\blx@imc@ifnumerals
  \let\mkpageprefix\blx@imc@mkpageprefix
  \let\mkpagetotal\blx@imc@mkpagetotal
  \let\newblock\blx@imc@newblock
  \let\newunit\blx@imc@newunit
  \let\setunit\blx@imc@setunit
  \let\finentry\blx@imc@finentry
  \protected\def\pno{\blx@imc@bibstring{page}}%
  \protected\def\ppno{\blx@imc@bibstring{pages}}%
  \let\nopp\relax
  \protected\def\psq{\sqspace\blx@imc@bibstring{sequens}}%
  \protected\def\psqq{\sqspace\blx@imc@bibstring{sequentes}}%
  \blx@initunit}

\appto\blx@blxinit{%
  \def\ifcitation{\iftoggle{blx@citation}}%
  \def\ifbibliography{\iftoggle{blx@bibliography}}%
  \def\iffootnote{\iftoggle{blx@footnote}}%
  \def\ifuseprefix{\iftoggle{blx@useprefix}}%
  \def\ifuseauthor{\iftoggle{blx@useauthor}}%
  \def\ifuseeditor{\iftoggle{blx@useeditor}}%
  \def\ifusetranslator{\iftoggle{blx@usetranslator}}%
  \def\iffirstinits{\iftoggle{blx@firstinits}}%
  \def\ifsingletitle{\iftoggle{abx@bool@singletitle}}%
  \def\ifandothers#1{\iftoggle{abx@bool@more#1}}}

%% Global formatting hooks

% capitalization

% {<text>}

\newcommand{\MakeCapital}{}
\begingroup
\catcode`\"=\active
\protected\long\gdef\MakeCapital#1{%
  \begingroup
  \def\do##1{\def##1{\blx@mkcp@single##1}}%
  \abx@dosingleaccents
  \def\do##1{\def##1{\blx@mkcp@double##1}}%
  \abx@dodoubleaccents
  \def\IeC{\blx@mkcp@single\IeC}%
  \def\@tabacckludge##1{%
    \expandafter\blx@mkcp@single\csname\string##1\endcsname}%
  \ifnum\catcode`\"=\active
    \def"##1{\blx@mkcp@single"\noexpand##1}%
  \fi
  \def\blx@mkcp@single{\noexpand\blx@mkcp@single\noexpand}%
  \def\blx@mkcp@double{\noexpand\blx@mkcp@double\noexpand}%
  \protected@edef\blx@tempa{%
    \noexpand\ifblank{#1}
      {\endgroup\unexpanded{#1}}
      {\noexpand\blx@mkcp@parse#1}}%
  \blx@tempa}
\endgroup

\long\def\blx@mkcp@parse#1{%
  \begingroup
  \expandafter\def\expandafter\blx@tempa\expandafter{#1}%
  \ifx\blx@tempa\blx@mkcp@single
    \aftergroup\blx@mkcp@two
  \else\ifx\blx@tempa\blx@mkcp@double
    \aftergroup\blx@mkcp@three
  \else
    \aftergroup\blx@mkcp@one
  \fi\fi
  \endgroup{#1}}

\long\def\blx@mkcp@one#1{%
  \def\i{I}\def\j{J}%
  \def\do##1##2{\let##1##2\do}%
  \expandafter\do\@uclclist\relax{\relax\@gobble}%
  \uppercase{\protected@edef\blx@tempa{#1}}%
  \expandafter\endgroup\blx@tempa}
\def\blx@mkcp@two#1#2#3{\blx@mkcp@one{#2#3}}
\def\blx@mkcp@three#1#2#3#4{\blx@mkcp@one{#2#3#4}}

\let\blx@mkcp@single\@empty
\let\blx@mkcp@double\@empty

\def\abx@dosingleaccents{%
  \do\"\do\'\do\`\do\^\do\~\do\=\do\.%
  \do\H\do\b\do\c\do\d\do\r\do\u\do\v}
\def\abx@dodoubleaccents{%
  \do\t}

% {<text>}

\newrobustcmd*{\MakeSentenceCase}{%
  \@ifstar\blx@mksc@i\blx@mksc@ii}

\def\blx@mksc@i{%
  \ifdef\abx@field@hyphenation
    {\xifinlist\abx@field@hyphenation\blx@cmksc@lang
       {\blx@mksc@ii}
       {\@firstofone}}
    {\blx@mksc@ii}}

\long\def\blx@mksc@ii#1{%
  \begingroup
  \def\blx@tempa{\endgroup}%
  \let\blx@tempb\@empty
  \def\blx@tempc{\MakeCapital}%
  \@tempswatrue
  \blx@mksc@parse#1\blx@mksc@end}

\def\blx@mksc@parse{%
  \futurelet\@let@token\blx@mksc@eval}

\def\blx@mksc@eval{%
  \ifx\@let@token\blx@mksc@end
    \blx@mksc@end
  \fi
  \ifx\@let@token\bgroup
    \blx@mksc@group
  \fi
  \ifx\@let@token\@sptoken
    \if@tempswa\blx@mksc@eject\fi
    \blx@mksc@space
  \fi
  \if\relax\noexpand\@let@token
    \blx@mksc@cs
  \fi
  \if-\noexpand\@let@token
    \if@tempswa\blx@mksc@eject\fi
  \fi
  \blx@mksc@other&}

\def\blx@mksc@end#1\blx@mksc@end{\fi
  \blx@mksc@eject
  \blx@tempa}

\long\def\blx@mksc@group#1&#2{\fi
  \futurelet\@let@token\blx@mksc@ingroup#2&{#2}%
  \blx@mksc@parse}

\long\def\blx@mksc@ingroup#1&#2{%
  \if\relax\noexpand\@let@token
    \blx@mksc@locase{{#2}}%
  \else
    \blx@mksc@nocase{{#2}}%
  \fi}

\def\blx@mksc@space{\def\blx@mksc@space##1&}
\@nameuse{blx@mksc@space} {\fi
  \blx@mksc@anycase{ }%
  \blx@mksc@parse}

\long\def\blx@mksc@cs#1&#2{\fi
  \ifcat\noexpand~\noexpand#2%
    \blx@mksc@locase{#2}%
  \else
    \blx@mksc@nocase{#2}%
  \fi
  \blx@mksc@parse}

\long\def\blx@mksc@other&#1{%
  \blx@mksc@locase{#1}%
  \blx@mksc@parse}

\def\blx@mksc@locase{%
  \appto\blx@tempb}

\def\blx@mksc@nocase{%
  \blx@mksc@eject
  \appto\blx@tempa}

\def\blx@mksc@anycase{%
  \ifx\blx@tempb\@empty
    \expandafter\appto
    \expandafter\blx@tempa
  \else
    \expandafter\appto
    \expandafter\blx@tempb
  \fi}

\def\blx@mksc@eject{%
  \ifx\blx@tempb\@empty
  \else
    \eappto\blx@tempa{%
      \expandonce\blx@tempc{\expandonce\blx@tempb}}%
    \let\blx@tempb\@empty
  \fi
  \if@tempswa
    \def\blx@tempc{\MakeLowercase}%
    \@tempswafalse
  \fi}

% {<language,language,...>}

\newrobustcmd*{\DeclareCaseLangs}{%
  \@ifstar
    {\blx@defcaselangs}
    {\global\let\blx@cmksc@lang\@empty
     \blx@defcaselangs}}

\def\blx@defcaselangs#1{%
  \ifblank{#1}
    {}
    {\begingroup
     \def\do##1{\listgadd\blx@cmksc@lang{##1}}
     \docsvlist{#1}%
     \endgroup}}

\DeclareCaseLangs{%
  american,british,canadian,
  english,USenglish,UKenglish,
  australian,newzealand}

%% Main formatting commands

% {<name>}{<definition>}

\def\blx@defformat#1{%
  \blx@safe@actives
  \afterassignment\blx@rest@actives
  \long\csdef{#1}}

% {<name>}{<name>}

\def\blx@letformat#1#2{%
  \blx@safe@actives
  \afterassignment\blx@rest@actives
  \csletcs{#1}{#2}}

% [aliastype]{aliasname}[formattype]{formatname}

\def\blx@defalias#1{%
  \@ifnextchar[%]
    {\blx@defalias@i{#1}}
    {\blx@defalias@i{#1}[*]}}
\def\blx@defalias@i#1[#2]#3{%
  \@ifnextchar[%]
    {\blx@defalias@ii{#1}{#2}{#3}}
    {\blx@defalias@ii{#1}{#2}{#3}[*]}}
\def\blx@defalias@ii#1#2#3[#4]#5{%
  \blx@safe@actives
  \afterassignment\blx@rest@actives
  \csedef{abx@#1@#2@#3}{%
    \expandonce{\csname abx@#1@#4@#5\endcsname}}}

% {<macro>}{<id>}{<name>}{<field>}

\def\blx@getformat#1#2#3#4{%
  \blx@safe@actives
  \afterassignment\blx@rest@actives
  \ifcsundef{abx@#2@\blx@imc@thefield{entrytype}@#3}
    {\ifcsundef{abx@#2@*@#3}
       {\ifcsundef{abx@#2@\blx@imc@thefield{entrytype}@#4}
          {\ifcsundef{abx@#2@*@#4}
             {\letcs#1{abx@#2@*@default}}
             {\letcs#1{abx@#2@*@#4}}}
          {\letcs#1{abx@#2@\blx@imc@thefield{entrytype}@#4}}}
       {\letcs#1{abx@#2@*@#3}}}
    {\letcs#1{abx@#2@\blx@imc@thefield{entrytype}@#3}}}

% [<entrytype>]{<name>}

\newrobustcmd*{\savefieldformat}[2][*]{\blx@save{abx@ffd@#1@#2}}
\newrobustcmd*{\savelistformat}[2][*]{\blx@save{abx@lfd@#1@#2}}
\newrobustcmd*{\savenameformat}[2][*]{\blx@save{abx@nfd@#1@#2}}

\newrobustcmd*{\restorefieldformat}[2][*]{\blx@restore{abx@ffd@#1@#2}}
\newrobustcmd*{\restorelistformat}[2][*]{\blx@restore{abx@lfd@#1@#2}}
\newrobustcmd*{\restorenameformat}[2][*]{\blx@restore{abx@nfd@#1@#2}}

% [<entrytype>]{<name>}{<definiton>}

\newrobustcmd*{\DeclareNameFormat}[2][*]{%
  \blx@defformat{abx@nfd@#1@#2}##1##2##3##4##5##6##7##8}
\newrobustcmd*{\DeclareIndexNameFormat}[2][*]{%
  \blx@defformat{abx@nid@#1@#2}##1##2##3##4##5##6##7##8}

\newrobustcmd*{\DeclareListFormat}[2][*]{%
  \blx@defformat{abx@lfd@#1@#2}##1}
\newrobustcmd*{\DeclareIndexListFormat}[2][*]{%
  \blx@defformat{abx@lid@#1@#2}##1}

\newrobustcmd*{\DeclareFieldFormat}[2][*]{%
  \blx@defformat{abx@ffd@#1@#2}##1}
\newrobustcmd*{\DeclareIndexFieldFormat}[2][*]{%
  \blx@defformat{abx@fid@#1@#2}##1}

% [<entrytype>]{<alias>}[<entrytype>]{<name>}

\newrobustcmd*{\DeclareNameAlias}{\blx@defalias{nfd}}
\newrobustcmd*{\DeclareIndexNameAlias}{\blx@defalias{nid}}

\newrobustcmd*{\DeclareListAlias}{\blx@defalias{lfd}}
\newrobustcmd*{\DeclareIndexListAlias}{\blx@defalias{lid}}

\newrobustcmd*{\DeclareFieldAlias}{\blx@defalias{ffd}}
\newrobustcmd*{\DeclareIndexFieldAlias}{\blx@defalias{fid}}

% [<format>]{<text>}

\newrobustcmd{\blx@imc@printtext}[2][]{%
  \ifblank{#2}
    {\blx@nounit}
    {\ifblank{#1}
       {\let\blx@theformat\@firstofone}
       {\blx@getformat\blx@theformat{ffd}{#1}{}}%
     \ifdefvoid\blx@theformat
       {\blx@nounit}
       {\blx@begunit
        \blx@theformat{#2}%
        \blx@endunit}}}

% [<format>]{<field>}

\newrobustcmd*{\blx@imc@printfield}[2][]{%
  \blx@imc@iffieldundef{#2}
    {\blx@nounit}
    {\blx@getformat\blx@theformat{ffd}{#1}{#2}%
     \ifdefvoid\blx@theformat
       {\blx@nounit}
       {\blx@begunit
        \def\currentfield{#2}%
        \expandafter\expandafter
	\expandafter\blx@theformat
	\expandafter\expandafter
	\expandafter{\csname abx@field@#2\endcsname}%
        \blx@endunit}}}

% [<format>]{<field>}

\protected\def\blx@imc@indexfield{%
  \iftoggle{blx@index}
    {\blx@indexfield}
    {\blx@noindex}}

\newcommand*{\blx@indexfield}[2][]{%
  \blx@imc@iffieldundef{#2}
    {}
    {\blx@getformat\blx@theformat{fid}{#1}{#2}%
     \ifdefvoid\blx@theformat
       {}
       {\begingroup
        \def\currentfield{#2}%
        \letcs\blx@tempa{abx@field@#2}%
        \expandafter\blx@theformat\expandafter{\blx@tempa}%
        \endgroup}}}

% [<format>]{<file>}

\newrobustcmd*{\blx@imc@printfile}[2][]{%
  \iftoggle{blx@loadfiles}
    {\IfFileExists{#2}
       {\blx@imc@printtext[#1]{\input{#2}\unspace}}
       {\blx@nounit}}
    {\blx@nounit}}

% {<macro>}[<format>][<start>-<stop>]
% => <macro>{<format>}{<start>}{<stop>}

\def\blx@listargs#1{%
  \@ifnextchar[%]
    {\blx@listargs@i{#1}}
    {#1{}{}{}}}

\def\blx@listargs@i#1[#2]{%
  \@ifnextchar[%]
    {\blx@listargs@ii{#1}{#2}}
    {#1{#2}{}{}}}

\def\blx@listargs@ii#1#2[#3]{%
  \blx@listargs@iii{#1}{#2}#3&}

\def\blx@listargs@iii#1#2#3-#4&{%
  #1{#2}{#3}{#4}}

% [<format>][<start>-<stop>]{<namelist>}

\protected\def\blx@imc@printnames{%
  \blx@listargs\blx@printnames}

% {<format>}{<start>}{<stop>}{<namelist>}

\def\blx@printnames#1#2#3#4{%
  \blx@imc@ifnameundef{#4}
    {\blx@nounit}
    {\blx@getformat\blx@theformat{nfd}{#1}{#4}%
     \ifdefvoid\blx@theformat
       {\blx@nounit}
       {\blx@begunit
        \blx@namesetup{#2}{#3}{#4}%
        \expandafter\blx@nameparser\blx@thedata{}&%
        \blx@endunit}}}

\def\blx@namesetup#1#2#3{%
  \c@listcount\@ne
  \expandafter\c@listtotal\csname c@#3\endcsname
  \ifblank{#1}
    {\c@liststart\@ne}
    {\ifnum#1<\@ne
       \c@liststart\@ne
     \else
       \c@liststart#1\relax
     \fi}%
  \ifblank{#2}
    {\ifnum\c@listtotal>\c@maxnames
       \c@liststop\c@minnames
     \else
       \c@liststop\c@listtotal
     \fi}
    {\ifnum#2>\c@listtotal
       \c@liststop\c@listtotal
     \else
       \c@liststop#2\relax
     \fi}%
  \def\currentname{#3}%
  \letcs\blx@thedata{abx@name@#3}%
  \let~\abx@btxnbspacefix
  \blx@namecodes}

\protected\def\abx@btxnbspacefix{%
  \leavevmode\penalty\value{highnamepenalty}\space}

% [<format>][<start>-<stop>]{<namelist>}

\protected\def\blx@imc@indexnames{%
  \iftoggle{blx@index}
    {\blx@listargs\blx@indexnames}
    {\blx@noindex}}

% {<format>}{<start>}{<stop>}{<namelist>}

\def\blx@indexnames#1#2#3#4{%
  \blx@imc@ifnameundef{#4}
    {}
    {\blx@getformat\blx@theformat{nid}{#1}{#4}%
     \ifdefvoid\blx@theformat
       {}
       {\begingroup
        \blx@namesetup{#2}{#3}{#4}%
        \expandafter\blx@nameparser\blx@thedata{}&%
        \endgroup}}}

% {<name1>}{<name2>}{...}

\long\def\blx@nameparser#1{%
  \ifblank{#1}
    {\blx@namebreak}
    {\ifnum\c@listcount<\c@liststart
     \else
       \blx@theformat#1%
     \fi
     \advance\c@listcount\@ne
     \ifnum\c@listcount>\c@liststop
       \expandafter\blx@namebreak
     \fi
     \blx@nameparser}}

\long\def\blx@namebreak#1&{}

% [<format>][<start>-<stop>]{<plainlist>}

\protected\def\blx@imc@printlist{%
  \blx@listargs\blx@printlist}

% {<format>}{<start>}{<stop>}{<plainlist>}

\def\blx@printlist#1#2#3#4{%
  \blx@imc@iflistundef{#4}
    {\blx@nounit}
    {\blx@getformat\blx@theformat{lfd}{#1}{#4}%
     \ifdefvoid\blx@theformat
       {\blx@nounit}
       {\blx@begunit
        \blx@listsetup{#2}{#3}{#4}%
        \expandafter\blx@listparser\blx@thedata{}&%
        \blx@endunit}}}

\def\blx@listsetup#1#2#3{%
  \c@listcount\@ne
  \expandafter\c@listtotal\csname c@#3\endcsname
  \ifblank{#1}
    {\c@liststart\@ne}
    {\ifnum#1<\@ne
       \c@liststart\@ne
     \else
       \c@liststart#1\relax
     \fi}%
  \ifblank{#2}
    {\ifnum\c@listtotal>\c@maxitems
       \c@liststop\c@minitems
     \else
       \c@liststop\c@listtotal
     \fi}
    {\ifnum#2>\c@listtotal
       \c@liststop\c@listtotal
     \else
       \c@liststop#2\relax
     \fi}%
  \def\currentlist{#3}%
  \letcs\blx@thedata{abx@list@#3}}

% [<format>][<start>-<stop>]{<plainlist>}

\protected\def\blx@imc@indexlist{%
  \iftoggle{blx@index}
    {\blx@listargs\blx@indexlist}
    {\blx@noindex}}

% {<format>}{<start>}{<stop>}{<plainlist>}

\def\blx@indexlist#1#2#3#4{%
  \blx@imc@iflistundef{#4}
    {}
    {\blx@getformat\blx@theformat{lid}{#1}{#4}%
     \ifdefvoid\blx@theformat
       {}
       {\begingroup
        \blx@listsetup{#2}{#3}{#4}%
        \expandafter\blx@listparser\blx@thedata{}&%
        \endgroup}}}

\def\blx@noindex{\@ifnextchar[\blx@noindex@i\@gobble}
\def\blx@noindex@i[#1]{\blx@noindex}

% {<item1>}{<item2>}{...}

\long\def\blx@listparser#1{%
  \ifblank{#1}
    {\blx@listbreak}
    {\ifnum\c@listcount<\c@liststart
     \else
       \blx@theformat{#1}%
     \fi
     \advance\c@listcount\@ne
     \ifnum\c@listcount>\c@liststop
       \expandafter\blx@listbreak
     \fi
     \blx@listparser}}

\long\def\blx@listbreak#1&{}

% {<key>}{<code>}

\protected\long\def\blx@imc@entrydata#1#2{%
  \blx@ifdata{#1}
    {\begingroup
     \blx@resetdata
     \blx@getdata{#1}%
     \blx@entrysetcount
     \blx@options
     \addtocounter{instcount}\@ne
     \blx@execute
     \blx@begbabel#2\blx@endbabel
     \endgroup}
    {}}

\protected\def\blx@imc@entryset#1#2{%
  \blx@imc@iffieldundef{entrykey}
    {}
    {\begingroup
     \long\def\blx@set@precode{#1}%
     \long\def\blx@set@postcode{#2}%
     \let\finentry\blx@imc@finentry@inset
     \let\do\blx@entryset
     \blx@imc@docsvfield{entryset}%
     \endgroup}}

\def\blx@entryset#1{%
  \blx@ifdata{#1}
    {\begingroup
     \begingroup
     \blx@getdata{#1}%
     \edef\blx@tempa{\endgroup
       \def\noexpand\abx@field@entrytype{\abx@field@entrytype}}%
     \blx@tempa
     \def\abx@field@entrysetcount{1}%
     \blx@set@precode
     \blx@driver{\blx@imc@thefield{entrytype}}%
     \blx@set@postcode
     \endgroup}
    {}%
  \let\do\blx@entryset@i}

\def\blx@entryset@i#1{%
  \blx@imc@entrydata{#1}{%
    \blx@set@precode
    \blx@driver{\blx@imc@thefield{entrytype}}
    \blx@set@postcode}}

\appto\blx@blxinit{%
  \let\printtext\blx@imc@printtext
  \let\printfield\blx@imc@printfield
  \let\printlist\blx@imc@printlist
  \let\printnames\blx@imc@printnames
  \let\printfile\blx@imc@printfile
  \let\indexfield\blx@imc@indexfield
  \let\indexlist\blx@imc@indexlist
  \let\indexnames\blx@imc@indexnames
  \let\entrydata\blx@imc@entrydata
  \let\entryset\blx@imc@entryset}

%% Localization

% [<wrapper>]{<string>}

\newrobustcmd*{\blx@imc@bibstring}[2][\@firstofone]{%
  \blx@begunit
  \blx@hyphenreset
  \let\bibstring\blx@imc@bibxstring
  \lowercase{\edef\blx@tempa{#2}}%
  \ifcsundef{abx@str@\blx@tempa}
    {\blx@warn@nostring{\blx@tempa}}
    {\blx@imc@ifcapital
       {#1{\MakeCapital{\csuse{abx@str@\blx@tempa}}}}
       {#1{\csuse{abx@str@\blx@tempa}}}}%
  \blx@endunit}

% [<wrapper>]{<string>}

\newrobustcmd*{\blx@imc@bibcpstring}[2][\@firstofone]{%
  \blx@begunit
  \blx@hyphenreset
  \let\bibstring\blx@imc@bibxstring
  \lowercase{\edef\blx@tempa{#2}}%
  \ifcsundef{abx@str@\blx@tempa}
    {\blx@warn@nostring{\blx@tempa}}
    {#1{\MakeCapital{\csuse{abx@str@\blx@tempa}}}}%
  \blx@endunit}

% [<wrapper>]{<string>}

\newrobustcmd*{\blx@imc@biblcstring}[2][\@firstofone]{%
  \blx@begunit
  \blx@hyphenreset
  \let\bibstring\blx@imc@bibxstring
  \lowercase{\edef\blx@tempa{#2}}%
  \ifcsundef{abx@str@\blx@tempa}
    {\blx@warn@nostring{\blx@tempa}}
    {#1{\MakeLowercase{\csuse{abx@str@\blx@tempa}}}}%
  \blx@endunit}

% [<wrapper>]{<string>}

\newrobustcmd*{\blx@imc@bibucstring}[2][\@firstofone]{%
  \blx@begunit
  \blx@hyphenreset
  \let\bibstring\blx@imc@bibxstring
  \lowercase{\edef\blx@tempa{#2}}%
  \ifcsundef{abx@str@\blx@tempa}
    {\blx@warn@nostring{\blx@tempa}}
    {#1{\MakeUppercase{\csuse{abx@str@\blx@tempa}}}}%
  \blx@endunit}

% {<string>}

\def\blx@imc@bibxstring#1{%
  \ifcsundef{abx@str@#1}
    {\protect\blx@warn@nostring{#1}}
    {\csuse{abx@str@#1}}}

% {<string>}{<true>}{<false>}

\def\blx@imc@ifbibstring#1{%
  \ifcsundef{abx@str@\detokenize{#1}}
    {\@secondoftwo}
    {\@firstoftwo}}

% {<field>}{<true>}{<false>}

\def\blx@imc@iffieldbibstring#1{%
  \blx@imc@iffieldundef{#1}
    {\@secondoftwo}
    {\ifcsundef{abx@str@\detokenize\expandafter
       \expandafter\expandafter{\csname abx@field@#1\endcsname}}
       {\@secondoftwo}
       {\@firstoftwo}}}

\appto\blx@blxinit{%
  \let\bibstring\blx@imc@bibstring
  \let\bibxstring\blx@imc@bibxstring
  \let\bibcpstring\blx@imc@bibcpstring
  \let\biblcstring\blx@imc@biblcstring
  \let\bibucstring\blx@imc@bibucstring
  \let\ifbibstring\blx@imc@ifbibstring
  \let\iffieldbibstring\blx@imc@iffieldbibstring}

\appto\blx@blxinit{%
  \appto\@uclclist{%
    \bibstring\bibucstring
    \biblcstring\bibstring
    \bibcpstring\bibucstring
    \biblcstring\bibcpstring
    \biblcstring\bibucstring}}

\def\abx@dostrings{%
  \do{bibliography}%
  \do{references}%
  \do{shorthands}%
  \do{editor}%
  \do{editors}%
  \do{typeeditor}%
  \do{typeeditors}%
  \do{typecompiler}%
  \do{typecompilers}%
  \do{translator}%
  \do{translators}%
  \do{redactor}%
  \do{redactors}%
  \do{commentator}%
  \do{commentators}%
  \do{annotator}%
  \do{annotators}%
  \do{commentary}%
  \do{annotations}%
  \do{introduction}%
  \do{foreword}%
  \do{afterword}%
  \do{editortr}%
  \do{editorstr}%
  \do{editorco}%
  \do{editorsco}%
  \do{editoran}%
  \do{editorsan}%
  \do{editorin}%
  \do{editorsin}%
  \do{editorfo}%
  \do{editorsfo}%
  \do{editoraf}%
  \do{editorsaf}%
  \do{editortrco}%
  \do{editorstrco}%
  \do{editortran}%
  \do{editorstran}%
  \do{editortrin}%
  \do{editorstrin}%
  \do{editortrfo}%
  \do{editorstrfo}%
  \do{editortraf}%
  \do{editorstraf}%
  \do{editorcoin}%
  \do{editorscoin}%
  \do{editorcofo}%
  \do{editorscofo}%
  \do{editorcoaf}%
  \do{editorscoaf}%
  \do{editoranin}%
  \do{editorsanin}%
  \do{editoranfo}%
  \do{editorsanfo}%
  \do{editoranaf}%
  \do{editorsanaf}%
  \do{editortrcoin}%
  \do{editorstrcoin}%
  \do{editortrcofo}%
  \do{editorstrcofo}%
  \do{editortrcoaf}%
  \do{editorstrcoaf}%
  \do{editortranin}%
  \do{editorstranin}%
  \do{editortranfo}%
  \do{editorstranfo}%
  \do{editortranaf}%
  \do{editorstranaf}%
  \do{translatorco}%
  \do{translatorsco}%
  \do{translatoran}%
  \do{translatorsan}%
  \do{translatorin}%
  \do{translatorsin}%
  \do{translatorfo}%
  \do{translatorsfo}%
  \do{translatoraf}%
  \do{translatorsaf}%
  \do{translatorcoin}%
  \do{translatorscoin}%
  \do{translatorcofo}%
  \do{translatorscofo}%
  \do{translatorcoaf}%
  \do{translatorscoaf}%
  \do{translatoranin}%
  \do{translatorsanin}%
  \do{translatoranfo}%
  \do{translatorsanfo}%
  \do{translatoranaf}%
  \do{translatorsanaf}%
  \do{byauthor}%
  \do{bytypeauthor}
  \do{byeditor}
  \do{bytypeeditor}
  \do{bytypeeditora}
  \do{bytypeeditorb}
  \do{bytypecompiler}%
  \do{bytypecompilera}%
  \do{bytypecompilerb}%
  \do{bytranslator}
  \do{byredactor}%
  \do{bycommentator}%
  \do{byannotator}%
  \do{withcommentator}%
  \do{withannotator}%
  \do{withintroduction}%
  \do{withforeword}%
  \do{withafterword}%
  \do{byeditortr}
  \do{byeditorco}
  \do{byeditoran}
  \do{byeditorin}
  \do{byeditorfo}
  \do{byeditoraf}
  \do{byeditortrco}
  \do{byeditortran}
  \do{byeditortrin}
  \do{byeditortrfo}
  \do{byeditortraf}
  \do{byeditorcoin}
  \do{byeditorcofo}
  \do{byeditorcoaf}
  \do{byeditoranin}
  \do{byeditoranfo}
  \do{byeditoranaf}
  \do{byeditortrcoin}
  \do{byeditortrcofo}
  \do{byeditortrcoaf}
  \do{byeditortranin}
  \do{byeditortranfo}
  \do{byeditortranaf}
  \do{bytranslatorco}
  \do{bytranslatoran}
  \do{bytranslatorin}
  \do{bytranslatorfo}
  \do{bytranslatoraf}
  \do{bytranslatorcoin}
  \do{bytranslatorcofo}
  \do{bytranslatorcoaf}
  \do{bytranslatoranin}
  \do{bytranslatoranfo}
  \do{bytranslatoranaf}
  \do{and}%
  \do{andothers}%
  \do{andmore}%
  \do{volume}%
  \do{volumes}%
  \do{jourvol}%
  \do{jourser}%
  \do{newseries}%
  \do{oldseries}%
  \do{edition}%
  \do{reprint}%
  \do{reprintof}%
  \do{reprintas}%
  \do{page}%
  \do{pages}%
  \do{column}%
  \do{columns}%
  \do{line}%
  \do{lines}%
  \do{verse}%
  \do{verses}%
  \do{section}%
  \do{sections}%
  \do{paragraph}%
  \do{paragraphs}%
  \do{in}%
  \do{inseries}%
  \do{ofseries}%
  \do{number}%
  \do{chapter}%
  \do{mathesis}%
  \do{phdthesis}%
  \do{resreport}%
  \do{techreport}%
  \do{software}%
  \do{datacd}%
  \do{audiocd}%
  \do{version}%
  \do{doi}%
  \do{url}%
  \do{urlseen}%
  \do{file}%
  \do{library}%
  \do{abstract}%
  \do{annotation}%
  \do{citedas}%
  \do{seenote}%
  \do{quotedin}%
  \do{opcit}%
  \do{loccit}%
  \do{ibidem}%
  \do{idem}%
  \do{idemsf}%
  \do{idemsm}%
  \do{idemsn}%
  \do{idempf}%
  \do{idempm}%
  \do{idempn}%
  \do{idempp}%
  \do{confer}%
  \do{sequens}%
  \do{sequentes}%
  \do{passim}%
  \do{see}%
  \do{seealso}%
  \do{thiscite}%
  \do{january}%
  \do{february}%
  \do{march}%
  \do{april}%
  \do{may}%
  \do{june}%
  \do{july}%
  \do{august}%
  \do{september}%
  \do{october}%
  \do{november}%
  \do{december}%
  \do{langamerican}%
  \do{langbrazilian}%
  \do{langdanish}%
  \do{langdutch}%
  \do{langenglish}%
  \do{langfrench}%
  \do{langgerman}%
  \do{langgreek}%
  \do{langitalian}%
  \do{langlatin}%
  \do{langnorwegian}%
  \do{langportuguese}%
  \do{langspanish}%
  \do{langswedish}%
  \do{fromamerican}%
  \do{frombrazilian}%
  \do{fromdanish}%
  \do{fromdutch}%
  \do{fromenglish}%
  \do{fromfrench}%
  \do{fromgerman}%
  \do{fromgreek}%
  \do{fromitalian}%
  \do{fromlatin}%
  \do{fromnorwegian}%
  \do{fromportuguese}%
  \do{fromspanish}%
  \do{fromswedish}%
  \do{countryde}%
  \do{countryep}%
  \do{countryeu}%
  \do{countryfr}%
  \do{countryuk}%
  \do{countryus}%
  \do{patent}%
  \do{patentde}%
  \do{patenteu}%
  \do{patentfr}%
  \do{patentuk}%
  \do{patentus}%
  \do{patreq}%
  \do{patreqde}%
  \do{patreqeu}%
  \do{patreqfr}%
  \do{patrequk}%
  \do{patrequs}%
}

\newrobustcmd*{\NewBibliographyString}[1]{%
  \ifcsundef{KV@blx@lbx@#1}
    {\gappto\abx@dostrings{\do{#1}}%
     \csgdef{KV@blx@lbx@#1}##1{\blx@defstring{#1}{##1}}}
    {}}

% in *.cbx/bbx/tex: <key> = {<string>},
% in *.lbx:         <key> = {{<longstring>}{<abbrevstring>}},

\def\do#1{\define@key{blx@lbx}{#1}{\blx@defstring{#1}{##1}}}
\abx@dostrings

% in *.cbx/bbx/tex: (implicit)
% in *.lbx:         inherit = {<language>},

\define@key{blx@lbx}{inherit}{%
  \blx@lbxinput{#1}{}{\blx@err@nolang{#1}}%
  \csuse{abx@strings@#1}}

\def\blx@cfg@defstring#1{\csdef{abx@str@#1}}
\def\blx@lbx@defstring#1#2{%
  \expandafter\blx@lbx@thedef\csname abx@str@#1\endcsname#2}
\def\blx@lbx@longdef#1#2#3{\def#1{#2}}
\def\blx@lbx@shortdef#1#2#3{\def#1{#3}}

% {<language>}

\def\blx@lbxcheck#1{%
  \ifcsdef{blx@lng@#1}
    {\expandafter\expandafter\expandafter\IfFileExists
     \expandafter\expandafter\expandafter{%
     \csname blx@lng@#1\endcsname.lbx}
       {}
       {\blx@err@nolang{#1}}}
    {\IfFileExists{#1.lbx}
       {}
       {\blx@err@nolang{#1}}}}

% {<language>}{<definitions>}

\newrobustcmd*{\DefineBibliographyExtras}[2]{%
  \blx@lbxcheck{#1}%
  \csgappto{blx@hook@extras@#1}{%
    \blx@defbibextras{#1}{#2}}}
\@onlypreamble\DefineBibliographyExtras

\newrobustcmd*{\UndefineBibliographyExtras}[2]{%
  \blx@lbxcheck{#1}%
  \csgappto{blx@hook@noextras@#1}{%
    \blx@undefbibextras{#1}{#2}}}
\@onlypreamble\UndefineBibliographyExtras

\def\blx@defbibextras#1{\csgappto{abx@extras@#1}}
\def\blx@undefbibextras#1{\csgappto{abx@noextras@#1}}

% {<language>}{<language>}

\def\blx@letbibextras#1#2{%
  \blx@lbxinput{#2}{}{\blx@err@nolang{#2}}%
  \global\csletcs{abx@extras@#1}{abx@extras@#2}
  \global\csletcs{abx@noextras@#1}{abx@noextras@#2}}%

% {<language>}{<strings>}

\newrobustcmd*{\DefineBibliographyStrings}[2]{%
  \blx@lbxcheck{#1}%
  \csgappto{blx@hook@strings@#1}{%
    \begingroup
    \let\blx@defstring\blx@cfg@defstring
    \blx@defbibstrings{#1}{#2}%
    \endgroup}}
\@onlypreamble\DefineBibliographyStrings

\def\blx@defbibstrings#1#2{%
  \def\do##1{\csundef{abx@str@##1}}%
  \abx@dostrings
  \csuse{abx@strings@#1}%
  \setkeys{blx@lbx}{#2}%
  \global\cslet{abx@strings@#1}\@empty
  \def\do##1{%
    \ifcsundef{abx@str@##1}
      {\csxappto{abx@strings@#1}{%
         \undef\expandafter\noexpand\csname abx@str@##1\endcsname}}
      {\csxappto{abx@strings@#1}{%
         \def\expandafter\noexpand\csname abx@str@##1\endcsname{%
           \csexpandonce{abx@str@##1}}}}}%
  \abx@dostrings
  \csgappto{abx@strings@#1}{%
    \let\bibname\abx@str@bibliography
    \let\refname\abx@str@references
    \let\losname\abx@str@shorthands}}

% {<language>}{<language>}

\def\blx@letbibstrings#1#2{%
  \blx@lbxinput{#2}{}{\blx@err@nolang{#2}}%
  \global\csletcs{abx@strings@#1}{abx@strings@#2}}%

% {<language>}{<exceptions>}

\newrobustcmd*{\DefineHyphenationExceptions}[2]{%
  \ifcsundef{l@#1}
    {\blx@warn@nohyph{#1}}
    {}%
  \csgappto{blx@hook@hyph@#1}{\blx@hyphexcept{#1}{#2}}}
\@onlypreamble\DefineHyphenationExceptions

\def\blx@hyphexcept#1#2{%
  \ifcsundef{l@#1}
    {\blx@warn@nohyph{#1}}
    {\begingroup
     \language\csname l@#1\endcsname\relax
     \hyphenation{#2}%
     \endgroup}}

% {<language>}{<mapping>}

\newrobustcmd*{\DeclareLanguageMapping}[2]{%
  \csgdef{blx@lng@#1}{#2}}
\@onlypreamble\DeclareLanguageMapping

% {<language>}{<success>}{<failure>}

\def\blx@lbxinput#1{%
  \ifcsdef{blx@lng@#1}
    {\expandafter\expandafter\expandafter\blx@lbxinput@i
     \expandafter\expandafter\expandafter{%
       \csname blx@lng@#1\endcsname}{#1}}
    {\blx@lbxinput@ii{#1}{#1.lbx}{language '#1'}}}

% {<mapping>}{<language>}

\def\blx@lbxinput@i#1#2{%
  \global\csundef{blx@lng@#2}%
  \IfFileExists{#1.lbx}
    {\blx@lbxinput@ii{#2}{#1.lbx}{language '#2' -> '#1'}}
    {\blx@warning@noline{%
       File '#1.lbx' not found!\MessageBreak
       Ignoring mapping '#2' -> '#1'}
     \blx@lbxinput{#2}}}

% {<language>}{<lbxfile>}{<message>}

\def\blx@lbxinput@ii#1#2#3{%
  \begingroup
  \setbox\@tempboxa=\hbox\bgroup
    \aftergroup\endgroup
    \blx@inputonce{#2}{#3}
      {\global\cslet{abx@strings@#1}\@empty
       \global\cslet{abx@extras@#1}\@empty
       \global\cslet{abx@noextras@#1}\@empty
       \blx@maplang{#1}{#1}%
       \def\InheritBibliographyStrings{\blx@letbibstrings{#1}}%
       \def\DeclareBibliographyStrings####1{%
         \begingroup
         \let\blx@defstring\blx@lbx@defstring
	 \blx@defbibstrings{#1}{####1}%
	 \endgroup}%
       \def\InheritBibliographyExtras{\blx@letbibextras{#1}}%
       \def\DeclareBibliographyExtras{\blx@defbibextras{#1}}%
       \def\UndeclareBibliographyExtras{\blx@undefbibextras{#1}}%
       \def\DeclareHyphenationExceptions{\blx@hyphexcept{#1}}%
       \begingroup
       \blx@saneccodes
       \makeatletter}
      {\endgroup
       \blx@lbxinput@iii{strings}{#1}%
       \blx@lbxinput@iii{extras}{#1}%
       \blx@lbxinput@iii{noextras}{#1}%
       \blx@lbxinput@iii{hyph}{#1}}
      {\aftergroup\@firstoftwo}
      {\aftergroup\@secondoftwo}%
  \egroup}

\def\blx@lbxinput@iii#1#2{%
  \ifcsdef{blx@hook@#1@#2}
    {\csuse{blx@hook@#1@#2}%
     \global\csundef{blx@hook@#1@#2}}
    {}}

% {<language>}

\def\blx@langsetup#1{%
  \blx@lbxinput{#1}
    {\edef\blx@languagename{#1}}
    {\blx@warning
       {Language '#1' not supported.\MessageBreak
        Using fallback language '\blx@languagename'}%
     \blx@lbxinput{\blx@languagename}
       {\blx@maplang{#1}{\blx@languagename}}
       {\blx@err@nolang{\blx@languagename}}}}

% auxiliary macros

\newrobustcmd*{\bibrangedash}{\textendash}
\newrobustcmd*{\finalandcomma}{}
\newrobustcmd*{\mkbibordinal}[1]{#1}
\newrobustcmd*{\mkbibmascord}{\mkbibordinal}
\newrobustcmd*{\mkbibfemord}{\mkbibordinal}
\newrobustcmd*{\bibdatelong}{}
\newrobustcmd*{\bibdateshort}{}
\newrobustcmd*{\biburldatelong}{}
\newrobustcmd*{\biburldateshort}{}
\newrobustcmd*{\mkbibmonth}[1]{%
  \ifcase0#1%
  \or\bibstring{january}%
  \or\bibstring{february}%
  \or\bibstring{march}%
  \or\bibstring{april}%
  \or\bibstring{may}%
  \or\bibstring{june}%
  \or\bibstring{july}%
  \or\bibstring{august}%
  \or\bibstring{september}%
  \or\bibstring{october}%
  \or\bibstring{november}%
  \or\bibstring{december}%
  \else#1%
  \fi}%

% {<language>}{<strings>}

\def\blx@maplang#1#2{%
  \csxappto{captions#1}{%
    \expandafter\noexpand\csname abx@strings@#2\endcsname}%
  \csxappto{extras#1}{%
    \noexpand\blx@resetpunct
    \expandafter\noexpand\csname abx@extras@#2\endcsname}%
  \csxappto{noextras#1}{%
    \noexpand\blx@resetpunct
    \expandafter\noexpand\csname abx@noextras@#2\endcsname}}

%% Babel interface

\def\blx@languagename{english}
\let\blx@begbabel\begingroup
\let\blx@endbabel\endgroup
\def\blx@hyphenreset{%
  \ifcsundef{l@\blx@languagename}
    {}
    {\language\csname l@\blx@languagename\endcsname\relax}%
  \ifcsundef{\blx@languagename hyphenmins}
    {\blx@sethyphenmins\tw@\thr@@}
    {\expandafter\expandafter\expandafter\blx@sethyphenmins
       \csname\blx@languagename hyphenmins\endcsname}}
\def\blx@sethyphenmins#1#2{%
  \lefthyphenmin#1\relax
  \righthyphenmin#2\relax}

\def\blx@mkbabel{%
  \patchcmd\bbl@set@language
    {\select@language}
    {\blx@langsetup\languagename\select@language}%
    {\ifundef\blx@babelenv
       {}
       {\def\blx@begbabel{%
          \begingroup
          \blx@imc@iffieldundef{hyphenation}
            {}
            {\def\blx@endbabel{%
               \csname end\blx@babelenv\endcsname
               \endgroup}%
             \csname\blx@babelenv\expandafter\endcsname
               \expandafter{\abx@field@hyphenation}}}}%
     \blx@langsetup\bbl@main@language}
    {\blx@err@patch{'babel' package}%
     \blx@mknobabel}}

\def\blx@mknobabel{%
  \blx@lbxinput{\blx@languagename}
    {}
    {\blx@err@nolang{\blx@languagename}}}

%% Bibtex data interface

\def\abx@donames{%
  \do{labelname}%
  \do{author}%
  \do{shortauthor}%
  \do{editor}%
  \do{shorteditor}%
  \do{bookauthor}%
  \do{translator}%
  \do{redactor}%
  \do{annotator}%
  \do{commentator}%
  \do{introduction}%
  \do{foreword}%
  \do{afterword}%
  \do{holder}%
  \do{namea}%
  \do{nameb}%
  \do{namec}%
}

\def\abx@dolists{%
  \do{institution}%
  \do{language}%
  \do{location}%
  \do{organization}%
  \do{origlocation}%
  \do{origpublisher}%
  \do{pageref}%
  \do{publisher}%
  \do{lista}%
  \do{listb}%
  \do{listc}%
  \do{listd}%
  \do{liste}%
  \do{listf}%
}

\def\abx@dofields{%
  \do{entrykey}%
  \do{entrytype}%
  \do{entrysubtype}%
  \do{entryset}%
  \do{entrysetcount}%
  \do{crossref}%
  \do{xref}%
  \do{hyphenation}%
  \do{keywords}%
  \do{authortype}%
  \do{editortype}%
  \do{nameatype}%
  \do{namebtype}%
  \do{namectype}%
  \do{addendum}%
  \do{booktitle}%
  \do{booksubtitle}%
  \do{booktitleaddon}%
  \do{chapter}%
  \do{day}%
  \do{doi}%
  \do{edition}%
  \do{eid}%
  \do{eprint}%
  \do{eprinttype}%
  \do{file}%
  \do{gender}%
  \do{howpublished}%
  \do{indextitle}%
  \do{indexsorttitle}%
  \do{isan}%
  \do{isbn}%
  \do{ismn}%
  \do{isrn}%
  \do{issn}%
  \do{issue}%
  \do{iswc}%
  \do{issuetitle}%
  \do{issuesubtitle}%
  \do{journaltitle}%
  \do{journalsubtitle}%
  \do{label}%
  \do{labelalpha}%
  \do{extraalpha}%
  \do{labelnumber}%
  \do{labeltitle}%
  \do{labelyear}%
  \do{library}%
  \do{localnumber}%
  \do{mainsubtitle}%
  \do{maintitle}%
  \do{maintitleaddon}%
  \do{month}%
  \do{nameaddon}%
  \do{namehash}%
  \do{fullhash}%
  \do{note}%
  \do{number}%
  \do{origlanguage}%
  \do{origtitle}%
  \do{origyear}%
  \do{reprinttitle}%
  \do{pages}%
  \do{pagetotal}%
  \do{pagination}%
  \do{bookpagination}%
  \do{part}%
  \do{series}%
  \do{shorthand}%
  \do{shorthandintro}%
  \do{shortjournal}%
  \do{shortseries}%
  \do{shorttitle}%
  \do{sortinit}%
  \do{subtitle}%
  \do{title}%
  \do{titleaddon}%
  \do{eventtitle}%
  \do{type}%
  \do{url}%
  \do{urlday}%
  \do{urlmonth}%
  \do{urlyear}%
  \do{venue}%
  \do{version}%
  \do{volume}%
  \do{volumes}%
  \do{year}%
  \do{abstract}%
  \do{annotation}%
  \do{usera}%
  \do{userb}%
  \do{userc}%
  \do{userd}%
  \do{usere}%
  \do{userf}%
  \do{verba}%
  \do{verbb}%
  \do{verbc}%
}

\def\abx@dobooleans{%
  \do{singletitle}%
}

\def\do#1{%
  \newcounter{#1}%
  \csedef{the#1}{\noexpand\the\expandonce{\csname c@#1\endcsname}}%
  \appto\abx@dobooleans{\do{more#1}}}
\abx@donames
\abx@dolists
\def\do#1{\newtoggle{abx@bool@#1}}
\abx@dobooleans

\protected\def\blx@resetdata{%
  \let\blx@savedo\do
  \let\do\blx@imc@clearname
  \abx@donames
  \let\do\blx@imc@clearlist
  \abx@dolists
  \let\do\blx@imc@clearfield
  \abx@dofields\do{execute}\do{options}%
  \def\do##1{\togglefalse{abx@bool@##1}}%
  \abx@dobooleans
  \c@uniquename\z@
  \let\do\blx@savedo}

% {<code>}

\protected\long\def\blx@bbl@preamble#1{%
  \gappto\abx@preamble{#1}#1}

% {<message>}

\protected\def\blx@bbl@warn#1{%
  \blx@warning@noline{%
    \ifnum\blx@backend=\blx@backend@biber
      Biber
    \else
      BibTeX
    \fi
    reported the following issues%
    \ifundef\abx@field@entrykey
      {}
      {\MessageBreak with the entry '\abx@field@entrykey'}%
    :\MessageBreak #1}}

% {<field>}{<value>}

\protected\long\def\blx@bbl@fielddef#1#2{%
  \csxappto\blx@bbl@data{%
    \def\expandonce{\csname abx@field@#1\endcsname}%
    {\unexpanded{#2}}}}

\protected\long\def\blx@bbl@fieldedef#1#2{%
  \csxappto\blx@bbl@data{%
    \def\expandonce{\csname abx@field@#1\endcsname}{#2}}}

\protected\long\def\blx@bbl@stringdef#1#2{%
  \csxappto\blx@bbl@data{%
    \def\expandonce{\csname abx@field@#1\endcsname}%
    {\detokenize{#2}}}}

% {<field>}

\protected\def\blx@bbl@verbdef#1{%
  \begingroup
  \let\verb\blx@bbl@verbadd
  \def\blx@tempa{#1}%
  \let\blx@tempb\@empty}

\protected\def\blx@bbl@verbend{%
  \csxappto\blx@bbl@data{%
    \def\expandonce{\csname abx@field@\blx@tempa\endcsname}%
      {\blx@tempb}}%
  \endgroup}

\protected\def\blx@bbl@verbadd{%
  \begingroup
  \let\do\@makeother
  \dospecials
  \catcode\endlinechar=12\relax
  \blx@bbl@verbadd@i}

\begingroup
\catcode`\<=12
\catcode`\>=12
\uccode`\<=`\ %
\uccode`\>=\endlinechar
\uppercase{\gdef\blx@bbl@verbadd@i<#1>}{%
  \endgroup
  \edef\blx@tempb{\blx@tempb\detokenize{#1}}}
\endgroup

% {<counter>}{<value>}

\protected\long\def\blx@bbl@countdef#1#2{%
  \csxappto\blx@bbl@data{%
    \csname c@#1\endcsname#2\relax}}

% {<boolean>}

\protected\def\blx@bbl@booltrue#1{%
  \csgappto\blx@bbl@data{%
    \toggletrue{abx@bool@#1}}}

\protected\def\blx@bbl@boolfalse#1{%
  \csgappto\blx@bbl@data{%
    \togglefalse{abx@bool@#1}}}

% {<list}{<itemcount>}{<value>}

\protected\def\blx@bbl@listdef#1#2#3{%
  \csxappto\blx@bbl@data{%
    \csname c@#1\endcsname#2\relax
    \def\expandonce{\csname abx@list@#1\endcsname}%
    {\unexpanded{#3}}}}

% {<name>}{<itemcount>}{<value>}

\protected\def\blx@bbl@namedef#1#2#3{%
  \csxappto\blx@bbl@data{%
    \csname c@#1\endcsname#2\relax
    \def\expandonce{\csname abx@name@#1\endcsname}%
    {\unexpanded{#3}}}}

% {<entrykey>,...}

\protected\def\blx@bbl@set#1{%
  \blx@bbl@fieldedef{entryset}{\detokenize{#1}}%
  \csxdef{blx@setp@\the\c@refsection @\abx@field@entrykey}{\detokenize{#1}}%
  \begingroup
  \@tempcnta\z@
  \let\do\blx@bbl@set@i
  \expandafter\docsvlist\expandafter{\detokenize{#1}}%
  \endgroup}

\def\blx@bbl@set@i#1{%
  \advance\@tempcnta\@ne
  \csxdef{blx@seti@\the\c@refsection @#1}{\the\@tempcnta}}

% {<entrykey>}

\protected\def\blx@bbl@inset#1{%
  \toggletrue{blx@setonly}%
  \blx@bbl@fieldedef{entryset}{\detokenize{#1}}%
  \csxdef{blx@setc@\the\c@refsection @\abx@field@entrykey}{\detokenize{#1}}}

% {<entrykey>}

\protected\def\blx@bbl@xref#1{%
  \ifcsdef{blx@refp@\the\c@refsection @#1}
    {}
    {\listcsgadd{blx@refs@\the\c@refsection}{#1}}%
  \listcsxadd{blx@refp@\the\c@refsection @#1}{\abx@field@entrykey}%
  \csxdef{blx@refc@\the\c@refsection @\abx@field@entrykey}{#1}}

\def\blx@addxref#1{%
  \blx@ifdata{#1}
    {\begingroup
     \def\do##1{%
       \csgappto{blx@data@\the\c@refsection @##1}{%
	 \def\abx@field@xref{#1}}}%
     \dolistcsloop{blx@refp@\the\c@refsection @#1}%
     \endgroup}
    {}%
  \global\csundef{blx@refp@\the\c@refsection @#1}}

% {<keyword>,...}

\protected\def\blx@bbl@keyw#1{%
  \iftoggle{blx@skipbib}
    {}
    {\def\do{\blx@addkeyword{\abx@field@entrykey}}%
     \docsvlist{#1}%
     \blx@bbl@fielddef{keywords}{#1}}}

\def\blx@addkeyword#1#2{%
  \listcsxadd{blx@keyw@\the\c@refsection @\detokenize{#2}}{#1}}

% {<options>}

\protected\long\def\blx@bbl@options#1{%
  \begingroup
  \let\blx@tempa\@empty
  \let\do\blx@bbl@options@i
  \docsvlist{#1}%
  \edef\blx@tempa{%
    \endgroup
    \ifx\blx@tempa\@empty
    \else
      \def\noexpand\abx@field@options{\expandonce\blx@tempa}%
    \fi}%
  \blx@tempa}

\long\def\blx@bbl@options@i#1{\blx@bbl@options@ii#1==&}

\long\def\blx@bbl@options@ii#1=#2=#3&{%
  \ifcsundef{KV@blx@opt@bib@#1}
    {\blx@warning@noline{%
       Ignoring undefined option '#1'\MessageBreak
       at entry '\abx@field@entrykey'}}
    {\eappto\blx@tempa{%
       \ifx\blx@tempa\@empty\else,\fi
       \unexpanded{#1}\ifblank{#2}{}{=\unexpanded{#2}}}}}

% \blx@data@<section>@<entrykey>	data hook
%					key -> data
% \blx@sort@<section>			all entries, sorted
%					section -> keys [internal list]
% \blx@cite@<section>			all entries in bibliography, sorted
%					section -> keys [internal list]
% \blx@bsee@<section>			seen citations, document body
%					section -> keys [internal list]
% \blx@fsee@<section>			seen citations, footnotes
%					section -> keys [internal list]
% \blx@type@<section>@<entrytype>	type hash
%					type -> keys [internal list]
% \blx@segm@<section>@<segment>		segment hash
%					segment -> keys [internal list]
% \blx@keyw@<section>@<keyword>		keyword hash
%					keyword -> keys [internal list]
% \blx@losh@<section>			shorthand hash
%					section -> keys [internal list]
% \blx@catg@<category>			category hash, global
%					category -> keys [internal list]
% \blx@setp@<section>@<entrykey>	parent -> child mapping (entry sets)
%					key -> key,key,... [csv list]
% \blx@setc@<section>@<entrykey>	child -> parent mapping (entry sets)
%					key -> key
% \blx@seti@<section>@<entrykey>	child -> index mapping (entry sets)
%					key -> index
% \blx@pref@<section>@<entrykey>	pageref hook, temporary
%					key -> pages [internal list]
% \blx@refs@<section>			xref hash, temporary
%					section -> parents [internal list]
% \blx@refp@<section>@<entrykey>	parent -> child mapping (xrefs), temporary
%					key -> keys [internal list]
% \blx@refc@<section>@<entrykey>	child -> parent mapping (xrefs)
%					key -> key [internal list]

\def\blx@ifdata#1{%
  \ifcsdef{blx@data@\the\c@refsection @#1}}

\def\blx@getdata#1{%
  \csuse{blx@data@\the\c@refsection @#1}}

\def\blx@getdata@cite#1{%
  \ifcsdef{blx@setc@\the\c@refsection @#1}
    {\expandafter\expandafter\expandafter\blx@getdata
     \expandafter\expandafter\expandafter{%
       \csname blx@setc@\the\c@refsection @#1\endcsname}}
    {\blx@getdata{#1}}%
  \ifcsdef{blx@seti@\the\c@refsection @#1}
    {\letcs\abx@field@entrysetcount{blx@seti@\the\c@refsection @#1}}
    {}}

\def\blx@getdata@cite@i#1#2{%
  \blx@getdata{#1}%
  \def\abx@field@entrysetcount{#2}}

\def\blx@execute{%
  \blx@imc@thefield{execute}}

\def\blx@options{%
  \blx@imc@iffieldundef{options}
    {}
    {\begingroup
     \def\blx@tempa{\endgroup\setkeys{blx@opt@bib}}%
     \expandafter\blx@tempa
     \expandafter{\abx@field@options}}}

\def\blx@entrysetcount{%
  \ifdef\abx@field@entrykey
    {\ifcsdef{blx@seti@\the\c@refsection @\abx@field@entrykey}
       {\letcs\abx@field@entrysetcount{%
          blx@seti@\the\c@refsection @\abx@field@entrykey}}
       {}}
    {}}

% {<entrykey>}{<type>}{<options>}

\protected\def\blx@bbl@entry#1#2#3{%
  \begingroup
  \edef\abx@field@entrykey{\detokenize{#1}}%
  \blx@bbl@options{#3}\blx@options
  \edef\blx@bbl@data{blx@data@\the\c@refsection @\abx@field@entrykey}%
  \csuse\blx@bbl@data
  \cslet\blx@bbl@data\@empty
  \blx@bbl@fieldedef{entrykey}{\abx@field@entrykey}%
  \blx@bbl@fielddef{entrytype}{#2}%
  \blx@imc@iffieldundef{options}
    {}
    {\blx@bbl@fieldedef{options}{\expandonce\abx@field@options}}}

\protected\def\blx@bbl@endentry{%
  \csuse\blx@bbl@data
  \iftoggle{blx@setonly}
    {\global\toggletrue{blx@addset}%
     \toggletrue{blx@skipbib}%
     \toggletrue{blx@skiplos}%
     \toggletrue{blx@skiplab}}
    {\listcsxadd{blx@sort@\the\c@refsection}{\abx@field@entrykey}}%
  \iftoggle{blx@skipbib}
    {}
    {\listcsxadd{blx@cite@\the\c@refsection}{\abx@field@entrykey}%
     \listcsxadd{blx@type@\the\c@refsection @\abx@field@entrytype}{\abx@field@entrykey}%
     \ifcsundef{blx@pref@\the\c@refsection @\abx@field@entrykey}
       {}
       {\blx@addpageref{\abx@field@entrykey}}}%
  \iftoggle{blx@skiplos}
    {}
    {\blx@bbl@shorthand}%
  \iftoggle{blx@skiplab}
    {}
    {\iftoggle{blx@labelnumber}
       {\blx@bbl@labelnumber}
       {}%
     \iftoggle{blx@labelalpha}
       {\blx@bbl@labelalpha}
       {}%
     \iftoggle{blx@labelyear}
       {\blx@bbl@labelyear}
       {}}%
  \blx@bbl@labelname
  \blx@bbl@titles
  \blx@bbl@hooks
  \endgroup}

\def\blx@addset{%
  \begingroup
  \letcs\blx@tempa{blx@sort@\the\c@refsection}%
  \global\cslet{blx@sort@\the\c@refsection}\@empty
  \let\do\blx@addset@i
  \dolistloop\blx@tempa
  \endgroup}

\def\blx@addset@i#1{%
  \listcsgadd{blx@sort@\the\c@refsection}{#1}%
  \ifcsdef{blx@setp@\the\c@refsection @#1}
    {\begingroup
     \let\do\blx@addset@ii
     \expandafter\expandafter\expandafter\docsvlist
     \expandafter\expandafter\expandafter{%
       \csname blx@setp@\the\c@refsection @#1\endcsname}%
     \endgroup}
    {}}

\def\blx@addset@ii#1{%
  \listcsgadd{blx@sort@\the\c@refsection}{#1}}

\def\blx@bbl@shorthand{%
  \ifundef\abx@field@shorthand
    {}
    {\blx@setlabwidth{\shorthandwidth}{%
       \csuse{abx@ffd@*@shorthandwidth}{\abx@field@shorthand}}}}

\def\blx@bbl@labelnumber{%
  \ifundef\abx@field@shorthand
    {\ifundef\abx@field@localnumber
       {\csnumgdef{blx@labelnumber@\the\c@refsection}{%
          \csuse{blx@labelnumber@\the\c@refsection}+1}%
        \edef\abx@field@localnumber{%
          \csuse{blx@labelnumber@\the\c@refsection}}}
       {}%
     \blx@bbl@fieldedef{labelnumber}{\abx@field@localnumber}%
     \iftoggle{blx@skipbib}
       {}
       {\blx@setlabwidth{\labelnumberwidth}{%
          \csuse{abx@ffd@*@labelnumberwidth}{\abx@field@localnumber}}}}
    {\csgappto\blx@bbl@data{%
       \let\abx@field@labelnumber\abx@field@shorthand}%
     \iftoggle{blx@skipbib}
       {}
       {\blx@setlabwidth{\labelnumberwidth}{%
          \csuse{abx@ffd@*@labelnumberwidth}{\abx@field@shorthand}}}}}

\def\blx@bbl@labelalpha{%
  \ifundef\abx@field@shorthand
    {\ifundef\abx@field@labelalpha
       {}
       {\ifundef\abx@field@extraalpha
          {}
          {\ifnum\abx@field@extraalpha>\c@maxextraalpha
             \global\c@maxextraalpha\abx@field@extraalpha\relax
           \fi}%
        \iftoggle{blx@skipbib}
          {}
          {\blx@setlabwidth{\labelalphawidth}{%
             \csuse{abx@ffd@*@labelalphawidth}{%
               \csuse{abx@ffd@*@labelalpha}{\abx@field@labelalpha}%
               \ifundef\abx@field@extraalpha
                 {}
                 {\csuse{abx@ffd@*@extraalpha}{\abx@field@extraalpha}}}}}}}
    {\csgappto\blx@bbl@data{%
       \let\abx@field@labelalpha\abx@field@shorthand}%
     \iftoggle{blx@skipbib}
       {}
       {\blx@setlabwidth{\labelalphawidth}{%
          \csuse{abx@ffd@*@labelalphawidth}{\abx@field@shorthand}}}}}

\def\blx@bbl@labelyear{%
  \ifundef\abx@field@labelyear
    {}
    {\ifnum\abx@field@labelyear>\c@maxlabelyear
       \global\c@maxlabelyear\abx@field@labelyear\relax
     \fi}}

\def\blx@bbl@labelname{%
  \iftoggle{blx@useauthor}
    {\ifundef\abx@name@shortauthor
       {\ifundef\abx@name@author
          {\blx@bbl@labelname@i}
          {\csgappto\blx@bbl@data{%
             \c@labelname\c@author
             \let\abx@name@labelname\abx@name@author}%
           \iftoggle{abx@bool@moreauthor}
             {\csgappto\blx@bbl@data{%
                \toggletrue{abx@bool@morelabelname}}}
             {}}}
       {\csgappto\blx@bbl@data{%
          \c@labelname\c@shortauthor
          \let\abx@name@labelname\abx@name@shortauthor}%
        \iftoggle{abx@bool@moreshortauthor}
          {\csgappto\blx@bbl@data{%
             \toggletrue{abx@bool@morelabelname}}}
          {}}}
    {\blx@bbl@labelname@i}}

\def\blx@bbl@labelname@i{%
  \iftoggle{blx@useeditor}
    {\ifundef\abx@name@shorteditor
       {\ifundef\abx@name@editor
          {\blx@bbl@labelname@ii}
          {\csgappto\blx@bbl@data{%
             \c@labelname\c@editor
             \let\abx@name@labelname\abx@name@editor}%
           \iftoggle{abx@bool@moreeditor}
             {\csgappto\blx@bbl@data{%
                \toggletrue{abx@bool@morelabelname}}}
             {}}}
       {\csgappto\blx@bbl@data{%
          \c@labelname\c@shorteditor
          \let\abx@name@labelname\abx@name@shorteditor}%
        \iftoggle{abx@bool@moreshorteditor}
          {\csgappto\blx@bbl@data{%
             \toggletrue{abx@bool@morelabelname}}}
          {}}}
    {\blx@bbl@labelname@ii}}

\def\blx@bbl@labelname@ii{%
  \iftoggle{blx@usetranslator}
    {\ifundef\abx@name@translator
       {}
       {\csgappto\blx@bbl@data{%
          \c@labelname\c@translator
          \let\abx@name@labelname\abx@name@translator}%
        \iftoggle{abx@bool@moretranslator}
          {\csgappto\blx@bbl@data{%
             \toggletrue{abx@bool@morelabelname}}}
          {}}}
    {}}

\def\blx@bbl@titles{%
  \ifundef\abx@field@shorttitle
    {\csgappto\blx@bbl@data{%
       \let\abx@field@labeltitle\abx@field@title}}
    {\csgappto\blx@bbl@data{%
       \let\abx@field@labeltitle\abx@field@shorttitle}}%
  \ifundef\abx@field@indextitle
    {\csgappto\blx@bbl@data{%
       \let\abx@field@indextitle\abx@field@title}}
    {}%
  \ifundef\abx@field@indexsorttitle
    {\csgappto\blx@bbl@data{%
       \let\abx@field@indexsorttitle\abx@field@indextitle}}
    {}}

\def\blx@bbl@hooks{%
  \ifcsundef{blx@hook@bblitem@*}
    {\ifcsundef{blx@hook@bblitem@\abx@field@entrytype}
       {}
       {\csuse\blx@bbl@data
        \csuse{blx@hook@bblitem@\abx@field@entrytype}}}
    {\csuse\blx@bbl@data
     \csuse{blx@hook@bblitem@*}%
     \csuse{blx@hook@bblitem@\abx@field@entrytype}}}

\newrobustcmd*{\AtDataInput}[1][*]{\csgappto{blx@hook@bblitem@#1}}
\@onlypreamble\AtDataInput

\def\blx@setlabwidth#1#2{%
  \begingroup
  \settowidth{\@tempdima}{\bibfont#2}%
  \ifnum\@tempdima>#1%
    \global#1\@tempdima
  \fi
  \endgroup}

\def\blx@bblstart{%
  \let\preamble\blx@bbl@preamble
  \let\warn\blx@bbl@warn
  \let\entry\blx@bbl@entry
  \let\endentry\blx@bbl@endentry
  \let\lossort\blx@bbl@lossort
  \let\endlossort\blx@bbl@endlossort
  \let\set\blx@bbl@set
  \let\inset\blx@bbl@inset
  \let\xref\blx@bbl@xref
  \let\keyw\blx@bbl@keyw
  \let\name\blx@bbl@namedef
  \let\list\blx@bbl@listdef
  \let\field\blx@bbl@fielddef
  \let\strng\blx@bbl@stringdef
  \let\count\blx@bbl@countdef
  \let\true\blx@bbl@booltrue
  \let\false\blx@bbl@boolfalse
  \let\verb\blx@bbl@verbdef
  \let\endverb\blx@bbl@verbend}

\def\blx@bblend{%
  \ifcsdef{blx@refs@\the\c@refsection}
    {\begingroup
     \let\do\blx@addxref
     \dolistcsloop{blx@refs@\the\c@refsection}%
     \endgroup
     \global\csundef{blx@refs@\the\c@refsection}}
    {}%
  \iftoggle{blx@addset}
    {\blx@addset
     \global\togglefalse{blx@addset}}
    {}}

% {<instcount>}{<entrykey>}{<refsection>}{<labelnumber>}

\protected\def\blx@aux@number#1#2#3#4{%
  \begingroup
  \edef\blx@bbl@data{blx@data@#3@\detokenize{#2}}%
  \blx@bbl@fielddef{localnumber}{#4}%
  \csgdef{blx@labelnumber@\the\c@refsection}{#4}%
  \blx@addchecksum{\the\numexpr#1+#4}%
  \endgroup}

\AtEndDocument{%
  \def\abx@aux@number#1#2#3#4{\blx@addchecksum{\the\numexpr#1+#4}}}

\def\blx@addlabelnumber{%
  \iftoggle{blx@skiplab}
    {}
    {\begingroup
     \ifundef\abx@field@shorthand
       {\ifundef\abx@field@localnumber
          {\csnumgdef{blx@labelnumber@\the\c@refsection}{%
             \csuse{blx@labelnumber@\the\c@refsection}+1}%
           \blx@auxwrite\@mainaux{%
             \string\abx@aux@number{\the\c@instcount}{\abx@field@entrykey}%
               {\the\c@refsection}{\csuse{blx@labelnumber@\the\c@refsection}}}%
           \edef\blx@bbl@data{blx@data@\the\c@refsection @\abx@field@entrykey}%
           \blx@bbl@fieldedef{localnumber}{\csuse{blx@labelnumber@\the\c@refsection}}}
          {}}
       {}%
     \endgroup}}

\def\blx@bbl@lossort{%
  \begingroup
  \def\key##1{\listcsxadd{blx@losh@\the\c@refsection}{\detokenize{##1}}}}
\let\blx@bbl@endlossort\endgroup

\def\blx@addpageref#1{%
  \begingroup
  \@tempcnta\z@
  \let\blx@tempa\@empty
  \def\do##1{%
    \appto\blx@tempa{{##1}}%
    \advance\@tempcnta\@ne}%
  \dolistcsloop{blx@pref@\the\c@refsection @#1}%
  \edef\blx@tempa{\endgroup\noexpand\blx@bbl@listdef
    {pageref}{\the\@tempcnta}{\blx@tempa}}%
  \blx@tempa}

%% Data input

\def\blx@bblinput{%
  \begingroup
  \iftoggle{blx@recode}
    {\ifdef\inpenc@prehook % inputenc 2006/05/05 v1.1b
       {\inpenc@prehook{}%
	\inpenc@posthook{}}
       {}%
     \inputencoding\blx@bibencoding}
    {}%
  \blx@info@noline{Trying to load bibliographic data..}%
  \blx@blxinit
  \blx@bblfile
  \blx@bblsecs
  \endgroup}

\def\blx@bblfile{%
  \blx@secinit
  \begingroup
  \blx@bblstart
  \ifnum\c@refsection>\z@
    \edef\blx@auxfile{\jobname\the\c@refsection\blxauxsuffix}%
  \else
    \edef\blx@auxfile{\jobname}%
  \fi
  \blx@ifsigned{\blx@auxfile}{bbl}
    {\InputIfFileExists{\blx@auxfile.bbl}
       {\blx@info@noline{... file '\blx@auxfile.bbl' found}}
       {\blx@info@noline{... file '\blx@auxfile.bbl' not found}%
        \typeout{No file \blx@auxfile.bbl.}}}
    {}%
  \blx@bblend
  \endgroup
  \csnumgdef{blx@labelnumber@\the\c@refsection}{0}%
  \iftoggle{blx@recode}{\blx@recode}{}}

\def\blx@bblsecs{%
  \advance\c@refsection\@ne
  \ifnum\c@refsection>\blx@maxsection
  \else
    \blx@bblfile
    \expandafter\blx@bblsecs
  \fi}

\def\blx@recode{%
  \begingroup
  \let\protect\@unexpandable@protect
  \def\IeC##1{\unexpanded{##1}}%
  \let~\relax
  \def\do##1{\cslet{abx@name@##1}\relax}%
  \abx@donames
  \def\do##1{\cslet{abx@list@##1}\relax}%
  \abx@dolists
  \def\do##1{\cslet{abx@field@##1}\relax}%
  \abx@dofields\do{options}%
  \long\def\abx@field@execute##1{%
    \unexpanded{\abx@field@execute{##1}}}%
  \csuse{abx@preamble}%
  \def\do##1{%
    \csxdef{blx@data@\the\c@refsection @##1}{%
      \csuse{blx@data@\the\c@refsection @##1}}}%
  \dolistcsloop{blx@sort@\the\c@refsection}%
  \endgroup}

%% Bibliography

% {<name>}{<code>}

\newrobustcmd*{\defbibheading}[1]{%
  \long\csdef{blx@head@#1}}

% {<name>}{<text>}

\newrobustcmd*{\defbibnote}[1]{%
  \long\csdef{blx@note@#1}}

% {<name>}{<code>}

\newrobustcmd*{\defbibfilter}[2]{%
  \ifblank{#2}
    {\blx@error
       {Invalid filter}
       {The specified filter code is invalid}}
    {\long\csdef{blx@filter@#1}{#2}}}

% options

\define@key{blx@bib}{section}{%
  \ifcsundef{blx@cite@#1}
    {\blx@error
       {Section '#1' not found}
       {The reference section '#1' could not be found}}
    {\c@refsection#1\relax
     \iftoggle{blx@tempa}
       {\letcs\blx@tempa{blx@cite@\the\c@refsection}}
       {\blx@error
          {'section' not first filter}
          {When passing multiple filter options to
           \string\printbibliography,\MessageBreak
           the 'section' filter must be given first}}}}
\define@key{blx@los}{section}{\blx@key@section{#1}}
\define@key{blx@bbg}{section}{\blx@key@section{#1}}
\define@key{blx@bbc}{section}{\blx@key@section{#1}}
\def\blx@key@section#1{%
  \ifcsundef{blx@cite@#1}
    {\blx@error
       {Section '#1' not found}
       {The reference section '#1' could not be found}}
    {\c@refsection#1\relax}}

\define@key{blx@bib}{segment}{%
  \ifcsundef{blx@segm@\the\c@refsection @#1}
    {\blx@error
       {Segment '#1' not found}
       {The reference segment '#1' could not be found}}
    {\c@refsegment#1\relax
     \blx@printbibchecks
     \blx@filter\blx@tempa{blx@segm@\the\c@refsection @#1}}}

\define@key{blx@bib}{type}{%
  \ifcsundef{blx@type@\the\c@refsection @#1}
    {\blx@warning{%
       Entry type '#1' not found.\MessageBreak
       Skipping this type filter}}
    {\blx@printbibchecks
     \iftoggle{blx@tempb}
       {\togglefalse{blx@tempb}%
        \blx@filter\blx@tempa{blx@type@\the\c@refsection @#1}}
       {\blx@error
          {'type' used multiple times}
          {When passing multiple filter options to
           \string\printbibliography,\MessageBreak each entry in the
           bibliography must satisfy all conditions\MessageBreak
           (AND conjunction), hence some options may not be
           used\MessageBreak twice. Use 'filter' and
           '\string\defbibfilter' with OR conjunctions}}}}

\define@key{blx@bib}{nottype}{%
  \ifcsundef{blx@type@\the\c@refsection @#1}
    {}
    {\blx@printbibchecks
     \blx@notfilter\blx@tempa{blx@type@\the\c@refsection @#1}}}

\define@key{blx@bib}{keyword}{%
  \edef\@tempa{\detokenize{#1}}%
  \ifcsundef{blx@keyw@\the\c@refsection @\@tempa}
    {\blx@warning{%
       Keyword '\@tempa' not found.\MessageBreak
       Skipping this keyword filter}}
    {\blx@printbibchecks
     \blx@filter\blx@tempa{blx@keyw@\the\c@refsection @\@tempa}}}

\define@key{blx@bib}{notkeyword}{%
  \edef\@tempa{\detokenize{#1}}%
  \ifcsundef{blx@keyw@\the\c@refsection @\@tempa}
    {}
    {\blx@printbibchecks
     \blx@notfilter\blx@tempa{blx@keyw@\the\c@refsection @\@tempa}}}

\define@key{blx@bib}{category}{%
  \ifcsundef{blx@catg@#1}
    {\blx@warning{%
       Category '#1' not found.\MessageBreak
       Skipping this category filter}}
    {\blx@printbibchecks
     \blx@filter\blx@tempa{blx@catg@#1}}}

\define@key{blx@bib}{notcategory}{%
  \ifcsundef{blx@catg@#1}
    {}
    {\blx@printbibchecks
     \blx@notfilter\blx@tempa{blx@catg@#1}}}

\define@key{blx@bib}{filter}{%
  \ifcsundef{blx@filter@#1}
    {\blx@warning{%
       Custom filter '#1' not found.\MessageBreak
       Skipping this custom filter}}
    {\blx@printbibchecks
     \blx@bibfilter\blx@tempa{blx@filter@#1}}}

\def\blx@printbibchecks{%
  \togglefalse{blx@tempa}%
  \iftoggle{blx@defernums}
    {\global\let\blx@printbibchecks\relax}
    {\iftoggle{blx@labelnumber}
       {\blx@warning{Setting 'defernums=true' recommended}}
       {\global\let\blx@printbibchecks\relax}}}

\define@key{blx@bib}{maxnames}{\blx@key@maxnames{#1}}
\define@key{blx@los}{maxnames}{\blx@key@maxnames{#1}}
\define@key{blx@bbs}{maxnames}{\blx@key@maxnames{#1}}
\define@key{blx@bbg}{maxnames}{\blx@key@maxnames{#1}}
\define@key{blx@bbc}{maxnames}{\blx@key@maxnames{#1}}
\def\blx@key@maxnames#1{%
  \ifnum#1<\c@maxnames
    \blx@error
      {'maxnames=#1' invalid}
      {The value may not be smaller than the global setting}%
  \else
    \c@maxnames#1\relax
  \fi}

\define@key{blx@bib}{minnames}{\blx@key@minnames{#1}}
\define@key{blx@los}{minnames}{\blx@key@minnames{#1}}
\define@key{blx@bbs}{minnames}{\blx@key@minnames{#1}}
\define@key{blx@bbg}{minnames}{\blx@key@minnames{#1}}
\define@key{blx@bbc}{minnames}{\blx@key@minnames{#1}}
\def\blx@key@minnames#1{%
  \ifnum#1<\c@minnames
    \blx@error
      {'minnames=#1' invalid}
      {The value may not be smaller than the global setting}%
  \else
    \c@minnames#1\relax
  \fi}

\define@key{blx@bib}{maxitems}{\c@maxitems#1\relax}
\define@key{blx@los}{maxitems}{\c@maxitems#1\relax}
\define@key{blx@bbs}{maxitems}{\c@maxitems#1\relax}
\define@key{blx@bbg}{maxitems}{\c@maxitems#1\relax}
\define@key{blx@bbc}{maxitems}{\c@maxitems#1\relax}

\define@key{blx@bib}{minitems}{\c@minitems#1\relax}
\define@key{blx@los}{minitems}{\c@minitems#1\relax}
\define@key{blx@bbs}{minitems}{\c@minitems#1\relax}
\define@key{blx@bbg}{minitems}{\c@minitems#1\relax}
\define@key{blx@bbc}{minitems}{\c@minitems#1\relax}

\define@key{blx@bib}{heading}{\blx@key@heading{#1}}
\define@key{blx@los}{heading}{\blx@key@heading{#1}}
\define@key{blx@bbs}{heading}{\blx@key@heading{#1}}
\define@key{blx@bbg}{heading}{\blx@key@heading{#1}}
\def\blx@key@heading#1{%
  \ifcsundef{blx@head@#1}
     {\blx@error
        {Heading '#1' undefined}
        {Use \string\defbibheading\space to define it}}
     {\def\blx@tempb{#1}}}

\define@key{blx@bib}{prenote}{\blx@key@prenote{#1}}
\define@key{blx@los}{prenote}{\blx@key@prenote{#1}}
\define@key{blx@bbs}{prenote}{\blx@key@prenote{#1}}
\define@key{blx@bbg}{prenote}{\blx@key@prenote{#1}}
\define@key{blx@bbc}{prenote}{\blx@key@prenote{#1}}
\def\blx@key@prenote#1{%
  \ifcsundef{blx@note@#1}
     {\blx@error
        {Note '#1' undefined}
        {Use \string\defbibnote\space to define it}}
     {\def\blx@tempc{#1}}}

\define@key{blx@bib}{postnote}{\blx@key@postnote{#1}}
\define@key{blx@los}{postnote}{\blx@key@postnote{#1}}
\define@key{blx@bbs}{postnote}{\blx@key@postnote{#1}}
\define@key{blx@bbg}{postnote}{\blx@key@postnote{#1}}
\define@key{blx@bbc}{postnote}{\blx@key@postnote{#1}}
\def\blx@key@postnote#1{%
  \ifcsundef{blx@note@#1}
     {\blx@error
        {Note '#1' undefined}
        {Use \string\defbibnote\space to define it}}
     {\def\blx@tempd{#1}}}

% [<options>]

\newrobustcmd*{\printbibliography}{%
  \begingroup
  \edef\on@line{\on@line}%
  \@ifnextchar[%]
    {\blx@printbibliography}
    {\blx@printbibliography[]}}

\def\blx@printbibliography[#1]{%
  \toggletrue{blx@tempa}%
  \toggletrue{blx@tempb}%
  \letcs\blx@tempa{blx@cite@\the\c@refsection}%
  \def\blx@tempb{bibliography}%
  \let\blx@tempc\@empty
  \let\blx@tempd\@empty
  \blx@safe@actives
  \setkeys{blx@bib}{#1}%
  \blx@rest@actives
  \blx@bibliography\blx@tempa}

% [<options>]

\newrobustcmd*{\bibbysection}{%
  \begingroup
  \ifnum\blx@maxsection=\z@
    \blx@warning{No reference sections found}%
  \fi
  \edef\on@line{\on@line}%
  \@ifnextchar[%]
    {\blx@bibbysection}
    {\blx@bibbysection[]}}

\def\blx@bibbysection[#1]{%
  \def\blx@tempb{bibliography}%
  \let\blx@tempc\@empty
  \let\blx@tempd\@empty
  \c@refsection\@ne
  \blx@safe@actives
  \setkeys{blx@bbs}{#1}%
  \blx@rest@actives
  \togglefalse{blx@tempa}%
  \blx@refsections}

\def\blx@refsections{%
  \ifcsvoid{blx@cite@\the\c@refsection}
    {}
    {\toggletrue{blx@tempa}%
     \begingroup
     \expandafter\blx@bibliography\csname blx@cite@\the\c@refsection\endcsname}%
  \ifnum\c@refsection<\blx@maxsection
    \advance\c@refsection\@ne
    \expandafter\blx@refsections
  \else
    \iftoggle{blx@tempa}{}{\blx@warn@bibempty}%
    \endgroup
  \fi}

% [<options>]

\newrobustcmd*{\bibbysegment}{%
  \begingroup
  \edef\on@line{\on@line}%
  \ifnum\blx@maxsegment=\z@
    \blx@warning{No reference segments found}%
  \fi
  \@ifnextchar[%]
    {\blx@bibbysegment}
    {\blx@bibbysegment[]}}

\def\blx@bibbysegment[#1]{%
  \def\blx@tempb{bibliography}%
  \let\blx@tempc\@empty
  \let\blx@tempd\@empty
  \c@refsection\z@
  \c@refsegment\@ne
  \blx@safe@actives
  \setkeys{blx@bbg}{#1}%
  \blx@rest@actives
  \togglefalse{blx@tempa}%
  \blx@refsegments}

\def\blx@refsegments{%
  \ifcsvoid{blx@segm@\the\c@refsection @\the\c@refsegment}
    {}
    {\toggletrue{blx@tempa}%
     \begingroup
     \letcs\blx@tempa{blx@cite@\the\c@refsection}%
     \blx@filter\blx@tempa{blx@segm@\the\c@refsection @\the\c@refsegment}%
     \blx@bibliography\blx@tempa}%
  \ifnum\c@refsegment<\blx@maxsegment
    \advance\c@refsegment\@ne
    \expandafter\blx@refsegments
  \else
    \iftoggle{blx@tempa}{}{\blx@warn@bibempty}%
    \endgroup
  \fi}

% [<options>]

\newrobustcmd*{\bibbycategory}{%
  \begingroup
  \edef\on@line{\on@line}%
  \ifx\blx@categories\@empty
    \blx@warning{No categories found}%
  \fi
  \@ifnextchar[%]
    {\blx@bibbycategory}
    {\blx@bibbycategory[]}}

\def\blx@bibbycategory[#1]{%
  \def\blx@tempb{bibliography}%
  \let\blx@tempc\@empty
  \let\blx@tempd\@empty
  \c@refsection\z@
  \blx@safe@actives
  \setkeys{blx@bbc}{#1}%
  \blx@rest@actives
  \togglefalse{blx@tempa}%
  \let\do\blx@bibcategory
  \dolistloop\blx@categories
  \blx@endbibcategory}

\def\blx@bibcategory#1{%
  \ifcsvoid{blx@catg@#1}
    {}
    {\toggletrue{blx@tempa}%
     \begingroup
     \blx@key@heading{#1}%
     \letcs\blx@tempa{blx@cite@\the\c@refsection}%
     \blx@filter\blx@tempa{blx@catg@#1}%
     \blx@bibliography\blx@tempa}}%

\def\blx@endbibcategory{%
  \iftoggle{blx@tempa}{}{\blx@warn@bibempty}%
  \endgroup}

% {<entrykey>,...}

\def\blx@bibliography{%
  \blx@bibheading\blx@tempb
  \blx@bibnote\blx@tempc
  \begingroup
  \blx@bibinit
  \let\@noitemerr\@empty
  \let\blx@noitem\blx@warn@bibempty
  \ifnum\bibinitsep=\z@
    \let\blx@initsep\relax
  \fi
  \ifnum\bibnamesep=\z@
    \let\blx@namesep\relax
  \fi
  \thebibliography\relax
  \csuse{blx@hook@bibinit}%
  \let\blx@do\blx@bibitem
  \let\blx@done\blx@endbibliography
  \blx@listloop}

\def\blx@endbibliography{%
  \endthebibliography
  \par\nobreak
  \blx@noitem
  \endgroup
  \blx@bibnote\blx@tempd
  \endgroup}

\def\blx@bibheading#1{%
  \let\newrefsection\relax
  \let\newrefsegment\relax
  \csuse{blx@head@#1}%
  \let\newrefsection\blx@newrefsection
  \let\newrefsegment\blx@newrefsegment}

\def\blx@bibnote#1{%
  \ifx#1\@empty
  \else
    \begingroup
    \let\newrefsection\relax
    \let\newrefsegment\relax
    \noindent
    \csuse{blx@note@#1}\par\nobreak
    \endgroup
  \fi}

\def\blx@bibinit{%
  \iftoggle{blx@citation}
    {}
    {\toggletrue{blx@bibliography}%
     \settoggle{blx@index}{\iftoggle{blx@bibindex}{true}{false}}}%
  \blx@blxinit
  \csuse{blx@hook@bbxinit}%
  \bibsetup\bibfont
  \blx@setsfcodes
  \aftergroup\blx@postpunct
  \csuse{blx@bibsetup}}

% {<entrykey>}

\def\blx@bibitem#1{%
  \blx@ifdata{#1}
    {\let\blx@noitem\@empty
     \begingroup
     \blx@getdata{#1}%
     \ifcsundef{blx@bbx@\abx@field@entrytype}
       {\blx@warning{%
          No driver for entry type
          '\abx@field@entrytype'.\MessageBreak
          Skipping entry '\abx@field@entrykey'}}
       {\blx@options
        \blx@thelabelnumber
        \addtocounter{instcount}\@ne
        \thebibitem\relax
        \blx@initsep
        \blx@namesep
        \csuse{blx@hook@bibitem}%
        \blx@execute
        \blx@initunit
        \blx@anchor
        \blx@begbabel
        \bibsentence
        \blx@pagetracker
        \blx@driver{\abx@field@entrytype}%
        \blx@endbabel}%
     \endgroup}
    {}}

\def\blx@initsep{%
  \ifnum\c@instcount>\@ne
    \blx@imc@iffieldequals{sortinit}\blx@previnit
      {}
      {\addvspace{\bibinitsep}}%
  \fi
  \global\let\blx@previnit\abx@field@sortinit}

\def\blx@namesep{%
  \ifnum\c@instcount>\@ne
    \blx@imc@iffieldequals{fullhash}\blx@prevhash
      {}
      {\addvspace{\bibnamesep}}%
  \fi
  \global\let\blx@prevhash\abx@field@fullhash}

\providecommand*{\thebibliography}{}
\renewenvironment*{thebibliography}
  {\list{}{%
     \leftmargin\bibhang
     \itemindent-\leftmargin
     \itemsep\bibitemsep
     \parsep\bibparsep}}
  {\endlist}
\newcommand*{\thebibitem}{\item}
\newrobustcmd*{\AtBeginBibliography}{\gappto\blx@hook@bibinit}
\newrobustcmd*{\AtEveryBibitem}{\gappto\blx@hook@bibitem}
\@onlypreamble\AtBeginBibliography
\@onlypreamble\AtEveryBibitem

% page tracker

\def\blx@pagetracker@context{%
  \blx@leavevmode
  \ifbool{@filesw}
    {\ifbool{pagetracker}
       {\protected@write\@mainaux{}{%
          \iftoggle{blx@footnote}
            {\string\abx@aux@fnpage}
            {\string\abx@aux@page}%
          {\the\c@instcount}{\noexpand\the\c@page}}}
       {}}
    {}}

% {<instcount>}{<page>}

\protected\def\blx@aux@page#1#2{%
  \csgdef{blx@page@#1}{#2}%
  \blx@addchecksum{\the\numexpr#1+0#2}}
\protected\def\blx@aux@spread#1#2{%
  \ifodd#2\relax
    \csxdef{blx@page@#1}{\number\numexpr#2-1}%
  \else
    \csgdef{blx@page@#1}{#2}%
  \fi
  \blx@addchecksum{\the\numexpr#1+0#2}}

\protected\def\blx@aux@fnpage#1#2{%
  \csgdef{blx@fnpage@#1}{#2}%
  \blx@addchecksum{\the\numexpr#1+0#2}}
\protected\def\blx@aux@fnspread#1#2{%
  \ifodd#2\relax
    \csxdef{blx@fnpage@#1}{\number\numexpr#2-1}%
  \else
    \csgdef{blx@fnpage@#1}{#2}%
  \fi
  \blx@addchecksum{\the\numexpr#1+0#2}}

\AtEndDocument{%
  \def\abx@aux@page#1#2{\blx@addchecksum{\the\numexpr#1+0#2}}%
  \def\abx@aux@fnpage#1#2{\blx@addchecksum{\the\numexpr#1+0#2}}}

% hyperref interface

\appto\blx@mkhyperref{%
  \let\blx@anchors\@empty
  \ifundef\hyper@natanchorstart
    {\protected\def\blx@anchor{%
       \xifinlist{\the\c@refsection @\abx@field@entrykey}{\blx@anchors}
	 {}
	 {\listxadd\blx@anchors{\the\c@refsection @\abx@field@entrykey}%
	  \hypertarget{cite.\the\c@refsection @\abx@field@entrykey}{}}}}
    {\protected\def\blx@anchor{%
       \xifinlist{\the\c@refsection @\abx@field@entrykey}{\blx@anchors}
	 {}
	 {\listxadd\blx@anchors{\the\c@refsection @\abx@field@entrykey}%
	  \hyper@natanchorstart{\the\c@refsection @\abx@field@entrykey}%
	  \hyper@natanchorend}}}}

\appto\blx@mknohyperref{\let\blx@anchor\relax}

% List of shorthands

\newrobustcmd*{\printshorthands}{%
  \begingroup
  \edef\on@line{\on@line}%
  \@ifnextchar[%]
    {\blx@printshorthands}
    {\blx@printshorthands[]}}

\def\blx@printshorthands[#1]{%
  \def\blx@tempb{shorthands}%
  \let\blx@tempc\@empty
  \let\blx@tempd\@empty
  \blx@safe@actives
  \setkeys{blx@los}{#1}%
  \blx@rest@actives
  \ifcsundef{blx@losh@\the\c@refsection}
    {\blx@warn@losempty\endgroup}
    {\expandafter\blx@shorthands
     \csname blx@losh@\the\c@refsection\endcsname}}

% {<entrykey>,...}

\def\blx@shorthands{%
  \if@twocolumn
    \@restonecoltrue\onecolumn
  \else
    \@restonecolfalse
  \fi
  \blx@bibheading\blx@tempb
  \blx@bibnote\blx@tempc
  \begingroup
  \blx@bibinit
  \let\@noitemerr\@empty
  \let\blx@noitem\blx@warn@losempty
  \theshorthands\relax
  \csuse{blx@hook@losinit}%
  \let\blx@do\blx@lositem
  \let\blx@done\blx@endshorthands
  \blx@listloop}

\def\blx@endshorthands{%
  \endtheshorthands
  \par\nobreak
  \blx@noitem
  \endgroup
  \blx@bibnote\blx@tempd
  \endgroup
  \if@restonecol\twocolumn\fi}

\newcommand*{\thelositem}{\item}
\newenvironment*{theshorthands}
  {\list{\thefield{shorthand}}{%
     \labelwidth\shorthandwidth
     \labelsep\biblabelsep
     \leftmargin\labelwidth
     \advance\leftmargin\labelsep
     \itemsep\bibitemsep
     \parsep\bibparsep
     \def\makelabel##1{##1\hss}}}
  {\endlist}
\newrobustcmd*{\AtBeginShorthands}{\gappto\blx@hook@losinit}
\newrobustcmd*{\AtEveryLositem}{\gappto\blx@hook@lositem}
\@onlypreamble\AtBeginShorthands
\@onlypreamble\AtEveryLositem

% {<entrykey>}

\def\blx@lositem#1{%
  \blx@ifdata{#1}
    {\let\blx@noitem\@empty
     \begingroup
     \blx@getdata{#1}%
     \blx@options
     \addtocounter{instcount}\@ne
     \thelositem\relax
     \csuse{blx@hook@lositem}%
     \blx@execute
     \blx@initunit
     \blx@begbabel
     \bibsentence
     \blx@pagetracker
     \blx@driver{shorthands}%
     \blx@endbabel
     \endgroup}
    {}}

\DeclareBibliographyDriver{shorthands}{%
  \iffieldundef{shorttitle}
    {\printfield{title}}
    {\printfield{shorttitle}}}

% Reference sections

\newrobustcmd*{\newrefsection}{%
  \ifnum\c@refsection>\z@
    \blx@endrefsection
  \fi
  \refsection}
\let\blx@newrefsection\newrefsection

\newrobustcmd*{\refsection}{%
  \begingroup
  \edef\on@line{\on@line}%
  \ifnum\c@refsection>\z@
    \blx@err@nestenv{refsection}%
    \blx@endrefsection
  \fi
  \ifnum\c@refsegment>\z@
    \blx@err@nestenv{refsection}%
    \blx@endrefsegment
  \fi
  \@ifnextchar[%]
    {\blx@refsection}
    {\blx@refsection[\blx@bibfiles]}}

\def\blx@refsection[#1]{%
  \global\advance\blx@maxsection\@ne
  \global\c@refsection\blx@maxsection
  \blx@inf@refsec
  \blx@secinit
  \if@filesw
    \blx@auxwrite\@mainaux{%
      \string\abx@aux@refsection{\the\c@refsection}}%
    \xdef\blx@auxfile{\jobname\the\c@refsection\blxauxsuffix}%
    \blx@ifsigned{\blx@auxfile}{aux}
      {\immediate\openout\blx@auxout \blx@auxfile.aux\relax
       \global\let\blx@theauxout\blx@auxout
       \blx@auxinit{#1}}
      {}%
  \fi
  \blx@info{Setting label 'refsection:\the\c@refsection'}%
  \label{refsection:\the\c@refsection}%
  \endgroup}

\protected\def\endrefsection{%
  \blx@endrefsection
  \blx@inf@refsec}

\def\blx@endrefsection{%
  \blx@endrefsegment
  \ifx\blx@theauxout\blx@auxout
    \immediate\closeout\blx@auxout
  \fi
  \global\let\blx@theauxout\@mainaux
  \xdef\blx@auxfile{\jobname}%
  \ifnum\c@refsection>\z@
    \global\c@refsection\z@
  \fi}

\AtEndDocument{%
  \blx@endrefsection
  \def\abx@aux@refsection#1{\blx@addchecksum{[#1]}}}

\protected\def\abx@aux@refsection#1{%
  \ifnum#1>\blx@maxsection
    \global\blx@maxsection#1\relax
  \fi
  \blx@addchecksum{[#1]}}

% Reference segments

\newrobustcmd*{\newrefsegment}{%
  \ifnum\c@refsegment>\z@
    \blx@endrefsegment
  \fi
  \refsegment}
\let\blx@newrefsegment\newrefsegment

\newrobustcmd*{\refsegment}{%
  \ifnum\c@refsegment>\z@
    \blx@err@nestenv{refsegment}%
    \blx@endrefsegment
  \fi
  \global\advance\blx@maxsegment\@ne
  \global\c@refsegment\blx@maxsegment
  \blx@inf@refseg
  \blx@info{Setting label 'refsegment:\the\c@refsegment'}%
  \label{refsegment:\the\c@refsegment}%
  \ifcsundef{blx@segm@\the\c@refsection @\the\c@refsegment}
    {\global\cslet{blx@segm@\the\c@refsection @\the\c@refsegment}\@empty}
    {}}

\protected\def\endrefsegment{%
  \blx@endrefsegment
  \blx@inf@refseg}

\def\blx@endrefsegment{%
  \global\c@refsegment\z@}

% Bibliography categories

\let\blx@categories\@empty

% {<category>}

\newrobustcmd*{\DeclareBibliographyCategory}[1]{%
  \ifcsundef{blx@catg@#1}
    {\global\cslet{blx@catg@#1}\@empty
     \listgadd{\blx@categories}{#1}}
    {\blx@error
       {Category '#1' already declared}
       {The bibliography category '#1'\MessageBreak
        has already been declared}}}
\@onlypreamble\DeclareBibliographyCategory

% {<category>}{<entrykey>,...}

\newrobustcmd*{\addtocategory}[2]{%
  \ifcsundef{blx@catg@#1}
    {\blx@error
       {Category '#1' not declared}
       {Use \string\DeclareBibliographyCategory\space to declare}}
    {\AfterPreamble{%
       \def\do{\blx@addtocategory{#1}}%
       \blx@sanitizekeys\docsvlist{#2}%
       \let\do\noexpand}}}

% {<category>}{<entrykey>,...}

\def\blx@addtocategory#1#2{%
  \blx@auxwrite\@mainaux{\string\abx@aux@category{#1}{#2}}%
  \abx@aux@category{#1}{#2}}

% {<category>}{<entrykey>,...}

\protected\def\abx@aux@category#1#2{%
  \xifinlistcs{\detokenize{#2}}{blx@catg@#1}
    {}
    {\listcsxadd{blx@catg@#1}{\detokenize{#2}}}}

\AtEndDocument{\let\abx@aux@category\@gobbletwo}

%% Legacy commands

\renewrobustcmd*{\bibliography}[1]{%
  \ifx\blx@bibfiles\@empty
    \gdef\blx@bibfiles{#1}%
  \else
    \gappto\blx@bibfiles{,#1}%
  \fi}
\let\blx@bibfiles\@empty

\AtBeginDocument{%
  \def\bibliography#1{%
    \blx@warning
      {'\string\bibliography' must be given in
       preamble.\MessageBreak Ignoring command}}}

\renewrobustcmd*{\bibliographystyle}[1]{%
  \blx@warning
    {'\string\bibliographystyle' not supported.\MessageBreak
     Use the 'bibstyle' package option.\MessageBreak
     Ignoring command}}

%% Citations

\newrobustcmd*{\AtEveryCite}{\gappto\blx@hook@cite}
\newrobustcmd*{\AtEveryCitekey}{\gappto\blx@hook@citekey}
\@onlypreamble\AtEveryCite
\@onlypreamble\AtEveryCitekey

\newrobustcmd*{\AtNextCite}{%
  \ifundef\blx@hook@cite@next
    {\gdef\blx@hook@cite@next{\global\undef\blx@hook@cite@next}}
    {}%
  \gappto\blx@hook@cite@next}

\newrobustcmd*{\AtNextCitekey}{%
  \ifundef\blx@hook@citekey@next
    {\gdef\blx@hook@citekey@next{\global\undef\blx@hook@citekey@next}}
    {}%
  \gappto\blx@hook@citekey@next}

% {<style>]

\newrobustcmd*{\RequireCitationStyle}[1]{%
  \blx@inputonce{#1.cbx}{citation style '#1'}{}{}{}
    {\blx@error
       {Style '#1' not found}
       {The citation style '#1' could not be found}}}
\@onlypreamble\RequireCitationStyle

% {<code>}

\newrobustcmd*{\InitializeCitationStyle}{\appto\blx@hook@cbxinit}
\@onlypreamble\InitializeCitationStyle

% {<code>}

\newrobustcmd*{\OnManualCitation}{\appto\blx@hook@mancite}
\@onlypreamble\OnManualCitation

\newrobustcmd*{\mancite}{%
  \csuse{blx@hook@mancite}%
  \blx@ibidreset
  \blx@idemreset
  \blx@opcitreset
  \blx@loccitreset}

% {<entrykey>}{<message>}

\def\blx@citation#1#2{%
  \ifbool{citerequest}
    {\ifcsdef{blx@setp@\the\c@refsection @#1}
       {\blx@citation@set{#1}{#2}}
       {\ifcsdef{blx@setc@\the\c@refsection @#1}
	  {\blx@citation@inset{#1}{#2}}
	  {\blx@citation@entry{#1}{#2}}}%
     \ifcsdef{blx@refc@\the\c@refsection @#1}
       {\blx@citation@xref{#1}}
       {}}
    {}}

\def\blx@citation@entry#1#2{%
  \blx@bibreq{#1}%
  \ifinlistcs{#1}{blx@segm@\the\c@refsection @\the\c@refsegment}
    {}
    {\listcsgadd{blx@segm@\the\c@refsection @\the\c@refsegment}{#1}}%
  \blx@ifdata{#1}
    {}
    {\blx@logreq{#2{#1}}}}

\def\blx@citation@set#1#2{%
  \blx@citation@entry{#1}{#2}%
  \begingroup
  \def\do##1{\blx@citation@entry{##1}\blx@msg@cundef}%
  \expandafter\expandafter\expandafter\docsvlist
  \expandafter\expandafter\expandafter{%
    \csname blx@setp@\the\c@refsection @#1\endcsname}%
  \endgroup}

\def\blx@citation@inset#1#2{%
  \blx@citation@entry{#1}{#2}%
  \expandafter\expandafter\expandafter\blx@citation@inset@i
  \expandafter\expandafter\expandafter{%
    \csname blx@setc@\the\c@refsection @#1\endcsname}\blx@msg@cundef}

\def\blx@citation@inset@i#1{%
  \ifcsdef{blx@setp@\the\c@refsection @#1}
    {\blx@citation@set{#1}}
    {\blx@citation@entry{#1}}}

\def\blx@citation@xref#1{%
  \begingroup
  \edef\blx@tempa{blx@refp@\the\c@refsection @%
          \csname blx@refc@\the\c@refsection @#1\endcsname}%
  \ifcsdef\blx@tempa
    {\ifinlistcs{#1}\blx@tempa
       {}
       {\listcsxadd\blx@tempa{#1}}%
     \@tempcnta\z@
     \def\do##1{\advance\@tempcnta\@ne}%
     \dolistcsloop\blx@tempa}
    {\listcsxadd\blx@tempa{#1}%
     \@tempcnta\@ne}%
  \expandafter\endgroup\ifnum\@tempcnta<\blx@minxrefs\relax
  \else
    \expandafter\expandafter\expandafter\blx@citation@entry
    \expandafter\expandafter\expandafter{%
      \csname blx@refc@\the\c@refsection @#1\endcsname}\blx@msg@cundef
  \fi}

\def\blx@citation@all{%
  \ifbool{citerequest}
    {\blx@bibreq{*}%
     \global\csletcs
       {blx@segm@\the\c@refsection @\the\c@refsegment}
       {blx@cite@\the\c@refsection}%
     \ifcsvoid{blx@sort@\the\c@refsection}
       {\blx@logreq{}}
       {}}
    {}}

\def\blx@bibreq#1{%
  \blx@auxwrite\blx@theauxout{\string\citation{#1}}}

% {<entrykey>,...}

\protected\def\blx@citeloop#1{%
  \begingroup
  \@tempcnta\z@
  \@tempcntb\z@
  \let\blx@tempa\@empty
  \let\do\blx@citeadd
  \docsvlist{#1}%
  \blx@thenotecheck
  \ifnum\@tempcnta>\z@
    \ifnum\@tempcntb>\z@
      \multicitedelim
    \fi
  \fi
  \letcs\blx@tempb{blx@sort@\the\c@refsection}%
  \blx@thecitesort
  \edef\blx@tempa{\endgroup
    \c@citecount\z@
    \c@citetotal\the\@tempcnta\relax
    \unexpanded{\let\do\blx@citeprint\dolistloop}{\blx@tempb}}%
  \blx@tempa}

\def\blx@notecheck{%
  \ifnum\@tempcnta>\@ne
    \blx@warning{%
      Package option 'sortcites' enabled.\MessageBreak
      Verify postnote placement}%
  \fi}

\def\blx@citesort{%
  \ifnum\@tempcnta>\@ne
    \blx@filter\blx@tempb{blx@tempa}%
  \else
    \blx@citenosort
  \fi}

\def\blx@citenosort{%
  \let\blx@tempb\blx@tempa}

% {<entrykey>}

\def\blx@citeadd#1{%
  \blx@citation{#1}\blx@msg@cundefon
  \blx@ifdata{#1}
    {\advance\@tempcnta\@ne
     \listadd\blx@tempa{#1}}
    {\ifnum\@tempcntb>\z@\multicitedelim\fi
     \blx@missing{#1}%
     \advance\@tempcntb\@ne}}

% {<entrykey>}

\protected\def\blx@citeprint#1{%
  \advance\c@citecount\@ne
  \addtocounter{instcount}\@ne
  \ifnum\c@citecount=\@ne
    \blx@getdata@cite{#1}%
    \blx@precode
    \ifnum\c@citetotal>\@ne
      \blx@resetdata
    \fi
  \else
    \blx@dlimcode
  \fi
  \begingroup
  \ifnum\c@citetotal>\@ne
    \blx@getdata@cite{#1}%
  \fi
  \blx@entrysetcount
  \blx@options
  \blx@backref
  \blx@pagetracker
  \csuse{blx@hook@citekey}%
  \csuse{blx@hook@citekey@next}%
  \blx@execute
  \blx@loopcode
  \blx@citetracker
  \blx@ibidtracker
  \blx@idemtracker
  \blx@opcittracker
  \blx@loccittracker
  \ifnum\c@citecount=\c@citetotal
    \def\blx@thecheckpunct{\blx@err@nestcite\@gobble}%
    \blx@postcode
  \fi
  \endgroup}

% cite tracker

\def\blx@citetracker@global{%
  \ifbool{citetracker}
    {\xifinlistcs\abx@field@entrykey{blx@bsee@\the\c@refsection}
       {}
       {\listcsxadd{blx@bsee@\the\c@refsection}\abx@field@entrykey}}
    {}}

\def\blx@citetracker@context{%
  \ifbool{citetracker}
    {\iftoggle{blx@footnote}
       {\xifinlistcs\abx@field@entrykey{blx@fsee@\the\c@refsection}
          {}
          {\listcsxadd{blx@fsee@\the\c@refsection}\abx@field@entrykey}}
       {\xifinlistcs{\abx@field@entrykey}{blx@bsee@\the\c@refsection}
          {}
          {\listcsxadd{blx@bsee@\the\c@refsection}\abx@field@entrykey}}}
    {}}

% ibidem tracker

\def\blx@ibidtracker@gobal{%
  \ifbool{citetracker}
    {\global\let\blx@lastkey@text\abx@field@entrykey}
    {}}

\def\blx@ibidtracker@context{%
  \ifbool{citetracker}
    {\iftoggle{blx@footnote}
       {\global\let\blx@lastkey@foot\abx@field@entrykey}
       {\global\let\blx@lastkey@text\abx@field@entrykey}}
    {}}

\def\blx@ibidtracker@strict{%
  \blx@ifcitesingle
    {\blx@ibidtracker@gobal}
    {\blx@ibidreset@gobal}}%

\def\blx@ibidtracker@constrict{%
  \blx@ifcitesingle
    {\blx@mpfnsave
     \blx@ibidtracker@context}
    {\blx@ibidreset@context}}%

\def\blx@ibidreset@force{%
  \global\undef\blx@lastkey@text
  \global\undef\blx@lastkey@foot
  \blx@mpfnreset}

\def\blx@ibidreset@gobal{%
  \global\undef\blx@lastkey@text}

\def\blx@ibidreset@context{%
  \iftoggle{blx@footnote}
    {\blx@mpfnreset
     \global\undef\blx@lastkey@foot}
    {\global\undef\blx@lastkey@text}}

% idem tracker

\def\blx@idemtracker@gobal{%
  \ifbool{citetracker}
    {\global\let\blx@lasthash@text\abx@field@fullhash}
    {}}

\def\blx@idemtracker@context{%
  \ifbool{citetracker}
    {\iftoggle{blx@footnote}
       {\global\let\blx@lasthash@foot\abx@field@fullhash}
       {\global\let\blx@lasthash@text\abx@field@fullhash}}
    {}}

\def\blx@idemtracker@strict{%
  \blx@ifcitesingle
    {\blx@idemtracker@gobal}
    {\blx@idemreset@gobal}}%

\def\blx@idemtracker@constrict{%
  \blx@ifcitesingle
    {\blx@mpfnsave
     \blx@idemtracker@context}
    {\blx@idemreset@context}}%

\def\blx@idemreset@force{%
  \global\undef\blx@lasthash@text
  \global\undef\blx@lasthash@foot
  \blx@mpfnreset}

\def\blx@idemreset@gobal{%
  \global\undef\blx@lasthash@text}

\def\blx@idemreset@context{%
  \iftoggle{blx@footnote}
    {\blx@mpfnreset
     \global\undef\blx@lasthash@foot}
    {\global\undef\blx@lasthash@text}}

% opcit tracker

\def\blx@opcittracker@gobal{%
  \ifbool{citetracker}
    {\blx@opcit@tracker{text}}
    {}}

\def\blx@opcittracker@context{%
  \ifbool{citetracker}
    {\iftoggle{blx@footnote}
       {\blx@opcit@tracker{foot}}
       {\blx@opcit@tracker{text}}}
    {}}

\def\blx@opcittracker@strict{%
  \blx@ifcitesingle
    {\blx@opcittracker@gobal}
    {\blx@opcitreset@gobal}}%

\def\blx@opcittracker@constrict{%
  \blx@ifcitesingle
    {\blx@mpfnsave
     \blx@opcittracker@context}
    {\blx@opcitreset@context}}%

\def\blx@opcit@tracker#1{%
  \global\cslet{blx@lastkey@#1@\abx@field@namehash}\abx@field@entrykey
  \xifinlistcs\abx@field@namehash{blx@trackhash@#1}
    {}
    {\listcsxadd{blx@trackhash@#1}\abx@field@namehash}}

\def\blx@opcit@reset#1{%
  \begingroup
  \def\do##1{\global\csundef{blx@lastkey@#1@##1}}%
  \dolistcsloop{blx@trackhash@#1}%
  \global\cslet{blx@trackhash@#1}\@empty
  \endgroup}

\let\blx@trackhash@text\@empty
\let\blx@trackhash@foot\@empty

\def\blx@opcitreset@force{%
  \blx@opcit@reset{text}%
  \blx@opcit@reset{foot}%
  \blx@mpfnreset}

\def\blx@opcitreset@gobal{%
  \blx@opcit@reset{text}}

\def\blx@opcitreset@context{%
  \iftoggle{blx@footnote}
    {\blx@opcit@reset{foot}%
     \blx@mpfnreset}
    {\blx@opcit@reset{text}}}

% loccit tracker

\def\blx@loccittracker@gobal{%
  \ifbool{citetracker}
    {\blx@loccit@tracker{text}}
    {}}

\def\blx@loccittracker@context{%
  \ifbool{citetracker}
    {\iftoggle{blx@footnote}
       {\blx@loccit@tracker{foot}}
       {\blx@loccit@tracker{text}}}
    {}}

\def\blx@loccittracker@strict{%
  \ifbool{citetracker}
    {\blx@loccit@stricttracker{text}}
    {}}

\def\blx@loccittracker@constrict{%
  \ifbool{citetracker}
    {\iftoggle{blx@footnote}
       {\blx@mpfnsave
        \blx@loccit@stricttracker{foot}}
       {\blx@loccit@stricttracker{text}}}
    {}}

\def\blx@loccit@tracker#1{%
  \global\csundef{blx@lastnote@#1@\abx@field@entrykey}%
  \blx@imc@iffieldundef{postnote}
    {}
    {\global\cslet{blx@lastnote@#1@\abx@field@entrykey}\abx@field@postnote
     \xifinlistcs\abx@field@entrykey{blx@trackkeys@#1}
       {}
       {\listcsxadd{blx@trackkeys@#1}\abx@field@entrykey}}}

\def\blx@loccit@stricttracker#1{%
  \global\csundef{blx@lastnote@#1@\abx@field@entrykey}%
  \blx@imc@iffieldundef{postnote}
    {}
    {\blx@ifcitesingle
       {\expandafter\blx@ifnumerals@loccit
	\expandafter{\abx@field@postnote}
	  {\global\cslet{blx@lastnote@#1@\abx@field@entrykey}\abx@field@postnote
           \xifinlistcs\abx@field@entrykey{blx@trackkeys@#1}
             {}
             {\listcsxadd{blx@trackkeys@#1}\abx@field@entrykey}}
	  {}}
       {}}}

\def\blx@loccit@reset#1{%
  \begingroup
  \def\do##1{\global\csundef{blx@lastnote@#1@##1}}%
  \dolistcsloop{blx@trackkeys@#1}%
  \global\cslet{blx@trackkeys@#1}\@empty
  \endgroup}

\let\blx@trackkeys@text\@empty
\let\blx@trackkeys@foot\@empty

\def\blx@loccitreset@force{%
  \blx@loccit@reset{text}%
  \blx@loccit@reset{foot}%
  \blx@mpfnreset}

\def\blx@loccitreset@gobal{%
  \blx@loccit@reset{text}}

\def\blx@loccitreset@context{%
  \iftoggle{blx@footnote}
    {\blx@loccit@reset{foot}%
     \blx@mpfnreset}
    {\blx@loccit@reset{text}}}

\def\blx@backref@global{%
  \blx@leavevmode
  \if@filesw
    \protected@write\@mainaux{}{\string\abx@aux@backref
      {\the\c@instcount}{\abx@field@entrykey}%
      {\the\c@refsection}{\thepage}}%
  \fi}

% {<instcount>}{<entrykey>}{<refsection>}{<page>}

\protected\def\blx@aux@backref#1#2#3#4{%
  \ifcsundef{blx@pref@#3@\detokenize{#2}}
    {\global\cslet{blx@pref@#3@\detokenize{#2}}\@empty
     \expandafter\blx@onlypreamble
     \expandafter{\csname blx@pref@#3@\detokenize{#2}\endcsname}}
    {}%
  \ifinlistcs{#4}{blx@pref@#3@\detokenize{#2}}
    {}
    {\listcsgadd{blx@pref@#3@\detokenize{#2}}{#4}}%
  \blx@addchecksum{\the\numexpr#1+0#4}}

\AtEndDocument{%
  \def\abx@aux@backref#1#2#3#4{\blx@addchecksum{\the\numexpr#1+0#4}}}

% {<true>}{<false>}

\def\blx@ifcitesingle{%
  \ifnum\c@citetotal=\@ne
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi}

%  hyperref interface

\appto\blx@mkhyperref{%
  \protected\def\blx@imc@bibhyperref{%
    \@ifnextchar[%]
      {\blx@bibhyperref}
      {\blx@bibhyperref[\abx@field@entrykey]}}%
  \ifundef\hyper@natanchorstart
    {\long\def\blx@bibhyperref[#1]#2{%
       \hyperlink{cite.\the\c@refsection @#1}{#2}}%
     \protected\long\def\blx@imc@bibhyperlink#1#2{%
       \hyperlink{cite.\the\c@refsection:#1}{#2}}%
     \protected\long\def\blx@imc@bibhypertarget#1#2{%
       \hypertarget{cite.\the\c@refsection:#1}{#2}}}%
    {\long\def\blx@bibhyperref[#1]#2{%
       \hyper@natlinkstart{\the\c@refsection @#1}#2\hyper@natlinkend}%
     \protected\long\def\blx@imc@bibhyperlink#1#2{%
       \hyper@natlinkstart{\the\c@refsection:#1}#2\hyper@natlinkend}%
     \protected\long\def\blx@imc@bibhypertarget#1#2{%
       \@bsphack\hyper@natanchorstart{\the\c@refsection:#1}\@esphack
       #2\hyper@natanchorend}}
  \let\blx@imc@ifhyperref\@firstoftwo}

\appto\blx@mknohyperref{%
  \protected\def\blx@imc@bibhyperref{\@ifnextchar[\blx@nohyperref\@firstofone}%
  \def\blx@nohyperref[#1]#2{#2}%
  \let\blx@imc@bibhyperlink\@secondoftwo
  \let\blx@imc@bibhypertarget\@secondoftwo
  \let\blx@imc@ifhyperref\@secondoftwo}

\appto\blx@blxinit{%
  \let\bibhyperref\blx@imc@bibhyperref
  \let\bibhyperlink\blx@imc@bibhyperlink
  \let\bibhypertarget\blx@imc@bibhypertarget
  \let\ifhyperref\blx@imc@ifhyperref}

% {<entrykey>,...}

\renewrobustcmd*{\nocite}[1]{%
  \@bsphack
  \AfterPreamble{\blx@nocite{#1}}%
  \@esphack}

\protected\def\blx@nocite#1{%
  \iftoggle{blx@bibliography}
    {}
    {\ifstrequal{*}{#1}
       {\blx@citation@all}
       {\begingroup
	\let\do\blx@nocite@do
	\blx@sanitizekeys\docsvlist{#1}%
	\endgroup}}}

\def\blx@nocite@do#1{\blx@citation{#1}\blx@msg@cundef}

% {<macro>}[<arg1>][<arg2>]{<arg3>}
% => <macro>{<arg1>}{<arg2>}{<arg3>}

\protected\def\blx@citeargs#1{%
  \@ifnextchar[%]
    {\blx@citeargs@i{#1}}
    {\blx@citeargs@iii{#1{}{}}}}
\long\def\blx@citeargs@i#1[#2]{%
  \@ifnextchar[%]
    {\blx@citeargs@ii{#1{#2}}}
    {\blx@citeargs@iii{#1{}{#2}}}}
\long\def\blx@citeargs@ii#1[#2]{%
  \blx@citeargs@iii{#1{#2}}}
\long\def\blx@citeargs@iii#1#2{%
  \blx@sanitizekeys{#1}{#2}}

% {<macro>}(<arg1>)(<arg2>)
% => <macro>{<arg1>}{<arg2>}

\protected\def\blx@multiargs#1{%
  \@ifnextchar(%)
    {\blx@multiargs@i{#1}}
    {#1{}{}}}
\long\def\blx@multiargs@i#1(#2){%
  \@ifnextchar(%)
    {\blx@multiargs@ii{#1{#2}}}
    {#1{}{#2}}}
\long\def\blx@multiargs@ii#1(#2){#1{#2}}

% {<macro>}[<arg1>][<arg2>]{<arg3>}<punct>
% => <macro>{<arg1>}{<arg2>}{<arg3>}{<punctcmd>}

\protected\def\blx@citepunct#1{%
  \blx@citeargs{\blx@citepunct@i{#1}}}
\long\def\blx@citepunct@i#1#2#3#4{%
  \blx@thecheckpunct{#1{#2}{#3}{#4}}}

% {<csname>}[<arg1>][<arg2>]{arg3}[arg4]{arg5}<punct>
% => <macro>{<arg1>}{<arg2>}{<arg3>}{<arg4>}{arg5}{<punctcmd>}

\protected\def\blx@citexpunct#1{%
  \blx@citeargs{\blx@citexpunct@i{#1}}}
\long\def\blx@citexpunct@i#1#2#3#4{%
  \@ifnextchar[%]
    {\blx@citexpunct@ii{#1}{{#2}{#3}{#4}}}
    {\blx@citexpunct@ii{#1}{{#2}{#3}{#4}}[#1]}}
\long\def\blx@citexpunct@ii#1#2[#3]#4{%
  \blx@thecheckpunct{\blx@citecmd{#1}#2{#3}{#4}}}

% {<code>}<punct> => <code>{<punctcmd>}

\long\def\blx@checkpunct#1{%
  \begingroup
  \def\blx@tempa{\endgroup#1}%
  \futurelet\blx@tempb\blx@checkpunct@i}
\def\blx@checkpunct@i{%
  \expandafter\blx@checkpunct@ii\blx@autopunct&}
\def\blx@checkpunct@ii#1{%
  \ifx#1&%
    \expandafter\blx@checkpunct@iii
  \fi
  \if\noexpand#1\noexpand\blx@tempb
    \expandafter\blx@checkpunct@iv
  \fi
  \blx@checkpunct@ii}
\def\blx@checkpunct@iii#1\blx@checkpunct@ii{%
  \blx@tempa{}}
\def\blx@checkpunct@iv#1\blx@checkpunct@ii#2&#3{%
  \edef\blx@tempa{%
    \expandonce\blx@tempa{%
    \ifcsdef{blx@pm@\detokenize{#3}}
      {\csname blx@imc@add\csname blx@pm@\detokenize{#3}\endcsname
       \endcsname}
      {\noexpand#3}}}%
  \blx@tempa}

\long\def\blx@nocheckpunct#1{#1{}}

\protected\def\blx@citeinit{%
  \iftoggle{blx@bibliography}
    {}
    {\toggletrue{blx@citation}%
     \settoggle{blx@index}{\iftoggle{blx@citindex}{true}{false}}}%
  \blx@blxinit
  \citesetup
  \blx@setsfcodes
  \aftergroup\blx@postpunct
  \blx@resetdata
  \blx@leavevmode
  \csuse{blx@hook@cite}%
  \csuse{blx@hook@cite@next}%
  \let\blx@citeinit\blx@resetdata}

% *{<command>}[<wrapper>]{<precode>}{<loopcode>}{<delimcode>}{<postcode>}

\newrobustcmd*{\DeclareCiteCommand}{%
  \@ifstar{\blx@defcitecmd*}{\blx@defcitecmd{}}}

\def\blx@defcitecmd#1#2{%
  \begingroup
  \escapechar\m@ne
  \edef\blx@tempa{\endgroup
    \noexpand\blx@defcitecmd@i{#1}{\string#2}}%
  \blx@tempa}

\def\blx@defcitecmd@i#1#2{%
  \blx@checkcitecmd{#2}{#1}%
  \protected\csedef{#2}{%
    \blx@leavevmode@cite
    \noexpand\@ifstar
      {\blx@citepunct\expandafter\noexpand
       \csname blx@cmd@#2*\endcsname}
      {\blx@citepunct\expandafter\noexpand
       \csname blx@cmd@#2\endcsname}}%
  \@ifnextchar[%]
    {\blx@defcitecmd@iii{#2#1}}
    {\blx@defcitecmd@ii{#2#1}}}

\long\def\blx@defcitecmd@ii#1{%
  \protected\csedef{blx@cmd@#1}{%
    \begingroup
    \blx@citeinit
    \expandafter\noexpand
    \csname blx@cmdi@#1\endcsname}%
  \blx@defcitecmd@iv{#1}}

\long\def\blx@defcitecmd@iii#1[#2]{%
  \protected\long\csedef{blx@cmd@#1}##1##2##3##4{%
    \begingroup
    \blx@citeinit
    \unexpanded{#2}{%
      \begingroup
      \blx@citeinit
      \expandafter\noexpand
      \csname blx@cmdi@#1\endcsname{##1}{##2}{##3}{}}%
    ##4\endgroup}%
  \blx@defcitecmd@iv{#1}}

\long\def\blx@defcitecmd@iv#1#2#3#4#5{%
  \protected\long\csdef{blx@cmdi@#1}##1##2##3##4{%
    \ifblank{##1}
      {}
      {\def\abx@field@prenote{##1}}%
    \ifblank{##2}
      {\let\blx@thenotecheck\relax}
      {\def\abx@field@postnote{##2}}%
    \def\blx@precode{#2}%
    \def\blx@loopcode{#3}%
    \def\blx@dlimcode{#4}%
    \def\blx@postcode{#5##4}%
    \blx@citeloop{##3}%
    \endgroup}}

% {<type>}{<name>}{*}

\def\blx@checkcitecmd#1#2{%
  \ifblank{#2}
    {\ifcsdef{blx@cmd@#1}
       {\blx@info{Redefining '\@backslashchar#1'}}
       {\ifcsundef{#1}
          {}
          {\blx@warning@noline{Redefining '\@backslashchar#1'}}}%
     \ifcsdef{blx@cmd@#1*}
       {}
       {\csedef{blx@cmd@#1*}{%
          \expandafter\noexpand\csname blx@cmd@#1\endcsname}%
        \csedef{blx@cmdi@#1*}{%
          \expandafter\noexpand\csname blx@cmdi@#1\endcsname}}}
    {\ifcsdef{blx@cmd@#1}
       {}
       {\csdef{blx@cmd@#1}{\blx@err@citecmd{#1}}%
        \csdef{blx@cmdi@#1}{\blx@err@citecmd{#1}}}}}

% {<name>}

\protected\def\blx@citecmd#1{%
  \ifcsundef{blx@cmd@#1}
    {\blx@err@citecmd{#1}}
    {\csuse{blx@cmd@#1}}}

\protected\def\blx@citeicmd#1{%
  \ifcsundef{blx@cmdi@#1}
    {\blx@err@citecmd{#1}}
    {\begingroup\csuse{blx@cmdi@#1}}}

% {<command>}[<wrapper>]{<cite>}{<delimiter>}

\newrobustcmd{\DeclareMultiCiteCommand}[1]{%
  \ifundef#1%
    {}
    {\blx@info{Redefining '\string#1'}}%
  \@ifnextchar[%]
    {\blx@defmcitecmd{#1}}
    {\blx@defmcitecmd{#1}[\@firstofone]}}

\def\blx@defmcitecmd#1[#2]#3#4{%
  \begingroup
  \escapechar\m@ne
  \edef\blx@tempa{\endgroup
    \protected\def\noexpand#1{%
      \blx@leavevmode@cite
      \noexpand\@ifstar
        {\expandafter\noexpand
         \csname blx@mcite@\string#1\endcsname*%
         \expandafter\noexpand
         \csname blx@mcitei@\string#1\endcsname}
        {\expandafter\noexpand
         \csname blx@mcite@\string#1\endcsname{}%
         \expandafter\noexpand
         \csname blx@mcitei@\string#1\endcsname}}%
    \protected\csdef{blx@mcite@\string#1}####1####2{%
      \begingroup
      \blx@citeinit
      \noexpand\blx@multicite
        ####2%
        {\unexpanded{#2}}%
        {\blx@citeicmd{\string#3####1}}%
        {\unexpanded{#4}}}%
    \protected\long\csdef{blx@mcitei@\string#1}}%
  \blx@tempa##1##2##3{%
    \blx@multiprint{##1}{##2}{}{##3}\endgroup}}

% {<command>}{<wrapper>}{<citecmd>}{<delimiter>} =>
%  <init><command>{<wrapper>}{<cites>}{<punct>}

\def\blx@multicite#1#2#3#4{%
  \begingroup
  \def\blx@tempa{#1}%
  \def\blx@tempb{#2}%
  \def\blx@tempc{#3}%
  \def\blx@tempd{#4}%
  \c@multicitetotal\z@
  \blx@multiargs\blx@multicite@i}

\def\blx@multicite@i#1#2{%
  \ifblank{#1}%
    {}
    {\preto\blx@tempa{\def\abx@field@multiprenote{#1}}}%
  \ifblank{#2}%
    {}
    {\preto\blx@tempa{\def\abx@field@multipostnote{#2}}}%
  \let\blx@tempe\@empty
  \let\blx@tempf\@empty
  \togglefalse{blx@tempa}%
  \blx@multiparse}

\def\blx@multicite@add#1#2#3{%
  \togglefalse{blx@tempa}%
  \advance\c@multicitetotal\@ne
  \eappto\blx@tempe{%
    \expandonce\blx@tempf
    \advance\c@multicitecount\@ne
    \expandonce\blx@tempc
      \unexpanded{{#1}{#2}{#3}}{}}%
  \let\blx@tempf\blx@tempd
  \blx@multiparse}

\def\blx@multicite@end#1{%
  \edef\blx@tempa{\endgroup
    \c@multicitecount\z@
    \c@multicitetotal\the\c@multicitetotal\relax
    \ifnum\c@multicitetotal>\@ne
      \let\noexpand\blx@ifcitesingle\noexpand\@secondoftwo
    \fi
    \expandonce\blx@tempa
      {\expandonce\blx@tempb}%
      {\expandonce\blx@tempe}%
      {#1}%
    \iftoggle{blx@tempa}{\relax\space}{}}%
  \blx@tempa}

\def\blx@multiparse{%
  \futurelet\@let@token\blx@multiparse@i}

\def\blx@multiparse@i{%
  \ifx\@let@token\relax
    \blx@multiparse@ii{\blx@multicite@end{}}%
  \fi
  \ifx\@let@token[%]
    \blx@multiparse@ii{\blx@citeargs\blx@multicite@add}%
  \fi
  \ifx\@let@token\bgroup
    \blx@multiparse@ii{\blx@citeargs\blx@multicite@add}%
  \fi
  \ifx\@let@token\@sptoken
    \blx@multiparse@ii\blx@multiparse@iii
  \fi
  \iftrue
    \iftoggle{blx@tempa}
      {\blx@multiparse@ii{\blx@multicite@end{}}}
      {\blx@multiparse@ii{\blx@thecheckpunct\blx@multicite@end}}%
  \fi
  &}

\def\blx@multiparse@ii#1#2&{\fi#1}
\csdef{blx@multiparse@iii} {\toggletrue{blx@tempa}\blx@multiparse}

% {<wrapper>}{<cites>}{<leftpunct>}{<rightpunct>}

\def\blx@multiprint#1#2#3#4{%
  #3#1{%
    \blx@citeinit
    \usebibmacro{multiprenote}#2%
    \usebibmacro{multipostnote}}%
  #4}

% {<name>}[l|i|r]{<cite>}{<multicite>}

\newrobustcmd*{\DeclareAutoCiteCommand}[1]{%
  \ifcsundef{blx@acite@#1}
    {}
    {\blx@info{Redefining autocite command '#1'}}%
  \@ifnextchar[%]
    {\blx@defautocmd@i{#1}}
    {\blx@defautocmd@i{#1}[r]}}

\def\blx@defautocmd@i#1[#2]#3#4{%
  \begingroup
  \escapechar\m@ne
  \edef\blx@tempa{\endgroup
    \noexpand\blx@defautocmd@ii{#1}{#2}%
      {\string#3}{\string#4}}%
  \blx@tempa}

\def\blx@defautocmd@ii#1#2#3#4{%
  \csedef{blx@acite@#1}{%
    \blx@leavevmode@cite
    \noexpand\@ifstar
      {\blx@citepunct{\expandafter\noexpand
       \csname blx@acitei@#1\endcsname*}}
      {\blx@citepunct{\expandafter\noexpand
       \csname blx@acitei@#1\endcsname{}}}}%
  \csedef{blx@acitei@#1}##1##2##3##4##5{%
    \begingroup
    \blx@citeinit
    \if l#2\unspace##5\fi
    \blx@citecmd{#3##1}{##2}{##3}{##4}{}%
    \if r#2##5\fi
    \endgroup}%
  \csedef{blx@macite@#1}{%
    \blx@leavevmode@cite
    \noexpand\@ifstar
      {\expandafter\noexpand
       \csname blx@mcite@#4\endcsname*%
       \expandafter\noexpand
       \csname blx@macitei@#1\endcsname}
      {\expandafter\noexpand
       \csname blx@mcite@#4\endcsname{}%
       \expandafter\noexpand
       \csname blx@macitei@#1\endcsname}}%
  \csedef{blx@macitei@#1}##1##2##3{%
    \noexpand\blx@multiprint{##1}{##2}%
      {\if l#2\unspace##3\fi}%
      {\if r#2##3\fi}%
    \endgroup}}

% {<characters>}

\newrobustcmd*{\DeclareAutoPunctuation}[1]{%
  \ifblank{#1}
    {\let\blx@thecheckpunct\blx@nocheckpunct}
    {\let\blx@thecheckpunct\blx@checkpunct
     \edef\blx@autopunct{#1}}}

% [<prenote>][<postnote>]{<entrykey>,...}[<format>]{<namelist>}<punct>

\newrobustcmd*{\citename}{\blx@citexpunct{citename}}
\long\csdef{blx@cmd@citename}#1#2#3#4#5#6{%
  \begingroup
  \blx@citeinit
  \ifblank{#1}
    {}
    {\def\abx@field@prenote{#1}}%
  \ifblank{#2}
    {\let\blx@thenotecheck\relax}
    {\def\abx@field@postnote{#2}}%
  \def\blx@precode{\usebibmacro{prenote}}%
  \def\blx@loopcode{%
    \ifnameundef{#5}
      {\blx@warning@entry{'#5' undefined or not a name list}%
       \blx@missing{#5}}
      {\printnames[#4]{#5}}}%
  \def\blx@dlimcode{\multicitedelim}%
  \ifblank{#2}
    {\def\blx@postcode{#6}}
    {\def\blx@postcode{\usebibmacro{postnote}#6}}%
  \boolfalse{citetracker}%
  \boolfalse{pagetracker}%
  \blx@citeloop{#3}%
  \endgroup}

% [<prenote>][<postnote>]{<entrykey>,...}[<format>]{<list>}<punct>

\newrobustcmd*{\citelist}{\blx@citexpunct{citelist}}
\long\csdef{blx@cmd@citelist}#1#2#3#4#5#6{%
  \begingroup
  \blx@citeinit
  \ifblank{#1}
    {}
    {\def\abx@field@prenote{#1}}%
  \ifblank{#2}
    {\let\blx@thenotecheck\relax}
    {\def\abx@field@postnote{#2}}%
  \def\blx@precode{\usebibmacro{prenote}}%
  \def\blx@loopcode{%
    \blx@imc@iflistundef{#5}
      {\blx@warning@entry{'#5' undefined or not a literal list}%
       \blx@missing{#5}}
      {\printlist[#4]{#5}}}%
  \def\blx@dlimcode{\multicitedelim}%
  \ifblank{#2}
    {\def\blx@postcode{#6}}
    {\def\blx@postcode{\usebibmacro{postnote}#6}}%
  \boolfalse{citetracker}%
  \boolfalse{pagetracker}%
  \blx@citeloop{#3}%
  \endgroup}

% [<prenote>][<postnote>]{<entrykey>,...}[<format>]{<field>}<punct>

\newrobustcmd*{\citefield}{\blx@citexpunct{citefield}}
\long\csdef{blx@cmd@citefield}#1#2#3#4#5#6{%
  \begingroup
  \blx@citeinit
  \ifblank{#1}
    {}
    {\def\abx@field@prenote{#1}}%
  \ifblank{#2}
    {\let\blx@thenotecheck\relax}
    {\def\abx@field@postnote{#2}}%
  \def\blx@precode{\usebibmacro{prenote}}%
  \def\blx@loopcode{%
    \iffieldundef{#5}
      {\blx@warning@entry{'#5' undefined or not a field}%
       \blx@missing{#5}}
      {\printfield[#4]{#5}}}%
  \def\blx@dlimcode{\multicitedelim}%
  \ifblank{#2}
    {\def\blx@postcode{#6}}
    {\def\blx@postcode{\usebibmacro{postnote}#6}}%
  \boolfalse{citetracker}%
  \boolfalse{pagetracker}%
  \blx@citeloop{#3}%
  \endgroup}

\renewrobustcmd*{\cite}{\blx@err@citecmd\cite}
\let\blx@cmd@cite\relax
\newrobustcmd*{\parencite}{\blx@warn@citecmd\parencite\cite}
\let\blx@cmd@parencite\relax
\newrobustcmd*{\footcite}{\blx@warn@citecmd\footcite\cite}
\let\blx@cmd@footcite\relax
\newrobustcmd*{\textcite}{\blx@warn@citecmd\textcite\cite}
\let\blx@cmd@textcite\relax
\newrobustcmd*{\supercite}{\blx@warn@citecmd\supercite\cite}
\let\blx@cmd@supercite\relax

%% ifthen interface

\def\blx@TE#1#2{%
  \TE@throw
  \unexpanded{%
    \iftrue\@nameuse{fi}%
    #1{\@nameuse{iftrue}}{\@nameuse{iffalse}}}#2}

\def\blx@xTE#1#2{%
  \TE@throw
  \unexpanded{\iftrue\@nameuse{fi}}%
  #1\unexpanded{{\@nameuse{iftrue}}{\@nameuse{iffalse}}}#2}

\let\blx@TE@hook\@empty

\appto\blx@blxinit{%
  \appto\blx@TE@hook{%
    \def\ifhyperref{\blx@TE\blx@imc@ifhyperref}%
    \def\ifmorenames{\blx@TE\blx@imc@ifmorenames}%
    \def\ifmoreitems{\blx@TE\blx@imc@ifmoreitems}%
    \def\ifciteseen{\blx@TE\blx@imc@ifciteseen}%
    \def\ifentryseen{\blx@TE\blx@imc@ifentryseen}%
    \def\ifciteibid{\blx@TE\blx@imc@ifciteibid}%
    \def\ifciteidem{\blx@TE\blx@imc@ifciteidem}%
    \def\ifopcit{\blx@TE\blx@imc@ifopcit}%
    \def\ifloccit{\blx@TE\blx@imc@ifloccit}%
    \def\ifsamepage{\blx@TE\blx@imc@ifsamepage}%
    \def\iffirstonpage{\blx@TE\blx@imc@iffirstonpage}%
    \def\ifcurrentfield#1{\blx@TE{\blx@imc@ifcurrentfield{#1}}}%
    \def\ifcurrentlist#1{\blx@TE{\blx@imc@ifcurrentlist{#1}}}%
    \def\ifcurrentname#1{\blx@TE{\blx@imc@ifcurrentname{#1}}}%
    \def\ifentrytype#1{\blx@TE{\blx@imc@ifentrytype{#1}}}%
    \def\iffieldequalcs#1#2{\blx@TE{\blx@imc@iffieldequalcs{#1}{#2}}}%
    \def\iffieldequals#1#2{\blx@TE{\blx@imc@iffieldequals{#1}{#2}}}%
    \def\iffieldequalstr#1#2{\blx@TE{\blx@imc@iffieldequalstr{#1}{#2}}}%
    \def\iffieldsequal#1#2{\blx@TE{\blx@imc@iffieldsequal{#1}{#2}}}%
    \def\iffieldundef#1{\blx@TE{\blx@imc@iffieldundef{#1}}}%
    \def\ifnameequalcs#1#2{\blx@TE{\blx@imc@ifnameequalcs{#1}{#2}}}%
    \def\ifnameequals#1#2{\blx@TE{\blx@imc@ifnameequals{#1}{#2}}}%
    \def\ifnamesequal#1#2{\blx@TE{\blx@imc@ifnamesequal{#1}{#2}}}%
    \def\ifnameundef#1{\blx@TE{\blx@imc@ifnameundef{#1}}}%
    \def\ifcitation{\blx@TE{\iftoggle{blx@citation}}}%
    \def\ifbibliography{\blx@TE{\iftoggle{blx@bibliography}}}%
    \def\iffootnote{\blx@TE{\iftoggle{blx@footnote}}}%
    \def\ifuseprefix{\blx@TE{\iftoggle{blx@useprefix}}}%
    \def\ifuseauthor{\blx@TE{\iftoggle{blx@useauthor}}}%
    \def\ifuseeditor{\blx@TE{\iftoggle{blx@useeditor}}}%
    \def\ifusetranslator{\blx@TE{\iftoggle{blx@usetranslator}}}%
    \def\iffirstinits{\blx@TE{\iftoggle{blx@firstinits}}}%
    \def\ifsingletitle{\blx@TE{\iftoggle{abx@bool@singletitle}}}%
    \def\ifandothers#1{\blx@TE{\iftoggle{abx@bool@more#1}}}%
    \def\ifcapital{\blx@TE\blx@imc@ifcapital}%
    \def\ifinteger#1{\blx@TE{\blx@imc@ifinteger{#1}}}%
    \def\ifnumeral#1{\blx@TE{\blx@imc@ifnumeral{#1}}}%
    \def\ifnumerals#1{\blx@TE{\blx@imc@ifnumerals{#1}}}%
    \def\ifbibstring#1{\blx@TE{\blx@imc@ifbibstring{#1}}}%
    \def\iffieldbibstring#1{\blx@TE{\blx@imc@iffieldbibstring{#1}}}}}

% {<listmacro>}{<filtercsname>} => matches in <listmacro>

\protected\def\blx@bibfilter#1#2{%
  \let\blx@@TE@hook\blx@TE@hook
  \appto\blx@TE@hook\blx@fltinit
  \edef\blx@do##1{%
    \def\noexpand\blx@fltitem{##1}%
    \noexpand\ifthenelse{\csexpandonce{#2}}%
      {\listadd\noexpand#1{##1}}%
      {}}%
  \def\blx@done{\let\blx@TE@hook\blx@@TE@hook}%
  \begingroup\edef#1{\endgroup
    \unexpanded{\let#1\@empty}%
    \blx@listloop{#1}}%
  #1}

\appto\blx@fltinit{%
  \def\segment#1{\blx@xTE{%
    \ifinlist
      {\blx@fltitem}
      {\csuse{blx@segm@\the\c@refsection @#1}}}}%
  \def\type#1{\blx@xTE{%
    \ifinlist
      {\blx@fltitem}
      {\csuse{blx@type@\the\c@refsection @#1}}}}%
  \def\keyword#1{\blx@xTE{%
    \ifinlist
      {\blx@fltitem}
      {\csuse{blx@keyw@\the\c@refsection @\detokenize{#1}}}}}%
  \def\category#1{\blx@xTE{%
    \ifinlist
      {\blx@fltitem}
      {\csuse{blx@catg@#1}}}}}

%% Auxiliary macros

\newrobustcmd*{\mkbibquote}{\enquote}
\protected\def\blx@imc@mkbibquote{%
  \blx@ifuspunct\blx@usquote\enquote}

\def\blx@usquote{%
  \ifnum\@quotelevel>\z@
    \expandafter\blx@usiquote
  \else
    \expandafter\blx@usoquote
  \fi}

\long\def\blx@usoquote#1{%
  \begingroup
  \initoquote
  \textooquote#1%
  \blx@imc@ifterm
    {\textcoquote\endgroup}
    {\futurelet\@let@token\blx@usoquote@i}}

\def\blx@usoquote@i{%
  \blx@usqcheck
    {\ifx\blx@postpunct\@empty\else\blx@dopostpunct\fi
     \textcoquote\endgroup}
    {\blx@setpostpunct\textcoquote\endgroup}}

\long\def\blx@usiquote#1{%
  \begingroup
  \initiquote
  \textoiquote#1%
  \blx@imc@ifterm
    {\textciquote\endgroup}
    {\futurelet\@let@token\blx@usiquote@i}}

\def\blx@usiquote@i{%
  \blx@usqcheck
    {\textciquote\endgroup}
    {\blx@setpostpunct\textciquote\endgroup}}

\def\blx@usqcheck#1#2{%
  \def\blx@tempa{#1}%
  \def\blx@tempb{#2}%
  \ifx\@let@token\space
    \blx@usqcheck@i\blx@tempa
  \fi
  \ifx\@let@token\@sptoken
    \blx@usqcheck@i\blx@tempa
  \fi
  \if\noexpand\@let@token\relax
    \blx@usqcheck@i\blx@tempb
  \fi
  \expandafter\blx@usqcheck@ii\blx@quotepunct\relax&}

\def\blx@usqcheck@i#1#2&{\fi#1}

\def\blx@usqcheck@ii#1{%
  \if\noexpand#1\relax
    \blx@usqcheck@i\blx@tempa
  \fi
  \if\noexpand#1\noexpand\@let@token
    \blx@usqcheck@i{\blx@usqcheck@iii\blx@tempa}%
  \fi
  \blx@usqcheck@ii}

\def\blx@usqcheck@iii#1#2{#2#1}

\newrobustcmd*{\mkbibemph}{\emph}
\protected\long\def\blx@imc@mkbibemph#1{%
  \emph{#1}\relax
  \blx@imc@setpunctfont\emph}

\appto\blx@blxinit{%
  \let\mkbibquote\blx@imc@mkbibquote
  \let\mkbibemph\blx@imc@mkbibemph}

\newrobustcmd{\mkbibparens}[1]{%
  \begingroup
  \let\mkbibparens\blx@noparens
  \bibleftparen#1\blx@postpunct\bibrightparen
  \endgroup}

\long\def\blx@noparens#1{%
  \blx@warning{Nested parentheses}%
  \mkbibbrackets{#1}}

\newrobustcmd{\mkbibbrackets}[1]{%
  \begingroup
  \let\mkbibbrackets\blx@nobrackets
  \bibleftbracket#1\blx@postpunct\bibrightbracket
  \endgroup}

\long\def\blx@nobrackets#1{%
  \blx@warning{Nested brackets}%
  <#1\blx@postpunct>}

\newrobustcmd{\mkbibfootnote}[1]{%
  \iftoggle{blx@footnote}
    {\blx@warning{Nested footnotes}%
     \addspace\mkbibparens{#1}}
    {\unspace\footnote{%
       \toggletrue{blx@footnote}%
       \blx@setsfcodes\bibsentence
       #1\blx@imc@addperiod}}}

\newrobustcmd{\mkbibendnote}[1]{%
  \iftoggle{blx@footnote}
    {\blx@warning{Nested endnotes}%
     \addspace\mkbibparens{#1}}
    {\unspace
     \ifundef\endnote\footnote\endnote{%
       \toggletrue{blx@footnote}%
       \blx@setsfcodes\bibsentence
       #1\blx@imc@addperiod}}}

\newrobustcmd{\mkbibsuperscript}[1]{%
  \unspace\allowhyphens\textsuperscript{%
    \begingroup
    \let\mkbibsuperscript\blx@nosuperscript
    #1\endgroup}}

\long\def\blx@nosuperscript#1{%
  \blx@warning{Nested superscript}%
  \mkbibbrackets{#1}}

\newrobustcmd*{\mknumalph}[1]{%
  \begingroup
  \@tempcnta=#1\relax
  \ifnum\@tempcnta>702 %
  \else
    \ifnum\@tempcnta>26 %
      \advance\@tempcnta\m@ne
      \divide\@tempcnta26\relax
      \blx@numalph\@tempcnta
      \multiply\@tempcnta26\relax
      \@tempcnta=\numexpr#1-\@tempcnta\relax
    \fi
  \fi
  \blx@numalph\@tempcnta
  \endgroup}
\def\blx@numalph#1{%
  \ifcase#1\relax\blx@warning@entry{Value out of range}\number#1\or
  a\or b\or c\or d\or e\or f\or g\or h\or i\or j\or k\or l\or m\or
  n\or o\or p\or q\or r\or s\or t\or u\or v\or w\or x\or y\or z\else
  \blx@warning@entry{Value out of range}\number#1\fi}

\newrobustcmd*{\volcitecmd}[1]{%
  \begingroup
  \def\blx@tempa{\endgroup#1}%
  \@ifstar
    {\appto\blx@tempa{*}%
     \blx@volcitecmd@i}
    {\blx@volcitecmd@i}}

\def\blx@volcitecmd@i{%
  \@ifnextchar[%]
    {\blx@volcitecmd@ii}
    {\blx@volcitecmd@ii[]}}

\def\blx@volcitecmd@ii[#1]#2{%
  \appto\blx@tempa{[#1]}%
  \@ifnextchar[%]
    {\blx@volcitecmd@iii{#2}}
    {\blx@tempa[\blx@volcite@vol{#2}]}}

\def\blx@volcitecmd@iii#1[#2]{%
  \blx@tempa[\blx@volcite@vol{#1}\blx@volcite@page{#2}]}

\protected\def\blx@volcite@vol#1{%
  \blx@imc@bibstring{volume}\ppspace#1}
\protected\def\blx@volcite@page#1{%
  \addcomma\space\blx@imc@mkpageprefix{#1}}

\appto\blx@hook@ifloccit{%
  \let\blx@volcite@vol\@gobble
  \let\blx@volcite@page\@firstofone}

%% Package options

% {<options>}

\newrobustcmd*{\ExecuteBibliographyOptions}{\setkeys{blx@opt@pre}}
\@onlypreamble\ExecuteBibliographyOptions

% load-time only

\define@key{blx@opt@ldt}{style}{%
  \def\blx@cbxfile{#1}%
  \def\blx@bbxfile{#1}}

\define@key{blx@opt@ldt}{bibstyle}{%
  \def\blx@bbxfile{#1}}

\define@key{blx@opt@ldt}{citestyle}{%
  \def\blx@cbxfile{#1}}

\define@key{blx@opt@ldt}{natbib}[true]{%
  \settoggle{blx@natbib}{#1}}

% load-time and preamble

\define@key{blx@opt@pre}{debug}[true]{%
  \settoggle{blx@debug}{#1}}

\define@key{blx@opt@pre}{backend}{%
  \ifcsdef{blx@backend@#1}
    {\letcs\blx@backend{blx@backend@#1}}
    {\blx@err@invopt{backend=#1}}}
\chardef\blx@backend@bibtex=0
\expandafter\chardef\csname blx@backend@bibtex8\endcsname=1
\chardef\blx@backend@biber=2

\define@key{blx@opt@pre}{loadfiles}[true]{%
  \settoggle{blx@loadfiles}{#1}}

\define@key{blx@opt@pre}{mincrossrefs}{%
  \ifnum#1<\z@
    \undef\blx@mincrossrefs
    \def\blx@minxrefs{1}%
  \else
    \def\blx@mincrossrefs{#1}%
    \def\blx@minxrefs{#1}%
  \fi}
\def\blx@minxrefs{2}

\define@key{blx@opt@pre}{bibencoding}{%
  \ifstrequal{#1}{ascii}
    {\undef\blx@bibencoding
     \togglefalse{blx@recode}}
    {\def\blx@bibencoding{#1}%
     \ifstrequal{#1}{inputenc}
       {\togglefalse{blx@recode}}
       {\toggletrue{blx@recode}}%
     \ifnum\blx@backend<\csuse{blx@backend@bibtex8}%
       \letcs\blx@backend{blx@backend@bibtex8}%
     \fi}}

\define@key{blx@opt@pre}{sorting}{%
  \ifcsdef{blx@opt@sorting@#1}
    {\def\blx@sorting{#1}}
    {\blx@err@invopt{sorting=#1}}}
\def\blx@opt@sorting@none{0}
\def\blx@opt@sorting@nty{1}
\def\blx@opt@sorting@nyt{2}
\def\blx@opt@sorting@nyvt{3}
\def\blx@opt@sorting@anyt{12}
\def\blx@opt@sorting@anyvt{13}
\def\blx@opt@sorting@ynt{21}
\def\blx@opt@sorting@ydnt{22}
\def\blx@opt@sorting@debug{99}

\define@key{blx@opt@pre}{sortlos}{%
  \ifcsdef{blx@opt@sortlos@#1}
    {\letcs\blx@sortlos{blx@opt@sortlos@#1}}
    {\blx@err@invopt{sortlos=#1}}}
\def\blx@opt@sortlos@bib{0}
\def\blx@opt@sortlos@los{1}

\define@key{blx@opt@pre}{maxnames}{%
  \ifnum#1<\@ne
    \c@maxnames\@ne
  \else
    \c@maxnames#1\relax
  \fi}

\define@key{blx@opt@pre}{minnames}{%
  \ifnum#1<\@ne
    \c@minnames\@ne
  \else
    \c@minnames#1\relax
  \fi}

\define@key{blx@opt@pre}{maxitems}{%
  \ifnum#1<\@ne
    \c@maxitems\@ne
  \else
    \c@maxitems#1\relax
  \fi}

\define@key{blx@opt@pre}{minitems}{%
  \ifnum#1<\@ne
    \c@minitems\@ne
  \else
    \c@minitems#1\relax
  \fi}

\define@key{blx@opt@pre}{maxline}{%
  \ifnum#1<49
    \def\blx@maxline{49}%
  \else
    \ifnum#1>79
      \def\blx@maxline{79}%
    \else
      \def\blx@maxline{#1}%
    \fi
  \fi}

\define@key{blx@opt@pre}{terseinits}[true]{%
  \settoggle{blx@terseinits}{#1}}

\define@key{blx@opt@pre}{firstinits}[true]{%
  \settoggle{blx@firstinits}{#1}}

\define@key{blx@opt@pre}{abbreviate}[true]{%
  \ifstrequal{#1}{true}
    {\let\blx@lbx@thedef\blx@lbx@shortdef}
    {\let\blx@lbx@thedef\blx@lbx@longdef}}

\define@key{blx@opt@pre}{babel}{%
  \ifcsdef{blx@opt@babel@#1}
    {\csuse{blx@opt@babel@#1}}
    {\blx@err@invopt{babel=#1}}}
\def\blx@opt@babel@none{\undef\blx@babelenv}
\def\blx@opt@babel@hyphen{\def\blx@babelenv{hyphenrules}}
\def\blx@opt@babel@other{\def\blx@babelenv{otherlanguage}}
\csdef{blx@opt@babel@other*}{\def\blx@babelenv{otherlanguage*}}

\define@key{blx@opt@pre}{indexing}[true]{%
  \ifcsdef{blx@opt@index@#1}
    {\csuse{blx@opt@index@#1}}
    {\blx@err@invopt{indexing=#1}}}
\def\blx@opt@index@true{%
  \toggletrue{blx@citindex}%
  \toggletrue{blx@bibindex}}
\def\blx@opt@index@false{%
  \togglefalse{blx@citindex}%
  \togglefalse{blx@bibindex}}
\def\blx@opt@index@cite{%
  \toggletrue{blx@citindex}%
  \togglefalse{blx@bibindex}}
\def\blx@opt@index@bib{%
  \togglefalse{blx@citindex}%
  \toggletrue{blx@bibindex}}

\define@key{blx@opt@pre}{sortcites}[true]{%
  \ifstrequal{#1}{true}
    {\let\blx@thecitesort\blx@citesort
     \let\blx@thenotecheck\blx@notecheck}
    {\let\blx@thecitesort\blx@citenosort
     \let\blx@thenotecheck\relax}}

\define@key{blx@opt@pre}{hyperref}[true]{%
  \ifcsdef{blx@opt@hyperref@#1}
    {\letcs\blx@hyperref{blx@opt@hyperref@#1}}
    {\blx@err@invopt{hyperref=#1}}}
\def\blx@opt@hyperref@false{0}
\def\blx@opt@hyperref@true{1}
\def\blx@opt@hyperref@auto{2}

\define@key{blx@opt@pre}{backref}[true]{%
  \ifstrequal{#1}{true}
    {\let\blx@backref\blx@backref@global
     \let\abx@aux@backref\blx@aux@backref}
    {\let\blx@backref\relax
     \let\abx@aux@backref\@gobblefour}}

\appto\blx@mkhyperref{%
  \ifHy@plainpages
    \blx@warning@noline{%
      hyperref package option 'plainpages' enabled.\MessageBreak
      This may cause problems with hyperlinked back\MessageBreak
      references. 'plainpages=false' is recommended}%
  \fi
  \ifHy@pageanchor\else
    \blx@warning@noline{%
      hyperref package option 'pageanchor' disabled.\MessageBreak
      This will cause problems with hyperlinked back\MessageBreak
      references. 'pageanchor=true' is required}%
  \fi}

\define@key{blx@opt@pre}{block}{%
  \ifcsdef{blx@opt@block@#1}
    {\csuse{blx@opt@block@#1}}
    {\blx@err@invopt{block=#1}}}
\def\blx@opt@block@none{%
  \let\blx@bibsetup\@empty
  \let\newblockpunct\@empty}
\def\blx@opt@block@par{%
  \let\blx@bibsetup\@empty
  \def\newblockpunct{\par}}
\def\blx@opt@block@nbpar{%
  \def\blx@bibsetup{\interlinepenalty\@M}%
  \def\newblockpunct{\par\nobreak}}
\def\blx@opt@block@space{%
  \let\blx@bibsetup\@empty
  \def\newblockpunct{%
    \unspace\space
    \hskip  0.11em
    \@plus  0.33em
    \@minus 0.07em}}
\def\blx@opt@block@ragged{%
  \let\blx@bibsetup\raggedright
  \def\newblockpunct{%
    \unspace\penalty-9\relax\space}}

\define@key{blx@opt@pre}{pagetracker}[true]{%
  \ifcsdef{blx@opt@pagetracker@#1}
    {\csuse{blx@opt@pagetracker@#1}}
    {\blx@err@invopt{pagetracker=#1}}}
\def\blx@opt@pagetracker@true{%
  \if@twoside
    \blx@opt@pagetracker@spread
  \else
    \blx@opt@pagetracker@page
  \fi}
\def\blx@opt@pagetracker@false{%
  \let\blx@pagetracker\relax
  \let\abx@aux@page\@gobbletwo
  \let\abx@aux@fnpage\@gobbletwo
  \boolfalse{pagetracker}}
\def\blx@opt@pagetracker@page{%
  \let\blx@pagetracker\blx@pagetracker@context
  \let\abx@aux@page\blx@aux@page
  \let\abx@aux@fnpage\blx@aux@fnpage
  \booltrue{pagetracker}}
\def\blx@opt@pagetracker@spread{%
  \if@twoside
    \let\blx@pagetracker\blx@pagetracker@context
    \let\abx@aux@page\blx@aux@spread
    \let\abx@aux@fnpage\blx@aux@fnspread
    \booltrue{pagetracker}%
  \else
    \blx@warning@noline{%
      LaTeX not in twoside mode\MessageBreak
      Falling back to 'pagetracker=page'}%
    \blx@opt@pagetracker@page
  \fi}

\define@key{blx@opt@pre}{citetracker}[true]{%
  \ifcsdef{blx@opt@citetracker@#1}
    {\csuse{blx@opt@citetracker@#1}}
    {\blx@err@invopt{citetracker=#1}}}
\def\blx@opt@citetracker@true{%
  \let\blx@imc@ifciteseen\blx@imc@ifciteseen@global
  \let\blx@imc@ifentryseen\blx@imc@ifentryseen@global
  \let\blx@citetracker\blx@citetracker@global
  \booltrue{citetracker}}
\def\blx@opt@citetracker@false{%
  \let\blx@imc@ifciteseen\@secondoftwo
  \protected\long\def\blx@imc@ifentryseen##1##2##3{##3}%
  \let\blx@citetracker\relax}
\def\blx@opt@citetracker@context{%
  \let\blx@imc@ifciteseen\blx@imc@ifciteseen@context
  \let\blx@imc@ifentryseen\blx@imc@ifentryseen@context
  \let\blx@citetracker\blx@citetracker@context
  \booltrue{citetracker}}
\def\blx@opt@citetracker@strict{%
  \let\blx@imc@ifciteseen\blx@imc@ifciteseen@global
  \let\blx@imc@ifentryseen\blx@imc@ifentryseen@global
  \def\blx@citetracker{%
    \blx@ifcitesingle{\blx@citetracker@global}{}}%
  \booltrue{citetracker}}
\def\blx@opt@citetracker@constrict{%
  \let\blx@imc@ifciteseen\blx@imc@ifciteseen@context
  \let\blx@imc@ifentryseen\blx@imc@ifentryseen@context
  \def\blx@citetracker{%
    \blx@ifcitesingle{\blx@citetracker@context}{}}%
  \booltrue{citetracker}}

\define@key{blx@opt@pre}{ibidtracker}[true]{%
  \ifcsdef{blx@opt@ibidtracker@#1}
    {\csuse{blx@opt@ibidtracker@#1}}
    {\blx@err@invopt{ibidtracker=#1}}}
\def\blx@opt@ibidtracker@true{%
  \let\blx@imc@ifciteibid\blx@imc@ifciteibid@global
  \let\blx@ibidtracker\blx@ibidtracker@gobal
  \let\blx@ibidreset\blx@ibidreset@gobal
  \booltrue{citetracker}}
\def\blx@opt@ibidtracker@false{%
  \let\blx@imc@ifciteibid\@secondoftwo
  \let\blx@ibidtracker\relax
  \let\blx@ibidreset\relax}
\def\blx@opt@ibidtracker@context{%
  \let\blx@imc@ifciteibid\blx@imc@ifciteibid@context
  \let\blx@ibidtracker\blx@ibidtracker@context
  \let\blx@ibidreset\blx@ibidreset@context
  \booltrue{citetracker}}
\def\blx@opt@ibidtracker@strict{%
  \let\blx@imc@ifciteibid\blx@imc@ifciteibid@strict
  \let\blx@ibidtracker\blx@ibidtracker@strict
  \let\blx@ibidreset\blx@ibidreset@gobal
  \booltrue{citetracker}}
\def\blx@opt@ibidtracker@constrict{%
  \let\blx@imc@ifciteibid\blx@imc@ifciteibid@constrict
  \let\blx@ibidtracker\blx@ibidtracker@constrict
  \let\blx@ibidreset\blx@ibidreset@context
  \booltrue{citetracker}}

\define@key{blx@opt@pre}{idemtracker}[true]{%
  \ifcsdef{blx@opt@idemtracker@#1}
    {\csuse{blx@opt@idemtracker@#1}}
    {\blx@err@invopt{idemtracker=#1}}}
\def\blx@opt@idemtracker@true{%
  \let\blx@imc@ifciteidem\blx@imc@ifciteidem@global
  \let\blx@idemtracker\blx@idemtracker@gobal
  \let\blx@idemreset\blx@idemreset@gobal
  \booltrue{citetracker}}
\def\blx@opt@idemtracker@false{%
  \let\blx@imc@ifciteidem\@secondoftwo
  \let\blx@idemtracker\relax
  \let\blx@idemreset\relax}
\def\blx@opt@idemtracker@context{%
  \let\blx@imc@ifciteidem\blx@imc@ifciteidem@context
  \let\blx@idemtracker\blx@idemtracker@context
  \let\blx@idemreset\blx@idemreset@context
  \booltrue{citetracker}}
\def\blx@opt@idemtracker@strict{%
  \let\blx@imc@ifciteidem\blx@imc@ifciteidem@strict
  \let\blx@idemtracker\blx@idemtracker@strict
  \let\blx@idemreset\blx@idemreset@gobal
  \booltrue{citetracker}}
\def\blx@opt@idemtracker@constrict{%
  \let\blx@imc@ifciteidem\blx@imc@ifciteidem@constrict
  \let\blx@idemtracker\blx@idemtracker@constrict
  \let\blx@idemreset\blx@idemreset@context
  \booltrue{citetracker}}

\define@key{blx@opt@pre}{opcittracker}[true]{%
  \ifcsdef{blx@opt@opcittracker@#1}
    {\csuse{blx@opt@opcittracker@#1}}
    {\blx@err@invopt{opcittracker=#1}}}
\def\blx@opt@opcittracker@true{%
  \let\blx@imc@ifopcit\blx@imc@ifopcit@global
  \let\blx@opcittracker\blx@opcittracker@gobal
  \let\blx@opcitreset\blx@opcitreset@gobal
  \booltrue{citetracker}}
\def\blx@opt@opcittracker@false{%
  \let\blx@imc@ifopcit\@secondoftwo
  \let\blx@opcittracker\relax
  \let\blx@opcitreset\relax}
\def\blx@opt@opcittracker@context{%
  \let\blx@imc@ifopcit\blx@imc@ifopcit@context
  \let\blx@opcittracker\blx@opcittracker@context
  \let\blx@opcitreset\blx@opcitreset@context
  \booltrue{citetracker}}
\def\blx@opt@opcittracker@strict{%
  \let\blx@imc@ifopcit\blx@imc@ifopcit@strict
  \let\blx@opcittracker\blx@opcittracker@strict
  \let\blx@opcitreset\blx@opcitreset@gobal
  \booltrue{citetracker}}
\def\blx@opt@opcittracker@constrict{%
  \let\blx@imc@ifopcit\blx@imc@ifopcit@constrict
  \let\blx@opcittracker\blx@opcittracker@constrict
  \let\blx@opcitreset\blx@opcitreset@context
  \booltrue{citetracker}}

\define@key{blx@opt@pre}{loccittracker}[true]{%
  \ifcsdef{blx@opt@loccittracker@#1}
    {\csuse{blx@opt@loccittracker@#1}}
    {\blx@err@invopt{loccittracker=#1}}}
\def\blx@opt@loccittracker@true{%
  \let\blx@imc@ifloccit\blx@imc@ifloccit@global
  \let\blx@loccittracker\blx@loccittracker@gobal
  \let\blx@loccitreset\blx@loccitreset@gobal
  \booltrue{citetracker}}
\def\blx@opt@loccittracker@false{%
  \let\blx@imc@ifloccit\@secondoftwo
  \let\blx@loccittracker\relax
  \let\blx@loccitreset\relax}
\def\blx@opt@loccittracker@context{%
  \let\blx@imc@ifloccit\blx@imc@ifloccit@context
  \let\blx@loccittracker\blx@loccittracker@context
  \let\blx@loccitreset\blx@loccitreset@context
  \booltrue{citetracker}}
\def\blx@opt@loccittracker@strict{%
  \let\blx@imc@ifloccit\blx@imc@ifloccit@strict
  \let\blx@loccittracker\blx@loccittracker@strict
  \let\blx@loccitreset\blx@loccitreset@gobal
  \booltrue{citetracker}}
\def\blx@opt@loccittracker@constrict{%
  \let\blx@imc@ifloccit\blx@imc@ifloccit@constrict
  \let\blx@loccittracker\blx@loccittracker@constrict
  \let\blx@loccitreset\blx@loccitreset@context
  \booltrue{citetracker}}

\define@key{blx@opt@pre}{date}{%
  \ifcsundef{bibdate#1}
    {\blx@err@invopt{date=#1}}
    {\edef\bibdate{%
       \expandonce{\csname bibdate#1\endcsname}}}}

\define@key{blx@opt@pre}{urldate}{%
  \ifcsundef{biburldate#1}
    {\blx@err@invopt{urldate=#1}}
    {\edef\biburldate{%
       \expandonce{\csname biburldate#1\endcsname}}}}

\define@key{blx@opt@pre}{autocite}{%
  \ifcsundef{blx@acite@#1}
    {\blx@error
       {Autocite command '#1' undefined}
       {The autocite command '#1' has not been defined by
        the\MessageBreak selected citation style}}
    {\letcs\autocite{blx@acite@#1}%
     \letcs\autocites{blx@macite@#1}}}

\define@key{blx@opt@pre}{autopunct}[true]{%
  \ifstrequal{#1}{true}
    {\DeclareAutoPunctuation{.,;:!?}}
    {\DeclareAutoPunctuation{}}}

\define@key{blx@opt@pre}{punctfont}[true]{%
  \ifstrequal{#1}{true}
    {\let\blx@ifpuncthook\@firstoftwo}
    {\let\blx@ifpuncthook\@secondoftwo}}

\define@key{blx@opt@pre}{labelnumber}[true]{%
  \settoggle{blx@labelnumber}{#1}%
  \iftoggle{blx@labelnumber}
    {}
    {\KV@blx@opt@pre@defernums{false}}}

\define@key{blx@opt@pre}{labelalpha}[true]{%
  \settoggle{blx@labelalpha}{#1}}

\define@key{blx@opt@pre}{labelyear}[true]{%
  \settoggle{blx@labelyear}{#1}}

\define@key{blx@opt@pre}{uniquename}[true]{%
  \ifcsdef{blx@opt@uniquename@#1}
    {\letcs\blx@uniquename{blx@opt@uniquename@#1}}
    {\blx@err@invopt{uniquename=#1}}}
\def\blx@opt@uniquename@false{0}
\def\blx@opt@uniquename@true{1}
\def\blx@opt@uniquename@init{2}

\define@key{blx@opt@pre}{singletitle}[true]{%
  \settoggle{blx@singletitle}{#1}}

\define@key{blx@opt@pre}{defernums}[true]{%
  \settoggle{blx@defernums}{#1}%
  \iftoggle{blx@defernums}
    {\KV@blx@opt@pre@labelnumber{true}%
     \let\blx@thelabelnumber\blx@addlabelnumber
     \let\abx@aux@number\blx@aux@number}
    {\let\blx@thelabelnumber\relax
     \let\abx@aux@number\@gobblefour}}

\define@key{blx@opt@pre}{refsection}{%
  \ifcsdef{blx@opt@refsection@#1}
    {\letcs\blx@refhook@section{blx@opt@refsection@#1}}
    {\blx@err@invopt{refsection=#1}}}
\def\blx@opt@refsection@none{0}
\def\blx@opt@refsection@part{1}
\def\blx@opt@refsection@chapter{2}
\def\blx@opt@refsection@section{3}
\def\blx@opt@refsection@subsection{4}

\define@key{blx@opt@pre}{refsegment}{%
  \ifcsdef{blx@opt@refsegment@#1}
    {\letcs\blx@refhook@segment{blx@opt@refsegment@#1}}
    {\blx@err@invopt{refsegment=#1}}}
\def\blx@opt@refsegment@none{0}
\def\blx@opt@refsegment@part{1}
\def\blx@opt@refsegment@chapter{2}
\def\blx@opt@refsegment@section{3}
\def\blx@opt@refsegment@subsection{4}

\define@key{blx@opt@pre}{citereset}{%
  \ifcsdef{blx@opt@citereset@#1}
    {\letcs\blx@resethook{blx@opt@citereset@#1}}
    {\blx@err@invopt{citereset=#1}}}
\def\blx@opt@citereset@none{0}
\def\blx@opt@citereset@part{1}
\def\blx@opt@citereset@chapter{2}
\def\blx@opt@citereset@section{3}
\def\blx@opt@citereset@subsection{4}

% Entry options

\DeclareBibliographyOption{useprefix}[true]{%
  \settoggle{blx@useprefix}{#1}}
\DeclareEntryOption{useprefix}[true]{%
  \settoggle{blx@useprefix}{#1}}

\DeclareBibliographyOption{useauthor}[true]{%
  \settoggle{blx@useauthor}{#1}}
\DeclareEntryOption{useauthor}[true]{%
  \settoggle{blx@useauthor}{#1}}

\DeclareBibliographyOption{useeditor}[true]{%
  \settoggle{blx@useeditor}{#1}}
\DeclareEntryOption{useeditor}[true]{%
  \settoggle{blx@useeditor}{#1}}

\DeclareBibliographyOption{usetranslator}[true]{%
  \settoggle{blx@usetranslator}{#1}}
\DeclareEntryOption{usetranslator}[true]{%
  \settoggle{blx@usetranslator}{#1}}

\DeclareEntryOption{skipbib}[true]{%
  \settoggle{blx@skipbib}{#1}}
\DeclareEntryOption{skiplos}[true]{%
  \settoggle{blx@skiplos}{#1}}
\DeclareEntryOption{skiplab}[true]{%
  \settoggle{blx@skiplab}{#1}}
\DeclareEntryOption{dataonly}[true]{%
  \settoggle{blx@skipbib}{#1}%
  \settoggle{blx@skiplos}{#1}%
  \settoggle{blx@skiplab}{#1}}

% Legacy options

\define@key{blx@opt@pre}{bibtex8}[true]{%
  \ifstrequal{#1}{true}
    {\letcs\blx@backend{blx@backend@bibtex8}}
    {\letcs\blx@backend{blx@backend@bibtex}}}

\DeclareOption{openbib}{\setkeys{blx@opt@pre}{block=par}}

% Option processor/scheduler

\DeclareOption*{%
  \begingroup
  \def\blx@tempa#1=#2&{#1}%
  \edef\blx@tempa{%
    \expandafter\blx@tempa\CurrentOption=&}%
  \ifcsundef{KV@blx@opt@ldt@\blx@tempa}
    {\endgroup
     \eappto\blx@theoptions{\CurrentOption,}}
    {\edef\blx@tempa{\endgroup
       \noexpand\setkeys{blx@opt@ldt}{\CurrentOption}}%
     \blx@tempa}}

\def\blx@processoptions{%
  \ifundef\blx@theoptions
    {}
    {\begingroup
     \edef\blx@tempa{\endgroup
       \noexpand\setkeys{blx@opt@pre}{\blx@theoptions}}%
     \blx@tempa}}

% Set defaults

\setkeys{blx@opt@ldt}{style=numeric}
\setkeys{blx@opt@pre}{%
  sorting=nty,sortlos=los,sortcites=false,maxnames=3,minnames=1,
  maxitems=3,minitems=1,mincrossrefs=2,useauthor=true,useeditor=true,
  usetranslator=false,indexing=false,backref=false,abbreviate=true,
  pagetracker=false,ibidtracker=false,idemtracker=false,
  opcittracker=false,loccittracker=false,citetracker=false,
  block=none,babel=none,date=long,urldate=short,autopunct=true,
  punctfont=false,defernums=false,refsection=none,refsegment=none,
  citereset=none,hyperref=false,maxline=79}

% Process load-time options

\ProcessOptions*

%% Initial setup

% Restore catcodes

\def\do#1#2{\catcode`#1=#2\relax}\blx@catcodes
\undef\blx@catcodes
\let\do\noexpand

% Load citation and bibliography styles, configuration file

\input{biblatex.def}
\iftoggle{blx@natbib}
  {\blx@inputonce{bibnatex.def}{natbib compatibility}{}{}{}{}}
  {}
\RequireBibliographyStyle{\blx@bbxfile}
\RequireCitationStyle{\blx@cbxfile}
\blx@secinit
\citereset
\blx@inputonce{biblatex.cfg}{configuration file}{}{}{}{}

% Process preamble options

\blx@processoptions

% Deferred last minute setup

\csdef{blx@opt@refsection@none}{0}
\csdef{blx@opt@refsection@part}{1}
\csdef{blx@opt@refsection@chapter}{2}
\csdef{blx@opt@refsection@section}{3}
\csdef{blx@opt@refsection@subsection}{4}

\AtEndPreamble{%
  \iftoggle{blx@firstinits}
    {\ifx\blx@uniquename\blx@opt@uniquename@true
       \setkeys{blx@opt@pre}{uniquename=init}%
       \blx@warn@conflopt{%
         'firstinits' conflicts with 'uniquename=true'.\MessageBreak
         Setting 'uniquename=init'}%
     \fi}
    {}%
  \ifnum\blx@refhook@segment>\z@
    \ifnum\blx@refhook@segment>\blx@refhook@section\relax
    \else
      \blx@err@confopt{%
        The 'refsegment' option must point to a
        lower-level\MessageBreak document division
        than 'refsection'}%
      \def\blx@refhook@segment{0}%
    \fi
  \fi
  \ifcase\blx@refhook@segment
  \or % 1
    \ifundef\part
      {\blx@err@nodocdiv{part}}
      {\pretocmd\part{\newrefsegment}
         {}
	 {\blx@err@patch{\string\part}}}%
  \or % 2
    \ifundef\chapter
      {\blx@err@nodocdiv{chapter}}
      {\pretocmd\chapter{\newrefsegment}
         {}
	 {\blx@err@patch{\string\part}}}%
  \or % 3
    \ifundef\section
      {\blx@err@nodocdiv{section}}
      {\pretocmd\section{\newrefsegment}
         {}
	 {\blx@err@patch{\string\part}}}%
  \or % 4
    \ifundef\subsection
      {\blx@err@nodocdiv{subsection}}
      {\pretocmd\subsection{\newrefsegment}
         {}
	 {\blx@err@patch{\string\part}}}%
  \fi
  \ifcase\blx@refhook@section
  \or % 1
    \ifundef\part
      {\blx@err@nodocdiv{part}}
      {\pretocmd\part{\newrefsection}
         {}
	 {\blx@err@patch{\string\part}}}%
  \or % 2
    \ifundef\chapter
      {\blx@err@nodocdiv{chapter}}
      {\pretocmd\chapter{\newrefsection}
         {}
	 {\blx@err@patch{\string\part}}}%
  \or % 3
    \ifundef\section
      {\blx@err@nodocdiv{section}}
      {\pretocmd\section{\newrefsection}
         {}
	 {\blx@err@patch{\string\part}}}%
  \or % 4
    \ifundef\subsection
      {\blx@err@nodocdiv{subsection}}
      {\pretocmd\subsection{\newrefsection}
         {}
	 {\blx@err@patch{\string\part}}}%
  \fi
  \ifcase\blx@resethook
  \or % 1
    \ifundef\part
      {\blx@err@nodocdiv{part}}
      {\pretocmd\part{\citereset\blx@inf@creset}
         {}
	 {\blx@err@patch{\string\part}}}%
  \or % 2
    \ifundef\chapter
      {\blx@err@nodocdiv{chapter}}
      {\pretocmd\chapter{\citereset\blx@inf@creset}
         {}
	 {\blx@err@patch{\string\part}}}%
  \or % 3
    \ifundef\section
      {\blx@err@nodocdiv{section}}
      {\pretocmd\section{\citereset\blx@inf@creset}
         {}
	 {\blx@err@patch{\string\part}}}%
  \or % 4
    \ifundef\subsection
      {\blx@err@nodocdiv{subsection}}
      {\pretocmd\subsection{\citereset\blx@inf@creset}
         {}
	 {\blx@err@patch{\string\part}}}%
  \fi
  \ifnum\c@minnames>\c@maxnames
    \blx@err@confopt{%
      The value of 'minnames' must be smaller than\MessageBreak
      or equal to the value of 'maxnames'}%
    \c@minnames\c@maxnames
  \fi
  \ifnum\c@minitems>\c@maxitems
    \blx@err@confopt{%
      The value of 'minitems' must be smaller than\MessageBreak
      or equal to the value of 'maxitems'}%
    \c@minitems\c@maxitems
  \fi
  \@ifpackageloaded{inputenc}
    {\ifundef\inputencodingname % inputenc 2006/05/05 v1.1b
       {\begingroup
	\def\@inpenc@undefined@#1{\gdef\blx@inputenc{#1}}%
	\@inpenc@undefined
	\endgroup}
       {\let\blx@inputenc\inputencodingname}%
     \ifdef\blx@bibencoding
       {\iftoggle{blx@recode}
	  {\blx@info@noline{%
             Input encoding '\blx@bibencoding' specified}}
	  {\blx@info@noline{%
             Input encoding '\blx@inputenc' detected}%
	   \let\blx@bibencoding\blx@inputenc}}
       {}}
    {\ifdef\blx@bibencoding
       {\blx@error
	  {Package 'inputenc' not loaded}
	  {The 'bibencoding' option depends on 'inputenc'}%
	\undef\blx@bibencoding
	\togglefalse{blx@recode}}
       {}}}

\begingroup
\let~\space
\xdef\blx@ctrl@bibtex{%
  \blx@msg@bib
  @Control\string{biblatex-control,\blx@nl
  ~~ctrl-options~~~~~=~\string{%
    \noexpand\blx@version:%
    \noexpand\iftoggle{blx@debug}{1}{0}:%
    \noexpand\ifnum\noexpand\blx@backend=\csuse{blx@backend@bibtex8}%
      1:%
    \noexpand\else
      0:%
    \noexpand\fi
    \noexpand\iftoggle{blx@terseinits}{1}{0}:%
    \noexpand\iftoggle{blx@useprefix}{1}{0}:%
    \noexpand\iftoggle{blx@useauthor}{1}{0}:%
    \noexpand\iftoggle{blx@useeditor}{1}{0}:%
    \noexpand\iftoggle{blx@usetranslator}{1}{0}:%
    \noexpand\iftoggle{blx@labelalpha}{1}{0}:%
    \noexpand\iftoggle{blx@labelyear}{1}{0}:%
    \noexpand\iftoggle{blx@singletitle}{1}{0}:%
    \noexpand\blx@uniquename:%
    \noexpand\csuse{blx@opt@sorting@\noexpand\blx@sorting}:%
    \noexpand\blx@sortlos:%
    \noexpand\the\c@maxnames:%
    \noexpand\the\c@minnames:%
    \noexpand\blx@maxline:%
    \noexpand\detokenize\noexpand\expandafter{\noexpand\labelalphaothers}%
  \string},\blx@nl
  \string}%
}
\endgroup

\begingroup
\let~\space
\@makeother\<
\@makeother\>
\@makeother\.
\@makeother\:
\@makeother\?
\@makeother\"
\@makeother\-
\@makeother\/
\xdef\blx@bcf@file#1{%
  <?xml version="1.0" encoding="UTF-8"?>\blx@nl
  <?oxygen RNGSchema="../data/schemas/bcf2.rnc" type="compact"?>\blx@nl
  <bcf:controlfile version="\noexpand\blx@version"
  xmlns:bcf="https://sourceforge.net/projects/biblatex">\blx@nl
  #1%
  </bcf:controlfile>}
\xdef\blx@bcf@comment#1{%
  ~~<!-- #1 -->\blx@nl}
\xdef\blx@bcf@options#1#2#3{%
  ~~<bcf:options%
    \noexpand\ifblank{#1}{}{ component="#1"}%
    \noexpand\ifblank{#2}{}{ type="#2"}%
  >\blx@nl
  #3%
  ~~</bcf:options>\blx@nl}
\xdef\blx@bcf@option#1#2{%
  ~~~~<bcf:option type="#1">\blx@nl
  #2%
  ~~~~</bcf:option>\blx@nl}
\xdef\blx@bcf@keyvalue#1#2{%
  ~~~~~~<bcf:key>#1</bcf:key>\blx@nl
  ~~~~~~<bcf:value>#2</bcf:value>\blx@nl
}
\xdef\blx@bcf@keymulti#1#2{%
  ~~~~~~<bcf:key>#1</bcf:key>\blx@nl
  #2}
\xdef\blx@bcf@ordered#1#2{%
  ~~~~~~<bcf:value order="#1">#2</bcf:value>\blx@nl}
\xdef\blx@bcf@sorting#1#2{%
  ~~<bcf:sorting type="#1">\blx@nl
  #2%
  ~~</bcf:sorting>\blx@nl}
\xdef\blx@bcf@sort#1#2{%
  ~~~~<bcf:sort #1>\blx@nl
  #2%
  ~~~~</bcf:sort>\blx@nl}
\xdef\blx@bcf@sortitem#1#2{%
  ~~~~~~<bcf:sortitem #1>#2</bcf:sortitem>\blx@nl}
\endgroup

\newrobustcmd*{\DeclareSortingScheme}[2]{%
  \begingroup
  \let\item\blx@sortdef@item
  \let\field\blx@sortdef@field
  \let\literal\blx@sortdef@literal
  \@tempcnta\z@
  \let\blx@tempa\@empty
  #2%
  \csxdef{blx@bcf@scheme@#1}{\blx@bcf@sorting{global}{\blx@tempa}}%
  \endgroup}
\@onlypreamble\DeclareSortingScheme

\def\blx@sortdef@item#1{%
  \advance\@tempcnta\@ne
  \@tempcntb\z@
  \let\blx@tempb\@empty
  \let\do\@firstofone
  #1%
  \eappto\blx@tempa{%
    \blx@bcf@sort{order="\the\@tempcnta"}{\blx@tempb}}}

\newcommand*{\blx@sortdef@field}[2][]{%
  \advance\@tempcntb\@ne
  \edef\blx@tempc{order="\the\@tempcntb"}%
  \ifblank{#1}
    {}
    {\setkeys{blx@sortdef@field}{#1}}%
  \eappto\blx@tempb{%
    \blx@bcf@sortitem{\blx@tempc}{#2}}}

\define@key{blx@sortdef@field}{final}[true]{%
  \ifstrequal{#1}{true}
    {\appto\blx@tempc{ final="1"}}
    {}}
\define@key{blx@sortdef@field}{pass}{% label|final
  \appto\blx@tempc{ pass="#1"}}
\define@key{blx@sortdef@field}{direction}{% ascending|descending
  \appto\blx@tempc{ sort_direction="#1"}}
\define@key{blx@sortdef@field}{strside}{% left|right
  \appto\blx@tempc{ substring_side="#1"}}
\define@key{blx@sortdef@field}{strwidth}{% integer
  \appto\blx@tempc{ substring_width="#1"}}
\define@key{blx@sortdef@field}{padside}{% left|right
  \appto\blx@tempc{ pad_side="#1"}}
\define@key{blx@sortdef@field}{padwidth}{% integer
  \appto\blx@tempc{ pad_width="#1"}}
\define@key{blx@sortdef@field}{padchar}{% character
  \appto\blx@tempc{ pad_char="#1"}}

\def\blx@sortdef@literal#1{%
  \advance\@tempcntb\@ne
  \eappto\blx@tempb{%
    \blx@bcf@sortitem{order="\the\@tempcntb"}{#1}}}

\DeclareSortingScheme{none}{%
  \item{\field{citeorder}}
}

\DeclareSortingScheme{debug}{%
  \item{\field{entrykey}}
}

\DeclareSortingScheme{nty}{%
  \item{\field[strside=left,strwidth=2]{presort}
        \literal{mm}}
  \item{\field[final]{sortkey}}
  \item{\field{sortname}
	\field{author}
	\field{editor}
	\field{translator}
	\field{sorttitle}
	\field{title}}
  \item{\field{sorttitle}
        \field{title}}
  \item{\field[strside=left,strwidth=4]{sortyear}
        \field[strside=left,strwidth=4]{year}}
  \item{\field[padside=left,padwidth=4,padchar=0]{volume}
        \literal{0000}}
}

\DeclareSortingScheme{nyt}{%
  \item{\field[strside=left,strwidth=2]{presort}
        \literal{mm}}
  \item{\field[final]{sortkey}}
  \item{\field{sortname}
	\field{author}
	\field{editor}
	\field{translator}
	\field{sorttitle}
	\field{title}}
  \item{\field[strside=left,strwidth=4]{sortyear}
        \field[strside=left,strwidth=4]{year}}
  \item{\field{sorttitle}
        \field{title}}
  \item{\field[padside=left,padwidth=4,padchar=0]{volume}
        \literal{0000}}
}

\DeclareSortingScheme{nyvt}{%
  \item{\field[strside=left,strwidth=2]{presort}
        \literal{mm}}
  \item{\field[final]{sortkey}}
  \item{\field{sortname}
	\field{author}
	\field{editor}
	\field{translator}
	\field{sorttitle}
	\field{title}}
  \item{\field[strside=left,strwidth=4]{sortyear}
        \field[strside=left,strwidth=4]{year}}
  \item{\field[padside=left,padwidth=4,padchar=0]{volume}
        \literal{0000}}
  \item{\field{sorttitle}
        \field{title}}
}

\DeclareSortingScheme{anyt}{%
  \item{\field[strside=left,strwidth=2]{presort}
        \literal{mm}}
  \item{\field[pass=label]{labelalpha}}
  \item{\field[final]{sortkey}}
  \item{\field[pass=final]{labelalpha}}
  \item{\field[pass=final,padside=left,padwidth=4,padchar=0]{extraalpha}}
  \item{\field{sortname}
	\field{author}
	\field{editor}
	\field{translator}
	\field{sorttitle}
	\field{title}}
  \item{\field[strside=left,strwidth=4]{sortyear}
        \field[strside=left,strwidth=4]{year}}
  \item{\field{sorttitle}
        \field{title}}
  \item{\field[padside=left,padwidth=4,padchar=0]{volume}
        \literal{0000}}
}

\DeclareSortingScheme{anyvt}{%
  \item{\field[strside=left,strwidth=2]{presort}
        \literal{mm}}
  \item{\field[pass=label]{labelalpha}}
  \item{\field[final]{sortkey}}
  \item{\field[pass=final]{labelalpha}}
  \item{\field[pass=final,padside=left,padwidth=4,padchar=0]{extraalpha}}
  \item{\field{sortname}
	\field{author}
	\field{editor}
	\field{translator}
	\field{sorttitle}
	\field{title}}
  \item{\field[strside=left,strwidth=4]{sortyear}
        \field[strside=left,strwidth=4]{year}}
  \item{\field[padside=left,padwidth=4,padchar=0]{volume}
        \literal{0000}}
  \item{\field{sorttitle}
        \field{title}}
}

\DeclareSortingScheme{ynt}{%
  \item{\field[strside=left,strwidth=2]{presort}
        \literal{mm}}
  \item{\field[final]{sortkey}}
  \item{\field[strside=left,strwidth=4]{sortyear}
        \field[strside=left,strwidth=4]{year}
        \literal{9999}}
  \item{\field{sortname}
	\field{author}
	\field{editor}
	\field{translator}
	\field{sorttitle}
	\field{title}}
  \item{\field{sorttitle}
        \field{title}}
}

\DeclareSortingScheme{ydnt}{%
  \item{\field[strside=left,strwidth=2]{presort}
        \literal{mm}}
  \item{\field[final]{sortkey}}
  \item{\field[strside=left,strwidth=4,direction=descending]{sortyear}
        \field[strside=left,strwidth=4,direction=descending]{year}
        \literal{9999}}
  \item{\field{sortname}
	\field{author}
	\field{editor}
	\field{translator}
	\field{sorttitle}
	\field{title}}
  \item{\field{sorttitle}
        \field{title}}
}

\def\blx@ctrl@biber{%
  \blx@sig@bcf\blx@nl
  \blx@ver@bcf\blx@nl
  \blx@bcf@file{%
    \blx@bcf@comment{options: biber}%
    \blx@bcf@options{biber}{global}{%
      \blx@bcf@option{singlevalued}{%
	\blx@bcf@keyvalue{bibencoding}{\ifdef\blx@bibencoding{\blx@bibencoding}{ascii}}%
      }%
      \blx@bcf@option{singlevalued}{%
	\blx@bcf@keyvalue{debug}{\iftoggle{blx@debug}{1}{0}}%
      }%
      \blx@bcf@option{singlevalued}{%
	\blx@bcf@keyvalue{inputenc}{\ifdef\blx@inputenc{\blx@inputenc}{ascii}}%
      }%
      \blx@bcf@option{singlevalued}{%
	\blx@bcf@keyvalue{mincrossrefs}{\blx@mincrossrefs}%
      }%
    }%
    \blx@bcf@comment{options: biblatex}%
    \blx@bcf@options{biblatex}{global}{%
      \blx@bcf@option{singlevalued}{%
	\blx@bcf@keyvalue{alphaothers}{\detokenize\expandafter{\labelalphaothers}}%
      }%
      \blx@bcf@option{singlevalued}{%
	\blx@bcf@keyvalue{labelalpha}{\iftoggle{blx@labelalpha}{1}{0}}%
      }%
      \blx@bcf@option{multivalued}{%
	\blx@bcf@keymulti{labelname}{\blx@bcf@labelname@global}%
      }%
      \blx@bcf@option{singlevalued}{%
	\blx@bcf@keyvalue{labelyear}{\iftoggle{blx@labelyear}{1}{0}}%
      }%
      \blx@bcf@option{singlevalued}{%
	\blx@bcf@keyvalue{maxnames}{\the\c@maxnames}%
      }%
      \blx@bcf@option{singlevalued}{%
	\blx@bcf@keyvalue{minnames}{\the\c@minnames}%
      }%
      \blx@bcf@option{singlevalued}{%
	\blx@bcf@keyvalue{singletitle}{\iftoggle{blx@singletitle}{1}{0}}%
      }%
      \blx@bcf@option{singlevalued}{%
	\blx@bcf@keyvalue{sortalphaothers}{\detokenize\expandafter{\labelalphaothers}}%
      }%
      \blx@bcf@option{singlevalued}{%
	\blx@bcf@keyvalue{sortlos}{\blx@sortlos}%
      }%
      \blx@bcf@option{singlevalued}{%
	\blx@bcf@keyvalue{terseinits}{\iftoggle{blx@terseinits}{1}{0}}%
      }%
      \blx@bcf@option{singlevalued}{%
	\blx@bcf@keyvalue{uniquename}{\blx@uniquename}%
      }%
      \blx@bcf@option{singlevalued}{%
	\blx@bcf@keyvalue{useauthor}{\iftoggle{blx@useauthor}{1}{0}}%
      }%
      \blx@bcf@option{singlevalued}{%
	\blx@bcf@keyvalue{useeditor}{\iftoggle{blx@useeditor}{1}{0}}%
      }%
      \blx@bcf@option{singlevalued}{%
	\blx@bcf@keyvalue{useprefix}{\iftoggle{blx@useprefix}{1}{0}}%
      }%
      \blx@bcf@option{singlevalued}{%
	\blx@bcf@keyvalue{usetranslator}{\iftoggle{blx@usetranslator}{1}{0}}%
      }%
    }%
    \blx@bcf@comment{sorting}%
    \csuse{blx@bcf@scheme@\blx@sorting}%
  }%
}

\newrobustcmd*{\DeclareLabelname}[1]{%
  \begingroup
  \global\let\blx@bcf@labelname@global\@empty
  \@tempcnta\z@
  \def\do##1{%
    \advance\@tempcnta\@ne
    \xappto\blx@bcf@labelname@global{%
      \noexpand\blx@bcf@ordered{\the\@tempcnta}{##1}}}%
  \docsvlist{#1}%
  \endgroup}
\@onlypreamble\DeclareLabelname

\DeclareLabelname{%
  shortauthor,
  author,
  shorteditor,
  editor,
  translator}

\AtBeginDocument{%
  \if@filesw
    \blx@auxinit{\blx@bibfiles}%
    \ifnum\blx@backend=\blx@backend@biber
      \blx@ifsigned{\jobname}{bcf}
	{\immediate\openout\blx@auxout \jobname.bcf\relax
	 \immediate\write\blx@auxout{\blx@ctrl@biber}%
	 \immediate\closeout\blx@auxout}
	{}%
    \else
      \blx@ifsigned{\blx@ctrlfile\blxauxsuffix}{bib}
	{\immediate\openout\blx@auxout \blx@ctrlfile\blxauxsuffix.bib\relax
	 \immediate\write\blx@auxout{\blx@ctrl@bibtex}%
	 \immediate\closeout\blx@auxout}
	{}%
    \fi
    \blx@bblinput
    \blx@maxsection\z@
  \fi
  \csuse{abx@preamble}%
  \blx@inf@refsec
  \blx@inf@refseg}

\AtEndOfPackage{%
  \AtBeginDocument{%
    \let\do\undef
    \blx@dopreamblecmds
    \let\do\noexpand}}

\endinput
