%%
%% This is file `latex-lab-testphase-title.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% latex-lab-title.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Copyright 2021-2025 LaTeX Project
%% 
%% This file was generated from file(s) of the  `LaTeX-lab Bundle'.
%% ------------------------------------------------------------------------------------
%% 
%% It may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3c
%% 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.3c or later is part of all distributions of LaTeX
%% version 2008 or later.
%% 
%% This file may only be distributed together with a copy of the LaTeX
%% `LaTeX-lab Bundle'. You may however distribute the `LaTeX-lab Bundle'
%% without such generated files.
%% 
%% The newest sources can be found below
%% 
%%    https://github.com/latex3/latex2e/required/latex-lab
%% 
%% where one can also log issues in case there are any.
%% 
%% 
%% File: latex-lab-title.dtx (C) Copyright 2023-2025 LaTeX Project
\def\ltlabtitledate{2025-03-08}
\def\ltlabtitleversion{0.85d}


\ProvidesExplPackage {latex-lab-testphase-title} {\ltlabtitledate} {\ltlabtitleversion}
  {Changes related to the tagging of the title}
\cs_new_protected:Npn \__tag_patch_thanks:n #1
  {
    \rlap{\footnotemark}
    \protected@xdef\@thanks{\@thanks
      \protect\footnotetext[\the\c@footnote]{#1}}
  }
\cs_new_protected:Npn \__tag_patch_maketitle:
  {
    \par
    \begingroup
      \cs_if_exist_use:N\__tag_tbl_disable:
      \renewcommand\thefootnote{\@fnsymbol\c@footnote}%
      \cs_set_eq:NN \thanks \__tag_patch_thanks:n
      \if@twocolumn
        \ifnum \col@number=\@ne
          \@maketitle
        \else
          \twocolumn[\@maketitle]%
        \fi
      \else
      \newpage
        \global\@topnum\z@   % Prevents figures from going at top of page.
        \@maketitle
      \fi
      \thispagestyle{plain}\@thanks
    \endgroup
    \setcounter{footnote}{0}%
    \global\let\thanks\relax
    \global\let\maketitle\relax
    \global\let\@maketitle\relax
    \global\let\@thanks\@empty
    \global\let\@author\@empty
    \global\let\@date\@empty
    \global\let\@title\@empty
    \global\let\title\relax
    \global\let\author\relax
    \global\let\date\relax
    \global\let\and\relax
  }
\cs_new_protected:Npn \__tag_patch_@maketitle:
 {
  \newpage
  \null
  \vskip 2em%
  \begin{center}%
  \let \footnote \thanks
  \pdf_version_compare:NnTF > {1.7}
    {{\LARGE \tag_struct_begin:n{tag=Title}\@title \par\tag_struct_end:}}
    {{\LARGE \tagtool{paratag=Title}\@title \par}}%
   \vskip 1.5em%
    {\large
      \lineskip .5em%
      \begin{tabular}[t]{c}%
        \@author
      \end{tabular}\par}%
    \vskip 1em%
    {\large \@date}%
  \end{center}%
  \par
  \vskip 1.5em
  }

\cs_new_protected:Npn \__tag_patch_maketitle_page:
  {\begin{titlepage}%
  \cs_if_exist_use:N\__tag_tbl_disable:
  \let\footnotesize\small
  \let\footnoterule\relax
  \let \footnote \thanks
  \null\vfil
  \vskip 60\p@
  \begin{center}%
   \pdf_version_compare:NnTF > {1.7}
     {{\LARGE \tag_struct_begin:n{tag=Title}\@title \par\tag_struct_end:}}
     {{\LARGE \tagtool{paratag=Title}\@title \par}}%
   \vskip 3em%
    {\large
     \lineskip .75em%
      \begin{tabular}[t]{c}%
        \@author
      \end{tabular}\par}%
      \vskip 1.5em%
    {\large \@date \par}%       % Set date in \large size.
  \end{center}\par
  \@thanks
  \vfil\null
  \end{titlepage}%
  \setcounter{footnote}{0}%
  \global\let\thanks\relax
  \global\let\maketitle\relax
  \global\let\@thanks\@empty
  \global\let\@author\@empty
  \global\let\@date\@empty
  \global\let\@title\@empty
  \global\let\title\relax
  \global\let\author\relax
  \global\let\date\relax
  \global\let\and\relax
  }

\AddToHook{class/article/after}
  {
    \if@titlepage
     \cs_set_eq:NN \maketitle \__tag_patch_maketitle_page:
    \else
     \cs_set_eq:NN \maketitle \__tag_patch_maketitle:
     \cs_set_eq:NN \@maketitle \__tag_patch_@maketitle:
    \fi
  }
\AddToHook{class/report/after}
  {
    \if@titlepage
     \cs_set_eq:NN \maketitle \__tag_patch_maketitle_page:
    \else
    \cs_set_eq:NN \maketitle \__tag_patch_maketitle:
    \cs_set_eq:NN \@maketitle \__tag_patch_@maketitle:
    \fi
  }
\AddToHook{class/book/after}
  {
    \if@titlepage
     \cs_set_eq:NN \maketitle \__tag_patch_maketitle_page:
    \else
    \cs_set_eq:NN \maketitle \__tag_patch_maketitle:
    \cs_set_eq:NN \@maketitle \__tag_patch_@maketitle:
    \fi
  }
\str_new:N \g__tag_title_tmpa_str
\str_new:N \l__tag_title_tmpa_str
\tl_new:N  \l__tag_title_tmpa_tl
\seq_new:N \l__tag_title_tmpa_seq
\providecommand\texorpdfstring[2]{#1}%
\protected\def\@title{\@latex@error{No~\noexpand\title given}\@ehc}
\protected\def\@author{\@latex@warning@no@line{No~\noexpand\author given}}
\cs_new_protected:Npn \__tag_title_pdfstring:nnN #1 #2 #3 % #1 text, #2 e.g. utf16/hex
  {
    \group_begin:
    \cs_set_eq:NN\texorpdfstring\use_ii:nn
    \str_set:Ne \l__tag_title_tmpa_str {\text_purify:n { #1 } }
    \pdf_string_from_unicode:nVN { #2 } \l__tag_title_tmpa_str \l__tag_title_tmpa_str
    \str_gset_eq:NN \g__tag_title_tmpa_str\l__tag_title_tmpa_str
    \group_end:
    \str_set_eq:NN #3 \g__tag_title_tmpa_str
  }
\cs_generate_variant:Nn\__tag_title_pdfstring:nnN {e}

\tl_new:N \g__tag_title_title_tl
\RenewDocumentCommand\title{O{}m}
 {
    \gdef\@title{#2}
    \tl_gset_eq:NN\g__tag_title_title_tl\@title
    \keys_set:nn {hyp}{#1}
 }
\regex_new:N\l__tag_title_optlang_regex
\regex_set:Nn\l__tag_title_optlang_regex {\A\[([A-Za-z\-]+)\](.*)}
\cs_generate_variant:Nn \regex_extract_once:NnN{NVN}
\cs_generate_variant:Nn \clist_item:nn {on}
\keys_define:nn { hyp }
   {
     pdftitle  .code:n =
       {
         \tl_if_blank:nTF {#1}
           {
             \pdfmanagement_remove:nn {Info}{Title}
           }
           {
             \tl_set:Ne\l__tag_title_tmpa_tl {\clist_item:on{#1}{1}}
             \regex_extract_once:NVN
                \l__tag_title_optlang_regex
                \l__tag_title_tmpa_tl
                \l__tag_title_tmpa_seq
             \seq_if_empty:NTF\l__tag_title_tmpa_seq
              {
                \__tag_title_pdfstring:nnN {#1}{utf16/hex}\l__tag_title_tmpa_str
              }
              {
                \__tag_title_pdfstring:enN
                   {\seq_item:Nn \l__tag_title_tmpa_seq{3}}{utf16/hex}\l__tag_title_tmpa_str
              }
             \str_if_eq:VnF\l__tag_title_tmpa_str{<FEFF>}
               {
                 \pdfmanagement_add:nne {Info}{Title}{\l__tag_title_tmpa_str}
               }
           }
          \AddToDocumentProperties[hyperref]{pdftitle}{#1}
       }
   ,pdfsubtitle .code:n = { \AddToDocumentProperties[hyperref]{pdfsubtitle}{#1} }
   }
\tl_new:N \g__tag_title_author_tl
\RenewDocumentCommand\author{O{}m}
 {
    \gdef\@author{#2}
    \tl_gset_eq:NN\g__tag_title_author_tl\@author
    \keys_set:nn {hyp}{#1}
 }

\keys_define:nn { hyp }
   {
     pdfauthor  .code:n =
       {
         \tl_if_blank:nTF {#1}
           {
             \pdfmanagement_remove:nn {Info}{Author}
           }
           {
             \tl_set:Ne\l__tag_title_tmpa_tl {\clist_item:on{#1}{1}}
             \regex_extract_once:NVN
                \l__tag_title_optlang_regex
                \l__tag_title_tmpa_tl
                \l__tag_title_tmpa_seq
             \seq_if_empty:NTF\l__tag_title_tmpa_seq
              {
                \__tag_title_pdfstring:nnN {#1}{utf16/hex}\l__tag_title_tmpa_str
              }
              {
                \__tag_title_pdfstring:enN
                   {\seq_item:Nn \l__tag_title_tmpa_seq{3}}{utf16/hex}\l__tag_title_tmpa_str
              }
             \str_if_eq:VnF\l__tag_title_tmpa_str{<FEFF>}
               {
                 \pdfmanagement_add:nne {Info}{Author}{\l__tag_title_tmpa_str}
               }
           }
          \AddToDocumentProperties[hyperref]{pdfauthor}{#1}
       }
   }
\AddToHook{cmd/maketitle/before}
  {
   \tl_gset_eq:NN \g__tag_title_author_tl\@author
   \tl_gset_eq:NN \g__tag_title_title_tl\@title
  }
\AddToHook{shipout/lastpage}
 {
   \tl_if_empty:eT{\GetDocumentProperties{hyperref/pdftitle}}
      {
        \group_begin:
        \cs_set_eq:NN\thanks \use_none:n
        \str_set:Ne \l__tag_title_tmpa_str {\text_purify:n { \g__tag_title_title_tl } }
        \keys_set:ne{hyp}{pdftitle={\exp_not:V\l__tag_title_tmpa_str}}
        \group_end:
      }
   \tl_if_empty:eT{\GetDocumentProperties{hyperref/pdfauthor}}
      {
        \group_begin:
        \cs_set_eq:NN\thanks \use_none:n
        \cs_set:Npn \and {,}
        \str_set:Ne \l__tag_title_tmpa_str {\text_purify:n { \g__tag_title_author_tl } }
        \keys_set:ne{hyp}{pdfauthor={\exp_not:V\l__tag_title_tmpa_str}}
        \group_end:
      }
   \tl_if_empty:eF{\GetDocumentProperties{document/pdfstandard-UA}}
     {
       \pdfmanagement_add:nnn {Catalog / ViewerPreferences } { DisplayDocTitle } { true }
     }
 }
\DeclareHookRule{shipout/lastpage}{latex-lab-testphase-title}{before}{pdfmanagement-testphase}

\endinput
%%
%% End of file `latex-lab-testphase-title.sty'.
