%%
%% This is file `floatrowbytocbasic.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% floatrowbytocbasic.dtx  (with options: `package')
%% 
%% IMPORTANT NOTICE:
%% 
%% For the copyright see the source file.
%% 
%% Any modified versions of this file must be renamed
%% with new filenames distinct from floatrowbytocbasic.sty.
%% 
%% For distribution of the original source see the terms
%% for copying and modification in the file floatrowbytocbasic.dtx.
%% 
%% This generated file may be distributed as long as the
%% original source files, as listed above, are part of the
%% same distribution. (The sources need not necessarily be
%% in the same archive or directory.)
\ProvidesPackage{floatrowbytocbasic}
             [2023-08-16 v1.0
              improved floatrow package using tocbasic]
\RequirePackage{tocbasic}[2023/07/07]
\RequirePackage{floatrow}
\RequirePackage{xpatch}
\@ifundefined{ExplSyntaxOn}{%
  \RequirePackage{expl3}%
}{}
\@ifundefined{NewCommandCopy}{\let\DeclareFloatType\DeclareNewFloatType}{%
  \NewCommandCopy\DeclareFloatType\DeclareNewFloatType
}
\newcommand*{\floatrowbytocbasic@incompatibility@error}[1]{%
  \PackageError{floatrowbytocbasic}{incompatible definition of
    \expandafter\string\csname #1\endcsname}{%
    Package `floatrowbytocbasic' depends on the original definition of
    package\MessageBreal
    `floatrow'.\MessageBreak
    Some changes to that definition are tolerated.\MessageBreak
    \@ifundefined{#1}%
    {But it seems the definition is completely missing!}%
    {But the current definition is incompatible!}%
    \MessageBreak
    Make sure, you have installed the original package `floatrow' as
    referred\MessageBreak
    by section ``References'' of the manual.%
  }%
}
\xpatchcmd{\DeclareFloatType}{%
  \xdef\@tempa{\noexpand\flrow@types{\the\flrow@types \FR@tmp{#1}}}%
  \@tempa
}{%
  \Ifattoclist{\@nameuse{ext@\FB@captype}}{%
    \let\reserved@a\relax
    \owneroftoc[\def\reserved@a]{\@nameuse{ext@\FB@captype}}\relax
    \@ifundefined{reserved@a}{}{%
      \Ifstr{\reserved@a}{float}{%
        \PackageInfo{floarowtbytocbasic}{%
          reusing file extension `\@nameuse{ext@\FB@captype}' for\MessageBreak
          float type `#1'%
        }%
      }{%
        \PackageWarning{floatrowbytocbasic}{%
          reusing file extension `\@nameuse{ext@\FB@captype}' of owner\MessageBreak
          `\reserved@a' for float `#1'\MessageBreak
          not recommended%
        }%
      }%
    }%
  }{%
    \addtotoclist[float]{\@nameuse{ext@\FB@captype}}%
  }%
  \xdef\@tempa{\noexpand\flrow@types{\the\flrow@types \FR@tmp{#1}}}%
  \@tempa
}{}{%
  \floatrowbytocbasic@incompatibility@error{DeclareNewFloatType}%
}
\xpatchcmd{\DeclareFloatType}{%
  \newcounter{#1}%
}{%
  \@ifundefined{c@#1}{\newcounter{#1}}{%
    \PackageInfo{floatrowbytocbasic}{%
      reusing existing counter for float type `#1'%
    }%
  }%
}{}{%
  \floatrowbytocbasic@incompatibility@error{DeclareNewFloatType}%
}
\xpatchcmd{\DeclareFloatType}{%
  \@namedef{l@#1}{\@dottedtocline{1}{1.5em}{2.3em}}%
}{%
  \@ifundefined{l@#1}{\expandafter\let\csname l@#1\endcsname\l@figure
    \@ifundefined{l@#1}{%
      \DeclareTOCStyleEntry[level=1,numwith=2.3em,indent=1.5em]{default}{#1}%
    }{}%
  }{}%
}{}{%
  \floatrowbytocbasic@incompatibility@error{DeclareNewFloatType}%
}
\renewcommand{\DeclareNewFloatType}[2]{%
  \floatrowbytocbasic@get@currext{#1}{#2}%
  \@tempswatrue
  \begingroup
    \def\FR@tmp##1{%
      \Ifstr{#1}{##1}{\aftergroup\@tempswafalse}{}%
    }%
    \the\flrow@types
  \endgroup
  \if@tempswa
    \expandafter\@ifdefinable\csname #1\endcsname {%
      \Ifattoclist{\floatrowbytocbasic@currext}{%
        \let\reserved@a\relax
        \owneroftoc[\def\reserved@a]{\floatrowbytocbasic@currext}\relax
        \@ifundefined{reserved@a}{%
          \DeclareFloatType{#1}{#2}%
        }{%
          \Ifstr{\reserved@a}{float}{%
            \PackageInfo{floatrowbytocbasic}{%
              reusing `\floatrowbytocbasic@currext' of owner `float'%
            }%
            \DeclareFloatType{#1}{#2}%
          }{%
            \PackageError{floatrowbytocbasic}{%
              reusing `\floatrowbytocbasic@currext' of owner `\reserved@a' not
              allowed%
            }{%
              Each file extension should be used only once.\MessageBreak
              Reusing is only allowed with the same owner/category.\MessageBreak
              You, the class, or another package already uses
              `\floatrowbytocbasic@currext'.\MessageBreak
              \@eha
            }%
          }%
        }%
      }{%
        \DeclareFloatType{#1}{#2}%
      }%
    }%
  \else
    \PackageError{floatrowbytocbasic}{Float `#1' already defined}{%
      Each float can be defined only once using
      \string\DeclareNewFloatType.\MessageBreak
      If you want to redefine an already existing float, please
      use\MessageBreak
      \string\RedeclareFloatType.\MessageBreak
      \@eha
    }%
  \fi
}
\newcommand{\ProvideFloatType}[2]{%
  \@ifundefined{#1}{%
    \@tempswatrue
    \begingroup
      \def\FR@tmp##1{%
        \Ifstr{#1}{##1}{\aftergroup\@tempswafalse}{}%
      }%
      \the\flrow@types
    \endgroup
    \if@tempswa
      \DeclareNewFloatType{#1}{#2}%
    \fi
  }{}%
}
\newcommand{\RedeclareFloatType}[2]{%
  \@tempswafalse
  \@ifundefined{#1}{%
    \begingroup
      \def\FR@tmp##1{%
        \Ifstr{#1}{##1}{\aftergroup\@tempswatrue}{}%
      }%
      \the\flrow@types
    \endgroup
  }{\@tempswatrue}%
  \floatrowbytocbasic@get@currext{#1}{#2}%
  \if@tempswa
    \Ifattoclist{\floatrowbytocbasic@currext}{%
      \removefromtoclist{\floatrowbytocbasic@currext}%
    }{%
      \PackageError{floatrowbytocbasic}{%
        extension `\floatrowbytocbasic@currext' not yet registered%
      }{%
        I can only renew floats with already registered
        extensions.\MessageBreak
        \@ehc
      }%
    }%
  \else
    \@latex@error{Environment #1 undefined}\@ehc
    \removefromtoclist{\floatrowbytocbasic@currext}%
  \fi
  \DeclareFloatType{#1}{#2}%
}
\ExplSyntaxOn
\prop_new:N \__floatrowbytocbasic_DeclareNewFloatType_prop
\tl_new:N \__floatrowbytocbasic_ext_tl
\cs_new:Nn \__floatrowbytocbasic_get_ext_from_prop:nn
  {
    \prop_set_from_keyval:Nn \__floatrowbytocbasic_DeclareNewFloatType_prop { #2 }
    \prop_get:NnN \__floatrowbytocbasic_DeclareNewFloatType_prop { fileext } \__floatrowbytocbasic_ext_tl
    \quark_if_no_value:NT \__floatrowbytocbasic_ext_tl
      {
        \tl_set:Nn \__floatrowbytocbasic_ext_tl { lo#1 }
      }
  }
\newcommand*{\floatrowbytocbasic@get@currext}[2]{%
  \__floatrowbytocbasic_get_ext_from_prop:nn { #1 } { #2 }
  \let\floatrowbytocbasic@currext\__floatrowbytocbasic_ext_tl
}
\ExplSyntaxOff
\renewcommand*{\listof}[2]{%
  \@ifundefined{ext@#1}{\flrow@error{Unknown float style `#1'}}{%
    \@ifundefined{l@#1}{\expandafter\let\csname l@#1\endcsname\l@figure
      \@ifundefined{l@#1}{%
        \DeclareTOCStyleEntry[level=1,numwidth=2.3em,indent=1.5em]
        {default}{#1}%
      }{}%
    }{}%
    \listoftoc[{#2}]{\csname ext@#1\endcsname}%
  }%
}%
\endinput
%%
%% End of file `floatrowbytocbasic.sty'.
