var juniperTikTokFeeApp=(function instafeedLoad(){const t="tiktok.nfcube.com",e="cdn.nfcube.com",n="juniper",i="3.0.2",o=!1;var s=function(){function o(e){this.options={target:"mintty-tiktok-feed",forceUpdate:!1,locale:"en",picturesLoaded:0,picturesNeeded:0,admin:window.location.hostname===t},Object.assign(this.options,e),this.options.admin||this._loadCss()}return o.prototype.run=function(){var e=document.getElementById(this.options.target);if(0===e.clientWidth&&parseInt(this.options.autoLayout)>0)return this._checkClientWidth(this,e),!1;parseInt(this.options.autoLayout)>0?(this.options.picturesNeeded=this.options.rows*this._getAutoColumns(e.clientWidth),this._isMobileDevice()&&this._validateCharge(this.options.charge)&&(this.options.picturesNeeded=this.options.rowsMobile*this._getAutoColumns(e.clientWidth))):this._isMobileDevice()&&this._validateCharge(this.options.charge)?this.options.picturesNeeded=this.options.rowsMobile*this.options.columnsMobile:this.options.picturesNeeded=this.options.rows*this.options.columns;var n="";this.options.admin&&(n="
Hang on we are processing your feed ☕"),e.innerHTML="loading bar"+n;var i=this;const o=new XMLHttpRequest;return o.open("GET",this._buildUrl(),!0),o.onload=function(){i.parse(JSON.parse(o.responseText))},o.onerror=function(){console.log("Network error")},o.send(),!0},o.prototype.parse=function(e){var i,o,s,r,a,l,c;if(c=document.getElementById(this.options.target),"object"!=typeof e)throw new Error("Invalid JSON response");const{meta:{code:d,error_message:p}}=e,u=parseInt(d,10);if(c.innerHTML="",204===u||200!==u)return this.options.admin&&(c.innerHTML=204===u?p:`⚠️ ${p}`,"function"==typeof this.options.error&&this.options.error.call(this,e)),!1;if(null!==this.options.success&&"function"==typeof this.options.success&&this.options.success.call(this,e),"undefined"==typeof document||null===document)return!1;a=e.data,i="";var h="standard_resolution",m=parseInt(100-this.options.space),g=0,f=0;f=g=parseInt(this.options.autoLayout)>0?parseFloat(100/this._getAutoColumns(c.clientWidth)).toFixed(6):this._isMobileDevice()&&this._validateCharge(this.options.charge)?parseFloat(100/this.options.columnsMobile).toFixed(6):parseFloat(100/this.options.columns).toFixed(6),parseInt(this.options.layout)>=2&&(f=parseFloat(g*(16/9)).toFixed(6));var v=`
{{icon}}
`,y=`
${v}
`,w="
{{containerContent}}"+y+"
";for(1===parseInt(this.options.openIg)?w=""+w+"":3===parseInt(this.options.openIg)&&(w=""+w+""),o=0,l=a.length;o","video"===s.type&&"batatas.myshopify.com"===this.options.shopOrigin?containerContent='':containerContent="{{captionAlt}}",this.options.picturesLoaded++;var _=1===this.options.picturesLoaded?this.options.picturesNeeded:this.options.picturesLoaded-1,k=this.options.picturesLoaded===this.options.picturesNeeded?1:this.options.picturesLoaded+1;if(i+=this._makeTemplate(w,{model:s,id:this.options.picturesLoaded,fullId:s.id,minusId:_,plusId:k,link:s.link,embedLink:s.embed_link,image:r.url,icon:this._generateIcon(s),username:s.user.username,fullName:s.user.full_name,userPicture:5===this.options.apiVersion?s.user.profile_picture:"https://"+t+"/assets/img/logo-instagram-transparent.png",containerContent:containerContent,imageFullHtml:imageFullHtml,taggedProduct:"",date:this._timeConverter(s.created_time),caption:this._escapeHtml(this._getObjectProperty(s,"caption.text")),captionAlt:this._escapeHtml(this._getObjectProperty(s,"caption.text").substring(0,100)),comments:this._shortenLargeNumber(s.comments.count,1),location:this._getObjectProperty(s,"location.name")}),this.options.picturesLoaded>=this.options.picturesNeeded||e.data.length===this.options.picturesLoaded)break}c.innerHTML="";var I="";if(this._validateCharge(this.options.charge)&&parseInt(this.options.showFollowers)>0&&(I="

"+this._shortenLargeNumber(b)+" followers"),this.options.title.length>0||"undefined"!=typeof juniperLocalTitle&&juniperLocalTitle.length>0){let t=document.createElement("h2");const e="undefined"!=typeof juniperLocalTitle&&juniperLocalTitle.length>0?juniperLocalTitle:this.options.title;t.innerHTML=e+I,c.insertBefore(t,c.firstChild)}if(1===parseInt(this.options.layout)||3===parseInt(this.options.layout))window.juniperSliderNumVisibleImages=parseInt(Math.round(100/g)),window.juniperSliderTotalImages=this.options.picturesLoaded,c.innerHTML+=this._generateCarouselHTML(a,this._escapeHtml),this._setNumVisibleImages(),c.addEventListener("swiped-left",(t=>{(window.lastSwipeEventJuniper||{}).target!==t.target&&(juniperSliderMove(1,this.options.feedId),window.lastSwipeEventJuniper=t)})),c.addEventListener("swiped-right",(t=>{(window.lastSwipeEventJuniper||{}).target!==t.target&&(juniperSliderMove(-1,this.options.feedId),window.lastSwipeEventJuniper=t)}));else{const t=document.createDocumentFragment();this._appendHtmlToParent(i,t),c.appendChild(t)}if(3===parseInt(this.options.openIg)){null===document.getElementById(n+"-tiktok-iframe-container")&&this._addPopupDom();const t=[];document.querySelectorAll("."+n+"-video").forEach((e=>{t.push(e.dataset.videoUrl)}));let e=0;document.querySelectorAll("."+n+"-video").forEach((i=>{i.addEventListener("click",(()=>{e=t.indexOf(i.dataset.videoUrl),this._updateIframeSrc(t,e);document.getElementById(n+"-tiktok-popup").style.display="block",this._toggleBodyScrolling(!1)}))}));const i=document.getElementById(n+"-tiktok-prev-video"),o=document.getElementById(n+"-tiktok-next-video"),s=document.getElementById(n+"-tiktok-popup-close");i&&i.addEventListener("click",(()=>{e=(e-1+t.length)%t.length,this._updateIframeSrc(t,e)})),o&&o.addEventListener("click",(()=>{e=(e+1)%t.length,this._updateIframeSrc(t,e)})),s&&s.addEventListener("click",(()=>{document.getElementById(n+"-tiktok-popup").style.display="none",this._toggleBodyScrolling(!0);document.getElementById(n+"-tiktok-iframe-container").innerHTML=""}))}return this._enableLazyLoading(),!0},o.prototype._toggleBodyScrolling=function(t){document.body.style.overflow=t?"":"hidden"},o.prototype._updateIframeSrc=function(t,e){const i=t[e],o=document.createElement("iframe");o.src=i+"&mute=1",o.width="450",o.height=`${Math.min(window.innerHeight-100,800)}`,o.allow="autoplay",o.setAttribute("playsinline","");const s=document.getElementById(n+"-tiktok-iframe-container");s.innerHTML="",s.appendChild(o)},o.prototype._addPopupDom=function(){const t=`\n \n `,e=document.createElement("template");e.innerHTML=t.trim();const i=document.body.lastChild;document.body.insertBefore(e.content.firstChild,i)},o.prototype._appendHtmlToParent=function(t,e=document.body,n=null){const i=document.createElement("template");for(i.innerHTML=t;i.content.firstChild;)e.insertBefore(i.content.firstChild,n)},o.prototype._setNumVisibleImages=function(){const t=document.getElementById(this.options.target).offsetWidth,e=t/juniperSliderNumVisibleImages,i=3===parseInt(this.options.layout)?parseFloat(e*(16/9)).toFixed(6):e;document.querySelectorAll("."+n+"-new-carousel-item").forEach((t=>{t.style.width=`${e}px`,t.style.height=`${i}px`}));const o=document.querySelector("."+n+"-new-carousel-container");o.style.width=`${t}px`,o.style.height=`${i}px`,window.juniperSliderStepSize=juniperSliderNumVisibleImages*e},o.prototype._generateCarouselHTML=function(t){let e="",i=0;for(let n of t)i++,e+=this._imageTemplate(n,i);let o="";return i>juniperSliderNumVisibleImages&&(o=`\n \n \n `),`\n `},o.prototype._imageTemplate=function(e,i){let o=e.images.standard_resolution,s=parseInt(100-this.options.space,10),r=this._escapeHtml(e.caption.text).substring(0,64),a="";const l=this._generateIcon(e);a=`\n Instagram post with the caption: '${r}...'\n `;const c=this._generatePostUrl(a,e,i);return`\n `},o.prototype._generatePostUrl=function(t,e,n){const i=parseInt(this.options.openIg,10);return 1===i?`${t}`:3===i?`${t}`:t},o.prototype._generateIcon=function(e){if(parseInt(this.options.likes)>0&&this._validateCharge(this.options.charge))return`\n ${this._shortenLargeNumber(e.likes.count,1)}`;{const n="video"===e.type?"video-icon.png":"instagram-icon-v2.svg";return`hover icon`}},o.prototype._buildUrl=function(){const{forceUpdate:e,apiVersion:n,charge:i,picturesNeeded:o,shopOrigin:s,feedId:r,hash:a,locale:l}=this.options;return`https://${t}/api/v${n}?charge=${i}&fu=${e?1:0}&limit=${o}&account=${s}&fid=${r}&hash=${a}&locale=${l}`},o.prototype._makeTemplate=function(t,e){return t.replace(/{{([\w[\].]+)}}/g,((t,n)=>{const i=this._getObjectProperty(e,n);return null!==i?i:""}))},o.prototype._getObjectProperty=function(t,e){const n=(e=e.replace(/\[(\w+)\]/g,".$1")).split(".");for(const e of n){if(null===t||!(e in t))return null;t=t[e]}return t},o.prototype._validateCharge=function(t){return parseInt(t)>0},o.prototype._getAutoColumns=function(t){return t<480?2:t<768?3:t<1024?4:t<=1200?5:6},o.prototype._escapeHtml=function(t){return t&&(t=t.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")),t},o.prototype._shortenLargeNumber=function(t,e){const n=["k","M","G","T","P","E","Z","Y"];for(let i=n.length-1;i>=0;i--){const o=Math.pow(1e3,i+1);if(t<=-o||t>=o)return+(t/o).toFixed(e)+n[i]}return t},o.prototype._timeConverter=function(t){return new Date(1e3*t).toLocaleDateString(navigator.language,{month:"long",day:"numeric"})},o.prototype._isMobileDevice=function(t=!1){return!(!this.options.admin||this.options.desktopPreview||!1!==t)||(!this.options.admin||!this.options.desktopPreview||!1!==t)&&window.matchMedia("only screen and (max-width: 768px)").matches},o.prototype._checkClientWidth=function(t,e){0===e.clientWidth?setTimeout((()=>{t._checkClientWidth(t,e)}),100):t.run()},o.prototype._loadCss=function(){if(document.currentScript&&!document.currentScript.src.includes(e)&&!document.currentScript.src.includes(t))return!1;const n=document.createElement("link");n.href=`https://${t}/cdn/tiktok-${i}.css`,n.type="text/css",n.rel="stylesheet",n.media="screen,print",document.head.appendChild(n)},o.prototype._enableLazyLoading=function(){const t=document.querySelectorAll(".js-lazy-image"),e={rootMargin:"100px 0px",threshold:.01};let n,i=t.length;function o(t){const e=t.dataset.src;var n;if(e.includes("https://"))return(n=e,new Promise(((t,e)=>{const i=new Image;i.src=n,i.onload=t,i.onerror=e}))).then((()=>{!function(t,e){t.classList.add("js-lazy-image--handled"),t.src=e}(t,e)})).catch((t=>{console.log(t)}))}"IntersectionObserver"in window&&t.length?(n=new IntersectionObserver((function(t){0===i&&n.disconnect();t.forEach((t=>{t.intersectionRatio>0&&(i--,n.unobserve(t.target),o(t.target))}))}),e),t.forEach((t=>{t.classList.contains("js-lazy-image--handled")||n.observe(t)}))):function(t){t.forEach((t=>o(t)))}(t)},o}();!function(t,e){t.Instafeed=s}(this),window.juniperSlidersState={},window.juniperSliderMove=(t,e=0)=>{juniperSlidersState[e]||(juniperSlidersState[e]={currentTransform:0,minTransform:0});const i=juniperSlidersState[e],o=Math.ceil(juniperSliderTotalImages/juniperSliderNumVisibleImages)-1,s=juniperSliderStepSize*o;i.currentTransform+=t*-juniperSliderStepSize,i.currentTransform<-s&&(i.currentTransform=i.minTransform),i.currentTransform>i.minTransform&&(i.currentTransform=-s),document.querySelector(`.${n}-new-carousel-wrapper[data-feed-id="${e}"]`).style.transform=`translateX(${i.currentTransform}px)`},function(t,e){"use strict";"function"!=typeof t.CustomEvent&&(t.CustomEvent=function(t,n){n=n||{bubbles:!1,cancelable:!1,detail:void 0};var i=e.createEvent("CustomEvent");return i.initCustomEvent(t,n.bubbles,n.cancelable,n.detail),i},t.CustomEvent.prototype=t.Event.prototype),e.addEventListener("touchstart",(function(t){"true"!==t.target.getAttribute("data-swipe-ignore")&&(a=t.target,r=Date.now(),n=t.touches[0].clientX,i=t.touches[0].clientY,o=0,s=0)}),!1),e.addEventListener("touchmove",(function(t){if(n&&i){var e=t.touches[0].clientX,r=t.touches[0].clientY;o=n-e,s=i-r}}),!1),e.addEventListener("touchend",(function(t){if(a===t.target){var e=parseInt(l(a,"data-swipe-threshold","20"),10),c=parseInt(l(a,"data-swipe-timeout","500"),10),d=Date.now()-r,p="",u=t.changedTouches||t.touches||[];if(Math.abs(o)>Math.abs(s)?Math.abs(o)>e&&d0?"swiped-left":"swiped-right"):Math.abs(s)>e&&d0?"swiped-up":"swiped-down"),""!==p){var h={dir:p.replace(/swiped-/,""),xStart:parseInt(n,10),xEnd:parseInt((u[0]||{}).clientX||-1,10),yStart:parseInt(i,10),yEnd:parseInt((u[0]||{}).clientY||-1,10)};a.dispatchEvent(new CustomEvent("swiped",{bubbles:!0,cancelable:!0,detail:h})),a.dispatchEvent(new CustomEvent(p,{bubbles:!0,cancelable:!0,detail:h}))}n=null,i=null,r=null}}),!1);var n=null,i=null,o=null,s=null,r=null,a=null;function l(t,n,i){for(;t&&t!==e.documentElement;){var o=t.getAttribute(n);if(o)return o;t=t.parentNode}return i}}(window,document);if(document.getElementById('mintty-tiktok-feed')!==null){var feed=new Instafeed({"account":"SILK PERFUMES","hash":"53545db6d633dffb7f9f290c7a7963ca","apiVersion":6,"shopOrigin":"silkperfumes.myshopify.com","title":"Tendencias en TikTok","openIg":3,"space":0,"likes":1,"corners":0,"showFollowers":0,"layout":3,"filter":"","public":0,"columns":5,"columnsMobile":5,"rows":5,"rowsMobile":5,"autoLayout":0,"feedId":0,"charge":0});feed.run();}return instafeedLoad;})();window.addEventListener('resize',((lastWidth)=>()=>window.innerWidth!==lastWidth&&(lastWidth=window.innerWidth,juniperTikTokFeeApp()))(window.innerWidth));document.addEventListener('shopify:section:load',()=>{juniperTikTokFeeApp()});