{"version":3,"sources":["webpack:///./PandoSites.Web/Shared/relatedContent/Scripts/relatedContent.vue?589f","webpack:///./PandoSites.Web/Shared/relatedContent/Scripts/relatedContent.vue?2b25","webpack:///./PandoSites.Web/Shared/relatedContent/Scripts/relatedContent.vue","webpack:///./PandoSites.Web/Shared/RelatedContent/Scripts/relatedContent.vue?4051","webpack:///./PandoSites.Web/Shared/RelatedContent/Scripts/relatedContent.vue?86a0","webpack:///./PandoSites.Web/Shared/RelatedContent/Scripts/relatedContent.vue"],"names":["Scripts_relatedContentvue_type_script_lang_js_","data","isItemFavorite","config","cookieName","methods","init","this","dataSourceId","cookieData","getCookieData","cookieObject","JSON","parse","toggleFavorite","contentId","contentType","title","deleteCookie","setFavorites","itemClick","event","stopPropagation","item","currentTarget","getItemData","raiseViewEvent","isCurrentUserAnonymous","isAnonymousUserWithFavorites","setCookie","openRegistration","relatedContentList","listSettings","performFavoriteToggle","getAttribute","isFavorite","itemIndex","items","findIndex","element","url","makeWebRequest","method","headers","Content-Type","webResponse","context","$set","postOptions","callback","_this","fetch","then","response","status","_this2","forEach","contents","name","decodeURIComponent","document","cookie","split","value","indexOf","substring","length","cookieContents","stringify","fullPageRegistrationUrl","encodeURIComponent","window","location","href","regAction","eSrcCode","toPascalCase","stringToModify","replace","g0","g1","g2","toUpperCase","toLowerCase","eventType","EventType","ContentListName","TemplateName","ContentId","ContentTitle","ContentType","RecordType","GeneralMills","Analytics","raiseEvent","directives","lazyloadimages","component","Object","componentNormalizer","render","staticRenderFns","options","__file","__webpack_exports__"],"mappings":"yIAAiVA,ECMlU,CACfC,KAAA,WACA,OACAC,eAAA,GACAC,OAAA,GACAC,WAAA,KAGAC,QAAA,CAGAC,KAAA,SAAAH,GACAI,KAAAJ,SACAI,KAAAH,WAAA,uCAAAG,KAAAJ,OAAAK,aAEA,IAAAC,EAAAF,KAAAG,cAAAH,KAAAH,YAEA,YAAAK,EAAA,CACA,IAAAE,EAAAC,KAAAC,MAAAJ,GACAF,KAAAO,e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AAAH,WAAA,4CAGA0B,iBAAA,SAAAE,GACA,IAAAQ,EAAAR,EAAAqC,yBAAA,sBACA7B,GAAA,4CAAA8B,mBAAAC,OAAAC,SAAAC,MACAzC,EAAA0C,YAAAlC,GAAA,cAAAR,EAAA0C,WACA1C,EAAA2C,WAAAnC,GAAA,aAAAR,EAAA2C,UACApE,KAAAJ,OAAAyB,+BAAAY,GAAA,6BAEA+B,OAAAC,SAAAC,KAAAjC,GAGAoC,aAAA,SAAAC,GACA,aAAAA,EAAA,KAAAA,EAAAC,QAAA,sBAAAC,EAAAC,EAAAC,GACA,OAAAD,EAAAE,cAAAD,EAAAE,iBAIAzD,eAAA,SAAAzB,EAAAmF,GACA,GAAAnF,EAAAc,WAAAd,EAAAe,aAAAf,EAAAgB,MAAA,CACA,IAAAI,EAAA,CACAgE,UAAAD,EACAE,gBAAA,iBACAC,aAAA,iBACAC,UAAAvF,EAAAc,UACA0E,aAAAxF,EAAAgB,MACAyE,YAAAnF,KAAAqE,aAAA3E,EAAAe,aACA2E,WAAApF,KAAAqE,aAAA3E,EAAAe,cAEA4E,aAAAC,WAAAD,aAAAC,UAAAC,WAAAzE,MAIA0E,WAAA,CACAC,oBAAoB,WCtLpBC,EAAgBC,OAAAC,EAAA,EAAAD,CACdlG,OARFoG,OAAAC,GAWA,EACA,KACA,KACA,MAkBAJ,EAAAK,QAAAC,OAAA,kEACeC,EAAA,QAAAP","file":"relatedContent.ee94be6365f9eea04d3f.chunk.js","sourcesContent":["import mod from \"-!../../../../custom_webpack_modules/styleAppenderLoader/index.js??ref--2-0!../../../../node_modules/babel-loader/lib/index.js!../../../../node_modules/webpack-import-glob-loader/index.js!../../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./relatedContent.vue?vue&type=script&lang=js&\"; export default mod; export * from \"-!../../../../custom_webpack_modules/styleAppenderLoader/index.js??ref--2-0!../../../../node_modules/babel-loader/lib/index.js!../../../../node_modules/webpack-import-glob-loader/index.js!../../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./relatedContent.vue?vue&type=script&lang=js&\"","import \"@Styles/Shared/RelatedContent/relatedContent_sm.less\";\nimport \"@Styles/Shared/RelatedContent/BC/relatedContent_sm.less\";\nimport \"@Styles/Shared/RelatedContent/relatedContent_md.less\";\nimport \"@Styles/Shared/RelatedContent/relatedContent_lg.less\";\nimport \"@Styles/Shared/RelatedContent/BC/relatedContent_lg.less\";\nimport { LazyLoadImages } from '@Shared/Common';\nexport default {\n  data: function data() {\n    return {\n      isItemFavorite: {},\n      config: {},\n      cookieName: \"\"\n    };\n  },\n  methods: {\n    //#region Public methods\n    // This function runs when the component loads\n    init: function init(config) {\n      this.config = config;\n      this.cookieName = 'relatedContentFavorite_initialState_' + this.config.dataSourceId; // Try to load any cookies if we've been directed back to this page, post-login\n\n      var cookieData = this.getCookieData(this.cookieName); // If we found the cookie, toggle the favorite\n\n      if (typeof cookieData !== 'undefined') {\n        var cookieObject = JSON.parse(cookieData);\n        this.toggleFavorite(cookieObject.contentId, cookieObject.contentType, cookieObject.title, 'False'); // Delete the cookie now what we're done\n\n        this.deleteCookie();\n      } // Set the initial favorite values\n\n\n      this.setFavorites();\n    },\n    // This method handles when the content's name or thumbnail is clicked\n    itemClick: function itemClick(event) {\n      event.stopPropagation();\n      var item = event.currentTarget;\n      var data = this.getItemData(item);\n      this.raiseViewEvent(data, \"ContentResult\");\n    },\n    // This method will toggle a favorite on and off\n    toggleFavorite: function toggleFavorite(contentId, contentType, title) {\n      if (!contentId || !contentType || !title) return; // Toggle the favorite if the user is logged in, otherwise make them log in\n\n      if (!this.config.isCurrentUserAnonymous && !this.config.isAnonymousUserWithFavorites) {\n        this.performFavoriteToggle(contentId, contentType, title);\n      } else {\n        this.setCookie(this.config.dataSourceId, contentId, contentType, title);\n        this.openRegistration(this.config.relatedContentList.listSettings);\n      }\n    },\n    //#endregion\n    //#region Private methods\n    // This method handles the formulation and return of a nice item \"object\"\n    getItemData: function getItemData(item) {\n      var data = {};\n\n      if (item) {\n        data = {\n          contentId: item.getAttribute('data-contentid') || '',\n          contentType: item.getAttribute('data-contenttype') || '',\n          title: item.getAttribute('data-title') || ''\n        };\n      }\n\n      return data;\n    },\n    // This method will do the groundwork for toggling a favorite on and off\n    performFavoriteToggle: function performFavoriteToggle(contentId, contentType, title) {\n      var isFavorite = false; // Try to find the item, return if we didn't\n\n      var itemIndex = this.config.relatedContentList.items.findIndex(function (element) {\n        return element.contentId === contentId;\n      });\n      if (itemIndex === -1) return; // We found the item, let's determine its new status\n\n      isFavorite = !this.config.relatedContentList.items[itemIndex].isFavorite; // Formulate the target service URL\n\n      var url = isFavorite ? '/api/relatedContentFavorite/add/' : '/api/relatedContentFavorite/remove/'; // Prepare for the POST\n\n      var postOptions = {\n        method: 'POST',\n        headers: {\n          'Content-Type': 'application/json; charset=utf-8'\n        }\n      }; // Define the callback function for toggling of the favorites\n\n      var callback = function callback(webResponse, context) {\n        if (webResponse) {\n          // Raise an analytics event if the request succeeded\n          if (isFavorite) {\n            var data = {};\n            data = {\n              contentId: contentId,\n              contentType: contentType,\n              title: title\n            };\n            context.raiseViewEvent(data, \"AddToFavorites\");\n          } // Adjust the item's status\n\n\n          context.config.relatedContentList.items[itemIndex].isFavorite = isFavorite; // Set the item status for favorite styling\n\n          context.$set(context.isItemFavorite, contentId, isFavorite);\n        }\n      }; // Make the call to toggle the favorite\n\n\n      this.makeWebRequest(url + contentId, postOptions, callback);\n    },\n    // This method makes a web request and returns whether it was successful\n    makeWebRequest: function makeWebRequest(url, postOptions, callback) {\n      var _this = this;\n\n      fetch(url, postOptions).then(function (response) {\n        callback(response.status === 200 || response.status === 204, _this);\n      });\n    },\n    // This method sets the favorite status for each item\n    setFavorites: function setFavorites() {\n      var _this2 = this;\n\n      this.config.relatedContentList.items.forEach(function (item) {\n        _this2.$set(_this2.isItemFavorite, item.contentId, item.isFavorite);\n      });\n    },\n    // This helper method will get the cookie data\n    getCookieData: function getCookieData() {\n      var name = this.cookieName + \"=\";\n      var decodedCookies = decodeURIComponent(document.cookie);\n      var allCookiesArray = decodedCookies.split('; ');\n      var contents; // Loop through all of the cookies and look for the target one\n\n      allCookiesArray.forEach(function (value) {\n        if (value.indexOf(name) === 0) contents = value.substring(name.length);\n      }); // If we found the cookie return its contents, deserialized back into an object\n\n      return contents;\n    },\n    // This helper method will set the cookie data\n    setCookie: function setCookie(dataSourceId, contentId, contentType, title) {\n      if (!contentId || !contentType || !title || !dataSourceId) return; // Define the cookie data, id will be the content list's id, since the user can only click and redirect / login, having attempted to save one item per time\n\n      var cookieData = {\n        contentId: contentId,\n        contentType: contentType,\n        title: title\n      }; // Set the cookie\n\n      var cookieContents = this.cookieName + \"=\" + JSON.stringify(cookieData);\n      document.cookie = cookieContents;\n    },\n    // This helper method will delete the cookie\n    deleteCookie: function deleteCookie() {\n      document.cookie = this.cookieName + \"=; expires=Thu, 01 Jan 1970 00:00:00 UTC\";\n    },\n    // This method sends the user to the login / registration form\n    openRegistration: function openRegistration(listSettings) {\n      var url = listSettings.fullPageRegistrationUrl || '/user-profile/login';\n      url += '?isRegistrationFirstStep=false&returnUrl=' + encodeURIComponent(window.location.href);\n      if (listSettings.regAction) url += '&regAction=' + listSettings.regAction;\n      if (listSettings.eSrcCode) url += '&eSrcCode=' + listSettings.eSrcCode;\n      if (this.config.isAnonymousUserWithFavorites) url += '&value_prop=AnonFavorites'; // Redirect to the full page registration\n\n      window.location.href = url;\n    },\n    // This helper method will Pascal-case a string\n    toPascalCase: function toPascalCase(stringToModify) {\n      return stringToModify == null ? null : stringToModify.replace(/(\\w)(\\w*)/g, function (g0, g1, g2) {\n        return g1.toUpperCase() + g2.toLowerCase();\n      });\n    },\n    // This method raises an analytics event\n    raiseViewEvent: function raiseViewEvent(data, eventType) {\n      if (!data.contentId || !data.contentType || !data.title) return;\n      var event = {\n        EventType: eventType,\n        ContentListName: 'RelatedContent',\n        TemplateName: 'RelatedContent',\n        ContentId: data.contentId,\n        ContentTitle: data.title,\n        ContentType: this.toPascalCase(data.contentType),\n        RecordType: this.toPascalCase(data.contentType)\n      };\n      if (GeneralMills.Analytics) GeneralMills.Analytics.raiseEvent(event);\n    } //#endregion\n\n  },\n  directives: {\n    lazyloadimages: LazyLoadImages\n  }\n};","var render, staticRenderFns\nimport script from \"./relatedContent.vue?vue&type=script&lang=js&\"\nexport * from \"./relatedContent.vue?vue&type=script&lang=js&\"\n\n\n/* normalize component */\nimport normalizer from \"!../../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n  script,\n  render,\n  staticRenderFns,\n  false,\n  null,\n  null,\n  null\n  \n)\n\n/* hot reload */\nif (module.hot) {\n  var api = require(\"D:\\\\actions-runner\\\\_work\\\\red.PandoSites\\\\red.PandoSites\\\\node_modules\\\\vue-hot-reload-api\\\\dist\\\\index.js\")\n  api.install(require('vue'))\n  if (api.compatible) {\n    module.hot.accept()\n    if (!module.hot.data) {\n      api.createRecord('ec0ee1da', component.options)\n    } else {\n      api.reload('ec0ee1da', component.options)\n    }\n    \n  }\n}\ncomponent.options.__file = \"PandoSites.Web/Shared/relatedContent/Scripts/relatedContent.vue\"\nexport default component.exports","import mod from \"-!../../../../custom_webpack_modules/styleAppenderLoader/index.js??ref--2-0!../../../../node_modules/babel-loader/lib/index.js!../../../../node_modules/webpack-import-glob-loader/index.js!../../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./relatedContent.vue?vue&type=script&lang=js&\"; export default mod; export * from \"-!../../../../custom_webpack_modules/styleAppenderLoader/index.js??ref--2-0!../../../../node_modules/babel-loader/lib/index.js!../../../../node_modules/webpack-import-glob-loader/index.js!../../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./relatedContent.vue?vue&type=script&lang=js&\"","import \"@Styles/Shared/RelatedContent/relatedContent_sm.less\";\nimport \"@Styles/Shared/RelatedContent/BC/relatedContent_sm.less\";\nimport \"@Styles/Shared/RelatedContent/relatedContent_md.less\";\nimport \"@Styles/Shared/RelatedContent/relatedContent_lg.less\";\nimport \"@Styles/Shared/RelatedContent/BC/relatedContent_lg.less\";\nimport { LazyLoadImages } from '@Shared/Common';\nexport default {\n  data: function data() {\n    return {\n      isItemFavorite: {},\n      config: {},\n      cookieName: \"\"\n    };\n  },\n  methods: {\n    //#region Public methods\n    // This function runs when the component loads\n    init: function init(config) {\n      this.config = config;\n      this.cookieName = 'relatedContentFavorite_initialState_' + this.config.dataSourceId; // Try to load any cookies if we've been directed back to this page, post-login\n\n      var cookieData = this.getCookieData(this.cookieName); // If we found the cookie, toggle the favorite\n\n      if (typeof cookieData !== 'undefined') {\n        var cookieObject = JSON.parse(cookieData);\n        this.toggleFavorite(cookieObject.contentId, cookieObject.contentType, cookieObject.title, 'False'); // Delete the cookie now what we're done\n\n        this.deleteCookie();\n      } // Set the initial favorite values\n\n\n      this.setFavorites();\n    },\n    // This method handles when the content's name or thumbnail is clicked\n    itemClick: function itemClick(event) {\n      event.stopPropagation();\n      var item = event.currentTarget;\n      var data = this.getItemData(item);\n      this.raiseViewEvent(data, \"ContentResult\");\n    },\n    // This method will toggle a favorite on and off\n    toggleFavorite: function toggleFavorite(contentId, contentType, title) {\n      if (!contentId || !contentType || !title) return; // Toggle the favorite if the user is logged in, otherwise make them log in\n\n      if (!this.config.isCurrentUserAnonymous && !this.config.isAnonymousUserWithFavorites) {\n        this.performFavoriteToggle(contentId, contentType, title);\n      } else {\n        this.setCookie(this.config.dataSourceId, contentId, contentType, title);\n        this.openRegistration(this.config.relatedContentList.listSettings);\n      }\n    },\n    //#endregion\n    //#region Private methods\n    // This method handles the formulation and return of a nice item \"object\"\n    getItemData: function getItemData(item) {\n      var data = {};\n\n      if (item) {\n        data = {\n          contentId: item.getAttribute('data-contentid') || '',\n          contentType: item.getAttribute('data-contenttype') || '',\n          title: item.getAttribute('data-title') || ''\n        };\n      }\n\n      return data;\n    },\n    // This method will do the groundwork for toggling a favorite on and off\n    performFavoriteToggle: function performFavoriteToggle(contentId, contentType, title) {\n      var isFavorite = false; // Try to find the item, return if we didn't\n\n      var itemIndex = this.config.relatedContentList.items.findIndex(function (element) {\n        return element.contentId === contentId;\n      });\n      if (itemIndex === -1) return; // We found the item, let's determine its new status\n\n      isFavorite = !this.config.relatedContentList.items[itemIndex].isFavorite; // Formulate the target service URL\n\n      var url = isFavorite ? '/api/relatedContentFavorite/add/' : '/api/relatedContentFavorite/remove/'; // Prepare for the POST\n\n      var postOptions = {\n        method: 'POST',\n        headers: {\n          'Content-Type': 'application/json; charset=utf-8'\n        }\n      }; // Define the callback function for toggling of the favorites\n\n      var callback = function callback(webResponse, context) {\n        if (webResponse) {\n          // Raise an analytics event if the request succeeded\n          if (isFavorite) {\n            var data = {};\n            data = {\n              contentId: contentId,\n              contentType: contentType,\n              title: title\n            };\n            context.raiseViewEvent(data, \"AddToFavorites\");\n          } // Adjust the item's status\n\n\n          context.config.relatedContentList.items[itemIndex].isFavorite = isFavorite; // Set the item status for favorite styling\n\n          context.$set(context.isItemFavorite, contentId, isFavorite);\n        }\n      }; // Make the call to toggle the favorite\n\n\n      this.makeWebRequest(url + contentId, postOptions, callback);\n    },\n    // This method makes a web request and returns whether it was successful\n    makeWebRequest: function makeWebRequest(url, postOptions, callback) {\n      var _this = this;\n\n      fetch(url, postOptions).then(function (response) {\n        callback(response.status === 200 || response.status === 204, _this);\n      });\n    },\n    // This method sets the favorite status for each item\n    setFavorites: function setFavorites() {\n      var _this2 = this;\n\n      this.config.relatedContentList.items.forEach(function (item) {\n        _this2.$set(_this2.isItemFavorite, item.contentId, item.isFavorite);\n      });\n    },\n    // This helper method will get the cookie data\n    getCookieData: function getCookieData() {\n      var name = this.cookieName + \"=\";\n      var decodedCookies = decodeURIComponent(document.cookie);\n      var allCookiesArray = decodedCookies.split('; ');\n      var contents; // Loop through all of the cookies and look for the target one\n\n      allCookiesArray.forEach(function (value) {\n        if (value.indexOf(name) === 0) contents = value.substring(name.length);\n      }); // If we found the cookie return its contents, deserialized back into an object\n\n      return contents;\n    },\n    // This helper method will set the cookie data\n    setCookie: function setCookie(dataSourceId, contentId, contentType, title) {\n      if (!contentId || !contentType || !title || !dataSourceId) return; // Define the cookie data, id will be the content list's id, since the user can only click and redirect / login, having attempted to save one item per time\n\n      var cookieData = {\n        contentId: contentId,\n        contentType: contentType,\n        title: title\n      }; // Set the cookie\n\n      var cookieContents = this.cookieName + \"=\" + JSON.stringify(cookieData);\n      document.cookie = cookieContents;\n    },\n    // This helper method will delete the cookie\n    deleteCookie: function deleteCookie() {\n      document.cookie = this.cookieName + \"=; expires=Thu, 01 Jan 1970 00:00:00 UTC\";\n    },\n    // This method sends the user to the login / registration form\n    openRegistration: function openRegistration(listSettings) {\n      var url = listSettings.fullPageRegistrationUrl || '/user-profile/login';\n      url += '?isRegistrationFirstStep=false&returnUrl=' + encodeURIComponent(window.location.href);\n      if (listSettings.regAction) url += '&regAction=' + listSettings.regAction;\n      if (listSettings.eSrcCode) url += '&eSrcCode=' + listSettings.eSrcCode;\n      if (this.config.isAnonymousUserWithFavorites) url += '&value_prop=AnonFavorites'; // Redirect to the full page registration\n\n      window.location.href = url;\n    },\n    // This helper method will Pascal-case a string\n    toPascalCase: function toPascalCase(stringToModify) {\n      return stringToModify == null ? null : stringToModify.replace(/(\\w)(\\w*)/g, function (g0, g1, g2) {\n        return g1.toUpperCase() + g2.toLowerCase();\n      });\n    },\n    // This method raises an analytics event\n    raiseViewEvent: function raiseViewEvent(data, eventType) {\n      if (!data.contentId || !data.contentType || !data.title) return;\n      var event = {\n        EventType: eventType,\n        ContentListName: 'RelatedContent',\n        TemplateName: 'RelatedContent',\n        ContentId: data.contentId,\n        ContentTitle: data.title,\n        ContentType: this.toPascalCase(data.contentType),\n        RecordType: this.toPascalCase(data.contentType)\n      };\n      if (GeneralMills.Analytics) GeneralMills.Analytics.raiseEvent(event);\n    } //#endregion\n\n  },\n  directives: {\n    lazyloadimages: LazyLoadImages\n  }\n};","var render, staticRenderFns\nimport script from \"./relatedContent.vue?vue&type=script&lang=js&\"\nexport * from \"./relatedContent.vue?vue&type=script&lang=js&\"\n\n\n/* normalize component */\nimport normalizer from \"!../../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n  script,\n  render,\n  staticRenderFns,\n  false,\n  null,\n  null,\n  null\n  \n)\n\n/* hot reload */\nif (module.hot) {\n  var api = require(\"D:\\\\actions-runner\\\\_work\\\\red.PandoSites\\\\red.PandoSites\\\\node_modules\\\\vue-hot-reload-api\\\\dist\\\\index.js\")\n  api.install(require('vue'))\n  if (api.compatible) {\n    module.hot.accept()\n    if (!module.hot.data) {\n      api.createRecord('1419a21a', component.options)\n    } else {\n      api.reload('1419a21a', component.options)\n    }\n    \n  }\n}\ncomponent.options.__file = \"PandoSites.Web/Shared/RelatedContent/Scripts/relatedContent.vue\"\nexport default component.exports"],"sourceRoot":""}