%%
%% This is file `bkm-dvipdfm.def',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% bookmark.dtx  (with options: `dvipdfm')
%% 
%% This is a generated file.
%% 
%% Project: bookmark
%% Version: 2023-12-10 v1.31
%% 
%% Copyright (C)
%%    2007-2011 Heiko Oberdiek
%%    2016-2023 Oberdiek Package Support Group
%% 
%% This work 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. This version of this license is in
%%    https://www.latex-project.org/lppl/lppl-1-3c.txt
%% and the latest version of this license is in
%%    https://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of
%% LaTeX version 2005/12/01 or later.
%% 
%% This work has the LPPL maintenance status "maintained".
%% 
%% The Current Maintainers of this work are
%% Heiko Oberdiek and the Oberdiek Package Support Group
%% https://github.com/ho-tex/bookmark/issues
%% 
%% This file is part of the "bookmark bundle" (The Work in LPPL)
%%  and all files in that bundle must be distributed together.
%% 
%%  The released version of this bundle is available from CTAN.
%% 
%%  This work consists of the main source files bookmark.dtx
%%  and bookmark.ins and the derived files
%%     bookmark.sty, bookmark.pdf,
%%     bkm-dvipdfm.def, bkm-dvips.def, bkm-pdftex.def, bkm-vtex.def,
%%     bookmark-example.tex.
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile{bkm-dvipdfm.def}%
  [2023-12-10 v1.31 bookmark driver for dvipdfm (HO)]%
\newcount\BKM@id
\BKM@id=\z@
\@namedef{BKM@0}{000}
\newif\ifBKM@sw
\newcommand\BKM@struct@dest{}
\ExplSyntaxOn
\IfDocumentMetadataTF
  {
    \tag_if_active:T
     {
       \def\BKM@struct@dest{/SD~@pdf.SDest.\BKM@dest}
     }

  }{}
\ExplSyntaxOff
\newcommand*{\bookmark}[2][]{%
  \if@filesw
    \begingroup
      \def\bookmark@text{#2}%
      \BKM@setup{#1}%
      \edef\BKM@prev{\the\BKM@id}%
      \global\advance\BKM@id\@ne
      \BKM@swtrue
      \@whilesw\ifBKM@sw\fi{%
        \def\BKM@abslevel{1}%
        \ifnum\ifBKM@startatroot\z@\else\BKM@prev\fi=\z@
          \BKM@startatrootfalse
          \expandafter\xdef\csname BKM@\the\BKM@id\endcsname{%
            0{\BKM@level}\BKM@abslevel
          }%
          \BKM@swfalse
        \else
          \expandafter\expandafter\expandafter\BKM@getx
              \csname BKM@\BKM@prev\endcsname
          \ifnum\BKM@level>\BKM@x@level\relax
            \BKM@CalcExpr\BKM@abslevel\BKM@x@abslevel+1%
            \expandafter\xdef\csname BKM@\the\BKM@id\endcsname{%
              {\BKM@prev}{\BKM@level}\BKM@abslevel
            }%
            \BKM@swfalse
          \else
            \let\BKM@prev\BKM@x@parent
          \fi
        \fi
      }%
      \csname HyPsd@XeTeXBigCharstrue\endcsname
      \pdfstringdef\BKM@title{\bookmark@text}%
      \edef\BKM@FLAGS{\BKM@PrintStyle}%
      \let\BKM@action\@empty
      \ifx\BKM@gotor\@empty
        \ifx\BKM@dest\@empty
          \ifx\BKM@named\@empty
            \ifx\BKM@rawaction\@empty
              \ifx\BKM@uri\@empty
                \ifx\BKM@page\@empty
                  \PackageError{bookmark}{Missing action}\@ehc
                  \edef\BKM@action{/Dest[@page1/Fit]}%
                \else
                  \ifx\BKM@view\@empty
                    \def\BKM@view{Fit}%
                  \fi
                  \edef\BKM@action{/Dest[@page\BKM@page/\BKM@view]}%
                \fi
              \else
                \BKM@EscapeString\BKM@uri
                \edef\BKM@action{%
                  /A<<%
                    /S/URI%
                    /URI(\BKM@uri)%
                  >>%
                }%
              \fi
            \else
              \edef\BKM@action{/A<<\BKM@rawaction>>}%
            \fi
          \else
            \BKM@EscapeName\BKM@named
            \edef\BKM@action{%
              /A<</S/Named/N/\BKM@named>>%
            }%
          \fi
        \else
          \BKM@EscapeString\BKM@dest
          \edef\BKM@action{%
            /A<<%
              /S/GoTo%
              /D(\BKM@dest)%
              \BKM@struct@dest
            >>%
          }%
        \fi
      \else
        \ifx\BKM@dest\@empty
          \ifx\BKM@page\@empty
            \def\BKM@page{0}%
          \else
            \BKM@CalcExpr\BKM@page\BKM@page-1%
          \fi
          \ifx\BKM@view\@empty
            \def\BKM@view{Fit}%
          \fi
          \edef\BKM@action{/D[\BKM@page/\BKM@view]}%
        \else
          \BKM@EscapeString\BKM@dest
          \edef\BKM@action{/D(\BKM@dest)}%
        \fi
        \BKM@EscapeString\BKM@gotor
        \edef\BKM@action{%
          /A<<%
            /S/GoToR%
            /F(\BKM@gotor)%
            \BKM@action
          >>%
        }%
      \fi
      \special{pdf:%
        out
              [%
              \ifBKM@open
                \ifnum\BKM@level<%
                    \expandafter\@firstofone\expandafter
                    {\number\BKM@openlevel} %
                \else
                  -%
                \fi
              \else
                -%
              \fi
              ] %
            \BKM@abslevel
        <<%
          /Title(\BKM@title)%
          \ifx\BKM@color\@empty
          \else
            /C[\BKM@color]%
          \fi
          \ifnum\BKM@FLAGS>\z@
            /F \BKM@FLAGS
          \fi
          \BKM@action
        >>%
      }%
    \endgroup
  \fi
}
\def\BKM@getx#1#2#3{%
  \def\BKM@x@parent{#1}%
  \def\BKM@x@level{#2}%
  \def\BKM@x@abslevel{#3}%
}
\ifBKM@atend
  \AddToHook{shipout/lastpage}{\BKM@EndHook}%
\fi

\endinput
%%
%% End of file `bkm-dvipdfm.def'.
