import{r as e,g as t}from"./vendor-react.js";function s(e,t){for(var s=0;sr[t]})}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}var r,n,o={exports:{}},i={};var l=(n||(n=1,o.exports=function(){if(r)return i;r=1;var t=e(),s=Symbol.for("react.element"),n=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,l=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,r){var n,i={},c=null,d=null;for(n in void 0!==r&&(c=""+r),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(d=t.ref),t)o.call(t,n)&&!a.hasOwnProperty(n)&&(i[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===i[n]&&(i[n]=t[n]);return{$$typeof:s,type:e,key:c,ref:d,props:i,_owner:l.current}}return i.Fragment=n,i.jsx=c,i.jsxs=c,i}()),o.exports),a=e();const c=t(a),d=s({__proto__:null,default:c},[a]),u=c.memo((({isOpen:e,onClose:t,children:s,onNext:r,onPrevious:n,isFirst:o,isLast:i,isPremium:d=!1})=>{const u=a.useRef(null),h=a.useRef(null),x=a.useRef(null),[m,g]=a.useState(null),[p,f]=a.useState(!1),[v,w]=a.useState({width:360,height:640}),[y,j]=a.useState(!1),[b,k]=a.useState(!1),[N,C]=a.useState(0),_=a.useRef(!1),L=a.useRef({isOpen:e,currentVideo:m,isLoading:p});a.useEffect((()=>{L.current.isOpen===e&&L.current.currentVideo===m&&L.current.isLoading===p||(L.current={isOpen:e,currentVideo:m,isLoading:p})}),[e,m,p]),a.useEffect((()=>{e&&!d&&m&&m.share_url&&(t&&t(),window.open(m.share_url,"_blank"))}),[e,d,m,t]);const M=(e,t=null)=>{if(h.current&&h.current.contentWindow)try{const s={"x-tiktok-player":!0,type:e,value:t};h.current.contentWindow.postMessage(s,"*")}catch(s){}};a.useEffect((()=>{if(!e)return;const t=()=>{if(!x.current)return;const e=window.innerWidth<768;j(e),w(e?{width:window.innerWidth,height:window.innerHeight}:{width:360,height:640})};return t(),window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t)}}),[e]),a.useEffect((()=>{}),[e]),a.useEffect((()=>{if(e&&s&&c.Children.count(s)>0){const e=c.Children.toArray(s)[0];e&&e.props&&e.props.video&&(e.props.video,g(e.props.video),k(!1),C(0),_.current=!1)}}),[s,e]);const T=a.useCallback((()=>{}),[e,s]),B=a.useCallback((()=>{if(!h.current)return;M("unMute"),M("changeVolume",80),M("play");const t=setTimeout((()=>{!_.current&&e&&k(!0)}),3e3);return()=>clearTimeout(t)}),[e]);a.useEffect((()=>{if(!e||!d)return;const t=console.error;console.error=(...e)=>{e[0]&&"string"==typeof e[0]&&e[0].includes("@ies/starling_intl")||t.apply(console,e)};const s=e=>{if(e.data&&e.data["x-tiktok-player"])switch(e.data.type){case"onPlayerReady":_.current=!0,k(!1),h.current&&B(),f(!1);break;case"onStateChange":1===e.data.value?(_.current=!0,k(!1),M("unMute")):-1!==e.data.value&&0!==e.data.value||e.data.value;break;case"onError":k(!0)}};return window.addEventListener("message",s),T(),()=>{window.removeEventListener("message",s),console.error=t}}),[T,B,e,d]);const P=a.useCallback((()=>{if(!(N>=3)&&(C((e=>e+1)),k(!1),f(!0),m)){const e=m;g(null),setTimeout((()=>{g(e)}),100)}}),[N,m]),I=a.useCallback((()=>{f(!0),k(!1),C(0),_.current=!1,r&&r()}),[r]),A=a.useCallback((()=>{f(!0),k(!1),C(0),_.current=!1,n&&n()}),[n]),E=a.useCallback((()=>{h.current&&M("pause"),t&&t()}),[t]);if(a.useEffect((()=>{m&&e&&d&&(f(!0),_.current=!1)}),[m,e,d]),!d||!e)return null;const S={overlay:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.9)",zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center"},popup:{backgroundColor:"#000",borderRadius:"8px",boxShadow:"0 4px 6px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.08)",position:"relative",overflow:"hidden",zIndex:1001,maxWidth:"100vw",maxHeight:"100vh"},navButton:{position:"absolute",top:"50%",transform:"translateY(-50%)",backgroundColor:"rgba(255, 255, 255, 0.2)",borderRadius:"50%",width:"40px",height:"40px",display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",cursor:"pointer",zIndex:1002,border:"none",outline:"none",padding:"0"},prevButton:{left:"10px"},nextButton:{right:"10px"},closeButton:{position:"absolute",top:"13px",right:"13px",backgroundColor:"#000",borderRadius:"50%",width:"33px",height:"35px",display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",cursor:"pointer",zIndex:1002,border:"none",outline:"none",padding:"0"},loadingOverlay:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0, 0, 0, 0.6)",zIndex:1003},spinner:{width:"40px",height:"40px",borderRadius:"50%",border:"3px solid rgba(255, 255, 255, 0.1)",borderTopColor:"#fff",animation:"etf-spin 1s linear infinite"},errorOverlay:{position:"absolute",inset:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0, 0, 0, 0.7)",zIndex:1003,padding:"24px",textAlign:"center",color:"#fff"},errorButtons:{display:"flex",gap:"12px",marginTop:"16px"},button:{padding:"8px 16px",borderRadius:"4px",border:"none",cursor:"pointer",fontWeight:"bold"},retryButton:{backgroundColor:"#4f46e5",color:"#fff"},nextVideoButton:{backgroundColor:"#fff",color:"#000"},closeErrorButton:{backgroundColor:"#ef4444",color:"#fff"}};return l.jsxs("div",{className:"etf-popup-overlay",ref:x,style:S.overlay,children:[l.jsx("div",{onClick:E,style:{position:"absolute",inset:0}}),l.jsxs("div",{className:"etf-popup-container",style:{...S.popup,width:`${v.width}px`,height:`${v.height}px`},children:[!o&&l.jsx("button",{onClick:A,style:{...S.navButton,...S.prevButton},"aria-label":"Previous video",children:l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),!i&&l.jsx("button",{onClick:I,style:{...S.navButton,...S.nextButton},"aria-label":"Next video",children:l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}),l.jsxs("div",{style:{height:"100%",width:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:[p&&l.jsx("div",{style:S.loadingOverlay,children:l.jsx("div",{style:S.spinner})}),b&&l.jsxs("div",{style:S.errorOverlay,children:[l.jsx("p",{style:{marginBottom:"16px"},children:"Unable to play video."}),l.jsxs("div",{style:S.errorButtons,children:[l.jsx("button",{onClick:P,disabled:N>=3,style:{...S.button,...S.retryButton,...N>=3?{opacity:.5,cursor:"not-allowed"}:{}},children:N>=3?"Retry limit reached":"Retry"}),l.jsx("button",{onClick:I,disabled:i,style:{...S.button,...S.nextVideoButton,...i?{opacity:.5,cursor:"not-allowed"}:{}},children:"Next Video"}),l.jsx("button",{onClick:E,style:{...S.button,...S.closeErrorButton},children:"Close"})]})]}),m?l.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",width:"100%"},ref:u,children:l.jsx("iframe",{ref:h,src:`https://www.tiktok.com/player/v1/${m.id}?controls=1&play_button=1&volume_control=1&progress_bar=1&fullscreen_button=0×tamp=0&autoplay=1&music_info=0&description=0&rel=0&native_context_menu=0&closed_caption=0&loop=0&video_info=0`,style:{width:"100%",height:"100%",maxWidth:"100%",maxHeight:"100%",backgroundColor:"black"},frameBorder:"0",allow:"autoplay",title:"TikTok Video Player",onLoad:()=>{f(!1)},onError:e=>{k(!0),f(!1)}},`player-${m.id}-${N}`)}):s&&c.Children.map(s,(e=>{if(e&&e.props&&e.props.video){const t=e.props.video.id;if(!t)return l.jsx("div",{style:{textAlign:"center",padding:"32px",color:"#fff"},children:l.jsx("p",{style:{color:"#ef4444"},children:"Cannot play video: Missing video ID"})});const s=`https://www.tiktok.com/player/v1/${t}?controls=1&play_button=1&volume_control=1&progress_bar=1&fullscreen_button=0×tamp=0&autoplay=1&music_info=0&description=0&rel=0&native_context_menu=0&closed_caption=0&loop=0&video_info=0`;return l.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",width:"100%"},ref:u,children:l.jsx("iframe",{ref:h,src:s,style:{width:"100%",height:"100%",backgroundColor:"black"},frameBorder:"0",allow:"autoplay",title:"TikTok Video Player",onLoad:()=>f(!1),onError:()=>k(!0)},`player-${t}-alt-${N}`)})}return e}))]}),l.jsx("button",{onClick:E,style:S.closeButton,"aria-label":"Close video",children:l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]})})),h=({accountInfo:e,feedSettings:t})=>{var s,r,n,o;if(!e)return null;if(!(null==t?void 0:t.showTopbar))return null;const i=e.profile||e.meta||{},a=i.profile_picture||i.avatar_url||i.avatar||(null==(s=e.meta)?void 0:s.profile_picture)||(null==(r=e.meta)?void 0:r.avatar_url)||(e.avatar?e.avatar:null),c=i.username||e.title&&e.title.rendered||(null==(n=e.meta)?void 0:n.etf_username)||"TikTok Account",d=i.display_name||i.nickname||(null==(o=e.title)?void 0:o.rendered)||c,u=e=>e||0===e?e>=1e6?(e/1e6).toFixed(1)+"M":e>=1e3?(e/1e3).toFixed(1)+"K":e.toLocaleString():"0",h=i.video_count||0,x=i.followers_count||0,m=i.following_count||0,g=i.likes_count||0,p=i.bio||"",f=i.verified||!1;return l.jsxs("div",{className:"bg-white rounded-lg shadow mb-4 overflow-hidden",children:[l.jsx("div",{className:"px-2 py-4 md:px-6 flex items-center",children:l.jsxs("div",{className:"flex md:items-center items-start flex-grow flex-col md:flex-row gap-2 md:gap-0",children:[a&&l.jsxs("div",{className:"flex-shrink-0 flex md:flex-row md:mr-6",children:[l.jsx("img",{src:a,alt:d,className:"w-12 h-12 rounded-full object-cover border-2 border-gray-200",onError:e=>{e.target.onerror=null,e.target.src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0iI2NjY2NjYyI+PHBhdGggZD0iTTEyIDJDNi40OCAyIDIgNi40OCAyIDEyczQuNDggMTAgMTAgMTAgMTAtNC40OCAxMC0xMFMxNy41MiAyIDEyIDJ6bTAgM2MyLjY3IDAgOCAyLjY1IDggNiAwIDMuMzEtNS42OSA2LTggNi0yLjMxIDAtOC0yLjY1LTgtNiAwLTMuMzUgNS42Ny02IDgtNnptMCAyYy0xLjEgMC0yIC45LTIgMnMuOSAyIDIgMiAyLS45IDItMi0uOS0yLTIteiIvPjwvc3ZnPg=="}}),l.jsxs("div",{className:"ml-3",children:[t.showDisplayname&&d&&l.jsxs("h2",{className:"font-bold mb-1 text-gray-900 flex items-center",children:[d,f&&l.jsx("span",{className:"ml-1 text-blue-500",children:l.jsx("svg",{className:"h-5 w-5 inline",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:l.jsx("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"})})})]}),t.showUsername&&c&&l.jsxs("p",{className:"text-sm text-gray-500",children:["@",c]})]})]}),l.jsx("div",{className:"flex flex-grow items-center flex-wrap",children:l.jsxs("div",{className:"flex space-x-2 md:space-x-6 flex-grow flex-wrap",children:[t.showVideoCount&&l.jsxs("div",{className:"flex items-center",children:[l.jsx("p",{className:"mr-1",children:u(h)}),l.jsx("p",{className:"text-xs text-gray-500",children:"Videos"})]}),t.showFollowers&&l.jsxs("div",{className:"flex items-center",children:[l.jsx("p",{className:"mr-1",children:u(x)}),l.jsx("p",{className:"text-xs text-gray-500",children:"Followers"})]}),t.showFollowing&&l.jsxs("div",{className:"flex items-center",children:[l.jsx("p",{className:"mr-1",children:u(m)}),l.jsx("p",{className:"text-xs text-gray-500",children:"Following"})]}),t.showLikesCount&&l.jsxs("div",{className:"flex items-center",children:[l.jsx("p",{className:"mr-1",children:u(g)}),l.jsx("p",{className:"text-xs text-gray-500",children:"Likes"})]})]})})]})}),t.showBio&&p&&l.jsx("div",{className:"px-6 py-3 border-t border-gray-100",children:l.jsx("p",{className:"text-sm text-gray-700",children:p})})]})},x=c.memo((({layout:e,tikTokAccountId:t,feedSettings:s,onAccountInfoChange:r,syncingVideos:n=!1,showFallbackPreview:o=!1})=>{const[i,d]=a.useState(null),[x,m]=a.useState(!1),[g,p]=a.useState([]),f=c.useRef(null),[v,w]=a.useState(null),[y,j]=a.useState(0),[b,k]=a.useState(!1),[N,C]=a.useState(0),_=a.useRef(null),L=a.useRef({layout:e,tikTokAccountId:t,syncingVideos:n}),[M,T]=a.useState({is_premium:!1,is_free_plan:!0});a.useEffect((()=>{L.current.layout===e&&L.current.tikTokAccountId===t&&L.current.syncingVideos===n||(s&&Object.keys(s).length,L.current={layout:e,tikTokAccountId:t,syncingVideos:n})}),[e,t,s,n,o]),a.useEffect((()=>{(async()=>{try{const e=B(),t=await fetch(`${e.apiBase}/freemius-status`,{method:"GET",headers:{"X-WP-Nonce":e.nonce}});if(t.ok){const e=await t.json();return void T(e)}}catch(e){}window.etfFreemius&&T(window.etfFreemius)})()}),[]);const B=()=>window.etfAdmin?{apiBase:window.etfAdmin.apiBase,nonce:window.etfAdmin.nonce}:window.etfFrontend?{apiBase:window.etfFrontend.apiBase,nonce:window.etfFrontend.nonce}:{apiBase:"/wp-json/easy-tiktok-feed/v1",nonce:""},[P,I]=a.useState([]),[A,E]=a.useState("undefined"!=typeof window?window.innerWidth:1200);a.useEffect((()=>{const e=()=>{E(window.innerWidth)};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)}),[]),a.useEffect((()=>{const e=[{height:A<768?200:300,cols:1},{height:A<768?150:225,cols:1},{height:A<768?175:275,cols:1}];I(Array.from({length:20},((t,s)=>({...e[s%e.length],id:s}))))}),[A]),a.useEffect((()=>{i&&r&&r(i)}),[i,r]),a.useEffect((()=>{(async()=>{!n&&t&&await S(t)})()}),[n,t]),a.useEffect((()=>{if(f.current===t)return;if(!t)return;f.current=t;(async()=>{try{m(!0);const e=B();if(!e.apiBase)return;e.apiBase;const s=await fetch(`${e.apiBase}/tiktok-accounts`,{headers:{"X-WP-Nonce":e.nonce}});if(!s.ok)throw new Error(`Failed to fetch accounts: ${s.status}`);const r=await s.json(),n=r.find((e=>e.id.toString()===t.toString()));n&&(d(n),await S(n.id))}catch(e){}finally{m(!1)}})()}),[t]);const S=async e=>{if(e)try{const t=B();if(!t.apiBase)return;const s=await fetch(`${t.apiBase}/tiktok-videos/${e}`,{headers:{"X-WP-Nonce":t.nonce}});if(!s.ok)throw new Error(`Failed to fetch videos: ${s.status}`);const r=await s.json();r&&r.profile&&d((e=>({...e,profile:r.profile}))),r&&r.videos&&Array.isArray(r.videos)?(r.videos.length,p(r.videos)):p([])}catch(t){p([])}},z=e=>{if(!((null==s?void 0:s.enableVideoPopup)&&!M.is_free_plan)&&e.share_url)return void window.open(e.share_url,"_blank");const t=g.findIndex((t=>t.id===e.id));w(e),j(t),k(!0)},R=a.useCallback((()=>{if(y>0){const e=y-1;j(e);const t=g[e];w(t)}}),[y,g]),O=a.useCallback((()=>{const e=(null==s?void 0:s.postsPerPage)?Math.min(s.postsPerPage,g.length):6;if(y{_.current&&clearTimeout(_.current);const e=(null==s?void 0:s.postsPerPage)?Math.min(s.postsPerPage,g.length):6;C((t=>t<=0?e-1:t-1))},V=()=>{_.current&&clearTimeout(_.current);const e=(null==s?void 0:s.postsPerPage)?Math.min(s.postsPerPage,g.length):6;C((t=>t>=e-1?0:t+1))};a.useEffect((()=>{if("carousel"!==e||!(null==s?void 0:s.autoPlay)||0===g.length)return void(_.current&&(clearTimeout(_.current),_.current=null));const t=s.interval||3e3,r=(null==s?void 0:s.postsPerPage)?Math.min(s.postsPerPage,g.length):6;_.current&&clearTimeout(_.current);return _.current=setTimeout((()=>{C((e=>e>=r-1?0:e+1))}),t),()=>{_.current&&(clearTimeout(_.current),_.current=null)}}),[N,e,g.length,null==s?void 0:s.autoPlay,null==s?void 0:s.interval,null==s?void 0:s.postsPerPage]);const W=()=>{const r=(null==s?void 0:s.postsPerPage)||6,n=!!window.etfFrontend;if(!t&&n)return l.jsx("div",{className:"p-4 text-center",children:l.jsxs("div",{className:"p-6 bg-gray-100 rounded-lg",children:[l.jsx("svg",{className:"w-16 h-16 mx-auto text-gray-400 mb-4",fill:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:l.jsx("path",{d:"M12 2C6.477 2 2 6.477 2 12c0 5.523 4.477 10 10 10s10-4.477 10-10c0-5.523-4.477-10-10-10zm0 18c-4.411 0-8-3.589-8-8s3.589-8 8-8 8 3.589 8 8-3.589 8-8 8zm0-14c-.552 0-1 .448-1 1v5c0 .552.448 1 1 1h4c.552 0 1-.448 1-1s-.448-1-1-1h-3V7c0-.552-.448-1-1-1z"})}),l.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-2",children:"No TikTok Account Connected"}),l.jsx("p",{className:"text-gray-600 mb-4",children:"This feed doesn't have a TikTok account connected yet."})]})});switch(e){case"masonry":return l.jsx("div",{className:"grid grid-cols-3 gap-4",children:Array.from({length:r},((e,t)=>l.jsx("div",{className:"bg-gray-200 rounded-lg"},t)))});case"grid":return l.jsx("div",{className:"grid grid-cols-3 gap-4",children:Array.from({length:r},((e,t)=>l.jsx("div",{className:"bg-gray-200 rounded-lg aspect-square"},t)))});case"carousel":const e=(null==s?void 0:s.slidesVisible)||3,t=100/e,n=Array.from({length:r}),o=[...n.slice(-e),...n,...n.slice(0,e)],i=-(N+e)*t;return l.jsxs("div",{className:"relative",children:[l.jsx("div",{className:"overflow-hidden mb-4",children:l.jsx("div",{className:"carousel-track-preview flex transition-transform duration-300 ease-in-out",style:{transform:`translateX(${i}%)`},onTransitionEnd:()=>{if(-1===N){const e=document.querySelector(".carousel-track-preview");e&&(e.style.transition="none",C(r-1),setTimeout((()=>{e&&(e.style.transition="transform 300ms ease-in-out")}),50))}else if(N===r){const e=document.querySelector(".carousel-track-preview");e&&(e.style.transition="none",C(0),setTimeout((()=>{e&&(e.style.transition="transform 300ms ease-in-out")}),50))}},children:o.map(((e,s)=>l.jsx("div",{className:"flex-shrink-0 px-2",style:{width:`${t}%`},children:l.jsx("div",{className:"h-auto md:h-48 bg-gray-200 rounded-lg"})},`dummy-slide-${s}`)))})}),(null==s?void 0:s.showNavigation)&&l.jsxs(l.Fragment,{children:[l.jsx("button",{onClick:D,className:"absolute left-0 top-1/2 transform -translate-y-1/2 bg-white bg-opacity-70 rounded-full p-2 shadow-md z-10",children:l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6 text-gray-800",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),l.jsx("button",{onClick:V,className:"absolute right-0 top-1/2 transform -translate-y-1/2 bg-white bg-opacity-70 rounded-full p-2 shadow-md z-10",children:l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6 text-gray-800",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]}),(null==s?void 0:s.showDots)&&l.jsx("div",{className:"flex justify-center space-x-2 mt-2",children:Array.from({length:r}).map(((e,t)=>l.jsx("div",{onClick:()=>C(t),className:"h-2 w-2 rounded-full cursor-pointer "+((N%r+r)%r===t?"bg-indigo-600":"bg-gray-300")},t)))})]});case"list":return l.jsx("div",{className:"space-y-4",children:Array.from({length:Math.min(r,4)},((e,t)=>l.jsxs("div",{className:"flex space-x-4 bg-gray-200 rounded-lg p-4",children:[l.jsx("div",{className:"w-32 h-32 bg-gray-300 rounded"}),l.jsxs("div",{className:"flex-1 space-y-2",children:[l.jsx("div",{className:"h-4 bg-gray-300 rounded w-3/4"}),l.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[l.jsx("div",{className:"h-3 bg-gray-300 rounded w-16"}),l.jsx("div",{className:"h-3 bg-gray-300 rounded w-14"}),l.jsx("div",{className:"h-3 bg-gray-300 rounded w-20"}),l.jsx("div",{className:"h-3 bg-gray-300 rounded w-12"})]})]})]},t)))});default:return null}};return l.jsxs("div",{className:"bg-white rounded-lg shadow",children:[l.jsx(h,{accountInfo:i,feedSettings:s}),l.jsx("div",{className:"p-2 md:p-6",children:l.jsx("div",{className:"aspect-video rounded-md overflow-auto",children:x?l.jsx("div",{className:"flex justify-center items-center h-full",children:l.jsxs("div",{className:"text-center",children:[l.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-indigo-600 mx-auto mb-2"}),l.jsx("p",{className:"text-gray-500 text-sm",children:"Loading account data..."})]})}):i?n?l.jsx("div",{className:"flex justify-center items-center h-full",children:l.jsxs("div",{className:"text-center",children:[l.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-indigo-600 mx-auto mb-2"}),l.jsx("p",{className:"text-gray-500 text-sm",children:"Syncing videos from TikTok..."})]})}):g&&g.length>0?(()=>{if(!(g&&0!==g.length||o))return l.jsx("div",{className:"flex items-center justify-center h-full",children:l.jsx("p",{className:"text-gray-500 text-sm",children:"No videos available"})});const t=g&&g.length>0,r=(null==s?void 0:s.postsPerPage)?Math.min(s.postsPerPage,t?g.length:9):6;if(!t&&o)return W();switch(e){case"masonry":return l.jsx("div",{className:"grid gap-[10px] "+(A<640||A<768?"grid-cols-2":"grid-cols-3"),children:g.slice(0,r).map(((e,t)=>{const s=P[t]||{height:200};return l.jsx("div",{className:"rounded-lg overflow-hidden relative group",style:{gridRowEnd:`span ${Math.ceil(s.height/10)}`,height:`${s.height}px`},children:e.cover_image_url&&l.jsxs(l.Fragment,{children:[l.jsx("img",{src:e.cover_image_url,alt:e.title||"TikTok video",className:"w-full h-full object-cover"}),l.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black bg-opacity-0 group-hover:bg-opacity-30 transition-all cursor-pointer",onClick:()=>z(e),children:l.jsx("div",{className:"w-12 h-12 rounded-full bg-white bg-opacity-80 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-6 h-6 text-indigo-600",children:l.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})})})]})},e.id||t)}))});case"grid":return l.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:g.slice(0,r).map(((e,t)=>l.jsx("div",{className:"bg-gray-200 rounded-lg overflow-hidden",children:l.jsx("div",{className:"aspect-square overflow-hidden relative group",children:e.cover_image_url&&l.jsxs(l.Fragment,{children:[l.jsx("img",{src:e.cover_image_url,alt:e.title||"TikTok video",className:"w-full h-full object-cover"}),l.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black bg-opacity-0 group-hover:bg-opacity-30 transition-all cursor-pointer",onClick:()=>z(e),children:l.jsx("div",{className:"w-12 h-12 rounded-full bg-white bg-opacity-80 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-6 h-6 text-indigo-600",children:l.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})})})]})})},t)))});case"carousel":const e=(null==s?void 0:s.slidesVisible)||3,t=100/e,n=g.slice(0,r),o=[...n.slice(-e),...n,...n.slice(0,e)],i=-(N+e)*t;return l.jsxs("div",{className:"relative",children:[l.jsx("div",{className:"overflow-hidden mb-4",children:l.jsx("div",{className:"carousel-track flex transition-transform duration-300 ease-in-out",style:{transform:`translateX(${i}%)`},onTransitionEnd:()=>{if(-1===N){const e=document.querySelector(".carousel-track");e&&(e.style.transition="none",C(r-1),setTimeout((()=>{e&&(e.style.transition="transform 300ms ease-in-out")}),50))}else if(N===r){const e=document.querySelector(".carousel-track");e&&(e.style.transition="none",C(0),setTimeout((()=>{e&&(e.style.transition="transform 300ms ease-in-out")}),50))}},children:o.map(((e,s)=>l.jsx("div",{className:"flex-shrink-0 px-2",style:{width:`${t}%`},children:l.jsx("div",{className:"bg-gray-200 rounded-lg overflow-hidden",children:l.jsx("div",{className:"h-auto md:h-48 overflow-hidden relative group",children:e.cover_image_url&&l.jsxs(l.Fragment,{children:[l.jsx("img",{src:e.cover_image_url,alt:e.title||"TikTok video",className:"w-full h-full object-cover"}),l.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black bg-opacity-0 group-hover:bg-opacity-30 transition-all cursor-pointer",onClick:()=>z(e),children:l.jsx("div",{className:"w-12 h-12 rounded-full bg-white bg-opacity-80 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-6 h-6 text-indigo-600",children:l.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})})})]})})})},`slide-${s}`)))})}),(null==s?void 0:s.showNavigation)&&l.jsxs(l.Fragment,{children:[l.jsx("button",{onClick:D,className:"absolute left-0 top-1/2 transform -translate-y-1/2 bg-white bg-opacity-70 hover:bg-opacity-100 rounded-full p-2 shadow-md z-10",children:l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6 text-gray-800",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),l.jsx("button",{onClick:V,className:"absolute right-0 top-1/2 transform -translate-y-1/2 bg-white bg-opacity-70 hover:bg-opacity-100 rounded-full p-2 shadow-md z-10",children:l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6 text-gray-800",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]}),(null==s?void 0:s.showDots)&&l.jsx("div",{className:"flex justify-center space-x-2 mt-2",children:g.slice(0,r).map(((e,t)=>l.jsx("div",{onClick:()=>C(t),className:"h-2 w-2 rounded-full cursor-pointer "+((N%r+r)%r===t?"bg-indigo-600":"bg-gray-300")},t)))})]});case"list":return l.jsx("div",{className:"space-y-4",children:g.slice(0,r).map(((e,t)=>l.jsxs("div",{className:"flex space-x-4 rounded-lg shadow-md py-1",children:[l.jsx("div",{className:"w-32 h-32 rounded overflow-hidden relative group",children:e.cover_image_url&&l.jsxs(l.Fragment,{children:[l.jsx("img",{src:e.cover_image_url,alt:e.title||"TikTok video",className:"w-full h-full object-cover"}),l.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black bg-opacity-0 group-hover:bg-opacity-30 transition-all cursor-pointer",onClick:()=>z(e),children:l.jsx("div",{className:"w-10 h-10 rounded-full bg-white bg-opacity-80 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-5 h-5 text-indigo-600",children:l.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})})})]})}),l.jsx("div",{className:"flex-1 space-y-2",children:l.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1 text-xs text-gray-500",children:[(null==s?void 0:s.showViewCount)&&e.view_count?l.jsxs("div",{className:"flex items-center",children:[l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-3.5 w-3.5 mr-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:[l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]}),l.jsxs("span",{children:[e.view_count," views"]})]}):null,(null==s?void 0:s.showLikes)&&e.like_count?l.jsxs("div",{className:"flex items-center",children:[l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-3.5 w-3.5 mr-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z"})}),l.jsxs("span",{children:[e.like_count," likes"]})]}):null,(null==s?void 0:s.showComments)&&e.comment_count?l.jsxs("div",{className:"flex items-center",children:[l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-3.5 w-3.5 mr-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),l.jsxs("span",{children:[e.comment_count," comments"]})]}):null,(null==s?void 0:s.showShares)&&e.share_count?l.jsxs("div",{className:"flex items-center",children:[l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-3.5 w-3.5 mr-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8.684 13.342C8.886 12.938 9 12.482 9 12c0-.482-.114-.938-.316-1.342m0 2.684a3 3 0 110-2.684m0 2.684l6.632 3.316m-6.632-6l6.632-3.316m0 0a3 3 0 105.367-2.684 3 3 0 00-5.367 2.684zm0 9.316a3 3 0 105.368 2.684 3 3 0 00-5.368-2.684z"})}),l.jsxs("span",{children:[e.share_count," shares"]})]}):null,(null==s?void 0:s.showDate)&&e.create_time?l.jsxs("div",{className:"flex items-center",children:[l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-3.5 w-3.5 mr-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})}),l.jsx("span",{children:new Date(1e3*e.create_time).toLocaleDateString()})]}):null]})})]},t)))});default:return null}})():W():W()})}),l.jsx(u,{isOpen:b,onClose:()=>{k(!1),setTimeout((()=>w(null)),300)},onNext:O,onPrevious:R,isFirst:0===y,isLast:y===Math.min((null==s?void 0:s.postsPerPage)||6,g.length)-1,isPremium:!M.is_free_plan&&(null==s?void 0:s.enableVideoPopup),children:v&&l.jsx("div",{video:v})})]})}));export{x as L,d as R,c as a,l as j,a as r};