import{e as j,j as e,P as a,r as f,a as n,T as b,v as k,n as A,J as S,K as P,p as v,Y as w,M as q,Z as M}from"./index-Dastpg3d.js";import{L as T}from"./validator-CFS8HeGh.js";import{E as F}from"./form-gPl9P668.js";const K=j.div`
  width: 24em;
`;function C({apiKey:s,label:i,placeholder:o,length:c,minLength:l}){const t=A(),{data:d}=S(P()),{mutate:h,isPending:u}=v({...w(),onSuccess:()=>{t.refetchQueries({queryKey:q()}),t.invalidateQueries({queryKey:M()})},meta:{errorPrefix:"Error updating API key"}}),r=String(s),p=({formValue:m,formSubmitCallback:y,formReset:x})=>{h({body:{id:r,key:m[r]}},{onSuccess:g=>{y({message:g.message,formReset:x})}})};return e.jsx(F,{name:r,label:i,value:d.user_api_keys[s]??"",placeholder:o,length:c,minLength:l,mutationCallback:p,mutationIsPending:u})}function I(){return e.jsxs(e.Fragment,{children:[e.jsx(n,{$variant:"ingress",children:"For managing some of the settings, this application needs to know the keys for some external APIs. These are keys that each user needs to acquire, and which can then be stored through this application."}),e.jsx(a,{$variant:"h3",children:e.jsx("span",{id:"smda_subscription",children:"SMDA"})}),e.jsxs(n,{children:["An SMDA subscription key is needed for querying the"," ",e.jsx("a",{href:"https://smda.equinor.com/",target:"_blank",rel:"noreferrer",children:"SMDA"})," ","API. This key can be created as follows:"]}),e.jsxs(b,{as:"ol",children:[e.jsxs("li",{children:["Go to the"," ",e.jsx("a",{href:"https://api.equinor.com/",target:"_blank",rel:"noreferrer",children:"Equinor API portal"})," ","and sign in"]}),e.jsxs("li",{children:["Go to the"," ",e.jsx("a",{href:"https://api.equinor.com/product#product=smda",target:"_blank",rel:"noreferrer",children:"SMDA product page"})]}),e.jsx("li",{children:'Subscribe to the API. The subscription name can be given as "SMDA"'}),e.jsx("li",{children:'The subscription will be listed on the Profile page, with a primary and a secondary key, masked with "XXX...". Show the actual value of the primary key, and copy the value'}),e.jsx("li",{children:'Add the copied key value to the edit field here. After saving the value will be shown masked with "***..."'})]}),e.jsx(k,{}),e.jsx(K,{children:e.jsx(C,{apiKey:"smda_subscription",label:"SMDA subscription primary key",placeholder:"(not set)",length:32})})]})}const Q=function(){return e.jsxs(e.Fragment,{children:[e.jsx(a,{children:"API keys"}),e.jsx(f.Suspense,{fallback:e.jsx(T,{}),children:e.jsx(I,{})})]})};export{Q as component};
