{"version":3,"file":"social-wall-slider-Cr8nPlvu.js","sources":["../../src/project/AramcoLife/social-wall-slider/social-wall-slider.ts"],"sourcesContent":["import { bootstrapConstructorOnElement } from \"~/foundation/Bootstrapper\";\r\nimport { type Module } from \"~/foundation/Bootstrapper/types\";\r\nimport { isRtl } from \"~/foundation/Helpers/isRtl\";\r\nimport { addLoader } from \"~/foundation/Loaders/loader\";\r\nimport slider from \"~/foundation/Slider/slider\";\r\nimport { socialWallService } from \"../services/socialWallService\";\r\nimport { addVideoEventListeners, removeLoader, renderSocialWallItem } from \"../social-wall/markup/socialWallMarkup\";\r\nimport \"./social-wall-slider.scss\";\r\nimport { type SocialWallSliderProps } from \"../generated-types\";\r\n\r\nconst slidesCount = 10;\r\n\r\nconst socialWallSlider: Module = async (element, props) => {\r\n\tconst swiper = element.querySelector(\"[data-swiper-lazy]\");\r\n\tconst swiperWrapper = element.querySelector(\".swiper-wrapper\");\r\n\r\n\tif (!swiper || !swiperWrapper) {\r\n\t\tconsole.log(\"Could not find swiper or swiperWrapper\");\r\n\t\treturn;\r\n\t}\r\n\r\n\taddLoader(element);\r\n\tconst response = await socialWallService.feed({ language: props.language! });\r\n\r\n\tif (response.error || response.data?.length === 0) {\r\n\t\tremoveLoader(element);\r\n\t\tconsole.error(\"Error fetching social wall data:\", response.error);\r\n\t\tif (element) {\r\n\t\t\telement.innerHTML = `${isRtl\r\n\t\t\t\t? `يبدو أن هناك مشكلة في الحصول على الأخبار. الرجاء المحاولة في وقت لاحق `\r\n\t\t\t\t: `Looks like there was a problem getting the social news. Please try again later.`\r\n\t\t\t\t}`;\r\n\t\t}\r\n\t\treturn;\r\n\t}\r\n\r\n\tif (!swiper.className.includes(\"swiper-initialized\")) {\r\n\t\tawait bootstrapConstructorOnElement(swiper, slider, \"slider\");\r\n\t}\r\n\r\n\tlet socialWallItems = response.data || [];\r\n\tsocialWallItems = socialWallItems.filter(x => x.text);\r\n\r\n\tconst slicedResponse = socialWallItems.slice(0, slidesCount);\r\n\r\n\tif (slicedResponse && slicedResponse.length > 0) {\r\n\t\tfor (const item of slicedResponse) {\r\n\t\t\ttry {\r\n\t\t\t\tconst slideElement = await renderSocialWallItem(item, undefined, true);\r\n\t\t\t\tswiperWrapper.appendChild(slideElement);\r\n\t\t\t} catch (e) {\r\n\t\t\t\tconsole.error(e);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tconst mediaWrappers = element?.querySelectorAll(\".media-wrapper\");\r\n\t\tif (mediaWrappers) {\r\n\t\t\taddVideoEventListeners(mediaWrappers);\r\n\t\t}\r\n\t}\r\n\r\n\tremoveLoader(element);\r\n};\r\n\r\nexport default socialWallSlider;"],"names":["slidesCount","socialWallSlider","element","props","swiper","swiperWrapper","addLoader","response","socialWallService","_a","removeLoader","isRtl","bootstrapConstructorOnElement","slider","socialWallItems","x","slicedResponse","item","slideElement","renderSocialWallItem","e","mediaWrappers","addVideoEventListeners"],"mappings":"8MAUA,MAAMA,EAAc,GAEdC,EAAkD,MAAOC,EAASC,IAAU,OAC3E,MAAAC,EAASF,EAAQ,cAA2B,oBAAoB,EAChEG,EAAgBH,EAAQ,cAAc,iBAAiB,EAEzD,GAAA,CAACE,GAAU,CAACC,EAAe,CAC9B,QAAQ,IAAI,wCAAwC,EACpD,MACD,CAEAC,EAAUJ,CAAO,EACX,MAAAK,EAAW,MAAMC,EAAkB,KAAK,CAAE,SAAUL,EAAM,SAAW,EAE3E,GAAII,EAAS,SAASE,EAAAF,EAAS,OAAT,YAAAE,EAAe,UAAW,EAAG,CAClDC,EAAaR,CAAO,EACZ,QAAA,MAAM,mCAAoCK,EAAS,KAAK,EAC5DL,IACHA,EAAQ,UAAY,GAAGS,EACpB,yEACA,iFACF,IAEF,MACD,CAEKP,EAAO,UAAU,SAAS,oBAAoB,GAC5C,MAAAQ,EAA8BR,EAAQS,EAAQ,QAAQ,EAGzD,IAAAC,EAAkBP,EAAS,MAAQ,GACvCO,EAAkBA,EAAgB,OAAYC,GAAAA,EAAE,IAAI,EAEpD,MAAMC,EAAiBF,EAAgB,MAAM,EAAGd,CAAW,EAEvD,GAAAgB,GAAkBA,EAAe,OAAS,EAAG,CAChD,UAAWC,KAAQD,EACd,GAAA,CACH,MAAME,EAAe,MAAMC,EAAqBF,EAAM,OAAW,EAAI,EACrEZ,EAAc,YAAYa,CAAY,QAC9BE,EAAG,CACX,QAAQ,MAAMA,CAAC,CAChB,CAGK,MAAAC,EAAgBnB,GAAA,YAAAA,EAAS,iBAAiB,kBAC5CmB,GACHC,EAAuBD,CAAa,CAEtC,CAEAX,EAAaR,CAAO,CACrB"}