%%
%% This is file `unicode-math-luatex.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% unicode-math.dtx  (with options: `package,LU')
%% unicode-math-compat.dtx  (with options: `compat,LU')
%% Copyright 2006-2015   Will Robertson <will.robertson@latex-project.org>
%% Copyright 2010-2013 Philipp Stephani <st_philipp@yahoo.de>
%% Copyright 2012-2015     Khaled Hosny <khaledhosny@eglug.org>
%% 
%% This package is free software and may be redistributed and/or modified under
%% the conditions of the LaTeX Project Public License, version 1.3c or higher
%% (your choice): <http://www.latex-project.org/lppl/>.
%% 
%% This work is "maintained" by Will Robertson.
\ExplSyntaxOn
\RequirePackage{luaotfload}   [2014/05/18]
\RequirePackage{lualatex-math}[2011/08/07]
\tl_map_inline:nn
 {
  \new@mathgroup\cdp@list\cdp@elt\DeclareMathSizes
  \@DeclareMathSizes\newmathalphabet\newmathalphabet__um\newmathalphabet__um@
  \DeclareMathVersion\define@mathalphabet\define@mathgroup\addtoversion
  \version@list\version@elt\alpha@list\alpha@elt
  \restore@mathversion\init@restore@version\dorestore@version\process@table
  \new@mathversion\DeclareSymbolFont\group@list\group@elt
  \new@symbolfont\SetSymbolFont\SetSymbolFont@\get@cdp
  \DeclareMathAlphabet\new@mathalphabet\SetMathAlphabet\SetMathAlphabet@
  \DeclareMathAccent\set@mathaccent\DeclareMathSymbol\set@mathchar
  \set@mathsymbol\DeclareMathDelimiter\@xxDeclareMathDelimiter
  \@DeclareMathDelimiter\@xDeclareMathDelimiter\set@mathdelimiter
  \set__ummathdelimiter\DeclareMathRadical\mathchar@type
  \DeclareSymbolFontAlphabet\DeclareSymbolFontAlphabet@
 }
 {
  \tl_remove_once:Nn \@preamblecmds {\do#1}
 }
\cs_set:Nn \__um_set_mathsymbol:nNNn
 {
  \bool_if:nT
   {
    \int_compare_p:nNn {#4} > {127} &&
    \int_compare_p:nNn { \char_value_catcode:n {#4} } = {11}
   }
   { \char_set_catcode_other:n {#4} }

  \tl_case:Nn #3
   {
    \mathord   { \__um_set_mathcode:nnn {#4} {#3} {#1} }
    \mathalpha { \__um_set_mathcode:nnn {#4} {#3} {#1} }
    \mathbin   { \__um_set_mathcode:nnn {#4} {#3} {#1} }
    \mathrel   { \__um_set_mathcode:nnn {#4} {#3} {#1} }
    \mathpunct { \__um_set_mathcode:nnn {#4} {#3} {#1} }
    \mathop    { \__um_set_big_operator:nnn {#1} {#2} {#4} }
    \mathopen  { \__um_set_math_open:nnn    {#1} {#2} {#4} }
    \mathclose { \__um_set_math_close:nnn   {#1} {#2} {#4} }
    \mathfence { \__um_set_math_fence:nnnn  {#1} {#2} {#3} {#4} }
    \mathaccent
     { \__um_set_math_accent:Nnnn #2 {fixed} {#1} {#4} }
    \mathbotaccent
     { \__um_set_math_accent:Nnnn #2 {bottom~ fixed} {#1} {#4} }
    \mathaccentwide
     { \__um_set_math_accent:Nnnn #2 {} {#1} {#4} }
    \mathbotaccentwide
     { \__um_set_math_accent:Nnnn #2 {bottom} {#1} {#4} }
    \mathover
     { \__um_set_math_overunder:Nnnn #2 {} {#1} {#4} }
    \mathunder
     { \__um_set_math_overunder:Nnnn #2 {bottom} {#1} {#4} }
   }
 }
\edef\mathfence{\string\mathfence}
\edef\mathover{\string\mathover}
\edef\mathunder{\string\mathunder}
\edef\mathbotaccent{\string\mathbotaccent}
\edef\mathaccentwide{\string\mathaccentwide}
\edef\mathbotaccentwide{\string\mathbotaccentwide}
\cs_new:Nn \__um_set_big_operator:nnn
 {
  \__um_char_gmake_mathactive:n {#3}
  \cs_set_protected_nopar:Npx \__um_tmpa: { \exp_not:c { \cs_to_str:N #2 _sym } }
  \char_gset_active_eq:nN {#3} \__um_tmpa:

  \__um_set_mathchar:cNnn {\cs_to_str:N #2 op} \mathop {#1} {#3}

  \cs_gset:cpx { \cs_to_str:N #2 _sym }
   {
    \exp_not:c { \cs_to_str:N #2 op   }
    \exp_not:n { \tl_if_in:NnT \l__um_nolimits_tl {#2} \nolimits }
   }
 }
\cs_new:Nn \__um_set_math_open:nnn
 {
  \tl_if_in:NnTF \l__um_radicals_tl {#2}
   {
     \cs_gset_protected_nopar:cpx {\cs_to_str:N #2 sign}
       { \__um_radical:nn {#1} {#3} }
     \tl_set:cn {l__um_radical_\cs_to_str:N #2_tl} {\use:c{sym #1}~ #3}
   }
   {
     \__um_set_delcode:nnn {#1} {#3} {#3}
     \__um_set_mathcode:nnn {#3} \mathopen {#1}
     \cs_gset_protected_nopar:Npx #2
       { \__um_delimiter:Nnn \mathopen {#1} {#3} }
   }
 }
\cs_new:Nn \__um_set_math_close:nnn
 {
  \__um_set_delcode:nnn {#1} {#3} {#3}
  \__um_set_mathcode:nnn {#3} \mathclose {#1}
  \cs_gset_protected_nopar:Npx #2
    { \__um_delimiter:Nnn \mathclose {#1} {#3} }
 }
\cs_new:Nn \__um_set_math_fence:nnnn
 {
  \__um_set_mathcode:nnn {#4} {#3} {#1}
  \__um_set_delcode:nnn  {#1} {#4} {#4}
  \cs_gset_protected_nopar:cpx {l \cs_to_str:N #2}
    { \__um_delimiter:Nnn \mathopen  {#1} {#4} }
  \cs_gset_protected_nopar:cpx {r \cs_to_str:N #2}
    { \__um_delimiter:Nnn \mathclose {#1} {#4} }
 }
\cs_new:Nn \__um_set_math_accent:Nnnn
 {
  \cs_gset_protected_nopar:Npx #1
   { \__um_accent:nnn {#2} {#3} {#4} }
 }
\cs_new:Nn \__um_set_math_overunder:Nnnn
 {
  \cs_gset_protected_nopar:Npx #1 ##1
   {
    \mathop
     { \__um_accent:nnn {#2} {#3} {#4} {##1} }
    \limits
   }
 }
\keys_define:nn {__um_mathface}
 {
  version .code:n =
   { \tl_set:Nn \l__um_mversion_tl {#1} }
 }

\DeclareDocumentCommand \setmathfontface { m O{} m O{} }
 {
  \tl_clear:N \l__um_mversion_tl

  \keys_set_known:nnN {__um_mathface} {#2,#4} \l__um_keyval_clist
  \exp_args:Nnx \fontspec_set_family:Nxn \l__um_tmpa_tl
   { ItalicFont={}, BoldFont={}, \exp_not:V \l__um_keyval_clist } {#3}

  \tl_if_empty:NT \l__um_mversion_tl
   {
    \tl_set:Nn \l__um_mversion_tl {normal}
    \DeclareMathAlphabet #1 {\g_fontspec_encoding_tl} {\l__um_tmpa_tl} {\mddefault} {\updefault}
   }
  \SetMathAlphabet #1 {\l__um_mversion_tl} {\g_fontspec_encoding_tl} {\l__um_tmpa_tl} {\mddefault} {\updefault}

  % integrate with fontspec's \setmathrm etc:
  \tl_case:Nn #1
   {
    \mathrm { \cs_set_eq:NN \g__fontspec_mathrm_tl \l__um_tmpa_tl }
    \mathsf { \cs_set_eq:NN \g__fontspec_mathsf_tl \l__um_tmpa_tl }
    \mathtt { \cs_set_eq:NN \g__fontspec_mathtt_tl \l__um_tmpa_tl }
   }
 }

\@onlypreamble \setmathfontface
\DeclareDocumentCommand \setoperatorfont {m}
 { \tl_set:Nn \g__um_operator_mathfont_tl {#1} }
\setoperatorfont{\mathrm}
\cs_generate_variant:Nn \tl_if_eq:nnT {o}
\cs_set:Nn \__fontspec_setmainfont:nn
 {
  \fontspec_set_family:Nnn \rmdefault {#1}{#2}
  \tl_if_eq:onT {\g__fontspec_mathrm_tl} {\rmdefault}
   {
  \fontspec_set_family:Nnn \g__fontspec_mathrm_tl {Renderer=Basic,#1} {#2}
    \SetMathAlphabet\mathrm{normal}\g_fontspec_encoding_tl\g__fontspec_mathrm_tl\mddefault\updefault
    \SetMathAlphabet\mathit{normal}\g_fontspec_encoding_tl\g__fontspec_mathrm_tl\mddefault\itdefault
    \SetMathAlphabet\mathbf{normal}\g_fontspec_encoding_tl\g__fontspec_mathrm_tl\bfdefault\updefault
   }
  \normalfont
  \ignorespaces
 }

\cs_set:Nn \__fontspec_setsansfont:nn
 {
  \fontspec_set_family:Nnn \sfdefault {#1}{#2}
  \tl_if_eq:onT {\g__fontspec_mathsf_tl} {\sfdefault}
   {
  \fontspec_set_family:Nnn \g__fontspec_mathsf_tl {Renderer=Basic,#1} {#2}
    \SetMathAlphabet\mathsf{normal}\g_fontspec_encoding_tl\g__fontspec_mathsf_tl\mddefault\updefault
    \SetMathAlphabet\mathsf{bold}  \g_fontspec_encoding_tl\g__fontspec_mathsf_tl\bfdefault\updefault
   }
  \normalfont
  \ignorespaces
 }

\cs_set:Nn \__fontspec_setmonofont:nn
 {
  \fontspec_set_family:Nnn \ttdefault {#1}{#2}
  \tl_if_eq:onT {\g__fontspec_mathtt_tl} {\ttdefault}
   {
  \fontspec_set_family:Nnn \g__fontspec_mathtt_tl {Renderer=Basic,#1} {#2}
    \SetMathAlphabet\mathtt{normal}\g_fontspec_encoding_tl\g__fontspec_mathtt_tl\mddefault\updefault
    \SetMathAlphabet\mathtt{bold}  \g_fontspec_encoding_tl\g__fontspec_mathtt_tl\bfdefault\updefault
   }
  \normalfont
  \ignorespaces
 }
\cs_set:Nn \__fontspec_setmathrm:nn
 {
  \fontspec_set_family:Nnn \g__fontspec_mathrm_tl {Renderer=Basic,#1} {#2}
  \SetMathAlphabet\mathrm{normal}\g_fontspec_encoding_tl\g__fontspec_mathrm_tl\mddefault\updefault
  \SetMathAlphabet\mathit{normal}\g_fontspec_encoding_tl\g__fontspec_mathrm_tl\mddefault\itdefault
  \SetMathAlphabet\mathbf{normal}\g_fontspec_encoding_tl\g__fontspec_mathrm_tl\bfdefault\updefault
 }
\cs_set:Nn \__fontspec_setboldmathrm:nn
 {
  \fontspec_set_family:Nnn \g__fontspec_bfmathrm_tl {Renderer=Basic,#1} {#2}
  \SetMathAlphabet\mathrm{bold}\g_fontspec_encoding_tl\g__fontspec_bfmathrm_tl\mddefault\updefault
  \SetMathAlphabet\mathbf{bold}\g_fontspec_encoding_tl\g__fontspec_bfmathrm_tl\bfdefault\updefault
  \SetMathAlphabet\mathit{bold}\g_fontspec_encoding_tl\g__fontspec_bfmathrm_tl\mddefault\itdefault
 }
\cs_set:Nn \__fontspec_setmathsf:nn
 {
  \fontspec_set_family:Nnn \g__fontspec_mathsf_tl {Renderer=Basic,#1} {#2}
  \SetMathAlphabet\mathsf{normal}\g_fontspec_encoding_tl\g__fontspec_mathsf_tl\mddefault\updefault
  \SetMathAlphabet\mathsf{bold}  \g_fontspec_encoding_tl\g__fontspec_mathsf_tl\bfdefault\updefault
 }
\cs_set:Nn \__fontspec_setmathtt:nn
 {
  \fontspec_set_family:Nnn \g__fontspec_mathtt_tl {Renderer=Basic,#1} {#2}
  \SetMathAlphabet\mathtt{normal}\g_fontspec_encoding_tl\g__fontspec_mathtt_tl\mddefault\updefault
  \SetMathAlphabet\mathtt{bold}  \g_fontspec_encoding_tl\g__fontspec_mathtt_tl\bfdefault\updefault
 }
\DeclareDocumentCommand \setmathfont { O{} m O{} }
 {
  \tl_set:Nn \l__um_fontname_tl {#2}
  \__um_init:
  \cs_if_exist:cF { S@ \f@size } { \calculate@math@sizes }
  \csname S@\f@size\endcsname
  \keys_set_known:nnN {unicode-math} {#1,#3} \l__um_unknown_keys_clist
  \bool_if:NT \l__um_init_bool { \__um_log:n {default-math-font} }

  \__um_fontspec_select_font:
  \bool_if:nT { \l__um_ot_math_bool && !\g__um_mainfont_already_set_bool }
   {
    \__um_declare_math_sizes:
    \__um_fontspec_select_font:
   }
  \cs_if_exist:cF { sym \__um_symfont_tl }
    {
      \DeclareSymbolFont{\__um_symfont_tl}
        {\encodingdefault}{\l__um_family_tl}{\mddefault}{\updefault}
    }
  \SetSymbolFont{\__um_symfont_tl}{\l__um_mversion_tl}
    {\encodingdefault}{\l__um_family_tl}{\mddefault}{\updefault}
  \tl_set:Nn \l__um_tmpa_tl {normal}
  \tl_if_eq:NNT \l__um_mversion_tl \l__um_tmpa_tl
    {
     \SetSymbolFont{\__um_symfont_tl}{bold}
      {\encodingdefault}{\l__um_family_tl}{\bfdefault}{\updefault}
    }
  \bool_if:nT { \l__um_ot_math_bool && !\g__um_mainfont_already_set_bool }
   {
    \bool_set_true:N \g__um_mainfont_already_set_bool
    \__um_setup_legacy_fam_two:
    \__um_setup_legacy_fam_three:
   }
  \__um_input_math_symbol_table:
  \__um_remap_symbols:
  \__um_setup_mathactives:
  \__um_setup_delcodes:
  \__um_setup_alphabets:
  \__um_setup_negations:
  \ignorespaces
 }
\cs_set_eq:NN \resetmathfont \setmathfont
\cs_new:Nn \__um_init:
 {
  \bool_set_true:N  \l__um_ot_math_bool
  \cs_set_eq:NN \glb@currsize \scan_stop:
  \bool_set_true:N \l__um_init_bool
  \seq_clear:N \l__um_char_range_seq
  \clist_clear:N \l__um_char_nrange_clist
  \seq_clear:N \l__um_mathalph_seq
  \seq_clear:N \l__um_missing_alph_seq
  \tl_set:Nn \l__um_mversion_tl {normal}
  \tl_set:Nn \__um_symfont_tl {operators}
  \cs_set_eq:NN \__um_sym:nnn \__um_process_symbol_noparse:nnn
  \cs_set_eq:NN \__um_set_mathalphabet_char:nnn \__um_mathmap_noparse:nnn
  \cs_set_eq:NN \__um_remap_symbol:nnn \__um_remap_symbol_noparse:nnn
  \cs_set_eq:NN \__um_maybe_init_alphabet:n \__um_init_alphabet:n
  \cs_set_eq:NN \__um_map_char_single:nn \__um_map_char_noparse:nn
  \cs_set_eq:NN \__um_assign_delcode:nn \__um_assign_delcode_noparse:nn
  \cs_set_eq:NN \__um_make_mathactive:nNN \__um_make_mathactive_noparse:nNN
  \tl_set:Nn \l__um_script_features_tl  {Style=MathScript}
  \tl_set:Nn \l__um_sscript_features_tl {Style=MathScriptScript}
  \tl_set_eq:NN \l__um_script_font_tl   \l__um_fontname_tl
  \tl_set_eq:NN \l__um_sscript_font_tl  \l__um_fontname_tl
 }
\cs_new:Nn \__um_declare_math_sizes:
  {
    \dim_compare:nF { \fontdimen 10 \l__um_font == 0pt }
      {
        \DeclareMathSizes { \f@size } { \f@size }
          { \__um_fontdimen_to_scale:nn {10} {\l__um_font} }
          { \__um_fontdimen_to_scale:nn {11} {\l__um_font} }
      }
  }
\cs_new:Nn \__um_setup_legacy_fam_two:
  {
    \fontspec_set_family:Nxn \l__um_family_tl
      {
      \l__um_font_keyval_tl,
      Scale=1.00001,
      FontAdjustment =
       {
        \fontdimen8\font= \__um_get_fontparam:nn {43} {FractionNumeratorDisplayStyleShiftUp}\relax
        \fontdimen9\font= \__um_get_fontparam:nn {42} {FractionNumeratorShiftUp}\relax
        \fontdimen10\font=\__um_get_fontparam:nn {32} {StackTopShiftUp}\relax
        \fontdimen11\font=\__um_get_fontparam:nn {45} {FractionDenominatorDisplayStyleShiftDown}\relax
        \fontdimen12\font=\__um_get_fontparam:nn {44} {FractionDenominatorShiftDown}\relax
        \fontdimen13\font=\__um_get_fontparam:nn {21} {SuperscriptShiftUp}\relax
        \fontdimen14\font=\__um_get_fontparam:nn {21} {SuperscriptShiftUp}\relax
        \fontdimen15\font=\__um_get_fontparam:nn {22} {SuperscriptShiftUpCramped}\relax
        \fontdimen16\font=\__um_get_fontparam:nn {18} {SubscriptShiftDown}\relax
        \fontdimen17\font=\__um_get_fontparam:nn {18} {SubscriptShiftDownWithSuperscript}\relax
        \fontdimen18\font=\__um_get_fontparam:nn {24} {SuperscriptBaselineDropMax}\relax
        \fontdimen19\font=\__um_get_fontparam:nn {20} {SubscriptBaselineDropMin}\relax
        \fontdimen20\font=0pt\relax % delim1 = FractionDelimiterDisplaySize
        \fontdimen21\font=0pt\relax % delim2 = FractionDelimiterSize
        \fontdimen22\font=\__um_get_fontparam:nn {15} {AxisHeight}\relax
       }
      } {\l__um_fontname_tl}
    \SetSymbolFont{symbols}{\l__um_mversion_tl}
      {\encodingdefault}{\l__um_family_tl}{\mddefault}{\updefault}

    \tl_set:Nn \l__um_tmpa_tl {normal}
    \tl_if_eq:NNT \l__um_mversion_tl \l__um_tmpa_tl
      {
      \SetSymbolFont{symbols}{bold}
        {\encodingdefault}{\l__um_family_tl}{\bfdefault}{\updefault}
      }
  }
\cs_new:Nn \__um_setup_legacy_fam_three:
  {
    \fontspec_set_family:Nxn \l__um_family_tl
      {
      \l__um_font_keyval_tl,
      Scale=0.99999,
      FontAdjustment={
        \fontdimen8\font= \__um_get_fontparam:nn {48} {FractionRuleThickness}\relax
        \fontdimen9\font= \__um_get_fontparam:nn {28} {UpperLimitGapMin}\relax
        \fontdimen10\font=\__um_get_fontparam:nn {30} {LowerLimitGapMin}\relax
        \fontdimen11\font=\__um_get_fontparam:nn {29} {UpperLimitBaselineRiseMin}\relax
        \fontdimen12\font=\__um_get_fontparam:nn {31} {LowerLimitBaselineDropMin}\relax
        \fontdimen13\font=0pt\relax
      }
    } {\l__um_fontname_tl}
    \SetSymbolFont{largesymbols}{\l__um_mversion_tl}
      {\encodingdefault}{\l__um_family_tl}{\mddefault}{\updefault}

    \tl_set:Nn \l__um_tmpa_tl {normal}
    \tl_if_eq:NNT \l__um_mversion_tl \l__um_tmpa_tl
      {
      \SetSymbolFont{largesymbols}{bold}
        {\encodingdefault}{\l__um_family_tl}{\bfdefault}{\updefault}
      }
  }
\cs_new:Nn \__um_get_fontparam:nn
  { \directlua{fontspec.mathfontdimen("l__um_font","#2")} }
\cs_new:Nn \__um_fontspec_select_font:
 {
  \tl_set:Nx \l__um_font_keyval_tl {
     Renderer = Basic,
    BoldItalicFont = {}, ItalicFont = {},
    Script = Math,
    SizeFeatures =
     {
      {
       Size = \tf@size-
      } ,
      {
       Size = \sf@size-\tf@size ,
       Font = \l__um_script_font_tl ,
       \l__um_script_features_tl
      } ,
      {
       Size = -\sf@size ,
       Font = \l__um_sscript_font_tl ,
       \l__um_sscript_features_tl
      }
     } ,
    \l__um_unknown_keys_clist
  }
  \fontspec_set_fontface:NNxn \l__um_font \l__um_family_tl
    {\l__um_font_keyval_tl} {\l__um_fontname_tl}
  \group_begin:
    \fontfamily{\l__um_family_tl}\selectfont
    \fontspec_if_script:nF {math} {\bool_gset_false:N \l__um_ot_math_bool}
  \group_end:
 }
\cs_set:Nn \__um_process_symbol_noparse:nnn
 {
  \__um_set_mathsymbol:nNNn {\__um_symfont_tl} #2 #3 {#1}
 }
\cs_set:Nn \__um_process_symbol_parse:nnn
 {
  \__um_if_char_spec:nNNT {#1} {#2} {#3}
   {
    \__um_process_symbol_noparse:nnn {#1} {#2} {#3}
   }
 }
\cs_new:Npn \__um_remap_symbols:
 {
  \__um_remap_symbol:nnn{`\-}{\mathbin}{"02212}% hyphen to minus
  \__um_remap_symbol:nnn{`\*}{\mathbin}{"02217}% text asterisk to "centred asterisk"
  \bool_if:NF \g__um_literal_colon_bool
   {
    \__um_remap_symbol:nnn{`\:}{\mathrel}{"02236}% colon to ratio (i.e., punct to rel)
   }
 }
\cs_new:Nn \__um_remap_symbol_parse:nnn
 {
  \__um_if_char_spec:nNNT {#3} {\@nil} {#2}
   { \__um_remap_symbol_noparse:nnn {#1} {#2} {#3} }
 }
\cs_new:Nn \__um_remap_symbol_noparse:nnn
 {
  \clist_map_inline:nn {#1}
   { \__um_set_mathcode:nnnn {##1} {#2} {\__um_symfont_tl} {#3} }
 }
\cs_new:Npn \__um_setup_mathactives:
 {
  \__um_make_mathactive:nNN {"2032} \__um_prime_single_mchar \mathord
  \__um_make_mathactive:nNN {"2033} \__um_prime_double_mchar \mathord
  \__um_make_mathactive:nNN {"2034} \__um_prime_triple_mchar \mathord
  \__um_make_mathactive:nNN {"2057} \__um_prime_quad_mchar   \mathord
  \__um_make_mathactive:nNN {"2035} \__um_backprime_single_mchar \mathord
  \__um_make_mathactive:nNN {"2036} \__um_backprime_double_mchar \mathord
  \__um_make_mathactive:nNN {"2037} \__um_backprime_triple_mchar \mathord
  \__um_make_mathactive:nNN {`\'} \mathstraightquote \mathord
  \__um_make_mathactive:nNN {`\`} \mathbacktick      \mathord
 }
\cs_new:Nn \__um_make_mathactive_parse:nNN
  {
    \__um_if_char_spec:nNNT {#1} #2 #3
      { \__um_make_mathactive_noparse:nNN {#1} #2 #3 }
  }
\cs_new:Nn \__um_make_mathactive_noparse:nNN
  {
    \__um_set_mathchar:NNnn #2 #3 {\__um_symfont_tl} {#1}
    \__um_char_gmake_mathactive:n {#1}
  }
\cs_new:Nn \__um_assign_delcode_noparse:nn
 {
  \__um_set_delcode:nnn \__um_symfont_tl {#1} {#2}
 }
\cs_new:Nn \__um_assign_delcode_parse:nn
 {
  \__um_if_char_spec:nNNT {#2} {\@nil} {\@nil}
   {
    \__um_assign_delcode_noparse:nn {#1} {#2}
   }
 }
\cs_new:Nn \__um_assign_delcode:n { \__um_assign_delcode:nn {#1} {#1} }
\cs_new:Npn \__um_setup_delcodes:
 {
  % ensure \left. and \right. work:
  \__um_set_delcode:nnn \__um_symfont_tl {`\.} {\c_zero}
  % this is forcefully done to fix a bug -- indicates a larger problem!

  \__um_assign_delcode:nn {`\/}   {\g__um_slash_delimiter_usv}
  \__um_assign_delcode:nn {"2044} {\g__um_slash_delimiter_usv} % fracslash
  \__um_assign_delcode:nn {"2215} {\g__um_slash_delimiter_usv} % divslash
  \__um_assign_delcode:n {"005C} % backslash
  \__um_assign_delcode:nn {`\<} {"27E8} % angle brackets with ascii notation
  \__um_assign_delcode:nn {`\>} {"27E9} % angle brackets with ascii notation
  \__um_assign_delcode:n {"2191} % up arrow
  \__um_assign_delcode:n {"2193} % down arrow
  \__um_assign_delcode:n {"2195} % updown arrow
  \__um_assign_delcode:n {"219F} % up arrow twohead
  \__um_assign_delcode:n {"21A1} % down arrow twohead
  \__um_assign_delcode:n {"21A5} % up arrow from bar
  \__um_assign_delcode:n {"21A7} % down arrow from bar
  \__um_assign_delcode:n {"21A8} % updown arrow from bar
  \__um_assign_delcode:n {"21BE} % up harpoon right
  \__um_assign_delcode:n {"21BF} % up harpoon left
  \__um_assign_delcode:n {"21C2} % down harpoon right
  \__um_assign_delcode:n {"21C3} % down harpoon left
  \__um_assign_delcode:n {"21C5} % arrows up down
  \__um_assign_delcode:n {"21F5} % arrows down up
  \__um_assign_delcode:n {"21C8} % arrows up up
  \__um_assign_delcode:n {"21CA} % arrows down down
  \__um_assign_delcode:n {"21D1} % double up arrow
  \__um_assign_delcode:n {"21D3} % double down arrow
  \__um_assign_delcode:n {"21D5} % double updown arrow
  \__um_assign_delcode:n {"21DE} % up arrow double stroke
  \__um_assign_delcode:n {"21DF} % down arrow double stroke
  \__um_assign_delcode:n {"21E1} % up arrow dashed
  \__um_assign_delcode:n {"21E3} % down arrow dashed
  \__um_assign_delcode:n {"21E7} % up white arrow
  \__um_assign_delcode:n {"21E9} % down white arrow
  \__um_assign_delcode:n {"21EA} % up white arrow from bar
  \__um_assign_delcode:n {"21F3} % updown white arrow
 }
\tl_new:N \l__um_nolimits_tl
\tl_set:Nn \l__um_nolimits_tl
 {
  \int\iint\iiint\iiiint\oint\oiint\oiiint
  \intclockwise\varointclockwise\ointctrclockwise\sumint
  \intbar\intBar\fint\cirfnint\awint\rppolint
  \scpolint\npolint\pointint\sqint\intlarhk\intx
  \intcap\intcup\upint\lowint
 }
\DeclareDocumentCommand \addnolimits {m}
 {
  \tl_put_right:Nn \l__um_nolimits_tl {#1}
 }
\DeclareDocumentCommand \removenolimits {m}
 {
  \tl_remove_all:Nn \l__um_nolimits_tl {#1}
 }
\tl_new:N \l__um_radicals_tl
\tl_set:Nn \l__um_radicals_tl {\sqrt \longdivision}
\cs_new_protected_nopar:Nn \__um_new_cramped_style:N
  {
    \cs_if_exist:NF #1
      { \cs_new_eq:Nc #1 { luatex \cs_to_str:N #1 } }
  }
\__um_new_cramped_style:N \crampeddisplaystyle
\__um_new_cramped_style:N \crampedtextstyle
\__um_new_cramped_style:N \crampedscriptstyle
\__um_new_cramped_style:N \crampedscriptscriptstyle
\cs_new_protected_nopar:Nn \__um_font_param:nnnnn
{
  \tl_set:Nn \l__um_tmpa_tl { #1 }
  \tl_remove_all:Nn \l__um_tmpa_tl { _ }
  \__um_font_param_aux:ccc { __um_ #1 :N } { __um_set_ #1 :Nn }
    { Umath \l__um_tmpa_tl }
}
\cs_new_protected_nopar:Nn \__um_font_param:nnn
 {
  \__um_font_param:nnnnn { #1 } { #2 } { #2 } { #3 } { #3 }
 }
\cs_new_protected_nopar:Nn \__um_font_param:nn
 {
  \__um_font_param:nnnnn { #1 } { #2 } { #2 } { #2 } { #2 }
 }
\cs_new_protected_nopar:Nn \__um_font_param:n
  { \__um_font_param:nnnnn { #1 } { 0 } { 0 } { 0 } { 0 } }
\cs_new_protected_nopar:Nn \__um_font_param_aux:NNN
  {
    \cs_new_nopar:Npn #1 ##1
     {
      #3 ##1
     }
    \cs_new_protected_nopar:Npn #2 ##1 ##2
     {
      #3 ##1 \dim_eval:n { ##2 }
     }
  }
\cs_generate_variant:Nn \__um_font_param_aux:NNN { ccc }
\__um_font_param:nn { axis } { 15 }
\__um_font_param:nn { operator_size } { 13 }
\__um_font_param:n { fraction_del_size }
\__um_font_param:nnn { fraction_denom_down } { 45 } { 44 }
\__um_font_param:nnn { fraction_denom_vgap } { 50 } { 49 }
\__um_font_param:nnn { fraction_num_up } { 43 } { 42 }
\__um_font_param:nnn { fraction_num_vgap } { 47 } { 46 }
\__um_font_param:nn { fraction_rule } { 48 }
\__um_font_param:nn { limit_above_bgap } { 29 }
\__um_font_param:n { limit_above_kern }
\__um_font_param:nn { limit_above_vgap } { 28 }
\__um_font_param:nn { limit_below_bgap } { 31 }
\__um_font_param:n { limit_below_kern }
\__um_font_param:nn { limit_below_vgap } { 30 }
\__um_font_param:nn { over_delimiter_vgap } { 41 }
\__um_font_param:nn { over_delimiter_bgap } { 38 }
\__um_font_param:nn { under_delimiter_vgap } { 40 }
\__um_font_param:nn { under_delimiter_bgap } { 39 }
\__um_font_param:nn { overbar_kern } { 55 }
\__um_font_param:nn { overbar_rule } { 54 }
\__um_font_param:nn { overbar_vgap } { 53 }
\__um_font_param:n { quad }
\__um_font_param:nn { radical_kern } { 62 }
\__um_font_param:nn { radical_rule } { 61 }
\__um_font_param:nnn { radical_vgap } { 60 } { 59 }
\__um_font_param:nn { radical_degree_before } { 63 }
\__um_font_param:nn { radical_degree_after } { 64 }
\__um_font_param:nn { radical_degree_raise } { 65 }
\__um_font_param:nn { space_after_script } { 27 }
\__um_font_param:nnn { stack_denom_down } { 35 } { 34 }
\__um_font_param:nnn { stack_num_up } { 33 } { 32 }
\__um_font_param:nnn { stack_vgap } { 37 } { 36 }
\__um_font_param:nn { sub_shift_down } { 18 }
\__um_font_param:nn { sub_shift_drop } { 20 }
\__um_font_param:n { subsup_shift_down }
\__um_font_param:nn { sub_top_max } { 19 }
\__um_font_param:nn { subsup_vgap } { 25 }
\__um_font_param:nn { sup_bottom_min } { 23 }
\__um_font_param:nn { sup_shift_drop } { 24 }
\__um_font_param:nnnnn { sup_shift_up } { 21 } { 22 } { 21 } { 22 }
\__um_font_param:nn { supsub_bottom_max } { 26 }
\__um_font_param:nn { underbar_kern } { 58 }
\__um_font_param:nn { underbar_rule } { 57 }
\__um_font_param:nn { underbar_vgap } { 56 }
\__um_font_param:n { connector_overlap_min }
\keys_define:nn {unicode-math}
  {
    version .code:n =
      {
        \tl_set:Nn \l__um_mversion_tl {#1}
        \DeclareMathVersion {\l__um_mversion_tl}
      }
  }
\keys_define:nn {unicode-math}
 {
  script-features  .tl_set:N =  \l__um_script_features_tl ,
  sscript-features .tl_set:N = \l__um_sscript_features_tl ,
       script-font .tl_set:N =      \l__um_script_font_tl ,
      sscript-font .tl_set:N =     \l__um_sscript_font_tl ,
 }
\keys_define:nn {unicode-math}
 {
  range .code:n =
   {
    \bool_set_false:N \l__um_init_bool
    \int_incr:N \g__um_fam_int
    \tl_set:Nx \__um_symfont_tl {__um_fam\int_use:N\g__um_fam_int}
    \cs_set_eq:NN \__um_sym:nnn \__um_process_symbol_parse:nnn
    \cs_set_eq:NN \__um_set_mathalphabet_char:Nnn \__um_mathmap_parse:Nnn
    \cs_set_eq:NN \__um_remap_symbol:nnn \__um_remap_symbol_parse:nnn
    \cs_set_eq:NN \__um_maybe_init_alphabet:n \use_none:n
    \cs_set_eq:NN \__um_map_char_single:nn \__um_map_char_parse:nn
    \cs_set_eq:NN \__um_assign_delcode:nn \__um_assign_delcode_parse:nn
    \cs_set_eq:NN \__um_make_mathactive:nNN \__um_make_mathactive_parse:nNN
    \seq_clear:N \l__um_char_range_seq
    \seq_clear:N \l__um_mclass_range_seq
    \seq_clear:N \l__um_cmd_range_seq
    \seq_clear:N \l__um_mathalph_seq

    \clist_map_inline:nn {#1}
     {
      \__um_if_mathalph_decl:nTF {##1}
       {
        \seq_put_right:Nx \l__um_mathalph_seq
         {
          { \exp_not:V \l__um_tmpa_tl }
          { \exp_not:V \l__um_tmpb_tl }
          { \exp_not:V \l__um_tmpc_tl }
         }
       }
       {
        \seq_if_in:NnTF \g__um_mathclasses_seq {##1}
          { \seq_put_right:Nn \l__um_mclass_range_seq {##1} }
          {
            \bool_if:nTF { \tl_if_single_p:n {##1} && \token_if_cs_p:N ##1 }
              { \seq_put_right:Nn \l__um_cmd_range_seq {##1} }
              { \seq_put_right:Nn \l__um_char_range_seq {##1} }
          }
       }
     }
   }
 }
\prg_new_conditional:Nnn \__um_if_mathalph_decl:n {TF}
 {
  \tl_set:Nn  \l__um_tmpa_tl {#1}
  \tl_clear:N \l__um_tmpb_tl
  \tl_clear:N \l__um_tmpc_tl

  \tl_if_in:NnT \l__um_tmpa_tl {->}
   { \exp_after:wN \__um_split_arrow:w \l__um_tmpa_tl \q_nil }

  \tl_if_in:NnT \l__um_tmpa_tl {/}
   { \exp_after:wN \__um_split_slash:w \l__um_tmpa_tl \q_nil }

  \tl_set:Nx \l__um_tmpa_tl { \tl_to_str:N \l__um_tmpa_tl }
  \exp_args:NNx \tl_remove_all:Nn \l__um_tmpa_tl { \token_to_str:N \math }
  \exp_args:NNx \tl_remove_all:Nn \l__um_tmpa_tl { \token_to_str:N \sym }
  \tl_trim_spaces:N \l__um_tmpa_tl

  \tl_if_empty:NT \l__um_tmpc_tl
   { \tl_set_eq:NN \l__um_tmpc_tl \l__um_tmpa_tl }

  \seq_if_in:NVTF \g__um_named_ranges_seq \l__um_tmpa_tl
   { \prg_return_true: } { \prg_return_false: }
 }
\cs_set:Npn \__um_split_arrow:w #1->#2 \q_nil
 {
  \tl_set:Nx \l__um_tmpa_tl { \tl_trim_spaces:n {#1} }
  \tl_set:Nx \l__um_tmpc_tl { \tl_trim_spaces:n {#2} }
 }
\cs_set:Npn \__um_split_slash:w #1/#2 \q_nil
 {
  \tl_set:Nx \l__um_tmpa_tl { \tl_trim_spaces:n {#1} }
  \tl_set:Nx \l__um_tmpb_tl { \tl_trim_spaces:n {#2} }
 }
\cs_new:Nn \__um_if_char_spec:nNNT
  {
    % math class:
    \seq_if_in:NnT \l__um_mclass_range_seq {#3}
      { \use_none_delimit_by_q_nil:w }

    % command name:
    \seq_if_in:NnT \l__um_cmd_range_seq {#2}
      { \use_none_delimit_by_q_nil:w }

    % character slot:
    \seq_map_inline:Nn \l__um_char_range_seq
      {
        \__um_int_if_slot_in_range:nnT {#1} {##1}
          { \seq_map_break:n { \use_none_delimit_by_q_nil:w } }
      }

    % the following expands to nil if no match was found:
    \use_none:nnn
    \q_nil
    \use:n
      {
        \clist_put_right:Nx \l__um_char_nrange_clist { \int_eval:n {#1} }
        #4
      }
  }
\cs_new:Nn \__um_int_if_slot_in_range:nnT
  { \__um_numrange_parse:nwT {#1} #2 - \q_nil - \q_stop {#3} }
\cs_set:Npn \__um_numrange_parse:nwT #1 #2 - #3 - #4 \q_stop #5
  {
    \tl_if_empty:nTF {#4} { \int_compare:nT {#1=#2} {#5} }
      {
    \tl_if_empty:nTF {#3} { \int_compare:nT {#1>=#2} {#5} }
      {
    \tl_if_empty:nTF {#2} { \int_compare:nT {#1<=#3} {#5} }
      {
    \int_compare:nT {#1>=#2} { \int_compare:nT {#1<=#3} {#5} }
      } } }
  }
\AtBeginDocument{\__um_resolve_greek:}
\cs_new:Npn \__um_resolve_greek:
 {
  \clist_map_inline:nn
   {
    Alpha,Beta,Gamma,Delta,Epsilon,Zeta,Eta,Theta,Iota,Kappa,Lambda,
    alpha,beta,gamma,delta,        zeta,eta,theta,iota,kappa,lambda,
    Mu,Nu,Xi,Omicron,Pi,Rho,Sigma,Tau,Upsilon,Phi,Chi,Psi,Omega,
    mu,nu,xi,omicron,pi,rho,sigma,tau,upsilon,    chi,psi,omega,
    varTheta,
    varsigma,vartheta,varkappa,varrho,varpi
   }
   {
    \tl_set:cx {##1} { \exp_not:c { mit ##1 } }
    \tl_set:cx {up ##1} { \exp_not:N \symup \exp_not:c { ##1 } }
    \tl_set:cx {it ##1} { \exp_not:N \symit \exp_not:c { ##1 } }
   }
  \tl_set:Nn \epsilon
   { \bool_if:NTF \g__um_texgreek_bool \mitvarepsilon \mitepsilon }
  \tl_set:Nn \phi
   { \bool_if:NTF \g__um_texgreek_bool \mitvarphi \mitphi }
  \tl_set:Nn \varepsilon
   { \bool_if:NTF \g__um_texgreek_bool \mitepsilon \mitvarepsilon }
  \tl_set:Nn \varphi
   { \bool_if:NTF \g__um_texgreek_bool \mitphi \mitvarphi }
 }
\cs_set:Npn \use@mathgroup #1 #2
 {
  \mode_if_math:T % <- not sure if this is really necessary since we've just checked for mmode and raised an error if not!
   {
    \math@bgroup
      \cs_if_eq:cNF {M@\f@encoding} #1 {#1}
      \__um_switchto_literal:
      \mathgroup #2 \relax
    \math@egroup
   }
 }
\cs_new:Nn \__um_prepare_mathstyle:n
 {
  \seq_put_right:Nn \g__um_mathstyles_seq {#1}
  \__um_init_alphabet:n {#1}
  \cs_set:cpn {__um_sym_#1_aux:n}
   { \use:c {__um_switchto_#1:} \math@egroup }
  \cs_set_protected:cpx {sym#1}
   {
    \exp_not:n
     {
      \math@bgroup
      \mode_if_math:F
        {
          \egroup\expandafter
          \non@alpherr\expandafter{\csname sym#1\endcsname\space}
        }
      \tl_set:Nn \l__um_mathstyle_tl {#1}
     }
    \exp_not:c {__um_sym_#1_aux:n}
   }
 }
\cs_set:Nn \__um_init_alphabet:n
 {
  \__um_log:nx {alph-initialise} {#1}
  \cs_set_eq:cN {__um_switchto_#1:} \prg_do_nothing:
 }
\cs_new:Nn \__um_new_named_range:n
 {
  \prop_new:c {g__um_named_range_#1_prop}
 }
\clist_set:Nn \g__um_named_ranges_clist
 {
  up, it, tt, bfup, bfit, bb , bbit, scr, bfscr, cal, bfcal,
  frak, bffrak, sfup, sfit, bfsfup, bfsfit, bfsf
 }
\clist_map_inline:Nn \g__um_named_ranges_clist
 { \__um_new_named_range:n {#1} }
\clist_new:N  \g__um_alphabets_seq
\clist_set:Nn \g__um_alphabets_seq { latin, Latin, greek, Greek, num }
\cs_new:Nn \__um_new_alphabet_config:nnn
 {
  \prop_if_exist:cF {g__um_named_range_#1_prop}
   { \__um_warning:nnn {no-named-range} {#1} {#2} }

  \prop_gput:cnn {g__um_named_range_#1_prop} { alpha_tl }
    {
     \prop_item:cn {g__um_named_range_#1_prop} { alpha_tl }
     {#2}
    }
  % Q: do I need to bother removing duplicates?

  \cs_new:cn { __um_config_#1_#2:n } {#3}
 }
\cs_new:Nn \__um_alphabet_config:nnn
 {
  \use:c {__um_config_#1_#2:n} {#3}
 }
\prg_new_conditional:Nnn \__um_if_alphabet_exists:nn {T,TF}
 {
  \cs_if_exist:cTF {__um_config_#1_#2:n}
   \prg_return_true: \prg_return_false:
 }
\cs_new:Nn \__um_default_mathalph:nnn
 {
  \seq_put_right:Nx \g__um_named_ranges_seq { \tl_to_str:n {#1} }
  \seq_put_right:Nn \g__um_default_mathalph_seq {{#1}{#2}{#3}}
  \prop_gput:cnn { g__um_named_range_#1_prop } { default-alpha } {#2}
 }
\__um_default_mathalph:nnn {up    } {latin,Latin,greek,Greek,num,misc} {up    }
\__um_default_mathalph:nnn {it    } {latin,Latin,greek,Greek,misc}     {it    }
\__um_default_mathalph:nnn {bb    } {latin,Latin,num,misc}             {bb    }
\__um_default_mathalph:nnn {bbit  } {misc}                             {bbit  }
\__um_default_mathalph:nnn {scr   } {latin,Latin}                      {scr   }
\__um_default_mathalph:nnn {cal   } {Latin}                            {scr   }
\__um_default_mathalph:nnn {bfcal } {Latin}                            {bfscr }
\__um_default_mathalph:nnn {frak  } {latin,Latin}                      {frak  }
\__um_default_mathalph:nnn {tt    } {latin,Latin,num}                  {tt    }
\__um_default_mathalph:nnn {sfup  } {latin,Latin,num}                  {sfup  }
\__um_default_mathalph:nnn {sfit  } {latin,Latin}                      {sfit  }
\__um_default_mathalph:nnn {bfup  } {latin,Latin,greek,Greek,num,misc} {bfup  }
\__um_default_mathalph:nnn {bfit  } {latin,Latin,greek,Greek,misc}     {bfit  }
\__um_default_mathalph:nnn {bfscr } {latin,Latin}                      {bfscr }
\__um_default_mathalph:nnn {bffrak} {latin,Latin}                      {bffrak}
\__um_default_mathalph:nnn {bfsfup} {latin,Latin,greek,Greek,num,misc} {bfsfup}
\__um_default_mathalph:nnn {bfsfit} {latin,Latin,greek,Greek,misc}     {bfsfit}
\clist_map_inline:nn
 {
  up, it, bfup, bfit, sfup, sfit, bfsfup, bfsfit, bfsf,
  tt, bb, bbit, scr, bfscr, cal, bfcal, frak, bffrak,
  normal, literal, sf, bf,
 }
 { \__um_prepare_mathstyle:n {#1} }
\clist_map_inline:nn
 { rm, it, bf, sf, tt }
 { \cs_set_eq:cc { mathtext #1 } { math #1 } }
\clist_map_inline:nn
 {
   normal, bb , bbit, scr, bfscr, cal, bfcal, frak, bffrak, tt,
   bfup, bfit, sfup, sfit, bfsfup, bfsfit, bfsf
 }
 {
  \cs_set:cpx { math #1 } { \exp_not:c { sym #1 } }
 }
\AtBeginDocument{
\clist_map_inline:nn
 { rm, it, bf, sf, tt }
 {
  \cs_set_protected:cpx { math #1 }
   {
    \exp_not:n { \bool_if:NTF  } \exp_not:c { g__um_ math #1 _text_bool}
     { \exp_not:c { mathtext #1 } }
     { \exp_not:c { sym #1 } }
   }
 }}
\cs_set_protected:Npn \mathup { \mathrm }
\cs_set_protected:Npn \symrm  { \symup  }
\cs_set:Npn \operator@font
 {
  \__um_switchto_literal:
  \@fontswitch {} { \g__um_operator_mathfont_tl }
 }
\cs_new:Npn \__um_setup_alphabets:
 {
  \seq_if_empty:NTF \l__um_mathalph_seq
   {
    \__um_log:n {setup-implicit}
    \seq_set_eq:NN \l__um_mathalph_seq \g__um_default_mathalph_seq
    \bool_set_true:N \l__um_implicit_alph_bool
    \__um_maybe_init_alphabet:n  {sf}
    \__um_maybe_init_alphabet:n  {bf}
    \__um_maybe_init_alphabet:n  {bfsf}
   }
   {
    \__um_log:n {setup-explicit}
    \bool_set_false:N \l__um_implicit_alph_bool
    \cs_set_eq:NN \__um_set_mathalphabet_char:nnn \__um_mathmap_noparse:nnn
    \cs_set_eq:NN \__um_map_char_single:nn \__um_map_char_noparse:nn
   }

  % Now perform the mapping:
  \seq_map_inline:Nn \l__um_mathalph_seq
   {
    \tl_set:No    \l__um_style_tl       { \use_i:nnn   ##1 }
    \clist_set:No \l__um_alphabet_clist { \use_ii:nnn  ##1 }
    \tl_set:No    \l__um_remap_style_tl { \use_iii:nnn ##1 }

    % If no set of alphabets is defined:
    \clist_if_empty:NT \l__um_alphabet_clist
     {
      \cs_set_eq:NN \__um_maybe_init_alphabet:n \__um_init_alphabet:n
      \prop_get:cnN { g__um_named_range_ \l__um_style_tl _prop }
       { default-alpha } \l__um_alphabet_clist
     }

    \__um_setup_math_alphabet:
   }
  \seq_if_empty:NF \l__um_missing_alph_seq { \__um_log:n { missing-alphabets } }
 }
\cs_new:Nn \__um_setup_math_alphabet:
 {
  \clist_map_inline:Nn \l__um_alphabet_clist
   {
    \tl_set:Nn \l__um_alphabet_tl {##1}
    \__um_if_alphabet_exists:nnTF \l__um_style_tl \l__um_alphabet_tl
     {
      \str_if_eq_x:nnTF {\l__um_alphabet_tl} {misc}
       {
        \__um_maybe_init_alphabet:n \l__um_style_tl
        \clist_map_break:
       }
       {
        \__um_glyph_if_exist:nT { \__um_to_usv:nn {\l__um_style_tl} {\l__um_alphabet_tl} }
         {
          \__um_maybe_init_alphabet:n \l__um_style_tl
          \clist_map_break:
         }
       }
     }
     { \msg_warning:nnx {unicode-math} {no-alphabet} { \l__um_style_tl / \l__um_alphabet_tl } }
   }
  \clist_map_inline:Nn \l__um_alphabet_clist
   {
    \tl_set:Nx \l__um_alphabet_tl { \tl_trim_spaces:n {##1} }
    \cs_if_exist:cT {__um_config_ \l__um_style_tl _ \l__um_alphabet_tl :n}
     {
      \exp_args:No \tl_if_eq:nnTF \l__um_alphabet_tl {misc}
       {
        \__um_log:nx {setup-alph} {sym \l__um_style_tl~(\l__um_alphabet_tl)}
        \__um_alphabet_config:nnn {\l__um_style_tl} {\l__um_alphabet_tl} {\l__um_remap_style_tl}
       }
       {
        \__um_glyph_if_exist:nTF { \__um_to_usv:nn {\l__um_remap_style_tl} {\l__um_alphabet_tl} }
         {
          \__um_log:nx {setup-alph} {sym \l__um_style_tl~(\l__um_alphabet_tl)}
          \__um_alphabet_config:nnn {\l__um_style_tl} {\l__um_alphabet_tl} {\l__um_remap_style_tl}
         }
         {
          \bool_if:NTF \l__um_implicit_alph_bool
           {
            \seq_put_right:Nx \l__um_missing_alph_seq
             {
              \@backslashchar sym \l__um_style_tl \space
              (\tl_use:c{c__um_math_alphabet_name_ \l__um_alphabet_tl _tl})
             }
           }
           {
            \__um_alphabet_config:nnn {\l__um_style_tl} {\l__um_alphabet_tl} {up}
           }
         }
       }
     }
   }
 }
\cs_new:Nn \__um_map_char_noparse:nn
 { \__um_set_mathcode:nnnn {#1}{\mathalpha}{\__um_symfont_tl}{#2} }
\cs_new:Nn \__um_map_char_parse:nn
 {
  \__um_if_char_spec:nNNT {#1} {\@nil} {\mathalpha}
   { \__um_map_char_noparse:nn {#1}{#2} }
 }
\cs_new:Nn \__um_map_char_single:nnn
 {
  \__um_map_char_single:nn { \__um_to_usv:nn {#1}{#3} }
                         { \__um_to_usv:nn {#2}{#3} }
 }
\cs_set:Nn \__um_map_chars_range:nnn
 {
  \int_step_inline:nnnn {0}{1}{#1-1}
   { \__um_map_char_single:nn {#2+##1}{#3+##1} }
 }
\cs_new:Nn \__um_map_chars_range:nnnn
 {
  \__um_map_chars_range:nnn {#1} { \__um_to_usv:nn {#2}{#4} }
                               { \__um_to_usv:nn {#3}{#4} }
 }
\cs_set:Nn \__um_set_normal_char:nnn
 {
  \__um_usv_if_exist:nnT {#3} {#1}
  {
    \clist_map_inline:nn {#2}
     {
      \__um_set_mathalphabet_pos:nnnn {normal} {#1} {##1} {#3}
      \__um_map_char_single:nnn {##1} {#3} {#1}
     }
  }
 }
\cs_new:Nn \__um_set_normal_Latin:nn
 {
  \clist_map_inline:nn {#1}
   {
    \__um_set_mathalphabet_Latin:nnn {normal} {##1} {#2}
    \__um_map_chars_range:nnnn {26} {##1} {#2} {Latin}
   }
 }
\cs_new:Nn \__um_set_normal_latin:nn
 {
  \clist_map_inline:nn {#1}
   {
    \__um_set_mathalphabet_latin:nnn {normal} {##1} {#2}
    \__um_map_chars_range:nnnn {26} {##1} {#2} {latin}
   }
 }
\cs_new:Nn \__um_set_normal_greek:nn
 {
  \clist_map_inline:nn {#1}
   {
    \__um_set_mathalphabet_greek:nnn {normal} {##1} {#2}
    \__um_map_chars_range:nnnn {25} {##1} {#2} {greek}
    \__um_map_char_single:nnn {##1} {#2} {varepsilon}
    \__um_map_char_single:nnn {##1} {#2} {vartheta}
    \__um_map_char_single:nnn {##1} {#2} {varkappa}
    \__um_map_char_single:nnn {##1} {#2} {varphi}
    \__um_map_char_single:nnn {##1} {#2} {varrho}
    \__um_map_char_single:nnn {##1} {#2} {varpi}
    \__um_set_mathalphabet_pos:nnnn {normal} {varepsilon} {##1} {#2}
    \__um_set_mathalphabet_pos:nnnn {normal} {vartheta} {##1} {#2}
    \__um_set_mathalphabet_pos:nnnn {normal} {varkappa} {##1} {#2}
    \__um_set_mathalphabet_pos:nnnn {normal} {varphi} {##1} {#2}
    \__um_set_mathalphabet_pos:nnnn {normal} {varrho} {##1} {#2}
    \__um_set_mathalphabet_pos:nnnn {normal} {varpi} {##1} {#2}
   }
 }
\cs_new:Nn \__um_set_normal_Greek:nn
 {
  \clist_map_inline:nn {#1}
   {
    \__um_set_mathalphabet_Greek:nnn {normal} {##1} {#2}
    \__um_map_chars_range:nnnn {25} {##1} {#2} {Greek}
    \__um_map_char_single:nnn {##1} {#2} {varTheta}
    \__um_set_mathalphabet_pos:nnnn {normal} {varTheta} {##1} {#2}
   }
 }
\cs_new:Nn \__um_set_normal_numbers:nn
 {
  \__um_set_mathalphabet_numbers:nnn {normal} {#1} {#2}
  \__um_map_chars_range:nnnn {10} {#1} {#2} {num}
 }
\cs_new:Nn \__um_mathmap_noparse:nnn
 {
  \clist_map_inline:nn {#2}
   {
    \tl_put_right:cx {__um_switchto_#1:}
     {
      \__um_set_mathcode:nnnn {##1} {\mathalpha} {\__um_symfont_tl} {#3}
     }
   }
 }
\cs_new:Nn \__um_mathmap_parse:nnn
 {
  \clist_if_in:NnT \l__um_char_nrange_clist {#3}
   {
    \__um_mathmap_noparse:nnn {#1}{#2}{#3}
   }
 }
\cs_new:Nn \__um_set_mathalphabet_char:nnnn
 {
  \__um_set_mathalphabet_char:nnn {#1} { \__um_to_usv:nn {#2} {#4} }
                                     { \__um_to_usv:nn {#3} {#4} }
 }
\cs_new:Nn \__um_set_mathalph_range:nnnn
 {
  \int_step_inline:nnnn {0} {1} {#1-1}
    { \__um_set_mathalphabet_char:nnn {#2} { ##1 + #3 } { ##1 + #4 } }
 }
\cs_new:Nn \__um_set_mathalph_range:nnnnn
 {
  \__um_set_mathalph_range:nnnn {#1} {#2} { \__um_to_usv:nn {#3} {#5} }
                                        { \__um_to_usv:nn {#4} {#5} }
 }
\cs_new:Nn \__um_set_mathalphabet_pos:nnnn
 {
  \__um_usv_if_exist:nnT {#4} {#2}
   {
    \clist_map_inline:nn {#3}
      { \__um_set_mathalphabet_char:nnnn {#1} {##1} {#4} {#2} }
   }
 }
\cs_new:Nn \__um_set_mathalphabet_numbers:nnn
 {
  \clist_map_inline:nn {#2}
    { \__um_set_mathalph_range:nnnnn {10} {#1} {##1} {#3} {num} }
 }
\cs_new:Nn \__um_set_mathalphabet_Latin:nnn
 {
  \clist_map_inline:nn {#2}
    { \__um_set_mathalph_range:nnnnn {26} {#1} {##1} {#3} {Latin} }
 }
\cs_new:Nn \__um_set_mathalphabet_latin:nnn
 {
  \clist_map_inline:nn {#2}
   {
    \__um_set_mathalph_range:nnnnn {26} {#1} {##1} {#3} {latin}
    \__um_set_mathalphabet_char:nnnn    {#1} {##1} {#3} {h}
   }
 }
\cs_new:Nn \__um_set_mathalphabet_Greek:nnn
 {
  \clist_map_inline:nn {#2}
   {
    \__um_set_mathalph_range:nnnnn {25} {#1} {##1} {#3} {Greek}
    \__um_set_mathalphabet_char:nnnn    {#1} {##1} {#3} {varTheta}
   }
 }
\cs_new:Nn \__um_set_mathalphabet_greek:nnn
 {
  \clist_map_inline:nn {#2}
   {
    \__um_set_mathalph_range:nnnnn {25} {#1} {##1} {#3} {greek}
    \__um_set_mathalphabet_char:nnnn    {#1} {##1} {#3} {varepsilon}
    \__um_set_mathalphabet_char:nnnn    {#1} {##1} {#3} {vartheta}
    \__um_set_mathalphabet_char:nnnn    {#1} {##1} {#3} {varkappa}
    \__um_set_mathalphabet_char:nnnn    {#1} {##1} {#3} {varphi}
    \__um_set_mathalphabet_char:nnnn    {#1} {##1} {#3} {varrho}
    \__um_set_mathalphabet_char:nnnn    {#1} {##1} {#3} {varpi}
   }
 }
\cs_new:Npn \__um_symbol_setup:
 {
  \cs_set:Npn \UnicodeMathSymbol ##1##2##3##4
   {
    \exp_not:n { \__um_sym:nnn {##1} {##2} {##3} }
   }
 }
\tl_set_from_file_x:Nnn \g__um_mathtable_tl {\__um_symbol_setup:} {unicode-math-table.tex}
\cs_new:Nn \__um_input_math_symbol_table: {\g__um_mathtable_tl}
\AtBeginDocument{\__um_define_math_chars:}
\cs_new:Nn \__um_define_math_chars:
 {
  \group_begin:
    \cs_set:Npn \__um_sym:nnn ##1##2##3
     {
      \tl_if_in:nnT
       { \mathord \mathalpha \mathbin \mathrel \mathpunct \mathop \mathfence }
       {##3}
      {
        \exp_last_unbraced:NNx \cs_gset_eq:NN ##2 { \Ucharcat ##1 ~ 12 ~ }
      }
     }
    \__um_input_math_symbol_table:
  \group_end:
 }
\AtBeginDocument { \__um_load_lm_if_necessary: }
\cs_new:Nn \__um_load_lm_if_necessary:
  {
    \cs_if_exist:NF \l__um_fontname_tl
      {
        % TODO: update this when lmmath-bold.otf is released
        \setmathfont{latinmodern-math.otf}[BoldFont={latinmodern-math.otf}]
        \bool_set_false:N \g__um_mainfont_already_set_bool
      }
  }
\cs_new:Nn \__um_arg_i_before_egroup:n {#1\egroup}
\cs_new:Nn \__um_superscript:n
 {
  ^\bgroup #1
  \peek_meaning_remove:NTF ^ \__um_arg_i_before_egroup:n \egroup
 }
\cs_new:Nn \__um_nprimes:Nn
 {
  \__um_superscript:n
   {
    #1
    \prg_replicate:nn {#2-1} { \mskip \g__um_primekern_muskip #1 }
   }
 }

\cs_new:Nn \__um_nprimes_select:nn
 {
  \int_case:nnF {#2}
   {
    {1} { \__um_superscript:n {#1} }
    {2} {
      \__um_glyph_if_exist:nTF {"2033}
        { \__um_superscript:n {\__um_prime_double_mchar} }
        { \__um_nprimes:Nn #1 {#2} }
    }
    {3} {
      \__um_glyph_if_exist:nTF {"2034}
        { \__um_superscript:n {\__um_prime_triple_mchar} }
        { \__um_nprimes:Nn #1 {#2} }
    }
    {4} {
      \__um_glyph_if_exist:nTF {"2057}
        { \__um_superscript:n {\__um_prime_quad_mchar} }
        { \__um_nprimes:Nn #1 {#2} }
    }
   }
   {
    \__um_nprimes:Nn #1 {#2}
   }
 }
\cs_new:Nn \__um_nbackprimes_select:nn
 {
  \int_case:nnF {#2}
   {
    {1} { \__um_superscript:n {#1} }
    {2} {
      \__um_glyph_if_exist:nTF {"2036}
        { \__um_superscript:n {\__um_backprime_double_mchar} }
        { \__um_nprimes:Nn #1 {#2} }
    }
    {3} {
      \__um_glyph_if_exist:nTF {"2037}
        { \__um_superscript:n {\__um_backprime_triple_mchar} }
        { \__um_nprimes:Nn #1 {#2} }
    }
   }
   {
    \__um_nprimes:Nn #1 {#2}
   }
 }
\cs_new:Npn \__um_scan_prime:
 {
  \cs_set_eq:NN \__um_superscript:n \use:n
  \int_zero:N \l__um_primecount_int
  \__um_scanprime_collect:N \__um_prime_single_mchar
 }
\cs_new:Npn \__um_scan_dprime:
 {
  \cs_set_eq:NN \__um_superscript:n \use:n
  \int_set:Nn \l__um_primecount_int {1}
  \__um_scanprime_collect:N \__um_prime_single_mchar
 }
\cs_new:Npn \__um_scan_trprime:
 {
  \cs_set_eq:NN \__um_superscript:n \use:n
  \int_set:Nn \l__um_primecount_int {2}
  \__um_scanprime_collect:N \__um_prime_single_mchar
 }
\cs_new:Npn \__um_scan_qprime:
 {
  \cs_set_eq:NN \__um_superscript:n \use:n
  \int_set:Nn \l__um_primecount_int {3}
  \__um_scanprime_collect:N \__um_prime_single_mchar
 }
\cs_new:Npn \__um_scan_sup_prime:
 {
  \int_zero:N \l__um_primecount_int
  \__um_scanprime_collect:N \__um_prime_single_mchar
 }
\cs_new:Npn \__um_scan_sup_dprime:
 {
  \int_set:Nn \l__um_primecount_int {1}
  \__um_scanprime_collect:N \__um_prime_single_mchar
 }
\cs_new:Npn \__um_scan_sup_trprime:
 {
  \int_set:Nn \l__um_primecount_int {2}
  \__um_scanprime_collect:N \__um_prime_single_mchar
 }
\cs_new:Npn \__um_scan_sup_qprime:
 {
  \int_set:Nn \l__um_primecount_int {3}
  \__um_scanprime_collect:N \__um_prime_single_mchar
 }
\cs_new:Nn \__um_scanprime_collect:N
 {
  \int_incr:N \l__um_primecount_int
  \peek_meaning_remove:NTF '
   { \__um_scanprime_collect:N #1 }
   {
    \peek_meaning_remove:NTF \__um_scan_prime:
     { \__um_scanprime_collect:N #1 }
     {
      \peek_meaning_remove:NTF ^^^^2032
       { \__um_scanprime_collect:N #1 }
       {
        \peek_meaning_remove:NTF \__um_scan_dprime:
         {
          \int_incr:N \l__um_primecount_int
          \__um_scanprime_collect:N #1
         }
         {
          \peek_meaning_remove:NTF ^^^^2033
           {
            \int_incr:N \l__um_primecount_int
            \__um_scanprime_collect:N #1
           }
           {
            \peek_meaning_remove:NTF \__um_scan_trprime:
             {
              \int_add:Nn \l__um_primecount_int {2}
              \__um_scanprime_collect:N #1
             }
             {
              \peek_meaning_remove:NTF ^^^^2034
               {
                \int_add:Nn \l__um_primecount_int {2}
                \__um_scanprime_collect:N #1
               }
               {
                \peek_meaning_remove:NTF \__um_scan_qprime:
                 {
                  \int_add:Nn \l__um_primecount_int {3}
                  \__um_scanprime_collect:N #1
                 }
                 {
                  \peek_meaning_remove:NTF ^^^^2057
                   {
                    \int_add:Nn \l__um_primecount_int {3}
                    \__um_scanprime_collect:N #1
                   }
                   {
                    \__um_nprimes_select:nn {#1} {\l__um_primecount_int}
                   }
                 }
               }
             }
           }
         }
       }
     }
   }
 }
\cs_new:Npn \__um_scan_backprime:
 {
  \cs_set_eq:NN \__um_superscript:n \use:n
  \int_zero:N \l__um_primecount_int
  \__um_scanbackprime_collect:N \__um_backprime_single_mchar
 }
\cs_new:Npn \__um_scan_backdprime:
 {
  \cs_set_eq:NN \__um_superscript:n \use:n
  \int_set:Nn \l__um_primecount_int {1}
  \__um_scanbackprime_collect:N \__um_backprime_single_mchar
 }
\cs_new:Npn \__um_scan_backtrprime:
 {
  \cs_set_eq:NN \__um_superscript:n \use:n
  \int_set:Nn \l__um_primecount_int {2}
  \__um_scanbackprime_collect:N \__um_backprime_single_mchar
 }
\cs_new:Npn \__um_scan_sup_backprime:
 {
  \int_zero:N \l__um_primecount_int
  \__um_scanbackprime_collect:N \__um_backprime_single_mchar
 }
\cs_new:Npn \__um_scan_sup_backdprime:
 {
  \int_set:Nn \l__um_primecount_int {1}
  \__um_scanbackprime_collect:N \__um_backprime_single_mchar
 }
\cs_new:Npn \__um_scan_sup_backtrprime:
 {
  \int_set:Nn \l__um_primecount_int {2}
  \__um_scanbackprime_collect:N \__um_backprime_single_mchar
 }
\cs_new:Nn \__um_scanbackprime_collect:N
 {
  \int_incr:N \l__um_primecount_int
  \peek_meaning_remove:NTF `
   {
    \__um_scanbackprime_collect:N #1
   }
   {
    \peek_meaning_remove:NTF \__um_scan_backprime:
     {
      \__um_scanbackprime_collect:N #1
     }
     {
      \peek_meaning_remove:NTF ^^^^2035
       {
        \__um_scanbackprime_collect:N #1
       }
       {
        \peek_meaning_remove:NTF \__um_scan_backdprime:
         {
          \int_incr:N \l__um_primecount_int
          \__um_scanbackprime_collect:N #1
         }
         {
          \peek_meaning_remove:NTF ^^^^2036
           {
            \int_incr:N \l__um_primecount_int
            \__um_scanbackprime_collect:N #1
           }
           {
            \peek_meaning_remove:NTF \__um_scan_backtrprime:
             {
              \int_add:Nn \l__um_primecount_int {2}
              \__um_scanbackprime_collect:N #1
             }
             {
              \peek_meaning_remove:NTF ^^^^2037
               {
                \int_add:Nn \l__um_primecount_int {2}
                \__um_scanbackprime_collect:N #1
               }
               {
                \__um_nbackprimes_select:nn {#1} {\l__um_primecount_int}
               }
             }
           }
         }
       }
     }
   }
 }
\AtBeginDocument{\__um_define_prime_commands: \__um_define_prime_chars:}
\cs_new:Nn \__um_define_prime_commands:
 {
  \cs_set_eq:NN \prime       \__um_prime_single_mchar
  \cs_set_eq:NN \dprime      \__um_prime_double_mchar
  \cs_set_eq:NN \trprime     \__um_prime_triple_mchar
  \cs_set_eq:NN \qprime      \__um_prime_quad_mchar
  \cs_set_eq:NN \backprime   \__um_backprime_single_mchar
  \cs_set_eq:NN \backdprime  \__um_backprime_double_mchar
  \cs_set_eq:NN \backtrprime \__um_backprime_triple_mchar
 }
\group_begin:
  \char_set_catcode_active:N \'
  \char_set_catcode_active:N \`
  \char_set_catcode_active:n {"2032}
  \char_set_catcode_active:n {"2033}
  \char_set_catcode_active:n {"2034}
  \char_set_catcode_active:n {"2057}
  \char_set_catcode_active:n {"2035}
  \char_set_catcode_active:n {"2036}
  \char_set_catcode_active:n {"2037}
  \cs_gset:Nn \__um_define_prime_chars:
   {
    \cs_set_eq:NN '        \__um_scan_sup_prime:
    \cs_set_eq:NN ^^^^2032 \__um_scan_sup_prime:
    \cs_set_eq:NN ^^^^2033 \__um_scan_sup_dprime:
    \cs_set_eq:NN ^^^^2034 \__um_scan_sup_trprime:
    \cs_set_eq:NN ^^^^2057 \__um_scan_sup_qprime:
    \cs_set_eq:NN `        \__um_scan_sup_backprime:
    \cs_set_eq:NN ^^^^2035 \__um_scan_sup_backprime:
    \cs_set_eq:NN ^^^^2036 \__um_scan_sup_backdprime:
    \cs_set_eq:NN ^^^^2037 \__um_scan_sup_backtrprime:
   }
\group_end:
\cs_if_exist:NF \Uroot
  { \cs_new_eq:NN \Uroot \luatexUroot }
\AtBeginDocument{\__um_redefine_radical:}
\cs_new:Nn \__um_redefine_radical:
 {
  \@ifpackageloaded { amsmath } { }
   {
    \cs_set:Npn \root ##1 \of ##2
     {
       \Uroot \l__um_radical_sqrt_tl { ##1 } { ##2 }
     }
   }
 }
\cs_new:Nn \__um_fontdimen_to_percent:nn
 {
  \fp_eval:n { \dim_to_decimal:n { \fontdimen #1 #2 } * 65536 / 100 }
 }
\cs_new:Nn \__um_fontdimen_to_scale:nn
 {
  \fp_eval:n {\__um_fontdimen_to_percent:nn {#1} {#2} * \f@size } pt
 }
\cs_new:Nn \__um_mathstyle_scale:Nnn
 {
  \ifx#1\scriptstyle
    #2 \__um_fontdimen_to_percent:nn {10} \l__um_font #3
  \else
    \ifx#1\scriptscriptstyle
      #2 \__um_fontdimen_to_percent:nn {11} \l__um_font #3
    \else
      #2 #3
    \fi
  \fi
 }
\group_begin:
\cs_new:Nn \__um_setup_active_superscript:nn
 {
  \prop_gput:Non \g__um_supers_prop   {\meaning #1} {#2}
  \char_set_catcode_active:N #1
  \__um_char_gmake_mathactive:N #1
  \scantokens
   {
    \cs_gset:Npn #1
     {
      \tl_set:Nn \l__um_ss_chain_tl {#2}
      \cs_set_eq:NN \__um_sub_or_super:n \sp
      \tl_set:Nn \l__um_tmpa_tl {supers}
      \__um_scan_sscript:
     }
   }
 }
\__um_setup_active_superscript:nn {^^^^2070} {0}
\__um_setup_active_superscript:nn {^^^^00b9} {1}
\__um_setup_active_superscript:nn {^^^^00b2} {2}
\__um_setup_active_superscript:nn {^^^^00b3} {3}
\__um_setup_active_superscript:nn {^^^^2074} {4}
\__um_setup_active_superscript:nn {^^^^2075} {5}
\__um_setup_active_superscript:nn {^^^^2076} {6}
\__um_setup_active_superscript:nn {^^^^2077} {7}
\__um_setup_active_superscript:nn {^^^^2078} {8}
\__um_setup_active_superscript:nn {^^^^2079} {9}
\__um_setup_active_superscript:nn {^^^^207a} {+}
\__um_setup_active_superscript:nn {^^^^207b} {-}
\__um_setup_active_superscript:nn {^^^^207c} {=}
\__um_setup_active_superscript:nn {^^^^207d} {(}
\__um_setup_active_superscript:nn {^^^^207e} {)}
\__um_setup_active_superscript:nn {^^^^2071} {i}
\__um_setup_active_superscript:nn {^^^^207f} {n}
\__um_setup_active_superscript:nn {^^^^02b0} {h}
\__um_setup_active_superscript:nn {^^^^02b2} {j}
\__um_setup_active_superscript:nn {^^^^02b3} {r}
\__um_setup_active_superscript:nn {^^^^02b7} {w}
\__um_setup_active_superscript:nn {^^^^02b8} {y}
\cs_new:Nn \__um_setup_active_subscript:nn
 {
  \prop_gput:Non \g__um_subs_prop   {\meaning #1} {#2}
  \char_set_catcode_active:N #1
  \__um_char_gmake_mathactive:N #1
  \scantokens
   {
    \cs_gset:Npn #1
     {
      \tl_set:Nn \l__um_ss_chain_tl {#2}
      \cs_set_eq:NN \__um_sub_or_super:n \sb
      \tl_set:Nn \l__um_tmpa_tl {subs}
      \__um_scan_sscript:
     }
   }
 }
\__um_setup_active_subscript:nn {^^^^2080} {0}
\__um_setup_active_subscript:nn {^^^^2081} {1}
\__um_setup_active_subscript:nn {^^^^2082} {2}
\__um_setup_active_subscript:nn {^^^^2083} {3}
\__um_setup_active_subscript:nn {^^^^2084} {4}
\__um_setup_active_subscript:nn {^^^^2085} {5}
\__um_setup_active_subscript:nn {^^^^2086} {6}
\__um_setup_active_subscript:nn {^^^^2087} {7}
\__um_setup_active_subscript:nn {^^^^2088} {8}
\__um_setup_active_subscript:nn {^^^^2089} {9}
\__um_setup_active_subscript:nn {^^^^208a} {+}
\__um_setup_active_subscript:nn {^^^^208b} {-}
\__um_setup_active_subscript:nn {^^^^208c} {=}
\__um_setup_active_subscript:nn {^^^^208d} {(}
\__um_setup_active_subscript:nn {^^^^208e} {)}
\__um_setup_active_subscript:nn {^^^^2090} {a}
\__um_setup_active_subscript:nn {^^^^2091} {e}
\__um_setup_active_subscript:nn {^^^^1d62} {i}
\__um_setup_active_subscript:nn {^^^^2092} {o}
\__um_setup_active_subscript:nn {^^^^1d63} {r}
\__um_setup_active_subscript:nn {^^^^1d64} {u}
\__um_setup_active_subscript:nn {^^^^1d65} {v}
\__um_setup_active_subscript:nn {^^^^2093} {x}
\__um_setup_active_subscript:nn {^^^^1d66} {\beta}
\__um_setup_active_subscript:nn {^^^^1d67} {\gamma}
\__um_setup_active_subscript:nn {^^^^1d68} {\rho}
\__um_setup_active_subscript:nn {^^^^1d69} {\phi}
\__um_setup_active_subscript:nn {^^^^1d6a} {\chi}
\group_end:
\cs_new:Npn \__um_scan_sscript:
 {
  \__um_scan_sscript:TF
   {
    \__um_scan_sscript:
   }
   {
    \__um_sub_or_super:n {\l__um_ss_chain_tl}
   }
 }
\cs_new:Npn \__um_scan_sscript:TF #1#2
 {
  \tl_set:Nx \__peek_true_aux:w { \exp_not:n{ #1 } }
  \tl_set_eq:NN \__peek_true:w \__peek_true_remove:w
  \tl_set:Nx \__peek_false:w { \exp_not:n { \group_align_safe_end: #2 } }
  \group_align_safe_begin:
    \peek_after:Nw \__um_peek_execute_branches_ss:
 }
\cs_new:Npn \__um_peek_execute_branches_ss:
 {
  \bool_if:nTF
   {
    \token_if_eq_catcode_p:NN \l_peek_token \c_group_begin_token ||
    \token_if_eq_catcode_p:NN \l_peek_token \c_group_end_token ||
    \token_if_eq_meaning_p:NN \l_peek_token \c_space_token
   }
   { \__peek_false:w  }
   { \__um_peek_execute_branches_ss_aux: }
 }
\cs_new:Npn \__um_peek_execute_branches_ss_aux:
 {
  \prop_if_in:coTF
    {g__um_\l__um_tmpa_tl _prop} {\meaning\l_peek_token}
    {
      \prop_get:coN
        {g__um_\l__um_tmpa_tl _prop} {\meaning\l_peek_token} \l__um_tmpb_tl
      \tl_put_right:NV \l__um_ss_chain_tl \l__um_tmpb_tl
      \__peek_true:w
    }
    { \__peek_false:w }
 }
\cs_new:Npn \__um_define_active_frac:Nw #1 #2/#3
 {
  \char_set_catcode_active:N #1
  \__um_char_gmake_mathactive:N #1
  \tl_rescan:nn
   {
    \catcode`\_=11\relax
    \catcode`\:=11\relax
   }
   {
    \cs_gset:Npx #1
     {
      \bool_if:NTF \l__um_smallfrac_bool {\exp_not:N\tfrac} {\exp_not:N\frac}
          {#2} {#3}
     }
   }
 }
\cs_new:Npn \__um_setup_active_frac:
 {
  \group_begin:
  \__um_define_active_frac:Nw  ^^^^2189  0/3
  \__um_define_active_frac:Nw  ^^^^2152  1/{10}
  \__um_define_active_frac:Nw  ^^^^2151  1/9
  \__um_define_active_frac:Nw  ^^^^215b  1/8
  \__um_define_active_frac:Nw  ^^^^2150  1/7
  \__um_define_active_frac:Nw  ^^^^2159  1/6
  \__um_define_active_frac:Nw  ^^^^2155  1/5
  \__um_define_active_frac:Nw  ^^^^00bc  1/4
  \__um_define_active_frac:Nw  ^^^^2153  1/3
  \__um_define_active_frac:Nw  ^^^^215c  3/8
  \__um_define_active_frac:Nw  ^^^^2156  2/5
  \__um_define_active_frac:Nw  ^^^^00bd  1/2
  \__um_define_active_frac:Nw  ^^^^2157  3/5
  \__um_define_active_frac:Nw  ^^^^215d  5/8
  \__um_define_active_frac:Nw  ^^^^2154  2/3
  \__um_define_active_frac:Nw  ^^^^00be  3/4
  \__um_define_active_frac:Nw  ^^^^2158  4/5
  \__um_define_active_frac:Nw  ^^^^215a  5/6
  \__um_define_active_frac:Nw  ^^^^215e  7/8
  \group_end:
 }
\__um_setup_active_frac:
\def\to{\rightarrow}
\def\le{\leq}
\def\ge{\geq}
\def\neq{\ne}
\def\triangle{\mathord{\bigtriangleup}}
\def\bigcirc{\mdlgwhtcircle}
\def\circ{\vysmwhtcircle}
\def\bullet{\smblkcircle}
\def\mathyen{\yen}
\def\mathsterling{\sterling}
\def\diamond{\smwhtdiamond}
\def\emptyset{\varnothing}
\def\hbar{\hslash}
\def\land{\wedge}
\def\lor{\vee}
\def\owns{\ni}
\def\gets{\leftarrow}
\def\mathring{\ocirc}
\def\lnot{\neg}
\def\longdivision{\longdivisionsign}
\def\backepsilon{\upbackepsilon}
\def\eth{\matheth}
\def\dbkarow {\dbkarrow}
\def\drbkarow{\drbkarrow}
\def\hksearow{\hksearrow}
\def\hkswarow{\hkswarrow}
\def\smallint{\mathop{\textstyle\int}\limits}
\cs_set_eq:NN \latexe_underbar:n \underbar
\renewcommand\underbar
 {
  \mode_if_math:TF \mathunderbar \latexe_underbar:n
 }
\@ifpackageloaded{amsmath}
 {
  % define their own colon, perhaps I should just steal it. (It does look much better.)
 }
 {
  \cs_set_protected:Npn \colon
   {
    \bool_if:NTF \g__um_literal_colon_bool {:} { \mathpunct{:} }
   }
 }
\def\digamma{\updigamma}
\def\Digamma{\upDigamma}
\cs_set:Npn \| {\Vert}
\cs_set:Npn \mathellipsis {\mathinner{\unicodeellipsis}}
\cs_set:Npn \cdots {\mathinner{\unicodecdots}}
\cs_set_eq:NN \__um_text_slash: \slash
\cs_set_protected:Npn \slash
 {
  \mode_if_math:TF {\mathslash} {\__um_text_slash:}
 }
\cs_new:Npn \__um_newnot:N #1
 {
   \tl_set:Nx \l_not_token_name_tl { \token_to_str:N #1 }
   \exp_args:Nx \tl_if_empty:nF { \tl_tail:V \l_not_token_name_tl }
    {
     \tl_set:Nx \l_not_token_name_tl { \tl_tail:V \l_not_token_name_tl }
    }
   \cs_if_exist:cTF { n \l_not_token_name_tl }
    {
     \use:c { n \l_not_token_name_tl }
    }
    {
     \cs_if_exist:cTF { not \l_not_token_name_tl }
      {
       \use:c { not \l_not_token_name_tl }
      }
      {
       \__um_oldnot: #1
      }
    }
 }
\cs_set_eq:NN \__um_oldnot: \not
\AtBeginDocument{\cs_set_eq:NN \not \__um_newnot:N}
\cs_new_protected_nopar:Nn \__um_setup_negations:
 {
  \cs_gset:cpn { not= }    { \neq }
  \cs_gset:cpn { not< }    { \nless }
  \cs_gset:cpn { not> }    { \ngtr }
  \cs_gset:Npn  \ngets     { \nleftarrow }
  \cs_gset:Npn  \nsimeq    { \nsime }
  \cs_gset:Npn  \nequal    { \ne }
  \cs_gset:Npn  \nle       { \nleq }
  \cs_gset:Npn  \nge       { \ngeq }
  \cs_gset:Npn  \ngreater  { \ngtr }
  \cs_gset:Npn  \nforksnot { \forks }
 }
\cs_new_protected_nopar:Nn \__um_check_and_fix:NNnnnn
 {
  \cs_if_exist:NT #1
   {
    \token_if_macro:NTF #1
     {
      \group_begin:
      #2 \__um_tmpa:w #3 { #4 }
      \cs_if_eq:NNTF #1 \__um_tmpa:w
       {
        \msg_info:nnx { unicode-math } { patch-macro }
          { \token_to_str:N #1 }
        \group_end:
        #2 #1 #3
          { #5 }
       }
       {
        \msg_warning:nnxxx { unicode-math } { wrong-meaning }
          { \token_to_str:N #1 } { \token_to_meaning:N #1 }
          { \token_to_meaning:N \__um_tmpa:w }
        \group_end:
       }
     }
     {
      \msg_warning:nnx { unicode-math } { macro-expected }
        { \token_to_str:N #1 }
     }
   }
 }
\cs_new_protected_nopar:Nn \__um_check_and_fix:NNnnn
 {
  \__um_check_and_fix:NNnnnn #1 #2 { #3 } { #4 } { #5 } { #5 }
 }
\cs_new_protected_nopar:Nn \__um_check_and_fix_luatex:NNnnn
 {
    \__um_check_and_fix:NNnnn #1 #2 { #3 } { #4 } { #5 }
 }
\cs_generate_variant:Nn \__um_check_and_fix_luatex:NNnnn { c }
\AtEndOfPackageFile * {url}
 {
  \tl_put_left:Nn \Url@FormatString { \__um_switchto_up: }
  \tl_put_right:Nn \UrlSpecials
   {
    \do\`{\mathchar`\`}
    \do\'{\mathchar`\'}
    \do\${\mathchar`\$}
    \do\&{\mathchar`\&}
   }
 }
\AtEndOfPackageFile * {amsmath}
 {
  \cs_set:Npn \@cdots {\mathinner{\cdots}}
  \cs_set_eq:NN \dotsb@ \cdots
  \__um_check_and_fix_luatex:NNnnn \plainroot@ \cs_set_nopar:Npn { #1 \of #2 }
   {
    \setbox \rootbox \hbox
     {
      $ \m@th \scriptscriptstyle { #1 } $
     }
    \mathchoice
      { \r@@t \displaystyle      { #2 } }
      { \r@@t \textstyle         { #2 } }~
      { \r@@t \scriptstyle       { #2 } }
      { \r@@t \scriptscriptstyle { #2 } }
    \egroup
   }
   {
    \bool_if:nTF
     {
      \int_compare_p:nNn { \uproot@ } = { \c_zero }
      && \int_compare_p:nNn { \leftroot@ } = { \c_zero }
     }
     {
        \Uroot \l__um_radical_sqrt_tl { #1 } { #2 }
     }
     {
      \hbox_set:Nn \rootbox
       {
        \c_math_toggle_token
        \m@th
        \scriptscriptstyle { #1 }
        \c_math_toggle_token
       }
      \mathchoice
        { \r@@t \displaystyle      { #2 } }
        { \r@@t \textstyle         { #2 } }
        { \r@@t \scriptstyle       { #2 } }
        { \r@@t \scriptscriptstyle { #2 } }
     }
    \c_group_end_token
   }
  \__um_check_and_fix:NNnnnn \r@@t \cs_set_nopar:Npn { #1 #2 }
   {
    \setboxz@h { $ \m@th #1 \sqrtsign { #2 } $ }
    \dimen@ \ht\z@
    \advance \dimen@ -\dp\z@
    \setbox\@ne \hbox { $ \m@th #1 \mskip \uproot@ mu $ }
    \advance \dimen@ by 1.667 \wd\@ne
    \mkern -\leftroot@ mu
    \mkern 5mu
    \raise .6\dimen@ \copy\rootbox
    \mkern -10mu
    \mkern \leftroot@ mu
    \boxz@
   }
   {
    \hbox_set:Nn \l_tmpa_box
     {
      \c_math_toggle_token
      \m@th
      #1
      \mskip \uproot@ mu
      \c_math_toggle_token
     }
      \Uroot \l__um_radical_sqrt_tl
     {
      \box_move_up:nn { \box_wd:N \l_tmpa_box }
       {
        \hbox:n
         {
          \c_math_toggle_token
          \m@th
          \mkern -\leftroot@ mu
          \box_use:N \rootbox
          \mkern \leftroot@ mu
          \c_math_toggle_token
         }
       }
     }
     { #2 }
   }
   {
    \hbox_set:Nn \l_tmpa_box
     {
      \c_math_toggle_token
      \m@th
      #1
      \sqrtsign { #2 }
      \c_math_toggle_token
     }
    \hbox_set:Nn \l_tmpb_box
     {
      \c_math_toggle_token
      \m@th
      #1
      \mskip \uproot@ mu
      \c_math_toggle_token
     }
    \mkern -\leftroot@ mu
    \__um_mathstyle_scale:Nnn #1 { \kern }
     {
      \fontdimen 63 \l__um_font
     }
    \box_move_up:nn
     {
      \box_wd:N \l_tmpb_box
      + (\box_ht:N \l_tmpa_box - \box_dp:N \l_tmpa_box)
      * \number \fontdimen 65 \l__um_font / 100
     }
     {
      \box_use:N \rootbox
     }
    \__um_mathstyle_scale:Nnn #1 { \kern }
     {
      \fontdimen 64 \l__um_font
     }
    \mkern \leftroot@ mu
    \box_use_clear:N \l_tmpa_box
   }
 }
\AtEndOfPackageFile * { mathtools }
 {
\AtEndOfPackageFile * { mathtools }
 {
    \cs_set_eq:NN \MToverbracket  \overbracket
    \cs_set_eq:NN \MTunderbracket \underbracket

    \AtBeginDocument
     {
      \msg_warning:nn { unicode-math } { mathtools-overbracket }

\def\downbracketfill#1#2
 {%
            \edef\l_MT_bracketheight_fdim{.27ex}%
            \downbracketend{#1}{#2}
            \leaders \vrule \@height #1 \@depth \z@ \hfill
            \downbracketend{#1}{#2}%
     }
\def\upbracketfill#1#2
 {%
            \edef\l_MT_bracketheight_fdim{.27ex}%
            \upbracketend{#1}{#2}
            \leaders \vrule \@height \z@ \@depth #1 \hfill
            \upbracketend{#1}{#2}%
     }
\let\Uoverbracket =\overbracket
\let\Uunderbracket=\underbracket
        \let\overbracket  =\MToverbracket
        \let\underbracket =\MTunderbracket
     }
 }
  \msg_warning:nn { unicode-math } { mathtools-colon }
  \NewDocumentCommand \dblcolon { } { \Colon }
  \NewDocumentCommand \coloneqq { } { \coloneq }
  \NewDocumentCommand \Coloneqq { } { \Coloneq }
  \NewDocumentCommand \eqqcolon { } { \eqcolon }
 }
\AtEndOfPackageFile * { colonequals }
 {
  \msg_warning:nn { unicode-math } { colonequals }
  \RenewDocumentCommand \ratio { } { \mathratio }
  \RenewDocumentCommand \coloncolon { } { \Colon }
  \RenewDocumentCommand \minuscolon { } { \dashcolon }
  \RenewDocumentCommand \colonequals { } { \coloneq }
  \RenewDocumentCommand \equalscolon { } { \eqcolon }
  \RenewDocumentCommand \coloncolonequals { } { \Coloneq }
 }
