{"version":3,"file":"generic-helpers-f8ba4018.js","sources":["../../../client/src/javascripts/customer_pages/_utils/generic-helpers.js"],"sourcesContent":["// Import JS Modules\nimport translate from './tools/translate';\n// A collection of functions for utilities business logic\n\nconst genericHelpers = {\n  promisifiedXHR(url, method, data, returnErrorBody) {\n    return new Promise((resolve, reject) => {\n      const xhr = new XMLHttpRequest();\n\n      xhr.onload = () => {\n        if (xhr.status >= 200 && xhr.status < 300) {\n          resolve(xhr.responseText && JSON.parse(xhr.responseText));\n        } else if (returnErrorBody) {\n          try {\n            reject(JSON.parse(xhr.responseText));\n          } catch (_e) {\n            reject(xhr.responseText);\n          }\n        } else {\n          reject(xhr.statusText);\n        }\n      };\n      xhr.onerror = () => reject(xhr.statusText);\n\n      const { payload, querystring } = (() => {\n        switch (method) {\n          case 'POST':\n            const formData = new FormData();\n            for (const key in data) {\n              formData.append(key, data[key]);\n            }\n            return {\n              payload: formData,\n            };\n\n          default:\n            const params = [];\n            for (const key in data) {\n              params.push([key, data[key]].join('='));\n            }\n\n            return {\n              querystring: params.join('&'),\n            };\n        }\n      })();\n\n      xhr.open(method, querystring ? `${url}?${querystring}` : url);\n      xhr.send(payload);\n    });\n  },\n  findLocations: (url, postalCode, serviceFilter, limit) => {\n    if (!postalCode) {\n      return Promise.reject();\n    }\n\n    const params = {\n      postal_code: postalCode,\n      service_filter: serviceFilter,\n      limit,\n    };\n\n    return new Promise((resolve, reject) => {\n      genericHelpers.promisifiedXHR(url, 'GET', params)\n        .then((locations) => {\n          if (locations.length > 0) {\n            resolve(locations);\n          } else {\n            reject(`We found 0 collection options near your ${translate('zip code')}. Please try again with a different ${translate('zip code')}.`);\n          }\n        })\n        .catch((error) => reject(error));\n    });\n  },\n  debounce: (func, threshold, execAsap) => {\n    let timeout;\n\n    return function debounced() {\n      const obj = this; const\n        args = arguments;\n      function delayed() {\n        if (!execAsap) {\n          func.apply(obj, args);\n        }\n        timeout = null;\n      }\n\n      if (timeout) {\n        clearTimeout(timeout);\n      } else if (execAsap) {\n        func.apply(obj, args);\n      }\n\n      timeout = setTimeout(delayed, threshold || 100);\n    };\n  },\n  isWasPriceValid: (product) => {\n    if (product.was_price) {\n      const today = genericHelpers.getDateWithoutTime(new Date());\n      const { was_price } = product;\n      const determiners = [was_price.value !== undefined];\n\n      if (was_price.start_date) {\n        determiners.push(today >= genericHelpers.getDateWithoutTime(new Date(was_price.start_date)));\n      }\n      if (was_price.end_date) {\n        determiners.push(today <= genericHelpers.getDateWithoutTime(new Date(was_price.end_date)));\n      }\n      if (product.price) {\n        determiners.push(was_price.value > product.price);\n      }\n\n      return determiners.every(Boolean);\n    }\n    return false;\n  },\n  imageMatchesSlotOrientation: (image, slot) => {\n    const { width: imageWidth, height: imageHeight } = image;\n    const { w, h, angle } = slot;\n\n    const slotOrientation = genericHelpers.getOrientation(w, h)\n    const imageOrientation = genericHelpers.getOrientation(imageWidth, imageHeight, angle);\n\n    return imageOrientation === slotOrientation;\n  },\n  getOrientation: (width, height, angle = 0) => {\n    if (angle === 90 || angle === 270) {\n      return width > height ? 'portrait' : 'landscape';\n    }\n\n    if (width === height) {\n      return 'square';\n    } else {\n      return width > height ? 'landscape' : 'portrait';\n    }\n  },\n\n  getImageOutputDpiWithSlotData: (slotData, image) => {\n    if (!activeView.template || !image || !slotData) return;\n\n    const getDiagonal = (width, height) => {\n      return Math.sqrt(width * width + height * height);\n    }\n\n    const adjustRealSize = (real, size, print) => {\n      if (print) {\n        return { \n          width: real?.width * (print[2] / size.width),\n          height: real?.height * (print[3] / size.height),\n        }\n      } else {\n        return { \n          width: real?.width,\n          height: real?.height,\n        }\n      }\n    }\n    \n    const adjustedRealSize = adjustRealSize( \n      activeView.template['real-size'], \n      activeView.template.size, \n      activeView.template['print-area']\n    )\n\n    // get printArea dimensions and diagonal in pixels\n    const printArea = {\n      width: adjustedRealSize.width,\n      height: adjustedRealSize.height\n    }\n    const printAreaAspect = printArea.width / printArea.height;\n    const printAreaDiagonal = getDiagonal(printArea.width, printArea.height);\n\n    // get slot dimensions and diagonal in pixels\n    const slotDimensions = {\n      width: slotData?.layout?.w,\n      height: slotData?.layout?.h,\n    }\n    const slotDiagonal = getDiagonal(slotDimensions.width, slotDimensions.height);\n\n    // get output dimensions and diagonal in inches\n    let outputSizeInches;\n    let outputDiagonal;\n\n    if ( printAreaAspect == 1 ){\n      // square\n      outputSizeInches = {\n        width: activeView?.output_width,\n        height: activeView?.output_width\n      }\n      outputDiagonal = getDiagonal(outputSizeInches.width, outputSizeInches.height);\n    } else if (printAreaAspect < 1){\n      // portrait\n      outputSizeInches = {\n        width: activeView?.output_width_p,\n        height: activeView?.output_width_p / printAreaAspect\n      }\n      outputDiagonal = getDiagonal(outputSizeInches.width, outputSizeInches.height);\n    } else {\n      // landscape\n      outputSizeInches = {\n        width: activeView?.output_width_l,\n        height: activeView?.output_width_l / printAreaAspect\n      }\n      outputDiagonal = getDiagonal(outputSizeInches.width, outputSizeInches.height);\n    }\n\n    const slotDiagonalInches = (slotDiagonal / printAreaDiagonal) * outputDiagonal;\n    const slotZoom = slotData?.zoomFactor ? slotData?.zoom * slotData?.zoomFactor : slotData?.zoom || 1;\n    const imgDiagonal = getDiagonal(image.width, image.height) / slotZoom;\n    \n    const dpi = Math.round(imgDiagonal / slotDiagonalInches);\n\n    return dpi;\n  },\n\n\n  getDateWithoutTime: (date) => date.setHours(0, 0, 0, 0),\n  \n  extractSpanText(html) {\n    const parser = new DOMParser();\n    const doc = parser.parseFromString(html, \"text/html\");\n    return doc.body.textContent.trim();\n  },\n\n  isMobileViewport: () => document.documentElement.clientWidth < 1024,\n  // If the `stackable` attribute is true, it means stackable content is _disabled_.\n  disallowStackable: () => window.wkData.stackable || genericHelpers.isMobileViewport(),\n  isEmptyPrintedEnvelope: () => wkData.product_title.includes('Printed Envelope') && wkData.values.returnAddress === null,\n  tidyTitleFilter: (title) => ({\n    'num-photo': 'Number of Photos',\n    'number of month': 'Number of Months',\n  }[title] || title),\n  calculateDeliveryDay: (hours) => {\n    // (Time.now + hours.to_i.hours).strftime('%a, %b %e')\n    const now = new Date();\n    const ready = new Date(now);\n    ready.setHours(now.getHours() + hours);\n\n    const day_names = ['Sun', 'Mon', 'Tues', 'Wed', 'Thu', 'Fri', 'Sat'];\n    const month_names = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];\n    return `${day_names[ready.getDay()]}, ${month_names[ready.getMonth()]} ${ready.getDate()}`;\n  },\n  capitalizeString: (str = '') => str.charAt(0).toUpperCase() + str.slice(1),\n  capitalizeWordsInString: (str = '') => str.replace('_', ' ').replace(/\\w\\S*/g, (wrd) => wrd.charAt(0).toUpperCase() + wrd.slice(1).toLowerCase()),\n  shallowObjectEquals: (objectA = {}, objectB = {}) => {\n    let key; let sizeA = 0; let\n      sizeB = 0;\n\n    for (key in objectA) {\n      if (objectA.hasOwnProperty(key)) {\n        sizeA++;\n      }\n    }\n\n    for (key in objectB) {\n      if (objectB.hasOwnProperty(key)) {\n        sizeB++;\n      }\n    }\n\n    if (sizeA !== sizeB) {\n      return false;\n    }\n\n    for (key in objectA) {\n      if (objectA[key] !== objectB[key]) {\n        return false;\n      }\n    }\n    return true;\n  },\n  deepObjectEquals: (a, b, enforce_properties_order, cyclic) => {\n    return a === b // strick equality should be enough unless zero\n      && a !== 0 // because 0 === -0, requires test by _equals()\n      || _equals(a, b) // handles not strictly equal or zero values\n    ;\n\n    function _equals(a, b) {\n      // a and b have already failed test for strict equality or are zero\n\n      let s; let l; let p; let x; let y;\n      const { toString } = Object.prototype;\n\n      // They should have the same toString() signature\n      if ((s = toString.call(a)) !== toString.call(b)) {\n        return false;\n      }\n\n      switch (s) {\n        default: // Boolean, Date, String\n          return a.valueOf() === b.valueOf();\n\n        case '[object Number]':\n          // Converts Number instances into primitive values\n          // This is required also for NaN test bellow\n          a = +a;\n          b = +b;\n\n          return a // a is Non-zero and Non-NaN\n            ? a === b\n            : // a is 0, -0 or NaN\n            a === a // a is 0 or -O\n              ? 1 / a === 1 / b // 1/0 !== 1/-0 because Infinity !== -Infinity\n              : b !== b // NaN, the only Number not equal to itself!\n          ;\n          // [object Number]\n\n        case '[object RegExp]':\n          return a.source == b.source\n            && a.global == b.global\n            && a.ignoreCase == b.ignoreCase\n            && a.multiline == b.multiline\n            && a.lastIndex == b.lastIndex\n          ;\n          // [object RegExp]\n\n        case '[object Function]':\n          return false; // functions should be strictly equal because of closure context\n          // [object Function]\n\n        case '[object Array]':\n          if (cyclic && (x = reference_equals(a, b)) !== null) {\n            return x;\n          } // intentionally duplicated bellow for [object Object]\n\n          if ((l = a.length) != b.length) {\n            return false;\n          }\n          // Both have as many elements\n\n          while (l--) {\n            if ((x = a[l]) === (y = b[l]) && x !== 0 || _equals(x, y)) {\n              continue;\n            }\n\n            return false;\n          }\n\n          return true;\n          // [object Array]\n\n        case '[object Object]':\n          if (cyclic && (x = reference_equals(a, b)) !== null) {\n            return x;\n          } // intentionally duplicated from above for [object Array]\n\n          l = 0; // counter of own properties\n\n          if (enforce_properties_order) {\n            const properties = [];\n\n            for (p in a) {\n              if (a.hasOwnProperty(p)) {\n                properties.push(p);\n\n                if ((x = a[p]) === (y = b[p]) && x !== 0 || _equals(x, y)) {\n                  continue;\n                }\n\n                return false;\n              }\n            }\n\n            // Check if 'b' has as the same properties as 'a' in the same order\n            for (p in b) {\n              if (b.hasOwnProperty(p) && properties[l++] != p) {\n                return false;\n              }\n            }\n          } else {\n            for (p in a) {\n              if (a.hasOwnProperty(p)) {\n                ++l;\n\n                if ((x = a[p]) === (y = b[p]) && x !== 0 || _equals(x, y)) {\n                  continue;\n                }\n\n                return false;\n              }\n            }\n\n            // Check if 'b' has as not more own properties than 'a'\n            for (p in b) {\n              if (b.hasOwnProperty(p) && --l < 0) {\n                return false;\n              }\n            }\n          }\n\n          return true;\n        // [object Object]\n      } // switch toString.call( a )\n    } // _equals()\n\n    /* -----------------------------------------------------------------------------------------\n       reference_equals( a, b )\n\n       Helper function to compare object references on cyclic objects or arrays.\n\n       Returns:\n         - null if a or b is not part of a cycle, adding them to object_references array\n         - true: same cycle found for a and b\n         - false: different cycle found for a and b\n\n       On the first call of a specific invocation of equal(), replaces self with inner function\n       holding object_references array object in closure context.\n\n       This allows to create a context only if and when an invocation of equal() compares\n       objects or arrays.\n    */\n    function reference_equals(a, b) {\n      const object_references = [];\n\n      return (reference_equals = _reference_equals)(a, b);\n\n      function _reference_equals(a, b) {\n        let l = object_references.length;\n\n        while (l--) {\n          if (object_references[l--] === b) {\n            return object_references[l] === a;\n          }\n        }\n\n        object_references.push(a, b);\n\n        return null;\n      } // _reference_equals()\n    } // reference_equals()\n  },\n  clamp: (num, min, max) => (num <= min ? min : num >= max ? max : num),\n};\n\nexport default genericHelpers;\n"],"names":["genericHelpers","url","method","data","returnErrorBody","resolve","reject","xhr","payload","querystring","formData","key","params","postalCode","serviceFilter","limit","locations","translate","error","func","threshold","execAsap","timeout","obj","args","delayed","product","today","was_price","determiners","image","slot","imageWidth","imageHeight","w","h","angle","slotOrientation","width","height","slotData","getDiagonal","adjustedRealSize","real","size","print","printArea","printAreaAspect","printAreaDiagonal","slotDimensions","_a","_b","slotDiagonal","outputSizeInches","outputDiagonal","slotDiagonalInches","slotZoom","imgDiagonal","date","html","title","hours","now","ready","day_names","month_names","str","wrd","objectA","objectB","sizeA","sizeB","a","b","enforce_properties_order","cyclic","_equals","s","l","p","x","y","toString","reference_equals","properties","object_references","_reference_equals","num","min","max"],"mappings":"4CAIK,MAACA,EAAiB,CACrB,eAAeC,EAAKC,EAAQC,EAAMC,EAAiB,CACjD,OAAO,IAAI,QAAQ,CAACC,EAASC,IAAW,CACtC,MAAMC,EAAM,IAAI,eAEhBA,EAAI,OAAS,IAAM,CACjB,GAAIA,EAAI,QAAU,KAAOA,EAAI,OAAS,IACpCF,EAAQE,EAAI,cAAgB,KAAK,MAAMA,EAAI,YAAY,CAAC,UAC/CH,EACT,GAAI,CACFE,EAAO,KAAK,MAAMC,EAAI,YAAY,CAAC,CACpC,MAAY,CACXD,E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