%% This is file `hyperxmp-patches-tmp-ltx.sty"
% Copyright (C) 2019-2021 The LaTeX Project
%
% It may be distributed and/or modified under the conditions of the
% LaTeX Project Public License (LPPL), either version 1.3c of this
% license or (at your option) any later version.  The latest version
% of this license is in the file
%
%    https://www.latex-project.org/lppl.txt
%
% This file is part of the "pdfmanagement bundle" (The Work in LPPL)
% and all files in that bundle must be distributed together.
%
% -----------------------------------------------------------------------
%
% The development version of the bundle can be found at
%
%    https://github.com/latex3/pdfresources
%
% for those people who are interested.
\NeedsTeXFormat{LaTeX2e}[2020/10/01]
\ProvidesExplPackage{colorspace-patches-tmp-ltx}{2022-05-11}{0.95o}
  {temporay patches to for the colorspace package to test pdfresource management ... UF}

\hook_gput_code:nnn {begindocument} {pdf}
  {
    \tl_if_exist:NT \spc@op
      {
        \def\spc@Pageresources#1{}
      }

  }

\hook_gput_code:nnn {begindocument/end} {pdf}
  {
    \tl_if_exist:NT \spc@op
      {
        \__pdf_backend_object_new:nn  {__spc_extgstate_op_false}{dict}
        \__pdf_backend_object_write:nn
          {__spc_extgstate_op_false}
          {/Type /ExtGState~/op~false~/OP~false}
        \pdfmanagement_add:nnn
          {Page/Resources/ExtGState}
          {SPCko}
          {\__pdf_backend_object_ref:n {__spc_extgstate_op_false}}
        \__pdf_backend_object_new:nn  {__spc_extgstate_op_true0}{dict}
        \__pdf_backend_object_write:nn
          {__spc_extgstate_op_true0}
          {/Type /ExtGState~/op~true~/OP~true~/OPM~0}%
        \pdfmanagement_add:nnn
          {Page/Resources/ExtGState}
          {SPCmz}
          {\__pdf_backend_object_ref:n {__spc_extgstate_op_true0}}
        \__pdf_backend_object_new:nn  {__spc_extgstate_op_true1}{dict}
        \__pdf_backend_object_write:nn
          {__spc_extgstate_op_true1}
          {/Type /ExtGState~/op~true~/OP~true~/OPM~1}%
         \pdfmanagement_add:nnn
          {Page/Resources/ExtGState}
          {SPCop}
          {\__pdf_backend_object_ref:n {__spc_extgstate_op_true1}}
      }
  }

\RemoveFromHook{begindocument}[colorspace]

\hook_gput_code:nnn {enddocument} {pdf}
 {
  \def\spc@elt#1#2
   {
    \str_set_eq:Nc\l_tmpa_str {spc@ir@#2}
    \seq_set_split:NnV \l_tmpa_seq {~}\l_tmpa_str
    \seq_get_left:NN\l_tmpa_seq\l_tmpa_str
    %remove spaces
    \exp_args:NNx
    \str_replace_all:Nnn\l_tmpa_str {\c_hash_str20}{~}
    %remove slash
    \str_set:Nx\l_tmpa_str{\str_tail:N\l_tmpa_str}
    \pdfmanagement_add:nex
      {Page/Resources/ColorSpace}{\l_tmpa_str}{\seq_item:Nn\l_tmpa_seq{2}~0~R}
   }
   \spc@csall
 }

\endinput
