import*as e from"react";import o from"styled-components";import{useParams as g}from"react-router-dom";import{useMutation as E,useQueryClient as y}from"@tanstack/react-query";import{Flex as s}from"@redocly/portal-legacy-ui";import{Button as x}from"@redocly/theme/components/Button/Button";import{H3 as h}from"@redocly/theme/components/Typography/H3";import{Admonition as v}from"@redocly/theme/markdoc/components/Admonition/Admonition";import k from"./ApiKeyOverview";import{ApiKeyProductsStatus as w}from"./ApiKeyProductStatus";import{UpdateKey as K}from"./UpdateApiKey";import{Dialog as L}from"./Dialog";import{ButtonWithLoading as D}from"./ButtonWithLoading";function S(m){const p=y(),{credential:t}=m,{id:r}=g(),[c,a]=e.useState(!1),[u,n]=e.useState(!1),{isPending:i,error:l,mutate:d}=E({mutationKey:["DELETE_CRED"+t.id],mutationFn:()=>fetch(`/api/api-keys/apps/${r}/credentials/${t.id}`,{method:"DELETE"}),onSuccess:()=>{p.invalidateQueries({queryKey:["APP:"+r]}),n(!1)}}),C=()=>{d()},f=()=>{a(!0)};return e.createElement(e.Fragment,null,e.createElement(A,null,e.createElement(k,{apiKey:t}),e.createElement(w,{apiProductsStatuses:t.apiProductsStatus,secret:t.clientSecret,id:t.id})),e.createElement(K,{credential:t,open:c,onClose:()=>a(!1),onOpen:f}),e.createElement(L,{open:u,onOpen:()=>n(!0),onClose:()=>n(!1)},e.createElement(e.Fragment,null,e.createElement(h,null,"Revoke key"),e.createElement("div",null,"Do you really want to revoke this key?"),l&&e.createElement(v,{type:"danger"},l.message),e.createElement(O,null,e.createElement(x,{onClick:()=>n(!1)},"Cancel"),e.createElement(D,{variant:"primary",onClick:C,disabled:i,loading:i},"Revoke key")))))}const A=o(s)`
  flex-wrap: wrap;
  gap: 32px;
`,W=o.span`
  margin: 14px 6px;
  width: 20px;
  height: 20px;
  background-repeat: no-repeat;
  background-size: 20px 20px;
  background-image: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='20' height='20' fill='none' style='mix-blend-mode:multiply'/%3E%3Cpath d='M14.9998 6.25L14.1159 7.13381L16.3572 9.375H7.43657C7.31292 8.77515 7.01623 8.22468 6.58316 7.7916C6.15008 7.35853 5.59961 7.06183 4.99976 6.93819V1.25H3.74976V6.93819C3.04406 7.08229 2.40981 7.46575 1.95431 8.02367C1.4988 8.5816 1.25 9.27974 1.25 10C1.25 10.7203 1.4988 11.4184 1.95431 11.9763C2.40981 12.5343 3.04406 12.9177 3.74976 13.0618V18.75H4.99976V13.0618C5.59961 12.9382 6.15008 12.6415 6.58316 12.2084C7.01623 11.7753 7.31292 11.2248 7.43657 10.625H16.3572L14.1159 12.8662L14.9998 13.75L18.7498 10L14.9998 6.25ZM4.37476 11.875C4.00392 11.875 3.6414 11.765 3.33306 11.559C3.02472 11.353 2.7844 11.0601 2.64248 10.7175C2.50057 10.3749 2.46344 9.99792 2.53578 9.63421C2.60813 9.27049 2.78671 8.9364 3.04893 8.67417C3.31116 8.41195 3.64525 8.23338 4.00896 8.16103C4.37268 8.08868 4.74968 8.12581 5.09229 8.26773C5.4349 8.40964 5.72774 8.64996 5.93376 8.95831C6.13979 9.26665 6.24976 9.62916 6.24976 10C6.24921 10.4971 6.05149 10.9737 5.69998 11.3252C5.34847 11.6767 4.87187 11.8745 4.37476 11.875Z' fill='%231E1E1F'/%3E%3C/svg%3E%0A");
`,O=o(s)`
  margin-top: 2em;
  justify-content: flex-end;
  gap: var(--spacing-xs);
`;export{O as ButtonsWrapper,W as ConnectSourceIcon,S as default};
