import{j as a,B as g,S as m,X as h,r as d}from"./main-pzSpmpV2.js";import"./separator-C1IUkfHl.js";import{D as u}from"./layout-D23Ks5S8.js";import{f as l,D as f,a as j,b,c as w,d as D,e as k}from"./data-table-column-header-DXeZFhtt.js";import{I as C}from"./input-6kwZWIt9.js";import{D as S}from"./data-table-CFJjNL4R.js";import{F as y}from"./FetchWrapper-DtDh1OOQ.js";import"./dialog-CwPbkvSr.js";import"./chevron-right-aCSBeO6-.js";import"./index-BtdXaa8D.js";import"./chevrons-up-down-ZAOsMAOK.js";import"./table-Di4jwPel.js";import"./spinner-BwGdrg0I.js";import"./loader-2-fAceJRLq.js";const V=[{accessorKey:"date",header:({column:e})=>a.jsx(l,{column:e,title:"Date"}),cell:({row:e})=>a.jsx("div",{children:e.getValue("date")}),enableSorting:!1,enableHiding:!1},{accessorKey:"clickId",header:({column:e})=>a.jsx(l,{column:e,title:"Click ID"}),cell:({row:e})=>a.jsx("div",{className:"w-[80px]",children:e.getValue("clickId")}),enableSorting:!1,enableHiding:!1},{accessorKey:"campaign_name",header:({column:e})=>a.jsx(l,{column:e,title:"Campaign"}),cell:({row:e})=>a.jsx("div",{children:e.getValue("campaign_name")}),enableSorting:!1,enableHiding:!1},{accessorKey:"referer",header:({column:e})=>a.jsx(l,{column:e,title:"Referer"}),cell:({row:e})=>a.jsx("div",{children:e.getValue("referer")}),enableSorting:!1,enableHiding:!1},{accessorKey:"host",header:({column:e})=>a.jsx(l,{column:e,title:"Host"}),cell:({row:e})=>a.jsx("div",{children:e.getValue("host")}),enableSorting:!1,enableHiding:!1},{accessorKey:"uri",header:({column:e})=>a.jsx(l,{column:e,title:"Uri"}),cell:({row:e})=>a.jsx("div",{children:e.getValue("uri")}),enableSorting:!1,enableHiding:!1},{accessorKey:"device_info",header:({column:e})=>a.jsx(l,{column:e,title:"Device"}),cell:({row:e})=>{const s=e.getValue("device_info");return a.jsx("div",{children:(s==null?void 0:s.device)||"Unknown"})},enableSorting:!1,enableHiding:!1},{accessorKey:"device_os",header:({column:e})=>a.jsx(l,{column:e,title:"OS"}),cell:({row:e})=>{const s=e.getValue("device_info");return a.jsx("div",{className:"flex items-center gap-2",children:a.jsx("img",{className:"w-[32px]",src:`/wp-content/plugins/linkfiliate/assets/icons/os/${s==null?void 0:s.os}.png`,alt:(s==null?void 0:s.os)||"Unknown",title:`${s==null?void 0:s.os} ${s==null?void 0:s.os_version}`})})},enableSorting:!1,enableHiding:!1},{accessorKey:"device_browser",header:({column:e})=>a.jsx(l,{column:e,title:"Browser"}),cell:({row:e})=>{const s=e.getValue("device_info");return a.jsx("div",{className:"flex items-center gap-2",children:a.jsx("img",{className:"w-[32px]",src:`/wp-content/plugins/linkfiliate/assets/icons/browsers/${s==null?void 0:s.browser}.png`,alt:(s==null?void 0:s.browser)||"Unknown",title:`${s==null?void 0:s.browser} ${s==null?void 0:s.browser_version}`})})},enableSorting:!1,enableHiding:!1},{accessorKey:"ip_address",header:({column:e})=>a.jsx(l,{column:e,title:"IP Address"}),cell:({row:e})=>a.jsx("div",{className:"w-[80px]",children:e.getValue("ip_address")}),enableSorting:!1,enableHiding:!1}];function v({table:e}){return a.jsxs(f,{children:[a.jsx(j,{asChild:!0,children:a.jsxs(g,{variant:"outline",size:"sm",className:"ml-auto hidden h-8 lg:flex",children:[a.jsx(m,{}),"View"]})}),a.jsxs(b,{align:"end",className:"w-[150px]",children:[a.jsx(w,{children:"Toggle columns"}),a.jsx(D,{}),e.getAllColumns().filter(s=>typeof s.accessorFn<"u"&&s.getCanHide()).map(s=>a.jsx(k,{className:"capitalize",checked:s.getIsVisible(),onCheckedChange:t=>s.toggleVisibility(!!t),children:s.id},s.id))]})]})}function N({table:e}){var t;const s=e.getState().columnFilters.length>0;return a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex flex-1 items-center space-x-2",children:[a.jsx(C,{placeholder:"Filter Click ID...",value:((t=e.getColumn("clickId"))==null?void 0:t.getFilterValue())??"",onChange:r=>{var i;return(i=e.getColumn("clickId"))==null?void 0:i.setFilterValue(r.target.value)},className:"h-8 w-[150px] lg:w-[250px]"}),s&&a.jsxs(g,{variant:"ghost",onClick:()=>e.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:["Reset",a.jsx(h,{})]})]}),a.jsx(v,{table:e})]})}function O(){const[e,s]=d.useState([]),[t,r]=d.useState(!0);d.useEffect(()=>{document.title="ClickLog";const n=async()=>{r(!0);const x=new y(linkfiliate==null?void 0:linkfiliate.pluginApiUrl,linkfiliate==null?void 0:linkfiliate.nonce);try{const o=new URLSearchParams;x.post("/clicklog",o.toString(),{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"}).then(c=>{s(c.data),r(!1)}).catch(c=>{console.error("Error fetching data:",c),r(!1)})}catch(o){console.error("Error:",o),r(!1)}};n();const p=setInterval(n,2e4);return()=>clearInterval(p)},[]);const i=[{name:"Dashboard",href:"#/dashboard"},{name:"Clicklog"}];return a.jsx(u,{breadcrumb:i,children:a.jsx("div",{className:"space-y-6 p-4",children:a.jsx(S,{data:e,columns:V,toolbar:n=>a.jsx(N,{table:n}),isLoading:t})})})}export{O as default};
//# sourceMappingURL=index-EcyFZX5u.js.map
