1import{q as Je,a2 as Xe,c$ as et,p as ae,bK as Ie,b as tt,R as e,d as Oe,cS as Te,d0 as St,a4 as We,d1 as Ct,bP as ge,r as Ge,cZ as Be,bx as we,d2 as Tt,E as L,U as B,bZ as at,d3 as bt,d4 as Dt,cg as It,bY as nt,c6 as rt,T as j,d5 as lt,b4 as st,b5 as ot,b6 as it,b7 as h,b8 as f,d6 as Ot,A as Q,G as x,N as z,O as w,c9 as ne,b_ as be,cs as De,b0 as wt,d7 as He,bG as A,a5 as T,d8 as Nt,i as ct,j as mt,k as ut,n as dt,o as gt,m as Rt,y as b,d9 as se,ai as te,da as oe,db as Ue,dc as kt,be as Fe,M as ie,dd as Le,de as Mt,df as ye,dg as Yt,dh as At,di as Pt,dj as xt,dk as Bt,w as $t,dl as Wt,P as Gt,dm as qt,aA as Ve,z as $e,aC as Ht}from"./index-CpcUj6vn.js";import{O as Ut}from"./DescriptionOutlined-BItYoAWk.js";import{S as _e}from"./ServiceTags-__zOVFbb.js";import{A as je}from"./AdminAction-DPSBG5Fm.js";import{W as Ft}from"./ResourceAccessControl-BuAkXQTs.js";import{u as ft}from"./useCodeServiceSelect-CrjyuOPs.js";import{P as Lt}from"./PinAsFavouriteService-TqJby03k.js";import{D as vt}from"./DefaultSenderTextField-kQ0FG8GZ.js";import{O as Vt}from"./index-h9mpbqWH.js";import{S as _t}from"./index-CPEdw4CR.js";import{D as jt}from"./DonutLargeRounded-Bfj4fTw3.js";import{N as zt}from"./NestedIntervalDropdown-D7q-iQ0C.js";import{T as Qt}from"./ToggleButtonGroup-BmqFZsME.js";import{T as Se}from"./ToggleButton-CeIAdu7E.js";import{N as ze,a as ce,b as me}from"./index-CXES7HEQ.js";import"./ComboBox-BZcaHpwp.js";import"./AccessGroupTable-CrtG92CC.js";import"./AccessGroupForm-JWkeOl5H.js";import"./ArrowBackRounded-DjrvSj4E.js";import"./userAccess-jX4bU9Up.js";import"./LockRounded-KZJ2DSB0.js";import"./lodash-DqXObOj3.js";import"./lodash-1T78Azbp.js";import"./DatatableCustomPagination-BGD_tESa.js";const Zt=Ie(t=>({lastTableRow:{border:"0"},card:{width:"100%",marginBottom:t.spacing(2),flex:1,display:"flex",flexDirection:"column"},select:{minWidth:"40%"},cardContent:{display:"flex",justifyContent:"center"},serviceTagContainer:{marginBottom:t.spacing(1)},required:{fontWeight:"bold"}})),Kt=()=>{const t=Je(),{error:c,success:D}=Xe(),{showInfo:y}=et(),{messagingAccounts:W}=ae(r=>r.messagingAccounts),{selectedCustomerMessageRetentionDays:o}=ae(r=>r.auth),d=Zt(),v=tt(),[i,R]=e.useState(!1),[l,G]=e.useState({}),[E,q]=e.useState({}),V=ae(r=>r.enums),{customerId:Z,serviceId:N}=Oe(),[k,M]=e.useState(!1),[m,U]=e.useState(!1),{payload:u,error:$,loading:P}=Te({method:"GET",endpoint:`/messaging/services/oneway/${N}`,params:{"include-uncached-properties":!0}});e.useEffect(()=>{u&&(G(u),q(u),U(u?.hiddenContent??!1),v(St(u)))},[u,v]),e.useEffect(()=>{$&&(c("Service not found"),t.replace(`/${Z}/services/onewaymessaging`))},[c,$,Z,t]);const{loading:J,mutate:F}=We(r=>({method:"PUT",endpoint:"/messaging/services/oneway",body:r,headers:{serviceId:r.id}})),{loading:fe,mutate:n}=We(()=>({method:"DELETE",endpoint:`/messaging/services/oneway/${N}`})),O=Ct(l?.serviceModifiedByUserId),re=()=>{R(!0)},X=()=>{G(E),R(!1),v(A(!1))},Ne=async()=>{const r={...l,hiddenContent:m},{error:I,errorMessages:H,status:K}=await F(r);I?c(K===403?"You don´t have access to update this service":H):(D("OneWay service updated successfully"),R(!1),v(A(!1)),v(He(r)),q(r))},le=()=>{M(!0)},Re=async()=>{M(!1);const{error:r,errorMessages:I}=await n();let H=!1;r?c(I):(D("OneWay service deleted successfully"),H=!0),H&&(v(Nt(N)),t.push(`/${Z}/services/onewaymessaging`))},_=r=>{const I={...l,[r.target.name]:r.target.value};G(I),v(A(!0))},ve=r=>{const I={...l,serviceConfiguration:{...l.serviceConfiguration,[r.target.name]:r.target.value}};G(I),v(A(!0))},Ee=r=>{const I={...l,serviceConfiguration:{...l.serviceConfiguration,[r.target.name]:r.target.checked}};G(I),v(A(!0))},ke=r=>{const I={...l,startDate:r._d};G(I),v(A(!0))},Me=r=>{const I={...l,endDate:r};G(I),v(A(!0))},he=r=>V?.serviceState?.[r]??r,ee=r=>{const I=T.utc(r).local();return I.isValid()?I.format("D.M.YYYY HH:mm"):""},Ye=r=>{r.target.value.length<3&&c("Default sender value must be at least 3 characters.")},Ae=r=>{const I={...l,serviceTags:[...r]};v(He(I))},{loading:pe,CodeServiceSelect:Pe}=ft(),xe=e.useMemo(()=>l?.messageRetentionDays?`${l?.messageRetentionDays} days`:o?`${o} days`:"365 days",[l.messageRetentionDays,o]);return P||J||fe||pe?e.createElement(ge,null):e.createElement(Ge.Suspense,{fallback:e.createElement(ge,null)},e.createElement("div",{className:d.serviceTagContainer},e.createElement(je,{resourceId:N,productType:Be,actionAvailable:e.createElement(_e,{serviceTags:l?.serviceTags,onTagsUpdated:Ae}),actionUnavailable:e.createElement(_e,{disabled:!0,serviceTags:l?.serviceTags})})),e.createElement(we,{className:d.card},e.createElement(Tt,{avatar:e.createElement(j,{variant:"h5"},"General"),action:e.createElement(e.Fragment,null,e.createElement(L,{"aria-label":"info",onClick:y},e.createElement(B,{title:"Info"},e.createElement(at,null))),e.createElement(Lt,{settings:{serviceType:"onewaymessaging",serviceId:N}}),e.createElement(L,{"aria-label":"info",component:bt,href:"https://openapi.arena.fi/1-way/modern-openapi"},e.createElement(B,{title:"OpenApi Portal"},e.createElement(Ut,null))),e.createElement(Ft,{resourceId:N,productType:Be}),e.createElement(je,{resourceId:N,productType:Be,actionAvailable:e.createElement(e.Fragment,null,i===!1&&e.createElement(e.Fragment,null,e.createElement(L,{"aria-label":"delete",onClick:le},e.createElement(B,{title:"Delete service"},e.createElement(Dt,null))),e.createElement(L,{"aria-label":"edit",onClick:re},e.createElement(B,{title:"Edit service"},e.createElement(It,null)))),i===!0&&e.createElement(e.Fragment,null,e.createElement(L,{"aria-label":"cancel",onClick:X},e.createElement(B,{title:"Cancel"},e.createElement(nt,null))),e.createElement(L,{"aria-label":"save",onClick:Ne},e.createElement(B,{title:"Save changes"},e.createElement(rt,null)))))}))}),e.createElement(lt,{className:d.cardContent},e.createElement(st,{style:{flexGrow:1}},e.createElement(ot,{xs:6,sm:3},e.createElement("colgroup",null,e.createElement("col",{width:"30%"}),e.createElement("col",{width:"70%"})),e.createElement(it,null,e.createElement(h,null,e.createElement(f,{align:"left"},"Service id"),e.createElement(f,{align:"left"},e.createElement(Ot,{text:N},N))),e.createElement(h,null,e.createElement(f,{align:"left",className:i&&d.required},"Service name (*)"),e.createElement(f,{align:"left"},i?e.createElement(Q,{name:"name",onBlur:_,defaultValue:l?.name,className:d.select}):l?.name)),e.createElement(h,null,e.createElement(f,{align:"left"},"Service state"),e.createElement(f,{align:"left"},i?e.createElement(x,{className:d.formControl},e.createElement(z,{id:"state-select",value:l?.serviceState,onChange:_,name:"serviceState"},e.createElement(w,{value:"Active"},"Active"),e.createElement(w,{value:"Passive"},"Passive"))):e.createElement(e.Fragment,null,he(l?.serviceState)))),e.createElement(h,null,e.createElement(f,{align:"left"},"Messaging account"),e.createElement(f,{align:"left"},W.find(r=>r.id===l?.messagingAccountId)?.name??"")),e.createElement(h,null,e.createElement(f,{align:"left",className:i&&d.required},"Default sender (*)"),e.createElement(f,{align:"left"},i?e.createElement(vt,{name:"defaultSender",defaultValue:l?.defaultSender,className:d.select,helperText:"Long- or shortcode or Alphanumeric string (3-11 chars, no special characters)",onBlur:r=>{_(r),Ye(r)}}):l?.defaultSender)),e.createElement(h,null,e.createElement(f,{align:"left",className:i&&d.required},"Start date (*)"),e.createElement(f,{align:"left"},i?e.createElement(ne,{autoOk:!0,hideTabs:!0,ampm:!1,value:l?.startDate,onChange:ke,n
1ame:"startDate",format:"D.M.YYYY HH.mm"}):e.createElement(e.Fragment,null,ee(l?.startDate)))),e.createElement(h,null,e.createElement(f,{align:"left"},"End date"),e.createElement(f,{align:"left"},i?e.createElement(ne,{autoOk:!0,hideTabs:!0,clearable:!0,ampm:!1,value:l?.endDate,onChange:Me,name:"endDate",format:"D.M.YYYY HH.mm"}):e.createElement(e.Fragment,null,ee(l?.endDate)))),e.createElement(h,null,e.createElement(f,{align:"left"},"Modified date"),e.createElement(f,{align:"left"},ee(l?.serviceModified??""))),O&&e.createElement(h,null,e.createElement(f,{align:"left"},"Modified by"),e.createElement(f,{align:"left"},O)),e.createElement(h,null,e.createElement(f,{align:"left"},"Dlr url"),e.createElement(f,{align:"left"},i?e.createElement(Q,{name:"dlrUrl",onBlur:_,defaultValue:l?.dlrUrl,className:d.select}):l?.dlrUrl)),e.createElement(Pe,{displayOnly:!i,name:"rCodeServiceId",value:l?.rCodeServiceId??"",onChange:_}),e.createElement(h,null,e.createElement(f,{align:"left"},"Client id"),e.createElement(f,{align:"left"},i?e.createElement(Q,{name:"clientId",onBlur:ve,defaultValue:l?.serviceConfiguration?.clientId,className:d.select,helperText:"Client id must be unique across the Messaging Account"}):l?.serviceConfiguration?.clientId)),e.createElement(h,{style:{display:"none"}},e.createElement(f,{align:"left"},"Allow priority messages:"),e.createElement(f,{align:"left"},l?.serviceConfiguration?.allowPriorityMessages?e.createElement(e.Fragment,null,"Yes"):e.createElement(e.Fragment,null,"No"))),e.createElement(h,null,e.createElement(f,{align:"left"},"Force ad messages"),e.createElement(f,{align:"left"},i&&e.createElement(be,{control:e.createElement(De,{checked:l?.serviceConfiguration?.adMessage,onChange:Ee,name:"adMessage",color:"primary"})}),!i&&`${l?.serviceConfiguration?.adMessage?"Yes":"No"}`)),e.createElement(h,null,e.createElement(f,{align:"left"},"Message retention days"),e.createElement(f,{align:"left"},i&&e.createElement(Q,{name:"messageRetentionDays",defaultValue:l?.messageRetentionDays,className:d.select,placeholder:`${o||"365"}`,helperText:`Must be greater than or equal to 90 days. If not set, default value is ${o||"365"} days.`,onBlur:r=>{_(r)}}),!i&&xe)),e.createElement(h,{className:d.lastTableRow},e.createElement(f,{align:"left"},"Hidden content"),e.createElement(f,{align:"left"},i&&e.createElement(be,{control:e.createElement(De,{checked:m,disabled:E?.hiddenContent,onChange:()=>U(!m),name:"hiddenContent",color:"primary"})}),!i&&`${m?"Yes":"No"}`))))))),e.createElement(wt,{title:"Delete service?",open:k,onConfirm:Re,onCancel:()=>M(!1)},e.createElement(j,{variant:"body1"},"Do you really want to delete this service?")))};var ue={},Qe;function Jt(){if(Qe)return ue;Qe=1;var t=ct(),c=mt();Object.defineProperty(ue,"__esModule",{value:!0}),ue.default=void 0;var D=c(ut()),y=t(dt()),W=(0,y.default)(D.createElement("path",{d:"M11 3.18v17.64c0 .64-.59 1.12-1.21.98C5.32 20.8 2 16.79 2 12s3.32-8.8 7.79-9.8c.62-.14 1.21.34 1.21.98zm2.03 0v6.81c0 .55.45 1 1 1h6.79c.64 0 1.12-.59.98-1.22-.85-3.76-3.8-6.72-7.55-7.57-.63-.14-1.22.34-1.22.98zm0 10.83v6.81c0 .64.59 1.12 1.22.98 3.76-.85 6.71-3.82 7.56-7.58.14-.62-.35-1.22-.98-1.22h-6.79c-.56.01-1.01.46-1.01 1.01z"}),"PieChartRounded");return ue.default=W,ue}var Xt=Jt();const ea=gt(Xt);var de={},Ze;function ta(){if(Ze)return de;Ze=1;var t=ct(),c=mt();Object.defineProperty(de,"__esModule",{value:!0}),de.default=void 0;var D=c(ut()),y=t(dt()),W=(0,y.default)(D.createElement("path",{d:"M20 4H4c-1.11 0-1.99.89-1.99 2L2 18c0 1.11.89 2 2 2h16c1.11 0 2-.89 2-2V6c0-1.11-.89-2-2-2zm-1 14H5c-.55 0-1-.45-1-1v-5h16v5c0 .55-.45 1-1 1zm1-10H4V7c0-.55.45-1 1-1h14c.55 0 1 .45 1 1v1z"}),"PaymentRounded");return de.default=W,de}var aa=ta();const na=gt(aa),ra=Rt(t=>({chartContainer:{marginBottom:t.spacing(5),display:"flex",flexDirection:"column",justifyContent:"center",width:"100%"},chartCard:{boxShadow:"none"},chart:{marginTop:t.spacing(5),width:"80vw",maxWidth:"450px"},gridItem:{marginBottom:t.spacing(5)}}));function Et({dataToday:t,dataThisWeek:c,dataThisMonth:D,dataThisQuarter:y,dataThisYear:W,showBy:o}){const d=ra();return e.createElement(we,{className:d.chartCard},e.createElement(lt,{className:d.content},e.createElement(b,{container:!0,item:!0,xs:12,justifyContent:"space-around",alignItems:"center",className:d.filterGrid},e.createElement(b,{item:!0,className:d.gridItem},e.createElement(j,{variant:"h5",align:"center"},"Today"),e.createElement(se,{data:t,className:d.chart,showBy:o})),e.createElement(b,{item:!0,className:d.gridItem},e.createElement(j,{variant:"h5",align:"center"},"This Week"),e.createElement(se,{data:c,className:d.chart,showBy:o})),e.createElement(b,{item:!0,className:d.gridItem},e.createElement(j,{variant:"h5",align:"center"},"This Month"),e.createElement(se,{data:D,className:d.chart,showBy:o})),e.createElement(b,{item:!0,className:d.gridItem},e.createElement(j,{variant:"h5",align:"center"},"This Quarter"),e.createElement(se,{data:y,className:d.chart,showBy:o})),e.createElement(b,{item:!0,className:d.gridItem},e.createElement(j,{variant:"h5",align:"center"},"This Year"),e.createElement(se,{data:W,className:d.chart,showBy:o})))))}Et.propTypes={dataToday:te.array.isRequired,dataThisWeek:te.array.isRequired,dataThisMonth:te.array.isRequired,dataThisQuarter:te.array.isRequired,dataThisYear:te.array.isRequired,showBy:te.string};const p={DOUGHNUT:"DOUGHNUT",OPERATORDOUGHNUT:"OPERATORDOUGHNUT",BAR:"BAR",REPORTINGSTATISTICS:"REPORTINGSTATISTICS"},la=Ie(t=>({card:{width:"100%",flex:1},cardGrid:{height:"100%",display:"flex",flexDirection:"column",flexWrap:"wrap"},divider:{width:"100%",margin:"10px 0"},typeGrid:{width:"100%",flexBasis:"50px",backgroundColor:t.palette.background.gray,color:t.palette.white,"& *":{color:t.palette.white}},filterGrid:{width:"100%",flexBasis:"75px"},chartContainer:{width:"100%",display:"flex",flex:1,overflow:"hidden"},gridItem:{margin:t.spacing(0),padding:t.spacing(0,2)},formControl:{margin:t.spacing(),minWidth:130},button:{marginLeft:t.spacing(1)}})),Ce={year:T.duration(1,"year").add(1,"day"),quarter:T.duration(1,"quarter"),month:T.duration(32,"days"),week:T.duration(1,"week"),day:T.duration(1,"day"),hour:T.duration(1,"hour")},Ke=t=>{let c=[{label:"Per year",value:"year"}];return t<=Ce.year&&(c=[{label:"Per week",value:"week"},{label:"Per month",value:"month"},{label:"Per quarter",value:"quarter"},...c]),t<=Ce.month&&(c=[{label:"Per day",value:"day"},...c]),t<=Ce.day&&(c=[{label:"Per hour",value:"hour"},...c]),t<=Ce.hour&&(c=[{label:"Per minute",value:"minute"},...c]),c};function sa(){const t=la(),[c,D]=e.useState("all"),[y,W]=e.useState("amount"),[o,d]=e.useState(p.DOUGHNUT),[v,i]=e.useState(null),[R,l]=e.useState([]),[G,E]=e.useState([]),[q,V]=e.useState(!1),[Z,N]=e.useState(!1),[k,M]=e.useState({options:[],value:"day"}),[m,U]=e.useState({definedInterval:"thisweek",intervalDescr:"This week",from:T().startOf("week"),to:T()}),[u,$]=e.useState({definedInterval:"thisMonth",from:T().startOf("month"),to:T()}),[P,J]=e.useState({options:[],value:"day"}),{serviceId:F}=Oe(),{services:fe}=ae(a=>
1a.onewaymessaging),n=fe?.find(a=>a.id===F)?.name??"1-Way Service",[O,re]=e.useState({from:m.from.valueOf(),to:m.to.valueOf(),groupBy:k.value}),[X,Ne]=e.useState({from:u.from.valueOf(),to:u.to.valueOf(),groupBy:k.value}),le={method:"GET",endpoint:`/messagepersistence/statistics/oneway/${F}`,params:{...O}},{query:Re,loading:_}=Te(le,!1),ve=e.useCallback(Re,[]);e.useEffect(()=>{let a=!0;const g=async()=>{const{error:s,payload:S}=await ve();a&&i(s?[]:S)};return o===p.DOUGHNUT||o===p.BAR?g():a&&i([]),()=>{a=!1}},[o,ve,O]);const Ee={method:"GET",endpoint:`/messagepersistence/statistics/operators/${F}`,params:{...O}},{query:ke,loading:Me}=Te(Ee,!1),he=e.useCallback(ke,[]);e.useEffect(()=>{let a=!0;const g=async()=>{const{error:s,payload:S}=await he();a&&l(s?[]:S)};return o===p.OPERATORDOUGHNUT?g():a&&l([]),()=>{a=!1}},[o,he,O]);const ee={method:"GET",endpoint:`/messagepersistence/statistics/reporting/oneway/${F}`,params:{...X,from:T(u.from).utc(!0).valueOf(),to:T(u.to).utc(!0).valueOf()}},{query:Ye,loading:Ae}=Te(ee,!1),pe=e.useCallback(Ye,[]);e.useEffect(()=>{let a=!0;const g=async()=>{const{error:s,payload:S}=await pe();a&&E(s?[]:S)};return o===p.REPORTINGSTATISTICS?g():a&&E([]),()=>{a=!1}},[o,pe,u.from,u.to,P.value]),e.useEffect(()=>{let a=!0;const g=T.duration(m.to.diff(m.from)),s=Ke(g);let S={options:s,value:k.value};return s.find(Y=>Y.value===k.value)||(S={options:s,value:s?.[0]?.value}),a&&(M(S),re({from:m.from.valueOf(),to:m.to.valueOf(),groupBy:S.value})),()=>{a=!1}},[m.to,m.from,k.value]),e.useEffect(()=>{let a=!0;const g=T.duration(u.to.diff(u.from)),s=Ke(g);let S={options:s,value:P.value};return s.find(Y=>Y.value===P.value)||(S={options:s,value:s?.[0]?.value}),a&&(J(S),Ne({from:u.from.valueOf(),to:u.to.valueOf(),groupBy:S.value})),()=>{a=!1}},[u.to,u.from,P.value]);const Pe=oe(v,y,"day"),xe=oe(v,y,"week"),qe=oe(v,y,"month"),r=oe(v,y,"quarter"),I=oe(v,y,"year"),H=e.useMemo(()=>Ue(v)(a=>a?.averages?.averageLength),[v]),K=e.useMemo(()=>Ue(v)(a=>a?.averages?.averageSendTime),[v]),ht=a=>{const g=a;let s=T(),S=T(),Y="";g==="lastmonth"?(s=s.subtract(1,"months").startOf("month"),S=S.subtract(1,"months").endOf("month"),Y="Last month"):g==="lastweek"?(s=s.subtract(1,"weeks").startOf("weeks"),S=S.subtract(1,"weeks").endOf("weeks"),Y="Last week"):g==="lasthour"?(s=s.subtract(1,"hours"),Y="Last hour"):g==="today"?(s=s.startOf("day"),Y="Today"):g==="thisweek"?(s=s.startOf("week"),Y="This week"):g==="thismonth"?(s=s.startOf("month"),Y="This month"):g==="thisquarter"?(s=s.startOf("quarter"),Y="This quarter"):g==="thisyear"||g==="all"?(s=s.startOf("year"),Y="This year"):g==="custom"&&(s=m.from,S=m.to,Y="Custom"),U({...m,definedInterval:g,intervalDescr:Y,from:s,to:S})},pt=(a,g,s)=>{U({...m,definedInterval:"custom",intervalDescr:s,from:a,to:g})},yt=a=>{const g=a.target.value,s=T(),S=T();switch(g){case"thisMonth":$({...u,definedInterval:g,from:s.startOf("month"),to:S});break;case"lastMonth":$({...u,definedInterval:g,from:s.subtract(1,"month").startOf("month"),to:S.subtract(1,"month").endOf("month")});break;case"thisYear":$({...u,definedInterval:g,from:s.startOf("year"),to:S});break;case"customYear":$({...u,definedInterval:g}),V(!0);break;case"customMonth":$({...u,definedInterval:g}),N(!0);break}};return e.createElement(Ge.Suspense,{fallback:e.createElement(ge,null)},e.createElement(we,{className:t.card},e.createElement("div",{className:t.cardGrid},e.createElement("div",{className:t.typeGrid},e.createElement(b,{container:!0,item:!0,xs:12,alignItems:"center"},e.createElement(b,{container:!0,item:!0,xs:6,justifyContent:"flex-start",className:t.gridItem},e.createElement(j,{variant:"h5"},o===p.REPORTINGSTATISTICS?"Billable Outbound messages":"Outbound messages")),e.createElement(b,{container:!0,item:!0,xs:6,justifyContent:"flex-end",className:t.gridItem},e.createElement(Qt,{value:o,exclusive:!0},e.createElement(Se,{value:p.DOUGHNUT,onClick:()=>d(p.DOUGHNUT)},e.createElement(B,{title:"Show doughnut chart"},e.createElement(jt,null))),e.createElement(Se,{value:p.OPERATORDOUGHNUT,onClick:()=>d(p.OPERATORDOUGHNUT)},e.createElement(B,{title:"Show operator doughnut chart"},e.createElement(ea,null))),e.createElement(Se,{value:p.BAR,onClick:()=>d(p.BAR)},e.createElement(B,{title:"Show bar chart"},e.createElement(kt,null))),e.createElement(Se,{value:p.REPORTINGSTATISTICS,onClick:()=>d(p.REPORTINGSTATISTICS)},e.createElement(B,{title:"Show reporting statistics chart"},e.createElement(na,null))))))),e.createElement("div",{className:t.divider},e.createElement(Fe,null)),e.createElement("div",{className:t.filterGrid},e.createElement(b,{container:!0,item:!0,xs:12,justifyContent:"center",alignItems:"center"},o!==p.REPORTINGSTATISTICS&&e.createElement(e.Fragment,null,e.createElement(b,null,e.createElement(x,{variant:"outlined",className:t.formControl},e.createElement(zt,{variant:"outlined",interval:m,handleIntervalChange:ht,handleSetPrevMonth:pt}))),e.createElement(b,{item:!0,className:t.gridItem},e.createElement(x,{variant:"outlined",className:t.formControl},e.createElement(ne,{autoOk:!0,hideTabs:!0,ampm:!1,value:m.from,onChange:a=>U({...m,definedInterval:"custom",intervalDescr:"Custom",from:a}),name:"from",label:"From date",format:"D.M.YYYY HH.mm",inputVariant:"outlined"}))),e.createElement(b,{item:!0,className:t.gridItem},e.createElement(x,{variant:"outlined",className:t.formControl},e.createElement(ne,{autoOk:!0,hideTabs:!0,ampm:!1,value:m.to,onChange:a=>U({...m,definedInterval:"custom",intervalDescr:"Custom",to:a}),name:"to",label:"To date",format:"D.M.YYYY HH.mm",inputVariant:"outlined"})))),o===p.REPORTINGSTATISTICS&&e.createElement(e.Fragment,null,e.createElement(b,{item:!0,className:t.gridItem},e.createElement(x,{variant:"outlined",className:t.formControl},e.createElement(ie,{id:"time-period-label"},"Time period"),e.createElement(z,{labelId:"time-period-label",defaultValue:"thisMonth",value:u.definedInterval,onChange:yt,label:"Time period"},e.createElement(w,{value:"thisMonth"},"This month"),e.createElement(w,{value:"lastMonth"},"Last month"),e.createElement(w,{value:"thisYear"},"This year"),e.createElement(w,{value:"customYear"},e.createElement("em",null,"Custom year...")),e.createElement(w,{value:"customMonth"},e.createElement("em",null,"Custom month..."))))),u.definedInterval==="customYear"&&e.createElement(b,{item:!0,className:t.gridItem},e.createElement(x,{variant:"outlined",className:t.formControl},e.createElement(Le,{open:q,views:["year"],autoOk:!0,hideTabs:!0,value:u.from,inputProps:{onClick:()=>V(!0)},onClose:()=>V(!1),onChange:a=>{const g=T(a).startOf("year"),s=T(a).endOf("year");$({...u,definedInterval:"customYear",from:g,to:s}),V(!1)},minDate:new Date(2019,0),maxDate:new Date,label:"Custom Year",format:"YYYY",inputVariant:"outlined"}))),u.definedInterval==="customMonth"&&e.createElement(b,{item:!0,className:t.gridItem},e.createElement(x,{variant:"outlined",className:t.formControl},e.createElement(Le,{open:Z,views:["year","month"],autoOk:!0,hideTabs:!0,value:u.from,inputProps:{onClick:()=>N(!0)},onClose:()=>N(!1),onChange:a=>{const g=T(a).startOf("month"),s=T(a).endOf("month");$({...u,definedInterval:"customMonth",from:g,to:s}),N(!1)},minDate:new Date(2019,0),maxDate:new Date,openTo:"month",label:"Custom Month",format:"MMM-YYYY",inputVariant:"outlined"}))),e.createElement(b,{item:!0,className:t.gridItem},e.createElement(x,{variant:"outlined",className:t.formControl},e.createElement(ie,{id:"group-by-label"},"Group by"),e.createElement(z,{labelId:"group-by-label",value:P.value,onChange:a=>J({...P,value:a.target.value}),label:"Group by"},P?.options?.map(a=>e.createElement(w,{key:a.value,value:a.value},a.label)))))),o===p.BAR&&e.createElement(b,{item:!0,className:t.gridItem},e.createElement(x,{variant:"outlined",className:t.formControl},e.createElement(ie,{id:"group-by-label"},"Group by"),e.createElement(z,{labelId:"group-by-label",id:"group-by-select",value:k.value,onChange:a=>M({...k,value:a.target.value}),label:"Group by"},k?.options?.map(a=>e.createElement(w,{key:a.value,value:a.value},a.label))))),o===p.BAR&&e.createElement(b,{item:!0,className:t.gridItem},e.createElement(x,{variant:"outlined",className:t.formControl},e.createElement(ie,{id:"status-label"},"Status filter"),e.createElement(z,{labelId:"status-label",id:"status-select",defaultValue:"all",onChange:a=>D(a.target.value),label:"Status filter"},e.createElement(w,{value:"all"},e.createElement("em",null,"All")),e.createElement(w,{value:"pending"},"Pending"),e.createElement(w,{value:"delivered"},"Delivered"),e.createElement(w,{value:"failed"},"Failed")))),(o===p.BAR||o===p.DOUGHNUT||o===p.OPERATORDOUGHNUT)&&e.createElement(b,{item:!0,className:t.gridItem},e.createElement(x,{variant:"outlined",className:t.formControl},e.createElement(ie,{id:"visualization-label"},"Show by"),e.createElement(z,{labelId:"visualization-label",id:"visualization-select",defaultValue:"amount",value:y,onChange:a=>W(a.target.value),label:"Show by"},e.createElement(w,{value:"amount"},"Amount"),e.createElement(w,{value:"percentage"},"Percentage")))))),e.createElement("div",{className:t.divider},e.createElement(Fe,null)),e.createElement("div",{className:t.chartContainer},v&&e.createElement(Mt,{loading:_||Me||Ae},o===p.DOUGHNUT&&m.definedInterval==="all"&&e.createElement(Et,{dataToday:Pe,dataThisWeek:xe,dataThisMonth:qe,dataThisQuarter:r,dataThisYear:I,showBy:y}),o===p.DOUGHNUT&&m.definedInterval!=="all"&&e.createElement(ye,{component:"MessageStatisticsDoughnutWidget",settings:{title:"1-Way Outbound Messages",serviceName:n,visualization:y,requestSettings:le,interval:m,chips:[`Service name: ${n}`,`Average delivery time: ${K?.toFixed(1)}ms`,`Average length: ${H?.toFixed(1)}`]}},e.createElement(Yt,{data:v,chips:[`Service name: ${n}`,`From: ${m.from?.format("DD.MM.YYYY HH:mm")}`,`To: ${m.to?.format("DD.MM.YYYY HH:mm")}`,`Average delivery time: ${K?.toFixed(1)}ms`,`Average length: ${H?.toFixed(1)}`],showBy:y})),o===p.BAR&&e.createElement(ye,{component:"MessageStatisticsBarWidget",settings:{title:"1-Way Outbound Messages",serviceName:n,visualization:y,requestSettings:le,interval:m,groupBy:k.value,statusFilter:c,chips:[`Service name: ${n}`,`Average delivery time: ${K?.toFixed(1)}ms`,`Average length: ${H?.toFixed(1)}`]}},e.createElement(At,{data:v,chips:[`Service name: ${n}`,`From: ${m.from?.format("DD.MM.YYYY HH:mm")}`,`To: ${m.to?.format("DD.MM.YYYY HH:mm")}`,`Average delivery time: ${K?.toFixed(1)}ms`,`Average length: ${H?.toFixed(1)}`],groupBy:k.value,showBy:y,statusFilter:c})),o===p.OPERATORDOUGHNUT&&e.createElement(ye,{component:"MessageStatisticsOperatorDoughnutWidget",settings:{title:"1-Way Outbound Messages By Operator",serviceName:n,visualization:y,requestSettings:Ee,interval:m,chips:[`Service name: ${n}`,`Average delivery time: ${K?.toFixed(1)}ms`,`Average length: ${H?.toFixed(1)}`]}},e.createElement(Pt,{data:R,chips:[`Service name: ${n}`,`From: ${m.from?.format("DD.MM.YYYY")}`,`To: ${m.to?.format("DD.MM.YYYY")}`],serviceId:F,interval:m,showBy:y})),o===p.REPORTINGSTATISTICS&&e.createElement(ye,{component:"MessageStatisticsReportingBarWidget",settings:{title:"1-Way Billable Outbound Messages",serviceName:n,visualization:y,requestSettings:ee,groupBy:P.value,interval:u,chips:[`Service name: ${n}`]}},e.createElement(xt,{data:G,chips:[`Service name: ${n}`,`From: ${u.from?.format("DD.MM.YYYY HH:mm")}`,`To: ${u.to?.format("DD.MM.YYYY HH:mm")}`],groupBy:P.value,showBy:y})))))))}const C=$t({root:{borderBottom:"none"}})(f),oa=Ie(t=>({lastTableRow:{border:"0"},card:{width:"100%",marginBottom:t.spacing(2)},select:{minWidth:"40%"},required:{fontWeight:"bold"}}));function ia(){const t=Je(),{customerId:c}=Oe(),{error:D,success:y}=Xe(),{showInfo:W}=et(),{messagingAccounts:o}=ae(n=>n.messagingAccounts),d=Bt(),{selectedCustomerMessageRetentionDays:v}=ae(n=>n.auth),i=oa(),R=tt(),[l,G]=e.useState(!1),[E,q]=e.useState({serviceState:"Active",startDate:new Date,endD
1ate:null,dlrUrl:"",codeServiceId:"",customerId:c,defaultSender:d,name:"",messagingAccountId:"",serviceConfiguration:{clientId:"",allowPriorityMessages:!1,adMessage:!1}});e.useEffect(()=>{o&&o.length>0&&q(n=>({...n,messagingAccountId:o[0]?.id??null}))},[o]);const{loading:V,mutate:Z}=We(n=>({method:"POST",endpoint:"/messaging/services/oneway",body:n})),N=async()=>{const{error:n,errorMessages:O,status:re}=await Z({...E,hiddenContent:l});let X=!1;n?D(re===403?"You don´t have access to create a service":O):(y("OneWay service created successfully"),R(Wt()),X=!0),X&&(R(A(!1)),t.push(`/${c}/services/onewaymessaging`))},k=()=>{t.push(`/${c}/services/onewaymessaging`),R(A(!1))},M=n=>{const O={...E,[n.target.name]:n.target.value};q(O),R(A(!0))},m=n=>{const O={...E,serviceConfiguration:{...E.serviceConfiguration,[n.target.name]:n.target.value}};q(O),R(A(!0))},U=n=>{const O={...E,serviceConfiguration:{...E.serviceConfiguration,[n.target.name]:n.target.checked}};q(O),R(A(!0))},u=n=>{const O={...E,startDate:n._d};q(O),R(A(!0))},$=n=>{const O={...E,endDate:n};q(O),R(A(!0))},P=n=>{n.target.value.length<3&&D("Default sender value must be at least 3 characters.")},{loading:J,CodeServiceSelect:F}=ft();return V||J?e.createElement(ge,null):e.createElement(Ge.Suspense,{fallback:e.createElement(ge,null)},e.createElement(we,{className:i.card},e.createElement(b,{container:!0,direction:"row",justifyContent:"flex-end",alignItems:"center",className:i.toolbar},e.createElement(b,{item:!0,className:i.gridItem},e.createElement(L,{"aria-label":"info",onClick:W},e.createElement(B,{title:"Info"},e.createElement(at,null))),e.createElement(L,{"aria-label":"cancel",onClick:k},e.createElement(B,{title:"Cancel"},e.createElement(nt,null))),e.createElement(L,{"aria-label":"save",onClick:N},e.createElement(B,{title:"Save service"},e.createElement(rt,null))))),e.createElement(st,null,e.createElement(ot,{xs:6,sm:3},e.createElement("colgroup",null,e.createElement("col",{width:"20%"}),e.createElement("col",{width:"80%"})),e.createElement(it,null,e.createElement(h,{key:"name"},e.createElement(C,{align:"left",className:i.required},"Service name (*)"),e.createElement(C,{align:"left"},e.createElement(Q,{name:"name",onBlur:M,defaultValue:E?.name,className:i.select}))),e.createElement(h,{key:"servicestate"},e.createElement(C,{align:"left"},"Service state"),e.createElement(C,{align:"left"},e.createElement(x,{className:i.formControl},e.createElement(z,{id:"state-select",value:E?.serviceState,onChange:M,name:"serviceState"},e.createElement(w,{value:"Active"},"Active"),e.createElement(w,{value:"Passive"},"Passive"))))),e.createElement(h,{key:"messagingaccount"},e.createElement(C,{align:"left"},"Messaging account"),e.createElement(C,{align:"left"},e.createElement(x,{className:i.formControl},e.createElement(z,{id:"messaging-account-select",onChange:M,name:"messagingAccountId",value:E?.messagingAccountId},o?.map(n=>e.createElement(w,{key:n.id,value:n.id},n.name)))))),e.createElement(h,{key:"defaultsender"},e.createElement(C,{align:"left",className:i.required},"Default sender (*)"),e.createElement(C,{align:"left"},e.createElement(vt,{name:"defaultSender",defaultValue:E?.defaultSender,className:i.select,helperText:"Long- or shortcode or Alphanumeric string (3-11 chars, no special characters)",onBlur:n=>{M(n),P(n)}}))),e.createElement(h,{key:"startdate"},e.createElement(C,{align:"left",className:i.required},"Start date (*)"),e.createElement(C,{align:"left"},e.createElement(ne,{autoOk:!0,hideTabs:!0,ampm:!1,value:E?.startDate,onChange:u,name:"startDate",format:"D.M.YYYY HH.mm"}))),e.createElement(h,{key:"enddate"},e.createElement(C,{align:"left"},"End date"),e.createElement(C,{align:"left"},e.createElement(ne,{autoOk:!0,hideTabs:!0,clearable:!0,ampm:!1,value:E?.endDate,onChange:$,name:"endDate",format:"D.M.YYYY HH.mm"}))),e.createElement(h,{key:"dlrurl"},e.createElement(C,{align:"left"},"Dlr url"),e.createElement(C,{align:"left"},e.createElement(Q,{name:"dlrUrl",onBlur:M,defaultValue:E?.dlrUrl,className:i.select}))),e.createElement(F,{name:"rCodeServiceId",value:E?.rCodeServiceId??"",onChange:M}),e.createElement(h,{key:"clientid"},e.createElement(C,{align:"left"},"Client id"),e.createElement(C,{align:"left"},e.createElement(Q,{name:"clientId",onBlur:m,defaultValue:E?.serviceConfiguration?.clientId,className:i.select,helperText:"Client id must be unique across the Messaging Account"}))),e.createElement(h,{key:"messageretentiondays"},e.createElement(C,{align:"left"},"Message retention days"),e.createElement(C,{align:"left"},e.createElement(Q,{name:"messageRetentionDays",defaultValue:E?.messageRetentionDays,className:i.select,placeholder:`${v||"365"}`,helperText:`Must be greater than or equal to 90 days. If not set, default value is ${v||"365"} days.`,onBlur:n=>{M(n)}}))),e.createElement(h,{key:"allowprioritymessages",style:{display:"none"}},e.createElement(C,{align:"left"},"Allow priority messages"),e.createElement(C,{align:"left"},E?.serviceConfiguration?.allowPriorityMessages?e.createElement(e.Fragment,null,"Yes"):e.createElement(e.Fragment,null,"No"))),e.createElement(h,{key:"admessages"},e.createElement(C,{align:"left"},"Force ad messages"),e.createElement(C,{align:"left"},e.createElement(be,{control:e.createElement(De,{checked:E?.serviceConfiguration?.adMessage,onChange:U,name:"adMessage",color:"primary"})}))),e.createElement(h,{className:i.lastTableRow},e.createElement(C,{align:"left"},"Hidden content"),e.createElement(C,{align:"left"},e.createElement(be,{control:e.createElement(De,{checked:l,disabled:E?.hiddenContent,onChange:()=>G(!l),name:"hiddenContent",color:"primary"})}))))))))}const ca=Ie(()=>({root:{flex:1,display:"flex",flexDirection:"column"},appBar:{backgroundColor:"#fff"}})),Pa=()=>{const t=ca(),{customerId:c,serviceId:D}
1=Oe();return e.createElement(Gt,{className:t.root,title:"1-Way Messaging Service"},e.createElement(e.Fragment,null,e.createElement(qt,{position:"static",color:"default",elevation:0,className:t.appBar,variant:"outlined"},e.createElement(Ve,null,e.createElement($e,{exact:!0,path:"/:customerId/services/onewaymessaging/new"},e.createElement(ze,null,e.createElement(ce,{label:"Service Info",value:`/${c}/services/onewaymessaging/new`}))),e.createElement($e,null,e.createElement(ze,null,e.createElement(ce,{label:"Service Info",value:`/${c}/services/onewaymessaging/${D}/info`}),e.createElement(ce,{label:"Message Events",value:`/${c}/services/onewaymessaging/${D}/events`}),e.createElement(ce,{label:"Messaging Errors",value:`/${c}/services/onewaymessaging/${D}/errors`}),e.createElement(ce,{label:"Statistics",value:`/${c}/services/onewaymessaging/${D}/statistics`}))))),e.createElement(Ve,null,e.createElement(me,{path:"/:customerId/services/onewaymessaging/new"},e.createElement(ia,null)),e.createElement($e,{exact:!0,path:"/:customerId/services/onewaymessaging/:serviceId"},e.createElement(Ht,{replace:!0,to:`/${c}/services/onewaymessaging/${D}/info`})),e.createElement(me,{path:"/:customerId/services/onewaymessaging/:serviceId/info"},e.createElement(Kt,null)),e.createElement(me,{path:"/:customerId/services/onewaymessaging/:serviceId/events"},e.createElement(Vt,{serviceId:D,persistedFiltersTableId:"onewayMessageEvents"})),e.createElement(me,{path:"/:customerId/services/onewaymessaging/:serviceId/errors"},e.createElement(_t,{serviceType:"OneWay"})),e.createElement(me,{path:"/:customerId/services/onewaymessaging/:serviceId/statistics"},e.createElement(sa,null)))))};export{Pa 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.