import{r as p,j as t,b as At,R as L}from"./chunk-UIGDSWPH-BhuNDbxn.js";import{g as W,B as O,L as Et,c as st,a3 as at,a4 as Tt,a5 as Pe,a6 as Re,a7 as Ht,u as _t,I as It,a8 as Ge,a9 as Qe}from"./main-af3pcbZa.js";import{S as rt}from"./SelectDropdown-C8sZwHi_.js";import{A as Lt}from"./AlertModal-BhtTtzZV.js";import{S as Ot}from"./plus-2WF6_FMG.js";import{S as B}from"./check-circle--AtVWUy0.js";import{S as Ke}from"./arrow-right-DC7G5FiV.js";import{S as Rt}from"./pencil-CuC2vg9I.js";import{M as it}from"./index-ju2wdkG8.js";import{S as Vt}from"./angle-left-CYBnq6Pg.js";import{B as Xe}from"./Badge-DM3morB7.js";const lt=e=>p.createElement("svg",{className:"size-5",xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"none",...e},p.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.6501 11.9996C3.6501 7.38803 7.38852 3.64961 12.0001 3.64961C16.6117 3.64961 20.3501 7.38803 20.3501 11.9996C20.3501 16.6112 16.6117 20.3496 12.0001 20.3496C7.38852 20.3496 3.6501 16.6112 3.6501 11.9996ZM12.0001 1.84961C6.39441 1.84961 1.8501 6.39392 1.8501 11.9996C1.8501 17.6053 6.39441 22.1496 12.0001 22.1496C17.6058 22.1496 22.1501 17.6053 22.1501 11.9996C22.1501 6.39392 17.6058 1.84961 12.0001 1.84961ZM10.9992 7.52468C10.9992 8.07697 11.4469 8.52468 11.9992 8.52468H12.0002C12.5525 8.52468 13.0002 8.07697 13.0002 7.52468C13.0002 6.9724 12.5525 6.52468 12.0002 6.52468H11.9992C11.4469 6.52468 10.9992 6.9724 10.9992 7.52468ZM12.0002 17.371C11.586 17.371 11.2502 17.0352 11.2502 16.621V10.9445C11.2502 10.5303 11.586 10.1945 12.0002 10.1945C12.4144 10.1945 12.7502 10.5303 12.7502 10.9445V16.621C12.7502 17.0352 12.4144 17.371 12.0002 17.371Z",fill:"#0BA5EC"})),Z=e=>p.createElement("svg",{className:"fill-current",width:"1em",height:"1em",viewBox:"0 0 25 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},p.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.6686 16.75C12.4526 16.75 12.2579 16.6587 12.1211 16.5126L7.5115 11.9059C7.21851 11.6131 7.21836 11.1382 7.51116 10.8452C7.80396 10.5523 8.27883 10.5521 8.57182 10.8449L11.9186 14.1896V4C11.9186 3.58579 12.2544 3.25 12.6686 3.25C13.0828 3.25 13.4186 3.58579 13.4186 4V14.1854L16.7615 10.8449C17.0545 10.5521 17.5294 10.5523 17.8222 10.8453C18.115 11.1383 18.1148 11.6131 17.8218 11.9059L13.2469 16.4776C13.1093 16.644 12.9013 16.75 12.6686 16.75ZM5.41663 16C5.41663 15.5858 5.08084 15.25 4.66663 15.25C4.25241 15.25 3.91663 15.5858 3.91663 16V18.5C3.91663 19.7426 4.92399 20.75 6.16663 20.75H19.1675C20.4101 20.75 21.4175 19.7426 21.4175 18.5V16C21.4175 15.5858 21.0817 15.25 20.6675 15.25C20.2533 15.25 19.9175 15.5858 19.9175 16V18.5C19.9175 18.9142 19.5817 19.25 19.1675 19.25H6.16663C5.75241 19.25 5.41663 18.9142 5.41663 18.5V16Z",fill:"currentColor"})),Pt=e=>p.createElement("svg",{width:"1em",height:"1em",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},p.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.54142 3.7915C6.54142 2.54886 7.54878 1.5415 8.79142 1.5415H11.2081C12.4507 1.5415 13.4581 2.54886 13.4581 3.7915V4.0415H15.6252H16.666C17.0802 4.0415 17.416 4.37729 17.416 4.7915C17.416 5.20572 17.0802 5.5415 16.666 5.5415H16.3752V8.24638V13.2464V16.2082C16.3752 17.4508 15.3678 18.4582 14.1252 18.4582H5.87516C4.63252 18.4582 3.62516 17.4508 3.62516 16.2082V13.2464V8.24638V5.5415H3.3335C2.91928 5.5415 2.5835 5.20572 2.5835 4.7915C2.5835 4.37729 2.91928 4.0415 3.3335 4.0415H4.37516H6.54142V3.7915ZM14.8752 13.2464V8.24638V5.5415H13.4581H12.7081H7.29142H6.54142H5.12516V8.24638V13.2464V16.2082C5.12516 16.6224 5.46095 16.9582 5.87516 16.9582H14.1252C14.5394 16.9582 14.8752 16.6224 14.8752 16.2082V13.2464ZM8.04142 4.0415H11.9581V3.7915C11.9581 3.37729 11.6223 3.0415 11.2081 3.0415H8.79142C8.37721 3.0415 8.04142 3.37729 8.04142 3.7915V4.0415ZM8.3335 7.99984C8.74771 7.99984 9.0835 8.33562 9.0835 8.74984V13.7498C9.0835 14.1641 8.74771 14.4998 8.3335 14.4998C7.91928 14.4998 7.5835 14.1641 7.5835 13.7498V8.74984C7.5835 8.33562 7.91928 7.99984 8.3335 7.99984ZM12.4168 8.74984C12.4168 8.33562 12.081 7.99984 11.6668 7.99984C11.2526 7.99984 10.9168 8.33562 10.9168 8.74984V13.7498C10.9168 14.1641 11.2526 14.4998 11.6668 14.4998C12.081 14.4998 12.4168 14.1641 12.4168 13.7498V8.74984Z",fill:"currentColor"})),zt=e=>p.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"none",...e},p.createElement("path",{d:"M8.875 18.25L15.125 12L8.875 5.75",stroke:"#344054",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"})),Dt=e=>p.createElement("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},p.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10.2441 6C10.2441 5.0335 11.0276 4.25 11.9941 4.25H12.0041C12.9706 4.25 13.7541 5.0335 13.7541 6C13.7541 6.9665 12.9706 7.75 12.0041 7.75H11.9941C11.0276 7.75 10.2441 6.9665 10.2441 6ZM10.2441 18C10.2441 17.0335 11.0276 16.25 11.9941 16.25H12.0041C12.9706 16.25 13.7541 17.0335 13.7541 18C13.7541 18.9665 12.9706 19.75 12.0041 19.75H11.9941C11.0276 19.75 10.2441 18.9665 10.2441 18ZM11.9941 10.25C11.0276 10.25 10.2441 11.0335 10.2441 12C10.2441 12.9665 11.0276 13.75 11.9941 13.75H12.0041C12.9706 13.75 13.7541 12.9665 13.7541 12C13.7541 11.0335 12.9706 10.25 12.0041 10.25H11.9941Z",fill:"currentColor"})),Ut=({children:e,className:a})=>t.jsx("table",{className:`min-w-full w-full ${a}`,children:e}),Bt=({children:e,className:a})=>t.jsx("thead",{className:a,children:e}),Yt=({children:e,className:a})=>t.jsx("tbody",{className:a,children:e}),Oe=({children:e,className:a})=>t.jsx("tr",{className:a,children:e}),te=({children:e,isHeader:a=!1,className:r})=>{const n=a?"th":"td";return t.jsx(n,{className:` ${r}`,children:e})},Mt={"/planner/keywords":{title:"Delete Keywords",singleItemMessage:"You are about to delete this keyword. This action cannot be undone.",multipleItemsMessage:e=>`You are deleting ${e} keywords. This action cannot be undone.`,itemNameSingular:"keyword",itemNamePlural:"keywords"},"/planner/clusters":{title:"Delete Clusters",singleItemMessage:"You are about to delete this cluster. All associated keywords will remain but will no longer be grouped under this cluster.",multipleItemsMessage:e=>`You are deleting ${e} clusters. All associated keywords will remain but will no longer be grouped under these clusters.`,itemNameSingular:"cluster",itemNamePlural:"clusters"},"/planner/ideas":{title:"Delete Ideas",singleItemMessage:"You are about to delete this idea. This action cannot be undone.",multipleItemsMessage:e=>`You are deleting ${e} ideas. This action cannot be undone.`,itemNameSingular:"idea",itemNamePlural:"ideas"},"/writer/tasks":{title:"Delete Tasks",singleItemMessage:"You are about to delete this task. This action cannot be undone.",multipleItemsMessage:e=>`You are deleting ${e} tasks. This action cannot be undone.`,itemNameSingular:"task",itemNamePlural:"tasks"},"/writer/content":{title:"Delete Drafts",singleItemMessage:"You are about to delete this draft. This action cannot be undone.",multipleItemsMessage:e=>`You are deleting ${e} drafts. This action cannot be undone.`,itemNameSingular:"draft",itemNamePlural:"drafts"},"/writer/published":{title:"Delete Published Content",singleItemMessage:"You are about to delete this published content. This action cannot be undone.",multipleItemsMessage:e=>`You are deleting ${e} published content items. This action cannot be undone.`,itemNameSingular:"published content",itemNamePlural:"published content items"}};function Wt(e){return Mt[e]||null}const Zt={"/planner/keywords":{export:{title:"Export Selected Keywords",message:e=>`You are about to export ${e} selected keyword${e!==1?"s":""}. The export will be downloaded as a CSV file.`,confirmText:"Export",itemNamePlural:"keywords"},updateStatus:{title:"Update Status",message:e=>`You are about to update the status of ${e} selected keyword${e!==1?"s":""}. Select the new status below.`,confirmText:"Update Status",itemNamePlural:"keywords",statusOptions:[{value:"active",label:"Active"},{value:"pending",label:"Pending"},{value:"archived",label:"Archived"}]}},"/planner/clusters":{export:{title:"Export Selected Clusters",message:e=>`You are about to export ${e} selected cluster${e!==1?"s":""}. The export will be downloaded as a CSV file.`,confirmText:"Export",itemNamePlural:"clusters"},updateStatus:{title:"Update Status",message:e=>`You are about to update the status of ${e} selected cluster${e!==1?"s":""}. Select the new status below.`,confirmText:"Update Status",itemNamePlural:"clusters",statusOptions:[{value:"active",label:"Active"},{value:"inactive",label:"Inactive"}]}},"/planner/ideas":{export:{title:"Export Selected Ideas",message:e=>`You are about to export ${e} selected idea${e!==1?"s":""}. The export will be downloaded as a CSV file.`,confirmText:"Export",itemNamePlural:"ideas"},updateStatus:{title:"Update Status",message:e=>`You are about to update the status of ${e} selected idea${e!==1?"s":""}. Select the new status below.`,confirmText:"Update Status",itemNamePlural:"ideas",statusOptions:[{value:"new",label:"New"},{value:"scheduled",label:"Scheduled"},{value:"published",label:"Published"}]}},"/writer/tasks":{export:{title:"Export Selected Tasks",message:e=>`You are about to export ${e} selected task${e!==1?"s":""}. The export will be downloaded as a CSV file.`,confirmText:"Export",itemNamePlural:"tasks"},updateStatus:{title:"Update Status",message:e=>`You are about to update the status of ${e} selected task${e!==1?"s":""}. Select the new status below.`,confirmText:"Update Status",itemNamePlural:"tasks",statusOptions:[{value:"queued",label:"Queued"},{value:"completed",label:"Completed"}]}},"/writer/content":{export:{title:"Export Selected Drafts",message:e=>`You are about to export ${e} selected draft${e!==1?"s":""}. The export will be downloaded as a CSV file.`,confirmText:"Export",itemNamePlural:"drafts"},updateStatus:{title:"Update Status",message:e=>`You are about to update the status of ${e} selected draft${e!==1?"s":""}. Select the new status below.`,confirmText:"Update Status",itemNamePlural:"drafts",statusOptions:[{value:"draft",label:"Draft"},{value:"review",label:"Review"},{value:"publish",label:"Publish"}]}},"/writer/published":{export:{title:"Export Selected Published Content",message:e=>`You are about to export ${e} selected published content item${e!==1?"s":""}. The export will be downloaded as a CSV file.`,confirmText:"Export",itemNamePlural:"published content items"},updateStatus:{title:"Update Status",message:e=>`You are about to update the status of ${e} selected published content item${e!==1?"s":""}. Select the new status below.`,confirmText:"Update Status",itemNamePlural:"published content items",statusOptions:[{value:"publish",label:"Publish"},{value:"review",label:"Review"},{value:"draft",label:"Draft"}]}}};function Jt(e){return Zt[e]||null}const J=t.jsx(Rt,{className:"w-5 h-5"}),qt=t.jsx(Pt,{className:"w-5 h-5"}),Ft=t.jsx(Z,{className:"w-5 h-5"});function Gt(e){const a=et[e]||et.default;if(e==="/planner/keyword-opportunities")return{rowActions:a.rowActions||[],bulkActions:a.bulkActions||[]};const r=a.rowActions.filter(c=>c.key!=="edit"&&c.key!=="delete"&&c.key!=="export"),n=a.rowActions.find(c=>c.key==="edit"||c.key==="update")||{key:"edit",label:"Update",icon:J,variant:"primary"},u=a.rowActions.find(c=>c.key==="export")||{key:"export",label:"Export",icon:Ft,variant:"secondary"},m={key:"delete",label:"Delete",icon:qt,variant:"danger"},o=a.bulkActions.filter(c=>c.key!=="delete"),d=a.bulkActions.find(c=>c.key==="delete")||m;return{rowActions:[n,...r,u,m],bulkActions:[...o,d]}}const et={"/planner/keyword-opportunities":{rowActions:[{key:"add_to_workflow",label:"Add",icon:t.jsx(W,{className:"w-5 h-5"}),variant:"success"}],bulkActions:[{key:"add_selected_to_workflow",label:"Add Selected to Workflow",icon:t.jsx(W,{className:"w-5 h-5"}),variant:"success"}]},"/planner/keywords":{rowActions:[{key:"edit",label:"Edit",icon:J,variant:"primary"}],bulkActions:[{key:"update_status",label:"Update Status",icon:t.jsx(B,{className:"w-4 h-4 text-success-500"}),variant:"secondary"},{key:"export",label:"Export Selected",icon:t.jsx(Z,{className:"w-4 h-4 text-blue-light-500"}),variant:"secondary"},{key:"auto_cluster",label:"Auto-Cluster",icon:t.jsx(W,{className:"w-4 h-4 text-warning-500"}),variant:"secondary"}]},"/planner/clusters":{rowActions:[{key:"edit",label:"Edit",icon:J,variant:"primary"},{key:"generate_ideas",label:"Generate Ideas",icon:t.jsx(W,{className:"w-5 h-5"}),variant:"primary"}],bulkActions:[{key:"update_status",label:"Update Status",icon:t.jsx(B,{className:"w-4 h-4 text-success-500"}),variant:"secondary"},{key:"export",label:"Export Selected",icon:t.jsx(Z,{className:"w-4 h-4 text-blue-light-500"}),variant:"secondary"},{key:"auto_generate_ideas",label:"Generate Ideas",icon:t.jsx(W,{className:"w-4 h-4 text-warning-500"}),variant:"secondary"}]},"/planner/ideas":{rowActions:[{key:"edit",label:"Edit",icon:J,variant:"primary"},{key:"queue_to_writer",label:"Queue to Writer",icon:t.jsx(Ke,{className:"w-5 h-5"}),variant:"primary"}],bulkActions:[{key:"update_status",label:"Update Status",icon:t.jsx(B,{className:"w-4 h-4 text-success-500"}),variant:"secondary"},{key:"export",label:"Export Selected",icon:t.jsx(Z,{className:"w-4 h-4 text-blue-light-500"}),variant:"secondary"},{key:"queue_to_writer",label:"Queue to Writer",icon:t.jsx(Ke,{className:"w-4 h-4 text-brand-500"}),variant:"secondary"}]},"/writer/tasks":{rowActions:[{key:"edit",label:"Edit",icon:J,variant:"primary"},{key:"generate_content",label:"Generate Content",icon:t.jsx(W,{className:"w-5 h-5"}),variant:"primary"}],bulkActions:[{key:"update_status",label:"Update Status",icon:t.jsx(B,{className:"w-4 h-4 text-success-500"}),variant:"secondary"},{key:"export",label:"Export Selected",icon:t.jsx(Z,{className:"w-4 h-4 text-blue-light-500"}),variant:"secondary"}]},"/writer/content":{rowActions:[{key:"edit",label:"Edit",icon:J,variant:"primary"},{key:"generate_image_prompts",label:"Generate Image Prompts",icon:t.jsx(W,{className:"w-5 h-5 text-purple-500"}),variant:"primary"}],bulkActions:[{key:"update_status",label:"Update Status",icon:t.jsx(B,{className:"w-4 h-4 text-success-500"}),variant:"secondary"},{key:"export",label:"Export Selected",icon:t.jsx(Z,{className:"w-4 h-4 text-blue-light-500"}),variant:"secondary"},{key:"publish",label:"Publish Selected",icon:t.jsx(B,{className:"w-4 h-4 text-success-500"}),variant:"secondary"}]},"/writer/published":{rowActions:[{key:"edit",label:"Edit",icon:J,variant:"primary"}],bulkActions:[{key:"update_status",label:"Update Status",icon:t.jsx(B,{className:"w-4 h-4 text-success-500"}),variant:"secondary"},{key:"export",label:"Export Selected",icon:t.jsx(Z,{className:"w-4 h-4 text-blue-light-500"}),variant:"secondary"}]},"/writer/images":{rowActions:[{key:"update_status",label:"Update Status",icon:t.jsx(B,{className:"w-5 h-5"}),variant:"primary"}],bulkActions:[]},default:{rowActions:[],bulkActions:[]}};function Qt({isOpen:e,onClose:a,onConfirm:r,title:n,message:u,confirmText:m="Export",isLoading:o=!1}){return t.jsx(it,{isOpen:e,onClose:a,className:"max-w-md",children:t.jsxs("div",{className:"p-6",children:[t.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[t.jsx("div",{className:"flex items-center justify-center w-10 h-10 bg-blue-50 rounded-xl dark:bg-blue-500/10",children:t.jsx(lt,{className:"w-5 h-5 text-blue-500"})}),t.jsx("h2",{className:"text-xl font-bold text-gray-800 dark:text-white",children:n})]}),t.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-6",children:u}),t.jsxs("div",{className:"flex justify-end gap-4",children:[t.jsx(O,{variant:"outline",onClick:a,disabled:o,children:"Cancel"}),t.jsx(O,{variant:"primary",onClick:r,disabled:o,children:o?"Exporting...":m})]})]})})}function Kt({isOpen:e,onClose:a,onConfirm:r,title:n,message:u,confirmText:m="Update Status",statusOptions:o,isLoading:d=!1}){const[c,y]=p.useState(""),g=async()=>{c&&(await r(c),y(""))},b=()=>{y(""),a()};return t.jsx(it,{isOpen:e,onClose:b,className:"max-w-md",children:t.jsxs("div",{className:"p-6",children:[t.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[t.jsx("div",{className:"flex items-center justify-center w-10 h-10 bg-blue-50 rounded-xl dark:bg-blue-500/10",children:t.jsx(lt,{className:"w-5 h-5 text-blue-500"})}),t.jsx("h2",{className:"text-xl font-bold text-gray-800 dark:text-white",children:n})]}),t.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-4",children:u}),t.jsxs("div",{className:"mb-6",children:[t.jsx(Et,{className:"mb-2",children:"New Status"}),t.jsx(rt,{options:o,placeholder:"Select status",value:c,onChange:N=>y(N||""),className:"w-full"})]}),t.jsxs("div",{className:"flex justify-end gap-4",children:[t.jsx(O,{variant:"outline",onClick:b,disabled:d,children:"Cancel"}),t.jsx(O,{variant:"primary",onClick:g,disabled:d||!c,children:d?"Updating...":m})]})]})})}const Xt=({currentPage:e,totalPages:a,pageSize:r,onPageChange:n,onPageSizeChange:u,className:m=""})=>{const d=(()=>{const g=[];if(a<=7)for(let b=1;b<=a;b++)g.push(b);else if(e<=3){for(let b=1;b<=5;b++)g.push(b);g.push("..."),g.push(a)}else if(e>=a-2){g.push(1),g.push("...");for(let b=a-4;b<=a;b++)g.push(b)}else{g.push(1),g.push("...");for(let b=e-1;b<=e+1;b++)g.push(b);g.push("..."),g.push(a)}return g})(),c=e===1,y=e===a;return t.jsxs("div",{className:`flex items-center gap-3 ${m}`,children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("label",{htmlFor:"page-size",className:"text-sm text-gray-500 dark:text-gray-400 whitespace-nowrap",children:"Show:"}),t.jsxs("select",{id:"page-size",value:r,onChange:g=>u(Number(g.target.value)),className:"h-8 px-2 text-sm rounded-lg border border-gray-300 bg-white text-gray-700 shadow-sm hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-brand-500 focus:border-brand-500 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:hover:bg-gray-700",children:[t.jsx("option",{value:10,children:"10"}),t.jsx("option",{value:20,children:"20"}),t.jsx("option",{value:50,children:"50"})]}),t.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400 whitespace-nowrap",children:"per page"})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:()=>!c&&n(e-1),disabled:c,type:"button",className:"flex items-center justify-center w-7 h-7 rounded-lg border border-gray-300 bg-white text-gray-700 shadow-sm hover:bg-gray-50 hover:text-gray-900 disabled:opacity-50 disabled:cursor-not-allowed dark:border-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 transition-colors","aria-label":"Previous page",children:t.jsx(Vt,{className:"w-4 h-4"})}),t.jsx("div",{className:"flex items-center gap-0.5",children:d.map((g,b)=>{if(g==="...")return t.jsx("span",{className:"flex items-center justify-center w-7 h-7 text-xs font-medium text-gray-700 dark:text-gray-400",children:"..."},`ellipsis-${b}`);const N=g,$=N===e;return t.jsx("button",{className:`flex items-center justify-center w-7 h-7 text-xs font-medium rounded-lg transition-colors ${$?"text-white bg-brand-500 hover:bg-brand-600 shadow-sm":"text-gray-700 hover:bg-brand-500 hover:text-white dark:text-gray-400 dark:hover:text-white dark:hover:bg-brand-500"}`,onClick:()=>n(N),type:"button","aria-label":`Go to page ${N}`,"aria-current":$?"page":void 0,children:N},N)})}),t.jsx("button",{onClick:()=>!y&&n(e+1),disabled:y,type:"button",className:"flex items-center justify-center w-7 h-7 rounded-lg border border-gray-300 bg-white text-gray-700 shadow-sm hover:bg-gray-50 hover:text-gray-900 disabled:opacity-50 disabled:cursor-not-allowed dark:border-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200 transition-colors","aria-label":"Next page",children:t.jsx(zt,{className:"w-4 h-4"})})]})]})},es=st()(at(e=>({pageSize:10,setPageSize:a=>e({pageSize:a})}),{name:"igny8-page-size"})),ts=st()(at((e,a)=>({pageColumns:{},setPageColumns:(r,n)=>{e(u=>({pageColumns:{...u.pageColumns,[r]:n}}))},getPageColumns:r=>a().pageColumns[r]||[],toggleColumn:(r,n)=>{e(u=>{const m=u.pageColumns[r]||[],o=m.includes(n)?m.filter(d=>d!==n):[...m,n];return{pageColumns:{...u.pageColumns,[r]:o}}})},resetPageColumns:r=>{e(n=>{const u={...n.pageColumns};return delete u[r],{pageColumns:u}})}}),{name:"igny8-column-visibility",partialize:e=>({pageColumns:e.pageColumns})}));function Ve(e){if(!e)return"";const a=document.createElement("div");return a.innerHTML=e,a.querySelectorAll("script").forEach(u=>u.remove()),a.querySelectorAll("*").forEach(u=>{const m=u.attributes;for(let o=m.length-1;o>=0;o--){const d=m[o];d.name.startsWith("on")&&u.removeAttribute(d.name),(d.name==="href"||d.name==="src")&&d.value.startsWith("javascript:")&&u.removeAttribute(d.name)}}),a.innerHTML}function tt(e){return e?/<[a-z][\s\S]*>/i.test(e):!1}function ce(e){if(!e)return"";if(typeof e=="object"&&e!==null&&"content"in e){const r=e.content;if(typeof r=="string"&&r.trim().length>0)return Ve(r)}let a='
';return e.introduction&&(a+='
',typeof e.introduction=="string"?a+=`
${k(e.introduction)}
`:typeof e.introduction=="object"&&(e.introduction.hook&&(a+=`
Hook: ${k(e.introduction.hook)}
`),e.introduction.paragraphs&&Array.isArray(e.introduction.paragraphs)&&e.introduction.paragraphs.forEach((r,n)=>{r.details&&(a+=`
Intro Paragraph ${n+1}: ${k(r.details)}
`)})),a+="
"),e.sections&&Array.isArray(e.sections)&&e.sections.forEach(r=>{if(r){if(a+='
',r.title){const n=r.title.replace(/^H2:\s*/i,"").trim();n.toLowerCase()==="conclusion"?a+=`
${k(n)}
`:a+=`
${k(n)}
`}r.content&&(Array.isArray(r.content)?r.content.forEach(n=>{if(n.title){const u=n.title.replace(/^H3:\s*/i,"").trim();a+=`
${k(u)}
`}n.content&&(a+=`
${k(String(n.content))}
`)}):typeof r.content=="string"&&(a+=`
${k(r.content)}
`)),a+="
"}}),e.H2&&(Array.isArray(e.H2)?e.H2.forEach(r=>{if(r.heading||typeof r=="string"){a+='
';const n=r.heading||r;a+=`
${k(n)}
`,r.content_type&&(a+=`
${k(r.content_type.replace("_"," ").toUpperCase())}
`),r.subsections&&Array.isArray(r.subsections)&&r.subsections.forEach(u=>{const m=u.subheading||u.heading||u;a+=`
${k(m)}
`,u.details&&(a+=`
${k(u.details)}
`)}),r.details&&(a+=`
${k(r.details)}
`),a+="
"}}):typeof e.H2=="string"?(a+='
',a+=`
${k(e.H2)}
`,a+=""):typeof e.H2=="object"&&Object.entries(e.H2).forEach(([r,n])=>{a+='
',a+=`
${k(n)}
`,a+=""})),e.H3&&!e.H2&&(a+='
',typeof e.H3=="string"?a+=`
${k(e.H3)}
`:typeof e.H3=="object"&&Object.entries(e.H3).forEach(([r,n])=>{a+=`${k(n)}
`}),a+=""),a+="
",a}function k(e){const a=document.createElement("div");return a.textContent=e,a.innerHTML}const ss=({content:e,className:a="",maxHeight:r})=>{const n=p.useMemo(()=>{if(!e)return'No content available
';if(typeof e=="object"&&e!==null){if(e.H2||e.H3||e.introduction||e.sections)return ce(e);try{return Object.keys(e).length>0?ce(e):k(JSON.stringify(e,null,2))}catch{return k(JSON.stringify(e,null,2))}}if(typeof e=="string"){if(e.trim().startsWith("{")||e.trim().startsWith("["))try{const d=JSON.parse(e);if(typeof d=="object"&&d!==null){if(d.content&&typeof d.content=="string"){const c=d.content;if(tt(c)){const y=Ve(c);return y.trim().startsWith("${y}`:``}if(c.trim().startsWith("{"))try{const y=JSON.parse(c);if(y.H2||y.H3||y.introduction||y.sections)return ce(y)}catch{}e=c}else if(d.H2||d.H3||d.introduction||d.sections)return ce(d)}}catch{}try{const d=JSON.parse(e);if(typeof d=="object"&&(d.H2||d.H3||d.introduction||d.sections))return ce(d)}catch{}if(tt(e)){const d=Ve(e);return d.trim().startsWith("${d}`:``}const u=e.split(`
`);let m='',o=!1;for(const d of u){const c=d.trim();if(!c){o&&(m+="",o=!1),m+="
";continue}if(c.match(/^[-*]\s+/)){o||(m+='
',o=!0);const y=c.replace(/^[-*]\s+/,"");c.startsWith(" ")||c.startsWith(" ")?m+=`- ${k(y)}
`:m+=`- ${k(y)}
`}else if(c.match(/^[-*]\s*H2[:]/i)){o&&(m+="
",o=!1);const y=c.replace(/^[-*]\s*H2[:]\s*/i,"");m+=`
${k(y)}
`}else if(c.match(/^[-*]\s*H3[:]/i)){o&&(m+="",o=!1);const y=c.replace(/^[-*]\s*H3[:]\s*/i,"");m+=`
${k(y)}
`}else o&&(m+="",o=!1),m+=`
${k(c)}
`}return o&&(m+=""),m+="
",m}return k(String(e))},[e]);return t.jsx("div",{className:`html-content-renderer ${a}`,style:r?{maxHeight:r,overflow:"auto"}:void 0,dangerouslySetInnerHTML:{__html:n}})},as=({row:e,contentKey:a,contentLabel:r="Content",colSpan:n,isExpanded:u,defaultExpanded:m=!1,onToggle:o,className:d=""})=>{const[c,y]=p.useState(m),g=u!==void 0?u:c,[b,N]=p.useState("auto"),$=p.useRef(null);let h=e[a],Y=null;h&&typeof h=="object"&&h!==null&&"content"in h&&(Y={...h},h=h.content),(!h||typeof h=="string"&&h.trim().length===0)&&(h=e.description||e.content_outline||null);const q=h&&(typeof h=="string"?h.trim().length>0:typeof h=="object"&&h!==null&&Object.keys(h).length>0);return p.useEffect(()=>{if(g&&$.current){const _=$.current.scrollHeight;N(_)}else N(0)},[g,h]),!q||!g?null:t.jsx("tr",{className:`toggle-content-row expanded ${d}`,"aria-hidden":!1,children:t.jsx("td",{colSpan:n,className:"px-5 py-0 bg-gray-50 dark:bg-gray-800/50 border-b border-gray-200 dark:border-white/[0.05]",children:t.jsx("div",{ref:$,className:"overflow-hidden bg-white dark:bg-gray-900",style:{maxWidth:"1200px",margin:"auto",padding:"25px",marginTop:"50px"},children:t.jsx("div",{className:"py-4 px-2",children:t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsx("div",{className:"text-xs font-semibold uppercase text-gray-500 dark:text-gray-400 tracking-wide",children:r}),e.idea_title&&t.jsxs("div",{className:"mb-2",children:[t.jsx("div",{className:"text-xs font-semibold text-gray-600 dark:text-gray-400 mb-1",children:"Idea:"}),t.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:e.idea_title})]}),t.jsx(rs,{row:e,contentMetadata:Y}),t.jsx("div",{className:"html-content-wrapper",children:t.jsx(ss,{content:h,className:"text-sm text-gray-700 dark:text-gray-300 leading-relaxed"})})]})})})})})},rs=({row:e,contentMetadata:a})=>{var y,g,b,N,$;const r=e.content_primary_keyword||e.primary_keyword||(a==null?void 0:a.primary_keyword)||((y=a==null?void 0:a.metadata)==null?void 0:y.primary_keyword)||null,n=e.content_secondary_keywords||e.secondary_keywords||(a==null?void 0:a.secondary_keywords)||((g=a==null?void 0:a.metadata)==null?void 0:g.secondary_keywords)||[],u=e.content_tags||e.tags||(a==null?void 0:a.tags)||((b=a==null?void 0:a.metadata)==null?void 0:b.tags)||[],m=e.content_categories||e.categories||(a==null?void 0:a.categories)||((N=a==null?void 0:a.metadata)==null?void 0:N.categories)||[];let o=null;if(e.meta_description&&typeof e.meta_description=="string"?o=e.meta_description:e.content_meta_description&&typeof e.content_meta_description=="string"?o=e.content_meta_description:a!=null&&a.meta_description&&typeof a.meta_description=="string"?o=a.meta_description:($=a==null?void 0:a.metadata)!=null&&$.meta_description&&typeof a.metadata.meta_description=="string"&&(o=a.metadata.meta_description),o&&o.trim().startsWith("{"))try{const h=JSON.parse(o);h.meta_description&&typeof h.meta_description=="string"?o=h.meta_description:o=h.meta_description||null}catch{}if(!(r||n&&n.length>0||u&&u.length>0||m&&m.length>0||o))return null;const c=(h,Y="light")=>{if(!h)return null;const q=Array.isArray(h)?h:[h];return q.length===0?null:t.jsx("div",{className:"flex flex-wrap gap-1",children:q.map((_,ke)=>t.jsx(Xe,{color:Y,size:"sm",variant:"light",children:_},`${_}-${ke}`))})};return t.jsxs("div",{className:"space-y-2",children:[r&&t.jsxs("div",{className:"flex items-start gap-2 text-sm text-gray-700 dark:text-gray-300",children:[t.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-400",children:"Primary Keyword:"}),t.jsx(Xe,{color:"info",size:"sm",variant:"light",children:r})]}),(()=>{const h=c(n);return h?t.jsxs("div",{className:"flex items-start gap-2 text-sm text-gray-700 dark:text-gray-300",children:[t.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-400",children:"Secondary Keywords:"}),h]}):null})(),(()=>{const h=c(u);return h?t.jsxs("div",{className:"flex items-start gap-2 text-sm text-gray-700 dark:text-gray-300",children:[t.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-400",children:"Tags:"}),h]}):null})(),(()=>{const h=c(m);return h?t.jsxs("div",{className:"flex items-start gap-2 text-sm text-gray-700 dark:text-gray-300",children:[t.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-400",children:"Categories:"}),h]}):null})(),o&&t.jsxs("div",{className:"rounded-lg bg-gray-50 dark:bg-gray-800/50 p-3 text-xs text-gray-600 dark:text-gray-400",children:[t.jsx("span",{className:"font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400 block mb-1",children:"Meta Description"}),o]})]})},is=({isExpanded:e,onClick:a,hasContent:r,className:n=""})=>r?t.jsx("button",{type:"button",onClick:a,className:`inline-flex items-center justify-center w-8 h-8 rounded-lg transition-all duration-200 ${e?"text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900/20":"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800"} ${n}`,"aria-label":e?"Collapse content":"Expand content","aria-expanded":e,children:t.jsx(Pe,{className:`w-4 h-4 transition-transform duration-200 ${e?"rotate-180":""}`})}):t.jsx("span",{className:`inline-flex items-center justify-center w-8 h-8 text-gray-300 dark:text-gray-600 ${n}`,children:t.jsx(Tt,{className:"w-4 h-4"})});function ls({columns:e,visibleColumns:a,onToggleColumn:r,className:n=""}){const[u,m]=p.useState(!1),o=p.useRef(null),d=p.useRef(null);p.useEffect(()=>{const g=b=>{o.current&&!o.current.contains(b.target)&&d.current&&!d.current.contains(b.target)&&m(!1)};if(u)return document.addEventListener("mousedown",g),()=>{document.removeEventListener("mousedown",g)}},[u]);const c=a.size,y=e.length;return t.jsxs("div",{className:`relative ${n}`,children:[t.jsxs("button",{ref:d,type:"button",onClick:()=>m(!u),className:"inline-flex items-center gap-2 px-3 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 dark:bg-gray-800 dark:text-gray-300 dark:border-gray-700 dark:hover:bg-gray-700 transition-colors",children:[t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})}),t.jsx("span",{children:"Columns"}),t.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["(",c,"/",y,")"]}),t.jsx(Pe,{className:`w-4 h-4 transition-transform ${u?"rotate-180":""}`})]}),u&&t.jsx("div",{ref:o,className:"absolute right-0 mt-2 w-56 rounded-lg border border-gray-200 bg-white shadow-lg dark:border-gray-700 dark:bg-gray-800 z-50 max-h-96 overflow-y-auto",children:t.jsxs("div",{className:"p-2",children:[t.jsx("div",{className:"px-3 py-2 text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wide border-b border-gray-200 dark:border-gray-700 mb-1",children:"Show Columns"}),t.jsx("div",{className:"space-y-1",children:e.map(g=>{const b=a.has(g.key);return t.jsxs("label",{className:"flex items-center gap-2 px-3 py-2 rounded-md hover:bg-gray-50 dark:hover:bg-gray-700 cursor-pointer",children:[t.jsx(Re,{checked:b,onChange:()=>{r(g.key)}}),t.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300 flex-1",children:g.label})]},g.key)})}),t.jsx("div",{className:"mt-2 pt-2 border-t border-gray-200 dark:border-gray-700",children:t.jsx("button",{type:"button",onClick:()=>{e.forEach(g=>{a.has(g.key)||r(g.key)})},className:"w-full px-3 py-1.5 text-xs font-medium text-brand-600 hover:text-brand-700 hover:bg-brand-50 dark:text-brand-400 dark:hover:bg-brand-500/10 rounded-md transition-colors",children:"Show All"})})]})})]})}function bs({columns:e,data:a,loading:r=!1,showContent:n=!0,filters:u=[],filterValues:m={},onFilterChange:o,onFilterReset:d,renderFilters:c,onEdit:y,onCreate:g,createLabel:b="+ Add",onCreateIcon:N,onExportCSV:$,onExportIcon:h,onImport:Y,onImportIcon:q,headerMetrics:_=[],selectionLabel:ke="items",pagination:F,selection:x,sorting:V,onDelete:ue,onBulkDelete:me,onBulkExport:we,onBulkUpdateStatus:je,onBulkAction:ge,onRowAction:ze,onExport:De,getItemDisplayName:nt=j=>j.name||j.keyword||j.title||String(j.id),className:ot=""}){const j=At(),[Ue,Ce]=p.useState(!1),[dt,Ne]=p.useState(new Map),Se=L.useRef(new Map),Be=L.useRef(null),A=Wt(j.pathname),T=Jt(j.pathname),G=Gt(j.pathname),M=(G==null?void 0:G.rowActions)||[],P=(G==null?void 0:G.bulkActions)||[],[w,he]=p.useState((x==null?void 0:x.selectedIds)||[]),[ct,ut]=p.useState(new Set),[I,Q]=p.useState({isOpen:!1,items:[],isBulk:!1,isLoading:!1}),[$e,se]=p.useState({isOpen:!1,itemCount:0,isLoading:!1}),[Ae,ae]=p.useState({isOpen:!1,itemCount:0,isLoading:!1}),{setMetrics:Ee}=Ht(),H=_t(),{pageSize:mt,setPageSize:gt}=es(),{pageColumns:ns,setPageColumns:re,getPageColumns:pe}=ts(),ht=p.useMemo(()=>{const s=pe(j.pathname);if(s.length>0){const i=new Set(s),l=e.filter(f=>i.has(f.key));if(l.length>0){const f=e.filter(v=>!i.has(v.key)&&v.defaultVisible!==!1).map(v=>v.key);return new Set([...Array.from(l.map(v=>v.key)),...f])}}return new Set(e.filter(i=>i.defaultVisible!==!1).map(i=>i.key))},[e,j.pathname,pe]),[ie,Te]=p.useState(ht);p.useEffect(()=>{const s=pe(j.pathname);if(s.length>0){const l=new Set(s),f=e.filter(v=>l.has(v.key));if(f.length>0){const v=e.filter(z=>!l.has(z.key)&&z.defaultVisible!==!1).map(z=>z.key),X=new Set([...Array.from(f.map(z=>z.key)),...v]);Te(X),re(j.pathname,Array.from(X));return}}const i=new Set(e.filter(l=>l.defaultVisible!==!1).map(l=>l.key));Te(i),re(j.pathname,Array.from(i))},[e,j.pathname,pe,re]),p.useEffect(()=>{re(j.pathname,Array.from(ie))},[ie,j.pathname,re]);const K=p.useMemo(()=>e.filter(s=>ie.has(s.key)),[e,ie]),pt=s=>{Te(i=>{const l=new Set(i);return l.has(s)?l.delete(s):l.add(s),l})},xt=x!=null&&x.selectedIds?JSON.stringify(x.selectedIds):"";p.useEffect(()=>{x!=null&&x.selectedIds&&he(x.selectedIds)},[xt]);const ft=s=>{!ue||!A||Q({isOpen:!0,items:[s],isBulk:!1,isLoading:!1})},yt=s=>{if(!me||!A)return;const i=a.filter(l=>s.includes(String(l.id)));Q({isOpen:!0,items:i,isBulk:!0,isLoading:!1})},bt=async()=>{if(!(I.items.length===0||!A)){Q(s=>({...s,isLoading:!0}));try{if(I.isBulk){if(me){const s=I.items.map(f=>f.id),i=await me(s),l=(i==null?void 0:i.deleted_count)||I.items.length;H.success(`${l} ${A.itemNamePlural} deleted successfully`)}}else ue&&(await ue(I.items[0].id),H.success(`${A.itemNameSingular.charAt(0).toUpperCase()+A.itemNameSingular.slice(1)} deleted successfully`));Q({isOpen:!1,items:[],isBulk:!1,isLoading:!1}),x&&x.onSelectionChange([])}catch(s){H.error(`Failed to delete: ${s.message}`),Q(i=>({...i,isLoading:!1}))}}},Ye=async(s,i)=>{var l;Ne(f=>{const v=new Map(f);return v.set(i.id||i,!1),v}),s==="edit"&&y?y(i):s==="delete"&&ue&&A?ft(i):s==="export"&&De?await De(i):ze?ze(s,i).catch(f=>{H.error(`Action failed: ${f.message}`)}):ge?ge(s,[((l=i.id)==null?void 0:l.toString())||String(i)]):H.info(`Action "${s}" not yet implemented`)},Me=(s,i)=>{if(!x)return;const l=x.selectedIds.length>0?x.selectedIds:i;if(s==="delete"&&me&&A)yt(l);else if(s==="export"&&we&&T){const f=l.length;se({isOpen:!0,itemCount:f,isLoading:!1})}else s==="update_status"&&je&&T?ae({isOpen:!0,itemCount:l.length,isLoading:!1}):ge?ge(s,l).catch(f=>{H.error(`Bulk action failed: ${f.message}`)}):H.info(`Bulk action "${s}" not yet implemented`);Ce(!1)},vt=async()=>{if(!we||!x)return;const s=x.selectedIds.length>0?x.selectedIds:w;se(i=>({...i,isLoading:!0}));try{await we(s),H.success("Export successful"),se({isOpen:!1,itemCount:0,isLoading:!1}),x.onSelectionChange([])}catch(i){H.error(`Export failed: ${i.message}`),se(l=>({...l,isLoading:!1}))}},kt=async s=>{if(!(!je||!x)){ae(i=>({...i,isLoading:!0}));try{await je(x.selectedIds,s),H.success("Status updated successfully"),ae({isOpen:!1,itemCount:0,isLoading:!1}),x.onSelectionChange([])}catch(i){H.error(`Failed to update status: ${i.message}`),ae(l=>({...l,isLoading:!1}))}}},He=p.useRef(""),le=p.useRef(!1),xe=p.useMemo(()=>{if(!_||_.length===0)return"";try{return _.map(s=>`${s.label}:${String(s.value)}`).join("|")}catch{return""}},[_]);p.useEffect(()=>{if(xe!==He.current)return xe?(Ee(_),le.current=!0,He.current=xe):le.current&&(Ee([]),le.current=!1,He.current=""),()=>{le.current&&(Ee([]),le.current=!1)}},[xe]);const wt=(c||u.length>0)&&Object.values(m).some(s=>s===""||s===null||s===void 0?!1:typeof s=="object"&&("min"in s||"max"in s)?s.min!==""&&s.min!==null&&s.min!==void 0||s.max!==""&&s.max!==null&&s.max!==void 0:!0),jt=s=>{if(!s.sortable||!V)return;const i=s.sortField||s.key,l=V.sortBy===i?V.sortDirection:null;let f="asc";if(l==="asc")f="desc";else if(l==="desc"){V.onSort("created_at","desc");return}V.onSort(i,f)},We=s=>{if(!s.sortable||!V)return null;const i=s.sortField||s.key;return V.sortBy!==i?t.jsx("span",{className:"ml-1 cursor-pointer text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",children:"⇅"}):V.sortDirection==="asc"?t.jsx("span",{className:"ml-1 cursor-pointer text-brand-500",children:"↑"}):t.jsx("span",{className:"ml-1 cursor-pointer text-brand-500",children:"↓"})},Ct=s=>{if(s){const i=a.filter(l=>!l.isAdded).map(l=>{var f;return((f=l.id)==null?void 0:f.toString())||""}).filter(l=>l!=="");he(i),x==null||x.onSelectionChange(i)}else he([]),x==null||x.onSelectionChange([])},Nt=(s,i)=>{const l=a.find(v=>String(v.id)===s);if(l&&l.isAdded)return;const f=i?[...w,s]:w.filter(v=>v!==s);he(f),x==null||x.onSelectionChange(f)};return t.jsxs("div",{className:ot,children:[(c||u.length>0)&&t.jsx("div",{className:"flex justify-center mb-4",children:t.jsx("div",{className:"w-[75%] igny8-filter-bar p-3 rounded-lg bg-transparent",style:{boxShadow:"0 2px 6px 3px rgba(0, 0, 0, 0.08)"},children:t.jsxs("div",{className:"flex flex-nowrap gap-3 items-center justify-between w-full",children:[t.jsx("div",{className:"flex flex-nowrap gap-3 items-center flex-1 min-w-0 w-full",children:c?t.jsx("div",{className:"flex flex-nowrap gap-3 items-center flex-1 min-w-0 w-full",children:c}):t.jsx(t.Fragment,{children:u.map(s=>{if(s.type==="custom"&&s.customRender)return t.jsx(L.Fragment,{children:s.customRender()},s.key);if(s.type==="text")return t.jsx(It,{type:"text",placeholder:s.placeholder||`Search ${s.label.toLowerCase()}...`,value:m[s.key]||"",onChange:i=>{o==null||o(s.key,i.target.value)},className:"flex-1 min-w-[200px] h-9"},s.key);if(s.type==="select"){const i=m[s.key]||"";return t.jsx(rt,{options:s.options||[],placeholder:s.label,value:i,onChange:l=>{const f=l==null?"":String(l);o==null||o(s.key,f)},className:s.className||"flex-1 min-w-[140px]"},s.key)}return null})})}),wt&&d&&t.jsx(O,{variant:"secondary",size:"sm",onClick:d,className:"flex-shrink-0",children:"Clear Filters"})]})})}),t.jsxs("div",{className:"flex justify-between items-center mb-4",children:[P.length>0&&t.jsx("div",{className:"inline-block",children:P.length===1?t.jsxs(O,{size:"md",onClick:()=>{w.length>0&&Me(P[0].key,w)},disabled:w.length===0,variant:P[0].variant==="success"?"success":(P[0].variant==="danger","primary"),startIcon:P[0].icon,className:w.length===0?"opacity-50 cursor-not-allowed":"",children:[P[0].label,w.length>0&&t.jsx("span",{className:"ml-2 inline-flex items-center justify-center px-2 py-0.5 text-xs font-medium rounded-full bg-white/20 text-white",children:w.length})]}):t.jsxs(t.Fragment,{children:[t.jsxs(O,{ref:Be,size:"md",onClick:()=>w.length>0&&Ce(!Ue),disabled:w.length===0,className:`dropdown-toggle ${w.length===0?"opacity-50 cursor-not-allowed":""}`,endIcon:t.jsx(Pe,{className:"w-4 h-4"}),children:["Bulk Actions",w.length>0&&t.jsx("span",{className:"ml-2 inline-flex items-center justify-center px-2 py-0.5 text-xs font-medium rounded-full bg-blue-100 text-blue-800 dark:bg-blue-500/20 dark:text-blue-300",children:w.length})]}),t.jsx(Ge,{isOpen:Ue&&w.length>0,onClose:()=>Ce(!1),anchorRef:Be,placement:"bottom-left",className:"w-48 p-2",children:P.map((s,i)=>{const l=s.key==="delete",f=l&&i>0;return t.jsxs(L.Fragment,{children:[f&&t.jsx("div",{className:"my-2 border-t border-gray-200 dark:border-gray-800"}),t.jsxs(Qe,{onItemClick:()=>{Me(s.key,w)},className:`flex items-center gap-3 px-3 py-2 font-medium rounded-lg text-sm text-left ${l?"text-error-500 hover:bg-error-50 hover:text-error-600 dark:text-error-400 dark:hover:bg-error-500/15 dark:hover:text-error-300":"text-gray-700 hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-white/5 dark:hover:text-gray-300"}`,children:[s.icon&&t.jsx("span",{className:"flex-shrink-0 w-5 h-5",children:s.icon}),t.jsx("span",{className:"text-left",children:s.label})]})]},s.key)})})]})}),t.jsxs("div",{className:"flex gap-2 items-center",children:[t.jsx(ls,{columns:e.map(s=>({key:s.key,label:s.label,defaultVisible:s.defaultVisible!==!1})),visibleColumns:ie,onToggleColumn:pt}),$&&t.jsx(O,{variant:"secondary",size:"md",endIcon:h,onClick:$,children:"Export CSV"}),Y&&t.jsx(O,{variant:"secondary",size:"md",endIcon:q,onClick:Y,children:"Import"}),g&&t.jsx(O,{variant:"primary",size:"md",endIcon:N,onClick:g,children:b})]})]}),t.jsx("div",{className:`rounded-xl border border-gray-200 bg-white dark:border-white/[0.05] dark:bg-white/[0.03] igny8-table-container ${n?"loaded":"loading"}`,style:{overflowX:"auto",overflowY:"visible"},children:t.jsx("div",{className:"igny8-table-wrapper",style:{overflow:"visible"},children:t.jsxs(Ut,{className:"igny8-table-compact igny8-table-smooth",children:[t.jsx(Bt,{className:"border-b border-gray-100 dark:border-white/[0.05]",children:t.jsxs(Oe,{children:[x&&t.jsx(te,{isHeader:!0,className:"px-5 py-3 font-medium text-gray-500 text-start text-theme-xs dark:text-gray-400 w-12",children:n&&t.jsx(Re,{checked:(()=>{const s=a.filter(i=>!i.isAdded);return s.length>0&&w.length===s.length})(),onChange:Ct,id:"select-all"})}),K.map((s,i)=>{const l=i===K.length-1;return t.jsx(te,{isHeader:!0,className:`px-5 py-3 font-medium text-gray-500 text-${s.align||"start"} text-theme-xs dark:text-gray-400 ${s.sortable?"cursor-pointer hover:text-gray-700 dark:hover:text-gray-300":""} ${l&&M.length>0?"pr-16":""}`,children:s.sortable?t.jsxs("div",{onClick:()=>jt(s),className:"flex items-center",children:[s.label,We(s)]}):t.jsxs(t.Fragment,{children:[s.label,We(s)]})},s.key)})]})}),t.jsx(Yt,{className:"divide-y divide-gray-100 dark:divide-white/[0.05] igny8-table-body",children:n?a.length===0?null:a.map((s,i)=>{var qe;const l=s.id||i,f=ct.has(l),v=e.find(S=>S.toggleable),X=(v==null?void 0:v.toggleContentKey)||(v==null?void 0:v.key),z=(v==null?void 0:v.toggleContentLabel)||"Content",ee=X?s[X]:null,fe=ee&&(typeof ee=="string"?ee.trim().length>0:typeof ee=="object"&&ee!==null&&Object.keys(ee).length>0),St=(x?1:0)+K.length,Ze=(S,D)=>{ut(ne=>{const E=new Set(ne),oe=D??l;return S?E.add(oe):E.delete(oe),E})},Je=!!s.isAdded;return t.jsxs(L.Fragment,{children:[t.jsxs(Oe,{className:`igny8-data-row ${Je?"bg-blue-50 dark:bg-blue-500/10":""}`,children:[x&&t.jsx(te,{className:"px-5 py-4 text-start",children:t.jsx(Re,{checked:w.includes(((qe=s.id)==null?void 0:qe.toString())||""),onChange:S=>{var D;return Nt(((D=s.id)==null?void 0:D.toString())||"",S)},id:`checkbox-${s.id}`,disabled:Je})}),K.map((S,D)=>{var oe;const ne=D===K.length-1,E=s.id||i;if(ne&&M.length>0&&!Se.current.has(E)){const de=L.createRef();Se.current.set(E,de)}return t.jsxs(te,{className:`px-5 py-4 text-${S.align||"start"} text-gray-800 dark:text-white/90 ${ne&&M.length>0?"relative pr-16":""}`,children:[t.jsxs("div",{className:`flex items-center ${S.toggleable&&fe?"justify-between w-full":""} gap-2`,children:[t.jsx("div",{className:"flex-1",children:S.render?S.render(s[S.key],s):t.jsx("span",{children:((oe=s[S.key])==null?void 0:oe.toString())||"-"})}),S.toggleable&&fe&&t.jsx("div",{onClick:de=>de.stopPropagation(),children:t.jsx(is,{isExpanded:f,onClick:()=>{Ze(!f,l)},hasContent:fe})})]}),ne&&M.length>0&&(()=>{const de=!!s.isAdded;if(M.length===1){const C=M[0];return de?t.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 z-10",children:t.jsx("span",{className:"text-sm font-medium text-blue-light-500 dark:text-blue-light-400",children:"Added"})}):t.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 z-10",children:t.jsxs("button",{type:"button",onClick:R=>{R.stopPropagation(),Ye(C.key,s)},className:"flex items-center gap-1 text-sm font-medium text-success-500 hover:text-success-600 dark:text-success-400 dark:hover:text-success-300 transition-colors cursor-pointer",children:[C.label,t.jsx("span",{className:"inline-flex items-center",children:t.jsx(Ot,{className:"w-4 h-4 fill-current"})})]})})}const _e=Se.current.get(E);if(!_e)return null;const $t=dt.get(E)||!1;return t.jsxs(t.Fragment,{children:[t.jsx("button",{ref:_e,type:"button",onClick:C=>{C.stopPropagation(),Ne(R=>{const U=new Map(R);return U.forEach((Ie,ye)=>{ye!==E&&U.set(ye,!1)}),U.set(E,!U.get(E)),U})},className:"absolute right-2 top-1/2 -translate-y-1/2 inline-flex items-center justify-center w-8 h-8 rounded-lg transition-colors text-gray-500 hover:text-gray-700 hover:bg-gray-100 dark:text-gray-400 dark:hover:text-gray-300 dark:hover:bg-gray-800 dropdown-toggle z-10",title:"Actions",children:t.jsx(Dt,{className:"w-5 h-5"})}),t.jsx(Ge,{isOpen:$t,onClose:()=>{Ne(C=>{const R=new Map(C);return R.set(E,!1),R})},anchorRef:_e,placement:"right",className:"w-48 p-2",children:M.map(C=>{const R=C.key==="edit",U=C.key==="delete",Ie=C.key==="export",ye=()=>{var Fe;if(!C.icon)return null;const be=C.icon,ve=((Fe=be.props)==null?void 0:Fe.className)||"",Le=ve.includes("w-")?"":"w-5 h-5 ";return R?L.cloneElement(be,{className:`${Le}text-blue-light-500 ${ve}`.trim()}):U?L.cloneElement(be,{className:`${Le}text-error-500 ${ve}`.trim()}):Ie?L.cloneElement(be,{className:`${Le}text-gray-600 dark:text-gray-400 ${ve}`.trim()}):C.icon};return t.jsxs(L.Fragment,{children:[t.jsxs(Qe,{onItemClick:()=>Ye(C.key,s),className:`flex items-center gap-3 px-3 py-2 font-medium rounded-lg text-sm text-left ${R?"text-blue-light-500 hover:bg-blue-light-50 hover:text-blue-light-600 dark:text-blue-light-400 dark:hover:bg-blue-light-500/15 dark:hover:text-blue-light-300":U?"text-error-500 hover:bg-error-50 hover:text-error-600 dark:text-error-400 dark:hover:bg-error-500/15 dark:hover:text-error-300":"text-gray-700 hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-white/5 dark:hover:text-gray-300"}`,children:[t.jsx("span",{className:"flex-shrink-0 w-5 h-5",children:ye()}),t.jsx("span",{className:"text-left",children:C.label})]}),Ie&&t.jsx("div",{className:"my-2 border-t border-gray-200 dark:border-gray-800"})]},C.key)})})]})})()]},S.key)})]}),v&&fe&&t.jsx(as,{row:s,contentKey:X||"",contentLabel:z,colSpan:St,isExpanded:f,onToggle:Ze})]},s.id||i)}):Array.from({length:10}).map((s,i)=>t.jsxs(Oe,{className:"igny8-skeleton-row",children:[x&&t.jsx(te,{children:t.jsx("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"})}),K.map((l,f)=>t.jsx(te,{children:t.jsx("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"})},f))]},`skeleton-${i}`))})]})})}),A&&t.jsx(Lt,{isOpen:I.isOpen,onClose:()=>Q({isOpen:!1,items:[],isBulk:!1,isLoading:!1}),onConfirm:bt,title:A.title,message:I.isBulk?A.multipleItemsMessage(I.items.length):A.singleItemMessage,variant:"danger",isConfirmation:!0,confirmText:"Delete",cancelText:"Cancel",isLoading:I.isLoading,itemsList:I.items.map(s=>nt(s))}),T&&t.jsx(Qt,{isOpen:$e.isOpen,onClose:()=>se({isOpen:!1,itemCount:0,isLoading:!1}),onConfirm:vt,title:T.export.title,message:T.export.message($e.itemCount),confirmText:T.export.confirmText,isLoading:$e.isLoading}),T&&t.jsx(Kt,{isOpen:Ae.isOpen,onClose:()=>ae({isOpen:!1,itemCount:0,isLoading:!1}),onConfirm:kt,title:T.updateStatus.title,message:T.updateStatus.message(Ae.itemCount),confirmText:T.updateStatus.confirmText,statusOptions:T.updateStatus.statusOptions,isLoading:Ae.isLoading}),F&&t.jsx("div",{className:"mt-6 border-t border-gray-200 dark:border-gray-800 pt-6",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Showing ",a.length," of ",F.totalCount," ",ke||"items"]}),t.jsx(Xt,{currentPage:F.currentPage,totalPages:F.totalPages,pageSize:mt,onPageChange:s=>{F.onPageChange(s)},onPageSizeChange:s=>{gt(s),F.onPageChange(1)}})]})})]})}export{Z as S,bs as T,lt as a,es as u};