<?php

add_filter("rwmb_meta_boxes", function ($meta_boxes) {
  $meta_boxes[] = apply_filters("inoby_mb_page_contact", [
    "id" => "contact_page",
    "title" => __("Contact", "inoby"),
    "post_types" => ["page"],
    "show" => [
      "template" => ["page-templates/contact.php"],
    ],
    "context" => "normal",
    "priority" => "default",
    "tab_style" => "left",
    "tabs" => [
      "contact-info" => [
        "label" => __("Contact info", "inoby"),
      ],
      "contact-form" => [
        "label" => __("Contact form", "inoby"),
      ],
      "billing-information" => [
        "label" => __("Billing information", "inoby"),
      ],
      "google-map" => [
        "label" => __("Google Map", "inoby"),
      ],
    ],
    "autosave" => "false",
    "fields" => [
      [
        "group_title" => __("Information #{#}", "inoby"),
        "id" => "contact_informations",
        "type" => "group",
        "tab" => "contact-info",
        "clone" => true,
        "sort_clone" => true,
        "collapsible" => true,
        "default_state" => "expanded",
        "fields" => [
          [
            "name" => __("Label", "inoby"),
            "id" => "contact_information_label",
            "type" => "text",
            "translate" => true,
          ],
          [
            "name" => __("Text Icon", "inoby"),
            "id" => "contact_information_icon",
            "type" => "image_advanced",
            "force_delete" => false,
            "max_file_uploads" => 1,
            "max_status" => false,
            "image_size" => "thumbnail",
          ],
          [
            "name" => __("Add divider?", "inoby"),
            "id" => "contact_information_divider",
            "type" => "checkbox",
            "std" => 0,
          ],
          [
            "group_title" => __("Text #{#}", "inoby"),
            "id" => "contact_information_texts",
            "type" => "group",
            "clone" => true,
            "sort_clone" => true,
            "fields" => [
              [
                "name" => __("Text", "inoby"),
                "id" => "contact_information_text",
                "type" => "textarea",
                "sanitize_callback" => "none",
                "translate" => true,
              ],
              [
                "name" => __("URL", "inoby"),
                "id" => "contact_information_url",
                "type" => "text",
                "translate" => true,
              ],
            ],
          ],
        ],
      ],
      [
        "type" => "custom_html",
        "std" =>
          "<p>The e-mail address to which the form sends information can be found in the section: Theme Options - Contact</p>",
        "tab" => "contact-form",
      ],
      [
        "name" => __("Heading", "inoby"),
        "id" => "contact_billing_heading",
        "type" => "text",
        "tab" => "billing-information",
        "sanitize_callback" => "none",
        "translate" => true,
      ],
      [
        "group_title" => __(
          "Billing information - {contact_billing_information_label}",
          "inoby",
        ),
        "id" => "contact_billing_information",
        "type" => "group",
        "tab" => "billing-information",
        "clone" => true,
        "sort_clone" => true,
        "collapsible" => true,
        "default_state" => "expanded",
        "fields" => [
          [
            "name" => __("Label", "inoby"),
            "id" => "contact_billing_information_label",
            "type" => "text",
            "sanitize_callback" => "none",
            "translate" => true,
          ],
          [
            "name" => __("Value", "inoby"),
            "id" => "contact_billing_information_value",
            "type" => "text",
            "sanitize_callback" => "none",
            "translate" => true,
          ],
        ],
      ],
      [
        "name" => __("Google Map - iframe", "inoby"),
        "id" => "google_map",
        "type" => "textarea",
        "tab" => "google-map",
      ],
    ],
  ]);
  return $meta_boxes;
});
