window.storecrm_config = {"favorite":{},"favoriteList":{},"restock":{"button_text":"再入荷通知をする","button_width":300,"button_height":50,"button_color":"#ffffff","button_background_color":"#000000","button_border_color":"#000000","button_hover_color":"#222222","button_hover_background_color":"#a1a1a1","button_hover_border_color":"#222222","button_radius":0,"button_border_width":0,"button_font":"helvetica_n4","button_fontsize":16,"button_fontweight":400,"button_speed":0.3,"align":"center"},"restockPopup":{"popup_title":"再入荷通知","popup_description":"再入荷通知をご希望の方は以下から、ご選択ください。","emailaddress":"ご連絡メールアドレス","background_color":"#ffffff","text_color":"#000000","close_text_color":"#000000","button_background_color":"#222222","button_text_color":"#dddddd","button_text":"再入荷通知を有効にする","success_text":"再入荷通知が登録されました。","success_background_color":"#F0FDF4","success_text_color":"#166534","error_text":"再入荷通知の登録に失敗しました。しばらくたってから再度お試しください。","error_text_email":"メールアドレスが正しくありません。確認の上、再度ご記入ください。","failure_background_color":"#FEF2F2","failure_text_color":"#991B1B","button_radius":10},"backendUrl":"https://obake.groovymedia.co","appProxyName":"obake"}; (()=>{"use strict";var e={208:(e,t,o)=>{o.d(t,{A:()=>a});var n=o(601),r=o.n(n),i=o(314),s=o.n(i)()(r());s.push([e.id,'.storecrm_modal {\n display: none;\n}\n\n.storecrm_modal.is-open {\n display: block;\n}\n\n.storecrm_modal_line {\n margin: 1rem 0;\n}\n\n.storecrm_modal input, .storecrm_modal select {\n width: 100%;\n padding: 10px;\n font-size: 100%;\n margin: 1rem 0;\n}\n\n.storecrm_modal__overlay {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n z-index: 10000;\n background: rgba(0,0,0,0.6);\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.storecrm_modal__container {\n background-color: #fff;\n padding: 30px;\n min-width: 320px;\n max-width: 500px;\n min-height: 200px;\n max-height: 100vh;\n border-radius: 4px;\n overflow-y: auto;\n box-sizing: border-box;\n}\n\n.storecrm_modal__header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n.storecrm_modal__title {\n margin-top: 0;\n margin-bottom: 0;\n font-weight: 600;\n font-size: 1.25;\n line-height: 1.25;\n box-sizing: border-box;\n}\n\n.storecrm_modal__close {\n background: transparent;\n border: 0;\n cursor: pointer;\n}\n\n.storecrm_modal_message {\n margin-top: 2rem;\n padding: 1rem;\n}\n\n.storecrm_modal__header .storecrm_modal__close:before { content: "\\2715"; }\n\n.storecrm_modal__content {\n margin-top: 2rem;\n margin-bottom: 1rem;\n line-height: 1.5;\n color: rgba(0,0,0,.8);\n}\n\n.storecrm_modal__btn {\n display: block;\n width: 100%;\n padding-top: 1rem;\n padding-bottom: 1rem;\n background-color: #e6e6e6;\n color: rgba(0,0,0,.8);\n border-radius: .25rem;\n border-style: none;\n border-width: 0;\n cursor: pointer;\n -webkit-appearance: button;\n text-transform: none;\n overflow: visible;\n line-height: 1.15;\n margin: 0;\n margin-top: 1rem;\n will-change: transform;\n -moz-osx-font-smoothing: grayscale;\n -webkit-backface-visibility: hidden;\n backface-visibility: hidden;\n -webkit-transform: translateZ(0);\n transform: translateZ(0);\n transition: -webkit-transform .25s ease-out;\n transition: transform .25s ease-out;\n transition: transform .25s ease-out,-webkit-transform .25s ease-out;\n}\n\n.storecrm_modal__btn:hover {\n -webkit-transform: scale(1.05);\n transform: scale(1.05);\n}\n\n.storecrm_modal__btn-primary {\n background-color: #00449e;\n color: #fff;\n}\n\n.storecrm_modal__btn:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n@keyframes mmfadeIn {\n from { opacity: 0; }\n to { opacity: 1; }\n}\n\n@keyframes mmfadeOut {\n from { opacity: 1; }\n to { opacity: 0; }\n}\n\n@keyframes mmslideIn {\n from { transform: translateY(15%); }\n to { transform: translateY(0); }\n}\n\n@keyframes mmslideOut {\n from { transform: translateY(0); }\n to { transform: translateY(-10%); }\n}\n\n.micromodal-slide {\n display: none;\n}\n\n.micromodal-slide.is-open {\n display: block;\n}\n\n.micromodal-slide[aria-hidden="false"] .storecrm_modal__overlay {\n animation: mmfadeIn .3s cubic-bezier(0.0, 0.0, 0.2, 1);\n}\n\n.micromodal-slide[aria-hidden="false"] .storecrm_modal__container {\n animation: mmslideIn .3s cubic-bezier(0, 0, .2, 1);\n}\n\n.micromodal-slide[aria-hidden="true"] .storecrm_modal__overlay {\n animation: mmfadeOut .3s cubic-bezier(0.0, 0.0, 0.2, 1);\n}\n\n.micromodal-slide[aria-hidden="true"] .storecrm_modal__container {\n animation: mmslideOut .3s cubic-bezier(0, 0, .2, 1);\n}\n\n.micromodal-slide .storecrm_modal__container,\n.micromodal-slide .storecrm_modal__overlay {\n will-change: transform;\n}\n\n\n.storecrm-status-widget {\n width: 100%;\n border: 1px solid #e6e6e6;\n display: flex;\n align-items: center;\n justify-content: center;\n max-height: 3em;\n}\n\n.storecrm-status-widget > div {\n padding: 1rem;\n}\n\n.storecrm-on {\n /* deep green, bold */\n color: #094c00;\n font-weight: bold;;\n}\n\n.storecrm-off {\n color: #df8536c6;\n font-weight: bold;\n}\n',""]);const a=s},314:e=>{e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var o="",n=void 0!==t[5];return t[4]&&(o+="@supports (".concat(t[4],") {")),t[2]&&(o+="@media ".concat(t[2]," {")),n&&(o+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),o+=e(t),n&&(o+="}"),t[2]&&(o+="}"),t[4]&&(o+="}"),o})).join("")},t.i=function(e,o,n,r,i){"string"==typeof e&&(e=[[null,e,void 0]]);var s={};if(n)for(var a=0;a0?" ".concat(d[5]):""," {").concat(d[1],"}")),d[5]=i),o&&(d[2]?(d[1]="@media ".concat(d[2]," {").concat(d[1],"}"),d[2]=o):d[2]=o),r&&(d[4]?(d[1]="@supports (".concat(d[4],") {").concat(d[1],"}"),d[4]=r):d[4]="".concat(r)),t.push(d))}},t}},601:e=>{e.exports=function(e){return e[1]}},804:(e,t,o)=>{function n(e){return function(e){if(Array.isArray(e))return r(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return r(e,t);var o=Object.prototype.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?r(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var o=0,n=new Array(t);ou});var i,s,a,c,l,d=(i=["a[href]","area[href]",'input:not([disabled]):not([type="hidden"]):not([aria-hidden])',"select:not([disabled]):not([aria-hidden])","textarea:not([disabled]):not([aria-hidden])","button:not([disabled]):not([aria-hidden])","iframe","object","embed","[contenteditable]",'[tabindex]:not([tabindex^="-"])'],s=function(){function e(t){var o=t.targetModal,r=t.triggers,i=void 0===r?[]:r,s=t.onShow,a=void 0===s?function(){}:s,c=t.onClose,l=void 0===c?function(){}:c,d=t.openTrigger,u=void 0===d?"data-micromodal-trigger":d,m=t.closeTrigger,h=void 0===m?"data-micromodal-close":m,f=t.openClass,p=void 0===f?"is-open":f,g=t.disableScroll,b=void 0!==g&&g,v=t.disableFocus,_=void 0!==v&&v,w=t.awaitCloseAnimation,y=void 0!==w&&w,k=t.awaitOpenAnimation,E=void 0!==k&&k,x=t.debugMode,S=void 0!==x&&x;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.modal=document.getElementById(o),this.config={debugMode:S,disableScroll:b,openTrigger:u,closeTrigger:h,openClass:p,onShow:a,onClose:l,awaitCloseAnimation:y,awaitOpenAnimation:E,disableFocus:_},i.length>0&&this.registerTriggers.apply(this,n(i)),this.onClick=this.onClick.bind(this),this.onKeydown=this.onKeydown.bind(this)}var t;return(t=[{key:"registerTriggers",value:function(){for(var e=this,t=arguments.length,o=new Array(t),n=0;n0&&void 0!==arguments[0]?arguments[0]:null;this.activeElement=document.activeElement,this.modal.setAttribute("aria-hidden","false"),this.modal.classList.add(this.config.openClass),this.scrollBehaviour("disable"),this.addEventListeners(),this.config.awaitOpenAnimation?this.modal.addEventListener("animationend",(function t(){e.modal.removeEventListener("animationend",t,!1),e.setFocusToFirstNode()}),!1):this.setFocusToFirstNode(),this.config.onShow(this.modal,this.activeElement,t)}},{key:"closeModal",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=this.modal;if(this.modal.setAttribute("aria-hidden","true"),this.removeEventListeners(),this.scrollBehaviour("enable"),this.activeElement&&this.activeElement.focus&&this.activeElement.focus(),this.config.onClose(this.modal,this.activeElement,e),this.config.awaitCloseAnimation){var o=this.config.openClass;this.modal.addEventListener("animationend",(function e(){t.classList.remove(o),t.removeEventListener("animationend",e,!1)}),!1)}else t.classList.remove(this.config.openClass)}},{key:"closeModalById",value:function(e){this.modal=document.getElementById(e),this.modal&&this.closeModal()}},{key:"scrollBehaviour",value:function(e){if(this.config.disableScroll){var t=document.querySelector("body");switch(e){case"enable":Object.assign(t.style,{overflow:""});break;case"disable":Object.assign(t.style,{overflow:"hidden"})}}}},{key:"addEventListeners",value:function(){this.modal.addEventListener("touchstart",this.onClick),this.modal.addEventListener("click",this.onClick),document.addEventListener("keydown",this.onKeydown)}},{key:"removeEventListeners",value:function(){this.modal.removeEventListener("touchstart",this.onClick),this.modal.removeEventListener("click",this.onClick),document.removeEventListener("keydown",this.onKeydown)}},{key:"onClick",value:function(e){(e.target.hasAttribute(this.config.closeTrigger)||e.target.parentNode.hasAttribute(this.config.closeTrigger))&&(e.preventDefault(),e.stopPropagation(),this.closeModal(e))}},{key:"onKeydown",value:function(e){27===e.keyCode&&this.closeModal(e),9===e.keyCode&&this.retainFocus(e)}},{key:"getFocusableNodes",value:function(){var e=this.modal.querySelectorAll(i);return Array.apply(void 0,n(e))}},{key:"setFocusToFirstNode",value:function(){var e=this;if(!this.config.disableFocus){var t=this.getFocusableNodes();if(0!==t.length){var o=t.filter((function(t){return!t.hasAttribute(e.config.closeTrigger)}));o.length>0&&o[0].focus(),0===o.length&&t[0].focus()}}}},{key:"retainFocus",value:function(e){var t=this.getFocusableNodes();if(0!==t.length)if(t=t.filter((function(e){return null!==e.offsetParent})),this.modal.contains(document.activeElement)){var o=t.indexOf(document.activeElement);e.shiftKey&&0===o&&(t[t.length-1].focus(),e.preventDefault()),!e.shiftKey&&t.length>0&&o===t.length-1&&(t[0].focus(),e.preventDefault())}else t[0].focus()}}])&&function(e,t){for(var o=0;o')),!1},l=function(e,t){if(function(e){e.length<=0&&(console.warn("MicroModal: ❗Please specify at least one %c'micromodal-trigger'","background-color: #f8f9fa;color: #50596c;font-weight: bold;","data attribute."),console.warn("%cExample:","background-color: #f8f9fa;color: #50596c;font-weight: bold;",''))}(e),!t)return!0;for(var o in t)c(o);return!0},{init:function(e){var t=Object.assign({},{openTrigger:"data-micromodal-trigger"},e),o=n(document.querySelectorAll("[".concat(t.openTrigger,"]"))),r=function(e,t){var o=[];return e.forEach((function(e){var n=e.attributes[t].value;void 0===o[n]&&(o[n]=[]),o[n].push(e)})),o}(o,t.openTrigger);if(!0!==t.debugMode||!1!==l(o,r))for(var i in r){var c=r[i];t.targetModal=i,t.triggers=n(c),a=new s(t)}},show:function(e,t){var o=t||{};o.targetModal=e,!0===o.debugMode&&!1===c(e)||(a&&a.removeEventListeners(),(a=new s(o)).showModal())},close:function(e){e?a.closeModalById(e):a.closeModal()}});"undefined"!=typeof window&&(window.MicroModal=d);const u=d},511:(e,t,o)=>{o.r(t),o.d(t,{default:()=>b});var n=o(72),r=o.n(n),i=o(825),s=o.n(i),a=o(659),c=o.n(a),l=o(56),d=o.n(l),u=o(540),m=o.n(u),h=o(113),f=o.n(h),p=o(208),g={};g.styleTagTransform=f(),g.setAttributes=d(),g.insert=c().bind(null,"head"),g.domAPI=s(),g.insertStyleElement=m(),r()(p.A,g);const b=p.A&&p.A.locals?p.A.locals:void 0},72:e=>{var t=[];function o(e){for(var o=-1,n=0;n{var t={};e.exports=function(e,o){var n=function(e){if(void 0===t[e]){var o=document.querySelector(e);if(window.HTMLIFrameElement&&o instanceof window.HTMLIFrameElement)try{o=o.contentDocument.head}catch(e){o=null}t[e]=o}return t[e]}(e);if(!n)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");n.appendChild(o)}},540:e=>{e.exports=function(e){var t=document.createElement("style");return e.setAttributes(t,e.attributes),e.insert(t,e.options),t}},56:(e,t,o)=>{e.exports=function(e){var t=o.nc;t&&e.setAttribute("nonce",t)}},825:e=>{e.exports=function(e){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var t=e.insertStyleElement(e);return{update:function(o){!function(e,t,o){var n="";o.supports&&(n+="@supports (".concat(o.supports,") {")),o.media&&(n+="@media ".concat(o.media," {"));var r=void 0!==o.layer;r&&(n+="@layer".concat(o.layer.length>0?" ".concat(o.layer):""," {")),n+=o.css,r&&(n+="}"),o.media&&(n+="}"),o.supports&&(n+="}");var i=o.sourceMap;i&&"undefined"!=typeof btoa&&(n+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(i))))," */")),t.styleTagTransform(n,e,t.options)}(t,e,o)},remove:function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(t)}}}},113:e=>{e.exports=function(e,t){if(t.styleSheet)t.styleSheet.cssText=e;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(e))}}},989:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.schema=t.renderWidgetSelector=t.hideWidgetSelector=t.render=void 0;const o=e=>{document.querySelectorAll(`.storecrm-wishlistbutton-${e}`).forEach((e=>{if(e instanceof HTMLElement&&e.closest('[data-type="wishlist-button"]')){const t=new URL(location.href),o=t.searchParams.get("variant")&&t.searchParams.get("variant")||"";o&&(e.dataset.variantId=o),window.storecrm&&window.storecrm.render(!0)}}))},n={},r=(e,t=!1)=>{let o=null;return"star"===e.buttonicon?o=t?'':'':"heart"===e.buttonicon?o=t?'':'':"tag"===e.buttonicon?o='':"clip"===e.buttonicon&&(o=''),o&&(o=o.replace("viewBox",`width="${e.icon_size}" height="${e.icon_size}" style="margin-right: ${e.icon_margin}px;" viewBox`)),o};let i,s,a;t.render=({productId:e,variantId:t,id:i,button:s,buttonSettings:a,isFavorited:c=!1,preview:l=!1,hasVariantSelector:d=!1})=>{const u=Object.assign({},a);u.has_background||(u.button_width="auto",u.button_height="auto",u.button_radius=0,u.button_border_width=0,u.button_background_color="transparent",u.button_border_color="transparent",u.button_hover_border_color="transparent",u.button_hover_background_color="transparent");const m=r(u,c),h=new URL(location.href),f=parseInt(h.searchParams.get("variant")||t||"0",10)||"",p=d?"data-variant-selector":"",g=void 0!==s.dataset.noLabel;if(!n[i])if(window.navigation)window.navigation.addEventListener("navigate",(()=>{window.setTimeout((()=>o(i)),100)})),window.setTimeout((()=>o(i)),100),window.setTimeout((()=>o(i)),1e3);else{let e=location.href;window.setInterval((()=>{e!==location.href&&(e=location.href,o(i))}),1e3),window.setTimeout((()=>o(i)),100),window.setTimeout((()=>o(i)),1e3)}const b=0===Object.keys(n).length||l;console.log("isFirstRender",b,n),n[i]=!0;const v=l?"":`onclick="event.preventDefault();window.storecrm ? window.storecrm.toggleWishlist(this, ${c?"true":"false"}, ${u.is_only_member}, '${u.non_member_link}') : alert('読込中です。しばらくたってから再度お試しください。');"`,_=``;if(l){const e=document.querySelector("#storecrm-wishlistbutton-style");e&&e.remove()}return document.querySelector("#storecrm-wishlistbutton-style")||document.body.insertAdjacentHTML("beforeend",_),`\n
\n\n
\n`},t.hideWidgetSelector=()=>{i&&(i.remove(),i=void 0),document.querySelectorAll(".storecrm-variantselector-dropdown").forEach((e=>e.remove())),s=void 0,a=void 0},t.renderWidgetSelector=({button:e,productId:t,variants:o,wishlist:n,buttonSettings:c,preview:l=!1,rerender:d=!1})=>{const u=s===t&&a?a:o,m=i&&d&&s==t?i.style:void 0;if(!l&&d&&s!==t)return;if(!l&&i&&(i.remove(),i=void 0,!d))return;s=t,a=u;const h=u.map((e=>{const o=n.variants.indexOf(e.id.toString())>=0,i=r(c,o),s=l?"":`onclick="event.preventDefault();window.storecrm ? window.storecrm.toggleWishlist(this, ${o?"true":"false"}, ${c.is_only_member}, '${c.non_member_link}') : alert('読込中です。しばらくたってから再度お試しください。');"`;return`\n ${i||(o?c.button_text_remove:c.button_text)}\n ${e.title}\n `})).join("");let f="";f=l?"position: static;":m?`top: ${m.top}; left: ${m.left};`:`top: ${e.getBoundingClientRect().bottom+document.documentElement.scrollTop}px; left: ${e.getBoundingClientRect().left+document.documentElement.scrollLeft}px;`;const p=``;l||(document.body.insertAdjacentHTML("afterend",p),i=document.querySelector(".storecrm-variantselector-dropdown"));{const e=e=>{e.target&&e.target instanceof HTMLElement&&e.target.closest("[data-variant-selector]")||i&&(i.remove(),i=void 0)};document.addEventListener("click",e),document.addEventListener("resize",e)}return p},t.schema={preview:e=>{let o='
お気に入り(お気に入り前)
';return o+=(0,t.render)({productId:"TEMP_product",id:"TEMP_favorite",buttonSettings:e,button:document.createElement("div"),isFavorited:!1,preview:!0}),"variant"===e.favoriteMode&&(o+='
バリエーションモードの際の
',o+=(0,t.renderWidgetSelector)({productId:"TEMP_product",variants:[{id:"1",title:"バリエーション1"},{id:"2",title:"バリエーション2"},{id:"3",title:"バリエーション3"}],wishlist:{variants:[]},buttonSettings:e,button:document.createElement("div"),preview:!0,rerender:!1})),o+='
お気に入り(お気に入り後)
',o+=(0,t.render)({productId:"TEMP_product",id:"TEMP_favorite2",buttonSettings:e,button:document.createElement("div"),isFavorited:!0,preview:!0}),o},rows:[{type:"card",slug:"favoriteMode",nameJa:"お気に入りのモードを選んでください",nameEn:"Choose the favorite mode",default:"product",selectOptions:[{value:"product",label:"商品ごとにお気に入りをする"},{value:"variant",label:"バリエーション(商品の色やサイズなど)ごとにお気に入りをする"}],warningOnChangeJa:"設定を変更すると、既存のお気に入りデータが無効となります。データ移管をご希望の方はこの設定を保存せずに、お問い合わせください。",warningOnChangeEn:"Changing the setting will invalidate existing favorite data. Please contact us if you wish to transfer the data.",fullsize:!0},{type:"checkbox",slug:"is_only_member",nameJa:"お気に入り機能の利用を会員限定にする",nameEn:"isOnlyMember",default:!1,fullsize:!0},{type:"text",slug:"non_member_link",nameJa:"非会員がお気に入りを押した場合の遷移先URL ※空欄の場合ログイン画面に遷移します",nameEn:"nonMemberLink ※If left blank, you will be redirected to the login screen.",default:"",depends:"is_only_member",fullsize:!0},{type:"select",slug:"buttonicon",nameJa:"アイコン",nameEn:"buttonIcon",selectOptions:[{value:"star",label:"星マーク(☆)"},{value:"heart",label:"ハートマーク(♡)"},{value:"tag",label:"タグアイコン"},{value:"clip",label:"クリップアイコン"},{value:"none",label:"なし"}],default:"star"},{type:"text",slug:"button_text",nameJa:"ボタンのテキスト",nameEn:"buttonText",default:"お気に入り"},{type:"text",slug:"button_text_remove",nameJa:"ボタンのテキスト(お気に入り解除)",nameEn:"buttonTextRemove",default:"お気に入り済み"},{type:"checkbox",slug:"has_background",nameJa:"背景があるボタンにする",nameEn:"hasBackground",default:!1},{type:"range",slug:"button_width",nameJa:"ボタンの幅",nameEn:"buttonWidth",default:200,min:50,max:600,step:10,depends:"has_background"},{type:"range",slug:"button_height",nameJa:"ボタンの高さ",nameEn:"buttonHeight",default:50,min:30,max:100,step:10,depends:"has_background"},{type:"colorpicker",slug:"button_color",nameJa:"ボタンの文字色",nameEn:"buttonColor",default:"#000000"},{type:"colorpicker",slug:"icon_color",nameJa:"アイコンの文字色",nameEn:"iconColor",default:"#000000"},{type:"colorpicker",slug:"button_background_color",nameJa:"ボタンの背景色",nameEn:"buttonBackgroundColor",default:"#ffffff",depends:"has_background"},{type:"colorpicker",slug:"button_border_color",nameJa:"ボタンの線の色",nameEn:"buttonBorderColor",default:"#000000",depends:"has_background"},{type:"colorpicker",slug:"button_hover_color",nameJa:"ボタンの文字色(ホバー時)",nameEn:"buttonHoverColor",default:"#222222"},{type:"colorpicker",slug:"icon_hover_color",nameJa:"アイコンの文字色(ホバー時)",nameEn:"iconHoverColor",default:"#000000"},{type:"colorpicker",slug:"button_hover_background_color",nameJa:"ボタンの背景色(ホバー時)",nameEn:"buttonHoverBackgroundColor",default:"#dddddd",depends:"has_background"},{type:"colorpicker",slug:"button_hover_border_color",nameJa:"ボタンの線の色(ホバー時)",nameEn:"buttonHoverBorderColor",default:"#222222",depends:"has_background"},{type:"range",slug:"button_radius",nameJa:"ボタンの丸み",nameEn:"buttonRadius",default:5,min:0,max:20,step:1,depends:"has_background"},{type:"range",slug:"button_border_width",nameJa:"ボタンの線の太さ",nameEn:"buttonBorderWidth",default:0,min:0,max:10,step:1,depends:"has_background"},{type:"fontpicker",slug:"button_font",nameJa:"ボタンのフォント",nameEn:"buttonFont",default:"helvetica_n4"},{type:"range",slug:"button_fontsize",nameJa:"ボタンのフォントサイズ",nameEn:"buttonFontSize",default:16,min:10,max:30,step:1},{type:"range",slug:"button_fontweight",nameJa:"ボタンのフォントウェイト",nameEn:"buttonFontWeight",default:400,min:100,max:900,step:100},{type:"range",slug:"icon_size",nameJa:"アイコンのサイズ",nameEn:"iconSize",default:16,min:10,max:30,step:1},{type:"range",slug:"icon_margin",nameJa:"アイコンとテキストとの間隔",nameEn:"iconMargin",default:5,min:0,max:20,step:1},{type:"range",slug:"button_speed",nameJa:"ボタンのアニメーション速度",nameEn:"buttonSpeed",default:.3,min:0,max:1,step:.1},{type:"select",slug:"align",nameJa:"ボタンの配置",nameEn:"align",default:"center",selectOptions:[{value:"left",label:"左寄せ"},{value:"center",label:"中央寄せ"},{value:"right",label:"右寄せ"}]},{type:"colorpicker",slug:"popup_text_color",nameJa:"POPUPのテキスト色",nameEn:"popupTextColor",default:"#000000",checkVisible:e=>"variant"===e.favoriteMode},{type:"colorpicker",slug:"popup_background_color",nameJa:"POPUPの背景色",nameEn:"popupBackgroundColor",default:"#ffffff",checkVisible:e=>"variant"===e.favoriteMode},{type:"colorpicker",slug:"popup_icon_color",nameJa:"POPUPのアイコン色",nameEn:"popupIconColor",default:"#000000",checkVisible:e=>"variant"===e.favoriteMode},{type:"colorpicker",slug:"popup_icon_hover_color",nameJa:"POPUPのアイコン色(ホバー時)",nameEn:"popupIconHoverColor",default:"#000000",checkVisible:e=>"variant"===e.favoriteMode},{type:"range",slug:"popup_border_width",nameJa:"POPUPの線の太さ",nameEn:"popupBorderWidth",default:0,min:0,max:10,step:1,checkVisible:e=>"variant"===e.favoriteMode},{type:"colorpicker",slug:"popup_border_color",nameJa:"POPUPの線の色",nameEn:"popupBorderColor",default:"#999",checkVisible:e=>"variant"===e.favoriteMode}]}},435:function(e,t,o){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.schema=t.RestockPopupManager=void 0;const r=n(o(804));class i{constructor(e,t=!1){this.content=null,this.title=null,this.popup=null,this.button=null,this.footer=null,this.preview=!1,this.container=null,this.close=null,this.inited=!1,this.preview=t,this.config=e,this.init()}static getInstance(e,t=!1){return i.instance||(i.instance=new i(e,t)),i.instance}setParent(e){this.parent=e}renderTemplate(){document&&document.body?document.body.insertAdjacentHTML("beforeend",i.template):window.setTimeout(this.renderTemplate.bind(this),100)}init(){document&&document.body?this.runInit():window.setTimeout(this.init.bind(this),100)}runInit(){console.log("RestockPopupManager initialized"),this.inited=!0,this.preview||document.body.insertAdjacentHTML("beforeend",i.template),r.default.init(),this.popup=document.getElementById("storecrm-modal"),this.content=document.getElementById("storecrm-modal-content"),this.title=document.getElementById("storecrm-modal-title"),this.button=document.querySelector(".storecrm_modal__btn-primary"),this.footer=document.querySelector(".storecrm_modal__footer"),this.container=document.querySelector(".storecrm_modal__container"),this.container&&this.container.addEventListener("click",(e=>{e.stopPropagation()})),this.close=document.querySelector(".storecrm_modal__close"),this.close&&!this.preview&&this.close.addEventListener("click",(e=>{r.default.close("storecrm-modal")})),this.button&&!this.preview&&this.button.addEventListener("click",(()=>{this.submit()}))}render(e,t,o){var n;this.config=t;const r=(null===(n=window.storecrm_data)||void 0===n?void 0:n.customer_email)||window.localStorage.getItem("storecrm_restock_email")||"";if(this.title&&this.content&&this.popup){this.title.innerText=t.popup_title;let e=`\n
${t.popup_description}
\n
\n
${t.emailaddress}
\n
\n`.trim(),n=null;if(location.search&&location.search.includes("variant")){const e=new URL(location.href);n=e.searchParams.get("variant")}const i=o.map((e=>``)).join("");o&&Array.isArray(o)&&o.length>1?(e=e.replace("\x3c!-- select_style --\x3e",""),e=e.replace("\x3c!-- options --\x3e",i)):(e=e.replace("\x3c!-- select_style --\x3e","display:none"),e=e.replace("\x3c!-- options --\x3e","")),this.button&&(this.button.innerHTML=t.button_text),this.content.innerHTML=e,this.content.style.color=t.text_color,this.container&&(this.container.style.backgroundColor=t.background_color,this.container.style.borderRadius=`${t.button_radius}px`),this.button&&(this.button.style.backgroundColor=t.button_background_color,this.button.style.color=t.button_text_color),this.close&&(this.close.style.color=t.close_text_color)}this.resetMessage(),this.preview&&(this.success(this.config.success_text),this.failure(this.config.error_text),this.popup&&this.popup.querySelectorAll(".storecrm_modal__overlay,.storecrm_modal__close").forEach((e=>{e.addEventListener("click",(e=>{e.preventDefault(),e.stopPropagation()}))})))}resetMessage(){var e;this.footer&&(null===(e=this.footer)||void 0===e||e.querySelectorAll(".storecrm_modal_message").forEach((e=>e.remove())))}disableButton(){this.button&&(this.button.setAttribute("disabled","disabled"),this.button.innerText="Sending...")}enableButtion(){this.button&&(this.button.removeAttribute("disabled"),this.button.innerText=this.config.button_text||"Enable Restock Notification")}submit(){var e,t;if(this.preview)return;this.resetMessage(),this.disableButton();const o=null===(e=this.content)||void 0===e?void 0:e.querySelector("#storecrm_restock_email"),n=null===(t=this.content)||void 0===t?void 0:t.querySelector("#storecrm_restock_variant"),r=o?o.value:"",i=n?n.value:"";this.parent&&this.parent.storeRestock(r,i,this.success.bind(this),this.failure.bind(this))}show(e,t,o){this.inited?this.runShow(e,t,o):window.setTimeout(this.show.bind(this),100)}runShow(e,t,o){this.render(e,t,o),r.default.show("storecrm-modal")}hide(){r.default.close("storecrm-modal")}success(e){this.enableButtion();const t=document.createElement("div");t.classList.add("storecrm_modal_success","storecrm_modal_message"),t.style.color=this.config.success_text_color,t.style.backgroundColor=this.config.success_background_color,t.innerText=e,this.footer&&this.footer.appendChild(t)}failure(e){this.enableButtion();const t=document.createElement("div");t.classList.add("storecrm_modal_error","storecrm_modal_message"),t.style.color=this.config.failure_text_color,t.style.backgroundColor=this.config.failure_background_color,t.innerText=e,this.footer&&this.footer.appendChild(t)}}t.RestockPopupManager=i,i.template='';let s=null;t.schema={preview:e=>{var t;return t=()=>{i.getInstance(e,!0).show("TEMP_restockpopup",e,[])},300,clearTimeout(s),s=setTimeout(t,300),i.template},rows:[{type:"text",slug:"popup_title",nameJa:"ポップアップのタイトル",nameEn:"Popup title",default:"再入荷通知"},{type:"text",slug:"popup_description",nameJa:"POPUPの本文",nameEn:"Popup description",default:"再入荷通知をご希望の方は以下から、ご選択ください。"},{type:"text",slug:"emailaddress",nameJa:"メールアドレスフォーム名",nameEn:"Email address form name",default:"ご連絡メールアドレス"},{type:"colorpicker",slug:"background_color",nameJa:"ポップアップの背景色",nameEn:"Popup background color",default:"#ffffff"},{type:"colorpicker",slug:"text_color",nameJa:"ポップアップのテキスト色",nameEn:"Popup text color",default:"#000000"},{type:"colorpicker",slug:"close_text_color",nameJa:"閉じるボタンの色",nameEn:"Popup close button text color",default:"#000000"},{type:"colorpicker",slug:"button_background_color",nameJa:"ボタンの背景色",nameEn:"buttonHoverColor",default:"#222222"},{type:"colorpicker",slug:"button_text_color",nameJa:"ボタンのテキストカラー",nameEn:"buttonHoverBackgroundColor",default:"#dddddd"},{type:"text",slug:"button_text",nameJa:"ボタンのテキスト",nameEn:"buttonText",default:"再入荷通知を有効にする"},{type:"text",slug:"success_text",nameJa:"成功時のテキスト",nameEn:"Success text",default:"再入荷通知が登録されました。"},{type:"colorpicker",slug:"success_background_color",nameJa:"成功時の背景色",nameEn:"Success background color",default:"#F0FDF4"},{type:"colorpicker",slug:"success_text_color",nameJa:"成功時の文字色",nameEn:"Success text color",default:"#166534"},{type:"text",slug:"error_text",nameJa:"失敗時のテキスト",nameEn:"Error text",default:"再入荷通知の登録に失敗しました。しばらくたってから再度お試しください。"},{type:"text",slug:"error_text_email",nameJa:"失敗時のテキスト(メールアドレスの判定)",nameEn:"Error text",default:"メールアドレスが正しくありません。確認の上、再度ご記入ください。"},{type:"colorpicker",slug:"failure_background_color",nameJa:"エラー時の背景色",nameEn:"Success background color",default:"#FEF2F2"},{type:"colorpicker",slug:"failure_text_color",nameJa:"エラー時の文字色",nameEn:"Success text color",default:"#991B1B"},{type:"range",slug:"button_radius",nameJa:"ポップアップの丸み",nameEn:"buttonRadius",default:10,min:0,max:40,step:1}]}},898:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.schema=t.render=void 0;const o={},n=(e,t,o,n)=>{const r=e?"":"onclick=\"event.preventDefault();window.storecrm ? window.storecrm.showRestock(this) : alert('読込中です。しばらくたってから再度お試しください。');\"";return`\n\n\n
\n\n
\n `},r=(e,t)=>{document.querySelectorAll(`.storecrm-restock-${e}`).forEach((t=>{if(t instanceof HTMLElement&&t.closest('[data-type="restock-button"]')){const o=new URL(location.href),n=parseInt(o.searchParams.get("variant")||window.storecrm_data[e]&&window.storecrm_data[e].current_variant&&window.storecrm_data[e].current_variant.id,10),r=window.storecrm_data[e].product;if(!r||!r.tags||r.tags.indexOf("storecrm-restock-hidden")>=0)return console.log("StoreCRM Restock: product not found or hidden"),void(t.style.display="none");const i=window.Shopify&&window.Shopify.designMode||window.storecrm_data[e].variants.find((e=>!e.available&&e.id===n));t.style.display=i?"inline-block":"none"}}))};t.render=({productId:e,variantId:t,id:i,buttonSettings:s,isOutOfStock:a,preview:c=!1})=>{if(c)return n(!0,i,s,e);if(!o[i]){if(o[i]=!0,window.navigation)window.navigation.addEventListener("navigate",(()=>{window.setTimeout((()=>r(i)),100)})),window.setTimeout((()=>r(i)),100),window.setTimeout((()=>r(i)),1e3);else{let e=location.href;window.setInterval((()=>{e!==location.href&&(e=location.href,r(i))}),1e3),window.setTimeout((()=>r(i)),100),window.setTimeout((()=>r(i)),1e3)}return n(!1,i,s,e)}},t.schema={preview:e=>(0,t.render)({productId:"TEMP_productId",id:"TEMP_restock",buttonSettings:e,isOutOfStock:!1,preview:!0}),rows:[{type:"text",slug:"button_text",nameJa:"ボタンのテキスト",nameEn:"buttonText",default:"再入荷通知をする"},{type:"range",slug:"button_width",nameJa:"ボタンの幅",nameEn:"buttonWidth",default:200,min:50,max:600,step:10},{type:"range",slug:"button_height",nameJa:"ボタンの高さ",nameEn:"buttonHeight",default:50,min:30,max:100,step:5},{type:"colorpicker",slug:"button_color",nameJa:"ボタンの文字色",nameEn:"buttonColor",default:"#000000"},{type:"colorpicker",slug:"button_background_color",nameJa:"ボタンの背景色",nameEn:"buttonBackgroundColor",default:"#ffffff"},{type:"colorpicker",slug:"button_border_color",nameJa:"ボタンの線の色",nameEn:"buttonBorderColor",default:"#000000"},{type:"colorpicker",slug:"button_hover_color",nameJa:"ボタンの文字色(ホバー時)",nameEn:"buttonHoverColor",default:"#222222"},{type:"colorpicker",slug:"button_hover_background_color",nameJa:"ボタンの背景色(ホバー時)",nameEn:"buttonHoverBackgroundColor",default:"#dddddd"},{type:"colorpicker",slug:"button_hover_border_color",nameJa:"ボタンの線の色(ホバー時)",nameEn:"buttonHoverBorderColor",default:"#222222"},{type:"range",slug:"button_radius",nameJa:"ボタンの丸み",nameEn:"buttonRadius",default:0,min:0,max:20,step:1},{type:"range",slug:"button_border_width",nameJa:"ボタンの線の太さ",nameEn:"buttonBorderWidth",default:0,min:0,max:5,step:1},{type:"fontpicker",slug:"button_font",nameJa:"ボタンのフォント",nameEn:"buttonFont",default:"helvetica_n4"},{type:"range",slug:"button_fontsize",nameJa:"ボタンのフォントサイズ",nameEn:"buttonFontSize",default:16,min:10,max:30,step:1},{type:"range",slug:"button_fontweight",nameJa:"ボタンのフォントウェイト",nameEn:"buttonFontWeight",default:400,min:100,max:900,step:100},{type:"range",slug:"button_speed",nameJa:"ボタンのアニメーション速度",nameEn:"buttonSpeed",default:.3,min:0,max:1,step:.1},{type:"select",slug:"align",nameJa:"ボタンの配置",nameEn:"align",default:"center",selectOptions:[{value:"left",label:"左寄せ"},{value:"center",label:"中央寄せ"},{value:"right",label:"右寄せ"}]}]}},247:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StatusWidget=void 0,t.StatusWidget=class{constructor(e,t,o){this.position="beforeend",this.header=e,this.config=o,this.position=t}setParent(e){this.parent=e}render(){this.parent&&this.parent.getStatus((e=>{this.renderedWidget&&(this.renderedWidget.remove(),this.renderedWidget=void 0),this.renderedWidget=this.createWidget(e),console.log("StoreCRM rendered:",this.renderedWidget),this.header.insertAdjacentElement(this.position,this.renderedWidget)}),(e=>{console.error("StoreCRM render failed",e)})),this.parent||console.error("StoreCRM render: no parent. Abort.")}isLineVisible(e){return e.line_show_account&&(!e.line_debug_account||document.querySelector("#preview-bar-iframe")||window.Shopify.designMode)}createWidget(e){var t,o,n,r;const i=document.createElement("div");function s(e){const t=document.createElement("span");return t.classList.add("storecrm-off"),t.appendChild(document.createTextNode(e)),t}function a(e){const t=document.createElement("span");return t.classList.add("storecrm-on"),t.appendChild(document.createTextNode(e)),t}function c(e){const t=document.createElement("button");return t.classList.add("storecrm-button","storecrm-button-off"),t.appendChild(document.createTextNode(e)),t}function l(e){const t=document.createElement("button");return t.classList.add("storecrm-button","storecrm-button-on"),t.appendChild(document.createTextNode(e)),t}if(i.classList.add("storecrm-status-widget"),this.isLineVisible(e)){const n=document.createElement("div");n.appendChild(document.createTextNode("LINE設定: ")),n.appendChild(e.line?a("設定済"):s("未登録")),this.lineButton=e.line?c("解除する"):l("登録する"),n.appendChild(this.lineButton),i.appendChild(n),e.line?null===(t=this.lineButton)||void 0===t||t.addEventListener("click",this.lineUnsubscribe.bind(this)):null===(o=this.lineButton)||void 0===o||o.addEventListener("click",this.lineSubscribe.bind(this))}if(e.mail_show_account){const t=document.createElement("div");t.appendChild(document.createTextNode("メールマガジン: ")),t.appendChild(e.accepts_marketing?a("購読中"):s("未購読")),this.mailButton=e.accepts_marketing?c("購読解除する"):l("購読する"),t.appendChild(this.mailButton),i.appendChild(t),e.accepts_marketing?null===(n=this.mailButton)||void 0===n||n.addEventListener("click",this.unsubscribe.bind(this)):null===(r=this.mailButton)||void 0===r||r.addEventListener("click",this.subscribe.bind(this))}return i}lineSubscribe(){console.log("LINE購読処理をします"),this.parent&&this.parent.lineSubscribe((function(e){alert(e)}))}lineUnsubscribe(){console.log("LINE購読解除処理をします"),this.parent&&this.parent.lineUnsubscribe((function(e){alert(e)}))}subscribe(){console.log("メール購読処理をします"),this.parent&&this.parent.mailSubscribe((function(e){alert(e)}))}unsubscribe(){console.log("メール購読解除処理をします"),this.parent&&this.parent.mailUnsubscribe((function(e){alert(e)}))}}},398:function(e,t,o){var n=this&&this.__awaiter||function(e,t,o,n){return new(o||(o=Promise))((function(r,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=o(989),i=o(898),s=o(435),a=o(247);o(511),t.default=class{constructor(e){this.statusWidget=void 0,this.isTokenRefreshed=!1,this.isTokenFetching=!1,this.favoriteMode="product",this.favoriteKey="products",window.storecrm_data=window.storecrm_data||{},console.log("storeCRM initialized version 0.6.2",e),this.config=e,this.fillDefault(),this.popupManager=s.RestockPopupManager.getInstance(e.restockPopup),this.popupManager.setParent(this)}init(){this.render(),this.syncWishlist(),"/"==location.pathname&&this.fetchToken(),window.addEventListener("pageshow",(e=>{e.persisted&&this.render(!0)})),document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&this.render(!0)}))}fillDefault(){this.config.favorite=this.config.favorite||{},r.schema.rows.forEach((e=>{this.config.favorite[e.slug]=this.config.favorite[e.slug]||e.default})),this.favoriteMode=this.config.favorite.favoriteMode||"product",this.favoriteKey="product"===this.favoriteMode?"products":"variants",console.log("StoreCRM: Favorite mode",this.favoriteMode,this.favoriteKey),this.config.restock=this.config.restock||{},i.schema.rows.forEach((e=>{this.config.restock[e.slug]=this.config.restock[e.slug]||e.default})),this.config.restockPopup=this.config.restockPopup||{},s.schema.rows.forEach((e=>{this.config.restockPopup[e.slug]=this.config.restockPopup[e.slug]||e.default}))}render(e=!1){this.doRender(e),e||(window.setTimeout(this.doRender.bind(this),500),window.setTimeout(this.doRender.bind(this),2e3),window.setTimeout(this.doRender.bind(this),5e3))}doRender(e=!1){window.location.pathname.startsWith("/apps")&&window.location.pathname.endsWith("/connect")&&(this.checkConnect(),this.renderStatusWidget());const t=JSON.parse(window.localStorage.getItem("storecrm_wishlist")||"{}");t[this.favoriteKey]||(t[this.favoriteKey]=[]),document.querySelectorAll(".storecrm-button").forEach((e=>{if(e instanceof HTMLElement==0)return;if(!window.storecrm_data||!e.dataset.blockId||!(e.dataset.blockId in window.storecrm_data))return;const o=e.dataset.blockId||"";if(!o)return;const n=window.storecrm_data[e.dataset.blockId||""],s=new URL(location.href),a=s.searchParams.get("variant")&&s.searchParams.get("variant"),c=e.dataset.productId||n&&n.product&&n.product.id.toString(),l=e.dataset.variantId||a||n&&n.current_variant&&n.current_variant.id.toString(),d=void 0!==e.dataset.variantSelector,u=t&&(e.dataset.variantId||"product"==this.favoriteMode?t.products&&t.products.includes(c):t.variants&&t.variants.includes(l)),m=window.Shopify&&window.Shopify.designMode||window.storecrm_data[o]&&window.storecrm_data[o].current_variant&&!window.storecrm_data[o].current_variant.available,h="wishlist-button"===e.dataset.type?(0,r.render)({productId:c,variantId:l,id:o,button:e,buttonSettings:this.config.favorite,isFavorited:u,hasVariantSelector:d}):(0,i.render)({productId:c,variantId:l,id:o,buttonSettings:this.config.restock,isOutOfStock:m});h&&(e.innerHTML=h)})),document.querySelectorAll(".storecrm-favorite").forEach((o=>{if(o instanceof HTMLElement==0)return;if(!e&&"true"===o.dataset.isRendered)return;o.dataset.isRendered="true";const n=o.dataset.productId||"",i=o.dataset.variantId||"";if(!n)return;const s=void 0!==o.dataset.variantSelector,a=o.id||"storecrm-favorite-"+Math.random().toString(36).slice(-8);o.id||(o.id=a);const c=t&&t.products&&t.products.includes(n);o.innerHTML=(0,r.render)({productId:n,variantId:i,button:o,id:a,buttonSettings:this.config.favorite,isFavorited:c,hasVariantSelector:s})||""})),"/account"!==window.location.pathname&&"/account/"!==window.location.pathname||this.renderStatusWidget(),this.checkToken()}checkToken(){this.isTokenRefreshed||this.isTokenRefreshNeeded()&&this.fetchToken()}isTokenRefreshNeeded(){const e=parseInt(window.localStorage.getItem("storecrm_customer_id")||"0",10),t=window.localStorage.getItem("storecrm_token");let o=null;try{o=t?t.split("|")[1]:null}catch(e){}return this.isTokenRefreshed?(console.log("Token refresh needed: false (already refreshed)"),!1):e&&t&&o?window.ShopifyAnalytics&&window.ShopifyAnalytics.meta&&window.ShopifyAnalytics.meta.page&&window.ShopifyAnalytics.meta.page.customerId&&window.ShopifyAnalytics.meta.page.customerId!==e?(console.log("Token refresh needed: true (customerId mismatch)"),!0):window.ShopifyAnalytics&&window.ShopifyAnalytics.meta&&window.ShopifyAnalytics.meta.page&&window.ShopifyAnalytics.meta.page.customerId?1e3*parseFloat(o)<(new Date).getTime()?(console.log("Token refresh needed: true (expired)"),!0):(console.log("Token refresh needed: false"),!1):(console.log("Token refresh needed: true (no customerId)"),!0):(console.log("Token refresh needed: true (no token)"),!0)}fetchToken(){return n(this,void 0,void 0,(function*(){if(this.isTokenFetching)return yield new Promise((e=>{const t=setInterval((()=>{this.isTokenFetching||(clearInterval(t),e(null))}),100)})),window.localStorage.getItem("storecrm_token");this.isTokenFetching=!0;const e=window.localStorage.getItem("storecrm_customer_id"),t=yield fetch(`/apps/${this.config.appProxyName}/token?current_customer_id=${e}`),o=(yield t.text()).match(/\[data\]([\s\S]*?)\[\/data\]/);if(!o)throw this.isTokenRefreshed=!0,new Error("No data from API");const n=JSON.parse(o[1]);if(!n||!n.customer)throw this.isTokenRefreshed=!0,new Error("No data from API2");return window.localStorage.setItem("storecrm_token",n.customer.token),window.localStorage.setItem("storecrm_customer_id",n.customer.id),this.isTokenRefreshed=!0,(null==e?void 0:e.startsWith("TEMP_"))&&n.customer.id!==e&&this.syncWishlist(null,e),this.isTokenFetching=!1,n.customer.token}))}getToken(){return n(this,void 0,void 0,(function*(){return this.isTokenRefreshNeeded()&&(yield this.fetchToken()),window.localStorage.getItem("storecrm_token")}))}getCustomerId(){return n(this,void 0,void 0,(function*(){return this.isTokenRefreshNeeded()&&(yield this.fetchToken()),window.localStorage.getItem("storecrm_customer_id")}))}request(){return n(this,arguments,void 0,(function*(e="GET",t,o=null,n=!1){const r=yield this.getCustomerId(),i=yield this.getToken(),s=window.location.href;t.includes("?")?t+=`&customer_id=${r}&host=${window.location.host}&referrer=${encodeURIComponent(s)}`:t+=`?customer_id=${r}&host=${window.location.host}&referrer=${encodeURIComponent(s)}`;const a=yield fetch(t,{method:e,headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:o?JSON.stringify(o):null,credentials:n?"include":"same-origin"});if(!a.ok)throw new Error("API request failed");return a.json()}))}toggleWishlist(e,t=!1,o=!1,n=""){o?this.fetchToken().then((()=>{var o=window.localStorage.getItem("storecrm_customer_id");o&&!/^TEMP_/.test(o)?this.doToggleWishlist(e,!t).then((()=>{console.log("StoreCRM: Wishlist saved!")})).catch((e=>{console.error(e),alert("サーバエラーが発生しました! error: "+e.message+" しばらくたってから再度お試しください。")})):window.location.href=""===n?"/account/login":n})):this.doToggleWishlist(e,!t).then((()=>{console.log("StoreCRM: Wishlist saved!")})).catch((e=>{console.error(e),alert("サーバエラーが発生しました! error: "+e.message+" しばらくたってから再度お試しください。")}))}syncWishlist(){return n(this,arguments,void 0,(function*(e=null,t=void 0,o=!1){const n=e||(yield this.getWishlist(t));if(!n||!(this.favoriteKey in n))return void console.error("StoreCRM: Invalid response from favorite fetch API",n);const r=!!window.localStorage.getItem("storecrm_wishlist");return"products"===this.favoriteKey?(window.localStorage.setItem("storecrm_wishlist",JSON.stringify({products:n.products})),!r&&location.pathname.endsWith("/favorites")&&window.setTimeout((()=>location.reload()),100),{products:n.products}):(window.localStorage.setItem("storecrm_wishlist",JSON.stringify({products:n.products,variants:n.variants})),!r&&location.pathname.endsWith("/favorites")&&window.setTimeout((()=>location.reload()),100),{products:n.products,variants:n.variants})}))}getWishlist(){return n(this,arguments,void 0,(function*(e=void 0){return e?this.request("GET",`${this.config.backendUrl}/frontend/favorite/?old_customer_id=${e}&mode=${this.favoriteMode}`):this.request("GET",`${this.config.backendUrl}/frontend/favorite/?mode=${this.favoriteMode}`)}))}doToggleWishlist(e){return n(this,arguments,void 0,(function*(e,t=!1){const o=e.dataset.productId;let n=e.dataset.variantId;const i=void 0!==e.dataset.variantSelector;if(!o)return void console.error("Product ID not found");const s=e.closest(".storecrm-favorite"),a=s&&JSON.parse(s.dataset.variants||"null");if("variants"==this.favoriteKey&&a&&1===a.length&&(n=a[0].id,(0,r.hideWidgetSelector)()),"variants"==this.favoriteKey&&!n){if(i){const t=JSON.parse(window.localStorage.getItem("storecrm_wishlist")||"{}");return void(0,r.renderWidgetSelector)({button:e,productId:o,variants:a,wishlist:t,buttonSettings:this.config.favorite})}return void console.error("Variant ID not found: you need to set data-variant-id (Specify variant id) or data-variant-selector(Show variant selector) attribute.")}let c={};if(t){const e=yield this.request("POST",`${this.config.backendUrl}/frontend/favorite/`,{product_id:o,variant_id:n,mode:this.favoriteMode});c=yield this.syncWishlist(e)}else{const e=yield this.request("DELETE",`${this.config.backendUrl}/frontend/favorite/?product_id=${o}&variant_id=${n}&mode=${this.favoriteMode}`);c=yield this.syncWishlist(e)}console.log("StoreCRM response wishlist: ",c),"variants"==this.favoriteKey&&i&&(0,r.renderWidgetSelector)({button:e,productId:o,variants:a,wishlist:c,buttonSettings:this.config.favorite,rerender:!0}),this.render(!0)}))}showRestock(e){let t=window.storecrm_data[e.dataset.blockId||""].variants;t&&0!==t.length||(t=[window.storecrm_data[e.dataset.blockId||""].current_variant]),this.currentRestockBlockId=e.dataset.blockId,this.popupManager.show(this.currentRestockBlockId||"",this.config.restockPopup,t)}storeRestock(e,t,o=void 0,n=void 0){if(!e||!e.match(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|.(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/))return n&&n("メールアドレスが正しくありません。");this.doStoreRestock(t,e).then((()=>{console.log("Restock saved!"),o&&o(this.config.restockPopup.success_text)})).catch((e=>{console.error(e),n&&n(this.config.restockPopup.error_text)}))}doStoreRestock(e,t){return n(this,void 0,void 0,(function*(){return yield this.request("POST",`${this.config.backendUrl}/frontend/restock/`,{product_id:window.storecrm_data[this.currentRestockBlockId||""].product.id,variant_id:e||window.storecrm_data[this.currentRestockBlockId||""].current_variant.id,email:t})}))}renderStatusWidget(){if(this.statusWidget)return void console.log("warning: statusWidget already exists");const e=document.querySelector(".storecrm-status-widget-target"),t=document.querySelector("#shopify-section-header,.section-header,.section--header,header,.header-wrapper,.header,.header_nav"),o=document.querySelector("#MainContent, #main, .main, main");if(console.log("StoreCRM: renderStatusWidget",t,o),t||o||e){if(e)this.statusWidget=new a.StatusWidget(e,"beforeend",this.config);else if(o)this.statusWidget=new a.StatusWidget(o,"afterbegin",this.config);else{if(!t)return;this.statusWidget=new a.StatusWidget(t,"beforeend",this.config)}this.statusWidget.setParent(this),this.statusWidget.render()}else console.error("Shopify header not found. Please assign following class/id/element to header: #shopify-section-header,.section-header,.section--header,header,.header_nav")}getStatus(e,t){this.doGetStatus().then((t=>{e(t)})).catch((e=>{console.error(e),t("サーバエラーが発生しました。")}))}doGetStatus(){return n(this,void 0,void 0,(function*(){return yield this.request("GET",`${this.config.backendUrl}/frontend/status`)}))}lineSubscribe(e=void 0){this.doLineSubscribe()}doLineSubscribe(){return n(this,void 0,void 0,(function*(){const e=yield this.getCustomerId(),t=yield this.getToken(),o=window.location.href;location.href=`${this.config.backendUrl}/frontend/line/connect?token=${t}&customer_id=${e}&host=${window.location.host}&referrer=${encodeURIComponent(o)}`}))}lineUnsubscribe(e=void 0){this.doLineUnsubscribe().then((e=>{location.href=location.pathname+"?line_disconnect=1"})).catch((t=>{console.error(t),e?e("LINEの通知解除に失敗しました。"):alert("LINEの通知解除に失敗し���した。")}))}doLineUnsubscribe(){return n(this,void 0,void 0,(function*(){return yield this.request("POST",`${this.config.backendUrl}/frontend/line/disconnect`)}))}mailSubscribe(){this.doMailSubscribe().then((e=>{console.log("メールマガジンの購読に成功しました。",e),this.statusWidget&&this.statusWidget.render()})).catch((e=>{console.error(e),alert("メールマガジンの購読に失敗しました。")}))}doMailSubscribe(){return n(this,void 0,void 0,(function*(){return yield this.request("POST",`${this.config.backendUrl}/frontend/email/subscribe`)}))}mailUnsubscribe(){this.doMailUnsubscribe().then((e=>{console.log("メールマガジンの解除に成功しました。",e);const t=document.getElementById("storecrm_message");t&&(t.innerHTML="メールマガジンの解除に成功しました。"),this.statusWidget&&this.statusWidget.render()})).catch((e=>{console.error(e);const t=document.getElementById("storecrm_message");t&&(t.innerHTML="メールマガジンの解除に失敗しました。","API"in e.toString()&&(t.innerHTML+='
解除を進めるにはログインをしてください。')),alert("メールマガジンの解除に失敗しました。")}))}doMailUnsubscribe(){return n(this,void 0,void 0,(function*(){return yield this.request("POST",`${this.config.backendUrl}/frontend/email/unsubscribe`)}))}birthdaySet(){}checkConnect(){const e=new URLSearchParams(window.location.search),t=e.get("storecrm"),o=window.localStorage.getItem("storecrm_customer_id");if(o&&!o.startsWith("TEMP_")){if("line_connect"===t?this.lineSubscribe((function(){console.log("LINEの通知登録に失敗しました。")})):"line_disconnect"===t?this.lineUnsubscribe():"email_subscribe"===t?this.mailSubscribe():"email_unsubscribe"===t?this.mailUnsubscribe():"birthday_set"===t&&this.birthdaySet(),e.get("line_disconnect")){const e=document.querySelector("#storecrm_message");e&&(e.innerHTML="LINEの通知を解除しました。")}if(e.get("line_connect")){const e=document.querySelector("#storecrm_message");e&&(e.innerHTML="LINEを連携しました。")}}else{const e=document.getElementById("storecrm_message");e&&(e.innerHTML='設定変更に失敗しました。
進めるにはログインをしてください。')}}}},927:function(e,t,o){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=n(o(398));window.storecrm=new r.default(window.storecrm_config||{}),window.storecrm.init()}},t={};function o(n){var r=t[n];if(void 0!==r)return r.exports;var i=t[n]={id:n,exports:{}};return e[n].call(i.exports,i,i.exports,o),i.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.nc=void 0,o(927)})();