<?php

use Twig\Environment;
use Twig\Error\LoaderError;
use Twig\Error\RuntimeError;
use Twig\Extension\CoreExtension;
use Twig\Extension\SandboxExtension;
use Twig\Markup;
use Twig\Sandbox\SecurityError;
use Twig\Sandbox\SecurityNotAllowedTagError;
use Twig\Sandbox\SecurityNotAllowedFilterError;
use Twig\Sandbox\SecurityNotAllowedFunctionError;
use Twig\Source;
use Twig\Template;
use Twig\TemplateWrapper;

/* components/itilobject/actors/field.html.twig */
class __TwigTemplate_168fe9b1b59cea64fd9ce67fae2c2dd1 extends Template
{
    private Source $source;
    /**
     * @var array<string, Template>
     */
    private array $macros = [];

    public function __construct(Environment $env)
    {
        parent::__construct($env);

        $this->source = $this->getSourceContext();

        $this->parent = false;

        $this->blocks = [
        ];
    }

    protected function doDisplay(array $context, array $blocks = []): iterable
    {
        $macros = $this->macros;
        // line 32
        yield "
";
        // line 33
        $context["rand"] = Twig\Extension\CoreExtension::random($this->env->getCharset());
        // line 34
        yield "
";
        // line 35
        $context["load_actors"] = (((CoreExtension::getAttribute($this->env, $this->source, ($context["params"] ?? null), "load_actors", [], "array", true, true, false, 35) &&  !(null === (($_v0 = ($context["params"] ?? null)) && is_array($_v0) || $_v0 instanceof ArrayAccess ? ($_v0["load_actors"] ?? null) : null)))) ? ((($_v1 = ($context["params"] ?? null)) && is_array($_v1) || $_v1 instanceof ArrayAccess ? ($_v1["load_actors"] ?? null) : null)) : (true));
        // line 36
        $context["actors"] = (((($tmp = ($context["load_actors"] ?? null)) && $tmp instanceof Markup ? (string) $tmp : $tmp)) ? (CoreExtension::getAttribute($this->env, $this->source, ($context["item"] ?? null), "getActorsForType", [($context["actortypeint"] ?? null), ($context["params"] ?? null)], "method", false, false, false, 36)) : ([]));
        // line 37
        yield "
";
        // line 38
        $context["required"] = false;
        // line 39
        if (((CoreExtension::getAttribute($this->env, $this->source, ($context["itiltemplate"] ?? null), "isMandatoryField", [("_users_id_" . ($context["actortype"] ?? null))], "method", false, false, false, 39) || CoreExtension::getAttribute($this->env, $this->source, ($context["itiltemplate"] ?? null), "isMandatoryField", [("_groups_id_" . ($context["actortype"] ?? null))], "method", false, false, false, 39)) || ((($context["actortype"] ?? null) == "assign") && CoreExtension::getAttribute($this->env, $this->source, ($context["itiltemplate"] ?? null), "isMandatoryField", [("_suppliers_id_" . ($context["actortype"] ?? null))], "method", false, false, false, 39)))) {
            // line 40
            yield "   ";
            $context["required"] = true;
        }
        // line 42
        yield "
";
        // line 43
        $context["is_actor_hidden"] = false;
        // line 44
        if (((CoreExtension::getAttribute($this->env, $this->source, ($context["itiltemplate"] ?? null), "isHiddenField", [("_users_id_" . ($context["actortype"] ?? null))], "method", false, false, false, 44) && CoreExtension::getAttribute($this->env, $this->source, ($context["itiltemplate"] ?? null), "isHiddenField", [("_groups_id_" . ($context["actortype"] ?? null))], "method", false, false, false, 44)) && ((($context["actortype"] ?? null) != "assign") || CoreExtension::getAttribute($this->env, $this->source, ($context["itiltemplate"] ?? null), "isHiddenField", [("_suppliers_id_" . ($context["actortype"] ?? null))], "method", false, false, false, 44)))) {
            // line 45
            yield "   ";
            $context["is_actor_hidden"] = true;
        }
        // line 47
        yield "
";
        // line 48
        $context["onchange"] = "";
        // line 49
        $context["allow_auto_submit"] = (((array_key_exists("allow_auto_submit", $context) &&  !(null === $context["allow_auto_submit"]))) ? ($context["allow_auto_submit"]) : (true));
        // line 50
        if (((($context["allow_auto_submit"] ?? null) && CoreExtension::getAttribute($this->env, $this->source, ($context["item"] ?? null), "isNewItem", [], "method", false, false, false, 50)) && (($context["actortype"] ?? null) == "requester"))) {
            // line 51
            yield "   ";
            $context["onchange"] = "this.form.submit();";
        }
        // line 53
        yield "
";
        // line 54
        if ((($tmp =  !($context["is_actor_hidden"] ?? null)) && $tmp instanceof Markup ? (string) $tmp : $tmp)) {
            // line 55
            yield "   <select class=\"form-select\" multiple=\"true\" id=\"actor_";
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["rand"] ?? null), "html", null, true);
            yield "\" data-actor-type=\"";
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["actortype"] ?? null), "html", null, true);
            yield "\"
        ";
            // line 56
            yield (((($tmp = ($context["required"] ?? null)) && $tmp instanceof Markup ? (string) $tmp : $tmp)) ? ("required") : (""));
            yield ">
   ";
            // line 57
            $context['_parent'] = $context;
            $context['_seq'] = CoreExtension::ensureTraversable(($context["actors"] ?? null));
            foreach ($context['_seq'] as $context["_key"] => $context["actor"]) {
                // line 58
                yield "      ";
                $context["unique_id"] = ((("user_opt_" . ($context["actortype"] ?? null)) . CoreExtension::getAttribute($this->env, $this->source, $context["actor"], "itemtype", [], "any", false, false, false, 58)) . CoreExtension::getAttribute($this->env, $this->source, $context["actor"], "items_id", [], "any", false, false, false, 58));
                // line 59
                yield "      <option selected=\"true\" value=\"";
                yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape((((($_v2 = $context["actor"]) && is_array($_v2) || $_v2 instanceof ArrayAccess ? ($_v2["itemtype"] ?? null) : null) . "_") . (($_v3 = $context["actor"]) && is_array($_v3) || $_v3 instanceof ArrayAccess ? ($_v3["items_id"] ?? null) : null)), "html", null, true);
                yield "\"
            data-itemtype=\"";
                // line 60
                yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape((($_v4 = $context["actor"]) && is_array($_v4) || $_v4 instanceof ArrayAccess ? ($_v4["itemtype"] ?? null) : null), "html", null, true);
                yield "\" data-items-id=\"";
                yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape((($_v5 = $context["actor"]) && is_array($_v5) || $_v5 instanceof ArrayAccess ? ($_v5["items_id"] ?? null) : null), "html", null, true);
                yield "\"
            data-use-notification=\"";
                // line 61
                yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape((($_v6 = $context["actor"]) && is_array($_v6) || $_v6 instanceof ArrayAccess ? ($_v6["use_notification"] ?? null) : null), "html", null, true);
                yield "\"
            data-default-email=\"";
                // line 62
                yield (((CoreExtension::getAttribute($this->env, $this->source, $context["actor"], "default_email", [], "array", true, true, false, 62) &&  !(null === (($_v7 = $context["actor"]) && is_array($_v7) || $_v7 instanceof ArrayAccess ? ($_v7["default_email"] ?? null) : null)))) ? ($this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape((($_v8 = $context["actor"]) && is_array($_v8) || $_v8 instanceof ArrayAccess ? ($_v8["default_email"] ?? null) : null), "html", null, true)) : (""));
                yield "\"
            data-alternative-email=\"";
                // line 63
                yield (((CoreExtension::getAttribute($this->env, $this->source, $context["actor"], "alternative_email", [], "array", true, true, false, 63) &&  !(null === (($_v9 = $context["actor"]) && is_array($_v9) || $_v9 instanceof ArrayAccess ? ($_v9["alternative_email"] ?? null) : null)))) ? ($this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape((($_v10 = $context["actor"]) && is_array($_v10) || $_v10 instanceof ArrayAccess ? ($_v10["alternative_email"] ?? null) : null), "html", null, true)) : (""));
                yield "\"
            ";
                // line 64
                if (((((($_v11 = $context["actor"]) && is_array($_v11) || $_v11 instanceof ArrayAccess ? ($_v11["itemtype"] ?? null) : null) == "User") && CoreExtension::getAttribute($this->env, $this->source, ($context["itiltemplate"] ?? null), "isHiddenField", [("_users_id_" . ($context["actortype"] ?? null))], "method", false, false, false, 64)) || (((($_v12 = $context["actor"]) && is_array($_v12) || $_v12 instanceof ArrayAccess ? ($_v12["itemtype"] ?? null) : null) == "Group") && CoreExtension::getAttribute($this->env, $this->source, ($context["itiltemplate"] ?? null), "isHiddenField", [("_groups_id_" . ($context["actortype"] ?? null))], "method", false, false, false, 64)))) {
                    // line 65
                    yield "               disabled=\"disabled\" style=\"display: none;\"
            ";
                }
                // line 67
                yield "            data-text=\"";
                yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape($this->extensions['Glpi\Application\View\Extension\DataHelpersExtension']->getVerbatimValue((($_v13 = $context["actor"]) && is_array($_v13) || $_v13 instanceof ArrayAccess ? ($_v13["text"] ?? null) : null)), "html", null, true);
                yield "\" data-title=\"";
                yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape($this->extensions['Glpi\Application\View\Extension\DataHelpersExtension']->getVerbatimValue((($_v14 = $context["actor"]) && is_array($_v14) || $_v14 instanceof ArrayAccess ? ($_v14["title"] ?? null) : null)), "html", null, true);
                yield "\" data-glpi-popover-source=\"content";
                yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["unique_id"] ?? null), "html", null, true);
                yield "\">
         ";
                // line 68
                yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape($this->extensions['Glpi\Application\View\Extension\DataHelpersExtension']->getVerbatimValue((($_v15 = $context["actor"]) && is_array($_v15) || $_v15 instanceof ArrayAccess ? ($_v15["title"] ?? null) : null)), "html", null, true);
                yield "
      </option>
   ";
            }
            $_parent = $context['_parent'];
            unset($context['_seq'], $context['_key'], $context['actor'], $context['_parent']);
            $context = array_intersect_key($context, $_parent) + $_parent;
            // line 71
            yield "   </select>

   ";
            // line 73
            if ((( !CoreExtension::getAttribute($this->env, $this->source, ($context["item"] ?? null), "isNewItem", [], "method", false, false, false, 73) &&  !(($_v16 = ($context["params"] ?? null)) && is_array($_v16) || $_v16 instanceof ArrayAccess ? ($_v16["template_preview"] ?? null) : null)) && ($context["canassigntome"] ?? null))) {
                // line 74
                yield "      ";
                yield Twig\Extension\CoreExtension::include($this->env, $context, "components/itilobject/actors/assign_to_me.html.twig");
                yield "
   ";
            }
            // line 76
            yield "
   ";
            // line 86
            yield "   ";
            $context["safe_item_fields"] = Twig\Extension\CoreExtension::filter($this->env, $this->env->hasExtension(\Twig\Extension\SandboxExtension::class) && $this->env->getExtension(\Twig\Extension\SandboxExtension::class)->isSandboxed($this->source), CoreExtension::getAttribute($this->env, $this->source, ($context["item"] ?? null), "fields", [], "any", false, false, false, 86), function ($__value__, $__key__) use ($context, $macros) { $context["value"] = $__value__; $context["key"] = $__key__; return (($context["key"] ?? null) != "content"); });
            // line 87
            yield "
   <script type=\"text/javascript\">

   // Do not use jquery ready wrapper here as it behave unexpectedly with ajax
   // requests, adding an unnecessary delay
   (function() {
      var actorytype = \x27";
            // line 93
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["actortype"] ?? null), "html", null, true);
            yield "\x27;

      // function to display an option in the list or the selected input
      var genericTemplate_";
            // line 96
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["rand"] ?? null), "html", null, true);
            yield " = function(option = {}, is_selection = false) {
         var element   = \$(option.element);
         var itemtype  = element.data(\x27itemtype\x27) ?? option.itemtype;
         var items_id  = element.data(\x27items-id\x27) ?? option.items_id;
         var text      = escapeMarkupText(element.data(\x27text\x27) ?? option.text ?? \x27\x27);
         var title     = escapeMarkupText(element.data(\x27title\x27) ?? option.title ?? \x27\x27);
         var use_notif = element.data(\x27use-notification\x27) ?? option.use_notification ?? 1;
         var alt_email = element.data(\x27alternative-email\x27) ?? option.alternative_email ?? \x27\x27;

         var icon = \"\";
         var fk   = \"\";
         switch (itemtype) {
            case \"User\":
               if (items_id == 0) {
                  text = alt_email;
                  icon = `<i class=\"ti  fa-fw ti-mail mx-1\" title=\"";
            // line 111
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(__("Direct email"), "html", null, true);
            yield "\"></i>`;
               } else {
                  icon = `<i class=\"ti  fa-fw ti-user mx-1\" title=\"";
            // line 113
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape($this->extensions['Glpi\Application\View\Extension\ItemtypeExtension']->getItemtypeName("User"), "html", null, true);
            yield "\"></i>`;
               }
               if (\"";
            // line 115
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["actortype"] ?? null), "html", null, true);
            yield "\" == \"assign\") {
                  fk = \"users_id_assign\";
               } else if (\"";
            // line 117
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["actortype"] ?? null), "html", null, true);
            yield "\" == \"requester\") {
                  fk = \"users_id_requester\";
               } else if (\"";
            // line 119
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["actortype"] ?? null), "html", null, true);
            yield "\" == \"observer\") {
                  fk = \"users_id_observer\";
               }
               break;
            case \"Group\":
               icon = `<i class=\"ti  fa-fw ti-users mx-1\" title=\"";
            // line 124
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape($this->extensions['Glpi\Application\View\Extension\ItemtypeExtension']->getItemtypeName("Group"), "html", null, true);
            yield "\"></i>`;
               if (\"";
            // line 125
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["actortype"] ?? null), "html", null, true);
            yield "\" == \"assign\") {
                  fk = \"groups_id_assign\";
               } else if (\"";
            // line 127
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["actortype"] ?? null), "html", null, true);
            yield "\" == \"requester\") {
                  fk = \"groups_id_requester\";
               } else if (\"";
            // line 129
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["actortype"] ?? null), "html", null, true);
            yield "\" == \"observer\") {
                  fk = \"groups_id_observer\";
               }
               break;
            case \"Supplier\":
               icon = `<i class=\"ti fa-fw ti-package mx-1\" title=\"";
            // line 134
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape($this->extensions['Glpi\Application\View\Extension\ItemtypeExtension']->getItemtypeName("Supplier"), "html", null, true);
            yield "\"></i>`;
               fk   = \"suppliers_id_assign\";
               break;
         }

         var actions = \"\";
         ";
            // line 140
            if ((($tmp = ($context["canupdate"] ?? null)) && $tmp instanceof Markup ? (string) $tmp : $tmp)) {
                // line 141
                yield "         if ([\x27User\x27, \x27Supplier\x27, \x27Email\x27].includes(itemtype)
            && is_selection) {
            var fa_class = \"far\";
            if (use_notif) {
               fa_class = \"fas\";
            }
            actions = `<button class=\"btn btn-sm btn-ghost-secondary edit-notify-user\"
                              data-bs-toggle=\"tooltip\" data-bs-placement=\"top\"
                              title=\"";
                // line 149
                yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(__("Email followup"), "html", null, true);
                yield "\"
                              type=\"button\">
               <i class=\"\${fa_class} fa-bell notify-icon\"></i>
            </button>`;
         }
         ";
            }
            // line 155
            yield "
         // manage specific display for tree data (like groups)
         var indent = \"\";
         if (!is_selection && \"level\" in option && option.level > 1) {
            for (let index = 1; index < option.level; index++) {
               indent = \"&nbsp;&nbsp;&nbsp;\"+indent;
            }
            indent = indent+\"&raquo;\";
         }

         // prepare html for option element
         var text = (is_selection && itemtype == \"Group\") ? title : text;
         var option_text    = `<span class=\"actor_text\">\${text}</span>`;
         var option_element = \$(`<span class=\"actor_entry\" data-itemtype=\"\${itemtype}\" data-items-id=\"\${items_id}\" data-actortype=\"\${actorytype}\">\${indent}\${icon}\${option_text}\${actions}</span>`);

          if (is_selection && itemtype == \"User\") {
              const unique_id = \"user_opt_\" + actor_select.attr(\x27data-actor-type\x27) + \"User\" + items_id;
              \$.ajax({
                  url: \x27";
            // line 173
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape($this->extensions['Glpi\Application\View\Extension\RoutingExtension']->path("/ajax/comments.php"), "html", null, true);
            yield "\x27,
                  type: \x27POST\x27,
                  data: {
                      \x27itemtype\x27: \x27User\x27,
                      \x27value\x27: items_id,
                  }
              }).then((result) => {
                  if (result) {
                      actor_select.parent().append(\x27<\x27 + `div id=\"content\${unique_id}\" style=\"display: none;\">` + result + \x27<\x27 + \x27/div>\x27);
                      option_element.attr(\x27data-glpi-popover-source\x27, `content\${unique_id}`);
                  }
              });
          }

         if (is_selection && itemtype == \"Group\") {
            const unique_id = \"group_opt_\" + actor_select.attr(\x27data-actor-type\x27) + \"Group\" + items_id;
            \$.ajax({
               url: \x27";
            // line 190
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape($this->extensions['Glpi\Application\View\Extension\RoutingExtension']->path("/ajax/comments.php"), "html", null, true);
            yield "\x27,
               type: \x27POST\x27,
               data: {
                  \x27itemtype\x27: \x27Group\x27,
                  \x27value\x27: items_id,
               }
            }).then((result) => {
               if (result) {
                  actor_select.parent().append(\x27<\x27 + `div id=\"content\${unique_id}\" style=\"display: none;\">` + result + \x27<\x27 + \x27/div>\x27);
                  option_element.attr(\x27data-glpi-popover-source\x27, `content\${unique_id}`);
               }
            });
         }

         if (is_selection && itemtype == \"Supplier\") {
            const unique_id = \"supplier_opt_\" + actor_select.attr(\x27data-actor-type\x27) + \"Supplier\" + items_id;
            \$.ajax({
               url: \x27";
            // line 207
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape($this->extensions['Glpi\Application\View\Extension\RoutingExtension']->path("/ajax/comments.php"), "html", null, true);
            yield "\x27,
               type: \x27POST\x27,
               data: {
                  \x27itemtype\x27: \x27Supplier\x27,
                  \x27value\x27: items_id,
               }
            }).then((result) => {
               if (result) {
                  actor_select.parent().append(\x27<\x27 + `div id=\"content\${unique_id}\" style=\"display: none;\">` + result + \x27<\x27 + \x27/div>\x27);
                  option_element.attr(\x27data-glpi-popover-source\x27, `content\${unique_id}`);
               }
            });
         }

         // manage ticket information (number of assigned ticket for an actor)
         if (is_selection && itemtype != \"Email\") {
            var label = \x27\x27;
            if (\"";
            // line 224
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["actortype"] ?? null), "html", null, true);
            yield "\" == \"assign\") {
               label = \"";
            // line 225
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(__("Number of tickets already assigned"), "html", null, true);
            yield "\";
            } else if (\"";
            // line 226
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["actortype"] ?? null), "html", null, true);
            yield "\" == \"requester\") {
               label = \"";
            // line 227
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(__("Number of tickets as requester"), "html", null, true);
            yield "\";
            }
            var existing_element = \$(
               `<span class=\"assign_infos ms-1\" title=\"\${label}\"
                     data-bs-toggle=\"tooltip\" data-bs-placement=\"top\"
                     data-id=\"\${items_id}\" data-fk=\"\${fk}\">
                  <i class=\"fas fa-spinner fa-spin\"></i>
               </span>`
            );
            option_element.append(existing_element);

            \$.get(\"";
            // line 238
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape($this->extensions['Glpi\Application\View\Extension\RoutingExtension']->path("/ajax/actorinformation.php"), "html", null, true);
            yield "\", {
               [fk]: items_id,
               only_number: true,
            }).done(function (number) {
               var badge = \"\";
               if (number.length > 0) {
                  badge = `<span class=\"badge bg-secondary-lt\">
                  \${number}
               </span>`;
               }
               existing_element.html(badge);
            });
         }

         return option_element;
      };

      var select2_width = \"";
            // line 255
            yield (((($tmp = ($context["canassigntome"] ?? null)) && $tmp instanceof Markup ? (string) $tmp : $tmp)) ? ("calc(100% - 30px)") : ("100%"));
            yield "\";

      const actor_select = \$(\"#actor_";
            // line 257
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["rand"] ?? null), "html", null, true);
            yield "\");
      actor_select.select2({
         tags: true,
         width: select2_width,
         tokenSeparators: [\x27,\x27, \x27 \x27],
         containerCssClass: \x27actor-field\x27,
         templateSelection: function(option) { return genericTemplate_";
            // line 263
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["rand"] ?? null), "html", null, true);
            yield "(option, true); },
         templateResult:    function(option) { return genericTemplate_";
            // line 264
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["rand"] ?? null), "html", null, true);
            yield "(option, false); },
         disabled: ";
            // line 265
            yield (((($tmp = ($context["canupdate"] ?? null)) && $tmp instanceof Markup ? (string) $tmp : $tmp)) ? ("false") : ("true"));
            yield ",
         createTag: function (params) {
            var term = \$.trim(params.term);

            if (term === \x27\x27) {
               return null;
            }

            // Don\x27t offset to create a tag if it\x27s not an email
            if (!new RegExp(/^[\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,63}\$/).test(term)) {
               // Return null to disable tag creation
               return null;
            }

            return {
               id: term,
               text: term,
               itemtype: \"User\",
               items_id: 0,
               use_notification: 1,
               alternative_email: term,
            }
         },
         ajax: {
            url: \x27";
            // line 289
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape($this->extensions['Glpi\Application\View\Extension\RoutingExtension']->path("/ajax/actors.php"), "html", null, true);
            yield "\x27,
            datatype: \x27json\x27,
            type: \x27POST\x27,
            delay:250,
            data: function (params) {
               var is_new_item = ";
            // line 294
            yield (((($tmp = CoreExtension::getAttribute($this->env, $this->source, ($context["item"] ?? null), "isNewItem", [], "method", false, false, false, 294)) && $tmp instanceof Markup ? (string) $tmp : $tmp)) ? ("true") : ("false"));
            yield ";
               return {
                  action: \x27getActors\x27,
                  actortype: actorytype,
                  users_right: \x27";
            // line 298
            yield (((array_key_exists("users_right", $context) &&  !(null === $context["users_right"]))) ? ($this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape($context["users_right"], "html", null, true)) : ("all"));
            yield "\x27,
                  entity_restrict: (actors.requester.length == 0 && is_new_item) ? -1 : ";
            // line 299
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["entities_id"] ?? null), "html", null, true);
            yield ",
                  searchText: params.term,
                  _idor_token: \x27";
            // line 301
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(Session::getNewIDORToken(CoreExtension::getAttribute($this->env, $this->source, ($context["item"] ?? null), "getType", [], "method", false, false, false, 301), ["users_right" => (((array_key_exists("users_right", $context) &&  !(null === $context["users_right"]))) ? ($context["users_right"]) : ("all"))]), "html", null, true);
            yield "\x27,
                  itiltemplate_class: \x27";
            // line 302
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, ($context["itiltemplate"] ?? null), "getType", [], "method", false, false, false, 302), "html", null, true);
            yield "\x27,
                  itiltemplates_id: ";
            // line 303
            yield (((CoreExtension::getAttribute($this->env, $this->source, CoreExtension::getAttribute($this->env, $this->source, ($context["itiltemplate"] ?? null), "fields", [], "any", false, true, false, 303), "id", [], "array", true, true, false, 303) &&  !(null === (($_v17 = CoreExtension::getAttribute($this->env, $this->source, ($context["itiltemplate"] ?? null), "fields", [], "any", false, false, false, 303)) && is_array($_v17) || $_v17 instanceof ArrayAccess ? ($_v17["id"] ?? null) : null)))) ? ($this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape((($_v18 = CoreExtension::getAttribute($this->env, $this->source, ($context["itiltemplate"] ?? null), "fields", [], "any", false, false, false, 303)) && is_array($_v18) || $_v18 instanceof ArrayAccess ? ($_v18["id"] ?? null) : null), "html", null, true)) : (0));
            yield ",
                  itemtype: \x27";
            // line 304
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, ($context["item"] ?? null), "getType", [], "method", false, false, false, 304), "html", null, true);
            yield "\x27,
                  items_id: ";
            // line 305
            yield (((($tmp = CoreExtension::getAttribute($this->env, $this->source, ($context["item"] ?? null), "isNewItem", [], "method", false, false, false, 305)) && $tmp instanceof Markup ? (string) $tmp : $tmp)) ? ($this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape( -1, "html", null, true)) : ($this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape((($_v19 = CoreExtension::getAttribute($this->env, $this->source, ($context["item"] ?? null), "fields", [], "any", false, false, false, 305)) && is_array($_v19) || $_v19 instanceof ArrayAccess ? ($_v19["id"] ?? null) : null), "html", null, true)));
            yield ",
                  item: ";
            // line 306
            yield json_encode(($context["safe_item_fields"] ?? null));
            yield ",
                  returned_itemtypes: ";
            // line 307
            yield json_encode((((array_key_exists("returned_itemtypes", $context) &&  !(null === $context["returned_itemtypes"]))) ? ($context["returned_itemtypes"]) : (["User", "Group", "Supplier"])));
            yield ",
                  page: params.page || 1
               };
            },
         }
      }).on(\x27select2:open\x27, () => {
          // Close popovers
          \$(\x27.popover\x27).popover(\x27hide\x27);
      });

      \$(function () {
         actor_select.parent().popover({
            selector: \x27[data-glpi-popover-source]\x27,
            container: actor_select.parent(),
            html: true,
            sanitize: false,
            trigger: \x27hover\x27,
            delay: {
               hide: 300
            },
            template: \x27<\x27 + \x27div class=\"popover shadow\" role=\"tooltip\"><\x27 + \x27div class=\"popover-arrow\"><\x27 + \x27/div><\x27 + \x27h3 class=\"popover-header\"><\x27 + \x27/h3><\x27 + \x27div class=\"popover-body\"><\x27 + \x27/div><\x27 + \x27/div>\x27,
            content: function() {
               // Close other popovers
               \$(\x27.popover\x27).popover(\x27hide\x27);
               return \$(\x27#\x27 + \$(this).attr(\x27data-glpi-popover-source\x27)).html();
            }
         }).on(\x27hide.bs.popover\x27, function () {
            // prevent closing popover when user card is hover
            if (\$(\x27.user-info-card:hover\x27).length > 0) {
               return false;
            }
            // prevent closing popover when group card is hover
            if (\$(\x27.group-info-card:hover\x27).length > 0) {
               return false;
            }
            // prevent closing popover when supplier card is hover
            if (\$(\x27.supplier-info-card:hover\x27).length > 0) {
               return false;
            }
         });
      });

        // when the mouse leave the user card in the popover, close it
        \$(document).on(\x27mouseleave\x27, \x27.user-info-card\x27, function() {
            setTimeout(() => {
                \$(\x27.popover\x27).popover(\x27hide\x27);
            }, 300);
        });

        // when the mouse leave the group card in the popover, close it
        \$(document).on(\x27mouseleave\x27, \x27.group-info-card\x27, function() {
            setTimeout(() => {
                \$(\x27.popover\x27).popover(\x27hide\x27);
            }, 300);
        });

      // manage actors change
      var updateActors";
            // line 364
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["rand"] ?? null), "html", null, true);
            yield " = function() {
         var data = \$(\"#actor_";
            // line 365
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["rand"] ?? null), "html", null, true);
            yield "\").select2(\x27data\x27);

         var new_actors = [];
         data.forEach(function(selection) {
            var element = \$(selection.element);

            var itemtype  = selection.itemtype ?? element.data(\x27itemtype\x27);
            var items_id  = selection.items_id ?? element.data(\x27items-id\x27);
            var use_notif = selection.use_notification  ?? element.data(\x27use-notification\x27)  ?? false;
            var def_email = selection.default_email ?? element.data(\x27default-email\x27) ?? \x27\x27;
            var alt_email = selection.alternative_email ?? element.data(\x27alternative-email\x27) ?? \x27\x27;

            if (itemtype == \"Email\") {
               itemtype  = \"User\";
               use_notif = true;
               alt_email = selection.id;
            }

            new_actors.push({
               itemtype: itemtype,
               items_id: items_id,
               use_notification: use_notif,
               default_email: def_email,
               alternative_email: alt_email,
            });
         });

         actors[actorytype] = new_actors;

         saveActorsToDom();
      };
      \$(\"#actor_";
            // line 396
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["rand"] ?? null), "html", null, true);
            yield "\").on(\x27select2:select\x27, function () {
         updateActors";
            // line 397
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["rand"] ?? null), "html", null, true);
            yield "();
         ";
            // line 398
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["onchange"] ?? null), "html", null, true);
            yield "
      });
      \$(\"#actor_";
            // line 400
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["rand"] ?? null), "html", null, true);
            yield "\").on(\x27select2:unselect\x27, function () {
         updateActors";
            // line 401
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["rand"] ?? null), "html", null, true);
            yield "();
         ";
            // line 402
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["onchange"] ?? null), "html", null, true);
            yield "
      });

      // intercept event for edit notification button
      document.addEventListener(\x27click\x27, event => {
         if (event.target.closest(\"#actor_";
            // line 407
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["rand"] ?? null), "html", null, true);
            yield " + .select2 .edit-notify-user\")) {
            return openNotifyModal(event);
         }
         // if a click on assign info is detected prevent opening of select2
         if (event.target.closest(\"#actor_";
            // line 411
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["rand"] ?? null), "html", null, true);
            yield " + .select2 .assign_infos\")) {
            event.stopPropagation();
         }
      }, {capture: true})
      document.addEventListener(\x27keydown\x27, event => {
         if (event.target.closest(\"#actor_";
            // line 416
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["rand"] ?? null), "html", null, true);
            yield " + .select2 .edit-notify-user\")
            && event.key == \"Enter\") {
            return openNotifyModal(event);
         }
      }, {capture: true})

      ";
            // line 422
            if ((($tmp = CoreExtension::getAttribute($this->env, $this->source, ($context["itiltemplate"] ?? null), "isHiddenField", [("_users_id_" . ($context["actortype"] ?? null))], "method", false, false, false, 422)) && $tmp instanceof Markup ? (string) $tmp : $tmp)) {
                // line 423
                yield "         \$(\".actor_entry[data-itemtype=\\\"User\\\"][data-actortype=\\\"";
                yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["actortype"] ?? null), "html", null, true);
                yield "\\\"]\").parent().css(\"display\", \"none\");
      ";
            }
            // line 425
            yield "      ";
            if ((($tmp = CoreExtension::getAttribute($this->env, $this->source, ($context["itiltemplate"] ?? null), "isHiddenField", [("_groups_id_" . ($context["actortype"] ?? null))], "method", false, false, false, 425)) && $tmp instanceof Markup ? (string) $tmp : $tmp)) {
                // line 426
                yield "         \$(\".actor_entry[data-itemtype=\\\"Group\\\"][data-actortype=\\\"";
                yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["actortype"] ?? null), "html", null, true);
                yield "\\\"]\").parent().css(\"display\", \"none\");
      ";
            }
            // line 428
            yield "   })();
   </script>
";
        }
        yield from [];
    }

    /**
     * @codeCoverageIgnore
     */
    public function getTemplateName(): string
    {
        return "components/itilobject/actors/field.html.twig";
    }

    /**
     * @codeCoverageIgnore
     */
    public function isTraitable(): bool
    {
        return false;
    }

    /**
     * @codeCoverageIgnore
     */
    public function getDebugInfo(): array
    {
        return array (  680 => 428,  674 => 426,  671 => 425,  665 => 423,  663 => 422,  654 => 416,  646 => 411,  639 => 407,  631 => 402,  627 => 401,  623 => 400,  618 => 398,  614 => 397,  610 => 396,  576 => 365,  572 => 364,  512 => 307,  508 => 306,  504 => 305,  500 => 304,  496 => 303,  492 => 302,  488 => 301,  483 => 299,  479 => 298,  472 => 294,  464 => 289,  437 => 265,  433 => 264,  429 => 263,  420 => 257,  415 => 255,  395 => 238,  381 => 227,  377 => 226,  373 => 225,  369 => 224,  349 => 207,  329 => 190,  309 => 173,  289 => 155,  280 => 149,  270 => 141,  268 => 140,  259 => 134,  251 => 129,  246 => 127,  241 => 125,  237 => 124,  229 => 119,  224 => 117,  219 => 115,  214 => 113,  209 => 111,  191 => 96,  185 => 93,  177 => 87,  174 => 86,  171 => 76,  165 => 74,  163 => 73,  159 => 71,  150 => 68,  141 => 67,  137 => 65,  135 => 64,  131 => 63,  127 => 62,  123 => 61,  117 => 60,  112 => 59,  109 => 58,  105 => 57,  101 => 56,  94 => 55,  92 => 54,  89 => 53,  85 => 51,  83 => 50,  81 => 49,  79 => 48,  76 => 47,  72 => 45,  70 => 44,  68 => 43,  65 => 42,  61 => 40,  59 => 39,  57 => 38,  54 => 37,  52 => 36,  50 => 35,  47 => 34,  45 => 33,  42 => 32,);
    }

    public function getSourceContext(): Source
    {
        return new Source("", "components/itilobject/actors/field.html.twig", "C:\\xampp\\htdocs\\itsm\\templates\\components\\itilobject\\actors\\field.html.twig");
    }
}
