import subscribeTwig from './paragraph.subscribe.twig';
import subscribeData from './paragraph.subscribe.yml';
import './paragraph.subscribe.js';

import linkTwig from '@ui-base/link/_link.twig';

import { setPublishedStatus } from '.storybook/utils';

/**
 * Storybook Definition.
 */
export default {
  title: 'Layout Components/Subscribe',
};

export const subscribe = (args) => {
  // Create deep copy of data and merge args.
  let data = JSON.parse(JSON.stringify(subscribeData ?? {}));
  data = Object.assign(data, args);

  data.paragraph = setPublishedStatus(data.paragraph_is_published);

  return subscribeTwig({
    ...data,
    paragraph_link: linkTwig({ link_text: 'Sign Up', link_url: '#' })
  });
}
subscribe.args = subscribeData;
