LeeepCite=window.LeeepCite||{domain:"https://cite.leeep.jp",apiBase:"https://cite.leeep.jp/v2",site_id:"",pageProductId:"",tagStyle:{},Website:null,initingTagIds:[],abId:null,patternId:null,patternTagIds:[],uid:"",init:async e=>{var o,s,d,r;if(e.uid&&(LeeepCite.uid=(o=e.uid)==null?void 0:o.toString()),!(e!=null&&e.site_id)&&!(e!=null&&e.tag_id)){console.log("LEEEPタグエラー：パラメータが不足しています");return}if(e.tag_id){await LeeepCite.initByTagId(e.tag_id,e);return}e.product_id&&(LeeepCite.pageProductId=e.product_id),e.url=location.origin+location.pathname;const i=await fetch(`${LeeepCite.apiBase}/onetag?site_id=${e.site_id}&url=${e.url}`);if(i.status>=400){const l=document.querySelectorAll(".leeep-cite-section, .parte-cite-section");l.length&&l.forEach(n=>n.style.setProperty("display","none","important"));return}const t=await i.json();if(t.tag_ids){const l=t.tag_ids.map(n=>LeeepCite.initByTagId(n,{...e}));await Promise.all(l)}if(t.ab_id){const l=t.ab_id,n=await fetch(`${LeeepCite.apiBase}/ab/${l}`);if(n.status>=400){(s=document.querySelectorAll(".leeep-cite-section, .parte-cite-section"))==null||s.forEach(y=>y.style.setProperty("display","none","important"));return}const c=await n.json(),a=`Leeep.AB.${l}.Pattern`;if(!localStorage.getItem(a)){let y=Math.random()*c.total_weight;for(const _ of c.patterns)if(y-=_.weight,y<0){localStorage.setItem(a,_.pattern_id);break}}const u=c.patterns.find(y=>y.pattern_id===localStorage.getItem(a));LeeepCite.abId=l,LeeepCite.patternId=u.pattern_id,LeeepCite.patternTagIds=u.tag_ids,e.ab_id=l,e.pattern_id=u.pattern_id,(d=u.tag_ids)==null||d.forEach(y=>LeeepCite.initByTagId(y,e)),LeeepCite.isTrackable("init-selectABPattern")&&ParteTracking.selectABPattern({site_id:e.site_id,ab_id:l,pattern_id:u.pattern_id,user:{id:e.uid}});return}if(!t.tag_ids){LeeepCite.site_id=e.site_id,e.count=e.count||8,e.style=e.style||{},e.style.list_column=((r=e.style)==null?void 0:r.list_column)||4,e.style.list_column<1&&(e.style.list_column=1),e.style.list_column>6&&(e.style.list_column=6);const l=document.querySelector("#leeep-cite-embed-container, #parte-cite-embed-container");if(!l)return;const n=new URLSearchParams;if(n.set("site_id",e.site_id),n.set("count",e.count),e.sources&&n.set("sources",e.sources.join(",")),e.content_type&&n.set("content_type",e.content_type),e.brands&&n.set("brands",e.brands.join(",")),e.hashtag_id&&n.set("hashtag_id",e.hashtag_id),e.product_id&&n.set("product_id",e.product_id),e.mentioned_ig_user_id&&n.set("mentioned_ig_user_id",e.mentioned_ig_user_id),e.own_ig_user_id&&n.set("own_ig_user_id",e.own_ig_user_id),e.post_user_id&&n.set("post_user_id",e.post_user_id),e.min_height&&n.set("min_height",e.min_height),e.max_height&&n.set("max_height",e.max_height),e.sort&&n.set("sort",e.sort),e!=null&&e.style){const c=e.style;c.list_style&&n.set("style.list_style",c.list_style),c.list_scroll&&n.set("style.list_scroll",c.list_scroll),c.list_column&&n.set("style.list_column",c.list_column),c.list_column_mobile&&n.set("style.list_column_mobile",c.list_column_mobile),c.list_video&&n.set("style.list_video",c.list_video),c.list_user&&n.set("style.list_user",c.list_user),c.list_caption&&n.set("style.list_caption",c.list_caption),c.list_date&&n.set("style.list_date",c.list_date),c.list_see_more&&n.set("style.list_see_more",c.list_see_more),c.detail_item&&n.set("style.detail_item",c.detail_item),c.detail_caption&&n.set("style.detail_caption",c.detail_caption),c.detail_date&&n.set("style.detail_date",c.detail_date),c.by_leeep&&n.set("style.by_leeep",c.by_leeep)}LeeepCite.appendListIframe(l,n)}},embeddedElemId:e=>`leeep-embedded-${e}`,initByTagId:async(e,i)=>{var u,y,_,h,f,b;if(document.querySelector("#"+LeeepCite.embeddedElemId(e))||LeeepCite.initingTagIds.includes(e))return;LeeepCite.initingTagIds.push(e);const t=new URLSearchParams;i.pattern_id&&t.set("pattern_id",i.pattern_id),i.url&&t.set("url",i.url),i._cache_key&&t.set("_cache_key",i._cache_key),i._preview&&t.set("_preview",i._preview);const o=await fetch(`${LeeepCite.apiBase}/embed/${e}/style?${t.toString()}`);if(o.status>=400){const p=document.querySelectorAll(`#leeep-tag-section-${e}`);p.length&&p.forEach(g=>g.style.setProperty("display","none","important"));return}const s=await o.json();if(LeeepCite.tagStyle[e]=s,LeeepCite.site_id=s.WebsiteID,LeeepCite.Website=s.Website,s.Style.Common.PublishStatus==="unpublished"||s.Style.Common.PublishStatus==="test"&&new URLSearchParams(location.search).get("leeep_test")!=="on")return;if((u=s.Filter)!=null&&u.List.Filter.Common.LikedOnly){if(!LeeepCite.uid)return;t.set("liked_only","1")}if((y=s.Filter)!=null&&y.List.Filter.Common.FollowedOnly){if(!LeeepCite.uid)return;t.set("followed_only","1")}if((_=s.Filter)!=null&&_.List.Filter.Common.SpecifyDirectBrandCodes&&(i.brands=s.Filter.List.Filter.Common.BrandCodes),(h=s.Filter)!=null&&h.List.Filter.Common.SpecifyDirectShopCodes&&(i.shops=s.Filter.List.Filter.Common.ShopCodes),((b=(f=s.Filter)==null?void 0:f.List.Filter.Common.StaffPostHashtagIDs)==null?void 0:b.length)>0&&(i.hashtags=s.Filter.List.Filter.Common.StaffPostHashtagIDs),s.Style.Script){const p=document.createElement("script");p.async=!0,p.src=s.Style.Script.Src+"?revision="+s.Style.Script.Revision,document.body.appendChild(p);return}new URLSearchParams(location.search).get("leeep_sdk")==="1"&&new ResizeObserver(g=>{var m,C,S,w;if(g.length===0)return;const L=JSON.stringify({bodyHeight:g[0].contentRect.bottom});(S=(C=(m=window.webkit)==null?void 0:m.messageHandlers)==null?void 0:C.LeeepIosSdk)==null||S.postMessage(L),(w=window.LeeepAndroidSdk)==null||w.postMessage(L)}).observe(document.querySelector(`#leeep-tag-${e}`));const d=s.Positions||[{Selector:`#leeep-tag-${e}`,AdjacentPosition:"beforeend"}],r=await LeeepCite.waitForPosition(d);if(!r){console.log("selector ["+d.map(p=>p.Selector).join(" / ")+"] not found");return}const{position:l,element:n}=r,c=s.Style.Common.Viewer;if(c==="single_video"){t.set("style.custom_css",""+!!s.Style.Common.CustomCss),t.set("style.custom_js",""+!!s.Style.Common.CustomJs),t.set("style.auto_play",s.Style.SingleVideo.AutoPlay),t.set("style.control",s.Style.SingleVideo.Control),t.set("style.fullscreen",s.Style.SingleVideo.Fullscreen),t.set("style.sound_control",s.Style.SingleVideo.SoundControl),t.set("style.by_leeep",s.Style.Common.ByLeeep);const p={tagId:e,position:l.AdjacentPosition,styleCommon:s.Style.Common};if(new URLSearchParams(location.search).get("leeep_single_video")==="iframe"){LeeepCite.setSingleVideoIframe(i,t,n,p);return}LeeepCite.appendSingleVideo(n,i,p);return}if(t.set("tag_id",e),i.brands&&t.set("brands",i.brands.join(",")),i.shops&&t.set("shop_code",i.shops.join(",")),i.product_id&&t.set("product_id",i.product_id),i.cart_product_id&&t.set("cart_product_id",i.cart_product_id),i.hashtags&&t.set("hashtag_id",i.hashtags.join(",")),["staff_post_detail","staff_list","staff_detail","review_list","review_edit_form","review_score_for_detail","review_score_for_list","blog_list","blog_detail","tab"].includes(c)){console.log("viewer",c);const p=LeeepCite.makeStyledDiv(e);p.id=LeeepCite.embeddedElemId(e),l.AdjacentPosition==="overwrite"&&(n.innerHTML="",l.AdjacentPosition="beforeend"),n.insertAdjacentElement(l.AdjacentPosition||"beforeend",p);const L=await(await fetch(`${LeeepCite.apiBase}/embed/${c}/html?tag_id=${e}`)).text();p.insertAdjacentHTML("beforeend",L),LeeepCite.initingTagIds=LeeepCite.initingTagIds.filter(C=>C!==e);const m=document.createElement("script");m.async=!0,m.src=`${LeeepCite.apiBase}/embed/${c}/js?${t.toString()}`,document.body.appendChild(m);return}const a={tagId:e,position:l.AdjacentPosition,isOnetag:i.site_id&&!i.tag_id,abId:i==null?void 0:i.ab_id,patternId:i==null?void 0:i.pattern_id};if(s.Style.Common.Iframe){a.styleCommon=s.Style.Common,LeeepCite.applyStyleParams(t,s.Style),LeeepCite.appendListIframe(n,t,a);return}await LeeepCite.appendList(n,t,a)},waitForPosition:async(e,{timeoutMs:i=1e4,intervalMs:t=100}={})=>{const o=Date.now()+i;for(;Date.now()<=o;){for(const s of e){const d=document.querySelector(s.Selector);if(d)return{position:s,element:d}}await new Promise(s=>setTimeout(s,t))}return null},applyStyleParams:(e,i)=>{var t,o,s,d,r,l,n;return e.set("style.viewer",i.Common.Viewer),e.set("style.custom_css",""+!!i.Common.CustomCss),e.set("style.custom_js",""+!!i.Common.CustomJs),e.set("style.list_style",i.List.Frame),e.set("style.list_scroll",i.List.Scroll),e.set("style.list_media_aspect_ratio",i.List.MediaAspectRatio),e.set("style.list_column",i.List.Column),e.set("style.list_column_mobile",i.List.ColumnMobile),e.set("style.list_count",i.List.Count),e.set("style.list_count_mobile",i.List.CountMobile),e.set("style.list_video",i.List.VideoLength),e.set("style.list_user",i.List.User),e.set("style.list_caption",i.List.Caption),e.set("style.list_date",i.List.Date),e.set("style.list_see_more",i.List.SeeMore),e.set("style.list_see_more_text",i.List.SeeMoreText||""),e.set("style.detail_user",i.Detail.User),e.set("style.detail_item",i.Detail.Item),e.set("style.detail_out_of_stock_item",i.Detail.OutOfStockItem),e.set("style.detail_price",i.Detail.ItemPrice),e.set("style.detail_caption",i.Detail.Caption),e.set("style.detail_date",i.Detail.Date),e.set("style.fullscreen_price",(t=i.FullScreen)==null?void 0:t.ItemPrice),e.set("style.fullscreen_sound",(o=i.FullScreen)==null?void 0:o.Sound),e.set("style.fullscreen_auto_next_video",(s=i.FullScreen)==null?void 0:s.AutoNextVideo),e.set("style.fullscreen_see_product_text",(d=i.FullScreen)==null?void 0:d.SeeProductText),e.set("style.fullscreen_related_product_text",(r=i.FullScreen)==null?void 0:r.RelatedProductText),e.set("style.fullscreen_no_product_text",(l=i.FullScreen)==null?void 0:l.NoProductText),e.set("style.fullscreen_close_text",(n=i.FullScreen)==null?void 0:n.CloseText),e.set("style.by_leeep",i.Common.ByLeeep),e.set("style.target_blank",i.Common.TargetBlank),e},appendList:async(e,i,t)=>{const o=LeeepCite.tagStyle[t.tagId].Style;t!=null&&t.isOnetag||(e.style.margin="0 auto",e.style.width="100%",o.List.Scroll!=="horizontal"&&(e.style.maxWidth="calc(100vw - 24px)")),(t==null?void 0:t.position)==="overwrite"&&(e.innerHTML="",t.position="beforeend");const s=LeeepCite.makeStyledDiv(t.tagId);s.id=LeeepCite.embeddedElemId(t.tagId),e.insertAdjacentElement((t==null?void 0:t.position)||"beforeend",s);const r=await(await fetch(`${LeeepCite.apiBase}/embed/list/html?tag_id=${t.tagId}`)).text();s.insertAdjacentHTML("beforeend",r),LeeepCite.initingTagIds=LeeepCite.initingTagIds.filter(n=>n!==t.tagId);const l=document.createElement("script");l.async=!0,l.src=`${LeeepCite.apiBase}/embed/list/js?${i.toString()}`,document.body.appendChild(l)},appendListIframe:(e,i,t)=>{t!=null&&t.isOnetag||(e.style.margin="0 auto",e.style.width="100%",i.get("style.list_scroll")!=="horizontal"&&(e.style.maxWidth="calc(100vw - 24px)"));const o=document.createElement("iframe");t!=null&&t.tagId&&(o.id=`leeep-tag-iframe-${t.tagId}`),o.classList.add("leeep-tag-iframe"),o.src=`${LeeepCite.apiBase}/embed/posts?${i.toString()}`,o.style.display="block",o.style.margin="0 auto",o.style.border="none",o.style.width="100%",o.style.setProperty("max-height","99999px","important"),(t==null?void 0:t.styleCommon.MaxWidthPixel)*1>0&&(o.style.maxWidth=(t==null?void 0:t.styleCommon.MaxWidthPixel)+"px"),(t==null?void 0:t.styleCommon.Margin.Top)*1>0&&(o.style.marginTop=(t==null?void 0:t.styleCommon.Margin.Top)+"px"),(t==null?void 0:t.styleCommon.Margin.Left)*1>0&&(o.style.marginLeft=(t==null?void 0:t.styleCommon.Margin.Left)+"px"),(t==null?void 0:t.styleCommon.Margin.Right)*1>0&&(o.style.marginRight=(t==null?void 0:t.styleCommon.Margin.Right)+"px"),(t==null?void 0:t.styleCommon.Margin.Bottom)*1>0&&(o.style.marginBottom=(t==null?void 0:t.styleCommon.Margin.Bottom)+"px"),o.style.height="750px",(t==null?void 0:t.position)==="overwrite"&&(e.innerHTML="",t.position="beforeend"),e.insertAdjacentElement((t==null?void 0:t.position)||"beforeend",o);const s=e.clientWidth;t!=null&&t.styleCommon.HeaderHtml&&o.insertAdjacentHTML("beforebegin",`<div>${t.styleCommon.HeaderHtml}</div>`),t!=null&&t.styleCommon.FooterHtml&&o.insertAdjacentHTML("afterend",`<div>${t.styleCommon.FooterHtml}</div>`),LeeepCite.doOnce("setOnMessageList",d=>{window.addEventListener("message",LeeepCite.onMessageList)}),window.addEventListener("load",d=>{var r;e.clientWidth!==s&&((r=o.contentWindow)==null||r.postMessage({requestDocumentHeight:!0},"*"))}),(i.get("style.list_video")==="full"||i.get("style.list_video")==="head")&&setInterval(d=>{var l;const r=-o.getBoundingClientRect().y;(l=o.contentWindow)==null||l.postMessage({viewableTop:r,viewableBottom:r+window.innerHeight},"*")},200)},makeStyledDiv:e=>{const i=document.createElement("div");i.style.margin="0 auto";const t=LeeepCite.tagStyle[e].Style.Common;return t.MaxWidthPixel*1>0&&(i.style.maxWidth=t.MaxWidthPixel+"px"),t.Margin.Top*1>0&&(i.style.marginTop=t.Margin.Top+"px"),t.Margin.Left*1>0&&(i.style.paddingLeft=t.Margin.Left+"px"),t.Margin.Right*1>0&&(i.style.paddingRight=t.Margin.Right+"px"),t.Margin.Bottom*1>0&&(i.style.marginBottom=t.Margin.Bottom+"px"),i},insertByLeeep:async(e,i,t)=>{var o;((o=LeeepCite.tagStyle[e])==null?void 0:o.Style.Common.ByLeeep)==="shown"&&fetch(`${LeeepCite.apiBase}/embed/by_leeep?tag_id=${e}`).then(s=>s.text()).then(s=>i==null?void 0:i.insertAdjacentHTML(t,s))},insertCommonElement:(e,i={})=>{var s,d,r;const t=(s=LeeepCite.tagStyle[e])==null?void 0:s.Style;if(!t)return;function o(l){for(const n in i)l=l.replaceAll(n,i[n]);return l}if(t.Common.HeaderHtml){const l=o(t.Common.HeaderHtml);(d=document.querySelector(`#${LeeepCite.embeddedElemId(e)}`))==null||d.insertAdjacentHTML("afterbegin",l)}if(t.Common.FooterHtml){const l=o(t.Common.FooterHtml);(r=document.querySelector(`#${LeeepCite.embeddedElemId(e)}`))==null||r.insertAdjacentHTML("beforeend",l)}},insertSearchFilter:(e,i)=>{const t=document.createElement("script");t.async=!0;const o=i?"&_cache_key="+i:"";t.src=`${LeeepCite.apiBase}/embed/search_filter/js?tag_id=${e}${o}`,document.body.appendChild(t)},openModal:async(e,i)=>{var r;let t=new URLSearchParams(i);LeeepCite.tagStyle[e.tagId]&&(t=LeeepCite.applyStyleParams(t,LeeepCite.tagStyle[e.tagId].Style));const o=e.clickedPostId,s=e.tagId,d=document.createElement("div");if(d.id="leeep-cite-modal",t.set("parent_href",window.location.href),e.viewer==="list_fullscreen")t.set("clicked_post_id",o),t.set("count",e.count),t.set("page",e.page),e.randSeed&&t.set("rand_seed",e.randSeed),d.innerHTML=`
                <style>
                    @media (max-width: 640px) { #LeeepTagIframeFullscreen { top: 0; bottom: 0; } }
                    @media (min-width: 641px) { #LeeepTagIframeFullscreen { top: 5vh; bottom: 5vh; margin: 0 auto; max-width: 832px; max-height: 90vh; border-radius: 8px; } }
                </style>
                <div class="LeeepFullscreenCurtain" style="position: fixed; top: 0; left: 0; right: 0; bottom: 0; width: 100vw; height: 100vh; background-color: #0008; z-index: 2147483647;"></div>
                <iframe id="LeeepTagIframeFullscreen" src="${LeeepCite.apiBase}/embed/fullscreen?${t.toString()}" allow="autoplay"
                    style="position: fixed; left: 0; right: 0; width: 100vw; height: 100vh; height: 100dvh; border: none; z-index: 2147483647;"></iframe>`,document.body.appendChild(d),document.body.style.overflow="hidden",LeeepCite.doOnce("setOnMessageFullscreen",l=>{window.addEventListener("message",LeeepCite.onMessageFullscreen)});else if(document.body.clientWidth<=640){const l=e.postIds;let n=`
                <style>#LeeepPopupScrollX{ position: fixed; top: 50px; left: 0; right: 0; bottom: 0; overflow-x: scroll; z-index: 2147483647; scroll-snap-type: x mandatory; scrollbar-width: none; } #LeeepPopupScrollX::-webkit-scrollbar{ display: none; }
                    #leeep-cite-modal div:empty{ display: block; } #LeeepPopupCurtain{ position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: #0008; z-index: 2147483647; }
                    #LeeepPopupCloseButton{ position: fixed; display: block; top: 8px; right: 9px; width: 40px; height: 40px; z-index: 2147483647; }</style>
                <div id="LeeepPopupCurtain" onclick="LeeepCite.closeModal(); event.stopPropagation();"></div>
                <a id="LeeepPopupCloseButton" href="javascript:void(0)" onclick="LeeepCite.closeModal(); event.stopPropagation(); return false;">
                    <svg viewBox="0 0 40 40" style="width: 100%; height: 100%; stroke: #fff; stroke-width: 2; stroke-linejoin: round;"><path d="M13 13l14 14z M27 13l-14 14z" /></svg>
                </a>
                <div id="LeeepPopupScrollX" onscroll="LeeepCite.onModalScroll(this, '${t.toString()}', '${s}')">`,c=0;l.forEach((a,u)=>{n+=`<div class="LeeepPopupPage" style="position: absolute; left: calc(20px + ${u*100}vw - ${u*30}px); width: calc(100vw - 40px); height: 100%; border-radius: 12px 12px 0 0;
                    background-color: #fff; scroll-snap-align: center; overflow: hidden;" data-id="${a}">`,a===o&&(n+=LeeepCite.mobileDetailIframeHtml(o,t.toString()),c=u),n+="</div>"}),n+=`<div class="LeeepPopupScrollXEnd" style="position: absolute; left: calc(20px + ${l.length*100}vw - ${l.length*30}px); width: 10px; height: 100%;"></div></div>`,d.innerHTML=n,document.body.appendChild(d),(r=document.querySelector("#LeeepPopupScrollX"))==null||r.scrollTo(c*window.innerWidth-c*30,0),LeeepCite.doOnce("setOnMessageDetail",a=>{window.addEventListener("message",LeeepCite.onMessageDetail)})}else d.innerHTML=`
                <style>#leeep-cite-modal div:empty{ display: block; } #LeeepPopupCurtain{ position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: #0008; z-index: 2147483647; }
                    #LeeepPopup{ position: fixed; top: 4vh; left: 2.5vw; right: 2.5vw; bottom: 4vh; margin: 0 auto; width: min(95vw, 1200px); border-radius: 12px; background-color: #fff; overflow: hidden; z-index: 2147483647; }
                    #LeeepPopupCloseButton{ position: absolute; display: block; top: 11px; right: 11px; width: 40px; height: 40px; background-color: #fffc; border-radius: 12px; } #LeeepPopupCloseButton:hover{ background-color: #eee; }</style>
                <div id="LeeepPopupCurtain" onclick="LeeepCite.closeModal(); event.stopPropagation();"></div>
                <div id="LeeepPopup">
                    <iframe class="LeeepPopupIframePc" src="${LeeepCite.apiBase}/embed/posts/${o}?${t.toString()}" allow="autoplay" style="display: block; border: none; width: 100%; height: 100%;"></iframe>
                    <a id="LeeepPopupCloseButton" href="javascript:" onclick="LeeepCite.closeModal(); event.stopPropagation(); return false;">
                        <svg viewBox="0 0 40 40" style="width: 100%; height: 100%; stroke: #666; stroke-width: 2; stroke-linejoin: round;"><path d="M13 13l14 14z M27 13l-14 14z"></svg>
                    </a>
                </div>`,document.body.appendChild(d),LeeepCite.doOnce("setOnMessageDetail",l=>{window.addEventListener("message",LeeepCite.onMessageDetail)});LeeepCite.isTrackable("openModal-viewPost")&&ParteTracking.viewPost({site_id:LeeepCite.site_id,tid:s||"",pid:o,ab_id:LeeepCite.patternTagIds.includes(s)?LeeepCite.abId:null,pattern_id:LeeepCite.patternTagIds.includes(s)?LeeepCite.patternId:null,user:{id:LeeepCite.uid}})},mobileDetailIframeHtml:(e,i)=>`<iframe class="LeeepPopupIframeSp" src="${LeeepCite.apiBase}/embed/posts/${e}?${i}" allow="autoplay" style="display: block; border: none; width: 100%; height: 100%;"></iframe>`,currentPage:null,onModalScroll:(e,i,t)=>{const o=Array.from(e.childNodes).filter(s=>{const d=s.getBoundingClientRect();return d.x+d.width/2>0})[0];if(o.innerHTML===""){const s=o.dataset.id;o.innerHTML=LeeepCite.mobileDetailIframeHtml(s,i),LeeepCite.isTrackable("onModalScroll-viewPost")&&ParteTracking.viewPost({site_id:LeeepCite.site_id,tid:t||"",pid:s,ab_id:LeeepCite.patternTagIds.includes(t)?LeeepCite.abId:null,pattern_id:LeeepCite.patternTagIds.includes(t)?LeeepCite.patternId:null,user:{id:LeeepCite.uid}})}if(o!==LeeepCite.currentPage){const s=o.querySelector("iframe");Array.from(e.querySelectorAll("iframe")).filter(d=>d!==o).forEach(d=>d.contentWindow.postMessage({videoControl:"pause"},"*")),s==null||s.contentWindow.postMessage({videoControl:"play"},"*")}LeeepCite.currentPage=o},closeModal:()=>{document.body.style.overflow==="hidden"&&(document.body.style.overflow="auto"),document.getElementById("leeep-cite-modal").remove()},singleVideo:async e=>{var s;if(!(e!=null&&e.site_id)&&!(e!=null&&e.tag_id)){console.log("LEEEPタグエラー：パラメータが不足しています");return}LeeepCite.uid=((s=e.uid)==null?void 0:s.toString())||"";let i=document.querySelector("#leeep-single-video-container");const t=new URLSearchParams;let o={};if(e.tag_id){i=document.querySelector(`#leeep-tag-${e.tag_id}`),e._cache_key&&t.set("_cache_key",e._cache_key);const d=await fetch(`${LeeepCite.apiBase}/embed/${e.tag_id}/style?${t.toString()}`);if(d.status>=400){const c=e.tag_id?`#leeep-tag-section-${e.tag_id}`:".leeep-single-video-section",a=document.querySelector(c);a&&a.style.setProperty("display","none","important");return}const r=await d.json();LeeepCite.tagStyle[e.tag_id]=r,LeeepCite.site_id=r.WebsiteID,t.set("style.custom_css",""+!!r.Style.Common.CustomCss),t.set("style.custom_js",""+!!r.Style.Common.CustomJs),t.set("style.auto_play",r.Style.SingleVideo.AutoPlay),t.set("style.control",r.Style.SingleVideo.Control),t.set("style.fullscreen",r.Style.SingleVideo.Fullscreen),t.set("style.sound_control",r.Style.SingleVideo.SoundControl),t.set("style.by_leeep",r.Style.Common.ByLeeep);const n=(r.Positions||[{Selector:`#leeep-tag-${e.tag_id}`,AdjacentPosition:"beforeend"}]).filter(c=>document.querySelector(c.Selector))[0];i=document.querySelector(n==null?void 0:n.Selector)||i,o={tagId:e.tag_id,position:(n==null?void 0:n.AdjacentPosition)||"beforeend",styleCommon:r.Style.Common}}else{LeeepCite.site_id=e.site_id,e.ugc_id&&(i=document.querySelector(`#leeep-tag-ugc-${e.ugc_id}`)),LeeepCite.setSingleVideoIframe(e,t,i,o);return}if(new URLSearchParams(location.search).get("leeep_single_video")==="iframe"){LeeepCite.setSingleVideoIframe(e,t,i,o);return}LeeepCite.appendSingleVideo(i,e,o)},appendSingleVideo:async(e,i,t)=>{(t==null?void 0:t.position)==="overwrite"&&(e.innerHTML="",t.position="beforeend"),LeeepCite.tagStyle[t.tagId].Style;const o=LeeepCite.makeStyledDiv(t.tagId);o.id=LeeepCite.embeddedElemId(t.tagId),LeeepCite.initingTagIds=LeeepCite.initingTagIds.filter(n=>n!==t.tagId),e.insertAdjacentElement((t==null?void 0:t.position)||"beforeend",o);const s=new URLSearchParams;i.site_id&&s.set("site_id",i.site_id),t.tagId&&s.set("tag_id",t.tagId),i.ugc_id&&s.set("ugc_id",i.ugc_id),i.brands&&s.set("brands",i.brands.join(",")),i.product_id&&s.set("product_id",i.product_id);const r=await(await fetch(`${LeeepCite.apiBase}/embed/single_video/html?tag_id=${t.tagId}`)).text();o.insertAdjacentHTML("beforeend",r);const l=document.createElement("script");l.async=!0,l.src=`${LeeepCite.apiBase}/embed/single_video/js?${s.toString()}`,document.body.appendChild(l)},setSingleVideoIframe:(e,i,t,o)=>{var d,r,l,n,c,a,u;e.site_id&&i.set("site_id",e.site_id),o.tagId&&i.set("tag_id",o.tagId),e.ugc_id&&i.set("ugc_id",e.ugc_id),e.brands&&i.set("brands",e.brands.join(",")),e.product_id&&i.set("product_id",e.product_id);const s=document.createElement("iframe");o.tagId?s.id=`leeep-tag-iframe-${o.tagId}`:e.ugc_id?s.id=`leeep-tag-iframe-ugc-${e.ugc_id}`:s.className="leeep-tag-iframe-video",s.classList.add("leeep-tag-iframe"),s.src=`${LeeepCite.domain}/v2/embed/single_video?${i.toString()}`,s.style.display="block",s.style.margin="0 auto",s.style.border="none",s.style.width="100%",s.style.setProperty("max-height","99999px","important"),((d=o.styleCommon)==null?void 0:d.MaxWidthPixel)*1>0&&(s.style.maxWidth=o.styleCommon.MaxWidthPixel+"px"),((r=o.styleCommon)==null?void 0:r.Margin.Top)*1>0&&(s.style.marginTop=o.styleCommon.Margin.Top+"px"),((l=o.styleCommon)==null?void 0:l.Margin.Left)*1>0&&(s.style.marginLeft=o.styleCommon.Margin.Left+"px"),((n=o.styleCommon)==null?void 0:n.Margin.Right)*1>0&&(s.style.marginRight=o.styleCommon.Margin.Right+"px"),((c=o.styleCommon)==null?void 0:c.Margin.Bottom)*1>0&&(s.style.marginBottom=o.styleCommon.Margin.Bottom+"px"),s.style.height="0",s.allowFullscreen=!0,o.position==="overwrite"&&(t.innerHTML="",o.position="beforeend"),t.insertAdjacentElement(o.position||"beforeend",s),(a=o.styleCommon)!=null&&a.HeaderHtml&&s.insertAdjacentHTML("beforebegin",`<div>${o.styleCommon.HeaderHtml}</div>`),(u=o.styleCommon)!=null&&u.FooterHtml&&s.insertAdjacentHTML("afterend",`<div>${o.styleCommon.FooterHtml}</div>`),LeeepCite.doOnce("setOnMessageSingleVideo",y=>{window.addEventListener("message",LeeepCite.onMessageSingleVideo)})},onMessageList:e=>{var o;if(e.origin!==LeeepCite.domain)return;const i=e.data;let t=document.querySelector(".leeep-tag-iframe");if(i.tagId?t=document.querySelector(`#leeep-tag-iframe-${i.tagId}`):i.ugcId&&(t=document.querySelector(`#leeep-tag-iframe-ugc-${i.ugcId}`)),!!t){if(i.hasContent!==void 0)if(i.hasContent){const s=new IntersectionObserver((d,r)=>{var l;d.length>0&&d[0].isIntersecting&&d[0].target===t&&((l=t.contentWindow)==null||l.postMessage({requestDocumentHeight:!0},"*"),i.tagId&&LeeepCite.isTrackable("onMessageList-viewTag")&&LeeepCite.doOnce("trackingViewTag"+i.tagId,n=>{ParteTracking.viewTag({site_id:LeeepCite.site_id,tid:i.tagId,ab_id:LeeepCite.patternTagIds.includes(i.tagId)?LeeepCite.abId:null,pattern_id:LeeepCite.patternTagIds.includes(i.tagId)?LeeepCite.patternId:null,user:{id:LeeepCite.uid}})}),s.unobserve(t))},{threshold:0});s.observe(t)}else{t.remove();const s=i.tagId?`#leeep-tag-section-${i.tagId}`:".leeep-cite-section, .parte-cite-section",d=document.querySelectorAll(s);d&&d.forEach(r=>r.style.setProperty("display","none","important"))}if(i.documentHeight&&(t.style.setProperty("height",i.documentHeight+"px","important"),i.enableAutoPaging)){let s=function(){var l;const r=window.visualViewport;r.pageTop+r.height>t.offsetTop+t.offsetHeight&&(window.clearInterval(d),(l=t.contentWindow)==null||l.postMessage({seeMore:!0},"*"))};const d=window.setInterval(s,200)}i.clickedPostId&&LeeepCite.openModal(i,t.src.split("?")[1]),i.posts&&((o=document.querySelector("#LeeepTagIframeFullscreen").contentWindow)==null||o.postMessage({posts:i.posts},"*"))}},onMessageDetail:e=>{if(e.origin!==LeeepCite.domain)return;const i=e.data;i.clickedProductId&&LeeepCite.isTrackable("onMessageDetail-clickItem")&&ParteTracking.clickItem({site_id:LeeepCite.site_id,tid:i.tagId||"",pid:i.ugcId,product_id:i.clickedProductId,ab_id:LeeepCite.patternTagIds.includes(i.tagId)?LeeepCite.abId:null,pattern_id:LeeepCite.patternTagIds.includes(i.tagId)?LeeepCite.patternId:null,user:{id:LeeepCite.uid}})},onMessageFullscreen:e=>{var t,o;if(e.origin!==LeeepCite.domain)return;const i=e.data;i.ready&&((o=(t=document.querySelector(`#leeep-tag-iframe-${i.tagId}`))==null?void 0:t.contentWindow)==null||o.postMessage({requestPosts:!0},"*")),i.viewPostId&&LeeepCite.isTrackable("onMessageFullscreen-viewPost")&&ParteTracking.viewPost({site_id:LeeepCite.site_id,tid:i.tagId||"",pid:i.viewPostId,ab_id:LeeepCite.patternTagIds.includes(i.tagId)?LeeepCite.abId:null,pattern_id:LeeepCite.patternTagIds.includes(i.tagId)?LeeepCite.patternId:null,user:{id:LeeepCite.uid}}),i.clickedProductId&&LeeepCite.isTrackable("onMessageFullscreen-clickItem")&&ParteTracking.clickItem({site_id:LeeepCite.site_id,tid:i.tagId||"",pid:i.ugcId,product_id:i.clickedProductId,ab_id:LeeepCite.patternTagIds.includes(i.tagId)?LeeepCite.abId:null,pattern_id:LeeepCite.patternTagIds.includes(i.tagId)?LeeepCite.patternId:null,user:{id:LeeepCite.uid}}),i.close&&LeeepCite.closeModal()},onMessageSingleVideo:e=>{var o,s,d;if(e.origin!==LeeepCite.domain)return;const i=e.data;let t=document.querySelector(".leeep-tag-iframe-video");if(i.tagId?t=document.querySelector(`#leeep-tag-iframe-${i.tagId}`):i.ugcId&&(t=document.querySelector(`#leeep-tag-iframe-ugc-${i.ugcId}`)),!!t){if(i.hasContent!==void 0)if(i.hasContent){const r=new IntersectionObserver((l,n)=>{var c;l.length>0&&l[0].isIntersecting&&l[0].target===t&&((c=t.contentWindow)==null||c.postMessage({requestSize:!0},"*"),i.tagId&&LeeepCite.isTrackable("onMessageSingleVideo-viewTag")&&LeeepCite.doOnce("trackingViewTag"+i.tagId,a=>{ParteTracking.viewTag({site_id:LeeepCite.site_id,tid:i.tagId,ab_id:LeeepCite.patternTagIds.includes(i.tagId)?LeeepCite.abId:null,pattern_id:LeeepCite.patternTagIds.includes(i.tagId)?LeeepCite.patternId:null,user:{id:LeeepCite.uid}})}),r.unobserve(t))},{threshold:0});r.observe(t),(d=(s=(o=window.webkit)==null?void 0:o.messageHandlers)==null?void 0:s.LeeepReadyToPlay)==null||d.postMessage(""),typeof android<"u"&&(android==null||android.LeeepReadyToPlay())}else{t.remove();const r=i.tagId?`#leeep-tag-section-${i.tagId}`:".leeep-single-video-section",l=document.querySelector(r);l&&l.style.setProperty("display","none","important")}i.size&&(t.style.setProperty("height",`${t.offsetWidth*i.size.height/i.size.width+i.size.footerHeight}px`,"important"),LeeepCite.addInviewTarget(t,.5)),i.viewPost&&LeeepCite.isTrackable("onMessageSingleVideo-viewPost")&&ParteTracking.viewPost({site_id:LeeepCite.site_id,tid:i.tagId||"",pid:i.postId,ab_id:LeeepCite.patternTagIds.includes(i.tagId)?LeeepCite.abId:null,pattern_id:LeeepCite.patternTagIds.includes(i.tagId)?LeeepCite.patternId:null,user:{id:LeeepCite.uid}}),i.toggleFullscreen&&(document.fullscreenElement?(document.exitFullscreen||document.mozCancelFullScreen||document.webkitCancelFullScreen||document.cancelFullScreen||document.msExitFullscreen).call(document):(t.requestFullscreen||t.mozRequestFullScreen||t.webkitRequestFullscreen||t.webkitEnterFullscreen||t.msRequestFullscreen).call(t))}},inviewTargets:[],addInviewTarget:(e,i)=>{if(LeeepCite.inviewTargets.filter(d=>d===e).length>0)return;LeeepCite.inviewTargets.push(e);const t=(d,r)=>{d.forEach(l=>{var n;(n=l.target.contentWindow)==null||n.postMessage({inview:l.isIntersecting},"*")})},o={threshold:i};new IntersectionObserver(t,o).observe(e)},isTrackable:function(e){const i=typeof ParteTracking=="object";return i||console.log("ParteTracking is not defined:",e),i},_dones:[],doOnce:(e,i)=>{LeeepCite._dones.includes(e)||(LeeepCite._dones.push(e),i())},playVideo:e=>{var t,o;(o=(t=document.querySelector(".leeep-tag-iframe"))==null?void 0:t.contentWindow)==null||o.postMessage({playVideo:!0},"*");const i=document.querySelector(".LeeepSingleVideoContainer");i&&(i.querySelector(".LeeepSingleVideoIconPlay").style.display="none",i.querySelector(".LeeepSingleVideoIconPause").style.display="block",i.querySelector(".LeeepSingleVideoPlayer").play(),setTimeout(s=>{const d=i.querySelector(".LeeepSingleVideoBottomGradient");d.animate({opacity:[1,0]},{duration:200,easing:"ease-out"}),d.style.opacity=0},1500))},pauseVideo:e=>{var t,o;(o=(t=document.querySelector(".leeep-tag-iframe"))==null?void 0:t.contentWindow)==null||o.postMessage({pauseVideo:!0},"*");const i=document.querySelector(".LeeepSingleVideoContainer");i&&(i.querySelector(".LeeepSingleVideoIconPlay").style.display="block",i.querySelector(".LeeepSingleVideoIconPause").style.display="none",i.querySelector(".LeeepSingleVideoPlayer").pause())},goBackVideo:e=>{var t,o;(o=(t=document.querySelector(".leeep-tag-iframe"))==null?void 0:t.contentWindow)==null||o.postMessage({goBackVideo:!0},"*");const i=document.querySelector(".LeeepSingleVideoContainer");i&&(i.querySelector(".LeeepSingleVideoPlayer").currentTime=0)},isUnpublished:e=>e.published_to?new Date>new Date(e.published_to):!1,removeUnpublishedFromList:e=>(e.posts=e.posts.filter(i=>LeeepCite.isUnpublished(i)?(e.total--,!1):!0),e),removeUnpublishedFromDetail:e=>((!e.post||LeeepCite.isUnpublished(e.post))&&(e.post=void 0),e),removeUnpublishedFromStaffPostDetail:e=>{if(!(!e||LeeepCite.isUnpublished(e)))return e}};ParteCite=LeeepCite;
