if (typeof barsJS!=="object"){barsJS = {}} if (typeof barsJS.gtDS!=="function"){ barsJS.gtDS=function(a){try{return document.querySelector('[data-byapps-item="'+a+'"]').getAttribute("data-byapps-item-value")||document.querySelector('[data-byapps-item="'+a+'"]').textContent;}catch(e){return "";}} } if (typeof barsJS.gtCK!=="function") { barsJS.gtCK=function(k){var v=document.cookie.match('(^|;) ?'+k+'=([^;]*)(;|$)');return v?decodeURIComponent(v[2]):""} } if (typeof barsJS.gtQP!=="function") { barsJS.gtQP=function(a,b){var r='';a.toString().replace(/[?&]+([^=&]+)=([^&]*)/gi, function(str, k, v){if(k==b) r=v;});return r.split('#')[0];} } function gtagscript(e,t,i,r,n){"use strict";let o=e.location.href;e.location.host,t.referrer;let c=t.querySelector('script[src*="id='+i+'"]'),l={},d="",a=!1;var p=!0;try{localStorage.setItem("WACK_test","yes"),localStorage.removeItem("WACK_test")}catch(s){p=!1}let u=function(e,i,r,n){let o;r&&(o=new Date).setTime(o.getTime()+1e3*r),t.cookie=e+"="+encodeURIComponent(i)+(r?";expires="+o.toUTCString():"")+";path="+(n||"/;")},f=function(e,i){let r=t.cookie.match("(^|;) ?"+e+"=([^;]*)(;|$)");return r?decodeURIComponent(r[2]):""},g=function(e){try{return t.querySelector(e).getAttribute("content")}catch(i){return""}},$=function(e,t){var i="";return e.replace(/[?&]+([^=&]+)=([^&]*)/gi,function(e,r,n){r==t&&(i=n)}),i.split("#")[0]},y=function(e,t){let i=t?"":{};return e.toString().replace(/[?&]+([^=&]+)=([^&]*)/gi,(e,r,n)=>{t?t==r&&(i=n.split("#")[0]):i[r]=n.split("#")[0]}),i||""},m=function(e,t,i){return new Promise((r,n)=>{(()=>{if(void 0===t&&(t="tag"),void 0===i&&(i=0),"text"==t&&document.querySelector("html").innerHTML.indexOf(e)>-1){r(!0);return}if("tag"==t){let n=document.querySelectorAll(e);try{if(n.length>0){r(!0);return}}catch(o){}}if("js"==t)try{if(e.indexOf(".")>0){let c=e.split(".");if((c.length=void 0!==window[c[0]][c[1]])||(c.length=void 0!==window[c[0]][c[1]][c[2]])||(c.length=void 0!==window[c[0]][c[1]][c[2]][c[3]])||(c.length=void 0!==window[c[0]][c[1]][c[2]][c[3]][c[4]])){r(!0);return}}else if(void 0!==window[e]){r(!0);return}}catch(l){}})()})},h=function(e){let t="",i={},r=0,n=0,o="",c=[];switch(e){case"godo1":null!==g('[name="order:price"]')&&(r=null!=(r=g('[name="order:price"]'))?r.replace(/[^0-9]/g,""):0),o=y(window.location.href).orderNo,n=r,""!=o&&n>0&&(i={total_price:n,order_id:o,shipping:0,items:c});break;case"godo2":m(t=".order_end_box .prc")&&(r=0!=(r=null!=(r=document.querySelector(t))?r.innerText:0)?r.replace(/[^0-9]/g,""):0),o=y(window.location.href).orderNo,n=r,""!=o&&n>0&&(i={total_price:n,order_id:o,shipping:0,items:c});break;case"makeshop":m(t="#order-complete .complete-price em")&&(null==(r=document.querySelector(t))&&(r=document.querySelector("#order-complete .pay_info #mk_totalprice")),r=0!=(r=null==r?0:r.innerText)?r.replace(/[^0-9]/g,""):0),n=r,o=f("order_flag");let l=document.querySelectorAll(".product_info table .title a");null!==l&&l.forEach(e=>{c.push(e.href.replace(/\D/g,""))}),""!=o&&n>0&&(i={total_price:n,order_id:o,shipping:0,items:c});break;case"prosell":void 0!==SHOP.ORDER_OPTIONS&&"{}"!==JSON.stringify(SHOP.ORDER_OPTIONS)&&(o=SHOP.ORDER_OPTIONS.ono,n=SHOP.ORDER_OPTIONS.order_amount_price,c=SHOP.ORDER_OPTIONS.getItems),""!=o&&n>0&&(i={total_price:n,order_id:o,shipping:0,items:c})}return i},v=function(e,r,o){let c=t.createElement("script");c.type="text/javascript",c.async=!0,c.src="https://www.googletagmanager.com/gtag/js?id="+i,c.onload=function(){window.dataLayer=window.dataLayer||[],window.byapps_gtag=function(){dataLayer.push(arguments)},byapps_gtag("js",new Date),byapps_gtag("config",i),e&&r&&byapps_gtag(e,r,o),n&&r&&console.log(r,o)},t.body.appendChild(c)},O=function(e,t,i){c&&"function"==typeof gtag?(e&&t&>ag(e,t,i),n&&t&&console.log(t,i)):"function"==typeof byapps_gtag?(e&&t&&byapps_gtag(e,t,i),n&&t&&console.log(t,i)):v(e,t,i)},R=function(){let e="",t="",i="",r="",n="";if(e||(e="undefined"!=typeof iProductNo?iProductNo:e?g('[name="order:no"]'):barsJS.gtDS("pno")),t||(t="undefined"!=typeof product_name?product_name:g('[property="og:title"]'))||(t=barsJS.gtDS("title")),i||(i="undefined"!=typeof iCategoryNo?iCategoryNo:barsJS.gtDS("cate")),!r){if("undefined"!=typeof iProductPrice)r=iProductPrice;else if("undefined"!=typeof productPrice)r=productPrice;else{(r=g('[property="product:price:amount"]'))||(r=g('[name="order:price"]')),r||(r=barsJS.gtDS("price"));let o=g('[property="product:sale_price:amount"]');o||(o=barsJS.gtDS("sprice")),r&&o&&r>o&&(r=o)}}if(n||(n=g('[property="product:price:currency"]')),"undefined"!=typeof EC_SDE_SHOP_NUM&&void 0!==window.sessionStorage&&(!e||!t||!i)){let c=window.sessionStorage.getItem("localRecentProduct"+EC_SDE_SHOP_NUM);if(null!==c){let l=JSON.parse(c);!e&&l[0].iProductNo&&(e=l[0].iProductNo),!t&&l[0].sProductName&&(t=l[0].sProductName),!i&&l[0].sParam&&(i=$(l[0].sParam,"cate_no"))}}return{items:[{id:e,name:t,list_name:"",brand:"",category:i,price:r,currency:n}]}},S=function(){let e=t.querySelector("#NPAY_BUY_LINK");e&&e.addEventListener("click",function(e){l.NPAY_BUY()})},b=function(e,t,i,r){var n=location.protocol+"//openapi2.byapps.co.kr/stat/"+e+"/",o={};o.app_id=t,o.uuid=i,o.type=navigator.userAgent.match("Byapps")?"A":"W",o.order_data=r,fetch(n,{method:"POST",mode:"no-cors",headers:{"Content-Type":"multipart/form-data; charset=UTF-8"},body:JSON.stringify(o)}).then(e=>console.log(e)).catch(e=>console.log(e))},D=function(e){let t=f("bars_uuid"),i="bagstay";("twee"==i||"liberomall"==i)&&b("sales",i,t,e)};l.PRODUCT_DETAIL=function(){if("function"==typeof e.basket_result_action){let t=e.basket_result_action;e.basket_result_action=function(){return l.ADD_TO_CART(),t.apply(t,arguments)}}if("function"==typeof e.add_wishlist_result){let i=e.add_wishlist_result;e.add_wishlist_result=function(){return l.ADD_TO_WISHLIST(),i.apply(i,arguments)}}d||(d=R()),-1==o.indexOf("layer_option.html")&&O("event","view_item",d),S()},l.view=function(){d||(d=R()),O("event","view_item",d)},l.ORDER_BASKET=function(){var e="savedItem";let t=p?decodeURIComponent(localStorage.getItem(e)||""):f(e,void 0);if(t){let i=JSON.parse(t),r=[];if("undefined"!=typeof aBasketProductData&&aBasketProductData.length>0&&i.length>aBasketProductData.length)for(let n=0;n0){var c,l="savedItem";c=JSON.stringify(r),p?localStorage.setItem(l,encodeURIComponent(c)):u(l,c,void 0,void 0)}}},l.ADD_TO_CART=function(){d||(d=R()),"undefined"!=typeof iEventQuantity&&d.items&&(d.items[0].quantity=iEventQuantity),a||O("event","add_to_cart",d)},l.ADD_TO_WISHLIST=function(){d||(d=R()),O("event","add_to_wishlist",d)},l.ORDER_ORDERFORM=function(){let e=t.querySelector("#total_price").value,i=0,r=[];if(e||"object"!=typeof EC_ORDER_FORM_ASSIGN_DATA||void 0===EC_ORDER_FORM_ASSIGN_DATA.r_total_price||(e=EC_ORDER_FORM_ASSIGN_DATA.r_total_price),"object"==typeof EC_ORDER_FORM_ASSIGN_DATA&&void 0!==EC_ORDER_FORM_ASSIGN_DATA.ship_fee&&(i=EC_ORDER_FORM_ASSIGN_DATA.ship_fee),"undefined"!=typeof aBasketProductOrderData&&aBasketProductOrderData.length>0)for(let n=0;n0)){let n=EC_FRONT_EXTERNAL_SCRIPT_VARIABLE_DATA.order_product;for(let c=0;c0&&(e=n.total_price,t=n.order_id,i=n.shipping,r=n.items),t||(t=$(o,"order_id")),O("event","purchase",{value:e,currency:"KRW",transaction_id:t,shipping:i,items:r});D({amount:e,order_id:t,shipping:i,items:r})},l.ordered=function(){let e=0,t="",i=[];if(barsJS.gtCK("bars_items")){let r=barsJS.gtCK("bars_items");if(r){let n=r.split("|");for(let c=0;c