PageSourceSearch

https://v3.quickbox.io/_next/static/chunks/96346-5960acca9993ddfc.js

js quickbox.io collected 2026-09-24 10:06:01 UTC 41,893 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[96346],{96346:(e,t,r)=>{r.r(t),r.d(t,{default:()=>j});var s=r(95155),a=r(12115),o=r(15927),i=r(26497),n=r(4496),l=r(45871);function d(e){let{text:t,imageUrl:r,imageAlt:a}=e,o=t.trim();return(0,s.jsx)("div",{className:"rounded-2xl border border-[#2f3336] bg-black p-4 text-[15px] leading-normal",children:(0,s.jsxs)("div",{className:"flex gap-3",children:[(0,s.jsx)("div",{className:"flex-shrink-0",children:(0,s.jsx)("div",{className:"w-10 h-10 rounded-full overflow-hidden bg-[#16181c] border border-[#2f3336] flex items-center justify-center",children:(0,s.jsx)("img",{src:"/qb_logo.svg",alt:"QuickBox",className:"w-7 h-7 object-contain"})})}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("div",{className:"flex items-center gap-1 flex-wrap",children:[(0,s.jsx)("span",{className:"font-bold text-[#e7e9ea] truncate",children:"QuickBox"}),(0,s.jsx)("svg",{viewBox:"0 0 24 24","aria-label":"Verified account",className:"w-[18px] h-[18px] flex-shrink-0 fill-[#1d9bf0]",children:(0,s.jsx)("path",{d:"M22.25 12c0-1.43-.88-2.67-2.19-3.34.46-1.39.2-2.9-.81-3.91s-2.52-1.27-3.91-.81c-.66-1.31-1.91-2.19-3.34-2.19s-2.68.88-3.34 2.19c-1.39-.46-2.9-.2-3.91.81s-1.27 2.52-.81 3.91c-1.31.66-2.19 1.91-2.19 3.34s.88 2.67 2.19 3.34c-.46 1.39-.2 2.9.81 3.91s2.52 1.26 3.91.81c.66 1.31 1.91 2.19 3.34 2.19s2.68-.88 3.34-2.19c1.39.45 2.9.2 3.91-.81s1.27-2.52.81-3.91c1.31-.67 2.19-1.91 2.19-3.34zm-11.71 4.2L6.8 12.46l1.41-1.42 2.26 2.26 4.8-5.23 1.47 1.36-6.2 6.77z"})}),(0,s.jsxs)("span",{className:"text-[#71767b] truncate",children:["@","QuickBoxIO"]}),(0,s.jsx)("span",{className:"text-[#71767b]",children:"\xb7"}),(0,s.jsx)("span",{className:"text-[#71767b]",children:"now"})]}),o?(0,s.jsx)("p",{className:"mt-1 text-[#e7e9ea] whitespace-pre-wrap break-words",children:t}):(0,s.jsx)("p",{className:"mt-1 text-[#71767b] italic",children:"Your post preview will appear here as you type…"}),r&&(0,s.jsx)("div",{className:"mt-3 rounded-2xl overflow-hidden border border-[#2f3336]",children:(0,s.jsx)("img",{src:r,alt:a||"Attached image preview",className:"w-full max-h-80 object-cover bg-[#16181c]"})})]})]})})}let c={unconfigured:"The social bot is not configured on this environment.",proxy_error:"Could not reach the social bot. Refresh the queue before trying again.",proxy_timeout:"The social bot took too long to respond. Posting may still finish. Refresh the queue and history before trying again.",invalid_bot_response:"The social bot returned an invalid or incomplete response. Refresh the queue and history to check the result.",cortex_disabled:"Draft generation is disabled (Cortex is off).",invalid_topic_seed:"That topic seed is not valid.",no_topic_available:"No fresh topic is available to draft right now.",recently_drafted:"A draft on this topic was created recently — try again later.",insufficient_context:"Not enough context to compose a post.",compose_failed:"The bot could not compose a draft. Try again.",already_posted:"This post was already posted and cannot be changed.",posting_in_progress:"This post is being posted. Refresh history to check the result.",not_approvable:"This post is no longer in a state that can be approved.",not_rejectable:"This post is no longer in a state that can be rejected.",not_schedulable:"This post is no longer a draft that can be scheduled.",not_reschedulable:"This post is not scheduled, so it cannot be rescheduled.",not_cancelable:"This post is not scheduled, so there is nothing to cancel.",invalid_scheduled_at:"Pick a time in the future to schedule this post.",post_failed:"Posting to X failed.",disabled:"The social service is currently disabled.",bad_request:"The request was rejected as invalid.",unauthorized:"The signed request was rejected by the bot.",not_found:"That post no longer exists.",oversized:"The post text is too large.",rate_limited:"Too many requests — slow down and retry."};function h(e,t){var r,s;return e?"post_failed"===e&&"string"==typeof t&&t.trim()?t:null!=(s=null!=(r=c[e])?r:t)?s:e:null!=t?t:"Something went wrong."}function u(e,t){let r=String(e||""),s="string"==typeof t?t.trim():"";if(!s||r.includes(s))return r;let a=280-(s.length+2);
1if(a<=0)return s.slice(0,280);let o=function(e,t){let r=String(e||"").trim();if(t<=0)return"";if(r.length<=t)return r;let s=r.slice(0,t),a=s.lastIndexOf(" ");return(a>t-40?s.slice(0,a):s).trimEnd()}(r,a);return"".concat(o).concat("\n\n").concat(s)}function x(e){let t=e=>String(e).padStart(2,"0");return"".concat(e.getFullYear(),"-").concat(t(e.getMonth()+1),"-").concat(t(e.getDate()),"T").concat(t(e.getHours()),":").concat(t(e.getMinutes()))}function p(e){let{postId:t,onDeleted:r,onUpdated:o,actionControl:i}=e,[n,d]=(0,a.useState)(!1),c="delete"===i.busy,u=null!==i.busy,[x,p]=(0,a.useState)(null);async function m(){if(i.start("delete")){p(null);try{var e;let s=await fetch("/api/admin/social/".concat(t),{method:"DELETE"}),a=await s.json().catch(()=>null);if(a&&a.ok||404===s.status)return void r(t);let i=a&&!a.ok?a.reason:"proxy_error",n=a&&!a.ok?a.message:void 0;p(h(i,n)),a&&!a.ok&&(null==(e=a.data)?void 0:e.post)&&(null==o||o(a.data.post)),d(!1)}catch(e){p("Network error — the post was not deleted. Try again."),d(!1)}finally{i.finish()}}}return n?(0,s.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,s.jsx)("span",{className:"text-[10px] text-white/50",children:"Delete?"}),(0,s.jsx)("button",{onClick:m,disabled:u,className:"flex items-center gap-1 px-2.5 py-1 rounded-md bg-red-500/15 hover:bg-red-500/25 border border-red-500/30 text-red-300 text-[11px] font-medium transition-all disabled:opacity-40",children:c?(0,s.jsx)("span",{className:"w-3 h-3 rounded-full border-2 border-red-300/40 border-t-red-300 animate-spin"}):"Delete"}),(0,s.jsx)("button",{onClick:()=>d(!1),disabled:u,className:"px-2.5 py-1 rounded-md bg-white/[0.03] hover:bg-white/[0.06] border border-white/[0.08] text-white/50 hover:text-white/70 text-[11px] transition-all disabled:opacity-40",children:"Cancel"}),x&&(0,s.jsx)("span",{className:"text-[10px] text-amber-300/90 break-words",children:x})]}):(0,s.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,s.jsx)(l.m,{content:"Delete this post permanently",children:(0,s.jsx)("button",{onClick:()=>{u||(p(null),d(!0))},disabled:u,"aria-label":"Delete post",className:"flex items-center justify-center w-7 h-7 rounded-md bg-white/[0.02] hover:bg-red-500/10 border border-white/[0.06] hover:border-red-500/20 text-white/35 hover:text-red-300 transition-all disabled:opacity-40 disabled:cursor-not-allowed",children:(0,s.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})}),x&&(0,s.jsx)("span",{className:"text-[10px] text-amber-300/90 break-words",children:x})]})}function m(e){let{post:t,onUpdated:r,blockedReason:o,actionControl:i}=e,n="SCHEDULED"===t.status,[d,c]=(0,a.useState)(!1),[u,p]=(0,a.useState)(""),m=i.busy,b=null!==m,[g,f]=(0,a.useState)(null),w=x(new Date);function j(){b||o||(p(n?function(e){if(!e)return"";let t=new Date(e);return Number.isNaN(t.getTime())?"":x(t)}(t.scheduledAt):""),f(null),c(!0))}async function v(e){if(("cancel"===e||!o&&y)&&i.start(e)){f(null);try{var s;let a=await fetch("/api/admin/social/".concat(t.id,"/").concat(e),{method:"POST",headers:{"Content-Type":"application/json"},body:"cancel"===e?void 0:JSON.stringify({scheduledAt:new Date(u).toISOString()})}),o=await a.json().catch(()=>null);if(o&&o.ok){r(o.data.post),c(!1);return}let i=o&&!o.ok?o.reason:"proxy_error",n=o&&!o.ok?o.message:void 0;f(h(i,n)),o&&!o.ok&&(null==(s=o.data)?void 0:s.post)&&r(o.data.post)}catch(e){f("Network error — the schedule was not changed. Try again.")}finally{i.finish()}}}let y=u.trim().length>0&&!Number.isNaN(new Date(u).getTime())&&u>=w;return(0,s.jsxs)("div",{className:"space-y-2",children:[n&&t.scheduledAt&&!d&&(0,s.jsxs)("div",{className:"flex items-start gap-2 px-2.5 py-2 rounded-lg bg-amber-500/10 border border-amber-500/20 text-[11px]",children:[(0,s.jsx)("svg",{className:"w-3.5 h-3.5 text-amber-400 flex-shrink-0 mt-0.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,s.jsxs)("div",{className:"text-amber-200/90 leading-snug",children:[(0,s.jsxs)("span",{className:"font-medium",children:["Auto-posts ",new Date(t.scheduledAt).toLocaleStr
1ing()]}),(0,s.jsx)("span",{className:"text-amber-200/60",children:" — publishes to X unattended and spends an X credit."})]})]}),d?(0,s.jsxs)("div",{className:"space-y-2 p-2.5 rounded-lg bg-white/[0.03] border border-white/[0.08]",children:[(0,s.jsxs)("label",{className:"block text-[10px] font-medium text-white/50 uppercase tracking-wider",children:[n?"New auto-post time":"Auto-post time"," (your local time)"]}),(0,s.jsx)("input",{type:"datetime-local",value:u,min:w,onChange:e=>p(e.target.value),disabled:b,"aria-label":"Scheduled auto-post time",className:"w-full bg-white/[0.02] border border-white/[0.08] rounded-lg px-3 py-2 text-sm text-white focus:outline-none focus:border-[#26AE7F]/40 focus:ring-1 focus:ring-[#26AE7F]/30 transition-all disabled:opacity-50 [color-scheme:dark]"}),(0,s.jsx)("p",{className:"text-[10px] text-amber-200/70 leading-snug",children:"This post will publish to X automatically at the time above, with no further review, and will spend one X post credit."}),g&&(0,s.jsx)("p",{className:"text-[10px] text-amber-300/90 break-words",children:g}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>v(n?"reschedule":"schedule"),disabled:b||!!o||!y,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-gradient-to-r from-[#26AE7F] to-[#2aebcb] text-white font-semibold text-[11px] transition-all disabled:opacity-40 disabled:cursor-not-allowed",children:["schedule"===m||"reschedule"===m?(0,s.jsx)("span",{className:"w-3 h-3 rounded-full border-2 border-white/40 border-t-white animate-spin"}):(0,s.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,s.jsx)("span",{children:n?"Update schedule":"Schedule auto-post"})]}),(0,s.jsx)("button",{type:"button",onClick:()=>c(!1),disabled:b,className:"px-3 py-1.5 rounded-lg bg-white/[0.03] hover:bg-white/[0.06] border border-white/[0.08] text-white/50 hover:text-white/70 text-[11px] transition-all disabled:opacity-40",children:"Cancel"})]})]}):n?(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(l.m,{content:o||"Change the auto-post time",children:(0,s.jsx)("button",{type:"button",onClick:j,disabled:b||!!o,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-white/[0.03] hover:bg-white/[0.06] border border-white/[0.08] text-white/60 hover:text-white/80 text-[11px] font-medium transition-all disabled:opacity-40 disabled:cursor-not-allowed",children:"Reschedule"})}),(0,s.jsx)(l.m,{content:"Disarm the schedule — returns this to a plain draft (nothing posts)",children:(0,s.jsx)("button",{type:"button",onClick:()=>v("cancel"),disabled:b,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-white/[0.03] hover:bg-red-500/15 border border-white/[0.08] hover:border-red-500/25 text-white/60 hover:text-red-300 text-[11px] font-medium transition-all disabled:opacity-40 disabled:cursor-not-allowed",children:"cancel"===m?(0,s.jsx)("span",{className:"w-3 h-3 rounded-full border-2 border-white/30 border-t-white/70 animate-spin"}):"Cancel schedule"})}),g&&(0,s.jsx)("span",{className:"text-[10px] text-amber-300/90 break-words",children:g})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(l.m,{content:o||"Arm this draft to post to @QuickBoxIO automatically at a future time",children:(0,s.jsxs)("button",{type:"button",onClick:j,disabled:b||!!o,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-white/[0.03] hover:bg-white/[0.06] border border-white/[0.08] text-white/60 hover:text-white/80 text-[11px] font-medium transition-all disabled:opacity-40 disabled:cursor-not-allowed",children:[(0,s.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),"Schedule"]})}),g&&(0,s.jsx)("span",{className:"text-[10px] text-amber-300/90 break-words",children:g})]})]})}function b(e){var t,r,o;let{post:i,onResolved:n,onUpdated:c,onDeleted:x}=e,b="DRAFT"===i.status,g="SCHEDULED"===i.status,[f,w]=(0,a.useState)(i.text),[j,v]=(0,a.useState)(!1),[y,k]=(0,a.useState)(null),N=(0,a.useRef)(null),[A,S]=(0,a.useState)(null),[C,E]=(0,a.useState)(!1),T=(b||g)&&!!(n&&c)&&!C,D=f.length>280,L=280-f.length,F=f.trim()!==i.text.trim(),_=u(T||C?f:i.text,i.sourceUrl),P="POSTED"===i.status&&"dryrun"===i.tweetId,M=function(e,t){if(t)return{label:"Staged",className:"bg-amber-500/10 border-amber-500/25 text-amber-300"};switch(e){case"POSTED":return{label:"Posted",className:"bg-[#26AE7F]/10 border-[#26AE7F]/25 text-[#5fd3aa]"};case"SCHEDULED":return{label:"Scheduled",className:"bg-amber-500/10 border-amber-500/25 text-amber-300"};case"REJECTED":return{label:"Rejected",className:"bg-white/[0.04] border-white/[0.1] text-white/50"};case"FAILED":return{label:"Failed",className:"bg-red-500/10 border-red-500/25 text-red-300"};case"APPROVED":return{label:"Posting",className:"bg-blue-500/10 border-blue-500/25 text-blue-300"};default:return{label:"Draft",className:"bg-white/[0.04] border-white/[0.1] text-white/50"}}}(i.status,P),R="SCHEDULED"===(t=i).status&&t.scheduledAt?new Date(t.scheduledAt).toLocaleStr
1ing():new Date(null!=(o=null!=(r=t.postedAt)?r:t.decidedAt)?o:t.createdAt).toLocaleString(),B={busy:y,start:e=>null===N.current&&(N.current=e,k(e),!0),finish(){"unknown"!==N.current&&(N.current=null),k(null)}};function U(){N.current="unknown",E(!0)}async function I(e){if(b&&("approve"!==e||!D&&f.trim())&&B.start(e)){S(null);try{var t,r,s;let a=await fetch("/api/admin/social/".concat(i.id,"/").concat(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify("approve"===e&&F?{text:f}:{})}),o=await a.json().catch(()=>null);if(o&&o.ok){null==n||n(o.data.post);return}if(404===a.status||null!==o&&!o.ok&&"not_found"===o.reason){S("This draft no longer exists — it may have been handled already."),setTimeout(()=>null==n?void 0:n(i),1600);return}let l=o&&!o.ok?o.reason:"proxy_error",d=o&&!o.ok&&(o.message||(null==(r=o.data)||null==(t=r.post)?void 0:t.error))||void 0;S(h(l,d));let u=o&&!o.ok?null==(s=o.data)?void 0:s.post:void 0;"approve"===e&&(!o||["proxy_error","proxy_timeout","invalid_bot_response"].includes(l)||a.status>=500&&!u)&&U(),u&&(null==c||c(u))}catch(t){S("The response was interrupted. Posting may still finish. Refresh the queue and history before trying again."),"approve"===e&&U()}finally{B.finish()}}}return(0,s.jsxs)("div",{className:"flex flex-col rounded-xl bg-gradient-to-br from-white/[0.04] to-transparent border border-white/[0.06] p-3 sm:p-4 gap-3",children:[(0,s.jsx)(d,{text:_,imageUrl:i.imageUrl,imageAlt:"Attached image preview"}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-[10px] text-white/40",children:[(0,s.jsx)("span",{className:"px-2 py-0.5 rounded-full border uppercase tracking-wider ".concat(M.className),children:M.label}),i.topicSeed&&(0,s.jsx)("span",{className:"px-2 py-0.5 rounded-full bg-[#26AE7F]/10 border border-[#26AE7F]/20 text-[#5fd3aa] break-all",children:i.topicSeed}),i.sourceUrl&&(0,s.jsx)("a",{href:i.sourceUrl,target:"_blank",rel:"noopener noreferrer",className:"text-[#5fd3aa] hover:text-[#7be0bd] underline decoration-dotted break-all",children:i.sourceType?"".concat(i.sourceType," source"):"source"}),i.decidedBy&&(0,s.jsxs)("span",{className:"text-white/40 break-all",children:["by ",i.decidedBy]}),(0,s.jsx)("span",{className:"ml-auto font-mono text-white/30",children:R})]}),T&&b&&j&&(0,s.jsxs)("div",{children:[(0,s.jsx)("textarea",{value:f,onChange:e=>w(e.target.value),rows:4,disabled:null!==y,"aria-label":"Tweet text",className:"w-full bg-white/[0.02] border border-white/[0.06] rounded-lg px-3 py-2 text-sm text-white placeholder-white/25 focus:outline-none focus:border-[#26AE7F]/40 focus:ring-1 focus:ring-[#26AE7F]/30 transition-all resize-none disabled:opacity-60"}),(0,s.jsxs)("div",{className:"flex items-center justify-between mt-1 text-[10px]",children:[(0,s.jsx)("span",{className:"text-white/30",children:F?"Edited — will post as shown":"Auto-generated"}),(0,s.jsxs)("span",{className:D?"text-red-400 font-medium":"text-white/40",children:[L," left"]})]})]}),A&&(0,s.jsx)("div",{role:"alert",className:"text-xs text-amber-300/90 bg-amber-500/10 border border-amber-500/20 rounded-lg px-3 py-2 break-words",children:A}),T&&c&&(0,s.jsx)(m,{post:i,onUpdated:c,actionControl:B,blockedReason:F?"Approve to post your edit — scheduling arms the saved draft text, not the unsaved change.":void 0}),T?(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[b&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(l.m,{content:D?"Text exceeds 280 characters":"Approve and post to @QuickBoxIO on X",children:(0,s.jsxs)("button",{onClick:()=>I("approve"),disabled:null!==y||D||0===f.trim().length,className:"flex items-center gap-1.5 px-3.5 py-2 bg-gradient-to-r from-[#26AE7F] to-[#2aebcb] text-white rounded-lg font-semibold text-xs transition-all disabled:opacity-40 disabled:cursor-not-allowed shadow-lg shadow-[#26AE7F]/20",children:["approve"===y?(0,s.jsx)("span",{className:"w-3.5 h-3.5 rounded-full border-2 border-white/40 border-t-white animate-spin"}):(0,s.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.2,d:"M5 13l4 4L19 7"})}),(0,s.jsx)("span",{children:"approve"===y?"Posting…":"Approve & Post"})]})}),(0,s.jsx)(l.m,{content:"Reject this draft (not posted)",children:(0,s.jsxs)("button",{onClick:()=>I("reject"),disabled:null!==y,className:"flex items-center gap-1.5 px-3.5 py-2 bg-white/[0.03] hover:bg-red-500/15 border border-white/[0.08] hover:border-red-500/25 text-white/60 hover:text-red-300 rounded-lg font-medium text-xs transition-all disabled:opacity-40 disabled:cursor-not-allowed",children:["reject"===y?(0,s.jsx)("span",{className:"w-3.5 h-3.5 rounded-full border-2 border-white/30 border-t-white/70 animate-spin"}):(0,s.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.2,d:"M6 18L18 6M6 6l12 12"})}),(0,s.jsx)("span",{children:"Reject"})]})}),(0,s.jsx)(l.m,{content:j?"Done editing":"Edit the post text before approving",children:(0,s.jsx)("button",{type:"button",onClick:()=>v(e=>!e),disabled:null!==y,className:"flex items-center gap-1.5 px-3 py-2 rounded-lg bg-white/[0.03] hover:bg-white/[0.06] border border-white/[0.08] text-white/60 hover:text-white/80 text-xs font-medium transition-all disabled:opacity-40",children:j?"Done":"Edit"})})]}),(0,s.jsx)("div",{className:"ml-auto",children:(0,s.jsx)(p,{postId:i.id,onDeleted:x,onUpdated:c,actionControl:B})})]}):(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-3 text-[10px] text-white/40",children:["POSTED"===i.status&&!P&&i.tweetId&&(0,s.jsx)("a",{href:"https://x.com/".concat("QuickBoxIO","/status/").concat(i.tweetId),target:"_blank",rel:"noopener noreferrer",className:"text-[#5fd3aa] hover:text-[#7be0bd] underline decoration-dotted break-all",children:"View on X"}),P&&(0,s.jsx)(l.m,{content:"Staged in dry-run mode — not posted to X live",children:(0,s.jsx)("span",{className:"text-amber-300/80 cursor-help",children:"Staged (dry-run)"})}),"FAILED"===i.status&&i.error&&!A&&(0,s.jsxs)("span",{role:"alert",className:"text-red-300/80 break-words",children:["Error: ",i.error]}),"APPROVED"===i.status&&(0,s.jsx)("span",{children:"Posting is in progress. Refresh history to check the result."}),"APPROVED"!==i.status&&!C&&(0,s.jsx)("div",{className:"ml-auto",children:(0,s.jsx)(p,{postId:i.id,onDeleted:x,onUpdated:c,actionControl:B})})]})]})}let g=["image/png","image/jpeg","image/webp","image/gif"];function f(e){let{disabled:t,onDraftCreated:r}=e,[o,i]=(0,a.useState)(""),[n,c]=(0,a.useState)(""),[x,p]=(0,a.useState)(""),[m,b]=(0,a.useState)(null),[f,w]=(0,a.useState)(null),[j,v]=(0,a.useState)(null),[y,k]=(0,a.useState)(!1),[N,A]=(0,a.useState)(!1),[S,C]=(0,a.useState)(!1),[E,T]=(0,a.useState)(!1),[D,L]=(0,a.useState)(null),F=(0,a.useRef)(null),_=o.length>280,P=280-o.length,M=N||S||E,R=!t&&!M&&o.trim().length>0&&!_,B=u(o,x.trim()),U=x.trim(),I=U.length>0&&!o.includes(U)&&B!=="".concat(o.trim()).concat("\n\n").concat(U);async function O(){A(!0),L(null);try{let r=await fetch("/api/admin/social/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n.trim()?{topicSeed:n.trim()}:{})}),s=await r.json().catch(()=>null);if(s&&s.ok){var e,t;i(s.data.text),p(null!=(e=s.data.sourceUrl)?e:""),v(null!=(t=s.data.sourceImageUrl)?t:null),y&&H(),L({type:"success",text:"Draft generated — edit it below, then save."})}else{let e=s&&!s.ok?s.reason:"proxy_error";L({type:"error",text:h(e,s&&!s.ok?s.message:void 0)})}}catch(e){L({type:"error",text:"Network error — no draft was generated. Try again."})}finally{A(!1)}}async function W(e){if(!g.includes(e.type))return void L({type:"error",text:"Unsupported image type. Use PNG, JPEG, WebP, or GIF."});if(e.size>5242880)return void L({type:"error",text:"Image is too large — the maximum is 5MB."});C(!0),L(null);try{let t=new FormData;t.append("file",e);let r=await fetch("/api/admin/social/images",{method:"POST",body:t}),s=await r.json().catch(()=>null);s&&s.ok?(b(s.data.url),w(s.data.altText),k(!1),L({type:"success",text:"Image attached."})):L({type:"error",text:s&&!s.ok&&s.message||"Upload failed. Try again."})}catch(e){L({type:"error",text:"Network error during upload. Try again."})}finally{C(!1),F.current&&(F.current.value="")}}function H(){b(null),w(null),k(!1),F.current&&(F.current.value="")}async function z(){if(R){T(!0),L(null);try{let e=await fetch("/api/admin/social/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:B.trim(),...m?{imageUrl:m}:{}})}),t=await e.json().catch(()=>null);if(t&&t.ok)r(t.data.post),L({type:"success",text:"Draft saved — review it in the Drafts tab."}),i(""),c(""),p(""),v(null),H();else{let e=t&&!t.ok?t.reason:"proxy_error";L({type:"error",text:h(e,t&&!t.ok?t.message:void 0)})}}catch(e){L({type:"error",text:"Network error — the draft was not saved. Try again."})}finally{T(!1)}}}return(0,s.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-5",children:[(0,s.jsxs)("div",{className:"bg-gradient-to-br from-white/[0.04] to-transparent border border-white/[0.06] rounded-xl p-5 sm:p-6 space-y-5",children:[(0,s.jsxs)("div",{className:"pb-4 border-b border-white/[0.06]",children:[(0,s.jsx)("h3",{className:"text-base sm:text-lg font-semibold text-white",children:"Compose a promo"}),(0,s.jsx)("p",{className:"text-white/40 text-xs sm:text-sm mt-0.5",children:"Write your own post or generate one, attach an image, and save it as a draft — nothing posts without approval."})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("label",{htmlFor:"topicSeed",className:"block text-xs font-medium text-white/50 mb-1.5 uppercase tracking-wider",children:["Topic seed ",(0,s.jsx)("span",{className:"text-white/25 normal-case tracking-normal",children:"(optional)"})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)("input",{id:"topicSeed",type:"text",value:n,onChange:e=>c(e.target.value),disabled:t||M,maxLength:120,className:"flex-1 min-w-0 bg-white/[0.02] border border-white/[0.06] rounded-lg px-3 py-2 text-sm text-white placeholder-white/25 focus:outline-none focus:border-[#26AE7F]/40 focu
1s:ring-1 focus:ring-[#26AE7F]/30 transition-all disabled:opacity-50",placeholder:"e.g. seedbox performance, rTorrent, 100% ownership"}),(0,s.jsx)(l.m,{content:"Ask the bot to draft a post into the editor — you can edit it before saving",children:(0,s.jsxs)("button",{type:"button",onClick:O,disabled:t||M,className:"flex-shrink-0 flex items-center gap-1.5 px-3.5 py-2 bg-white/[0.04] hover:bg-white/[0.08] border border-white/[0.1] text-white/80 rounded-lg font-medium text-xs transition-all disabled:opacity-40 disabled:cursor-not-allowed",children:[N?(0,s.jsx)("span",{className:"w-3.5 h-3.5 rounded-full border-2 border-white/40 border-t-white animate-spin"}):(0,s.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 3v4M3 5h4M6 17v4m-2-2h4m5-16l2.286 6.857L21 12l-5.714 2.143L13 21l-2.286-6.857L5 12l5.714-2.143L13 3z"})}),(0,s.jsx)("span",{children:N?"Drafting…":"Draft a fact"})]})})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"composerText",className:"block text-xs font-medium text-white/50 mb-1.5 uppercase tracking-wider",children:"Post text"}),(0,s.jsx)("textarea",{id:"composerText",value:o,onChange:e=>i(e.target.value),disabled:t||M,rows:5,className:"w-full bg-white/[0.02] border border-white/[0.06] rounded-lg px-3 py-2 text-sm text-white placeholder-white/25 focus:outline-none focus:border-[#26AE7F]/40 focus:ring-1 focus:ring-[#26AE7F]/30 transition-all resize-none disabled:opacity-50",placeholder:"Write your @QuickBoxIO post…"}),(0,s.jsx)("div",{className:"flex items-center justify-end mt-1 text-[10px]",children:(0,s.jsxs)("span",{className:_?"text-red-400 font-medium":"text-white/40",children:[P," left"]})})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("label",{htmlFor:"sourceLink",className:"block text-xs font-medium text-white/50 mb-1.5 uppercase tracking-wider",children:["Source link ",(0,s.jsx)("span",{className:"text-white/25 normal-case tracking-normal",children:"(optional)"})]}),(0,s.jsx)("input",{id:"sourceLink",type:"url",inputMode:"url",value:x,onChange:e=>{let t=e.target.value;t.trim()!==x.trim()&&(v(null),y&&(H(),L(null))),p(t)},disabled:t||M,className:"w-full bg-white/[0.02] border border-white/[0.06] rounded-lg px-3 py-2 text-sm text-white placeholder-white/25 focus:outline-none focus:border-[#26AE7F]/40 focus:ring-1 focus:ring-[#26AE7F]/30 transition-all disabled:opacity-50",placeholder:"https://quickbox.io/… (appended to the post)"}),(0,s.jsx)("p",{className:"mt-1 text-[10px] text-white/30",children:I?"Appended to the post — your text was trimmed so the link fits the 280 limit (see preview).":"Appended to the end of the post. The preview shows the final tweet."})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{className:"block text-xs font-medium text-white/50 mb-1.5 uppercase tracking-wider",children:"Image (optional)"}),j&&(0,s.jsx)("div",{className:"mb-3",children:(0,s.jsx)(l.m,{content:"Attach the source article's image to this draft",children:(0,s.jsx)("button",{type:"button","aria-pressed":y,onClick:()=>{t||M||(b(j),w("Source article image"),k(!0),L({type:"success",text:"Source image attached."}))},disabled:t||M,className:"px-3 py-2 rounded-lg bg-white/[0.04] hover:bg-white/[0.08] border border-white/[0.1] text-white/80 text-xs font-medium transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#26AE7F] disabled:opacity-40 disabled:cursor-not-allowed",children:y?"Source image selected":"Use source image"})})}),(0,s.jsx)("input",{ref:F,type:"file",accept:g.join(","),className:"hidden",onChange:e=>{var t;let r=null==(t=e.target.files)?void 0:t[0];r&&W(r)}}),m?(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("img",{src:m,alt:f||"Attached image",className:"w-16 h-16 rounded-lg object-cover border border-white/[0.1]"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(l.m,{content:"Replace the attached image",children:(0,s.jsx)("button",{type:"button",onClick:()=>{var e;return null==(e=F.current)?void 0:e.click()},disabled:t||M,className:"px-3 py-1.5 rounded-lg bg-white/[0.03] hover:bg-white/[0.06] border border-white/[0.08] text-white/60 hover:text-white/80 text-xs transition-all disabled:opacity-40 disabled:cursor-not-allowed",children:"Replace"})}),(0,s.jsx)(l.m,{content:"Remove the attached image",children:(0,s.jsx)("button",{type:"button",onClick:()=>{H(),L(null)},disabled:t||M,className:"px-3 py-1.5 rounded-lg bg-white/[0.03] hover:bg-red-500/15 border border-white/[0.08] hover:border-red-500/25 text-white/60 hover:text-red-300 text-xs transition-all disabled:opacity-40 disabled:cursor-not-allowed",children:"Remove"})})]})]}):(0,s.jsxs)("button",{type:"button",onClick:()=>{var e;return null==(e=F.current)?void 0:e.click()},disabled:t||M,className:"flex items-center gap-2 px-4 py-2.5 rounded-lg bg-white/[0.02] hover:bg-white/[0.05] border border-dashed border-white/[0.12] text-white/50 hover:text-white/70 text-xs transition-all disabled:opacity-40 disabled:cursor-not-allowed w-full justify-center",children:[S?(0,s.jsx)("span",{className:"w-4 h-4 rounded-full border-2 border-white/40 border-t-white animate-spin"}):(0,s.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})}),(0,s.jsx)("span",{children:S?"Uploading…":"Upload an image (PNG, JPEG, WebP, GIF \xb7 max 5M
1B)"})]})]}),D&&(0,s.jsx)("div",{className:"text-xs rounded-lg px-3 py-2 border ".concat("success"===D.type?"text-[#5fd3aa] bg-[#26AE7F]/10 border-[#26AE7F]/20":"text-amber-300/90 bg-amber-500/10 border-amber-500/20"),children:D.text}),(0,s.jsx)(l.m,{content:_?"Text exceeds 280 characters":"Save as a draft for review",children:(0,s.jsx)("button",{type:"button",onClick:z,disabled:!R,className:"flex items-center gap-2 px-5 py-2.5 bg-gradient-to-r from-[#26AE7F] to-[#2aebcb] text-white rounded-lg font-semibold text-sm transition-all disabled:opacity-40 disabled:cursor-not-allowed shadow-lg shadow-[#26AE7F]/20",children:E?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"w-4 h-4 rounded-full border-2 border-white/40 border-t-white animate-spin"}),(0,s.jsx)("span",{children:"Saving…"})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),(0,s.jsx)("span",{children:"Save draft"})]})})})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("span",{className:"block text-xs font-medium text-white/50 uppercase tracking-wider",children:"Live preview"}),(0,s.jsx)(d,{text:B,imageUrl:m,imageAlt:f}),(0,s.jsx)("p",{className:"text-[10px] text-white/30",children:"This is how the post will appear on X once approved."})]})]})}async function w(e){try{let t=await fetch("/api/admin/social/queue?status=".concat(e),{cache:"no-store"}),r=await t.json().catch(()=>null);if(r&&r.ok)return{ok:!0,posts:r.data.posts};return{ok:!1,reason:r&&!r.ok?r.reason:"proxy_error",message:r&&!r.ok?r.message:void 0}}catch(e){return{ok:!1,reason:"proxy_error"}}}function j(){let[e,t]=(0,a.useState)("drafts"),[r,d]=(0,a.useState)([]),[c,u]=(0,a.useState)(!1),[x,p]=(0,a.useState)(null),[m,g]=(0,a.useState)([]),[j,N]=(0,a.useState)(!1),[A,S]=(0,a.useState)(null),C=(null==x?void 0:x.reason)==="unconfigured"||(null==A?void 0:A.reason)==="unconfigured",E=(0,a.useCallback)(async()=>{u(!0);let e=await Promise.all([w("DRAFT"),w("SCHEDULED")]),t=e.find(e=>!e.ok);if(t){p({reason:t.reason,message:t.message}),u(!1);return}d(e.flatMap(e=>e.ok?e.posts:[]).sort((e,t)=>{var r,s;let a="SCHEDULED"===e.status,o="SCHEDULED"===t.status;return a&&o?new Date(null!=(r=e.scheduledAt)?r:0).getTime()-new Date(null!=(s=t.scheduledAt)?s:0).getTime():a!==o?a?-1:1:new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime()})),p(null),u(!1)},[]),T=(0,a.useCallback)(async()=>{N(!0);let e=await Promise.all([w("APPROVED"),w("POSTED"),w("REJECTED"),w("FAILED")]),t=e.find(e=>!e.ok);if(t){S({reason:t.reason,message:t.message}),N(!1);return}g(e.flatMap(e=>e.ok?e.posts:[]).sort((e,t)=>{var r,s;return new Date(null!=(r=t.decidedAt)?r:t.createdAt).getTime()-new Date(null!=(s=e.decidedAt)?s:e.createdAt).getTime()})),S(null),N(!1)},[]);(0,a.useEffect)(()=>{"drafts"===e&&E(),"history"===e&&T()},[e,E,T]);let D=e=>{d(t=>t.filter(t=>t.id!==e.id))},L=e=>{d(t=>t.map(t=>t.id===e.id?e:t).sort((e,t)=>{var r,s;let a="SCHEDULED"===e.status,o="SCHEDULED"===t.status;return a&&o?new Date(null!=(r=e.scheduledAt)?r:0).getTime()-new Date(null!=(s=t.scheduledAt)?s:0).getTime():a!==o?a?-1:1:new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime()}))},F=e=>{d(t=>t.filter(t=>t.id!==e))},_=e=>{g(t=>t.filter(t=>t.id!==e))},P=[{id:"drafts",label:"Drafts",icon:(0,s.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})},{id:"compose",label:"Compose",icon:(0,s.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})},{id:"history",label:"History",icon:(0,s.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})})}];return(0,s.jsx)(n.U,{children:(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsx)("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"w-12 h-12 rounded-xl bg-gradient-to-br from-[#26AE7F]/20 to-[#2aebcb]/5 border border-[#26AE7F]/30 flex items-center justify-center",children:(0,s.jsx)("svg",{className:"w-6 h-6 text-[#26AE7F]",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8.684 13.342C8.886 12.938 9 12.482 9 12c0-.482-.114-.938-.316-1.342m0 2.684a3 3 0 110-2.684m0 2.684l6.632 3.316m-6.632-6l6.632-3.3
116m0 0a3 3 0 105.367-2.684 3 3 0 00-5.367 2.684zm0 9.316a3 3 0 105.368 2.684 3 3 0 00-5.368-2.684z"})})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h1",{className:"text-2xl sm:text-3xl font-bold text-white",children:"Social Promotion"}),(0,s.jsxs)("p",{className:"text-white/40 text-xs sm:text-sm mt-0.5",children:["Review, edit & approve @","QuickBoxIO"," promo drafts before they post to X"]})]})]})}),C&&(0,s.jsxs)("div",{className:"flex items-start gap-3 px-4 py-3 rounded-xl bg-amber-500/10 border border-amber-500/20",children:[(0,s.jsx)("svg",{className:"w-5 h-5 text-amber-400 flex-shrink-0 mt-0.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),(0,s.jsxs)("div",{className:"text-sm text-amber-200/90",children:[(0,s.jsx)("p",{className:"font-medium",children:"The social bot is not connected on this environment."}),(0,s.jsx)("p",{className:"text-amber-200/60 text-xs mt-0.5",children:"Drafts, composing, and posting are disabled until the bot API is configured."})]})]}),(0,s.jsx)("div",{className:"flex items-center gap-1 p-0.5 bg-white/[0.02] border border-white/[0.06] rounded-xl w-fit",children:P.map(a=>(0,s.jsxs)("button",{onClick:()=>t(a.id),className:"relative px-4 py-2 rounded-lg font-medium text-xs transition-all duration-200 ".concat(e===a.id?"text-white":"text-white/40 hover:text-white/60 hover:bg-white/[0.02]"),children:[e===a.id&&(0,s.jsx)(o.P.div,{layoutId:"activeSocialTab",className:"absolute inset-0 bg-gradient-to-r from-[#26AE7F]/20 to-[#2aebcb]/10 border border-[#26AE7F]/30 rounded-lg",transition:{type:"spring",bounce:.2,duration:.6}}),(0,s.jsxs)("span",{className:"relative flex items-center gap-1.5",children:[a.icon,(0,s.jsx)("span",{children:a.label}),"drafts"===a.id&&r.length>0&&(0,s.jsx)("span",{className:"relative ml-0.5 px-1.5 py-0.5 rounded-full bg-[#26AE7F]/20 text-[#5fd3aa] text-[10px] font-mono leading-none",children:r.length})]})]},a.id))}),(0,s.jsxs)(i.N,{mode:"wait",children:["drafts"===e&&(0,s.jsxs)(o.P.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.2},className:"space-y-3",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("span",{className:"text-white/50 text-xs uppercase tracking-wider",children:"Pending review"}),(0,s.jsx)(l.m,{content:"Reload drafts",children:(0,s.jsxs)("button",{onClick:E,disabled:c,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-white/[0.03] hover:bg-white/[0.06] border border-white/[0.08] text-white/50 hover:text-white/70 text-xs transition-all disabled:opacity-50",children:[(0,s.jsx)("svg",{className:"w-3.5 h-3.5 ".concat(c?"animate-spin":""),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),"Refresh"]})})]}),c?(0,s.jsx)(v,{label:"Loading drafts…"}):x&&"unconfigured"!==x.reason?(0,s.jsx)(k,{text:h(x.reason,x.message),onRetry:E}):0===r.length?(0,s.jsx)(y,{title:C?"Bot not connected":"No drafts to review",hint:C?"Configure the bot API to see auto-generated drafts.":"New auto-generated drafts will appear here for approval."}):(0,s.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4 items-start",children:r.map(e=>(0,s.jsx)(b,{post:e,onResolved:D,onUpdated:L,onDeleted:F},e.id))})]},"drafts"),"compose"===e&&(0,s.jsx)(o.P.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.2},children:(0,s.jsx)(f,{disabled:C,onDraftCreated:e=>{d(t=>[e,...t.filter(t=>t.id!==e.id)])}})},"compose"),"history"===e&&(0,s.jsxs)(o.P.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.2},className:"space-y-3",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("span",{className:"text-white/50 text-xs uppercase tracking-wider",children:"Outbound history"}),(0,s.jsx)(l.m,{content:"Reload history",children:(0,s.jsxs)("button",{onClick:T,disabled:j,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-white/[0.03] hover:bg-white/[0.06] border border-white/[0.08] text-white/50 hover:text-white/70 text-xs transition-all disabled:opacity-50",children:[(0,s.jsx)("svg",{className:"w-3.5 h-3.5 ".concat(j?"animate-spin":""),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),"Refresh"]})})]}),j?(0,s.jsx)(v,{label:"Loading history…"}):A&&"unconfigured"!==A.reason?(0,s.jsx)(k,{text:h(A.reason,A.message),onRetry:T}):0===m.length?(0,s.jsx)(y,{title:C?"Bot not connected":"No outbound history yet",hint:C?"Configure the bot API to see posted and rejected promos.":"Approved, rejected, and failed promos will show here."}):(0,s.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4 items-start",children:m.map(e=>(0,s.jsx)(b,{post:e,onDeleted:_},e.id))})]},"history")]})]})})}function v(e){let{label:t}=e;return(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 gap-3",children:[(0,s.jsx)("div",{className:"animate-spin rounded-full h-9 w-9 border-t-2 border-b-2 border-[#26AE7F]"}),(0,s.jsx)("span",{className:"text-white/40 text-sm",children:t})]})}function y(e){let{title:t,hint:r}=e;return(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 gap-2 text-center rounded-xl border border-dashed border-white/[0.08] bg-white/[0.01]",children:[(0,s.jsx)("svg",{className:"w-8 h-8 text-white/20",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.86 9.86 0 01-4.25
15-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),(0,s.jsx)("p",{className:"text-white/60 text-sm font-medium",children:t}),(0,s.jsx)("p",{className:"text-white/30 text-xs max-w-xs",children:r})]})}function k(e){let{text:t,onRetry:r}=e;return(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center py-14 gap-3 text-center rounded-xl border border-red-500/15 bg-red-500/[0.04]",children:[(0,s.jsx)("p",{className:"text-red-300/90 text-sm max-w-sm",children:t}),(0,s.jsx)("button",{onClick:r,className:"px-4 py-1.5 rounded-lg bg-white/[0.05] hover:bg-white/[0.1] border border-white/[0.1] text-white/70 text-xs transition-all",children:"Try again"})]})}}}]);

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.