1import{j as a,r as l,e as an}from"./vendor-react-DO6Up8DA.js";import{u as Ae,e as sn}from"./vendor-redux-DS2atDyC.js";import{e as dt,Q as De,f as $e,X as ut,cr as on,en as ln,eo as rn,o as cn}from"./index-J9gu9H_Z.js";import{c as St}from"./copy-BeLnjvtU.js";import{t as Lt}from"./talent-B9ILWvhu.js";import{X as dn,L as un,aI as mn,ad as hn,bz as _e,e as fn,q as pn,a as _n,bh as gn,x as ft,bN as yn}from"./vendor-lucide-D2UFZrVp.js";import{u as bn}from"./useVideoFramePoster-Bsj5hI_b.js";const At=l.createContext(null);function Za({children:e}){const t=Ae(n=>dt(n));return a.jsx(At.Provider,{value:t,children:e})}function It(){const e=l.useContext(At),t=Ae(n=>dt(n));return e??t}const X="https://cdn.getphyllo.com/platforms_logo/logos",ge=[{id:"instagram",label:"Instagram",tagline:"Reels, posts & stories",accent:"pink",iconUrl:`${X}/logo_instagram.png`},{id:"tiktok",label:"TikTok",tagline:"Short-form video stats",accent:"cyan",iconUrl:`${X}/logo_tiktok.png`},{id:"youtube",label:"YouTube",tagline:"Channel & video analytics",accent:"red",iconUrl:`${X}/logo_youtube.png`},{id:"facebook",label:"Facebook",tagline:"Pages & post engagement",accent:"blue",iconUrl:`${X}/logo_facebook.png`},{id:"x",label:"X",tagline:"Posts & social engagement",accent:"slate",iconUrl:`${X}/logo_x.png`},{id:"twitch",label:"Twitch",tagline:"Streams & channel stats",accent:"purple",iconUrl:`${X}/logo_twitch.png`},{id:"substack",label:"Substack",tagline:"Newsletter content stats",accent:"orange",iconUrl:`${X}/logo_substack.png`},{id:"beehiiv",label:"Beehiiv",tagline:"Newsletter & publication stats",accent:"green",iconUrl:`${X}/logo_beehiiv.png`}],Rt=[{target:{platform:"instagram",flow:"direct"},label:"Instagram",shortLabel:"Instagram",description:"Connect your Instagram account for reels, posts, and story stats."},{target:{platform:"tiktok"},label:"TikTok",shortLabel:"TikTok",description:"Connect your TikTok creator account for video stats.",badge:"Popular"},{target:{platform:"youtube"},label:"YouTube",shortLabel:"YouTube",description:"Connect your YouTube channel for video performance data."},{target:{platform:"facebook"},label:"Facebook",shortLabel:"Facebook",description:"Connect a Facebook Page to sync posts and engagement metrics."},{target:{platform:"x"},label:"X (Twitter)",shortLabel:"X",description:"Connect your X account for post and engagement analytics."},{target:{platform:"twitch"},label:"Twitch",shortLabel:"Twitch",description:"Connect your Twitch channel for stream and content stats."},{target:{platform:"substack"},label:"Substack",shortLabel:"Substack",description:"Connect your Substack publication for newsletter content stats."},{target:{platform:"beehiiv"},label:"Beehiiv",shortLabel:"Beehiiv",description:"Connect your Beehiiv publication for content performance data."}],kn={direct:["instagram direct"],lite:["instagram lite"],graph:["instagram","instagram graph"]},vn={instagram:["instagram direct","instagram lite","instagram"],tiktok:["tiktok"],youtube:["youtube"],facebook:["facebook"],x:["x"],twitch:["twitch"],substack:["substack"],beehiiv:["beehiiv"]},Dt={instagram:"Instagram",tiktok:"TikTok",youtube:"YouTube",facebook:"Facebook",x:"X",twitch:"Twitch",substack:"Substack",beehiiv:"Beehiiv"},Nn={"instagram-direct":"d3badb09-a81f-4444-bc27-1a994d939e00","instagram-graph":"9bb8913b-ddd9-430b-a66a-d74d846e6c66","instagram-lite":"fb7cafcf-60ed-468a-ad6d-6bb6899d0871",tiktok:"de55aeec-0dc8-4119-bf90-16b3d1f0c987",youtube:"14d9ddf5-51c6-415e-bde6-f8ed36ad7054",facebook:"ad2fec62-2987-40a0-89fb-23485972598c",x:"7645460a-96e0-4192-a3ce-a1fc30641f72",twitch:"e4de6c01-5b78-4fc0-a651-24f44134457b",substack:"fbf76083-710b-439a-8b8c-956f607ef2c1",beehiiv:"24fcaa09-0a79-4deb-b074-d8efd900265b"};function $t(e){return Rt.filter(t=>t.target.platform===e)}function Cn(e){return vn[e]}function lt(e){return Dt[e]}function xn(e){const t=ke(e),n=Nn[t];if(!n)throw new Error(`No Phyllo work platform id configured for ${t}`);return n}function wn(e){if(!e)return null;const t=e.trim().toLowerCase();return Object.entries(Dt).find(([,s])=>s.toLowerCase()===t)?.[0]??null}function ke(e){return e.platform==="instagram"?`instagram-${e.flow}`:e.platform}function Ot(e){return Rt.find(n=>ke(n.target)===ke(e))?.label??e.platform}function jn(e){return e.platform}function Pn(e,t){if(!e)return!1;const n=e.toLowerCase().trim();return t.platform==="instagram"?kn[t.flow].includes(n):n===t.platform}function Ft(e,t){const n=e.work_platform?.name?.toLowerCase().trim()??"";return t==="instagram"?n.includes("instagram"):Cn(t).includes(n)}function ve(e){const t=String(e??"").trim().toUpperCase();return t==="PENDING"||t==="APPROVED"||t==="REJECTED"?t:null}function O(e,t){let n=null,s=!1;for(const o of e){if(!Ft(o,t))continue;const i=ve(o.status);if(!i){s=!0;continue}if(i==="APPROVED")return"APPROVED";i==="PENDING"?n="PENDING":i==="REJECTED"&&n==null&&(n="REJECTED")}return n||(s?"APPROVED":null)}function Ie(e,t){return O(e,t)!=null}function at(e,t){return O(e,t)==="APPROVED"}function Ut(e,t){const n=O(e,t);return n==="APPROVED"||n==="REJECTED"}function rt(e,t){const n=O(e,t);return n!=="APPROVED"&&n!=="REJECTED"?null:e.find(o=>Ft(o,t)?ve(o.status)===n:!1)??null}const Tn={approved:"Live",pending:"Pending",rejected:"Rejected"};function En(e,t=Tn){return e==="APPROVED"?{label:t.approved,className:"is_approved"}:e==="PENDING"?{label:t.pending,className:"is_pending"}:e==="REJECTED"?{label:t.rejected,className:"is_rejected"}:null}const Sn=["youtube","substack","beehiiv"];function Mt(e){return Sn.includes(e)?"Subscribers":"Followers"}function Ln(e){const t=e.toLowerCase();return t.includes("instagram")?"pink":t.includes("tiktok")?"cyan":t.includes("youtube")?"red":t.includes("facebook")?"blue":t==="x"?"slate":t.includes("twitch")?"purple":t.includes("substack")?"orange":t.includes("beehiiv")?"green":"slate"}async function An(e){return xn(e)}function mt(e){return`phyllo_user_id_${e.toLowerCase()}`}function In(e){return localStorage.getItem(mt(e))}function pt(e,t){localStorage.setItem(mt(e),t)}function ye(){try{localStorage.removeItem("talent_platforms_v1")}catch{}ie=null}function Rn(e){localStorage.removeItem(mt(e)),zt(),ye()}const ht="phyllo_sdk_token_v1",Dn=300*1e3;function Gt(e){if(!e)return null;const t=/[Zz]|[+-]\d{2}:?\d{2}$/.test(e),n=Date.parse(t?e:`${e}Z`);return Number.isFinite(n)?n:null}function zt(){try{localStorage.removeItem(ht)}catch{}}function $n(){try{const e=localStorage.getItem(ht);if(!e)return null;const t=JSON.parse(e);
1if(!t?.token||!t?.userId||!t?.expirationTime||t.authToken!==localStorage.getItem("auth-token"))return null;const n=Gt(t.expirationTime);return n==null||Date.now()>n-Dn?null:{token:t.token,userId:t.userId,expirationTime:t.expirationTime}}catch{return null}}function On(e){try{const t={...e,authToken:localStorage.getItem("auth-token")};localStorage.setItem(ht,JSON.stringify(t))}catch{}}function Fn(...e){for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Un(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function Mn(e){if(!e||typeof e!="object")return null;const t=e,n=[t.data,t._data].map(Un).filter(f=>!!f),s=(...f)=>{const v=f.map(N=>t[N]),g=n.flatMap(N=>f.map(u=>N[u]));return Fn(...v,...g)},o=s("token","sdk_token","sdkToken"),i=s("userId","user_id","phylloUserId","phyllo_user_id"),d=s("expirationTime","expiration_time","expires_at","expiresAt");return!o||!i||!d||Gt(d)==null?null:{token:o,userId:i,expirationTime:d}}async function _t(e){{const s=$n();if(s)return s}const t=await De({url:$e.phyllo_talents_auth_url,method:"POST",auth:!0,recoverAuth:!0,interactiveRecovery:!0});if(t?.error)throw new Error(typeof t.error=="string"?t.error:"Failed to get Phyllo Connect token");const n=Mn(t?.data??t);if(!n)throw new Error("Invalid talents/auth response â expected { token, userId, expirationTime }");return On(n),n}let ie=null;function Gn(e){const t=e?.data;if(Array.isArray(t))return t;if(t&&typeof t=="object"){const s=t;if(Array.isArray(s._data))return s._data;if(Array.isArray(s.data))return s.data}const n=e;return Array.isArray(n?._data)?n._data:[]}function Vt(e){return e.filter(t=>!!(t?.accountId&&t?.socialPlatformName)).map(t=>({id:t.accountId,status:ve(t.status)??void 0,work_platform:{name:t.socialPlatformName.toLowerCase().trim(),id:t.profileId??void 0}}))}function gt(e){const t={};for(const n of e){if(ve(n.status)==="REJECTED")continue;const o=n.socialPlatformName?.toLowerCase().trim()??"";let i=null;if(o.includes("instagram")?i="instagram":o.includes("tiktok")?i="tiktok":o.includes("youtube")?i="youtube":o.includes("facebook")?i="facebook":o==="x"||o.includes("twitter")?i="x":o.includes("twitch")?i="twitch":o.includes("substack")?i="substack":o.includes("beehiiv")&&(i="beehiiv"),!i)continue;const d=Number(i==="youtube"||i==="substack"||i==="beehiiv"?n.subscribersCount??n.followersCount:n.followersCount);t[i]=Number.isFinite(d)?d:0}return t}async function Bt(e){if(ie)return ie;const t=(async()=>{const n=await De({url:$e.phyllo_talents_platforms_url,method:"GET",auth:!0,recoverAuth:!0});if(n?.error)throw new Error(typeof n.error=="string"?n.error:"Failed to load connected platforms");return Gn(n)})();ie=t;try{return await t}finally{ie===t&&(ie=null)}}async function zn(e){const t=String(e??"").trim();if(!t)throw new Error("Missing accountId for platform disconnect");const n=$e.phyllo_talents_platforms_disconnect_url.replace(/\/$/,""),s=await De({url:`${n}/${encodeURIComponent(t)}`,method:"DELETE",auth:!0,recoverAuth:!0,interactiveRecovery:!0});if(s?.error)throw new Error(typeof s.error=="string"?s.error:"Failed to disconnect social platform")}async function Vn(e,t){let o=[],i=[];for(let d=0;d<4;d+=1){ye(),i=await Bt(),o=Vt(i);const f=O(o,e);if(f==="APPROVED"||f==="REJECTED"||f==="PENDING")return{accounts:o,platforms:i};d<3&&await new Promise(v=>{window.setTimeout(v,1200)})}return{accounts:o,platforms:i}}const Bn="Historic content backfill is not available yet. Use Refresh stats to reload synced posts.";function Yn(e){const t=e??{},n=[t.data,t._data,e];for(const s of n){if(!s)continue;if(Array.isArray(s))return{All:s};if(typeof s!="object")continue;const o=s;if(o._data&&typeof o._data=="object"&&!Array.isArray(o._data))return o._data;if(Array.isArray(o._data))return{All:o._data};if(o.data&&typeof o.data=="object"&&!Array.isArray(o.data))return o.data;if(Array.isArray(o.data))return{All:o.data};const i=Object.entries(o).filter(([,d])=>Array.isArray(d));if(i.length>0)return Object.fromEntries(i)}return{}}function Wn(e,t){const n=typeof e.format=="string"?e.format.trim().toUpperCase():"";if(n==="VIDEO"||n==="IMAGE")return n;const s=`${e.mediaUrl??""} ${e.url??""} ${e.thumbnail??""}`.toLowerCase();if(/\.(mp4|mov|webm|m3u8)(\?|#|$)/.test(s))return"VIDEO";if(/\.(jpe?g|png|gif|webp)(\?|#|$)/.test(s))return"IMAGE";const o=t.toLowerCase();if(o.includes("tiktok")||o.includes("youtube")||o.includes("twitch"))return"VIDEO";if(e.thumbnail||e.mediaUrl)return"IMAGE"}function Kn(e,t){const n=e.platformName?.trim()||t,s=typeof e.url=="string"?e.url:"",o=typeof e.publishedAt=="string"?e.publishedAt:"",i=typeof e.title=="string"&&e.title.trim()||typeof e.description=="str
1ing"&&e.description.trim()||"",d=typeof e.mediaUrl=="string"&&e.mediaUrl.trim()?e.mediaUrl.trim():void 0,f=Wn(e,n);return{id:s||d||`${n}:${o}:${i.slice(0,32)}`,platform:n,caption:i,url:s,publishedAt:o,thumbnailUrl:typeof e.thumbnail=="string"?e.thumbnail:void 0,mediaUrl:d,contentFormat:f,likes:typeof e.likes=="number"?e.likes:void 0,comments:typeof e.comments=="number"?e.comments:void 0,shares:typeof e.shares=="number"?e.shares:void 0,views:typeof e.views=="number"?e.views:void 0,saves:typeof e.saves=="number"?e.saves:void 0,clicks:typeof e.clicks=="number"?e.clicks:void 0,profileUrl:typeof e.profileUrl=="string"?e.profileUrl:void 0,campaign:Hn(e)}}function Hn(e){const t=e.campaign;if(!t||typeof t!="object")return;const n=typeof t.hits=="number"?t.hits:typeof t.clicks=="number"?t.clicks:void 0,s=typeof t.users=="number"?t.users:void 0,o=typeof t.earned=="number"?t.earned:void 0,i=typeof t.code=="string"&&t.code.trim()?t.code.trim():void 0,d=typeof t.link=="string"&&t.link.trim()?t.link.trim():void 0,f=typeof t.title=="string"?t.title:void 0;if(!(i===void 0&&d===void 0&&f===void 0&&n===void 0&&s===void 0&&o===void 0))return{code:i,link:d,title:f,hits:n,users:s,earned:o}}function Yt(e,t){const n=t?lt(t).toLowerCase():null,s=[];for(const[o,i]of Object.entries(e)){if(!Array.isArray(i)||n&&o!=="All"&&o.toLowerCase()!==n)continue;const d=wn(o)??t??"tiktok";for(const f of i){const v=Kn(f,lt(d));n&&v.platform.toLowerCase()!==n||s.push(v)}}return s}async function Wt(e=""){const t=$e.phyllo_talents_contents_url.replace(/\/$/,""),n=await De({url:e?`${t}/${encodeURIComponent(e)}`:t,method:"GET",auth:!0,recoverAuth:!0});if(n?.error)throw new Error(typeof n.error=="string"?n.error:"Failed to load talent content");return Yn(n)}async function yt(){const e=await Wt();return Yt(e)}async function Jn(e,t,n){const s=lt(t),o=await Wt(s);return Yt(o,t)}async function Xn(e,t,n){throw new Error(Bn)}function Zn(e=1){const t=new Date;return t.setFullYear(t.getFullYear()-e),t.toISOString().slice(0,10)}const Kt="phyllo_post_tracking_links_v1";function Ht(){if(typeof window>"u")return{};try{const e=localStorage.getItem(Kt);if(!e)return{};const t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return{}}}function qn(e){typeof window>"u"||localStorage.setItem(Kt,JSON.stringify(e))}function Qn(e,t){const s=e.replace(/[^a-zA-Z0-9]/g,"").slice(-10)||crypto.randomUUID().replace(/-/g,"").slice(0,10);return`${t.replace(/[^a-z0-9]/gi,"").slice(0,4).toLowerCase()||"post"}-${s}`.toLowerCase()}function ea(e,t,n){const s=new URLSearchParams({post:n,src:"sctnlt"});return`${e}/t/${t}?${s.toString()}`}function be(e){return Ht()[e]??null}async function ta(e){const t=be(e.postId);if(t)return t;await new Promise(d=>{window.setTimeout(d,520)});const n=typeof window<"u"?window.location.origin:"https://playw3.com",s=Qn(e.postId,e.platform),o={trackingUrl:ea(n,s,e.postId),trackingCode:s,postId:e.postId,platform:e.platform,createdAt:new Date().toISOString(),statsApiPath:`/v1/talent/post-links/${s}/stats`},i=Ht();return i[e.postId]=o,qn(i),o}function Y(e){return e==null||Number.isNaN(e)?"0":e>=1e6?`${(e/1e6).toFixed(1).replace(/\.0$/,"")}M`:e>=1e4?`${Math.round(e/1e3)}K`:e>=1e3?`${(e/1e3).toFixed(1).replace(/\.0$/,"")}K`:String(e)}function na(e){if(!e||e<=0)return null;if(e>=3600){const t=Math.floor(e/3600),n=Math.floor(e%3600/60);return`${t}:${String(n).padStart(2,"0")}h`}if(e>=60){const t=Math.floor(e/60),n=e%60;return`${t}:${String(n).padStart(2,"0")}`}return`${e}s`}function bt(e){return!e||Number.isNaN(e)?"0%":`${e.toFixed(1).replace(/\.0$/,"")}%`}const aa=/T\d{2}:\d{2}/;function sa(e){if(!e)return"Date unavailable";const t=new Date(e);if(Number.isNaN(t.getTime()))return"Date unavailable";const n=t.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"});if(!aa.test(e))return n;const s=t.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"});return`${n} · ${s}`}const oa=[{key:"clicks",label:"Clicks",shortLabel:"Clicks"},{key:"signups",label:"Signups",shortLabel:"Signups"},{key:"earned",label:"G Earned",shortLabel:"G Earned"}];function la(e,t){const n=t?.[e],s=typeof n=="number"&&!Number.isNaN(n)?n:0;return Y(s)}function ra(e,t){const n=t?.[e];return(typeof n=="number"&&!Number.isNaN(n)?n:0)===0}const ia=({stats:e,hasPostMetricsAbove:t=!0})=>a.jsx("div",{className:["phyllo_social_post_track_metrics",t?"":"is_standalone"].join(" ").trim(),role:"group","aria-label":"Tracking stats",children:oa.map(n=>a.jsxs("div",{className:["phyllo_social_stat","is_post","is_tracking",ra(n.key,e)?"is_zero":""].join(" ").trim(),children:[a.jsx("span",{className:"phyllo_social_stat_value",children:la(n.key,e)}),a.jsxs("span",{className:"phyllo_social_stat_label",title:n.label,children:[a.jsx("span",{className:"phyllo_social_stat_label_full",children:n.label}),a.jsx("span",{className:"phyllo_social_stat_label_short",children:n.shortLabel})]})]},n.key))}),ca=(e,t=72)=>{const n=e.trim();return n.length<=t?n:`${n.slice(0,t-1)}â¦`},da=({post:e,portalUserId:t,onClose:n,onLinkReady:s})=>{const{showSuccess:o,showError:i}=ut(),[d,f]=l.useState(()=>!be(e.id)),[v,g]=l.useState(()=>be(e.id)),[N,u]=l.useState(null);on(!0);const w=k=>{k.target===k.currentTarget&&n()},h=l.useCallback(async()=>{const k=be(e.id);if(k){g(k),u(null),f(!1),s?.();return}f(!0),u(null);try{const y=await ta({postId:e.id,platform:e.platform,portalUserId:t,caption:e.caption,postUrl:e.url});g(y),s?.()}catch(y){const Q=y instanceof Error?y.message:"Failed to generate tracking link";u(Q),i(Q)}finally{f(!1)}},[s,t,e,i]);l.useEffect(()=>{h()}
1,[h]),l.useEffect(()=>{const k=y=>{y.key==="Escape"&&n()};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[n]);const L=async()=>{if(v?.trackingUrl)try{await St(v.trackingUrl),o("Tracking link copied")}catch{i("Could not copy link")}};return typeof document>"u"?null:an.createPortal(a.jsx("div",{className:"phyllo_social_page phyllo_social_track_overlay",onClick:w,role:"presentation",children:a.jsxs("div",{className:"phyllo_social_track_popup",role:"dialog","aria-modal":"true","aria-labelledby":"phyllo-track-title",onClick:k=>k.stopPropagation(),children:[a.jsx("button",{type:"button",className:"phyllo_social_track_close",onClick:n,"aria-label":"Close",children:"Ã"}),a.jsxs("div",{className:"phyllo_social_track_head",children:[a.jsx("span",{className:"phyllo_social_track_badge",children:"Talent tracking"}),a.jsx("h3",{id:"phyllo-track-title",className:"phyllo_social_track_title",children:"Post tracking link"}),a.jsx("p",{className:"phyllo_social_track_sub",children:"Share this link to track clicks, signups and earned rewards from this post."})]}),a.jsxs("div",{className:"phyllo_social_track_post",children:[a.jsx("span",{className:"phyllo_social_track_post_label",children:"Post"}),a.jsx("p",{className:"phyllo_social_track_post_caption",children:ca(e.caption||"Untitled post")})]}),d?a.jsxs("div",{className:"phyllo_social_track_loading","aria-live":"polite",children:[a.jsx("span",{className:"phyllo_social_loading_spinner","aria-hidden":"true"}),a.jsx("p",{children:"Generating your tracking linkâ¦"})]}):null,!d&&N?a.jsxs("div",{className:"phyllo_social_track_error",children:[a.jsx("p",{children:N}),a.jsx("button",{type:"button",className:"phyllo_social_btn is_ghost is_compact",onClick:()=>void h(),children:"Try again"})]}):null,!d&&v?a.jsxs("div",{className:"phyllo_social_track_result",children:[a.jsx("label",{className:"phyllo_social_track_field_label",htmlFor:"phyllo-track-url",children:"Your link"}),a.jsxs("div",{className:"phyllo_social_track_field_row",children:[a.jsx("input",{id:"phyllo-track-url",className:"phyllo_social_track_field",readOnly:!0,value:v.trackingUrl}),a.jsx("button",{type:"button",className:"phyllo_social_btn is_primary is_compact",onClick:()=>void L(),children:"Copy"})]}),a.jsx("p",{className:"phyllo_social_track_hint",children:"Tracking stats appear on the post card below post engagement."})]}):null]})}),document.body)},ua="route_home_page",ma=/^[a-zA-Z0-9_\s]{2,255}$/;function Jt(e){const t=e.trim();return t.length<2?{ok:!1,message:"Title must be at least 2 characters."}:t.length>255?{ok:!1,message:"Title must be 255 characters or fewer."}:ma.test(t)?{ok:!0}:{ok:!1,message:"Use only letters, numbers, spaces, and underscores."}}const Re=e=>{if(!e||typeof e!="object")return!1;const t=e;return typeof t.code=="string"&&typeof t.title=="string"&&typeof t.link=="string"&&typeof t.dateCreated=="string"},ha=e=>{const t=e;if(!t)return[];const n=[t,t.data];for(const s of n){if(!s||typeof s!="object")continue;const o=s;if(Array.isArray(o._data))return o._data.filter(Re)}return Array.isArray(t._data)?t._data.filter(Re):[]};async function qa(){const e=await Lt.getCampaigns();if(e?.error)throw new Error(typeof e.error=="string"?e.error:"Failed to load campaign links");return ha(e.data).sort((n,s)=>new Date(s.dateCreated).getTime()-new Date(n.dateCreated).getTime())}const fa=e=>{const t=e;if(!t||typeof t!="object")return null;if(Re(t._data))return t._data;const n=t.data?._data;return Re(n)?n:null};async function pa(e){const t=Jt(e.title);if(!t.ok)throw new Error(t.message);const n=await Lt.createCampaign({title:e.title.trim(),target:e.target});if(n?.error)throw new Error(typeof n.error=="string"?n.error:"Failed to create campaign link");const s=fa(n.data);if(!s)throw new Error("Unexpected response when creating campaign");return s}const Z=(e,t,n)=>{const s=String(e[t]??"").trim();return!s||s===t||/^(td_|id_)[a-z0-9_]+$/i.test(s)?n:s},_a=({open:e,onClose:t,onCreated:n})=>{const s=It(),o=l.useId(),[i,d]=l.useState(""),[f,v]=l.useState(null),[g,N]=l.useState(null),[u,w]=l.useState(!1);l.useEffect(()=>{if(e)return ln(),()=>rn()},[e]),l.useEffect(()=>{e||(d(""),v(null),N(null),w(!1))},[e]);const h=l.useCallback(()=>{u||t()},[t,u]),L=l.useCallback(async()=>{const k=Jt(i);if(!k.ok){v(k.message);return}v(null),N(null),w(!0);try{const y=await pa({title:i.trim(),target:ua});n(y),t()}catch(y){N(y instanceof Error?y.message:Z(s,"td_campaigns_create_error","Could not create campaign."))}finally{w(!1)}},[t,n,s,i]);return e?a.jsx("div",{className:"td_campaigns_modal_overlay",role:"presentation",onClick:h,children:a.jsxs("div",{className:"td_campaigns_modal",role:"dialog","aria-modal":"true","aria-labelledby":"td-campaigns-create-title",onClick:k=>k.stopPropagation(),children:[a.jsx("button",{type:"button",className:"td_campaigns_modal_close","aria-label":Z(s,"td_campaigns_modal_close","Close"),onClick:h,disabled:u,children:a.jsx(dn,{size:20})}),a.jsxs("header",{className:"td_campaigns_modal_head",children:[a.jsx("h2",{id:"td-campaigns-create-title",children:Z(s,"td_campaigns_create_title","Create campaign link")}),a.jsx("p",{children:Z(s,"td_campaigns_create_desc","Name your campaign. Weâll generate a tracking link y
1ou can share.")})]}),a.jsxs("form",{className:"td_campaigns_modal_form",onSubmit:k=>{k.preventDefault(),L()},children:[a.jsxs("label",{className:"td_campaigns_field",htmlFor:o,children:[a.jsx("span",{children:Z(s,"td_campaigns_field_title","Campaign title")}),a.jsx("input",{id:o,type:"text",value:i,maxLength:255,autoComplete:"off",placeholder:Z(s,"td_campaigns_field_title_ph","e.g. My Lovely Campaign"),disabled:u,onChange:k=>{d(k.target.value),f&&v(null)}})]}),f?a.jsx("p",{className:"td_campaigns_field_error",role:"alert",children:f}):null,g?a.jsx("p",{className:"td_campaigns_field_error",role:"alert",children:g}):null,a.jsxs("div",{className:"td_campaigns_modal_actions",children:[a.jsx("button",{type:"button",className:"td_btn td_btn_ghost",onClick:h,disabled:u,children:Z(s,"td_campaigns_cancel","Cancel")}),a.jsxs("button",{type:"submit",className:"td_btn td_btn_primary",disabled:u,children:[u?a.jsx(un,{size:16,className:"td_campaigns_spin","aria-hidden":"true"}):null,Z(s,"td_campaigns_create_submit","Create link")]})]})]})]})}):null},kt="td_content_last_campaign_link",q=(e,t,n)=>{const s=String(e[t]??"").trim();return!s||s===t||/^(td_|id_)[a-z0-9_]+$/i.test(s)?n:s},ga=()=>{const e=It(),{showSuccess:t,showError:n}=ut(),[s,o]=l.useState(null),[i,d]=l.useState(!1);l.useEffect(()=>{try{const N=sessionStorage.getItem(kt);N&&o(N)}catch{}},[]);const f=l.useCallback(N=>{o(N);try{sessionStorage.setItem(kt,N)}catch{}},[]),v=l.useCallback(N=>{f(N.link),t(q(e,"td_content_campaign_generated","Campaign link ready â copy it into your post."))},[f,t,e]),g=l.useCallback(()=>{if(s)try{St(s),t(q(e,"td_campaigns_copied","Campaign link copied"))}catch{n(q(e,"td_notify_copy_failed","Copy failed"))}},[s,n,t,e]);return a.jsxs("div",{className:"td_content_campaign_bar","aria-label":q(e,"td_content_campaign_bar_aria","Campaign link for social posts"),children:[a.jsx("p",{className:"td_content_campaign_note",children:q(e,"td_content_campaign_note","Please note: that in order to see posts, please attach the campaign link into the social post")}),a.jsx("div",{className:"td_content_campaign_actions",children:a.jsxs("button",{type:"button",className:"phyllo_social_btn is_primary is_compact",onClick:()=>d(!0),children:[a.jsx(mn,{size:15,strokeWidth:2.2,"aria-hidden":"true"}),q(e,"td_content_campaign_generate","Generate campaign link")]})}),s?a.jsxs("div",{className:"td_content_campaign_result",children:[a.jsx("input",{type:"text",className:"td_content_campaign_link_field",readOnly:!0,value:s,"aria-label":q(e,"td_content_campaign_link_aria","Generated campaign link")}),a.jsxs("button",{type:"button",className:"phyllo_social_btn is_ghost is_compact td_content_campaign_copy",onClick:g,children:[a.jsx(hn,{size:15,strokeWidth:2.1,"aria-hidden":"true"}),q(e,"td_content_campaign_copy","Copy link")]})]}):null,a.jsx(_a,{open:i,onClose:()=>d(!1),onCreated:v})]})},Se=new Map;async function ya(e){try{const t=await fetch(e,{referrerPolicy:"no-referrer",mode:"cors",credentials:"omit"});if(!t.ok)return null;const n=await t.blob();return URL.createObjectURL(n)}catch{return null}}function ba(e){const t=Se.get(e);if(t)return t;const n=ya(e);return Se.set(e,n),n.then(s=>{!s&&Se.get(e)===n&&Se.delete(e)}),n}function ka(e,t){const n=t?.enabled??!0,[s,o]=l.useState(void 0);return l.useEffect(()=>{if(!e||!n){o(void 0);return}let i=!1;return o(void 0),ba(e).then(d=>{i||o(d)}),()=>{i=!0}},[e,n]),s}const va=/\.(mp4|mov|webm|m3u8)(\?|#|$)/i;function Na(e,t){const n=(e.contentFormat||"").toUpperCase();return n==="VIDEO"?!0:n==="IMAGE"?!1:va.test(t)}function Ca(e){if(!e)return;e.muted=!0,e.defaultMuted=!0;const t=()=>{const n=e.play();n&&typeof n.catch=="function"&&n.catch(()=>{})};e.readyState>=2?t():e.addEventListener("loadeddata",t,{once:!0})}function xa({post:e,thumbClassName:t="phyllo_social_post_thumb",fallbackClassName:n="phyllo_social_post_thumb_fallback",durationClassName:s="phyllo_social_post_duration"}){const[o,i]=l.useState(!1),d=na(e.durationSec),f=e.caption||"Post preview",v=!!e.mediaUrl&&Na(e,e.mediaUrl),g=(!e.thumbnailUrl||o)&&v,N=g?e.mediaUrl:e.thumbnailUrl||e.mediaUrl,u=ka(g?e.mediaUrl:void 0,{enabled:g}),w=bn(u||void 0,{enabled:g&&!!u});if(!N)return a.jsx("div",{className:n,children:a.jsx("span",{children:"No preview"})});const h=a.jsxs(a.Fragment,{children:[g?a.jsx("video",{ref:Ca,className:t,src:u||void 0,poster:w||void 0,muted:!0,loop:!0,playsInl
1ine:!0,preload:"auto","aria-label":f}):a.jsx("img",{className:t,src:N,alt:f,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>i(!0)}),d?a.jsx("span",{className:s,children:d}):null]});return e.url?a.jsx("a",{className:"phyllo_social_post_thumb_link",href:e.url,target:"_blank",rel:"noreferrer","aria-label":`Open ${f}`,children:h}):a.jsx("div",{className:"phyllo_social_post_thumb_link",children:h})}const wa="https://cdn.getphyllo.com/connect/v2/phyllo-connect.js";let st=null;function vt(){const e=window.PhylloConnect;return e?.initialize?e:null}function ja(){const e=vt();return e?Promise.resolve(e):(st||(st=new Promise((t,n)=>{const s=document.createElement("script");s.src=wa,s.async=!0,s.onload=()=>{const o=vt();if(!o){n(new Error("Phyllo Connect SDK failed to initialize"));return}t(o)},s.onerror=()=>n(new Error("Failed to load Phyllo Connect SDK")),document.head.appendChild(s)})),st)}function Pa(e,t){e.on("accountConnected",(n,s,o)=>{t.onAccountConnected?.(n,s,o)}),e.on("accountDisconnected",(n,s,o)=>{t.onAccountDisconnected?.(n,s,o)}),e.on("tokenExpired",n=>{t.onTokenExpired?.(n)}),e.on("exit",(n,s)=>{t.onExit?.(n,s)}),e.on("connectionFailure",(n,s,o)=>{t.onConnectionFailure?.(n,s,o)})}async function Ta(e){const t=await ja(),n={clientDisplayName:e.clientDisplayName,environment:e.environment,userId:e.userId,token:e.token};e.workPlatformId&&(n.workPlatformId=e.workPlatformId);const s=t.initialize(n);return Pa(s,e.handlers),s.open(),s}const Le=(e,t)=>{const n=String(e??"").trim();return!n||/^[a-z]{2,4}_[a-z0-9_]+$/i.test(n)?t:n},Ea="Playnance",Sa="staging",it="phyllo_guest_user_id",Nt=["youtube","tiktok","twitch"],La={likes:0,comments:0,shares:0,views:0,impressions:0,reach:0};function Aa(e){if(e)return e.toLowerCase();const t=localStorage.getItem(it);if(t)return t;const n=`guest-${crypto.randomUUID()}`;return localStorage.setItem(it,n),n}function Ct(e){return e.reduce((t,n)=>({likes:t.likes+(n.likes??0),comments:t.comments+(n.comments??0),shares:t.shares+(n.shares??0),views:t.views+(n.views??0),impressions:t.impressions+(n.impressions??0),reach:t.reach+(n.reach??0)}),{...La})}function xt(e){return[...e].sort((t,n)=>{const s=t.publishedAt?Date.parse(t.publishedAt):0;return(n.publishedAt?Date.parse(n.publishedAt):0)-s})}const Ia=new Set(["IMAGE","VIDEO"]),Ra=new Set(["RETWEET"]);function wt(e){return e.filter(t=>{if(Ra.has((t.contentType||"").toUpperCase()))return!1;const n=(t.contentFormat||"").toUpperCase();return!!(Ia.has(n)||!n&&(t.thumbnailUrl||t.mediaUrl||t.url))})}function ot(e,t){const n=Ot(t);return e?e.includes("EXIT_FROM_CONNECTION_FAILED")||e.includes("CONNECTION_FAILED")?[`${n} connection failed at Phyllo/Meta.`,"⢠Allow popups for this site (Chrome, no ad-blocker).","⢠Log into the correct account and accept all permissions.","⢠Disconnect the platform, then try connecting again.",t.platform==="instagram"?"⢠For Instagram Graph: Business/Creator account + linked Facebook Page.":`⢠Use the ${n} button and complete login in the popup.`].join(` 2`):e:`${n} login failed. Try another connect option or reset session.`}function Da(e,t){return e.find(n=>Pn(n.work_platform?.name,t))}function jt(e){const t=e.filter(n=>(n.views??0)>0).map(n=>((n.likes??0)+(n.comments??0)+(n.shares??0))/(n.views??1)*100);return t.length===0?0:t.reduce((n,s)=>n+s,0)/t.length}function Pt(e){return e.reduce((t,n)=>t+Math.max(0,Math.floor((n.views??0)/100)),0)}function $a({layout:e="page"}={}){const t=Ae(c=>c.wallet.walletAddress),n=Ae(dt),{showError:s,showSuccess:o,showInfo:i}=ut(),d=l.useRef(null),f=l.useRef(new Set),v=l.useRef(null),g=Le(n.td_social_platform_rejected,"This social profile is already linked to another talent account and cannot be used here."),N=l.useMemo(()=>({approved:Le(n.td_social_platform_status_live,"Live"),pending:Le(n.td_social_platform_status_pending,"Pending"),rejected:Le(n.td_social_platform_status_rejected,"Rejected")}),[n]),[u,w]=l.useState(null),[h,L]=l.useState([]),[k,y]=l.useState([]),[Q,ee]=l.useState([]),[te,W]=l.useState({}),[Oe,se]=l.useState(!1),[Fe,ce]=l.useState(!1),[D,A]=l.useState(!1),[de,ue]=l.useState(!1),[Ne,B]=l.useState(!1),[Ue,K]=l.useState(!1),[I,m]=l.useState(null),[U,Me]=l.useState("instagram-direct"),[T,ne]=l.useState(e==="dashboard"?"youtube":"instagram"),[R,Ce]=l.useState("all"),[xe,oe]=l.useState(!1),[we,Ge]=l.useState(null),[je,me]=l.useState(0),M=l.useCallback(c=>
2{for(const p of c)ve(p.status)==="REJECTED"&&(f.current.has(p.id)||(f.current.add(p.id),i(g)))},[g,i]),ze=l.useCallback(c=>{O(h,c)==="REJECTED"&&i(g)},[h,g,i]),G=Aa(t),S=ge.find(c=>c.id===T)??ge[0],Pe=$t(T),z=l.useMemo(()=>xt(wt(k)),[k]),Ve=l.useMemo(()=>Ct(z),[z]),Be=l.useMemo(()=>jt(z),[z]),Ye=l.useMemo(()=>Pt(z),[z]),V=Ie(h,T),We=at(h,T),Ke=O(h,T),He=Ut(h,T),Je=rt(h,T),Xe=l.useMemo(()=>Nt.some(c=>Ie(h,c)),[h]),r=l.useMemo(()=>ge.map(c=>c.id).filter(c=>at(h,c)),[h]),x=r.join(","),C=l.useMemo(()=>wt(Q),[Q]),j=l.useMemo(()=>Ct(C),[C]),$=l.useMemo(()=>jt(C),[C]),F=l.useMemo(()=>Pt(C),[C]),he=Mt(T),fe=te[T]??null,H=l.useMemo(()=>r.reduce((c,p)=>{const _=te[p];return typeof _=="number"?c+_:c},0),[r,te]),J=l.useCallback(async(c=!1)=>{const p=await Bt(),_=Vt(p);return L(_),W(b=>({...b,...gt(p)})),M(_),_},[M]),Xt=l.useCallback(async(c,p)=>{try{await J(!!p?.force)}catch{p?.force&&L([])}},[J]),le=l.useCallback(async(c,p,_=!1)=>{const b=O(h,p);if(b==="REJECTED"){y([]),m(g);return}if(b==="PENDING"){y([]),m(`${S.label} connection is pending approvalâ¦`);return}if(b!=="APPROVED"){y([]);return}A(!0),m(_?`Loading latest ${S.label} contentâ¦`:null);try{const P=await Jn(c,p,{syncLatest:_});y(P),P.length===0?m(_?`${S.label} is linked, but no posts were returned. Try Refresh stats again in a minute.`:`Connect and publish on ${S.label}, then click Refresh stats.`):m(null)}catch(P){y([]);const E=P instanceof Error?P.message:"Failed to load posts";if(E.toLowerCase().includes("not connected")){m(`Connect a ${S.label} option below to load content stats.`);return}s(E),m(E)}finally{A(!1)}},[S.label,h,g,s]),Te=l.useCallback(async(c,p=!1)=>{A(!0),m(p?"Loading synced contentâ¦":null);try{const _=await yt(),b=Nt.filter(E=>at(h,E)),P=xt(_.filter(E=>{const ae=E.platform.trim().toLowerCase();return b.some(Ee=>ae===Ee||ae.includes(Ee))}));y(P),m(P.length===0?"Connect YouTube, TikTok, or Twitch to load synced content.":null)}catch(_){y([]);const b=_ instanceof Error?_.message:"Failed to load posts";s(b),m(b)}finally{A(!1)}},[h,s]),Ze=l.useCallback(async(c,p)=>{if(p.length===0){ee([]);return}ue(!0);try{const _=await yt(),b=new Set(p.map(P=>P.toLowerCase()));ee(_.filter(P=>{const E=P.platform.trim().toLowerCase();return b.has(E)||p.some(ae=>E.includes(ae))}))}catch{ee([])}finally{ue(!1)}},[]),qe=l.useCallback(async(c,p)=>{B(!0);try{await J(!1)}catch{}finally{B(!1)}},[J]),Zt=l.useCallback(c=>{ne(c),y([]),m(null)},[]),qt=l.useCallback(c=>{Ce(c),y([]),m(null),c!=="all"&&ne(c)},[]),Qt=l.useCallback(()=>{oe(!0),R!=="all"&&ne(R),window.requestAnimationFrame(()=>{v.current?.scrollIntoView({behavior:"smooth",block:"nearest"})})},[R]);return l.useEffect(()=>{const c=In(G);w(c)},[G]),l.useEffect(()=>{if(!t){L([]),W({});return}let c=!1;return(async()=>{try{const[p]=await Promise.all([_t(),J(!1).catch(()=>null)]);if(c||!p.userId)return;pt(G,p.userId),w(p.userId)}catch{}})(),()=>{c=!0}},[t,G,J]),l.useEffect(()=>{if(!u){y([]);return}if(e==="dashboard"){if(R==="all"){Te(u);return}le(u,R);return}le(u,T)},[u,T,R,e,le,Te]),l.useEffect(()=>{if(!u){ee([]);return}Ze(u,r)},[u,x,Ze]),l.useEffect(()=>{if(!u){W({});return}qe(u,r)},[u,x,qe]),{layout:e,walletAddress:t,portalUserId:G,phylloUserId:u,connectedAccounts:h,posts:k,sortedPosts:z,summary:Ve,averageEngagementRate:Be,contentGcoins:Ye,connectedPlatforms:r,totalSummary:j,totalAverageEngagementRate:$,totalContentGcoins:F,followerCounts:te,activeFollowerCount:fe,activeFollowerLabel:he,totalFollowerCount:H,isConnecting:Oe,isLoadingPosts:D,isLoadingTotalStats:de,isLoadingFollowers:Ne,isLoadingHistory:Ue,statusMessage:I,lastConnectKey:U,activePlatform:T,activeTab:S,connectOptions:Pe,platformConnected:V,platformApproved:We,activePlatformStatus:Ke,canDisconnectActive:He,activeDisconnectAccount:Je,rejectedSocialMessage:g,platformStatusLabels:N,notifyRejectedForPlatform:ze,hasAnyDashboardConnection:Xe,contentFilter:R,showConnectPanel:xe,setShowConnectPanel:oe,trackingPost:we,setTrackingPost:Ge,trackLinkRevision:je,setTrackLinkRevision:me,connectPanelRef:v,selectPlatform:Zt,selectContentFilter:qt,openConnectPanel:Qt,handleResetSession:()=>{Rn(G),ye(),localStorage.removeItem(it),w(null),L([]),W({}),y([]),m("Session reset. Pick a platform tab and connect again."),d.current=null},handleRefresh:()=>
2{if(!u)return;if(Ze(u,r),qe(u,r),e==="dashboard"&&R==="all"){Te(u,!0);return}le(u,e==="dashboard"&&R!=="all"?R:T,!0)},handleLoadHistory:async()=>{if(!u||!V)return;const c=Zn(1);K(!0),m(`Requesting posts back to ${c} from Phylloâ¦`);try{await Xn(u,T,c),m(`Historic fetch started (back to ${c}). Phyllo usually needs a few minutes â click Refresh stats to check.`)}catch(p){const _=p instanceof Error?p.message:"Failed to request historic posts";s(_),m(_)}finally{K(!1)}},handleDisconnect:async(c=T)=>{const p=rt(h,c),_=ge.find(b=>b.id===c)?.label??c;if(!p?.id){s(`No disconnectable ${_} account found.`);return}ce(!0),m(`Disconnecting ${_}â¦`);try{await zn(p.id),ye(),f.current.delete(p.id),await J(!0),T===c&&y([]),o(`${_} disconnected`),m(`${_} disconnected.`)}catch(b){const P=b instanceof Error?b.message:`Failed to disconnect ${_}`;s(P),m(P)}finally{ce(!1)}},handleConnect:async c=>{const p=ke(c),_=jn(c),b=Ot(c);se(!0),Me(p),ne(_),oe(!0),d.current=null,m(`Checking ${b} connectionâ¦`);try{const P=await J(!0),E=O(P,_);if(E==="APPROVED"||E==="PENDING"){m(E==="PENDING"?`${b} connection is pending approvalâ¦`:`${b} is already connected.`);return}if(E==="REJECTED"){i(g),m(g);return}m("Getting Connect tokenâ¦");const[ae,Ee]=await Promise.all([_t(),An(c)]),pe=ae.userId;pt(G,pe),w(pe),m("Opening Phyllo Connectâ¦"),await Ta({userId:pe,token:ae.token,environment:Sa,clientDisplayName:Ea,workPlatformId:Ee,handlers:{onAccountConnected:(re,Qe,en)=>{d.current=null,o(`${b} connected`),m(`${b} linked. Confirming with Playblockâ¦`);const et=en||pe;(async()=>{const{accounts:tt,platforms:tn}=await Vn(_);L(tt),M(tt),W(nn=>({...nn,...gt(tn)}));const nt=O(tt,_);if(nt==="REJECTED"){i(g),m(g);return}if(nt==="PENDING"||nt==null){m(`${b} connection is pending approvalâ¦`);return}m(`${b} linked. Loading contentâ¦`),e==="dashboard"&&R==="all"?Te(et,!0):le(et,_,!0)})()},onAccountDisconnected:()=>{y([]),m(`${b} disconnected.`),ye(),Xt(pe,{force:!0})},onTokenExpired:()=>{zt(),s("Phyllo session expired. Connect again."),m("Session expired â connect again.")},onExit:re=>{if(d.current){m(ot(d.current,c));return}if(re&&re!=="EXIT"){m(ot(re,c));return}m("Phyllo Connect closed.")},onConnectionFailure:re=>{d.current=re||"CONNECTION_FAILED";const Qe=ot(d.current,c);s(Qe.split(` 3`)[0]||"Connection failed"),m(Qe)}}}),m(`Complete ${b} login in the Phyllo popup.`)}catch(P){const E=P instanceof Error?P.message:"Failed to open Phyllo Connect";s(E),m(E)}finally{se(!1)}},isDisconnecting:Fe,findConnectedAccount:Da}}const Tt=[{key:"views",label:"Views",shortLabel:"Views"},{key:"likes",label:"Likes",shortLabel:"Likes"},{key:"comments",label:"Comments",shortLabel:"Comments"},{key:"shares",label:"Shares",shortLabel:"Shares"},{key:"impressions",label:"Impressions",shortLabel:"Impr."},{key:"reach",label:"Reach",shortLabel:"Reach"}];function ct(e){const t=e??0;return t>0&&!Number.isNaN(t)}function Et({label:e,shortLabel:t,value:n,variant:s}){return ct(n)?a.jsxs("div",{className:["phyllo_social_stat",`is_${s}`].join(" "),children:[a.jsx("span",{className:"phyllo_social_stat_value",children:Y(n)}),a.jsxs("span",{className:"phyllo_social_stat_label",title:e,children:[a.jsx("span",{className:"phyllo_social_stat_label_full",children:e}),a.jsx("span",{className:"phyllo_social_stat_label_short",children:t})]})]}):null}function Oa(e){return`is_${Ln(e)}`}const Fa=({embedded:e=!1})=>{const t=sn(),n=$a({layout:"page"}),s=l.useRef(null),o=l.useRef(null),[i,d]=l.useState(!1),[f,v]=l.useState(!1),{walletAddress:g,portalUserId:N,phylloUserId:u,connectedAccounts:w,sortedPosts:h,summary:L,averageEngagementRate:k,contentGcoins:y,connectedPlatforms:Q,totalSummary:ee,totalAverageEngagementRate:te,totalContentGcoins:W,followerCounts:Oe,activeFollowerCount:se,activeFollowerLabel:Fe,totalFollowerCount:ce,isConnecting:D,isLoadingPosts:A,isLoadingTotalStats:de,isLoadingFollowers:ue,isLoadingHistory:Ne,statusMessage:B,lastConnectKey:Ue,activePlatform:K,activeTab:I,connectOptions:m,platformConnected:U,canDisconnectActive:Me,platformStatusLabels:T,notifyRejectedForPlatform:ne,trackingPost:R,setTrackingPost:Ce,setTrackLinkRevision:xe,selectPlatform:oe,handleRefresh:we,handleLoadHistory:Ge,handleDisconnect:je,handleConnect:me,isDisconnecting:M,findConnectedAccount:ze}=n,G=l.useMemo(()=>Tt.filter(r=>ct(L[r.key])),[L]),S=l.useCallback(()=>{const r=s.current;if(!r)return;const x=r.scrollWidth-r.clientWidth;d(r.scrollLeft>4),v(r.scrollLeft<x-4)},[]),Pe=r=>{const x=s.current;if(!x)return;const C=x.querySelector(".phyllo_social_post"),j=C?C.offsetWidth+12:
3x.clientWidth*.86;x.scrollBy({left:r*j,behavior:"smooth"})};l.useEffect(()=>{S();const r=s.current,x=window.setTimeout(S,120);return window.addEventListener("resize",S),r?.addEventListener("scroll",S),()=>{window.clearTimeout(x),window.removeEventListener("resize",S),r?.removeEventListener("scroll",S)}},[h.length,S]);const z=l.useCallback(r=>{const x=Ie(w,r);if(oe(r),x||D){O(w,r)==="REJECTED"&&ne(r);return}if(!g){t(cn());return}const j=$t(r)[0]?.target;j&&me(j)},[w,t,me,D,ne,oe,g]),Ve=L.views>0?Y(L.views):"0",Be=k>0?bt(k):"0%",Ye=y>0?Y(y):"0",V=Q.length,We=ee.views>0?Y(ee.views):"0",Ke=te>0?bt(te):"0%",He=W>0?Y(W):"0",Je=se!=null?Y(se):"â",Xe=ce>0?Y(ce):"0";return a.jsxs("div",{className:["phyllo_social_page",e?"is_embedded":""].filter(Boolean).join(" "),children:[a.jsxs("div",{className:"phyllo_social_shell",children:[e?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"td_content_metrics_row_label",children:[I.label," stats",V>0?a.jsxs("span",{className:"td_content_metrics_row_sub",children:[a.jsx(_e,{size:11,strokeWidth:2.3,"aria-hidden":"true"}),"totals across ",V," social",V===1?"":"s"]}):null]}),a.jsxs("div",{className:"td_content_metrics",children:[a.jsxs("article",{className:"td_content_metric_card",children:[a.jsxs("div",{className:"td_content_metric_head",children:[a.jsx("span",{className:"td_content_metric_label",children:Fe}),a.jsx("span",{className:"td_content_metric_icon","aria-hidden":"true",children:a.jsx(fn,{size:16,strokeWidth:2.1})})]}),a.jsx("strong",{className:"td_content_metric_value",children:ue&&se==null?"â¦":Je}),V>0?a.jsxs("div",{className:"td_content_metric_total",children:[a.jsx(_e,{size:11,strokeWidth:2.3,"aria-hidden":"true"}),a.jsxs("span",{children:[ue?"â¦":Xe," across all socials"]})]}):null]}),a.jsxs("article",{className:"td_content_metric_card",children:[a.jsxs("div",{className:"td_content_metric_head",children:[a.jsx("span",{className:"td_content_metric_label",children:"Views"}),a.jsx("span",{className:"td_content_metric_icon","aria-hidden":"true",children:a.jsx(pn,{size:16,strokeWidth:2.1})})]}),a.jsx("strong",{className:"td_content_metric_value",children:Ve}),V>0?a.jsxs("div",{className:"td_content_metric_total",children:[a.jsx(_e,{size:11,strokeWidth:2.3,"aria-hidden":"true"}),a.jsxs("span",{children:[de?"â¦":We," total"]})]}):null]}),a.jsxs("article",{className:"td_content_metric_card",children:[a.jsxs("div",{className:"td_content_metric_head",children:[a.jsx("span",{className:"td_content_metric_label",children:"Engagement"}),a.jsx("span",{className:"td_content_metric_icon","aria-hidden":"true",children:a.jsx(_n,{size:16,strokeWidth:2.1})})]}),a.jsx("strong",{className:"td_content_metric_value",children:Be}),V>0?a.jsxs("div",{className:"td_content_metric_total",children:[a.jsx(_e,{size:11,strokeWidth:2.3,"aria-hidden":"true"}),a.jsxs("span",{children:[de?"â¦":Ke," total"]})]}):null]}),a.jsxs("article",{className:"td_content_metric_card td_content_metric_card--featured",children:[a.jsxs("div",{className:"td_content_metric_head",children:[a.jsx("span",{className:"td_content_metric_label",children:"GCoins"}),a.jsx("span",{className:"td_content_metric_icon is_gold","aria-hidden":"true",children:a.jsx(gn,{size:16,strokeWidth:2.1})})]}),a.jsx("strong",{className:"td_content_metric_value",children:Ye}),V>0?a.jsxs("div",{className:"td_content_metric_total",children:[a.jsx(_e,{size:11,strokeWidth:2.3,"aria-hidden":"true"}),a.jsxs("span",{children:[de?"â¦":He," total"]})]}):null]})]})]}):a.jsx("header",{className:"phyllo_social_header",children:a.jsxs("div",{className:"phyllo_social_header_copy",children:[a.jsx("h1",{className:"phyllo_social_title",children:"Social stats"}),a.jsx("p",{className:"phyllo_social_subtitle",children:"Pick a platform tab, connect an account, then browse every synced post with full engagement metrics."})]})}),a.jsx("div",{className:"phyllo_social_tabs_wrap",children:a.jsx("nav",{className:"phyllo_social_tabs","aria-label":"Social platforms",children:ge.map(r=>{const x=Ie(w,r.id),C=O(w,r.id),j=En(C,T),$=D&&K===r.id,F=Oe[r.id];return a.jsx("button",{type:"button",className:["phyllo_social_tab",`is_${r.accent}`,K===r.id?"is_active":"",x?"is_connected":"is_disconnected",C?`is_status_${C.toLowerCase()}`:"",$?"is_connecting":""].join(" "),"aria-selected":K===r.id,"aria-label":x?`${r.label}, ${j?.label??"connected"}`:`${r.label}, tap to connect`,onClick:()=>z(r.id),children:a.jsxs("span",{className:"phyllo_social_tab_main",children:[a.jsx("img",{className:"phyllo_social_tab_icon",src:r.iconUrl,alt:"","aria-hidden":"true"}),a.jsxs("span",{className:"phyllo_social_tab_copy",children:[a.jsxs("span",{className:"phyllo_social_tab_top",children:[a.jsx("span",{className:"phyllo_social_tab_label",children:r.label}),j?a.jsx("span",{className:`phyllo_social_tab_badge ${j.className}`,children:j.label}):null]}),e?null:a.jsx("span",{className:"phyllo_social_tab_tagline",children:r.tagline}),x&&F!=null?a.jsxs("span",{className:"phyllo_social_tab_followers",children:[Y(F)," ",Mt(r.id).toLowerCase()]}):null]})]})},r.id)})})}),e?a.jsx(ga,{}):null,e?null:a.jsxs("section",{ref:o,className:"phyllo_social_panel","aria-labelledby":"phyllo-connect-heading",children:[a.jsxs("div",{className:"phyllo_social_panel_head",children:[a.jsxs("div",{children:[a.jsx("h2",{id:"phyllo-connect-heading",className:"phyllo_social_panel_title",children:m.length>1?`${I.label} connect options`:`${I.label} connection`}),a.jsx("p",{className:"phyllo_social_panel_hint",children:m.length>1?"Choose the integration that matches your account type.":"Connect once to sync posts and engagement stats."})]}),a.jsx("div",{className:"phyllo_social_panel_actions",children:a.jsx("button",{type:"button",className:"phyllo_social_btn is_ghost",onClick:we,disabled:!u||A,children:A?"Refreshingâ¦":"Refresh stats"})})]}),a.jsx("div",{className:["phyllo_social_connect_grid",m.length===1?"is_solo":""].join(" "),children:m.map(r=>{const x=ke(r.target),C=ze(w,r.target),j=!!C,$=D&&Ue===x,F=r.target.platform==="instagram"?"instagram":r.target.platform,he=Ut(w,F),fe=rt(w,F);return a.jsxs("article",{className:["phyllo_social_connect_card",j?"is_linked":""].join(" "),children:[a.jsxs("div",{className:"phyllo_social_connect_card_body",children:[a.jsxs("div",{className:"phyllo_social_connect_card_top",children:[a.jsxs("div",{className:"phyllo_social_connect_titles",children:[r.badge?a.jsx("span",{className:"phyllo_social_connect_badge",children:r.badge}):null,a.jsx("h3",{className:"phyllo_social_connect_title",children:r.label})]}),a.jsx("span",{className:["phyllo_social_connect_status",j?"is_linked":""].join(" "),children:j?"Linked":"Available"})]}),a.jsx("p",{className:"phyllo_social_connect_desc",children:r.description}),C?a.jsxs("p",{className:"phyllo_social_connect_meta",children:["Account ",C.id.slice(0,8),"â¦",C.status?` · ${C.status}`:""]}):null]}),a.jsxs("div",{className:"phyllo_social_connect_footer",children:[he&&fe?a.jsx("button",{type:"button",className:"phyllo_social_btn is_ghost is_compact is_danger",onClick:()=>void je(F),disabled:M||D,children:M?"Disconnectingâ¦":"Disconnect"}):null,a.jsx("button",{type:"button",className:["phyllo_social_btn",j?"is_ghost is_compact":"is_primary is_compact"].join(" "),onClick:()=>void me(r.target),disabled:D||M,children:$?"Openingâ¦":j?"Reconnect":"Connect"})]})]},x)})})]}),a.jsxs("section",{className:"phyllo_social_content","aria-label":`${I.label} posts`,children:[a.jsx("div",{className:"phyllo_social_content_head",children:e?a.jsxs("div",{className:"phyllo_social_content_subrow phyllo_social_content_subrow--embedded",children:[a.jsx("p",{className:"phyllo_social_content_hint",children:D?`Opening ${I.label} loginâ¦`:U?B?B.split(` 4`)[0]:`${h.length} post${h.length===1?"":"s"} · 90 days`:`Tap ${I.label} to connect`}),a.jsxs("div",{className:"phyllo_social_content_toolbar",children:[U?a.jsx("button",{type:"button",className:"phyllo_social_btn is_ghost is_compact",onClick:we,disabled:!u||A||M,children:A?"Refreshingâ¦":"Refresh"}):null,Me?a.jsx("button",{type:"button",className:"phyllo_social_btn is_ghost is_compact is_danger",onClick:()=>void je(K),disabled:M||D,children:M?"Disconnectingâ¦":"Disconnect"}):null]})]}):a.jsxs(a.Fragment,{children:[a.jsxs("h2",{className:"phyllo_social_content_title",children:[I.label," content"]}),a.jsxs("div",{className:"phyllo_social_content_subrow",children:[a.jsx("p",{className:"phyllo_social_content_hint",children:U?`${h.length} synced post${h.length===1?"":"s"} · default window ~90 days`:"Connect an account above to load synced content."}),U?a.jsx("button",{type:"button",className:"phyllo_social_btn is_ghost is_compact",onClick:()=>void Ge(),disabled:!u||Ne||A,children:Ne?"Requestingâ¦":"Load 1 year history"}):null]})]})}),!e&&B?a.jsxs("div",{className:"phyllo_social_notice",children:[a.jsx(ft,{size:18,strokeWidth:2.1,"aria-hidden":"true"}),a.jsxs("div",{className:"phyllo_social_notice_copy",children:[a.jsx("strong",{children:"Status update"}),a.jsx("p",{className:"phyllo_social_notice_text",children:B})]})]}):null,A?a.jsxs("div",{className:"phyllo_social_loading",children:[a.jsx("span",{className:"phyllo_social_loading_spinner","aria-hidden":"true"}),a.jsxs("p",{children:["Loading ",I.label," contentâ¦"]})]}):null,!A&&U&&h.length>0?a.jsxs("div",{className:"phyllo_social_feed",children:[G.length>0?a.jsx("div",{className:"phyllo_social_summary",role:"group","aria-label":"Total engagement",children:G.map(r=>a.jsx(Et,{label:r.label,shortLabel:r.shortLabel,value:L[r.key],variant:"summary"},r.key))}):null,a.jsxs("div",{className:"phyllo_social_posts_carousel",children:[a.jsx("div",{className:"phyllo_social_posts",ref:s,onScroll:S,children:h.map(r=>
4{const x=Oa(r.platform),C=Tt.filter(H=>ct(r[H.key])),j=be(r.id),$=r.campaign,F=!!($?.code||$?.link||j),he={clicks:$?.hits??$?.clicks??0,signups:$?.users??0,earned:$?.earned??0},fe=C.length>0||F;return a.jsxs("article",{className:["phyllo_social_post",x].join(" "),children:[a.jsx("div",{className:"phyllo_social_post_media",children:a.jsx(xa,{post:r})}),a.jsxs("div",{className:"phyllo_social_post_body",children:[a.jsx("div",{className:"phyllo_social_post_meta",children:a.jsx("time",{dateTime:r.publishedAt||void 0,children:sa(r.publishedAt)})}),a.jsx("p",{className:"phyllo_social_post_caption",children:r.caption||"No caption provided"}),fe?a.jsxs("div",{className:"phyllo_social_post_stats_panel",children:[C.length>0?a.jsx("div",{className:"phyllo_social_post_metrics",role:"group","aria-label":"Post engagement",children:C.map(H=>a.jsx(Et,{label:H.label,shortLabel:H.shortLabel,value:r[H.key],variant:"post"},H.key))}):null,F?a.jsx(ia,{stats:he,hasPostMetricsAbove:C.length>0}):null]}):null,a.jsxs("div",{className:"phyllo_social_post_footer",children:[!$?.link&&!j?a.jsx("button",{type:"button",className:"phyllo_social_post_track_btn",onClick:()=>Ce(r),children:"Generate track link"}):null,r.url?a.jsx("a",{className:"phyllo_social_post_link",href:r.url,target:"_blank",rel:"noreferrer",children:"View post â"}):null]})]})]},r.id)})}),h.length>1?a.jsxs("div",{className:"phyllo_social_posts_nav",children:[a.jsx("button",{type:"button",className:"phyllo_social_posts_arrow is_prev","aria-label":"Previous post",disabled:!i,onClick:()=>Pe(-1),children:"â¹"}),a.jsx("button",{type:"button",className:"phyllo_social_posts_arrow is_next","aria-label":"Next post",disabled:!f,onClick:()=>Pe(1),children:"âº"})]}):null]})]}):null,!A&&U&&h.length===0&&!B?a.jsxs("div",{className:"phyllo_social_empty",children:[a.jsx("span",{className:"phyllo_social_empty_icon","aria-hidden":"true",children:a.jsx(ft,{size:22,strokeWidth:2.1})}),a.jsx("strong",{children:"No synced content yet"}),a.jsxs("p",{children:["Publish on ",I.label," or wait a few minutes, then hit Refresh stats."]})]}):null,!A&&!U&&!B&&!e?a.jsxs("div",{className:"phyllo_social_empty",children:[a.jsx("span",{className:"phyllo_social_empty_icon","aria-hidden":"true",children:a.jsx(yn,{size:22,strokeWidth:2.1})}),a.jsxs("strong",{children:[I.label," not connected"]}),a.jsxs("p",{children:["Click the ",I.label," tab to open login."]}),a.jsx("button",{type:"button",className:"phyllo_social_btn is_primary is_compact",onClick:()=>z(K),disabled:D,children:D?"Openingâ¦":`Connect ${I.label}`})]}):null,e&&!A&&!U&&!D?a.jsx("div",{className:"phyllo_social_empty phyllo_social_empty--compact",children:a.jsxs("strong",{children:["Tap ",I.label," above to connect"]})}):null]})]}),R?a.jsx(da,{post:R,portalUserId:N,onLinkReady:()=>xe(r=>r+1),onClose:()=>{Ce(null),xe(r=>r+1)}}):null]})},Qa=Object.freeze(Object.defineProperty({__proto__:null,default:Fa},Symbol.toStringTag,{value:"Module"}));export{Fa as P,_a as T,Za as a,Qa as b,qa as f,It as u};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.