%%
%% This is file `tipauni.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% tipauni.dtx  (with options: `package')
%% 
%% ---------------------------------------------------------------------------
%% Package:      tipauni
%% Author:       निरंजन
%% Description:  For producing Unicode characters with TIPA commands.
%% Repository:   https://git.gnu.org.ua/tipauni.git
%% Bug tracker:  https://puszcza.gnu.org.ua/bugs/?group=tipauni
%% License:      GPL v3.0+, GFDL 1.3+
%% ---------------------------------------------------------------------------
%% 
%% LaTeX Package tipauni v0.7a
%% Copyright © 2021, 2022, 2023 निरंजन
%% 
%% This program is free software: you can redistribute it and/or modify
%% it under the terms of the GNU General Public License as published by
%% the Free Software Foundation, either version 3 of the License, or
%% (at your option) any later version.
%% 
%% This program is distributed in the hope that it will be useful,
%% but WITHOUT ANY WARRANTY; without even the implied warranty of
%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
%% GNU General Public License for more details.
%% 
%% You should have received a copy of the GNU General Public License
%% along with this program. If not, see <https://www.gnu.org/licenses/>.
%% ---------------------------------------------------------------------------
%% 
\def\tipauniname{tipauni}
\def\tipauniversion{0.7a}
\def\tipaunidate{2023-02-13}
\def\tipaunidescription{For producing Unicode characters with TIPA commands}
\ProvidesPackage{tipauni}[2023/02/13 v0.7a
Unicode characters with TIPA commands]
\RequirePackage{xparse}
\RequirePackage{fontspec}
\RequirePackage{expkv-def,expkv-opt}
\newif\iftipauni@document@font
\def\tipauni@bookorregular{regular}
\def\tipauni@recommended@font{tipauni-newcm-\tipauni@bookorregular}
\tipauni@document@fonttrue
\let\tipauni@font@options\@empty
\ekvdefinekeys{tipauni}{%
  bool incompatible              = \iftipauni@nontipa@ignore,%
  noval preservefont             = {%
    \let\tipauni@font\tipauni@undefined
    \tipauni@document@fontfalse
  },%
  estore fontspecoptions         = \tipauni@font@options,%
  new noval fontspecoptions      = {%
    \PackageWarningNoLine{tipauni}{%
      As you haven't given any value to package option\MessageBreak
      `fontspecoptions'; it will be ignored. Please\MessageBreak
      provide a valid (list of) fontspec option(s)%
    }%
  },%
  noval resetfontspecoptions     = {%
    \let\tipauni@font@options\@empty
  },%
  noval documentfont             = {%
    \PackageError{tipauni}{No value for the `documentfont' option}{%
      The `documentfont' option has no value. Please provide a valid
      font-name,\MessageBreak otherwise it will be ignored or
      (if given) the value of another non-empty\MessageBreak
      `documentfont' will be used.%
    }%
    \ifdefined\tipauni@font
      \tipauni@document@fonttrue
    \else
      \tipauni@document@fontfalse
    \fi
  },%
  new code documentfont          = {%
    \edef\tipauni@temp{#1}%
    \ifx\tipauni@temp\@empty
      \PackageError{tipauni}{Empty `documentfont' option}{%
        The `documentfont' option has an empty value. Please provide a valid%
        \MessageBreak
        font-name, otherwise it will be ignored or (if given) the value of%
        \MessageBreak
        another non-empty `documentfont' will be used.%
      }%
      \ifdefined\tipauni@font
        \tipauni@document@fonttrue
      \else
        \tipauni@document@fontfalse
      \fi
    \else
      \tipauni@document@fonttrue
      \let\tipauni@font\tipauni@temp
    \fi
  },%
  noval recommendedfont          = {%
    \tipauni@document@fonttrue
    \let\tipauni@font\tipauni@recommended@font
  },%
  noval newcmbook                = {%
    \def\tipauni@bookorregular{book}%
  }%
}
\ekvoProcessLocalOptions{tipauni}
\iftipauni@document@font
  \ifdefined\tipauni@font
  \else
    \let\tipauni@font\tipauni@recommended@font
  \fi
  \expandafter\setmainfont\expandafter
  [\expandafter{\tipauni@font@options}]{\tipauni@font}
\else
  \ifx\tipauni@font@options\@empty
  \else
    \PackageWarningNoLine{tipauni}{%
      An active font loaded with package fontspec is\MessageBreak
      necessary for `fontspecoptions' to take effect.\MessageBreak
      Please use the `documentfont'/`recommendedfont'\MessageBreak
      option or load a font outside package `tipauni'\MessageBreak
      to make your options active. Currently ignoring:\MessageBreak
      [\tipauni@font@options]%
    }%
  \fi
\fi
\newif\ifnontipa
\protected\def\nontipatrue{\global\let\ifnontipa\iftrue}
\protected\def\nontipafalse{\global\let\ifnontipa\iffalse}
\iftipauni@nontipa@ignore
  \protected\def\nontipatrue{}
\fi
\NewDocumentCommand\tipaunicmd{ m m }{%
  \NewDocumentCommand#1{ }{\nontipatrue #2}%
}%
\AtEndDocument{%
  \ifnontipa
  \PackageWarningNoLine{tipauni}{%
    You have used a command(s) that is (are) not\MessageBreak
    supported by package TIPA. Thus your current code is\MessageBreak
    incompatible with that package. These commands are\MessageBreak
    printed with a different Unicode font. Refer to the\MessageBreak
    documentation of package tipauni for a list of\MessageBreak
    commands that are not supported in TIPA%
  }%
  \else
  \fi
}%
\DeclareTextCommand{\tipaunistar}{TU}[1]{{#1}}
\DeclareTextAccentDefault{\tipaunistar}{TU}
\DeclareTextCommand{\tipaunisemicolon}{TU}[1]{{#1}}
\DeclareTextAccentDefault{\tipaunisemicolon}{TU}
\DeclareTextCommand{\tipaunicolon}{TU}[1]{{#1}}
\DeclareTextAccentDefault{\tipaunicolon}{TU}
\DeclareTextCommand{\tipaunibang}{TU}[1]{{#1}}
\DeclareTextAccentDefault{\tipaunibang}{TU}
\DeclareTextCommand{\tipaunipipe}{TU}[2]{\@pipeshorthands{#1}{#2}}
\DeclareTextAccentDefault{\tipaunipipe}{TU}
%% Pulmonic consonants
%%-- Stops
%%--** Retroflex
\DeclareTextSymbol{\textrtailt}{TU}{"0288}%% ʈ
\DeclareTextComposite{\tipaunicolon}{TU}{t}{"288}
\DeclareTextSymbol{\textrtaild}{TU}{"0256}%% ɖ
\DeclareTextComposite{\tipaunicolon}{TU}{d}{"256}
%%--** Palatal
\DeclareTextSymbol{\textbardotlessj}{TU}{"25F}%% ɟ
\DeclareTextComposite{\tipaunistar}{TU}{j}{"25F}
%%--** Uvular
\DeclareTextSymbol{\textscg}{TU}{"262}%% ɢ
\DeclareTextComposite{\tipaunisemicolon}{TU}{G}{"262}
%%--** Glottal
\DeclareTextSymbol{\textglotstop}{TU}{"294}%% ʔ
%%-- Nasals
%%--** Labiodental
\DeclareTextSymbol{\textltailm}{TU}{"271}%% ɱ
%%--** Retroflex
\DeclareTextSymbol{\textrtailn}{TU}{"273}%% ɳ
\DeclareTextComposite{\tipaunicolon}{TU}{n}{"273}
%%--** Palatal
\DeclareTextSymbol{\textltailn}{TU}{"272}%% ɲ
\DeclareTextComposite{\tipaunistar}{TU}{n}{"272}
%%--** Uvular
\DeclareTextSymbol{\textscn}{TU}{"274}%% ɴ
\DeclareTextComposite{\tipaunisemicolon}{TU}{N}{"274}
%%-- Affricates
\DeclareTextSymbol{\textdzlig}{TU}{"02A3}%% ʣ
\DeclareTextSymbol{\textdyoghlig}{TU}{"02A4}%% ʤ
\DeclareTextSymbol{\texttslig}{TU}{"02A6}%% ʦ
\DeclareTextSymbol{\textteshlig}{TU}{"02A7}%% ʧ
\DeclareTextSymbol{\textdblig}{TU}{"02A4}%% ȸ
\DeclareTextSymbol{\textqplig}{TU}{"00239}%% ȹ
\DeclareTextSymbol{\texthvlig}{TU}{"0195}%% ƕ
\DeclareTextSymbol{\texttctclig}{TU}{"02A8}%% ʨ
%%-- Trills
%%--** Bilabial
\DeclareTextSymbol{\textscb}{TU}{"299}%% ʙ
\DeclareTextComposite{\tipaunisemicolon}{TU}{B}{"299}
%%--** Uvular
\DeclareTextSymbol{\textscr}{TU}{"280}%% ʀ
\DeclareTextComposite{\tipaunisemicolon}{TU}{R}{"280}
%%-- Taps or flaps
%%-- Labiodental flap
\tipaunicmd{\labdentflap}{ⱱ}%% tipauni-exclusive
\DeclareTextComposite{\tipaunistar}{TU}{v}{"2C71}%% tipauni-exclusive
%%--** Alveolar
\DeclareTextSymbol{\textfishhookr}{TU}{"27E}%% ɾ
%%--** Retroflex
\DeclareTextSymbol{\textrtailr}{TU}{"27D}%% ɽ
\DeclareTextComposite{\tipaunicolon}{TU}{r}{"27D}
%%-- Fricatives
%%--** Bilabial
\DeclareTextSymbol{\textphi}{TU}{"278}%% ɸ
\DeclareTextSymbol{\textbeta}{TU}{"3B2}%% β
%%--** Dental
\DeclareTextSymbol{\texttheta}{TU}{"3B8}%% θ
%%--** Postalveolar
\DeclareTextSymbol{\textesh}{TU}{"283}%% ʃ
\DeclareTextSymbol{\textyogh}{TU}{"292}%% ʒ
%%--** Retroflex
\DeclareTextSymbol{\textrtails}{TU}{"282}%% ʂ
\DeclareTextComposite{\tipaunicolon}{TU}{s}{"282}
\DeclareTextSymbol{\textrtailz}{TU}{"290}%% ʐ
\DeclareTextComposite{\tipaunicolon}{TU}{z}{"290}
%%--** Palatal
\DeclareTextSymbol{\textctj}{TU}{"29D}%% ʝ
%%--** Velar
\DeclareTextSymbol{\textgamma}{TU}{"263}%% ɣ
%%--** Uvular
\DeclareTextSymbol{\textchi}{TU}{"3C7}%% χ
\DeclareTextSymbol{\textinvscr}{TU}{"281}%% ʁ
%%--** Pharyngeal
\DeclareTextSymbol{\textcrh}{TU}{"127}%% ħ
\DeclareTextComposite{\tipaunistar}{TU}{h}{"127}
\DeclareTextSymbol{\textrevglotstop}{TU}{"295}%% ʕ
%%--** Glottal
\DeclareTextSymbol{\texthth}{TU}{"266}%% ɦ
%%-- Lateral fricatives
%%--** Alveolar
\DeclareTextSymbol{\textbeltl}{TU}{"26C}%% ɬ
\DeclareTextComposite{\tipaunistar}{TU}{l}{"26C}
\DeclareTextSymbol{\textlyoghlig}{TU}{"26E}%% ɮ
\DeclareTextComposite{\tipaunistar}{TU}{z}{"26E}
%%-- Approximants
%%-- Labiodental approximant
\tipaunicmd{\labdentapp}{ʋ}%% tipauni-exclusive
%%--** Alveolar
\DeclareTextSymbol{\textturnr}{TU}{"279}%% ɹ
\DeclareTextComposite{\tipaunistar}{TU}{r}{"279}
%%--** Retroflex
\DeclareTextSymbol{\textturnrrtail}{TU}{"27B}%% ɻ
\DeclareTextComposite{\tipaunicolon}{TU}{R}{"27B}
%%--** Velar
\DeclareTextSymbol{\textturnmrleg}{TU}{"270}%% ɰ
\DeclareTextComposite{\tipaunistar}{TU}{m}{"270}
%%-- Lateral approximants
%%--** Retroflex
\DeclareTextSymbol{\textrtaill}{TU}{"26D}%% ɭ
\DeclareTextComposite{\tipaunicolon}{TU}{l}{"26D}
\DeclareTextSymbol{\textturny}{TU}{"28E}%% ʎ
\DeclareTextSymbol{\textscl}{TU}{"29F}%% ʟ
\DeclareTextComposite{\tipaunisemicolon}{TU}{L}{"29F}
%% Non-pulmonic consonants
%%-- Clicks
%%--** Bilabial
\DeclareTextSymbol{\textbullseye}{TU}{"298}%% ʘ
\DeclareTextComposite{\tipaunibang}{TU}{o}{"298}
%%-- Postalveolar click
\tipaunicmd{\pstalvclick}{ǃ}%% tipauni-exclusive
%%--** Palato-alveolar
\DeclareTextSymbol{\textdoublebarpipe}{TU}{"1C2}%% ǂ
\DeclareTextComposite{\tipaunibang}{TU}{c}{"1C2}%% tipauni-exclusive
%%--** Alveolar lateral
\DeclareTextSymbol{\textdoublepipe}{TU}{"1C1}% ǁ
%%-- Implosives
%%--** Bilabial
\DeclareTextSymbol{\texthtb}{TU}{"253}%% ɓ
\DeclareTextComposite{\tipaunibang}{TU}{b}{"253}
%%--** Dental
\DeclareTextSymbol{\texthtd}{TU}{"257}%% ɗ
\DeclareTextComposite{\tipaunibang}{TU}{d}{"257}
%%--** Palatal
\DeclareTextSymbol{\texthtbardotlessj}{TU}{"284}%% ʄ
\DeclareTextComposite{\tipaunibang}{TU}{j}{"284}
%%--** Velar
\DeclareTextSymbol{\texthtg}{TU}{"260}%% ɠ
\DeclareTextComposite{\tipaunibang}{TU}{g}{"260}
%%--** Uvular
\DeclareTextSymbol{\texthtscg}{TU}{"29B}%% ʛ
\DeclareTextComposite{\tipaunibang}{TU}{G}{"29B}
%% Other consonants
\DeclareTextSymbol{\textturnw}{TU}{"28D}%% ʍ
\DeclareTextSymbol{\textturnh}{TU}{"265}%% ɥ
\DeclareTextSymbol{\textsch}{TU}{"29C}%% ʜ
\DeclareTextSymbol{\textbarrevglotstop}{TU}{"2A2}%% ʢ
\DeclareTextComposite{\tipaunistar}{TU}{1}{"2A2}%% tipauni-exclusive
\DeclareTextSymbol{\textbarglotstop}{TU}{"2A1}%% ʡ
\DeclareTextComposite{\tipaunistar}{TU}{2}{"2A1}%% tipauni-exclusive
\DeclareTextSymbol{\textctc}{TU}{"255}%% ɕ
\DeclareTextSymbol{\textctz}{TU}{"291}%% ʑ
\DeclareTextComposite{\tipaunistar}{TU}{Z}{"291}%% tipauni-exclusive
\DeclareTextSymbol{\textturnlonglegr}{TU}{"27A}%% ɺ
\DeclareTextComposite{\tipaunibang}{TU}{r}{"27A}%% tipauni-exclusive
\DeclareTextSymbol{\texththeng}{TU}{"267}%% ɧ
\DeclareTextComposite{\tipaunistar}{TU}{3}{"267}%% tipauni-exclusive
\DeclareTextComposite{\tipaunistar}{TU}{k}{"029E}% ʞ
\DeclareTextComposite{\tipaunistar}{TU}{t}{"287}% ʇ
\DeclareTextComposite{\tipaunistar}{TU}{w}{"28D}% ʍ
\DeclareTextComposite{\tipaunisemicolon}{TU}{E}{"1D07}% ᴇ
\DeclareTextComposite{\tipaunisemicolon}{TU}{J}{"1D0A}% ᴊ
\DeclareTextComposite{\tipaunisemicolon}{TU}{A}{"1D00}% ᴀ
\DeclareTextComposite{\tipaunisemicolon}{TU}{H}{"29C}% ʜ
\DeclareTextComposite{\tipaunisemicolon}{TU}{U}{"1D1C}% ᴜ
%% Vowels
\DeclareTextSymbol{\textsci}{TU}{"26A}%% ɪ
\DeclareTextSymbol{\textscy}{TU}{"28F}%% ʏ
\DeclareTextSymbol{\textepsilon}{TU}{"25B}%% ɛ
\DeclareTextSymbol{\textbari}{TU}{"268}%% ɨ
\DeclareTextSymbol{\textbaru}{TU}{"289}%% ʉ
\DeclareTextSymbol{\textupsilon}{TU}{"28A}%% ʊ
\DeclareTextSymbol{\textreve}{TU}{"258}%% ɘ
\DeclareTextSymbol{\textbaro}{TU}{"275}%% ɵ
\DeclareTextSymbol{\textschwa}{TU}{"259}%% ə
\DeclareTextSymbol{\textrevepsilon}{TU}{"25C}%% ɜ
\DeclareTextSymbol{\textcloserevepsilon}{TU}{"25E}%% ɞ
\DeclareTextSymbol{\textturna}{TU}{"250}%% ɐ
\DeclareTextSymbol{\textturnm}{TU}{"26F}%% ɯ
\DeclareTextSymbol{\textramshorns}{TU}{"264}%% ɤ
\DeclareTextSymbol{\textturnv}{TU}{"28C}%% ʌ
\DeclareTextSymbol{\textopeno}{TU}{"254}%% ɔ
\DeclareTextSymbol{\textscripta}{TU}{"251}%% ɑ
\DeclareTextSymbol{\textturnscripta}{TU}{"252}%% ɒ
%% Independent diacritic marks
%%-- Rhoticity
\DeclareTextSymbol{\textrhoticity}{TU}{"2DE}%% ˞
\tipaunicmd{\tr}{˞}
%%-- Tie bar (below)
\DeclareTextCommand{\tipaunitextbottomtiebar}{TU}[2]{#1\symbol{"035C}#2}
\NewDocumentCommand\textbottomtiebar{ m }{\tipaunitextbottomtiebar#1}
%%-- Tie bar (below) - standalone character
\DeclareTextCommand{\tipaunits}{TU}[2]{#1\symbol{"203F}#2}
\NewDocumentCommand\stdlnetiebar{ m }{\tipaunits#1}
\NewDocumentCommand\ts{ m }{\tipaunits#1}
%% No audible release
\DeclareTextSymbol{\textcorner}{TU}{"31A}%% ̚
\tipaunicmd{\tc}{̚}
%% Syllabic
\DeclareUnicodeAccent{\textsyllabic}{TU}{"0329}%% ̩
\NewDocumentCommand\s{ m }{\textsyllabic{\textipa{#1}}\nontipatrue}
%% Non-syllabic
\DeclareUnicodeAccent{\textsubarch}{TU}{"032F}%% ̯
\NewDocumentCommand\ns{ m }{\textsubarch{\textipa{#1}}}
%% Laminal
\DeclareUnicodeAccent{\textsubsquare}{TU}{"033B}%% ̻
\NewDocumentCommand\lmn{ m }{\textsubsquare{\textipa{#1}}\nontipatrue}
%% Other complex shorthand commands
\DeclareTextCommand{\@pipeshorthands}{TU}[2]{%
  \if #1[\tipaunisubbridge{\textipa{#2}}\else
  \if #1]\tipauniinvsubbridge{\textipa{#2}}\else
  \if #1(\tipaunisublhalfring{\textipa{#2}}\else
  \if #1)\tipaunisubrhalfring{\textipa{#2}}\else
  \if #1+\tipaunisubplus{\textipa{#2}}\else
  \if #1'\tipauniraising{\textipa{#2}}\else
  \if #1`\tipaunilowering{\textipa{#2}}\else
  \if #1<\tipauniadvancing{\textipa{#2}}\else
  \if #1>\tipauniretracting{\textipa{#2}}\else
  \if #1x\tipauniovercross{\textipa{#2}}\else
  \if #1m\tipauniseagull{\textipa{#2}}\else #1#2%
  \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
}%
\DeclareTextAccentDefault{\@pipeshorthands}{TU}
\ExplSyntaxOn
\NewDocumentCommand \super { m }
  {%
    \str_case:nn {#1}
      {
        {h} {ʰ}
        {w} {ʷ}
        {j} {ʲ}
        {ɣ} {ˠ}
        {ʕ} {ˤ}
        {n} {ⁿ}
        {l} {ˡ}
      }
  }
\seq_new:N \l__tipauni_remove_from_accents_seq
\tl_new:N \l__tipauni_textipa_tl
\seq_set_split:Nnn \l__tipauni_remove_from_accents_seq { , }
  { \~, \=, \", \r, \v, \t }
\iftipauni@nontipa@ignore
  \cs_new_eq:NN \__tipauni_nontipa_search: \prg_do_nothing:
  \cs_new_eq:NN \__tipauni_nontipa_search:n \use_none:n
\else
  \cs_new_protected:Npn \__tipauni_nontipa_search:
    {
      \unless\ifnontipa
        \exp_args:No \__tipauni_nontipa_search:n \l__tipauni_textipa_tl
      \fi
    }
  \cs_new_protected:Npn \__tipauni_nontipa_search:n #1
    {
      \str_if_in:nnT {#1} {ⱱ} { \nontipatrue \use_none_delimit_by_s_stop:w }
      \str_if_in:nnT {#1} {ɞ} { \nontipatrue \use_none_delimit_by_s_stop:w }
      \str_if_in:nnT {#1} {ɰ} { \nontipatrue \use_none_delimit_by_s_stop:w }
      \str_if_in:nnT {#1} {ǃ} { \nontipatrue \use_none_delimit_by_s_stop:w }
      \str_if_in:nnT {#1} {ǂ} { \nontipatrue \use_none_delimit_by_s_stop:w }
      \str_if_in:nnT {#1} {ʢ} { \nontipatrue \use_none_delimit_by_s_stop:w }
      \str_if_in:nnT {#1} {ɺ} { \nontipatrue \use_none_delimit_by_s_stop:w }
      \str_if_in:nnT {#1} {ʑ} { \nontipatrue \use_none_delimit_by_s_stop:w }
      \str_if_in:nnT {#1} {ɧ} { \nontipatrue \use_none_delimit_by_s_stop:w }
      \use_none:nnn \s_stop
      \use:n { \cs_gset_eq:NN \__tipauni_nontipa_search: \prg_do_nothing: }
    }
\fi
\NewDocumentCommand\textipa{ +m }%
  {
    \begingroup
      \let\*\tipaunistar
      \let\:\tipaunicolon
      \let\;\tipaunisemicolon
      \let\!\tipaunibang
      \let\|\tipaunipipe
      \let\t\tipaunit
      \seq_map_inline:Nn \l__tipauni_remove_from_accents_seq
      { \tl_remove_all:Nn \l_text_accents_tl {##1} }
      \tl_set:Nx \l__tipauni_textipa_tl { \text_expand:n {#1} }
      \use:x
        {
          \exp_not:n
            {
              \escapechar = `\\
              \tl_set:Nx \l__tipauni_textipa_tl
                { \exp_args:No \__tipauni_act:n \l__tipauni_textipa_tl }
              \escapechar =
            }
          \int_use:N \escapechar
        }
      \exp_stop_f:
      \l__tipauni_textipa_tl
      \__tipauni_nontipa_search:
    \endgroup
  }
\scan_new:N \s__tipauni_act_stop
\cs_new:Npn
\__tipauni_use_none_delimit_by_act_stop:w
#1
\s__tipauni_act_stop
{}
\cs_new:Npn
\__tipauni_act:n
#1
{ \__tipauni_act_loop:w #1 {\s__tipauni_act_stop} . \s__tipauni_act_stop }
\cs_new_eq:NN \__tipauni_act_output:n \exp_not:n
\cs_new:Npn \__tipauni_act_loop:w { \__tipauni_act_loop:Nnw \use_none:nn {} }
\cs_new:Npn \__tipauni_act_loop:Nnw #1#2#3 \s__tipauni_act_stop
  {
    \__tipauni_act_if_head_is_space:nTF {#3}
      { \__tipauni_act_space:Nnw }
      {
        \tl_if_head_is_group:nTF {#3}
          \__tipauni_act_group:Nnn
          \__tipauni_act_normal:NnN
      }
      #1 {#2} #3 \s__tipauni_act_stop
  }
\group_begin:
  \cs_set:Npn \__tipauni_tmp:n #1
    {
      \cs_new:Npn \__tipauni_act_if_head_is_space:nTF ##1
        {
          \__tipauni_act_if_head_is_space:w
            \s__tipauni_act_stop ##1 \s__tipauni_act_stop
            \__tipauni_act_if_head_is_space_true:w
            \s__tipauni_act_stop #1 \s__tipauni_act_stop
            \use_ii:nn
        }
      \cs_new:Npn \__tipauni_act_if_head_is_space:w
          ##1 \s__tipauni_act_stop #1 ##2 \s__tipauni_act_stop
        {}
      \cs_new:Npn \__tipauni_act_if_head_is_space_true:w
          \s__tipauni_act_stop #1 \s__tipauni_act_stop \use_ii:nn ##1 ##2
        {##1}
      \cs_new:Npn \__tipauni_act_space:Nnw ##1 ##2 #1
        {
          \token_if_eq_meaning:NNTF ##1 \__tipauni_act_macro:nn
            { \__tipauni_act_space_macro:nn ##2 }
            {
              \cs_if_exist_use:cTF {
                __tipauni_act_char_mono_
                \tl_to_str:n { ##2 } :
              }
                { \__tipauni_act_output:n {~} }
                { \__tipauni_act_output:n { ##2 ~ } }
              \__tipauni_act_loop:w
            }
        }
    }
  \__tipauni_tmp:n {~}
\group_end:
\cs_new:Npn \__tipauni_act_space_macro:nn #1#2
  { \__tipauni_act_loop:Nnw \__tipauni_act_macro:nn { {#1} { #2 ~ } } }
\cs_new:Npn \__tipauni_act_group:Nnn #1#2#3
  {
    \__tipauni_use_none_delimit_by_act_stop:w
      #3 \__tipauni_act_final:Nnw #1 {#2} \s__tipauni_act_stop
    \token_if_eq_meaning:NNTF #1 \__tipauni_act_macro:nn
      { \__tipauni_act_group_macro:nn {#2} {#3} }
      {
        \cs_if_exist_use:cF
        { __tipauni_act_char_mono_ \tl_to_str:n { #2 } : }
        { \__tipauni_act_output:n {#2} }
        {
          \__tipauni_act_loop:w
          #3
          {\s__tipauni_act_stop}
          .
          \s__tipauni_act_stop
        }
      }
    \__tipauni_act_loop:w
  }
\cs_new:Npn \__tipauni_act_final:Nnw
    #1#2 \s__tipauni_act_stop #3 \__tipauni_act_loop:w #4 \s__tipauni_act_stop
  {
    \cs_if_exist_use:cF { __tipauni_act_char_mono_ \tl_to_str:n { #2 } : }
      {
        \token_if_eq_meaning:NNTF #1 \__tipauni_act_macro:nn
          { \exp_args:No \__tipauni_act_output:n { \use:nn #2 } }
          { \__tipauni_act_output:n {#2} }
      }
  }
\cs_new:Npn \__tipauni_act_normal:NnN #1#2#3
  {
    \token_if_eq_meaning:NNTF #1 \use_none:nn
      {
        \cs_if_exist_use:cF { __tipauni_act_normal_ \tl_to_str:n {#3} :nw }
          { \__tipauni_act_output:n }
          {#3}
      }
      { #1 {#2} {#3} }
    \__tipauni_act_loop:w
  }
\cs_new:Npn \__tipauni_act_macro:nn #1#2
  {
    \cs_if_exist_use:cF
    {
      __tipauni_act_macro_
      \exp_args:No
      \tl_to_str:n {
        \use_i:nn #1 / #2
      }
      :
    }
    { \exp_args:No \__tipauni_act_output:n { \use:nn #1 #2 } }
  }
\cs_new:Npn \__tipauni_act_group_macro:nn #1#2
  {
    \cs_if_exist_use:cF
    {
      __tipauni_act_macro_
      \exp_args:No
      \tl_to_str:n {
        \use_i:nn #1 / #2
      }
      :
    }
    {
      \exp_args:No
      \__tipauni_act_output:n {
        \use:nn #1
      }
      {
        \__tipauni_act_loop:w
        #2
        {\s__tipauni_act_stop} . \s__tipauni_act_stop
      }
    }
  }
\cs_new:Npn \__tipauni_act_char:nn #1#2
  {
    \cs_if_exist_use:cF {
      __tipauni_act_char_bigraph_
      \tl_to_str:n
      { #1/#2 }
      :
    }
    {
      \cs_if_exist_use:cF {
        __tipauni_act_char_mono_
        \tl_to_str:n { #1 }
        :
      }
      { \__tipauni_act_output:n {#1} }
      \use_i:nn {
        \__tipauni_act_normal:NnN
        \use_none:nn {} {#2}
      }
    }
  }
\cs_new_protected:Npn \__tipauni_new_macro_pair_bigraph:NNNn #1#2#3#4
  {
    \__tipauni_new_macro_bigraph:NNn #1 #3 {#4}
    \__tipauni_new_macro_bigraph:NNn #2 #3 {#4}
  }
\cs_new_protected:Npn \__tipauni_new_macro_bigraph:NNn #1#2#3
  {
    \cs_gset:cpn {
      __tipauni_act_normal_
      \tl_to_str:n
      {#1}
      :nw
    }
    ##1##2
    \__tipauni_act_loop:w
    {
      \__tipauni_act_loop:Nnw
      \__tipauni_act_macro:nn
      { {##1} {} }
    }
    \cs_gset:cpn
    { __tipauni_act_macro_ \tl_to_str:n { #1/#2 } : }
    { \__tipauni_act_output:n {#3} }
  }
\cs_new_protected:Npn \__tipauni_new_char_bigraph:NNn #1#2#3
  {
    \cs_gset:cpn {
      __tipauni_act_normal_
      \tl_to_str:n
      {#1}
      :nw
    } ##1##2
    \__tipauni_act_loop:w
    {
      \__tipauni_act_loop:Nnw
      \__tipauni_act_char:nn {##1}
    }
    \cs_gset:cpn {
      __tipauni_act_char_bigraph_
      \tl_to_str:n { #1/#2 } :
    }
    { \__tipauni_act_output:n {#3} }
  }
\cs_new_protected:Npn \__tipauni_new_char_mono:Nn #1#2
  {
    \cs_gset:cpn {
      __tipauni_act_normal_
      \tl_to_str:n
      {#1}
      :nw
    } ##1##2
    \__tipauni_act_loop:w
    { \__tipauni_act_loop:Nnw
      \__tipauni_act_char:nn
      {##1}
    }
    \cs_gset:cpn
    { __tipauni_act_char_mono_
      \tl_to_str:n {#1} :
    }
    { \__tipauni_act_output:n {#2} }
  }
\__tipauni_new_macro_pair_bigraph:NNNn \! \tipaunibang      G {ʛ}
\__tipauni_new_macro_pair_bigraph:NNNn \! \tipaunibang      g {ɠ}
\__tipauni_new_macro_pair_bigraph:NNNn \* \tipaunistar      1 {ʢ}
\__tipauni_new_macro_pair_bigraph:NNNn \* \tipaunistar      2 {ʡ}
\__tipauni_new_macro_pair_bigraph:NNNn \* \tipaunistar      3 {ɧ}
\__tipauni_new_macro_pair_bigraph:NNNn \* \tipaunistar      Z {ʑ}
\__tipauni_new_macro_pair_bigraph:NNNn \: \tipaunicolon     R {ɻ}
\__tipauni_new_macro_pair_bigraph:NNNn \; \tipaunisemicolon A {ᴀ}
\__tipauni_new_macro_pair_bigraph:NNNn \; \tipaunisemicolon G {ɢ}
\__tipauni_new_macro_pair_bigraph:NNNn \; \tipaunisemicolon B {ʙ}
\__tipauni_new_macro_pair_bigraph:NNNn \; \tipaunisemicolon E {ᴇ}
\__tipauni_new_macro_pair_bigraph:NNNn \; \tipaunisemicolon H {ʜ}
\__tipauni_new_macro_pair_bigraph:NNNn \; \tipaunisemicolon J {ᴊ}
\__tipauni_new_macro_pair_bigraph:NNNn \; \tipaunisemicolon L {ʟ}
\__tipauni_new_macro_pair_bigraph:NNNn \; \tipaunisemicolon N {ɴ}
\__tipauni_new_macro_pair_bigraph:NNNn \; \tipaunisemicolon R {ʀ}
\__tipauni_new_macro_pair_bigraph:NNNn \; \tipaunisemicolon U {ᴜ}
\__tipauni_new_char_bigraph:NNn || {ǁ}
\__tipauni_new_char_bigraph:NNn "" {ˌ}
\clist_map_inline:nn
  {
    {5}{ɐ}, {A}{ɑ}, {6}{ɒ}, {2}{ʌ}, {B}{β}, {C}{ɕ}, {D}{ð}, {9}{ɘ}, {E}{ɛ},
    {3}{ɜ}, {g}{ɡ}, {G}{ɣ}, {7}{ɤ}, {H}{ɦ}, {L}{ʎ}, {4}{ɥ}, {1}{ɨ}, {I}{ɪ},
    {J}{ʝ}, {M}{ɱ}, {W}{ɯ}, {N}{ŋ}, {8}{ɵ}, {O}{ɔ}, {F}{ɸ}, {R}{ɾ}, {K}{ʁ},
    {S}{ʃ}, {T}{θ}, {0}{ʉ}, {U}{ʊ}, {V}{ʋ}, {X}{χ}, {Y}{ʏ}, {Z}{ʒ},
    {P}{ʔ}, {Q}{ʕ},
    {:}{ː}, {;}{ˑ}, {!}{ǃ}, {&}{ɞ}, {@}{ə}, {|}{ǀ}, {"}{ˈ}
  }
  { \__tipauni_new_char_mono:Nn #1 }
\ExplSyntaxOff
%%-- Dependent diacritic marks
%%--** Voiceless
\DeclareUnicodeAccent{\textsupring}{TU}{"030A}%% ̊
\DeclareUnicodeAccent{\textsubring}{TU}{"0325}%% ̥
\DeclareTextCommand{\r}{TU}{\tipauniring}
\protected\def\tipauniring{\@ifstar{\TipaUniSubRing}{\TipaUniSupRing}}
\NewDocumentCommand\TipaUniSupRing{ m }{\textsupring{\textipa{#1}}}
\NewDocumentCommand\TipaUniSubRing{ m }{\textsubring{\textipa{#1}}}
%%--** Voiced
\DeclareUnicodeAccent{\textsupwedge}{TU}{"030C}%% ̌
\DeclareUnicodeAccent{\textsubwedge}{TU}{"032C}%% ̬
\DeclareTextCommand{\v}{TU}{\tipauniwedge}
\protected\def\tipauniwedge{\@ifstar{\TipaUniSubWedge}{\TipaUniSupWedge}}
\NewDocumentCommand\TipaUniSupWedge{ m }{\textsupwedge{\textipa{#1}}}
\NewDocumentCommand\TipaUniSubWedge{ m }{\textsubwedge{\textipa{#1}}}
%%--** More rounded
\DeclareUnicodeAccent{\textsubrhalfring}{TU}{"0339}%% ̹
\NewDocumentCommand\tipaunisubrhalfring{ m }{\textsubrhalfring{\textipa{#1}}}
%%--** Less rounded
\DeclareUnicodeAccent{\textsublhalfring}{TU}{"031C}%% ̜
\NewDocumentCommand\tipaunisublhalfring{ m }{\textsublhalfring{\textipa{#1}}}
%%--** Advanced
\DeclareUnicodeAccent{\textsubplus}{TU}{"031F}%% ̟
\NewDocumentCommand\tipaunisubplus{ m }{\textsubplus{\textipa{#1}}}
%%--** Retracted
\DeclareUnicodeAccent{\textsupbar}{TU}{"0304}%% ̄
\DeclareUnicodeAccent{\textsubbar}{TU}{"0320}%% ̠
\DeclareTextCommand{\=}{TU}{\tipaunibar}
\protected\def\tipaunibar{\@ifstar{\TipaUniSubBar}{\TipaUniSupBar}}
\NewDocumentCommand\TipaUniSupBar{ m }{\textsupbar{\textipa{#1}}}
\NewDocumentCommand\TipaUniSubBar{ m }{\textsubbar{\textipa{#1}}}
%%--** Mid-centralized
\DeclareUnicodeAccent{\textovercross}{TU}{"033D}%% ̽
\NewDocumentCommand\tipauniovercross{ m }{\textovercross{\textipa{#1}}}
%%--** Breathy voiced
\DeclareUnicodeAccent{\textsupumlaut}{TU}{"0308}%% ̈
\DeclareUnicodeAccent{\textsubumlaut}{TU}{"0324}%% ̤
\DeclareTextCommand{\"}{TU}{\tipauniumlaut}
\protected\def\tipauniumlaut{\@ifstar{\TipaUniSubUmlaut}{\TipaUniSupUmlaut}}
\NewDocumentCommand\TipaUniSupUmlaut{ m }{\textsupumlaut{\textipa{#1}}}
\NewDocumentCommand\TipaUniSubUmlaut{ m }{\textsubumlaut{\textipa{#1}}}
%%--** Creaky voiced
\DeclareUnicodeAccent{\textsuptilde}{TU}{"0303}%% ̃
\DeclareUnicodeAccent{\textsubtilde}{TU}{"0330}%% ̰
\DeclareTextCommand{\~}{TU}{\tipaunitilde}
\protected\def\tipaunitilde{\@ifstar{\TipaUniSubTilde}{\TipaUniSupTilde}}
\NewDocumentCommand\TipaUniSupTilde{ m }{\textsuptilde{\textipa{#1}}}
\NewDocumentCommand\TipaUniSubTilde{ m }{\textsubtilde{\textipa{#1}}}
%%--** Linguo-labialized
\DeclareUnicodeAccent{\textseagull}{TU}{"033C}%% ̼
\NewDocumentCommand\tipauniseagull{ m }{\textseagull{#1}}
%%--** Velarized
\DeclareUnicodeAccent{\textsuperimposetilde}{TU}{"0334}%% ̴
\NewDocumentCommand\tipaunisuperimposetilde{ m }{\textsuperimposetilde{#1}}
\NewDocumentCommand\vl{ m }{\textsuperimposetilde{\textipa{#1}}}
%%--** Raised
\DeclareUnicodeAccent{\textraising}{TU}{"031D}%% ̝
\NewDocumentCommand{\tipauniraising}{m}{\textraising{#1}}
%%--** Lowered
\DeclareUnicodeAccent{\textlowering}{TU}{"031E}%% ̞
\NewDocumentCommand{\tipaunilowering}{m}{\textlowering{#1}}
%%%--** Advanced tongue root
\DeclareUnicodeAccent{\textadvancing}{TU}{"0318}%% ̘
\NewDocumentCommand{\tipauniadvancing}{m}{\textadvancing{#1}}
%%--** Retracted tongue root
\DeclareUnicodeAccent{\textretracting}{TU}{"0319}%% ̙
\NewDocumentCommand{\tipauniretracting}{m}{\textretracting{#1}}
%%--** Dental
\DeclareUnicodeAccent{\textsubbridge}{TU}{"032A}%% ̪
\NewDocumentCommand\tipaunisubbridge{ m }{\textsubbridge{#1}}
%%--** Apical
\DeclareUnicodeAccent{\textinvsubbridge}{TU}{"033A}%% ̺
\NewDocumentCommand\tipauniinvsubbridge{ m }{\textinvsubbridge{#1}}
%%--** Tie bar (above)
\DeclareTextCommand{\tipaunitexttoptiebar}{TU}[2]{#1\symbol{"0361}#2}
\NewDocumentCommand\texttoptiebar{ m }{\tipaunitexttoptiebar#1}
\DeclareTextCommand{\tipaunit}{TU}{%
  \@ifstar{\textbottomtiebar}{\texttoptiebar}%
}
\NewDocumentEnvironment{IPA}{+b}{\textipa{#1}}{}
\endinput
%%
%% End of file `tipauni.sty'.
