(window.cbJsonP=window.cbJsonP||[]).push([[188],{185:function(e,t,n){"use strict";var i=n(21),a=n.n(i),r=n(24),o=n.n(r),s=n(8),c=n.n(s),d=n(2),u=n.n(d),l=n(5),m=n.n(l),f=n(4),h=n(31),A=n(1),w=n(6),g=n(19),p=n(26),y=n(15),v=n(7),S=n(46),E=n(17),R=window.addEventListener?"addEventListener":"attachEvent",M=window[R],F="attachEvent"==R?"onmessage":"message",T=function(){function e(t){u()(this,e),this.windowType=t,this.listen()}return m()(e,[{key:"listen",value:function(){var e=this;M(F,(function(t){if(Object(E.a)()&&console.log("message received",t.data),"object"==c()(t.data)&&null!=t.data&&t.data.cbEvent){var n=t.data;if((n.targetWindowName==window.name||e.windowType==A.o.Host&&n.targetWindowName==v.a.HOST_NAME)&&!(e.windowType==A.o.Component&&t.origin!=f.a.getJSDomainIframeCommunication()||e.windowType==A.o.Master&&t.origin!=f.a.getJSDomainIframeCommunication()&&t.source!==window.parent)){var i=n.replyId,a=n.srcWindowName,r=n.message;r&&r.action&&(h.a.notTrue((function(){return e.windowType!=A.o.Component||n.srcWindowName==v.a.MASTER_FRAME}),Object(p.d)(g.e.receiveMessageError)),w.a.resolve(r).then((function(o){if(!(r.options&&r.options.noReply||n.srcWindowName===n.targetWindowName)){var s={replyId:i,message:o,cbEvent:!0,targetWindowName:n.srcWindowName};e.postMessage(a,s,t.origin)}})).catch((function(o){if(!(r.options&&r.options.noReply||n.srcWindowName===n.targetWindowName)){var s=new g.a(o),c={replyId:i,error:Object(y.l)(s),message:o.message,cbEvent:!0,targetWindowName:n.srcWindowName};e.postMessage(a,c,t.origin)}})))}}}))}},{key:"postMessage",value:function(e,t,n){var i=this;h.a.notTrue((function(){return i.windowType!=A.o.Component||e==v.a.MASTER_FRAME}),Object(p.d)(g.e.responseError)),h.a.notTrue((function(){return i.windowType!=A.o.Component||n==f.a.getJSDomainIframeCommunication()}),Object(p.d)(g.e.responseMismatchError)),Object(E.a)()&&console.log("response to --\x3e "+e+" "+o()(t));var a=this.getTargetWindow(e,{target_iframe_name:e,message_action:t.targetWindowName});try{Object(y.m)({targetWindow:a,message:t,targetIframeName:e,windowType:this.windowType,handlerType:A.n.Receiver})}catch(e){console.error(e)}Object(y.e)(a,t,n,A.n.Receiver)}},{key:"getTargetWindow",value:function(e,t){try{return this.windowType==A.o.Host?window.frames[e]:e&&e!=v.a.HOST_NAME?window.parent.frames[e]:window.parent}catch(e){if(this.windowType===A.o.Component||this.windowType===A.o.Master){var n=a()({},t,window.cb_site_info);S.a.error(e,n)}}}}]),e}();t.a=T},231:function(e,t,n){"use strict";n.r(t);var i=n(2),a=n.n(i),r=n(5),o=n.n(r),s=n(3),c=n.n(s),d=n(21),u=n.n(d),l=n(13),m=n.n(l),f=n(7),h=n(1),A=n(4),w=function(){function e(){var t=this;a()(this,e),this.iframeLoad=new m.a((function(e,n){t.iframeLoadSuccess=e,t.iframeLoadFailed=n})),this.initialize=new m.a((function(e,n){t.initializeSuccess=e,t.initializeFailed=n}))}return o()(e,[{key:"insertInside",value:function(e,t,n,i){var a=this,r=window.document.createElement("iframe");r.id=e,r.name=this.name,r.src=this.srcUrl,r.instance=this;var o=u()({margin:"0",padding:"0",border:"none",overflow:"hidden",display:"block",minWidth:"100%",width:"1px",height:"1.2em"},i);c()(o).forEach((function(e){r.style[e]=o[e]}));var s=document.getElementById(e);if(s){if(r.id=r.id+"_frame",s.classList.add("CbHosted"),n&&"1.2em"===o.height){n.container=s,this.componentField=n;var d="1.2em";try{var l=n.parent.options.style.base.fontSize;if(~l.indexOf("px"))d=1.2*parseInt(l.replace("px",""))+"px"||"1.2em"}catch(e){}r.style.height=d}s.appendChild(r)}else t.insertBefore(r,null);return this.ref=r,new m.a((function(e,t){var n,i=function(){a.iframeLoadSuccess(),clearInterval(n),e(!0)},o=function(){if(clearInterval(n),!A.a.isSPA()){var e=r.name+" iframe load failed";a.iframeLoadFailed(e),t(e)}};r.onload=i;var s=0;n=setInterval((function(){window["cb-"+a.name+"-loaded"]?i():++s>=100&&o()}),100),setTimeout(o,1e4)}))}},{key:"insert",value:function(){var e=window.document.getElementById(f.a.CONTAINER);return this.insertInside(this.name,e)}},{key:"destroy",value:function(){this.ref.innerHTML="",this.componentField.container.removeChild(this.ref),delete this.ref,delete this.componentField}}],[{key:"masterFrame",value:function(t,n){var i=new e;return i.name=t,i.type=h.o.Master,i.srcUrl=n,i}},{key:"componentFrame",value:function(t,n){var i=new e;return i.name=t,i.type=h.o.Component,i.srcUrl=n,i}}]),e}(),g=n(64),p=n(185),y=n(31),v=n(318),S=n(6),E=n(19),R=n(26),M=n(15),F=n(17);n.d(t,"CHILD_IFRAME_NAME",(function(){return T}));var T=function(e,t){return"cb-component-"+e+"-"+t},_=function(){return"#"+encodeURIComponent(window.location.host)},b=new(function(){function e(){var t;a()(this,e),this.childFrames=[],this.connectionClient=new g.c(h.o.Host,!0),new p.a(h.o.Host),t=this,S.a.registerAction(h.i.Actions.TriggerEvent,{handle:function(e){var t=v.a.registry[e.data.frame];return y.a.notTrue((function(){return!!t}),Object(R.d)(E.e.componentNotFound)),t.delegateEvent(e.data),new m.a((function(e,t){return e({acknowledged:!0})}))}}),S.a.registerAction(h.i.Actions.ReceiveStatusBroadcast,{handle:function(e){var t=v.a.registry[e.data.frame];return y.a.notTrue((function(){return!!t}),Object(R.d)(E.e.componentNotFound)),t.delegateEvent(e.data),new m.a((function(e,t){return e({acknowledged:!0})}))}}),S.a.registerAction(h.i.Actions.setTestCards,{handle:function(e){var t=v.a.registry[e.data.frame];return t&&t.delegateEvent(e.data),m.a.resolve({acknowledged:!0})}}),S.a.registerAction(h.i.Actions.SetPaymentIntent3DSResult,{handle:function(e){return t.send({action:h.m.Actions.SetPaymentIntent3DSResult,data:e.data},f.a.MASTER_FRAME)}}),S.a.registerAction(h.i.Actions.SetAdyen3DS1VerificationResult,{handle:function(e){return t.send({action:h.m.Actions.SetAdyen3DS1VerificationResult,data:e.data},f.a.MASTER_FRAME)}}),S.a.registerAction(h.m.Actions.SetCheckoutCom3DSVerificationResult,{handle:function(e){return t.send({action:h.m.Actions.SetCheckoutCom3DSVerificationResult,data:e.data},f.a.MASTER_FRAME)}}),S.a.registerAction(h.m.Actions.SetCybersource3DSVerificationResult,{handle:function(e){return t.send({action:h.m.Actions.SetCybersource3DSVerificationResult,data:e.data},f.a.MASTER_FRAME)}}),S.a.registerAction(h.i.Actions.SetAdyenIDealVerificationResult,{handle:function(e){try{t.send({action:h.m.Actions.CaptureKVL,data:u()({action:"iDeal_set_verification_result"},Object(M.l)(e.data))},f.a.MASTER_FRAME)}catch(e){}return t.send({action:h.m.Actions.SetAdyenIDealVerificationResult,data:e.data},f.a.MASTER_FRAME)}}),S.a.registerAction(h.i.Actions.SetStripeIDealVerificationResult,{handle:function(e){try{t.send({action:h.m.Actions.CaptureKVL,data:u()({action:"iDeal_set_verification_result"},Object(M.l)(e.data))},f.a.MASTER_FRAME)}catch(e){}return t.send({action:h.m.Actions.SetStripeIDealVerificationResult,data:e.data},f.a.MASTER_FRAME)}}),S.a.registerAction(h.i.Actions.SetAdyenSofortVerificationResult,{handle:function(e){return t.send({action:h.m.Actions.SetAdyenSofortVerificationResult,data:e.data},f.a.MASTER_FRAME)}}),S.a.registerAction(h.i.Actions.SetAdyenBancontactVerificationResult,{handle:function(e){return t.send({action:h.m.Actions.SetAdyenBancontactVerificationResult,data:e.data},f.a.MASTER_FRAME)}}),S.a.registerAction(h.i.Actions.SetAdyenGiropayVerificationResult,{handle:function(e){return t.send({action:h.m.Actions.SetAdyenGiropayVerificationResult,data:e.data},f.a.MASTER_FRAME)}}),S.a.registerAction(h.i.Actions.SetAdyenDotpayVerificationResult,{handle:function(e){return t.send({action:h.m.Actions.SetAdyenDotpayVerificationResult,data:e.data},f.a.MASTER_FRAME)}}),S.a.registerAction(h.i.Actions.SetFrameLoaded,{handle:function(e){return window["cb-"+e.data.frame+"-loaded"]=!0,m.a.resolve({acknowledged:!0})}}),S.a.registerAction(h.i.Actions.CaptureKVL,{handle:function(e){return t.send({action:h.m.Actions.CaptureKVL,data:e.data},f.a.MASTER_FRAME)}}),S.a.registerAction(h.i.Actions.CaptureException,{handle:function(e){return t.send({action:h.m.Actions.CaptureException,data:e.data},f.a.MASTER_FRAME)}}),S.a.registerAction(h.i.Actions.SetAuthToken,{handle:function(e){return t.send({action:h.m.Actions.SetHpData,data:{jwt:Object(M.q)(e,"data.jwt")||""}},f.a.MASTER_FRAME)}}),S.a.registerAction(h.i.Actions.SetCustomerHandle,{handle:function(e){return t.send({action:h.m.Actions.SetHpData,data:{customer_handle:Object(M.q)(e,"data.customer_handle")||""}},f.a.MASTER_FRAME)}}),S.a.registerAction(h.i.Actions.SetPreviewPortalEmail,{handle:function(e){var n=Object(M.q)(e,"data.email")||"";return t.send({action:h.m.Actions.SetHpData,data:{preview_portal_email:n}},f.a.MASTER_FRAME)}}),S.a.registerAction(h.i.Actions.GetPreviewPortalEmail,{handle:function(e){return t.send({action:h.m.Actions.GetHpData,data:{param:"preview_portal_email"}},f.a.MASTER_FRAME).then((function(e){var t=e.preview_portal_email,n=document.getElementById("cb-frame");return n&&t&&n.contentWindow.postMessage({action:"setPreviewPortalEmail",referrer:"chargebeejs",data:{preview_portal_email:t}},"*"),e}))}}),S.a.registerAction(h.i.Actions.ShowFrame,{handle:function(e){return document.querySelector("iframe[name="+e.data+"]").style.display="block",new m.a((function(e,t){return e({acknowledged:!0})}))}}),S.a.registerAction(h.i.Actions.HideFrame,{handle:function(e){return document.querySelector("iframe[name="+e.data+"]").style.display="none",new m.a((function(e,t){return e({acknowledged:!0})}))}})}return o()(e,[{key:"createMasterFrame",value:function(){var e=this;return this.checkMasterInitialized()||(this.masterFrame=w.masterFrame(g.b,F.b.ASSET_PATH+"/master.html"+_()),this.commMgrReady=this.masterFrame.insert().then((function(){var t=A.a.getCbInstance(),n={host:window.location.origin,site:t.site,publishableKey:t.publishableKey,businessEntityId:A.a.getBusinessEntityId(),options:t.options,window_url:window.location.href},i={action:h.m.Actions.RegisterMaster,data:n};return e.register(i,e.masterFrame)})).catch((function(t){e.masterFrame.initializeFailed(new Error(Object(R.d)(E.e.errorMountingMaster))),console.error(Object(R.d)(E.e.errorMountingMaster)),t&&console.error(t)}))),this.commMgrReady}},{key:"createCbFrame",value:function(e,t){var n=this,i=e.id,a=e.fieldType,r=(e.options,w.componentFrame(T.apply(null,[a,this.childFrames.length]),F.b.ASSET_PATH+"/component.html"+_()));return this.childFrames.push(r),r.insertInside(i,t,e).then((function(){return n.masterFrame.initialize})).then((function(){return r}))}},{key:"createIDealFrame",value:function(e,t,n){var i=this,a=e.id,r=e.fieldType,o=w.componentFrame(T.apply(null,[r,this.childFrames.length]),F.b.ASSET_PATH+"/component.html"+_());return this.childFrames.push(o),o.insertInside(a,t,e,n).then((function(){return i.masterFrame.initialize})).then((function(){return o}))}},{key:"register",value:function(e,t){var n=this;return this.masterFrame.iframeLoad.then((function(){return n.connectionClient.sendMessage(e,g.b,{timeout:1e4})})).then((function(){return t.initializeSuccess(),{registered:!0}})).catch((function(e){return t.initializeFailed(e),{registered:!1}}))}},{key:"checkMasterInitialized",value:function(){var e=document.getElementById(g.b);return!this.masterFrame&&e&&(this.masterFrame=e.instance),!!this.masterFrame&&!!e}},{key:"send",value:function(e,t,n){var i=this;return this.createMasterFrame().then((function(){return i.masterFrame.initialize})).then((function(){return i.connectionClient.sendMessage(e,t,n)}))}},{key:"listen",value:function(e){this.connectionClient.receiver.listen(e)}},{key:"deregister",value:function(e){this.childFrames=this.childFrames.filter((function(t){return t.name!==e}))}}]),e}());t.default=b},318:function(e,t,n){"use strict";var i=n(2),a=n.n(i),r=n(5),o=n.n(r),s=function(){function e(){a()(this,e)}return o()(e,null,[{key:"register",value:function(e,t){this.registry[t]=e}}]),e}();s.registry={},t.a=s},6:function(e,t,n){"use strict";var i=n(2),a=n.n(i),r=n(5),o=n.n(r),s=new(function(){function e(){a()(this,e),this.actionRegistry={}}return o()(e,[{key:"registerAction",value:function(e,t){this.actionRegistry[e]=t}},{key:"resolve",value:function(e){var t=this.actionRegistry[e.action];if(t&&t.handle)return t.handle(e);console.log("Unknown action: "+t)}}]),e}());t.a=s}}]); //# sourceMappingURL=188-37b579d66f932fbb9de9.js.map