(function () {
  const checkout = window.wc && window.wc.blocksCheckout;
  if (!checkout || typeof checkout.registerCheckoutFilters !== 'function') {
    return;
  }

  checkout.registerCheckoutFilters('asuka-product-designer', {
    cartItemClass(defaultValue, extensions) {
      const data = extensions && extensions.asuka_product_designer;
      if (!data || data.customized !== true) {
        return defaultValue;
      }

      const classes = String(defaultValue || '').split(/\s+/).filter(Boolean);
      if (!classes.includes('apd-blocks-cart-item--customized')) {
        classes.push('apd-blocks-cart-item--customized');
      }
      return classes.join(' ');
    },
  });
}());
