1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5322],{5322:(e,t,a)=>{a.r(t),a.d(t,{SocialPreviewModal:()=>b});var s=a(95155),l=a(12115),i=a(65229),r=a(35299),n=a(6132),o=a(89559),d=a(42529),c=a(75426),x=a(91169),f=a(93499),m=a(16485),h=a(18720),p=a(89419),u=a(88590);function b(e){var t,a;let{platform:b,platformKey:j,brandColor:y,endpoint:k,postId:N,onClose:v,onPublished:w,onScheduled:S,extraBody:A,shareUrl:C,shareHashtags:T,shareDisclaimer:P,facebookGroups:z,publishTargetLabel:E,facebookPages:D}=e,[F,O]=(0,l.useState)(!0),[Y,M]=(0,l.useState)(""),[R,I]=(0,l.useState)(""),[_,G]=(0,l.useState)(null),[J,B]=(0,l.useState)(!1),[L,H]=(0,l.useState)(null),[K,U]=(0,l.useState)(!1),[W,$]=(0,l.useState)(!1),[q,Q]=(0,l.useState)(()=>g()),[V,X]=(0,l.useState)(!1),[Z,ee]=(0,l.useState)(null),[et,ea]=(0,l.useState)(!1),[es,el]=(0,l.useState)(()=>{var e,t,a,s;return null!=(s=null!=(a=null==A?void 0:A.socialAccountId)?a:null==D||null==(e=D.find(e=>e.isDefault))?void 0:e.id)?s:null==D||null==(t=D[0])?void 0:t.id}),ei=!!D&&D.length>0,er=ei&&es?{...A,socialAccountId:es}:A,en=ei&&null!=(a=null==(t=D.find(e=>e.id===es))?void 0:t.name)?a:E,[eo,ed]=(0,l.useState)(""),ec="facebook"===j,[ex,ef]=(0,l.useState)(!1),[em,eh]=(0,l.useState)(!1),[ep,eu]=(0,l.useState)("thumbnail"),eb=[Y.trim(),(eo||T||"").trim(),(C||"").trim(),(P||"").trim()].filter(Boolean).join("\n\n");async function eg(){G(null);try{let e=await fetch(k,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({postId:N,dryRun:!0,...A})}),t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error||"Preview failed");M(t.text||""),I(t.finalText||t.text||""),"string"==typeof t.hashtags&&t.hashtags.trim()&&ed(t.hashtags.trim()),"boolean"==typeof t.affiliateAvailable&&ef(t.affiliateAvailable),"boolean"==typeof t.videoAvailable&&(eh(t.videoAvailable),t.videoAvailable||eu("thumbnail"))}catch(e){G(e instanceof Error?e.message:"Preview failed")}}async function ej(){U(!0),await eg(),U(!1)}async function ey(){if(Y.trim()){B(!0),H(null);try{let e=await fetch(k,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({postId:N,text:Y,...er,...ec?{media:ep}:{}})}),t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error||"Publish failed");"string"==typeof t.mediaNote&&t.mediaNote&&h.oR.warning(t.mediaNote,{duration:9e3}),w(),v()}catch(e){H(e instanceof Error?e.message:"Publish failed")}finally{B(!1)}}}async function ek(){if(j&&Y.trim()){X(!0),ee(null);try{let e=new Date(q);if(isNaN(e.getTime()))throw Error("Invalid date / time");let t=await fetch("/api/blog/schedule-post",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({postId:N,platform:j,scheduledAt:e.toISOString(),text:Y,...er,...ec?{media:ep}:{}})}),a=await t.json().catch(()=>({}));if(!t.ok)throw Error(a.error||"Schedule failed");null==S||S(e),v()}catch(e){ee(e instanceof Error?e.message:"Schedule failed")}finally{X(!1)}}}(0,l.useEffect)(()=>{let e=!0;return O(!0),eg().finally(()=>{e&&O(!1)}),()=>{e=!1}},[N,k]);let eN=(0,l.useRef)(null),ev=(0,p.f)(!0,eN,v);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:v,onKeyDown:ev,role:"presentation",children:(0,s.jsx)("div",{ref:eN,onClick:e=>e.stopPropagation(),className:"bg-white dark:bg-[#1c1c1e] rounded-2xl shadow-2xl max-w-xl w-full max-h-[90vh] overflow-y-auto outline-none",role:"dialog","aria-modal":"true","aria-label":"Social preview",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)("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center text-white text-xs font-bold",style:{background:y},children:b.charAt(0)}),(0,s.jsxs)("h3",{className:"text-sm font-semibold text-[#1d1d1f] dark:text-[#f5f5f7]",children:["Preview ",b," post"]})]}),(0,s.jsx)("button",{onClick:v,className:"text-[#86868b] hover:text-[#1d1d1f] dark:hover:text-[#f5f5f7]",children:(0,s.jsx)(i.A,{size:16})})]}),F?(0,s.jsxs)("div",{className:"flex flex-col items-center gap-2 py-10 text-xs text-[#6e6e73]",children:[(0,s.jsx)(r.A,{size:18,className:"animate-spin text-[#7C3AED]"}),(0,s.jsx)("span",{children:"Generating previewâ¦"})]}):_?(0,s.jsxs)("div",{className:"flex flex-col gap-3 py-6 text-center",children:[(0,s.jsxs)("p",{className:"text-xs text-[#ff3b30] flex items-center gap-1.5 justify-center",children:[(0,s.jsx)(n.A,{size:12})," ",_]}),(0,s.jsx)("button",{onClick:ej,className:"text-xs text-[#7C3AED] hover:underline",children:"Retry"})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"mb-3",children:[(0,s.jsxs)("label",{className:"text-[11px] font-medium text-[#6e6e73] dar
1k:text-[#ebebf0] mb-1 flex items-center justify-between",children:[(0,s.jsxs)("span",{children:["Post text ",(0,s.jsxs)("span",{className:"text-[#86868b]",children:["(",Y.length," chars)"]})]}),(0,s.jsxs)("button",{onClick:ej,disabled:K,className:"text-[10px] text-[#7C3AED] hover:underline inline-flex items-center gap-1 disabled:opacity-60",children:[K?(0,s.jsx)(r.A,{size:10,className:"animate-spin"}):(0,s.jsx)(o.A,{size:10})," Regenerate"]})]}),(0,s.jsx)("textarea",{value:Y,onChange:e=>M(e.target.value),rows:9,className:"w-full text-xs text-[#1d1d1f] dark:text-[#f5f5f7] p-3 rounded-lg bg-white dark:bg-[#1c1c1e] border border-gray-200 dark:border-white/10 focus:border-[#7C3AED] focus:outline-none leading-relaxed font-mono resize-none",placeholder:"Post body â edit freely"})]}),R&&R!==Y&&(0,s.jsxs)("details",{className:"mb-3 text-[11px] text-[#6e6e73] dark:text-[#ebebf0]",children:[(0,s.jsx)("summary",{className:"cursor-pointer hover:text-[#1d1d1f] dark:hover:text-[#f5f5f7]",children:"Preview what gets posted (with URL + disclaimer appended)"}),(0,s.jsx)("pre",{className:"mt-2 p-3 rounded-lg bg-gray-50 dark:bg-white/5 border border-gray-200 dark:border-white/10 whitespace-pre-wrap font-mono leading-relaxed",children:R})]}),ec&&ex&&(0,s.jsxs)("p",{className:"mb-3 text-[11px] text-[#86868b] dark:text-[#8e8e93]",children:["The link destination (blog, affiliate, or both) is set in ",(0,s.jsx)("strong",{className:"font-semibold",children:"Link settings"})," at the top of the page."]}),ec&&(0,s.jsxs)("div",{className:"mb-4 rounded-xl border border-gray-200 dark:border-white/10 p-3",children:[(0,s.jsx)("p",{className:"text-[11px] font-semibold text-[#1d1d1f] dark:text-[#f5f5f7] mb-2",children:"What Facebook shows"}),(0,s.jsxs)("label",{className:"flex items-start gap-2 text-xs cursor-pointer mb-2",children:[(0,s.jsx)("input",{type:"radio",name:"fb-media",checked:"thumbnail"===ep,onChange:()=>eu("thumbnail"),className:"mt-0.5"}),(0,s.jsxs)("span",{children:[(0,s.jsx)("span",{className:"font-medium text-[#1d1d1f] dark:text-[#f5f5f7]",children:"The thumbnail as a hero image"}),(0,s.jsx)("span",{className:"block text-[10px] text-[#86868b] dark:text-[#8e8e93] leading-relaxed",children:"A still photo post. Tapping it opens the photo on Facebook."})]})]}),(0,s.jsxs)("label",{className:"flex items-start gap-2 text-xs ".concat(em?"cursor-pointer":"cursor-not-allowed opacity-60"),children:[(0,s.jsx)("input",{type:"radio",name:"fb-media",disabled:!em,checked:"video"===ep,onChange:()=>eu("video"),className:"mt-0.5"}),(0,s.jsxs)("span",{children:[(0,s.jsx)("span",{className:"font-medium text-[#1d1d1f] dark:text-[#f5f5f7]",children:"The YouTube video, playable"}),(0,s.jsx)("span",{className:"block text-[10px] text-[#86868b] dark:text-[#8e8e93] leading-relaxed",children:em?"Facebook builds a video card from your YouTube link: it plays in the feed on desktop and opens YouTube on mobile. Your blog link stays in the text above, but a tap on the card goes to YouTube.":"This post has no YouTube video behind it, so there is nothing to play."})]})]})]}),C&&(0,s.jsxs)("div",{className:"mb-4 rounded-xl border border-gray-200 dark:border-white/10 p-3 bg-[#f5f5f7] dark:bg-white/5",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,s.jsx)("span",{className:"text-[11px] font-semibold text-[#1d1d1f] dark:text-[#f5f5f7]",children:"Post to a Facebook Group"}),(0,s.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(eb).then(()=>{ea(!0),setTimeout(()=>ea(!1),1500)})},className:"inline-flex items-center gap-1 text-[11px] font-semibold text-[#7C3AED] hover:underline",children:et?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(d.A,{size:11})," Copied!"]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(c.A,{size:11})," Copy"]})})]}),(0,s.jsx)("pre",{className:"text-[11px] text-[#1d1d1f] dark:text-[#f5f5f7] whitespace-pre-wrap font-mono leading-relaxed max-h-32 overflow-y-auto p-2 rounded-lg bg-white dark:bg-[#1c1c1e] border border-gray-200 dark:border-white/10",children:eb}
1),(0,s.jsx)("p",{className:"text-[10px] text-[#86868b] dark:text-[#8e8e93] mt-1.5 leading-relaxed",children:"Facebook blocks apps from posting to Groups â copy this and paste it into a new post in the Group below."}),z&&z.length>0?(0,s.jsx)("div",{className:"mt-2 flex flex-col gap-1",children:z.filter(e=>{var t;return null==(t=e.url)?void 0:t.trim()}).map((e,t)=>{var a;return(0,s.jsxs)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 text-[11px] text-[#1877f2] hover:underline",children:[(0,s.jsx)(x.A,{size:11})," ",(null==(a=e.name)?void 0:a.trim())||e.url," ",(0,s.jsx)(f.A,{size:9})]},t)})}):(0,s.jsxs)("p",{className:"text-[10px] text-[#86868b] dark:text-[#8e8e93] mt-2",children:["No groups saved yet â add them in ",(0,s.jsx)("a",{href:"/brand",className:"text-[#7C3AED] hover:underline",children:"Brand Profile"})," to list them here."]})]}),j&&(0,s.jsxs)("div",{className:"mb-4",children:[(0,s.jsxs)("label",{className:"flex items-center gap-2 text-xs cursor-pointer mb-2",children:[(0,s.jsx)("input",{type:"checkbox",checked:W,onChange:e=>$(e.target.checked),className:"rounded border-gray-300"}),(0,s.jsxs)("span",{className:"font-medium text-[#1d1d1f] dark:text-[#f5f5f7] flex items-center gap-1.5",children:[(0,s.jsx)(m.A,{size:11,className:"text-[#86868b]"}),"Schedule for later"]})]}),W&&(0,s.jsxs)("div",{className:"pl-6",children:[(0,s.jsx)("input",{type:"datetime-local",value:q,onChange:e=>Q(e.target.value),min:g(),className:"w-full text-xs px-3 py-2 rounded-lg bg-white dark:bg-[#1c1c1e] border border-gray-200 dark:border-white/10 focus:border-[#7C3AED] focus:outline-none"}),(0,s.jsxs)("p",{className:"text-[10px] text-[#86868b] dark:text-[#8e8e93] mt-1.5 leading-relaxed",children:["Times are in your local timezone (",(0,u.$)(),"). The post fires automatically, you don't need to keep the app open."]})]})]}),ei?(0,s.jsxs)("div",{className:"mb-2 flex items-center gap-2 rounded-lg bg-[#1877f2]/8 border border-[#1877f2]/20 px-3 py-2",children:[(0,s.jsx)(d.A,{size:12,className:"text-[#1877f2] flex-shrink-0"}),(0,s.jsx)("span",{className:"text-[11px] text-[#1d1d1f] dark:text-[#f5f5f7] flex-shrink-0",children:"Publish to Page:"}),(0,s.jsx)("select",{value:null!=es?es:"",onChange:e=>el(e.target.value),className:"flex-1 min-w-0 text-[11px] font-semibold rounded-md border border-[#1877f2]/30 bg-white dark:bg-[#1c1c1e] text-[#1d1d1f] dark:text-[#f5f5f7] px-2 py-1",children:D.map(e=>(0,s.jsxs)("option",{value:e.id,children:[e.name,e.isDefault?" (default)":""]},e.id))})]}):E&&!W?(0,s.jsxs)("div",{className:"mb-2 flex items-center gap-1.5 rounded-lg bg-[#1877f2]/8 border border-[#1877f2]/20 px-3 py-2",children:[(0,s.jsx)(d.A,{size:12,className:"text-[#1877f2] flex-shrink-0"}),(0,s.jsxs)("span",{className:"text-[11px] text-[#1d1d1f] dark:text-[#f5f5f7]",children:["Publish posts to your Page: ",(0,s.jsx)("span",{className:"font-semibold",children:E})]})]}):null,(0,s.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,s.jsx)("button",{onClick:v,disabled:J||V,className:"text-xs text-[#86868b] dark:text-[#8e8e93] hover:text-[#1d1d1f] px-3 py-2 disabled:opacity-60",children:"Cancel"}),W&&j?(0,s.jsx)("button",{onClick:ek,disabled:V||!Y.trim(),className:"inline-flex items-center gap-2 px-4 py-2 rounded-lg text-xs font-semibold text-white disabled:opacity-50 transition-opacity hover:opacity-90",style:{background:y},children:V?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(r.A,{size:12,className:"animate-spin"})," Schedulingâ¦"]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(m.A,{size:12})," Schedule for ",b]})}):(0,s.jsx)("button",{onClick:ey,disabled:J||!Y.trim(),className:"inline-flex items-center gap-2 px-4 py-2 rounded-lg text-xs font-semibold text-white disabled:opacity-50 transition-opacity hover:opacity-90",style:{background:y},children:J?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(r.A,{size:12,className:"animate-spin"})," Publishingâ¦"]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(d.A,{size:12})," Publish to ",en||b]})})]}),L&&(0,s.jsx)("p",{className:"text-[11px] text-[#ff3b30] mt-3 break-all",children:L}),Z&&(0,s.jsx)("p",{className:"text-[11px] text-[#ff3b30] mt-3 break-all",children:Z})]})]})})})}function g(){let e=new Date(Date.now()+36e5),t=e.getMinutes();e.setMinutes(5*Math.ceil(t/5),0,0);let a=e=>String(e).padStart(2,"0");return"".concat(e.getFullYear(),"-").concat(a(e.getMonth()+1),"-").concat(a(e.getDate()),"T").concat(a(e.getHours()),":").concat(a(e.getMinutes()))}}}]);
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.