import{a as p,j as a}from"./vendor-query-B2UbickB.js";import{X as m}from"./vendor-icons-CrrAvF2g.js";function d(t){return t.toLowerCase().replace(/[^a-z0-9-]/g,"").replace(/^-|-$/g,"")}function y({tags:t,onChange:o,placeholder:u="Add tag...",compact:x}){const[r,s]=p.useState(""),c=p.useRef(null),i=e=>{const n=d(e);n&&!t.includes(n)&&o([...t,n]),s("")},l=e=>{o(t.filter(n=>n!==e))},f=e=>{e.key==="Enter"||e.key===","?(e.preventDefault(),i(r)):e.key==="Backspace"&&!r&&t.length>0&&l(t[t.length-1])};return a.jsxs("div",{className:x?"flex flex-wrap items-center gap-1.5":"flex flex-wrap items-center gap-1.5 bg-surface-sunken border border-surface-border rounded-md px-2 py-1.5 focus-within:ring-1 focus-within:ring-accent-primary cursor-text",onClick:()=>{var e;return(e=c.current)==null?void 0:e.focus()},children:[t.map(e=>a.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-accent/10 text-accent text-[11px] font-medium",children:[e,a.jsx("button",{type:"button",onClick:n=>{n.stopPropagation(),l(e)},className:"hover:text-status-error transition-colors",children:a.jsx(m,{className:"w-2.5 h-2.5"})})]},e)),a.jsx("input",{ref:c,type:"text",value:r,onChange:e=>s(e.target.value),onKeyDown:f,onBlur:()=>{r.trim()&&i(r)},placeholder:t.length===0?u:"",className:"flex-1 min-w-[80px] bg-transparent text-xs text-text-primary outline-none placeholder:text-text-tertiary"})]})}export{y as T};
//# sourceMappingURL=TagInput-D6l1SPWd.js.map
