<?php
namespace NeoMotionBeta\NeoDraw; if (!defined("ABSPATH")) { die("neoWP direct access not allowed"); }




\NeoMotionBeta\NeoGlobal\add_action_hook("load-upload.php", function () {
    if (!\NeoMotionBeta\NeoGlobal\current_user_can__neo_draw()) { return; }

    [$neo_library_page_slug, $interface_ok] = \NeoMotionBeta\NeoGlobal\call_interface_func_implemented('\NeoMotionBeta\NeoLibrary\interface_neo_library_menu_page_slug_20250618')();
    if ($interface_ok && \NeoMotionBeta\NeoGlobal\query_param("page") === $neo_library_page_slug) { return; }

    draw_pagebuilder_init();
    \NeoMotionBeta\NeoGlobal\add_action_hook("admin_head", function () {
        ?><style>


            .neo-draw--pb-media-library-create-button .neo-draw--button-logo { height: 1.2em; width: 1.2em; margin-bottom: -0.2em; margin-right: 0.2em; }
        </style><?php
    });


    \NeoMotionBeta\NeoGlobal\enqueue_js("neo-draw--pb-media-library-general.js");

    
    \NeoMotionBeta\NeoGlobal\add_filter_hook("wp_get_attachment_image_attributes", function ($attr, $attachment, $size) {
        if (!is_admin()) { return $attr; }
        if (!array_key_exists("src", $attr)) { return $attr; }
        if (\NeoMotionBeta\NeoGlobal\is_neodraw_image_post($attachment)) {
            $attr["data-neo-draw--is-neodraw"] = "true";
        } else {
            $attr["data-neo-draw--is-neodraw"] = "false";
        }
        return $attr;
    });


    
    $mode  = get_user_option( "media_library_mode", get_current_user_id() ) ? get_user_option( "media_library_mode", get_current_user_id() ) : "grid";
    $modes = ["grid", "list"];
    if (in_array(\NeoMotionBeta\NeoGlobal\query_param("mode"), $modes, true) ) { $mode = \NeoMotionBeta\NeoGlobal\query_param("mode"); }
    
    if ($mode === "list") { draw_pagebuilder_init_list(); }
    else {                  draw_pagebuilder_init_grid(); }
});
