import{j as e,c as J,a as K,h as Q,r as l,R as U,fV as X,l as Y,bz as Z,I as n,B as a,T as w,a7 as ee,M as S,a1 as re,E as ie,w as te}from"./index-7414fd54.js";import{i as I}from"./index-89446b48.js";import{r as _}from"./createSvgIcon-95ed2313.js";import{d as ae}from"./Article-5d7e88ef.js";import{d as se}from"./Add-d3721059.js";import{o as oe}from"./yup-42c56a9b.js";import{u as le}from"./index.esm-87a8ddec.js";import{c as ne,b as ce}from"./index.esm-24ac0554.js";import{R as de}from"./index.esm-05813f26.js";import{L as me}from"./Link-152aa696.js";import{B as he}from"./Badge-d0750533.js";import{T as pe}from"./Tooltip-395a1541.js";import{T as ue}from"./TextField-ee00f42e.js";import{I as xe}from"./InputAdornment-038fa482.js";var p={},ve=I;Object.defineProperty(p,"__esModule",{value:!0});var k=p.default=void 0,fe=ve(_()),ge=e,je=(0,fe.default)((0,ge.jsx)("path",{d:"M3 13h2v-2H3v2zm0 4h2v-2H3v2zm0-8h2V7H3v2zm4 4h14v-2H7v2zm0 4h14v-2H7v2zM7 7v2h14V7H7z"}),"List");k=p.default=je;var u={},ye=I;Object.defineProperty(u,"__esModule",{value:!0});var C=u.default=void 0,ze=ye(_()),we=e,Se=(0,ze.default)((0,we.jsx)("path",{fillRule:"evenodd",d:"M3 3v8h8V3H3zm6 6H5V5h4v4zm-6 4v8h8v-8H3zm6 6H5v-4h4v4zm4-16v8h8V3h-8zm6 6h-4V5h4v4zm-6 4v8h8v-8h-8zm6 6h-4v-4h4v4z"}),"GridView");C=u.default=Se;const Ge=({title:R,breadcrumbs:Ie,onAddClick:V,showAddButton:$,applabel:H,model:T,count:_e,addButtonLabel:F,permissionPrefix:A,permissionPostfix:B,handleSearch:x,showFilterButton:M=!1,filterCount:t,openFilter:v,fetchapi:E,pageParams:c,buttons:i={list:!0,thumbnail:!0,grid:!0},tabs:s,onSelectedTab:f,goBack:L,extraHeader:g})=>{const P=J(),{userAccessList:d}=K(r=>Q(r)),[o,q]=l.useState(localStorage.getItem("view")||"list");U.useState({Approved:0,Pending:0,Rejected:0,Skipped:0});const[j,D]=l.useState("all"),m=X(c),O=Y(),h=r=>{localStorage.setItem("view",r),q(r),window.dispatchEvent(new CustomEvent("viewChange",{detail:r})),console.log(c),P(E({...c,page:1}))};let G=ne({search:ce()});const{control:ke,handleSubmit:Ce,register:W,getValues:Re}=le({resolver:oe(G),values:{search:m==null?void 0:m.search}}),b=l.useCallback(Z(r=>{x({search:r})},300),[x]),N=l.useMemo(()=>e.jsxs(e.Fragment,{children:[(i==null?void 0:i.list)&&e.jsx(n,{onClick:()=>h("list"),children:e.jsx(k,{color:o==="list"?"primary":"inherit",fontSize:"medium"})}),(i==null?void 0:i.thumbnail)&&e.jsx(n,{onClick:()=>h("thumbnail"),children:e.jsx(ae,{color:o==="thumbnail"?"primary":"inherit",fontSize:"medium"})}),(i==null?void 0:i.grid)&&e.jsx(n,{onClick:()=>h("grid"),children:e.jsx(C,{fontSize:"medium",color:o==="grid"?"primary":"inherit"})})]}),[o]);return e.jsxs(e.Fragment,{children:[e.jsxs(a,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:2,my:2,bgcolor:"white",height:"60px",borderRadius:-1.5},children:[e.jsxs(a,{display:"flex",alignItems:"center",gap:1.5,p:3,children:[L&&e.jsx(me,{sx:r=>{var y,z;return{textDecoration:"none",color:(z=(y=r.palette)==null?void 0:y.success)==null?void 0:z.main,mt:.6}},onClick:()=>O(-1),children:e.jsx(de,{size:20})}),e.jsx(w,{variant:"h4",children:R})]}),e.jsxs(a,{display:"flex",alignItems:"center",gap:2.5,p:3,children:[M&&e.jsx(he,{badgeContent:t,color:"success",invisible:!t||t===0,children:e.jsx(pe,{title:"Filter",arrow:!0,placement:"top",children:e.jsx(n,{onClick:()=>v&&v(!0),color:t&&t>0?"success":"default",children:e.jsx(ee,{size:20})})})}),e.jsx(S,{direction:"row",spacing:1,flex:1,width:"100%",children:e.jsx(ue,{type:"text",sx:{width:"100%"},...W("search"),id:"input-with-icon-textfield",size:"small",InputProps:{startAdornment:e.jsx(xe,{position:"start",children:e.jsx(re,{size:16})})},variant:"outlined",placeholder:"Search",onChange:r=>{b(r.target.value)}})}),e.jsxs(S,{direction:"row",alignItems:"center",spacing:1,children:[N,$&&(d==null?void 0:d.indexOf(`${A||H}.add_${B||T}`))!==-1&&e.jsx(ie,{color:"success",variant:"contained",startIcon:e.jsx(se,{}),onClick:V,sx:{textTransform:"none",borderRadius:2},children:F})]}),g&&g]})]}),s&&e.jsx(a,{children:e.jsx(te,{sx:{p:2,display:"flex",alignItems:"center",gap:2},children:s==null?void 0:s.map(r=>e.jsxs(a,{display:"flex",alignItems:"center",sx:{borderBottom:j===r.key?"2px solid #4CAF50":"none",pb:.5,cursor:"pointer",color:j===r.key?"green":"text.secondary",fontWeight:"bold",fontSize:"14"},onClick:()=>{D(r.key),f&&f(r.key)},children:[r.icon,r.label&&e.jsx(w,{variant:"body2",sx:{ml:.5,fontWeight:500},children:r.label})]},r.key))})})]})};export{Ge as P};
