%% Copyright 2016 Daniel Ballester Marques
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%   http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%%
%% This work has the LPPL maintenance status `maintained'.
%%
%% The Current Maintainer of this work is Daniel Ballester Marques.

\ProvidesFile{abnt.bbx}%
[2018-11-17\space v3.4\space ABNT BibLaTeX citation style]%


% Init >>>1

\RequireBiber[3]%

\RequirePackage{xparse}%
\RequirePackage{xpatch}%
\RequirePackage{expl3}%

\DeclareLanguageMapping{american}{american-abnt}
\DeclareLanguageMapping{australian}{australian-abnt}
\DeclareLanguageMapping{brazil}{brazil-abnt}
\DeclareLanguageMapping{brazilian}{brazilian-abnt}
\DeclareLanguageMapping{british}{british-abnt}
\DeclareLanguageMapping{canadian}{canadian-abnt}
\DeclareLanguageMapping{english}{english-abnt}
\DeclareLanguageMapping{portuges}{portuges-abnt}
\DeclareLanguageMapping{portuguese}{portuguese-abnt}
\DeclareLanguageMapping{spanish}{spanish-abnt}

\RequireBibliographyStyle{standard}%

\ExecuteBibliographyOptions{%
  % language=brazil,%
  block=none,%
  urldate=long,%
  pagetracker,%
  uniquename=false,%
  sorting=nty,%
}%

\InitializeBibliographyStyle{\global\undef\bbx@lasthash}%

\setcounter{biburlnumpenalty}{3000}%
\setcounter{biburllcpenalty}{6000}%
\setcounter{biburlucpenalty}{9000}%

% <<<1


% Macros >>>1

% Dashed option >>>2

\newbool{bbx@inset}%

\newtoggle{isdashed}%

\newcommand*{\bibnameunderscore}{\underline{\hspace*{4em}}}%
\newcommand*{\nopunctdash}{\bibnameunderscore\addspace}%
\renewcommand*{\bibnamedash}{\bibnameunderscore\addperiod\addspace}%

\renewbibmacro*{begrelated}{%% >>>3
  \booltrue{bbx@inset}%
}%% <<<3

\newbibmacro*{bbx:savehash}{%% >>>3
  \savefield{fullhash}{\bbx@lasthash}%
}%% <<<3

\newbibmacro*{bbx:saveorg}{%% >>>3
  \savelist{organization}{\bbx@lastorg}%
}%% <<<3

\newbibmacro*{bbx:savetitle}{%% >>>3
  \savefield{title}{\bbx@lasttitle}%
}%% <<<3

\newbibmacro*{bbx:savesubtitle}{%% >>>3
  \savefield{subtitle}{\bbx@lastsubtitle}%
}%% <<<3

\newbibmacro*{bbx:dashcheck}[2]{%% >>>3
  \ifboolexpr{%
    (%
      test {\iffieldequals{fullhash}{\bbx@lasthash}}%
      or%
      test {\iflistequals{organization}{\bbx@lastorg}}%
    )%
    and%
    not test \iffirstonpage%
    and%
    not test {\iftoggle{repeatfields}}%
    and%
    not test {\iftoggle{repeatfirstfields}}%
    and%
    (%
       not bool {bbx@inset}%
       or%
       test {\iffieldequalstr{entrysetcount}{1}}%
    )%
  }%
    {\settoggle{isdashed}{true}#1}%
    {\settoggle{isdashed}{false}#2}%
}%% <<<3

\newbibmacro*{bbx:titledashcheck}[2]{%% >>>3
  \iftoggle{isdashed}{%
    \ifboolexpr{%
      test {\iffieldequals{title}{\bbx@lasttitle}}%
      and%
      (%
        test {\iffieldequals{subtitle}{\bbx@lastsubtitle}}%
        or%
        test {\iffieldundef{subtitle}}%
      )%
      and%
      not test {\iftoggle{repeattitle}}%
    }%
      {#1}%
      {#2}%
  }{%
    #2%
  }%
}%% <<<3

\newbibmacro*{bbx:ineditordashcheck}[2]{%% >>>3
  \ifboolexpr{%
    test {\ifnamesequal{editor}{author}}%
    and%
    not test {\iftoggle{repeatfields}}%
    and%
    (%
       not bool {bbx@inset}%
       or%
       test {\iffieldequalstr{entrysetcount}{1}}%
    )%
  }%
    {\settoggle{isdashed}{true}#1}%
    {\settoggle{isdashed}{false}#2}%
}%% <<<3

% <<<2

% Titles >>>2

\newbibmacro*{titleiskey}[2]{%% >>>3
\ifboolexpr{%
  test {\ifnameundef{author}}%
  and%
  test {\ifnameundef{editor}}%
  and%
  test {\ifnameundef{holder}}%
  and%
  test {\ifcsundef{saveded}}%
  and%
  test {\ifcsundef{savedorg}}%
  and%
  test {\iffieldundef{eventtitle}}%
}%
    {#1}%
    {#2}%
}%% <<<3

\renewbibmacro*{title}{%% >>>3
  \ifboolexpr{%
    test {\iffieldundef{title}}%
    and%
    test {\iffieldundef{subtitle}}%
  }%
    {\global\undef\bbx@lasttitle%
    \global\undef\bbx@lastsubtitle}%
      {\usebibmacro{bbx:titledashcheck}%
        {\unspace\bibnamedash}%
        {\usebibmacro{bbx:savetitle}%
      \usebibmacro{bbx:savesubtitle}%
      \printtext[title]{%
        \usebibmacro{titleiskey}%
          {\unspace\printfield[upperfirst]{title}}%
          {\ifboolexpr{%
            test {\iffieldundef{maintitle}}%
            and%
            test {\iffieldundef{related}}%
          }%
            {\printfield[titlecase]{title}}%
            {\printfield[normalfont]{title}}}%
        \normalfont{%
          \iffieldendswithpunct{title}{%
            \setunit*{\addspace}%
          }{%
            \setunit*{\subtitlepunct}%
          }
          \printfield[normalfont]{subtitle}%
          \setunit{\addperiod\addspace}%
        }}%
    \newunit}}%
  \printfield{titleaddon}%
}%% <<<3

\newbibmacro*{booktitleiskey}[2]{%% >>>3
\ifboolexpr{%
  test {\ifnameundef{bookauthor}}%
  and%
  test {\ifnameundef{editor}}%
  and%
  test {\iffieldundef{organization}}%
  and%
  test {\ifcsundef{saveded}}%
  and%
  test {\ifcsundef{savedorg}}%
  and%
  test {\iffieldundef{eventtitle}}%
}%
    {#1}%
    {#2}%
}%% <<<3

\renewbibmacro*{booktitle}{%% >>>3
  \ifboolexpr{%
    test {\iffieldundef{booktitle}}%
    and%
    test {\iffieldundef{booksubtitle}}%
  }%
    {}%
    {\printtext[booktitle]{%
      \usebibmacro{booktitleiskey}{%
        \printfield[upperfirst]{booktitle}%
      }{%
        \printfield[titlecase]{booktitle}%
      }%
      \iffieldendswithpunct{booktitle}{%
        \normalfont{\setunit*{\addspace}}%
      }{%
        \normalfont{\setunit*{\subtitlepunct}}%
      }
      \printfield[normalfont]{booksubtitle}}%
      \newunit}%
  \printfield{booktitleaddon}%
}%% <<<3

\renewbibmacro*{maintitle}{%% >>>3
  \ifboolexpr{%
    test {\iffieldundef{maintitle}}%
    and%
    test {\iffieldundef{mainsubtitle}}%
  }%
    {}%
    {\printtext[maintitle]{%
      \usebibmacro{titleiskey}{%
        \printfield[upperfirst]{maintitle}%
      }{%
        \printfield[titlecase]{maintitle}%
      }%
      \iffieldendswithpunct{maintitle}{%
        \normalfont{\setunit*{\addspace}}%
      }{%
        \normalfont{\setunit*{\subtitlepunct}}%
      }
      \printfield[normalfont]{mainsubtitle}}%
      \newunit}%
  \printfield{maintitleaddon}%
}%% <<<3

\newbibmacro*{in:maintitle}{%% >>>3
  \iffieldundef{maintitle}{}{%
    \usebibmacro{in:}%
    \iftoggle{repeatfields}%
      {\addspace\usebibmacro{author/editor+others}}%
      {\addspace\bibnamedash}%
    \newunit%
    \usebibmacro{maintitle}%
  }%
}%% <<<3

\renewbibmacro*{maintitle+booktitle}{%% >>>3
  \iffieldundef{maintitle}%
    {}%
    {\usebibmacro{maintitle}%
     \newunit\newblock%
     \iffieldundef{volume}%
       {}%
       {\printfield{volume}%
        \printfield{part}%
        \setunit{\addcolon\addspace}}}%
  \usebibmacro{booktitle}%
  \newunit%
}%% <<<3

\newbibmacro*{maintitle/booktitle}{%% >>>3
  \iffieldundef{maintitle}%
    {\usebibmacro{booktitle}}%
    {\usebibmacro{maintitle}}%
}%% <<<3

\renewbibmacro*{journal}{%% >>>3
  \iffieldundef{journaltitle}%
    {}%
    {\printtext[journaltitle]{%
       \printfield[titlecase]{journaltitle}%
       \iffieldendswithpunct{journaltitle}{%
          \setunit{\addspace}%
       }{%
          \setunit{\subtitlepunct}%
       }
       \printfield[normalfont]{journalsubtitle}}}%
}%% <<<3

\newbibmacro{journal+section}{%% >>>3
  \usebibmacro{journal}%
  \iffieldundef{section}%
    {}%
    {\setunit{\addspace\textendash\addspace}%
    \printfield{section}}%
}%% <<<3

\renewbibmacro*{journal+issuetitle}{%% >>>3
  \usebibmacro{journal}%
  \setunit*{\addcomma\addspace}%
  \iffieldundef{series}%
    {}%
    {\newunit%
     \printfield{series}%
     \setunit{\addspace}}%
  \usebibmacro{volume+number+eid}%
  \newunit%
}%% <<<3

\renewbibmacro*{periodical}{%% >>>3
  \iffieldundef{title}{}{%
    \printtext[title]{%
      \iffieldundef{issue}{%
        \unspace\printfield[upperfirst]{title}%
      }{%
        \printfield[titlecase]{title}%
      }
      \normalfont{%
        \iffieldendswithpunct{title}{%
          \setunit*{\addspace}%
        }{%
          \setunit*{\subtitlepunct}%
        }
        \printfield[normalfont]{subtitle}%
      }%
    }%
  }%
}%% <<<3

% <<<2

% Names >>>2

\renewbibmacro*{author}{%% >>>3
  \ifboolexpr{%
    test \ifuseauthor%
    and%
    not test {\ifnameundef{author}}%
  }{%
    \usebibmacro{bbx:dashcheck}{%
      \iffieldundef{authortype}{%
        \bibnamedash%
        \newunit%
        \printfield{nameaddon}%
      }{%
        \nopunctdash%
        \usebibmacro{authorstrg}%
        \newunit%
        \printfield{nameaddon}%
      }%
    }{%
      \usebibmacro{bbx:savehash}%
      \printnames{author}%
      \addspace%
      \usebibmacro{authorstrg}%
      \newunit%
      \printfield{nameaddon}%
    }%
  }{%
    \global\undef\bbx@lasthash%
  }%
}%% <<<3

\renewbibmacro*{editor+others}{%% >>>3
  \ifboolexpr{%
    test \ifuseeditor%
    and%
    not test {\ifnameundef{editor}}%
  }{%
    \usebibmacro{bbx:dashcheck}{%
      \iffieldundef{editortype}{%
        \bibnamedash%
      }{%
        \nopunctdash%
        \usebibmacro{editor+othersstrg}%
      }%
    }{%
      \usebibmacro{bbx:savehash}%
      \printnames{editor}%
      \setunit{\addspace}%
          \usebibmacro{editor+othersstrg}%
    }%
      \savenamecs*{editor}{saveded}%
      \clearname{editor}%
  }{%
    \global\undef\bbx@lasthash%
    \usebibmacro{organization}%
  }%
}%% <<<3

\renewbibmacro*{byeditor+others}{%% >>>3
  \toggletrue{byeditor+others}%
  \ifnameundef{editor}{}{% else
    \usebibmacro{byeditor+othersstrg}%
    \setunit*{\addspace}%
    \printnames[byeditor]{editor}%
    \clearname{editor}%
    \newunit%
  }%
  \usebibmacro{byeditorx}%
  \usebibmacro{bytranslator+others}%
  \togglefalse{byeditor+others}%
}%% <<<3

\newbibmacro*{organization}{%% >>>3
  \iflistundef{organization}%
    {\global\undef\bbx@lastorg}%
        {\usebibmacro{bbx:dashcheck}%
      {\bibnamedash}%
      {\usebibmacro{bbx:saveorg}%
      \printlist[uppercase]{organization}}%
    \savelistcs*{organization}{savedorg}%
    \clearlist{organization}%
    \newunit%
    \printfield{nameaddon}}%
}%% <<<3

\newbibmacro*{author/organization}{%% >>>3
  \ifnameundef{author}%
  {\usebibmacro{organization}}%
  {\usebibmacro{author}}%
}%% <<<3

\newbibmacro*{editor+others/organization}{%% >>>3
  \ifnameundef{editor}%
    {\usebibmacro{organization}}%
    {\usebibmacro{editor+others}}%
}%% <<<3

\newbibmacro*{organization/eventtitle}{%% >>>3
  \iffieldundef{eventtitle}%
  {\usebibmacro{organization}}%
  {\printfield[uppercase]{eventtitle}}%
}%% <<<3

\newbibmacro*{bookauthor/editor+others}{%% >>>3
  \ifnameundef{bookauthor}{%
    \usebibmacro{editor+others}}%
  {\printnames{bookauthor}}%
}%% <<<3

\newbibmacro*{in:bookauthor+others}{%% >>>3
  \usebibmacro{in:}%
  \ifnameundef{bookauthor}{%
    % do nothing
  }{% else
    \ifnamesequal{author}{bookauthor}{%
      \iftoggle{repeatfields}{%
        \usebibmacro{author/editor+others}%
      }{% else
        \bibnamedash%
      }%
    }{% else
      \printnames{bookauthor}%
    }%
  }%
}%% <<<3

\newbibmacro*{in:editor+others}{%% >>>3
  \usebibmacro{in:}%
  \addspace%
  \ifnameundef{editor}{%
    \printlist[uppercase]{organization}%
  }{%
    \usebibmacro{bbx:ineditordashcheck}{%
      \iffieldundef{editortype}{%
        \bibnamedash%
      }{%
        \nopunctdash%
        \usebibmacro{editor+othersstrg}%
        \savenamecs*{editor}{saveded}%
        \clearname{editor}%
      }%
    }{%
      \printnames{editor}%
      \setunit*{\addspace}%
      \usebibmacro{editor+othersstrg}%
      \savenamecs*{editor}{saveded}%
      \clearname{editor}%
    }%
  }%
}%% <<<3

\newbibmacro*{in:eventtitle/organization/editor}{%% >>>3
  \usebibmacro{in:}%
  \iffieldundef{eventtitle}{%
    \ifnameundef{editor}{%
      \printlist[uppercase]{organization}%
      \clearlist{organization}%
    }{%
      \usebibmacro{editor+others}%
    }%
  }{%
    \printfield[uppercase]{eventtitle}%
  }%
}%% <<<3

% <<<2

% Publisher, location, date, issue >>>2

\renewbibmacro*{date}{%
  \iftoggle{extradate}{%
    \printdateextra%
  }{%
    \printdate%
  }%
  \printunit{\addperiod\addspace}%
}%

\newbibmacro*{publisher}{%% >>>3
  \iflistundef{publisher}%
    {\iftoggle{nosn}{}{\printtext[brackets]{\mkbibemph{\bibstring{sinenomine}}}}}%
      {\printlist{publisher}}%
}%% <<<3

\newbibmacro*{location}{%% >>>3
  \iflistundef{location}%
    {\iftoggle{nosl}{}{\printtext[brackets]{\mkbibemph{\bibstring{sineloco}}}}}%
      {\printlist{location}}%
}%% <<<3

\newbibmacro*{venue}{%% >>>3
  \iffieldundef{venue}%
    {\iftoggle{nosl}{}{\printtext[brackets]{\mkbibemph{\bibstring{sineloco}}}}}%
      {\printfield{venue}}%
}%% <<<3

\renewbibmacro*{location+date}{%% >>>3
  \usebibmacro{location}%
  \setunit*{\addcomma\addspace}%
  \usebibmacro{date}%
  \newunit%
}%% <<<3

\renewbibmacro*{publisher+location+date}{%% >>>3
  \ifboolexpr{%
    test {\iflistundef{publisher}}%
    and%
    test {\iflistundef{location}}%
    and%
    not test {\iftoggle{nosl}}%
    and%
    not test {\iftoggle{nosn}}%
  }{%
    \printtext[brackets]{\mkbibemph{\bibstring{sineloco}}%
    \setunit{\addcolon\addnbspace}%
    \mkbibemph{\bibstring{sinenomine}}}%
  }{%
    \ifboolexpr{%
      test {\ifnameundef{author}}%
      and%
      test {\ifnameundef{editor}}%
      and%
      test {\iflistundef{publisher}}%
      and%
      not test {\iflistundef{organization}}%
    }{%
      \usebibmacro{location}%
    }{%
      \usebibmacro{location}%
      \setunit*{\addcolon\addspace}%
      \usebibmacro{publisher}%
    }%
  }%
  \setunit*{\addcomma\addspace}%
  \usebibmacro{date}%
  \newunit%
}%% <<<3

\renewbibmacro*{issue}{%% >>>3
  \iffieldundef{issuetitle}%
    {}%
    {\printtext[issuetitle]{%
       \printfield[upperfirst]{issuetitle}%
        \iffieldendswithpunct{issuetitle}{%
          \setunit*{\addspace}%
        }{%
          \setunit*{\subtitlepunct}%
        }
       \printfield[normalfont]{issuesubtitle}}}%
}%% <<<3

\renewbibmacro*{issue+date}{%% >>>3
  \iffieldundef{issue}%
    {\usebibmacro{date}}%
    {\printfield{issue}%
     \setunit*{\addspace}%
     \usebibmacro{date}}%
  \newunit%
}%% <<<3

\newbibmacro*{publisher+location+issue+date}{%% >>>3
  \ifboolexpr{%
    test {\iflistundef{publisher}}%
    and%
    test {\iflistundef{location}}%
    and%
    not test {\iftoggle{nosl}}%
    and%
    not test {\iftoggle{nosn}}%
  }{%
    \printtext[brackets]{\mkbibemph{\bibstring{sineloco}}%
    \setunit{\addcolon\addnbspace}%
    \mkbibemph{\bibstring{sinenomine}}}%
  }{%
    \ifboolexpr{%
      test {\ifnameundef{author}}%
      and%
      test {\ifnameundef{editor}}%
      and%
      test {\iflistundef{publisher}}%
      and%
      not test {\iflistundef{organization}}%
    }{%
      \usebibmacro{location}%
    }{%
      \usebibmacro{location}%
      \setunit*{\addcolon\addspace}%
      \usebibmacro{publisher}%
    }%
  }%
  \setunit*{\addcomma\addspace}%
  \printfield[number]{issue}%
  \setunit*{\addcomma\addspace}%
  \usebibmacro{date}%
  \newunit%
}%% <<<3

% <<<2

% Misc >>>2

\xpatchbibmacro{name:andothers}{%% >>>3
  \bibstring{andothers}%
}{%
  \mkbibemph{\bibstring{andothers}}%
}{}{}%% <<<3

\renewbibmacro*{in:}{%% >>>3
  \mkbibemph{\bibstring{in}\intitlepunct}
}%% <<<3

\renewbibmacro*{volume+number+eid}{%% >>>3
  \printfield{volume}%
  \setunit*{\addcomma\addspace}%
  \printfield{number}%
  \setunit{\addcomma\addspace}%
  \printfield{eid}%
}%% <<<3

\renewbibmacro*{series+number}{%% >>>3
  \iffieldundef{series}{}{%
    \printtext[parens]{%
      \printfield{series}%
      \setunit*{\addcomma\addspace}%
      \printfield[normalfont]{number}%
      \newunit}%
    }%
}%% <<<3

\renewbibmacro*{url+urldate}{%% >>>3
  \usebibmacro{url}%
  \iffieldundef{urlyear}%
    {}%
    {\setunit*{\addperiod\addspace}%
     \usebibmacro{urldate}}%
}%% <<<3

\newbibmacro*{mathesis}{%% >>>3
  \iffieldundef{type}{%
    \bibstring{dissertation}\addspace\printtext[parens]{\bibstring{mathesis}}%
  }{%
    \bibstring{dissertation}\addspace\printtext[parens]{\printfield{type}}%
  }%
}%% <<<3

\newbibmacro*{phdthesis}{%% >>>3
  \iffieldundef{type}{%
    \bibstring{thesis}\addspace\printtext[parens]{\bibstring{phdthesis}}%
  }{%
    \bibstring{thesis}\addspace\printtext[parens]{\printfield{type}}%
  }%
}%% <<<3

\newbibmacro*{language}{%% >>>3
  \ifboolexpr{%
    test {\iflistundef{language}}%
    or%
    test {\iflistundef{origlanguage}}%
  }%
  {}%
  {%
    \printtext{\printlist{language}\addspace\printlist{origlanguage}}%
  }%
}%% <<<3

\renewbibmacro*{related:reprintfrom}[1]{%% >>>3
  \entrydata*{#1}{%
    \usedriver%
      {\ifnameundef{savedauthor}%
         {\ifnameundef{savededitor}%
            {}%
            {\ifnamesequal{editor}{savededitor}%
               {\clearname{editor}}%
               {}}}%
         {\ifnamesequal{author}{savedauthor}%
            {\clearname{author}}%
            {}}%
       \renewbibmacro*{related:init}{}%
       \DeclareNameAlias{sortname}{default}%
       \ifbibmacroundef{date+extradate}%
         {}%
         {\renewbibmacro*{date+extradate}{}%
          \renewbibmacro*{date}{\printdate}}%
       \renewbibmacro*{pageref}{}}%
      {\thefield{entrytype}}}%
}%% <<<3

\renewbibmacro*{pageref}{% >>>3
  \iftoggle{backref}{%
    \iftoggle{citecount}{%
      \iflistundef{pageref}{%
        \bibstring{citecountnopage}%
      }{%
        \printtext{%
          \ifnumgreater{\value{pageref}}{1}{%
            \bibstring{citecountpages}\ppspace%
          }{%
            \bibstring{citecountpage}\ppspace%
          }%
          \printlist[pageref][-\value{listtotal}]{pageref}%
        }%
      }%
    }{%
      \iflistundef{pageref}{}{%
        \printtext{%
          \ifnumgreater{\value{pageref}}{1}{%
            \bibstring{backrefpages}\ppspace%
          }{%
            \bibstring{backrefpage}\ppspace%
          }%
          \printlist[pageref][-\value{listtotal}]{pageref}%
        }%
      }%
    }%
  }{}
}% <<<3

% <<<2

% <<<1


% Options >>>1

% Print titles in italics >>>2
\newtoggle{ittitles}%
\DeclareBibliographyOption{ittitles}[true]{%
  \settoggle{ittitles}{#1}}%
% <<<2

% Use small caps in the bibliography >>>2
\newtoggle{scbib}%
\DeclareBibliographyOption{scbib}[true]{%
  \settoggle{scbib}{#1}}%
% <<<2

% Hide "[s.l.]" >>>2
\newtoggle{nosl}%
\DeclareBibliographyOption{nosl}[true]{%
  \settoggle{nosl}{#1}}%
\DeclareEntryOption[boolean]{nosl}[true]{%
  \settoggle{nosl}{#1}}%
% <<<2

% Hide "[s.n.]" >>>2
\newtoggle{nosn}%
\DeclareBibliographyOption{nosn}[true]{%
  \settoggle{nosn}{#1}}%
\DeclareEntryOption[boolean]{nosn}[true]{%
  \settoggle{nosn}{#1}}%
% <<<2

% Hide "[S.l.: sn]" >>>2
\newtoggle{noslsn}%
\DeclareBibliographyOption{noslsn}[true]{%
  \settoggle{noslsn}{#1}%
  \settoggle{nosl}{#1}%
  \settoggle{nosn}{#1}}%
\DeclareEntryOption[boolean]{noslsn}[true]{%
  \settoggle{noslsn}{#1}%
  \settoggle{nosl}{#1}%
  \settoggle{nosn}{#1}}%
% <<<2

% Repeat titles >>>2
\newtoggle{repeattitle}%
\DeclareBibliographyOption[boolean]{repeattitles}[true]{%
  \settoggle{repeattitle}{#1}%
  \ifstrequal{#1}{true}{%
    \renewbibmacro*{bbx:savetitle}{}%
    \renewbibmacro*{bbx:savesubtitle}{}%
  }{%
    \ExecuteBibliographyOptions{pagetracker}%
    \renewbibmacro*{bbx:savetitle}{\savefield{title}{\bbx@lasttitle}}%
    \renewbibmacro*{bbx:savesubtitle}{\savefield{subtitle}{\bbx@lastsubtitle}}%
  }%
}%
\DeclareEntryOption[boolean]{repeattitle}[true]{%
  \settoggle{repeattitle}{#1}%
}%
\DeclareEntryOption[boolean]{repeattitles}[true]{%
  \settoggle{repeattitle}{#1}%
}%
% <<<2

% Repeat first fields >>>2
\newtoggle{repeatfirstfields}%
\DeclareBibliographyOption[boolean]{repeatfirstfields}[true]{%
  \settoggle{repeatfirstfields}{#1}%
}%
\DeclareEntryOption[boolean]{repeatfirstfields}[true]{%
  \settoggle{repeatfirstfields}{#1}%
}%
% <<<2

% Repeat fields >>>2
\newtoggle{repeatfields}%
\DeclareBibliographyOption[boolean]{repeatfields}[true]{%
  \settoggle{repeatfields}{#1}%
  \ifstrequal{#1}{true}{%
    \renewbibmacro*{bbx:savehash}{}%
    \renewbibmacro*{bbx:saveorg}{}%
    \renewbibmacro*{bbx:savetitle}{}%
    \renewbibmacro*{bbx:savesubtitle}{}%
  }{%
    \ExecuteBibliographyOptions{pagetracker}%
    \renewbibmacro*{bbx:savehash}{\savefield{fullhash}{\bbx@lasthash}}%
    \renewbibmacro*{bbx:saveorg}{\savelist{organization}{\bbx@lasthash}}%
    \renewbibmacro*{bbx:savetitle}{\savefield{title}{\bbx@lasttitle}}%
    \renewbibmacro*{bbx:savesubtitle}{\savefield{subtitle}{\bbx@lastsubtitle}}%
  }%
}%
\ExecuteBibliographyOptions{repeatfields}
\DeclareEntryOption[boolean]{repeatfields}[true]{%
  \settoggle{repeatfields}{#1}%
}%
% <<<2

% Use original dashes instead of underscores >>>2
\newtoggle{usedashes}%
\DeclareBibliographyOption[boolean]{usedashes}[true]{%
  \settoggle{usedashes}{#1}%
  \ifstrequal{#1}{true}{%
    \renewcommand*{\bibnamedash}{%
      \ifdimless{\leftmargin}{0.75em}{%
        \mbox{\textemdash\addspace}%
      }{% else
        \makebox[\leftmargin][l]{%
            \ifdimless{\leftmargin}{1.25em}{%
              \textendash%
            }{%
              \textemdash%
            }%
        }%
      }%
    }%
  }{}%
}%
% <<<2

% Use hanging indentation >>>2
\setlength{\bibhang}{0pt}%
\DeclareBibliographyOption{indent}[true]{%
  \ifstrequal{#1}{true}{%
    \setlength{\bibhang}{%
      \ifnumequal{\parindent}{0}{1em}{\parindent}%
    }%
  }{}}%
% <<<2

% Show extradate in bibliography >>>2
\newtoggle{extradate}%
\DeclareBibliographyOption{extradate}[true]{%
  \settoggle{extradate}{#1}}%
\DeclareEntryOption[boolean]{extradate}[true]{%
  \settoggle{extradate}{#1}}%
\DeclareBibliographyOption{extrayear}[true]{%
  \settoggle{extradate}{#1}}%
\DeclareEntryOption[boolean]{extrayear}[true]{%
  \settoggle{extradate}{#1}}%
% <<<2

% Commands that append things to \bibsetup >>>2
% Justify text >>>3
\newtoggle{justify}
\DeclareBibliographyOption{justify}[true]{%
  \settoggle{justify}{#1}%
}%
% <<<3

% don't apply NBR 6023 2018 spacing >>>3
\newtoggle{oldspacing}
\DeclareBibliographyOption{oldspacing}[true]{%
  \settoggle{oldspacing}{#1}%
}%
% <<<3

\appto{\bibsetup}{%
  \nottoggle{justify}{\raggedright}{}%
  \nottoggle{oldspacing}{%
    \setlength{\bibitemsep}{\baselineskip}%
    \linespread{1}%
  }{}%
}%
% <<<2

% Make it pretty >>>2
\DeclareBibliographyOption{pretty}[true]{%
  \ifstrequal{#1}{true}{%
    \ExecuteBibliographyOptions{%
      ittitles,%
      sccite,%
      scbib,%
      indent,%
      justify,%
    }%
  }{}%
}%
% <<<2

% Show count in backref >>>2
\newtoggle{citecount}%
\DeclareBibliographyOption{citecount}[true]{%
  \settoggle{citecount}{#1}%
  \ifstrequal{#1}{true}{%
    \ExecuteBibliographyOptions{backref, citecounter}%
  }{}%
}%
% <<<2

% Toggle backref per entry >>>2
\newtoggle{backref}%
\settoggle{backref}{true}%
\DeclareEntryOption[boolean]{backref}[true]{%
  \settoggle{backref}{#1}%
}%
% <<<2

% Option to use a slash / as the daterangesep >>>2
\DeclareBibliographyOption[boolean]{slashdaterange}[true]{%
\renewrobustcmd*{\bibdaterangesep}{\slash}%
}%
\DeclareEntryOption[boolean]{slashdaterange}[true]{%
\renewrobustcmd*{\bibdaterangesep}{\slash}%
}%
% <<<2

% Options to define type of date per entrytype >>>2
% Options to show only years
\DeclareBiblatexOption{global, type, entry}[boolean]{dateyear}[true]{%
\renewbibmacro*{date}{\mkdaterangeyear{}}%
}%

% Options to show years and months
% O comando abaixo é o \mkdaterangeyear adaptado para não remover o mês
\newrobustcmd*{\mkdaterangeyearmonth}[1]{%
\begingroup
  \clearfield{yeardivision}%
  % \clearfield{#1month}%
  \clearfield{day}%
  \clearfield{hour}%
  \clearfield{minute}%
  \clearfield{second}%
  \clearfield{timezone}%
  \clearfield{endyeardivision}%
  % \clearfield{#1endmonth}%
  \clearfield{endday}%
  \clearfield{endhour}%
  \clearfield{endminute}%
  \clearfield{endsecond}%
  \clearfield{endtimezone}%
  \ifdaterangesequal{#1}{#1end}
    {\clearfield{#1endmonth}
      \clearfield{#1endyear}}
    {\ifdateyearsequal{#1}{#1end}
      {\blx@imc@clearfield{#1endyear}}
      {}%
    }%
  \mkdaterangefull{long}{#1}%
\endgroup}
\DeclareBiblatexOption{global, type, entry}[boolean]{datemonth}[true]{%
\renewbibmacro*{date}{\mkdaterangeyearmonth{}}%
}%
% <<<2

\DeclareFieldFormat{url}{\bibstring{urlfrom}\addcolon\addspace\url{#1}}%
\DeclareFieldFormat{urldate}{\bibstring{urlseen}\addcolon\addspace #1}%

% <<<1


% Data model and sorting >>>1

\DeclareSortingTemplate{nty}{%% >>>2
  \sort{%
    \field{presort}%
  }%
  \sort[final]{%
    \field{sortkey}%
  }%
  \sort{%
    \field{sortname}%
    \field{holder}%
    \field{author}%
    \field{editor}%
    \field{organization}%
    \field{sorttitle}%
    \field{issuetitle}%
    \field{title}%
    \field{subtitle}%
  }%
  \sort{%
    \field{nameaddon}%
    \field{sorttitle}%
    \field{issuetitle}%
    \field{title}%
    \field{subtitle}%
  }%
  \sort{%
    \field{sorttitle}%
    \field{issuetitle}%
    \field{title}%
    \field{subtitle}%
  }%
  \sort{%
    \field{sortyear}%
    \field{year}%
  }%
  \sort{%
    \field[padside=left,padwidth=4,padchar=0]{volume}%
    \literal{0000}%
  }%
}% <<<2

\DeclareStyleSourcemap{%% >>>2
  % This maps some fields used in abntex2cite to biblatex fields.
  \maps[datatype=bibtex]{%
    \map{%
      \step[fieldsource=conference-number,fieldtarget=number]%
      \step[fieldsource=conference-year,fieldtarget=eventdate]%
      \step[fieldsource=conference-location,fieldtarget=venue]%
      \step[fieldsource=conference-number,fieldtarget=number]%
      \step[fieldsource=org-short,fieldtarget=shortauthor]%
      \step[fieldsource=urlaccessdate,fieldtarget=urldate]%
      \step[fieldsource=year-presented,fieldtarget=eventyear]%
      \step[fieldsource=furtherresp,fieldtarget=titleaddon]%
      \step[typesource=journalpart,typetarget=supperiodical]%
    }%
  \map[overwrite=false]{%
        \step[fieldsource=reprinted-from, final]%
        \step[fieldset=related, origfieldval]%
  }%
  \map[overwrite=false]{%
        \step[fieldsource=reprinted-text, final]%
        \step[fieldset=relatedtype, fieldvalue={reprintfrom}]%
  }%
  \map{%
        \pertype{patent}% Use the organization as sourcekey for patents
        \step[fieldsource=organization, final]%
        \step[fieldset=sortkey, origfieldval]%
  }%
    \map[overwrite=false]{%
      \pertype{thesis}%
      \pertype{phdthesis}%
      \pertype{mastersthesis}%
      \pertype{monography}%
      \step[fieldset=bookpagination, fieldvalue={sheet}]%
    }%
  }%
}% <<<2

\DeclareDatamodelFields[type=field,datatype=literal]{%% >>>2
  section,%
  illustrated,%
  dimensions,%
  reprinted-text,%
}% <<<2

\DeclareDatamodelEntryfields[monography]{%% >>>2
  location,%
  author,%
  chapter%
  pages,%
  pagetotal,%
  bookpagination,%
  institution,%
  title,%
  type,%
  note,%
  isbn,%
  doi,%
  eprint,%
  url,%
  addendum,%
  pubstate,%
  pageref,%
  date%
}% <<<2

% <<<1


% Helper commands >>>1

\newcommand\FirstWordUpper[1]{\@firstwordupper#1 \@nil}% >>>2
\newcommand\@firstwordupper{}%
\def\@firstwordupper#1 #2\@nil{\MakeUppercase{#1} #2\unskip}% <<<2

\newcommand\FirstWordSC[1]{\@firstwordsc#1 \@nil}% >>>2
\newcommand\@firstwordsc{}%
\def\@firstwordsc#1 #2\@nil{\textsc{#1} #2\unskip}% <<<2

\newcommand\FirstWordLCSC[1]{\@firstwordlcsc#1 \@nil}% >>>2
\newcommand\@firstwordlcsc{}%
\def\@firstwordlcsc#1 #2\@nil{\textsc{\MakeLowercase{#1}} #2\unskip}% <<<2

% Helper macros >>>2

\long\def\addto#1#2{\expandafter\def\expandafter#1\expandafter{#1#2}}%

\def\traceparam#1{\def\paramL{}\traceparamA #1\end}%
\def\traceparamA{\futurelet\next\traceparamB}%
\def\traceparamB{%
   \let\nexts=\undefined%
   \expandafter\ifx\space\next \let\nexts=\traceparamS \fi%
   \ifx\bgroup\next \let\nexts=\traceparamD \fi%
   \ifx\end\next \let\nexts=\traceparamE \fi%
   \ifx\nexts\undefined \let\nexts=\traceparamC\fi%
   \nexts%
}%
\def\traceparamS{\addto\paramL{ }\afterassignment\traceparamA \let\next= }%
\def\traceparamC#1{\addto\paramL{#1}\traceparamA}%
\def\traceparamD#1{%
   \expandafter\addto\expandafter\paramL\expandafter%
   {\expandafter\noexpand\csname ll:\detokenize{#1}\endcsname}%
   \expandafter\def\csname ll:\detokenize{#1}\endcsname{\normalfont #1}%
   \traceparamA%
}%
\def\traceparamE\end{}%

% <<<2

\def\smartuppercase#1{% >>>2
   \bgroup %
   \traceparam{#1}%
   \MakeUppercase{\paramL}%
   \egroup%
}% <<<2

\def\smartlowercase#1{% >>>2
   \bgroup %
   \traceparam{#1}%
   \MakeLowercase{\paramL}%
   \egroup%
}% <<<2

\def\smartlcsc#1{% >>>2
   \bgroup %
   \traceparam{#1}%
   \textsc{\MakeLowercase{\paramL}}%
   \egroup%
}% <<<2

\def\smartsc#1{% >>>2
   \bgroup %
   \traceparam{#1}%
   \textsc{\paramL}%
   \egroup%
}% <<<2

\renewcommand*{\mkbibacro}[1]{% >>>2
  \iftoggle{scbib}{%
    \textsc{\MakeLowercase{#1}}%
  }{\MakeUppercase{#1}}%
}% <<<2

\newcommand*{\UpperOrSC}[1]{% >>>2
  \let\MakeCapital\relax%
  \iftoggle{scbib}{%
    \textsc{\MakeLowercase{#1}}%
  }{%
    \MakeUppercase{#1}%
  }%
}% <<<2

\newcommand*{\NormalOrSC}[1]{% >>>2
  \iftoggle{scbib}{%
    \textsc{\MakeLowercase{#1}}%
  }{%
    #1%
  }%
}% <<<2


% auxiliary commands
\ExplSyntaxOn
% {<string>}{<regex>}
\NewDocumentCommand { \abntblx@regex@match } { mm } {
  \regex_match:nnTF { #2 } { #1 }
}
\ExplSyntaxOff

% define \iffieldregex{<field>}{<regex>}
\newcommand*{\blx@imc@iffieldregex}{}
\newcommand*{\iffieldregex}{}

\protected\def\blx@imc@iffieldregex#1#2{%
  \blx@imc@iffieldundef{#1}
    {\@secondoftwo}
    {\expandafter\expandafter
     \expandafter\abntblx@regex@match
     \expandafter\expandafter
     \expandafter{\csname abx@field@#1\endcsname}{#2}}}

\blx@regimcs{\iffieldregex}

\newcommand*{\iffieldendswithpunct}[1]{%
  \iffieldregex{#1}{(\.|\!|\?|\-|\:|\/)\Z}%
}

% <<<1


% Formatting >>>1

% Use \refname for headings >>>2
\ifcase\abx@classtype\relax % article
\or % book/report
  \defbibheading{bibliography}[\refname]{%
    \chapter*{#1}%
    \@mkboth{\abx@MakeMarkcase{#1}}{\abx@MakeMarkcase{#1}}}
\or % scrartcl
\or % scrbook/scrreprt
  \defbibheading{bibliography}[\refname]{%
    \ifcsundef{bibliography@heading}
      {\ifkomabibtotocnumbered
         {\chapter{#1}}
         {\ifkomabibtotoc
            {\addchap{#1}}
            {\chapter*{#1}
             \ifcsundef{@mkdouble}
               {\@mkboth{\abx@MakeMarkcase{#1}}{\abx@MakeMarkcase{#1}}}
               {\@mkdouble{\abx@MakeMarkcase{#1}}}}}}
      {\bibliography@heading{#1}}}
\or % memoir (article)
\or % memoir (book)
  \ifcsundef{memUChead}{}{\def\abx@MakeMarkcase{\memUChead}}%
  \defbibheading{bibliography}[\refname]{%
    \chapter*{#1}%
    \if@twoside
      \markboth{\abx@MakeMarkcase{#1}}{\abx@MakeMarkcase{#1}}%
    \else
      \markright{\abx@MakeMarkcase{#1}}%
    \fi
    \ifmemoirbibintoc
      {\phantomsection
       \addcontentsline{toc}{chapter}{#1}}
      {}}
\fi
% <<<2

% \IfGivenIsInitial >>>2

\ExplSyntaxOn%

\ProvideDocumentCommand{\IfGivenIsInitial}{mm}{%
  \regex_match:nVTF {\w\w} \namepartgiven {#2} {#1}%
}%
\cs_generate_variant:Nn \regex_match:nnTF { nV }%

\ExplSyntaxOff%

% <<<2

% Name format >>>2

\DeclareNameFormat{LAST-first}{%% >>>3
  \renewcommand*{\mkbibnamefamily}[1]{\UpperOrSC{##1}}%
  \renewcommand*{\mkbibnamegiven}[1]{\ifgiveninits{\NormalOrSC{##1}}{##1}}%
  \renewcommand*{\mkbibnamegiven}[1]{%
    \ifgiveninits{%
      \NormalOrSC{##1}%
    }{%
      \IfGivenIsInitial{\NormalOrSC{##1}}{##1}%
    }%
  }%
  \renewcommand*{\mkbibnameprefix}[1]{%
    \ifuseprefix{%
      \UpperOrSC{##1}%
    }{%
      \ifgiveninits{\NormalOrSC{##1}}{##1}%
    }%
  }%
  \renewcommand*{\mkbibnamesuffix}[1]{\UpperOrSC{##1}}%
  \ifgiveninits{%
    \usebibmacro{name:family-given}%
    {\namepartfamily}%
    {\namepartgiveni}%
    {\namepartprefix}%
    {\namepartsuffix}%
  }{%
    \usebibmacro{name:family-given}%
    {\namepartfamily}%
    {\namepartgiven}%
    {\namepartprefix}%
    {\namepartsuffix}%
  }%
  \usebibmacro{name:andothers}%
}% <<<

\DeclareNameAlias{default}{LAST-first}%

\DeclareNameFormat{full}{%% >>>3
  \usebibmacro{name:given-family}%
    {\namepartfamily}%
    {\namepartgiven}%
    {\namepartprefix}%
    {\namepartsuffix}%
}% <<<

\DeclareNameAlias{byauthor}{full}%
\DeclareNameAlias{bybookauthor}{byauthor}%
\DeclareNameAlias{byeditor}{full}%
\DeclareNameAlias{byeditora}{byeditor}%
\DeclareNameAlias{byeditorb}{byeditor}%
\DeclareNameAlias{byeditorc}{byeditor}%
\DeclareNameAlias{bytranslator}{full}%

\DeclareNameAlias{withcommentator}{given-family}%
\DeclareNameAlias{withannotator}{given-family}%
\DeclareNameAlias{withintroduction}{given-family}%
\DeclareNameAlias{withforeword}{given-family}%
\DeclareNameAlias{withafterword}{given-family}%

\DeclareBibliographyAlias{legislation}{article}%
\DeclareBibliographyAlias{jurisdiction}{article}%
\DeclareBibliographyAlias{legal}{article}%

% Name delimiters >>>3
\newtoggle{byeditor+others}%

\let\multinamedelimorig\multinamedelim%
\let\finalnamedelimorig\finalnamedelim%

\renewcommand*{\multinamedelim}{%
  \iftoggle{byeditor+others}{%
    \addcomma\addspace%
  }{%
    \addsemicolon\addspace%
  }%
}%

\renewcommand*{\finalnamedelim}{%
  \iftoggle{byeditor+others}{%
    \addspace\bibstring{and}\addspace%
  }{%
    \addsemicolon\addspace%
  }%
}%
% <<<

% <<<2

% Field format >>>2

% Standard entry fields >>>3

\DeclareFieldFormat{authortype}{\printtext[parens]{\midsentence#1}}%
\DeclareFieldFormat{editortype}{\printtext[parens]{\midsentence#1}}%

\DeclareFieldFormat{nameaddon}{\addspace #1}%

% titles >>>4

\renewcommand*{\subtitlepunct}{\addcolon\addspace}%
\renewcommand*{\bibpagerefpunct}{\addperiod\space}%

\DeclareFieldFormat{journaltitle}{%% >>>
  \iftoggle{ittitles}{%
    \addspace\mkbibemph{#1}\isdot%
  }{%
    \addspace\mkbibbold{#1}\isdot%
  }%
}%% <<<
\DeclareFieldFormat{issuetitle}{%% >>>
  \iftoggle{ittitles}{%
    \addspace\mkbibemph{#1}\isdot%
  }{%
    \addspace\mkbibbold{#1}\isdot%
  }%
}%% <<<
\DeclareFieldFormat{maintitle}{%% >>>
  \iftoggle{ittitles}{%
    \addspace\mkbibemph{#1}\isdot%
  }{%
    \addspace\mkbibbold{#1}\isdot%
  }%
}%% <<<
\DeclareFieldFormat{booktitle}{%% >>>
  \iftoggle{ittitles}{%
    \addspace\mkbibemph{#1}\isdot%
  }{%
    \addspace\mkbibbold{#1}\isdot%
  }%
}%% <<<
\DeclareFieldFormat{citetitle}{%% >>>
  \iftoggle{ittitles}{%
    \addspace\mkbibemph{#1}\isdot%
  }{%
    \addspace\mkbibbold{#1}\isdot%
  }%
}%% <<<
\DeclareFieldFormat*{title}{%% >>>
  \iftoggle{ittitles}{%
    \addspace\mkbibemph{#1}\isdot%
  }{%
    \addspace\mkbibbold{#1}\isdot%
  }%
}%% <<<
\DeclareFieldFormat[% title >>>
  article,%
  legislation,%
  jurisdiction,%
  legal,%
  inbook,%
  incollection,%
  bookinbook,%
  inproceedings,%
  inthesis,%
  unpublished%
]{title}{\addspace #1\isdot}%% <<<

% <<<

% number >>>4
\DeclareNumChars*{,-/}%
\newcommand{\abntnum}[1]{\ifrmnum{#1}{\rmntonum{#1}}{#1}}%
\DeclareFieldFormat*{number}{%% >>>
  \ifnumerals{#1}%
    {\addspace \MakeLowercase{\bibstring{number}}~\abntnum{#1}}%
    {\addspace #1\isdot}%
}%% <<<
\DeclareFieldFormat[% number >>>
  book,%
  collection,%
  misc%
]{number}{\addcomma\addspace #1}%% <<<
\DeclareFieldFormat[% number >>>
  proceedings,%
  inproceedings,%
]{number}{\addspace #1}%% <<<
% <<<

\DeclareFieldFormat*{volume}{%% >>>4
  \ifnumerals{#1}%
    {\addspace \MakeLowercase{\bibstring{volume}}~#1}%
    {\addspace #1\isdot}%
}%% <<<

\DeclareFieldFormat*{chapter}{%% >>>4
  \ifnumerals{#1}%
    {\addspace \MakeLowercase{\bibstring{chapter}~#1}}%
    {\addspace #1\isdot}%
}%% <<<

\DeclareFieldFormat{edition}{%% >>>4
  \ifnumerals{#1}%
    {\addspace #1\adddot\addspace\bibstring{edition}}%
    {\addspace #1\isdot}%
}%% <<<

\DeclareFieldFormat*{pages}{%% >>>4
  \midsentence \MakeLowercase{\mkpageprefix[bookpagination]{#1}}%
}%% <<<
% \xpretofieldformat{pages}{\midsentence}{}{} % Fix the capitalization of the page label

\DeclareFieldFormat*{pagetotal}{%% >>>4
  \MakeLowercase{\mkpagetotal[bookpagination]{#1}}%
}%% <<<

\DeclareFieldFormat{illustrated}{\addspace #1\isdot}%

% remove <> in URLs according to abnt-6023:2018
\DeclareFieldFormat{url}{\textmainlang{\bibstring{urlfrom}\addcolon\addspace \url{#1}}}
\DeclareFieldFormat{urldate}{\textmainlang{\bibstring{urlseen}\addcolon\addspace #1}}%

\DeclareFieldFormat*{note}{\addspace #1}%

\DeclareFieldFormat{mathesis}{\bibstring{mathesis}}%
\DeclareFieldFormat{phdthesis}{\bibstring{phdthesis}}%

\DeclareFieldFormat[monography]{type}{%% >>>4
  \bibstring{monography}\addspace\printtext[parens]{#1}%
}%% <<<

\DeclareListFormat{origlanguage}{%% >>>4
    \ifbibstring{#1}%
      {\bibxstring{#1}}%
      {\ifbibstring{from#1}%
         {\bibxstring{from#1}}%
         {#1}}%
}%% <<<

% is*n >>>4
\DeclareFieldFormat{isbn}{\mkbibacro{ISBN}\space #1}%
\DeclareFieldFormat{isrn}{\mkbibacro{ISRN}\space #1}%
\DeclareFieldFormat{issn}{\mkbibacro{ISSN}\space #1}%
% <<<

% relatedstring >>>4
\DeclareFieldFormat{relatedstring:reprintfrom}{#1\addcolon\addspace}%
\DeclareFieldFormat{relatedstring:reviewof}{#1\addcolon\addspace}%
\DeclareFieldFormat{relatedstring:default}{#1\addcolon\addspace}%
% <<<

% <<<

% Capitalization >>>3

\DeclareFieldFormat{lowercase}{\smartlowercase{#1}}%

\DeclareFieldFormat{uppercase}{%% >>>
  \iftoggle{scbib}{%
    \textsc{\smartlowercase{#1}}%
  }{%
    \smartuppercase{#1}%
  }%
}%% <<<

\DeclareListFormat{uppercase}{%% >>>
  \usebibmacro{list:delim}{#1}%
  \iftoggle{scbib}{%
    \ifgiveninits{%
      \normalfont\smartsc{#1}%
    }{%
      \normalfont\smartlcsc{#1}%
    }%
  }{%
    \normalfont\smartuppercase{#1}%
  }%
  \isdot%
  \usebibmacro{list:andothers}%
}%% <<<

\DeclareFieldFormat{upperfirst}{%% >>>
  \iftoggle{scbib}{%
    \ifgiveninits{%
      \normalfont\FirstWordSC{#1}%
    }{%
      \normalfont\FirstWordLCSC{#1}%
    }%
  }{%
    \normalfont\FirstWordUpper{#1}%
  }%
}%% <<<

\DeclareListFormat{upperfirst}{%% >>>
  \usebibmacro{list:delim}{#1}%
    \iftoggle{scbib}{%
      \ifgiveninits{%
        \normalfont\FirstWordSC{#1}%
      }{%
        \normalfont\FirstWordLCSC{#1}%
      }%
    }{%
      \normalfont\FirstWordUpper{#1}%
    }%
    \isdot%
  \usebibmacro{list:andothers}%
}%% <<<

% <<<

\DeclareFieldFormat{normalfont}{\normalfont{#1}}%

% <<<2

% <<<1


% Drivers >>>1

\DeclareBibliographyDriver{article}{%% >>>2
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/organization}%
  \setunit{\labelnamepunct}%
  \usebibmacro{title}\newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printlist{language}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{byauthor}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{byeditor+others}\newunit%
  \usebibmacro{bytranslator+others}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{version}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \iffieldundef{relatedtype}{}{%
    \bibstring{\strfield{relatedtype}}}%
  \setunit*{\addcolon\addspace}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{journal+section}%
  \setunit*{\addcomma\addspace}%
  \printlist{publisher}%
  \setunit*{\addcomma\addspace}%
  \printlist{location}%
  \setunit*{\addcomma\addspace}%
  \usebibmacro{volume+number+eid}%
  \setunit{\addcomma\addspace}%
  \printfield{pages}%
  \setunit*{\addcomma\addspace}%
  \printfield{pagetotal}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{issue+date}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{note}%
  \printunit{\addperiod\addspace}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \iftoggle{bbx:isbn}%
    {\printfield{issn}}%
    {}%
    \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{doi+eprint+url}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{pageref}%
  \setunit*{\addperiod\addspace}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \iftoggle{bbx:related}%
    {\usebibmacro{related:init}%
    \usebibmacro{related}}%
    {}%
  \usebibmacro{finentry}%
}%% <<<2

\DeclareBibliographyDriver{book}{%% >>>2
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/editor+others}%
  \setunit{\labelnamepunct}%
  \usebibmacro{title}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{in:maintitle}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{byeditor+others}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{edition}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{publisher+location+date}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{volume}%
  \printfield{part}%
  \setunit{\addcomma\addspace}%
  \printfield{chapter}%
  \setunit*{\addcomma\addspace}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{pages}%
  \newunit%
  \printfield{pagetotal}%
  \setunit*{\addcomma\addspace}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{illustrated}%
  \setunit*{\addcomma\addspace}%
  \printfield{dimensions}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{series+number}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{howpublished}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{language}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{note}%
  \printunit{\addperiod\addspace}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \iftoggle{bbx:isbn}%
    {\printfield{isbn}}%
    {}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{doi+eprint+url}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{pageref}%
  \setunit*{\addperiod\addspace}%
  \setunit*{\addperiod\addspace}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \iftoggle{bbx:related}%
    {\usebibmacro{related:init}%
     \usebibmacro{related}}%
    {}%
  \usebibmacro{finentry}%
}%% <<<2

\DeclareBibliographyDriver{inbook}{%% >>>2
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/editor+others}%
  \setunit{\labelnamepunct}%
  \usebibmacro{title}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{in:bookauthor+others}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{maintitle/booktitle}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{byeditor+others}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{edition}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{publisher+location+date}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{volume}%
  \printfield{part}%
  \setunit*{\addcomma\addspace}%
  \usebibmacro{chapter+pages}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{series+number}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{note}%
  \printunit{\addperiod\addspace}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \iftoggle{bbx:isbn}%
    {\printfield{isbn}}%
    {}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{doi+eprint+url}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{pageref}%
  \setunit*{\addperiod\addspace}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \iftoggle{bbx:related}%
    {\usebibmacro{related:init}%
     \usebibmacro{related}}%
    {}%
  \usebibmacro{finentry}%
}%% <<<2

\DeclareBibliographyDriver{mvbook}{%% >>>2
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/editor+others}%
  \setunit{\labelnamepunct}%
  \usebibmacro{title}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{in:maintitle}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{byeditor+others}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{edition}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{publisher+location+date}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{volumes}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{chapter+pages}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{pagetotal}%
  \setunit*{\addcomma\addspace}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{illustrated}%
  \setunit*{\addcomma\addspace}%
  \printfield{dimensions}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{series+number}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{howpublished}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{language}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{note}%
  \printunit{\addperiod\addspace}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \iftoggle{bbx:isbn}%
    {\printfield{isbn}}%
    {}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{doi+eprint+url}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{pageref}%
  \setunit*{\addperiod\addspace}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \iftoggle{bbx:related}%
    {\usebibmacro{related:init}%
     \usebibmacro{related}}%
    {}%
  \usebibmacro{finentry}%
}%% <<<2

\DeclareBibliographyDriver{booklet}{%% >>>2
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/editor+others}%
  \setunit{\labelnamepunct}%
  \usebibmacro{maintitle+title}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printlist{language}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{byauthor}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{byeditor+others}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{edition}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{series+number}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{type}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{version}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{location+date}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{chapter+pages}%
  \newunit%
  \printfield{pagetotal}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{note}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \iftoggle{bbx:isbn}%
    {\printfield{isbn}}%
    {}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{doi+eprint+url}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{pageref}%
  \setunit*{\addperiod\addspace}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \iftoggle{bbx:related}%
    {\usebibmacro{related:init}%
     \usebibmacro{related}}%
    {}%
  \usebibmacro{finentry}%
}%% <<<2

\DeclareBibliographyDriver{collection}{%% >>>2
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{editor+others}%
  \setunit{\labelnamepunct}%
  \usebibmacro{title}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{in:maintitle}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{byeditor+others}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{edition}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{publisher+location+date}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{volume}%
  \printfield{part}%
  \setunit{\addcomma\addspace}%
  \printfield{chapter}%
  \setunit*{\addcomma\addspace}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{pages}%
  \newunit%
  \printfield{pagetotal}%
  \setunit*{\addcomma\addspace}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{illustrated}%
  \setunit*{\addcomma\addspace}%
  \printfield{dimensions}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{series+number}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{howpublished}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{language}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{note}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printunit{\addperiod\addspace}%
  \iftoggle{bbx:isbn}%
    {\printfield{isbn}}%
    {}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{doi+eprint+url}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{pageref}%
  \setunit*{\addperiod\addspace}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \iftoggle{bbx:related}%
    {\usebibmacro{related:init}%
     \usebibmacro{related}}%
    {}%
  \usebibmacro{finentry}%
}%% <<<2

\DeclareBibliographyDriver{incollection}{%% >>>2
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author}%
  \setunit{\labelnamepunct}%
  \usebibmacro{title}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{in:editor+others}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{maintitle/booktitle}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{byeditor+others}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{edition}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{publisher+location+date}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{volume}%
  \printfield{part}%
  \newunit%
  \usebibmacro{series+number}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{note}%
  \printunit{\addperiod\addspace}%
  \usebibmacro{chapter+pages}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \iftoggle{bbx:isbn}%
    {\printfield{isbn}}%
    {}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{doi+eprint+url}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{pageref}%
  \setunit*{\addperiod\addspace}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \iftoggle{bbx:related}%
    {\usebibmacro{related:init}%
     \usebibmacro{related}}%
    {}%
  \usebibmacro{finentry}%
}%% <<<2

\DeclareBibliographyDriver{mvcollection}{%% >>>2
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{editor+others}%
  \setunit{\labelnamepunct}%
  \usebibmacro{title}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{in:maintitle}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{byeditor+others}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{edition}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{publisher+location+date}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{volumes}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{chapter+pages}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{pagetotal}%
  \setunit*{\addcomma\addspace}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{illustrated}%
  \setunit*{\addcomma\addspace}%
  \printfield{dimensions}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{series+number}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{howpublished}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{language}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{note}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printunit{\addperiod\addspace}%
  \iftoggle{bbx:isbn}%
    {\printfield{isbn}}%
    {}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{doi+eprint+url}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{pageref}%
  \setunit*{\addperiod\addspace}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \iftoggle{bbx:related}%
    {\usebibmacro{related:init}%
     \usebibmacro{related}}%
    {}%
  \usebibmacro{finentry}%
}%% <<<2

\DeclareBibliographyDriver{manual}{%% >>>2
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/editor+others}%
  \setunit{\labelnamepunct}%
  \usebibmacro{maintitle+title}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printlist{language}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{byauthor}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{byeditor}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{edition}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{type}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{version}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{location+date}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{chapter+pages}%
  \newunit%
  \printfield{pagetotal}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{series+number}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{note}%
  \printunit{\addperiod\addspace}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \iftoggle{bbx:isbn}%
    {\printfield{isbn}}%
    {}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{doi+eprint+url}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{pageref}%
  \setunit*{\addperiod\addspace}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \iftoggle{bbx:related}%
    {\usebibmacro{related:init}%
     \usebibmacro{related}}%
    {}%
  \usebibmacro{finentry}%
}%% <<<2

\DeclareBibliographyDriver{monography}{%% >>>2
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author}%
  \setunit{\labelnamepunct}%
  \usebibmacro{title}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{date}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{chapter+pages}%
  \newunit%
  \printfield{pagetotal}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{type}%
  \setunit*{\addspace\textendash\addspace}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printlist{institution}%
  \setunit*{\addcomma\addspace}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printlist{location}%
  \setunit*{\addcomma\addspace}%
  \printeventdate%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{note}%
  \printunit{\addperiod\addspace}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \iftoggle{bbx:isbn}%
    {\printfield{isbn}}%
    {}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{doi+eprint+url}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{pageref}%
  \setunit*{\addperiod\addspace}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \iftoggle{bbx:related}%
    {\usebibmacro{related:init}%
     \usebibmacro{related}}%
    {}%
  \usebibmacro{finentry}%
}%% <<<2

\DeclareBibliographyDriver{patent}{%% >>>2
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \ifnameundef{holder}{%
    \iflistundef{organization}{%
      \usebibmacro{author/editor+others}%
    }{%
      \usebibmacro{organization}%
      \ifnameundef{author}{%
        \printnames[given-family]{editor}%
      }{%
        \printnames[given-family]{author}%
      }%
      \newunit%
      \printfield{nameaddon}%
      \newunit%
    }%
  }{%
      \printnames{holder}%
      \newunit%
      \printfield{nameaddon}%
      \newunit%
      \ifnameundef{author}{%
        \printnames[given-family]{editor}%
      }{%
        \printnames[given-family]{author}%
      }%
  }%
  \setunit{\labelnamepunct}%
  \usebibmacro{title}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printlist{language}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{byauthor}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{byeditor+others}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printlist{location}%
  \setunit*{\addcomma\addspace}%
  \usebibmacro{date}%
  \setunit*{\addcomma\addspace}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{number}%
  \setunit*{\addcomma\addspace}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{howpublished}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{type}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{version}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{note}%
  \printunit{\addperiod\addspace}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{doi+eprint+url}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{pageref}%
  \setunit*{\addperiod\addspace}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \iftoggle{bbx:related}%
    {\usebibmacro{related:init}%
     \usebibmacro{related}}%
    {}%
  \usebibmacro{finentry}%
}%% <<<2

\DeclareBibliographyDriver{periodical}{%% >>>2
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{editor+others/organization}%
  \setunit{\labelnamepunct}%
  \printfield[uppercase]{title}%
  \setunit*{\addcolon\addspace}%
  \printfield[normalfont]{subtitle}%
  \newunit%
  \printfield{titleaddon}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{publisher+location+issue+date}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printlist{language}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{byeditor}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{chapter+pages}%
  \setunit*{\addcomma\addspace}%
  \printfield{pagetotal}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{note}%
  \printunit{\addperiod\addspace}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \iftoggle{bbx:isbn}%
    {\printfield{issn}}%
    {}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{doi+eprint+url}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{pageref}%
  \setunit*{\addperiod\addspace}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \iftoggle{bbx:related}%
    {\usebibmacro{related:init}%
     \usebibmacro{related}}%
    {}%
  \usebibmacro{finentry}%
}%% <<<2

\DeclareBibliographyDriver{supperiodical}{%% >>>2
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/editor+others}%
  \setunit{\labelnamepunct}%
  \usebibmacro{issue}%
  \setunit*{\addperiod\addspace}%
  \usebibmacro{periodical}%
  \setunit*{\addperiod\addspace}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{location}%
  \setunit*{\addcolon\addspace}%
  \usebibmacro{publisher}%
  \setunit*{\addcomma\addspace}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{volume}%
  \setunit*{\addcomma\addspace}%
  \printfield{number}%
  \setunit*{\addcomma\addspace}%
  \printfield{pages}%
  \setunit*{\addcomma\addspace}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{date}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printlist{language}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{byauthor}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{byeditor+others}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{howpublished}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{type}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{version}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{chapter+pages}%
  \setunit*{\addcomma\addspace}%
  \printfield{pagetotal}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{note}%
  \printunit{\addperiod\addspace}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{doi+eprint+url}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{pageref}%
  \setunit*{\addperiod\addspace}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \iftoggle{bbx:related}%
    {\usebibmacro{related:init}%
     \usebibmacro{related}}%
    {}%
  \usebibmacro{finentry}%
}%% <<<2

\DeclareBibliographyDriver{proceedings}{%% >>>2
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{organization/eventtitle}%
  \setunit{\addcomma\addspace}%
  \printfield{number}%
  \setunit*{\adddot\addcomma\addspace}%
  \printeventdate%
  \setunit{\addcomma\addspace}%
  \usebibmacro{venue}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{maintitle+title}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{byeditor+others}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{publisher+location+date}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \iffieldundef{maintitle}%
    {\printfield{volume}%
     \printfield{part}}%
    {}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{volumes}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{note}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printunit{\addperiod\addspace}%
  \printlist{organization}% % This has to be printed conditionally
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{chapter+pages}%
  \newunit%
  \printfield{pagetotal}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \iftoggle{bbx:isbn}%
    {\printfield{isbn}}%
    {}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{doi+eprint+url}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{pageref}%
  \setunit*{\addperiod\addspace}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \iftoggle{bbx:related}%
    {\usebibmacro{related:init}%
     \usebibmacro{related}}%
    {}%
  \usebibmacro{finentry}%
}%% <<<2

\DeclareBibliographyDriver{inproceedings}{%% >>>2
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/translator+others}%
  \setunit{\labelnamepunct}%
  \usebibmacro{title}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printlist{language}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{byauthor}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{in:eventtitle/organization/editor}%
  \setunit*{\addcomma\addspace}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{number}%
  \setunit*{\adddot\addcomma\addspace}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printeventdate%
  \setunit*{\addcomma\addspace}%
  \printfield{venue}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{maintitle+booktitle}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{byeditor+others}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \ifboolexpr{%
    test {\iffieldundef{booktitle}}%
    and%
    test {\iffieldundef{maintitle}}%
  }%
  {}%
  {\usebibmacro{publisher+location+date}}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \iffieldundef{maintitle}%
    {\printfield{volume}%
     \printfield{part}}%
    {}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{volumes}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{series+number}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printlist{organization}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{chapter+pages}%
  \newunit%
  \printfield{pagetotal}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{note}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printunit{\addperiod\addspace}%
  \iftoggle{bbx:isbn}%
    {\printfield{isbn}}%
    {}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{doi+eprint+url}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{pageref}%
  \setunit*{\addperiod\addspace}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \iftoggle{bbx:related}%
    {\usebibmacro{related:init}%
     \usebibmacro{related}}%
    {}%
  \usebibmacro{finentry}%
}%% <<<2

\DeclareBibliographyDriver{report}{%% >>>2
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/editor+others}%
  \setunit{\labelnamepunct}%
  \usebibmacro{maintitle+title}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printlist{language}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{byauthor}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{byeditor+others}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{edition}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \iffieldundef{maintitle}%
    {\printfield{volume}%
     \printfield{part}}%
    {}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{volumes}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{location+date}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{chapter+pages}%
  \newunit%
  \printfield{pagetotal}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{series+number}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{note}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printunit{\addperiod\addspace}%
  \iftoggle{bbx:isbn}%
    {\printfield{isbn}}%
    {}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{doi+eprint+url}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{pageref}%
  \setunit*{\addperiod\addspace}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \iftoggle{bbx:related}%
    {\usebibmacro{related:init}%
     \usebibmacro{related}}%
    {}%
  \usebibmacro{finentry}%
}%% <<<2

\DeclareBibliographyDriver{thesis}{%% >>>2
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author}%
  \setunit{\labelnamepunct}%
  \usebibmacro{title}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{date}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{chapter+pages}%
  \newunit%
  \printfield{pagetotal}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{type}%
  \setunit*{\addspace\textendash\addspace}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printlist{institution}%
  \setunit*{\addcomma\addspace}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printlist{location}%
  \setunit*{\addcomma\addspace}%
  \printeventdate%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{note}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printunit{\addperiod\addspace}%
  \iftoggle{bbx:isbn}%
    {\printfield{isbn}}%
    {}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{doi+eprint+url}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{pageref}%
  \setunit*{\addperiod\addspace}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \iftoggle{bbx:related}%
    {\usebibmacro{related:init}%
     \usebibmacro{related}}%
    {}%
  \usebibmacro{finentry}%
}%% <<<2

\DeclareBibliographyDriver{inthesis}{%% >>>2
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/editor+others}%
  \setunit{\labelnamepunct}%
  \usebibmacro{title}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{in:bookauthor+others}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{maintitle/booktitle}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{date}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  % \usebibmacro{chapter+pages}%
  % \newunit%
  \printfield{pagetotal}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{type}%
  \setunit*{\addspace\textendash\addspace}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printlist{institution}%
  \setunit*{\addcomma\addspace}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printlist{location}%
  \setunit*{\addcomma\addspace}%
  \printeventdate%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{pages}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{note}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printunit{\addperiod\addspace}%
  \iftoggle{bbx:isbn}%
    {\printfield{isbn}}%
    {}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{doi+eprint+url}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{pageref}%
  \setunit*{\addperiod\addspace}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \iftoggle{bbx:related}%
    {\usebibmacro{related:init}%
     \usebibmacro{related}}%
    {}%
  \usebibmacro{finentry}%
}%% >>>2

\DeclareBibliographyDriver{misc}{%% >>>2
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/editor+others}%
  \setunit{\labelnamepunct}%
  \usebibmacro{maintitle+title}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printlist{language}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{byauthor}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{byeditor+others}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{edition}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \iffieldundef{maintitle}%
    {\printfield{volume}%
     \printfield{part}}%
    {}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{volumes}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{publisher+location+date}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{chapter+pages}%
  \newunit%
  \printfield{pagetotal}%
  \setunit*{\addcomma\addspace}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{dimensions}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{howpublished}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{series+number}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printfield{note}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \printunit{\addperiod\addspace}%
  \iftoggle{bbx:isbn}%
    {\printfield{isbn}}%
    {}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{doi+eprint+url}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{pageref}%
  \setunit*{\addperiod\addspace}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \iftoggle{bbx:related}%
    {\usebibmacro{related:init}%
     \usebibmacro{related}}%
    {}%
  \usebibmacro{finentry}%
}%% <<<2

\DeclareBibliographyDriver{set}{%% >>>2
  \booltrue{bbx@inset}%
  \entryset{}{}%
  \newunit%
  \newblock%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \usebibmacro{setpageref}%
  \finentry%
}%% <<<2

% <<<1


\endinput%


% vim: set foldmarker=\ >>>,\ <<< :