/**
 * * Dynamically populates the color palettes in ACF color pickers
 */
(function ($) {
  if (typeof acf === 'undefined') return;

  acf.add_filter('color_picker_args', function (args, field) {
    // Replace default palette with your custom ones from localized script
    if (
      typeof acfCustomPalette !== 'undefined' &&
      Array.isArray(acfCustomPalette.colors)
    ) {
      args.palettes = acfCustomPalette.colors;
    }

    return args;
  });
})(jQuery);
