PageSourceSearch

https://socialnex.ai/audit/assets/content-studio-BHe87HLQ.js

js socialnex.ai collected 2026-10-05 15:12:11 UTC 34,225 bytes, 1 lines download raw bytes

1import{r as e,j as t,c as s}from"./react-vendor-hAxFZxNQ.js";import{$ as a,a0 as r,a1 as n,a2 as i,a$ as l,b0 as o,ai as d,c,b1 as u,b2 as m,f as x,aj as h,as as p,b3 as f,at as g,h as v,_ as b,e as j,b4 as N,ar as y,Q as w,U as C,V as S,W as k,Y as I,am as D,b5 as T,af as E,ag as O,D as R,b6 as P,b7 as _,b8 as z,b9 as $,ba as F,bb as G,bc as M,bd as W,ah as X,be as A,bf as U,bg as L,bh as J}from"./main-FMm0mhBU.js";import{C as Y,c as B}from"./card-fqsfvo4t.js";import{P as H,a as V}from"./PostComposerModal-DJwl2WsW.js";import{u as K,a as Q,b as q,c as Z,d as ee,e as te,i as se,C as ae,g as re,K as ne,f as ie,h as le,P as oe,D as de,j as ce,k as ue}from"./core.esm-CLy08_YJ.js";import"./ui-DlHKYJvh.js";import"./GoogleBusinessPreview-CfcpQz-L.js";import"./switch-DMvaYDaX.js";const me=()=>j("/api/v1/content-studio");function xe({open:s,onOpenChange:j,columns:N,defaultColumnId:y,editCard:w,onSave:C,onDelete:S,onCreatePost:k}){const[I,D]=e.useState(""),[T,E]=e.useState(""),[O,R]=e.useState(y||N[0]?.id||""),[P,_]=e.useState([]),[z,$]=e.useState(!1),[F,G]=e.useState(!1);e.useEffect(()=>{s&&(w?(D(w.title||""),E(w.content||""),R(w.column_id||y||N[0]?.id||""),_(w.media||[]),$(!1)):(D(""),E(""),R(y||N[0]?.id||""),_([]),$(!1)))},[s,w,y,N]);const M=N.find(e=>e.id===O);return t.jsx(a,{open:s,onOpenChange:j,children:t.jsx(r,{className:"bg-transparent border-none shadow-none p-0 max-w-none w-auto overflow-visible",children:t.jsx("div",{className:"flex items-start",children:t.jsx("div",{className:"relative",children:t.jsxs("div",{className:"w-[700px] max-h-[90vh] overflow-hidden flex flex-col bg-card border rounded-xl shadow-lg z-10",children:[t.jsx(n,{className:"px-6 pt-6 pb-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(i,{children:w?"Edit Idea":"Create Idea"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(l,{children:[t.jsx(o,{asChild:!0,children:t.jsxs(d,{variant:"outline",size:"sm",className:"gap-2",children:[t.jsx(c,{name:"Columns3",className:"h-4 w-4"}),M?.title||"Select Column",t.jsx(c,{name:"ChevronDown",className:"h-4 w-4"})]})}),t.jsx(u,{align:"end",children:N.map(e=>t.jsxs(m,{onClick:()=>R(e.id),className:"gap-2",children:[t.jsx("div",{className:x("w-3 h-3 rounded",e.color)}),e.title,e.id===O&&t.jsx(c,{name:"Check",className:"h-4 w-4 ml-auto"})]},e.id))})]}),t.jsxs(d,{variant:"outline",size:"sm",className:"gap-2",disabled:!0,children:[t.jsx(c,{name:"Tag",className:"h-4 w-4"}),"Tags",t.jsx(c,{name:"ChevronDown",className:"h-4 w-4"})]})]})]})}),t.jsxs("div",{className:"px-6 pb-6 flex flex-col flex-1 overflow-hidden",children:[t.jsx(h,{placeholder:"Give your idea a title",value:I,onChange:e=>D(e.target.value),className:"text-lg font-medium border rounded-lg px-4 py-2 h-auto mb-4 focus-visible:ring-1 placeholder:text-muted-foreground"}),t.jsxs("div",{className:"overflow-hidden rounded-lg border",children:[t.jsx(p,{placeholder:"Describe your idea...",value:T,onChange:e=>E(e.target.value),className:"min-h-[200px] resize-none rounded-none border-0 focus-visible:ring-0 p-4"}),t.jsx("div",{className:"border-t px-3 py-2",children:t.jsx(H,{onEmojiSelect:e=>E(t=>t+e),onMediaClick:()=>$(!0),mediaCount:P.length})}),P.length>0&&t.jsx("div",{className:"flex gap-3 flex-wrap px-4 pb-3",children:P.map(e=>{const s="video"===e.media_type,a=e.thumbnail_url||"image"===e.media_type&&e.url;return t.jsxs("div",{className:"relative w-28 h-28 rounded-lg overflow-hidden group bg-muted border",children:[a?t.jsx("img",{src:e.thumbnail_url||e.url,alt:"",className:"w-full h-full object-contain"}):t.jsx("div",{className:"w-full h-full flex items-center justify-center bg-muted",children:t.jsx(c,{name:"Film",className:"size-8 text-muted-foreground"})}),s&&t.jsxs("div",{className:"absolute bottom-1 left-1 px-1.5 py-0.5 rounded bg-black/70 text-white text-xs flex items-center gap-1",children:[t.jsx(c,{name:"Play",className:"size-3"}),e.duration&&t.jsxs("span",{children:[Math.floor(e.duration/60),":",String(Math.floor(e.duration%60)).padStart(2,"0")]})]}),t.jsx("button",{type:"button","aria-label":"Remove media",onClick:()=>_(t=>t.filter(t=>t.id!==e.id)),className:"absolute top-1 right-1 p-1 rounded-full bg-black/70 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:t.jsx(c,{name:"X",className:"size-4 text-white"})})]},e.id)})})]}),t.jsx(f,{open:z,onOpenChange:$,onSelect:e=>_(e),maxSelect:10,initialSelected:P}),t.jsxs(g,{className:"flex-row justify-between sm:justify-between border-t pt-4 mt-4",children:[t.jsx("div",{className:"flex items-center gap-2",children:w&&S&&t.jsx(d,{variant:"ghost",size:"sm",onClick:()=>
1{w&&S&&S(w.id)},className:"text-destructive hover:text-destructive hover:bg-destructive/10",children:t.jsx(c,{name:"Trash2",className:"h-4 w-4"})})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(d,{variant:"outline",disabled:!k||!T.trim(),onClick:()=>{k&&(k(T,P),j(!1))},children:"Create Post"}),t.jsxs(d,{onClick:async()=>{if(T.trim()){G(!0);try{const e=v("csrftoken"),t={title:I.trim(),content:T.trim(),column_id:O,media_ids:P.map(e=>e.id),order:0};let s;if(s=w?await fetch(`${me()}/cards/${w.id}/`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json","X-CSRFToken":e||""},body:JSON.stringify(t)}):await fetch(`${me()}/cards/`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json","X-CSRFToken":e||""},body:JSON.stringify(t)}),!s.ok)throw new Error("Failed to save idea");const a=await s.json();C(a),j(!1),b({title:w?"Idea updated":"Idea saved",description:"Your idea has been saved to the board."})}catch(e){b({title:"Error",description:"Failed to save idea. Please try again.",variant:"destructive"})}finally{G(!1)}}},disabled:!T.trim()||F,children:[F&&t.jsx(c,{name:"Loader2",className:"h-4 w-4 mr-2 animate-spin"}),w?"Update Idea":"Save Idea"]})]})]})]})]})})})})})}const he=[{value:"professional",label:"Professional"},{value:"casual",label:"Casual"},{value:"witty",label:"Witty"},{value:"inspirational",label:"Inspirational"},{value:"educational",label:"Educational"}];function pe({open:s,onOpenChange:l,onIdeasGenerated:o}){const[u,m]=e.useState(""),[x,h]=e.useState("professional"),[f,g]=e.useState(""),[v,b]=e.useState(!1),[j,T]=e.useState(null),[E,O]=e.useState(null),{gate:R,CreditsGateModal:P}=N(),_=()=>{l(!1),setTimeout(()=>{O(null),T(null)},200)};return t.jsxs(a,{open:s,onOpenChange:_,children:[t.jsxs(r,{className:"sm:max-w-[500px]",children:[t.jsx(n,{children:t.jsxs(i,{className:"text-xl",children:[E?"Here are your ideas":"Generate Ideas"," ✨"]})}),E?t.jsxs("div",{className:"space-y-4 pt-2",children:[t.jsx("div",{className:"space-y-3 max-h-[400px] overflow-y-auto",children:E.map(e=>t.jsxs("div",{className:"p-3 rounded-lg border bg-card hover:bg-muted/50 transition-colors cursor-pointer",children:[t.jsx("h4",{className:"font-medium mb-1",children:e.title}),t.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:e.description}),e.suggested_platforms.length>0&&t.jsx("div",{className:"flex gap-1 flex-wrap",children:e.suggested_platforms.map(e=>t.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-primary/10 text-primary",children:e},e))})]},e.title))}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(d,{variant:"outline",onClick:()=>{O(null),T(null)},className:"flex-1",children:"Start Over"}),t.jsx(d,{onClick:_,className:"flex-1",children:"Done"})]})]}):t.jsxs("div",{className:"space-y-4 pt-2",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(y,{htmlFor:"topic",children:"What do you want to write about?"}),t.jsx(p,{id:"topic",placeholder:"e.g., New product launch announcement",value:u,onChange:e=>m(e.target.value),className:"min-h-[100px] resize-none",disabled:v})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(y,{htmlFor:"tone",children:"Tone"}),t.jsxs(w,{value:x,onValueChange:h,disabled:v,children:[t.jsx(C,{children:t.jsx(S,{placeholder:"Select tone"})}),t.jsx(k,{children:he.map(e=>t.jsx(I,{value:e.value,children:e.label},e.value))})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs(y,{htmlFor:"instructions",className:"text-muted-foreground",children:["Additional instructions ",t.jsx("span",{className:"text-muted-foreground/60",children:"(optional)"})]}),t.jsx(p,{id:"instructions",placeholder:"e.g., Include a call to action",value:f,onChange:e=>
1g(e.target.value),className:"min-h-[60px] resize-none",disabled:v})]}),j&&t.jsx("p",{className:"text-sm text-destructive",children:j}),t.jsx(d,{onClick:R(async()=>{if(u.trim()){b(!0),T(null);try{const e=await D.generateIdeas({business_description:u,target_audience:`Tone: ${x}${f?`. ${f}`:""}`,count:5});O(e.ideas),o?.(e.ideas)}catch(e){T(e instanceof Error?e.message:"Failed to generate ideas")}finally{b(!1)}}else T("Please enter a topic")}),disabled:v||!u.trim(),className:"w-full",size:"lg",children:v?t.jsxs(t.Fragment,{children:[t.jsx(c,{name:"Loader2",className:"mr-2 h-4 w-4 animate-spin"}),"Generating..."]}):"Generate Ideas"})]})]}),P]})}function fe(e,t,s){const a=e.slice();return a.splice(s<0?a.length+s:s,0,a.splice(t,1)[0]),a}function ge(e,t){return e.reduce((e,s,a)=>{const r=t.get(s);return r&&(e[a]=r),e},Array(e.length))}function ve(e){return null!==e&&e>=0}const be={scaleX:1,scaleY:1},je=e=>{var t;let{rects:s,activeNodeRect:a,activeIndex:r,overIndex:n,index:i}=e;const l=null!=(t=s[r])?t:a;if(!l)return null;const o=function(e,t,s){const a=e[t],r=e[t-1],n=e[t+1];return a&&(r||n)?s<t?r?a.left-(r.left+r.width):n.left-(a.left+a.width):n?n.left-(a.left+a.width):a.left-(r.left+r.width):0}(s,i,r);if(i===r){const e=s[n];return e?{x:r<n?e.left+e.width-(l.left+l.width):e.left-l.left,y:0,...be}:null}return i>r&&i<=n?{x:-l.width-o,y:0,...be}:i<r&&i>=n?{x:l.width+o,y:0,...be}:{x:0,y:0,...be}},Ne=e=>{let{rects:t,activeIndex:s,overIndex:a,index:r}=e;const n=fe(t,a,s),i=t[r],l=n[r];return l&&i?{x:l.left-i.left,y:l.top-i.top,scaleX:l.width/i.width,scaleY:l.height/i.height}:null},ye={scaleX:1,scaleY:1},we=e=>{var t;let{activeIndex:s,activeNodeRect:a,index:r,rects:n,overIndex:i}=e;const l=null!=(t=n[s])?t:a;if(!l)return null;if(r===s){const e=n[i];return e?{x:0,y:s<i?e.top+e.height-(l.top+l.height):e.top-l.top,...ye}:null}const o=function(e,t,s){const a=e[t],r=e[t-1],n=e[t+1];return a?s<t?r?a.top-(r.top+r.height):n?n.top-(a.top+a.height):0:n?n.top-(a.top+a.height):r?a.top-(r.top+r.height):0:0}(n,r,s);return r>s&&r<=i?{x:0,y:-l.height-o,...ye}:r<s&&r>=i?{x:0,y:l.height+o,...ye}:{x:0,y:0,...ye}},Ce="Sortable",Se=s.createContext({activeIndex:-1,containerId:Ce,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Ne,disabled:{draggable:!1,droppable:!1}});function ke(t){let{children:a,id:r,items:n,strategy:i=Ne,disabled:l=!1}=t;const{active:o,dragOverlay:d,droppableRects:c,over:u,measureDroppableContainers:m}=K(),x=Q(Ce,r),h=Boolean(null!==d.rect),p=e.useMemo(()=>n.map(e=>"object"==typeof e&&"id"in e?e.id:e),[n]),f=null!=o,g=o?p.indexOf(o.id):-1,v=u?p.indexOf(u.id):-1,b=e.useRef(p),j=!function(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let s=0;s<e.length;s++)if(e[s]!==t[s])return!1;return!0}(p,b.current),N=-1!==v&&-1===g||j,y=function(e){return"boolean"==typeof e?{draggable:e,droppable:e}:e}(l);q(()=>{j&&f&&m(p)},[j,p,f,m]),e.useEffect(()=>{b.current=p},[p]);const w=e.useMemo(()=>({activeIndex:g,containerId:x,disabled:y,disableTransforms:N,items:p,overIndex:v,useDragOverlay:h,sortedRects:ge(p,c),strategy:i}),[g,x,y.draggable,y.droppable,N,p,v,c,h,i]);return s.createElement(Se.Provider,{value:w},a)}const Ie=e=>{let{id:t,items:s,activeIndex:a,overIndex:r}=e;return fe(s,a,r).indexOf(t)},De=e=>{let{containerId:t,isSorting:s,wasDragging:a,index:r,items:n,newIndex:i,previousItems:l,previousContainerId:o,transition:d}=e;return!(!d||!a||l!==n&&r===i||!s&&(i===r||t!==o))},Te={duration:200,easing:"ease"},Ee="transform",Oe=ae.Transition.toString({property:Ee,duration:0,easing:"linear"}),Re={roleDescription:"sortable"};function Pe(t){let{animateLayoutChanges:s=De,attributes:a,disabled:r,data:n,getNewIndex:i=Ie,id:l,strategy:o,resizeObserverConfig:d,transition:c=Te}=t;const{items:u,containerId:m,activeIndex:x,disabled:h,disableTransforms:p,sortedRects:f,overIndex:g,useDragOverlay:v,strategy:b}=e.useContext(Se),j=function(e,t){var s,a;return"boolean"==typeof e?{draggable:e,droppable:!1}:{draggable:null!=(s=null==e?void 0:e.draggable)?s:t.draggable,droppable:null!=(a=null==e?void 0:e.droppable)?a:t.droppable}}(r,h),N=u.indexOf(l),y=e.useMemo(()=>({sortable:{containerId:m,index:N,items:u},...n}),[m,n,N,u]),w=e.useMemo(()=>u.slice(u.indexOf(l)),[u,l]),{rect:C,node:S,isOver:k,setNodeRef:I}=Z({id:l,data:y,disabled:j.droppable,resizeObserverConfig:{updateMeasurementsFor:w,...d}}),{active:D,activatorEvent:T,activeNodeRect:E,attributes:O,setNodeRef:R,listeners:P,isDragging:_,over:z,setActivatorNodeRef:$,transform:F}
1=ee({id:l,data:y,attributes:{...Re,...a},disabled:j.draggable}),G=te(I,R),M=Boolean(D),W=M&&!p&&ve(x)&&ve(g),X=!v&&_,A=X&&W?F:null,U=W?null!=A?A:(null!=o?o:b)({rects:f,activeNodeRect:E,activeIndex:x,overIndex:g,index:N}):null,L=ve(x)&&ve(g)?i({id:l,items:u,activeIndex:x,overIndex:g}):N,J=null==D?void 0:D.id,Y=e.useRef({activeId:J,items:u,newIndex:L,containerId:m}),B=u!==Y.current.items,H=s({active:D,containerId:m,isDragging:_,isSorting:M,id:l,index:N,items:u,newIndex:Y.current.newIndex,previousItems:Y.current.items,previousContainerId:Y.current.containerId,transition:c,wasDragging:null!=Y.current.activeId}),V=function(t){let{disabled:s,index:a,node:r,rect:n}=t;const[i,l]=e.useState(null),o=e.useRef(a);return q(()=>{if(!s&&a!==o.current&&r.current){const e=n.current;if(e){const t=re(r.current,{ignoreTransform:!0}),s={x:e.left-t.left,y:e.top-t.top,scaleX:e.width/t.width,scaleY:e.height/t.height};(s.x||s.y)&&l(s)}}a!==o.current&&(o.current=a)},[s,a,r,n]),e.useEffect(()=>{i&&l(null)},[i]),i}({disabled:!H,index:N,node:S,rect:C});return e.useEffect(()=>{M&&Y.current.newIndex!==L&&(Y.current.newIndex=L),m!==Y.current.containerId&&(Y.current.containerId=m),u!==Y.current.items&&(Y.current.items=u)},[M,L,m,u]),e.useEffect(()=>{if(J===Y.current.activeId)return;if(null!=J&&null==Y.current.activeId)return void(Y.current.activeId=J);const e=setTimeout(()=>{Y.current.activeId=J},50);return()=>clearTimeout(e)},[J]),{active:D,activeIndex:x,attributes:O,data:y,rect:C,index:N,newIndex:L,items:u,isOver:k,isSorting:M,isDragging:_,listeners:P,node:S,overIndex:g,over:z,setNodeRef:G,setActivatorNodeRef:$,setDroppableNodeRef:I,setDraggableNodeRef:R,transform:null!=V?V:U,transition:V||B&&Y.current.newIndex===N?Oe:X&&!se(T)||!c?void 0:M||H?ae.Transition.toString({...c,property:Ee}):void 0}}ne.Down,ne.Right,ne.Up,ne.Left;const _e=[{name:"Gray",value:"bg-slate-500/10"},{name:"Blue",value:"bg-blue-500/10"},{name:"Green",value:"bg-emerald-500/10"},{name:"Yellow",value:"bg-amber-500/10"},{name:"Red",value:"bg-red-500/10"},{name:"Purple",value:"bg-purple-500/10"},{name:"Pink",value:"bg-pink-500/10"},{name:"Cyan",value:"bg-cyan-500/10"}],ze=[{id:"unassigned",title:"Unassigned",color:"bg-slate-500/10",order:0,cards:[]},{id:"todo",title:"To Do",color:"bg-blue-500/10",order:1,cards:[]},{id:"in-progress",title:"In Progress",color:"bg-amber-500/10",order:2,cards:[]},{id:"done",title:"Done",color:"bg-emerald-500/10",order:3,cards:[]}],$e=()=>j("/api/v1/content-studio"),Fe="kanban:columns",Ge="content-studio:view-mode",Me="content-studio:columns";function We({column:s,onUpdateTitle:a,onUpdateColor:r,onDelete:n,onNewIdea:i,onEditCard:p,onDeleteCard:f,isEditing:g,onStartEdit:v,onEndEdit:b,isDragOverlay:j=!1}){const{attributes:N,listeners:y,setNodeRef:w,transform:C,transition:S,isDragging:k}=Pe({id:s.id}),I={transform:ae.Transform.toString(C),transition:S,opacity:k?.5:1},D=e.useRef(null),[T,E]=e.useState(s.title);e.useEffect(()=>{g&&D.current&&(D.current.focus(),D.current.select())},[g]);const O=()=>{const e=T.trim();e&&e!==s.title?a(s.id,e):E(s.title),b()};return t.jsxs("div",{ref:j?void 0:w,style:j?void 0:I,className:x("flex flex-col min-w-[280px] max-w-[280px] rounded-lg",s.color,j&&"shadow-2xl ring-2 ring-primary"),children:[t.jsxs("div",{className:"flex items-center justify-between px-3 py-3 border-b border-border/50",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[t.jsx("button",{type:"button",...j?{}:{...N,...y},className:"cursor-grab active:cursor-grabbing p-1 -ml-1 hover:bg-muted rounded",title:"Drag to reorder",children:t.jsx(c,{name:"GripVertical",className:"h-4 w-4 text-muted-foreground"})}),g?t.jsx(h,{ref:D,value:T,onChange:e=>E(e.target.value),onBlur:O,onKeyDown:e=>{"Enter"===e.key?O():"Escape"===e.key&&(E(s.title),b())},className:"h-7 text-sm font-medium px-2 py-1"}):t.jsx("span",{className:"font-medium text-sm cursor-pointer hover:text-primary truncate",onClick:v,title:"Click to rename",children:s.title}),t.jsx("span",{className:"text-xs text-muted-foreground bg-muted px-1.5 py-0.5 rounded flex-shrink-0",children:s.cards.length})]}),t.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[t.jsx(d,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>i(s.id),children:t.jsx(c,{name:"Plus",className:"h-4 w-4"})}),t.jsxs(l,{children:[t.jsx(o,{asChild:!0,children:t.jsx(d,{variant:"ghost",size:"icon",className:"h-7 w-7",children:t.jsx(c,{name:"MoreHorizontal",className:"h-4 w-4"})})}),t.jsxs(u,{align:"end",className:"w-48",children:[t.jsxs(m,{onClick:v,children:[t.jsx(c,{name:"Pencil",className:"h-4 w-4 mr-2"}),"Rename"]}),t.jsxs(A,{children:[t.jsxs(U,{children:[t.jsx(c,{name:"Palette",className:"h-4 w-4 mr-2"}),"Change Color"]}),t.jsx(L,{children:_e.map(e=>t.jsxs(m,{onClick:()=>r(s.id,e.value),children:[t.jsx("div",{className:x("h-4 w-4 roun
1ded mr-2 border border-border",e.value)}),e.name,s.color===e.value&&t.jsx(c,{name:"Check",className:"h-4 w-4 ml-auto"})]},e.value))})]}),t.jsx(J,{}),t.jsxs(m,{onClick:()=>n(s.id),className:"text-destructive focus:text-destructive",children:[t.jsx(c,{name:"Trash2",className:"h-4 w-4 mr-2"}),"Delete Column"]})]})]})]})]}),t.jsx(ke,{items:s.cards.map(e=>`card-${e.id}`),strategy:we,children:t.jsxs("div",{className:"flex-1 p-2 space-y-2 min-h-[200px] overflow-y-auto",children:[s.cards.map(e=>t.jsx(Xe,{card:e,onClick:()=>p(e),onDelete:f},e.id)),t.jsxs(d,{variant:"ghost",className:"w-full justify-start text-muted-foreground hover:text-foreground h-auto py-3",onClick:()=>i(s.id),children:[t.jsx(c,{name:"Plus",className:"h-4 w-4 mr-2"}),"New Idea"]})]})})]})}function Xe({card:e,onClick:s,onDelete:a}){const{attributes:r,listeners:n,setNodeRef:i,transform:l,transition:o,isDragging:d}=Pe({id:`card-${e.id}`}),c={transform:ae.Transform.toString(l),transition:o,opacity:d?.5:1};return t.jsx("div",{ref:i,style:c,...r,...n,children:t.jsx(Ae,{card:e,onClick:()=>{!d&&s&&s()},onDelete:t=>{t.stopPropagation(),a&&a(e.id)},isDragging:d})})}function Ae({card:e,onClick:s,onDelete:a,isDragging:r=!1}){const n=e.media?.[0],i="video"===n?.media_type;return t.jsxs("div",{className:x("bg-card rounded-lg border border-border shadow-sm overflow-hidden cursor-grab hover:border-primary/50 transition-colors group relative",r&&"cursor-grabbing ring-2 ring-primary"),onClick:s,children:[a&&t.jsx("button",{type:"button","aria-label":"Delete",onClick:a,className:"absolute top-2 right-2 z-10 p-1.5 rounded-md bg-card/80 backdrop-blur-sm border border-border opacity-0 group-hover:opacity-100 transition-opacity hover:bg-destructive/10 hover:border-destructive/50 hover:text-destructive",children:t.jsx(c,{name:"Trash2",className:"h-3.5 w-3.5"})}),n&&t.jsxs("div",{className:"aspect-video bg-muted relative",children:[i?t.jsxs(t.Fragment,{children:[t.jsx("img",{src:n.thumbnail_url||n.url,alt:"",className:"w-full h-full object-cover"}),t.jsx("div",{className:"absolute inset-0 bg-black/20 flex items-center justify-center",children:t.jsx(c,{name:"Play",className:"h-8 w-8 text-white"})})]}):t.jsx("img",{src:n.url,alt:"",className:"w-full h-full object-cover"}),e.media.length>1&&t.jsxs("div",{className:"absolute bottom-2 right-2 bg-black/60 text-white text-xs px-1.5 py-0.5 rounded",children:["+",e.media.length-1]})]}),t.jsxs("div",{className:"p-3",children:[e.title&&t.jsx("h4",{className:"font-medium text-sm text-foreground mb-1 line-clamp-2",children:e.title}),e.content&&t.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:e.content})]})]})}function Ue({card:e,onClick:s}){const a=e.media?.find(e=>"image"===e.media_type);return t.jsxs(Y,{className:"h-full cursor-pointer hover:bg-muted/50 transition-colors overflow-hidden",onClick:s,children:[a&&t.jsx("div",{className:"aspect-[4/3] w-full overflow-hidden bg-muted",children:t.jsx("img",{src:a.thumbnail_url||a.url,alt:"",className:"h-full w-full object-cover"})}),t.jsxs(B,{className:"px-3 py-2",children:[t.jsx("h4",{className:"font-medium text-sm truncate",children:e.title||"Untitled"}),t.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 mt-0.5",children:e.content||"No content"})]})]})}const Le=function(){const{toast:s}=T(),[a,r]=e.useState(()=>E(Me)??[]),[n,i]=e.useState(()=>!O(Me)),l=e.useRef(O(Me)),[o,u]=e.useState(()=>"undefined"!=typeof window&&localStorage.getItem(Ge)||"cards"),[m,p]=e.useState(null),[f,g]=e.useState(null),[b,N]=e.useState(null),[y,w]=e.useState(null),C=e.useRef(null),[S,k]=e.useState(!1),[I,D]=e.useState(void 0),[A,U]=e.useState(null),[L,J]=e.useState(!1),[Y,B]=e.useState(!1),[H,K]=e.useState(""),[Q,q]=e.useState([]),[Z,ee]=e.useState(""),te=ie(le(oe,{activationConstraint:{distance:8}}));e.useEffect(()=>{localStorage.setItem(Ge,o)},[o]),e.useEffect(()=>{!async function(){O(Me)||i(!0);const e=await async function(){try{const e=await fetch(`${$e()}/columns/`,{credentials:"include"});if(e.ok)return(await e.json()).map(e=>({id:e.id.toString(),title:e.title,color:e.color,order:e.order,cards:(e.cards||[]).map(t=>({id:t.id.toString(),title:t.title||"",content:t.content||"",media:t.media||[],column_id:e.id.toString(),order:t.order||0,created_at:t.created_at||"",updated_at:t.updated_at||""}))}))}catch(e){}return function(){try{const e=localStorage.getItem(Fe);if(e)return JSON.parse(e)}catch(e){}return ze}()}();r(e),X(Me,e),i(!1)}()},[]),e.useEffect(()=>{if(!n&&a.length>0){if(l.current)return void(l.current=!1);!function(e){try{localStorage.setItem(Fe,JSON.stringify(e))}catch(t){}}(a),async function(e){try{const t=v("csrftoken");await fetch(`${$e()}/columns/bulk-update/`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json","X-CSRFToken":t||""},body:JSON.stringify(e.map((e,t)=>({id:e.id,title:e.title,color:e.color,order:t})))})}catch(t){}}(a)}},[a,n]);const se=function(e){const t=[];for(const s of e)for(const e of s.cards)t.push(e);return t.sort((e,t)=>
1new Date(t.updated_at).getTime()-new Date(e.updated_at).getTime()),t}(a),ae=(e,t)=>{r(s=>s.map(s=>s.id===e?{...s,title:t}:s))},re=(e,t)=>{r(s=>s.map(s=>s.id===e?{...s,color:t}:s))},ne=e=>{g(e)},me=e=>{U(null),D(e||a[0]?.id),k(!0)},he=e=>{U(e),D(e.column_id),k(!0)},ge=e=>{N(e)},ve=a.find(e=>e.id===f),be=b?a.flatMap(e=>e.cards).find(e=>String(e.id)===String(b)):null,Ne=a.find(e=>e.id===y),ye=y?.startsWith("card-")?a.flatMap(e=>e.cards).find(e=>`card-${e.id}`===y):null;return t.jsxs(R,{children:[t.jsxs("div",{className:"flex flex-col h-full min-w-0",children:[t.jsxs("div",{className:"max-w-7xl mx-auto w-full px-6 py-6 pb-0",children:[t.jsxs("div",{className:"space-y-4 mb-4",children:[t.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-start md:items-end gap-4",children:[t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("h1",{className:"text-3xl md:text-4xl font-black tracking-tight",children:"Content Studio"}),t.jsx("p",{className:"text-muted-foreground",children:"Create and organize your content ideas before publishing."})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("div",{className:"relative",children:[t.jsx(c,{name:"Search",className:"size-4 absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),t.jsx(h,{placeholder:"Search ideas...",className:"pl-9 w-[200px] h-9"})]}),t.jsx(d,{variant:"ghost",size:"icon",className:"h-9 w-9",children:t.jsx(c,{name:"Bell",className:"size-4"})})]})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("div",{className:"inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",children:[t.jsxs("button",{type:"button",onClick:()=>u("cards"),className:x("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md px-3 py-1.5 text-sm font-medium transition-all","cards"===o?"bg-background text-foreground shadow-sm":"hover:text-foreground"),children:[t.jsx(c,{name:"LayoutGrid",className:"h-4 w-4"}),"Cards"]}),t.jsxs("button",{type:"button",onClick:()=>u("kanban"),className:x("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md px-3 py-1.5 text-sm font-medium transition-all","kanban"===o?"bg-background text-foreground shadow-sm":"hover:text-foreground"),children:[t.jsx(c,{name:"Columns3",className:"h-4 w-4"}),"Board"]})]}),t.jsxs("span",{className:"text-sm text-muted-foreground",children:[se.length," ",1===se.length?"idea":"ideas"]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(d,{variant:"outline",size:"sm",className:"h-9 gap-2",onClick:()=>B(!0),children:[t.jsx(c,{name:"Sparkles",className:"h-4 w-4 text-primary"}),"Generate Ideas"]}),t.jsxs(d,{size:"sm",className:"h-9 gap-2",onClick:()=>me(),children:[t.jsx(c,{name:"Plus",className:"h-4 w-4"}),"New Idea"]})]})]})]}),t.jsx("div",{className:"mb-4",children:t.jsxs("div",{className:"relative bg-muted/50 border border-border rounded-xl p-3 focus-within:border-primary/50 focus-within:ring-1 focus-within:ring-primary/20 transition-all",children:[t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(c,{name:"Sparkles",className:"h-5 w-5 text-primary mt-0.5 flex-shrink-0"}),t.jsx("textarea",{value:Z,onChange:e=>ee(e.target.value),placeholder:"Ask AI to write a post, generate ideas, or help with your content...",rows:1,className:"w-full resize-none border-0 bg-transparent text-sm placeholder:text-muted-foreground focus:outline-none"}),t.jsx(d,{size:"icon",disabled:!Z.trim(),className:"h-8 w-8 rounded-full flex-shrink-0",children:t.jsx(c,{name:"ArrowUp",className:"h-4 w-4"})})]}),t.jsxs("div",{className:"flex items-center gap-2 mt-2 pt-2 border-t border-border/50",children:[t.jsxs("button",{type:"button",onClick:()=>me(),className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md bg-background border border-border text-xs text-muted-foreground hover:text-foreground hover:border-primary/50 transition-colors",children:[t.jsx(c,{name:"FileText",className:"h-3.5 w-3.5"}),"Write Post"]}),t.jsxs("button",{type:"button",onClick:()=>B(!0),className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md bg-background border border-border text-xs text-muted-foreground hover:text-foreground hover:border-primary/50 transition-colors",children:[t.jsx(c,{name:"Lightbulb",className:"h-3.5 w-3.5"}),"Get Ideas"]}),t.jsxs("button",{type:"button",className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md bg-background border border-border text-xs text-muted-foreground hover:text-foreground hover:border-primary/50 transition-colors",children:[t.jsx(c,{name:"Wand2",className:"h-3.5 w-3.5"}),"Improve"]})]})]})})]}),n?t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsx(c,{name:"Loader2",className:"h-8 w-8 animate-spin text-muted-foreground"})}):"cards"===o?t.jsx("div",{className:"flex-1 overflow-auto",children:t.jsx("div",{className:"max-w-7xl mx-auto px-6 py-6",children:0===se.length?t.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[t.jsx(c,{name:"FileText",className:"h-12 w-12 text-muted-foreground
1/50 mb-4"}),t.jsx("h3",{className:"font-medium text-lg mb-1",children:"No drafts yet"}),t.jsx("p",{className:"text-sm text-muted-foreground max-w-sm mb-4",children:"Start creating content and your drafts will appear here."}),t.jsxs(d,{onClick:()=>me(),children:[t.jsx(c,{name:"Plus",className:"h-4 w-4 mr-2"}),"Create your first idea"]})]}):t.jsx("div",{className:"grid gap-3 grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5",children:se.map(e=>t.jsx(Ue,{card:e,onClick:()=>he(e)},e.id))})})}):t.jsx("div",{className:"flex-1 overflow-auto",children:t.jsx("div",{ref:C,className:"max-w-7xl mx-auto px-6 py-6 overflow-x-auto",children:t.jsxs(de,{sensors:te,collisionDetection:ce,onDragStart:e=>{w(e.active.id)},onDragOver:e=>{const{active:t,over:s}=e;if(!s)return;const n=t.id,i=s.id;if(!n.startsWith("card-"))return;const l=n.replace("card-",""),o=a.find(e=>e.cards.some(e=>e.id===l));if(!o)return;let d=null;if(i.startsWith("card-")){const e=i.replace("card-",""),t=a.find(t=>t.cards.some(t=>t.id===e));d=t?.id||null}else d=i;d&&o.id!==d&&r(e=>{const t=o.cards.find(e=>e.id===l);return t?e.map(e=>e.id===o.id?{...e,cards:e.cards.filter(e=>e.id!==l)}:e.id===d?{...e,cards:[...e.cards,{...t,column_id:e.id}]}:e):e})},onDragEnd:e=>{const{active:t,over:s}=e;if(w(null),!s||t.id===s.id)return;const n=t.id,i=s.id;if(n.startsWith("card-")||i.startsWith("card-")){if(n.startsWith("card-")&&i.startsWith("card-")){const e=n.replace("card-",""),t=i.replace("card-","");r(s=>s.map(s=>{const a=s.cards.findIndex(t=>t.id===e),r=s.cards.findIndex(e=>e.id===t);if(-1!==a&&-1!==r){const e=fe(s.cards,a,r).map((e,t)=>({...e,order:t}));return(async e=>{try{const t=v("csrftoken");for(const s of e)await fetch(j(`/api/v1/content-studio/cards/${s.id}/`),{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json","X-CSRFToken":t||""},body:JSON.stringify({order:s.order})})}catch(t){}})(e),{...s,cards:e}}return s}))}if(n.startsWith("card-")&&!i.startsWith("card-")){const e=n.replace("card-",""),t=a.flatMap(e=>e.cards).find(t=>t.id===e);t&&(async(e,t)=>{try{const s=v("csrftoken");await fetch(j(`/api/v1/content-studio/cards/${e}/`),{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json","X-CSRFToken":s||""},body:JSON.stringify({column_id:t})})}catch(s){}})(t.id,i)}}else r(e=>{const t=e.findIndex(e=>e.id===n),s=e.findIndex(e=>e.id===i);return fe(e,t,s).map((e,t)=>({...e,order:t}))})},children:[t.jsx(ke,{items:a.map(e=>e.id),strategy:je,children:t.jsxs("div",{className:"flex gap-4 h-full",children:[a.map(e=>t.jsx(We,{column:e,onUpdateTitle:ae,onUpdateColor:re,onDelete:ne,onNewIdea:me,onEditCard:he,onDeleteCard:ge,isEditing:m===e.id,onStartEdit:()=>p(e.id),onEndEdit:()=>p(null)},e.id)),t.jsx("div",{className:"min-w-[200px]",children:t.jsxs(d,{variant:"ghost",className:"text-muted-foreground hover:text-foreground gap-2",onClick:async()=>{const e=`col-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,t={id:e,title:"New Group",color:"bg-slate-500/10",order:a.length,cards:[]};r(e=>[...e,t]),p(e);const s=await async function(e){try{const t=v("csrftoken"),s=await fetch(`${$e()}/columns/`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json","X-CSRFToken":t||""},body:JSON.stringify({title:e.title,color:e.color,order:e.order})});if(s.ok){const e=await s.json();return{id:e.id.toString(),title:e.title,color:e.color,order:e.order,cards:[]}}}catch(t){}return null}(t);s&&(r(t=>t.map(t=>t.id===e?{...t,id:s.id}:t)),p(s.id)),setTimeout(()=>{C.current&&(C.current.scrollLeft=C.current.scrollWidth)},50)},children:[t.jsx(c,{name:"Plus",className:"h-4 w-4"}),"New Group"]})})]})}),t.jsx(ue,{children:Ne?t.jsx(We,{column:Ne,onUpdateTitle:()=>{},onUpdateColor:()=>{},onDelete:()=>{},onNewIdea:()=>{},onEditCard:()=>{},onDeleteCard:()=>{},isEditing:!1,onStartEdit:()=>{},onEndEdit:()=>{},isDragOverlay:!0}):ye?t.jsx("div",{className:"w-[260px]",children:t.jsx(Ae,{card:ye,isDragging:!0})}):null})]})})})]}),t.jsx(P,{open:!!f,onOpenChange:()=>g(null),children:t.jsxs(_,{children:[t.jsxs(z,{children:[t.jsx($,{children:"Delete Column"}),t.jsxs(F,{children:['Are you sure you want to delete "',ve?.title,'"? This action cannot be undone.']})]}),t.jsxs(G,{children:[t.jsx(M,{children:"Cancel"}),t.jsx(W,{onClick:async()=>{f&&(await async function(e){try{const t=v("csrftoken"),s=await fetch(`${$e()}/columns/${e}/`,{method:"DELETE",credentials:"include",headers:{"X-CSRFToken":t||""}});return s.ok||404===s.status}catch(t){return!1}}(f),r(e=>e.filter(e=>e.id!==f)),g(null))},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),t.jsx(P,{open:!!b,onOpenChange:()=>N(null),children:t.jsxs(_,{children:[t.jsxs(z,{children:[t.jsx($,{children:"Delete Idea"}),t.jsxs(F,{children:["Are you sure you want to delete ",be?.title?`"${be.title}"`:"this idea","? This action cannot be undone."]})]}),t.jsxs(G,{children:[t.jsx(M,{children:"Cancel"}),t.jsx(W,{onClick:async()=>
1{if(b)try{const e=v("csrftoken");if(!(await fetch(`${$e()}/cards/${b}/`,{method:"DELETE",credentials:"include",headers:{"X-CSRFToken":e||""}})).ok)throw new Error("Failed to delete card");r(e=>e.map(e=>({...e,cards:e.cards.filter(e=>String(e.id)!==String(b))}))),A&&String(A.id)===String(b)&&(k(!1),U(null)),s({title:"Idea deleted",description:"Your idea has been removed from the board."})}catch(e){s({title:"Error",description:"Failed to delete idea. Please try again.",variant:"destructive"})}finally{N(null)}},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),t.jsx(xe,{open:S,onOpenChange:e=>{k(e),e||U(null)},columns:a,defaultColumnId:I,editCard:A,onSave:e=>{const t=String(e.column_id),s=String(e.id);r(a=>a.map(a=>{if(a.id===t){const r=a.cards.findIndex(e=>String(e.id)===s);if(r>=0){const n=[...a.cards];return n[r]={...e,id:s,column_id:t},{...a,cards:n}}return{...a,cards:[{...e,id:s,column_id:t},...a.cards]}}{const e=a.cards.filter(e=>String(e.id)!==s);if(e.length!==a.cards.length)return{...a,cards:e}}return a}))},onDelete:ge,onCreatePost:(e,t)=>{K(e),q(t),J(!0)}}),t.jsx(V,{open:L,onOpenChange:e=>{J(e),e||(K(""),q([]))},initialContent:H,initialMedia:Q}),t.jsx(pe,{open:Y,onOpenChange:B})]})};export{Le as component};

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.