1import{q as H,bK as O,d as R,R as t,bx as q,b4 as W,b5 as j,b6 as U,b7 as J,b8 as B,cU as X,cV as Q,cW as Z,ai as S,y,aD as ee,T as x,be as F,B as te,b as ae,p as k,a5 as E,P as re,r as se,bP as D,G as I,cX as L,M as ne,N as ie,E as oe,U as le,cY as ce,cG as de,b_ as ue,K as me}from"./index-CpcUj6vn.js";import{S as ge,a as pe,b as ve}from"./ServiceViewSelector-C4l_kId6.js";import{F as Se}from"./FilterListRounded-BWbzQC2p.js";import"./ClearRounded-D3KXK82-.js";import"./ViewModuleRounded-evQnbe6M.js";import"./ToggleButtonGroup-BmqFZsME.js";import"./ToggleButton-CeIAdu7E.js";const fe=e=>`SmartDialog_${window.location.host}_${e}_SurveyServiceSortOrder`,$=e=>`SmartDialog_${window.location.host}_${e}_SurveyServicesRowsPerPage`,Ee=O(e=>({card:{width:"100%",marginBottom:e.spacing(2)},visuallyHidden:{border:0,clip:"rect(0 0 0 0)",height:1,margin:-1,overflow:"hidden",padding:0,position:"absolute",top:20,width:1}}));function A(e,r,a){if(typeof r[a]=="string"){if(r[a]?.toLowerCase()<e[a]?.toLowerCase())return-1;if(r[a]?.toLowerCase()>e[a]?.toLowerCase())return 1}else{if(r[a]<e[a])return-1;if(r[a]>e[a])return 1}return 0}function be(e,r){return e==="desc"?(a,s)=>A(a,s,r):(a,s)=>-A(a,s,r)}function ye(e,r){const a=e.map((s,o)=>[s,o]);return a.sort((s,o)=>{const d=r(s[0],o[0]);return d!==0?d:s[1]-o[1]}),a.map(s=>s[0])}function G(e){const{classes:r,order:a,orderBy:s,onRequestSort:o,headCells:d}=e,m=l=>g=>{o(g,l)};return t.createElement(Q,null,t.createElement(J,null,d.map(l=>t.createElement(B,{key:l.id,align:l.align,sortDirection:s===l.id?a:!1},l.id!=="id"&&t.createElement(Z,{active:s===l.id,direction:s===l.id?a:"asc",onClick:m(l.id)},l.label,s===l.id?t.createElement("span",{className:r.visuallyHidden},a==="desc"?"sorted descending":"sorted ascending"):null)))))}G.propTypes={classes:S.object.isRequired,onRequestSort:S.func.isRequired,order:S.oneOf(["asc","desc"]).isRequired,orderBy:S.string.isRequired,headCells:S.array};function K({headCells:e,rows:r,defaultOrderBy:a}){const s=H(),o=Ee(),{customerId:d}=R(),[m,l]=t.useState(JSON.parse(a).order??"asc"),[g,p]=t.useState(JSON.parse(a).orderBy??"name"),[c,b]=t.useState(0),[f,h]=t.useState(Number(localStorage.getItem($(d))??10)),P=(i,u)=>{const w=g===u&&m==="asc";l(w?"desc":"asc"),p(u),localStorage.setItem(fe(d),JSON.stringify({order:w?"desc":"asc",orderBy:u}))},T=(i,u)=>{s.push(`/${d}/services/surveyservice/${u}/info`)},N=(i,u)=>{b(u)},v=i=>{h(parseInt(i.target.value,10)),localStorage.setItem($(d),parseInt(i.target.value,10)),b(0)},n=f-Math.min(f,r.length-c*f);return t.createElement(q,{dir:"ltr"},t.createElement(W,null,t.createElement(j,null,t.createElement(G,{classes:o,order:m,orderBy:g,onRequestSort:P,rowCount:r.length,headCells:e}),t.createElement(U,null,ye(r,be(m,g)).slice(c*f,c*f+f).map(i=>t.createElement(J,{hover:!0,tabIndex:-1,key:i.id},e.map(u=>{const w=u?.formatter?u?.formatter(i[u.id]):i[u.id];return t.createElement(B,{key:u.id,align:u.align,onClick:Y=>T(Y,i.id)},w)}))),n>0&&null))),t.createElement(X,{rowsPerPageOptions:[10,25,100],component:"div",count:r.length,rowsPerPage:f,page:c,onPageChange:N,onRowsPerPageChange:v}))}K.propTypes={headCells:S.array,rows:S.array,defaultOrderBy:S.string};const he=O(e=>({grid:{paddingTop:e.spacing(5),[e.breakpoints.down("xs")]:{paddingTop:e.spacing(5),padding:e.spacing(4)}},service:{overflow:"visible",position:"relative",padding:e.spacing(5,3),cursor:"pointer",transition:e.transitions.create("transform",{easing:e.transitions.easing.sharp,duration:e.transitions.duration.leavingScreen}),"&:hover":{[e.breakpoints.up("md")]:{transform:"scale(1.05)"},zIndex:"150000"}},passiveService:{backgroundColor:"#eaeaea",overflow:"visible",position:"relative",padding:e.spacing(5,3),cursor:"pointer",transition:e.transitions.create("transform",{easing:e.transitions.easing.sharp,duration:e.transitions.duration.leavingScreen}),"&:hover":{[e.breakpoints.up("md")]:{transform:"scale(1.05)"},zIndex:"150000"}},image:{borderRadius:e.shape.borderRadius,position:"absolute",top:-24,left:e.spacing(3),height:48,width:48,fontSize:24,backgroundColor:e.palette.primary.main},passiveImage:{borderRadius:e.shape.borderRadius,position:"absolute",top:-24,left:e.spacing(3),height:48,width:48,fontSize:24,backgroundColor:"#999"},header:{marginBottom:e.spacing(2),textTransform:"uppercase"},divider:{margin:e.spacing(2,0)},button:{width:"100%"}}));function z(e,r,a){if(typeof r[a]=="string"){if(r[a]?.toLowerCase()<e[a]?.toLowerCase())return-1;if(r[a]?.toLowerCase()>e[a]?.toLowerCase())return 1}else{if(r[a]<e[a])return-1;if(r[a]>e[a])return 1}return 0}function we(e,r){return e==="desc"?(a,s)=>z(a,s,r):(a,s)=>-z(a,s,r)}function Ce(e,r){const a=e.map((s,o)=>[s,o]);return a.sort((s,o)=>{const d=r(s[0],o[0]);return d!==0?d:s[1]-o[1]}),a.map(s=>s[0])}function M({headCells:e,rows:r,defaultOrderBy:a}){const s=H(),o=he(),{customerId:d}=R(),[m]=t.useState(JSON.parse(a).order??"asc"),[l]=t.useState(JSON.parse(a).orderBy??"name"),g=p=>{s.push(`/${d}/services/surveyservice/${p}/info`)};return t.createElement(y,{container:!0,spacing:4,className:o.grid},Ce(r,we(m,l)).map(p=>t.createElement(y,{item:!0,xs:12,sm:6,lg:4,xl:3,key:p.id},t.createElement(ee,{className:o.service,elevation:1},t.createElement("img",{alt:"Survey Service Icon",className:o.image,src:"/images/survey_icon_transparent.png"}),e.map(c=>{const b=c?.formatter?c?.formatter(p[c.id]):p[c.id];return c.id==="id"?null:c.id==="name"?t.createElement("div",{key:c.id},t.createElement(x,{gutterBottom:!0,variant:"h5",component:"span",className:o.header},b),t.createElement(F,{className:o.divider})):t.createElement("div",{key:c.id},t.createElement(x,{gutterBottom:!0,variant:"body1",component:"span"},c.label,":Â ",t.createElement("b",null,b)))}),t.createElement(F,{className:o.divider}),t.createElement(te,{variant:"contained",color:"primary",className:o.button,onClick:()=>g(p.id)},"OPEN")))))}M.propTypes={headCells:S.array,rows:S.array,defaultOrderBy:S.string};const Pe=O(e=>({card:{width:"100%",marginBottom:e.spacing(2),overflow:"unset"},gridItem:{margin:e.spacing(1)},formControl:{margin:e.spacing(0,1),minWidth:120},popoverFormControl:{margin:e.spacing(0,1.5),minWidth:120,display:"flex"},popoverPaper:{padding:"10px"}})),_=e=>`SmartDialog_${window.location.host}_${e}_SurveyServiceSortOrder`,V={order:"asc",orderBy:"name"},C=e=>{const r=E.utc(e);return r.isValid()?r.format("D.M.YYYY HH:mm"):""},Te=()=>[{id:"name",label:"Service name",align:"left"},{id:"startDate",label:"Start date",align:"left",formatter:C},{id:"endDate",label:"End date",align:"left",formatter:C}],De=()=>{const e=Pe(),{customerId:r}=R(),a=ae(),{services:s}=k(n=>n.surveyservice),{tags:o,tagsLoading:d}=k(n=>n.tagservice),{searchFilterValue:m,statusFilterValue:l}=k(n=>n.session.serviceFilters),[g,p]=t.useState([]),[c,b]=t.useState(null),f=Array.isArray(o)?o:[],h=Te(),P=n=>{n.target.checked?p(i=>i.concat(n.target.value)):p(g.filter(i=>i!==n.target.value))},T=n=>{b(n.currentTarget)},N=()=>{b(null)};let v=t.useMemo(()=>l==="Pending"?s?.filter(n=>n?.serviceState==="Active"&&E(n?.startDate).isAfter(E()))??[]:l==="Active"?s?.filter(n=>n?.serviceState==="Active"&&E(n?.startDate).isBefore(E())&&(E(n?.endDate).isAfter(E())||n?.endDate===null))??[]:l==="Passive"?s?.filter(n=>n?.serviceState==="Passive"||n?.serviceState==="Active"&&E(n?.endDate).isBefore(E()))??[]:s,[s,l]);return g.length>0&&(v=v.filter(n=>n.serviceTags.some(i=>g.includes(i.tag)))),v=t.useMemo(()=>(m?.length>0&&(v=v?.filter?.(n=>n?.name?.toLowerCase()?.includes?.(m.toLowerCase())||C(n.startDate)?.includes?.(m)||C(n.endDate)?.includes?.(m))),v),[v,m]),t.createElement(ge,null,({ServiceViewButtons:n})=>t.createElement(re,{title:"Survey Services"},t.createElement(se.Suspense,{fallback:t.createElement(D,null)},t.createElement(q,{className:e.card,dir:"ltr"},d?t.createElement(D,null):t.createElement(y,{container:!0,direction:"row",justifyContent:"flex-end",alignItems:"center",className:e.toolbar},t.createElement(y,{item:!0,className:e.gridItem},t.createElement(I,{variant:"outlined",className:e.formControl,size:"small"},t.createElement(pe,{searchTerm:m,handleSetSearchTerm:i=>a(L("searchFilterValue",i))}))),t.createElement(y,{item:!0,className:e.gridItem},t.createElement(I,{variant:"outlined",className:e.formControl,size:"small"},t.createElement(ne,{id:"serviceStatusLabel"},"Service status"),t.createElement(ie,{native:!0,onChange:i=>a(L("statusFilterValue",i.target.value)),value:l,label:"Service status"},t.createElement("option",{value:"All"},"All"),t.createElement("option",{value:"Pending"},"Pending"),t.createElement("option",{value:"Active"},"Active"),t.createElement("option",{value:"Passive"},"Passive / Expired")))),t.createElement(y,{item:!0,className:e.gridItem},t.createElement(oe,{value:"left",onClick:T,size:"small"},t.createElement(le,{title:"Service tag filter"},t.createElement(Se,null))),t.createElement(ce,{open:!!c,anchorEl:c,onClose:N,anchorOrigin:{vertical:"bottom",horizontal:"center"},transformOrigin:{vertical:"top",horizontal:"center"},classes:{paper:e.popoverPaper},style:{maxHeight:"500px"}},f?.map(i=>t.createElement(I,{key:i,component:"fieldset",variant:"outlined",className:e.popoverFormControl,size:"small"},t.createElement(de,null,t.createElement(ue,{control:t.createElement(me,{checked:g.includes(i),onChange:u=>P(u),name:i,value:i,style:{padding:"6px"}}),label:i,style:{width:"100%",whiteSpace:"nowrap"}})))))),t.createElement(n,null))),t.createElement(ve,{gridView:()=>t.createElement(M,{headCells:h,rows:v,defaultOrderBy:localStorage.getItem(_(r))??JSON.stringify(V)}),listView:()=>t.createElement(K,{headCells:h,rows:v,defaultOrderBy:localStorage.getItem(_(r))??JSON.stringify(V)})}))))};export{De as default};
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.