PageSourceSearch

https://thetool.company/_next/static/chunks/2h9luzt6wxhz1.js

js thetool.company collected 2026-09-24 15:00:28 UTC 187,471 bytes, 1 lines download raw bytes

1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,440742,e=>{"use strict";var t=e.i(843476),n=e.i(271645),a=e.i(21218),r=e.i(287751),s=e.i(474911),i=e.i(494913),o=e.i(227516),l=e.i(941388),c=e.i(788699),d=e.i(727612),u=e.i(466261),m=e.i(662031),p=e.i(595468),h=e.i(795465),x=e.i(210578),f=e.i(459648);let g={created:{label:"created this",icon:l.Plus,color:"text-emerald-600"},updated:{label:"made changes",icon:c.Pencil,color:"text-blue-600"},deleted:{label:"deleted this",icon:d.Trash2,color:"text-red-600"},status_changed:{label:"changed status",icon:u.ArrowRightLeft,color:"text-amber-600"},stage_changed:{label:"changed stage",icon:u.ArrowRightLeft,color:"text-amber-600"},assigned:{label:"reassigned this",icon:f.AddPersonIcon,color:"text-violet-600"},shared:{label:"shared this",icon:m.Share2,color:"text-blue-600"},completed:{label:"completed this",icon:p.CheckCircle2,color:"text-emerald-600"},closed:{label:"closed this",icon:p.CheckCircle2,color:"text-emerald-600"}};function b({log:e}){var n;let a=g[n=e.action]??{label:n.replace(/_/g," "),icon:o.History,color:"text-muted-foreground"},r=a.icon,s=e.actor?.full_name??null;return(0,t.jsxs)("div",{className:"flex gap-3 py-2 relative",children:[(0,t.jsxs)("div",{className:"relative shrink-0 z-10",children:[s?(0,t.jsx)(x.ContactAvatar,{imageUrl:e.actor?.avatar_url,name:s,size:"sm"}):(0,t.jsx)("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center squircle bg-muted",children:(0,t.jsx)(r,{className:`h-4 w-4 ${a.color}`})}),s&&(0,t.jsx)("div",{className:"absolute -bottom-0.5 -right-0.5 flex h-4 w-4 items-center justify-center rounded-full bg-background border border-border",children:(0,t.jsx)(r,{className:`h-2.5 w-2.5 ${a.color}`})})]}),(0,t.jsxs)("div",{className:"flex-1 min-w-0 pt-0.5",children:[(0,t.jsxs)("div",{className:"flex items-baseline gap-2 flex-wrap",children:[(0,t.jsxs)("span",{className:"text-sm",children:[(0,t.jsx)("span",{className:"font-semibold",children:s??"Someone"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:" · "}),(0,t.jsx)("span",{className:"font-medium",children:a.label})]}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:(0,i.formatDistanceToNow)(new Date(e.created_at),{addSuffix:!0})})]}),(0,t.jsx)(y,{log:e})]})]})}function y({log:e}){let n=e.metadata?.name??e.metadata?.title??e.metadata?.subject;if(e.changes&&Object.keys(e.changes).length>0){let n=Object.entries(e.changes);return(0,t.jsx)("div",{className:"mt-1 space-y-0.5",children:n.map(([e,n])=>{var a;let r,s;return(0,t.jsxs)("div",{className:"text-xs text-muted-foreground",children:[(0,t.jsx)("span",{className:"font-medium text-foreground/70",children:(0,h.getFieldLabel)(e)})," changed ",(r=j((a=n).from),s=j(a.to),null===r?(0,t.jsxs)(t.Fragment,{children:["to ",(0,t.jsx)("span",{className:"text-foreground/80",children:s??(0,t.jsx)("span",{className:"italic",children:"empty"})})]}):(0,t.jsxs)(t.Fragment,{children:["from ",(0,t.jsx)("span",{className:"line-through opacity-60",children:r})," → ",(0,t.jsx)("span",{className:"text-foreground/80",children:s??(0,t.jsx)("span",{className:"italic",children:"empty"})})]}))]},e)})})}return n?(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:v(n)}):null}function j(e){if(null==e||""===e)return null;if("string"==typeof e)return v(e);if("number"==typeof e||"boolean"==typeof e)return String(e);try{return v(JSON.stringify(e))}catch{return String(e)}}function v(e,t=80){return e.length<=t?e:e.slice(0,t)+"…"}function w(){return(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("div",{className:"absolute left-[15px] top-4 bottom-4 w-px bg-muted-foreground/15"}),(0,t.jsx)("div",{className:"space-y-1",children:Array.from({length:5}).map((e,n)=>(0,t.jsxs)("div",{className:"flex gap-3 py-2 relative",children:[(0,t.jsx)("div",{className:"h-8 w-8 shrink-0 squircle bg-muted animate-pulse z-10"}),(0,t.jsxs)("div",{className:"flex-1 min-w-0 pt-0.5 space-y-1.5",children:[(0,t.jsx)("div",{className:"h-3.5 w-1/3 rounded bg-muted animate-pulse"}
1),(0,t.jsx)("div",{className:"h-3 w-1/2 rounded bg-muted/70 animate-pulse"})]})]},n))})]})}e.s(["ActivityTab",0,function({logs:e,entityType:i,entityId:o}){let{data:l,isLoading:c}=(0,r.useCachedFetch)(`/api/audit?entityType=${encodeURIComponent(i)}&entityId=${encodeURIComponent(o)}`),d=(0,n.useMemo)(()=>{let t=l?.logs??[];return[...e.map(e=>({kind:"activity",key:`a-${e.id}`,at:new Date(e.created_at).getTime(),log:e})),...t.map(e=>({kind:"audit",key:`e-${e.id}`,at:new Date(e.created_at).getTime(),log:e}))].sort((e,t)=>t.at-e.at)},[e,l]);return c&&0===d.length?(0,t.jsx)(w,{}):0===d.length?(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[(0,t.jsx)(a.Activity,{className:"h-8 w-8 mb-2 opacity-40"}),(0,t.jsx)("p",{className:"text-sm",children:"No activity yet."})]}):(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("div",{className:"absolute left-[15px] top-4 bottom-4 w-px bg-muted-foreground/25"}),(0,t.jsx)("div",{className:"space-y-1",children:d.map(e=>"activity"===e.kind?(0,t.jsx)(s.ActivityRow,{log:e.log},e.key):(0,t.jsx)(b,{log:e.log},e.key))})]})}],440742)},25532,e=>{"use strict";var t=e.i(843476),n=e.i(271645),a=e.i(431343),r=e.i(495242),s=e.i(503116),i=e.i(151898),o=e.i(475682),l=e.i(555436),c=e.i(687130),d=e.i(37727),u=e.i(788042),m=e.i(210578),p=e.i(213788),h=e.i(167881),x=e.i(23750),f=e.i(947627),g=e.i(821875),b=e.i(29383),y=e.i(447170),j=e.i(330009),v=e.i(611423),w=e.i(920755),N=e.i(826902),k=e.i(440160),_=e.i(90382);function C({url:e}){let s=(0,n.useRef)(null),[i,o]=(0,n.useState)(!1),[l,c]=(0,n.useState)(0),[d,u]=(0,n.use
1State)(0);function m(e){let t=Math.floor(e/60),n=Math.floor(e%60);return`${t}:${n.toString().padStart(2,"0")}`}return(0,n.useEffect)(()=>{let t=new Audio(e);return s.current=t,t.addEventListener("loadedmetadata",()=>u(t.duration)),t.addEventListener("timeupdate",()=>c(t.currentTime)),t.addEventListener("ended",()=>o(!1)),()=>{t.pause(),t.remove()}},[e]),(0,t.jsxs)("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-muted/50",children:[(0,t.jsx)(h.Button,{variant:"ghost",size:"sm",className:"rounded-3xl h-7 w-7 p-0 shrink-0",onClick:function(){s.current&&(i?s.current.pause():s.current.play(),o(!i))},children:i?(0,t.jsx)(r.Pause,{className:"h-3.5 w-3.5"}):(0,t.jsx)(a.Play,{className:"h-3.5 w-3.5"})}),(0,t.jsxs)("div",{className:"flex-1 flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-[10px] text-muted-foreground font-mono w-8",children:m(l)}),(0,t.jsx)(_.Slider,{value:[l],max:d||100,step:.1,onValueChange:function(e){s.current&&(s.current.currentTime=e[0],c(e[0]))},className:"flex-1"}),(0,t.jsx)("span",{className:"text-[10px] text-muted-foreground font-mono w-8",children:m(d)})]}),(0,t.jsx)("a",{href:`${e}?download=1`,download:!0,className:"shrink-0",children:(0,t.jsx)(h.Button,{variant:"ghost",size:"sm",className:"rounded-3xl h-7 w-7 p-0",children:(0,t.jsx)(k.Download,{className:"h-3 w-3"})})})]})}var S=e.i(531278),T=e.i(497960),D=e.i(55487),D=D,P=e.i(630275),P=P,I=e.i(63209),$=e.i(63804),R=e.i(972520),M=e.i(760757),M=M,L=e.i(178583),E=e.i(267331),A=e.i(978200),F=e.i(846696),z=e.i(647163),O=e.i(502072),U=e.i(783618);let q={connected:"Connected",voicemail:"Voicemail",no_answer:"No answer",invalid_number:"Invalid",gatekeeper:"Gatekeeper",busy:"Busy",left_voicemail:"Left voicemail",callback_scheduled:"Callback",meeting_booked:"Meeting",not_interested:"Not interested",referred:"Referred",info_sent:"Info sent"};function B({callLogId:e,manualDisposition:a}){let[r,s]=(0,n.useState)(null),[i,o]=(0,n.useState)(!0),l=(0,n.useRef)(null),[c,d]=(0,n.useState)(!1),u=(0,n.useCallback)(async()=>{try{let t=await fetch(`/api/twilio/calls/${e}/transcript`);if(!t.ok)return null;return(await t.json()).transcript}catch{return null}},[e]);if((0,n.useEffect)(()=>{let e=!1,t=async()=>{let n=await u();e||(s(n),o(!1),n?.status==="analyzing"&&(l.current=setTimeout(t,4e3)))};return t(),()=>{e=!0,l.current&&clearTimeout(l.current)}},[u]),i)return(0,t.jsxs)("div",{className:"rounded-lg border px-3 py-3 bg-muted/10 space-y-2",children:[(0,t.jsx)(v.Skeleton,{className:"h-3 w-40"}),(0,t.jsx)(v.Skeleton,{className:"h-3 w-full"}),(0,t.jsx)(v.Skeleton,{className:"h-3 w-2/3"})]});if(!r)return null;if("analyzing"===r.status)return(0,t.jsxs)("div",{className:"rounded-lg border px-3 py-3 bg-muted/10 flex items-center gap-2 text-xs",children:[(0,t.jsx)(S.Loader2,{className:"h-3.5 w-3.5 animate-spin text-muted-foreground"}),(0,t.jsx)("span",{children:"Analyzing call transcript…"})]});if("failed"===r.status)return(0,t.jsx)("div",{className:"rounded-lg border border-amber-300/60 bg-amber-50 dark:bg-amber-950/20 dark:border-amber-700/40 px-3 py-2 text-xs",children:(0,t.jsxs)("div",{className:"flex items-start gap-2",children:[(0,t.jsx)(I.AlertCircle,{className:"h-3.5 w-3.5 mt-0.5 text-amber-600 shrink-0"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-medium text-amber-900 dark:text-amber-200",children:"Analysis failed"}),r.error&&(0,t.jsx)("p",{className:"text-amber-800/80 dark:text-amber-300/80 break-words",children:r.error})]})]})});let m=r.transcript_paragraphs??[],p=r.objections??[],h=r.action_items??[],x=r.next_steps??[],f=r.key_moments??[],g=r.disposition_confidence??0,b=a&&r.auto_disposition&&a!==r.auto_disposition;return(0,t.jsxs)("div",{className:"rounded-lg border bg-background overflow-hidden",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-wrap px-3 py-2 border-b bg-muted/20",children:[(0,t.jsx)(A.SparkleIcon,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),(0,t.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:"AI analysis"}),r.auto_disposition&&(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-[11px] font-medium bg-primary/10 text-primary",children:[q[r.auto_disposition]||r.auto_disposition,(0,t.jsxs)("span",{className:"text-[10px] text-primary/70 tabular-nums",children:[Math.round(100*g),"%"]})]}),r.sentiment&&(0,t.jsx)(J,{sentiment:r.sentiment}),b&&(0,t.jsxs)("span",{className:(0,U.tonePillClass)("attention"),children:[(0,t.jsx)(I.AlertCircle,{className:"h-2.5 w-2.5"}),"Manual: ",q[a]||a," ≠ AI: ",q[r.auto_disposition]||r.auto_disposition]})]}),(0,t.jsxs)("div",{className:"p-3 sm:p-4 space-y-4",children:[r.summary&&(0,t.jsx)("p",{className:"text-sm leading-relaxed",children:r.summary}),r.disposition_rationale&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground italic border-l-2 border-border pl-2",children:r.disposition_rationale}),h.length>0&&(0,t.jsx)(G,{title:"Action items",icon:$.ListChecks,children:(0,t.jsx)("ul",{className:"space-y-1.5",children:h.map((e,n)=>(0,t.jsxs)("li",{className:"text-sm leading-snug",children:[(0,t.jsxs)("span",{className:"font-medium",children:[e.assignee||"Unassigned",":"]}
1)," ",(0,t.jsx)("span",{children:e.item}),(0,t.jsxs)("span",{className:"text-muted-foreground",children:[" - Due: ",(0,t.jsx)("span",{className:"text-foreground/80 font-medium",children:e.due||"TBD"})]}),e.uncertain&&(0,t.jsx)(K,{})]},n))})}),x.length>0&&(0,t.jsx)(G,{title:"Next steps",icon:R.ArrowRight,children:(0,t.jsx)("ul",{className:"space-y-1",children:x.map((e,n)=>(0,t.jsxs)("li",{className:"flex gap-2 items-start text-sm",children:[(0,t.jsx)(R.ArrowRight,{className:"h-3 w-3 mt-1 text-muted-foreground shrink-0"}),(0,t.jsx)("span",{children:e})]},n))})}),p.length>0&&(0,t.jsx)(G,{title:"Objections",icon:M.default,children:(0,t.jsx)("ul",{className:"space-y-2",children:p.map((e,n)=>(0,t.jsxs)("li",{className:"text-sm",children:[(0,t.jsx)("p",{className:"font-medium leading-snug",children:e.objection}),e.response&&(0,t.jsxs)("p",{className:"text-xs text-muted-foreground mt-0.5",children:["→ ",e.response]})]},n))})}),f.length>0&&(0,t.jsx)(G,{title:"Key moments",icon:A.SparkleIcon,children:(0,t.jsx)("ul",{className:"space-y-1.5",children:f.map((e,n)=>(0,t.jsxs)("li",{className:"text-sm",children:[(0,t.jsxs)("div",{className:"flex items-baseline gap-2 flex-wrap",children:[(0,t.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wide",children:e.label}),"number"==typeof e.at&&(0,t.jsx)("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:X(e.at)})]}),(0,t.jsxs)("p",{className:"text-xs italic text-foreground/80",children:["“",e.quote,"”"]})]},n))})}),m.length>0&&(0,t.jsxs)("div",{children:[(0,t.jsxs)("button",{onClick:()=>d(e=>!e),className:"flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground hover:text-foreground transition-colors",children:[(0,t.jsx)(L.FileText,{className:"h-3 w-3"}),"Full transcript (",m.length,")",(0,t.jsx)(O.AnimatedChevron,{open:c,degOpen:180,degClosed:0,className:"h-3 w-3"})]}),c&&(0,t.jsx)(H,{callLogId:e,paragraphs:m,onChange:e=>s(t=>t?{...t,transcript_paragraphs:e}:t)})]})]})]})}function H({callLogId:e,paragraphs:n,onChange:a}){let r=e=>"Agent"===e?"oklch(0.55 0.08 240)":"oklch(0.55 0.08 155)",s=async t=>{let n=await fetch(`/api/twilio/calls/${e}/transcript`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({transcript_paragraphs:t})});if(!n.ok){let e=await n.json().catch(()=>({}));return F.toast.error(e.error||"Failed to save transcript edit"),!1}return a(t),!0};return(0,t.jsx)("div",{className:"mt-2 space-y-2 max-h-[50vh] overflow-y-auto pr-1",children:n.map((e,a)=>(0,t.jsxs)("div",{className:"flex gap-2.5",children:[(0,t.jsx)("span",{className:"h-5 w-5 rounded-full flex items-center justify-center text-[9px] font-semibold text-white shrink-0 mt-0.5",style:{background:r(e.speaker)},title:e.speaker,children:e.speaker.charAt(0)}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,t.jsx)("span",{className:"text-[11px] font-medium",style:{color:r(e.speaker)},children:e.speaker}),(0,t.jsx)("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:X(e.start)})]}),(0,t.jsx)(V,{text:e.text,onSave:async t=>{let r=t.trim();return r===e.text||s(n.map((e,t)=>t===a?{...e,text:r}:e))}})]})]},a))})}function V({text:e,onSave:a}){let[r,s]=(0,n.useState)(!1),[i,o]=(0,n.useState)(e),l=(0,n.useRef)(null),c=(0,n.useRef)(!1);(0,n.useEffect)(()=>{o(e)},[e]),(0,n.useEffect)(()=>{r&&l.current&&(l.current.focus(),l.current.select(),W(l.current))},[r]);let d=async()=>{if(!c.current){c.current=!0;try{let t=i.trim();if(!t||t===e){o(e),s(!1);return}await a(t)?s(!1):o(e)}finally{c.current=!1}}};return r?(0,t.jsx)("textarea",{ref:l,value:i,onChange:e=>{o(e.target.value),W(e.currentTarget)},onBlur:d,onKeyDown:t=>{"Enter"!==t.key||t.shiftKey||(t.preventDefault(),d()),"Escape"===t.key&&(t.preventDefault(),o(e),s(!1))},rows:1,className:"w-full text-sm leading-snug bg-transparent px-1 -mx-1 py-0 outline-none resize-none caret-foreground"}):(0,t.jsx)("button",{type:"button",onClick:()=>s(!0),className:"text-left w-full text-sm leading-snug rounded-sm px-1 -mx-1 cursor-text hover:underline underline-offset-2 decoration-foreground
1/30",title:"Click to edit",children:e})}function W(e){e.style.height="auto",e.style.height=`${e.scrollHeight}px`}function G({title:e,icon:n,children:a}){return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 mb-1.5",children:[(0,t.jsx)(n,{className:"h-3 w-3 text-muted-foreground"}),(0,t.jsx)("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:e})]}),a]})}function J({sentiment:e}){let{Icon:n,label:a,cls:r}=(()=>{switch(e){case"positive":return{Icon:T.Smile,label:"Positive",cls:"bg-emerald-100 text-emerald-800 dark:bg-emerald-950/40 dark:text-emerald-300"};case"negative":return{Icon:P.default,label:"Negative",cls:"bg-red-100 text-red-800 dark:bg-red-950/40 dark:text-red-300"};case"mixed":return{Icon:D.default,label:"Mixed",cls:"bg-amber-100 text-amber-800 dark:bg-amber-950/40 dark:text-amber-300"};default:return{Icon:D.default,label:"Neutral",cls:"bg-muted text-muted-foreground"}}})();return(0,t.jsxs)("span",{className:(0,z.cn)("inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-medium",r),children:[(0,t.jsx)(n,{className:"h-2.5 w-2.5"}),a]})}function K(){return(0,t.jsxs)("span",{className:"ml-2 inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-amber-100 dark:bg-amber-900/30 text-amber-800 dark:text-amber-300 text-[10px] font-medium uppercase tracking-wide",children:[(0,t.jsx)(E.HelpCircle,{className:"h-2.5 w-2.5"}),"Uncertain"]})}function X(e){let t=Math.max(0,Math.floor(e)),n=Math.floor(t/60);return`${n}:${(t%60).toString().padStart(2,"0")}`}var Z=e.i(679880),Q=e.i(362597),Y=e.i(341256);let ee={connected:{label:"Connected",color:"var(--ring-1)"},meeting_booked:{label:"Meeting",color:"var(--ring-2)"},callback_scheduled:{label:"Callback",color:"var(--ring-5)"},info_sent:{label:"Info Sent",color:"var(--ring-2)"},referred:{label:"Referred",color:"var(--ring-4)"},gatekeeper:{label:"Gatekeeper",color:"var(--ring-3)"},voicemail:{label:"Voicemail",color:"var(--ring-3)"},left_voicemail:{label:"Left VM",color:"var(--ring-3)"},no_answer:{label:"No Answer",color:"var(--ring-7)"},busy:{label:"Busy",color:"var(--ring-3)"},not_interested:{label:"Not Interested",color:"var(--ring-6)"},invalid_number:{label:"Invalid",color:"var(--ring-6)"}};function et({disposition:e}){let n=ee[e];return n?(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-[11px] font-medium whitespace-nowrap text-foreground/80",style:{backgroundColor:`color-mix(in oklch, ${n.color} 28%, transparent)`},children:[(0,t.jsx)("span",{className:"h-2 w-2 rounded-full shrink-0",style:{backgroundColor:n.color}}),n.label]}):(0,t.jsx)("span",{className:"text-[10px] text-muted-foreground",children:e})}e.s(["CallHistory",0,function({contactId:e,companyId:k,recordTaskId:_,limit:S=100,compact:T=!1}){let D,{calls:P,loading:I,refetch:$}=function(e={}){let{contactId:t,companyId:a,recordTaskId:r,limit:s=50}=e,[i,o]=(0,n.useState)([]),[l,c]=(0,n.useState)(!0),d=(0,n.useCallback)(async()=>{let e=new URLSearchParams;t&&e.set("contactId",t),a&&e.set("companyId",a),r&&e.set("recordTaskId",r),e.set("limit",s.toString());try{let t=await fetch(`/api/twilio/call/history?${e}`);if(t.ok){let e=await t.json();o(e)}}catch{}finally{c(!1)}},[t,a,r,s]);return(0,n.useEffect)(()=>{d();let e=(0,w.createClient)(),n=t?{filter:`contact_id=eq.${t}`}:a?{filter:`company_id=eq.${a}`}:{},r=e.channel("call-logs-changes").on("postgres_changes",{event:"*",schema:"public",table:"call_logs",...n},()=>{d()}).subscribe();return()=>{e.removeChannel(r)}},[d,t,a]),{calls:i,loading:l,refetch:d}}({contactId:e,companyId:k,recordTaskId:_,limit:S}),[R,M]=(0,n.useState)(null),[L,E]=(0,n.useState)(""),[A,z]=(0,n.useState)("all"),[O,U]=(0,n.useState)("all"),[q,H]=(0,n.useState)(null),[V,W]=(0,n.useState)(!1),{sortColumn:G,sortDir:J,handleSort:K}=(0,N.useTableSort)("time","desc"),{getColumnStyle:X,getResizeProps:en}=(0,g.useColumnResize)("call-history"),ea=(0,n.useMemo)(()=>{let e=P;if(L){let t=L.toLowerCase();e=e.filter(e=>(e.contact?.name||"").toLowerCase().includes(t)||e.from_number.includes(t)||e.to_number.includes(t)||(e.notes||"").toLowerCase().includes(t))}return"all"!==A&&(e=e.filter(e=>e.disposition===A)),"all"!==O&&(e=e.filter(e=>e.direction===O)),G&&(e=[...e].sort((e,t)=>
1(function(e,t,n,a){let r=0;switch(n){case"contact":r=(e.contact?.name||"").localeCompare(t.contact?.name||"");break;case"from":r=e.from_number.localeCompare(t.from_number);break;case"to":r=e.to_number.localeCompare(t.to_number);break;case"disposition":r=(e.disposition||"").localeCompare(t.disposition||"");break;case"duration":r=(e.duration_seconds||0)-(t.duration_seconds||0);break;case"time":r=new Date(e.created_at).getTime()-new Date(t.created_at).getTime()}return"asc"===a?r:-r})(e,t,G,J))),e},[P,L,A,O,G,J]),er=(0,n.useCallback)(async()=>{if(q){W(!0);try{(0,Q.deleteWithUndo)({message:"Call log deleted",keys:[`calls:${q}`],onCommitted:()=>$(),onError:()=>F.toast.error("Failed to delete"),commit:async()=>{if(!(await fetch(`/api/twilio/call/${q}`,{method:"DELETE"})).ok)throw Error("Delete failed")}})}catch{F.toast.error("Failed to delete")}finally{W(!1),H(null)}}},[q,$]);if(I)return T?(0,t.jsx)("div",{className:"space-y-1 py-2",children:Array.from({length:4}).map((e,n)=>(0,t.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2",children:[(0,t.jsx)(v.Skeleton,{className:"h-3 w-3 rounded-full shrink-0"}),(0,t.jsx)(v.Skeleton,{className:"h-3 w-32 rounded-full flex-1"}),(0,t.jsx)(v.Skeleton,{className:"h-3.5 w-14 rounded-full"}),(0,t.jsx)(v.Skeleton,{className:"h-3 w-10 rounded-full"})]},n))}):(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(v.Skeleton,{className:"h-8 w-[180px] rounded-full"}),(0,t.jsx)(v.Skeleton,{className:"h-8 w-[120px] rounded-md"}),(0,t.jsx)(v.Skeleton,{className:"h-8 w-[100px] rounded-md"}),(0,t.jsx)("div",{className:"flex-1"}),(0,t.jsx)(v.Skeleton,{className:"h-3 w-12 rounded-full"})]}),(0,t.jsx)("div",{className:"rounded-lg border overflow-hidden",children:(0,t.jsxs)(f.Table,{children:[(0,t.jsx)(f.TableHeader,{children:(0,t.jsxs)(f.TableRow,{className:"hover:bg-transparent",children:[(0,t.jsx)(f.TableHead,{className:"text-xs",children:"Contact"}),(0,t.jsx)(f.TableHead,{className:"text-xs",children:"From"}),(0,t.jsx)(f.TableHead,{className:"text-xs",children:"To"}),(0,t.jsx)(f.TableHead,{className:"text-xs",children:"Disposition"}),(0,t.jsx)(f.TableHead,{className:"text-xs text-center",children:"Duration"}),(0,t.jsx)(f.TableHead,{className:"text-xs text-center",children:"Recording"}),(0,t.jsx)(f.TableHead,{className:"text-xs text-right",children:"Time"}),(0,t.jsx)(f.TableHead,{className:"w-8"})]})}),(0,t.jsx)(f.TableBody,{children:Array.from({length:8}).map((e,n)=>(0,t.jsxs)(f.TableRow,{className:"hover:bg-transparent",children:[(0,t.jsx)(f.TableCell,{children:(0,t.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,t.jsx)(v.Skeleton,{className:"h-8 w-8 rounded-[10px] shrink-0"}),(0,t.jsx)(v.Skeleton,{className:"h-4 w-28"})]})}),(0,t.jsx)(f.TableCell,{children:(0,t.jsx)(v.Skeleton,{className:"h-3.5 w-24"})}),(0,t.jsx)(f.TableCell,{children:(0,t.jsx)(v.Skeleton,{className:"h-3.5 w-24"})}),(0,t.jsx)(f.TableCell,{children:(0,t.jsx)(v.Skeleton,{className:"h-5 w-20 rounded-full"})}),(0,t.jsx)(f.TableCell,{children:(0,t.jsx)(v.Skeleton,{className:"h-3.5 w-10 mx-auto"})}),(0,t.jsx)(f.TableCell,{children:(0,t.jsx)(v.Skeleton,{className:"h-6 w-6 rounded-full mx-auto"})}),(0,t.jsx)(f.TableCell,{children:(0,t.jsx)(v.Skeleton,{className:"h-3.5 w-16 ml-auto"})}),(0,t.jsx)(f.TableCell,{})]},n))})]})})]});if(0===P.length&&!L&&"all"===A)return(0,t.jsxs)("div",{className:"py-8 text-center text-sm text-muted-foreground",children:[(0,t.jsx)(u.IPhoneIcon,{className:"h-6 w-6 mx-auto mb-2 opacity-30"}),"No call history yet"]});if(T)return(0,t.jsx)("div",{className:"divide-y",children:P.slice(0,S).map(e=>(0,t.jsxs)("div",{className:"px-3 py-2 text-xs",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[e.contact&&(0,t.jsx)(m.ContactAvatar,{imageUrl:e.contact.image_url,name:e.contact.name||"?",size:"xs"}),"inbound"===e.direction?(0,t.jsx)(i.PhoneIncoming,{className:"h-3 w-3 shrink-0",style:{color:"var(--ring-2)"}}):(0,t.jsx)(o.PhoneOutgoing,{className:"h-3 w-3 shrink-0",style:{color:"var(--ring-1)"}}),(0,t.jsx)("span",{className:"font-medium truncate flex-1",children:e.contact?.name||(0,Z.formatPhoneDisplay)("outbound"===e.direction?e.to_number:e.from_number)}),e.disposition&&(0,t.jsx)(et,{disposition:e.disposition}),e.recording_url&&(0,t.jsx)(h.Button,{variant:"ghost",size:"sm",className:"rounded-3xl h-5 w-5 p-0 shrink-0",onClick:()=>M(R===e.id?null:e.id),children:R===e.id?(0,t.jsx)(r.Pause,{className:"h-2.5 w-2.5"}):(0,t.jsx)(a.Play,{className:"h-2.5 w-2.5"})})]}),R===e.id&&(0,t.jsxs)("div",{className:"mt-2 space-y-2",children:[e.recording_url&&(0,t.jsx)(C,{url:`/api/twilio/recordings/${e.id}`}),(0,t.jsx)(B,{callLogId:e.id,manualDisposition:e.disposition})]})]},e.id))});let es=[...new Set(P.map(e=>
1e.disposition).filter(Boolean))];return(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,t.jsxs)("div",{className:"relative flex-1 min-w-[140px] max-w-[200px]",children:[(0,t.jsx)(l.Search,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),(0,t.jsx)(x.Input,{placeholder:"Search calls...",value:L,onChange:e=>E(e.target.value),className:"pl-8 h-8 text-xs rounded-full bg-muted/60 border-border/40"}),L&&(0,t.jsx)("button",{onClick:()=>E(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:(0,t.jsx)(d.X,{className:"h-3 w-3"})})]}),(0,t.jsx)(y.SearchableSelect,{value:A,onValueChange:z,size:"sm",placeholder:"Disposition",className:"w-auto min-w-[120px]",triggerIcon:(0,t.jsx)(c.Filter,{className:"h-3 w-3 text-muted-foreground"}),options:[{value:"all",label:"All dispositions"},...es.map(e=>({value:e,label:ee[e]?.label||e}))]}),(0,t.jsx)(y.SearchableSelect,{value:O,onValueChange:U,size:"sm",placeholder:"Direction",className:"w-auto min-w-[100px]",options:[{value:"all",label:"All"},{value:"outbound",label:"Outbound"},{value:"inbound",label:"Inbound"}]}),(0,t.jsxs)("span",{className:"text-[11px] text-muted-foreground ml-auto",children:[ea.length," call",1!==ea.length?"s":""]})]}),(0,t.jsx)("div",{className:"rounded-lg border overflow-hidden",children:(0,t.jsxs)(f.Table,{children:[(0,t.jsx)(f.TableHeader,{children:(0,t.jsxs)(f.TableRow,{children:[(0,t.jsx)(b.SortableTableHead,{columnId:"contact",label:"Contact",sortColumn:G,sortDir:J,onSort:K,className:"text-xs",style:X("contact"),extra:(0,t.jsx)(f.TableResizeHandle,{...en("contact")})}),(0,t.jsx)(b.SortableTableHead,{columnId:"from",label:"From",sortColumn:G,sortDir:J,onSort:K,className:"text-xs",style:X("from"),extra:(0,t.jsx)(f.TableResizeHandle,{...en("from")})}),(0,t.jsx)(b.SortableTableHead,{columnId:"to",label:"To",sortColumn:G,sortDir:J,onSort:K,className:"text-xs",style:X("to"),extra:(0,t.jsx)(f.TableResizeHandle,{...en("to")})}),(0,t.jsx)(b.SortableTableHead,{columnId:"disposition",label:"Disposition",sortColumn:G,sortDir:J,onSort:K,className:"text-xs",style:X("disposition"),extra:(0,t.jsx)(f.TableResizeHandle,{...en("disposition")})}),(0,t.jsx)(b.SortableTableHead,{columnId:"duration",label:"Duration",sortColumn:G,sortDir:J,onSort:K,className:"text-xs text-center",style:X("duration"),extra:(0,t.jsx)(f.TableResizeHandle,{...en("duration")})}),(0,t.jsxs)(f.TableHead,{className:"text-xs text-center",style:X("recording"),children:["Recording",(0,t.jsx)(f.TableResizeHandle,{...en("recording")})]}),(0,t.jsx)(b.SortableTableHead,{columnId:"time",label:"Time",sortColumn:G,sortDir:J,onSort:K,className:"text-xs text-right",style:X("time"),extra:(0,t.jsx)(f.TableResizeHandle,{...en("time")})}),(0,t.jsx)(f.TableHead,{className:"text-xs w-8"})]})}),(0,t.jsx)(f.TableBody,{children:0===ea.length?(0,t.jsx)(f.TableRow,{children:(0,t.jsx)(f.TableCell,{colSpan:8,className:"text-center py-6 text-xs text-muted-foreground",children:"No calls match your filters"})}):ea.map(e=>{let n,l,c,d,x,g;return(0,t.jsxs)(f.TableRow,{className:"group",children:[(0,t.jsx)(f.TableCell,{children:(0,t.jsxs)("div",{className:"flex items-center gap-2.5",children:[e.contact?(0,t.jsx)(m.ContactAvatar,{imageUrl:e.contact.image_url,name:e.contact.name||"?",size:"sm"}):e.company?(0,t.jsx)(p.CompanyLogo,{domain:e.company.domain??null,companyName:e.company.name,logoUrl:e.company.logo_url??null,size:"xs",className:"!h-8 !w-8 shrink-0"}):(0,t.jsx)("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center squircle bg-muted",children:(0,t.jsx)(u.IPhoneIcon,{className:"h-3.5 w-3.5 text-muted-foreground/50"})}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:["inbound"===e.direction?(0,t.jsx)(i.PhoneIncoming,{className:"h-3 w-3 shrink-0",style:{color:"var(--ring-2)"}}):(0,t.jsx)(o.PhoneOutgoing,{className:"h-3 w-3 shrink-0",style:{color:"var(--ring-1)"}}),(0,t.jsx)("span",{className:"text-sm font-medium truncate max-w-[140px]",children:e.contact?.name||e.company?.name||"-"})]}),e.notes&&(0,t.jsx)("p",{className:"text-[10px] text-muted-foreground truncate max-w-[160px] mt-0.5",children:e.notes})]})]})}),(0,t.jsx)(f.TableCell,{children:(0,t.jsx)("span",{className:"text-xs font-mono text-muted-foreground",children:(0,Z.formatPhoneDisplay)(e.from_number)})}),(0,t.jsx)(f.TableCell,{children:(0,t.jsx)("span",{className:"text-xs font-mono text-muted-foreground",children:(0,Z.formatPhoneDisplay)(e.to_number)})}),(0,t.jsx)(f.TableCell,{children:e.disposition?(0,t.jsx)(et,{disposition:e.disposition}):(0,t.jsx)("span",{className:"text-[10px] text-muted-foreground
1/50",children:"-"})}),(0,t.jsx)(f.TableCell,{className:"text-center",children:e.duration_seconds>0?(0,t.jsxs)("span",{className:"inline-flex items-center gap-0.5 text-xs text-muted-foreground font-mono",children:[(0,t.jsx)(s.Clock,{className:"h-2.5 w-2.5"}),function(e){if(!e)return"0:00";let t=Math.floor(e/60);return`${t}:${(e%60).toString().padStart(2,"0")}`}(e.duration_seconds)]}):(0,t.jsx)("span",{className:"text-[10px] text-muted-foreground/50",children:"-"})}),(0,t.jsx)(f.TableCell,{className:"text-center",children:e.recording_url?(0,t.jsx)(h.Button,{variant:"ghost",size:"sm",className:"rounded-3xl h-6 w-6 p-0 mx-auto",onClick:()=>M(R===e.id?null:e.id),title:"Play recording",children:R===e.id?(0,t.jsx)(r.Pause,{className:"h-3 w-3"}):(0,t.jsx)(a.Play,{className:"h-3 w-3"})}):(0,t.jsx)("span",{className:"text-[10px] text-muted-foreground/50",children:"-"})}),(0,t.jsx)(f.TableCell,{className:"text-right",children:(0,t.jsx)("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:(n=new Date(e.created_at),l=new Date,c=n.toDateString()===l.toDateString(),(d=new Date(l)).setDate(d.getDate()-1),x=n.toDateString()===d.toDateString(),g=n.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit"}),c?g:x?`Yesterday ${g}`:`${n.toLocaleDateString("en-GB",{day:"numeric",month:"short"})} ${g}`)})}),(0,t.jsx)(f.TableCell,{children:(0,t.jsx)(h.Button,{variant:"ghost",size:"sm",className:"rounded-3xl h-6 w-6 p-0 opacity-0 group-hover:opacity-100 transition-opacity text-muted-foreground hover:text-destructive",onClick:()=>H(e.id),title:"Delete call log",children:(0,t.jsx)(Y.TrashIcon,{className:"h-3 w-3"})})})]},e.id)})})]})}),R&&((D=P.find(e=>e.id===R))?(0,t.jsxs)("div",{className:"space-y-3",children:[D.recording_url&&(0,t.jsx)("div",{className:"rounded-lg border p-3 bg-muted/20",children:(0,t.jsx)(C,{url:`/api/twilio/recordings/${D.id}`})}),(0,t.jsx)(B,{callLogId:D.id,manualDisposition:D.disposition})]}):null),(0,t.jsx)(j.AlertDialog,{open:!!q,onOpenChange:e=>!e&&H(null),children:(0,t.jsxs)(j.AlertDialogContent,{children:[(0,t.jsxs)(j.AlertDialogHeader,{children:[(0,t.jsx)(j.AlertDialogTitle,{children:"Delete call log?"}),(0,t.jsx)(j.AlertDialogDescription,{children:"This will permanently remove this call record. This action cannot be undone."})]}),(0,t.jsxs)(j.AlertDialogFooter,{children:[(0,t.jsx)(j.AlertDialogCancel,{disabled:V,children:"Cancel"}),(0,t.jsx)(j.AlertDialogAction,{onClick:er,disabled:V,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:V?"Deleting...":"Delete"})]})]})})]})}],25532)},428516,845919,e=>{"use strict";var t=e.i(843476),n=e.i(271645),a=e.i(522016),r=e.i(920755),s=e.i(154548),i=e.i(30590),o=e.i(306519),l=e.i(941388),c=e.i(299023),d=e.i(398361),u=e.i(37727),m=e.i(541071),p=e.i(955716),h=e.i(248256),x=e.i(174886),f=e.i(643531),g=e.i(416788),b=e.i(513744),y=e.i(765183),j=e.i(459648),v=e.i(213788),w=e.i(630374),N=e.i(59377),k=e.i(753751),_=e.i(463415),C=e.i(548106),S=e.i(751558),T=e.i(572377),D=e.i(320445),P=e.i(647163),I=e.i(952372);e.i(989308);var $=e.i(559749),R=e.i(996974),M=e.i(771238),L=e.i(27003);let E=[[/\b(ceo|chief executive|founder|co-?founder|president|owner|managing director)\b/i,0],[/\b(cto|cfo|coo|cmo|cro|chro|cio|cpo|clo|cso|chief\s+\w+\s+officer)\b/i,1],[/\b(svp|evp|vp|vice\s+president)\b/i,2],[/\b(director|head of)\b/i,3],[/\b(manager|lead|supervisor|team\s+lead|principal)\b/i,4],[/\bsenior\b/i,5]];function A(e){if(!e)return 6;for(let[t,n]of E)if(t.test(e))return n;return 6}function F(e){if(0===e.length)return[];let t=new Map;for(let n of e)t.set(n.id,{contact:n,level:A(n.job_title),children:[]});let n=[],a=new Set;for(let e of t.values()){let n=e.contact.reports_to;n&&n!==e.contact.id&&t.has(n)&&(t.get(n).children.push(e),a.add(e.contact.id))}let r=[...t.values()].filter(e=>!a.has(e.contact.id)).sort((e,t)=>e.level-t.level);if(0===r.length){for(let e of t.values())a.has(e.contact.id)||n.push(e);return n.length>0?n:[[...t.values()][0]]}if(e.some(e=>e.reports_to))for(let e of r)n.push(e);else{let e=r[0].level;for(let a of r){if(a.level===e){n.push(a);continue}let r=null,s=1/0;
1for(let e of t.values()){if(e.contact.id===a.contact.id||e.level>=a.level)continue;let t=a.level-e.level;(t<s||t===s&&r&&e.children.length<r.children.length)&&(s=t,r=e)}r?r.children.push(a):n.push(a)}}let s=(e,t)=>e.level-t.level||e.contact.name.localeCompare(t.contact.name);return n.sort(s),n.forEach(function e(t){t.children.sort(s),t.children.forEach(e)}),n}function z(e){let t=new Set;return!function e(n){for(let a of n.children)t.add(a.contact.id),e(a)}(e),t}function O(e,t){for(let n of e){if(n.contact.id===t)return n;let e=O(n.children,t);if(e)return e}return null}e.s(["buildOrgTree",0,F,"findNode",0,O,"getDescendantIds",0,z,"getTitleLevel",0,A],845919);let U={bg:(0,L.rgb)(1,1,1),card:(0,L.rgb)(.961,.957,.929),border:(0,L.rgb)(.88,.875,.86),fg:(0,L.rgb)(.271,.271,.271),muted:(0,L.rgb)(.45,.447,.435),dim:(0,L.rgb)(.6,.597,.585),dimmer:(0,L.rgb)(.7,.697,.685),white:(0,L.rgb)(1,1,1),li:(0,L.rgb)(.039,.4,.761),edge:(0,L.rgb)(.82,.817,.805),success:(0,L.rgb)(.067,.639,.537),warning:(0,L.rgb)(.843,.471,.173),destructive:(0,L.rgb)(.776,.184,.298),mutedDot:(0,L.rgb)(.72,.717,.705)},q={gray:(0,L.rgb)(.55,.55,.55),darkgray:(0,L.rgb)(.4,.4,.4),blue:(0,L.rgb)(.235,.478,.859),green:(0,L.rgb)(.063,.725,.506),yellow:(0,L.rgb)(.878,.667,.122),orange:(0,L.rgb)(.878,.486,.161),red:(0,L.rgb)(.878,.282,.282),violet:(0,L.rgb)(.545,.361,.965),pink:(0,L.rgb)(.878,.333,.639),teal:(0,L.rgb)(.078,.694,.624),indigo:(0,L.rgb)(.388,.4,.945)};async function B(t){try{let[e,n]=await Promise.all([fetch("/fonts/Geist-Regular.ttf").then(e=>e.arrayBuffer()),fetch("/fonts/Geist-SemiBold.ttf").then(e=>e.arrayBuffer())]);return{r:await t.embedFont(e),sb:await t.embedFont(n)}}catch{let{StandardFonts:n}=await e.A(66151);return{r:await t.embedFont(n.Helvetica),sb:await t.embedFont(n.HelveticaBold)}}}async function H(e){try{let t=await fetch(e);if(t.ok)return await t.arrayBuffer()}catch{}try{let t=await fetch(`/api/proxy-image?url=${encodeURIComponent(e)}`);
1if(t.ok)return await t.arrayBuffer()}catch{}return null}async function V(e,t,n){try{let a=new Blob([e]),r=await createImageBitmap(a),s=Math.max(r.width,r.height),i=Math.min(Math.max(Math.round(s/t),2),8),o=t*i,l=document.createElement("canvas");l.width=o,l.height=o;let c=l.getContext("2d");if(!c)return null;c.beginPath(),c.roundRect(0,0,o,o,n*i),c.clip();let d=Math.max(o/r.width,o/r.height),u=r.width*d,m=r.height*d;c.drawImage(r,(o-u)/2,(o-m)/2,u,m);let p=l.toDataURL("image/png").split(",")[1];return Uint8Array.from(atob(p),e=>e.charCodeAt(0)).buffer}catch{return null}}async function W(e,t,n,a){let r=await H(t);if(!r)return null;let s=await V(r,n,a);if(s)try{return await e.embedPng(s)}catch{}return null}function G(e,t,n,a){if(t.widthOfTextAtSize(e,n)<=a)return e;let r=e;for(;r.length>1&&t.widthOfTextAtSize(r+"…",n)>a;)r=r.slice(0,-1);return r+"…"}function J(e,t,n){return t.widthOfTextAtSize(e,n)}function K(e,t,n){return n=Math.min(n,e/2,t/2),`M ${n} 0 L ${e-n} 0 Q ${e} 0 ${e} ${n} L ${e} ${t-n} Q ${e} ${t} ${e-n} ${t} L ${n} ${t} Q 0 ${t} 0 ${t-n} L 0 ${n} Q 0 0 ${n} 0 Z`}function X(e,t,n,a,r,s,i,o){let l=K(a,r,s);e.drawSvgPath(l,{x:t,y:n+r,color:i,borderWidth:0}),o&&e.drawSvgPath(l,{x:t,y:n+r,borderColor:o,borderWidth:.5})}function Z(e,t,n,a,r){e.drawImage(t,{x:n,y:a,width:r,height:r})}function Q(e,t){return e.replace(/-?\d+(\.\d+)?/g,e=>(parseFloat(e)*t).toFixed(3))}let Y=["M61.813,4.424c33.545,0,61.793,28.248,61.793,61.793c0,35.31-30.014,62.676-61.793,61.793C29.151,128.893,0.02,101.527,0.02,66.217C-0.863,31.789,27.386,4.424,61.813,4.424","M96.241,507.596H25.62c-9.71,0-17.655-7.945-17.655-17.655V180.976c0-9.71,7.062-17.655,16.772-17.655h71.503c9.71,0,17.655,7.945,17.655,17.655v309.848C113.896,499.651,105.951,507.596,96.241,507.596","M511.137,271.017c0-65.324-48.552-116.524-113.876-116.524h-18.538c-35.31,0-69.738,16.772-88.276,44.138c-6.179,6.179-8.828,8.828-8.828,8.828v-35.31c0-3.531-5.297-8.828-8.828-8.828h-88.276c-3.531,0-8.828,3.531-8.828,7.945v329.269c0,3.531,5.297,7.062,8.828,7.062h97.103c3.531,0,8.828-3.531,8.828-7.062V309.858c0-32.662,24.717-60.028,57.379-60.91c16.772,0,31.779,6.179,43.255,17.655c10.593,10.593,15.007,25.6,15.007,42.372v189.793c0,3.531,5.297,8.828,8.828,8.828h88.276c3.531,0,8.828-5.297,8.828-8.828V271.017H511.137z"];function ee(e,t,n,a){X(e,t,n,a,a,.22*a,U.li);let r=.2*a,s=(a-2*r)/512,i=t+r,o=n+a-r;for(let t of Y)e.drawSvgPath(Q(t,s),{x:i,y:o,color:U.white})}async function et(e,t,n,a){let r=function(e,t,n){let a=new Map,r=e=>{var s;let i,o=t.get(e.contact.id),l=o?function(e){let t,n=new Date(e),a=new Date,r=(a.getFullYear()-n.getFullYear())*12+(a.getMonth()-n.getMonth());if(r<1)t="<1mo";else if(r<12)t=`${r}mo`;else{let e=Math.floor(r/12),n=r%12;t=n>0?`${e}y ${n}mo`:`${e}y`}return`${new Date(e+"T00:00:00").toLocaleDateString("en-GB",{month:"short",year:"numeric"})} – Present \xb7 ${t}`}(o):null,c=n.get(e.contact.id)??null,d=(s=e.contact,i=23,s.job_title&&(i+=14.5),s.location&&(i+=13),l&&(i+=13),c&&(i+=13),s.email&&(i+=18),Math.max(i+=10,60));return a.set(e.contact.id,{tenure:l,persona:c,h:d}),{id:e.contact.id,height:d,children:e.children.map(r)}},s=e.map(r),{positions:i}=(0,o.layoutHierarchy)(s,{nodeWidth:210,nodeHeight:60,hGap:32,vGap:70,rootGap:64}),l=e=>{let t=a.get(e.contact.id),n=i.get(e.contact.id)??{x:0,y:0};return{id:e.contact.id,contact:e.contact,tenure:t.tenure,persona:t.persona,x:n.x,y:n.y,h:t.h,children:e.children.map(l)}};return e.map(l)}(F(e),t,a??new Map);if(0===r.length)throw Error("No contacts");for(let e of r)!function e(t,n){for(let a of(t.y+=n,t.children))e(a,n)}(e,40);let s=await $.PDFDocument.create(),i=await B(s),l=new Map,c=[];
1for(let e of r)!function e(t){for(let n of(t.contact.image_url&&c.push({id:t.id,url:t.contact.image_url}),t.children))e(n)}(e);for(let{id:e,img:t}of(await Promise.all(c.map(async({id:e,url:t})=>({id:e,img:await W(s,t,40,10)})))))l.set(e,t);let d=n?.logo_url?await W(s,n.logo_url,32,6):null,u=function(e){let t=1/0,n=1/0,a=-1/0,r=-1/0;for(let s of e)!function e(s){for(let i of(t=Math.min(t,s.x),n=Math.min(n,s.y),a=Math.max(a,s.x+210),r=Math.max(r,s.y+s.h),s.children))e(i)}(s);return{x1:t,y1:n,x2:a,y2:r}}(r);for(let e of r){let t=e.y-20-20;u.y1=Math.min(u.y1,t)}let m=0,p=0,h=0;if(n){let e,t;e=46,n.domain&&(e+=14),t=0,n.industry&&t++,n.employee_range&&t++,n.founded_year&&t++,n.headquarters&&t++,t>0&&(e+=10+13*t),m=e,p=(u.x1+u.x2)/2-145,h=u.y1-m-70}let x=Math.min(u.x1,n?p:u.x1),f=Math.max(u.x2,n?p+290:u.x2),g=n?h:u.y1,b=u.y2,y=f-x+100,j=b-g+100,v=s.addPage([y,j]);v.drawRectangle({x:0,y:0,width:y,height:j,color:U.bg});let w=[];function N(e,t,n){return{x:e-x+50,y:j-(t-g+50+n)}}if(n){let{x:e,y:t}=N(p,h,m);!function(e,t,n,a,r,s,i,o,l){X(e,a,r,290,s,16,U.card,U.border);let c=r+s-20,d=i?a+20+32+8:a+20;if(i){let t=a+20,n=c-32+4;Z(e,i,t,n,32),e.drawSvgPath(K(32,32,6),{x:t,y:n+32,borderColor:U.border,borderWidth:.5})}let u=c-12,m=a+290-20;if(n.linkedin_url&&(ee(e,m-=11,u,11),o.push(l.obj({Type:"Annot",Subtype:"Link",Rect:[m,u,m+11,u+11],Border:[0,0,0],A:l.obj({Type:"Action",S:"URI",URI:M.PDFString.of(n.linkedin_url)})})),m-=5),n.website_url||n.domain){var p,h,x;let t,a;m-=12,p=m,h=u-.5,x=U.muted,t=h+6,a=.35,e.drawCircle({x:p+6,y:t,size:5,borderColor:x,borderWidth:a,opacity:0}),e.drawLine({start:{x:p+1,y:t},end:{x:p+11,y:t},thickness:a,color:x}),e.drawSvgPath(Q("M 12 2 C 14.21 2 16 6.48 16 12 C 16 17.52 14.21 22 12 22 C 9.79 22 8 17.52 8 12 C 8 6.48 9.79 2 12 2 Z",.5),{x:p,y:h+12,borderColor:x,borderWidth:a});let r=n.website_url||`https://${n.domain}`;o.push(l.obj({Type:"Annot",Subtype:"Link",Rect:[m,u-.5,m+12,u+11.5],Border:[0,0,0],A:l.obj({Type:"Action",S:"URI",URI:M.PDFString.of(r)})}))}let f=G(n.name,t.sb,11,250-40*!!i-40);if(c-=11,e.drawText(f,{x:d,y:c,size:11,font:t.sb,color:U.fg}),c-=4,n.domain){c-=9,e.drawText(n.domain,{x:d,y:c,size:9,font:t.r,color:U.muted});let a=n.website_url||`https://${n.domain}`;o.push(l.obj({Type:"Annot",Subtype:"Link",Rect:[d,c-2,d+J(n.domain,t.r,9),c+9+2],Border:[0,0,0],A:l.obj({Type:"Action",S:"URI",URI:M.PDFString.of(a)})})),c-=4}let g=[];if(n.industry&&g.push(n.industry),n.employee_range&&g.push(`${n.employee_range} employees`),n.founded_year&&g.push(`Founded ${n.founded_year}`),n.headquarters&&g.push(n.headquarters),g.length>0)for(let n of(c-=10,g))c-=8.5,e.drawText(n,{x:a+20,y:c,size:8.5,font:t.r,color:U.muted}),c-=4.5}(v,i,n,e,t,m,d,w,s.context)}let k=r.map(e=>{let t=N(e.x+45,e.y-20-20,20);return!function(e,t,n,a,r){if(X(e,n,a,120,20,10,U.card,U.border),r){let s=G(r,t.sb,8,104),i=J(s,t.sb,8);e.drawText(s,{x:n+(120-i)/2,y:a+6,size:8,font:t.sb,color:U.muted})}}(v,i,t.x,t.y,e.contact.department),{pp:t,root:e}});if(n&&k.length>0){let e=N(p,h,m),t=e.x+145,n=e.y,a=k.map(({pp:e})=>({cx:e.x+60,top:e.y+20})),r=(n+a[0].top)/2;if(v.drawLine({start:{x:t,y:n},end:{x:t,y:r},thickness:1,color:U.edge}),1===a.length)v.drawLine({start:{x:a[0].cx,y:r},end:{x:a[0].cx,y:a[0].top},thickness:1,color:U.edge});else{let e=Math.min(...a.map(e=>e.cx)),t=Math.max(...a.map(e=>e.cx));for(let n of(v.drawLine({start:{x:e,y:r},end:{x:t,y:r},thickness:1,color:U.edge}),a))v.drawLine({start:{x:n.cx,y:r},end:{x:n.cx,y:n.top},thickness:1,color:U.edge})}}for(let{pp:e,root:t}of k){let n=e.x+60,a=e.y,r=N(t.x,t.y,t.h);v.drawLine({start:{x:n,y:a},end:{x:r.x+105,y:r.y+t.h},thickness:1,color:U.edge})}for(let e of r)!function e(t){let{x:n,y:a}=N(t.x,t.y,t.h);for(let r of(!function(e,t,n,a,r,s,i,o){let{contact:l,tenure:c,persona:d}=n;X(e,a,r,210,n.h,16,U.card,U.border);let u=a+10,m=r+n.h-10-40;if(s)Z(e,s,u,m,40),e.drawSvgPath(K(40,40,10),{x:u,y:m+40,borderColor:U.border,borderWidth:.5});else{X(e,u,m,40,40,10,U.white,U.border);let n=l.name.charAt(0).toUpperCase();e.drawText(n,{x:u+20-J(n,t.sb,14)/2,y:m+20-5,size:14,font:t.sb,color:U.dim})}let p=u+40+12,h=r+n.h-10-1,x=G(l.name,t.sb,10,120);if(h-=10,e.drawText(x,{x:p,y:h,size:10,font:t.sb,color:U.fg}),l.linkedin_url){let n=p+J(x,t.sb,10)+4;ee(e,n,h-1,10),i.push(o.obj({Type:"Annot",Subtype:"Link",Rect:[n,h-1,n+10,h+10-1],Border:[0,0,0],A:o.obj({Type:"Action",S:"URI",URI:M.PDFString.of(l.linkedin_url)})}))}if(h-=5,l.job_title&&(h-=8.5,e.drawText(G(l.job_title,t.r,8.5,138),{x:p,y:h,size:8.5,font:t.r,color:U.muted}),h-=4),l.location&&(h-=7.5,e.drawText(G(l.location,t.r,7.5,138),{x:p,y:h,size:7.5,font:t.r,color:U.dim}),h-=3.5),c&&(h-=7.5,e.drawText(G(c,t.r,7.5,138),{x:p,y:h,size:7.5,font:t.r,color:U.dimmer}),h-=3.5),d){h-=7.5;let n=function(e){if(e.startsWith("#")&&e.length>=7){let t=parseInt(e.slice(1,3),16)/255,n=parseInt(e.slice(3,5),16)/255,a=parseInt(e.slice(5,7),16)/255;return(0,L.rgb)(t,n,a)}return q[e]??U.muted}(d.color);e.drawCircle({x:p+2.5,y:h+3.75-.5,size:2.5,color:n}),e.drawText(G(d.label,t.r,7.5,128),{x:p+5+4,y:h,size:7.5,font:t.r,color:U.dim}),h-=3.5}if(l.email){var f,g;let n;h-=5;let r=a+10;h-=8.5,f=h-.5,g=U.muted,n=K(9,7,1.5),e.drawSvgPath(n,{x:r,y:f+7,borderColor:g,borderWidth:.6}),e.drawLine({start:{x:r,y:f+7},end:{x:r+4.5,y:f+.35*7},thickness:.6,color:g}),e.drawLine({start:{x:r+9,y:f+7},end:{x:r+4.5,y:f+.35*7},thickness:.6,color:g});let s=G(l.email,t.r,8.5,162);e.drawText(s,{x:r+14,y:h,size:8.5,font:t.r,color:U.muted});let c=function(e){switch(e){case"valid":return U.success;
1case"invalid":return U.destructive;case"questionable":case"role_ended":return U.warning;default:return null}}(l.email_status);if(c){let n=r+14+J(s,t.r,8.5)+5;e.drawCircle({x:n+3,y:h+4.25-1,size:3,color:c})}i.push(o.obj({Type:"Annot",Subtype:"Link",Rect:[r+14,h-2,r+14+J(s,t.r,8.5),h+8.5+2],Border:[0,0,0],A:o.obj({Type:"Action",S:"URI",URI:M.PDFString.of(`mailto:${l.email}`)})}))}}(v,i,t,n,a,l.get(t.id)??null,w,s.context),t.children))e(r)}(e);for(let e of r)!function e(t,n,a){if(0===n.children.length)return;let r=a(n.x,n.y,n.h),s=r.x+105,i=r.y,o=n.children.map(e=>{let t=a(e.x,e.y,e.h);return{cx:t.x+105,top:t.y+e.h}}),l=(i+o[0].top)/2;if(t.drawLine({start:{x:s,y:i},end:{x:s,y:l},thickness:1,color:U.edge}),1===o.length)t.drawLine({start:{x:o[0].cx,y:l},end:{x:o[0].cx,y:o[0].top},thickness:1,color:U.edge});else{let e=Math.min(...o.map(e=>e.cx)),n=Math.max(...o.map(e=>e.cx));for(let a of(t.drawLine({start:{x:e,y:l},end:{x:n,y:l},thickness:1,color:U.edge}),o))t.drawLine({start:{x:a.cx,y:l},end:{x:a.cx,y:a.top},thickness:1,color:U.edge})}for(let r of n.children)e(t,r,a)}(v,e,N);return w.length>0&&v.node.set(R.PDFName.of("Annots"),s.context.obj(w.map(e=>s.context.register(e)))),s.save()}var en=e.i(846696);let ea="id, workspace_id, owner_id, company_id, name, is_default, sort_order, member_ids, reporting, departments, node_positions, created_at, updated_at",er="__full__";function es(e){return{...e,member_ids:e.member_ids??[],reporting:e.reporting??{},departments:e.departments??{},node_positions:e.node_positions??{}}}async function ei(e,t){let{data:n,error:a}=await e.from("buying_groups").select(ea).eq("company_id",t).order("sort_order").order("created_at");return a||!n?[]:n.map(es)}async function eo(e,t){let{data:n,error:a}=await e.from("buying_groups").insert({company_id:t.companyId,owner_id:t.ownerId,workspace_id:t.workspaceId,name:t.name,member_ids:t.memberIds,reporting:t.reporting??{},departments:t.departments??{},node_positions:t.nodePositions??{},sort_order:t.sortOrder}).select(ea).single();return a||!n?null:es(n)}async function el(e,t,n){await e.from("buying_groups").update({...n,updated_at:new Date().toISOString()}).eq("id",t)}async function ec(e,t,n){let a=e.from("buying_groups").update({is_default:!1,updated_at:new Date().toISOString()}).eq("company_id",t).eq("is_default",!0);n&&(a=a.neq("id",n)),await a,n&&await e.from("buying_groups").update({is_default:!0,updated_at:new Date().toISOString()}).eq("id",n)}async function ed(e,t){await e.from("buying_groups").delete().eq("id",t)}var eu=e.i(664659),em=e.i(788699),ep=e.i(870273),eh=e.i(23750),ex=e.i(167881),ef=e.i(341256);function eg({groups:e,activeId:a,onSelect:r,onCreate:s,onRename:i,onDuplicate:o,onDelete:c,onSetDefault:d,className:u}){let[m,p]=(0,n.useState)(!1),[h,x]=(0,n.useState)("list"),[f,b]=(0,n.useState)(""),[y,j]=(0,n.useState)(null),[v,w]=(0,n.useState)(""),k=e.find(e=>e.id===a)??null,_=k?k.name:"Org chart",C=e.find(e=>e.is_default)?.id??null;function S(){p(!1),x("list"),j(null)}async function T(){let e=f.trim();e&&(b(""),S(),await s(e))}async function D(e){let t=v.trim();j(null),w(""),t&&await i(e,t)}return(0,t.jsxs)(N.Popover,{open:m,onOpenChange:e=>{p(e),e||(x("list"),j(null))},children:[(0,t.jsx)(N.PopoverTrigger,{asChild:!0,children:(0,t.jsxs)("button",{"aria-label":`Buying group - current: ${_}`,className:(0,P.cn)("flex items-center gap-1.5 rounded-full border border-input bg-white dark:bg-zinc-950 px-2.5 h-7 text-xs max-w-[200px]","hover:bg-accent transition-colors whitespace-nowrap cursor-pointer",k&&"border-foreground
1/20",u),children:[(0,t.jsx)(g.PeopleGroupIcon,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),(0,t.jsx)("span",{className:"truncate",children:_}),(0,t.jsx)(eu.ChevronDown,{className:"h-3 w-3 opacity-60 shrink-0"})]})}),(0,t.jsx)(N.PopoverContent,{align:"start",sideOffset:6,className:"w-[260px] p-0 overflow-hidden rounded-xl shadow-lg border-border/80",children:"list"===h?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"max-h-80 overflow-y-auto",children:[(0,t.jsx)(eb,{label:"Org chart",subtitle:"Everyone at the company",isActive:a===er,isDefault:null===C,onClick:()=>{r(er),S()},actions:(0,t.jsx)(ey,{isDefault:null===C,onSetDefault:()=>d(null)})}),e.length>0&&(0,t.jsx)("div",{className:"px-2.5 pt-2 pb-1 text-[10px] font-medium uppercase tracking-wider text-muted-foreground",children:"Buying groups"}),e.map(e=>(0,t.jsx)(eb,{label:e.name,subtitle:`${e.member_ids.length} ${1===e.member_ids.length?"person":"people"}`,isActive:a===e.id,isDefault:C===e.id,renaming:y===e.id,renameValue:v,onRenameChange:w,onRenameCommit:()=>D(e.id),onClick:()=>{y!==e.id&&(r(e.id),S())},actions:(0,t.jsx)(ey,{isDefault:C===e.id,onSetDefault:()=>d(C===e.id?null:e.id),onRename:()=>{j(e.id),w(e.name)},onDuplicate:()=>{S(),o(e.id)},onDelete:()=>{S(),c(e.id)}})},e.id))]}),(0,t.jsx)("div",{className:"border-t border-border/60 p-1.5",children:(0,t.jsxs)("button",{onClick:()=>x("create"),className:"flex w-full items-center gap-2 rounded-md px-2 py-2 text-xs hover:bg-accent/70 transition-colors cursor-pointer text-left",children:[(0,t.jsx)(l.Plus,{className:"h-3.5 w-3.5 text-muted-foreground"}),"New buying group"]})})]}):(0,t.jsxs)("div",{className:"p-2.5 space-y-2.5",children:[(0,t.jsx)("p",{className:"text-xs font-medium",children:"New buying group"}),(0,t.jsx)("p",{className:"text-[11px] text-muted-foreground leading-snug",children:"Starts as a copy of what is on screen. Editing it never changes the company's real reporting."}),(0,t.jsx)(eh.Input,{variant:"on-white",value:f,onChange:e=>b(e.target.value),placeholder:"e.g. Security evaluation",autoFocus:!0,onKeyDown:e=>{"Enter"===e.key&&T(),"Escape"===e.key&&x("list")},className:"h-8 text-xs"}),(0,t.jsxs)("div",{className:"flex items-center justify-end gap-1.5",children:[(0,t.jsx)(ex.Button,{size:"sm",variant:"ghost",className:"h-7 px-2 text-[11px]",onClick:()=>{x("list"),b("")},children:"Cancel"}),(0,t.jsx)(ex.Button,{size:"sm",className:"h-7 px-3 text-[11px]",disabled:!f.trim(),onClick:T,children:"Create"})]})]})})]})}function eb({label:e,subtitle:n,isActive:a,isDefault:r,renaming:s,renameValue:i,onRenameChange:o,onRenameCommit:l,onClick:c,actions:d}){return(0,t.jsxs)("div",{onClick:c,className:(0,P.cn)("group flex items-center gap-2 px-2.5 py-2 text-xs cursor-pointer hover:bg-accent/70 transition-colors",a&&"bg-accent/50"),children:[(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[s?(0,t.jsx)("input",{autoFocus:!0,value:i??"",onChange:e=>o?.(e.target.value),onKeyDown:e=>{"Enter"===e.key&&l?.()},onClick:e=>e.stopPropagation(),onBlur:l,className:"w-full bg-transparent outline-none border-b border-border text-xs"}):(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("span",{className:"truncate",children:e}),r&&(0,t.jsx)(ep.Star,{className:"h-2.5 w-2.5 fill-amber-500 text-amber-500 shrink-0"})]}),n&&!s&&(0,t.jsx)("p",{className:"text-[10px] text-muted-foreground truncate",children:n})]}),a&&(0,t.jsx)(f.Check,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),d]})}function ey({isDefault:e,onSetDefault:a,onRename:r,onDuplicate:s,onDelete:i}){let[o,c]=(0,n.useState)(!1),d="flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-xs outline-none cursor-pointer hover:bg-accent transition-colors text-left";return(0,t.jsxs)(N.Popover,{open:o,onOpenChange:c,children:[(0,t.jsx)(N.PopoverTrigger,{asChild:!0,children:(0,t.jsx)("button",{onClick:e=>e.stopPropagation(),className:"opacity-0 group-hover:opacity-100 data-[state=open]:opacity-100 p-1 rounded-md hover:bg-foreground
1/10 transition-opacity shrink-0","aria-label":"Buying group actions",children:(0,t.jsx)(m.MoreHorizontal,{className:"h-3 w-3 text-muted-foreground"})})}),(0,t.jsxs)(N.PopoverContent,{align:"end",sideOffset:4,className:"w-[170px] p-1 rounded-lg shadow-lg",onClick:e=>e.stopPropagation(),children:[(0,t.jsxs)("button",{onClick:()=>{a(),c(!1)},className:d,children:[(0,t.jsx)(ep.Star,{className:(0,P.cn)("h-3 w-3",e?"fill-amber-500 text-amber-500":"text-muted-foreground")}),e?"Remove default":"Set as default"]}),r&&(0,t.jsxs)("button",{onClick:()=>{r(),c(!1)},className:d,children:[(0,t.jsx)(em.Pencil,{className:"h-3 w-3 text-muted-foreground"}),"Rename"]}),s&&(0,t.jsxs)("button",{onClick:()=>{s(),c(!1)},className:d,children:[(0,t.jsx)(l.Plus,{className:"h-3 w-3 text-muted-foreground"}),"Duplicate"]}),i&&(0,t.jsxs)("button",{onClick:()=>{i(),c(!1)},className:(0,P.cn)(d,"text-destructive hover:bg-destructive/10"),children:[(0,t.jsx)(ef.TrashIcon,{className:"h-3 w-3"}),"Delete"]})]})]})}var ej=e.i(660662),ev=e.i(773993),ew=e.i(400236);let eN=(0,n.createContext)({setRoot:()=>{},dropTarget:null,setDepartment:()=>{},addGroup:()=>{},nonRootContacts:[],removeFromGroup:null});function ek(e,t,n){let a,r=(a=e=>({id:e.contact.id,children:e.children.map(a)}),(0,o.layoutHierarchy)(e.map(a),{nodeWidth:300,nodeHeight:140,hGap:28,vGap:60,rootGap:56}).positions),s=[],i=[];for(let e of r.values())e.y+=64;for(let t of e){let e=r.get(t.contact.id);if(!e)continue;let n=`__dept_${t.contact.id}__`,a=e.x+50,o=e.y-32-32;s.push({id:n,type:"departmentPill",position:{x:a,y:o},data:{label:t.contact.department,contactId:t.contact.id},style:{pointerEvents:"all",zIndex:10}}),i.push({id:`e-dept-${t.contact.id}
1`,source:n,target:t.contact.id,type:"orgStep"})}if(n&&e.length>0){let t=1/0,a=-1/0,o=1/0;for(let n of e){let e=r.get(n.contact.id);if(e){let n=e.x+50,r=e.y-32-32;t=Math.min(t,n),a=Math.max(a,n+200),o=Math.min(o,r)}}let l=(t+a)/2,c=o-eC-60;for(let t of(s.push({id:"__company_header__",type:"companyHeader",position:{x:l-e_/2,y:c},data:{company:n},draggable:!1,selectable:!1,style:{pointerEvents:"all",zIndex:10}}),e))i.push({id:`e-header-${t.contact.id}`,source:"__company_header__",target:`__dept_${t.contact.id}__`,type:"orgStep"})}for(let n of e)!function e(n){let a=t.get(n.contact.id);for(let t of(s.push({id:n.contact.id,type:"orgPerson",position:r.get(n.contact.id)??{x:0,y:0},data:{contact:n.contact,tenure:a?function(e){let t,n=`${new Date(e+"T00:00:00").toLocaleDateString("en-GB",{month:"short",year:"numeric"})} – Present`,a=new Date(e),r=new Date,s=(r.getFullYear()-a.getFullYear())*12+(r.getMonth()-a.getMonth());if(s<1)t="<1mo";else if(s<12)t=`${s}mo`;else{let e=Math.floor(s/12),n=s%12;t=n>0?`${e}y ${n}mo`:`${e}y`}return`${n} \xb7 ${t}`}(a):null}}),n.children))i.push({id:`e-${n.contact.id}-${t.contact.id}
1`,source:n.contact.id,target:t.contact.id,type:"orgStep"}),e(t)}(n);return{nodes:s,edges:i}}let e_=380,eC=140,eS={orgPerson:function({data:e,id:o}){let{contact:l,tenure:c}=e,{setRoot:d,dropTarget:u,removeFromGroup:h}=(0,n.useContext)(eN),[g,b]=(0,n.useState)(l),[y,j]=(0,n.useState)(!1),[v,w]=(0,n.useState)(!1),N=(0,n.useRef)(null);async function k(e){b(t=>({...t,persona:e}));let t=(0,r.createClient)();await t.from("contacts").update({persona:e,updated_at:new Date().toISOString()}).eq("id",g.id)}return(0,n.useEffect)(()=>{b(l)},[l]),(0,n.useEffect)(()=>{if(y)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e);function e(e){N.current&&!N.current.contains(e.target)&&j(!1)}},[y]),(0,t.jsxs)("div",{className:"group relative",children:[(0,t.jsx)(s.Handle,{type:"target",position:i.Position.Top,className:"!w-0 !h-0 !border-0 !bg-transparent !-top-[1px]"}),(0,t.jsx)("div",{className:(0,P.cn)("w-[260px] sm:min-w-[300px] sm:w-fit rounded-[20px] select-none relative","transition-all duration-200 ease-out","border border-card-border bg-[var(--muted)]",u===o?"ring-2 ring-foreground/10 scale-[1.02]":"hover:border-foreground
1/15"),children:(0,t.jsxs)("div",{className:"p-3.5 relative",children:[(0,t.jsx)("div",{className:"absolute top-2.5 right-2.5 z-10",onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,t.jsxs)(_.DropdownMenu,{children:[(0,t.jsx)(_.DropdownMenuTrigger,{asChild:!0,children:(0,t.jsx)("button",{className:"p-1 squircle text-muted-foreground hover:text-foreground hover:bg-sidebar-accent transition-colors",onPointerDown:e=>e.stopPropagation(),children:(0,t.jsx)(m.MoreHorizontal,{className:"h-3.5 w-3.5"})})}),(0,t.jsxs)(_.DropdownMenuContent,{align:"end",className:"w-40",children:[(0,t.jsx)(_.DropdownMenuItem,{asChild:!0,children:(0,t.jsxs)(a.default,{href:`/people/${g.id}`,children:[(0,t.jsx)(ev.PeopleIcon,{className:"mr-2 h-3.5 w-3.5"}),"View profile"]})}),(0,t.jsxs)(_.DropdownMenuItem,{onClick:()=>d(g.id),disabled:!g.reports_to,children:[(0,t.jsx)(p.GitBranch,{className:"mr-2 h-3.5 w-3.5"}),"New department"]}),h&&(0,t.jsxs)(_.DropdownMenuItem,{onClick:()=>h(g.id),children:[(0,t.jsx)(ew.RemovePersonIcon,{className:"mr-2 h-3.5 w-3.5"}),"Remove from group"]})]})]})}),(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)(a.default,{href:`/people/${g.id}`,className:"flex h-12 w-12 shrink-0 items-center justify-center squircle bg-card avatar-border text-sm font-medium hover:opacity-90 transition-opacity",onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),draggable:!1,children:g.image_url?(0,t.jsx)(C.SafeImage,{src:g.image_url,alt:g.name,className:"h-full w-full object-contain",fallback:g.name.charAt(0).toUpperCase()}):(0,t.jsx)("span",{className:"text-muted-foreground",children:g.name.charAt(0).toUpperCase()})}),(0,t.jsxs)("div",{className:"min-w-0 flex-1 whitespace-nowrap",children:[(0,t.jsx)(a.default,{href:`/people/${g.id}`,className:"text-[13px] font-semibold leading-tight hover:opacity-90 transition-opacity",onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),draggable:!1,children:g.name}),g.job_title&&(0,t.jsx)("p",{className:"text-[11px] text-muted-foreground mt-0.5",children:g.job_title}),g.location&&(0,t.jsx)("p",{className:"text-[10px] text-muted-foreground/60",children:g.location}),c&&(0,t.jsx)("p",{className:"text-[10px] text-muted-foreground/50",children:c})]})]}),(0,t.jsxs)("div",{ref:N,className:"flex items-center gap-1 mt-2.5 min-w-0",onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:[g.linkedin_url&&(0,t.jsx)("a",{href:g.linkedin_url,target:"_blank",rel:"noopener noreferrer",title:"View LinkedIn profile",className:"shrink-0",draggable:!1,children:(0,t.jsx)(T.LinkedInSquircle,{className:"h-5 w-5 hover:brightness-[0.96] active:brightness-90 transition-[filter] duration-150"})}),g.email&&(0,t.jsx)("button",{type:"button",onClick:()=>j(e=>!e),title:y?"Hide email":g.email,className:"shrink-0 cursor-pointer",children:(0,t.jsx)(T.MailProviderSquircle,{bg:"bg-white dark:bg-white/10",className:"h-5 w-5 hover:brightness-[0.96] active:brightness-90 transition-[filter] duration-150"})}),g.email&&(0,t.jsx)("div",{className:"grid transition-[grid-template-columns] duration-300 ease-out min-w-0",style:{gridTemplateColumns:y?"1fr":"0fr"},children:(0,t.jsx)("div",{className:"overflow-hidden min-w-0",children:(0,t.jsxs)("div",{className:"flex items-center gap-1.5 pl-0.5 pr-1",children:[(0,t.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground whitespace-nowrap truncate hover:text-foreground transition-colors",children:g.email}),(0,t.jsx)(S.EmailStatusDot,{status:g.email_status||"no_status",size:"sm"}),(0,t.jsx)("button",{type:"button",onClick:async e=>{e.stopPropagation();try{await navigator.clipboard.writeText(g.email),w(!0),setTimeout(()=>w(!1),1500)}catch{}},className:"shrink-0 p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors",title:"Copy email",children:v?(0,t.jsx)(f.Check,{className:"h-3 w-3 text-success"}):(0,t.jsx)(x.Copy,{className:"h-3 w-3"})})]})})}),(0,t.jsx)("div",{className:"flex-1"}),(0,t.jsx)(D.PersonaBadge,{persona:g.persona||"none",onChange:k})]})]})}),(0,t.jsx)(s.Handle,{type:"source",position:i.Position.Bottom,className:"!w-0 !h-0 !border-0 !bg-transparent !-bottom-[1px]"})]})},companyHeader:function({data:e}){let r=e.company,{addGroup:o,setRoot:c,nonRootContacts:d}
1=(0,n.useContext)(eN),[u,m]=(0,n.useState)(!1);return(0,t.jsxs)("div",{className:(0,P.cn)("rounded-[20px] select-none p-5","border border-card-border bg-[var(--muted)]"),style:{width:e_},children:[(0,t.jsxs)("div",{className:"flex items-center gap-3.5",children:[(0,t.jsxs)(a.default,{href:`/companies/${r.id}`,className:"flex items-center gap-3.5 min-w-0 flex-1 rounded-lg hover:bg-card transition-colors p-1 -m-1",onClick:e=>e.stopPropagation(),draggable:!1,children:[(0,t.jsx)(v.CompanyLogo,{domain:r.domain,companyName:r.name,logoUrl:r.logo_url,size:"lg"}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"text-sm font-semibold truncate",children:r.name}),r.domain&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground truncate",children:r.domain})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 shrink-0",children:[(r.website_url||r.domain)&&(0,t.jsx)("a",{href:r.website_url||`https://${r.domain}`,target:"_blank",rel:"noopener noreferrer",title:"Visit website",className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-card transition-colors",onClick:e=>e.stopPropagation(),draggable:!1,children:(0,t.jsx)(h.Globe,{className:"h-4 w-4"})}),r.linkedin_url&&(0,t.jsx)("a",{href:r.linkedin_url,target:"_blank",rel:"noopener noreferrer",title:"View on LinkedIn",className:"flex h-5.5 w-5.5 shrink-0 items-center justify-center squircle bg-[#0A66C2] hover:opacity-80 transition-opacity",onClick:e=>e.stopPropagation(),draggable:!1,children:(0,t.jsx)(T.LinkedInGlyph,{className:"h-3 w-3 text-white"})})]})]}),(r.industry||r.headquarters||r.employee_range||r.founded_year||d.length>0)&&(0,t.jsxs)("div",{className:"flex items-end gap-2 mt-3",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 min-w-0 flex-1 text-xs text-muted-foreground",children:[r.industry&&(0,t.jsx)("span",{children:r.industry}),r.employee_range&&(0,t.jsxs)("span",{children:[r.employee_range," employees"]}),r.founded_year&&(0,t.jsxs)("span",{children:["Founded ",r.founded_year]}),r.headquarters&&(0,t.jsx)("span",{children:r.headquarters})]}),d.length>0&&(0,t.jsxs)(N.Popover,{open:u,onOpenChange:m,children:[(0,t.jsx)(N.PopoverTrigger,{asChild:!0,children:(0,t.jsxs)("button",{className:"nodrag nopan shrink-0 flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground transition-colors rounded-md px-2 py-1 hover:bg-card",onPointerDownCapture:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),m(!0)},children:[(0,t.jsx)(l.Plus,{className:"h-3 w-3"}),"Add group"]})}),(0,t.jsx)(N.PopoverContent,{className:"w-56 p-0",align:"end",children:(0,t.jsxs)(k.Command,{children:[(0,t.jsx)(k.CommandInput,{placeholder:"Pick department head..."}),(0,t.jsxs)(k.CommandList,{children:[(0,t.jsx)(k.CommandEmpty,{children:"No people available."}),(0,t.jsx)(k.CommandGroup,{children:d.map(e=>(0,t.jsxs)(k.CommandItem,{value:`${e.name} ${e.email||""}`,onSelect:()=>{c(e.id),m(!1)},children:[(0,t.jsx)("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-muted text-[10px] font-medium overflow-hidden",children:e.image_url?(0,t.jsx)("img",{src:e.image_url,alt:"",className:"h-full w-full object-cover"}):e.name.charAt(0).toUpperCase()}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"truncate text-sm",children:e.name}),e.job_title&&(0,t.jsx)("p",{className:"truncate text-xs text-muted-foreground",children:e.job_title})]})]},e.id))})]})]})})]})]}),(0,t.jsx)(s.Handle,{type:"source",position:i.Position.Bottom,className:"!w-0 !h-0 !border-0 !bg-transparent !-bottom-[1px]"})]})},departmentPill:function({data:e}){let{setDepartment:a}=(0,n.useContext)(eN),{label:r,contactId:o}
1=e,[l,c]=(0,n.useState)(!1),[d,u]=(0,n.useState)(r||""),m=(0,n.useRef)(null);function p(){c(!1);let e=d.trim();e!==(r||"")&&a(o,e||null)}return(0,n.useEffect)(()=>{if(l){let e=setTimeout(()=>{m.current?.focus(),m.current?.select()},0);return()=>clearTimeout(e)}},[l]),(0,t.jsxs)("div",{style:{width:200,height:32,pointerEvents:"all"},className:"flex items-center justify-center",children:[(0,t.jsx)(s.Handle,{type:"target",position:i.Position.Top,isConnectable:!1,className:"!w-0 !h-0 !border-0 !bg-transparent !-top-[1px]"}),l?(0,t.jsx)("input",{ref:m,value:d,onChange:e=>u(e.target.value),onBlur:p,onKeyDown:e=>{"Enter"===e.key&&p(),"Escape"===e.key&&(u(r||""),c(!1))},onPointerDownCapture:e=>{e.stopPropagation()},className:(0,P.cn)("nodrag nopan w-full h-full rounded-full text-center text-xs font-medium bg-transparent","border border-foreground/20 px-3 outline-none"),placeholder:"Add label..."}):(0,t.jsx)("div",{role:"button",tabIndex:0,onDoubleClick:()=>{c(!0),u(r||"")},onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(c(!0),u(r||""))},className:(0,P.cn)("w-full h-full rounded-full text-xs font-medium transition-colors px-3 select-none cursor-grab","flex items-center justify-center",r?"border border-card-border bg-[var(--muted)] text-foreground/70 hover:border-foreground
1/15":"border border-dashed border-foreground/20 text-muted-foreground/50 hover:text-muted-foreground/70 hover:border-foreground/30 hover:bg-[var(--muted)]"),children:r||"Double-click to label..."}),(0,t.jsx)(s.Handle,{type:"source",position:i.Position.Bottom,isConnectable:!1,className:"!w-0 !h-0 !border-0 !bg-transparent !-bottom-[1px]"})]})}},eT={orgStep:function({sourceX:e,sourceY:n,targetX:a,targetY:r,style:s}){let i,o=n+(r-n)/2,l=a-e,c=Math.min(12,Math.abs(l)/2,Math.abs(r-n)/4);if(2>Math.abs(l)||0===c)i=`M ${e},${n} V ${r}`;else{let t=l>0?1:-1;i=`M ${e},${n} V ${o-c} Q ${e},${o} ${e+t*c},${o} H ${a-t*c} Q ${a},${o} ${a},${o+c} V ${r}`}return(0,t.jsx)("path",{d:i,fill:"none",stroke:s?.stroke||"var(--foreground)",strokeWidth:Number(s?.strokeWidth)||1.5,opacity:Number(s?.opacity)||.25})}};function eD({v:e,h:n}){let a,r,i,o,l,c,{getViewport:d}=(0,s.useReactFlow)();if(!e&&!n)return null;let{x:u,y:m,zoom:p}=d();return(0,t.jsxs)("svg",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:1e3,overflow:"visible"},children:[e&&(a=e.x*p+u,r=e.y1*p+m+6,(i=e.y2*p+m-6)<=r?null:(0,t.jsx)("line",{x1:a,y1:r,x2:a,y2:i,stroke:"#3b82f6",strokeWidth:1,opacity:.5})),n&&(o=n.y*p+m,l=n.x1*p+u+6,(c=n.x2*p+u-6)<=l?null:(0,t.jsx)("line",{x1:l,y1:o,x2:c,y2:o,stroke:"#3b82f6",strokeWidth:1,opacity:.5}))]})}function eP({contacts:e,companyId:a,company:o,allContacts:l,initialExpanded:c,onClose:m}){let p=(0,r.createClient)(),{fitView:h}=(0,s.useReactFlow)(),{personas:x}=(0,I.usePersonas)(),[f,g]=(0,n.useState)(e),[j,N]=(0,n.useState)(!1),[k,_]=(0,n.use
1State)(null),[C,S]=(0,n.useState)([]),[T,D]=(0,n.useState)([]),[$,R]=(0,n.useState)(new Map),[M,L]=(0,n.useState)(!1),[E,A]=(0,n.useState)(c??!1),[U,q]=(0,n.useState)([]),[B,H]=(0,n.useState)(er),[V,W]=(0,n.useState)([]),G=(0,n.useMemo)(()=>U.find(e=>e.id===B)??null,[U,B]),J=(0,n.useRef)(G);J.current=G;let K=(0,n.useMemo)(()=>{if(0===V.length)return f;let e=new Set(f.map(e=>e.id));return[...f,...V.filter(t=>!e.has(t.id))]},[f,V]),X=(0,n.useRef)(K);X.current=K;let Z=(0,n.useMemo)(()=>{let e;return G?(e=new Set(G.member_ids),K.filter(t=>e.has(t.id)).map(t=>{let n=Object.prototype.hasOwnProperty.call(G.reporting,t.id)?G.reporting[t.id]:t.reports_to,a=Object.prototype.hasOwnProperty.call(G.departments,t.id)?G.departments[t.id]:t.department;return{...t,reports_to:n&&e.has(n)?n:null,department:a}})):f},[G,K,f]),Q=(0,n.useRef)(Z);Q.current=Z;let Y=(0,n.useRef)(null),ee=(0,n.useRef)(null),[ea,es]=(0,n.useState)(!1),eu=(0,n.useRef)(null),em=(0,n.useRef)(er),ep=(0,n.useRef)(null),eh=(0,n.useRef)(null),ex=(0,n.useRef)(null),ef=(0,n.useRef)(B);ef.current=B;let eb=(0,n.useRef)(new Set),ey=(0,n.useMemo)(()=>F(Z),[Z]),ej=(0,n.useRef)(ey);ej.current=ey;let ev=(0,n.useRef)($);ev.current=$;let ew=(0,n.useRef)(C);ew.current=C;let e_=(0,n.useRef)(new Set),eC=(0,n.useRef)(null),eR=(0,n.useCallback)(async(e,t)=>{if(t!==er){await el(p,t,{node_positions:e}),eu.current=null;return}let n=eh.current;n&&(await p.from("org_chart_layouts").upsert({user_id:n,company_id:a,node_positions:e,updated_at:new Date().toISOString()},{onConflict:"user_id,company_id"}),eu.current=null)},[a,p]),eL=(0,n.useCallback)(e=>{let t={};for(let n of e)t[n.id]={x:n.position.x,y:n.position.y};let n=ef.current;n===er?Y.current=t:ee.current=t,eu.current=t,em.current=n,ep.current&&clearTimeout(ep.current),ep.current=setTimeout(()=>eR(t,n),500)},[eR]),eE=(0,n.useCallback)(()=>{if(ep.current&&(clearTimeout(ep.current),ep.current=null),eu.current){let e=eu.current;eu.current=null,eR(e,em.current)}},[eR]);async function eA(e,t){let n=J.current;if(n){let a={...n.reporting,[e]:t};q(e=>e.map(e=>e.id===n.id?{...e,reporting:a,node_positions:{}}:e)),ee.current=null,await el(p,n.id,{reporting:a,node_positions:{}});return}let{error:a}=await p.from("contacts").update({reports_to:t,updated_at:new Date().toISOString()}).eq("id",e);if(a){en.toast.error("Failed to update reporting structure");let{nodes:e,edges:t}=ek(ej.current,ev.current,o);S(e),D(t);return}Y.current=null,g(n=>n.map(n=>n.id===e?{...n,reports_to:t}:n))}async function eF(e,t){let n=J.current;if(n){let a={...n.departments,[e]:t};q(e=>e.map(e=>e.id===n.id?{...e,departments:a}:e)),await el(p,n.id,{departments:a});return}let{error:a}=await p.from("contacts").update({department:t,updated_at:new Date().toISOString()}).eq("id",e);a?en.toast.error("Failed to update department label"):g(n=>n.map(n=>n.id===e?{...n,department:t}:n))}async function ez(e){let t=J.current;if(t){if(t.member_ids.includes(e))return void N(!1);let n=[...t.member_ids,e];if(q(e=>e.map(e=>e.id===t.id?{...e,member_ids:n}:e)),await el(p,t.id,{member_ids:n}),!X.current.some(t=>t.id===e)){eb.current.add(e);let{data:t}=await p.from("contacts").select("*").eq("id",e).single();t&&W(n=>n.some(t=>t.id===e)?n:[...n,t])}return en.toast.success("Added to buying group"),void N(!1)}let{error:n}=await p.from("contacts").update({company_id:a,updated_at:new Date().toISOString()}).eq("id",e);if(n)return void en.toast.error("Failed to add person");let{data:r}=await p.from("contacts").select("*").eq("id",e).single();r&&(g(e=>[...e,r]),en.toast.success("Person added")),N(!1)}(0,n.useEffect)(()=>()=>{ep.current&&clearTimeout(ep.current),eu.current&&eR(eu.current,em.current)},[eR]),(0,n.useEffect)(()=>{let e=!1;return(async()=>{let{data:{user:t}}=await p.auth.getUser();if(e)return;if(!t)return es(!0);eh.current=t.id;let[n,r,s]=await Promise.all([p.from("profiles").select("workspace_id").eq("id",t.id).maybeSingle(),p.from("org_chart_layouts").select("node_positions").eq("user_id",t.id).eq("company_id",a).maybeSingle(),ei(p,a)]);if(e)return;ex.current=n.data?.workspace_id??null,r.data?.node_positions&&(Y.current=r.data.node_positions),q(s);let i=s.find(e=>e.is_default);i&&(ee.current=i.node_positions,ef.current=i.id,H(i.id)),es(!0)})(),()=>{e=!0}},[a]),(0,n.useEffect)(()=>{let e=new Set([...f.map(e=>e.id),...V.map(e=>e.id),...eb.current]),t=new Set;for(let n of U)for(let a of n.member_ids)e.has(a)||t.add(a);if(0===t.size)return;for(let e of t)eb.current.add(e);let n=!1;return p.from("contacts").select("*").in("id",[...t]).then(({data:e})=>{!n&&e&&0!==e.length&&W(t=>{let n=new Set(t.map(e=>e.id));return[...t,...e.filter(e=>!n.has(e.id))]})}),()=>{n=!0}},[U,f,V,p]),(0,n.useEffect)(()=>
1{if(0===f.length)return;let e=f.map(e=>e.id);p.from("person_experiences").select("contact_id, start_date, company_id, company_name").in("contact_id",e).then(({data:e})=>{if(!e)return;let t=o?.name?.toLowerCase(),n=new Map;for(let r of e)if(r.company_id===a||t&&r.company_name?.toLowerCase()===t){let e=n.get(r.contact_id);(!e||r.start_date&&(!e||r.start_date<e))&&n.set(r.contact_id,r.start_date)}R(n)})},[f,a,o?.name,p]),(0,n.useEffect)(()=>{if(!ea)return;let{nodes:e,edges:t}=ek(ey,$,o),n=ef.current===er?Y.current:ee.current;if(n)for(let t of e){let e=n[t.id];e&&(t.position={x:e.x,y:e.y})}S(e),D(t);let a=setTimeout(()=>h({padding:.3,duration:200,minZoom:.05}),60);return()=>clearTimeout(a)},[ey,$,ea,B]),(0,n.useEffect)(()=>{if(!E){let e=setTimeout(()=>h({padding:.3,duration:200,minZoom:.05}),150);return()=>clearTimeout(e)}},[E,h]);let[eO,eU]=(0,n.useState)({v:null,h:null});function eq(e){return e.startsWith("__dept_")?200:300}function eB(e){return e.startsWith("__dept_")?32:140}let eH=(0,n.useCallback)(e=>{let t=null,n=null;for(let a of e){if("position"!==a.type||!a.dragging||!a.position)continue;let e=a.id.startsWith("__dept_")&&eC.current?new Set(eC.current.keys()):void 0,r=function(e,t,n,a){let r=eq(e),s=eB(e),i=t.x+r/2,o=t.y+s/2,l=0,c=0,d=null,u=null;for(let m of n){if(m.id===e||"__company_header__"===m.id||a?.has(m.id))continue;let n=eq(m.id),p=eB(m.id),h=m.position.x+n/2,x=m.position.y+p/2;if(!d&&8>Math.abs(i-h)){l=h-i;let e=t.y+s,n=m.position.y,a=m.position.y+p;e<=n?d={x:h,y1:e,y2:n}:a<=t.y&&(d={x:h,y1:a,y2:t.y})}if(!u&&8>Math.abs(o-x)){c=x-o;let e=t.x+r,a=m.position.x,s=m.position.x+n;e<=a?u={y:x,x1:e,x2:a}:s<=t.x&&(u={y:x,x1:s,x2:t.x})}}return{snapDx:l,snapDy:c,vGuide:d,hGuide:u}}(a.id,a.position,ew.current,e);a.position.x+=r.snapDx,a.position.y+=r.snapDy,t=r.vGuide,n=r.hGuide}eU({v:t,h:n}),S(t=>{let n=(0,s.applyNodeChanges)(e,t);for(let t of e){if("position"!==t.type||!t.dragging||!t.id.startsWith("__dept_")||!eC.current)continue;let e=eC.current.get(t.id),a=n.find(e=>e.id===t.id);if(!e||!a)continue;let r=a.position.x-e.x,s=a.position.y-e.y;n=n.map(e=>{if(e.id===t.id)return e;let n=eC.current?.get(e.id);return n?{...e,position:{x:n.x+r,y:n.y+s}}:e})}return n})},[]);async function eV(e,t){let n=O(ej.current,e);if(!n)return;let a=null;for(let e of n.children)if(e.contact.id===t||O([e],t)){a=e.contact.id;break}if(!a)return;let r=n.contact.reports_to||null,s=J.current;if(s){let n={...s.reporting,[a]:r,[e]:t};q(e=>e.map(e=>e.id===s.id?{...e,reporting:n,node_positions:{}}:e)),ee.current=null,await el(p,s.id,{reporting:n,node_positions:{}});return}let{error:i}=await p.from("contacts").update({reports_to:r,updated_at:new Date().toISOString()}).eq("id",a),{error:l}=await p.from("contacts").update({reports_to:t,updated_at:new Date().toISOString()}).eq("id",e);if(i||l){en.toast.error("Failed to update reporting structure");let{nodes:e,edges:t}=ek(ej.current,ev.current,o);S(e),D(t);return}g(n=>n.map(n=>n.id===a?{...n,reports_to:r}:n.id===e?{...n,reports_to:t}:n))}async function eW(e){let t=J.current;if(!t)return;let n=t.member_ids.filter(t=>t!==e),a={...t.reporting};for(let t of(delete a[e],Q.current))t.id!==e&&t.reports_to===e&&(a[t.id]=null);q(e=>e.map(e=>e.id===t.id?{...e,member_ids:n,reporting:a}:e)),await el(p,t.id,{member_ids:n,reporting:a})}async function eG(e){let t=eh.current;if(!t)return void en.toast.error("Not signed in");eE();let{reporting:n,departments:r,memberIds:s}=function(e){let t={},n={},a=[];for(let r of e)!function e(r,s){for(let i of(t[r.contact.id]=s,n[r.contact.id]=r.contact.department,a.push(r.contact.id),r.children))e(i,r.contact.id)}(r,null);return{reporting:t,departments:n,memberIds:a}}(ej.current),i=await eo(p,{companyId:a,ownerId:t,workspaceId:ex.current,name:e,memberIds:s,reporting:n,departments:r,nodePositions:function(){let e={};for(let t of ew.current)e[t.id]={x:t.position.x,y:t.position.y};return e}(),sortOrder:U.length});i?(q(e=>[...e,i]),ee.current=i.node_positions,ef.current=i.id,H(i.id),en.toast.success(`Created "${i.name}"`)):en.toast.error("Failed to create buying group")}async function eJ(e,t){q(n=>n.map(n=>n.id===e?{...n,name:t}:n)),await el(p,e,{name:t})}async function eK(e){let t=U.find(t=>
1t.id===e),n=eh.current;if(!t||!n)return;eE();let r=await eo(p,{companyId:a,ownerId:n,workspaceId:ex.current,name:`${t.name} copy`,memberIds:t.member_ids,reporting:t.reporting,departments:t.departments,nodePositions:t.node_positions,sortOrder:U.length});r?(q(e=>[...e,r]),ee.current=r.node_positions,ef.current=r.id,H(r.id)):en.toast.error("Failed to duplicate buying group")}async function eX(e){q(t=>t.filter(t=>t.id!==e)),ef.current===e&&(ep.current&&clearTimeout(ep.current),eu.current=null,ee.current=null,ef.current=er,H(er)),await ed(p,e),en.toast.success("Buying group deleted")}async function eZ(e){q(t=>t.map(t=>({...t,is_default:t.id===e}))),await ec(p,a,e)}async function eQ(){L(!0);try{let e=new Map;for(let t of Z)if(t.persona&&"none"!==t.persona){let n=x.find(e=>e.value===t.persona);n&&e.set(t.id,{label:n.label,color:n.color})}let t=await et(Z,$,o,e),n=new Blob([t],{type:"application/pdf"}),a=URL.createObjectURL(n),r=document.createElement("a");r.href=a,r.download=`${o?.name||"org-chart"}-${G?G.name:"org-chart"}.pdf`,r.click(),URL.revokeObjectURL(a)}catch{en.toast.error("Failed to generate PDF")}finally{L(!1)}}let eY=(0,n.useMemo)(()=>{let e=new Set(Z.map(e=>e.id));return l.filter(t=>!e.has(t.id))},[l,Z]),e0=(0,n.useMemo)(()=>Z.filter(e=>e.reports_to),[Z]),e1=(0,t.jsx)(eg,{groups:U,activeId:B,onSelect:function(e){if(e===ef.current)return;eE();let t=U.find(t=>t.id===e)??null;ee.current=t?t.node_positions:null,ef.current=e,H(e)},onCreate:eG,onRename:eJ,onDuplicate:eK,onDelete:eX,onSetDefault:eZ});if(0===K.length&&0===U.length)return(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-center space-y-3",children:[(0,t.jsx)("div",{className:"flex h-12 w-12 items-center justify-center rounded-full bg-muted",children:(0,t.jsx)(b.OrgChartIcon,{className:"h-6 w-6 text-muted-foreground"})}),(0,t.jsx)("p",{className:"text-sm font-medium",children:"No people in this company"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Add people to see the org chart"}),eY.length>0&&(0,t.jsx)(eM,{contacts:eY,open:j,onOpenChange:N,onAdd:ez})]});let e2={nodes:C,edges:T,nodeTypes:eS,edgeTypes:eT,onNodesChange:eH,onNodeDragStart:function(e,t){if(t.id.startsWith("__dept_")){let e=t.id.slice(7,-2),n=O(ej.current,e);if(!n)return;let a=new Set([e,...z(n)]),r=new Map;for(let e of ew.current)(e.id===t.id||a.has(e.id))&&r.set(e.id,{x:e.position.x,y:e.position.y});eC.current=r;return}let n=O(ej.current,t.id);e_.current=n?z(n):new Set},onNodeDrag:function(e,t){if(t.id.startsWith("__dept_"))return;let n=t.position.x+150,a=t.position.y+70,r=null,s=120;for(let e of ew.current){if(e.id===t.id||"__company_header__"===e.id||e.id.startsWith("__dept_"))continue;let i=n-(e.position.x+150),o=a-(e.position.y+70),l=Math.sqrt(i*i+o*o);l<s&&(s=l,r=e.id)}_(e=>e!==r?r:e)},onNodeDragStop:function(e,t){if(eU({v:null,h:null}),t.id.startsWith("__dept_")){eC.current=null,S(e=>(eL(e),e));return}_(null),k&&k!==t.id?e_.current.has(k)?eV(t.id,k):eA(t.id,k):S(e=>(eL(e),e))},fitView:!0,fitViewOptions:{padding:.15,minZoom:.05},minZoom:.05,maxZoom:2,elementsSelectable:!0,multiSelectionKeyCode:"Shift",nodesConnectable:!1,selectionMode:i.SelectionMode.Partial,panOnScroll:!1,zoomOnPinch:!0,defaultEdgeOptions:{type:"orgStep",style:{stroke:"var(--foreground)",strokeWidth:1.5,opacity:.25}},proOptions:{hideAttribution:!0},className:"org-chart-canvas"},e5="flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-accent transition-colors";return(0,t.jsx)(eN.Provider,{value:{setRoot:e=>eA(e,null),dropTarget:k,setDepartment:eF,addGroup:()=>{},nonRootContacts:e0,removeFromGroup:G?eW:null},children:(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[e1,(0,t.jsx)("p",{className:"hidden sm:block text-xs text-muted-foreground truncate",children:"Drag people onto others to change reporting"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,t.jsx)("button",{onClick:eQ,disabled:M,title:M?"Exporting...":"Download PDF",className:(0,P.cn)(e5,"disabled:opacity-50"),children:(0,t.jsx)(y.DownloadIcon,{className:"h-3.5 w-3.5"})}),(0,t.jsx)(eM,{contacts:eY,open:j,onOpenChange:N,onAdd:ez}),(0,t.jsx)("button",{onClick:()=>A(!0),title:"Expand",className:e5,children:(0,t.jsx)(d.Maximize2,{className:"h-3.5 w-3.5"})})]})]}),!E&&(0,t.jsx)("div",{className:"h-[350px] sm:h-[500px] rounded-xl border overflow-hidden",children:(0,t.jsxs)(s.ReactFlow,{...e2,zoomOnScroll:!1,preventScrolling:!1,children:[(0,t.jsx)(s.Backgroun
1d,{gap:18,size:1.5,color:"var(--accent)"}),(0,t.jsx)(e$,{}),(0,t.jsx)(eD,{v:eO.v,h:eO.h}),0===Z.length&&(0,t.jsx)(eI,{inGroup:!!G})]},"embedded")}),(0,t.jsx)(w.Dialog,{open:E,onOpenChange:e=>{A(e),e||m?.()},children:(0,t.jsx)(w.DialogContent,{showCloseButton:!1,className:"!max-w-[calc(100%-1rem)] sm:!max-w-[calc(100%-2rem)] w-full !h-[calc(100%-1rem)] sm:!h-[calc(100%-2rem)] !p-0 !rounded-2xl overflow-hidden",children:(0,t.jsxs)("div",{className:"flex flex-col h-full",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-3 sm:px-4 py-2.5 border-b shrink-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 sm:gap-2.5 min-w-0",children:[o?.logo_url&&(0,t.jsx)(v.CompanyLogo,{domain:o.domain,companyName:o.name,logoUrl:o.logo_url,size:"sm"}),(0,t.jsx)("p",{className:"text-sm font-medium truncate",children:o?.name?`${o.name} - Org Chart`:"Org Chart"}),e1]}),(0,t.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,t.jsx)("button",{onClick:eQ,disabled:M,title:M?"Exporting...":"Download PDF",className:(0,P.cn)(e5,"disabled:opacity-50"),children:(0,t.jsx)(y.DownloadIcon,{className:"h-3.5 w-3.5"})}),(0,t.jsx)(eM,{contacts:eY,open:j,onOpenChange:N,onAdd:ez}),(0,t.jsx)("button",{onClick:()=>{A(!1),m?.()},className:e5,children:(0,t.jsx)(u.X,{className:"h-3.5 w-3.5"})})]})]}),(0,t.jsx)("div",{className:"flex-1 min-h-0",children:(0,t.jsx)(s.ReactFlowProvider,{children:(0,t.jsxs)(s.ReactFlow,{...e2,children:[(0,t.jsx)(s.Background,{gap:18,size:1.5,color:"var(--accent)"}),(0,t.jsx)(e$,{}),(0,t.jsx)(eD,{v:eO.v,h:eO.h}),0===Z.length&&(0,t.jsx)(eI,{inGroup:!!G})]},"modal")})})]})})})]})})}function eI({inGroup:e}){return(0,t.jsxs)("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 pointer-events-none text-center px-6",children:[(0,t.jsx)("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-muted",children:e?(0,t.jsx)(g.PeopleGroupIcon,{className:"h-5 w-5 text-muted-foreground"}):(0,t.jsx)(b.OrgChartIcon,{className:"h-5 w-5 text-muted-foreground"})}),(0,t.jsx)("p",{className:"text-sm font-medium",children:e?"This buying group is empty":"No people in this company"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Use Add Person to put someone on the chart"})]})}function e$(){let{zoomIn:e,zoomOut:n,fitView:a}=(0,s.useReactFlow)();return(0,t.jsxs)("div",{className:"org-chart-controls absolute bottom-3 left-3 sm:bottom-4 sm:left-4 z-10 flex flex-col items-center rounded-full border border-card-border bg-[var(--muted)] p-1 gap-0.5 sm:gap-1",children:[(0,t.jsx)("button",{onClick:()=>e({duration:200}),className:"flex h-9 w-9 sm:h-7 sm:w-7 items-center justify-center rounded-full text-muted-foreground hover:text-foreground hover:bg-white dark:hover:bg-white/10 transition-colors active:bg-white/20",title:"Zoom in",children:(0,t.jsx)(l.Plus,{className:"h-4 w-4 sm:h-3.5 sm:w-3.5"})}),(0,t.jsx)("button",{onClick:()=>n({duration:200}),className:"flex h-9 w-9 sm:h-7 sm:w-7 items-center justify-center rounded-full text-muted-foreground hover:text-foreground hover:bg-white dark:hover:bg-white/10 transition-colors active:bg-white/20",title:"Zoom out",children:(0,t.jsx)(c.Minus,{className:"h-4 w-4 sm:h-3.5 sm:w-3.5"})}),(0,t.jsx)("button",{onClick:()=>a({padding:.3,duration:200,minZoom:.05}),className:"flex h-9 w-9 sm:h-7 sm:w-7 items-center justify-center rounded-full text-muted-foreground hover:text-foreground hover:bg-white dark:hover:bg-white/10 transition-colors active:bg-white/20",title:"Fit to view",children:(0,t.jsx)(d.Maximize2,{className:"h-4 w-4 sm:h-3.5 sm:w-3.5"})})]})}let eR=e=>[e.name,e.email];function eM({contacts:e,open:n,onOpenChange:a,onAdd:r}){let{query:s,setQuery:i,items:o,searching:l,truncated:c}=(0,ej.useOptionSearch)({base:e,search:ej.searchContactOptions,searchText:eR});return(0,t.jsxs)(N.Popover,{open:n,onOpenChange:a,children:[(0,t.jsx)(N.PopoverTrigger,{asChild:!0,children:(0,t.jsx)("button",{title:"Add Person",className:"flex h-7 w-7 items-center justify-center squircle text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",children:(0,t.jsx)(j.AddPersonIcon,{className:"h-3.5 w-3.5"})})}),(0,t.jsx)(N.PopoverContent,{className:"w-64 p-0",align:"end",children:(0,t.jsxs)(k.Command,{shouldFilter:!1,children:[(0,t.jsx)(k.CommandInput,{placeholder:"Search contacts...",value:s,onValueChange:i}),(0,t.jsxs)(k.CommandList,{children:[0===o.length&&(0,t.jsx)(k.CommandEmpty,{children:l?"Searching…":"No contacts found."}),(0,t.jsx)(k.CommandGroup,{children:o.map(e=>(0,t.jsxs)(k.CommandItem,{value:e.id,onSelect:()=>r(e.id),children:[(0,t.jsx)("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-muted text-[10px] font-medium overflow-hidden",children:e.imageUrl?(0,t.jsx)("img",{src:e.imageUrl,alt:"",className:"h-full w-full object-cover"}):e.name.charAt(0).toUpperCase()}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"truncate text-sm",children:e.name}),(0,t.jsx)("p",{className:"truncate text-xs text-muted-foreground",children:e.email})]})]},e.id))}),c&&(0,t.jsxs)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:["Showing the first ",o.length,". Type to search everyone."]})]})]})})]})}e.s(["CompanyOrgChart",0,function(e){return(0,t.jsx)(s.ReactFlowProvider,{children:(0,t.jsx)(eP,{...e})})}],428516)},665359,e=>{"use strict";var t=e.i(843476),n=e.i(271645),a=e.i(611423),r=e.i(941388),s=e.i(37727),i=e.i(531278),o=e.i(643531),l=e.i(344523),c=e.i(488844),d=e.i(541071),u=e.i(223622),m=e.i(367240),p=e.i(495242),h=e.i(431343),x=e.i(213788),f=e.i(852861),g=e.i(548106),b=e.i(920755),y=e.i(167881),j=e.i(463415),v=e.i(59377),w=e.i(753751),N=e.i(647163),k=e.i(846696),_=e.i(119925),C=e.i(327147);function S({sub:e,products:n,editable:a,inherited:r,inheritedFromCompanyName:s,unlinking:i,canceling:o,pausing:l,onUnlink:c,onCancel:d,onPause:u,onUpdate:m,companyDomain:p,companyLogoUrl:h,hideActions:f}){let g=M[e.status]??M.incomplete;return(0,t.jsxs)("div",{className:"group relative flex items-start gap-2 p-2 -mx-2 rounded-lg",children:[(0,t.jsx)(x.CompanyLogo,{domain:p,companyName:e.product_name??void 0,logoUrl:h,size:"sm",className:"mt-0.5"}),(0,t.jsxs)("div",{className:"min-w-0 flex-1 pr-7",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap",children:[a?(0,t.jsx)(I,{sub:e,products:n,onUpdate:m}):(0,t.jsx)("p",{className:"text-sm font-medium truncate",children:e.product_name||"Subscription"}),(0,t.jsx)("span",{className:`inline-flex items-center rounded-full px-1.5 py-0.5 text-[10px] font-medium ${g.bg} ${g.text}`,children:e.status}),r&&s&&(0,t.jsxs)("span",{className:"inline-flex items-center rounded-full bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground",title:"Subscription belongs to parent company",children:["via ",s]})]}
1),(0,t.jsx)(D,{sub:e,editable:a,onUpdate:m})]}),!f&&(c||d||u)&&(0,t.jsx)(T,{sub:e,unlinking:i,canceling:o,pausing:l,onUnlink:c,onCancel:d,onPause:u,className:"absolute top-1 right-1"})]})}function T({sub:e,unlinking:n,canceling:a,pausing:r,onUnlink:i,onCancel:o,onPause:l,className:c}){let x=n||a||r,f="active"===e.status||"trialing"===e.status,g=null!=e.pause_collection;return(0,t.jsxs)(j.DropdownMenu,{children:[(0,t.jsx)(j.DropdownMenuTrigger,{asChild:!0,children:(0,t.jsx)("button",{type:"button",disabled:x,className:(0,N.cn)("p-1 rounded hover:bg-muted text-muted-foreground transition-opacity data-[state=open]:opacity-100",c?.includes("-top-")?"opacity-70 hover:opacity-100":"opacity-0 group-hover:opacity-100",c),title:"Subscription actions",children:x?(0,t.jsx)(C.ButtonSpinner,{}):(0,t.jsx)(d.MoreHorizontal,{className:"h-3.5 w-3.5"})})}),(0,t.jsxs)(j.DropdownMenuContent,{align:"end",className:"w-56",children:[l&&f&&(g?(0,t.jsxs)(j.DropdownMenuItem,{onClick:()=>l("resume"),className:"gap-2",children:[(0,t.jsx)(h.Play,{className:"h-3.5 w-3.5"}),"Resume subscription"]}):(0,t.jsxs)(j.DropdownMenuItem,{onClick:()=>l("pause"),className:"gap-2",children:[(0,t.jsx)(p.Pause,{className:"h-3.5 w-3.5"}),"Pause subscription"]})),o&&f&&(e.cancel_at_period_end?(0,t.jsxs)(j.DropdownMenuItem,{onClick:()=>o("reactivate"),className:"gap-2",children:[(0,t.jsx)(m.RotateCcw,{className:"h-3.5 w-3.5"}),"Don't cancel"]}):(0,t.jsxs)(j.DropdownMenuItem,{onClick:()=>o("at_period_end"),className:"gap-2",children:[(0,t.jsx)(u.Ban,{className:"h-3.5 w-3.5"}),"Cancel at period end"]})),o&&"canceled"!==e.status&&(0,t.jsxs)(j.DropdownMenuItem,{onClick:()=>{confirm("Cancel this subscription immediately? This cannot be undone.")&&o("immediately")},className:"gap-2 text-destructive focus:text-destructive",children:[(0,t.jsx)(s.X,{className:"h-3.5 w-3.5"}),"Cancel immediately"]}),i&&(0,t.jsxs)(j.DropdownMenuItem,{onClick:i,className:"gap-2",children:[(0,t.jsx)(s.X,{className:"h-3.5 w-3.5"}),"Unlink from company"]})]})]})}function D({sub:e,editable:n,onUpdate:a}){let r=e.quantity??1,s=e.amount*r,i=e.discount_percent??0,o=i>0?Math.round(s*(1-i/100)):s;return(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:[L(o,e.currency),e.interval&&`/${e.interval}`,i>0&&(0,t.jsxs)(t.Fragment,{children:[" ",(0,t.jsx)("span",{className:"line-through text-muted-foreground/50",children:L(s,e.currency)})," ",(0,t.jsxs)("span",{className:"text-success",children:["-",i,"%"]})]}),n&&0===i&&(0,t.jsxs)(t.Fragment,{children:[" (",(0,t.jsx)($,{sub:e,onUpdate:a}),")"]}),!n&&r>1&&0===i&&(0,t.jsxs)(t.Fragment,{children:[" (",r," × ",L(e.amount,e.currency),")"]}),e.current_period_end&&"active"===e.status&&(0,t.jsxs)(t.Fragment,{children:[" · renews ",new Date(e.current_period_end).toLocaleDateString("en-GB")]}),e.cancel_at_period_end&&(0,t.jsx)(t.Fragment,{children:" · cancels at period end"}),e.pause_collection&&(0,t.jsxs)(t.Fragment,{children:[" · ",(0,t.jsx)("span",{className:"text-orange-600",children:"paused"})]})]})}async function P(e,t){let n=await fetch("/api/stripe/subscriptions/update",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({stripe_subscription_id:e,...t})});if(!n.ok)throw Error((await n.json().catch(()=>({}))).error||"Failed to update subscription");return(await n.json()).subscription??{}}function I({sub:e,products:a,onUpdate:r}){let[s,i]=(0,n.useState)(!1);async function d(t){if(t.stripe_price_id!==e.stripe_price_id){i(!0);try{await P(e.stripe_subscription_id,{stripe_price_id:t.stripe_price_id}),r({stripe_price_id:t.stripe_price_id,stripe_product_id:t.stripe_product_id,product_name:t.name,amount:Math.round(100*t.price),currency:t.currency.toLowerCase(),interval:"unit"===t.unit?null:t.unit}),k.toast.success("Plan updated")}catch(e){k.toast.error(e instanceof Error?e.message:"Failed to update plan")}finally{i(!1)}}}return(0,t.jsxs)(j.DropdownMenu,{children:[(0,t.jsx)(j.DropdownMenuTrigger,{asChild:!0,children:(0,t.jsxs)("button",{type:"button",disabled:s,className:(0,N.cn)("inline-flex items-center gap-1 text-sm font-medium rounded-sm px-1 -mx-1 transition-colors cursor-pointer hover:bg-accent truncate",N.haloMaxWidth),children:[s?(0,t.jsx)(C.ButtonSpinner,{className:"shrink-0"}):null,(0,t.jsx)(C.ShimmerLabel,{active:s,className:"truncate",children:e.product_name||"Subscription"}),(0,t.jsx)(l.ChevronsUpDown,{className:"h-3 w-3 text-muted-foreground shrink-0"})]})}),(0,t.jsx)(j.DropdownMenuContent,{align:"start",className:"max-w-80",children:a.map(n=>{let a=e.stripe_price_id===n.stripe_price_id||e.stripe_product_id===n.stripe_product_id;return(0,t.jsxs)(j.DropdownMenuItem,{onClick:()=>d(n),className:"gap-2",children:[(0,t.jsx)(o.Check,{className:(0,N.cn)("h-3.5 w-3.5 shrink-0",a?"opacity-100":"opacity-0")}),(0,t.jsx)("div",{className:"flex h-6 w-6 shrink-0 items-center justify-center squircle bg-muted",children:n.image_url?(0,t.jsx)(g.SafeImage,{src:n.image_url,alt:n.name,className:"h-full w-full object-cover",fallback:(0,t.jsx)(c.Package,{className:"h-3 w-3 text-muted-foreground"})}):(0,t.jsx)(c.Package,{className:"h-3 w-3 text-muted-foreground"})}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("p",{className:"text-sm truncate",children:n.name}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:function(e){let t=Math.round(100*e.price);if(0===t)return e.unit&&"unit"!==e.unit?`Usage-based/${e.unit}`:"Usage-based";let n=new Intl.NumberFormat("en-US",{style:"currency",currency:e.currency.toUpperCase(),minimumFractionDigits:2*(t%100!=0)}).format(e.price);return e.unit&&"unit"!==e.unit?`${n}/${e.unit}`:n}(n)})]})]},n.id)})})]})}function $({sub:e,onUpdate:a}
1){let r=e.quantity??1,[s,o]=(0,n.useState)(!1),[l,c]=(0,n.useState)(r.toString()),[d,u]=(0,n.useState)(!1),m=(0,n.useRef)(null),p=(0,n.useRef)(!1);(0,n.useEffect)(()=>{c(r.toString())},[r]),(0,n.useEffect)(()=>{s&&(m.current?.focus(),m.current?.select())},[s]);let h=(0,n.useCallback)(async()=>{if(p.current)return;let t=parseInt(l,10),n=isNaN(t)||t<1?1:t;if(n===r){c(r.toString()),o(!1);return}p.current=!0,u(!0);try{await P(e.stripe_subscription_id,{quantity:n}),a({quantity:n}),k.toast.success("Seats updated"),o(!1)}catch(e){k.toast.error(e instanceof Error?e.message:"Failed to update seats"),c(r.toString())}finally{u(!1),p.current=!1}},[l,r,e.stripe_subscription_id,a]);return s?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("input",{ref:m,type:"number",min:1,value:l,onChange:e=>c(e.target.value),onKeyDown:e=>{"Enter"===e.key&&h(),"Escape"===e.key&&(c(r.toString()),o(!1))},onBlur:h,disabled:d,className:"bg-transparent w-[4ch] px-0.5 py-0 text-xs outline-none caret-foreground tabular-nums [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none"}),d&&(0,t.jsx)(i.Loader2,{className:"inline h-2.5 w-2.5 animate-spin"}),(0,t.jsxs)("span",{children:[" × ",L(e.amount,e.currency)]})]}):(0,t.jsxs)("button",{type:"button",onClick:()=>o(!0),className:"text-left rounded-sm px-0.5 transition-colors cursor-text hover:underline underline-offset-2 decoration-foreground/30",title:"Click to edit seats",children:[r," × ",L(e.amount,e.currency)]})}function R({companyId:e,linkedIds:s,onLink:i}
1){let[o,l]=(0,n.useState)(!1),[c,d]=(0,n.useState)(!1),[u,m]=(0,n.useState)([]),p=(0,b.createClient)();return(0,n.useEffect)(()=>{o&&(d(!0),p.from("stripe_subscriptions").select("*").is("company_id",null).order("created_at",{ascending:!1}).then(({data:e})=>{m((e||[]).filter(e=>!s.includes(e.id))),d(!1)}))},[o,s,p]),(0,t.jsxs)(v.Popover,{open:o,onOpenChange:l,children:[(0,t.jsx)(v.PopoverTrigger,{asChild:!0,children:(0,t.jsxs)(y.Button,{variant:"ghost",size:"sm",className:"w-full justify-start text-muted-foreground h-8 px-2 -mx-2",children:[(0,t.jsx)(r.Plus,{className:"h-3.5 w-3.5 mr-1.5"}),"Link subscription"]})}),(0,t.jsx)(v.PopoverContent,{className:"w-80 p-0",align:"start",children:(0,t.jsxs)(w.Command,{children:[(0,t.jsx)(w.CommandInput,{placeholder:"Search by product, customer, email..."}),(0,t.jsx)(w.CommandList,{children:c?(0,t.jsx)("div",{className:"py-1",children:Array.from({length:4}).map((e,n)=>(0,t.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5",children:[(0,t.jsx)(a.Skeleton,{className:"h-7 w-7 rounded-full shrink-0"}),(0,t.jsxs)("div",{className:"flex-1 space-y-1.5",children:[(0,t.jsx)(a.Skeleton,{className:"h-3.5 w-32"}),(0,t.jsx)(a.Skeleton,{className:"h-3 w-20"})]}),(0,t.jsx)(a.Skeleton,{className:"h-3.5 w-12"})]},n))}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(w.CommandEmpty,{children:"No unlinked subscriptions found."}),(0,t.jsx)(w.CommandGroup,{children:u.map(e=>(0,t.jsxs)(w.CommandItem,{value:[e.product_name,e.customer_name,e.customer_email,e.stripe_subscription_id].filter(Boolean).join(" "),onSelect:()=>{i(e),l(!1)},children:[(0,t.jsx)(x.CompanyLogo,{domain:(0,f.extractCompanyDomain)(e.customer_email??""),companyName:e.customer_name??void 0,size:"xs",className:"mr-2 shrink-0"}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"text-sm truncate",children:e.product_name||"Subscription"}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground truncate",children:[e.customer_name||e.customer_email||"Unknown customer"," · ",L(e.amount,e.currency),e.interval&&`/${e.interval}`," · ",e.status]})]})]},e.id))})]})})]})})]})}let M={active:{bg:"bg-success/10",text:"text-success"},trialing:{bg:"bg-blue-500/10",text:"text-blue-600"},past_due:{bg:"bg-orange-500/10",text:"text-orange-600"},canceled:{bg:"bg-muted",text:"text-muted-foreground"},unpaid:{bg:"bg-destructive/10",text:"text-destructive"},incomplete:{bg:"bg-muted",text:"text-muted-foreground"},paused:{bg:"bg-muted",text:"text-muted-foreground"}};function L(e,t){return new Intl.NumberFormat("en-US",{style:"currency",currency:t.toUpperCase(),minimumFractionDigits:0}).format(e/100)}e.s(["CompanySubscriptions",0,function({companyId:e,companyDomain:a,companyLogoUrl:r,subscriptions:s,products:i=[],inheritedSubscriptionIds:o,inheritedFromCompanyName:l,onChanged:c}
1){let[d,u]=(0,n.useState)(s),[m,p]=(0,n.useState)(null),[h,x]=(0,n.useState)(null),[f,g]=(0,n.useState)(null),y=(0,b.createClient)();async function j(e,t){g(e.id);try{let n=await fetch("/api/stripe/subscriptions/pause",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({stripe_subscription_id:e.stripe_subscription_id,mode:t})}),a=await n.json().catch(()=>({}));if(!n.ok)return void k.toast.error(a.error||"Failed to update subscription");C(e.id,{status:a.subscription?.status??e.status,pause_collection:a.subscription?.pause_collection??null}),k.toast.success("pause"===t?"Subscription paused":"Subscription resumed")}catch(e){k.toast.error(e instanceof Error?e.message:"Failed to update subscription")}finally{g(null)}}async function v(e,t){x(e.id);try{let n=await fetch("/api/stripe/subscriptions/cancel",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({stripe_subscription_id:e.stripe_subscription_id,mode:t})}),a=await n.json().catch(()=>({}));if(!n.ok)return void k.toast.error(a.error||"Failed to update subscription");C(e.id,{status:a.subscription?.status??e.status,cancel_at_period_end:a.subscription?.cancel_at_period_end??e.cancel_at_period_end}),k.toast.success("immediately"===t?"Subscription canceled":"reactivate"===t?"Subscription reactivated":"Subscription will cancel at period end")}catch(e){k.toast.error(e instanceof Error?e.message:"Failed to update subscription")}finally{x(null)}}async function w(e){p(e);let{error:t}=await y.from("stripe_subscriptions").update({company_id:null,updated_at:new Date().toISOString()}).eq("id",e);(p(null),t)?k.toast.error("Failed to unlink subscription"):(u(t=>t.filter(t=>t.id!==e)),c?.())}async function N(t){let{data:{user:n}}=await y.auth.getUser();if(!n)return void k.toast.error("You must be logged in");let{error:a}=await y.from("stripe_subscriptions").update({company_id:e,updated_at:new Date().toISOString()}).eq("id",t.id);a?k.toast.error("Failed to link subscription"):(t.stripe_customer_id&&await (0,_.linkStripeCustomerToCompany)(y,n.id,t.stripe_customer_id,e),u(n=>[...n,{...t,company_id:e}]),c?.())}function C(e,t){u(n=>n.map(n=>n.id===e?{...n,...t}:n)),c?.()}(0,n.useEffect)(()=>{u(s)},[s]);let D=e=>o?.includes(e.id)??!1,P=1===d.length,I=P?d[0]:null,$=!!I&&D(I);return(0,t.jsxs)("div",{className:"relative space-y-2",children:[P&&I&&!$&&(0,t.jsx)(T,{sub:I,unlinking:m===I.id,canceling:h===I.id,pausing:f===I.id,onUnlink:()=>w(I.id),onCancel:e=>v(I,e),onPause:e=>j(I,e),className:"absolute -top-9 right-0"}),0===d.length&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"No subscriptions linked."}),d.map(e=>{let n=D(e);return(0,t.jsx)(S,{sub:e,products:i,editable:!n&&i.length>0&&("active"===e.status||"trialing"===e.status),inherited:n,inheritedFromCompanyName:n?l:void 0,unlinking:m===e.id,canceling:h===e.id,pausing:f===e.id,onUnlink:n?void 0:()=>w(e.id),onCancel:n?void 0:t=>v(e,t),onPause:n?void 0:t=>j(e,t),onUpdate:t=>C(e.id,t),companyDomain:a,companyLogoUrl:r,hideActions:P},e.id)}),(0,t.jsx)(R,{companyId:e,linkedIds:d.map(e=>e.id),onLink:N})]})}])},210578,e=>{"use strict";var t=e.i(843476),n=e.i(271645),a=e.i(647163);let r={xs:"h-5 w-5 text-[12px]",sm:"h-8 w-8 text-[15px]",md:"h-10 w-10 text-[18px]"};e.s(["ContactAvatar",0,function({imageUrl:e,name:s,size:i="xs",shape:o="squircle",className:l}){let[c,d]=(0,n.useState)(!1),u=!!e&&!c;return(0,t.jsx)("div",{className:(0,a.cn)("flex shrink-0 items-center justify-center bg-muted font-semibold","circle"===o?"rounded-full overflow-hidden":"squircle",u?"avatar-border":"",r[i],l),children:u?(0,t.jsx)("img",{src:e,alt:s,className:"h-full w-full object-cover",onError:()=>d(!0)}):(0,t.jsx)("span",{className:"text-foreground/60 leading-none",children:s.charAt(0).toUpperCase()})})}])},470138,e=>{"use strict";var t=e.i(843476),n=e.i(271645);e.i(807567);var a=e.i(611423),r=e.i(815926),s=e.i(361340),i=e.i(3895);function o({card:e,parentEntityType:n,parentEntityId:a}){if("rich_text"===e.card_kind){let n=e.config.html||"";return(0,t.jsx)("p",{className:"whitespace-pre-wrap text-sm text-muted-foreground",children:n||"-"})}return"sub_record_list"===e.card_kind?(0,t.jsx)(c,{config:e.config,parentEntityId:a}):"widget"===e.card_kind?(0,t.jsx)(l,{card:e,parentEntityType:n,parentEntityId:a}):(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"No fields configured."})}function l({card:e,parentEntityType:r,parentEntityId:s}
1){let o=e.config,[c,d]=(0,n.useState)(!0),[u,m]=(0,n.useState)(null),[p,h]=(0,n.useState)(void 0),x=(0,n.useRef)(null),f=(0,n.useRef)(!1),g=(0,n.useRef)(!1),b=(0,n.useRef)(void 0);(0,n.useEffect)(()=>{let t=!0;return d(!0),fetch(`/api/custom-records?card_id=${e.id}&parent_id=${s}`,{cache:"no-store"}).then(e=>e.ok?e.json():[]).then(e=>{if(!t)return;let n=e[0];m(n?.id??null);let a=n?.data?.value;h(a),b.current=a}).catch(()=>{}).finally(()=>{t&&d(!1)}),()=>{t=!1}},[e.id,s]);let y=(0,n.useCallback)(async()=>{if(f.current){g.current=!0;return}f.current=!0;try{let t={value:b.current},n=u?await fetch("/api/custom-records",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:u,data:t})}):await fetch("/api/custom-records",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({card_id:e.id,parent_entity_type:r,parent_entity_id:s,data:t})});if(n.ok){let e=await n.json();!u&&e?.id&&m(e.id)}}finally{f.current=!1,g.current&&(g.current=!1,y())}},[u,e.id,r,s]),j=(0,n.useCallback)(e=>{h(e),b.current=e,x.current&&clearTimeout(x.current),x.current=setTimeout(y,600)},[y]);return c?(0,t.jsx)(a.Skeleton,{className:"h-16 w-full rounded-lg"}):(0,t.jsx)(i.WidgetControl,{widgetType:o.widgetType,config:o.config,value:p,onChange:j})}function c({config:e,parentEntityId:r}){let[s,i]=(0,n.useState)(null),o=e.limit??5;return((0,n.useEffect)(()=>{if(!e.tabId)return void i([]);let t=!0;return fetch(`/api/custom-records?tab_id=${e.tabId}&parent_id=${r}`,{cache:"no-store"}).then(e=>e.ok?e.json():[]).then(e=>{t&&i(e)}).catch(()=>{t&&i([])}),()=>{t=!1}},[e.tabId,r]),null===s)?(0,t.jsx)("div",{className:"space-y-2",children:[0,1].map(e=>(0,t.jsx)(a.Skeleton,{className:"h-5 w-full"},e))}):0===s.length?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"No entries."}):(0,t.jsxs)("ul",{className:"space-y-1.5 text-sm",children:[s.slice(0,o).map(e=>{let n=Object.values(e.data).find(e=>null!=e&&""!==e);return(0,t.jsx)("li",{className:"truncate text-foreground/90",children:n?String(n):(0,t.jsx)("span",{className:"text-muted-foreground",children:"Entry"})},e.id)}),s.length>o&&(0,t.jsxs)("li",{className:"text-xs text-muted-foreground",children:["+",s.length-o," more"]})]})}e.s(["CustomCardView",0,function({card:e,parentEntityType:n,parentEntityId:a}){let i=(0,r.resolveCustomIcon)(e.icon);return(0,t.jsxs)("section",{className:"group relative rounded-[20px] border border-card-border bg-card p-4",children:[(0,t.jsx)(s.EditCardButton,{card:e}),(0,t.jsxs)("h3",{className:"mb-3 flex items-center gap-2 text-sm font-semibold",children:[(0,t.jsx)(i,{className:"h-4 w-4 text-muted-foreground"}),e.name]}),(0,t.jsx)(o,{card:e,parentEntityType:n,parentEntityId:a})]})}])},418001,e=>{"use strict";var t=e.i(843476),n=e.i(271645),a=e.i(618566),r=e.i(643531),s=e.i(531278),i=e.i(424154);e.i(807567);var o=e.i(611423),l=e.i(167881),c=e.i(846696),d=e.i(218834),u=e.i(800860),m=e.i(3895),p=e.i(361340),h=e.i(102766),x=e.i(327147);function f({boxed:e,children:n}){return e?(0,t.jsx)("div",{className:"rounded-[20px] border border-card-border bg-light-oat dark:bg-muted/30 p-4",children:n}):(0,t.jsx)(t.Fragment,{children:n})}function g({html:e}){let a=(0,n.useRef)(null);return(0,n.useEffect)(()=>{let t=a.current;if(!t)return;let n=i.default.sanitize(e||"",{ADD_ATTR:["target"],RETURN_DOM_FRAGMENT:!0});t.replaceChildren(n)},[e]),(0,t.jsx)("div",{ref:a,className:"tiptap"})}function b({label:e,onRun:a}){let[r,s]=(0,n.useState)(!1);return(0,t.jsxs)(l.Button,{onClick:async()=>{s(!0);try{await a()}finally{s(!1)}},disabled:r,children:[r&&(0,t.jsx)(x.ButtonSpinner,{}),(0,t.jsx)(x.ShimmerLabel,{active:r,children:e})]})}e.s(["CustomTabView",0,function({tab:e,parentEntityType:i,parentEntityId:l}
1){let x=(0,a.useRouter)(),y=e.field_schema,[j,v]=(0,n.useState)(!1),[w,N]=(0,n.useState)(!0),[k,_]=(0,n.useState)(null),[C,S]=(0,n.useState)({}),[T,D]=(0,n.useState)("idle"),P=(0,n.useRef)(null),I=(0,n.useRef)(!1),$=(0,n.useRef)(!1),R=(0,n.useRef)({});(0,n.useEffect)(()=>{let t=!0;return N(!0),fetch(`/api/custom-records?tab_id=${e.id}&parent_id=${l}`,{cache:"no-store"}).then(e=>e.ok?e.json():[]).then(e=>{if(!t)return;let n=e[0];_(n?.id??null),S(n?.data??{}),R.current=n?.data??{}}).catch(()=>{t&&c.toast.error("Could not load this tab")}).finally(()=>{t&&N(!1)}),()=>{t=!1}},[e.id,l]);let M=(0,n.useCallback)(async()=>{if(I.current){$.current=!0;return}I.current=!0,D("saving");try{let t=R.current,n=k?await fetch("/api/custom-records",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:k,data:t})}):await fetch("/api/custom-records",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tab_id:e.id,parent_entity_type:i,parent_entity_id:l,data:t})});if(!n.ok){let e=await n.json().catch(()=>({}));c.toast.error(e.error||"Could not save"),D("idle");return}let a=await n.json();!k&&a?.id&&_(a.id),D("saved"),setTimeout(()=>D(e=>"saved"===e?"idle":e),1500)}finally{I.current=!1,$.current&&($.current=!1,M())}},[k,e.id,i,l]),L=(0,n.useCallback)((e,t)=>{S(n=>{let a={...n,[e]:t};return R.current=a,a}),P.current&&clearTimeout(P.current),P.current=setTimeout(M,600)},[M]),E=(0,n.useCallback)(async t=>{P.current&&clearTimeout(P.current),await M();try{let n=await fetch("/api/custom-records/action",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tab_id:e.id,parent_entity_id:l,block_index:t})}),a=await n.json().catch(()=>({}));if(!n.ok)return void c.toast.error(a.error||a.message||"Action failed");c.toast.success(a.message||"Done")}catch{c.toast.error("Action failed")}},[M,e.id,l]);return j?(0,t.jsx)("div",{className:"max-w-3xl",children:(0,t.jsx)(h.TabBuilderDialog,{inline:!0,entityType:e.entity_type,tab:e,onClose:()=>v(!1),onSaved:()=>{v(!1),x.refresh()}})}):w?(0,t.jsx)("div",{className:"max-w-2xl space-y-5",children:[0,1,2].map(e=>(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)(o.Skeleton,{className:"h-3.5 w-24"}),(0,t.jsx)(o.Skeleton,{className:"h-10 w-full rounded-xl"})]},e))}):0===y.length?(0,t.jsxs)("div",{className:"max-w-2xl",children:[(0,t.jsx)(p.EditTabButton,{tab:e,onEdit:()=>v(!0)}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"This tab has no fields yet."})]}):(0,t.jsxs)("div",{className:"max-w-2xl",children:[(0,t.jsx)(p.EditTabButton,{tab:e,onEdit:()=>v(!0)}),(0,t.jsx)("div",{className:"flex flex-wrap items-end gap-y-5 -mx-2",children:y.map((e,n)=>"content"===e.kind?(0,t.jsx)("div",{className:"w-full px-2",children:(0,t.jsx)(f,{boxed:e.boxed,children:(0,t.jsx)(g,{html:e.html})})},n):"button"===e.kind?(0,t.jsx)("div",{className:"px-2 w-full sm:w-[var(--bw)]",style:{"--bw":`${(0,d.widthToPct)(e.width)}%`},children:(0,t.jsx)(f,{boxed:e.boxed,children:(0,t.jsx)(b,{label:e.label,onRun:()=>E(n)})})},n):"widget"===e.kind?(0,t.jsx)("div",{className:"px-2 w-full sm:w-[var(--bw)]",style:{"--bw":`${(0,d.widthToPct)(e.width)}%`},children:(0,t.jsxs)(f,{boxed:e.boxed,children:[e.label&&(0,t.jsx)("p",{className:"mb-1.5 text-sm font-medium text-foreground/80",children:e.label}),(0,t.jsx)(m.WidgetControl,{widgetType:e.widgetType,config:e.config,value:C[e.key],onChange:t=>L(e.key,t)})]})},e.key||n):(0,t.jsx)("div",{className:"px-2 w-full sm:w-[var(--bw)]",style:{"--bw":`${(0,d.widthToPct)(e.width)}%`},children:(0,t.jsx)(f,{boxed:e.boxed,children:(0,t.jsx)(u.CustomEntryField,{field:e,value:C[e.key],onChange:t=>L(e.key,t)})})},e.key||n))}),(0,t.jsxs)("div",{className:"h-4 mt-4 text-xs text-muted-foreground",children:["saving"===T&&(0,t.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,t.jsx)(s.Loader2,{className:"h-3 w-3 animate-spin"})," Saving…"]}),"saved"===T&&(0,t.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,t.jsx)(r.Check,{className:"h-3 w-3"})," Saved"]})]})]})}])},650754,275473,e=>{"use strict";var t=e.i(843476),n=e.i(271645),a=e.i(618566),r=e.i(920755);async function s(e,t=1e3,n=6){let a=async n=>{let a=n*t,r=await e(a,a+t-1);if(r.error)throw r.error;return r.data??[]},r=await a(0);if(r.length<t)return r;let i=[...r],o=1;for(;i.length<2e5;){let e=Array.from({length:n},(e,t)=>o+t),r=await Promise.all(e.map(a)),s=!1;for(let e of r)if(e.length>0&&i.push(...e),e.length<t){s=!0;break}if(s)break;o+=n}return i.length>2e5?i.slice(0,2e5):i}var i=e.i(115344),o=e.i(411466),l=e.i(846696);function c(e,t){return!e||t.some(t=>t.id===e.id)?t:[e,...t]}e.s(["useCreateDealDialog",0,function({seedContact:e,seedCompany:d}
1){let u=(0,a.useRouter)(),m=(0,r.createClient)(),[p,h]=(0,n.useState)(!1),[x,f]=(0,n.useState)(!1),[g,b]=(0,n.useState)([]),[y,j]=(0,n.useState)([]),[v,w]=(0,n.useState)([]),[N,k]=(0,n.useState)(!1);async function _(){if(N)return void h(!0);f(!0);try{let[t,n,[{data:a},{data:r}]]=await Promise.all([s((e,t)=>m.from("contacts").select("id, name, email, image_url").order("name").range(e,t)),s((e,t)=>m.from("companies").select("id, name, logo_url").order("name").range(e,t)),Promise.all([m.from("products").select("id, name, price, currency, image_url, billing_interval, stripe_price_id").eq("active",!0).order("name").limit(500),m.from("product_prices").select("id, product_id, stripe_price_id, unit_amount, currency, billing_interval, nickname, active").eq("active",!0).limit(2e3)])]);b(c(e??null,(t||[]).map(e=>({id:e.id,name:e.name,email:e.email,imageUrl:e.image_url})))),j(c(d??null,(n||[]).map(e=>({id:e.id,name:e.name,logoUrl:e.logo_url})))),w((0,o.buildDealProductOptions)(a||[],r||[])),k(!0),h(!0)}catch{l.toast.error("Could not load deal options")}finally{f(!1)}}let C=e?[e.id]:[],S=d?[d.id]:[];return{openDialog:_,loading:x,dialog:(0,t.jsx)(i.DealDialog,{open:p,onOpenChange:h,onSaved:e=>{u.push(`/deals/${e.id}`)},contactOptions:g,companyOptions:y,productOptions:v,initialContactIds:C,initialCompanyIds:S})}}],650754);var d=e.i(167881),u=e.i(965627),m=e.i(647163),p=e.i(395913),h=e.i(417955),x=e.i(501949);let f={fetch:["Enriching…","Reading LinkedIn…","Finding email…"],save:["Saving…","Updating record…"],queue:["Enriching…","Waking extension…"]},g="cubic-bezier(0.4, 0, 0.2, 1)";e.s(["LinkedInEnrichButton",0,function({entityType:e,entityId:a,hasLinkedInId:s,linkedInUrl:i,linkedInUrn:o,salesNavigatorUrn:c,linkedInId:b,onEnriched:y,onSettled:j,externalLoading:v,onLoadingChange:w,onBeforeEnrich:N,className:k}
1){let[_,C]=(0,n.useState)(!1),[S,T]=(0,n.useState)("fetch"),[D,P]=(0,n.useState)(0),I=_||!!v,$=(0,n.useRef)(w);function R(e){T(e),P(0)}(0,n.useEffect)(()=>{$.current=w}),(0,n.useEffect)(()=>{$.current?.(_)},[_]),(0,n.useEffect)(()=>{if(!I)return;let e=setInterval(()=>P(e=>e+1),2e3);return()=>clearInterval(e)},[I,S]);let M=f[S],L=M[D%M.length],[E,A]=(0,n.useState)(L),[F,z]=(0,n.useState)(null),O=(0,n.useRef)(null),U=(0,n.useRef)(null),q=(0,n.useRef)(null),B=(0,n.useRef)(null);async function H(){if(!s)return void l.toast.error(`Add a LinkedIn URL, LinkedIn URN, or Sales Nav URN to this ${e} first.`);C(!0),R("fetch");try{try{await N?.()}catch{}(0,p.isExtensionInstalled)()||await (0,p.waitForExtension)(1500)?await W():await V()}catch{l.toast.error("Network error – could not reach enrichment API.")}finally{C(!1)}}async function V(){let t=G();if(!t)return void l.toast.error("Could not determine LinkedIn identifier for this record.");R("queue");let n=(0,r.createClient)(),{data:{user:s}}=await n.auth.getUser();if(!s)return void l.toast.error("Not signed in.");let{error:i}=await n.from("linkedin_action_queue").insert({owner_id:s.id,contact_id:"person"===e?a:null,action_type:"enrich",priority:10,payload:{entity_type:e,entity_id:a,identifier_type:t.type,identifier_value:t.value}});i?l.toast.error("Could not queue enrichment: "+i.message):(l.toast.success("Queued on your desktop extension - will run in a moment."),y&&setTimeout(()=>y(),12e3))}async function W(){let t=G();if(!t)return void l.toast.error("Could not determine LinkedIn identifier for this record.");try{let n="person"===e?await (0,h.fetchPersonEnrichData)(t.type,t.value):await (0,h.fetchCompanyEnrichData)(t.type,t.value);if(!("person"===e?!!n.profileJson:!!n.companyJson))return void l.toast.error("Could not fetch data from LinkedIn. Make sure you are logged in.");if("person"===e&&"sales_nav_urn"===t.type&&n.profileJson){let e=(0,h.extractPublicIdentifierFromProfileJson)(n.profileJson);if(e){let t=`https://www.linkedin.com/in/${e}`;try{(await fetch(`/api/contacts/${a}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({linkedin_url:t})})).ok&&(n={...n,identifierType:"vanity_name",identifierValue:e})}catch{}}}R("save");let r=await fetch("/api/linkedin/enrich-with-data",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({entityType:e,entityId:a,...n})}),s=await r.json();if(!r.ok)return void l.toast.error(s.error||"Enrichment failed");s.message&&console.log("[enrich]",s.message);let i=s.fieldsUpdated?.length??0;i>0?(l.toast.success(`Updated ${i} ${1===i?"field":"fields"}`),y?.()):(l.toast.info("Already up to date"),j?.())}catch(e){console.error("[enrich] Browser enrichment failed:",e),l.toast.error("Enrichment failed. Check console for details.")}}function G(){let t="person"===e?x.parsePersonIdentifier:x.parseCompanyIdentifier;for(let e of[i,o,c,b])if(e){let n=t(e);if(n)return n}return null}return L!==E&&(A(L),z(E)),(0,n.useLayoutEffect)(()=>{let e=O.current;if(!e){B.current=null;return}let t=e.getBoundingClientRect().width,n=B.current;if(B.current=t,null===F)return;let a=!!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;if(!a&&null!==n){let a=document.timeline.currentTime,r=e=>(e&&null!==a&&(e.startTime=a),e);if(Math.abs(n-t)>=.5){e.style.width=`${n}px`;let a=e.animate([{width:`${n}px`},{width:`${t}px`}],{duration:300,easing:g,fill:"forwards"});r(a),a.finished.then(()=>{e.style.width="",a.cancel()}).catch(()=>{})}r(q.current?.animate([{opacity:1},{opacity:0}],{duration:165,easing:g,fill:"forwards"})),r(U.current?.animate([{opacity:0},{opacity:1}],{duration:300,easing:g,fill:"backwards"}))}let r=setTimeout(()=>z(null),a||null===n?0:300);return()=>clearTimeout(r)},[E,F,I]),(0,t.jsx)(d.Button,{variant:"default",size:"sm",onClick:H,disabled:I||!s,className:(0,m.cn)("rounded-full px-4",I&&"disabled:bg-transparent disabled:hover:bg-transparent disabled:text-muted-foreground disabled:hover:text-muted-foreground",k),title:s?`Pull data from LinkedIn for this ${e}`:"Add a LinkedIn identifier to enable enrichment",children:I?(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-[13px] font-semibold",children:[(0,t.jsx)(u.LinkedInExportSpinner,{className:"h-4 w-6 shrink-0 opacity-[0.55]",alt:""}),(0,t.jsxs)("span",{ref:O,className:"relative block overflow-hidden",children:[(0,t.jsx)("span",{"aria-hidden":!0,
1className:"invisible block whitespace-nowrap",children:E}),(0,t.jsx)("span",{ref:U,className:"export-shimmer-text absolute inset-0 whitespace-nowrap",children:E}),null!==F&&(0,t.jsx)("span",{ref:q,"aria-hidden":!0,className:"export-shimmer-text absolute inset-0 whitespace-nowrap",children:F},F)]})]}):"Enrich"})}],275473)},788015,e=>{"use strict";var t=e.i(843476),n=e.i(271645),a=e.i(178583),r=e.i(493886),s=e.i(248256),i=e.i(473708),o=e.i(531278),l=e.i(82735),c=e.i(846696),d=e.i(920755),u=e.i(647163),m=e.i(132193),p=e.i(341256),h=e.i(761691);function x({asset:e,onRename:n,onDelete:a}){var r;return(0,t.jsxs)("li",{className:"group flex items-center gap-2 rounded-md px-2 py-1.5 -mx-2 hover:bg-muted/60 transition-colors",children:[(0,t.jsx)("a",{href:e.url??"#",target:"_blank",rel:"noopener noreferrer",className:"shrink-0",title:e.url?"Open":void 0,onClick:t=>{e.url||t.preventDefault()},children:(0,t.jsx)(f,{asset:e})}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)(m.InlineEdit,{value:e.title||"",onSave:n,placeholder:e.url||"Untitled",className:"block text-sm font-medium",inputClassName:"text-sm font-medium"}),null!=e.size_bytes&&(0,t.jsx)("p",{className:"px-1 text-[11px] text-muted-foreground",children:(r=e.size_bytes)<1024?`${r} B`:r<1048576?`${(r/1024).toFixed(1)} KB`:r<0x40000000?`${(r/1048576).toFixed(1)} MB`:`${(r/0x40000000).toFixed(2)} GB`}),null==e.size_bytes&&e.url&&(0,t.jsx)("p",{className:"truncate px-1 text-[11px] text-muted-foreground",children:e.url})]}),(0,t.jsx)("button",{type:"button",onClick:a,className:"shrink-0 squircle p-1 text-muted-foreground opacity-0 transition-opacity hover:bg-muted hover:text-destructive group-hover:opacity-100","aria-label":"Delete asset",children:(0,t.jsx)(p.TrashIcon,{className:"h-3.5 w-3.5"})})]})}function f({asset:e}){return e.thumbnail_url?(0,t.jsx)("img",{src:e.thumbnail_url,alt:"",className:"h-8 w-8 rounded-md object-cover shrink-0 bg-muted"}):"image"===e.kind&&e.url?(0,t.jsx)("img",{src:e.url,alt:"",className:"h-8 w-8 rounded-md object-cover shrink-0 bg-muted"}):(0,t.jsx)("div",{className:"flex h-8 w-8 items-center justify-center rounded-md bg-muted shrink-0",children:(0,t.jsx)(g,{kind:e.kind,className:"h-4 w-4 text-muted-foreground"})})}function g({kind:e,className:n}){return"loom"===e||"youtube"===e||"vimeo"===e?(0,t.jsx)(r.Film,{className:n}):"image"===e?(0,t.jsx)(i.Image,{className:n}):"pdf"===e?(0,t.jsx)(h.PdfIcon,{className:n}):"document"===e?(0,t.jsx)(a.FileText,{className:n}):(0,t.jsx)(s.Globe,{className:n})}e.s(["EntityAssetsCard",0,function({entityType:e,entityId:a}
1){let[r,s]=(0,n.useState)([]),[i,m]=(0,n.useState)(!0),[p,h]=(0,n.useState)(!1),[f,g]=(0,n.useState)(!1),[b,y]=(0,n.useState)(!1),j=(0,n.useRef)(null);(0,n.useEffect)(()=>{let t=!1;return(async()=>{m(!0);let n=await fetch(`/api/entity-assets?entity_type=${e}&entity_id=${a}`),r=await n.json().catch(()=>({}));t||(s(r.assets??[]),m(!1))})(),()=>{t=!0}},[e,a]);let v=(0,n.useCallback)(async t=>{h(!0);try{let n=(0,d.createClient)(),{data:{user:r}}=await n.auth.getUser();if(!r)return void c.toast.error("Not signed in");let i=t.name.split(".").pop()?.toLowerCase()||"bin",o=`${Date.now()}-${Math.random().toString(36).slice(2,8)}.${i}`,l=`${r.id}/entity-assets/${o}`,{error:u}=await n.storage.from("avatars").upload(l,t,{upsert:!1,contentType:t.type||"application/octet-stream"});if(u)return void c.toast.error(`Upload failed: ${u.message}`);let{data:m}=n.storage.from("avatars").getPublicUrl(l),p=t.type.startsWith("image/")?"image":"application/pdf"===t.type||"pdf"===i?"pdf":"document",h=await fetch("/api/entity-assets",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({entity_type:e,entity_id:a,url:m.publicUrl,title:t.name,kind:p,mime_type:t.type||null,size_bytes:t.size})}),x=await h.json();if(!h.ok)return void c.toast.error(x.error||"Failed to save");s(e=>[...e,x.asset])}finally{h(!1)}},[e,a]),w=(0,n.useCallback)(async t=>{let n=t.trim();if(n){g(!0);try{let t=await fetch("/api/entity-assets",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({entity_type:e,entity_id:a,url:n,title:null})}),r=await t.json();if(!t.ok)return void c.toast.error(r.error||"Failed to add link");s(e=>[...e,r.asset])}finally{g(!1)}}},[e,a]);async function N(e){s(t=>t.filter(t=>t.id!==e)),(await fetch(`/api/entity-assets/${e}`,{method:"DELETE"})).ok||(s(r),c.toast.error("Failed to delete"))}async function k(e,t){s(n=>n.map(n=>n.id===e?{...n,title:t}:n)),(await fetch(`/api/entity-assets/${e}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:t})})).ok||(s(r),c.toast.error("Failed to rename"))}let _=p||f;return(0,t.jsxs)("div",{className:"border border-card-border rounded-[20px] p-4 bg-card space-y-3",children:[(0,t.jsx)("div",{className:"flex items-center justify-between",children:(0,t.jsxs)("h3",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:["Assets",!i&&(0,t.jsx)("span",{className:"ml-1.5 text-muted-foreground/60",children:r.length})]})}),(0,t.jsx)("input",{ref:j,type:"file",className:"hidden",onChange:e=>{let t=e.target.files?.[0];t&&v(t),e.target.value=""}}),(0,t.jsx)("div",{tabIndex:0,"aria-label":"Drop, paste, or browse to add asset",onDragOver:e=>{e.preventDefault(),y(!0)},onDragLeave:()=>y(!1),onDrop:e=>{e.preventDefault(),y(!1);let t=e.dataTransfer.files?.[0];t&&v(t)},onClick:e=>{e.currentTarget.focus()},onPaste:e=>{let t=e.clipboardData.files?.[0];if(t){e.preventDefault(),v(t);return}let n=e.clipboardData.getData("text").trim();n&&/^https?:\/\//i.test(n)&&(e.preventDefault(),w(n))},className:(0,u.cn)("flex cursor-text flex-col items-center justify-center gap-1 rounded-[16px] border border-dashed bg-card/30 px-4 py-6 text-xs text-muted-foreground transition-colors focus:outline-none focus-visible:border-foreground
1/40 focus-visible:text-foreground",b?"border-foreground/40 bg-card":"border-border",_&&"opacity-60"),children:_?(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[(0,t.jsx)(o.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),"Uploading…"]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,t.jsx)(l.Paperclip,{className:"h-3.5 w-3.5"}),"Drop, paste, or"," ",(0,t.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),j.current?.click()},className:"underline underline-offset-2 hover:text-foreground",children:"browse"})]}),(0,t.jsx)("span",{className:"text-[11px] text-muted-foreground/70",children:"click the box, then ⌘V to paste a link or file"})]})}),i?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Loading…"}):0===r.length?null:(0,t.jsx)("ul",{className:"space-y-1",children:r.map(e=>(0,t.jsx)(x,{asset:e,onRename:t=>k(e.id,t),onDelete:()=>N(e.id)},e.id))})]})}])},796861,e=>{"use strict";var t=e.i(843476);e.s(["GlobeIcon",0,function(e){return(0,t.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[(0,t.jsx)("clipPath",{id:"globe-sphere",children:(0,t.jsx)("circle",{cx:"12",cy:"12",r:"10"})}),(0,t.jsxs)("g",{clipPath:"url(#globe-sphere)",children:[(0,t.jsx)("circle",{cx:"12",cy:"12",r:"10",fill:"var(--sq-sky, none)",stroke:"none"}),(0,t.jsx)("path",{d:"M11.75 2.3C12.74 2.43 13.7 2.4 14.66 2.67C15.63 2.95 17.34 3.9 17.34 3.9C17.34 3.9 15.93 5.73 15.08 6.55C14.66 6.95 13.64 7.44 13.64 7.44C13.64 7.44 13.54 9.22 13.54 9.22C13.54 9.22 13.21 9.45 13.02 9.43C12.24 9.32 10.78 8.84 10.78 8.84C10.78 8.84 10.18 9.35 10.18 9.35C10.18 9.35 10.15 10.16 10.36 10.49C10.65 10.94 11.1 11.25 11.57 11.51C11.84 11.67 12.16 11.72 12.47 11.7C13.33 11.65 14.12 11.13 14.96 11.3C15.73 11.47 16.88 12.63 16.88 12.63C16.88 12.63 16.9 13.61 16.76 14.08C16.54 14.81 16.27 15.51 15.84 16.14C15.04 17.28 13.18 19.25 13.18 19.25C13.18 19.25 12.09 19.08 12.09 19.08C12.09 19.08 12.28 17.09 11.83 16.24C11.35 15.35 9.55 14.34 9.55 14.34C9.55 14.34 9.96 12.58 9.47 11.9C7.96 9.78 3.97 6.55 3.97 6.55C3.97 6.55 4.9 5.35 5.47 4.83C6.05 4.3 6.66 3.86 7.35 3.49C8.03 3.12 8.72 2.84 9.47 2.64C10.22 2.43 10.96 2.42 11.73 2.3C11.73 2.3 11.74 2.3 11.75 2.3Z",fill:"var(--sq-leaf, none)",paintOrder:"stroke"})]}),(0,t.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:1.2})]})}])},821725,e=>{"use strict";var t=e.i(843476);e.s(["MergeIcon",0,function(e){return(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"-16 -16 544 486",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd",shapeRendering:"geometricPrecision",textRendering:"geometricPrecision",imageRendering:"optimizeQuality",...e,children:(0,t.jsx)("path",{fillRule:"nonzero",fill:"currentColor",stroke:"currentColor",strokeWidth:16,strokeLinejoin:"round",paintOrder:"stroke fill",d:"M400.718 127.273c-7.011-5.832-17.426-4.874-23.259 2.136-5.832 7.011-4.874 17.427 2.137 23.259l69.359 57.73H259.307c-56.487 0-113.058-22.813-155.638-59.731-40.329-34.958-67.93-82.463-70.583-134.902C32.659 6.643 24.907-.408 15.785.019 6.663.445-.388 8.197.039 17.319c3.139 62.098 35.188 117.797 81.986 158.362 25.345 21.969 55.077 39.541 86.906 51.3-31.909 11.795-61.717 29.432-87.097 51.482C35.027 319.133 3.012 374.947.019 437.125c-.427 9.122 6.624 16.875 15.746 17.301 9.122.426 16.874-6.625 17.301-15.746 2.527-52.555 30.083-100.165 70.412-135.203 42.61-37.019 99.267-59.902 155.829-59.902h191.067l-70.778 58.914c-7.011 5.832-7.969 16.248-2.137 23.258 5.833 7.011 16.248 7.969 23.259 2.136l105.054-87.442a16.541 16.541 0 002.337-2.302 16.459 16.459 0 003.701-8.625l.035-.276c.1-.737.155-1.489.155-2.252 0-6.629-3.891-12.351-9.518-15.009l-101.764-84.704z"})})}])},825217,e=>{"use strict";var t=e.i(843476),n=e.i(271645),a=e.i(531278),r=e.i(664659),s=e.i(149685),i=e.i(994179),o=e.i(167881),l=e.i(59377),c=e.i(728231),d=e.i(184762),u=e.i(647163),m=e.i(395913),p=e.i(417955),h=e.i(581438),x=e.i(920755),f=e.i(311652),g=e.i(846696),b=e.i(327147);let y=(0,e.i(783618).pillClass)("default","text-foreground");function j({sending:e,showNote:n,setShowNote:s,note:i,setNote:c,onConnect:u}){return(0,t.jsxs)(l.Popover,{open:n,onOpenChange:s,children:[(0,t.jsxs)("div",{className:"flex items-center",children:[(0,t.jsxs)(o.Button,{variant:"default",size:"sm",onClick:()=>u(null),disabled:e,className:"h-9 gap-1.5 rounded-full rounded-r-none px-3.5 text-xs font-medium",children:[e?(0,t.jsx)(a.Loader2,{className:"size-3.5 animate-spin"}):(0,t.jsx)("span",{className:"squircle flex size-4 shrink-0 items-center justify-center bg-background text-foreground",children:(0,t.jsx)(v,{className:"size-2.5"})}),(0,t.jsx)(b.ShimmerLabel,{active:e,children:"Connect"})]}),(0,t.jsx)(l.PopoverTrigger,{asChild:!0,children:(0,t.jsx)(o.Button,{variant:"default",size:"sm",disabled:e,className:"h-9 rounded-full rounded-l-none border-l border-primary-foreground
1/20 px-2.5 text-xs font-medium",children:(0,t.jsx)(r.ChevronDown,{className:"h-3 w-3"})})})]}),(0,t.jsx)(l.PopoverContent,{className:"w-72",align:"end",children:(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:"Connect with a note"}),(0,t.jsx)(d.Textarea,{variant:"on-white",value:i,onChange:e=>c(e.target.value),onKeyDown:t=>{"Enter"!==t.key||t.shiftKey||(t.preventDefault(),i.trim()&&!e&&u(i))},placeholder:"Add a personal note...",maxLength:300,rows:3,autoFocus:!0}),(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("span",{className:"text-xs text-muted-foreground",children:[i.length,"/300"]}),(0,t.jsxs)(o.Button,{size:"sm",onClick:()=>u(i),disabled:e||!i.trim(),children:[e&&(0,t.jsx)(a.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),(0,t.jsx)(b.ShimmerLabel,{active:e,children:"Send"})]})]})]})})]})}function v({className:e}){return(0,t.jsxs)("svg",{viewBox:"-16 -16 544 544",xmlns:"http://www.w3.org/2000/svg",className:e,fill:"currentColor","aria-hidden":!0,children:[(0,t.jsx)("path",{d:"M61.813,4.424c33.545,0,61.793,28.248,61.793,61.793c0,35.31-30.014,62.676-61.793,61.793\n        C29.151,128.893,0.02,101.527,0.02,66.217C-0.863,31.789,27.386,4.424,61.813,4.424"}),(0,t.jsx)("path",{d:"M96.241,507.596H25.62c-9.71,0-17.655-7.945-17.655-17.655V180.976\n        c0-9.71,7.062-17.655,16.772-17.655h71.503c9.71,0,17.655,7.945,17.655,17.655v309.848\n        C113.896,499.651,105.951,507.596,96.241,507.596"}),(0,t.jsx)("path",{d:"M511.137,271.017c0-65.324-48.552-116.524-113.876-116.524h-18.538\n        c-35.31,0-69.738,16.772-88.276,44.138c-6.179,6.179-8.828,8.828-8.828,8.828v-35.31c0-3.531-5.297-8.828-8.828-8.828h-88.276\n        c-3.531,0-8.828,3.531-8.828,7.945v329.269c0,3.531,5.297,7.062,8.828,7.062h97.103c3.531,0,8.828-3.531,8.828-7.062V309.858\n        c0-32.662,24.717-60.028,57.379-60.91c16.772,0,31.779,6.179,43.255,17.655c10.593,10.593,15.007,25.6,15.007,42.372v189.793\n        c0,3.531,5.297,8.828,8.828,8.828h88.276c3.531,0,8.828-5.297,8.828-8.828V271.017H511.137z"})]})}e.s(["ConnectionButton",0,function({profileUrn:e,linkedinUrl:r,contactId:l,workspaceId:d,initialStatus:w="unknown",onStatusChange:N,onProfilePicture:k,variant:_="default",className:C,staggerMs:S=0}){let[T,D]=(0,n.useState)(w),[P,I]=(0,n.useState)(null),[$,R]=(0,n.useState)(!1),[M,L]=(0,n.useState)(!1),[E,A]=(0,n.use
1State)(""),F=(0,x.createClient)(),z=(0,n.useRef)(N);(0,n.useEffect)(()=>{z.current=N});let O=(0,n.useRef)(w);function U(t){D(t),N?.(t),"loading"!==t&&"unknown"!==t&&(0,h.publishConnectionUpdate)({profileUrn:e,status:t,connectedAt:P})}async function q(e=null){R(!0);try{(0,m.isExtensionInstalled)()?await H(e):await B(e)}catch{g.toast.error("Network error")}finally{R(!1)}}async function B(t){if(!r)return void g.toast.error("LinkedIn URL missing - cannot queue connection request.");let{data:{user:n}}=await F.auth.getUser();if(!n)return void g.toast.error("Not signed in.");let{error:a}=await F.from("linkedin_action_queue").insert({owner_id:n.id,contact_id:l??null,action_type:"connect",priority:10,payload:{linkedin_url:r,profile_urn:e,connection_note:t?.trim()||void 0}});a?g.toast.error("Could not queue connection: "+a.message):(U("pending"),L(!1),A(""),g.toast.success("Queued on your desktop - will send in a moment."),fetch("/api/linkedin/connect/persist",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({profileUrn:e,contactId:l,workspaceId:d,status:"pending",customMessage:t||null})}).catch(()=>{}))}async function H(t){let n=await (0,p.sendConnectionRequest)(e,t,r);if(!n.success)return void g.toast.error(n.error||"Connection request failed");if(n.profilePictureUrl&&k&&k(n.profilePictureUrl),n.alreadyConnected){U("connected"),g.toast.success("Already connected!"),fetch("/api/linkedin/connect/persist",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({profileUrn:e,contactId:l,workspaceId:d,status:"connected",profilePictureUrl:n.profilePictureUrl||null})}).catch(()=>{});return}U("pending"),L(!1),A(""),g.toast.success(n.alreadySent?"Connection request already sent":"Connection request sent!"),fetch("/api/linkedin/connect/persist",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({profileUrn:e,contactId:l,workspaceId:d,status:"pending",customMessage:t||null,profilePictureUrl:n.profilePictureUrl||null})}).catch(()=>{})}return((0,n.useEffect)(()=>{O.current=w}),(0,n.useEffect)(()=>{let t=O.current;"loading"!==t&&D(t);let n=!1;return async function(){if(S>0&&(await new Promise(e=>setTimeout(e,S)),n))return;let{data:a}=await F.from("linkedin_connection_requests").select("id, status, connected_at, sent_by").eq("workspace_id",d).eq("target_linkedin_urn",e).order("sent_at",{ascending:!1}).limit(1).maybeSingle();if(n)return;if(a?.status==="connected"){I(a.connected_at??null),D("connected"),z.current?.("connected");let e="compact"===_||await (0,f.isOwnConnectionRow)(F,a.sent_by);if(n||a.connected_at&&e)return}if("loading"!==t&&a?.status!=="connected")return;let r=await (0,m.waitForExtension)();if(!n){if(!r){if(a?.status==="connected")return;let e=a?.status==="pending"?"pending":"unknown";D(e),z.current?.(e);return}try{let{status:t,connectedAt:r}=await (0,p.checkConnectionStatus)(e);if(n)return;if("connected"===t&&(a?.status==="pending"?fetch("/api/linkedin/connect/persist",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({profileUrn:e,contactId:l,workspaceId:d,status:"connected",connectedAt:r})}).catch(()=>{}):a?"connected"===a.status&&!a.connected_at&&r&&F.from("linkedin_connection_requests").update({connected_at:r}).eq("id",a.id).then(()=>{}):fetch("/api/linkedin/connect/persist",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({profileUrn:e,contactId:l,workspaceId:d,status:"connected",connectedAt:r})}).catch(()=>{}),r&&I(r)),"unknown"===t){a?.status!=="connected"&&(D("unknown"),z.current?.("unknown"));return}D(t),z.current?.(t),(0,h.publishConnectionUpdate)({profileUrn:e,status:t,connectedAt:r??null})}catch{n||a?.status==="connected"||(D("unknown"),z.current?.("unknown"))}}}(),()=>{n=!0}},[e,d]),(0,n.useEffect)(()=>(0,h.subscribeToConnection)(e,e=>{D(e.status),e.connectedAt&&I(e.connectedAt),z.current?.(e.status)}),[e]),(0,n.useEffect)(()=>{if("pending"===T)return(0,h.startConnectionPoll)(e,{workspaceId:d,contactId:l})},[T,e,d,l]),"header"===_)?"not_connected"!==T&&"unknown"!==T?null:(0,t.jsxs)(c.Tooltip,{children:[(0,t.jsx)(c.TooltipTrigger,{asChild:!0,children:(0,t.jsxs)(o.Button,{variant:"default",size:"sm",className:(0,u.cn)("h-9 gap-1.5 rounded-full px-3.5 text-xs font-medium",C),"aria-label":"Connect on LinkedIn",onClick:()=>{$||q(null)},disabled:$,children:[$?(0,t.jsx)(a.Loader2,{className:"size-3.5 animate-spin"}):(0,t.jsx)("span",{className:"squircle flex size-4 shrink-0 items-center justify-center bg-background text-foreground",children:(0,t.jsx)(v,{className:"size-2.5"})}),(0,t.jsx)(b.ShimmerLabel,{active:$,children:"Connect"})]})}),(0,t.jsx)(c.TooltipContent,{side:"bottom",children:"Connect on LinkedIn"})]}):"compact"===_?"not_connected"!==T&&"unknown"!==T?null:(0,t.jsxs)(o.Button,{variant:"outline",size:"xs",onClick:e=>{e.preventDefault(),e.stopPropagation(),$||q(null)},disabled:$,children:[$&&(0,t.jsx)(a.Loader2,{className:"h-3 w-3 animate-spin"}),(0,t.jsx)(b.ShimmerLabel,{active:$,children:"Connect"})]}):"loading"===T?(0,t.jsxs)(i.Badge,{variant:"outline",className:(0,u.cn)(y),children:[(0,t.jsx)(a.Loader2,{className:"h-3 w-3 animate-spin text-muted-foreground"}),"Checking..."]}):"connected"===T?(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-sm text-foreground",children:[(0,t.jsx)(s.Handshake,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),function(e){if(!e)return"Connected";let t=new Date(e);return Number.isNaN(t.getTime())?"Connected":`Connected since ${t.toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"})}`}(P)]}):"pending"===T?(0,t.jsxs)(i.Badge,{variant:"outline",className:(0,u.cn)(y),children:[(0,t.jsx)("span",{className:"size-2 roun
1ded-full shrink-0 bg-warning"}),"Pending"]}):(0,t.jsx)("div",{className:"flex items-center",children:(0,t.jsx)(j,{sending:$,showNote:M,setShowNote:L,note:E,setNote:A,onConnect:q})})}])},433597,e=>{"use strict";var t=e.i(843476),n=e.i(271645),a=e.i(531278),r=e.i(643531),s=e.i(664659),i=e.i(656766),o=e.i(567136),l=e.i(463415),c=e.i(647163),d=e.i(275236),u=e.i(12007),m=e.i(783618),p=e.i(545787),h=e.i(791450),x=e.i(521082),f=e.i(353830),g=e.i(450263);let b=[{id:"00000000-0000-4000-8000-000000000024",label:"Full brief (recommended)",tagline:"Tech stack + priorities + ICP fit + velocity, posted to Research."},{id:"00000000-0000-4000-8000-000000000020",label:"Tech stack from job postings",tagline:"Tools they list as required - categorized + weighted."},{id:"00000000-0000-4000-8000-000000000021",label:"Hiring priorities",tagline:"What they're building, from where they're hiring."},{id:"00000000-0000-4000-8000-000000000022",label:"ICP persona deep dive",tagline:"Requirements, tools, and pains for your target buyer."},{id:"00000000-0000-4000-8000-000000000023",label:"Hiring velocity & growth signals",tagline:"Spikes, slowdowns, and geo expansions in their hiring."}],y=[{id:"00000000-0000-4000-8000-000000000030",label:"Full brief (recommended)",tagline:"Role, our history, their voice, fit, and openers."},{id:"00000000-0000-4000-8000-000000000031",label:"Relationship history",tagline:"Every touch, every open loop, and whose court it's in."},{id:"00000000-0000-4000-8000-000000000032",label:"Their public voice",tagline:"LinkedIn + X + Reddit: themes, opinions, vocabulary."},{id:"00000000-0000-4000-8000-000000000033",label:"Buying signals & intent",tagline:"Site visits, engagement, replies - scored hot to cold."},{id:"00000000-0000-4000-8000-000000000034",label:"Persona fit & org context",tagline:"ICP match, what they own, who else you need."},{id:"00000000-0000-4000-8000-000000000035",label:"Icebreakers",tagline:"Five sendable openers, each on a cited fact."}];e.s(["ResearchCard",0,function({entity:e,entityId:j,entityName:v,initialValue:w,initialUpdatedAt:N,variant:k="profile",label:_="Research",className:C,hideWhenEmpty:S,clamp:T,onSaved:D}){let[P,I]=(0,n.useState)(w??""),[$,R]=(0,n.useState)(N??null),[M,L]=(0,n.useState)(!1),[E,A]=(0,n.use
1State)(!1),{agent:F,name:z}=(0,o.useAgentBrand)(),[O,U]=(0,n.useState)(null),q=(0,n.useRef)(w??""),B=(0,n.useRef)(null),[H,V]=(0,n.useState)(null),W=(0,n.useRef)(M);W.current=M;let G=(0,n.useRef)(D);async function J(t){if(t!==q.current){A(!0);try{let n=await fetch(`/api/research/${e}/${j}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({research:t||null})});if(!n.ok)throw Error();q.current=t;let a=await n.json().catch(()=>({}));R(a.research_updated_at??new Date().toISOString()),U(Date.now()),D?.(t||null),setTimeout(()=>U(null),1500)}catch{}finally{A(!1)}}}G.current=D,(0,n.useEffect)(()=>{if(!M)return;let e=B.current;e&&(e.focus(),e.setSelectionRange(e.value.length,e.value.length))},[M]),(0,n.useEffect)(()=>{I(w??""),R(N??null),q.current=w??""},[w,N,j]),(0,n.useEffect)(()=>{if(!H)return;let t=q.current,n=Date.now(),a=!1,r=setInterval(async()=>{if(!a){if(Date.now()-n>3e5){a=!0,V(null);return}try{let n=await fetch(`/api/research/${e}/${j}`);if(!n.ok)return;let r=await n.json(),s=r.research??"";if(s===t)return;a=!0,q.current=s,R(r.research_updated_at??new Date().toISOString()),W.current||I(s),G.current?.(s||null),V(null)}catch{}}},8e3);return()=>{a=!0,clearInterval(r)}},[H,e,j]);let K="company"===e?b:y,X=function(e){let{entity:t,entityId:n,entityName:a}=e,r=a?`, "${a}"`:"";return"company"===t?`Use the everything MCP to research the company (id: ${n}${r}). Pull recent news, hiring signals, product updates, mutual connections, and anything else useful for a sales conversation. When you have a tight summary, paste it back into the company's Research field via update_company_research.`:`Use the everything MCP to research the person (contact id: ${n}${r}). Start with manage_record for the record itself, find_conversations_for_person for our history with them across every channel, and get_contact_website_activity for intent. Then look at what they've said publicly - LinkedIn and X, via the extension-backed tools, never by fetching linkedin.com. When you have a tight summary of who they are, where we stand, and what to open on, paste it back into their Research field via update_contact_research (mode=append).`}({entity:e,entityId:j,entityName:v}),Z=!P.trim(),Q=(0,n.useMemo)(()=>(function(e){let t=[],n=e.replace(/\r\n/g,"\n").split("\n"),a=[],r=null,s=null,i=()=>{a.length&&t.push(a.join("\n")),a=[]},o=()=>{s?.length&&t.push(s.join("\n")),s=null};for(let e of n){if(r){r.push(e),/^\s*```/.test(e)&&(t.push(r.join("\n")),r=null);continue}if(/^\s*```/.test(e)){i(),o(),r=[e];continue}if(/^\s*\|/.test(e)){i(),(s??=[]).push(e);continue}if(o(),!e.trim()){i();continue}if(/^\s*(#{1,6}\s|[-*+]\s|>\s|\d+[.)]\s)/.test(e)){i(),t.push(e);continue}a.push(e)}return r&&t.push(r.join("\n")),o(),i(),t.filter(e=>e.trim())})(P),[P]),Y=(0,f.useCardClamp)(!!T&&!M);if(S&&Z&&!M)return null;let ee="compact"===k;return(0,t.jsxs)("div",{className:(0,c.cn)(ee?"rounded-[14px] bg-muted/30 p-3 space-y-2":"rounded-[20px] border border-card-border bg-light-oat dark:bg-card p-4 space-y-2",T&&"flex h-full min-h-0 flex-col",C),"data-fit-max":Y.maxHeight??void 0,children:[(0,t.jsxs)("div",{className:"flex shrink-0 items-center justify-between gap-2",children:[(0,t.jsx)("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground",children:_}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[E?(0,t.jsx)(a.Loader2,{className:"h-3 w-3 animate-spin text-muted-foreground"}):O?(0,t.jsx)(r.Check,{className:"h-3 w-3 text-success"}):null,(0,t.jsxs)(l.DropdownMenu,{children:[(0,t.jsx)(l.DropdownMenuTrigger,{asChild:!0,children:(0,t.jsxs)("button",{type:"button",className:(0,m.pillClass)(),title:`Run a ${z} analysis against this ${"company"===e?"company":"person"}`,children:[(0,t.jsx)(i.AgentGlyph,{agent:F,className:"h-3 w-3"}),"Run analysis",(0,t.jsx)(s.ChevronDown,{className:"h-3 w-3 opacity-60"})]})}),(0,t.jsxs)(l.DropdownMenuContent,{align:"end",className:"w-72",children:[(0,t.jsxs)(l.DropdownMenuItem,{onSelect:()=>(0,d.openWithClaude)(X),className:"flex flex-col items-start gap-0.5",children:[(0,t.jsx)("span",{className:"text-[12px] font-medium",children:"Qu
1ick research"}),(0,t.jsx)("span",{className:"text-[11px] text-muted-foreground",children:"company"===e?"Generic news + hiring + signals sweep.":"Fast sweep of who they are and what we know."})]}),(0,t.jsx)(l.DropdownMenuSeparator,{}),(0,t.jsx)(l.DropdownMenuLabel,{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:"company"===e?"Jobs-powered":"Deep dives"}),K.map(n=>(0,t.jsxs)(l.DropdownMenuItem,{onSelect:()=>{var t;let a,r,s,i;return a="company"===(t={entity:e,skillId:n.id,skillLabel:n.label.replace(/\s*\(recommended\)\s*$/,""),entityId:j,entityName:v}).entity?"company":"contact",r=t.entityName?`@[${a}:${t.entityId}|${t.entityName}]`:`[${a}:${t.entityId}]`,s="company"===t.entity?["Look up the skill via the everything MCP `get_skill` tool to read its full instructions, then execute those instructions against this company. The skill uses `list_linkedin_company_jobs` to pull the company's open roles and `get_sales_playbook` for ICP context.","","If the company turns out to have no LinkedIn postings, do not stop - the skill carries a web-research fallback (their own careers page and ATS board, aggregators like Levels.fyi, archived historical postings, then docs/changelog/GitHub). Follow it and still produce the brief. Never fetch linkedin.com directly.","","When the analysis is complete, post the brief to the company's Research card via `update_company_research` (mode=append)."]:["Look up the skill via the everything MCP `get_skill` tool to read its full instructions, then execute those instructions against this person. The skill pulls from the CRM record, every conversation channel, meetings and calls, website activity, LinkedIn/X/Reddit, and `get_sales_playbook` for ICP context.","","Where a source is missing (no handle on the record, tracking not installed, no prior contact), say so rather than filling the gap with guesses. Never fetch linkedin.com directly - LinkedIn goes through the extension-backed search_linkedin_* tools.","","When the analysis is complete, post it to the person's Research card via `update_contact_research` (mode=append)."],i=[`Run the everything skill "${t.skillLabel}" (skill id: ${t.skillId}) on ${a} ${r}.`,"",...s].join("\n"),void(0,d.openWithClaude)(i,{autosubmit:!0})},className:"flex flex-col items-start gap-0.5",children:[(0,t.jsx)("span",{className:"text-[12px] font-medium",children:n.label}),(0,t.jsx)("span",{className:"text-[11px] text-muted-foreground",children:n.tagline})]},n.id))]})]}),(0,t.jsx)(f.CardClampToggle,{clamp:Y,label:_.toLowerCase()})]})]}),M?(0,t.jsx)("textarea",{ref:B,value:P,onChange:e=>I(e.target.value),onBlur:()=>{L(!1),J(P)},placeholder:"What do we know about them? Recent news, pain points, mutual connections…",className:(0,c.cn)("w-full resize-y bg-transparent outline-none whitespace-pre-wrap leading-relaxed",ee?"text-[12px] min-h-[60px]":"text-[13px] min-h-[100px]",T&&"min-h-0 flex-1")}):Z?(0,t.jsx)("button",{type:"button",onClick:()=>L(!0),className:(0,c.cn)("block w-full text-left text-muted-foreground hover:text-foreground transition-colors",ee?"text-[12px]":"text-[13px]"),children:"Add research…"}):(0,t.jsx)(f.CardClampBody,{clamp:Y,onClick:e=>{e.target.closest("a")||window.getSelection()?.toString()||(V(null),L(!0))},title:"Click to edit",className:(0,c.cn)("cursor-text space-y-2 leading-relaxed break-words",ee?"text-[12px]":"text-[13px]"),children:Q.map((n,a)=>H===n?(0,t.jsxs)("div",{className:"flex items-start gap-2",children:[(0,t.jsx)(g.AgentThinkingMark,{agent:F,className:"mt-[3px] size-3.5"}),(0,t.jsx)(h.LineSkeleton,{text:n,perLine:ee?52:76}
1)]},a):(0,t.jsxs)("div",{className:"inline-edit-read group/edit -mx-2 flex items-start gap-1 rounded-[8px] px-2 py-0.5",children:[(0,t.jsx)(u.MarkdownLite,{text:n,className:"min-w-0 flex-1 space-y-2"}),(0,t.jsx)(p.LineFeedbackButton,{quote:n,onSend:t=>{var a;let r,s,i;V(n),r="company"===(a={entity:e,entityId:j,entityName:v,block:n,note:t}).entity?"company":"contact",s=a.entityName?`@[${r}:${a.entityId}|${a.entityName}]`:`[${r}:${a.entityId}]`,i="company"===a.entity?"update_company_research":"update_contact_research",(0,d.openWithClaude)([`Part of the Research card on ${r} ${s} is wrong. Fix it.`,"\nThe part I flagged:\n","> "+a.block.split("\n").join("\n> "),"",`What I said about it: ${a.note}`,"\nMy note outranks whatever is on the card: it came from me, not from a source you read. Check what it changes against what we actually have on the record and in our threads with them, then rewrite that part so it says what I told you.",`Post the whole corrected research back with ${i} (mode="replace"), leaving every other part of it exactly as it is, word for word. Do not reply with the correction in prose - the updated Research card is the answer.`].join("\n"))},label:`Tell ${z} about this`,hint:`${z} checks it, then rewrites this part of the research.`,className:"mt-[3px]"})]},a))}),!M&&!Z&&(0,t.jsx)(x.CardUpdatedAt,{at:$,className:"shrink-0"})]})}],433597)},628712,e=>{"use strict";var t=e.i(843476),n=e.i(522016),a=e.i(494913),r=e.i(161765),s=e.i(287751),i=e.i(204125),o=e.i(167881),l=e.i(611423),c=e.i(402370),d=e.i(647163);e.s(["EntityTasksCard",0,function({entityType:e,entityId:u,tasksHref:m,onTaskCompleted:p,className:h}){let{data:x=[],isLoading:f}=(0,s.useCachedFetch)(`/api/tasks?entity_type=${e}&entity_id=${u}`,{staleTime:3e4}),g=(0,i.useTaskExecutionOptional)()?.execute,b=x.filter(e=>"complete"!==e.status&&"skipped"!==e.status),y=b.slice(0,5),j=b.length-y.length;return(0,t.jsxs)("div",{className:(0,d.cn)("border border-card-border rounded-[20px] p-5 bg-card flex flex-col",h),...!f&&0===b.length?{"data-overview-empty":""}:{},children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,t.jsxs)("h3",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:["Tasks",!f&&b.length>0&&(0,t.jsx)("span",{className:"ml-1.5 text-muted-foreground/60 font-normal tabular-nums",children:b.length})]}),m&&b.length>0&&(0,t.jsx)(n.default,{href:m,className:"text-[11px] text-muted-foreground hover:text-foreground transition-colors",children:"View all"})]}),f?(0,t.jsx)("div",{className:"space-y-2",children:Array.from({length:3}).map((e,n)=>(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)(l.Skeleton,{className:"h-6 w-6 rounded-md shrink-0"}),(0,t.jsxs)("div",{className:"flex-1 space-y-1.5 min-w-0",children:[(0,t.jsx)(l.Skeleton,{className:"h-3 w-36 rounded-full"}),(0,t.jsx)(l.Skeleton,{className:"h-2.5 w-20 rounded-full"})]})]},n))}):0===b.length?(0,t.jsxs)("p",{className:"text-sm text-muted-foreground",children:["No open tasks for this ","company"===e?"company":"person","."]}):(0,t.jsxs)("div",{className:"-mx-2 space-y-0.5",children:[y.map(e=>{let n=c.TASK_TYPE_CONFIG[e.task_type],s=n?.Icon;return(0,t.jsxs)("div",{className:"group flex items-center gap-3 px-2 py-1.5 rounded-lg hover:bg-muted/50 transition-colors",children:[s&&(0,t.jsx)(s,{className:"h-6 w-6 shrink-0"}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("p",{className:"text-[13px] font-medium leading-tight truncate",children:e.title||n?.label||e.task_type}),e.due_at&&(0,t.jsxs)("p",{className:"text-[11px] text-muted-foreground",children:["Due ",(0,a.formatDistanceToNow)(new Date(e.due_at),{addSuffix:!0})]})]}),(0,t.jsx)(o.Button,{variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",title:"Execute",onClick:()=>{g?.(e),p?.()},children:(0,t.jsx)(r.Hammer,{className:"h-3.5 w-3.5"})})]},e.id)}),j>0&&(0,t.jsxs)("p",{className:"px-2 pt-1 text-[11px] text-muted-foreground",children:["+",j," more"]})]})]})}])},676899,e=>{"use strict";var t=e.i(843476),n=e.i(271645),a=e.i(846696),r=e.i(920755),s=e.i(630374),i=e.i(167881),o=e.i(23750),l=e.i(10708),c=e.i(184762),d=e.i(447170),u=e.i(651035),m=e.i(59377),p=e.i(753751),h=e.i(210578),x=e.i(213788),f=e.i(710559);function g({kind:e,picked:a,onPick:s}
1){let[o,l]=(0,n.useState)(!1),[c,d]=(0,n.useState)([]),u=(0,r.createClient)(),f=async t=>{if("contact"===e){let e=u.from("contacts").select("id, name, image_url").order("name").limit(15);t&&(e=e.ilike("name",`%${t}%`));let{data:n}=await e;d((n||[]).map(e=>({id:e.id,name:e.name,imageUrl:e.image_url})))}else{let e=u.from("companies").select("id, name, domain, logo_url").order("name").limit(15);t&&(e=e.ilike("name",`%${t}%`));let{data:n}=await e;d((n||[]).map(e=>({id:e.id,name:e.name,domain:e.domain,logoUrl:e.logo_url})))}};return(0,n.useEffect)(()=>{o&&0===c.length&&f()},[o]),(0,t.jsxs)(m.Popover,{open:o,onOpenChange:l,children:[(0,t.jsx)(m.PopoverTrigger,{asChild:!0,children:(0,t.jsx)(i.Button,{variant:"outline",size:"sm",className:"w-full justify-start font-normal h-9",children:a?(0,t.jsxs)("span",{className:"inline-flex items-center gap-2 truncate",children:["contact"===e?(0,t.jsx)(h.ContactAvatar,{imageUrl:a.imageUrl,name:a.name,size:"xs"}):(0,t.jsx)(x.CompanyLogo,{domain:a.domain,logoUrl:a.logoUrl,companyName:a.name,size:"xs"}),(0,t.jsx)("span",{className:"truncate",children:a.name})]}):(0,t.jsxs)("span",{className:"text-muted-foreground",children:["Search ",e,"…"]})})}),(0,t.jsx)(m.PopoverContent,{className:"w-64 p-0",align:"start",children:(0,t.jsxs)(p.Command,{shouldFilter:!1,children:[(0,t.jsx)(p.CommandInput,{placeholder:`Search ${e}s…`,onValueChange:e=>e.length>=2?f(e):f()}),(0,t.jsxs)(p.CommandList,{children:[(0,t.jsxs)(p.CommandEmpty,{children:["No ",e,"s found"]}),a&&(0,t.jsx)(p.CommandGroup,{children:(0,t.jsx)(p.CommandItem,{value:"__clear",onSelect:()=>{s(null),l(!1)},className:"text-muted-foreground",children:"Clear"})}),(0,t.jsx)(p.CommandGroup,{children:c.map(n=>(0,t.jsxs)(p.CommandItem,{value:n.id,onSelect:()=>{s(n),l(!1)},className:"gap-2",children:["contact"===e?(0,t.jsx)(h.ContactAvatar,{imageUrl:n.imageUrl,name:n.name,size:"xs"}):(0,t.jsx)(x.CompanyLogo,{domain:n.domain,logoUrl:n.logoUrl,companyName:n.name,size:"xs"}),(0,t.jsx)("span",{className:"truncate",children:n.name})]},n.id))})]})]})})]})}e.s(["TicketDialog",0,function({members:e,categories:r,onClose:m,onCreated:p,initialRequester:h=null,initialCompany:x=null}
1){let[b,y]=(0,n.useState)(""),[j,v]=(0,n.useState)(""),[w,N]=(0,n.useState)("medium"),[k,_]=(0,n.useState)(""),[C,S]=(0,n.useState)(""),[T,D]=(0,n.useState)(h),[P,I]=(0,n.useState)(x),[$,R]=(0,n.useState)(!1);async function M(){if(b.trim()){R(!0);try{let e=await fetch("/api/tickets",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({subject:b.trim(),description:j.trim()||null,priority:w,category_id:k||null,assignee_user_id:C||null,requester_contact_id:T?.id??null,company_id:P?.id??null})}),t=await e.json();if(!e.ok)throw Error(t.error||"Failed");p(t.ticket)}catch(e){a.toast.error(e instanceof Error?e.message:"Failed to create ticket")}finally{R(!1)}}}return(0,t.jsx)(s.Dialog,{open:!0,onOpenChange:e=>{e||m()},children:(0,t.jsxs)(s.DialogContent,{className:"sm:max-w-2xl",children:[(0,t.jsx)(s.DialogHeader,{children:(0,t.jsx)(s.DialogTitle,{children:"New ticket"})}),(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)(l.Label,{htmlFor:"t-subject",children:"Subject"}),(0,t.jsx)(o.Input,{variant:"default",id:"t-subject",autoFocus:!0,value:b,onChange:e=>y(e.target.value),placeholder:"Brief summary of the issue"})]}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)(l.Label,{htmlFor:"t-desc",children:"Description"}),(0,t.jsx)(c.Textarea,{variant:"default",id:"t-desc",rows:3,value:j,onChange:e=>v(e.target.value),placeholder:"Details…"})]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)(l.Label,{children:"Priority"}),(0,t.jsx)(d.SearchableSelect,{value:w,onValueChange:N,modal:!0,options:f.TICKET_PRIORITIES.map(e=>({value:e.value,label:e.label}))})]}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)(l.Label,{children:"Category"}),(0,t.jsx)(d.SearchableSelect,{value:k,onValueChange:_,modal:!0,placeholder:"None",options:r.map(e=>({value:e.id,label:`${e.name}${null!=e.sla_hours?` \xb7 ${e.sla_hours}h`:""}`}))})]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)(l.Label,{children:"Requester"}),(0,t.jsx)(g,{kind:"contact",picked:T,onPick:D})]}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)(l.Label,{children:"Company"}),(0,t.jsx)(g,{kind:"company",picked:P,onPick:I})]})]}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)(l.Label,{children:"Assignee"}),(0,t.jsx)(d.SearchableSelect,{value:C,onValueChange:S,modal:!0,placeholder:"Unassigned",options:e.filter(e=>e.profile).map(e=>(0,u.memberOption)(e))})]})]}),(0,t.jsxs)(s.DialogFooter,{children:[(0,t.jsx)(i.Button,{variant:"ghost",onClick:m,children:"Cancel"}),(0,t.jsx)(i.Button,{onClick:M,disabled:!b.trim()||$,children:$?"Creating…":"Create ticket"})]})]})})}])},500013,e=>{"use strict";var t=e.i(843476),n=e.i(522016),a=e.i(494913),r=e.i(686311),s=e.i(263488),i=e.i(674558),o=e.i(210578),l=e.i(213788),c=e.i(710559),d=e.i(271645),u=e.i(618566),m=e.i(941388),p=e.i(167881),h=e.i(634372),x=e.i(676899);function f({seedRequester:e=null,seedCompany:n=null,variant:a="header",label:r="New ticket"}){let s=(0,u.useRouter)(),{categories:i}=(0,h.useTicketCategories)(),[o,l]=(0,d.useState)(null),[c,g]=(0,d.useState)(!1),[b,y]=(0,d.useState)(!1),j=(0,d.useCallback)(async()=>{if(null===o){y(!0);try{let e=await fetch("/api/workspace/members"),t=await e.json().catch(()=>({members:[]}));l(t.members??[])}catch{l([])}finally{y(!1)}}g(!0)},[o]);return(0,t.jsxs)(t.Fragment,{children:["header"===a?(0,t.jsx)("button",{type:"button",onClick:j,disabled:b,"aria-label":"New ticket",className:"text-muted-foreground/60 hover:text-foreground transition-colors disabled:opacity-50",children:(0,t.jsx)(m.Plus,{className:"h-4 w-4"})}):(0,t.jsx)("div",{className:"flex justify-end",children:(0,t.jsx)(p.Button,{size:"icon-sm",className:"rounded-full",onClick:j,disabled:b,"aria-label":r,children:(0,t.jsx)(m.Plus,{className:"h-4 w-4"})})}),c&&null!==o&&(0,t.jsx)(x.TicketDialog,{members:o,categories:i,initialRequester:e,initialCompany:n,onClose:()=>g(!1),onCreated:e=>{g(!1),s.push(`/tickets/${e.id}`)}})]})}let g={chat:r.MessageSquare,email:s.Mail,manual:i.PenLine};function b({ticket:e,prefer:r}){let s=g[e.source]??i.PenLine,d="company"===r&&e.company&&(e.company.logo_url||e.company.domain),u="company"===r?e.company?.name??e.requester?.name??e.requester?.email:e.requester?.name??e.requester?.email??e.company?.name,m=(0,a.formatDistanceToNow)(new Date(e.last_activity_at||e.created_at),{addSuffix:!0});return(0,t.jsxs)(n.default,{href:`/tickets/${e.id}`,className:"group flex items-center gap-2.5 p-2 -mx-2 rounded-lg hover:bg-muted transition-colors",children:[d?(0,t.jsx)(l.CompanyLogo,{domain:e.company.domain,logoUrl:e.company.logo_url,companyName:e.company.name??"",size:"xs",className:"h-7 w-7 shrink-0"}):e.requester?(0,t.jsx)(o.ContactAvatar,{imageUrl:e.requester.image_url,name:e.requester.name??e.requester.email??"?",size:"sm",className:"h-7 w-7 shrink-0"}):(0,t.jsx)("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center squircle bg-muted avatar-border",children:(0,t.jsx)(s,{className:"h-3.5 w-3.5 text-muted-foreground"})}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("p",{className:"text-sm font-medium truncate",children:e.subject}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground truncate",children:[u,m].filter(
1Boolean).join(" · ")})]}),(0,t.jsx)(c.TicketStageBadge,{stage:e.stage,className:"shrink-0"})]})}e.s(["TicketsCard",0,function({tickets:e,prefer:n="requester",seedRequester:a=null,seedCompany:r=null}){return(0,t.jsxs)("div",{className:"border border-card-border rounded-[20px] p-4 bg-card",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,t.jsxs)("h3",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:["Tickets",(0,t.jsx)("span",{className:"ml-1.5 text-muted-foreground/60",children:e.length})]}),e.length>0&&(0,t.jsx)(f,{variant:"header",seedRequester:a,seedCompany:r})]}),0===e.length?(0,t.jsx)(f,{variant:"empty",seedRequester:a,seedCompany:r}):(0,t.jsx)("div",{className:"space-y-1",children:e.map(e=>(0,t.jsx)(b,{ticket:e,prefer:n},e.id))})]})}],500013)},502072,800453,e=>{"use strict";var t=e.i(843476),n=e.i(271645),a=e.i(664659);function r(e,t){if(window.matchMedia?.("(prefers-reduced-motion: reduce)").matches)return null;let n=function(e){let t=getComputedStyle(e).transform;if(!t||"none"===t)return 0;try{let e=new DOMMatrixReadOnly(t);return 180*Math.atan2(e.b,e.a)/Math.PI}catch{return 0}}(e),a=t===n?1:Math.sign(t-n);return e.getAnimations().forEach(e=>e.cancel()),e.animate([{transform:`rotate(${n}deg)`},{transform:`rotate(${t+12*a}deg)`,offset:.45},{transform:`rotate(${t-6*a}deg)`,offset:.7},{transform:`rotate(${t+2*a}deg)`,offset:.88},{transform:`rotate(${t}deg)`}],{duration:420,fill:"forwards",easing:"ease-out"})}e.s(["arrowDown",0,function(e,t){let n=e.querySelector("svg");n&&(n.getAnimations().forEach(e=>e.cancel()),n.animate([{transform:"translateX(0)"},{transform:`translateX(${"left"===t?-3.5:3.5}px)`}],{duration:500,fill:"forwards",easing:"cubic-bezier(.2,.8,.3,1)"}))},"arrowUp",0,function(e,t){let n=e.querySelector("svg");n&&(n.getAnimations().forEach(e=>e.cancel()),n.animate([{transform:`translateX(${"left"===t?-3.5:3.5}px)`},{transform:`translateX(${"left"===t?1.5:-1.5}px)`,offset:.4},{transform:"translateX(0)"}],{duration:350,fill:"forwards",easing:"ease-out"}))},"chevronSwing",0,r,"refreshDown",0,function(e){let t=e.querySelector("svg");t&&(t.getAnimations().forEach(e=>e.cancel()),t.animate([{transform:"rotate(0deg)"},{transform:"rotate(80deg)",offset:.2},{transform:"rotate(138deg)",offset:.4},{transform:"rotate(112deg)",offset:.65},{transform:"rotate(125deg)",offset:.85},{transform:"rotate(120deg)"}],{duration:550,fill:"forwards",easing:"ease-out"}))},"refreshUp",0,function(e){let t=e.querySelector("svg");t&&(t.getAnimations().forEach(e=>e.cancel()),t.animate([{transform:"rotate(120deg)"},{transform:"rotate(-12deg)",offset:.45},{transform:"rotate(6deg)",offset:.7},{transform:"rotate(-2deg)",offset:.88},{transform:"rotate(0deg)"}],{duration:600,fill:"forwards",easing:"ease-out"}))}],800453),e.s(["AnimatedChevron",0,function({open:e,degOpen:s=0,degClosed:i=-90,className:o,strokeWidth:l,icon:c=a.ChevronDown}){let d=(0,n.useRef)(null),u=e?s:i,m=(0,n.useRef)(u),p=(0,n.useRef)(u),h=(0,n.useRef)(!1);function x(e,t){p.current=t;let n=r(e,t);n?.finished.then(()=>{m.current===t&&n.cancel()}).catch(()=>{})}return(0,n.useEffect)(()=>{m.current=u},[u]),(0,n.useEffect)(()=>{let t=d.current,n=t?.closest('button,[role="button"],a,summary,label');if(!t||!n)return;let a=()=>{h.current=!0,x(t,e?i:s)},r=()=>{h.current=!1,setTimeout(()=>{p.current!==m.current&&x(t,m.current)},0)},o=()=>{h.current&&(h.current=!1,x(t,m.current))};return n.addEventListener("pointerdown",a),n.addEventListener("pointerup",r),n.addEventListener("pointerleave",o),n.addEventListener("pointercancel",o),()=>{n.removeEventListener("pointerdown",a),n.removeEventListener("pointerup",r),n.removeEventListener("pointerleave",o),n.removeEventListener("pointercancel",o)}},[e,s,i]),(0,n.useEffect)(()=>{p.current!==u&&d.current&&x(d.current,u)},[u]),(0,t.jsx)("span",{ref:d,className:"inline-flex shrink-0 items-center justify-center",style:{transform:`rotate(${u}deg)`},children:(0,t.jsx)(c,{className:o,strokeWidth:l})})}],502072)},711287,e=>{"use strict";var t=e.i(843476),n=e.i(271645),a=e.i(476819),r=e.i(174080),s=e.i(647163),i=e.i(668270);e.s(["InlineSearchEdit",0,function({value:e,onSave:o,fetcher:l,onPick:c,defaultQuery:d,canSaveText:u,skipSearch:m,placeholder:p,className:h,inputClassName:x}
1){let[f,g]=(0,n.useState)(!1),[b,y]=(0,n.useState)(e),j=(0,n.useRef)(null),v=(0,n.useRef)(null),w=(0,n.useRef)(!1),N=(0,n.useRef)(!1),k=(0,n.useRef)(e),_=(0,n.useRef)(null),C=(0,n.useRef)(!1),S=(0,n.useRef)(!1);(0,n.useEffect)(()=>{f||y(e)},[e,f]);let T=b.trim(),D=f&&!m?.(T)?b:"",P=(0,i.useSearchPreview)(D,l);(0,n.useEffect)(()=>{f&&(j.current?.focus(),j.current?.select())},[f]),(0,n.useEffect)(()=>{if(f)return document.addEventListener("pointerdown",e,!0),document.addEventListener("keydown",t,!0),()=>{document.removeEventListener("pointerdown",e,!0),document.removeEventListener("keydown",t,!0)};function e(e){let t=e.target;!t||j.current?.contains(t)||v.current?.contains(t)||(S.current=!0)}function t(e){"Tab"===e.key&&(S.current=!0)}},[f]);let[I,$]=(0,n.useState)(null);function R(t){let n=b.trim(),a=C.current&&n===k.current.trim();_.current=t&&n&&n!==e.trim()&&!a?b:null,P.clear(),y(e),N.current=!1,g(!1)}function M(){if(w.current)return;let t=b.trim();t===e.trim()||C.current&&t===k.current.trim()||t&&u&&!u(t)?R(!0):(_.current=null,P.clear(),N.current=!1,g(!1),w.current=!0,Promise.resolve(o(t)).catch(()=>{}).finally(()=>{w.current=!1}))}function L(e){w.current||(_.current=null,P.clear(e.title),N.current=!1,g(!1),w.current=!0,Promise.resolve(c(e)).catch(()=>{}).finally(()=>{w.current=!1}))}return(0,n.useEffect)(()=>{if(!f)return void $(null);function e(){let e=j.current;if(!e)return;let t=e.getBoundingClientRect(),n=window.innerHeight-t.bottom-8,a=t.top-8,r=n<180&&a>n;$({left:Math.max(8,Math.min(t.left,window.innerWidth-340-8)),top:r?t.top:t.bottom,placement:r?"top":"bottom",maxHeight:Math.max(120,(r?a:n)-16)})}return e(),window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[f]),f?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("input",{ref:j,type:"text",value:b,onChange:e=>y(e.target.value),onKeyDown:e=>{if(!(0,i.handlePreviewKeyDown)(e,P,L)){if("Enter"===e.key){if(T&&u&&!u(T)&&P.items.length>0)return;M()}"Escape"===e.key&&R(!1)}},onBlur:function(e){let t=e.relatedTarget,n=!!t&&!v.current?.contains(t);if(S.current||n){S.current=!1,M();return}requestAnimationFrame(()=>{N.current&&document.activeElement!==j.current&&j.current?.focus()})},placeholder:p,className:(0,s.cn)("bg-transparent px-1 -mx-1 py-0 text-inherit outline-none caret-foreground min-w-0","[field-sizing:content] min-w-[6ch] max-w-[calc(100%+0.5rem)]",x)}),I&&(0,r.createPortal)((0,t.jsx)("div",{ref:v,style:{position:"fixed",left:I.left,top:I.top,width:(0,a.designPx)(340),zIndex:60},onMouseDown:e=>e.preventDefault(),children:(0,t.jsx)(i.SearchPreviewDropdown,{preview:P,keyword:b,onPick:L,placement:I.placement,maxHeight:I.maxHeight})}),document.body)]}):(0,t.jsx)("button",{type:"button",onClick:function(){let t=e||_.current||d||"";y(t),k.current=t,C.current=!e&&!_.current&&!!t,S.current=!1,e&&t===e&&P.clear(e),N.current=!0,g(!0)},className:(0,s.cn)("text-left rounded-sm px-1 -mx-1 transition-colors cursor-text hover:underline underline-offset-2 decoration-foreground/30 whitespace-nowrap",h),title:e||void 0,children:e||(0,t.jsx)("span",{className:"text-muted-foreground",children:p})})}])},127341,e=>{"use strict";var t=e.i(843476),n=e.i(271645),a=e.i(225913),r=e.i(981140),s=e.i(30030),i=e.i(842727),o=e.i(296626);e.i(174080);var l=e.i(991918),c=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,a)=>{let r=(0,l.createSlot)(`Primitive.${a}`),s=n.forwardRef((e,n)=>{let{asChild:s,...i}=e;return"u">typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,t.jsx)(s?r:a,{...i,ref:n})});return s.displayName=`Primitive.${a}`,{...e,[a]:s}},{}),d=e.i(586318),u=e.i(369340),m=e.i(610772),p="Tabs",[h,x]=(0,s.createContextScope)(p,[i.createRovingFocusGroupScope]),f=(0,i.createRovingFocusGroupScope)(),[g,b]=h(p),y=n.forwardRef((e,n)=>{let{__scopeTabs:a,value:r,onValueChange:s,defaultValue:i,orientation:o="horizontal",dir:l,activationMode:h="automatic",...x}=e,f=(0,d.useDirection)(l),[b,y]=(0,u.useControllableState)({prop:r,onChange:s,defaultProp:i??"",caller:p});return(0,t.jsx)(g,{scope:a,baseId:(0,m.useId)(),value:b,onValueChange:y,orientation:o,dir:f,activationMode:h,children:(0,t.jsx)(c.div,{dir:f,"data-orientation":o,...x,ref:n})})});y.displayName=p;
1var j="TabsList",v=n.forwardRef((e,n)=>{let{__scopeTabs:a,loop:r=!0,...s}=e,o=b(j,a),l=f(a);return(0,t.jsx)(i.Root,{asChild:!0,...l,orientation:o.orientation,dir:o.dir,loop:r,children:(0,t.jsx)(c.div,{role:"tablist","aria-orientation":o.orientation,...s,ref:n})})});v.displayName=j;var w="TabsTrigger",N=n.forwardRef((e,n)=>{let{__scopeTabs:a,value:s,disabled:o=!1,...l}=e,d=b(w,a),u=f(a),m=C(d.baseId,s),p=S(d.baseId,s),h=s===d.value;return(0,t.jsx)(i.Item,{asChild:!0,...u,focusable:!o,active:h,children:(0,t.jsx)(c.button,{type:"button",role:"tab","aria-selected":h,"aria-controls":p,"data-state":h?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:m,...l,ref:n,onMouseDown:(0,r.composeEventHandlers)(e.onMouseDown,e=>{o||0!==e.button||!1!==e.ctrlKey?e.preventDefault():d.onValueChange(s)}),onKeyDown:(0,r.composeEventHandlers)(e.onKeyDown,e=>{[" ","Enter"].includes(e.key)&&d.onValueChange(s)}),onFocus:(0,r.composeEventHandlers)(e.onFocus,()=>{let e="manual"!==d.activationMode;h||o||!e||d.onValueChange(s)})})})});N.displayName=w;var k="TabsContent",_=n.forwardRef((e,a)=>{let{__scopeTabs:r,value:s,forceMount:i,children:l,...d}=e,u=b(k,r),m=C(u.baseId,s),p=S(u.baseId,s),h=s===u.value,x=n.useRef(h);return n.useEffect(()=>{let e=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,t.jsx)(o.Presence,{present:i||h,children:({present:n})=>(0,t.jsx)(c.div,{"data-state":h?"active":"inactive","data-orientation":u.orientation,role:"tabpanel","aria-labelledby":m,hidden:!n,id:p,tabIndex:0,...d,ref:a,style:{...e.style,animationDuration:x.current?"0s":void 0},children:n&&l})})});function C(e,t){return`${e}-trigger-${t}`}function S(e,t){return`${e}-content-${t}`}_.displayName=k,e.s(["Content",0,_,"List",0,v,"Root",0,y,"Tabs",0,y,"TabsContent",0,_,"TabsList",0,v,"TabsTrigger",0,N,"Trigger",0,N,"createTabsScope",0,x],926209);var T=e.i(926209),T=T,D=e.i(647163),P=e.i(65373);let I=0;function $(){return performance.now()<I}let R=n.createContext(void 0),M=(0,a.cva)("rounded-full sq-capsule p-[3px] group-data-[orientation=horizontal]/tabs:h-9 data-[variant=line]:rounded-none group/tabs-list text-muted-foreground inline-flex w-fit items-center justify-center group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col overflow-x-auto overflow-y-hidden scrollbar-none",{variants:{variant:{default:"bg-muted",line:"gap-1 bg-transparent w-full flex justify-start p-0 items-center"}},defaultVariants:{variant:"line"}});e.s(["Tabs",0,function({className:e,orientation:a="horizontal",onValueChange:r,persistKey:s,value:i,defaultValue:o,children:l,...c}){let d=n.useRef(null),u=void 0!==i,m=!!s&&!u,[p,h]=(0,P.usePersistedTab)(m?s:"","string"==typeof o?o:""),[x,f]=n.useState("string"==typeof o?o:void 0),g=u?i:m?p:x,b=n.useCallback(e=>{let t=d.current?.closest("[data-scroll-root]"),n=t?.scrollTop??0;if(r?.(e),m?h(e):u||f(e),t&&!$()){let e=!1,a=()=>{e=!0};t.addEventListener("touchmove",a,{passive:!0}),t.addEventListener("wheel",a,{passive:!0});let r=()=>{t.removeEventListener("touchmove",a),t.removeEventListener("wheel",a)};requestAnimationFrame(()=>{e?r():(t.scrollTop=n,requestAnimationFrame(()=>{e||(t.scrollTop=n),r()}))})}},[r,m,h,u]);return(0,t.jsx)(T.Root,{ref:d,"data-slot":"tabs","data-orientation":a,orientation:a,value:m?p:i,defaultValue:m?void 0:o,onValueChange:b,className:(0,D.cn)("group/tabs flex gap-2 data-[orientation=horizontal]:flex-col",e),...c,children:(0,t.jsx)(R.Provider,{value:g,children:l})})},"TabsContent",0,function({className:e,onFocusCapture:a,keepMounted:r,style:s,children:i,...o}){let l=n.useContext(R),c=void 0!==l&&l===o.value,[d,u]=n.useState(c);c&&!d&&u(!0);let m=!!r&&d&&!c;return(0,t.jsx)(T.Content,{"data-slot":"tabs-content",className:(0,D.cn)("flex-1 outline-none",e),tabIndex:-1,...m?{forceMount:!0,hidden:!0}:null,style:m?{...s,display:"none"}:s,onFocusCapture:e=>{let t=e.currentTarget.closest("[data-scroll-root]"),n=t?.scrollTop??0;if(e.preventDefault(),a?.(e),t&&!$()){let e=!1,a=()=>{e=!0};t.addEventListener("touchmove",a,{passive:!0}),t.addEventListener("wheel",a,{passive:!0}),requestAnimationFrame(()=>{e||(t.scrollTop=n),t.removeEventListener("touchmove",a),t.removeEventListener("wheel",a)})}},...o,children:r&&d?(0,t.jsx)(n.Activity,{mode:c?"visible":"hidden",children:i}):i}
1)},"TabsList",0,function({className:e,variant:n="line",...a}){return(0,t.jsx)(T.List,{"data-slot":"tabs-list","data-variant":n,className:(0,D.cn)(M({variant:n}),e),...a})},"TabsTrigger",0,function({className:e,...n}){return(0,t.jsx)(T.Trigger,{"data-slot":"tabs-trigger",className:(0,D.cn)("outline-none data-[state=inactive]:text-foreground/60 hover:text-foreground dark:data-[state=inactive]:text-muted-foreground dark:hover:text-foreground relative inline-flex h-[calc(100%-1px)] flex-1 shrink-0 items-center justify-center gap-1.5 rounded-full sq-capsule border border-transparent px-2 py-1 text-xs sm:text-sm font-medium whitespace-nowrap transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4","group-data-[variant=line]/tabs-list:flex-none group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-[#F5F4ED] group-data-[variant=line]/tabs-list:data-[state=active]:text-foreground dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-accent","group-data-[variant=line]/tabs-list:h-9 group-data-[variant=line]/tabs-list:px-4 group-data-[variant=line]/tabs-list:text-sm group-data-[variant=line]/tabs-list:data-[state=inactive]:hover:bg-[#F5F4ED] dark:group-data-[variant=line]/tabs-list:data-[state=inactive]:hover:bg-accent","data-[state=active]:bg-background dark:data-[state=active]:text-foreground dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 data-[state=active]:text-foreground",e),...n})},"claimTabScroll",0,function(e=1500){I=performance.now()+e},"tabsListVariants",0,M],127341)},651035,e=>{"use strict";var t=e.i(843476),n=e.i(63270),a=e.i(647163);function r({name:e,email:s,avatarUrl:i,className:o}){let l;return(0,t.jsxs)(n.Avatar,{className:(0,a.cn)("size-5 shrink-0",o),children:[i&&(0,t.jsx)(n.AvatarImage,{src:i,alt:e||s||""}
1),(0,t.jsx)(n.AvatarFallback,{className:"bg-foreground/8 text-[9px] text-foreground/60",children:0===(l=(e?.trim()||s?.split("@")[0]||"").split(/[\s._-]+/).filter(Boolean)).length?"?":1===l.length?l[0].slice(0,2).toUpperCase():(l[0][0]+l[l.length-1][0]).toUpperCase()})]})}function s(e,{value:n,fallbackLabel:a="Teammate"}={}){let i=e.name??e.full_name??null,o=i||e.email||a;return{value:n??e.id,label:o,icon:(0,t.jsx)(r,{name:i,email:e.email,avatarUrl:e.avatar_url}),keywords:e.email??void 0}}e.s(["UserAvatar",0,r,"memberOption",0,function(e,t){let n=e.profile??e.profiles??null;return s({id:e.user_id,full_name:n?.full_name??null,email:n?.email??null,avatar_url:n?.avatar_url??null},t)},"userOption",0,s])},706923,e=>{"use strict";var t=e.i(843476),n=e.i(271645),a=e.i(494913),r=e.i(401851),s=e.i(463059),i=e.i(778917),o=e.i(503116),l=e.i(286536),c=e.i(426669),c=c,d=e.i(416788),u=e.i(796861),m=e.i(647163),p=e.i(502072);function h({label:e,value:n,icon:a}){return(0,t.jsxs)("div",{className:"border border-card-border rounded-[20px] p-3 bg-card",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:[(0,t.jsx)(a,{className:"h-3 w-3"}),e]}),(0,t.jsx)("div",{className:"text-xl font-bold tracking-tight mt-0.5 tabular-nums truncate",title:n,children:n})]})}function x({session:e,isLast:a}){let[o,d]=(0,n.useState)(!1),u=e.page_views.length>0||e.events.length>0,h=new Date(e.started_at),g=e.referrer?function(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}(e.referrer):"Direct",b=e.landing_path||(e.landing_url?function(e){try{return new URL(e).pathname||"/"}catch{return e}}(e.landing_url):"/");return(0,t.jsxs)("div",{className:(0,m.cn)(!a&&"border-b border-card-border/70"),children:[(0,t.jsxs)("button",{type:"button",onClick:()=>u&&d(e=>!e),className:(0,m.cn)("w-full flex items-center gap-3 px-4 py-3 text-left",u&&"hover:bg-muted/30 transition-colors"),children:[(0,t.jsx)(p.AnimatedChevron,{open:o,icon:s.ChevronRight,degOpen:90,degClosed:0,className:(0,m.cn)("h-4 w-4 shrink-0 text-muted-foreground",!u&&"opacity-30")}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-baseline gap-2 flex-wrap text-sm",children:[(0,t.jsx)("span",{className:"font-mono text-foreground truncate",title:b,children:b}),(0,t.jsxs)("span",{className:"text-xs text-muted-foreground",children:["· from ",g]}),e.utm_campaign&&(0,t.jsx)("span",{className:"text-[11px] rounded-full bg-muted px-1.5 py-0.5 text-muted-foreground",children:e.utm_campaign})]}),(0,t.jsxs)("div",{className:"mt-0.5 text-[11px] text-muted-foreground tabular-nums",children:[(0,r.format)(h,"MMM d, h:mm a")," · ",e.page_view_count," ",1===e.page_view_count?"page":"pages",e.duration_seconds>0&&(0,t.jsxs)(t.Fragment,{children:[" · ",f(e.duration_seconds)]}),(e.city||e.country)&&(0,t.jsxs)(t.Fragment,{children:[" · ",[e.city,e.country].filter(Boolean).join(", ")]})]})]})]}),o&&u&&(0,t.jsxs)("div",{className:"border-t border-card-border/70 bg-muted/30 px-4 py-2 space-y-0.5",children:[e.page_views.map(e=>(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs py-1",children:[(0,t.jsx)(l.Eye,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),(0,t.jsx)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"font-mono truncate text-foreground/80 hover:text-foreground",title:e.title||e.url,children:e.path}),(0,t.jsx)(i.ExternalLink,{className:"h-3 w-3 shrink-0 text-muted-foreground/50"}),(0,t.jsxs)("div",{className:"ml-auto shrink-0 text-muted-foreground tabular-nums",children:[null!=e.duration_seconds&&e.duration_seconds>0&&(0,t.jsxs)("span",{children:[f(e.duration_seconds)," · "]}),(0,r.format)(new Date(e.viewed_at),"h:mm:ss a")]})]},e.id)),e.events.map(e=>(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs py-1",children:[(0,t.jsx)(c.default,{className:"h-3 w-3 shrink-0 text-purple-500"}),(0,t.jsx)("span",{className:"font-medium text-foreground",children:e.name}),e.path&&(0,t.jsx)("span",{className:"text-muted-foreground font-mono",children:e.path}),(0,t.jsx)("div",{className:"ml-auto shrink-0 text-muted-foreground tabular-nums",children:(0,r.format)(new Date(e.occurred_at),"h:mm:ss a")})]},e.id))]})]})}function f(e){if(!e||e<1)return"0s";if(e<60)return`${Math.round(e)}s`;let t=Math.floor(e/60),n=Math.round(e%60);if(t<60)return n?`${t}m ${n}s`:`${t}m`;let a=Math.floor(t/60),r=t%60;return r?`${a}h ${r}m`:`${a}h`}e.s(["WebsiteActivity",0,function({visitors:e,sessions:n,variant:r="contact",emptyHint:s}){if(0===n.length)return(0,t.jsxs)("div",{className:"rounded-[20px] border border-card-border bg-card p-12 flex flex-col items-center justify-center text-center",children:[(0,t.jsx)("div",{className:"h-12 w-12 squircle bg-muted/60 flex items-center justify-center mb-3",children:(0,t.jsx)(u.GlobeIcon,{className:"h-6 w-6 text-muted-foreground"})}),(0,t.jsx)("h3",{className:"text-sm font-semibold",children:"No website activity yet"}),s&&(0,t.jsx)("p",{className:"mt-1 text-xs text-muted-foreground max-w-md leading-relaxed",children:s})]});let i=n.length,c=n.reduce((e,t)=>
1e+(t.page_view_count||0),0),m=n.reduce((e,t)=>e+(t.duration_seconds||0),0),p=n.reduce((e,t)=>{let n=new Date(t.last_activity_at);return!e||n>e?n:e},null);return(0,t.jsxs)("div",{className:"space-y-5",children:[(0,t.jsxs)("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:[(0,t.jsx)(h,{label:"Sessions",value:String(i),icon:u.GlobeIcon}),(0,t.jsx)(h,{label:"Pageviews",value:String(c),icon:l.Eye}),(0,t.jsx)(h,{label:"Time on site",value:f(m),icon:o.Clock}),"company"===r?(0,t.jsx)(h,{label:"Visitors",value:String(e.length),icon:d.PeopleGroupIcon}):(0,t.jsx)(h,{label:"Last seen",value:p?(0,a.formatDistanceToNow)(p,{addSuffix:!0}):"-",icon:o.Clock})]}),(0,t.jsxs)("div",{className:"rounded-[20px] border border-card-border bg-card overflow-hidden",children:[(0,t.jsxs)("div",{className:"px-4 py-3 border-b border-card-border/70 flex items-center justify-between",children:[(0,t.jsxs)("h3",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:["Sessions",(0,t.jsx)("span",{className:"ml-1.5 text-muted-foreground/60",children:i})]}),(0,t.jsxs)("div",{className:"text-[11px] text-muted-foreground tabular-nums",children:[c," ",1===c?"pageview":"pageviews"," · ",f(m)]})]}),(0,t.jsx)("div",{children:n.map((e,a)=>(0,t.jsx)(x,{session:e,isLast:a===n.length-1},e.id))})]})]})}],706923)},212555,e=>{"use strict";var t=e.i(271645),n=e.i(920755),a=e.i(489681),r=e.i(400732);e.s(["useLinkedInAutoRefresh",0,function(e,s,i,o){let l=(0,t.useRef)(!1);(0,t.useEffect)(()=>{if(l.current)return;l.current=!0;let t=(0,n.createClient)(),c=(0,r.isLinkedInDataStale)(s)||(0,r.needsIdentityMatch)(s);c&&o?.(!0);let d=e=>{e&&i(e),c&&o?.(!1)};"person"===e?(0,a.refreshPersonIfStale)(t,s).then(d,()=>{c&&o?.(!1)}):(0,a.refreshCompanyIfStale)(t,s).then(d,()=>{c&&o?.(!1)})},[])}])},65373,e=>{"use strict";var t=e.i(271645);e.s(["usePersistedTab",0,function(e,n){let[a,r]=(0,t.useState)(n);return(0,t.useEffect)(()=>{if(!e)return;let t=new URLSearchParams(window.location.search).get("tab");if(!t)try{t=localStorage.getItem(e)}catch{t=null}t&&r(t)},[e]),[a,(0,t.useCallback)(t=>{if(r(t),e)try{localStorage.setItem(e,t)}catch{}},[e])]}])},199598,e=>{"use strict";var t=e.i(747250),n=e.i(762836),a=e.i(533500),r=e.i(832006),s=e.i(617516),i=e.i(904889),o=e.i(620043);function l(t){switch(t){case"whatsapp":e.A(165119).catch(()=>{});break;case"sms":e.A(450811).catch(()=>{});break;case"imessage":e.A(906059).catch(()=>{});break;case"messages":e.A(659021).catch(()=>{});break;case"slack":e.A(93125).catch(()=>{});break;case"linkedin":e.A(169964).catch(()=>{});break;case"chat":e.A(148238).catch(()=>{});break;case"x":e.A(37404).catch(()=>{}),e.A(525728).catch(()=>{});break;case"reddit":e.A(733478).catch(()=>{}),e.A(24541).catch(()=>{})}}e.s(["pickLatestOpenable",0,function(e,t){if(!Array.isArray(e))return null;let n=[...e].sort((e,t)=>{let n=e.last_message_at?new Date(e.last_message_at).getTime():0;return(t.last_message_at?new Date(t.last_message_at).getTime():0)-n}),a=n.find(e=>!e.is_group&&e.last_message_at);return a?t?n.find(e=>e.channel===a.channel&&!e.is_group&&e.owner_user_id===t)??a:a:null},"prefetchWidgetThread",0,function(e,c){try{l(e.channel)}catch{}let d=e.contact_name||"",u=c.workspaceId;try{switch(e.channel){case"email":e.conversation_ref&&(0,t.preloadThread)(e.conversation_ref,"outlook"===e.email_provider?"/api/outlook":"/api/gmail");break;case"linkedin":e.conversation_ref&&(0,n.prefetchLinkedInByConversationId)({conversationId:e.conversation_ref,contactName:d}),e.contact_id&&c.profileUrn&&(0,n.prefetchLinkedInConversation)({contactId:e.contact_id,workspaceId:u,profileUrn:c.profileUrn,contactName:d.split(/\s+/)[0]||d});break;case"whatsapp":(0,a.prefetchWhatsAppConversation)({contactId:e.contact_id,conversationId:e.conversation_ref||void 0,workspaceId:u});break;case"sms":e.contact_id&&(0,r.prefetchSmsConversation)({contactId:e.contact_id,workspaceId:u});break;case"imessage":(0,o.prefetchImessageThread)(e.conversation_ref);break;case"messages":(0,i.prefetchMessagesThread)({contactId:e.contact_id,conversationId:e.conversation_ref||null});break;case"slack":e.conversation_ref?(0,s.prefetchSlackConversation)({conversationId:e.conversation_ref}):e.contact_id&&(0,s.prefetchSlackByContact)({contactId:e.contact_id,workspaceId:u})}}catch{}},"preloadChannelPanel",0,l])},423437,e=>{"use strict";var t=e.i(843476),n=e.i(271645);let a=(0,n.createContext)({denied:new Set,isAdmin:!1});e.s(["NavPermissionsProvider",0,function({deniedNavHrefs:e,isAdmin:r,children:s}){let i=(0,n.useMemo)(()=>({denied:new Set(e),isAdmin:r}),[e.join("|"),r]);return(0,t.jsx)(a.Provider,{value:i,children:s})},"useNavPermissions",0,function(){return(0,n.useContext)(a)}])},47563,e=>{"use strict";let t=(0,e.i(475254).default)("arrow-down-right",[["path",{d:"m7 7 10 10",key:"1fmybs"}],["path",{d:"M17 7v10H7",key:"6fjiku"}]]);e.s(["default",0,t])},10813,e=>{"use strict";var t=e.i(47563);e.s(["ArrowDownRight",()=>t.default])},900465,e=>{"use strict";let t=(0,e.i(475254).default)("arrow-right-left",[["path",{d:"m16 3 4 4-4 4",key:"1x1c3m"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"m8 21-4-4 4-4",key:"h9nckh"}],["path",{d:"M4 17h16",key:"g4d7ey"}]]);e.s(["default",0,t])},466261,e=>{"use strict";var t=e.i(900465);e.s(["ArrowRightLeft",()=>t.default])},469184,e=>{"use strict";let t=(0,e.i(475254).default)("arrow-up-right",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]);e.s(["default",0,t])},115057,e=>{"use strict";var t=e.i(469184);e.s(["ArrowUpRight",()=>t.default])},613278,e=>{"use strict";let t=(0,e.i(475254).default)("chart-no-axes-column",[["path",{d:"M5 21v-6",key:"1hz6c0"}],["path",{d:"M12 21V3",key:"1lcnhd"}],["path",{d:"M19 21V9",key:"unv183"}]]);e.s(["default",0,t])},173024,251485,636312,e=>{"use strict";var t=e.i(475254);let n=(0,t.default)("circle-dashed",[["path",{d:"M10.1 2.182a10 10 0 0 1 3.8 0",key:"5ilxe3"}],["path",{d:"M13.9 21.818a10 10 0 0 1-3.8 0",key:"11zvb9"}],["path",{d:"M17.609 3.721a10 10 0 0 1 2.69 2.7",key:"1iw5b2"}],["path",{d:"M2.182 13.9a10 10 0 0 1 0-3.8",key:"c0bmvh"}],["path",{d:"M20.279 17.609a10 10 0 0 1-2.7 2.69",key:"1ruxm7"}],["path",{d:"M21.818 10.1a10 10 0 0 1 0 3.8",key:"qkgqxc"}],["path",{d:"M3.721 6.391a10 10 0 0 1 2.7-2.69",key:"1mcia2"}],["path",{d:"M6.391 20.279a10 10 0 0 1-2.69-2.7",key:"1fvljs"}]]);e.s(["default",0,n],173024);let a=(0,t.default)("gauge",[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]]);e.s(["default",0,a],251485);let r=(0,t.default)("square-dashed-bottom",[["path",{d:"M5 21a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2",key:"as5y1o"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M14 21h1",key:"v9vybs"}]]);e.s(["default",0,r],636312)},872446,e=>{"use strict";let t=(0,e.i(475254).default)("hammer",[["path",{d:"m15 12-9.373 9.373a1 1 0 0 1-3.001-3L12 9",key:"1hayfq"}],["path",{d:"m18 15 4-4",key:"16gjal"}],["path",{d:"m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172v-.344a2 2 0 0 0-.586-1.414l-1.657-1.657A6 6 0 0 0 12.516 3H9l1.243 1.243A6 6 0 0 1 12 8.485V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5",key:"15ts47"}]]);e.s(["default",0,t])},161765,e=>{"use strict";var t=e.i(872446);e.s(["Hammer",()=>t.default])},249758,e=>{"use strict";let t=(0,e.i(475254).default)("heading",[["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M6 20V4",key:"1w1bmo"}],["path",{d:"M18 20V4",key:"o2hl4u"}]]);e.s(["default",0,t])},426669,e=>{"use strict";let t=(0,e.i(475254).default)("mouse-pointer-2",[["path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.5
179 6.126a.5.5 0 0 1-.947.063z",key:"edeuup"}]]);e.s(["default",0,t])},844489,e=>{"use strict";let t=(0,e.i(475254).default)("phone-incoming",[["path",{d:"M16 2v6h6",key:"1mfrl5"}],["path",{d:"m22 2-6 6",key:"6f0sa0"}],["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]]);e.s(["default",0,t])},151898,e=>{"use strict";var t=e.i(844489);e.s(["PhoneIncoming",()=>t.default])},437423,e=>{"use strict";let t=(0,e.i(475254).default)("phone-outgoing",[["path",{d:"m16 8 6-6",key:"oawc05"}],["path",{d:"M22 8V2h-6",key:"oqy2zc"}],["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]]);e.s(["default",0,t])},475682,e=>{"use strict";var t=e.i(437423);e.s(["PhoneOutgoing",()=>t.default])},44016,e=>{"use strict";let t=(0,e.i(475254).default)("settings-2",[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]);e.s(["default",0,t])},284765,e=>{"use strict";var t=e.i(44016);e.s(["Settings2",()=>t.default])},574146,e=>{"use strict";let t=(0,e.i(475254).default)("sticky-note",[["path",{d:"M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z",key:"1dfntj"}],["path",{d:"M15 3v5a1 1 0 0 0 1 1h5",key:"6s6qgf"}]]);e.s(["default",0,t])},131531,e=>{"use strict";var t=e.i(574146);e.s(["StickyNote",()=>t.default])},977482,e=>{"use strict";let t=(0,e.i(475254).default)("table-2",[["path",{d:"M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18",key:"gugj83"}]]);e.s(["default",0,t])},878894,e=>{"use strict";var t=e.i(582458);e.s(["AlertTriangle",()=>t.default])},559749,e=>{"use strict";var t=e.i(430735);e.s(["PDFDocument",()=>t.default])}]);

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.