import{iv as y,hn as j,fH as e,bU as I,ck as k,aD as S,cz as s,cI as p,cQ as T}from"./strapi-ye6TfKul.js";import{b,a as C,L as A,c as L}from"./TokenBox-CEBEn4T7.js";const R=n=>[n.firstname,n.lastname].filter(Boolean).join(" ")||n.username||n.email||"",O=({errors:n={},onChange:a,canEditInputs:l,isCreating:g,values:i={},apiToken:r={},kind:o,onDispatch:d,setHasChangedPermissions:f})=>{const{formatMessage:c}=y(),m=j("FormApiTokenContainer",t=>t.user),u=(()=>{const t=o==="admin"?r?.adminUserOwner:void 0;return t==null||typeof t!="object"||m?.id!==void 0&&t.id===m.id?null:t})(),h=({target:{value:t}})=>{f(!1),t==="full-access"&&d({type:"SELECT_ALL_ACTIONS"}),t==="read-only"&&d({type:"ON_CHANGE_READ_ONLY"})},x=[{value:"read-only",label:{id:"Settings.tokens.types.read-only",defaultMessage:"Read-only"}},{value:"full-access",label:{id:"Settings.tokens.types.full-access",defaultMessage:"Full access"}},{value:"custom",label:{id:"Settings.tokens.types.custom",defaultMessage:"Custom"}}];return e.jsx(I,{background:"neutral0",hasRadius:!0,shadow:"filterShadow",paddingTop:6,paddingBottom:6,paddingLeft:7,paddingRight:7,children:e.jsxs(k,{direction:"column",alignItems:"stretch",gap:4,children:[e.jsx(S,{variant:"delta",tag:"h2",children:c({id:"global.details",defaultMessage:"Details"})}),e.jsxs(s.Root,{gap:5,children:[e.jsx(s.Item,{m:6,xs:12,direction:"column",alignItems:"stretch",children:e.jsx(b,{error:n.name,value:i.name,canEditInputs:l,onChange:a})},"name"),e.jsx(s.Item,{m:6,xs:12,direction:"column",alignItems:"stretch",children:e.jsx(C,{error:n.description,value:i.description,canEditInputs:l,onChange:a})},"description"),e.jsx(s.Item,{m:6,xs:12,direction:"column",alignItems:"stretch",children:e.jsx(A,{isCreating:g,error:n.lifespan,value:i.lifespan,onChange:a,token:r})},"lifespan"),o==="content-api"&&e.jsx(s.Item,{m:6,xs:12,direction:"column",alignItems:"stretch",children:e.jsx(L,{value:i.type,error:n.type,label:{id:"Settings.tokens.form.type",defaultMessage:"Token type"},onChange:t=>{h({target:{value:String(t)}}),a({target:{name:"type",value:String(t)}})},options:x,canEditInputs:l})},"type"),u!==null&&e.jsx(s.Item,{m:6,xs:12,direction:"column",alignItems:"stretch",children:e.jsxs(p.Root,{name:"adminUserOwner",children:[e.jsx(p.Label,{children:c({id:"Settings.tokens.form.owner",defaultMessage:"Owner"})}),e.jsx(T,{type:"text",value:R(u),disabled:!0,onChange:()=>{}})]})},"owner")]})]})})};export{O as F};
