1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[572],{269:function(e,t,s){(window.__NEXT_P=window.__NEXT_P||[]).push(["/scenario/[scenarioId]/timeline/[eventId]",function(){return s(5845)}])},543:function(e,t,s){"use strict";var n=s(5893),a=s(4080),r=s(8813),l=s(7294);t.Z=e=>{let{isOpen:t,close:s,onConfirm:o,title:i,description:c,isDeleting:d}=e;return(0,n.jsx)(a.u.Root,{show:t,as:l.Fragment,children:(0,n.jsx)(r.V,{as:"div",className:"fixed z-20 inset-0 overflow-y-auto",onClose:s,children:(0,n.jsxs)("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,n.jsx)(a.u.Child,{as:l.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-200",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,n.jsx)(r.V.Overlay,{className:"fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity"})}),(0,n.jsx)("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"â"}),(0,n.jsx)(a.u.Child,{as:l.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",enterTo:"opacity-100 translate-y-0 sm:scale-100",leave:"ease-in duration-200",leaveFrom:"opacity-100 translate-y-0 sm:scale-100",leaveTo:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",children:(0,n.jsxs)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:[(0,n.jsx)("div",{className:"bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:(0,n.jsx)("div",{className:"sm:flex sm:items-start",children:(0,n.jsxs)("div",{className:"mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left",children:[(0,n.jsx)(r.V.Title,{as:"h3",className:"text-lg leading-6 font-medium text-gray-900",children:i}),(0,n.jsx)("div",{className:"mt-2",children:(0,n.jsx)("p",{className:"text-sm text-gray-500",children:c})})]})})}),(0,n.jsxs)("div",{className:"bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse",children:[(0,n.jsx)("button",{type:"button",className:"w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-red-600 text-base font-medium text-white hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500 sm:ml-3 sm:w-auto sm:text-sm",onClick:o,disabled:d,children:d?"Deleting...":"Confirm"}),(0,n.jsx)("button",{type:"button",className:"mt-3 w-full inline-flex justify-center rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-base font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 sm:mt-0 sm:ml-3 sm:w-auto sm:text-sm",onClick:s,children:"Cancel"})]})]})})]})})})}},223:function(e,t,s){"use strict";var n=s(5893),a=s(1664),r=s.n(a),l=s(1163);t.Z=()=>{let e=(0,l.useRouter)(),{scenarioId:t}=e.query;return(0,n.jsx)("nav",{className:"bg-white p-4",children:(0,n.jsxs)("ul",{className:"flex space-x-4",children:[(0,n.jsx)("li",{children:(0,n.jsx)(r(),{href:"/scenario",children:(0,n.jsx)("div",{className:"/scenario"===e.pathname?"text-blue-500":"text-gray-600",children:"Editor Home"})})}),(0,n.jsx)("li",{children:(0,n.jsx)(r(),{href:"/scenario/".concat(t),children:(0,n.jsx)("div",{className:e.pathname==="/scenario/".concat(t)?"text-blue-500":"text-gray-600",children:"Scenario"})})}),(0,n.jsx)("li",{children:(0,n.jsx)(r(),{href:"/scenario/".concat(t,"/timeline"),children:(0,n.jsx)("div",{className:e.pathname==="/scenario/".concat(t,"/timeline")?"text-blue-500":"text-gray-600",children:"Timeline"})})})]})})}},8338:function(e,t,s){"use strict";var n=s(5893),a=s(4185),r=s(5675),l=s.n(r);t.Z=function(e){let{user:t,content:s,timestamp:r,currentReplies:o,currentTweets:i,currentLikes:c}=e;return(0,n.jsxs)("div",{className:"flex p-4 border-b border-gray-200",children:[(0,n.jsx)(l(),{src:t.profileImage,alt:t.name,className:"w-12 h-12 rounded-full mr-4",width:300,height:300}),(0,n.jsxs)("div",{className:"flex flex-col w-full",children:[(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"flex items-center mb-2",children:[(0,n.jsx)("strong",{className:"text-l mr-1",children:t.name}),(0,n.jsx)("span",{className:"text-gray-500 mr-1",children:"\xb7"}),(0,n.jsxs)("span",{className:"text-gray-500 mr-1",children:["@",t.username]}),(0,n.jsx)("span",{className:"text-gray-500 mr-1",children:"\xb7"}),(0,n.jsx)("span",{className:"text- text-gray-400 ",children:r})]}),(0,n.jsx)("div",{className:"items-left text-left",children:(0,n.jsx)("p",{className:"text-sm mb-2",children:s})})]}),(0,n.jsx)(a.Z,{currentReplies:o,currentTweets:i,currentLikes:c})]})]})}},4185:function(e,t,s){"use strict";s.d(t,{Z:function(){return TweetStats}});var n=s(5893),a=s(512),r=s(2647);function TweetOption(e){let{stats:t,disabled:s,iconName:l,className:o,viewTweet:i,iconClassName:c}=e;return(0,n.jsxs)("button",{className:(0,a.Z)("group flex items-center gap-1.5 p-0 transition-none\n disabled:cursor-not-allowed inner:transition inner:duration-200",s&&"cursor-not-allowed",o),children:[(0,n.jsx)("i",{className:(0,a.Z)("relative rounded-full p-2 not-italic group-focus-visible:ring-2",c),children:(0,n.jsx)(r.e,{className:i?"h-6 w-6":"h-5 w-5",iconName:l})}),t&&(0,n.jsx)("span",{className:"text-xs text-gray-400 group-hover:text-gray-500",children:t})]})}function TweetStats(e){let{currentReplies:t,currentTweets:s,currentLikes:a}=e;return(0,n.jsxs)("div",{className:"flex max-w-md justify-between",children:[(0,n.jsx)(TweetOption,{className:"hover:text-accent-blue focus-visible:text-accent-blue",iconClassName:"group-hover:bg-accent-blue/10 group-active:bg-accent-blue/20 group-focus-visible:bg-accent-blue/10 group-focus-visible:ring-accent-blue/80",tip:"Reply",stats:t,iconName:"ChatBubbleOvalLeftIcon"}),(0,n.jsx)(TweetOption,{className:"hover:text-accent-green focus-visible:text-accent-green",iconClassName:"group-hover:bg-accent-green/10 group-active:bg-accent-green/20 group-focus-visible:bg-accent-green/10 group-focus-visible:ring-accent-green/80",stats:s,iconName:"ArrowPathRoundedSquareIcon"}),(0,n.jsx)(TweetOption,{className:"hover:text-accent-pink focus-visible:text-accent-pink",iconClassName:"group-hover:bg-accent-pink/10 group-active:bg-accent-pink/20 group-focus-visible:bg-accent-pink/10 group-focus-visible:ring-accent-pink/80",stats:a,iconName:"HeartIcon"}),(0,n.jsx)(TweetOption,{className:"group relative flex items-center gap-1 p-0 outline-none transition-none hover:text-accent-blue focus-visible:text-accent-blue",iconClassName:"relative rounded-full p-2 not-italic duration-200 group-hover:bg-accent-blue/10 group-focus-visible:bg-accent-blue/10 group-focus-visible:ring-2 group-focus-visible:ring-accent-blue/80 group-active:bg-accent-blue/20",iconName:"ArrowUpTrayIcon"})]})}},2647:function(e,t,s){"use strict";s.d(t,{e:function(){return HeroIcon}});var n=s(5893),a=s(7459),r=s(1394);function HeroIcon(e){let{solid:t,iconName:s,className:l}=e,o=t?a[s]:r[s];return(0,n.jsx)(o,{className:null!=l?l:"h-6 w-6"})}},5845:function(e,t,s){"use strict";s.r(t),s.d(t,{default:function(){return _eventId_}});var n=s(5893),a=s(223),r=s(7294),l=s(4080),o=s(8813),i=s(1444),AddContent=e=>{let{setIsOpen:t,onContentSave:s}=e,[a,l]=(0,r.useState)([]),[o,c]=(0,r.useState)(new Set),[d,m]=(0,r.useState)({contentName:"",contentDescription:"",contentPlatform:"",content:""}),generateTweets=async()=>{try{let e=await fetch("/api/gpt/createContent",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify("a bomb has gone off")});if(!e.ok)throw Error("Error fetching event");let t=await e.json(),s=JSON.parse(t);if(Array.isArray(s)&&s.length>0){let e=s.map(e=>({username:e.username,tweet:e.tweet,misinformation:e.misinformation||!1}));await l(t=>[...t,...e])}else console.error("Invalid structure received from API:",t),i.Am.error("Failed to generate posts try again.")}catch(e){console.error("Failed to fetch event:",e),i.Am.error("Failed to generate posts try again.")}},toggleTweetSelection=e=>{c(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})};return(0,r.useEffect)(()=>{console.log("Selected Tweets:",Array.from(o))}
1,[o]),(0,n.jsxs)("div",{className:"bg-custom-bg p-4",children:[(0,n.jsxs)("div",{className:"mb-8",children:[(0,n.jsx)("h2",{className:"text-xl font-semibold mb-4",children:"Event Details:"}),(0,n.jsxs)("form",{children:[(0,n.jsxs)("div",{className:"mb-4",children:[(0,n.jsx)("label",{htmlFor:"contentTitle",className:"text-lg font-semibold",children:"Content Title:"}),(0,n.jsx)("input",{type:"text",id:"eventTitle",className:"block w-full p-2 border rounded",value:d.contentName,onChange:e=>{m({...d,contentName:e.target.value})},required:!0})]}),(0,n.jsxs)("div",{className:"mb-4",children:[(0,n.jsx)("label",{htmlFor:"eventPlatform",className:"text-lg font-semibold",children:"Content Platform:"}),(0,n.jsx)("select",{id:"eventPlatform",className:"block w-full p-2 border rounded",value:d.contentPlatform,onChange:e=>m({...d,contentPlatform:e.target.value}),children:(0,n.jsx)("option",{value:"X/Twitter",children:"X/Twitter"})})]}),(0,n.jsxs)("div",{className:"mb-4",children:[(0,n.jsx)("label",{htmlFor:"content",className:"text-lg font-semibold",children:"Content:"}),(0,n.jsx)("textarea",{id:"content",rows:"4",className:"block w-full p-2 border rounded",value:d.content,onChange:e=>m({...d,content:e.target.value})})]})]})]}),(0,n.jsxs)("div",{className:"flex justify-between md:justify-end mb-2 ",children:[(0,n.jsx)("button",{className:"bg-green-500 text-white px-4 py-2 rounded-md",onClick:generateTweets,children:"Generate Tweets"}),(0,n.jsx)("button",{className:"bg-blue-500 text-white px-4 py-2 rounded-md",onClick:()=>{s(d),i.Am.success("Event saved!"),t(!1)},children:"Save Post"})]}),(0,n.jsx)("div",{className:"flex justify-center px-4 py-2",children:a.length>0&&(0,n.jsx)("div",{className:"space-y-4 mt-4 bg-gray-100 p-4 rounded-lg shadow max-w-xl mx-auto",children:a.map((e,t)=>(0,n.jsx)("div",{className:"bg-white p-4 rounded-lg shadow border border-gray-200",children:(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[(0,n.jsxs)("div",{children:[(0,n.jsxs)("p",{className:"text-gray-800 font-semibold",children:[(0,n.jsx)("strong",{children:"Username:"})," ",e.username]}),(0,n.jsxs)("p",{className:"text-gray-700 mt-2",children:[(0,n.jsx)("strong",{children:"Tweet:"})," ",e.tweet]}),(0,n.jsxs)("p",{className:"font-semibold mt-2 ".concat(e.misinformation?"text-red-500":"text-green-500"),children:[(0,n.jsx)("strong",{children:"Misinformation Alert:"})," ",e.misinformation?"True":"False"]})]}),(0,n.jsx)("input",{type:"checkbox",checked:o.has(e),onChange:()=>toggleTweetSelection(e),className:"ml-4"})]})},t))})}),(0,n.jsx)("div",{className:"flex justify-center md:justify-end mb-2 ",children:(0,n.jsx)("div",{className:"flex justify-center md:justify-end mb-2",children:(0,n.jsx)("button",{className:"bg-blue-500 text-white px-4 py-2 rounded-md",onClick:()=>{let e=Array.from(o);try{e.forEach(async e=>{let t=await fetch("/api/tweets",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw Error("Error saving tweet");let s=await t.json();console.log("Saved tweet:",s)}),console.log("Selected Tweets:",e),i.Am.success("Selected tweets saved!")}catch(e){console.error("Failed to save tweet:",e),i.Am.error("Failed to save tweet try again.")}t(!1)},children:"Save Selected Tweets"})})})]})},c=s(1415);function AddContentModal(e){let{title:t,open:s,setIsOpen:a,closeModal:i,onContentSave:d}=e,m=(0,r.useRef)(null);return(0,n.jsx)(l.u.Root,{appear:!0,show:s,as:r.Fragment,children:(0,n.jsxs)(o.V,{as:"div",className:"relative z-10",onClose:i,initialFocus:m,children:[(0,n.jsx)(l.u.Child,{as:r.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-200",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,n.jsx)("div",{className:"fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity"})}),(0,n.jsx)("div",{className:"fixed inset-0 z-10 w-screen overflow-y-auto ",children:(0,n.jsx)("div",{className:"flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0",children:(0,n.jsx)(l.u.Child,{as:r.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",enterTo:"opacity-100 translate-y-0 sm:scale-100",leave:"ease-in duration-200",leaveFrom:"opacity-100 translate-y-0 sm:scale-100",leaveTo:"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",children:(0,n.jsxs)(o.V.Panel,{className:"relative transform min-w-[75%] overflow-hidden rounded-lg bg-custom-bg text-left shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-lg",children:[(0,n.jsx)("button",{className:"absolute top-0 right-0 m-4 hover:text-gray-500",onClick:i,children:(0,n.jsx)(c.Z,{className:"h-6 w-6 ","aria-hidden":"true"})}),(0,n.jsx)("div",{className:"bg-custom-bg px-4 pb-4 pt-5 sm:p-6 sm:pb-4",children:(0,n.jsx)("div",{className:"sm:flex sm:items-start",children:(0,n.jsxs)("div",{className:"mt-3 text-center sm:ml-4 sm:mt-0 sm:text-left w-full",children:[(0,n.jsx)(o.V.Title,{as:"h2",className:" text-2xl font-bold text-center leading-6 text-gray-900",children:t}),(0,n.jsx)(AddContent,{setIsOpen:a,onContentSave:d})]})})}),(0,n.jsx)("div",{className:"bg-gray-50 px-4 py-3 sm:flex sm:flex-row-reverse sm:px-6",children:(0,n.jsx)("button",{type:"button",className:"mt-3 inline-flex w-full justify-center rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50 sm:mt-0 sm:w-auto",onClick:()=>a(!1),ref:m,children:"Cancel"})})]})})})})]})})}var d=s(1163),m=s(8338),u=s(543);function EditEventForm(e){let{event:t,handleInputChange:s}=e;return(0,n.jsxs)("div",{className:"grid grid-cols-1 sm:gap-x-4 sm:grid-cols-2 p-2",children:[(0,n.jsxs)("div",{className:"mb-4 w-full",children:[(0,n.jsx)("label",{className:"font-bold",children:"Event Name:"}),(0,n.jsx)("input",{type:"text",name:"name",className:"p-2 border w-full rounded",value:t.name,onChange:s})]}),(0,n.jsxs)("div",{className:"mb-4 w-full",children:[(0,n.jsx)("label",{className:"font-bold",children:"Event Status:"}),(0,n.jsx)("input",{type:"text",name:"status",className:"p-2 border w-full rounded",value:t.status,onChange:s})]}),(0,n.jsxs)("div",{className:"mb-4 col-span-full w-full",children:[(0,n.jsx)("label",{className:"font-bold",children:"Event Description:"}),(0,n.jsx)("textarea",{name:"description",className:"p-2 border rounded w-full",value:t.description,onChange:s})]}),(0,n.jsxs)("div",{className:"mb-4 w-full",children:[(0,n.jsx)("label",{className:"font-bold",children:"Event Platform:"}),(0,n.jsx)("input",{type:"text",name:"eventPlatform",className:"p-2 w-full border rounded",value:t.eventPlatform,onChange:s})]}),(0,n.jsxs)("div",{className:"mb-4 w-full",children:[(0,n.jsx)("label",{className:"font-bold",children:"Event Type:"}),(0,n.jsx)("input",{type:"text",name:"eventType",className:"p-2 w-full border rounded",value:t.eventType.name,onChange:s})]}),(0,n.jsxs)("div",{className:"mb-4 w-full",children:[(0,n.jsx)("label",{className:"font-bold",children:"Sub Type:"}),(0,n.jsx)("input",{type:"text",name:"eventSubType",className:"p-2 w-full border rounded",value:t.eventSubType.name,onChange:s})]}),(0,n.jsxs)("div",{className:"mb-4 w-full",children:[(0,n.jsx)("label",{className:"font-bold",children:"Event Location:"}),(0,n.jsx)("input",{type:"text",name:"eventLocation",className:"p-2 w-full border rounded",value:t.eventLocation,onChange:s})]}),(0,n.jsxs)("div",{className:"mb-4 w-full",children:[(0,n.jsx)("label",{className:"font-bold",children:"Event Time:"}),(0,n.jsx)("input",{type:"text",name:"eventTime",className:"p-2 w-full border rounded",value:t.eventTime,onChange:s})]}),(0,n.jsxs)("div",{className:"mb-4 w-full",children:[(0,n.jsx)("label",{className:"font-bold",children:"Number of Posts:"}),(0,n.jsx)("input",{type:"number",name:"numberOfPosts",className:"p-2 w-full border rounded",value:t.numberOfPosts,onChange:s})]}),(0,n.jsxs)("div",{className:"mb-4 w-full",children:[(0,n.jsx)("label",{className:"font-bold",children:"Unique Posters:"}),(0,n.jsx)("input",{type:"number",name:"uniquePosters",className:"p-2 w-full border rounded",value:t.uniquePosters,onChange:s})]}),(0,n.jsx)("div",{}),(0,n.jsxs)("div",{children:["Created by: ",null==t?void 0:t.created_by]}),(0,n.jsxs)("div",{children:["Updated by: ",null==t?void 0:t.updated_by]}),(0,n.jsxs)("div",{children:["Created at: ",null==t?void 0:t.created_at]}),(0,n.jsxs)("div",{children:["Updated at: ",null==t?void 0:t.updated_at]})]})}function EventDisplay(e){let{event:t}=e;return(0,n.jsxs)("div",{className:"text-center",children:[(0,n.jsxs)("p",{children:[(0,n.jsx)("strong",{children:"Event Name:"})," ",t.name]}),(0,n.jsxs)("p",{children:[(0,n.jsx)("strong",{children:"Event Description:"})," ",t.description]}),(0,n.jsxs)("p",{children:[(0,n.jsx)("strong",{children:"Event Platform:"})," ",t.eventPlatform]}),(0,n.jsxs)("p",{children:[(0,n.jsx)("strong",{children:"Event Type:"})," ",t.eventType.name]}),(0,n.jsxs)("p",{children:[(0,n.jsx)("strong",{children:"Sub Type:"})," ",t.eventSubType.name]}),(0,n.jsxs)("p",{children:[(0,n.jsx)("strong",{children:"Event Location:"})," ",t.eventLocation]}),(0,n.jsxs)("p",{children:[(0,n.jsx)("strong",{children:"Event Time:"})," ",t.eventTime]}),(0,n.jsxs)("p",{children:[(0,n.jsx)("strong",{children:"Number of Posts:"})," ",t.numberOfPosts]}),(0,n.jsxs)("p",{children:[(0,n.jsx)("strong",{children:"Unique Posters:"})," ",t.uniquePosters]})]})}var x=s(4185),h=s(5675),p=s.n(h),AddContent_EditTweet=function(e){let{user:t,content:s,timestamp:a,currentReplies:l,currentTweets:o,currentLikes:i,onContentChange:c}=e,[d,m]=(0,r.useState)(s);return(0,r.useEffect)(()=>{m(s)},[s]),(0,n.jsxs)("div",{className:"flex p-4 border-b border-gray-200",children:[(0,n.jsx)(p(),{src:t.profileImage,alt:t.name,className:"w-12 h-12 rounded-full mr-4",width:300,height:300}),(0,n.jsxs)("div",{className:"flex flex-col w-full",children:[(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"flex items-center mb-2",children:[(0,n.jsx)("strong",{className:"text-l mr-1",children:t.name}),(0,n.jsx)("span",{className:"text-gray-500 mr-1",children:"\xb7"}),(0,n.jsxs)("span",{className:"text-gray-500 mr-1",children:["@",t.username]}),(0,n.jsx)("span",{className:"text-gray-500 mr-1",children:"\xb7"}),(0,n.jsx)("span",{className:"text- text-gray-400 ",children:a})]}),(0,n.jsx)("div",{className:"items-left text-left",children:(0,n.jsx)("textarea",{className:"w-full text-sm mb-2",value:d,rows:4,onChange:e=>{m(e.target.value),c(e.target.value)}})})]}),(0,n.jsx)(x.Z,{currentReplies:l,currentTweets:o,currentLikes:i})]})]})},_eventId_=()=>{let[e,t]=(0,r.useState)(null),[s,l]=(0,r.useState)(!1),[o,c]=(0,r.useState)(!1),x=(0,d.useRouter)(),[h,p]=(0,r.useState)(!1),[g,f]=(0,r.useState)([]),[v,b]=(0,r.useState)([]),[j,y]=(0,r.useState)(!1),[w,N]=(0,r.useState)(null),[C,T]=(0,r.useState)(""),[E,S]=(0,r.useState)(null),[P,k]=(0,r.useState)(!1),closeConfirmDialog=()=>k(!1),[A,F]=(0,r.useState)(!1),{scenarioId:O,eventId:I}=x.query;(0,r.useEffect)(()=>{I&&(console.log("Fetching event data"),fetchEventData(I),getAllPosts())},[I]);let fetchEventData=async e=>{try{y(!0);let s=await fetch("/api/scenarioEvent/".concat(e,"/getEvent"),{method:"GET",headers:{"Content-Type":"application/json"}});if(!s.ok)throw Error("Error fetching event");let n=await s.json();return t(n),y(!1),n}catch(e){console.error("Failed to fetch event:",e),y(!1)}},saveChanges=async()=>{try{console.log("Updated Event:",e),i.Am.success("Event updated successfully."),p(!1)}catch(e){console.error("Error updating event:",e),i.Am.error("Failed to update event.")}},generatePosts=async e=>{y(!0);try{let t=await fetch("/api/gpt/createContent",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:e})});if(!t.ok)throw y(!1),Error("Error fetching event");let s=await t.json(),n=JSON.parse(s);if(Array.isArray(n)&&n.length>0){let e=n.map(e=>({username:e.username,tweet:e.tweet,misinformation:e.misinformation||!1}));await f(t=>[...t,...e]),y(!1)}else console.error("Invalid structure received from API:",s),i.Am.error("Failed to generate posts try again."),y(!1)}catch(e){y(!1),console.error("Failed to fetch event:",e),i.Am.error("Failed to generate posts try again.")}finally{y(!1)}},addPost=async e=>{console.log("Adding post"),console.log(I),console.log(e);try{let t=await fetch("/api/scenarioEvent/".concat(I,"/addContent"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({contentData:e})});if(!t.ok)throw Error("Error creating event");let s=await t.json();console.log(s),i.Am.success("Post added successfully.")}catch(e){console.error("Failed to fetch event:",e),i.Am.error("Failed to add post.")}},getAllPosts=async()=>{try{let e=await fetch("/api/scenarioEvent/".concat(I,"/getContent"),{method:"GET",headers:{"Content-Type":"application/json"}});if(!e.ok)throw Error("Error fetching event");let t=await e.json();b(t),console.log("loaded posts")}catch(e){console.error("Failed to fetch event:",e),i.Am.error("Failed to retrieve posts.")}},deletePost=async e=>{c(!0);try{let t=await fetch("/api/scenarioEvent/".concat(I,"/").concat(e,"/deleteContent"),{method:"DELETE",headers:{"Content-Type":"application/json"}});if(!t.ok)throw Error("Error fetching event");let s=await t.json();console.log(s),closeConfirmDialog(),l(!1),getAllPosts()}catch(e){console.error("Failed to fetch event:",e),i.Am.error("Failed to delete post.")}c(!1)},handleContentSave=async e=>{console.log("Saving content data"),console.log(e);let t={name:e.contentName,description:e.contentDescription,platformId:1,content:e.content};await addPost(t),getAllPosts()},handleContentUpdate=async e=>{F(!0),console.log("Saving content data"),console.log(e);try{let t=await fetch("/api/scenarioEvent/".concat(I,"/").concat(e,"/updateContent"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:{name:"name",description:"description",content:C}})});if(!t.ok)throw F(!1),Error("Error updating event");let s=await t.json();console.log(s),i.Am.success("Post updated successfully."),getAllPosts(),N(null),T("")}catch(e){F(!1),console.error("Failed to fetch event:",e),i.Am.error("Failed to update post.")}F(!1)};return(0,n.jsxs)("div",{className:"bg-custom-bg p-4 ",children:[(0,n.jsx)("div",{className:"flex justify-center items-center pb-4",children:(0,n.jsx)(a.Z,{scenarioId:O})}),(0,n.jsx)("h1",{className:"text-2xl font-bold mb-4 text-center",children:"Event Details"}),e?(0,n.jsxs)("div",{className:"px-20",children:[h?(0,n.jsx)(EditEventForm,{event:e,handleInputChange:e=>{let{name:s,value:n}=e.target;t(e=>({...e,[s]:n}))}}):(0,n.jsx)(EventDisplay,{event:e}),(0,n.jsxs)("div",{className:"mt-4 text-center",children:[h?(0,n.jsxs)("div",{className:"flex flex-row space-x-2",children:[(0,n.jsx)("button",{className:"bg-blue-500 text-white px-4 py-2 rounded mr-2",onClick:saveChanges,children:"Save Changes"}),(0,n.jsx)("button",{className:"bg-yellow-500 text-white px-4 py-2 rounded mr-2",onClick:()=>{p(!1),i.Am.info("Changes discarded.")},children:"Cancel"})]}):(0,n.jsx)("button",{className:"bg-green-500 hover:bg-green-600 m-2 text-white px-4 py-2 rounded mr-2",onClick:()=>p(!0),children:"Edit"}),(0,n.jsxs)("button",{className:"bg-blue-500 hover:bg-blue-600 text-white m-2 p-2 rounded ",disabled:j,onClick:()=>{y(!0),generatePosts(e.description)},children:[j&&(0,n.jsxs)("div",{className:"flex flex-row space-x-2",children:[(0,n.jsx)("div",{className:"animate-spin rounded-full h-5 w-5 border-b-2 border-white"}),(0,n.jsx)("p",{children:"Generating Posts..."})]}),!j&&(0,n.jsx)("p",{children:"Generate Posts"})]}),(0,n.jsx)("button",{className:"bg-blue-500 hover:bg-blue-600 text-white m-2 p-2 rounded ",onClick:()=>{l(!0)},children:"Manually Create Post"})]})]}):(0,n.jsx)("p",{children:"Loading event data..."}),g.length>0&&(0,n.jsx)("div",{className:"flex justify-center px-4 py-2",children:(0,n.jsx)("div",{className:"space-y-4 mt
1-4 bg-gray-100 p-4 rounded-lg shadow max-w-xl mx-auto",children:g.map((e,t)=>(0,n.jsxs)("div",{className:"bg-white p-4 rounded-lg shadow border border-gray-200",children:[(0,n.jsxs)("p",{className:"text-gray-800 font-semibold",children:[(0,n.jsx)("strong",{children:"Username:"})," ",e.username]}),(0,n.jsxs)("p",{className:"text-gray-700 mt-2",children:[(0,n.jsx)("strong",{children:"Tweet:"})," ",e.tweet]}),(0,n.jsxs)("p",{className:"font-semibold mt-2 ".concat(e.misinformation?"text-red-500":"text-green-500"),children:[(0,n.jsx)("strong",{children:"Misinformation Alert:"})," ",e.misinformation?"True":"False"]})]},t))})}),(0,n.jsx)("div",{className:"mt-4 text-center flex flex-col items-center ",children:v.map((e,t)=>(0,n.jsxs)("div",{className:"grid grid-cols-1 bg-white hover:bg-gray-100 rounded-lg w-full max-w-xl mb-2 justify-between hover:drop-shadow-md hover:transition duration-300 ease-in-out transform hover:-translate-y-1",children:[w===e.id?(0,n.jsx)(AddContent_EditTweet,{user:{name:"Name",username:"Username",profileImage:"/default-pfp.png"},content:e.tweet.content,timestamp:"Just now",currentLikes:e.tweet.countLikes||"2",currentReplies:e.tweet.countReplies||"6",currentTweets:e.tweet.countRetweets||"5",onContentChange:e=>T(e)}):(0,n.jsx)(m.Z,{user:{name:"Name",username:"Username",profileImage:"/default-pfp.png"},content:e.tweet.content,timestamp:"Just now",currentLikes:e.tweet.countLikes||"2",currentReplies:e.tweet.countReplies||"6",currentTweets:e.tweet.countRetweets||"5"}),(0,n.jsxs)("div",{className:"text-right rounded-bl-lg rounded br-lg bg-gray-200 p-1 ",children:[w!==e.id?(0,n.jsx)("button",{className:"bg-blue-500 hover:bg-blue-600 p-1 text-white rounded mr-2",onClick:()=>{N(e.id)},children:"Edit Post"}):(0,n.jsx)("button",{className:"bg-yellow-500 hover:bg-yellow-600 p-1 text-white rounded mr-2",onClick:()=>{N(null)},children:"Cancel"}),w!==e.id?(0,n.jsx)("button",{className:"bg-red-500 hover:bg-red-600 p-1 text-white rounded ",onClick:()=>{S(e.id),k(!0)},children:"Delete Post"}):(0,n.jsx)("button",{className:"bg-green-500 hover:bg-green-600 p-1 text-white rounded ",onClick:()=>{handleContentUpdate(e.id)},disabled:A,children:A?"Updating":"Save Changes"})]})]},t))}),(0,n.jsx)(AddContentModal,{open:s,setIsOpen:l,closeModal:()=>{l(!1)},onContentSave:handleContentSave,title:"Add Post"}),(0,n.jsx)(u.Z,{isOpen:P,close:closeConfirmDialog,title:"Delete Post",description:"Are you sure you want to delete this post?",isDeleting:o,onConfirm:()=>{deletePost(E)}})]})}}},function(e){e.O(0,[675,72,142,774,888,179],function(){return e(e.s=269)}),_N_E=e.O()}]);
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.