@archerjessop/utilities 7.16.0 → 7.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createNavigationGuard as e}from"./createNavigationGuard.js";import{createPanel as t}from"./createPanel.js";import{runReveals as
|
|
1
|
+
import{createNavigationGuard as e}from"./createNavigationGuard.js";import{createPanel as t}from"./createPanel.js";import{runReveals as a}from"./runReveals.js";import{syncInterestRateForUnits as n}from"./interestRateSync.js";import{setupPriceClickHandler as r,setupCapRateClickHandler as o,setupDownPaymentClickHandler as c,setupNoiClickHandler as i,setupAwningLinkHandler as l,setupDiscountButtonHandler as p}from"../ui/click-handlers.js";import{calculateFinancials as s}from"../financial/calculateFinancials.js";import{calculateDOM as u}from"../../date/utilities.js";import{normalizeWhitespace as d}from"../../formatting/text.js";function createPipeline({adapter:m,config:y,ctx:f,exportOps:g,finance:E,render:b,resolveCssUrls:h,services:w}){const{state:C,updateState:P}=f,listingId=()=>m.getListingId(window.location.href);function watchLateFields(e){const isPresent=e=>"string"==typeof e&&""!==e.trim()&&"Not found"!==e,applyLateFields=()=>{const e=m.scrape();if(!e)return!1;const t=d(e.contact),a=d(e.phone),n=d(e.listingDate);return b.updateElement("prop-contact",t),b.updateElement("prop-phone",a),b.updateElement("prop-dom",u(n)),isPresent(t)&&isPresent(a)&&isPresent(n)};if(applyLateFields())return;let t=!1;let n=Math.ceil(1e4/300);const tick=()=>{e.isStale()||(!t&&y.reveals?.length&&(t=!0,a(y.reveals).finally(()=>{t=!1})),applyLateFields()||n--<=0||setTimeout(tick,300))};setTimeout(tick,300)}async function updateFooterData(){const t=e(listingId);if(t.capture(),y.reveals?.length&&(await a(y.reveals),t.isStale()))return;const d=E.scrapeAndApply();if(!d)return console.error("❌ Malformed listing data — missing a contract field, refusing to render"),void b.updateElement("prop-name","Data error — see console");const m=d.unitCount??4;P({numberOfUnits:m});const g=document.getElementById("ln-units-input");g&&(g.value=m),n(C,P,m),b.updateElement("prop-name",d.name),b.updateElement("prop-price",C.priceWasDefaulted?"No price":d.price),b.updateElement("prop-contact",d.contact),b.updateElement("prop-phone",d.phone),b.updateElement("prop-dom",u(d.listingDate)),b.updatePriceLabel(),b.updateCapRateLabel(),b.syncUnitsFieldForType(C.currentPropertyType,d.bedroomCount),function(e){const t=document.getElementById("prop-name");t&&e.name&&"Not found"!==e.name&&(t.style.cursor="pointer",t.style.textDecoration="underline",t.onclick=()=>{const t=`https://www.google.com/maps/search/${encodeURIComponent(e.name)}`;window.open(t,"_blank")});const a={getCurrentPrice:b.getCurrentPrice,recalculateFinancials:E.recalculateFinancials,state:C,updatePercentageLabels:b.updatePercentageLabels,updatePriceLabel:b.updatePriceLabel,updateState:P},n=document.getElementById("prop-price");r(n,n?.closest(".metric")?.querySelector(".metric-label"),a);const s=document.getElementById("prop-cap");o(s,s?.closest(".metric")?.querySelector(".metric-label"),a);const u=document.getElementById("prop-down");c(u,u?.closest(".metric")?.querySelector(".metric-label"),a);const d=document.getElementById("prop-noi");i(d,d?.closest(".metric")?.querySelector(".metric-label"),a),l(document.getElementById("prop-noi-awning")),p(document.getElementById("ln-discount-btn"),a)}(d),watchLateFields(t);const h=C.isUsingEstimatedCapRate?`${C.currentEstimatedCapRate}%`:d.capRate,S=await s(f,d.price,h,C.currentPropertyType,d.name);if(t.isStale())return;b.applyFinancials(S),b.updateActiveCapDisplay();const F=await w.loadLeadStatus(d.name);if(t.isStale())return;b.updateElement("prop-lead-status",F.leadStatus),b.updateLeadStatusTooltip(F);const T=await w.loadStrValue(d.name,t);t.isStale()||T&&"str"===C.currentPropertyType&&(P({baseNOI:null}),await E.recalculateFinancials(),t.isStale())||(await w.loadDebt(d.name,t),t.isStale()||b.updateEquityDisplay())}let S=!1,F=null;return{runPipeline:function(){S=!1,F&&(F.disconnect(),F=null),t({callbacks:{onExportClick:g.handleExportClick,onInterestRateTypeChange:()=>E.recalculateFinancials(),onPropertyTypeChange:()=>{E.handlePropertyTypeChange(),b.updateCapRateLabel();const e=m.scrape();b.syncUnitsFieldForType(C.currentPropertyType,e?.bedroomCount),E.recalculateFinancials()},state:C,updateState:P},cssUrls:h(y.cssFiles),defaultPropertyType:y.defaultPropertyType});const stopObserver=()=>{F&&(F.disconnect(),F=null)},tryImmediateUpdate=(e=!1)=>!!(()=>{const e=document.getElementById("prop-name"),t=document.getElementById("prop-price");return!!(e&&t&&e.textContent.trim()&&t.textContent.trim())})()&&(!(!e&&!(()=>{const e=m.scrape();return!!e&&"Not found"!==e.price&&!e.priceWasDefaulted})())&&((async()=>{S||(S=!0,await updateFooterData())})(),!0));if(tryImmediateUpdate())return;F=new MutationObserver(()=>{tryImmediateUpdate()&&stopObserver()}),F.observe(document.body,{childList:!0,subtree:!0});let e=0;const fallbackPoll=()=>{S||(tryImmediateUpdate(e>=8e3)?stopObserver():(e+=300,setTimeout(fallbackPoll,300)))};setTimeout(fallbackPoll,300)},updateFooterData:updateFooterData}}export{createPipeline};
|
|
2
2
|
//# sourceMappingURL=pipeline.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline.js","sources":["../../../src/browser/widget/pipeline.js"],"sourcesContent":["// Pipeline unit: the re-runnable footer pipeline — builds the shared panel, wires the clickable\r\n// elements, runs the main async update (scrape -> financials -> lead status -> STR -> equity with\r\n// the navigation guard between awaits), and drives the immediate/observer/load entry points.\r\n// Extracted verbatim from createAnalyzer (T12).\r\n\r\nimport { createNavigationGuard } from \"./createNavigationGuard.js\";\r\nimport { createPanel } from \"./createPanel.js\";\r\nimport { runReveals } from \"./runReveals.js\";\r\nimport { syncInterestRateForUnits } from \"./interestRateSync.js\";\r\nimport {\r\n setupAwningLinkHandler,\r\n setupCapRateClickHandler,\r\n setupDiscountButtonHandler,\r\n setupDownPaymentClickHandler,\r\n setupNoiClickHandler,\r\n setupPriceClickHandler,\r\n} from \"../ui/click-handlers.js\";\r\nimport { calculateFinancials } from \"../financial/calculateFinancials.js\";\r\nimport { calculateDOM } from \"../../date/utilities.js\";\r\nimport { normalizeWhitespace } from \"../../formatting/text.js\";\r\n\r\n// Some sites (e.g. Zillow) client-render parts of a listing — the listing-agent attribution and\r\n// the price-history table — a beat AFTER first paint, so the pipeline's single initial scrape\r\n// reads \"Not found\" for the fields they carry (contact, phone, listing date). After the first\r\n// render we poll the pure scrape() for just those display fields and fill them in as they arrive,\r\n// until all are present or this budget elapses. Poll-count based (like runReveals' waitForSelector)\r\n// so it stays bounded and predictable under heavy DOM churn.\r\nconst LATE_FIELD_TIMEOUT = 10000;\r\nconst LATE_FIELD_POLL_INTERVAL = 300;\r\n\r\n// The main render waits for the page to expose a scrapeable PRICE before it commits — price is the\r\n// field every financial metric derives from. On a full page load the server-rendered JSON-LD has it\r\n// immediately; on an SPA overlay (Zillow search -> listing) it is client-painted a beat after the\r\n// navigation fires, so an eager scrape would read no price and paint N/A everywhere with no recovery.\r\n// If the price never becomes scrapeable (a genuinely price-less/off-market listing) the timeout lets\r\n// the render proceed anyway, so the panel never hangs on \"Loading...\" — it shows the honest no-price state.\r\nconst DATA_READY_TIMEOUT = 8000;\r\nconst DATA_READY_POLL_INTERVAL = 300;\r\n\r\nexport function createPipeline({ adapter, config, ctx, exportOps, finance, render, resolveCssUrls, services }) {\r\n const { state, updateState } = ctx;\r\n const listingId = () => adapter.getListingId(window.location.href);\r\n\r\n function setupClickableElements(data) {\r\n const nameElement = document.getElementById(\"prop-name\");\r\n if (nameElement && data.name && data.name !== \"Not found\") {\r\n nameElement.style.cursor = \"pointer\";\r\n nameElement.style.textDecoration = \"underline\";\r\n nameElement.onclick = () => {\r\n const searchUrl = `https://www.google.com/maps/search/${encodeURIComponent(data.name)}`;\r\n window.open(searchUrl, \"_blank\");\r\n };\r\n }\r\n\r\n // The shared click-handlers read callbacks.state / callbacks.updateState — the engine's\r\n // ctx is injected here (no global-state coupling).\r\n const callbacks = {\r\n getCurrentPrice: render.getCurrentPrice,\r\n recalculateFinancials: finance.recalculateFinancials,\r\n state,\r\n updatePercentageLabels: render.updatePercentageLabels,\r\n updatePriceLabel: render.updatePriceLabel,\r\n updateState,\r\n };\r\n\r\n const priceElement = document.getElementById(\"prop-price\");\r\n setupPriceClickHandler(priceElement, priceElement?.closest(\".metric\")?.querySelector(\".metric-label\"), callbacks);\r\n\r\n const capElement = document.getElementById(\"prop-cap\");\r\n setupCapRateClickHandler(capElement, capElement?.closest(\".metric\")?.querySelector(\".metric-label\"), callbacks);\r\n\r\n const downElement = document.getElementById(\"prop-down\");\r\n setupDownPaymentClickHandler(downElement, downElement?.closest(\".metric\")?.querySelector(\".metric-label\"), callbacks);\r\n\r\n const noiElement = document.getElementById(\"prop-noi\");\r\n setupNoiClickHandler(noiElement, noiElement?.closest(\".metric\")?.querySelector(\".metric-label\"), callbacks);\r\n setupAwningLinkHandler(document.getElementById(\"prop-noi-awning\"));\r\n\r\n setupDiscountButtonHandler(document.getElementById(\"ln-discount-btn\"), callbacks);\r\n }\r\n\r\n // Progressive fill for fields a site renders after first paint (see LATE_FIELD_* above).\r\n // Re-reads ONLY the scrape-derived display fields (contact, phone, listing date) via the pure\r\n // adapter.scrape() — never scrapeAndApply, so it touches no state and re-applies no cap rate —\r\n // and updates only those three elements; price/NOI/financials and all network calls are left\r\n // alone. Stops as soon as every field is present (so a server-rendered site like LoopNet, where\r\n // the first read already has them, never starts a poll), when the budget elapses, or when the\r\n // page navigated to another listing (guard). Whitespace is normalized here to match the\r\n // contract's single normalization point in finance.scrapeAndApply (e.g. a broker name that the\r\n // markup splits across lines).\r\n function watchLateFields(guard) {\r\n const isPresent = (value) => typeof value === \"string\" && value.trim() !== \"\" && value !== \"Not found\";\r\n\r\n const applyLateFields = () => {\r\n const data = adapter.scrape();\r\n if (!data) return false;\r\n const contact = normalizeWhitespace(data.contact);\r\n const phone = normalizeWhitespace(data.phone);\r\n const listingDate = normalizeWhitespace(data.listingDate);\r\n render.updateElement(\"prop-contact\", contact);\r\n render.updateElement(\"prop-phone\", phone);\r\n render.updateElement(\"prop-dom\", calculateDOM(listingDate));\r\n return isPresent(contact) && isPresent(phone) && isPresent(listingDate);\r\n };\r\n\r\n if (applyLateFields()) return;\r\n\r\n let remaining = Math.ceil(LATE_FIELD_TIMEOUT / LATE_FIELD_POLL_INTERVAL);\r\n const tick = () => {\r\n if (guard.isStale()) return;\r\n if (applyLateFields() || remaining-- <= 0) return;\r\n setTimeout(tick, LATE_FIELD_POLL_INTERVAL);\r\n };\r\n setTimeout(tick, LATE_FIELD_POLL_INTERVAL);\r\n }\r\n\r\n async function updateFooterData() {\r\n // The listing this run is for. On an SPA the page can navigate mid-flight; after each\r\n // await we drop out if the identity changed, so a stale run never writes onto another\r\n // listing's panel. On a full-reload site getListingId is stable, so isStale() is always\r\n // false and this is a no-op.\r\n const guard = createNavigationGuard(listingId);\r\n guard.capture();\r\n\r\n // Click-to-reveal any data gated behind a button (broker phone/email, OM access) so the\r\n // pure scrape() below reads it. Platform-declared (config.reveals); a no-op when absent.\r\n if (config.reveals?.length) {\r\n await runReveals(config.reveals);\r\n if (guard.isStale()) return;\r\n }\r\n\r\n const data = finance.scrapeAndApply();\r\n if (!data) {\r\n console.error(\"❌ Malformed listing data — missing a contract field, refusing to render\");\r\n render.updateElement(\"prop-name\", \"Data error — see console\");\r\n return;\r\n }\r\n\r\n const unitCount = data.unitCount ?? 4;\r\n updateState({ numberOfUnits: unitCount });\r\n const unitsInput = document.getElementById(\"ln-units-input\");\r\n if (unitsInput) unitsInput.value = unitCount;\r\n\r\n syncInterestRateForUnits(state, updateState, unitCount);\r\n\r\n render.updateElement(\"prop-name\", data.name);\r\n // Display guard (H2): a defaulted price shows \"No price\"; the metrics fall through to N/A.\r\n render.updateElement(\"prop-price\", state.priceWasDefaulted ? \"No price\" : data.price);\r\n render.updateElement(\"prop-contact\", data.contact);\r\n render.updateElement(\"prop-phone\", data.phone);\r\n render.updateElement(\"prop-dom\", calculateDOM(data.listingDate));\r\n\r\n render.updatePriceLabel();\r\n render.updateCapRateLabel();\r\n render.syncUnitsFieldForType(state.currentPropertyType, data.bedroomCount);\r\n setupClickableElements(data);\r\n\r\n // Fields some sites render after first paint (agent contact/phone, listing date) start as\r\n // \"Not found\" above; fill them in progressively as they arrive without blocking what follows.\r\n watchLateFields(guard);\r\n\r\n const calculationCapRate = state.isUsingEstimatedCapRate ? `${state.currentEstimatedCapRate}%` : data.capRate;\r\n const financials = await calculateFinancials(ctx, data.price, calculationCapRate, state.currentPropertyType, data.name);\r\n if (guard.isStale()) return;\r\n render.applyFinancials(financials);\r\n render.updateActiveCapDisplay();\r\n\r\n const loiData = await services.loadLeadStatus(data.name);\r\n if (guard.isStale()) return;\r\n render.updateElement(\"prop-lead-status\", loiData.leadStatus);\r\n render.updateLeadStatusTooltip(loiData);\r\n\r\n // STR revenue seam: the footer already shows the 5.5%-of-price estimate. If the backend\r\n // returns real data, recompute the STR NOI with it. Dormant until that backend ships.\r\n const strResult = await services.loadStrValue(data.name, guard);\r\n if (guard.isStale()) return;\r\n if (strResult && state.currentPropertyType === \"str\") {\r\n updateState({ baseNOI: null });\r\n await finance.recalculateFinancials();\r\n if (guard.isStale()) return;\r\n }\r\n\r\n await services.loadDebt(data.name, guard);\r\n if (guard.isStale()) return;\r\n render.updateEquityDisplay();\r\n }\r\n\r\n // One running pipeline at a time. Re-runnable so the SPA watcher can rebuild per listing;\r\n // the observer is tracked so a re-run detaches the previous one.\r\n let footerUpdated = false;\r\n let pipelineObserver = null;\r\n\r\n function runPipeline() {\r\n footerUpdated = false;\r\n if (pipelineObserver) {\r\n pipelineObserver.disconnect();\r\n pipelineObserver = null;\r\n }\r\n\r\n createPanel({\r\n callbacks: {\r\n onExportClick: exportOps.handleExportClick,\r\n onInterestRateTypeChange: () => finance.recalculateFinancials(),\r\n onPropertyTypeChange: () => {\r\n finance.handlePropertyTypeChange();\r\n render.updateCapRateLabel();\r\n const listing = adapter.scrape();\r\n render.syncUnitsFieldForType(state.currentPropertyType, listing?.bedroomCount);\r\n finance.recalculateFinancials();\r\n },\r\n state,\r\n updateState,\r\n },\r\n cssUrls: resolveCssUrls(config.cssFiles),\r\n defaultPropertyType: config.defaultPropertyType,\r\n });\r\n\r\n const runUpdateOnce = async () => {\r\n if (footerUpdated) return;\r\n footerUpdated = true;\r\n await updateFooterData();\r\n };\r\n\r\n const stopObserver = () => {\r\n if (pipelineObserver) {\r\n pipelineObserver.disconnect();\r\n pipelineObserver = null;\r\n }\r\n };\r\n\r\n // The panel's own elements are built (createPanel's async append finished).\r\n const panelReady = () => {\r\n const nameEl = document.getElementById(\"prop-name\");\r\n const priceEl = document.getElementById(\"prop-price\");\r\n return !!(nameEl && priceEl && nameEl.textContent.trim() && priceEl.textContent.trim());\r\n };\r\n\r\n // The page exposes a real, scrapeable price (see DATA_READY_* above). Pure read — no state writes.\r\n const priceReady = () => {\r\n const listing = adapter.scrape();\r\n return !!listing && listing.price !== \"Not found\" && !listing.priceWasDefaulted;\r\n };\r\n\r\n // Run the main update once the panel is built AND the price is scrapeable. `force` (the timeout\r\n // path) commits even without a price so a price-less listing renders its honest no-price state.\r\n const tryImmediateUpdate = (force = false) => {\r\n if (!panelReady()) return false;\r\n if (!force && !priceReady()) return false;\r\n runUpdateOnce();\r\n return true;\r\n };\r\n\r\n if (tryImmediateUpdate()) return;\r\n\r\n pipelineObserver = new MutationObserver(() => {\r\n if (tryImmediateUpdate()) stopObserver();\r\n });\r\n pipelineObserver.observe(document.body, { childList: true, subtree: true });\r\n\r\n // Bounded fallback for SPA overlays (already readyState \"complete\", so the load event never\r\n // fires) and for listings whose price never paints: poll until the price is scrapeable, then\r\n // force the render at the timeout so the panel never hangs on \"Loading...\".\r\n let waited = 0;\r\n const fallbackPoll = () => {\r\n if (footerUpdated) return;\r\n if (tryImmediateUpdate(waited >= DATA_READY_TIMEOUT)) {\r\n stopObserver();\r\n return;\r\n }\r\n waited += DATA_READY_POLL_INTERVAL;\r\n setTimeout(fallbackPoll, DATA_READY_POLL_INTERVAL);\r\n };\r\n setTimeout(fallbackPoll, DATA_READY_POLL_INTERVAL);\r\n }\r\n\r\n return { runPipeline, updateFooterData };\r\n}\r\n"],"names":["createPipeline","adapter","config","ctx","exportOps","finance","render","resolveCssUrls","services","state","updateState","listingId","getListingId","window","location","href","async","updateFooterData","guard","createNavigationGuard","capture","reveals","length","runReveals","isStale","data","scrapeAndApply","console","error","updateElement","unitCount","numberOfUnits","unitsInput","document","getElementById","value","syncInterestRateForUnits","name","priceWasDefaulted","price","contact","phone","calculateDOM","listingDate","updatePriceLabel","updateCapRateLabel","syncUnitsFieldForType","currentPropertyType","bedroomCount","nameElement","style","cursor","textDecoration","onclick","searchUrl","encodeURIComponent","open","callbacks","getCurrentPrice","recalculateFinancials","updatePercentageLabels","priceElement","setupPriceClickHandler","closest","querySelector","capElement","setupCapRateClickHandler","downElement","setupDownPaymentClickHandler","noiElement","setupNoiClickHandler","setupAwningLinkHandler","setupDiscountButtonHandler","setupClickableElements","isPresent","trim","applyLateFields","scrape","normalizeWhitespace","remaining","Math","ceil","tick","setTimeout","watchLateFields","calculationCapRate","isUsingEstimatedCapRate","currentEstimatedCapRate","capRate","financials","calculateFinancials","applyFinancials","updateActiveCapDisplay","loiData","loadLeadStatus","leadStatus","updateLeadStatusTooltip","strResult","loadStrValue","baseNOI","loadDebt","updateEquityDisplay","footerUpdated","pipelineObserver","runPipeline","disconnect","createPanel","onExportClick","handleExportClick","onInterestRateTypeChange","onPropertyTypeChange","handlePropertyTypeChange","listing","cssUrls","cssFiles","defaultPropertyType","stopObserver","tryImmediateUpdate","force","nameEl","priceEl","textContent","panelReady","priceReady","runUpdateOnce","MutationObserver","observe","body","childList","subtree","waited","fallbackPoll"],"mappings":"unBAuCO,SAASA,gBAAeC,QAAEA,EAAOC,OAAEA,EAAMC,IAAEA,EAAGC,UAAEA,EAASC,QAAEA,EAAOC,OAAEA,EAAMC,eAAEA,EAAcC,SAAEA,IACjG,MAAMC,MAAEA,EAAKC,YAAEA,GAAgBP,EACzBQ,UAAY,IA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G,IACO,IAGT,GAAIP,qBAAsB,OAE1Bd,EAAmB,IAAIsB,iBAAiB,KAClCR,sBAAsBD,iBAE5Bb,EAAiBuB,QAAQ7F,SAAS8F,KAAM,CAAEC,WAAW,EAAMC,SAAS,IAKpE,IAAIC,EAAS,EACb,MAAMC,aAAe,KACf7B,IACAe,mBAAmBa,GArOF,KAsOnBd,gBAGFc,GAxO2B,IAyO3B/C,WAAWgD,aAzOgB,QA2O7BhD,WAAWgD,aA3OkB,IA4O/B,EAEsBlH,kCACxB"}
|
|
1
|
+
{"version":3,"file":"pipeline.js","sources":["../../../src/browser/widget/pipeline.js"],"sourcesContent":["// Pipeline unit: the re-runnable footer pipeline — builds the shared panel, wires the clickable\r\n// elements, runs the main async update (scrape -> financials -> lead status -> STR -> equity with\r\n// the navigation guard between awaits), and drives the immediate/observer/load entry points.\r\n// Extracted verbatim from createAnalyzer (T12).\r\n\r\nimport { createNavigationGuard } from \"./createNavigationGuard.js\";\r\nimport { createPanel } from \"./createPanel.js\";\r\nimport { runReveals } from \"./runReveals.js\";\r\nimport { syncInterestRateForUnits } from \"./interestRateSync.js\";\r\nimport {\r\n setupAwningLinkHandler,\r\n setupCapRateClickHandler,\r\n setupDiscountButtonHandler,\r\n setupDownPaymentClickHandler,\r\n setupNoiClickHandler,\r\n setupPriceClickHandler,\r\n} from \"../ui/click-handlers.js\";\r\nimport { calculateFinancials } from \"../financial/calculateFinancials.js\";\r\nimport { calculateDOM } from \"../../date/utilities.js\";\r\nimport { normalizeWhitespace } from \"../../formatting/text.js\";\r\n\r\n// Some sites (e.g. Zillow) client-render parts of a listing — the listing-agent attribution and\r\n// the price-history table — a beat AFTER first paint, so the pipeline's single initial scrape\r\n// reads \"Not found\" for the fields they carry (contact, phone, listing date). After the first\r\n// render we poll the pure scrape() for just those display fields and fill them in as they arrive,\r\n// until all are present or this budget elapses. Poll-count based (like runReveals' waitForSelector)\r\n// so it stays bounded and predictable under heavy DOM churn.\r\nconst LATE_FIELD_TIMEOUT = 10000;\r\nconst LATE_FIELD_POLL_INTERVAL = 300;\r\n\r\n// The main render waits for the page to expose a scrapeable PRICE before it commits — price is the\r\n// field every financial metric derives from. On a full page load the server-rendered JSON-LD has it\r\n// immediately; on an SPA overlay (Zillow search -> listing) it is client-painted a beat after the\r\n// navigation fires, so an eager scrape would read no price and paint N/A everywhere with no recovery.\r\n// If the price never becomes scrapeable (a genuinely price-less/off-market listing) the timeout lets\r\n// the render proceed anyway, so the panel never hangs on \"Loading...\" — it shows the honest no-price state.\r\nconst DATA_READY_TIMEOUT = 8000;\r\nconst DATA_READY_POLL_INTERVAL = 300;\r\n\r\nexport function createPipeline({ adapter, config, ctx, exportOps, finance, render, resolveCssUrls, services }) {\r\n const { state, updateState } = ctx;\r\n const listingId = () => adapter.getListingId(window.location.href);\r\n\r\n function setupClickableElements(data) {\r\n const nameElement = document.getElementById(\"prop-name\");\r\n if (nameElement && data.name && data.name !== \"Not found\") {\r\n nameElement.style.cursor = \"pointer\";\r\n nameElement.style.textDecoration = \"underline\";\r\n nameElement.onclick = () => {\r\n const searchUrl = `https://www.google.com/maps/search/${encodeURIComponent(data.name)}`;\r\n window.open(searchUrl, \"_blank\");\r\n };\r\n }\r\n\r\n // The shared click-handlers read callbacks.state / callbacks.updateState — the engine's\r\n // ctx is injected here (no global-state coupling).\r\n const callbacks = {\r\n getCurrentPrice: render.getCurrentPrice,\r\n recalculateFinancials: finance.recalculateFinancials,\r\n state,\r\n updatePercentageLabels: render.updatePercentageLabels,\r\n updatePriceLabel: render.updatePriceLabel,\r\n updateState,\r\n };\r\n\r\n const priceElement = document.getElementById(\"prop-price\");\r\n setupPriceClickHandler(priceElement, priceElement?.closest(\".metric\")?.querySelector(\".metric-label\"), callbacks);\r\n\r\n const capElement = document.getElementById(\"prop-cap\");\r\n setupCapRateClickHandler(capElement, capElement?.closest(\".metric\")?.querySelector(\".metric-label\"), callbacks);\r\n\r\n const downElement = document.getElementById(\"prop-down\");\r\n setupDownPaymentClickHandler(downElement, downElement?.closest(\".metric\")?.querySelector(\".metric-label\"), callbacks);\r\n\r\n const noiElement = document.getElementById(\"prop-noi\");\r\n setupNoiClickHandler(noiElement, noiElement?.closest(\".metric\")?.querySelector(\".metric-label\"), callbacks);\r\n setupAwningLinkHandler(document.getElementById(\"prop-noi-awning\"));\r\n\r\n setupDiscountButtonHandler(document.getElementById(\"ln-discount-btn\"), callbacks);\r\n }\r\n\r\n // Progressive fill for fields a site renders after first paint (see LATE_FIELD_* above).\r\n // Re-reads ONLY the scrape-derived display fields (contact, phone, listing date) via the pure\r\n // adapter.scrape() — never scrapeAndApply, so it touches no state and re-applies no cap rate —\r\n // and updates only those three elements; price/NOI/financials and all network calls are left\r\n // alone. Stops as soon as every field is present (so a server-rendered site like LoopNet, where\r\n // the first read already has them, never starts a poll), when the budget elapses, or when the\r\n // page navigated to another listing (guard). Whitespace is normalized here to match the\r\n // contract's single normalization point in finance.scrapeAndApply (e.g. a broker name that the\r\n // markup splits across lines).\r\n function watchLateFields(guard) {\r\n const isPresent = (value) => typeof value === \"string\" && value.trim() !== \"\" && value !== \"Not found\";\r\n\r\n const applyLateFields = () => {\r\n const data = adapter.scrape();\r\n if (!data) return false;\r\n const contact = normalizeWhitespace(data.contact);\r\n const phone = normalizeWhitespace(data.phone);\r\n const listingDate = normalizeWhitespace(data.listingDate);\r\n render.updateElement(\"prop-contact\", contact);\r\n render.updateElement(\"prop-phone\", phone);\r\n render.updateElement(\"prop-dom\", calculateDOM(listingDate));\r\n return isPresent(contact) && isPresent(phone) && isPresent(listingDate);\r\n };\r\n\r\n if (applyLateFields()) return;\r\n\r\n // A reveal's trigger (e.g. LoopNet's \"Call\" button) can render AFTER the one-shot runReveals\r\n // in updateFooterData fired — the broker CTA paints a beat after price/title — so the gated\r\n // field (phone) is never clicked into the DOM and the scrape poll above finds nothing to fill.\r\n // Re-run the idempotent reveals alongside the poll: runReveals no-ops once its waitFor target\r\n // is present, so this clicks each trigger at most once. The overlap guard prevents a second\r\n // click during the window between the first click and the revealed content appearing.\r\n let revealing = false;\r\n const retryReveals = () => {\r\n if (revealing || !config.reveals?.length) return;\r\n revealing = true;\r\n runReveals(config.reveals).finally(() => {\r\n revealing = false;\r\n });\r\n };\r\n\r\n let remaining = Math.ceil(LATE_FIELD_TIMEOUT / LATE_FIELD_POLL_INTERVAL);\r\n const tick = () => {\r\n if (guard.isStale()) return;\r\n retryReveals();\r\n if (applyLateFields() || remaining-- <= 0) return;\r\n setTimeout(tick, LATE_FIELD_POLL_INTERVAL);\r\n };\r\n setTimeout(tick, LATE_FIELD_POLL_INTERVAL);\r\n }\r\n\r\n async function updateFooterData() {\r\n // The listing this run is for. On an SPA the page can navigate mid-flight; after each\r\n // await we drop out if the identity changed, so a stale run never writes onto another\r\n // listing's panel. On a full-reload site getListingId is stable, so isStale() is always\r\n // false and this is a no-op.\r\n const guard = createNavigationGuard(listingId);\r\n guard.capture();\r\n\r\n // Click-to-reveal any data gated behind a button (broker phone/email, OM access) so the\r\n // pure scrape() below reads it. Platform-declared (config.reveals); a no-op when absent.\r\n if (config.reveals?.length) {\r\n await runReveals(config.reveals);\r\n if (guard.isStale()) return;\r\n }\r\n\r\n const data = finance.scrapeAndApply();\r\n if (!data) {\r\n console.error(\"❌ Malformed listing data — missing a contract field, refusing to render\");\r\n render.updateElement(\"prop-name\", \"Data error — see console\");\r\n return;\r\n }\r\n\r\n const unitCount = data.unitCount ?? 4;\r\n updateState({ numberOfUnits: unitCount });\r\n const unitsInput = document.getElementById(\"ln-units-input\");\r\n if (unitsInput) unitsInput.value = unitCount;\r\n\r\n syncInterestRateForUnits(state, updateState, unitCount);\r\n\r\n render.updateElement(\"prop-name\", data.name);\r\n // Display guard (H2): a defaulted price shows \"No price\"; the metrics fall through to N/A.\r\n render.updateElement(\"prop-price\", state.priceWasDefaulted ? \"No price\" : data.price);\r\n render.updateElement(\"prop-contact\", data.contact);\r\n render.updateElement(\"prop-phone\", data.phone);\r\n render.updateElement(\"prop-dom\", calculateDOM(data.listingDate));\r\n\r\n render.updatePriceLabel();\r\n render.updateCapRateLabel();\r\n render.syncUnitsFieldForType(state.currentPropertyType, data.bedroomCount);\r\n setupClickableElements(data);\r\n\r\n // Fields some sites render after first paint (agent contact/phone, listing date) start as\r\n // \"Not found\" above; fill them in progressively as they arrive without blocking what follows.\r\n watchLateFields(guard);\r\n\r\n const calculationCapRate = state.isUsingEstimatedCapRate ? `${state.currentEstimatedCapRate}%` : data.capRate;\r\n const financials = await calculateFinancials(ctx, data.price, calculationCapRate, state.currentPropertyType, data.name);\r\n if (guard.isStale()) return;\r\n render.applyFinancials(financials);\r\n render.updateActiveCapDisplay();\r\n\r\n const loiData = await services.loadLeadStatus(data.name);\r\n if (guard.isStale()) return;\r\n render.updateElement(\"prop-lead-status\", loiData.leadStatus);\r\n render.updateLeadStatusTooltip(loiData);\r\n\r\n // STR revenue seam: the footer already shows the 5.5%-of-price estimate. If the backend\r\n // returns real data, recompute the STR NOI with it. Dormant until that backend ships.\r\n const strResult = await services.loadStrValue(data.name, guard);\r\n if (guard.isStale()) return;\r\n if (strResult && state.currentPropertyType === \"str\") {\r\n updateState({ baseNOI: null });\r\n await finance.recalculateFinancials();\r\n if (guard.isStale()) return;\r\n }\r\n\r\n await services.loadDebt(data.name, guard);\r\n if (guard.isStale()) return;\r\n render.updateEquityDisplay();\r\n }\r\n\r\n // One running pipeline at a time. Re-runnable so the SPA watcher can rebuild per listing;\r\n // the observer is tracked so a re-run detaches the previous one.\r\n let footerUpdated = false;\r\n let pipelineObserver = null;\r\n\r\n function runPipeline() {\r\n footerUpdated = false;\r\n if (pipelineObserver) {\r\n pipelineObserver.disconnect();\r\n pipelineObserver = null;\r\n }\r\n\r\n createPanel({\r\n callbacks: {\r\n onExportClick: exportOps.handleExportClick,\r\n onInterestRateTypeChange: () => finance.recalculateFinancials(),\r\n onPropertyTypeChange: () => {\r\n finance.handlePropertyTypeChange();\r\n render.updateCapRateLabel();\r\n const listing = adapter.scrape();\r\n render.syncUnitsFieldForType(state.currentPropertyType, listing?.bedroomCount);\r\n finance.recalculateFinancials();\r\n },\r\n state,\r\n updateState,\r\n },\r\n cssUrls: resolveCssUrls(config.cssFiles),\r\n defaultPropertyType: config.defaultPropertyType,\r\n });\r\n\r\n const runUpdateOnce = async () => {\r\n if (footerUpdated) return;\r\n footerUpdated = true;\r\n await updateFooterData();\r\n };\r\n\r\n const stopObserver = () => {\r\n if (pipelineObserver) {\r\n pipelineObserver.disconnect();\r\n pipelineObserver = null;\r\n }\r\n };\r\n\r\n // The panel's own elements are built (createPanel's async append finished).\r\n const panelReady = () => {\r\n const nameEl = document.getElementById(\"prop-name\");\r\n const priceEl = document.getElementById(\"prop-price\");\r\n return !!(nameEl && priceEl && nameEl.textContent.trim() && priceEl.textContent.trim());\r\n };\r\n\r\n // The page exposes a real, scrapeable price (see DATA_READY_* above). Pure read — no state writes.\r\n const priceReady = () => {\r\n const listing = adapter.scrape();\r\n return !!listing && listing.price !== \"Not found\" && !listing.priceWasDefaulted;\r\n };\r\n\r\n // Run the main update once the panel is built AND the price is scrapeable. `force` (the timeout\r\n // path) commits even without a price so a price-less listing renders its honest no-price state.\r\n const tryImmediateUpdate = (force = false) => {\r\n if (!panelReady()) return false;\r\n if (!force && !priceReady()) return false;\r\n runUpdateOnce();\r\n return true;\r\n };\r\n\r\n if (tryImmediateUpdate()) return;\r\n\r\n pipelineObserver = new MutationObserver(() => {\r\n if (tryImmediateUpdate()) stopObserver();\r\n });\r\n pipelineObserver.observe(document.body, { childList: true, subtree: true });\r\n\r\n // Bounded fallback for SPA overlays (already readyState \"complete\", so the load event never\r\n // fires) and for listings whose price never paints: poll until the price is scrapeable, then\r\n // force the render at the timeout so the panel never hangs on \"Loading...\".\r\n let waited = 0;\r\n const fallbackPoll = () => {\r\n if (footerUpdated) return;\r\n if (tryImmediateUpdate(waited >= DATA_READY_TIMEOUT)) {\r\n stopObserver();\r\n return;\r\n }\r\n waited += DATA_READY_POLL_INTERVAL;\r\n setTimeout(fallbackPoll, DATA_READY_POLL_INTERVAL);\r\n };\r\n setTimeout(fallbackPoll, DATA_READY_POLL_INTERVAL);\r\n }\r\n\r\n return { runPipeline, updateFooterData };\r\n}\r\n"],"names":["createPipeline","adapter","config","ctx","exportOps","finance","render","resolveCssUrls","services","state","updateState","listingId","getListingId","window","location","href","watchLateFields","guard","isPresent","value","trim","applyLateFields","data","scrape","contact","normalizeWhitespace","phone","listingDate","updateElement","calculateDOM","revealing","remaining","Math","ceil","tick","isStale","reveals","length","runReveals","finally","setTimeout","async","updateFooterData","createNavigationGuard","capture","scrapeAndApply","console","error","unitCount","numberOfUnits","unitsInput","document","getElementById","syncInterestRateForUnits","name","priceWasDefaulted","price","updatePriceLabel","updateCapRateLabel","syncUnitsFieldForType","currentPropertyType","bedroomCount","nameElement","style","cursor","textDecoration","onclick","searchUrl","encodeURIComponent","open","callbacks","getCurrentPrice","recalculateFinancials","updatePercentageLabels","priceElement","setupPriceClickHandler","closest","querySelector","capElement","setupCapRateClickHandler","downElement","setupDownPaymentClickHandler","noiElement","setupNoiClickHandler","setupAwningLinkHandler","setupDiscountButtonHandler","setupClickableElements","calculationCapRate","isUsingEstimatedCapRate","currentEstimatedCapRate","capRate","financials","calculateFinancials","applyFinancials","updateActiveCapDisplay","loiData","loadLeadStatus","leadStatus","updateLeadStatusTooltip","strResult","loadStrValue","baseNOI","loadDebt","updateEquityDisplay","footerUpdated","pipelineObserver","runPipeline","disconnect","createPanel","onExportClick","handleExportClick","onInterestRateTypeChange","onPropertyTypeChange","handlePropertyTypeChange","listing","cssUrls","cssFiles","defaultPropertyType","stopObserver","tryImmediateUpdate","force","nameEl","priceEl","textContent","panelReady","priceReady","runUpdateOnce","MutationObserver","observe","body","childList","subtree","waited","fallbackPoll"],"mappings":"unBAuCO,SAASA,gBAAeC,QAAEA,EAAOC,OAAEA,EAAMC,IAAEA,EAAGC,UAAEA,EAASC,QAAEA,EAAOC,OAAEA,EAAMC,eAAEA,EAAcC,SAAEA,IACjG,MAAMC,M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