export const syncPCtoTBSP = (attributes, setAttributes, attributeKeys) => {
  const syncAttrs = {};
  
  attributeKeys.forEach(key => {
    const pcKey = `${key}PC`;
    const tbKey = `${key}TB`;
    const spKey = `${key}SP`;
    
    if (attributes[pcKey] !== undefined) {
      syncAttrs[tbKey] = attributes[pcKey];
      syncAttrs[spKey] = attributes[pcKey];
    }
  });
  
  if (Object.keys(syncAttrs).length > 0) {
    setAttributes(syncAttrs);
  }
};

export const createResponsiveChangeHandlerV2 = (
  attributeKey,
  setAttributes,
  responsiveEnabled,
  activeTab
) => {
  return (value) => {
    if (!responsiveEnabled) {
      setAttributes({
        [`${attributeKey}PC`]: value,
        [`${attributeKey}TB`]: value,
        [`${attributeKey}SP`]: value,
      });
    } else {
      const deviceSuffix = activeTab.toUpperCase();
      setAttributes({ [`${attributeKey}${deviceSuffix}`]: value });
    }
  };
};

export const getDeviceSuffix = (activeTab) => {
  return activeTab.toUpperCase();
};
