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IAC,EACF,C","sources":["webpack://stdcheck-exposed-wp-theme/./themes/stdcheck-exposed/src/js/services/storage.js","webpack://stdcheck-exposed-wp-theme/./themes/stdcheck-exposed/src/js/components/selected-center.js"],"sourcesContent":["/**\n * Service class for accessing localStorage.\n */\nexport function StorageService() {\n  /**\n   * Keys used to reference data in localStorage\n   */\n  const CJ_EVENT_KEY = 'ngStorage-cjevent';\n  const COUPON_KEY = 'ngStorage-coupon';\n  const FEE_KEY = 'ngStorage-fee';\n  const LAB_KEY = 'ngStorage-center';\n  const REORDER_KEY = 'ngStorage-reorder';\n  const TESTS_KEY = 'ngStorage-tests';\n  const TOKEN_KEY = 'ngStorage-token';\n  const ZIPCODE_KEY = 'ngStorage-zip_code';\n  const IN_HOME_KEY = 'ngStorage-in-home-booking-result';\n  const EMAIL_KEY = 'ngStorage-email';\n  const FREE_KEY = 'ngStorage-free';\n  const TRANSACTION_ID_KEY = 'transaction_id';\n  const BETTER_LAB = 'ngStorage-betterlab';\n  const IHC_PROVIDERS_KEY = 'ngStorage-ihc-providers';\n\n  /**\n   * Retrieves a value stored as JSON in localStorage\n   *\n   * @param {string} key the key to retrieve from storage\n   *\n   * @return {any}  The value stored in localStorage\n   */\n  function getLocalStorage(key) {\n    return JSON.parse(window.localStorage?.getItem(key) || null);\n  }\n\n  /**\n   * Saves a value in localStorage as a JSON string\n   *\n   * @param {string} key The key to store the value in\n   * @param {any} value  The value to be stored\n   *\n   * @return {void}\n   */\n  function setLocalStorage(key, value) {\n    window.localStorage?.setItem(key, JSON.stringify(value || null));\n  }\n\n  /**\n   * Deletes a value from the storage.\n   *\n   * @param key {string} The value's key.\n   *\n   * @return void\n   */\n  function removeLocalStorage(key) {\n    window.localStorage?.removeItem(key);\n  }\n\n  // Initialize tests in localStorage\n  if (!getLocalStorage(TESTS_KEY)) {\n    setLocalStorage(TESTS_KEY, []);\n  }\n\n  return {\n    /**\n     * Local Storage get, set and remove\n     */\n    localStorage: {\n      get: getLocalStorage,\n      set: setLocalStorage,\n      remove: removeLocalStorage,\n    },\n\n    /**\n     * Removes any reorder information from local storage\n     */\n    removeReorderInformation: function () {\n      window.localStorage?.removeItem(REORDER_KEY);\n    },\n\n    /**\n     * Removes previous order information from local storage\n     */\n    removePreviousOrderInformation: function () {\n      window.localStorage?.removeItem(TRANSACTION_ID_KEY);\n      window.localStorage?.removeItem(BETTER_LAB);\n    },\n\n    /**\n     * Retrieve coupon data from local storage\n     */\n    get coupon() {\n      return this.localStorage.get(COUPON_KEY) ?? {};\n    },\n\n    /**\n     * Store coupon data in local storage\n     */\n    set coupon(coupon) {\n      this.localStorage.set(COUPON_KEY, coupon);\n    },\n\n    /**\n     * Retrieve fee data from localStorage\n     */\n    get fee() {\n      return this.localStorage.get(FEE_KEY);\n    },\n\n    /**\n     * Store fee data in localStorage\n     */\n    set fee(fee) {\n      this.localStorage.set(FEE_KEY, fee);\n    },\n\n    /**\n     * Retrieve lab data from local storage\n     */\n    get lab() {\n      return this.localStorage.get(LAB_KEY) ?? {};\n    },\n\n    /**\n     * Store lab data in local storage\n     */\n    set lab(lab) {\n      this.localStorage.set(LAB_KEY, lab);\n    },\n\n    /**\n     * Retrieve psc data from local storage\n     */\n    get psc() {\n      return this.lab;\n    },\n\n    /**\n     * Store psc data in local storage\n     */\n    set psc(psc) {\n      this.lab = psc;\n    },\n\n    /**\n     * Retrieve selected tests data from local storage\n     */\n    get tests() {\n      return this.localStorage.get(TESTS_KEY) ?? [];\n    },\n\n    /**\n     * Store selected tests data in local storage\n     */\n    set tests(tests) {\n      this.localStorage.set(TESTS_KEY, tests);\n    },\n\n    /**\n     * Retrieve token data from localStorage\n     */\n    get token() {\n      return this.localStorage.get(TOKEN_KEY);\n    },\n\n    /**\n     * Store token data in localStorage\n     */\n    set token(token) {\n      this.localStorage.set(TOKEN_KEY, token);\n    },\n\n    /**\n     * Retrieve CJ Affiliate data from localStorage\n     */\n    get cjevent() {\n      return this.localStorage.get(CJ_EVENT_KEY);\n    },\n\n    /**\n     * Store CJ Affiliate data in localStorage\n     */\n    set cjevent(cjevent) {\n      this.localStorage.set(CJ_EVENT_KEY, cjevent);\n    },\n\n    /**\n     * Retrieve zip code data from localStorage\n     */\n    get zipCode() {\n      return this.localStorage.get(ZIPCODE_KEY);\n    },\n\n    /**\n     * Store zip code data in localStorage\n     */\n    set zipCode(zipCode) {\n      this.localStorage.set(ZIPCODE_KEY, zipCode);\n    },\n\n    get inHomeResult() {\n      return this.localStorage.get(IN_HOME_KEY);\n    },\n\n    /**\n     * Retrieve email data from local storage\n     */\n    get email() {\n      return this.localStorage.get(EMAIL_KEY) ?? {};\n    },\n\n    /**\n     * Store email data in local storage\n     */\n    set email(email) {\n      this.localStorage.set(EMAIL_KEY, email);\n    },\n\n    /**\n     * Retrieve free order data from local storage\n     */\n    get free() {\n      return this.localStorage.get(FREE_KEY) ?? {};\n    },\n\n    /**\n     * Store free order data in local storage\n     */\n    set free(free) {\n      this.localStorage.set(FREE_KEY, free);\n    },\n\n    /**\n     * Retrieve In-Home Collection provider IDs from local storage\n     */\n    get ihcProviders() {\n      return this.localStorage.get(IHC_PROVIDERS_KEY);\n    },\n\n    /**\n     * Store In-Home Collection provider IDs in local storage\n     */\n    set ihcProviders(ihcProviders) {\n      this.localStorage.set(IHC_PROVIDERS_KEY, ihcProviders);\n    },\n  };\n}\n","import { StorageService } from '../services/storage';\n\nfunction SelectedCenterComponent() {\n  const storageService = new StorageService();\n\n  function init() {\n    const center = storageService.lab;\n    const inHomeResult = storageService.inHomeResult;\n    const shouldDisplayComponent = center?.zip_code || inHomeResult;\n    const parentContainer = document.querySelector('#labSelectedLocation');\n    const iconElement = document.querySelector('#labSelectedLocation i.fa-bolt');\n\n    if (!parentContainer || !shouldDisplayComponent || !iconElement) {\n      return;\n    }\n\n    removeHomepageFindalabWidget();\n    showHomepagePriceAndPackageWidget();\n    renderSelectedCenter(center, inHomeResult);\n    parentContainer.style.display = 'block';\n    iconElement.classList.remove('fa-bolt');\n    iconElement.classList.add('fa-map-marker');\n  }\n\n  /**\n   * Adds survey date field and event listener so admins can copy/paste testimonials from one of our other projects.\n   *\n   * @param center\n   * @param inHomeResult\n   */\n  function renderSelectedCenter(center, inHomeResult) {\n    const selectedCenterDescription = document.querySelector('#selectedCenterDescription');\n    const selectedValue = document.querySelector('#selectedCenterValue');\n    if (center.zip_code) {\n      selectedCenterDescription.textContent = 'Your selected location is';\n      selectedValue.textContent = renderCenterDescription(center);\n    } else {\n      selectedCenterDescription.textContent = 'You selected In-home Collection at';\n      selectedValue.textContent = renderInHomeCollectionAddress(inHomeResult.address);\n    }\n    addChangeLocationLink(selectedValue);\n  }\n\n  /**\n   * Renders the selected center description. On a small screen only the city, state, and zip code will be displayed (Max. 2 lines).\n   * The breakpoint and maximum length are based on when the text wraps to a second line, and on how many characters can fit on two lines in small screens.\n   *\n   * @param center\n   * @returns {string}\n   */\n  function renderCenterDescription(center) {\n    const longText = getLongSelectedCenterDescription(center);\n    const MAX_LENGTH = 60;\n    const MAX_SCREEN_WIDTH = 880;\n\n    return longText.length > MAX_LENGTH && window.innerWidth < MAX_SCREEN_WIDTH\n      ? getShortSelectedCenterDescription(center)\n      : longText;\n  }\n\n  /**\n   * Builds a string with the selected center description containing the street address, city, state and zip code.\n   *\n   * @param {Object} center A Lab model\n   * @returns {string} The long selected center description\n   */\n  function getLongSelectedCenterDescription(center) {\n    return (\n      getNetworkName(center) +\n      ' at ' +\n      center.address +\n      (center.address2 ? ' ' + center.address2 : '') +\n      ', ' +\n      center.city +\n      ', ' +\n      center.state +\n      ' ' +\n      center.zip_code\n    );\n  }\n\n  /**\n   * Builds a string with the selected center description containing only city, state and zip code.\n   *\n   * @param {Object} center A Lab model\n   * @returns {string} The short selected center description\n   */\n  function getShortSelectedCenterDescription(center) {\n    return getNetworkName(center) + ' in ' + center.city + ', ' + center.state + ' ' + center.zip_code;\n  }\n\n  /**\n   * Returns the network name to be displayed as the selected center name, formatting it if necessary.\n   *\n   * @param {Object} center A Lab model\n   * @returns {string} The network name to be displayed\n   */\n  function getNetworkName(center) {\n    switch (center.network.name) {\n      case 'Quest':\n        return 'Quest Diagnostics';\n      default:\n        return center.network.name;\n    }\n  }\n\n  /**\n   * Renders the In-Home Collection address description.\n   *\n   * @param address\n   * @returns {string}\n   */\n  function renderInHomeCollectionAddress(address) {\n    return address.street + ', ' + address.city + ', ' + address.state + ' ' + address.zipCode;\n  }\n\n  /**\n   * Removes the homepage zip code input when the center/In-Home Collection is selected.\n   */\n  function removeHomepageFindalabWidget() {\n    const homepageFindalabWidget = document.querySelector('#home-findalab-widget');\n\n    if (homepageFindalabWidget) {\n      homepageFindalabWidget.remove();\n    }\n  }\n\n  /**\n   * Shows the homepage price and package widget when the center/In-Home Collection is selected.\n   */\n  function showHomepagePriceAndPackageWidget() {\n    const homepagePriceAndPackageWidget = document.getElementById('home-price-and-package-widget');\n\n    if (homepagePriceAndPackageWidget) {\n      homepagePriceAndPackageWidget.style.setProperty('display', 'block', 'important');\n    }\n  }\n\n  /**\n   * Appends a link to change the selected location to the selected center banner.\n   */\n  function addChangeLocationLink(siblingElement) {\n    const href = `/std-test-center.php`;\n    if (!siblingElement || window.location.pathname === href) {\n      return;\n    }\n\n    const link = document.createElement('a');\n    link.href = href;\n    link.textContent = ' (change)';\n    link.setAttribute('data-qa-id', 'Location Bar Change Button');\n    siblingElement.insertAdjacentElement('afterend', link);\n  }\n\n  init();\n}\n\nwindow.selectedCenter = new SelectedCenterComponent();\n"],"names":["StorageService","CJ_EVENT_KEY","COUPON_KEY","FEE_KEY","LAB_KEY","TESTS_KEY","TOKEN_KEY","ZIPCODE_KEY","EMAIL_KEY","FREE_KEY","IHC_PROVIDERS_KEY","getLocalStorage","key","JSON","parse","window","localStorage","getItem","setLocalStorage","value","setItem","stringify","get","set","remove","removeItem","removeReorderInformation","removePreviousOrderInformation","coupon","this","fee","lab","psc","tests","token","cjevent","zipCode","inHomeResult","email","free","ihcProviders","selectedCenter","storageService","getNetworkName","center","network","name","shouldDisplayComponent","zip_code","parentContainer","document","querySelector","iconElement","homepageFindalabWidget","removeHomepageFindalabWidget","homepagePriceAndPackageWidget","getElementById","style","setProperty","showHomepagePriceAndPackageWidget","selectedCenterDescription","selectedValue","address","textContent","longText","address2","city","state","getLongSelectedCenterDescription","length","innerWidth","getShortSelectedCenterDescription","renderCenterDescription","street","siblingElement","href","location","pathname","link","createElement","setAttribute","insertAdjacentElement","addChangeLocationLink","renderSelectedCenter","display","classList","add","init"],"sourceRoot":""}