1import{iE as a,i2 as e,v as F,aE as he,an as pt,ar as rt,c$ as ht,ls as ta,bR as aa,E as sa,l4 as $e,kO as ra,aQ as Y,aR as ia,ag as Le,at as la,bM as na,bK as oa,bN as ca,bi as da,bL as ua,aT as it,aX as qe,io as ma}from"./index-m0nIusX2.js";import{d as gt}from"./useNavigate-CjRXjgJ2.js";import{as as fa}from"./main-B-Q_hDbY.js";import{f as xa,aa as pa,N as ha,L as ga,W as ja}from"./cosell-CDHgCfSm.js";import{q as va}from"./queryKeys-B45qGzbE.js";import{B as Da}from"./ClosePageButton-BIs7xOSf.js";import{C as ba}from"./ConfirmDialog-CPxNwzMt.js";import{J as Ca}from"./JsonViewerDialog-CebH9YyY.js";import{B as lt}from"./StatusTag-D_J5sKF5.js";import{B as Na}from"./StatusTagWithOptionalTooltip-CbCPahTc.js";import{L as ya}from"./LinkedCrmRecord-CYAOyiuD.js";import{B as jt}from"./data-table-DhOn_5Ve.js";import{D as ge,b as je,e as ve,f as De,d as Ae}from"./dialog-CFYhFcS7.js";import{I as q}from"./input-19-b3r-T.js";import{L as y}from"./label-CDX2fXz3.js";import{S as te,f as ae,g as se,a as re,c as ie}from"./select-gOil4l5w.js";import{M as Ee}from"./cosell-K2rD1Qvl.js";import{t as R}from"./toast-DVMkOnGB.js";import{g as Sa,A as nt,a as Ta}from"./microsoftSolutionPlay-D63xDuli.js";import{B as ka}from"./StatusStepper-Bm9Ase2q.js";import{f as Ue}from"./cosell_constants-CqICz_kT.js";import{R as Aa,p as Ea}from"./azure_constants-BT37L9bq.js";import{T as Ra}from"./textarea-DQD8e6_8.js";import{B as Ma}from"./bell-DKFeemuL.js";import{C as ot}from"./checkbox-G2vka5Hu.js";import{S as ct}from"./separator-0jgnJG7N.js";import{g as wa,A as Ia}from"./MicrosoftStatusTag-BPZiHpbc.js";import{u as Pa,C as Oa,a as Fa}from"./useCosellChatbotAutofix-BZQiCgyC.js";import{C as T}from"./InfoCol-CKIwYxEL.js";import{C as me}from"./InfoRow-BjeQUiEp.js";import{D as Va}from"./DetailLayout-Dpbm8sSW.js";import{L as za}from"./LinkWithCrmDialog-BbtZZOWr.js";import{P as La}from"./progress-BnQsWDkD.js";import{T as fe,e as xe,f as K,d as G,a as pe,b as O}from"./table-CrmSJbvH.js";import{u as qa}from"./useReferralPreview-Bf1Ab1Lt.js";import{g as Ba,a as $a}from"./referralUtils-4W-ndPd1.js";import{G as Ua}from"./partnerLogo-BXvhM4ZD.js";import{h as Ya}from"./cloneDeep-B2EVPRU3.js";import{s as Ha}from"./set-C2jMOK7Z.js";import{S as Wa}from"./send-C4aWHj_v.js";import"./useDebouncedValue-ICJsIdDe.js";import"./with-selector-GRmPFr_4.js";import"./NewVersionNotice-CrTFp0hf.js";import"./useBrandTheme-sQQ09a9X.js";import"./MultiChannelRevenueApp-DUnEa3zZ.js";import"./revenue-Bu8mA0KS.js";import"./badge-BCMxaEMg.js";import"./entitlement-CyHOcwOn.js";import"./usePostHog-CRYHY6ir.js";import"./popover-CGlOkWc4.js";import"./index-BXR6F2tF.js";import"./card-GJzlNXrB.js";import"./skeleton-CNdnTm6N.js";import"./native-date-input-DI2oKHvG.js";import"./info-tooltip-XXnoIbIR.js";import"./react-apexcharts.esm-DfsHi1ot.js";import"./useQueries-DPzJKR8R.js";import"./tabs-CkSvPL9R.js";import"./index-vDSVTUCl.js";import"./index-B6ksRBvq.js";import"./index-MnGK8kX1.js";import"./index-B5SjYlct.js";import"./radio-group-C08LUop7.js";import"./index-BeoYln4u.js";import"./index-B44nOmpW.js";import"./alert-dialog-xuEC_uzA.js";import"./index-CiNTbKJG.js";import"./SearchBox-BlgUqEeD.js";import"./JsonViewer-CRlhcjkI.js";import"./StatusChip-DIPkyc-U.js";import"./purify.es-DCSLj_Qk.js";import"./command-QbbEZl6d.js";import"./index-CL1vzYPC.js";import"./mdi-3HaUydhU.js";import"./index-uEVxYnCT.js";import"./index-BRn12YI3.js";import"./index-BdQq_4o_.js";import"./hub-spot-CEawy5nT.js";import"./cosell-D_8W5V4v.js";import"./partner-relationship-management-CL914no1.js";import"./salesforce-C-_JY_w6.js";import"./httpError-C4LZ5tRB.js";import"./form-section-D-TXzghY.js";import"./dynamics365-DWenbHkj.js";import"./dynamics365-D8WCopq5.js";import"./dynamics365Url-tHZpBVFh.js";import"./index-Cxk2_3Oe.js";import"./dropdown-menu-CQET0a5q.js";import"./index-ns31NdoK.js";import"./useSingleReferralSync-CX7XPbvD.js";import"./flame-CAgGPngv.js";import"./pencil-line-BoG8_Ubo.js";import"./operation-DysZJ2U5.js";import"./operation-jwLp1NGO.js";import"./OperationsTable-QAVkvuk4.js";import"./label-value-CeLqqgtP.js";import"./CopyToClipBoard-hSOPKua6.js";import"./useTableSearch-CmYXt8qA.js";import"./useAIChatbot-BYapCoqB.js";import"./v4-BKrj-4V8.js";import"./usePageContext-DEfWYerv.js";import"./aiContextStore-BEU57wZn.js";import"./contact-Dswi6Sas.js";import"./contact-DXKWydiY.js";import"./MdiIcon-BeuZ5i0m.js";import"./chunkAndFetch-BlYD2O4M.js";import"./usePartnerAvailability-_5KF0_40.js";import"./intelligence-CqAz1g6F.js";import"./UserEmailCard-D9WJtA8W.js";import"./user-email-C_OT4lnB.js";import"./PrmKpiTooltip-axfO09X9.js";import"./usePrmTracking-C-RjCWeW.js";import"./divider-oAVeoVc_.js";import"./users-D74et90S.js";import"./mail--y8t11MM.js";import"./panel-right-open-Dmi14cf0.js";import"./useCrmIntegration-DKox56Dp.js";import"./mouse-pointer-click-CIhtvcSf.js";import"./CrmField-C2afe4xz.js";import"./multi-select-D97MmYDa.js";import"./chevrons-up-down-CDydpTXX.js";import"./switch-DxNJvRbX.js";import"./index-BTsUZHbC.js";import"./form-layout-03MQzVnn.js";import"./Combobox-CgeS0IhE.js";import"./debounce-BdT7fk_L.js";import"./isObject-C3e4t58V.js";import"./isObjectLike-Dipz0mOK.js";import"./toNumber-GVsAjY7V.js";import"./isSymbol-C1qQj8zB.js";import"./index-B-YO4kT9.js";import"./buildQuery-DGxOWbI3.js";import"./isArray-Dxzbedgu.js";import"./_toKey-CrbQo_fF.js";import"./toString-d-GUlYYl.js";function _a({visible:r,msReferralSet:o,updateReferral:c,onHide:x,onRefresh:f}){const[m,g]=a.useState(""),[d,N]=a.useState(""),[s,b]=a.useState(""),[w,A]=a.useState(""),[S,I]=a.use
1State(""),[v,p]=a.useState(!1),M=Ee;a.useEffect(()=>{r&&o?.self&&(g(o.self.name||""),N(o.self.details?.dealValue!=null?String(o.self.details.dealValue):""),b(o.self.details?.currency||""),A(o.self.details?.closingDateTime||""),I(o.self.campaignId||""))},[r,o]);const D=a.useCallback(()=>{x()},[x]),_=a.useCallback(()=>{f()},[f]),H=a.useCallback(async()=>{p(!0);try{const j={"info.microsoftReferralSet.self.status":"Active","info.microsoftReferralSet.self.substatus":"Accepted","info.microsoftReferralSet.self.name":m,"info.microsoftReferralSet.self.details.dealValue":d?+d:void 0,"info.microsoftReferralSet.self.details.currency":s||"","info.microsoftReferralSet.self.details.closingDateTime":w||"","info.microsoftReferralSet.self.campaignId":S||""};await c(j,!0),R.info("Request received. Please refresh the page later to see the result."),D(),_()}catch(j){console.error("Failed to accept the Azure referral:",j);const Z=j.response?.data?.message||j.message||"Unknown error";R.error(`Failed to accept the Azure referral: ${Z}`)}finally{p(!1)}},[m,d,s,w,S,c,D,_]),E=!!m&&!!d&&!!s&&!!w;return e.jsx(ge,{open:r,onOpenChange:j=>{j||D()},children:e.jsxs(je,{className:"max-w-[900px] w-full",onInteractOutside:j=>j.preventDefault(),onEscapeKeyDown:j=>j.preventDefault(),children:[e.jsx(ve,{children:e.jsx(De,{children:"Accept Microsoft Referral"})}),e.jsxs("div",{className:"-mx-6 max-h-[60vh] overflow-y-auto px-6",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx(y,{children:"* Deal Name"}),e.jsx(q,{value:m,onChange:j=>g(j.target.value)})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx(y,{children:"* Deal Value"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx("div",{children:e.jsx(q,{type:"number",placeholder:"Estimated Value",value:d,onChange:j=>N(j.target.value)})}),e.jsx("div",{children:e.jsxs(te,{value:s,onValueChange:b,children:[e.jsx(ae,{children:e.jsx(se,{placeholder:"Currency"})}),e.jsx(re,{children:M.currencyOptions?.map(j=>e.jsx(ie,{value:j.value,children:j.label},j.value))})]})})]})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx(y,{children:"* Estimated Close Date"}),e.jsx(jt,{value:w,onChange:j=>A(j),label:"",width:"100%",minDate:new Date().toISOString().split("T")[0]})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx(y,{children:"Marketing Campaign ID"}),e.jsx(q,{value:S,onChange:j=>I(j.target.value)})]})]}),e.jsxs(Ae,{children:[e.jsx(F,{variant:"outline",onClick:D,children:"Cancel"}),e.jsxs(F,{disabled:!E||v,onClick:H,children:[v&&e.jsx(he,{className:"mr-2 size-4 animate-spin"}),"Save"]})]})]})})}function dt({visible:r,msReferralSet:o,updateReferral:c,isEditTeamMember:x=!1,editIndex:f=-1,onHide:m,onRefresh:g}){const[d,N]=a.useState({}),[s,b]=a.useState(!1),w=a.useCallback(()=>{x&&o.self.team&&o.self.team.length>(f||0)&&N({...o.self.team[f||0]})},[x,o,f]);a.useEffect(()=>{f!==-1&&r&&w()},[f,r,w]),a.useEffect(()=>{r&&!x&&N({})},[r,x]);const A=a.useCallback(()=>{m()},[m]),S=a.useCallback(()=>{g()},[g]),I=a.useCallback(async()=>{b(!0);try{const p={};if(x)p[`info.microsoftReferralSet.self.team.${f}`]=d;else{const D=[...o.self.team||[],d];p["info.microsoftReferralSet.self.team"]=D}await c(p,!0),R.info("Request received. Please refresh the page later to see the result."),A(),S()}catch(p){console.error(`Failed to ${x?"update":"add"} team member:`,p);const M=p.response?.data?.message||p.message||"Unknown error";R.error(`Failed to ${x?"update":"add"} team member: ${M}`)}finally{b(!1)}},[x,f,d,o,c,A,S]),v=!!d.firstName&&!!d.lastName&&!!d.email&&!!d.phoneNumber;return e.jsx(ge,{open:r,onOpenChange:p=>{p||A()},children:e.jsxs(je,{className:"max-w-[900px] w-full",onInteractOutside:p=>p.preventDefault(),onEscapeKeyDown:p=>p.preventDefault(),children:[e.jsx(ve,{children:e.jsx(De,{children:x?"Edit Team Member":"Add Team Member"})}),e.jsxs("div",{className:"-mx-6 max-h-[60vh] overflow-y-auto px-6",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx(y,{children:"* First Name"}),e.jsx(q,{value:d.firstName||"",onChange:p=>N(M=>({...M,firstName:p.target.value}))})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx(y,{children:"* Last Name"}),e.jsx(q,{value:d.lastName||"",onChange:p=>N(M=>({...M,lastName:p.target.value}))})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx(y,{children:"* Email"}),e.jsx(q,{value:d.email||"",onChange:p=>N(M=>({...M,email:p.target.value}))})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx(y,{children:"* Phone Number"}),e.jsx(q,{value:d.phoneNumber||"",onChange:p=>N(M=>({...M,phoneNumber:p.target.value}))})]})]}),e.jsxs(Ae,{children:[e.jsx(F,{variant:"outline",onClick:A,children:"Cancel"}),e.jsxs(F,{disabled:!v||s,onClick:I,children:[s&&e.jsx(he,{className:"mr-2 size-4 animate-spin"}),"Save"]})]})]})})}const ut=[{label:"Created",value:0},{label:"Qualified",value:20},{label:"Developed",value:40},{label:"Proposed",value:60},{label:"Negotiated",value:80},{label:"Closed",value:100}];function Ka({msReferralSet:r,sugerReferral:o,updateReferral:c,onStageUpdated:x}){const[f,m]=a.useState(!1),g=a.useMemo(()=>
1{if(r?.self?.status==="Closed")return 100;switch(r?.self?.salesStage){case"<nil>":return 3;case"20":return 20;case"40":return 40;case"60":return 60;case"80":return 80;case"100":return 100;default:return 3}},[r]),d=r?.self?.status==="Active",N=o?.status===Ue.CREATE_FAILED,s=a.useMemo(()=>{const A=ut.findIndex(S=>S.value===g);return A>=0?A:0},[g]),b=a.useMemo(()=>ut.map((A,S)=>{const I=S<=s,v=I?"#06AE77":"#E2E8F0",p=I?"#06AE77":"#E2E8F0";return{item:{label:A.label,sublabel:"",icon:I?"mdi-check":"mdi-circle",color:v},...S>0?{divider:{color:p,shape:"solid"}}:{}}}),[s]),w=async()=>{const A=`${Number.parseInt(r.self.salesStage||"0",10)+20}`;m(!0);try{await c({"info.microsoftReferralSet.self.salesStage":A},!0),R.info("Request received. Please refresh the page later to see the result."),x?.()}catch(S){console.error("Failed to change the sales stage:",S);const I=S.response?.data?.message||S.message||"Unknown error";R.error(`Failed to change the sales stage: ${I}`)}finally{m(!1)}};return e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("div",{className:"flex-1",children:e.jsx(ka,{steps:b,finalStepIndex:5})}),(d&&g<80||N)&&e.jsx(F,{variant:"outline",className:"mt-[-20px]",disabled:f||N,onClick:w,children:f?"Loading...":"Next Stage"})]})}const Ga="Let us know why you are closing this deal so we can provide better deals in the future. We won't share this feedback with the customer. The deal will be moved to Closed after you select a reason for closing. After you close this deal you will no longer be able to edit it.",Za="Let us know why you declined this deal so we can provide better deals in the future. We won't share this feedback with the customer. The deal will be moved to Archive after you select a reason for declining.",Qa=Ea,Ja=Aa;function Be({visible:r,msReferralSet:o,updateReferral:c,isCloseWithLostStatus:x=!1,isCloseAsError:f=!1,isCloseWithDecline:m=!1,onHide:g,onRefresh:d}){const[N,s]=a.useState("Others"),[b,w]=a.useState(""),[A,S]=a.useState(!1),I=a.useMemo(()=>m?"Reason for decline":"Reason for closing",[m]),v=a.useMemo(()=>x?"Lost":f?"Close as Error":"Decline",[x,f]),p=a.useCallback(()=>{g()},[g]),M=a.useCallback(()=>{d()},[d]),D=a.useCallback(async()=>{S(!0);const E={"info.microsoftReferralSet.self.status":"Closed","info.microsoftReferralSet.self.statusReason":`${N}:${b}`};if(f)E["info.microsoftReferralSet.self.substatus"]="Error";else if(x)E["info.microsoftReferralSet.self.substatus"]="Lost";else if(m)E["info.microsoftReferralSet.self.substatus"]="Declined";else{R.error("Invalid close status"),S(!1);return}try{await c(E,!0),R.info("Request received. Please refresh the page later to see the result."),p(),M()}catch(j){console.error("Failed to close referral:",j);const Z=j.response?.data?.message||j.message||"Unknown error";R.error(`Failed to close referral: ${Z}`)}finally{S(!1)}},[N,b,f,x,m,c,p,M]),_=f?Ja:Qa,H=!!N;return e.jsx(ge,{open:r,onOpenChange:E=>{E||p()},children:e.jsxs(je,{className:"max-w-[900px] w-full",onInteractOutside:E=>E.preventDefault(),onEscapeKeyDown:E=>E.preventDefault(),children:[e.jsx(ve,{children:e.jsx(De,{children:v})}),e.jsxs("div",{className:"-mx-6 max-h-[60vh] overflow-y-auto px-6",children:[e.jsx("p",{className:"mb-2",children:e.jsx("strong",{children:"Your feedback is important to us"})}),e.jsx("p",{className:"mb-4 text-sm text-muted-foreground",children:m?Za:Ga}),e.jsxs("div",{className:"mb-4",children:[e.jsx(y,{children:I}),e.jsxs(te,{value:N,onValueChange:s,children:[e.jsx(ae,{children:e.jsx(se,{placeholder:"Select a reason"})}),e.jsx(re,{children:_.map(E=>e.jsx(ie,{value:E.value,children:E.label},E.value))})]})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx(y,{children:"Notes (optional)"}),e.jsx(Ra,{value:b,onChange:E=>w(E.target.value),maxLength:500,rows:3})]})]}),e.jsxs(Ae,{children:[e.jsx(F,{variant:"outline",onClick:p,children:"Cancel"}),e.jsxs(F,{disabled:!H||A,onClick:D,children:[A&&e.jsx(he,{className:"mr-2 size-4 animate-spin"}),"Save"]})]})]})})}function Xa({msReferralSet:r,allPassed:o,onRegister:c}){const x=a.useMemo(()=>r.self.registrations||[],[r]),f=a.useMemo(()=>x.length>0,[x]),m=a.useMemo(()=>{const g=r.self.closedDateTime;if(!g)return null;const d=new Date(g),N=new Date(d.getTime()+1440*60*60*1e3),s=new Date,b=Math.ceil((N.getTime()-s.getTime())/(1440*60*1e3));return b>0?b:0},[r]);return e.jsx("div",{children:f?e.jsx("div",{className:"flex flex-col gap-3",children:x.map((g,d)=>e.jsx("div",{className:"rounded-md overflow-hidden bg-muted",children:e.jsxs("div",{className:"px-4 py-3 flex flex-col gap-3",children:[e.jsxs("div",{className:"flex flex-row justify-between gap-4",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Contract Value"}),e.jsx("div",{className:"text-sm text-foreground font-medium truncate",children:g.contract?.value?`${g.contract.currency||""}
1 ${g.contract.value.toLocaleString()}`:"N/A"})]}),e.jsxs("div",{className:"flex flex-row justify-between gap-4",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Term"}),e.jsx("div",{className:"text-sm text-foreground font-medium truncate",children:g.contract?.term||"N/A"})]}),e.jsxs("div",{className:"flex flex-row justify-between gap-4",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Signed Date"}),e.jsx("div",{className:"text-sm text-foreground font-medium truncate",children:g.contract?.signDateTime?pt(g.contract.signDateTime):"N/A"})]}),g.statusReason&&e.jsxs("div",{className:"flex flex-row justify-between gap-4",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Reason"}),e.jsx("div",{className:"text-sm text-foreground font-medium truncate",children:g.statusReason})]})]})},d))}):o?e.jsxs("div",{className:"rounded-xl border border-[#CA8A04] bg-[#FFFBEB] p-[17.5px] shadow-sm",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Ma,{size:22,color:"#854D0E",className:"shrink-0 mt-0.5"}),e.jsx("div",{className:"flex-1",children:e.jsx("div",{className:"text-[16px] font-semibold text-[#854D0E] leading-[22px]",children:"Link a Deal Registration to this opportunity"})})]}),e.jsxs("div",{className:"px-2 pt-3 pb-2 text-[13px] leading-normal text-muted-foreground",children:["This opportunity is approaching close but has no Deal Registration.",m!==null&&e.jsxs(e.Fragment,{children:[" ","You have ",e.jsx("span",{className:"font-bold text-[#854D0E]",children:m})," days remaining."]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(F,{variant:"outline",className:"!text-[#854D0E] !border-[#854D0E]",onClick:c,children:"Register Deal"})})]}):e.jsxs("div",{className:"rounded-xl border border-border bg-muted p-4",children:[e.jsx("div",{className:"text-sm font-semibold text-muted-foreground mb-1",children:"Not Eligible"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"This deal does not meet all eligibility requirements for deal registration."})]})})}ht.extend(ta);const ce=r=>ht.utc(r).format("YYYY-MM-DD"),mt=()=>({contract:{value:0,currency:"USD",term:"Finite",signDateTime:"",startDateTime:"",endDateTime:""},solutionDetails:[{id:"",value:0,currency:"USD",isDeployedOnAzure:!0,primaryDeploymentOn:"Customer",pricingModel:"Other",marketplaceTransactionDetails:{isMarketplaceTransacted:!1,marketplaceTransactionDateTime:""}}]}),es=[{label:"Finite",value:"Finite"},{label:"Perpetual",value:"Perpetual"}],ts=[{label:"Customer",value:"Customer"},{label:"Partner",value:"Partner"}],as=[{label:"Other",value:"Other"},{label:"Pay As You Go",value:"PayAsYouGo"}];function ss({visible:r,onHide:o,msReferralSet:c,updateReferral:x,onRefresh:f,initialContract:m}){const d=Ee.currencyOptions,N=a.useCallback(()=>({today:ce(new Date),sixtyDaysAgo:ce(new Date(Date.now()-1440*60*60*1e3)),ninetyDaysAgo:ce(new Date(Date.now()-2160*60*60*1e3))}),[]),[s,b]=a.useState(mt),[w,A]=a.useState(!1),[S,I]=a.useState(""),[v,p]=a.useState({});a.useEffect(()=>{r&&m&&b(i=>({...i,contract:{value:m.value??i.contract.value,currency:m.currency||i.contract.currency,term:m.term||i.contract.term,signDateTime:m.signDateTime?ce(new Date(m.signDateTime)):i.contract.signDateTime,startDateTime:m.startDateTime?ce(new Date(m.startDateTime)):i.contract.startDateTime,endDateTime:m.endDateTime?ce(new Date(m.endDateTime)):i.contract.endDateTime}}))},[r,m]);const M=a.useMemo(()=>(c.self?.details?.requirements?.solutions||[]).map(u=>({id:u.id||"",displayName:u.name||u.id||""})),[c]),D=a.useCallback((i,u)=>{b(V=>{const C={...V},P=i.split(".");let L=C;for(let ue=0;ue<P.length-1;ue++){const le=P[ue],X=Number(le);Number.isNaN(X)?(L[le]=Array.isArray(L[le])?[...L[le]]:{...L[le]},L=L[le]):(L[X]=Array.isArray(L[X])?[...L[X]]:{...L[X]},L=L[X])}return L[P[P.length-1]]=u,C})},[]),_=a.useCallback(i=>{if(i==null||i<=0)return null;const u=rt(s.contract.currency||"USD");if(s.contract.term==="Perpetual"){const V=i/6;return V<25e3?`Annual value (TCV/6 = ${u}${Math.round(V).toLocaleString()}) must be >= $25,000`:null}if(s.contract.startDateTime&&s.contract.endDateTime){const V=new Date(s.contract.startDateTime),P=(new Date(s.contract.endDateTime).getTime()-V.getTime())/(1440*60*1e3);if(P>0){const L=i*365/P;if(L<25e3)return`Annual value (${u}
1${Math.round(L).toLocaleString()}) must be >= $25,000`}}return null},[s.contract.term,s.contract.currency,s.contract.startDateTime,s.contract.endDateTime]),H=a.useCallback(i=>s.contract.value&&i>s.contract.value?`Must be ⤠contract value (${rt(s.contract.currency||"USD")}${s.contract.value.toLocaleString()})`:null,[s.contract.value,s.contract.currency]),E=a.useCallback(i=>{if(!i||!s.contract.startDateTime)return null;const u=ce(new Date(s.contract.startDateTime));return i<u?"End date can't be earlier than start date":null},[s.contract.startDateTime]),j=a.useCallback(()=>{const{today:i,sixtyDaysAgo:u,ninetyDaysAgo:V}=N(),C={};if(!s.contract.value||s.contract.value<=0)C["contract.value"]="Contract value is required and must be > 0";else{const P=_(s.contract.value);P&&(C["contract.value"]=P)}if(s.contract.currency||(C["contract.currency"]="Currency is required"),s.contract.term||(C["contract.term"]="Contract term is required"),s.contract.signDateTime?s.contract.signDateTime>i?C["contract.signDateTime"]="Signed date cannot be in the future":s.contract.signDateTime<u&&(C["contract.signDateTime"]="Signed date cannot be more than 60 days ago"):C["contract.signDateTime"]="Contract signed date is required",s.contract.startDateTime?s.contract.startDateTime<V&&(C["contract.startDateTime"]="Start date cannot be more than 90 days ago"):C["contract.startDateTime"]="Contract start date is required",s.contract.term!=="Perpetual")if(!s.contract.endDateTime)C["contract.endDateTime"]="Contract end date is required";else{const P=E(s.contract.endDateTime);P&&(C["contract.endDateTime"]=P)}if(s.solutionDetails[0].id||(C["solution.id"]="Solution is required"),!s.solutionDetails[0].value||s.solutionDetails[0].value<=0)C["solution.value"]="Solution value is required and must be > 0";else{const P=H(s.solutionDetails[0].value);P&&(C["solution.value"]=P)}return s.solutionDetails[0].primaryDeploymentOn||(C["solution.primaryDeploymentOn"]="Primary deployment is required"),s.solutionDetails[0].pricingModel||(C["solution.pricingModel"]="Pricing model is required"),s.solutionDetails[0].marketplaceTransactionDetails.isMarketplaceTransacted&&!s.solutionDetails[0].marketplaceTransactionDetails.marketplaceTransactionDateTime&&(C["solution.marketplaceTransactionDateTime"]="Marketplace transaction date is required"),p(C),Object.keys(C).length===0},[s,_,H,E,N]),Z=a.useCallback(i=>{I(i),D("solutionDetails.0.id",i),D("solutionDetails.0.currency",s.contract.currency)},[s.contract.currency,D]),J=a.useCallback(()=>{b(mt()),I(""),p({}),o()},[o]),de=a.useCallback(async()=>{if(j()){A(!0);try{const i={type:"AzureIPCoSell",contract:{value:s.contract.value,currency:s.contract.currency,term:s.contract.term,signDateTime:new Date(s.contract.signDateTime).toISOString(),startDateTime:new Date(s.contract.startDateTime).toISOString()},solutionDetails:[{id:s.solutionDetails[0].id,value:s.solutionDetails[0].value,currency:s.solutionDetails[0].currency,isDeployedOnAzure:s.solutionDetails[0].isDeployedOnAzure,primaryDeploymentOn:s.solutionDetails[0].primaryDeploymentOn,pricingModel:s.solutionDetails[0].pricingModel,marketplaceTransactionDetails:{isMarketplaceTransacted:s.solutionDetails[0].marketplaceTransactionDetails.isMarketplaceTransacted}}]};s.contract.term!=="Perpetual"&&s.contract.endDateTime&&(i.contract.endDateTime=new Date(s.contract.endDateTime).toISOString()),s.solutionDetails[0].marketplaceTransactionDetails.isMarketplaceTransacted&&s.solutionDetails[0].marketplaceTransactionDetails.marketplaceTransactionDateTime&&(i.solutionDetails[0].marketplaceTransactionDetails.marketplaceTransactionDateTime=s.solutionDetails[0].marketplaceTransactionDetails.marketplaceTransactionDateTime);const V={"info.microsoftReferralSet.self.registrations":[...c.self.registrations||[],i]};await x(V,!0),R.info("Deal registration submitted. Please refresh the page later to see the result."),J(),f?.()}catch(i){console.error("Failed to submit deal registration:",i);const u=i.response?.data?.message||i.message||"Unknown error";R.error(`Failed to submit deal registration: ${u}`)}finally{A(!1)}}},[s,c,x,f,j,J]);return e.jsx(ge,{open:r,onOpenChange:i=>!i&&J(),children:e.jsxs(je,{className:"max-w-[900px]",children:[e.jsx(ve,{children:e.jsx(De,{children:"Submit Deal Registration"})}),e.jsxs("div",{className:"px-2 pb-4",style:{maxHeight:"80vh",overflowY:"auto"},children:[e.jsx("div",{className:"text-base font-semibold text-foreground mb-4",children:"Contract Details"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(y,{htmlFor:"contract-value",children:"Contract Value"}),e.jsx(q,{id:"contract-value",type:"number",value:s.contract.value||"",onChange:i=>D("contract.value",Number(i.target.value)),placeholder:"Enter contract value"}),v["contract.value"]&&e.jsx("p",{className:"text-xs text-red-500",children:v["contract.value"]})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(y,{htmlFor:"contract-currency",children:"Currency"}),e.jsxs(te,{value:s.contract.currency,onValueChange:i=>D("contract.currency",i),children:[e.jsx(ae,{id:"contract-currency",children:e.jsx(se,{placeholder:"Select currency"})}),e.jsx(re,{children:d.map(i=>e.jsx(ie,{value:i.value,children:i.label},i.value))})]}),v["contract.currency"]&&e.jsx("p",{className:"text-xs text-red-500",children:v["contract.currency"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 mt-3",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(y,{htmlFor:"contract-term",children:"Contract Term"}),e.jsxs(te,{value:s.contract.term,onValueChange:i=>D("contract.term",i),children:[e.jsx(ae,{id:"contract-term",children:e.jsx(se,{placeholder:"Select term"})}),e.jsx(re,{children:es.map(i=>e.jsx(ie,{value:i.value,children:i.label},i.value))})]}),v["contract.term"]&&e.jsx("p",{className:"text-xs text-red-500",children:v["contract.term"]})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(y,{htmlFor:"contract-sign-date",children:"Contract Signed Date"}),e.jsx(q,{id:"contract-sign-date",type:"date",value:s.contract.signDateTime,onChange:i=>D("contract.signDateTime",i.target.value)}),v["contract.signDateTime"]&&e.jsx("p",{className:"text-xs text-red-500",children:v["contract.signDateTime"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 mt-3",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(y,{htmlFor:"contract-start-date",children:"Contract Start Date"}),e.jsx(q,{id:"contract-start-date",type:"date",value:s.contract.startDateTime,onChange:i=>D("contract.startDateTime",i.target.value)}),v["contract.startDateTime"]&&e.jsx("p",{className:"text-xs text-red-500",children:v["contract.startDateTime"]})]}),s.contract.term!=="Perpetual"&&e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(y,{htmlFor:"contract-end-date",children:"Contract End Date"}),e.jsx(q,{id:"contract-end-date",type:"date",value:s.contract.endDateTime,onChange:i=>D("contract.endDateTime",i.target.value)}),v["contract.endDateTime"]&&e.jsx("p",{className:"text-xs text-red-500",children:v["contract.endDateTime"]})]})]}),e.jsx(ct,{className:"my-5"}),e.jsx("div",{className:"text-base font-semibold text-foreground mb-4",children:"Solution Details"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(y,{htmlFor:"solution-select",children:"Solution"}),e.jsxs(te,{value:S,onValueChange:Z,children:[e.jsx(ae,{id:"solution-select",children:e.jsx(se,{placeholder:"Select solution"})}),e.jsx(re,{children:M.map(i=>e.jsx(ie,{value:i.id,children:i.displayName},i.id))})]}),v["solution.id"]&&e.jsx("p",{className:"text-xs text-red-500",children:v["solution.id"]})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(y,{htmlFor:"solution-value",children:"Solution Value"}),e.jsx(q,{id:"solution-value",type:"number",value:s.solutionDetail
1s[0].value||"",onChange:i=>D("solutionDetails.0.value",Number(i.target.value)),placeholder:"Enter solution value"}),v["solution.value"]&&e.jsx("p",{className:"text-xs text-red-500",children:v["solution.value"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 mt-3",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(y,{htmlFor:"primary-deployment",children:"Primary Deployment"}),e.jsxs(te,{value:s.solutionDetails[0].primaryDeploymentOn,onValueChange:i=>D("solutionDetails.0.primaryDeploymentOn",i),children:[e.jsx(ae,{id:"primary-deployment",children:e.jsx(se,{placeholder:"Select deployment"})}),e.jsx(re,{children:ts.map(i=>e.jsx(ie,{value:i.value,children:i.label},i.value))})]}),v["solution.primaryDeploymentOn"]&&e.jsx("p",{className:"text-xs text-red-500",children:v["solution.primaryDeploymentOn"]})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(y,{htmlFor:"pricing-model",children:"Pricing Model"}),e.jsxs(te,{value:s.solutionDetails[0].pricingModel,onValueChange:i=>D("solutionDetails.0.pricingModel",i),children:[e.jsx(ae,{id:"pricing-model",children:e.jsx(se,{placeholder:"Select pricing model"})}),e.jsx(re,{children:as.map(i=>e.jsx(ie,{value:i.value,children:i.label},i.value))})]}),v["solution.pricingModel"]&&e.jsx("p",{className:"text-xs text-red-500",children:v["solution.pricingModel"]})]})]}),e.jsxs("div",{className:"mt-4 flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ot,{id:"deployed-on-azure",checked:s.solutionDetails[0].isDeployedOnAzure,onCheckedChange:i=>D("solutionDetails.0.isDeployedOnAzure",!!i)}),e.jsx(y,{htmlFor:"deployed-on-azure",className:"cursor-pointer",children:"Deployed on Azure"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ot,{id:"marketplace-transacted",checked:s.solutionDetails[0].marketplaceTransactionDetails.isMarketplaceTransacted,onCheckedChange:i=>D("solutionDetails.0.marketplaceTransactionDetails.isMarketplaceTransacted",!!i)}),e.jsx(y,{htmlFor:"marketplace-transacted",className:"cursor-pointer",children:"Marketplace Transacted"})]})]}),s.solutionDetails[0].marketplaceTransactionDetails.isMarketplaceTransacted&&e.jsx("div",{className:"grid grid-cols-2 gap-4 mt-3",children:e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(y,{htmlFor:"marketplace-transaction-date",children:"Marketplace Transaction Date"}),e.jsx(q,{id:"marketplace-transaction-date",type:"date",value:s.solutionDetails[0].marketplaceTransactionDetails.marketplaceTransactionDateTime,onChange:i=>D("solutionDetails.0.marketplaceTransactionDetails.marketplaceTransactionDateTime",i.target.value)}),v["solution.marketplaceTransactionDateTime"]&&e.jsx("p",{className:"text-xs text-red-500",children:v["solution.marketplaceTransactionDateTime"]})]})})]}),e.jsx(ct,{}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx(F,{variant:"outline",onClick:J,children:"Cancel"}),e.jsxs(F,{disabled:w,onClick:de,children:[w&&e.jsx(he,{className:"mr-2 size-4 animate-spin"}),"Submit Registration"]})]})]})})}function rs({visible:r,msReferralSet:o,updateReferral:c,onHide:x,onRefresh:f}){const[m,g]=a.useState(""),[d,N]=a.useState(""),[s,b]=a.useState(""),[w,A]=a.useState(""),[S,I]=a.useState(""),[v,p]=a.useState(""),[M,D]=a.useState("HaveNotDecided"),[_,H]=a.useState(!1),E=Ee;a.useEffect(()=>{if(r&&o?.self)if(g(o.self.name||""),N(o.self.details?.dealValue!=null?String(o.self.details.dealValue):""),b(o.self.details?.estimatedACRValue!=null?String(o.self.details.estimatedACRValue):""),A(o.self.details?.currency||""),I(o.self.details?.closingDateTime||""),p(o.self.campaignId||""),o.self.details?.requirements?.additionalRequirements?.attributes){const u=o.self.details.requirements.additionalRequirements.attributes.find(V=>V.type==="CustomerMarketplaceIntent");D(u?u.id:"HaveNotDecided")}else D("HaveNotDecided")},[r,o]);const j=a.useCallback(()=>{x()},[x]),Z=a.useCallback(()=>{f()},[f]),J=a.useCallback(async()=>{H(!0);const u={"info.microsoftReferralSet.self.name":m,"info.microsoftReferralSet.self.details.dealValue":d?+d:void 0,"info.microsoftReferralSet.self.details.estimatedACRValue":s?+s:void 0,"info.microsoftReferralSet.self.details.currency":w||"","info.microsoftReferralSet.self.details.closingDateTime":S||"","info.microsoftReferralSet.self.campaignId":v||""},V=o.self.details?.requirements?.additionalRequirements?.attributes?.findIndex(C=>C.type==="CustomerMarketplaceIntent");V!==-1&&V!==void 0&&(u[`info.microsoftReferralSet.self.details.requirements.additionalRequirements.attributes.${V}.id`]=M);try{await c(u,!0),R.success("Referral details updated successfully."),j(),Z()}catch(C){console.error("Failed to update the Azure referral details:",C);const P=C.response?.data?.message||C.message||"Unknown error";R.error(`Failed to update the Azure referral details: ${P}`)}finally{H(!1)}},[m,d,s,w,S,v,M,o,c,j,Z]),de=s&&d&&Number(s)>Number(d),i=!!m&&!!d&&!!w&&!!S&&!de;return e.jsx(ge,{open:r,onOpenChange:u=>{u||j()},children:e.jsxs(je,{className:"max-w-[900px] w-full h-[80vh] flex flex-col",onInteractOutside:u=>u.preventDefault(),onEscapeKeyDown:u=>u.preventDefault(),children:[e.jsx(ve,{children:e.jsx(De,{children:"Edit Microsoft Referral Details"})}),e.jsxs("div",{className:"-mx-6 flex-1 overflow-y-auto px-6",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx(y,{children:"* Deal Name"}),e.jsx(q,{value:m,onChange:u=>g(u.target.value)})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx(y,{children:"* Deal Value"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx("div",{children:e.jsx(q,{type:"number",placeholder:"Estimated Value",value:d,onChange:u=>N(u.target.value)})}),e.jsx("div",{children:e.jsxs(te,{value:w,onValueChange:A,children:[e.jsx(ae,{children:e.jsx(se,{placeholder:"Currency"})}),e.jsx(re,{children:E.currencyOptions?.map(u=>e.jsx(ie,{value:u.value,children:u.label},u.value))})]})})]})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx(y,{children:"Estimated ACR Value"}),e.jsx(q,{type:"number",value:s,onChange:u=>b(u.target.value)}),de&&e.jsx("p",{className:"text-xs text-destructive mt-1",children:"Estimated ACR Value must not be greater than Deal Value."}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"For Azure deals, estimate the Azure Consumed Revenue this customer is expected to consume. This helps Microsoft accurately recognize and engage with the deal."})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx(y,{children:"* Estimated Close Date"}),e.jsx(jt,{value:S,onChange:u=>I(u),label:"",width:"100%",minDate:new Date().toISOString().split("T")[0]})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx(y,{children:"Customer Purchase Intent"}),e.jsxs(te,{value:M,onValueChange:D,children:[e.jsx(ae,{children:e.jsx(se,{placeholder:"Select purchase intent"})}),e.jsx(re,{children:E.purchaseIntentOptions?.map(u=>e.jsx(ie,{value:u.value,children:u.label},u.value))})]})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx(y,{children:"Marketing Campaign ID"}
1),e.jsx(q,{value:v,onChange:u=>p(u.target.value)})]})]}),e.jsxs(Ae,{children:[e.jsx(F,{variant:"outline",onClick:j,children:"Cancel"}),e.jsxs(F,{disabled:!i||_,onClick:J,children:[_&&e.jsx(he,{className:"mr-2 size-4 animate-spin"}),"Save"]})]})]})})}const z={None:"None",ReviewPending:"ReviewPending",ActionRequired:"ActionRequired",Approved:"Approved",Passed:"Passed",Failed:"Failed",MarketplaceValidationPending:"MarketplaceValidationPending",MarketplaceValidationPassed:"MarketplaceValidationPassed",MarketplaceValidationFailed:"MarketplaceValidationFailed"},is={[z.None]:"Registration Pending",[z.ReviewPending]:"In Review",[z.ActionRequired]:"Action Required",[z.Approved]:"Approved",[z.Passed]:"Review Passed",[z.Failed]:"Review Failed",[z.MarketplaceValidationPending]:"Marketplace Validation Pending",[z.MarketplaceValidationPassed]:"Marketplace Validation Passed",[z.MarketplaceValidationFailed]:"Marketplace Validation Failed"},ft={[z.None]:{backgroundColor:"#DCFCE7",color:"#B91C1C"},[z.ReviewPending]:{backgroundColor:"#EDE9FE",color:"#6D28D9"},[z.ActionRequired]:{backgroundColor:"#FEF3C7",color:"#B91C1C"},[z.Approved]:{backgroundColor:"#DCFCE7",color:"#15803D"},[z.Passed]:{backgroundColor:"#DCFCE7",color:"#15803D"},[z.Failed]:{backgroundColor:"#FEF3C7",color:"#B91C1C"},[z.MarketplaceValidationPending]:{backgroundColor:"#FEF3C7",color:"#B91C1C"},[z.MarketplaceValidationPassed]:{backgroundColor:"#DCFCE7",color:"#15803D"},[z.MarketplaceValidationFailed]:{backgroundColor:"#FDF2F8",color:"#B91C1C"}},xt={isDealTypeCosellOrPartnerLed:{displayName:"Deal Type is Co-sell or Partner-led",description:"The referral must be of type Co-sell or Partner-led"},isMicrosoftReferralAcceptedOrWon:{displayName:"Microsoft Referral Accepted or Won",description:"The Microsoft referral status must be Accepted or Won"},isSolutionIncentiveEligible:{displayName:"Solution is Incentive Eligible",description:"At least one attached solution must be IP Co-sell eligible"},isDealValueEligible:{displayName:"Deal Value Meets Threshold",description:"The deal ACV must be ⥠$25,000 USD"},isCustomerManaged:{displayName:"Customer is Partner-managed",description:"The customer account must be managed by the partner (not Microsoft-managed)"}},ls=r=>r?is[r]||r:"Registration Pending",ns=r=>{if(!r)return ft[z.None];const o=ft[r];if(o)return{backgroundColor:o.backgroundColor,color:o.color};const c=r.toLowerCase();return c.includes("approved")||c.includes("passed")?{backgroundColor:"#DCFCE7",color:"#15803D"}:c.includes("pending")||c.includes("action")?{backgroundColor:"#FEF3C7",color:"#B91C1C"}:c.includes("failed")||c.includes("rejected")?{backgroundColor:"#FEF3C7",color:"#B91C1C"}:{backgroundColor:"#E5E7EB",color:"#374151"}};function os({eligibility:r,loading:o,error:c,registrations:x}){const f=a.useMemo(()=>{const d=Object.entries(xt).map(([s,b])=>({policyName:s,displayName:b.displayName,description:b.description,isEligible:!1}));return r?r.partnerEligible?[...r.passedPolicies||[],...r.failedPolicies||[]].map(s=>{const b=xt[s.policyName];return{policyName:s.policyName,displayName:b?.displayName||s.policyName,description:b?.description||"",isEligible:s.isEligible}}):d:c?d:[]},[r,c]),m=f.filter(d=>d.isEligible).length,g=x&&x.length>0?x[0]:null;return e.jsxs("div",{children:[e.jsx("div",{className:"rounded-md font-medium bg-gradient-to-r from-[#FFEEFF] to-[#DAEAFF] text-left px-5 py-3 text-[16px] text-foreground flex items-center gap-2",children:"Eligibility Checks"}),o?e.jsx("div",{className:"mt-3 bg-muted rounded-xl py-8 flex justify-center",children:e.jsx(he,{className:"size-6 animate-spin text-[#10B981]"})}):e.jsxs("div",{className:"mt-3 bg-muted rounded-xl py-5 flex flex-col gap-3",children:[g?e.jsxs("div",{className:"px-5 pb-1",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Deal registration status"}),e.jsxs("div",{className:"flex items-center justify-between mt-2",children:[e.jsx("span",{className:"inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold whitespace-nowrap",style:ns(g.status),children:ls(g.status)}),f.length>0&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:[m,"/",f.length," requirements met"]})]})]}):c&&!r||r&&!r.partnerEligible?e.jsx("div",{className:"mx-3 rounded-xl border border-[#B91C1C] bg-[#FDF2F8] p-[17.5px] shadow-sm",children:e.jsxs("div",{className:"flex items-start gap-[7px]",children:[e.jsx(aa,{size:16,color:"#B91C1C",className:"shrink-0 mt-[3px]"}),e.jsx("div",{className:"text-[16px] font-semibold text-[#B91C1C] leading-[22px]",children:"Deal registration is not available for this partner"})]})}):f.length>0?e.jsx("div",{className:"px-5 pb-1 flex justify-end",children:e.jsxs("span",{className:"text-sm text-muted-foreground",children:[m,"/",f.length," requirements met"]})}):null,f.map(d=>e.jsxs("div",{className:"flex items-start gap-3 px-4",children:[e.jsx(sa,{size:20,color:d.isEligible?"#10B981":"#CBD5E1",className:"mt-0.5 shrink-0"}),e.jsxs("div",{className:"flex-1 pb-1 pr-3",children:[e.jsx("div",{className:`text-[13px] font-semibold leading-[18px] ${d.isEligible?"text-foreground":"text-muted-foreground"}`,children:d.displayName}),d.description&&e.jsx("div",{className:`text-[13px] leading-[18px] mt-1 ${d.isEligible?"text-foreground":"text-muted-foreground"}`,children:d.description})]})]},d.policyName))]})]})}const cs=[{title:"Name",key:"name"},{title:"Email",key:"email"},{title:"Phone Number",key:"phoneNumber"}],ds=[{title:"Name",key:"name"},{title:"ID",key:"id"},{title:"Publisher Name",key:"publisherName"}],us=[{title:"Name",key:"name"},{title:"Email",key:"email"}],ms=[{title:"Partner Name",key:"partnerName"},{title:"Status",key:"status"},{title:"Estimated Close Date",key:"estimatedCloseDate"},{title:"Estimated Value",key:"estimatedValue"},{title:"Help Requested",key:"helpRequested"}];function Bi(){const{id:r}=fa({strict:!1}),o=gt(),c=$e(b=>b.currentOrganization?.id),x=a.useRef(c),{data:f,isFetching:m,refetch:g,error:d}=ra({queryKey:va.azureReferralDetail?.(c??"",r)??["azureReferralDetail",c,r],queryFn:()=>ja(c,r),enabled:!!c&&!!r}),N=a.useCallback(()=>g(),[g]);a.useEffect(()=>{d&&R.error(d?.response?.data?.message||d.message)},[d]),a.useEffect(()=>{x.current&&x.current!==c&&o({to:"/cosell"}),x.current=c},[c,o]);const s=f?.info?.microsoftReferralSet;return m&&!f?e.jsx(La,{className:"h-1"}):!s||!f?null:e.jsx(fs,{referral:f,onRefresh:N})}function fs({referral:r,onRefresh:o}){const c=$e(t=>t.currentOrganization?.id),x=$e(t=>t.integrations),f=Ee,{previewReferral:m}=qa(),g=gt(),[d,N]=a.useState(-1),[s,b]=a.useState(-1),[w,A]=a.useState(!1),[S,I]=a.use
1State(!1),[v,p]=a.useState(!1),[M,D]=a.useState(!1),[_,H]=a.useState(!1),[E,j]=a.useState(!1),[Z,J]=a.useState(!1),[de,i]=a.useState(!1),[u,V]=a.useState(!1),[C,P]=a.useState(!1),[L,ue]=a.useState(!1),[le,X]=a.useState(!1),[$,vt]=a.useState(null),[Dt,Re]=a.useState(!1),[Ye,Me]=a.useState(!1),[bt,He]=a.useState(!1),[Ct,We]=a.useState(!1),[Nt,_e]=a.useState(!1),[Ke,yt]=a.useState([]),[we,St]=a.useState(null),[Tt,Ge]=a.useState(!1),[kt,Ze]=a.useState(null),[Qe,Je]=a.useState(!1),n=a.useMemo(()=>r?.info?.microsoftReferralSet||{},[r]),W=r?.id||"",At=a.useMemo(()=>!!x?.find(t=>[Y.HUBSPOT,Y.SALESFORCE].includes(t.partner)&&t.service===ia.CRM),[x]),Ne=a.useMemo(()=>(n.self?.details?.requirements?.solutions||[]).map(l=>{const k=Ke.find(h=>h.id===l.id);return{...l,name:k?.name||l.name}}),[n,Ke]),Ie=a.useMemo(()=>Ba(r),[r]),Q=n.self?.direction==="Incoming",ne=n.self?.status==="Active"&&r?.status!==Ue.CREATE_FAILED,Pe=n.self?.status==="Closed",Xe=n.self?.substatus==="Pending",Oe=a.useMemo(()=>n.self?.status==="Closed"&&n.self?.substatus==="Won",[n]),Et=a.useMemo(()=>we?.isEligible??!1,[we]),et=a.useCallback(async()=>{if(!(!c||!W)){Ge(!0),Ze(null);try{const t=await xa(c,W);St(t)}catch(t){Ze(t.response?.data?.message||t.message||"Failed to check eligibility")}finally{Ge(!1)}}},[c,W]);a.useEffect(()=>{Oe&&et()},[Oe,et]);const ye=r?.status===Ue.CREATE_FAILED,Se=a.useMemo(()=>{if(r?.salesforceOpportunityId)return Y.SALESFORCE;if(r?.hubspotDealId)return Y.HUBSPOT;if(r?.dynamics365OpportunityId)return Y.DYNAMICS365},[r]),be=r?.salesforceOpportunityId||r?.hubspotDealId||r?.dynamics365OpportunityId,Rt=a.useMemo(()=>`autofix:azure-referral-submission-${(Se||"unknown").toLowerCase()}${be?`-${be}`:""}`,[Se,be]),Mt=a.useMemo(()=>wa(r)??"Private",[r]),wt=a.useMemo(()=>n.self?.details?.requirements?.additionalRequirements?.attributes?.some(l=>l.type==="PartnerRole"&&l.id)?"Service Co-sell":"IP Co-sell",[n]),It=a.useMemo(()=>{const t=n.self?.customerProfile?.team;if(t?.length){const l=t[0];return l.firstName&&l.lastName?`${l.firstName} ${l.lastName}`:l.firstName||l.lastName||"N/A"}return"N/A"},[n]),Te=a.useMemo(()=>{const t=n.self?.customerProfile?.team;return t?.length&&t[0].email||"N/A"},[n]),Pt=a.useMemo(()=>{let t="";const l=n.self?.customerProfile?.address;return l&&(l.addressLine1&&(t+=l.addressLine1),l.city&&(t.length>0&&(t+=", "),t+=l.city),l.state&&(t.length>0&&(t+=", "),t+=l.state),l.country&&(t.length>0&&(t+=", "),t+=l.country)),t||"N/A"},[n]),Ot=a.useMemo(()=>{const t=n.self?.customerProfile?.ids??[];let l="";for(const k of t)k.profileType==="External"&&k.id&&(l=k.id);return l||"N/A"},[n]),Ft=a.useMemo(()=>n.self?.details?.requirements?.additionalRequirements?.attributes?.find(l=>l.type==="SolutionArea")?.id||"N/A",[n]),Vt=a.useMemo(()=>Sa(n.self?.details?.requirements?.additionalRequirements?.attributes)||"N/A",[n]),zt=a.useMemo(()=>n.self?.details?.requirements?.additionalRequirements?.attributes?.find(l=>l.type==="CustomerMarketplaceIntent")?.id||"N/A",[n]),Lt=n.self?.campaignId||"N/A";n.self?.status;const qt=n.self?.substatus||"N/A",Bt=a.useMemo(()=>{const t=n.self?.id;return t?`https://partner.microsoft.com/dashboard/v2/referrals/v3/cosell/${Q?"inbound":"outbound"}/details?id=${t}`:""},[n,Q]),$t=n.self?.createdDateTime?pt(n.self.createdDateTime):"N/A",tt=n.self?.details?.closingDateTime?Le(n.self.details.closingDateTime,"YYYY-MM-DD"):"N/A",Ut=a.useMemo(()=>{const t=n.self?.team;return t?.length?t.map(l=>({name:`${l.firstName} ${l.lastName}`,email:l.email||"",phoneNumber:l.phoneNumber||""})):[]},[n]),Yt=a.useMemo(()=>Te?.includes("@")?la(Te):"",[Te]),Ht=a.useMemo(()=>n.connected?.find(t=>t.organizationId==="msft"),[n]),Ce=a.useMemo(()=>{if(!Q||!n.connected)return null;const t=n.connected.find(l=>l.organizationId!=="msft"&&l.inviteContext?.invitedBy?.organizationId===l.organizationId);return t||n.connected.find(l=>l.organizationId==="msft")},[Q,n]),ee=Q?Ce:Ht,Wt=a.useMemo(()=>Q&&Ce?`Help requested by ${Ce.organizationId==="msft"?"Microsoft":Ce.organizationName||"Partner"}`:"Help from Microsoft",[Q,Ce]),Fe=a.useMemo(()=>n.connected?n.connected.filter(t=>t.organizationId!=="msft").map(t=>{const l=t.details?.dealValue||"",k=t.details?.currency||"",h=l?`${k} ${l}`.trim():"",B=t.details?.closingDateTime?Le(t.details.closingDateTime,"YYYY-MM-DD"):"",oe=t.invite
1Context?.assistanceRequestCode||"",Ve=f?.helpFromMicrosoftOptionsValueLabelMap?.[oe]||oe,ke=t.details?.requirements?.solutions||[],ze=t.team||[];return{id:t.id,organizationId:t.organizationId||"",partnerName:t.organizationName||"",status:t.substatus||"",estimatedCloseDate:B,estimatedValue:h,helpRequested:Ve,dealName:t.name||"",notes:t.inviteContext?.notes||t.details?.notes||"",solutions:ke,solutionsCount:ke.length,team:ze}}):[],[n,f]),_t=a.useMemo(()=>Fe.map(t=>t.organizationId),[Fe]),Kt=a.useCallback(()=>({status:r?.status,partnerStatus:r?.partnerStatus||"",partner:r?.partner||"AZURE",errorMessages:r?.errorMessages||[],metaInfo:r?.metaInfo||{}}),[r]);a.useEffect(()=>{(async()=>{if(c)try{const l=await ma(c,"AZURE"),k=l.status>=400?[]:l.data??[];k instanceof Error||yt(k.filter(h=>h.status==="PUBLIC").map(h=>({id:h.info?.azureProduct?.id||"",name:h.info?.azureProduct?.name||""})).filter(h=>h.id))}catch(l){console.error("Failed to fetch company products:",l)}})()},[c]);const U=a.useCallback(async(t,l=!1)=>{if(!c||!W){l||R.error("Missing organization or referral ID");return}try{const k=Ya(r);Object.entries(t).forEach(([B,oe])=>{Ha(k,B,oe)}),await pa(c,W,k);const h=Object.keys(t).join(", ");l||R.success(`Successfully updated ${h}`),o()}catch(k){console.error("Failed to update referral:",k);const h=k.response?.data?.message||k.message||"Unknown error";l||R.error(`Failed to update referral: ${h}`)}},[c,W,r,o]),Gt=a.useCallback(async()=>{try{await U({"info.microsoftReferralSet.self.status":"Closed","info.microsoftReferralSet.self.substatus":"Won","info.microsoftReferralSet.self.salesStage":"100"},!0),R.success("Successfully closed the referral")}catch(t){console.error("Failed to close the referral:",t);const l=t.response?.data?.message||t.message||"Unknown error";R.error(`Failed to close the referral: ${l}`)}},[U]),at=a.useCallback(()=>{if(!be||!Se){R.error("Missing CRM record ID or CRM partner");return}g({to:"/cosell/resubmit/$referralId",params:{referralId:W}})},[be,Se,W,g]);Pa({partner:Y.AZURE,referral:r,errMsg:Ie,openResubmitDialog:at,chatbotScopeKey:Rt});const Zt=a.useCallback(async t=>{if(c){Me(!0);try{const l=t.selectedPartner===Y.SALESFORCE?{salesforceOpportunityId:t.selectId,hubspotDealId:void 0,dynamics365OpportunityId:void 0}:t.selectedPartner===Y.DYNAMICS365?{salesforceOpportunityId:void 0,hubspotDealId:void 0,dynamics365OpportunityId:t.selectId}:{salesforceOpportunityId:void 0,hubspotDealId:t.selectId,dynamics365OpportunityId:void 0};let k=t.selectId;try{const h=t.selectedPartner===Y.SALESFORCE?Y.SALESFORCE:t.selectedPartner===Y.DYNAMICS365?Y.DYNAMICS365:Y.HUBSPOT,B=await m(Y.AZURE,h,t.selectId,!1);B?.info?.microsoftReferralCreationRequest?.externalReferenceId&&(k=B.info.microsoftReferralCreationRequest.externalReferenceId)}catch(h){console.warn("Failed to get mapped externalReferenceId, falling back:",h)}l["info.microsoftReferralSet.self.externalReferenceId"]=k,await U(l,!0),R.success("Successfully linked with CRM.")}catch(l){console.error("Failed to link with CRM:",l);const k=l.response?.data?.message||l.message||"Unknown error";R.error(`Failed to link with CRM: ${k}`)}finally{Me(!1),Re(!1)}}},[c,U,m]),Qt=a.useCallback(async t=>{const l=(t.selectedSolutions||[]).map(h=>{const B=h.publisherName==="Microsoft"?"1P":"3P";return{id:h.id,name:h.name,solutionType:B}}),k={partnerOrganizationId:t.partnerOrganizationId,partnerOrganizationName:t.partnerName,assistanceRequestCode:t.assistanceRequestCode,notes:t.notes,dealValue:t.dealValue,currency:t.currency,estimatedCloseDate:t.estimatedCloseDate?new Date(t.estimatedCloseDate).toISOString():void 0,solutions:l,team:(t.teamMembers||[]).map(h=>{const{firstName:B,lastName:oe,email:Ve,phoneNumber:ke,title:ze}=h;return{firstName:B,lastName:oe,email:Ve,phoneNumber:ke,title:ze}})};if(!c||!W){R.error("Missing organization or referral ID");return}try{await ha(c,W,k),R.success("Partner invitation sent successfully.")}catch(h){console.error("Failed to invite partner:",h);const B=h.response?.data?.info||h.response?.data?.message||h.message||"Unknown error";R.error(`Failed to invite partner: ${B}
1`)}finally{await ga(c,"AZURE"),o()}},[c,W,o]),Jt=t=>t?.details?.closingDateTime?Le(t.details.closingDateTime,"YYYY-MM-DD"):"N/A",Xt=t=>{const l=Q?n.self?.inviteContext?.assistanceRequestCode:t?.inviteContext?.assistanceRequestCode;return l&&f?.helpFromMicrosoftOptionsValueLabelMap?.[l]||"N/A"},st=t=>{const l=[],k=t?.team;if(k?.length)for(const h of k){let B="N/A";h.firstName&&h.lastName?B=`${h.firstName} ${h.lastName}`:B=h.firstName||h.lastName||"N/A";const oe=h.email||"N/A";(h.firstName||h.lastName)&&h.email&&l.push({name:B,email:oe})}return l},ea=()=>{try{He(!0),o()}catch(t){console.error("Failed to refresh referral:",t)}finally{He(!1)}};return n?.self?e.jsxs("div",{className:"clear-layout-margin bg-card",children:[Ie&&e.jsx("div",{className:"bg-red-50 border border-red-200 text-red-700 px-4 py-3 text-sm",children:Ie}),e.jsxs("div",{className:"flex justify-between items-center h-[84px] px-7 border-b",children:[e.jsxs("div",{className:"flex items-center min-w-fit mr-4",children:[e.jsx("img",{className:"w-[32px] mr-2",src:Ua("MICROSOFT"),alt:"Microsoft"}),e.jsx("div",{className:"text-foreground",children:"Azure Referral"}),e.jsx(lt,{title:Q?"Inbound":"Outbound",hideIcon:!0,status:"info",className:"ml-2"})]}),e.jsxs("div",{className:"flex items-center min-w-fit gap-3",children:[At&&e.jsxs(F,{variant:"outline",className:"!h-11 !min-w-[140px]",disabled:Ye,onClick:()=>Re(!0),children:[e.jsx(Wa,{className:"mr-2 size-4"}),"Link With CRM"]}),e.jsx(Oa,{cloudPartner:"AZURE",referralId:W,orgId:c||"",onOperationsClick:()=>We(!0),onDetailsClick:()=>_e(!0),onRefreshSuccess:o,onResubmit:at,showResubmit:ye,showAccept:Xe,showDecline:Xe,onAccept:()=>P(!0),onDecline:()=>V(!0),onWon:!Pe&&!ye?()=>j(!0):void 0,onLost:!Pe&&!ye?()=>J(!0):void 0,onCloseAsError:!Pe&&!ye?()=>i(!0):void 0,linkToPartnerCenter:Bt}),e.jsx(na,{children:e.jsxs(oa,{children:[e.jsx(ca,{asChild:!0,children:e.jsx(F,{variant:"outline",size:"icon",className:"!w-11 !h-11",disabled:bt,onClick:ea,children:e.jsx(da,{className:"size-4"})})}),e.jsx(ua,{children:"Refresh referral data"})]})}),e.jsx(Da,{className:"ml-3"})]})]}),e.jsx(Va,{companyDomain:Yt,referral:r,sidebarExtra:Oe?e.jsxs(e.Fragment,{children:[e.jsx(os,{eligibility:we,loading:Tt,error:kt,registrations:n.self?.registrations}),e.jsx(Xa,{msReferralSet:n,allPassed:Et,onRegister:()=>Je(!0)})]}):void 0,children:e.jsxs("div",{className:"w-full overflow-auto",children:[e.jsx("div",{className:"px-7 pt-4",children:e.jsx(Ka,{msReferralSet:n,sugerReferral:r,updateReferral:U,onStageUpdated:o})}),e.jsxs(me,{title:"Details",titleExtra:ne?e.jsx(F,{variant:"ghost",className:"ml-2 text-link",onClick:()=>A(!0),children:"Edit"}):void 0,children:[e.jsx(T,{label:"Deal Name",value:n.self.name}),e.jsx(T,{label:"Deal Type",value:wt}),e.jsx(T,{label:"Co-sell Type",value:Mt}),e.jsx(T,{label:"Deal Value",value:n.self.details?.dealValue}),e.jsx(T,{label:"Estimated ACR Value",value:n.self.details?.estimatedACRValue}),e.jsx(T,{label:"MACC Eligibility",value:n.self.customerProfile?.isMaccEligible?"Yes":"No"}),e.jsx(T,{label:"Estimated Close Date",value:tt}),e.jsx(T,{label:"Marketplace purchase intent:",value:zt}),e.jsx(T,{label:"Marketing Campaign ID",value:Lt}),e.jsx(T,{label:"Created Date",value:$t}),e.jsx(T,{label:"Currency",value:n.self.details?.currency}),e.jsx(T,{label:"Status",children:e.jsx(Na,{data:Kt(),nowrap:!0})}),e.jsx(T,{label:"Stage",children:e.jsx(lt,{title:qt,status:"base",hideIcon:!0})}),e.jsx(T,{label:"Microsoft Status",children:e.jsx(Ia,{referral:r,fallback:e.jsx(e.Fragment,{children:"N/A"})})}),e.jsx(T,{label:"Created Source",value:$a(r?.metaInfo?.createdBySource)}),e.jsx(T,{label:"Created By Email",value:r?.metaInfo?.createdByEmail||"--"})]}),e.jsxs(me,{title:"Customer",children:[e.jsx(T,{label:"Company Name",value:n.self.customerProfile?.name}),e.jsx(T,{label:"Managed Account ID",value:Ot}),e.jsx(T,{label:"Location",value:Pt}),e.jsx(T,{label:"Contact Name",value:It}),e.jsx(T,{label:"Contact Email",value:Te}),e.jsx(T,{label:"Solution Area",value:Ft}),e.jsx(T,{label:"Conversation",value:Vt})]}),e.jsx(me,{title:"Team",titleExtra:ne?e.jsxs(F,{variant:"ghost",className:"ml-2 text-link",onClick:()=>I(!0),children:[e.jsx(qe,{className:"mr-1 size-4"}),"Add Team Member"]}):void 0,children:e.jsx("div",{className:"col-span-full",children:e.jsxs(fe,{children:[e.jsx(xe,{children:e.jsxs(K,{children:[cs.map(t=>e.jsx(G,{children:t.title},t.key)),ne&&e.jsx(G,{})]})}),e.jsx(pe,{children:Ut.map((t,l)=>e.jsxs(K,{children:[e.jsx(O,{children:t.name}),e.jsx(O,{children:t.email}),e.jsx(O,{children:t.phoneNumber}),ne&&e.jsx(O,{children:e.jsx(F,{variant:"ghost",size:"icon",onClick:()=>{N(l),p(!0)},children:e.jsx(it,{className:"size-4"})})})]},t.email||l))})]})})}),e.jsx(me,{title:"Solutions",titleExtra:ne?e.jsxs(F,{variant:"ghost",className:"ml-2 text-link",onClick:()=>D(!0),children:[e.jsx(qe,{className:"mr-1 size-4"}),"Add Solution"]}):void 0,children:e.jsx("div",{className:"col-span-full",children:e.jsxs(fe,{children:[e.jsx(xe,{children:e.jsxs(K,{children:[ds.map(t=>e.jsx(G,{children:t.title},t.key)),ne&&e.jsx(G,{})]})}),e.jsx(pe,{children:Ne.map((t,l)=>e.jsxs(K,{children:[e.jsx(O,{children:t.name}),e.jsx(O,{children:t.id}),e.jsx(O,{children:t.publisherName}),ne&&e.jsx(O,{children:e.jsx(F,{variant:"ghost",size:"icon",onClick:()=>{b(l),H(!0)},children:e.jsx(it,{className:"size-4"})})})]},t.id||l))})]})})}),ee&&e.jsxs(me,{title:Wt,children:[e.jsx(T,{label:"Estimated Value",value:ee.details?.dealValue||"N/A"}),e.jsx(T,{label:"Estimated Close Date",value:Jt(ee)}),ee.substatus==="Declined"&&e.jsx(T,{label:"Status Reason",value:ee.statusReason||"N/A"}),e.jsx(T,{label:"Assistance Requested",value:Xt(ee)}),e.jsx(T,{label:"CRM ID",value:ee.trackingInfo?.microsoftMsxId||"N/A"}),st(ee).length>0&&e.jsxs("div",{className:"col-span-full mt-4",children:[e.jsx("h4",{className:"text-sm font-semibold mb-2 text-foreground",children:"Team"}),e.jsxs(fe,{children:[e.jsx(xe,{children:e.jsx(K,{children:us.map(t=>e.jsx(G,{children:t.title},t.key))})}),e.jsx(pe,{children:st(ee).map(t=>e.jsxs(K,{children:[e.jsx(O,{children:t.name}),e.jsx(O,{children:t.email})]},t.email))})]})]})]}),e.jsx(me,{title:"Partner Collaboration",titleExtra:ne&&!Q?e.jsxs(F,{variant:"ghost",className:"ml-2 text-link",onClick:()=>ue(!0),children:[e.jsx(qe,{className:"mr-1 size-4"}),"Invite Partner"]}):void 0,children:e.jsx("div",{className:"col-span-full",children:e.jsxs(fe,{children:[e.jsx(xe,{children:e.jsx(K,{children:ms.map(t=>e.jsx(G,{children:t.title},t.key))})}),e.jsx(pe,{children:Fe.map(t=>e.jsxs(K,{children:[e.jsx(O,{children:e.jsx("button",{type:"button",className:"text-blue-600 cursor-pointer hover:underline",onClick:()=>{vt(t),X(!0)},children:t.partnerName})}),e.jsx(O,{children:t.status}),e.jsx(O,{children:t.estimatedCloseDate}),e.jsx(O,{children:t.estimatedValue}),e.jsx(O,{children:t.helpRequested})]},t.id))})]})})}),e.jsx(ya,{salesforceId:r?.salesforceOpportunityId,hubspotId:r?.hubspotDealId,dynamics365Id:r?.dynamics365OpportunityId})]})}),e.jsx(za,{visible:Dt,onHide:()=>{Ye&&Me(!1),Re(!1)},referralId:W,keyword:n.self?.customerProfile?.name,cloudPartner:"AZURE",onSelect:Zt}),e.jsx(rs,{visible:w,onHide:()=>A(!1),msReferralSet:n,updateReferral:U,onRefresh:o}),e.jsx(dt,{visible:S,onHide:()=>I(!1),msReferralSet:n,updateReferral:U,onRefresh:o}),e.jsx(dt,{visible:v,onHide:()=>p(!1),editIndex:d,msReferralSet:n,isEditTeamMember:!0,updateReferral:U,onRefresh:o}),e.jsx(nt,{visible:M,onVisibleChange:t=>D(t),selectedSolutionIds:Ne.map(t=>
1t.id),onSelect:async t=>{const l=n?.self?.solutions||[];await U({"info.microsoftReferralSet.self.solutions":[...l,{id:t.id,name:t.name,publisherName:t.publisherName}]}),D(!1),o()}}),e.jsx(nt,{visible:_,onVisibleChange:t=>H(t),selectedSolutionIds:Ne.map(t=>t.id),onSelect:async t=>{const l=[...n?.self?.solutions||[]];l[s]={id:t.id,name:t.name,publisherName:t.publisherName},await U({"info.microsoftReferralSet.self.solutions":l}),H(!1),o()}}),e.jsx(Be,{visible:Z,onHide:()=>J(!1),msReferralSet:n,updateReferral:U,isCloseWithLostStatus:!0,onRefresh:o}),e.jsx(Be,{visible:de,onHide:()=>i(!1),msReferralSet:n,updateReferral:U,isCloseAsError:!0,onRefresh:o}),e.jsx(Be,{visible:u,onHide:()=>V(!1),msReferralSet:n,updateReferral:U,isCloseWithDecline:!0,onRefresh:o}),e.jsx(_a,{visible:C,onHide:()=>P(!1),msReferralSet:n,updateReferral:U,onRefresh:o}),e.jsx(Ta,{visible:L,onVisibleChange:t=>ue(t),estimatedCloseDate:tt!=="N/A"?String(n.self.details?.closingDateTime??"").split("T")[0]:"",estimatedValue:String(n.self.details?.dealValue||""),currency:n.self.details?.currency||"USD",teamMembers:n.self.team||[],solutions:Ne.map(t=>({id:t.id||"",name:t.name||"",publisherName:t.publisherName})),existingPartnerIds:_t,onSelect:Qt}),e.jsx(ge,{open:le,onOpenChange:X,children:e.jsxs(je,{className:"max-w-[700px]",children:[e.jsx(ve,{children:e.jsx(De,{children:"Partner Collaboration Details"})}),$&&e.jsxs("div",{className:"overflow-auto max-h-[70vh]",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("div",{className:"text-base font-bold mb-2",children:"Partner Information"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Partner Name"}),e.jsx("div",{className:"font-medium",children:$.partnerName})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Status"}),e.jsx("div",{className:"font-medium",children:$.status})]})]})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("div",{className:"text-base font-bold mb-2",children:"Deal Details"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Deal Name"}),e.jsx("div",{className:"font-medium",children:$.dealName||"N/A"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Estimated Value"}),e.jsx("div",{className:"font-medium",children:$.estimatedValue||"N/A"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Estimated Close Date"}),e.jsx("div",{className:"font-medium",children:$.estimatedCloseDate||"N/A"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Help Requested"}),e.jsx("div",{className:"font-medium",children:$.helpRequested||"N/A"})]})]}),$.notes&&e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Notes"}),e.jsx("div",{className:"font-medium",children:$.notes})]})]}),$.solutions?.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"text-base font-bold mb-2",children:["Solutions (",$.solutions.length,")"]}),e.jsxs(fe,{children:[e.jsx(xe,{children:e.jsxs(K,{children:[e.jsx(G,{children:"Name"}),e.jsx(G,{children:"ID"}),e.jsx(G,{children:"Publisher"})]})}),e.jsx(pe,{children:$.solutions.map(t=>e.jsxs(K,{children:[e.jsx(O,{children:t.name}),e.jsx(O,{children:t.id}),e.jsx(O,{children:t.publisherName})]},t.id))})]})]}),$.team?.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"text-base font-bold mb-2",children:["Team (",$.team.length,")"]}),e.jsxs(fe,{children:[e.jsx(xe,{children:e.jsxs(K,{children:[e.jsx(G,{children:"Name"}),e.jsx(G,{children:"Email"})]})}),e.jsx(pe,{children:$.team.map(t=>e.jsxs(K,{children:[e.jsx(O,{children:[t.firstName,t.lastName].filter(Boolean).join(" ")||"N/A"}),e.jsx(O,{children:t.email||"N/A"})]},t.email||`${t.firstName}-${t.lastName}`))})]})]})]})]})}),e.jsx(ba,{visible:E,message:"When you close a deal you will no longer be able to edit it. Are you sure you want to proceed?",onConfirm:Gt,onHide:()=>j(!1)}),e.jsx(Fa,{visible:Ct,onHide:()=>We(!1),referral:r}),e.jsx(Ca,{visible:Nt,onHide:()=>_e(!1),item:r}),Qe&&e.jsx(ss,{visible:Qe,onHide:()=>Je(!1),msReferralSet:n,updateReferral:U,onRefresh:o})]}):null}export{Bi as component};
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.