1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/jszip.min-h8_JVI1_.js","assets/chunk-DseTPa7n.js"])))=>i.map(i=>d[i]); 2import{i as e}from"./chunk-DseTPa7n.js";import{h as t,m as n,t as r}from"./jsx-runtime-Fw7QqmeF.js";import{t as i}from"./Portal-C6xezA9t.js";import{D as a,S as o,_ as s,f as c,m as l,n as u,o as d,s as f}from"./AuthContext-Dj8EQKiU.js";import{r as p}from"./api-BwrUMEK3.js";import{a as m,t as h}from"./useQuery-CZ8TLikl.js";import{n as g}from"./TeamModeContext-Dq0NMdWj.js";import{c as _,f as v,i as y,l as b,p as ee}from"./verifyLink-CO3FbqDk.js";import{i as x,n as te,r as S,t as ne}from"./PlatformIcon-CZ4OvYFI.js";import{a as C,t as w}from"./notificationProducers-CZBGrgjF.js";var T=e(t(),1),E=r(),D={CAMERA_SCAN:`camera_scan`,TIKTOK:`tiktok`,INSTAGRAM:`instagram`,YOUTUBE:`youtube`};function re(e,t){let n=e?.enabled_features??e?.enabledFeatures;return Array.isArray(n)?n.includes(t):!1}var O={tiktok:D.TIKTOK,instagram:D.INSTAGRAM,youtube:D.YOUTUBE};function ie(){let{user:e}=u();return(0,T.useCallback)(t=>{if(S(t))return!0;let n=x(t),r=n?O[n]:void 0;return r?re(e,r):!1},[e])}var ae=(0,T.createContext)(void 0);function k(){let e=(0,T.useContext)(ae);if(!e)throw Error(`useSnackbar must be used within a SnackbarProvider`);return e}var oe={neutral:`bg-primary`,success:`bg-success-dark`,warning:`bg-warning`,error:`bg-danger`},se=84,A=11,j=.035,M=3,N=300,ce=340;function P(e,t){switch(t.type){case`push`:{let n=new Set(e.filter(e=>!e.exiting&&e.opts.key).map(e=>e.opts.key)),r=[];for(let e of t.opts)e.key&&n.has(e.key)||(e.key&&n.add(e.key),r.push({id:t.seq.n++,opts:e,exiting:!1}));return r.length?[...e,...r]:e}case`exit`:return e.map(e=>e.id===t.id?{...e,exiting:!0}:e);case`remove`:return e.filter(e=>e.id!==t.id)}}function F({children:e}){let t=(0,T.useRef)({n:1}),[n,r]=(0,T.useReducer)(P,[]),a=(0,T.useRef)(new Set),[,o]=(0,T.useReducer)(e=>e+1,0),s=(0,T.useCallback)(e=>{r({type:`push`,opts:[e],seq:t.current})},[]),c=(0,T.useCallback)(e=>{e.length&&r({type:`push`,opts:e,seq:t.current})},[]),l=(0,T.useCallback)(e=>{r({type:`exit`,id:e}),window.setTimeout(()=>r({type:`remove`,id:e}),ce)},[]),u=n.filter(e=>!e.exiting),d=u[0]?.id,f=(0,T.useCallback)(()=>{d!=null&&l(d)},[d,l]);(0,T.useEffect)(()=>{if(d==null)return;let e=u.find(e=>e.id===d)?.opts.duration??5e3;if(e<=0)return;let t=window.setTimeout(()=>l(d),e);return()=>window.clearTimeout(t)},[d]),(0,T.useEffect)(()=>{if(!n.some(e=>!a.current.has(e.id)))return;let e=requestAnimationFrame(()=>{n.forEach(e=>a.current.add(e.id)),o()});return()=>cancelAnimationFrame(e)},[n]);let p=e=>{let t=u.findIndex(t=>t.id===e.id);return t<0?0:t};return(0,E.jsxs)(ae.Provider,{value:{showSnackbar:s,enqueueSnackbars:c,hideSnackbar:f},children:[e,n.length>0&&(0,E.jsx)(i,{children:(0,E.jsx)(`div`,{className:`pointer-events-none fixed right-6 top-[56px] z-[100] w-[360px] max-w-[calc(100vw-2rem)]`,style:{height:se},"aria-live":`polite`,role:`status`,children:n.filter(e=>e.exiting||p(e)<=M).map(e=>{let t=p(e),n=!e.exiting&&t===0,r=a.current.has(e.id),i,o;e.exiting?(i=`translateY(-22px) scale(1)`,o=0):r?(i=`translateY(${t*A}px) scale(${1-t*j})`,o=1):(i=`translateY(${(t+1)*A}px) scale(${1-(t+1)*j})`,o=0);let{opts:s}=e,c=oe[s.type??`neutral`];return(0,E.jsxs)(`div`,{onClick:n?()=>{s.onClick?.(),l(e.id)}:void 0,className:`absolute inset-x-0 top-0 flex items-stretch gap-3 overflow-hidden rounded-2xl border border-border bg-bg-card/95 py-2.5 pl-2.5 pr-3 shadow-[0_8px_24px_rgba(0,0,0,0.45)] backdrop-blur-md ${n&&s.onClick?`cursor-pointer pointer-events-auto`:``} ${n?`pointer-events-auto`:`pointer-events-none`}`,style:{height:se,transform:i,opacity:o,zIndex:e.exiting?60:50-t,transition:`transform ${N}ms ease-out, opacity ${N}ms ease-out`},children:[(0,E.jsx)(`div`,{className:`w-1 shrink-0 self-stretch rounded-full ${c}`}),s.icon&&(0,E.jsx)(`div`,{className:`flex h-9 w-9 shrink-0 items-center justify-center self-center rounded-xl bg-white/[.06] text-primary`,children:s.icon}),(0,E.jsxs)(`div`,{className:`min-w-0 flex-1 self-center`,children:[(0,E.jsx)(`p`,{className:`truncate font-display text-[14px] font-semibold text-text`,children:s.title}),s.description&&(0,E.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-[13px] leading-snug text-text-secondary`,children:s.description})]}),n&&(0,E.jsx)(`button`,{type:`button`,"aria-label":`Dismiss`,onClick:t=>{t.stopPropagation(),l(e.id)},className:`shrink-0 self-start text-text-tertiary transition-colors hover:text-text`,children:(0,E.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:(0,E.jsx)(`path`,{d:`M18 6 6 18M6 6l12 12`})})})]},e.id)})})})]})}function I({open:e,items:t,onClose:n}){return(0,T.useEffect)(()=>
2{if(!e)return;let t=e=>{e.key===`Escape`&&(e.stopPropagation(),n())};return window.addEventListener(`keydown`,t,!0),()=>window.removeEventListener(`keydown`,t,!0)},[e,n]),e?(0,E.jsx)(i,{children:(0,E.jsxs)(`div`,{className:`fixed inset-0 z-[140] flex items-center justify-center p-4`,onClick:e=>e.stopPropagation(),children:[(0,E.jsx)(`div`,{className:`absolute inset-0 bg-black/70 backdrop-blur-sm`,onClick:n}),(0,E.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Post stats and verifications`,className:`relative z-10 w-full max-w-[400px] rounded-2xl border border-white/10 bg-bg-card p-4`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between pl-2`,children:[(0,E.jsx)(`h2`,{className:`font-display text-[17px] font-medium text-text`,children:`Post stats & verifications`}),(0,E.jsx)(`button`,{onClick:n,"aria-label":`Close`,className:`grid h-8 w-8 place-items-center rounded-full text-text transition-colors hover:bg-white/[.08]`,children:(0,E.jsx)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,children:(0,E.jsx)(`path`,{d:`M6 6l12 12M18 6 6 18`})})})]}),(0,E.jsx)(`div`,{className:`mt-3 grid gap-2 rounded-xl px-2 py-3`,style:{gridTemplateColumns:`repeat(${Math.max(t.length,1)}, minmax(0, 1fr))`},children:t.map(e=>(0,E.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,E.jsx)(`span`,{className:`font-display text-[16px] font-medium ${e.key===`verifications`?`text-primary`:`text-text`}`,children:e.value.toLocaleString(`en-US`)}),(0,E.jsx)(`span`,{className:`font-sans text-[12px] text-text-muted`,children:e.label})]},e.key))})]})]})}):null}function L({isDraft:e,canManage:t,canDownload:n=!0,onShare:r,onDownload:i,onEdit:a,onPublish:o,onPostOnSocials:s,stats:c,className:l=``}){let[u,d]=(0,T.useState)(!1),f=ee(c),[p,m]=(0,T.useState)(`idle`),h=(0,T.useRef)(void 0);(0,T.useEffect)(()=>()=>window.clearTimeout(h.current),[]);let g=async e=>{m(await r(e)===!1?`failed`:`copied`),window.clearTimeout(h.current),h.current=window.setTimeout(()=>m(`idle`),1800)},_=p===`copied`?`Link copied`:p===`failed`?`Couldn't copy`:`Share`;return(0,E.jsxs)(`footer`,{className:`flex h-[49px] items-center border-t border-white/[.06] pt-2 ${l}`,children:[c&&(0,E.jsx)(R,{items:f,onClick:e=>{e.stopPropagation(),d(!0)}}),!e&&(0,E.jsx)(B,{icon:(0,E.jsx)(le,{}),label:_,onClick:g}),n&&(0,E.jsx)(B,{icon:(0,E.jsx)(V,{}),label:`Download`,onClick:i}),e?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(B,{icon:(0,E.jsx)(de,{}),label:`Edit`,onClick:a}),t&&(0,E.jsx)(B,{icon:(0,E.jsx)(fe,{}),label:`Publish`,onClick:o})]}):t&&(0,E.jsx)(B,{icon:(0,E.jsx)(ue,{}),label:`Post on socials`,onClick:s}),(0,E.jsx)(I,{open:u,items:f,onClose:()=>d(!1)})]})}function R({items:e,onClick:t}){let[n,r]=(0,T.useState)(0),i=e.some(e=>e.value>0)&&!window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;(0,T.useEffect)(()=>{if(!i)return;let t=window.setInterval(()=>r(t=>(t+1)%(e.length+1)),3e3);return()=>window.clearInterval(t)},[i,e.length]);let a=i?n%(e.length+1):0,o=a===0?null:e[a-1];return(0,E.jsx)(`button`,{onClick:t,"aria-label":`Post stats`,className:`flex flex-1 flex-col items-center gap-1 rounded-lg py-1 text-[11px] text-text-muted transition-colors hover:bg-white/[.05] hover:text-text`,children:(0,E.jsxs)(`span`,{className:`flex animate-stat-roll flex-col items-center gap-1`,children:[o?(0,E.jsx)(`span`,{className:`flex h-[17px] items-center text-[14px] font-medium leading-none text-primary`,children:v(o.value)}):(0,E.jsx)(z,{}),o?o.label:`Stats`]},a)})}function z(){return(0,E.jsx)(`svg`,{width:`17`,height:`17`,viewBox:`0 0 24 24`,fill:`currentColor`,fillRule:`evenodd`,clipRule:`evenodd`,children:(0,E.jsx)(`path`,{d:`M18.4 1.6C18.8418 1.6 19.2 1.95818 19.2 2.4V21.6C19.2 22.0418 18.8418 22.4 18.4 22.4C17.9582 22.4 17.6 22.0418 17.6 21.6V2.4C17.6 1.95818 17.9582 1.6 18.4 1.6ZM15.2 4.8C15.6418 4.8 16 5.15818 16 5.6V21.6C16 22.0418 15.6418 22.4 15.2 22.4C14.7582 22.4 14.4 22.0418 14.4 21.6V5.6C14.4 5.15818 14.7582 4.8 15.2 4.8ZM21.6 4.8C22.0418 4.8 22.4 5.15818 22.4 5.6V21.6C22.4 22.0418 22.0418 22.4 21.6 22.4C21.1582 22.4 20.8 22.0418 20.8 21.6V5.6C20.8 5.15818 21.1582 4.8 21.6 4.8ZM8.8 6.4C9.24182 6.4 9.6 6.75818 9.6 7.2V21.6C9.6 22.0418 9.24182 22.4 8.8 22.4C8.35818 22.4 8 22.0418 8 21.6V7.2C8 6.75818 8.35818 6.4 8.8 6.4ZM2.4 8C2.84182 8 3.2 8.35818 3.2 8.8V21.6C3.2 22.0418 2.84182 22.4 2.4 22.4C1.95818 22.4 1.6 22.0418 1.6 21.6V8.8C1.6 8.35818 1.95818 8 2.4 8ZM12 8C12.4418 8 12.8 8.35818 12.8 8.8V21.6C12.8 22.0418 12.4418 22.4 12 22.4C11.5582 22.4 11.2 22.0418 11.2 21.6V8.8C11.2 8.35818 11.5582 8 12 8ZM5.6 11.2C6.04182 11.2 6.4 11.5582 6.4 12V21.6C6.4 22.0418 6.04182 22.4 5.6 22.4C5.15818 22.4 4.8 22.0418 4.8 21.6V12C4.8 11.5582 5.15818 11.2 5.6 11.2Z`})})}function B({icon:e,label:t,onClick:n}){return(0,E.jsxs)(`button`,{onClick:n,className:`flex flex-1 flex-col items-center gap-1 rounded-lg py-1 text-[11px] text-text-muted transition-colors hover:bg-white/[.05] hover:text-text`,children:[e,t]})}
2function le(){return(0,E.jsxs)(`svg`,{width:`17`,height:`17`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,E.jsx)(`circle`,{cx:`18`,cy:`5`,r:`3`}),(0,E.jsx)(`circle`,{cx:`6`,cy:`12`,r:`3`}),(0,E.jsx)(`circle`,{cx:`18`,cy:`19`,r:`3`}),(0,E.jsx)(`path`,{d:`m8.6 13.5 6.8 4M15.4 6.5l-6.8 4`})]})}function V(){return(0,E.jsx)(`svg`,{width:`17`,height:`17`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,E.jsx)(`path`,{d:`M12 3v12m0 0 4-4m-4 4-4-4M4 19h16`})})}function ue(){return(0,E.jsxs)(`svg`,{width:`17`,height:`17`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,E.jsx)(`path`,{d:`m12 3 9 5-9 5-9-5 9-5Z`}),(0,E.jsx)(`path`,{d:`m3 13 9 5 9-5`})]})}function de(){return(0,E.jsxs)(`svg`,{width:`17`,height:`17`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,E.jsx)(`path`,{d:`M12 20h9`}),(0,E.jsx)(`path`,{d:`M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z`})]})}function fe(){return(0,E.jsx)(`svg`,{width:`17`,height:`17`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,E.jsx)(`path`,{d:`m22 2-7 20-4-9-9-4Z`})})}function H(e){let t=[e.tagged_url,e.tagged_url_fallback].filter(e=>typeof e==`string`&&e.length>0);return t.length>0?t:e.url?[e.url]:[]}async function U(e){for(let t of H(e))try{let e=await fetch(t);if(e.ok)return await e.blob()}catch{}return null}async function pe(e){if(!e||!navigator.clipboard)return!1;try{return await navigator.clipboard.writeText(`https://verda.ai/${e}`),!0}catch{return!1}}var W=`_vmark`;function G(e){let t=e=>e?.split(`?`)[0].split(`/`).pop()||``,n=t(e.url),r=t(e.tagged_url),i=(e.original_filename||``).trim();if(!i){i=n.replace(/\.[^.]+$/,``)||`original`;for(let e=0;e<3;e++){let e;try{e=decodeURIComponent(i)}catch{break}if(e===i)break;i=e}}let a=(r.match(/\.([^.]+)$/)||n.match(/\.([^.]+)$/)||[])[1];return a?`${i}${W}.${a}`:`${i}${W}`}function me(e){let t=(e||``).trim();return/^[A-Za-z0-9_-]{4,32}$/.test(t)?`verda_${t}`:`verda_watermarked`}async function he(e){if(!e)return!1;let t=H(e);if(t.length===0)return!1;let n=G(e),r=await U(e);if(r)return ge(r,n),!0;let i=document.createElement(`a`);return i.href=t[0],i.download=n,i.rel=`noreferrer`,i.click(),!0}function ge(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,r.click(),setTimeout(()=>URL.revokeObjectURL(n),0)}async function _e(t,r=`verda_watermarked`){let i=(t||[]).filter(e=>H(e||{}).length>0);if(i.length===0)return 0;if(i.length===1)return+!!await he(i[0]);let{default:a}=await n(async()=>{let{default:t}=await import(`./jszip.min-h8_JVI1_.js`).then(t=>e(t.default,1));return{default:t}},__vite__mapDeps([0,1])),o=new a,s=new Set,c=0,l=await Promise.all(i.map(async e=>{let t=await U(e);return t?{blob:t,name:G(e)}:null}));for(let e of l){if(!e)continue;let t=e.name;if(s.has(t)){let e=t.lastIndexOf(`.`),n=e>0?t.slice(0,e):t,r=e>0?t.slice(e):``,i=2;for(;s.has(`${n}_${i}${r}`);)i+=1;t=`${n}_${i}${r}`}s.add(t),o.file(t,e.blob),c+=1}return c===0?0:(ge(await o.generateAsync({type:`blob`}),`${r}.zip`),c)}async function K(e,t,n){let r=(e||[]).length,i=await _e(e,me(n));if(i!==r){if(i===0){t({type:`error`,title:`Could not download this post`,description:r>1?`None of the ${r} files could be fetched. They may have expired â reload the page and try again.`:`The file could not be fetched. It may have expired â reload the page and try again.`});return}t({type:`error`,title:`Downloaded ${i} of ${r}`,description:`The rest could not be fetched. They may have expired â reload the page and try again.`})}}var ve=f;function ye(){let{user:e}=u(),{isTeamMode:t}=g(),n=(e?.social_connections||[]).map(e=>e.platform),{data:r,isPending:i}=h({queryKey:[`social`,`connections`,`team`],enabled:t,staleTime:6e4,queryFn:async()=>{let e=[];for(let t of ve)(await c(t))?.connected&&e.push(`PLATFORM_${t}`);return e}});return t?{platforms:r??[],isLoading:i}:{platforms:n,isLoading:!1}}var be=`pending_post_queue`,xe=15e3,Se=1440*60*1e3,Ce=`https://api.verda.ai`,we=null,Te=null;function q(){try{let e=localStorage.getItem(be);return e?JSON.parse(e):[]}catch{return[]}}function Ee(e){localStorage.setItem(be,JSON.stringify(e))}function De(e,t){let n=q();n.some(t=>t.postId===e)||(n.push({postId:e,addedAt:Date.now(),isVault:t}),Ee(n)),Me()}function Oe(e){let t=q().filter(t=>t.postId!==e);Ee(t),t.length===0&&Ne()}function ke(e){return q().some(t=>t.postId===e)}function Ae(e){Te=e}async function je(){let e=q();if(e.length===0){Ne();return}let t=Date.now(),n=[];for(let r of e)if(!(t-r.addedAt>Se)){try{let e=await p(`${Ce}/api/v2/posts?post_id=${r.postId}&platform=VERDA`);if(e?.response_code===200){let t=(e.data?.versions||[]).find(e=>e.platform===`VERDA`),n=t?.status;if(n===`POSTED`){Te?.(r.postId,`POSTED`,t);continue}else if(n===`FAILED`){Te?.(r.postId,`FAILED`);continue}}}catch{}n.push(r)}Ee(n),n.length===0&&Ne()}function Me(){we||=(je(),setInterval(je,xe))}function Ne(){we&&=(clearInterval(we),null)}function Pe(){q().length>0&&Me()}
2var Fe=`verda.pending_social_posts`,Ie=2e3,Le=1440*60*1e3,Re=`https://api.verda.ai`;function J(){try{return JSON.parse(localStorage.getItem(Fe)||`{}`)}catch{return{}}}function ze(e){try{localStorage.setItem(Fe,JSON.stringify(e))}catch{}}function Be(e,t){let n=J();n[e]=[...n[e]||[],t],ze(n)}function Ve(e){return(J()[e]||[]).length>0}function He(e){let t=J();delete t[e],ze(t)}function Ue(e){return e.map(e=>e.url?.match(/cloudfront\.net\/([a-f0-9-]+)\//)?.[1]).filter(e=>!!e)}async function We(e){let t=(await p(`${Re}/api/v2/posts?post_id=${e}`))?.data?.versions||[],n=t.find(e=>e.platform?.toUpperCase()===`VERDA`)||t[0];return{tinyUrlId:n?.tiny_url_id,media:n?.media||[]}}function Ge(e){return e?.response?.status===409}function Ke(e){let t=J(),n=t[e]||[];return delete t[e],ze(t),n}async function qe(e){let t=J()[e]||[];if(t.length===0)return[];He(e);let n=t.filter(e=>Date.now()-e.createdAt<Le),r=t.filter(e=>Date.now()-e.createdAt>=Le);for(let t of r)w(e,t.platform,`This post waited too long to go out and was not sent.`);await new Promise(e=>setTimeout(e,Ie));let i,a=[];try{let t=await We(e);i=t.tinyUrlId,a=Ue(t.media)}catch{}let o=[];for(let t of n)try{let n=t.text;if(!_(t.platform))n=b(t.text);else if(i){let e=t.mediaContentIds.length===0,r=t.platform===`X`&&e?`.`:``;n=y(t.text,t.verifyLinkTemplate||`Verify at: [Verda link]`,i,r)}let r=t.scheduledAt!==void 0&&t.scheduledAt>Date.now();await s(e,[{platform:t.platform,scheduleType:r?`AT_TIME`:`IMMEDIATE`,...r?{scheduledAt:new Date(t.scheduledAt)}:{},text:n,hashtags:[],mediaContentIds:t.mediaContentIds.length>0?t.mediaContentIds:a,...t.youtube?{youtube:t.youtube}:{}}]),o.push({platform:t.platform,ok:!0}),C()}catch(n){if(Ge(n)){o.push({platform:t.platform,ok:!0,alreadyPosted:!0});continue}let r=n?.message||`Failed to post`;o.push({platform:t.platform,ok:!1,error:r}),w(e,t.platform,r)}return o}function Je({open:e,isDeleting:t=!1,error:n,onConfirm:r,onCancel:a}){return(0,T.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&(e.stopPropagation(),t||a())};return window.addEventListener(`keydown`,n,!0),()=>window.removeEventListener(`keydown`,n,!0)},[e,t,a]),e?(0,E.jsx)(i,{children:(0,E.jsxs)(`div`,{className:`fixed inset-0 z-[140] flex items-center justify-center p-4`,children:[(0,E.jsx)(`div`,{className:`absolute inset-0 bg-black/70 backdrop-blur-sm`,onClick:()=>!t&&a()}),(0,E.jsxs)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-label":`Delete Post`,className:`relative z-10 w-full max-w-[400px] rounded-2xl border border-white/10 bg-bg-card p-6 text-center`,children:[(0,E.jsx)(`div`,{className:`mx-auto grid h-14 w-14 place-items-center rounded-full bg-[#FF3B30]/12`,children:(0,E.jsxs)(`svg`,{width:`28`,height:`28`,viewBox:`0 0 24 24`,fill:`none`,stroke:`#FF3B30`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,E.jsx)(`path`,{d:`M3 6h18M8 6V4a1 1 0 0 1 1-1h6a1 1 0 0 1 1 1v2M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6`}),(0,E.jsx)(`path`,{d:`M10 11v6M14 11v6`})]})}),(0,E.jsx)(`h2`,{className:`mt-4 font-display text-[19px] font-bold text-text`,children:`Delete Post`}),(0,E.jsx)(`p`,{className:`mt-2 font-sans text-[14px] leading-relaxed text-text-muted`,children:`This will permanently delete this post and invalidate its w
2atermark. This cannot be undone.`}),n&&(0,E.jsx)(`p`,{className:`mt-3 rounded-xl border border-error/30 bg-error/10 px-3 py-2 font-sans text-[13px] text-error`,children:n}),(0,E.jsxs)(`div`,{className:`mt-6 flex flex-col gap-2`,children:[(0,E.jsx)(`button`,{onClick:r,disabled:t,className:`h-12 rounded-full bg-[#FF3B30] font-display text-[15px] font-medium text-white transition-opacity hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-60`,children:t?`Deletingâ¦`:`Delete`}),(0,E.jsx)(`button`,{onClick:a,disabled:t,className:`h-12 rounded-full border border-white/12 font-display text-[15px] font-medium text-text transition-colors hover:bg-white/[.06] disabled:cursor-not-allowed disabled:opacity-60`,children:`Cancel`})]})]})]})}):null}function Ye({open:e,isPublishing:t=!1,error:n,onConfirm:r,onCancel:a}){return(0,T.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&(e.stopPropagation(),t||a())};return window.addEventListener(`keydown`,n,!0),()=>window.removeEventListener(`keydown`,n,!0)},[e,t,a]),e?(0,E.jsx)(i,{children:(0,E.jsxs)(`div`,{className:`fixed inset-0 z-[140] flex items-center justify-center p-4`,children:[(0,E.jsx)(`div`,{className:`absolute inset-0 bg-black/70 backdrop-blur-sm`,onClick:()=>!t&&a()}),(0,E.jsxs)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-label":`Move to published?`,className:`relative z-10 w-full max-w-[400px] rounded-2xl border border-white/10 bg-bg-card p-6 text-center`,children:[(0,E.jsx)(`div`,{className:`mx-auto grid h-14 w-14 place-items-center rounded-full bg-primary/12`,children:(0,E.jsx)(`svg`,{width:`26`,height:`26`,viewBox:`0 0 24 24`,fill:`none`,stroke:`#FFA62B`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,E.jsx)(`path`,{d:`M12 19V5M5 12l7-7 7 7`})})}),(0,E.jsx)(`h2`,{className:`mt-4 font-display text-[19px] font-bold text-text`,children:`Move to published?`}),(0,E.jsx)(`p`,{className:`mt-2 font-sans text-[14px] leading-relaxed text-text-muted`,children:`This post will be published and visible on your profile.`}),n&&(0,E.jsx)(`p`,{className:`mt-3 rounded-xl border border-error/30 bg-error/10 px-3 py-2 font-sans text-[13px] text-error`,children:n}),(0,E.jsxs)(`div`,{className:`mt-6 flex flex-col gap-2`,children:[(0,E.jsx)(`button`,{onClick:r,disabled:t,className:`h-12 rounded-full bg-primary font-display text-[15px] font-medium text-bg transition-colors hover:bg-primary-hover disabled:cursor-not-allowed disabled:opacity-60`,children:t?`Publishingâ¦`:`Publish`}),(0,E.jsx)(`button`,{onClick:a,disabled:t,className:`h-12 rounded-full border border-white/12 font-display text-[15px] font-medium text-text transition-colors hover:bg-white/[.06] disabled:cursor-not-allowed disabled:opacity-60`,children:`Cancel`})]})]})]})}):null}var Y=5e3,Xe=[{value:`public`,label:`Public`,hint:`Anyone can find and watch it.`},{value:`unlisted`,label:`Unlisted`,hint:`Only people with the link can watch it.`},{value:`private`,label:`Private`,hint:`Only you can watch it.`}];function X(e){return e.replace(/[<>]/g,``)}function Ze(e){return X(e.split(` 3`).map(e=>e.trim()).find(e=>e.length>0)??``).slice(0,100)}function Qe(e){return X(e.trim()).slice(0,Y)}function $e(e){return{title:Ze(e),description:Qe(e)}}function et(e){return e.title.trim()?e.title.length>100?`A YouTube title is at most 100 characters.`:e.description.length>5e3?`A YouTube description is at most ${Y} characters.`:e.privacy?null:`Choose who can watch this video on YouTube.`:`YouTube needs a title.`}function tt(e){return et(e)!==null||!e.privacy?null:{title:e.title.trim(),description:e.description,privacy:e.privacy}}function nt({value:e,onChange:t}){let n=e.title.length,r=n>100,i=e.description.length,a=i>Y;return(0,E.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-x-5 gap-y-4 overflow-y-auto scroll-hidden sm:grid-cols-2`,children:[(0,E.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[(0,E.jsxs)(`div`,{className:`flex shrink-0 flex-col`,children:[(0,E.jsx)(`label`,{htmlFor:`yt-title`,className:`mb-1.5 px-1 font-sans text-[12px] font-medium text-text-secondary`,children:`Title`}),(0,E.jsx)(`input`,{id:`yt-title`,value:e.title,onChange:n=>t({...e,title:X(n.target.value)}),maxLength:100,placeholder:`What is this video called?`,className:`rounded-[14px] border border-white/[.06] bg-white/[.03] px-4 py-3 font-sans text-[14px] text-text outline-none placeholder:text-text-faint focus:border-white/20`}),(0,E.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-between gap-3 px-1`,children:[(0,E.jsx)(`span`,{className:`font-sans text-[11.5px] text-text-tertiary`,children:`Shown as the video's name on YouTube.`}),(0,E.jsxs)(`span`,{className:`shrink-0 font-sans text-[11.5px] tabular-nums ${r?`text-error`:`text-text-muted`}`,children:[n,`/`,100]})]})]}),(0,E.jsxs)(`div`,{className:`flex shrink-0 flex-col`,children:[(0,E.jsx)(`label`,{htmlFor:`yt-description`,className:`mb-1.5 px-1 font-sans text-[12px] font-medium text-text-secondary`,children:`Description`}),(0,E.jsx)(`textarea`,{id:`yt-description`,value:e.description,onChange:n=>t({...e,description:X(n.target.value)}),maxLength:Y,rows:5,placeholder:`What is this video about?`,className:`scroll-hidden resize-none rounded-[14px] border border-white/[.06] bg-white/[.03] p-4 font-sans text-[14px] leading-relaxed text-text outline-none placeholder:text-text-faint focus:border-white/20`}),(0,E.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-between gap-3 px-1`,children:[(0,E.jsx)(`span`,{className:`font-sans text-[11.5px] text-text-tertiary`,children:`The verify link is added when it posts.`}),(0,E.jsxs)(`span`,{className:`shrink-0 font-sans text-[11.5px] tabular-nums ${a?`text-error`:`text-text-muted`}`,children:[i,`/`,Y]})]})]})]}),(0,E.jsxs)(`fieldset`,{className:`flex min-w-0 shrink-0 flex-col`,children:[(0,E.jsx)(`legend`,{className:`mb-1.5 px-1 font-sans text-[12px] font-medium text-text-secondary`,children:`Who can watch it?`}),(0,E.jsx)(`div`,{className:`flex flex-col gap-2`,children:Xe.map(n=>{let r=e.privacy===n.value;return(0,E.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":r,onClick:()=>t({...e,privacy:n.value}),className:`flex items-center gap-3 rounded-[14px] border px-4 py-3 text-left transition-colors ${r?`border-primary bg-primary/[.08]`:`border-white/[.06] bg-white/[.03] hover:border-white/20`}`,children:[(0,E.jsx)(`span`,{className:`flex h-[18px] w-[18px] shrink-0 items-center justify-center rounded-full border-2 ${r?`border-primary`:`border-border-strong`}`,children:r&&(0,E.jsx)(`span`,{className:`h-2 w-2 rounded-full bg-primary`})}),(0,E.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,E.jsx)(`span`,{className:`font-sans text-[14px] font-medium text-text`,children:n.label}),(0,E.jsx)(`span`,{className:`font-sans text-[11.5px] text-text-tertiary`,children:n.hint})]})]},n.value)})})]})]})}function rt({className:e=``}){let[t,n]=(0,T.useState)(!1);return(0,E.jsxs)(`div`,{className:`shrink-0 rounded-xl border border-warning/30 bg-warning/10 ${e}`,children:[(0,E.jsxs)(`button`,{type:`button`,onClick:()=>n(e=>!e),"aria-expanded":t,className:`flex w-full items-center gap-2.5 px-3 py-2.5 text-left`,children:[(0,E.jsx)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`#E59422`,strokeWidth:`1.9`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`shrink-0`,"aria-hidden":!0,
3children:(0,E.jsx)(`path`,{d:`M12 9v4M12 17h.01M10.3 3.9 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0z`})}),(0,E.jsx)(`span`,{className:`min-w-0 flex-1 font-sans text-[13px] leading-[18px] text-text-secondary`,children:`YouTube takes a few minutes to process this upload.`}),(0,E.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`shrink-0 text-text-muted transition-transform ${t?`rotate-180`:``}`,"aria-hidden":!0,children:(0,E.jsx)(`path`,{d:`m6 9 6 6 6-6`})})]}),t&&(0,E.jsxs)(`p`,{className:`px-3 pb-3 pl-[42px] font-sans text-[12.5px] leading-[17px] text-text-muted`,children:[`Longer for a high-resolution file, and it can take`,` `,(0,E.jsx)(`strong`,{className:`font-medium text-text-secondary`,children:`several hours more`}),` to show up in search or on your channel page. The link will look empty until processing finishes â that is normal, not a failed post.`]})]})}function it({open:e,value:t,onChange:n,onConfirm:r,onCancel:a,busy:o}){if(!e)return null;let s=et(t);return(0,E.jsx)(i,{children:(0,E.jsxs)(`div`,{className:`fixed inset-0 z-[150] flex items-center justify-center p-4`,children:[(0,E.jsx)(`div`,{className:`absolute inset-0 bg-black/70 backdrop-blur-sm`,onClick:()=>!o&&a()}),(0,E.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`YouTube details`,className:`relative z-10 flex max-h-[85vh] w-full max-w-[860px] flex-col rounded-2xl border border-white/10 bg-bg-card p-6`,children:[(0,E.jsx)(`h2`,{className:`font-display text-[17px] font-semibold text-text`,children:`YouTube details`}),(0,E.jsx)(`p`,{className:`mb-4 mt-1 font-sans text-[12.5px] leading-relaxed text-text-muted`,children:`This is what YouTube will show, and who will be able to watch it.`}),(0,E.jsx)(nt,{value:t,onChange:n}),(0,E.jsx)(rt,{className:`mt-4`}),(0,E.jsxs)(`div`,{className:`mt-5 flex items-center justify-end gap-2`,children:[(0,E.jsx)(`button`,{type:`button`,onClick:a,disabled:o,className:`h-10 rounded-full px-4 font-display text-[13.5px] font-semibold text-text-muted transition-colors hover:text-text disabled:opacity-50`,children:`Cancel`}),(0,E.jsx)(`button`,{type:`button`,onClick:r,disabled:o||s!==null,title:s??void 0,className:`h-10 rounded-full bg-primary px-5 font-display text-[13.5px] font-semibold text-bg transition-all hover:brightness-[1.06] disabled:cursor-not-allowed disabled:opacity-40`,children:`Continue`})]})]})]})})}function at({platform:e,handle:t,status:n,selected:r=!1,disabled:i=!1,onClick:a}){let o=x(e),s=o?ne[o]:e;return(0,E.jsxs)(`button`,{type:`button`,onClick:a,disabled:i,"aria-pressed":r,className:`flex shrink-0 items-center gap-2 rounded-[8px] px-3 py-2.5 text-left transition-all ${r?`border-[1.5px] border-solid border-[#ffa62b] bg-[rgba(255,166,43,0.1)]`:`border-[1.5px] border-solid border-transparent bg-white/10`} ${i?`cursor-not-allowed opacity-45`:`hover:brightness-125`}`,children:[o?(0,E.jsx)(te,{platform:o,size:24}):(0,E.jsx)(`span`,{className:`h-6 w-6 rounded-full bg-white/15`}),(0,E.jsxs)(`span`,{className:`flex min-w-0 flex-col items-start`,children:[(0,E.jsx)(`span`,{className:`truncate font-sans text-[13px] leading-[18px] text-[#fcfdfd]`,children:t?`@${t}`:s}),n&&(0,E.jsxs)(`span`,{className:`flex items-center gap-0.5`,children:[(0,E.jsxs)(`svg`,{width:`10`,height:`10`,viewBox:`0 0 24 24`,fill:`none`,stroke:`#c2c8cc`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,E.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,E.jsx)(`path`,{d:`M12 7v5.2l3.2 1.9`})]}),(0,E.jsx)(`span`,{className:`whitespace-nowrap font-sans text-[10px] leading-[13px] text-[#c2c8cc]`,children:n})]})]})]})}function ot(e){let t=e=>String(e).padStart(2,`0`);return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}T${t(e.getHours())}:${t(e.getMinutes())}`}function st(){let e=new Date(Date.now()+900*1e3);return e.setSeconds(0,0),e.setMinutes(e.getMinutes()>30?60:30),e}function ct({open:e,platforms:t,initial:n,onCancel:r,onConfirm:a,onClear:o}){let{user:s}=u(),[c,l]=(0,T.useState)(!0),[d,f]=(0,T.useState)({}),[p,m]=(0,T.useState)(``),[h,g]=(0,T.useState)(``),_=(0,T.useMemo)(()=>{let e={};for(let t of s?.social_connections??[]){let n=x(t.platform);
3n&&(e[n]=t.metadata?.platform_username)}return e},[s?.social_connections]);(0,T.useEffect)(()=>{if(!e)return;let r=ot(st()),i={};for(let e of t){let t=n?.[e];i[e]=t?ot(new Date(t)):r}f(i),l(new Set(Object.values(i)).size<=1),m(t[0]||``),g(``)},[e]);let v=t[0],y=(e,n)=>{g(``),f(r=>c?Object.fromEntries(t.map(e=>[e,n])):{...r,[e]:n})};return e?(0,E.jsx)(i,{children:(0,E.jsxs)(`div`,{className:`fixed inset-0 z-[140] flex items-center justify-center p-4`,children:[(0,E.jsx)(`div`,{className:`absolute inset-0 bg-black/70 backdrop-blur-sm`,onClick:r}),(0,E.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Schedule post`,className:`relative z-10 w-full max-w-[460px] rounded-2xl border border-white/10 bg-bg-card p-6`,children:[(0,E.jsx)(`h2`,{className:`font-display text-[19px] font-bold text-text`,children:`Schedule post`}),(0,E.jsx)(`p`,{className:`mt-2 font-sans text-[14px] leading-relaxed text-text-muted`,children:`Your post is watermarked now and goes out at the time you pick.`}),t.length>1&&(0,E.jsxs)(`label`,{className:`mt-4 flex cursor-pointer items-center gap-2.5 rounded-xl bg-white/[.05] px-4 py-3`,children:[(0,E.jsx)(`input`,{type:`checkbox`,checked:c,onChange:e=>{let n=e.target.checked;if(l(n),n&&v){let e=d[v];f(Object.fromEntries(t.map(t=>[t,e])))}},className:`h-4 w-4 accent-primary`}),(0,E.jsx)(`span`,{className:`font-sans text-[13px] text-text`,children:`Same time on all channels`})]}),(0,E.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-1`,children:t.map(e=>{let t=x(e),n=d[e]?new Date(d[e]):null;return(0,E.jsx)(at,{platform:e,handle:t?_[t]:void 0,status:n?n.toLocaleString(`en-US`,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}):void 0,selected:!c&&p===e,onClick:()=>!c&&m(e)},e)})}),(0,E.jsxs)(`div`,{className:`mt-3 flex items-center gap-3 rounded-xl bg-white/[.05] px-4 py-3`,children:[(0,E.jsx)(`span`,{className:`shrink-0 font-sans text-[12px] text-text-muted`,children:c?`All channels`:lt(p)}),(0,E.jsx)(`input`,{type:`datetime-local`,value:d[c?v:p]||``,min:ot(new Date),onChange:e=>y(c?v:p,e.target.value),className:`min-w-0 flex-1 bg-transparent font-sans text-[14px] text-text outline-none [color-scheme:dark]`})]}),!c&&(0,E.jsx)(`p`,{className:`mt-2 px-1 font-sans text-[11px] leading-snug text-text-tertiary`,children:`Each channel keeps its own slot â one certificate covers them all.`}),h&&(0,E.jsx)(`p`,{className:`mt-3 font-sans text-[13px] text-danger`,children:h}),(0,E.jsxs)(`div`,{className:`mt-6 flex items-center gap-2`,children:[n&&Object.keys(n).length>0&&(0,E.jsx)(`button`,{onClick:o,className:`h-12 rounded-full px-4 font-sans text-[13px] text-text-muted transition-colors hover:text-text`,children:`Post immediately`}),(0,E.jsx)(`button`,{onClick:r,className:`ml-auto h-12 rounded-full border border-white/10 px-5 font-display text-[15px] text-text transition-colors hover:bg-white/[.06]`,children:`Cancel`}),(0,E.jsx)(`button`,{onClick:()=>{let e={};for(let n of t){let t=d[n];if(!t){g(`Pick a time for every channel.`);return}let r=new Date(t);if(Number.isNaN(r.getTime())){g(`That date is not valid.`);return}if(r.getTime()<=Date.now()){g(`Pick a time in the future.`);return}e[n]=r.getTime()}a(e)},className:`h-12 rounded-full bg-primary px-6 font-display text-[15px] font-medium text-bg transition-all hover:brightness-[1.06]`,children:t.length>1?`Schedule ${t.length} channels`:`Schedule`})]})]})]})}):null}function lt(e){let t=x(e);return t?ne[t]:e}var ut={PLATFORM_X:`x`,PLATFORM_LINKEDIN:`linkedin`,PLATFORM_TIKTOK:`tiktok`,PLATFORM_BLUESKY:`bluesky`,PLATFORM_INSTAGRAM:`instagram`},Z={PLATFORM_X:`X`,PLATFORM_LINKEDIN:`LinkedIn`,PLATFORM_TIKTOK:`TikTok`,PLATFORM_BLUESKY:`Bluesky`,PLATFORM_INSTAGRAM:`Instagram`};function dt(e){return l()[ut[e]??``]?.max_characters}var ft=/verda\.ai\/[A-Za-z0-9]+/;function pt(e,t){if(!_(e))return b(t.text).length;if(ft.test(t.text))return t.text.length;let n=t.media.length===0;return t.text.length+(e===`PLATFORM_X`&&n?27:26)}function mt(e,t){return e.filter(e=>{let n=t[e],r=dt(e);return!n||r===void 0?!1:pt(e,n)>r})}function ht(e){if(e.includes(`AUDIO`))return`TikTok cannot post audio.`;let t=e.filter(e=>e===`VIDEO`).length,n=e.filter(e=>e===`IMAGE`).length;return t>1?`TikTok takes one video per post.`:t===1?n>0?`TikTok cannot mix a video with images.`:null:n===0?`TikTok needs a video or at least 2 images.`:n===1?`TikTok needs 2 or more images, or a video.`:n>35?`TikTok takes up to 35 images.`:null}function gt(e){if(e.includes(`AUDIO`))return`Bluesky cannot post audio.`;let t=e.filter(e=>e===`VIDEO`).length,n=e.filter(e=>e===`IMAGE`).length;return t>1?`Bluesky takes one video per post.`:t===1&&n>0?`Bluesky cannot mix a video with images.`:n>4?`Bluesky takes up to 4 images.`:null}function _t(e,t=[]){if(e.includes(`AUDIO`))return`Instagram cannot post audio.`;if(e.length===0)return`Instagram needs at least one photo or video.`;if(e.length>10)return`Instagram takes up to 10 items per post.`;let n=t.find((t,n)=>e[n]!==`IMAGE`||!t?!1:![`jpg`,`jpeg`].includes(t.toLowerCase()));return n?`Instagram accepts JPEG images only; this one is ${n.toUpperCase()}.`:null}function vt(e){let t=e.filter(e=>e===`VIDEO`).length,n=e.filter(e=>e===`IMAGE`).length;return e.includes(`AUDIO`)?`YouTube cannot post audio on its own.`:t===0?`YouTube needs a video; it cannot post images.`:t>1?`YouTube takes one video per post.`:n>0?`YouTube posts the video only; images cannot be included.`:null}function yt(e,t,n,r={}){let i={...r};for(let r of e)i[r]||(i[r]={text:t,media:[...n]});return i}function bt({platforms:e,media:t,drafts:n,onChange:r,activeTab:i,onTab:a}){let o=n[i],s=dt(i),c=o?pt(i,o):0,u=s!==void 0&&c>s,d=l()[ut[i]??``],f=mt(e,n),p=e=>r({...n,[i]:{...n[i],...e}});return(0,E.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4`,children:[(0,E.jsx)(`div`,{className:`flex shrink-0 gap-2`,children:e.map(e=>{let t=e===i,n=f.includes(e);return(0,E.jsxs)(`button`,{onClick:()=>a(e),className:`flex h-9 items-center gap-2 rounded-full px-4 font-display text-[13px] font-medium transition-colors ${t?`bg-primary text-bg`:`bg-white/[.07] text-text-secondary hover:bg-white/[.12]`}`,children:[(()=>{let t=x(e);return t?(0,E.jsx)(te,{platform:t,size:20}):null})(),Z[e]??e,n&&(0,E.jsx)(`span`,{className:t?`text-bg`:`text-error`,children:`!`})]},e)})}),(0,E.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-4`,children:[t.length>0&&(0,E.jsxs)(`div`,{className:`flex w-[240px] shrink-0 flex-col rounded-[16px] border border-white/[.06] bg-white/[.03] p-4`,children:[(0,E.jsx)(`p`,{className:`font-display text-[13px] font-semibold text-text`,children:`Media`}),(0,E.jsx)(`p`,{className:`mt-1 font-sans text-[11.5px] leading-snug text-text-muted`,children:d?`${Z[i]} takes up to ${d.max_images} images or ${d.max_videos} video.`:`Choose what goes to this platform.`}),(0,E.jsx)(`div`,{className:`scroll-hidden mt-3 grid min-h-0 flex-1 auto-rows-min grid-cols-3 content-start gap-2 overflow-y-auto`,children:t.map(e=>{let n=o?.media.includes(e.id)??!0;return(0,E.jsx)(`button`,{onClick:()=>p({media:n?(o?.media??[]).filter(t=>t!==e.id):t.map(e=>e.id).filter(t=>t===e.id||(o?.media??[]).includes(t))}),className:`relative aspect-square overflow-hidden rounded-[8px] border-2 transition-colors ${n?`border-primary`:`border-transparent opacity-40`}`,children:(0,E.jsx)(`img`,{src:e.previewUrl,alt:``,className:`h-full w-full object-cover`})},e.id)})}),o&&o.media.length===0&&(0,E.jsx)(`p`,{className:`mt-2 font-sans text-[11.5px] text-text-tertiary`,children:`Text only for this platform.`})]}),(0,E.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,E.jsx)(`textarea`,{value:o?.text??``,onChange:e=>p({text:e.target.value}),placeholder:`What goes out on ${Z[i]??`this platform`}?`,className:`scroll-hidden min-h-0 flex-1 resize-none rounded-[16px] border border-white/[.06] bg-white/[.03] p-4 font-sans text-[14px] leading-relaxed text-text outline-none placeholder:text-text-faint focus:border-white/20`}),(0,E.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-3 px-1`,children:[(0,E.jsx)(`span`,{className:`font-sans text-[11.5px] text-text-tertiary`,children:_(i)?o&&/verda\.ai\/[A-Za-z0-9]+/.test(o.text)?`The verify link is already part of this text.`:`Includes the verify link, which is added when it posts.`:`Goes out without the verify link, and to your TikTok drafts to finish there.`}),s!==void 0&&(0,E.jsxs)(`span`,{className:`shrink-0 font-sans text-[12px] tabular-nums ${u?`text-error`:`text-text-muted`}`,children:[c,`/`,s]})]})]})]})]})}var xt={x:!1,linkedin:!0,tiktok:!1,bluesky:!1,instagram:!0},St=1440*60*1e3,Ct=1440*60*1e3,wt={status:`unknown`,daysLeft:null,usableUntil:null};
3function Tt(e,t,n=Date.now()){if(!xt[e]||!t||t<=0)return wt;let r=t*1e3-St,i=r-n;if(i<=0)return{status:`expired`,daysLeft:0,usableUntil:r};let a=Math.ceil(i/Ct);return{status:a<=14?`expiring`:`healthy`,daysLeft:a,usableUntil:r}}function Et(e,t){return e.usableUntil===null?!1:t>=e.usableUntil}function Dt(e){return e.status===`expired`?`Connection expired`:e.status!==`expiring`||e.daysLeft===null?null:e.daysLeft<=1?`Expires today`:`Expires in ${e.daysLeft} days`}function Ot({open:e,connectedPlatforms:t,alreadyPosted:n,isPosting:r,error:s,onConfirm:l,onCancel:p,postText:h,postMedia:g,preselect:_,initialDrafts:v,alreadySharedToHootsuite:y}){let[b,ee]=(0,T.useState)([]),[S,ne]=(0,T.useState)(!1),[C,w]=(0,T.useState)(null),[D,re]=(0,T.useState)(null),{user:O,setUserData:ae}=u(),k=ie(),oe=m(),se=async(e,t)=>{if(!C){re(null),w(e),a(`Social Connection Initiated`,{platform:t,source:`Post on Socials`});try{let n=await d(t);if(!n.ok){a(n.reason===`cancelled`?`Social Connection Abandoned`:`Social Connection Failed`,{platform:t,source:`Post on Socials`,error:n.reason}),n.reason!==`cancelled`&&re(`${Z[e]??e} could not be connected.`);return}a(`Social Connection Succeeded`,{platform:t,source:`Post on Socials`});let r=await c(e);r?.connected&&O&&ae({...O,social_connections:[...(O.social_connections||[]).filter(e=>x(e.platform)!==t),{platform:`PLATFORM_${e}`,metadata:r.metadata??{},connected_at:Date.now()}]}),oe.invalidateQueries({queryKey:[`social`,`connections`,`team`]})}finally{w(null)}}},[A,j]=(0,T.useState)([]),[M,N]=(0,T.useState)({}),[ce,P]=(0,T.useState)(!1),[F,I]=(0,T.useState)(`pick`),[L,R]=(0,T.useState)(null),[z,B]=(0,T.useState)({}),[le,V]=(0,T.useState)(``);if((0,T.useEffect)(()=>{e&&(ee(_??[]),j([]),N({}),I(`pick`),B(v??{}),V(``),R(null))},[e]),(0,T.useEffect)(()=>{if(!e)return;let t=!1;return(async()=>{let e=[];for(let t of f){let n=await c(t);n?.connected&&Et(Tt(t.toLowerCase(),n.expiresAt),Date.now())&&e.push(t)}t||j(e)})(),()=>{t=!0}},[e]),(0,T.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&(e.stopPropagation(),r||p())};return window.addEventListener(`keydown`,t,!0),()=>window.removeEventListener(`keydown`,t,!0)},[e,r,p]),!e)return null;let ue=new Set(t.map(e=>x(e)).filter(Boolean)),de=new Set(n.map(e=>o(e)).filter(Boolean)),fe=[{key:`LINKEDIN`,label:`LinkedIn`,norm:`linkedin`},{key:`X`,label:`X/Twitter`,norm:`x`},...k(`tiktok`)?[{key:`TIKTOK`,label:`TikTok`,norm:`tiktok`}]:[],...k(`bluesky`)?[{key:`BLUESKY`,label:`Bluesky`,norm:`bluesky`}]:[],...k(`instagram`)?[{key:`INSTAGRAM`,label:`Instagram`,norm:`instagram`}]:[],...k(`youtube`)?[{key:`YOUTUBE`,label:`YouTube`,norm:`youtube`}]:[]],H=b.map(e=>M[e]).filter(Boolean),U=H.length>0,pe=U?new Set(H).size>1?`${H.length} channels, different times`:new Date(H[0]).toLocaleString(`en-US`,{weekday:`short`,day:`numeric`,month:`short`,hour:`numeric`,minute:`2-digit`}):`Schedule for later`,W=b.map(e=>`PLATFORM_${e}`),G=mt(W,z),me=(()=>{if(!b.includes(`TIKTOK`)||!g)return null;let e=(z.PLATFORM_TIKTOK?.media??g.map(e=>e.id)).map(e=>g.find(t=>t.id===e)?.contentType);return e.some(e=>!e)?null:ht(e)})(),he=(()=>{if(!b.includes(`BLUESKY`)||!g)return null;let e=(z.PLATFORM_BLUESKY?.media??g.map(e=>e.id)).map(e=>g.find(t=>t.id===e)?.contentType);return e.some(e=>!e)?null:gt(e)})(),ge=(()=>{if(!b.includes(`INSTAGRAM`)||!g)return null;let e=(z.PLATFORM_INSTAGRAM?.media??g.map(e=>e.id)).map(e=>g.find(t=>t.id===e)),t=e.map(e=>e?.contentType);return t.some(e=>!e)?null:_t(t,e.map(e=>e?.fileFormat))})(),_e=(()=>{if(!b.includes(`YOUTUBE`)||!g)return null;let e=(z.PLATFORM_YOUTUBE?.media??g.map(e=>e.id)).map(e=>g.find(t=>t.id===e)?.contentType);return e.some(e=>!e)?null:vt(e)})(),K=me??he??ge??_e,ve=b.includes(`YOUTUBE`),ye=()=>{B(e=>yt(W,h??``,(g??[]).map(e=>e.id),e)),V(e=>W.includes(e)?e:W[0]??``),I(`customize`)},be=()=>l(b,M,F!==`pick`||Object.keys(v??{}).length>0?Object.fromEntries(Object.entries(z).map(([e,t])=>[e.replace(/^PLATFORM_/,``),t])):void 0,S,b.includes(`YOUTUBE`)&&L?tt(L)??void 0:void 0),xe=()=>{if(b.includes(`YOUTUBE`)&&!L){R($e(z.PLATFORM_YOUTUBE?.text??h??``)),I(`youtube`);return}be()},Se=F===`youtube`&&L?et(L):null,Ce=e=>ee(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);return(0,E.jsx)(i,{children:(0,E.jsxs)(`div`,{className:`fixed inset-0 z-[140] flex items-center justify-center p-4`,children:[(0,E.jsx)(`div`,{className:`absolute inset-0 bg-black/70 backdrop-blur-sm`,onClick:()=>!r&&p()}),(0,E.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Post on socials`,className:`relative z-10 flex w-full flex-col rounded-2xl border border-white/10 bg-bg-card p-6 transition-[max-width] ${F===`customize`?`max-w-[860px] h-[min(600px,85vh)]`:F===`youtube`?`max-w-[860px] max-h-[85vh]`:`max-w-[420px]`}`,children:[(0,E.jsx)(`h2`,{className:`shrink-0 font-display text-[19px] font-bold text-text`,children:F===`pick`?`Post on socials`:F===`youtube`?`YouTube details`:`Customize for each social`}),(0,E.jsx)(`p`,{className:`mt-2 shrink-0 font-sans text-[14px] leading-relaxed text-text-muted`,children:F===`pick`?b.includes(`TIKTOK`)?`Choose where to share this post. The verification link is added for you, except on TikTok, which goes to your TikTok drafts to finish there.`:`Choose where to share this post. The verification link is added for you.`:F===`youtube`?`This is what YouTube will show, and who will be able to watch it.`:`Each platform posts its own version. What you leave alone goes out as written.`}),F===`pick`&&(0,E.jsxs)(`div`,{className:`mt-4 flex flex-col gap-2`,children:[fe.map(e=>
3{let t=de.has(e.key),n=ue.has(e.norm),r=A.includes(e.key),i=t||!n||r,a=t?`Already posted`:n?r?`Connection expired`:null:`Not connected`,o=b.includes(e.key),s=!n&&!r&&!t,c=C===e.key,l=i?`div`:`button`;return(0,E.jsxs)(l,{onClick:l===`button`?()=>Ce(e.key):void 0,...l===`button`?{disabled:i}:{},className:`flex h-[56px] items-center gap-3 rounded-[12px] border px-4 text-left transition-colors ${o?`border-primary bg-primary/10`:i?`cursor-default border-white/[.06] bg-white/[.03]`:`border-white/15 bg-white/[.06] hover:bg-white/[.09]`}`,children:[(0,E.jsx)(`span`,{className:i?`opacity-40`:``,children:(0,E.jsx)(te,{platform:e.norm,size:22})}),(0,E.jsx)(`span`,{className:`flex-1 font-sans text-[15px] ${i?`text-text-faint`:`text-text`}`,children:e.label}),s?(0,E.jsx)(`button`,{onClick:()=>se(e.key,e.norm),disabled:!!C,className:`rounded-full border border-primary/60 px-3 py-1.5 font-sans text-[12px] font-medium text-primary transition-colors hover:bg-primary/10 disabled:cursor-not-allowed disabled:opacity-50`,children:c?`Connectingâ¦`:`Connect`}):a&&(0,E.jsx)(`span`,{className:`font-sans text-[12px] text-text-faint`,children:a})]},e.key)}),fe.some(e=>e.norm===`x`&&!ue.has(`x`)&&!A.includes(e.key)&&!de.has(e.key))&&(0,E.jsx)(`p`,{className:`font-sans text-[12px] leading-snug text-text-faint`,children:`X adds a short confirmation step when you connect. Tick the box to continue and we'll bring you right back.`}),(0,E.jsxs)(`button`,{onClick:()=>!y&&ne(e=>!e),disabled:y,className:`flex h-[56px] items-center gap-3 rounded-[12px] border px-4 text-left transition-colors ${S?`border-primary bg-primary/10`:y?`cursor-not-allowed border-white/[.06] bg-white/[.03]`:`border-white/15 bg-white/[.06] hover:bg-white/[.09]`}`,children:[(0,E.jsx)(`span`,{className:`flex h-[22px] w-[22px] shrink-0 items-center justify-center rounded-[5px] bg-white/15 font-display text-[12px] font-bold text-text ${y?`opacity-40`:``}`,children:`H`}),(0,E.jsx)(`span`,{className:`flex-1 font-sans text-[15px] ${y?`text-text-faint`:`text-text`}`,children:`Hootsuite`}),(0,E.jsx)(`span`,{className:`font-sans text-[12px] text-text-faint`,children:S?`Pick it in Hootsuite`:y?`Already sent`:`Send to library`})]})]}),F===`youtube`&&L&&(0,E.jsx)(`div`,{className:`mt-4 flex min-h-0 flex-1 flex-col`,children:(0,E.jsx)(nt,{value:L,onChange:R})}),F===`customize`&&(0,E.jsx)(`div`,{className:`mt-4 flex min-h-0 flex-1 flex-col`,children:(0,E.jsx)(bt,{platforms:W,media:g??[],drafts:z,onChange:B,activeTab:le,onTab:V})}),F===`pick`&&b.length>0&&(0,E.jsxs)(`button`,{onClick:()=>P(!0),className:`mt-3 flex w-full items-center gap-2 rounded-xl bg-white/[.05] px-4 py-3 text-left transition-colors hover:bg-white/[.08]`,children:[(0,E.jsxs)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,className:`shrink-0 text-text-muted`,children:[(0,E.jsx)(`rect`,{x:`3`,y:`5`,width:`18`,height:`16`,rx:`2`}),(0,E.jsx)(`path`,{d:`M3 10h18M8 3v4M16 3v4`})]}),(0,E.jsx)(`span`,{className:`flex-1 font-sans text-[13px] text-text`,children:pe}),(0,E.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,className:`shrink-0 text-text-tertiary`,children:(0,E.jsx)(`path`,{d:`m9 18 6-6-6-6`})})]}),K&&(0,E.jsx)(`p`,{className:`mt-3 font-sans text-[13px] text-text-muted`,children:K}),ve&&(0,E.jsx)(rt,{className:`mt-3`}),s&&(0,E.jsx)(`p`,{className:`mt-3 rounded-xl border border-error/30 bg-error/10 px-3 py-2 font-sans text-[13px] text-error`,children:s}),D&&(0,E.jsx)(`p`,{className:`mt-3 rounded-xl border border-error/30 bg-error/10 px-3 py-2 font-sans text-[13px] text-error`,children:D}),(0,E.jsxs)(`div`,{className:`mt-6 shrink-0 gap-2 ${F===`pick`?`flex flex-col`:`flex justify-end`}`,children:[(0,E.jsx)(`button`,{onClick:xe,disabled:r||b.length===0&&!S||G.length>0||!!K||!!Se,title:G.length>0?`Too long for ${G.map(e=>Z[e]??e).join(` and `)}`:K??Se??void 0,className:`h-12 rounded-full bg-primary font-display text-[15px] font-medium text-bg transition-colors hover:bg-primary-hover disabled:cursor-not-allowed disabled:bg-btn-disabled disabled:text-white/45 ${F===`pick`?``:`order-2 w-[200px]`}`,children:r?`Postingâ¦`:b.length===0&&S?`Send to Hootsuite`:U?`Schedule`:`Post`}),F===`pick`&&h!==void 0&&(0,E.jsx)(`button`,{onClick:ye,disabled:r||b.length===0,title:b.length===0&&S?`Hootsuite has no version to customize â you compose it there`:void 0,className:`h-12 rounded-full border border-white/12 font-display text-[15px] font-medium text-text transition-colors hover:bg-white/[.06] disabled:cursor-not-allowed disabled:opacity-60`,children:`Customize for each social`}),(0,E.jsx)(`button`,{onClick:F===`customize`?()=>I(`pick`):F===`youtube`?()=>{R(null),I(`pick`)}:p,disabled:r,className:`h-12 rounded-full border border-white/12 font-display text-[15px] font-medium text-text transition-colors hover:bg-white/[.06] disabled:cursor-not-allowed disabled:opacity-60 ${F===`pick`?``:`order-1 w-[200px]`}`,children:F===`pick`?`Cancel`:`Back`})]}),(0,E.jsx)(ct,{open:ce,platforms:b,initial:M,onCancel:()=>P(!1),onConfirm:e=>{N(e),P(!1)},onClear:()=>{N({}),P(!1)}})]})]})})}var kt=`verda.media.unmuted`;function At(){try{return sessionStorage.getItem(kt)===`1`}catch{return!1}}function jt(e){try{e?sessionStorage.setItem(kt,`1`):sessionStorage.removeItem(kt)}catch{}}function Mt(e){e&&(e.muted=!At())}function Nt(e){jt(!e.currentTarget.muted)}var Q=new Map,$=new WeakMap,Pt=new WeakSet,Ft=new WeakSet,It=.5,Lt=[0,.1,.25,.4,.5,.6,.75,.9,1];function Rt(e){let t=e.currentTarget;if(Pt.has(t)){Pt.delete(t);return}Ft.add(t)}function zt(e){Ft.delete(e.currentTarget)}function Bt(){let e=null,t=0;for(let[n,r]of Q){if(!n.isConnected){Q.delete(n);continue}r>=It&&r>t&&(t=r,e=n)}for(let t of Q.keys())t!==e&&(t.paused||(Pt.add(t),t.pause()));e&&e.paused&&!Ft.has(e)&&e.play().catch(()=>{})}function Vt(e){if(!e||$.has(e))return;if(typeof IntersectionObserver>`u`){e.play().catch(()=>{});return}e.addEventListener(`pause`,Rt),e.addEventListener(`play`,zt),Q.set(e,0);let t=new IntersectionObserver(e=>{for(let t of e)Q.set(t.target,t.intersectionRatio);Bt()},{threshold:Lt});t.observe(e),$.set(e,t),e.addEventListener(`emptied`,()=>Ht(e),{once:!0})}function Ht(e){e&&($.get(e)?.disconnect(),$.delete(e),Q.delete(e),e.removeEventListener(`pause`,Rt),e.removeEventListener(`play`,zt))}var Ut=`/verify-identity?next=%2Fcreate`,Wt=`Verify your identity to post. Posts carry your verified name, so this is needed once per account.`;function Gt(e){return e?.response?.data?.error_reason===`VERIFICATION_REQUIRED`}export{De as A,k as B,tt as C,qe as D,Be as E,ye as F,K as I,pe as L,ke as M,Oe as N,Ve as O,Ae as P,L as R,$e as S,Je as T,ie as V,yt as _,Mt as a,ct as b,xt as c,Et as d,bt as f,mt as g,_t as h,Vt as i,Pe as j,Ke as k,Dt as l,gt as m,Ut as n,Nt as o,Z as p,Gt as r,Ot as s,Wt as t,Tt as u,ht as v,Ye as w,it as x,vt as y,F as z};
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.