{"version":3,"file":"ModifaceVTO.js","names":["BaseStore","a","default","execute","initialData","vtoActivationHistory","isVTOActivated","currentPid","category","currentLook","previewProductsMap","currentEditPid","isMultipleSelection","mode","modifaceStore","enableVTO","state","data","currentVtoStates","Object","assign","pid","look","forEach","item","upc","disableVTO","selectLook","lookProductsMap","unSelectLook","removeProduct","filter","editProduct","updateProductQuantity","map","productData","newProductData","qty","reset","accessBy","resetLook","selectMode","unselectMode"],"sources":["stores/ModifaceVTO.js"],"sourcesContent":["import BaseStore from 'stores/BaseStore';\n\nconst initialData = {\n vtoActivationHistory: {}, // list of variations where VTO was activated during current page visit\n isVTOActivated: false, // current \"activation\" state of Modiface VTO\n currentPid: null, // current product id\n category: null, // Modiface category\n currentLook: null, // object with current look data [{\"category\":\"eyeshadow\",\"upc\":\"3605533330142\",\"color_id\":0}, ...]\n // data about list of products and quantities which will be addded to basket\n previewProductsMap: [], // list of product which should be added to basket\n currentEditPid: null, // product id which is currently editing\n isMultipleSelection: false, // is multiple product selection allowed\n mode: null, // Modiface VTO iframe mode\n};\n\nconst modifaceStore = new BaseStore(initialData, {\n enableVTO: (state, data) => {\n const currentVtoStates = Object.assign({}, state.vtoActivationHistory);\n\n if (data.pid) {\n currentVtoStates[data.pid] = true;\n }\n\n const look = data.look || state.currentLook;\n // add look products to VTO state history\n if (look) {\n look.forEach((item) => {\n currentVtoStates[item.upc] = true;\n });\n }\n\n return Object.assign({}, state, {\n vtoActivationHistory: currentVtoStates,\n isVTOActivated: true,\n currentPid: data.pid,\n currentLook: data.look || state.currentLook,\n });\n },\n\n disableVTO: state => Object.assign({}, state, {\n isVTOActivated: false,\n }),\n\n selectLook: (state, data) => Object.assign({}, state, {\n currentPid: data.pid,\n currentLook: data.look || state.currentLook,\n previewProductsMap: data.lookProductsMap || [],\n currentEditPid: null,\n }),\n\n unSelectLook: state => Object.assign({}, state, {\n currentPid: null,\n currentLook: null,\n previewProductsMap: [],\n currentEditPid: null,\n }),\n\n removeProduct: (state, data) => {\n const previewProductsMap = state.previewProductsMap.filter(item => data.pid !== item.pid);\n\n return Object.assign({}, state, {\n previewProductsMap,\n });\n },\n\n editProduct: (state, data) => Object.assign({}, state, {\n currentEditPid: data.pid,\n }),\n\n updateProductQuantity: (state, data) => {\n const previewProductsMap = state.previewProductsMap.map((productData) => {\n const newProductData = Object.assign({}, productData);\n if (data.pid === newProductData.pid) {\n newProductData.qty = data.qty || 1;\n }\n return newProductData;\n });\n\n return Object.assign({}, state, {\n previewProductsMap,\n });\n },\n\n reset: state => Object.assign({}, state, {\n isVTOActivated: false,\n currentPid: null,\n category: null,\n currentLook: null,\n vtoActivationHistory: {},\n previewProductsMap: [],\n currentEditPid: null,\n accessBy: null,\n mode: null,\n }),\n\n resetLook: state => Object.assign({}, state, {\n currentLook: null,\n previewProductsMap: [],\n currentEditPid: null,\n }),\n\n selectMode: (state, data) => Object.assign({}, state, {\n mode: data,\n }),\n\n unselectMode: state => Object.assign({}, state, {\n mode: null,\n }),\n});\n\nexport default modifaceStore;\n"],"mappings":"iHAAOA,CAAS,CAAAC,CAAA,CAAAC,OAAA,GAAAC,OAAA,SAAAA,CAAA,EAEVC,CAAW,CAAG,CAChBC,oBAAoB,CAAE,CAAC,CAAC,CACxBC,cAAc,GAAO,CACrBC,UAAU,CAAE,IAAI,CAChBC,QAAQ,CAAE,IAAI,CACdC,WAAW,CAAE,IAAI,CAEjBC,kBAAkB,CAAE,EAAE,CACtBC,cAAc,CAAE,IAAI,CACpBC,mBAAmB,GAAO,CAC1BC,IAAI,CAAE,IACV,CAAC,CAEKC,CAAa,CAAG,GAAI,CAAAd,CAAS,CAACI,CAAW,CAAE,CAC7CW,SAAS,CAAEA,CAACC,CAAK,CAAEC,CAAI,GAAK,CACxB,KAAM,CAAAC,CAAgB,CAAGC,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,CAAEJ,CAAK,CAACX,oBAAoB,CAAC,CAElEY,CAAI,CAACI,GAAG,GACRH,CAAgB,CAACD,CAAI,CAACI,G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