"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[24167],{33783:function(e,n,t){t.r(n),t.d(n,{default:function(){return C}});var r=t(62540),a=t(65242),i=t(69410),o=t(5898),c=t(63696),l=t(40532),s=t(51137),u=t(61586),f="ApiKeys",p=function(){var e=(0,i.gf)().api;return(0,u.I)({queryKey:[f],queryFn:function(){return function(e){return n=void 0,t=void 0,a=function(){return function(e,n){var t,r,a,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=c(0),o.throw=c(1),o.return=c(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(c){return function(l){return function(c){if(t)throw new TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(i=0)),i;)try{if(t=1,r&&(a=2&c[0]?r.return:c[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,c[1])).done)return a;switch(r=0,a&&(c=[2&c[0],a.value]),c[0]){case 0:case 1:a=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!((a=(a=i.trys).length>0&&a[a.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!a||c[1]>a[0]&&c[1]<a[3])){i.label=c[1];break}if(6===c[0]&&i.label<a[1]){i.label=a[1],a=c;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(c);break}a[2]&&i.ops.pop(),i.trys.pop();continue}c=n.call(e,i)}catch(e){c=[6,e],r=0}finally{t=a=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,l])}}}(this,(function(n){switch(n.label){case 0:return e?[4,(0,s._)(e).getKeys()]:(console.error("[useApiKeys] Failed to create Api instance"),[2]);case 1:return[2,n.sent().data]}}))},new((r=void 0)||(r=Promise))((function(e,i){function o(e){try{l(a.next(e))}catch(e){i(e)}}function c(e){try{l(a.throw(e))}catch(e){i(e)}}function l(n){var t;n.done?e(n.value):(t=n.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,c)}l((a=a.apply(n,t||[])).next())}));var n,t,r,a}(e)},enabled:!!e})},d=t(38596),y=t(53678),A=t(5271),h=t(77890),m=t(34907),b=t(58765),v=t(20541),x=t(99851),k=t(51602),g=t(98320),w=t(16638),K=t(86074),C=function(){var e=(0,i.gf)().api,n=p(),u=n.data,C=n.isLoading,j=function(){var e=(0,i.gf)().api;return(0,d.n)({mutationFn:function(n){return(0,s._)(e).revokeKey(n)},onSuccess:function(){y.q.invalidateQueries({queryKey:[f]})}})}(),H=function(){var e=(0,i.gf)().api;return(0,d.n)({mutationFn:function(n){return(0,s._)(e).createKey(n)},onSuccess:function(){y.q.invalidateQueries({queryKey:[f]})}})}(),N=(0,c.useMemo)((function(){return[{id:"ApiKey",accessorKey:"AccessToken",header:o.Ay.translate("HeaderApiKey"),size:300},{id:"AppName",accessorKey:"AppName",header:o.Ay.translate("HeaderApp")},{id:"DateIssued",accessorFn:function(e){return(0,g.mk)(e.DateCreated)},Cell:function(e){var n=e.cell;return(0,g.hJ)(n.getValue())+" "+(0,g.OB)(n.getValue())},header:o.Ay.translate("HeaderDateIssued"),filterVariant:"datetime-range"}]}),[]),T=(0,k.Up)({columns:N,data:(null==u?void 0:u.Items)||[],state:{isLoading:C},rowCount:(null==u?void 0:u.TotalRecordCount)||0,enableColumnPinning:!0,enableColumnResizing:!0,enableStickyFooter:!0,enableStickyHeader:!0,muiTableContainerProps:{sx:{maxHeight:"calc(100% - 7rem)"}},enableRowActions:!0,positionActionsColumn:"last",displayColumnDefOptions:{"mrt-row-actions":{header:"",size:25}},renderTopToolbarCustomActions:function(){return(0,r.jsxs)(h.A,{onClick:q,children:[(0,r.jsx)(K.A,{}),o.Ay.translate("HeaderNewApiKey")]})},renderRowActions:function(e){var n=e.row;return(0,r.jsx)(A.A,{sx:{display:"flex"},children:(0,r.jsx)(v.A,{title:o.Ay.translate("ButtonRevoke"),children:(0,r.jsx)(m.A,{color:"error",onClick:function(){var e;return(null===(e=n.original)||void 0===e?void 0:e.AccessToken)&&R(n.original.AccessToken)},children:(0,r.jsx)(w.A,{})})})})}}),R=(0,c.useCallback)((function(n){e&&(0,l.A)(o.Ay.translate("MessageConfirmRevokeApiKey"),o.Ay.translate("HeaderConfirmRevokeApiKey")).then((function(){j.mutate({key:n})})).catch((function(e){console.error("[apikeys] failed to show confirmation dialog",e)}))}),[e,j]),q=(0,c.useCallback)((function(){e&&t.e(72521).then(t.bind(t,72521)).then((function(e){(0,e.default)({title:o.Ay.translate("HeaderNewApiKey"),label:o.Ay.translate("LabelAppName"),description:o.Ay.translate("LabelAppNameExample")}).then((function(e){H.mutate({app:e})})).catch((function(){}))})).catch((function(e){console.error("[apikeys] failed to load api key popup",e)}))}),[e,H]);return(0,r.jsx)(a.A,{id:"apiKeysPage",title:o.Ay.translate("HeaderApiKeys"),className:"mainAnimatedPage type-interior",children:(0,r.jsxs)(A.A,{className:"content-primary",sx:{display:"flex",flexDirection:"column",height:"100%"},children:[(0,r.jsx)(A.A,{sx:{marginBottom:1},children:(0,r.jsxs)(b.A,{spacing:2,children:[(0,r.jsx)(x.A,{variant:"h2",children:o.Ay.translate("HeaderApiKeys")}),(0,r.jsx)(x.A,{children:o.Ay.translate("HeaderApiKeysHelp")})]})}),(0,r.jsx)(k.zp,{table:T})]})})}}}]);