import{r as l,j as e,av as _,ai as I,u as S,h as b,B as c,aC as C,e5 as A,aB as k,e6 as F,I as T,e7 as D,e8 as y}from"./index-f9c70843.js";import{I as w}from"./input-ae70f3cc.js";import{L as N,T as M}from"./textarea-2b2c5564.js";import{C as R}from"./checkbox-5461a929.js";const B=({name:m,invalidNameList:v,description:i,endpointName:f,maxLength:n=50,setName:d,setDescription:s,setEndpointName:o})=>{const[p,r]=l.useState(!1),[h,j]=l.useState(!0),u=a=>{const{value:x}=a.target;x.length>=n?r(!0):r(!1),d(x)},t=a=>{s(a.target.value)},E=a=>{const x=/^[a-zA-Z0-9_-]+$/.test(a.target.value)&&a.target.value.length<=n||a.target.value.length===0;j(x),o(a.target.value)},g=a=>a.target.select();return e.jsxs(e.Fragment,{children:[e.jsxs(N,{children:[e.jsxs("div",{className:"edit-flow-arrangement",children:[e.jsxs("span",{className:"font-medium",children:["Name",d?"":":"]})," ",p&&e.jsx("span",{className:"edit-flow-span",children:"Character limit reached"})]}),d?e.jsx(w,{className:"nopan nodelete nodrag noundo nocopy mt-2 font-normal",onChange:u,type:"text",name:"name",value:m??"",placeholder:"Flow name",id:"name",maxLength:n,onDoubleClickCapture:a=>{g(a)}}):e.jsx("span",{className:"font-normal text-muted-foreground word-break-break-word",children:m})]}),e.jsxs(N,{children:[e.jsx("div",{className:"edit-flow-arrangement mt-3",children:e.jsxs("span",{className:"font-medium ",children:["Description",s?" (optional)":":"]})}),s?e.jsx(M,{name:"description",id:"description",onChange:t,value:i,placeholder:"Flow description",className:"mt-2 max-h-[100px] resize-none font-normal",rows:3,onDoubleClickCapture:a=>{g(a)}}):e.jsx("span",{className:_("font-normal text-muted-foreground word-break-break-word",i===""?"font-light italic":""),children:i===""?"No description":i})]}),o&&e.jsxs(N,{children:[e.jsxs("div",{className:"edit-flow-arrangement mt-3",children:[e.jsx("span",{className:"font-medium",children:"Endpoint Name"}),!h&&e.jsxs("span",{className:"edit-flow-span",children:["Invalid endpoint name. Use only letters, numbers, hyphens, and underscores (",n," characters max)."]})]}),e.jsx(w,{className:"nopan nodelete nodrag noundo nocopy mt-2 font-normal",onChange:E,type:"text",name:"endpoint_name",value:f??"",placeholder:"An alternative name to run the endpoint",maxLength:n,id:"endpoint_name",onDoubleClickCapture:a=>{g(a)}})]})]})},L=B,O=l.forwardRef((m,v)=>{const i=I(t=>t.version),f=S(t=>t.setNoticeData),[n,d]=l.useState(!1),s=b(t=>t.currentFlow);l.useEffect(()=>{p(s.name),h(s.description)},[s.name,s.description]);const[o,p]=l.useState(s.name),[r,h]=l.useState(s.description),[j,u]=l.useState(!1);return e.jsxs(c,{size:"smaller-h-full",open:j,setOpen:u,onSubmit:()=>{n?(C({id:s.id,data:s.data,description:r,name:o,last_tested_version:i,is_component:!1},o,r),f({title:A})):C(k({id:s.id,data:s.data,description:r,name:o,last_tested_version:i,is_component:!1}),o,r),u(!1)},children:[e.jsx(c.Trigger,{asChild:!0,children:m.children}),e.jsxs(c.Header,{description:F,children:[e.jsx("span",{className:"pr-2",children:"Export"}),e.jsx(T,{name:"Download",className:"h-6 w-6 pl-1 text-foreground","aria-hidden":"true"})]}),e.jsxs(c.Content,{children:[e.jsx(L,{name:o,description:r,setName:p,setDescription:h}),e.jsxs("div",{className:"mt-3 flex items-center space-x-2",children:[e.jsx(R,{id:"terms",checked:n,onCheckedChange:t=>{d(t)}}),e.jsx("label",{htmlFor:"terms",className:"export-modal-save-api text-sm ",children:D})]}),e.jsx("span",{className:"mt-1 text-xs text-destructive ",children:y})]}),e.jsx(c.Footer,{submit:{label:"Export"}})]})}),W=O;export{W as E,L as a};
