1import{P as W}from"./ProfilePageHeader.6d589eb1.js";import{a6 as X,t as ee,u as L,au as ae,aj as ne,bb as te,aN as ie,r as V,_ as R}from"./index.95b37175.js";import{A as D}from"./AlertMessage.4fb9c290.js";import{a4 as se,Z as le,r as h,c as o,cu as oe,cv as re,cm as U,d as T,O as i,Y as x,a7 as C,U as P,u as e,P as k,V as E,F as pe,k as q,j as ue}from"./helpers.282417e7.js";import{u as ce,E as _e}from"./EmailConfirmationDialog.d3839012.js";import{u as de}from"./index.5e2cf334.js";import"./MainInput.919f7b13.js";const me="https://api.aim.market/v1/api/partner/docs",M=100;function ge(){const{user:B}=se(),{displayCurrency:r}=X(),s=ee(),{locale:p,t:u}=L(),K=le(),c=h(!1),b=h(null),f=h(null),d=o(()=>{var a;return((a=B.value)==null?void 0:a.email)||null}),{result:y,loading:m,refetch:S}=oe(),g=h(null),v=o(()=>{var a;return g.value||((a=y.value)==null?void 0:a.get_user_api_key)||null}),{result:n,loading:t}=re(),_=o(()=>{var a;return!K.value||!!((a=n.value)!=null&&a.generate_api_key_allowed)}),z=o(()=>K.value&&!!v.value),Q=o(()=>m.value||I.value||!n.value||t.value),G=o(()=>_.value&&!!d.value),{requestEmailConfirmationMutate:j,requestEmailConfirmationLoading:I}=ce();async function F(a){var A;if(a===U.GenerateApiKey&&!G.value||I.value)return;if(!d.value){s.notify({type:"negative",message:u("pages.profile.errors.verified_email_required"),html:!1,timeout:1e4,icon:void 0});return}f.value=a;const l=await j({input:{action:f.value,locale:p.value}}).catch(w=>{let $="";w.message.includes("ThrottlerException")?$=u("errors.too_many_requests"):w.message==="generation_not_allowed_by_balance"?$=u("pages.profile.errors.generation_not_allowed_by_balance",{amount:M}):$=u("errors.unknown_error"),s.notify({type:"negative",message:$,html:!1,timeout:1e4,icon:void 0})});!((A=l==null?void 0:l.data)!=null&&A.request_email_confirmation)||(b.value=l.data.request_email_confirmation.expiresAt,c.value=!0)}const O=async()=>{!v.value||await te(v.value).then(()=>{s.notify({type:"info",message:u("overall.copied"),icon:void 0})})};async function H(a){var w;const l=(w=a==null?void 0:a.data)==null?void 0:w.verify_email_confirmation,A=(l==null?void 0:l.apiKey)||null;A?(g.value=A,await O()):g.value=null,S()}const{value:N}=ae(()=>"USD",()=>M),{formatPrice:Y}=ne(),Z=o(()=>N.value&&Y(N.value||0,r.value)||"$100"),J=o(()=>`${me}/${p.value}/`);return{apiKey:v,hasKey:z,action:f,email:d,loading:Q,docsUrl:J,expiresIn:b,newApiKey:g,canGenerate:G,requestAction:F,allowedLoading:t,displayCurrency:r,generateApiKeyAllowed:_,showConfirmationModal:c,onEmailConfirmationSuccess:H,minUsdBalance:M,minBalanceAmountText:Z}}const ve={class:"api-panel"},fe={class:"api-panel__header"},ye=["textContent"],Ae=["href","textContent"],we={class:"api-panel__key-row"},Ce={class:"api-panel__field"},ke=["textContent"],xe=["textContent"],Ke=T({__name:"ApiKeyPanel",setup(B){const{email:r,apiKey:s,hasKey:p,action:u,docsUrl:K,loading:c,newApiKey:b,expires
1In:f,canGenerate:d,requestAction:y,showConfirmationModal:m,generateApiKeyAllowed:S,onEmailConfirmationSuccess:g,minBalanceAmountText:v}=ge();return(n,t)=>(i(),x("div",ve,[C("div",fe,[C("span",{class:"api-panel__title",textContent:P(n.$t("pages.profile.api_your_key"))},null,8,ye),C("a",{class:"api-panel__docs",href:e(K),target:"_blank",rel:"noopener noreferrer",textContent:P(n.$t("pages.profile.api_go_to_docs"))},null,8,Ae)]),C("div",we,[C("div",Ce,[e(p)?(i(),x("span",{key:0,class:"ellipsis api-panel__field-text",textContent:P(e(s))},null,8,ke)):(i(),x("span",{key:1,class:"api-panel__field-text api-panel__field-text--empty",textContent:P(n.$t("pages.profile.api_not_generated"))},null,8,xe)),e(b)?(i(),k(ie,{key:2,size:"16px",value:e(s)},null,8,["value"])):E("",!0)]),e(p)?(i(),x(pe,{key:1},[q(V,{unelevated:"","no-caps":"",disable:!e(d),loading:e(c),class:"api-panel__generate",label:n.$t("pages.profile.api_regenerate"),onClick:t[1]||(t[1]=_=>e(y)(e(U).GenerateApiKey))},null,8,["disable","loading","label"]),q(V,{unelevated:"","no-caps":"",loading:e(c),class:"api-panel__generate",label:n.$t("pages.profile.api_revoke"),color:"negative",onClick:t[2]||(t[2]=_=>e(y)(e(U).RevokeApiKey))},null,8,["loading","label"])],64)):(i(),k(V,{key:0,unelevated:"","no-caps":"",disable:!e(d),loading:e(c),class:"api-panel__generate",label:n.$t("pages.profile.api_generate"),color:"primary",onClick:t[0]||(t[0]=_=>e(y)(e(U).GenerateApiKey))},null,8,["disable","loading","label"]))]),!e(c)&&!e(S)?(i(),k(D,{key:0,type:"warning",icon:"svguse:/figma-icons.v26.svg#alert-warning","icon-size":"20px",class:"api-panel__warning",message:n.$t("pages.profile.api_balance_warning",{amount:e(v)})},null,8,["message"])):E("",!0),!e(r)&&!e(p)?(i(),k(D,{key:1,type:"warning",icon:"svguse:/figma-icons.v26.svg#alert-warning","icon-size":"20px",class:"api-panel__warning",message:n.$t("pages.profile.api_verified_email_required")},null,8,["message"])):E("",!0),e(m)?(i(),k(_e,{key:2,modelValue:e(m),"onUpdate:modelValue":t[3]||(t[3]=_=>ue(m)?m.value=_:null),email:e(r),"expires-in":e(f),action:e(u),onSuccess:e(g)},null,8,["modelValue","email","expires-in","action","onSuccess"])):E("",!0)]))}});var be=R(Ke,[["__scopeId","data-v-17ec3d88"]]);const $e={class:"api-page tw-flex tw-flex-col tw-gap-[16px] lt-md:tw-gap-[8px]"},he=T({__name:"ApiPage",setup(B){const{t:r}=L();return de(()=>({title:r("pages.profile.title.api")})),(s,p)=>(i(),x("div",$e,[q(W,{icon:"svguse:/figma-icons.v26.svg#api",title:s.$t("pages.profile.nav_api"),class:"api-page__header"},null,8,["title"]),q(be)]))}});var Me=R(he,[["__scopeId","data-v-9d72a08a"]]);export{Me 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.