% $Id: biblatex.sty,v 0.7g 2008/04/26 18:00:00 lehman beta $

% Copyright (c) 2006-2008 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\blx@rcsid$#1: #2 #3 #4 #5${#4 v#3}
\def\blx@bbxid$#1: #2 #3 #4 #5${#4 v#3 biblatex bibliography style}
\def\blx@cbxid$#1: #2 #3 #4 #5${#4 v#3 biblatex citation style}
\def\blx@lbxid$#1: #2 #3 #4 #5${#4 v#3 biblatex localization}

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{biblatex}
[\blx@rcsid $Id: biblatex.sty,v 0.7g 2008/04/26 18:00:00 lehman beta $
 programmable bibliographies]

%% Compatibility and requirements

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

\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{%
    babelbib,backref,bibtopic,bibunits,chapterbib,cite,citeref,%
    inlinebib,jurabib,mlbib,multibib,natbib,splitbib}%
  \@ifpackageloaded{babel}
    {\blx@mkbabel}
    {\blx@mknobabel}%
  \csuse{bib@extras@\blx@languagename}%
  \csuse{bib@strings@\blx@languagename}%
  \undef\blx@mkbabel
  \undef\blx@mknobabel
  \ifblx@hyperref
    \@ifpackageloaded{hyperref}
      {\blx@mkhyperref}
      {\blx@mknohyperref}%
  \else
    \blx@mknohyperref
  \fi
  \undef\blx@mkhyperref
  \undef\blx@mknohyperref
  \ifundef\TE@hook
    {\let\TE@hook\@empty
     \blx@tempswatrue
     \def\do#1{%
       \patchcmd#1%
	 {\let\isundefined\TE@undef}
	 {\let\isundefined\TE@undef\TE@hook}
	 {\blx@tempswafalse\listbreak}
	 {}}%
     \docsvlist{%
       \ifthenelse,%          ifthen
       \org@ifthenelse,%      babel
       \HyOrg@ifthenelse,%    hyperref
       \NROrg@ifthenelse}%    nameref
     \ifblx@tempswa\blx@err@patch{'ifthen' package}\fi}
    {}%
  \appto\TE@hook{\blx@TE@hook}%
  \blx@tempswatrue
  \def\do#1{%
    \patchcmd#1%
      {\color@begingroup}
      {\color@begingroup\blx@footnotetrue}
      {\blx@tempswafalse\listbreak}
      {}}%
  \docsvlist{%
    \@footnotetext,%          latex
    \H@@footnotetext,%        hyperref
    \@fntORI}%                frenchle
  \@ifclassloaded{memoir}
    {\blx@tempswafalse
     \def\do#1{%              memoir
       \patchcmd#1%
	 {\color@begingroup}
	 {\color@begingroup\blx@footnotetrue}
	 {}
	 {\blx@tempswatrue}}%
     \docsvlist{%
       \m@mold@footnotetext,%
       \@twocolfootnotetext,%
       \@threecolfootnotetext,%
       \@parafootnotetext}}
    {}%
  \ifblx@tempswa\blx@warn@patch{footnotes}\fi
  \@ifpackageloaded{endnotes}
    {\patchcmd\theendnotes
       {\enoteformat}
       {\blx@footnotetrue\enoteformat}
       {}
       {\blx@err@patch{'endnotes' package}}}
    {}%
  \@ifpackageloaded{showkeys}
    {\ifundef\SK@cite % 'notcite' option disabled
       {\AtEveryBibitem{\SK@\SK@@label{\thefield{entrykey}}}%
        \AtEveryLositem{\SK@\SK@@label{\thefield{entrykey}}}%
        \AtEveryCitekey{\SK@\SK@@ref{\thefield{entrykey}}}}
       {}}
    {}%
  \@ifpackageloaded{csquotes}
    {\@ifpackagelater{csquotes}{2008/01/05}
       {}
       {\blx@warning@noline{%
          Upgrading to 'csquotes' version 3.8\MessageBreak
	  or later recommended. I found:\MessageBreak
	  '\@nameuse{ver@csquotes.sty}'}}}
    {\@ifpackageloaded{babel}
       {\blx@warning@noline{%
          'babel' detected but 'csquotes' not\MessageBreak
	  loaded. Loading 'csquotes' version 3.8\MessageBreak
	  or later recommended}}
       {}%
     \newrobustcmd*{\enquote}{\@ifstar\blx@senquote\blx@enquote}%
     \long\def\blx@enquote#1{``#1''}%
     \long\def\blx@senquote#1{`#1'}}%
  \ifundef\BlockquoteDisable
    {}
    {\BlockquoteDisable{\let\blx@thecheckpunct\@gobble}}%
  \ifundef\csq@setsfcodes
    {\let\blx@csqsetsfcodes\relax}
    {\def\blx@csqsetsfcodes{\csq@setsfcodes}}%
  \ifundef\csq@kernmark
    {}
    {\def\blx@csqmarkcheck{%
       \ifdim\lastskip=\csq@kernmark\relax
	 \expandafter\@gobble
       \else
	 \expandafter\@firstofone
       \fi}}
  \providecommand*{\nolinkurl}{\url}%
  \let\do\noexpand}

% koma
\newcommand{\ifkomabibtotoc}[2]{#2}
\newcommand{\ifkomabibtotocnumbered}[2]{#2}
\ifdef\ds@bibtotoc
  {\DeclareOption{bibtotoc}{%
     \let\ifkomabibtotoc\@firstoftwo}%
   \DeclareOption{bibtotocnumbered}{%
     \let\ifkomabibtotoc\@firstoftwo
     \let\ifkomabibtotocnumbered\@firstoftwo}}
  {}

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

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

%% 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{\do\&\do\|\blx@docatcodes}

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

\blx@saneccodes
\catcode`\&=3
\catcode`\|=3

%% 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{abbrvpenalty}
\def\theabbrvpenalty{\the\c@abbrvpenalty}
\newcounter{lownamepenalty}
\def\thelownamepenalty{\the\c@lownamepenalty}
\newcounter{highnamepenalty}
\def\thehighnamepenalty{\the\c@highnamepenalty}

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

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

\newif\ifcitetracker
\newif\ifpagetracker

\newif\ifblx@labelnumber
\newif\ifblx@labelalpha
\newif\ifblx@xbibtex
\newif\ifblx@useprefix
\newif\ifblx@useauthor
\newif\ifblx@useeditor
\newif\ifblx@hyperref
\newif\ifblx@block
\newif\ifblx@unit
\newif\ifblx@insert
\newif\ifblx@lastins
\newif\ifblx@footnote
\newif\ifblx@defernums
\newif\ifblx@tempswa
\newif\ifblx@tempswb

\def\blx@debug{0}
\def\blx@labelyear{0}
\def\blx@singletitle{0}
\def\blx@uniquename{0}
\def\blx@terseinits{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

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

\def\blx@secinit{%
  \ifcsundef{blx@all@\the\c@refsection}
    {\global\cslet{blx@all@\the\c@refsection}\@empty}
    {}%
  \ifcsundef{blx@see@\the\c@refsection}
    {\global\cslet{blx@see@\the\c@refsection}\@empty}
    {}%
  \ifcsundef{blx@fns@\the\c@refsection}
    {\global\cslet{blx@fns@\the\c@refsection}\@empty}
    {}%
  \blx@ibidreset@force
  \blx@opcitreset@force
  \blx@loccitreset@force
  \ifcsundef{blx@seg@\the\c@refsection @\the\c@refsegment}
    {\global\cslet{blx@seg@\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@docsvfield#1{%
  \blx@iffieldundef{#1}
    {}
    {\expandafter\expandafter\expandafter\docsvlist
     \expandafter\expandafter\expandafter{%
       \csname bib@field@#1\endcsname}}}

\appto\blx@blxinit{%
  \let\blx@blxinit\relax
  \let\docsvfield\blx@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
    \string\bibstyle{biblatex}%
    \expandafter\ifblank
    \expandafter{#1}
      {}
      {^^J\string\bibdata{\jobname\blxauxsuffix,#1}%
       ^^J\string\citation{biblatex-control}}}}

% {<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@sig@aux{%
  \@percentchar\space $ biblatex auxiliary file $}
\let\blx@sig@bbl\blx@sig@aux
\begingroup
\def\blx@tempa$#1: #2 ${#2}
\xdef\blx@ver@bib{%
  @Comment{$ biblatex version \blx@tempa$Revision: 0.7 $ $}}
\xdef\blx@ver@aux{%
  \@percentchar\space
  $ biblatex version \blx@tempa$Revision: 0.7 $ $}
\endgroup
\let\blx@ver@bbl\blx@ver@aux


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

%% 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\bib@field@entrykey
    {\blx@warning{#1}}
    {\blx@warning{#1\MessageBreak at entry '\bib@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}

\appto\blx@blxinit{%
  \let\BibliographyWarning\blx@warning@entry}

\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@invldopt#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@conflopt#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\bib@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@patch#1{%
  \blx@warning@noline{%
    Patching #1 failed.\MessageBreak This is an internal issue
    typically caused\MessageBreak by a conflict between
    biblatex and some\MessageBreak other package. Modifying the
    package\MessageBreak loading order may fix the problem}}

\protected\def\bib@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@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@request@latex{\typeout{REQ:1:latex:REQ}}
\def\blx@request@bibtex#1{%
  \begingroup
  \edef\blx@tempa{\endgroup
    \noexpand\typeout{REQ:2:bibtex:^^J%
      binary=bibtex\ifblx@xbibtex 8\fi^^J%
      \ifundef\blx@mincrossrefs
        {}
        {\ifblx@xbibtex
           option=--min\string_crossrefs \blx@mincrossrefs^^J%
         \else
           option=-min-crossrefs=\blx@mincrossrefs^^J%
         \fi}%
      \ifundef\blx@bibencoding
        {}
        {\ifblx@xbibtex
           option=--csfile \blx@bibencoding.csf^^J%
         \fi}%
      infile=#1^^J:REQ}}%
  \blx@tempa}

\let\blx@auxlist\@empty
\def\blx@reqauxfile{%
  \xifinlist{\blx@auxfile.aux}{\blx@auxlist}
    {}
    {\listxadd\blx@auxlist{\blx@auxfile.aux}%
     \blx@request@bibtex{\blx@auxfile}}%
  \blx@reruntrue}

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

\def\blx@warn@auxlist{%
  \begingroup
  \def\blx@tempa{Please (re)run BibTeX 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@request@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\bib@aux@checksum\relax

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

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

\AfterEndDocument{\blx@checksum}

%% Punctuation and capitalization

%   99       new paragaph
% 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

\mathchardef\blx@sf@par=99
\mathchardef\blx@sf@apo=1001
\mathchardef\blx@sf@dot=1002
\mathchardef\blx@sf@com=1003
\mathchardef\blx@sf@sem=1004
\mathchardef\blx@sf@col=1005
\mathchardef\blx@sf@per=1006
\mathchardef\blx@sf@emk=1007
\mathchardef\blx@sf@qmk=1008
\mathchardef\blx@sf@nop=1009

\csedef{blx@sf@1250}{\the\blx@sf@com}
\csedef{blx@sf@1500}{\the\blx@sf@sem}
\csedef{blx@sf@2000}{\the\blx@sf@col}
\csedef{blx@sf@3000}{\the\blx@sf@per}
\csedef{blx@sf@3001}{\the\blx@sf@emk}
\csedef{blx@sf@3002}{\the\blx@sf@qmk}

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

\def\blx@setfrcodes{%
  \ifnum\sfcode`\A=\@m
  \else
    \blx@setazcodes
  \fi
  \sfcode`\,=\blx@sf@com
  \sfcode`\;=\blx@sf@sem
  \sfcode`\:=\blx@sf@col
  \sfcode`\.=\blx@sf@per
  \sfcode`\!=\blx@sf@emk
  \sfcode`\?=\blx@sf@qmk
}

\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@resetpunct{%
  \cslet{blx@capstr@\the\blx@sf@par}\@empty
  \cslet{blx@capstr@\the\blx@sf@com}\@undefined
  \cslet{blx@capstr@\the\blx@sf@sem}\@undefined
  \cslet{blx@capstr@\the\blx@sf@col}\@undefined
  \cslet{blx@capstr@\the\blx@sf@per}\@empty
  \cslet{blx@capstr@\the\blx@sf@emk}\@empty
  \cslet{blx@capstr@\the\blx@sf@qmk}\@empty
  \def\bib@period{\unkern\bib@punctfont{.}}%
  \def\bib@comma{\unkern\bib@punctfont{,}}%
  \def\bib@semicolon{\bib@punctfont{;}}%
  \def\bib@colon{\bib@punctfont{:}}%
  \def\bib@exclam{\bib@punctfont{!}}%
  \def\bib@question{\bib@punctfont{?}}%
  \blx@resetpunctfont}

\protected\def\blx@punctfont@set#1{%
  \protected\gdef\bib@punctfont{\unkern\blx@punctfont@reset#1}}
\protected\def\blx@punctfont@reset{%
  \global\let\bib@punctfont\@firstofone}

\let\blx@setpunctfont\blx@punctfont@set
\let\blx@resetpunctfont\blx@punctfont@reset
\blx@resetpunct

% {<character>}

\newrobustcmd*{\EnableCapitalAfter}{%
  \blx@defcapstring\@empty}
\newrobustcmd*{\DisableCapitalAfter}{%
  \blx@defcapstring\@undefined}

\def\blx@defcapstring#1#2{%
  \begingroup
  \blx@setfrcodes
  \expandafter\endgroup
  \expandafter\let
  \csname blx@capstr@\the\sfcode`#2\endcsname#1}

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

\protected\def\blx@ifpunctmark#1{%
  \ifhmode
    \ifnum\sfcode`#1=\spacefactor
      \expandafter\expandafter
      \expandafter\@firstoftwo
    \else
      \expandafter\expandafter
      \expandafter\@secondoftwo
    \fi
  \else
    \expandafter\@secondoftwo
  \fi}

% {<true>}{<false>}

\protected\def\blx@ifterm{%
  \ifhmode
    \ifcsundef{blx@capstr@\blx@spacefactor}
      {\expandafter\@secondoftwo}
      {\expandafter\@firstoftwo}%
  \else
    \expandafter\@secondoftwo
  \fi}

% {<true>}{<false>}

\protected\def\blx@ifcapital{%
  \ifcsundef{blx@capstr@\blx@spacefactor}
    {\@secondoftwo}
    {\@firstoftwo}}

% {<true>}{<false>}

\protected\def\blx@ifpunct{%
  \ifnum\blx@spacefactor>\blx@sf@dot
    \ifnum\blx@spacefactor=\blx@sf@nop
      \expandafter\expandafter
      \expandafter\@secondoftwo
    \else
      \expandafter\expandafter
      \expandafter\@firstoftwo
    \fi
  \else
    \expandafter\@secondoftwo
  \fi}

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

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

\protected\def\blx@adddot{%
  \ifnum\blx@spacefactor<\blx@sf@dot
    \unspace\bib@period
    \leavevmode\spacefactor\blx@sf@dot
  \else\ifnum\blx@spacefactor=\blx@sf@per
    \unspace\spacefactor\blx@sf@dot
  \fi\fi}

\protected\def\blx@addperiod{%
  \ifnum\blx@spacefactor<\blx@sf@dot
    \unspace\bib@period
  \else\ifnum\blx@spacefactor=\blx@sf@dot
    \unspace\spacefactor\blx@sf@per
  \fi\fi}

\protected\def\blx@addcomma{%
  \ifnum\blx@spacefactor<\blx@sf@com
    \unspace\bib@comma
  \else\ifnum\blx@spacefactor>\blx@sf@per
    \ifnum\blx@spacefactor=\blx@sf@nop
    \else
      \unspace\bib@comma
    \fi
  \fi\fi}

\protected\def\blx@addsemicolon{%
  \ifnum\blx@spacefactor<\blx@sf@com
    \unspace\bib@semicolon
  \else\ifnum\blx@spacefactor>\blx@sf@per
    \ifnum\blx@spacefactor=\blx@sf@nop
    \else
      \unspace\bib@semicolon
    \fi
  \fi\fi}

\protected\def\blx@addcolon{%
  \ifnum\blx@spacefactor<\blx@sf@com
    \unspace\bib@colon
  \else\ifnum\blx@spacefactor>\blx@sf@per
    \ifnum\blx@spacefactor=\blx@sf@nop
    \else
      \unspace\bib@colon
    \fi
  \fi\fi}

\protected\def\blx@addexclam{%
  \ifnum\blx@spacefactor<\blx@sf@com
    \unspace\bib@exclam
  \else\ifnum\blx@spacefactor>\blx@sf@nop
    \unspace\bib@exclam
  \fi\fi}

\protected\def\blx@addquestion{%
  \ifnum\blx@spacefactor<\blx@sf@com
    \unspace\bib@question
  \else\ifnum\blx@spacefactor>\blx@sf@nop
    \unspace\bib@question
  \fi\fi}

\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\spacefactor\@m
  \ignorespaces}

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

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

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

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

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

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

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

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

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

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

\newrobustcmd*{\adddotspace}{%
  \unspace\adddot\penalty\value{abbrvpenalty}%
  \space\blx@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@setpunctfont
  \let\resetpunctfont\blx@resetpunctfont
  \let\ifcapital\blx@ifcapital
  \let\ifpunctmark\blx@ifpunctmark
  \let\ifpunct\blx@ifpunct
  \let\ifterm\blx@ifterm
  \let\nopunct\blx@nopunct
  \let\isdot\blx@isdot
  \let\adddot\blx@adddot
  \let\addperiod\blx@addperiod
  \let\addcomma\blx@addcomma
  \let\addsemicolon\blx@addsemicolon
  \let\addcolon\blx@addcolon
  \let\addexclam\blx@addexclam
  \let\addquestion\blx@addquestion
  \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@conflopt{The package option '#1' already exists}}}
    {\blx@err@conflopt{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@conflopt{The entry option '#1' already exists}}}

%% Auxiliary commands

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

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

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

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

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

% {<name>}

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

\newrobustcmd*{\restorebibmacro}[1]{%
  \blx@restore{bib@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 bib@macro@\detokenize{#2}\endcsname}

% {<name>}

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

% {<field>}

\def\blx@thefield#1{\csuse{bib@field@#1}}

% {<plainlist>}

\def\blx@thelist#1{\csuse{bib@list@#1}}

% {<namelist>}

\def\blx@thename#1{\csuse{bib@name@#1}}

% {<field>}

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

% {<plainlist>}

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

% {<namelist>}

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

% {<field>}{<macro>}

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

% {<plainlist>}{<macro>}

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

% {<namelist>}{<macro>}

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

% {<field>}{<macro>}

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

% {<plainlist>}{<macro>}

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

% {<namelist>}{<macro>}

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

% {<field>}{<csname>}

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

% {<plainlist>}{<csname>}

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

% {<namelist>}{<csname>}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

\def\blx@iffieldxref@i#1#2{%
  \begingroup
  \letcs\blx@tempa{bib@field@#2}%
  \letcs\blx@tempb{bib@field@#1}%
  \csundef{bib@field@#1}%
  \csuse{blx@dat@\the\c@refsection @\blx@tempa}%
  \blx@iffieldequals{#1}\blx@tempb
    {\aftergroup\@firstoftwo}
    {\aftergroup\@secondoftwo}%
  \endgroup}

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

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

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

\def\blx@iflistxref@i#1#2{%
  \begingroup
  \letcs\blx@tempa{bib@field@#2}%
  \letcs\blx@tempb{bib@list@#1}%
  \csundef{bib@list@#1}%
  \csuse{blx@dat@\the\c@refsection @\blx@tempa}%
  \blx@iflistequals{#1}\blx@tempb
    {\aftergroup\@firstoftwo}
    {\aftergroup\@secondoftwo}%
  \endgroup}

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

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

\def\blx@ifnamexref@i#1#2{%
  \begingroup
  \letcs\blx@tempa{bib@field@#2}%
  \letcs\blx@tempb{bib@name@#1}%
  \csundef{bib@name@#1}%
  \csuse{blx@dat@\the\c@refsection @\blx@tempa}%
  \blx@ifnameequals{#1}\blx@tempb
    {\aftergroup\@firstoftwo}
    {\aftergroup\@secondoftwo}%
  \endgroup}

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

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

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

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

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

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

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

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

% {<true>}{<false>}

\def\blx@ifuseprefix{%
  \ifblx@useprefix
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi}

% {<true>}{<false>}

\def\blx@ifuseauthor{%
  \ifblx@useauthor
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi}

% {<true>}{<false>}

\def\blx@ifuseeditor{%
  \ifblx@useeditor
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi}

% {<true>}{<false>}

\def\blx@ifsingletitle{%
  \iftoggle{bib@bool@singletitle}}

% {<list>}{<true>}{<false>}

\def\blx@ifandothers#1{%
  \iftoggle{bib@bool@more#1}}

% {<true>}{<false>}

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

% {<true>}{<false>}

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

% {<true>}{<false>}

\protected\def\blx@ifciteseen@global{%
  \xifinlistcs{\bib@field@entrykey}{blx@see@\the\c@refsection}}

\protected\def\blx@ifciteseen@context{%
  \blx@iffootnote
    {\xifinlistcs{\bib@field@entrykey}{blx@fns@\the\c@refsection}}
    {\xifinlistcs{\bib@field@entrykey}{blx@see@\the\c@refsection}}}

% {<true>}{<false>}

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

\def\blx@ifciteibid@context{%
  \blx@iffootnote
    {\blx@iffieldequals{entrykey}\blx@lastkey@foot}
    {\blx@iffieldequals{entrykey}\blx@lastkey@text}}

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

\def\blx@ifciteibid@constrict{%
  \blx@ifcitesingle
    {\blx@iffootnote
       {\ifnum\numexpr\value\@mpfn-\blx@lastmpfn<\tw@
	  \expandafter\@firstoftwo
	\else
	  \expandafter\@secondoftwo
	\fi
          {\blx@iffieldequals{entrykey}\blx@lastkey@foot}
	  {\@secondoftwo}}
       {\blx@iffieldequals{entrykey}\blx@lastkey@text}}
    {\@secondoftwo}}%

% {<true>}{<false>}

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

\def\blx@ifopcit@context{%
  \blx@iffootnote
    {\blx@iffieldequalcs{entrykey}{blx@lastkey@foot@\bib@field@namehash}}
    {\blx@iffieldequalcs{entrykey}{blx@lastkey@text@\bib@field@namehash}}}

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

\def\blx@ifopcit@constrict{%
  \blx@ifcitesingle
    {\blx@iffootnote
       {\ifnum\numexpr\value\@mpfn-\blx@lastmpfn<\tw@
	  \expandafter\@firstoftwo
	\else
	  \expandafter\@secondoftwo
	\fi
	  {\blx@iffieldequalcs{entrykey}{blx@lastkey@foot@\bib@field@namehash}}
	  {\@secondoftwo}}
       {\blx@iffieldequalcs{entrykey}{blx@lastkey@text@\bib@field@namehash}}}
    {\@secondoftwo}}%

% {<true>}{<false>}

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

\def\blx@ifloccit@context{%
  \blx@iffootnote
    {\blx@ifloccit@check{foot}}
    {\blx@ifloccit@check{text}}}

\def\blx@ifloccit@strict{%
  \blx@ifcitesingle
    {\blx@ifloccit@global}
    {\@secondoftwo}}%

\def\blx@ifloccit@constrict{%
  \blx@ifcitesingle
    {\blx@iffootnote
       {\ifnum\numexpr\value\@mpfn-\blx@lastmpfn<\tw@
	  \expandafter\@firstoftwo
	\else
	  \expandafter\@secondoftwo
	\fi
	  {\blx@ifloccit@check{foot}}
	  {\@secondoftwo}}
       {\blx@ifloccit@check{text}}}
    {\@secondoftwo}}

\def\blx@ifloccit@check#1{%
  \blx@iffieldundef{postnote}
    {\@secondoftwo}
    {\expandafter\blx@ifnumerals
     \expandafter{\bib@field@postnote}
       {\blx@iffieldequalcs{postnote}{blx@lastnote@#1@\bib@field@entrykey}}
       {\@secondoftwo}}}

% {<true>}{<false>}

\def\blx@iffootnote{%
  \ifblx@footnote
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi}

% {<true>}{<false>}

\def\blx@iffirstonpage{%
  \blx@iffootnote
    {\blx@iffirstonpage@i{fnpage}}
    {\blx@iffirstonpage@i{page}}}

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

\def\blx@iffirstonpage@ii#1#2{%
  \ifcsundef{blx@#2@#1}
    {\ifnum#1>\@ne
       \expandafter\@firstoftwo
     \else
       \expandafter\@secondoftwo
     \fi
     {\expandafter\blx@iffirstonpage@ii
      \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@ifsamepage#1#2{%
  \ifcsundef{blx@page@\number\numexpr#1}
    {\ifcsundef{blx@fnpage@\number\numexpr#1}
       {\@secondoftwo}
       {\blx@ifsamepage@i{#1}{#2}{fnpage}}}
    {\blx@ifsamepage@i{#1}{#2}{page}}}

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

\def\blx@ifsamepage@ii#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@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@ifnumeral{%
  \begingroup
  \blx@ifnum}

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

\protected\def\blx@ifnumerals{%
  \begingroup
  \def\do##1{\uccode`##1=`\%}%
  \bib@dorangechars
  \def\do##1{\let##1\@empty}%
  \bib@dorangecmds
  \blx@ifnum}

\long\def\blx@ifnum#1{%
  \blx@hook@ifnum
  \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%
  \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
  \let\RN\@gobble
  \let\Rn\@gobble
  \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\bib@dorangechars{%
  \do\ \do\~\do\,\do\;\do\-\do\+\do\/}
\def\bib@dorangecmds{%
  \do\ \do\,\do\space\do\nobreakspace\do\addspace\do\addnbspace
  \do\addthinspace\do\addnbthinspace\do\addlowpenspace
  \do\addhighpenspace\do\addlpthinspace\do\addhpthinspace
  \do\adddotspace\do\addabbrvspace\do\&\do\psq\do\psqq
  \do\bibrangedash\do\textendash\do\textemdash}

% *{<code>}

\newrobustcmd*{\NumcheckSetup}{\appto\blx@hook@ifnum}
\let\blx@hook@ifnum\@empty

% [<pagination>]{<string>}

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

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

% [<pagination>]{<string>}

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

\long\def\blx@mkpagetotal@i#1#2{%
  \begingroup
  \blx@ifnumeral{#2}
    {\setbox\@tempboxa=\hbox{%
       \@tempcnta0#2\relax
       \ifnum\@tempcnta=\@ne
	 \aftergroup\@firstoftwo
       \else
	 \aftergroup\@secondoftwo
       \fi}%
     {#2\ppspace\blx@bibstring{#1}}
     {#2\ppspace\blx@bibstring{#1s}}}
    {\def\pno{\blx@bibstring{#1}}%
     \def\ppno{\blx@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>}{<type>}

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

% Punctuation

\def\blx@initunit{%
  \blx@blockfalse
  \blx@unitfalse
  \blx@insertfalse
  \blx@lastinsfalse
  \blx@resetpunctfont}

\def\blx@nounit{\blx@lastinsfalse}

\def\blx@unitmark{23sp}
\let\blx@csqmarkcheck\@firstofone

\def\blx@begunit{%
  \blx@tempswatrue
  \ifblx@insert
    \ifblx@unit
      \begingroup
        \let\blx@begunit\@empty
        \let\blx@endunit\@empty
        \blx@unitpunct
      \endgroup
      \blx@unitfalse
      \blx@tempswafalse
    \fi
    \ifblx@block
      \begingroup
        \let\blx@begunit\@empty
        \let\blx@endunit\@empty
        \newblockpunct
      \endgroup
      \blx@blockfalse
      \blx@tempswafalse
    \fi
  \fi
  \ifblx@tempswa\else
    \blx@insertfalse
  \fi
  \blx@resetpunctfont
  \blx@leavevmode
  \blx@csqmarkcheck{%
    \penalty\@M
    \hskip-\blx@unitmark\relax
    \hskip\blx@unitmark\relax}%
  \begingroup}

\def\blx@endunit{%
  \global\let\blx@aftergroup\bib@punctfont
  \endgroup
  \let\bib@punctfont\blx@aftergroup
  \ifdim\lastskip=\blx@unitmark
    \unskip\unskip\unpenalty
    \blx@lastinsfalse
  \else
    \blx@inserttrue
    \blx@lastinstrue
  \fi}

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

\long\def\blx@setunit@i#1{%
  \def\blx@unitpunct{#1}%
  \blx@unittrue}%

\def\blx@setunit@ii{%
  \ifblx@lastins
    \expandafter\blx@setunit@i
  \else
    \expandafter\@gobble
  \fi}

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

%% Global formatting hooks

% capitalization

\newcommand*{\MakeCapital}{}
\begingroup
\catcode`\"=\active
\protected\long\gdef\MakeCapital#1{%
  \begingroup
  \def\do##1{\def##1{\blx@capii##1}}%
  \bib@dosingleaccents
  \def\do##1{\def##1{\blx@capiii##1}}%
  \bib@dodoubleaccents
  \def\IeC{\blx@capii\IeC}%
  \def\@tabacckludge##1{%
    \expandafter\blx@capii\csname\string##1\endcsname}%
  \ifnum\catcode`\"=\active
    \def"##1{\blx@capii"\noexpand##1}%
  \fi
  \def\blx@capii{\noexpand\blx@capii\noexpand}%
  \def\blx@capiii{\noexpand\blx@capiii\noexpand}%
  \protected@edef\blx@tempa{#1}%
  \expandafter\blx@capital\blx@tempa\@empty\@empty\@empty}
\endgroup

\def\blx@capital#1{%
  \begingroup
  \expandafter\def\expandafter\blx@tempa\expandafter{#1}%
  \ifx\blx@tempa\blx@capii
    \aftergroup\blx@capital@ii
  \else\ifx\blx@tempa\blx@capiii
    \aftergroup\blx@capital@iii
  \else
    \aftergroup\blx@capital@i
  \fi\fi
  \endgroup{#1}}

\def\blx@capital@i#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@capital@ii#1#2#3{\blx@capital@i{#2#3}}
\def\blx@capital@iii#1#2#3#4{\blx@capital@i{#2#3#4}}

\let\blx@capii\@empty
\let\blx@capiii\@empty

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

%% Main formatting commands

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

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

\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{bib@#1@#2@#3}{%
    \expandonce{\csname bib@#1@#4@#5\endcsname}}}

\def\blx@getformat#1#2#3#4{%
  \ifcsundef{bib@#2@\blx@thefield{entrytype}@#3}
    {\ifcsundef{bib@#2@*@#3}
       {\ifcsundef{bib@#2@\blx@thefield{entrytype}@#4}
	  {\ifcsundef{bib@#2@*@#4}
	     {\letcs#1{bib@#2@*@default}}
	     {\letcs#1{bib@#2@*@#4}}}
	  {\letcs#1{bib@#2@\blx@thefield{entrytype}@#4}}}
       {\letcs#1{bib@#2@*@#3}}}
    {\letcs#1{bib@#2@\blx@thefield{entrytype}@#3}}}

% [<entrytype>]{<name>}

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

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

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

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

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

\newrobustcmd*{\DeclareFieldFormat}[2][*]{%
  \blx@defformat{bib@ffd@#1@#2}##1}
\newrobustcmd*{\DeclareIndexFieldFormat}[2][*]{%
  \blx@defformat{bib@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@printtext}[2][]{%
  \ifblank{#2}
    {\blx@nounit}
    {\blx@begunit
     \blx@safe@actives
     \ifblank{#1}
       {\let\blx@theformat\@firstofone}
       {\blx@getformat\blx@theformat{ffd}{#1}{}}%
     \blx@rest@actives
     \blx@theformat{#2}%
     \blx@endunit}}

% [<format>]{<field>}

\newrobustcmd*{\blx@printfield}[2][]{%
  \blx@iffieldundef{#2}
    {\blx@nounit}
    {\blx@begunit
     \blx@safe@actives
     \blx@getformat\blx@theformat{ffd}{#1}{#2}%
     \def\currentfield{#2}%
     \letcs\blx@tempa{bib@field@#2}%
     \blx@rest@actives
     \expandafter\blx@theformat
     \expandafter{\blx@tempa}%
     \blx@endunit}}

% [<format>]{<field>}

\newrobustcmd*{\blx@indexfield}[2][]{%
  \blx@iffieldundef{#2}
    {}
    {\begingroup
     \blx@safe@actives
     \blx@getformat\blx@theformat{fid}{#1}{#2}%
     \def\currentfield{#2}%
     \letcs\blx@tempa{bib@field@#2}%
     \expandafter\blx@theformat
     \expandafter{\blx@tempa}%
     \endgroup}}

% {<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@printnames{%
  \blx@listargs\blx@printnames@i}

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

\def\blx@printnames@i#1#2#3#4{%
  \blx@ifnameundef{#4}
    {\blx@nounit}
    {\blx@begunit
     \blx@safe@actives
     \blx@getformat\blx@theformat{nfd}{#1}{#4}%
     \blx@rest@actives
     \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{bib@name@#3}%
  \let~\bib@btxnbspacefix
  \blx@namecodes}

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

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

\protected\def\blx@indexnames{%
  \blx@listargs\blx@indexnames@i}

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

\def\blx@indexnames@i#1#2#3#4{%
  \blx@ifnameundef{#4}
    {}
    {\begingroup
     \blx@safe@actives
     \blx@getformat\blx@theformat{nid}{#1}{#4}%
     \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@printlist{%
  \blx@listargs\blx@printlist@i}

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

\def\blx@printlist@i#1#2#3#4{%
  \blx@iflistundef{#4}
    {\blx@nounit}
    {\blx@begunit
     \blx@safe@actives
     \blx@getformat\blx@theformat{lfd}{#1}{#4}%
     \blx@rest@actives
     \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{bib@list@#3}}

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

\protected\def\blx@indexlist{%
  \blx@listargs\blx@indexlist@i}

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

\def\blx@indexlist@i#1#2#3#4{%
  \blx@iflistundef{#4}
    {}
    {\begingroup
     \blx@safe@actives
     \blx@getformat\blx@theformat{lid}{#1}{#4}%
     \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&{}

\appto\blx@blxinit{%
  \let\printtext\blx@printtext
  \let\printfield\blx@printfield
  \let\printlist\blx@printlist
  \let\printnames\blx@printnames
  \blx@ifindex
    {\let\indexfield\blx@indexfield
     \let\indexlist\blx@indexlist
     \let\indexnames\blx@indexnames}
    {\let\indexfield\blx@noindex
     \let\indexlist\blx@noindex
     \let\indexnames\blx@noindex}}
\let\blx@ifindex\@secondoftwo

%% Localization

% [<wrapper>]{<string>}

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

% [<wrapper>]{<string>}

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

% [<wrapper>]{<string>}

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

% [<wrapper>]{<string>}

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

% {<string>}

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

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

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

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

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

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

\def\bib@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{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{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{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{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{langdanish}%
  \do{langenglish}%
  \do{langfrench}%
  \do{langgerman}%
  \do{langgreek}%
  \do{langitalian}%
  \do{langlatin}%
  \do{langnorwegian}%
  \do{langspanish}%
  \do{langswedish}%
  \do{fromamerican}%
  \do{fromdanish}%
  \do{fromenglish}%
  \do{fromfrench}%
  \do{fromgerman}%
  \do{fromgreek}%
  \do{fromitalian}%
  \do{fromlatin}%
  \do{fromnorwegian}%
  \do{fromspanish}%
  \do{fromswedish}%
  \do{countryca}%
  \do{countryde}%
  \do{countrydk}%
  \do{countryep}%
  \do{countryes}%
  \do{countryeu}%
  \do{countryfr}%
  \do{countryit}%
  \do{countryno}%
  \do{countryse}%
  \do{countryuk}%
  \do{countryus}%
  \do{countrywo}%
  \do{patent}%
  \do{patentca}%
  \do{patentde}%
  \do{patentdk}%
  \do{patentes}%
  \do{patenteu}%
  \do{patentfr}%
  \do{patentit}%
  \do{patentno}%
  \do{patentse}%
  \do{patentuk}%
  \do{patentus}%
  \do{patreq}%
  \do{patreqca}%
  \do{patreqde}%
  \do{patreqdk}%
  \do{patreqes}%
  \do{patreqeu}%
  \do{patreqfr}%
  \do{patreqit}%
  \do{patreqno}%
  \do{patreqse}%
  \do{patrequk}%
  \do{patrequs}%
}

\newrobustcmd*{\NewBibliographyString}[1]{%
  \ifcsundef{KV@blx@lbx@#1}
    {\appto\bib@dostrings{\do{#1}}%
     \define@key{blx@lbx}{#1}{\blx@defstring{#1}{##1}}}
    {\blx@warning{%
       Bibliography string '#1' already defined.\MessageBreak
       Ignoring command}}}
\@onlypreamble\NewBibliographyString

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

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

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

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

\def\blx@defstring#1{\csdef{bib@str@#1}}
\def\blx@lbx@defstring#1#2{%
  \expandafter\blx@lbx@thedef\csname bib@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>}{<definitions>}

\newrobustcmd*{\DefineBibliographyExtras}[1]{%
  \blx@lbxinput{#1}{}{\blx@err@nolang{#1}}%
  \blx@defbibextras{#1}}
\@onlypreamble\DefineBibliographyExtras

\newrobustcmd*{\UndefineBibliographyExtras}[1]{%
  \blx@lbxinput{#1}{}{\blx@err@nolang{#1}}%
  \blx@undefbibextras{#1}}
\@onlypreamble\UndefineBibliographyExtras

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

% {<language>}{<language>}

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

% {<language>}{<strings>}

\newrobustcmd*{\DefineBibliographyStrings}[1]{%
  \blx@lbxinput{#1}{}{\blx@err@nolang{#1}}%
  \blx@defbibstrings{#1}}
\@onlypreamble\DefineBibliographyStrings

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

% {<language>}{<language>}

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

% {<language>}{<exceptions>}

\newrobustcmd*{\DefineHyphenationExceptions}[1]{%
  \blx@lbxinput{#1}{}{\blx@err@nolang{#1}}%
  \blx@hyphexcept{#1}}
\@onlypreamble\DefineHyphenationExceptions

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

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

\def\blx@lbxinput#1{%
  \blx@inputonce{#1.lbx}{language '#1'}
    {\begingroup
     \global\cslet{bib@strings@#1}\@empty
     \global\cslet{bib@extras@#1}\@empty
     \global\cslet{bib@noextras@#1}\@empty
     \blx@maplang{#1}{#1}%
     \def\InheritBibliographyStrings{\blx@letbibstrings{#1}}%
     \def\DeclareBibliographyStrings{\blx@defbibstrings{#1}}%
     \def\InheritBibliographyExtras{\blx@letbibextras{#1}}%
     \def\DeclareBibliographyExtras{\blx@defbibextras{#1}}%
     \def\UndeclareBibliographyExtras{\blx@undefbibextras{#1}}%
     \def\DeclareHyphenationExceptions{\blx@hyphexcept{#1}}%
     \let\blx@defstring\blx@lbx@defstring
     \blx@saneccodes
     \makeatletter}
    {\endgroup}}

% {<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}%

\newcounter{smartand}
\setcounter{smartand}{1}
\newrobustcmd*{\forceY}[1]{#1}
\newrobustcmd*{\forceE}[1]{#1}
\newrobustcmd*{\forceD}[1]{#1}
\newrobustcmd*{\forceDE}[1]{#1}

% {<language>}{<strings>}

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

%% Babel interface

\def\blx@languagename{english}
\let\blx@begbabel\begingroup
\let\blx@endbabel\endgroup
\def\blx@hyphenreset{%
  \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@iffieldundef{hyphenation}
	    {}
	    {\def\blx@endbabel{%
	       \csname end\blx@babelenv\endcsname
	       \endgroup}%
             \csname\blx@babelenv\expandafter\endcsname
               \expandafter{\bib@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\bib@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\bib@dolists{%
  \do{institution}%
  \do{language}%
  \do{location}%
  \do{organization}%
  \do{origlocation}%
  \do{origpublisher}%
  \do{pageref}%
  \do{publisher}%
}

\def\bib@dofields{%
  \do{entrykey}%
  \do{entrytype}%
  \do{entrysubtype}%
  \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{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{labelnumber}%
  \do{labeltitle}%
  \do{labelyear}%
  \do{library}%
  \do{localnumber}%
  \do{mainsubtitle}%
  \do{maintitle}%
  \do{maintitleaddon}%
  \do{month}%
  \do{nameaddon}%
  \do{namehash}%
  \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{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\bib@dobooleans{%
  \do{singletitle}%
}

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

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

% {<code>}

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

% {<message>}

\protected\def\blx@bbl@warn#1{%
  \blx@warning@noline{%
    BibTeX reported the following issues%
    \ifundef\bib@field@entrykey
      {}
      {\MessageBreak with entry '\bib@field@entrykey'}%
    :\MessageBreak\MessageBreak #1}}

% {<options>}

\protected\long\def\blx@bbl@optdef#1{%
  \begingroup
  \let\blx@tempa\@empty
  \let\blx@tempb\@empty
  \let\do\blx@bbl@optdef@i
  \docsvlist{#1}%
  \ifx\blx@tempa\@empty
  \else
    \csxappto\blx@bbl@data{%
      \def\noexpand\bib@field@options
      {\expandonce\blx@tempa}}%
  \fi
  \endgroup}

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

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

% {<field>}{<value>}

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

\protected\long\def\blx@bbl@fieldedef#1#2{%
  \begingroup
  \let\protect\@unexpandable@protect
  \csxappto\blx@bbl@data{%
    \def\expandonce{\csname bib@field@#1\endcsname}{#2}}%
  \endgroup}

\protected\long\def\blx@bbl@stringdef#1#2{%
  \csxappto\blx@bbl@data{%
    \def\expandonce{\csname bib@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 bib@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{bib@bool@#1}}}

\protected\def\blx@bbl@boolfalse#1{%
  \csgappto\blx@bbl@data{%
    \togglefalse{bib@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 bib@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 bib@name@#1\endcsname}%
    {\unexpanded{#3}}}}

% \blx@all@<section>               all citations (sorted)
% \blx@see@<section>               seen citations (body)
% \blx@fns@<section>               seen citations (footnote)
% \blx@dat@<section>@<entrykey>    data hook
% \blx@typ@<section>@<entrytype>   type hash
% \blx@seg@<section>@<segment>     segment hash
% \blx@kwd@<section>@<keyword>     keyword hash
% \blx@los@<section>               shorthand hash
% \blx@prf@<section>@<entrykey>    pageref hook (temporary)
% \blx@xrf@<section>               xref hash (temporary)
% \blx@xrf@<section>@<entrykey>    xref hook (temporary)
% \blx@xct@<section>@<entrykey>    xref count (temporary)
% \blx@cat@<category>              category hash (global)

% {<entrykey>}{<type>}{<keywords>}

\protected\def\blx@bbl@entry#1#2#3{%
  \begingroup
  \edef\bib@field@entrykey{\detokenize{#1}}%
  \listcsxadd{blx@all@\the\c@refsection}{\bib@field@entrykey}%
  \listcsxadd{blx@typ@\the\c@refsection @#2}{\bib@field@entrykey}%
  \edef\blx@bbl@data{blx@dat@\the\c@refsection @\bib@field@entrykey}%
  \ifcsundef\blx@bbl@data
    {}
    {\csuse\blx@bbl@data
     \cslet\blx@bbl@data\@empty}%
  \blx@bbl@fieldedef{entrykey}{\bib@field@entrykey}%
  \blx@bbl@fielddef{entrytype}{#2}%
  \ifblank{#3}
    {}
    {\def\do{\blx@addkeyword{\bib@field@entrykey}}%
     \docsvlist{#3}%
     \field{keywords}{#3}}%
  \ifcsundef{blx@prf@\the\c@refsection @\bib@field@entrykey}
    {}
    {\blx@addpageref{\bib@field@entrykey}}}

\protected\def\blx@bbl@endentry{%
  \csuse\blx@bbl@data
  \blx@options
  \ifundef\bib@field@shorthand
    {\ifblx@labelnumber
       \ifundef\bib@field@localnumber
         {\csnumgdef{blx@labelnumber@\the\c@refsection}{%
            \csuse{blx@labelnumber@\the\c@refsection}+1}%
          \edef\bib@field@localnumber{%
            \csuse{blx@labelnumber@\the\c@refsection}}}
         {}%
       \blx@bbl@fieldedef{labelnumber}{\bib@field@localnumber}%
       \blx@setlabwidth{\labelnumberwidth}{%
         \csuse{bib@ffd@*@labelnumberwidth}{\bib@field@localnumber}}
     \fi
     \ifundef\bib@field@labelalpha
       {}
       {\blx@setlabwidth{\labelalphawidth}{%
          \csuse{bib@ffd@*@labelalphawidth}{\bib@field@labelalpha}}}}
    {\blx@setlabwidth{\shorthandwidth}{%
       \csuse{bib@ffd@*@shorthandwidth}{\bib@field@shorthand}}%
     \ifblx@labelnumber
       \csgappto\blx@bbl@data{%
         \let\bib@field@labelnumber\bib@field@shorthand}%
       \blx@setlabwidth{\labelnumberwidth}{%
         \csuse{bib@ffd@*@labelnumberwidth}{\bib@field@shorthand}}%
     \fi
     \ifblx@labelalpha
       \csgappto\blx@bbl@data{%
         \let\bib@field@labelalpha\bib@field@shorthand}%
       \blx@setlabwidth{\labelalphawidth}{%
         \csuse{bib@ffd@*@labelalphawidth}{\bib@field@shorthand}}%
     \fi}%
  \blx@bbl@labelname
  \ifundef\bib@field@shorttitle
    {\csgappto\blx@bbl@data{%
       \let\bib@field@labeltitle\bib@field@title}}
    {\csgappto\blx@bbl@data{%
       \let\bib@field@labeltitle\bib@field@shorttitle}}%
  \ifundef\bib@field@indextitle
    {\csgappto\blx@bbl@data{%
       \let\bib@field@indextitle\bib@field@title}}
    {}%
  \ifundef\bib@field@indexsorttitle
    {\csgappto\blx@bbl@data{%
       \let\bib@field@indexsorttitle\bib@field@indextitle}}
    {}%
  \ifcsundef{blx@hook@bblitem@*}
    {\ifcsundef{blx@hook@bblitem@\bib@field@entrytype}
       {}
       {\csuse\blx@bbl@data
        \csuse{blx@hook@bblitem@\bib@field@entrytype}}}
    {\csuse\blx@bbl@data
     \csuse{blx@hook@bblitem@*}%
     \csuse{blx@hook@bblitem@\bib@field@entrytype}}%
  \ifundef\bib@field@labelyear
    {}
    {\ifnum\bib@field@labelyear>\c@maxlabelyear
       \global\c@maxlabelyear\bib@field@labelyear\relax
     \fi}%
  \endgroup}

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

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

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

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

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

\protected\def\blx@bbl@xref#1{%
  \ifcsdef{blx@xrf@\the\c@refsection @#1}
    {}
    {\listcsgadd{blx@xrf@\the\c@refsection}{#1}}%
  \listcsxadd{blx@xrf@\the\c@refsection @#1}{%
    \bib@field@entrykey}%
  \csnumgdef{blx@xct@\the\c@refsection @#1}{%
    \csuse{blx@xct@\the\c@refsection @#1}+1}}

\def\blx@addxref#1{%
  \begingroup
  \ifcsundef{blx@dat@\the\c@refsection @#1}
    {}
    {\def\blx@tempa{#1}%
     \let\do\blx@addxref@i
     \dolistcsloop{blx@xrf@\the\c@refsection @#1}}%
  \ifnum\csname blx@xct@\the\c@refsection @#1\endcsname
       <\blx@minxrefs\relax
  \else
    \begingroup
    \edef\blx@tempa{\endgroup
      \noexpand\AtBeginDocument{%
        \begingroup
	\c@refsection\the\c@refsection\relax
	\blx@nociteadd{#1}%
	\endgroup}}%
    \blx@tempa
  \fi
  \csundef{blx@xrf@\the\c@refsection @#1}%
  \csundef{blx@xct@\the\c@refsection @#1}%
  \endgroup}

\def\blx@addxref@i#1{%
  \csxappto{blx@dat@\the\c@refsection @#1}{%
    \def\noexpand\bib@field@xref{\blx@tempa}}}

\def\blx@bblstart{%
  \let\preamble\blx@bbl@preamble
  \let\warn\blx@bbl@warn
  \let\options\blx@bbl@optdef
  \let\entry\blx@bbl@entry
  \let\endentry\blx@bbl@endentry
  \let\lossort\blx@bbl@lossort
  \let\endlossort\blx@bbl@endlossort
  \let\xref\blx@bbl@xref
  \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{%
  \ifcsundef{blx@xrf@\the\c@refsection}
    {}
    {\let\do\blx@addxref
     \dolistcsloop{blx@xrf@\the\c@refsection}%
     \csundef{blx@xrf@\the\c@refsection}}}

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

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

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

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

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

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

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

%% Data input

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

\def\blx@bblinput{%
  \begingroup
  \blx@secinit
  \blx@blxinit
  \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}%
  \blx@bbl@recode}

\let\blx@bbl@recode\endgroup

\def\blx@recode{%
  \let\protect\@unexpandable@protect
  \def\IeC##1{\unexpanded{##1}}%
  \let~\relax
  \def\do##1{\cslet{bib@name@##1}\relax}%
  \bib@donames
  \def\do##1{\cslet{bib@list@##1}\relax}%
  \bib@dolists
  \def\do##1{\cslet{bib@field@##1}\relax}%
  \bib@dofields\do{options}%
  \long\def\bib@field@execute##1{%
    \unexpanded{\bib@field@execute{##1}}}%
  \ifdef\inpenc@prehook % inputenc 2006/05/05 v1.1b
    {\inpenc@prehook{}%
     \inpenc@posthook{}}
    {}%
  \inputencoding\blx@bibencoding
  \csuse{bib@preamble}%
  \def\do##1{%
    \csxdef{blx@dat@\the\c@refsection @##1}{%
      \csuse{blx@dat@\the\c@refsection @##1}}}%
  \dolistcsloop{blx@all@\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@all@#1}
    {\blx@error
       {Section '#1' not found}
       {The reference section '#1' could not be found}}
    {\c@refsection#1\relax
     \ifblx@tempswa
       \blx@printbibchecks
       \letcs\blx@tempa{blx@all@\the\c@refsection}%
     \else
       \blx@error
         {'section' not first filter}
         {When passing multiple filter options to
          \string\printbibliography,\MessageBreak
          the 'section' filter must be given first}%
     \fi}}
\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@all@#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@seg@\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@seg@\the\c@refsection @#1}}}

\define@key{blx@bib}{type}{%
  \ifcsundef{blx@typ@\the\c@refsection @#1}
    {\blx@warning{%
       Entry type '#1' not found.\MessageBreak
       Skipping this type filter}}
    {\blx@printbibchecks
     \ifblx@tempswb
       \blx@tempswbfalse
       \blx@filter\blx@tempa{blx@typ@\the\c@refsection @#1}%
     \else
       \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}%
     \fi}}

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

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

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

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

\define@key{blx@bib}{notcategory}{%
  \ifcsundef{blx@cat@#1}
    {}
    {\blx@printbibchecks
     \blx@notfilter\blx@tempa{blx@cat@#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{%
  \blx@tempswafalse
  \ifblx@defernums
    \global\let\blx@printbibchecks\relax
  \else
    \ifblx@labelnumber
      \blx@warning{Setting 'defernums=true' recommended}%
    \else
      \global\let\blx@printbibchecks\relax
    \fi
  \fi}

\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]{%
  \blx@tempswatrue
  \blx@tempswbtrue
  \letcs\blx@tempa{blx@all@\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
  \blx@tempswafalse
  \blx@refsections}

\def\blx@refsections{%
  \ifcsundef{blx@all@\the\c@refsection}
    {}
    {\ifcsvoid{blx@all@\the\c@refsection}
       {}
       {\blx@tempswatrue
	\begingroup
	\expandafter\blx@bibliography\csname blx@all@\the\c@refsection\endcsname}}%
  \ifnum\c@refsection<\blx@maxsection
    \advance\c@refsection\@ne
    \expandafter\blx@refsections
  \else
    \ifblx@tempswa\else\blx@warn@bibempty\fi
    \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
  \blx@tempswafalse
  \blx@refsegments}

\def\blx@refsegments{%
  \ifcsundef{blx@seg@\the\c@refsection @\the\c@refsegment}
    {}
    {\ifcsvoid{blx@seg@\the\c@refsection @\the\c@refsegment}
       {}
       {\blx@tempswatrue
	\begingroup
	\letcs\blx@tempa{blx@all@\the\c@refsection}%
	\blx@filter\blx@tempa{blx@seg@\the\c@refsection @\the\c@refsegment}%
	\blx@bibliography\blx@tempa}}%
  \ifnum\c@refsegment<\blx@maxsegment
    \advance\c@refsegment\@ne
    \expandafter\blx@refsegments
  \else
    \ifblx@tempswa\else\blx@warn@bibempty\fi
    \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
  \blx@tempswafalse
  \let\do\blx@bibcategory
  \dolistloop\blx@categories
  \blx@endbibcategory}

\def\blx@bibcategory#1{%
  \ifcsvoid{blx@cat@#1}
    {}
    {\blx@tempswatrue
     \begingroup
     \blx@key@heading{#1}%
     \letcs\blx@tempa{blx@all@\the\c@refsection}%
     \blx@filter\blx@tempa{blx@cat@#1}%
     \blx@bibliography\blx@tempa}}%

\def\blx@endbibcategory{%
  \ifblx@tempswa\else\blx@warn@bibempty\fi
  \endgroup}

% {<entrykey>,...}

\def\blx@bibliography{%
  \blx@bibheading\blx@tempb
  \ifx\blx@tempc\@empty
  \else
    \blx@bibnote\blx@tempc
  \fi
  \begingroup
  \blx@bibinit
  \let\@noitemerr\@empty
  \let\blx@noitem\blx@warn@bibempty
  \ifnum\bibitemextrasep=\z@
    \let\blx@bibitem@extrasep\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
  \ifx\blx@tempd\@empty
  \else
    \noindent
    \blx@bibnote\blx@tempd
  \fi
  \endgroup}

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

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

\def\blx@bibinit{%
  \let\blx@ifindex\blx@ifbibindex
  \blx@blxinit
  \csuse{blx@hook@bbxinit}%
  \bib@urlsetup
  \bibsetup\bibfont
  \blx@setsfcodes
  \csuse{blx@bibsetup}}

\ifundef\Urlmuskip
  {\def\bib@urlsetup{\def\do@url@hyp{\do\-}}}
  {\def\bib@urlsetup{%
     \def\do@url@hyp{\do\-}%
     \Urlmuskip=0mu plus 1mu\relax}}

% {<entrykey>}

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

\def\blx@bibitem@extrasep{%
  \ifnum\c@instcount>\@ne
    \blx@iffieldequals{namehash}\blx@prevhash
      {}
      {\vspace{\bibitemextrasep}}%
  \fi
  \global\let\blx@prevhash\bib@field@namehash}

\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
  \if@filesw\ifpagetracker
    \protected@write\@mainaux{}{%
      \blx@iffootnote
  	{\string\bib@aux@fnpage}
  	{\string\bib@aux@page}%
      {\the\c@instcount}{\noexpand\the\c@page}}%
  \fi\fi}

% {<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\bib@aux@page#1#2{\blx@addchecksum{\the\numexpr#1+0#2}}%
  \def\bib@aux@fnpage#1#2{\blx@addchecksum{\the\numexpr#1+0#2}}}

% hyperref interface

\appto\blx@mkhyperref{%
  \let\blx@anchors\@empty
  \protected\def\blx@anchor{%
    \xifinlist{\the\c@refsection @\bib@field@entrykey}{\blx@anchors}
      {}
      {\listxadd\blx@anchors{\the\c@refsection @\bib@field@entrykey}%
       \hyper@natanchorstart{\the\c@refsection @\bib@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@los@\the\c@refsection}
    {\blx@warn@losempty\endgroup}
    {\expandafter\blx@shorthands
     \csname blx@los@\the\c@refsection\endcsname}}

% {<entrykey>,...}

\def\blx@shorthands{%
  \if@twocolumn
    \@restonecoltrue\onecolumn
  \else
    \@restonecolfalse
  \fi
  \blx@bibheading\blx@tempb
  \ifx\blx@tempc\@empty
  \else
    \blx@bibnote\blx@tempc
  \fi
  \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
  \ifx\blx@tempd\@empty
  \else
    \noindent
    \blx@bibnote\blx@tempd
  \fi
  \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{%
  \let\blx@noitem\@empty
  \begingroup
  \csuse{blx@dat@\the\c@refsection @#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}

\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@info{Setting label 'refsection:\the\c@refsection'}%
  \label{refsection:\the\c@refsection}%
  \blx@secinit
  \if@filesw
    \blx@auxwrite\@mainaux{%
      \string\bib@aux@section{\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
  \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}%
  \global\c@refsection\z@}

\protected\def\bib@aux@section#1{%
  \global\blx@maxsection#1\relax
  \blx@addchecksum{[#1]}}

\AtEndDocument{%
  \blx@endrefsection
  \def\bib@aux@section#1{\blx@addchecksum{[#1]}}}

% Reference segments

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

\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@seg@\the\c@refsection @\the\c@refsegment}
    {\global\cslet{blx@seg@\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@cat@#1}
    {\global\cslet{blx@cat@#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@cat@#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\bib@aux@category{#1}{#2}}%
  \bib@aux@category{#1}{#2}}

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

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

\AtEndDocument{\let\bib@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@opcitreset
  \blx@loccitreset}

% {<entrykey>}

\def\blx@citation#1{%
  \blx@auxwrite\blx@theauxout{\string\citation{#1}}%
  \ifinlistcs{#1}{blx@seg@\the\c@refsection @\the\c@refsegment}
    {}
    {\listcsgadd{blx@seg@\the\c@refsection @\the\c@refsegment}{#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@all@\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
  \ifundef\blx@thecitekey
    {}
    {\csuse{\blx@thecitekey}%
     \blx@options}%
  \def\blx@thecheckpunct{\blx@err@nestcite\@gobble}%
  \blx@postcode\endgroup}

\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@nocitesort
  \fi}

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

% {<entrykey>}

\def\blx@citeadd#1{%
  \blx@citation{#1}%
  \ifcsundef{blx@dat@\the\c@refsection @#1}
    {\blx@reqauxfile
     \@latex@warning{Citation '#1' on page \thepage\space undefined}%
     \ifnum\@tempcntb>\z@\multicitedelim\fi
     \blx@missing{#1}%
     \advance\@tempcntb\@ne}%
    {\advance\@tempcnta\@ne
     \listadd\blx@tempa{#1}}}%

% {<entrykey>}

\protected\def\blx@citeprint#1{%
  \advance\c@citecount\@ne
  \addtocounter{instcount}\@ne
  \blx@citenext
  \edef\blx@thecitekey{blx@dat@\the\c@refsection @#1}%
  \begingroup
  \csuse{\blx@thecitekey}%
  \blx@options
  \blx@backref
  \blx@pagetracker
  \csuse{blx@hook@citekey}%
  \csuse{blx@hook@citekey@next}%
  \blx@execute
  \blx@loopcode
  \blx@citetracker
  \blx@ibidtracker
  \blx@opcittracker
  \blx@loccittracker
  \endgroup}

\def\blx@citenext{%
  \def\blx@citenext{\blx@dlimcode}}%

\def\blx@citetracker@global{%
  \ifcitetracker
    \xifinlistcs\bib@field@entrykey{blx@see@\the\c@refsection}
      {}
      {\listcsxadd{blx@see@\the\c@refsection}\bib@field@entrykey}%
  \fi}

\def\blx@citetracker@context{%
  \ifcitetracker
    \blx@iffootnote
      {\xifinlistcs\bib@field@entrykey{blx@fns@\the\c@refsection}
	 {}
	 {\listcsxadd{blx@fns@\the\c@refsection}\bib@field@entrykey}}
      {\xifinlistcs{\bib@field@entrykey}{blx@see@\the\c@refsection}
	 {}
	 {\listcsxadd{blx@see@\the\c@refsection}\bib@field@entrykey}}%
  \fi}

\def\blx@ibidtracker@gobal{%
  \ifcitetracker
    \global\let\blx@lastkey@text\bib@field@entrykey
  \fi}

\def\blx@ibidtracker@context{%
  \ifcitetracker
    \blx@iffootnote
      {\global\let\blx@lastkey@foot\bib@field@entrykey}
      {\global\let\blx@lastkey@text\bib@field@entrykey}%
  \fi}

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

\def\blx@ibidtracker@constrict{%
  \xdef\blx@lastmpfn{\the\value\@mpfn}%
  \blx@ifcitesingle
    {\blx@ibidtracker@context}
    {\blx@ibidreset@context}}%

\def\blx@ibidreset@force{%
  \global\undef\blx@lastkey@text
  \global\undef\blx@lastkey@foot
  \global\let\blx@lastmpfn\z@}

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

\def\blx@ibidreset@context{%
  \blx@iffootnote
    {\global\undef\blx@lastkey@foot
     \global\let\blx@lastmpfn\z@}
    {\global\undef\blx@lastkey@text}}

\def\blx@opcittracker@gobal{%
  \ifcitetracker
    \blx@opcit@tracker{text}%
  \fi}

\def\blx@opcittracker@context{%
  \ifcitetracker
    \blx@iffootnote
      {\blx@opcit@tracker{foot}}
      {\blx@opcit@tracker{text}}%
  \fi}

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

\def\blx@opcittracker@constrict{%
  \xdef\blx@lastmpfn{\the\value\@mpfn}%
  \blx@ifcitesingle
    {\blx@opcittracker@context}
    {\blx@opcitreset@context}}%

\def\blx@opcit@tracker#1{%
  \global\cslet{blx@lastkey@#1@\bib@field@namehash}\bib@field@entrykey
  \xifinlistcs\bib@field@namehash{blx@trackhash@#1}
    {}
    {\listcsxadd{blx@trackhash@#1}\bib@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}%
  \global\let\blx@lastmpfn\z@}

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

\def\blx@opcitreset@context{%
  \blx@iffootnote
    {\blx@opcit@reset{foot}%
     \global\let\blx@lastmpfn\z@}
    {\blx@opcit@reset{text}}}

\def\blx@loccittracker@gobal{%
  \ifcitetracker
    \blx@loccit@tracker{text}%
  \fi}

\def\blx@loccittracker@context{%
  \ifcitetracker
    \blx@iffootnote
      {\blx@loccit@tracker{foot}}
      {\blx@loccit@tracker{text}}%
  \fi}

\def\blx@loccittracker@strict{%
  \blx@ifcitesingle
    {\blx@loccittracker@gobal}
    {\blx@loccitreset@gobal}}%

\def\blx@loccittracker@constrict{%
  \xdef\blx@lastmpfn{\the\value\@mpfn}%
  \blx@ifcitesingle
    {\blx@loccittracker@context}
    {\blx@loccitreset@context}}%

\def\blx@loccit@tracker#1{%
  \blx@iffieldundef{postnote}
    {}
    {\expandafter\blx@ifnumerals
     \expandafter{\bib@field@postnote}
       {\global\cslet{blx@lastnote@#1@\bib@field@entrykey}\bib@field@postnote
	\xifinlistcs\bib@field@entrykey{blx@trackkeys@#1}
	  {}
	  {\listcsxadd{blx@trackkeys@#1}\bib@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}%
  \global\let\blx@lastmpfn\z@}

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

\def\blx@loccitreset@context{%
  \blx@iffootnote
    {\blx@loccit@reset{foot}%
     \global\let\blx@lastmpfn\z@}
    {\blx@loccit@reset{text}}}

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

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

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

\AtEndDocument{%
  \def\bib@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@bibhyperref{%
    \@ifnextchar[%]
      {\blx@bibhyperref@i}
      {\blx@bibhyperref@i[\bib@field@entrykey]}}%
  \long\def\blx@bibhyperref@i[#1]#2{%
    \hyper@natlinkstart{\the\c@refsection @#1}%
    #2\hyper@natlinkend}%
  \protected\long\def\blx@bibhyperlink#1#2{%
    \hyper@natlinkstart{\the\c@refsection:#1}%
    #2\hyper@natlinkend}%
  \protected\long\def\blx@bibhypertarget#1#2{%
    \@bsphack
    \hyper@natanchorstart{\the\c@refsection:#1}%
    \@esphack
    #2\hyper@natanchorend}%
  \let\blx@ifhyperref\@firstoftwo}

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

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

% {<entrykey>,...}

\renewrobustcmd*{\nocite}[1]{%
  \@bsphack
  \AfterPreamble{%
    \ifstrequal{*}{#1}
      {\blx@nociteall}
      {\begingroup
       \let\do\blx@nociteadd
       \blx@sanitizekeys\docsvlist{#1}%
       \endgroup}}%
  \@esphack}

\protected\def\blx@nociteadd#1{%
  \blx@citation{#1}%
  \ifcsundef{blx@dat@\the\c@refsection @#1}
    {\blx@reqauxfile
     \@latex@warning{Citation '#1' undefined}}
    {}}%

\def\blx@nociteall{%
  \blx@auxwrite\blx@theauxout{\string\citation{*}}%
  \ifcsvoid{blx@all@\the\c@refsection}
    {\blx@reqauxfile}
    {}%
  \global\csletcs
    {blx@seg@\the\c@refsection @\the\c@refsegment}
    {blx@all@\the\c@refsection}}

% {<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#2&{%
  \if\noexpand#1\noexpand\blx@tempb
    \expandafter\blx@checkpunct@iv
  \fi
  \ifblank{#2}
    {\blx@checkpunct@iii}
    {\blx@checkpunct@ii#2}&}
\def\blx@checkpunct@iii#1&{\blx@tempa{}}
\def\blx@checkpunct@iv#1&#2{%
  \edef\blx@tempb{{%
         \if\noexpand#2.\blx@addperiod
    \else\if\noexpand#2,\blx@addcomma
    \else\if\noexpand#2;\blx@addsemicolon
    \else\if\noexpand#2:\blx@addcolon
    \else\if\noexpand#2!\blx@addexclam
    \else\if\noexpand#2?\blx@addquestion
    \else\noexpand#2\fi\fi\fi\fi\fi\fi}}%
  \expandafter\blx@tempa\blx@tempb}

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

\protected\def\blx@citeinit{%
  \let\blx@ifindex\blx@ifciteindex
  \blx@blxinit
  \citesetup
  \blx@setsfcodes
  \blx@resetdata
  \blx@leavevmode
  \csuse{blx@hook@cite}%
  \csuse{blx@hook@cite@next}%
  \let\blx@citeinit\relax}

\protected\def\blx@citestart{%
  \leavevmode}

% *{<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{cite}{#2}{#1}%
  \protected\csedef{#2}{%
    \blx@citestart
    \noexpand\@ifstar
      {\blx@citepunct\expandafter\noexpand
       \csname blx@cite@#2*\endcsname}
      {\blx@citepunct\expandafter\noexpand
       \csname blx@cite@#2\endcsname}}%
  \@ifnextchar[%]
    {\blx@defcitecmd@iii{#2#1}}
    {\blx@defcitecmd@ii{#2#1}}}

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

\long\def\blx@defcitecmd@iii#1[#2]{%
  \protected\long\csedef{blx@cite@#1}##1##2##3##4{%
    \begingroup
    \blx@citeinit
    \unexpanded{#2}{%
      \begingroup
      \blx@citeinit
      \expandafter\noexpand
      \csname blx@citei@#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@citei@#1}##1##2##3##4{%
    \ifblank{##1}
      {}
      {\def\bib@field@prenote{##1}}%
    \ifblank{##2}
      {\let\blx@thenotecheck\relax}
      {\def\bib@field@postnote{##2}}%
    \def\blx@loopcode{#3}%
    \def\blx@dlimcode{#4}%
    \def\blx@postcode{#5##4}%
    #2\blx@citeloop{##3}}}

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

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

% {<name>}

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

\protected\def\blx@citeicmd#1{%
  \ifcsundef{blx@citei@#1}
    {\bib@err@citecmd{#1}}
    {\begingroup\csuse{blx@citei@#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@citestart
      \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\bib@field@multiprenote{#1}}}%
  \ifblank{#2}%
    {}
    {\preto\blx@tempa{\def\bib@field@multipostnote{#2}}}%
  \let\blx@tempe\@empty
  \let\blx@tempf\@empty
  \blx@tempswafalse
  \blx@multiparse}

\def\blx@multicite@add#1#2#3{%
  \blx@tempswafalse
  \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}%
    \ifblx@tempswa\relax\space\fi}%
  \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@multicite@add{}{}}%
  \fi
  \ifx\@let@token\@sptoken
    \blx@multiparse@ii\blx@multiparse@iii
  \fi
  \ifblx@tempswa
    \blx@multiparse@ii{\blx@multicite@end{}}%
  \else
    \blx@multiparse@ii{\blx@thecheckpunct\blx@multicite@end}%
  \fi
  &}

\def\blx@multiparse@ii#1#2&{\fi#1}
\csdef{blx@multiparse@iii} {\blx@tempswatrue\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@citestart
    \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@citestart
    \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
     \def\blx@autopunct{#1}}}

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

\newrobustcmd*{\citename}{\blx@citexpunct{citename}}
\long\csdef{blx@cite@citename}#1#2#3#4#5#6{%
  \begingroup
  \blx@citeinit
  \ifblank{#1}
    {}
    {\def\bib@field@prenote{#1}}%
  \ifblank{#2}
    {\let\blx@thenotecheck\relax}
    {\def\bib@field@postnote{#2}}%
  \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}}%
  \citetrackerfalse
  \pagetrackerfalse
  \usebibmacro{prenote}%
  \blx@citeloop{#3}}

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

\newrobustcmd*{\citelist}{\blx@citexpunct{citelist}}
\long\csdef{blx@cite@citelist}#1#2#3#4#5#6{%
  \begingroup
  \blx@citeinit
  \ifblank{#1}
    {}
    {\def\bib@field@prenote{#1}}%
  \ifblank{#2}
    {\let\blx@thenotecheck\relax}
    {\def\bib@field@postnote{#2}}%
  \def\blx@loopcode{%
    \blx@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}}%
  \citetrackerfalse
  \pagetrackerfalse
  \usebibmacro{prenote}%
  \blx@citeloop{#3}}

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

\newrobustcmd*{\citefield}{\blx@citexpunct{citefield}}
\long\csdef{blx@cite@citefield}#1#2#3#4#5#6{%
  \begingroup
  \blx@citeinit
  \ifblank{#1}
    {}
    {\def\bib@field@prenote{#1}}%
  \ifblank{#2}
    {\let\blx@thenotecheck\relax}
    {\def\bib@field@postnote{#2}}%
  \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}}%
  \citetrackerfalse
  \pagetrackerfalse
  \usebibmacro{prenote}%
  \blx@citeloop{#3}}

\renewrobustcmd*{\cite}{\bib@err@citecmd\cite}
\cslet{blx@cite@cite}\relax
\newrobustcmd*{\parencite}{\bib@warn@citecmd\parencite\cite}
\cslet{blx@cite@parencite}\relax
\newrobustcmd*{\footcite}{\bib@warn@citecmd\footcite\cite}
\cslet{blx@cite@footcite}\relax
\newrobustcmd*{\textcite}{\bib@warn@citecmd\textcite\cite}
\cslet{blx@cite@textcite}\relax
\newrobustcmd*{\supercite}{\bib@warn@citecmd\supercite\cite}
\cslet{blx@cite@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\ifandothers#1{\blx@TE{\blx@ifandothers{#1}}}%
    \def\ifmorenames{\blx@TE\blx@ifmorenames}%
    \def\ifmoreitems{\blx@TE\blx@ifmoreitems}%
    \def\ifsingletitle{\blx@TE\blx@ifsingletitle}%
    \def\ifciteseen{\blx@TE\blx@ifciteseen}%
    \def\ifciteibid{\blx@TE\blx@ifciteibid}%
    \def\ifopcit{\blx@TE\blx@ifopcit}%
    \def\ifloccit{\blx@TE\blx@ifloccit}%
    \def\iffootnote{\blx@TE\blx@iffootnote}%
    \def\ifsamepage{\blx@TE\blx@ifsamepage}%
    \def\iffirstonpage{\blx@TE\blx@iffirstonpage}%
    \def\ifcurrentfield#1{\blx@TE{\blx@ifcurrentfield{#1}}}%
    \def\ifcurrentlist#1{\blx@TE{\blx@ifcurrentlist{#1}}}%
    \def\ifcurrentname#1{\blx@TE{\blx@ifcurrentname{#1}}}%
    \def\ifentrytype#1{\blx@TE{\blx@ifentrytype{#1}}}%
    \def\iffieldequalcs#1#2{\blx@TE{\blx@iffieldequalcs{#1}{#2}}}%
    \def\iffieldequals#1#2{\blx@TE{\blx@iffieldequals{#1}{#2}}}%
    \def\iffieldequalstr#1#2{\blx@TE{\blx@iffieldequalstr{#1}{#2}}}%
    \def\iffieldsequal#1#2{\blx@TE{\blx@iffieldsequal{#1}{#2}}}%
    \def\iffieldundef#1{\blx@TE{\blx@iffieldundef{#1}}}%
    \def\ifnameequalcs#1#2{\blx@TE{\blx@ifnameequalcs{#1}{#2}}}%
    \def\ifnameequals#1#2{\blx@TE{\blx@ifnameequals{#1}{#2}}}%
    \def\ifnamesequal#1#2{\blx@TE{\blx@ifnamesequal{#1}{#2}}}%
    \def\ifnameundef#1{\blx@TE{\blx@ifnameundef{#1}}}%
    \def\ifuseprefix{\blx@TE\blx@ifuseprefix}%
    \def\ifuseauthor{\blx@TE\blx@ifuseauthor}%
    \def\ifuseeditor{\blx@TE\blx@ifuseeditor}%
    \def\ifcapital{\blx@TE\blx@ifcapital}%
    \def\ifinteger#1{\blx@TE{\blx@ifinteger{#1}}}%
    \def\ifnumeral#1{\blx@TE{\blx@ifnumeral{#1}}}%
    \def\ifnumerals#1{\blx@TE{\blx@ifnumerals{#1}}}%
    \def\ifbibstring#1{\blx@TE{\blx@ifbibstring{#1}}}%
    \def\iffieldbibstring#1{\blx@TE{\blx@iffieldbibstring{#1}}}}}

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

\protected\def\bl