import{r,j as e}from"./vendor-react-wBh_31cN.js";import{B as u}from"./badge-nyizWwTN.js";import{G as d}from"./index-BKr2rJhV.js";import{E as w}from"./editable-select-Co_-YcCr.js";import{T as C}from"./tooltip-Da8-EbK8.js";import{C as b}from"./CardLabels-Dyg8tTF4.js";import{ah as E}from"./vendor-icons-BUUmD6ht.js";const k=(s,n,t)=>!s||s.trim().length===0?!1:!t.find(c=>c.label===s.trim()),T=({value:s,onSave:n,isDisabled:t=!1,isSaving:o=!1,editRestrictionText:c,itemName:a="keywords",options:f=[],isCaseSensitive:h=!1})=>{const[l,x]=r.useState(s),[m,i]=r.useState(!1),p=r.useCallback(async()=>{i(!0),await n(l),i(!1)},[l,n]),j=r.useCallback(()=>{x(s),i(!1)},[s]);return m?e.jsxs("div",{className:"flex gap-2.5",children:[e.jsx("div",{className:"flex flex-1 w-full",children:e.jsx(w,{isMulti:!0,value:l,options:f,placeholder:a,onChange:x,noResultsText:`No ${a} defined`,...h&&{isValidNewOption:k}})}),e.jsxs("div",{className:"flex gap-2.5 max-h-[33px] flex-[0_1_min-content]",children:[e.jsx(d,{disabled:o,onClick:j,variant:"outline",children:"Cancel"}),e.jsx(d,{"data-test":"save-keyword",onClick:p,disabled:o,children:"Save"})]})]}):e.jsxs("div",{className:"flex items-baseline",children:[e.jsx("div",{className:"flex-1",children:s!=null&&s.length?e.jsx(b,{flexGrow:1,flexWrap:"wrap",labels:l}):e.jsx(u,{variant:"outline",children:`No ${a}`})}),e.jsx(C,{content:t?c??"You have no edit right":void 0,children:e.jsxs(d,{variant:"outline",size:"sm",disabled:t,onClick:()=>i(!0),children:[e.jsx(E,{className:"w-4 h-4"}),"Edit ",a]})})]})};export{T as K};
