1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,233525,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"warnOnce",{enumerable:!0,get:function(){return n}});let n=e=>{}},718967,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n={DecodeError:function(){return b},MiddlewareNotFoundError:function(){return _},MissingStaticPage:function(){return y},NormalizeError:function(){return x},PageNotFoundError:function(){return v},SP:function(){return p},ST:function(){return h},WEB_VITALS:function(){return i},execOnce:function(){return o},getDisplayName:function(){return d},getLocationOrigin:function(){return c},getURL:function(){return u},isAbsoluteUrl:function(){return l},isResSent:function(){return f},loadGetInitialProps:function(){return m},normalizeRepeatedSlashes:function(){return g},stringifyError:function(){return w}};for(var a in n)Object.defineProperty(r,a,{enumerable:!0,get:n[a]});let i=["CLS","FCP","FID","INP","LCP","TTFB"];function o(e){let t,r=!1;return(...n)=>(r||(r=!0,t=e(...n)),t)}let s=/^[a-zA-Z][a-zA-Z\d+\-.]*?:/,l=e=>s.test(e);function c(){let{protocol:e,hostname:t,port:r}=window.location;return`${e}//${t}${r?":"+r:""}`}function u(){let{href:e}=window.location,t=c();return e.substring(t.length)}function d(e){return"string"==typeof e?e:e.displayName||e.name||"Unknown"}function f(e){return e.finished||e.headersSent}function g(e){let t=e.split("?");return t[0].replace(/\\/g,"/").replace(/\/\/+/g,"/")+(t[1]?`?${t.slice(1).join("?")}`:"")}async function m(e,t){let r=t.res||t.ctx&&t.ctx.res;if(!e.getInitialProps)return t.ctx&&t.Component?{pageProps:await m(t.Component,t.ctx)}:{};let n=await e.getInitialProps(t);if(r&&f(r))return n;if(!n)throw Object.defineProperty(Error(`"${d(e)}.getInitialProps()" should resolve to an object. But found "${n}" instead.`),"__NEXT_ERROR_CODE",{value:"E1025",enumerable:!1,configurable:!0});return n}let p="u">typeof performance,h=p&&["mark","measure","getEntriesByName"].every(e=>"function"==typeof performance[e]);class b extends Error{}class x extends Error{}class v extends Error{constructor(e){super(),this.code="ENOENT",this.name="PageNotFoundError",this.message=`Cannot find module for page: ${e}`}}class y extends Error{constructor(e,t){super(),this.message=`Failed to load static file for page: ${e} ${t}`}}class _ extends Error{constructor(){super(),this.code="ENOENT",this.message="Cannot find the middleware module"}}function w(e){return JSON.stringify({message:e.message,stack:e.stack})}},998183,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n={assign:function(){return l},searchParamsToUrlQuery:function(){return i},urlQueryToSearchParams:function(){return s}};for(var a in n)Object.defineProperty(r,a,{enumerable:!0,get:n[a]});function i(e){let t={};for(let[r,n]of e.entries()){let e=t[r];void 0===e?t[r]=n:Array.isArray(e)?e.push(n):t[r]=[e,n]}return t}function o(e){return"string"==typeof e?e:("number"!=typeof e||isNaN(e))&&"boolean"!=typeof e?"":String(e)}function s(e){let t=new URLSearchParams;for(let[r,n]of Object.entries(e))if(Array.isArray(n))for(let e of n)t.append(r,o(e));else t.set(r,o(n));return t}function l(e,...t){for(let r of t){for(let t of r.keys())e.delete(t);for(let[t,n]of r.entries())e.append(t,n)}return e}},93890,e=>{"use strict";var t=e.i(843476);e.s(["default",0,({className:e})=>(0,t.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:e,children:[(0,t.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,t.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})])},998348,e=>{"use strict";let t;var r=((t=r||{}).Space=" ",t.Enter="Enter",t.Escape="Escape",t.Backspace="Backspace",t.Delete="Delete",t.ArrowLeft="ArrowLeft",t.ArrowUp="ArrowUp",t.ArrowRight="ArrowRight",t.ArrowDown="ArrowDown",t.Home="Home",t.End="End",t.PageUp="PageUp",t.PageDown="PageDown",t.Tab="Tab",t);e.s(["Keys",0,r])},80758,e=>{"use strict";var t=Object.defineProperty,r=(e,r,n)=>{let a;return(a="symbol"!=typeof r?r+"":r)in e?t(e,a,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[a]=n,n};let n=new class{constructor(){r(this,"current",this.detect()),r(this,"handoffState","pending"),r(this,"currentId",0)}set(e){this.current!==e&&(this.handoffState="pending",this.currentId=0,this.current=e)}reset(){this.set(this.detect())}nextId(){return++this.currentId}get isServer(){return"server"===this.current}get isClient(){return"client"===this.current}
1detect(){return"u"<typeof window||"u"<typeof document?"server":"client"}handoff(){"pending"===this.handoffState&&(this.handoffState="complete")}get isHandoffComplete(){return"complete"===this.handoffState}};e.s(["env",0,n])},914189,835696,941444,e=>{"use strict";var t=e.i(271645),r=e.i(80758);let n=(e,n)=>{r.env.isServer?(0,t.useEffect)(e,n):(0,t.useLayoutEffect)(e,n)};function a(e){let r=(0,t.useRef)(e);return n(()=>{r.current=e},[e]),r}e.s(["useIsoMorphicEffect",0,n],835696),e.s(["useLatestValue",0,a],941444),e.s(["useEvent",0,function(e){let r=a(e);return t.default.useCallback((...e)=>r.current(...e),[r])}],914189)},544508,368578,e=>{"use strict";function t(e){"function"==typeof queueMicrotask?queueMicrotask(e):Promise.resolve().then(e).catch(e=>setTimeout(()=>{throw e}))}e.s(["microTask",0,t],368578),e.s(["disposables",0,function e(){let r=[],n={addEventListener:(e,t,r,a)=>(e.addEventListener(t,r,a),n.add(()=>e.removeEventListener(t,r,a))),requestAnimationFrame(...e){let t=requestAnimationFrame(...e);return n.add(()=>cancelAnimationFrame(t))},nextFrame:(...e)=>n.requestAnimationFrame(()=>n.requestAnimationFrame(...e)),setTimeout(...e){let t=setTimeout(...e);return n.add(()=>clearTimeout(t))},microTask(...e){let r={current:!0};return t(()=>{r.current&&e[0]()}),n.add(()=>{r.current=!1})},style(e,t,r){let n=e.style.getPropertyValue(t);return Object.assign(e.style,{[t]:r}),this.add(()=>{Object.assign(e.style,{[t]:n})})},group(t){let r=e();return t(r),this.add(()=>r.dispose())},add:e=>(r.includes(e)||r.push(e),()=>{let t=r.indexOf(e);if(t>=0)for(let e of r.splice(t,1))e()}),dispose(){for(let e of r.splice(0))e()}};return n}],544508)},402155,e=>{"use strict";var t=e.i(80758);e.s(["getOwnerDocument",0,function(e){return t.env.isServer?null:e instanceof Node?e.ownerDocument:null!=e&&e.hasOwnProperty("current")&&e.current instanceof Node?e.current.ownerDocument:document}])},397701,e=>{"use strict";e.s(["match",0,function e(t,r,...n){if(t in r){let e=r[t];return"function"==typeof e?e(...n):e}let a=Error(`Tried to handle "${t}" but there is no handler defined. Only defined handlers are: ${Object.keys(r).map(e=>`"${e}"`).join(", ")}.`);throw Error.captureStackTrace&&Error.captureStackTrace(a,e),a}])},732607,e=>{"use strict";e.s(["classNames",0,function(...e){return Array.from(new Set(e.flatMap(e=>"string"==typeof e?e.split(" "):[]))).filter(Boolean).join(" ")}])},700020,e=>{"use strict";let t,r;var n=e.i(271645),a=e.i(732607),i=e.i(397701),o=((t=o||{})[t.None=0]="None",t[t.RenderStrategy=1]="RenderStrategy",t[t.Static=2]="Static",t),s=((r=s||{})[r.Unmount=0]="Unmount",r[r.Hidden=1]="Hidden",r);function l(e,t={},r,i,o){let{as:s=r,children:c,refName:g="ref",...m}=f(e,["unmount","static"]),p=void 0!==e.ref?{[g]:e.ref}:{},h="function"==typeof c?c(t):c;"className"in m&&m.className&&"function"==typeof m.className&&(m.className=m.className(t)),m["aria-labelledby"]&&m["aria-labelledby"]===m.id&&(m["aria-labelledby"]=void 0);let b={};if(t){let e=!1,r=[];for(let[n,a]of Object.entries(t))"boolean"==typeof a&&(e=!0),!0===a&&r.push(n.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`));if(e)for(let e of(b["data-headlessui-state"]=r.join(" "),r))b[`data-${e}`]=""}if(s===n.Fragment&&(Object.keys(d(m)).length>0||Object.keys(d(b)).length>0))if(!(0,n.isValidElement)(h)||Array.isArray(h)&&h.length>1){if(Object.keys(d(m)).length>0)throw Error(['Passing props on "Fragment"!',"",`The current component <${i} /> is rendering a "Fragment".`,"However we need to passthrough the following props:",Object.keys(d(m)).concat(Object.keys(d(b))).map(e=>` - ${e}`).join(` 2`),"","You can apply a few solutions:",['Add an `as="..."` prop, to ensure that we render an actual element instead of a "Fragment".',"Render a single element as the child so that we can forward the props onto that element."].map(e=>` - ${e}`).join(` 3`)].join(` 4`))}else{let e=h.props,t=null==e?void 0:e.className,r="function"==typeof t?(...e)=>(0,a.classNames)(t(...e),m.className):(0,a.classNames)(t,m.className),i=u(h.props,d(f(m,["ref"])));for(let e in b)e in i&&delete b[e];return(0,n.cloneElement)(h,Object.assign({},i,b,p,{ref:o(h.ref,p.ref)},r?{className:r}:{}))}return(0,n.createElement)(s,Object.assign({},f(m,["ref"]),s!==n.Fragment&&p,s!==n.Fragment&&b),h)}function c(...e){return e.every(e=>null==e)?void 0:t=>{for(let r of e)null!=r&&("function"==typeof r?r(t):r.current=t)}}function u(...e){if(0===e.length)return{};if(1===e.length)return e[0];let t={},r={};for(let n of e)for(let e in n)e.startsWith("on")&&"function"==typeof n[e]?(null!=r[e]||(r[e]=[]),r[e].push(n[e])):t[e]=n[e];if(t.disabled||t["aria-disabled"])for(let e in r)/^(on(?:Click|Pointer|Mouse|Key)(?:Down|Up|Press)?)$/.test(e)&&(r[e]=[e=>{var t;return null==(t=null==e?void 0:e.preventDefault)?void 0:t.call(e)}]);for(let e in r)Object.assign(t,{[e](t,...n){for(let a of r[e]){if((t instanceof Event||(null==t?void 0:t.nativeEvent)instanceof Event)&&t.defaultPrevented)return;a(t,...n)}}});return t}function d(e){let t=Object.assign({},e);for(let e in t)void 0===t[e]&&delete t[e];return t}function f(e,t=[]){let r=Object.assign({},e);for(let e of t)e in r&&delete r[e];return r}e.s(["RenderFeatures",0,o,"RenderStrategy",0,s,"compact",0,d,"forwardRefWithAs",0,function(e){var t;return Object.assign((0,n.forwardRef)(e),{displayName:null!=(t=e.displayName)?t:e.name})},"mergeProps",0,function(...e){if(0===e.length)return{};if(1===e.length)return e[0];let t={},r={};for(let n of e)for(let e in n)e.startsWith("on")&&"function"==typeof n[e]?(null!=r[e]||(r[e]=[]),r[e].push(n[e])):t[e]=n[e];for(let e in r)Object.assign(t,{[e](...t){for(let n of r[e])null==n||n(...t)}});return t},"render",0,function({ourProps:e,theirProps:t,slot:r,defaultTag:n,features:a,visible:o=!0,name:s,mergeRefs:d}){d=null!=d?d:c;let f=u(t,e);if(o)return l(f,r,n,s,d);let g=null!=a?a:0;if(2&g){let{static:e=!1,...t}=f;if(e)return l(t,r,n,s,d)}if(1&g){let{unmount:e=!0,...t}=f;return(0,i.match)(+!e,{0:()=>null,1:()=>l({...t,hidden:!0,style:{display:"none"}},r,n,s,d)})}return l(f,r,n,s,d)},"useMergeRefsFn",0,function(){let e=(0,n.useRef)([]),t=(0,n.useCallback)(t=>{for(let r of e.current)null!=r&&("function"==typeof r?r(t):r.current=t)},[]);return(...r)=>{if(!r.every(e=>null==e))return e.current=r,t}}])},294316,e=>{"use strict";var t=e.i(271645),r=e.i(914189);let n=Symbol();e.s(["optionalRef",0,function(e,t=!0){return Object.assign(e,{[n]:t})},"useSyncRefs",0,function(...e){let a=(0,t.useRef)(e);(0,t.useEffect)(()=>{a.current=e},[e]);let i=(0,r.useEvent)(e=>{for(let t of a.current)null!=t&&("function"==typeof t?t(e):t.current=e)});return e.every(e=>null==e||(null==e?void 0:e[n]))?void 0:i}])},674175,e=>{"use strict";var t=e.i(271645);let r=(0,t.createContext)(()=>{});e.s(["CloseProvider",0,function({value:e,children:n}){return t.default.createElement(r.Provider,{value:e},n)}])},233137,e=>{"use strict";let t;var r=e.i(271645);let n=(0,r.createContext)(null);n.displayName="OpenClosedContext";var a=((t=a||{})[t.Open=1]="Open",t[t.Closed=2]="Closed",t[t.Closing=4]="Closing",t[t.Opening=8]="Opening",t);e.s(["OpenClosedProvider",0,function({value:e,children:t}){return r.default.createElement(n.Provider,{value:e},t)},"ResetOpenClosedProvider",0,function({children:e}){return r.default.createElement(n.Provider,{value:null},e)},"State",0,a,"useOpenClosed",0,function(){return(0,r.useContext)(n)}])},746725,e=>{"use strict";var t=e.i(271645),r=e.i(544508);e.s(["useDisposables",0,function(){let[e]=(0,t.useState)(r.disposables);return(0,t.useEffect)(()=>()=>
4e.dispose(),[e]),e}])},83733,e=>{"use strict";let t;var r,n=e.i(247167),a=e.i(271645),i=e.i(544508),o=e.i(746725),s=e.i(835696);void 0!==n.default&&"u">typeof globalThis&&(null==(r=null==n.default?void 0:n.default.env)?void 0:r.NODE_ENV)==="test"&&void 0===Element.prototype.getAnimations&&(Element.prototype.getAnimations=function(){return console.warn(["Headless UI has polyfilled `Element.prototype.getAnimations` for your tests.","Please install a proper polyfill e.g. `jsdom-testing-mocks`, to silence these warnings.","","Example usage:","```js","import { mockAnimationsApi } from 'jsdom-testing-mocks'","mockAnimationsApi()","```"].join(` 5`)),[]});var l=((t=l||{})[t.None=0]="None",t[t.Closed=1]="Closed",t[t.Enter=2]="Enter",t[t.Leave=4]="Leave",t);e.s(["transitionDataAttributes",0,function(e){let t={};for(let r in e)!0===e[r]&&(t[`data-${r}`]="");return t},"useTransition",0,function(e,t,r,n){let[l,c]=(0,a.useState)(r),{hasFlag:u,addFlag:d,removeFlag:f}=function(e=0){let[t,r]=(0,a.useState)(e),n=(0,a.useCallback)(e=>r(e),[t]),i=(0,a.useCallback)(e=>r(t=>t|e),[t]),o=(0,a.useCallback)(e=>(t&e)===e,[t]);return{flags:t,setFlag:n,addFlag:i,hasFlag:o,removeFlag:(0,a.useCallback)(e=>r(t=>t&~e),[r]),toggleFlag:(0,a.useCallback)(e=>r(t=>t^e),[r])}}(e&&l?3:0),g=(0,a.useRef)(!1),m=(0,a.useRef)(!1),p=(0,o.useDisposables)();return(0,s.useIsoMorphicEffect)(()=>{var a;if(e){if(r&&c(!0),!t){r&&d(3);return}return null==(a=null==n?void 0:n.start)||a.call(n,r),function(e,{prepare:t,run:r,done:n,inFlight:a}){let o=(0,i.disposables)();return function(e,{inFlight:t,prepare:r}){if(null!=t&&t.current)return r();let n=e.style.transition;e.style.transition="none",r(),e.offsetHeight,e.style.transition=n}(e,{prepare:t,inFlight:a}),o.nextFrame(()=>{r(),o.requestAnimationFrame(()=>{o.add(function(e,t){var r,n;let a=(0,i.disposables)();if(!e)return a.dispose;let o=!1;a.add(()=>{o=!0});let s=null!=(n=null==(r=e.getAnimations)?void 0:r.call(e).filter(e=>e instanceof CSSTransition))?n:[];return 0===s.length?t():Promise.allSettled(s.map(e=>e.finished)).then(()=>{o||t()}),a.dispose}(e,n))})}),o.dispose}(t,{inFlight:g,prepare(){m.current?m.current=!1:m.current=g.current,g.current=!0,m.current||(r?(d(3),f(4)):(d(4),f(2)))},run(){m.current?r?(f(3),d(4)):(f(4),d(3)):r?f(1):d(1)},done(){var e;m.current&&"function"==typeof t.getAnimations&&t.getAnimations().length>0||(g.current=!1,f(7),r||c(!1),null==(e=null==n?void 0:n.end)||e.call(n,r))}})}},[e,r,t,p]),e?[l,{closed:u(1),enter:u(2),leave:u(4),transition:u(2)||u(4)}]:[r,{closed:void 0,enter:void 0,leave:void 0,transition:void 0}]}],83733)},795817,e=>{"use strict";var t=e.i(271645);let r=(0,t.createContext)(null);e.s(["EmailModalProvider",0,function({children:e}){let[n,a]=(0,t.useState)({isOpen:!1,recipientEmail:"",recipientName:""}),i=(0,t.useCallback)((e,t)=>{console.log("useEmailModal.openEmailModal called:",{email:e,name:t}),a({isOpen:!0,recipientEmail:e,recipientName:t})},[]),o=(0,t.useCallback)(()=>{console.log("useEmailModal.closeEmailModal called"),a(e=>({...e,isOpen:!1}))},[]),s={isOpen:n.isOpen,recipientEmail:n.recipientEmail,recipientName:n.recipientName,openEmailModal:i,closeEmailModal:o};return(0,t.createElement)(r.Provider,{value:s},e)},"useEmailModal",0,function(){let e=(0,t.useContext)(r);if(!e)throw Error("useEmailModal must be used within an EmailModalProvider");return e}])},332529,e=>{"use strict";var t=e.i(247167),r=e.i(624632);let n="https://bsemaovjgsrsbbdkzydo.supabase.co";async function a(e){let t={auth:{persistSession:!1},global:{headers:{"x-client-info":"pages-router-client"}}};return e&&(t.global.headers.Authorization=`Bearer ${e}`),(0,r.createClient)(n,"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImJzZW1hb3ZqZ3Nyc2JiZGt6eWRvIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDE3OTY3MTcsImV4cCI6MjA1NzM3MjcxN30.4LHiJ6GGOn6piGDtM_58FSa1j-r9_K5mngg2IGHMEr4",t)}e.s(["createServerAdminClient",0,function(){let e=t.default.env.SUPABASE_SERVICE_ROLE_KEY||"";if(!e)throw Error("SUPABASE_SERVICE_ROLE_KEY is required but not set. This function can only be used on the server side. If you need to access storage usage from a client component, use the API route /api/storage/usage instead.");return(0,r.createClient)(n,e,{auth:{persistSession:!1,autoRefreshToken:!1},global:{headers:{"x-client-info":"pages-router-admin-client",Authorization:`Bearer ${e}`}}})}
5,"createServerSupabaseClient",0,a])},304507,e=>{"use strict";e.i(703922);var t=e.i(332529);let r=t.createServerAdminClient,n=t.createServerSupabaseClient;e.s(["createServerAdminClient",0,r,"createServerSupabaseClient",0,n])},585093,e=>{"use strict";var t=e.i(304507),r=e.i(703922);async function n(e){console.log("API: Fetching financial defaults for org:",e);try{let n=null;n=await (0,r.getCurrentAccessToken)();let a=await (0,t.createServerSupabaseClient)(n||void 0),{data:i,error:o}=await a.from("organization_financial_defaults").select("*").eq("org_id",e).single();if(o){if("PGRST116"===o.code)return console.log("API: No financial defaults found for org:",e),null;throw console.error("API Error fetching organization financial defaults:",o),o}return console.log("API: Successfully fetched financial defaults:",i?"Found":"Not found"),i}catch(e){return console.error("API: Unexpected error in getOrganizationFinancialDefaults:",e),null}}async function a(e){if(console.log("API: Saving financial defaults:",e),!e.org_id)throw console.error("API: Missing org_id in saveOrganizationFinancialDefaults"),Error("Organization ID is required");if(void 0!==e.default_bank_loan_percentage&&void 0!==e.default_sellers_note_percentage&&void 0!==e.default_buyer_contribution_percentage&&void 0!==e.default_outside_investor_percentage){let t=e.default_bank_loan_percentage+e.default_sellers_note_percentage+e.default_buyer_contribution_percentage+e.default_outside_investor_percentage;if(console.log("API: Checking total percentage:",t),Math.abs(t-100)>.01){let e=`Funding percentages must add up to 100%. Current total: ${t.toFixed(1)}`;throw console.error("API:",e),Error(e)}}else console.log("API: Not all percentage fields are defined, skipping validation");let n={...e};void 0!==n.quality_of_earnings_cost&&(n.quality_of_earnings_cost=Number(n.quality_of_earnings_cost),isNaN(n.quality_of_earnings_cost)&&(n.quality_of_earnings_cost=0)),void 0!==n.legal_due_diligence_cost&&(n.legal_due_diligence_cost=Number(n.legal_due_diligence_cost),isNaN(n.legal_due_diligence_cost)&&(n.legal_due_diligence_cost=0)),void 0!==n.additional_due_diligence_cost&&(n.additional_due_diligence_cost=Number(n.additional_due_diligence_cost),isNaN(n.additional_due_diligence_cost)&&(n.additional_due_diligence_cost=0)),void 0!==n.buyer_salary&&(n.buyer_salary=Number(n.buyer_salary),isNaN(n.buyer_salary)&&(n.buyer_salary=0)),void 0!==n.include_extras_loan&&(n.include_extras_loan=!0===n.include_extras_loan),console.log("API: Cleaned defaults for saving:",n);try{let e=null;e=await (0,r.getCurrentAccessToken)();let a=await (0,t.createServerSupabaseClient)(e||void 0),{data:i,error:o}=await a.from("organization_financial_defaults").upsert(n).select().single();if(o)throw console.error("API Error saving organization financial defaults:",o),o;return console.log("API: Successfully saved financial defaults:",i),i}catch(e){throw console.error("API: Error in saveOrganizationFinancialDefaults:",e),e}}async function i(e){if(console.log("API: Saving listing financial parameters:",e),!e.deal_id)throw console.error("API: Missing deal_id in saveListingFinancialParameters"),Error("Deal ID is required");if(void 0!==e.bank_loan_percentage&&void 0!==e.sellers_note_percentage&&void 0!==e.buyer_contribution_percentage&&void 0!==e.outside_investor_percentage){let t=e.bank_loan_percentage+e.sellers_note_percentage+e.buyer_contribution_percentage+e.outside_investor_percentage;if(console.log("API: Checking total percentage for listing:",t),Math.abs(t-100)>.01){let e=`Funding percentages must add up to 100%. Current total: ${t.toFixed(1)}`;throw console.error("API:",e),Error(e)}}else console.log("API: Not all percentage fields are defined for listing, skipping validation");try{let n=null;n=await (0,r.getCurrentAccessToken)();let a=await (0,t.createServerSupabaseClient)(n||void 0),{data:i,error:o}=await a.from("listing_financial_parameters").upsert(e).select().single();if(o)throw console.error("API Error saving listing financial parameters:",o),o;return console.log("API: Successfully saved listing financial parameters:",i),i}catch(e){throw console.error("API: Error in saveListingFinancialParameters:",e),e}}async function o(e){try{let n=null;n=await (0,r.getCurrentAccessToken)();let a=await (0,t.createServerSupabaseClient)(n||void 0),{data:i,error:o}=await a.from("listings").select("*").eq("deal_id",e).single();if(o||!i)return console.error("Error fetching listing:",o),null;let{data:s,error:l}=await a.from("listing_financial_parameters").select("*").eq("deal_id",e).single();l&&"PGRST116"!==l.code&&console.error("Error fetching listing financial parameters:",l);let c={...i,financials:s||void 0};return s&&void 0===s.include_extras_loan&&(s.include_extras_loan=i.include_extras_loan||!1),c}catch(e){return console.error("Unexpected error in getListingWithFinancials:",e),null}}function s(e,t){let r;r=e<=15e4?.85*e:.75*e;let n=0;return t>12&&e<=5e6&&(e<=1e6?n=0:e>1e6&&e<=5e6&&(n=.035*Math.min(r,1e6)+.0375*Math.max(r-1e6,0))),n}function l(e,t,r){if(e<=0||t<=0||r<=0)return 0;let n=t/100/12,a=12*r-1;return n<1e-6||Math.pow(1+n,a)-1<1e-6?e/a:e*n*Math.pow(1+n,a)/(Math.pow(1+n,a)-1)}e.s(["calculateFinancialMetrics",0,function(e,t){let r=e.offer_price||e.asking_price,n=e.disc_earn&&e.disc_earn>0?e.disc_earn:0,a=e.revenue&&e.revenue>0?e.revenue:0,i=t.quality_of_earnings_cost||0,o=t.legal_due_diligence_cost||0,c=t.additional_due_diligence_cost||0,u=t.buyer_salary||0,d=i+o+c,f=0,g=t.bank_loan_amount,m=!0;if("SBA"===t.loan_type){let e=12*t.loan_term_years-1;f=s(t.bank_loan_amount,e),m=t.bank_loan_amount+(t.include_sba_fees_in_loan?f:0)+(t.include_extras_loan?d:0)<=5e6,t.include_sba_fees_in_loan&&m&&(g=t.bank_loan_amount+f)}let p=l(g,t.loan_interest_rate,t.loan_term_years),h=l(t.sellers_note_amount,t.sellers_note_interest_rate,t.sellers_note_term_years),b=p+h,x=12*b,v=x+u,y=v;!t.include_extras_loan&&d>0&&(y+=d/5);let _=n-y,w=t.buyer_contribution_amount+t.outside_investor_amount;t.include_extras_loan||(w+=d),"SBA"!==t.loan_type||t.include_sba_fees_in_loan||(w+=f);let j=g+t.sellers_note_amount;return{purchasePriceMultiple:n>0?((r&&r>0?r:0)/n).toFixed(2):"N/A",debtToEbitda:n>0?(j/n).toFixed(2):"N/A",monthlyLoanPayment:p.toFixed(2),monthlyNotePayment:h.toFixed(2),totalMonthlyPayment:b.toFixed(2),annualDebtService:x.toFixed(2),buyerSalary:u.toFixed(2),qualityOfEarningsCost:i.toFixed(2),legalDueDiligenceCost:o.toFixed(2),additionalDueDiligenceCost:c.toFixed(2),totalDueDiligenceCosts:d.toFixed(2),coreAnnualCosts:v.toFixed(2),totalAnnualCosts:y.toFixed(2),cashFlow:_.toFixed(2),totalInvestment:w.toFixed(2),buyerCash:(t.buyer_contribution_amount+t.outside_investor_amount).toFixed(2),traditionalDscr:b>0&&n>0?(n/12/b).toFixed(2):"N/A",dscr:b>0&&n>0?(n/12/b).toFixed(2):"N/A",adjustedDscr:x>0&&n>u?((n-u)/x).toFixed(2):"N/A",cashOnCash:w>0&&_>0?(_/w*100).toFixed(2):"N/A",annualDebtServiceToRevenue:a>0&&x>0?(x/a*100).toFixed(2):"N/A",totalExpensesToRevenue:a>0&&y>0?(y/a*100).toFixed(2):"N/A",breakeven:(()=>
5{if(a>0&&n>0){let e=n/a;return e>0&&y>0?(y/e).toFixed(0):"N/A"}return"N/A"})(),timeToRecoup:_>0&&w>0?(w/_).toFixed(1):"N/A",equityGrowth3Year:(()=>{if(t.bank_loan_amount<=0||t.sellers_note_amount<=0||p<=0||h<=0)return"N/A";let e=t.bank_loan_amount,r=t.sellers_note_amount,n=t.loan_interest_rate/100/12,a=t.sellers_note_interest_rate/100/12;for(let t=0;t<36;t++){let t=p-e*n;e=Math.max(0,e-t);let i=h-r*a;r=Math.max(0,r-i)}let i=t.bank_loan_amount+t.sellers_note_amount-(e+r);return(w+i).toFixed(0)})(),postDebtCashFlow:(n-x-u).toFixed(0),sbaFees:f.toFixed(2),includeSBAFeesInLoan:t.include_sba_fees_in_loan||!1,effectiveBankLoanAmount:g.toFixed(2),sbaEligibility:(()=>{if("SBA"!==t.loan_type)return"Not SBA Loan";if(!m)return"Exceeds $5M Limit";if(n<=0||y<=0)return"Cannot Determine";let e=x>0&&n>u?(n-u)/x:0,r=t.buyer_contribution_percentage;return e>=1.25&&r>=10?"Eligible":e>=1&&e<1.25&&r>=10?"May Be Eligible":"Not Eligible"})(),businessResilience:(()=>{if(n<=0||a<=0)return"N/A";let e=a-n+x+u;return a>e?((a-e)/a*100).toFixed(1):"0.0"})(),fiveYearROI:(()=>{if(_<=0||w<=0)return"N/A";let e=5*_,r=g,n=t.sellers_note_amount,a=t.loan_interest_rate/100/12,i=t.sellers_note_interest_rate/100/12;for(let e=0;e<60;e++){if(a>0&&p>0){let e=Math.min(p-r*a,r);r=Math.max(0,r-e)}if(i>0&&h>0){let e=Math.min(h-n*i,n);n=Math.max(0,n-e)}}return((e+(g+t.sellers_note_amount-(r+n)))/w*100).toFixed(0)})()}},"calculateSBAUpfrontFee",0,s,"getListingWithFinancials",0,o,"getOrganizationFinancialDefaults",0,n,"saveListingFinancialParameters",0,i,"saveOrganizationFinancialDefaults",0,a])},444641,e=>{"use strict";var t=e.i(843476),r=e.i(271645),n=e.i(630168),a=e.i(585093);let i=(0,r.createContext)(void 0);e.s(["FinancialDefaultsProvider",0,function({children:e}){let{currentOrg:o}=(0,n.useOrganization)(),[s,l]=(0,r.useState)(null),[c,u]=(0,r.useState)(!1),[d,f]=(0,r.useState)(null),[g,m]=(0,r.useState)(!1);(0,r.useEffect)(()=>{o?(console.log("Organization changed, loading defaults for:",o.name),p()):(console.log("No current organization available"),l(null))},[o?.org_id]);let p=async()=>{if(!o)return void console.log("Cannot load defaults: No current organization");if(c)return void console.log("Already loading defaults, skipping");console.log("Starting to load financial defaults for org:",o.org_id),u(!0),f(null);try{let e=await (0,a.getOrganizationFinancialDefaults)(o.org_id);console.log("Financial defaults loaded:",e?"Found":"Not found"),l(e),m(!0)}catch(e){console.error("Error loading financial defaults:",e),f(e)}finally{u(!1)}},h=async e=>{if(!o)throw Error("No current organization selected");u(!0),f(null);try{let t={...e,org_id:o.org_id};console.log("Saving financial defaults:",t);let r=await (0,a.saveOrganizationFinancialDefaults)(t);console.log("Save result:",r),l(r)}catch(e){throw console.error("Error saving financial defaults:",e),f(e),e}finally{u(!1)}};return(0,t.jsx)(i.Provider,{value:{orgDefaults:s,loading:c,error:d,saveDefaults:h,loadDefaults:p},children:e})},"useFinancialDefaults",0,function(){let e=(0,r.useContext)(i);if(void 0===e)throw Error("useFinancialDefaults must be used within a FinancialDefaultsProvider");return e}])},515226,e=>{"use strict";e.s(["processTemplateVariables",0,function(e,t,r={}){let{formatters:n={},fallbackText:a="",preserveMissingVariables:i=!0}=r,o={currency:(e,t="USD")=>"number"!=typeof e?String(e):new Intl.NumberFormat("en-US",{style:"currency",currency:t}).format(e),date:(e,t="short")=>{if(!e)return"";let r=e instanceof Date?e:new Date(e);if(isNaN(r.getTime()))return String(e);switch(t){case"short":default:return r.toLocaleDateString();case"long":return r.toLocaleDateString(void 0,{weekday:"long",year:"numeric",month:"long",day:"numeric"});case"iso":return r.toISOString()}},uppercase:e=>String(e).toUpperCase(),lowercase:e=>String(e).toLowerCase(),capitalize:e=>{let t=String(e);return t.charAt(0).toUpperCase()+t.slice(1)},...n};return e.replace(/\{\{\s*([\w.]+)(?:\|(.*?))?\s*\}\}/g,(e,r,n)=>{let s=function(e,t){let r=t.split("."),n=e;for(let e of r){if(null==n)return;n=n[e]}return n}(t,r);if(null==s)return i?e:n&&!n.includes("format:")?n.trim():a;if(n&&n.includes("format:")){let e=n.match(/format:"([^"]*)"/);if(e){let[t,r]=e[1].split(":");if(t&&o[t])return o[t](s,r)}}return String(s)})}])},604614,e=>{"use strict";var t=e.i(271645),r=e.i(515226);e.s(["useEmailTemplates",0,function(e,n){let[a,i]=(0,t.useState)([]),[o,s]=(0,t.useState)(""),[l,c]=(0,t.useState)(""),[u,d]=(0,t.useState)(""),[f,g]=(0,t.useState)(!1),[m,p]=(0,t.useState)(null);(0,t.useEffect)(()=>{(async()=>{g(!0),p(null);try{let e=await fetch("/api/email-templates");if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.message||`Failed to fetch templates: ${e.status}`)}let t=(await e.json()).map(e=>({...e,id:e.id||e.template_id}));i(t.filter(e=>!e.is_archived))}catch(e){console.error("Error fetching templates:",e),p(e instanceof Error?e.message:"Unknown error fetching templates")}
5finally{g(!1)}})()},[]);let h=(0,t.useCallback)(t=>{let i=a.find(e=>e.template_id===t);if(!i)return void p("Template not found");s(t);try{let a=(0,r.processTemplateVariables)(i.subject,e),o=(0,r.processTemplateVariables)(i.body,e);c(a),d(o),t&&(fetch("/api/email-templates/usage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({templateId:t})}).catch(e=>{}),n&&n(t))}catch(e){p("Error processing template variables")}},[a,e,n]),b=(0,t.useCallback)(()=>{let e=new Set;return a.forEach(t=>{t.category&&e.add(t.category)}),Array.from(e)},[a]),x=(0,t.useCallback)(e=>e?a.filter(t=>t.category===e):a,[a]);return{templates:a,selectedTemplateId:o,processedSubject:l,processedBody:u,isLoading:f,error:m,selectTemplate:h,categories:b(),filterByCategory:x}}])},450249,e=>{"use strict";var t=e.i(843476),r=e.i(271645),n=e.i(155487),a=e.i(600019);let i=()=>(0,t.jsx)("div",{className:"screen_loader animate__animated fixed inset-0 z-[60] grid place-content-center bg-[#fafafa] dark:bg-[#060818]",children:(0,t.jsxs)("svg",{width:"64",height:"64",viewBox:"0 0 135 135",xmlns:"http://www.w3.org/2000/svg",fill:"#4361ee",children:[(0,t.jsx)("path",{d:"M67.447 58c5.523 0 10-4.477 10-10s-4.477-10-10-10-10 4.477-10 10 4.477 10 10 10zm9.448 9.447c0 5.523 4.477 10 10 10 5.522 0 10-4.477 10-10s-4.478-10-10-10c-5.523 0-10 4.477-10 10zm-9.448 9.448c-5.523 0-10 4.477-10 10 0 5.522 4.477 10 10 10s10-4.478 10-10c0-5.523-4.477-10-10-10zM58 67.447c0-5.523-4.477-10-10-10s-10 4.477-10 10 4.477 10 10 10 10-4.477 10-10z",children:(0,t.jsx)("animateTransform",{attributeName:"transform",type:"rotate",from:"0 67 67",to:"-360 67 67",dur:"2.5s",repeatCount:"indefinite"})}),(0,t.jsx)("path",{d:"M28.19 40.31c6.627 0 12-5.374 12-12 0-6.628-5.373-12-12-12-6.628 0-12 5.372-12 12 0 6.626 5.372 12 12 12zm30.72-19.825c4.686 4.687 12.284 4.687 16.97 0 4.686-4.686 4.686-12.284 0-16.97-4.686-4.687-12.284-4.687-16.97 0-4.687 4.686-4.687 12.284 0 16.97zm35.74 7.705c0 6.627 5.37 12 12 12 6.626 0 12-5.373 12-12 0-6.628-5.374-12-12-12-6.63 0-12 5.372-12 12zm19.822 30.72c-4.686 4.686-4.686 12.284 0 16.97 4.687 4.686 12.285 4.686 16.97 0 4.687-4.686 4.687-12.284 0-16.97-4.685-4.687-12.283-4.687-16.97 0zm-7.704 35.74c-6.627 0-12 5.37-12 12 0 6.626 5.373 12 12 12s12-5.374 12-12c0-6.63-5.373-12-12-12zm-30.72 19.822c-4.686-4.686-12.284-4.686-16.97 0-4.686 4.687-4.686 12.285 0 16.97 4.686 4.687 12.284 4.687 16.97 0 4.687-4.685 4.687-12.283 0-16.97zm-35.74-7.704c0-6.627-5.372-12-12-12-6.626 0-12 5.373-12 12s5.374 12 12 12c6.628 0 12-5.373 12-12zm-19.823-30.72c4.687-4.686 4.687-12.284 0-16.97-4.686-4.686-12.284-4.686-16.97 0-4.687 4.686-4.687 12.284 0 16.97 4.686 4.687 12.284 4.687 16.97 0z",children:(0,t.jsx)("animateTransform",{attributeName:"transform",type:"rotate",from:"0 67 67",to:"360 67 67",dur:"8s",repeatCount:"indefinite"})})]})});var o=e.i(725665);let s=function({children:e}){let s=(0,n.useSelector)(e=>e.themeConfig),l=(0,n.useDispatch)(),{initLocale:c}=(0,o.getTranslation)(),[u,d]=(0,r.useState)(!0);return(0,r.useEffect)(()=>
5{l((0,a.toggleTheme)(localStorage.getItem("theme")||s.theme)),l((0,a.toggleMenu)(localStorage.getItem("menu")||s.menu)),l((0,a.toggleLayout)(localStorage.getItem("layout")||s.layout)),l((0,a.toggleRTL)(localStorage.getItem("rtlClass")||s.rtlClass)),l((0,a.toggleAnimation)(localStorage.getItem("animation")||s.animation)),l((0,a.toggleNavbar)(localStorage.getItem("navbar")||s.navbar)),l((0,a.toggleSemidark)(localStorage.getItem("semidark")||s.semidark)),c(s.locale),d(!1)},[l,c,s.theme,s.menu,s.layout,s.rtlClass,s.animation,s.navbar,s.locale,s.semidark]),(0,t.jsx)("div",{className:`${s.sidebar&&"toggle-sidebar"||""} ${s.menu} ${s.layout} ${s.rtlClass} main-section relative font-nunito text-sm font-normal antialiased`,children:u?(0,t.jsx)(i,{}):e})};var l=e.i(308158),c=e.i(164645);let u=(0,l.combineReducers)({themeConfig:a.default}),d=(0,c.configureStore)({reducer:u});var f=e.i(795817),g=e.i(854878),m=e.i(854056),p=e.i(93890),h=e.i(604614),b=e.i(360339);function x({recipientEmail:e,recipientName:n,contexts:a={},onClose:i}){let[o,s]=(0,r.useState)(e),[l,c]=(0,r.useState)(""),[u,d]=(0,r.useState)(""),[f,g]=(0,r.useState)(""),[m,v]=(0,r.useState)(""),[y,_]=(0,r.useState)(!1),[w,j]=(0,r.useState)(!1),N=(0,r.useRef)(null),[k,S]=(0,r.useState)(""),E=n.split(" ")[0],C={recipient:{name:E,email:e},contact:{...a.contact||{},first_name:E,last_name:n.split(" ").slice(1).join(" "),email:e},...a},{templates:A,selectedTemplateId:F,processedSubject:P,processedBody:O,selectTemplate:T,categories:I,isLoading:M,error:D}=(0,h.useEmailTemplates)(C),L=A.reduce((e,t)=>{let r=t.category||"General";return e[r]||(e[r]=[]),e[r].push(t),e},{});(0,r.useEffect)(()=>{F&&(g(P),v(O))},[F,P,O]);let z=(0,r.useCallback)(()=>{let e=[o];l&&e.push(`cc=${l}`),u&&e.push(`bcc=${u}`);let t=m.replace(/<\/p>\s*<p>/g,"\n").replace(/<p>/g,"").replace(/<\/p>/g,"").replace(/<br\s*\/?>/gi,"\n").replace(/<li>/g,"* ").replace(/<\/li>/g,"\n").replace(/<a\s+(?:[^>]*?\s+)?href="([^"]*)"[^>]*>(.*?)<\/a>/gi,(e,t,r)=>`${r} (${t})`).replace(/<[^>]+>/g,"").replace(/\n{3,}/g,"\n\n").replace(/[ \t]+/g," ").trim(),r=`mailto:${e.join("?")}${e.length>1?"&":"?"}subject=${encodeURIComponent(f)}&body=${encodeURIComponent(t)}`;window.location.href=r},[o,l,u,f,m]);return(0,t.jsxs)("div",{className:"flex flex-col h-full bg-white dark:bg-black",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between p-4 border-b border-[#e0e6ed] dark:border-[#1b2e4b]",children:[(0,t.jsx)("h4",{className:"text-lg font-semibold dark:text-gray-400",children:"New Message"}),(0,t.jsx)("div",{className:"flex items-center gap-2",children:i&&(0,t.jsx)("button",{onClick:i,className:"hover:text-primary",children:(0,t.jsx)(p.default,{className:"w-5 h-5"})})})]}),(0,t.jsx)("div",{className:"flex-1 p-4 space-y-4",children:(0,t.jsxs)("div",{className:"flex flex-col space-y-4",children:[(0,t.jsxs)("div",{className:"flex items-center border-b border-[#e0e6ed] dark:border-[#1b2e4b] py-2",children:[(0,t.jsx)("span",{className:"w-16 text-white-dark",children:"To:"}),(0,t.jsx)("input",{type:"text",value:o,onChange:e=>s(e.target.value),className:"form-input border-0 bg-transparent focus:outline-none flex-1"}),!y&&!w&&(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("button",{onClick:()=>_(!0),className:"text-sm text-primary hover:underline",children:"Cc"}),(0,t.jsx)("button",{onClick:()=>j(!0),className:"text-sm text-primary hover:underline",children:"Bcc"})]})]}),y&&(0,t.jsxs)("div",{className:"flex items-center border-b border-[#e0e6ed] dark:border-[#1b2e4b] py-2",children:[(0,t.jsx)("span",{className:"w-16 text-white-dark",children:"Cc:"}),(0,t.jsx)("input",{type:"text",value:l,onChange:e=>c(e.target.value),className:"form-input border-0 bg-transparent focus:outline-none flex-1"})]}),w&&(0,t.jsxs)("div",{className:"flex items-center border-b border-[#e0e6ed] dark:border-[#1b2e4b] py-2",children:[(0,t.jsx)("span",{className:"w-16 text-white-dark",children:"Bcc:"}),(0,t.jsx)("input",{type:"text",value:u,onChange:e=>d(e.target.value),className:"form-input border-0 bg-transparent focus:outline-none flex-1"})]}),(0,t.jsxs)("div",{className:"flex items-center border-b border-[#e0e6ed] dark:border-[#1b2e4b] py-2",children:[(0,t.jsx)("span",{className:"w-16 text-white-dark",children:"Subject:"}),(0,t.jsx)("input",{type:"text",value:f,onChange:e=>g(e.target.value),placeholder:"Enter Subject",className:"form-input border-0 bg-transparent focus:outline-none flex-1"})]}),(0,t.jsx)("div",{className:"flex-1",children:(0,t.jsx)(b.default,{value:m,onChange:v,variant:"full",placeholder:"Type your message here...",style:{height:"calc(100vh - 500px)",marginBottom:"3rem"}})})]})}),(0,t.jsxs)("div",{className:"flex items-center justify-between p-4 bg-white dark:bg-black border-t",children:[(0,t.jsxs)("div",{className:"flex items-center relative",children:[(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsxs)("button",{className:"flex items-center gap-2 text-sm text-gray-500 hover:text-gray-700",onClick:()=>{N.current&&(N.current.focus(),N.current.click())},disabled:M||0===A.length,children:[(0,t.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"w-5 h-5",children:[(0,t.jsx)("rect",{width:"20",height:"14",x:"2",y:"5",rx:"2"}),(0,t.jsx)("line",{x1:"2",x2:"22",y1:"10",y2:"10"})]}),(0,t.jsx)("span",{children:M?"Loading Templates...":"Select Template"}),(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"w-4 h-4",children:(0,t.jsx)("path",{d:"m6 9 6 6 6-6"})})]}),(0,t.jsxs)("select",{ref:N,className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer",value:k,disabled:M||0===A.length,onChange:e=>{let t=e.target.value;"manage"===t?window.open("/settings/mail-templates","_blank"):(S(t),t&&(T(t),g(P),v(O)))},children:[(0,t.jsx)("option",{value:"",children:"Select a template"}),Object.entries(L).map(([e,r])=>(0,t.jsx)("optgroup",{label:e,children:r.map(e=>(0,t.jsx)("option",{value:e.template_id,children:e.name},e.template_id))},e)),(0,t.jsx)("option",{value:"manage",className:"text-blue-500 border-t border-gray-200 dark:border-gray-700 pt-1 mt-1",children:"Manage Templates"})]})]}),D&&(0,t.jsx)("p",{className:"text-red-500 text-xs ml-2",children:D})]}),(0,t.jsxs)("div",{className:"flex items-center",children:[(0,t.jsxs)("div",{className:"group relative inline-block mr-2",children:[(0,t.jsx)("div",{className:"w-4 h-4 text-gray-400 hover:text-gray-600 cursor-help flex items-center justify-center rounded-full border border-gray-400",children:(0,t.jsx)("span",{className:"text-xs font-bold",children:"?"})}),(0,t.jsx)("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity duration-200 bg-black text-white text-xs rounded py-1 px-2 absolute z-10 bottom-full left-1/2 transform -translate-x-1/2 mb-1 w-48 text-center pointer-events-none",children:"This will open your default email client with a draft email for final review and sending."})]}),(0,t.jsxs)("button",{type:"button",className:"flex items-center gap-2 px-4 py-2 text-sm font-medium text-white bg-[#4f46e5] rounded-lg hover:bg-[#4338ca] shadow-sm",onClick:z,children:[(0,t.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"w-5 h-5",children:[(0,t.jsx)("path",{d:"m22 2-7 20-4-9-9-4Z"}),(0,t.jsx)("path",{d:"M22 2 11 13"})]}),"Send"]})]})]})]})}function v(){let{isOpen:e,recipientEmail:n,recipientName:a,closeEmailModal:i}=(0,f.useEmailModal)();return(0,t.jsx)(m.Transition,{appear:!0,show:e,as:r.Fragment,children:(0,t.jsxs)(g.Dialog,{as:"div",className:"relative z-50",onClose:i,children:[(0,t.jsx)(m.Transition.Child,{as:r.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-200",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,t.jsx)("div",{className:"fixed inset-0 bg-black bg-opacity-25 dark:bg-opacity-40"})}),(0,t.jsx)("div",{className:"fixed inset-0 overflow-y-auto",children:(0,t.jsx)("div",{className:"flex min-h-full items-center justify-center p-4 text-center",children:(0,t.jsx)(m.Transition.Child,{as:r.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0 scale-95",enterTo:"opacity-100 scale-100",leave:"ease-in duration-200",leaveFrom:"opacity-100 scale-100",leaveTo:"opacity-0 scale-95",children:(0,t.jsx)(g.Dialog.Panel,{className:"w-full max-w-4xl transform overflow-hidden rounded-lg bg-white dark:bg-black text-left align-middle shadow-xl transition-all",children:(0,t.jsx)(x,{recipientEmail:n,recipientName:a,onClose:i})})})})})]})})}function y({children:e}){return(0,r.createElement)(f.EmailModalProvider,null,(0,r.createElement)(r.Fragment,null,e,(0,r.createElement)(v)))}e.s(["default",0,({children:e})=>(0,t.jsx)(n.Provider,{store:d,children:(0,t.jsx)(r.Suspense,{fallback:(0,t.jsx)(i,{}),children:(0,t.jsx)(y,{children:(0,t.jsx)(s,{children:e})})})})],450249)},480475,e=>{"use strict";var t=e.i(843476),r=e.i(894746),n=e.i(271645),a=e.i(458324);let i=()=>(0,t.jsx)("div",{className:"flex h-screen items-center justify-center",children:(0,t.jsx)("div",{className:"animate-spin rounded-full border-4 border-primary border-t-transparent h-12 w-12"})}),o=({onRetry:e,onLogin:r})=>(0,t.jsx)("div",{className:"flex h-screen items-center justify-center",children:(0,t.jsxs)("div",{className:"text-center max-w-md p-6",children:[(0,t.jsx)("div",{className:"mb-4",children:(0,t.jsx)("svg",{className:"mx-auto h-12 w-12 text-yellow-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),(0,t.jsx)("h2",{className:"text-xl font-semibold mb-2 text-gray-800 dark:text-white",children:"Loading is taking longer than expected"}),(0,t.jsx)("p",{className:"text-gray-600 dark:text-gray-300 mb-6",children:"There may be a connection issue. Please try again or go to the login page."}),(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row gap-3 justify-center",children:[(0,t.jsx)("button",{onClick:e,className:"px-4 py-2 bg-primary text-white rounded-lg hover:bg-primary/90 transition-colors",children:"Try Again"}),(0,t.jsx)("button",{onClick:r,className:"px-4 py-2 bg-gray-200 dark:bg-gray-700 text-gray-800 dark:text-white rounded-lg hover:bg-gray-300 dark:hover:bg-gray-600 transition-colors",children:"Go to Login"})]})]})});e.s(["default",0,({children:e})=>{let{loading:s,currentUser:l,error:c}
5=(0,r.useAuth)(),[u,d]=(0,n.useState)(!1),[f,g]=(0,n.useState)(!1),m=(0,n.useCallback)(()=>{if("u">typeof document)for(let e of document.cookie.split(";")){let[t]=e.split("="),r=t.trim();(r.startsWith("sb-")||r.includes("supabase"))&&(document.cookie=`${r}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`)}window.location.reload()},[]),p=(0,n.useCallback)(()=>{if("u">typeof document)for(let e of document.cookie.split(";")){let[t]=e.split("="),r=t.trim();(r.startsWith("sb-")||r.includes("supabase"))&&(document.cookie=`${r}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`)}window.location.href="/login"},[]);return((0,n.useEffect)(()=>{if(s&&!u){let e=setTimeout(()=>{console.error("[Auth] Loading state has persisted for 10 seconds - showing error UI"),d(!0),g(!0),fetch("/api/monitoring/login-error",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({warning:"login_hang_detected",duration_ms:1e4,breadcrumbs:(0,a.getLoginBreadcrumbs)(),has_user:!!l,timestamp:new Date().toISOString(),url:window.location.href,localStorage:{hasOrgId:!!localStorage.getItem("currentOrgId"),hasTheme:!!localStorage.getItem("theme")}})}).catch(()=>{})},1e4);return()=>clearTimeout(e)}s||(d(!1),g(!1))},[s,l,u]),f||c&&s)?(0,t.jsx)(o,{onRetry:m,onLogin:p}):s?(0,t.jsx)(i,{}):(0,t.jsx)(t.Fragment,{children:e})}])},93878,e=>{"use strict";var t=e.i(843476),r=e.i(271645),n=e.i(618566),a=e.i(894746),i=e.i(703922);e.s(["default",0,function(){let{currentUser:e,loading:o}=(0,a.useAuth)(),s=(0,n.usePathname)(),[l,c]=(0,r.useState)(!1),[u,d]=(0,r.useState)(!0);(0,r.useEffect)(()=>{s&&["/auth","/login","/signup","/forgot-password","/reset-password"].some(e=>s.startsWith(e))||o||!e||(async()=>{try{let t=(0,i.createBrowserSupabaseClient)(),r=e.user_id||e.id;if(!r)return void d(!1);let{data:n,error:a}=await t.from("users").select("has_completed_onboarding_tour").eq("user_id",r).single();if(a){console.error("Error checking tour status:",a),d(!1);return}n?.has_completed_onboarding_tour||setTimeout(()=>{c(!0)},1e3),d(!1)}catch(e){console.error("Error checking tour status:",e),d(!1)}})()},[e,o,s]);let f=async()=>{if(c(!1),e)try{let t=(0,i.createBrowserSupabaseClient)(),r=e.user_id||e.id;if(!r)return;await t.from("users").update({has_completed_onboarding_tour:!0}).eq("user_id",r),e&&(e.has_completed_onboarding_tour=!0)}catch(e){console.error("Error marking tour as completed:",e)}};return s&&["/auth","/login","/signup","/forgot-password","/reset-password"].some(e=>s.startsWith(e))||u||!l?null:(0,t.jsx)("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black bg-opacity-75",children:(0,t.jsxs)("div",{className:"relative bg-white dark:bg-dark rounded-lg shadow-xl max-w-4xl w-full mx-4 max-h-[90vh] overflow-hidden",children:[(0,t.jsx)("button",{onClick:f,className:"absolute top-4 right-4 z-10 w-8 h-8 flex items-center justify-center rounded-full bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600 transition-colors","aria-label":"Close",children:(0,t.jsx)("svg",{className:"w-5 h-5 text-gray-700 dark:text-gray-300",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),(0,t.jsxs)("div",{className:"p-6 border-b border-gray-200 dark:border-gray-700",children:[(0,t.jsx)("h2",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:"Welcome to AlphaY! ð"}),(0,t.jsx)("p",{className:"mt-2 text-gray-600 dark:text-gray-400",children:"Watch this quick video to get started with the platform."})]}),(0,t.jsx)("div",{className:"relative",style:{paddingBottom:"56.25%"},children:(0,t.jsx)("iframe",{className:"absolute top-0 left-0 w-full h-full",src:"https://www.youtube.com/embed/v7lzy-ogjmY?autoplay=0&rel=0",title:"AlphaY Getting Started Video",frameBorder:"0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})}),(0,t.jsx)("div",{className:"p-6 border-t border-gray-200 dark:border-gray-700 flex justify-end",children:(0,t.jsx)("button",{onClick:f,className:"px-6 py-2 bg-primary text-white rounded-lg hover:bg-primary-dark transition-colors font-medium",children:"Got it, thanks!"})})]})})}])}]);
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.