define(['jquery','Magento_Ui/js/modal/modal','mage/storage','jquery/jquery-storageapi'],function($,modal){'use strict';$.widget('smartsolutions.actionPopup',{options:{type:'popup',responsive:true,eventName:'submit',searchOnClosest:true,showOncePerSession:false},_create:function(){this.initStorage();if(undefined!==this.element){let popupDiv=$(this.element).siblings('.product__popup-message') if(popupDiv.length){var selfActionPopup=this;$(this.element).on(this.options.eventName,function(e,test){if(true===test){return true;} let pId=selfActionPopup.getPId(popupDiv);if(!selfActionPopup.options.showOncePerSession||(pId&&!selfActionPopup.isStoragePidSet(pId))){e.preventDefault();let callback=selfActionPopup.createButtonCallback(pId);selfActionPopup.displayPopup(popupDiv,pId,callback);}});}}},initStorage:function(){this.popupStorage=$.initNamespaceStorage('popup-products-viewed').sessionStorage;},isStoragePidSet:function(pId){return this.popupStorage.isSet('t'+pId)},getPId:function(element){return element.data('product-id');},createButtonCallback:function(pId){var self=this;return function(){self.element.trigger(self.options.eventName,[true]);}},displayPopup:function(element,pId,callback,callbackParam1,callbackParam2){var self=this;let modalOptions={type:this.options.type,responsive:this.options.responsive,buttons:[{text:$.mage.__('Ok'),class:'',click:function(){this.closeModal();self.popupStorage.set('t'+pId,true);if(undefined!==callbackParam1&&undefined!==callbackParam2){callback(callbackParam1,callbackParam2);}else if(undefined!==callbackParam1){callback(callbackParam1);}else{callback();}}}]};modal(modalOptions,element);element.modal('openModal');}});return $.smartsolutions.actionPopup;});