1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8490],{8490:(e,t,a)=>{a.r(t),a.d(t,{BulkScheduleModal:()=>x});var s=a(95155),r=a(12115),n=a(16485),l=a(65229),i=a(6132),o=a(35299),d=a(42529),c=a(89419);function x(e){var t,a;let{posts:x,platforms:f,fbAccounts:m=[],onClose:g,onScheduled:p}=e,b=(0,r.useMemo)(()=>new Set(f.filter(e=>e.connected).map(e=>e.key)),[f]),[j,k]=(0,r.useState)(b),[v,y]=(0,r.useState)(()=>u()),[w,N]=(0,r.useState)(30),[S,C]=(0,r.useState)(()=>{var e,t,a,s;let r=null;try{r=localStorage.getItem("mvp_fb_account_choice")}catch(e){}return r&&m.some(e=>e.id===r)?r:null!=(s=null!=(a=null==(e=m.find(e=>e.isDefault))?void 0:e.id)?a:null==(t=m[0])?void 0:t.id)?s:""}),[D,A]=(0,r.useState)(!1),[E,T]=(0,r.useState)(null),[z,P]=(0,r.useState)(null),F=x.length*j.size,[M,I]=(0,r.useState)(!1);async function _(){if(!F)return;if(F>=25&&!M)return void I(!0);A(!0),P(null),T({done:0,total:F});let e=0,t=0,a=null,s=0,r=new Date(v).getTime();if(isNaN(r)){P("Invalid start time"),A(!1),T(null);return}for(let l=0;l<x.length;l++)for(let i of j){let o=f.find(e=>e.key===i),d=new Date(r+s*w*6e4).toISOString(),c=x[l].postId;try{var n;let t=await fetch(o.dryRunEndpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({postId:c,dryRun:!0})}),a=await t.json().catch(()=>({}));if(!t.ok)throw Error(a.error||"Dry-run HTTP ".concat(t.status));let s=null!=(n=a.text)?n:"";if(!s)throw Error("Empty AI text");let r=await fetch("/api/blog/schedule-post",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({postId:c,platform:i,scheduledAt:d,text:s,socialAccountId:"facebook"===i&&S?S:void 0})}),l=await r.json().catch(()=>({}));if(!r.ok)throw Error(l.error||"Schedule HTTP ".concat(r.status));e++}catch(e){t++,a||(a=e instanceof Error?e.message:String(e))}finally{T({done:++s,total:F})}}A(!1),p({ok:e,failed:t,firstError:a}),g()}let O=(0,r.useRef)(null),H=(0,c.f)(!0,O,g);return(0,s.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm p-4",onClick:g,onKeyDown:H,role:"presentation",children:(0,s.jsx)("div",{ref:O,onClick:e=>e.stopPropagation(),className:"bg-white dark:bg-[#1c1c1e] rounded-2xl shadow-2xl max-w-lg w-full max-h-[90vh] overflow-y-auto outline-none",role:"dialog","aria-modal":"true","aria-label":"Bulk schedule",tabIndex:-1,children:(0,s.jsxs)("div",{className:"p-6",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(n.A,{size:16,className:"text-[#7C3AED]"}),(0,s.jsxs)("h3",{className:"text-sm font-semibold text-[#1d1d1f] dark:text-[#f5f5f7]",children:["Schedule ",x.length," post",1!==x.length?"s":""]})]}),(0,s.jsx)("button",{onClick:g,disabled:D,className:"text-[#86868b] hover:text-[#1d1d1f] dark:hover:text-[#f5f5f7] disabled:opacity-60",children:(0,s.jsx)(l.A,{size:16})})]}),(0,s.jsxs)("div",{className:"mb-5",children:[(0,s.jsx)("p",{className:"text-xs font-semibold text-[#1d1d1f] dark:text-[#f5f5f7] mb-2",children:"1. Publish to"}),(0,s.jsx)("div",{className:"grid grid-cols-2 gap-2",children:f.map(e=>{let t=j.has(e.key);return(0,s.jsxs)("label",{className:"flex items-center gap-2 px-3 py-2 rounded-lg border cursor-pointer transition-colors ".concat(e.connected?t?"border-[#7C3AED] bg-[#7C3AED]/5":"border-gray-200 dark:border-white/10 hover:border-gray-300":"opacity-40 cursor-not-allowed border-gray-200 dark:border-white/10"),children:[(0,s.jsx)("input",{type:"checkbox",checked:t,disabled:!e.connected||D,onChange:()=>{var t;return t=e.key,void(I(!1),k(e=>{let a=new Set(e);return a.has(t)?a.delete(t):a.add(t),a}))},className:"w-3 h-3 rounded cursor-pointer accent-[#7C3AED]"}),(0,s.jsx)("span",{className:"w-5 h-5 rounded-md flex items-center justify-center text-white text-[10px] font-bold flex-shrink-0",style:{background:e.color},children:e.label.charAt(0)}),(0,s.jsx)("span",{className:"text-xs text-[#1d1d1f] dark:text-[#f5f5f7] truncate",children:e.label}),!e.connected&&(0,s.jsx)("span",{className:"text-[9px] text-[#86868b]",children:"(not connected)"})]},e.key)})})]}),j.has("facebook")&&m.length>1&&(0,s.jsxs)("div",{className:"mb-5",children:[(0,s.jsx)("p",{className:"text-xs font-semibold text-[#1d1d1f] dark:text-[#f5f5f7] mb-1.5",children:"Facebook Page"}),(0,s.jsx)("select",{value:S,onChange:e=>C(e.target.value),disabled:D,className:"w-full text-xs px-2 py-1.5 rounded-lg bg-white dark:bg-[#1c1c1e] border border-gray-200 dark:border-white/10 focus:border-[#7C3AED] focus:outline-none",children:m.map(e=>(0,s.jsx)("option",{value:e.id,children:e.displayName||"Facebook Page"},e.id))})]}),(0,s.jsxs)("div",{className:"mb-5 grid grid-cols-2 gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-xs font-semibold text-[#1d1d1f] dark:text-[#f5f5f7] mb-1.5",children:"2. First post at"}
1),(0,s.jsx)("input",{type:"datetime-local",value:v,onChange:e=>y(e.target.value),min:u(),disabled:D,className:"w-full text-xs px-2 py-1.5 rounded-lg bg-white dark:bg-[#1c1c1e] border border-gray-200 dark:border-white/10 focus:border-[#7C3AED] focus:outline-none"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-xs font-semibold text-[#1d1d1f] dark:text-[#f5f5f7] mb-1.5",children:"3. Stagger interval"}),(0,s.jsxs)("select",{value:w,onChange:e=>N(Number(e.target.value)),disabled:D,className:"w-full text-xs px-2 py-1.5 rounded-lg bg-white dark:bg-[#1c1c1e] border border-gray-200 dark:border-white/10 focus:border-[#7C3AED] focus:outline-none",children:[(0,s.jsx)("option",{value:5,children:"5 minutes apart"}),(0,s.jsx)("option",{value:15,children:"15 minutes apart"}),(0,s.jsx)("option",{value:30,children:"30 minutes apart"}),(0,s.jsx)("option",{value:60,children:"1 hour apart"}),(0,s.jsx)("option",{value:180,children:"3 hours apart"}),(0,s.jsx)("option",{value:360,children:"6 hours apart"}),(0,s.jsx)("option",{value:720,children:"12 hours apart"}),(0,s.jsx)("option",{value:1440,children:"1 day apart"})]})]})]}),(0,s.jsxs)("div",{className:"mb-5 rounded-lg bg-gray-50 dark:bg-white/5 border border-gray-200 dark:border-white/10 p-3",children:[(0,s.jsx)("p",{className:"text-xs font-semibold text-[#1d1d1f] dark:text-[#f5f5f7] mb-1",children:"Preview"}),(0,s.jsx)("p",{className:"text-[11px] text-[#6e6e73] dark:text-[#ebebf0] leading-relaxed",children:0===F?"Pick at least one platform.":(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("strong",{children:F})," post",1!==F?"s":""," ","(",x.length," \xd7 ",j.size," platform",1!==j.size?"s":"",")."," ","First fires ",h(v),", last fires ",h(function(e,t){let a=new Date(new Date(e).getTime()+6e4*t),s=e=>String(e).padStart(2,"0");return"".concat(a.getFullYear(),"-").concat(s(a.getMonth()+1),"-").concat(s(a.getDate()),"T").concat(s(a.getHours()),":").concat(s(a.getMinutes()))}(v,(F-1)*w)),". AI text is generated for each now and locked in."]})})]}),z&&(0,s.jsxs)("p",{className:"text-xs text-[#ff3b30] mb-3 flex items-center gap-1.5",children:[(0,s.jsx)(i.A,{size:11})," ",z]}),M&&!D&&(0,s.jsxs)("p",{className:"text-xs text-[#ff9500] mb-3 flex items-start gap-1.5",children:[(0,s.jsx)(i.A,{size:12,className:"flex-shrink-0 mt-0.5"}),(0,s.jsxs)("span",{children:["That's ",(0,s.jsxs)("strong",{children:[F," pushes"]})," (",x.length," post",1!==x.length?"s":""," \xd7 ",j.size," platform",1!==j.size?"s":"","). Large batch â every Pinterest pin builds an image. Click again to confirm."]})]}),(0,s.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,s.jsx)("button",{onClick:g,disabled:D,className:"text-xs text-[#86868b] dark:text-[#8e8e93] hover:text-[#1d1d1f] px-3 py-2 disabled:opacity-60",children:"Cancel"}),(0,s.jsx)("button",{onClick:_,disabled:D||0===F,className:"inline-flex items-center gap-2 px-4 py-2 rounded-lg text-xs font-semibold text-white bg-[#7C3AED] hover:bg-[#6D28D9] disabled:opacity-50 transition-colors",children:D?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.A,{size:12,className:"animate-spin"})," Scheduling ",null!=(t=null==E?void 0:E.done)?t:0,"/",null!=(a=null==E?void 0:E.total)?a:0,"â¦"]}):M?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.A,{size:12})," Confirm ",F," pushes"]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(d.A,{size:12})," Schedule ",F]})})]})]})})})}function u(){let e=new Date(Date.now()+36e5);e.setMinutes(5*Math.ceil(e.getMinutes()/5),0,0);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 h(e){let t=new Date(e);return isNaN(t.getTime())?"â":t.toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}}}]);
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.