PageSourceSearch

https://app.eano.com/_next/static/chunks/50449-57f19f174d888acf.js

js eano.com collected 2026-10-01 15:42:52 UTC 276,385 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[50449],{48519:function(e,t,s){s.d(t,{U:function(){return l}});var n=s(52676);s(75271);let a={left:"text-left",center:"text-center",right:"text-right"};function l(e){let{field:t,label:s,sortConfig:l,onSort:r,width:i="",className:o="",tooltip:d,align:c="left"}=e,u=l.field===t;return(0,n.jsx)("th",{className:"group px-4 py-4 ".concat(a[c]," text-14 font-medium text-[#7C8293] bg-[#F3F3F3]\n        cursor-pointer hover:bg-[#E8E8E8] transition-colors ").concat(i," ").concat(o),onClick:()=>r(t),children:(0,n.jsxs)("div",{className:"flex items-center gap-1 ".concat("center"===c?"justify-center":""),children:[(0,n.jsx)("span",{children:s}),d&&(0,n.jsx)("span",{className:"flex-shrink-0",children:d}),(0,n.jsx)("svg",{className:"ml-1 h-3 w-3 flex-shrink-0 transition-transform ".concat(u?"asc"===l.order?"rotate-180":"":"opacity-30"),fill:"currentColor",viewBox:"0 0 20 20",children:(0,n.jsx)("path",{d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"})})]})})}},32306:function(e,t,s){var n=s(52676),a=s(75271),l=s(47280);t.Z=e=>{let{value:t,onChange:s,options:r,placeholder:i,renderValue:o,className:d,disabled:c=!1}=e,[u,x]=(0,a.useState)(!1),p=(0,a.useRef)(null);return(0,a.useEffect)(()=>{let e=e=>{p.current&&!p.current.contains(e.target)&&x(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,n.jsxs)("div",{ref:p,className:(0,l.cn)("relative",d),children:[(0,n.jsxs)("div",{onClick:()=>!c&&x(!u),className:(0,l.cn)("h-11 px-4 pr-10 rounded-[30px] border border-[#E5E7EB] bg-white","flex items-center relative",c?"opacity-50 cursor-not-allowed":"cursor-pointer hover:border-[#E5E7EB] focus:outline-none focus:ring-2 focus:ring-[#0052CC]",u&&!c&&"ring-2 ring-[#0052CC] border-[#0052CC]"),title:o?void 0:(()=>{if(!t&&i)return i;let e=r.find(e=>e.value===t);return(null==e?void 0:e.label)||String(t)})(),children:[(0,n.jsx)("span",{className:"text-[#051023] text-sm truncate flex-1 pr-2",children:(()=>{if(o&&t)return o(t);if(!t&&i)return(0,n.jsx)("span",{className:"text-[#9CA3AF]",children:i});let e=r.find(e=>e.value===t);return(null==e?void 0:e.label)||t})()}),(0,n.jsx)("svg",{className:(0,l.cn)("absolute right-4 w-4 h-4 transition-transform flex-shrink-0",u&&"rotate-180"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M19 9l-7 7-7-7"})})]}),u&&!c&&(0,n.jsx)("div",{className:"absolute top-full mt-1 w-full bg-white border border-[#E1E4EB] rounded-lg shadow-lg z-10 max-h-60 overflow-auto",children:r.map(e=>(0,n.jsx)("div",{onClick:()=>{s(e.value),x(!1)},className:"px-4 py-2 hover:bg-[#F7F8FA] cursor-pointer text-sm text-[#051023]",children:e.label},e.value))})]})}},28882:function(e,t,s){s.d(t,{U:function(){return a},k:function(){return n}});let n="#E12424",a="#35AB3B"},91043:function(e,t,s){var n=s(52676),a=s(75271),l=s(29037);let r=[{key:"qbOpportunityAutoCreate",title:"Automatically add new opportunities",description:"Automatically create a new project in QuickBooks for every new opportunity created in Eano, and automatically link the two projects"},{key:"qbProjectAutoCreate",title:"Automatically add new projects",description:"Automatically create a new project in QuickBooks for every new project created in Eano, including opportunities that convert to projects, and automatically link the two projects"}];t.Z=e=>{let{values:t,pendingKeys:s,disabled:i=!1,onChange:o,className:d=""}=e;return(0,n.jsx)("div",{className:"rounded-xl p-4 bg-white border-[1.5px] border-en-divider-dark shadow ".concat(d),children:r.map((e,r)=>{let{key:d,title:c,description:u}=e;return(0,n.jsxs)(a.Fragment,{children:[r>0&&(0,n.jsx)("div",{className:"h-4"}),(0,n.jsxs)(l.Z,{isChecked:!!(null==t?void 0:t[d]),onChange:e=>o(d,e),isDisabled:i||s.has(d),checkboxVerticalAlign:"top",labelPadding:"0",dataTestId:d,children:[(0,n.jsx)("div",{className:"font-medium text-sm mb-1 text-en-dark-blue",children:c}),(0,n.jsx)("p",{className:"text-sm text-en-light-blue leading-relaxed font-normal",children:u})]})]},d)})})}},80739:function(e,t,s){s.d(t,{O:function(){return r}});var n=s(52676),a=s(75271),l=s(56674);let r=e=>{let{onSettingClick:t,onDisconnectClick:s}=e,[r,i]=(0,a.useState)(!1),o=(0,a.useRef)(null);return(0,a.useEffect)(()=>{let e=e=>{r&&o.current&&!o.current.contains(e.target)&&i(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[r]),(0,n.jsxs)("div",{className:"relative",ref:o,children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-[#E6FAE6] rounded-lg",children:[(0,n.jsx)("svg",{className:"w-2 h-2",viewBox:"0 0 8 8",fill:"none",children:(0,n.jsx)("circle",{cx:"4",cy:"4",r:"4",fill:"#35AB3B"})}),(0,n.jsx)("span",{className:"text-sm text-[#051023]",children:"Connected to QuickBooks"}),(0,n.jsx)("button",{className:"p-0.5 hover:bg-[#D0EDD0] rounded transition-colors",onClick:e=>{e.stopPropagation(),i(!r)},children:(0,n.jsxs)("svg",{className:"w-5 h-5",viewBox:"0 0 32 44",fill:"none",children:[(0,n.jsx)("circle",{cx:"8",cy:"22",r:"2",fill:"#3B4658"}),(0,n.jsx)("circle",{cx:"15",cy:"22",r:"2",fill:"#3B4658"}),(0,n.jsx)("circle",{cx:"22",cy:"22",r:"2",fill:"#3B4658"})]})})]}),r&&(0,n.jsxs)("div",{className:"absolute right-0 top-full mt-2 w-48 bg-white rounded-lg shadow-lg border border-[#
1E1E4EB] py-1 z-50",children:[(0,n.jsxs)("button",{onClick:e=>{e.stopPropagation(),i(!1),null==t||t()},className:"w-full px-4 py-2 text-left hover:bg-[#F7F8FA] flex items-center gap-2",children:[(0,n.jsx)(l.Z,{className:"w-[18px] h-[18px] text-[#3B4658]"}),(0,n.jsx)("span",{className:"text-[#051023] text-sm",children:"Setting"})]}),(0,n.jsxs)("button",{onClick:e=>{e.stopPropagation(),i(!1),null==s||s()},className:"w-full px-4 py-2 text-left hover:bg-[#F7F8FA] flex items-center gap-2",children:[(0,n.jsxs)("svg",{className:"w-[18px] h-[18px]",viewBox:"0 0 18 18",fill:"none",children:[(0,n.jsx)("g",{clipPath:"url(#clip0_qb_disconnect)",children:(0,n.jsx)("path",{d:"M1.09141 1.94242C0.798908 1.7118 0.374221 1.76524 0.143596 2.05774C-0.0870294 2.35024 -0.0335919 2.77492 0.258908 3.00555L16.9089 16.0555C17.2014 16.2862 17.6261 16.2327 17.8567 15.9402C18.0873 15.6477 18.0339 15.223 17.7414 14.9924L13.7617 11.8734L16.307 9.32805C17.8961 7.73899 17.8961 5.16555 16.307 3.57649C14.9008 2.17024 12.6845 1.98742 11.0673 3.14336L11.0223 3.1743C10.6173 3.46399 10.5245 4.02649 10.8142 4.42867C11.1039 4.83086 11.6664 4.92649 12.0686 4.6368L12.1136 4.60586C13.0164 3.9618 14.2511 4.06305 15.033 4.84774C15.9189 5.73367 15.9189 7.16805 15.033 8.05399L12.333 10.754L11.4358 10.0509C12.1192 8.53774 11.8155 6.72367 10.6033 5.51149C9.13516 4.04055 6.82047 3.93086 5.22297 5.18242L1.09141 1.94242ZM6.72203 6.35524C7.56859 5.93617 8.62609 6.0768 9.33203 6.78555C9.89453 7.34805 10.1055 8.14399 9.94234 8.88086L6.72203 6.35524ZM3.27953 7.08367L1.69328 8.66992C0.104221 10.259 0.104221 12.8324 1.69328 14.4215C3.09953 15.8277 5.31578 16.0105 6.93297 14.8546L6.97797 14.8237C7.38297 14.534 7.47578 13.9715 7.18609 13.5693C6.89641 13.1671 6.33391 13.0715 5.93172 13.3612L5.88672 13.3921C4.98391 14.0362 3.74922 13.9349 2.96735 13.1502C2.08141 12.2615 2.08141 10.8271 2.96735 9.94117L4.70547 8.20305L3.28235 7.08086L3.27953 7.08367ZM6.21297 9.39274C6.15391 10.5121 6.5561 11.6455 7.39985 12.4865C8.49391 13.5805 10.0548 13.9209 11.4386 13.5074L6.21297 9.39274Z",fill:"#E12424"})}),(0,n.jsx)("defs",{children:(0,n.jsx)("clipPath",{id:"clip0_qb_disconnect",children:(0,n.jsx)("rect",{width:"18",height:"18",fill:"white"})})})]}),(0,n.jsx)("span",{className:"text-[#E12424] text-sm",children:"Disconnect"})]})]})]})};t.Z=r},93542:function(e,t,s){s.d(t,{A:function(){return r}});var n=s(52676),a=s(75271),l=s(28317);let r=e=>{let{open:t,onClose:s,onDisconnect:r}=e,[i,o]=(0,a.useState)(!1),d=async()=>{o(!0);try{await r()&&s()}catch(e){console.error("Failed to disconnect from QuickBooks:",e)}finally{o(!1)}};return(0,n.jsxs)(l.Z,{open:t,onClose:()=>!i&&s(),maxWidth:!1,PaperProps:{className:"rounded-2xl shadow-2xl !max-w-[600px] w-full px-16 py-14"},children:[(0,n.jsx)("h2",{className:"text-28 font-circular-bold text-en-dark-blue mb-6",children:"Confirm account disconnection"}),(0,n.jsxs)("div",{className:"space-y-4 mb-8 text-en-mid-blue text-base",children:[(0,n.jsx)("p",{className:"leading-relaxed",children:"Disconnecting your account will disable sync between your linked QuickBooks account and Eano. You'll lose access to any features that rely on QuickBooks data."}),(0,n.jsx)("p",{className:"leading-relaxed",children:"You can always re-enable these features later by re-connecting your QuickBooks account."}),(0,n.jsx)("p",{className:"leading-relaxed",children:"Please be sure you'd like to disconnect your account before continuing."})]}),(0,n.jsxs)("div",{className:"flex justify-between gap-4",children:[(0,n.jsx)("button",{onClick:s,disabled:i,className:"flex-1 px-6 py-3 text-base font-medium text-[#051023] bg-white border-2 border-[#D1D5DB] rounded-lg hover:bg-[#F9FAFB] transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:"Cancel"}),(0,n.jsx)("button",{onClick:d,disabled:i,style:{background:"linear-gradient(0deg, rgba(255, 255, 255, 0.90) 0%, rgba(255, 255, 255, 0.90) 100%), #F02326"},className:"flex-1 px-6 py-3 text-base font-medium border border-[#F02326] text-[#F02326] rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2 whitespace-nowrap",children:i?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-[#F02326]"}),(0,n.jsx)("span",{className:"whitespace-nowrap",children:"Disconnecting..."})]}):"Disconnect My Account"})]})]})};t.Z=r},85777:function(e,t,s){s.d(t,{ej:function(){return c},uc:function(){return i}});var n=s(52676),a=s(75271),l=s(2032),r=s(47541);let i=(e,t,s)=>{let n=new Date;switch(e){case"today":return{startDate:(0,l.WU)(n,"yyyy-MM-dd"),endDate:(0,l.WU)((0,r.E)(n,1),"yyyy-MM-dd")};case"this_month":return{startDate:(0,l.WU)(new Date(n.getFullYear(),n.getMonth(),1),"yyyy-MM-dd"),endDate:(0,l.WU)(new Date(n.getFullYear(),n.getMonth()+1,0),"yyyy-MM-dd")};case"this_year":return{startDate:(0,l.WU)(new Date(n.getFullYear(),0,1),"yyyy-MM-dd"),endDate:(0,l.WU)(new Date(n.getFullYear(),11,31),"yyyy-MM-dd")};case"last_year":return{startDate:(0,l.WU)(new Date(n.getFullYear()-1,0,1),"yyyy-MM-dd"),endDate:(0,l.WU)(new Date(n.getFullYear()-1,11,31),"yyyy-MM-dd")};
1case"custom":if(t&&s)return{startDate:t,endDate:s};return null;default:return null}},o=e=>{let[t,s,n]=e.split("-");return"".concat(s,"/").concat(n,"/").concat(t)},d=(e,t,s)=>{let n=new Date;switch(e){case"today":return"Today (".concat((0,l.WU)(n,"MM/dd/yyyy"),")");case"this_month":return"This Month (".concat((0,l.WU)(new Date(n.getFullYear(),n.getMonth(),1),"MM/dd/yyyy"),")");case"this_year":return"This Year (".concat((0,l.WU)(new Date(n.getFullYear(),0,1),"MM/dd/yyyy"),")");case"last_year":return"Last Year (".concat((0,l.WU)(new Date(n.getFullYear()-1,0,1),"MM/dd/yyyy"),")");case"custom":if(t&&s)return"".concat(o(t)," - ").concat(o(s));return"Custom";default:return""}},c=e=>{let{defaultOption:t="this_year",disabled:s=!1,onChange:r,label:o="Start Sync From",width:c=320}=e,[u,x]=(0,a.useState)(t),[p,m]=(0,a.useState)(""),[h,v]=(0,a.useState)(""),[g,f]=(0,a.useState)(!1),b=e=>{if(x(e),f(!1),"custom"!==e){let t=i(e);t&&r&&r(t,e)}},j=(e,t)=>{"start"===e?(m(t),t&&h&&r&&r({startDate:t,endDate:h},"custom")):(v(t),p&&t&&r&&r({startDate:p,endDate:t},"custom"))},y="number"==typeof c?{width:"".concat(c,"px")}:{};return(0,n.jsxs)("div",{className:"sync-date-range-picker",children:[(0,n.jsxs)("div",{className:"mb-3 relative",children:[o&&(0,n.jsx)("div",{className:"text-en-light-blue text-14 mb-1",children:o}),(0,n.jsxs)("button",{type:"button",onClick:()=>!s&&f(!g),disabled:s,style:y,className:"bg-en-bg-black-50 w-full px-4 py-3 text-base text-left border border-en-divider-dark rounded-lg focus:outline-none focus:ring-2 focus:ring-[#0052CC] focus:border-transparent cursor-pointer flex items-center justify-between disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,n.jsx)("span",{className:"text-[#051023]",children:d(u,p,h)}),(0,n.jsx)("svg",{className:"w-5 h-5 text-[#7C8293] transition-transform ".concat(g?"rotate-180":""),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),g&&(0,n.jsxs)("div",{style:y,className:"absolute top-full left-0 mt-2 bg-white border border-[#E1E4EB] rounded-lg shadow-lg z-50 overflow-hidden",children:[(0,n.jsxs)("label",{className:"flex items-center gap-3 px-4 py-3 hover:bg-[#F7F8FA] cursor-pointer transition-colors",children:[(0,n.jsx)("input",{type:"radio",name:"syncOption",value:"today",checked:"today"===u,onChange:()=>b("today"),className:"w-5 h-5 text-[#0052CC] focus:ring-[#0052CC] focus:ring-2"}),(0,n.jsxs)("span",{className:"text-base text-[#051023]",children:["Today ",(0,n.jsxs)("span",{className:"text-[#7C8293]",children:["(",(0,l.WU)(new Date,"MM/dd/yyyy"),")"]})]})]}),(0,n.jsxs)("label",{className:"flex items-center gap-3 px-4 py-3 hover:bg-[#F7F8FA] cursor-pointer transition-colors",children:[(0,n.jsx)("input",{type:"radio",name:"syncOption",value:"this_month",checked:"this_month"===u,onChange:()=>b("this_month"),className:"w-5 h-5 text-[#0052CC] focus:ring-[#0052CC] focus:ring-2"}),(0,n.jsxs)("span",{className:"text-base text-[#051023]",children:["This Month"," ",(0,n.jsxs)("span",{className:"text-[#7C8293]",children:["(",(0,l.WU)(new Date(new Date().getFullYear(),new Date().getMonth(),1),"MM/dd/yyyy"),")"]})]})]}),(0,n.jsxs)("label",{className:"flex items-center gap-3 px-4 py-3 hover:bg-[#F7F8FA] cursor-pointer transition-colors",children:[(0,n.jsx)("input",{type:"radio",name:"syncOption",value:"this_year",checked:"this_year"===u,onChange:()=>b("this_year"),className:"w-5 h-5 text-[#0052CC] focus:ring-[#0052CC] focus:ring-2"}),(0,n.jsxs)("span",{className:"text-base text-[#051023]",children:["This Year"," ",(0,n.jsxs)("span",{className:"text-[#7C8293]",children:["(",(0,l.WU)(new Date(new Date().getFullYear(),0,1),"MM/dd/yyyy"),")"]})]})]}),(0,n.jsxs)("label",{className:"flex items-center gap-3 px-4 py-3 hover:bg-[#F7F8FA] cursor-pointer transition-colors",children:[(0,n.jsx)("input",{type:"radio",name:"syncOption",value:"last_year",checked:"last_year"===u,onChange:()=>b("last_year"),className:"w-5 h-5 text-[#0052CC] focus:ring-[#0052CC] focus:ring-2"}),(0,n.jsxs)("span",{className:"text-base text-[#051023]",children:["Last Year"," ",(0,n.jsxs)("span",{className:"text-[#7C8293]",children:["(",(0,l.WU)(new Date(new Date().getFullYear()-1,0,1),"MM/dd/yyyy"),")"]})]})]}),(0,n.jsxs)("label",{className:"flex items-center gap-3 px-4 py-3 hover:bg-[#F7F8FA] cursor-pointer transition-colors",children:[(0,n.jsx)("input",{type:"radio",name:"syncOption",value:"custom",checked:"custom"===u,onChange:()=>b("custom"),className:"w-5 h-5 text-[#0052CC] focus:ring-[#0052CC] focus:ring-2"}),(0,n.jsx)("span",{className:"text-base text-[#051023]",children:"Custom"})]})]})]}),"custom"===u&&(0,n.jsxs)("div",{className:"mb-3 space-y-4",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"block text-sm font-medium text-[#051023] mb-2",children:"Start Date"}),(0,n.jsx)("input",{type:"date",value:p,onChange:e=>j("start",e.target.value),max:h||void 0,style:y,className:"bg-en-bg-black-50 px-4 w-full py-3 text-base border border-[#D1D5DB] rounded-lg focus:outline-none focus:ring-2 focus:ring-[#0052CC] focus:border-transparent",disabled:s})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"block text-sm font-medium text-[#051023] mb-2",children:"End Date"}),(0,n.jsx)("input",{type:"date",value:h,onChange:e=>j("end",e.target.value),min:p,style:y,className:"bg-en-bg-black-50 px-4 w-full py-3 text-base border border-[#D1D5DB] rounded-lg focus:outline-none focus:ring-2 focus:ring-[#0052CC] focus:border-transparent",disabled:s})]})]})]})}},11052:function(e,t,s){s.d(t,{S:function(){return i}});var n=s(52676);s(75271);var a=s(20896),l=s(80574);let r=e=>null==e||"string"==typeof e&&""===e.trim(),i=e=>{let{lineItems:t,classNames:s="mt-8 text-16",showQtyPrice:i}=e,o=t.some(e=>e.is_header);return(0,n.jsx)("div",{className:s,children:(0,n.jsxs)("table",{className:"w-full",children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{className:"border-b border-[#DFE1E6]",children:[(0,n.jsx)("th",{className:"text-left py-3 font-medium text-[#6B778C]",children:"Description"}),(0,n.jsx)("th",{className:"text-left py-3 font-medium text-[#6B778C] w-24",children:i&&"Quantity"}),(0,n.jsx)("th",{className:"text-left py-3 font-medium text-[#6B778C] w-32",children:i&&"Unit Price"}),(0,n.jsx)("th",{className:"text-right py-3 font-medium text-[#6B778C] w-32",children:"Amount"})]})}),(0,n.jsx)("tbody",{children:t.map((e,t)=>e.is_header?(0,n.jsx)("tr",{className:"border-b border-[#F4F5F7]",children:(0,n.jsx)("td",{colSpan:4,className:"py-4 text-[#172B4D] ".concat(2===e.header_level?"pl-6 font-medium":"font-circular-bold"),children:r(e.description)?"\xa0":e.description})},e.id||t):(0,n.jsxs)("tr",{className:"border-b border-[#F4F5F7]",children:[(0,n.jsx)("td",{className:"py-4 text-[#172B4D] ".concat(o?(0,l.g2)(e):""),children:r(e.description)?"\xa0":e.description}),(0,n.jsx)("td",{className:"py-4 text-[#172B4D] text-left",children:r(e.quantity)?"\xa0":e.quantity}),(0,n.jsx)("td",{className:"py-4 text-[#172B4D] text-left",children:r(e.unit_amount)?"\xa0":(0,a.E)(e.unit_amount,!0)}),(0,n.jsx)("td",{className:"py-4 font-medium text-[#172B4D] text-right",children:r(e.amount)?"\xa0":(0,a.E)(e.amount,!0)})]},e.id||t))})]})})}},62845:function(e,t,s){s.d(t,{kB:function(){return w.k},tU:function(){return b},et:function(){return y.e},SB:function(){return j.S},nQ:function(){return N.Z}});var n=s(52676),a=s(75271),l=s(47280),r=s(36246),i=s(22294),o=s(22944),d=s(84241),c=s(59100),u=s(9530),x=s(4816),p=s(874),m=s.n(p),h=s(56680),v=s(21765),g=s(56080),f=s(25034);let b=e=>{let{invoiceId:t,invoiceStatus:s,isVoided:p=!1,hasPaidViaStripe:b=!1,hasAttachments:j=!1,onAction:y,onPreviewAsClient:w,draftCanFinalize:N}=e,[C,k]=(0,a.useState)(!1),[_,F]=(0,a.useState)(!1),E=(0,a.useRef)(null);(0,a.useEffect)(()=>{let e=e=>{E.current&&!E.current.contains(e.target)&&k(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);let S=3===s,D=2===s,I=S||D,A=0===s,P=async()=>{try{let s=await (0,v.r)({url:"/api/v1/invoice/invoice/generate_link/",method:"post",params:{invoice_id:t}});if(s.isOk){var e;let t=null===(e=s.result)||void 0===e?void 0:e.shareUrl;m()(t),F(!0),setTimeout(()=>{F(!1),k(!1)},1500)}else g.ZP.error(s.resMessage||"Failed to generate link"),k(!1)}catch(e){g.ZP.error("Failed to generate invoice link"),k(!1)}},B=void 0===N,M=B||!N,L=e=>B?"Checking…":N?e:"Finish this draft before finalizing — open it to add a due date and at least one priced line.",Z=A&&!p?[{id:"finalize_draft",label:"Save",icon:(0,n.jsx)(r.Z,{size:20,color:M?"#9AA1AC":"#0052CC"}),primary:!0,disabled:M,tooltip:L("Save a finalized invoice without notifying the client.")},{id:"finalize_and_send_draft",label:"Save & Send to Client",icon:(0,n.jsx)(i.Z,{size:20,color:M?"#9AA1AC":"#0052CC"}),primary:!0,disabled:M,tooltip:L("Save finalized invoice and notify the client.")}]:[],T=w?[{id:"preview",label:"Preview as Client",icon:(0,n.jsx)(o.Z,{size:20,color:"#3B4658"}),onClick:()=>{k(!1),w&&w()},dividerBefore:Z.length>0}]:[],O=j?[{id:"export_pdf",label:"Download PDF only",icon:(0,n.jsx)(h.E5,{}),dividerBefore:0===T.length&&Z.length>0},{id:"export_zip",label:"Download ZIP with attachments",icon:(0,n.jsx)(d.Z,{size:20,color:"#3B4658"})}]:[{id:"export_pdf",label:"Download PDF",icon:(0,n.jsx)(h.E5,{}),dividerBefore:0===T.length&&Z.length>0}],R=1!==s&&2!==s&&3!==s||p?[]:[{id:"copy_link",label:_?"Copied!":"Copy Sharing Link",icon:_?(0,n.jsx)(c.Z,{size:20,color:"#36B37E"}):(0,n.jsx)(u.Z,{size:20,color:"#3B4658"}),onClick:P,textColor:_?"#36B37E":void 0}],z=1!==s||p?[]:[{id:"send_reminder",label:"Send Reminder",icon:(0,n.jsx)(h.Dk,{}),disabled:I}],W=A&&!p?[{id:"delete_draft",label:"Delete",icon:(0,n.jsx)(x.Z,{size:20,color:"#E12424"}),danger:!0,dividerBefore:!0}]:[],q=D||S&&b,U=[...Z,...T,...O,...R,...z,...W];return(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsxs)("div",{ref:E,className:"relative",children:[(0,n.jsxs)("button",{onClick:()=>k(!C),className:"px-4 py-2.5 bg-white text-en-dark-blue rounded-lg font-medium hover:bg-gray-50 transition-all flex items-center gap-2",children:["More Actions",(0,n.jsx)("svg",{className:(0,l.cn)("w-4 h-4 transition-transform",C&&"rotate-180"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),C&&(0,n.jsx)("div",{className:"absolute right-0 top-full mt-2 w-56 bg-white rounded-lg shadow-lg border border-[#
1E1E4EB] z-50",children:U.map((e,t)=>{let s=(0,n.jsxs)("button",{onClick:()=>{e.disabled||(e.onClick?e.onClick():(y(e.id),k(!1)))},disabled:e.disabled,className:(0,l.cn)("w-full px-4 py-3 text-left text-sm flex items-center gap-3 transition-colors",e.danger?"text-red-600 hover:bg-red-50":e.primary?"text-[#0052CC] font-medium hover:bg-blue-50":"text-[#051023] hover:bg-gray-50",e.disabled&&"opacity-50 cursor-not-allowed",0===t&&"rounded-t-lg",t===U.length-1&&"rounded-b-lg"),style:e.textColor?{color:e.textColor}:void 0,children:[(0,n.jsx)("span",{className:"text-base",children:e.icon}),(0,n.jsx)("span",{children:e.label})]});return(0,n.jsxs)(a.Fragment,{children:[t>0&&e.dividerBefore&&(0,n.jsx)("div",{className:"border-t border-[#E1E4EB]"}),e.tooltip?(0,n.jsx)(f.u,{title:e.tooltip,arrow:!0,placement:"left",children:(0,n.jsx)("div",{children:s})}):s]},e.id)})})]}),!A&&!p&&(0,n.jsx)("button",{onClick:()=>{q||y("void")},disabled:q,className:(0,l.cn)("px-4 py-2.5 bg-red-50 text-red-600 border border-red-400 rounded-lg font-medium transition-all",q&&"opacity-50 cursor-not-allowed"),children:"Void Invoice"})]})};var j=s(11052),y=s(19537),w=s(71936),N=s(49198)},80273:function(e,t,s){s.d(t,{r:function(){return E}});var n=s(52676),a=s(75271),l=s(2032),r=s(97776),i=s(70714),o=s(89602),d=s(30857),c=s(21765),u=s(82243),x=s(80114),p=s(8685);let m=function(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1],{data:s,error:n,isLoading:a,mutate:r}=(0,x.u)(t&&e?"invoice-detail-".concat(e):null,async()=>{let t=await (0,c.r)({url:"/api/v1/invoice/invoice/detail/",method:"get",noCamel:!0,params:{invoice_id:e}});if(t.isOk&&t.result){var s,n,a,r,i,o,d,u,x,m,h,v,g,f,b,j,y,w,N,C,k,_,F;let e=t.result;return{paymentMethodId:(null==e?void 0:e.payment_method_id)||"",paymentReference:(null==e?void 0:e.payment_reference)||"",paymentMemo:(null==e?void 0:e.payment_memo)||"",projectId:(null===(s=e.project_id)||void 0===s?void 0:s.toString())||"",effectiveProjectNo:(null===(n=e.effective_project_no)||void 0===n?void 0:n.toString())||"",paymentStatus:e.payment_status,clientId:(null===(a=e.client_id)||void 0===a?void 0:a.toString())||"",invoiceNumber:e.custom_invoice_no||e.invoice_no||e.invoice_number||"",eanoInvoiceNo:e.default_invoice_no||"",dateOfIssue:e.create_time||(0,l.WU)(new Date,"yyyy-MM-dd"),operator:null==e?void 0:e.operator,dueDate:e.due_date||"",paymentTerms:null!==(_=e.payment_terms)&&void 0!==_?_:null,paymentTermsName:e.payment_terms_name||"",invoiceNote:e.invoice_note||"",lineItems:(null===(r=e.items)||void 0===r?void 0:r.map((e,t)=>({...e,id:(t+1).toString()}
1)))||[],summary:{subTotal:e.sub_total||0,adjustments:(null===(i=e.adjustment)||void 0===i?void 0:i.toString())||"0",grandTotal:e.actual_grand_total||0,totalGrandTotal:e.total_grand_total},vendorInfo:{name:(null===(o=e.vendor_info)||void 0===o?void 0:o.name)||(null===(d=e.vendor_info)||void 0===d?void 0:d.business_name)||"",email:(null===(u=e.vendor_info)||void 0===u?void 0:u.email)||"",phone:(null===(x=e.vendor_info)||void 0===x?void 0:x.phone)||"",address:(null===(m=e.vendor_info)||void 0===m?void 0:m.address)||"",business_logo:(null===(h=e.vendor_info)||void 0===h?void 0:h.business_logo)||"",company_name:(null===(v=e.vendor_info)||void 0===v?void 0:v.company_name)||"",license_number:(null===(g=e.vendor_info)||void 0===g?void 0:g.license_number)||"",address_dict:null===(f=e.vendor_info)||void 0===f?void 0:f.address_dict},clientInfo:{name:(null===(b=e.client_info)||void 0===b?void 0:b.name)||"",email:(null===(j=e.client_info)||void 0===j?void 0:j.email)||"",phone:(null===(y=e.client_info)||void 0===y?void 0:y.phone)||(null===(w=e.client_info)||void 0===w?void 0:w.original_phone)||"",address:(null===(N=e.client_info)||void 0===N?void 0:N.billing_address)||(null===(C=e.client_info)||void 0===C?void 0:C.address)||(null==e?void 0:e.project_address)||""},projectInfo:{projectColor:e.project_color||"#0052CC",projectAddress:e.address||e.project_address||e.project_name||"",projectName:(null==e?void 0:null===(k=e.client_info)||void 0===k?void 0:k.project_name)||""},clientMessage:e.client_note||"",internalMemo:e.internal_note||"",files:e.attachment||[],status:e.status,statusDict:e.status_dict,actionButton:e.action_button,hasPaidViaStripe:e.has_paid,paidOn:e.paid_on||e.paid_date,payMethod:e.pay_method||e.payment_method,clientPaysCreditCardFee:e.client_pays_credit_card_fee,clientPaysCreditCardFeeTotal:e.client_credit_card_fee_amount,isShowCreditCardFee:e.is_show_credit_card_fee,isShowFeeNote:e.is_show_fee_note,creditCardFeeNote:e.credit_card_fee_note,showQtyPrice:e.show_qty_price,isCheckEnabled:e.is_check_enabled,invoiceId:e.id,createTime:null==e?void 0:e.create_time,updateTime:null==e?void 0:e.update_time,showProjectAddress:null!==(F=e.show_project_address)&&void 0!==F&&F,address:e.address||e.project_address||"",canFinalize:(0,p.Yj)((0,p.p5)(e))}}throw Error(t.resMessage||"Failed to fetch invoice details")},{revalidateOnFocus:!1,revalidateOnReconnect:!1});return{invoiceData:s,loading:a,error:!!n,mutate:r}},h=(e,t)=>{let[s,n]=(0,a.useState)(!1),l=(0,a.useCallback)(async s=>{n(!0);try{let n={invoice_id:e,income_type:2,status:"paid"===s.status?void 0:s.status,payment_amount:parseFloat(s.amount),paid_date:s.paidDate,payment_method:s.paymentMethod,payment_reference:s.paymentReference,payment_memo:s.paymentMemo},a=await (0,c.r)({url:"/api/v1/invoice/invoice/mark_paid/",method:"post",params:n});if(a.isOk)return u.y.success("Invoice updated successfully"),t&&t(),!0;return u.y.error(a.resMessage||"Failed to update invoice"),!1}catch(e){return console.error("Error updating invoice:",e),u.y.error("Failed to update invoice"),!1}finally{n(!1)}},[e,t]),r=(0,a.useCallback)(async()=>{try{let t=await (0,c.r)({url:"/api/v1/finance/send_reminder/",method:"post",noCamel:!0,params:{milestone_id:e,is_co:!1,type:2}});t.isOk?u.y.success("Reminder Sent Successfully."):u.y.error(t.resMessage||"Failed to send reminder")}catch(e){console.error("Error sending reminder:",e),u.y.error("Failed to send reminder")}},[e]),i=(0,a.useCallback)(async function(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];try{let s=await (0,c.r)({url:"/api/v1/invoice/invoice/mark_void/",method:"post",noCamel:!0,params:{invoice_id:e,notify_client:t}});if(s.isOk)return!0;return u.y.error(s.resMessage||"Failed to void invoice"),!1}catch(e){return console.error("Error voiding invoice:",e),u.y.error("Failed to void invoice"),!1}},[e]);return{submitLoading:s,markAsPaid:l,sendReminder:r,voidInvoice:i,updateInternalMemo:(0,a.useCallback)(async s=>{try{let n=await (0,c.r)({url:"/api/v1/invoice/invoice/edit/",method:"post",noCamel:!0,params:{invoice_id:e,internal_note:s}});if(n.isOk)return u.y.success("Internal memo updated successfully"),t&&t(),!0;return u.y.error(n.resMessage||"Failed to update internal memo"),!1}catch(e){return console.error("Error updating internal memo:",e),u.y.error("Failed to update internal memo"),!1}},[e,t]),exportPDF:(0,a.useCallback)(t=>{window.open("".concat("https://api.eano.com","/api/v1/invoice/invoice/export_invoice/?invoice_id=").concat(e).concat(t?"&download_type=".concat(t):""),"_blank")},[e]),previewAsClient:(0,a.useCallback)(()=>{window.open("/invoice-preview/".concat(e),"_blank")},[e])}};var v=s(62845),g=s(37508),f=s(61162),b=s(6741),j=s(80574);s(43073);var y=s(38182),w=s(9835),N=s(89030),C=s(78628),k=s(31635),_=s(28518),F=s(77806);let E=e=>{var t,s,x,p,E,S,D;let{open:I,onClose:A,invoiceId:P,onSuccess:B,onEditDraft:M}=e,{invoiceData:L,loading:Z,mutate:T}=m(P,I),{submitLoading:O,markAsPaid:R,sendReminder:z,voidInvoice:W,exportPDF:q,previewAsClient:U}
1=h(P,()=>{T(),B&&B()}),[V,Q]=(0,a.useState)(!1),[H,Y]=(0,a.useState)({status:"",amount:"",paidDate:new Date().toISOString().split("T")[0],paymentMethod:"",paymentMethodName:"",paymentReference:"",paymentMemo:""}),[G,$]=(0,a.useState)(!1),[K,X]=(0,a.useState)(!1),[J,ee]=(0,a.useState)(!1),[et,es]=(0,a.useState)(!1),[en,ea]=(0,a.useState)(!1),[el,er]=(0,a.useState)("send"),[ei,eo]=(0,a.useState)(!1),[ed,ec]=(0,a.useState)(!1),eu=()=>{Q(!1),A()},ex=async e=>{eo(!0);try{let t=await (0,c.r)({url:"/api/v1/invoice/invoice/update/",method:"post",params:{invoice_id:P,action:e}});if(t.isOk)return u.y.success("finalize_and_send"===e?"Invoice Sent Successfully! Your client will receive an email and SMS.":"Invoice Saved Successfully!"),null==B||B(),eu(),!0;return u.y.error(t.resMessage||"Failed to save invoice"),!1}finally{eo(!1)}},ep=async()=>{eo(!0);try{let e=await (0,c.r)({url:"/api/v1/invoice/invoice/draft/delete/",method:"post",params:{invoice_id:P}});e.isOk?(u.y.success("Draft deleted"),null==B||B(),eu()):u.y.error(e.resMessage||"Failed to delete draft")}finally{eo(!1)}},em=async e=>{var t,s,n;switch(e){case"mark_as_paid":Y({status:"paid",amount:(null===(t=L.summary.grandTotal)||void 0===t?void 0:t.toString())||"0",paidDate:new Date().toISOString().split("T")[0],paymentMethod:"",paymentMethodName:"",paymentReference:L.paymentReference||"",paymentMemo:L.paymentMemo||""}),Q(!0);break;case"export_pdf":q();break;case"export_zip":q("zip");break;case"send_reminder":await z();break;case"void":ee(!0);break;case"finalize_draft":0===Number(null==L?void 0:null===(s=L.summary)||void 0===s?void 0:s.grandTotal)?(er("finalize"),ea(!0)):await ex("finalize");break;case"finalize_and_send_draft":0===Number(null==L?void 0:null===(n=L.summary)||void 0===n?void 0:n.grandTotal)?(er("finalize_and_send"),ea(!0)):await ex("finalize_and_send");break;case"delete_draft":ec(!0)}},eh=async()=>{X(!0);try{let e=await (0,c.r)({url:"/api/v1/invoice/send_to_client/",params:{invoice_id:L.invoiceId},method:"post"});e.isOk?(u.y.success("Invoice sent successfully"),null==B||B(),eu()):u.y.error(e.resMessage||"Invoice send failed")}finally{X(!1)}},ev=async()=>{await R(H)&&(Q(!1),Y({status:"",amount:"",paidDate:new Date().toISOString().split("T")[0],paymentMethod:"",paymentMethodName:"",paymentReference:"",paymentMemo:""}))},eg=async e=>{$(!0);try{let t=await (0,c.r)({url:"/api/v1/invoice/invoice/edit/",method:"post",noCamel:!0,params:{invoice_id:P,internal_note:e}});if(t.isOk)u.y.success("Internal memo updated successfully"),T(),B&&B();else throw u.y.error(t.resMessage||"Failed to update internal memo"),Error(t.resMessage)}catch(e){throw console.error("Error updating internal memo:",e),u.y.error("Failed to update internal memo"),e}finally{$(!1)}};if(!L&&!Z)return null;let ef=(null==L?void 0:L.paymentStatus)===3,eb=(null==L?void 0:null===(t=L.statusDict)||void 0===t?void 0:t.text)==="Draft",ej=(null==L?void 0:null===(s=L.statusDict)||void 0===s?void 0:s.text)==="Voided";return(0,n.jsx)(N.Z,{open:I,onClose:eu,children:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"fixed inset-0 z-[9999] bg-white flex flex-col",children:[(0,n.jsx)(C.Z,{onClose:eu}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto min-h-0",children:(0,n.jsx)("div",{className:"max-w-4xl mx-auto px-6 pb-6",children:Z?(0,n.jsx)(d.T,{message:"Loading invoice details..."}):L?(0,n.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between sticky top-0 z-10 bg-white pt-6",children:[(0,n.jsx)("div",{className:"flex items-center gap-4",children:(0,n.jsx)(k.Z,{invoiceNumber:L.invoiceNumber,statusDict:null==L?void 0:L.statusDict,paymentStatus:null==L?void 0:L.paymentStatus,paidOn:null==L?void 0:L.paidOn,payMethod:null==L?void 0:L.payMethod,dateOfIssue:null==L?void 0:L.dateOfIssue,createTime:null==L?void 0:L.createTime,updateTime:null==L?void 0:L.updateTime,editable:!1,eanoInvoiceNo:null==L?void 0:L.eanoInvoiceNo,invoiceId:P,onInvoiceNoSaved:()=>{T(),null==B||B()}})}),(0,n.jsxs)("div",{className:"flex items-center gap-3 shrink-0",children:[(0,n.jsx)(v.tU,{invoiceId:P,invoiceStatus:L.paymentStatus,isVoided:ej,hasPaidViaStripe:L.hasPaidViaStripe,hasAttachments:(null!==(D=null===(x=L.files)||void 0===x?void 0:x.length)&&void 0!==D?D:0)>0,onAction:em,onPreviewAsClient:()=>U(),draftCanFinalize:L.canFinalize}),ej?null:eb?(0,n.jsxs)("button",{onClick:()=>null==M?void 0:M(P),disabled:!M||ei,className:"px-6 py-2.5 bg-[#0052CC] text-white rounded-lg font-medium hover:bg-[#0747A6] disabled:opacity-50 disabled:cursor-not-allowed transition-all inline-flex items-center gap-2 whitespace-nowrap",children:[(0,n.jsx)(r.Z,{size:16,className:"shrink-0"}),"Edit Invoice"]}):L.actionButton&&L.actionButton.can_click&&(0,n.jsx)("button",{onClick:()=>{var e,t,s,n,a;let r=(null==L?void 0:null===(e=L.actionButton)||void 0===e?void 0:e.button_type)===0;
1if((null==L?void 0:null===(t=L.actionButton)||void 0===t?void 0:t.button_type)===2){if(0===Number(L.summary.grandTotal)){er("send"),ea(!0);return}return eh()}if(r){let e=L.paymentMethodId?L.paymentMethodId.toString():"";Y({status:(null===(s=L.status)||void 0===s?void 0:s.toString())||"paid",amount:(null===(n=L.summary.grandTotal)||void 0===n?void 0:n.toString())||"0",paidDate:L.paidOn?(0,l.WU)(new Date(L.paidOn),"yyyy-MM-dd"):new Date().toISOString().split("T")[0],paymentMethod:e,paymentMethodName:"",paymentReference:L.paymentReference||"",paymentMemo:L.paymentMemo||""})}else L&&Y({status:"paid",amount:(null===(a=L.summary.grandTotal)||void 0===a?void 0:a.toString())||"0",paidDate:new Date().toISOString().split("T")[0],paymentMethod:"",paymentMethodName:"",paymentReference:L.paymentReference||"",paymentMemo:L.paymentMemo||""});Q(!0)},disabled:O||K,className:"px-6 py-2.5 bg-[#0052CC] text-white rounded-lg font-medium hover:bg-[#0747A6] disabled:opacity-50 disabled:cursor-not-allowed transition-all",children:K?"Sending...":L.actionButton.button_text})]})]}),(0,n.jsx)(w.Z,{projectInfo:L.projectInfo,internalMemo:L.internalMemo,onSave:eg,saving:G}),(0,n.jsx)(v.kB,{isShowFeeNote:null==L?void 0:L.isShowFeeNote,note:L.creditCardFeeNote}),(0,n.jsxs)("div",{className:"relative bg-white rounded-xl border border-[#EBECF0] overflow-hidden shadow-sm",children:[ej&&(0,n.jsx)("div",{className:"pointer-events-none absolute top-0 left-0 w-full h-full z-20 opacity-10",children:(0,n.jsx)("div",{className:"flex justify-center items-center h-full",children:(0,n.jsx)(y.UR,{})})}),ef&&!ej&&(0,n.jsx)("div",{className:"pointer-events-none absolute top-0 left-0 w-full h-full z-20 opacity-10",children:(0,n.jsx)("div",{className:"flex justify-center items-center h-full",children:(0,n.jsx)(y.gT,{})})}),(0,n.jsx)("div",{className:"p-1 text-white",style:{backgroundColor:(null===(p=L.projectInfo)||void 0===p?void 0:p.projectColor)||"#0052CC"}}),(0,n.jsx)("div",{className:"bg-[#F9FAFB] p-6 ",children:(0,n.jsxs)("div",{className:"grid grid-cols-3 gap-6 max-w-2xl",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"text-[#3B4658] text-base mb-1",children:"Date of issue"}),(0,n.jsx)("div",{className:"text-en-dark-blue text-base",children:(0,j.U_)(L.dateOfIssue)})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"text-[#3B4658] text-base mb-1",children:"Due on"}),(0,n.jsx)("div",{className:"text-base text-en-dark-blue",children:L.dueDate?(0,j.U_)(L.dueDate):"--"})]}),L.paymentTermsName&&(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"text-[#3B4658] text-base mb-1",children:"Payment terms"}),(0,n.jsx)("div",{className:"text-base text-en-dark-blue",children:L.paymentTermsName})]}),ef&&L.paidOn&&(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"text-[#3B4658] text-base mb-1",children:"Paid on"}),(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"text-[#051023] text-base font-medium",children:(0,l.WU)(new Date(L.paidOn),"MM/dd/yyyy")}),(0,n.jsxs)("div",{className:"text-[#7C8293] text-sm mt-1",children:[L.payMethod||"Check"," | Recorded by"," ",null==L?void 0:L.operator]})]})]})]})}),(0,n.jsxs)("div",{className:"p-6",children:[(0,n.jsxs)("div",{className:"flex justify-between",children:[(0,n.jsx)(g.b,{vendorInfo:L.vendorInfo,clientInfo:L.clientInfo,projectId:L.projectId,effectiveProjectId:L.effectiveProjectNo,showProjectAddress:L.showProjectAddress,projectAddress:L.address}),(0,n.jsx)("div",{className:"flex justify-center w-[35%]",children:(0,n.jsx)(b.l,{businessLogo:null===(E=L.vendorInfo)||void 0===E?void 0:E.business_logo,disabled:!0,logoLoading:!1,logoDragging:!1,onLogoUpload:()=>{},onLogoDrop:()=>{},onLogoDragOver:()=>{},onLogoDragLeave:()=>{},onLogoRemove:()=>{}})})]}),(0,n.jsx)(v.SB,{showQtyPrice:L.showQtyPrice,lineItems:L.lineItems}),(0,n.jsx)(f._,{summary:L.summary,grandTotal:L.clientPaysCreditCardFee?L.summary.totalGrandTotal:L.summary.grandTotal,vendorInfo:L.vendorInfo,clientPaysCreditCardFee:L.clientPaysCreditCardFee||!1,creditCardFeeTotal:L.clientPaysCreditCardFeeTotal||0,isShowCreditCardFee:null==L?void 0:L.isShowCreditCardFee,isShowFeeNote:null==L?void 0:L.isShowFeeNote,credit
1CardFeeLoading:!1,onlyShow:!0,paymentStatus:null==L?void 0:L.paymentStatus,isCheckEnabled:null==L?void 0:L.isCheckEnabled})]})]}),(0,n.jsx)(o.w,{message:L.clientMessage}),L.files&&L.files.length>0&&(0,n.jsx)(v.et,{files:L.files})]}):(0,n.jsx)("div",{className:"text-center py-20",children:(0,n.jsx)("p",{className:"text-red-500",children:"Failed to load invoice"})})})})]}),L&&(0,n.jsx)(i.h,{open:V,onClose:()=>Q(!1),onSubmit:ev,selectedIncome:{income_id:P,income_type:2,amount:L.summary.grandTotal,action_button:L.actionButton},paymentData:H,onPaymentDataChange:(e,t)=>Y(s=>({...s,[e]:t})),isUpdate:(null==L?void 0:null===(S=L.actionButton)||void 0===S?void 0:S.button_type)===0,loading:O}),(0,n.jsx)(_.Z,{open:en,variant:"finalize"===el?"save":"send",onClose:()=>ea(!1),onConfirm:async()=>{ea(!1),"finalize"===el?await ex("finalize"):"finalize_and_send"===el?await ex("finalize_and_send"):await eh()}}),(0,n.jsx)(v.nQ,{open:J,loading:et,onClose:()=>{et||ee(!1)},onConfirm:async e=>{es(!0);try{await W(e)&&(u.y.success(e?(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"font-semibold text-en-dark-blue",children:"Invoice voided"}),(0,n.jsx)("div",{className:"mt-0.5 text-13 text-en-dark-blue",children:"The client has been notified via email and SMS."})]}):(0,n.jsx)("div",{className:"font-semibold text-en-dark-blue",children:"Invoice voided"})),ee(!1),null==B||B(),eu())}finally{es(!1)}}}),(0,n.jsx)(F.Z,{open:ed,loading:ei,onClose:()=>{ei||ec(!1)},onConfirm:async()=>{await ep(),ec(!1)}})]})})}},90033:function(e,t,s){s.d(t,{p:function(){return i}});var n=s(52676),a=s(75271),l=s(87178),r=s(12311);let i=e=>{let{nodes:t,onToggle:s}=e,[i,o]=(0,a.useState)(new Set),d=e=>{o(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})},c=e=>{let t=!e.enabled;s(function e(t){return[t.qbAccountId,...t.children.flatMap(e)]}(e),t)},u=(e,t)=>{let{checked:s,indeterminate:a}=function e(t){if(0===t.children.length)return{checked:t.enabled,indeterminate:!1};let s=t.children.map(e),n=t.enabled&&s.every(e=>e.checked&&!e.indeterminate),a=!t.enabled&&s.every(e=>!e.checked&&!e.indeterminate);return n?{checked:!0,indeterminate:!1}:a?{checked:!1,indeterminate:!1}:{checked:!1,indeterminate:!0}}(e),o=e.children.length>0,x=i.has(e.qbAccountId);return(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"flex items-center gap-1 py-1.5",style:{paddingLeft:24*t},children:[(0,n.jsx)(l.Z,{checked:s,indeterminate:a,onChange:()=>c(e),inputProps:{"aria-label":e.name},inputRef:e=>{e&&(e.indeterminate=a)},size:"small",style:{color:"#0052CC",padding:4}}),o&&(0,n.jsx)("button",{type:"button","aria-label":"".concat(x?"Collapse":"Expand"," ").concat(e.name),onClick:()=>d(e.qbAccountId),className:"flex items-center",children:(0,n.jsx)(r.Z,{fontSize:"small",style:x?{}:{transform:"rotate(-90deg)"}})}),(0,n.jsx)("span",{className:"text-sm text-en-dark-blue",children:e.name})]}),o&&x&&(0,n.jsx)("div",{children:e.children.map(e=>u(e,t+1))})]},e.qbAccountId)};return(0,n.jsx)("div",{children:t.map(e=>u(e,0))})}},62088:function(e,t,s){s.d(t,{s:function(){return d}});var n=s(52676),a=s(75271),l=s(21765),r=s(6522),i=s(77690);let o=e=>{var t;let{open:s,onClose:a}=e,{financeSettings:o,isFinanceSettingsLoading:d,mutateFinanceSettings:c}=(0,r.pL)(),u=null!==(t=null==o?void 0:o.expense_require)&&void 0!==t&&t,x=e=>{c(async()=>(await (0,l.r)({url:"/api/v1/finance/settings/",method:"post",params:{expense_require:e},noCamel:!0}),{...o,expense_require:e}),{optimisticData:{...o,expense_require:e},rollbackOnError:!0})};return(0,n.jsx)(i.ZP,{width:"medium640",titleClassName:"text-28 !text-left",open:s,onClose:a,title:"Finance Settings",children:(0,n.jsx)("div",{className:"min-h-40",children:d?(0,n.jsx)("div",{className:"h-24 flex items-center justify-center text-[#7C8293] text-sm",children:"Loading..."}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("p",{className:"text-18 font-circular-bold text-en-dark-blue mb-4",children:"Expense Settings"}
1),(0,n.jsxs)("div",{className:"flex items-baseline gap-4 rounded-xl border px-5 py-4 transition-colors ".concat(u?"border-[#0052CC] bg-[#EDF3FB] shadow-[0_8px_20px_0_rgba(51,51,51,0.10)]":"border-en-divider-dark bg-[#F4F5F7]"),children:[(0,n.jsx)("button",{onClick:()=>x(!u),className:"relative top-1 flex-shrink-0 w-[38px] h-[18px] rounded-full transition-colors duration-200 focus:outline-none cursor-pointer ".concat(u?"bg-[#0052CC]":"bg-[#D1D5DB]"),children:(0,n.jsx)("span",{className:"absolute top-[1px] left-[1px] w-4 h-4 bg-white rounded-full shadow transition-transform duration-200 ".concat(u?"translate-x-5":"translate-x-0")})}),(0,n.jsxs)("div",{className:"",children:[(0,n.jsx)("p",{className:"text-[#051023]",children:"Require vendor for expenses"}),(0,n.jsx)("p",{className:"text-sm text-[#7C8293] mt-0.5",children:"Enabling this will require a vendor name when creating an expense."})]})]})]})})})},d=()=>{let[e,t]=(0,a.useState)(!1);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("button",{onClick:()=>t(!0),className:"px-4 py-2.5 text-15 text-[#3B4658] flex items-center gap-2 h-10 cursor-pointer hover:bg-gray-50 rounded-lg transition-colors",children:[(0,n.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",children:[(0,n.jsx)("path",{d:"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"}),(0,n.jsx)("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1Z",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})]}),"Settings"]}),(0,n.jsx)(o,{open:e,onClose:()=>t(!1)})]})}},11219:function(e,t,s){var n=s(52676),a=s(75271),l=s(28317),r=s(6155),i=s(61662),o=s(51521),d=s(85777),c=s(4772),u=s(80114),x=s(20582),p=s(21765),m=s(37924),h=s(91043),v=s(80874),g=s(24596),f=s(90033);let b=e=>{var t,s;let{open:r,onClose:o,onConfirm:c,lastSyncedDateRange:u,loading:x=!1,syncModel:p="expense"}=e,[m,h]=(0,a.useState)((0,d.uc)("custom")),[v,g]=(0,a.useState)("custom"),f=async()=>{if("custom"===v&&!m){i.yw.error("Please select both start and end dates");return}if(!m){i.yw.error("Please select a date range");return}await c(m.startDate,m.endDate)};return(0,n.jsx)(l.Z,{open:r,onClose:o,PaperProps:{className:"rounded-2xl max-w-[600px] w-full"},children:(0,n.jsxs)("div",{className:"px-16 py-14",children:[(0,n.jsx)("h2",{className:"text-28 font-circular-bold text-en-dark-blue mb-6",children:"expense"===p?"Resync QuickBooks expenses":"Resync QuickBooks AP accounts"}),(0,n.jsx)("p",{className:"text-base text-en-mid-blue leading-relaxed mb-5",children:{expense:"The re-sync process will only synchronize data for the selected Expense account types. Existing historical data will remain intact and will not be removed.",account:"Re-syncing your QuickBooks AP accounts will remove all previously imported QuickBooks AP accounts, including any data added in Eano, and replace it with a fresh copy of the QuickBooks data."}[p]}),(0,n.jsx)(d.ej,{defaultOption:"custom",disabled:x,onChange:(e,t)=>
1{h(e),g(t)},label:"Resync Start From",width:"100%"}),u&&(0,n.jsxs)("p",{className:"text-xs text-en-light-blue mb-6 pt-2",children:["Last synced data range: ",null===(t=u[p])||void 0===t?void 0:t.startDate," -"," ",null===(s=u[p])||void 0===s?void 0:s.endDate]}),(0,n.jsxs)("div",{className:"flex gap-3 mt-6",children:[(0,n.jsx)("button",{onClick:o,disabled:x,className:"flex-1 px-6 py-3 text-base font-medium text-en-dark-blue bg-white border border-[#D1D5DB] rounded-lg hover:bg-[#F9FAFB] transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:"Cancel"}),(0,n.jsx)("button",{onClick:f,disabled:x||"custom"===v&&!m,className:"flex-1 px-6 py-3 text-base font-medium text-white bg-[#0052CC] hover:bg-[#0043A8] rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2",children:x?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),(0,n.jsx)("span",{children:"Resyncing..."})]}):"Resync Data"})]})]})})},j=e=>{let{enabled:t,onChange:s,disabled:a=!1}=e;return(0,n.jsx)("button",{type:"button",onClick:()=>!a&&s(!t),disabled:a,className:"relative inline-flex h-4 w-[30px] flex-shrink-0 items-center rounded-full transition-colors ".concat(t?"bg-[#0052CC]":"bg-gray-300"," ").concat(a?"opacity-50 cursor-not-allowed":"cursor-pointer"),children:(0,n.jsx)("span",{className:"inline-block h-3 w-3 transform rounded-full bg-white transition-transform ".concat(t?"translate-x-4":"translate-x-0.5")})})},y=e=>{var t;let{value:s,options:l,onChange:r,disabled:i}=e,[o,d]=(0,a.useState)(!1),c=(0,a.useRef)(null);(0,a.useEffect)(()=>{let e=e=>{c.current&&!c.current.contains(e.target)&&d(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);let u=(null===(t=l.find(e=>e.value===s))||void 0===t?void 0:t.label)||"";return(0,n.jsxs)("div",{ref:c,className:"relative w-full",children:[(0,n.jsxs)("button",{type:"button",onClick:()=>!i&&d(!o),disabled:i,className:"w-full h-10 px-3 text-sm text-left border rounded-lg bg-white text-en-dark-blue flex items-center justify-between ".concat(o?"border-[#0052CC] ring-1 ring-[#0052CC]":"border-[#D1D5DB] hover:border-[#9CA3AF]"," ").concat(i?"opacity-50 cursor-not-allowed":"cursor-pointer"),children:[(0,n.jsx)("span",{className:"truncate",children:u}),(0,n.jsx)("svg",{className:"w-4 h-4 text-gray-400 flex-shrink-0 ml-2 transition-transform ".concat(o?"rotate-180":""),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),o&&(0,n.jsx)("div",{className:"absolute z-50 w-full mt-1 bg-white border border-[#D1D5DB] rounded-lg shadow-lg overflow-auto max-h-60",children:l.map(e=>(0,n.jsx)("div",{onClick:()=>{r(e.value),d(!1)},className:"px-3 py-2.5 text-sm cursor-pointer transition-colors ".concat(e.value===s?"bg-[#EDF3FB] text-[#0052CC] font-medium":"text-en-dark-blue hover:bg-[#F5F7FA]"),children:e.label},e.value))})]})},w=()=>(0,n.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 bg-[#979797] text-white text-xs font-medium rounded-[13px] leading-4",children:"Feature unavailable"});t.Z=e=>{var t,s,l,d,N,C,k,_,F,E;let{open:S,onClose:D,onConfirm:I,loading:A=!1}=e,[P,B]=(0,a.useState)(!1),[M,L]=(0,a.useState)(!1),[Z,T]=(0,a.useState)(new Set),[O,R]=(0,a.useState)("expense"),{data:z,mutate:W,isLoading:q}=(0,u.u)("/api/v1/finance/qb/setting/",x._i,{revalidateOnFocus:!0}),{data:U,mutate:V}=(0,u.u)(S?"/api/v1/qb/sync_date_range":null,x._i,{revalidateOnFocus:!1}),{data:Q}=(0,u.u)(S?"/api/v1/qb/accounts/bank":null,x._i,{revalidateOnFocus:!1}),{data:H,mutate:Y,isLoading:G}=(0,u.u)(S&&(null==z?void 0:z.qbExpenseSync)?"/api/v1/finance/qb/expense_accounts/":null,x._i,{revalidateOnFocus:!1}),$=(null==H?void 0:H.tree)||[],{data:K}=(0,u.u)(S?"/api/v1/finance/qb/setting/mapping-options/":null,x._i,{revalidateOnFocus:!1}),X=(0,a.useMemo)(()=>(null==Q?void 0:Q.accounts)||[],[Q]),J=(0,a.useMemo)(()=>{var e;if(!X.length)return null;let t=X.find(e=>{var t;return null===(t=e.qbAccountName)||void 0===t?void 0:t.toLowerCase().includes("stripe")});return null!==(e=null==t?void 0:t.qbAccountId)&&void 0!==e?e:null},[X]),ee=(0,a.useMemo)(()=>{let e=null==z?void 0:z.qbInvoiceAccountMapping;return e&&X.some(t=>t.qbAccountId===e)?e:J||""},[null==z?void 0:z.qbInvoiceAccountMapping,X,J]),et=(null==K?void 0:K.options)||[{value:1,label:"Client name"},{value:2,label:"Client company"},{value:3,label:"Project address"},{value:4,label:"Project name"},{value:5,label:"Project ID"}],es=(null==K?void 0:K.invoiceNoOptions)||[{value:1,label:"Eano invoice ID"},{value:2,label:"Custom invoice ID"}],en=(0,g.LK)(!!(null==z?void 0:z.qbProjectSync),null==z?void 0:z.qbInvoiceClientMapping,et),ea=async(e,t)=>{if(Z.has(e))return;T(t=>new Set(t).add(e));let s=null==z?void 0:z[e];W({...z,[e]:t},!1);try{let l=await (0,p.r)({url:"/api/v1/finance/qb/setting/",method:"post",params:{[e]:t}});if(l.isOk&&"qbProjectSync"===e&&t){var n,a;let t=null!==(a=null===(n=l.result)||void 0===n?void 0:n.qbProjectSyncIssues)&&void 0!==a?a:[];if(t.length>0){W(t=>({...t,[e]:s}
1),!1),t.forEach(e=>i.yw.warning(e.message));return}}W()}catch(t){W(t=>({...t,[e]:s}),!1),i.yw.error("Failed to update setting")}finally{T(t=>{let s=new Set(t);return s.delete(e),s})}},el=async(e,t)=>{if(Z.has(e))return;T(t=>new Set(t).add(e));let s=null==z?void 0:z[e];W({...z,[e]:t},!1);try{await (0,p.r)({url:"/api/v1/finance/qb/setting/",method:"post",params:{[e]:t}}),W()}catch(t){W(t=>({...t,[e]:s}),!1),i.yw.error("Failed to update setting")}finally{T(t=>{let s=new Set(t);return s.delete(e),s})}},er=async(e,t)=>{let s="expenseAccount:".concat(e.join(","));if(Z.has(s))return;T(e=>new Set(e).add(s));let n=new Set(e),a=e=>e.map(e=>({...e,enabled:n.has(e.qbAccountId)?t:e.enabled,children:a(e.children)}));Y(e=>({tree:a((null==e?void 0:e.tree)||[])}),!1);try{var l;let s=await (0,p.r)({url:"/api/v1/finance/qb/expense_accounts/",method:"post",params:{updates:e.map(e=>({qbAccountId:e,enabled:t}))},requestPayload:!0});if(0!==s.code)throw Error("Failed to update");Y(e=>({tree:a((null==e?void 0:e.tree)||[])}),!1),(null===(l=s.result)||void 0===l?void 0:l.qbExpenseSync)===!1&&(null==z?void 0:z.qbExpenseSync)&&(W({...z,qbExpenseSync:!1},!1),i.yw.warning("QuickBooks expense sync is off because no expense accounts are selected."))}catch(e){Y(),i.yw.error("Failed to update setting")}finally{T(e=>{let t=new Set(e);return t.delete(s),t})}},ei=null===(F=null==z?void 0:z.canSyncEanoExpenseToQb)||void 0===F||F,eo=null===(E=null==z?void 0:z.canSyncQbProjects)||void 0===E||E,ed=(null==z?void 0:z.qbPlan)==="plus"||(null==z?void 0:z.qbPlan)==="advanced",ec=e=>t=>{("eanoExpenseSyncQb"!==e||ei)&&ea(e,t)},eu=Array.from(Z).some(e=>e.startsWith("expenseAccount:")),ex=(null==z?void 0:z.qbExpenseSync)&&G||eu,ep=async(e,t)=>{L(!0);try{let s=await (0,p.r)({url:"expense"===O?"/api/v1/qb/purchases/date-range/":"/api/v1/qb/ap_accounts/sync/range/",method:"post",params:{start_date:e,end_date:t}});if(0!==s.code)throw Error("Resync failed");V(),I&&await I(),B(!1),i.yw.success("QuickBooks data resynced successfully")}catch(e){i.yw.error("Failed to resync QuickBooks data")}finally{L(!1)}};return(0,n.jsxs)(r.ZP,{anchor:"right",open:S,onClose:D,PaperProps:{className:"w-[640px] max-w-full"},children:[(0,n.jsxs)("div",{className:"h-full flex flex-col",children:[(0,n.jsx)("div",{className:"flex items-center justify-end px-6 py-4",children:(0,n.jsx)("button",{onClick:D,className:"text-en-light-blue hover:text-en-dark-blue transition-colors",children:(0,n.jsx)(o.T,{width:16,height:16,color:"#051023"})})}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto px-14 pb-10",children:q?(0,n.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,n.jsx)(m.Z,{})}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"flex items-center gap-3 pb-8",children:[(0,n.jsx)("h2",{className:"text-28 font-circular-bold text-en-dark-blue",children:"QuickBooks Sync Settings"}),(0,n.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-[#EBF7EB] border border-[#C8D9C9] text-en-mid-blue text-sm font-medium rounded-[20px]",children:[(0,n.jsx)("span",{className:"w-2 h-2 bg-[#35AB3B] rounded-full"}),"Sync enabled"]})]}),(0,n.jsxs)("div",{className:"mb-8",children:[(0,n.jsxs)("h3",{className:"text-18 font-circular-bold font-medium text-en-dark-blue mb-3 flex justify-between",children:[(0,n.jsx)("div",{children:"Sync"}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("span",{className:"bg-en-blue px-2 py-1.5 rounded-[16px]",children:(0,n.jsx)(c.uN,{})}),(0,n.jsx)(c.ZH,{}),(0,n.jsx)(c.YZ,{})]})]}),(0,n.jsxs)("div",{className:"rounded-xl p-6 border-[1.5px] flex items-start gap-3 ".concat((null==z?void 0:z.qbProjectSync)?"bg-[#EDF3FB] border-en-blue":"bg-white border-en-divider-dark shadow"),children:[(0,n.jsx)(j,{enabled:null==z?void 0:z.qbProjectSync,onChange:ec("qbProjectSync"),disabled:A||Z.has("qbProjectSync")||!eo}),(0,n.jsxs)("div",{className:"flex-1",children:[(0,n.jsxs)("div",{className:"flex items-center gap-1 font-medium text-sm mb-1 text-en-dark-blue mt-[-2px]",children:[(0,n.jsx)("div",{className:"".concat(eo?"":"text-en-disable"),children:"Project Sync"}),(0,n.jsx)("div",{children:!eo&&(0,n.jsx)(w,{})})]}),(0,n.jsx)("p",{className:"text-sm ".concat(eo?"text-en-light-blue":"text-en-disable"," leading-relaxed mb-3"),children:"Link Eano and QuickBooks projects to enable automatic expense and invoice mapping"}),!eo&&(0,n.jsx)("div",{className:"text-14 leading-5 text-[#F02326]",children:ed?(0,n.jsx)("p",{children:"Project sync isn't enabled for your team yet. Please contact Eano support to turn it on."}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("p",{className:"mb-4",children:"Your QuickBooks Online subscription (Essentials) does not include project support, which we need to enable this feature."}),(0,n.jsx)("p",{children:"To enable project sync, you'll need to upgrade your QuickBooks Online subscription to Advanced or higher."})]})}),(null==z?void 0:z.qbProjectSync)&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(h.Z,{values:z,pendingKeys:Z,disabled:A||!eo,onChange:(e,t)=>
1ea(e,t)}),(0,n.jsx)(v.i,{className:"my-3"}),(0,n.jsx)("div",{className:"flex justify-between text-xs text-en-light-blue",children:(null==U?void 0:U.projectLastSynced)&&(0,n.jsxs)("p",{children:["Last sync: ",null==U?void 0:U.projectLastSynced]})})]})]})]})]}),(0,n.jsx)(v.i,{}),(0,n.jsxs)("div",{className:"my-8",children:[(0,n.jsxs)("h3",{className:"text-18 font-circular-bold font-medium text-en-dark-blue mb-3 flex justify-between",children:[(0,n.jsx)("div",{children:"Import from QuickBooks"}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(c.YZ,{}),(0,n.jsx)(c.AD,{}),(0,n.jsx)("span",{className:"bg-en-blue px-2 py-1.5 rounded-[16px]",children:(0,n.jsx)(c.uN,{})})]})]}),(0,n.jsx)("div",{className:"rounded-xl p-6 border-[1.5px] mb-4 ".concat((null==z?void 0:z.qbExpenseSync)?"bg-[#EDF3FB] border-en-blue":"bg-white border-en-divider-dark shadow"),children:(0,n.jsxs)("div",{className:"flex items-start gap-3",children:[(0,n.jsx)(j,{enabled:null==z?void 0:z.qbExpenseSync,onChange:ec("qbExpenseSync"),disabled:A||Z.has("qbExpenseSync")}),(0,n.jsxs)("div",{className:"flex-1",children:[(0,n.jsx)("div",{className:"flex items-center justify-between font-medium text-sm mb-1 text-en-dark-blue leading-4",children:"QuickBooks expenses"}),(0,n.jsx)("p",{className:"text-sm text-en-light-blue leading-relaxed pb-3 mb-3 border-b border-en-divider-dark",children:"Import all your existing and add any new expenses from QuickBooks into Eano"}),(0,n.jsxs)("div",{className:"flex justify-between",children:[(0,n.jsxs)("div",{className:"text-xs text-en-light-blue space-y-1",children:[(null==U?void 0:null===(t=U.expense)||void 0===t?void 0:t.lastSynced)&&(0,n.jsxs)("p",{children:["Last sync: ",null==U?void 0:null===(s=U.expense)||void 0===s?void 0:s.lastSynced]}),U&&(null==z?void 0:z.qbExpenseSync)&&(0,n.jsxs)("p",{children:["Last synced data range: ",null==U?void 0:null===(l=U.expense)||void 0===l?void 0:l.startDate," -"," ",null==U?void 0:null===(d=U.expense)||void 0===d?void 0:d.endDate]})]}),I&&(null==z?void 0:z.qbExpenseSync)&&(0,n.jsx)("button",{onClick:()=>{R("expense"),B(!0)},disabled:ex,title:ex?"Waiting for expense account changes to save before resyncing":void 0,className:"px-4 py-1.5 text-sm font-medium text-[#0052CC] bg-white border border-[#D1D5DB] rounded-lg hover:bg-[#F9FAFB] transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:ex?"Loading...":"Resync"})]}),(null==z?void 0:z.qbExpenseSync)&&G&&(0,n.jsxs)("div",{className:"bg-white border border-[#D7D9DD] rounded-xl mt-4 overflow-hidden",children:[(0,n.jsxs)("div",{className:"bg-[#F4F5F7] px-6 py-3",children:[(0,n.jsx)("div",{className:"flex items-center gap-1 text-sm text-[#3B4658]",children:"Expense Accounts"}),(0,n.jsx)("p",{className:"text-xs text-en-light-blue mt-0.5",children:"Choose which expense sources in QuickBooks to import"})]}),(0,n.jsxs)("div",{className:"px-6 py-4 flex items-center gap-2 text-sm text-en-light-blue",children:[(0,n.jsx)("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-[#0052CC]"}),(0,n.jsx)("span",{children:"Loading expense accounts..."})]})]}),(null==z?void 0:z.qbExpenseSync)&&!G&&$.length>0&&(0,n.jsxs)("div",{className:"bg-white border border-[#D7D9DD] rounded-xl mt-4 overflow-hidden",children:[(0,n.jsxs)("div",{className:"bg-[#F4F5F7] px-6 py-3",children:[(0,n.jsx)("div",{className:"flex items-center gap-1 text-sm text-[#3B4658]",children:"Expense Accounts"}),(0,n.jsx)("p",{className:"text-xs text-en-light-blue mt-0.5",children:"Choose which expense sources in QuickBooks to import"})]}),(0,n.jsx)("div",{className:"px-6 py-2",children:(0,n.jsx)(f.p,{nodes:$,onToggle:er})})]})]})]})}),(0,n.jsx)("div",{className:"rounded-xl p-6 border-[1.5px] ".concat((null==z?void 0:z.qbAccountSync)?"bg-[#EDF3FB] border-en-blue":"bg-white border-en-divider-dark shadow"),children:(0,n.jsxs)("div",{className:"flex items-start gap-3",children:[(0,n.jsx)(j,{enabled:null==z?void 0:z.qbAccountSync,onChange:ec("qbAccountSync"),disabled:A||Z.has("qbAccountSync")}),(0,n.jsxs)("div",{className:"flex-1",children:[(0,n.jsx)("div",{className:"flex items-center justify-between font-medium text-sm mb-1 text-en-dark-blue leading-4",children:"Qu
1ickBooks AP accounts"}),(0,n.jsx)("p",{className:"text-sm text-en-light-blue leading-relaxed pb-3 mb-3 border-b border-en-divider-dark",children:"Import your accounts payable (AP) destinations to classify expenses"}),(0,n.jsxs)("div",{className:"flex justify-between",children:[(0,n.jsxs)("div",{className:"text-xs text-en-light-blue space-y-1",children:[(null==U?void 0:null===(N=U.account)||void 0===N?void 0:N.lastSynced)&&(0,n.jsxs)("p",{children:["Last sync: ",null==U?void 0:null===(C=U.account)||void 0===C?void 0:C.lastSynced]}),U&&(null==z?void 0:z.qbAccountSync)&&(0,n.jsxs)("p",{children:["Last synced data range: ",null==U?void 0:null===(k=U.account)||void 0===k?void 0:k.startDate," -"," ",null==U?void 0:null===(_=U.account)||void 0===_?void 0:_.endDate]})]}),I&&(null==z?void 0:z.qbAccountSync)&&(0,n.jsx)("button",{onClick:()=>{R("account"),B(!0)},className:"px-4 py-1.5 text-sm font-medium text-[#0052CC] bg-white border border-[#D1D5DB] rounded-lg hover:bg-[#F9FAFB] transition-colors",children:"Resync"})]})]})]})})]}),(0,n.jsx)(v.i,{}),(0,n.jsxs)("div",{className:"my-8",children:[(0,n.jsxs)("h3",{className:"text-18 font-circular-bold font-medium text-en-dark-blue mb-3 flex justify-between",children:[(0,n.jsx)("div",{children:"Export to QuickBooks"}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("span",{className:"bg-en-blue px-2 py-1.5 rounded-[16px]",children:(0,n.jsx)(c.uN,{})}),(0,n.jsx)(c.AD,{}),(0,n.jsx)(c.YZ,{})]})]}),(0,n.jsx)("div",{className:"rounded-xl p-6 border-[1.5px] mb-4  ".concat((null==z?void 0:z.eanoInvoiceSyncQb)?"bg-[#EDF3FB] border-en-blue":"bg-white border-en-divider-dark shadow"),children:(0,n.jsxs)("div",{className:"flex items-start gap-3",children:[(0,n.jsx)(j,{enabled:null==z?void 0:z.eanoInvoiceSyncQb,onChange:ec("eanoInvoiceSyncQb"),disabled:A||Z.has("eanoInvoiceSyncQb")}),(0,n.jsxs)("div",{className:"flex-1",children:[(0,n.jsx)("div",{className:"flex items-center justify-between font-medium text-sm mb-1 text-en-dark-blue leading-4",children:"Eano invoices"}),(0,n.jsx)("p",{className:"text-sm text-en-light-blue leading-relaxed mb-1",children:"Sync milestone invoices and manual invoices with QuickBooks. Changes made in QuickBooks to invoices created by the Eano sync engine will be updated."}),(0,n.jsx)("p",{className:"text-sm text-en-light-blue leading-relaxed mb-3 ",children:"invoices created in QuickBooks will not be imported"}),(0,n.jsx)("p",{className:"text-sm text-en-light-blue leading-relaxed mb-3 border-b border-en-divider-dark"}),(null==z?void 0:z.eanoInvoiceSyncQb)&&(0,n.jsxs)("div",{className:"mb-3",children:[(0,n.jsx)("h4",{className:"text-sm text-en-light-blue mb-3",children:"Data Mapping"}),(0,n.jsxs)("div",{className:"rounded-xl p-5 bg-white",children:[(0,n.jsxs)("div",{className:"mb-4",children:[(0,n.jsxs)("label",{className:"flex items-center gap-1.5 text-sm text-en-dark-blue mb-2",children:["Destination",(0,n.jsx)(c.YZ,{})]}),(0,n.jsx)(y,{value:ee,options:X.map(e=>({value:e.qbAccountId,label:e.qbAccountName})),onChange:e=>el("qbInvoiceAccountMapping",String(e)),disabled:Z.has("qbInvoiceAccountMapping")})]}),(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsxs)("label",{className:"flex-1 flex items-center gap-1.5 text-sm text-en-dark-blue mb-2",children:["Eano invoice",(0,n.jsx)("span",{className:"bg-en-blue px-2 py-1.5 rounded-[16px] inline-flex",children:(0,n.jsx)(c.uN,{})})]}),(0,n.jsx)("div",{className:"invisible",children:(0,n.jsx)(c.AD,{})}),(0,n.jsxs)("label",{className:"flex-1 flex items-center gap-1.5 text-sm text-en-dark-blue mb-2",children:["Destination Field",(0,n.jsx)(c.YZ,{})]})]}),(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)("div",{className:"flex-1",children:(0,n.jsx)(y,{value:en.displayValue,options:et,onChange:e=>el("qbInvoiceClientMapping",Number(e)),disabled:en.locked||Z.has("qbInvoiceClientMapping")})}),(0,n.jsx)(c.AD,{}),(0,n.jsx)("div",{className:"flex-1",children:(0,n.jsx)("div",{className:"w-full px-3 py-2 text-sm border border-[#D1D5DB] rounded-lg bg-[#F3F4F6] text-[#9CA3AF]",children:"Name"})})]}),en.showProjectSyncNote&&(0,n.jsx)("p",{className:"text-xs text-en-light-blue mt-1",children:g.rc}),en.duplicateWarning&&(0,n.jsx)("p",{className:"text-xs text-[#B25C1F] mt-1",children:en.duplicateWarning}),(0,n.jsxs)("div",{className:"flex items-center gap-3 mt-1",children:[(0,n.jsx)("div",{className:"flex-1",children:(0,n.jsx)(y,{value:(null==z?void 0:z.qbInvoiceNoMapping)||1,options:es,onChange:e=>el("qbInvoiceNoMapping",Number(e)),disabled:Z.has("qbInvoiceNoMapping")})}),(0,n.jsx)(c.AD,{}),(0,n.jsx)("div",{className:"flex-1",children:(0,n.jsx)("div",{className:"w-full px-3 py-2 text-sm border border-[#D1D5DB] rounded-lg bg-[#F3F4F6] text-[#9CA3AF]",children:"Invoice ID"})})]}),(null==z?void 0:z.qbInvoiceNoMapping)===2&&(0,n.jsx)("p",{className:"text-xs text-en-light-blue mt-2",children:'When "Custom invoice ID" is selected, the custom ID will be sent to QuickBooks. If no custom ID is set, the Eano invoice number will be used as fallback. If the same custom ID is assigned to multiple invoices, QuickBooks will be updated with the newest invoice.'}),(0,n.jsxs)("div",{className:"mt-5",children:[(0,n.jsx)("h4",{className:"text-sm text-en-light-blue mb-3",children:"Product Mapping"}),(0,n.jsx)("div",{className:"space-y-2",children:[{value:1,title:"Consolidated data",desc:"Create a single Eano product in QuickBooks, and use the description line to encode order lines"}
1,{value:2,title:"Create new products",desc:"Create a product in QuickBooks for every distinct order line in your Eano invoices"}].map(e=>{let t=((null==z?void 0:z.qbInvoiceProductMapping)||1)===e.value;return(0,n.jsx)("button",{type:"button",disabled:Z.has("qbInvoiceProductMapping"),onClick:()=>el("qbInvoiceProductMapping",e.value),className:"w-full text-left rounded-xl border p-4 transition-colors ".concat(t?"border-en-blue bg-[#F5F8FF]":"border-[#D1D5DB] bg-white"," ").concat(Z.has("qbInvoiceProductMapping")?"opacity-60 cursor-not-allowed":""),children:(0,n.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"text-sm font-medium text-en-dark-blue",children:e.title}),(0,n.jsx)("p",{className:"text-xs text-en-light-blue mt-1",children:e.desc})]}),(0,n.jsx)("span",{className:"mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-full border ".concat(t?"border-en-blue":"border-[#D1D5DB]"),children:t&&(0,n.jsx)("span",{className:"h-2 w-2 rounded-full bg-en-blue"})})]})},e.value)})})]})]})]}),(0,n.jsx)("div",{className:"text-xs text-en-light-blue pt-3 ",children:(null==U?void 0:U.invoiceLastSynced)&&(0,n.jsxs)("p",{children:["Last sync: ",null==U?void 0:U.invoiceLastSynced]})})]})]})}),(0,n.jsx)("div",{className:"rounded-xl p-6 border-[1.5px]  ".concat((null==z?void 0:z.eanoExpenseSyncQb)&&ei?"bg-[#EDF3FB] border-en-blue":"bg-white border-en-divider-dark shadow"),children:(0,n.jsxs)("div",{className:"flex items-start gap-3",children:[(0,n.jsx)(j,{enabled:(null==z?void 0:z.eanoExpenseSyncQb)&&ei,onChange:ec("eanoExpenseSyncQb"),disabled:A||Z.has("eanoExpenseSyncQb")||!ei}),(0,n.jsxs)("div",{className:"flex-1 mt-[-2px]",children:[(0,n.jsx)("div",{className:"flex items-center justify-between mb-1",children:(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("span",{className:"font-medium text-sm text-en-dark-blue leading-4",children:"Eano expense"}),!ei&&(0,n.jsx)(w,{})]})}),(0,n.jsx)("p",{className:"text-sm text-en-light-blue leading-relaxed mb-1",children:(null==z?void 0:z.eanoExpenseSyncQb)&&ei?(0,n.jsxs)(n.Fragment,{children:["Sync manual expenses with QuickBooks. Changes made in QuickBooks to invoices created by the Eano sync engine will be updated.",(0,n.jsx)("br",{}),"This feature is only available for QuickBooks Plus and Advanced plans with Purchase Orders enabled."]}):"Write expenses you create in Eano into QuickBooks"}),!ei&&(0,n.jsxs)("p",{className:"text-sm text-[#DC2626] leading-relaxed mt-2",children:["Your QuickBooks Online subscription (",(null==z?void 0:z.qbPlan)==="simple_start"?"Simple Start":(null==z?void 0:z.qbPlan)==="essentials"?"Essentials":(null==z?void 0:z.qbPlan)||"current plan",") does not include purchase order support, which we need to write expenses from Eano to your QuickBooks.",(0,n.jsx)("br",{}),"To enable this, you'll need to upgrade your QuickBooks Online subscription to Plus or higher."]}),(0,n.jsx)("div",{className:"text-xs text-en-light-blue mt-2",children:(null==U?void 0:U.eanoExpenseLastSynced)&&(0,n.jsxs)("p",{children:["Last sync: ",null==U?void 0:U.eanoExpenseLastSynced]})})]})]})})]})]})})]}),(0,n.jsx)(b,{open:P,onClose:()=>B(!1),onConfirm:ep,lastSyncedDateRange:U,loading:M,syncModel:O})]})}},22187:function(e,t,s){s.d(t,{W:function(){return l}});var n=s(52676);s(75271);var a=s(77690);let l=e=>{let{open:t,onClose:s,onConnect:l}=e;return(0,n.jsx)(a.ZP,{open:t,onClose:s,width:"small",contentClassName:"px-8 py-6",hideCloseBtn:!1,closeOnBackdropClick:!1,children:(0,n.jsxs)("div",{className:"flex flex-col items-center",children:[(0,n.jsx)("div",{className:"mb-6",children:(0,n.jsxs)("svg",{width:"80",height:"80",viewBox:"0 0 80 80",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,n.jsx)("circle",{cx:"40",cy:"40",r:"40",fill:"#F0F4FF"}),(0,n.jsx)("path",{d:"M28 40L36 48L52 32",stroke:"#0052CC",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round"})]})}),(0,n.jsx)("h2",{className:"text-2xl font-semibold text-[#051023] mb-4 text-center",children:"Connect Your Stripe Account"}),(0,n.jsx)("p",{className:"text-[#6B7280] text-base text-center mb-8 max-w-md",children:"To receive online payments from your clients, you need to connect your Str
1ipe account. This will enable secure payment processing for all your projects."}),(0,n.jsxs)("div",{className:"flex gap-4 w-full max-w-sm",children:[(0,n.jsx)("button",{onClick:s,className:"flex-1 px-6 py-3 text-base text-[#6B7280] bg-white border border-[#E5E7EB] rounded-lg hover:bg-gray-50 transition-colors",children:"Later"}),(0,n.jsx)("button",{onClick:l,className:"flex-1 px-6 py-3 text-base text-white bg-[#0052CC] rounded-lg hover:bg-[#0041AA] transition-colors",children:"Connect Stripe"})]})]})})}},47758:function(e,t,s){s.d(t,{i:function(){return sI}});var n,a,l,r,i=s(52676),o=s(75271),d=s(6522),c=s(89148),u=s.n(c),x=s(10734),p=s(26059),m=s(47280),h=s(5400),v=s(14836),g=s(82243),f=s(55052),b=s.n(f),j=s(28317),y=s(84665),w=s(37832),N=s(41478),C=s(38259),k=s(92736),_=s(77938),F=s(60722),E=s(83857),S=s(14190),D=s(10604),I=s(35937),A=s(65966),P=s(64729),B=s(21765),M=s(53700),L=s(53256),Z=s(76815),T=s(71792);let O=async e=>{let t=new URLSearchParams(e.split("?")[1]),s=await T.vendor.getVendorTeamList({query:t.get("query")||"",role_id:t.get("role_id")||"3",page:Number(t.get("page")||1),page_size:30});if(0===s.code)return s.data||{};throw Error(s)},R=function(){var e,t;let s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{enabled:n=!0,revalidateOnFocus:a=!1,revalidateOnReconnect:l=!1,query:r="",roleId:i="3"}=s,{data:d,error:c,isLoading:u,isValidating:x,mutate:p,size:m,setSize:h}=(0,Z.ZP)(e=>{if(!n)return null;let t=new URLSearchParams({page:String(e+1),page_size:String(30),query:r,role_id:i});return"/api/v1/vendor/people/list?".concat(t.toString())},O,{revalidateOnFocus:a,revalidateOnReconnect:l}),v=(0,o.useRef)(r);(0,o.useEffect)(()=>{v.current!==r&&(v.current=r,h(1))},[r,h]);let g=d?d.flatMap(e=>(null==e?void 0:e.items)||[]):[],f=null!==(t=null==d?void 0:null===(e=d[0])||void 0===e?void 0:e.total_count)&&void 0!==t?t:0,b=m>0&&d&&void 0===d[m-1],j=g.length<f,y=(0,o.useCallback)(()=>{!x&&j&&h(e=>e+1)},[x,j,h]);return{userData:g,total:f,isLoading:u,isLoadingMore:b||!1,hasMore:j,loadMore:y,reset:(0,o.useCallback)(()=>{h(1),p()},[h,p]),isError:!!c,error:c,mutate:p}};var z=s(14567),W=s(93735),q=s(53100),U=s(80114),V=s(20582);let Q=e=>{let{enabled:t,objId:s,sourceType:n}=e,{data:a,isLoading:l,mutate:r,error:i}=(0,U.u)(t&&s&&n?"/api/v1/finance/expense/detail/?obj_id=".concat(s,"&source_id=").concat(n):null,V._i,{revalidateOnFocus:!1,revalidateOnReconnect:!1});return{detailData:a,isLoading:l,mutate:r,error:i}};var H=s(81764),Y=s.n(H),G=s(60090),$=s(45358);let K=(0,E.ZP)(j.Z)({"& .MuiDialog-paper":{borderRadius:16,width:480,maxWidth:"90%",padding:0}}),X=(0,E.ZP)("button",{shouldForwardProp:e=>"active"!==e})(e=>{let{theme:t,active:s}=e;return{padding:t.spacing(1,3),border:"none",background:s?"#FFFFFF":"transparent",color:s?"#111827":"#6B7280",fontSize:14,fontWeight:500,borderRadius:100,cursor:"pointer",transition:"all 0.2s ease",outline:"none",minWidth:140,...s&&{boxShadow:"0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)"},"&:hover":{color:s?"#111827":"#374151"}}}),J=(0,E.ZP)("div",{shouldForwardProp:e=>"selected"!==e})(e=>{let{theme:t,selected:s}=e;return{flex:1,padding:t.spacing(2.5),border:s?"2px solid #2563EB":"2px solid #E5E7EB",borderRadius:12,cursor:"pointer",transition:"all 0.2s ease",position:"relative",backgroundColor:s?"#EFF6FF":"#FFFFFF","&:hover":{borderColor:"#D1D5DB"}}}),ee=(0,E.ZP)(y.Z)(e=>{let{theme:t}=e;return{"& .MuiOutlinedInput-root":{fontSize:16,"& input":{padding:t.spacing(1.5)}}}}),et=(0,E.ZP)(w.Z)(e=>{let{theme:t}=e;return{flex:1,backgroundColor:"#10CA8A",borderRadius:8,color:"white",textTransform:"none",fontWeight:500,padding:t.spacing(1.5),fontSize:16,"&:hover":{background:"linear-gradient(0deg, rgba(255, 255, 255, 0.50) 0%, rgba(255, 255, 255, 0.50) 100%), #10CA8A"},"&.Mui-disabled":{backgroundColor:"#9CA3AF",color:"#D1D5DB",cursor:"not-allowed","&:hover":{backgroundColor:"#9CA3AF",cursor:"not-allowed"}},"& .MuiButton-startIcon":{marginRight:t.spacing(1)}}}),es=(0,E.ZP)(w.Z)(e=>{let{theme:t}=e;return{flex:1,backgroundColor:"#0052CC",borderRadius:8,color:"white",textTransform:"none",fontWeight:500,padding:t.spacing(1.5),fontSize:16,"&:hover":{backgroundColor:"#1D4ED8"},"& .MuiButton-startIcon":{marginRight:t.spacing(1)}}}),en=(0,E.ZP)("div")({color:"#2563EB",textDecoration:"none",fontSize:16,fontWeight:500,cursor:"pointer",textAlign:"center",display:"flex",justifySelf:"center",width:"fit-content","&:hover":{textDecoration:"underline"}});(n=l||(l={}))[n.OpenBid=0]="OpenBid",n[n.FirmOnPrice=1]="FirmOnPrice";var ea=e=>{let{open:t,setOpen:s,projectId:n,itemExpense:a,setItemExpense:l,openScopeEdit:r,onRefreshData:d,setProjectDetailActiveTab:c,setOpenProjectId:u,isInDetail:x,linkOnly:p=!1}=e,[m,h]=(0,o.useState)(p?0:1),{refresh:v}=(0,z.z)({projectId:n,excludeCancel:!0,pageSize:20}),{mutate:g}
1=Q({enabled:r&&!Y().isEmpty(a),objId:null==a?void 0:a.obj_id,sourceType:null==a?void 0:a.source_type}),[f,j]=(0,o.useState)(1),[y,w]=(0,o.useState)({kind:$.k8.SUBCONTRACT,price:"",specifyVendorIds:[],files:[]}),[E,Z]=(0,o.useState)(!1),[T,O]=(0,o.useState)(!1),[U,V]=(0,o.useState)(!1),[H,ea]=(0,o.useState)(""),[el,er]=(0,o.useState)(""),ei=(0,o.useRef)(),eo=(0,o.useRef)(null),ed=(0,o.useRef)(null),{userData:ec,hasMore:eu,loadMore:ex,isLoadingMore:ep}=R({enabled:t,query:el}),em=e=>{ea(e),clearTimeout(ei.current),ei.current=setTimeout(()=>{er(e)},300)};(0,o.useEffect)(()=>{t&&p&&h(0)},[t,p]),(0,o.useEffect)(()=>{let e=e=>{eo.current&&!eo.current.contains(e.target)&&V(!1)};if(U)return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[U]),(0,o.useEffect)(()=>{U&&ed.current&&setTimeout(()=>{var e;null===(e=ed.current)||void 0===e||e.focus()},50)},[U]);let eh=Array.isArray(ec)?ec:[],ev=e=>{w(t=>({...t,specifyVendorIds:t.specifyVendorIds.includes(e)?t.specifyVendorIds.filter(t=>t!==e):[...t.specifyVendorIds,e]}))},eg=e=>{let t=(0,W.q)(e);w(e=>({...e,files:[...e.files,...t]}))},ef=()=>{s(!1),h(1),r||l({}),j(1),w({kind:$.k8.SUBCONTRACT,price:"",specifyVendorIds:[],files:[]}),u(null),O(!1)},eb=e=>{j(e),w(t=>({...t,price:0===e?"":t.price,specifyVendorIds:[]}))},ej=(e,t)=>{w(s=>({...s,[e]:t}))},ey=async e=>{e.id&&(await ew({workOrderId:e.id}),await d())},ew=async e=>{let t=await (0,B.r)({url:"/api/v1/finance/link_work_order/",method:"post",params:{...e,manualExpenseId:null==a?void 0:a.obj_id}});return t.isOk?(ef(),!0):(L.Z.error(t.resMessage||"Create Failed"),!1)},eN=async e=>{if(T)return!1;O(!0);try{var t;let{isOk:s,result:l,resMessage:r}=await (0,B.r)({url:"/api/v1/dispatch_work_order/create",method:"post",params:{...e,price:""===e.price||void 0===e.price?null:e.price,files:e.files.map(e=>({fileId:e.fileId,privateFile:!1})),scope:JSON.stringify(a.group_id?[{title:(null==a?void 0:a.scope_description)||(null==a?void 0:a.description)||"Work Order",sub_project_type:"",checked:!0,content:null!==(t=null==a?void 0:a.scope_names)&&void 0!==t?t:[]}]:[{title:(null==a?void 0:a.scope_description)||(null==a?void 0:a.description)||"Work Order",sub_project_type:"",checked:!0}]),name:(null==a?void 0:a.scope_description)||(null==a?void 0:a.description)||"Work Order",projectId:n,priceType:f}});if(!s)return L.Z.error(r||"Create Failed"),!1;{window.postMessage({type:"updateWorkOrders"},"*");let e=!1;return e=await ew(l),await d(),await g(),v(),e}}catch(e){return console.error("Failed to save work order:",e),L.Z.error("Failed to create. Please try again."),!1}finally{O(!1)}},eC=async()=>{await eN({...y,isCreateAndAssigned:!0})&&L.Z.success("Work order created and assigned successfully!")},ek=async()=>{await eN({...y,isCreateAndAssigned:!1})&&L.Z.success("Work order created and bids requested successfully!")};return(0,i.jsxs)(K,{open:t,onClose:ef,children:[(0,i.jsxs)(N.Z,{className:"relative",sx:{pt:3,pb:0,px:3},children:[(0,i.jsx)(C.Z,{className:"absolute cursor-pointer z-[100]",sx:{top:16,right:16,p:1},onClick:ef,size:"small",children:(0,i.jsx)(S.Z,{})}),(0,i.jsxs)(N.Z,{className:"inline-flex bg-[#E5E7EB] rounded-[100px] p-1 ".concat(p?"!bg-white":""),sx:{mb:3},children:[(0,i.jsx)(X,{active:0===m&&!p,onClick:()=>h(0),children:"Link to Existing"}),!p&&(0,i.jsx)(X,{active:1===m,onClick:()=>h(1),children:"Create New"})]})]}),(0,i.jsx)(k.Z,{sx:{pt:0,px:3,pb:3},children:0===m?(0,i.jsx)(M.Z,{projectId:n,onSelectWorkOrder:ey}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(_.Z,{className:"text-[#6B7280] text-base",sx:{mb:3},children:"Choose a pricing method to start creating a new order"}),(0,i.jsxs)(N.Z,{className:"flex",sx:{gap:2,mb:3},children:[(0,i.jsxs)(J,{selected:0===f,onClick:()=>eb(0),children:[0===f&&(0,i.jsx)(D.Z,{className:"absolute text-[#2563EB]",sx:{top:16,right:16}}),(0,i.jsx)(_.Z,{className:"text-lg font-semibold text-[#1F2937]",sx:{mb:1},children:"Allow Offers"}),(0,i.jsx)(_.Z,{className:"text-sm text-[#6B7280] leading-normal",children:"People invited can submit their best offer, and you choose your favorite bid."})]}),(0,i.jsxs)(J,{selected:1===f,onClick:()=>eb(1),children:[1===f&&(0,i.jsx)(D.Z,{className:"absolute text-[#2563EB]",sx:{top:16,right:16}}),(0,i.jsx)(_.Z,{className:"text-lg font-semibold text-[#1F2937]",sx:{mb:1},children:"Firm On Price"}),(0,i.jsx)(_.Z,{className:"text-sm text-[#6B7280] leading-normal",children:"You set a price, and invited people can review it and bid if they accept; you choose the winner."})]})]}),(0,i.jsxs)(N.Z,{sx:{mb:3},children:[(0,i.jsxs)(_.Z,{className:"text-sm font-medium text-[#374151] block",sx:{mb:1},children:["Kind ",(0,i.jsx)("span",{className:"text-[#EF4444]",children:"*"})]}),(0,i.jsx)("div",{children:(0,i.jsx)(G.Z,{value:y.kind,onChange:e=>ej("kind",e)})})]}),0===f?null:(0,i.jsxs)(N.Z,{sx:{mb:3},children:[(0,i.jsxs)(_.Z,{className:"text-sm font-medium text-[#374151] block",sx:{mb:1},children:["Price ",(0,i.jsx)("span",{className:"text-[#EF4444]",children:"*"})]}),(0,i.jsx)(q.h3,{customInput:ee,variant:"outlined",fullWidth:!0,value:y.price,onValueChange:e=>{ej("price",e.value)}
1,placeholder:"0",thousandSeparator:",",decimalScale:2,allowNegative:!1,allowLeadingZeros:!1,isAllowed:e=>{let{floatValue:t}=e;return void 0===t||t>=0},InputProps:{startAdornment:(0,i.jsx)(F.Z,{position:"start",children:"$"})}})]}),(0,i.jsxs)(N.Z,{sx:{mb:3},children:[(0,i.jsx)(_.Z,{className:"text-sm font-medium text-[#374151] block",sx:{mb:1},children:"Select Vendors"}),(0,i.jsxs)("div",{className:"relative",ref:eo,children:[(0,i.jsx)("button",{type:"button",onClick:()=>V(!U),className:"w-full px-4 py-2.5 border-2 border-[#E1E4EB] rounded-2xl text-left bg-[#F7F8FA] hover:bg-white hover:border-[#D1E0F6] focus:outline-none focus:ring-2 focus:ring-[#E9F1FD] focus:border-[#0052CC] transition-all duration-200",children:y.specifyVendorIds.length>0?(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)("div",{className:"flex -space-x-2",children:(ec||[]).filter(e=>y.specifyVendorIds.includes(e.id)).slice(0,3).map(e=>(0,i.jsx)("div",{className:"relative",children:e.avatar_url?(0,i.jsx)(b(),{src:e.avatar_url,alt:e.name,width:32,height:32,className:"w-8 h-8 rounded-full border-2 border-white shadow-sm object-cover"}):(0,i.jsx)("div",{className:"w-8 h-8 rounded-full bg-gradient-to-br from-[#E9F1FD] to-[#D6E5FC] border-2 border-white shadow-sm flex items-center justify-center",children:(0,i.jsx)("span",{className:"text-[#0052CC] text-xs font-medium",children:e.name.charAt(0).toUpperCase()})})},e.id))}),(0,i.jsxs)("span",{className:"text-sm text-[#3B4658]",children:[y.specifyVendorIds.length," vendor",y.specifyVendorIds.length>1?"s":""," selected"]})]}):(0,i.jsx)("span",{className:"text-[#B0B8C4]",children:"Select vendors..."})}),U&&(0,i.jsxs)("div",{className:"absolute top-full left-0 right-0 mt-2 bg-white border-2 border-[#E1E4EB] rounded-2xl shadow-xl z-50 max-h-96 overflow-hidden",children:[(0,i.jsx)("div",{className:"p-3 border-b border-[#E1E4EB]",children:(0,i.jsxs)("div",{className:"relative",children:[(0,i.jsx)("input",{ref:ed,type:"text",value:H,onChange:e=>em(e.target.value),placeholder:"Search vendors by name...",className:"w-full pl-10 pr-4 py-2 border border-[#E1E4EB] rounded-xl bg-[#F7F8FA] hover:bg-white focus:bg-white focus:outline-none focus:ring-2 focus:ring-[#E9F1FD] focus:border-[#0052CC] transition-all duration-200 text-sm"}),(0,i.jsx)("div",{className:"absolute left-3 top-1/2 -translate-y-1/2 pointer-events-none",children:(0,i.jsx)("svg",{className:"w-4 h-4 text-[#7C8293]",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}),H&&(0,i.jsx)("button",{type:"button",onClick:()=>em(""),className:"absolute right-3 top-1/2 -translate-y-1/2",children:(0,i.jsx)("svg",{className:"w-4 h-4 text-[#7C8293] hover:text-[#051023]",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),(0,i.jsxs)("div",{className:"p-2 max-h-80 overflow-y-auto",onScroll:e=>{let{scrollTop:t,scrollHeight:s,clientHeight:n}=e.currentTarget;s-t-n<50&&eu&&!ep&&ex()},children:[0===eh.length?(0,i.jsx)("div",{className:"text-center py-4 text-sm text-gray-500",children:H?"No vendors match your search":"No vendors found"}):eh.map(e=>(0,i.jsxs)("label",{className:"flex items-center gap-3 p-2 hover:bg-[#F7F8FA] rounded-xl cursor-pointer transition-all duration-200",children:[(0,i.jsx)("input",{type:"checkbox",checked:y.specifyVendorIds.includes(e.id),onChange:()=>ev(e.id),className:"h-4 w-4 text-[#0052CC] focus:ring-[#0052CC] focus:ring-offset-0 focus:ring-2 border-2 border-[#E1E4EB] rounded cursor-pointer"}),(0,i.jsxs)("div",{className:"flex items-center gap-2 flex-1",children:[e.avatar_url?(0,i.jsx)(b(),{src:e.avatar_url,alt:e.name,width:32,height:32,className:"w-8 h-8 rounded-full object-cover"}):(0,i.jsx)("div",{className:"w-8 h-8 rounded-full bg-gradient-to-br from-[#E9F1FD] to-[#D6E5FC] flex items-center justify-center",children:(0,i.jsx)("span",{className:"text-[#0052CC] text-sm font-medium",children:e.name.charAt(0).toUpperCase()})}),(0,i.jsxs)("div",{children:[(0,i.jsx)("p",{className:"text-sm font-medium text-[#051023]",children:e.name}),e.type&&(0,i.jsx)("p",{className:"text-xs text-[#7C8293]",children:e.type})]})]})]},e.id)),ep&&(0,i.jsx)("div",{className:"flex items-center justify-center py-2",children:(0,i.jsx)("div",{className:"w-4 h-4 border-2 border-[#0052CC] border-t-transparent roun
1ded-full animate-spin"})})]})]})]})]}),(0,i.jsxs)(N.Z,{sx:{mb:3},children:[(0,i.jsx)(_.Z,{className:"text-sm font-semibold text-[#1A1F36]",sx:{mb:2},children:"Attachments"}),y.files.length>0?(0,i.jsxs)("div",{className:"space-y-2",children:[y.files.map((e,t)=>(0,i.jsxs)("div",{className:"flex items-center justify-between p-3 bg-en-light-gray rounded-lg",children:[(0,i.jsxs)("div",{className:"flex items-center gap-3",children:[(0,i.jsx)(b(),{src:e.thumbnailUrl,alt:"Attachment ".concat(t+1),width:40,height:40,className:"w-10 h-10 object-cover rounded"}),(0,i.jsx)("span",{className:"text-sm text-gray-700",children:e.fileName||"Attachment ".concat(t+1)})]}),(0,i.jsx)("button",{className:"text-gray-400 hover:text-red-500 transition-colors",onClick:()=>{w(e=>({...e,attachmentIds:e.files.filter((e,s)=>s!==t)}))},children:(0,i.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]},t)),(0,i.jsx)(I.Z,{onChange:eg,className:"w-full",children:(0,i.jsxs)("button",{className:"w-full py-2 px-4 bg-white border border-gray-300 rounded-lg text-gray-600 hover:bg-gray-50 transition-colors flex items-center justify-center gap-2",children:[(0,i.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"})}),"Upload Files"]})})]}):(0,i.jsx)(I.Z,{onChange:eg,className:"w-full h-full [&>div]:w-full [&>div]:h-full",children:(0,i.jsxs)("div",{className:"py-4 gap-2 border-[1.5px] border-dashed bg-[#eaf1fc] cursor-pointer rounded-lg w-full h-full flex items-center justify-center",children:[(0,i.jsx)("div",{className:"flex rounded-full w-10 h-10 items-center justify-center bg-[#0052CC] bg-opacity-50",children:(0,i.jsx)(A.rG,{})}),(0,i.jsx)("div",{className:"text-sm text-en-disable text-center",children:"Drag here or click to upload"})]})})]})]})}),1===m&&(0,i.jsxs)(N.Z,{className:"bg-[#F9FAFB] border-t border-[#E5E7EB] rounded-b-2xl",sx:{p:3},children:[(0,i.jsxs)(N.Z,{className:"flex",sx:{gap:2,mb:2},children:[1===f&&(0,i.jsx)(P.Z,{open:E,onOpen:()=>Z(!0),onClose:()=>Z(!1),title:(0,i.jsx)("div",{children:"Use this button to assign and mark the selected vendor as won when the price is above $0, and only one vendor is selected."}),placement:"top",arrow:!0,children:(0,i.jsx)(et,{onClick:eC,disabled:y.specifyVendorIds.length>1||T,children:T?"Send...":"Send Confirmation"})}),(0,i.jsx)(es,{onClick:ek,disabled:T,children:T?"Requesting...":"Request Bids"})]}),x&&(0,i.jsx)(en,{onClick:()=>{ef(),c("work_orders"),window.top.postMessage({type:"openCreateWorkOrder",data:a.group_id?{group_id:a.group_id,group_name:null==a?void 0:a.scope_description}:null},"*")},children:"Edit More >"})]})]})},el=s(77690),er=s(82298),ei=e=>{let{open:t,onClose:s,expense:n,mode:a="modify"}=e,{categoryOptions:l}=(0,er.z)(),{actions:r}=(0,d.pL)(),[c,u]=(0,o.useState)([]),[x,p]=(0,o.useState)(!1),[h,f]=(0,o.useState)(null),[b,j]=(0,o.useState)("");(0,o.useEffect)(()=>{if(n){var e;u((null===(e=n.category)||void 0===e?void 0:e.map(e=>e.id))||[]),j("")}},[n]);let y=e=>{u(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},w=async()=>{if(n){p(!0);try{await v.o.setExpenseCategory(n.obj_id,n.source_type,c),g.y.success("Categories updated successfully"),r.updateExpenseCategories(n.obj_id,c,l),s()}catch(e){console.error("Failed to update categories:",e),g.y.error("Failed to update categories. Please try again.")}finally{p(!1)}}},N=async e=>{if(n){f(e);try{let t=c.filter(t=>t!==e);await v.o.setExpenseCategory(n.obj_id,n.source_type,t),g.y.success("Category removed successfully"),u(t),r.updateExpenseCategories(n.obj_id,t,l)}catch(e){console.error("Failed to remove category:",e),g.y.error("Failed to remove category. Please try again.")}finally{f(null)}}},C=async()=>
1{if("DELETE"!==b){g.y.error("Please type DELETE to confirm");return}if(n){p(!0);try{await v.o.setExpenseCategory(n.obj_id,n.source_type,[]),g.y.success("All categories removed successfully"),r.updateExpenseCategories(n.obj_id,[]),s()}catch(e){console.error("Failed to remove categories:",e),g.y.error("Failed to remove categories. Please try again.")}finally{p(!1)}}};return(0,i.jsx)(el.ZP,{open:t,onClose:s,width:"small",title:"delete"===a?"Delete Categories":"Manage Categories",children:(0,i.jsx)("div",{className:"p-6",children:"modify"===a?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:"mb-6",children:[(0,i.jsx)("h3",{className:"text-sm font-medium text-gray-700 mb-3",children:"Select Categories"}),(0,i.jsx)("div",{className:"space-y-2",children:l.map(e=>{let t=c.includes(e.id);return(0,i.jsxs)("label",{className:"flex items-center p-3 rounded-lg border border-gray-200 hover:bg-gray-50 cursor-pointer transition-colors",children:[(0,i.jsx)("input",{type:"checkbox",checked:t,onChange:()=>y(e.id),className:"mr-3 h-4 w-4 text-blue-600 rounded focus:ring-blue-500",disabled:x}),(0,i.jsx)("span",{className:(0,m.cn)("text-sm",t?"font-medium text-gray-900":"text-gray-600"),children:e.name})]},e.id)})})]}),(0,i.jsxs)("div",{className:"flex justify-end gap-3",children:[(0,i.jsx)("button",{onClick:s,className:"px-4 py-2 text-sm text-gray-600 hover:text-gray-800 transition-colors",disabled:x,children:"Cancel"}),(0,i.jsx)("button",{onClick:w,disabled:x,className:(0,m.cn)("px-6 py-2 text-sm text-white rounded-lg transition-colors",x?"bg-gray-400 cursor-not-allowed":"bg-blue-600 hover:bg-blue-700"),children:x?"Saving...":"Save Changes"})]})]}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:"mb-6",children:[(0,i.jsx)("h3",{className:"text-sm font-medium text-gray-700 mb-3",children:"Current Categories"}),c.length>0?(0,i.jsx)("div",{className:"space-y-2",children:c.map(e=>{let t=l.find(t=>t.id===e);return t?(0,i.jsxs)("div",{className:"flex items-center justify-between p-3 rounded-lg border border-gray-200",children:[(0,i.jsx)("span",{className:"text-sm text-gray-700",children:t.name}),(0,i.jsx)("button",{onClick:()=>N(e),disabled:x||h===e,className:(0,m.cn)("text-sm font-medium transition-colors",x||h===e?"text-gray-400 cursor-not-allowed":"text-red-600 hover:text-red-700"),children:h===e?"Removing...":"Remove"})]},e):null})}):(0,i.jsx)("p",{className:"text-sm text-gray-500",children:"No categories assigned"})]}),c.length>0&&(0,i.jsxs)("div",{className:"mb-6 p-4 bg-red-50 rounded-lg border border-red-200",children:[(0,i.jsx)("h4",{className:"text-sm font-medium text-red-800 mb-2",children:"Remove All Categories"}),(0,i.jsx)("p",{className:"text-xs text-red-600 mb-3",children:'This will remove all category assignments from this expense. Type "DELETE" to confirm.'}),(0,i.jsx)("input",{type:"text",value:b,onChange:e=>j(e.target.value),placeholder:"Type DELETE to confirm",className:"w-full px-3 py-2 text-sm border border-red-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-red-500",disabled:x})]}),(0,i.jsxs)("div",{className:"flex justify-end gap-3",children:[(0,i.jsx)("button",{onClick:s,className:"px-4 py-2 text-sm text-gray-600 hover:text-gray-800 transition-colors",disabled:x,children:"Close"}),c.length>0&&(0,i.jsx)("button",{onClick:C,disabled:x||"DELETE"!==b,className:(0,m.cn)("px-6 py-2 text-sm text-white rounded-lg transition-colors",x||"DELETE"!==b?"bg-gray-400 cursor-not-allowed":"bg-red-600 hover:bg-red-700"),children:x?"Removing...":"Remove All"})]})]})})})},eo=s(4471),ed=s(6155),ec=s(74722),eu=s(37924),ex=s(84662),ep=s(22665),em=s(17702),eh=s(16113),ev=s(56080),eg=s(49838),ef=s(62633),eb=s(69210);let ej={amount:"",paidDate:null,payMethod:"",paymentReference:"",paymentMemo:"",files:[]};var ey=e=>{let{expenseObjId:t,initialPayments:s,onRefreshData:n,onStatusChange:a,onNavigateAway:l,readOnly:r=!1}=e,{paymentsData:d,paymentDialogOpen:c,paymentsInitData:u,openAdd:x,openEdit:p,closePaymentDialog:m,handleSavePayment:h,deletePayment:v}=function(e,t){let{initialPayments:s,onRefreshData:n,onStatusChange:a}=t,[l,r]=(0,o.useState)(!1),[i,d]=(0,o.useState)(ej),[c,u]=(0,o.useState)({paymentPriceMap:{},payments:[]});(0,o.useEffect)(()=>{s&&u(s)},[s]);let x=()=>{r(!1),d(ej)},p=async()=>{x(),n();let{result:t,isOk:s}=await (0,B.r)({url:"/api/v1/finance/get_all_payment_detail/",params:{expenseId:e}});s&&u(t.data)};return{paymentsData:c,paymentDialogOpen:l,paymentsInitData:i,openAdd:()=>r(!0),openEdit:e=>{r(!0),d(e)},closePaymentDialog:x,handleSavePayment:async t=>{let{files:s=[],manualExpensePaymentId:n,paidDate:l,payMethod:r,payMethodName:i,source:o,lineItems:d=[],receiptFile:c,...u}
1=t,x={...u,paidDate:(0,em.WU)(l,"yyyy-MM-dd"),fileIds:(0,eb.mC)(c,s),manualExpenseId:e,payment_account_id:r,payMethod:i,source:o||1};n&&(x.manualExpensePaymentId=n),d.length>0&&(x.items=(0,eb.Oo)(d));let m=await (0,B.r)({url:"/api/v1/finance/edit_payment/",method:"post",params:x});if(m.isOk){var h;(0,eh.k)("/api/v1/finance/qb/expense/chart"),(null===(h=m.result)||void 0===h?void 0:h.status)&&(null==a||a(m.result.status)),p()}else ev.ZP.error(m.resMessage||"Save error")},deletePayment:async e=>{let t=await (0,B.r)({url:"/api/v1/finance/del_payment/",method:"post",params:{manualExpensePaymentId:e}});t.isOk?(p(),(0,eh.k)("/api/v1/finance/qb/expense/chart")):ev.ZP.error(t.resMessage||"Save error")}}}(t,{initialPayments:s,onRefreshData:n,onStatusChange:a});return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(ef.Z,{payments:null==d?void 0:d.payments,paymentPriceMap:null==d?void 0:d.paymentPriceMap,onPaymentClick:p,onAddPayment:x,readOnly:r}),c&&(0,i.jsx)(eb.ZP,{open:c,onClose:m,onSave:h,initialData:u,deletePayment:v,onNavigateAway:l})]})},ew=e=>{let{source:t}=e;return(0,i.jsx)("span",{className:"ml-3 px-3 py-1 text-xs rounded-[13px] bg-[#E1E4EB] text-[#051023]",children:t})},eN=s(50496),eC=s(65857),ek=s(35405),e_=e=>{let{onDelete:t,qbSyncEnabled:s=!1}=e,[n,a]=(0,o.useState)(null),l=async()=>{null!==n&&(await t(n),a(null))};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{className:"flex w-fit flex-col gap-2 justify-self-center",children:s?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(ek.vd,{startIcon:(0,i.jsx)(eN.Z,{}),onClick:()=>a(!1),fullWidth:!0,children:"Delete from Eano & QuickBooks"}),(0,i.jsx)(ek.vd,{startIcon:(0,i.jsx)(eN.Z,{}),onClick:()=>a(!0),fullWidth:!0,children:"Delete from Eano Only"})]}):(0,i.jsx)(ek.vd,{startIcon:(0,i.jsx)(eN.Z,{}),onClick:()=>a(!1),fullWidth:!0,children:"Delete This Expense"})}),(0,i.jsx)(eC.Z,{open:null!==n,onClose:()=>a(null),handleDelete:l,dialogTitle:"Delete Expense",dialogContentText:n?"This will delete this expense from Eano only. It will remain unchanged in QuickBooks. This action cannot be undone.":"Are you sure you want to delete this expense? This action cannot be undone."})]})},eF=s(11061),eE=s(42999),eS=s(7026);let eD={1:"Draft",2:"Request sent",3:"Client viewed",4:"Payment processing",5:"Paid",6:"Past due",7:"Failed payment"};var eI=e=>{var t;let s,{clientInvoice:n}=e,{invoice_no:a,is_paid:l,status:r,paid_date:o,due_date:d}=n,c=null!==(t=eD[r])&&void 0!==t?t:"Status ".concat(r);if(l){let e=o?" | Paid Date: ".concat((0,eS.Kc)(o)):"";s="Status: ".concat(c).concat(e)}else{let e=d?" | Due on: ".concat((0,eS.Kc)(d)):"";s="Status: ".concat(c).concat(e)}return(0,i.jsx)("div",{className:"flex justify-between items-center px-4 py-3 rounded-lg bg-en-light-gray border border-en-divider-dark",children:(0,i.jsxs)("div",{className:"space-y-1",children:[(0,i.jsx)("div",{className:"inline-block px-2 py-0.5 text-xs font-medium text-[#5E6C84] bg-[#DFE1E6] rounded",children:"Client Invoice"}),(0,i.jsx)("div",{className:"text-16 text-en-mid-blue",children:a}),(0,i.jsx)("div",{className:"text-14 text-en-light-blue",children:s})]})})},eA=s(8098),eP=s(16308),eB=s(41249),eM=e=>{let{description:t,subProjectName:s,groupName:n,isGroup:a}=e;return(0,i.jsx)("div",{className:"flex justify-between items-center px-4 py-3 rounded-lg bg-en-light-gray border border-en-divider-dark",children:(0,i.jsxs)("div",{className:"space-y-1",children:[(0,i.jsx)("div",{className:"bg-[#D9E1E9] rounded-[13px] px-2.5 py-1 text-13 text-en-mid-blue w-fit",children:a?"Group":"Scope"}),(0,i.jsx)("div",{className:"text-16 text-en-mid-blue",children:t}),(0,i.jsx)("div",{className:"text-14 text-en-light-blue",children:(0,eB.a)({subProjectName:s,groupName:n,isGroup:a})})]})})},eL=s(22414),eZ=e=>{let{project:t}=e;return(0,i.jsx)(eL.I,{...t})},eT=s(64638),eO=e=>{let{workerData:t,projectId:s,onCreateNew:n,onNavigate:a,onDisconnect:l,onSelectWorkOrder:r}=e,[d,c]=(0,o.useState)(null);return(0,i.jsxs)(i.Fragment,{children:[Y().isEmpty(t)?(0,i.jsxs)("div",{className:"flex py-1 items-center gap-1 cursor-pointer hover:opacity-80",onClick:e=>c(e.currentTarget),children:[(0,i.jsx)("div",{children:(0,i.jsx)(A.Ph,{})}),(0,i.jsx)("div",{className:"text-16 text-[#B2B2B2]",children:"Connect with subcontract"})]}):(0,i.jsxs)("div",{onClick:a,className:"flex justify-between items-center px-4 py-3 rounded-lg bg-en-light-gray border border-en-divider-dark cursor-pointer",children:[(0,i.jsxs)("div",{className:"space-y-1",children:[(0,i.jsx)($.K7,{t
1ype:(null==t?void 0:t.kind)||$.k8.SUBCONTRACT}),(0,i.jsxs)("div",{className:"text-16 text-en-mid-blue",children:[null==t?void 0:t.orderIdName," - ",null==t?void 0:t.name]}),(0,i.jsxs)("div",{className:"text-14 text-en-light-blue flex gap-2",children:[(0,i.jsxs)("div",{children:["Status: ",eE.hI[null==t?void 0:t.status]]}),(0,i.jsx)("div",{className:"w-[1px] h-5 bg-en-divider-dark"}),(0,i.jsx)("div",{children:eE.g8[null==t?void 0:t.priceType]}),(0,i.jsx)("div",{className:"w-[1px] h-5 bg-en-divider-dark"}),(0,i.jsxs)("div",{children:["Total Price: $ ",null==t?void 0:t.price]})]})]}),(0,i.jsx)("div",{onClick:e=>{e.stopPropagation(),l()},className:"cursor-pointer",children:(0,i.jsx)(A.RN,{})})]}),(0,i.jsx)(eT.Z,{canEdit:!0,anchorEl:d,onClose:()=>c(null),projectId:s,onCreateNew:n,onSelectWorkOrder:r})]})},eR=s(57085),ez=s(64338),eW=e=>{let{locked:t,payeeId:s,payeeName:n,userData:a,onChange:l}=e;return(0,i.jsx)(ep.Z,{className:"w-full",sx:ek.QW,children:t?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(_.Z,{className:"text-[14px] font-medium text-[#051023]",sx:ek.il,children:"Expense Owner"}),(0,i.jsx)(ek.fG,{variant:"outlined",fullWidth:!0,value:s,disabled:!0,IconComponent:()=>(0,i.jsx)(eR.Z,{title:"This vendor won the work order.",children:(0,i.jsx)("span",{style:{display:"flex",alignItems:"center",marginRight:8},children:(0,i.jsx)(A.Ph,{})})}),renderValue:e=>{let t=(a||[]).find(t=>t.id===e);return t?(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.avatar_url&&(0,i.jsx)(b(),{src:t.avatar_url,alt:t.name,width:24,height:24,style:{borderRadius:"50%",objectFit:"cover"}}),(0,i.jsx)("span",{className:"text-en-disable",children:t.name})]}):(0,i.jsx)("span",{className:"text-en-disable",children:n||""})},children:(a||[]).map(e=>(0,i.jsx)(p.Z,{value:e.id,children:e.name},e.id))})]}):(0,i.jsx)(ez.Z,{value:n||"",payeeId:s,onChange:l})})},eq=s(56154),eU=s(22158),eV=s(79852),eQ=e=>{let{totalCost:t,onTotalCostChange:s,totalCostError:n,priceDisabled:a,dueDate:l,onDueDateChange:r}=e,[d,c]=(0,o.useState)(!1);return(0,i.jsxs)("div",{className:"flex gap-4 mb-5",children:[(0,i.jsxs)(ep.Z,{className:"flex-1",children:[(0,i.jsxs)(_.Z,{className:"text-[14px] font-medium text-[#051023]",sx:ek.il,children:["Billing Amount ",(0,i.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,i.jsx)(q.h3,{customInput:y.Z,variant:"outlined",fullWidth:!0,fixedDecimalScale:!1,disabled:a,value:t,onValueChange:e=>s(e.value),error:!!n,helperText:n,thousandSeparator:",",decimalScale:2,allowLeadingZeros:!1,InputProps:{startAdornment:(0,i.jsx)(F.Z,{position:"start",children:"$"}),style:a?{backgroundColor:"#F5F5F5",color:"#9E9E9E"}:{}}})]}),(0,i.jsx)(eq._,{dateAdapter:eU.H,children:(0,i.jsxs)(ep.Z,{className:"flex-1",children:[(0,i.jsx)(_.Z,{className:"text-[14px] font-medium text-[#051023]",sx:ek.il,children:"Due Date"}),(0,i.jsx)(eV.$,{format:"MM/dd/yyyy",open:d,onOpen:()=>c(!0),onClose:()=>c(!1),value:l?new Date(l):null,onChange:e=>r(e||null),slotProps:{textField:{fullWidth:!0,InputProps:{readOnly:!0,style:{cursor:"pointer"},onClick:()=>c(!0)},inputProps:{style:{cursor:"pointer"}}},openPickerButton:{"aria-label":"change date"}}})]})})]})},eH=s(73957),eY=s(62481);let eG=Intl.DateTimeFormat().resolvedOptions().timeZone,e$=(0,o.forwardRef)((e,t)=>{let{expense:s,detailData:n,onClose:a,onRefreshData:l,projectId:r,setWorkOrderOpen:d,setProjectDetailActiveTab:c}=e,{categoryOptions:u}=(0,er.z)(),{userData:x}=R({enabled:!Y().isEmpty(s)}),{data:p}=(0,U.u)("/api/v1/finance/qb/setting/",V._i),m=!!(null==p?void 0:p.eanoExpenseSyncQb)&&!!(null==n?void 0:n.qbSynced),{invoices:h=[]}=n||{},[v,f]=(0,o.useState)(null),[b,j]=(0,o.useState)({description:"",status:eE.qb.Open,totalCost:"",dueDate:null,category:[],attachmentIds:[],fileIds:[],paidDate:null,workerId:null,vendorId:"",vendorName:"",payeeId:"",payeeName:"",items:[]}),[w,k]=(0,o.useState)([]),F=(0,o.useMemo)(()=>parseFloat((null==n?void 0:n.paidOut)||(null==n?void 0:n.totalCost)||"0")||0,[n]),[E,D]=(0,o.useState)(!1),[I,A]=(0,o.useState)(!1),[P,M]=(0,o.useState)(!1),[L,Z]=(0,o.useState)(!1),[T,O]=(0,o.useState)({});(0,o.useEffect)(()=>
1{if(n){let{workerOrderDetail:e,description:t="",status:a=eE.qb.Open,paidOut:l="",dueDate:r,category:i=[],attachments:o=[],expenseFile:d=[],paidDate:c,workerOrderId:u,vendorId:x,vendorName:p,subItems:m=[]}=n;f(e),j({description:t,status:a,totalCost:l,dueDate:r?new Date((0,em.CV)(r,eG,"yyyy/MM/dd")):null,category:i.map(e=>e.id),attachmentIds:o,fileIds:d,paidDate:c,workerId:u,items:m,vendorId:x||"",vendorName:p||(null==s?void 0:s.vendorName)||"",payeeId:n.payeeId||"",payeeName:n.payeeName||""}),k(m.map(e=>({date:e.paidDate,title:e.description||"",vendor:"",cost:Number(e.totalCost)||0,payMethod:e.payMethod}))),(null==m?void 0:m.length)>0&&D(!0)}},[n,null==s?void 0:s.vendorName]);let z=()=>{A(!1),O({}),a()},q=(e,t)=>{j(s=>({...s,[e]:t})),"totalCost"===e&&T.totalCost&&O({})},Q=()=>{let e={};return""===b.totalCost||null===b.totalCost||void 0===b.totalCost?e.totalCost="Billing amount is required":(isNaN(Number(b.totalCost))||0>Number(b.totalCost))&&(e.totalCost="Please enter a valid amount (0 or greater)"),O(e),0===Object.keys(e).length},H=async()=>{if(Q()&&!I){A(!0);try{let{attachmentIds:e,fileIds:t,vendorId:n,vendorName:a,dueDate:i,payeeId:o,payeeName:d,...c}=b,u=await (0,B.r)({url:"/api/v1/finance/expense/",method:"post",params:{...c,dueDate:i?(0,em.WU)(i,"yyyy-MM-dd"):null,attachmentIds:e.map(e=>e.fileId).filter(e=>null!=e),fileIds:t.map(e=>null==e?void 0:e.fileId).filter(e=>null!=e),id:null==s?void 0:s.objId,sourceType:null==s?void 0:s.sourceType,projectId:r,vendorId:n||null,vendorName:a||null,payeeId:o||null,payeeName:d||null,items:w.map(e=>({description:e.title,vendor_name:e.vendor,unit_cost:String(e.cost||0),total_cost:String(e.cost||0),pay_method:parseInt(e.payMethod)||0,paid_date:e.date}))}});u.isOk?(z(),l(),(0,eh.k)("/api/v1/finance/qb/expense/chart"),g.y.success("Change Success")):g.y.error(u.resMessage||"")}catch(e){g.y.error("Failed to save changes")}finally{A(!1)}}},G=async e=>{let t={id:s.objId,sourceType:s.sourceType};e&&(t.eanoOnly=!0);let n=await (0,B.r)({url:"/api/v1/finance/manual/expense/",method:"delete",params:t});n.isOk?(z(),l(),(0,eh.k)("/api/v1/finance/qb/expense/chart"),ev.ZP.success("Delete success")):ev.ZP.error(n.resMessage||"Delete error")};return(0,o.useImperativeHandle)(t,()=>({close:z})),(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(N.Z,{className:"flex items-center justify-between",sx:ek.N0,children:[(0,i.jsxs)(_.Z,{className:"text-[20px] font-semibold text-[#1A1F36]",children:["Edit Expense",(null==n?void 0:n.source)&&(0,i.jsx)(ew,{source:n.source})]}),(0,i.jsx)(C.Z,{sx:ek.l_,onClick:z,size:"small",children:(0,i.jsx)(S.Z,{})})]}),(0,i.jsxs)("div",{className:"space-y-6",children:[(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsx)(eA.Z,{value:b.status,onChange:e=>q("status",e)}),(0,i.jsx)(eZ,{project:{projectId:r||(null==s?void 0:s.projectId)||(null==n?void 0:n.projectId)||"",effectiveProjectId:(null==s?void 0:s.effectiveProjectNo)||(null==n?void 0:n.effectiveProjectNo),disabled:!0,onProjectChange:()=>{},clientInfo:{project_name:(null==s?void 0:s.projectName)||(null==n?void 0:n.projectName),address:(null==s?void 0:s.projectAddress)||(null==n?void 0:n.projectAddress)}}}),!b.workerId&&(0,i.jsx)(eF.Z,{files:b.fileIds,onFilesChange:e=>q("fileIds",e),lineItems:w,onLineItemsChange:e=>{k(e),e.length>0?(q("totalCost",(0,eF.o)(e).toFixed(2)),D(!0)):D(!1)},paidDate:b.paidDate,onPaidDateChange:e=>q("paidDate",e),onOcrVendorNameDetected:e=>j(t=>t.vendorName?t:{...t,vendorName:e}),error:T.file,onErrorChange:e=>O(t=>({...t,file:e})),onLoadingChange:M}),(0,i.jsx)(eM,{description:null==n?void 0:n.scopeDescription,subProjectName:null==n?void 0:n.subProjectName,groupName:null==n?void 0:n.groupName,isGroup:!!(null==n?void 0:n.groupId)}),h.length>0&&(0,i.jsx)("div",{className:"flex flex-col gap-3",children:(0,W.e)(h).map(e=>(0,i.jsx)(eI,{clientInvoice:e},e.invoice_id))}),(0,i.jsx)(eO,{workerData:v,projectId:r,onCreateNew:()=>d(!0),onNavigate:()=>{null==c||c("work_orders"),window.top.postMessage({type:"openWorkOrderDetail",data:{workOrderId:v.id}})},onDisconnect:()=>{f(null),j(e=>({...e,workerId:null}))},onSelectWorkOrder:e=>{let{won_vendor:t}=e;j(s=>({...s,workerId:e.id,vendorId:t?t.id:s.vendorId,vendorName:t?t.name:s.vendorName,payeeId:t?t.id:s.payeeId,payeeName:t?t.name:s.payeeName})),f((0,W.q)(e))}})]}),(0,i.jsx)(eP.Z,{value:b.vendorName,vendorId:b.vendorId,onChange:(e,t)=>
1{j(s=>({...s,vendorName:e,vendorId:t||""}))},disabled:(null==v?void 0:v.status)===eE.Q_.DONE}),(0,i.jsx)(eW,{locked:(null==v?void 0:v.status)===eE.Q_.DONE,payeeId:b.payeeId,payeeName:b.payeeName,userData:x,onChange:(e,t)=>j(s=>({...s,payeeName:e,payeeId:t}))}),(null==n?void 0:n.budgetInfo)&&(0,i.jsx)(eY.Z,{budgeted:n.budgetInfo.budgeted,budgetRemaining:parseFloat(((n.budgetInfo.budgetRemaining||0)+F-(parseFloat(b.totalCost||"0")||0)).toFixed(2)),usedByThisExpense:n.budgetInfo.budgeted>0?parseFloat(((parseFloat(b.totalCost||"0")||0)/n.budgetInfo.budgeted*100).toFixed(2)):void 0}),(0,i.jsx)(eQ,{totalCost:b.totalCost,onTotalCostChange:e=>q("totalCost",e),totalCostError:T.totalCost,priceDisabled:E,dueDate:b.dueDate,onDueDateChange:e=>q("dueDate",e)}),(0,i.jsx)(eH.Z,{value:b.category,onChange:e=>q("category",e),categoryOptions:u}),(0,i.jsxs)(ep.Z,{className:"w-full",sx:ek.QW,children:[(0,i.jsx)(_.Z,{className:"text-[14px] font-medium text-[#051023]",sx:ek.il,children:"Memo"}),(0,i.jsx)(y.Z,{variant:"outlined",fullWidth:!0,multiline:!0,minRows:3,value:b.description,onChange:e=>q("description",e.target.value),placeholder:"Add notes..."})]}),(0,i.jsx)(ey,{expenseObjId:null==s?void 0:s.objId,initialPayments:null==n?void 0:n.payments,onRefreshData:l,onStatusChange:e=>j(t=>({...t,status:e})),onNavigateAway:z}),(0,i.jsx)(eg.Z,{attachments:b.attachmentIds,onUploadingChange:Z,onUploadComplete:e=>{j(t=>({...t,attachmentIds:[...t.attachmentIds,...e]}))},onDeleteAttachment:e=>{j(t=>({...t,attachmentIds:t.attachmentIds.filter((t,s)=>s!==e)}))}}),(0,i.jsx)(e_,{onDelete:G,qbSyncEnabled:m})]}),(0,i.jsx)(N.Z,{className:"sticky -bottom-6 bg-white flex",sx:ek.CF,children:(0,i.jsx)(ek.NH,{variant:"contained",onClick:H,fullWidth:!0,disabled:I||P||L,children:I?"Saving...":"Save changes"})})]})});e$.displayName="ScopeExpenseEditForm";var eK=e=>{let{loading:t,onSubmit:s,submitLabel:n,disabled:a=!1}=e;return(0,i.jsx)(N.Z,{className:"sticky -bottom-6 bg-white flex",sx:ek.CF,children:(0,i.jsx)(ek.NH,{variant:"contained",onClick:s,fullWidth:!0,disabled:t||a,children:t?"Saving...":n})})},eX=s(34226),eJ=s(83369),e0=s(65226),e1=e=>{let{paymentMethod:t}=e;return(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{className:"block text-sm font-medium text-[#051023] mb-2",children:"Payment Method"}),(0,i.jsxs)("div",{className:"flex items-center p-3 border border-[#E1E4EB] rounded-lg bg-[#F7F8FA]",children:[(0,i.jsxs)("svg",{className:"w-6 h-6 mr-2",viewBox:"0 0 24 24",fill:"none",children:[(0,i.jsx)("circle",{cx:"12",cy:"12",r:"10",fill:"#979797"}),(0,i.jsx)("path",{d:"M7 12.1128L10.3744 15.5266L16.0611 9.5",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),(0,i.jsx)("span",{className:"text-[#7C8293]",children:t||"QuickBooks"})]})]})},e2=s(39192),e4=s(36907),e5=e=>{let{hoursWorked:t,unitCost:s,totalCost:n,onUnitCostChange:a}=e;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{className:"block text-sm font-medium text-[#051023] mb-2",children:"Hours Worked"}),(0,i.jsx)("input",{type:"text",value:t||"",className:"w-full px-3 py-2 border border-[#E1E4EB] rounded-lg bg-[#F7F8FA] text-[#7C8293]",disabled:!0})]}),(0,i.jsxs)("div",{children:[(0,i.jsxs)("label",{className:"block text-sm font-medium text-[#051023] mb-2",children:["Unit Cost ",(0,i.jsx)("span",{className:"text-[#E12424]",children:"*"})]}),(0,i.jsxs)("div",{className:"relative",children:[(0,i.jsx)("span",{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-[#051023]",children:"$"}),(0,i.jsx)("span",{className:"absolute right-3 top-1/2 transform -translate-y-1/2 text-[#051023]",children:"/hr"}),(0,i.jsx)(q.h3,{value:s||"",decimalScale:2,allowNegative:!1,onValueChange:e=>{let s=e.floatValue||0,n=0;if(t){let e=String(t);if(e.includes(":")){let[t,s]=e.split(":");n=parseInt(t)+(parseInt(s)||0)/60}else n=parseFloat(e)||0}let l=s*n;a(e.value,l.toFixed(2))},className:"w-full pl-8 pr-12 py-2 border border-[#E1E4EB] rounded-lg focus:outline-none focus:ring-2 focus:ring-[#0052CC]",valueIsNumericString:!0})]})]})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{className:"block text-sm font-medium text-[#051023] mb-2",children:"Total Cost"}),(0,i.jsx)("input",{type:"text",value:"$".concat(n||"0.00"),className:"w-full px-3 py-2 border border-[#
1E1E4EB] rounded-lg bg-[#F7F8FA] text-[#7C8293]",disabled:!0})]})]})};let e3=e=>(parseFloat(e.toString())||0).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2});var e6=e=>{let{paidOutFmt:t,paidOut:s,totalCost:n}=e;return(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{className:"block text-sm font-medium text-[#051023] mb-2",children:"Price"}),(0,i.jsx)("input",{type:"text",value:t||"$".concat(e3(s||n||"0")),className:"w-full px-3 py-2 border border-[#E1E4EB] rounded-lg bg-[#F7F8FA] text-[#7C8293]",disabled:!0})]})};let e8=e=>{let t={id:e.objId,sourceType:e.sourceType,projectId:e.projectId,category:e.categoryList,paidDate:e.paidDate,paymentAccountId:e.paymentMethodId,paymentReference:e.paymentReference||"",paymentMemo:e.paymentMemo||"",description:e.description,status:e.status};return e.payeeId&&(t.payeeId=e.payeeId),e.payeeName&&(t.payeeName=e.payeeName),2===e.sourceType&&(t.vendorId=e.vendorId,t.unitCost=e.unitCost,t.totalCost=e.paidOut,t.scopeId=e.scopeId,t.groupId=e.groupId),1===e.sourceType&&(t.vendorName=e.vendorName),(3===e.sourceType||e.sourceType===ex.wQ)&&(t.fileIds=(e.expenseFile||[]).map(e=>null==e?void 0:e.fileId).filter(e=>null!=e),t.attachmentIds=e.attachmentIds,t.scopeId=e.scopeId,t.groupId=e.groupId,t.workerId=e.workerId,t.isManualOverride=!!e.isManualOverride,e.vendorId&&(t.vendorId=e.vendorId),e.vendorName&&!e.vendorId&&(t.createVendorName=e.vendorName),t.totalCost=e.paidOut,t.dueDate=e.dueDate||null,t.items=(e.subItems||[]).map(e=>({id:e.id,description:e.title||e.description,vendorName:e.vendor||e.vendorName,unitCost:e.cost||e.unitCost||e.totalCost,totalCost:e.cost||e.totalCost||e.unitCost,payMethod:parseInt(e.payMethod)||0,paidDate:e.date||e.paidDate||null}))),t};var e7=e=>{var t,s,n,a,l;let{expense:r,detailData:c,onClose:u,onRefreshData:x,projectList:p,currentProjectId:h}=e,{categoryOptions:f}=(0,er.z)(),{financeSettings:b}=(0,d.pL)(),[j,y]=(0,o.useState)({}),[w,N]=(0,o.useState)(!1),[C,k]=(0,o.useState)([]),[_,F]=(0,o.useState)([]),[E,S]=(0,o.useState)([]),[D,I]=(0,o.useState)(!1),[A,P]=(0,o.useState)(!1),[M,L]=(0,o.useState)({}),[Z,T]=(0,o.useState)(null),[O,R]=(0,o.useState)(!1),[z,q]=(0,o.useState)(null),Q=(0,o.useMemo)(()=>({...r,...c}),[r,c]),H=(0,o.useMemo)(()=>{var e;return parseFloat(Q.paidOut||Q.totalCost||(null===(e=Q.paidOutFmt)||void 0===e?void 0:e.replace(/[^0-9.-]/g,""))||"0")||0},[Q]),{invoices:Y=[]}=Q,G=3===Q.sourceType||Q.sourceType===ex.wQ,{data:$}=(0,U.u)("/api/v1/finance/qb/setting/",V._i),K=!!(null==$?void 0:$.eanoExpenseSyncQb)&&!!(null==Q?void 0:Q.qbSynced),X=2===Q.sourceType,J=1===Q.sourceType,ee=(0,ex.AW)(j.projectId),et=G&&!!Q.objId,es=0>Number(null!==(n=null!==(s=j.paidOut)&&void 0!==s?s:j.totalCost)&&void 0!==n?n:0),en=(null!==(a=null==b?void 0:b.expense_require)&&void 0!==a&&a||es)&&G,ea=parseFloat(j.paidOut||j.totalCost||"0")||0,el=null!==(l=null==Z?void 0:Z.price)&&void 0!==l?l:null==Z?void 0:Z.retailFinalPrice,ei=O?Z&&void 0!==el?{budgeted:el,budgetRemaining:void 0!==Z.residualPrice?parseFloat((Z.residualPrice-ea).toFixed(2)):void 0,usedByThisExpense:el>0&&ea>0?parseFloat((ea/el*100).toFixed(2)):void 0,committed:null}:null:Q.budgetInfo?{budgeted:Q.budgetInfo.budgeted,budgetRemaining:parseFloat(((Q.budgetInfo.budgetRemaining||0)+H-ea).toFixed(2)),usedByThisExpense:Q.budgetInfo.budgeted>0&&ea>0?parseFloat((ea/Q.budgetInfo.budgeted*100).toFixed(2)):void 0,committed:Q.budgetInfo.committed}:null;(0,o.useEffect)(()=>{es&&(Z||j.workerId)&&(T(null),q(null),y(e=>({...e,workerId:null})))},[es]),(0,o.useEffect)(()=>{var e,t,s;let n=Q.paidOut||Q.totalCost||(null===(e=Q.paidOutFmt)||void 0===e?void 0:e.replace(/[^0-9.-]/g,""))||"0";y({...Q,workerId:Q.workerOrderId,projectId:(0,ex.jx)(Q.sourceType)?ex.Cx:Q.projectId,categoryList:(null===(t=Q.category)||void 0===t?void 0:t.map(e=>e.id))||[],paymentMethodId:String((null===(s=Q.paymentAccount)||void 0===s?void 0:s.id)||Q.paymentMethodId||Q.paymentMethod||"0"),paymentReference:(0,eb.AW)(Q),paymentMemo:Q.paymentMemo||"",paidOut:n,totalCost:n,attachmentIds:Q.attachments||[]}),k(Q.subItems||[]),F(Q.subItems||[]),S(Q.expenseFile||[]),Q.scopeId?T({id:Q.scopeId,name:Q.scopeDescription||"",subProjectName:Q.subProjectName||"",groupName:Q.groupName||"",isGroup:!!Q.groupId}
1):T(null),R(!1),q(Q.workerOrderId?Q.workerOrderDetail:null)},[Q]),(0,o.useEffect)(()=>{if(C.length>0&&!j.isManualOverride){let e=C.reduce((e,t)=>e+parseFloat(t.cost||t.totalCost||0),0).toFixed(2);y(t=>({...t,paidOut:e,totalCost:e}))}},[C,j.isManualOverride]);let eo=async e=>{let t=await v.o.createExpense(e8(e));return t.isOk?(x&&await x(),g.y.success("Expense updated successfully"),!0):(g.y.error(t.resMessage||""),!1)},ed=async e=>{let t={id:r.objId,sourceType:r.sourceType};e&&(t.eanoOnly=!0);let s=await (0,B.r)({url:"/api/v1/finance/manual/expense/",method:"delete",params:t});s.isOk?(x&&await x(),u(),(0,eh.k)("/api/v1/finance/qb/expense/chart"),j.projectId&&(0,eh.k)((0,eJ.t)(j.projectId)),ev.ZP.success("Delete success")):ev.ZP.error(s.resMessage||"Delete error")},ec=async()=>{var e,t,s,n,a,l,r,i;if(!X&&!h&&!j.projectId){L(e=>({...e,projectId:"Project is required"})),g.y.error(J?"A project is required for QuickBooks-sourced expenses":"Project is required");return}if(G&&0>Number(null!==(n=null!==(s=null!==(t=Q.paidOut)&&void 0!==t?t:Q.totalCost)&&void 0!==s?s:null===(e=Q.paidOutFmt)||void 0===e?void 0:e.replace(/[^0-9.-]/g,""))&&void 0!==n?n:0)!=0>Number(null!==(l=null!==(a=j.paidOut)&&void 0!==a?a:j.totalCost)&&void 0!==l?l:0)){g.y.error("An expense's sign can't be changed. Delete it and add a new one instead.",2500);return}if(en&&!j.vendorName){L(e=>({...e,vendorName:"Vendor name is required"})),g.y.error("Vendor name is required");return}N(!0);try{if(!await eo({...j,subItems:C,projectId:(0,ex.AW)(j.projectId)?null:j.projectId,expenseFile:E,attachmentIds:(j.attachmentIds||[]).map(e=>e.fileId).filter(e=>null!=e),scopeId:(null==Z?void 0:Z.isGroup)?null:null!==(r=null==Z?void 0:Z.id)&&void 0!==r?r:null,groupId:(null==Z?void 0:Z.isGroup)&&null!==(i=null==Z?void 0:Z.id)&&void 0!==i?i:null,workerId:j.workerId}))return;(0,eh.k)("/api/v1/finance/qb/expense/chart"),j.projectId&&(0,eh.k)((0,eJ.t)(j.projectId)),u()}catch(e){console.error("Failed to update expense:",e)}finally{N(!1)}};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:"flex items-center mb-6",children:[(0,i.jsx)("h2",{className:"text-2xl font-medium text-[#051023]",children:"Edit Expenses"}),(0,i.jsx)(ew,{source:Q.source})]}),(0,i.jsxs)("div",{className:"space-y-6",children:[(0,i.jsx)(eA.Z,{value:j.status,onChange:e=>y({...j,status:e}),disabled:J||es}),(0,i.jsx)(eZ,{project:{projectId:j.sourceType===ex.wQ?ex.Cx:j.projectId||"",effectiveProjectId:null==c?void 0:c.effectiveProjectNo,disabled:X||!!h,includeOpex:!h&&G,error:M.projectId,onProjectChange:e=>{let t=String(e)!==String(j.projectId);y({...j,projectId:e,...(0,ex.AW)(e)||t?{workerId:null}:{},sourceType:(0,ex.AW)(e)?ex.wQ:j.sourceType||3}),M.projectId&&L(e=>({...e,projectId:""})),((0,ex.AW)(e)||t)&&(T(null),R(!0),q(null))},clientInfo:{project_name:Q.projectName,address:Q.projectAddress||(null==p?void 0:null===(t=p.find(e=>String(e.id)===String(j.projectId)))||void 0===t?void 0:t.address)}}}),G&&!es&&(0,i.jsx)(eF.Z,{files:E,onFilesChange:S,lineItems:C,onLineItemsChange:k,originalLineItems:_,paidDate:j.paidDate,onPaidDateChange:e=>y(t=>({...t,paidDate:e})),onOcrVendorNameDetected:e=>y(t=>t.vendorName?t:{...t,vendorName:e}),error:M.file,onErrorChange:e=>L(t=>({...t,file:null!=e?e:""})),onLoadingChange:I}),Y.length>0&&(0,i.jsx)("div",{className:"flex flex-col gap-3",children:(0,W.e)(Y).map(e=>(0,i.jsx)(eI,{clientInvoice:e},e.invoice_id))}),(G||X)&&!ee&&!es&&(0,i.jsx)(e0.Z,{projectId:j.projectId,scopeData:Z,workerData:G?z:null,hideWorkOrder:!G,onScopeChange:e=>{T(e),R(!0)},onWorkerChange:(e,t,s)=>{q(e),y(e=>({...e,workerId:t,vendorId:(null==s?void 0:s.id)||e.vendorId,vendorName:(null==s?void 0:s.name)||e.vendorName}))}}),(0,i.jsx)(eP.Z,{value:j.vendorName||"",vendorId:j.vendorId,onChange:(e,t)=>
1{y({...j,vendorName:e,vendorId:t}),M.vendorName&&L(e=>({...e,vendorName:""}))},disabled:!G,required:en,error:M.vendorName}),(0,i.jsx)(ez.Z,{value:j.payeeName||"",payeeId:j.payeeId,onChange:(e,t)=>y({...j,payeeName:e,payeeId:t}),disabled:!G}),(G||X)&&(0,i.jsxs)(i.Fragment,{children:[ei&&(0,i.jsx)(eY.Z,{budgeted:ei.budgeted,budgetRemaining:ei.budgetRemaining,usedByThisExpense:ei.usedByThisExpense}),G?(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{className:"flex gap-4",children:[(0,i.jsx)("div",{className:"flex-1",children:(0,i.jsx)(e2.Z,{value:j.paidOut||j.totalCost||"",onChange:(e,t)=>{y(s=>({...s,paidOut:e,totalCost:e,isManualOverride:"event"===t&&E.length>0&&C.length>0||s.isManualOverride}))}})}),(0,i.jsx)("div",{className:"flex-1",children:(0,i.jsx)(e4.Z,{value:j.dueDate||"",onChange:e=>y({...j,dueDate:e})})})]}),ei?(0,i.jsxs)("p",{className:"text-xs text-[#7C8293]",children:[ei.budgeted>0?(0,i.jsxs)("span",{className:"text-[#35AB3B]",children:[(ea/ei.budgeted*100).toFixed(2),"%"]}):"—"," ","of Budget"]}):null,(null==ei?void 0:ei.committed)!=null&&ei.committed>0?(0,i.jsxs)("p",{className:"text-xs text-[#7C8293]",children:[(0,i.jsxs)("span",{className:"text-[#35AB3B]",children:[(ea/ei.committed*100).toFixed(2),"%"]})," ","of Committed"]}):null]}):null]}),(0,i.jsx)(eH.Z,{categoryOptions:f,value:j.categoryList,onChange:e=>y({...j,categoryList:e})}),(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{className:"flex justify-between items-center mb-2",children:[(0,i.jsx)("label",{className:"block text-sm font-medium text-[#051023]",children:"Memo"}),(0,i.jsx)("span",{className:"text-[#7C8293] text-sm",children:"Optional"})]}),(0,i.jsx)("textarea",{value:j.description||"",onChange:e=>y({...j,description:e.target.value}),className:"w-full px-3 py-2 border border-[#E1E4EB] rounded-lg focus:outline-none focus:ring-2 focus:ring-[#0052CC]",rows:4})]}),!et&&(0,i.jsxs)("div",{children:[(0,i.jsxs)("label",{className:"block text-sm font-medium text-[#051023] mb-2",children:["Payment Date ",(0,i.jsx)("span",{className:"text-[#E12424]",children:"*"}),X&&(0,i.jsx)("span",{className:"ml-2 text-[#7C8293] text-xs",children:"ℹ Expenses generated from clock-ins will default the payment time to the clock-out time."})]}),(0,i.jsx)(eq._,{dateAdapter:eU.H,children:(0,i.jsx)(eV.$,{value:j.paidDate?(0,em.ZU)(j.paidDate,{timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone}):null,onChange:e=>{if(e){let t=Intl.DateTimeFormat().resolvedOptions().timeZone,s=(0,em.CV)(e,t,"yyyy-MM-dd");y({...j,paidDate:s})}else y({...j,paidDate:""})},format:"MM/dd/yyyy",maxDate:new Date,disabled:J,slotProps:{textField:{variant:"standard",fullWidth:!0,InputProps:{className:(0,m.cn)("w-full",J&&"bg-[#F7F8FA]"),style:{borderRadius:"8px",border:"1px solid #E1E4EB",padding:"8px 12px",fontSize:"14px"},disableUnderline:!0},inputProps:{className:(0,m.cn)("focus:outline-none",J&&"text-[#7C8293] cursor-not-allowed"),placeholder:"MM/DD/YYYY"}}}})})]}),!et&&(J?(0,i.jsx)(e1,{paymentMethod:j.paymentMethod}):(0,i.jsx)(eX.Z,{value:j.paymentMethodId,onChange:e=>y({...j,paymentMethodId:e}),reference:j.paymentReference,onReferenceChange:e=>y({...j,paymentReference:e}),paymentMemo:j.paymentMemo,onPaymentMemoChange:e=>y({...j,paymentMemo:e}),onNavigateAway:u})),X&&(0,i.jsx)(e5,{hoursWorked:j.hoursWorked,unitCost:j.unitCost,totalCost:j.paidOut||j.totalCost,onUnitCostChange:(e,t)=>
1y({...j,unitCost:e,paidOut:t,totalCost:t})}),J&&(0,i.jsx)(e6,{paidOutFmt:j.paidOutFmt,paidOut:j.paidOut,totalCost:j.totalCost}),et&&(0,i.jsx)(ey,{expenseObjId:Q.objId,initialPayments:null==c?void 0:c.payments,onRefreshData:x,onStatusChange:e=>y({...j,status:e}),onNavigateAway:u,readOnly:es}),G&&(0,i.jsx)(eg.Z,{attachments:j.attachmentIds||[],onUploadingChange:P,onUploadComplete:e=>y(t=>({...t,attachmentIds:[...t.attachmentIds,...e]})),onDeleteAttachment:e=>y(t=>({...t,attachmentIds:t.attachmentIds.filter((t,s)=>s!==e)}))}),G&&!!Q.objId&&(0,i.jsx)(e_,{onDelete:ed,qbSyncEnabled:K})]}),(0,i.jsx)(eK,{loading:w,disabled:D||A,onSubmit:ec,submitLabel:Q.objId?"Update Expense":"Save Changes"})]})},e9=s(17223),te=s(68193),tt=e=>{let{projectId:t,effectiveProjectId:s,projectName:n,projectAddress:a,onNavigate:l}=e,r=(0,e9.useRouter)(),o="".concat(n?"".concat(n," - "):"").concat(a||"Project address missing","(#").concat(s||t,")");return(0,i.jsxs)("button",{type:"button",className:"mb-3 flex w-fit items-center gap-0.5 text-left text-14 text-en-blue hover:underline",onClick:()=>{l(),r.push("/project/".concat(t))},children:[o,(0,i.jsx)(te.Z,{className:"h-4 w-4 shrink-0"})]})},ts=e=>{let{open:t,onClose:s,itemExpense:n,onRefreshData:a,projectList:l,currentProjectId:r,projectId:d,setWorkOrderOpen:c,setProjectDetailActiveTab:u}=e,x=(0,o.useRef)(null),p=(0,o.useMemo)(()=>(0,W.q)(n||{}),[n]),m=(null==p?void 0:p.sourceType)===4,h=()=>{var e;return m?null===(e=x.current)||void 0===e?void 0:e.close():s()},{detailData:v,isLoading:g,mutate:f}=Q({enabled:t&&!!(null==p?void 0:p.objId),objId:null==p?void 0:p.objId,sourceType:null==p?void 0:p.sourceType});return(0,o.useEffect)(()=>{t&&(null==p?void 0:p.objId)&&f()},[t,null==p?void 0:p.objId,f]),(0,i.jsx)(ed.ZP,{className:"w-[640px] shrink-0",anchor:"right",open:t,onClose:h,classes:{paper:"w-[640px] p-6 overflow-y-auto"},children:(0,i.jsx)("div",{children:(0,i.jsx)(ec.wT,{maxSnack:3,autoHideDuration:2500,anchorOrigin:{vertical:"bottom",horizontal:"center"},children:g||!v?(0,i.jsx)(eu.Z,{}):(0,i.jsxs)(i.Fragment,{children:[!r&&!!v.projectId&&!(0,ex.AW)(v.projectId)&&(0,i.jsx)(tt,{projectId:v.projectId,effectiveProjectId:v.effectiveProjectNo,projectName:v.projectName,projectAddress:v.projectAddress,onNavigate:h}),m?(0,i.jsx)(e$,{ref:x,expense:p,detailData:v,onClose:s,onRefreshData:a,projectId:d,setWorkOrderOpen:c,setProjectDetailActiveTab:u}):(0,i.jsx)(e7,{expense:p,detailData:v,onClose:s,onRefreshData:a,projectList:l,currentProjectId:r})]})})})})},tn=s(58160),ta=s(11219),tl=s(93542),tr=s(35852),ti=s(97438),to=s(32095),td=s(63611),tc=s(80273),tu=s(32306),tx=s(57383),tp=s(20529),tm=s(61498),th=s(61793),tv=s(59302),tg=s(27403);let tf=e=>e?e.trim().substring(0,1).toUpperCase():"?";var tb=e=>{let{value:t=[],onChange:s,label:n="Vendor",className:a="",disabled:l=!1}=e,[r,d]=(0,o.useState)(!1),[c,u]=(0,o.useState)(""),x=(0,o.useRef)(null),{data:p,isLoading:m}=(0,U.u)("/api/v1/finance/qb/expense/vendors",()=>v.o.getExpenseVendors(),{revalidateOnFocus:!1}),[h,g]=(0,o.useState)(new Map);(0,o.useEffect)(()=>{p&&g(e=>{let s=new Map(e);return p.forEach(e=>{let n=String(e.user_id);t.includes(n)&&s.set(n,e)}),s})},[p,t]),(0,o.useEffect)(()=>{0===t.length&&h.size>0&&g(new Map)},[t,h.size]),(0,o.useEffect)(()=>{r||u("")},[r]);let f=(0,o.useMemo)(()=>{let e=null!=p?p:[],t=c.trim().toLowerCase();return t?e.filter(e=>{var s;return null===(s=e.name)||void 0===s?void 0:s.toLowerCase().includes(t)}):e},[p,c]),b=(0,o.useMemo)(()=>{let e=new Set(f.map(e=>String(e.user_id))),s=[];return t.forEach(t=>{if(!e.has(t)){let e=h.get(t);e&&s.push(e)}}),[...s,...f]},[f,t,h]),j=e=>{if(l)return;let n=String(e.user_id);t.includes(n)?(s(t.filter(e=>e!==n)),g(e=>{let t=new Map(e);return t.delete(n),t})):(s([...t,n]),g(t=>{let s=new Map(t);return s.set(n,e),s}))},y=e=>{e.stopPropagation(),l||(s([]),g(new Map))};return(0,i.jsx)(tv.d,{onClickAway:()=>d(!1),children:(0,i.jsxs)("div",{className:"relative ".concat(a," h-11 w-[180px]"),children:[(0,i.jsx)("div",{className:"relative h-full w-full",children:(0,i.jsxs)("button",{onClick:()=>!l&&d(!r),disabled:l,className:"group h-full w-full flex items-center justify-between pl-3 pr-2 py-1.5 border border-[#
1E1E4EB] rounded-full bg-white transition-all ".concat(l?"opacity-50 cursor-not-allowed":"hover:border-[#0052CC] focus:outline-none focus:ring-2 focus:ring-[#0052CC] focus:ring-opacity-20 cursor-pointer"," ").concat(t.length>0?"border-[#0052CC] bg-[#E9F1FD]":""),children:[(0,i.jsxs)("div",{className:"flex items-center",children:[(0,i.jsx)("span",{className:"text-14 font-medium ".concat(t.length>0?"text-[#0052CC]":"text-[#979797]"),children:n}),(0,i.jsx)("span",{className:"flex items-center justify-center min-w-[20px] h-5 px-1.5 ml-1.5 text-12 font-semibold text-white bg-[#0052CC] rounded-full transition-opacity ".concat(t.length>0?"opacity-100":"opacity-0"),children:t.length||0})]}),(0,i.jsxs)("div",{className:"flex items-center ml-1",children:[(0,i.jsx)("span",{role:"button",onClick:y,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),e.stopPropagation(),y(e))},className:"p-0.5 rounded hover:bg-[#D4E4FA] transition-opacity mr-0.5 ".concat(t.length>0&&!l?"opacity-100":"opacity-0 pointer-events-none"),title:"Clear filter",tabIndex:t.length>0&&!l?0:-1,children:(0,i.jsx)(tm.Z,{className:"w-3.5 h-3.5 text-[#0052CC]"})}),(0,i.jsx)(th.Z,{className:"w-4 h-4 transition-transform ".concat(t.length>0?"text-[#0052CC]":"text-[#7C8293]"," ").concat(r?"rotate-180":"")})]})]})}),r&&(0,i.jsxs)("div",{className:"absolute z-50 mt-2 bg-white rounded-lg shadow-lg border border-[#E1E4EB] py-2 min-w-[280px]",style:{boxShadow:"0 4px 12px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04)"},children:[(0,i.jsx)("div",{className:"px-3 pb-2",children:(0,i.jsx)("input",{type:"text",placeholder:"Search...",value:c,onChange:e=>u(e.target.value),className:"w-full px-3 py-2 text-14 border border-[#E1E4EB] rounded-lg focus:outline-none focus:border-[#0052CC] focus:ring-1 focus:ring-[#0052CC]"})}),(0,i.jsx)("div",{ref:x,className:"max-h-[320px] overflow-y-auto",children:m?(0,i.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,i.jsx)(tg.Z,{size:24})}):0===b.length?(0,i.jsx)("div",{className:"px-4 py-8 text-center text-sm text-[#7C8293]",children:"No vendors found"}):b.map(e=>{let s=String(e.user_id),n=t.includes(s),a=tf(e.name);return(0,i.jsxs)("div",{className:"px-3 py-2 hover:bg-[#F7F8FA] cursor-pointer flex items-center space-x-3 ".concat(n?"bg-[#F0F5FF]":""),onClick:()=>j(e),children:[(0,i.jsx)("div",{className:"flex-shrink-0 w-5 h-5 border-2 rounded flex items-center justify-center transition-colors ".concat(n?"bg-[#0052CC] border-[#0052CC]":"border-[#D1D5DB] bg-white"),children:n&&(0,i.jsx)("svg",{className:"w-3 h-3 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:3,d:"M5 13l4 4L19 7"})})}),e.avatar_url&&e.avatar_url.trim()?(0,i.jsx)("img",{src:e.avatar_url,alt:e.name,className:"flex-shrink-0 w-9 h-9 rounded-full object-cover"}):(0,i.jsx)("div",{className:"flex-shrink-0 w-9 h-9 rounded-full flex items-center justify-center",style:{backgroundColor:"#3B4658"},children:(0,i.jsx)("span",{className:"text-white text-sm font-medium",children:a})}),(0,i.jsx)("div",{className:"flex-1 min-w-0",children:(0,i.jsx)("div",{className:"text-14 font-medium text-[#051023] truncate",children:e.name})})]},s)})})]})]})})},tj=s(80739);let ty=[{mode:"table",label:"Table",icon:(0,i.jsxs)("svg",{width:"15",height:"12",viewBox:"0 0 15 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,i.jsx)("path",{d:"M1 1H14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"square",strokeLinejoin:"round"}),(0,i.jsx)("path",{d:"M1 6H14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"square",strokeLinejoin:"round"}),(0,i.jsx)("path",{d:"M1 11H14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"square",strokeLinejoin:"round"})]})},{mode:"scope",label:"Scope",icon:(0,i.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,i.jsx)("path",{d:"M15.4167 3.33301H4.58333C4.1231 3.33301 3.75 3.7061 3.75 4.16634V17.4997C3.75 17.9599 4.1231 18.333 4.58333 18.333H15.4167C15.8769 18.333 16.25 17.9599 16.25 17.4997V4.16634C16.25 3.7061 15.8769 3.33301 15.4167 3.33301Z",fill:"currentColor",stroke:"currentColor",strokeWidth:"1.66667",strokeLinejoin:"round"}),(0,i.jsx)("path",{d:"M7.5 1.66699V4.16699",stroke:"currentColor",strokeWidth:"1.66667",strokeLinecap:"round",strokeLinejoin:"round"}),(0,i.jsx)("path",{d:"M12.5 1.66699V4.16699",stroke:"currentColor",strokeWidth:"1.66667",strokeLinecap:"round",strokeLinejoin:"round"}),(0,i.jsx)("path",{d:"M6.66699 7.91699H13.3337",stroke:"#fff",strokeWidth:"1.66667",strokeLinecap:"round",strokeLinejoin:"round"}),(0,i.jsx)("path",{d:"M6.66699 11.25H11.667",stroke:"#fff",strokeWidth:"1.66667",strokeLinecap:"round",strokeLinejoin:"round"}),(0,i.jsx)("path",{d:"M6.66699 14.583H10.0003",stroke:"#fff",strokeWidth:"1.66667",strokeLinecap:"round",strokeLinejoin:"round"})]})},{mode:"vendor",label:"Vendor",icon:(0,i.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,i.jsx)("path",{d:"M1.66699 17.5H18.3337",stroke:"currentColor",strokeWidth:"1.66667",strokeLinecap:"round",strokeLinejoin:"round"}
1),(0,i.jsx)("path",{d:"M5.83301 11.667H3.33301V17.5003H5.83301V11.667Z",fill:"currentColor",stroke:"currentColor",strokeWidth:"1.66667",strokeLinejoin:"round"}),(0,i.jsx)("path",{d:"M11.25 7.5H8.75V17.5H11.25V7.5Z",fill:"currentColor",stroke:"currentColor",strokeWidth:"1.66667",strokeLinejoin:"round"}),(0,i.jsx)("path",{d:"M16.667 2.5H14.167V17.5H16.667V2.5Z",fill:"currentColor",stroke:"currentColor",strokeWidth:"1.66667",strokeLinejoin:"round"})]})}];var tw=e=>{let{mode:t,onChange:s,showScopeOption:n,disabled:a}=e;return(0,i.jsx)("div",{className:"inline-flex rounded-lg border border-[#EBECF0]",children:ty.filter(e=>"scope"!==e.mode||n).map(e=>(0,i.jsxs)("button",{onClick:()=>s(e.mode),disabled:a,className:"px-3 py-2 text-sm font-medium transition-colors flex items-center gap-1.5 ".concat(t===e.mode?"bg-[#CFDFF6] text-en-blue":"text-en-mid-blue hover:text-[#051023] hover:bg-[#F7F8FA]"),children:[e.icon,e.label]},e.mode))})},tN=e=>{let{filterRef:t,isFilterSticky:s,isEnterprisePlan:n,localFilters:a,handleFilterChange:l,dateRangeOptions:r,sourceOptions:d,categoryOptions:c,currentProjectId:u,tableLoading:x,clearFilters:p,saveFilters:m,filters:h,mutateSavedFilters:v,isLoading:g,activeFilterId:f,setActiveFilterId:b,activeFilter:j,notAssignedProjectCount:y,hasQuickBooksConnection:w,canEditExpense:N,selectedExpensesCount:C,onBulkAssignClick:k,isOwner:_,isAdmin:F,onSyncClick:E,onDisconnectClick:S,viewMode:D,onViewModeChange:I,showExpenseId:A}=e,[P,B]=(0,o.useState)(a.search||""),M=()=>{P!==(a.search||"")&&l("search",P)};return(0,i.jsx)("div",{ref:t,className:"bg-white pb-4 border-b border-gray-200 mb-4 sticky top-0 z-40",style:s?{paddingTop:"16px",boxShadow:"0 2px 4px rgba(0,0,0,0.1)"}:{},children:(0,i.jsxs)("div",{className:"flex justify-between items-start gap-4",children:[(0,i.jsxs)("div",{className:"space-y-3",children:[n&&(0,i.jsx)(tp.Z,{onApplyFilter:e=>{Y().isEmpty(e)?p():m(e)},searchType:u?ti.S.TYPE_PROJECT_FINANCE_EXPENSE:ti.S.TYPE_FINANCE_EXPENSE,filters:h,mutate:v,isLoading:g,activeFilterId:f,setActiveFilterId:b,activeFilter:j}),(0,i.jsxs)("div",{className:"flex gap-3 items-center flex-wrap gap-y-3 flex-1 min-w-0",children:[(0,i.jsx)(tu.Z,{value:a.dateRangeFilter,onChange:e=>l("dateRangeFilter",e),options:r,className:"w-[150px]",disabled:x,placeholder:"All"}),(0,i.jsx)(tu.Z,{value:a.sourceFilter,onChange:e=>l("sourceFilter",e),options:[{value:"",label:"All Sources"},...d.map(e=>({value:e.id,label:e.name}))],renderValue:e=>{if(""===e||!e)return"All Sources";let t=d.find(t=>t.id===e||t.id===String(e));return(null==t?void 0:t.name)||(0===d.length?"Loading...":"All Sources")},className:"w-[160px]",disabled:x,placeholder:"All Sources"}),(0,i.jsx)(tu.Z,{value:a.categoryFilter,onChange:e=>l("categoryFilter",e),options:[{value:"",label:"All Categories"},...(c||[]).map(e=>({value:e.id,label:e.name}))],renderValue:e=>{if(""===e||!e)return"All Categories";let t=c.find(t=>t.id===e||t.id===String(e));return(null==t?void 0:t.name)||(0===c.length?"Loading...":"All Categories")},className:"w-[180px]",disabled:x,placeholder:"All Categories"}),!u&&(0,i.jsx)(tx.default,{value:a.tagsFilter||[],onChange:e=>l("tagsFilter",e),disabled:x,height:"44px"}),(0,i.jsx)(tb,{value:a.vendorUserIds||[],onChange:e=>l("vendorUserIds",e),label:"Vendor/Subs"}),(0,i.jsx)(tu.Z,{value:a.statusFilter||"",onChange:e=>l("statusFilter",e),options:[{value:"",label:"All Status"},{value:"2",label:"Open"},{value:"1",label:"Paid"}],className:"w-[180px]",disabled:x,placeholder:"All Status"}),A&&(0,i.jsx)("input",{type:"text",value:P,onChange:e=>B(e.target.value),onBlur:M,onKeyDown:e=>{"Enter"===e.key&&M()},disabled:x,placeholder:"Search by ID or description",className:"w-[220px] h-[44px] px-3 rounded-md border border-[#D1D5DB] text-14 text-[#181B24] placeholder:text-[#7C8293] focus:outline-none focus:ring-1 focus:ring-[#0052CC] disabled:opacity-50"}),n&&(0,i.jsx)(ti.Z,{showEdit:!!(0!==a.dateRangeFilter||a.sourceFilter||a.categoryFilter||""!==a.statusFilter||!Y().isEmpty(a.tagsFilter)||!Y().isEmpty(a.vendorUserIds)),reset:p,projectId:u,setActiveFilterId:b,currentFilters:{dateRangeFilter:a.dateRangeFilter,sourceFilter:a.sourceFilter,categoryFilter:a.c
1ategoryFilter,tagsFilter:a.tagsFilter,vendorUserIds:a.vendorUserIds,statusFilter:a.statusFilter},activeFilter:j,searchType:u?ti.S.TYPE_PROJECT_FINANCE_EXPENSE:ti.S.TYPE_FINANCE_EXPENSE})]}),w&&(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsxs)("label",{className:"relative inline-flex items-center ".concat(x?"cursor-not-allowed opacity-50":"cursor-pointer"),children:[(0,i.jsx)("input",{type:"checkbox",checked:a.showExpensesToClassify,disabled:x,onChange:e=>l("showExpensesToClassify",e.target.checked),className:"sr-only peer"}),(0,i.jsx)("div",{className:"w-11 h-6 bg-[#E1E4EB] rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-[#0052CC]"})]}),(0,i.jsxs)("span",{className:"text-sm text-[#3B4658] font-normal",children:["Show Expenses to Classify (",y,")"]})]}),x&&(0,i.jsxs)("div",{className:"flex items-center gap-2 ml-2",children:[(0,i.jsx)("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-[#0052CC]"}),(0,i.jsx)("span",{className:"text-sm text-gray-600",children:"Loading..."})]})]}),(0,i.jsxs)("div",{className:"flex items-center gap-4 flex-shrink-0",children:[N&&C>0&&(0,i.jsx)("button",{onClick:k,className:"px-4 py-2.5 text-sm text-[#0052CC] bg-[#F0F7FB] border border-[#0052CC] rounded-lg hover:bg-[#E6F4FF]",children:"Bulk Assign Projects"}),w&&!u&&(_||F)&&(0,i.jsx)(tj.O,{onSettingClick:E,onDisconnectClick:S}),(0,i.jsx)(tw,{mode:D||"table",onChange:e=>null==I?void 0:I(e),showScopeOption:!!u,disabled:x})]})]})})},tC=s(48519),tk=e=>{let{isFilterSticky:t,filterHeight:s,tableLoading:n,headerScrollRef:a,localFilters:l,selectedExpensesCount:r,expensesListCount:o,onSelectAll:d,canEditExpense:c,sortConfig:u,onSort:x,isProOrAbove:p,currentProjectId:h,isShowContracted:v,showExpenseId:g,isScrolledToEnd:f}=e;return(0,i.jsx)("div",{className:"sticky z-20",style:{top:t?"".concat(s,"px"):"0px"},children:(0,i.jsx)("div",{className:(0,m.cn)("bg-white rounded-t-xl overflow-hidden",n&&"opacity-50"),children:(0,i.jsx)("div",{ref:a,className:"overflow-x-auto overflow-y-hidden scrollbar-hide pl-scroll-layer",children:(0,i.jsx)("table",{className:"w-full min-w-[1450px] table-fixed",children:(0,i.jsx)("thead",{className:"bg-[#F7F8FA]",children:(0,i.jsxs)("tr",{className:"border-b border-[#EBECF0]",children:[l.showExpensesToClassify&&(0,i.jsx)("th",{className:"w-12 px-4 bg-[#F7F8FA] text-left",children:(0,i.jsx)("input",{type:"checkbox",checked:r===o&&o>0,onChange:e=>d(e.target.checked),disabled:!c,className:"rounded border-[#D1D5DB] text-[#0052CC] focus:ring-[#0052CC] disabled:opacity-50 disabled:cursor-not-allowed"})}),g&&(0,i.jsx)("th",{className:"px-4 py-4 text-left text-14 font-medium text-[#7C8293] w-[90px] bg-[#F3F3F3]",children:"ID"}),(0,i.jsx)(tC.U,{field:"description",label:"Description",sortConfig:u,onSort:x,width:"w-[250px]"}),(0,i.jsx)(tC.U,{field:"vendor_name",label:(0,i.jsx)(P.Z,{arrow:!0,placement:"top",title:"The business listed on the receipt (e.g., Home Depot, gas station). When syncing from QuickBooks, the Payee maps here.).",children:(0,i.jsx)("span",{className:"border-b border-dashed border-[#7C8293] cursor-help",children:"Vendor"})}),sortConfig:u,onSort:x,width:"w-[160px]"}),(0,i.jsx)(tC.U,{field:"payee_name",label:(0,i.jsx)(P.Z,{arrow:!0,placement:"top",title:"The person who paid this expense. If Worker A uploads the receipt, this field defaults to Worker A and cannot be edited by them. Admins can reassign the expense owner (e.g., to track subcontractor expenses and handle reimbursement).",children:(0,i.jsx)("span",{className:"border-b border-dashed border-[#7C8293] cursor-help",children:"Expense Owner"})}),sortConfig:u,onSort:x,width:"w-[160px]"}),(0,i.jsx)(tC.U,{field:"paid_out",label:(0,i.jsx)(P.Z,{arrow:!0,placement:"top",title:"The estimated cost based on the linked scope items or the amount entered for this expense.",children:(0,i.jsx)("span",{className:"border-b border-dashed border-[#7C8293] cursor-help",children:"Projected Exp"})}),sortConfig:u,onSort:x,width:"w-[120px]"}),(0,i.jsx)(tC.U,{field:"won_price",label:(0,i.jsx)(P.Z,{arrow:!0,placement:"top",title:"The agreed contract amount, shown when this expense is linked to a work order.",children:(0,i.jsx)("span",{className:"border-b border-dashed border-[#7C8293] cursor-help",children:"Contracted"})}),sortConfig:u,onSort:x,width:"w-[120px]"}),(0,i.jsx)(tC.U,{field:"total_actual_exp",label:(0,i.jsx)(P.Z,{arrow:!0,placement:"top",title:"The total amount spent so far on this expense.",children:(0,i.jsx)("span",{className:"border-b border-dashed border-[#7C8293] cursor-help",children:"Actual Exp"})}),sortConfig:u,onSort:x,width:"w-[120px]"}),(0,i.jsx)("th",{className:"px-6 py-4 text-left text-14 font-medium text-[#7C8293] w-[160px] bg-[#F3F3F3]",children:"Subcontracts#"}),(0,i.jsx)(tC.U,{field:"paid_date_timestamp",label:"Payment Date",sortConfig:u,onSort:x,width:"w-[140px]"}),(0,i.jsx)(tC.U,{field:"source",label:"Source",sortConfig:u,onSort:x,width:"w-[120px]"}),(0,i.jsx)(tC.U,{field:"status",label:"Status",sortConfig:u,onSort:x,width:"w-[120px]"}),p&&(0,i.jsx)("th",{className:"px-6 py-4 text-left text-14 font-medium text-[#7C8293] w-[160px] bg-[#F3F3F3]",children:"Client Invoice"}),(0,i.jsx)(tC.U,{field:"category",label:"Category",sortConfig:u,onSort:x,width:"w-[180px]"}),!h&&(0,i.jsx)(tC.U,{field:"project_name",label:"Project",sortConfig:u,onSort:x,width:"w-[220px]"}),!h&&v&&(0,i.jsx)(tC.U,{field:"contracted_price",label:"Project Value",sortConfig:u,onSort:x,width:"w-[140px]"}),(0,i.jsx)(tC.U,{field:"payment_method",label:"Payment Method",sortConfig:u,onSort:x,width:"w-[140px]"}),(0,i.jsx)(tC.U,{field:"create_time_timestamp",label:"Creation Date",sortConfig:u,onSort:x,width:"w-[140px]"}),(0,i.jsxs)("th",{className:"px-6 py-4 text-center text-14 font-medium text-[#7C8293] bg-[#F3F3F3] w-[120px] sticky right-0 z-30",children:[(0,i.jsx)("div",{className:"absolute left-0 top-0 bottom-0 w-[1px] bg-gray-200"}),(0,i.jsx)("div",{className:(0,m.cn)("absolute left-[-8px] top-0 bottom-0 w-[8px] transition-opacity duration-200",f&&"opacity-0"),style:{background:"linear-gradient(to left, rgba(0,0,0,0.08), rgba(0,0,0,0.05), rgba(0,0,0,0.02), transparent)"}}),"Actions"]})]})})})})})})},t_=s(69365),tF=s(6991);let tE=e=>{let{title:t}=e;return(0,i.jsxs)("svg",{width:"16",height:"16",viewBox:"2 2 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"flex-shrink-0","aria-label":t,children:[(0,i.jsx)("title",{children:t}),(0,i.jsx)("circle",{cx:"12",cy:"12",r:"10",fill:"#35AB3B"}),(0,i.jsx)("path",{d:"M7.5 12.3L10.6 15.4L16.5 8.8",stroke:"#FFFFFF",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})},tS=e=>{let{title:t}=e;return(0,i.jsxs)("svg",{width:"16",height:"16",viewBox:"2 2 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"flex-shrink-0","aria-label":t,children:[(0,i.jsx)("title",{children:t}
1),(0,i.jsx)("circle",{cx:"10",cy:"10",r:"8",fill:"#BDBDBD"}),(0,i.jsx)("path",{d:"M10.0028 6L10.0024 10.0029L12.8289 12.8294",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})};var tD=e=>{let{clientInvoice:t,onClick:s}=e;if(!t)return null;let n=t.is_paid,a=n?"Invoice is paid":"Invoice is unpaid";return(0,i.jsxs)("button",{type:"button",onClick:s?e=>{e.stopPropagation(),s(t)}:void 0,className:"inline-flex items-center gap-1 cursor-pointer rounded-sm focus:outline-none focus:ring-2 focus:ring-[#0052CC] focus:ring-offset-1","aria-label":"Open invoice ".concat(t.invoice_no),children:[n?(0,i.jsx)(tE,{title:a}):(0,i.jsx)(tS,{title:a}),(0,i.jsx)("span",{className:"text-sm font-medium underline whitespace-nowrap",style:{color:"#0052CC"},children:t.invoice_no})]})},tI=s(88607),tA=s(28882);let tP=Intl.DateTimeFormat().resolvedOptions().timeZone;var tB=e=>{var t,s,n,a,l,r,d,c,u,x,p,h,f;let{expense:b,index:j,canEditExpense:y,showExpensesToClassify:w,initialShowExpensesToClassify:N,selectedExpenses:C,onExpenseSelection:k,expandedExpenses:_,onToggleExpanded:F,onExpenseEdit:E,setItemExpense:S,formatPrice:D,formatTimestamp:I,isProOrAbove:B,onClientInvoiceClick:M,categoryDropdownRef:L,onOpenCategoryDialog:Z,deletingCategoryId:T,setDeletingCategoryId:O,categoryOptions:R,actions:z,currentProjectId:W,showProjectDropdown:q,setShowProjectDropdown:U,projectSearchQuery:V,setProjectSearchQuery:Q,projectList:H,onProjectAssign:Y,isShowContracted:G,showExpenseId:$,onMenuOpen:K,isScrolledToEnd:X,setWorkOrderOpen:J,setOpenProjectId:ee,setProjectDetailActiveTab:et}=e,es="".concat(b.obj_id,"-").concat(j);return(0,i.jsxs)(o.Fragment,{children:[(0,i.jsxs)("tr",{className:(0,m.cn)("hover:bg-[#F7F8FA] transition-colors",y?"cursor-pointer":"cursor-default"),onClick:()=>{y&&E(b)},children:[w&&(0,i.jsx)("td",{className:"px-4 w-12 text-left",children:(0,i.jsx)("input",{type:"checkbox",checked:C.some(e=>e.obj_id===b.obj_id),onChange:e=>k(b,e.target.checked),onClick:e=>e.stopPropagation(),disabled:!y,className:"rounded border-[#D1D5DB] text-[#0052CC] focus:ring-[#0052CC] disabled:opacity-50 disabled:cursor-not-allowed"})}),$&&(0,i.jsx)("td",{className:"px-4 py-4 w-[90px] text-14 text-[#181B24]",children:b.obj_id}),(0,i.jsx)("td",{className:"py-4 w-[250px]",children:(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(null==b?void 0:null===(s=b.payments)||void 0===s?void 0:null===(t=s.payments)||void 0===t?void 0:t.length)>0?(0,i.jsx)("button",{"aria-label":"toggle payments",onClick:e=>{e.stopPropagation(),F(b.obj_id)},className:"flex-shrink-0 p-1 hover:bg-gray-100 transition-colors",children:(0,i.jsx)("svg",{className:"w-4 h-4 text-gray-500 transition-transform ".concat(_.has(b.obj_id)?"rotate-90":""),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}):(0,i.jsx)("div",{className:"w-6 h-6"}),(0,i.jsx)(P.Z,{arrow:!0,placement:"top",title:b.description||"",children:(0,i.jsx)("div",{className:"text-sm text-[#051023] truncate flex-1",children:b.description||(0,i.jsx)("span",{className:"text-[#CCC]",children:"— —"})})}),(b.scope_id||b.group_id)&&(0,i.jsx)(P.Z,{arrow:!0,placement:"top",title:"This expense is linked to a scope",children:(0,i.jsx)("div",{className:"w-5 h-5 rounded-full bg-[#E9F1FD] flex justify-center items-center",children:(0,i.jsx)(A.UO,{})})}),5===b.source_type&&(0,i.jsx)(tI.Z,{})]})}),(0,i.jsx)("td",{className:"px-6 py-4 w-[160px]",children:(0,i.jsx)("div",{className:"flex items-start",children:b.vendor_name?(0,i.jsxs)(i.Fragment,{children:[b.avatar_url?(0,i.jsx)("img",{src:b.avatar_url,alt:"",className:"w-6 h-6 rounded-full mr-2 flex-shrink-0 object-cover"}):(0,i.jsx)("div",{className:"w-6 h-6 rounded-full bg-[#3B4658] text-white text-xs flex items-center justify-center mr-2 flex-shrink-0",children:b.vendor_name_first_letter||b.vendor_name.charAt(0).toUpperCase()}),(0,i.jsx)("span",{className:"text-sm text-[#051023] break-words leading-5 max-w-[120px]",children:b.vendor_name})]}):(0,i.jsx)("span",{className:"text-[#CCC]",children:"— —"})})}),(0,i.jsx)("td",{className:"px-6 py-4 w-[160px]",children:(0,i.jsx)("div",{className:"flex items-start",children:b.payee_name?(0,i.jsxs)(i.Fragment,{children:[b.payee_avatar_url?(0,i.jsx)("img",{src:b.payee_avatar_url,alt:"",className:"w-6 h-6 rounded-full mr-2 flex-shrink-0 object-cover"}):(0,i.jsx)("div",{className:"w-6 h-6 rounded-full bg-[#3B4658] text-white text-xs flex items-center justify-center mr-2 flex-shrink-0",children:b.payee_name.charAt(0).toUpperCase()}),(0,i.jsx)("span",{className:"text-sm text-[#051023] break-words leading-5 max-w-[120px]",children:b.payee_name})]}):(0,i.jsx)("span",{className:"text-[#CCC]",children:"— —"})})}),(0,i.jsx)("td",{className:"px-6 py-4 whitespace-nowrap w-[120px]",children:(0,i.jsxs)("span",{className:"text-base font-medium",style:{color:tA.k},children:[D(parseFloat(b.paid_out)||0),(null==b?void 0:null===(a=b.payments)||void 0===a?void 0:null===(n=a.payments)||void 0===n?void 0:n.length)>0&&(0,i.jsxs)("span",{className:"ml-2 text-14 text-[#B2B2B2] inline-flex items-center gap-1",children:[null==b?void 0:null===(r=b.payments)||void 0===r?void 0:null===(l=r.payments)||void 0===l?void 0:l.length,(0,i.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,i.jsx)("path",{d:"M10.2105 6.5H2M10.2105 12.1316H4.73684C3.22533 12.1316 2 10.9063 2 9.39474L2 3",stroke:"#B2B2B2",strokeWidth:"1.3",strokeLinecap:"round"}),(0,i.jsx)("circle",{cx:"12",cy:"6.5",r:"1.35",stroke:"#B2B2B2",strokeWidth:"1.3"}),(0,i.jsx)("circle",{cx:"12",cy:"12",r:"1.35",stroke:"#B2B2B2",strokeWidth:"1.3"})]})]})]})}),(0,i.jsx)("td",{className:"px-6 py-4 whitespace-nowrap w-[120px]",children:(0,i.jsx)("span",{className:"text-base font-medium text-[#2563eb]",children:4===b.source_type||3===b.source_type?D(parseFloat(null===(d=b.worker_order_detail)||void 0===d?void 0:d.won_price)||0):"--"})}),(0,i.jsx)("td",{className:"px-6 py-4 whitespace-nowrap w-[120px]",children:(0,i.jsx)("span",{className:"text-base font-medium",style:{color:tA.k},children:D(parseFloat(b.total_actual_exp)||0)})}),(0,i.jsx)("td",{onClick:e=>{y&&(4===b.source_type||3===b.source_type)&&(e.stopPropagation(),b.worker_order_id?W&&(et("work_orders"),window.top.postMessage({type:"openWorkOrderDetail",data:{workOrderId:b.worker_order_id}})):(J(!0),ee(b.project_id),S(b)))},className:"px-6 py-4 w-[160px]",children:4===b.source_type||3===b.source_type?(0,i.jsx)("div",{className:"text-14 text-en-blue",children:b.worker_order_id?b.worker_order_detail.order_id_name:y?"+ New":"--"}):"--"}),(0,i.jsx)("td",{className:"px-6 py-4 w-[140px]",children:(0,i.jsx)("div",{className:"text-sm text-[#051023]",children:I(b.paid_date_timestamp)})}),(0,i.jsx)("td",{className:"px-6 py-4 w-[120px]",children:(0,i.jsx)("div",{className:"flex items-center",children:(0,i.jsxs)("span",{className:"inline-flex items-center px-2 py-1 text-xs rounded-[13px] bg-[#E1E4EB] text-[#051023] gap-1",children:[b.source,1===b.source_type&&(0,i.jsxs)("svg",{className:"w-4 h-4 cursor-pointer",xmlns:"http://www.w3.org/2000/svg",width:"20",height:"21",viewBox:"0 0 20 21",fill:"none",style:{marginLeft:"4px"},onClick:e=>{e.stopPropagation(),b.qblink&&window.open(b.qblink,"_blank")},children:[(0,i.jsxs)("g",{clipPath:"url(#clip0_13146_6155)",children:[(0,i.jsx)("path",{d:"M10 20.5C15.5228 20.5 20 16.0228 20 10.5C20 4.97719 15.5228 0.5 10 0.5C4.47719 0.5 0 4.47719 0 10.5C0 16.0228 4.47719 20.5 10 20.5Z",fill:"#2CA01C"}),(0,i.jsx)("path",{d:"M2.77799 10.4998C2.77799 11.5312 3.18771 12.5204 3.91702 13.2497C4.64633 13.979 5.63549 14.3887 6.66689 14.3887H7.22236V12.9442H6.66689C6.34424 12.9468 6.02427 12.8854 5.72543 12.7637C5.42659 12.6421 5.1548 12.4624 4.92573 12.2352C4.69666 12.0079 4.51485 11.7376 4.39077 11.4397C4.2667 11.1419 4.20282 10.8224 4.20282 10.4997C4.20282 10.1771 4.2667 9.85759 4.39077 9.55973C4.51485 9.26188 4.69666 8.99153 4.92573 8.76429C5.1548 8.53704 5.42659 8.35739 5.72543 8.23571C6.02427 8.11402 6.34424 8.05269 6.66689 8.05527H8.00018V15.6109C8.0003 15.9939 8.15251 16.3613 8.42335 16.6321C8.69419 16.903 9.0615 17.0553 9.44455 17.0554V6.6109H6.66689C6.15618 6.61088 5.65047 6.71145 5.17863 6.90688C4.70678 7.10231 4.27806 7.38876 3.91692 7.74988C3.55579 8.111 3.26932 8.53971 3.07387 9.01155C2.87843 9.48338 2.77799 9.98909 2.77799 10.4998ZM13.3335 6.6109H12.778V8.05543H13.3335C13.977 8.06271 14.5916 8.32344 15.0441 8.78106C15.4966 9.23868 15.7503 9.85626 15.7503 10.4998C15.7503 11.1433 15.4966 11.7609 15.0441 12.2185C14.5916 12.6762 13.977 12.9369 13.3335 12.9442H12.0002V5.38887C12.0002 5.19918 11.9629 5.01134 11.8903 4.83608C11.8177 4.66082 11.7113 4.50158 11.5772 4.36744C11.4431 4.2333 11.2838 4.12689 11.1086 4.0543C10.9333 3.9817 10.7455 3.94434 10.5558 3.94434V14.3889H13.3335C14.3649 14.3889 15.354 13.9791 16.0833 13.2498C16.8126 12.5205 17.2224 11.5314 17.2224 10.5C17.2224 9.46856 16.8126 8.4794 16.0833 7.75009C15.354 7.02078 14.3649 6.6109 13.3335 6.6109Z",fill:"white"})]}),(0,i.jsx)("defs",{children:(0,i.jsx)("clipPath",{id:"clip0_13146_6155",children:(0,i.jsx)("rect",{width:"20",height:"20",fill:"white",transform:"translate(0 0.5)"})})})]})]})})}),(0,i.jsx)("td",{className:"px-6 py-4 w-[120px]",children:(0,i.jsxs)("div",{className:"inline-flex items-center px-2 py-1 text-xs rounded-[13px]",style:{color:null===(c=b.status_info)||void 0===c?void 0:c.color,backgroundColor:null===(u=b.status_info)||void 0===u?void 0:u.bg_color},children:[(0,i.jsx)("div",{className:"w-[5px] h-[5px] rounded-full mr-1 shrink-0",style:{backgroundColor:null===(x=b.status_info)||void 0===x?void 0:x.color}}),null===(p=b.status_info)||void 0===p?void 0:p.status]})}),B&&(0,i.jsx)("td",{className:"px-6 py-4 w-[160px]",onClick:e=>e.stopPropagation(),children:(0,i.jsx)(tD,{clientInvoice:b.client_invoice,onClick:M})}),(0,i.jsx)("td",{className:"px-6 py-4 w-[180px]",children:(0,i.jsx)("div",{className:"relative",ref:e=>{L.current[b.id]=e},children:b.category&&b.category.length>0?(0,i.jsx)("div",{className:(0,m.cn)("flex flex-wrap gap-1",y&&"cursor-pointer"),onClick:e=>{y&&(e.stopPropagation(),Z(b,"modify"))},children:b.category.map(e=>(0,i.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1 rounded-[13px] bg-[#E1E4EB]",children:[(0,i.jsx)("span",{className:"text-xs text-[#051023]",children:e.name}),y&&(0,i.jsx)("button",{onClick:async t=>{t.stopPropagation(),O(e.id);try{var s;let t=((null===(s=b.category)||void 0===s?void 0:s.map(e=>e.id))||[]).filter(t=>t!==e.id);await v.o.setExpenseCategory(b.obj_id,b.source_type,t),g.y.success("Category removed successfully"),z.updateExpenseCategories(b.obj_id,t,R)}catch(e){console.error("Failed to remove category:",e),g.y.error("Failed to remove category. Please try again.")}finally{O(null)}},disabled:T===e.id,className:"ml-1 ".concat(T===e.id?"opacity-50 cursor-not-allowed":"hover:opacity-70"),children:(0,i.jsx)("svg",{className:"w-3 h-3",viewBox:"0 0 14 14",fill:"none",children:(0,i.jsx)("path",{d:"M3.18164 10.1821L6.68164 6.68213M6.68164 6.68213L10.1816 3.18213M6.68164 6.68213L3.18164 3.18213M6.68164 6.68213L10.1816 10.1821",stroke:"#7C8293",strokeWidth:"1.05",strokeLinecap:"round"})})})]},e.id))}):y?(0,i.jsxs)("button",{className:"flex items-center gap-1 text-[#0052CC] text-sm",onClick:e=>{e.stopPropagation(),Z(b,"modify")},children:[(0,i.jsx)("span",{children:"+"}),(0,i.jsx)("span",{children:"Assign"})]}):(0,i.jsx)("span",{className:"text-[#CCC]",children:"— —"})})}),!W&&(0,i.jsx)("td",{className:"px-6 py-4 w-[220px]",children:(0,ex.jx)(b.source_type)?(0,i.jsxs)("div",{className:"text-en-dark-blue text-14",children:[(0,i.jsx)(tI.Z,{})," OpEx (Operating Expenses)"]}):b.project_id?(0,i.jsxs)("div",{className:"flex items-center gap-2 cursor-pointer",children:[(0,i.jsx)("div",{className:"w-3 h-3 rounded flex-shrink-0",style:{backgroundColor:b.color||"#3B82F6"}}),(0,i.jsx)("span",{className:"text-sm text-[#051023] break-words leading-5",children:(0,i.jsx)("div",{children:"".concat((null==b?void 0:b.project_name)?"".concat(b.project_name," - "):"").concat(b.project_address||"Project address missing","(#").concat(b.effective_project_no||b.project_id,")")})})]}):2!==b.source_type&&y?(0,i.jsx)("div",{className:"relative",children:q===es?(0,i.jsxs)("div",{"data-project-dropdown":!0,className:"absolute top-full mt-1 left-0 w-80 bg-white rounded-lg shadow-lg border border-[#
1E1E4EB] z-20 max-h-96 overflow-hidden",children:[(0,i.jsx)("div",{className:"sticky top-0 bg-white border-b border-[#E1E4EB] px-3 py-2",children:(0,i.jsx)("input",{type:"text",placeholder:"Search projects...",value:V,onChange:e=>Q(e.target.value),className:"w-full px-3 py-1.5 text-sm border border-[#E1E4EB] rounded-md focus:outline-none focus:ring-2 focus:ring-[#0052CC] focus:border-transparent",autoFocus:!0,onClick:e=>e.stopPropagation()})}),(0,i.jsxs)("div",{className:"overflow-y-auto max-h-80",children:[(H||[]).filter(e=>e.address.toLowerCase().includes(V.toLowerCase())||e.id.toString().includes(V)).slice(0,50).map(e=>(0,i.jsxs)("div",{onClick:t=>{t.stopPropagation(),Y(b,e.id),U(null),Q("")},className:"px-3 py-2.5 hover:bg-[#F7F8FA] cursor-pointer flex items-center gap-3 transition-colors border-b border-[#F7F8FA]",children:[(0,i.jsx)("div",{className:"w-4 h-4 rounded flex-shrink-0 shadow-sm",style:{backgroundColor:e.color||"#3B82F6"}}),(0,i.jsx)("div",{className:"flex-1 min-w-0",children:(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsxs)("span",{className:"text-[#7C8293] text-xs font-medium",children:["#",e.effectiveProjectNo||e.id]}),(0,i.jsx)("span",{className:"text-sm text-[#051023] truncate font-medium",children:e.address})]})})]},e.id)),0===H.filter(e=>e.address.toLowerCase().includes(V.toLowerCase())||e.id.toString().includes(V)).length&&(0,i.jsxs)("div",{className:"px-3 py-8 text-center text-[#7C8293] text-sm",children:[(0,i.jsx)("svg",{className:"w-12 h-12 text-[#E1E4EB] mx-auto mb-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),"No projects found"]}),H.filter(e=>e.address.toLowerCase().includes(V.toLowerCase())||e.id.toString().includes(V)).length>50&&(0,i.jsx)("div",{className:"px-3 py-2 text-center text-[#7C8293] text-xs bg-[#F7F8FA]",children:"Showing first 50 results. Type to refine your search."})]})]}):(0,i.jsxs)("button",{className:"flex items-center gap-1 text-[#0052CC] text-sm hover:underline",onClick:e=>{e.stopPropagation(),U(es)},children:[(0,i.jsx)("span",{children:"+"}),(0,i.jsx)("span",{children:"Assign"})]})}):null}),!W&&G&&(0,i.jsx)("td",{className:"px-6 py-4 whitespace-nowrap w-[140px]",children:(0,i.jsx)("span",{className:"text-base font-medium text-[#051023]",children:null===b.contracted_price||void 0===b.contracted_price||""===b.contracted_price||1===b.source_type&&("0.00"===b.contracted_price||"0"===b.contracted_price||0===b.contracted_price)?"--":D(parseFloat(b.contracted_price)||0)})}),(0,i.jsx)("td",{className:"px-6 py-4 w-[140px]",children:(0,i.jsx)(tF.Z,{paymentAccount:b.payment_account,fallbackMethod:b.payment_method,showDetail:!0,reference:b.payment_reference})}),(0,i.jsx)("td",{className:"px-6 py-4 w-[140px]",children:(0,i.jsx)("div",{className:"text-sm text-[#051023]",children:I(b.create_time_timestamp)})}),(0,i.jsxs)("td",{onClick:e=>{y&&1!==b.source_type&&2!==b.source_type&&K(e,b)},className:"px-6 py-4 whitespace-nowrap text-center sticky right-0 bg-white z-10 w-[120px]",children:[(0,i.jsx)("div",{className:"absolute left-0 top-0 bottom-0 w-[1px] bg-gray-200"}),(0,i.jsx)("div",{className:(0,m.cn)("absolute left-[-8px] top-0 bottom-0 w-[8px] transition-opacity duration-200",X&&"opacity-0"),style:{background:"linear-gradient(to left, rgba(0,0,0,0.08), rgba(0,0,0,0.05), rgba(0,0,0,0.02), transparent)"}}),y&&1!==b.source_type&&2!==b.source_type&&(0,i.jsx)("div",{className:"pl-4",children:(0,i.jsx)("svg",{width:"18",height:"4",viewBox:"0 0 18 4",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,i.jsxs)("g",{opacity:"0.7",children:[(0,i.jsx)("circle",{cx:"2",cy:"2",r:"2",fill:"#7C8293"}),(0,i.jsx)("circle",{cx:"9",cy:"2",r:"2",fill:"#7C8293"}),(0,i.jsx)("circle",{cx:"16",cy:"2",r:"2",fill:"#7C8293"})]})})})]})]}),_.has(b.obj_id)&&(null==b?void 0:null===(f=b.payments)||void 0===f?void 0:null===(h=f.payments)||void 0===h?void 0:h.length)>0&&(0,i.jsxs)("tr",{className:"bg-en-bg-light-blue",children:[(0,i.jsx)("td",{className:"px-6",colSpan:(W?N?14:13:(N?15:14)+(G?1:0))+(B?1:0),children:(0,i.jsx)("div",{className:"pl-6 divide-y-1px",children:b.payments.payments.map((e,t)=>{var s;return(0,i.jsx)("div",{className:"flex items-center justify-between",children:(0,i.jsxs)("div",{className:"flex items-center gap-4 border-gray-200 py-3 pl-4 text-en-mid-blue",children:[(0,i.jsx)("div",{className:"text-sm text-gray-600 w-80",children:e.paid_date?(0,em.CV)(e.paid_date,tP,"MM/dd/yyyy"):"--"}),(0,i.jsx)("div",{className:"w-80 text-14",children:(0,i.jsxs)("div",{className:"flex items-center gap-2 text-gray-900",children:[(0,i.jsx)(t_.Z,{status:e.status,className:"mr-2"}),(0,i.jsx)(tF.Z,{paymentAccount:e.payment_account,fallbackMethod:e.pay_method,showDetail:!0,reference:e.payment_reference}),(null==e?void 0:e.files.length)>0&&(0,i.jsx)("span",{children:(0,i.jsx)(A.aA,{})})]})}),(0,i.jsxs)("div",{className:"text-sm font-medium text-gray-900 w-80",children:["$ ",e.amount||"0.00"]}),B&&(0,i.jsx)("div",{className:"text-sm w-80",children:(0,i.jsx)(tD,{clientInvoice:null!==(s=e.client_invoice)&&void 0!==s?s:null,onClick:M})})]})},t)})})}),(0,i.jsxs)("td",{className:"px-6 py-4 whitespace-nowrap !border-0 text-center sticky right-0 bg-white z-10 w-[120px]",children:[(0,i.jsx)("div",{className:"absolute left-0 top-0 bottom-0 w-[1px] bg-white"}),(0,i.jsx)("div",{className:(0,m.cn)("absolute left-[-8px] top-0 bottom-0 w-[8px] transition-opacity duration-200",X&&"opacity-0"),style:{background:"linear-gradient(to left, rgba(0,0,0,0.08), rgba(0,0,0,0.05), rgba(0,0,0,0.02), transparent)"}}),(0,i.jsx)("div",{className:"pl-4"})]})]})]},es)},tM=e=>{let{expensesListCount:t,totalCount:s,totalExpense:n,formatPrice:a,isLoadingMore:l,hasMore:r,loadMoreRef:o}=e;return(0,i.jsxs)("div",{className:"bg-gray-50 border-t border-gray-200 mt-4",children:[(0,i.jsxs)("div",{className:"px-6 py-4",children:[(0,i.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,i.jsx)("div",{className:"text-sm text-gray-600",children:s?(0,i.jsxs)(i.Fragment,{children:["Showing"," ",(0,i.jsx)("span",{className:"font-semibold text-gray-900",children:Math.min(t,s)})," ","of ",(0,i.jsx)("span",{className:"font-semibold text-gray-900",children:s})," records"]}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("span",{className:"font-semibold text-gray-900",children:t})," records loaded"]})}),t>0&&(0,i.jsxs)("div",{className:"flex items-center gap-6",children:[(0,i.jsxs)("span",{className:"text-sm text-gray-600",children:["Total:"," ",(0,i.jsxs)("span",{className:"font-semibold text-gray-900",children:[s," ",1===s?"Item":"Items"]})]}),(0,i.jsx)("span",{className:"text-lg font-semibold",style:{color:tA.k},children:a(n)})]})]}),(0,i.jsxs)("div",{className:"flex items-center justify-center",children:[l&&(0,i.jsxs)("div",{className:"flex items-center gap-3",children:[(0,i.jsx)("div",{className:"animate-spin rounded-full h-5 w-5 border-b-2 border-[#0052CC]"}),(0,i.jsx)("span",{className:"text-sm text-gray-600",children:"Loading more records..."})]}),!l&&r&&(0,i.jsx)("span",{className:"text-sm text-gray-500",children:"Scroll down to load more"}),!r&&t>0&&!l&&(0,i.jsxs)("div",{className:"flex items-center gap-2 text-sm text-green-600",children:[(0,i.jsx)("svg",{className:"w-4 h-4",fill:"
1currentColor",viewBox:"0 0 20 20",children:(0,i.jsx)("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}),"All records loaded"]})]})]}),r&&(0,i.jsx)("div",{ref:o,className:"h-4"})]})},tL=e=>{let{selectedExpensesCount:t,projectList:s,selectedProjectId:n,setSelectedProjectId:a,onCancel:l,onAssign:r}=e;return(0,i.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,i.jsx)("div",{className:"fixed inset-0 bg-black bg-opacity-50",onClick:l}),(0,i.jsxs)("div",{className:"relative bg-white rounded-xl shadow-lg max-w-md w-full mx-4 p-6",children:[(0,i.jsx)("h2",{className:"text-xl font-medium text-[#051023] mb-4",children:"Bulk Assign Projects"}),(0,i.jsxs)("p",{className:"text-sm text-[#7C8293] mb-6",children:["You have selected ",t," expense",t>1?"s":""," to assign to a project."]}),(0,i.jsxs)("div",{className:"mb-6",children:[(0,i.jsxs)("label",{className:"block text-sm font-medium text-[#051023] mb-2",children:["Select Project ",(0,i.jsx)("span",{className:"text-[#E12424]",children:"*"})]}),(0,i.jsxs)("select",{value:n,onChange:e=>a(e.target.value),className:"w-full px-3 py-2 border border-[#E1E4EB] rounded-lg focus:outline-none focus:ring-2 focus:ring-[#0052CC]",children:[(0,i.jsx)("option",{value:"",children:"Select a project"}),s.map(e=>(0,i.jsxs)("option",{value:e.id,children:["(",e.effectiveProjectNo||e.id,") ",e.address]},e.id))]})]}),(0,i.jsxs)("div",{className:"flex justify-end gap-3",children:[(0,i.jsx)("button",{onClick:l,className:"px-4 py-2 text-sm text-[#051023] bg-[#F4F5F7] border border-[#D7D9DD] rounded-lg hover:bg-[#EBECF0]",children:"Cancel"}),(0,i.jsx)("button",{onClick:r,disabled:!n,className:"px-4 py-2 text-sm text-white bg-[#0052CC] rounded-lg hover:bg-[#0043A8] disabled:opacity-50",children:"Assign"})]})]})]})},tZ=e=>{let{expensesList:t,totalExpense:s,totalCount:n,notAssignedProjectCount:a,loading:l,tableLoading:r,isLoadingMore:c,hasMore:f,loadMoreRef:b,onFilterChange:j,hasQuickBooksConnection:y,hasQBData:w=!1,isShowContracted:N=!1,showExpenseId:C=!1,showExpensesToClassify:k,onRefreshData:_,currentProjectId:F,setProjectDetailActiveTab:E,projectList:S,setLocalFilters:D,localFilters:I,viewMode:A,onViewModeChange:P}=e,{actions:M}=(0,d.pL)(),{isOwner:L,isAdmin:Z}=(0,tn.j$)(),{isEnterprisePlan:T,isProOrAbove:O}=(0,td.U_)(),{categoryOptions:R}=(0,er.z)(),z=!1!==(0,eo.v9)(e=>{var t,s,n;return null===(n=e.authStore)||void 0===n?void 0:null===(s=n.user)||void 0===s?void 0:null===(t=s.vendor_info)||void 0===t?void 0:t.is_has_expense_edit_permission}),{sortConfig:W,setSortConfig:q,getNextSort:Q}=(0,tr.f)(),H=(0,o.useRef)(),[Y,G]=(0,o.useState)(new Set),[$,K]=(0,o.useState)([]),[X,J]=(0,o.useState)(!1),[ee,et]=(0,o.useState)([]),[es,en]=(0,o.useState)(""),el=(0,o.useRef)({}),[ed,ec]=(0,o.useState)(!1),[eu,ex]=(0,o.useState)("modify"),[ep,em]=(0,o.useState)(null),[eg,ef]=(0,o.useState)(null),[eb,ej]=(0,o.useState)(null),[ey,ew]=(0,o.useState)(""),[eN,ek]=(0,o.useState)(!1),[e_,eF]=(0,o.useState)(null),[eE,eS]=(0,o.useState)(null),[eD,eI]=(0,o.useState)(null),{data:eA}=(0,U.u)("/api/v1/finance/qb/setting/",V._i),[eP,eB]=(0,o.useState)(!1),[eM,eL]=(0,o.useState)(!1),[eZ,eT]=(0,o.useState)(!1),[eO,eR]=(0,o.useState)(""),ez=(0,o.useCallback)(e=>{eR(e.invoice_id),eT(!0)},[]),[eW,eq]=(0,o.useState)(null),{filters:eU,isLoading:eV,mutate:eQ}=(0,to.L)(F?{searchType:ti.S.TYPE_PROJECT_FINANCE_EXPENSE,projectId:F}:{searchType:ti.S.TYPE_FINANCE_EXPENSE}),eH=(0,o.useMemo)(()=>null==eU?void 0:eU.find(e=>e.id===eW),[eW,eU]),{isFilterSticky:eY,filterRef:eG,sentinelRef:e$,filterHeight:eK}=function(){let[e,t]=(0,o.useState)(!1),s=(0,o.useRef)(null),n=(0,o.useRef)(null),[a,l]=(0,o.useState)(0);return(0,o.useEffect)(()=>{let e=()=>{s.current&&l(s.current.offsetHeight)};return e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}},[]),(0,o.useEffect)(()=>{let e=n.current;if(!e)return;let a=new IntersectionObserver(e=>{let[n]=e,a=!n.isIntersecting;t(a),a&&s.current&&l(s.current.offsetHeight)},{threshold:0,rootMargin:"-1px 0px 0px 0px"});return a.observe(e),()=>{a.unobserve(e)}},[]),{isFilterSticky:e,filterRef:s,sentinelRef:n,filterHeight:a}}(),[eX,e0]=(0,o.useState)(!1),[e1,e2]=(0,o.useState)({}),{headerScrollRef:e4,bodyScrollRef:e5,isScrolledToEnd:e3}=function(e){let{expensesList:t,currentProjectId:s,showExpensesToClassify:n}=e,a=(0,o.useRef)(null),l=(0,o.useRef)(null),r=(0,o.useRef)(!1),i=(0,o.useRef)(!1),[d,c]=(0,o.useState)(!1);return(0,o.useEffect)(()=>{let e=null,t=null,s=e=>{null!==t&&cancelAnimationFrame(t),t=requestAnimationFrame(()=>{c(e.scrollLeft+e.clientWidth>=e.scrollWidth-2)})},n=t=>
1{null!==e&&cancelAnimationFrame(e),e=requestAnimationFrame(()=>{a.current&&l.current&&("header"===t?(i.current=!0,l.current.scrollLeft=a.current.scrollLeft,s(a.current)):(r.current=!0,a.current.scrollLeft=l.current.scrollLeft,s(l.current)))})},o=()=>{if(r.current){r.current=!1;return}n("header")},d=()=>{if(i.current){i.current=!1;return}n("body")},u=a.current,x=l.current;return u&&u.addEventListener("scroll",o,{passive:!0}),x&&x.addEventListener("scroll",d,{passive:!0}),x&&s(x),()=>{null!==e&&cancelAnimationFrame(e),null!==t&&cancelAnimationFrame(t),u&&u.removeEventListener("scroll",o),x&&x.removeEventListener("scroll",d)}},[]),(0,o.useEffect)(()=>{let e=()=>{let e=l.current;e&&c(e.scrollLeft+e.clientWidth>=e.scrollWidth-2)},t=setTimeout(e,100);return window.addEventListener("resize",e),()=>{clearTimeout(t),window.removeEventListener("resize",e)}},[t,s,n]),{headerScrollRef:a,bodyScrollRef:l,isScrolledToEnd:d}}({expensesList:t,currentProjectId:F,showExpensesToClassify:I.showExpensesToClassify}),[e6,e8]=(0,o.useState)(null),e7=(0,o.useRef)(!1),e9=e=>{G(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})};(0,o.useEffect)(()=>{te()},[y]);let te=async()=>{try{let e=await v.o.getExpenseSources();et(e.map(e=>({id:e.value||e.id,name:e.label||e.name,value:e.value,label:e.label})))}catch(e){console.error("Failed to load sources:",e)}},tt=(0,o.useCallback)(e=>{H.current&&clearTimeout(H.current);let t=Q(e);q(t),j&&j({...I,sortField:t.field,sortOrder:t.field?t.order:void 0})},[Q,q,j,I]);(0,o.useEffect)(()=>()=>{H.current&&clearTimeout(H.current)},[]),(0,o.useEffect)(()=>{!y||!(n>0)||e7.current||l||w||F||(eL(!1),e7.current=!0)},[y,n,w,l]);let tu=(e,t)=>{e.stopPropagation(),eS(e.currentTarget),eI(t)},tx=()=>{eS(null),eI(null)},tp=e=>{e2(eD),eF(e),tx()},tm=(e,t)=>{t?K([...$,e]):K($.filter(t=>t.obj_id!==e.obj_id))},th=(e,t)=>{em(e),ex(t),ec(!0)},tv=async(e,t)=>{try{let s=e.obj_id,n=e.source_type;if(!s||void 0===n){console.error("Invalid expense data:",e),g.y.error("Invalid expense data");return}await v.o.assignExpenseToProject(s,n,t),_&&await _(),g.y.success("Project assigned successfully")}catch(e){console.error("Failed to assign project:",e),g.y.error("Failed to assign project. Please try again.")}},tg=async()=>{if(es&&0!==$.length)try{await v.o.bulkAssignProjects($,es),K([]),J(!1),en(""),_&&await _(),g.y.success("Projects assigned successfully")}catch(e){console.error("Failed to bulk assign projects:",e),g.y.error("Failed to bulk assign projects. Please try again.")}},tf=async()=>{let e={id:e1.obj_id,sourceType:e1.source_type};e_&&(e.eanoOnly=!0);let t=await (0,B.r)({url:"/api/v1/finance/manual/expense/",method:"delete",params:e});t.isOk?(_(),eF(null),ek(!1),e2({}),(0,eh.k)("/api/v1/finance/qb/expense/chart"),F&&(0,eh.k)((0,eJ.t)(F)),ev.ZP.success("Delete success")):ev.ZP.error(t.resMessage||"Delete error")},tb=e=>"".concat(e<0?"-":"","$").concat(Math.abs(e).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})),tj=e=>{if(!e)return"-";let t=new Date(1e3*e);return"".concat(t.getMonth()+1,"/").concat(t.getDate(),"/").concat(t.getFullYear())},ty=e=>{e2(e),e8(e.project_id),ek(!0)};return(0,i.jsxs)("div",{className:"jsx-daf42ae5c1721118 relative",children:[(0,i.jsx)(u(),{id:"daf42ae5c1721118",children:".scrollbar-hide.jsx-daf42ae5c1721118::-webkit-scrollbar{display:none}.pl-scroll-layer.jsx-daf42ae5c1721118{-webkit-transform:translatez(0);-moz-transform:translatez(0);-ms-transform:translatez(0);-o-transform:translatez(0);transform:translatez(0);will-change:scroll-position;-webkit-overflow-scrolling:touch;contain:paint}"}),r&&t.length>0&&(0,i.jsxs)("div",{className:"jsx-daf42ae5c1721118 fixed top-20 right-6 z-50 bg-white rounded-lg shadow-lg border border-gray-200 px-4 py-2 flex items-center gap-2",children:[(0,i.jsx)("div",{className:"jsx-daf42ae5c1721118 animate-spin rounded-full h-4 w-4 border-b-2 border-[#0052CC]"}),(0,i.jsx)("span",{className:"jsx-daf42ae5c1721118 text-sm text-gray-600",children:"Updating..."})]}),(0,i.jsx)("div",{ref:e$,className:"jsx-daf42ae5c1721118 h-0"}),(0,i.jsx)(tN,{filterRef:eG,isFilterSticky:eY,isEnterprisePlan:T,localFilters:I,handleFilterChange:(e,t)=>
1{D(s=>({...s,[e]:t})),j&&(H.current&&clearTimeout(H.current),H.current=setTimeout(()=>{j({dateRangeFilter:"dateRangeFilter"===e?t:I.dateRangeFilter,sourceFilter:"sourceFilter"===e?t:I.sourceFilter,categoryFilter:"categoryFilter"===e?t:I.categoryFilter,showExpensesToClassify:"showExpensesToClassify"===e?t:I.showExpensesToClassify,tagsFilter:"tagsFilter"===e?t:I.tagsFilter,vendorUserIds:"vendorUserIds"===e?t:I.vendorUserIds,statusFilter:"statusFilter"===e?t:I.statusFilter,search:"search"===e?t:I.search,sortField:W.field,sortOrder:W.order})},300))},dateRangeOptions:[{value:0,label:"All"},{value:1,label:"Last 7 days"},{value:2,label:"Last 30 days"},{value:3,label:"Last 90 days"},{value:4,label:"Last 6 months"},{value:5,label:"Last 12 months"}],sourceOptions:ee,categoryOptions:R,currentProjectId:F,tableLoading:r,clearFilters:()=>{let e={dateRangeFilter:0,sourceFilter:"",categoryFilter:"",showExpensesToClassify:!1,tagsFilter:[],vendorUserIds:[],statusFilter:"0"};D({...e}),j({...e,sortField:W.field,sortOrder:W.order})},saveFilters:e=>{D(t=>({...t,...e})),j({...I,...e,sortField:W.field,sortOrder:W.order})},filters:eU,mutateSavedFilters:eQ,isLoading:eV,activeFilterId:eW,setActiveFilterId:eq,activeFilter:eH,notAssignedProjectCount:a,hasQuickBooksConnection:y,canEditExpense:z,selectedExpensesCount:$.length,onBulkAssignClick:()=>J(!0),isOwner:L,isAdmin:Z,onSyncClick:()=>eL(!0),onDisconnectClick:()=>eB(!0),viewMode:A,onViewModeChange:P,showExpenseId:C}),(0,i.jsxs)("div",{className:"jsx-daf42ae5c1721118 ",children:[(0,i.jsx)(tk,{isFilterSticky:eY,filterHeight:eK,tableLoading:r,headerScrollRef:e4,localFilters:I,selectedExpensesCount:$.length,expensesListCount:t.length,onSelectAll:e=>{e?K(t):K([])},canEditExpense:z,sortConfig:W,onSort:tt,isProOrAbove:O,currentProjectId:F,isShowContracted:N,showExpenseId:C,isScrolledToEnd:e3}),(0,i.jsxs)("div",{className:"jsx-daf42ae5c1721118 "+((0,m.cn)("bg-white rounded-b-xl shadow-none -mt-[2px] relative",r&&"opacity-70 pointer-events-none")||""),children:[r&&(0,i.jsx)("div",{className:"jsx-daf42ae5c1721118 absolute inset-0 bg-white bg-opacity-50 z-10"}),(0,i.jsx)("div",{ref:e5,className:"jsx-daf42ae5c1721118 overflow-x-auto pl-scroll-layer no-scrollbar",children:(0,i.jsx)("table",{className:"jsx-daf42ae5c1721118 w-full min-w-[1450px] table-fixed",children:(0,i.jsx)("tbody",{className:"jsx-daf42ae5c1721118 divide-y divide-[#EBECF0]",children:0!==t.length||l||r?0===t.length&&(l||r)?(0,i.jsx)("tr",{className:"jsx-daf42ae5c1721118",children:(0,i.jsx)("td",{colSpan:(F?I.showExpensesToClassify?15:14:(I.showExpensesToClassify?16:15)+(N?1:0))+(O?1:0),className:"jsx-daf42ae5c1721118 px-6 py-12 text-center",children:(0,i.jsxs)("div",{className:"jsx-daf42ae5c1721118 flex flex-col items-center",children:[(0,i.jsx)("div",{className:"jsx-daf42ae5c1721118 animate-spin rounded-full h-8 w-8 border-b-2 border-[#0052CC] mb-4"}),(0,i.jsx)("p",{className:"jsx-daf42ae5c1721118 text-[#7C8293] text-base",children:"Loading expenses..."})]})})}):t.map((e,t)=>(0,i.jsx)(tB,{expense:e,index:t,canEditExpense:z,showExpensesToClassify:I.showExpensesToClassify,initialShowExpensesToClassify:k,selectedExpenses:$,onExpenseSelection:tm,expandedExpenses:Y,onToggleExpanded:e9,onExpenseEdit:ty,setItemExpense:e2,formatPrice:tb,formatTimestamp:tj,isProOrAbove:O,onClientInvoiceClick:ez,categoryDropdownRef:el,onOpenCategoryDialog:th,deletingCategoryId:eg,setDeletingCategoryId:ef,categoryOptions:R,actions:M,currentProjectId:F,showProjectDropdown:eb,setShowProjectDropdown:ej,projectSearchQuery:ey,setProjectSearchQuery:ew,projectList:S,onProjectAssign:tv,isShowContracted:N,showExpenseId:C,onMenuOpen:tu,isScrolledToEnd:e3,setWorkOrderOpen:e0,setOpenProjectId:e8,setProjectDetailActiveTab:E},"".concat(e.obj_id,"-").concat(t))):(0,i.jsx)("tr",{className:"jsx-daf42ae5c1721118",children:(0,i.jsx)("td",{colSpan:(F?I.showExpensesToClassify?15:14:(I.showExpensesToClassify?16:15)+(N?1:0))+(O?1:0),className:"jsx-daf42ae5c1721118 px-6 py-12 text-center",children:(0,i.jsxs)("div",{className:"jsx-daf42ae5c1721118 flex flex-col items-center",children:[(0,i.jsx)("svg",{fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",className:"jsx-daf42ae5c1721118 w-12 h-12 text-[#E1E4EB] mb-4",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2",className:"jsx-daf42ae5c1721118"})}),(0,i.jsx)("p",{className:"jsx-daf42ae5c1721118 text-[#7C8293] text-base",children:"No expense records foun
1d"}),(0,i.jsx)("p",{className:"jsx-daf42ae5c1721118 text-[#9CA3AF] text-sm mt-1",children:"Try adjusting your filters or add a new expense"})]})})})})})})]}),(0,i.jsx)(tM,{expensesListCount:t.length,totalCount:n,totalExpense:s,formatPrice:tb,isLoadingMore:c,hasMore:f,loadMoreRef:b}),0!==t.length&&(0,i.jsx)(h.Z,{viewportRef:e5,label:"Expenses table horizontal scrollbar"})]}),(0,i.jsx)(eC.Z,{open:null!==e_,onClose:()=>{e2({}),eF(null)},handleDelete:tf,dialogTitle:"Delete Expense",dialogContentText:e_?"This will delete this expense from Eano only. It will remain unchanged in QuickBooks. This action cannot be undone.":"Are you sure you want to delete this expense? This action cannot be undone."}),(0,i.jsx)(ts,{open:eN,onClose:()=>{ek(!1),e2({}),e8(null)},itemExpense:e1,onRefreshData:_,projectList:S,currentProjectId:F,projectId:F||e6,setWorkOrderOpen:e0,setProjectDetailActiveTab:E}),X&&(0,i.jsx)(tL,{selectedExpensesCount:$.length,projectList:S,selectedProjectId:es,setSelectedProjectId:en,onCancel:()=>{J(!1),en("")},onAssign:tg}),(0,i.jsx)(ea,{itemExpense:e1,setItemExpense:e2,projectId:F||e6,open:eX,openScopeEdit:eN&&(null==e1?void 0:e1.source_type)===4,setOpen:e0,onRefreshData:_,setProjectDetailActiveTab:E,setOpenProjectId:e8,isInDetail:!!F,linkOnly:(null==e1?void 0:e1.source_type)===3}),ed&&(0,i.jsx)(ei,{open:ed,onClose:()=>{ec(!1),em(null)},expense:ep,onRefreshData:_,mode:eu}),(0,i.jsx)(x.Z,{anchorEl:eE,open:!!eE,onClose:tx,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},PaperProps:{style:{minWidth:120,boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",border:"1px solid #E1E4EB"}},children:z&&(null==eD?void 0:eD.source_type)!==1&&(null==eD?void 0:eD.source_type)!==2&&((null==eA?void 0:eA.eanoExpenseSyncQb)&&(null==eD?void 0:eD.qb_synced)?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(p.Z,{onClick:()=>tp(!1),style:{color:"#E12424",fontSize:"14px",padding:"8px 16px"},children:"Delete (Eano + QB)"}),(0,i.jsx)(p.Z,{onClick:()=>tp(!0),style:{color:"#E12424",fontSize:"14px",padding:"8px 16px"},children:"Delete (Eano Only)"})]}):(0,i.jsx)(p.Z,{onClick:()=>tp(!1),style:{color:"#E12424",fontSize:"14px",padding:"8px 16px"},children:"Delete"}))}),eM&&(0,i.jsx)(ta.Z,{open:eM,onClose:()=>eL(!1),onConfirm:async()=>{_&&await _()}}),(0,i.jsx)(tl.A,{open:eP,onClose:()=>eB(!1),onDisconnect:async()=>{let e=await M.handleDisconnectQuickBooks();return e&&(await M.fetchFinanceData(1,!1,!1),await M.fetchExpensesData(1,!1,!1)),e}}),O&&(0,i.jsx)(tc.r,{open:eZ,onClose:()=>eT(!1),invoiceId:eO,vendorId:"",onSuccess:()=>eT(!1)})]})},tT=e=>{var t,s;let{projectId:n,setProjectDetailActiveTab:a,projectList:l,setLocalFilters:r,localFilters:o,viewMode:c,onViewModeChange:u}=e,{expensesList:x,expensesTotal:p,expensesTotalCount:m,notAssignedProjectCount:h,loading:v,expensesLoadMoreRef:g,filters:f,actions:b,expensesPagination:j,financeData:y,hasQuickBooksConnection:w,hasQBData:N,isShowContracted:C,showExpenseId:k}=(0,d.pL)(),_=async()=>{await Promise.all([b.fetchExpensesData(1,!1,!1),b.fetchFinanceData()])};return(0,i.jsx)(tZ,{expensesList:x,totalExpense:p,totalCount:m,notAssignedProjectCount:h,loading:v.fullPage,tableLoading:v.tableOverlay,isLoadingMore:v.loadingMore,hasMore:j.hasMore||!1,loadMoreRef:g,onFilterChange:e=>{b.handleExpensesFilterChange(e)},hasQuickBooksConnection:w||!1,hasQBData:N||!1,isShowContracted:C||!1,showExpenseId:k||!1,quickBooksEmail:(null==y?void 0:null===(t=y.connect_info)||void 0===t?void 0:t.qb_email)||"",initialFilters:{dateRangeFilter:f.dateRangeFilter||0,sourceFilter:f.sourceFilter||"",categoryFilter:(null===(s=f.expenseCategory)||void 0===s?void 0:s.length)>0?f.expenseCategory[0]:""},projectList:l,localFilters:o,setLocalFilters:r,showExpensesToClassify:f.showExpensesToClassify||!1,onRefreshData:_,currentProjectId:f.projectId||n,setProjectDetailActiveTab:a,viewMode:c,onViewModeChange:u})},tO=s(6863);let tR={itemStyle:{shadowBlur:10,shadowColor:"rgba(0,0,0,0.3)"}},tz=e=>{let{className:t="",projectId:s}=e,{data:n={},isLoading:a}=(0,U.u)("/api/v1/finance/qb/expense/chart",async e=>(await (0,B.r)({url:e,params:s?{project_id:s}:null,noCamel:!0})).result),{vendor_grouped_data:l=[]}=n,r=(0,o.useMemo)(()=>({grid:{top:"10%",left:"5%",right:"5%",bottom:"15%",containLabel:!0},tooltip:{trigger:"axis",axisPointer:{type:"shadow"},formatter:e=>{if(!e||0===e.length)return"";let t=e[0].axisValue||"Unknown",s='<div style="font-weight: 600; margin-bottom: 8px;">'.concat(t,"</div>");
1return e.forEach(e=>{let t=e.value||0,n=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2}).format(t);s+='\n							<div style="display: flex; align-items: center; margin: 4px 0;">\n								<span style="display: inline-block; width: 10px; height: 10px; background: '.concat(e.color,'; border-radius: 50%; margin-right: 8px;"></span>\n								<span style="flex: 1;">').concat(e.seriesName,':</span>\n								<span style="font-weight: 500; margin-left: 12px;">').concat(n,"</span>\n							</div>\n						")}),s}},legend:{data:["Projected","Paid","Paid over budget","Contracted"],bottom:0,itemWidth:10,itemHeight:10,icon:"circle",textStyle:{color:"#7C8293",fontSize:12}},xAxis:{type:"category",data:l.map(e=>e.vendor_name||"Unknown"),axisLine:{onZero:!0},splitLine:{show:!1},splitArea:{show:!1},axisLabel:{interval:0,textStyle:{color:"#7C8293",fontSize:11},formatter:e=>e&&e.length>10?e.substring(0,10)+"...":e||""}},yAxis:{type:"value",axisLine:{show:!1},axisLabel:{color:"#7C8293",fontSize:11,formatter:e=>e>=1e6?"$".concat((e/1e6).toFixed(1),"M"):e>=1e3?"$".concat((e/1e3).toFixed(0),"k"):"$".concat(e.toFixed(0))},splitLine:{lineStyle:{color:"#EBECF0",type:"dashed"}}},series:[{name:"Projected",type:"bar",stack:"projected",data:l.map(e=>{let t=e.total_projected||0;return t>0?t:null}),emphasis:tR,color:"#C7D7EE"},{name:"Paid",type:"bar",stack:"paid",data:l.map(e=>{let t=e.total_paid||0;return t>0?t:null}),emphasis:tR,color:"#298FF7"},{name:"Paid over budget",type:"bar",stack:"paidover",data:l.map(e=>{let t=e.total_paid_over_budget||0;return t>0?t:null}),emphasis:tR,color:"#FE842C"},{name:"Contracted",type:"bar",stack:"contracted",data:l.map(e=>{let t=e.total_contracted||0;return t>0?t:null}),emphasis:tR,color:"#10CA8A"}]}),[n]);return a?(0,i.jsx)(eu.Z,{}):l&&0!==l.length?(0,i.jsx)("div",{className:"space-y-6 ".concat(t),children:(0,i.jsx)("div",{className:"bg-white rounded-xl border border-[#EBECF0] p-6",children:(0,i.jsx)(tO.Z,{option:r,style:{height:"300px"},opts:{renderer:"svg"}})})}):null};var tW=s(97618),tq=s(4814),tU=s(54671);let tV=e=>{let{subExpenses:t=[],formatCurrency:s,formatDate:n,onRefreshData:a,projectList:l,setProjectDetailActiveTab:r,currentProjectId:d}=e,[c,u]=(0,o.useState)(!1),[x,p]=(0,o.useState)({}),[m,h]=(0,o.useState)(null),[v,g]=(0,o.useState)(!1),[f,b]=(0,o.useState)(!1),j=e=>{p(e),h(e.project_id),g(!0)},y=async()=>{let e=await (0,B.r)({url:"/api/v1/finance/manual/expense/",method:"delete",params:{id:x.obj_id,sourceType:x.source_type}});e.isOk?(a(),b(!1),g(!1),p({}),(0,eh.k)("/api/v1/finance/qb/expense/chart"),ev.ZP.success("Delete success")):ev.ZP.error(e.resMessage||"Delete error")};return(0,i.jsxs)(i.Fragment,{children:[t.map((e,t)=>(0,i.jsxs)("tr",{className:"border-y border-gray-200 bg-[#F0F7FB] cursor-pointer hover:bg-[#E6F4FA] transition-colors",onClick:()=>j(e),children:[(0,i.jsx)("td",{className:"py-3 px-4",children:(0,i.jsx)("div",{className:"pl-11 text-sm text-gray-600",children:n(e.payment_date)})}),(0,i.jsx)("td",{className:"py-3 px-4 text-sm text-gray-900",children:e.description}),(0,i.jsx)("td",{className:"py-3 px-4",children:(0,i.jsx)(tF.Z,{paymentAccount:e.payment_account,fallbackMethod:e.payment_method,showDetail:!0,reference:e.payment_reference})}),(0,i.jsx)("td",{className:"py-3 px-4",children:(0,i.jsx)("span",{className:"text-sm text-gray-600"})}),(0,i.jsx)("td",{className:"py-3 px-4 text-sm text-gray-900 text-center"}),(0,i.jsx)("td",{className:"py-3 px-4 text-sm text-gray-900"}),(0,i.jsx)("td",{className:"py-3 px-4 text-sm  font-medium text-[#E12424]",children:s(e.actual_exp)}),(0,i.jsx)("td",{onClick:t=>{4===e.source_type&&(t.stopPropagation(),e.work_order_id?d&&(r("work_orders"),window.top.postMessage({type:"openWorkOrderDetail",data:{workOrderId:e.work_order_id}})):(u(!0),h(e.project_id),p({...e,scope_description:e.scope_description||e.description||"Work Order"})))},className:"py-3 px-4 text-sm text-en-blue",children:4===e.source_type?e.work_order_id?e.work_order_id_name:"+ New":(null==e?void 0:e.work_order_id_name)||"-"}),(0,i.jsx)("td",{className:"py-3 px-4 text-center",children:e.is_has_file&&(0,i.jsx)(tU.Z,{className:"w-4 h-4 text-gray-400 mx-auto"})}),(0,i.jsx)("td",{className:"py-3 px-4"})]},"".concat(e.obj_id,"-").concat(t))),(0,i.jsx)(ts,{open:v,onClose:()=>{g(!1),p(null),h(null)},itemExpense:x,onRefreshData:a,projectList:l,currentProjectId:d,projectId:d||m,setWorkOrderOpen:u,setProjectDetailActiveTab:r}),(0,i.jsx)(ea,{itemExpense:x,setItemExpense:p,projectId:d||m,open:c,openScopeEdit:v&&(null==x?void 0:x.source_type)===4,setOpen:u,onRefreshData:a,setProjectDetailActiveTab:r,setOpenProjectId:h,isInDetail:!!d}),(0,i.jsx)(eC.Z,{open:f,onClose:()=>{p({}),b(!1)},handleDelete:y,dialogTitle:"Delete Expense",dialogContentText:"Are you sure you want to delete this expense? This action cannot be undone."})]})},tQ=e=>{let{open:t,onClose:s,onSuccess:n,selectedExpense:a,useBatchApi:l=!0}=e,{categoryOptions:r}=(0,er.z)(),[d,c]=(0,o.useState)([]),[u,x]=(0,o.useState)(!1);(0,o.useEffect)(()=>{(null==a?void 0:a.category)?Array.isArray(a.category)&&c(a.category):c([])},[a]);let p=async()=>
1{if(a){x(!0);try{let e=d.map(e=>"string"==typeof e.id?parseInt(e.id,10):e.id);if(l){let t=a.items||[{id:"string"==typeof a.obj_id?parseInt(a.obj_id,10):a.obj_id,source_type:a.source_type||1}];(await (0,B.r)({url:"/api/v1/finance/batch/expense/category/",method:"post",params:{items:t.map(e=>({id:"string"==typeof e.id?parseInt(e.id,10):e.id,source_type:e.source_type})),categories:e},noCamel:!0})).result&&(g.y.success("Category updated successfully"),n(),s())}else await v.o.setExpenseCategory(a.obj_id,a.source_type||1,e.map(e=>String(e))),g.y.success("Category updated successfully"),n(),s()}catch(e){console.error("Failed to update category:",e),g.y.error("Failed to update category")}finally{x(!1)}}},m=e=>{c(t=>t.some(t=>t.id===e.id)?t.filter(t=>t.id!==e.id):[...t,{name:e.name,id:e.id}])};return t?(0,i.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,i.jsx)("div",{className:"absolute inset-0 bg-black/50",onClick:s}),(0,i.jsxs)("div",{className:"relative bg-white rounded-lg shadow-xl w-full max-w-md mx-4",children:[(0,i.jsxs)("div",{className:"flex items-center justify-between p-6 border-b border-gray-200",children:[(0,i.jsx)("h3",{className:"text-lg font-semibold text-gray-900",children:"Edit Category"}),(0,i.jsx)("button",{onClick:s,className:"text-gray-400 hover:text-gray-500 transition-colors",children:(0,i.jsx)(tm.Z,{className:"w-5 h-5"})})]}),(0,i.jsx)("div",{className:"p-6",children:(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsx)("label",{className:"text-sm font-medium text-gray-700 block mb-3",children:"Select Categories"}),(0,i.jsx)("div",{className:"max-h-64 overflow-y-auto space-y-2 border border-gray-200 rounded-lg p-3",children:r.map(e=>(0,i.jsxs)("label",{className:"flex items-center space-x-3 cursor-pointer hover:bg-gray-50 p-2 rounded",children:[(0,i.jsx)("input",{type:"checkbox",checked:d.some(t=>t.id===e.id),onChange:()=>m(e),className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"}),(0,i.jsx)("span",{className:"text-sm text-gray-900",children:e.name})]},e.id))}),0===r.length&&(0,i.jsx)("p",{className:"text-sm text-gray-500 text-center py-4",children:"No categories available"})]})}),(0,i.jsxs)("div",{className:"flex items-center justify-end gap-3 px-6 py-4 border-t border-gray-200",children:[(0,i.jsx)("button",{onClick:s,className:"px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 transition-colors",children:"Cancel"}),(0,i.jsx)("button",{onClick:p,disabled:u,className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-lg hover:bg-blue-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:u?"Saving...":"Save"})]})]})]}):null};var tH=s(90103);let tY=(0,E.ZP)(e=>{let{className:t,classes:s,...n}=e;return(0,i.jsx)(eR.Z,{...n,classes:{...s,popper:(0,tq.Z)(null==s?void 0:s.popper,t)}})})({["& .".concat(tH.Z.tooltip)]:{fontSize:13,maxWidth:320}}),tG=e=>{let{data:t,projectList:s,setProjectDetailActiveTab:n,currentProjectId:a}=e,[l,r]=(0,o.useState)(()=>new Set(t.map(e=>e.vendor_id))),[c,u]=(0,o.useState)(!1),[x,p]=(0,o.useState)(null),{actions:m}=(0,d.pL)(),h=async()=>{await m.fetchExpensesData(1,!1,!1)};o.useEffect(()=>{r(new Set(t.map(e=>e.vendor_id)))},[t]);let v=e=>{p(e),u(!0)},g=async()=>{m&&m.fetchExpensesData&&await m.fetchExpensesData(1,!1,!1)},f=e=>{r(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})},j=e=>{let t="string"==typeof e?parseFloat(e):e;return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(t)},y=e=>e?new Date(e).toLocaleDateString("en-US",{month:"2-digit",day:"2-digit",year:"numeric"}):"-";return(0,i.jsxs)("div",{className:"w-full",children:[(0,i.jsx)("div",{className:"overflow-auto max-h-[calc(100vh-300px)] rounded-t-xl",children:(0,i.jsxs)("table",{className:"w-full min-w-[1200px]",children:[(0,i.jsx)("thead",{className:"sticky top-0 z-10 bg-[#F7F8FA]",children:(0,i.jsxs)("tr",{className:"border-b border-[#EBECF0]",children:[(0,i.jsx)("th",{className:"text-left py-3 px-4 text-sm font-medium text-gray-600 whitespace-nowrap bg-[#F7F8FA]",children:(0,i.jsx)(tY,{arrow:!0,placement:"top",title:"The business listed on the receipt (e.g., Home Depot, gas station). When syncing from QuickBooks, the Payee maps here.).",children:(0,i.jsx)("span",{className:"border-b border-dashed border-[#7C8293] cursor-help",children:"Vendor"})})}),(0,i.jsx)("th",{className:"text-left py-3 px-4 text-sm font-medium text-gray-600 whitespace-nowrap bg-[#F7F8FA]",children:(0,i.jsx)(tY,{arrow:!0,placement:"top",title:"The person who paid this expense. If Worker A uploads the receipt, this field defaults to Worker A and cannot be edited by them. Admins can reassign the expense owner (e.g., to track subcontractor expenses and handle reimbursement).",children:(0,i.jsx)("span",{className:"border-b border-dashed border-[#7C8293] cursor-help",children:"Expense Owner"})})}),(0,i.jsx)("th",{className:"text-left py-3 px-4 text-sm font-medium text-gray-600 whitespace-nowrap bg-[#F7F8FA]",children:"Description"}),(0,i.jsx)("th",{className:"text-left py-3 px-4 text-sm font-medium text-gray-600 whitespace-nowrap bg-[#F7F8FA]",children:"Status"}),(0,i.jsx)("th",{className:"text-left py-3 px-4 text-sm font-medium text-gray-600 whitespace-nowrap bg-[#F7F8FA]",children:"Category"}),(0,i.jsx)("th",{className:"text-center py-3 px-4 text-sm font-medium text-gray-600 whitespace-nowrap bg-[#F7F8FA]",children:(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)("div",{children:"Projected Exp"}),(0,i.jsx)(A.Rs,{title:"The estimated cost based on the linked scope items or the amount entered for this expense."})]})}),(0,i.jsx)("th",{className:"text-left py-3 px-4 text-sm font-medium text-gray-600 whitespace-nowrap bg-[#F7F8FA]",children:(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)("div",{children:"Contracted"}),(0,i.jsx)(A.Rs,{title:"The agreed contract amount, shown when this expense is linked to a work order."})]})}),(0,i.jsx)("th",{className:"text-left py-3 px-4 text-sm font-medium text-gray-600 whitespace-nowrap bg-[#F7F8FA]",children:(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)("div",{children:"Actual Exp"}),(0,i.jsx)(A.Rs,{title:"The total amount spent so far on this expense."})]})}),(0,i.jsx)("th",{className:"text-left py-3 px-4 text-sm font-medium text-gray-600 whitespace-nowrap bg-[#F7F8FA]",children:"Work Order#"}),(0,i.jsx)("th",{className:"w-10 bg-[#F7F8FA]"})]})}),(0,i.jsx)("tbody",{children:t.map(e=>{var t,r,d,c,x;let m=l.has(e.vendor_id),g=null===e.vendor_id;return(0,i.jsxs)(o.Fragment,{children:[(0,i.jsxs)("tr",{className:"border-b border-gray-100 hover:bg-gray-50 cursor-pointer",onClick:()=>f(e.vendor_id),children:[(0,i.jsx)("td",{className:"py-3 px-4",children:(0,i.jsx)("div",{className:"flex items-center gap-3",children:g?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(th.Z,{className:"w-5 h-5 text-gray-400 transition-transform ".concat(m?"rotate-0":"-rotate-90")}),(0,i.jsx)("span",{children:"Unassigned vendor items"}),(0,i.jsxs)("span",{className:"text-xs text-gray-500 ml-2",children:[e.scope_count," scope item",1!==e.scope_count?"s":""]})]}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{className:"w-8 h-8 rounded-full bg-gray-200 flex items-center justify-center overflow-hidden relative",children:(0,i.jsx)(b(),{src:e.avatar_url||"/default-avatar.png",alt:e.vendor_name,fill:!0,className:"object-cover"})}),(0,i.jsx)("span",{className:"text-sm font-medium text-gray-900",children:e.vendor_name})]})})}),(0,i.jsx)("td",{className:"py-3 px-4",children:(0,i.jsx)("div",{className:"flex items-center gap-2",children:e.payee_name?(0,i.jsxs)(i.Fragment,{children:[e.payee_avatar_url?(0,i.jsx)("img",{src:e.payee_avatar_url,alt:"",className:"w-6 h-6 rounded-full flex-shrink-0 object-cover"}):(0,i.jsx)("div",{className:"w-6 h-6 rounded-full bg-[#3B4658] text-white text-xs flex items-center justify-center flex-shrink-0",children:e.payee_name.charAt(0).toUpperCase()}),(0,i.jsx)("span",{className:"text-sm text-gray-900",children:e.payee_name})]}):(0,i.jsx)("span",{className:"text-gray-400",children:"— —"})})}),(0,i.jsx)("td",{className:"py-3 px-4",children:(0,i.jsxs)("span",{className:"text-sm text-en-dark-blue",children:[null==e?void 0:e.scope_count," scope ",(null==e?void 0:e.scope_count)>1?"items":"item"]})}),(0,i.jsx)("td",{className:"py-3 px-4",children:(0,i.jsxs)("span",{className:"inline-flex items-center px-2.5 py-1 rounded-full text-xs font-medium",style:{backgroundColor:e.status_info.bg_color,color:e.status_info.color},children:[e.status_info.percentage&&"".concat(e.status_info.percentage," "),e.status_info.status_val]})}),(0,i.jsx)("td",{className:"py-3 px-4",children:e.categories&&e.categories.length>0?(0,i.jsx)("div",{className:"flex flex-wrap gap-1 cursor-pointer",onClick:t=>{t.stopPropagation();let s=e.sub_expenses.map(e=>({id:e.obj_id,source_type:e.source_type}));p({obj_id:e.vendor_id,items:s,category:e.categories||[]}),u(!0)},children:e.categories.map(e=>(0,i.jsx)("div",{className:"flex items-center gap-1 px-2 py-1 rounded-[13px] bg-[#E1E4EB]",children:(0,i.jsx)("span",{className:"text-xs text-[#051023]",children:e.name})},e.id))}):(0,i.jsxs)("button",{className:"flex items-center gap-1 text-[#0052CC] text-sm hover:text-[#0747A6]",onClick:t=>{t.stopPropagation();let s=e.sub_expenses.map(e=>({id:e.obj_id,source_type:e.source_type}));p({obj_id:e.vendor_id,items:s,category:[]}),u(!0)},children:[(0,i.jsx)("span",{children:"+"}),(0,i.jsx)("span",{children:"Assign"})]})}),(0,i.jsx)("td",{className:"py-3 px-4 text-sm text-gray-900 text-center",children:j(e.projected_ext)}),(0,i.jsx)("td",{className:"py-3 px-4",children:(0,i.jsx)("div",{className:"text-sm",children:j(null==e?void 0:null===(t=e.work_order_info)||void 0===t?void 0:t.work_order_price)})}),(0,i.jsx)("td",{className:"py-3 px-4 text-sm",style:{color:tA.k},children:(0,i.jsxs)("div",{className:"flex gap-0.5",children:[(0,i.jsx)("div",{children:j(e.total_actual_exp)}),(null===(r=e.sub_expenses)||void 0===r?void 0:r.length)>0&&(0,i.jsxs)("span",{className:"ml-2 text-14 text-[#B2B2B2] inline-flex items-center gap-1",children:[e.sub_expenses.length,(0,i.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,i.jsx)("path",{d:"M10.2105 6.5H2M10.2105 12.1316H4.73684C3.22533 12.1316 2 10.9063 2 9.39474L2 3",stroke:"#B2B2B2",strokeWidth:"1.3",strokeLinecap:"round"}),(0,i.jsx)("circle",{cx:"12",cy:"6.5",r:"1.35",stroke:"#B2B2B2",strokeWidth:"1.3"}),(0,i.jsx)("circle",{cx:"12",cy:"12",r:"1.35",stroke:"#B2B2B2",strokeWidth:"1.3"})]})]})]})}),(0,i.jsx)("td",{className:"py-3 px-4 text-sm",children:(null==e?void 0:null===(d=e.work_order_info)||void 0===d?void 0:d.work_order_count)===1?(0,i.jsx)("span",{className:"text-en-blue",children:null==e?void 0:null===(c=e.work_order_info)||void 0===c?void 0:c.work_order_id_name}):(0,i.jsxs)("span",{className:"text-gray-900",children:[null==e?void 0:null===(x=e.work_order_info)||void 0===x?void 0:x.work_order_count," orders"]})}),(0,i.jsx)("td",{className:"py-3 px-4",children:m?(0,i.jsx)(tW.Z,{className:"w-5 h-5 text-gray-400"}):(0,i.jsx)(th.Z,{className:"w-5 h-5 text-gray-400"})})]}),m&&(0,i.jsx)(tV,{subExpenses:e.sub_expenses,formatCurrency:j,formatDate:y,onCategoryClick:v,onRefreshData:h,projectList:s,setProjectDetailActiveTab:n,currentProjectId:a})]},e.vendor_id)})})]})}),x&&(0,i.jsx)(tQ,{open:c,onClose:()=>{u(!1),p(null)},onSuccess:g,selectedExpense:x})]})};var t$=s(10025),tK=s(51521),tX=s(80074);let tJ="/api/v1/finance/scope/budget_detail/",t0=async e=>{let t=await (0,B.r)({url:e});if(!t.isOk)throw Error(t.resMessage||"Failed to load budget detail");return t.result},t1=e=>{let{projectId:t,scopeId:s,groupId:n,nodeType:a}=e;return"".concat(tJ,"?project_id=").concat(t,"&scope_id=").concat(null!=s?s:"","&group_id=").concat(null!=n?n:"","&node_type=").concat(a)},t2=e=>t=>"string"==typeof t&&t.startsWith("".concat(tJ,"?project_id=").concat(e,"&")),t4=e=>{let{enabled:t,projectId:s,scopeId:n=null,groupId:a=null,nodeType:l}=e,{data:r,isLoading:i,error:d,mutate:c}=(0,U.u)(t&&s&&l?t1({projectId:s,scopeId:n,groupId:a,nodeType:l}):null,t0,{revalidateOnFocus:!1,revalidateOnReconnect:!1});return(0,o.useEffect)(()=>{d&&ev.ZP.error(d instanceof Error?d.message:"Failed to load budget detail")},[d]),{detail:r,isLoading:i,error:d,mutate:c}};var t5=s(20896),t3=s(56391),t6=s(90170);let t8={healthy:{className:"bg-[#EBF7EB] text-[#257829]",Icon:(0,i.jsx)(t3.Z,{className:"text-[#35AB3B]"})},eroding:{className:"bg-[#FFF7E4] text-[#B25C1F] border-[#FE842C]",Icon:(0,i.jsx)(()=>(0,i.jsxs)("svg",{width:"19",height:"18",viewBox:"0 0 19 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,i.jsx)("path",{d:"M7.97955 1.72021C8.53396 0.75993 9.92 0.759932 10.4744 1.72021L17.959 14.6839C18.5134 15.6442 17.8204 16.8446 16.7116 16.8446H1.74236C0.633534 16.8446 -0.0594827 15.6442 0.494933 14.6839L7.97955 1.72021Z",fill:"#FE842C"}),(0,i.jsx)("path",{d:"M8.93555 11.7051C9.37622 11.7049 9.7334 11.3856 9.7334 10.9922V6.71777C9.7334 6.32436 9.37622 6.00503 8.93555 6.00488
1C8.49474 6.00488 8.13672 6.32427 8.13672 6.71777V10.9922C8.13672 11.3857 8.49474 11.7051 8.93555 11.7051ZM9.06445 14.8975C9.65208 14.8973 10.1279 14.4207 10.1279 13.833C10.1278 13.2455 9.65199 12.7697 9.06445 12.7695C8.4768 12.7695 8.00014 13.2454 8 13.833C8 14.4207 8.47671 14.8975 9.06445 14.8975Z",fill:"white"})]}),{})},wipedOut:{className:"bg-[#FCE9E9] text-[#9D1919] border-[#E12424]",Icon:(0,i.jsx)(t6.Z,{className:"text-[#E12424]"})}};var t7=e=>{let{margin:t,budgeted:s}=e,n=(0,tX.EP)(t,s);if(!n)return null;let{className:a,Icon:l}=t8[n.state];return(0,i.jsxs)("div",{className:"flex items-center gap-2 rounded-lg px-3 border py-2 mt-4 text-16 ".concat(a),children:[l,n.text]})};let t9={healthy:"#35AB3B",eroding:"#FE842C",wipedOut:"#F02326"};var se=e=>{var t;let{budgeted:s,allocated:n,margin:a}=e,l=(0,tX.EP)(a,s),r=t9[null!==(t=null==l?void 0:l.state)&&void 0!==t?t:n>s?"wipedOut":"healthy"],o=s>0?Math.min(100,n/s*100):n>0?100:0;return(0,i.jsxs)("div",{className:"max-w-[600px]",children:[(0,i.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,i.jsx)("span",{className:"text-16 font-medium text-[#051023]",children:"Budget"}),(0,i.jsxs)("span",{className:"text-16 text-[#051023]",children:[(0,t5.E)(n,!0)," allocated of ",(0,t5.E)(s,!0)]})]}),(0,i.jsx)("div",{className:"h-3 rounded-full bg-[#EBECF0] overflow-hidden",children:(0,i.jsx)("div",{className:"h-full rounded-full",style:{width:"".concat(o,"%"),backgroundColor:r}})}),(0,i.jsx)(t7,{margin:a,budgeted:s})]})},st=e=>{let{pct:t}=e;if(null===t)return null;let s=t>100;return(0,i.jsx)(P.Z,{arrow:!0,placement:"top",title:"Shows the percentage of this budget currently allocated to expenses.",children:(0,i.jsx)("span",{className:"ml-2 inline-block rounded border px-2 py-0.5 text-xs font-medium ".concat(s?"border-[#FCD3D4] bg-[#FDE9E9] text-[#A8191B]":"border-[#C8D9C9] bg-[#EBF7EB] text-[#257829]"),children:(0,tX.Vm)(t)})})},ss=s(51488);let sn=e=>{let{vendor:t,vendorAvatar:s,isVendorPending:n}=e;return t?(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[s?(0,i.jsx)(b(),{src:s,alt:t,width:20,height:20,className:"w-5 h-5 rounded-full object-cover flex-shrink-0"}):(0,i.jsx)("div",{className:"w-5 h-5 rounded-full bg-[#E8E8E8] flex items-center justify-center flex-shrink-0",children:(0,i.jsx)("span",{className:"text-[10px] font-medium text-[#666666]",children:t.charAt(0).toUpperCase()})}),(0,i.jsx)("span",{children:t})]}):(0,i.jsx)("span",{className:"text-[#7C8293]",children:n?"Vendor Pending":"No vendor"})},sa=e=>{let{item:t,onClick:s}=e;return(0,i.jsxs)("tr",{className:"cursor-pointer hover:bg-[#F2F6FC]",onClick:()=>s(t),children:[(0,i.jsx)("td",{className:"py-3 text-sm text-[#051023] pl-2",children:t.description||""}),(0,i.jsx)("td",{className:"py-3 text-sm text-[#051023]",children:(0,i.jsx)(sn,{vendor:t.vendor,vendorAvatar:t.vendorAvatar,isVendorPending:t.isVendorPending})}),(0,i.jsxs)("td",{className:"py-3 text-sm font-medium text-[#051023]",children:[(0,tX.dN)(t.billingAmount),(0,i.jsx)(st,{pct:t.allocationPct})]}),(0,i.jsx)("td",{className:"py-3 text-sm font-medium text-[#051023]",children:(0,tX.dN)(t.contracted)}),(0,i.jsx)("td",{className:"py-3 text-sm font-medium text-[#F02326]",children:(0,tX.dN)(t.paid)})]})},sl=e=>{let{node:t,onOpenGroupItem:s}=e;return(0,i.jsxs)("tr",{className:"cursor-pointer bg-[#F4F5F7] hover:bg-[#EBECF0]",onClick:()=>s(t),children:[(0,i.jsx)("td",{className:"py-3 text-sm font-medium text-[#051023] pl-2",children:t.name}),(0,i.jsx)("td",{className:"py-3 text-sm ".concat((0,tX.U1)(t.vendorLabel)),children:t.vendorLabel}),(0,i.jsxs)("td",{className:"py-3 text-sm font-medium text-[#051023]",children:[(0,tX.dN)(t.billingAmount),(0,i.jsx)(st,{pct:t.allocationPct})]}),(0,i.jsx)("td",{className:"py-3 text-sm font-medium text-[#051023]",children:(0,tX.dN)(t.contracted)}),(0,i.jsx)("td",{className:"py-3 text-sm font-medium text-[#F02326]",children:(0,tX.dN)(t.paid)})]})},sr=e=>{let{nodes:t,onExpenseClick:s,onOpenGroupItem:n}=e;return(0,i.jsx)(i.Fragment,{children:t.map(e=>(0,ss.S)(e)?(0,i.jsx)(sl,{node:e,onOpenGroupItem:n},(0,tX.rt)(e)):(0,i.jsx)(sa,{item:e,onClick:s},e.id))})};var si=e=>{let{items:t,groupChildren:s,onExpenseClick:n,onOpenGroupItem:a,onAddExpense:l,addExpenseDisabled:r}=e;return(0,i.jsxs)("div",{children:[(0,i.jsxs)("table",{className:"w-full table-fixed",children:[(0,i.jsxs)("colgroup",{children:[(0,i.jsx)("col",{}),(0,i.jsx)("col",{className:"w-[180px]"}),(0,i.jsx)("col",{className:"w-[140px]"}),(0,i.jsx)("col",{className:"w-[140px]"}),(0,i.jsx)("col",{className:"w-[140px]"})]}),(0,i.jsx)("thead",{children:(0,i.jsxs)("tr",{className:"text-sm text-[#7C8293] border-y border-[#D7D9DD] bg-[#F4F5F7]",children:[(0,i.jsx)("th",{className:"text-left font-medium py-2 pl-2",children:"Description"}),(0,i.jsx)("th",{className:"text-left font-medium py-2",children:"Vendor"}),(0,i.jsx)("th",{className:"text-left font-medium py-2",children:"Billing Amount"}),(0,i.jsx)("th",{className:"text-left font-medium py-2",children:"Contracted"}),(0,i.jsx)("th",{className:"text-left font-medium py-2",children:"Paid"})]})}),(0,i.jsx)("tbody",{className:"divide-y divide-[#D7D9DD] border-b border-[#D7D9DD]",children:s?(0,i.jsx)(sr,{nodes:s,onExpenseClick:n,onOpenGroupItem:a}):t.map(e=>(0,i.jsx)(sa,{item:e,onClick:n},e.id))})]}),(0,i.jsx)("button",{type:"button",disabled:r,onClick:l,className:"mt-2 text-14 text-en-blue disabled:text-[#A0A5B1] disabled:cursor-not-allowed hover:underline",children:"+ Add new expense"})]})},so=s(85326),sd=s(50744);let sc=(e,t)=>e===sd.Rv?"".concat(t,"%"):(0,tX.dN)(t),su=e=>{let{label:t,children:s}=e;return(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:"text-16 text-en-mid-blue mb-1",children:t}),(0,i.jsx)("div",{className:"text-16 font-medium text-en-dark-blue",children:s})]})},sx=e=>{let{costType:t,quantity:s,unit:n,unitCost:a,markupType:l,markupVal:r,price:o}=e;
1return(0,i.jsxs)("div",{className:"grid grid-cols-6 gap-4 rounded-lg py-3",children:[(0,i.jsx)(su,{label:"Cost Type",children:(0,i.jsx)(so.Z,{type:t})}),(0,i.jsx)(su,{label:"Quantity",children:s}),(0,i.jsx)(su,{label:"Units",children:(0,i.jsx)("span",{className:"whitespace-normal [overflow-wrap:anywhere]",children:n})}),(0,i.jsx)(su,{label:"Unit Cost",children:(0,tX.dN)(a)}),(0,i.jsx)(su,{label:"Markup",children:sc(l,r)}),(0,i.jsx)(su,{label:"Total",children:(0,tX.dN)(o)})]})},sp=e=>{let{costType:t,price:s}=e;return(0,i.jsxs)("div",{className:"grid grid-cols-6 gap-4 rounded-lg py-3",children:[(0,i.jsx)(su,{label:"Cost Type",children:(0,i.jsx)(so.Z,{type:t})}),(0,i.jsx)(su,{label:"Total",children:(0,tX.dN)(s)})]})};var sm=e=>{var t;let{recap:s}=e;return Array.isArray(s)?(0,i.jsx)("div",{className:"divide-y divide-[#D7D9DD]",children:s.map(e=>e.isIncluded?null:e.simpleMode?(0,i.jsx)(sp,{costType:e.costType,price:e.price},e.scopeId):(0,i.jsx)(sx,{costType:e.costType,quantity:e.quantity,unit:e.unit,unitCost:e.unitCost,markupType:e.markupType,markupVal:e.markupVal,price:e.price},e.scopeId))}):(0,i.jsxs)("div",{className:"grid grid-cols-3 gap-4 py-3",children:[(0,i.jsx)(su,{label:"Group Cost",children:(0,tX.dN)(null!==(t=s.groupCost)&&void 0!==t?t:0)}),(0,i.jsx)(su,{label:"Markup",children:(0,tX.dN)(s.markupAmount)}),(0,i.jsx)(su,{label:"Total",children:(0,tX.dN)(s.total)})]})};let sh=e=>{var t,s;return{id:String("group"===e.nodeType?e.groupId:e.scopeId),name:e.name,subProjectName:null!==(t=e.subProjectName)&&void 0!==t?t:void 0,groupName:null!==(s=e.groupName)&&void 0!==s?s:void 0,price:e.budget.budgeted,allocatedAmount:e.budget.allocated,residualPrice:e.budget.residualPrice,isGroup:"group"===e.nodeType}},sv=e=>{var t,s;let{open:n,onClose:a,projectId:l,scopeId:r,groupId:d,nodeType:c,initialName:u,node:x=null,onExpenseClick:p,onAddExpense:m,onViewInScope:h}=e,{detail:v,isLoading:g,error:f}=t4({enabled:n,projectId:l,scopeId:r,groupId:d,nodeType:c}),[b,j]=(0,o.useState)(null),y=()=>{v&&m(sh(v))},w=()=>{j(null),a()},N=()=>{j(null),h()};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(ed.ZP,{anchor:"right",open:n,onClose:w,PaperProps:{style:{width:"80vw"}},children:(0,i.jsxs)("div",{className:"relative p-8 h-full overflow-y-auto",children:[(0,i.jsx)(tK.T,{className:"absolute top-8 right-8 cursor-pointer z-10",onClick:w}),(0,i.jsxs)("div",{className:"mb-2",children:[(0,i.jsxs)("h2",{className:"text-24 font-medium text-[#051023]",children:['Budget for "',null!==(t=null==v?void 0:v.name)&&void 0!==t?t:u,'"']}),(0,i.jsx)("button",{type:"button",className:"text-14 text-en-blue",onClick:N,children:"View this item in scope >"})]}),f?(0,i.jsx)("p",{className:"text-sm text-[#F02326] py-6",children:"Couldn't load this budget's details. Please try again."}):g||!v?(0,i.jsx)(eu.Z,{}):(0,i.jsxs)("div",{className:"flex flex-col gap-6 mt-6",children:[(0,i.jsx)(se,{budgeted:v.budget.budgeted,allocated:v.budget.allocated,margin:v.margin}),(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:"text-16 font-medium text-[#051023] mb-2",children:"Add an expense"}),(0,i.jsx)("button",{type:"button",onClick:y,className:"rounded-lg border border-[#D7D9DD] px-4 py-2 text-sm font-medium text-[#051023]",children:"+ Create expense manually"})]}),v.recap&&(0,i.jsx)(sm,{recap:v.recap}),(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:"text-16 font-medium text-[#051023] mb-2",children:"Expense Items"}),(0,i.jsx)(si,{items:v.expenseItems,groupChildren:"group"===v.nodeType&&null!==(s=null==x?void 0:x.children)&&void 0!==s?s:void 0,onExpenseClick:e=>{p({id:e.id,sourceType:e.sourceType})},onOpenGroupItem:j,onAddExpense:y,addExpenseDisabled:!1})]})]})]})}),b&&(0,i.jsx)(sv,{open:!0,onClose:()=>j(null),projectId:l,scopeId:b.scopeId,groupId:b.groupId,nodeType:b.nodeType,initialName:(0,tX.Sq)(b.name).name,onExpenseClick:p,onAddExpense:m,onViewInScope:N})]})};var sg=s(84850);let sf=e=>{let{label:t,tooltip:s}=e;return(0,i.jsx)("th",{className:"px-4 py-3 text-left text-14 font-medium text-[#7C8293] bg-[#F3F3F3]",children:s?(0,i.jsx)(P.Z,{arrow:!0,placement:"top",title:s,children:(0,i.jsx)("span",{className:"border-b border-dashed border-[#7C8293] cursor-help",children:t})}):t})};var sb=()=>(0,i.jsx)("thead",{className:"bg-[#F3F3F3]",children:(0,i.jsxs)("tr",{className:"border-b border-[#
1EBECF0]",children:[(0,i.jsx)("th",{className:"py-3 pl-4 text-left text-14 font-medium text-[#7C8293] bg-[#F3F3F3]",children:"Description"}),(0,i.jsx)(sf,{label:"Vendor"}),(0,i.jsx)(sf,{label:"Budget",tooltip:"Amount from the linked scope item, excluding markup."}),(0,i.jsx)(sf,{label:"Billing Amount",tooltip:"Displays the Billing Amount saved for this expense."}),(0,i.jsx)(sf,{label:"Contracted",tooltip:"Amount from the linked subcontract."}),(0,i.jsx)(sf,{label:"Paid"})]})}),sj=e=>{let{expense:t,level:s,onClick:n,showTreeLine:a=!0}=e;return(0,i.jsxs)("tr",{className:"bg-[#F0F7FB] cursor-pointer",onClick:()=>n(t),children:[(0,i.jsxs)("td",{className:"py-3 relative",style:{paddingLeft:16+20*s},children:[a&&(0,i.jsx)("span",{className:"absolute inset-y-0 w-px bg-[#D7D9DD]",style:{left:(0,tX.e0)(s)}}),(0,i.jsx)("span",{className:"text-sm text-[#051023]",children:t.description||""})]}),(0,i.jsx)("td",{className:"px-4 py-3 text-sm text-[#051023]",children:t.vendor?(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[t.vendorAvatar?(0,i.jsx)("img",{src:t.vendorAvatar,alt:t.vendor,className:"w-5 h-5 rounded-full object-cover flex-shrink-0"}):(0,i.jsx)("div",{className:"w-5 h-5 rounded-full bg-[#E8E8E8] flex items-center justify-center flex-shrink-0",children:(0,i.jsx)("span",{className:"text-[10px] font-medium text-[#666666]",children:t.vendor.charAt(0).toUpperCase()})}),(0,i.jsx)("span",{children:t.vendor})]}):(0,i.jsx)("span",{className:"text-[#7C8293]",children:t.isVendorPending?"Vendor Pending":"No vendor"})}),(0,i.jsx)("td",{className:"px-4 py-3 text-sm text-[#CCC]",children:(0,tX.dP)(null)}),(0,i.jsxs)("td",{className:"px-4 py-3 text-sm font-medium text-[#051023]",children:[(0,tX.dN)(t.billingAmount),(0,i.jsx)(st,{pct:t.allocationPct})]}),(0,i.jsx)("td",{className:"px-4 py-3 text-sm font-medium text-[#051023]",children:(0,tX.dN)(t.contracted)}),(0,i.jsx)("td",{className:"px-4 py-3 text-sm font-medium text-[#F02326]",children:(0,tX.dN)(t.paid)})]})};let sy=e=>{var t;let{node:s,level:n,expandedIds:a,onToggle:l,onExpenseClick:r,onOpenBudgetDetail:o,onAddExpense:d,subProjectName:c=null,groupName:u=null,ancestorBudgetContext:x=null}=e,p=(0,tX.rt)(s),m=a.has(p),h=(0,tX.Sq)(s.name),v=null!==(t=h.subProjectName)&&void 0!==t?t:c,g=0===n?h.name:u,f=(0===n?[v,h.name]:[v,u,h.name]).filter(e=>!!e).join(" - "),b=null!==s.budget?{budget:s.budget,allocated:s.allocated,residualPrice:s.residualPrice}:x;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("tr",{className:"cursor-pointer border-t border-[#D7D9DD] ".concat(0===n?"bg-[#F4F5F7] hover:bg-[#EBECF0]":"hover:bg-[#F7F8FA]"),onClick:()=>o(s),children:[(0,i.jsx)("td",{className:"py-3",style:{paddingLeft:16+20*n},children:(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)("span",{role:"button","aria-label":m?"Collapse":"Expand",className:"flex-shrink-0",onClick:e=>{e.stopPropagation(),l(p)},children:(0,i.jsx)("svg",{className:"w-4 h-4 text-gray-500 transition-transform ".concat(m?"rotate-90":""),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}),(0,i.jsx)("span",{className:"text-sm font-medium text-[#051023] hover:underline",children:s.name}),(0,i.jsx)(P.Z,{arrow:!0,placement:"top",title:(0,i.jsxs)(i.Fragment,{children:["Linked to Scope: ",(0,i.jsx)("br",{}),f]}),children:(0,i.jsx)("div",{className:"w-5 h-5 rounded-full bg-[#E9F1FD] flex justify-center items-center flex-shrink-0",children:(0,i.jsx)(A.UO,{})})})]})}),(0,i.jsx)("td",{className:"px-4 py-3 text-sm ".concat((0,tX.U1)(s.vendorLabel)),children:s.vendorLabel}),(0,i.jsx)("td",{className:"px-4 py-3 text-sm text-[#051023]",children:(0,tX.dP)(s.budget)}),(0,i.jsxs)("td",{className:"px-4 py-3 text-sm font-medium text-[#051023]",children:[(0,tX.dN)(s.billingAmount),(0,i.jsx)(st,{pct:s.allocationPct})]}),(0,i.jsx)("td",{className:"px-4 py-3 text-sm font-medium text-[#051023]",children:(0,tX.dN)(s.contracted)}),(0,i.jsx)("td",{className:"px-4 py-3 text-sm font-medium text-[#F02326]",children:(0,tX.dN)(s.paid)})]}),m&&(0,i.jsxs)(i.Fragment,{children:[s.children.map(e=>(0,ss.S)(e)?(0,i.jsx)(sy,{node:e,level:n+1,expandedIds:a,onToggle:l,onExpenseClick:r,onOpenBudgetDetail
1:o,onAddExpense:d,subProjectName:v,groupName:g,ancestorBudgetContext:b},(0,tX.rt)(e)):(0,i.jsx)(sj,{expense:e,level:n+1,onClick:r,showTreeLine:n>1},e.id)),(0,i.jsx)("tr",{className:"cursor-pointer hover:bg-[#F7F8FA]",style:{backgroundColor:"group"!==s.nodeType&&n>0?"#F0F7FB":""},onClick:()=>d(s,v,b),children:(0,i.jsxs)("td",{className:"py-2 relative",colSpan:6,style:{paddingLeft:16+(n+1)*20},children:["group"!==s.nodeType&&n>0&&(0,i.jsx)("span",{className:"absolute inset-y-0 w-px bg-[#D7D9DD]",style:{left:(0,tX.e0)(n+1)}}),(0,i.jsx)("span",{className:"text-14 text-en-blue",children:"+ Add new expense"})]})})]})]})};var sw=e=>{let{unassigned:t,expanded:s,onToggle:n,onExpenseClick:a,onAddExpense:l}=e;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("tr",{className:"hover:bg-[#F7F8FA] cursor-pointer border-t border-[#EBECF0]",onClick:n,children:[(0,i.jsx)("td",{className:"py-3 pl-4",children:(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)("svg",{className:"w-4 h-4 text-gray-500 transition-transform ".concat(s?"rotate-90":""),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),(0,i.jsx)("span",{className:"text-sm font-medium text-[#051023]",children:"Unassigned"})]})}),(0,i.jsx)("td",{className:"px-4 py-3 text-sm ".concat((0,tX.U1)(t.vendorLabel)),children:(0,i.jsx)("span",{children:t.vendorLabel})}),(0,i.jsx)("td",{className:"px-4 py-3 text-sm text-[#CCC]"}),(0,i.jsx)("td",{className:"px-4 py-3 text-sm font-medium text-[#051023]",children:(0,tX.dN)(t.billingAmount)}),(0,i.jsx)("td",{className:"px-4 py-3 text-sm font-medium text-[#051023]",children:(0,tX.dN)(t.contracted)}),(0,i.jsx)("td",{className:"px-4 py-3 text-sm font-medium text-[#F02326]",children:(0,tX.dN)(t.paid)})]}),s&&(0,i.jsxs)(i.Fragment,{children:[t.children.map(e=>(0,i.jsx)(sj,{expense:e,level:1,onClick:a,showTreeLine:!1},e.id)),(0,i.jsx)("tr",{className:"cursor-pointer hover:bg-[#F7F8FA]",onClick:l,children:(0,i.jsx)("td",{className:"py-2 pl-9",colSpan:6,children:(0,i.jsx)("span",{className:"text-14 text-en-blue",children:"+ Add new expense"})})})]})]})};let sN="__unassigned__",sC=()=>(0,i.jsxs)("colgroup",{children:[(0,i.jsx)("col",{}),(0,i.jsx)("col",{className:"w-[160px]"}),(0,i.jsx)("col",{className:"w-[160px]"}),(0,i.jsx)("col",{className:"w-[160px]"}),(0,i.jsx)("col",{className:"w-[160px]"}),(0,i.jsx)("col",{className:"w-[160px]"})]});var sk=e=>{let{nodes:t,unassigned:s,total:n,expandedIds:a,onToggle:l,onExpenseClick:r,onOpenBudgetDetail:d,onAddExpense:c}=e,{headerScrollRef:u,bodyScrollRef:x}=function(){let e=(0,o.useRef)(null),t=(0,o.useRef)(null),s=(0,o.useRef)(!1),n=(0,o.useRef)(!1);return(0,o.useEffect)(()=>{let a=null,l=l=>{null!==a&&cancelAnimationFrame(a),a=requestAnimationFrame(()=>{e.current&&t.current&&("header"===l?(n.current=!0,t.current.scrollLeft=e.current.scrollLeft):(s.current=!0,e.current.scrollLeft=t.current.scrollLeft))})},r=()=>{if(s.current){s.current=!1;return}l("header")},i=()=>
1{if(n.current){n.current=!1;return}l("body")},o=e.current,d=t.current;return null==o||o.addEventListener("scroll",r,{passive:!0}),null==d||d.addEventListener("scroll",i,{passive:!0}),()=>{null!==a&&cancelAnimationFrame(a),null==o||o.removeEventListener("scroll",r),null==d||d.removeEventListener("scroll",i)}},[]),{headerScrollRef:e,bodyScrollRef:t}}();return(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:"sticky top-0 z-20",children:(0,i.jsx)("div",{ref:u,className:"overflow-x-auto overflow-y-hidden scrollbar-hide",children:(0,i.jsxs)("table",{className:"w-full min-w-[1260px] table-fixed",children:[(0,i.jsx)(sC,{}),(0,i.jsx)(sb,{})]})})}),(0,i.jsx)("div",{ref:x,className:"overflow-x-auto",children:(0,i.jsxs)("table",{className:"w-full min-w-[1260px] table-fixed",children:[(0,i.jsx)(sC,{}),(0,i.jsxs)("tbody",{className:"divide-y divide-[#EBECF0]",children:[t.map(e=>(0,i.jsx)(sy,{node:e,level:0,expandedIds:a,onToggle:l,onExpenseClick:r,onOpenBudgetDetail:d,onAddExpense:c},(0,tX.rt)(e))),(0,i.jsx)(sw,{unassigned:s,expanded:a.has(sN),onToggle:()=>l(sN),onExpenseClick:r,onAddExpense:()=>c(null)}),(0,i.jsxs)("tr",{className:"bg-[#F4F5F7]",children:[(0,i.jsx)("td",{className:"px-4 py-3 text-sm font-medium text-[#051023]",children:"Total"}),(0,i.jsx)("td",{className:"px-4 py-3",colSpan:4}),(0,i.jsx)("td",{className:"px-4 py-3 text-sm font-medium text-[#F02326]",children:(0,tX.dN)(n.paid)})]})]})]})})]})};let s_=(e,t,s)=>({id:String("group"===e.nodeType?e.groupId:e.scopeId),name:(0,tX.Sq)(e.name).name,subProjectName:null!=t?t:void 0,price:null==s?void 0:s.budget,allocatedAmount:null==s?void 0:s.allocated,residualPrice:null==s?void 0:s.residualPrice,isGroup:"group"===e.nodeType});var sF=e=>{var t,s,n,a;let{projectId:l,projectList:r,setProjectDetailActiveTab:d}=e,{nodes:c,unassigned:u,total:x,isLoading:p,mutate:m}=(0,eJ.i)(l);(0,sg.jY)(sg.FK.FINANCES,()=>m());let[h,v]=(0,o.useState)(new Set),g=(0,o.useRef)(null);(0,o.useEffect)(()=>{p||g.current===l||(g.current=l,v(new Set([...(0,tX.Qp)(c),sN])))},[p,c,l]);let[f,b]=(0,o.useState)(!1),[j,y]=(0,o.useState)(void 0),[w,N]=(0,o.useState)({}),[C,k]=(0,o.useState)(!1),[_,F]=(0,o.useState)(!1),[E,S]=(0,o.useState)(null),D=E?null!==(t=(0,tX.f_)(c,(0,tX.rt)(E)))&&void 0!==t?t:E:null,I=e=>{N({obj_id:e.id,source_type:e.sourceType}),k(!0)},A=()=>{(0,eh.k)(t2(l))},P=async()=>{await m(),A()};return p?(0,i.jsx)(eu.Z,{}):(0,i.jsxs)("div",{className:"",children:[(0,i.jsx)("div",{className:"bg-white",children:(0,i.jsx)(sk,{nodes:c,unassigned:u,total:x,expandedIds:h,onToggle:e=>{v(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})},onExpenseClick:I,onOpenBudgetDetail:S,onAddExpense:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;y(e?s_(e,t,s):void 0),b(!0)}})}),(0,i.jsx)(t$.Y,{open:f,onClose:()=>b(!1),currentProjectId:l,lockedScope:j,onSuccess:()=>{m(),A()}}),(0,i.jsx)(sv,{open:!!E,onClose:()=>S(null),projectId:l,scopeId:null!==(s=null==E?void 0:E.scopeId)&&void 0!==s?s:null,groupId:null!==(n=null==E?void 0:E.groupId)&&void 0!==n?n:null,nodeType:null!==(a=null==E?void 0:E.nodeType)&&void 0!==a?a:"scope_item",initialName:E?(0,tX.Sq)(E.name).name:"",node:D,onExpenseClick:I,onAddExpense:e=>{y(e),b(!0)},onViewInScope:()=>{S(null),null==d||d("scope")}}),(0,i.jsx)(ts,{open:C,onClose:()=>{k(!1),N({})},itemExpense:w,onRefreshData:P,projectList:r,currentProjectId:l,projectId:l,setWorkOrderOpen:F,setProjectDetailActiveTab:d}),(0,i.jsx)(ea,{itemExpense:w,setItemExpense:N,projectId:l,open:_,openScopeEdit:C&&(null==w?void 0:w.source_type)===4,setOpen:F,onRefreshData:P,setProjectDetailActiveTab:d,isInDetail:!0,linkOnly:(null==w?void 0:w.source_type)===3})]})};(a=r||(r={}))[a.table=0]="table",a[a.scope=1]="scope",a[a.vendor=2]="vendor";let sE=e=>1===e?"scope":2===e?"vendor":"table",sS=e=>"scope"===e?1:"vendor"===e?2:0,sD=e=>0===e?void 0:e,sI=e=>{let{setLocalFilters:t,localFilters:s,projectList:n,projectId:a,setProjectDetailActiveTab:l}=e,{filters:r,actions:c,expensesList:u}=(0,d.pL)(),[x,p]=(0,o.useState)(r.profitBy?r.profitBy:0);o.useEffect(()=>{r.profitBy&&r.profitBy!==x&&p(r.profitBy)},[r.profitBy]);let m=e=>{p(e),c.handleExpensesFilterChange({...r,profitBy:sD(e)})},h=1!==x||a?x:0,v=sE(h);return 0===h?(0,i.jsx)(tT,{setLocalFilters:t,localFilters:s,projectList:n,setProjectDetailActiveTab:l,viewM
1ode:v,onViewModeChange:e=>m(sS(e))}):(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:"flex justify-end mb-4",children:(0,i.jsx)(tw,{mode:v,onChange:e=>m(sS(e)),showScopeOption:!!a})}),1===h?(0,i.jsx)(sF,{projectId:a,projectList:n,setProjectDetailActiveTab:l}):(0,i.jsxs)("div",{className:"space-y-6",children:[(0,i.jsx)(tz,{projectId:a}),(0,i.jsxs)("div",{children:[(0,i.jsx)("h3",{className:"text-lg font-semibold text-[#051023] mb-4",children:"Expense Details"}),(0,i.jsx)(tG,{data:u,projectList:n,setProjectDetailActiveTab:l,currentProjectId:a})]})]})]})}},85029:function(e,t,s){s.d(t,{a:function(){return ep},Z:function(){return em}});var n=s(52676),a=s(75271),l=s(6522),r=s(89148),i=s.n(r),o=s(47280),d=s(58160),c=s(63611),u=s(5400),x=s(66277),p=s.n(x),m=s(81764),h=s.n(m),v=s(20529),g=s(97438),f=s(80739),b=s(32306);let j=[{value:0,label:"All"},{value:1,label:"Last 7 days"},{value:2,label:"Last 30 days"},{value:3,label:"Last 90 days"},{value:4,label:"Last 6 months"},{value:5,label:"Last 12 months"}],y=[{value:"",label:"All Sources"},{value:"1",label:"Milestone"},{value:"2",label:"Manual Invoice"}],w=p()(()=>Promise.resolve().then(s.bind(s,57383)),{loadableGenerated:{webpack:()=>[57383]},ssr:!1});var N=e=>{let{filterRef:t,isFilterSticky:s,isEnterprisePlan:a,tableLoading:l,isLoadingMore:r,currentProjectId:i,statusOptions:o,filterStates:d,handleFilterChange:c,saveFilters:u,clearFilters:x,getSourceLabel:p,getStatusLabel:m,filters:N,isLoading:C,mutate:k,activeFilterId:_,setActiveFilterId:F,activeFilter:E,hasQuickBooksConnection:S,isOwner:D,isAdmin:I,onSettingClick:A,onDisconnectClick:P}=e;return(0,n.jsx)("div",{ref:t,className:"bg-white pb-4 border-b border-gray-200 mb-4 sticky top-0 z-40",style:s?{paddingTop:"16px",boxShadow:"0 2px 4px rgba(0,0,0,0.1)"}:{},children:(0,n.jsxs)("div",{className:"flex justify-between items-center",children:[(0,n.jsxs)("div",{className:"space-y-3",children:[a&&(0,n.jsx)(v.Z,{onApplyFilter:e=>{h().isEmpty(e)?x():u(e)},searchType:i?g.S.TYPE_PROJECT_FINANCE_INCOME:g.S.TYPE_FINANCE_INCOME,filters:N,mutate:k,isLoading:C,activeFilterId:_,setActiveFilterId:F,activeFilter:E}),(0,n.jsxs)("div",{className:"flex gap-3 items-center flex-wrap",children:[(0,n.jsx)(b.Z,{value:null==d?void 0:d.dateRangeFilter,onChange:e=>c("dateRangeFilter",e),options:j,className:"w-[200px]",disabled:l||r,placeholder:"All"}),(0,n.jsx)(b.Z,{value:null==d?void 0:d.sourceFilter,onChange:e=>c("sourceFilter",e),options:y,renderValue:e=>""===e?null:p(e),className:"w-[180px]",disabled:l||r,placeholder:"All Sources"}),(0,n.jsx)(b.Z,{value:null==d?void 0:d.statusFilter,onChange:e=>c("statusFilter",e),options:[{value:"",label:"All Status"},...o.map(e=>({value:e.value,label:e.text}))],renderValue:e=>""===e?null:m(e),className:"w-[180px]",disabled:l||r,placeholder:"All Status"}),!i&&(0,n.jsx)(w,{value:null==d?void 0:d.tagsFilter,onChange:e=>c("tagsFilter",e),disabled:l||r,height:"44px"}),l&&(0,n.jsxs)("div",{className:"flex items-center gap-2 ml-3",children:[(0,n.jsx)("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-[#0052CC]"}),(0,n.jsx)("span",{className:"text-sm text-gray-600",children:"Updating..."})]}),a&&(0,n.jsx)(g.Z,{showEdit:!!((null==d?void 0:d.dateRangeFilter)||(null==d?void 0:d.sourceFilter)||(null==d?void 0:d.statusFilter)||!h().isEmpty(null==d?void 0:d.tagsFilter)),currentFilters:{...d},reset:x,activeFilter:E,projectId:i,searchType:i?g.S.TYPE_PROJECT_FINANCE_INCOME:g.S.TYPE_FINANCE_INCOME,setActiveFilterId:F})]})]}),(0,n.jsx)("div",{children:S&&!i&&(D||I)&&(0,n.jsx)(f.Z,{onSettingClick:A,onDisconnectClick:P})})]})})},C=s(48519),k=e=>{let{headerScrollRef:t,isFilterSticky:s,filterHeight:a,tableLoading:l,currentProjectId:r,isMultiTeam:i,sortConfig:d,handleSort:c,isScrolledToEnd:u}=e;return(0,n.jsx)("div",{className:"sticky z-20",style:{top:s?"".concat(a,"px"):"0px"},children:(0,n.jsx)("div",{className:(0,o.cn)("bg-white rounded-t-lg overflow-hidden",l&&"opacity-50"),children:(0,n.jsx)("div",{ref:t,className:"overflow-x-auto overflow-y-hidden scrollbar-hide pl-scroll-layer",children:(0,n.jsx)("table",{className:"w-full table-fixed ".concat(r?"min-w-[1400px]":"min-w-[2000px]"),children:(0,n.jsx)("thead",{className:"bg-[#F3F3F3]",children:(0,n.jsxs)("tr",{className:"border-b border-gray-200",children:[!r&&(0,n.jsx)(C.U,{field:"project_id",label:"ID",sortConfig:d,onSort:c,width:"w-[80px]"}),i&&(0,n.jsx)(C.U,{field:"clientID",label:"Client's ID",sortConfig:d,onSort:c,width:"w-[140px]"}),!r&&(0,n.jsx)(C.U,{field:"project_name",label:"Project",sortConfig:d,onSort:c,width:"w-[200px]"}),!r&&(0,n.jsx)(C.U,{field:"user_name",label:"Client",sortConfig:d,onSort:c,width:"w-[220px]"}),(0,n.jsx)(C.U,{field:"income_name",label:"Name/Invoice#",sortConfig:d,onSort:c,width:"w-[180px]"}),(0,n.jsx)(C.U,{field:"income_type_value",label:"Source",sortConfig:d,onSort:c,width:"w-[150px]"}),(0,n.jsx)(C.U,{field:"status",label:"Status",sortConfig:d,onSort:c,width:"w-[150px]"}),(0,n.jsx)(C.U,{field:"invoice_send",label:"Invoice sent",sortConfig:d,onSort:c,width:"w-[120px]"}
1),(0,n.jsx)(C.U,{field:"amount",label:"Amount",sortConfig:d,onSort:c,width:"w-[100px]"}),(0,n.jsx)(C.U,{field:"payment_amount",label:"Received",sortConfig:d,onSort:c,width:"w-[100px]"}),(0,n.jsx)(C.U,{field:"payment_method",label:"Payment Method",sortConfig:d,onSort:c,width:"w-[140px]"}),(0,n.jsx)(C.U,{field:"paid_date",label:"Paid Date",sortConfig:d,onSort:c}),(0,n.jsxs)("th",{className:"p-4 text-14 font-medium text-[#7C8293] text-center bg-[#F3F3F3] sticky right-0 z-10 w-[160px]",children:[(0,n.jsx)("div",{className:"absolute left-0 top-0 bottom-0 w-[1px] bg-gray-200"}),(0,n.jsx)("div",{className:(0,o.cn)("absolute left-[-8px] top-0 bottom-0 w-[8px] transition-opacity duration-200",u&&"opacity-0"),style:{background:"linear-gradient(to left, rgba(0,0,0,0.08), rgba(0,0,0,0.05), rgba(0,0,0,0.02), transparent)"}}),"Actions"]})]})})})})})})},_=s(10734),F=s(26059),E=s(42758),S=s(77314),D=s(36246),I=s(22294),A=s(4816),P=s(84241),B=s(59100),M=s(9530),L=s(61498),Z=s(25034),T=s(46017),O=s(6991),R=s(874),z=s.n(R),W=s(21765),q=s(56080),U=s(91676),V=s(41315),Q=e=>{let{row:t,payment:s,paymentIndex:l,payments:r,currentProjectId:i,isMultiTeam:d,isScrolledToEnd:c,onRowClick:u,onMarkAsPaid:x,onSendReminder:p,resolvePaymentAccount:m,savedPaymentAccounts:h,globalPayments:v}=e,[g,f]=(0,a.useState)(null),[b,j]=(0,a.useState)(!1),y=(0,V.Z)(r,l),w={requested:{text:"Requested",bg:"#FFF3CD",color:"#856404"},processing:{text:"Payment Processing",bg:"#FCEECD",color:"#8E4410"},paid:{text:"Paid",bg:"#D4EDDA",color:"#155724"},canceled:{text:"Canceled",bg:"#F8D7DA",color:"#721C24"},failed:{text:"Failed",bg:"#F8D7DA",color:"#721C24"}},N=w[s.status]||w.requested,C=N.text,k=N.bg,S=N.color,{label:D,isManualInvoice:I,recordedByName:A}=(0,V.K)(s,y),P={...t,income_name:D,income_type_value:"Progress Payment",amount:s.amount,payment_amount:"paid"===s.status?s.amount:0,payment_method:s.payment_method||"",payment_method_id:(()=>{let e=(0,U.Tu)(s.payment_method,h,v);return e?String(e.id):""})(),paid_date:s.paid_date||"",invoice_send:s.create_time||"",status:{text:C,color:S,"background-color":k},_is_partial_payment:!0,_partial_payment_id:s.id,action_button:"requested"===s.status||"processing"===s.status?{button_text:"Mark as paid",button_type:1,can_click:!0}:{button_text:"",button_type:0,can_click:!1}},L="requested"===s.status||"processing"===s.status||"paid"===s.status||"failed"===s.status,Z=()=>f(null);return(0,n.jsxs)("tr",{className:"bg-en-bg-light-blue hover:bg-blue-100 cursor-pointer",onClick:e=>{!e.target.closest("button")&&u&&u(P)},children:[!i&&(0,n.jsx)("td",{className:"p-4 w-[80px]"}),d&&(0,n.jsx)("td",{className:"p-4 w-[140px]"}),!i&&(0,n.jsx)("td",{className:"p-4 w-[220px]"}),!i&&(0,n.jsx)("td",{className:"p-4 w-[220px]"}),(0,n.jsx)("td",{className:"p-4",colSpan:2,children:(0,n.jsxs)("div",{className:"text-sm text-en-mid-blue pl-6 flex items-center gap-2",children:[(0,n.jsxs)("span",{children:["↳ ",D]}),I&&(0,n.jsx)("span",{className:"text-11 px-2 py-0.5 rounded-full bg-[#E9EBEF] text-en-mid-blue font-circular-medium whitespace-nowrap",children:"Manual Addition"})]})}),(0,n.jsx)("td",{className:"p-4 w-[150px]",children:(0,n.jsxs)("div",{className:"text-center rounded-[13px] w-fit px-3 py-1 text-sm flex items-center",style:{backgroundColor:k,color:S},children:[(0,n.jsx)("div",{className:"w-[5px] h-[5px] rounded-full mr-1 flex-none",style:{backgroundColor:S}}),C]})}),(0,n.jsx)("td",{className:"p-4 text-sm text-[#051023] w-[120px]",children:s.create_time||"-"}),(0,n.jsxs)("td",{className:"p-4 text-sm text-[#051023] w-[100px]",children:["$",Number(s.amount).toLocaleString()]}),(0,n.jsx)("td",{className:"p-4 text-sm text-[#051023] w-[100px]",children:"paid"===s.status?"$".concat(Number(s.amount).toLocaleString()):"-"}),(0,n.jsx)("td",{className:"p-4 text-sm text-[#051023] w-[120px]",children:(0,n.jsx)(O.Z,{paymentAccount:m(s.payment_account,P.payment_method_id),fallbackMethod:s.payment_method||"-",reference:s.payment_reference,showDetail:!0})}),(0,n.jsxs)("td",{className:"p-4 text-sm text-[#051023] w-[100px]",children:[s.paid_date||"-",I&&"paid"===s.status&&(0,n.jsxs)("div",{className:"text-12 text-en-light-blue whitespace-nowrap",children:["Recorded by ",A]})]}),(0,n.jsxs)("td",{className:"p-4 sticky right-0 bg-en-bg-light-blue z-10 w-[160px]",children:[(0,n.jsx)("div",{className:"absolute left-0 top-0 bottom-0 w-[1px] bg-gray-200"}),(0,n.jsx)("div",{className:(0,o.cn)("absolute left-[-8px] top-0 bottom-0 w-[8px] transition-opacity duration-200",c&&"opacity-0"),style:{background:"linear-gradient(to left, rgba(0,0,0,0.08), rgba(0,0,0,0.05), rgba(0,0,0,0.02), transparent)"}}),(0,n.jsx)("div",{className:"flex flex-col items-center gap-2",children:(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[P.action_button.can_click&&1===P.action_button.button_type&&(0,n.jsx)("button",{className:"px-3 py-1.5 text-sm font-medium text-[#0052CC] bg-white border border-[#0052CC] rounded-lg hover:bg-blue-50 transition-colors w-[110px]",onClick:e=>{e.stopPropagation(),x&&x(P)},children:"Mark as paid"}),(0,n.jsx)("button",{className:"p-1.5 rounded-lg transition-colors ".concat(L?"text-[#7C8293] hover:bg-gray-100":"text-[#D1D5DB] cursor-not-allowed"),onClick:e=>{e.stopPropagation(),L&&f(e.currentTarget)},disabled:!L,children:(0,n.jsx)(E.Z,{fontSize:"small"})}
1),(0,n.jsxs)(_.Z,{anchorEl:g,open:!!g,onClose:Z,onClick:e=>e.stopPropagation(),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},BackdropProps:{invisible:!0,onClick:e=>{e.stopPropagation(),Z()}},PaperProps:{style:{marginTop:"4px",borderRadius:"8px",boxShadow:"0px 4px 12px rgba(0, 0, 0, 0.1)",minWidth:"180px"}},children:["requested"===s.status&&(0,n.jsxs)(F.Z,{onClick:()=>{Z(),p&&p({...P,__index:"pp-".concat(s.id)})},style:{padding:"10px 16px",fontSize:"14px",color:"#172B4D"},children:[(0,n.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"#3B4658",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{marginRight:"12px"},children:[(0,n.jsx)("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),(0,n.jsx)("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]}),"Send Reminder"]}),(0,n.jsxs)(F.Z,{onClick:e=>{e.stopPropagation(),Z();let t=document.createElement("a");t.href="".concat("https://api.eano.com","/api/v1/vendor/milestone/invoice/export_progress_payment/?entry_id=").concat(s.id),t.download="invoice-pp-".concat(s.id,".pdf"),t.click()},style:{padding:"10px 16px",fontSize:"14px",color:"#172B4D"},children:[(0,n.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"#3B4658",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{marginRight:"12px"},children:[(0,n.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,n.jsx)("polyline",{points:"7 10 12 15 17 10"}),(0,n.jsx)("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),"Download PDF"]}),("requested"===s.status||"failed"===s.status)&&(0,n.jsxs)(F.Z,{onClick:async e=>{e.stopPropagation();try{let e=await (0,W.r)({url:"/api/v1/vendor/milestone/invoice/generate_progress_payment_link/?entry_id=".concat(s.id),method:"post"});if(e.isOk){var t;z()(null===(t=e.result)||void 0===t?void 0:t.shareUrl),j(!0),setTimeout(()=>{j(!1),Z()},1500)}else q.ZP.error(e.resMessage||"Failed to generate link"),Z()}catch(e){q.ZP.error("Failed to generate link"),Z()}},style:{padding:"10px 16px",fontSize:"14px",color:b?"#36B37E":"#172B4D"},children:[b?(0,n.jsx)(B.Z,{size:18,color:"#36B37E",style:{marginRight:"12px"}}):(0,n.jsx)(M.Z,{size:18,color:"#3B4658",style:{marginRight:"12px"}}),b?"Copied!":"Copy Sharing Link"]}),("requested"===s.status||"processing"===s.status)&&(0,n.jsxs)(F.Z,{onClick:()=>{Z(),u&&u(P)},style:{padding:"10px 16px",fontSize:"14px",color:"#172B4D"},children:[(0,n.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"#3B4658",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{marginRight:"12px"},children:[(0,n.jsx)("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),(0,n.jsx)("circle",{cx:"12",cy:"12",r:"3"})]}),"Preview as Client"]})]})]})})]})]})},H=e=>{var t,s,l,r,i,d,c,u,x,p,m,h,v,g,f,b;let{row:j,index:y,currentProjectId:w,isMultiTeam:N,isScrolledToEnd:C,onRowClick:k,onMarkAsPaid:R,onSendReminder:z,onEditDraft:W,actionButtonsLoading:q,expandedMilestones:U,setExpandedMilestones:V,menuAnchorEl:H,handleMenuOpen:Y,handleMenuClose:G,copiedIndex:$,handleCopyLink:K,sendClientLoadingId:X,isDraftRow:J,isVoidedRow:ee,canVoidRow:et,checkDraftFinalizeReady:es,draftFinalizeBtnState:en,handleDraftFinalize:ea,setZeroConfirmRow:el,setDeleteConfirmRow:er,setVoidConfirmRow:ei,handleExportRow:eo,resolvePaymentAccount:ed,getPaymentMethodLabel:ec,savedPaymentAccounts:eu,globalPayments:ex,sendClient:ep}=e;return(0,n.jsxs)(a.Fragment,{children:[(0,n.jsxs)("tr",{className:(0,o.cn)("hover:bg-gray-50",(2===j.income_type||1===j.income_type)&&k&&"cursor-pointer"),onClick:e=>{if((2===j.income_type||1===j.income_type)&&k){let t=e.target;t.closest("button")||t.closest(".sticky")||k(j)}},children:[!w&&(0,n.jsx)("td",{className:"p-4 text-sm text-[#051023] w-[80px]",children:j.effective_project_no||j.project_id||"-"}),N&&(0,n.jsx)("td",{className:"p-4 text-sm text-[#051023] w-[140px]",children:(0,n.jsx)("div",{title:(null==j?void 0:j.custom_invoice_no)||"-",className:"text-sm text-[#051023] truncate",children:(null==j?void 0:j.custom_invoice_no)||"-"})}),!w&&(0,n.jsx)("td",{className:"p-4 w-[200px]",children:(0,n.jsxs)("div",{className:"text-sm font-medium text-[#051023] flex items-center gap-2",children:[(0,n.jsx)("div",{className:"w-3 h-3 bg-[#2275EF] rounded-sm flex-shrink-0"}),(0,n.jsxs)("div",{children:[(null==j?void 0:j.project_name)?(0,n.jsxs)("span",{className:"font-circular-bold",children:[null==j?void 0:j.project_name," - "]}):null,j.address||"Project address missing"]})]})}),!w&&(0,n.jsx)("td",{className:"p-4 w-[220px]",children:(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("div",{className:"w-6 h-6 rounded-full bg-gray-300 flex-shrink-0 mt-0.5",style:{backgroundImage:j.avatar_url?"url(".concat(j.avatar_url,")"):void 0,backgroundSize:"cover",backgroundPosition:"center"}}),(0,n.jsx)("div",{className:"text-sm text-[#051023] break-words",style:{wordBreak:"break-word"},children:j.user_name||"-"})]})}),(0,n.jsx)("td",{className:"p-4 w-[180px]",children:(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[1===j.income_type&&(null===(s=j.partial_payments)||void 0===s?void 0:null===(t=s.payments)||void 0===t?void 0:t.length)>0?(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),V(e=>{let t=new Set(e);return t.has(j.income_id)?t.delete(j.income_id):t.add(j.income_id),t})},className:"flex-shrink-0 p-0.5 hover:bg-gray-100 transition-colors rounded",children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5 text-gray-500 transition-transform ".concat(U.has(j.income_id)?"rotate-90":""),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}):(0,n.jsx)("div",{className:"w-4"}),(0,n.jsx)("div",{className:"text-sm text-[#051023] truncate flex-1",title:(null==j?void 0:j.internal_note)||(null==j?void 0:j.custom_invoice_no)||j.income_name||"-",children:(null==j?void 0:j.internal_note)||(null==j?void 0:j.custom_invoice_no)||j.income_name||"-"})]})}),(0,n.jsx)("td",{className:"p-2 w-[150px]",children:(0,n.jsx)("div",{className:"bg-[#E1E4EB] text-[#3B4658] text-center rounded-[13px] w-fit px-5 py-1 text-sm",children:j.income_type_value||"-"})}),(0,n.jsx)("td",{className:"p-4 w-[150px]",children:j.status&&(0,n.jsxs)("div",{className:"text-center rounded-[13px] w-fit px-3 py-1 text-sm flex items-center justify-center",style:{backgroundColor:j.status["background-color"],
1color:j.status.color},children:[(0,n.jsx)("div",{className:"w-[5px] h-[5px] rounded-full mr-1 flex-none",style:{backgroundColor:j.status.color}}),(0,n.jsx)("div",{children:j.status.text})]})}),(0,n.jsx)("td",{className:"p-4 text-sm text-[#051023] w-[120px]",children:j.invoice_send||"-"}),(0,n.jsxs)("td",{className:"p-4 text-sm text-[#051023] w-[100px]",children:["$",(0,T.r)(j).toLocaleString()]}),(0,n.jsxs)("td",{className:"p-4 text-sm text-[#35AB3B] w-[100px]",children:["$",Number(j.payment_amount&&j.payment_amount>0?j.payment_amount:0).toLocaleString()]}),(0,n.jsx)("td",{className:"p-4 text-sm text-[#051023] w-[140px]",children:(0,n.jsx)(O.Z,{paymentAccount:ed(j.payment_account,j.payment_method_id),fallbackMethod:ec(j.payment_method_id||j.payment_method),reference:j.payment_reference,showDetail:!0})}),(0,n.jsx)("td",{className:"p-4",children:(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"text-sm text-[#051023]",children:j.paid_date?j.paid_date:"-"}),j.paid_text&&(0,n.jsx)("div",{className:"text-sm text-[#7C8293]",children:j.paid_text})]})}),(0,n.jsxs)("td",{className:"p-4 sticky right-0 bg-white z-10 w-[160px]",children:[(0,n.jsx)("div",{className:"absolute left-0 top-0 bottom-0 w-[1px] bg-gray-200"}),(0,n.jsx)("div",{className:(0,o.cn)("absolute left-[-8px] top-0 bottom-0 w-[8px] transition-opacity duration-200",C&&"opacity-0"),style:{background:"linear-gradient(to left, rgba(0,0,0,0.08), rgba(0,0,0,0.05), rgba(0,0,0,0.02), transparent)"}}),(0,n.jsx)("div",{className:"flex flex-col items-center gap-2",children:(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[ee(j)&&j.action_button?(0,n.jsx)("button",{disabled:!0,className:"px-3 py-1.5 text-sm font-medium text-white bg-[#DFDFDF] rounded-lg cursor-not-allowed w-[110px]",children:j.action_button.button_text}):J(j)?(0,n.jsx)("button",{className:"px-3 py-1.5 text-sm font-medium text-white bg-[#0052CC] rounded-lg hover:bg-[#0747A6] transition-colors w-[110px] disabled:opacity-50 disabled:cursor-not-allowed",onClick:e=>{e.stopPropagation(),W?W(j):k&&k(j)},disabled:X===j.income_id,children:"Edit"}):j.action_button&&(0===j.action_button.button_type?j.action_button.can_click?(0,n.jsx)("button",{className:"px-3 py-1.5 text-sm font-medium text-[#3B4658] bg-white border border-[#EBECF0] rounded-lg hover:bg-gray-50 transition-colors w-[110px]",onClick:()=>R&&R(j),children:j.action_button.button_text}):(0,n.jsx)(Z.u,{title:"You cannot modify this income because this record was automatically created by the system through an online payment.",arrow:!0,placement:"top",children:(0,n.jsx)("span",{children:(0,n.jsx)("button",{disabled:!0,className:"px-3 py-1.5 text-sm font-medium text-white bg-[#DFDFDF] rounded-lg cursor-not-allowed w-[110px]",children:j.action_button.button_text})})}):2===j.action_button.button_type?(0,n.jsx)("button",{className:"px-3 py-1.5 text-sm font-medium text-white bg-[#0052CC] rounded-lg hover:bg-[#0041a3] transition-colors w-[110px] disabled:opacity-50 disabled:cursor-not-allowed",onClick:()=>{0===(0,T.r)(j)?el(j):ep(j)},disabled:X===j.income_id,children:X===j.income_id?"Sending...":j.action_button.button_text}):(0,n.jsx)("button",{className:"px-3 py-1.5 text-sm font-medium text-[#0052CC] bg-white border border-[#0052CC] rounded-lg hover:bg-blue-50 transition-colors w-[110px]",onClick:()=>R&&R(j),children:j.action_button.button_text})),(()=>{var e,t,s,a,l,r,i;let o=J(j)||1===j.income_type||2===j.income_type||(null===(e=j.status)||void 0===e?void 0:e.value)===2||(null===(t=j.status)||void 0===t?void 0:t.value)===3||(null===(s=j.status)||void 0===s?void 0:s.text)==="Request sent"||(null===(a=j.status)||void 0===a?void 0:a.text)==="Client viewed"||(null===(l=j.status)||void 0===l?void 0:l.text)==="Past due"||1!==j.income_type&&((null===(r=j.status)||void 0===r?void 0:r.value)<4||(null===(i=j.status)||void 0===i?void 0:i.text)==="Not finished");return(0,n.jsx)("button",{className:"p-1.5 rounded-lg transition-colors ".concat(o?"text-[#7C8293] hover:bg-gray-100":"text-[#D1D5DB] cursor-not-allowed"),onClick:e=>{o&&(Y(e,y),J(j)&&es(j))},disabled:!o,children:(0,n.jsx)(E.Z,{fontSize:"small"})})}
1)(),(0,n.jsxs)(_.Z,{anchorEl:H[y],open:!!H[y],onClose:()=>G(y),onClick:e=>e.stopPropagation(),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},BackdropProps:{invisible:!0,onClick:e=>{e.stopPropagation(),G(y)}},PaperProps:{style:{marginTop:"4px",borderRadius:"8px",boxShadow:"0px 4px 12px rgba(0, 0, 0, 0.1)",minWidth:"180px"}},children:[J(j)&&en(j).checking&&(0,n.jsxs)(F.Z,{disabled:!0,style:{padding:"10px 16px",fontSize:"14px",color:"#9AA1AC",fontWeight:500},children:[(0,n.jsx)(S.Z,{size:18,className:"animate-spin",style:{marginRight:"12px",flexShrink:0}}),"Loading…"]}),J(j)&&!en(j).checking&&(()=>{let{ready:e}=en(j),t=e?"#0052CC":"#9AA1AC",s=X===j.income_id||!e;return(0,n.jsx)(Z.u,{arrow:!0,placement:"top",title:e?"":"Finish this draft before finalizing — open it to add a due date and at least one priced line.",children:(0,n.jsx)("span",{children:(0,n.jsxs)(F.Z,{onClick:async()=>{s||(G(y),0===(0,T.r)(j)?el({...j,__draftFinalize:!0,__finalizeAction:"finalize"}):await ea(j,"finalize"))},disabled:s,style:{padding:"10px 16px",fontSize:"14px",color:t,fontWeight:500},children:[(0,n.jsx)(D.Z,{size:18,color:t,style:{marginRight:"12px",flexShrink:0}}),"Save"]})})})})(),J(j)&&!en(j).checking&&(()=>{let{ready:e}=en(j),t=e?"#0052CC":"#9AA1AC",s=X===j.income_id||!e;return(0,n.jsx)(Z.u,{arrow:!0,placement:"top",title:e?"":"Finish this draft before finalizing — open it to add a due date and at least one priced line.",children:(0,n.jsx)("span",{children:(0,n.jsxs)(F.Z,{onClick:async()=>{s||(G(y),0===(0,T.r)(j)?el({...j,__draftFinalize:!0,__finalizeAction:"finalize_and_send"}):await ea(j,"finalize_and_send"))},disabled:s,style:{padding:"10px 16px",fontSize:"14px",color:t,fontWeight:500},children:[(0,n.jsx)(I.Z,{size:18,color:t,style:{marginRight:"12px",flexShrink:0}}),"Save & Send"]})})})})(),J(j)&&!en(j).checking&&(0,n.jsxs)(F.Z,{onClick:()=>{G(y),er(j)},disabled:X===j.income_id,style:{padding:"10px 16px",fontSize:"14px",color:"#E12424"},children:[(0,n.jsx)(A.Z,{size:18,color:"#E12424",style:{marginRight:"12px",flexShrink:0}}),"Delete"]}),!J(j)&&(null===(l=j.action_button)||void 0===l?void 0:l.button_type)===2&&(0,n.jsx)(F.Z,{onClick:()=>{G(y),R&&R(j)},children:"Mark as paid"}),(1===j.income_type||2===j.income_type)&&j.can_export_zip&&(0,n.jsxs)(F.Z,{onClick:()=>{G(y),eo(j,"pdf")},style:{padding:"10px 16px",fontSize:"14px",color:"#172B4D"},children:[(0,n.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"#3B4658",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{marginRight:"12px"},children:[(0,n.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,n.jsx)("polyline",{points:"7 10 12 15 17 10"}),(0,n.jsx)("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),"Download PDF only"]}),(1===j.income_type||2===j.income_type)&&j.can_export_zip&&(0,n.jsxs)(F.Z,{onClick:()=>{G(y),eo(j,"zip")},style:{padding:"10px 16px",fontSize:"14px",color:"#172B4D"},children:[(0,n.jsx)(P.Z,{size:18,color:"#3B4658",style:{marginRight:"12px"}}),"Download ZIP with attachments"]}),(1===j.income_type||2===j.income_type)&&!j.can_export_zip&&(0,n.jsxs)(F.Z,{onClick:()=>{G(y),eo(j)},style:{padding:"10px 16px",fontSize:"14px",color:"#172B4D"},children:[(0,n.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"#3B4658",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{marginRight:"12px"},children:[(0,n.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,n.jsx)("polyline",{points:"7 10 12 15 17 10"}),(0,n.jsx)("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),"Download PDF"]}),((null===(r=j.status)||void 0===r?void 0:r.value)===2||(null===(i=j.status)||void 0===i?void 0:i.value)===3||(null===(d=j.status)||void 0===d?void 0:d.text)==="Request sent"||(null===(c=j.status)||void 0===c?void 0:c.text)==="Client viewed"||1!==j.income_type&&((null===(u=j.status)||void 0===u?void 0:u.value)===1||(null===(x=j.status)||void 0===x?void 0:x.text)==="Not finished"))&&(0,n.jsxs)(F.Z,{onClick:e=>K(e,j,y),style:{padding:"10px 16px",fontSize:"14px",color:$===y?"#36B37E":"#172B4D"},children:[$===y?(0,n.jsx)(B.Z,{size:18,color:"#36B37E",style:{marginRight:"12px"}}):(0,n.jsx)(M.Z,{size:18,color:"#3B4658",style:{marginRight:"12px"}}),$===y?"Copied!":"Copy Sharing Link"]}),((null===(p=j.status)||void 0===p?void 0:p.value)===2||(null===(m=j.status)||void 0===m?void 0:m.value)===3||(null===(h=j.status)||void 0===h?void 0:h.text)==="Request sent"||(null===(v=j.status)||void 0===v?void 0:v.text)==="Client viewed"||(null===(g=j.status)||void 0===g?void 0:g.text)==="Past due")&&(0,n.jsxs)(F.Z,{onClick:()=>{G(y),z&&z({...j,__index:y})},disabled:q["reminder-".concat(y)],style:{padding:"10px 16px",fontSize:"14px",color:"#172B4D"},children:[q["reminder-".concat(y)]?(0,n.jsxs)("svg",{className:"animate-spin h-4 w-4",style:{marginRight:"12px"},xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[(0,n.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,n.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}):(0,n.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"#3B4658",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{marginRight:"12px"},children:[(0,n.jsx)("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),(0,n.jsx)("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]}),"Send Reminder"]}),et(j)&&(0,n.jsxs)(F.Z,{onClick:()=>{G(y),ei(j)},style:{padding:"10px 16px",fontSize:"14px",color:"#E12424",borderTop:"1px solid #EBECF0"},children:[(0,n.jsx)(L.Z,{size:18,color:"#E12424",style:{marginRight:"12px",flexShrink:0}}),"Void"]})]})]})})]})]}),1===j.income_type&&U.has(j.income_id)&&(null===(b=j.partial_payments)||void 0===b?void 0:null===(f=b.payments)||void 0===f?void 0:f.length)>0&&j.partial_payments.payments.map((e,t,s)=>(0,n.jsx)(Q,{row:j,payment:e,paymentIndex:t,payments:s,currentProjectId:w,isMultiTeam:N,isScrolledToEnd:C,onRowClick:k,onMarkAsPaid:R,onSendReminder:z,resolvePaymentAccount:ed,savedPaymentAccounts:eu,globalPayments:ex},"pp-".concat(j.income_id,"-").concat(t)))]})},Y=e=>{let{financingList:t,totalRecords:s,isLoadingMore:a,hasMore:l,loadMoreRef:r}=e;return(0,n.jsxs)("div",{className:"bg-gray-50 border-t border-gray-200 mt-4",children:[(0,n.jsxs)("div",{className:"px-6 py-4",children:[(0,n.jsx)("div",{className:"text-center mb-3",children:(0,n.jsx)("div",{className:"text-sm text-gray-600",children:s?(0,n.jsxs)(n.Fragment,{children:["Showing"," ",(0,n.jsx)("span",{className:"font-semibold text-gray-900",children:Math.min(t.length,s)})," ","of ",(0,n.jsx)("span",{className:"font-semibold text-gray-900",children:s})," records"]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"font-semibold text-gray-900",children:t.length})," records loaded"]})})}),(0,n.jsxs)("div",{className:"flex items-center justify-center",children:[a&&(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)("div",{className:"animate-spin rounded-full h-5 w-5 border-b-2 border-[#0052CC]"}),(0,n.jsx)("span",{className:"text-sm text-gray-600",children:"Loading more records..."})]}),!a&&l&&(0,n.jsx)("span",{className:"text-sm text-gray-500",children:"Scroll down to load more"}),!l&&t.length>0&&!a&&(0,n.jsxs)("div",{className:"flex items-center gap-2 text-sm text-green-600",children:[(0,n.jsx)("svg",{className:"w-4 h-4",fill:"
1currentColor",viewBox:"0 0 20 20",children:(0,n.jsx)("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}),"All records loaded"]})]})]}),l&&(0,n.jsx)("div",{ref:r,className:"h-4"})]})},G=s(11219),$=s(93542),K=s(28518),X=s(77806),J=s(62845),ee=e=>{let{showSyncDialog:t,setShowSyncDialog:s,showDisconnectDialog:a,setShowDisconnectDialog:l,handleRefreshExpenses:r,handleDisconnectQuickBooks:i,zeroConfirmRow:o,setZeroConfirmRow:d,handleDraftFinalize:c,sendClient:u,deleteConfirmRow:x,setDeleteConfirmRow:p,deleteLoading:m,handleDraftDelete:h,voidConfirmRow:v,setVoidConfirmRow:g,voidLoading:f,handleVoid:b}=e;return(0,n.jsxs)(n.Fragment,{children:[t&&(0,n.jsx)(G.Z,{open:t,onClose:()=>s(!1),onConfirm:async()=>{await r()}}),(0,n.jsx)($.Z,{open:a,onClose:()=>l(!1),onDisconnect:i}),(0,n.jsx)(K.Z,{open:!!o,variant:(null==o?void 0:o.__finalizeAction)==="finalize"?"save":"send",onClose:()=>d(null),onConfirm:async()=>{d(null),(null==o?void 0:o.__draftFinalize)?await c(o,o.__finalizeAction||"finalize_and_send"):await u(o)}}),(0,n.jsx)(X.Z,{open:!!x,loading:m,onClose:()=>{m||p(null)},onConfirm:async()=>{x&&await h(x)}}),(0,n.jsx)(J.nQ,{open:!!v,loading:f,onClose:()=>{f||g(null)},onConfirm:b})]})},et=s(32095),es=s(35852),en=s(9780),ea=s(8685),el=s(64754);let er=e=>{var t;return(null==e?void 0:e.income_type)===2&&(null==e?void 0:null===(t=e.status)||void 0===t?void 0:t.text)==="Draft"},ei=e=>{var t;return(null==e?void 0:null===(t=e.status)||void 0===t?void 0:t.text)==="Voided"},eo=e=>{var t;return(null==e?void 0:null===(t=e.status)||void 0===t?void 0:t.text)==="Paid"},ed=e=>(null==e?void 0:e.income_type)===2?!(er(e)||ei(e)||eo(e)&&(null==e?void 0:e.has_paid_via_stripe)):(null==e?void 0:e.income_type)===1&&!!(null==e?void 0:e.can_void);var ec=s(48419);let eu={COLLAPSED:64,EXPANDED:224};var ex=e=>{var t;let{financingList:s,statusOptions:r,tableLoading:x,isLoadingMore:p,hasMore:m,loadMoreRef:h,totalRecords:v,initialFilters:f,onFilterChange:b,onMarkAsPaid:j,onSendReminder:w,onRowClick:C,onEditDraft:_,actionButtonsLoading:F={},currentProjectId:E,hasQuickBooksConnection:S}=e,{isOwner:D,isAdmin:I}=(0,d.j$)(),{isMultiTeam:A,isEnterprisePlan:P}=(0,c.U_)(),[B,M]=(0,a.useState)(new Set),{isFilterSticky:L,filterRef:Z,sentinelRef:T,filterHeight:O,headerScrollRef:R,bodyScrollRef:V,isScrolledToEnd:Q}=function(e,t){let[s,n]=(0,a.useState)(!1),l=(0,a.useRef)(null),r=(0,a.useRef)(null),[i,o]=(0,a.useState)(0),d=(0,a.useRef)(null),c=(0,a.useRef)(null),u=(0,a.useRef)(!1),x=(0,a.useRef)(!1),[p,m]=(0,a.useState)(!1);return(0,a.useEffect)(()=>{let e=!1,t=()=>{e||(window.requestAnimationFrame(()=>{e=!1}),e=!0)};return window.addEventListener("scroll",t,{passive:!0}),t(),()=>{window.removeEventListener("scroll",t)}},[]),(0,a.useEffect)(()=>{let e=null,t=null,s=e=>{null!==t&&cancelAnimationFrame(t),t=requestAnimationFrame(()=>{m(e.scrollLeft+e.clientWidth>=e.scrollWidth-2)})},n=t=>{null!==e&&cancelAnimationFrame(e),e=requestAnimationFrame(()=>{d.current&&c.current&&("header"===t?(x.current=!0,c.current.scrollLeft=d.current.scrollLeft,s(d.current)):(u.current=!0,d.current.scrollLeft=c.current.scrollLeft,s(c.current)))})},a=()=>{if(u.current){u.current=!1;return}n("header")},l=()=>{if(x.current){x.current=!1;return}n("body")},r=d.current,i=c.current;return r&&r.addEventListener("scroll",a,{passive:!0}),i&&i.addEventListener("scroll",l,{passive:!0}),i&&s(i),()=>{null!==e&&cancelAnimationFrame(e),null!==t&&cancelAnimationFrame(t),r&&r.removeEventListener("scroll",a),i&&i.removeEventListener("scroll",l)}},[]),(0,a.useEffect)(()=>{let e=()=>{let e=c.current;e&&m(e.scrollLeft+e.clientWidth>=e.scrollWidth-2)},t=setTimeout(e,100);return window.addEventListener("resize",e),()=>{clearTimeout(t),window.removeEventListener("resize",e)}},[e,t]),(0,a.useEffect)(()=>{let e=e=>{let t=e?eu.COLLAPSED:eu.EXPANDED;document.documentElement.style.setProperty("--content-padding-left","".concat(t+40,"px")),document.documentElement.style.setProperty("--content-padding-right","40px")};e("true"===localStorage.getItem(ec.I.COLLAPSED_STATE));let t=t=>{var s;e(!!(null===(s=t.detail)||void 0===s?void 0:s.collapsed))};return window.addEventListener(ec.FP.NAV_TOGGLE,t),()=>{window.removeEventListener(ec.FP.NAV_TOGGLE,t)}},[]),(0,a.useEffect)(()=>{let e=()=>{l.current&&o(l.current.offsetHeight)};return e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}},[]),(0,a.useEffect)(()=>{let e=r.current;if(!e)return;let t=new IntersectionObserver(e=>{let[t]=e,s=!t.isIntersecting;n(s),s&&l.current&&o(l.current.offsetHeight)},{threshold:0,rootMargin:"-1px 0px 0px 0px"});return t.observe(e),()=>{t.unobserve(e)}},[]),{isFilterSticky:s,filterRef:l,sentinelRef:r,filterHeight:i,headerScrollRef:d,bodyScrollRef:c,isScrolledToEnd:p}}(s,E),{sortConfig:G,activeFilterId:$,setActiveFilterId:K,filters:X,isLoading:J,mutate:ex,activeFilter:ep,filterStates:em,handleFilterChange:eh,saveFilters:ev,clearFilters:eg,handleSort:ef,getSourceLabel:eb,getStatusLabel:ej}=function(e){let{statusOptions:t,initialFilters:s,currentProjectId:n,onFilterChange:l}=e,{sortConfig:r,setSortConfig:i,getNextSort:o}=(0,es.f)(),[d,c]=(0,a.useState)(null),{filters:u,isLoading:x,mutate:p}=(0,et.L)(n?{searchType:g.S.TYPE_PROJECT_FINANCE_INCOME,projectId:n}:{searchType:g.S.TYPE_FINANCE_INCOME}),m=(0,a.useMemo)(()=>null==u?void 0:u.find(e=>e.id===d),[d,u]),[h,v]=(0,a.useState)({dateRangeFilter:(null==s?void 0:s.dateRangeFilter)||0,sourceFilter:(null==s?void 0:s.sourceFilter)||"",statusFilter:(null==s?void 0:s.statusFilter)||"",tagsFilter:(null==s?void 0:s.tagsFilter)||[]}),f=(0,a.useRef)();(0,a.useEffect)(()=>{s&&v(e=>({...e,...s}))},[s]);let b=(0,a.useCallback)(e=>{f.current&&clearTimeout(f.current);
1let t=o(e);i(t),l({...h,sortField:t.field,sortOrder:t.field?t.order:void 0})},[o,i,l,h]);return{sortConfig:r,activeFilterId:d,setActiveFilterId:c,filters:u,isLoading:x,mutate:p,activeFilter:m,filterStates:h,handleFilterChange:(e,t)=>{v(s=>({...s,[e]:t})),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{l({dateRangeFilter:"dateRangeFilter"===e?t:null==h?void 0:h.dateRangeFilter,sourceFilter:"sourceFilter"===e?t:null==h?void 0:h.sourceFilter,statusFilter:"statusFilter"===e?t:null==h?void 0:h.statusFilter,tagsFilter:"tagsFilter"===e?t:null==h?void 0:h.tagsFilter,sortField:r.field,sortOrder:r.field?r.order:void 0})},300)},saveFilters:e=>{v(t=>({...t,...e})),l({...h,...e,sortField:r.field,sortOrder:r.order})},clearFilters:()=>{let e={dateRangeFilter:0,sourceFilter:"",statusFilter:"",tagsFilter:[]};v({...e}),l({...e,sortField:r.field,sortOrder:r.field?r.order:void 0})},handleSort:b,getSourceLabel:e=>{let t=y.find(t=>t.value===e);return(null==t?void 0:t.label)||"All Sources"},getStatusLabel:e=>{let s=t.find(t=>t.value===e);return(null==s?void 0:s.text)||"All Status"}}}({statusOptions:r,initialFilters:f,currentProjectId:E,onFilterChange:b}),{menuAnchorEl:ey,copiedIndex:ew,showSyncDialog:eN,setShowSyncDialog:eC,showDisconnectDialog:ek,setShowDisconnectDialog:e_,sendClientLoadingId:eF,zeroConfirmRow:eE,setZeroConfirmRow:eS,deleteConfirmRow:eD,setDeleteConfirmRow:eI,deleteLoading:eA,voidConfirmRow:eP,setVoidConfirmRow:eB,voidLoading:eM,isDraftRow:eL,isVoidedRow:eZ,canVoidRow:eT,checkDraftFinalizeReady:eO,draftFinalizeBtnState:eR,sendClient:ez,handleDraftFinalize:eW,handleDraftDelete:eq,handleVoid:eU,handleMenuOpen:eV,handleMenuClose:eQ,handleExportRow:eH,handleCopyLink:eY,handleRefreshExpenses:eG,handleDisconnectQuickBooks:e$}=function(){let{actions:e}=(0,l.pL)(),{mutate:t}=(0,en.kY)(),s=(0,a.useCallback)(()=>(0,el.k)(t),[t]),[r,i]=(0,a.useState)({}),[o,d]=(0,a.useState)(null),[c,u]=(0,a.useState)(!1),[x,p]=(0,a.useState)(!1),[m,h]=(0,a.useState)(null),[v,g]=(0,a.useState)(null),[f,b]=(0,a.useState)(null),[j,y]=(0,a.useState)(!1),[w,N]=(0,a.useState)(null),[C,k]=(0,a.useState)(!1),[_,F]=(0,a.useState)({}),E=async t=>{h(t.income_id);try{let a=await (0,W.r)({url:"/api/v1/invoice/send_to_client/",params:{invoice_id:t.income_id},method:"post"});if(a.isOk){var n;q.ZP.success("Invoice sent successfully"),null==e||null===(n=e.fetchFinanceData)||void 0===n||n.call(e),s()}else q.ZP.error(a.resMessage||"Invoice send failed")}finally{h(null)}},S=(0,a.useCallback)(async e=>{let t=null==e?void 0:e.income_id;if(null!=t){F(e=>({...e,[t]:null}));try{let e=await (0,W.r)({url:"/api/v1/invoice/invoice/detail/",method:"get",noCamel:!0,params:{invoice_id:t}}),s=!!e.isOk&&(0,ea.Yj)((0,ea.p5)(e.result));F(e=>({...e,[t]:s}))}catch(e){F(e=>({...e,[t]:!1}))}}},[]),D=async t=>{y(!0);try{let n=await (0,W.r)({url:"/api/v1/invoice/invoice/draft/delete/",method:"post",params:{invoice_id:t.income_id}});if(n.isOk){var s;q.ZP.success("Draft deleted"),b(null),null==e||null===(s=e.fetchFinanceData)||void 0===s||s.call(e)}else q.ZP.error(n.resMessage||"Failed to delete draft")}finally{y(!1)}},I=async t=>{if(w){k(!0);try{let a=1===w.income_type?await (0,W.r)({url:"/api/v1/vendor/milestone/invoice/void",method:"post",noCamel:!0,params:{milestone_id:w.income_id,notify_client:t}}):await (0,W.r)({url:"/api/v1/invoice/invoice/mark_void/",method:"post",noCamel:!0,params:{invoice_id:w.income_id,notify_client:t}});if(a.isOk){var n;q.ZP.success("Invoice voided"),N(null),null==e||null===(n=e.fetchFinanceData)||void 0===n||n.call(e),s()}else q.ZP.error(a.resMessage||"Failed to void invoice")}finally{k(!1)}}},A=e=>{i({...r,[e]:null})},P=async(e,t,s)=>{e.stopPropagation();try{let e=1===t.income_type,a=e?"/api/v1/vendor/milestone/invoice/generate_link/?milestone_id=".concat(t.income_id):"/api/v1/invoice/invoice/generate_link/",l=await (0,W.r)({url:a,method:"post",params:e?void 0:{invoice_id:t.income_id}});if(l.isOk){var n;let e=null===(n=l.result)||void 0===n?void 0:n.shareUrl;z()(e),d(s),setTimeout(()=>{d(null),A(s)},1500)}else console.error("Generate link error:",l),q.ZP.error(l.resMessage||"Failed to generate link"),A(s)}catch(e){console.error("Generate link exception:",e),q.ZP.error("Failed to generate invoice link"),A(s)}};return{menuAnchorEl:r,copiedIndex:o,showSyncDialog:c,setShowSyncDialog:u,showDisconnectDialog:x,setShowDisconnectDialog:p,sendClientLoadingId:m,zeroConfirmRow:v,setZeroConfirmRow:g,deleteConfirmRow:f,setDeleteConfirmRow:b,deleteLoading:j,voidConfirmRow:w,setVoidConfirmRow:N,voidLoading:C,isDraftRow:er,isVoidedRow:ei,isPaidR
1ow:eo,canVoidRow:ed,checkDraftFinalizeReady:S,draftFinalizeBtnState:e=>{let t=_[null==e?void 0:e.income_id];return{checking:null==t,ready:!0===t}},sendClient:E,handleDraftFinalize:async(t,a)=>{h(t.income_id);try{let r=await (0,W.r)({url:"/api/v1/invoice/invoice/update/",method:"post",params:{invoice_id:t.income_id,action:a}});if(r.isOk){var l;q.ZP.success("finalize_and_send"===a?(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"font-semibold text-en-dark-blue",children:"Invoice Sent Successfully!"}),(0,n.jsx)("div",{className:"mt-0.5 text-13 text-en-dark-blue",children:"Your client will receive an email and SMS."})]}):(0,n.jsx)("div",{className:"font-semibold text-en-dark-blue",children:"Invoice Saved Successfully!"})),null==e||null===(l=e.fetchFinanceData)||void 0===l||l.call(e),s()}else q.ZP.error(r.resMessage||"Failed to save invoice")}finally{h(null)}},handleDraftDelete:D,handleVoid:I,handleMenuOpen:(e,t)=>{e.stopPropagation(),i({...r,[t]:e.currentTarget})},handleMenuClose:A,handleExportRow:(e,t)=>{!function(e,t){let s=function(e,t){let s=t?"&download_type=".concat(t):"";return 2===e.income_type?"".concat("https://api.eano.com","/api/v1/invoice/invoice/export_invoice/?invoice_id=").concat(e.income_id).concat(s):1===e.income_type?"".concat("https://api.eano.com","/api/v1/vendor/milestone/invoice/export_invoice/?milestone_id=").concat(e.income_id).concat(s):null}(e,t);s&&window.open(s,"_blank")}(e,t)},handleCopyLink:P,handleRefreshExpenses:async()=>{await Promise.all([e.fetchExpensesData(1,!1,!1),e.fetchFinanceData()])},handleDisconnectQuickBooks:async()=>{let t=await e.handleDisconnectQuickBooks();return t&&(await e.fetchFinanceData(1,!1,!1),await e.fetchExpensesData(1,!1,!1)),t}}}(),{savedPaymentAccounts:eK,globalPayments:eX,resolvePaymentAccount:eJ,getPaymentMethodLabel:e0}=function(){let{payments:e,globalPayments:t}=(0,U.Ew)();return{savedPaymentAccounts:e,globalPayments:t,resolvePaymentAccount:(s,n)=>s||(0,U.CG)(n,e,t),getPaymentMethodLabel:s=>{if(!s)return"-";let n=(0,U.CG)(s,e,t);if(n)return(0,U.d0)(n);if("number"==typeof s||!isNaN(Number(s)))switch(Number(s)){case 5981:case 1:return"Check";case 108640:case 2:return"Cash";case 115935:case 3:return"Bank transfers";case 115936:case 4:return"Credit cards";case 5980:case 5:return"Zelle";default:return"Other"}return s}}}();return(0,n.jsxs)("div",{className:"jsx-daf42ae5c1721118 relative",children:[(0,n.jsx)(i(),{id:"daf42ae5c1721118",children:".scrollbar-hide.jsx-daf42ae5c1721118::-webkit-scrollbar{display:none}.pl-scroll-layer.jsx-daf42ae5c1721118{-webkit-transform:translatez(0);-moz-transform:translatez(0);-ms-transform:translatez(0);-o-transform:translatez(0);transform:translatez(0);will-change:scroll-position;-webkit-overflow-scrolling:touch;contain:paint}"}),(0,n.jsx)("div",{ref:T,className:"jsx-daf42ae5c1721118 h-0"}),(0,n.jsx)(N,{filterRef:Z,isFilterSticky:L,isEnterprisePlan:P,tableLoading:x,isLoadingMore:p,currentProjectId:E,statusOptions:r,filterStates:em,handleFilterChange:eh,saveFilters:ev,clearFilters:eg,getSourceLabel:eb,getStatusLabel:ej,filters:X,isLoading:J,mutate:ex,activeFilterId:$,setActiveFilterId:K,activeFilter:ep,hasQuickBooksConnection:S,isOwner:D,isAdmin:I,onSettingClick:()=>eC(!0),onDisconnectClick:()=>e_(!0)}),L&&(0,n.jsx)("div",{style:{height:(null===(t=Z.current)||void 0===t?void 0:t.offsetHeight)||0},className:"jsx-daf42ae5c1721118"}),(0,n.jsxs)("div",{className:"jsx-daf42ae5c1721118 ",children:[(0,n.jsx)(k,{headerScrollRef:R,isFilterSticky:L,filterHeight:O,tableLoading:x,currentProjectId:E,isMultiTeam:A,sortConfig:G,handleSort:ef,isScrolledToEnd:Q}),(0,n.jsx)("div",{className:"jsx-daf42ae5c1721118 "+((0,o.cn)("bg-white rounded-b-lg shadow-none -mt-[2px]",x&&"opacity-50")||""),children:(0,n.jsx)("div",{ref:V,className:"jsx-daf42ae5c1721118 overflow-x-auto pl-scroll-layer no-scrollbar",children:(0,n.jsx)("table",{className:"jsx-daf42ae5c1721118 "+"w-full table-fixed ".concat(E?"min-w-[1400px]":"min-w-[2000px]"),children:(0,n.jsx)("tbody",{className:"jsx-daf42ae5c1721118 bg-white divide-y divide-gray-200",children:s.map((e,t)=>(0,n.jsx)(H,{row:e,index:t,currentProjectId:E,isMultiTeam:A,isScrolledToEnd:Q,onRowClick:C,onMarkAsPaid:j,onSendReminder:w,onEditDraft:_,actionButtonsLoading:F,expandedMilestones:B,setExpandedMilestones:M,menuAnchorEl:ey,handleMenuOpen:eV,handleMenuClose:eQ,copiedIndex:ew,handleCopyLink:eY,sendClientLoadingId:eF,isDraftRow:eL,isVoidedRow:eZ,canVoidRow:eT,checkDraftFinalizeReady:eO,draftFinalizeBtnState:eR,handleDraftFinalize:eW,setZeroConfirmRow:eS,setDeleteConfirmRow:eI,setVoidConfirmRow:eB,handleExportRow:eH,resolvePaymentAccount:eJ,getPaymentMethodLabel:e0,savedPaymentAccounts:eK,globalPayments:eX,sendClient:ez},"row-".concat(t,"-").concat(e.id)))})})})}),(0,n.jsx)(Y,{financingList:s,totalRecords:v,isLoadingMore:p,hasMore:m,loadMoreRef:h}),0!==s.length&&(0,n.jsx)(u.Z,{viewportRef:V,label:"Income table horizontal scrollbar"})]}),(0,n.jsx)(ee,{showSyncDialog:eN,setShowSyncDialog:eC,showDisconnectDialog:ek,setShowDisconnectDialog:e_,handleRefreshExpenses:eG,handleDisconnectQuickBooks:e$,zeroConfirmRow:eE,setZeroConfirmRow:eS,handleDraftFinalize:eW,sendClient:ez,deleteConfirmRow:eD,setDeleteConfirmRow:eI,deleteLoading:eA,handleDraftDelete:eq,voidConfirmRow:eP,setVoidConfirmRow:eB,voidLoading:eM,handleVoid:eU})]})};let ep=e=>{let{onMarkAsPaid:t,onSendReminder:s,onRowClick:a,onEditDraft:r,actionButtonsLoading:i,projectId:o}=e,{financingList:d,statusOptions:c,loading:u,loadMoreRef:x,actions:p,pagination:m,hasConnect:h,filters:v,hasQuickBooksConnection:g}=(0,l.pL)();return(0,n.jsx)(ex,{financingList:d,statusOptions:c,loading:u.fullPage,tableLoading:u.tableOverlay,isLoadingMore:u.loadingMore,hasMore:m.hasMore,hasStripeAccount:h,loadM
1oreRef:x,totalRecords:m.total,initialFilters:{dateRangeFilter:v.dateRangeFilter||0,sourceFilter:v.sourceFilter||"",statusFilter:v.statusFilter||"",tagsFilter:v.tagsFilter||[]},onFilterChange:e=>{p.handleFilterChange(e)},onMarkAsPaid:t,onSendReminder:s,onRowClick:a,onEditDraft:r,actionButtonsLoading:i,currentProjectId:o,hasQuickBooksConnection:g})};var em=ep},35852:function(e,t,s){s.d(t,{f:function(){return a}});var n=s(75271);function a(){let[e,t]=(0,n.useState)({field:null,order:"asc"}),s=(0,n.useCallback)(t=>e.field===t?"asc"===e.order?{field:t,order:"desc"}:{field:null,order:"asc"}:{field:t,order:"asc"},[e]),a=(0,n.useCallback)(e=>{t(s(e))},[s]);return{sortConfig:e,setSortConfig:t,getNextSort:s,handleSort:a}}},24596:function(e,t,s){s.d(t,{LK:function(){return l},rc:function(){return n}});let n="*Invoice names will automatically come from the project name.",a=e=>"*Warning: Due to QuickBooks limitations, choosing “".concat(e,"” will create a new client in QuickBooks for every project.");function l(e,t,s){if(e)return{displayValue:4,locked:!0,showProjectSyncNote:!0,duplicateWarning:null};let n=t||1;if(1!==n){var l;let e=null===(l=s.find(e=>e.value===n))||void 0===l?void 0:l.label;return{displayValue:n,locked:!1,showProjectSyncNote:!1,duplicateWarning:e?a(e):null}}return{displayValue:n,locked:!1,showProjectSyncNote:!1,duplicateWarning:null}}},64754:function(e,t,s){s.d(t,{k:function(){return n}});let n=e=>{e(e=>"string"==typeof e?e.startsWith("/api/v1/finance/financials"):!!Array.isArray(e)&&"/api/v1/finance/price-data"===e[0])}},81476:function(e,t,s){s.d(t,{G:function(){return l}});var n=s(80114),a=s(71792);let l=(e,t)=>{let{data:s,error:l,mutate:r,isLoading:i,isValidating:o}=(0,n.u)(e?["vendor-settings",e]:null,async()=>{let t=await a.vendor.getSettings({project_id:e});if((null==t?void 0:t.code)===0)return t.data;throw Error((null==t?void 0:t.message)||"Failed to fetch vendor settings")},{revalidateOnFocus:!1,revalidateOnReconnect:!1,dedupingInterval:1e4,...t});return{settings:s,isLoading:i||!l&&!s,isError:!!l,error:l,mutate:r,isValidating:o}}},68388:function(e,t,s){s.d(t,{k:function(){return r}});var n=s(75271),a=s(4471),l=s(71792);function r(){let e=(0,a.I0)();return{globalMilestoneSettings:(0,a.v9)(e=>{var t,s,n;return null===(n=e.authStore)||void 0===n?void 0:null===(s=n.user)||void 0===s?void 0:null===(t=s.vendor_info)||void 0===t?void 0:t.global_milestone_settings})||{},refreshUserInfo:(0,n.useCallback)(async()=>{let t=await l.MI.getUserInfo(null,!1);(null==t?void 0:t.code)===0&&e.authStore.saveToken({user:t.data})},[e])}}},77806:function(e,t,s){var n=s(52676);s(75271);var a=s(77690);t.Z=e=>{let{open:t,loading:s=!1,onClose:l,onConfirm:r}=e;return(0,n.jsx)(a.ZP,{open:t,onClose:l,width:"small",contentClassName:"px-8 py-10",hideCloseBtn:!0,children:(0,n.jsxs)("div",{className:"flex flex-col items-center text-center",children:[(0,n.jsx)("h2",{className:"text-2xl font-bold text-[#172B4D] mb-3",children:"Delete Draft Invoice?"}),(0,n.jsx)("p",{className:"text-[#6B778C] text-base mb-8",children:"This invoice will be permanently deleted and removed from your invoice list."}),(0,n.jsxs)("div",{className:"flex gap-4 w-full",children:[(0,n.jsx)("button",{onClick:l,disabled:s,className:"flex-[1] py-3 border border-[#D7D9DD] rounded-lg text-[#172B4D] font-medium text-base hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed",children:"Cancel"}),(0,n.jsx)("button",{onClick:()=>r(),disabled:s,className:"flex-[2] py-3 bg-[#E12424] bg-opacity-10 border border-[#902721] text-[#902721] rounded-lg font-medium text-base hover:bg-opacity-20 disabled:opacity-50 disabled:cursor-not-allowed",children:s?"Deleting...":"Delete Invoice"})]})]})})}},46017:function(e,t,s){s.d(t,{r:function(){return l}});let n=e=>{let t=Number(e);return Number.isFinite(t)?t:0},a=e=>!!e&&(3===e.income_type||!0===e.is_change_order||"change_order"===e.type||3===e.type),l=e=>{var t,s,l,r;if(!e)return 0;let i=n(null!==(r=null!==(l=null!==(s=null!==(t=e.effective_price)&&void 0!==t?t:e.payment_price)&&void 0!==s?s:e.amount)&&void 0!==l?l:e.price)&&void 0!==r?r:0);return i<0&&a(e)?0:i<0?0:i}}
1,20734:function(e,t,s){var n=s(52676),a=s(75271),l=s(71792),r=s(75177),i=s(90484),o=s(56080),d=s(68388);let c=[{label:"S",value:6},{label:"M",value:0},{label:"T",value:1},{label:"W",value:2},{label:"T",value:3},{label:"F",value:4},{label:"S",value:5}],u=e=>{let{open:t,onClose:s,completion:a,onApply:l,loading:i}=e;return(0,n.jsx)(r.ZP,{isOpen:t,width:"narrow",onCloseClick:s,children:(0,n.jsxs)("div",{className:"text-center",children:[(0,n.jsx)("div",{className:"text-en-dark-blue text-28 font-circular-bold mb-6",children:"Apply to All Milestones?"}),(0,n.jsx)("div",{className:"text-en-dark-blue text-16 mb-3",children:"This will apply the current project's completion settings:"}),(0,n.jsx)("div",{style:{borderRadius:4,background:"linear-gradient(0deg, rgba(255, 255, 255, 0.90) 0%, rgba(255, 255, 255, 0.90) 100%), #298FF7"},className:"inline-block px-4 py-2 rounded-full text-[#298FF7] text-16 mb-4",children:a?(0,n.jsxs)(n.Fragment,{children:["Milestones can be completed"," ",(0,n.jsx)("span",{className:"font-circular-bold text-en-blue",children:"without"})," a photo"]}):(0,n.jsxs)(n.Fragment,{children:["Milestones must be completed"," ",(0,n.jsx)("span",{className:"font-circular-bold text-en-blue",children:"with"})," a photo"]})}),(0,n.jsx)("div",{className:"text-en-dark-blue text-16 mb-8",children:"Applying this setting will also change this setting for milestones on all future and newly created projects and opportunities."}),(0,n.jsxs)("div",{className:"flex gap-4",children:[(0,n.jsx)("button",{onClick:s,className:"flex-1 py-3 rounded-lg border border-en-divider-dark text-en-dark-blue text-16 font-circular-bold cursor-pointer",children:"Back"}),(0,n.jsx)("button",{onClick:l,disabled:i,className:"flex-1 py-3 rounded-lg bg-en-blue text-white text-16 font-circular-bold cursor-pointer disabled:opacity-50",children:"Apply"})]})]})})};t.Z=e=>{let{open:t,onClose:s=()=>{},projectId:x,hasSigned:p,completion:m,setCompletion:h,client:v,setClient:g,internal:f,setInternal:b,workDays:j=[],setWorkDays:y,mutateSettings:w}=e,[N,C]=(0,a.useState)(!1),[k,_]=(0,a.useState)(!1),{refreshUserInfo:F}=(0,d.k)(),E=async e=>{var t,s;let n={internal_estprice_active:f,milestone_completed_nolimit:m,payable:v,project_id:x,gc_workdays:j,...e},a=await l.vendor.setSettings(n);return 0===a.code?(null==w||w(),null===(t=window.parent)||void 0===t||t.postMessage({type:"reloadOverAllTab",milestone_completed_nolimit:n.milestone_completed_nolimit},"*")):o.ZP.error(null!==(s=null==a?void 0:a.message)&&void 0!==s?s:"Setting failed"),a},S=async()=>{let e=!m;h(e),0!==(await E({milestone_completed_nolimit:e})).code&&h(m)},D=async()=>{if(p)return;let e=!v;g(e),0!==(await E({payable:e})).code&&g(v)},I=async()=>{let e=!f;b(e),0!==(await E({internal_estprice_active:e})).code&&b(f)},A=async e=>{let t=(null==j?void 0:j.includes(e))?j.filter(t=>t!==e):[...j,e];y(t),0!==(await E({gc_workdays:t})).code&&y(j)},P=async()=>{_(!0);let e=await l.vendor.setGlobalSettings({milestone_completed_nolimit:m});if(_(!1),0===e.code)C(!1),o.ZP.success("Global settings updated successfully"),F();else{var t;o.ZP.error(null!==(t=null==e?void 0:e.message)&&void 0!==t?t:"Failed to update global settings")}};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(r.ZP,{isOpen:t,width:"narrow",onCloseClick:s,children:[(0,n.jsx)("div",{className:"text-en-dark-blue text-28 font-circular-bold mb-12",children:"Milestone Settings"}),(0,n.jsx)("div",{className:"text-en-dark-blue text-18 font-circular-bold mb-5 ",children:"Completion settings"}),(0,n.jsx)("div",{className:"p-6 rounded-xl border  ".concat(m?"border-en-divider-dark bg-en-light-gray":"border-en-success bg-en-success/10"),children:(0,n.jsxs)("div",{className:"flex gap-3",children:[(0,n.jsx)("div",{className:"w-12 cursor-pointer",children:(0,n.jsx)(i.Z,{open:!m,onSwitch:S})}),(0,n.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,n.jsx)("div",{className:"text-en-dark-blue text-16",children:"Require milestone photos"}),(0,n.jsxs)("div",{className:"text-en-light-blue text-14 font-normal font-circular",children:["If enabled, milestone photos are required before a milestone can be marked as complete.",(0,n.jsx)("br",{}),"* These settings apply only to the current project. To apply this to all newly created projects, click"," ",(0,n.jsx)("span",{className:"text-en-blue underline cursor-pointer",onClick:()=>C(!0),children:"Apply to Global Settings"}),"."]})]})]})}),(0,n.jsx)("div",{className:"w-full h-[1px] bg-en-bg-line-light my-8"}),(0,n.jsxs)("div",{className:"text-en-dark-blue text-18 font-circular-bold mb-5 ",children:["Client billing settings",(0,n.jsx)("div",{className:"text-en-light-blue text-16",children:"This setting cannot be modified after construction begins"})]}),(0,n.jsx)("div",{className:"p-6 rounded-xl border  ".concat(v?"border-en-success bg-en-success/10":"border-en-divider-dark bg-en-light-gray"),children:(0,n.jsxs)("div",{className:"flex gap-3",children:[(0,n.jsx)("div",{className:"w-12 h-fit ".concat(p?"cursor-not-allowed":"cursor-pointer"),children:(0,n.jsx)(i.Z,{disable:p,open:v,onSwitch:D})}),(0,n.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,n.jsx)("div",{className:"text-en-dark-blue font-circular-bold text-16",children:"Allow milestones to be set as payable or non-payable"}),(0,n.jsx)("div",{className:"text-en-light-blue text-14 font-normal font-circular",children:"If enabled, you will be able to disable asking your clients for payment on certain milestones"})]})]})}),(0,n.jsx)("div",{className:"w-full h-[1px] bg-en-bg-line-light my-8"}),(0,n.jsx)("div",{className:"text-en-dark-blue text-18 font-circular-bold mb-5 ",children:"Internal estimation settings"}),(0,n.jsxs)("div",{className:"p-6 rounded-xl border  ".concat(f?"border-en-success bg-en-success/10":"border-en-divider-dark bg-en-light-gray"),children:[(0,n.jsxs)("div",{className:"flex gap-3",children:[(0,n.jsx)("div",{className:"w-12 cursor-pointer",children:(0,n.jsx)(i.Z,{open:f,onSwitch:I})}),(0,n.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,n.jsx)("div",{className:"text-en-dark-blue font-circular-bold text-16",children:"Allow the addition of projected start and completion dates for each milestone"}),(0,n.jsx)("div",{className:"text-en-light-blue text-14 font-normal font-circular",children:"If enabled, you can set projected start and completion dates for milestones"})]})]}),(0,n.jsxs)("div",{className:"pt-3 mt-3 border-t",children:[(0,n.jsx)("div",{className:"text-sm text-en-dark-blue",children:"Work days"}),(0,n.jsx)("div",{className:"mt-2 flex items-center space-x-2.5",children:null==c?void 0:c.map((e,t)=>(0,n.jsx)("div",{className:"".concat((null==j?void 0:j.includes(e.value))?"bg-en-mid-blue text-white":"bg-white text-en-mid-blue"," w-10 h-10 rounded-full border flex items-center justify-center cursor-pointer"),onClick:()=>A(e.value),children:e.label},t))})]})]})]}),(0,n.jsx)(u,{open:N,onClose:()=>C(!1),completion:m,onApply:P,loading:k})]})}}}]);

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.