1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6676,8828],{4898:(e,t,s)=>{"use strict";s.d(t,{LM:()=>h,Yi:()=>g,ct:()=>m,pO:()=>u,sq:()=>c,yS:()=>x});var a=s(95778),n=s(70643),l=s(90124),r=s(66657),i=s(79882),o=s(52969);async function d(e,t){return(await (0,o.postAuthenticated)(e,t)).data}function c(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1],{user:s}=(0,i.Z2)();return(0,a.I)({queryKey:["teamConversation",null==s?void 0:s.uid,e],queryFn:()=>d("teamConversation",{...e}),enabled:!!(t&&s&&e.accountId&&e.teamId&&e.peerId),staleTime:15e3})}function u(e){let t=(0,n.jE)();return(0,l.n)({mutationFn:t=>{let{endpoint:s,...a}=t;return d(s,{...a,teamId:e})},onSettled:async()=>{await Promise.all(["teamConversation","teamWork","teamActivity"].map(e=>t.invalidateQueries({queryKey:[e]})))}})}function m(e,t){let{user:s}=(0,i.Z2)();return(0,r.q)({queryKey:["teamActivity",null==s?void 0:s.uid,e],queryFn:t=>{let{pageParam:s}=t;return d("teamActivity",{teamId:e,...s?{cursor:s}:{}})},getNextPageParam:e=>e.nextCursor||void 0,enabled:!!(s&&t&&e),staleTime:15e3})}function x(e,t,s,a,n){let{user:l}=(0,i.Z2)();return(0,r.q)({queryKey:["teamWork",null==l?void 0:l.uid,e,t,s,a],queryFn:n=>{let{pageParam:l}=n;return d("teamWork",{teamId:e,accountId:t,assignee:s,overdueOnly:a,...l?{cursor:l}:{}})},getNextPageParam:e=>e.nextCursor||void 0,enabled:!!(l&&n&&e&&t),staleTime:15e3})}function g(e,t){let{user:s}=(0,i.Z2)();return(0,r.q)({queryKey:["teamReviews",null==s?void 0:s.uid,e],queryFn:t=>{let{pageParam:s}=t;return d("teamReviews",{teamId:e,...s?{cursor:s}:{}})},getNextPageParam:e=>e.nextCursor||void 0,enabled:!!(s&&t&&e),staleTime:1e4})}function h(e){let t=(0,n.jE)();return(0,l.n)({mutationFn:t=>{let{endpoint:s,...a}=t;return d(s,{...a,teamId:e})},onSettled:async()=>{await Promise.all(["teamReviews","teamActivity"].map(e=>t.invalidateQueries({queryKey:[e]})))}})}},15019:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>ex});var a=s(26514),n=s(14254),l=s(46055),r=s(14684),i=s(10819),o=s(25986),d=s(59017),c=s(35529),u=s(15776),m=s(27228),x=s(89433),g=s(84739),h=s(59104),p=s(46168),v=s(46225),f=s(75834),j=s(23469),b=s.n(j),y=s(94358),w=s(9001);let N=b()(()=>s.e(6797).then(s.bind(s,86797)),{loadableGenerated:{webpack:()=>[null]},ssr:!1});function k(e){var t,s,l;let{columns:r,data:i,contacts:j,isToolBarDisplayed:b=!0,isPaginationDisplayed:k=!0,initialState:C,showSyncButton:I=!0,isSyncButtonActive:S=!1,showAddOpportunity:A=!1,areBottomButtonsActive:R=!1,showBackupButton:T=!1,handleAddColumn:F,isAddingColumn:M=!1,setIsAddingColumn:z,setNewColumnName:E,handleSaveColumn:L,newColumnName:P,syncFunc:q,isLoading:D,className:O,pagination:B,setPagination:K,messages:_,isRefetching:H=!1,startTour:U,isTourOpen:$,renderRowSubComponent:Q}=e,Z=(0,n.cc)(),[X,W]=f.useState({}),[V,G]=f.useState((0,y.G)().hiddenColumns.reduce((e,t)=>(e[t]=!1,e),{})),[J,Y]=f.useState([]),[ee,et]=f.useState([]),[es,ea]=f.useState({}),en=(0,v.useRouter)().pathname,[el,er]=(0,h.fp)(m.g5),[ei,eo]=(0,h.fp)(m.Dz),ed=(0,x.N4)({data:i,columns:r,state:{sorting:ee,columnVisibility:V,rowSelection:X,columnFilters:J,columnSizing:es},columnResizeMode:"onChange",onColumnSizingChange:ea,enableColumnResizing:!0,enableRowSelection:!0,onRowSelectionChange:W,onSortingChange:et,onColumnFiltersChange:Y,onColumnVisibilityChange:G,getCoreRowModel:(0,g.HT)(),getFilteredRowModel:(0,g.hM)(),getPaginationRowModel:(0,g.kW)(),getSortedRowModel:(0,g.h5)(),getFacetedRowModel:(0,g.kQ)(),getFacetedUniqueValues:(0,g.oS)(),pageCount:Math.ceil((null!=(s=null==B?void 0:B.total)?s:0)/(null!=(l=null==B?void 0:B.pageSize)?l:1)),manualPagination:!0,getExpandedRowModel:(0,g.D0)()});ed.getSortedRowModel().flatRows.map(e=>e.original),(0,f.useEffect)(()=>{(0,y.y)({hiddenColumns:Object.entries(V).filter(e=>{let[t,s]=e;return!s}).map(e=>{let[t]=e;return t})})},[V]),(0,f.useEffect)(()=>{let{pageSize:e,pageIndex:t}=B,s=t*e,a=ed.getRowModel().flatRows;[...a.slice(0,s),...a.slice(s+e)].forEach(e=>e.toggleSelected(!1))},[B]);let ec=[{target:".tour-search",content:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.tv,{message:"Welcome to your personal CRM!
1Let's go through some core features:"}),(0,a.jsx)("br",{}),(0,a.jsx)("br",{}),(0,a.jsx)(n.tv,{message:"Search your chats..."})]})},{target:".tour-filter",content:Z("... and filter them by Folder or Priority."),placement:"right"},{target:".tour-folder",content:Z("Easily manage your folders. Add chats, remove chats, and create new folders."),placement:"right"},{target:".tour-followup",content:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.tv,{message:"Schedule follow-up dates, and receive daily notifications from our Telegram bot:"}),(0,a.jsx)(o.p,{href:"https://t.me/chihoaibot",target:"_blank",rel:"noopener noreferrer",className:"font-bold ml-1",children:"@chihoaibot"})]}),placement:"right"},{target:".tour-ai",content:Z("Summarize chats and get actionable tasks from our AI."),placement:"left"},{target:".sync-chats-tab",content:Z("Finally, add more Telegram chats to your CRM Chats.")}],eu=[{target:".tour-filter2",content:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.tv,{message:"Welcome to Chiho!"}),(0,a.jsx)("br",{}),(0,a.jsx)("br",{}),(0,a.jsx)(n.tv,{message:"Start by searching chats and folders that you want to sync to your CRM."})]}),placement:"left"},{target:".tour-checkbox",content:Z("Then choose chats and sync them to your CRM Chats tab.")}],[em,ex]=f.useState(!1);return(0,a.jsxs)("div",{className:"space-y-4",children:["/crm"===en&&$&&(U?!el:!ei)&&(0,a.jsx)(N,{steps:U?ec:eu,run:"/crm"===en&&$&&(U?!el:!ei),callback:e=>{let t=U?eu:ec,{action:s,type:a,step:n,index:l}=e;("skip"===s||"tour:end"===a)&&(U?er(!0):eo(!0)),"step:after"===a&&t===ec&&l===t.length-2&&setTimeout(()=>{let e=document.querySelector(".tour-ai");if(e){let t=e.closest(".tableclass");if(t){let s=e.getBoundingClientRect(),a=t.getBoundingClientRect();t.scrollLeft=s.left-a.left}}},50)},continuous:!0,showSkipButton:!0,showProgress:!0,styles:{options:{arrowColor:"#e0e0e0",backgroundColor:"#e0e0e0",primaryColor:"#c73e3e"}}}),b&&(0,a.jsx)(c.w,{isLoading:H,table:ed,contacts:j,handleAddColumn:F,showSyncButton:I,showAddOpportunity:A,isSyncPage:S,messages:_,showBackupButton:T,pagination:B,setPagination:K}),(0,a.jsx)("div",{className:"rounded-md border",children:(0,a.jsxs)(u.XI,{className:O,onScroll:e=>{ex(e.target.scrollLeft>0)},children:[(0,a.jsx)(u.A0,{children:ed.getHeaderGroups().map(e=>(0,a.jsxs)(u.Hj,{children:[e.headers.map((e,t)=>(0,a.jsx)(u.nd,{columnId:e.id,style:{width:e.getSize()},onMouseDown:e.getResizeHandler(),onTouchStart:e.getResizeHandler(),className:"resizer ".concat(e.column.getIsResizing()?"isResizing":""),children:e.isPlaceholder?null:(0,x.Kv)(e.column.columnDef.header,e.getContext())},e.id)),M&&(0,a.jsx)(u.nd,{className:"w-72 bg-muted ",children:(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("input",{value:P,onChange:e=>E(e.target.value),placeholder:Z("Enter column name"),className:"w-full mr-2 rounded-md font-secondary border-none bg-transparent py-2 text-sm r
1ing-transparent focus:outline-none focus:ring-0"}),(0,a.jsx)("button",{onClick:()=>L(!0),className:"p-1",children:(0,a.jsx)(p.A,{className:"h-4 w-4"})})]})})]},e.id))}),(0,a.jsx)(u.BF,{children:D?[...Array(B.pageSize)].map((e,t)=>(0,a.jsx)(u.Hj,{children:r.map(e=>(0,a.jsx)(u.nA,{children:(0,a.jsx)(w.E,{className:"h-8 mb-2"})},e.id))},t)):(null==(t=ed.getRowModel().rows)?void 0:t.length)?ed.getRowModel().rows.slice((null==B?void 0:B.pageIndex)*(null==B?void 0:B.pageSize),((null==B?void 0:B.pageIndex)+1)*(null==B?void 0:B.pageSize)).map(e=>{let t=e.original.isLoading;return(0,a.jsxs)(f.Fragment,{children:[(0,a.jsx)(u.Hj,{"data-state":e.getIsSelected()&&"selected",children:e.getVisibleCells().map((e,s)=>(0,a.jsx)(u.nA,{columnId:e.column.id,style:{width:e.column.getSize()},children:t?(0,a.jsx)(w.E,{className:"h-8 mb-2"}):(0,x.Kv)(e.column.columnDef.cell,e.getContext())},e.id))}),!t&&e.getIsExpanded()&&(0,a.jsx)(u.Hj,{className:"bg-muted/50",children:(0,a.jsx)(u.nA,{colSpan:r.length,children:Q?Q({row:e}):null})})]},e.id)}):(0,a.jsx)(u.Hj,{children:(0,a.jsx)(u.nA,{colSpan:r.length,className:"h-24 text-center text-muted-foreground/80 dark:text-muted-foreground/50",children:(0,a.jsx)(n.tv,{message:"Loading data or no data yet."})})})})]})}),k&&(0,a.jsx)(d.T,{syncFunc:q,isSyncButtonActive:S,areBottomButtonsActive:R,table:ed,pagination:B,setPagination:K,selectRowsEnabled:X&&Object.keys(X).length>0})]})}var C=s(22085),I=s(67574),S=s(31639),A=s(53401),R=s(29356),T=s(98860),F=s(55340);function M(e){let{teamId:t,row:s}=e,{mutate:l,isLoading:i}=(0,I.oQ)(),{mutate:o,isLoading:d}=(0,I.Wt)();return(0,a.jsx)(T.lG,{children:(0,a.jsxs)(C.rI,{children:[(0,a.jsx)(C.ty,{asChild:!0,children:i||d?(0,a.jsx)(F.A,{size:4}):(0,a.jsxs)(r.$,{variant:"ghost",className:"flex h-8 w-8 p-0 data-[state=open]:bg-muted",children:[(0,a.jsx)(S.A,{className:"h-4 w-4"}),(0,a.jsx)("span",{className:"sr-only",children:(0,a.jsx)(n.tv,{message:"Open menu"})})]})}),(0,a.jsxs)(C.SQ,{align:"end",className:"w-[160px]",children:["admin"===s.original.myRole&&(0,a.jsxs)(C._2,{onClick:()=>{l({teamId:t})},children:[(0,a.jsx)(A.A,{className:"mr-2 h-3.5 w-3.5 text-muted-foreground/80 dark:text-muted-foreground/50"}),(0,a.jsx)(n.tv,{message:"Delete Team"})]}),"member"===s.original.myRole&&(0,a.jsxs)(C._2,{onClick:()=>{o({teamId:t})},children:[(0,a.jsx)(R.A,{className:"mr-2 h-3.5 w-3.5 text-muted-foreground/80 dark:text-muted-foreground/50"}),(0,a.jsx)(n.tv,{message:"Exit Team"})]})]})]})})}var z=s(50471),E=s(29729),L=s(87754),P=s(88920),q=s(61090);let D=f.createContext({}),O=e=>{let{...t}=e;return(0,a.jsx)(D.Provider,{value:{name:t.name},children:(0,a.jsx)(L.xI,{...t})})},B=()=>{let e=f.useContext(D),t=f.useContext(K),{getFieldState:s,formState:a}=(0,L.xW)(),n=s(e.name,a);if(!e)throw Error("useFormField should be used within <FormField>");let{id:l}=t;return{id:l,name:e.name,formItemId:"".concat(l,"-form-item"),formDescriptionId:"".concat(l,"-form-item-description"),formMessageId:"".concat(l,"-form-item-message"),...n}},K=f.createContext({}),_=f.forwardRef((e,t)=>{let{className:s,...n}=e,l=f.useId();return(0,a.jsx)(K.Provider,{value:{id:l},children:(0,a.jsx)("div",{ref:t,className:(0,P.cn)("space-y-2",s),...n})})});_.displayName="FormItem",f.forwardRef((e,t)=>{let{className:s,...n}=e,{error:l,formItemId:r}=B();return(0,a.jsx)(q.J,{ref:t,className:(0,P.cn)(l&&"text-destructive",s),htmlFor:r,...n})}).displayName="FormLabel";let H=f.forwardRef((e,t)=>{let{...s}=e,{error:n,formItemId:l,formDescriptionId:r,formMessageId:i}=B();return(0,a.jsx)(E.DX,{ref:t,id:l,"aria-describedby":n?"".concat(r," ").concat(i):"".concat(r),"aria-invalid":!!n,...s})});H.displayName="FormControl",f.forwardRef((e,t)=>{let{className:s,...n}=e,{formDescriptionId:l}=B();return(0,a.jsx)("p",{ref:t,id:l,className:(0,P.cn)("text-sm text-muted-foreground",s),...n})}).displayName="FormDescription";let U=f.forwardRef((e,t)=>{let{className:s,children:l,...r}=e,i=(0,n.cc)(),{error:o,formMessageId:d}=B(),c=o?(0,z.lX)(o,i,"Check this field and try again."):l;return c?(0,a.jsx)("p",{ref:t,id:d,className:(0,P.cn)("text-sm font-medium text-destructive",s),...r,children:c}):null});U.displayName="FormMessage";var $=s(97469),Q=s(34608),Z=s(13853),X=s(23076),W=s(79882),V=s(70072),G=s(71420),J=s(2689),Y=s(72343),ee=s(80649),et=s(96456),es=s.n(et),ea=s(96212),en=s(4898),el=s(22751);function er(e){var t;let{team:s}
1=e,l=(0,n.cc)(),i=(0,en.Yi)(s.id,!0),o=(0,en.LM)(s.id),d=(null==(t=i.data)?void 0:t.pages.flatMap(e=>e.reviews))||[];return(0,a.jsxs)("section",{className:"space-y-3 border-t pt-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("h5",{className:"font-medium",children:(0,a.jsx)(n.tv,{message:"Message reviews"})}),(0,a.jsx)("button",{type:"button",className:"text-sm underline",disabled:i.isFetching,onClick:()=>void i.refetch(),children:(0,a.jsx)(n.tv,{message:"Refresh"})})]}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:(0,a.jsx)(n.tv,{message:"Approve the saved content, recipient, topic, account, and schedule. Changing a message requires a new review. Reviews expire after seven days; receipts remain for 30 days."})}),i.isLoading?(0,a.jsx)("p",{children:(0,a.jsx)(n.tv,{message:"Loading messagesâ¦"})}):null,i.error?(0,a.jsx)("p",{role:"alert",children:(0,a.jsx)(n.tv,{message:"Message reviews could not be loaded."})}):null,o.error?(0,a.jsx)("p",{role:"alert",children:(0,z.lX)(o.error,l,"The review could not be changed. Refresh its status before trying again.")}):null,i.isLoading||i.error||d.length?null:(0,a.jsx)("p",{className:"text-sm",children:(0,a.jsx)(n.tv,{message:"No message reviews on this page."})}),d.map(e=>{var t;let i=Date.parse(e.expiresAt)<=Date.now(),d="pending"===e.status;return(0,a.jsxs)("article",{className:"space-y-2 rounded border p-3 text-sm",children:[(0,a.jsxs)("p",{children:[(null==(t=s.users.find(t=>t.userId===e.actorId))?void 0:t.name)||(0,a.jsx)(n.tv,{message:"Former member"})," ","â ",e.peerId,e.topicId?l(" / {{value0}}",{value0:e.topicTitle||l("Topic {{id}}",{id:e.topicId})}):""," ",(0,a.jsx)(n.tv,{message:"\xb7 account"})," ",e.accountId]}),(0,a.jsxs)("p",{children:[d&&i?l("Expired"):l(e.status)," \xb7"," ",e.schedule?l("Scheduled for {{value0}}",{value0:l.dateTime(new Date(1e3*e.schedule))}):l("Send immediately after approval")]}),"html"===e.format?(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:(0,a.jsx)(n.tv,{message:"Message with Telegram formatting"})}):null,(0,a.jsx)("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap break-words rounded bg-muted p-2 font-sans",children:e.text}),e.attachments.length?(0,a.jsx)("ul",{children:e.attachments.map(e=>(0,a.jsxs)("li",{children:[e.name," (",Math.ceil(e.bytes/1024)," ",(0,a.jsx)(n.tv,{message:"KB)"})]},e.sha256))}):null,e.result?(0,a.jsx)("p",{children:e.result}):null,"executing"===e.status?(0,a.jsx)("p",{children:(0,a.jsx)(n.tv,{message:"Execution has started. Refresh for its receipt; do not submit a duplicate."})}):null,d?(0,a.jsxs)("div",{className:"flex gap-2",children:["admin"===s.myRole?(0,a.jsx)(r.$,{size:"sm",disabled:i||o.isLoading,onClick:()=>{window.confirm(l("Approve this exact message to {{value0}}{{value1}} from account {{value2}}{{value3}}?",{value0:e.peerId,value1:e.topicId?" / ".concat(e.topicTitle||l("Topic {{id}}",{id:e.topicId})):"",value2:e.accountId,value3:e.schedule?l(" at {{time}}",{time:l.dateTime(new Date(1e3*e.schedule))}):l(" now")}))&&o.mutateAsync({endpoint:"approveTeamReview",reviewId:e.id,contentHash:e.contentHash}).catch(()=>void 0)},children:(0,a.jsx)(n.tv,{message:"Approve and send"})}):(0,a.jsx)("span",{children:(0,a.jsx)(n.tv,{message:"Awaiting administrator review"})}),(0,a.jsx)(r.$,{size:"sm",variant:"outline",disabled:o.isLoading,onClick:()=>void o.mutateAsync({endpoint:"cancelTeamReview",reviewId:e.id}).catch(()=>void 0),children:(0,a.jsx)(n.tv,{message:"Cancel message"})})]}):null]},e.id)}),i.hasNextPage?(0,a.jsx)(r.$,{size:"sm",variant:"outline",disabled:i.isFetchingNextPage,onClick:()=>void i.fetchNextPage(),children:(0,a.jsx)(n.tv,{message:"Load more reviews"})}):null]})}function ei(e){var t,s,l,i,o,d,c,u,m,x,g,h,p,v,j;let{team:b}=e,y=(0,n.cc)(),{user:w}=(0,W.Z2)(),N=(0,I.PU)(),[k,C]=(0,f.useState)(!1),[S,A]=(0,f.useState)((null==(t=b.accountIds)?void 0:t[0])||""),[R,T]=(0,f.useState)("me"),[F,M]=(0,f.useState)(!1),[z,E]=(0,f.useState)(null),[L,P]=(0,f.useState)(!1),q=!!(null==(s=b.capabilities)?void 0:s.collaboration),D=(0,en.yS)(b.id,S,R,F,k&&q),O=(0,en.ct)(b.id,k&&q&&L),B=b.users.find(e=>{var t;return e.userId===(null==(t=b.capabilities)?void 0:t.billingOwnerId)});return(0,a.jsxs)("section",{className:"mt-5 space-y-3 rounded border p-4",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsxs)("h4",{className:"font-medium",children:[b.name,(0,a.jsx)(n.tv,{message:": team work"})]}),(0,a.jsx)(r.$,{size:"sm",variant:"outline",onClick:()=>C(!k),"aria-expanded":k,children:k?y("Hide"):y("Open")})]}),(0,a.jsxs)("p",{className:"text-xs text-muted-foreground",children:[(null==(l=b.capabilities)?void 0:l.seatAccounting)==="members"?y("{{value0}} / {{value1}} members under the existing team allowance.",{value0:b.users.length,value1:b.capabilities.memberLimit}):y("{{value0}} / {{value1}} seats, including pending invitations.",{value0:null!=(v=null==(i=b.capabilities)?void 0:i.occupiedSeats)?v:b.users.length,value1:null!=(j=null==(o=b.capabilities)?void 0:o.memberLimit)?j:2})," ",B?(null==(d=b.capabilities)?void 0:d.purchasedSeats)?y("{{owner}} pays for {{count}} seats.",{owner:B.name||B.email,count:b.capabilities.purchasedSeats}):y("Billing owner: {{value0}}.",{value0:B.name||B.email}):y("An administrator must select the billing owner.")]}),"admin"===b.myRole&&((null==(c=b.capabilities)?void 0:c.billingOwnerId)!==(null==w?void 0:w.uid)||(null==(u=b.capabilities)?void 0:u.purchasedSeats)===null)?(0,a.jsx)(r.$,{size:"sm",variant:"outline",disabled:N.isLoading,onClick:()=>{window.confirm(y("Use your current Chiho subscription and purchased
1seat quantity for {{value0}}? This changes the team's billing owner without buying more seats.",{value0:b.name}))&&N.mutateAsync({endpoint:"claimTeamBillingOwnership",teamId:b.id}).catch(()=>void 0)},children:(0,a.jsx)(n.tv,{message:"Use my subscription for this team"})}):null,"admin"===b.myRole&&(null==(m=b.outstandingInvites)?void 0:m.length)?(0,a.jsx)("ul",{className:"space-y-1 text-xs",children:b.outstandingInvites.map(e=>(0,a.jsxs)("li",{className:"flex items-center justify-between gap-2",children:[(0,a.jsxs)("span",{children:[(0,a.jsx)(n.tv,{message:"Pending:"})," ",e]}),(0,a.jsx)("button",{type:"button",className:"underline",disabled:N.isLoading,onClick:()=>void N.mutateAsync({endpoint:"cancelTeamInvitation",teamId:b.id,email:e}).catch(()=>void 0),children:(0,a.jsx)(n.tv,{message:"Cancel invitation"})})]},e))}):null,N.error?(0,a.jsx)("p",{role:"alert",className:"text-sm text-red-600",children:(0,a.jsx)(n.tv,{message:"The team settings could not be changed. Refresh and try again."})}):null,k?(0,a.jsx)(er,{team:b}):null,k&&!q?(0,a.jsx)("p",{className:"text-sm",children:(0,a.jsx)(n.tv,{message:"Conversation assignments, assigned-work views, and 90-day activity history are included when the billing owner pays $9 for each team seat, including pending invitations."})}):null,k&&q?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-3 text-sm",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)(n.tv,{message:"Account"})," ",(0,a.jsxs)("select",{className:"rounded border bg-background p-1",value:S,onChange:e=>{A(e.target.value),E(null)},children:[(0,a.jsx)("option",{value:"",children:(0,a.jsx)(n.tv,{message:"Select shared account"})}),null==(x=b.accountIds)?void 0:x.map(e=>(0,a.jsx)("option",{value:e,children:e},e))]})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)(n.tv,{message:"Show"})," ",(0,a.jsxs)("select",{className:"rounded border bg-background p-1",value:R,onChange:e=>T(e.target.value),children:[(0,a.jsx)("option",{value:"me",children:(0,a.jsx)(n.tv,{message:"My work"})}),(0,a.jsx)("option",{value:"unassigned",children:(0,a.jsx)(n.tv,{message:"Unassigned"})}),(0,a.jsx)("option",{value:"all",children:(0,a.jsx)(n.tv,{message:"All team work"})})]})]}),(0,a.jsxs)("label",{className:"flex items-center gap-1",children:[(0,a.jsx)("input",{type:"checkbox",checked:F,onChange:e=>M(e.target.checked)}),(0,a.jsx)(n.tv,{message:"Overdue only"})]}),(0,a.jsx)("button",{type:"button",className:"underline",onClick:()=>void D.refetch(),disabled:!S||D.isFetching,children:(0,a.jsx)(n.tv,{message:"Refresh"})})]}),(null==(g=b.accountIds)?void 0:g.length)?null:(0,a.jsx)("p",{className:"text-sm",children:(0,a.jsx)(n.tv,{message:"Share conversations with this team to add team work."})}),S&&D.isLoading?(0,a.jsx)("p",{children:(0,a.jsx)(n.tv,{message:"Loading team workâ¦"})}):null,D.error?(0,a.jsx)("p",{role:"alert",children:(0,a.jsx)(n.tv,{message:"Team work could not be loaded."})}):null,null==(h=D.data)?void 0:h.pages.flatMap(e=>e.conversations).map(e=>(0,a.jsxs)("article",{className:"rounded border p-3",children:[(0,a.jsx)("button",{type:"button",className:"font-medium underline",onClick:()=>E(z===e.peer?null:e.peer),children:e.title}),(0,a.jsx)("ul",{className:"mt-1 list-inside list-disc text-sm",children:e.tasks.map(e=>(0,a.jsxs)("li",{children:[e.why," ",(0,a.jsx)(n.tv,{message:"â due"})," ",e.due.slice(0,10)]},e.taskId))}),z===e.peer?(0,a.jsx)(el.v,{teamId:b.id,accountId:S,peerId:e.peer}):null]},"".concat(e.accountId,":").concat(e.peer))),D.hasNextPage?(0,a.jsx)(r.$,{size:"sm",variant:"outline",disabled:D.isFetchingNextPage,onClick:()=>void D.fetchNextPage(),children:(0,a.jsx)(n.tv,{message:"Load more conversations"})}):null,(0,a.jsx)("button",{type:"button",className:"block text-sm underline",onClick:()=>P(!L),"aria-expanded":L,children:L?y("Hide activity history"):y("Show activity history")}),L?(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:(0,a.jsx)(n.tv,{message:"Last 90 days. History starts when team activity recording is enabled."})}),O.isLoading?(0,a.jsx)("p",{children:(0,a.jsx)(n.tv,{message:"Loading activityâ¦"})}):null,O.error?(0,a.jsx)("p",{role:"alert",children:(0,a.jsx)(n.tv,{message:"Activity could not be loaded."})}):null,(0,a.jsx)("ul",{className:"space-y-1 text-xs",children:null==(p=O.data)?void 0:p.pages.flatMap(e=>e.events).map(e=>{var t;return(0,a.jsxs)("li",{children:[(0,a.jsx)("time",{dateTime:e.occurredAt,children:y.dateTime(new Date(e.occurredAt))})," ","\xb7"," ",(null==(t=b.users.find(t=>t.userId===e.actorId))?void 0:t.name)||(0,a.jsx)(n.tv,{message:"Former member"}
1)," ","\xb7 ",y(e.action.replaceAll("."," "))," \xb7"," ",y(e.source)]},e.id)})}),O.hasNextPage?(0,a.jsx)(r.$,{size:"sm",variant:"outline",disabled:O.isFetchingNextPage,onClick:()=>void O.fetchNextPage(),children:(0,a.jsx)(n.tv,{message:"Load earlier activity"})}):null]}):null]}):null]})}let eo=ea.Ik({name:ea.Yj().min(2,{message:"Team Name must be at least 2 characters."}).max(30,{message:"Team Name must not be longer than 30 characters."})}),ed=[{meta:{displayName:"Team Name"},header:"Team Name",id:"name",cell:e=>{let{row:t}=e,s=(0,n.cc)(),[l,r]=(0,f.useState)(!1),[i,o]=(0,f.useState)(t.original.name),{mutateAsync:d,isLoading:c}=(0,I.eB)(),u=async()=>{r(!1),""!==i&&void 0!==i&&await d({teamId:t.original.id,name:i})},m=async e=>{"Enter"===e.key&&(e.preventDefault(),await u())},x=async()=>{await u()};return(0,a.jsxs)("div",{className:"group flex items-center",children:[(0,a.jsx)("div",{className:"w-full ".concat(l?"":"truncate break-words"),onClick:()=>{r(!0)},children:l?(0,a.jsx)("input",{type:"text",value:i,onBlur:x,onKeyDown:m,onChange:e=>o(e.target.value),placeholder:s("Edit name"),autoFocus:!0,className:"flex h-10 w-full rounded-md border-none bg-transparent py-2 text-sm r
1ing-transparent file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder-opacity-50 focus-visible:outline-none focus-visible:ring-0 focus-visible:ring-offset-0"}):(0,a.jsx)("span",{children:i})}),(0,a.jsx)("div",{children:c?(0,a.jsx)(F.A,{size:4}):"admin"===t.original.myRole&&(0,a.jsx)(J.A,{onClick:()=>r(!0),className:"h-4 w-4 cursor-pointer flex-shrink-0 text-muted-foreground/80 transition duration-300 ease-in-out hover:scale-110 dark:text-muted-foreground/50"})})]})},size:50},{meta:{displayName:"Members"},header:"Members",id:"members",cell:e=>{var t,s;let{row:l}=e,{mutateAsync:r,isLoading:i}=(0,I.QN)(),{mutateAsync:o}=(0,I.RZ)(),{includeQueue:d,handleQueueChange:c}=((e,t)=>{let{users:s=[],id:a}=e.original||{},[n,l]=(0,f.useState)([]),[r,i]=(0,f.useState)([]);return(0,f.useEffect)(()=>{l(s.map(e=>!e.queued)),i(s.map(e=>e.queued))},[]),{includeFree:n,includeQueue:r,handleFreeChange:async(e,s,n)=>{l(t=>{let s=[...t];return s[n]=e,s}),i(t=>{let s=[...t];return s[n]=!e,s}),await t({userId:s,queued:!e,teamId:a})},handleQueueChange:async(e,s,n)=>{i(t=>{let s=[...t];return s[n]=e,s}),l(t=>{let s=[...t];return s[n]=!e,s}),await t({userId:s,queued:e,teamId:a})}}})(l,o),{user:u}=(0,W.Z2)();return(0,a.jsx)("ul",{className:"list-disc",children:null==(s=l.original)||null==(t=s.users)?void 0:t.map((e,t)=>(0,a.jsxs)("li",{className:"mb-2 flex items-center",children:[(0,a.jsxs)("div",{className:"flex flex-grow items-center gap-2",children:[e.email,"admin"===e.role&&(0,a.jsx)("span",{className:"flex-shrink-0 text-muted-foreground/80 dark:text-muted-foreground/50",children:(0,a.jsx)(n.tv,{message:"Admin"})}),u&&e.email===u.email&&(0,a.jsx)("span",{className:"flex-shrink-0 text-muted-foreground/80 dark:text-muted-foreground/50",children:(0,a.jsx)(n.tv,{message:"(me)"})}),"admin"===l.original.myRole&&"member"===e.role&&(0,a.jsx)(a.Fragment,{children:i?(0,a.jsx)(F.A,{size:4}):(0,a.jsx)(Y.A,{onClick:()=>r({userId:e.userId,teamId:l.original.id}),className:"h-4 w-4 cursor-pointer flex-shrink-0 text-muted-foreground/80 transition duration-300 ease-in-out hover:scale-110 dark:text-muted-foreground/50"})})]}),(0,a.jsx)("div",{className:"flex-grow"}),"admin"!==e.role&&(0,a.jsxs)("div",{style:{alignItems:"center",display:"flex",justifyContent:"space-between"},children:[(0,a.jsxs)($.jc,{children:[(0,a.jsx)($.d0,{children:(0,a.jsxs)("label",{htmlFor:"includeQueue-".concat(t),className:"mr-2 flex items-center gap-2",children:[(0,a.jsx)(n.tv,{message:"Queue"}),(0,a.jsx)(ee.A,{className:"h-4 w-4 text-muted-foreground/80 dark:text-muted-foreground/50"})]})}),(0,a.jsx)($.Et,{children:(0,a.jsx)(n.tv,{message:"When enabled, this team member's messages will require admin a
1pproval before being sent."})})]}),(0,a.jsx)(X.d,{id:"includeQueue-".concat(t),checked:d[t],onCheckedChange:s=>c(s,e.userId,t),className:"flex-shrink-0",isDisabled:"admin"!==l.original.myRole})]})]},e.userId))})},size:120},{meta:{displayName:"Outstanding Invites"},header:"Outstanding Invites",id:"outstandingInvites",cell:e=>{var t,s;let{row:n}=e;return(0,a.jsx)("ul",{className:"list-disc",children:null==(s=n.original)||null==(t=s.outstandingInvites)?void 0:t.map(e=>(0,a.jsx)("li",{children:e},e))})},size:100},{id:"inviteUser",cell:e=>{var t;let{row:s}=e,l=(0,n.cc)(),{mutateAsync:o,isLoading:d,isSuccess:c,error:u,reset:m}=(0,I.aD)(),[x,g]=(0,f.useState)(""),[h,p]=(0,f.useState)(!1),{refetch:v}=(0,I.KH)(),j=s.original.capabilities,b=(null==j?void 0:j.seatAccounting)==="members",y=!(null==j?void 0:j.paid)&&!(null==j?void 0:j.availableSeats),w=(null==j?void 0:j.paid)&&!(null==j?void 0:j.availableSeats),N=e=>{e?m():(g(""),p(!1),c&&v())};return(0,a.jsxs)("div",{className:"flex flex-col",children:[(0,a.jsx)(i.A,{title:l("Invite to Team"),isLoading:d,isSuccess:c,successMessage:"Invite sent!",setIsOpen:p,onOpenChange:N,open:h,error:u?{body:(null==u?void 0:u.message)||"",message:l("Failed to sent invite")}:void 0,content:(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"mb-3",children:(0,a.jsx)(n.tv,{message:"Enter your team mate's email"})}),(0,a.jsx)(Q.p,{id:"emailInput",className:"form-control mb-1",placeholder:l("Email"),autoCapitalize:"none",autoComplete:"usernameInput",autoCorrect:"off",type:"email",value:x,onChange:e=>g(e.target.value)})]}),handleSubmit:async()=>{try{await o({email:x,teamId:s.original.id}),(0,V.eE)("team_member_invited",{invitation_type:"email"}),v()}catch(e){console.error(e)}},trigger:(0,a.jsx)(r.$,{className:"h-8",disabled:(null==(t=s.original)?void 0:t.myRole)!=="admin"||y||w,onClick:()=>N(!0),children:(0,a.jsx)(n.tv,{message:"Invite Team Member"})})}),(null==j?void 0:j.ownerSelectionRequired)?(0,a.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:(0,a.jsx)(n.tv,{message:"Select the team billing owner below before inviting members."})}):y&&(0,a.jsxs)("p",{className:"mt-2 text-xs text-muted-foreground",children:[b?l("Existing team member allowance reached ({{value0}} members).",{value0:null==j?void 0:j.memberLimit}):l("Free team allowance reached (2 seats, including invitations).")," ",(0,a.jsx)(es(),{href:"/profile/payment?teamId=".concat(encodeURIComponent(s.original.id)),className:"text-primary hover:underline",children:(0,a.jsx)(n.tv,{message:"Upgrade to Pro"})})]}),w&&(0,a.jsxs)("p",{className:"mt-2 text-xs text-muted-foreground",children:[b?l("Existing team member allowance reached ({{value0}} members).",{value0:null==j?void 0:j.memberLimit}):l("Purchased seat allowance reached, including pending invitations.")," ",(0,a.jsx)(es(),{href:"/profile/payment?teamId=".concat(encodeURIComponent(s.original.id)),className:"text-primary hover:underline",children:(0,a.jsx)(n.tv,{message:"Manage seats"})})]})]})},enableResizing:!1,size:60},{id:"actions",cell:e=>{let{row:t}=e;return(0,a.jsx)(M,{row:t,teamId:t.original.id})},size:5}];function ec(){let e=(0,n.cc)(),t=(0,I.A6)(),{mutateAsync:s}=(0,I.tK)(),{user:i}=(0,W.Z2)(),o=(0,L.mN)({resolver:(0,G.u)(eo),mode:"onChange"});return(0,a.jsx)(l.A,{layoutType:"profile",children:(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"text-lg font-medium",children:(0,a.jsx)(n.tv,{message:"My Teams"})}),(0,a.jsx)("p",{className:"mb-4 text-sm text-muted-foreground",children:(0,a.jsx)(n.tv,{message:"Share leads, assign work, and review outgoing messages together across Chiho and connected AI clients."})}),0===t.length?(0,a.jsx)(n.tv,{message:"You are not a part of any teams yet"}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(k,{isToolBarDisplayed:!1,isPaginationDisplayed:!1,pagination:{pageIndex:0,pageSize:10},columns:ed,data:t}),t.map(e=>(0,a.jsx)(ei,{team:e},e.id))]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"mb-4 text-lg font-medium",children:(0,a.jsx)(n.tv,{message:"Create a new Team"})}),(0,a.jsx)(L.Op,{...o,children:(0,a.jsxs)("form",{className:"flex flex-row items-center space-x-4",onSubmit:o.handleSubmit(e=>s(null==e?void 0:e.name)),children:[(0,a.jsx)(O,{control:o.control,name:"name",render:t=>{let{field:s}=t;return(0,a.jsx)(_,{children:(0,a.jsx)(H,{children:(0,a.jsx)(Q.p,{...s,placeholder:e("Team Name"),className:"space-y-0"})})})}}),(0,a.jsx)(r.$,{type:"submit",children:(0,a.jsx)(n.tv,{message:"Create Team"})}),(0,a.jsx)("div",{className:"h-4",children:(0,a.jsx)(U,{})})]})})]}),(0,a.jsx)(Z.w,{})]})})}var eu=s(73920),em=s(33391);let ex=(0,eu.A)((0,em.A)(function(){return(0,a.jsx)(ec,{})}))},15379:(e,t,s)=>{"use strict";s.d(t,{Bz:()=>m,nQ:()=>d,te:()=>x});var a=s(14254),n=s(95778),l=s(70643),r=s(90124),i=s(22699),o=s(52969);let d=["getTemplates"],c=async()=>await (0,o.getAuthenticated)("getTemplates"),u=async e=>{let t=await (0,o.postAuthenticated)("saveBotMessage",{text:e.text});return null==t?void 0:t.data};function m(e){return(0,n.I)({enabled:!e,queryKey:d,staleTime:3e4,queryFn:async()=>{let{data:e}=await c();return e.data},onError:e=>{console.error(e)}})}function x(){let e=(0,a.cc)(),t=(0,l.jE)();return(0,r.n)({mutationKey:["saveBotMessage"],mutationFn:async e=>await u({text:e.text}),onSuccess:(s,a)=>{t.setQueryData(d,e=>e?{...e,botMessage:a.text}:{botMessage:a.text,templates:[]}),(0,i.oR)({title:e("Template Saved Succesfully")})},onError:e=>{console.error(e)}})}},15776:(e,t,s)=>{"use strict";s.d(t,{A0:()=>c,BF:()=>u,Hj:()=>m,XI:()=>d,nA:()=>g,nd:()=>x});var a=s(26514),n=s(75834),l=s(88920),r=s(59104),i=s(28227),o=s(27228);let d=n.forwardRef((e,t)=>
1{let{className:s,...n}=e,[i,d]=(0,r.fp)(o.Sb),[c,u]=(0,r.fp)(o.hq);return(0,a.jsx)("div",{className:"w-full overflow-auto tableclass tour-table",onScroll:e=>{d(e.target.scrollLeft>50),u(e.target.scrollTop>50)},children:(0,a.jsx)("table",{ref:t,className:(0,l.cn)("w-full caption-bottom text-sm",s),...n})})});d.displayName="Table";let c=n.forwardRef((e,t)=>{let{className:s,...n}=e;return(0,a.jsx)("thead",{ref:t,className:(0,l.cn)("[&_tr]:border-b",s,"sticky top-0 bg-background z-20"),...n})});c.displayName="TableHeader";let u=n.forwardRef((e,t)=>{let{className:s,...n}=e;return(0,a.jsx)("tbody",{ref:t,className:(0,l.cn)("[&_tr:last-child]:border-0",s),...n})});u.displayName="TableBody",n.forwardRef((e,t)=>{let{className:s,...n}=e;return(0,a.jsx)("tfoot",{ref:t,className:(0,l.cn)("bg-primary font-medium text-primary-foreground",s),...n})}).displayName="TableFooter";let m=n.forwardRef((e,t)=>{let{className:s,...n}=e;return(0,a.jsx)("tr",{ref:t,className:(0,l.cn)("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",s),...n})});m.displayName="TableRow";let x=n.forwardRef((e,t)=>{let{className:s,columnId:d,isFirstColumn:c=!1,...u}=e,[m]=(0,r.fp)(o.Sb),[x,g]=(0,r.fp)(o.Rh),[h,p]=(0,n.useState)(!1);return(0,a.jsxs)("th",{ref:t,className:(0,l.cn)("h-12 px-4 text-left align-middle font-medium text-muted-foreground relative th-draggable",{"sticky left-0 bg-background z-20":m&&d&&x[d]},s),...u,children:[u.children,m&&d&&x[d]&&(0,a.jsx)("button",{onClick:()=>{d&&g({...x,[d]:!x[d]})},className:"absolute top-1/2 right-5 transform -translate-y-1/2 your-button-styles",children:(0,a.jsx)(i.A,{className:"h-4 w-4 text-muted-foreground"})}),!c&&(0,a.jsx)("div",{onMouseDown:u.onMouseDown,onTouchStart:u.onTouchStart,className:"absolute top-0 right-0 bottom-0 w-2"})]})});x.displayName="TableHead";let g=n.forwardRef((e,t)=>{let{className:s,columnId:n,...i}=e,[d]=(0,r.fp)(o.Sb),[c]=(0,r.fp)(o.Rh),u=n&&c[n];return(0,a.jsx)("td",{ref:t,className:(0,l.cn)("p-4 align-middle [&:has([role=checkbox])]:pr-0",{"sticky left-0 bg-background z-20":d&&u},s),...i})});g.displayName="TableCell",n.forwardRef((e,t)=>{let{className:s,...n}=e;return(0,a.jsx)("caption",{ref:t,className:(0,l.cn)("mt-4 text-sm text-muted-foreground",s),...n})}).displayName="TableCaption"},21124:(e,t,s)=>{"use strict";s.d(t,{Av:()=>v,IL:()=>h});var a=s(91046),n=s(50471),l=s(14254),r=s(90124),i=s(70643),o=s(22699),d=s(25228),c=s(67574),u=s(52969),m=s(75834),x=s(66018);let g=async e=>{let{data:t}=await (0,u.postAuthenticated)("getChatsInFolder",e);return t};function h(){let e=(0,l.cc)();return(0,r.n)({mutationKey:["getChatsInFolder"],mutationFn:g,onError:t=>{(0,o.oR)({title:e("Error"),description:(0,n.lX)(t,e),variant:"destructive"})}})}let p=async e=>{try{return(await (0,u.postAuthenticated)("sendTemplateToChat",e)).data}catch(e){var t;throw console.error("sendTemplateToChat failed",{status:null==e||null==(t=e.response)?void 0:t.status}),e}};function v(e){let t=(0,l.cc)(),s=(0,i.jE)(),u=(0,c.sh)(),g=(0,m.useRef)((0,x.I)());return(0,r.n)({mutationKey:["sendTemplateToChat"],mutationFn:async e=>{let t=!!e.outgoingTracking&&!e.tagKeyMembers,s=e.source||"batch_send",a=g.current.requestId(JSON.stringify([null==u?void 0:u.id,e]));if(e.tagKeyMembers){let n={};e.chats.forEach(t=>{var s;let a=(null==(s=t.template)?void 0:s.text)||e.template.text;n[a]||(n[a]=[]),n[a].push(t)});let l=[];for(let[r,i]of Object.entries(n)){let n={...e.template};r!==e.template.text&&(n.text=r);let o=await p({...e,template:n,chats:i,teamId:null==u?void 0:u.id,requestId:a,...t?{trackOutgoing:!0,async:!0,source:s}:{}});l.push(o)}return["failed","unknown"].includes((0,x.K)(l))||g.current.complete(a),l}{let n=await p({...e,teamId:null==u?void 0:u.id,requestId:a,...t?{trackOutgoing:!0,async:!0,source:s}:{}});return["failed","unknown"].includes((0,x.K)(n))||g.current.complete(a),n}},onSuccess:(n,l)=>{let r=Array.isArray(n)?n[0]:n;if((null==r?void 0:r.accepted)&&(null==r?void 0:r.batchId))return void(0,o.oR)({title:t("Batch started"),description:t("Track progress from your Outbox!"),action:m.createElement(d.Qg,{altText:t("View Outbox"),onClick:()=>{window.location.href=(0,a._J)("/profile/outgoing/".concat(r.batchId),t.locale)}},t("View"))});s.invalidateQueries({queryKey:["teamReviews"]});let i=(0,x.K)(n);if("failed"===i||"unknown"===i)return void(0,o.oR)({title:"unknown"===i?t("Delivery needs checking"):t("Some messages could not be processed"),description:t("Open the teamâs message reviews to inspect each recipientâs result before retrying."),variant:"destructive"});let c=!1;r&&r.message&&"string"==typeof r.message&&(c=r.message.toLowerCase().includes("queued")),!c&&r&&r.report&&(c=Object.values(r.report).some(e=>"string"==typeof e&&e.toLowerCase().includes("queued"))),c?(0,o.oR)({title:t("Message queued successfully"),description:t("Check the teams page to view all queued messages.")}):(0,o.oR)({title:e?t("Message sent successfully."):t("Template sent successfully.")})},onError:e=>{var s,a,l,r,i;let d="Failed to send message";if(null==(a=e.response)||null==(s=a.data)?void 0:s.message)d=e.response.data.message;else if("Network Error"===e.message&&(null==(l=e.config)?void 0:l.data))try{let t=JSON.parse(e.config.data);((null==(r=t.template)?void 0:r.file)||(null==(i=t.template)?void 0:i.files))&&(d="File too large. Maximum size is 10MB.")}catch(e){}(0,o.oR)({title:t("Error"),description:(0,n.lX)({message:d},t),variant:"destructive"})}})}},22751:(e,t,s)=>{"use strict";s.d(t,{v:()=>h});var a=s(26514),n=s(50471),l=s(14254),r=s(75834),i=s(4898),o=s(67574),d=s(14684),c=s(34608),u=s(28608);function m(e,t){return(0,n.lX)(e,t,"The change could not be saved. Refresh to check the latest state before retrying.")}function x(e){let{team:t,selected:s}=e;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("option",{value:"",children:(0,a.jsx)(l.tv,{message:"Unassigned"})}),!s||(null==t?void 0:t.users.some(e=>e.userId===s))?null:(0,a.jsx)("option",{value:s,children:(0,a.jsx)(l.tv,{message:"Former member"})}),null==t?void 0:t.users.map(e=>(0,a.jsx)("option",{value:e.userId,children:e.name||e.email}
1,e.userId))]})}function g(e){var t;let{target:s,team:n,initial:o,onClose:u}=e,g=(0,l.cc)(),[h,p]=(0,r.useState)((null==o?void 0:o.assigneeId)||""),[v,f]=(0,r.useState)((null==o?void 0:o.handoverNote)||""),[j,b]=(0,r.useState)((null==o||null==(t=o.dueAt)?void 0:t.slice(0,10))||""),y=(0,r.useRef)((null==o?void 0:o.revision)||0),w=(0,i.pO)(s.teamId);return(0,a.jsxs)("form",{className:"space-y-2 rounded border p-2",onSubmit:async e=>{e.preventDefault();try{await w.mutateAsync({endpoint:"assignTeamConversation",...s,assigneeId:h||null,handoverNote:v,dueAt:j?new Date("".concat(j,"T23:59:59Z")).toISOString():null,expectedRevision:y.current}),u()}catch(e){}},children:[(0,a.jsxs)("label",{className:"block text-xs",children:[(0,a.jsx)(l.tv,{message:"Conversation owner"}),(0,a.jsx)("select",{className:"mt-1 w-full rounded border bg-background p-1",value:h,onChange:e=>p(e.target.value),children:(0,a.jsx)(x,{team:n,selected:h})})]}),(0,a.jsxs)("label",{className:"block text-xs",children:[(0,a.jsx)(l.tv,{message:"Handover note"}),(0,a.jsx)("textarea",{className:"mt-1 w-full rounded border bg-background p-1",value:v,maxLength:2e3,onChange:e=>f(e.target.value)})]}),(0,a.jsxs)("label",{className:"block text-xs",children:[(0,a.jsx)(l.tv,{message:"Due date (UTC)"}),(0,a.jsx)(c.p,{type:"date",value:j,onChange:e=>b(e.target.value)})]}),w.error?(0,a.jsx)("p",{role:"alert",className:"text-xs text-red-600",children:m(w.error,g)}):null,(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$,{size:"sm",type:"submit",disabled:w.isLoading,children:(0,a.jsx)(l.tv,{message:"Save handover"})}),(0,a.jsx)(d.$,{size:"sm",variant:"ghost",type:"button",onClick:u,children:(0,a.jsx)(l.tv,{message:"Cancel"})})]})]})}function h(e){var t,s,n,h;let{teamId:p,accountId:v,peerId:f}=e,j=(0,l.cc)(),b={teamId:p,accountId:v,peerId:f},y=(0,o.A6)().find(e=>e.id===p),w=(0,i.sq)(b),N=(0,i.pO)(p),k=(0,u.xh)(),[C,I]=(0,r.useState)(!1),[S,A]=(0,r.useState)(""),[R,T]=(0,r.useState)(""),[F,M]=(0,r.useState)(()=>new Date(Date.now()+864e5).toISOString().slice(0,10)),z=(0,r.useRef)(),E=(null==y||null==(t=y.capabilities)?void 0:t.collaboration)===!0,L=(null==(s=w.data)?void 0:s.assignment)||null,P=(null==(n=w.data)?void 0:n.tasks)||[];async function q(e,t){try{await N.mutateAsync({endpoint:"updateTeamTask",...b,taskId:e.taskId,expectedRevision:e.revision||0,...t})}catch(e){}}return(0,a.jsxs)("div",{className:"mt-2 space-y-3 text-sm",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsxs)("span",{children:[(0,a.jsx)(l.tv,{message:"Owner:"})," ",(null==L?void 0:L.assigneeId)?(null==y||null==(h=y.users.find(e=>e.userId===L.assigneeId))?void 0:h.name)||(0,a.jsx)(l.tv,{message:"Former member"}):j("Unassigned")]}),(0,a.jsx)("button",{type:"button",className:"text-xs underline",onClick:()=>void w.refetch(),disabled:w.isFetching,children:(0,a.jsx)(l.tv,{message:"Refresh"})})]}),(null==L?void 0:L.handoverNote)?(0,a.jsx)("p",{className:"whitespace-pre-wrap text-xs",children:L.handoverNote}):null,(null==L?void 0:L.dueAt)?(0,a.jsxs)("p",{className:"text-xs text-muted-foreground",children:[(0,a.jsx)(l.tv,{message:"Handover due"})," ",L.dueAt.slice(0,10)]}):null,C?(0,a.jsx)(g,{target:b,team:y,initial:L,onClose:()=>I(!1)}):E?(0,a.jsx)(d.$,{size:"sm",variant:"outline",onClick:()=>I(!0),children:(0,a.jsx)(l.tv,{message:"Assign / hand over"})}):null,w.isLoading?(0,a.jsx)("p",{children:(0,a.jsx)(l.tv,{message:"Loading shared tasksâ¦"})}):null,w.error?(0,a.jsx)("p",{role:"alert",children:m(w.error,j)}):null,P.map(e=>(0,a.jsxs)("div",{className:"space-y-1 rounded border p-2",children:[(0,a.jsxs)("label",{className:"flex items-start gap-2",children:[(0,a.jsx)("input",{type:"checkbox",checked:"done"===e.status,disabled:"done"===e.status||N.isLoading,onChange:()=>void q(e,{completed:!0})}),(0,a.jsx)("span",{className:"done"===e.status?"line-through text-muted-foreground":"",children:e.why})]}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,a.jsx)("select",{"aria-label":j("Assignee for {{value0}}",{value0:e.why}),className:"rounded border bg-background p-1 text-xs",value:e.assigneeId||"",disabled:!E||N.isLoading,onChange:t=>void q(e,{assigneeId:t.target.value||null}),children:(0,a.jsx)(x,{team:y,selected:e.assigneeId})}),(0,a.jsx)("input",{type:"date","aria-label":j("Due date for {{value0}} (UTC)",{value0:e.why}),className:"rounded border bg-background p-1 text-xs",value:e.due.slice(0,10),disabled:"done"===e.status||N.isLoading,onChange:t=>{t.target.value&&q(e,{due:"".concat(t.target.value,"T23:59:59Z")})}})]})]},e.taskId)),(0,a.jsxs)("form",{className:"space-y-2",onSubmit:async e=>{if(e.preventDefault(),S.trim()){z.current||(z.current=crypto.randomUUID());try{await N.mutateAsync({endpoint:"addTeamTask",...b,why:S.trim(),due:"".concat(F,"T23:59:59Z"),assigneeId:E&&R?R:null,idempotencyKey:z.current}),A(""),z.current=void 0}catch(e){}}},children:[(0,a.jsx)(c.p,{"aria-label":j("New shared task"),placeholder:j("Add shared task"),value:S,maxLength:2e3,onChange:e=>{A(e.target.value),z.current=void 0},required:!0}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,a.jsx)("select",{"aria-label":j("New task assignee"),className:"rounded border bg-background p-1 text-xs",disabled:!E,value:R,onChange:e=>{T(e.target.value),z.current=void 0},children:(0,a.jsx)(x,{team:y,selected:R})}),(0,a.jsx)("input",{type:"date","aria-label":j("New task due date (UTC)"),className:"rounded border bg-background p-1 text-xs",value:F,required:!0,onChange:e=>{M(e.target.value),z.current=void 0}}),(0,a.jsx)(d.$,{size:"sm",type:"submit",disabled:N.isLoading||!S.trim(),children:(0,a.jsx)(l.tv,{message:"Add task"})})]})]}),N.error?(0,a.jsx)("p",{role:"alert",className:"text-xs text-red-600",children:m(N.error,j)}):null,(0,a.jsx)("button",{type:"button",className:"text-xs underline",disabled:k.isLoading,onClick:async()=>{try{await k.mutateAsync({teamId:p,accountId:v,chatId:f}),await w.refetch()}catch(e){}},children:(0,a.jsx)(l.tv,{message:"Suggest tasks with Chiho AI"})}),k.error?(0,a.jsx)("p",{role:"alert",className:"text-xs text-red-600",children:m(k.error,j)}):null,E?null:(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:(0,a.jsx)(l.tv,{message:"Assignments and activity history are included when the billing owner has purchased enough seats for members and pending invitations."})})]})}},23076:(e,t,s)=>{"use strict";s.d(t,{d:()=>i});var a=s(26514),n=s(75834),l=s(8114),r=s(88920);let i=n.forwardRef((e,t)=>
1{let{className:s,isDisabled:n,...i}=e;return(0,a.jsx)(l.bL,{...i,disabled:n,className:(0,r.cn)("peer inline-flex h-[24px] w-[44px] shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background","data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",{"opacity-50":n,"cursor-not-allowed":n},s),ref:t,children:(0,a.jsx)(l.zi,{className:"pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0"})})});i.displayName="Switch"},26233:(e,t,s)=>{"use strict";function a(e){let{loading:t,pathname:s,ready:a,user:n}=e;return t||a||null!=n||"/"===s?null:"/"}function n(e){let{isLoading:t,pathname:s,user:a}=e;return t||null==a||a.telegramConnected||"/connectTelegram"===s?null:"/connectTelegram"}s.d(t,{P:()=>a,o:()=>n})},33391:(e,t,s)=>{"use strict";s.d(t,{A:()=>o});var a=s(26514),n=s(46225),l=s(75834),r=s(22198),i=s(26233);let o=function(e){return t=>{let s=(0,n.useRouter)(),{isLoading:o,data:d}=(0,r.be)();return((0,l.useEffect)(()=>{let e=(0,i.o)({isLoading:o,pathname:s.pathname,user:d});e&&s.push(e)},[d,o,s]),o)?null:d&&d.telegramConnected?(0,a.jsx)(e,{...t}):null}}},46055:(e,t,s)=>{"use strict";s.d(t,{A:()=>p});var a=s(26514),n=s(14254),l=s(99322),r=s(13853),i=s(88920),o=s(96456),d=s.n(o),c=s(77470),u=s(14684),m=s(75834),x=s(90153);function g(e){let{className:t,items:s,...l}=e,r=(0,c.usePathname)();return(0,a.jsx)("nav",{className:(0,i.cn)("flex flex-wrap space-x-2 lg:flex-col lg:space-x-0 lg:space-y-1",t),...l,children:s.map(e=>(0,a.jsxs)("div",{className:(0,i.cn)("flex flex-wrap space-x-2 lg:flex-col lg:space-x-0 mb-4",t),children:[(0,a.jsx)("h2",{className:"mb-2 px-4 text-lg font-semibold tracking-tight",children:(0,a.jsx)(n.tv,{message:e.title})}),e.items.map(e=>(0,a.jsx)("div",{className:"inline-flex mb-1 items-center justify-start",children:e.enabled?(0,a.jsx)(d(),{href:e.href,children:(0,a.jsxs)("button",{className:(0,i.cn)((0,u.r)({variant:"ghost"}),(null==r?void 0:r.replace(/^\/(?:ru|zh)(?=\/|$)/,""))===e.href?"bg-muted hover:bg-muted":"","justify-start"),children:[x[e.icon]&&(0,m.createElement)(x[e.icon],{className:"h-3.5 w-3.5 text-muted-foreground/80 dark:text-muted-foreground/50 flex-shrink-0 mr-2"}),(0,a.jsx)(n.tv,{message:e.title})]})}):(0,a.jsxs)("button",{disabled:!0,className:(0,i.cn)((0,u.r)({variant:"ghost"}),"justify-start cursor-not-allowed opacity-50"),children:[x[e.icon]&&(0,m.createElement)(x[e.icon],{className:"h-3.5 w-3.5 text-muted-foreground/80 dark:text-muted-foreground/50 flex-shrink-0 mr-2"}),(0,a.jsx)(n.tv,{message:e.title})]})},e.href))]},e.title))})}let h=[{title:"Profile",items:[{title:"Profile",href:"/profile",icon:"User",enabled:!0},{title:"My Teams",href:"/profile/teams",icon:"Users2",enabled:!0},{title:"Billing",href:"/profile/payment",icon:"CreditCard",enabled:!0},{title:"AI Agent Access",href:"/profile/agent-access",icon:"Bot",enabled:!0}]},{title:"Tools",items:[{title:"Backup Contacts",href:"/profile/contacts",icon:"Contact",enabled:!0},{title:"Batch Send",href:"/profile/templates",icon:"FileText",enabled:!0},{title:"Outbox",href:"/profile/outgoing",icon:"Inbox",enabled:!0},{title:"AI Messaging",href:"/profile/auto-reply-followup",icon:"MessageSquare",enabled:!0},{title:"Conversation workflows",href:"/profile/conversation-workflows",icon:"MessagesSquare",enabled:!0},{title:"Analytics",href:"/profile/analytics",icon:"BarChart4",enabled:!0},{title:"Invite Friends",href:"/profile/invites",icon:"Coins",enabled:!0}]}];function p(e){let{children:t,layoutType:s,isMaxWidthRestricted:i,hideProfileHeading:o=!1}=e,d=(0,n.cc)(),c=s.charAt(0).toUpperCase()+s.slice(1);return(0,a.jsxs)("div",{className:"flex flex-col min-h-screen space-y-6 p-10",style:{minHeight:"calc(100vh - 64px)"},children:[!o&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"space-y-0.5",children:[(0,a.jsx)("h2",{className:"text-2xl font-bold tracking-tight",children:d(c)}),(0,a.jsx)("p",{className:"text-muted-foreground",children:d("Manage your profile settings.")})]}),(0,a.jsx)(r.w,{className:"my-6"})]}
1),(0,a.jsxs)("div",{className:"flex flex-col flex-grow space-y-8 lg:flex-row lg:space-x-12 lg:space-y-0",children:[(0,a.jsx)("aside",{className:"-mx-4 lg:w-48",children:(0,a.jsx)(g,{items:h})}),(0,a.jsx)("div",{className:"min-w-0 flex-1 ".concat(i?"lg:max-w-6xl":"lg:w-4/5"),children:t})]}),(0,a.jsx)(l.Z,{messageBot:!0,messagePromotion:!1})]})}},73920:(e,t,s)=>{"use strict";s.d(t,{A:()=>o});var a=s(26514),n=s(46225),l=s(75834),r=s(79882),i=s(26233);let o=function(e){return t=>{let{user:s,loading:o,ready:d}=(0,r.Z2)(),c=(0,n.useRouter)();return((0,l.useEffect)(()=>{let e=(0,i.P)({loading:o,pathname:c.pathname,ready:d,user:s});e&&c.push(e)},[s,o,d,c]),o)?null:s&&d?(0,a.jsx)(e,{...t}):null}}},83794:(e,t,s)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/profile/teams",function(){return s(15019)}])}},e=>{e.O(0,[5389,3116,2787,6558,9865,3227,9691,9254,6801,9433,6958,349,504,6212,276,1420,2969,9882,9322,6523,3118,9017,5529,8829,636,6593,8792],()=>e(e.s=83794)),_N_E=e.O()}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.