/*! v3.1.5 */
!function(){function t(t){var e=a[t];a[t]=function(t){return o(e(t))}}function i(t,e,i){return(i=this).attachEvent("on"+t,function(t){(t=t||n.event).preventDefault=t.preventDefault||function(){t.returnValue=!1},t.stopPropagation=t.stopPropagation||function(){t.cancelBubble=!0},e.call(i,t)})}function o(t,e){if(e=t.length)for(;e--;)t[e].addEventListener=i;else t.addEventListener=i;return t}var n,a;function s(t){window.setTimeout(function(){t&&t.call(document)})}n=window,a=document,n.addEventListener||(o([a,n]),"Element"in n?n.Element.prototype.addEventListener=i:(a.attachEvent("onreadystatechange",function(){o(a.all)}),t("getElementsByTagName"),t("getElementById"),t("createElement"),o(a.all))),"undefined"!=typeof window&&window.addEventListener("load",function(){var t;navigator.platform.match(/iPhone|iPod|iPad/)&&History.initCore&&(t=function(t){var i=t.func,o=t.limit,n=!1,a=[null,"",location.href];return function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if(t[1]!==a[1]||t[2]!==a[2])return a=t,void i.apply(this,t);a=t,n||(i.apply(this,t),n=!0,setTimeout(function(){n=!1},o))}},History.pushState=t({func:History.pushState,limit:350}),History.replaceState=t({func:History.replaceState,limit:350}))},!1);var r=!1,d=[],e=function(){for(r=!0;d.length;)s(d.shift())};"undefined"!=typeof document&&("complete"===document.readyState||"loading"!==document.readyState&&!document.documentElement.doScroll?r=!0:(document.addEventListener("DOMContentLoaded",e),document.addEventListener("load",e)));var c=(h=navigator.userAgent.toLowerCase()).match(/android (\d+(\.\d+)?)/),u=h.match(/firefox\/(\d+(\.\d+)?)/),e=h.match(/chrome\/(\d+(\.\d+)?)/),h=h.match(/msie (\d+(\.\d+)?)/),p=!!u,l=!!e,f=c?parseFloat(c[1]):null,m=h?parseFloat(h[1]):null;function y(){return f&&!l&&!p&&f<5?"お客様のご利用端末は、サポート対象外のOSバージョンのため2018年11月13日以降Paidy決済をご利用頂けません。サポート対象であるAndroid4.4以上のバージョンに更新していただくか、パソコン等（ブラウザ：IE11以上、Chrome、Firefox)をご使用いただくことで、Paidy決済をご利用いただけます。":m&&m<11?"お客様のブラウザバージョンは、サポート対象外のブラウザバージョンのため2018年11月13日以降Paidy決済をご利用頂けません。サポート対象であるIE11以上のバージョンに更新していただくか、他のブラウザ(Chrome、Firefox)をご使用いただくことで、Paidy決済をご利用いただけます。":0}var g=function(){var t=(new Date).getTime(),e=g.last||t,e=e<t?t:e+1;return g.last=e};function _(t,e){var i=arguments;if(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var o=Object(t),n=1;n<arguments.length;n++){var a=i[n];if(null!=a)for(var s in a)Object.prototype.hasOwnProperty.call(a,s)&&(o[s]=a[s])}return o}function v(t,e){if(t.metadata=_({},e.metadata,t.metadata),e&&e.key&&0<=P.indexOf(function(t){for(var e=0,i=0;i<t.length;i++)e=(e<<5)-e+t.charCodeAt(i),e&=e;return e.toString(16)}(e.key)))try{var i=_({},t);if(t.buyer_data){var o=_({},t.buyer_data),n=o.shops;o.shops=[];for(var a=0;a<n.length;a+=1){var s=n[a],s=_({},{age:s.age,item_id:s.item_id,shop_id:s.shop_id,category:s.category,transaction_count:s.transaction_count},s.num_photos&&{num_photos:s.num_photos},s.buyer_shop_url&&{buyer_shop_url:s.buyer_shop_url},s.shop_name&&{shop_name:s.shop_name},s.total_sales_amount&&{total_sales_amount:s.total_sales_amount},s.shop_reputation&&{shop_reputation:s.shop_reputation},s.item_likes&&{item_likes:s.item_likes},s.item_reputation&&{item_reputation:s.item_reputation},s.num_of_follower&&{num_of_follower:s.num_of_follower});o.shops.push(s)}i.buyer_data=o}if(t.merchant_data){var r=_({},t.merchant_data),d=r.shops;r.shops=[];for(var c=0;c<d.length;c+=1){var u=d[c],u=_({},{age:u.age,item_id:u.item_id,shop_id:u.shop_id,category:u.category,transaction_count:u.transaction_count},u.num_photos&&{num_photos:u.num_photos},u.buyer_shop_url&&{buyer_shop_url:u.buyer_shop_url});r.shops.push(u)}i.merchant_data=r}return i}catch(t){}return t}function E(t){return t&&"[object Function]"==={}.toString.call(t)}function w(t){return E(t)?t:null}function b(){}function k(t,e,i){var o=this;void 0===e&&(e={}),this._id=i,this.options=e,this.state=H,this.iframeState=N,this.queue=[],this.iframe=document.createElement("iframe"),this.iframe.onload=function(){o.iframeState=T,o.dequeue()},i=new URLSearchParams(window.location.search),e="",i.has("category")&&(e+="&category="+i.get("category")),i.has("size")&&(e+="&size="+i.get("size")),i.has("installment")&&(e+="&installment="+i.get("installment")),this.iframe.src=t+"?key="+(this.options.apiKey||"")+e,this.iframe.setAttribute("style","z-index: 2147483647; display: none; position: fixed; background: transparent; top: 0; left: 0; width: 100%; height: 100%; border: 0; overflow-x: hidden; overflow-y: auto; visibility: visible; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent;"),y()||(e=function(){o.originalBodyPosition=window.getComputedStyle(document.body).getPropertyValue("position"),document.body.appendChild(o.iframe)},r?s(e):d.push(e))}var P=["1ef6fdec","-1ef11ad9","-c625635","6bae0047","2a81ac6","12966806","769a403e","2ab62f65","3afc47b8","-39f922c7","-702e5867","-5fbb4b4d","f584825","3fd95727"],S="production",C="paidy_checkout_style",O={production:"https://api.paidy.com"},L={production:"https://checkout-v2.paidy.com"},D={AUTHORIZED:"authorized",PENDING:"pending",REJECTED:"rejected",CLOSED:"closed"},F="active",I="recurring",N="initialized",T="loaded",x="closed",H="prepare",q="launch";function A(t){var i=this;this._id=g().toString(36).toUpperCase(),this.config={},this.configure(t),this.paidyFrame=new k(this.appHost,{apiKey:this.apiKey,onPending:this.onPending,onClose:this.onClose,isOnCloseV2:this.isOnCloseV2},this._id),this.wait=!1,window.addEventListener("message",function(t){var e=t.data;if(e&&e._id===i._id)switch(e.event){case"paidy_checkout:close":case"paidy_checkout:init_failed":i.paidyFrame&&i.paidyFrame.close(e.payload);break;case"paidy_checkout:payment_pending":i.paidyFrame&&i.paidyFrame.invokePending(e.payload)}},!1)}k.prototype.enqueue=function(t){this.queue.push(t),this.dequeue()},k.prototype.dequeue=function(){var t;this.iframeState!==T||(t=this.queue.shift())&&(E(t)&&t(this.iframe),this.dequeue())},k.prototype.reload=function(){this.iframeState=N,this.iframe.src=this.iframe.src},k.prototype.launch=function(o,t){var n=this;this.state!==q&&(this.state=q,this.config=_({},t),this.payload=o,this.enqueue(function(t){t.contentWindow.postMessage({_id:n._id,event:"paidy_checkout:init",config:JSON.stringify(n.config),payload:JSON.stringify(o)},t.src),n._iOSDevice=!!navigator.platform.match(/iPhone|iPod|iPad|iOS/),n._LIFF=!!navigator.userAgent.match(/LIFF/),n._LINE=!!navigator.userAgent.match(/Line/);var e=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css",i.id=C,i.appendChild(document.createTextNode("body { overflow: hidden !important; margin: 0 !important; padding: 0 !important; }")),e.appendChild(i),n._iOSDevice&&(n._LIFF||n._LINE)&&(t.style.position="absolute",t.style.top=document.documentElement.scrollTop+"px"),t.style.display="block"}))},k.prototype.invokePending=function(t){this.options.onPending&&this.options.onPending(t)},k.prototype.close=function(t){this.state=H;var e,i=!!this.payload.merchant_data,o=!!this.config&&!!this.config.token&&this.config.token.type===I;e=C,(e=document.getElementById(e))&&e.parentNode&&e.parentNode.removeChild(e),this._iOSDevice&&(document.body.style.position=this.originalBodyPosition),t=i?-1<[D.AUTHORIZED,D.PENDING].indexOf(t.status)&&{payment_id:t.id,status:function(t){var e=t.status;switch(e){case D.AUTHORIZED:return"authorize_success";case D.PENDING:return"pending_success";default:return e}}({status:t.status}),test:t.test}:(t.test&&delete t.test,o?t.status===F?{created_at:t.created_at,id:t.id,status:F}:this.options.isOnCloseV2&&{status:D.CLOSED}:-1<[D.AUTHORIZED,D.PENDING,D.REJECTED].indexOf(t.status)?t:{status:D.CLOSED}),this.iframe.style.display="none",t&&this.options.onClose(t),this.iframeState=x,this.reload()},A.prototype.configure=function(t){var e=t.key,i=t.api_key,o=t.api_host,n=t.app_host,a=t.tier,s=t.token,r=t.logo_url,d=t.metadata,c=t.on_pending,u=t.on_close,h=t.closed,t=t.callback;if(!i&&!e)throw new Error("[Paidy] Field 'key' or 'api_key' is required");var p,t=w(u)||w(h)||w(t)||b,u=E(u);this.config.key=i||e||"",this.config.api_host=o||O[S],this.config.app_host=n||L[S],this.config.tier=a,this.config.token=s,this.config.metadata=d,this.config.logo_url=r,this.config.on_pending=w(c),this.config.closed=(p=t,function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];setTimeout(function(){p.apply(void 0,t)},0)}),this.apiKey=this.config.key,this.apiHost=this.config.api_host,this.appHost=this.config.app_host,this.tier=this.config.tier,this.token=this.config.token,this.logoURL=this.config.logo_url,this.onPending=this.config.on_pending,this.onClose=this.config.closed,this.isOnCloseV2=u},A.prototype.launch=function(t){var e,i=this;this.wait||((e=y())&&alert(e),e=t,t=this.config,t=v(e,t),this.paidyFrame.launch(t,this.config),setTimeout(function(){i.wait=!1},1e3))},window.Paidy={},window.Paidy.configure=function(t){return new A(t)}}();
