{"version":3,"file":"productSample-5560b902.js","sources":["../../../../../../src/scripts/modules/productSample.tsx"],"sourcesContent":["import React, { JSXElementConstructor, ReactElement } from 'react';\nimport { render } from 'react-dom';\nimport axios from 'axios';\nimport { Component } from '@verndale/core';\nimport ProductSampleSelection from './productSampleSelection';\nimport ProductGuideOverlay from './react/productGuideOverlay';\n\nexport type Filter = {\n SKUPropertyValue: string;\n Text: string;\n SKUPropertyName: string;\n Label: string;\n};\n\nexport type TableAttribute = {\n SKUPropertyName: string;\n Label: string;\n};\n\nexport type SKU = {\n [key: string]: string;\n};\n\nexport type DataType = {\n Filters: Filter[];\n TableAttributes: TableAttribute[];\n Skus: SKU[];\n};\n\nconst reactModule = (Component: ReactElement, nodeList: HTMLElement[], data: DataType ) => {\n nodeList.forEach((node) => render((\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n as JSXElementConstructor), node));\n};\n\nclass ProductSample extends Component {\n constructor(el: HTMLElement) {\n super(el);\n this.loadData();\n }\n\n setupDefaults() {\n this.dom = {\n sampleSelector: this.el.querySelector(\n '.product-detail__sample-selection'\n ),\n productOverlayButton: this.el.querySelector('.product-detail__footer-button-container')\n };\n }\n\n async loadData() {\n try {\n const { data } = await axios.get(this.el.dataset.endpoint as string);\n this.initModules(data);\n\n } catch (error) {\n console.log(error);\n }\n }\n\n initModules(data: DataType) {\n if (this.dom.sampleSelector) {\n new ProductSampleSelection(this.dom.sampleSelector as HTMLElement, data);\n }\n\n if (this.dom.productOverlayButton) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n reactModule(ProductGuideOverlay, [this.dom.productOverlayButton], data);\n }\n }\n}\n\nexport default ProductSample;\n"],"names":["reactModule","Component","nodeList","data","node","render","ProductSample","el","axios","error","ProductSampleSelection","ProductGuideOverlay"],"mappings":"6MA6BA,MAAMA,EAAc,CAACC,EAAyBC,EAAyBC,IAAoB,CAChFD,EAAA,QAASE,GAASC,EAAA,uBAGxBJ,EAAA,CAAW,GAAGG,EAAK,QAAS,KAAAD,EAAY,EAA8BC,CAAA,CAAK,CAChF,EAEA,MAAME,UAAsBL,CAAU,CACpC,YAAYM,EAAiB,CAC3B,MAAMA,CAAE,EACR,KAAK,SAAS,CAChB,CAEA,eAAgB,CACd,KAAK,IAAM,CACT,eAAgB,KAAK,GAAG,cACtB,mCACF,EACA,qBAAsB,KAAK,GAAG,cAA2B,0CAA0C,CAAA,CAEvG,CAEA,MAAM,UAAW,CACX,GAAA,CACI,KAAA,CAAE,KAAAJ,GAAS,MAAMK,EAAM,IAAI,KAAK,GAAG,QAAQ,QAAkB,EACnE,KAAK,YAAYL,CAAI,QAEdM,EAAO,CACd,QAAQ,IAAIA,CAAK,CACnB,CACF,CAEA,YAAYN,EAAgB,CACtB,KAAK,IAAI,gBACX,IAAIO,EAAuB,KAAK,IAAI,eAA+BP,CAAI,EAGrE,KAAK,IAAI,sBAGXH,EAAYW,EAAqB,CAAC,KAAK,IAAI,oBAAoB,EAAGR,CAAI,CAE1E,CACF"}