"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9200],{99200:(e,a,s)=>{s.r(a),s.d(a,{DocTags:()=>g});var t=s(57505),l=s(16697),n=s(81594),d=s(50245),i=s(28284),r=s(65874);let c=({teamDocTags:e,availableDocTagCount:a,onAddDocTags:s,onAddTeamDocTag:l})=>{let[n,c]=(0,d.useState)([]),[o,g]=(0,d.useState)(!1),m=()=>{g(!1),s(n),c([])};return(0,t.jsx)(r.n,{isOpen:o,onClose:m,onToggle:e=>e?g(!0):m(),docTags:e,onClick:e=>{n.includes(e)?c(a=>a.filter(a=>a!==e)):a-n.length>0&&c(a=>[...a,e])},onAddTeamDocTag:l,isReadOnly:!1,selectedDocTagIds:n,children:(0,t.jsxs)("div",{className:"cursor-pointer gap-2 rounded-2xl p-2 flex items-center text-gray-400 dark:text-gray-500 hover:bg-gray-50 dark:hover:bg-gray-950 transition",children:[(0,t.jsx)("div",{className:"flex items-center justify-center h-5 w-5 shrink-0",children:(0,t.jsx)(i.A,{size:16})}),(0,t.jsx)("span",{className:"text-sm leading-5 font-medium w-max",children:"Add tag"})]})})};var o=s(79178);let g=({isReadOnly:e,teamDocTags:a,docTags:s,onUpdateDocTags:i,onUpdateTeamDocTags:r,className:g})=>{let m=(0,d.useMemo)(()=>(0,n.SO)(s,a),[s,a]),u=(0,d.useMemo)(()=>a.filter(e=>!s.includes(e.id)),[s,a]),x=async e=>{if(!e.length)return;let a=m.map(e=>e.id);i?.([...a,...e])},T=(e,a)=>{let s=m.map(s=>s.id===e?a:s.id);i?.(s)},h=e=>{let a=m.filter(a=>a.id!==e).map(e=>e.id);i?.(a)},f=e=>{let s=[e,...a];r?.(s)};return(0,t.jsxs)("div",{className:(0,l.cn)("flex flex-wrap items-center gap-2 w-full",g),children:[m.map(a=>(0,t.jsx)(o.v,{isReadOnly:e,teamDocTags:u,onUpdateDocTag:T,onDeleteDocTag:h,onAddTeamDocTag:f,docTag:a},a.id)),!e&&m.length!==n.fo&&(0,t.jsx)(c,{teamDocTags:u,availableDocTagCount:n.fo-m.length,onAddDocTags:x,onAddTeamDocTag:f})]})}}}]);