"use strict";exports.__esModule=true;exports.getFontDefinitionFromNetwork=getFontDefinitionFromNetwork;exports.getFontDefinitionFromManifest=getFontDefinitionFromManifest;var Log=_interopRequireWildcard(require("../../build/output/log"));function _getRequireWildcardCache(){if(typeof WeakMap!=="function")return null;var cache=new WeakMap();_getRequireWildcardCache=function(){return cache;};return cache;}function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj;}if(obj===null||typeof obj!=="object"&&typeof obj!=="function"){return{default:obj};}var cache=_getRequireWildcardCache();if(cache&&cache.has(obj)){return cache.get(obj);}var newObj={};var hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;if(desc&&(desc.get||desc.set)){Object.defineProperty(newObj,key,desc);}else{newObj[key]=obj[key];}}}newObj.default=obj;if(cache){cache.set(obj,newObj);}return newObj;}const https=require('https');const CHROME_UA='Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36';const IE_UA='Mozilla/5.0 (Windows NT 10.0; Trident/7.0; rv:11.0) like Gecko';function getFontForUA(url,UA){return new Promise((resolve,reject)=>{let rawData='';https.get(url,{headers:{'user-agent':UA}},res=>{res.on('data',chunk=>{rawData+=chunk;});res.on('end',()=>{resolve(rawData.toString('utf8'));});}).on('error',e=>{reject(e);});});}async function getFontDefinitionFromNetwork(url){let result='';/**
   * The order of IE -> Chrome is important, other wise chrome starts loading woff1.
   * CSS cascading 🤷‍♂️.
   */try{result+=await getFontForUA(url,IE_UA);result+=await getFontForUA(url,CHROME_UA);}catch(e){Log.warn(`Failed to download the stylesheet for ${url}. Skipped optimizing this font.`);return'';}return result;}function getFontDefinitionFromManifest(url,manifest){var _manifest$find;return((_manifest$find=manifest.find(font=>{if(font&&font.url===url){return true;}return false;}))==null?void 0:_manifest$find.content)||'';}
//# sourceMappingURL=font-utils.js.map