PageSourceSearch

https://www.splutter.ai/_next/static/chunks/8940.66985468aab9a708.js

js splutter.ai collected 2026-09-29 03:24:11 UTC 165,194 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8940],{69037:(e,n,t)=>{t.d(n,{e1:()=>h,my:()=>p,rJ:()=>f});var r=t(19127),i=t(5820),o=t(54756),a=t.n(o),s=t(7708),c=t(71884),d=t(14604);function l(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),t.push.apply(t,r)}return t}function u(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?l(Object(t),!0).forEach(function(n){(0,r.A)(e,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):l(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}var p=function(){var e=(0,i.A)(a().mark(function e(n,t,r){var i,o,d,l,p,f,h,x;return a().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,o=null===(i=s.auth.currentUser)||void 0===i?void 0:i.uid){e.next=4;break}throw Error("User is not authenticated");case 4:return d=(0,c.aU)(n),l=(0,c.rJ)(d,"customers",o,"checkout_sessions"),console.log(p=t.map(function(e){return u(u({},""!=e.priceId&&{price:e.priceId}),e.quantity&&{quantity:e.quantity})})),f={firebaseUID:o},r&&(f.client_reference_id=r),h={line_items:p,metadata:f,success_url:window.location.origin+"/success",cancel_url:window.location.origin+"/fail",allow_promotion_codes:!0},r&&(h.client_reference_id=r),e.next=14,(0,c.gS)(l,h);case 14:return x=e.sent,e.abrupt("return",new Promise(function(e,n){var t=(0,c.aQ)(x,function(r){var i=r.data(),o=i.error,a=i.url;o&&(t(),n(Error("An error occurred: ".concat(o.message)))),a&&(console.log("Stripe Checkout URL:",a),t(),e(a))})}));case 18:e.prev=18,e.t0=e.catch(0),console.log(e.t0.toString());case 21:case"end":return e.stop()}},e,null,[[0,18]])}));return function(n,t,r){return e.apply(this,arguments)}}(),f=function(){var e=(0,i.A)(a().mark(function e(n,t,r){var i,o,d,l,p,f,h,x;return a().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,o=null===(i=s.auth.currentUser)||void 0===i?void 0:i.uid){e.next=4;break}throw Error("User is not authenticated");case 4:return d=(0,c.aU)(n),l=(0,c.rJ)(d,"customers",o,"checkout_sessions"),p=t.map(function(e){return u(u({},e.priceId&&{price:e.priceId}),e.quantity&&{quantity:e.quantity})}),f={firebaseUID:o},r&&(f.client_reference_id=r),h={mode:"payment",line_items:p,metadata:f,success_url:window.location.origin+"/success",cancel_url:window.location.origin+"/fail",allow_promotion_codes:!0},r&&(h.client_reference_id=r),e.next=13,(0,c.gS)(l,h);case 13:return x=e.sent,e.abrupt("return",new Promise(function(e,n){var t=(0,c.aQ)(x,function(r){var i=r.data()||{},o=i.error,a=i.url;o&&(t(),n(Error("An error occurred: ".concat(o.message)))),a&&(console.log("Stripe Checkout URL (One‐Time):",a),t(),e(a))})}));case 17:throw e.prev=17,e.t0=e.catch(0),console.error("One-time checkout error:",e.t0),e.t0;case 21:case"end":return e.stop()}},e,null,[[0,17]])}));return function(n,t,r){return e.apply(this,arguments)}}(),h=function(){var e=(0,i.A)(a().mark(function e(n){var t,r,i,o;return a().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=s.auth.currentUser){e.next=3;break}throw Error("User is not authenticated.");case 3:return e.prev=3,i=(0,d.Uz)(n,"us-central1"),o=(0,d.Qg)(i,"ext-firestore-stripe-payments-createPortalLink"),e.next=8,o({customerId:null==t?void 0:t.uid,returnUrl:window.location.origin+"/dashboard"});case 8:console.log("Reroute to Stripe portal: ",(r=e.sent.data).url),e.next=17;break;case 14:e.prev=14,e.t0=e.catch(3),console.error(e.t0);case 17:return e.abrupt("return",new Promise(function(e,n){r?r.url?e(r.url):n(Error("No url returned")):n(Error("No url at all"))}));case 18:case"end":return e.stop()}},e,null,[[3,14]])}));return function(n){return e.apply(this,arguments)}}()},98940:(e,n,t)=>{t.r(n),t.d(n,{default:()=>oo});var r=t(5820),i=t(87567),o=t(54756),a=t.n(o),s=t(96540),c=t(44404),d=t(77079),l=t(52865),u=t(64721),p=t(71536),f=t.n(p),h=t(90629),x=t(69037),g=t(7708),m=t(86715),b=t(65781),y=t(42705),v=t
1(54293),w=t(94089),j=t(24473),_=t(4153),C=t(35929),k=t(58833),A=t(761),I=t(94736),S=t(19127),N=t(38242),D=t(74353),T=t.n(D),O=t(6279),z=t.n(O),P=t(30924),M=t(84212),E=t(52838),L=t(21961),B=t(55578),R=t(36205),H=t(30184),$=t(228),W=t(74848),F="#f5d487",V=c.Ay.div.withConfig({displayName:"SalesFunnel__Box",componentId:"sc-wypx3v-0"})(["width:250px;height:250px;margin:0 auto;display:flex;flex-direction:column;justify-content:center;gap:12px;"]),U=c.Ay.div.attrs(function(e){return{style:{width:"".concat(e.$pct,"%"),margin:"0 auto"}}}).withConfig({displayName:"SalesFunnel__Slice",componentId:"sc-wypx3v-1"})(["position:relative;flex:1 1 0;min-height:0;&::after{content:'';position:absolute;inset:0;background:rgba(245,212,135,.06);clip-path:polygon( 0 0,100% 0,95% 100%,0 100% );border:1px solid ",";border-right:none;z-index:0;}&::before{content:'';position:absolute;left:0;top:0;width:1px;height:100%;background:",";z-index:1;}.label{position:absolute;top:50%;transform:translateY(-50%);font-size:.8rem;font-weight:600;white-space:nowrap;z-index:2;","}.value{position:absolute;top:50%;transform:translateY(-50%);left:calc(100% + 10px);font-size:.8rem;font-weight:600;color:",";white-space:nowrap;z-index:2;}"],F,F,function(e){return e.$inside?(0,c.AH)(["left:50%;transform:translate(-50%,-50%);text-align:center;"]):(0,c.AH)(["right:calc(100% + 10px);"])},F);function G(e){var n=e.levels;if(!(null!=n&&n.length))return null;var t={Contacts:1e3,Meetings:100,Deals:10},r=Math.max.apply(Math,[1].concat((0,N.A)(n.map(function(e){return+e.v||0}))));return(0,W.jsx)(V,{children:n.map(function(e){var n=r?e.v/r*100:0,i=Math.round(e.v/(t[e.n]||1)).toLocaleString();return(0,W.jsxs)(U,{$pct:n,$inside:n>66,children:[(0,W.jsx)("span",{className:"label",children:e.n}),(0,W.jsx)("span",{className:"value",children:i})]},e.n)})})}function q(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),t.push.apply(t,r)}return t}function Y(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?q(Object(t),!0).forEach(function(n){(0,S.A)(e,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):q(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}T().extend(z());var J="#ffffff",Q="#e5e7eb",K="#6b7280",X="#0ea5e9",Z=c.Ay.section.withConfig({displayName:"DashboardTab__Page",componentId:"sc-1dgy8g1-0"})(["background:",";color:",";padding:2rem;display:flex;flex-direction:column;gap:24px;min-height:100%;font-family:Inter,system-ui,-apple-system,Segoe UI,Helvetica,Arial,sans-serif;"],J,"#1f2937"),ee=c.Ay.div.withConfig({displayName:"DashboardTab__HeroBar",componentId:"sc-1dgy8g1-1"})(["display:flex;width:100%;border:1px solid ",";border-radius:14px;overflow:hidden;"],Q),en=c.Ay.div.withConfig({displayName:"DashboardTab__KPI",componentId:"sc-1dgy8g1-2"})(["flex:1 1 0;padding:22px 28px;display:flex;flex-direction:column;gap:6px;&:not(:last-child){border-right:1px solid ",";}h5{margin:0;font-size:.65rem;letter-spacing:.04em;color:",";text-transform:uppercase;font-weight:600;}strong{font-size:2rem;font-weight:700;color:",";line-height:1;}"],Q,K,function(e){return e.$c}),et=c.Ay.div.withConfig({displayName:"DashboardTab__Main",componentId:"sc-1dgy8g1-3"})(["display:flex;flex-direction:column;gap:12px;@media(min-width:1024px){flex-direction:row;}"]),er=c.Ay.div.withConfig({displayName:"DashboardTab__Col",componentId:"sc-1dgy8g1-4"})(["display:flex;flex-direction:column;gap:12px;width:100%;min-width:0;",""],function(e){return e.$w&&(0,c.AH)(["@media(min-width:1024px){width:",";}"],e.$w)}),ei=c.Ay.div.withConfig({displayName:"DashboardTab__Card",componentId:"sc-1dgy8g1-5"})(["background:transparent;border:1px solid ",";border-radius:12px;padding:",";display:flex;flex-direction:column;"],Q,function(e){return e.$tight?"14px 18px":"22px 26px"}),eo=c.Ay.h4.withConfig({displayName:"DashboardTab__CardTitle",componentId:"sc-1dgy8g1-6"})(["margin:0 0 10px;font-size:.95rem;font-weight:600;color:",";"],X),ea=c.Ay.ul.withConfig({displayName:"DashboardTab__List",componentId:"sc-1dgy8g1-7"})(["list-style:none;margin:0;padding:0;display:flex;flex-direction:column;"]),es=c.Ay.li.withConfig({displayName:"DashboardTab__Row",componentId:"sc-1dgy8g1-8"})(["display:flex;align-items:center;gap:12px;padding:12px 0;min-height:58px;&:not(:last-child){border-bottom:1px solid ",";}.info{flex:1;min-width:0;display:flex;flex-direction:column;}h6{margin:0;font-size:.82rem;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}span{font-size:.7rem;color:",";}"],Q,K),ec=c.Ay.div.withConfig({displayName:"DashboardTab__Empty",componentId:"sc-1dgy8g1-9"})(["text-align:center;padding:40px 0;font-size:.85rem;color:",";"],K),ed=c.Ay.button.withConfig({displayName:"DashboardTab__PushBtn",componentId:"sc-1dgy8g1-10"})(["padding:6px 12px;border:none;border-radius:6px;font-size:.72rem;font-weight:600;background:",";color:#fff;cursor:",";white-space:nowrap;"],function(e){return e.disabled?Q:"#6366f1"},function(e){return e.disabled?"not-allowed":"pointer"}),el=function(e){return e.reduce(function(e,n){return e+(+n||0)},0)},eu=function(e,n){var t=(Date.now()-n)/864e5;return 2*e+(t<1?10:t<3?6:t<7?3:0)};
1function ep(){var e=(0,d.mc)().state,n=(0,l.y)(),t=(0,s.useMemo)(function(){return new Set(e.crmProfiles.map(function(e){var n;return null===(n=e.email)||void 0===n?void 0:n.toLowerCase()}).filter(Boolean))},[e.crmProfiles]),r=(0,s.useCallback)(function(e){return console.log("Push to DGS",e.id||e.visitorId)},[]),o=(0,s.useMemo)(function(){var t=Array.isArray(n.events)?n.events:[],r=T()().subtract(29,"day").startOf("day"),o=Array.from({length:30},function(e,n){return{d:r.add(n,"day"),ids:new Set}}),a={};t.forEach(function(e){var n=e.visitor_id||e.visitorId||null;if(n){var t=+new Date(e.created_at||e.createdAt),i=T()(t).diff(r,"day");i>=0&&i<30&&o[i].ids.add(n),(a[n]=a[n]||[]).push(t)}});var s={};Object.entries(a).forEach(function(e){var n=(0,i.A)(e,2),t=n[0],r=n[1].sort(function(e,n){return e-n}),o=0,a=null;r.forEach(function(e){(null===a||e-a>18e5)&&o++,a=e}),s[t]={v:o,l:r[r.length-1],f:r[0],tsList:r}});var c=o.map(function(e){return{name:e.d.format("D MMM"),Visitors:e.ids.size}}),d=new Set(Object.keys(s)),l=new Set(o.flatMap(function(e){return(0,N.A)(e.ids)})).size,u=(0,N.A)(d).map(function(e){var t=s[e],r=(n.profiles||[]).find(function(n){return n.visitorId===e})||{},i=r.name||r.displayName||n.getAvatarEntry(e).displayName,o=(r.email||"").toLowerCase()||"",a=r.phone||"";return{id:e,visits:t.v,last:t.l,name:i,email:o,phone:a,avatar:n.getAvatar(e)}}).sort(function(e,n){return eu(n.v,n.l)-eu(e.v,e.l)}).slice(0,12),p={};e.dealProfiles.forEach(function(e){return p[e.stage||"Unknown"]=[].concat((0,N.A)(p[e.stage||"Unknown"]||[]),[e])});var f=el((p.Won||[]).map(function(e){return e.value_usd})),h=(p.Won||[]).length,x=el(Object.entries(p).filter(function(e){return!["Won","Lost"].includes((0,i.A)(e,1)[0])}).flatMap(function(e){return(0,i.A)(e,2)[1].map(function(e){return e.value_usd})})),g=T()().startOf("day");return{wonUsd:f,dealsWon:h,openUsd:x,visitors30:l,meetingsToday:e.meetingProfiles.filter(function(e){return T()(e.meeting_ts).isSame(g,"day")}),hot:u,visitorsSeries:c,funnel:[{n:"Visitors",v:d.size},{n:"Contacts",v:1e3*e.crmProfiles.length},{n:"Meetings",v:100*e.meetingProfiles.length},{n:"Deals",v:10*e.dealProfiles.length}]}},[e,n]);return o.funnel[0].v,(0,W.jsxs)(Z,{children:[(0,W.jsxs)(ee,{children:[(0,W.jsxs)(en,{$c:"#22c55e",children:[(0,W.jsx)("h5",{children:"Revenue"}),(0,W.jsxs)("strong",{children:["$",o.wonUsd.toLocaleString()]})]}),(0,W.jsxs)(en,{$c:"#eab308",children:[(0,W.jsx)("h5",{children:"Deals won"}),(0,W.jsx)("strong",{children:o.dealsWon})]}),(0,W.jsxs)(en,{$c:"#f97316",children:[(0,W.jsx)("h5",{children:"Open pipeline"}),(0,W.jsxs)("strong",{children:["$",o.openUsd.toLocaleString()]})]}),(0,W.jsxs)(en,{$c:"#ef4444",children:[(0,W.jsx)("h5",{children:"New visitors 30 d"}),(0,W.jsx)("strong",{children:o.visitors30.toLocaleString()})]})]}),(0,W.jsxs)(et,{children:[(0,W.jsxs)(er,{$w:"320px",children:[(0,W.jsxs)(ei,{$tight:!0,children:[(0,W.jsx)(eo,{children:"Tasks"}),(0,W.jsx)(ec,{children:"No tasks yet"})]}),(0,W.jsxs)(ei,{$tight:!0,children:[(0,W.jsx)(eo,{children:"Today’s meetings"}),o.meetingsToday.length?(0,W.jsx)(ea,{children:o.meetingsToday.map(function(e){return(0,W.jsxs)(es,{children:[(0,W.jsx)("div",{className:"info",children:(0,W.jsx)("h6",{children:e.contact_name||"—"})}),(0,W.jsx)("span",{style:{fontSize:12,color:K},children:T()(e.meeting_ts).format("h:mm A")})]},e.id)})}):(0,W.jsx)(ec,{children:"No meetings"})]})]}),(0,W.jsxs)(er,{children:[(0,W.jsxs)(ei,{children:[(0,W.jsx)(eo,{children:"Sales funnel"}),(0,W.jsx)(G,{levels:o.funnel})]}),(0,W.jsxs)(ei,{$tight:!0,children:[(0,W.jsx)(eo,{children:"Unique visitors \xb7 30 d"}),o.visitorsSeries.every(function(e){return 0===e.Visitors})?(0,W.jsx)(ec,{children:"No visits yet"}):(0,W.jsx)(P.u,{width:"100%",height:220,children:(0,W.jsxs)(M.b,{data:o.visitorsSeries,children:[(0,W.jsx)(E.d,{strokeDasharray:"3 3",vertical:!1,stroke:Q}),(0,W.jsx)(L.W,{dataKey:"name",tick:{fontSize:10,fill:K}}),(0,W.jsx)(B.h,{tick:{fontSize:10,fill:K},allowDecimals:!1}),(0,W.jsx)(R.m,{contentStyle:{background:J,border:"1px solid ".concat(Q)}}),(0,W.jsx)(H.N,{type:"monotone",dataKey:"Visitors",stroke:X,strokeWidth:2,dot:!1})]})})]})]}),(0,W.jsx)(er,{$w:"620px",children:(0,W.jsxs)(ei,{$tight:!0,children:[(0,W.jsx)(eo,{children:"High-value traffic"}),o.hot.length?(0,W.jsx)(ea,{children:o.hot.map(function(e){var n,i,o=!!(e.email&&t.has(e.email)||e.phone&&null!==(n=crmPhones)&&void 0!==n&&null!==(i=n.has)&&void 0!==i&&i.call(n,e.phone)),a=(!!e.email||!!e.phone)&&!o;return(0,W.jsxs)(es,{children:[(0,W.jsx)($.A,Y(Y({style:{width:36,height:36}},e.avatar),{},{shape:"circle"})),(0,W.jsxs)("div",{className:"info",children:[(0,W.jsx)("h6",{children:e.name}),e.email&&(0,W.jsx)("span",{children:e.email}),e.phone&&(0,W.jsx)("span",{children:e.phone}),(0,W.jsxs)("span",{children:[e.visits," visit",1===e.visits?"":"s"," \xb7 ",T()(e.last).fromNow(!0)," ago"]})]}),(0,W.jsx)(ed,{disabled:!a,onClick:function(){return a&&r(e)},children:o?"In DGS":"Add"})]},e.id)})}):(0,W.jsx)(ec,{children:"No high-interest visitors"})]})})]})]})}var ef=t(27682),eh=t(86354);function ex(e,n,t){if(!n.team_id)return n.owner_id===e;var r,i=null==t||null===(r=t.members)||void 0===r?void 0:r.find(function(n){return n.uid===e});return!!i&&("admin"===i.role||n.assignee_id===e)}var eg=function(e,n,t){return"PERSONAL"===e||n(t,"d")},em=function(e,n,t){return"PERSONAL"===e||n(t,"c")},eb=c.Ay.button.withConfig({displayName:"CreateOrgButtonModal__Fab",componentId:"sc-1kfinjw-0"})(["margin-top:18px;align-self:flex-start;padding:8px 14px;font-weight:600;background:#6366f1;color:#fff;border:none;border-radius:8px;
1cursor:pointer;transition:background .18s;&:hover:not(:disabled){background:#4f46e5;}&:disabled{opacity:.55;cursor:not-allowed;}"]),ey=c.Ay.div.withConfig({displayName:"CreateOrgButtonModal__Backdrop",componentId:"sc-1kfinjw-1"})(["position:fixed;inset:0;background:rgba(0,0,0,.45);display:grid;place-items:center;z-index:100;"]),ev=c.Ay.div.withConfig({displayName:"CreateOrgButtonModal__Card",componentId:"sc-1kfinjw-2"})(["width:460px;max-width:90%;background:#fff;border-radius:12px;padding:24px 26px;display:flex;flex-direction:column;gap:18px;"]),ew=c.Ay.div.withConfig({displayName:"CreateOrgButtonModal__Row",componentId:"sc-1kfinjw-3"})(["display:flex;flex-direction:column;gap:4px;"]),ej=c.Ay.label.withConfig({displayName:"CreateOrgButtonModal__Label",componentId:"sc-1kfinjw-4"})(["font-size:.78rem;font-weight:600;"]),e_=c.Ay.input.withConfig({displayName:"CreateOrgButtonModal__Input",componentId:"sc-1kfinjw-5"})(["padding:7px 10px;border:1px solid #d1d5db;border-radius:8px;background:#f9fafb;&:focus{outline:none;border-color:#6366f1;box-shadow:0 0 0 1px #6366f1;}"]),eC=c.Ay.label.withConfig({displayName:"CreateOrgButtonModal__Check",componentId:"sc-1kfinjw-6"})(["display:flex;align-items:center;gap:6px;font-size:.8rem;line-height:1.3;cursor:pointer;input{accent-color:#6366f1;}"]);function ek(e){var n=e.crmProfiles,t=e.state,o=e.dispatch,c=(0,s.useState)(!1),d=c[0],l=c[1],p=(0,s.useState)(!1),f=p[0],h=p[1],x=(0,s.useState)(""),m=x[0],b=x[1],y=(0,s.useState)(""),v=y[0],w=y[1],j=(0,s.useState)(new Set),_=j[0],C=j[1],k=(0,eh.hD)(g.auth),A=(0,i.A)(k,1)[0];return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(eb,{onClick:function(){return l(!0)},children:"+ Create Organisation"}),d&&(0,W.jsx)(ey,{onClick:function(){return!f&&l(!1)},children:(0,W.jsxs)(ev,{onClick:function(e){return e.stopPropagation()},children:[(0,W.jsx)("h3",{style:{margin:0},children:"Create organisation"}),(0,W.jsxs)(ew,{children:[(0,W.jsx)(ej,{children:"Name *"}),(0,W.jsx)(e_,{value:m,onChange:function(e){return b(e.target.value)},disabled:f})]}),(0,W.jsxs)(ew,{children:[(0,W.jsx)(ej,{children:"Domain (optional)"}),(0,W.jsx)(e_,{value:v,onChange:function(e){return w(e.target.value)},disabled:f})]}),(0,W.jsxs)(ew,{children:[(0,W.jsx)(ej,{children:"Add existing contacts (optional)"}),(0,W.jsx)("div",{style:{maxHeight:140,overflowY:"auto",border:"1px solid #eee",padding:8},children:n.map(function(e){return(0,W.jsxs)(eC,{children:[(0,W.jsx)("input",{type:"checkbox",checked:_.has(e.id),onChange:function(){var n;return n=e.id,C(function(e){var t=new Set(e);return t.has(n)?t.delete(n):t.add(n),t})},disabled:f}),e.full_name,e.email?" (".concat(e.email,")"):""]},e.id)})})]}),(0,W.jsx)(eb,{onClick:function(){if(f||!m.trim()){m.trim()||u.o.error("Name is required");return}var e,n=(e=(0,r.A)(a().mark(function e(){var n,r,i,s,c;return a().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,A.getIdToken(!0);case 2:return r=e.sent,i=(null===(n=t.currentTeam)||void 0===n?void 0:n.uid)==="PERSONAL"?null:t.currentTeam.uid,e.next=6,fetch("/api/v1/crm/upsert",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(r)},body:JSON.stringify({org_name:m.trim(),org_domain:v.trim()||null,teamId:i,contact:null})}).then(function(e){return e.json()});case 6:if((s=e.sent).success){e.next=9;break}throw Error(s.error||"Failed");case 9:if(c=s.organization,!_.size){e.next=15;break}return e.next=13,Promise.all((0,N.A)(_).map(function(e){return fetch("/api/v1/crm/linkProfileToOrg",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(r)},body:JSON.stringify({profile_id:e,organization_id:c.id})}).then(function(e){return e.json()}).then(function(e){if(!e.success)throw Error(e.error);return e.organization})}));case 13:c=e.sent.at(-1)||c;case 15:o({type:"ADD_ORG",payload:c}),o({type:"PATCH_ORG",payload:c});case 17:case"end":return e.stop()}},e)})),function(){return e.apply(this,arguments)});h(!0),u.o.promise(n(),{loading:"Creating organisation…",success:function(){return h(!1),l(!1),b(""),w(""),C(new Set),"Organisation created"},error:function(e){return h(!1),e.message}})}
1,disabled:f||!m.trim(),children:f?"Saving…":"Create"})]})})]})}var eA=c.Ay.button.withConfig({displayName:"CreateContactButtonModal__Fab",componentId:"sc-1b1b5b5-0"})(["margin-top:18px;align-self:flex-start;padding:8px 14px;font-weight:600;background:#10b981;color:#fff;border:none;border-radius:8px;cursor:pointer;transition:background .18s;&:hover:not(:disabled){background:#059669;}&:disabled{opacity:.55;cursor:not-allowed;}"]),eI=c.Ay.div.withConfig({displayName:"CreateContactButtonModal__Backdrop",componentId:"sc-1b1b5b5-1"})(["position:fixed;inset:0;background:rgba(0,0,0,.45);display:grid;place-items:center;z-index:110;"]),eS=c.Ay.div.withConfig({displayName:"CreateContactButtonModal__Card",componentId:"sc-1b1b5b5-2"})(["width:420px;max-width:90%;background:#fff;border-radius:12px;padding:24px 26px;display:flex;flex-direction:column;gap:18px;"]),eN=c.Ay.div.withConfig({displayName:"CreateContactButtonModal__Row",componentId:"sc-1b1b5b5-3"})(["display:flex;flex-direction:column;gap:4px;"]),eD=c.Ay.label.withConfig({displayName:"CreateContactButtonModal__Label",componentId:"sc-1b1b5b5-4"})(["font-size:.78rem;font-weight:600;"]),eT=c.Ay.input.withConfig({displayName:"CreateContactButtonModal__Input",componentId:"sc-1b1b5b5-5"})(["padding:7px 10px;border:1px solid #d1d5db;border-radius:8px;background:#f9fafb;&:focus{outline:none;border-color:#10b981;box-shadow:0 0 0 1px #10b981;}"]),eO=c.Ay.button.withConfig({displayName:"CreateContactButtonModal__CTA",componentId:"sc-1b1b5b5-6"})(["padding:8px 18px;font-weight:600;border:none;border-radius:8px;cursor:pointer;transition:background .18s;"," &:disabled{opacity:.55;cursor:not-allowed;}"],function(e){return e.primary?"background:#10b981;color:#fff;\n       &:hover:not(:disabled){ background:#059669; }":"background:#e5e7eb;color:#111;\n       &:hover:not(:disabled){ background:#d1d5db; }"});function ez(e){var n=e.state,t=e.dispatch,o=(0,s.useState)(!1),c=o[0],d=o[1],l=(0,s.useState)(!1),p=l[0],f=l[1],h=(0,s.useState)(""),x=h[0],m=h[1],b=(0,s.useState)(""),y=b[0],v=b[1],w=(0,s.useState)(""),j=w[0],_=w[1],C=(0,eh.hD)(g.auth),k=(0,i.A)(C,1)[0],A=function(){m(""),v(""),_("")},I=x.trim()&&y.includes("@");return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(eA,{onClick:function(){return d(!0)},children:"+ Create Contact"}),c&&(0,W.jsx)(eI,{onClick:function(){return!p&&d(!1)},children:(0,W.jsxs)(eS,{onClick:function(e){return e.stopPropagation()},children:[(0,W.jsx)("h3",{style:{margin:0},children:"Create contact"}),(0,W.jsxs)(eN,{children:[(0,W.jsx)(eD,{children:"Full name *"}),(0,W.jsx)(eT,{value:x,onChange:function(e){return m(e.target.value)},disabled:p})]}),(0,W.jsxs)(eN,{children:[(0,W.jsx)(eD,{children:"E-mail *"}),(0,W.jsx)(eT,{type:"email",value:y,onChange:function(e){return v(e.target.value)},disabled:p})]}),(0,W.jsxs)(eN,{children:[(0,W.jsx)(eD,{children:"Phone (optional)"}),(0,W.jsx)(eT,{value:j,onChange:function(e){return _(e.target.value)},disabled:p})]}),(0,W.jsxs)(eN,{style:{flexDirection:"row",justifyContent:"flex-end"},children:[(0,W.jsx)(eO,{onClick:function(){return d(!1)},disabled:p,children:"Cancel"}),(0,W.jsx)(eO,{primary:!0,onClick:function(){if(!p){var e,i=(e=(0,r.A)(a().mark(function e(){var r,i,o,s;return a().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,k.getIdToken(!0);case 2:return i=e.sent,o=(null===(r=n.currentTeam)||void 0===r?void 0:r.uid)==="PERSONAL"?null:n.currentTeam.uid,e.next=6,fetch("/api/v1/crm/createProfile",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(i)},body:JSON.stringify({teamId:o,full_name:x.trim(),email:y.trim().toLowerCase(),phone:j.trim()||null})}).then(function(e){return e.json()});case 6:if(!(!(s=e.sent).success||!s.profile)){e.next=9;break}throw Error(s.error||"Failed");case 9:t({type:"ADD_CRM",payload:s.profile});case 10:case"end":return e.stop()}},e)})),function(){return e.apply(this,arguments)});f(!0),u.o.promise(i(),{loading:"Creating contact…",success:function(){return f(!1),d(!1),A(),"Contact created"},error:function(e){return f(!1),e.message}})}},disabled:!I||p,children:p?"Saving…":"Create"})]})]})})]})}function eP(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),t.push.apply(t,r)}return t}var eM=c.Ay.div.withConfig({displayName:"CreateDealButtonModal__Backdrop",componentId:"sc-1p5vyzg-0"})(["position:fixed;inset:0;display:grid;place-items:center;background:rgba(0,0,0,0.35);z-index:60;"]),eE=c.Ay.div.withConfig({displayName:"CreateDealButtonModal__Panel",componentId:"sc-1p5vyzg-1"})(["width:420px;max-width:90%;background:#fff;border-radius:12px;padding:28px 34px;display:flex;flex-direction:column;gap:18px;"]),eL=c.Ay.h3.withConfig({displayName:"CreateDealButtonModal__H3",componentId:"sc-1p5vyzg-2"})(["margin:0;font-size:1.25rem;font-weight:700;"]),eB=c.Ay.input.withConfig({displayName:"CreateDealButtonModal__Input",componentId:"sc-1p5vyzg-3"})(['padding:8px 10px;border:1px solid #d1d5db;border-radius:6px;&[type="number"]{width:160px;}']),eR=c.Ay.div.withConfig({displayName:"CreateDealButtonModal__Footer",componentId:"sc-1p5vyzg-4"})(["display:flex;justify-content:flex-end;
1gap:12px;"]),eH=c.Ay.button.withConfig({displayName:"CreateDealButtonModal__Btn",componentId:"sc-1p5vyzg-5"})(["padding:8px 18px;font-weight:600;border:none;border-radius:6px;cursor:pointer;transition:background 0.18s;"," &:disabled{opacity:0.55;cursor:not-allowed;}"],function(e){return e.primary?(0,c.AH)(["background:#6366f1;color:#fff;&:hover:not(:disabled){background:#4f46e5;}"]):(0,c.AH)(["background:#e5e7eb;color:#111827;&:hover:not(:disabled){background:#d1d5db;}"])}),e$=c.Ay.input.withConfig({displayName:"CreateDealButtonModal__Search",componentId:"sc-1p5vyzg-6"})(["padding:7px 10px;border:1px solid #d1d5db;border-radius:6px;width:100%;&:focus{outline:none;border-color:#6366f1;box-shadow:0 0 0 1px #6366f1;}"]),eW=c.Ay.div.withConfig({displayName:"CreateDealButtonModal__ListBox",componentId:"sc-1p5vyzg-7"})(["max-height:160px;overflow-y:auto;border:1px solid #e5e7eb;border-radius:6px;padding:6px;display:flex;flex-direction:column;gap:6px;"]),eF=c.Ay.label.withConfig({displayName:"CreateDealButtonModal__Row",componentId:"sc-1p5vyzg-8"})(["display:flex;align-items:center;gap:8px;font-size:0.85rem;cursor:pointer;input{accent-color:#6366f1;}span{line-height:1.25;}"]);function eV(e){var n,t,i=e.orgId,o=e.children,c=(0,s.useState)(!1),p=c[0],f=c[1],x=(0,s.useState)(""),g=x[0],m=x[1],b=(0,s.useState)(""),y=b[0],v=b[1],w=(0,s.useState)(new Set),j=w[0],_=w[1],C=(0,s.use
1State)(""),k=C[0],A=C[1],I=(0,s.useState)(!1),D=I[0],T=I[1],O=(0,d.mc)(),z=O.state,P=O.dispatch,M=(0,l.y)().getAvatar,E=(0,s.useMemo)(function(){if(!i)return[];var e=z.orgProfiles.find(function(e){return e.id===i});return z.crmProfiles.filter(function(n){var t;return null==e||null===(t=e.member_ids)||void 0===t?void 0:t.includes(n.id)})},[z.crmProfiles,z.orgProfiles,i]),L=(0,s.useMemo)(function(){if(!k.trim())return E;var e=k.toLowerCase();return E.filter(function(n){return n.full_name.toLowerCase().includes(e)||(n.email||"").toLowerCase().includes(e)})},[E,k]),B=(0,s.useCallback)((n=(0,r.A)(a().mark(function e(n){var t;return a().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n.preventDefault(),!D){e.next=3;break}return e.abrupt("return");case 3:if(g.trim()){e.next=5;break}return e.abrupt("return",u.o.error("Title is required"));case 5:if(0!==j.size){e.next=7;break}return e.abrupt("return",u.o.error("Select at least one participant"));case 7:t=function(){var e=(0,r.A)(a().mark(function e(){var n,t,r,o,s;return a().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(n=(0,h.xI)().currentUser)||void 0===n?void 0:n.getIdToken(!0);case 2:return r=e.sent,e.next=5,fetch("/api/v1/crm/createDeal",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(r)},body:JSON.stringify({teamId:(null===(t=z.currentTeam)||void 0===t?void 0:t.uid)==="PERSONAL"?null:z.currentTeam.uid,org_id:i,member_ids:(0,N.A)(j),title:g,value_usd:y?+y:null})});case 5:return o=e.sent,e.next=8,o.json();case 8:if((s=e.sent).success){e.next=11;break}throw Error(s.error||"Failed");case 11:P({type:"ADD_DEAL",payload:s.deal}),f(!1),m(""),v(""),_(new Set),A("");case 17:case"end":return e.stop()}},e)}));return function(){return e.apply(this,arguments)}}(),T(!0),u.o.promise(t(),{loading:"Creating deal…",success:function(){return T(!1),"Deal created"},error:function(e){return T(!1),e.message}});case 10:case"end":return e.stop()}},e)})),function(e){return n.apply(this,arguments)}),[D,g,y,j,null===(t=z.currentTeam)||void 0===t?void 0:t.uid,i,P]);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)("span",{style:{cursor:"pointer"},onClick:function(){return f(!0)},children:o}),p&&(0,W.jsx)(eM,{onClick:function(){return!D&&f(!1)},children:(0,W.jsxs)(eE,{onClick:function(e){return e.stopPropagation()},children:[(0,W.jsx)(eL,{children:"New deal"}),(0,W.jsx)(eB,{placeholder:"Deal title",value:g,onChange:function(e){return m(e.target.value)}}),(0,W.jsx)(eB,{type:"number",placeholder:"Value USD",value:y,onChange:function(e){return v(e.target.value)}}),(0,W.jsxs)("div",{children:[(0,W.jsx)(e$,{placeholder:"Search participants…",value:k,onChange:function(e){return A(e.target.value)},disabled:D}),(0,W.jsxs)(eW,{children:[L.map(function(e){var n;return(0,W.jsxs)(eF,{children:[(0,W.jsx)("input",{type:"checkbox",checked:j.has(e.id),onChange:function(){var n;return n=e.id,_(function(e){var t=new Set(e);return t.has(n)?t.delete(n):t.add(n),t})},disabled:D}),(0,W.jsx)($.A,function(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?eP(Object(t),!0).forEach(function(n){(0,S.A)(e,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):eP(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}({style:{width:26,height:26},shape:"circle"},M((null===(n=e.visitor_ids)||void 0===n?void 0:n[0])||e.id,e.full_name||""))),(0,W.jsxs)("span",{children:[(0,W.jsx)("b",{children:e.full_name}),(0,W.jsx)("br",{}),e.email||"—"]})]},e.id)}),0===L.length&&(0,W.jsx)("span",{style:{fontSize:12,color:"#6b7280"},children:"No matches"})]})]}),(0,W.jsxs)(eR,{children:[(0,W.jsx)(eH,{onClick:function(){return f(!1)},disabled:D,children:"Cancel"}),(0,W.jsx)(eH,{primary:!0,onClick:B,disabled:D||!g.trim()||0===j.size,children:D?"Saving…":"Save"})]})]})})]})}var eU=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,eG=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return e.startsWith("v-")?e.slice(2):e},eq=!1;function eY(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),t.push.apply(t,r)}return t}var eJ=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return e.split(/\s+/).slice(0,2).map(function(e){return e[0]||""}).join("").toUpperCase()},eQ=c.Ay.div.withConfig({displayName:"AddMemberButtonModal__PlusBtn",componentId:"sc-1rdbus5-0"})(["width:24px;height:24px;display:grid;place-items:center;margin-left:6px;align-self:center;border:1.6px dashed #a5b4fc;border-radius:50%;background:#eef2ff;color:#6366f1;font-size:18px;font-weight:700;line-height:0;cursor:",";opacity:",";transition:all 0.18s ease;",""],function(e){return e.disabled?"not-allowed":"pointer"},function(e){return e.disabled?.35:1},function(e){return!e.disabled&&(0,c.AH)(["&:hover,&:focus-visible{background:#6366f1;color:#fff;transform:scale(1.15);box-shadow:0 0 0 2px #e0e7ff inset;}"])}),eK=c.Ay.div.withConfig({displayName:"AddMemberButtonModal__Backdrop",componentId:"sc-1rdbus5-1"})(["position:fixed;inset:0;display:grid;place-items:center;background:rgba(0,0,0,0.45);z-index:60;"]),eX=(0,c.i7)(["from{opacity:0;transform:scale(.9) translateY(8px);}to{opacity:1;transform:scale(1) translateY(0);}"]),eZ=c.Ay.div.withConfig({displayName:"AddMemberButtonModal__Panel",componentId:"sc-1rdbus5-2"})(["width:420px;max-width:90%;background:#fff;border-radius:14px;padding:26px 32px;display:flex;flex-direction:column;gap:18px;animation:"," 0.24s ease-out;"],eX),e0=c.Ay.h3.withConfig({displayName:"AddMemberButtonModal__H3",componentId:"sc-1rdbus5-3"})(["margin:0;font-size:1.05rem;font-weight:700;display:flex;gap:6px;align-items:center;span{font-size:1.3rem;}"]),e1=c.Ay.input.withConfig({displayName:"AddMemberButtonModal__SearchInput",componentId:"sc-1rdbus5-4"})(["padding:8px 10px;border:1px solid #d1d5db;border-radius:8px;&:focus{outline:none;border-color:#6366f1;box-shadow:0 0 0 1px #6366f1;}"]),e6=c.Ay.div.withConfig({displayName:"AddMemberButtonModal__List",componentId:"sc-1rdbus5-5"})(["max-height:220px;overflow-y:auto;border:1px solid #e5e7eb;border-radius:8px;"]),e2=c.Ay.div.withConfig({displayName:"AddMemberButtonModal__Row",componentId:"sc-1rdbus5-6"})(["display:flex;gap:10px;align-items:center;padding:8px 10px;cursor:pointer;background:",";&:hover{background:",";}"],function(e){return e.active?"#eef2ff":"#fff"},function(e){return e.active?"#e0e7ff":"#f9fafb"}),e5=c.Ay.div.withConfig({displayName:"AddMemberButtonModal__Info",componentId:"sc-1rdbus5-7"})(["flex:1 1 auto;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;b{display:block;font-weight:600;}small{color:#6b7280;font-size:0.75rem;}"]),e8=c.Ay.div.withConfig({displayName:"AddMemberButtonModal__BtnRow",componentId:"sc-1rdbus5-8"})(["display:flex;justify-content:flex-end;
1gap:12px;"]),e3=c.Ay.button.withConfig({displayName:"AddMemberButtonModal__Btn",componentId:"sc-1rdbus5-9"})(["padding:8px 20px;font-weight:600;border:none;border-radius:8px;cursor:pointer;transition:background 0.18s;"," &:disabled{opacity:0.55;cursor:not-allowed;}"],function(e){return e.primary?(0,c.AH)(["background:#6366f1;color:#fff;&:hover:not(:disabled){background:#4f46e5;}"]):(0,c.AH)(["background:#e5e7eb;color:#111827;&:hover:not(:disabled){background:#d1d5db;}"])}),e4=c.Ay.div.withConfig({displayName:"AddMemberButtonModal__Pfp",componentId:"sc-1rdbus5-10"})(["flex:0 0 30px;height:30px;border-radius:50%;background:#c7d2fe;color:#4338ca;font-size:0.8rem;font-weight:700;display:grid;place-items:center;"]);function e7(e){var n=e.org,t=e.allContacts,o=e.dispatch,c=(0,s.useState)(!1),d=c[0],p=c[1],f=(0,s.useState)(new Set),h=f[0],x=f[1],m=(0,s.useState)(!1),b=m[0],y=m[1],v=(0,s.useState)(""),w=v[0],j=v[1],_=(0,eh.hD)(g.auth),C=(0,i.A)(_,1)[0],k=(0,l.y)().getAvatar,A=(0,s.useMemo)(function(){return t.filter(function(e){return!(n.member_ids||[]).includes(e.id)})},[t,n.member_ids]),I=(0,s.useMemo)(function(){var e=w.trim().toLowerCase();return e?A.filter(function(n){return"".concat(n.full_name," ").concat(n.email||"").toLowerCase().includes(e)}):A},[A,w]),D=0===A.length;return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(eQ,{title:D?"All contacts are already members":"Add member(s)",disabled:D,onClick:function(){return!D&&p(!0)},children:"+"}),d&&(0,W.jsx)(eK,{onClick:function(){return!b&&p(!1)},children:(0,W.jsxs)(eZ,{onClick:function(e){return e.stopPropagation()},children:[(0,W.jsxs)(e0,{children:[(0,W.jsx)("span",{children:"\uD83C\uDFE2"})," Add to\xa0",(0,W.jsx)("strong",{children:n.name})]}),(0,W.jsx)(e1,{placeholder:"Search contacts…",value:w,onChange:function(e){return j(e.target.value)},disabled:b}),(0,W.jsxs)(e6,{children:[0===I.length&&(0,W.jsx)("div",{style:{padding:10,color:"#6b7280"},children:"No matches."}),I.map(function(e){var n,t=h.has(e.id),r=k?k((null===(n=e.visitor_ids)||void 0===n?void 0:n[0])||e.id,e.full_name||""):null;return(0,W.jsxs)(e2,{active:t,onClick:function(){var n;return!b&&(n=e.id,x(function(e){var t=new Set(e);return t.has(n)?t.delete(n):t.add(n),t}))},children:[r?(0,W.jsx)($.A,function(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?eY(Object(t),!0).forEach(function(n){(0,S.A)(e,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):eY(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}({style:{width:30,height:30},shape:"circle"},r)):(0,W.jsx)(e4,{children:eJ(e.full_name)}),(0,W.jsxs)(e5,{children:[(0,W.jsx)("b",{children:e.full_name}),(0,W.jsx)("small",{children:e.email||"—"})]})]},e.id)})]}),(0,W.jsxs)(e8,{children:[(0,W.jsx)(e3,{onClick:function(){return p(!1)},disabled:b,children:"Cancel"}),(0,W.jsx)(e3,{primary:!0,onClick:function(){if(!b&&0!==h.size){var e,t=(e=(0,r.A)(a().mark(function e(){var t;return a().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,C.getIdToken(!0);case 2:return t=e.sent,e.next=5,Promise.all((0,N.A)(h).map(function(e){return fetch("/api/v1/crm/linkProfileToOrg",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(t)},body:JSON.stringify({profile_id:e,organization_id:n.id})}).then(function(e){return e.json()}).then(function(e){if(!e.success)throw Error(e.error);return e.organization})}));case 5:o({type:"PATCH_ORG",payload:e.sent.at(-1)});case 7:case"end":return e.stop()}},e)})),function(){return e.apply(this,arguments)});y(!0),u.o.promise(t(),{loading:"Linking contact…",success:function(){return y(!1),p(!1),x(new Set),j(""),"Contact linked"},error:function(e){return y(!1),e.message}})}},disabled:b||0===h.size,children:"Save"})]})]})})]})}function e9(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),t.push.apply(t,r)}return t}function ne(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};
1n%2?e9(Object(t),!0).forEach(function(n){(0,S.A)(e,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):e9(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}var nn={Lead:{bg:"#fed7aa",txt:"#7c2d12"},Prospect:{bg:"#fecaca",txt:"#7f1d1d"},Client:{bg:"#bfdbfe",txt:"#1e3a8a"},Partner:{bg:"#d1d5db",txt:"#111827"}},nt={New:{bg:"#e5e7eb",txt:"#374151"},Qualified:{bg:"#bfdbfe",txt:"#1e3a8a"},Proposal:{bg:"#fde68a",txt:"#78350f"},Won:{bg:"#bbf7d0",txt:"#065f46"},Lost:{bg:"#fecaca",txt:"#7f1d1d"}},nr=Object.entries(nn).map(function(e){var n=(0,i.A)(e,2),t=n[0];return ne({value:t,label:t},n[1])}),ni={control:function(e){return ne(ne({},e),{},{border:"none",background:"transparent",minHeight:"auto",padding:0,boxShadow:"none",cursor:"pointer"})},valueContainer:function(e){return ne(ne({},e),{},{padding:0})},indicatorsContainer:function(){return{display:"none"}},singleValue:function(e,n){var t=n.data;return ne(ne({},e),{},{background:t.bg,color:t.txt,fontWeight:600,borderRadius:9999,padding:"2px 10px"})},option:function(e,n){var t=n.data,r=n.isFocused;return ne(ne({},e),{},{background:r?t.bg:"#fff",color:t.txt,fontWeight:600})},menu:function(e){return ne(ne({},e),{},{zIndex:30,minWidth:110})}},no=c.Ay.div.withConfig({displayName:"ClientsTab__Wrap",componentId:"sc-1rhch52-0"})(["display:flex;flex-direction:column;height:100%;padding:20px 24px 40px;background:#fafafa;overflow:hidden;"]),na=c.Ay.div.withConfig({displayName:"ClientsTab__Toolbar",componentId:"sc-1rhch52-1"})(["display:flex;flex-wrap:wrap;gap:12px;align-items:center;margin-bottom:16px;"]),ns=c.Ay.input.withConfig({displayName:"ClientsTab__SearchBox",componentId:"sc-1rhch52-2"})(["width:240px;padding:7px 10px;background:#fff;border:1px solid #d1d5db;border-radius:8px;&:focus{outline:none;border-color:#6366f1;box-shadow:0 0 0 1px #6366f1;}"]),nc=c.Ay.select.withConfig({displayName:"ClientsTab__PlainSelect",componentId:"sc-1rhch52-3"})(["padding:7px 38px 7px 10px;background:#fff url(\"data:image/svg+xml,%3Csvg width='16' height='16' fill='%236b7280' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 6l4 4 4-4z'/%3E%3C/svg%3E\") no-repeat right 12px center/14px;border:1px solid #d1d5db;border-radius:8px;"]),nd=c.Ay.button.withConfig({displayName:"ClientsTab__ViewSwitch",componentId:"sc-1rhch52-4"})(["all:unset;cursor:pointer;padding:6px 12px;border-radius:6px;font-weight:600;font-size:0.82rem;background:",";color:",";"],function(e){return e.active?"#6366f1":"#e5e7eb"},function(e){return e.active?"#fff":"#111"}),nl="180px 80px 1fr     220px  120px  240px",nu="60px 1fr 190px 90px",np=c.Ay.div.withConfig({displayName:"ClientsTab__Sheet",componentId:"sc-1rhch52-5"})(["flex:1;overflow:auto;background:#fff;border:1px solid #e5e7eb;border-radius:8px;"]),nf=c.Ay.div.withConfig({displayName:"ClientsTab__HeaderRow",componentId:"sc-1rhch52-6"})(["display:grid;grid-template-columns:",";background:#f97316;color:#fff;font-weight:700;font-size:0.82rem;letter-spacing:0.02em;position:sticky;top:0;z-index:5;"],function(e){return e.cols}),nh=c.Ay.div.withConfig({displayName:"ClientsTab__Row",componentId:"sc-1rhch52-7"})(["display:grid;grid-template-columns:",";font-size:0.85rem;&:nth-child(even){background:#f9fafb;}&:hover{background:#f0f9ff;}"],function(e){return e.cols}),nx=c.Ay.div.withConfig({displayName:"ClientsTab__Cell",componentId:"sc-1rhch52-8"})(["padding:6px 10px;border-bottom:1px solid #f3f4f6;display:flex;align-items:flex-start;gap:6px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;"]),ng=c.Ay.button.withConfig({displayName:"ClientsTab__OrgBtn",componentId:"sc-1rhch52-9"})(["all:unset;cursor:pointer;display:flex;flex-direction:column;gap:2px;&:hover b{text-decoration:underline;}small{color:#6b7280;font-size:0.72rem;}"]),nm=c.Ay.div.withConfig({displayName:"ClientsTab__MembersBox",componentId:"sc-1rhch52-10"})(["max-height:350px;overflow-y:auto;display:flex;flex-direction:column;gap:6px;height:100%;"]),nb=c.Ay.div.withConfig({displayName:"ClientsTab__MemberLine",componentId:"sc-1rhch52-11"})(["display:flex;gap:8px;font-size:0.8rem;line-height:1.25;white-space:normal;margin-top:4px;margin-bottom:-2px;"]),ny=c.Ay.div.withConfig({displayName:"ClientsTab__ActStack",componentId:"sc-1rhch52-12"})(["display:flex;flex-wrap:wrap;gap:6px;"]),nv=c.Ay.button.withConfig({displayName:"ClientsTab__ActBtn",componentId:"sc-1rhch52-13"})(["padding:6px 10px;font-size:0.78rem;border:1px solid #d1d5db;border-radius:6px;background:#fff;cursor:pointer;transition:background .15s;&:hover{background:#f3f4f6;}"]),nw=c.Ay.div.withConfig({displayName:"ClientsTab__Empty",componentId:"sc-1rhch52-14"})(["padding:80px 12px;text-align:center;color:#6b7280;"]),nj=c.Ay.button.withConfig({displayName:"ClientsTab__DealLine",componentId:"sc-1rhch52-15"})(["all:unset;display:block;width:100%;cursor:pointer;margin-bottom:0px;padding:6px 8px;border:1px solid #e5e7eb;border-radius:6px;background:#fff;&:hover{background:#f3f4f6;}h6{margin:0;font-size:0.78rem;font-weight:600;display:flex;justify-content:space-between;gap:6px;}span{font-size:0.7rem;color:#6b7280;}"]),n_=c.Ay.span.withConfig({displayName:"ClientsTab__Pill",componentId:"sc-1rhch52-16"})(["padding:1px 8px;border-radius:9999px;font-size:0.65rem;font-weight:600;background:",";color:",";"],function(e){return e.bg},function(e){return e.txt});function nC(){var e,n,t,o,c,p,f,x,m,b,y,v,w=(0,d.mc)(),j=w.state,_=w.dispatch,C=w.setActiveDealId,k=w.can,A=(0,l.y)(),I=A.getAvatar,S=A.avatarMap,N=A.events,D=A.loading,O=null!==(x=j.orgProfiles)&&void 0!==x?x:[],z=null!==(m=j.crmProfiles)&&void 0!==m?m:[],P=null!==(b=j.dealProfiles)&&void 0!==b?b:[],M=em(null===(y=j.currentTeam)||void 0===y?void 0:y.uid,k,"clients"),E=em(null===(v=j.currentTeam)||void 0===v?void 0:v.uid,k,"deals"),L=(0,eh.hD)(g.auth),B=(0,i.A)(L,1)[0],R=(0,s.use
1State)("org"),H=R[0],F=R[1],V=(0,s.useState)(""),U=V[0],G=V[1],q=(0,s.useState)(""),Y=q[0],J=q[1],Q=(0,s.useState)(0)[1],K=(0,s.useState)(null),X=K[0],Z=K[1];e=j.loading||D?[]:z,n=j.loading||D?[]:N,t=(0,s.useRef)(!0),(0,s.useEffect)(function(){return function(){t.current=!1}},[]),(0,s.useEffect)(function(){if(e.length&&n.length&&!eq){var i=new Map(e.filter(function(e){return e.email}).map(function(e){return[e.email.toLowerCase(),e]})),o=new Map;n.forEach(function(e){var n,t=null===(n=e.custom_data)||void 0===n?void 0:n.email;if(t&&e.visitor_id){var r=eG(e.visitor_id);eU.test(r)&&o.set(t.toLowerCase(),r)}});var s=[];o.forEach(function(e,n){var t,r=i.get(n);r&&!(null!==(t=r.visitor_ids)&&void 0!==t&&t.includes(e))&&s.push({crmId:r.id,vid:e})}),0!==s.length&&(eq=!0,u.o.promise((0,r.A)(a().mark(function e(){var n,t,r,i;return a().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(n=(0,h.xI)().currentUser)||void 0===n?void 0:n.getIdToken(!0);case 2:return t=e.sent,e.next=5,fetch("/api/v1/crm/appendVisitorIds",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(t)},body:JSON.stringify({pairs:s})});case 5:return r=e.sent,e.next=8,r.json();case 8:if((i=e.sent).success){e.next=11;break}throw Error(i.error||"API error");case 11:return e.abrupt("return",i.updated||0);case 12:case"end":return e.stop()}},e)}))(),{loading:"Syncing ".concat(s.length," visitor-id").concat(s.length>1?"s":"","…"),success:function(e){return 0===e?"Already up-to-date":"Linked ".concat(e," new visitor-id").concat(e>1?"s":"")},error:function(e){return"Sync failed – ".concat(e.message)}}).finally(function(){eq=!1,t.current||(eq=!1)}))}},[e,n]);var ee=(0,s.useMemo)(function(){return O.filter(function(e){return!Y||e.status===Y}).filter(function(e){return!U.trim()||"".concat(e.name," ").concat(e.domain||"").toLowerCase().includes(U.toLowerCase())}).map(function(e){var n=z.filter(function(n){var t;return null===(t=e.member_ids)||void 0===t?void 0:t.includes(n.id)}),t=P.filter(function(n){return n.org_id===e.id});return{org:e,members:n,deals:t}})},[O,z,P,U,Y]),en=(0,s.useMemo)(function(){return z.filter(function(e){return!Y||e.status===Y}).filter(function(e){return!U.trim()||U.toLowerCase().split(/\s+/).every(function(n){return"".concat(e.full_name," ").concat(e.email||""," ").concat(e.phone||"").toLowerCase().includes(n)})})},[z,U,Y]),et=(0,s.useCallback)((o=(0,r.A)(a().mark(function e(n,t){var i;return a().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!(!t||n.status===t.value)){e.next=2;break}return e.abrupt("return");case 2:i=n.status,n.status=t.value,Q(function(e){return e+1}),u.o.promise((0,r.A)(a().mark(function e(){var r,i,o;return a().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,B.getIdToken(!0);case 2:return r=e.sent,e.next=5,fetch("/api/v1/crm/updateStatus",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(r)},body:JSON.stringify({organization_id:n.id,status:t.value})});case 5:return i=e.sent,e.next=8,i.json();case 8:if((o=e.sent).success){e.next=11;break}throw Error(o.error);case 11:_({type:"PATCH_ORG",payload:o.row});case 12:case"end":return e.stop()}},e)}))(),{loading:"Saving…",success:"Status updated",error:function(e){return n.status=i,Q(function(e){return e+1}),e.message}});case 6:case"end":return e.stop()}},e)})),function(e,n){return o.apply(this,arguments)}),[B,_]),er=(0,s.useCallback)((c=(0,r.A)(a().mark(function e(n){var t;return a().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(eg(null===(t=j.currentTeam)||void 0===t?void 0:t.uid,k,"clients")){e.next=3;break}return u.o.error("You don’t have permission to delete organisations"),e.abrupt("return");case 3:if(confirm("Delete “".concat(n.name,"”?"))){e.next=5;break}return e.abrupt("return");case 5:u.o.promise((0,r.A)(a().mark(function e(){var t,r,i;return a().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,B.getIdToken(!0);case 2:return t=e.sent,e.next=5,fetch("/api/v1/crm/deleteOrganization",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(t)},body:JSON.stringify({organization_id:n.id})});case 5:return r=e.sent,e.next=8,r.json();case 8:if((i=e.sent).success){e.next=11;break}throw Error(i.error);case 11:_({type:"SET_DATA",payload:ne(ne({},j),{},{orgProfiles:j.orgProfiles.filter(function(e){return e.id!==n.id})})});case 12:case"end":return e.stop()}},e)}))(),{loading:"Deleting…",success:"Organisation removed",error:function(e){return e.message}});case 6:case"end":return e.stop()}},e)})),function(e){return c.apply(this,arguments)}),[B,j,_]),ei=(0,s.useCallback)((p=(0,r.A)(a().mark(function e(n){var t;return a().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(eg(null===(t=j.currentTeam)||void 0===t?void 0:t.uid,k,"clients")){e.next=3;break}return u.o.error("You don’t have permission to delete clients"),e.abrupt("return");case 3:if(confirm("Delete CRM profile “".concat(n.full_name,"”?"))){e.next=5;break}return e.abrupt("return");case 5:u.o.promise((0,r.A)(a().mark(function e(){var t,r,i;return a().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,B.getIdToken(!0);case 2:return t=e.sent,e.next=5,fetch("/api/v1/crm/deleteProfile",{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(t)},body:JSON.stringify({ids:[n.id]})});case 5:return r=e.sent,e.next=8,r.json();case 8:if((i=e.sent).success){e.next=11;break}throw Error(i.error);case 11:_({type:"SET_DATA",payload:ne(ne({},j),{},{crmProfiles:j.crmProfiles.filter(function(e){return e.id!==n.id})})});case 12:case"end":return e.stop()}},e)}))(),{loading:"Deleting…",success:"Profile removed",error:function(e){return e.message}});case 6:case"end":return e.stop()}},e)})),function(e){return p.apply(this,arguments)}),[B,j,_]),eo=(0,s.useCallback)((f=(0,r.A)(a().mark(function e(n,t){return a().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!((n.member_ids||[]).length<=1)){e.next=2;break}return e.abrupt("return");case 2:if(confirm("Remove this member from the organisation?")){e.next=4;break}return e.abrupt("return");case 4:u.o.promise((0,r.A)(a().mark(function e(){var r,i,o;return a().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,B.getIdToken(!0);case 2:return r=e.sent,e.next=5,fetch("/api/v1/crm/unlinkProfileFromOrg",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(r)},body:JSON.stringify({profile_id:t,organization_id:n.id})});case 5:return i=e.sent,e.next=8,i.json();case 8:if((o=e.sent).success){e.next=11;break}throw Error(o.error);case 11:_({type:"PATCH_ORG",payload:o.organization});case 12:case"end":return e.stop()}},e)}))(),{loading:"Removing…",success:"Member removed",error:function(e){return e.message}});case 5:case"end":return e.stop()}},e)})),function(e,n){return f.apply(this,arguments)}),[B,_]);return(0,W.jsxs)(no,{children:[(0,W.jsxs)(na,{children:[(0,W.jsx)(nd,{active:"org"===H,onClick:function(){return F("org")},children:"Organisations"}),(0,W.jsx)(nd,{active:"crm"===H,onClick:function(){return F("crm")},children:"Contacts"}),(0,W.jsx)(ns,{placeholder:"Search…",value:U,onChange:function(e){return G(e.target.value)}}),(0,W.jsxs)(nc,{value:Y,onChange:function(e){return J(e.target.value)},children:[(0,W.jsx)("option",{value:"",children:"All status"}),Object.keys(nn).map(function(e){return(0,W.jsx)("option",{children:e},e)})]})]}),"org"===H?0===ee.length?(0,W.jsx)(nw,{children:"No matching organisations."}):(0,W.jsxs)(np,{children:[(0,W.jsxs)(nf,{cols:nl,children:[(0,W.jsx)(nx,{children:"Organisation"}),(0,W.jsx)(nx,{children:"Info"}),(0,W.jsx)(nx,{children:"Members"}),(0,W.jsx)(nx,{children:"Deals"}),(0,W.jsx)(nx,{children:"Status"}),(0,W.jsx)(nx,{children:"Actions"})]}),ee.map(function(e){var n,t,r=e.org,i=e.members,o=e.deals;return(0,W.jsxs)(nh,{cols:nl,children:[(0,W.jsx)(nx,{children:(0,W.jsxs)(ng,{children:[(0,W.jsxs)("b",{children:["\uD83C\uDFE2 ",r.name]}),(0,W.jsx)("small",{children:r.domain||"—"})]})}),(0,W.jsx)(nx,{style:{justifyContent:"center"},children:(0,W.jsx)(nv,{onClick:function(){return Z(r)},children:"✏️ Info"})}),(0,W.jsxs)(nx,{style:{padding:0},children:[(0,W.jsx)(nm,{children:i.map(function(e){var n=e.visitor_ids||e.visitorIds||[],t=n.find(function(e){return S[e]})||n[0]||e.visitorId||null,o=i.length>1;return(0,W.jsxs)(nb,{children:[(0,W.jsx)($.A,ne({style:{width:26,height:26},shape:"circle"},I(t||e.id,e.full_name))),(0,W.jsxs)("div",{style:{minWidth:0,overflow:"hidden"},children:[(0,W.jsx)("b",{children:e.full_name}),(0,W.jsx)("br",{}),e.email||"—"]}),o&&(0,W.jsx)(nO,{title:"Remove from organisation",onClick:function(){return eo(r,e.id)},children:"\xd7"})]},e.id)})}),(0,W.jsx)(e7,{org:r,allContacts:z,dispatch:_})]}),(0,W.jsxs)(nx,{style:{flexDirection:"column"},children:[0===o.length&&"—",o.slice(0,3).map(function(e){return(0,W.jsxs)(nj,{onClick:function(){_({type:"SET_DEAL_FILTER",payload:{orgId:r.id,dealId:e.id}}),C(e.id);var n=document.querySelector('[data-tab="3"]');null==n||n.click()},children:[(0,W.jsxs)("h6",{children:[e.title,(0,W.jsx)(n_,ne(ne({},nt[e.stage||"New"]),{},{children:e.stage||"New"}))]}),(0,W.jsxs)("span",{children:[null!=e.value_usd?"$".concat((+e.value_usd).toLocaleStr
1ing()):"—"," \xb7"," ",T()(e.created_at).format("D MMM YY")]})]},e.id)}),o.length>3&&(0,W.jsxs)("span",{style:{fontSize:11,color:"#6b7280"},children:["+",o.length-3," more"]})]}),(0,W.jsx)(nx,{children:(0,W.jsx)(ef.Ay,{instanceId:"org-".concat(r.id),options:nr,value:nr.find(function(e){return e.value===r.status}),onChange:function(e){return et(r,e)},styles:ni,menuPortalTarget:document.body})}),(0,W.jsx)(nx,{children:(0,W.jsxs)(ny,{children:[E?(0,W.jsx)(eV,{orgId:r.id,children:(0,W.jsx)(nv,{children:"Create Deal"})}):(0,W.jsx)(nv,{style:{opacity:.45,cursor:"not-allowed"},disabled:!0,children:"Deal\xa0+ (no perm)"}),(0,W.jsx)(nv,{onClick:function(){_({type:"SET_DEAL_FILTER",payload:{orgId:r.id}}),C(null);var e=document.querySelector('[data-tab="3"]');null==e||e.click()},children:"View Deals"}),(0,W.jsx)(nv,{style:{color:"#b91c1c",borderColor:"#fca5a5",opacity:eg(null===(n=j.currentTeam)||void 0===n?void 0:n.uid,k,"clients")?1:.45},disabled:!eg(null===(t=j.currentTeam)||void 0===t?void 0:t.uid,k,"clients"),onClick:function(){return er(r)},children:"Delete Org"})]})})]},r.id)})]}):0===en.length?(0,W.jsx)(nw,{children:"No matching contacts."}):(0,W.jsxs)(np,{children:[(0,W.jsxs)(nf,{cols:nu,children:[(0,W.jsx)(nx,{}),(0,W.jsx)(nx,{children:"Name & Info"}),(0,W.jsx)(nx,{children:"Created"}),(0,W.jsx)(nx,{children:"Actions"})]}),en.map(function(e){var n,t,r=e.visitor_ids||e.visitorIds||[],i=r.find(function(e){return S[e]})||r[0]||e.visitorId||null;return(0,W.jsxs)(nh,{cols:nu,children:[(0,W.jsx)(nx,{children:(0,W.jsx)($.A,ne({style:{width:38,height:38},shape:"circle"},I(i||e.id,e.full_name)))}),(0,W.jsxs)(nx,{style:{flexDirection:"column"},children:[(0,W.jsx)("div",{style:{fontWeight:700},children:e.full_name}),(0,W.jsx)("div",{children:e.email||"—"}),(0,W.jsx)("div",{children:e.phone||"—"})]}),(0,W.jsx)(nx,{children:new Date(e.created_at).toLocaleDateString()}),(0,W.jsx)(nx,{children:(0,W.jsx)(nv,{style:{color:"#b91c1c",borderColor:"#fca5a5",opacity:eg(null===(n=j.currentTeam)||void 0===n?void 0:n.uid,k,"clients")?1:.45},disabled:!eg(null===(t=j.currentTeam)||void 0===t?void 0:t.uid,k,"clients"),onClick:function(){return ei(e)},children:"Delete"})})]},e.id)})]}),(0,W.jsx)(nT,{org:X,open:!!X,onClose:function(){return Z(null)},save:function(e){return(0,r.A)(a().mark(function n(){var t,r;return a().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,B.getIdToken(!0);case 2:return t=n.sent,n.next=5,fetch("/api/v1/crm/updateOrganization",{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(t)},body:JSON.stringify({organization_id:X.id,branding:e})}).then(function(e){return e.json()});case 5:if((r=n.sent).success){n.next=8;break}throw Error(r.error);case 8:return _({type:"PATCH_ORG",payload:r.row}),Z(null),n.abrupt("return",!0);case 11:case"end":return n.stop()}},n)}))()}}),"crm"===H&&M&&(0,W.jsx)(ez,{state:j,dispatch:_}),"org"===H&&M&&(0,W.jsx)(ek,{crmProfiles:z,state:j,dispatch:_})]})}var nk=c.Ay.div.withConfig({displayName:"ClientsTab__Overlay",componentId:"sc-1rhch52-17"})(["position:fixed;inset:0;display:grid;place-items:center;background:rgba(0,0,0,.45);z-index:9999;"]),nA=c.Ay.div.withConfig({displayName:"ClientsTab__Dialog",componentId:"sc-1rhch52-18"})(["background:#fff;width:600px;max-width:90%;border-radius:10px;box-shadow:0 10px 30px rgba(0,0,0,.2);display:flex;flex-direction:column;padding:22px;gap:16px;"]),nI=c.Ay.h3.withConfig({displayName:"ClientsTab__Heading",componentId:"sc-1rhch52-19"})(["margin:0;font-size:1.2rem;font-weight:700;display:flex;align-items:center;gap:6px;color:#111827;span{font-size:1.4rem;}"]),nS=c.Ay.textarea.withConfig({displayName:"ClientsTab__BigInp",componentId:"sc-1rhch52-20"})(["flex:1;min-height:220px;resize:vertical;padding:10px 12px;font-size:.9rem;border:1px solid #d1d5db;border-radius:8px;&:focus{outline:none;border-color:#6366f1;box-shadow:0 0 0 1px #6366f1;}"]),nN=c.Ay.div.withConfig({displayName:"ClientsTab__BtnRow",componentId:"sc-1rhch52-21"})(["display:flex;justify-content:flex-end;gap:10px;margin-top:6px;"]),nD=c.Ay.button.withConfig({displayName:"ClientsTab__Btn",componentId:"sc-1rhch52-22"})(["padding:7px 16px;border-radius:8px;font-size:.85rem;font-weight:600;border:none;cursor:pointer;transition:background .15s;"," &:disabled{opacity:.45;cursor:default;pointer-events:none;}"],function(e){return e.primary?"background:#6366f1; color:#fff;\n       &:hover{background:#4f46e5;}":"background:#e5e7eb; color:#111827;\n       &:hover{background:#d1d5db;}"});function nT(e){var n=e.org,t=e.open,r=e.onClose,i=e.save,o=(0,s.use
1State)(""),a=o[0],c=o[1],d=(0,s.useState)(!1),l=d[0],p=d[1];return((0,s.useEffect)(function(){t&&n&&c(n.branding||"")},[t,n]),t&&n)?(0,W.jsx)(nk,{children:(0,W.jsxs)(nA,{children:[(0,W.jsxs)(nI,{children:[(0,W.jsx)("span",{children:"\uD83C\uDFE2"})," ",n.name]}),(0,W.jsx)(nS,{value:a,onChange:function(e){return c(e.target.value)},placeholder:"Describe the organisation, brand voice, positioning…"}),(0,W.jsxs)(nN,{children:[(0,W.jsx)(nD,{onClick:r,disabled:l,children:"Cancel"}),(0,W.jsx)(nD,{primary:!0,onClick:function(){p(!0),u.o.promise(i(a),{loading:"Saving…",success:function(){return p(!1),"Branding updated"},error:function(e){return e.message||"Failed"}})},disabled:l,children:"Save"})]})]})}):null}var nO=c.Ay.button.withConfig({displayName:"ClientsTab__KickBtn",componentId:"sc-1rhch52-23"})(["all:unset;margin-left:4px;width:16px;height:16px;border-radius:50%;background:#fecaca;color:#b91c1c;font-size:12px;font-weight:700;line-height:0;display:grid;place-items:center;cursor:pointer;&:hover{background:#fca5a5;}"]),nz=t(55825),nP=t(97289),nM=t(50893),nE=t(66954),nL=t(8651),nB=t(58036),nR=c.Ay.div.withConfig({displayName:"DealCharts__ChartsWrap",componentId:"sc-12zsawi-0"})(["display:grid;gap:12px;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));"]),nH=c.Ay.div.withConfig({displayName:"DealCharts__Card",componentId:"sc-12zsawi-1"})(["background:#fff;border:1px solid #ddd;border-radius:6px;display:flex;flex-direction:column;"]),n$=c.Ay.div.withConfig({displayName:"DealCharts__Hdr",componentId:"sc-12zsawi-2"})(["background:#f5f5f5;font-weight:600;font-size:0.85rem;border-bottom:1px solid #ddd;padding:0.45rem 0.7rem;"]),nW=c.Ay.div.withConfig({displayName:"DealCharts__ChartArea",componentId:"sc-12zsawi-3"})(["position:relative;height:110px;padding:","px;cursor:crosshair;"],8),nF=c.Ay.span.withConfig({displayName:"DealCharts__Quad",componentId:"sc-12zsawi-4"})(["position:absolute;font-size:0.72rem;font-weight:600;opacity:0.25;pointer-events:none;user-select:none;"]);function nV(e){var n=e.title,t=e.value,r=e.quadLabels,i=e.onMove,o=(0,s.useState)(t),a=o[0],c=o[1],d=(0,s.useState)(null),l=d[0],u=d[1];(0,s.useEffect)(function(){c(t),u(null)},[t.x,t.y]);var p=(0,s.useRef)(null),f=(0,s.useCallback)(function(e){if(i&&p.current){var n=p.current.getBoundingClientRect(),t={x:Math.max(0,Math.min(1,(e.clientX-n.left-8)/(n.width-16))),y:Math.max(0,Math.min(1,1-(e.clientY-n.top-8)/(n.height-16)))};u(t),i(t)}},[i]);return(0,W.jsxs)(nH,{children:[(0,W.jsx)(n$,{children:n}),(0,W.jsxs)(nW,{ref:p,onClick:f,children:[(0,W.jsx)(nF,{style:{left:"8%",top:"6%"},children:r[0]}),(0,W.jsx)(nF,{style:{right:"8%",top:"6%"},children:r[1]}),(0,W.jsx)(nF,{style:{left:"8%",bottom:"6%"},children:r[2]}),(0,W.jsx)(nF,{style:{right:"8%",bottom:"6%"},children:r[3]}),(0,W.jsx)(P.u,{width:"100%",height:"100%",children:(0,W.jsxs)(nE.t,{margin:{top:0,right:0,bottom:0,left:0},children:[(0,W.jsx)(L.W,{type:"number",dataKey:"x",domain:[0,1],hide:!0}),(0,W.jsx)(B.h,{type:"number",dataKey:"y",domain:[0,1],hide:!0}),(0,W.jsx)(nL.e,{x:.5,stroke:"#888",strokeDasharray:"3 3"}),(0,W.jsx)(nL.e,{y:.5,stroke:"#888",strokeDasharray:"3 3"}),l&&(0,W.jsx)(nB.X,{data:[l],fill:"#facc15",isAnimationActive:!1}),(0,W.jsx)(nB.X,{data:[a],fill:"#2962ff",animationDuration:300,animationEasing:"ease-out"})]})})]})]})}function nU(e){var n=e.customer,t=e.solution,r=e.onCustomerChange,i=e.onSolutionChange,o=n||{solution:.5,problem:.5},a=t||{value:.5,urgency:.5};return(0,W.jsxs)(nR,{children:[(0,W.jsx)(nV,{title:"Customer Awareness",value:{x:o.solution,y:o.problem},onMove:r,quadLabels:["Value Selling","Transactional","Consultative","Solution Selling"]}),(0,W.jsx)(nV,{title:"Solution Awareness",value:{x:a.value,y:a.urgency},onMove:i,quadLabels:["Nurture","Hot / Ready","Educate","Qualify"]})]})}var nG=c.Ay.div.withConfig({displayName:"LiveTranscription__Wrap",componentId:"sc-xz04r9-0"})(["display:flex;flex-direction:column;border:1px solid #ddd;border-radius:6px;background:#fafafa;overflow:hidden;flex:2;min-height:0;position:relative;"]),nq=c.Ay.div.withConfig({displayName:"LiveTranscription__Header",componentId:"sc-xz04r9-1"})(["padding:6px 10px;font-weight:600;background:#f5f5f5;border-bottom:1px solid #ddd;font-size:0.85rem;display:flex;align-items:center;justify-content:space-between;"]),nY=c.Ay.div.withConfig({displayName:"LiveTranscription__BtnRow",componentId:"sc-xz04r9-2"})(["display:flex;gap:6px;"]),nJ=c.Ay.button.withConfig({displayName:"LiveTranscription__StartBtn",componentId:"sc-xz04r9-3"})(["font-size:0.78rem;padding:4px 10px;border-radius:6px;border:none;cursor:pointer;color:#fff;white-space:nowrap;background:",";
1opacity:",";pointer-events:",";"],function(e){return e.$stop?"#b91c1c":"#6366f1"},function(e){return e.disabled?.4:1},function(e){return e.disabled?"none":"auto"}),nQ=c.Ay.div.withConfig({displayName:"LiveTranscription__Transcript",componentId:"sc-xz04r9-4"})(["flex:1;overflow-y:auto;padding:8px 10px;position:relative;"]),nK=c.Ay.div.withConfig({displayName:"LiveTranscription__Line",componentId:"sc-xz04r9-5"})(["margin-bottom:6px;color:",";"],function(e){return"Agent"===e.who?"#0B5FFF":"#F95C0E"}),nX=c.Ay.span.withConfig({displayName:"LiveTranscription__Chip",componentId:"sc-xz04r9-6"})(["font-weight:600;margin-right:6px;"]),nZ=c.Ay.div.withConfig({displayName:"LiveTranscription__Badge",componentId:"sc-xz04r9-7"})(["position:sticky;bottom:0px;margin-left:calc( 100% - 153px);font-size:0.72rem;background:#fff;border:1px solid #ddd;border-radius:6px;padding:2px 4px;display:flex;align-items:center;gap:5px;pointer-events:none;"]),n0=c.Ay.div.withConfig({displayName:"LiveTranscription__Timer",componentId:"sc-xz04r9-8"})(["position:sticky;bottom:0px;margin-right:calc( 100% - 80px);font-size:0.72rem;background:#fff;border:1px solid #ddd;border-radius:6px;padding:2px 4px;display:flex;align-items:center;font-weight:600;color:#2c3e50;gap:5px;pointer-events:none;justify-content:center;"]),n1=c.Ay.span.withConfig({displayName:"LiveTranscription__Pie",componentId:"sc-xz04r9-9"})(['--pct:0.5;width:14px;height:14px;border-radius:50%;border:1px solid #222;background:conic-gradient( #0b5fff 0 calc(var(--pct) * 360deg),#f95c0e calc(var(--pct) * 360deg) 360deg );position:relative;&::after{content:"";position:absolute;inset:0;border-radius:50%;background:conic-gradient( transparent 0 calc(var(--pct) * 360deg - 3deg),#000 calc(var(--pct) * 360deg - 3deg) calc(var(--pct) * 360deg + 3deg),transparent calc(var(--pct) * 360deg + 3deg) 360deg );}']),n6=c.Ay.div.withConfig({displayName:"LiveTranscription__Tabs",componentId:"sc-xz04r9-10"})(["display:flex;border-top:1px solid #ddd;background:#f5f5f5;"]),n2=c.Ay.button.withConfig({displayName:"LiveTranscription__TabBtn",componentId:"sc-xz04r9-11"})(["flex:1;padding:6px 0;font-size:0.78rem;font-weight:600;border:none;cursor:pointer;background:",";border-right:1px solid #ddd;position:relative;&:last-of-type{border-right:none;}"],function(e){return e.active?"#eef3ff":"transparent"}),n5=c.Ay.div.withConfig({displayName:"LiveTranscription__Pane",componentId:"sc-xz04r9-12"})(["max-height:35vh;overflow-y:auto;padding:8px 10px;background:#fff;min-height:110px;max-height:110px;overflow-y:auto;"]),n8=c.Ay.div.withConfig({displayName:"LiveTranscription__ObjCard",componentId:"sc-xz04r9-13"})(["border:1px solid #e5e7eb;border-radius:6px;padding:3px 4px;margin-bottom:8px;"]),n3=c.Ay.div.withConfig({displayName:"LiveTranscription__Controls",componentId:"sc-xz04r9-14"})(["padding:8px 10px;background:#f5f5f5;border-top:1px solid #ddd;display:flex;flex-direction:column;gap:8px;"]),n4=c.Ay.div.withConfig({displayName:"LiveTranscription__CtlRow",componentId:"sc-xz04r9-15"})(["display:flex;align-items:center;gap:8px;label{font-size:0.75rem;min-width:70px;text-align:right;}"]),n7=c.Ay.select.withConfig({displayName:"LiveTranscription__SelectNarrow",componentId:"sc-xz04r9-16"})(["font-size:0.78rem;max-width:180px;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;"]),n9=c.Ay.div.withConfig({displayName:"LiveTranscription__Meter",componentId:"sc-xz04r9-17"})(["width:120px;height:10px;background:#e0e0e0;border-radius:5px;overflow:hidden;"]),te=c.Ay.div.withConfig({displayName:"LiveTranscription__Fill",componentId:"sc-xz04r9-18"})(["width:","%;height:100%;transition:width 40ms linear;background:",";"],function(e){return(100*e.$v).toFixed(0)},function(e){var n=e.$v;return n<.4?"#4caf50":n<.9?"#ffb300":"#f44336"}),tn=c.Ay.span.withConfig({displayName:"LiveTranscription__Pill",componentId:"sc-xz04r9-19"})(["min-width:16px;height:16px;border-radius:999px;background:#dc2626;color:#fff;font-size:0.68rem;display:grid;place-items:center;margin-left:4px;position:absolute;top:3px;right:3px;"]),tt=c.Ay.div.withConfig({displayName:"LiveTranscription__SlideWrap",componentId:"sc-xz04r9-20"})(["display:flex;align-items:center;gap:6px;width:100%;"]),tr=c.Ay.button.withConfig({displayName:"LiveTranscription__Arrow",componentId:"sc-xz04r9-21"})(["all:unset;cursor:pointer;font-size:1.2rem;opacity:",";pointer-events:",";user-select:none;"],function(e){return e.disabled?.25:1},function(e){return e.disabled?"none":"auto"}),ti=c.Ay.div.withConfig({displayName:"LiveTranscription__SugCard",componentId:"sc-xz04r9-22"})(["flex:1;display:flex;border:1px solid #e5e7eb;border-radius:6px;overflow:hidden;font-size:0.82rem;min-height:46px;"]),to=c.Ay.div.withConfig({displayName:"LiveTranscription__Diag",componentId:"sc-xz04r9-23"})(["width:60%;background:#f3f4f6;padding:6px;font-weight:600;display:flex;align-items:center;justify-content:center;text-align:center;"]),ta=c.Ay.div.withConfig({displayName:"LiveTranscription__Guide",componentId:"sc-xz04r9-24"})(["flex:1;padding:6px;display:flex;align-items:center;padding-top:12px;"]),ts=c.Ay.span.withConfig({displayName:"LiveTranscription__Latest",componentId:"sc-xz04r9-25"})(["position:absolute;top:2px;right:6px;font-size:0.65rem;color:#10b981;display:flex;align-items:center;gap:2px;&::before{content:'●';}"]),tc=c.Ay.div.withConfig({displayName:"LiveTranscription__Risk",componentId:"sc-xz04r9-26"})(["font-weight:600;margin-bottom:2px;color:#cc3366;"]),td=c.Ay.div.withConfig({displayName:"LiveTranscription__Move",componentId:"sc-xz04r9-27"})(["font-size:0.82rem;"]);function tl(e){var n,t,r,i,o=e.lines,a=e.suggestions,c=e.objections;e.onSuggestionCopy,e.onObjectionHandled;
1var l=(0,d.mc)(),u=l.salesTranscripts,p=l.llmSuggestions,f=l.availableInputs,h=l.availableOutputs,x=l.agentVu,g=l.customerVu,m=l.recording,b=l.startRecording,y=l.stopRecording,v=l.cancelRecording,w=u&&u.length?u:void 0===o?[]:o,j=p.length?p.filter(function(e){return e.guide}):void 0===a?[]:a,_=p.length?p.filter(function(e){var n;return null===(n=e.counter)||void 0===n?void 0:n.move}).map(function(e){return{risk:e.counter.risk,move:e.counter.move}}):void 0===c?[]:c,C=(0,s.useRef)(null),k=(0,s.useState)("suggestions"),A=k[0],I=k[1],S=(0,s.useState)(0),N=S[0],D=S[1],T=(0,s.useState)(0),O=T[0],z=T[1],P=(0,s.useState)(0),M=P[0],E=P[1],L=(0,s.useState)(0),B=L[0],R=L[1],H=(0,s.useRef)(j.length),$=(0,s.useRef)(_.length),F=(0,s.useState)(""),V=F[0],U=F[1],G=(0,s.useState)(""),q=G[0],Y=G[1],J=(0,s.useState)(!1),Q=J[0],K=J[1],X=(0,s.useState)(0),Z=X[0],ee=X[1],en=(0,s.useRef)(null);(0,s.useEffect)(function(){var e;return m&&(en.current=Date.now(),ee(0),e=setInterval(function(){return ee(Math.floor((Date.now()-en.current)/1e3))},1e3)),function(){return clearInterval(e)}},[m]),(0,s.useEffect)(function(){D(function(e){var n=j.length-1;return n<0?0:Math.max(0,Math.min(e,n))}),z(function(e){var n=_.length-1;return n<0?0:Math.max(0,Math.min(e,n))})},[j.length]),(0,s.useEffect)(function(){var e=j.length-H.current;e>0&&"suggestions"!==A&&E(function(n){return n+e}),H.current=j.length},[j,A]),(0,s.useEffect)(function(){var e=_.length-$.current;e>0&&"objections"!==A&&R(function(n){return n+e}),$.current=_.length},[_,A]),(0,s.useEffect)(function(){var e;null===(e=C.current)||void 0===e||e.scrollIntoView({behavior:"smooth"})},[w]);var et=(0,s.useMemo)(function(){if(!w.length)return{agentPct:0,custPct:0};var e=w.reduce(function(e,n){var t=(n.text||"").split(/\s+/).filter(Boolean).length;return"Agent"===n.who?e.agent+=t:e.cust+=t,e},{agent:0,cust:0}),n=e.agent+e.cust||1;return{agentPct:e.agent/n,custPct:e.cust/n}},[w]),er=et.agentPct,ei=et.custPct,eo=function(e){I(e),"suggestions"===e&&E(0),"objections"===e&&R(0)};return(0,W.jsxs)(nG,{children:[(0,W.jsxs)(nq,{children:["Live Transcript",m?(0,W.jsx)(nJ,{$stop:!0,onClick:function(){return K(!0)},children:"End\xa0meeting"}):(0,W.jsx)(nY,{children:(0,W.jsx)(nJ,{disabled:!f.length,onClick:function(){return b(V,{desktop:!0})},children:"Start\xa0(share\xa0screen)"})})]}),(0,W.jsxs)(nQ,{children:[!w.length&&(0,W.jsx)("i",{style:{color:"#888"},children:"No transcript yet…"}),w.map(function(e){return(0,W.jsxs)(nK,{who:e.who,children:[(0,W.jsx)(nX,{children:e.who}),e.text]},e.timestamp)}),(0,W.jsx)("div",{ref:C}),(0,W.jsxs)(nZ,{children:["\uD83D\uDDE3 You ",Math.round(100*er),"% / Them ",Math.round(100*ei),"%",(0,W.jsx)(n1,{style:{"--pct":er}})]}),(0,W.jsx)(n0,{children:(n=function(e){return String(e).padStart(2,"0")},t=Math.floor(Z/3600),r=Math.floor(Z%3600/60),i=Z%60,t?"".concat(n(t),":").concat(n(r),":").concat(n(i)):"".concat(n(r),":").concat(n(i)))})]}),(0,W.jsxs)(n6,{children:[(0,W.jsxs)(n2,{active:"suggestions"===A,onClick:function(){return eo("suggestions")},children:["\uD83D\uDCA1 Suggested",M>0&&(0,W.jsx)(tn,{children:M>9?"9+":M})]}),(0,W.jsxs)(n2,{active:"objections"===A,onClick:function(){return eo("objections")},children:["\uD83D\uDEA9 Objections",B>0&&(0,W.jsx)(tn,{children:B>9?"9+":B})]})]}),(0,W.jsx)(n5,{children:function(){if("suggestions"===A){if(!j.length)return(0,W.jsx)("i",{children:"No suggestions yet…"});var e=Math.max(0,Math.min(N,j.length-1)),n=j[e];return(0,W.jsxs)(tt,{children:[(0,W.jsx)(tr,{disabled:N===j.length-1,onClick:function(){return D(function(e){return Math.min(e+1,j.length-1)})},children:"‹"}),(0,W.jsxs)(ti,{style:{position:"relative"},children:[(0,W.jsx)(to,{children:n.diagnose||"—"}),(0,W.jsx)(ta,{children:n.guide}),0===N&&(0,W.jsx)(ts,{children:"Latest"})]}),(0,W.jsx)(tr,{disabled:0===N,onClick:function(){return D(function(e){return Math.max(e-1,0)})},children:"›"})]})}if("objections"===A){if(!_.length)return(0,W.jsx)("i",{children:"No objections detected…"});var t=_[O];return(0,W.jsxs)(tt,{children:[(0,W.jsx)(tr,{disabled:O===_.length-1,onClick:function(){return z(function(e){return Math.min(e+1,_.length-1)})},children:"‹"}),(0,W.jsxs)(n8,{style:{flex:1,position:"relative"},children:[0===O&&(0,W.jsx)(ts,{children:"Latest"}),(0,W.jsx)(tc,{children:t.risk}),(0,W.jsx)(td,{children:t.move})]}),(0,W.jsx)(tr,{disabled:0===O,onClick:function(){return z(function(e){return Math.max(e-1,0)})},children:"›"})]})}}()}),(0,W.jsxs)(n3,{children:[(0,W.jsxs)(n4,{children:[(0,W.jsx)("label",{children:"Microphone:"}),(0,W.jsxs)(n7,{value:V,onChange:function(e){return U(e.target.value)},disabled:m,children:[(0,W.jsx)("option",{value:"",children:"(Default)"}),f.map(function(e){return(0,W.jsx)("option",{value:e.deviceId,children:e.label||"Input ".concat(e.deviceId)},e.deviceId)})]}),(0,W.jsx)(n9,{children:(0,W.jsx)(te,{$v:x})})]}),(0,W.jsxs)(n4,{children:[(0,W.jsx)("label",{children:"Speaker:"}),(0,W.jsxs)(n7,{value:q,onChange:function(e){return Y(e.target.value)},disabled:m,children:[(0,W.jsx)("option",{value:"",children:"(Default)"}),h.map(function(e){return(0,W.jsx)("option",{value:e.deviceId,children:e.label||"Output ".concat(e.deviceId)},e.deviceId)})]}),(0,W.jsx)(n9,{children:(0,W.jsx)(te,{$v:g})})]})]}),Q&&(0,W.jsx)("div",{style:{position:"absolute",inset:0,background:"rgba(0,0,0,.4)",display:"grid",placeItems:"center",zIndex:50},children:(0,W.jsxs)("div",{style:{background:"#fff",padding:24,borderRadius:8,width:260,display:"flex",flexDirection:"column",gap:12},children:[(0,W.jsx)("h4",{style:{marginTop:0},children:"End meeting?"}),(0,W.jsx)("button",{style:{padding:8,background:"#4ade80",color:"#fff",border:"none",borderRadius:6,cursor:"pointer"},onClick:function(){y(),K(!1)},children:"Save & End"}),(0,W.jsx)("button",{style:{padding:8,background:"#ef4444",color:"#fff",border:"none",borderRadius:6,cursor:"pointer"},onClick:function(){v(),K(!1)},children:"End without saving"})]})})]})}function tu(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),t.push.apply(t,r)}return t}function tp(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};
1n%2?tu(Object(t),!0).forEach(function(n){(0,S.A)(e,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):tu(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}var tf=c.Ay.div.withConfig({displayName:"LiveChatPanel__ChatWrap",componentId:"sc-94o8ll-0"})(["display:flex;flex-direction:column;height:100%;min-height:0;position:relative;"]),th=c.Ay.div.withConfig({displayName:"LiveChatPanel__Msgs",componentId:"sc-94o8ll-1"})(["flex:1 1 0%;overflow-y:auto;padding:8px 10px;"]),tx=c.Ay.p.withConfig({displayName:"LiveChatPanel__Line",componentId:"sc-94o8ll-2"})(["margin:4px 0;white-space:pre-wrap;font-size:11px;b{color:#374151;margin-right:4px;}&.assistant{background:#f3f4f6;border-radius:6px;padding:4px 6px;}"]),tg=c.Ay.form.withConfig({displayName:"LiveChatPanel__InputRow",componentId:"sc-94o8ll-3"})(["display:flex;gap:6px;padding:6px;border-top:1px solid #ddd;"]),tm=c.Ay.textarea.withConfig({displayName:"LiveChatPanel__Inp",componentId:"sc-94o8ll-4"})(["flex:1;resize:none;border:1px solid #ccc;border-radius:6px;padding:6px 8px;font-size:.82rem;"]),tb=c.Ay.button.withConfig({displayName:"LiveChatPanel__Send",componentId:"sc-94o8ll-5"})(["padding:6px 10px;border:none;border-radius:6px;background:#6366f1;color:#fff;cursor:pointer;"]),ty=c.Ay.button.withConfig({displayName:"LiveChatPanel__CancelBtn",componentId:"sc-94o8ll-6"})(["all:unset;cursor:pointer;font-size:.8rem;color:#b91c1c;margin-left:8px;"]),tv=function(){return(0,W.jsx)("span",{style:{animation:"blink .9s steps(1) infinite"},children:"▌"})};function tw(e){var n,t=e.dealId,i=(0,d.mc)(),o=i.state,c=i.dispatch,l=(0,s.useState)(function(){var e;return(null===(e=o.chatLog)||void 0===e?void 0:e[t])||[]}),u=l[0],p=l[1],f=(0,s.useState)(null),x=f[0],g=f[1],m=(0,s.useState)(""),b=m[0],y=m[1],v=(0,s.useState)(!1),w=v[0],j=v[1],_=(0,s.useRef)(null),C=(0,s.useRef)(null),k=(0,s.useRef)("");(0,s.useEffect)(function(){var e;p((null===(e=o.chatLog)||void 0===e?void 0:e[t])||[])},[o.chatLog,t]),(0,s.useEffect)(function(){var e=_.current;e&&(e.scrollTop=e.scrollHeight)},[u,x]);var A=(0,s.useCallback)(function(){return(0,d.UD)(o,t,u)},[o,t,u]),I=(0,s.useCallback)((n=(0,r.A)(a().mark(function e(n){var r,i,o,s,d,l,u;return a().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!w){e.next=2;break}return e.abrupt("return");case 2:return j(!0),p(function(e){return[].concat((0,N.A)(e),[{role:"User",text:n}])}),c({type:"ADD_CHAT_LINE",payload:{dealId:t,role:"User",text:n}}),g({role:"Assistant",text:""}),e.next=8,(0,h.xI)().currentUser.getIdToken(!0);case 8:return r=e.sent,i={prompt:n,dealId:t,context:A()},o=new AbortController,C.current=o,e.prev=12,e.next=15,fetch("/api/v1/crm/chat",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(r)},body:JSON.stringify(i),signal:o.signal});case 15:if((s=e.sent).ok){e.next=22;break}return e.t0=Error,e.next=20,s.text();case 20:throw e.t1=e.sent,new e.t0(e.t1);case 22:d=s.body.getReader(),l=new TextDecoder,u=a().mark(function e(){var n,t,r;return a().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,d.read();case 2:if(t=(n=e.sent).value,!n.done){e.next=7;break}return e.abrupt("return",1);case 7:r=l.decode(t,{stream:!0}),k.current+=r,g(function(e){return tp(tp({},e),{},{text:e.text+r})});case 10:case"end":return e.stop()}},e)});case 25:return e.delegateYield(u(),"t2",27);case 27:if(!e.t2){e.next=29;break}return e.abrupt("break",31);case 29:e.next=25;break;case 31:p(function(e){return[].concat((0,N.A)(e),[{role:"Assistant",text:k.current}])}),c({type:"ADD_CHAT_LINE",payload:{dealId:t,role:"Assistant",text:k.current}}),k.current="",g(null),e.next=42;break;case 37:e.prev=37,e.t3=e.catch(12),console.error("[chat]",e.t3),p(function(n){var t,r=null!==(t=n[n.length-1])&&void 0!==t?t:{role:"Assistant",text:""};return[].concat((0,N.A)(n.slice(0,-1)),[tp(tp({},r),{},{streaming:!1,text:"".concat(r.text,"\n⚠️ ").concat(e.t3.message)})])}),k.current="";case 42:return e.prev=42,j(!1),C.current=null,e.finish(42);case 46:case"end":return e.stop()}},e,null,[[12,37,42,46]])})),function(e){return n.apply(this,arguments)}),[w,t,A,c]);return(0,W.jsxs)(tf,{children:[(0,W.jsx)(tj,{onClick:function(){u.length&&(p([]),c({type:"RESET_CHAT",payload:{dealId:t}}))},children:"\uD83D\uDDD1 Reset chat"}),(0,W.jsxs)(th,{ref:_,children:[!u.length&&(0,W.jsx)("i",{style:{color:"#888"},children:"No messages yet. Ask me anything!"}),u.map(function(e,n){return(0,W.jsxs)(tx,{className:"Assistant"===e.role?"assistant":"",children:[(0,W.jsxs)("b",{children:[e.role,":"]})," ",e.text]},n)}),x&&(0,W.jsxs)(tx,{className:"assistant",children:[(0,W.jsx)("b",{children:"Assistant (typing):"})," ",x.text," ",(0,W.jsx)(tv,{})]})]}),(0,W.jsxs)(tg,{onSubmit:function(e){if(e.preventDefault(),b.trim()&&!w){var n=b.trim();y(""),I(n)}},children:[(0,W.jsx)(tm,{rows:2,value:b,placeholder:w?"Wait for reply…":"Ask the AI…",onChange:function(e){return y(e.target.value)},disabled:w}),w?(0,W.jsx)(ty,{onClick:function(){var e;return null===(e=C.current)||void 0===e?void 0:e.abort()},children:"Cancel"}):(0,W.jsx)(tb,{type:"submit",children:"Send"})]})]})}c.Ay.div.withConfig({displayName:"LiveChatPanel__TopBar",componentId:"sc-94o8ll-7"})(["display:flex;justify-content:flex-end;padding:4px 8px;border-bottom:1px solid #ddd;background:#fafafa;"]);var tj=c.Ay.button.withConfig({displayName:"LiveChatPanel__ResetBtn",componentId:"sc-94o8ll-8"})(["padding:2px 5px;font-size:.6rem;border-radius:6px;cursor:pointer;border:1px solid rgba(200,200,200,0.1);background:#fff;&:hover{background:#f3f4f6;}position:absolute;top:0;right:12px;"]),t_=c.Ay.div.withConfig({displayName:"MeetingsPane__Pane",componentId:"sc-19h2bfj-0"})(["flex:1;overflow-y:auto;position:relative;"]),tC=c.Ay.input.withConfig({displayName:"MeetingsPane__SearchBar",componentId:"sc-19h2bfj-1"})(["width:100%;padding:6px 10px;border:none;border-bottom:1px solid #ddd;font-size:.82rem;&:focus{outline:none;background:#f9fafb;}"]),tk=c.Ay.details.withConfig({displayName:"MeetingsPane__Card",componentId:"sc-19h2bfj-2"})(["padding:10px 12px;border-bottom:1px solid #eee;&[open]{background:#fafbff;}summary{cursor:pointer;font-weight:600;list-style:none;display:flex;gap:8px;}summary::-webkit-details-marker{display:none;}time{font-size:.75rem;color:#555;}.dur{background:#e0e7ff;font-size:.7rem;padding:0 4px;border-radius:4px;color:#3730a3;}.body{margin:8px 0 0 2px;font-size:.82rem;white-space:pre-wrap;line-height:1.35;}"]),tA=c.Ay.button.withConfig({displayName:"MeetingsPane__DeleteBtn",componentId:"sc-19h2bfj-3"})(["margin-left:auto;background:none;border:none;color:#b91c1c;font-size:.8rem;cursor:pointer;padding:0 4px;&:hover{text-decoration:underline;}"]),tI=c.Ay.span.withConfig({displayName:"MeetingsPane__Badge",componentId:"sc-19h2bfj-4"})(["background:#fee2e2;color:#991b1b;font-size:.7rem;border-radius:4px;padding:0 4px;margin-left:4px;"]),tS=c.Ay.i.withConfig({displayName:"MeetingsPane__NoHit",componentId:"sc-19h2bfj-5"})(["color:#888;padding:12px;display:block;"]);function tN(e){var n,t=e.dealId,i=(0,d.mc)(),o=i.state,c=i.dispatch,l=o.meetingProfiles.filter(function(e){return e.deal_id===t}
1),u=(0,s.useState)(""),p=u[0],f=u[1],x=(0,s.useState)(null),g=x[0],m=x[1],b=(0,s.useRef)(null);(0,s.useEffect)(function(){var e=b.current;return function(){e&&(e.dataset.scroll=e.scrollTop)}},[]),(0,s.useEffect)(function(){var e=b.current;e&&e.dataset.scroll&&(e.scrollTop=e.dataset.scroll)},[t]);var y=(0,s.useMemo)(function(){if(!p.trim())return l;var e=p.trim().toLowerCase();return l.filter(function(n){var t,r;return(null===(t=n.ai_summary)||void 0===t?void 0:t.toLowerCase().includes(e))||(null===(r=n.transcription)||void 0===r?void 0:r.toLowerCase().includes(e))})},[l,p]),v=function(e){return p.trim()?e.split(RegExp("(".concat(p,")"),"gi")).map(function(e,n){return e.toLowerCase()===p.toLowerCase()?(0,W.jsx)("mark",{style:{background:"#fde047"},children:e},n):e}):e},w=(0,s.useCallback)((n=(0,r.A)(a().mark(function e(n){var t;return a().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(window.confirm("Delete this meeting permanently?")){e.next=2;break}return e.abrupt("return");case 2:return e.prev=2,m(n),e.next=6,(0,h.xI)().currentUser.getIdToken(!0);case 6:return t=e.sent,e.next=9,fetch("/api/v1/crm/deleteMeeting",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(t)},body:JSON.stringify({meetingId:n})});case 9:c({type:"DELETE_MEETING",payload:{id:n}}),e.next=15;break;case 12:e.prev=12,e.t0=e.catch(2),alert(e.t0.message||"Failed");case 15:return e.prev=15,m(null),e.finish(15);case 18:case"end":return e.stop()}},e,null,[[2,12,15,18]])})),function(e){return n.apply(this,arguments)}),[c]);return(0,s.useEffect)(function(){var e=function(e){if((e.metaKey||e.ctrlKey)&&"f"===e.key){var n;e.preventDefault(),null===(n=document.getElementById("meet-search"))||void 0===n||n.focus()}};return window.addEventListener("keydown",e),function(){return window.removeEventListener("keydown",e)}},[]),(0,W.jsxs)(t_,{ref:b,children:[(0,W.jsx)(tC,{id:"meet-search",placeholder:"Search transcripts… ⌘/Ctrl+F",value:p,onChange:function(e){return f(e.target.value)}}),!y.length&&(0,W.jsx)(tS,{children:"No meetings match."}),y.map(function(e){var n,t,r=(e.ai_summary||"").split(/\n+/).map(function(e){return e.replace(/^[-•]\s*/,"").trim()}).filter(Boolean);return(0,W.jsxs)(tk,{open:1===y.length,children:[(0,W.jsxs)("summary",{children:[(0,W.jsx)("time",{children:T()(e.meeting_ts).format("D MMM YYYY")}),(0,W.jsx)("span",{className:"dur",children:(t=Math.floor((n=e.duration_sec)/60),"".concat(t," m ").concat(String(n%60).padStart(2,"0")," s"))}),p&&!r.length&&(0,W.jsx)(tI,{children:"hit"}),(0,W.jsx)(tA,{disabled:g===e.id,onClick:function(n){n.stopPropagation(),w(e.id)},children:g===e.id?"…":"Delete"})]}),(0,W.jsx)("div",{className:"body",children:r.length?(0,W.jsx)("ul",{children:r.map(function(e,n){return(0,W.jsx)("li",{children:v(e)},n)})}):v(e.transcription||"—")})]},e.id)})]})}var tD=c.Ay.div.withConfig({displayName:"HistoryPanel__Wrap",componentId:"sc-7bs7ll-0"})(["border:1px solid #ddd;border-radius:6px;background:#fff;display:flex;flex-direction:column;flex:1;min-height:0;= height:100%;max-height:100%;overflow:hidden;"]),tT=c.Ay.div.withConfig({displayName:"HistoryPanel__Tabs",componentId:"sc-7bs7ll-1"})(["display:flex;border-bottom:1px solid #ddd;"]),tO=c.Ay.button.withConfig({displayName:"HistoryPanel__TabBtn",componentId:"sc-7bs7ll-2"})(["flex:1;padding:6px 0;font-size:0.82rem;font-weight:600;border:none;background:",";cursor:pointer;"],function(e){return e.active?"#eef3ff":"#f5f5f5"});function tz(e){var n=e.dealId,t=(0,s.useState)("meetings"),r=t[0],i=t[1];return(0,W.jsxs)(tD,{children:[(0,W.jsxs)(tT,{children:[(0,W.jsx)(tO,{active:"meetings"===r,onClick:function(){return i("meetings")},children:"\uD83D\uDDD3 Past Meetings"}),(0,W.jsx)(tO,{active:"chat"===r,onClick:function(){return i("chat")},children:"\uD83E\uDD16 AI Chat"})]}),"meetings"===r?(0,W.jsx)(tN,{dealId:n}):(0,W.jsx)(tw,{dealId:n})]})}function tP(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),t.push.apply(t,r)}return t}function tM(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};
1n%2?tP(Object(t),!0).forEach(function(n){(0,S.A)(e,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):tP(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}var tE=["M","A","N"],tL=["M","A","G","I","C"],tB=["Questions to Ask","Outcomes","Best Practices","Sales Artifacts"],tR=Object.entries({New:{bg:"#e5e7eb",txt:"#374151"},Qualified:{bg:"#bfdbfe",txt:"#1e3a8a"},Proposal:{bg:"#fde68a",txt:"#78350f"},Won:{bg:"#bbf7d0",txt:"#065f46"},Lost:{bg:"#fecaca",txt:"#7f1d1d"}}).map(function(e){var n=(0,i.A)(e,2),t=n[0];return tM({value:t,label:t},n[1])}),tH={control:function(e){return tM(tM({},e),{},{border:"none",background:"transparent",minHeight:"auto",padding:0,boxShadow:"none",cursor:"pointer"})},valueContainer:function(e){return tM(tM({},e),{},{padding:0})},indicatorsContainer:function(){return{display:"none"}},singleValue:function(e,n){var t=n.data;return tM(tM({},e),{},{background:t.bg,color:t.txt,fontWeight:600,borderRadius:9999,padding:"2px 10px"})},option:function(e,n){var t=n.data,r=n.isFocused;return tM(tM({},e),{},{background:r?t.bg:"#fff",color:t.txt,fontWeight:600})},menu:function(e){return tM(tM({},e),{},{zIndex:30,minWidth:110})}},t$=c.Ay.div.withConfig({displayName:"DealInfo__Page",componentId:"sc-875hqk-0"})(["height:100%;display:flex;flex-direction:column;padding:6px 12px;gap:8px;"]),tW=c.Ay.div.withConfig({displayName:"DealInfo__TopRow",componentId:"sc-875hqk-1"})(["display:flex;align-items:center;flex-wrap:wrap;gap:12px;width:100%;"]),tF=c.Ay.button.withConfig({displayName:"DealInfo__Back",componentId:"sc-875hqk-2"})(["all:unset;width:30px;height:30px;display:grid;place-items:center;cursor:pointer;border:1px solid #e5e7eb;border-radius:6px;background:#f9fafb;svg{width:16px;color:#6366f1;}",""],function(e){return e.$disabled&&(0,c.AH)(["pointer-events:none;opacity:.35;"])}),tV=c.Ay.div.withConfig({displayName:"DealInfo__Pill",componentId:"sc-875hqk-3"})(["min-width:0;background:#f3f4f6;border-radius:6px;padding:3px 8px;display:flex;flex-direction:column;font-size:0.75rem;line-height:1.25;b{font-size:0.9rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}label{font-size:0.62rem;color:#6b7280;text-transform:uppercase;}flex:1;"]),tU=(0,c.i7)(["50%{opacity:.4;}"]),tG=c.Ay.div.withConfig({displayName:"DealInfo__StatusChip",componentId:"sc-875hqk-4"})(["display:flex;align-items:center;gap:6px;font-size:.8rem;font-weight:600;background:#ecfdf5;color:#065f46;border:1px solid #a7f3d0;border-radius:999px;padding:4px 10px;white-space:nowrap;svg{width:16px;}"," .spin{animation:"," 1s linear infinite;}min-width:110px;"],function(e){return e.$updating&&(0,c.AH)(["background:#fef3c7;border-color:#fde68a;color:#92400e;"])},tU),tq=c.Ay.div.withConfig({displayName:"DealInfo__Main",componentId:"sc-875hqk-5"})(["flex:1;display:flex;gap:16px;min-height:0;"]),tY=c.Ay.div.withConfig({displayName:"DealInfo__Left",componentId:"sc-875hqk-6"})(["flex:1.5;min-width:0;display:flex;flex-direction:column;gap:12px;"]),tJ=c.Ay.div.withConfig({displayName:"DealInfo__Right",componentId:"sc-875hqk-7"})(["flex:1;display:flex;flex-direction:column;gap:12px;min-width:260px;min-height:0;"]),tQ=c.Ay.div.withConfig({displayName:"DealInfo__MagicBox",componentId:"sc-875hqk-8"})(["border:1px solid #e5e7eb;border-radius:8px;display:flex;flex-direction:column;overflow:hidden;position:relative;"]),tK=(0,c.AH)(["border-left:","px solid #000!important;border-right:","px solid #000!important;"],3,3),tX=c.Ay.div.withConfig({displayName:"DealInfo__Grid",componentId:"sc-875hqk-9"})(["display:grid;grid-template-columns:","px repeat(5,1fr);grid-template-rows:38px repeat(3,50px);"],56),tZ=c.Ay.button.withConfig({displayName:"DealInfo__ColHead",componentId:"sc-875hqk-10"})(["all:unset;display:flex;justify-content:center;align-items:center;cursor:pointer;background:#f3f4f6;border-right:1px solid #e5e7eb;font-weight:700;font-size:1.05rem;"," ",""],function(e){return e.active&&(0,c.AH)(["background:#6366f1;color:#fff;"])},function(e){return e.selected&&tK}),t0=c.Ay.div.withConfig({displayName:"DealInfo__RowHead",componentId:"sc-875hqk-11"})(["display:flex;justify-content:center;align-items:center;background:#f3f4f6;border-bottom:1px solid #e5e7eb;font-weight:700;font-size:0.9rem;"]),t1=c.Ay.div.withConfig({displayName:"DealInfo__Cell",componentId:"sc-875hqk-12"})(["display:flex;justify-content:center;align-items:center;border-right:1px solid #e5e7eb;border-bottom:1px solid #e5e7eb;",""],function(e){return e.selected&&tK}),t6=c.Ay.button.withConfig({displayName:"DealInfo__Dot",componentId:"sc-875hqk-13"})(["all:unset;width:16px;height:16px;border-radius:50%;cursor:pointer;background:",";"],function(e){return({null:"#e5e7eb",red:"#f87171",yellow:"#facc15",green:"#4ade80"})[e.c]}),t2=c.Ay.div.withConfig({displayName:"DealInfo__BridgeWrap",componentId:"sc-875hqk-14"})(["width:100%;height:16px;line-height:0;pointer-events:none;"]),t5=(0,c.i7)(["from{opacity:0;transform:translateY(6px);}to{opacity:1;transform:translateY(0);}"]),t8=c.Ay.div.withConfig({displayName:"DealInfo__Notes",componentId:"sc-875hqk-15"})(["display:flex;gap:4px;padding:4px;animation:",".25s ease;"],t5),t3=c.Ay.div.withConfig({displayName:"DealInfo__Card",componentId:"sc-875hqk-16"})(["flex:1;min-width:0;background:#fff;border:1px solid #e5e7eb;border-radius:8px;padding:8px 10px;display:flex;flex-direction:column;min-height:100px;h5{margin:0 0 6px;font-size:0.7rem;text-transform:uppercase;color:#6b7280;}textarea{flex:1;border:none;resize:none;font-size:0.78rem;min-height:100px;padding:0;&:focus{outline:none;}}button{align-self:flex-end;margin-top:4px;font-size:0.7rem;border:none;cursor:pointer;background:#6366f1;color:#fff;padding:4px 8px;border-radius:6px;}"]);function t4(e){var n,t,i,o=e.userData,c=e.deal,l=e.onBack,u=e.assigneeMail,p=(0,d.mc)(),f=p.state,x=p.dispatch,g=p.recording,m=p.setActiveDealId,b=p.meetingSave;p.askChat;var y=ex(null===(i=(0,h.xI)().currentUser)||void 0===i?void 0:i.uid,c,f.currentTeam),v=(0,s.useRef)(null),w=Object.fromEntries(tL.flatMap(function(e){return tE.map(function(n){return[[e,n].join(""),null]})}
1)),j=(0,s.useState)(function(){return tM(tM({},w),c.magic_grid||{})}),_=j[0],C=j[1],k=(0,s.useState)(c.customer_awareness||{solution:.5,problem:.5}),A=k[0],I=k[1],N=(0,s.useState)(c.solution_awareness||{value:.5,urgency:.5}),D=N[0],O=N[1],z=(0,s.useState)(c.stage||"New"),P=z[0],M=z[1],E=(0,s.useState)(c.close_date||""),L=E[0],B=E[1],R=(0,s.useState)(null!=c.value_usd?String(c.value_usd):""),H=R[0],$=R[1],F=(0,s.useState)(null),V=F[0],U=F[1],G=s.useMemo(function(){return(f.meetingProfiles||[]).filter(function(e){return e.deal_id===c.id}).sort(function(e,n){return new Date(n.meeting_ts)-new Date(e.meeting_ts)})},[f.meetingProfiles,c.id]);(0,s.useEffect)(function(){return function(){return clearTimeout(v.current)}},[]),(0,s.useEffect)(function(){return m(c.id),function(){return m(null)}},[c.id]),(0,s.useEffect)(function(){c.customer_awareness&&I(c.customer_awareness),c.solution_awareness&&O(c.solution_awareness)},[c.customer_awareness,c.solution_awareness]),(0,s.useEffect)(function(){C(tM(tM({},w),c.magic_grid||{}))},[c.magic_grid]);var q=(0,s.useState)(0),Y=(q[0],q[1]),J=(n=(0,r.A)(a().mark(function e(n){var t,r,i,o;return a().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return Y(function(e){return e+1}),e.prev=1,e.next=4,null===(t=(0,h.xI)().currentUser)||void 0===t?void 0:t.getIdToken(!0);case 4:return r=e.sent,e.next=7,fetch("/api/v1/crm/updateDeal",{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(r)},body:JSON.stringify(tM(tM({deal_id:c.id},n),{},{client_ts:Date.now()}))});case 7:return i=e.sent,e.next=10,i.json();case 10:if((o=e.sent).success){e.next=13;break}throw Error(o.error);case 13:x({type:"PATCH_DEAL",payload:o.deal}),e.next=19;break;case 16:e.prev=16,e.t0=e.catch(1),console.error("savePartial:",e.t0);case 19:return e.prev=19,Y(function(e){var n=e-1;return 0===n&&eg(!1),n}),e.finish(19);case 22:case"end":return e.stop()}},e,null,[[1,16,19,22]])})),function(e){return n.apply(this,arguments)}),Q=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return tM({stage:P,value_usd:""===H.trim()?null:+H,close_date:L||null,magic_grid:_,magic_notes:eo,customer_awareness:A,solution_awareness:D},e)},K=(0,s.useCallback)(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};v.current&&clearTimeout(v.current),eg(!0),v.current=setTimeout(function(){J(Q(e)),v.current=null},5e3)},[J,P,H,L,_,eo,A,D]),X=function(e,n){y&&C(function(t){var r=tM(tM({},t),{},(0,S.A)({},e+n,{null:"red",red:"yellow",yellow:"green",green:null}[t[e+n]]));return K({magic_grid:r,magic_notes:eo,customer_awareness:A,solution_awareness:D}),r})},Z=(0,s.useState)(tL[0]),ee=Z[0],en=Z[1],et=tL.indexOf(ee),er=tL.reduce(function(e,n){return tM(tM({},e),{},(0,S.A)({},n,tB.reduce(function(e,n){return tM(tM({},e),{},(0,S.A)({},n,""))},{})))},{}),ei=(0,s.useState)(function(){return c.magic_notes?tM(tM({},er),c.magic_notes):er}),eo=ei[0],ea=ei[1],es=function(e,n,t){y&&ea(function(r){var i=tM(tM({},r),{},(0,S.A)({},e,tM(tM({},r[e]),{},(0,S.A)({},n,t))));return K({magic_notes:i,magic_grid:_,customer_awareness:A,solution_awareness:D}),i})},ec=(0,s.useRef)(null),ed=(0,s.useState)(null),el=ed[0],eu=ed[1];(0,s.useLayoutEffect)(function(){if(ec.current){var e=function(){var e=ec.current.offsetWidth,n=(e-56)/5;eu({w:Math.round(e),l:Math.round(56+n*et),r:Math.round(56+n*(et+1))})};return e(),window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}}},[et]);var ep=(0,s.useState)(!1),eh=ep[0],eg=ep[1],em="saving"===b.state||"fetching"===b.state,eb="error"===b.state,ey=(t=(0,r.A)(a().mark(function e(n,t){var r,i,o;return a().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return U("".concat(n,"-").concat(t)),(r=(0,d.UD)(f,c.id)).magic_notes=eo,r.magic_grid=_,r.customer_awareness=A,r.solution_awareness=D,e.prev=7,e.next=10,(0,h.xI)().currentUser.getIdToken(!0);case 10:return i=e.sent,e.next=13,fetch("/api/v1/crm/aiNote",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(i)},body:JSON.stringify({dealId:c.id,column:n,kind:t,current:eo[n][t],context:r})}).then(function(e){return e.json()});case 13:if((o=e.sent).success){e.next=16;break}throw Error(o.error);case 16:es(n,t,eo[n][t]?eo[n][t].trimEnd()+"\n- "+o.bullet:"- "+o.bullet),e.next=22;break;case 19:e.prev=19,e.t0=e.catch(7),alert(e.t0.message||"AI failed");case 22:return e.prev=22,U(null),e.finish(22);case 25:case"end":return e.stop()}},e,null,[[7,19,22,25]])})),function(e,n){return t.apply(this,arguments)});return(0,s.useEffect)(function(){M(c.stage||"New"),B(c.close_date||""),$(null!=c.value_usd?String(c.value_usd):"")},[c.stage,c.close_date,c.value_usd]),(0,W.jsxs)(t$,{children:[(0,W.jsxs)(tW,{children:[(0,W.jsx)(tF,{$disabled:g,onClick:function(){return!g&&l()},children:(0,W.jsx)(nz.n,{})}),(0,W.jsxs)(tV,{children:[(0,W.jsx)("label",{children:"Deal"}),(0,W.jsx)("b",{children:c.title})]}),(0,W.jsxs)(tV,{children:[(0,W.jsx)("label",{children:"Account"}),u||o.email||"—"]}),(0,W.jsxs)(tV,{style:{minWidth:120},children:[(0,W.jsx)("label",{children:"Stage"}),(0,W.jsx)(ef.Ay,{instanceId:"deal-stage-".concat(c.id),options:tR,value:tR.find(function(e){return e.value===P}),onChange:function(e){y&&e&&e.value!==P&&(M(e.value),K({stage:e.value}))},styles:tH,menuPortalTarget:document.body})]}),(0,W.jsxs)(tV,{style:{minWidth:140},children:[(0,W.jsx)("label",{children:"Close\xa0date"}),(0,W.jsx)("input",{type:"date",value:L?T()(L).format("YYYY-MM-DD"):"",onCh
1ange:function(e){return y&&B(e.target.value)},onBlur:function(){y&&K({close_date:L||null})},style:{border:"none",background:"transparent"}})]}),(0,W.jsxs)(tV,{style:{minWidth:120},children:[(0,W.jsx)("label",{children:"Value"}),(0,W.jsx)("input",{type:"number",min:"0",value:H,onChange:function(e){return y&&$(e.target.value)},onBlur:function(){y&&K({value_usd:""===H.trim()?null:+H})},style:{border:"none",background:"transparent",width:"100%"},placeholder:"—"})]}),(0,W.jsxs)(tG,{$updating:eh||em||eb,children:[eh||em?(0,W.jsx)(nP.z,{className:"spin"}):(0,W.jsx)(nM.r,{}),eh?"Updating…":em?"saving"===b.state?"Uploading…":"Refreshing…":eb?"Save failed":"Updated"]})]}),(0,W.jsxs)(tq,{children:[(0,W.jsxs)(tY,{children:[(0,W.jsxs)(tQ,{ref:ec,children:[(0,W.jsxs)(tX,{children:[(0,W.jsx)("div",{}),tL.map(function(e,n){return(0,W.jsx)(tZ,{active:e===ee,selected:n===et,onClick:function(){return en(e)},children:e},e)}),tE.map(function(e){return(0,W.jsxs)(s.Fragment,{children:[(0,W.jsx)(t0,{children:e}),tL.map(function(n,t){return(0,W.jsx)(t1,{selected:t===et,children:(0,W.jsx)(t6,{c:_[n+e],onClick:function(){return X(n,e)}})},n+e)})]},e)})]}),(0,W.jsx)(t2,{children:el&&(0,W.jsxs)("svg",{width:"100%",height:"100%",viewBox:"0 0 ".concat(el.w," 16"),preserveAspectRatio:"none",children:[(0,W.jsx)("polygon",{points:"0,16 ".concat(el.l,",0 ").concat(el.r,",0 ").concat(el.w,",16"),fill:"#fff"}),(0,W.jsx)("line",{x1:"0",y1:"16",x2:el.l,y2:"0",stroke:"#000",strokeWidth:3,strokeLinecap:"square",shapeRendering:"crispEdges"}),(0,W.jsx)("line",{x1:el.r,y1:"0",x2:el.w,y2:"16",stroke:"#000",strokeWidth:3,strokeLinecap:"square",shapeRendering:"crispEdges"})]})}),(0,W.jsx)(t8,{children:tB.map(function(e){return(0,W.jsxs)(t3,{children:[(0,W.jsx)("h5",{children:e}),(0,W.jsx)("textarea",{value:eo[ee][e],onChange:function(n){return es(ee,e,n.target.value)},placeholder:"Add notes…"}),(0,W.jsx)("button",{disabled:V==="".concat(ee,"-").concat(e),onClick:function(){return ey(ee,e)},children:V==="".concat(ee,"-").concat(e)?"…":"AI ✨"})]},e)})},ee)]}),(0,W.jsx)(nU,{customer:A,solution:D,onCustomerChange:function(e){var n={solution:e.x,problem:e.y};I(n),K({customer_awareness:n})},onSolutionChange:function(e){var n={value:e.x,urgency:e.y};O(n),K({solution_awareness:n})}})]}),(0,W.jsxs)(tJ,{children:[(0,W.jsx)(tl,{onSuggestionCopy:function(){},onObjectionHandled:function(){}}),(0,W.jsx)(tz,{meetings:G,dealId:c.id})]})]})]})}function t7(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),t.push.apply(t,r)}return t}function t9(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?t7(Object(t),!0).forEach(function(n){(0,S.A)(e,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):t7(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}c.Ay.div.withConfig({displayName:"DealInfo__Box",componentId:"sc-875hqk-17"})(["background:#fff;border:1px solid #e5e7eb;border-radius:8px;padding:12px;font-size:0.8rem;"," "," h4{margin:0 0 6px;font-size:0.86rem;}"],function(e){return e.tall&&(0,c.AH)(["flex:1;display:flex;flex-direction:column;"])},function(e){var n=e.min;return n&&(0,c.AH)(["min-height:",";"],n)});var re={New:{bg:"#e5e7eb",txt:"#374151"},Qualified:{bg:"#bfdbfe",txt:"#1e3a8a"},Proposal:{bg:"#fde68a",txt:"#78350f"},Won:{bg:"#bbf7d0",txt:"#065f46"},Lost:{bg:"#fecaca",txt:"#7f1d1d"}},rn=Object.entries(re).map(function(e){var n=(0,i.A)(e,2),t=n[0];return t9({value:t,label:t},n[1])}),rt={control:function(e){return t9(t9({},e),{},{border:"none",background:"transparent",minHeight:"auto",padding:0,boxShadow:"none",cursor:"pointer"})},valueContainer:function(e){return t9(t9({},e),{},{padding:0})},indicatorsContainer:function(){return{display:"none"}},singleValue:function(e,n){var t=n.data;return t9(t9({},e),{},{background:t.bg,color:t.txt,fontWeight:600,borderRadius:9999,padding:"2px 10px"})},option:function(e,n){var t=n.data,r=n.isFocused;return t9(t9({},e),{},{background:r?t.bg:"#fff",color:t.txt,fontWeight:600})},menu:function(e){return t9(t9({},e),{},{zIndex:30,minWidth:110})}},rr=c.Ay.div.withConfig({displayName:"DealsTab__Wrap",componentId:"sc-1ej1zc0-0"})(["display:flex;flex-direction:column;height:100%;padding:20px 24px 40px;
1gap:16px;"]),ri=c.Ay.div.withConfig({displayName:"DealsTab__Toolbar",componentId:"sc-1ej1zc0-1"})(["display:flex;flex-wrap:wrap;gap:12px;align-items:center;"]),ro=c.Ay.input.withConfig({displayName:"DealsTab__Search",componentId:"sc-1ej1zc0-2"})(["width:240px;padding:7px 10px;border:1px solid #d1d5db;border-radius:8px;&:focus{outline:none;border-color:#6366f1;box-shadow:0 0 0 1px #6366f1;}"]),ra=c.Ay.select.withConfig({displayName:"DealsTab__Select",componentId:"sc-1ej1zc0-3"})(["padding:7px 36px 7px 10px;border:1px solid #d1d5db;border-radius:8px;background:#fff;"]),rs="200px 1.5fr 120px 120px 140px 110px 160px",rc=c.Ay.div.withConfig({displayName:"DealsTab__Sheet",componentId:"sc-1ej1zc0-4"})(["flex:1;overflow:auto;background:#fff;border:1px solid #e5e7eb;border-radius:8px;"]),rd=c.Ay.div.withConfig({displayName:"DealsTab__Header",componentId:"sc-1ej1zc0-5"})(["display:grid;grid-template-columns:",";background:#6366f1;color:#fff;font-size:0.82rem;font-weight:700;position:sticky;top:0;z-index:5;"],rs),rl=c.Ay.div.withConfig({displayName:"DealsTab__Row",componentId:"sc-1ej1zc0-6"})(["display:grid;grid-template-columns:",";font-size:0.85rem;&:nth-child(even){background:#f9fafb;}"],rs),ru=c.Ay.div.withConfig({displayName:"DealsTab__Cell",componentId:"sc-1ej1zc0-7"})(["padding:8px 10px;border-bottom:1px solid #f3f4f6;display:flex;align-items:center;gap:6px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;"]),rp=c.Ay.button.withConfig({displayName:"DealsTab__ActBtn",componentId:"sc-1ej1zc0-8"})(["padding:6px 10px;font-size:0.78rem;border:1px solid #d1d5db;border-radius:6px;background:#fff;cursor:pointer;transition:background .15s;&:hover{background:#f3f4f6;}"]);function rf(e){var n=e.userData,t=(0,d.mc)(),o=t.state,c=o.dealProfiles,l=o.orgProfiles,p=o.dealFilter,f=o.currentTeam,h=t.dispatch,x=t.setActiveDealId,m=t.can,b=(0,eh.hD)(g.auth),y=(0,i.A)(b,1)[0],v=(0,s.useState)(null),w=v[0],j=v[1],_=(0,s.useState)(""),C=_[0],k=_[1],A=(0,s.useState)(""),I=A[0],S=A[1],N=(0,s.useState)(""),D=N[0],O=N[1],z=(0,s.useCallback)((E=(0,r.A)(a().mark(function e(n,t){var i;return a().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!(!t||t.value===n.stage)){e.next=2;break}return e.abrupt("return");case 2:i=n.stage,n.stage=t.value,u.o.promise((0,r.A)(a().mark(function e(){var r,i,o;return a().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,y.getIdToken(!0);case 2:return r=e.sent,e.next=5,fetch("/api/v1/crm/updateDeal",{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(r)},body:JSON.stringify({deal_id:n.id,stage:t.value})});case 5:return i=e.sent,e.next=8,i.json();case 8:if((o=e.sent).success){e.next=11;break}throw Error(o.error);case 11:h({type:"PATCH_DEAL",payload:o.deal});case 12:case"end":return e.stop()}},e)}))(),{loading:"Saving…",success:"Stage updated",error:function(e){return n.stage=i,e.message}});case 5:case"end":return e.stop()}},e)})),function(e,n){return E.apply(this,arguments)}),[y,h]),P=(0,s.useCallback)((L=(0,r.A)(a().mark(function e(n){return a().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(eg(null==f?void 0:f.uid,m,"deals")){e.next=3;break}return u.o.error("You don’t have permission to delete deals"),e.abrupt("return");case 3:if(confirm("Delete deal “".concat(n.title,"”?"))){e.next=5;break}return e.abrupt("return");case 5:u.o.promise((0,r.A)(a().mark(function e(){var t,r,i;return a().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,y.getIdToken(!0);case 2:return t=e.sent,e.next=5,fetch("/api/v1/crm/deleteDeal",{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(t)},body:JSON.stringify({deal_id:n.id})});case 5:return r=e.sent,e.next=8,r.json();case 8:if((i=e.sent).success){e.next=11;break}throw Error(i.error);case 11:h({type:"SET_DATA",payload:{dealProfiles:c.filter(function(e){return e.id!==n.id})}});case 12:case"end":return e.stop()}},e)}))(),{loading:"Deleting…",success:"Deal removed",error:function(e){return e.message}});case 6:case"end":return e.stop()}},e)})),function(e){return L.apply(this,arguments)}),[y,h,c]),M=(0,s.useMemo)(function(){return c.filter(function(e){return(null==p||!p.orgId||e.org_id===p.orgId)&&(null==p||!p.crmId||e.crm_profile_id===p.crmId)&&(!I||e.stage===I)&&(!D||e.org_id===D)&&(!C.trim()||e.title.toLowerCase().includes(C.toLowerCase()))}).sort(function(e,n){return new Date(n.created_at)-new Date(e.created_at)})},[c,p,C,I,D]);if((0,s.useEffect)(function(){if(null!=p&&p.dealId){var e=c.find(function(e){return e.id===p.dealId});e&&(j(e),x(e.id))}else j(null),h({type:"SET_DEAL_FILTER",payload:null}),x(null)},[p]),(0,s.useEffect)(function(){if(w){var e=c.find(function(e){return e.id===w.id});e&&e!==w&&(j(e),x(e.id))}},[c]),w){var E,L,B,R,H=(null===(B=l.find(function(e){return e.id===w.org_id}))||void 0===B?void 0:B.name)||"—",$=null==f||null===(R=f.members)||void 0===R||null===(R=R.find(function(e){return e.uid===w.assignee_id}))||void 0===R?void 0:R.email;return(0,W.jsx)(t4,{deal:w,orgName:H,userData:n,assigneeMail:$,onBack:function(){j(null),h({type:"SET_DEAL_FILTER",payload:null}),x(null)}})}var F=function(e){j(e),x(e.id)};return(0,W.jsxs)(rr,{children:[(0,W.jsxs)(ri,{children:[(0,W.jsx)(ro,{placeholder:"Search title…",value:C,onChange:function(e){return k(e.target.value)}}
1),(0,W.jsxs)(ra,{value:I,onChange:function(e){return S(e.target.value)},children:[(0,W.jsx)("option",{value:"",children:"All stages"}),Object.keys(re).map(function(e){return(0,W.jsx)("option",{children:e},e)})]}),(0,W.jsxs)(ra,{value:D,onChange:function(e){return O(e.target.value)},children:[(0,W.jsx)("option",{value:"",children:"All organisations"}),l.map(function(e){return(0,W.jsx)("option",{value:e.id,children:e.name},e.id)})]})]}),0===M.length?(0,W.jsx)("p",{style:{padding:40,textAlign:"center",color:"#6b7280"},children:"No deals"}):(0,W.jsxs)(rc,{children:[(0,W.jsxs)(rd,{children:[(0,W.jsx)(ru,{children:"Organisation"}),(0,W.jsx)(ru,{children:"Title"}),(0,W.jsx)(ru,{children:"Stage"}),(0,W.jsx)(ru,{children:"Value"}),(0,W.jsx)(ru,{children:"Created"}),(0,W.jsx)(ru,{children:"Participants"}),(0,W.jsx)(ru,{children:"Actions"})]}),M.map(function(e){var n,t,r,i=(null===(t=l.find(function(n){return n.id===e.org_id}))||void 0===t?void 0:t.name)||"—",o=null==f||null===(r=f.members)||void 0===r||null===(r=r.find(function(n){return n.uid===e.assignee_id}))||void 0===r?void 0:r.email,a=ex(null==y?void 0:y.uid,e,f),s=eg(null==f?void 0:f.uid,m,"deals");return(0,W.jsxs)(rl,{children:[(0,W.jsx)(ru,{children:i}),(0,W.jsxs)(ru,{children:[e.title,o&&(0,W.jsx)("span",{title:"Assigned to ".concat(o),style:{marginLeft:6,fontSize:11,background:"#fecaca",color:"#7f1d1d",padding:"2px 6px",borderRadius:14},children:o})]}),(0,W.jsx)(ru,{children:(0,W.jsx)("div",{onClick:function(e){return e.stopPropagation()},children:(0,W.jsx)(ef.Ay,{instanceId:"deal-".concat(e.id),options:rn,value:rn.find(function(n){return n.value===e.stage}),onChange:function(n){return a&&z(e,n)},styles:rt,menuPortalTarget:document.body,isDisabled:!a})})}),(0,W.jsx)(ru,{children:null!=(n=e.value_usd)?"$".concat((+n).toLocaleString()):"—"}),(0,W.jsx)(ru,{children:T()(e.created_at).format("D MMM YYYY")}),(0,W.jsx)(ru,{children:e.member_ids.length}),(0,W.jsxs)(ru,{style:{gap:6},children:[(0,W.jsx)(rp,{onClick:function(){return F(e)},children:"View"}),(0,W.jsx)(rp,{disabled:!a||!s,style:{color:"#b91c1c",borderColor:"#fca5a5",opacity:a&&s?1:.45},onClick:function(){return a&&s&&P(e)},children:"Delete"})]})]},e.id)})]})]})}c.Ay.div.withConfig({displayName:"DealsTab__Page",componentId:"sc-1ej1zc0-9"})(["padding:24px 28px;"]),c.Ay.button.withConfig({displayName:"DealsTab__Back",componentId:"sc-1ej1zc0-10"})(["all:unset;display:flex;align-items:center;gap:6px;cursor:pointer;margin-bottom:18px;color:#6366f1;font-weight:600;"]),c.Ay.p.withConfig({displayName:"DealsTab__Field",componentId:"sc-1ej1zc0-11"})(["margin:4px 0;span{color:#6b7280;font-size:.85rem;}"]),c.Ay.h2.withConfig({displayName:"DealsTab__H1",componentId:"sc-1ej1zc0-12"})(["margin-top:0;"]);var rh=t(23512),rx=c.Ay.div.withConfig({displayName:"AddClientModal__Backdrop",componentId:"sc-19jkjdn-0"})(["position:fixed;inset:0;display:grid;place-items:center;background:rgba(0,0,0,0.45);z-index:50;"]),rg=c.Ay.div.withConfig({displayName:"AddClientModal__Card",componentId:"sc-19jkjdn-1"})(["width:460px;background:#fff;border-radius:14px;padding:24px 28px;box-shadow:0 10px 25px rgba(0,0,0,0.12);display:flex;flex-direction:column;gap:18px;h3{margin:0;font-size:1.08rem;font-weight:600;color:#111827;}"]),rm=c.Ay.div.withConfig({displayName:"AddClientModal__Row",componentId:"sc-19jkjdn-2"})(["display:flex;flex-direction:column;gap:6px;"]),rb=c.Ay.label.withConfig({displayName:"AddClientModal__Label",componentId:"sc-19jkjdn-3"})(["font-size:0.82rem;"]),ry=c.Ay.input.withConfig({displayName:"AddClientModal__Input",componentId:"sc-19jkjdn-4"})(["padding:7px 10px;font-size:0.88rem;border:1px solid #d1d5db;border-radius:6px;&:disabled{background:#f9fafb;}"]),rv=c.Ay.select.withConfig({displayName:"AddClientModal__Select",componentId:"sc-19jkjdn-5"})(["padding:7px 10px;font-size:0.88rem;border:1px solid #d1d5db;border-radius:6px;"]),rw=c.Ay.button.withConfig({displayName:"AddClientModal__Btn",componentId:"sc-19jkjdn-6"})(["align-self:flex-end;padding:10px 16px;font-weight:600;border:none;border-radius:6px;background:#6366f1;color:#fff;cursor:pointer;transition:0.15s;&:disabled{opacity:0.55;cursor:not-allowed;}"]);function rj(e){var n,t=e.onClose,o=e.onComplete,c=e.preset,l=void 0===c?{}:c,p=(0,d.mc)(),f=p.state,h=p.dispatch,x=(0,eh.hD)(g.auth),m=(0,i.A)(x,1)[0],b=(0,s.use
1State)("pick"),y=b[0],v=b[1],w=(0,s.useState)(!1),j=w[0],_=w[1],C=(0,s.useState)(""),k=C[0],A=C[1],I=(0,s.useState)(""),S=I[0],N=I[1],D=(0,s.useState)(""),T=D[0],O=D[1],z=(0,s.useState)(l.name||""),P=z[0],M=z[1],E=(0,s.useState)(l.email||""),L=E[0],B=E[1],R=(0,s.useState)(l.phone||""),H=R[0],$=R[1],F=(0,s.useCallback)(function(){if(!j){_(!0);var e,n=(e=(0,r.A)(a().mark(function e(){var n,r,i,s,c;return a().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,m.getIdToken(!0);case 2:return r=e.sent,i={teamId:(null===(n=f.currentTeam)||void 0===n?void 0:n.uid)==="PERSONAL"?null:f.currentTeam.uid,organization_id:k||null,org_name:k?null:S,org_domain:k?null:T,contact:{full_name:P,email:L,phone:H,visitorId:l.visitorId||null}},e.next=6,fetch("/api/v1/crm/upsert",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(r)},body:JSON.stringify(i)});case 6:return s=e.sent,e.next=9,s.json();case 9:if((c=e.sent).success){e.next=12;break}throw Error(c.error||"Failed");case 12:c.organization&&h({type:"ADD_ORG",payload:c.organization}),h({type:"ADD_CRM",payload:c.crm}),null==o||o(!0),t();case 16:case"end":return e.stop()}},e)})),function(){return e.apply(this,arguments)});u.o.promise(n(),{loading:"Adding client…",success:function(){return _(!1),"Client added"},error:function(e){return _(!1),null==o||o(!1),e.message}})}},[j,m,null===(n=f.currentTeam)||void 0===n?void 0:n.uid,k,S,T,P,L,H,l.visitorId,h,t,o]);return(0,W.jsx)(rx,{onClick:t,children:(0,W.jsxs)(rg,{onClick:function(e){return e.stopPropagation()},children:["pick"===y&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)("h3",{children:"Select organisation"}),(0,W.jsx)(rm,{children:(0,W.jsxs)(rv,{value:k,onChange:function(e){return A(e.target.value)},children:[(0,W.jsx)("option",{value:"",children:"— choose —"}),(f.orgProfiles||[]).map(function(e){return(0,W.jsx)("option",{value:e.id,children:e.name},e.id)})]})}),(0,W.jsx)(rw,{onClick:function(){return k?v("contact"):v("newOrg")},children:k?"Next":"Create new organisation"})]}),"newOrg"===y&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)("h3",{children:"New organisation"}),(0,W.jsxs)(rm,{children:[(0,W.jsx)(rb,{children:"Name"}),(0,W.jsx)(ry,{value:S,onChange:function(e){return N(e.target.value)},placeholder:"e.g. Splutter AI"})]}),(0,W.jsxs)(rm,{children:[(0,W.jsx)(rb,{children:"Domain"}),(0,W.jsx)(ry,{value:T,onChange:function(e){return O(e.target.value)},placeholder:"e.g. splutter.ai"})]}),(0,W.jsx)(rw,{disabled:!S.trim(),onClick:function(){return v("contact")},children:"Next"})]}),"contact"===y&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)("h3",{children:"Contact details"}),(0,W.jsxs)(rm,{children:[(0,W.jsx)(rb,{children:"Full name"}),(0,W.jsx)(ry,{value:P,onChange:function(e){return M(e.target.value)},placeholder:"e.g. Jane Doe"})]}),(0,W.jsxs)(rm,{children:[(0,W.jsx)(rb,{children:"Email"}),(0,W.jsx)(ry,{value:L,onChange:function(e){return B(e.target.value)},placeholder:"[email protected]",readOnly:!!l.email,disabled:!!l.email})]}),(0,W.jsxs)(rm,{children:[(0,W.jsx)(rb,{children:"Phone"}),(0,W.jsx)(ry,{value:H,onChange:function(e){return $(e.target.value)},placeholder:"+1 234 567 8901"})]}),(0,W.jsx)(rw,{disabled:j||!P.trim(),onClick:F,children:j?"Saving…":"Add client"})]})]})})}var r_=t(70747),rC=t(88410),rk=t(50980),rA=t(94014),rI=t(66138),rS=t(62070),rN=t(79860),rD=t(80722),rT=t(69358),rO=t(26988),rz=t(16494),rP=t(44563),rM=t(93231),rE=t(41534);function rL(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),t.push.apply(t,r)}return t}function rB(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?rL(Object(t),!0).forEach(function(n){(0,S.A)(e,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):rL(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}var rR=c.Ay.div.withConfig({displayName:"VisitorsTab__Wrapper",componentId:"sc-it923m-0"})(["display:flex;flex-direction:column;height:100%;background:#f9fafb;border-radius:12px;box-shadow:0 4px 14px rgb(0 0 0 / 6%);"]),rH=c.Ay.div.withConfig({displayName:"VisitorsTab__Toolbar",componentId:"sc-it923m-1"})(["display:flex;align-items:center;gap:12px;padding:14px 18px;background:#ffffff;border-bottom:1px solid #e5e7eb;position:sticky;top:0;z-index:15;"]),r$=c.Ay.label.withConfig({displayName:"VisitorsTab__SearchWra
1p",componentId:"sc-it923m-2"})(["position:relative;flex:1;max-width:320px;svg{position:absolute;left:10px;top:50%;transform:translateY(-50%);color:#9ca3af;}"]),rW=c.Ay.input.withConfig({displayName:"VisitorsTab__SearchBar",componentId:"sc-it923m-3"})(["width:100%;padding:7px 12px 7px 34px;font-size:0.88rem;border-radius:8px;border:1px solid #d1d5db;background:#f3f4f6;transition:0.15s;&:focus{background:#fff;outline:none;border-color:#6366f1;box-shadow:0 0 0 1px #6366f1;}"]),rF=c.Ay.span.withConfig({displayName:"VisitorsTab__CountChip",componentId:"sc-it923m-4"})(["padding:3px 10px;border-radius:9999px;font-size:0.75rem;font-weight:600;background:#eef2ff;color:#4f46e5;"]),rV=c.Ay.div.withConfig({displayName:"VisitorsTab__HeaderGrid",componentId:"sc-it923m-5"})(["display:grid;grid-template-columns:46px 1fr 1fr 0.8fr 100px 100px 80px;padding:6px 0 5px;padding-right:10px;background:#f3f4f6;font-weight:600;font-size:0.8rem;letter-spacing:0.02em;border-bottom:1px solid #e5e7eb;position:sticky;top:57px;z-index:10;box-shadow:0 1px 3px rgb(0 0 0 / 4%);padding-left:10px;"]),rU=(0,c.Ay)(rV).withConfig({displayName:"VisitorsTab__RowGrid",componentId:"sc-it923m-6"})(["font-weight:400;background:#ffffff;min-height:72px;&:nth-child(even){background:#fcfcfd;}&:hover{background:#f0f2ff;}"]),rG=c.Ay.div.withConfig({displayName:"VisitorsTab__NameLine",componentId:"sc-it923m-7"})(["font-weight:600;"]),rq=c.Ay.div.withConfig({displayName:"VisitorsTab__InfoLine",componentId:"sc-it923m-8"})(["color:#555;font-size:0.75rem;"]),rY=c.Ay.div.withConfig({displayName:"VisitorsTab__MetaLine",componentId:"sc-it923m-9"})(["color:#777;font-size:0.75rem;"]),rJ=c.Ay.div.withConfig({displayName:"VisitorsTab__UAStack",componentId:"sc-it923m-10"})(["display:flex;flex-direction:column;gap:2px;"]),rQ=c.Ay.div.withConfig({displayName:"VisitorsTab__UAItem",componentId:"sc-it923m-11"})(["display:flex;align-items:center;gap:4px;font-size:0.75rem;"]),rK=c.Ay.div.withConfig({displayName:"VisitorsTab__TimelineWrap",componentId:"sc-it923m-12"})(["position:relative;margin-top:3px;width:140px;height:6px;border-radius:3px;background:#e5e7eb;"]),rX=c.Ay.div.withConfig({displayName:"VisitorsTab__Dot",componentId:"sc-it923m-13"})(["position:absolute;top:50%;transform:translate(-50%,-50%);width:6px;height:6px;border-radius:50%;background:#10b981;"]),rZ=c.Ay.button.withConfig({displayName:"VisitorsTab__PushBtn",componentId:"sc-it923m-14"})(["width:100%;padding:6px 10px;border:none;border-radius:4px;font-size:0.75rem;background:",";color:",";cursor:",";opacity:",";"],function(e){return"grey"===e.variant?"#e5e7eb":"#6366f1"},function(e){return"grey"===e.variant?"#6b7280":"#ffffff"},function(e){return e.disabled?"not-allowed":"pointer"},function(e){return e.disabled?.6:1}),r0=c.Ay.img.withConfig({displayName:"VisitorsTab__FlagImg",componentId:"sc-it923m-15"})(["width:16px;height:12px;margin-left:4px;"]),r1=c.Ay.div.withConfig({displayName:"VisitorsTab__NoRes",componentId:"sc-it923m-16"})(["flex:1;display:flex;align-items:center;justify-content:center;color:#6b7280;font-size:0.9rem;"]),r6=Date.now(),r2=function(e){if(!e)return"-";var n=(r6-e)/1e3;return n<90?"".concat(Math.floor(n),"s ago"):(n/=60)<90?"".concat(Math.floor(n),"m ago"):(n/=60)<48?"".concat(Math.floor(n),"h ago"):(n/=24)<14?"".concat(Math.floor(n),"d ago"):(n/=7)<52?"".concat(Math.floor(n),"w ago"):T()(e).format("YYYY-MM-DD")},r5=function(e){var n=(e||"").toLowerCase();return n.includes("win")?(0,W.jsx)(rI.a,{size:14}):n.includes("android")?(0,W.jsx)(rA.Q,{size:14}):(0,W.jsx)(rS.Z,{size:14})},r8=function(e){var n=(e||"").toLowerCase();return n.includes("chrome")?(0,W.jsx)(rN.Z,{size:14}):n.includes("firefox")?(0,W.jsx)(rD.y,{size:14}):n.includes("safari")?(0,W.jsx)(rT.L,{size:14}):n.includes("edge")?(0,W.jsx)(rO.o,{size:14}):n.includes("opera")?(0,W.jsx)(rz.c,{size:14}):n.includes("brave")?(0,W.jsx)(rP.x,{size:14}):(0,W.jsx)(rM.P,{size:14})},r3=function(e){if(!e)return"Direct/None";try{return new URL(e).host||"Direct/None"}catch(e){return"Direct/None"}};function r4(){var e,n=(0,d.mc)(),t=n.state,r=n.can,o=(0,l.y)(),a=o.profiles,c=void 0===a?[]:a,p=o.events,f=void 0===p?[]:p,h=t.crmProfiles,x=void 0===h?[]:h,g=em(null===(e=t.currentTeam)||void 0===e?void 0:e.uid,r,"clients"),m=(0,s.useMemo)(function(){var e=new Set,n=new Set,t=new Set;return x.forEach(function(r){r.email&&e.add(r.email.toLowerCase()),r.phone&&n.add(r.phone),Array.isArray(r.visitor_ids)&&r.visitor_ids.forEach(function(e){return t.add(e)})}),{crmEmails:e,crmPhones:n,crmVisitorIds:t}},[x]),b=m.crmEmails,y=m.crmPhones,v=m.crmVisitorIds,w=(0,s.useMemo)(function(){var e={},n={};return f.forEach(function(t){if("stripe_payment"===t.event_type&&(null===(r=t.custom_data)||void 0===r?void 0:r.status)==="succeeded"){var r,i,o,a,s=t.visitor_id;if(s){var c=((null===(i=t.custom_data)||void 0===i?void 0:i.amount)||0)-((null===(o=t.custom_data)||void 0===o?void 0:o.amount_refunded)||0);e[s]=(e[s]||0)+c/100,!n[s]&&null!==(a=t.custom_data)&&void 0!==a&&a.email&&(n[s]=t.custom_data.email.toLowerCase())}}}),{revenueMap:e,emailOverride:n}},[f]),j=w.revenueMap,_=w.emailOverride,C=(0,s.useMemo)(function(){var e={},n={};f.forEach(function(t){var r=t.visitor_id;if(r){var i=+new Date(t.created_at||t.createdAt);(e[r]=e[r]||[]).push(i),void 0===n[r]&&(n[r]=r3(t.referrer))}});var t={};return Object.entries(e).forEach(function(e){var n=(0,i.A)(e,2),r=n[0],o=n[1],a=(0,N.A)(o).sort(function(e,n){return e-n}),s=0,c=null;a.forEach(function(e){(null===c||e-c>18e5)&&s++,c=e}),t[r]={first:a[0],last:a[a.length-1],visits:s,tsList:a}}),{stats:t,refSrc:n}},[f]),k=C.stats,A=C.refSrc,I=(0,s.useMemo)(function(){var e=c.map(function(e){var n,t,r,i=k[e.visitorId]||{},o=e.userAgentInfo||{}
1,a=(null===(n=o.device)||void 0===n?void 0:n.model)||"Desktop",s=(null===(t=o.os)||void 0===t?void 0:t.name)||"Windows",c=(null===(r=o.browser)||void 0===r?void 0:r.name)||"Chrome",d=/mobile|tablet/i.test(a)?"Mobile":"Desktop",l=e.source||e.referrer||A[e.visitorId]||"Direct/None",u=!e.email&&_[e.visitorId]?rB(rB({},e),{},{email:_[e.visitorId]}):e,p=i.visits||0,f=p+Math.max(0,30-(i.last?(r6-i.last)/864e5:1e3))/30;return rB(rB({},u),{},{firstVisit:i.first||null,lastVisit:i.last||null,visits:p,tsList:i.tsList||[],device:a,osName:s,browser:c,isMobile:d,source:l,totalRevenue:j[e.visitorId]||0,lowInterest:f<2})}),n=new Map;return e.forEach(function(e){var t="".concat(e.visitorId,"|").concat(e.countryCode||"XX","|").concat(e.device),r=n.get(t);if(!r){n.set(t,e);return}var i=!!r.email,o=!!e.email,a=(e.lastVisit||0)>(r.lastVisit||0);!i&&o?n.set(t,e):i&&!o||a&&n.set(t,e)}),(0,N.A)(n.values()).sort(function(e,n){return(n.lastVisit||0)-(e.lastVisit||0)})},[c,k,A,_,j]),S=(0,s.useState)(""),D=S[0],T=S[1],O=(0,s.useState)(new Set),z=O[0],P=O[1],M=(0,s.useState)(!1),E=M[0],L=M[1],B=(0,s.useState)(!1),R=B[0],H=B[1],F=(0,s.useState)(!1),V=F[0],U=F[1],G=(0,s.useState)(null),q=G[0],Y=G[1],J=(0,s.useMemo)(function(){var e=I;if(E&&(e=e.filter(function(e){return e.visits>1})),R&&(e=e.filter(function(e){return(e.email||"").includes("@")})),V&&(e=e.filter(function(e){return!e.lowInterest})),!D.trim())return e;var n=D.toLowerCase().split(/\s+/).filter(Boolean);return e.filter(function(e){var t=("".concat(e.displayName||""," ").concat(e.name||""," ").concat(e.email||""," ").concat(e.phone||""," ")+"".concat(e.visitorId||""," ").concat(e.source||""," ").concat(e.device||""," ")+"".concat(e.osName||""," ").concat(e.browser||""," ").concat(e.countryCode||"")).toLowerCase();return n.every(function(e){return t.includes(e)})})},[I,D,E,R,V]),Q=(0,s.useCallback)(function(e){if(!g){u.o.error("You don’t have permission to create clients");return}if(e.visitorId){var n=e.visitorId;P(function(e){return new Set(e).add(n)}),Y(rB(rB({},e),{},{onComplete:function(e){P(function(e){var t=new Set(e);return t.delete(n),t}),e||u.o.error("Failed to add client")}}))}},[g]),K=(0,s.useCallback)(function(e){var n,t=e.index,r=e.key,i=e.style,o=J[t];if(!o)return null;var a=o.name||o.displayName||(o.visitorId?"Visitor ".concat(o.visitorId.slice(0,6)):"Visitor"),s=!o.visitorId,c=(n=o.countryCode)?"https://purecatamphetamine.github.io/country-flag-icons/3x2/".concat(n.toUpperCase(),".svg"):"",d=r2(o.firstVisit),l=r2(o.lastVisit),u=r6-(o.firstVisit||r6),p="Direct/None"===o.source||"(none)"===o.source||!o.source||o.source.includes("localhost"),f=!!(o.email||o.phone),h=v.has(o.visitorId)||o.email&&b.has(o.email.toLowerCase())||o.phone&&y.has(o.phone),x=z.has(o.visitorId),m=!g||!f||h||x;return(0,W.jsxs)(rU,{style:rB(rB({},i),{},{width:"100%",background:s?"#fef2f2":void 0}),children:[(0,W.jsx)("div",{children:(0,W.jsx)($.A,rB(rB({style:{width:36,height:36}},o.avatarConfig||{}),{},{shape:"circle"}))}),(0,W.jsxs)("div",{children:[(0,W.jsxs)(rG,{children:[a,c&&(0,W.jsx)(r0,{src:c,alt:""})]}),(0,W.jsx)(rq,{children:o.email||"-"}),(0,W.jsx)(rq,{children:o.phone||"-"})]}),(0,W.jsxs)("div",{children:[(0,W.jsxs)(rY,{children:["First: ",d]}),(0,W.jsxs)(rY,{children:["Last\xa0: ",l]}),(0,W.jsxs)(rY,{children:[o.visits," visit",1===o.visits?"":"s"]}),u>0&&(0,W.jsx)(rK,{children:o.tsList.slice(0,100).map(function(e){var n=(e-o.firstVisit)/u*100;return(0,W.jsx)(rX,{style:{left:"".concat(n,"%")}},e)})})]}),(0,W.jsx)("div",{children:p?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(rE.G,{size:16,style:{marginRight:4}}),o.source]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)("img",{src:"https://www.google.com/s2/favicons?domain=".concat(o.source),alt:"",style:{width:16,height:16,marginRight:4}}),o.source]})}),(0,W.jsx)("div",{children:(0,W.jsxs)(rJ,{children:[(0,W.jsxs)(rQ,{children:["Desktop"===o.isMobile?(0,W.jsx)(rC.X,{size:14}):(0,W.jsx)(rk.f,{size:14}),o.device]}),(0,W.jsxs)(rQ,{children:[r5(o.osName),o.osName]}),(0,W.jsxs)(rQ,{children:[r8(o.browser),o.browser]})]})}),(0,W.jsx)("div",{children:o.totalRevenue>
10?"$".concat(o.totalRevenue.toLocaleString()):"-"}),(0,W.jsx)("div",{style:{display:"flex",alignItems:"center"},children:(0,W.jsx)(rZ,{variant:f?"blue":"grey",disabled:m,style:x?{background:"#facc15",color:"#78350f",fontWeight:700}:void 0,onClick:function(){return!m&&Q(o)},children:h?"View in Clients":x?"Adding…":"Push to Clients"})})]},r)},[J,b,y,Q]);return(0,W.jsxs)(rR,{children:[q&&(0,W.jsx)(rj,{preset:{name:q.name,email:q.email,phone:q.phone,visitorId:q.visitorId},onClose:function(){return Y(null)},onComplete:q.onComplete}),(0,W.jsxs)(rH,{children:[(0,W.jsxs)(r$,{children:[(0,W.jsx)(r_.v,{size:18}),(0,W.jsx)(rW,{placeholder:"Search visitors…",value:D,onChange:function(e){return T(e.target.value)}})]}),(0,W.jsxs)(r7,{children:[(0,W.jsx)("input",{type:"checkbox",checked:E,onChange:function(e){return L(e.target.checked)}}),">1 visit"]}),(0,W.jsxs)(r7,{children:[(0,W.jsx)("input",{type:"checkbox",checked:R,onChange:function(e){return H(e.target.checked)}}),"has email"]}),(0,W.jsxs)(r7,{children:[(0,W.jsx)("input",{type:"checkbox",checked:V,onChange:function(e){return U(e.target.checked)}}),"high\xa0interest"]}),(0,W.jsxs)(rF,{children:[J.length.toLocaleString()," found"]})]}),(0,W.jsxs)(rV,{children:[(0,W.jsx)("div",{}),(0,W.jsx)("div",{children:"Visitor"}),(0,W.jsx)("div",{children:"Activity"}),(0,W.jsx)("div",{children:"Source"}),(0,W.jsx)("div",{children:"Device"}),(0,W.jsx)("div",{children:"Revenue"}),(0,W.jsx)("div",{children:"Action"})]}),0===J.length?(0,W.jsx)(r1,{children:"No matching visitors."}):(0,W.jsx)("div",{style:{flex:1,minHeight:300},children:(0,W.jsx)(rh.t$,{children:function(e){var n=e.height,t=e.width;return(0,W.jsx)(rh.B8,{width:t,height:n,rowCount:J.length,rowHeight:72,rowRenderer:K,overscanRowCount:10})}})})]})}var r7=c.Ay.label.withConfig({displayName:"VisitorsTab__FilterCheck",componentId:"sc-it923m-17"})(["display:flex;align-items:center;gap:4px;font-size:0.75rem;white-space:nowrap;cursor:pointer;input{margin:0;accent-color:#6366f1;}"]),r9=t(40469),ie=t(36797),it=t(39206);function ir(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),t.push.apply(t,r)}return t}function ii(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?ir(Object(t),!0).forEach(function(n){(0,S.A)(e,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ir(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}var io=c.Ay.div.withConfig({displayName:"CRMPermModal__BG",componentId:"sc-nkaaca-0"})(["position:fixed;inset:0;display:grid;place-items:center;backdrop-filter:blur(2px);background:rgba(0,0,0,.45);z-index:9999;"]),ia=c.Ay.div.withConfig({displayName:"CRMPermModal__Card",componentId:"sc-nkaaca-1"})(["width:600px;max-width:95%;background:#fff;border-radius:10px;box-shadow:0 10px 30px rgba(0,0,0,.25);padding:24px;display:flex;flex-direction:column;gap:18px;"]),is=c.Ay.table.withConfig({displayName:"CRMPermModal__Grid",componentId:"sc-nkaaca-2"})(["width:100%;border-collapse:collapse;font-size:.82rem;th,td{border:1px solid #e5e7eb;padding:8px;text-align:center;}th{background:#f3f4f6;font-weight:600;}"]),ic=c.Ay.button.withConfig({displayName:"CRMPermModal__Toggle",componentId:"sc-nkaaca-3"})(["all:unset;cursor:pointer;width:24px;height:24px;border:2px solid #6366f1;justify-self:center;border-radius:4px;display:grid;place-items:center;background:",";svg{color:#fff;width:18px;display:",";}"],function(e){return e.on?"#6366f1":"#fff"},function(e){return e.on?"block":"none"}),id=c.Ay.div.withConfig({displayName:"CRMPermModal__BtnRow",componentId:"sc-nkaaca-4"})(["display:flex;gap:12px;justify-content:flex-end;"]),il=c.Ay.button.withConfig({displayName:"CRMPermModal__Btn",componentId:"sc-nkaaca-5"})(["padding:7px 14px;border-radius:8px;font-weight:600;font-size:.82rem;border:none;background:",";color:",";opacity:",";cursor:",";"],function(e){return e.primary?"#6366f1":"#e5e7eb"},function(e){return e.primary?"#fff":"#111"},function(e){return e.disabled?.45:1},function(e){return e.disabled?"default":"pointer"}),iu=["visitors","clients","deals","teams"],ip=["c","r","u","d"],ih={visitors:{c:!1,r:!0,u:!1,d:!1},clients:{c:!1,r:!0,u:!0,d:!1},deals:{c:!0,r:!0,u:!0,d:!1},teams:{c:!1,r:!1,u:!1,d:!1}};function ix(e){var n=e.teamId,t=e.member,i=e.onClose,o=e.refreshPerms,c=(0,s.use
1State)(null),d=c[0],l=c[1],p=(0,s.useState)(!1),f=p[0],x=p[1];if((0,s.useEffect)(function(){(0,r.A)(a().mark(function e(){var r,o;return a().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,(0,h.xI)().currentUser.getIdToken(!0);case 3:return r=e.sent,e.next=6,fetch("/api/v1/teams/crmperms?team=".concat(n,"&user=").concat(t.uid),{headers:{Authorization:"Bearer ".concat(r)}}).then(function(e){return e.json()});case 6:if((o=e.sent).success){e.next=9;break}throw Error(o.error);case 9:l(ii(ii({},ih),o.matrix||{})),e.next=16;break;case 12:e.prev=12,e.t0=e.catch(0),u.o.error(e.t0.message),i();case 16:case"end":return e.stop()}},e,null,[[0,12]])}))()},[n]),!d)return null;function g(){return(g=(0,r.A)(a().mark(function e(){var r,s,c;return a().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return x(!0),e.prev=1,e.next=4,(0,h.xI)().currentUser.getIdToken(!0);case 4:return r=e.sent,s={teamId:n,targetUid:t.uid,matrix:d},e.next=8,fetch("/api/v1/teams/crmperms",{method:"PATCH",headers:{Authorization:"Bearer ".concat(r),"Content-Type":"application/json"},body:JSON.stringify(s)}).then(function(e){return e.json()});case 8:if((c=e.sent).success){e.next=11;break}throw Error(c.error);case 11:u.o.success("Permissions updated"),null==o||o(),i(),e.next=19;break;case 16:e.prev=16,e.t0=e.catch(1),u.o.error(e.t0.message);case 19:return e.prev=19,x(!1),e.finish(19);case 22:case"end":return e.stop()}},e,null,[[1,16,19,22]])}))).apply(this,arguments)}return(0,W.jsx)(io,{onClick:i,children:(0,W.jsxs)(ia,{onClick:function(e){return e.stopPropagation()},children:[(0,W.jsxs)("h3",{style:{margin:0},children:["CRM permissions → ",t.email]}),(0,W.jsxs)(is,{children:[(0,W.jsx)("thead",{children:(0,W.jsxs)("tr",{children:[(0,W.jsx)("th",{}),ip.map(function(e){return(0,W.jsx)("th",{children:"c"==e?"Create":"r"==e?"Read":"u"==e?"Update":"Delete"},e)})]})}),(0,W.jsx)("tbody",{children:iu.map(function(e){return(0,W.jsxs)("tr",{children:[(0,W.jsx)("td",{style:{textTransform:"capitalize",textAlign:"left"},children:e}),ip.map(function(n){var t;return(0,W.jsx)("td",{children:(0,W.jsx)(ic,{onClick:function(){l(function(t){return ii(ii({},t),{},(0,S.A)({},e,ii(ii({},t[e]),{},(0,S.A)({},n,!t[e][n]))))})},on:!!(null!=d&&null!==(t=d[e])&&void 0!==t&&t[n]),children:(0,W.jsx)(it.J,{})})},n)})]},e)})})]}),(0,W.jsxs)(id,{children:[(0,W.jsx)(il,{onClick:i,disabled:f,children:"Cancel"}),(0,W.jsx)(il,{primary:!0,onClick:function(){return g.apply(this,arguments)},disabled:f,children:"Save"})]})]})})}var ig=t(72001),im=c.Ay.div.withConfig({displayName:"AssignDealModal__ModalBG",componentId:"sc-944rca-0"})(["position:fixed;inset:0;display:grid;place-items:center;background:rgba(0,0,0,.35);z-index:60;"]),ib=c.Ay.div.withConfig({displayName:"AssignDealModal__Modal",componentId:"sc-944rca-1"})(["width:460px;max-width:90%;background:#fff;border-radius:12px;padding:28px 34px;display:flex;flex-direction:column;gap:18px;"]),iy=c.Ay.input.withConfig({displayName:"AssignDealModal__Search",componentId:"sc-944rca-2"})(["padding:7px 10px;border:1px solid #d1d5db;border-radius:6px;width:100%;&:focus{outline:none;border-color:#6366f1;box-shadow:0 0 0 1px #6366f1;}"]),iv=c.Ay.div.withConfig({displayName:"AssignDealModal__List",componentId:"sc-944rca-3"})(["max-height:220px;overflow-y:auto;border:1px solid #e5e7eb;border-radius:6px;"]),iw=c.Ay.div.withConfig({displayName:"AssignDealModal__Row",componentId:"sc-944rca-4"})(["display:flex;gap:10px;align-items:center;padding:8px 10px;cursor:pointer;background:",";&:hover{background:",";}"],function(e){return e.sel?"#eef2ff":"#fff"},function(e){return e.sel?"#e0e7ff":"#f9fafb"}),ij=c.Ay.div.withConfig({displayName:"AssignDealModal__CheckBox",componentId:"sc-944rca-5"})(["flex:0 0 18px;height:18px;border:1.8px solid #d1d5db;border-radius:4px;display:grid;place-items:center;color:#fff;font-size:12px;background:",";svg{display:",";}"],function(e){return e.sel?"#6366f1":"transparent"},function(e){return e.sel?"block":"none"}),i_=c.Ay.button.withConfig({displayName:"AssignDealModal__Btn2",componentId:"sc-944rca-6"})(["padding:8px 20px;font-weight:600;border:none;border-radius:6px;cursor:pointer;transition:background .18s;"," &:disabled{opacity:.55;cursor:not-allowed;}"],function(e){return e.primary?"\n    background:#6366f1;color:#fff;\n    &:hover:not(:disabled){background:#4f46e5;}\n  ":"\n    background:#e5e7eb;color:#111827;\n    &:hover:not(:disabled){background:#d1d5db;}\n  "}),iC={New:{bg:"#e5e7eb",txt:"#374151"},Qualified:{bg:"#bfdbfe",txt:"#1e3a8a"},Proposal:{bg:"#fde68a",txt:"#78350f"},Won:{bg:"#bbf7d0",txt:"#065f46"},Lost:{bg:"#fecaca",txt:"#7f1d1d"}},ik=c.Ay.span.withConfig({displayName:"AssignDealModal__Pill",componentId:"sc-944rca-7"})(["font-size:.65rem;font-weight:600;border-radius:9999px;padding:1px 7px;background:",";color:",";"],function(e){var n;return null===(n=iC[e.stage])||void 0===n?void 0:n.bg},function(e){var n;return null===(n=iC[e.stage])||void 0===n?void 0:n.txt}),iA=function(e){var n,t=e.member,i=e.deals,o=e.close,c=e.dispatch,d=(0,s.use
1State)([]),l=d[0],p=d[1],f=(0,s.useState)(!1),x=f[0],g=f[1],m=(0,s.useState)(""),b=m[0],y=m[1],v=(0,s.useMemo)(function(){var e=b.trim().toLowerCase();return e?i.filter(function(n){return n.title.toLowerCase().includes(e)}):i},[b,i]),w=(n=(0,r.A)(a().mark(function e(){var n,r;return a().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(l.length){e.next=3;break}return o(),e.abrupt("return");case 3:return g(!0),e.prev=4,e.next=7,(0,h.xI)().currentUser.getIdToken(!0);case 7:return n=e.sent,e.next=10,fetch("/api/v1/crm/assignDeal",{method:"PATCH",headers:{Authorization:"Bearer ".concat(n),"Content-Type":"application/json"},body:JSON.stringify({deal_ids:l,assignee_id:t.uid})}).then(function(e){return e.json()});case 10:if((r=e.sent).success){e.next=13;break}throw Error(r.error);case 13:r.deals.forEach(function(e){return c({type:"PATCH_DEAL",payload:e})}),u.o.success("Assigned ".concat(l.length," deal").concat(l.length>1?"s":""," to ").concat(t.email)),o(),e.next=21;break;case 18:e.prev=18,e.t0=e.catch(4),u.o.error(e.t0.message);case 21:return e.prev=21,g(!1),e.finish(21);case 24:case"end":return e.stop()}},e,null,[[4,18,21,24]])})),function(){return n.apply(this,arguments)});return(0,W.jsx)(im,{onClick:o,children:(0,W.jsxs)(ib,{onClick:function(e){return e.stopPropagation()},children:[(0,W.jsxs)("h3",{style:{margin:0},children:["Assign deals to ",t.email]}),(0,W.jsx)(iy,{placeholder:"Search deals…",value:b,onChange:function(e){return y(e.target.value)}}),(0,W.jsxs)(iv,{children:[0===v.length&&(0,W.jsx)("p",{style:{padding:12,color:"#6b7280"},children:"No matching deals"}),v.map(function(e){return(0,W.jsxs)(iw,{sel:l.includes(e.id),onClick:function(){var n;return n=e.id,p(function(e){return e.includes(n)?e.filter(function(e){return e!==n}):[].concat((0,N.A)(e),[n])})},children:[(0,W.jsx)(ij,{sel:l.includes(e.id),children:(0,W.jsx)(ig.J,{})}),(0,W.jsx)("div",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.title}),(0,W.jsx)(ik,{stage:e.stage,children:e.stage})]},e.id)})]}),(0,W.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[(0,W.jsx)(i_,{onClick:o,disabled:x,children:"Cancel"}),(0,W.jsx)(i_,{primary:!0,onClick:w,disabled:x||!l.length,children:x?"Saving…":"Assign"})]})]})})};function iI(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),t.push.apply(t,r)}return t}function iS(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?iI(Object(t),!0).forEach(function(n){(0,S.A)(e,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):iI(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}var iN=c.Ay.div.withConfig({displayName:"TeamsTab__Wrap",componentId:"sc-1ug0mvb-0"})(["padding:22px 26px;"]),iD=c.Ay.div.withConfig({displayName:"TeamsTab__Top",componentId:"sc-1ug0mvb-1"})(["display:flex;align-items:center;justify-content:space-between;margin-bottom:14px;"]),iT=c.Ay.h2.withConfig({displayName:"TeamsTab__Title",componentId:"sc-1ug0mvb-2"})(["margin:0;font-size:1.25rem;display:flex;align-items:center;gap:6px;"]),iO=c.Ay.button.withConfig({displayName:"TeamsTab__Btn",componentId:"sc-1ug0mvb-3"})(["all:unset;cursor:pointer;color:#6366f1;border:1px solid #6366f1;padding:4px 10px;border-radius:6px;font-size:.82rem;display:flex;align-items:center;gap:4px;&:hover{background:#eef2ff;}"]),iz=c.Ay.table.withConfig({displayName:"TeamsTab__Table",componentId:"sc-1ug0mvb-4"})(["width:100%;border-collapse:collapse;font-size:.88rem;th,td{padding:8px 10px;text-align:left;border-bottom:1px solid #e5e7eb;vertical-align:top;}th{font-weight:600;background:#f8f9ff;}"]),iP=c.Ay.span.withConfig({displayName:"TeamsTab__Tag",componentId:"sc-1ug0mvb-5"})(["background:#f1f5f9;border-radius:12px;padding:2px 6px;font-size:.75rem;margin-left:6px;"]),iM=c.Ay.button.withConfig({displayName:"TeamsTab__ActionBtn",componentId:"sc-1ug0mvb-6"})(["all:unset;cursor:pointer;padding:4px 10px;font-size:.78rem;border-radius:6px;background:#6366f1;color:#fff;&:hover{background:#4f46e5;}"]),iE=c.Ay.button.withConfig({displayName:"TeamsTab__DealCard",componentId:"sc-1ug0mvb-7"})(["all:unset;display:block;width:100%;cursor:pointer;margin-bottom:4px;padding:6px 8px;border:1px solid #e5e7eb;border-radius:6px;background:#fff;&:hover{background:#f3f4f6;}h6{margin:0;font-size:.78rem;font-weight:600;display:flex;justify-content:space-between;gap:6px;}span{font-size:.7rem;color:#6b7280;}"]),iL={New:{bg:"#e5e7eb",txt:"#374151"},Qualified:{bg:"#bfdbfe",txt:"#1e3a8a"},Proposal:{bg:"#fde68a",txt:"#78350f"},Won:{bg:"#bbf7d0",txt:"#065f46"},Lost:{bg:"#fecaca",txt:"#7f1d1d"}},iB=c.Ay.span.withConfig({displayName:"TeamsTab__Pill",componentId:"sc-1ug0mvb-8"})(["font-size:.65rem;font-weight:600;border-radius:9999px;padding:1px 7px;background:",";color:",";"],function(e){var n;return null===(n=iL[e.stage])||void 0===n?void 0:n.bg},function(e){var n;return null===(n=iL[e.stage])||void 0===n?void 0:n.txt}),iR=c.Ay.div.withConfig({displayName:"TeamsTab__Card",componentId:"sc-1ug0mvb-9"})(["max-width:460px;margin:40px auto;
1padding:24px 26px;border:1px solid #e5e7eb;border-radius:8px;background:#fff;display:flex;flex-direction:column;gap:16px;"]),iH=c.Ay.input.withConfig({displayName:"TeamsTab__Input",componentId:"sc-1ug0mvb-10"})(["padding:8px 10px;border:1px solid #d1d5db;border-radius:6px;font-size:.88rem;width:100%;"]),i$=c.Ay.div.withConfig({displayName:"TeamsTab__LinkBox",componentId:"sc-1ug0mvb-11"})(["display:flex;gap:8px;align-items:center;background:#f9fafb;border:1px solid #d1d5db;border-radius:6px;padding:6px 10px;font-size:.8rem;word-break:break-all;"]),iW=c.Ay.button.withConfig({displayName:"TeamsTab__CopyBtn",componentId:"sc-1ug0mvb-12"})(["all:unset;cursor:pointer;display:flex;align-items:center;padding:4px;border-radius:4px;color:#6366f1;&:hover{background:#eef2ff;}"]),iF=(0,c.Ay)(iO).withConfig({displayName:"TeamsTab__Submit",componentId:"sc-1ug0mvb-13"})(["align-self:flex-end;background:#6366f1;color:#fff;border:none;&:disabled{opacity:.4;pointer-events:none;}"]),iV=c.Ay.div.withConfig({displayName:"TeamsTab__SeatDot",componentId:"sc-1ug0mvb-14"})(["width:18px;height:18px;border:2px solid ",";border-radius:50%;background:",";cursor:",";transition:background 120ms;margin:0 auto;"],function(e){return e.admin?"#fa6d15":"#6366f1"},function(e){var n=e.admin,t=e.active;return n?"#fa6d15":t?"#6366f1":"transparent"},function(e){return e.clickable?"pointer":"default"}),iU=c.Ay.div.withConfig({displayName:"TeamsTab__SeatCard",componentId:"sc-1ug0mvb-15"})(["display:inline-flex;align-items:center;padding:6px 10px 6px 14px;border:1px solid #e0e7ff;border-radius:10px;background:#f8f9ff;"]),iG=c.Ay.div.withConfig({displayName:"TeamsTab__MeterShell",componentId:"sc-1ug0mvb-16"})(["position:relative;width:62px;height:8px;border-radius:5px;background:#e5e7eb;overflow:hidden;"]),iq=c.Ay.div.withConfig({displayName:"TeamsTab__MeterFill",componentId:"sc-1ug0mvb-17"})(["position:absolute;inset:0;background:#6366f1;width:","%;transition:width .3s;"],function(e){return e.pct}),iY=c.Ay.span.withConfig({displayName:"TeamsTab__Count",componentId:"sc-1ug0mvb-18"})(["font-size:.8rem;font-weight:600;color:#374151;min-width:46px;text-align:center;"]),iJ=c.Ay.div.withConfig({displayName:"TeamsTab__Stepper",componentId:"sc-1ug0mvb-19"})(["display:flex;align-items:center;border:1px solid #6366f1;border-radius:8px;overflow:hidden;margin-right:5px;"]),iQ=c.Ay.button.withConfig({displayName:"TeamsTab__StepBtn",componentId:"sc-1ug0mvb-20"})(["all:unset;cursor:pointer;display:grid;place-content:center;width:26px;height:24px;color:#6366f1;font-weight:700;user-select:none;&:hover{background:#eef2ff;}"]),iK=c.Ay.input.attrs({type:"number",min:1}).withConfig({displayName:"TeamsTab__QtyBox",componentId:"sc-1ug0mvb-21"})(["width:36px;padding:0;border:none;text-align:center;font-size:.8rem;background:#fff;outline:none;"]);function iX(e){var n,t,i,o,c,l,p,f,b=e.userData,y=(0,d.mc)(),w=y.state,j=y.dispatch,_=y.setActiveDealId,C=w.currentTeam,k=w.dealProfiles||[],S=w.meetingProfiles||[],N=(null==C?void 0:C.members)||[],D=null===(i=(0,h.xI)().currentUser)||void 0===i?void 0:i.uid,O=(0,s.useState)("list"),z=O[0],P=O[1],M=(0,s.useState)(""),E=M[0],L=M[1],B=(0,s.useState)(!1),R=B[0],H=B[1],$=(0,s.useState)(null),F=$[0],V=$[1],U=(0,s.useState)(null),G=U[0],q=U[1],Y=(0,s.useState)(1),J=Y[0],Q=Y[1],K=(0,m.useRouter)(),X=(0,s.useState)(!1),Z=X[0],ee=X[1],en=N.some(function(e){return e.uid===D&&"admin"===e.role}),et=null!==(o=null==b||null===(c=b.subData)||void 0===c?void 0:c.seats)&&void 0!==o?o:0;null==b||null===(l=b.usageData)||void 0===l||l.seats;var er=(0,s.useState)(function(){return new Set(N.filter(function(e){return e.hasSeat}).map(function(e){return e.uid}))}),ei=er[0],eo=er[1],ea=Math.max(et-(null!==(p=null==C||null===(f=C.usageData)||void 0===f?void 0:f.seats)&&void 0!==p?p:0),0);function es(){return(es=(0,r.A)(a().mark(function e(n){var t,i;return a().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(en){e.next=2;break}return e.abrupt("return");case 2:return t=!ei.has(n),eo(function(e){var r=new Set(e);return t?r.add(n):r.delete(n),r}),e.next=6,(0,h.xI)().currentUser.getIdToken();case 6:return i=e.sent,e.next=9,u.o.promise((0,r.A)(a().mark(function e(){var r,o;return a().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch("/api/v1/teams/seats",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(i)},body:JSON.stringify({teamId:C.uid,memberUid:n,assign:t})});case 2:if((o=e.sent).ok){e.next=9;break}return e.t0=Error,e.next=7,o.text();case 7:throw e.t1=e.sent,new e.t0(e.t1);case 9:return j({type:"SET_TEAM_DETAILS",payload:{usageData:iS(iS({},C.usageData||{}),{},{seats:((null===(r=C.usageData)||void 0===r?void 0:r.seats)||0)+(t?1:-1)})}}),e.abrupt("return",t);case 11:case"end":return e.stop()}},e)}))(),{loading:t?"Assigning seat…":"Removing seat…",success:function(e){return e?"Seat assigned":"Seat removed"},error:function(e){return eo(function(e){var r=new Set(e);return t?r.delete(n):r.add(n),r}),e.message||"Could not update seat"}});case 9:case"end":return e.stop()}},e)}))).apply(this,arguments)}function ec(){return(ec=(0,r.A)(a().mark(function e(){var n,t;return a().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(en){e.next=2;break}return e.abrupt("return");case 2:if(!Z){e.next=4;break}return e.abrupt("return");case 4:return ee(!0),e.prev=5,n=[{priceId:"price_1Rny0bDOj40aI7mMVKbudsDy",quantity:J}],e.next=9,(0,x.my)(g.default,n);case 9:t=e.sent,K.push(t),e.next=17;break;case 13:e.prev=13,e.t0=e.catch(5),console.error(e.t0),u.o.error(e.t0.message||"Checkout failed");case 17:return e.prev=17,ee(!1),e.finish(17);case 20:case"end":return e.stop()}},e,null,[[5,13,17,20]])}))).apply(this,arguments)}var ed=(0,s.useMemo)(function(){return N.map(function(e){var n=k.filter(function(n){return n.assignee_id===e.uid}),t=k.filter(function(n){return(n.member_ids||[]).includes(e.uid)}),r=S.filter(function(e){return t.some(function(n){return n.id===e.deal_id})}).length;return iS(iS({},e),{},{owns:n,deals:t.length,meets:r})})},[N,k,S]),el="https://www.splutter.ai/invites?teamId=".concat(null==C?void 0:C.uid),eu=(n=(0,r.A)(a().mark(function e(){return a().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,navigator.clipboard.writeText(el);case 3:u.o.success("Link copied"),e.next=9;break;case 6:e.prev=6,e.t0=e.catch(0),u.o.error("Could not copy");case 9:case"end":return e.stop()}},e,null,[[0,6]])})),function(){return n.apply(this,arguments)}),ep=(t=(0,r.A)(a().mark(function e(){var n,t,r;return a().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n=E.trim(),/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n)){e.
1next=4;break}return u.o.error("Enter a valid e-mail"),e.abrupt("return");case 4:return H(!0),e.prev=5,e.next=8,(0,h.xI)().currentUser.getIdToken();case 8:return t=e.sent,e.next=11,fetch("/api/v1/teams/update",{method:"POST",headers:{Authorization:"Bearer ".concat(t),"Content-Type":"application/json"},body:JSON.stringify({teamId:C.uid,emailAddress:n})});case 11:if((r=e.sent).ok){e.next=18;break}return e.t0=Error,e.next=16,r.text();case 16:throw e.t1=e.sent,new e.t0(e.t1);case 18:u.o.success("Invitation sent"),L(""),P("list"),e.next=26;break;case 23:e.prev=23,e.t2=e.catch(5),u.o.error(e.t2.message);case 26:return e.prev=26,H(!1),e.finish(26);case 29:case"end":return e.stop()}},e,null,[[5,23,26,29]])})),function(){return t.apply(this,arguments)});return(0,W.jsxs)(iN,{children:[(0,W.jsx)(u.l,{position:"bottom-right",richColors:!0}),(0,W.jsxs)(iD,{children:[(0,W.jsxs)(iT,{children:[(0,W.jsx)(v.z,{size:20})," Team members"]}),en&&(0,W.jsxs)(iU,{children:[(0,W.jsx)(iG,{children:(0,W.jsx)(iq,{pct:et?(et-ea)/et*100:0})}),(0,W.jsxs)(iY,{children:[et-ea,"/",et]}),(0,W.jsxs)(iJ,{children:[(0,W.jsx)(iQ,{onClick:function(){return Q(function(e){return Math.max(1,e-1)})},children:(0,W.jsx)(A.H,{size:12})}),(0,W.jsx)(iK,{value:J,onChange:function(e){return Q(Math.max(1,parseInt(e.target.value)||1))}}),(0,W.jsx)(iQ,{onClick:function(){return Q(function(e){return e+1})},children:(0,W.jsx)(I.F,{size:12})})]}),(0,W.jsx)(iO,{style:{background:"#6366f1",color:"#fff"},disabled:Z,onClick:function(){return ec.apply(this,arguments)},children:Z?"Redirecting…":"Buy\xa0Seats"})]}),(0,W.jsx)(iO,{onClick:function(){return P(function(e){return"list"===e?"invite":"list"})},children:"list"===z?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(I.F,{size:16}),"Invite"]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ie.k,{size:16}),"Back"]})})]}),"list"===z?(0,W.jsx)(function(){return(0,W.jsxs)(iz,{children:[(0,W.jsx)("thead",{children:(0,W.jsxs)("tr",{children:[en&&(0,W.jsx)("th",{style:{width:"40px",textAlign:"center"},children:"Seat"}),(0,W.jsx)("th",{style:{width:"150px"},children:"Email"}),(0,W.jsx)("th",{style:{width:"150px"},children:"Owned Deals"}),(0,W.jsx)("th",{style:{width:"100px"},children:"Deals"}),(0,W.jsx)("th",{style:{width:"100px"},children:"Meetings"}),(0,W.jsx)("th",{style:{width:"150px"}})]})}),(0,W.jsx)("tbody",{children:ed.map(function(e){var n="admin"===e.role,t=ei.has(e.uid);return(0,W.jsxs)("tr",{children:[en&&(0,W.jsx)("td",{style:{justifyContent:"center",alignItems:"center"},children:(0,W.jsx)(iV,{admin:n,active:n||t,clickable:!n,onClick:n?void 0:function(){return function(e){return es.apply(this,arguments)}(e.uid)},title:n?"Admins don’t consume seats":t?"Seat assigned":"Assign seat"})}),(0,W.jsxs)("td",{children:[e.email,"ACCEPTED"!==e.status&&(0,W.jsx)(iP,{children:e.status})]}),(0,W.jsxs)("td",{style:{width:230,minWidth:230},children:[0===e.owns.length&&"—",e.owns.slice(0,3).map(function(e){return(0,W.jsxs)(iE,{onClick:function(){var n;return j({type:"SET_DEAL_FILTER",payload:{orgId:e.org_id,dealId:e.id}}),_(e.id),void(null==(n=document.querySelector('[data-tab="3"]'))||n.click())},children:[(0,W.jsxs)("h6",{children:[e.title,(0,W.jsx)(iB,{stage:e.stage,children:e.stage})]}),(0,W.jsxs)("span",{children:[null!=e.value_usd?"$".concat((+e.value_usd).toLocaleString()):"—"," \xb7"," ",T()(e.created_at).format("D MMM YY")]})]},e.id)}),e.owns.length>3&&(0,W.jsxs)("span",{style:{fontSize:11,color:"#6b7280"},children:["+",e.owns.length-3," more"]})]}),(0,W.jsx)("td",{children:e.deals}),(0,W.jsx)("td",{children:e.meets}),(0,W.jsxs)("td",{style:{display:"flex",gap:6},children:[(0,W.jsx)(iM,{onClick:function(){return V(e)},children:"Assign Deal"}),en&&(0,W.jsx)(iM,{style:{marginLeft:6},onClick:function(){return q(e)},children:"CRM Perms"})]})]},e.uid)})})]})},{}):(0,W.jsx)(function(){return(0,W.jsxs)(iR,{children:[(0,W.jsx)("h3",{style:{margin:0},children:"Invite a team-mate"}),(0,W.jsx)("label",{style:{fontSize:".82rem",fontWeight:600},children:"Public invite link"}),(0,W.jsxs)(i$,{children:[(0,W.jsx)("span",{style:{flex:1},children:el}),(0,W.jsx)(iW,{onClick:eu,children:(0,W.jsx)(r9.Q,{size:16})})]}),(0,W.jsx)("label",{style:{fontSize:".82rem",fontWeight:600,marginTop:6},children:"Send email invite"}),(0,W.jsx)(iH,{placeholder:"[email protected]",value:E,onChange:function(e){return L(e.target.value)}}),(0,W.jsx)(iF,{onClick:ep,disabled:R||!E.trim(),children:R?"Sending…":"Send invite"})]})},{}),F&&(0,W.jsx)(iA,{member:F,deals:k.filter(function(e){return!e.assignee_id}),close:function(){return V(null)},dispatch:j}),G&&(0,W.jsx)(ix,{teamId:C.uid,member:G,onClose:function(){return q(null)}})]})}var iZ="#6366f1",i0=[{idx:0,label:"Dashboard",icon:b.I,res:null},{idx:1,label:"Visitors",icon:y.k,res:"visitors"},{idx:2,label:"Clients",icon:v.z,res:"clients"},{idx:3,label:"Deals",icon:w.Z,res:"deals"},{idx:4,label:"Teams",icon:v.z,res:"teams"}],i1=c.Ay.div.withConfig({displayName:"DGSHead__Wrapper",componentId:"sc-151i8xi-0"}
1)(["height:100vh;display:flex;overflow:hidden;background:#f6f7fb;"]),i6=c.Ay.aside.withConfig({displayName:"DGSHead__Sidebar",componentId:"sc-151i8xi-1"})(["width:","px;transition:width 0.25s;background:linear-gradient(180deg,#20232a 0%,#312e81 100%);color:#f9fafb;display:flex;flex-direction:column;box-shadow:2px 0 6px rgb(0 0 0 / 0.18);z-index:10;"],function(e){return e.$collapsed?64:220}),i2=c.Ay.header.withConfig({displayName:"DGSHead__Bar",componentId:"sc-151i8xi-2"})(["height:56px;display:flex;align-items:center;gap:10px;padding:0 18px;backdrop-filter:blur(6px);background:rgba(255,255,255,0.04);font-weight:600;white-space:nowrap;overflow:hidden;"]),i5=c.Ay.button.withConfig({displayName:"DGSHead__TeamBtn",componentId:"sc-151i8xi-3"})(["all:unset;cursor:pointer;display:grid;place-content:center;width:28px;height:28px;border-radius:6px;transition:background 0.2s;&:hover{background:rgba(255,255,255,0.08);}"]),i8=(0,c.Ay)(i5).withConfig({displayName:"DGSHead__CollapseBtn",componentId:"sc-151i8xi-4"})(["margin:8px auto 12px;transform:",";",""],function(e){return e.$collapsed?"rotate(180deg)":"none"},function(e){return e.$disabled&&(0,c.AH)(["pointer-events:none;opacity:0.35;"])}),i3=c.Ay.ul.withConfig({displayName:"DGSHead__NavList",componentId:"sc-151i8xi-5"})(["flex:1;list-style:none;margin:0;padding:8px 0;display:flex;flex-direction:column;gap:4px;"]),i4=c.Ay.li.withConfig({displayName:"DGSHead__NavItem",componentId:"sc-151i8xi-6"})(["position:relative;",""],function(e){var n=e.$active,t=e.$collapsed;return n&&!t&&(0,c.AH)(['&:before{content:"";position:absolute;left:0px;top:4px;width:3px;height:calc(100% - 8px);border-radius:2px;background:',";}"],iZ)}),i7=c.Ay.button.withConfig({displayName:"DGSHead__NavButton",componentId:"sc-151i8xi-7"})(["all:unset;cursor:pointer;width:100%;display:flex;align-items:center;gap:12px;padding:10px 18px;font-size:0.9rem;color:",";font-weight:",";transition:background 0.15s,transform 0.15s;"," &:hover{","}svg{flex-shrink:0;}span{flex:1;white-space:nowrap;opacity:",";width:",";transform:",";transition:opacity 0.25s,transform 0.25s;}",""],function(e){var n=e.$active;return e.$forbidden?"#fca5a5":n?"#ffffff":"#e5e7eb"},function(e){return e.$active?600:500},function(e){return e.$collapsed&&(0,c.AH)(["justify-content:center;gap:0;"])},function(e){return e.$forbidden?(0,c.AH)(["background:rgba(127,29,29,.45);"]):(0,c.AH)(["background:rgba(255,255,255,.08);transform:translateX(2px);"])},function(e){return e.$collapsed?0:1},function(e){return e.$collapsed?"0":"auto"},function(e){return e.$collapsed?"translateX(-4px)":"none"},function(e){var n=e.$disabled,t=e.$forbidden;return(n||t)&&(0,c.AH)(["pointer-events:none;opacity:0.55;"])}),i9=c.Ay.ul.withConfig({displayName:"DGSHead__Menu",componentId:"sc-151i8xi-8"})(["position:absolute;top:56px;left:","px;min-width:160px;background:#ffffff;color:#111827;border-radius:8px;padding:6px 0;box-shadow:0 6px 20px rgb(0 0 0 / 0.15);list-style:none;z-index:30;"],function(e){return e.$collapsed?64:16}),oe=c.Ay.li.withConfig({displayName:"DGSHead__MenuItem",componentId:"sc-151i8xi-9"})(["padding:8px 14px;cursor:pointer;font-size:0.875rem;"," &:hover{background:#f3f4f6;}"],function(e){return e.$selected&&(0,c.AH)(["background:#eef2ff;font-weight:600;"])}),on=c.Ay.main.withConfig({displayName:"DGSHead__Body",componentId:"sc-151i8xi-10"})(["flex:1;min-width:0;overflow:auto;background:#f6f7fb;position:relative;"]),ot=(0,c.i7)(["to{transform:rotate(360deg);}"]),or=c.Ay.div.withConfig({displayName:"DGSHead__LoaderWrap",componentId:"sc-151i8xi-11"})(["position:absolute;inset:0;display:flex;justify-content:center;align-items:center;"]),oi=c.Ay.div.withConfig({displayName:"DGSHead__Loader",componentId:"sc-151i8xi-12"})(["width:34px;height:34px;border:4px solid #dbeafe;border-top-color:#6366f1;border-radius:50%;animation:"," 0.8s linear infinite;"],ot);function oo(e){var n,t,r,i,o,a,c,p=e.userData,x=(0,d.mc)(),g=x.state,m=x.switchTeam,b=x.recording,y=x.can,v=g.teams,w=g.currentTeam,k=g.loading,A=g.error,I=(0,l.y)().setActiveTeam,S=null===(i=(0,h.xI)().currentUser)||void 0===i?void 0:i.uid,N=(0,s.use
1State)(!1),D=N[0],T=N[1],O=(0,s.useState)(!1),z=O[0],P=O[1],M=(0,s.useState)(0),E=M[0],L=M[1],B=null==w||null===(o=w.members)||void 0===o?void 0:o.find(function(e){return e.uid===S}),R=(null==w?void 0:w.uid)==="PERSONAL"||!!B&&"boolean"==typeof B.hasSeat,H=w&&"PERSONAL"!==w.uid&&R&&!B.hasSeat&&"admin"!==B.role,$=w&&"PERSONAL"!==w.uid&&(null==B?void 0:B.role)==="admin"&&(null!==(a=null==p||null===(c=p.subData)||void 0===c?void 0:c.seats)&&void 0!==a?a:0)<1,F=$||H;(0,s.useEffect)(function(){!w&&v.length&&T(!1)},[w,v.length]),(0,s.useEffect)(function(){var e=function(){return T(window.innerWidth<640)};return e(),window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}},[]),(0,s.useEffect)(function(){var e=function(e){(e.metaKey||e.ctrlKey)&&"b"===e.key.toLowerCase()&&T(function(e){return!e})};return window.addEventListener("keydown",e),function(){return window.removeEventListener("keydown",e)}},[]),(0,s.useEffect)(function(){I(w?w.uid:null)},[null==w?void 0:w.uid]);var V=(0,s.useCallback)(function(){var e=["visitors","clients","deals","teams"][E-1];if(e&&!y(e,"r"))return(0,W.jsx)(oh,{});switch(E){case 0:default:return(0,W.jsx)(ep,{});case 1:return(0,W.jsx)(r4,{});case 2:return(0,W.jsx)(nC,{});case 3:return(0,W.jsx)(rf,{userData:p});case 4:return(0,W.jsx)(iX,{userData:p})}},[E]);return(0,W.jsxs)(i1,{children:[(0,W.jsx)(u.l,{position:"bottom-right",richColors:!0}),(0,W.jsxs)(i6,{$collapsed:D,children:[(0,W.jsxs)(i2,{children:[(0,W.jsx)(i5,{title:"Switch workspace",onClick:function(){return!b&&P(function(e){return!e})},children:(0,W.jsx)(j.y,{size:20})}),!D&&(w?w.name:"Select workspace")]}),(0,W.jsx)(i3,{children:i0.map(function(e){var n=e.idx,t=e.label,r=e.icon,i=e.res,o=!i||y(i,"r");return(0,W.jsx)(i4,{$active:E===n,$collapsed:D,children:(0,W.jsxs)(i7,{"data-tab":n,$active:E===n,$collapsed:D,$disabled:b||!w||R&&F||"Teams"===t&&"PERSONAL"===w.uid,$forbidden:!o,title:o?void 0:"Permission\xa0required",onClick:function(){return o&&L(n)},children:[(0,W.jsx)(r,{size:20}),(0,W.jsx)("span",{children:t})]})},n)})}),w&&"PERSONAL"!==w.uid&&(r=null!==(n=null===(t=w.members)||void 0===t||null===(t=t.find(function(e){return e.uid===S}))||void 0===t?void 0:t.role)&&void 0!==n?n:"staff",(0,W.jsxs)(ou,{$collapsed:D,title:w.name,children:[(0,W.jsxs)("div",{style:{flex:1,overflow:"hidden"},children:[(0,W.jsx)("span",{style:{fontSize:D?"0.63rem":".82rem",fontWeight:600,display:"block"},children:w.name}),(0,W.jsx)(of,{$collapsed:D,children:null==p?void 0:p.email})]}),(0,W.jsx)(op,{$admin:"admin"===r,$collapsed:D,children:r})]})),(0,W.jsx)(i8,{title:D?"Expand":"Collapse sidebar",disabled:b,onClick:function(){return!b&&T(function(e){return!e})},$collapsed:D,children:D?(0,W.jsx)(_.c,{size:20}):(0,W.jsx)(C.J,{size:20})})]}),z&&(0,W.jsx)(i9,{$collapsed:D,onMouseLeave:function(){return P(!1)},children:v.map(function(e){return(0,W.jsx)(oe,{$selected:(null==w?void 0:w.uid)===e.uid,onClick:function(){m(e.uid),f().set(null,"crm_team",e.uid,{path:"/"}),P(!1)},children:e.name},e.uid)})}),(0,W.jsxs)(on,{children:[k&&(0,W.jsx)(or,{children:(0,W.jsx)(oi,{})}),A&&(0,W.jsx)("p",{style:{padding:"1rem",color:"#b91c1c"},children:A}),!k&&!A&&w&&H&&(0,W.jsx)(ox,{}),!k&&!A&&w&&$&&(0,W.jsx)(oy,{}),!k&&!A&&w&&!H&&R&&V(),!k&&!A&&w&&!H&&!R&&(0,W.jsx)(or,{children:(0,W.jsx)(oi,{})}),!k&&!A&&!w&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ol,{children:"Select a workspace to get started"}),(0,W.jsx)(oa,{children:v.map(function(e){var n="PERSONAL"===e.uid;return(0,W.jsxs)(os,{$accent:n,title:"Switch to “".concat(e.name,"”"),onClick:function(){m(e.uid),f().set(null,"crm_team",e.uid,{path:"/"})},children:[(0,W.jsx)(oc,{children:n?"\uD83C\uDFE0":"\uD83D\uDC65"}),(0,W.jsx)(od,{children:e.name})]},e.uid)})})]})]})]})}var oa=c.Ay.div.withConfig({displayName:"DGSHead__SelWrap",componentId:"sc-151i8xi-13"})(["display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:22px;padding:40px;padding-top:10px;max-width:900px;margin:0 auto;"]),os=c.Ay.button.withConfig({displayName:"DGSHead__Card",componentId:"sc-151i8xi-14"})(["all:unset;cursor:pointer;background:#fff;border:2px solid ",";border-radius:10px;padding:22px 20px 26px;box-shadow:0 4px 10px rgb(0 0 0 / .06);display:flex;flex-direction:column;align-items:center;transition:transform .15s,box-shadow .15s;&:hover{transform:translateY(-2px);box-shadow:0 6px 16px rgb(0 0 0 / .10);}"],function(e){return e.$accent?iZ:"#e5e7eb"}),oc=c.Ay.div.withConfig({displayName:"DGSHead__Emoji",componentId:"sc-151i8xi-15"})(["font-size:38px;line-height:1;margin-bottom:14px;"]),od=c.Ay.h4.withConfig({displayName:"DGSHead__Title",componentId:"sc-151i8xi-16"})(["margin:0;font-size:1.05rem;color:#111827;text-align:center;"]),ol=c.Ay.p.withConfig({displayName:"DGSHead__Intro",componentId:"sc-151i8xi-17"})(["font-size:1.05rem;color:#555;text-align:center;margin:20px 0 4px;"]),ou=c.Ay.div.withConfig({displayName:"DGSHead__TeamInfo",componentId:"sc-151i8xi-18"})(["margin:",";padding:",";border-radius:8px;background:#1f2937;display:flex;align-items:center;text-align:",";gap:",";flex-direction:",";justify-content:center;
1span{display:",";}"],function(e){return e.$collapsed?"0 6px 10px":"6px 12px 10px"},function(e){return e.$collapsed?"6px":"8px 10px"},function(e){return e.$collapsed?"center":"left"},function(e){return e.$collapsed?"0":"8px"},function(e){return e.$collapsed?"column":"row"},function(e){return e.$collapsed?"none":"block"}),op=c.Ay.div.withConfig({displayName:"DGSHead__RoleTag",componentId:"sc-151i8xi-19"})(["font-size:0.70rem;font-weight:700;text-transform:uppercase;padding:2px 6px;border-radius:6px;color:",";background:",";",""],function(e){return e.$admin?"#7f1d1d":"#78350f"},function(e){return e.$admin?"#fecaca":"#fef3c7"},function(e){return e.$collapsed&&(0,c.AH)(["width:12px;height:12px;padding:0;border-radius:50%;font-size:0;line-height:0;color:transparent;"])}),of=c.Ay.span.withConfig({displayName:"DGSHead__Email",componentId:"sc-151i8xi-20"})(["font-size:0.72rem;color:#d1d5db;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;display:",";"],function(e){return e.$collapsed?"none":"block"}),oh=function(){return(0,W.jsxs)("div",{style:{height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:"#6b7280"},children:[(0,W.jsx)(k.$,{size:46,style:{opacity:.35,marginBottom:16}}),(0,W.jsx)("p",{style:{fontSize:"1.1rem",margin:0},children:"Permission\xa0Not\xa0Allowed"})]})},ox=function(){return(0,W.jsxs)("div",{style:{height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:"#6b7280",padding:"0 24px",textAlign:"center"},children:[(0,W.jsx)(k.$,{size:46,style:{opacity:.35,marginBottom:16}}),(0,W.jsxs)("p",{style:{fontSize:"1.15rem",margin:0,maxWidth:420},children:["You dont have an active\xa0",(0,W.jsx)("b",{children:"seat"}),"\xa0in this workspace yet.",(0,W.jsx)("br",{}),"Ask a team\xa0admin to assign one before using\xa0DGS."]})]})},og=c.Ay.div.withConfig({displayName:"DGSHead__Stepper",componentId:"sc-151i8xi-21"})(["display:flex;align-items:center;border:1px solid #6366f1;border-radius:8px;overflow:hidden;margin:18px auto;"]),om=c.Ay.button.withConfig({displayName:"DGSHead__StepBtn",componentId:"sc-151i8xi-22"})(["all:unset;cursor:pointer;width:28px;height:24px;display:grid;place-content:center;color:#6366f1;font-weight:700;&:hover{background:#eef2ff;}"]),ob=c.Ay.input.attrs({type:"number",min:1}).withConfig({displayName:"DGSHead__QtyBox",componentId:"sc-151i8xi-23"})(["width:40px;text-align:center;border:none;font-size:.85rem;"]),oy=function(){var e,n=(0,m.useRouter)(),t=s.useState(1),o=(0,i.A)(t,2),c=o[0],d=o[1],l=s.useState(!1),u=(0,i.A)(l,2),p=u[0],f=u[1],h=(e=(0,r.A)(a().mark(function e(){var t;return a().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!p){e.next=2;break}return e.abrupt("return");case 2:return f(!0),e.prev=3,e.next=6,(0,x.my)(g.default,[{priceId:"price_1Rny0bDOj40aI7mMVKbudsDy",quantity:c}]);case 6:t=e.sent,n.push(t),e.next=13;break;case 10:e.prev=10,e.t0=e.catch(3),toast.error(e.t0.message||"Checkout failed");case 13:return e.prev=13,f(!1),e.finish(13);case 16:case"end":return e.stop()}},e,null,[[3,10,13,16]])})),function(){return e.apply(this,arguments)});return(0,W.jsxs)("div",{style:{height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:"#6b7280",padding:"0 24px",textAlign:"center"},children:[(0,W.jsx)(v.z,{size:48,style:{opacity:.35,marginBottom:16}}),(0,W.jsxs)("p",{style:{fontSize:"1.15rem",maxWidth:460,margin:0},children:["This workspace doesn’t have any ",(0,W.jsx)("b",{children:"MAGIC\xa0AI\xa0Sales\xa0Buddy seats"})," yet.",(0,W.jsx)("br",{}),"Purchase at least one seat to start collaborating."]}),(0,W.jsxs)(og,{children:[(0,W.jsx)(om,{onClick:function(){return d(function(e){return Math.max(1,e-1)})},children:(0,W.jsx)(A.H,{size:12})}),(0,W.jsx)(ob,{value:c,onChange:function(e){return d(Math.max(1,parseInt(e.target.value)||1))}}),(0,W.jsx)(om,{onClick:function(){return d(function(e){return e+1})},children:(0,W.jsx)(I.F,{size:12})})]}),(0,W.jsx)("button",{style:{all:"unset",cursor:"pointer",background:"#6366f1",color:"#fff",padding:"8px 22px",borderRadius:"8px",fontSize:".9rem",fontWeight:600},disabled:p,onClick:h,children:p?"Redirecting…":"Buy\xa0Seats"})]})}}}]);

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.