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,IAAIC,GAAgB,CAClB,IAAAC,EACA,QAAAL,GACA,iBAAAC,GACA,kBAAAC,GACA,gBAAAC,EACF","names":["KWH_PER_BYTE_FOR_NETWORK","OneByte","options","KWH_PER_BYTE_FOR_NETWORK","bytes","green","Co2ForDC","Co2forNetwork","KwHPerByte","byte_default","fileSize","KWH_PER_GB","END_USER_DEVICE_ENERGY","NETWORK_ENERGY","DATACENTER_ENERGY","PRODUCTION_ENERGY","GLOBAL_GRID_INTENSITY","RENEWABLES_GRID_INTENSITY","FIRST_TIME_VIEWING_PERCENTAGE","RETURNING_VISITOR_PERCENTAGE","PERCENTAGE_OF_DATA_LOADED_ON_SUBSEQUENT_LOAD","formatNumber","outputRating","__defProp","__defProps","__getOwnPropDescs","__getOwnPropSymbols","__hasOwnProp","__propIsEnum","__defNormalProp","obj","key","value","__spreadValues","a","b","prop","__spreadProps","SustainableWebDesign","options","bytes","energyUsage","energyByComponent","carbonIntensity","deviceCarbonIntensity","networkCarbonIntensity","dataCenterCarbonIntensity","globalEmissions","device","network","dataCenter","returnCO2ByComponent","segmentResults","ratingResults","energyBycomponent","co2ValuesbyComponent","co2ValuesSum","prevValue","currentValue","rating","firstView","returnView","dataReloadRatio","cacheAdjustedSegmentEnergy","energyValues","firstVisits","subsequentVisits","val","energyPerVisit","carbonintensity","monthlyVisitors","co2grams","annualEnergy","co2e","sustainable_web_design_v3_default","fileSize","SWDV4","outputRating","__defProp","__defProps","__getOwnPropDescs","__getOwnPropSymbols","__hasOwnProp","__propIsEnum","__defNormalProp","obj","key","value","__spreadValues","a","b","prop","__spreadProps","OPERATIONAL_KWH_PER_GB_DATACENTER","OPERATIONAL_KWH_PER_GB_NETWORK","OPERATIONAL_KWH_PER_GB_DEVICE","EMBODIED_KWH_PER_GB_DATACENTER","EMBODIED_KWH_PER_GB_NETWORK","EMBODIED_KWH_PER_GB_DEVICE","GLOBAL_GRID_INTENSITY","outputSegments","operationalEmissions","embodiedEmissions","totalOperationalCO2e","totalEmbodiedCO2e","dataCenterCO2e","networkCO2e","consumerDeviceCO2e","getGreenHostingFactor","green","options","SustainableWebDesign","bytes","transferedBytesToGb","dataCenter","network","device","dataCenterGridIntensity","networkGridIntensity","deviceGridIntensity","device2","network2","dataCenter2","dataCenterEmissions","networkEmissions","deviceEmissions","segmented","ratingResults","greenHostingFactor","totalEmissions","total","rating","segments","firstViewRatio","returnViewRatio","dataReloadRatio","firstVisitEmissions","returnVisitEmissions","co2e","sustainable_web_design_v4_default","parseByteTraceOptions","parseVisitTraceOptions","__defProp","__getOwnPropSymbols","__hasOwnProp","__propIsEnum","__defNormalProp","obj","key","value","__spreadValues","a","b","prop","__objRest","source","exclude","target","CO2","options","sustainable_web_design_v4_default","byte_default","sustainable_web_design_v3_default","allowRatings","bytes","green","_a","adjustments","gridIntensity","_b","dataReloadRatio","firstVisitPercentage","returnVisitPercentage","otherVariables","variables","co2_default","hosting","averageIntensity","marginalIntensity","electricityMaps","index_default","co2_default"],"sources":["../esm/npm/@tgwf/co2@0.19.0/node_modules/@tgwf/co2/dist/esm/1byte.js","../esm/npm/@tgwf/co2@0.19.0/node_modules/@tgwf/co2/dist/esm/sustainable-web-design-v3.js","../esm/npm/@tgwf/co2@0.19.0/node_modules/@tgwf/co2/dist/esm/sustainable-web-design-v4.js","../esm/npm/@tgwf/co2@0.19.0/node_modules/@tgwf/co2/dist/esm/co2.js","../esm/npm/@tgwf/co2@0.19.0/node_modules/@tgwf/co2/dist/esm/index.js"],"sourcesContent":["const CO2_PER_KWH_IN_DC_GREY = 519;\nconst CO2_PER_KWH_NETWORK_GREY = 475;\nconst CO2_PER_KWH_IN_DC_GREEN = 0;\nconst KWH_PER_BYTE_IN_DC = 72e-12;\nconst FIXED_NETWORK_WIRED = 429e-12;\nconst FIXED_NETWORK_WIFI = 152e-12;\nconst FOUR_G_MOBILE = 884e-12;\nconst KWH_PER_BYTE_FOR_NETWORK = (FIXED_NETWORK_WIRED + FIXED_NETWORK_WIFI + FOUR_G_MOBILE) / 3;\nconst KWH_PER_BYTE_FOR_DEVICES = 13e-11;\nclass OneByte {\n  constructor(options) {\n    this.allowRatings = false;\n    this.options = options;\n    this.KWH_PER_BYTE_FOR_NETWORK = KWH_PER_BYTE_FOR_NETWORK;\n  }\n  /**\n   * Calculates the carbon footprint of a website using the OneByte model\n   * @param {number} bytes - The number of bytes to calculate the carbon footprint for\n   * @param {boolean} green - Whether the energy is green or not\n   * @returns {number} The carbon footprint in grams of CO2\n   */\n  perByte(bytes, green) {\n    if (bytes \u003c 1) {\n      return 0;\n    }\n    if (green) {\n      const Co2ForDC = bytes * KWH_PER_BYTE_IN_DC * CO2_PER_KWH_IN_DC_GREEN;\n      const Co2forNetwork = bytes * KWH_PER_BYTE_FOR_NETWORK * CO2_PER_KWH_NETWORK_GREY;\n      return Co2ForDC + Co2forNetwork;\n    }\n    const KwHPerByte = KWH_PER_BYTE_IN_DC + KWH_PER_BYTE_FOR_NETWORK;\n    return bytes * KwHPerByte * CO2_PER_KWH_IN_DC_GREY;\n  }\n}\nvar byte_default = OneByte;\nexport {\n  OneByte,\n  byte_default as default\n};\n","var __defProp = Object.defineProperty;\nvar __defProps = Object.defineProperties;\nvar __getOwnPropDescs = Object.getOwnPropertyDescriptors;\nvar __getOwnPropSymbols = Object.getOwnPropertySymbols;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __propIsEnum = Object.prototype.propertyIsEnumerable;\nvar __defNormalProp = (obj, key, value) =\u003e key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;\nvar __spreadValues = (a, b) =\u003e {\n  for (var prop in b || (b = {}))\n    if (__hasOwnProp.call(b, prop))\n      __defNormalProp(a, prop, b[prop]);\n  if (__getOwnPropSymbols)\n    for (var prop of __getOwnPropSymbols(b)) {\n      if (__propIsEnum.call(b, prop))\n        __defNormalProp(a, prop, b[prop]);\n    }\n  return a;\n};\nvar __spreadProps = (a, b) =\u003e __defProps(a, __getOwnPropDescs(b));\nimport {\n  fileSize,\n  KWH_PER_GB,\n  END_USER_DEVICE_ENERGY,\n  NETWORK_ENERGY,\n  DATACENTER_ENERGY,\n  PRODUCTION_ENERGY,\n  GLOBAL_GRID_INTENSITY,\n  RENEWABLES_GRID_INTENSITY,\n  FIRST_TIME_VIEWING_PERCENTAGE,\n  RETURNING_VISITOR_PERCENTAGE,\n  PERCENTAGE_OF_DATA_LOADED_ON_SUBSEQUENT_LOAD\n} from \"./constants/index.js\";\nimport { formatNumber, outputRating } from \"./helpers/index.js\";\nclass SustainableWebDesign {\n  constructor(options) {\n    this.allowRatings = true;\n    this.options = options;\n    this.version = 3;\n  }\n  /**\n   * Accept a figure for bytes transferred and return an object representing\n   * the share of the total enrgy use of the entire system, broken down\n   * by each corresponding system component\n   *\n   * @param {number}  bytes - the data transferred in bytes\n   * @return {object} Object containing the energy in kilowatt hours, keyed by system component\n   */\n  energyPerByteByComponent(bytes) {\n    const transferedBytesToGb = bytes / fileSize.GIGABYTE;\n    const energyUsage = transferedBytesToGb * KWH_PER_GB;\n    return {\n      consumerDeviceEnergy: energyUsage * END_USER_DEVICE_ENERGY,\n      networkEnergy: energyUsage * NETWORK_ENERGY,\n      productionEnergy: energyUsage * PRODUCTION_ENERGY,\n      dataCenterEnergy: energyUsage * DATACENTER_ENERGY\n    };\n  }\n  /**\n   * Accept an object keys by the different system components, and\n   * return an object with the co2 figures key by the each component\n   *\n   * @param {object} energyByComponent - energy grouped by the four system components\n   * @param {number} [carbonIntensity] - carbon intensity to apply to the datacentre values\n   * @return {number} the total number in grams of CO2 equivalent emissions\n   */\n  co2byComponent(energyByComponent, carbonIntensity = GLOBAL_GRID_INTENSITY, options = {}) {\n    let deviceCarbonIntensity = GLOBAL_GRID_INTENSITY;\n    let networkCarbonIntensity = GLOBAL_GRID_INTENSITY;\n    let dataCenterCarbonIntensity = GLOBAL_GRID_INTENSITY;\n    let globalEmissions = GLOBAL_GRID_INTENSITY;\n    if (options == null ? void 0 : options.gridIntensity) {\n      const { device, network, dataCenter } = options.gridIntensity;\n      if ((device == null ? void 0 : device.value) || (device == null ? void 0 : device.value) === 0) {\n        deviceCarbonIntensity = device.value;\n      }\n      if ((network == null ? void 0 : network.value) || (network == null ? void 0 : network.value) === 0) {\n        networkCarbonIntensity = network.value;\n      }\n      if ((dataCenter == null ? void 0 : dataCenter.value) || (dataCenter == null ? void 0 : dataCenter.value) === 0) {\n        dataCenterCarbonIntensity = dataCenter.value;\n      }\n    }\n    if (carbonIntensity === true) {\n      dataCenterCarbonIntensity = RENEWABLES_GRID_INTENSITY;\n    }\n    const returnCO2ByComponent = {};\n    for (const [key, value] of Object.entries(energyByComponent)) {\n      if (key.startsWith(\"dataCenterEnergy\")) {\n        returnCO2ByComponent[key.replace(\"Energy\", \"CO2\")] = value * dataCenterCarbonIntensity;\n      } else if (key.startsWith(\"consumerDeviceEnergy\")) {\n        returnCO2ByComponent[key.replace(\"Energy\", \"CO2\")] = value * deviceCarbonIntensity;\n      } else if (key.startsWith(\"networkEnergy\")) {\n        returnCO2ByComponent[key.replace(\"Energy\", \"CO2\")] = value * networkCarbonIntensity;\n      } else {\n        returnCO2ByComponent[key.replace(\"Energy\", \"CO2\")] = value * globalEmissions;\n      }\n    }\n    return returnCO2ByComponent;\n  }\n  /**\n   * Accept a figure for bytes transferred and return a single figure for CO2\n   * emissions. Where information exists about the origin data is being\n   * fetched from, a different carbon intensity figure\n   * is applied for the data centre share of the carbon intensity.\n   *\n   * @param {number} bytes - the data transferred in bytes\n   * @param {boolean} carbonIntensity - a boolean indicating whether the data center is green or not\n   * @param {boolean} segmentResults - a boolean indicating whether to return the results broken down by component\n   * @param {boolean} ratingResults - a boolean indicating whether to return the rating based on the Sustainable Web Design Model\n   * @param {object} options - an object containing the grid intensity and first/return visitor values\n   * @return {number|object} the total number in grams of CO2 equivalent emissions, or an object containing the breakdown by component\n   */\n  perByte(bytes, carbonIntensity = false, segmentResults = false, ratingResults = false, options = {}) {\n    if (bytes \u003c 1) {\n      bytes = 0;\n    }\n    const energyBycomponent = this.energyPerByteByComponent(bytes, options);\n    if (typeof carbonIntensity !== \"boolean\") {\n      throw new Error(\n        \"perByte expects a boolean for the carbon intensity value. Received: \".concat(carbonIntensity)\n      );\n    }\n    const co2ValuesbyComponent = this.co2byComponent(\n      energyBycomponent,\n      carbonIntensity,\n      options\n    );\n    const co2Values = Object.values(co2ValuesbyComponent);\n    const co2ValuesSum = co2Values.reduce(\n      (prevValue, currentValue) =\u003e prevValue + currentValue\n    );\n    let rating = null;\n    if (ratingResults) {\n      rating = this.ratingScale(co2ValuesSum);\n    }\n    if (segmentResults) {\n      if (ratingResults) {\n        return __spreadProps(__spreadValues({}, co2ValuesbyComponent), {\n          total: co2ValuesSum,\n          rating\n        });\n      }\n      return __spreadProps(__spreadValues({}, co2ValuesbyComponent), { total: co2ValuesSum });\n    }\n    if (ratingResults) {\n      return { total: co2ValuesSum, rating };\n    }\n    return co2ValuesSum;\n  }\n  /**\n   * Accept a figure for bytes transferred and return a single figure for CO2\n   * emissions. This method applies caching assumptions from the original Sustainable Web Design model.\n   *\n   * @param {number} bytes - the data transferred in bytes\n   * @param {boolean} carbonIntensity - a boolean indicating whether the data center is green or not\n   * @param {boolean} segmentResults - a boolean indicating whether to return the results broken down by component\n   * @param {boolean} ratingResults - a boolean indicating whether to return the rating based on the Sustainable Web Design Model\n   * @param {object} options - an object containing the grid intensity and first/return visitor values\n   * @return {number|object} the total number in grams of CO2 equivalent emissions, or an object containing the breakdown by component\n   */\n  perVisit(bytes, carbonIntensity = false, segmentResults = false, ratingResults = false, options = {}) {\n    const energyBycomponent = this.energyPerVisitByComponent(bytes, options);\n    if (typeof carbonIntensity !== \"boolean\") {\n      throw new Error(\n        \"perVisit expects a boolean for the carbon intensity value. Received: \".concat(carbonIntensity)\n      );\n    }\n    const co2ValuesbyComponent = this.co2byComponent(\n      energyBycomponent,\n      carbonIntensity,\n      options\n    );\n    const co2Values = Object.values(co2ValuesbyComponent);\n    const co2ValuesSum = co2Values.reduce(\n      (prevValue, currentValue) =\u003e prevValue + currentValue\n    );\n    let rating = null;\n    if (ratingResults) {\n      rating = this.ratingScale(co2ValuesSum);\n    }\n    if (segmentResults) {\n      if (ratingResults) {\n        return __spreadProps(__spreadValues({}, co2ValuesbyComponent), {\n          total: co2ValuesSum,\n          rating\n        });\n      }\n      return __spreadProps(__spreadValues({}, co2ValuesbyComponent), { total: co2ValuesSum });\n    }\n    if (ratingResults) {\n      return { total: co2ValuesSum, rating };\n    }\n    return co2ValuesSum;\n  }\n  /**\n   * Accept a figure for bytes transferred and return the number of kilowatt hours used\n   * by the total system for this data transfer\n   *\n   * @param {number} bytes\n   * @return {number} the number of kilowatt hours used\n   */\n  energyPerByte(bytes) {\n    const energyByComponent = this.energyPerByteByComponent(bytes);\n    const energyValues = Object.values(energyByComponent);\n    return energyValues.reduce(\n      (prevValue, currentValue) =\u003e prevValue + currentValue\n    );\n  }\n  /**\n   * Accept a figure for bytes transferred, and return an object containing figures\n   * per system component, with the caching assumptions applied. This tries to account\n   * for webpages being loaded from a cache by browsers, so if you had a thousand page views,\n   * and tried to work out the energy per visit, the numbers would reflect the reduced amounts\n   * of transfer.\n   *\n   * @param {number} bytes - the data transferred in bytes for loading a webpage\n   * @param {number} firstView - what percentage of visits are loading this page for the first time\n   * @param {number} returnView - what percentage of visits are loading this page for subsequent times\n   * @param {number} dataReloadRatio - what percentage of a page is reloaded on each subsequent page view\n   *\n   * @return {object} Object containing the energy in kilowatt hours, keyed by system component\n   */\n  energyPerVisitByComponent(bytes, options = {}, firstView = FIRST_TIME_VIEWING_PERCENTAGE, returnView = RETURNING_VISITOR_PERCENTAGE, dataReloadRatio = PERCENTAGE_OF_DATA_LOADED_ON_SUBSEQUENT_LOAD) {\n    if (options.dataReloadRatio || options.dataReloadRatio === 0) {\n      dataReloadRatio = options.dataReloadRatio;\n    }\n    if (options.firstVisitPercentage || options.firstVisitPercentage === 0) {\n      firstView = options.firstVisitPercentage;\n    }\n    if (options.returnVisitPercentage || options.returnVisitPercentage === 0) {\n      returnView = options.returnVisitPercentage;\n    }\n    const energyBycomponent = this.energyPerByteByComponent(bytes);\n    const cacheAdjustedSegmentEnergy = {};\n    const energyValues = Object.values(energyBycomponent);\n    for (const [key, value] of Object.entries(energyBycomponent)) {\n      cacheAdjustedSegmentEnergy[\"\".concat(key, \" - first\")] = value * firstView;\n      cacheAdjustedSegmentEnergy[\"\".concat(key, \" - subsequent\")] = value * returnView * dataReloadRatio;\n    }\n    return cacheAdjustedSegmentEnergy;\n  }\n  /**\n   * Accept a figure for bytes, and return the total figure for energy per visit\n   * using the default caching assumptions for loading a single website\n   *\n   * @param {number} bytes\n   * @return {number} the total energy use for the visit, after applying the caching assumptions\n   */\n  energyPerVisit(bytes) {\n    let firstVisits = 0;\n    let subsequentVisits = 0;\n    const energyBycomponent = Object.entries(\n      this.energyPerVisitByComponent(bytes)\n    );\n    for (const [key, val] of energyBycomponent) {\n      if (key.indexOf(\"first\") \u003e 0) {\n        firstVisits += val;\n      }\n    }\n    for (const [key, val] of energyBycomponent) {\n      if (key.indexOf(\"subsequent\") \u003e 0) {\n        subsequentVisits += val;\n      }\n    }\n    return firstVisits + subsequentVisits;\n  }\n  emissionsPerVisitInGrams(energyPerVisit, carbonintensity = GLOBAL_GRID_INTENSITY) {\n    return formatNumber(energyPerVisit * carbonintensity);\n  }\n  annualEnergyInKwh(energyPerVisit, monthlyVisitors = 1e3) {\n    return energyPerVisit * monthlyVisitors * 12;\n  }\n  annualEmissionsInGrams(co2grams, monthlyVisitors = 1e3) {\n    return co2grams * monthlyVisitors * 12;\n  }\n  annualSegmentEnergy(annualEnergy) {\n    return {\n      consumerDeviceEnergy: formatNumber(annualEnergy * END_USER_DEVICE_ENERGY),\n      networkEnergy: formatNumber(annualEnergy * NETWORK_ENERGY),\n      dataCenterEnergy: formatNumber(annualEnergy * DATACENTER_ENERGY),\n      productionEnergy: formatNumber(annualEnergy * PRODUCTION_ENERGY)\n    };\n  }\n  /**\n   * Determines the rating of a website's sustainability based on its CO2 emissions.\n   *\n   * @param {number} co2e - The CO2 emissions of the website in grams.\n   * @returns {string} The sustainability rating, ranging from \"A+\" (best) to \"F\" (worst).\n   */\n  ratingScale(co2e) {\n    return outputRating(co2e, this.version);\n  }\n}\nvar sustainable_web_design_v3_default = SustainableWebDesign;\nexport {\n  SustainableWebDesign,\n  sustainable_web_design_v3_default as default\n};\n","var __defProp = Object.defineProperty;\nvar __defProps = Object.defineProperties;\nvar __getOwnPropDescs = Object.getOwnPropertyDescriptors;\nvar __getOwnPropSymbols = Object.getOwnPropertySymbols;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __propIsEnum = Object.prototype.propertyIsEnumerable;\nvar __defNormalProp = (obj, key, value) =\u003e key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;\nvar __spreadValues = (a, b) =\u003e {\n  for (var prop in b || (b = {}))\n    if (__hasOwnProp.call(b, prop))\n      __defNormalProp(a, prop, b[prop]);\n  if (__getOwnPropSymbols)\n    for (var prop of __getOwnPropSymbols(b)) {\n      if (__propIsEnum.call(b, prop))\n        __defNormalProp(a, prop, b[prop]);\n    }\n  return a;\n};\nvar __spreadProps = (a, b) =\u003e __defProps(a, __getOwnPropDescs(b));\nimport { fileSize, SWDV4 } from \"./constants/index.js\";\nimport { outputRating } from \"./helpers/index.js\";\nconst {\n  OPERATIONAL_KWH_PER_GB_DATACENTER,\n  OPERATIONAL_KWH_PER_GB_NETWORK,\n  OPERATIONAL_KWH_PER_GB_DEVICE,\n  EMBODIED_KWH_PER_GB_DATACENTER,\n  EMBODIED_KWH_PER_GB_NETWORK,\n  EMBODIED_KWH_PER_GB_DEVICE,\n  GLOBAL_GRID_INTENSITY\n} = SWDV4;\nfunction outputSegments(operationalEmissions, embodiedEmissions) {\n  const totalOperationalCO2e = operationalEmissions.dataCenter + operationalEmissions.network + operationalEmissions.device;\n  const totalEmbodiedCO2e = embodiedEmissions.dataCenter + embodiedEmissions.network + embodiedEmissions.device;\n  const dataCenterCO2e = operationalEmissions.dataCenter + embodiedEmissions.dataCenter;\n  const networkCO2e = operationalEmissions.network + embodiedEmissions.network;\n  const consumerDeviceCO2e = operationalEmissions.device + embodiedEmissions.device;\n  return {\n    dataCenterOperationalCO2e: operationalEmissions.dataCenter,\n    networkOperationalCO2e: operationalEmissions.network,\n    consumerDeviceOperationalCO2e: operationalEmissions.device,\n    dataCenterEmbodiedCO2e: embodiedEmissions.dataCenter,\n    networkEmbodiedCO2e: embodiedEmissions.network,\n    consumerDeviceEmbodiedCO2e: embodiedEmissions.device,\n    totalEmbodiedCO2e,\n    totalOperationalCO2e,\n    dataCenterCO2e,\n    networkCO2e,\n    consumerDeviceCO2e\n  };\n}\nfunction getGreenHostingFactor(green, options) {\n  if (green) {\n    return 1;\n  } else if ((options == null ? void 0 : options.greenHostingFactor) || (options == null ? void 0 : options.greenHostingFactor) === 0) {\n    return options.greenHostingFactor;\n  }\n  return 0;\n}\nclass SustainableWebDesign {\n  constructor(options) {\n    this.allowRatings = true;\n    this.options = options;\n    this.version = 4;\n  }\n  /**\n   * Calculate the operational energy of data transfer for each system segment\n   *\n   * @param {number} bytes\n   * @returns {object}\n   */\n  operationalEnergyPerSegment(bytes) {\n    const transferedBytesToGb = bytes / fileSize.GIGABYTE;\n    const dataCenter = transferedBytesToGb * OPERATIONAL_KWH_PER_GB_DATACENTER;\n    const network = transferedBytesToGb * OPERATIONAL_KWH_PER_GB_NETWORK;\n    const device = transferedBytesToGb * OPERATIONAL_KWH_PER_GB_DEVICE;\n    return {\n      dataCenter,\n      network,\n      device\n    };\n  }\n  /**\n   * Calculate the operational emissions of data transfer for each system segment\n   *\n   * @param {number} bytes\n   * @param {object} options\n   * @returns {object}\n   */\n  operationalEmissions(bytes, options = {}) {\n    const { dataCenter, network, device } = this.operationalEnergyPerSegment(bytes);\n    let dataCenterGridIntensity = GLOBAL_GRID_INTENSITY;\n    let networkGridIntensity = GLOBAL_GRID_INTENSITY;\n    let deviceGridIntensity = GLOBAL_GRID_INTENSITY;\n    if (options == null ? void 0 : options.gridIntensity) {\n      const { device: device2, network: network2, dataCenter: dataCenter2 } = options.gridIntensity;\n      if ((device2 == null ? void 0 : device2.value) || (device2 == null ? void 0 : device2.value) === 0) {\n        deviceGridIntensity = device2.value;\n      }\n      if ((network2 == null ? void 0 : network2.value) || (network2 == null ? void 0 : network2.value) === 0) {\n        networkGridIntensity = network2.value;\n      }\n      if ((dataCenter2 == null ? void 0 : dataCenter2.value) || (dataCenter2 == null ? void 0 : dataCenter2.value) === 0) {\n        dataCenterGridIntensity = dataCenter2.value;\n      }\n    }\n    const dataCenterEmissions = dataCenter * dataCenterGridIntensity;\n    const networkEmissions = network * networkGridIntensity;\n    const deviceEmissions = device * deviceGridIntensity;\n    return {\n      dataCenter: dataCenterEmissions,\n      network: networkEmissions,\n      device: deviceEmissions\n    };\n  }\n  /**\n   * Calculate the embodied energy of data transfer for each system segment\n   *\n   * @param {number} bytes\n   * @returns {object}\n   */\n  embodiedEnergyPerSegment(bytes) {\n    const transferedBytesToGb = bytes / fileSize.GIGABYTE;\n    const dataCenter = transferedBytesToGb * EMBODIED_KWH_PER_GB_DATACENTER;\n    const network = transferedBytesToGb * EMBODIED_KWH_PER_GB_NETWORK;\n    const device = transferedBytesToGb * EMBODIED_KWH_PER_GB_DEVICE;\n    return {\n      dataCenter,\n      network,\n      device\n    };\n  }\n  /**\n   * Calculate the embodied emissions of data transfer for each system segment\n   *\n   * @param {number} bytes\n   * @returns {object}\n   */\n  embodiedEmissions(bytes) {\n    const { dataCenter, network, device } = this.embodiedEnergyPerSegment(bytes);\n    const dataCenterGridIntensity = GLOBAL_GRID_INTENSITY;\n    const networkGridIntensity = GLOBAL_GRID_INTENSITY;\n    const deviceGridIntensity = GLOBAL_GRID_INTENSITY;\n    const dataCenterEmissions = dataCenter * dataCenterGridIntensity;\n    const networkEmissions = network * networkGridIntensity;\n    const deviceEmissions = device * deviceGridIntensity;\n    return {\n      dataCenter: dataCenterEmissions,\n      network: networkEmissions,\n      device: deviceEmissions\n    };\n  }\n  // NOTE: Setting green: true should result in a greenHostingFactor of 1.0\n  perByte(bytes, green = false, segmented = false, ratingResults = false, options = {}) {\n    if (bytes \u003c 1) {\n      return 0;\n    }\n    const operationalEmissions = this.operationalEmissions(bytes, options);\n    const embodiedEmissions = this.embodiedEmissions(bytes);\n    const greenHostingFactor = getGreenHostingFactor(green, options);\n    const totalEmissions = {\n      dataCenter: operationalEmissions.dataCenter * (1 - greenHostingFactor) + embodiedEmissions.dataCenter,\n      network: operationalEmissions.network + embodiedEmissions.network,\n      device: operationalEmissions.device + embodiedEmissions.device\n    };\n    const total = totalEmissions.dataCenter + totalEmissions.network + totalEmissions.device;\n    let rating = null;\n    if (ratingResults) {\n      rating = this.ratingScale(total);\n    }\n    if (segmented) {\n      const segments = __spreadValues({}, outputSegments(operationalEmissions, embodiedEmissions));\n      if (ratingResults) {\n        return __spreadProps(__spreadValues({}, segments), {\n          total,\n          rating\n        });\n      }\n      return __spreadProps(__spreadValues({}, segments), { total });\n    }\n    if (ratingResults) {\n      return { total, rating };\n    }\n    return total;\n  }\n  perVisit(bytes, green = false, segmented = false, ratingResults = false, options = {}) {\n    let firstViewRatio = 1;\n    let returnViewRatio = 0;\n    let dataReloadRatio = 0;\n    const greenHostingFactor = getGreenHostingFactor(green, options);\n    const operationalEmissions = this.operationalEmissions(bytes, options);\n    const embodiedEmissions = this.embodiedEmissions(bytes);\n    if (bytes \u003c 1) {\n      return 0;\n    }\n    if (options.firstVisitPercentage || options.firstVisitPercentage === 0) {\n      firstViewRatio = options.firstVisitPercentage;\n    }\n    if (options.returnVisitPercentage || options.returnVisitPercentage === 0) {\n      returnViewRatio = options.returnVisitPercentage;\n    }\n    if (options.dataReloadRatio || options.dataReloadRatio === 0) {\n      dataReloadRatio = options.dataReloadRatio;\n    }\n    const firstVisitEmissions = operationalEmissions.dataCenter * (1 - greenHostingFactor) + embodiedEmissions.dataCenter + operationalEmissions.network + embodiedEmissions.network + operationalEmissions.device + embodiedEmissions.device;\n    const returnVisitEmissions = firstVisitEmissions * dataReloadRatio;\n    const total = firstVisitEmissions * firstViewRatio + returnVisitEmissions * returnViewRatio;\n    let rating = null;\n    if (ratingResults) {\n      rating = this.ratingScale(total);\n    }\n    if (segmented) {\n      const segments = __spreadProps(__spreadValues({}, outputSegments(operationalEmissions, embodiedEmissions)), {\n        firstVisitCO2e: firstVisitEmissions,\n        returnVisitCO2e: returnVisitEmissions\n      });\n      if (ratingResults) {\n        return __spreadProps(__spreadValues({}, segments), {\n          total,\n          rating\n        });\n      }\n      return __spreadProps(__spreadValues({}, segments), { total });\n    }\n    if (ratingResults) {\n      return { total, rating };\n    }\n    return total;\n  }\n  /**\n   * Determines the rating of a website's sustainability based on its CO2 emissions.\n   *\n   * @param {number} co2e - The CO2 emissions of the website in grams.\n   * @returns {string} The sustainability rating, ranging from \"A+\" (best) to \"F\" (worst).\n   */\n  ratingScale(co2e) {\n    return outputRating(co2e, this.version);\n  }\n}\nvar sustainable_web_design_v4_default = SustainableWebDesign;\nexport {\n  SustainableWebDesign,\n  sustainable_web_design_v4_default as default\n};\n","var __defProp = Object.defineProperty;\nvar __getOwnPropSymbols = Object.getOwnPropertySymbols;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __propIsEnum = Object.prototype.propertyIsEnumerable;\nvar __defNormalProp = (obj, key, value) =\u003e key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;\nvar __spreadValues = (a, b) =\u003e {\n  for (var prop in b || (b = {}))\n    if (__hasOwnProp.call(b, prop))\n      __defNormalProp(a, prop, b[prop]);\n  if (__getOwnPropSymbols)\n    for (var prop of __getOwnPropSymbols(b)) {\n      if (__propIsEnum.call(b, prop))\n        __defNormalProp(a, prop, b[prop]);\n    }\n  return a;\n};\nvar __objRest = (source, exclude) =\u003e {\n  var target = {};\n  for (var prop in source)\n    if (__hasOwnProp.call(source, prop) \u0026\u0026 exclude.indexOf(prop) \u003c 0)\n      target[prop] = source[prop];\n  if (source != null \u0026\u0026 __getOwnPropSymbols)\n    for (var prop of __getOwnPropSymbols(source)) {\n      if (exclude.indexOf(prop) \u003c 0 \u0026\u0026 __propIsEnum.call(source, prop))\n        target[prop] = source[prop];\n    }\n  return target;\n};\nimport OneByte from \"./1byte.js\";\nimport SustainableWebDesignV3 from \"./sustainable-web-design-v3.js\";\nimport SustainableWebDesignV4 from \"./sustainable-web-design-v4.js\";\nimport {\n  parseByteTraceOptions,\n  parseVisitTraceOptions\n} from \"./helpers/index.js\";\nclass CO2 {\n  constructor(options) {\n    this.model = new SustainableWebDesignV4();\n    if ((options == null ? void 0 : options.model) === \"1byte\") {\n      this.model = new OneByte();\n    } else if ((options == null ? void 0 : options.model) === \"swd\") {\n      this.model = new SustainableWebDesignV4();\n      if ((options == null ? void 0 : options.version) === 3) {\n        this.model = new SustainableWebDesignV3();\n      } else if ((options == null ? void 0 : options.version) === 4) {\n        this.model = new SustainableWebDesignV4();\n      }\n    } else if (options == null ? void 0 : options.model) {\n      throw new Error(\n        '\"'.concat(options.model, '\" is not a valid model. Please use \"1byte\" for the OneByte model, and \"swd\" for the Sustainable Web Design model.\\nSee https://developers.thegreenwebfoundation.org/co2js/models/ to learn more about the models available in CO2.js.')\n      );\n    } else if (!(options == null ? void 0 : options.model) \u0026\u0026 (options == null ? void 0 : options.version)) {\n      throw new Error(\n        '\"Specified version '.concat(options == null ? void 0 : options.version, \" but an estimation model is missing. Please specify a model to use for the version you have set.\")\n      );\n    }\n    if ((options == null ? void 0 : options.rating) \u0026\u0026 typeof options.rating !== \"boolean\") {\n      throw new Error(\n        \"The rating option must be a boolean. Please use true or false.\\nSee https://developers.thegreenwebfoundation.org/co2js/options/ to learn more about the options available in CO2.js.\"\n      );\n    }\n    const allowRatings = !!this.model.allowRatings;\n    this._segment = (options == null ? void 0 : options.results) === \"segment\";\n    this._rating = (options == null ? void 0 : options.rating) === true;\n    if (!allowRatings \u0026\u0026 this._rating) {\n      throw new Error(\n        \"The rating system is not supported in the model you are using. Try using the Sustainable Web Design model instead.\\nSee https://developers.thegreenwebfoundation.org/co2js/models/ to learn more about the models available in CO2.js.\"\n      );\n    }\n  }\n  /**\n   * Accept a figure in bytes for data transfer, and a boolean for whether\n   * the domain shows as 'green', and return a CO2 figure for energy used to shift the corresponding\n   * the data transfer.\n   *\n   * @param {number} bytes\n   * @param {boolean} green\n   * @return {number|CO2EstimateComponentsPerByte} the amount of CO2 in grammes or its separate components\n   */\n  perByte(bytes, green = false) {\n    return this.model.perByte(bytes, green, this._segment, this._rating);\n  }\n  /**\n   * Accept a figure in bytes for data transfer, and a boolean for whether\n   * the domain shows as 'green', and return a CO2 figure for energy used to shift the corresponding\n   * the data transfer.\n   *\n   * @param {number} bytes\n   * @param {boolean} green\n   * @return {number|CO2EstimateComponentsPerVisit} the amount of CO2 in grammes or its separate components\n   */\n  perVisit(bytes, green = false) {\n    var _a;\n    if ((_a = this.model) == null ? void 0 : _a.perVisit) {\n      return this.model.perVisit(bytes, green, this._segment, this._rating);\n    } else {\n      throw new Error(\n        \"The perVisit() method is not supported in the model you are using. Try using perByte() instead.\\nSee https://developers.thegreenwebfoundation.org/co2js/methods/ to learn more about the methods available in CO2.js.\"\n      );\n    }\n  }\n  /**\n   * Accept a figure in bytes for data transfer, a boolean for whether\n   * the domain shows as 'green', and an options object.\n   * Returns an object containing CO2 figure, green boolean, and object of the variables used in calculating the CO2 figure.\n   *\n   * @param {number} bytes\n   * @param {boolean} green\n   * @param {Object} options\n   * @return {CO2EstimateTraceResultPerByte} the amount of CO2 in grammes\n   */\n  perByteTrace(bytes, green = false, options = {}) {\n    const adjustments = parseByteTraceOptions(\n      options,\n      this.model.version,\n      green\n    );\n    const _a = adjustments, { gridIntensity } = _a, traceVariables = __objRest(_a, [\"gridIntensity\"]);\n    const _b = traceVariables, {\n      dataReloadRatio,\n      firstVisitPercentage,\n      returnVisitPercentage\n    } = _b, otherVariables = __objRest(_b, [\n      \"dataReloadRatio\",\n      \"firstVisitPercentage\",\n      \"returnVisitPercentage\"\n    ]);\n    return {\n      co2: this.model.perByte(\n        bytes,\n        green,\n        this._segment,\n        this._rating,\n        adjustments\n      ),\n      green,\n      variables: __spreadValues({\n        description: \"Below are the variables used to calculate this CO2 estimate.\",\n        bytes,\n        gridIntensity: __spreadValues({\n          description: \"The grid intensity (grams per kilowatt-hour) used to calculate this CO2 estimate.\"\n        }, adjustments.gridIntensity)\n      }, otherVariables)\n    };\n  }\n  /**\n   * Accept a figure in bytes for data transfer, a boolean for whether\n   * the domain shows as 'green', and an options object.\n   * Returns an object containing CO2 figure, green boolean, and object of the variables used in calculating the CO2 figure.\n   *\n   * @param {number} bytes\n   * @param {boolean} green\n   * @param {Object} options\n   * @return {CO2EstimateTraceResultPerVisit} the amount of CO2 in grammes\n   */\n  perVisitTrace(bytes, green = false, options = {}) {\n    var _a;\n    if ((_a = this.model) == null ? void 0 : _a.perVisit) {\n      const adjustments = parseVisitTraceOptions(\n        options,\n        this.model.version,\n        green\n      );\n      const _b = adjustments, { gridIntensity } = _b, variables = __objRest(_b, [\"gridIntensity\"]);\n      return {\n        co2: this.model.perVisit(\n          bytes,\n          green,\n          this._segment,\n          this._rating,\n          adjustments\n        ),\n        green,\n        variables: __spreadValues({\n          description: \"Below are the variables used to calculate this CO2 estimate.\",\n          bytes,\n          gridIntensity: __spreadValues({\n            description: \"The grid intensity (grams per kilowatt-hour) used to calculate this CO2 estimate.\"\n          }, adjustments.gridIntensity)\n        }, variables)\n      };\n    } else {\n      throw new Error(\n        \"The perVisitTrace() method is not supported in the model you are using. Try using perByte() instead.\\nSee https://developers.thegreenwebfoundation.org/co2js/methods/ to learn more about the methods available in CO2.js.\"\n      );\n    }\n  }\n  SustainableWebDesignV3() {\n    return new SustainableWebDesignV3();\n  }\n  SustainableWebDesignV4() {\n    return new SustainableWebDesignV4();\n  }\n  OneByte() {\n    return new OneByte();\n  }\n}\nvar co2_default = CO2;\nexport {\n  CO2,\n  co2_default as default\n};\n","import co2 from \"./co2.js\";\nimport hosting from \"./hosting.js\";\nimport averageIntensity from \"./data/average-intensities.min.js\";\nimport marginalIntensity from \"./data/marginal-intensities-2021.min.js\";\nimport electricityMaps from \"./data/electricity-maps/index.js\";\nvar index_default = {\n  co2,\n  hosting,\n  averageIntensity,\n  marginalIntensity,\n  electricityMaps\n};\nexport {\n  averageIntensity,\n  co2,\n  index_default as default,\n  electricityMaps,\n  hosting,\n  marginalIntensity\n};\n"],"version":3}
