const separateScripts = function separateScripts(text) {
  if (!text) {
    return {
      inline: '',
      remotes: [],
      code: ''
    };
  }
  let inline = '';
  const scripts = text.match(/(<script.*src=.*?>.*<\/script>)/gim);
  const remotes = scripts ? scripts.map(script => script.match(/src=['"](.*)['"]/i)[1]) : [];
  const removedRemotes = text.replace(/(<script.*src=.*?>.*<\/script>)/gim, '');
  const code = removedRemotes.replace(/<script[^>]*>([\s\S]*?)<\/script>/gim, (match, group) => {
    inline += `${group}\n`;
    return '';
  });
  return {
    inline,
    remotes,
    code
  };
};
export default separateScripts;