{"version":3,"sources":["jsdelivr-header.js","/npm/alfred-workflow-translate@1.0.2/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACNA,MAAM,KAAO,QAAQ,QACf,UAAY,QAAQ,gCAEnB,OAAQ,UAAW,YAAc,KAAK,MAAM,MAAM,KACnD,MAAQ,WAAW,KAAK,KAE9B,UAAU,CAAE,KAAM,MAAO,cAAQ,gBAC9B,MAAK,SAAS,GACb,IAAK,EAEH,YADA,KAAK,OAAO,CAAC,CAAE,MAAO,2BAIxB,MAAM,EAAe,GAErB,GAAI,EAAO,KAAM,CACf,MAAM,EAAS,CAAC,EACV,EAAa,CAAC,EAEpB,EAAO,KAAK,SAAQ,IAClB,EAAI,MAAM,SAAQ,IAChB,EAAO,EAAM,MAAQ,EAAO,EAAM,OAAS,GAC3C,EAAO,EAAM,MAAM,KAAK,EAAI,KAE5B,EAAW,EAAM,MAAQ,KAAK,IAC5B,EAAM,MACN,EAAW,EAAM,OAAS,EAC3B,GACD,IAGJ,OAAO,KAAK,GAAY,SAAQ,IAC9B,EAAa,KAAK,CAChB,YAAa,EACb,MAAO,EAAW,GAClB,cAAe,EAAO,IACtB,GAEN,CAEA,GAAI,EAAO,YAAa,CACtB,MAAM,EAAU,EAAa,MAC3B,GAAK,EAAE,cAAgB,EAAO,cAE5B,EACF,EAAQ,MAAQ,EAEhB,EAAa,KAAK,CAAE,YAAa,EAAO,YAAa,MAAO,GAEhE,CAEA,EAAa,MAAK,CAAC,EAAG,IAAM,EAAE,MAAQ,EAAE,QAExC,MAAM,EAAQ,EAAa,KAAI,EAAG,cAAa,oBAAoB,CACjE,MAAO,EACP,UAAW,GAAiB,IAAI,KAAK,MACrC,IAAK,MAGP,KAAK,OAAO,EACd,IACC,OAAM,IACL,QAAQ,IAAI,MAAO,EAAI","file":"/npm/alfred-workflow-translate@1.0.2/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/alfred-workflow-translate@1.0.2/index.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 alfy = require(\"alfy\");\nconst translate = require(\"node-google-translate-skidz\");\n\nconst [source, target, ...queryWords] = alfy.input.split(\" \");\nconst query = queryWords.join(\" \")\n\ntranslate({ text: query, source, target })\n  .then(function(result) {\n    if (!result) {\n      alfy.output([{ title: \"No translations found\" }]);\n      return;\n    }\n\n    const translations = [];\n\n    if (result.dict) {\n      const posMap = {};\n      const wordScores = {};\n\n      result.dict.forEach(pos => {\n        pos.entry.forEach(entry => {\n          posMap[entry.word] = posMap[entry.word] || [];\n          posMap[entry.word].push(pos.pos);\n\n          wordScores[entry.word] = Math.max(\n            entry.score,\n            wordScores[entry.word] || 0\n          );\n        });\n      });\n\n      Object.keys(wordScores).forEach(word => {\n        translations.push({\n          translation: word,\n          score: wordScores[word],\n          partsOfSpeech: posMap[word]\n        });\n      });\n    }\n\n    if (result.translation) {\n      const current = translations.find(\n        t => t.translation === result.translation\n      );\n      if (current) {\n        current.score = 1.0;\n      } else {\n        translations.push({ translation: result.translation, score: 1.0 });\n      }\n    }\n\n    translations.sort((a, b) => b.score - a.score);\n\n    const items = translations.map(({ translation, partsOfSpeech }) => ({\n      title: translation,\n      subtitle: (partsOfSpeech || []).join(\", \"),\n      arg: translation\n    }));\n\n    alfy.output(items);\n  })\n  .catch(err => {\n    console.log(\"err\", err);\n  });\n"]}