@salla.sa/twilight-components 2.14.24 → 2.14.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/dist/cjs/{Helper-8b706e72.js → Helper-56efb09e.js} +4 -2
  2. package/dist/cjs/Helper-56efb09e.js.map +1 -0
  3. package/dist/cjs/app-globals-9596263d.js.map +1 -1
  4. package/dist/cjs/salla-add-product-button_48.cjs.entry.js +1 -1
  5. package/dist/cjs/salla-add-product-button_48.cjs.entry.js.map +1 -1
  6. package/dist/cjs/salla-filters-widget.cjs.entry.js +1 -1
  7. package/dist/cjs/salla-filters.cjs.entry.js +1 -1
  8. package/dist/cjs/salla-notifications.cjs.entry.js +1 -1
  9. package/dist/cjs/salla-orders.cjs.entry.js +1 -1
  10. package/dist/cjs/salla-products-slider.cjs.entry.js +1 -1
  11. package/dist/cjs/salla-reviews.cjs.entry.js +1 -1
  12. package/dist/collection/Helpers/Helper.js +3 -1
  13. package/dist/collection/Helpers/Helper.js.map +1 -1
  14. package/dist/components/Helper.js +3 -1
  15. package/dist/components/Helper.js.map +1 -1
  16. package/dist/components/index.js.map +1 -1
  17. package/dist/components/salla-quick-buy2.js.map +1 -1
  18. package/dist/esm/{Helper-c5b72361.js → Helper-3025592f.js} +4 -2
  19. package/dist/esm/Helper-3025592f.js.map +1 -0
  20. package/dist/esm/app-globals-15e3c645.js.map +1 -1
  21. package/dist/esm/salla-add-product-button_48.entry.js +1 -1
  22. package/dist/esm/salla-add-product-button_48.entry.js.map +1 -1
  23. package/dist/esm/salla-filters-widget.entry.js +1 -1
  24. package/dist/esm/salla-filters.entry.js +1 -1
  25. package/dist/esm/salla-notifications.entry.js +1 -1
  26. package/dist/esm/salla-orders.entry.js +1 -1
  27. package/dist/esm/salla-products-slider.entry.js +1 -1
  28. package/dist/esm/salla-reviews.entry.js +1 -1
  29. package/dist/esm-es5/Helper-3025592f.js +5 -0
  30. package/dist/esm-es5/Helper-3025592f.js.map +1 -0
  31. package/dist/esm-es5/app-globals-15e3c645.js.map +1 -1
  32. package/dist/esm-es5/salla-add-product-button_48.entry.js +1 -1
  33. package/dist/esm-es5/salla-add-product-button_48.entry.js.map +1 -1
  34. package/dist/esm-es5/salla-filters-widget.entry.js +1 -1
  35. package/dist/esm-es5/salla-filters.entry.js +1 -1
  36. package/dist/esm-es5/salla-notifications.entry.js +1 -1
  37. package/dist/esm-es5/salla-orders.entry.js +1 -1
  38. package/dist/esm-es5/salla-products-slider.entry.js +1 -1
  39. package/dist/esm-es5/salla-reviews.entry.js +1 -1
  40. package/dist/twilight/{p-572be994.system.entry.js → p-00fea9e4.system.entry.js} +2 -2
  41. package/dist/twilight/p-05c5b251.js.map +1 -1
  42. package/dist/twilight/p-12acd128.js +5 -0
  43. package/dist/twilight/p-12acd128.js.map +1 -0
  44. package/dist/twilight/{p-900b41fb.entry.js → p-22c5fed4.entry.js} +2 -2
  45. package/dist/twilight/{p-900b41fb.entry.js.map → p-22c5fed4.entry.js.map} +1 -1
  46. package/dist/twilight/{p-6e0a235a.entry.js → p-29bb96eb.entry.js} +2 -2
  47. package/dist/twilight/{p-c8f14d8f.system.entry.js → p-2a65790e.system.entry.js} +2 -2
  48. package/dist/twilight/{p-012877f7.system.entry.js → p-31f62211.system.entry.js} +2 -2
  49. package/dist/twilight/p-3e698672.system.js.map +1 -1
  50. package/dist/twilight/{p-346b1d3f.system.entry.js → p-672e2d86.system.entry.js} +2 -2
  51. package/dist/twilight/p-7c8ac4aa.system.js +5 -0
  52. package/dist/twilight/p-7c8ac4aa.system.js.map +1 -0
  53. package/dist/twilight/{p-5f689d13.entry.js → p-8a1d8623.entry.js} +2 -2
  54. package/dist/twilight/{p-f07ec02a.entry.js → p-a0138c35.entry.js} +2 -2
  55. package/dist/twilight/{p-4bc35b2b.system.entry.js → p-a24650b3.system.entry.js} +2 -2
  56. package/dist/twilight/{p-f0bfbb14.system.entry.js → p-acdf56d4.system.entry.js} +2 -2
  57. package/dist/twilight/{p-f0bfbb14.system.entry.js.map → p-acdf56d4.system.entry.js.map} +1 -1
  58. package/dist/twilight/{p-1dcd7c3b.entry.js → p-b5c29a36.entry.js} +2 -2
  59. package/dist/twilight/{p-dc21b7de.entry.js → p-c3d862f6.entry.js} +2 -2
  60. package/dist/twilight/p-d2b0dbcd.system.js +1 -1
  61. package/dist/twilight/{p-24062fa1.system.entry.js → p-de44d734.system.entry.js} +2 -2
  62. package/dist/twilight/{p-e0b02e94.entry.js → p-f803b45f.entry.js} +2 -2
  63. package/dist/twilight/twilight.esm.js +1 -1
  64. package/package.json +5 -5
  65. package/dist/cjs/Helper-8b706e72.js.map +0 -1
  66. package/dist/esm/Helper-c5b72361.js.map +0 -1
  67. package/dist/esm-es5/Helper-c5b72361.js +0 -5
  68. package/dist/esm-es5/Helper-c5b72361.js.map +0 -1
  69. package/dist/twilight/p-9776f50d.system.js +0 -5
  70. package/dist/twilight/p-9776f50d.system.js.map +0 -1
  71. package/dist/twilight/p-b9c0ec80.js +0 -5
  72. package/dist/twilight/p-b9c0ec80.js.map +0 -1
  73. /package/dist/twilight/{p-572be994.system.entry.js.map → p-00fea9e4.system.entry.js.map} +0 -0
  74. /package/dist/twilight/{p-6e0a235a.entry.js.map → p-29bb96eb.entry.js.map} +0 -0
  75. /package/dist/twilight/{p-c8f14d8f.system.entry.js.map → p-2a65790e.system.entry.js.map} +0 -0
  76. /package/dist/twilight/{p-012877f7.system.entry.js.map → p-31f62211.system.entry.js.map} +0 -0
  77. /package/dist/twilight/{p-346b1d3f.system.entry.js.map → p-672e2d86.system.entry.js.map} +0 -0
  78. /package/dist/twilight/{p-5f689d13.entry.js.map → p-8a1d8623.entry.js.map} +0 -0
  79. /package/dist/twilight/{p-f07ec02a.entry.js.map → p-a0138c35.entry.js.map} +0 -0
  80. /package/dist/twilight/{p-4bc35b2b.system.entry.js.map → p-a24650b3.system.entry.js.map} +0 -0
  81. /package/dist/twilight/{p-1dcd7c3b.entry.js.map → p-b5c29a36.entry.js.map} +0 -0
  82. /package/dist/twilight/{p-dc21b7de.entry.js.map → p-c3d862f6.entry.js.map} +0 -0
  83. /package/dist/twilight/{p-24062fa1.system.entry.js.map → p-de44d734.system.entry.js.map} +0 -0
  84. /package/dist/twilight/{p-e0b02e94.entry.js.map → p-f803b45f.entry.js.map} +0 -0
@@ -1 +0,0 @@
1
- {"file":"Helper-8b706e72.js","mappings":";;;;;;;AAOA;AACA,KAAK,CAAC,KAAK,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;AAEjC,MAAM,MAAM;EAIV,WAAW,CAAC,QAAiB;IAC3B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IACzB,OAAO,IAAI,CAAC;GACb;EAED,oBAAoB,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ;IACxD,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACpE,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACpE,IAAI,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;IACnC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,CAAC,MAAM,CAAC,IAAI,UAAU,GAAG,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC;IACjE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,CAAC,GAAG,CAAC,IAAI,UAAU,GAAG,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC;IAC9D,OAAO,IAAI,CAAC;GACb;EAED,aAAa,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ;IAClD,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,OAAO,IAAI,IAAI,CAAC,oB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C,CAAA;OACH;KAEF,CAAC,CAAA;GACH;EAED,kBAAkB,CAAC,UAAkB;IACnC,OAAO;MACL,OAAO,EAAE,QAAQ;MACjB,QAAQ,EAAE,UAAU,CAAC,IAAI;MACzB,eAAe,EAAE,UAAU,CAAC,IAAI,GAAG,IAAI;MACvC,aAAa,EAAE,UAAU,CAAC,OAAO;MACjC,cAAc,EAAE;QACd,OAAO,EAAE,QAAQ;QACjB,YAAY,EAAE,GAAG;QACjB,aAAa,EAAE,GAAG;QAClB,aAAa,EAAE,GAAG;OACnB;KACF,CAAC;GACH;EAED,oBAAoB,CAAC,OAAsB;IACzC,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChD,MAAM,CAAC,IAAI,GAAG,qBAAqB,CAAC;IAGpC,MAAM,MAAM,GAAG;MACb,UAAU,EAAE,oBAAoB;MAChC,OAAO,EAAE,gBAAgB;MACzB,MAAM,EAAE,eAAe;MACvB,aAAa,EAAE,6BAA6B;MAC5C,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;KACnE,CAAA;IAED,MAAM,CAAC,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC5C,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;GACnC;CACF;AAED,iBAAe,IAAI,MAAM;;;;","names":["anime"],"sources":["src/Helpers/Helper.ts"],"sourcesContent":["import { ProductDetail } from \"@salla.sa/twilight/types/api/product\";\nimport { Review } from \"../../src/components/salla-reviews/interfaces\";\nimport { Product as SallaProduct } from \"@salla.sa/twilight/types/common\";\nimport { ListItem, ItemList, Product as SchemaProduct, WithContext } from 'schema-dts';\nimport { Product } from '@salla.sa/twilight/types/common';\nimport anime from 'animejs';\n\n//TODO::reduce it to 10\nsalla.event.setMaxListeners(100);\n\nclass Helper {\n private debounce_: any;\n private includes;\n\n setIncludes(includes:string[]){\n this.includes = includes;\n return this;\n }\n\n toggleElementClassIf(element, classes1, classes2, callback) {\n classes1 = Array.isArray(classes1) ? classes1 : classes1.split(' ');\n classes2 = Array.isArray(classes2) ? classes2 : classes2.split(' ');\n let isClasses1 = callback(element);\n element?.classList.remove(...(isClasses1 ? classes2 : classes1));\n element?.classList.add(...(isClasses1 ? classes1 : classes2));\n return this;\n }\n\n toggleClassIf(selector, classes1, classes2, callback) {\n document.querySelectorAll(selector).forEach(element => this.toggleElementClassIf(element, classes1, classes2, callback));\n return this;\n }\n\n isValidEmail(email) {\n const re = /^(([^<>()[\\]\\\\.,;:\\s@\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/;\n return re.test(String(email).toLowerCase());\n }\n\n filterEmojies(text) {\n var characterFilter = /(?:[\\u2700-\\u27bf]|(?:\\ud83c[\\udde6-\\uddff]){2}|[\\ud800-\\udbff][\\udc00-\\udfff]|[\\u0023-\\u0039]\\ufe0f?\\u20e3|\\u3299|\\u3297|\\u303d|\\u3030|\\u24c2|\\ud83c[\\udd70-\\udd71]|\\ud83c[\\udd7e-\\udd7f]|\\ud83c\\udd8e|\\ud83c[\\udd91-\\udd9a]|\\ud83c[\\udde6-\\uddff]|\\ud83c[\\ude01-\\ude02]|\\ud83c\\ude1a|\\ud83c\\ude2f|\\ud83c[\\ude32-\\ude3a]|\\ud83c[\\ude50-\\ude51]|\\u203c|\\u2049|[\\u25aa-\\u25ab]|\\u25b6|\\u25c0|[\\u25fb-\\u25fe]|\\u00a9|\\u00ae|\\u2122|\\u2139|\\ud83c\\udc04|[\\u2600-\\u26FF]|\\u2b05|\\u2b06|\\u2b07|\\u2b1b|\\u2b1c|\\u2b50|\\u2b55|\\u231a|\\u231b|\\u2328|\\u23cf|[\\u23e9-\\u23f3]|[\\u23f8-\\u23fa]|\\ud83c\\udccf|\\u2934|\\u2935|[\\u2190-\\u21ff])/g;\n return text.replace(characterFilter, \"\");\n }\n\n debounce(fn, ...data) {\n if (!this.debounce_) {\n this.debounce_ = salla.helpers.debounce((callback, ...innerData) => callback(...innerData), 500);\n }\n //@ts-ignore\n return this.debounce_(fn, ...data);\n }\n\n getProductsSource(source) {\n return {\n 'brands.single': 'brands',\n 'product.index': 'categories',\n 'product.index.latest': 'latest',\n 'product.index.offers': 'offers',\n 'product.index.search': 'search',\n 'customer.wishlist': 'wishlist',\n 'landing-page': 'landing-page',\n 'product.index.tag': 'tags',\n 'product.index.sales': 'sales',\n 'components.most_sales_products': 'sales',//temporary, delete it after two days from now\n }[source || salla.config.get('page.slug')] || source || 'latest';\n }\n\n getPageTitleForSource(source) {\n\n source = {\n 'brands': 'common.titles.brands',\n // 'categories':'',\n 'latest': 'blocks.home.latest_products',\n 'offers': 'common.titles.discounts',\n // 'search':'',\n // 'landing-page':'',\n // 'tags':'',\n 'sales': 'common.titles.most_sales',\n }[source];\n\n return source ? salla.lang.get(source) : '';\n }\n\n getProductsSourceValue(source, sourceValue) {\n const parsedSource = this.getProductsSource(source);\n\n // Validate if the source value is a valid JSON string\n let parsedSourceValue: any = null;\n if (sourceValue) {\n try {\n parsedSourceValue = JSON.parse(sourceValue);\n } catch (error) {\n console.error('Invalid JSON string in sourceValue:', error);\n }\n }\n\n // Handle different source types\n if (!['search', 'json', 'offers', 'latest', 'sales', 'related'].includes(parsedSource)) {\n\n if (Array.isArray(parsedSourceValue) && parsedSourceValue.length) {\n return parsedSourceValue;\n }\n\n\n if (Array.isArray(parsedSourceValue) && !parsedSourceValue.length) {\n return '';\n }\n\n if (typeof parsedSourceValue === 'number') {\n return [parsedSourceValue];\n }\n\n if (!sourceValue && ['categories', 'tags', 'brands'].includes(source)) {\n return [salla.config.get('page.id')];\n }\n }\n\n // Return sourceValue if it exists and is a valid JSON object/array\n if (parsedSourceValue || sourceValue) {\n return parsedSourceValue || sourceValue;\n }\n\n if (parsedSource === 'search') {\n return new URLSearchParams(window.location.search).get('q') || '';\n }\n\n // Return page id as default value\n return salla.config.get('page.id');\n }\n\n extractFiltersFromUrl(searchParams) {\n let filters = {};\n searchParams.forEach((value, key) => {\n // Handle filters[xxx] format\n const matchesNested = key.match(/^filters\\[(.*?)\\](\\[(.*?)\\])?$/u);\n\n if (matchesNested) {\n const filterName = matchesNested[1];\n const nestedKey = matchesNested[3];\n\n if (nestedKey) {\n // Handle nested object\n filters[filterName] = filters[filterName] || {};\n filters[filterName][nestedKey] = value;\n } else {\n // Handle regular key\n filters[filterName] = value;\n }\n } else {\n // Handle simple key-value pairs\n const matchesSimple = key.match(/^(.*?)$/u);\n\n if (matchesSimple) {\n filters[matchesSimple[1]] = value;\n }\n }\n });\n return filters;\n }\n\n injectExtraFieldsToResponse( response: {data:Product[]}) {\n if (!response || !this.includes) return response;\n\n const productIds = response.data.map(product => product.id);\n\n return this.fetchImagesAndOptions(productIds)\n .then(({ data: product }) => this.injectOptionsAndImages(response.data, product))\n .then(() => {\n if(!this.includes.includes('metadata')){\n return response;\n }\n\n return salla.api.metadata.fetchValues('product', productIds)\n //@ts-ignore\n .then(({data}) => response.data.map(product => ({...product, metadata: data.find(meta => parseInt(meta.entity_id) === parseInt(product.id))})))\n .then(() => response);\n });\n }\n\n /**\n * This to make sure we will not request the options endpoint unless we have to.\n */\n fetchImagesAndOptions(productIds){\n return this.productsIncludes().length\n ? salla.api.product.fetchOptions(productIds, { with: this.productsIncludes() })\n : Promise.resolve({data:[]}); //fake the endpoint, to reduce unwanted query if developer wants metadata only\n }\n\n\n injectOptionsAndImages( productList: Product[], newData: Product[] ): Product[] {\n return newData.length\n ? productList.map(product => {\n this.includes\n .filter(field => field !== 'metadata')\n .forEach(field => {\n //@ts-ignore\n const foundProduct = newData.find((prod: Product) => parseInt(prod.id) === parseInt(product.id));\n product[field] = foundProduct ? foundProduct[field] : null; // Assign null or a default value if not found\n });\n return product;\n })\n :null;\n }\n\n productsIncludes(){\n return this.includes?.filter(field => field != 'metadata');\n }\n\n parseJson(includes: string | string[]): null | string[] {\n if (typeof includes !== 'string') {\n return includes;\n }\n try {\n return JSON.parse(includes);\n } catch (e) {\n salla.logger.error('Failed to parse includes as JSON:', e);\n }\n\n return null;\n }\n\n getProductSchemaMarkupScript(product: any): HTMLScriptElement {\n const scriptElement = document.createElement('script');\n scriptElement.type = 'application/ld+json';\n // TODO: This json object MIGHT need mode data or properties.\n const jsonData = {\n \"@context\": \"http://schema.org\",\n \"@type\": \"Product\",\n \"name\": product?.name,\n \"image\": product?.image?.url || product?.thumbnail,\n \"description\": product?.description,\n \"brand\": {\n \"@type\": \"Brand\",\n \"logo\": product?.brand?.logo\n },\n \"offers\": {\n \"@type\": \"Offer\",\n \"price\": product?.price\n }\n };\n scriptElement.text = JSON.stringify(jsonData);\n return scriptElement\n }\n\n createProductSchema(product: SallaProduct | ProductDetail, position: number): ListItem {\n let ProductSchema: SchemaProduct = {\n \"productID\": `${product.id}`,\n \"@type\": 'Product',\n \"name\": product.name,\n \"url\": product.url,\n \"image\": product.image.url || (product.image as string),\n \"description\": product.description || product.subtitle || product.name,\n \"offers\": {\n \"@type\": \"Offer\",\n \"url\": product.url,\n \"priceCurrency\": product.currency,\n \"price\": product.price,\n \"itemCondition\": \"NewCondition\",\n \"availability\": product.is_available ? \"InStock\" : \"OutOfStock\",\n //if there is no product.discount_ends, will set it to be valid until the end of this week\n \"priceValidUntil\": product.discount_ends || (new Date(new Date().setDate(new Date().getDate() + 7)).toISOString().split('T')[0]),\n \"priceSpecification\": {\n \"@type\": \"PriceSpecification\",\n \"price\": product.regular_price,\n \"priceCurrency\": product.currency,\n \"valueAddedTaxIncluded\": product.is_taxable,\n },\n \"seller\": {\n \"@type\": \"Organization\",\n \"name\": salla.config.get('store.name'),\n },\n }\n };\n //@ts-ignore\n if (product.rating?.stars) {\n ProductSchema.aggregateRating = {\n \"@type\": \"AggregateRating\",\n //@ts-ignore\n \"ratingValue\": product.rating.stars,\n \"reviewCount\": product.rating.count,\n };\n }\n\n\n return {\n \"@type\": \"ListItem\",\n \"position\": position,\n \"item\": ProductSchema,\n\n };\n }\n \n generateProductSchema(productList: Array<SallaProduct | ProductDetail>) {\n const schemaId = 'salla-product-schema-script';\n if (document.getElementById(schemaId)) {\n salla.logger.warn(`already added schema-script with id (${schemaId})!`)\n return;\n }\n\n const script = document.createElement('script');\n script.type = 'application/ld+json';\n script.id = schemaId;\n\n\n const schema: WithContext<ItemList> = {\n \"@context\": \"https://schema.org\",\n \"@type\": \"ItemList\",\n \"name\": salla.config.get('page.title'),\n \"itemListElement\": productList.map((product, indxe) => this.createProductSchema(product, indxe + 1)),\n };\n\n script.textContent = JSON.stringify(schema);\n document.head.appendChild(script);\n }\n\n /**\n * Format date in the form of `Monday 13 November 2023`\n */\n formatDateFromString(dateString: string, numberCb: Function, lang: string = 'en'): string {\n const dateObject = new Date(dateString);\n\n const errors = {\n en: \"Invalid Date\",\n ar: \"تاريخ غير صالح\"\n }\n\n if (isNaN(dateObject.getTime())) {\n return errors[lang];\n }\n\n const daysOfWeek = {\n en: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],\n ar: ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت']\n };\n const months = {\n en: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],\n ar: ['يناير', 'فبراير', 'مارس', 'أبريل', 'مايو', 'يونيو', 'يوليو', 'أغسطس', 'سبتمبر', 'أكتوبر', 'نوفمبر', 'ديسمبر']\n };\n\n const dayOfWeek = daysOfWeek[lang][dateObject.getDay()];\n const dayOfMonth = numberCb(dateObject.getDate(), lang === 'en');\n const month = months[lang][dateObject.getMonth()];\n const year = numberCb(dateObject.getFullYear(), lang === 'en');\n\n return `${dayOfWeek} ${dayOfMonth} ${month} ${year}`;\n }\n\n /**\n * Copy text into clipboard.\n * @param event \n */\n copyToClipboard(event) {\n // Get the text content from the clicked div\n var textToCopy = event.target.innerText;\n\n // Use the Clipboard API to copy text to the clipboard\n navigator.clipboard.writeText(textToCopy)\n .then(() => {\n console.log('Text copied to clipboard: ' + textToCopy);\n })\n .catch(err => {\n console.error('Unable to copy text to clipboard', err);\n });\n\n }\n\n animateItems(items: NodeListOf<Element>) {\n if (!items) return;\n anime({\n targets: items,\n opacity: [0, 1],\n duration: 1200,\n translateY: [20, 0],\n delay: function (_el, i) {\n return i * 100;\n },\n easing: 'easeOutExpo',\n complete: function (_anim) {\n items.forEach((item: Element) => {\n item.classList.add('animated');\n })\n }\n\n })\n }\n\n createReviewObject(reviewData: Review) {\n return {\n \"@type\": \"Review\",\n \"author\": reviewData.name,\n \"datePublished\": reviewData.date * 1000,\n \"description\": reviewData.content,\n \"reviewRating\": {\n \"@type\": \"Rating\",\n \"bestRating\": \"5\",\n \"ratingValue\": \"5\",\n \"worstRating\": \"1\"\n }\n };\n }\n\n generateReviewSchema(reviews: Array<Review>){\n const script = document.createElement('script');\n script.type = 'application/ld+json';\n\n\n const schema = {\n \"@context\": \"http://schema.org/\",\n \"@type\": \"CollectionPage\",\n \"name\": \"Category Name\", // TODO: check for the correct value here\n \"description\": \"Description of the category\", // TODO: here too\n \"review\": reviews.map((review) => this.createReviewObject(review))\n }\n\n script.textContent = JSON.stringify(schema);\n document.head.appendChild(script);\n }\n}\n\nexport default new Helper;\n"],"version":3}
@@ -1 +0,0 @@
1
- {"file":"Helper-c5b72361.js","mappings":";;;;;AAOA;AACA,KAAK,CAAC,KAAK,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;AAEjC,MAAM,MAAM;EAIV,WAAW,CAAC,QAAiB;IAC3B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IACzB,OAAO,IAAI,CAAC;GACb;EAED,oBAAoB,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAA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MAAM,MAAM,GAAG;MACb,UAAU,EAAE,oBAAoB;MAChC,OAAO,EAAE,gBAAgB;MACzB,MAAM,EAAE,eAAe;MACvB,aAAa,EAAE,6BAA6B;MAC5C,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;KACnE,CAAA;IAED,MAAM,CAAC,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC5C,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;GACnC;CACF;AAED,iBAAe,IAAI,MAAM;;;;","names":[],"sources":["src/Helpers/Helper.ts"],"sourcesContent":["import { ProductDetail } from \"@salla.sa/twilight/types/api/product\";\nimport { Review } from \"../../src/components/salla-reviews/interfaces\";\nimport { Product as SallaProduct } from \"@salla.sa/twilight/types/common\";\nimport { ListItem, ItemList, Product as SchemaProduct, WithContext } from 'schema-dts';\nimport { Product } from '@salla.sa/twilight/types/common';\nimport anime from 'animejs';\n\n//TODO::reduce it to 10\nsalla.event.setMaxListeners(100);\n\nclass Helper {\n private debounce_: any;\n private includes;\n\n setIncludes(includes:string[]){\n this.includes = includes;\n return this;\n }\n\n toggleElementClassIf(element, classes1, classes2, callback) {\n classes1 = Array.isArray(classes1) ? classes1 : classes1.split(' ');\n classes2 = Array.isArray(classes2) ? classes2 : classes2.split(' ');\n let isClasses1 = callback(element);\n element?.classList.remove(...(isClasses1 ? classes2 : classes1));\n element?.classList.add(...(isClasses1 ? classes1 : classes2));\n return this;\n }\n\n toggleClassIf(selector, classes1, classes2, callback) {\n document.querySelectorAll(selector).forEach(element => this.toggleElementClassIf(element, classes1, classes2, callback));\n return this;\n }\n\n isValidEmail(email) {\n const re = /^(([^<>()[\\]\\\\.,;:\\s@\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/;\n return re.test(String(email).toLowerCase());\n }\n\n filterEmojies(text) {\n var characterFilter = /(?:[\\u2700-\\u27bf]|(?:\\ud83c[\\udde6-\\uddff]){2}|[\\ud800-\\udbff][\\udc00-\\udfff]|[\\u0023-\\u0039]\\ufe0f?\\u20e3|\\u3299|\\u3297|\\u303d|\\u3030|\\u24c2|\\ud83c[\\udd70-\\udd71]|\\ud83c[\\udd7e-\\udd7f]|\\ud83c\\udd8e|\\ud83c[\\udd91-\\udd9a]|\\ud83c[\\udde6-\\uddff]|\\ud83c[\\ude01-\\ude02]|\\ud83c\\ude1a|\\ud83c\\ude2f|\\ud83c[\\ude32-\\ude3a]|\\ud83c[\\ude50-\\ude51]|\\u203c|\\u2049|[\\u25aa-\\u25ab]|\\u25b6|\\u25c0|[\\u25fb-\\u25fe]|\\u00a9|\\u00ae|\\u2122|\\u2139|\\ud83c\\udc04|[\\u2600-\\u26FF]|\\u2b05|\\u2b06|\\u2b07|\\u2b1b|\\u2b1c|\\u2b50|\\u2b55|\\u231a|\\u231b|\\u2328|\\u23cf|[\\u23e9-\\u23f3]|[\\u23f8-\\u23fa]|\\ud83c\\udccf|\\u2934|\\u2935|[\\u2190-\\u21ff])/g;\n return text.replace(characterFilter, \"\");\n }\n\n debounce(fn, ...data) {\n if (!this.debounce_) {\n this.debounce_ = salla.helpers.debounce((callback, ...innerData) => callback(...innerData), 500);\n }\n //@ts-ignore\n return this.debounce_(fn, ...data);\n }\n\n getProductsSource(source) {\n return {\n 'brands.single': 'brands',\n 'product.index': 'categories',\n 'product.index.latest': 'latest',\n 'product.index.offers': 'offers',\n 'product.index.search': 'search',\n 'customer.wishlist': 'wishlist',\n 'landing-page': 'landing-page',\n 'product.index.tag': 'tags',\n 'product.index.sales': 'sales',\n 'components.most_sales_products': 'sales',//temporary, delete it after two days from now\n }[source || salla.config.get('page.slug')] || source || 'latest';\n }\n\n getPageTitleForSource(source) {\n\n source = {\n 'brands': 'common.titles.brands',\n // 'categories':'',\n 'latest': 'blocks.home.latest_products',\n 'offers': 'common.titles.discounts',\n // 'search':'',\n // 'landing-page':'',\n // 'tags':'',\n 'sales': 'common.titles.most_sales',\n }[source];\n\n return source ? salla.lang.get(source) : '';\n }\n\n getProductsSourceValue(source, sourceValue) {\n const parsedSource = this.getProductsSource(source);\n\n // Validate if the source value is a valid JSON string\n let parsedSourceValue: any = null;\n if (sourceValue) {\n try {\n parsedSourceValue = JSON.parse(sourceValue);\n } catch (error) {\n console.error('Invalid JSON string in sourceValue:', error);\n }\n }\n\n // Handle different source types\n if (!['search', 'json', 'offers', 'latest', 'sales', 'related'].includes(parsedSource)) {\n\n if (Array.isArray(parsedSourceValue) && parsedSourceValue.length) {\n return parsedSourceValue;\n }\n\n\n if (Array.isArray(parsedSourceValue) && !parsedSourceValue.length) {\n return '';\n }\n\n if (typeof parsedSourceValue === 'number') {\n return [parsedSourceValue];\n }\n\n if (!sourceValue && ['categories', 'tags', 'brands'].includes(source)) {\n return [salla.config.get('page.id')];\n }\n }\n\n // Return sourceValue if it exists and is a valid JSON object/array\n if (parsedSourceValue || sourceValue) {\n return parsedSourceValue || sourceValue;\n }\n\n if (parsedSource === 'search') {\n return new URLSearchParams(window.location.search).get('q') || '';\n }\n\n // Return page id as default value\n return salla.config.get('page.id');\n }\n\n extractFiltersFromUrl(searchParams) {\n let filters = {};\n searchParams.forEach((value, key) => {\n // Handle filters[xxx] format\n const matchesNested = key.match(/^filters\\[(.*?)\\](\\[(.*?)\\])?$/u);\n\n if (matchesNested) {\n const filterName = matchesNested[1];\n const nestedKey = matchesNested[3];\n\n if (nestedKey) {\n // Handle nested object\n filters[filterName] = filters[filterName] || {};\n filters[filterName][nestedKey] = value;\n } else {\n // Handle regular key\n filters[filterName] = value;\n }\n } else {\n // Handle simple key-value pairs\n const matchesSimple = key.match(/^(.*?)$/u);\n\n if (matchesSimple) {\n filters[matchesSimple[1]] = value;\n }\n }\n });\n return filters;\n }\n\n injectExtraFieldsToResponse( response: {data:Product[]}) {\n if (!response || !this.includes) return response;\n\n const productIds = response.data.map(product => product.id);\n\n return this.fetchImagesAndOptions(productIds)\n .then(({ data: product }) => this.injectOptionsAndImages(response.data, product))\n .then(() => {\n if(!this.includes.includes('metadata')){\n return response;\n }\n\n return salla.api.metadata.fetchValues('product', productIds)\n //@ts-ignore\n .then(({data}) => response.data.map(product => ({...product, metadata: data.find(meta => parseInt(meta.entity_id) === parseInt(product.id))})))\n .then(() => response);\n });\n }\n\n /**\n * This to make sure we will not request the options endpoint unless we have to.\n */\n fetchImagesAndOptions(productIds){\n return this.productsIncludes().length\n ? salla.api.product.fetchOptions(productIds, { with: this.productsIncludes() })\n : Promise.resolve({data:[]}); //fake the endpoint, to reduce unwanted query if developer wants metadata only\n }\n\n\n injectOptionsAndImages( productList: Product[], newData: Product[] ): Product[] {\n return newData.length\n ? productList.map(product => {\n this.includes\n .filter(field => field !== 'metadata')\n .forEach(field => {\n //@ts-ignore\n const foundProduct = newData.find((prod: Product) => parseInt(prod.id) === parseInt(product.id));\n product[field] = foundProduct ? foundProduct[field] : null; // Assign null or a default value if not found\n });\n return product;\n })\n :null;\n }\n\n productsIncludes(){\n return this.includes?.filter(field => field != 'metadata');\n }\n\n parseJson(includes: string | string[]): null | string[] {\n if (typeof includes !== 'string') {\n return includes;\n }\n try {\n return JSON.parse(includes);\n } catch (e) {\n salla.logger.error('Failed to parse includes as JSON:', e);\n }\n\n return null;\n }\n\n getProductSchemaMarkupScript(product: any): HTMLScriptElement {\n const scriptElement = document.createElement('script');\n scriptElement.type = 'application/ld+json';\n // TODO: This json object MIGHT need mode data or properties.\n const jsonData = {\n \"@context\": \"http://schema.org\",\n \"@type\": \"Product\",\n \"name\": product?.name,\n \"image\": product?.image?.url || product?.thumbnail,\n \"description\": product?.description,\n \"brand\": {\n \"@type\": \"Brand\",\n \"logo\": product?.brand?.logo\n },\n \"offers\": {\n \"@type\": \"Offer\",\n \"price\": product?.price\n }\n };\n scriptElement.text = JSON.stringify(jsonData);\n return scriptElement\n }\n\n createProductSchema(product: SallaProduct | ProductDetail, position: number): ListItem {\n let ProductSchema: SchemaProduct = {\n \"productID\": `${product.id}`,\n \"@type\": 'Product',\n \"name\": product.name,\n \"url\": product.url,\n \"image\": product.image.url || (product.image as string),\n \"description\": product.description || product.subtitle || product.name,\n \"offers\": {\n \"@type\": \"Offer\",\n \"url\": product.url,\n \"priceCurrency\": product.currency,\n \"price\": product.price,\n \"itemCondition\": \"NewCondition\",\n \"availability\": product.is_available ? \"InStock\" : \"OutOfStock\",\n //if there is no product.discount_ends, will set it to be valid until the end of this week\n \"priceValidUntil\": product.discount_ends || (new Date(new Date().setDate(new Date().getDate() + 7)).toISOString().split('T')[0]),\n \"priceSpecification\": {\n \"@type\": \"PriceSpecification\",\n \"price\": product.regular_price,\n \"priceCurrency\": product.currency,\n \"valueAddedTaxIncluded\": product.is_taxable,\n },\n \"seller\": {\n \"@type\": \"Organization\",\n \"name\": salla.config.get('store.name'),\n },\n }\n };\n //@ts-ignore\n if (product.rating?.stars) {\n ProductSchema.aggregateRating = {\n \"@type\": \"AggregateRating\",\n //@ts-ignore\n \"ratingValue\": product.rating.stars,\n \"reviewCount\": product.rating.count,\n };\n }\n\n\n return {\n \"@type\": \"ListItem\",\n \"position\": position,\n \"item\": ProductSchema,\n\n };\n }\n \n generateProductSchema(productList: Array<SallaProduct | ProductDetail>) {\n const schemaId = 'salla-product-schema-script';\n if (document.getElementById(schemaId)) {\n salla.logger.warn(`already added schema-script with id (${schemaId})!`)\n return;\n }\n\n const script = document.createElement('script');\n script.type = 'application/ld+json';\n script.id = schemaId;\n\n\n const schema: WithContext<ItemList> = {\n \"@context\": \"https://schema.org\",\n \"@type\": \"ItemList\",\n \"name\": salla.config.get('page.title'),\n \"itemListElement\": productList.map((product, indxe) => this.createProductSchema(product, indxe + 1)),\n };\n\n script.textContent = JSON.stringify(schema);\n document.head.appendChild(script);\n }\n\n /**\n * Format date in the form of `Monday 13 November 2023`\n */\n formatDateFromString(dateString: string, numberCb: Function, lang: string = 'en'): string {\n const dateObject = new Date(dateString);\n\n const errors = {\n en: \"Invalid Date\",\n ar: \"تاريخ غير صالح\"\n }\n\n if (isNaN(dateObject.getTime())) {\n return errors[lang];\n }\n\n const daysOfWeek = {\n en: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],\n ar: ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت']\n };\n const months = {\n en: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],\n ar: ['يناير', 'فبراير', 'مارس', 'أبريل', 'مايو', 'يونيو', 'يوليو', 'أغسطس', 'سبتمبر', 'أكتوبر', 'نوفمبر', 'ديسمبر']\n };\n\n const dayOfWeek = daysOfWeek[lang][dateObject.getDay()];\n const dayOfMonth = numberCb(dateObject.getDate(), lang === 'en');\n const month = months[lang][dateObject.getMonth()];\n const year = numberCb(dateObject.getFullYear(), lang === 'en');\n\n return `${dayOfWeek} ${dayOfMonth} ${month} ${year}`;\n }\n\n /**\n * Copy text into clipboard.\n * @param event \n */\n copyToClipboard(event) {\n // Get the text content from the clicked div\n var textToCopy = event.target.innerText;\n\n // Use the Clipboard API to copy text to the clipboard\n navigator.clipboard.writeText(textToCopy)\n .then(() => {\n console.log('Text copied to clipboard: ' + textToCopy);\n })\n .catch(err => {\n console.error('Unable to copy text to clipboard', err);\n });\n\n }\n\n animateItems(items: NodeListOf<Element>) {\n if (!items) return;\n anime({\n targets: items,\n opacity: [0, 1],\n duration: 1200,\n translateY: [20, 0],\n delay: function (_el, i) {\n return i * 100;\n },\n easing: 'easeOutExpo',\n complete: function (_anim) {\n items.forEach((item: Element) => {\n item.classList.add('animated');\n })\n }\n\n })\n }\n\n createReviewObject(reviewData: Review) {\n return {\n \"@type\": \"Review\",\n \"author\": reviewData.name,\n \"datePublished\": reviewData.date * 1000,\n \"description\": reviewData.content,\n \"reviewRating\": {\n \"@type\": \"Rating\",\n \"bestRating\": \"5\",\n \"ratingValue\": \"5\",\n \"worstRating\": \"1\"\n }\n };\n }\n\n generateReviewSchema(reviews: Array<Review>){\n const script = document.createElement('script');\n script.type = 'application/ld+json';\n\n\n const schema = {\n \"@context\": \"http://schema.org/\",\n \"@type\": \"CollectionPage\",\n \"name\": \"Category Name\", // TODO: check for the correct value here\n \"description\": \"Description of the category\", // TODO: here too\n \"review\": reviews.map((review) => this.createReviewObject(review))\n }\n\n script.textContent = JSON.stringify(schema);\n document.head.appendChild(script);\n }\n}\n\nexport default new Helper;\n"],"version":3}
@@ -1,5 +0,0 @@
1
- var __spreadArray=this&&this.__spreadArray||function(e,t,r){if(r||arguments.length===2)for(var n=0,a=t.length,i;n<a;n++){if(i||!(n in t)){if(!i)i=Array.prototype.slice.call(t,0,n);i[n]=t[n]}}return e.concat(i||Array.prototype.slice.call(t))};
2
- /*!
3
- * Crafted with ❤ by Salla
4
- */import{a as anime}from"./anime.es-6b92d9cd.js";salla.event.setMaxListeners(100);var Helper=function(){function e(){}e.prototype.setIncludes=function(e){this.includes=e;return this};e.prototype.toggleElementClassIf=function(e,t,r,n){var a,i;t=Array.isArray(t)?t:t.split(" ");r=Array.isArray(r)?r:r.split(" ");var o=n(e);e===null||e===void 0?void 0:(a=e.classList).remove.apply(a,o?r:t);e===null||e===void 0?void 0:(i=e.classList).add.apply(i,o?t:r);return this};e.prototype.toggleClassIf=function(e,t,r,n){var a=this;document.querySelectorAll(e).forEach((function(e){return a.toggleElementClassIf(e,t,r,n)}));return this};e.prototype.isValidEmail=function(e){var t=/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;return t.test(String(e).toLowerCase())};e.prototype.filterEmojies=function(e){var t=/(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff]|[\u0023-\u0039]\ufe0f?\u20e3|\u3299|\u3297|\u303d|\u3030|\u24c2|\ud83c[\udd70-\udd71]|\ud83c[\udd7e-\udd7f]|\ud83c\udd8e|\ud83c[\udd91-\udd9a]|\ud83c[\udde6-\uddff]|\ud83c[\ude01-\ude02]|\ud83c\ude1a|\ud83c\ude2f|\ud83c[\ude32-\ude3a]|\ud83c[\ude50-\ude51]|\u203c|\u2049|[\u25aa-\u25ab]|\u25b6|\u25c0|[\u25fb-\u25fe]|\u00a9|\u00ae|\u2122|\u2139|\ud83c\udc04|[\u2600-\u26FF]|\u2b05|\u2b06|\u2b07|\u2b1b|\u2b1c|\u2b50|\u2b55|\u231a|\u231b|\u2328|\u23cf|[\u23e9-\u23f3]|[\u23f8-\u23fa]|\ud83c\udccf|\u2934|\u2935|[\u2190-\u21ff])/g;return e.replace(t,"")};e.prototype.debounce=function(e){var t=[];for(var r=1;r<arguments.length;r++){t[r-1]=arguments[r]}if(!this.debounce_){this.debounce_=salla.helpers.debounce((function(e){var t=[];for(var r=1;r<arguments.length;r++){t[r-1]=arguments[r]}return e.apply(void 0,t)}),500)}return this.debounce_.apply(this,__spreadArray([e],t,false))};e.prototype.getProductsSource=function(e){return{"brands.single":"brands","product.index":"categories","product.index.latest":"latest","product.index.offers":"offers","product.index.search":"search","customer.wishlist":"wishlist","landing-page":"landing-page","product.index.tag":"tags","product.index.sales":"sales","components.most_sales_products":"sales"}[e||salla.config.get("page.slug")]||e||"latest"};e.prototype.getPageTitleForSource=function(e){e={brands:"common.titles.brands",latest:"blocks.home.latest_products",offers:"common.titles.discounts",sales:"common.titles.most_sales"}[e];return e?salla.lang.get(e):""};e.prototype.getProductsSourceValue=function(e,t){var r=this.getProductsSource(e);var n=null;if(t){try{n=JSON.parse(t)}catch(e){console.error("Invalid JSON string in sourceValue:",e)}}if(!["search","json","offers","latest","sales","related"].includes(r)){if(Array.isArray(n)&&n.length){return n}if(Array.isArray(n)&&!n.length){return""}if(typeof n==="number"){return[n]}if(!t&&["categories","tags","brands"].includes(e)){return[salla.config.get("page.id")]}}if(n||t){return n||t}if(r==="search"){return new URLSearchParams(window.location.search).get("q")||""}return salla.config.get("page.id")};e.prototype.extractFiltersFromUrl=function(e){var t={};e.forEach((function(e,r){var n=r.match(/^filters\[(.*?)\](\[(.*?)\])?$/u);if(n){var a=n[1];var i=n[3];if(i){t[a]=t[a]||{};t[a][i]=e}else{t[a]=e}}else{var o=r.match(/^(.*?)$/u);if(o){t[o[1]]=e}}}));return t};e.prototype.injectExtraFieldsToResponse=function(e){var t=this;if(!e||!this.includes)return e;var r=e.data.map((function(e){return e.id}));return this.fetchImagesAndOptions(r).then((function(r){var n=r.data;return t.injectOptionsAndImages(e.data,n)})).then((function(){if(!t.includes.includes("metadata")){return e}return salla.api.metadata.fetchValues("product",r).then((function(t){var r=t.data;return e.data.map((function(e){return Object.assign(Object.assign({},e),{metadata:r.find((function(t){return parseInt(t.entity_id)===parseInt(e.id)}))})}))})).then((function(){return e}))}))};e.prototype.fetchImagesAndOptions=function(e){return this.productsIncludes().length?salla.api.product.fetchOptions(e,{with:this.productsIncludes()}):Promise.resolve({data:[]})};e.prototype.injectOptionsAndImages=function(e,t){var r=this;return t.length?e.map((function(e){r.includes.filter((function(e){return e!=="metadata"})).forEach((function(r){var n=t.find((function(t){return parseInt(t.id)===parseInt(e.id)}));e[r]=n?n[r]:null}));return e})):null};e.prototype.productsIncludes=function(){var e;return(e=this.includes)===null||e===void 0?void 0:e.filter((function(e){return e!="metadata"}))};e.prototype.parseJson=function(e){if(typeof e!=="string"){return e}try{return JSON.parse(e)}catch(e){salla.logger.error("Failed to parse includes as JSON:",e)}return null};e.prototype.getProductSchemaMarkupScript=function(e){var t,r;var n=document.createElement("script");n.type="application/ld+json";var a={"@context":"http://schema.org","@type":"Product",name:e===null||e===void 0?void 0:e.name,image:((t=e===null||e===void 0?void 0:e.image)===null||t===void 0?void 0:t.url)||(e===null||e===void 0?void 0:e.thumbnail),description:e===null||e===void 0?void 0:e.description,brand:{"@type":"Brand",logo:(r=e===null||e===void 0?void 0:e.brand)===null||r===void 0?void 0:r.logo},offers:{"@type":"Offer",price:e===null||e===void 0?void 0:e.price}};n.text=JSON.stringify(a);return n};e.prototype.createProductSchema=function(e,t){var r;var n={productID:"".concat(e.id),"@type":"Product",name:e.name,url:e.url,image:e.image.url||e.image,description:e.description||e.subtitle||e.name,offers:{"@type":"Offer",url:e.url,priceCurrency:e.currency,price:e.price,itemCondition:"NewCondition",availability:e.is_available?"InStock":"OutOfStock",priceValidUntil:e.discount_ends||new Date((new Date).setDate((new Date).getDate()+7)).toISOString().split("T")[0],priceSpecification:{"@type":"PriceSpecification",price:e.regular_price,priceCurrency:e.currency,valueAddedTaxIncluded:e.is_taxable},seller:{"@type":"Organization",name:salla.config.get("store.name")}}};if((r=e.rating)===null||r===void 0?void 0:r.stars){n.aggregateRating={"@type":"AggregateRating",ratingValue:e.rating.stars,reviewCount:e.rating.count}}return{"@type":"ListItem",position:t,item:n}};e.prototype.generateProductSchema=function(e){var t=this;var r="salla-product-schema-script";if(document.getElementById(r)){salla.logger.warn("already added schema-script with id (".concat(r,")!"));return}var n=document.createElement("script");n.type="application/ld+json";n.id=r;var a={"@context":"https://schema.org","@type":"ItemList",name:salla.config.get("page.title"),itemListElement:e.map((function(e,r){return t.createProductSchema(e,r+1)}))};n.textContent=JSON.stringify(a);document.head.appendChild(n)};e.prototype.formatDateFromString=function(e,t,r){if(r===void 0){r="en"}var n=new Date(e);var a={en:"Invalid Date",ar:"تاريخ غير صالح"};if(isNaN(n.getTime())){return a[r]}var i={en:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],ar:["الأحد","الاثنين","الثلاثاء","الأربعاء","الخميس","الجمعة","السبت"]};var o={en:["January","February","March","April","May","June","July","August","September","October","November","December"],ar:["يناير","فبراير","مارس","أبريل","مايو","يونيو","يوليو","أغسطس","سبتمبر","أكتوبر","نوفمبر","ديسمبر"]};var u=i[r][n.getDay()];var c=t(n.getDate(),r==="en");var s=o[r][n.getMonth()];var d=t(n.getFullYear(),r==="en");return"".concat(u," ").concat(c," ").concat(s," ").concat(d)};e.prototype.copyToClipboard=function(e){var t=e.target.innerText;navigator.clipboard.writeText(t).then((function(){console.log("Text copied to clipboard: "+t)})).catch((function(e){console.error("Unable to copy text to clipboard",e)}))};e.prototype.animateItems=function(e){if(!e)return;anime({targets:e,opacity:[0,1],duration:1200,translateY:[20,0],delay:function(e,t){return t*100},easing:"easeOutExpo",complete:function(t){e.forEach((function(e){e.classList.add("animated")}))}})};e.prototype.createReviewObject=function(e){return{"@type":"Review",author:e.name,datePublished:e.date*1e3,description:e.content,reviewRating:{"@type":"Rating",bestRating:"5",ratingValue:"5",worstRating:"1"}}};e.prototype.generateReviewSchema=function(e){var t=this;var r=document.createElement("script");r.type="application/ld+json";var n={"@context":"http://schema.org/","@type":"CollectionPage",name:"Category Name",description:"Description of the category",review:e.map((function(e){return t.createReviewObject(e)}))};r.textContent=JSON.stringify(n);document.head.appendChild(r)};return e}();var Helper$1=new Helper;export{Helper$1 as H};
5
- //# sourceMappingURL=Helper-c5b72361.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["salla","event","setMaxListeners","Helper","prototype","setIncludes","includes","this","toggleElementClassIf","element","classes1","classes2","callback","Array","isArray","split","isClasses1","_c","classList","remove","apply","_d","add","toggleClassIf","selector","_this","document","querySelectorAll","forEach","isValidEmail","email","re","test","String","toLowerCase","filterEmojies","text","characterFilter","replace","debounce","fn","data","_i","arguments","length","debounce_","helpers","innerData","__spreadArray","getProductsSource","source","config","get","getPageTitleForSource","brands","latest","offers","sales","lang","getProductsSourceValue","sourceValue","parsedSource","parsedSourceValue","JSON","parse","error","console","URLSearchParams","window","location","search","extractFiltersFromUrl","searchParams","filters","value","key","matchesNested","match","filterName","nestedKey","matchesSimple","injectExtraFieldsToResponse","response","productIds","map","product","id","fetchImagesAndOptions","then","injectOptionsAndImages","api","metadata","fetchValues","Object","assign","find","meta","parseInt","entity_id","productsIncludes","fetchOptions","with","Promise","resolve","productList","newData","filter","field","foundProduct","prod","_a","parseJson","e","logger","getProductSchemaMarkupScript","scriptElement","createElement","type","jsonData","name","image","url","thumbnail","description","brand","logo","_b","price","stringify","createProductSchema","position","ProductSchema","productID","concat","subtitle","priceCurrency","currency","itemCondition","availability","is_available","priceValidUntil","discount_ends","Date","setDate","getDate","toISOString","priceSpecification","regular_price","valueAddedTaxIncluded","is_taxable","seller","rating","stars","aggregateRating","ratingValue","reviewCount","count","item","generateProductSchema","schemaId","getElementById","warn","script","schema","itemListElement","indxe","textContent","head","appendChild","formatDateFromString","dateString","numberCb","dateObject","errors","en","ar","isNaN","getTime","daysOfWeek","months","dayOfWeek","getDay","dayOfMonth","month","getMonth","year","getFullYear","copyToClipboard","textToCopy","target","innerText","navigator","clipboard","writeText","log","catch","err","animateItems","items","anime","targets","opacity","duration","translateY","delay","_el","i","easing","complete","_anim","createReviewObject","reviewData","author","datePublished","date","content","reviewRating","bestRating","worstRating","generateReviewSchema","reviews","review","Helper$1"],"sources":["src/Helpers/Helper.ts"],"sourcesContent":["import { ProductDetail } from \"@salla.sa/twilight/types/api/product\";\nimport { Review } from \"../../src/components/salla-reviews/interfaces\";\nimport { Product as SallaProduct } from \"@salla.sa/twilight/types/common\";\nimport { ListItem, ItemList, Product as SchemaProduct, WithContext } from 'schema-dts';\nimport { Product } from '@salla.sa/twilight/types/common';\nimport anime from 'animejs';\n\n//TODO::reduce it to 10\nsalla.event.setMaxListeners(100);\n\nclass Helper {\n private debounce_: any;\n private includes;\n\n setIncludes(includes:string[]){\n this.includes = includes;\n return this;\n }\n\n toggleElementClassIf(element, classes1, classes2, callback) {\n classes1 = Array.isArray(classes1) ? classes1 : classes1.split(' ');\n classes2 = Array.isArray(classes2) ? classes2 : classes2.split(' ');\n let isClasses1 = callback(element);\n element?.classList.remove(...(isClasses1 ? classes2 : classes1));\n element?.classList.add(...(isClasses1 ? classes1 : classes2));\n return this;\n }\n\n toggleClassIf(selector, classes1, classes2, callback) {\n document.querySelectorAll(selector).forEach(element => this.toggleElementClassIf(element, classes1, classes2, callback));\n return this;\n }\n\n isValidEmail(email) {\n const re = /^(([^<>()[\\]\\\\.,;:\\s@\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/;\n return re.test(String(email).toLowerCase());\n }\n\n filterEmojies(text) {\n var characterFilter = /(?:[\\u2700-\\u27bf]|(?:\\ud83c[\\udde6-\\uddff]){2}|[\\ud800-\\udbff][\\udc00-\\udfff]|[\\u0023-\\u0039]\\ufe0f?\\u20e3|\\u3299|\\u3297|\\u303d|\\u3030|\\u24c2|\\ud83c[\\udd70-\\udd71]|\\ud83c[\\udd7e-\\udd7f]|\\ud83c\\udd8e|\\ud83c[\\udd91-\\udd9a]|\\ud83c[\\udde6-\\uddff]|\\ud83c[\\ude01-\\ude02]|\\ud83c\\ude1a|\\ud83c\\ude2f|\\ud83c[\\ude32-\\ude3a]|\\ud83c[\\ude50-\\ude51]|\\u203c|\\u2049|[\\u25aa-\\u25ab]|\\u25b6|\\u25c0|[\\u25fb-\\u25fe]|\\u00a9|\\u00ae|\\u2122|\\u2139|\\ud83c\\udc04|[\\u2600-\\u26FF]|\\u2b05|\\u2b06|\\u2b07|\\u2b1b|\\u2b1c|\\u2b50|\\u2b55|\\u231a|\\u231b|\\u2328|\\u23cf|[\\u23e9-\\u23f3]|[\\u23f8-\\u23fa]|\\ud83c\\udccf|\\u2934|\\u2935|[\\u2190-\\u21ff])/g;\n return text.replace(characterFilter, \"\");\n }\n\n debounce(fn, ...data) {\n if (!this.debounce_) {\n this.debounce_ = salla.helpers.debounce((callback, ...innerData) => callback(...innerData), 500);\n }\n //@ts-ignore\n return this.debounce_(fn, ...data);\n }\n\n getProductsSource(source) {\n return {\n 'brands.single': 'brands',\n 'product.index': 'categories',\n 'product.index.latest': 'latest',\n 'product.index.offers': 'offers',\n 'product.index.search': 'search',\n 'customer.wishlist': 'wishlist',\n 'landing-page': 'landing-page',\n 'product.index.tag': 'tags',\n 'product.index.sales': 'sales',\n 'components.most_sales_products': 'sales',//temporary, delete it after two days from now\n }[source || salla.config.get('page.slug')] || source || 'latest';\n }\n\n getPageTitleForSource(source) {\n\n source = {\n 'brands': 'common.titles.brands',\n // 'categories':'',\n 'latest': 'blocks.home.latest_products',\n 'offers': 'common.titles.discounts',\n // 'search':'',\n // 'landing-page':'',\n // 'tags':'',\n 'sales': 'common.titles.most_sales',\n }[source];\n\n return source ? salla.lang.get(source) : '';\n }\n\n getProductsSourceValue(source, sourceValue) {\n const parsedSource = this.getProductsSource(source);\n\n // Validate if the source value is a valid JSON string\n let parsedSourceValue: any = null;\n if (sourceValue) {\n try {\n parsedSourceValue = JSON.parse(sourceValue);\n } catch (error) {\n console.error('Invalid JSON string in sourceValue:', error);\n }\n }\n\n // Handle different source types\n if (!['search', 'json', 'offers', 'latest', 'sales', 'related'].includes(parsedSource)) {\n\n if (Array.isArray(parsedSourceValue) && parsedSourceValue.length) {\n return parsedSourceValue;\n }\n\n\n if (Array.isArray(parsedSourceValue) && !parsedSourceValue.length) {\n return '';\n }\n\n if (typeof parsedSourceValue === 'number') {\n return [parsedSourceValue];\n }\n\n if (!sourceValue && ['categories', 'tags', 'brands'].includes(source)) {\n return [salla.config.get('page.id')];\n }\n }\n\n // Return sourceValue if it exists and is a valid JSON object/array\n if (parsedSourceValue || sourceValue) {\n return parsedSourceValue || sourceValue;\n }\n\n if (parsedSource === 'search') {\n return new URLSearchParams(window.location.search).get('q') || '';\n }\n\n // Return page id as default value\n return salla.config.get('page.id');\n }\n\n extractFiltersFromUrl(searchParams) {\n let filters = {};\n searchParams.forEach((value, key) => {\n // Handle filters[xxx] format\n const matchesNested = key.match(/^filters\\[(.*?)\\](\\[(.*?)\\])?$/u);\n\n if (matchesNested) {\n const filterName = matchesNested[1];\n const nestedKey = matchesNested[3];\n\n if (nestedKey) {\n // Handle nested object\n filters[filterName] = filters[filterName] || {};\n filters[filterName][nestedKey] = value;\n } else {\n // Handle regular key\n filters[filterName] = value;\n }\n } else {\n // Handle simple key-value pairs\n const matchesSimple = key.match(/^(.*?)$/u);\n\n if (matchesSimple) {\n filters[matchesSimple[1]] = value;\n }\n }\n });\n return filters;\n }\n\n injectExtraFieldsToResponse( response: {data:Product[]}) {\n if (!response || !this.includes) return response;\n\n const productIds = response.data.map(product => product.id);\n\n return this.fetchImagesAndOptions(productIds)\n .then(({ data: product }) => this.injectOptionsAndImages(response.data, product))\n .then(() => {\n if(!this.includes.includes('metadata')){\n return response;\n }\n\n return salla.api.metadata.fetchValues('product', productIds)\n //@ts-ignore\n .then(({data}) => response.data.map(product => ({...product, metadata: data.find(meta => parseInt(meta.entity_id) === parseInt(product.id))})))\n .then(() => response);\n });\n }\n\n /**\n * This to make sure we will not request the options endpoint unless we have to.\n */\n fetchImagesAndOptions(productIds){\n return this.productsIncludes().length\n ? salla.api.product.fetchOptions(productIds, { with: this.productsIncludes() })\n : Promise.resolve({data:[]}); //fake the endpoint, to reduce unwanted query if developer wants metadata only\n }\n\n\n injectOptionsAndImages( productList: Product[], newData: Product[] ): Product[] {\n return newData.length\n ? productList.map(product => {\n this.includes\n .filter(field => field !== 'metadata')\n .forEach(field => {\n //@ts-ignore\n const foundProduct = newData.find((prod: Product) => parseInt(prod.id) === parseInt(product.id));\n product[field] = foundProduct ? foundProduct[field] : null; // Assign null or a default value if not found\n });\n return product;\n })\n :null;\n }\n\n productsIncludes(){\n return this.includes?.filter(field => field != 'metadata');\n }\n\n parseJson(includes: string | string[]): null | string[] {\n if (typeof includes !== 'string') {\n return includes;\n }\n try {\n return JSON.parse(includes);\n } catch (e) {\n salla.logger.error('Failed to parse includes as JSON:', e);\n }\n\n return null;\n }\n\n getProductSchemaMarkupScript(product: any): HTMLScriptElement {\n const scriptElement = document.createElement('script');\n scriptElement.type = 'application/ld+json';\n // TODO: This json object MIGHT need mode data or properties.\n const jsonData = {\n \"@context\": \"http://schema.org\",\n \"@type\": \"Product\",\n \"name\": product?.name,\n \"image\": product?.image?.url || product?.thumbnail,\n \"description\": product?.description,\n \"brand\": {\n \"@type\": \"Brand\",\n \"logo\": product?.brand?.logo\n },\n \"offers\": {\n \"@type\": \"Offer\",\n \"price\": product?.price\n }\n };\n scriptElement.text = JSON.stringify(jsonData);\n return scriptElement\n }\n\n createProductSchema(product: SallaProduct | ProductDetail, position: number): ListItem {\n let ProductSchema: SchemaProduct = {\n \"productID\": `${product.id}`,\n \"@type\": 'Product',\n \"name\": product.name,\n \"url\": product.url,\n \"image\": product.image.url || (product.image as string),\n \"description\": product.description || product.subtitle || product.name,\n \"offers\": {\n \"@type\": \"Offer\",\n \"url\": product.url,\n \"priceCurrency\": product.currency,\n \"price\": product.price,\n \"itemCondition\": \"NewCondition\",\n \"availability\": product.is_available ? \"InStock\" : \"OutOfStock\",\n //if there is no product.discount_ends, will set it to be valid until the end of this week\n \"priceValidUntil\": product.discount_ends || (new Date(new Date().setDate(new Date().getDate() + 7)).toISOString().split('T')[0]),\n \"priceSpecification\": {\n \"@type\": \"PriceSpecification\",\n \"price\": product.regular_price,\n \"priceCurrency\": product.currency,\n \"valueAddedTaxIncluded\": product.is_taxable,\n },\n \"seller\": {\n \"@type\": \"Organization\",\n \"name\": salla.config.get('store.name'),\n },\n }\n };\n //@ts-ignore\n if (product.rating?.stars) {\n ProductSchema.aggregateRating = {\n \"@type\": \"AggregateRating\",\n //@ts-ignore\n \"ratingValue\": product.rating.stars,\n \"reviewCount\": product.rating.count,\n };\n }\n\n\n return {\n \"@type\": \"ListItem\",\n \"position\": position,\n \"item\": ProductSchema,\n\n };\n }\n \n generateProductSchema(productList: Array<SallaProduct | ProductDetail>) {\n const schemaId = 'salla-product-schema-script';\n if (document.getElementById(schemaId)) {\n salla.logger.warn(`already added schema-script with id (${schemaId})!`)\n return;\n }\n\n const script = document.createElement('script');\n script.type = 'application/ld+json';\n script.id = schemaId;\n\n\n const schema: WithContext<ItemList> = {\n \"@context\": \"https://schema.org\",\n \"@type\": \"ItemList\",\n \"name\": salla.config.get('page.title'),\n \"itemListElement\": productList.map((product, indxe) => this.createProductSchema(product, indxe + 1)),\n };\n\n script.textContent = JSON.stringify(schema);\n document.head.appendChild(script);\n }\n\n /**\n * Format date in the form of `Monday 13 November 2023`\n */\n formatDateFromString(dateString: string, numberCb: Function, lang: string = 'en'): string {\n const dateObject = new Date(dateString);\n\n const errors = {\n en: \"Invalid Date\",\n ar: \"تاريخ غير صالح\"\n }\n\n if (isNaN(dateObject.getTime())) {\n return errors[lang];\n }\n\n const daysOfWeek = {\n en: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],\n ar: ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت']\n };\n const months = {\n en: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],\n ar: ['يناير', 'فبراير', 'مارس', 'أبريل', 'مايو', 'يونيو', 'يوليو', 'أغسطس', 'سبتمبر', 'أكتوبر', 'نوفمبر', 'ديسمبر']\n };\n\n const dayOfWeek = daysOfWeek[lang][dateObject.getDay()];\n const dayOfMonth = numberCb(dateObject.getDate(), lang === 'en');\n const month = months[lang][dateObject.getMonth()];\n const year = numberCb(dateObject.getFullYear(), lang === 'en');\n\n return `${dayOfWeek} ${dayOfMonth} ${month} ${year}`;\n }\n\n /**\n * Copy text into clipboard.\n * @param event \n */\n copyToClipboard(event) {\n // Get the text content from the clicked div\n var textToCopy = event.target.innerText;\n\n // Use the Clipboard API to copy text to the clipboard\n navigator.clipboard.writeText(textToCopy)\n .then(() => {\n console.log('Text copied to clipboard: ' + textToCopy);\n })\n .catch(err => {\n console.error('Unable to copy text to clipboard', err);\n });\n\n }\n\n animateItems(items: NodeListOf<Element>) {\n if (!items) return;\n anime({\n targets: items,\n opacity: [0, 1],\n duration: 1200,\n translateY: [20, 0],\n delay: function (_el, i) {\n return i * 100;\n },\n easing: 'easeOutExpo',\n complete: function (_anim) {\n items.forEach((item: Element) => {\n item.classList.add('animated');\n })\n }\n\n })\n }\n\n createReviewObject(reviewData: Review) {\n return {\n \"@type\": \"Review\",\n \"author\": reviewData.name,\n \"datePublished\": reviewData.date * 1000,\n \"description\": reviewData.content,\n \"reviewRating\": {\n \"@type\": \"Rating\",\n \"bestRating\": \"5\",\n \"ratingValue\": \"5\",\n \"worstRating\": \"1\"\n }\n };\n }\n\n generateReviewSchema(reviews: Array<Review>){\n const script = document.createElement('script');\n script.type = 'application/ld+json';\n\n\n const schema = {\n \"@context\": \"http://schema.org/\",\n \"@type\": \"CollectionPage\",\n \"name\": \"Category Name\", // TODO: check for the correct value here\n \"description\": \"Description of the category\", // TODO: here too\n \"review\": reviews.map((review) => this.createReviewObject(review))\n }\n\n script.textContent = JSON.stringify(schema);\n document.head.appendChild(script);\n }\n}\n\nexport default new Helper;\n"],"mappings":";;;kDAQAA,MAAMC,MAAMC,gBAAgB,KAE5B,IAAAC,OAAA,oBAAAA,I,CAIEA,EAAAC,UAAAC,YAAA,SAAYC,GACVC,KAAKD,SAAWA,EAChB,OAAOC,I,EAGTJ,EAAAC,UAAAI,qBAAA,SAAqBC,EAASC,EAAUC,EAAUC,G,QAChDF,EAAWG,MAAMC,QAAQJ,GAAYA,EAAWA,EAASK,MAAM,KAC/DJ,EAAWE,MAAMC,QAAQH,GAAYA,EAAWA,EAASI,MAAM,KAC/D,IAAIC,EAAaJ,EAASH,GAC1BA,IAAO,MAAPA,SAAO,UAAPQ,EAAAR,EAASS,WAAUC,OAAMC,MAAAH,EAAKD,EAAaL,EAAWD,GACtDD,IAAO,MAAPA,SAAO,UAAPY,EAAAZ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,UAAAiM,aAAA,SAAaC,GACX,IAAKA,EAAO,OACZC,MAAM,CACJC,QAASF,EACTG,QAAS,CAAC,EAAG,GACbC,SAAU,KACVC,WAAY,CAAC,GAAI,GACjBC,MAAO,SAAUC,EAAKC,GACpB,OAAOA,EAAI,G,EAEbC,OAAQ,cACRC,SAAU,SAAUC,GAClBX,EAAM1K,SAAQ,SAACiI,GACbA,EAAK3I,UAAUI,IAAI,W,QAO3BnB,EAAAC,UAAA8M,mBAAA,SAAmBC,GACjB,MAAO,CACL,QAAS,SACTC,OAAUD,EAAW5F,KACrB8F,cAAiBF,EAAWG,KAAO,IACnC3F,YAAewF,EAAWI,QAC1BC,aAAgB,CACd,QAAS,SACTC,WAAc,IACd/D,YAAe,IACfgE,YAAe,K,EAKrBvN,EAAAC,UAAAuN,qBAAA,SAAqBC,GAArB,IAAAnM,EAAAlB,KACE,IAAM2J,EAASxI,SAAS0F,cAAc,UACtC8C,EAAO7C,KAAO,sBAGd,IAAM8C,EAAS,CACb,WAAY,qBACZ,QAAS,iBACT5C,KAAQ,gBACRI,YAAe,8BACfkG,OAAUD,EAAQxI,KAAI,SAACyI,GAAW,OAAApM,EAAKyL,mBAAmBW,EAAxB,KAGpC3D,EAAOI,YAAcvG,KAAKiE,UAAUmC,GACpCzI,SAAS6I,KAAKC,YAAYN,E,WApZ9B,GAwZA,IAAA4D,SAAe,IAAI3N,c"}
@@ -1,5 +0,0 @@
1
- var __spreadArray=this&&this.__spreadArray||function(e,t,r){if(r||arguments.length===2)for(var n=0,a=t.length,i;n<a;n++){if(i||!(n in t)){if(!i)i=Array.prototype.slice.call(t,0,n);i[n]=t[n]}}return e.concat(i||Array.prototype.slice.call(t))};
2
- /*!
3
- * Crafted with ❤ by Salla
4
- */System.register(["./p-8f7b9e36.system.js"],(function(e){"use strict";var t;return{setters:[function(e){t=e.a}],execute:function(){salla.event.setMaxListeners(100);var r=function(){function e(){}e.prototype.setIncludes=function(e){this.includes=e;return this};e.prototype.toggleElementClassIf=function(e,t,r,n){var a,i;t=Array.isArray(t)?t:t.split(" ");r=Array.isArray(r)?r:r.split(" ");var o=n(e);e===null||e===void 0?void 0:(a=e.classList).remove.apply(a,o?r:t);e===null||e===void 0?void 0:(i=e.classList).add.apply(i,o?t:r);return this};e.prototype.toggleClassIf=function(e,t,r,n){var a=this;document.querySelectorAll(e).forEach((function(e){return a.toggleElementClassIf(e,t,r,n)}));return this};e.prototype.isValidEmail=function(e){var t=/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;return t.test(String(e).toLowerCase())};e.prototype.filterEmojies=function(e){var t=/(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff]|[\u0023-\u0039]\ufe0f?\u20e3|\u3299|\u3297|\u303d|\u3030|\u24c2|\ud83c[\udd70-\udd71]|\ud83c[\udd7e-\udd7f]|\ud83c\udd8e|\ud83c[\udd91-\udd9a]|\ud83c[\udde6-\uddff]|\ud83c[\ude01-\ude02]|\ud83c\ude1a|\ud83c\ude2f|\ud83c[\ude32-\ude3a]|\ud83c[\ude50-\ude51]|\u203c|\u2049|[\u25aa-\u25ab]|\u25b6|\u25c0|[\u25fb-\u25fe]|\u00a9|\u00ae|\u2122|\u2139|\ud83c\udc04|[\u2600-\u26FF]|\u2b05|\u2b06|\u2b07|\u2b1b|\u2b1c|\u2b50|\u2b55|\u231a|\u231b|\u2328|\u23cf|[\u23e9-\u23f3]|[\u23f8-\u23fa]|\ud83c\udccf|\u2934|\u2935|[\u2190-\u21ff])/g;return e.replace(t,"")};e.prototype.debounce=function(e){var t=[];for(var r=1;r<arguments.length;r++){t[r-1]=arguments[r]}if(!this.debounce_){this.debounce_=salla.helpers.debounce((function(e){var t=[];for(var r=1;r<arguments.length;r++){t[r-1]=arguments[r]}return e.apply(void 0,t)}),500)}return this.debounce_.apply(this,__spreadArray([e],t,false))};e.prototype.getProductsSource=function(e){return{"brands.single":"brands","product.index":"categories","product.index.latest":"latest","product.index.offers":"offers","product.index.search":"search","customer.wishlist":"wishlist","landing-page":"landing-page","product.index.tag":"tags","product.index.sales":"sales","components.most_sales_products":"sales"}[e||salla.config.get("page.slug")]||e||"latest"};e.prototype.getPageTitleForSource=function(e){e={brands:"common.titles.brands",latest:"blocks.home.latest_products",offers:"common.titles.discounts",sales:"common.titles.most_sales"}[e];return e?salla.lang.get(e):""};e.prototype.getProductsSourceValue=function(e,t){var r=this.getProductsSource(e);var n=null;if(t){try{n=JSON.parse(t)}catch(e){console.error("Invalid JSON string in sourceValue:",e)}}if(!["search","json","offers","latest","sales","related"].includes(r)){if(Array.isArray(n)&&n.length){return n}if(Array.isArray(n)&&!n.length){return""}if(typeof n==="number"){return[n]}if(!t&&["categories","tags","brands"].includes(e)){return[salla.config.get("page.id")]}}if(n||t){return n||t}if(r==="search"){return new URLSearchParams(window.location.search).get("q")||""}return salla.config.get("page.id")};e.prototype.extractFiltersFromUrl=function(e){var t={};e.forEach((function(e,r){var n=r.match(/^filters\[(.*?)\](\[(.*?)\])?$/u);if(n){var a=n[1];var i=n[3];if(i){t[a]=t[a]||{};t[a][i]=e}else{t[a]=e}}else{var o=r.match(/^(.*?)$/u);if(o){t[o[1]]=e}}}));return t};e.prototype.injectExtraFieldsToResponse=function(e){var t=this;if(!e||!this.includes)return e;var r=e.data.map((function(e){return e.id}));return this.fetchImagesAndOptions(r).then((function(r){var n=r.data;return t.injectOptionsAndImages(e.data,n)})).then((function(){if(!t.includes.includes("metadata")){return e}return salla.api.metadata.fetchValues("product",r).then((function(t){var r=t.data;return e.data.map((function(e){return Object.assign(Object.assign({},e),{metadata:r.find((function(t){return parseInt(t.entity_id)===parseInt(e.id)}))})}))})).then((function(){return e}))}))};e.prototype.fetchImagesAndOptions=function(e){return this.productsIncludes().length?salla.api.product.fetchOptions(e,{with:this.productsIncludes()}):Promise.resolve({data:[]})};e.prototype.injectOptionsAndImages=function(e,t){var r=this;return t.length?e.map((function(e){r.includes.filter((function(e){return e!=="metadata"})).forEach((function(r){var n=t.find((function(t){return parseInt(t.id)===parseInt(e.id)}));e[r]=n?n[r]:null}));return e})):null};e.prototype.productsIncludes=function(){var e;return(e=this.includes)===null||e===void 0?void 0:e.filter((function(e){return e!="metadata"}))};e.prototype.parseJson=function(e){if(typeof e!=="string"){return e}try{return JSON.parse(e)}catch(e){salla.logger.error("Failed to parse includes as JSON:",e)}return null};e.prototype.getProductSchemaMarkupScript=function(e){var t,r;var n=document.createElement("script");n.type="application/ld+json";var a={"@context":"http://schema.org","@type":"Product",name:e===null||e===void 0?void 0:e.name,image:((t=e===null||e===void 0?void 0:e.image)===null||t===void 0?void 0:t.url)||(e===null||e===void 0?void 0:e.thumbnail),description:e===null||e===void 0?void 0:e.description,brand:{"@type":"Brand",logo:(r=e===null||e===void 0?void 0:e.brand)===null||r===void 0?void 0:r.logo},offers:{"@type":"Offer",price:e===null||e===void 0?void 0:e.price}};n.text=JSON.stringify(a);return n};e.prototype.createProductSchema=function(e,t){var r;var n={productID:"".concat(e.id),"@type":"Product",name:e.name,url:e.url,image:e.image.url||e.image,description:e.description||e.subtitle||e.name,offers:{"@type":"Offer",url:e.url,priceCurrency:e.currency,price:e.price,itemCondition:"NewCondition",availability:e.is_available?"InStock":"OutOfStock",priceValidUntil:e.discount_ends||new Date((new Date).setDate((new Date).getDate()+7)).toISOString().split("T")[0],priceSpecification:{"@type":"PriceSpecification",price:e.regular_price,priceCurrency:e.currency,valueAddedTaxIncluded:e.is_taxable},seller:{"@type":"Organization",name:salla.config.get("store.name")}}};if((r=e.rating)===null||r===void 0?void 0:r.stars){n.aggregateRating={"@type":"AggregateRating",ratingValue:e.rating.stars,reviewCount:e.rating.count}}return{"@type":"ListItem",position:t,item:n}};e.prototype.generateProductSchema=function(e){var t=this;var r="salla-product-schema-script";if(document.getElementById(r)){salla.logger.warn("already added schema-script with id (".concat(r,")!"));return}var n=document.createElement("script");n.type="application/ld+json";n.id=r;var a={"@context":"https://schema.org","@type":"ItemList",name:salla.config.get("page.title"),itemListElement:e.map((function(e,r){return t.createProductSchema(e,r+1)}))};n.textContent=JSON.stringify(a);document.head.appendChild(n)};e.prototype.formatDateFromString=function(e,t,r){if(r===void 0){r="en"}var n=new Date(e);var a={en:"Invalid Date",ar:"تاريخ غير صالح"};if(isNaN(n.getTime())){return a[r]}var i={en:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],ar:["الأحد","الاثنين","الثلاثاء","الأربعاء","الخميس","الجمعة","السبت"]};var o={en:["January","February","March","April","May","June","July","August","September","October","November","December"],ar:["يناير","فبراير","مارس","أبريل","مايو","يونيو","يوليو","أغسطس","سبتمبر","أكتوبر","نوفمبر","ديسمبر"]};var u=i[r][n.getDay()];var c=t(n.getDate(),r==="en");var s=o[r][n.getMonth()];var d=t(n.getFullYear(),r==="en");return"".concat(u," ").concat(c," ").concat(s," ").concat(d)};e.prototype.copyToClipboard=function(e){var t=e.target.innerText;navigator.clipboard.writeText(t).then((function(){console.log("Text copied to clipboard: "+t)})).catch((function(e){console.error("Unable to copy text to clipboard",e)}))};e.prototype.animateItems=function(e){if(!e)return;t({targets:e,opacity:[0,1],duration:1200,translateY:[20,0],delay:function(e,t){return t*100},easing:"easeOutExpo",complete:function(t){e.forEach((function(e){e.classList.add("animated")}))}})};e.prototype.createReviewObject=function(e){return{"@type":"Review",author:e.name,datePublished:e.date*1e3,description:e.content,reviewRating:{"@type":"Rating",bestRating:"5",ratingValue:"5",worstRating:"1"}}};e.prototype.generateReviewSchema=function(e){var t=this;var r=document.createElement("script");r.type="application/ld+json";var n={"@context":"http://schema.org/","@type":"CollectionPage",name:"Category Name",description:"Description of the category",review:e.map((function(e){return t.createReviewObject(e)}))};r.textContent=JSON.stringify(n);document.head.appendChild(r)};return e}();var n=e("H",new r)}}}));
5
- //# sourceMappingURL=p-9776f50d.system.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["salla","event","setMaxListeners","Helper","prototype","setIncludes","includes","this","toggleElementClassIf","element","classes1","classes2","callback","Array","isArray","split","isClasses1","_c","classList","remove","apply","_d","add","toggleClassIf","selector","_this","document","querySelectorAll","forEach","isValidEmail","email","re","test","String","toLowerCase","filterEmojies","text","characterFilter","replace","debounce","fn","data","_i","arguments","length","debounce_","helpers","innerData","__spreadArray","getProductsSource","source","config","get","getPageTitleForSource","brands","latest","offers","sales","lang","getProductsSourceValue","sourceValue","parsedSource","parsedSourceValue","JSON","parse","error","console","URLSearchParams","window","location","search","extractFiltersFromUrl","searchParams","filters","value","key","matchesNested","match","filterName","nestedKey","matchesSimple","injectExtraFieldsToResponse","response","productIds","map","product","id","fetchImagesAndOptions","then","injectOptionsAndImages","api","metadata","fetchValues","Object","assign","find","meta","parseInt","entity_id","productsIncludes","fetchOptions","with","Promise","resolve","productList","newData","filter","field","foundProduct","prod","_a","parseJson","e","logger","getProductSchemaMarkupScript","scriptElement","createElement","type","jsonData","name","image","url","thumbnail","description","brand","logo","_b","price","stringify","createProductSchema","position","ProductSchema","productID","concat","subtitle","priceCurrency","currency","itemCondition","availability","is_available","priceValidUntil","discount_ends","Date","setDate","getDate","toISOString","priceSpecification","regular_price","valueAddedTaxIncluded","is_taxable","seller","rating","stars","aggregateRating","ratingValue","reviewCount","count","item","generateProductSchema","schemaId","getElementById","warn","script","schema","itemListElement","indxe","textContent","head","appendChild","formatDateFromString","dateString","numberCb","dateObject","errors","en","ar","isNaN","getTime","daysOfWeek","months","dayOfWeek","getDay","dayOfMonth","month","getMonth","year","getFullYear","copyToClipboard","textToCopy","target","innerText","navigator","clipboard","writeText","log","catch","err","animateItems","items","anime","targets","opacity","duration","translateY","delay","_el","i","easing","complete","_anim","createReviewObject","reviewData","author","datePublished","date","content","reviewRating","bestRating","worstRating","generateReviewSchema","reviews","review","Helper$1","exports"],"sources":["src/Helpers/Helper.ts"],"sourcesContent":["import { ProductDetail } from \"@salla.sa/twilight/types/api/product\";\nimport { Review } from \"../../src/components/salla-reviews/interfaces\";\nimport { Product as SallaProduct } from \"@salla.sa/twilight/types/common\";\nimport { ListItem, ItemList, Product as SchemaProduct, WithContext } from 'schema-dts';\nimport { Product } from '@salla.sa/twilight/types/common';\nimport anime from 'animejs';\n\n//TODO::reduce it to 10\nsalla.event.setMaxListeners(100);\n\nclass Helper {\n private debounce_: any;\n private includes;\n\n setIncludes(includes:string[]){\n this.includes = includes;\n return this;\n }\n\n toggleElementClassIf(element, classes1, classes2, callback) {\n classes1 = Array.isArray(classes1) ? classes1 : classes1.split(' ');\n classes2 = Array.isArray(classes2) ? classes2 : classes2.split(' ');\n let isClasses1 = callback(element);\n element?.classList.remove(...(isClasses1 ? classes2 : classes1));\n element?.classList.add(...(isClasses1 ? classes1 : classes2));\n return this;\n }\n\n toggleClassIf(selector, classes1, classes2, callback) {\n document.querySelectorAll(selector).forEach(element => this.toggleElementClassIf(element, classes1, classes2, callback));\n return this;\n }\n\n isValidEmail(email) {\n const re = /^(([^<>()[\\]\\\\.,;:\\s@\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/;\n return re.test(String(email).toLowerCase());\n }\n\n filterEmojies(text) {\n var characterFilter = /(?:[\\u2700-\\u27bf]|(?:\\ud83c[\\udde6-\\uddff]){2}|[\\ud800-\\udbff][\\udc00-\\udfff]|[\\u0023-\\u0039]\\ufe0f?\\u20e3|\\u3299|\\u3297|\\u303d|\\u3030|\\u24c2|\\ud83c[\\udd70-\\udd71]|\\ud83c[\\udd7e-\\udd7f]|\\ud83c\\udd8e|\\ud83c[\\udd91-\\udd9a]|\\ud83c[\\udde6-\\uddff]|\\ud83c[\\ude01-\\ude02]|\\ud83c\\ude1a|\\ud83c\\ude2f|\\ud83c[\\ude32-\\ude3a]|\\ud83c[\\ude50-\\ude51]|\\u203c|\\u2049|[\\u25aa-\\u25ab]|\\u25b6|\\u25c0|[\\u25fb-\\u25fe]|\\u00a9|\\u00ae|\\u2122|\\u2139|\\ud83c\\udc04|[\\u2600-\\u26FF]|\\u2b05|\\u2b06|\\u2b07|\\u2b1b|\\u2b1c|\\u2b50|\\u2b55|\\u231a|\\u231b|\\u2328|\\u23cf|[\\u23e9-\\u23f3]|[\\u23f8-\\u23fa]|\\ud83c\\udccf|\\u2934|\\u2935|[\\u2190-\\u21ff])/g;\n return text.replace(characterFilter, \"\");\n }\n\n debounce(fn, ...data) {\n if (!this.debounce_) {\n this.debounce_ = salla.helpers.debounce((callback, ...innerData) => callback(...innerData), 500);\n }\n //@ts-ignore\n return this.debounce_(fn, ...data);\n }\n\n getProductsSource(source) {\n return {\n 'brands.single': 'brands',\n 'product.index': 'categories',\n 'product.index.latest': 'latest',\n 'product.index.offers': 'offers',\n 'product.index.search': 'search',\n 'customer.wishlist': 'wishlist',\n 'landing-page': 'landing-page',\n 'product.index.tag': 'tags',\n 'product.index.sales': 'sales',\n 'components.most_sales_products': 'sales',//temporary, delete it after two days from now\n }[source || salla.config.get('page.slug')] || source || 'latest';\n }\n\n getPageTitleForSource(source) {\n\n source = {\n 'brands': 'common.titles.brands',\n // 'categories':'',\n 'latest': 'blocks.home.latest_products',\n 'offers': 'common.titles.discounts',\n // 'search':'',\n // 'landing-page':'',\n // 'tags':'',\n 'sales': 'common.titles.most_sales',\n }[source];\n\n return source ? salla.lang.get(source) : '';\n }\n\n getProductsSourceValue(source, sourceValue) {\n const parsedSource = this.getProductsSource(source);\n\n // Validate if the source value is a valid JSON string\n let parsedSourceValue: any = null;\n if (sourceValue) {\n try {\n parsedSourceValue = JSON.parse(sourceValue);\n } catch (error) {\n console.error('Invalid JSON string in sourceValue:', error);\n }\n }\n\n // Handle different source types\n if (!['search', 'json', 'offers', 'latest', 'sales', 'related'].includes(parsedSource)) {\n\n if (Array.isArray(parsedSourceValue) && parsedSourceValue.length) {\n return parsedSourceValue;\n }\n\n\n if (Array.isArray(parsedSourceValue) && !parsedSourceValue.length) {\n return '';\n }\n\n if (typeof parsedSourceValue === 'number') {\n return [parsedSourceValue];\n }\n\n if (!sourceValue && ['categories', 'tags', 'brands'].includes(source)) {\n return [salla.config.get('page.id')];\n }\n }\n\n // Return sourceValue if it exists and is a valid JSON object/array\n if (parsedSourceValue || sourceValue) {\n return parsedSourceValue || sourceValue;\n }\n\n if (parsedSource === 'search') {\n return new URLSearchParams(window.location.search).get('q') || '';\n }\n\n // Return page id as default value\n return salla.config.get('page.id');\n }\n\n extractFiltersFromUrl(searchParams) {\n let filters = {};\n searchParams.forEach((value, key) => {\n // Handle filters[xxx] format\n const matchesNested = key.match(/^filters\\[(.*?)\\](\\[(.*?)\\])?$/u);\n\n if (matchesNested) {\n const filterName = matchesNested[1];\n const nestedKey = matchesNested[3];\n\n if (nestedKey) {\n // Handle nested object\n filters[filterName] = filters[filterName] || {};\n filters[filterName][nestedKey] = value;\n } else {\n // Handle regular key\n filters[filterName] = value;\n }\n } else {\n // Handle simple key-value pairs\n const matchesSimple = key.match(/^(.*?)$/u);\n\n if (matchesSimple) {\n filters[matchesSimple[1]] = value;\n }\n }\n });\n return filters;\n }\n\n injectExtraFieldsToResponse( response: {data:Product[]}) {\n if (!response || !this.includes) return response;\n\n const productIds = response.data.map(product => product.id);\n\n return this.fetchImagesAndOptions(productIds)\n .then(({ data: product }) => this.injectOptionsAndImages(response.data, product))\n .then(() => {\n if(!this.includes.includes('metadata')){\n return response;\n }\n\n return salla.api.metadata.fetchValues('product', productIds)\n //@ts-ignore\n .then(({data}) => response.data.map(product => ({...product, metadata: data.find(meta => parseInt(meta.entity_id) === parseInt(product.id))})))\n .then(() => response);\n });\n }\n\n /**\n * This to make sure we will not request the options endpoint unless we have to.\n */\n fetchImagesAndOptions(productIds){\n return this.productsIncludes().length\n ? salla.api.product.fetchOptions(productIds, { with: this.productsIncludes() })\n : Promise.resolve({data:[]}); //fake the endpoint, to reduce unwanted query if developer wants metadata only\n }\n\n\n injectOptionsAndImages( productList: Product[], newData: Product[] ): Product[] {\n return newData.length\n ? productList.map(product => {\n this.includes\n .filter(field => field !== 'metadata')\n .forEach(field => {\n //@ts-ignore\n const foundProduct = newData.find((prod: Product) => parseInt(prod.id) === parseInt(product.id));\n product[field] = foundProduct ? foundProduct[field] : null; // Assign null or a default value if not found\n });\n return product;\n })\n :null;\n }\n\n productsIncludes(){\n return this.includes?.filter(field => field != 'metadata');\n }\n\n parseJson(includes: string | string[]): null | string[] {\n if (typeof includes !== 'string') {\n return includes;\n }\n try {\n return JSON.parse(includes);\n } catch (e) {\n salla.logger.error('Failed to parse includes as JSON:', e);\n }\n\n return null;\n }\n\n getProductSchemaMarkupScript(product: any): HTMLScriptElement {\n const scriptElement = document.createElement('script');\n scriptElement.type = 'application/ld+json';\n // TODO: This json object MIGHT need mode data or properties.\n const jsonData = {\n \"@context\": \"http://schema.org\",\n \"@type\": \"Product\",\n \"name\": product?.name,\n \"image\": product?.image?.url || product?.thumbnail,\n \"description\": product?.description,\n \"brand\": {\n \"@type\": \"Brand\",\n \"logo\": product?.brand?.logo\n },\n \"offers\": {\n \"@type\": \"Offer\",\n \"price\": product?.price\n }\n };\n scriptElement.text = JSON.stringify(jsonData);\n return scriptElement\n }\n\n createProductSchema(product: SallaProduct | ProductDetail, position: number): ListItem {\n let ProductSchema: SchemaProduct = {\n \"productID\": `${product.id}`,\n \"@type\": 'Product',\n \"name\": product.name,\n \"url\": product.url,\n \"image\": product.image.url || (product.image as string),\n \"description\": product.description || product.subtitle || product.name,\n \"offers\": {\n \"@type\": \"Offer\",\n \"url\": product.url,\n \"priceCurrency\": product.currency,\n \"price\": product.price,\n \"itemCondition\": \"NewCondition\",\n \"availability\": product.is_available ? \"InStock\" : \"OutOfStock\",\n //if there is no product.discount_ends, will set it to be valid until the end of this week\n \"priceValidUntil\": product.discount_ends || (new Date(new Date().setDate(new Date().getDate() + 7)).toISOString().split('T')[0]),\n \"priceSpecification\": {\n \"@type\": \"PriceSpecification\",\n \"price\": product.regular_price,\n \"priceCurrency\": product.currency,\n \"valueAddedTaxIncluded\": product.is_taxable,\n },\n \"seller\": {\n \"@type\": \"Organization\",\n \"name\": salla.config.get('store.name'),\n },\n }\n };\n //@ts-ignore\n if (product.rating?.stars) {\n ProductSchema.aggregateRating = {\n \"@type\": \"AggregateRating\",\n //@ts-ignore\n \"ratingValue\": product.rating.stars,\n \"reviewCount\": product.rating.count,\n };\n }\n\n\n return {\n \"@type\": \"ListItem\",\n \"position\": position,\n \"item\": ProductSchema,\n\n };\n }\n \n generateProductSchema(productList: Array<SallaProduct | ProductDetail>) {\n const schemaId = 'salla-product-schema-script';\n if (document.getElementById(schemaId)) {\n salla.logger.warn(`already added schema-script with id (${schemaId})!`)\n return;\n }\n\n const script = document.createElement('script');\n script.type = 'application/ld+json';\n script.id = schemaId;\n\n\n const schema: WithContext<ItemList> = {\n \"@context\": \"https://schema.org\",\n \"@type\": \"ItemList\",\n \"name\": salla.config.get('page.title'),\n \"itemListElement\": productList.map((product, indxe) => this.createProductSchema(product, indxe + 1)),\n };\n\n script.textContent = JSON.stringify(schema);\n document.head.appendChild(script);\n }\n\n /**\n * Format date in the form of `Monday 13 November 2023`\n */\n formatDateFromString(dateString: string, numberCb: Function, lang: string = 'en'): string {\n const dateObject = new Date(dateString);\n\n const errors = {\n en: \"Invalid Date\",\n ar: \"تاريخ غير صالح\"\n }\n\n if (isNaN(dateObject.getTime())) {\n return errors[lang];\n }\n\n const daysOfWeek = {\n en: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],\n ar: ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت']\n };\n const months = {\n en: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],\n ar: ['يناير', 'فبراير', 'مارس', 'أبريل', 'مايو', 'يونيو', 'يوليو', 'أغسطس', 'سبتمبر', 'أكتوبر', 'نوفمبر', 'ديسمبر']\n };\n\n const dayOfWeek = daysOfWeek[lang][dateObject.getDay()];\n const dayOfMonth = numberCb(dateObject.getDate(), lang === 'en');\n const month = months[lang][dateObject.getMonth()];\n const year = numberCb(dateObject.getFullYear(), lang === 'en');\n\n return `${dayOfWeek} ${dayOfMonth} ${month} ${year}`;\n }\n\n /**\n * Copy text into clipboard.\n * @param event \n */\n copyToClipboard(event) {\n // Get the text content from the clicked div\n var textToCopy = event.target.innerText;\n\n // Use the Clipboard API to copy text to the clipboard\n navigator.clipboard.writeText(textToCopy)\n .then(() => {\n console.log('Text copied to clipboard: ' + textToCopy);\n })\n .catch(err => {\n console.error('Unable to copy text to clipboard', err);\n });\n\n }\n\n animateItems(items: NodeListOf<Element>) {\n if (!items) return;\n anime({\n targets: items,\n opacity: [0, 1],\n duration: 1200,\n translateY: [20, 0],\n delay: function (_el, i) {\n return i * 100;\n },\n easing: 'easeOutExpo',\n complete: function (_anim) {\n items.forEach((item: Element) => {\n item.classList.add('animated');\n })\n }\n\n })\n }\n\n createReviewObject(reviewData: Review) {\n return {\n \"@type\": \"Review\",\n \"author\": reviewData.name,\n \"datePublished\": reviewData.date * 1000,\n \"description\": reviewData.content,\n \"reviewRating\": {\n \"@type\": \"Rating\",\n \"bestRating\": \"5\",\n \"ratingValue\": \"5\",\n \"worstRating\": \"1\"\n }\n };\n }\n\n generateReviewSchema(reviews: Array<Review>){\n const script = document.createElement('script');\n script.type = 'application/ld+json';\n\n\n const schema = {\n \"@context\": \"http://schema.org/\",\n \"@type\": \"CollectionPage\",\n \"name\": \"Category Name\", // TODO: check for the correct value here\n \"description\": \"Description of the category\", // TODO: here too\n \"review\": reviews.map((review) => this.createReviewObject(review))\n }\n\n script.textContent = JSON.stringify(schema);\n document.head.appendChild(script);\n }\n}\n\nexport default new Helper;\n"],"mappings":";;;qIAQAA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vG,KAAKiE,UAAUmC,GACpCzI,SAAS6I,KAAKC,YAAYN,E,WApZ9B,GAwZA,IAAA4D,EAAAC,EAAA,IAAe,IAAI5N,E"}
@@ -1,5 +0,0 @@
1
- /*!
2
- * Crafted with ❤ by Salla
3
- */
4
- import{a as e}from"./p-5a803ecc.js";salla.event.setMaxListeners(100);class t{setIncludes(e){this.includes=e;return this}toggleElementClassIf(e,t,a,r){t=Array.isArray(t)?t:t.split(" ");a=Array.isArray(a)?a:a.split(" ");let n=r(e);e===null||e===void 0?void 0:e.classList.remove(...n?a:t);e===null||e===void 0?void 0:e.classList.add(...n?t:a);return this}toggleClassIf(e,t,a,r){document.querySelectorAll(e).forEach((e=>this.toggleElementClassIf(e,t,a,r)));return this}isValidEmail(e){const t=/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;return t.test(String(e).toLowerCase())}filterEmojies(e){var t=/(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff]|[\u0023-\u0039]\ufe0f?\u20e3|\u3299|\u3297|\u303d|\u3030|\u24c2|\ud83c[\udd70-\udd71]|\ud83c[\udd7e-\udd7f]|\ud83c\udd8e|\ud83c[\udd91-\udd9a]|\ud83c[\udde6-\uddff]|\ud83c[\ude01-\ude02]|\ud83c\ude1a|\ud83c\ude2f|\ud83c[\ude32-\ude3a]|\ud83c[\ude50-\ude51]|\u203c|\u2049|[\u25aa-\u25ab]|\u25b6|\u25c0|[\u25fb-\u25fe]|\u00a9|\u00ae|\u2122|\u2139|\ud83c\udc04|[\u2600-\u26FF]|\u2b05|\u2b06|\u2b07|\u2b1b|\u2b1c|\u2b50|\u2b55|\u231a|\u231b|\u2328|\u23cf|[\u23e9-\u23f3]|[\u23f8-\u23fa]|\ud83c\udccf|\u2934|\u2935|[\u2190-\u21ff])/g;return e.replace(t,"")}debounce(e,...t){if(!this.debounce_){this.debounce_=salla.helpers.debounce(((e,...t)=>e(...t)),500)}return this.debounce_(e,...t)}getProductsSource(e){return{"brands.single":"brands","product.index":"categories","product.index.latest":"latest","product.index.offers":"offers","product.index.search":"search","customer.wishlist":"wishlist","landing-page":"landing-page","product.index.tag":"tags","product.index.sales":"sales","components.most_sales_products":"sales"}[e||salla.config.get("page.slug")]||e||"latest"}getPageTitleForSource(e){e={brands:"common.titles.brands",latest:"blocks.home.latest_products",offers:"common.titles.discounts",sales:"common.titles.most_sales"}[e];return e?salla.lang.get(e):""}getProductsSourceValue(e,t){const a=this.getProductsSource(e);let r=null;if(t){try{r=JSON.parse(t)}catch(e){console.error("Invalid JSON string in sourceValue:",e)}}if(!["search","json","offers","latest","sales","related"].includes(a)){if(Array.isArray(r)&&r.length){return r}if(Array.isArray(r)&&!r.length){return""}if(typeof r==="number"){return[r]}if(!t&&["categories","tags","brands"].includes(e)){return[salla.config.get("page.id")]}}if(r||t){return r||t}if(a==="search"){return new URLSearchParams(window.location.search).get("q")||""}return salla.config.get("page.id")}extractFiltersFromUrl(e){let t={};e.forEach(((e,a)=>{const r=a.match(/^filters\[(.*?)\](\[(.*?)\])?$/u);if(r){const a=r[1];const n=r[3];if(n){t[a]=t[a]||{};t[a][n]=e}else{t[a]=e}}else{const r=a.match(/^(.*?)$/u);if(r){t[r[1]]=e}}}));return t}injectExtraFieldsToResponse(e){if(!e||!this.includes)return e;const t=e.data.map((e=>e.id));return this.fetchImagesAndOptions(t).then((({data:t})=>this.injectOptionsAndImages(e.data,t))).then((()=>{if(!this.includes.includes("metadata")){return e}return salla.api.metadata.fetchValues("product",t).then((({data:t})=>e.data.map((e=>Object.assign(Object.assign({},e),{metadata:t.find((t=>parseInt(t.entity_id)===parseInt(e.id)))}))))).then((()=>e))}))}fetchImagesAndOptions(e){return this.productsIncludes().length?salla.api.product.fetchOptions(e,{with:this.productsIncludes()}):Promise.resolve({data:[]})}injectOptionsAndImages(e,t){return t.length?e.map((e=>{this.includes.filter((e=>e!=="metadata")).forEach((a=>{const r=t.find((t=>parseInt(t.id)===parseInt(e.id)));e[a]=r?r[a]:null}));return e})):null}productsIncludes(){var e;return(e=this.includes)===null||e===void 0?void 0:e.filter((e=>e!="metadata"))}parseJson(e){if(typeof e!=="string"){return e}try{return JSON.parse(e)}catch(e){salla.logger.error("Failed to parse includes as JSON:",e)}return null}getProductSchemaMarkupScript(e){var t,a;const r=document.createElement("script");r.type="application/ld+json";const n={"@context":"http://schema.org","@type":"Product",name:e===null||e===void 0?void 0:e.name,image:((t=e===null||e===void 0?void 0:e.image)===null||t===void 0?void 0:t.url)||(e===null||e===void 0?void 0:e.thumbnail),description:e===null||e===void 0?void 0:e.description,brand:{"@type":"Brand",logo:(a=e===null||e===void 0?void 0:e.brand)===null||a===void 0?void 0:a.logo},offers:{"@type":"Offer",price:e===null||e===void 0?void 0:e.price}};r.text=JSON.stringify(n);return r}createProductSchema(e,t){var a;let r={productID:`${e.id}`,"@type":"Product",name:e.name,url:e.url,image:e.image.url||e.image,description:e.description||e.subtitle||e.name,offers:{"@type":"Offer",url:e.url,priceCurrency:e.currency,price:e.price,itemCondition:"NewCondition",availability:e.is_available?"InStock":"OutOfStock",priceValidUntil:e.discount_ends||new Date((new Date).setDate((new Date).getDate()+7)).toISOString().split("T")[0],priceSpecification:{"@type":"PriceSpecification",price:e.regular_price,priceCurrency:e.currency,valueAddedTaxIncluded:e.is_taxable},seller:{"@type":"Organization",name:salla.config.get("store.name")}}};if((a=e.rating)===null||a===void 0?void 0:a.stars){r.aggregateRating={"@type":"AggregateRating",ratingValue:e.rating.stars,reviewCount:e.rating.count}}return{"@type":"ListItem",position:t,item:r}}generateProductSchema(e){const t="salla-product-schema-script";if(document.getElementById(t)){salla.logger.warn(`already added schema-script with id (${t})!`);return}const a=document.createElement("script");a.type="application/ld+json";a.id=t;const r={"@context":"https://schema.org","@type":"ItemList",name:salla.config.get("page.title"),itemListElement:e.map(((e,t)=>this.createProductSchema(e,t+1)))};a.textContent=JSON.stringify(r);document.head.appendChild(a)}formatDateFromString(e,t,a="en"){const r=new Date(e);const n={en:"Invalid Date",ar:"تاريخ غير صالح"};if(isNaN(r.getTime())){return n[a]}const u={en:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],ar:["الأحد","الاثنين","الثلاثاء","الأربعاء","الخميس","الجمعة","السبت"]};const i={en:["January","February","March","April","May","June","July","August","September","October","November","December"],ar:["يناير","فبراير","مارس","أبريل","مايو","يونيو","يوليو","أغسطس","سبتمبر","أكتوبر","نوفمبر","ديسمبر"]};const s=u[a][r.getDay()];const o=t(r.getDate(),a==="en");const d=i[a][r.getMonth()];const c=t(r.getFullYear(),a==="en");return`${s} ${o} ${d} ${c}`}copyToClipboard(e){var t=e.target.innerText;navigator.clipboard.writeText(t).then((()=>{console.log("Text copied to clipboard: "+t)})).catch((e=>{console.error("Unable to copy text to clipboard",e)}))}animateItems(t){if(!t)return;e({targets:t,opacity:[0,1],duration:1200,translateY:[20,0],delay:function(e,t){return t*100},easing:"easeOutExpo",complete:function(e){t.forEach((e=>{e.classList.add("animated")}))}})}createReviewObject(e){return{"@type":"Review",author:e.name,datePublished:e.date*1e3,description:e.content,reviewRating:{"@type":"Rating",bestRating:"5",ratingValue:"5",worstRating:"1"}}}generateReviewSchema(e){const t=document.createElement("script");t.type="application/ld+json";const a={"@context":"http://schema.org/","@type":"CollectionPage",name:"Category Name",description:"Description of the category",review:e.map((e=>this.createReviewObject(e)))};t.textContent=JSON.stringify(a);document.head.appendChild(t)}}const a=new t;export{a as H};
5
- //# sourceMappingURL=p-b9c0ec80.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["salla","event","setMaxListeners","Helper","setIncludes","includes","this","toggleElementClassIf","element","classes1","classes2","callback","Array","isArray","split","isClasses1","classList","remove","add","toggleClassIf","selector","document","querySelectorAll","forEach","isValidEmail","email","re","test","String","toLowerCase","filterEmojies","text","characterFilter","replace","debounce","fn","data","debounce_","helpers","innerData","getProductsSource","source","config","get","getPageTitleForSource","brands","latest","offers","sales","lang","getProductsSourceValue","sourceValue","parsedSource","parsedSourceValue","JSON","parse","error","console","length","URLSearchParams","window","location","search","extractFiltersFromUrl","searchParams","filters","value","key","matchesNested","match","filterName","nestedKey","matchesSimple","injectExtraFieldsToResponse","response","productIds","map","product","id","fetchImagesAndOptions","then","injectOptionsAndImages","api","metadata","fetchValues","Object","assign","find","meta","parseInt","entity_id","productsIncludes","fetchOptions","with","Promise","resolve","productList","newData","filter","field","foundProduct","prod","_a","parseJson","e","logger","getProductSchemaMarkupScript","scriptElement","createElement","type","jsonData","name","image","url","thumbnail","description","brand","logo","_b","price","stringify","createProductSchema","position","ProductSchema","productID","subtitle","priceCurrency","currency","itemCondition","availability","is_available","priceValidUntil","discount_ends","Date","setDate","getDate","toISOString","priceSpecification","regular_price","valueAddedTaxIncluded","is_taxable","seller","rating","stars","aggregateRating","ratingValue","reviewCount","count","item","generateProductSchema","schemaId","getElementById","warn","script","schema","itemListElement","indxe","textContent","head","appendChild","formatDateFromString","dateString","numberCb","dateObject","errors","en","ar","isNaN","getTime","daysOfWeek","months","dayOfWeek","getDay","dayOfMonth","month","getMonth","year","getFullYear","copyToClipboard","textToCopy","target","innerText","navigator","clipboard","writeText","log","catch","err","animateItems","items","anime","targets","opacity","duration","translateY","delay","_el","i","easing","complete","_anim","createReviewObject","reviewData","author","datePublished","date","content","reviewRating","bestRating","worstRating","generateReviewSchema","reviews","review","Helper$1"],"sources":["src/Helpers/Helper.ts"],"sourcesContent":["import { ProductDetail } from \"@salla.sa/twilight/types/api/product\";\nimport { Review } from \"../../src/components/salla-reviews/interfaces\";\nimport { Product as SallaProduct } from \"@salla.sa/twilight/types/common\";\nimport { ListItem, ItemList, Product as SchemaProduct, WithContext } from 'schema-dts';\nimport { Product } from '@salla.sa/twilight/types/common';\nimport anime from 'animejs';\n\n//TODO::reduce it to 10\nsalla.event.setMaxListeners(100);\n\nclass Helper {\n private debounce_: any;\n private includes;\n\n setIncludes(includes:string[]){\n this.includes = includes;\n return this;\n }\n\n toggleElementClassIf(element, classes1, classes2, callback) {\n classes1 = Array.isArray(classes1) ? classes1 : classes1.split(' ');\n classes2 = Array.isArray(classes2) ? classes2 : classes2.split(' ');\n let isClasses1 = callback(element);\n element?.classList.remove(...(isClasses1 ? classes2 : classes1));\n element?.classList.add(...(isClasses1 ? classes1 : classes2));\n return this;\n }\n\n toggleClassIf(selector, classes1, classes2, callback) {\n document.querySelectorAll(selector).forEach(element => this.toggleElementClassIf(element, classes1, classes2, callback));\n return this;\n }\n\n isValidEmail(email) {\n const re = /^(([^<>()[\\]\\\\.,;:\\s@\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/;\n return re.test(String(email).toLowerCase());\n }\n\n filterEmojies(text) {\n var characterFilter = /(?:[\\u2700-\\u27bf]|(?:\\ud83c[\\udde6-\\uddff]){2}|[\\ud800-\\udbff][\\udc00-\\udfff]|[\\u0023-\\u0039]\\ufe0f?\\u20e3|\\u3299|\\u3297|\\u303d|\\u3030|\\u24c2|\\ud83c[\\udd70-\\udd71]|\\ud83c[\\udd7e-\\udd7f]|\\ud83c\\udd8e|\\ud83c[\\udd91-\\udd9a]|\\ud83c[\\udde6-\\uddff]|\\ud83c[\\ude01-\\ude02]|\\ud83c\\ude1a|\\ud83c\\ude2f|\\ud83c[\\ude32-\\ude3a]|\\ud83c[\\ude50-\\ude51]|\\u203c|\\u2049|[\\u25aa-\\u25ab]|\\u25b6|\\u25c0|[\\u25fb-\\u25fe]|\\u00a9|\\u00ae|\\u2122|\\u2139|\\ud83c\\udc04|[\\u2600-\\u26FF]|\\u2b05|\\u2b06|\\u2b07|\\u2b1b|\\u2b1c|\\u2b50|\\u2b55|\\u231a|\\u231b|\\u2328|\\u23cf|[\\u23e9-\\u23f3]|[\\u23f8-\\u23fa]|\\ud83c\\udccf|\\u2934|\\u2935|[\\u2190-\\u21ff])/g;\n return text.replace(characterFilter, \"\");\n }\n\n debounce(fn, ...data) {\n if (!this.debounce_) {\n this.debounce_ = salla.helpers.debounce((callback, ...innerData) => callback(...innerData), 500);\n }\n //@ts-ignore\n return this.debounce_(fn, ...data);\n }\n\n getProductsSource(source) {\n return {\n 'brands.single': 'brands',\n 'product.index': 'categories',\n 'product.index.latest': 'latest',\n 'product.index.offers': 'offers',\n 'product.index.search': 'search',\n 'customer.wishlist': 'wishlist',\n 'landing-page': 'landing-page',\n 'product.index.tag': 'tags',\n 'product.index.sales': 'sales',\n 'components.most_sales_products': 'sales',//temporary, delete it after two days from now\n }[source || salla.config.get('page.slug')] || source || 'latest';\n }\n\n getPageTitleForSource(source) {\n\n source = {\n 'brands': 'common.titles.brands',\n // 'categories':'',\n 'latest': 'blocks.home.latest_products',\n 'offers': 'common.titles.discounts',\n // 'search':'',\n // 'landing-page':'',\n // 'tags':'',\n 'sales': 'common.titles.most_sales',\n }[source];\n\n return source ? salla.lang.get(source) : '';\n }\n\n getProductsSourceValue(source, sourceValue) {\n const parsedSource = this.getProductsSource(source);\n\n // Validate if the source value is a valid JSON string\n let parsedSourceValue: any = null;\n if (sourceValue) {\n try {\n parsedSourceValue = JSON.parse(sourceValue);\n } catch (error) {\n console.error('Invalid JSON string in sourceValue:', error);\n }\n }\n\n // Handle different source types\n if (!['search', 'json', 'offers', 'latest', 'sales', 'related'].includes(parsedSource)) {\n\n if (Array.isArray(parsedSourceValue) && parsedSourceValue.length) {\n return parsedSourceValue;\n }\n\n\n if (Array.isArray(parsedSourceValue) && !parsedSourceValue.length) {\n return '';\n }\n\n if (typeof parsedSourceValue === 'number') {\n return [parsedSourceValue];\n }\n\n if (!sourceValue && ['categories', 'tags', 'brands'].includes(source)) {\n return [salla.config.get('page.id')];\n }\n }\n\n // Return sourceValue if it exists and is a valid JSON object/array\n if (parsedSourceValue || sourceValue) {\n return parsedSourceValue || sourceValue;\n }\n\n if (parsedSource === 'search') {\n return new URLSearchParams(window.location.search).get('q') || '';\n }\n\n // Return page id as default value\n return salla.config.get('page.id');\n }\n\n extractFiltersFromUrl(searchParams) {\n let filters = {};\n searchParams.forEach((value, key) => {\n // Handle filters[xxx] format\n const matchesNested = key.match(/^filters\\[(.*?)\\](\\[(.*?)\\])?$/u);\n\n if (matchesNested) {\n const filterName = matchesNested[1];\n const nestedKey = matchesNested[3];\n\n if (nestedKey) {\n // Handle nested object\n filters[filterName] = filters[filterName] || {};\n filters[filterName][nestedKey] = value;\n } else {\n // Handle regular key\n filters[filterName] = value;\n }\n } else {\n // Handle simple key-value pairs\n const matchesSimple = key.match(/^(.*?)$/u);\n\n if (matchesSimple) {\n filters[matchesSimple[1]] = value;\n }\n }\n });\n return filters;\n }\n\n injectExtraFieldsToResponse( response: {data:Product[]}) {\n if (!response || !this.includes) return response;\n\n const productIds = response.data.map(product => product.id);\n\n return this.fetchImagesAndOptions(productIds)\n .then(({ data: product }) => this.injectOptionsAndImages(response.data, product))\n .then(() => {\n if(!this.includes.includes('metadata')){\n return response;\n }\n\n return salla.api.metadata.fetchValues('product', productIds)\n //@ts-ignore\n .then(({data}) => response.data.map(product => ({...product, metadata: data.find(meta => parseInt(meta.entity_id) === parseInt(product.id))})))\n .then(() => response);\n });\n }\n\n /**\n * This to make sure we will not request the options endpoint unless we have to.\n */\n fetchImagesAndOptions(productIds){\n return this.productsIncludes().length\n ? salla.api.product.fetchOptions(productIds, { with: this.productsIncludes() })\n : Promise.resolve({data:[]}); //fake the endpoint, to reduce unwanted query if developer wants metadata only\n }\n\n\n injectOptionsAndImages( productList: Product[], newData: Product[] ): Product[] {\n return newData.length\n ? productList.map(product => {\n this.includes\n .filter(field => field !== 'metadata')\n .forEach(field => {\n //@ts-ignore\n const foundProduct = newData.find((prod: Product) => parseInt(prod.id) === parseInt(product.id));\n product[field] = foundProduct ? foundProduct[field] : null; // Assign null or a default value if not found\n });\n return product;\n })\n :null;\n }\n\n productsIncludes(){\n return this.includes?.filter(field => field != 'metadata');\n }\n\n parseJson(includes: string | string[]): null | string[] {\n if (typeof includes !== 'string') {\n return includes;\n }\n try {\n return JSON.parse(includes);\n } catch (e) {\n salla.logger.error('Failed to parse includes as JSON:', e);\n }\n\n return null;\n }\n\n getProductSchemaMarkupScript(product: any): HTMLScriptElement {\n const scriptElement = document.createElement('script');\n scriptElement.type = 'application/ld+json';\n // TODO: This json object MIGHT need mode data or properties.\n const jsonData = {\n \"@context\": \"http://schema.org\",\n \"@type\": \"Product\",\n \"name\": product?.name,\n \"image\": product?.image?.url || product?.thumbnail,\n \"description\": product?.description,\n \"brand\": {\n \"@type\": \"Brand\",\n \"logo\": product?.brand?.logo\n },\n \"offers\": {\n \"@type\": \"Offer\",\n \"price\": product?.price\n }\n };\n scriptElement.text = JSON.stringify(jsonData);\n return scriptElement\n }\n\n createProductSchema(product: SallaProduct | ProductDetail, position: number): ListItem {\n let ProductSchema: SchemaProduct = {\n \"productID\": `${product.id}`,\n \"@type\": 'Product',\n \"name\": product.name,\n \"url\": product.url,\n \"image\": product.image.url || (product.image as string),\n \"description\": product.description || product.subtitle || product.name,\n \"offers\": {\n \"@type\": \"Offer\",\n \"url\": product.url,\n \"priceCurrency\": product.currency,\n \"price\": product.price,\n \"itemCondition\": \"NewCondition\",\n \"availability\": product.is_available ? \"InStock\" : \"OutOfStock\",\n //if there is no product.discount_ends, will set it to be valid until the end of this week\n \"priceValidUntil\": product.discount_ends || (new Date(new Date().setDate(new Date().getDate() + 7)).toISOString().split('T')[0]),\n \"priceSpecification\": {\n \"@type\": \"PriceSpecification\",\n \"price\": product.regular_price,\n \"priceCurrency\": product.currency,\n \"valueAddedTaxIncluded\": product.is_taxable,\n },\n \"seller\": {\n \"@type\": \"Organization\",\n \"name\": salla.config.get('store.name'),\n },\n }\n };\n //@ts-ignore\n if (product.rating?.stars) {\n ProductSchema.aggregateRating = {\n \"@type\": \"AggregateRating\",\n //@ts-ignore\n \"ratingValue\": product.rating.stars,\n \"reviewCount\": product.rating.count,\n };\n }\n\n\n return {\n \"@type\": \"ListItem\",\n \"position\": position,\n \"item\": ProductSchema,\n\n };\n }\n \n generateProductSchema(productList: Array<SallaProduct | ProductDetail>) {\n const schemaId = 'salla-product-schema-script';\n if (document.getElementById(schemaId)) {\n salla.logger.warn(`already added schema-script with id (${schemaId})!`)\n return;\n }\n\n const script = document.createElement('script');\n script.type = 'application/ld+json';\n script.id = schemaId;\n\n\n const schema: WithContext<ItemList> = {\n \"@context\": \"https://schema.org\",\n \"@type\": \"ItemList\",\n \"name\": salla.config.get('page.title'),\n \"itemListElement\": productList.map((product, indxe) => this.createProductSchema(product, indxe + 1)),\n };\n\n script.textContent = JSON.stringify(schema);\n document.head.appendChild(script);\n }\n\n /**\n * Format date in the form of `Monday 13 November 2023`\n */\n formatDateFromString(dateString: string, numberCb: Function, lang: string = 'en'): string {\n const dateObject = new Date(dateString);\n\n const errors = {\n en: \"Invalid Date\",\n ar: \"تاريخ غير صالح\"\n }\n\n if (isNaN(dateObject.getTime())) {\n return errors[lang];\n }\n\n const daysOfWeek = {\n en: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],\n ar: ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت']\n };\n const months = {\n en: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],\n ar: ['يناير', 'فبراير', 'مارس', 'أبريل', 'مايو', 'يونيو', 'يوليو', 'أغسطس', 'سبتمبر', 'أكتوبر', 'نوفمبر', 'ديسمبر']\n };\n\n const dayOfWeek = daysOfWeek[lang][dateObject.getDay()];\n const dayOfMonth = numberCb(dateObject.getDate(), lang === 'en');\n const month = months[lang][dateObject.getMonth()];\n const year = numberCb(dateObject.getFullYear(), lang === 'en');\n\n return `${dayOfWeek} ${dayOfMonth} ${month} ${year}`;\n }\n\n /**\n * Copy text into clipboard.\n * @param event \n */\n copyToClipboard(event) {\n // Get the text content from the clicked div\n var textToCopy = event.target.innerText;\n\n // Use the Clipboard API to copy text to the clipboard\n navigator.clipboard.writeText(textToCopy)\n .then(() => {\n console.log('Text copied to clipboard: ' + textToCopy);\n })\n .catch(err => {\n console.error('Unable to copy text to clipboard', err);\n });\n\n }\n\n animateItems(items: NodeListOf<Element>) {\n if (!items) return;\n anime({\n targets: items,\n opacity: [0, 1],\n duration: 1200,\n translateY: [20, 0],\n delay: function (_el, i) {\n return i * 100;\n },\n easing: 'easeOutExpo',\n complete: function (_anim) {\n items.forEach((item: Element) => {\n item.classList.add('animated');\n })\n }\n\n })\n }\n\n createReviewObject(reviewData: Review) {\n return {\n \"@type\": \"Review\",\n \"author\": reviewData.name,\n \"datePublished\": reviewData.date * 1000,\n \"description\": reviewData.content,\n \"reviewRating\": {\n \"@type\": \"Rating\",\n \"bestRating\": \"5\",\n \"ratingValue\": \"5\",\n \"worstRating\": \"1\"\n }\n };\n }\n\n generateReviewSchema(reviews: Array<Review>){\n const script = document.createElement('script');\n script.type = 'application/ld+json';\n\n\n const schema = {\n \"@context\": \"http://schema.org/\",\n \"@type\": \"CollectionPage\",\n \"name\": \"Category Name\", // TODO: check for the correct value here\n \"description\": \"Description of the category\", // TODO: here too\n \"review\": reviews.map((review) => this.createReviewObject(review))\n }\n\n script.textContent = JSON.stringify(schema);\n document.head.appendChild(script);\n }\n}\n\nexport default new Helper;\n"],"mappings":";;;oCAQAA,MAAMC,MAAMC,gBAAgB,KAE5B,MAAMC,EAIJ,WAAAC,CAAYC,GACVC,KAAKD,SAAWA,EAChB,OAAOC,I,CAGT,oBAAAC,CAAqBC,EAASC,EAAUC,EAAUC,GAChDF,EAAWG,MAAMC,QAAQJ,GAAYA,EAAWA,EAASK,MAAM,KAC/DJ,EAAWE,MAAMC,QAAQH,GAAYA,E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