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QuD,SAEpB/F,KAAKwC,QAAQuD,SAAW,MAE5B,CAEQ,aAAAjB,CAAckB,GAGpB,MAAMX,EAAiBrF,KAAKmF,WAAWpD,cAAc,cACjDiE,EAAMC,SAAWZ,IAIrBrF,KAAKwC,QAAQuD,SAAW,OAC1B,CAEQ,MAAAd,GAIgBjF,KAAKmF,WAAWpD,cAA2B,WACnD2B,iBAAiB,QAAS1D,KAAK6E,oBAEtB7E,KAAKmF,WAAWpD,cAAiC,cACzD2B,iBAAiB,QAAS1D,KAAK0E,sBAC9C1E,KAAK0F,iBAEL,MAAMQ,EAAkBlG,KAAKmF,WAAWpD,cAA2B,aACrC,SAA1B/B,KAAKwC,QAAQK,WACfqD,EAAgB7D,QAAS,GAGHrC,KAAKmF,WAAWpD,cAAc,oBACtCkB,YAAc,GAAGjD,KAAKwC,QAAQC,WAE9C,MAEM0D,GAFMC,KAAKC,MACC,IAAID,KAAKpG,KAAKwC,QAAQI,WAAW0D,WACN,IAAQ,GAAM,GAEvCtG,KAAKmF,WAAWpD,cAAc,oBACtCkB,YAAc,GAAGkD,EAAeI,QAAQ,eAE/BvG,KAAKmF,WAAWpD,cAAc,2BACtCS,QAAQgE,OAASxG,KAAKwC,QAAQL,OAAS,EACtD,CAEQ,cAAAuD,GACN,MAAML,EAAiBrF,KAAKmF,WAAWpD,cAAc,cACvB,SAA1B/B,KAAKwC,QAAQuD,UACfV,EAAeoB,aAAa,gBAAiB,QAC7CpB,EAAepC,YAAc,cAE7BoC,EAAeoB,aAAa,gBAAiB,SAC7CpB,EAAepC,YAAc,YAEjC,EASGyD,eAAeC,IAAI,sBACtBD,eAAeE,OAAO,oBAAqBrC","sources":["webpack://lange/../node_modules/@integrabeauty/assert/src/index.ts","webpack://lange/./sections/trustpilot-reviews/trustpilot-fetch-business-unit-reviews.ts","webpack://lange/./sections/trustpilot-reviews/init-reviews.ts","webpack://lange/./lib/dom-ready.ts","webpack://lange/./sections/trustpilot-reviews/trustpilot-review/index.ts"],"sourcesContent":["/**\n * Throws an assertion error if the given condition is falsy.\n *\n * @param expression any expression, although one that evaluates to true or false is preferred by\n * convention\n * @param message optional error text\n */\nexport function assert(expression: unknown, message?: string) {\n  if (!expression) {\n    throw new AssertionError(message);\n  }\n}\n\nexport class AssertionError extends Error {\n  constructor(message = 'Assertion error') {\n    super(message);\n    this.name = this.constructor.name;\n  }\n}\n","import { assert } from '@integrabeauty/assert';\nimport { FetchReviewsResponseBody } from '@integrabeauty/trustpilot-types';\n\n/**\n * Fetches recent reviews from the business unit using the public endpoint.\n *\n * If useCache is true, this fetches the reviews from a server side cache. Using the server side\n * cache is preferred because it scales substantially better than TrustPilot's API.\n */\nexport async function fetchBusinessUnitReviews(apiKey: string, businessUnitId: string,\n  useCache = false) {\n  assert(apiKey, 'Invalid api key');\n  assert(businessUnitId, 'Invalid business unit id');\n\n  const path = useCache ?\n    '/apps/trustpilot-cache/lange-product-reviews.json' :\n    `/apps/trustpilot-api/v1/business-units/${businessUnitId}/reviews`;\n  const url = new URL(path, 'https://langehair.com');\n\n  if (!useCache) {\n    url.searchParams.append('perPage', '25');\n  }\n\n  let headers: HeadersInit = {};\n  if (!useCache) {\n    headers = {\n      'Content-Type': 'application/json',\n      apiKey\n    };\n  }\n\n  let response;\n  try {\n    response = await fetch(url, { headers });\n  } catch (cause) {\n    const error: any = new Error('Failed to fetch TrustPilot business unit reviews', { cause });\n    error.url = url.href;\n    throw error;\n  }\n\n  if (!response.ok) {\n    const error: any = new Error('Received error status fetching TrustPilot business unit reviews');\n    error.status = response.status;\n    error.url = url.href;\n    throw error;\n  }\n\n  // We are intentionally not using response.json() here because it obscures errors.\n  let responseText;\n  try {\n    responseText = await response.text();\n  } catch (cause) {\n    const error: any = new Error('Failed to fetch TrustPilot business unit reviews response body',\n      { cause });\n    error.status = response.status;\n    error.url = response.url;\n    throw error;\n  }\n\n  let body;\n  try {\n    body = JSON.parse(responseText);\n  } catch (cause) {\n    const error: any = new Error('Failed to parse TrustPilot business unit reviews response body',\n      { cause });\n    error.body = responseText;\n    error.status = response.status;\n    error.url = response.url;\n    throw error;\n  }\n\n  if (!isResponseBody(body)) {\n    const error: any = new Error('Unexpected response body');\n    error.body = body;\n    error.status = response.status;\n    error.url = url.href;\n    throw error;\n  }\n\n  return body;\n}\n\nfunction isResponseBody(value: any): value is FetchReviewsResponseBody {\n  return typeof value === 'object' && value !== null && Array.isArray(value.reviews);\n}\n","import type { Review } from '@integrabeauty/trustpilot-types';\nimport { ready } from '../../lib/dom-ready.js';\nimport { fetchBusinessUnitReviews } from './trustpilot-fetch-business-unit-reviews.js';\n\n/**\n * Decorates the TrustPilot fetchBusinessUnitReviews function with client side caching.\n *\n * This tries to use session storage. If session storage is unavailable because of a user's cookies,\n * or the reviews are not found, then this falls back to fetching the reviews and updating the\n * cache.\n *\n * Session storage is used instead of local storage because we only want to cache the value for a\n * short period. The reviews are not going to change significantly within the time of someone's\n * session.\n *\n * This does not error because of issues with accessing session storage. However, this can error\n * because of a failure to fetch.\n */\nasync function fetchBusinessUnitReviewsCached(apiKey: string, businessUnitId: string) {\n  const storageKey = 'trustpilot_site_reviews';\n\n  // Attempt to return results from the client side cache.\n\n  try {\n    const value = sessionStorage.getItem(storageKey);\n    if (value) {\n      const reviews: Review[] = JSON.parse(value);\n      if (Array.isArray(reviews)) {\n        return reviews;\n      }\n    }\n  } catch (error) {\n    console.debug(error);\n  }\n\n  // Otherwise, attempt to fetch the reviews from the server side cache.\n\n  const body = await fetchBusinessUnitReviews(apiKey, businessUnitId, true);\n\n  // The fetch helper does not guarantee it returns useful results. On fetch error, we return\n  // undefined and swallow the error to indicate no results, treating it as equivalent to empty\n  // results.\n\n  if (typeof body !== 'object' || body === null) {\n    return;\n  }\n\n  // Attempt to save the fetched reviews to the client side cache.\n\n  if (body.reviews) {\n    try {\n      sessionStorage.setItem(storageKey, JSON.stringify(body.reviews));\n    } catch (error) {\n      console.debug(error);\n      // suppress and continue\n    }\n  }\n\n  return body.reviews;\n}\n\nfunction renderReviews(reviews: Review[]) {\n  const headingElement = document.querySelector<HTMLElement>('.trustpilot-reviews .reviews .title');\n  const positiveReviews = reviews.filter(review => review.stars >= 4);\n  if (positiveReviews.length > 0) {\n    headingElement.hidden = false;\n  }\n\n  for (const review of positiveReviews) {\n    const reviewElement = document.createElement('trustpilot-review');\n    reviewElement.dataset.author = review.consumer.displayName;\n    reviewElement.dataset.stars = `${review.stars}`;\n    reviewElement.dataset.createdAt = review.createdAt;\n    reviewElement.dataset.verified = `${review.isVerified}`;\n\n    // create slots\n    const titleElement = document.createElement('div');\n    titleElement.slot = 'title';\n    titleElement.textContent = review.title;\n    reviewElement.append(titleElement);\n\n    const textElement = document.createElement('div');\n    textElement.slot = 'text';\n    textElement.textContent = review.text;\n    reviewElement.append(textElement);\n\n    const container = document.querySelector('.trustpilot-reviews .reviews .list');\n    container.append(reviewElement);\n  }\n}\n\nfunction onReady() {\n  const wrapper = document.querySelector<HTMLElement>('.trustpilot-reviews .reviews');\n  const apiKey = wrapper.dataset.apiKey;\n  const businessUnitId = wrapper.dataset.businessUnitId;\n\n  fetchBusinessUnitReviewsCached(apiKey, businessUnitId)\n    .then(renderReviews)\n    .catch(console.error);\n}\n\nready(onReady);\n","/**\n * Releases the handle returned from the ready() function.\n *\n * This is idempotent. Additional calls are pointless but harmless.\n */\nexport type ReleaseHandle = () => void;\n\n/**\n * A subset of events that pertain to document ready state.\n */\ntype LoadingEventMap = Pick<DocumentEventMap, 'DOMContentLoaded' | 'load'>;\n\n/**\n * Calls the provided callback when the document is ready. This works both when the document is\n * already ready and when it is not, so callers do not have to care. This exists because it ensures\n * that each caller consistently expresses its dependency on document readiness, and to save a bit\n * of boilerplate.\n *\n * A document is considered ready when it has been parsed. This corresponds to the ready state of\n * 'interactive'. When the document has been fully loaded, the ready state is 'complete'. The\n * callback runs either way, so callers do not have to check which one they are in.\n *\n * Ready means the html is parsed and the DOM is there to query. It does not mean the page's other\n * scripts have run. Deferred scripts and module scripts run after the ready state turns\n * 'interactive' and before DOMContentLoaded fires, so a callback here can run before them. When a\n * caller needs some other script to have run already, this is the wrong tool, and it should wait on\n * whatever that script produces instead.\n *\n * That remedy has a catch of its own when the calling bundle is loaded with async. An async bundle\n * can execute after DOMContentLoaded has already fired, so a plain listener for that event never\n * runs and the work silently never happens. Nothing here can detect that, because by the time this\n * file executes the event is long gone. Catching it needs something registered at parse time,\n * before any bundle loads.\n *\n * There is a second trap right next to that one, and it applies only when waiting for\n * DOMContentLoaded. The ready state stays 'interactive' after DOMContentLoaded has fired, all the\n * way until 'complete', so the ready state cannot tell you whether DOMContentLoaded is still coming\n * or has already gone. Waiting for load is not exposed to this, because the ready state turns\n * 'complete' and load fires in the same task, so seeing 'complete' means load has fired too.\n *\n * When the document is already ready, the callback is invoked via setTimeout. This way, if the\n * callback throws, the error surfaces to the global error handler in a way that is similar to what\n * happens when an event listener throws.\n *\n * We might one day want to move this to an NPM library.\n *\n * Beware of a quirk here. setTimeout yields, and the busier the frontend, the longer it takes to\n * fire. Page load is exactly when the frontend is busiest. The timeout is a floor and not a\n * guarantee, so there is no real bound on how long that yield lasts. What this means is that using\n * this library can introduce more delay than you might expect. Compare code that runs on async load\n * and checks ready state and invokes immediately to code that runs after setTimeout. The former\n * runs in the same tick, the latter runs in \"some later tick\". That later tick can be surprisingly\n * much later. That can cause initial paint issues.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/readyState\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/DOMContentLoaded_event\n * @see https://html.spec.whatwg.org/multipage/parsing.html#the-end\n */\nexport function ready(callback: (event?: Event) => void,\n  type: keyof LoadingEventMap = 'DOMContentLoaded') {\n  if (document.readyState === 'complete' || (type === 'DOMContentLoaded' &&\n    document.readyState === 'interactive')) {\n    const timer = setTimeout(callback, 0);\n    const handle: ReleaseHandle = () => clearTimeout(timer);\n    return handle;\n  } else {\n    addEventListener(type, callback);\n    const handle: ReleaseHandle = () => removeEventListener(type, callback);\n    return handle;\n  }\n}\n","import type { CustomElement } from '@integrabeauty/custom-elements';\nimport html from './index.html';\nimport styles from './index.scss';\n\n/**\n * A single Trustpilot review card showing the author, post time, a verified badge, and the star\n * rating, with the review text supplied in a slot.\n *\n * It is one item in the Trustpilot reviews feed and delegates its stars to a trustpilot rating\n * stars child.\n */\nclass TrustpilotReview extends HTMLElement implements CustomElement {\n  public static get observedAttributes() {\n    return ['data-expanded'];\n  }\n\n  declare readonly dataset: {\n    /**\n     * Display name of an author who created review\n     */\n    author: string;\n\n    /**\n     * Timestamp when review was created\n     */\n    createdAt: string;\n\n    /**\n     * Set to true once the review text is shown. Only phones hide the text to begin with, so only\n     * phones show the read more button that toggles this.\n     */\n    expanded: string;\n\n    /**\n     * Number of stars given\n     */\n    stars: string;\n\n    /**\n     * Is review verified\n     */\n    verified: string;\n  };\n\n  private onReadMoreClickBound = this.onReadMoreClick.bind(this);\n  private onReviewClickBound = this.onReviewClick.bind(this);\n\n  public connectedCallback() {\n    this.initializeShadowRoot();\n    this.render();\n  }\n\n  public disconnectedCallback() {\n    const review = this.shadowRoot.querySelector<HTMLElement>('.review');\n    review?.removeEventListener('click', this.onReviewClickBound);\n\n    const readMoreButton = this.shadowRoot.querySelector<HTMLButtonElement>('.read-more');\n    readMoreButton?.removeEventListener('click', this.onReadMoreClickBound);\n  }\n\n  public attributeChangedCallback(_name: string, oldValue: string, newValue: string) {\n    this.initializeShadowRoot();\n\n    if (oldValue !== newValue) {\n      this.renderReadMore();\n    }\n  }\n\n  private initializeShadowRoot() {\n    if (!this.shadowRoot) {\n      this.attachShadow({ mode: 'open' });\n      this.shadowRoot.innerHTML = `<style>${styles}</style>${html}`;\n    }\n  }\n\n  private onReadMoreClick(_event: PointerEvent) {\n    if (this.dataset.expanded === 'true') {\n      delete this.dataset.expanded;\n    } else {\n      this.dataset.expanded = 'true';\n    }\n  }\n\n  private onReviewClick(event: PointerEvent) {\n    // A click on the read more button also reaches the card. The button's own listener handles it,\n    // and expanding here would undo the button collapsing the review.\n    const readMoreButton = this.shadowRoot.querySelector('.read-more');\n    if (event.target === readMoreButton) {\n      return;\n    }\n\n    this.dataset.expanded = 'true';\n  }\n\n  private render() {\n    // Besides the read more button, we listen on the whole card. The button is a small target on a\n    // phone, so a tap anywhere in the review expands it. Keyboard and screen reader users get the\n    // button.\n    const reviewElement = this.shadowRoot.querySelector<HTMLElement>('.review');\n    reviewElement.addEventListener('click', this.onReviewClickBound);\n\n    const readMoreButton = this.shadowRoot.querySelector<HTMLButtonElement>('.read-more');\n    readMoreButton.addEventListener('click', this.onReadMoreClickBound);\n    this.renderReadMore();\n\n    const verifiedElement = this.shadowRoot.querySelector<HTMLElement>('.verified');\n    if (this.dataset.verified === 'true') {\n      verifiedElement.hidden = false;\n    }\n\n    const userNameElement = this.shadowRoot.querySelector('.user-info .name');\n    userNameElement.textContent = `${this.dataset.author}, `;\n\n    const now = Date.now();\n    const createdAt = new Date(this.dataset.createdAt).getTime();\n    const hourDifference = (((now - createdAt) / 1000) / 60) / 60;\n\n    const dateElement = this.shadowRoot.querySelector('.user-info .date');\n    dateElement.textContent = `${hourDifference.toFixed(0)} hours ago`;\n\n    const starsElement = this.shadowRoot.querySelector('trustpilot-rating-stars');\n    starsElement.dataset.rating = this.dataset.stars || '';\n  }\n\n  private renderReadMore() {\n    const readMoreButton = this.shadowRoot.querySelector('.read-more');\n    if (this.dataset.expanded === 'true') {\n      readMoreButton.setAttribute('aria-expanded', 'true');\n      readMoreButton.textContent = 'Show less';\n    } else {\n      readMoreButton.setAttribute('aria-expanded', 'false');\n      readMoreButton.textContent = 'Read more';\n    }\n  }\n}\n\ndeclare global {\n  interface HTMLElementTagNameMap {\n    'trustpilot-review': TrustpilotReview;\n  }\n}\n\nif (!customElements.get('trustpilot-review')) {\n  customElements.define('trustpilot-review', TrustpilotReview);\n}\n"],"names":["assert","expression","message","AssertionError","Error","constructor","super","this","name","async","fetchBusinessUnitReviews","apiKey","businessUnitId","useCache","url","URL","searchParams","append","response","responseText","body","headers","fetch","cause","error","href","ok","status","text","JSON","parse","value","Array","isArray","reviews","renderReviews","headingElement","document","querySelector","positiveReviews","filter","review","stars","length","hidden","reviewElement","createElement","dataset","author","consumer","displayName","createdAt","verified","isVerified","titleElement","slot","textContent","title","textElement","callback","type","readyState","timer","setTimeout","clearTimeout","addEventListener","ready","wrapper","storageKey","sessionStorage","getItem","console","debug","setItem","stringify","fetchBusinessUnitReviewsCached","then","catch","TrustpilotReview","HTMLElement","observedAttributes","onReadMoreClickBound","onReadMoreClick","bind","onReviewClickBound","onReviewClick","connectedCallback","initializeShadowRoot","render","disconnectedCallback","shadowRoot","removeEventListener","readMoreButton","attributeChangedCallback","_name","oldValue","newValue","renderReadMore","attachShadow","mode","innerHTML","_event","expanded","event","target","verifiedElement","hourDifference","Date","now","getTime","toFixed","rating","setAttribute","customElements","get","define"],"sourceRoot":""}