%%
%% This is file `wu-kernel.code.tex',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% westlakethesis.dtx  (with options: `kernel')
%% -----------------------------------------------------------------------
%%   Copyright (C) 2026 by Mingyu Xia <myhsia@outlook.com>               *
%% -----------------------------------------------------------------------
%%   This work may be distributed and/or modified under the conditions   *
%%   of the LaTeX Project Public License (LPPL), 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 work has the LPPL maintenance status `maintained'.             *
%%                                                                       *
%%   The Current Maintainer of this work is Mingyu Xia.                  *
%% -----------------------------------------------------------------------
\GetIdInfo $Id: westlakethesis.dtx v0.0.2 2026-06-18 myhsia<myhsia@outlook.com>$
  {Inner functions for different modes (WESTLAKE)}
\ProvidesExplFile {wu-kernel.code.tex}
  {\ExplFileDate} {\ExplFileVersion} {\ExplFileDescription}
\cs_new:Npn \__wu_parse_slash_ab:c #1
  {
    \exp_args:Nc \tl_if_blank:VF {#1}
      {
        \tl_clear_new:c { #1_a }
        \tl_clear_new:c { #1_b }
        \seq_clear:N \l__wu_set_tmpa_seq
        \seq_set_split:Nne \l__wu_set_tmpa_seq { / } { \use:c {#1} }
        \seq_get_left:Nc  \l__wu_set_tmpa_seq { #1_a }
        \seq_get_right:Nc \l__wu_set_tmpa_seq { #1_b }
      }
  }
\cs_generate_variant:Nn \seq_get_left:NN  { Nc }
\cs_generate_variant:Nn \seq_get_right:NN { Nc }
\seq_clear_new:N \l__wu_set_tmpa_seq
\cs_new_protected:Npn \__wu_spread_box:nn #1#2
  {
    \mode_leave_vertical:
    \hbox_to_wd:nn {#1}
      { \exp_args:Nee \tl_map_inline:nn {#2} { ##1 \hfil } \unskip }
  }
\cs_new_protected:Npn \__wu_center_box:nnn #1#2#3
  {
    \mode_leave_vertical:
    \dim_set:Nn \l_tmpa_dim {#1}
    \box_gset_eq_drop:NN 1 \voidb@x
    \group_begin:
    \vbox_set:Nn 0
      {
        \dim_set:Nn  \parindent   { 0pt            }
        \skip_set:Nn \leftskip    { 0pt plus 1fil  }
        \skip_set:Nn \rightskip   { 0pt plus -1fil }
        \skip_set:Nn \parfillskip { 0pt plus 2fil  }
        #3 \par
        \loop
        \box_set_to_last:N 2
        \reverse_if:N \if_box_empty:N 2
        \vbox_gset_top:Nn 1
          {
            \hbox_to_wd:nn {#1} { \strut \hbox_unpack_drop:N 2 }
            \skip_vertical:n {#2}
            \__box_rule_horizontal:nn { .5pt } { \c_zero_dim }
            \skip_vertical:n { 9.6pt } \vbox_unpack_drop:N 1
          }
        \unskip \unpenalty
        \repeat
      }
    \group_end:
    \tex_box:D 1
  }
\cs_new:Npn \__wu_signature_inline:n #1
  {
    \box_move_down:nn { \fp_eval:n { .9 * \f@size } \p@ }
      {
        \hbox:n
          {
            \includegraphics
              [height = \fp_eval:n { 2.4 * \f@size } \p@] {#1}
          }
      }
  }
\cs_new_nopar:Npn \__wu_fontsize:nn #1#2
  {
    \__wu_kernel_bilingual:nnn {#1}
      {
        \fontsize
          { \dim_to_decimal:n {  #2 bp          } }
          { \dim_to_decimal:n { (#2 bp) * 6 / 5 } } \selectfont
      } { \ctex_zihao:n {#2} }
  }
\cs_new_protected_nopar:Npn \__wu_kernel_month:n #1
  {
    \__wu_kernel_bilingual:nnn {#1}
      {
        \if_case:w \int_value:w \c_sys_month_int
          \or: January \or: February \or: March
          \or: April   \or: May      \or: June
          \or: July    \or: August   \or: September
          \or: October \or: November \or: December
        \fi:
      }
      { \zhnum_digits:Nn \c_false_bool { \int_value:w \c_sys_month_int } 月 }
  }
\cs_new_protected_nopar:Npn \__wu_kernel_year:n #1
  {
    \__wu_kernel_bilingual:nnn {#1}
      { \int_value:w \c_sys_year_int }
      { \zhnum_digits:Nn \c_false_bool { \int_value:w \c_sys_year_int  } 年 }
  }
\cs_new_nopar:Npn \__wu_kernel_bilingual:nnn #1#2#3
  { \str_case:on {#1} { { en } {#2} { cn } {#3} } }
\hook_gput_code:nnn { begindocument / before } { . }
  {
    \bool_if_exist:NT \l__wu_load_bib_bool
      {
        \bool_if:NTF \l__wu_load_bib_bool
          {
            \DeclareDocumentCommand \printbibliography {}
              {
                \addcontentsline { toc } { chapter } { \bibname }
                \group_begin:
                  \dim_set:Nn \bibsep {1pt}
                  \linespread { 1.85 } \__wu_fontsize:nn { cn } { 5 }
                  \bibliography { \l__wu_set_bib_str }
                \group_end:
              }
          } { \newcommand \printbibliography { \chapter* { \bibname } } }
      }
  }
\file_input_stop:
%% -----------------------------------------------------------------------
%%   This work consists of the files westlakethesis.dtx,                 *
%%                                   westlakethesis.ins,                 *
%%                 the derived files westlakethesis.cls,                 *
%%                                   wu-depend.code.tex,                 *
%%                                   wu-kernel.code.tex,                 *
%%                                   wu-params.code.tex,                 *
%%                                   wu-thesis.code.tex,                 *
%%                                   wu-beamer.code.tex,                 *
%%                                   wu-poster.code.tex,                 *
%%                                   wu-usrdoc.code.tex,                 *
%%                                   westlake-logo.pdf,                  *
%%                                   westlake-badge-en.pdf,              *
%%                                   westlake-badge-cn.pdf,              *
%%                                   westlake-paint-a.png,               *
%%                                   westlake-paint-b.png,               *
%%           the documentation files westlakethesis.pdf,                 *
%%                               and README.md.                          *
%% -----------------------------------------------------------------------
%%
%% End of file `wu-kernel.code.tex'.
