{"version":3,"sources":["jsdelivr-header.js","/npm/zeev-mail@0.3.0/lib/compiler.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACNA,MAAM,GAAK,QAAQ,MACb,KAAO,QAAQ,QACf,KAAO,QAAQ,QACf,MAAQ,QAAQ,SAChB,KAAO,QAAQ,QACf,SAAW,QAAQ,aAEnB,kBACJ,kBAAiB,kBACjB,kBAAiB,aACjB,cACE,QAAQ,YAEZ,SAAS,UAAW,EAAS,GAC3B,MAAM,EAAY,UAAU,EAAO,KAAK,cAExC,OAAO,MAAM,GAAG,IAAY,IAC9B,CAEA,SAAS,WAAY,GACnB,OAAO,SACJ,QACC,EACA,kBACA,CAAC,EACD,kBAEN,CAEA,SAAS,oBAAqB,GAC5B,OAAO,EACH,KAAK,QAAQ,EAAU,CAAE,MAAO,gBAAiB,IACjD,EACN,CAEA,QAAQ,QAAU,gBAAgB,UAAE,EAAS,SAAE,EAAQ,WAAE,IACvD,MAAM,EAAkB,oBAAoB,GACtC,EAAc,KAAK,KAAK,GAuB9B,aArBuB,QAAQ,IAC7B,EACG,QAAO,GAAuC,UAA3B,KAAK,QAAQ,KAChC,KAAI,UACH,MAAM,EAAW,KAAK,SAAS,GACzB,EAAc,GAAG,aAAa,GAAU,WAE9C,MAAO,CACL,WACA,QAAS,QACC,WAAW,GACjB,EACN,MAIkB,KAAI,EAAG,WAAU,cAAc,CACrD,WACA,QAAS,UAAU,EAAQ,KAAM,CAAC,aAAc,OAIpD,EAEA,QAAQ,KAAO,UAAU,OAAE,EAAM,OAAE,IACjC,MAAM,EAAa,KAAK,IAEnB,GAAG,WAAW,IACjB,GAAG,UAAU,GAGf,EAAO,SAAQ,GACb,GAAG,cAAc,GAAG,KAAc,EAAM,WAAY,EAAM,UAE9D","file":"/npm/zeev-mail@0.3.0/lib/compiler.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/zeev-mail@0.3.0/lib/compiler.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","const fs = require('fs')\nconst path = require('path')\nconst sass = require('sass')\nconst juice = require('juice')\nconst glob = require('glob')\nconst htmlnano = require('htmlnano')\n\nconst {\n  HTML_NANO_OPTIONS,\n  POST_HTML_OPTIONS,\n  LOCAL_STYLES\n} = require('./config')\n\nfunction cssInline (content, styles) {\n  const allStyles = `<style>${styles.join('')}</style>`\n\n  return juice(`${allStyles}${content}`)\n}\n\nfunction htmlMinify (content) {\n  return htmlnano\n    .process(\n      content,\n      HTML_NANO_OPTIONS,\n      {},\n      POST_HTML_OPTIONS\n    )\n}\n\nfunction resolveExternalSass (sasspath) {\n  return sasspath\n    ? sass.compile(sasspath, { style: 'compressed' })?.css\n    : ''\n}\n\nexports.compile = async function ({ inputGlob, sasspath, minifyHtml }) {\n  const EXTERNAL_STYLES = resolveExternalSass(sasspath)\n  const INPUT_FILES = glob.sync(inputGlob)\n\n  const contents = await Promise.all(\n    INPUT_FILES\n      .filter(filepath => path.extname(filepath) === '.html')\n      .map(async filepath => {\n        const filename = path.basename(filepath)\n        const filecontent = fs.readFileSync(filepath).toString()\n\n        return {\n          filename,\n          content: minifyHtml\n            ? await htmlMinify(filecontent)\n            : filecontent\n        }\n      })\n  )\n\n  const emails = contents.map(({ filename, content }) => ({\n    filename,\n    content: cssInline(content.html, [LOCAL_STYLES, EXTERNAL_STYLES])\n  }))\n\n  return emails\n}\n\nexports.save = function ({ emails, outdir }) {\n  const OUTPUT_DIR = `./${outdir}`\n\n  if (!fs.existsSync(OUTPUT_DIR)) {\n    fs.mkdirSync(OUTPUT_DIR)\n  }\n\n  emails.forEach(email =>\n    fs.writeFileSync(`${OUTPUT_DIR}/${email.filename}`, email.content)\n  )\n}\n"]}