% Copyright 2024 by Qrrbrbirlbel
%
% This file may be distributed and/or modified
%
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Free Documentation License.
%

\def\tikzextversion{0.6.2}
\def\tikzextversionnumber{10}
\def\tikzextset{\pgfqkeys{/tikz/ext}}
\def\pgfextset{\pgfqkeys{/pgf/ext}}
\pgfextset{
  pgf/.code=\pgfset{#1},
  .code=\pgfextset{#1}%
}
\tikzextset{
  tikz/.code=\tikzset{#1},
  .code=\tikzextset{#1},
  .unknown/.code={%
    \pgfextset{\pgfkeyscurrentname/.try={#1}}%
    \unless\ifpgfkeyssuccess
      \pgfutil@packageerror{tikz-ext}{%
        I neither know '/tikz/ext/\pgfkeyscurrentname' nor
        '/pgf/ext/\pgfkeyscurrentname' to which you passed '#1'.%
      }%
    \fi
  },
  /pgfplots/ext/.code=\tikzextset{#1},
  /pgfplots/ext/.unknown/.code={%
    \tikzextset{\pgfkeyscurrentname={#1}}%
  }
}
% Compatibility
\gdef\tikzextutil@compatwarning@counter{0}
\def\tikzextutil@compatmaybewarning#1#2#3{%
  \ifnum\tikzextutil@compatwarning@counter<25
    \xdef\tikzextutil@compatwarning@counter{\the\numexpr\tikzextutil@compatwarning@counter+1\relax}%
    \pgfutil@packagewarning{tikz-ext}{%
      The deprecated #1 was used. It is now #2. Please use that instead.^^J%
      To remove this warning use \string\tikzextset\string{compat/#3\string}.^^J%
      This warning will be removed in the next version and the #1 will fail.^^J%
    }%
  \else\ifnum\tikzextutil@compatwarning@counter=25
    \gdef\tikzextutil@compatwarning@counter{26}%
    \pgfutil@packagewarning{tikz-ext}{Too many warnings generated. Remain silent.}%
  \fi\fi
}
\def\tikzextutil@compatwarning@cmd#1#2#3#4#5{%
  \pgfutil@IfUndefined{#3}{%
    \pgfutil@namedef{#3}{%
      \tikzextutil@compatmaybewarning
        {command \expandafter\pgfutil@gobble\string\\#3}{\string#4}{#1 = #2}%
      #4%
    }%
  }{}%
}
\def\tikzextutil@compatwarning@key#1#2#3{%
  \pgfutil@ifnextchar[%
    {\tikzextutil@compatwarning@key@opt{#1}{#2}{#3}}%
    {\tikzextutil@compatwarning@key@   {#1}{#2}{#3}{}}%
}
\def\tikzextutil@compatwarning@key@opt#1#2#3[#4]{%
  \tikzextutil@compatwarning@key@{#1}{#2}{#3}{\pgfkeyssetvalue{#3/.@def}{#4}}%
}
\def\tikzextutil@compatwarning@key@#1#2#3#4#5{%
  \pgfkeys@pathtoks{#3}%
  \pgfkeysifdefined{#3}{%
    % The key is a value key. Do not overwrite or adjust.
    % Old TikZ-Ext key simply will not work.
  }{%
    \pgfkeysifdefined{#3/.@cmd}{%
      % The key is a code key. Do not overwrite or adjust.
      % Old TikZ-Ext key simply will not work.
    }{%
      % The key is currently not used.
      #4%
      \pgfkeysdef{#3}{%
        \tikzextutil@compatmaybewarning{key '#3'}{'#5'}{#1 = #2}%
        \pgfkeysvalueof{#5/.@cmd}##1\pgfeov
      }%
    }
  }
}
\def\tikzextutil@compatwarning@valuekey#1#2#3#4{%
  \pgfkeys@pathtoks{#3}%
  \pgfkeysifdefined{#3}{%
    % The key is a value key. Do not overwrite or adjust.
    % Old TikZ-Ext key simply will not work.
  }{%
    \pgfkeysifdefined{#3/.@cmd}{%
      % The key is a code key. Do not overwrite or adjust.
      % Old TikZ-Ext key simply will not work.
    }{%
      % The key is currently not used.
      \pgfkeyssetvalue{#3}{\pgfkeysvalueof{#4}}%
      \pgfkeysdef{#3}{%
        \tikzextutil@compatmaybewarning{value-key '#3'}{'#4'}{#1 = #2}%
        \pgfkeyssetvalue{#4}{##1}%
      }%
    }
  }
}
\def\tikzextutil@compatwarning@mathcmdZ#1#2#3#4{%
  \pgfutil@IfUndefined{pgfmath#3}{%
    \pgfmathdeclarefunction*{#3}{0}{%
      \tikzextutil@compatmaybewarning{PGFMath function '#3'}{'#4'}{#1 = #2}%
      \csname pgfmath#4@\endcsname
    }%
  }{}%
}
\def\tikzextutil@compatwarning@mathcmdI#1#2#3#4{%
  \pgfutil@IfUndefined{pgfmath#3}{%
    \pgfmathdeclarefunction*{#3}{1}{%
      \tikzextutil@compatmaybewarning{PGFMath function '#3'}{'#4'}{#1 = #2}%
      \csname pgfmath#4@\endcsname{##1}%
    }%
  }{}%
}
\def\tikzextutil@compatwarning@mathcmdII#1#2#3#4{%
  \pgfutil@IfUndefined{pgfmath#3}{%
    \pgfmathdeclarefunction*{#3}{2}{%
      \tikzextutil@compatmaybewarning{PGFMath function '#3'}{'#4'}{#1 = #2}%
      \csname pgfmath#4@\endcsname{##1}{##2}%
    }%
  }{}%
}
\def\tikzextutil@compatwarning@mathcmdX#1#2#3#4{%
  \pgfutil@IfUndefined{pgfmath#3}{%
    \pgfmathdeclarefunction*{#3}{...}{%
      \tikzextutil@compatmaybewarning{PGFMath function '#3'}{'#4'}{#1 = #2}%
      \csname pgfmath#4@\endcsname##1%
    }%
  }{}%
}
\def\tikzextutil@compatwarning@handler#1#2#3#4{%
  \pgfkeys@pathtoks{/handlers/#3}%
  \pgfkeysifdefined{/handlers/#3}{%
    % The key is a value key. Do not overwrite or adjust.
    % Old TikZ-Ext key simply will not work.
  }{%
    \pgfkeysifdefined{/handlers/#3/.@cmd}{%
      % The key is a code key. Do not overwrite or adjust.
      % Old TikZ-Ext key simply will not work.
    }{%
      % The key is currently not used.
      \pgfkeysdef{/handlers/#3}{%
        \tikzextutil@compatmaybewarning{handler '#3'}{'#4'}{#1 = #2}%
        \pgfkeysvalueof{/handlers/#4/.@cmd}##1\pgfeov
      }%
    }
  }
}
\def\tikzextutil@compat@cloneshape#1#2{%
  \pgfutil@namelet{pgf@sh@s@#1}{pgf@sh@s@ext_#1}%
  \def\tikzext@temp{\edef\pgf@sm@shape@name{ext_#1}}%
  \expandafter\tikzextutil@prefix@macrotomacro\csname pgf@sh@s@#1\endcsname\tikzext@temp
  \pgfutil@namelet{pgf@anchor@#1@border}{pgf@anchor@ext_#1@border}%
  \pgfutil@namelet{pgf@sh@boxes@#1}{pgf@sh@boxes@ext_#1}%
  \pgfutil@for\tikzext@temp:=#2\do{%
    \pgfutil@namelet{pgf@anchor@#1@\tikzext@temp}{pgf@anchor@ext_#1@\tikzext@temp}}%
  \pgfutil@for\tikzext@temp:=bbg,bg,fbg,fg,ffg\do{%
    \pgfutil@namelet{pgf@sh@\tikzext@temp @#1}{pgf@sh@\tikzext@temp @ext_#1}}}

\tikzextset{
  compat/.is choice, compat/.default=warn,
  /tikz-ext/compat/add library/.code 2 args={%
    \tikzextset{
      compat/#1/.is choice,
      compat/#1/.default=#2,
      compat/#1/0.6.1/.style={/tikz/ext/compat/#1/0.6},
      compat/#1/0.6.2/.style={/tikz/ext/compat/#1/0.6}}%
    \pgfutil@for\tikzext@temp:=pre 0.6,0.6,0.6.1,0.6.2,newest,warn\do{%
      \pgfkeys@expanded{%
        \noexpand\tikzextset{%
          compat/\tikzext@temp/.append style=%
            /tikz/ext/compat/#1/\tikzext@temp}}%
      \pgfkeysedef
        {/tikz/ext/compat/#1/\tikzext@temp}
        {\noexpand\pgfkeyssetvalue{/tikz/ext/compat/#1}{\tikzext@temp}}%
    }%
  },
}

\def\tikzext@temp#1{%
  \pgfkeysedef{/tikz/ext/compat/#1}{%
    \noexpand\pgfkeyssetvalue{/tikz/ext/compat/arrows}                {#1}%
    \noexpand\pgfkeyssetvalue{/tikz/ext/compat/pgffor}                {#1}%
    \noexpand\pgfkeyssetvalue{/tikz/ext/compat/misc}                  {#1}%
    \noexpand\pgfkeyssetvalue{/tikz/ext/compat/nodes}                 {#1}%
    \noexpand\pgfkeyssetvalue{/tikz/ext/compat/node-families}         {#1}%
    \noexpand\pgfkeyssetvalue{/tikz/ext/compat/patterns.images}       {#1}%
    \noexpand\pgfkeyssetvalue{/tikz/ext/compat/paths.arcto}           {#1}%
    \noexpand\pgfkeyssetvalue{/tikz/ext/compat/paths.ortho}           {#1}%
    \noexpand\pgfkeyssetvalue{/tikz/ext/compat/paths.timer}           {#1}%
    \noexpand\pgfkeyssetvalue{/tikz/ext/compat/pgffor-ext}            {#1}%
    \noexpand\pgfkeyssetvalue{/tikz/ext/compat/pgfkeys-plus}          {#1}%
    \noexpand\pgfkeyssetvalue{/tikz/ext/compat/positioning-plus}      {#1}%
    \noexpand\pgfkeyssetvalue{/tikz/ext/compat/pgfcalendar-ext}       {#1}%
    \noexpand\pgfkeyssetvalue{/tikz/ext/compat/scalepicture}          {#1}%
    \noexpand\pgfkeyssetvalue{/tikz/ext/compat/shapes}                {#1}%
    \noexpand\pgfkeyssetvalue{/tikz/ext/compat/topaths.arcthrough}    {#1}%
    \noexpand\pgfkeyssetvalue{/tikz/ext/compat/transformations.mirror}{#1}%
  }}
\tikzext@temp{pre 0.6}
\tikzext@temp{0.6}
\tikzextset{
  compat/0.6.1/.style={/tikz/ext/compat/0.6},
  compat/0.6.2/.style={/tikz/ext/compat/0.6}%
}
\tikzext@temp{newest}
\tikzext@temp{warn}
\tikzextset{compat=warn}

\long\def\tikzextutil@gobblethree#1#2#3{}
\def\tikzextutil@addto@macro#1#2{\expandafter\def\expandafter#1\expandafter{#1#2}} % calendar: if
\def\tikzextutil@prefixtomacro#1#2{%
  \def\tikzext@temp{#2}%
  \tikzextutil@prefix@macrotomacro#1\tikzext@temp
}
\def\tikzextutil@prefix@macrotomacro#1#2{%
  \expandafter\expandafter\expandafter\def
  \expandafter\expandafter\expandafter#1%
  \expandafter\expandafter\expandafter{\expandafter#2#1}}

\def\tikzextutil@firstofmany#1#2\pgf@stop{#1}
\def\tikzextutil@secondofmany#1#2\pgf@stop{#2}
\endinput
