%% start of file `moderncvheadv.sty'.
%% Copyright 2015-2015 Xavier Danaux (xdanaux@gmail.com), 2020-2024 moderncv maintainers (github.com/moderncv).
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License version 1.3c,
% available at http://www.latex-project.org/lppl/.


%-------------------------------------------------------------------------------
%                identification
%-------------------------------------------------------------------------------
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{moderncvheadv}[2024-07-18 v2.4.1 modern curriculum vitae and letter header variant: 5]

% details options: "details" (default) or "nodetails"
\@initializeif{\if@details}\@detailsfalse
\DeclareOption{details}   {\@detailstrue}
\DeclareOption{nodetails} {\@detailsfalse}

\DeclareOption*{}% avoid choking on unknown options
\ExecuteOptions{details}
\ProcessOptions*\relax% \ProcessOptions* processes the options in the order provided (i.e., with the later ones possibly overriding the former ones), while \ProcessOptions processes them in the order of the package


%-------------------------------------------------------------------------------
%                required packages
%-------------------------------------------------------------------------------


%-------------------------------------------------------------------------------
%                overall head definition
%-------------------------------------------------------------------------------
% fonts
\renewcommand*{\namefont}{\fontsize{34}{36}\mdseries\upshape}
\renewcommand*{\titlefont}{\LARGE\mdseries\slshape}
\renewcommand*{\addressfont}{\small\mdseries\slshape}
\renewcommand*{\quotefont}{\large\slshape}

% styles
\renewcommand*{\namestyle}[1]{{\namefont\textcolor{namecolor}{#1}}}
\renewcommand*{\firstnamestyle}[1]{{\namefont\textcolor{firstnamecolor}{#1}}}
\renewcommand*{\lastnamestyle}[1]{{\namefont\textcolor{lastnamecolor}{#1}}}
\renewcommand*{\titlestyle}[1]{{\titlefont\textcolor{titlecolor}{#1}}}
\renewcommand*{\addressstyle}[1]{{\addressfont\textcolor{addresscolor}{#1}}}
\renewcommand*{\quotestyle}[1]{{\quotefont\textcolor{quotecolor}{#1}}}


%-------------------------------------------------------------------------------
%                resume head definition
%-------------------------------------------------------------------------------
% lengths
\@initializelength{\quotewidth}
\renewcommand*{\recomputecvheadlengths}{%
  \setlength{\quotewidth}{0.65\textwidth}}

% commands
\renewcommand*{\makecvhead}{%
  % recompute lengths (in case we are switching from letter to resume, or vice versa)
  \recomputecvlengths%
  % optional photo (pre-rendering)
  \@initializebox{\makecvheadpicturebox}%
  \savebox{\makecvheadpicturebox}{%
    \ifthenelse{\isundefined{\@photo}}%
    {}%
    {%
      \color{pictureframecolor}%
      \setlength{\fboxrule}{\@photoframewidth}%
      \ifdim\@photoframewidth=0pt%
        \setlength{\fboxsep}{0pt}\fi%
      \framebox{\includegraphics[width=\@photowidth]{\@photo}}}}%
  % rendering
  \@makecvtitle%
    {%
      \raggedleft%
      % optional photo
      \usebox{\makecvheadpicturebox}%
      % optional details
      \if@details%
        \ifthenelse{\isundefined{\@photo}}{}{\\[0.5em]}%
        \addressfont\color{addresscolor}%
        \ifthenelse{\isundefined{\@addressstreet}}{}{\makenewline\addresssymbol\@addressstreet%
          \ifthenelse{\equal{\@addresscity}{}}{}{\makenewline\@addresscity}% if \addresstreet is defined, \addresscity and \addresscountry will always be defined but could be empty
          \ifthenelse{\equal{\@addresscountry}{}}{}{\makenewline\@addresscountry}}%
        \ifthenelse{\isundefined{\@born}}{}{\makenewline\bornsymbol~\@born}%
        \collectionloop{phones}{% the key holds the phone type (=symbol command prefix), the item holds the number
          \makenewline\csname\collectionloopkey phonesymbol\endcsname~\collectionloopitem}%
        \ifthenelse{\isundefined{\@email}}{}{\makenewline\emailsymbol~\emaillink{\@email}}%
        \ifthenelse{\isundefined{\@homepage}}{}{\makenewline\homepagesymbol~%
          \ifthenelse{\equal{\@homepageprotocol}{http}}{\httplink{\@homepage}}{\httpslink{\@homepage}}}%
        \collectionloop{socials}{% the key holds the social type (=symbol command prefix), the item holds the link
          \makenewline\csname\collectionloopkey socialsymbol\endcsname~\collectionloopitem}%
        \ifthenelse{\isundefined{\@extrainfo}}{}{\makenewline\@extrainfo}\fi}%
    {%
      % name and optional title
      \newlength{\makecvheadpictureboxskip}%
      \setlength{\makecvheadpictureboxskip}{\totalheightof{\usebox{\makecvheadpicturebox}}}%
      \firstnamestyle{\@firstname}~\lastnamestyle{\@lastname}%
	  \ifthenelse{\equal{\@title}{}}{
	    \ifthenelse{\isundefined{\@quote}}%
        {}%
        {%
          \\[1.25em]%
          \begin{minipage}{\quotewidth}%
            \quotestyle{\@quote}%
          \end{minipage}}%
	    }{%
	      \\[1.25em]%
        \titlestyle{\@title}
        % optional quote
        \ifthenelse{\isundefined{\@quote}}%
          {\vspace{2.5em}}%
          {%
            \\[2.5em]%
            \begin{minipage}{\quotewidth}%
              \quotestyle{\@quote}
            \end{minipage}}}}%
  \par}% to avoid weird spacing bug at the first section if no blank line is left after \makecvhead

% underlying command to implement \makecvtitle, identical to \@cvitem from moderncvbodyv
\let\standarddoublebackslash\\%
\newcommand*{\@makecvtitle}[3][.5ex]{%
  \arrayrulecolor{headrulecolor}%
  \setlength\arrayrulewidth{1.2\p@}%
  \if@aftersection\else%
    \vspace*{-\arrayrulewidth}\fi% HACK; I don't understand where the space is coming from, nor what it's exact value is :(
  \noindent%
  \begin{tabular}[t]{@{}p{\hintscolumnwidth}@{\hspace{\separatorcolumnwidth}}|@{\hspace{\separatorcolumnwidth}}p{\maincolumnwidth}@{}}%
    \@moderncvstrut{4pt}{16pt}%
    \begin{minipage}[t]{\hintscolumnwidth}#2\end{minipage}
      &\begin{minipage}[t]{\maincolumnwidth}#3\end{minipage}%
      \\[#1]% the spacing needs to be inside the cell for the vertical rule to extend correctly
  \end{tabular}%
  \par\@aftersectionfalse\ignorespaces}


%-------------------------------------------------------------------------------
%                letter head definition
%-------------------------------------------------------------------------------
% lengths
%\renewcommand*{\recomputeletterheadlengths}{}

% commands
\renewcommand*{\makeletterhead}{%
  % recompute lengths (in case we are switching from letter to resume, or vice versa)
  \recomputeletterlengths%
  % sender contact info
  \hfill%
  \begin{minipage}{.5\textwidth}%
    % optional detailed information
    \if@details%
      \raggedleft%
      \addressfont\textcolor{addresscolor}{%
        {\bfseries\upshape\@firstname~\@lastname}\@firstdetailselementfalse%
        % optional detailed information
        \ifthenelse{\isundefined{\@addressstreet}}{}{\makenewline\addresssymbol\@addressstreet%
          \ifthenelse{\equal{\@addresscity}{}}{}{\makenewline\@addresscity}% if \addresstreet is defined, \addresscity and addresscountry will always be defined but could be empty
          \ifthenelse{\equal{\@addresscountry}{}}{}{\makenewline\@addresscountry}}%
        \collectionloop{phones}{% the key holds the phone type (=symbol command prefix), the item holds the number
          \makenewline\csname\collectionloopkey phonesymbol\endcsname\collectionloopitem}%
        \ifthenelse{\isundefined{\@email}}{}{\makenewline\emailsymbol\emaillink{\@email}}%
        \ifthenelse{\isundefined{\@homepage}}{}{\makenewline\homepagesymbol%
          \ifthenelse{\equal{\@homepageprotocol}{http}}{\httplink{\@homepage}}{\httpslink{\@homepage}}}%
        \ifthenelse{\isundefined{\@extrainfo}}{}{\makenewline\@extrainfo}}\fi%
    \end{minipage}\\[2em]
  % recipient block
  \begin{minipage}[t]{.5\textwidth}
    \raggedright%
    \addressfont%
    {\bfseries\upshape\@recipientname}\\%
    \@recipientaddress%
  \end{minipage}
  % date
  \hfill% US style
%  \\[1em]% UK style
  \@date\\[3em]% US informal style: "January 1, 1900"; UK formal style: "01/01/1900"
  % optional subject
  \ifthenelse{\isundefined{\@subject}}{}{{\bfseries\@subject\\[2em]}}
  % opening
  \raggedright%
  \@opening\\[1.5em]%
  % ensure no extra spacing after \makelettertitle due to a possible blank line
%  \ignorespacesafterend% not working
  \hspace{0pt}\par\vspace{-\baselineskip}\vspace{-\parskip}}


\endinput


%% end of file `moderncvheadv.sty'.