%%
%% This is file `verbose-trad2note-archaeology.cbx',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% biblatex-archaeology.dtx  (with options: `verbosetrad2noteCBX,verbosesharedCBX')
%% 

\ProvidesFile{verbose-trad2note-archaeology.cbx}
[2019/12/30 v2.2 biblatex-archaeology citation style (IB)]
\def\archaeocitestyletitle{\blxarch@style@vttwo}
\RequireCitationStyle{verbose-trad2}

\newbibmacro*{footcite}{%
  \usebibmacro{cite:citepages}%
  \ifciteseen
    {\iffieldundef{shorthand}
       {\usebibmacro{footcite:note}}
       {\usebibmacro{footcite:shorthand}}}
    {\usebibmacro{footcite:full}%
     \usebibmacro{footcite:save}}}

\newbibmacro*{footcite:full}{%
  \usebibmacro{cite:full:citepages}%
  \printtext[bibhypertarget]{%
    \usedriver
      {\DeclareNameAlias{sortname}{default}}
      {\thefield{entrytype}}}%
  \usebibmacro{shorthandintro}}

\newbibmacro*{footcite:note}{%
  \ifnameundef{labelname}
    {\printfield{label}}
    {\printnames{labelname}}%
  \ifsingletitle
    {}
    {\ifuselabeltitle{%
        \setunit*{\printdelim{labelnamepunct}}%
        \printfield[title]{labeltitle}}%
        {}}%
  \setunit*{\seenotedelim}%
  \printtext[seenote]{%
    \bibstring{seenote}\addnbspace
    \ref{cbx@\csuse{cbx@f@\thefield{entrykey}}}%
    \iftoggle{cbx:pageref}
      {\ifsamepage{\the\value{instcount}}
                  {\csuse{cbx@f@\thefield{entrykey}}}
         {}
     {\addcomma\space\bibstring{page}\addnbspace
      \pageref{cbx@\csuse{cbx@f@\thefield{entrykey}}}}}
      {}}}

\newbibmacro*{footcite:shorthand}{%
  \printtext[bibhyperlink]{\printfield{shorthand}}}

\DeclareCiteCommand{\cite}
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \ifseenote
     {\usebibmacro{footcite}}
     {\usebibmacro{cite}}}
  {\multicitedelim}
  {\usebibmacro{cite:postnote}}

  \DeclareCiteCommand{\footcite}[\mkbibfootnote]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \ifseenote
    {\usebibmacro{footcite}}
    {\usebibmacro{cite}}}
  {\multicitedelim}
  {\usebibmacro{cite:postnote}}

\DeclareCiteCommand{\parencite}[\mkbibparens]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \ifseenote
     {\usebibmacro{footcite}}
     {\usebibmacro{cite}}}
  {\multicitedelim}
  {\usebibmacro{cite:postnote}}

\DeclareCiteCommand{\smartcite}[\iffootnote\mkbibparens\mkbibfootnote]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \ifseenote
     {\usebibmacro{footcite}}
     {\usebibmacro{cite}}}
  {\multicitedelim}
  {\usebibmacro{cite:postnote}}

\newtoggle{cbx:pageref}
\DeclareBibliographyOption[boolean]{pageref}[true]{%
  \settoggle{cbx:pageref}{#1}%
  \iftoggle{cbx:pageref}
    {\ExecuteBibliographyOptions{pagetracker}}
    {}}
\newbibmacro*{footcite:save}{%
    \ifltxcounter{blxarch:\thefield{entrykey}}
        {\ifnumequal{0}{\value{blxarch:\thefield{entrykey}}}
            {\setcounter{blxarch:\thefield{entrykey}}{\value{footnote}}}
            {}}
        {\newcounter{blxarch:\thefield{entrykey}}%
         \setcounter{blxarch:\thefield{entrykey}}{\value{footnote}}}%
    \csxdef{cbx@f@\thefield{entrykey}}{\the\value{instcount}}%
    \label{cbx@\the\value{instcount}}
   \edef\blxarch@ult@key@count{blxarch:ult:\therefsection:\thefield{namehash}:\the\value{footnote}}%
   \ifltxcounter{\blxarch@ult@key@count}%
        {\stepcounter{\blxarch@ult@key@count}}
        {\newcounter{\blxarch@ult@key@count}%
         \setcounter{\blxarch@ult@key@count}{1}}%
   \edef\blxarch@ult@hash@count{blxarch:ult:\thefield{entrykey}:\the\value{footnote}:\therefsection}%
   \ifltxcounter{\blxarch@ult@hash@count}%
        {\stepcounter{\blxarch@ult@hash@count}}
        {\newcounter{\blxarch@ult@hash@count}%
         \setcounter{\blxarch@ult@hash@count}{1}}%
}
\renewcommand{\ifseenote}[2]{%
    \ifboolexpr{
        test {\iffootnote}
        and
        not test {\ifciteibid}
    }
        {\ifltxcounter{blxarch:\thefield{entrykey}}
            {\ifciteseen
                {\ifnumgreater{\value{footnote}}{\value{blxarch:\thefield{entrykey}}}
                    {#1}
                    {#2}%
                }
                {\setcounter{blxarch:\thefield{entrykey}}{0}#1}%
            }
            {#1}%
        }
        {#2}%
}
\newcommand{\ifuselabeltitle}[2]{%
    \edef\blxarch@ult@key@if{blxarch:ult:\thefield{entrykey}:\the\value{blxarch:\thefield{entrykey}}:\therefsection}%
    \edef\blxarch@ult@hash@if{blxarch:ult:\therefsection:\thefield{namehash}:\the\value{blxarch:\thefield{entrykey}}}%
    \ifltxcounter{\blxarch@ult@key@if}
        {\ifnumgreater{\value{\blxarch@ult@hash@if}}{\value{\blxarch@ult@key@if}}
            {#1}
            {\iftoggle{archbool:uselabeltitle}{#1}{#2}}%
        }
        {\iftoggle{archbool:uselabeltitle}{#1}{#2}}%
}
\providebibmacro*{cite:short}{}
\renewbibmacro*{cite:short}{%
    \printnames{labelname}%
    \setunit*{\printdelim{nametitledelim}}%
    \printtext[bibhyperlink]{%
    \iftoggle{archbool:citeshortin}
        {\ifboolexpr{
            not test {\iffieldundef{journaltitle}}
            or
            ( not test {\ifshortform{false}}
              and
              not test {\iffieldundef{shortform}}
            )
         }
         {\usebibmacro{cite:short:in}}
         {\printfield[citetitle]{labeltitle}}%
        }
        {\printfield[citetitle]{labeltitle}}}%
}
\newbibmacro*{cite:short:in}{%
    \savebibmacro{extendeddate}%
    \renewbibmacro*{extendeddate}[2]{}%
    \iffieldundef{journaltitle}
        {\iffieldundef{shortform}
            {\printfield[citetitle]{labeltitle}}
            {\usebibmacro{in:}%
             \printfield{shortform}%
             \setunit{\addspace}%
             \printfield[shortformvolume]{volume}%
             \setunit{\addspace}%
             \usebibmacro{bibliographydate}%
            }
        }
        {\usebibmacro{journal+issuetitle}}%
    \restorebibmacro{extendeddate}%
}
\endinput
%%
%% End of file `verbose-trad2note-archaeology.cbx'.
