%% This file is luabidi-footnotes.def
%% This is part of the luabidi package
%%
%% Copyright © 2009 Vafa Khalighi, 2013--2019 Arthur Reutenauer, 2019 Jürgen Spitzmüller
%%
%%%% It may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3c
%% of this license or (at your option) any later version.

%
% Footnotes
%

% These are defined in polyglossia. Provide simple fallbacks
\providecommand*\localnumeral{\@ifstar\@@localnumeral\@localnumeral}

\providecommand*\@localnumeral[1]{#1}
\providecommand*\@@localnumeral[1]{%
      \protect\@arabic\csuse{c@#1}%
}

\let\footnotemarkLR\footnotemark
\let\footnotemarkRL\footnotemark

\providecommand\LTRfootnote[2][]{%
  \begingroup
    \ifx#1\\\\\footnotemarkLR
        \renewcommand{\thefootnote}{\localnumeral*{footnote}}%
    \else%
        \footnotemarkLR[#1]%
        \renewcommand{\thefootnote}{\localnumeral{#1}}%
    \fi
    \pardir TLT \textdir TLT\footnotetext{#2}%
  \endgroup
}

\providecommand\RTLfootnote[2][]{%
  \begingroup
    \ifx#1\\\\\footnotemarkRL%
       \renewcommand{\thefootnote}{\localnumeral*{footnote}}%
    \else%
       \footnotemarkRL[#1]%
       \renewcommand{\thefootnote}{\localnumeral{#1}}%
    \fi
    \pardir TRT \textdir TRT\footnotetext{#2}%
  \endgroup
}

% backwards compatibility
\def\Footnote#1{\LTRfootnote{#1}}

%
% Footnote rules
%

% adjustable rule length
\newlength\footnoterulewidth
\setlength\footnoterulewidth{.4\columnwidth}

% The left, right and full width rules
\def\luabidi@left@fn{%
  \hbox to \columnwidth
  {\pagedir TLT\textdir TLT\vbox{\kern -3\p@
   \hrule\@width\footnoterulewidth\kern2.6\p@}\hfil}}
\def\luabidi@right@fn{%
   \pagedir TRT\textdir TRT\hrule\@width\footnoterulewidth\kern2.6\p@}
\def\luabidi@textwidth@fn{%
   \kern-3\p@\hrule\@width\textwidth\kern2.6\p@}

% switches for the rule position
\def\leftfootnoterule{\global\def\footnoterule{\luabidi@left@fn}}
\def\rightfootnoterule{\global\def\footnoterule{\luabidi@right@fn}}
\def\textwidthfootnoterule{\global\def\footnoterule{\luabidi@textwidth@fn}}
\def\autofootnoterule{\luabidi@autofootnoteruletrue}

% Finis
